diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/CREDITS linux-2.4.22-pre2/CREDITS
--- linux-2.4.21/CREDITS	2003-06-26 21:45:04.000000000 +0000
+++ linux-2.4.22-pre2/CREDITS	2003-06-26 21:43:12.000000000 +0000
@@ -1512,6 +1512,18 @@
 S: 8103 Rein
 S: Austria
 
+N: Mitsuru Kanda
+E: mk@linux-ipv6.org
+E: mk@isl.rdc.toshiba.co.jp
+E: mk@karaba.org
+W: http://www.karaba.org/~mk/
+P: 1024D/2EC7E30D 9A35 D378 F084 9EA4 EFBA  925B 1C93 B376 F0EF BE59
+D: IPsec, IPv6
+D: USAGI/WIDE Project, TOSHIBA CORPORATION
+S: 2-47-8, Takinogawa,
+S: Kita, Tokyo 114-0023
+S: Japan
+
 N: Jan Kara
 E: jack@atrey.karlin.mff.cuni.cz
 E: jack@suse.cz
@@ -2148,6 +2160,17 @@
 S: Richardson, Texas 75081
 S: USA
 
+N: Kazunori Miyazawa
+E: miyazawa@linux-ipv6.org
+E: Kazunori.Miyazawa@jp.yokogawa.com
+E: kazunori@miyazawa.org
+W: http://www.miyazawa.org/~kazunori/
+D: IPsec, IPv6
+D: USAGI/WIDE Project, Yokogawa Electric Corporation
+S: 2-20-4-203, Nakacho,
+S: Musashino, Tokyo 180-0006
+S: Japan
+
 N: Patrick Mochel
 E: pat@osdl.org
 E: mochelp@infinity.powertie.org
@@ -2687,6 +2710,14 @@
 E: gt8134b@prism.gatech.edu
 D: Dosemu
 
+N: Duncan Sands
+E: duncan.sands@wanadoo.fr
+W: http://topo.math.u-psud.fr/~sands
+D: Alcatel SpeedTouch USB driver
+S: 69 rue Dunois
+S: 75013 Paris
+S: France
+
 N: Hannu Savolainen
 E: hannu@opensound.com
 D: Maintainer of the sound drivers until 2.1.x days.
@@ -3327,6 +3358,17 @@
 D: Workbit NinjaSCSI-32Bi/UDE driver
 S: Japan
 
+N: Hideaki YOSHIFUJI
+E: hideaki@yoshifuji.org
+E: yoshfuji@linux-ipv6.org
+W: http://www.yoshifuji.org/~hideaki/
+P: 1024D/E0620EEA 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA
+D: IPv6 and other networking related stuff
+D: USAGI/WIDE Project, The University of Tokyo
+S: Green House #102, 1-15-5, Nishikata, 
+S: Bunkyo, Tokyo 113-0024
+S: Japan
+
 N: Eric Youngdale
 E: eric@andante.org
 W: http://www.andante.org
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/Documentation/Configure.help linux-2.4.22-pre2/Documentation/Configure.help
--- linux-2.4.21/Documentation/Configure.help	2003-06-26 21:45:04.000000000 +0000
+++ linux-2.4.22-pre2/Documentation/Configure.help	2003-06-26 21:43:32.000000000 +0000
@@ -5476,11 +5476,6 @@
   handled by the klogd daemon which is responsible for kernel messages
   ("man klogd").
 
-Large routing tables
-CONFIG_IP_ROUTE_LARGE_TABLES
-  If you have routing zones that grow to more than about 64 entries,
-  you may want to say Y here to speed up the routing process.
-
 Fast network address translation
 CONFIG_IP_ROUTE_NAT
   If you say Y here, your router will be able to modify source and
@@ -6904,6 +6899,15 @@
   the performances of the driver, and the size of your syslog files!
   Keep the debugging level to 0 during normal operations.
 
+ForeRunner HE Series
+CONFIG_ATM_HE
+  This is a driver for the Marconi ForeRunner HE-series ATM adapter
+  cards. It simultaneously supports the 155 and 622 versions.
+
+Use S/UNI PHY driver
+  Support for the S/UNI-Ultra and S/UNI-622 found in the ForeRunner
+  HE cards.  This driver provides carrier detection some statistics.
+
 PPP over ATM
 CONFIG_PPPOATM
   Support PPP (Point to Point Protocol) encapsulated in ATM frames.
@@ -7290,47 +7294,40 @@
 
 Adaptec AIC7xxx support
 CONFIG_SCSI_AIC7XXX
-  This driver supports all of Adaptec's PCI based SCSI controllers
-  (not the hardware RAID controllers though) as well as the aic7770
-  based EISA and VLB SCSI controllers (the 274x and 284x series).
-  This is an Adaptec sponsored driver written by Justin Gibbs.  It is
-  intended to replace the previous aic7xxx driver maintained by Doug
-  Ledford since Doug is no longer maintaining that driver.
+  This driver supports all of Adaptec's Fast through Ultra 160 PCI
+  based SCSI controllers as well as the aic7770 based EISA and VLB
+  SCSI controllers (the 274x and 284x series).  For AAA and ARO based
+  configurations, only SCSI functionality is provided.
 
   If you want to compile the driver as a module ( = code which can be
   inserted in and removed from the running kernel whenever you want),
   say M here and read <file:Documentation/modules.txt>.  The module
   will be called aic7xxx.o.
 
-Adaptec I2O RAID support
-CONFIG_SCSI_DPT_I2O
-  This driver supports all of Adaptec's I2O based RAID controllers as 
-  well as the DPT SmartRaid V cards.  This is an Adaptec maintained
-  driver by Deanna Bonds.  See <file:drivers/scsi/README.dpti>.
-
-  This driver is also available as a module ( = code which can be
-  inserted in and removed from the running kernel whenever you want).
-  If you want to compile it as a module, say M here and read
-  <file:Documentation/modules.txt>.  The module will be called
-  dpt_i2o.o.
-
-Default number of TCQ commands per device
+Maximum number of TCQ commands per device
 CONFIG_AIC7XXX_CMDS_PER_DEVICE
   Specify the number of commands you would like to allocate per SCSI
   device when Tagged Command Queueing (TCQ) is enabled on that device.
 
   This is an upper bound value for the number of tagged transactions
   to be used for any device.  The aic7xxx driver will automatically
-  vary this number based on device behaviour.  For devices with a
+  vary this number based on device behavior.  For devices with a
   fixed maximum, the driver will eventually lock to this maximum
   and display a console message indicating this value.
 
-  Note: Unless you experience some type of device failure, the default
-	value, no enforced limit, should work for you.
+  Due to resource allocation issues in the Linux SCSI mid-layer, using
+  a high number of commands per device may result in memory allocation
+  failures when many devices are attached to the system.  For this reason,
+  the default is set to 32.  Higher values may result in higer performance
+  on some devices.  The upper bound is 253. 0 disables tagged queueing.
+
+  Per device tag depth can be controlled via the kernel command line
+  "tag_info" option.  See drivers/scsi/aic7xxx/README.aic7xxx
+  for details.
 
-  Default: 253
+  Default: 32
 
-Delay in seconds after SCSI bus reset
+Initial bus reset delay in milli-seconds
 CONFIG_AIC7XXX_RESET_DELAY_MS
   The number of milliseconds to delay after an initial bus reset.
   The bus settle delay following all error recovery actions is
@@ -7338,16 +7335,43 @@
 
   Default: 15000 (15 seconds)
 
-Build Adapter Firmware with Kernel Build
+Probe for EISA and VL AIC7XXX Adapters
+CONFIG_AIC7XXX_PROBE_EISA_VL
+   Probe for EISA and VLB Aic7xxx controllers.  In many newer systems,
+   the invasive probes necessary to detect these controllers can cause
+   other devices to fail.  For this reason, the non-PCI probe code is
+   disabled by default.  The current value of this option can be "toggled"
+   via the no_probe kernel command line option.
+
 CONFIG_AIC7XXX_BUILD_FIRMWARE
   This option should only be enabled if you are modifying the firmware
   source to the aic7xxx driver and wish to have the generated firmware
   include files updated during a normal kernel build.  The assembler
   for the firmware requires lex and yacc or their equivalents, as well
   as the db v1 library.  You may have to install additional packages
-  or modify the assembler make file or the files it includes if your
+  or modify the assembler Makefile or the files it includes if your
   build environment is different than that of the author.
 
+Compile in Debugging Code
+CONFIG_AIC7XXX_DEBUG_ENABLE
+  Compile in aic7xxx debugging code that can be useful in diagnosing
+  driver errors.
+
+Debug code enable mask (2048 for all debugging)
+CONFIG_AIC7XXX_DEBUG_MASK
+  Bit mask of debug options that is only valid if the
+  CONFIG_AIC7XXX_DEBUG_ENBLE option is enabled.  The bits in this mask
+  are defined in the drivers/scsi/aic7xxx/aic7xxx.h - search for the
+  variable ahc_debug in that file to find them.
+
+  Default: 0
+
+Decode registers during diagnostics
+CONFIG_AIC7XXX_REG_PRETTY_PRINT
+  Compile in register value tables for the output of expanded register
+  contents in diagnostics.  This make it much easier to understand debug
+  output without having to refer to a data book and/or the aic7xxx.reg file.
+
 Old Adaptec AIC7xxx support
 CONFIG_SCSI_AIC7XXX_OLD
   WARNING This driver is an older aic7xxx driver and is no longer
@@ -7456,6 +7480,83 @@
 
   If unsure, say N.
 
+CONFIG_SCSI_AIC79XX
+  This driver supports all of Adaptec's Ultra 320 PCI-X based SCSI controllers.
+
+CONFIG_AIC79XX_CMDS_PER_DEVICE 32
+  Specify the number of commands you would like to allocate per SCSI
+  device when Tagged Command Queueing (TCQ) is enabled on that device.
+
+  This is an upper bound value for the number of tagged transactions
+  to be used for any device.  The aic7xxx driver will automatically
+  vary this number based on device behavior.  For devices with a
+  fixed maximum, the driver will eventually lock to this maximum
+  and display a console message indicating this value.
+
+  Due to resource allocation issues in the Linux SCSI mid-layer, using
+  a high number of commands per device may result in memory allocation
+  failures when many devices are attached to the system.  For this reason,
+  the default is set to 32.  Higher values may result in higer performance
+  on some devices.  The upper bound is 253.
+
+  Per device tag depth can be controlled via the kernel command line
+  "tag_info" option.  See drivers/scsi/aic7xxx/README.aic79xx
+  for details.
+
+  Default: 32
+
+CONFIG_AIC79XX_RESET_DELAY_MS 15000
+  The number of milliseconds to delay after an initial bus reset.
+  The bus settle delay following all error recovery actions is
+  dictated by the SCSI layer and is not affected by this value.
+
+  Default: 15000 (15 seconds)
+
+CONFIG_AIC79XX_BUILD_FIRMWARE
+  This option should only be enabled if you are modifying the firmware
+  source to the aic7xxx driver and wish to have the generated firmware
+  include files updated during a normal kernel build.  The assembler
+  for the firmware requires lex and yacc or their equivalents, as well
+  as the db v1 library.  You may have to install additional packages
+  or modify the assembler Makefile or the files it includes if your
+  build environment is different than that of the author.
+
+CONFIG_AIC79XX_ENABLE_RD_STRM
+  Read Streaming is a U320 protocol option that should enhance performance.
+  Early U320 drive firmware actually performs slower with read streaming
+  enabled so it is disabled by default.  Read Streaming can be configured
+  in much the same way as tagged queueing using the "rd_strm" command line
+  option.  See drivers/scsi/aic7xxx/README.aic79xx for details.
+
+CONFIG_AIC79XX_DEBUG_ENABLE
+  Compile in aic79xx debugging code that can be useful in diagnosing
+  driver errors.
+
+CONFIG_AIC79XX_DEBUG_MASK
+  Bit mask of debug options that is only valid if the
+  CONFIG_AIC79XX_DEBUG_ENBLE option is enabled.  The bits in this mask
+  are defined in the drivers/scsi/aic7xxx/aic79xx.h - search for the
+  variable ahd_debug in that file to find them.
+
+  Default: 0
+
+CONFIG_AIC79XX_REG_PRETTY_PRINT
+  Compile in register value tables for the output of expanded register
+  contents in diagnostics.  This make it much easier to understand debug
+  output without having to refer to a data book and/or the aic7xxx.reg file.
+
+Adaptec I2O RAID support
+CONFIG_SCSI_DPT_I2O
+  This driver supports all of Adaptec's I2O based RAID controllers as 
+  well as the DPT SmartRaid V cards.  This is an Adaptec maintained
+  driver by Deanna Bonds.  See <file:drivers/scsi/README.dpti>.
+
+  This driver is also available as a module ( = code which can be
+  inserted in and removed from the running kernel whenever you want).
+  If you want to compile it as a module, say M here and read
+  <file:Documentation/modules.txt>.  The module will be called
+  dpt_i2o.o.
+
 IBM ServeRAID support
 CONFIG_SCSI_IPS
   This is support for the IBM ServeRAID hardware RAID controllers.
@@ -11861,15 +11962,6 @@
   module, say M here and read <file:Documentation/modules.txt> as well
   as <file:Documentation/networking/net-modules.txt>.
 
-New Tulip bus configuration
-CONFIG_TULIP_MWI 
-  This configures your Tulip card specifically for the card and
-  system cache line size type you are using.
-
-  This is experimental code, not yet tested on many boards.
-
-  If unsure, say N.
-
 Use PCI shared memory for NIC registers
 CONFIG_TULIP_MMIO
   Use PCI shared memory for the NIC registers, rather than going through 
@@ -13919,11 +14011,12 @@
   The module will be called powermate.o. If you want to compile it as a
   module, say M here and read <file:Documentation/modules.txt>.
 
-Aiptek 6000U/8000U tablet support
+Aiptek HyperPen tablet support
 CONFIG_USB_AIPTEK
-  Say Y here if you want to use the USB version of the Aiptek 6000U/8000U
-  tablet.  Make sure to say Y to "Event interface support"
-  (CONFIG_INPUT_EVDEV) as well.
+  Say Y here if you want to use the USB version of the Aiptek HyperPen
+  Digital Tablet (models 4000U, 5000U, 6000U, 8000U, and 12000U.)
+  Make sure to say Y to "Mouse support" (CONFIG_INPUT_MOUSEDEV) and/or
+  "Event interface support" (CONFIG_INPUT_EVDEV) as well.
 
   This driver is also available as a module ( = code which can be
   inserted in and removed from the running kernel whenever you want).
@@ -14620,6 +14713,24 @@
   The module will be called catc.o. If you want to compile it as a
   module, say M here and read <file:Documentation/modules.txt>.
 
+USB ASIX AX88172 based ethernet device support
+CONFIG_USB_AX8817X
+  Say Y if you want to use one of the following 10/100 USB2 Ethernet
+  devices based on the ASIX AX88172 chip.  Supported devices are:
+    Linksys USB200M
+    Netgear FA120
+    D-Link DUB-E100
+    Hawking UF200
+
+  This driver makes the adapter appear as a normal Ethernet interface,
+  typically on eth0, if it is the only ethernet device, or perhaps on
+  eth1, if you have a PCI or ISA ethernet card installed.
+
+  This code is also available as a module ( = code which can be
+  inserted in and removed from the running kernel whenever you want).
+  The module will be called ax8817x.o. If you want to compile it as a
+  module, say M here and read <file:Documentation/modules.txt>.
+
 USB Kodak DC-2xx Camera support
 CONFIG_USB_DC2XX
   Say Y here if you want to connect this type of still camera to your
@@ -14903,6 +15014,17 @@
   The module will be called dsbr100.o. If you want to compile it as a
   module, say M here and read <file:Documentation/modules.txt>.
 
+Alcatel Speedtouch USB support
+CONFIG_USB_SPEEDTOUCH
+  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.
+
+  This code is also available as a module ( = code which can be
+  inserted in and removed from the running kernel whenever you want).
+  The module will be called speedtch.o. If you want to compile it as
+  a module, say M here and read <file:Documentation/modules.txt>.
+
 Always do synchronous disk IO for UBD
 CONFIG_BLK_DEV_UBD_SYNC
   The User-Mode Linux port includes a driver called UBD which will let
@@ -18602,6 +18724,20 @@
   The ACPI Sourceforge project may also be of interest:
   <http://sf.net/projects/acpi/>
 
+ACPI Processor Enumeration Only
+CONFIG_ACPI_HT_ONLY
+  This option enables limited ACPI support -- just enough to
+  enumerate processors from the ACPI Multiple APIC Description
+  Table (MADT).  Note that ACPI supports both logical (e.g. Hyper-
+  Threading) and physical processors, where the MultiProcessor
+  Specification (MPS) table only supports physical processors.
+
+  Full ACPI support (CONFIG_ACPI) is preferred.  Use this option
+  only if you wish to limit ACPI's role to processor enumeration.
+
+  In this configuration, ACPI defaults to off. It must be enabled
+  on the command-line with the "acpismp=force" option.
+
 Enable ACPI 2.0 with errata 1.3
 CONFIG_ACPI20
   Enable support for the 2.0 version of the ACPI interpreter.  See the
@@ -18643,6 +18779,20 @@
   down the system.  Until then, you can cat it, and see output when
   a button is pressed.
 
+CONFIG_ACPI_BATTERY
+  This driver adds support for battery information through
+  /proc/acpi/battery. If you have a mobile system with a battery, 
+  say Y.
+
+CONFIG_ACPI_FAN
+  This driver adds support for ACPI fan devices, allowing user-mode 
+  applications to perform basic fan control (on, off, status).
+
+CONFIG_ACPI_PROCESSOR
+  This driver installs ACPI as the idle handler for Linux, and uses
+  ACPI C2 and C3 processor states to save power, on systems that
+  support it.
+
 ACPI AC Adapter
 CONFIG_ACPI_AC
   This driver adds support for the AC Adapter object, which indicates
@@ -18665,6 +18815,53 @@
   This driver handles overheating conditions on laptops. It is HIGHLY
   recommended, as your laptop CPU may be damaged without it.
 
+ACPI ASUS/Medion Laptop Extras
+CONFIG_ACPI_ASUS
+  This driver provides support for extra features of ACPI-compatible
+  ASUS laptops. As some of Medion laptops are made by ASUS, it may also
+  support some Medion laptops (such as 9675 for example).  It makes all
+  the extra buttons generate standard ACPI events that go through
+  /proc/acpi/events, and (on some models) adds support for changing the
+  display brightness and output, switching the LCD backlight on and off,
+  and most importantly, allows you to blink those fancy LEDs intended
+  for reporting mail and wireless status.
+  
+  All settings are changed via /proc/acpi/asus directory entries. Owner
+  and group for these entries can be set with asus_uid and asus_gid
+  parameters.
+  
+  More information and a userspace daemon for handling the extra buttons
+  at <http://sourceforge.net/projects/acpi4asus/>.
+  
+  If you have an ACPI-compatible ASUS laptop, say Y or M here. This
+  driver is still under development, so if your laptop is unsupported or
+  something works not quite as expected, please use the mailing list
+  available on the above page (acpi4asus-user@lists.sourceforge.net)
+  
+ACPI Toshiba Laptop Extras
+CONFIG_ACPI_TOSHIBA
+  This driver adds support for access to certain system settings
+  on "legacy free" Toshiba laptops.  These laptops can be recognized by
+  their lack of a BIOS setup menu and APM support.
+
+  On these machines, all system configuration is handled through the
+  ACPI.  This driver is required for access to controls not covered
+  by the general ACPI drivers, such as LCD brightness, video output,
+  etc.
+
+  This driver differs from the non-ACPI Toshiba laptop driver (located
+  under "Processor type and features") in several aspects.
+  Configuration is accessed by reading and writing text files in the
+  /proc tree instead of by program interface to /dev.  Furthermore, no
+  power management functions are exposed, as those are handled by the
+  general ACPI drivers.
+
+  More information about this driver is available at
+  <http://memebeam.org/toys/ToshibaAcpiDriver>.
+
+  If you have a legacy free Toshiba laptop (such as the Libretto L1
+  series), say Y.
+
 Advanced Power Management BIOS support
 CONFIG_APM
   APM is a BIOS specification for saving power using several different
@@ -20673,6 +20870,17 @@
   feature. See <file:Documentation/isdn/README.syncppp> and
   <file:Documentation/isdn/syncPPP.FAQ> for more information.
 
+PPP filtering for ISDN
+CONFIG_IPPP_FILTER
+  Say Y here if you want to be able to filter the packets passing over
+  IPPP interfaces.  This allows you to control which packets count as
+  activity (i.e. which packets will reset the idle timer or bring up
+  a demand-dialled link) and which packets are to be dropped entirely.
+  You need to say Y here if you wish to use the pass-filter and
+  active-filter options to ipppd.
+
+  If unsure, say N.
+
 Support generic MP (RFC 1717)
 CONFIG_ISDN_MPP
   With synchronous PPP enabled, it is possible to increase throughput
@@ -21521,6 +21729,7 @@
                SCO Module (SCO links)
                RFCOMM Module (RFCOMM protocol)
                BNEP Module (BNEP protocol)
+               CMTP Module (CMTP protocol)
 
   Say Y here to enable Linux Bluetooth support and to build BlueZ Core
   layer.
@@ -21575,6 +21784,15 @@
   Say Y here to compile BNEP support into the kernel or say M to
   compile it as module (bnep.o).
 
+CMTP protocol support
+CONFIG_BLUEZ_CMTP
+  CMTP (CAPI Message Transport Protocol) is a transport layer
+  for CAPI messages. CMTP is required for the Bluetooth Common
+  ISDN Access Profile.
+
+  Say Y here to compile CMTP support into the kernel or say M to
+  compile it as module (cmtp.o).
+
 BNEP multicast filter support
 CONFIG_BLUEZ_BNEP_MC_FILTER
   This option enables the multicast filter support for BNEP.
@@ -26649,6 +26867,13 @@
 CONFIG_IPMI_WATCHDOG
   This enables the IPMI watchdog timer.
 
+CRC32 functions
+CONFIG_CRC32
+  This option is provided for the case where no in-kernel-tree
+  modules require CRC32 functions, but a module built outside the
+  kernel tree does. Such modules that use library CRC32 functions
+  require that you say M or Y here.
+
 #
 # A couple of things I keep forgetting:
 #   capitalize: AppleTalk, Ethernet, DOS, DMA, FAT, FTP, Internet,
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/Documentation/filesystems/jfs.txt linux-2.4.22-pre2/Documentation/filesystems/jfs.txt
--- linux-2.4.21/Documentation/filesystems/jfs.txt	2003-06-26 21:45:04.000000000 +0000
+++ linux-2.4.22-pre2/Documentation/filesystems/jfs.txt	2003-06-26 21:43:27.000000000 +0000
@@ -4,10 +4,10 @@
 
 Team members
 ------------
-Steve Best         sbest@us.ibm.com
 Dave Kleikamp      shaggy@austin.ibm.com  
+Dave Blaschke      blaschke@us.ibm.com
+Steve Best         sbest@us.ibm.com
 Barry Arndt        barndt@us.ibm.com
-Christoph Hellwig  hch@infradead.org
 
 The following mount options are supported:
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/Documentation/filesystems/sysv-fs.txt linux-2.4.22-pre2/Documentation/filesystems/sysv-fs.txt
--- linux-2.4.21/Documentation/filesystems/sysv-fs.txt	1997-12-16 17:43:36.000000000 +0000
+++ linux-2.4.22-pre2/Documentation/filesystems/sysv-fs.txt	2003-06-26 21:43:10.000000000 +0000
@@ -23,8 +23,9 @@
   - Only file systems with no filesystem name and no pack name are recognized.
   (See Coherent "man mkfs" for a description of these features.)
 - SystemV Release 2 FS:
-  The superblock is only searched in the blocks 9, 15, 18, which corresponds to the
-  beginning of track 1 on floppy disks. No support for this FS on hard disk yet.
+  The superblock is only searched in the blocks 9, 15, 18, which
+  corresponds to the beginning of track 1 on floppy disks. No support
+  for this FS on hard disk yet.
 
 
 Please report any bugs and suggestions to
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/Documentation/kernel-parameters.txt linux-2.4.22-pre2/Documentation/kernel-parameters.txt
--- linux-2.4.21/Documentation/kernel-parameters.txt	2002-11-28 23:53:08.000000000 +0000
+++ linux-2.4.22-pre2/Documentation/kernel-parameters.txt	2003-06-26 21:43:22.000000000 +0000
@@ -341,6 +341,18 @@
 			memory; to be used when the kernel is not able
 			to see the whole system memory or for test.
 
+	mem=nn[KMG]@ss[KMG]
+			[KNL,BOOT] Force usage of a specific region of memory
+			Region of memory to be used, from ss to ss+nn.
+
+	mem=nn[KMG]#ss[KMG]
+			[KNL,BOOT,ACPI] Mark specific memory as ACPI data.
+			Region of memory to be used, from ss to ss+nn.
+
+	mem=nn[KMG]$ss[KMG]
+			[KNL,BOOT,ACPI] Mark specific memory as reserved.
+			Region of memory to be used, from ss to ss+nn.
+
 	memfrac=	[KNL]
 
 	mga=		[HW,DRM]
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/Documentation/networking/bonding.txt linux-2.4.22-pre2/Documentation/networking/bonding.txt
--- linux-2.4.21/Documentation/networking/bonding.txt	2003-06-26 21:45:04.000000000 +0000
+++ linux-2.4.22-pre2/Documentation/networking/bonding.txt	2003-06-26 21:43:14.000000000 +0000
@@ -43,10 +43,10 @@
 For the latest version of the bonding driver, use kernel 2.4.12 or above
 (otherwise you will need to apply a patch).
 
-Configure kernel with `make menuconfig/xconfig/config', and select
-"Bonding driver support" in the "Network device support" section. It is
-recommended to configure the driver as module since it is currently the only way
-to pass parameters to the driver and configure more than one bonding device.
+Configure kernel with `make menuconfig/xconfig/config', and select "Bonding
+driver support" in the "Network device support" section. It is recommended
+to configure the driver as module since it is currently the only way to
+pass parameters to the driver and configure more than one bonding device.
 
 Build and install the new kernel and modules.
 
@@ -108,17 +108,17 @@
 SLAVE=yes
 BOOTPROTO=none
 
-Use DEVICE=eth1 in the ifcfg-eth1 config file. If you configure a second bonding
-interface (bond1), use MASTER=bond1 in the config file to make the network
-interface be a slave of bond1.
+Use DEVICE=eth1 in the ifcfg-eth1 config file. If you configure a second
+bonding interface (bond1), use MASTER=bond1 in the config file to make the
+network interface be a slave of bond1.
 
 Restart the networking subsystem or just bring up the bonding device if your
 administration tools allow it. Otherwise, reboot. On Red Hat distros you can 
 issue `ifup bond0' or `/etc/rc.d/init.d/network restart'.
 
-If the administration tools of your distribution do not support master/slave
-notation in configuring network interfaces, you will need to manually configure 
-the bonding device with the following commands:
+If the administration tools of your distribution do not support
+master/slave notation in configuring network interfaces, you will need to
+manually configure the bonding device with the following commands:
 
     # /sbin/ifconfig bond0 192.168.1.1 netmask 255.255.255.0 \
       broadcast 192.168.1.255 up
@@ -166,8 +166,9 @@
      ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.127.0.0.1 = 1
 
 This problem is avoided by loading the bonding driver before any network
-drivers participating in a bond. Below is an example of loading the bonding 
-driver first, the IP address 192.168.1.1 is correctly associated with ifDescr.2.
+drivers participating in a bond. Below is an example of loading the bonding
+driver first, the IP address 192.168.1.1 is correctly associated with
+ifDescr.2.
 
      interfaces.ifTable.ifEntry.ifDescr.1 = lo
      interfaces.ifTable.ifEntry.ifDescr.2 = bond0
@@ -200,6 +201,44 @@
 parameters be specified, otherwise serious network degradation will occur
 during link failures.
 
+arp_interval
+ 
+        Specifies the ARP monitoring frequency in milli-seconds. 
+        If ARP monitoring is used in a load-balancing mode (mode 0 or 2), the 
+        switch should be configured in a mode that evenly distributes packets 
+        across all links - such as round-robin. If the switch is configured to 
+        distribute the packets in an XOR fashion, all replies from the ARP 
+        targets will be received on the same link which could cause the other 
+        team members to fail. ARP monitoring should not be used in conjunction
+        with miimon. A value of 0 disables ARP monitoring. The default value 
+        is 0.
+ 
+arp_ip_target
+ 
+	Specifies the ip addresses to use when arp_interval is > 0. These
+	are the targets of the ARP request sent to determine the health of
+	the link to the targets. Specify these values in ddd.ddd.ddd.ddd
+	format. Multiple ip adresses must be seperated by a comma. At least
+	one ip address needs to be given for ARP monitoring to work. The
+	maximum number of targets that can be specified is set at 16.
+
+downdelay
+ 
+        Specifies the delay time in milli-seconds to disable a link after a 
+        link failure has been detected. This should be a multiple of miimon
+        value, otherwise the value will be rounded. The default value is 0.
+
+lacp_rate
+
+        Option specifying the rate in which we'll ask our link partner to
+	transmit LACPDU packets in 802.3ad mode.  Possible values are:
+
+	slow or 0
+		Request partner to transmit LACPDUs every 30 seconds (default)
+
+	fast or 1
+		Request partner to transmit LACPDUs every 1 second
+
 max_bonds
 
 	Specifies the number of bonding devices to create for this
@@ -207,18 +246,27 @@
 	the bonding driver is not already loaded, then bond0, bond1
 	and bond2 will be created.  The default value is 1.
 
+miimon
+ 
+        Specifies the frequency in milli-seconds that MII link monitoring
+        will occur. A value of zero disables MII link monitoring. A value
+        of 100 is a good starting point. See High Availability section for
+        additional information. The default value is 0.
+
 mode
 
-	Specifies one of four bonding policies. The default is
-round-robin (balance-rr).  Possible values are (you can use either the
-text or numeric option):
+	Specifies one of the bonding policies. The default is
+	round-robin (balance-rr).  Possible values are (you can use
+	either the text or numeric option):
  
 	balance-rr or 0
+
 		Round-robin policy: Transmit in a sequential order
 		from the first available slave through the last. This
 		mode provides load balancing and fault tolerance.
 
 	active-backup or 1
+
 		Active-backup policy: Only one slave in the bond is
 		active. A different slave becomes active if, and only
 		if, the active slave fails. The bond's MAC address is
@@ -226,7 +274,8 @@
 		to avoid confusing the switch.  This mode provides
 		fault tolerance.
  
-        balance-xor or 2
+	balance-xor or 2
+
 		XOR policy: Transmit based on [(source MAC address
 		XOR'd with destination MAC address) modula slave
 		count]. This selects the same slave for each
@@ -234,16 +283,125 @@
 		balancing and fault tolerance.
 
 	broadcast or 3
+
 		Broadcast policy: transmits everything on all slave
 		interfaces. This mode provides fault tolerance.
 
-miimon
- 
-        Specifies the frequency in milli-seconds that MII link monitoring will 
-        occur. A value of zero disables MII link monitoring. A value of 
-        100 is a good starting point. See High Availability section for 
-        additional information. The default value is 0.
+	802.3ad or 4
+
+		IEEE 802.3ad Dynamic link aggregation. Creates aggregation
+		groups that share the same speed and duplex settings.
+		Transmits and receives on all slaves in the active
+		aggregator.
+ 
+		Pre-requisites:
+
+		1. Ethtool support in the base drivers for retrieving the
+		speed and duplex of each slave.
+
+		2. A switch that supports IEEE 802.3ad Dynamic link
+		aggregation.
+
+	balance-tlb or 5
+
+		Adaptive transmit load balancing: channel bonding that does
+		not require any special switch support. The outgoing
+		traffic is distributed according to the current load
+		(computed relative to the speed) on each slave. Incoming
+		traffic is received by the current slave. If the receiving
+		slave fails, another slave takes over the MAC address of
+		the failed receiving slave.
+
+		Prerequisite:
+
+		Ethtool support in the base drivers for retrieving the
+		speed of each slave.
+
+	balance-alb or 6 
+
+		Adaptive load balancing: includes balance-tlb + receive
+		load balancing (rlb) for IPV4 traffic and does not require
+		any special switch support. The receive load balancing is
+		achieved by ARP negotiation. The bonding driver intercepts
+		the ARP Replies sent by the server on their way out and
+		overwrites the src hw address with the unique hw address of
+		one of the slaves in the bond such that different clients
+		use different hw addresses for the server.
+		
+		Receive traffic from connections created by the server is
+		also balanced. When the server sends an ARP Request the
+		bonding driver copies and saves the client's IP information
+		from the ARP. When the ARP Reply arrives from the client,
+		its hw address is retrieved and the bonding driver
+		initiates an ARP reply to this client assigning it to one
+		of the slaves in the bond. A problematic outcome of using
+		ARP negotiation for balancing is that each time that an ARP
+		request is broadcasted it uses the hw address of the
+		bond. Hence, clients learn the hw address of the bond and
+		the balancing of receive traffic collapses to the current
+		salve. This is handled by sending updates (ARP Replies) to
+		all the clients with their assigned hw address such that
+		the traffic is redistributed. Receive traffic is also
+		redistributed when a new slave is added to the bond and
+		when an inactive slave is re-activated. The receive load is
+		distributed sequentially (round robin) among the group of
+		highest speed slaves in the bond.
+
+		When a link is reconnected or a new slave joins the bond
+		the receive traffic is redistributed among all active
+		slaves in the bond by intiating ARP Replies with the
+		selected mac address to each of the clients. The updelay
+		modeprobe parameter must be set to a value equal or greater
+		than the switch's forwarding delay so that the ARP Replies
+		sent to the clients will not be blocked by the switch.
+
+		Prerequisites:
+
+		1. Ethtool support in the base drivers for retrieving the
+		speed of each slave.
+
+		2. Base driver support for setting the hw address of a
+		device also when it is open. This is required so that there
+		will always be one slave in the team using the bond hw
+		address (the current_slave) while having a unique hw
+		address for each slave in the bond. If the current_slave
+		fails it's hw address is swapped with the new current_slave
+		that was chosen.
+
+multicast
+
+        Option specifying the mode of operation for multicast support.
+        Possible values are:
+
+	disabled or 0
+		Disabled (no multicast support)
+
+        active or 1
+		Enabled on active slave only, useful in active-backup mode
+
+	all or 2
+		Enabled on all slaves, this is the default
+
+primary
+
+        A string (eth0, eth2, etc) to equate to a primary device. If this
+        value is entered, and the device is on-line, it will be used first
+        as the output media. Only when this device is off-line, will
+        alternate devices be used. Otherwise, once a failover is detected
+        and a new default output is chosen, it will remain the output media
+        until it too fails. This is useful when one slave was preferred
+        over another, i.e. when one slave is 1000Mbps and another is
+        100Mbps. If the 1000Mbps slave fails and is later restored, it may
+        be preferred the faster slave gracefully become the active slave -
+        without deliberately failing the 100Mbps slave. Specifying a
+        primary is only valid in active-backup mode.
 
+updelay
+ 
+        Specifies the delay time in milli-seconds to enable a link after a 
+        link up status has been detected. This should be a multiple of miimon
+        value, otherwise the value will be rounded. The default value is 0.
+ 
 use_carrier
 
         Specifies whether or not miimon should use MII or ETHTOOL
@@ -265,89 +423,37 @@
         0 will use the deprecated MII / ETHTOOL ioctls.  The default
         value is 1.
 
-downdelay
- 
-        Specifies the delay time in milli-seconds to disable a link after a 
-        link failure has been detected. This should be a multiple of miimon
-        value, otherwise the value will be rounded. The default value is 0.
-
-updelay
- 
-        Specifies the delay time in milli-seconds to enable a link after a 
-        link up status has been detected. This should be a multiple of miimon
-        value, otherwise the value will be rounded. The default value is 0.
- 
-arp_interval
- 
-        Specifies the ARP monitoring frequency in milli-seconds. 
-        If ARP monitoring is used in a load-balancing mode (mode 0 or 2), the 
-        switch should be configured in a mode that evenly distributes packets 
-        across all links - such as round-robin. If the switch is configured to 
-        distribute the packets in an XOR fashion, all replies from the ARP 
-        targets will be received on the same link which could cause the other 
-        team members to fail. ARP monitoring should not be used in conjunction
-        with miimon. A value of 0 disables ARP monitoring. The default value 
-        is 0.
- 
-arp_ip_target
- 
-        Specifies the ip addresses to use when arp_interval is > 0. These are
-        the targets of the ARP request sent to determine the health of the link
-        to the targets. Specify these values in ddd.ddd.ddd.ddd format.
-        Multiple ip adresses must be seperated by a comma. At least one ip
-        address needs to be given for ARP monitoring to work. The maximum number
-        of targets that can be specified is set at 16.
-
-primary
-
-        A string (eth0, eth2, etc) to equate to a primary device. If this 
-        value is entered, and the device is on-line, it will be used first as 
-        the output media. Only when this device is off-line, will alternate 
-        devices be used. Otherwise, once a failover is detected and a new 
-        default output is chosen, it will remain the output media until it too 
-        fails. This is useful when one slave was preferred over another, i.e. 
-        when one slave is 1000Mbps and another is 100Mbps. If the 1000Mbps 
-        slave fails and is later restored, it may be preferred the faster slave
-        gracefully become the active slave - without deliberately failing the
-        100Mbps slave. Specifying a primary is only valid in active-backup mode.
-
-multicast
-
-        Option specifying the mode of operation for multicast support.
-        Possible values are:
-
-	disabled or 0
-		Disabled (no multicast support)
-
-        active or 1
-		Enabled on active slave only, useful in active-backup mode
-
-	all or 2
-		Enabled on all slaves, this is the default
-
 
 Configuring Multiple Bonds
 ==========================
 
-If several bonding interfaces are required, the driver must be loaded
-multiple times. For example, to configure two bonding interfaces with link 
-monitoring performed every 100 milli-seconds, the /etc/conf.modules should
+If several bonding interfaces are required, either specify the max_bonds
+parameter (described above), or load the driver multiple times.  Using
+the max_bonds parameter is less complicated, but has the limitation that
+all bonding instances created will have the same options.  Loading the
+driver multiple times allows each instance of the driver to have differing
+options.
+
+For example, to configure two bonding interfaces, one with mii link
+monitoring performed every 100 milliseconds, and one with ARP link
+monitoring performed every 200 milliseconds, the /etc/conf.modules should
 resemble the following:
 
 alias bond0 bonding
 alias bond1 bonding
 
 options bond0 miimon=100
-options bond1 -o bonding1 miimon=100
+options bond1 -o bonding1 arp_interval=200 arp_ip_target=10.0.0.1
 
 Configuring Multiple ARP Targets
 ================================
 
-While ARP monitoring can be done with just one target, it can be usefull
+While ARP monitoring can be done with just one target, it can be useful
 in a High Availability setup to have several targets to monitor. In the
 case of just one target,  the target itself may go down or have a problem
 making it unresponsive to ARP requests. Having an additional target (or
-several) would increase the reliability of the ARP monitoring.
+several) increases the reliability of the ARP monitoring.
+
 Multiple ARP targets must be seperated by commas as follows:
 
 # example options for ARP monitoring with three targets
@@ -410,9 +516,10 @@
 Switch Configuration
 ====================
 
-While the switch does not need to be configured when the active-backup
-policy is used (mode=1), it does need to be configured for the round-robin, 
-XOR, and broadcast policies (mode=0, mode=2, and mode=3). 
+While the switch does not need to be configured when the active-backup,
+balance-tlb or balance-alb policies (mode=1,5,6) are used, it does need to
+be configured for the round-robin, XOR, broadcast, or 802.3ad policies
+(mode=0,2,3,4).
 
 
 Verifying Bond Configuration
@@ -420,7 +527,7 @@
 
 1) Bonding information files
 ----------------------------
-The bonding driver information files reside in the /proc/net/bond* directories. 
+The bonding driver information files reside in the /proc/net/bond* directories.
 
 Sample contents of /proc/net/bond0/info after the driver is loaded with 
 parameters of mode=0 and miimon=1000 is shown below.
@@ -445,7 +552,8 @@
 The network configuration can be verified using the ifconfig command. In
 the example below, the bond0 interface is the master (MASTER) while eth0 and 
 eth1 are slaves (SLAVE). Notice all slaves of bond0 have the same MAC address 
-(HWaddr) as bond0.
+(HWaddr) as bond0 for all modes except TLB and ALB that require a unique MAC
+address for each slave.
 
 [root]# /sbin/ifconfig
 bond0     Link encap:Ethernet  HWaddr 00:C0:F0:1F:37:B4  
@@ -488,8 +596,7 @@
 
 3.  How many bonding devices can I have?
 
-	One for each module you load. See section on Module Parameters for how
-	to accomplish this.
+	There is no limit.
 
 4.  How many slaves can a bonding device have?
 
@@ -508,10 +615,11 @@
 	For ethernet cards not supporting MII status, the arp_interval and
         arp_ip_target parameters must be specified for bonding to work
         correctly. If packets have not been sent or received during the
-        specified arp_interval durration, an ARP request is sent to the targets 
-        to generate send and receive traffic. If after this interval, either 
-        the successful send and/or receive count has not incremented, the next 
-        slave in the sequence will become the active slave.
+        specified arp_interval durration, an ARP request is sent to the
+        targets to generate send and receive traffic. If after this
+        interval, either the successful send and/or receive count has not
+        incremented, the next slave in the sequence will become the active
+        slave.
 
 	If neither mii_monitor and arp_interval is configured, the bonding
 	driver will not handle this situation very well. The driver will 
@@ -522,15 +630,16 @@
 
 6.  Can bonding be used for High Availability?
 
-	Yes, if you use MII monitoring and ALL your cards support MII link
-	status reporting. See section on High Availability for more information.
+        Yes, if you use MII monitoring and ALL your cards support MII link
+        status reporting. See section on High Availability for more
+        information.
 
 7.  Which switches/systems does it work with?
 
 	In round-robin and XOR mode, it works with systems that support 
 	trunking:
 	
-	* Cisco 5500 series (look for EtherChannel support).
+	* Many Cisco switches and routers (look for EtherChannel support).
 	* SunTrunking software.
 	* Alteon AceDirector switches / WebOS (use Trunks).
 	* BayStack Switches (trunks must be explicitly configured). Stackable
@@ -538,7 +647,17 @@
 	  units.
 	* Linux bonding, of course !
 	
-	In active-backup mode, it should work with any Layer-II switche.
+	In 802.3ad mode, it works with with systems that support IEEE 802.3ad
+	Dynamic Link Aggregation:
+
+	* Extreme networks Summit 7i (look for link-aggregation).
+	* Many Cisco switches and routers (look for LACP support; this may
+	  require an upgrade to your IOS software; LACP support was added
+	  by Cisco in late 2002).
+	* Foundry Big Iron 4000
+
+        In active-backup, balance-tlb and balance-alb modes, it should work
+        with any Layer-II switch.
 
 
 8.  Where does a bonding device get its MAC address from?
@@ -591,6 +710,20 @@
 
 	Broadcast policy transmits everything on all slave interfaces.
 
+	802.3ad, based on XOR but distributes traffic among all interfaces
+	in the active aggregator.
+
+	Transmit load balancing (balance-tlb) balances the traffic
+	according to the current load on each slave. The balancing is
+	clients based and the least loaded slave is selected for each new
+	client. The load of each slave is calculated relative to its speed
+	and enables load balancing in mixed speed teams.
+
+	Adaptive load balancing (balance-alb) uses the Transmit load
+	balancing for the transmit load. The receive load is balanced only
+	among the group of highest speed active slaves in the bond. The
+	load is distributed with round-robin i.e. next available slave in
+	the high speed group of active slaves.
 
 High Availability
 =================
@@ -826,10 +959,6 @@
     Use the arp_interval/arp_ip_target parameters to count incoming/outgoing
     frames.  
 
-  - A Transmit Load Balancing policy is not currently available. This mode 
-    allows every slave in the bond to transmit while only one receives. If 
-    the "receiving" slave fails, another slave takes over the MAC address of 
-    the failed receiving slave.
 
 
 Resources and Links
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/Documentation/networking/ifenslave.c linux-2.4.22-pre2/Documentation/networking/ifenslave.c
--- linux-2.4.21/Documentation/networking/ifenslave.c	2003-06-26 21:45:04.000000000 +0000
+++ linux-2.4.22-pre2/Documentation/networking/ifenslave.c	2003-06-26 21:43:13.000000000 +0000
@@ -51,10 +51,51 @@
  *         multiple interfaces are specified on a single ifenslave command
  *         (ifenslave bond0 eth0 eth1).
  *
+ *    - 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
+ *                   Shmulik Hen <shmulik.hen at intel dot com>
+ *       - Moved setting the slave's mac address and openning it, from
+ *         the application to the driver. This enables support of modes
+ *         that need to use the unique mac address of each slave.
+ *         The driver also takes care of closing the slave and restoring its
+ *         original mac address upon release.
+ *         In addition, block possibility of enslaving before the master is up.
+ *         This prevents putting the system in an undefined state.
+ *
+ *    - 2003/05/01 - Amir Noam <amir.noam at intel dot com>
+ *       - Added ABI version control to restore compatibility between
+ *         new/old ifenslave and new/old bonding.
+ *       - Prevent adding an adapter that is already a slave.
+ *         Fixes the problem of stalling the transmission and leaving
+ *         the slave in a down state.
+ *
+ *    - 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
+ *       - Prevent enslaving if the bond device is down.
+ *         Fixes the problem of leaving the system in unstable state and
+ *         halting when trying to remove the module.
+ *       - Close socket on all abnormal exists.
+ *       - Add versioning scheme that follows that of the bonding driver.
+ *         current version is 1.0.0 as a base line.
+ *
+ *    - 2003/05/22 - Jay Vosburgh <fubar at us dot ibm dot com>
+ *	 - ifenslave -c was broken; it's now fixed
+ *	 - Fixed problem with routes vanishing from master during enslave
+ *	   processing.
+ *
+ *    - 2003/05/27 - Amir Noam <amir.noam at intel dot com>
+ *	 - Fix backward compatibility issue:
+ *	   For drivers not using ABI versions, slave was set down while
+ *	   it should be left up before enslaving.
+ * 	 - For opt_c: slave should not be set to the master's setting
+ *	   while it is runnig. It was already set during enslave. To
+ *	   simplify things, it is now handeled separately.
  */
 
+#define APP_VERSION	"1.0.11"
+#define APP_RELDATE	"May 29, 2003"
+#define APP_NAME	"ifenslave"
+
 static char *version =
-"ifenslave.c:v0.07 9/9/97  Donald Becker (becker@cesdis.gsfc.nasa.gov).\n"
+APP_NAME ".c:v" APP_VERSION " (" APP_RELDATE ") "  "\nDonald Becker (becker@cesdis.gsfc.nasa.gov).\n"
 "detach support added on 2000/10/02 by Willy Tarreau (willy at meta-x.org).\n"
 "2.4 kernel support added on 2001/02/16 by Chad N. Tindel (ctindel at ieee dot org.\n";
 
@@ -103,6 +144,12 @@
 #include <linux/if_bonding.h>
 #include <linux/sockios.h>
 
+typedef unsigned long long u64;	/* hack, so we may include kernel's ethtool.h */
+typedef __uint32_t u32;		/* ditto */
+typedef __uint16_t u16;		/* ditto */
+typedef __uint8_t u8;		/* ditto */
+#include <linux/ethtool.h>
+
 struct option longopts[] = {
  /* { name  has_arg  *flag  val } */
     {"all-interfaces", 0, 0, 'a'},	/* Show all interfaces. */
@@ -130,18 +177,19 @@
 int skfd = -1;					/* AF_INET socket for ioctl() calls.	*/
 
 static void if_print(char *ifname);
+static int get_abi_ver(char *master_ifname);
 
 int
 main(int argc, char **argv)
 {
 	struct ifreq  ifr2, if_hwaddr, if_ipaddr, if_metric, if_mtu, if_dstaddr;
 	struct ifreq  if_netmask, if_brdaddr, if_flags;
-	int goterr = 0;
+	int rv, goterr = 0;
 	int c, errflag = 0;
 	sa_family_t master_family;
 	char **spp, *master_ifname, *slave_ifname;
 	int hwaddr_notset;
-	int master_up;
+	int abi_ver = 0;
 
 	while ((c = getopt_long(argc, argv, "acdfrvV?h", longopts, 0)) != EOF)
 		switch (c) {
@@ -207,6 +255,7 @@
 		char **tempp = spp;
 		if ((master_ifname == NULL)||(slave_ifname == NULL)||(*tempp++ != NULL)) {
 			fprintf(stderr, usage_msg);
+			(void) close(skfd);
 			return 2;
 		}
 	}
@@ -218,6 +267,13 @@
 		exit(0);
 	}
 
+	/* exchange abi version with bonding driver */
+	abi_ver = get_abi_ver(master_ifname);
+	if (abi_ver < 0) {
+		(void) close(skfd);
+		exit(1);
+	}
+
 	/* Get the vitals from the master interface. */
 	{
 		struct ifreq *ifra[7] = { &if_ipaddr, &if_mtu, &if_dstaddr,
@@ -242,6 +298,13 @@
 			}
 		}
 
+		/* check if master is up; if not then fail any operation */
+		if (!(if_flags.ifr_flags & IFF_UP)) {
+			fprintf(stderr, "Illegal operation; the specified master interface '%s' is not up.\n", master_ifname);
+			(void) close(skfd);
+			exit (1);
+		}
+
 		hwaddr_notset = 1; /* assume master's address not set yet */
 		for (i = 0; hwaddr_notset && (i < 6); i++) {
 			hwaddr_notset &= ((unsigned char *)if_hwaddr.ifr_hwaddr.sa_data)[i] == 0;
@@ -254,7 +317,7 @@
 					" with ethernet-like network interfaces.\n"
 					" Use the '-f' option to force the operation.\n",
 					master_ifname);
-
+			(void) close(skfd);
 			exit (1);
 		}
 		master_family = if_hwaddr.ifr_hwaddr.sa_family;
@@ -278,39 +341,50 @@
 					fprintf(stderr,	"SIOCBONDRELEASE: cannot detach %s from %s. errno=%s.\n",
 							slave_ifname, master_ifname, strerror(errno));
 			}
-			else {  /* we'll set the interface down to avoid any conflicts due to
-					   same IP/MAC */
+			else if (abi_ver < 1) {
+			      	/* The driver is using an old ABI, so we'll set the interface
+				 * down to avoid any conflicts due to same IP/MAC
+				 */
 				strncpy(ifr2.ifr_name, slave_ifname, IFNAMSIZ);
 				if (ioctl(skfd, SIOCGIFFLAGS, &ifr2) < 0) {
 					int saved_errno = errno;
 					fprintf(stderr, "SIOCGIFFLAGS on %s failed: %s\n", slave_ifname,
-							strerror(saved_errno));
+						strerror(saved_errno));
 				}
 				else {
 					ifr2.ifr_flags &= ~(IFF_UP | IFF_RUNNING);
 					if (ioctl(skfd, SIOCSIFFLAGS, &ifr2) < 0) {
 						int saved_errno = errno;
 						fprintf(stderr, "Shutting down interface %s failed: %s\n",
-								slave_ifname, strerror(saved_errno));
+							slave_ifname, strerror(saved_errno));
 					}
 				}
 			}
-		}
-		else {  /* attach a slave interface to the master */
-			/* two possibilities :
-			   - if hwaddr_notset, do nothing.  The bond will assign the
-			     hwaddr from it's first slave.
-			   - if !hwaddr_notset, assign the master's hwaddr to each slave
-			*/
+		} else if (opt_c) {
+			strncpy(if_flags.ifr_name, master_ifname, IFNAMSIZ);
+			strncpy(if_flags.ifr_slave, slave_ifname, IFNAMSIZ);
+			if ((ioctl(skfd, SIOCBONDCHANGEACTIVE, &if_flags) < 0) &&
+			    (ioctl(skfd, BOND_CHANGE_ACTIVE_OLD, &if_flags) < 0)) {
+				fprintf(stderr,	"SIOCBONDCHANGEACTIVE: %s.\n", strerror(errno));
+			}
+		} else {  /* attach a slave interface to the master */
 
 			strncpy(ifr2.ifr_name, slave_ifname, IFNAMSIZ);
 			if (ioctl(skfd, SIOCGIFFLAGS, &ifr2) < 0) {
 				int saved_errno = errno;
 				fprintf(stderr, "SIOCGIFFLAGS on %s failed: %s\n", slave_ifname,
 						strerror(saved_errno));
+				(void) close(skfd);
 				return 1;
 			}
 
+			if ((ifr2.ifr_flags & IFF_SLAVE) && !opt_r) {
+				fprintf(stderr, "%s is already a slave\n", slave_ifname);
+				(void) close(skfd);
+				return 1;
+			}
+
+			/* if hwaddr_notset, assign the slave hw address to the master */
 			if (hwaddr_notset) {
 				/* assign the slave hw address to the 
 				 * master since it currently does not 
@@ -322,43 +396,18 @@
 				 * TODO: put this and the "else" portion in
 				 *       a function.
 				 */
-				goterr = 0;
-				master_up = 0;
-				if (if_flags.ifr_flags & IFF_UP) {
-					if_flags.ifr_flags &= ~IFF_UP;
-					if (ioctl(skfd, SIOCSIFFLAGS, 
-							&if_flags) < 0) {
-						goterr = 1;
-						fprintf(stderr, 
-							"Shutting down "
-							"interface %s failed: "
-							"%s\n",
-							master_ifname, 
-							strerror(errno));
-					} else {
-						/* we took the master down, 
-						 * so we must bring it up 
-						 */
-						master_up = 1; 
-					}
-				}
-
-				if (!goterr) {
-					/* get the slaves MAC address */
-					strncpy(if_hwaddr.ifr_name, 
-							slave_ifname, IFNAMSIZ);
-					if (ioctl(skfd, SIOCGIFHWADDR, 
-							&if_hwaddr) < 0) {
-						fprintf(stderr, 
-							"Could not get MAC "
-							"address of %s: %s\n",
-							slave_ifname, 
-							strerror(errno));
-						strncpy(if_hwaddr.ifr_name, 
-							master_ifname, 
-							IFNAMSIZ);
-						goterr=1;
-					}
+				/* get the slaves MAC address */
+				strncpy(if_hwaddr.ifr_name, slave_ifname,
+					IFNAMSIZ);
+				rv = ioctl(skfd, SIOCGIFHWADDR, &if_hwaddr);
+				if (-1 == rv) {
+					fprintf(stderr, "Could not get MAC "
+						"address of %s: %s\n",
+						slave_ifname, 
+						strerror(errno));
+					strncpy(if_hwaddr.ifr_name,
+						master_ifname, IFNAMSIZ);
+					goterr = 1;
 				}
 
 				if (!goterr) {
@@ -376,45 +425,35 @@
 						hwaddr_notset = 0;
 					}
 				}
+			} else if (abi_ver < 1) { /* if (hwaddr_notset) */
 
-				if (master_up) {
-					if_flags.ifr_flags |= IFF_UP;
-					if (ioctl(skfd, SIOCSIFFLAGS, 
-							&if_flags) < 0) {
-						fprintf(stderr, 
-							"Bringing up interface "
-							"%s failed: %s\n",
-							master_ifname, 
-							strerror(errno));
-					}
-				}
-
-			} else {  
-				/* we'll assign master's hwaddr to this slave */
+			      	/* The driver is using an old ABI, so we'll set the interface
+				 * down and assign the master's hwaddr to it
+				 */
 				if (ifr2.ifr_flags & IFF_UP) {
 					ifr2.ifr_flags &= ~IFF_UP;
 					if (ioctl(skfd, SIOCSIFFLAGS, &ifr2) < 0) {
 						int saved_errno = errno;
 						fprintf(stderr, "Shutting down interface %s failed: %s\n",
-								slave_ifname, strerror(saved_errno));
+							slave_ifname, strerror(saved_errno));
 					}
 				}
-	
+
 				strncpy(if_hwaddr.ifr_name, slave_ifname, IFNAMSIZ);
 				if (ioctl(skfd, SIOCSIFHWADDR, &if_hwaddr) < 0) {
 					int saved_errno = errno;
 					fprintf(stderr, "SIOCSIFHWADDR on %s failed: %s\n", if_hwaddr.ifr_name,
-							strerror(saved_errno));
+						strerror(saved_errno));
 					if (saved_errno == EBUSY)
 						fprintf(stderr, "  The slave device %s is busy: it must be"
-								" idle before running this command.\n", slave_ifname);
+							" idle before running this command.\n", slave_ifname);
 					else if (saved_errno == EOPNOTSUPP)
 						fprintf(stderr, "  The slave device you specified does not support"
-								" setting the MAC address.\n  Your kernel likely does not"
-								" support slave devices.\n");
+							" setting the MAC address.\n  Your kernel likely does not"
+							" support slave devices.\n");
 					else if (saved_errno == EINVAL)
 						fprintf(stderr, "  The slave device's address type does not match"
-								" the master's address type.\n");
+							" the master's address type.\n");
 				} else {
 					if (verbose) {
 						unsigned char *hwaddr = if_hwaddr.ifr_hwaddr.sa_data;
@@ -424,10 +463,11 @@
 					}
 				}
 			}
-	
+
 			if (*spp  &&  !strcmp(*spp, "metric")) {
 				if (*++spp == NULL) {
 					fprintf(stderr, usage_msg);
+					(void) close(skfd);
 					exit(2);
 				}
 				if_metric.ifr_metric = atoi(*spp);
@@ -500,33 +540,44 @@
 				}
 			}
 			
-			ifr2.ifr_flags |= IFF_UP; /* the interface will need to be up to be bonded */
-			if ((ifr2.ifr_flags &= ~(IFF_SLAVE | IFF_MASTER)) == 0
-				|| strncpy(ifr2.ifr_name, slave_ifname, IFNAMSIZ) <= 0
-				|| ioctl(skfd, SIOCSIFFLAGS, &ifr2) < 0) {
-				fprintf(stderr,
-						"Something broke setting the slave (%s) flags: %s.\n",
-						slave_ifname, strerror(errno));
+			if (abi_ver < 1) {
+
+			      	/* The driver is using an old ABI, so we'll set the interface
+				 * up before enslaving it
+				 */
+				ifr2.ifr_flags |= IFF_UP;
+				if ((ifr2.ifr_flags &= ~(IFF_SLAVE | IFF_MASTER)) == 0
+					|| strncpy(ifr2.ifr_name, slave_ifname, IFNAMSIZ) <= 0
+					|| ioctl(skfd, SIOCSIFFLAGS, &ifr2) < 0) {
+						fprintf(stderr,
+							"Something broke setting the slave (%s) flags: %s.\n",
+							slave_ifname, strerror(errno));
+				} else {
+					if (verbose)
+						printf("Set the slave's (%s) flags %4.4x.\n",
+							slave_ifname, if_flags.ifr_flags);
+				}
 			} else {
-				if (verbose)
-					printf("Set the slave's (%s) flags %4.4x.\n", slave_ifname, if_flags.ifr_flags);
+				/* the bonding module takes care of setting the slave's mac address
+			 	 * and opening its interface
+			 	 */
+				if (ifr2.ifr_flags & IFF_UP) { /* the interface will need to be down */
+					ifr2.ifr_flags &= ~IFF_UP;
+					if (ioctl(skfd, SIOCSIFFLAGS, &ifr2) < 0) {
+						int saved_errno = errno;
+						fprintf(stderr, "Shutting down interface %s failed: %s\n",
+							slave_ifname, strerror(saved_errno));
+					}
+				}
 			}
-	
+
 			/* Do the real thing */
-			if ( ! opt_r) {
+			if (!opt_r) {
 				strncpy(if_flags.ifr_name, master_ifname, IFNAMSIZ);
 				strncpy(if_flags.ifr_slave, slave_ifname, IFNAMSIZ);
-				if (!opt_c) {
-					if ((ioctl(skfd, SIOCBONDENSLAVE, &if_flags) < 0) &&
-					    (ioctl(skfd, BOND_ENSLAVE_OLD, &if_flags) < 0)) {
-						fprintf(stderr,	"SIOCBONDENSLAVE: %s.\n", strerror(errno));
-					}
-				}
-				else {
-					if ((ioctl(skfd, SIOCBONDCHANGEACTIVE, &if_flags) < 0) &&
-					    (ioctl(skfd, BOND_CHANGE_ACTIVE_OLD, &if_flags) < 0)) {
-						fprintf(stderr,	"SIOCBONDCHANGEACTIVE: %s.\n", strerror(errno));
-					}
+				if ((ioctl(skfd, SIOCBONDENSLAVE, &if_flags) < 0) &&
+				    (ioctl(skfd, BOND_ENSLAVE_OLD, &if_flags) < 0)) {
+					fprintf(stderr,	"SIOCBONDENSLAVE: %s.\n", strerror(errno));
 				}
 			}
 		}
@@ -639,6 +690,37 @@
 	}
 }
 
+static int get_abi_ver(char *master_ifname)
+{
+	struct ifreq ifr;
+	struct ethtool_drvinfo info;
+	int abi_ver = 0;
+
+	memset(&ifr, 0, sizeof(ifr));
+	strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ);
+	ifr.ifr_data = (caddr_t)&info;
+
+	info.cmd = ETHTOOL_GDRVINFO;
+	strncpy(info.driver, "ifenslave", 32);
+	snprintf(info.fw_version, 32, "%d", BOND_ABI_VERSION);
+	if (ioctl(skfd, SIOCETHTOOL, &ifr) >= 0) {
+		char *endptr;
+
+		abi_ver = strtoul(info.fw_version, &endptr, 0);
+		if (*endptr) {
+			fprintf(stderr, "Error: got invalid string as an ABI "
+				"version from the bonding module\n");
+			return -1;
+		}
+	}
+
+	if (verbose) {
+        	printf("ABI ver is %d\n", abi_ver);
+	}
+	return abi_ver;
+}
+
+
 
 /*
  * Local variables:
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/Documentation/pci.txt linux-2.4.22-pre2/Documentation/pci.txt
--- linux-2.4.21/Documentation/pci.txt	2002-08-03 00:39:42.000000000 +0000
+++ linux-2.4.22-pre2/Documentation/pci.txt	2003-06-26 21:43:20.000000000 +0000
@@ -51,21 +51,24 @@
 			execution of pci_register_driver for already existing
 			devices or later if a new device gets inserted) for all
 			PCI devices which match the ID table and are not handled
-			by the other drivers yet. This function gets passed a pointer
-			to the pci_dev structure representing the device and also
-			which entry in the ID table did the device match. It returns
-			zero when the driver has accepted the device or an error
-			code (negative number) otherwise. This function always gets
-			called from process context, so it can sleep.
-	remove		Pointer to a function which gets called whenever a device
-			being handled by this driver is removed (either during
-			deregistration of the driver or when it's manually pulled
-			out of a hot-pluggable slot). This function always gets
-			called from process context, so it can sleep.
+			by the other drivers yet. This function gets passed a
+			pointer to the pci_dev structure representing the device
+			and also which entry in the ID table did the device
+			match. It returns zero when the driver has accepted the
+			device or an error code (negative number) otherwise.
+			This function always gets called from process context,
+			so it can sleep.
+	remove		Pointer to a function which gets called whenever a
+			device being handled by this driver is removed (either
+			during deregistration of the driver or when it's
+			manually pulled out of a hot-pluggable slot). This
+			function always gets called from process context, so it
+			can sleep.
 	save_state	Save a device's state before it's suspend.
 	suspend		Put device into low power state.
 	resume		Wake device from low power state.
-	enable_wake	Enable device to generate wake events from a low power state.
+	enable_wake	Enable device to generate wake events from a low power
+			state.
 
 			(Please see Documentation/power/pci.txt for descriptions
 			of PCI Power Management and the related functions)
@@ -186,8 +189,9 @@
 
    See Documentation/IO-mapping.txt for how to access device memory.
 
-   You still need to call request_region() for I/O regions and request_mem_region()
-for memory regions to make sure nobody else is using the same device.
+   You still need to call request_region() for I/O regions and
+request_mem_region() for memory regions to make sure nobody else is using the
+same device.
 
    All interrupt handlers should be registered with SA_SHIRQ and use the devid
 to map IRQs to devices (remember that all PCI interrupts are shared).
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/Documentation/power/pci.txt linux-2.4.22-pre2/Documentation/power/pci.txt
--- linux-2.4.21/Documentation/power/pci.txt	2002-08-03 00:39:42.000000000 +0000
+++ linux-2.4.22-pre2/Documentation/power/pci.txt	2003-06-26 21:43:15.000000000 +0000
@@ -22,7 +22,7 @@
 power management operations.
 
 Implementation of the PCI PM Spec is optional, as are several sub-components of
-it. If a device supports the PCI PM Spec, the device will have an 8 byte 
+it. If a device supports the PCI PM Spec, the device will have an 8 byte
 capability field in its PCI configuration space. This field is used to describe
 and control the standard PCI power management features.
 
@@ -50,33 +50,35 @@
 | D1, D2, D3    | D0        |
 +---------------------------+
 
-Note that when the system is entering a global suspend state, all devices will be 
-placed into D3 and when resuming, all devices will be placed into D0. However, 
-when the system is running, other state transitions are possible.
+Note that when the system is entering a global suspend state, all devices will
+be placed into D3 and when resuming, all devices will be placed into D0.
+However, when the system is running, other state transitions are possible.
 
 2. How The PCI Subsystem Handles Power Management
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-The PCI suspend/resume functionality is accessed indirectly via the Power Management 
-subsystem. At boot, the PCI driver registers a power management callback with that layer.
-Upon entering a suspend state, the PM layer iterates through all of its registered 
-callbacks. This currently takes place only during APM state transitions.
-
-Upon going to sleep, the PCI subsystem walks its device tree twice. Both times, it does
-a depth first walk of the device tree. The first walk saves each of the device's state 
-and checks for devices that will prevent the system from entering a global power state. 
-The next walk then places the devices in a low power state.
-
-The first walk allows a graceful recovery in the event of a failure, since none of the 
-devices have actually been powered down.
-
-In both walks, in particular the second, all children of a bridge are touched before the
-actual bridge itself. This allows the bridge to retain power while its children are being
-accessed.
-
-Upon resuming from sleep, just the opposite must be true: all bridges must be powered on
-and restored before their children are powered on. This is easily accomplished with a
-breadth-first walk of the PCI device tree.
+The PCI suspend/resume functionality is accessed indirectly via the Power
+Management subsystem. At boot, the PCI driver registers a power management
+callback with that layer. Upon entering a suspend state, the PM layer iterates
+through all of its registered callbacks. This currently takes place only during
+APM state transitions.
+
+Upon going to sleep, the PCI subsystem walks its device tree twice. Both times,
+it does a depth first walk of the device tree. The first walk saves each of the
+device's state and checks for devices that will prevent the system from entering
+a global power state. The next walk then places the devices in a low power
+state.
+
+The first walk allows a graceful recovery in the event of a failure, since none
+of the devices have actually been powered down.
+
+In both walks, in particular the second, all children of a bridge are touched
+before the actual bridge itself. This allows the bridge to retain power while
+its children are being accessed.
+
+Upon resuming from sleep, just the opposite must be true: all bridges must be
+powered on and restored before their children are powered on. This is easily
+accomplished with a breadth-first walk of the PCI device tree.
 
 
 3. PCI Utility Functions
@@ -86,8 +88,8 @@
 Assuming that a device behaves as advertised, these should be applicable in most
 cases. However, results may vary.
 
-Note that these functions are never implicitly called for the driver. The driver is always
-responsible for deciding when and if to call these.
+Note that these functions are never implicitly called for the driver. The driver
+is always responsible for deciding when and if to call these.
 
 
 pci_save_state
@@ -97,7 +99,8 @@
 	pci_save_state(dev, buffer);
 
 Description:
-	Save first 64 bytes of PCI config space. Buffer must be allocated by caller.
+	Save first 64 bytes of PCI config space. Buffer must be allocated by
+	caller.
 
 
 pci_restore_state
@@ -109,8 +112,8 @@
 Description:
 	Restore previously saved config space. (First 64 bytes only);
 
-	If buffer is NULL, then restore what information we know about the device
-	from bootup: BARs and interrupt line.
+	If buffer is NULL, then restore what information we know about the
+	device from bootup: BARs and interrupt line.
 
 
 pci_set_power_state
@@ -120,7 +123,8 @@
 	pci_set_power_state(dev, state);
 
 Description:
-	Transition device to low power state using PCI PM Capabilities registers.
+	Transition device to low power state using PCI PM Capabilities
+	registers.
 
 	Will fail under one of the following conditions:
 	- If state is less than current state, but not D0 (illegal transition)
@@ -138,14 +142,15 @@
 	Enable device to generate PME# during low power state using PCI PM 
 	Capabilities.
 
-	Checks whether if device supports generating PME# from requested state and fail
-	if it does not, unless enable == 0 (request is to disable wake events, which
-	is implicit if it doesn't even support it in the first place).
-
-	Note that the PMC Register in the device's PM Capabilties has a bitmask of
-	the states it supports generating PME# from. D3hot is bit 3 and D3cold is bit
-	4. So, while a value of 4 as the state may not seem semantically correct, it
-	is. 
+	Checks whether if device supports generating PME# from requested state
+	and fail if it does not, unless enable == 0 (request is to disable wake
+	events, which is implicit if it doesn't even support it in the first
+	place).
+
+	Note that the PMC Register in the device's PM Capabilties has a bitmask
+	of the states it supports generating PME# from. D3hot is bit 3 and
+	D3cold is bit 4. So, while a value of 4 as the state may not seem
+	semantically correct, it is. 
 
 
 4. PCI Device Drivers
@@ -168,25 +173,26 @@
 if (dev->driver && dev->driver->save_state)
 	dev->driver->save_state(dev,state);
 
-The driver should use this callback to save device state. It should take into 
-account the current state of the device and the requested state in order to avoid
-any unnecessary operations.
-
-For example, a video card that supports all 4 states (D0-D3), all controller context
-is preserved when entering D1, but the screen is placed into a low power state
-(blanked). 
-
-The driver can also interpret this function as a notification that it may be entering
-a sleep state in the near future. If it knows that the device cannot enter the 
-requested state, either because of lack of support for it, or because the device is 
-middle of some critical operation, then it should fail.
-
-This function should not be used to set any state in the device or the driver because
-the device may not actually enter the sleep state (e.g. another driver later causes
-causes a global state transition to fail).
-
-Note that in intermediate low power states, a device's I/O and memory spaces may be
-disabled and may not be available in subsequent transitions to lower power states.
+The driver should use this callback to save device state. It should take into
+account the current state of the device and the requested state in order to
+avoid any unnecessary operations.
+
+For example, a video card that supports all 4 states (D0-D3), all controller
+context is preserved when entering D1, but the screen is placed into a low power
+state (blanked). 
+
+The driver can also interpret this function as a notification that it may be
+entering a sleep state in the near future. If it knows that the device cannot
+enter the requested state, either because of lack of support for it, or because
+the device is middle of some critical operation, then it should fail.
+
+This function should not be used to set any state in the device or the driver
+because the device may not actually enter the sleep state (e.g. another driver
+later causes causes a global state transition to fail).
+
+Note that in intermediate low power states, a device's I/O and memory spaces may
+be disabled and may not be available in subsequent transitions to lower power
+states.
 
 
 suspend
@@ -197,27 +203,27 @@
 if (dev->driver && dev->driver->suspend)
 	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.
+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.
 
 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:
+For devices that support the PCI PM Spec, this may be used to set the device's
+power state:
 
 pci_set_power_state(dev,state);
 
 The driver is also responsible for disabling any other device-specific features
 (e.g blanking screen, turning off on-card memory, etc).
 
-The driver should be sure to track the current state of the device, as it may obviate
-the need for some operations.
+The driver should be sure to track the current state of the device, as it may
+obviate the need for some operations.
 
-The driver should update the current_state field in its pci_dev structure in this 
-function.
+The driver should update the current_state field in its pci_dev structure in
+this function.
 
 resume
 ------
@@ -227,36 +233,37 @@
 if (dev->driver && dev->driver->suspend)
 	dev->driver->resume(dev)
 
-The resume callback may be called from any power state, and is always meant to 
+The resume callback may be called from any power state, and is always meant to
 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.
-
-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.
+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.
+
+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.
 
-If the device supports the PCI PM Spec, it can use this to physically transition the
-device to D0:
+If the device supports the PCI PM Spec, it can use this to physically transition
+the device to D0:
 
 pci_set_power_state(dev,0);
 
-Note that if the entire system is transitioning out of a global sleep state, all 
-devices will be placed in the D0 state, so this is not necessary. However, in the
-event that the device is placed in the D3 state during normal operation, this call
-is necessary. It is impossible to determine which of the two events is taking place
-in the driver, so it is always a good idea to make that call.
+Note that if the entire system is transitioning out of a global sleep state, all
+devices will be placed in the D0 state, so this is not necessary. However, in
+the event that the device is placed in the D3 state during normal operation,
+this call is necessary. It is impossible to determine which of the two events is
+taking place in the driver, so it is always a good idea to make that call.
 
-The driver should take note of the state that it is resuming from in order to ensure
-correct (and speedy) operation.
+The driver should take note of the state that it is resuming from in order to
+ensure correct (and speedy) operation.
 
-The driver should update the current_state field in its pci_dev structure in this 
-function.
+The driver should update the current_state field in its pci_dev structure in
+this function.
 
 
 enable_wake
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/MAINTAINERS linux-2.4.22-pre2/MAINTAINERS
--- linux-2.4.21/MAINTAINERS	2003-06-26 21:45:04.000000000 +0000
+++ linux-2.4.22-pre2/MAINTAINERS	2003-06-26 21:43:28.000000000 +0000
@@ -206,6 +206,21 @@
 L:	linux-scsi@vger.kernel.org
 S:	Maintained
 
+ALCATEL SPEEDTOUCH USB DRIVER
+P:	Duncan Sands
+M:	duncan.sands@wanadoo.fr
+L:	linux-usb-users@lists.sourceforge.net
+L:	linux-usb-devel@lists.sourceforge.net
+W:	http://www.linux-usb.org/SpeedTouch/
+S:	Maintained
+
+AIPTEK USB TABLET DRIVER
+P:	Bryan W. Headley
+M:	Bryan W. Headley <bwheadley@earthlink.net>
+W:	http://aiptektablet.sourceforge.net
+L:	aiptektablet-users@sourceforge.net
+S:	Maintained
+
 ALTERA EPXA1/EPXA10 DEVELOPMENT BOARD PORT
 P:	Clive Davies
 M:	cdavies@altera.com
@@ -1183,6 +1198,8 @@
 M:	pekkas@netcore.fi
 P:	James Morris
 M:	jmorris@intercode.com.au
+P:	Hideaki YOSHIFUJI
+M:	yoshfuji@linux-ipv6.org
 L:	netdev@oss.sgi.com
 S:	Maintained
 
@@ -1706,6 +1723,12 @@
 W:	http://www.linuxtr.net
 S:	Maintained
 
+TOSHIBA ACPI EXTRAS DRIVER
+P:	John Belmonte
+M:	toshiba_acpi@memebeam.org
+W:	http://memebeam.org/toys/ToshibaAcpiDriver
+S:	Maintained
+
 TOSHIBA SMM DRIVER
 P:	Jonathan Buzzard
 M:	jonathan@buzzard.org.uk
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/Makefile linux-2.4.22-pre2/Makefile
--- linux-2.4.21/Makefile	2003-06-26 21:45:04.000000000 +0000
+++ linux-2.4.22-pre2/Makefile	2003-06-26 21:43:12.000000000 +0000
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 4
-SUBLEVEL = 21
-EXTRAVERSION =
+SUBLEVEL = 22
+EXTRAVERSION = -pre2
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/README linux-2.4.22-pre2/README
--- linux-2.4.21/README	2002-08-03 00:39:42.000000000 +0000
+++ linux-2.4.22-pre2/README	2003-06-26 21:43:16.000000000 +0000
@@ -64,12 +64,12 @@
  - You can also upgrade between 2.4.xx releases by patching.  Patches are
    distributed in the traditional gzip and the new bzip2 format.  To
    install by patching, get all the newer patch files, enter the
-   directory in which you unpacked the kernel source and execute:
+   top level directory of the kernel source (linux-2.4.xx) and execute:
 
-		gzip -cd patchXX.gz | patch -p0
+               gzip -cd ../patch-2.4.xx.gz | patch -p1
 
    or
-		bzip2 -dc patchXX.bz2 | patch -p0
+               bzip2 -dc ../patch-2.4.xx.bz2 | patch -p1
 
    (repeat xx for all versions bigger than the version of your current
    source tree, _in_order_) and you should be ok.  You may want to remove
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/alpha/config.in linux-2.4.22-pre2/arch/alpha/config.in
--- linux-2.4.21/arch/alpha/config.in	2003-06-26 21:45:04.000000000 +0000
+++ linux-2.4.22-pre2/arch/alpha/config.in	2003-06-26 21:43:13.000000000 +0000
@@ -42,6 +42,7 @@
 	 Eiger			CONFIG_ALPHA_EIGER		\
 	 Jensen			CONFIG_ALPHA_JENSEN		\
 	 LX164			CONFIG_ALPHA_LX164		\
+	 Lynx			CONFIG_ALPHA_LYNX		\
 	 Marvel			CONFIG_ALPHA_MARVEL		\
 	 Miata			CONFIG_ALPHA_MIATA		\
 	 Mikasa			CONFIG_ALPHA_MIKASA		\
@@ -157,6 +158,16 @@
 	fi
 	define_bool CONFIG_ALPHA_T2 y
 fi
+if [ "$CONFIG_ALPHA_LYNX" = "y" ]
+then
+	bool 'EV5 CPU(s) (model 5/xxx)?' CONFIG_ALPHA_EV5
+	if [ "$CONFIG_ALPHA_EV5" != "y" ]
+	then
+		define_bool CONFIG_ALPHA_EV4 y
+	fi
+	define_bool CONFIG_ALPHA_GAMMA y
+	define_bool CONFIG_ALPHA_T2 y
+fi
 if [ "$CONFIG_ALPHA_MIATA" = "y" -o "$CONFIG_ALPHA_LX164" = "y" \
 	-o "$CONFIG_ALPHA_SX164" = "y" -o "$CONFIG_ALPHA_RUFFIAN" = "y" ]
 then
@@ -216,7 +227,7 @@
 	-o "$CONFIG_ALPHA_DP264" = "y" -o "$CONFIG_ALPHA_RAWHIDE" = "y" \
 	-o "$CONFIG_ALPHA_EIGER" = "y" -o "$CONFIG_ALPHA_WILDFIRE" = "y" \
 	-o "$CONFIG_ALPHA_TITAN" = "y" -o "$CONFIG_ALPHA_SHARK" = "y" \
-	-o "$CONFIG_ALPHA_MARVEL" = "y" ]
+	-o "$CONFIG_ALPHA_MARVEL" = "y" -o "$CONFIG_ALPHA_LYNX" = "y" ]
 then
 	define_bool CONFIG_ALPHA_SRM y
 fi
@@ -234,7 +245,7 @@
 
 if [ "$CONFIG_ALPHA_ALCOR" = "y" -o "$CONFIG_ALPHA_MIKASA" = "y" \
 	-o "$CONFIG_ALPHA_SABLE" = "y" -o "$CONFIG_ALPHA_NORITAKE" = "y" \
-	-o "$CONFIG_ALPHA_RAWHIDE" = "y" ]
+	-o "$CONFIG_ALPHA_RAWHIDE" = "y" -o "$CONFIG_ALPHA_LYNX" = "y" ]
 then
 	define_bool CONFIG_ALPHA_EISA y
 fi
@@ -250,7 +261,8 @@
 if [ "$CONFIG_ALPHA_SABLE" = "y" -o "$CONFIG_ALPHA_RAWHIDE" = "y" \
 	-o "$CONFIG_ALPHA_DP264" = "y" -o "$CONFIG_ALPHA_WILDFIRE" = "y" \
 	-o "$CONFIG_ALPHA_TITAN" = "y" -o "$CONFIG_ALPHA_GENERIC" = "y" \
-	-o "$CONFIG_ALPHA_SHARK" = "y" -o "$CONFIG_ALPHA_MARVEL" = "y" ]
+	-o "$CONFIG_ALPHA_SHARK" = "y" -o "$CONFIG_ALPHA_MARVEL" = "y" \
+	-o "$CONFIG_ALPHA_LYNX" = "y" ]
 then
 	bool 'Symmetric multi-processing support' CONFIG_SMP
 fi
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/alpha/kernel/Makefile linux-2.4.22-pre2/arch/alpha/kernel/Makefile
--- linux-2.4.21/arch/alpha/kernel/Makefile	2003-06-26 21:45:04.000000000 +0000
+++ linux-2.4.22-pre2/arch/alpha/kernel/Makefile	2003-06-26 21:43:19.000000000 +0000
@@ -24,8 +24,7 @@
 # FIXME!
 # These should be made conditional on the stuff that needs them!
 #
-obj-y	 += irq_i8259.o irq_srm.o \
-	    es1888.o smc37c669.o smc37c93x.o ns87312.o
+obj-y	 += irq_i8259.o irq_srm.o
 
 ifdef CONFIG_VGA_HOSE
 obj-y	 += console.o
@@ -93,7 +92,10 @@
 obj-$(CONFIG_ALPHA_RAWHIDE) += sys_rawhide.o
 obj-$(CONFIG_ALPHA_RUFFIAN) += sys_ruffian.o
 obj-$(CONFIG_ALPHA_RX164) += sys_rx164.o
-obj-$(CONFIG_ALPHA_SABLE) += sys_sable.o
+
+ifneq ($(CONFIG_ALPHA_SABLE)$(CONFIG_ALPHA_LYNX),)
+obj-y    += sys_sable.o
+endif
 
 ifneq ($(CONFIG_ALPHA_BOOK1)$(CONFIG_ALPHA_AVANTI)$(CONFIG_ALPHA_NONAME)$(CONFIG_ALPHA_P2K)$(CONFIG_ALPHA_XL),)
 obj-y    += sys_sio.o
@@ -107,6 +109,22 @@
 obj-y    += irq_pyxis.o
 endif
 
+ifneq ($(CONFIG_ALPHA_MIATA)$(CONFIG_ALPHA_DP264),)
+obj-y    += es1888.o
+endif
+
+ifneq ($(CONFIG_ALPHA_DP264)$(CONFIG_ALPHA_MIATA)$(CONFIG_ALPHA_SX164)$(CONFIG_ALPHA_TITAN),)
+obj-y    += smc37c669.o
+endif
+
+ifneq ($(CONFIG_ALPHA_PC164)$(CONFIG_ALPHA_LX164),)
+obj-y    += smc37c93x.o
+endif
+
+ifneq ($(CONFIG_ALPHA_NONAME)$(CONFIG_ALPHA_EB164)$(CONFIG_ALPHA_AVANTI)$(CONFIG_ALPHA_P2K)$(CONFIG_ALPHA_XL)$(CONFIG_ALPHA_TAKARA),)
+obj-y    += ns87312.o
+endif
+
 endif # GENERIC
 
 all: kernel.o head.o
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/alpha/kernel/core_t2.c linux-2.4.22-pre2/arch/alpha/kernel/core_t2.c
--- linux-2.4.21/arch/alpha/kernel/core_t2.c	2003-06-26 21:45:04.000000000 +0000
+++ linux-2.4.22-pre2/arch/alpha/kernel/core_t2.c	2003-06-26 21:43:10.000000000 +0000
@@ -17,6 +17,7 @@
 
 #include <asm/ptrace.h>
 #include <asm/system.h>
+#include <asm/delay.h>
 
 #define __EXTERN_INLINE
 #include <asm/io.h>
@@ -26,6 +27,12 @@
 #include "proto.h"
 #include "pci_impl.h"
 
+/* For dumping initial DMA window settings. */
+#define DEBUG_PRINT_INITIAL_SETTINGS 0
+
+/* For dumping final DMA window settings. */
+#define DEBUG_PRINT_FINAL_SETTINGS 0
+
 /*
  * By default, we direct-map starting at 2GB, in order to allow the
  * maximum size direct-map window (2GB) to match the maximum amount of
@@ -34,11 +41,23 @@
  * ISA DMA, since the maximum ISA DMA address is 2GB-1.
  *
  * For now, this seems a reasonable trade-off: even though most SABLEs
- * have far less than even 1GB of memory, floppy usage/performance will
- * not really be affected by forcing it to go via scatter/gather...
+ * have less than 1GB of memory, floppy usage/performance will not
+ * really be affected by forcing it to go via scatter/gather...
  */
 #define T2_DIRECTMAP_2G 1
 
+#if T2_DIRECTMAP_2G
+# define T2_DIRECTMAP_START	0x80000000UL
+# define T2_DIRECTMAP_LENGTH	0x80000000UL
+#else
+# define T2_DIRECTMAP_START	0x40000000UL
+# define T2_DIRECTMAP_LENGTH	0x40000000UL
+#endif
+
+/* The ISA scatter/gather window settings. */
+#define T2_ISA_SG_START		0x00800000UL
+#define T2_ISA_SG_LENGTH	0x00800000UL
+
 /*
  * NOTE: Herein lie back-to-back mb instructions.  They are magic. 
  * One plausible explanation is that the i/o controller does not properly
@@ -57,6 +76,24 @@
 # define DBG(args)
 #endif
 
+static volatile unsigned int t2_mcheck_any_expected;
+static volatile unsigned int t2_mcheck_last_taken;
+
+/* Place to save the DMA Window registers as set up by SRM
+   for restoration during shutdown. */
+static struct
+{
+	struct {
+		unsigned long wbase;
+		unsigned long wmask;
+		unsigned long tbase;
+	} window[2];
+	unsigned long hae_1;
+  	unsigned long hae_2;
+	unsigned long hae_3;
+	unsigned long hae_4;
+	unsigned long hbase;
+} t2_saved_config __attribute((common));
 
 /*
  * Given a bus, device, and function number, compute resulting
@@ -135,42 +172,34 @@
 	return 0;
 }
 
+/*
+ * NOTE: both conf_read() and conf_write() may set HAE_3 when needing
+ *       to do type1 access. This is protected by the use of spinlock IRQ
+ *       primitives in the wrapper functions pci_{read,write}_config_*()
+ *       defined in drivers/pci/pci.c.
+ */
 static unsigned int
 conf_read(unsigned long addr, unsigned char type1)
 {
-	unsigned long flags;
-	unsigned int value, cpu;
+	unsigned int value, cpu, taken;
 	unsigned long t2_cfg = 0;
 
 	cpu = smp_processor_id();
 
-	__save_and_cli(flags);	/* avoid getting hit by machine check */
-
 	DBG(("conf_read(addr=0x%lx, type1=%d)\n", addr, type1));
 
-#if 0
-	{
-	  unsigned long stat0;
-	  /* Reset status register to avoid losing errors.  */
-	  stat0 = *(vulp)T2_IOCSR;
-	  *(vulp)T2_IOCSR = stat0;
-	  mb();
-	  DBG(("conf_read: T2 IOCSR was 0x%x\n", stat0));
-	}
-#endif
-
 	/* If Type1 access, must set T2 CFG.  */
 	if (type1) {
 		t2_cfg = *(vulp)T2_HAE_3 & ~0xc0000000UL;
 		*(vulp)T2_HAE_3 = 0x40000000UL | t2_cfg;
 		mb();
-		DBG(("conf_read: TYPE1 access\n"));
 	}
 	mb();
 	draina();
 
 	mcheck_expected(cpu) = 1;
 	mcheck_taken(cpu) = 0;
+	t2_mcheck_any_expected |= (1 << cpu);
 	mb();
 
 	/* Access configuration space. */
@@ -178,12 +207,20 @@
 	mb();
 	mb();  /* magic */
 
-	if (mcheck_taken(cpu)) {
+	/* Wait for possible mcheck. Also, this lets other CPUs clear
+	   their mchecks as well, as they can reliably tell when
+	   another CPU is in the midst of handling a real mcheck via
+	   the "taken" function. */
+	udelay(100);
+
+	if ((taken = mcheck_taken(cpu))) {
 		mcheck_taken(cpu) = 0;
+		t2_mcheck_last_taken |= (1 << cpu);
 		value = 0xffffffffU;
 		mb();
 	}
 	mcheck_expected(cpu) = 0;
+	t2_mcheck_any_expected = 0;
 	mb();
 
 	/* If Type1 access, must reset T2 CFG so normal IO space ops work.  */
@@ -191,45 +228,30 @@
 		*(vulp)T2_HAE_3 = t2_cfg;
 		mb();
 	}
-	DBG(("conf_read(): finished\n"));
 
-	__restore_flags(flags);
 	return value;
 }
 
 static void
 conf_write(unsigned long addr, unsigned int value, unsigned char type1)
 {
-	unsigned long flags;
-	unsigned int cpu;
+	unsigned int cpu, taken;
 	unsigned long t2_cfg = 0;
 
 	cpu = smp_processor_id();
 
-	__save_and_cli(flags);	/* avoid getting hit by machine check */
-
-#if 0
-	{
-	  unsigned long stat0;
-	  /* Reset status register to avoid losing errors.  */
-	  stat0 = *(vulp)T2_IOCSR;
-	  *(vulp)T2_IOCSR = stat0;
-	  mb();
-	  DBG(("conf_write: T2 ERR was 0x%x\n", stat0));
-	}
-#endif
-
 	/* If Type1 access, must set T2 CFG.  */
 	if (type1) {
 		t2_cfg = *(vulp)T2_HAE_3 & ~0xc0000000UL;
 		*(vulp)T2_HAE_3 = t2_cfg | 0x40000000UL;
 		mb();
-		DBG(("conf_write: TYPE1 access\n"));
 	}
 	mb();
 	draina();
 
 	mcheck_expected(cpu) = 1;
+	mcheck_taken(cpu) = 0;
+	t2_mcheck_any_expected |= (1 << cpu);
 	mb();
 
 	/* Access configuration space.  */
@@ -237,7 +259,19 @@
 	mb();
 	mb();  /* magic */
 
+	/* Wait for possible mcheck. Also, this lets other CPUs clear
+	   their mchecks as well, as they can reliably tell when
+	   this CPU is in the midst of handling a real mcheck via
+	   the "taken" function. */
+	udelay(100);
+
+	if ((taken = mcheck_taken(cpu))) {
+		mcheck_taken(cpu) = 0;
+		t2_mcheck_last_taken |= (1 << cpu);
+		mb();
+	}
 	mcheck_expected(cpu) = 0;
+	t2_mcheck_any_expected = 0;
 	mb();
 
 	/* If Type1 access, must reset T2 CFG so normal IO space ops work.  */
@@ -245,8 +279,6 @@
 		*(vulp)T2_HAE_3 = t2_cfg;
 		mb();
 	}
-	DBG(("conf_write(): finished\n"));
-	__restore_flags(flags);
 }
 
 static int
@@ -333,48 +365,121 @@
 	write_dword:	t2_write_config_dword
 };
 
+static void __init
+t2_direct_map_window1(unsigned long base, unsigned long length)
+{
+	unsigned long temp;
+
+	__direct_map_base = base;
+	__direct_map_size = length;
+
+	temp = (base & 0xfff00000UL) | ((base + length - 1) >> 20);
+	*(vulp)T2_WBASE1 = temp | 0x80000UL; /* OR in ENABLE bit */
+	temp = (length - 1) & 0xfff00000UL;
+	*(vulp)T2_WMASK1 = temp;
+	*(vulp)T2_TBASE1 = 0;
+
+#if DEBUG_PRINT_FINAL_SETTINGS
+	printk("%s: setting WBASE1=0x%lx WMASK1=0x%lx TBASE1=0x%lx\n",
+	       __FUNCTION__,
+	       *(vulp)T2_WBASE1,
+	       *(vulp)T2_WMASK1,
+	       *(vulp)T2_TBASE1);
+#endif
+}
+
+static void __init
+t2_sg_map_window2(struct pci_controller *hose,
+		  unsigned long base,
+		  unsigned long length)
+{
+	unsigned long temp;
+
+	/* Note we can only do 1 SG window, as the other is for direct, so
+	   do an ISA SG area, especially for the floppy. */
+	hose->sg_isa = iommu_arena_new(hose, base, length, 0);
+	hose->sg_pci = NULL;
+
+	temp = (base & 0xfff00000UL) | ((base + length - 1) >> 20);
+	*(vulp)T2_WBASE2 = temp | 0xc0000UL; /* OR in ENABLE/SG bits */
+	temp = (length - 1) & 0xfff00000UL;
+	*(vulp)T2_WMASK2 = temp;
+	*(vulp)T2_TBASE2 = virt_to_phys(hose->sg_isa->ptes) >> 1;
+	mb();
+
+	t2_pci_tbi(hose, 0, -1); /* flush TLB all */
+
+#if DEBUG_PRINT_FINAL_SETTINGS
+	printk("%s: setting WBASE2=0x%lx WMASK2=0x%lx TBASE2=0x%lx\n",
+	       __FUNCTION__,
+	       *(vulp)T2_WBASE2,
+	       *(vulp)T2_WMASK2,
+	       *(vulp)T2_TBASE2);
+#endif
+}
+
+static void __init
+t2_save_configuration(void)
+{
+#if DEBUG_PRINT_INITIAL_SETTINGS
+	printk("%s: HAE_1 was 0x%lx\n", __FUNCTION__, srm_hae); /* HW is 0 */
+	printk("%s: HAE_2 was 0x%lx\n", __FUNCTION__, *(vulp)T2_HAE_2);
+	printk("%s: HAE_3 was 0x%lx\n", __FUNCTION__, *(vulp)T2_HAE_3);
+	printk("%s: HAE_4 was 0x%lx\n", __FUNCTION__, *(vulp)T2_HAE_4);
+	printk("%s: HBASE was 0x%lx\n", __FUNCTION__, *(vulp)T2_HBASE);
+
+	printk("%s: WBASE1=0x%lx WMASK1=0x%lx TBASE1=0x%lx\n", __FUNCTION__, 
+	       *(vulp)T2_WBASE1, *(vulp)T2_WMASK1, *(vulp)T2_TBASE1);
+	printk("%s: WBASE2=0x%lx WMASK2=0x%lx TBASE2=0x%lx\n", __FUNCTION__, 
+	       *(vulp)T2_WBASE2, *(vulp)T2_WMASK2, *(vulp)T2_TBASE2);
+#endif
+
+	/*
+	 * Save the DMA Window registers.
+	 */
+	t2_saved_config.window[0].wbase = *(vulp)T2_WBASE1;
+	t2_saved_config.window[0].wmask = *(vulp)T2_WMASK1;
+	t2_saved_config.window[0].tbase = *(vulp)T2_TBASE1;
+	t2_saved_config.window[1].wbase = *(vulp)T2_WBASE2;
+	t2_saved_config.window[1].wmask = *(vulp)T2_WMASK2;
+	t2_saved_config.window[1].tbase = *(vulp)T2_TBASE2;
+
+	t2_saved_config.hae_1 = srm_hae; /* HW is already set to 0 */
+	t2_saved_config.hae_2 = *(vulp)T2_HAE_2;
+	t2_saved_config.hae_3 = *(vulp)T2_HAE_3;
+	t2_saved_config.hae_4 = *(vulp)T2_HAE_4;
+	t2_saved_config.hbase = *(vulp)T2_HBASE;
+}
+
 void __init
 t2_init_arch(void)
 {
 	struct pci_controller *hose;
-	unsigned long t2_iocsr;
+	unsigned long temp;
 	unsigned int i;
 
 	for (i = 0; i < NR_CPUS; i++) {
 		mcheck_expected(i) = 0;
 		mcheck_taken(i) = 0;
 	}
-
-#if 0
-	/* Set up error reporting.  */
-	t2_iocsr = *(vulp)T2_IOCSR;
-	*(vulp)T2_IOCSR = t2_iocsr | (0x1UL << 7); /* TLB error check */
-	mb();
-	*(vulp)T2_IOCSR; /* read it back to make sure */
-#endif
+	t2_mcheck_any_expected = 0;
+	t2_mcheck_last_taken = 0;
 
 	/* Enable scatter/gather TLB use.  */
-	t2_iocsr = *(vulp)T2_IOCSR;
-	if (!(t2_iocsr & (0x1UL << 26))) {
+	temp = *(vulp)T2_IOCSR;
+	if (!(temp & (0x1UL << 26))) {
 		printk("t2_init_arch: enabling SG TLB, IOCSR was 0x%lx\n",
-		       t2_iocsr);
-		*(vulp)T2_IOCSR = t2_iocsr | (0x1UL << 26);
+		       temp);
+		*(vulp)T2_IOCSR = temp | (0x1UL << 26);
 		mb();	
 		*(vulp)T2_IOCSR; /* read it back to make sure */
 	}
 
-#if 0
-	printk("t2_init_arch: HBASE was 0x%lx\n", *(vulp)T2_HBASE);
-	printk("t2_init_arch: WBASE1=0x%lx WMASK1=0x%lx TBASE1=0x%lx\n",
-	       *(vulp)T2_WBASE1, *(vulp)T2_WMASK1, *(vulp)T2_TBASE1);
-	printk("t2_init_arch: WBASE2=0x%lx WMASK2=0x%lx TBASE2=0x%lx\n",
-	       *(vulp)T2_WBASE2, *(vulp)T2_WMASK2, *(vulp)T2_TBASE2);
-#endif
+	t2_save_configuration();
 
 	/*
 	 * Create our single hose.
 	 */
-
 	pci_isa_hose = hose = alloc_pci_controller();
 	hose->io_space = &ioport_resource;
 	hose->mem_space = &iomem_resource;
@@ -385,52 +490,51 @@
 	hose->sparse_io_base = T2_IO - IDENT_ADDR;
 	hose->dense_io_base = 0;
 
-	/* Note we can only do 1 SG window, as the other is for direct, so
-	   do an ISA SG area, especially for the floppy. */
-	hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, 0);
-	hose->sg_pci = NULL;
-
 	/*
 	 * Set up the PCI->physical memory translation windows.
 	 *
-	 * Window 1 goes at ? GB and is ?GB large, direct mapped.
-	 * Window 2 goes at 8 MB and is 8MB large, scatter/gather (for ISA).
+	 * Window 1 is direct mapped.
+	 * Window 2 is scatter/gather (for ISA).
 	 */
 
-#if T2_DIRECTMAP_2G
-	__direct_map_base = 0x80000000UL;
-	__direct_map_size = 0x80000000UL;
-
-	/* WARNING!! must correspond to the direct map window params!!! */
-	*(vulp)T2_WBASE1 = 0x80080fffU;
-	*(vulp)T2_WMASK1 = 0x7ff00000U;
-	*(vulp)T2_TBASE1 = 0;
-#else /* T2_DIRECTMAP_2G */
-	__direct_map_base = 0x40000000UL;
-	__direct_map_size = 0x40000000UL;
-
-	/* WARNING!! must correspond to the direct map window params!!! */
-	*(vulp)T2_WBASE1 = 0x400807ffU;
-	*(vulp)T2_WMASK1 = 0x3ff00000U;
-	*(vulp)T2_TBASE1 = 0;
-#endif /* T2_DIRECTMAP_2G */
+	t2_direct_map_window1(T2_DIRECTMAP_START, T2_DIRECTMAP_LENGTH);
 
-	/* WARNING!! must correspond to the SG arena/window params!!! */
-	*(vulp)T2_WBASE2 = 0x008c000fU;
-	*(vulp)T2_WMASK2 = 0x00700000U;
-	*(vulp)T2_TBASE2 = virt_to_phys(hose->sg_isa->ptes) >> 1;
+	/* Always make an ISA DMA window. */
+	t2_sg_map_window2(hose, T2_ISA_SG_START, T2_ISA_SG_LENGTH);
 
-	*(vulp)T2_HBASE = 0x0;
+	*(vulp)T2_HBASE = 0x0; /* Disable HOLES. */
 
 	/* Zero HAE.  */
-	*(vulp)T2_HAE_1 = 0; mb();
-	*(vulp)T2_HAE_2 = 0; mb();
-	*(vulp)T2_HAE_3 = 0; mb();
+	*(vulp)T2_HAE_1 = 0; mb(); /* Sparse MEM HAE */
+	*(vulp)T2_HAE_2 = 0; mb(); /* Sparse I/O HAE */
+	*(vulp)T2_HAE_3 = 0; mb(); /* Config Space HAE */
 #if 0
-	*(vulp)T2_HAE_4 = 0; mb(); /* DO NOT TOUCH THIS!!! */
+	/* !!! DO NOT EVER TOUCH THIS !!! */
+	*(vulp)T2_HAE_4 = 0; mb(); /* Dense MEM HAE */
 #endif
+}
 
-	t2_pci_tbi(hose, 0, -1); /* flush TLB all */
+void
+t2_kill_arch(int mode)
+{
+	/*
+	 * Restore the DMA Window registers.
+	 */
+	*(vulp)T2_WBASE1 = t2_saved_config.window[0].wbase;
+	*(vulp)T2_WMASK1 = t2_saved_config.window[0].wmask;
+	*(vulp)T2_TBASE1 = t2_saved_config.window[0].tbase;
+	*(vulp)T2_WBASE2 = t2_saved_config.window[1].wbase;
+	*(vulp)T2_WMASK2 = t2_saved_config.window[1].wmask;
+	*(vulp)T2_TBASE2 = t2_saved_config.window[1].tbase;
+	mb();
+
+	*(vulp)T2_HAE_1 = srm_hae;
+	*(vulp)T2_HAE_2 = t2_saved_config.hae_2;
+	*(vulp)T2_HAE_3 = t2_saved_config.hae_3;
+	*(vulp)T2_HAE_4 = t2_saved_config.hae_4;
+	*(vulp)T2_HBASE = t2_saved_config.hbase;
+	mb();
+	*(vulp)T2_HBASE; /* READ it back to ensure WRITE occurred. */
 }
 
 void
@@ -458,13 +562,7 @@
 {
 	struct sable_cpu_csr *cpu_regs;
 
-	cpu_regs = (struct sable_cpu_csr *)T2_CPU0_BASE;
-	if (cpu == 1)
-		cpu_regs = (struct sable_cpu_csr *)T2_CPU1_BASE;
-	if (cpu == 2)
-		cpu_regs = (struct sable_cpu_csr *)T2_CPU2_BASE;
-	if (cpu == 3)
-		cpu_regs = (struct sable_cpu_csr *)T2_CPU3_BASE;
+	cpu_regs = (struct sable_cpu_csr *)T2_CPUn_BASE(cpu);
 		
 	cpu_regs->sic &= ~SIC_SEIC;
 
@@ -481,19 +579,74 @@
 	mb();  /* magic */
 }
 
+/*
+ * SABLE seems to have a "broadcast" style machine check, in that all
+ * CPUs receive it. And, the issuing CPU, in the case of PCI Config
+ * space read/write faults, will also receive a second mcheck, upon
+ * lowering IPL during completion processing in pci_read_config_byte()
+ * et al.
+ *
+ * Hence all the taken/expected/any_expected/last_taken stuff...
+ */
 void
 t2_machine_check(unsigned long vector, unsigned long la_ptr,
 		 struct pt_regs * regs)
 {
 	int cpu = smp_processor_id();
+	struct el_common *mchk_header = (struct el_common *)la_ptr;
 
 	/* Clear the error before any reporting.  */
 	mb();
 	mb();  /* magic */
 	draina();
 	t2_clear_errors(cpu);
-	wrmces(rdmces()|1);	/* ??? */
-	mb();
+
+	/* This should not actually be done until the logout frame is
+	   examined, but, since we don't do that, go on and do this... */
+	wrmces(0x7);
+	mb();
+
+	/* Now, do testing for the anomalous conditions. */
+	if (!mcheck_expected(cpu) && t2_mcheck_any_expected) {
+		/*
+		 * FUNKY: Received mcheck on a CPU and not
+		 * expecting it, but another CPU is expecting one.
+		 *
+		 * Just dismiss it for now on this CPU...
+		 */
+#if DEBUG_MCHECK > 0
+		printk("t2_machine_check(cpu%d): any_expected 0x%x -"
+		       " (assumed) spurious -"
+		       " code 0x%x\n", cpu, t2_mcheck_any_expected,
+		       (unsigned int)mchk_header->code);
+#endif /* DEBUG_MCHECK */
+		return;
+	}
+
+	if (!mcheck_expected(cpu) && !t2_mcheck_any_expected) {
+		if (t2_mcheck_last_taken & (1 << cpu)) {
+#if DEBUG_MCHECK > 0
+			printk("t2_machine_check(cpu%d): last_taken 0x%x -"
+			       " unexpected mcheck -"
+			       " code 0x%x\n", cpu, t2_mcheck_last_taken,
+			       (unsigned int)mchk_header->code);
+#endif /* DEBUG_MCHECK */
+			t2_mcheck_last_taken = 0;
+			mb();
+			return;
+		} else {
+			t2_mcheck_last_taken = 0;
+			mb();
+		}
+	}
+
+#if DEBUG_MCHECK > 0
+	printk("%s t2_mcheck(cpu%d): last_taken 0x%x -"
+	       " any_expected 0x%x - code 0x%x\n",
+	       (mcheck_expected(cpu) ? "EX" : "UN"),
+	       cpu, t2_mcheck_last_taken, t2_mcheck_any_expected,
+	       (unsigned int)mchk_header->code);
+#endif /* DEBUG_MCHECK */
 
 	process_mcheck_info(vector, la_ptr, regs, "T2", mcheck_expected(cpu));
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/alpha/kernel/proto.h linux-2.4.22-pre2/arch/alpha/kernel/proto.h
--- linux-2.4.21/arch/alpha/kernel/proto.h	2003-06-26 21:45:04.000000000 +0000
+++ linux-2.4.22-pre2/arch/alpha/kernel/proto.h	2003-06-26 21:43:13.000000000 +0000
@@ -76,6 +76,7 @@
 /* core_t2.c */
 extern struct pci_ops t2_pci_ops;
 extern void t2_init_arch(void);
+extern void t2_kill_arch(int);
 extern void t2_machine_check(u64, u64, struct pt_regs *);
 extern void t2_pci_tbi(struct pci_controller *, dma_addr_t, dma_addr_t);
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/alpha/kernel/setup.c linux-2.4.22-pre2/arch/alpha/kernel/setup.c
--- linux-2.4.21/arch/alpha/kernel/setup.c	2003-06-26 21:45:04.000000000 +0000
+++ linux-2.4.22-pre2/arch/alpha/kernel/setup.c	2003-06-26 21:43:13.000000000 +0000
@@ -154,6 +154,7 @@
 WEAK(eiger_mv);
 WEAK(jensen_mv);
 WEAK(lx164_mv);
+WEAK(lynx_mv);
 WEAK(marvel_ev7_mv);
 WEAK(miata_mv);
 WEAK(mikasa_mv);
@@ -260,7 +261,7 @@
 	unsigned long size;
 
 	size = initrd_end - initrd_start;
-	start = __alloc_bootmem(size, PAGE_SIZE, 0);
+	start = __alloc_bootmem(PAGE_ALIGN(size), PAGE_SIZE, 0);
 	if (!start || __pa(start) + size > mem_limit) {
 		initrd_start = initrd_end = 0;
 		return NULL;
@@ -720,7 +721,7 @@
 		NULL,		/* Turbolaser */
 		&avanti_mv,
 		NULL,		/* Mustang */
-		&alcor_mv,	/* Alcor, Bret, Maverick.  */
+		NULL,		/* Alcor, Bret, Maverick. HWRPB inaccurate? */
 		NULL,		/* Tradewind */
 		NULL,		/* Mikasa -- see below.  */
 		NULL,		/* EB64 */
@@ -729,7 +730,7 @@
 		&alphabook1_mv,
 		&rawhide_mv,
 		NULL,		/* K2 */
-		NULL,		/* Lynx */
+		&lynx_mv,	/* Lynx */
 		&xl_mv,
 		NULL,		/* EB164 -- see variation.  */
 		NULL,		/* Noritake -- see below.  */
@@ -915,6 +916,7 @@
 		&eiger_mv,
 		&jensen_mv,
 		&lx164_mv,
+		&lynx_mv,
 		&miata_mv,
 		&mikasa_mv,
 		&mikasa_primo_mv,
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/alpha/kernel/sys_nautilus.c linux-2.4.22-pre2/arch/alpha/kernel/sys_nautilus.c
--- linux-2.4.21/arch/alpha/kernel/sys_nautilus.c	2003-06-26 21:45:04.000000000 +0000
+++ linux-2.4.22-pre2/arch/alpha/kernel/sys_nautilus.c	2003-06-26 21:43:18.000000000 +0000
@@ -76,6 +76,9 @@
 void
 nautilus_kill_arch(int mode)
 {
+	u32 pmuport;
+	int off;
+
 	switch (mode) {
 	case LINUX_REBOOT_CMD_RESTART:
 		if (! alpha_using_srm) {
@@ -89,14 +92,18 @@
 		break;
 
 	case LINUX_REBOOT_CMD_POWER_OFF:
-		{
-			u32 pmuport;
-			pcibios_read_config_dword(0, 0x88, 0x10, &pmuport);
-			pmuport &= 0xfffe;
-			outl(0xffff, pmuport); /* clear pending events */
-			outw(0x2000, pmuport+4); /* power off */
-			/* NOTREACHED */
+		/* Assume M1543C */
+		off = 0x2000;		/* SLP_TYPE = 0, SLP_EN = 1 */
+		pcibios_read_config_dword(0, 0x88, 0x10, &pmuport);
+		if (!pmuport) {
+			/* M1535D/D+ */
+			off = 0x3400;	/* SLP_TYPE = 5, SLP_EN = 1 */
+			pcibios_read_config_dword(0, 0x88, 0xe0, &pmuport);
 		}
+		pmuport &= 0xfffe;
+		outw(0xffff, pmuport);	/* Clear pending events. */
+		outw(off, pmuport + 4);
+		/* NOTREACHED */
 		break;
 	}
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/alpha/kernel/sys_sable.c linux-2.4.22-pre2/arch/alpha/kernel/sys_sable.c
--- linux-2.4.21/arch/alpha/kernel/sys_sable.c	2003-06-26 21:45:04.000000000 +0000
+++ linux-2.4.22-pre2/arch/alpha/kernel/sys_sable.c	2003-06-26 21:43:11.000000000 +0000
@@ -5,7 +5,7 @@
  *	Copyright (C) 1996 Jay A Estabrook
  *	Copyright (C) 1998, 1999 Richard Henderson
  *
- * Code supporting the Sable and Sable-Gamma systems.
+ * Code supporting the Sable, Sable-Gamma, and Lynx systems.
  */
 
 #include <linux/config.h>
@@ -30,8 +30,28 @@
 #include "pci_impl.h"
 #include "machvec_impl.h"
 
-spinlock_t sable_irq_lock = SPIN_LOCK_UNLOCKED;
+spinlock_t sable_lynx_irq_lock = SPIN_LOCK_UNLOCKED;
 
+typedef struct irq_swizzle_struct
+{
+	char irq_to_mask[64];
+	char mask_to_irq[64];
+
+	/* Note mask bit is true for DISABLED irqs.  */
+	unsigned long shadow_mask;
+
+	void (*update_irq_hw)(unsigned long bit, unsigned long mask);
+	void (*ack_irq_hw)(unsigned long bit);
+
+} irq_swizzle_t;
+
+static irq_swizzle_t *sable_lynx_irq_swizzle;
+
+static void sable_lynx_init_irq(int nr_irqs);
+
+#if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_SABLE)
+
+/***********************************************************************/
 /*
  *   For SABLE, which is really baroque, we manage 40 IRQ's, but the
  *   hardware really only supports 24, not via normal ISA PIC,
@@ -70,30 +90,7 @@
  *23        IIC				-
  */
 
-static struct 
-{
-	char irq_to_mask[40];
-	char mask_to_irq[40];
-
-	/* Note mask bit is true for DISABLED irqs.  */
-	unsigned long shadow_mask;
-} sable_irq_swizzle = {
-	{
-		-1,  6, -1,  8, 15, 12,  7,  9,	/* pseudo PIC  0-7  */
-		-1, 16, 17, 18,  3, -1, 21, 22,	/* pseudo PIC  8-15 */
-		-1, -1, -1, -1, -1, -1, -1, -1,	/* pseudo EISA 0-7  */
-		-1, -1, -1, -1, -1, -1, -1, -1,	/* pseudo EISA 8-15 */
-		 2,  1,  0,  4,  5, -1, -1, -1,	/* pseudo PCI */
-	},
-	{
-		34, 33, 32, 12, 35, 36,  1,  6,	/* mask 0-7  */
-		 3,  7, -1, -1,  5, -1, -1,  4,	/* mask 8-15  */
-		 9, 10, 11, -1, -1, 14, 15, -1,	/* mask 16-23  */
-	},
-	-1
-};
-
-static inline void
+static void
 sable_update_irq_hw(unsigned long bit, unsigned long mask)
 {
 	int port = 0x537;
@@ -109,7 +106,7 @@
 	outb(mask, port);
 }
 
-static inline void
+static void
 sable_ack_irq_hw(unsigned long bit)
 {
 	int port, val1, val2;
@@ -132,102 +129,46 @@
 	outb(val2, 0x534);	/* ack the master */
 }
 
-static inline void
-sable_enable_irq(unsigned int irq)
-{
-	unsigned long bit, mask;
-
-	bit = sable_irq_swizzle.irq_to_mask[irq];
-	spin_lock(&sable_irq_lock);
-	mask = sable_irq_swizzle.shadow_mask &= ~(1UL << bit);
-	sable_update_irq_hw(bit, mask);
-	spin_unlock(&sable_irq_lock);
-}
-
-static void
-sable_disable_irq(unsigned int irq)
-{
-	unsigned long bit, mask;
-
-	bit = sable_irq_swizzle.irq_to_mask[irq];
-	spin_lock(&sable_irq_lock);
-	mask = sable_irq_swizzle.shadow_mask |= 1UL << bit;
-	sable_update_irq_hw(bit, mask);
-	spin_unlock(&sable_irq_lock);
-}
-
-static unsigned int
-sable_startup_irq(unsigned int irq)
-{
-	sable_enable_irq(irq);
-	return 0;
-}
-
-static void
-sable_end_irq(unsigned int irq)
-{
-	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
-		sable_enable_irq(irq);
-}
-
-static void
-sable_mask_and_ack_irq(unsigned int irq)
-{
-	unsigned long bit, mask;
-
-	bit = sable_irq_swizzle.irq_to_mask[irq];
-	spin_lock(&sable_irq_lock);
-	mask = sable_irq_swizzle.shadow_mask |= 1UL << bit;
-	sable_update_irq_hw(bit, mask);
-	sable_ack_irq_hw(bit);
-	spin_unlock(&sable_irq_lock);
-}
-
-static struct hw_interrupt_type sable_irq_type = {
-	typename:	"SABLE",
-	startup:	sable_startup_irq,
-	shutdown:	sable_disable_irq,
-	enable:		sable_enable_irq,
-	disable:	sable_disable_irq,
-	ack:		sable_mask_and_ack_irq,
-	end:		sable_end_irq,
+static irq_swizzle_t sable_irq_swizzle = {
+	{
+		-1,  6, -1,  8, 15, 12,  7,  9,	/* pseudo PIC  0-7  */
+		-1, 16, 17, 18,  3, -1, 21, 22,	/* pseudo PIC  8-15 */
+		-1, -1, -1, -1, -1, -1, -1, -1,	/* pseudo EISA 0-7  */
+		-1, -1, -1, -1, -1, -1, -1, -1,	/* pseudo EISA 8-15  */
+		 2,  1,  0,  4,  5, -1, -1, -1,	/* pseudo PCI */
+		-1, -1, -1, -1, -1, -1, -1, -1,	/*  */
+		-1, -1, -1, -1, -1, -1, -1, -1,	/*  */
+		-1, -1, -1, -1, -1, -1, -1, -1 	/*  */
+	},
+	{
+		34, 33, 32, 12, 35, 36,  1,  6,	/* mask 0-7  */
+		 3,  7, -1, -1,  5, -1, -1,  4,	/* mask 8-15  */
+		 9, 10, 11, -1, -1, 14, 15, -1,	/* mask 16-23  */
+		-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, -1, -1, -1, -1, -1, -1,	/*  */
+		-1, -1, -1, -1, -1, -1, -1, -1	/*  */
+	},
+	-1,
+	sable_update_irq_hw,
+	sable_ack_irq_hw
 };
 
-static void 
-sable_srm_device_interrupt(unsigned long vector, struct pt_regs * regs)
-{
-	/* Note that the vector reported by the SRM PALcode corresponds
-	   to the interrupt mask bits, but we have to manage via more
-	   normal IRQs.  */
-
-	int bit, irq;
-
-	bit = (vector - 0x800) >> 4;
-	irq = sable_irq_swizzle.mask_to_irq[bit];
-	handle_irq(irq, regs);
-}
-
 static void __init
 sable_init_irq(void)
 {
-	long i;
-
 	outb(-1, 0x537);	/* slave 0 */
 	outb(-1, 0x53b);	/* slave 1 */
 	outb(-1, 0x53d);	/* slave 2 */
 	outb(0x44, 0x535);	/* enable cascades in master */
 
-	for (i = 0; i < 40; ++i) {
-		irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
-		irq_desc[i].handler = &sable_irq_type;
-	}
-	
-	common_init_isa_dma();
+	sable_lynx_irq_swizzle = &sable_irq_swizzle;
+	sable_lynx_init_irq(40);
 }
 
-
 /*
- * PCI Fixup configuration for ALPHA SABLE (2100) - 2100A is different ??
+ * PCI Fixup configuration for ALPHA SABLE (2100).
  *
  * The device to slot mapping looks like:
  *
@@ -255,7 +196,7 @@
 static int __init
 sable_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 {
-        static char irq_tab[9][5] __initdata = {
+	static char irq_tab[9][5] __initdata = {
 		/*INT    INTA   INTB   INTC   INTD */
 		{ 32+0,  32+0,  32+0,  32+0,  32+0},  /* IdSel 0,  TULIP  */
 		{ 32+1,  32+1,  32+1,  32+1,  32+1},  /* IdSel 1,  SCSI   */
@@ -265,13 +206,349 @@
 		{   -1,    -1,    -1,    -1,    -1},  /* IdSel 5,  none   */
 		{ 32+2,  32+2,  32+2,  32+2,  32+2},  /* IdSel 6,  slot 0 */
 		{ 32+3,  32+3,  32+3,  32+3,  32+3},  /* IdSel 7,  slot 1 */
-		{ 32+4,  32+4,  32+4,  32+4,  32+4},  /* IdSel 8,  slot 2 */
-        };
+		{ 32+4,  32+4,  32+4,  32+4,  32+4}   /* IdSel 8,  slot 2 */
+	};
 	const long min_idsel = 0, max_idsel = 8, irqs_per_slot = 5;
 	return COMMON_TABLE_LOOKUP;
 }
+#endif /* defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_SABLE) */
+
+#if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_LYNX)
+
+/***********************************************************************/
+/* LYNX hardware specifics
+ */
+/*
+ *   For LYNX, which is also baroque, we manage 64 IRQs, via a custom IC.
+ *
+ * Bit      Meaning               Kernel IRQ
+ *------------------------------------------
+ * 0        
+ * 1        
+ * 2        
+ * 3        mouse			12
+ * 4        
+ * 5        
+ * 6        keyboard			1
+ * 7        floppy			6
+ * 8        COM2			3
+ * 9        parallel port		7
+ *10        EISA irq 3			-
+ *11        EISA irq 4			-
+ *12        EISA irq 5			5
+ *13        EISA irq 6			-
+ *14        EISA irq 7			-
+ *15        COM1			4
+ *16        EISA irq 9			9
+ *17        EISA irq 10			10
+ *18        EISA irq 11			11
+ *19        EISA irq 12			-
+ *20        
+ *21        EISA irq 14			14
+ *22        EISA irq 15			15
+ *23        IIC				-
+ *24        VGA (builtin)               -
+ *25
+ *26
+ *27
+ *28        NCR810 (builtin)		28
+ *29
+ *30
+ *31
+ *32        PCI 0 slot 4 A primary bus  32
+ *33        PCI 0 slot 4 B primary bus  33
+ *34        PCI 0 slot 4 C primary bus  34
+ *35        PCI 0 slot 4 D primary bus
+ *36        PCI 0 slot 5 A primary bus
+ *37        PCI 0 slot 5 B primary bus
+ *38        PCI 0 slot 5 C primary bus
+ *39        PCI 0 slot 5 D primary bus
+ *40        PCI 0 slot 6 A primary bus
+ *41        PCI 0 slot 6 B primary bus
+ *42        PCI 0 slot 6 C primary bus
+ *43        PCI 0 slot 6 D primary bus
+ *44        PCI 0 slot 7 A primary bus
+ *45        PCI 0 slot 7 B primary bus
+ *46        PCI 0 slot 7 C primary bus
+ *47        PCI 0 slot 7 D primary bus
+ *48        PCI 0 slot 0 A secondary bus
+ *49        PCI 0 slot 0 B secondary bus
+ *50        PCI 0 slot 0 C secondary bus
+ *51        PCI 0 slot 0 D secondary bus
+ *52        PCI 0 slot 1 A secondary bus
+ *53        PCI 0 slot 1 B secondary bus
+ *54        PCI 0 slot 1 C secondary bus
+ *55        PCI 0 slot 1 D secondary bus
+ *56        PCI 0 slot 2 A secondary bus
+ *57        PCI 0 slot 2 B secondary bus
+ *58        PCI 0 slot 2 C secondary bus
+ *59        PCI 0 slot 2 D secondary bus
+ *60        PCI 0 slot 3 A secondary bus
+ *61        PCI 0 slot 3 B secondary bus
+ *62        PCI 0 slot 3 C secondary bus
+ *63        PCI 0 slot 3 D secondary bus
+ */
+
+static void
+lynx_update_irq_hw(unsigned long bit, unsigned long mask)
+{
+	/*
+	 * Write the AIR register on the T3/T4 with the
+	 * address of the IC mask register (offset 0x40)
+	 */
+	*(vulp)T2_AIR = 0x40;
+	mb();
+	*(vulp)T2_AIR; /* re-read to force write */
+	mb();
+	*(vulp)T2_DIR = mask;    
+	mb();
+	mb();
+}
+
+static void
+lynx_ack_irq_hw(unsigned long bit)
+{
+	*(vulp)T2_VAR = (u_long) bit;
+	mb();
+	mb();
+}
+
+static irq_swizzle_t lynx_irq_swizzle = {
+	{ /* irq_to_mask */
+		-1,  6, -1,  8, 15, 12,  7,  9,	/* pseudo PIC  0-7  */
+		-1, 16, 17, 18,  3, -1, 21, 22,	/* pseudo PIC  8-15 */
+		-1, -1, -1, -1, -1, -1, -1, -1,	/* pseudo */
+		-1, -1, -1, -1, 28, -1, -1, -1,	/* pseudo */
+		32, 33, 34, 35, 36, 37, 38, 39,	/* mask 32-39 */
+		40, 41, 42, 43, 44, 45, 46, 47,	/* mask 40-47 */
+		48, 49, 50, 51, 52, 53, 54, 55,	/* mask 48-55 */
+		56, 57, 58, 59, 60, 61, 62, 63	/* mask 56-63 */
+	},
+	{ /* mask_to_irq */
+		-1, -1, -1, 12, -1, -1,  1,  6,	/* mask 0-7   */
+		 3,  7, -1, -1,  5, -1, -1,  4,	/* mask 8-15  */
+		 9, 10, 11, -1, -1, 14, 15, -1,	/* mask 16-23 */
+		-1, -1, -1, -1, 28, -1, -1, -1,	/* mask 24-31 */
+		32, 33, 34, 35, 36, 37, 38, 39,	/* mask 32-39 */
+		40, 41, 42, 43, 44, 45, 46, 47,	/* mask 40-47 */
+		48, 49, 50, 51, 52, 53, 54, 55,	/* mask 48-55 */
+		56, 57, 58, 59, 60, 61, 62, 63	/* mask 56-63 */
+	},
+	-1,
+	lynx_update_irq_hw,
+	lynx_ack_irq_hw
+};
+
+static void __init
+lynx_init_irq(void)
+{
+	sable_lynx_irq_swizzle = &lynx_irq_swizzle;
+	sable_lynx_init_irq(64);
+}
+
+/*
+ * PCI Fixup configuration for ALPHA LYNX (2100A)
+ *
+ * The device to slot mapping looks like:
+ *
+ * Slot     Device
+ *  0       none
+ *  1       none
+ *  2       PCI-EISA bridge
+ *  3       PCI-PCI bridge
+ *  4       NCR 810 (Demi-Lynx only)
+ *  5       none
+ *  6       PCI on board slot 4
+ *  7       PCI on board slot 5
+ *  8       PCI on board slot 6
+ *  9       PCI on board slot 7
+ *
+ * And behind the PPB we have:
+ *
+ * 11       PCI on board slot 0
+ * 12       PCI on board slot 1
+ * 13       PCI on board slot 2
+ * 14       PCI on board slot 3
+ */
+/*
+ * NOTE: the IRQ assignments below are arbitrary, but need to be consistent
+ * with the values in the irq swizzling tables above.
+ */
+
+static int __init
+lynx_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
+{
+	static char irq_tab[19][5] __initdata = {
+		/*INT    INTA   INTB   INTC   INTD */
+		{   -1,    -1,    -1,    -1,    -1},  /* IdSel 13,  PCEB   */
+		{   -1,    -1,    -1,    -1,    -1},  /* IdSel 14,  PPB    */
+		{   28,    28,    28,    28,    28},  /* IdSel 15,  NCR demi */
+		{   -1,    -1,    -1,    -1,    -1},  /* IdSel 16,  none   */
+		{   32,    32,    33,    34,    35},  /* IdSel 17,  slot 4 */
+		{   36,    36,    37,    38,    39},  /* IdSel 18,  slot 5 */
+		{   40,    40,    41,    42,    43},  /* IdSel 19,  slot 6 */
+		{   44,    44,    45,    46,    47},  /* IdSel 20,  slot 7 */
+		{   -1,    -1,    -1,    -1,    -1},  /* IdSel 22,  none   */
+		/* The following are actually behind the PPB. */
+		{   -1,    -1,    -1,    -1,    -1},  /* IdSel 16   none */
+		{   28,    28,    28,    28,    28},  /* IdSel 17   NCR lynx */
+		{   -1,    -1,    -1,    -1,    -1},  /* IdSel 18   none */
+		{   -1,    -1,    -1,    -1,    -1},  /* IdSel 19   none */
+		{   -1,    -1,    -1,    -1,    -1},  /* IdSel 20   none */
+		{   -1,    -1,    -1,    -1,    -1},  /* IdSel 21   none */
+		{   48,    48,    49,    50,    51},  /* IdSel 22   slot 0 */
+		{   52,    52,    53,    54,    55},  /* IdSel 23   slot 1 */
+		{   56,    56,    57,    58,    59},  /* IdSel 24   slot 2 */
+		{   60,    60,    61,    62,    63}   /* IdSel 25   slot 3 */
+	};
+	const long min_idsel = 2, max_idsel = 20, irqs_per_slot = 5;
+	return COMMON_TABLE_LOOKUP;
+}
+
+static u8 __init
+lynx_swizzle(struct pci_dev *dev, u8 *pinp)
+{
+	int slot, pin = *pinp;
+
+	if (dev->bus->number == 0) {
+		slot = PCI_SLOT(dev->devfn);
+	}
+	/* Check for the built-in bridge */
+	else if (PCI_SLOT(dev->bus->self->devfn) == 3) {
+		slot = PCI_SLOT(dev->devfn) + 11;
+	}
+	else
+	{
+		/* Must be a card-based bridge.  */
+		do {
+			if (PCI_SLOT(dev->bus->self->devfn) == 3) {
+				slot = PCI_SLOT(dev->devfn) + 11;
+				break;
+			}
+			pin = bridge_swizzle(pin, PCI_SLOT(dev->devfn)) ;
+
+			/* Move up the chain of bridges.  */
+			dev = dev->bus->self;
+			/* Slot of the next bridge.  */
+			slot = PCI_SLOT(dev->devfn);
+		} while (dev->bus->self);
+	}
+	*pinp = pin;
+	return slot;
+}
+
+#endif /* defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_LYNX) */
+
+/***********************************************************************/
+/* GENERIC irq routines */
+
+static inline void
+sable_lynx_enable_irq(unsigned int irq)
+{
+	unsigned long bit, mask;
+
+	bit = sable_lynx_irq_swizzle->irq_to_mask[irq];
+	spin_lock(&sable_lynx_irq_lock);
+	mask = sable_lynx_irq_swizzle->shadow_mask &= ~(1UL << bit);
+	sable_lynx_irq_swizzle->update_irq_hw(bit, mask);
+	spin_unlock(&sable_lynx_irq_lock);
+#if 0
+	printk("%s: mask 0x%lx bit 0x%x irq 0x%x\n",
+	       __FUNCTION__, mask, bit, irq);
+#endif
+}
 
+static void
+sable_lynx_disable_irq(unsigned int irq)
+{
+	unsigned long bit, mask;
 
+	bit = sable_lynx_irq_swizzle->irq_to_mask[irq];
+	spin_lock(&sable_lynx_irq_lock);
+	mask = sable_lynx_irq_swizzle->shadow_mask |= 1UL << bit;
+	sable_lynx_irq_swizzle->update_irq_hw(bit, mask);
+	spin_unlock(&sable_lynx_irq_lock);
+#if 0
+	printk("%s: mask 0x%lx bit 0x%x irq 0x%x\n",
+	       __FUNCTION__, mask, bit, irq);
+#endif
+}
+
+static unsigned int
+sable_lynx_startup_irq(unsigned int irq)
+{
+	sable_lynx_enable_irq(irq);
+	return 0;
+}
+
+static void
+sable_lynx_end_irq(unsigned int irq)
+{
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		sable_lynx_enable_irq(irq);
+}
+
+static void
+sable_lynx_mask_and_ack_irq(unsigned int irq)
+{
+	unsigned long bit, mask;
+
+	bit = sable_lynx_irq_swizzle->irq_to_mask[irq];
+	spin_lock(&sable_lynx_irq_lock);
+	mask = sable_lynx_irq_swizzle->shadow_mask |= 1UL << bit;
+	sable_lynx_irq_swizzle->update_irq_hw(bit, mask);
+	sable_lynx_irq_swizzle->ack_irq_hw(bit);
+	spin_unlock(&sable_lynx_irq_lock);
+}
+
+static struct hw_interrupt_type sable_lynx_irq_type = {
+	typename:	"SABLE/LYNX",
+	startup:	sable_lynx_startup_irq,
+	shutdown:	sable_lynx_disable_irq,
+	enable:		sable_lynx_enable_irq,
+	disable:	sable_lynx_disable_irq,
+	ack:		sable_lynx_mask_and_ack_irq,
+	end:		sable_lynx_end_irq,
+};
+
+static void 
+sable_lynx_srm_device_interrupt(unsigned long vector, struct pt_regs * regs)
+{
+	/* Note that the vector reported by the SRM PALcode corresponds
+	   to the interrupt mask bits, but we have to manage via the
+	   so-called legacy IRQs for many common devices.  */
+
+	int bit, irq;
+
+	bit = (vector - 0x800) >> 4;
+	irq = sable_lynx_irq_swizzle->mask_to_irq[bit];
+#if 0
+	printk("%s: vector 0x%lx bit 0x%x irq 0x%x\n",
+	       __FUNCTION__, vector, bit, irq);
+#endif
+	handle_irq(irq, regs);
+}
+
+static void __init
+sable_lynx_init_irq(int nr_irqs)
+{
+	long i;
+
+	for (i = 0; i < nr_irqs; ++i) {
+		irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
+		irq_desc[i].handler = &sable_lynx_irq_type;
+	}
+	
+	common_init_isa_dma();
+}
+
+static void __init
+sable_lynx_init_pci(void)
+{
+	common_init_pci();
+}
+
+/*****************************************************************/
 /*
  * The System Vectors
  *
@@ -279,7 +556,8 @@
  * these games with GAMMA_BIAS.
  */
 
-#if defined(CONFIG_ALPHA_GENERIC) || !defined(CONFIG_ALPHA_GAMMA)
+#if defined(CONFIG_ALPHA_GENERIC) || \
+    (defined(CONFIG_ALPHA_SABLE) && !defined(CONFIG_ALPHA_GAMMA))
 #undef GAMMA_BIAS
 #define GAMMA_BIAS 0
 struct alpha_machine_vector sable_mv __initmv = {
@@ -294,13 +572,13 @@
 	min_mem_address:	T2_DEFAULT_MEM_BASE,
 
 	nr_irqs:		40,
-	device_interrupt:	sable_srm_device_interrupt,
+	device_interrupt:	sable_lynx_srm_device_interrupt,
 
 	init_arch:		t2_init_arch,
 	init_irq:		sable_init_irq,
 	init_rtc:		common_init_rtc,
-	init_pci:		common_init_pci,
-	kill_arch:		NULL,
+	init_pci:		sable_lynx_init_pci,
+	kill_arch:		t2_kill_arch,
 	pci_map_irq:		sable_map_irq,
 	pci_swizzle:		common_swizzle,
 
@@ -309,9 +587,10 @@
 	} }
 };
 ALIAS_MV(sable)
-#endif
+#endif /* GENERIC || (SABLE && !GAMMA) */
 
-#if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_GAMMA)
+#if defined(CONFIG_ALPHA_GENERIC) || \
+    (defined(CONFIG_ALPHA_SABLE) && defined(CONFIG_ALPHA_GAMMA))
 #undef GAMMA_BIAS
 #define GAMMA_BIAS _GAMMA_BIAS
 struct alpha_machine_vector sable_gamma_mv __initmv = {
@@ -326,12 +605,13 @@
 	min_mem_address:	T2_DEFAULT_MEM_BASE,
 
 	nr_irqs:		40,
-	device_interrupt:	sable_srm_device_interrupt,
+	device_interrupt:	sable_lynx_srm_device_interrupt,
 
 	init_arch:		t2_init_arch,
 	init_irq:		sable_init_irq,
 	init_rtc:		common_init_rtc,
-	init_pci:		common_init_pci,
+	init_pci:		sable_lynx_init_pci,
+	kill_arch:		t2_kill_arch,
 	pci_map_irq:		sable_map_irq,
 	pci_swizzle:		common_swizzle,
 
@@ -340,4 +620,36 @@
 	} }
 };
 ALIAS_MV(sable_gamma)
-#endif
+#endif /* GENERIC || (SABLE && GAMMA) */
+
+#if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_LYNX)
+#undef GAMMA_BIAS
+#define GAMMA_BIAS _GAMMA_BIAS
+struct alpha_machine_vector lynx_mv __initmv = {
+	vector_name:		"Lynx",
+	DO_EV4_MMU,
+	DO_DEFAULT_RTC,
+	DO_T2_IO,
+	DO_T2_BUS,
+	machine_check:		t2_machine_check,
+	max_dma_address:	ALPHA_SABLE_MAX_DMA_ADDRESS,
+	min_io_address:		EISA_DEFAULT_IO_BASE,
+	min_mem_address:	T2_DEFAULT_MEM_BASE,
+
+	nr_irqs:		64,
+	device_interrupt:	sable_lynx_srm_device_interrupt,
+
+	init_arch:		t2_init_arch,
+	init_irq:		lynx_init_irq,
+	init_rtc:		common_init_rtc,
+	init_pci:		sable_lynx_init_pci,
+	kill_arch:		t2_kill_arch,
+	pci_map_irq:		lynx_map_irq,
+	pci_swizzle:		lynx_swizzle,
+
+	sys: { t2: {
+	    gamma_bias:		_GAMMA_BIAS
+	} }
+};
+ALIAS_MV(lynx)
+#endif /* GENERIC || LYNX */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/i386/boot/compressed/misc.c linux-2.4.22-pre2/arch/i386/boot/compressed/misc.c
--- linux-2.4.21/arch/i386/boot/compressed/misc.c	2002-11-28 23:53:09.000000000 +0000
+++ linux-2.4.22-pre2/arch/i386/boot/compressed/misc.c	2003-06-26 21:43:28.000000000 +0000
@@ -101,15 +101,11 @@
 static uch *output_data;
 static unsigned long output_ptr = 0;
 
- 
 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 **);
- 
+
 static void puts(const char *);
-  
+
 extern int end;
 static long free_mem_ptr = (long)&end;
 static long free_mem_end_ptr;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/i386/config.in linux-2.4.22-pre2/arch/i386/config.in
--- linux-2.4.21/arch/i386/config.in	2003-06-26 21:45:04.000000000 +0000
+++ linux-2.4.22-pre2/arch/i386/config.in	2003-06-26 21:43:16.000000000 +0000
@@ -326,14 +326,6 @@
 
 bool 'Power Management support' CONFIG_PM
 
-if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
-   dep_bool '  ACPI support' CONFIG_ACPI $CONFIG_PM
-   
-   if [ "$CONFIG_ACPI" != "n" ]; then
-      source drivers/acpi/Config.in
-   fi
-fi
-
 dep_tristate '  Advanced Power Management BIOS support' CONFIG_APM $CONFIG_PM
 if [ "$CONFIG_APM" != "n" ]; then
    bool '    Ignore USER SUSPEND' CONFIG_APM_IGNORE_USER_SUSPEND
@@ -345,6 +337,8 @@
    bool '    Use real mode APM BIOS call to power off' CONFIG_APM_REAL_MODE_POWER_OFF
 fi
 
+source drivers/acpi/Config.in
+
 endmenu
 
 source drivers/mtd/Config.in
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/i386/kernel/Makefile linux-2.4.22-pre2/arch/i386/kernel/Makefile
--- linux-2.4.21/arch/i386/kernel/Makefile	2002-11-28 23:53:09.000000000 +0000
+++ linux-2.4.22-pre2/arch/i386/kernel/Makefile	2003-06-26 21:43:13.000000000 +0000
@@ -36,9 +36,12 @@
 obj-$(CONFIG_X86_CPUID)		+= cpuid.o
 obj-$(CONFIG_MICROCODE)		+= microcode.o
 obj-$(CONFIG_APM)		+= apm.o
+obj-$(CONFIG_ACPI_BOOT)		+= acpi.o
+obj-$(CONFIG_ACPI_SLEEP)	+= acpi_wakeup.o
+obj-$(CONFIG_ACPI_HT_ONLY)	+= acpitable.o
 obj-$(CONFIG_SMP)		+= smp.o smpboot.o trampoline.o
 obj-$(CONFIG_X86_LOCAL_APIC)	+= mpparse.o apic.o nmi.o
-obj-$(CONFIG_X86_IO_APIC)	+= io_apic.o acpitable.o
+obj-$(CONFIG_X86_IO_APIC)	+= io_apic.o
 obj-$(CONFIG_X86_VISWS_APIC)	+= visws_apic.o
 
 include $(TOPDIR)/Rules.make
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/i386/kernel/acpi.c linux-2.4.22-pre2/arch/i386/kernel/acpi.c
--- linux-2.4.21/arch/i386/kernel/acpi.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/arch/i386/kernel/acpi.c	2003-06-26 21:43:15.000000000 +0000
@@ -0,0 +1,567 @@
+/*
+ *  acpi.c - Architecture-Specific Low-Level ACPI Support
+ *
+ *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
+ *  Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
+ *  Copyright (C) 2001 Patrick Mochel <mochel@osdl.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/config.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/stddef.h>
+#include <linux/slab.h>
+#include <linux/pci.h>
+#include <linux/bootmem.h>
+#include <linux/irq.h>
+#include <linux/acpi.h>
+#include <asm/mpspec.h>
+#include <asm/io.h>
+#include <asm/apic.h>
+#include <asm/apicdef.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+#include <asm/pgalloc.h>
+#include <asm/io_apic.h>
+#include <asm/acpi.h>
+#include <asm/save_state.h>
+
+
+#define PREFIX			"ACPI: "
+
+extern int acpi_disabled;
+
+/* --------------------------------------------------------------------------
+                              Boot-time Configuration
+   -------------------------------------------------------------------------- */
+
+#ifdef CONFIG_ACPI_BOOT
+
+enum acpi_irq_model_id		acpi_irq_model;
+
+
+/*
+ * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END,
+ * to map the target physical address. The problem is that set_fixmap()
+ * provides a single page, and it is possible that the page is not
+ * sufficient.
+ * By using this area, we can map up to MAX_IO_APICS pages temporarily,
+ * i.e. until the next __va_range() call.
+ *
+ * Important Safety Note:  The fixed I/O APIC page numbers are *subtracted*
+ * from the fixed base.  That's why we start at FIX_IO_APIC_BASE_END and
+ * count idx down while incrementing the phys address.
+ */
+char *__acpi_map_table(unsigned long phys, unsigned long size)
+{
+	unsigned long base, offset, mapped_size;
+	int idx;
+
+	if (phys + size < 8*1024*1024) 
+		return __va(phys); 
+
+	offset = phys & (PAGE_SIZE - 1);
+	mapped_size = PAGE_SIZE - offset;
+	set_fixmap(FIX_ACPI_END, phys);
+	base = fix_to_virt(FIX_ACPI_END);
+
+	/*
+	 * Most cases can be covered by the below.
+	 */
+	idx = FIX_ACPI_END;
+	while (mapped_size < size) {
+		if (--idx < FIX_ACPI_BEGIN)
+			return 0;	/* cannot handle this */
+		phys += PAGE_SIZE;
+		set_fixmap(idx, phys);
+		mapped_size += PAGE_SIZE;
+	}
+
+	return ((unsigned char *) base + offset);
+}
+
+
+#ifdef CONFIG_X86_LOCAL_APIC
+
+int acpi_lapic;
+
+static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
+
+
+static int __init
+acpi_parse_madt (
+	unsigned long		phys_addr,
+	unsigned long		size)
+{
+	struct acpi_table_madt	*madt = NULL;
+
+	if (!phys_addr || !size)
+		return -EINVAL;
+
+	madt = (struct acpi_table_madt *) __acpi_map_table(phys_addr, size);
+	if (!madt) {
+		printk(KERN_WARNING PREFIX "Unable to map MADT\n");
+		return -ENODEV;
+	}
+
+	if (madt->lapic_address)
+		acpi_lapic_addr = (u64) madt->lapic_address;
+
+	printk(KERN_INFO PREFIX "Local APIC address 0x%08x\n",
+		madt->lapic_address);
+
+	return 0;
+}
+
+
+static int __init
+acpi_parse_lapic (
+	acpi_table_entry_header *header)
+{
+	struct acpi_table_lapic	*processor = NULL;
+
+	processor = (struct acpi_table_lapic*) header;
+	if (!processor)
+		return -EINVAL;
+
+	acpi_table_print_madt_entry(header);
+
+	mp_register_lapic (
+		processor->id,					   /* APIC ID */
+		processor->flags.enabled);			  /* Enabled? */
+
+	return 0;
+}
+
+
+static int __init
+acpi_parse_lapic_addr_ovr (
+	acpi_table_entry_header *header)
+{
+	struct acpi_table_lapic_addr_ovr *lapic_addr_ovr = NULL;
+
+	lapic_addr_ovr = (struct acpi_table_lapic_addr_ovr*) header;
+	if (!lapic_addr_ovr)
+		return -EINVAL;
+
+	acpi_lapic_addr = lapic_addr_ovr->address;
+
+	return 0;
+}
+
+static int __init
+acpi_parse_lapic_nmi (
+	acpi_table_entry_header *header)
+{
+	struct acpi_table_lapic_nmi *lapic_nmi = NULL;
+
+	lapic_nmi = (struct acpi_table_lapic_nmi*) header;
+	if (!lapic_nmi)
+		return -EINVAL;
+
+	acpi_table_print_madt_entry(header);
+
+	if (lapic_nmi->lint != 1)
+		printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
+
+	return 0;
+}
+
+#endif /*CONFIG_X86_LOCAL_APIC*/
+
+#ifdef CONFIG_X86_IO_APIC
+
+int acpi_ioapic;
+
+static int __init
+acpi_parse_ioapic (
+	acpi_table_entry_header *header)
+{
+	struct acpi_table_ioapic *ioapic = NULL;
+
+	ioapic = (struct acpi_table_ioapic*) header;
+	if (!ioapic)
+		return -EINVAL;
+ 
+	acpi_table_print_madt_entry(header);
+
+	mp_register_ioapic (
+		ioapic->id,
+		ioapic->address,
+		ioapic->global_irq_base);
+ 
+	return 0;
+}
+
+
+static int __init
+acpi_parse_int_src_ovr (
+	acpi_table_entry_header *header)
+{
+	struct acpi_table_int_src_ovr *intsrc = NULL;
+
+	intsrc = (struct acpi_table_int_src_ovr*) header;
+	if (!intsrc)
+		return -EINVAL;
+
+	acpi_table_print_madt_entry(header);
+
+	mp_override_legacy_irq (
+		intsrc->bus_irq,
+		intsrc->flags.polarity,
+		intsrc->flags.trigger,
+		intsrc->global_irq);
+
+	return 0;
+}
+
+
+static int __init
+acpi_parse_nmi_src (
+	acpi_table_entry_header *header)
+{
+	struct acpi_table_nmi_src *nmi_src = NULL;
+
+	nmi_src = (struct acpi_table_nmi_src*) header;
+	if (!nmi_src)
+		return -EINVAL;
+
+	acpi_table_print_madt_entry(header);
+
+	/* TBD: Support nimsrc entries? */
+
+	return 0;
+}
+
+#endif /*CONFIG_X86_IO_APIC*/
+
+
+static unsigned long __init
+acpi_scan_rsdp (
+	unsigned long		start,
+	unsigned long		length)
+{
+	unsigned long		offset = 0;
+	unsigned long		sig_len = sizeof("RSD PTR ") - 1;
+
+	/*
+	 * Scan all 16-byte boundaries of the physical memory region for the
+	 * RSDP signature.
+	 */
+	for (offset = 0; offset < length; offset += 16) {
+		if (strncmp((char *) (start + offset), "RSD PTR ", sig_len))
+			continue;
+		return (start + offset);
+	}
+
+	return 0;
+}
+
+
+unsigned long __init
+acpi_find_rsdp (void)
+{
+	unsigned long		rsdp_phys = 0;
+
+	/*
+	 * Scan memory looking for the RSDP signature. First search EBDA (low
+	 * memory) paragraphs and then search upper memory (E0000-FFFFF).
+	 */
+	rsdp_phys = acpi_scan_rsdp (0, 0x400);
+	if (!rsdp_phys)
+		rsdp_phys = acpi_scan_rsdp (0xE0000, 0xFFFFF);
+
+	return rsdp_phys;
+}
+
+
+int __init
+acpi_boot_init (void)
+{
+	int			result = 0;
+
+	/*
+	 * The default interrupt routing model is PIC (8259).  This gets
+	 * overriden if IOAPICs are enumerated (below).
+	 */
+	acpi_irq_model = ACPI_IRQ_MODEL_PIC;
+
+	/* 
+	 * Initialize the ACPI boot-time table parser.
+	 */
+	result = acpi_table_init();
+	if (result)
+		return result;
+
+	result = acpi_blacklisted();
+	if (result) {
+		acpi_disabled = 1;
+		return result;
+	}
+	else
+		printk(KERN_NOTICE PREFIX "BIOS passes blacklist\n");
+
+#ifdef CONFIG_X86_LOCAL_APIC
+
+	/* 
+	 * MADT
+	 * ----
+	 * Parse the Multiple APIC Description Table (MADT), if exists.
+	 * Note that this table provides platform SMP configuration 
+	 * information -- the successor to MPS tables.
+	 */
+
+	result = acpi_table_parse(ACPI_APIC, acpi_parse_madt);
+	if (!result) {
+		printk(KERN_WARNING PREFIX "MADT not present\n");
+		return 0;
+	}
+	else if (result < 0) {
+		printk(KERN_ERR PREFIX "Error parsing MADT\n");
+		return result;
+	}
+	else if (result > 1) 
+		printk(KERN_WARNING PREFIX "Multiple MADT tables exist\n");
+
+	/* 
+	 * Local APIC
+	 * ----------
+	 * Note that the LAPIC address is obtained from the MADT (32-bit value)
+	 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
+	 */
+
+	result = acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr);
+	if (result < 0) {
+		printk(KERN_ERR PREFIX "Error parsing LAPIC address override entry\n");
+		return result;
+	}
+
+	mp_register_lapic_address(acpi_lapic_addr);
+
+	result = acpi_table_parse_madt(ACPI_MADT_LAPIC, acpi_parse_lapic);
+	if (!result) { 
+		printk(KERN_ERR PREFIX "No LAPIC entries present\n");
+		/* TBD: Cleanup to allow fallback to MPS */
+		return -ENODEV;
+	}
+	else if (result < 0) {
+		printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
+		/* TBD: Cleanup to allow fallback to MPS */
+		return result;
+	}
+
+	result = acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi);
+	if (result < 0) {
+		printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
+		/* TBD: Cleanup to allow fallback to MPS */
+		return result;
+	}
+
+	acpi_lapic = 1;
+
+#endif /*CONFIG_X86_LOCAL_APIC*/
+
+#ifdef CONFIG_X86_IO_APIC
+
+	/* 
+	 * I/O APIC 
+	 * --------
+	 */
+
+	result = acpi_table_parse_madt(ACPI_MADT_IOAPIC, acpi_parse_ioapic);
+	if (!result) { 
+		printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
+		return -ENODEV;
+	}
+	else if (result < 0) {
+		printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
+		return result;
+	}
+
+	/* Build a default routing table for legacy (ISA) interrupts. */
+	mp_config_acpi_legacy_irqs();
+
+	result = acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr);
+	if (result < 0) {
+		printk(KERN_ERR PREFIX "Error parsing interrupt source overrides entry\n");
+		/* TBD: Cleanup to allow fallback to MPS */
+		return result;
+	}
+
+	result = acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src);
+	if (result < 0) {
+		printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
+		/* TBD: Cleanup to allow fallback to MPS */
+		return result;
+	}
+
+	acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
+
+	acpi_ioapic = 1;
+
+#endif /*CONFIG_X86_IO_APIC*/
+
+#ifdef CONFIG_X86_LOCAL_APIC
+	if (acpi_lapic && acpi_ioapic)
+		smp_found_config = 1;
+#endif
+
+	return 0;
+}
+
+#endif /*CONFIG_ACPI_BOOT*/
+
+
+/* --------------------------------------------------------------------------
+                              Low-Level Sleep Support
+   -------------------------------------------------------------------------- */
+
+#ifdef CONFIG_ACPI_SLEEP
+
+#define DEBUG
+
+#ifdef DEBUG
+#include <linux/serial.h>
+#endif
+
+/* address in low memory of the wakeup routine. */
+unsigned long acpi_wakeup_address = 0;
+
+/* new page directory that we will be using */
+static pmd_t *pmd;
+
+/* saved page directory */
+static pmd_t saved_pmd;
+
+/* page which we'll use for the new page directory */
+static pte_t *ptep;
+
+extern unsigned long FASTCALL(acpi_copy_wakeup_routine(unsigned long));
+
+/*
+ * acpi_create_identity_pmd
+ *
+ * Create a new, identity mapped pmd.
+ *
+ * Do this by creating new page directory, and marking all the pages as R/W
+ * Then set it as the new Page Middle Directory.
+ * And, of course, flush the TLB so it takes effect.
+ *
+ * We save the address of the old one, for later restoration.
+ */
+static void acpi_create_identity_pmd (void)
+{
+	pgd_t *pgd;
+	int i;
+
+	ptep = (pte_t*)__get_free_page(GFP_KERNEL);
+
+	/* fill page with low mapping */
+	for (i = 0; i < PTRS_PER_PTE; i++)
+		set_pte(ptep + i, mk_pte_phys(i << PAGE_SHIFT, PAGE_SHARED));
+
+	pgd = pgd_offset(current->active_mm, 0);
+	pmd = pmd_alloc(current->mm,pgd, 0);
+
+	/* save the old pmd */
+	saved_pmd = *pmd;
+
+	/* set the new one */
+	set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(ptep)));
+
+	/* flush the TLB */
+	local_flush_tlb();
+}
+
+/*
+ * acpi_restore_pmd
+ *
+ * Restore the old pmd saved by acpi_create_identity_pmd and
+ * free the page that said function alloc'd
+ */
+static void acpi_restore_pmd (void)
+{
+	set_pmd(pmd, saved_pmd);
+	local_flush_tlb();
+	free_page((unsigned long)ptep);
+}
+
+/**
+ * acpi_save_state_mem - save kernel state
+ *
+ * Create an identity mapped page table and copy the wakeup routine to
+ * low memory.
+ */
+int acpi_save_state_mem (void)
+{
+	acpi_create_identity_pmd();
+	acpi_copy_wakeup_routine(acpi_wakeup_address);
+
+	return 0;
+}
+
+/**
+ * acpi_save_state_disk - save kernel state to disk
+ *
+ */
+int acpi_save_state_disk (void)
+{
+	return 1;
+}
+
+/*
+ * acpi_restore_state
+ */
+void acpi_restore_state_mem (void)
+{
+	acpi_restore_pmd();
+}
+
+/**
+ * acpi_reserve_bootmem - do _very_ early ACPI initialisation
+ *
+ * We allocate a page in low memory for the wakeup
+ * routine for when we come back from a sleep state. The
+ * runtime allocator allows specification of <16M pages, but not
+ * <1M pages.
+ */
+void __init acpi_reserve_bootmem(void)
+{
+	acpi_wakeup_address = (unsigned long)alloc_bootmem_low(PAGE_SIZE);
+	printk(KERN_DEBUG "ACPI: have wakeup address 0x%8.8lx\n", acpi_wakeup_address);
+}
+
+void do_suspend_lowlevel_s4bios(int resume)
+{
+	if (!resume) {
+		save_processor_context();
+		acpi_save_register_state((unsigned long)&&acpi_sleep_done);
+		acpi_enter_sleep_state_s4bios();
+		return;
+	}
+acpi_sleep_done:
+	restore_processor_context();
+}
+
+
+#endif /*CONFIG_ACPI_SLEEP*/
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/i386/kernel/acpi_wakeup.S linux-2.4.22-pre2/arch/i386/kernel/acpi_wakeup.S
--- linux-2.4.21/arch/i386/kernel/acpi_wakeup.S	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/arch/i386/kernel/acpi_wakeup.S	2003-06-26 21:43:29.000000000 +0000
@@ -0,0 +1,145 @@
+
+.text
+#include <linux/linkage.h>
+#include <asm/segment.h>
+
+
+ALIGN
+wakeup_start:
+wakeup_code:
+	wakeup_code_start = .
+	.code16
+
+	cli
+	cld
+
+	# setup data segment
+	movw	%cs, %ax
+
+	addw	$(wakeup_data - wakeup_code) >> 4, %ax
+	movw	%ax, %ds
+	movw	%ax, %ss
+
+	# Private stack is needed for ASUS board
+	mov	$(wakeup_stack - wakeup_data), %sp
+
+	# set up page table
+	movl	(real_save_cr3 - wakeup_data), %eax
+	movl	%eax, %cr3
+
+	# make sure %cr4 is set correctly (features, etc)
+	movl	(real_save_cr4 - wakeup_data), %eax
+	movl	%eax, %cr4
+
+	# need a gdt
+	lgdt	real_save_gdt - wakeup_data
+
+	# Flush the prefetch queue
+	jmp 1f
+1:
+
+	movl	%cr0, %eax
+	orl     $0x80000001, %eax
+	movl	%eax, %cr0
+
+	ljmpl	$__KERNEL_CS,$SYMBOL_NAME(wakeup_pmode_return)
+
+	.code32
+	ALIGN
+
+.org	0x100
+wakeup_data:
+		.word 0
+real_save_gdt:	.word 0
+		.long 0
+real_save_cr3:	.long 0
+real_save_cr4:	.long 0
+
+.org	0x300
+wakeup_stack:
+wakeup_end:
+
+wakeup_pmode_return:
+	# restore data segment
+	movl	$__KERNEL_DS, %eax
+	movw	%ax, %ds
+	movw	%ax, %es
+
+	# and restore the stack
+	movw	%ax, %ss
+	movl	saved_esp, %esp
+
+	# restore other segment registers
+	xorl	%eax, %eax
+	movw	%ax, %fs
+	movw	%ax, %gs
+
+	# reload the gdt, as we need the full 32 bit address
+	lgdt	saved_gdt
+	lidt	saved_idt
+	lldt	saved_ldt
+
+	# restore the other general registers
+	movl	saved_ebx, %ebx
+	movl	saved_edi, %edi
+	movl	saved_esi, %esi
+	movl	saved_ebp, %ebp
+
+	# jump to place where we left off
+	movl	saved_eip,%eax
+	jmp	*%eax
+
+##
+# acpi_copy_wakeup_routine
+#
+# Copy the above routine to low memory.
+#
+# Parameters:
+# %eax:	place to copy wakeup routine to
+#
+# Returned address is location of code in low memory (past data and stack)
+#
+ENTRY(acpi_copy_wakeup_routine)
+
+	pushl	%esi
+	pushl	%edi
+
+	sgdt	saved_gdt
+	sidt	saved_idt
+	sldt	saved_ldt
+	str	saved_tss
+
+	movl	%eax, %edi
+	leal	wakeup_start, %esi
+	movl	$(wakeup_end - wakeup_start) >> 2, %ecx
+
+	rep ;  movsl
+
+	movl    %cr3, %edx
+	movl    %edx, real_save_cr3 - wakeup_start (%eax)
+	movl    %cr4, %edx
+	movl    %edx, real_save_cr4 - wakeup_start (%eax)
+	sgdt    real_save_gdt - wakeup_start (%eax)
+
+	# restore the regs we used
+	popl	%edi
+	popl	%esi
+	ret
+
+
+.data
+ALIGN
+# saved registers
+saved_gdt:	.long	0,0
+saved_idt:	.long	0,0
+saved_ldt:	.long	0
+saved_tss:	.long	0
+saved_cr0:	.long	0
+
+ENTRY(saved_ebp)	.long	0
+ENTRY(saved_esi)	.long	0
+ENTRY(saved_edi)	.long	0
+ENTRY(saved_ebx)	.long	0
+
+ENTRY(saved_eip)	.long	0
+ENTRY(saved_esp)	.long	0
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/i386/kernel/acpitable.c linux-2.4.22-pre2/arch/i386/kernel/acpitable.c
--- linux-2.4.21/arch/i386/kernel/acpitable.c	2002-08-03 00:39:42.000000000 +0000
+++ linux-2.4.22-pre2/arch/i386/kernel/acpitable.c	2003-06-26 21:43:30.000000000 +0000
@@ -45,6 +45,7 @@
 
 static acpi_table_handler acpi_boot_ops[ACPI_TABLE_COUNT];
 
+int acpi_lapic;
 
 static unsigned char __init
 acpi_checksum(void *buffer, int length)
@@ -530,14 +531,13 @@
 	return 0;
 }
 
-extern int enable_acpi_smp_table;
 
 /*
  * Configure the processor info using MADT in the ACPI tables. If we fail to
  * configure that, then we use the MPS tables.
  */
 void __init
-config_acpi_tables(void)
+acpi_boot_init(void)
 {
 
 	memset(&acpi_boot_ops, 0, sizeof(acpi_boot_ops));
@@ -547,8 +547,7 @@
 	 * Only do this when requested, either because of CPU/Bios type or from the command line
 	 */
 
-	if (enable_acpi_smp_table && !acpi_tables_init()) {
-		have_acpi_tables = 1;
-		printk("Enabling the CPU's according to the ACPI table\n");
-	}
+	if (!acpi_tables_init())
+		acpi_lapic = 1;
 }
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/i386/kernel/io_apic.c linux-2.4.22-pre2/arch/i386/kernel/io_apic.c
--- linux-2.4.21/arch/i386/kernel/io_apic.c	2003-06-26 21:45:04.000000000 +0000
+++ linux-2.4.22-pre2/arch/i386/kernel/io_apic.c	2003-06-26 21:43:16.000000000 +0000
@@ -17,6 +17,7 @@
  *					thanks to Eric Gilmore
  *					and Rolf G. Tews
  *					for testing these extensively
+ *	Paul Diefenbaugh	:	Added full ACPI support
  */
 
 #include <linux/mm.h>
@@ -28,6 +29,7 @@
 #include <linux/config.h>
 #include <linux/smp_lock.h>
 #include <linux/mc146818rtc.h>
+#include <linux/acpi.h>
 
 #include <asm/io.h>
 #include <asm/smp.h>
@@ -750,6 +752,7 @@
 	struct IO_APIC_reg_00 reg_00;
 	struct IO_APIC_reg_01 reg_01;
 	struct IO_APIC_reg_02 reg_02;
+	struct IO_APIC_reg_03 reg_03;
 	unsigned long flags;
 
  	printk(KERN_DEBUG "number of MP IRQ sources: %d.\n", mp_irq_entries);
@@ -770,6 +773,8 @@
 	*(int *)&reg_01 = io_apic_read(apic, 1);
 	if (reg_01.version >= 0x10)
 		*(int *)&reg_02 = io_apic_read(apic, 2);
+	if (reg_01.version >= 0x20)
+		*(int *)&reg_03 = io_apic_read(apic, 3);
 	spin_unlock_irqrestore(&ioapic_lock, flags);
 
 	printk("\n");
@@ -807,13 +812,31 @@
 	if (reg_01.__reserved_1 || reg_01.__reserved_2)
 		UNEXPECTED_IO_APIC();
 
-	if (reg_01.version >= 0x10) {
+	/*
+	 * Some Intel chipsets with IO APIC VERSION of 0x1? don't have reg_02,
+	 * but the value of reg_02 is read as the previous read register
+	 * value, so ignore it if reg_02 == reg_01.
+	 */
+	if (reg_01.version >= 0x10 && *(int *)&reg_02 != *(int *)&reg_01) {
 		printk(KERN_DEBUG ".... register #02: %08X\n", *(int *)&reg_02);
 		printk(KERN_DEBUG ".......     : arbitration: %02X\n", reg_02.arbitration);
 		if (reg_02.__reserved_1 || reg_02.__reserved_2)
 			UNEXPECTED_IO_APIC();
 	}
 
+	/*
+	 * Some Intel chipsets with IO APIC VERSION of 0x2? don't have reg_02
+	 * or reg_03, but the value of reg_0[23] is read as the previous read
+	 * register value, so ignore it if reg_03 == reg_0[12].
+	 */
+	if (reg_01.version >= 0x20 && *(int *)&reg_03 != *(int *)&reg_02 &&
+	    *(int *)&reg_03 != *(int *)&reg_01) {
+		printk(KERN_DEBUG ".... register #03: %08X\n", *(int *)&reg_03);
+		printk(KERN_DEBUG ".......     : Boot DT    : %X\n", reg_03.boot_DT);
+		if (reg_03.__reserved_1)
+			UNEXPECTED_IO_APIC();
+	}
+
 	printk(KERN_DEBUG ".... IRQ redirection table:\n");
 
 	printk(KERN_DEBUG " NR Log Phy Mask Trig IRR Pol"
@@ -1057,6 +1080,10 @@
 	unsigned char old_id;
 	unsigned long flags;
 
+	if (acpi_ioapic)
+		/* This gets done during IOAPIC enumeration for ACPI. */
+		return;
+
 	if (clustered_apic_mode)
 		/* We don't have a good way to do this yet - hack */
 		phys_id_present_map = (u_long) 0xf;
@@ -1657,8 +1684,7 @@
 	printk("ENABLING IO-APIC IRQs\n");
 
 	/*
-	 * Set up the IO-APIC IRQ routing table by parsing the MP-BIOS
-	 * mptable:
+	 * Set up IO-APIC IRQ routing.
 	 */
 	setup_ioapic_ids_from_mpc();
 	sync_Arb_IDs();
@@ -1667,3 +1693,159 @@
 	check_timer();
 	print_IO_APIC();
 }
+
+
+/* --------------------------------------------------------------------------
+                          ACPI-based IOAPIC Configuration
+   -------------------------------------------------------------------------- */
+
+#ifdef CONFIG_ACPI_BOOT
+
+#define IO_APIC_MAX_ID		15
+
+int __init io_apic_get_unique_id (int ioapic, int apic_id)
+{
+	struct IO_APIC_reg_00 reg_00;
+	static unsigned long apic_id_map = 0;
+	unsigned long flags;
+	int i = 0;
+
+	/*
+	 * The P4 platform supports up to 256 APIC IDs on two separate APIC 
+	 * buses (one for LAPICs, one for IOAPICs), where predecessors only 
+	 * supports up to 16 on one shared APIC bus.
+	 * 
+	 * TBD: Expand LAPIC/IOAPIC support on P4-class systems to take full
+	 *      advantage of new APIC bus architecture.
+	 */
+
+	if (!apic_id_map)
+		apic_id_map = phys_cpu_present_map;
+
+	spin_lock_irqsave(&ioapic_lock, flags);
+	*(int *)&reg_00 = io_apic_read(ioapic, 0);
+	spin_unlock_irqrestore(&ioapic_lock, flags);
+
+	if (apic_id >= IO_APIC_MAX_ID) {
+		printk(KERN_WARNING "IOAPIC[%d]: Invalid apic_id %d, trying "
+			"%d\n", ioapic, apic_id, reg_00.ID);
+		apic_id = reg_00.ID;
+	}
+
+	/*
+	 * 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 (apic_id_map & (1 << apic_id)) {
+
+		for (i = 0; i < IO_APIC_MAX_ID; i++) {
+			if (!(apic_id_map & (1 << i)))
+				break;
+		}
+
+		if (i == IO_APIC_MAX_ID)
+			panic("Max apic_id exceeded!\n");
+
+		printk(KERN_WARNING "IOAPIC[%d]: apic_id %d already used, "
+			"trying %d\n", ioapic, apic_id, i);
+
+		apic_id = i;
+	} 
+
+	apic_id_map |= (1 << apic_id);
+
+	if (reg_00.ID != apic_id) {
+		reg_00.ID = apic_id;
+
+		spin_lock_irqsave(&ioapic_lock, flags);
+		io_apic_write(ioapic, 0, *(int *)&reg_00);
+		*(int *)&reg_00 = io_apic_read(ioapic, 0);
+		spin_unlock_irqrestore(&ioapic_lock, flags);
+
+		/* Sanity check */
+		if (reg_00.ID != apic_id)
+			panic("IOAPIC[%d]: Unable change apic_id!\n", ioapic);
+	}
+
+	printk(KERN_INFO "IOAPIC[%d]: Assigned apic_id %d\n", ioapic, apic_id);
+
+	return apic_id;
+}
+
+
+int __init io_apic_get_version (int ioapic)
+{
+	struct IO_APIC_reg_01	reg_01;
+	unsigned long flags;
+
+	spin_lock_irqsave(&ioapic_lock, flags);
+	*(int *)&reg_01 = io_apic_read(ioapic, 1);
+	spin_unlock_irqrestore(&ioapic_lock, flags);
+
+	return reg_01.version;
+}
+
+
+int __init io_apic_get_redir_entries (int ioapic)
+{
+	struct IO_APIC_reg_01	reg_01;
+	unsigned long flags;
+
+	spin_lock_irqsave(&ioapic_lock, flags);
+	*(int *)&reg_01 = io_apic_read(ioapic, 1);
+	spin_unlock_irqrestore(&ioapic_lock, flags);
+
+	return reg_01.entries;
+}
+
+
+int io_apic_set_pci_routing (int ioapic, int pin, int irq)
+{
+	struct IO_APIC_route_entry entry;
+	unsigned long flags;
+
+	if (!IO_APIC_IRQ(irq)) {
+		printk(KERN_ERR "IOAPIC[%d]: Invalid reference to IRQ 0/n", 
+			ioapic);
+		return -EINVAL;
+	}
+
+	/*
+	 * Generate a PCI IRQ routing entry and program the IOAPIC accordingly.
+	 * Note that we mask (disable) IRQs now -- these get enabled when the
+	 * corresponding device driver registers for this IRQ.
+	 */
+
+	memset(&entry,0,sizeof(entry));
+
+	entry.delivery_mode = dest_LowestPrio;
+	entry.dest_mode = INT_DELIVERY_MODE;
+	entry.dest.logical.logical_dest = target_cpus();
+	entry.mask = 1;					 /* Disabled (masked) */
+	entry.trigger = 1;				   /* Level sensitive */
+	entry.polarity = 1;					/* Low active */
+
+	add_pin_to_irq(irq, ioapic, pin);
+
+	entry.vector = assign_irq_vector(irq);
+
+	printk(KERN_DEBUG "IOAPIC[%d]: Set PCI routing entry (%d-%d -> 0x%x -> "
+		"IRQ %d)\n", ioapic, 
+		mp_ioapics[ioapic].mpc_apicid, pin, entry.vector, irq);
+
+	irq_desc[irq].handler = &ioapic_level_irq_type;
+
+	set_intr_gate(entry.vector, interrupt[irq]);
+
+	if (!ioapic && (irq < 16))
+		disable_8259A_irq(irq);
+
+	spin_lock_irqsave(&ioapic_lock, flags);
+	io_apic_write(ioapic, 0x11+2*pin, *(((int *)&entry)+1));
+	io_apic_write(ioapic, 0x10+2*pin, *(((int *)&entry)+0));
+	spin_unlock_irqrestore(&ioapic_lock, flags);
+
+	return 0;
+}
+
+#endif /*CONFIG_ACPI_BOOT*/
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/i386/kernel/mpparse.c linux-2.4.22-pre2/arch/i386/kernel/mpparse.c
--- linux-2.4.21/arch/i386/kernel/mpparse.c	2003-06-26 21:45:04.000000000 +0000
+++ linux-2.4.22-pre2/arch/i386/kernel/mpparse.c	2003-06-26 21:43:16.000000000 +0000
@@ -9,12 +9,14 @@
  *		Erich Boleyn	:	MP v1.4 and additional changes.
  *		Alan Cox	:	Added EBDA scanning
  *		Ingo Molnar	:	various cleanups and rewrites
- *	Maciej W. Rozycki	:	Bits for default MP configurations
+ *		Maciej W. Rozycki:	Bits for default MP configurations
+ *		Paul Diefenbaugh:	Added full ACPI support
  */
 
 #include <linux/mm.h>
 #include <linux/irq.h>
 #include <linux/init.h>
+#include <linux/acpi.h>
 #include <linux/delay.h>
 #include <linux/config.h>
 #include <linux/bootmem.h>
@@ -23,10 +25,12 @@
 #include <linux/mc146818rtc.h>
 
 #include <asm/smp.h>
+#include <asm/acpi.h>
 #include <asm/mtrr.h>
 #include <asm/mpspec.h>
 #include <asm/pgalloc.h>
 #include <asm/smpboot.h>
+#include <asm/io_apic.h>
 
 /* Have we found an MP table */
 int smp_found_config;
@@ -137,12 +141,6 @@
 	return n;
 }
 
-#ifdef CONFIG_X86_IO_APIC
-extern int have_acpi_tables;	/* set by acpitable.c */
-#else
-#define have_acpi_tables (0)
-#endif
-
 /* 
  * Have to match translation table entries to main table entries by counter
  * hence the mpc_record variable .... can't see a less disgusting way of
@@ -447,10 +445,11 @@
 	
 	printk("APIC at: 0x%lX\n",mpc->mpc_lapic);
 
-	/* save the local APIC address, it might be non-default,
-	 * but only if we're not using the ACPI tables
+	/* 
+	 * Save the local APIC address (it might be non-default) -- but only
+	 * if we're not using ACPI.
 	 */
-	if (!have_acpi_tables)
+	if (!acpi_lapic)
 		mp_lapic_addr = mpc->mpc_lapic;
 
 	if ((clustered_apic_mode == CLUSTERED_APIC_NUMAQ) && mpc->mpc_oemptr) {
@@ -530,9 +529,8 @@
 			{
 				struct mpc_config_processor *m=
 					(struct mpc_config_processor *)mpt;
-
-				/* ACPI may already have provided this one for us */
-				if (!have_acpi_tables)
+				/* ACPI may have already provided this data */
+				if (!acpi_lapic)
 					MP_processor_info(m);
 				mpt += sizeof(*m);
 				count += sizeof(*m);
@@ -761,7 +759,6 @@
 }
 
 static struct intel_mp_floating *mpf_found;
-extern void 	config_acpi_tables(void);
 
 /*
  * Scan the memory blocks for an SMP configuration block.
@@ -770,17 +767,19 @@
 {
 	struct intel_mp_floating *mpf = mpf_found;
 
-#ifdef CONFIG_X86_IO_APIC
 	/*
-	 * Check if the ACPI tables are provided. Use them only to get
-	 * the processor information, mainly because it provides
-	 * the info on the logical processor(s), rather than the physical
-	 * processor(s) that are provided by the MPS. We attempt to 
-	 * check only if the user provided a commandline override
+	 * ACPI may be used to obtain the entire SMP configuration or just to 
+	 * enumerate/configure processors (CONFIG_ACPI_HT_ONLY).  Note that 
+	 * ACPI supports both logical (e.g. Hyper-Threading) and physical 
+	 * processors, where MPS only supports physical.
 	 */
-	config_acpi_tables();
-#endif
-	
+	if (acpi_lapic && acpi_ioapic) {
+		printk(KERN_INFO "Using ACPI (MADT) for SMP configuration information\n");
+		return;
+	}
+	else if (acpi_lapic)
+		printk(KERN_INFO "Using ACPI for processor (LAPIC) configuration information\n");
+
 	printk("Intel MultiProcessor Specification v1.%d\n", mpf->mpf_specification);
 	if (mpf->mpf_feature2 & (1<<7)) {
 		printk("    IMCR and PIC compatibility mode.\n");
@@ -939,3 +938,393 @@
 #endif
 }
 
+
+/* --------------------------------------------------------------------------
+                            ACPI-based MP Configuration
+   -------------------------------------------------------------------------- */
+
+#ifdef CONFIG_ACPI_BOOT
+
+void __init mp_register_lapic_address (
+	u64			address)
+{
+	mp_lapic_addr = (unsigned long) address;
+
+	set_fixmap_nocache(FIX_APIC_BASE, mp_lapic_addr);
+
+	if (boot_cpu_physical_apicid == -1U)
+		boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID));
+
+	Dprintk("Boot CPU = %d\n", boot_cpu_physical_apicid);
+}
+
+
+void __init mp_register_lapic (
+	u8			id, 
+	u8			enabled)
+{
+	struct mpc_config_processor processor;
+	int			boot_cpu = 0;
+	
+	if (id >= MAX_APICS) {
+		printk(KERN_WARNING "Processor #%d invalid (max %d)\n",
+			id, MAX_APICS);
+		return;
+	}
+
+	if (id == boot_cpu_physical_apicid)
+		boot_cpu = 1;
+
+	processor.mpc_type = MP_PROCESSOR;
+	processor.mpc_apicid = id;
+	processor.mpc_apicver = 0x10; /* TBD: lapic version */
+	processor.mpc_cpuflag = (enabled ? CPU_ENABLED : 0);
+	processor.mpc_cpuflag |= (boot_cpu ? CPU_BOOTPROCESSOR : 0);
+	processor.mpc_cpufeature = (boot_cpu_data.x86 << 8) | 
+		(boot_cpu_data.x86_model << 4) | boot_cpu_data.x86_mask;
+	processor.mpc_featureflag = boot_cpu_data.x86_capability[0];
+	processor.mpc_reserved[0] = 0;
+	processor.mpc_reserved[1] = 0;
+
+	MP_processor_info(&processor);
+}
+
+#ifdef CONFIG_X86_IO_APIC
+
+#define MP_ISA_BUS		0
+#define MP_MAX_IOAPIC_PIN	127
+
+struct mp_ioapic_routing {
+	int			apic_id;
+	int			irq_start;
+	int			irq_end;
+	u32			pin_programmed[4];
+} mp_ioapic_routing[MAX_IO_APICS];
+
+
+static int __init mp_find_ioapic (
+	int			irq)
+{
+	int			i = 0;
+
+	/* Find the IOAPIC that manages this IRQ. */
+	for (i = 0; i < nr_ioapics; i++) {
+		if ((irq >= mp_ioapic_routing[i].irq_start)
+			&& (irq <= mp_ioapic_routing[i].irq_end))
+			return i;
+	}
+
+	printk(KERN_ERR "ERROR: Unable to locate IOAPIC for IRQ %d/n", irq);
+
+	return -1;
+}
+	
+
+void __init mp_register_ioapic (
+	u8			id, 
+	u32			address,
+	u32			irq_base)
+{
+	int			idx = 0;
+
+	if (nr_ioapics >= MAX_IO_APICS) {
+		printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded "
+			"(found %d)\n", MAX_IO_APICS, nr_ioapics);
+		panic("Recompile kernel with bigger MAX_IO_APICS!\n");
+	}
+	if (!address) {
+		printk(KERN_ERR "WARNING: Bogus (zero) I/O APIC address"
+			" found in MADT table, skipping!\n");
+		return;
+	}
+
+	idx = nr_ioapics++;
+
+	mp_ioapics[idx].mpc_type = MP_IOAPIC;
+	mp_ioapics[idx].mpc_flags = MPC_APIC_USABLE;
+	mp_ioapics[idx].mpc_apicaddr = address;
+
+	set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
+	mp_ioapics[idx].mpc_apicid = io_apic_get_unique_id(idx, id);
+	mp_ioapics[idx].mpc_apicver = io_apic_get_version(idx);
+	
+	/* 
+	 * Build basic IRQ lookup table to facilitate irq->io_apic lookups
+	 * and to prevent reprogramming of IOAPIC pins (PCI IRQs).
+	 */
+	mp_ioapic_routing[idx].apic_id = mp_ioapics[idx].mpc_apicid;
+	mp_ioapic_routing[idx].irq_start = irq_base;
+	mp_ioapic_routing[idx].irq_end = irq_base + 
+		io_apic_get_redir_entries(idx);
+
+	printk("IOAPIC[%d]: apic_id %d, version %d, address 0x%lx, "
+		"IRQ %d-%d\n", idx, mp_ioapics[idx].mpc_apicid, 
+		mp_ioapics[idx].mpc_apicver, mp_ioapics[idx].mpc_apicaddr,
+		mp_ioapic_routing[idx].irq_start,
+		mp_ioapic_routing[idx].irq_end);
+
+	return;
+}
+
+
+void __init mp_override_legacy_irq (
+	u8			bus_irq,
+	u8			polarity, 
+	u8			trigger, 
+	u32			global_irq)
+{
+	struct mpc_config_intsrc intsrc;
+	int			i = 0;
+	int			found = 0;
+	int			ioapic = -1;
+	int			pin = -1;
+
+	/* 
+	 * Convert 'global_irq' to 'ioapic.pin'.
+	 */
+	ioapic = mp_find_ioapic(global_irq);
+	if (ioapic < 0)
+		return;
+	pin = global_irq - mp_ioapic_routing[ioapic].irq_start;
+
+	/*
+	 * TBD: This check is for faulty timer entries, where the override
+	 *      erroneously sets the trigger to level, resulting in a HUGE 
+	 *      increase of timer interrupts!
+	 */
+	if ((bus_irq == 0) && (global_irq == 2) && (trigger == 3))
+		trigger = 1;
+
+	intsrc.mpc_type = MP_INTSRC;
+	intsrc.mpc_irqtype = mp_INT;
+	intsrc.mpc_irqflag = (trigger << 2) | polarity;
+	intsrc.mpc_srcbus = MP_ISA_BUS;
+	intsrc.mpc_srcbusirq = bus_irq;				       /* IRQ */
+	intsrc.mpc_dstapic = mp_ioapics[ioapic].mpc_apicid;	   /* APIC ID */
+	intsrc.mpc_dstirq = pin;				    /* INTIN# */
+
+	Dprintk("Int: type %d, pol %d, trig %d, bus %d, irq %d, %d-%d\n",
+		intsrc.mpc_irqtype, intsrc.mpc_irqflag & 3, 
+		(intsrc.mpc_irqflag >> 2) & 3, intsrc.mpc_srcbus, 
+		intsrc.mpc_srcbusirq, intsrc.mpc_dstapic, intsrc.mpc_dstirq);
+
+	/* 
+	 * If an existing [IOAPIC.PIN -> IRQ] routing entry exists we override it.
+	 * Otherwise create a new entry (e.g. global_irq == 2).
+	 */
+	for (i = 0; i < mp_irq_entries; i++) {
+		if ((mp_irqs[i].mpc_dstapic == intsrc.mpc_dstapic) 
+			&& (mp_irqs[i].mpc_dstirq == intsrc.mpc_dstirq)) {
+			mp_irqs[i] = intsrc;
+			found = 1;
+			break;
+		}
+	}
+	if (!found) {
+		mp_irqs[mp_irq_entries] = intsrc;
+		if (++mp_irq_entries == MAX_IRQ_SOURCES)
+			panic("Max # of irq sources exceeded!\n");
+	}
+
+	return;
+}
+
+
+void __init mp_config_acpi_legacy_irqs (void)
+{
+	int			i = 0;
+	int			ioapic = -1;
+
+	/*
+	 * Initialize mp_irqs for IRQ configuration.
+	 */
+	unsigned char *bus_data;
+	int count;
+
+	count = (MAX_MP_BUSSES * sizeof(int)) * 4;
+	count += (MAX_IRQ_SOURCES * sizeof(int)) * 4;
+	bus_data = alloc_bootmem(count);
+	if (!bus_data) {
+		panic("Fatal: can't allocate bus memory for ACPI legacy IRQ!");
+	}
+	mp_bus_id_to_type = (int *)&bus_data[0];
+	mp_bus_id_to_node = (int *)&bus_data[(MAX_MP_BUSSES * sizeof(int))];
+	mp_bus_id_to_local = (int *)&bus_data[(MAX_MP_BUSSES * sizeof(int)) * 2];
+	mp_bus_id_to_pci_bus = (int *)&bus_data[(MAX_MP_BUSSES * sizeof(int)) * 3];
+	mp_irqs = (struct mpc_config_intsrc *)&bus_data[(MAX_MP_BUSSES * sizeof(int)) * 4];
+	memset(mp_bus_id_to_pci_bus, -1, MAX_MP_BUSSES);
+
+	/* 
+	 * Fabricate the legacy ISA bus (bus #31).
+	 */
+	mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA;
+	Dprintk("Bus #%d is ISA\n", MP_ISA_BUS);
+
+	/* 
+	 * Locate the IOAPIC that manages the ISA IRQs (0-15). 
+	 */
+	ioapic = mp_find_ioapic(0);
+	if (ioapic < 0)
+		return;
+
+	/* 
+	 * Use the default configuration for the IRQs 0-15.  These may be
+	 * overriden by (MADT) interrupt source override entries.
+	 */
+	for (i = 0; i < 16; i++) {
+
+		if (i == 2) continue;			/* Don't connect IRQ2 */
+
+		mp_irqs[mp_irq_entries].mpc_type = MP_INTSRC;
+		mp_irqs[mp_irq_entries].mpc_irqflag = 0;	/* Conforming */
+		mp_irqs[mp_irq_entries].mpc_srcbus = MP_ISA_BUS;
+		mp_irqs[mp_irq_entries].mpc_dstapic = mp_ioapics[ioapic].mpc_apicid;
+		mp_irqs[mp_irq_entries].mpc_irqtype = i ? mp_INT : mp_ExtINT;   /* 8259A to #0 */
+		mp_irqs[mp_irq_entries].mpc_srcbusirq = i;	   /* Identity mapped */
+		mp_irqs[mp_irq_entries].mpc_dstirq = i;
+
+		Dprintk("Int: type %d, pol %d, trig %d, bus %d, irq %d, "
+			"%d-%d\n", 
+			mp_irqs[mp_irq_entries].mpc_irqtype, 
+			mp_irqs[mp_irq_entries].mpc_irqflag & 3, 
+			(mp_irqs[mp_irq_entries].mpc_irqflag >> 2) & 3, 
+			mp_irqs[mp_irq_entries].mpc_srcbus, 
+			mp_irqs[mp_irq_entries].mpc_srcbusirq, 
+			mp_irqs[mp_irq_entries].mpc_dstapic, 
+			mp_irqs[mp_irq_entries].mpc_dstirq);
+
+		if (++mp_irq_entries == MAX_IRQ_SOURCES)
+			panic("Max # of irq sources exceeded!\n");
+	}
+}
+
+/* Ensure the ACPI SCI interrupt level is active low, edge-triggered */
+
+extern FADT_DESCRIPTOR acpi_fadt;
+
+void __init mp_config_ioapic_for_sci(int irq)
+{
+	int ioapic;
+	int ioapic_pin;
+	struct acpi_table_madt* madt;
+	struct acpi_table_int_src_ovr *entry = NULL;
+	void *madt_end;
+	acpi_status status;
+
+	/*
+	 * Ensure that if there is an interrupt source override entry
+	 * for the ACPI SCI, we leave it as is. Unfortunately this involves
+	 * walking the MADT again.
+	 */
+	status = acpi_get_firmware_table("APIC", 1, ACPI_LOGICAL_ADDRESSING,
+		(struct acpi_table_header **) &madt);
+	if (ACPI_SUCCESS(status)) {
+		madt_end = (void *) (unsigned long)madt + madt->header.length;
+
+		entry = (struct acpi_table_int_src_ovr *)
+                ((unsigned long) madt + sizeof(struct acpi_table_madt));
+
+		while ((void *) entry < madt_end) {
+                	if (entry->header.type == ACPI_MADT_INT_SRC_OVR &&
+			    acpi_fadt.sci_int == entry->bus_irq) {
+				/*
+				 * See the note at the end of ACPI 2.0b section
+				 * 5.2.10.8 for what this is about.
+				 */
+				if (entry->bus_irq != entry->global_irq) {
+					acpi_fadt.sci_int = entry->global_irq;
+					irq = entry->global_irq;
+					break;
+				}
+				else
+                			return;
+			}
+
+                	entry = (struct acpi_table_int_src_ovr *)
+                	        ((unsigned long) entry + entry->header.length);
+        	}
+	}
+
+	ioapic = mp_find_ioapic(irq);
+
+	ioapic_pin = irq - mp_ioapic_routing[ioapic].irq_start;
+
+	io_apic_set_pci_routing(ioapic, ioapic_pin, irq);
+}
+
+#ifdef CONFIG_ACPI_PCI
+
+void __init mp_parse_prt (void)
+{
+	struct list_head	*node = NULL;
+	struct acpi_prt_entry	*entry = NULL;
+	int			ioapic = -1;
+	int			ioapic_pin = 0;
+	int			irq = 0;
+	int			idx, bit = 0;
+
+	/*
+	 * Parsing through the PCI Interrupt Routing Table (PRT) and program
+	 * routing for all entries.
+	 */
+	list_for_each(node, &acpi_prt.entries) {
+		entry = list_entry(node, struct acpi_prt_entry, node);
+
+		/* Need to get irq for dynamic entry */
+		if (entry->link.handle) {
+			irq = acpi_pci_link_get_irq(entry->link.handle, entry->link.index);
+			if (!irq)
+				continue;
+		}
+		else
+			irq = entry->link.index;
+
+		/* Don't set up the ACPI SCI because it's already set up */
+		if (acpi_fadt.sci_int == irq)
+			continue;
+	
+		ioapic = mp_find_ioapic(irq);
+		if (ioapic < 0)
+			continue;
+		ioapic_pin = irq - mp_ioapic_routing[ioapic].irq_start;
+
+		/* 
+		 * Avoid pin reprogramming.  PRTs typically include entries  
+		 * with redundant pin->irq mappings (but unique PCI devices);
+		 * we only only program the IOAPIC on the first.
+		 */
+		bit = ioapic_pin % 32;
+		idx = (ioapic_pin < 32) ? 0 : (ioapic_pin / 32);
+		if (idx > 3) {
+			printk(KERN_ERR "Invalid reference to IOAPIC pin "
+				"%d-%d\n", mp_ioapic_routing[ioapic].apic_id, 
+				ioapic_pin);
+			continue;
+		}
+		if ((1<<bit) & mp_ioapic_routing[ioapic].pin_programmed[idx]) {
+			printk(KERN_DEBUG "Pin %d-%d already programmed\n",
+				mp_ioapic_routing[ioapic].apic_id, ioapic_pin);
+			entry->irq = irq;
+			continue;
+		}
+
+		mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit);
+
+		if (!io_apic_set_pci_routing(ioapic, ioapic_pin, irq))
+			entry->irq = irq;
+
+		printk(KERN_DEBUG "%02x:%02x:%02x[%c] -> %d-%d -> IRQ %d\n",
+			entry->id.segment, entry->id.bus, 
+			entry->id.device, ('A' + entry->pin), 
+			mp_ioapic_routing[ioapic].apic_id, ioapic_pin, 
+			entry->irq);
+	}
+	
+	return;
+}
+
+#endif /*CONFIG_ACPI_PCI*/
+
+#endif /*CONFIG_X86_IO_APIC*/
+
+#endif /*CONFIG_ACPI_BOOT*/
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/i386/kernel/pci-irq.c linux-2.4.22-pre2/arch/i386/kernel/pci-irq.c
--- linux-2.4.21/arch/i386/kernel/pci-irq.c	2003-06-26 21:45:04.000000000 +0000
+++ linux-2.4.22-pre2/arch/i386/kernel/pci-irq.c	2003-06-26 21:43:33.000000000 +0000
@@ -116,7 +116,7 @@
  *  Code for querying and setting of IRQ routes on various interrupt routers.
  */
 
-static void eisa_set_level_irq(unsigned int irq)
+void eisa_set_level_irq(unsigned int irq)
 {
 	unsigned char mask = 1 << (irq & 7);
 	unsigned int port = 0x4d0 + (irq >> 3);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/i386/kernel/pci-pc.c linux-2.4.22-pre2/arch/i386/kernel/pci-pc.c
--- linux-2.4.21/arch/i386/kernel/pci-pc.c	2002-11-28 23:53:09.000000000 +0000
+++ linux-2.4.22-pre2/arch/i386/kernel/pci-pc.c	2003-06-26 21:43:19.000000000 +0000
@@ -11,6 +11,7 @@
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
+#include <linux/acpi.h>
 
 #include <asm/segment.h>
 #include <asm/io.h>
@@ -28,6 +29,8 @@
 int (*pci_config_read)(int seg, int bus, int dev, int fn, int reg, int len, u32 *value) = NULL;
 int (*pci_config_write)(int seg, int bus, int dev, int fn, int reg, int len, u32 value) = NULL;
 
+static int pci_using_acpi_prt = 0;
+
 #ifdef CONFIG_MULTIQUAD
 #define BUS2QUAD(global) (mp_bus_id_to_node[global])
 #define BUS2LOCAL(global) (mp_bus_id_to_local[global])
@@ -1353,6 +1356,23 @@
 	pci_read_bridge_bases(b);
 }
 
+struct pci_bus * __devinit pcibios_scan_root(int busnum)
+{
+	struct list_head *list;
+	struct pci_bus *bus;
+
+	list_for_each(list, &pci_root_buses) {
+		bus = pci_bus_b(list);
+		if (bus->number == busnum) {
+			/* Already scanned */
+			return bus;
+		}
+	}
+
+	printk("PCI: Probing PCI hardware (bus %02x)\n", busnum);
+
+	return pci_scan_bus(busnum, pci_root_ops, NULL);
+}
 
 void __devinit pcibios_config_init(void)
 {
@@ -1394,6 +1414,8 @@
 	return;
 }
 
+int use_acpi_pci __initdata = 1;
+
 void __init pcibios_init(void)
 {
 	int quad;
@@ -1406,7 +1428,19 @@
 	}
 
 	printk(KERN_INFO "PCI: Probing PCI hardware\n");
-	pci_root_bus = pci_scan_bus(0, pci_root_ops, NULL);
+#ifdef CONFIG_ACPI_PCI
+	if (use_acpi_pci && !acpi_pci_irq_init()) {
+		pci_using_acpi_prt = 1;
+		printk(KERN_INFO "PCI: Using ACPI for IRQ routing\n");
+		printk(KERN_INFO "PCI: if you experience problems, try using option 'pci=noacpi' or even 'acpi=off'\n");
+	}
+#endif
+	if (!pci_using_acpi_prt) {
+		pci_root_bus = pcibios_scan_root(0);
+		pcibios_irq_init();
+		pcibios_fixup_peer_bridges();
+		pcibios_fixup_irqs();
+	}
 	if (clustered_apic_mode && (numnodes > 1)) {
 		for (quad = 1; quad < numnodes; ++quad) {
 			printk("Scanning PCI bus %d for quad %d\n", 
@@ -1416,9 +1450,6 @@
 		}
 	}
 
-	pcibios_irq_init();
-	pcibios_fixup_peer_bridges();
-	pcibios_fixup_irqs();
 	pcibios_resource_survey();
 
 #ifdef CONFIG_PCI_BIOS
@@ -1470,6 +1501,9 @@
 	} else if (!strncmp(str, "lastbus=", 8)) {
 		pcibios_last_bus = simple_strtol(str+8, NULL, 0);
 		return NULL;
+	} else if (!strncmp(str, "noacpi", 6)) {
+		use_acpi_pci = 0;
+		return NULL;
 	}
 	return str;
 }
@@ -1485,6 +1519,15 @@
 
 	if ((err = pcibios_enable_resources(dev, mask)) < 0)
 		return err;
+
+#ifdef CONFIG_ACPI_PCI
+	if (pci_using_acpi_prt) {
+		acpi_pci_irq_enable(dev);
+		return 0;
+	}
+#endif
+
 	pcibios_enable_irq(dev);
+
 	return 0;
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/i386/kernel/setup.c linux-2.4.22-pre2/arch/i386/kernel/setup.c
--- linux-2.4.21/arch/i386/kernel/setup.c	2003-06-26 21:45:04.000000000 +0000
+++ linux-2.4.22-pre2/arch/i386/kernel/setup.c	2003-06-26 21:43:21.000000000 +0000
@@ -95,6 +95,7 @@
 #include <linux/delay.h>
 #include <linux/config.h>
 #include <linux/init.h>
+#include <linux/acpi.h>
 #include <linux/apm_bios.h>
 #ifdef CONFIG_BLK_DEV_RAM
 #include <linux/blk.h>
@@ -172,9 +173,14 @@
 static int disable_x86_serial_nr __initdata = 1;
 static int disable_x86_ht __initdata = 0;
 static u32 disabled_x86_caps[NCAPINTS] __initdata = { 0 };
-extern int blk_nohighio;
 
-int enable_acpi_smp_table;
+#ifdef CONFIG_ACPI_HT_ONLY
+int acpi_disabled __initdata = 1;
+#else
+int acpi_disabled __initdata = 0;
+#endif
+
+extern int blk_nohighio;
 
 /*
  * This is set up by the setup-routine at boot-time
@@ -782,6 +788,12 @@
 				if (*from == '@') {
 					start_at = memparse(from+1, &from);
 					add_memory_region(start_at, mem_size, E820_RAM);
+				} else if (*from == '#') {
+					start_at = memparse(from+1, &from);
+					add_memory_region(start_at, mem_size, E820_ACPI);
+				} else if (*from == '$') {
+					start_at = memparse(from+1, &from);
+					add_memory_region(start_at, mem_size, E820_RESERVED);
 				} else {
 					limit_regions(mem_size);
 					userdef=1;
@@ -795,9 +807,13 @@
 			set_bit(X86_FEATURE_HT, disabled_x86_caps);
 		}
 
-		/* "acpismp=force" forces parsing and use of the ACPI SMP table */
+		/* "acpi=off" disables both ACPI table parsing and interpreter init */
+		else if (!memcmp(from, "acpi=off", 8))
+			acpi_disabled = 1;
+
+		/* "acpismp=force" turns on ACPI again */
 		else if (!memcmp(from, "acpismp=force", 13))
-			enable_acpi_smp_table = 1;
+			acpi_disabled = 0;
 
 		/*
 		 * highmem=size forces highmem to be exactly 'size' bytes.
@@ -1007,10 +1023,15 @@
 	 */
 	reserve_bootmem(PAGE_SIZE, PAGE_SIZE);
 #endif
-
+#ifdef CONFIG_ACPI_SLEEP
+	/*
+	 * Reserve low memory region for sleep support.
+	 */
+	acpi_reserve_bootmem();
+#endif
 #ifdef CONFIG_X86_LOCAL_APIC
 	/*
-	 * Find and reserve possible boot-time SMP configuration:
+	 * Find and reserve possible boot-time SMP configuration.
 	 */
 	find_smp_config();
 #endif
@@ -1043,7 +1064,6 @@
 {
 	unsigned long low_mem_size;
 	int i;
-
 	probe_roms();
 	for (i = 0; i < e820.nr_map; i++) {
 		struct resource *res;
@@ -1129,21 +1149,10 @@
 
 	max_low_pfn = setup_memory();
 
-	/*
-	 * If enable_acpi_smp_table and HT feature present, acpitable.c
-	 * will find all logical cpus despite disable_x86_ht: so if both
-	 * "noht" and "acpismp=force" are specified, let "noht" override
-	 * "acpismp=force" cleanly.  Why retain "acpismp=force"? because
-	 * parsing ACPI SMP table might prove useful on some non-HT cpu.
-	 */
 	if (disable_x86_ht) {
 		clear_bit(X86_FEATURE_HT, &boot_cpu_data.x86_capability[0]);
 		set_bit(X86_FEATURE_HT, disabled_x86_caps);
-		enable_acpi_smp_table = 0;
 	}
-	if (test_bit(X86_FEATURE_HT, &boot_cpu_data.x86_capability[0]))
-		enable_acpi_smp_table = 1;
-	
 
 	/*
 	 * NOTE: before this point _nobody_ is allowed to allocate
@@ -1154,6 +1163,13 @@
 	smp_alloc_memory(); /* AP processor realmode stacks in low memory*/
 #endif
 	paging_init();
+#ifdef CONFIG_ACPI
+	/*
+	 * Parse the ACPI tables for possible boot-time SMP configuration.
+	 */
+	if (!acpi_disabled)
+		acpi_boot_init();
+#endif
 #ifdef CONFIG_X86_LOCAL_APIC
 	/*
 	 * get boot-time SMP configuration:
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/8260_io/enet.c linux-2.4.22-pre2/arch/ppc/8260_io/enet.c
--- linux-2.4.21/arch/ppc/8260_io/enet.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/8260_io/enet.c	2003-06-26 21:43:10.000000000 +0000
@@ -115,7 +115,7 @@
 	cbd_t	*dirty_tx;	/* The ring entries to be free()ed. */
 	scc_t	*sccp;
 	struct	net_device_stats stats;
-	uint	tx_full;
+	uint	tx_free;
 	spinlock_t lock;
 };
 
@@ -175,9 +175,9 @@
 	bdp = cep->cur_tx;
 
 #ifndef final_version
-	if (bdp->cbd_sc & BD_ENET_TX_READY) {
+	if (!cep->tx_free || (bdp->cbd_sc & BD_ENET_TX_READY)) {
 		/* Ooops.  All transmit buffers are full.  Bail out.
-		 * This should not happen, since cep->tx_full should be set.
+		 * This should not happen, since the tx queue should be stopped.
 		 */
 		printk("%s: tx queue full!.\n", dev->name);
 		return 1;
@@ -223,10 +223,8 @@
 	else
 		bdp++;
 
-	if (bdp->cbd_sc & BD_ENET_TX_READY) {
+	if (!--cep->tx_free)
 		netif_stop_queue(dev);
-		cep->tx_full = 1;
-	}
 
 	cep->cur_tx = (cbd_t *)bdp;
 
@@ -246,8 +244,8 @@
 	{
 		int	i;
 		cbd_t	*bdp;
-		printk(" Ring data dump: cur_tx %p%s cur_rx %p.\n",
-		       cep->cur_tx, cep->tx_full ? " (full)" : "",
+		printk(" Ring data dump: cur_tx %p tx_free %d cur_rx %p.\n",
+		       cep->cur_tx, cep->tx_free,
 		       cep->cur_rx);
 		bdp = cep->tx_bd_base;
 		printk(" Tx @base %p :\n", bdp);
@@ -265,7 +263,7 @@
 			       bdp->cbd_bufaddr);
 	}
 #endif
-	if (!cep->tx_full)
+	if (cep->tx_free)
 		netif_wake_queue(dev);
 }
 
@@ -309,7 +307,7 @@
 	    spin_lock(&cep->lock);
 	    bdp = cep->dirty_tx;
 	    while ((bdp->cbd_sc&BD_ENET_TX_READY)==0) {
-		if ((bdp==cep->cur_tx) && (cep->tx_full == 0))
+		if (cep->tx_free == TX_RING_SIZE)
 		    break;
 
 		if (bdp->cbd_sc & BD_ENET_TX_HB)	/* No heartbeat */
@@ -365,8 +363,7 @@
 		/* Since we have freed up a buffer, the ring is no longer
 		 * full.
 		 */
-		if (cep->tx_full) {
-			cep->tx_full = 0;
+		if (!cep->tx_free++) {
 			if (netif_queue_stopped(dev)) {
 				netif_wake_queue(dev);
 			}
@@ -395,13 +392,10 @@
 	}
 
 	/* Check for receive busy, i.e. packets coming but no place to
-	 * put them.  This "can't happen" because the receive interrupt
-	 * is tossing previous frames.
+	 * put them.
 	 */
-	if (int_events & SCCE_ENET_BSY) {
+	if (int_events & SCCE_ENET_BSY)
 		cep->stats.rx_dropped++;
-		printk("SCC ENET: BSY can't happen.\n");
-	}
 
 	return;
 }
@@ -576,7 +570,7 @@
 
 			dmi = dev->mc_list;
 
-			for (i=0; i<dev->mc_count; i++) {
+			for (i=0; i<dev->mc_count; i++, dmi = dmi->next) {
 				
 				/* Only support group multicast for now.
 				*/
@@ -693,6 +687,7 @@
 	cep->tx_bd_base = (cbd_t *)&immap->im_dprambase[i];
 
 	cep->dirty_tx = cep->cur_tx = cep->tx_bd_base;
+	cep->tx_free = TX_RING_SIZE;
 	cep->cur_rx = cep->rx_bd_base;
 
 	ep->sen_genscc.scc_rfcr = CPMFCR_GBL | CPMFCR_EB;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/8260_io/fcc_enet.c linux-2.4.22-pre2/arch/ppc/8260_io/fcc_enet.c
--- linux-2.4.21/arch/ppc/8260_io/fcc_enet.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/8260_io/fcc_enet.c	2003-06-26 21:43:20.000000000 +0000
@@ -1030,7 +1030,7 @@
 
 			dmi = dev->mc_list;
 
-			for (i=0; i<dev->mc_count; i++) {
+			for (i=0; i<dev->mc_count; i++, dmi = dmi->next) {
 				
 				/* Only support group multicast for now.
 				*/
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/8260_io/uart.c linux-2.4.22-pre2/arch/ppc/8260_io/uart.c
--- linux-2.4.21/arch/ppc/8260_io/uart.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/8260_io/uart.c	2003-06-26 21:43:11.000000000 +0000
@@ -907,9 +907,9 @@
 		 * enables, because we want to put them back if they were
 		 * present.
 		 */
-		prev_mode = smcp->smc_smcmr;
-		smcp->smc_smcmr = smcr_mk_clen(bits) | cval |  SMCMR_SM_UART;
-		smcp->smc_smcmr |= (prev_mode & (SMCMR_REN | SMCMR_TEN));
+		prev_mode = smcp->smc_smcmr & (SMCMR_REN | SMCMR_TEN);
+		smcp->smc_smcmr = smcr_mk_clen(bits) | cval | SMCMR_SM_UART
+			| prev_mode;
 	}
 	else {
 		sccp = &immr->im_scc[idx - SCC_IDX_BASE];
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/8xx_io/enet.c linux-2.4.22-pre2/arch/ppc/8xx_io/enet.c
--- linux-2.4.21/arch/ppc/8xx_io/enet.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/8xx_io/enet.c	2003-06-26 21:43:15.000000000 +0000
@@ -594,7 +594,7 @@
 
 			dmi = dev->mc_list;
 
-			for (i=0; i<dev->mc_count; i++) {
+			for (i=0; i<dev->mc_count; i++, dmi = dmi->next) {
 				
 				/* Only support group multicast for now.
 				*/
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/8xx_io/fec.c linux-2.4.22-pre2/arch/ppc/8xx_io/fec.c
--- linux-2.4.21/arch/ppc/8xx_io/fec.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/8xx_io/fec.c	2003-06-26 21:43:18.000000000 +0000
@@ -163,7 +163,7 @@
 	cbd_t	*dirty_tx;	/* The ring entries to be free()ed. */
 	scc_t	*sccp;
 	struct	net_device_stats stats;
-	uint	tx_full;
+	uint	tx_free;
 	spinlock_t lock;
 
 #ifdef	CONFIG_USE_MDIO
@@ -229,6 +229,7 @@
 mii_list_t	*mii_free;
 mii_list_t	*mii_head;
 mii_list_t	*mii_tail;
+int         mii_stopped;
 
 typedef struct mdio_read_data {
 	u16 regval;
@@ -295,18 +296,13 @@
 	fep = dev->priv;
 	fecp = (volatile fec_t*)dev->base_addr;
 
-	if (!fep->link) {
-		/* Link is down or autonegotiation is in progress. */
-		return 1;
-	}
-
 	/* Fill in a Tx ring entry */
 	bdp = fep->cur_tx;
 
 #ifndef final_version
-	if (bdp->cbd_sc & BD_ENET_TX_READY) {
+	if (!fep->tx_free || (bdp->cbd_sc & BD_ENET_TX_READY)) {
 		/* Ooops.  All transmit buffers are full.  Bail out.
-		 * This should not happen, since dev->tbusy should be set.
+		 * This should not happen, since the tx queue should be stopped.
 		 */
 		printk("%s: tx queue full!.\n", dev->name);
 		return 1;
@@ -357,10 +353,8 @@
 		bdp++;
 	}
 
-	if (bdp->cbd_sc & BD_ENET_TX_READY) {
+	if (!--fep->tx_free)
 		netif_stop_queue(dev);
-		fep->tx_full = 1;
-	}
 
 	fep->cur_tx = (cbd_t *)bdp;
 
@@ -381,11 +375,11 @@
 	int	i;
 	cbd_t	*bdp;
 
-	printk("Ring data dump: cur_tx %lx%s, dirty_tx %lx cur_rx: %lx\n",
-	       (unsigned long)fep->cur_tx, fep->tx_full ? " (full)" : "",
+	printk("Ring data dump: cur_tx %lx, tx_free %d, dirty_tx %lx, cur_rx %lx\n",
+	       (unsigned long)fep->cur_tx, fep->tx_free,
 	       (unsigned long)fep->dirty_tx,
 	       (unsigned long)fep->cur_rx);
-
+ 
 	bdp = fep->tx_bd_base;
 	printk(" tx: %u buffers\n",  TX_RING_SIZE);
 	for (i = 0 ; i < TX_RING_SIZE; i++) {
@@ -409,7 +403,7 @@
 	}
 	}
 #endif
-	if (!fep->tx_full)
+	if (fep->tx_free)
 		netif_wake_queue(dev);
 }
 
@@ -469,7 +463,7 @@
 	bdp = fep->dirty_tx;
 
 	while ((bdp->cbd_sc&BD_ENET_TX_READY) == 0) {
-		if (bdp == fep->cur_tx && fep->tx_full == 0) break;
+		if (fep->tx_free == TX_RING_SIZE) break;
 
 		skb = fep->tx_skbuff[fep->skb_dirty];
 		/* Check for errors. */
@@ -519,8 +513,7 @@
 		/* Since we have freed up a buffer, the ring is no longer
 		 * full.
 		 */
-		if (fep->tx_full) {
-			fep->tx_full = 0;
+		if (!fep->tx_free++) {
 			if (netif_queue_stopped(dev))
 				netif_wake_queue(dev);
 		}
@@ -668,6 +661,12 @@
 	ep = &(((immap_t *)IMAP_ADDR)->im_cpm.cp_fec);
 	mii_reg = ep->fec_mii_data;
 
+	/* Ignore this answer if the request queue has been stopped.
+	 * The request will be re-issued when the queue is restarted.
+	 */
+	if (mii_stopped)
+		return;
+
 	if ((mip = mii_head) == NULL) {
 		printk("MII and no head!\n");
 		return;
@@ -714,7 +713,8 @@
 			mii_tail = mip;
 		} else {
 			mii_head = mii_tail = mip;
-			(&(((immap_t *)IMAP_ADDR)->im_cpm.cp_fec))->fec_mii_data = regval;
+			if (!mii_stopped)
+				(&(((immap_t *)IMAP_ADDR)->im_cpm.cp_fec))->fec_mii_data = regval;
 		}
 	} else {
 		retval = 1;
@@ -725,6 +725,30 @@
 	return(retval);
 }
 
+/* Functions to stop/start the transmission of requests through the MDIO.
+ * They are intended to be used before and after a FEC reset.
+ */
+static void stop_mii_queue(struct net_device *dev)
+{
+	unsigned long flags;
+	save_flags(flags);
+	cli();
+	mii_stopped = 1;
+	restore_flags(flags);
+}
+
+static void start_mii_queue(struct net_device *dev)
+{
+	unsigned long flags;
+	volatile fec_t *ep = &(((immap_t *)IMAP_ADDR)->im_cpm.cp_fec);
+	save_flags(flags);
+	cli();
+	mii_stopped = 0;
+	if(mii_head)
+		ep->fec_mii_data = mii_head->mii_regval;
+	restore_flags(flags);
+}
+
 static void mii_do_cmd(struct net_device *dev, const phy_cmd_t *c)
 {
 	int k;
@@ -1367,31 +1391,20 @@
 #ifdef	CONFIG_USE_MDIO
 	struct	net_device *dev = dev_id;
 	struct fec_enet_private *fep = dev->priv;
-	volatile immap_t *immap = (immap_t *)IMAP_ADDR;
-	volatile fec_t *fecp = &(immap->im_cpm.cp_fec);
-	unsigned int ecntrl = fecp->fec_ecntrl;
-
-	/* We need the FEC enabled to access the MII
-	*/
-	if ((ecntrl & FEC_ECNTRL_ETHER_EN) == 0) {
-		fecp->fec_ecntrl |= FEC_ECNTRL_ETHER_EN;
-	}
-#endif	/* CONFIG_USE_MDIO */
-
-#if 0
-	disable_irq(fep->mii_irq);  /* disable now, enable later */
-#endif
-
 
-#ifdef	CONFIG_USE_MDIO
-	mii_do_cmd(dev, fep->phy->ack_int);
-	mii_do_cmd(dev, phy_cmd_relink);  /* restart and display status */
-
-	if ((ecntrl & FEC_ECNTRL_ETHER_EN) == 0) {
-		fecp->fec_ecntrl = ecntrl;	/* restore old settings */
+	/*
+	 * Acknowledge the interrupt if possible. If we have not
+	 * found the PHY yet we can't process or acknowledge the
+	 * interrupt now. Instead we ignore this interrupt for now,
+	 * which we can do since it is edge triggered. It will be
+	 * acknowledged later by fec_enet_open().
+	 */
+	if (fep->phy) {
+		mii_do_cmd(dev, fep->phy->ack_int);
+		mii_do_cmd(dev, phy_cmd_relink);  /* restart and display status */
 	}
 #else
-printk("%s[%d] %s: unexpected Link interrupt\n", __FILE__,__LINE__,__FUNCTION__);
+	printk ("FEC: unexpected Link interrupt\n");
 #endif	/* CONFIG_USE_MDIO */
 
 }
@@ -1652,7 +1665,7 @@
 
 			dmi = dev->mc_list;
 
-			for (i=0; i<dev->mc_count; i++) {
+			for (i=0; i<dev->mc_count; i++, dmi = dmi->next) {
 
 				/* Only support group multicast for now.
 				*/
@@ -1927,6 +1940,11 @@
 
 	fep = dev->priv;
 
+#ifdef CONFIG_USE_MDIO
+	/* Stop the MDIO communication prior to reset. */
+	stop_mii_queue(dev);
+#endif
+
 	/* Whack a reset.  We should wait for this.
 	*/
 	fecp->fec_ecntrl = FEC_ECNTRL_PINMUX | FEC_ECNTRL_RESET;
@@ -1960,6 +1978,7 @@
 	fecp->fec_x_des_start = __pa((uint)(fep->tx_bd_base));
 
 	fep->dirty_tx = fep->cur_tx = fep->tx_bd_base;
+	fep->tx_free = TX_RING_SIZE;
 	fep->cur_rx = fep->rx_bd_base;
 
 	/* Reset SKB transmit buffers.
@@ -2043,12 +2062,10 @@
 	fecp->fec_ecntrl = FEC_ECNTRL_PINMUX | FEC_ECNTRL_ETHER_EN;
 	fecp->fec_r_des_active = 0x01000000;
 
-	/* The tx ring is no longer full. */
-	if(fep->tx_full)
-	{
-		fep->tx_full = 0;
-		netif_wake_queue(dev);
-	}
+#ifdef CONFIG_USE_MDIO
+	/* Re-start any pending MDIO communication. */
+	start_mii_queue(dev);
+#endif
 }
 
 static void
@@ -2080,22 +2097,7 @@
 		printk ("FEC timeout on graceful transmit stop\n");
 	}
 
-	/* Clear outstanding MII command interrupts.
-	*/
-	fecp->fec_ievent = FEC_ENET_MII;
-
-	/* Enable MII command finished interrupt
-	*/
-	fecp->fec_ivec = (FEC_INTERRUPT/2) << 29;
+	/* Disable FEC. Let only MII interrupts. */
 	fecp->fec_imask = FEC_ENET_MII;
-
-#ifdef	CONFIG_USE_MDIO
-	/* Set MII speed.
-	*/
-	fecp->fec_mii_speed = fep->phy_speed;
-#endif	/* CONFIG_USE_MDIO */
-
-	/* Disable FEC
-	*/
 	fecp->fec_ecntrl &= ~(FEC_ECNTRL_ETHER_EN);
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/8xx_io/uart.c linux-2.4.22-pre2/arch/ppc/8xx_io/uart.c
--- linux-2.4.21/arch/ppc/8xx_io/uart.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/8xx_io/uart.c	2003-06-26 21:43:29.000000000 +0000
@@ -1023,9 +1023,9 @@
 		 * 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));
+		prev_mode = smcp->smc_smcmr & (SMCMR_REN | SMCMR_TEN);
+		new_mode = smcr_mk_clen(bits) | cval | SMCMR_SM_UART
+			| prev_mode;
 		if (!(prev_mode & SMCMR_PEN))
 			/* If parity is disabled, mask out even/odd */
 			prev_mode &= ~SMCMR_PM_EVEN;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/Makefile linux-2.4.22-pre2/arch/ppc/Makefile
--- linux-2.4.21/arch/ppc/Makefile	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/Makefile	2003-06-26 21:43:11.000000000 +0000
@@ -16,10 +16,6 @@
 # Be sure to change PAGE_OFFSET in include/asm-ppc/page.h to match
 KERNELLOAD	=0xc0000000
 
-ifeq ($(shell uname -m),ppc)
-CHECKS		= checks
-endif
-
 LINKFLAGS	= -T arch/ppc/vmlinux.lds -Ttext $(KERNELLOAD) -Bstatic
 CPPFLAGS	:= $(CPPFLAGS) -I$(TOPDIR)/arch/$(ARCH)
 AFLAGS		:= $(AFLAGS) -I$(TOPDIR)/arch/$(ARCH)
@@ -46,7 +42,7 @@
   CFLAGS += $(shell echo $(CONFIG_COMPILE_OPTIONS) | sed -e 's/"//g')
 endif
 
-ifdef CONFIG_4xx
+ifdef CONFIG_40x
   HEAD := arch/ppc/kernel/head_4xx.o
 else
   ifdef CONFIG_8xx
@@ -99,7 +95,7 @@
 # All the instructions talk about "make bzImage".
 bzImage: zImage
 
-$(BOOT_TARGETS): $(CHECKS) vmlinux
+$(BOOT_TARGETS): vmlinux
 	@$(MAKEBOOT) $@
 
 %_config: arch/ppc/configs/%_defconfig
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/boot/simple/Makefile linux-2.4.22-pre2/arch/ppc/boot/simple/Makefile
--- linux-2.4.21/arch/ppc/boot/simple/Makefile	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/boot/simple/Makefile	2003-06-26 21:43:10.000000000 +0000
@@ -74,7 +74,7 @@
 				$(MISC) ../common/misc-common.o \
 				../common/string.o ../common/util.o \
 				../common/serial_stub.o
-obj-$(CONFIG_4xx)		+= embed_config.o
+obj-$(CONFIG_40x)		+= embed_config.o
 obj-$(CONFIG_8xx)		+= embed_config.o
 obj-$(CONFIG_8260)		+= embed_config.o
 obj-$(CONFIG_BSEIP)		+= iic.o
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/config.in linux-2.4.22-pre2/arch/ppc/config.in
--- linux-2.4.21/arch/ppc/config.in	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/config.in	2003-06-26 21:43:22.000000000 +0000
@@ -29,11 +29,15 @@
 define_bool CONFIG_PPC32 y
 choice 'Processor Type'	\
 	"6xx/7xx/74xx/8260	CONFIG_6xx	\
-	 4xx			CONFIG_4xx	\
+	 40x			CONFIG_40x	\
 	 POWER3               	CONFIG_POWER3	\
 	 POWER4        	        CONFIG_POWER4	\
 	 8xx			CONFIG_8xx"	6xx
 
+if [ "$CONFIG_40x" = "y" ]; then
+  define_bool CONFIG_4xx y
+fi
+
 if [ "$CONFIG_6xx" = "y" ]; then
   bool 'MPC8260 CPM Support' CONFIG_8260
 fi
@@ -56,17 +60,15 @@
   bool 'Support for EST8260' CONFIG_EST8260
 fi
 
-if [ "$CONFIG_4xx" = "y" ]; then
-  choice 'Machine Type'			\
-	"Oak			CONFIG_OAK 	\
-	 Walnut			CONFIG_WALNUT"	Oak
-  if [ "$CONFIG_WALNUT" = "y" ]; then
-    define_bool CONFIG_IBM405_ERR77 y
-  fi
+if [ "$CONFIG_40x" = "y" ]; then
+    choice 'Machine Type'			\
+	 "Oak		CONFIG_OAK 		\
+	 Walnut		CONFIG_WALNUT"		Walnut
 fi
 
 if [ "$CONFIG_8xx" = "y" ]; then
   define_bool CONFIG_SERIAL_CONSOLE y
+  define_bool CONFIG_NOT_COHERENT_CACHE y
 
   choice 'Machine Type'		\
 	"RPX-Lite	CONFIG_RPXLITE		\
@@ -138,6 +140,30 @@
   bool 'Math emulation' CONFIG_MATH_EMULATION
 fi
 
+if [ "$CONFIG_40x" = "y" ]; then
+# It's often necessary to know the specific 4xx processor type.
+# Fortunately, it is impled (so far) from the board type, so we
+# don't need to ask more redundant questions.
+  if [ "$CONFIG_OAK" = "y" -o "$CONFIG_TIVO" = "y" ]; then
+    define_bool CONFIG_403GCX y
+    define_bool CONFIG_IBM_OPENBIOS y
+  fi
+  if [ "$CONFIG_WALNUT" = "y" ]; then
+    define_bool CONFIG_405GP y
+    define_bool CONFIG_BIOS_FIXUP y
+    define_bool CONFIG_IBM_OPENBIOS y
+    define_bool CONFIG_IBM405_ERR77 y
+    define_bool CONFIG_IBM_OCP y
+  fi
+  if [ "$CONFIG_40x" = "y" ]; then
+    choice 'TTYS0 device and default console'	\
+	"UART0  CONFIG_UART0_TTYS0		\
+	 UART1	CONFIG_UART0_TTYS1"		UART0
+  fi
+
+  define_bool CONFIG_IBM405_ERR51 y
+  define_bool CONFIG_NOT_COHERENT_CACHE y
+fi
 if [ "$CONFIG_8xx" = "y" -o "$CONFIG_8260" = "y" ]; then
     define_bool CONFIG_EMBEDDEDBOOT y
 fi
@@ -156,7 +182,8 @@
 define_bool CONFIG_MCA n
 
 if [ "$CONFIG_4xx" = "y" -o "$CONFIG_8260" = "y" ]; then
-  define_bool CONFIG_PCI n
+  bool "Enable PCI" CONFIG_PCI
+  bool 'PC PS/2 style Keyboard' CONFIG_PC_KEYBOARD
 else
   if [ "$CONFIG_8xx" = "y" ]; then
      bool 'QSpan PCI' CONFIG_PCI_QSPAN
@@ -328,7 +355,7 @@
 
 mainmenu_option next_comment
 comment 'Console drivers'
-if [ "$CONFIG_4xx" != "y" -a "$CONFIG_8xx" != "y" ]; then
+if [ "$CONFIG_40x" != "y" -a "$CONFIG_8xx" != "y" ]; then
   bool 'Support for VGA Console' CONFIG_VGA_CONSOLE
 fi
  source drivers/video/Config.in
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/configs/walnut_defconfig linux-2.4.22-pre2/arch/ppc/configs/walnut_defconfig
--- linux-2.4.21/arch/ppc/configs/walnut_defconfig	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/configs/walnut_defconfig	2003-06-26 21:43:31.000000000 +0000
@@ -24,17 +24,24 @@
 CONFIG_PPC=y
 CONFIG_PPC32=y
 # CONFIG_6xx is not set
-CONFIG_4xx=y
+CONFIG_40x=y
 # CONFIG_POWER3 is not set
 # CONFIG_POWER4 is not set
 # CONFIG_8xx is not set
+CONFIG_4xx=y
 # CONFIG_PPC_STD_MMU is not set
 # CONFIG_OAK is not set
 CONFIG_WALNUT=y
-CONFIG_IBM405_ERR77=y
 # CONFIG_ALL_PPC is not set
 # CONFIG_SMP is not set
 # CONFIG_MATH_EMULATION is not set
+CONFIG_405GP=y
+CONFIG_BIOS_FIXUP=y
+CONFIG_IBM_OPENBIOS=y
+CONFIG_IBM405_ERR77=y
+CONFIG_IBM_OCP=y
+CONFIG_IBM405_ERR51=y
+CONFIG_NOT_COHERENT_CACHE=y
 
 #
 # General setup
@@ -294,7 +301,8 @@
 CONFIG_SERIAL_CONSOLE=y
 # CONFIG_SERIAL_EXTENDED is not set
 # CONFIG_SERIAL_NONSTANDARD is not set
-# CONFIG_UNIX98_PTYS is not set
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
 
 #
 # I2C support
@@ -398,7 +406,7 @@
 # CONFIG_DEVFS_FS is not set
 # CONFIG_DEVFS_MOUNT is not set
 # CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS is not set
+CONFIG_DEVPTS_FS=y
 # CONFIG_QNX4FS_FS is not set
 # CONFIG_QNX4FS_RW is not set
 # CONFIG_ROMFS_FS is not set
@@ -437,8 +445,18 @@
 #
 # Partition Types
 #
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
+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_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
 
@@ -460,10 +478,11 @@
 #
 # Library routines
 #
-# CONFIG_ZLIB_INFLATE is not set
-# CONFIG_ZLIB_DEFLATE is not set
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=y
 
 #
 # Kernel hacking
 #
 # CONFIG_DEBUG_KERNEL is not set
+# CONFIG_SERIAL_TEXT_DEBUG is not set
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/kernel/Makefile linux-2.4.22-pre2/arch/ppc/kernel/Makefile
--- linux-2.4.21/arch/ppc/kernel/Makefile	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/kernel/Makefile	2003-06-26 21:43:31.000000000 +0000
@@ -23,19 +23,22 @@
 # Start off with 'head.o', change as needed.
 HEAD-y				:= head.o
 HEAD-$(CONFIG_6xx)		+= idle_6xx.o
-HEAD-$(CONFIG_4xx)		:= head_4xx.o
+HEAD-$(CONFIG_40x)		:= head_4xx.o
 HEAD-$(CONFIG_8xx)		:= head_8xx.o
 
 all: $(HEAD-y) kernel.o
 
 O_TARGET := kernel.o
 
-export-objs			:= ppc_ksyms.o time.o
+export-objs			:= ppc_ksyms.o time.o ocp.o ppc4xx_setup.o
 
 obj-y				:= entry.o traps.o irq.o idle.o time.o misc.o \
 					process.o signal.o ptrace.o align.o \
 					semaphore.o syscalls.o setup.o \
 					cputable.o ppc_htab.o
+ifneq ($(CONFIG_6xx),y)
+obj-y				+= idle_gen.o
+endif
 obj-$(CONFIG_6xx)		+= l2cr.o cpu_setup_6xx.o
 obj-$(CONFIG_MODULES)		+= ppc_ksyms.o
 obj-$(CONFIG_PCI)		+= pci.o 
@@ -48,7 +51,12 @@
 obj-$(CONFIG_KGDB)		+= gen550_kgdb.o gen550_dbg.o
 obj-$(CONFIG_SERIAL_TEXT_DEBUG)	+= gen550_dbg.o
 endif
-obj-$(CONFIG_4xx)		+= ppc4xx_pic.o
+obj-$(CONFIG_4xx)		+= todc_time.o
+obj-$(CONFIG_40x)		+= ppc4xx_setup.o ocp.o
+obj-$(CONFIG_40x)		+= ppc4xx_pic.o
+ifeq ($(CONFIG_PCI),y)
+obj-$(CONFIG_40x)		+= ppc405_pci.o indirect_pci.o pci_auto.o
+endif
 obj-$(CONFIG_8xx)		+= m8xx_setup.o ppc8xx_pic.o
 ifeq ($(CONFIG_8xx),y)
 obj-$(CONFIG_PCI)		+= qspan_pci.o
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/kernel/cputable.c linux-2.4.22-pre2/arch/ppc/kernel/cputable.c
--- linux-2.4.21/arch/ppc/kernel/cputable.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/kernel/cputable.c	2003-06-26 21:43:22.000000000 +0000
@@ -324,7 +324,7 @@
 	__setup_cpu_8xx	/* Empty */
     },
 #endif /* CONFIG_8xx */
-#ifdef CONFIG_4xx
+#ifdef CONFIG_40x
     {	/* 403GC */
     	0xffffff00, 0x00200200, "403GC",
     	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB,
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/kernel/entry.S linux-2.4.22-pre2/arch/ppc/kernel/entry.S
--- linux-2.4.21/arch/ppc/kernel/entry.S	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/kernel/entry.S	2003-06-26 21:43:16.000000000 +0000
@@ -307,6 +307,9 @@
 	 */
 	mfmsr	r0		/* Get current interrupt state */
 	rlwinm	r0,r0,0,17,15	/* clear MSR_EE in r0 */
+#ifdef CONFIG_4xx
+ 	rlwinm	r0,r0,0,23,21	/* clear MSR_DE in r0 */
+#endif
 	SYNC			/* Some chip revs have problems here... */
 	mtmsr	r0		/* Update machine state */
 
@@ -323,6 +326,14 @@
 	mtspr	SPRN_VRSAVE,r0		/* if G4, restore VRSAVE reg */
 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
 #endif /* CONFIG_ALTIVEC */
+#if defined(CONFIG_4xx) && !defined(CONFIG_BDI_SWITCH)
+	/* Restore the processor debugging state of the thread.  Only do
+	 * this if we aren't using an Abatron BDI JTAG debugger.  It doesn't
+	 * tolerate others mucking with the debug registers.
+	 */
+	lwz	r0,THREAD+THREAD_DBCR0(r2)
+	mtspr	SPRN_DBCR0,r0
+#endif
 	addi	r0,r1,INT_FRAME_SIZE	/* size of frame */
 	stw	r0,THREAD+KSP(r2)	/* save kernel stack pointer */
 	tophys(r8,r1)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/kernel/gen550_dbg.c linux-2.4.22-pre2/arch/ppc/kernel/gen550_dbg.c
--- linux-2.4.21/arch/ppc/kernel/gen550_dbg.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/kernel/gen550_dbg.c	2003-06-26 21:43:12.000000000 +0000
@@ -56,6 +56,7 @@
 unsigned long serial_init(int chan, void *ignored)
 {
 	unsigned long com_port;
+	unsigned char lcr, dlm;
 
 	/* We need to find out which type io we're expecting.  If it's
 	 * 'SERIAL_IO_PORT', we get an offset from the isa_io_base.
@@ -78,22 +79,38 @@
 
 	/* How far apart the registers are. */
 	shift = rs_table[chan].iomem_reg_shift;
+
+	/* save the LCR */
+	lcr = serial_inb(com_port + (UART_LCR << shift));
 	
 	/* Access baud rate */
-	serial_outb(com_port + (UART_LCR << shift), 0x80);
+	serial_outb(com_port + (UART_LCR << shift), UART_LCR_DLAB);
+	dlm = serial_inb(com_port + (UART_DLM << shift));
 
-	/* Input clock. */
-	serial_outb(com_port + (UART_DLL << shift),
+	/*
+	 * Test if serial port is unconfigured
+	 * We assume that no-one uses less than 110 baud or
+	 * less than 7 bits per character these days.
+	 *  -- paulus.
+	 */
+	if ((dlm <= 4) && (lcr & 2)) {
+		/* port is configured, put the old LCR back */
+		serial_outb(com_port + (UART_LCR << shift), lcr);
+	}
+	else {
+		/* Input clock. */
+		serial_outb(com_port + (UART_DLL << shift),
 			(rs_table[chan].baud_base / SERIAL_BAUD) & 0xFF);
-	serial_outb(com_port + (UART_DLM << shift),
-			(rs_table[chan].baud_base / SERIAL_BAUD) >> 8);
-	/* 8 data, 1 stop, no parity */
-	serial_outb(com_port + (UART_LCR << shift), 0x03);
-	/* RTS/DTR */
-	serial_outb(com_port + (UART_MCR << shift), 0x03);
+		serial_outb(com_port + (UART_DLM << shift),
+				(rs_table[chan].baud_base / SERIAL_BAUD) >> 8);
+		/* 8 data, 1 stop, no parity */
+		serial_outb(com_port + (UART_LCR << shift), 0x03);
+		/* RTS/DTR */
+		serial_outb(com_port + (UART_MCR << shift), 0x03);
 
-	/* Clear & enable FIFOs */
-	serial_outb(com_port + (UART_FCR << shift), 0x07);
+		/* Clear & enable FIFOs */
+		serial_outb(com_port + (UART_FCR << shift), 0x07);
+	}
 
 	return (com_port);
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/kernel/head_4xx.S linux-2.4.22-pre2/arch/ppc/kernel/head_4xx.S
--- linux-2.4.21/arch/ppc/kernel/head_4xx.S	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/kernel/head_4xx.S	2003-06-26 21:43:20.000000000 +0000
@@ -11,6 +11,13 @@
  *      PowerPC 403GCX modifications.
  *    Copyright (c) 1999 Grant Erickson <grant@lcse.umn.edu>
  *      PowerPC 403GCX/405GP modifications.
+ *    Copyright 2000 MontaVista Software Inc.
+ *	PPC405 modifications
+ *      PowerPC 403GCX/405GP modifications.
+ * 	Author: MontaVista Software, Inc.
+ *         	frank_rowand@mvista.com or source@mvista.com
+ * 	   	debbie_chu@mvista.com
+ *
  *
  *    Module name: head_4xx.S
  *
@@ -25,45 +32,32 @@
  */
 
 #include <linux/config.h>
-
 #include <asm/processor.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/mmu.h>
-
+#include <asm/pgtable.h>
+#include <asm/ibm4xx.h>
+#include <asm/cputable.h>
 #include <asm/ppc_asm.h>
 #include "ppc_defs.h"
 
-
 /* Preprocessor Defines */
 
 #define	STND_EXC	0
 #define	CRIT_EXC	1
 
-###
-### Check to make sure the right processor has been defined.
-###
-
-#if !defined(CONFIG_4xx)
-#error "This file is only appropriate for kernels supporting the PPC4xx."
-#endif
-
-###
-### Execution entry point.
-###
-
-###
-### As with the other PowerPC ports, it is expected that when code
-### execution begins here, the following registers contain valid, yet
-### optional, information:
-###
-###   r3 - Board info structure pointer (DRAM, frequency, MAC address, etc.)
-###   r4 - Starting address of the init RAM disk
-###   r5 - Ending address of the init RAM disk
-###   r6 - Start of kernel command line string (e.g. "mem=96m")
-###   r7 - End of kernel command line string
-### 
-	
+/* As with the other PowerPC ports, it is expected that when code
+ * execution begins here, the following registers contain valid, yet
+ * optional, information:
+ *
+ *   r3 - Board info structure pointer (DRAM, frequency, MAC address, etc.)
+ *   r4 - Starting address of the init RAM disk
+ *   r5 - Ending address of the init RAM disk
+ *   r6 - Start of kernel command line string (e.g. "mem=96m")
+ *   r7 - End of kernel command line string
+ *
+ * This is all going to change RSN when we add bi_recs.......  -- Dan
+ */ 
 	.text
 _GLOBAL(_stext)
 _GLOBAL(_start)
@@ -75,98 +69,72 @@
 	nop
 	nop
 
-	## Save residual data, init RAM disk, and command line parameters
-	
+	/* Save parameters we are passed.
+	*/
 	mr	r31,r3
 	mr	r30,r4
 	mr	r29,r5
 	mr	r28,r6
 	mr	r27,r7
+	li	r24,0		/* CPU number */
 
-	## Set the ID for this CPU
-
-	li	r24,0
-
-	## Invalidate all TLB entries
-
-	tlbia
-	
-	## We should still be executing code at physical address 0x0000xxxx
-	## at this point. However, start_here is at virtual address
-	## 0xC000xxxx. So, set up a TLB mapping to cover this once
-	## translation is enabled.
-
-	lis	r3,KERNELBASE@h		# Load the kernel virtual address
-	ori	r3,r3,KERNELBASE@l
-	tophys(r4,r3)			# Load the kernel physical address
-
-	## Save the existing PID and load the kernel PID.
-		
-	mfspr	r7,SPRN_PID		# Save the old PID
-	li	r0,0
-	mtspr	SPRN_PID,r0		# Load the kernel PID
-
-	## Configure and load entry into TLB slot 0.
-	
-	clrrwi	r4,r4,10		# Mask off the real page number
-	ori	r4,r4,(TLB_WR | TLB_EX)	# Set the write and execute bits
-	
-	clrrwi	r3,r3,10		# Mask off the effective page number
-	ori	r3,r3,(TLB_VALID | TLB_PAGESZ(PAGESZ_16M))
-
-	tlbwe	r4,r0,TLB_DATA		# Load the data portion of the entry
-	tlbwe	r3,r0,TLB_TAG		# Load the tag portion of the entry
-	isync
-	
-	mtspr	SPRN_PID,r7		# Restore the existing PID
-	
-	## Establish the exception vector base
-	
-	lis	r4,KERNELBASE@h		# EVPR only uses the high 16-bits
-	tophys(r0,r4)			# Use the physical address
-	mtspr	SPRN_EVPR,r0
+	/* We have to turn on the MMU right away so we get cache modes
+	 * set correctly.
+	 */
+	bl	initial_mmu
 
-	## Enable the MMU and jump to the main PowerPC kernel start-up code
+/* We now have the lower 16 Meg mapped into TLB entries, and the caches
+ * ready to work.
+ */
+turn_on_mmu:
+	li	r0,MSR_KERNEL
+	mtspr	SRR1,r0
+	lis	r0,start_here@h
+	ori	r0,r0,start_here@l
+	mtspr	SRR0,r0
+	SYNC
+	rfi				/* enables MMU */
+	b	.			/* prevent prefetch past rfi */
 
-	mfmsr	r0			# Get the machine state register
-	ori	r0,r0,(MSR_DR | MSR_IR)	# Enable data and instr. translation
-	mtspr	SPRN_SRR1,r0		# Set up the new machine state register
-	lis	r0,start_here@h		
-	ori	r0,r0,start_here@l	
-	mtspr	SPRN_SRR0,r0		# Set up the new instruction pointer
-	rfi				# Jump to start_here w/ translation on
-
-
-###
-### Exception vector entry code. This code runs with address translation
-### turned off (i.e. using physical addresses). We assume SPRG3 has the
-### physical address of the current task thread_struct.
-### 
+#ifdef CONFIG_405LP
+	/* Reserve space for ibm405lp_wakeup_info.  This contains the physical
+	 * address of a struct ibm405lp_wakeup_info which is used by the
+	 * firmware to pass control back to the kernel on cryo wakeup.  Because
+	 * the firmware uses this, the absolute address is fixed: don't try
+	 * changing it. */
+	. = 0xfc
+	.global ibm405lp_wakeup_info
+ibm405lp_wakeup_info:
+	.long	0x0
+#endif
 
-	## Common exception code for all exception types.
+/* Exception vector entry code. This code runs with address translation
+ * turned off (i.e. using physical addresses). We assume SPRG3 has the
+ * physical address of the current task thread_struct.
+ */ 
 
 #define COMMON_PROLOG							     \
-0:	mtspr	SPRN_SPRG0,r20;		/* We need r20, move it to SPRG0   */\
-	mtspr	SPRN_SPRG1,r21;		/* We need r21, move it to SPRG1   */\
-	mfcr	r20;			/* We need the CR, move it to r20  */\
-	mfspr	r21,SPRN_SPRG2;		/* Exception stack to use	   */\
-	cmpwi	cr0,r21,0;		/* From user mode or RTAS?	   */\
-	bne	1f;			/* Not RTAS, branch		   */\
-	tophys(r21, r1);		/* Convert vka in r1 to pka in r21 */\
-	subi	r21,r21,INT_FRAME_SIZE;	/* Allocate an exception frame	   */\
-1:	stw	r20,_CCR(r21);		/* Save CR on the stack		   */\
-	stw	r22,GPR22(r21);		/* Save r22 on the stack	   */\
-	stw	r23,GPR23(r21);		/* r23 Save on the stack	   */\
-	mfspr	r20,SPRN_SPRG0;		/* Get r20 back out of SPRG0	   */\
-	stw	r20,GPR20(r21);		/* Save r20 on the stack	   */\
-	mfspr	r22,SPRN_SPRG1;		/* Get r21 back out of SPRG0	   */\
-	stw	r22,GPR21(r21);		/* Save r21 on the stack	   */\
-	mflr	r20;							     \
-	stw	r20,_LINK(r21);		/* Save LR on the stack		   */\
-	mfctr	r22;							     \
-	stw	r22,_CTR(r21);		/* Save CTR on the stack	   */\
-	mfspr	r20,XER;						     \
-	stw	r20,_XER(r21);		/* Save XER on the stack	   */
+0:	mtspr	SPRN_SPRG0,r20;         /* We need r20, move it to SPRG0   */\
+	mtspr	SPRN_SPRG1,r21;         /* We need r21, move it to SPRG1   */\
+	mfcr	r20;                    /* We need the CR, move it to r20  */\
+	mfspr	r21,SPRN_SPRG2;         /* Exception stack to use          */\
+	cmpwi	cr0,r21,0;              /* From user mode or RTAS?         */\
+	bne	1f;                     /* Not RTAS, branch                */\
+	tophys(r21, r1);                /* Convert vka in r1 to pka in r21 */\
+	subi	r21,r21,INT_FRAME_SIZE; /* Allocate an exception frame     */\
+1:	stw	r20,_CCR(r21);          /* Save CR on the stack            */\
+	stw	r22,GPR22(r21);         /* Save r22 on the stack           */\
+	stw	r23,GPR23(r21);         /* r23 Save on the stack           */\
+	mfspr	r20,SPRN_SPRG0;         /* Get r20 back out of SPRG0       */\
+	stw	r20,GPR20(r21);         /* Save r20 on the stack           */\
+	mfspr	r22,SPRN_SPRG1;         /* Get r21 back out of SPRG0       */\
+	stw	r22,GPR21(r21);         /* Save r21 on the stack           */\
+	mflr	r20;                                                         \
+	stw	r20,_LINK(r21);         /* Save LR on the stack            */\
+	mfctr	r22;                                                         \
+	stw	r22,_CTR(r21);          /* Save CTR on the stack           */\
+	mfspr	r20,XER;                                                     \
+	stw	r20,_XER(r21);          /* Save XER on the stack           */
 
 #define	COMMON_EPILOG							     \
 	stw	r0,GPR0(r21);		/* Save r0 on the stack		   */\
@@ -177,25 +145,22 @@
 	SAVE_4GPRS(3, r21);		/* Save r3 through r6 on the stack */\
 	SAVE_GPR(7, r21);		/* Save r7 on the stack		   */
 
-	## Common exception code for standard (non-critical) exceptions.
-
 #define	STND_EXCEPTION_PROLOG						     \
 	COMMON_PROLOG;							     \
 	mfspr	r22,SPRN_SRR0;		/* Faulting instruction address	   */\
+	lis	r20,MSR_WE@h;						     \
 	mfspr	r23,SPRN_SRR1;		/* MSR at the time of fault	   */\
+	andc	r23,r23,r20;		/* disable processor wait state    */\
 	COMMON_EPILOG;
 
-	## Common exception code for critical exceptions.
-	
 #define	CRIT_EXCEPTION_PROLOG						     \
 	COMMON_PROLOG;							     \
 	mfspr	r22,SPRN_SRR2;		/* Faulting instruction address	   */\
+	lis	r20,MSR_WE@h;						     \
 	mfspr	r23,SPRN_SRR3;		/* MSR at the time of fault	   */\
+	andc	r23,r23,r20;		/* disable processor wait state    */\
 	COMMON_EPILOG;
 
-###
-### Macros for specific exception types
-### 
 
 #define	START_EXCEPTION(n, label)					     \
 	. = n;								     \
@@ -206,8 +171,8 @@
 	bl	transfer_to_handler;					     \
 	.long	func;							     \
 	.long	ret_from_except
-	
-		
+
+
 #define STND_EXCEPTION(n, label, func)					     \
 	START_EXCEPTION(n, label);					     \
 	STND_EXCEPTION_PROLOG;						     \
@@ -216,7 +181,7 @@
 	li	r20,MSR_KERNEL;						     \
 	FINISH_EXCEPTION(func)
 
-	
+
 #define	CRIT_EXCEPTION(n, label, func)					     \
 	START_EXCEPTION(n, label);					     \
 	CRIT_EXCEPTION_PROLOG;						     \
@@ -225,47 +190,191 @@
 	li	r20,MSR_KERNEL;						     \
 	FINISH_EXCEPTION(func)
 
-	
-###
-### Exception vectors.
-### 
-	
-### 0x0100 - Critical Interrupt Exception
 
+/* Exception vectors.
+*/ 
+
+/* 0x0100 - Critical Interrupt Exception
+*/
 	CRIT_EXCEPTION(0x0100,	CriticalInterrupt,	UnknownException)
 
-### 0x0200 - Machine Check Exception
-	
-	CRIT_EXCEPTION(0x0200,	MachineCheck,		MachineCheckException)
+/* 0x0200 - Machine Check Exception
+*/
+	START_EXCEPTION(0x0200, MachineCheck)
+	CRIT_EXCEPTION_PROLOG
+
+	/*
+	lis	r4,0x0400
+	mtdcr	DCRN_POB0_BESR0,r4
+	*/
+#ifdef DCRN_POB0_BEAR
+	mfdcr	r4,DCRN_POB0_BEAR
+	mfdcr	r4,DCRN_POB0_BESR0
+	mfdcr	r4,DCRN_POB0_BESR1
+#endif
 
-### 0x0300 - Data Storage Exception
+#ifdef DCRN_PLB0_BEAR
+	mfdcr	r4,DCRN_PLB0_ACR
+	mfdcr	r4,DCRN_PLB0_BEAR
+	mfdcr	r4,DCRN_PLB0_BESR
+#endif
 
-	START_EXCEPTION(0x0300,	DataAccess)
-	STND_EXCEPTION_PROLOG
-	mfspr	r5,SPRN_ESR		# Grab the ESR, save it, pass as arg3
-	stw	r5,_ESR(r21)
-	mfspr	r4,SPRN_DEAR		# Grab the DEAR, save it, pass as arg2
-	stw	r4,_DEAR(r21)
 	addi	r3,r1,STACK_FRAME_OVERHEAD
-	li	r7,STND_EXC		# This is a standard exception
+	li	r7,CRIT_EXC
 	li	r20,MSR_KERNEL
-	rlwimi	r20,r23,0,16,16		# Copy EE bit from the saved MSR
-	FINISH_EXCEPTION(do_page_fault)	# do_page_fault(regs, ESR, DEAR)
-	
-### 0x0400 - Instruction Storage Exception
+	FINISH_EXCEPTION(MachineCheckException)
+
+/* 0x0300 - Data Storage Exception
+ * This happens for just a few reasons.  U0 set (but we don't do that),
+ * or zone protection fault (user violation, write to protected page).
+ * If this is just an update of modified status, we do that quickly
+ * and exit.  Otherwise, we call heavywight functions to do the work.
+ */
+	START_EXCEPTION(0x0300,	DataStore)
+	mtspr	SPRG0, r20		/* Save some working registers */
+	mtspr	SPRG1, r21
+#ifdef CONFIG_403GCX
+	stw     r22, 0(r0)
+	stw     r23, 4(r0)
+	mfcr    r21
+	mfspr   r22, SPRN_PID
+	stw     r21, 8(r0)
+	stw     r22, 12(r0)
+#else
+	mtspr	SPRG4, r22
+	mtspr	SPRG5, r23
+	mfcr	r21
+	mfspr	r22, SPRN_PID
+	mtspr	SPRG7, r21
+	mtspr	SPRG6, r22
+#endif
+
+	/* First, check if it was a zone fault (which means a user
+	* tried to access a kernel or read-protected page - always
+	* a SEGV).  All other faults here must be stores, so no
+	* need to check ESR_DST as well. */
+	mfspr	r20, SPRN_ESR
+	andis.	r20, r20, ESR_DIZ@h
+	bne	2f
+
+	mfspr	r20, SPRN_DEAR		/* Get faulting address */
+
+	/* If we are faulting a kernel address, we have to use the
+	 * kernel page tables.
+	 */
+	andis.	r21, r20, 0x8000
+	beq	3f
+	lis	r21, swapper_pg_dir@h
+	ori	r21, r21, swapper_pg_dir@l
+	li	r23, 0
+	mtspr	SPRN_PID, r23		/* TLB will have 0 TID */
+	b	4f
+
+	/* Get the PGD for the current thread.
+	 */
+3:
+	mfspr	r21,SPRG3
+	lwz	r21,PGDIR(r21)
+4:
+	tophys(r21, r21)
+	rlwimi	r21, r20, 12, 20, 29	/* Create L1 (pgdir/pmd) address */
+	lwz	r21, 0(r21)		/* Get L1 entry */
+	rlwinm.	r22, r21, 0, 0, 19	/* Extract L2 (pte) base address */
+	beq	2f			/* Bail if no table */
+
+	tophys(r22, r22)
+	rlwimi	r22, r20, 22, 20, 29	/* Compute PTE address */
+	lwz	r21, 0(r22)		/* Get Linux PTE */
+
+	andi.	r23, r21, _PAGE_RW	/* Is it writeable? */
+	beq	2f			/* Bail if not */
+
+	/* Update 'changed'.
+	*/
+	ori	r21, r21, _PAGE_DIRTY|_PAGE_ACCESSED|_PAGE_HWWRITE
+	stw	r21, 0(r22)		/* Update Linux page table */
+
+	/* Most of the Linux PTE is ready to load into the TLB LO.
+	 * We set ZSEL, where only the LS-bit determines user access.
+	 * We set execute, because we don't have the granularity to
+	 * properly set this at the page level (Linux problem).
+	 * If shared is set, we cause a zero PID->TID load.
+	 * Many of these bits are software only.  Bits we don't set
+	 * here we (properly should) assume have the appropriate value.
+	 */
+	li	r22, 0x0ce2
+	andc	r21, r21, r22		/* Make sure 20, 21 are zero */
 
+	/* find the TLB index that caused the fault.  It has to be here.
+	*/
+	tlbsx	r23, 0, r20
+
+	tlbwe	r21, r23, TLB_DATA		/* Load TLB LO */
+
+	/* Done...restore registers and get out of here.
+	*/
+#ifdef CONFIG_403GCX
+	lwz     r22, 12(r0)
+	lwz     r21, 8(r0)
+	mtspr   SPRN_PID, r22
+	mtcr    r21
+	lwz     r23, 4(r0)
+	lwz     r22, 0(r0)
+#else
+	mfspr	r22, SPRG6
+	mfspr	r21, SPRG7
+	mtspr	SPRN_PID, r22
+	mtcr	r21
+	mfspr	r23, SPRG5
+	mfspr	r22, SPRG4
+#endif
+	mfspr	r21, SPRG1
+	mfspr	r20, SPRG0
+	PPC405_ERR77_SYNC
+	rfi			/* Should sync shadow TLBs */
+	b	.		/* prevent prefetch past rfi */
+
+2:
+	/* The bailout.  Restore registers to pre-exception conditions
+	 * and call the heavyweights to help us out.
+	 */
+#ifdef CONFIG_403GCX
+	lwz     r22, 12(r0)
+	lwz     r21, 8(r0)
+	mtspr   SPRN_PID, r22
+	mtcr    r21
+	lwz     r23, 4(r0)
+	lwz     r22, 0(r0)
+#else
+	mfspr	r22, SPRG6
+	mfspr	r21, SPRG7
+	mtspr	SPRN_PID, r22
+	mtcr	r21
+	mfspr	r23, SPRG5
+	mfspr	r22, SPRG4
+#endif
+	mfspr	r21, SPRG1
+	mfspr	r20, SPRG0
+	b	DataAccess
+
+/* 0x0400 - Instruction Storage Exception
+ * I don't know why it is called "Storage"....This is caused by a fetch
+ * from non-execute or guarded pages.
+ */
 	START_EXCEPTION(0x0400, InstructionAccess)
 	STND_EXCEPTION_PROLOG
-	mr	r4,r22			# Pass SRR0 as arg2
-	mr	r5,r23			# Pass SRR1 as arg3
+	mfspr	r5,SPRN_ESR		/* Grab the ESR, save it, not really needed */
+	stw	r5,_ESR(r21)
+	mr	r4,r22			/* Pass SRR0 as arg2 */
+	li	r5,0			/* Pass zero as arg3 */
 	addi	r3,r1,STACK_FRAME_OVERHEAD
-	li	r7,STND_EXC		# This is a standard exception
+	li	r7,STND_EXC
 	li	r20,MSR_KERNEL
-	rlwimi	r20,r23,0,16,16		# Copy EE bit from the saved MSR
-	FINISH_EXCEPTION(do_page_fault)	# do_page_fault(regs, SRR0, SRR1)
-	
-### 0x0500 - External Interrupt Exception
+	rlwimi	r20,r23,0,16,16		/* Copy EE bit from the saved MSR */
+	FINISH_EXCEPTION(do_page_fault)	/* do_page_fault(regs, SRR0, SRR1) */
 
+/* 0x0500 - External Interrupt Exception
+*/
 	START_EXCEPTION(0x0500, HardwareInterrupt)
 	STND_EXCEPTION_PROLOG
 	addi	r3,r1,STACK_FRAME_OVERHEAD
@@ -277,54 +386,72 @@
 	.long	do_IRQ
 	.long	ret_from_intercept
 
-### 0x0600 - Alignment Exception
-	
+/* 0x0600 - Alignment Exception
+*/
 	START_EXCEPTION(0x0600, Alignment)
 	STND_EXCEPTION_PROLOG
-	mfspr	r4,SPRN_DEAR		# Grab the DEAR and save it
+	mfspr	r4,SPRN_DEAR		/* Grab the DEAR and save it */
 	stw	r4,_DEAR(r21)
 	addi	r3,r1,STACK_FRAME_OVERHEAD
-	li	r7,STND_EXC		# This is a standard exception
+	li	r7,STND_EXC
 	li	r20,MSR_KERNEL
-	rlwimi	r20,r23,0,16,16		# Copy EE bit from the saved MSR
+	rlwimi	r20,r23,0,16,16		/* Copy EE bit from the saved MSR */
 	FINISH_EXCEPTION(AlignmentException)
 
-### 0x0700 - Program Exception
-
+/* 0x0700 - Program Exception
+*/
 	START_EXCEPTION(0x0700,	ProgramCheck)
 	STND_EXCEPTION_PROLOG
+	mfspr	r4,SPRN_ESR		/* Grab the ESR, save it */
+	stw	r4,_ESR(r21)
 	addi	r3,r1,STACK_FRAME_OVERHEAD
-	li	r7,STND_EXC		# This is a standard exception
+	li	r7,STND_EXC
 	li	r20,MSR_KERNEL
-	rlwimi	r20,r23,0,16,16		# Copy EE bit from the saved MSR
+	rlwimi	r20,r23,0,16,16		/* Copy EE bit from the saved MSR */
 	FINISH_EXCEPTION(ProgramCheckException)
-	
-	STND_EXCEPTION(0x0800,	Trap_08,		UnknownException)
+
+
+/* I'm stealing this unused vector location to build a standard exception
+ * frame for Data TLB Access errors.  The other Data TLB exceptions will bail
+ * out to this point if they can't resolve the lightweight TLB fault.
+ */
+	START_EXCEPTION(0x0800,	DataAccess)
+	STND_EXCEPTION_PROLOG
+	mfspr	r5,SPRN_ESR		/* Grab the ESR, save it, pass arg3 */
+	stw	r5,_ESR(r21)
+	mfspr	r4,SPRN_DEAR		/* Grab the DEAR, save it, pass arg2 */
+	stw	r4,_DEAR(r21)
+	addi	r3,r1,STACK_FRAME_OVERHEAD
+	li	r7,STND_EXC
+	li	r20,MSR_KERNEL
+	rlwimi	r20,r23,0,16,16		/* Copy EE bit from the saved MSR */
+	FINISH_EXCEPTION(do_page_fault)	/* do_page_fault(regs, ESR, DEAR) */
+
 	STND_EXCEPTION(0x0900,	Trap_09,		UnknownException)
 	STND_EXCEPTION(0x0A00,	Trap_0A,		UnknownException)
-	STND_EXCEPTION(0x0B00,	Trap_0B,		UnknownException)		
-### 0x0C00 - System Call Exception
-
+	STND_EXCEPTION(0x0B00,	Trap_0B,		UnknownException)
+/* 0x0C00 - System Call Exception
+*/
 	START_EXCEPTION(0x0C00,	SystemCall)
 	STND_EXCEPTION_PROLOG
 	stw	r3,ORIG_GPR3(r21)
-	li	r7,STND_EXC		# This is a standard exception
+	li	r7,STND_EXC
 	li	r20,MSR_KERNEL
-	rlwimi	r20,r23,0,16,16		# Copy EE bit from the saved MSR
+	rlwimi	r20,r23,0,16,16		/* Copy EE bit from the saved MSR */
 	FINISH_EXCEPTION(DoSyscall)
 
 	STND_EXCEPTION(0x0D00,	Trap_0D,		UnknownException)
 	STND_EXCEPTION(0x0E00,	Trap_0E,		UnknownException)
 	STND_EXCEPTION(0x0F00,	Trap_0F,		UnknownException)
 
-### 0x1000 - Programmable Interval Timer (PIT) Exception
-
+/* 0x1000 - Programmable Interval Timer (PIT) Exception
+*/
 	START_EXCEPTION(0x1000,	Decrementer)
 	STND_EXCEPTION_PROLOG
-	lis	r0,TSR_PIS@h		# Set-up the PIT exception mask
-	mtspr	SPRN_TSR,r0		# Clear the PIT exception
+	lis	r0,TSR_PIS@h		/* Set-up the PIT exception mask */
+	mtspr	SPRN_TSR,r0		/* Clear the PIT exception */
 	addi	r3,r1,STACK_FRAME_OVERHEAD
-	li	r7,STND_EXC		# This is a standard exception
+	li	r7,STND_EXC
 	li	r20,MSR_KERNEL
 	bl	transfer_to_handler
 _GLOBAL(timer_interrupt_intercept)
@@ -332,28 +459,217 @@
 	.long	ret_from_intercept
 
 #if 0
-### 0x1010 - Fixed Interval Timer (FIT) Exception
-	
+/* NOTE:
+ * FIT and WDT handlers are not implemented yet.
+ */
+
+/* 0x1010 - Fixed Interval Timer (FIT) Exception
+*/
 	STND_EXCEPTION(0x1010,	FITException,		UnknownException)
 
-### 0x1020 - Watchdog Timer (WDT) Exception
+/* 0x1020 - Watchdog Timer (WDT) Exception
+*/
 
 	CRIT_EXCEPTION(0x1020,	WDTException,		UnknownException)
 #endif
 
-### 0x1100 - Data TLB Miss Exception
+/* 0x1100 - Data TLB Miss Exception
+ * As the name implies, translation is not in the MMU, so search the
+ * page tables and fix it.  The only purpose of this function is to
+ * load TLB entries from the page table if they exist.
+ */
+	START_EXCEPTION(0x1100,	DTLBMiss)
+	mtspr	SPRG0, r20		/* Save some working registers */
+	mtspr	SPRG1, r21
+#ifdef CONFIG_403GCX
+	stw     r22, 0(r0)
+	stw     r23, 4(r0)
+	mfcr    r21
+	mfspr   r22, SPRN_PID
+	stw     r21, 8(r0)
+	stw     r22, 12(r0)
+#else
+	mtspr	SPRG4, r22
+	mtspr	SPRG5, r23
+	mfcr	r21
+	mfspr	r22, SPRN_PID
+	mtspr	SPRG7, r21
+	mtspr	SPRG6, r22
+#endif
+	mfspr	r20, SPRN_DEAR		/* Get faulting address */
+
+	/* If we are faulting a kernel address, we have to use the
+	 * kernel page tables.
+	 */
+	andis.	r21, r20, 0x8000
+	beq	3f
+	lis	r21, swapper_pg_dir@h
+	ori	r21, r21, swapper_pg_dir@l
+	li	r23, 0
+	mtspr	SPRN_PID, r23		/* TLB will have 0 TID */
+	b	4f
+
+	/* Get the PGD for the current thread.
+	 */
+3:
+	mfspr	r21,SPRG3
+	lwz	r21,PGDIR(r21)
+4:
+	tophys(r21, r21)
+	rlwimi	r21, r20, 12, 20, 29	/* Create L1 (pgdir/pmd) address */
+	lwz	r21, 0(r21)		/* Get L1 entry */
+	rlwinm.	r22, r21, 0, 0, 19	/* Extract L2 (pte) base address */
+	beq	2f			/* Bail if no table */
+
+	tophys(r22, r22)
+	rlwimi	r22, r20, 22, 20, 29	/* Compute PTE address */
+	lwz	r21, 0(r22)		/* Get Linux PTE */
+	andi.	r23, r21, _PAGE_PRESENT
+	beq	2f
+
+	ori	r21, r21, _PAGE_ACCESSED
+	stw	r21, 0(r22)
+
+	/* Most of the Linux PTE is ready to load into the TLB LO.
+	 * We set ZSEL, where only the LS-bit determines user access.
+	 * We set execute, because we don't have the granularity to
+	 * properly set this at the page level (Linux problem).
+	 * If shared is set, we cause a zero PID->TID load.
+	 * Many of these bits are software only.  Bits we don't set
+	 * here we (properly should) assume have the appropriate value.
+	 */
+	li	r22, 0x0ce2
+	andc	r21, r21, r22		/* Make sure 20, 21 are zero */
+
+	b	finish_tlb_load
+
+
+2:
+	/* The bailout.  Restore registers to pre-exception conditions
+	 * and call the heavyweights to help us out.
+	 */
+#ifdef CONFIG_403GCX
+	lwz     r22, 12(r0)
+	lwz     r21, 8(r0)
+	mtspr   SPRN_PID, r22
+	mtcr    r21
+	lwz     r23, 4(r0)
+	lwz     r22, 0(r0)
+#else
+	mfspr	r22, SPRG6
+	mfspr	r21, SPRG7
+	mtspr	SPRN_PID, r22
+	mtcr	r21
+	mfspr	r23, SPRG5
+	mfspr	r22, SPRG4
+#endif
+	mfspr	r21, SPRG1
+	mfspr	r20, SPRG0
+	b	DataAccess
+
+/* 0x1200 - Instruction TLB Miss Exception
+ * Nearly the same as above, except we get our information from different
+ * registers and bailout to a different point.
+ */
+	START_EXCEPTION(0x1200,	ITLBMiss)
+	mtspr	SPRG0, r20		/* Save some working registers */
+	mtspr	SPRG1, r21
+#ifdef CONFIG_403GCX
+	stw     r22, 0(r0)
+	stw     r23, 4(r0)
+	mfcr    r21
+	mfspr   r22, SPRN_PID
+	stw     r21, 8(r0)
+	stw     r22, 12(r0)
+#else
+	mtspr	SPRG4, r22
+	mtspr	SPRG5, r23
+	mfcr	r21
+	mfspr	r22, SPRN_PID
+	mtspr	SPRG7, r21
+	mtspr	SPRG6, r22
+#endif
+	mfspr	r20, SRR0		/* Get faulting address */
+
+	/* If we are faulting a kernel address, we have to use the
+	 * kernel page tables.
+	 */
+	andis.	r21, r20, 0x8000
+	beq	3f
+	lis	r21, swapper_pg_dir@h
+	ori	r21, r21, swapper_pg_dir@l
+	li	r23, 0
+	mtspr	SPRN_PID, r23		/* TLB will have 0 TID */
+	b	4f
+
+	/* Get the PGD for the current thread.
+	 */
+3:
+	mfspr	r21,SPRG3
+	lwz	r21,PGDIR(r21)
+4:
+	tophys(r21, r21)
+	rlwimi	r21, r20, 12, 20, 29	/* Create L1 (pgdir/pmd) address */
+	lwz	r21, 0(r21)		/* Get L1 entry */
+	rlwinm.	r22, r21, 0, 0, 19	/* Extract L2 (pte) base address */
+	beq	2f			/* Bail if no table */
+
+	tophys(r22, r22)
+	rlwimi	r22, r20, 22, 20, 29	/* Compute PTE address */
+	lwz	r21, 0(r22)		/* Get Linux PTE */
+	andi.	r23, r21, _PAGE_PRESENT
+	beq	2f
+
+	ori	r21, r21, _PAGE_ACCESSED
+	stw	r21, 0(r22)
 
-	STND_EXCEPTION(0x1100,	DTLBMiss, 		PPC4xx_dtlb_miss)
+	/* Most of the Linux PTE is ready to load into the TLB LO.
+	 * We set ZSEL, where only the LS-bit determines user access.
+	 * We set execute, because we don't have the granularity to
+	 * properly set this at the page level (Linux problem).
+	 * If shared is set, we cause a zero PID->TID load.
+	 * Many of these bits are software only.  Bits we don't set
+	 * here we (properly should) assume have the appropriate value.
+	 */
+	li	r22, 0x0ce2
+	andc	r21, r21, r22		/* Make sure 20, 21 are zero */
 
-### 0x1200 - Instruction TLB Miss Exception
+	b	finish_tlb_load
 
-	STND_EXCEPTION(0x1200,	ITLBMiss, 		PPC4xx_itlb_miss)
+2:
+	/* The bailout.  Restore registers to pre-exception conditions
+	 * and call the heavyweights to help us out.
+	 */
+#ifdef CONFIG_403GCX
+	lwz     r22, 12(r0)
+	lwz     r21, 8(r0)
+	mtspr   SPRN_PID, r22
+	mtcr    r21
+	lwz     r23, 4(r0)
+	lwz     r22, 0(r0)
+#else
+	mfspr	r22, SPRG6
+	mfspr	r21, SPRG7
+	mtspr	SPRN_PID, r22
+	mtcr	r21
+	mfspr	r23, SPRG5
+	mfspr	r22, SPRG4
+#endif
+	mfspr	r21, SPRG1
+	mfspr	r20, SPRG0
+	b	InstructionAccess
 
 	STND_EXCEPTION(0x1300,	Trap_13,		UnknownException)
 	STND_EXCEPTION(0x1400,	Trap_14,		UnknownException)
 	STND_EXCEPTION(0x1500,	Trap_15,		UnknownException)
 	STND_EXCEPTION(0x1600,	Trap_16,		UnknownException)
+#ifdef CONFIG_IBM405_ERR51
+	/* 405GP errata 51 */
+	START_EXCEPTION(0x1700, Trap_17)
+	b DTLBMiss
+#else
 	STND_EXCEPTION(0x1700,	Trap_17,		UnknownException)
+#endif
 	STND_EXCEPTION(0x1800,	Trap_18,		UnknownException)
 	STND_EXCEPTION(0x1900,	Trap_19,		UnknownException)
 	STND_EXCEPTION(0x1A00,	Trap_1A,		UnknownException)
@@ -362,73 +678,214 @@
 	STND_EXCEPTION(0x1D00,	Trap_1D,		UnknownException)
 	STND_EXCEPTION(0x1E00,	Trap_1E,		UnknownException)
 	STND_EXCEPTION(0x1F00,	Trap_1F,		UnknownException)
-	
-### 0x2000 - Debug Exception
 
-	CRIT_EXCEPTION(0x2000,	DebugTrap,		UnknownException)
+/* 0x2000 - Debug Exception
+*/
+	START_EXCEPTION(0x2000, DebugTrap)
+	b	check_single_step_in_exception
+ret_to_debug_exception:
+	CRIT_EXCEPTION_PROLOG
+	addi	r3,r1,STACK_FRAME_OVERHEAD
+	li	r7,CRIT_EXC;
+        li      r20,MSR_KERNEL
+	FINISH_EXCEPTION(DebugException)
+
+/* Make sure the final interrupt handler has not spilled past the
+ * end of its allotted space.
+ */
+        .=0x2100
+
+/* 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 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 handlers_ MSR (the debug trap is
+ * a critical exception, so we are using SPRN_SRR3 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.
+ */
+check_single_step_in_exception:
+
+	/* This first instruction was already executed by the exception
+	 * handler and must be the first instruction of every exception
+	 * handler.
+	 */
+	mtspr	SPRN_SPRG0,r20		/* Save some working registers... */
+	mtspr	SPRN_SPRG1,r21
+	mfcr	r20			/* ..and the cr because we change it */
+
+	mfspr   r21,SPRN_SRR3		/* MSR at the time of fault */
+	andi.   r21,r21,MSR_PR
+	bne+    2f			/* trapped from problem state */
+
+	mfspr   r21,SPRN_SRR2		/* Faulting instruction address */
+	cmplwi  r21,0x2100
+	bgt+    2f			/* address above exception vectors */
+
+	lis     r21,DBSR_IC@h           /* Remove the trap status */
+	mtspr   SPRN_DBSR,r21
+
+	mfspr	r21,SPRN_SRR3
+	rlwinm	r21,r21,0,23,21		/* clear MSR_DE */
+	mtspr	SPRN_SRR3, r21		/* restore MSR at rcfi without DE */
+
+	mtcrf   0xff,r20                /* restore registers */
+	mfspr   r21,SPRN_SPRG1
+	mfspr   r20,SPRN_SPRG0
+
+	sync
+	rfci                            /* return to the exception handler  */
+	b	.			/* prevent prefetch past rfci */
+
+2:
+	mtcrf   0xff,r20                /* restore registers */
+	mfspr   r21,SPRN_SPRG1
+	mfspr   r20,SPRN_SPRG0
+	b       ret_to_debug_exception
+
+/* Other PowerPC processors, namely those derived from the 6xx-series
+ * have vectors from 0x2100 through 0x2F00 defined, but marked as reserved.
+ * However, for the 4xx-series processors these are neither defined nor
+ * reserved.
+ */ 
+
+	/* Damn, I came up one instruction too many to fit into the
+	 * exception space :-).  Both the instruction and data TLB
+	 * miss get to this point to load the TLB.
+	 * 	r20 - EA of fault
+	 * 	r21 - TLB LO (info from Linux PTE)
+	 *	r22, r23 - avilable to use
+	 *	PID - loaded with proper value when we get here
+	 *	Upon exit, we reload everything and RFI.
+	 * Actually, it will fit now, but oh well.....a common place
+	 * to load the TLB.
+	 */
+tlb_4xx_index:
+	.long	0
+finish_tlb_load:
+	/* load the next available TLB index.
+	*/
+	lwz	r23, tlb_4xx_index@l(0)
+	addi	r23, r23, 1
+#ifdef CONFIG_PIN_TLB
+	cmpwi	0, r23, 61		/* reserve entries 62, 63 for kernel */
+	ble	7f
+	li	r23, 0
+7:
+#else
+	andi.	r23, r23, (PPC4XX_TLB_SIZE-1)
+#endif
+	stw	r23, tlb_4xx_index@l(0)
 
-###
-### Other PowerPC processors, namely those derived from the 6xx-series
-### have vectors from 0x2100 through 0x2F00 defined, but marked as reserved.
-### However, for the 4xx-series processors these are neither defined nor
-### reserved.
-### 
-
-### 
-### This code finishes saving the registers to the exception frame
-### and jumps to the appropriate handler for the exception, turning
-### on address translation.
-###
+6:
+	tlbwe	r21, r23, TLB_DATA		/* Load TLB LO */
 
+	/* Create EPN.  This is the faulting address plus a static
+	 * set of bits.  These are size, valid, E, U0, and ensure
+	 * bits 20 and 21 are zero.
+	 */
+	li	r22, 0x00c0
+	rlwimi	r20, r22, 0, 20, 31
+	tlbwe	r20, r23, TLB_TAG		/* Load TLB HI */
+
+	/* Done...restore registers and get out of here.
+	*/
+#ifdef CONFIG_403GCX
+	lwz     r22, 12(r0)
+	lwz     r21, 8(r0)
+	mtspr   SPRN_PID, r22
+	mtcr    r21
+	lwz     r23, 4(r0)
+	lwz     r22, 0(r0)
+#else
+	mfspr	r22, SPRG6
+	mfspr	r21, SPRG7
+	mtspr	SPRN_PID, r22
+	mtcr	r21
+	mfspr	r23, SPRG5
+	mfspr	r22, SPRG4
+#endif
+	mfspr	r21, SPRG1
+	mfspr	r20, SPRG0
+	PPC405_ERR77_SYNC
+	rfi			/* Should sync shadow TLBs */
+	b	.		/* prevent prefetch past rfi */
+
+/* This code finishes saving the registers to the exception frame
+ * and jumps to the appropriate handler for the exception, turning
+ * on address translation.
+ */
 _GLOBAL(transfer_to_handler)
-	stw	r22,_NIP(r21)		# Save the faulting IP on the stack
-	stw	r23,_MSR(r21)		# Save the exception MSR on the stack
-	SAVE_4GPRS(8, r21)		# Save r8 through r11 on the stack
-	SAVE_8GPRS(12, r21)		# Save r12 through r19 on the stack
-	SAVE_8GPRS(24, r21)		# Save r24 through r31 on the stack
-	andi.	r23,r23,MSR_PR		# Is this from user space?
-	mfspr	r23,SPRN_SPRG3		# If from user, fix up THREAD.regs
-	beq	2f			# No, it is from the kernel; branch.
+	stw	r22,_NIP(r21)		/* Save the faulting IP on the stack */
+	stw	r23,_MSR(r21)		/* Save the exception MSR on stack */
+	SAVE_4GPRS(8, r21)		/* Save r8 through r11 on the stack */
+	SAVE_8GPRS(12, r21)		/* Save r12 through r19 on the stack */
+	SAVE_8GPRS(24, r21)		/* Save r24 through r31 on the stack */
+	andi.	r23,r23,MSR_PR		/* Is this from user space? */
+	mfspr	r23,SPRN_SPRG3		/* If from user, fix up THREAD.regs */
+	beq	2f			/* No, it is from the kernel; branch. */
+	mfspr	r24,SPRN_DBCR0
+	stw	r24,THREAD_DBCR0(r23)	/* Save Debug Control in thread_struct */
 	addi	r24,r1,STACK_FRAME_OVERHEAD
-	stw	r24,PT_REGS(r23)	# 
-2:	addi	r2,r23,-THREAD		# Set r2 to current thread
+	stw	r24,PT_REGS(r23)
+2:	addi	r2,r23,-THREAD		/* Set r2 to current thread */
 	tovirt(r2,r2)
 	mflr	r23
-	andi.	r24,r23,0x3f00		# Get vector offset
+	andi.	r24,r23,0x3f00		/* Get vector offset */
 	stw	r24,TRAP(r21)
+	li	r22,RESULT
+	/* No need to put an erratum #77 workaround here
+		because interrupts are currently disabled */
+	stwcx.	r22,r22,r21		/* Clear the reservation */
 	li	r22,0
 	stw	r22,RESULT(r21)
-	mtspr	SPRN_SPRG2,r22		# r1 is now the kernel stack pointer
-	addi	r24,r2,TASK_STRUCT_SIZE	# Check for kernel stack overflow
+	mtspr	SPRN_SPRG2,r22		/* r1 is now the kernel stack pointer */
+	addi	r24,r2,TASK_STRUCT_SIZE	/* Check for kernel stack overflow */
 	cmplw	cr0,r1,r2
 	cmplw	cr1,r1,r24
 	crand	cr1,cr1,cr4
-	bgt-	stack_ovf		# If r2 < r1 < r2 + TASK_STRUCT_SIZE
-	lwz	r24,0(r23)		# Virtual address of the handler
-	lwz	r23,4(r23)		# Handler return pointer
-	cmpwi	cr0,r7,STND_EXC		# What type of exception is this?
-	bne	3f			# It is a critical exception...
-
-	## Standard exception jump path
-	
-	mtspr	SPRN_SRR0,r24		# Set up the instruction pointer
-	mtspr	SPRN_SRR1,r20		# Set up the machine state register
-	mtlr	r23			# Set up the return pointer
+	bgt-	stack_ovf		/* If r2 < r1 < r2 + TASK_STRUCT_SIZE */
+	lwz	r24,0(r23)		/* Virtual address of the handler */
+	lwz	r23,4(r23)		/* Handler return pointer */
+	cmpwi	cr0,r7,STND_EXC		/* What type of exception is this? */
+	bne	3f			/* It is a critical exception... */
+
+	/* Standard exception jump path
+	*/
+
+	/* We have to recover r7 from the register save stack.
+	 * It was used to indicate standard/critical exception.  In
+	 * the case of a standard exception that is the system call
+	 * trap, it may have originally contained one of the syscall
+	 * parameters and we have to get it back now.
+	 */
+	lwz	r7,GPR7(r21)
+	mtspr	SPRN_SRR0,r24		/* Set up the instruction pointer */
+	mtspr	SPRN_SRR1,r20		/* Set up the machine state register */
+	mtlr	r23			/* Set up the return pointer */
 	SYNC
-	rfi				# Enable the MMU, jump to the handler
+	/* We shouldn't need a 405 erratum #77 workaround here, because we're not
+	 * actually returning to the interrupted instruction yet. */
+	rfi
+	b	.		/* prevent prefetch past rfi */
 
-	## Critical exception jump path
+	/* Critical exception jump path
+	*/
 
-3:	mtspr	SPRN_SRR2,r24		# Set up the instruction pointer
-	mtspr	SPRN_SRR3,r20		# Set up the machine state register
-	mtlr	r23			# Set up the return pointer
+3:	mtspr	SPRN_SRR2,r24		/* Set up the instruction pointer */
+	mtspr	SPRN_SRR3,r20		/* Set up the machine state register */
+	mtlr	r23			/* Set up the return pointer */
 	SYNC
-	rfci				# Enable the MMU, jump to the handler
+	rfci
+	b	.			/* prevent prefetch past rfci */
 
-###
-### On kernel stack overlow, load up an initial stack pointer and call
-### StackOverflow(regs), which should NOT return.
-### 
+/* On kernel stack overlow, load up an initial stack pointer and call
+ * StackOverflow(regs), which should NOT return.
+ */ 
 
 stack_ovf:
 	addi	r3,r1,STACK_FRAME_OVERHEAD
@@ -438,143 +895,226 @@
 	lis	r24,StackOverflow@ha
 	addi	r24,r24,StackOverflow@l
 	li	r20,MSR_KERNEL
-	mtspr	SPRN_SRR0,r24		# Set up the instruction pointer
-	mtspr	SPRN_SRR1,r20		# Set up the machine state register
+	mtspr	SPRN_SRR0,r24
+	mtspr	SPRN_SRR1,r20
 	SYNC
-	rfi				# Enable the MMU, jump to StackOverflow
-
-###
-### extern void giveup_altivec(struct task_struct *prev)
-###
-### The PowerPC 4xx family of processors do not have AltiVec capabilities, so
-### this just returns.
-###
+	rfi
+	b	.		/* prevent prefetch past rfi */
 
+/* extern void giveup_altivec(struct task_struct *prev)
+ *
+ * The PowerPC 4xx family of processors do not have AltiVec capabilities, so
+ * this just returns.
+ */
 _GLOBAL(giveup_altivec)
 	blr
-	
-###
-### extern void giveup_fpu(struct task_struct *prev)
-###
-### The PowerPC 4xx family of processors do not have an FPU, so this just
-### returns.
-###
 
+/* extern void giveup_fpu(struct task_struct *prev)
+ *
+ * The PowerPC 4xx family of processors do not have an FPU, so this just
+ * returns.
+ */
 _GLOBAL(giveup_fpu)
 	blr
 
-###
-### extern void abort(void)
-###
-### At present, this routine just applies a system reset.
-### 
-	
+/* extern void abort(void)
+ *
+ * At present, this routine just applies a system reset.
+ */ 
 _GLOBAL(abort)
-	mfspr	r13,SPRN_DBCR
-	oris	r13,r13,DBCR_RST(DBCR_RST_SYSTEM)@h
-	mtspr	SPRN_DBCR,r13
-
+        mfspr   r13,SPRN_DBCR0
+        oris    r13,r13,DBCR_RST(DBCR_RST_SYSTEM)@h
+        mtspr   SPRN_DBCR0,r13
 
-### 
-### This is where the main kernel code starts.
-### 
 
+/* This is where the main kernel code starts.
+ */ 
 start_here:
-	## Establish a pointer to the current task
-	
+
+	/* ptr to current */
 	lis	r2,init_task_union@h
 	ori	r2,r2,init_task_union@l
-	
-	## Clear out the BSS as per ANSI C requirements
 
-	lis	r7,_end@ha
-	addi	r7,r7,_end@l
-	lis	r8,__bss_start@ha
-	addi	r8,r8,__bss_start@l
-	subf	r7,r8,r7
-	addi	r7,r7,3
-	srwi.	r7,r7,2
-	beq	2f
-	addi	r8,r8,-4
-	mtctr	r7
-	li	r0,0
-3:	stwu	r0,4(r8)
-	bdnz	3b
+	/* ptr to phys current thread */
+	tophys(r4,r2)
+	addi	r4,r4,THREAD	/* init task's THREAD */
+	mtspr	SPRG3,r4
+	li	r3,0
+	mtspr	SPRG2,r3	/* 0 => r1 has kernel sp */
 
-	## Stack
-	
-2:	addi	r1,r2,TASK_UNION_SIZE
+	/* stack */
+	addi	r1,r2,TASK_UNION_SIZE
 	li	r0,0
 	stwu	r0,-STACK_FRAME_OVERHEAD(r1)
 
-	## Determine what type of platform this is.
+	bl	early_init	/* We have to do this with MMU on */
 
+/*
+ * Decide what sort of machine this is and initialize the MMU.
+ */
 	mr	r3,r31
 	mr	r4,r30
 	mr	r5,r29
 	mr	r6,r28
 	mr	r7,r27
-	bl	identify_machine
-	
-	## Initialize the memory management unit.
-
+	bl	machine_init
 	bl	MMU_init
 
-	## Go back to running unmapped so that we can change to our
-	## exception vectors.
-
+/* Go back to running unmapped so we can load up new values
+ * and change to using our exception vectors.
+ * On the 4xx, all we have to do is invalidate the TLB to clear
+ * the old 16M byte TLB mappings.
+ */
 	lis	r4,2f@h
 	ori	r4,r4,2f@l
 	tophys(r4,r4)
 	li	r3,MSR_KERNEL & ~(MSR_IR|MSR_DR)
-	mtspr	SPRN_SRR0,r4		# Set up the instruction pointer
-	mtspr	SPRN_SRR1,r3		# Set up the machine state register
+	mtspr	SRR0,r4
+	mtspr	SRR1,r3
 	rfi
+	b	.		/* prevent prefetch past rfi */
+
+/* Load up the kernel context */
+2:
+	SYNC			/* Force all PTE updates to finish */
+#ifndef CONFIG_PIN_TLB
+	tlbia			/* Clear all TLB entries */
+	sync			/* wait for tlbia/tlbie to finish */
+#endif
+
+	/* set up the PTE pointers for the Abatron bdiGDB.
+	*/
+	lis	r6, swapper_pg_dir@h
+	ori	r6, r6, swapper_pg_dir@l
+	lis	r5, abatron_pteptrs@h
+	ori	r5, r5, abatron_pteptrs@l
+	stw	r5, 0xf0(r0)	/* Must match your Abatron config file */
+	tophys(r5,r5)
+	stw	r6, 0(r5)
+
+/* Now turn on the MMU for real! */
+	li	r4,MSR_KERNEL
+	lis	r3,start_kernel@h
+	ori	r3,r3,start_kernel@l
+	mtspr	SRR0,r3
+	mtspr	SRR1,r4
+	rfi			/* enable MMU and jump to start_kernel */
+	b	.		/* prevent prefetch past rfi */
+
+/* Set up the initial MMU state so we can do the first level of
+ * kernel initialization.  This maps the first 16 MBytes of memory 1:1
+ * virtual to physical and more importantly sets the cache mode.
+ */
+initial_mmu:
+	tlbia			/* Invalidate all TLB entries */
+	sync 
+
+	/* We should still be executing code at physical address 0x0000xxxx
+	 * at this point. However, start_here is at virtual address
+	 * 0xC000xxxx. So, set up a TLB mapping to cover this once
+	 * translation is enabled.
+	 */
 
-	## Load up the kernel context
+	lis	r3,KERNELBASE@h		/* Load the kernel virtual address */
+	ori	r3,r3,KERNELBASE@l
+	tophys(r4,r3)			/* Load the kernel physical address */
 
-2:	SYNC				# Force all PTE updates to finish
-#	tlbia				# Clear all TLB entries
-#	sync				# Wait for tlbia to finish...
+	iccci	r0,r3			/* Invalidate the i-cache before use */
 
-	## Set up for using our exception vectors
-	
-	tophys(r4,r2)			# Pointer to physical current thread
-	addi	r4,r4,THREAD		# The init task thread
-	mtspr	SPRN_SPRG3,r4		# Save it for exceptions later
-	li	r3,0			# 
-	mtspr	SPRN_SPRG2,r3		# 0 implies r1 has kernel stack pointer
+	/* Load the kernel PID.
+	*/
+	li	r0,0
+	mtspr	SPRN_PID,r0
+	sync
+
+	/* Configure and load two entries into TLB slots 62 and 63.
+	 * In case we are pinning TLBs, these are reserved in by the
+	 * other TLB functions.  If not reserving, then it doesn't
+	 * matter where they are loaded.
+	 */
+	clrrwi	r4,r4,10		/* Mask off the real page number */
+	ori	r4,r4,(TLB_WR | TLB_EX)	/* Set the write and execute bits */
+
+	clrrwi	r3,r3,10		/* Mask off the effective page number */
+	ori	r3,r3,(TLB_VALID | TLB_PAGESZ(PAGESZ_16M))
+
+        li      r0,62                    /* TLB slot 62 */
+
+	tlbwe	r4,r0,TLB_DATA		/* Load the data portion of the entry */
+	tlbwe	r3,r0,TLB_TAG		/* Load the tag portion of the entry */
+
+	addis	r4, r4, 0x0100		/* Map next 16 M entries */
+	addis	r3, r3, 0x0100
+
+        li      r0,63                    /* TLB slot 63 */
+
+	tlbwe	r4,r0,TLB_DATA
+	tlbwe	r3,r0,TLB_TAG
+
+#if defined(CONFIG_SERIAL_TEXT_DEBUG) && defined(SERIAL_DEBUG_IO_BASE)
 	
-	## Really turn on the MMU and jump into the kernel
+	/* Load a TLB entry for the UART, so that ppc4xx_progress() can use
+	 * the UARTs nice and early.  We use a 4k real==virtual mapping. */
+
+	lis	r3,SERIAL_DEBUG_IO_BASE@h
+	ori	r3,r3,SERIAL_DEBUG_IO_BASE@l
+	mr	r4,r3
+	clrrwi	r4,r4,12
+	ori	r4,r4,(TLB_WR|TLB_I|TLB_M|TLB_G)
+
+	clrrwi	r3,r3,12
+	ori	r3,r3,(TLB_VALID | TLB_PAGESZ(PAGESZ_4K))
+
+	li	r0,0			/* TLB slot 0 */
+	tlbwe	r4,r0,TLB_DATA
+	tlbwe	r3,r0,TLB_TAG
+#endif /* CONFIG_SERIAL_DEBUG_TEXT && SERIAL_DEBUG_IO_BASE */
+
+	isync
+
+	/* Establish the exception vector base
+	*/
+	lis	r4,KERNELBASE@h		/* EVPR only uses the high 16-bits */
+	tophys(r0,r4)			/* Use the physical address */
+	mtspr	SPRN_EVPR,r0
+
+	blr
 
-        lis     r4,MSR_KERNEL@h
-        ori     r4,r4,MSR_KERNEL@l
-        lis     r3,start_kernel@h
-        ori     r3,r3,start_kernel@l
-        mtspr   SPRN_SRR0,r3		# Set up the instruction pointer
-        mtspr   SPRN_SRR1,r4		# Set up the machine state register
-        rfi				# Enable the MMU, jump to the kernel
 
 _GLOBAL(set_context)
+
+#ifdef CONFIG_BDI_SWITCH
+	/* Context switch the PTE pointer for the Abatron BDI2000.
+	 * The PGDIR is the second parameter.
+	 */
+	lis	r5, KERNELBASE@h
+	lwz	r5, 0xf0(r5)
+	stw	r4, 0x4(r5)
+#endif
+	sync
 	mtspr	SPRN_PID,r3
+	isync				/* Need an isync to flush shadow */
+					/* TLBs after changing PID */
 	blr
 
-###
-### We put a few things here that have to be page-aligned. This stuff
-### goes at the beginning of the data segment, which is page-aligned.
-###
-
+/* We put a few things here that have to be page-aligned. This stuff
+ * goes at the beginning of the data segment, which is page-aligned.
+ */
 	.data
 _GLOBAL(sdata)
 _GLOBAL(empty_zero_page)
 	.space	4096
 _GLOBAL(swapper_pg_dir)
-	.space	4096	
-
-###
-### This space gets a copy of optional info passed to us by the bootstrap
-### which is used to pass parameters into the kernel like root=/dev/sda1, etc.
-###
+	.space	4096
 
+/* This space gets a copy of optional info passed to us by the bootstrap
+ * which is used to pass parameters into the kernel like root=/dev/sda1, etc.
+ */
 _GLOBAL(cmd_line)
 	.space	512
+
+/* Room for two PTE pointers, usually the kernel and current user pointers
+ * to their respective root page table.
+ */
+abatron_pteptrs:
+	.space	8
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/kernel/head_8xx.S linux-2.4.22-pre2/arch/ppc/kernel/head_8xx.S
--- linux-2.4.21/arch/ppc/kernel/head_8xx.S	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/kernel/head_8xx.S	2003-06-26 21:43:20.000000000 +0000
@@ -74,6 +74,20 @@
  * I used to use SPRG2 for a temporary register in the TLB handler, but it
  * has since been put to other uses.  I now use a hack to save a register
  * and the CCR at memory location 0.....Someday I'll fix this.....
+ *
+ * With regard to resetting the CPM. The UART console has a number of subtle
+ * assumptions built around the initialization to support kgdb/xmon debugging.
+ * The quick answer is we don't want to reset the CPM so we can proper support
+ * this debugging.
+ *
+ * When the kernel is first booted, kgdb/xmon use the CPM as it was set up by
+ * the boot rom.  There is a second initialization of the UART driver, but
+ * before the console is initialized.  This changes the BDs, but the UART
+ * still operates for kgdb/xmon.  The final stage initialization occurs when
+ * the console is initialized, and all of the "normal path" debugging and
+ * messages can occur after this point.  So the only time we want to do a CPM
+ * is in the case of a microcode patch.
+ *
  *	-- Dan
  */
 
@@ -470,7 +484,16 @@
 #endif
 	rfi
 
-2:	mfspr	r20, M_TW	/* Restore registers */
+2:
+	/* Copy 20 msb from MD_EPN to DAR since the dcxx instructions fail
+	 * to update DAR when they cause a DTLB miss.
+	 */
+	mfspr	r21, MD_EPN
+	mfspr	r20, DAR
+	rlwimi	r20, r21, 0, 0, 19
+	mtspr	DAR, r20
+
+	mfspr	r20, M_TW	/* Restore registers */
 	lwz	r21, 0(r0)
 	mtcr	r21
 	lwz	r21, 4(r0)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/kernel/idle.c linux-2.4.22-pre2/arch/ppc/kernel/idle.c
--- linux-2.4.21/arch/ppc/kernel/idle.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/kernel/idle.c	2003-06-26 21:43:10.000000000 +0000
@@ -34,9 +34,7 @@
 unsigned long powersave_nap;
 unsigned long powersave_lowspeed;
 
-#ifdef CONFIG_6xx
-extern void power_save_6xx(void);
-#endif
+extern void power_save(void);
 
 int idled(void)
 {
@@ -66,10 +64,8 @@
 			}
 		}
 #endif
-#ifdef CONFIG_6xx
 		if (do_power_save && !current->need_resched)
-			power_save_6xx();
-#endif /* CONFIG_6xx */			
+			power_save();
 
 		if (current->need_resched) {
 			schedule();
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/kernel/idle_6xx.S linux-2.4.22-pre2/arch/ppc/kernel/idle_6xx.S
--- linux-2.4.21/arch/ppc/kernel/idle_6xx.S	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/kernel/idle_6xx.S	2003-06-26 21:43:28.000000000 +0000
@@ -56,12 +56,12 @@
 	blr
 
 /*
- * Here is the power_save_6xx function. This could eventually be
+ * Here is the power_save function. This could eventually be
  * split into several functions & changing the function pointer
  * depending on the various features.
  */
-	.globl	power_save_6xx
-power_save_6xx:
+	.globl	power_save
+power_save:
 	/* Check if we can nap or doze, put HID0 mask in r3
 	 */
 	lis	r3, 0
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/kernel/idle_gen.c linux-2.4.22-pre2/arch/ppc/kernel/idle_gen.c
--- linux-2.4.21/arch/ppc/kernel/idle_gen.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/kernel/idle_gen.c	2003-06-26 21:43:10.000000000 +0000
@@ -0,0 +1,41 @@
+/*
+ * This is the old power_save() function from idle.c:
+ *
+ * Written by Cort Dougan (cort@cs.nmt.edu)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the 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 <asm/processor.h>
+#include <asm/cputable.h>
+
+void power_save(void)
+{
+	/* Make sure the CPU has the DOZE feature set. */
+	if (!(cur_cpu_spec[smp_processor_id()]->cpu_features
+				& CPU_FTR_CAN_DOZE))
+		return;
+	/*
+	 * Disable interrupts to prevent a lost wakeup
+	 * when going to sleep.  This is necessary even with
+	 * RTLinux since we are not guaranteed an interrupt
+	 * didn't come in and is waiting for a __sti() before
+	 * emulating one.  This way, we really do hard disable.
+	 * 
+	 * We assume that we're sti-ed when we come in here.  We
+	 * are in the idle loop so if we're cli-ed then it's a bug
+	 * anyway.
+	 *  -- Cort
+	 */
+	_nmask_and_or_msr(MSR_EE, 0);
+	if (!current->need_resched) {
+		/* set the POW bit in the MSR, and enable interrupts
+		 * so we wake up sometime! */
+		_nmask_and_or_msr(0, MSR_POW | MSR_EE);
+	}
+	_nmask_and_or_msr(0, MSR_EE);
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/kernel/indirect_pci.c linux-2.4.22-pre2/arch/ppc/kernel/indirect_pci.c
--- linux-2.4.21/arch/ppc/kernel/indirect_pci.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/kernel/indirect_pci.c	2003-06-26 21:43:11.000000000 +0000
@@ -29,10 +29,19 @@
 indirect_##rw##_config_##size(struct pci_dev *dev, int offset, type val) \
 {									 \
 	struct pci_controller *hose = dev->sysdata;			 \
+	u8 cfg_type = 0;						 \
+									 \
+	if (ppc_md.pci_exclude_device)					 \
+		if (ppc_md.pci_exclude_device(dev->bus->number, dev->devfn)) \
+			return PCIBIOS_DEVICE_NOT_FOUND;		 \
+									 \
+	if (hose->set_cfg_type)					 	 \
+		if (dev->bus->number != hose->first_busno)		 \
+			cfg_type = 1;					 \
 									 \
 	out_be32(hose->cfg_addr, 					 \
-		 ((offset & 0xfc) << 24) | (dev->devfn << 16)		 \
-		 | (dev->bus->number << 8) | 0x80);			 \
+		 (((offset & 0xfc) | cfg_type) << 24) | (dev->devfn << 16) \
+		 | ((dev->bus->number - hose->bus_offset) << 8) | 0x80); \
 	cfg_##rw(val, hose->cfg_data + (offset & mask), type, op);	 \
 	return PCIBIOS_SUCCESSFUL;    					 \
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/kernel/misc.S linux-2.4.22-pre2/arch/ppc/kernel/misc.S
--- linux-2.4.21/arch/ppc/kernel/misc.S	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/kernel/misc.S	2003-06-26 21:43:32.000000000 +0000
@@ -348,6 +348,20 @@
  * Flush MMU TLB
  */
 _GLOBAL(_tlbia)
+#if defined(CONFIG_40x) && defined(CONFIG_PIN_TLB)
+	/* This needs to be coordinated with other pinning functions since
+	 * we don't keep a memory location of number of entries to reduce
+	 * cache pollution during these operations.
+	 */
+	lis	r3, 0
+	sync
+1:
+	tlbwe	r3, r3, TLB_TAG		/* just ensure V is clear */
+	addi	r3, r3, 1		/*   so r3 works fine for that */
+	cmpwi	0, r3, 61		/* reserve last two entries */
+	ble	1b
+	isync
+#else
 #if defined(CONFIG_SMP)
 	mfmsr	r10
 	SYNC
@@ -375,12 +389,24 @@
 	mtmsr	r10
 	SYNC
 #endif /* CONFIG_SMP */
+#endif /* defined(CONFIG_40x) && defined(CONFIG_PIN_TLB) */
 	blr	
 
 /*
  * Flush MMU TLB for a particular address
  */
 _GLOBAL(_tlbie)
+#ifdef CONFIG_40x
+	tlbsx.	r3, 0, r3
+	bne	10f
+	sync
+	/* There are only 64 TLB entries, so r3 < 64, which means bit 25, is clear.
+	 * Since 25 is the V bit in the TLB_TAG, loading this value will invalidate
+	 * the TLB entry. */
+	tlbwe	r3, r3, TLB_TAG
+	isync
+10:
+#else
 #if defined(CONFIG_SMP)
 	mfmsr	r10
 	SYNC
@@ -394,6 +420,7 @@
 10:	lwarx	r7,0,r9
 	cmpi	0,r7,0
 	bne-	10b
+	PPC405_ERR77(0,r9)
 	stwcx.	r8,0,r9
 	bne-	10b
 #endif /* CONFIG_SMP */
@@ -407,6 +434,7 @@
 	mtmsr	r10
 	SYNC
 #endif
+#endif /* CONFIG_40x */
 	blr
 
 /*
@@ -418,9 +446,18 @@
 	isync
 	lis	r5, IDC_INVALL@h
 	mtspr	IC_CST, r5
-#elif defined(CONFIG_4xx)
+#elif CONFIG_4xx
+#ifdef CONFIG_403GCX
+	li      r3, 512
+	mtctr   r3
+	lis     r4, KERNELBASE@h
+1:	iccci   0, r4 
+	addi    r4, r4, 16
+	bdnz    1b
+#else
 	lis	r3, KERNELBASE@h
 	iccci	0,r3
+#endif
 #else
 	mfspr	r3,PVR
 	rlwinm	r3,r3,16,16,31
@@ -430,7 +467,7 @@
 	mfspr	r3,HID0
 	ori	r3,r3,HID0_ICFI
 	mtspr	HID0,r3
-#endif /* CONFIG_8xx */
+#endif /* CONFIG_8xx/4xx */
 	isync
 	blr
 
@@ -530,6 +567,27 @@
 	sync				/* wait for dcbi's to get to ram */
 	blr
 
+#ifdef CONFIG_NOT_COHERENT_CACHE
+/*
+ * 40x cores have 8K or 16K dcache and 32 byte line size.
+ * 440 has a 32K dcache and 32 byte line size.
+ * 8xx has 1, 2, 4, 8K variants.
+ * For now, cover the worst case of the 440.
+ * Must be called with external interrupts disabled.
+ */
+#define CACHE_NWAYS	64
+#define CACHE_NLINES	16	
+
+_GLOBAL(flush_dcache_all)
+	li	r4, (2 * CACHE_NWAYS * CACHE_NLINES)
+	mtctr	r4
+	lis     r5, KERNELBASE@h
+1:	lwz	r3, 0(r5)		/* Load one word from every line */
+	addi	r5, r5, L1_CACHE_LINE_SIZE
+	bdnz    1b
+	blr
+#endif /* CONFIG_NOT_COHERENT_CACHE */
+
 /*
  * Flush a particular page from the data cache to RAM.
  * Note: this is necessary because the instruction cache does *not*
@@ -867,7 +925,7 @@
  * and exceptions as if the cpu had performed the load or store.
  */
 
-#if defined(CONFIG_4xx)
+#ifdef CONFIG_4xx
 _GLOBAL(cvt_fd)
 	lfs	0,0(r3)
 	stfd	0,0(r4)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/kernel/mk_defs.c linux-2.4.22-pre2/arch/ppc/kernel/mk_defs.c
--- linux-2.4.21/arch/ppc/kernel/mk_defs.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/kernel/mk_defs.c	2003-06-26 21:43:27.000000000 +0000
@@ -57,6 +57,9 @@
 	DEFINE(THREAD_VRSAVE, offsetof(struct thread_struct, vrsave));
 	DEFINE(THREAD_VSCR, offsetof(struct thread_struct, vscr));
 #endif /* CONFIG_ALTIVEC */
+#ifdef CONFIG_4xx
+	DEFINE(THREAD_DBCR0, offsetof(struct thread_struct, dbcr0));
+#endif
 	/* Interrupt register frame */
 	DEFINE(TASK_UNION_SIZE, sizeof(union task_union));
 	DEFINE(STACK_FRAME_OVERHEAD, STACK_FRAME_OVERHEAD);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/kernel/ocp.c linux-2.4.22-pre2/arch/ppc/kernel/ocp.c
--- linux-2.4.21/arch/ppc/kernel/ocp.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/kernel/ocp.c	2003-06-26 21:43:22.000000000 +0000
@@ -0,0 +1,450 @@
+/*
+ * ocp.c
+ *
+ *      (c) Benjamin Herrenschmidt (benh@kernel.crashing.org)
+ *          Mipsys - France
+ *
+ "          Derived from work (c) Armin Kuster akuster@pacbell.net
+ *
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR   IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT,  INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ *	
+ */
+
+#include <linux/module.h>
+#include <linux/config.h>
+#include <linux/list.h>
+#include <linux/miscdevice.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/pm.h>
+#include <asm/io.h>
+#include <asm/ocp.h>
+#include <asm/errno.h>
+#include <asm/rwsem.h>
+#include <asm/semaphore.h>
+
+//#define DBG(x)	printk x
+#define DBG(x)
+
+extern struct ocp_def core_ocp[];	/* Static list of devices, provided by
+					   CPU core */
+
+LIST_HEAD(ocp_devices);			/* List of all OCP devices */
+LIST_HEAD(ocp_drivers);			/* List of all OCP drivers */
+DECLARE_RWSEM(ocp_devices_sem);		/* Global semaphores for those lists */
+DECLARE_MUTEX(ocp_drivers_sem);		/* Global semaphores for those lists */
+
+static int ocp_inited;
+
+/**
+ *	ocp_driver_match	-	Match one driver to one device
+ *	@drv: driver to match
+ *	@dev: device to match
+ *
+ *	This function returns 0 if the driver and device don't match
+ */
+static int
+ocp_driver_match(struct ocp_driver *drv, struct ocp_device *dev)
+{
+	const struct ocp_device_id *ids = drv->id_table;
+	
+	if (!ids)
+		return 0;
+
+	while (ids->vendor || ids->function) {
+		if ((ids->vendor == OCP_ANY_ID
+		     || ids->vendor == dev->def->vendor)
+		    && (ids->function == OCP_ANY_ID
+			|| ids->function == dev->def->function))
+		        return 1;
+		ids++;
+	}
+	return 0;
+}
+
+
+/**
+ *	ocp_bind_drivers	-	Match all drivers with all devices
+ *	@candidate: driver beeing registered
+ *	
+ *	This function is called on driver registration and device discovery,
+ *	it redo the matching of all "driverless" devices with all possible
+ *	driver candidates.
+ *	The driver beeing registered can be optionally passed in, in which
+ *	case, the function will return -ENODEV is no match have been found
+ *	or if all matches failed with a different code than -EAGAIN
+ */
+static int
+ocp_bind_drivers(struct ocp_driver *candidate)
+{
+	struct list_head	*deventry, *drventry;
+	struct ocp_device	*dev;
+	struct ocp_driver	*drv;
+	int			one_again, one_match;
+	int			count = 0;
+
+	DBG(("ocp: binding drivers...\n"));
+	do {
+		/* We re-do the match loop if we had a sucess match and got one -EAGAIN
+		 */
+		one_match = one_again = 0;
+		down_read(&ocp_devices_sem);
+		list_for_each(deventry, &ocp_devices) {     
+			dev = list_entry(deventry, struct ocp_device, link);
+			if (dev->driver != NULL)
+				continue;
+			DBG(("ocp: device %s unmatched, trying to match...\n", dev->name));
+			list_for_each(drventry, &ocp_drivers) {
+				drv = list_entry(drventry, struct ocp_driver, link);
+				if (ocp_driver_match(drv, dev)) {
+					int rc;
+
+					/* Hrm... shall we set dev->driver after or before ? */
+					DBG(("ocp: match with driver %s, calling probe...\n", drv->name));
+					rc = drv->probe(dev);
+					DBG(("ocp: probe result: %d\n", rc));
+					if (rc == 0) {
+						/* Driver matched, next device */
+						dev->driver = drv;
+						one_match = 1;
+						if (drv == candidate)
+							count++;	
+						break;
+					} else if (rc == -EAGAIN) {
+						/* Driver matched but asked for later call, next device */
+						one_again = 1;
+						if (drv == candidate)
+							count++;	
+						break;
+					}
+				}
+			}
+		}
+		up_read(&ocp_devices_sem);
+	} while(one_match && one_again);
+	DBG(("ocp: binding drivers... done.\n"));
+
+	return count;
+}
+
+/**
+ *	ocp_register_driver	-	Register an OCP driver
+ *	@drv: pointer to statically defined ocp_driver structure
+ *
+ *	The driver's probe() callback is called either recursively
+ *	by this function or upon later call of ocp_init
+ *
+ *      NOTE: Probe is called with ocp_drivers_sem heocp_find_deviceld, it shouldn't
+ *      call ocp_register/unregister_driver on his own code path.
+ *      however, it _can_ call ocp_find_device().
+ *
+ *	NOTE2: Detection of devices is a 2 pass step on this implementation,
+ *	hotswap isn't supported. First, all OCP devices are put in the device
+ *	list, _then_ all drivers are probed on each match.
+ *
+ *      NOTE3: Drivers are allowed to return -EAGAIN from the probe() routine.
+ *      this will cause them to be called again for this specific device as
+ *	soon as another device have been probed or another driver registered.
+ *	this, gives a simple way for a driver like EMAC to wait for another driver,
+ *	like MAL to be up. There is potentially a small race if MAL happens to
+ *	unregister, but this is hopefully never happening.
+ *	
+ *	This function returns a count of how many devices actually matched
+ *	(wether the probe routine returned 0 or -EAGAIN, a different error
+ *	code isn't considered as a match).
+ */
+
+int
+ocp_register_driver(struct ocp_driver *drv)
+{
+	int	rc = 0;
+
+	DBG(("ocp: ocp_register_driver(%s)...\n", drv->name));
+
+	/* Add to driver list */
+	down(&ocp_drivers_sem);
+	list_add_tail(&drv->link, &ocp_drivers);
+
+	/* Check matching devices */
+	rc = ocp_bind_drivers(drv);
+
+	up(&ocp_drivers_sem);
+
+	DBG(("ocp: ocp_register_driver(%s)... done, count: %d.\n", drv->name, rc));
+
+	return rc;
+}
+
+/**
+ *	ocp_unregister_driver	-	Unregister an OCP driver
+ *	@drv: pointer to statically defined ocp_driver structure
+ *
+ *	The driver's remove() callback is called recursively
+ *	by this function for any device already registered
+ */
+
+void
+ocp_unregister_driver(struct ocp_driver *drv)
+{
+	struct ocp_device	*dev;
+	struct list_head	*entry;
+
+	DBG(("ocp: ocp_unregister_driver(%s)...\n", drv->name));
+
+	/* Call remove() routine for all devices using it */
+	down(&ocp_drivers_sem);
+	down_read(&ocp_devices_sem);
+	list_for_each(entry, &ocp_devices) {
+		dev = list_entry(entry, struct ocp_device, link);
+		if (dev->driver == drv) {
+			drv->remove(dev);
+			dev->driver = NULL;
+			dev->drvdata = NULL;
+		}
+	}
+	up_read(&ocp_devices_sem);
+
+	/* Unlink driver structure */
+	list_del_init(&drv->link);
+	up(&ocp_drivers_sem);
+
+	DBG(("ocp: ocp_unregister_driver(%s)... done.\n", drv->name));
+}
+
+/**
+ *	ocp_find_device	-	Find a device by function & index
+ *      @vendor: vendor ID of the device (or OCP_ANY_ID)
+ *	@function: function code of the device (or OCP_ANY_ID)
+ *	@idx: index of the device (or OCP_ANY_INDEX)
+ * 
+ *	This function allows a lookup of a given function by it's
+ *	index, it's typically used to find the MAL or ZMII associated
+ *	with an EMAC or similar horrors.
+ *      You can pass vendor, though you usually want OCP_ANY_ID there...
+ */
+struct ocp_device *
+ocp_find_device(unsigned int vendor, unsigned int function, int index)
+{
+	struct list_head	*entry;
+	struct ocp_device	*dev, *found = NULL;
+
+	DBG(("ocp: ocp_find_device(vendor: %x, function: %x, index: %d)...\n",
+		vendor, function, index));
+
+	down_read(&ocp_devices_sem);
+	list_for_each(entry, &ocp_devices) {     
+		dev = list_entry(entry, struct ocp_device, link);
+		if (vendor != OCP_ANY_ID && vendor != dev->def->vendor)
+			continue;
+		if (function != OCP_ANY_ID && function != dev->def->function)
+			continue;
+		if (index != OCP_ANY_INDEX && index != dev->def->index)
+			continue;
+		found = dev;
+		break;
+	}
+	up_read(&ocp_devices_sem);
+
+	DBG(("ocp: ocp_find_device(vendor: %x, function: %x, index: %d)... done.\n",
+		vendor, function, index));
+
+	return found;
+}
+
+/**
+ *	ocp_add_one_device	-	Add a device
+ *	@def: static device definition structure
+ *
+ *	This function is solely meant to be called by ocp_init
+ *	to add one device from the core static list to the
+ *	device list
+ */
+static void
+ocp_add_one_device(struct ocp_def *def)
+{
+	struct	ocp_device	*dev;
+
+	dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+	if (dev == NULL)
+		return;
+	memset(dev, 0, sizeof(*dev));
+	dev->def = def;
+	dev->current_state = 4;
+	sprintf(dev->name, "OCP device %04x:%04x:%04x",
+		dev->def->vendor, dev->def->function, dev->def->index);
+	list_add_tail(&dev->link, &ocp_devices);
+}
+
+#ifdef CONFIG_PM
+/*
+ * OCP Power management..
+ *
+ * This needs to be done centralized, so that we power manage PCI
+ * devices in the right order: we should not shut down PCI bridges
+ * before we've shut down the devices behind them, and we should
+ * not wake up devices before we've woken up the bridge to the
+ * device.. Eh?
+ *
+ * We do not touch devices that don't have a driver that exports
+ * a suspend/resume function. That is just too dangerous. If the default
+ * PCI suspend/resume functions work for a device, the driver can
+ * easily implement them (ie just have a suspend function that calls
+ * the pci_set_power_state() function).
+ * 
+ * BenH: Implementation here couldn't work properly. This version
+ *       slightly modified and _might_ be more useable, but real
+ *       PM support will probably have to wait for 2.5
+ */
+
+static int ocp_pm_save_state_device(struct ocp_device *dev, u32 state)
+{
+	int error = 0;
+	if (dev) {
+		struct ocp_driver *driver = dev->driver;
+		if (driver && driver->save_state)
+			error = driver->save_state(dev,state);
+	}
+	return error;
+}
+
+static int ocp_pm_suspend_device(struct ocp_device *dev, u32 state)
+{
+	int error = 0;
+	if (dev) {
+		struct ocp_driver *driver = dev->driver;
+		if (driver && driver->suspend)
+			error = driver->suspend(dev,state);
+	}
+	return error;
+}
+
+static int ocp_pm_resume_device(struct ocp_device *dev)
+{
+	int error = 0;
+	if (dev) {
+		struct ocp_driver *driver = dev->driver;
+		if (driver && driver->resume)
+			error = driver->resume(dev);
+	}
+	return error;
+}
+
+static int
+ocp_pm_callback(struct pm_dev *pm_device, pm_request_t rqst, void *data)
+{
+	int error = 0;
+	struct list_head	*entry;
+	struct ocp_device	*dev;
+
+	down(&ocp_drivers_sem);
+	down_read(&ocp_devices_sem);
+
+	list_for_each(entry, &ocp_devices) {
+		dev = list_entry(entry, struct ocp_device, link);
+		switch (rqst) {
+		case PM_SAVE_STATE:
+			error = ocp_pm_save_state_device(dev, 3);
+			break;
+		case PM_SUSPEND:
+			error = ocp_pm_suspend_device(dev, 3);
+			break;
+		case PM_RESUME:
+			error = ocp_pm_resume_device(dev);
+			break;
+		default: break;
+		}
+		if (error)
+			break;
+	}
+	return error;
+}
+
+/*
+ * Is this ever used ?
+ */
+void
+ppc4xx_cpm_fr(u32 bits, int val)
+{
+	unsigned long flags;
+
+	save_flags(flags);
+	cli();
+
+	if (val)
+		mtdcr(DCRN_CPMFR, mfdcr(DCRN_CPMFR) | bits);
+	else
+		mtdcr(DCRN_CPMFR, mfdcr(DCRN_CPMFR) & ~bits);
+
+	restore_flags(flags);
+}
+#endif /* CONFIG_PM */
+
+/**
+ *	ocp_init	-	Init OCP device management
+ *
+ *	This function is meant to be called once, and only once to initialize
+ *	the OCP device management and build the list of devices. Note that
+ *	it can actually be called at any time, it's perfectly legal to
+ *	register drivers before ocp_init() is called
+ */
+int
+ocp_init(void)
+{
+	struct ocp_def	*def;
+
+	/* ocp_init is by default an initcall. If your arch requires this to
+	 * be called earlier, then go on, ocp_init is non-static for that purpose,
+	 * and can safely be called twice
+	 */
+	if (ocp_inited)
+		return 0;
+	ocp_inited = 1;
+	
+	DBG(("ocp: ocp_init()...\n"));
+
+	/* Fill the devices list */
+	down_write(&ocp_devices_sem);
+	for (def = core_ocp; def->vendor != OCP_VENDOR_INVALID; def++)
+		ocp_add_one_device(def);
+	up_write(&ocp_devices_sem);
+
+	DBG(("ocp: ocp_init()... added...\n"));
+
+	/* Call drivers probes */
+	down(&ocp_drivers_sem);
+	ocp_bind_drivers(NULL);
+	up(&ocp_drivers_sem);
+
+#ifdef CONFIG_PM
+	pm_register(PM_SYS_DEV, 0, ocp_pm_callback);
+#endif
+
+	DBG(("ocp: ocp_init()... done.\n"));
+
+	return 0;
+}
+
+__initcall(ocp_init);
+
+EXPORT_SYMBOL(ocp_register_driver);
+EXPORT_SYMBOL(ocp_unregister_driver);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/kernel/ppc405_pci.c linux-2.4.22-pre2/arch/ppc/kernel/ppc405_pci.c
--- linux-2.4.21/arch/ppc/kernel/ppc405_pci.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/kernel/ppc405_pci.c	2003-06-26 21:43:19.000000000 +0000
@@ -0,0 +1,227 @@
+/*
+ * FILE NAME: ppc405_pci.c
+ *
+ * BRIEF MODULE DESCRIPTION: 
+ * Based on arch/ppc/kernel/indirect.c, Copyright (C) 1998 Gabriel Paubert.
+ *
+ * Author: MontaVista Software, Inc.  <source@mvista.com>
+ *         Frank Rowand <frank_rowand@mvista.com>
+ *         Debbie Chu   <debbie_chu@mvista.com>
+ *
+ * Copyright 2000 MontaVista Software Inc.
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ *  	:05/07/02 - Armin
+ *  		converted to using ocp register & core_ocp[];
+ *
+ *  	: 05/24/02 - Armin 
+ *  		change get_ocp_paddr to ocp_get_paddr
+ *
+ *  	: 05029/02 - Armin 
+ *  	  added PSR_PCI_ARBIT_EN check , not all 4xx have a pin strap reg
+ */
+
+#include <linux/pci.h>
+#include <asm/io.h>
+#include <asm/system.h>
+#include <asm/machdep.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <asm/ibm4xx.h>
+#include <asm/pci-bridge.h>
+#include <asm/ocp.h>
+
+#ifdef  CONFIG_DEBUG_BRINGUP
+#define DBG(x...) printk(x)
+#else
+#define DBG(x...)
+#endif
+
+extern void bios_fixup(struct pci_controller *, struct pcil0_regs *);
+extern int ppc405_map_irq(struct pci_dev *dev, unsigned char idsel,
+			  unsigned char pin);
+
+void
+ppc405_pcibios_fixup_resources(struct pci_dev *dev)
+{
+	int i;
+	unsigned long max_host_addr;
+	unsigned long min_host_addr;
+	struct resource *res;
+
+	/*
+	 * openbios puts some graphics cards in the same range as the host
+	 * controller uses to map to SDRAM.  Fix it.
+	 */
+
+	min_host_addr = 0;
+	max_host_addr = PPC405_PCI_MEM_BASE - 1;
+
+	for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
+		res = dev->resource + i;
+		if (!res->start)
+			continue;
+		if ((res->flags & IORESOURCE_MEM) &&
+		    (((res->start >= min_host_addr)
+		      && (res->start <= max_host_addr))
+		     || ((res->end >= min_host_addr)
+			 && (res->end <= max_host_addr))
+		     || ((res->start < min_host_addr)
+			 && (res->end > max_host_addr))
+		    )
+		    ) {
+
+			DBG(KERN_ERR "PCI: 0x%lx <= resource[%d] <= 0x%lx"
+			    ", bus 0x%x dev 0x%2.2x.%1.1x,\n"
+			    KERN_ERR "  %s\n"
+			    KERN_ERR "  fixup will be attempted later\n",
+			    min_host_addr, i, max_host_addr,
+			    dev->bus->number, PCI_SLOT(dev->devfn),
+			    PCI_FUNC(dev->devfn), dev->name);
+
+			/* force pcibios_assign_resources() to assign a new address */
+			res->end -= res->start;
+			res->start = 0;
+		}
+	}
+}
+
+static int
+ppc4xx_exclude_device(unsigned char bus, unsigned char devfn)
+{
+	/* We prevent us from seeing ourselves to avoid having
+	 * the kernel try to remap our BAR #1 and fuck up bus
+	 * master from external PCI devices
+	 */
+	return (bus == 0 && devfn == 0);
+}
+
+void
+ppc4xx_find_bridges(void)
+{
+	struct pci_controller *hose_a;
+	struct pcil0_regs *pcip;
+	unsigned int new_pmm_max;
+	unsigned int new_pmm_min;
+
+	isa_io_base = 0;
+	isa_mem_base = 0;
+	pci_dram_offset = 0;
+
+#if  (PSR_PCI_ARBIT_EN > 1)
+	/* Check if running in slave mode */
+	if ((mfdcr(DCRN_CHPSR) & PSR_PCI_ARBIT_EN) == 0) {
+		printk("Running as PCI slave, kernel PCI disabled !\n");
+		return;
+	}
+#endif
+	/* Setup PCI32 hose */
+	hose_a = pcibios_alloc_controller();
+	if (!hose_a)
+		return;
+	setup_indirect_pci(hose_a, PPC405_PCI_CONFIG_ADDR,
+			   PPC405_PCI_CONFIG_DATA);
+
+#ifdef CONFIG_XILINX_OCP
+	/* Eliminate "unused variable" warning for pcip.  Optimizer removes. */
+	pcip = NULL;
+	new_pmm_min = PPC405_PCI_LOWER_MEM;
+	new_pmm_max = PPC405_PCI_UPPER_MEM;
+#else /* Must be IBM */
+	pcip = ioremap(PPC4xx_PCI_LCFG_PADDR, PAGE_SIZE);
+	if (pcip != NULL) {
+		unsigned int tmp_addr;
+		unsigned int tmp_size;
+		unsigned int reg_index;
+
+#if defined(CONFIG_BIOS_FIXUP)
+		bios_fixup(hose_a, pcip);
+#endif
+		new_pmm_min = 0xffffffff;
+		for (reg_index = 0; reg_index < 3; reg_index++) {
+			tmp_size = in_le32((void *) &(pcip->pmm[reg_index].ma));	// *_PMM0MA
+			if (tmp_size & 0x1) {
+				tmp_addr = in_le32((void *) &(pcip->pmm[reg_index].pcila));	// *_PMM0PCILA
+				if (tmp_addr < PPC405_PCI_PHY_MEM_BASE) {
+					printk(KERN_DEBUG
+					       "Disabling mapping to PCI mem addr 0x%8.8x\n",
+					       tmp_addr);
+					out_le32((void *) &(pcip->pmm[reg_index].ma), tmp_size & ~1);	// *_PMMOMA
+				} else {
+					tmp_addr = in_le32((void *) &(pcip->pmm[reg_index].la));	// *_PMMOLA
+					if (tmp_addr < new_pmm_min)
+						new_pmm_min = tmp_addr;
+					tmp_addr =
+					    tmp_addr + (0xffffffff -
+							(tmp_size &
+							 0xffffc000));
+					if (tmp_addr > PPC405_PCI_UPPER_MEM) {
+						new_pmm_max = tmp_addr;	// PPC405_PCI_UPPER_MEM 
+					} else {
+						new_pmm_max =
+						    PPC405_PCI_UPPER_MEM;
+					}
+				}
+			}
+
+		}		// for
+
+		iounmap(pcip);
+	}
+#endif
+
+	hose_a->first_busno = 0;
+	hose_a->last_busno = 0xff;
+	hose_a->pci_mem_offset = 0;
+
+	/* Setup bridge memory/IO ranges & resources
+	 * TODO: Handle firmwares setting up a legacy ISA mem base
+	 */
+	hose_a->io_space.start = PPC405_PCI_LOWER_IO;
+	hose_a->io_space.end = PPC405_PCI_UPPER_IO;
+	hose_a->mem_space.start = new_pmm_min;
+	hose_a->mem_space.end = new_pmm_max;
+	hose_a->io_base_phys = PPC405_PCI_PHY_IO_BASE;
+	hose_a->io_base_virt = ioremap(hose_a->io_base_phys, 0x10000);
+	hose_a->io_resource.start = 0;
+	hose_a->io_resource.end = PPC405_PCI_UPPER_IO - PPC405_PCI_LOWER_IO;
+	hose_a->io_resource.flags = IORESOURCE_IO;
+	hose_a->io_resource.name = "PCI I/O";
+	hose_a->mem_resources[0].start = new_pmm_min;
+	hose_a->mem_resources[0].end = new_pmm_max;
+	hose_a->mem_resources[0].flags = IORESOURCE_MEM;
+	hose_a->mem_resources[0].name = "PCI Memory";
+	isa_io_base = (int) hose_a->io_base_virt;
+	isa_mem_base = 0;	/*     ISA not implemented */
+	ISA_DMA_THRESHOLD = 0x00ffffff;	/* ??? ISA not implemented */
+
+	/* Scan busses & initial setup by pci_auto */
+	hose_a->last_busno = pciauto_bus_scan(hose_a, hose_a->first_busno);
+
+	/* Setup ppc_md */
+	ppc_md.pcibios_fixup = NULL;
+	ppc_md.pci_exclude_device = ppc4xx_exclude_device;
+	ppc_md.pcibios_fixup_resources = ppc405_pcibios_fixup_resources;
+	ppc_md.pci_swizzle = common_swizzle;
+	ppc_md.pci_map_irq = ppc405_map_irq;
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/kernel/ppc4xx_pic.c linux-2.4.22-pre2/arch/ppc/kernel/ppc4xx_pic.c
--- linux-2.4.21/arch/ppc/kernel/ppc4xx_pic.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/kernel/ppc4xx_pic.c	2003-06-26 21:43:09.000000000 +0000
@@ -15,10 +15,14 @@
  * there are eight internal interrupts for the on-chip serial port
  * (SPU), DMA controller, and JTAG controller.
  *
- * The PowerPC 405 cores' Universal Interrupt Controller (UIC) has 32
- * possible interrupts as well. There are seven, configurable external
- * interrupt pins and there are 17 internal interrupts for the on-chip
- * serial port, DMA controller, on-chip Ethernet controller, PCI, etc.
+ * The PowerPC 405/440 cores' Universal Interrupt Controller (UIC) has
+ * 32 possible interrupts as well.  Depending on the core and SoC
+ * implementation, a portion of the interrrupts are used for on-chip
+ * peripherals and a portion of the interrupts are available to be
+ * configured for external devices generating interrupts.
+ *
+ * The PowerNP and 440GP (and most likely future implementations) have
+ * cascaded UICs.
  *
  */
 
@@ -33,19 +37,31 @@
 #include <asm/ppc4xx_pic.h>
 
 /* Global Variables */
-
 struct hw_interrupt_type *ppc4xx_pic;
+/*
+ * We define 4xxIRQ_InitSenses table thusly:
+ * bit 0x1: sense, 0 for edge and 1 for level.
+ * bit 0x2: polarity, 0 for negative, 1 for positive.
+ */
+unsigned int ibm4xxPIC_NumInitSenses __initdata = 0;
+unsigned char *ibm4xxPIC_InitSenses __initdata = NULL;
+
+/* Six of one, half dozen of the other....#ifdefs, separate files,
+ * other tricks.....
+ *
+ * There are basically two types of interrupt controllers, the 403 AIC
+ * and the "others" with UIC.  I just kept them both here separated
+ * with #ifdefs, but it seems to change depending upon how supporting
+ * files (like ppc4xx.h) change.		-- Dan.
+ */
 
+#ifdef CONFIG_403
 
 /* Function Prototypes */
 
-static void	 ppc403_aic_enable(unsigned int irq);
-static void	 ppc403_aic_disable(unsigned int irq);
-static void	 ppc403_aic_disable_and_ack(unsigned int irq);
-
-static void	 ppc405_uic_enable(unsigned int irq);
-static void	 ppc405_uic_disable(unsigned int irq);
-static void	 ppc405_uic_disable_and_ack(unsigned int irq);
+static void ppc403_aic_enable(unsigned int irq);
+static void ppc403_aic_disable(unsigned int irq);
+static void ppc403_aic_disable_and_ack(unsigned int irq);
 
 static struct hw_interrupt_type ppc403_aic = {
 	"403GC AIC",
@@ -57,55 +73,11 @@
 	0
 };
 
-static struct hw_interrupt_type ppc405_uic = {
-	"405GP UIC",
-	NULL,
-	NULL,
-	ppc405_uic_enable,
-	ppc405_uic_disable,
-	ppc405_uic_disable_and_ack,
-	0
-};
-
-/*
- * Document me.
- */
-void __init
-ppc4xx_pic_init(void)
-{
-	unsigned long ver = PVR_VER(mfspr(SPRN_PVR));
-
-	switch (ver) {
-
-	case PVR_VER(PVR_403GC):
-		/*
-		 * Disable all external interrupts until they are
-		 * explicity requested.
-		 */
-		ppc_cached_irq_mask[0] = 0;
-		mtdcr(DCRN_EXIER, 0);
-
-		ppc4xx_pic = &ppc403_aic;
-		break;
-
-	case PVR_VER(PVR_405GP):
-		ppc4xx_pic = &ppc405_uic;
-		break;
-	}
-
-	return;
-}
-
-/*
- * XXX - Currently 403-specific!
- *
- * Document me.
- */
 int
-ppc4xx_pic_get_irq(struct pt_regs *regs)
+ppc403_pic_get_irq(struct pt_regs *regs)
 {
 	int irq;
-	unsigned long bits, mask = (1 << 31);
+	unsigned long bits;
 
 	/*
 	 * Only report the status of those interrupts that are actually
@@ -117,19 +89,17 @@
 	/*
 	 * Walk through the interrupts from highest priority to lowest, and
 	 * report the first pending interrupt found.
+	 * We want PPC, not C bit numbering, so just subtract the ffs()
+	 * result from 32.
 	 */
+	irq = 32 - ffs(bits);
 
-	for (irq = 0; irq < NR_IRQS; irq++, mask >>= 1) {
-		if (bits & mask)
-			break;
-	}
+	if (irq == NR_AIC_IRQS)
+		irq = -1;
 
 	return (irq);
 }
 
-/*
- * Document me.
- */
 static void
 ppc403_aic_enable(unsigned int irq)
 {
@@ -142,9 +112,6 @@
 	mtdcr(DCRN_EXIER, ppc_cached_irq_mask[word]);
 }
 
-/*
- * Document me.
- */
 static void
 ppc403_aic_disable(unsigned int irq)
 {
@@ -157,9 +124,6 @@
 	mtdcr(DCRN_EXIER, ppc_cached_irq_mask[word]);
 }
 
-/*
- * Document me.
- */
 static void
 ppc403_aic_disable_and_ack(unsigned int irq)
 {
@@ -173,29 +137,308 @@
 	mtdcr(DCRN_EXISR, (1 << (31 - bit)));
 }
 
-/*
- * Document me.
- */
+#else
+
+#ifndef UIC1
+#define UIC1 UIC0
+#endif
+
 static void
 ppc405_uic_enable(unsigned int irq)
 {
-	/* XXX - Implement me. */
+	int bit, word;
+	irq_desc_t *desc = irq_desc + irq;
+
+	bit = irq & 0x1f;
+	word = irq >> 5;
+
+#ifdef UIC_DEBUG
+	printk("ppc405_uic_enable - irq %d word %d bit 0x%x\n", irq, word, bit);
+#endif
+	ppc_cached_irq_mask[word] |= 1 << (31 - bit);
+	switch (word) {
+	case 0:
+		mtdcr(DCRN_UIC_ER(UIC0), ppc_cached_irq_mask[word]);
+		if ((mfdcr(DCRN_UIC_TR(UIC0)) & (1 << (31 - bit))) == 0)
+			desc->status |= IRQ_LEVEL;
+		else
+		/* lets hope this works since in linux/irq.h
+		 * there is no define for EDGE and it's assumed
+		 * once you set status to LEVEL you would not 
+		 * want to change it - Armin
+		 */
+		desc->status = desc->status & ~IRQ_LEVEL;
+		break;
+	case 1:
+		mtdcr(DCRN_UIC_ER(UIC1), ppc_cached_irq_mask[word]);
+		if ((mfdcr(DCRN_UIC_TR(UIC1)) & (1 << (31 - bit))) == 0)
+			desc->status |= IRQ_LEVEL;
+		else
+		/* lets hope this works since in linux/irq.h
+		 * there is no define for EDGE and it's assumed
+		 * once you set status to LEVEL you would not 
+		 * want to change it - Armin
+		 */
+		desc->status = desc->status & ~IRQ_LEVEL;
+	break;
+	}
+
 }
 
-/*
- * Document me.
- */
 static void
 ppc405_uic_disable(unsigned int irq)
 {
-	/* XXX - Implement me. */
+	int bit, word;
+
+	bit = irq & 0x1f;
+	word = irq >> 5;
+#ifdef UIC_DEBUG
+	printk("ppc405_uic_disable - irq %d word %d bit 0x%x\n", irq, word,
+	       bit);
+#endif
+	ppc_cached_irq_mask[word] &= ~(1 << (31 - bit));
+	switch (word) {
+	case 0:
+		mtdcr(DCRN_UIC_ER(UIC0), ppc_cached_irq_mask[word]);
+		break;
+	case 1:
+		mtdcr(DCRN_UIC_ER(UIC1), ppc_cached_irq_mask[word]);
+		break;
+	}
 }
 
-/*
- * Document me.
- */
 static void
 ppc405_uic_disable_and_ack(unsigned int irq)
 {
-	/* XXX - Implement me. */
+	int bit, word;
+
+	bit = irq & 0x1f;
+	word = irq >> 5;
+
+#ifdef UIC_DEBUG
+	printk("ppc405_uic_disable_and_ack - irq %d word %d bit 0x%x\n", irq,
+	       word, bit);
+#endif
+	ppc_cached_irq_mask[word] &= ~(1 << (31 - bit));
+	switch (word) {
+	case 0:
+		mtdcr(DCRN_UIC_ER(UIC0), ppc_cached_irq_mask[word]);
+		mtdcr(DCRN_UIC_SR(UIC0), (1 << (31 - bit)));
+		break;
+#if NR_UICS > 1
+	case 1:
+		mtdcr(DCRN_UIC_ER(UIC1), ppc_cached_irq_mask[word]);
+		mtdcr(DCRN_UIC_SR(UIC1), (1 << (31 - bit)));
+		/* ACK cascaded interrupt in UIC0 */
+		mtdcr(DCRN_UIC_SR(UIC0), (1 << (31 - UIC0_UIC1NC)));
+		break;
+#endif
+	}
+}
+
+static void
+ppc405_uic_end(unsigned int irq)
+{
+	int bit, word;
+	unsigned int tr_bits;
+
+	bit = irq & 0x1f;
+	word = irq >> 5;
+
+#ifdef UIC_DEBUG
+	printk("ppc405_uic_end - irq %d word %d bit 0x%x\n", irq, word, bit);
+#endif
+
+	switch (word) {
+	case 0:
+		tr_bits = mfdcr(DCRN_UIC_TR(UIC0));
+		break;
+	case 1:
+		tr_bits = mfdcr(DCRN_UIC_TR(UIC1));
+		break;
+	}
+
+	if ((tr_bits & (1 << (31 - bit))) == 0) {
+		/* level trigger */
+		switch (word) {
+		case 0:
+			mtdcr(DCRN_UIC_SR(UIC0), 1 << (31 - bit));
+			break;
+#if NR_UICS > 1
+		case 1:
+			mtdcr(DCRN_UIC_SR(UIC1), 1 << (31 - bit));
+			/* ACK cascaded interrupt in UIC0 */
+			mtdcr(DCRN_UIC_SR(UIC0), (1 << (31 - UIC0_UIC1NC)));
+			break;
+#endif
+		}
+	}
+
+	if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
+		ppc_cached_irq_mask[word] |= 1 << (31 - bit);
+		switch (word) {
+		case 0:
+			mtdcr(DCRN_UIC_ER(UIC0), ppc_cached_irq_mask[word]);
+			break;
+		case 1:
+			mtdcr(DCRN_UIC_ER(UIC1), ppc_cached_irq_mask[word]);
+			break;
+		}
+	}
+}
+
+static struct hw_interrupt_type ppc405_uic = {
+#if (NR_UICS == 1)
+	"IBM UIC",
+#else
+	"IBM UIC Cascade",
+#endif
+	NULL,
+	NULL,
+	ppc405_uic_enable,
+	ppc405_uic_disable,
+	ppc405_uic_disable_and_ack,
+	ppc405_uic_end,
+	0
+};
+
+int
+ppc405_pic_get_irq(struct pt_regs *regs)
+{
+	int irq, cas_irq;
+	unsigned long bits;
+	cas_irq = 0;
+	/*
+	 * Only report the status of those interrupts that are actually
+	 * enabled.
+	 */
+
+	bits = mfdcr(DCRN_UIC_MSR(UIC0));
+
+#if (NR_UICS > 1)
+	if (bits & UIC_CASCADE_MASK) {
+		bits = mfdcr(DCRN_UIC_MSR(UIC1));
+		cas_irq = 32 - ffs(bits);
+		irq = 32 + cas_irq;
+	} else {
+		irq = 32 - ffs(bits);
+		if (irq == 32)
+			irq = -1;
+	}
+#else
+	/*
+	 * Walk through the interrupts from highest priority to lowest, and
+	 * report the first pending interrupt found.
+	 * We want PPC, not C bit numbering, so just subtract the ffs()
+	 * result from 32.
+	 */
+	irq = 32 - ffs(bits);
+#endif
+	if (irq == (NR_UIC_IRQS * NR_UICS))
+		irq = -1;
+
+#ifdef UIC_DEBUG
+	printk("ppc405_pic_get_irq - irq %d bit 0x%x\n", irq, bits);
+#endif
+
+	return (irq);
+}
+#endif
+
+void __init
+ppc4xx_extpic_init(void)
+{
+	unsigned int sense, irq;
+	int bit, word;
+	unsigned long ppc_cached_sense_mask[NR_MASK_WORDS];
+	unsigned long ppc_cached_pol_mask[NR_MASK_WORDS];
+	ppc_cached_sense_mask[0] = 0;
+	ppc_cached_sense_mask[1] = 0;
+	ppc_cached_pol_mask[0] = 0;
+	ppc_cached_pol_mask[1] = 0;
+
+	for (irq = 0; irq < NR_IRQS; irq++) {
+
+		bit = irq & 0x1f;
+		word = irq >> 5;
+
+		sense = (irq < ibm4xxPIC_NumInitSenses) ?
+			ibm4xxPIC_InitSenses[irq] :
+			IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE;
+#ifdef PPC4xx_PIC_DEBUG
+		printk("PPC4xx_picext %d word:%x bit:%x sense:%x", irq, word,
+		       bit, sense);
+#endif
+		ppc_cached_sense_mask[word] |=
+		    (sense & IRQ_SENSE_MASK) << (31 - bit);
+		ppc_cached_pol_mask[word] |=
+		    ((~sense & IRQ_POLARITY_MASK) >> 1) << (31 - bit);
+		switch (word) {
+		case 0:
+#ifdef PPC4xx_PIC_DEBUG
+			printk("Pol %x ", mfdcr(DCRN_UIC_PR(UIC0)));
+			printk("Level %x\n", mfdcr(DCRN_UIC_TR(UIC0)));
+#endif
+			/* polarity  setting */
+			mtdcr(DCRN_UIC_PR(UIC0), ppc_cached_pol_mask[word]);
+
+			/* Level setting */
+			mtdcr(DCRN_UIC_TR(UIC0), ppc_cached_sense_mask[word]);
+
+			break;
+		case 1:
+#ifdef PPC4xx_PIC_DEBUG
+			printk("Pol %x ", mfdcr(DCRN_UIC_PR(UIC1)));
+			printk("Level %x\n", mfdcr(DCRN_UIC_TR(UIC1)));
+#endif
+			/* polarity  setting */
+			mtdcr(DCRN_UIC_PR(UIC1), ppc_cached_pol_mask[word]);
+
+			/* Level setting */
+			mtdcr(DCRN_UIC_TR(UIC1), ppc_cached_sense_mask[word]);
+
+			break;
+		}
+	}
+
+}
+void __init
+ppc4xx_pic_init(void)
+{
+
+	/*
+	 * Disable all external interrupts until they are
+	 * explicity requested.
+	 */
+	ppc_cached_irq_mask[0] = 0;
+	ppc_cached_irq_mask[1] = 0;
+
+#if defined CONFIG_403
+	mtdcr(DCRN_EXIER, ppc_cached_irq_mask[0]);
+
+	ppc4xx_pic = &ppc403_aic;
+	ppc_md.get_irq = ppc403_pic_get_irq;
+#else
+#if  (NR_UICS > 1)
+	ppc_cached_irq_mask[0] |= 1 << (31 - UIC0_UIC1NC);	/* enable cascading interrupt */
+	mtdcr(DCRN_UIC_ER(UIC1), ppc_cached_irq_mask[1]);
+	mtdcr(DCRN_UIC_CR(UIC1), 0);
+
+#endif
+	mtdcr(DCRN_UIC_ER(UIC0), ppc_cached_irq_mask[0]);
+	mtdcr(DCRN_UIC_CR(UIC0), 0);
+	
+	if (ibm4xxPIC_InitSenses != NULL)
+		ppc4xx_extpic_init();
+
+	/* Clear any pending interrupts */
+#if (NR_UICS > 1)
+	mtdcr(DCRN_UIC_SR(UIC1), 0xffffffff);
+#endif
+	mtdcr(DCRN_UIC_SR(UIC0), 0xffffffff);
+
+	ppc4xx_pic = &ppc405_uic;
+	ppc_md.get_irq = ppc405_pic_get_irq;
+#endif
+
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/kernel/ppc4xx_setup.c linux-2.4.22-pre2/arch/ppc/kernel/ppc4xx_setup.c
--- linux-2.4.21/arch/ppc/kernel/ppc4xx_setup.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/kernel/ppc4xx_setup.c	2003-06-26 21:43:12.000000000 +0000
@@ -0,0 +1,431 @@
+/*
+ *
+ *    Copyright (c) 1999-2000 Grant Erickson <grant@lcse.umn.edu>
+ *
+ *    Copyright 2000-2002 MontaVista Software Inc.
+ *      Completed implementation.
+ *      Author: MontaVista Software, Inc.  <source@mvista.com>
+ *              Frank Rowand <frank_rowand@mvista.com>
+ *              Debbie Chu   <debbie_chu@mvista.com>
+ *
+ *    Module name: ppc4xx_setup.c
+ *
+ *    Description:
+ *      Architecture- / platform-specific boot-time initialization code for
+ *      IBM PowerPC 4xx based boards. Adapted from original
+ *      code by Gary Thomas, Cort Dougan <cort@fsmlabs.com>, and Dan Malek
+ *      <dan@net4x.com>.
+ *
+ * 	History: 11/09/2001 - armin
+ *	rename board_setup_nvram_access to board_init. board_init is
+ *	used for all other board specific instructions needed during
+ *	platform_init.
+ *	moved RTC to board.c files
+ *	moved VT/FB to board.c files
+ *	moved r/w4 ide to redwood.c
+ *
+ *	History: 04/18/02 - Armin
+ *	added ash to setting CETE bit in calibrate() 
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/smp.h>
+#include <linux/threads.h>
+#include <linux/spinlock.h>
+#include <linux/irq.h>
+#include <linux/reboot.h>
+#include <linux/param.h>
+#include <linux/string.h>
+#include <linux/blk.h>
+#include <linux/pci.h>
+#include <linux/rtc.h>
+#include <linux/console.h>
+#include <linux/ide.h>
+#include <linux/serial_reg.h>
+#include <linux/seq_file.h>
+#include <linux/module.h>
+
+#include <asm/system.h>
+#include <asm/processor.h>
+#include <asm/machdep.h>
+#include <asm/page.h>
+#include <asm/kgdb.h>
+#include <asm/ibm4xx.h>
+#include <asm/time.h>
+#include <asm/todc.h>
+#include <asm/ppc4xx_pic.h>
+#include <asm/pci-bridge.h>
+#include <asm/bootinfo.h>
+
+/* Function Prototypes */
+static void ppc4xx_gdb_init(void);
+
+extern void abort(void);
+extern void ppc4xx_find_bridges(void);
+
+extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode);
+extern int pckbd_getkeycode(unsigned int scancode);
+extern int pckbd_pretranslate(unsigned char scancode, char raw_mode);
+extern int pckbd_translate(unsigned char scancode, unsigned char *keycode,
+			   char raw_mode);
+extern char pckbd_unexpected_up(unsigned char keycode);
+extern void pckbd_leds(unsigned char leds);
+extern void pckbd_init_hw(void);
+
+extern int nonpci_ide_default_irq(ide_ioreg_t base);
+extern void nonpci_ide_init_hwif_ports(hw_regs_t * hw, ide_ioreg_t data_port,
+				       ide_ioreg_t ctrl_port, int *irq);
+
+extern void ppc4xx_wdt_heartbeat(void);
+extern int wdt_enable;
+extern unsigned long wdt_period;
+//extern void early_uart_init(void);
+
+/* Board specific functions */
+extern void board_setup_arch(void);
+extern void board_io_mapping(void);
+extern void board_setup_irq(void);
+extern void board_init(void);
+
+/* Global Variables */
+unsigned char __res[sizeof (bd_t)];
+
+#if defined(EMAC_NUMS) && EMAC_NUMS > 0
+u32 emac_phy_map[EMAC_NUMS];
+EXPORT_SYMBOL(emac_phy_map);
+#endif
+
+static void __init
+ppc4xx_setup_arch(void)
+{
+
+	/* Setup PCI host bridges */
+
+#ifdef CONFIG_PCI
+	ppc4xx_find_bridges();
+#endif
+
+#if defined(CONFIG_FB)
+	conswitchp = &dummy_con;
+#endif
+#if defined (CONFIG_SERIAL) && !defined (CONFIG_RAINIER)
+//	early_uart_init();
+#endif
+	board_setup_arch();
+
+	ppc4xx_gdb_init();
+}
+
+/*
+ *   This routine pretty-prints the platform's internal CPU clock
+ *   frequencies into the buffer for usage in /proc/cpuinfo.
+ */
+
+static int
+ppc4xx_show_percpuinfo(struct seq_file *m, int i)
+{
+	bd_t *bip = (bd_t *) __res;
+
+	seq_printf(m, "clock\t\t: %ldMHz\n", (long) bip->bi_intfreq / 1000000);
+
+	return 0;
+}
+
+/*
+ *   This routine pretty-prints the platform's internal bus clock
+ *   frequencies into the buffer for usage in /proc/cpuinfo.
+ */
+static int
+ppc4xx_show_cpuinfo(struct seq_file *m)
+{
+	bd_t *bip = (bd_t *) __res;
+
+	seq_printf(m, "machine\t\t: %s\n", PPC4xx_MACHINE_NAME);
+	seq_printf(m, "plb bus clock\t: %ldMHz\n",
+		   (long) bip->bi_busfreq / 1000000);
+#ifdef CONFIG_PCI
+	seq_printf(m, "pci bus clock\t: %dMHz\n",
+		   bip->bi_pci_busfreq / 1000000);
+#endif
+
+	return 0;
+}
+
+/*
+ * Return the virtual address representing the top of physical RAM.
+ */
+static unsigned long __init
+ppc4xx_find_end_of_memory(void)
+{
+	bd_t *bip = (bd_t *) __res;
+
+	return ((unsigned long) bip->bi_memsize);
+}
+
+static void __init
+m4xx_map_io(void)
+{
+	io_block_mapping(PPC4xx_ONB_IO_VADDR,
+			 PPC4xx_ONB_IO_PADDR, PPC4xx_ONB_IO_SIZE, _PAGE_IO);
+#ifdef CONFIG_PCI
+	io_block_mapping(PPC4xx_PCI_IO_VADDR,
+			 PPC4xx_PCI_IO_PADDR, PPC4xx_PCI_IO_SIZE, _PAGE_IO);
+	io_block_mapping(PPC4xx_PCI_CFG_VADDR,
+			 PPC4xx_PCI_CFG_PADDR, PPC4xx_PCI_CFG_SIZE, _PAGE_IO);
+	io_block_mapping(PPC4xx_PCI_LCFG_VADDR,
+			 PPC4xx_PCI_LCFG_PADDR, PPC4xx_PCI_LCFG_SIZE, _PAGE_IO);
+#endif
+	board_io_mapping();
+}
+
+static void __init
+ppc4xx_init_IRQ(void)
+{
+	int i;
+
+	ppc4xx_pic_init();
+
+	for (i = 0; i < NR_IRQS; i++)
+		irq_desc[i].handler = ppc4xx_pic;
+
+	/* give board specific code a chance to setup things */
+	board_setup_irq();
+	return;
+}
+
+static void
+ppc4xx_restart(char *cmd)
+{
+	printk("%s\n", cmd);
+	abort();
+}
+
+static void
+ppc4xx_halt(void)
+{
+	printk("System Halted\n");
+	__cli();
+	while (1) ;
+}
+
+static void __init
+ppc4xx_gdb_init(void)
+{
+#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));
+	mtspr(SPRN_DBCR1, 0);
+#endif
+}
+
+/*
+ * This routine retrieves the internal processor frequency from the board
+ * information structure, sets up the kernel timer decrementer based on
+ * that value, enables the 4xx programmable interval timer (PIT) and sets
+ * it up for auto-reload.
+ */
+static void __init
+ppc4xx_calibrate_decr(void)
+{
+	unsigned int freq;
+	bd_t *bip = (bd_t *) __res;
+
+#if defined(CONFIG_WALNUT) || defined(CONFIG_CEDER) 	\
+	|| defined(CONFIG_ASH) || defined(CONFIG_SYCAMORE)
+	/* Openbios sets cpu  timers to CPU clk
+	 * we want to use the external clk 
+	 * DCR CHCR1 (aka CPC0_CR1) bit CETE to 1 */
+
+	mtdcr(DCRN_CHCR1, mfdcr(DCRN_CHCR1) & ~CHR1_CETE);
+#endif
+
+	freq = bip->bi_tbfreq;
+//	tb_ticks_per_jiffy = freq / HZ;
+//	tb_to_us = mulhwu_scale_factor(freq, 1000000);
+	tb_ticks_per_jiffy = (freq + HZ/2) / HZ;
+	tb_to_us = mulhwu_scale_factor(tb_ticks_per_jiffy*HZ, 1000000U);
+
+	/* Set the time base to zero.
+	   ** At 200 Mhz, time base will rollover in ~2925 years.
+	 */
+
+	mtspr(SPRN_TBWL, 0);
+	mtspr(SPRN_TBWU, 0);
+
+	/* Clear any pending timer interrupts */
+
+	mtspr(SPRN_TSR, TSR_ENW | TSR_WIS | TSR_PIS | TSR_FIS);
+	mtspr(SPRN_TCR, TCR_PIE | TCR_ARE);
+
+	/* 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", s);
+#endif
+}
+#endif				/* CONFIG_SERIAL_TEXT_DEBUG */
+
+/*
+ * IDE stuff.
+ * should be generic for every IDE PCI chipset
+ */
+#if defined(CONFIG_BLK_DEV_IDEPCI)
+static void
+ppc4xx_ide_init_hwif_ports(hw_regs_t * hw, ide_ioreg_t data_port,
+			   ide_ioreg_t ctrl_port, int *irq)
+{
+	int i;
+
+	for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; ++i)
+		hw->io_ports[i] = data_port + i - IDE_DATA_OFFSET;
+
+	hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
+}
+#endif
+
+TODC_ALLOC();
+
+/*
+ * Input(s):
+ *   r3 - Optional pointer to a board information structure.
+ *   r4 - Optional pointer to the physical starting address of the init RAM
+ *        disk.
+ *   r5 - Optional pointer to the physical ending address of the init RAM
+ *        disk.
+ *   r6 - Optional pointer to the physical starting address of any kernel
+ *        command-line parameters.
+ *   r7 - Optional pointer to the physical ending address of any kernel
+ *        command-line parameters.
+ */
+void __init
+platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
+	      unsigned long r6, unsigned long r7)
+{
+	parse_bootinfo(find_bootinfo());
+
+	/*
+	 * If we were passed in a board information, copy it into the
+	 * residual data area.
+	 */
+	if (r3) {
+		memcpy((void *) __res, (void *) (r3 + KERNELBASE),
+		       sizeof (bd_t));
+
+	}
+#if defined(CONFIG_BLK_DEV_INITRD)
+	/*
+	 * If the init RAM disk has been configured in, and there's a valid
+	 * starting address for it, set it up.
+	 */
+	if (r4) {
+		initrd_start = r4 + KERNELBASE;
+		initrd_end = r5 + KERNELBASE;
+	}
+#endif				/* CONFIG_BLK_DEV_INITRD */
+
+	/* Copy the kernel command line arguments to a safe place. */
+
+	if (r6) {
+		*(char *) (r7 + KERNELBASE) = 0;
+		strcpy(cmd_line, (char *) (r6 + KERNELBASE));
+	}
+#if defined(CONFIG_PPC405_WDT)
+	ppc_md.heartbeat = ppc4xx_wdt_heartbeat;
+
+/* Look for wdt= option on command line */
+	if (strstr(cmd_line, "wdt=")) {
+		int valid_wdt = 0;
+		char *p, *q;
+		for (q = cmd_line; (p = strstr(q, "wdt=")) != 0;) {
+			q = p + 4;
+			if (p > cmd_line && p[-1] != ' ')
+				continue;
+			wdt_period = simple_strtoul(q, &q, 0);
+			valid_wdt = 1;
+			++q;
+		}
+		wdt_enable = valid_wdt;
+	}
+#endif
+
+	/* Initialize machine-dependency vectors */
+
+	ppc_md.setup_arch = ppc4xx_setup_arch;
+	ppc_md.show_percpuinfo = ppc4xx_show_percpuinfo;
+	ppc_md.show_cpuinfo = ppc4xx_show_cpuinfo;
+	ppc_md.init_IRQ = ppc4xx_init_IRQ;
+
+	ppc_md.restart = ppc4xx_restart;
+	ppc_md.power_off = ppc4xx_halt;
+	ppc_md.halt = ppc4xx_halt;
+
+	ppc_md.calibrate_decr = ppc4xx_calibrate_decr;
+
+	ppc_md.find_end_of_memory = ppc4xx_find_end_of_memory;
+	ppc_md.setup_io_mappings = m4xx_map_io;
+
+#ifdef CONFIG_SERIAL_TEXT_DEBUG
+	ppc_md.progress = ppc4xx_progress;
+#endif
+#ifdef CONFIG_KGDB
+//	ppc_md.early_serial_map = early_uart_init;
+#endif
+#if defined(CONFIG_VT) && defined(CONFIG_PC_KEYBOARD)
+#if defined(CONFIG_REDWOOD_4) && defined(CONFIG_STB_KB)
+	redwood_irkb_init();
+#else
+	ppc_md.kbd_setkeycode = pckbd_setkeycode;
+	ppc_md.kbd_getkeycode = pckbd_getkeycode;
+	ppc_md.kbd_translate = pckbd_translate;
+	ppc_md.kbd_unexpected_up = pckbd_unexpected_up;
+	ppc_md.kbd_leds = pckbd_leds;
+	ppc_md.kbd_init_hw = pckbd_init_hw;
+#endif
+#endif
+
+/*
+**   m8xx_setup.c, prep_setup.c use
+**     defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
+*/
+#if defined (CONFIG_IDE)
+#if defined(CONFIG_BLK_DEV_IDEPCI)
+	ppc_ide_md.ide_init_hwif = ppc4xx_ide_init_hwif_ports;
+#elif defined (CONFIG_DMA_NONPCI)	/* ON board IDE */
+	ppc_ide_md.default_irq = nonpci_ide_default_irq;
+	ppc_ide_md.ide_init_hwif = nonpci_ide_init_hwif_ports;
+#endif
+#endif
+	board_init();
+
+	return;
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/kernel/ppc_htab.c linux-2.4.22-pre2/arch/ppc/kernel/ppc_htab.c
--- linux-2.4.21/arch/ppc/kernel/ppc_htab.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/kernel/ppc_htab.c	2003-06-26 21:43:11.000000000 +0000
@@ -441,18 +441,18 @@
     }
 }
 
+#define TMPBUFLEN 512
 int proc_dol2crvec(ctl_table *table, int write, struct file *filp,
 		  void *buffer, size_t *lenp)
 {
 	int vleft, first=1, len, left, val;
-	#define TMPBUFLEN 256
 	char buf[TMPBUFLEN], *p;
 	static const char *sizestrings[4] = {
 		"2MB", "256KB", "512KB", "1MB"
 	};
 	static const char *clockstrings[8] = {
-		"clock disabled", "+1 clock", "+1.5 clock", "reserved(3)",
-		"+2 clock", "+2.5 clock", "+3 clock", "reserved(7)"
+		"clock disabled", "+1 clock", "+1.5 clock", "+3.5 clock",
+		"+2 clock", "+2.5 clock", "+3 clock", "+4 clock"
 	};
 	static const char *typestrings[4] = {
 		"flow-through burst SRAM", "reserved SRAM",
@@ -508,21 +508,43 @@
 				*p++ = '\t';
 			val = _get_L2CR();
 			p += sprintf(p, "0x%08x: ", val);
-			p += sprintf(p, " %s", (val >> 31) & 1 ? "enabled" :
+			p += sprintf(p, " L2 %s", (val >> 31) & 1 ? "enabled" :
 				     	"disabled");
 			p += sprintf(p, ", %sparity", (val>>30)&1 ? "" : "no ");
-			p += sprintf(p, ", %s", sizestrings[(val >> 28) & 3]);
-			p += sprintf(p, ", %s", clockstrings[(val >> 25) & 7]);
-			p += sprintf(p, ", %s", typestrings[(val >> 23) & 2]);
-			p += sprintf(p, "%s", (val>>22)&1 ? ", data only" : "");
-			p += sprintf(p, "%s", (val>>20)&1 ? ", ZZ enabled": "");
-			p += sprintf(p, ", %s", (val>>19)&1 ? "write-through" :
-					"copy-back");
-			p += sprintf(p, "%s", (val>>18)&1 ? ", testing" : "");
-			p += sprintf(p, ", %sns hold",holdstrings[(val>>16)&3]);
-			p += sprintf(p, "%s", (val>>15)&1 ? ", DLL slow" : "");
-			p += sprintf(p, "%s", (val>>14)&1 ? ", diff clock" :"");
-			p += sprintf(p, "%s", (val>>13)&1 ? ", DLL bypass" :"");
+
+			/* 75x & 74x0 have different L2CR than 745x */
+			if (!(cur_cpu_spec[0]->cpu_features &
+						CPU_FTR_SPEC7450)) {
+				p += sprintf(p, ", %s",
+					sizestrings[(val >> 28) & 3]);
+				p += sprintf(p, ", %s",
+					clockstrings[(val >> 25) & 7]);
+				p += sprintf(p, ", %s",
+					typestrings[(val >> 23) & 3]);
+				p += sprintf(p, "%s", (val>>22)&1 ?
+					", data only" : "");
+				p += sprintf(p, "%s", (val>>20)&1 ?
+					", ZZ enabled": "");
+				p += sprintf(p, ", %s", (val>>19)&1 ?
+					"write-through" : "copy-back");
+				p += sprintf(p, "%s", (val>>18)&1 ?
+					", testing" : "");
+				p += sprintf(p, ", %sns hold",
+					holdstrings[(val>>16)&3]);
+				p += sprintf(p, "%s", (val>>15)&1 ?
+					", DLL slow" : "");
+				p += sprintf(p, "%s", (val>>14)&1 ?
+					", diff clock" :"");
+				p += sprintf(p, "%s", (val>>13)&1 ?
+					", DLL bypass" :"");
+			} else { /* 745x */
+				p += sprintf(p, ", %sinstn only", (val>>20)&1 ?
+					"" : "no ");
+				p += sprintf(p, ", %sdata only", (val>>16)&1 ?
+					"" : "no ");
+				p += sprintf(p, ", %s replacement",
+					(val>>12)&1 ?  "secondary" : "default");
+			}
 			
 			p += sprintf(p,"\n");
 			
@@ -559,3 +581,95 @@
 	filp->f_pos += *lenp;
 	return 0;
 }
+
+int proc_dol3crvec(ctl_table *table, int write, struct file *filp,
+		  void *buffer, size_t *lenp)
+{
+	int vleft, first=1, len, left, val;
+	char buf[TMPBUFLEN], *p;
+	static const char *clockstrings[8] = {
+		"+6 clock", "reserved(1)", "+2 clock", "+2.5 clock",
+		"+3 clock", "+3.5 clock", "+4 clock", "+5 clock"
+	};
+	static const char *clocksampstrings[4] = {
+		"2 clock", "3 clock", "4 clock", "5 clock"
+	};
+	static const char *pclocksampstrings[8] = {
+		"0 P-clock", "1 P-clock", "2 P-clock", "3 P-clock",
+		"4 P-clock", "5 P-clock", "reserved(6)", "reserved(7)"
+	};
+	static const char *typestrings[4] = {
+		"MSUG2 DDR SRAM",
+		"Pipelined synchronous late-write SRAM",
+		"Reserved", "PB2 SRAM"
+	};
+
+	if (!(cur_cpu_spec[0]->cpu_features & CPU_FTR_L3CR))
+		return -EFAULT;
+	if (write)
+		return -EFAULT;
+	
+	if (filp->f_pos && !write) {
+		*lenp = 0;
+		return 0;
+	}
+	
+	vleft = table->maxlen / sizeof(int);
+	left = *lenp;
+
+	for (; left; first=0) {
+		p = buf;
+		if (!first)
+			*p++ = '\t';
+		val = _get_L3CR();
+		p += sprintf(p, "0x%08x: ", val);
+		p += sprintf(p, " L3 %s", (val >> 31) & 1 ? "enabled" :
+			     	"disabled");
+		p += sprintf(p, ", %sdata parity", (val>>30)&1 ? "" :
+				"no ");
+		p += sprintf(p, ", %saddr parity", (val>>29)&1 ? "" :
+				"no ");
+		p += sprintf(p, ", %s", (val>>28)&1 ? "2MB" : "1MB");
+		p += sprintf(p, ", clocks %s", (val>>27)&1 ? "enabled" :
+				"disabled");
+		p += sprintf(p, ", %s", clockstrings[(val >> 23) & 7]);
+		p += sprintf(p, ", %sinstn only", (val>>22)&1 ? "" :
+				"no ");
+		p += sprintf(p, ", %ssample point override",
+				(val>>18)&1 ? "" : "no ");
+		p += sprintf(p, ", %s sample point",
+				clocksampstrings[(val>>16)&3]);
+		p += sprintf(p, ", %s sample point",
+				pclocksampstrings[(val>>13)&7]);
+		p += sprintf(p, ", %s replacement", (val>>12)&1 ?
+				"secondary" : "default");
+		p += sprintf(p, ", %s", typestrings[(val >> 8) & 3]);
+		p += sprintf(p, ", %sclock cntl", (val>>7)&1 ? "" :
+				"no ");
+		p += sprintf(p, ", %sdata only", (val>>6)&1 ? "" :
+				"no ");
+		p += sprintf(p, ", private mem %s", (val>>2)&1 ?
+				"enabled" : "disabled");
+		p += sprintf(p, ", %sprivate mem", val&1 ? "2MB " :
+				"1MB ");
+		p += sprintf(p,"\n");
+		
+		len = strlen(buf);
+		if (len > left)
+			len = left;
+		if(copy_to_user(buffer, buf, len))
+			return -EFAULT;
+		left -= len;
+		buffer += len;
+		break;
+	}
+
+	if (!write && !first && left) {
+		if(put_user('\n', (char *) buffer))
+			return -EFAULT;
+		left--, buffer++;
+	}
+	*lenp -= left;
+	filp->f_pos += *lenp;
+	return 0;
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/kernel/process.c linux-2.4.22-pre2/arch/ppc/kernel/process.c
--- linux-2.4.21/arch/ppc/kernel/process.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/kernel/process.c	2003-06-26 21:43:21.000000000 +0000
@@ -250,20 +250,33 @@
 	       regs->msr & MSR_FP ? 1 : 0,regs->msr&MSR_ME ? 1 : 0,
 	       regs->msr&MSR_IR ? 1 : 0,
 	       regs->msr&MSR_DR ? 1 : 0);
+#ifdef CONFIG_4xx
+	/*
+	 * TRAP 0x800 is the hijacked FPU unavailable exception vector
+	 * on 40x used to implement the heavyweight data access
+	 * functionality.  It is an emulated value (like all trap
+	 * vectors) on 440.
+	 */
+	if (regs->trap == 0x300 || regs->trap == 0x600 || regs->trap == 0x800)
+		printk("DEAR: %08lX, ESR: %08lX\n", regs->dar, regs->dsisr);
+#else
 	if (regs->trap == 0x300 || regs->trap == 0x600)
 		printk("DAR: %08lX, DSISR: %08lX\n", regs->dar, regs->dsisr);
+#endif
 	printk("TASK = %p[%d] '%s' ",
 	       current, current->pid, current->comm);
 	printk("Last syscall: %ld ", current->thread.last_syscall);
 	printk("\nlast math %p last altivec %p", last_task_used_math,
 	       last_task_used_altivec);
 
-#ifdef CONFIG_4xx
+#if defined(CONFIG_4xx) && defined(DCRN_PLB0_BEAR)
 	printk("\nPLB0: bear= 0x%8.8x acr=   0x%8.8x besr=  0x%8.8x\n",
-	    mfdcr(DCRN_POB0_BEAR), mfdcr(DCRN_PLB0_ACR),
+	    mfdcr(DCRN_PLB0_BEAR), mfdcr(DCRN_PLB0_ACR),
 	    mfdcr(DCRN_PLB0_BESR));
+#endif
+#if defined(CONFIG_4xx) && defined(DCRN_POB0_BEAR)
 	printk("PLB0 to OPB: bear= 0x%8.8x besr0= 0x%8.8x besr1= 0x%8.8x\n",
-	    mfdcr(DCRN_PLB0_BEAR), mfdcr(DCRN_POB0_BESR0),
+	    mfdcr(DCRN_POB0_BEAR), mfdcr(DCRN_POB0_BESR0),
 	    mfdcr(DCRN_POB0_BESR1));
 #endif
 	
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/kernel/ptrace.c linux-2.4.22-pre2/arch/ppc/kernel/ptrace.c
--- linux-2.4.21/arch/ppc/kernel/ptrace.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/kernel/ptrace.c	2003-06-26 21:43:14.000000000 +0000
@@ -33,7 +33,11 @@
 /*
  * Set of msr bits that gdb can change on behalf of a process.
  */
+#if defined(CONFIG_4xx)
+#define MSR_DEBUGCHANGE	(0)
+#else
 #define MSR_DEBUGCHANGE	(MSR_FE0 | MSR_SE | MSR_BE | MSR_FE1)
+#endif
 
 /*
  * does not yet catch signals sent when the child dies.
@@ -129,18 +133,27 @@
 set_single_step(struct task_struct *task)
 {
 	struct pt_regs *regs = task->thread.regs;
-
+#if defined(CONFIG_4xx)
+	regs->msr |= MSR_DE;
+	task->thread.dbcr0 |=  (DBCR0_IDM | DBCR0_IC);
+#else
 	if (regs != NULL)
 		regs->msr |= MSR_SE;
+#endif
+
 }
 
 static inline void
 clear_single_step(struct task_struct *task)
 {
 	struct pt_regs *regs = task->thread.regs;
-
+#if defined(CONFIG_4xx)
+	regs->msr &= ~MSR_DE;
+	task->thread.dbcr0 &=  ~DBCR0_IC;
+#else
 	if (regs != NULL)
 		regs->msr &= ~MSR_SE;
+#endif
 }
 
 /*
@@ -275,6 +288,12 @@
 		child->exit_code = data;
 		/* make sure the single step bit is not set. */
 		clear_single_step(child);
+#ifdef CONFIG_4xx
+		/* ...but traps may be set, so catch those....
+		*/
+		child->thread.regs->msr   |= MSR_DE;
+		child->thread.dbcr0 |= (DBCR0_IDM | DBCR0_TDE);
+#endif
 		wake_up_process(child);
 		ret = 0;
 		break;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/kernel/traps.c linux-2.4.22-pre2/arch/ppc/kernel/traps.c
--- linux-2.4.21/arch/ppc/kernel/traps.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/kernel/traps.c	2003-06-26 21:43:13.000000000 +0000
@@ -167,7 +167,7 @@
 #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
 /* On 4xx, the reason for the machine check or program exception
    is in the ESR. */
-#define get_reason(regs)	mfspr(SPRN_ESR);
+#define get_reason(regs)	((regs)->dsisr)
 #define REASON_FP		0
 #define REASON_ILLEGAL		ESR_PIL
 #define REASON_PRIVILEGED	ESR_PPR
@@ -213,7 +213,7 @@
 		printk("Data");
 	printk(" machine check in kernel mode.\n");
 
-#else /* CONFIG_4xx */
+#else /* !CONFIG_4xx */
 	printk("Machine check in kernel mode.\n");
 	printk("Caused by (from SRR1=%lx): ", reason);
 	switch (reason & 0x601F0000) {
@@ -327,7 +327,14 @@
 	extern int do_mathemu(struct pt_regs *regs);
 
 #ifdef CONFIG_MATH_EMULATION
-	if ((reason & REASON_ILLEGAL) && do_mathemu(regs) == 0)
+	/* (reason & REASON_ILLEGAL) would be the obvious thing here,
+	 * but there seems to be a hardware bug on the 405GP (RevD)
+	 * that means ESR is sometimes set incorrectly - either to
+	 * ESR_DST (!?) or 0.  In the process of chasing this with the
+	 * hardware people - not sure if it can happen on any illegal
+	 * instruction or only on FP instructions, whether there is a
+	 * pattern to occurences etc. -dgibson 31/Mar/2003 */
+	if (!(reason & REASON_TRAP) && do_mathemu(regs) == 0)
 		return;
 #endif /* CONFIG_MATH_EMULATION */
 
@@ -450,6 +457,35 @@
 }
 #endif /* CONFIG_8xx */
 
+#if defined(CONFIG_4xx)
+
+void DebugException(struct pt_regs *regs)
+{
+	unsigned long debug_status;
+
+	debug_status = mfspr(SPRN_DBSR);
+
+	regs->msr &= ~MSR_DE;  /* Turn off 'debug' bit */
+	if (debug_status & DBSR_TIE) {		/* trap instruction*/
+
+		mtspr(SPRN_DBSR, DBSR_TIE);
+
+		if (!user_mode(regs) && debugger_bpt(regs))
+			return;
+		_exception(SIGTRAP, regs, 0, 0);
+
+	} else if (debug_status & DBSR_IC) {	/* instruction completion */
+
+		mtspr(SPRN_DBSR, DBSR_IC);
+		current->thread.dbcr0 &=  ~DBCR0_IC;
+
+		if (!user_mode(regs) && debugger_sstep(regs))
+			return;
+		_exception(SIGTRAP, regs, 0, 0);
+	}
+}
+#endif /* CONFIG_4xx */
+
 #if !defined(CONFIG_TAU_INT)
 void
 TAUException(struct pt_regs *regs)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/mm/4xx_mmu.c linux-2.4.22-pre2/arch/ppc/mm/4xx_mmu.c
--- linux-2.4.21/arch/ppc/mm/4xx_mmu.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/mm/4xx_mmu.c	2003-06-26 21:43:10.000000000 +0000
@@ -51,11 +51,6 @@
 #include <asm/machdep.h>
 #include <asm/setup.h>
 
-/* Used by the 4xx TLB replacement exception handler.
- * Just needed it declared someplace (and initialized to zero).
- */
-unsigned int tlb_4xx_index;
-
 /*
  * MMU_init_hw does the chip-specific initialization of the MMU hardware.
  */
@@ -89,7 +84,14 @@
 	 * Cache instruction and data space where the exception
 	 * vectors and the kernel live in real-mode.
 	 */
+	/*
+	 * Once the following code is enhanced to not assume that it should
+	 * just enable caching on the first 512MB, we need to make sure that
+	 * we either are given the cache in a known state or handle correctly
+	 * the cache being enabled previously.  Currently this will clear
+	 * without flushing. -- Tom
+	 */
 
-        mtspr(SPRN_DCCR, 0x80000000);	/* 128 MB of data space at 0x0. */
-        mtspr(SPRN_ICCR, 0x80000000);	/* 128 MB of instr. space at 0x0. */
+        mtspr(SPRN_DCCR, 0xF0000000);	/* 512 MB of data space at 0x0. */
+        mtspr(SPRN_ICCR, 0xF0000000);	/* 512 MB of instr. space at 0x0. */
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/mm/4xx_tlb.c linux-2.4.22-pre2/arch/ppc/mm/4xx_tlb.c
--- linux-2.4.21/arch/ppc/mm/4xx_tlb.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/mm/4xx_tlb.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,358 +0,0 @@
-/*
- *
- *    Copyright (c) 1998-1999 TiVo, Inc.
- *      Original implementation.
- *    Copyright (c) 1999-2000 Grant Erickson <grant@lcse.umn.edu>
- *      Minor rework.
- *
- *    Module name: 4xx_tlb.c
- *
- *    Description:
- *      Routines for manipulating the TLB on PowerPC 400-class processors.
- *
- */
-
-#include <linux/mm.h>
-
-#include <asm/processor.h>
-#include <asm/io.h>
-#include <asm/mmu.h>
-#include <asm/pgtable.h>
-#include <asm/system.h>
-
-
-/* Preprocessor Defines */
-
-#if !defined(TRUE) || TRUE != 1
-#define TRUE    1
-#endif
-
-#if !defined(FALSE) || FALSE != 0
-#define FALSE   0
-#endif
-
-
-/* Global Variables */
-
-static int pinned = 0;
-
-
-/* Function Prototypes */
-
-static int PPC4xx_tlb_miss(struct pt_regs *, unsigned long, int);
-
-extern void do_page_fault(struct pt_regs *, unsigned long, unsigned long);
-
-
-/*
- * ()
- *
- * Description:
- *   This routine...
- *
- * Input(s):
- *
- *
- * Output(s):
- *
- *
- * Returns:
- *
- *
- */
-static inline void
-PPC4xx_tlb_write(unsigned long tag, unsigned long data, unsigned int index)
-{
-	asm("tlbwe %0,%1,1" : : "r" (data), "r" (index));
-	asm("tlbwe %0,%1,0" : : "r" (tag), "r" (index));
-}
-
-/*
- * ()
- *
- * Description:
- *   This routine...
- *
- * Input(s):
- *
- *
- * Output(s):
- *
- *
- * Returns:
- *
- *
- */
-void
-PPC4xx_flush_tlb_all(void)
-{
-	int i;
-	unsigned long flags, pid;
-
-	save_flags(flags);
-	cli();
-
-	pid = mfspr(SPRN_PID);
-	mtspr(SPRN_PID, 0);
-
-	for (i = pinned; i < PPC4XX_TLB_SIZE; i++) {
-		PPC4xx_tlb_write(0, 0, i);
-	}
-	asm("sync;isync");
-
-	mtspr(SPRN_PID, pid);
-	restore_flags(flags);
-}
-
-/*
- * ()
- *
- * Description:
- *   This routine...
- *
- * Input(s):
- *
- *
- * Output(s):
- *
- *
- * Returns:
- *
- *
- */
-void
-PPC4xx_dtlb_miss(struct pt_regs *regs)
-{
-	unsigned long addr = mfspr(SPRN_DEAR);
-	int write = mfspr(SPRN_ESR) & ESR_DST;
-
-	if (PPC4xx_tlb_miss(regs, addr, write) < 0) {
-		sti();
-		do_page_fault(regs, addr, write);
-		cli();
-	}
-	
-}
-
-/*
- * ()
- *
- * Description:
- *   This routine...
- *
- * Input(s):
- *
- *
- * Output(s):
- *
- *
- * Returns:
- *
- *
- */
-void
-PPC4xx_itlb_miss(struct pt_regs *regs)
-{
-	unsigned long addr = regs->nip;
-
-	if (PPC4xx_tlb_miss(regs, addr, 0) < 0) {
-		sti();
-		do_page_fault(regs, addr, 0);
-		cli();
-	}
-}
-
-/*
- * ()
- *
- * Description:
- *   This routine...
- *
- * Input(s):
- *
- *
- * Output(s):
- *
- *
- * Returns:
- *
- *
- */
-void
-PPC4xx_tlb_pin(unsigned long va, unsigned long pa, int pagesz, int cache)
-{
-	unsigned long tag, data;
-	unsigned long opid;
-
-	if (pinned >= PPC4XX_TLB_SIZE)
-		return;
-
-	opid = mfspr(SPRN_PID);
-	mtspr(SPRN_PID, 0);
-
-	data = (pa & TLB_RPN_MASK) | TLB_WR;
-
-	if (cache)
-		data |= (TLB_EX);
-	else
-		data |= (TLB_G | TLB_I);
-
-	tag = (va & TLB_EPN_MASK) | TLB_VALID | pagesz;
-
-	PPC4xx_tlb_write(tag, data, pinned++);
-
-	mtspr(SPRN_PID, opid);
-	return;
-}
-
-/*
- * ()
- *
- * Description:
- *   This routine...
- *
- * Input(s):
- *
- *
- * Output(s):
- *
- *
- * Returns:
- *
- *
- */
-void
-PPC4xx_tlb_unpin(unsigned long va, unsigned long pa, int size)
-{
-	/* XXX - To be implemented. */
-}
-
-/*
- * ()
- *
- * Description:
- *   This routine...
- *
- * Input(s):
- *
- *
- * Output(s):
- *
- *
- * Returns:
- *
- *
- */
-static inline void
-PPC4xx_tlb_update(unsigned long addr, pte_t *pte)
-{
-        unsigned long data, tag, rand;
-        int i, found = 1;
-
-        /* Construct the hardware TLB entry from the Linux-style PTE */
-
-        tag = tag = (addr & PAGE_MASK) | TLB_VALID | TLB_PAGESZ(PAGESZ_4K);
-        data = data = (pte_val(*pte) & PAGE_MASK) | TLB_EX | TLB_WR;
-
-#if 0
-        if (pte_val(*pte) & _PAGE_HWWRITE)
-                data |= TLB_WR;
-#endif
-
-        if (pte_val(*pte) & _PAGE_NO_CACHE)
-                data |= TLB_I;
-
-        if (pte_val(*pte) & _PAGE_GUARDED)
-                data |= TLB_G;
-
-        if (addr < KERNELBASE)
-                data |= TLB_ZSEL(1);
-
-        /* Attempt to match the new tag to an existing entry in the TLB. */
-
-        asm("tlbsx. %0,0,%2;"
-	    "beq 1f;"
-	    "li %1,0;1:" : "=r" (i), "=r" (found) : "r" (tag));
-
-	/*
-	 * If we found a match for the tag, reuse the entry index and update
-	 * the tag and data portions. Otherwise, we did not find a match. Use
-	 * the lower 5 bits of the lower time base register as a pseudo-random
-	 * index into the TLB and replace the entry at that index.
-	 */
-
-        if (found) {
-		PPC4xx_tlb_write(tag, data, i);
-        } else {
-		rand = mfspr(SPRN_TBLO) & (PPC4XX_TLB_SIZE - 1);
-		rand += pinned;
-		if (rand >= PPC4XX_TLB_SIZE)
-			rand -= pinned;
-
-		PPC4xx_tlb_write(tag, data, rand);
-		asm("isync;sync");
-        }
-}
-
-/*
- * ()
- *
- * Description:
- *   This routine...
- *
- * Input(s):
- *
- *
- * Output(s):
- *
- *
- * Returns:
- *
- *
- */
-static int
-PPC4xx_tlb_miss(struct pt_regs *regs, unsigned long addr, int write)
-{
-        unsigned long spid, ospid;
-        struct mm_struct *mm;
-        pgd_t *pgd;
-        pmd_t *pmd;
-        pte_t *pte;
-
-        if (!user_mode(regs) && (addr >= KERNELBASE)) {
-                mm = &init_mm;
-                spid = 0;
-        } else {
-                mm = current->mm;
-                spid = mfspr(SPRN_PID);
-        }
-
-        pgd = pgd_offset(mm, addr);
-        if (pgd_none(*pgd))
-                goto bad;
-
-        pmd = pmd_offset(pgd, addr);
-        if (pmd_none(*pmd))
-                goto bad;
-
-        pte = pte_offset(pmd, addr);
-        if (pte_none(*pte) || !pte_present(*pte))
-                goto bad;
-
-        if (write) {
-                if (!pte_write(*pte))
-                        goto bad;
-
-                set_pte(pte, pte_mkdirty(*pte));
-        }
-        set_pte(pte, pte_mkyoung(*pte));
-
-        ospid = mfspr(SPRN_PID);
-        mtspr(SPRN_PID, spid);
-        PPC4xx_tlb_update(addr, pte);
-        mtspr(SPRN_PID, ospid);
-
-	return (0);
-bad:
-	return (-1);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/mm/4xx_tlb.h linux-2.4.22-pre2/arch/ppc/mm/4xx_tlb.h
--- linux-2.4.21/arch/ppc/mm/4xx_tlb.h	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/mm/4xx_tlb.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,35 +0,0 @@
-/*
- *
- *    Copyright (c) 1999 Grant Erickson <grant@lcse.umn.edu>
- *
- *    Module name: 4xx_tlb.h
- *
- *    Description:
- *      Routines for manipulating the TLB on PowerPC 400-class processors.
- *
- */
-
-#ifndef __4XX_TLB_H__
-#define __4XX_TLB_H__
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* Function Prototypes */
-
-extern void	 PPC4xx_tlb_pin(unsigned long va, unsigned long pa,
-				int pagesz, int cache);
-extern void	 PPC4xx_tlb_unpin(unsigned long va, unsigned long pa,
-				  int size);
-extern void	 PPC4xx_tlb_flush_all(void);
-extern void	 PPC4xx_tlb_flush(unsigned long va, int pid);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __4XX_TLB_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/mm/Makefile linux-2.4.22-pre2/arch/ppc/mm/Makefile
--- linux-2.4.21/arch/ppc/mm/Makefile	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/mm/Makefile	2003-06-26 21:43:30.000000000 +0000
@@ -18,7 +18,7 @@
 					mmu_context.o pgtable.o
 
 obj-$(CONFIG_PPC_STD_MMU)	+= hashtable.o ppc_mmu.o tlb.o
-obj-$(CONFIG_4xx)		+= cachemap.o 4xx_mmu.o
-obj-$(CONFIG_8xx)		+= cachemap.o
+obj-$(CONFIG_40x)		+= 4xx_mmu.o
+obj-$(CONFIG_NOT_COHERENT_CACHE)	+= cachemap.o
 
 include $(TOPDIR)/Rules.make
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/mm/pgtable.c linux-2.4.22-pre2/arch/ppc/mm/pgtable.c
--- linux-2.4.21/arch/ppc/mm/pgtable.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/mm/pgtable.c	2003-06-26 21:43:13.000000000 +0000
@@ -278,11 +278,11 @@
 		/* On the MPC8xx, we want the page shared so we
 		 * don't get ASID compares on kernel space.
 		 */
-		f = _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_SHARED;
-#if defined(CONFIG_KGDB) || defined(CONFIG_XMON)
+		f = _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_SHARED | _PAGE_HWEXEC;
+#if defined(CONFIG_KGDB) || defined(CONFIG_XMON) || defined(CONFIG_BDI_SWITCH)
 		/* Allows stub to set breakpoints everywhere */
 		f |= _PAGE_WRENABLE;
-#else	/* !CONFIG_KGDB && !CONFIG_XMON */
+#else	/* !CONFIG_KGDB && !CONFIG_XMON && !CONFIG_BDI_SWITCH */
 		if ((char *) v < _stext || (char *) v >= etext)
 			f |= _PAGE_WRENABLE;
 #ifdef CONFIG_PPC_STD_MMU
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/platforms/Makefile linux-2.4.22-pre2/arch/ppc/platforms/Makefile
--- linux-2.4.21/arch/ppc/platforms/Makefile	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/platforms/Makefile	2003-06-26 21:43:34.000000000 +0000
@@ -28,7 +28,7 @@
 
 export-objs			:= prep_setup.o
 
-obj-$(CONFIG_WALNUT)		+= walnut.o
+obj-$(CONFIG_WALNUT)		+= walnut.o ibm405gp.o
 
 obj-$(CONFIG_APUS)		+= apus_setup.o
 ifeq ($(CONFIG_APUS),y)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/platforms/ibm405.h linux-2.4.22-pre2/arch/ppc/platforms/ibm405.h
--- linux-2.4.21/arch/ppc/platforms/ibm405.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/platforms/ibm405.h	2003-06-26 21:43:10.000000000 +0000
@@ -0,0 +1,332 @@
+/*
+ * ibm405.h
+ *
+ *	This was derived from the ppc4xx.h and contains
+ *	common 405 offsets
+ *
+ *      Armin Kuster akuster@pacbell.net
+ *      Jan, 2002
+ *
+ *
+ * Copyright 2002 MontaVista Softare 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.
+ *
+ *	Version 1.0 (02/01/17) - A. Kuster
+ *	Initial version	 - moved 405  specific out of the other core.h's
+ *
+ *	Version 1.0 (02/08/02) - A. Kuster
+ *	removed DCRN_UIC1_BASE to NP405L & H
+ *
+ *	Version 1.2 (05/29/02) - Akuster
+ *	removed DCRN_MALRXCTP2R etc, alread in ibmnp405.h
+ */
+
+#ifdef __KERNEL__
+#ifndef __ASM_IBM405_H__
+#define __ASM_IBM405_H__
+
+#ifdef DCRN_BE_BASE
+#define DCRN_BEAR	(DCRN_BE_BASE + 0x0)	/* Bus Error Address Register */
+#define DCRN_BESR	(DCRN_BE_BASE + 0x1)	/* Bus Error Syndrome Register */
+#endif
+/* DCRN_BESR */
+#define BESR_DSES	0x80000000	/* Data-Side Error Status */
+#define BESR_DMES	0x40000000	/* DMA Error Status */
+#define BESR_RWS	0x20000000	/* Read/Write Status */
+#define BESR_ETMASK	0x1C000000	/* Error Type */
+#define ET_PROT	0
+#define ET_PARITY	1
+#define ET_NCFG	2
+#define ET_BUSERR	4
+#define ET_BUSTO	6
+
+/* Clock and power management shifts for emacs */
+#define IBM_CPM_EMMII	0	/* Shift value for MII */
+#define IBM_CPM_EMRX	1	/* Shift value for recv */
+#define IBM_CPM_EMTX	2	/* Shift value for MAC */
+
+#ifdef DCRN_CHCR_BASE
+#define DCRN_CHCR0	(DCRN_CHCR_BASE + 0x0)	/* Chip Control Register 1 */
+#define DCRN_CHCR1	(DCRN_CHCR_BASE + 0x1)	/* Chip Control Register 2 */
+#endif
+#define CHR1_PCIPW	0x00008000	/* PCI Int enable/Peripheral Write enable */
+
+#ifdef DCRN_CHPSR_BASE
+#define DCRN_CHPSR	(DCRN_CHPSR_BASE + 0x0)	/* Chip Pin Strapping */
+#endif
+
+#ifdef DCRN_CPMFR_BASE
+#define DCRN_CPMFR	(DCRN_CPMFR_BASE + 0x0)	/* CPM Force */
+#endif
+
+#ifdef DCRN_CPMSR_BASE
+#define DCRN_CPMSR	(DCRN_CPMSR_BASE + 0x0)	/* CPM Status */
+#define DCRN_CPMER	(DCRN_CPMSR_BASE + 0x1)	/* CPM Enable */
+#endif
+
+#ifdef DCRN_DCP0_BASE
+/* Decompression Controller Address */
+#define DCRN_DCP0_CFGADDR	(DCRN_DCP0_BASE + 0x0)
+/* Decompression Controller Data */
+#define DCRN_DCP0_CFGDATA	(DCRN_DCP0_BASE + 0x1)
+#else
+#define DCRN_DCP0_CFGADDR	0x0
+#define DCRN_DCP0_CFGDATA	0x0
+#endif
+
+#ifdef DCRN_DMA0_BASE
+/* DMA Channel Control Register 0 */
+#define DCRN_DMACR0	(DCRN_DMA0_BASE + 0x0)
+#define DCRN_DMACT0	(DCRN_DMA0_BASE + 0x1)	/* DMA Count Register 0 */
+/* DMA Destination Address Register 0 */
+#define DCRN_DMADA0	(DCRN_DMA0_BASE + 0x2)
+/* DMA Source Address Register 0 */
+#define DCRN_DMASA0	(DCRN_DMA0_BASE + 0x3)
+#ifdef DCRNCAP_DMA_CC
+/* DMA Chained Count Register 0 */
+#define DCRN_DMACC0	(DCRN_DMA0_BASE + 0x4)
+#endif
+#ifdef DCRNCAP_DMA_SG
+/* DMA Scatter/Gather Descriptor Addr 0 */
+#define DCRN_ASG0	(DCRN_DMA0_BASE + 0x4)
+#endif
+#endif
+
+#ifdef DCRN_DMA1_BASE
+/* DMA Channel Control Register 1 */
+#define DCRN_DMACR1	(DCRN_DMA1_BASE + 0x0)
+#define DCRN_DMACT1	(DCRN_DMA1_BASE + 0x1)	/* DMA Count Register 1 */
+/* DMA Destination Address Register 1 */
+#define DCRN_DMADA1	(DCRN_DMA1_BASE + 0x2)
+/* DMA Source Address Register 1 */
+#define DCRN_DMASA1	(DCRN_DMA1_BASE + 0x3)	/* DMA Source Address Register 1 */
+#ifdef DCRNCAP_DMA_CC
+/* DMA Chained Count Register 1 */
+#define DCRN_DMACC1	(DCRN_DMA1_BASE + 0x4)
+#endif
+#ifdef DCRNCAP_DMA_SG
+/* DMA Scatter/Gather Descriptor Addr 1 */
+#define DCRN_ASG1	(DCRN_DMA1_BASE + 0x4)
+#endif
+#endif
+
+#ifdef DCRN_DMA2_BASE
+#define DCRN_DMACR2	(DCRN_DMA2_BASE + 0x0)	/* DMA Channel Control Register 2 */
+#define DCRN_DMACT2	(DCRN_DMA2_BASE + 0x1)	/* DMA Count Register 2 */
+#define DCRN_DMADA2	(DCRN_DMA2_BASE + 0x2)	/* DMA Destination Address Register 2 */
+#define DCRN_DMASA2	(DCRN_DMA2_BASE + 0x3)	/* DMA Source Address Register 2 */
+#ifdef DCRNCAP_DMA_CC
+#define DCRN_DMACC2	(DCRN_DMA2_BASE + 0x4)	/* DMA Chained Count Register 2 */
+#endif
+#ifdef DCRNCAP_DMA_SG
+#define DCRN_ASG2	(DCRN_DMA2_BASE + 0x4)	/* DMA Scatter/Gather Descriptor Addr 2 */
+#endif
+#endif
+
+#ifdef DCRN_DMA3_BASE
+#define DCRN_DMACR3	(DCRN_DMA3_BASE + 0x0)	/* DMA Channel Control Register 3 */
+#define DCRN_DMACT3	(DCRN_DMA3_BASE + 0x1)	/* DMA Count Register 3 */
+#define DCRN_DMADA3	(DCRN_DMA3_BASE + 0x2)	/* DMA Destination Address Register 3 */
+#define DCRN_DMASA3	(DCRN_DMA3_BASE + 0x3)	/* DMA Source Address Register 3 */
+#ifdef DCRNCAP_DMA_CC
+#define DCRN_DMACC3	(DCRN_DMA3_BASE + 0x4)	/* DMA Chained Count Register 3 */
+#endif
+#ifdef DCRNCAP_DMA_SG
+#define DCRN_ASG3	(DCRN_DMA3_BASE + 0x4)	/* DMA Scatter/Gather Descriptor Addr 3 */
+#endif
+#endif
+
+#ifdef DCRN_DMASR_BASE
+#define DCRN_DMASR	(DCRN_DMASR_BASE + 0x0)	/* DMA Status Register */
+#ifdef DCRNCAP_DMA_SG
+#define DCRN_ASGC	(DCRN_DMASR_BASE + 0x3)	/* DMA Scatter/Gather Command */
+/* don't know if these two registers always exist if scatter/gather exists */
+#define DCRN_POL	(DCRN_DMASR_BASE + 0x6)	/* DMA Polarity Register */
+#define DCRN_SLP	(DCRN_DMASR_BASE + 0x5)	/* DMA Sleep Register */
+#endif
+#endif
+
+#ifdef DCRN_EBC_BASE
+#define DCRN_EBCCFGADR	(DCRN_EBC_BASE + 0x0)	/* Peripheral Controller Address */
+#define DCRN_EBCCFGDATA	(DCRN_EBC_BASE + 0x1)	/* Peripheral Controller Data */
+#endif
+
+#ifdef DCRN_EXIER_BASE
+#define DCRN_EXIER	(DCRN_EXIER_BASE + 0x0)	/* External Interrupt Enable Register */
+#endif
+
+#ifdef DCRN_EXISR_BASE
+#define DCRN_EXISR	(DCRN_EXISR_BASE + 0x0)	/* External Interrupt Status Register */
+#endif
+
+#define EXIER_CIE	0x80000000	/* Critical Interrupt Enable */
+#define EXIER_SRIE	0x08000000	/* Serial Port Rx Int. Enable */
+#define EXIER_STIE	0x04000000	/* Serial Port Tx Int. Enable */
+#define EXIER_JRIE	0x02000000	/* JTAG Serial Port Rx Int. Enable */
+#define EXIER_JTIE	0x01000000	/* JTAG Serial Port Tx Int. Enable */
+#define EXIER_D0IE	0x00800000	/* DMA Channel 0 Interrupt Enable */
+#define EXIER_D1IE	0x00400000	/* DMA Channel 1 Interrupt Enable */
+#define EXIER_D2IE	0x00200000	/* DMA Channel 2 Interrupt Enable */
+#define EXIER_D3IE	0x00100000	/* DMA Channel 3 Interrupt Enable */
+#define EXIER_E0IE	0x00000010	/* External Interrupt 0 Enable */
+#define EXIER_E1IE	0x00000008	/* External Interrupt 1 Enable */
+#define EXIER_E2IE	0x00000004	/* External Interrupt 2 Enable */
+#define EXIER_E3IE	0x00000002	/* External Interrupt 3 Enable */
+#define EXIER_E4IE	0x00000001	/* External Interrupt 4 Enable */
+
+#ifdef DCRN_IOCR_BASE
+#define DCRN_IOCR	(DCRN_IOCR_BASE + 0x0)	/* Input/Output Configuration Register */
+#endif
+#define IOCR_E0TE	0x80000000
+#define IOCR_E0LP	0x40000000
+#define IOCR_E1TE	0x20000000
+#define IOCR_E1LP	0x10000000
+#define IOCR_E2TE	0x08000000
+#define IOCR_E2LP	0x04000000
+#define IOCR_E3TE	0x02000000
+#define IOCR_E3LP	0x01000000
+#define IOCR_E4TE	0x00800000
+#define IOCR_E4LP	0x00400000
+#define IOCR_EDT	0x00080000
+#define IOCR_SOR	0x00040000
+#define IOCR_EDO	0x00008000
+#define IOCR_2XC	0x00004000
+#define IOCR_ATC	0x00002000
+#define IOCR_SPD	0x00001000
+#define IOCR_BEM	0x00000800
+#define IOCR_PTD	0x00000400
+#define IOCR_ARE	0x00000080
+#define IOCR_DRC	0x00000020
+#define IOCR_RDM(x)	(((x) & 0x3) << 3)
+#define IOCR_TCS	0x00000004
+#define IOCR_SCS	0x00000002
+#define IOCR_SPC	0x00000001
+
+#define DCRN_MALCR(base)	(base + 0x0)	/* MAL Configuration */
+#define DCRN_MALDBR(base)	((base) + 0x3)	/* Debug Register */
+#define DCRN_MALESR(base)	((base) + 0x1)	/* Error Status */
+#define DCRN_MALIER(base)	((base) + 0x2)	/* Interrupt Enable */
+#define DCRN_MALTXCARR(base)	((base) + 0x5)	/* TX Channed Active Reset Register */
+#define DCRN_MALTXCASR(base)	((base) + 0x4)	/* TX Channel Active Set Register */
+#define DCRN_MALTXDEIR(base)	((base) + 0x7)	/* Tx Descriptor Error Interrupt */
+#define DCRN_MALTXEOBISR(base)	((base) + 0x6)	/* Tx End of Buffer Interrupt Status */
+#define DCRN_MALRXCARR(base)	((base) + 0x11)	/* RX Channed Active Reset Register */
+#define DCRN_MALRXCASR(base)	((base) + 0x10)	/* RX Channel Active Set Register */
+#define DCRN_MALRXDEIR(base)	((base) + 0x13)	/* Rx Descriptor Error Interrupt */
+#define DCRN_MALRXEOBISR(base)	((base) + 0x12)	/* Rx End of Buffer Interrupt Status */
+#define DCRN_MALRXCTP0R(base)	((base) + 0x40)	/* Channel Rx 0 Channel Table Pointer */
+#define DCRN_MALRXCTP1R(base)	((base) + 0x41)	/* Channel Rx 1 Channel Table Pointer */
+#define DCRN_MALTXCTP0R(base)	((base) + 0x20)	/* Channel Tx 0 Channel Table Pointer */
+#define DCRN_MALTXCTP1R(base)	((base) + 0x21)	/* Channel Tx 1 Channel Table Pointer */
+#define DCRN_MALTXCTP2R(base)	((base) + 0x22)	/* Channel Tx 2 Channel Table Pointer */
+#define DCRN_MALTXCTP3R(base)	((base) + 0x23)	/* Channel Tx 3 Channel Table Pointer */
+#define DCRN_MALRCBS0(base)	((base) + 0x60)	/* Channel Rx 0 Channel Buffer Size */
+#define DCRN_MALRCBS1(base)	((base) + 0x61)	/* Channel Rx 1 Channel Buffer Size */
+
+ /* DCRN_MALCR */
+#define MALCR_MMSR		0x80000000	/* MAL Software reset */
+#define MALCR_PLBP_1		0x00400000	/* MAL reqest priority: */
+#define MALCR_PLBP_2		0x00800000	/* lowsest is 00 */
+#define MALCR_PLBP_3		0x00C00000	/* highest */
+#define MALCR_GA		0x00200000	/* Guarded Active Bit */
+#define MALCR_OA		0x00100000	/* Ordered Active Bit */
+#define MALCR_PLBLE		0x00080000	/* PLB Lock Error Bit */
+#define MALCR_PLBLT_1		0x00040000	/* PLB Latency Timer */
+#define MALCR_PLBLT_2 		0x00020000
+#define MALCR_PLBLT_3		0x00010000
+#define MALCR_PLBLT_4		0x00008000
+#define MALCR_PLBLT_DEFAULT	0x00078000	/* JSP: Is this a valid default?? */
+#define MALCR_PLBB		0x00004000	/* PLB Burst Deactivation Bit */
+#define MALCR_OPBBL		0x00000080	/* OPB Lock Bit */
+#define MALCR_EOPIE		0x00000004	/* End Of Packet Interrupt Enable */
+#define MALCR_LEA		0x00000002	/* Locked Error Active */
+#define MALCR_MSD		0x00000001	/* MAL Scroll Descriptor Bit */
+/* DCRN_MALESR */
+#define MALESR_EVB		0x80000000	/* Error Valid Bit */
+#define MALESR_CIDRX		0x40000000	/* Channel ID Receive */
+#define MALESR_DE		0x00100000	/* Descriptor Error */
+#define MALESR_OEN		0x00080000	/* OPB Non-Fullword Error */
+#define MALESR_OTE		0x00040000	/* OPB Timeout Error */
+#define MALESR_OSE		0x00020000	/* OPB Slave Error */
+#define MALESR_PEIN		0x00010000	/* PLB Bus Error Indication */
+#define MALESR_DEI		0x00000010	/* Descriptor Error Interrupt */
+#define MALESR_ONEI		0x00000008	/* OPB Non-Fullword Error Interrupt */
+#define MALESR_OTEI		0x00000004	/* OPB Timeout Error Interrupt */
+#define MALESR_OSEI		0x00000002	/* OPB Slace Error Interrupt */
+#define MALESR_PBEI		0x00000001	/* PLB Bus Error Interrupt */
+/* DCRN_MALIER */
+#define MALIER_DE		0x00000010	/* Descriptor Error Interrupt Enable */
+#define MALIER_NE		0x00000008	/* OPB Non-word Transfer Int Enable */
+#define MALIER_TE		0x00000004	/* OPB Time Out Error Interrupt Enable */
+#define MALIER_OPBE		0x00000002	/* OPB Slave Error Interrupt Enable */
+#define MALIER_PLBE		0x00000001	/* PLB Error Interrupt Enable */
+/* DCRN_MALTXEOBISR */
+#define MALOBISR_CH0		0x80000000	/* EOB channel 1 bit */
+#define MALOBISR_CH2		0x40000000	/* EOB channel 2 bit */
+
+#ifdef DCRN_PLB0_BASE
+#define DCRN_PLB0_BESR	(DCRN_PLB0_BASE + 0x0)
+#define DCRN_PLB0_BEAR	(DCRN_PLB0_BASE + 0x2)
+/* doesn't exist on stb03xxx? */
+#define DCRN_PLB0_ACR	(DCRN_PLB0_BASE + 0x3)
+#endif
+
+#ifdef DCRN_PLB1_BASE
+#define DCRN_PLB1_BESR	(DCRN_PLB1_BASE + 0x0)
+#define DCRN_PLB1_BEAR	(DCRN_PLB1_BASE + 0x1)
+/* doesn't exist on stb03xxx? */
+#define DCRN_PLB1_ACR	(DCRN_PLB1_BASE + 0x2)
+#endif
+
+#ifdef DCRN_PLLMR_BASE
+#define DCRN_PLLMR	(DCRN_PLLMR_BASE + 0x0)	/* PL1 Mode */
+#endif
+
+#ifdef DCRN_POB0_BASE
+#define DCRN_POB0_BESR0	(DCRN_POB0_BASE + 0x0)
+#define DCRN_POB0_BEAR	(DCRN_POB0_BASE + 0x2)
+#define DCRN_POB0_BESR1	(DCRN_POB0_BASE + 0x4)
+#endif
+
+#define DCRN_UIC_SR(base)	(base + 0x0)
+#define DCRN_UIC_ER(base)	(base + 0x2)
+#define DCRN_UIC_CR(base)	(base + 0x3)
+#define DCRN_UIC_PR(base)	(base + 0x4)
+#define DCRN_UIC_TR(base)	(base + 0x5)
+#define DCRN_UIC_MSR(base)	(base + 0x6)
+#define DCRN_UIC_VR(base)	(base + 0x7)
+#define DCRN_UIC_VCR(base)	(base + 0x8)
+
+#ifdef DCRN_SDRAM0_BASE
+#define DCRN_SDRAM0_CFGADDR	(DCRN_SDRAM0_BASE + 0x0)	/* Memory Controller Address */
+#define DCRN_SDRAM0_CFGDATA	(DCRN_SDRAM0_BASE + 0x1)	/* Memory Controller Data */
+#endif
+
+#ifdef DCRN_OCM0_BASE
+#define DCRN_OCMISARC	(DCRN_OCM0_BASE + 0x0)	/* OCM Instr Side Addr Range Compare */
+#define DCRN_OCMISCR	(DCRN_OCM0_BASE + 0x1)	/* OCM Instr Side Control */
+#define DCRN_OCMDSARC	(DCRN_OCM0_BASE + 0x2)	/* OCM Data Side Addr Range Compare */
+#define DCRN_OCMDSCR	(DCRN_OCM0_BASE + 0x3)	/* OCM Data Side Control */
+#endif
+
+#endif				/* __ASM_IBM405_H__ */
+#endif				/* __KERNEL__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/platforms/ibm405gp.c linux-2.4.22-pre2/arch/ppc/platforms/ibm405gp.c
--- linux-2.4.21/arch/ppc/platforms/ibm405gp.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/platforms/ibm405gp.c	2003-06-26 21:43:31.000000000 +0000
@@ -0,0 +1,107 @@
+/*
+ *
+ *    Copyright 2000-2001 MontaVista Software Inc.
+ *      Original author: Armin Kuster akuster@mvista.com
+ *
+ *    Module name: ibm405gp.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  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/smp.h>
+#include <linux/threads.h>
+#include <linux/param.h>
+#include <linux/string.h>
+#include <platforms/ibm405gp.h>
+#include <asm/ibm4xx.h>
+#include <asm/ocp.h>
+
+static struct ocp_func_emac_data ibm405gp_emac0_def = {
+	.zmii_idx	= -1,		/* ZMII device index */
+	.zmii_mux	= 0,		/* ZMII input of this EMAC */
+	.mal_idx	= 0,		/* MAL device index */
+	.mal_rx_chan	= 0,		/* MAL rx channel number */
+	.mal_tx1_chan	= 0,		/* MAL tx channel 1 number */
+	.mal_tx2_chan	= 1,		/* MAL tx channel 2 number */
+	.wol_irq	= BL_MAC_WOL,	/* WOL interrupt number */
+	.mdio_idx	= -1,		/* No shared MDIO */
+};
+
+static struct ocp_func_mal_data ibm405gp_mal0_def = {
+	.num_tx_chans	= 2*EMAC_NUMS,	/* Number of TX channels */
+	.num_rx_chans	= EMAC_NUMS,	/* Number of RX channels */
+};
+
+struct ocp_def core_ocp[]  __initdata = {
+	{ .vendor	= OCP_VENDOR_IBM,
+	  .function	= OCP_FUNC_OPB,
+	  .index	= 0,
+	  .paddr	= OPB_BASE_START,
+	  .irq		= OCP_IRQ_NA,
+	  .pm		= OCP_CPM_NA,
+	},
+	{ .vendor	= OCP_VENDOR_IBM,
+	  .function	= OCP_FUNC_16550,
+	  .index	= 0,
+	  .paddr	= UART0_IO_BASE,
+	  .irq		= UART0_INT,
+	  .pm		= IBM_CPM_UART0
+	},
+	{ .vendor	= OCP_VENDOR_IBM,
+	  .function	= OCP_FUNC_16550,
+	  .index	= 1,
+	  .paddr	= UART1_IO_BASE,
+	  .irq		= UART1_INT,
+	  .pm		= IBM_CPM_UART1
+	},
+	{ .vendor	= OCP_VENDOR_IBM,
+	  .function	= OCP_FUNC_IIC,
+	  .paddr	= IIC0_BASE,
+	  .irq		= IIC0_IRQ,
+	  .pm		= IBM_CPM_IIC0
+	},
+	{ .vendor	= OCP_VENDOR_IBM,
+	  .function	= OCP_FUNC_GPIO,
+	  .paddr	= GPIO0_BASE,
+	  .irq		= OCP_IRQ_NA,
+	  .pm		= IBM_CPM_GPIO0
+	},
+	{ .vendor	= OCP_VENDOR_IBM,
+	  .function	= OCP_FUNC_MAL,
+	  .paddr	= OCP_PADDR_NA,
+	  .irq		= OCP_IRQ_NA,
+	  .pm		= OCP_CPM_NA,
+	  .additions	= &ibm405gp_mal0_def,
+	},
+	{ .vendor	= OCP_VENDOR_IBM,
+	  .function	= OCP_FUNC_EMAC,
+	  .index	= 0,
+	  .paddr	= EMAC0_BASE,
+	  .irq		= BL_MAC_ETH0,
+	  .pm		= IBM_CPM_EMAC0,
+	  .additions	= &ibm405gp_emac0_def,
+	},
+	{ .vendor	= OCP_VENDOR_INVALID
+	}
+};
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/platforms/ibm405gp.h linux-2.4.22-pre2/arch/ppc/platforms/ibm405gp.h
--- linux-2.4.21/arch/ppc/platforms/ibm405gp.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/platforms/ibm405gp.h	2003-06-26 21:43:11.000000000 +0000
@@ -0,0 +1,193 @@
+/*
+ * ibm405gp.h
+ *
+ *	This was derived from the ppc4xx.h and all 405GP specific
+ *	definition and board inclusions were moved here.
+ *
+ *      Original author: Armin Kuster akuster@mvista.com
+ *      Oct, 2001
+ *
+ *
+ * Copyright 2001 MontaVista Softare 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.
+ *
+ */
+
+#ifdef __KERNEL__
+#ifndef __ASM_IBM405GP_H__
+#define __ASM_IBM405GP_H__
+
+#include <linux/config.h>
+
+/* ibm405.h is included at the bottom of this file */
+
+/* PCI
+ * PCI Bridge config reg definitions
+ * see 17-19 of manual
+ */
+
+#define PPC405_PCI_CONFIG_ADDR	0xeec00000
+#define PPC405_PCI_CONFIG_DATA	0xeec00004
+
+#define PPC405_PCI_PHY_MEM_BASE	0x80000000	/* hose_a->pci_mem_offset */
+						/* setbat */
+#define PPC405_PCI_MEM_BASE	PPC405_PCI_PHY_MEM_BASE	/* setbat */
+#define PPC405_PCI_PHY_IO_BASE	0xe8000000	/* setbat */
+#define PPC405_PCI_IO_BASE	PPC405_PCI_PHY_IO_BASE	/* setbat */
+
+#define PPC405_PCI_LOWER_MEM	0x80000000	/* hose_a->mem_space.start */
+#define PPC405_PCI_UPPER_MEM	0xBfffffff	/* hose_a->mem_space.end */
+#define PPC405_PCI_LOWER_IO	0x00000000	/* hose_a->io_space.start */
+#define PPC405_PCI_UPPER_IO	0x0000ffff	/* hose_a->io_space.end */
+
+#define PPC405_ISA_IO_BASE	PPC405_PCI_IO_BASE
+
+#define PPC4xx_PCI_IO_PADDR	((uint)PPC405_PCI_PHY_IO_BASE)
+#define PPC4xx_PCI_IO_VADDR	PPC4xx_PCI_IO_PADDR
+#define PPC4xx_PCI_IO_SIZE	((uint)64*1024)
+#define PPC4xx_PCI_CFG_PADDR	((uint)PPC405_PCI_CONFIG_ADDR)
+#define PPC4xx_PCI_CFG_VADDR	PPC4xx_PCI_CFG_PADDR
+#define PPC4xx_PCI_CFG_SIZE	((uint)4*1024)
+#define PPC4xx_PCI_LCFG_PADDR	((uint)0xef400000)
+#define PPC4xx_PCI_LCFG_VADDR	PPC4xx_PCI_LCFG_PADDR
+#define PPC4xx_PCI_LCFG_SIZE	((uint)4*1024)
+#define PPC4xx_ONB_IO_PADDR	((uint)0xef600000)
+#define PPC4xx_ONB_IO_VADDR	PPC4xx_ONB_IO_PADDR
+#define PPC4xx_ONB_IO_SIZE	((uint)4*1024)
+
+#define OPB_BASE_START	0x40000000
+#define EBIU_BASE_START	0xF0100000
+
+/* serial port defines */
+#define RS_TABLE_SIZE	2
+
+#define UART0_INT	0
+#define UART1_INT	1
+
+#define PCIL0_BASE	0xEF400000
+#define UART0_IO_BASE	0xEF600300
+#define UART1_IO_BASE	0xEF600400
+#define IIC0_BASE	0xEF600500
+#define OPB0_BASE	0xEF600600
+#define GPIO0_BASE	0xEF600700
+#define EMAC0_BASE	0xEF600800
+#define BL_MAC_WOL	9	/* WOL */
+#define BL_MAL_SERR	10	/* MAL SERR */
+#define BL_MAL_TXDE	13	/* MAL TXDE */
+#define BL_MAL_RXDE	14	/* MAL RXDE */
+#define BL_MAL_TXEOB	11	/* MAL TX EOB */
+#define BL_MAL_RXEOB	12	/* MAL RX EOB */
+#define BL_MAC_ETH0	15	/* MAC */
+
+#define EMAC_NUMS	1
+#define IIC0_IRQ	2
+#define IIC1_IRQ	0
+
+#define IIC_OWN		0x55
+#define IIC_CLOCK	50
+#define BD_EMAC_ADDR(e,i) bi_enetaddr[i]
+
+#define STD_UART_OP(num)					\
+	{ 0, BASE_BAUD, 0, UART##num##_INT,			\
+		(ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST),	\
+		iomem_base: (u8 *)UART##num##_IO_BASE,		\
+		io_type: SERIAL_IO_MEM},
+
+#if defined(CONFIG_UART0_TTYS0)
+#define SERIAL_DEBUG_IO_BASE	UART0_IO_BASE
+#define SERIAL_PORT_DFNS	\
+	STD_UART_OP(0)		\
+	STD_UART_OP(1)
+#endif
+
+#if defined(CONFIG_UART0_TTYS1)
+#define SERIAL_DEBUG_IO_BASE	UART1_IO_BASE
+#define SERIAL_PORT_DFNS	\
+	STD_UART_OP(1)		\
+	STD_UART_OP(0)
+#endif
+
+/* DCR defines */
+#define DCRN_CHCR_BASE		0x0B1
+#define DCRN_CHPSR_BASE		0x0B4
+#define DCRN_CPMSR_BASE		0x0B8
+#define DCRN_CPMFR_BASE		0x0BA
+
+#define CHR0_U0EC	0x00000080	/* Select external clock for UART0 */
+#define CHR0_U1EC	0x00000040	/* Select external clock for UART1 */
+#define CHR0_UDIV	0x0000003E	/* UART internal clock divisor */
+#define CHR1_CETE	0x00800000	/* CPU external timer enable */
+
+#define DCRN_CHPSR_BASE         0x0B4
+#define  PSR_PLL_FWD_MASK        0xC0000000
+#define  PSR_PLL_FDBACK_MASK     0x30000000
+#define  PSR_PLL_TUNING_MASK     0x0E000000
+#define  PSR_PLB_CPU_MASK        0x01800000
+#define  PSR_OPB_PLB_MASK        0x00600000
+#define  PSR_PCI_PLB_MASK        0x00180000
+#define  PSR_EB_PLB_MASK         0x00060000
+#define  PSR_ROM_WIDTH_MASK      0x00018000
+#define  PSR_ROM_LOC             0x00004000
+#define  PSR_PCI_ASYNC_EN        0x00001000
+#define  PSR_PCI_ARBIT_EN        0x00000400
+
+#define IBM_CPM_IIC0		0x80000000	/* IIC interface */
+#define IBM_CPM_PCI		0x40000000	/* PCI bridge */
+#define IBM_CPM_CPU		0x20000000	/* processor core */
+#define IBM_CPM_DMA		0x10000000	/* DMA controller */
+#define IBM_CPM_OPB		0x08000000	/* PLB to OPB bridge */
+#define IBM_CPM_DCP		0x04000000	/* CodePack */
+#define IBM_CPM_EBC		0x02000000	/* ROM/SRAM peripheral controller */
+#define IBM_CPM_SDRAM0		0x01000000	/* SDRAM memory controller */
+#define IBM_CPM_PLB		0x00800000	/* PLB bus arbiter */
+#define IBM_CPM_GPIO0		0x00400000	/* General Purpose IO (??) */
+#define IBM_CPM_UART0		0x00200000	/* serial port 0 */
+#define IBM_CPM_UART1		0x00100000	/* serial port 1 */
+#define IBM_CPM_UIC		0x00080000	/* Universal Interrupt Controller */
+#define IBM_CPM_TMRCLK		0x00040000	/* CPU timers */
+#define IBM_CPM_EMAC0		0x00020000	/* on-chip ethernet MM unit */
+#define DFLT_IBM4xx_PM		~(IBM_CPM_PCI | IBM_CPM_CPU | IBM_CPM_DMA \
+					| IBM_CPM_OPB | IBM_CPM_EBC \
+					| IBM_CPM_SDRAM0 | IBM_CPM_PLB \
+					| IBM_CPM_UIC | IBM_CPM_TMRCLK)
+
+#define DCRN_DMA0_BASE		0x100
+#define DCRN_DMA1_BASE		0x108
+#define DCRN_DMA2_BASE		0x110
+#define DCRN_DMA3_BASE		0x118
+#define DCRNCAP_DMA_SG		1	/* have DMA scatter/gather capability */
+#define DCRN_DMASR_BASE		0x120
+#define DCRN_EBC_BASE		0x012
+#define DCRN_DCP0_BASE		0x014
+#define DCRN_MAL_BASE		0x180
+#define DCRN_OCM0_BASE		0x018
+#define DCRN_PLB0_BASE		0x084
+#define DCRN_PLLMR_BASE		0x0B0
+#define DCRN_POB0_BASE		0x0A0
+#define DCRN_SDRAM0_BASE	0x010
+#define DCRN_UIC0_BASE		0x0C0
+#define UIC0 DCRN_UIC0_BASE
+
+#include <platforms/ibm405.h>
+
+#endif				/* __ASM_IBM405GP_H__ */
+#endif				/* __KERNEL__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/platforms/ibm_ocp.h linux-2.4.22-pre2/arch/ppc/platforms/ibm_ocp.h
--- linux-2.4.21/arch/ppc/platforms/ibm_ocp.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/platforms/ibm_ocp.h	2003-06-26 21:43:17.000000000 +0000
@@ -0,0 +1,152 @@
+/*
+ * arch/ppc/platforms/ibm_ocp.h
+ *
+ *	Definitions for the on-chip peripherals on the IBM
+ *	PPC405GP embedded processor.
+ *
+ * Copyright 2001 MontaVista Softare 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.
+ *
+ */
+
+#ifdef __KERNEL__
+#ifndef __ASM_IBM_OCP_H__
+#define __ASM_IBM_OCP_H__
+
+#ifndef __ASSEMBLY__
+#include <linux/types.h>
+
+//
+// TODO: DEPRECATE THIS FILE !
+//
+
+ /* PCI 32 */
+
+struct pmm_regs {
+	u32 la;
+	u32 ma;
+	u32 pcila;
+	u32 pciha;
+};
+
+typedef struct pcil0_regs {
+	struct pmm_regs pmm[3];
+	u32 ptm1ms;
+	u32 ptm1la;
+	u32 ptm2ms;
+	u32 ptm2la;
+} pci0_t;
+
+/* Serial Ports */
+
+#define thr rbr
+#define iir fcr
+#define dll rbr
+#define dlm ier
+
+typedef struct NS16550 {
+	u8 rbr;			/* 0 */
+	u8 ier;			/* 1 */
+	u8 fcr;			/* 2 */
+	u8 lcr;			/* 3 */
+	u8 mcr;			/* 4 */
+	u8 lsr;			/* 5 */
+	u8 msr;			/* 6 */
+	u8 scr;			/* 7 */
+} uart_t;
+
+/* I2c */
+typedef struct iic_regs {
+	u16 mdbuf;
+	u16 sbbuf;
+	u8 lmadr;
+	u8 hmadr;
+	u8 cntl;
+	u8 mdcntl;
+	u8 sts;
+	u8 extsts;
+	u8 lsadr;
+	u8 hsadr;
+	u8 clkdiv;
+	u8 intmsk;
+	u8 xfrcnt;
+	u8 xtcntlss;
+	u8 directcntl;
+} iic_t;
+
+/* OPB arbiter */
+typedef struct opb {
+	u8 pr;
+	u8 cr;
+} opb_t;
+
+/* General purpose i/o */
+
+typedef struct gpio_regs {
+	u32 or;
+	u32 tcr;
+	u32 pad[4];
+	u32 odr;
+	u32 ir;
+} gpio_t;
+
+/* Structure of the memory mapped IDE control.
+*/
+typedef struct ide_regs {
+	unsigned int si_stat;	/* IDE status */
+	unsigned int si_intenable;	/* IDE interrupt enable */
+	unsigned int si_control;	/* IDE control */
+	unsigned int pad0[0x3d];
+	unsigned int si_c0rt;	/* Chan 0 Register transfer timing */
+	unsigned int si_c0fpt;	/* Chan 0 Fast PIO transfer timing */
+	unsigned int si_c0timo;	/* Chan 0 timeout */
+	unsigned int pad1[2];
+	unsigned int si_c0d0u;	/* Chan 0 UDMA transfer timing */
+#define si_c0d0m si_c0d0u	/* Chan 0 Multiword DMA timing */
+	unsigned int pad2;
+	unsigned int si_c0d1u;	/* Chan 0 dev 1 UDMA timing */
+#define si_c0d1m si_c0d1u	/* Chan 0 dev 1 Multiword DMA timing */
+	unsigned int si_c0c;	/* Chan 0 Control */
+	unsigned int si_c0s0;	/* Chan 0 Status 0 */
+	unsigned int si_c0ie;	/* Chan 0 Interrupt Enable */
+	unsigned int si_c0s1;	/* Chan 0 Status 0 */
+	unsigned int pad4[4];
+	unsigned int si_c0dcm;	/* Chan 0 DMA Command */
+	unsigned int si_c0tb;	/* Chan 0 PRD Table base address */
+	unsigned int si_c0dct;	/* Chan 0 DMA Count */
+	unsigned int si_c0da;	/* Chan 0 DMA Address */
+	unsigned int si_c0sr;	/* Chan 0 Slew Rate Output Control */
+	unsigned char pad5[0xa2];
+	unsigned short si_c0adc;	/* Chan 0 Alt status/control */
+	unsigned char si_c0d;	/* Chan 0 data */
+	unsigned char si_c0ef;	/* Chan 0 error/features */
+	unsigned char si_c0sct;	/* Chan 0 sector count */
+	unsigned char si_c0sn;	/* Chan 0 sector number */
+	unsigned char si_c0cl;	/* Chan 0 cylinder low */
+	unsigned char si_c0ch;	/* Chan 0 cylinder high */
+	unsigned char si_c0dh;	/* Chan 0 device/head */
+	unsigned char si_c0scm;	/* Chan 0 status/command */
+} ide_t;
+
+#endif				/* __ASSEMBLY__ */
+#endif				/* __ASM_IBM_OCP_H__ */
+#endif				/* __KERNEL__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/platforms/walnut.c linux-2.4.22-pre2/arch/ppc/platforms/walnut.c
--- linux-2.4.21/arch/ppc/platforms/walnut.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/platforms/walnut.c	2003-06-26 21:43:19.000000000 +0000
@@ -1,288 +1,250 @@
 /*
  *
- *    Copyright (c) 1999-2000 Grant Erickson <grant@lcse.umn.edu>
+ *    Copyrigh t(c) 1999-2000 Grant Erickson <grant@lcse.umn.edu>
  *
- *    Module name: walnut_setup.c
+ *    Copyright 2000-2002 MontaVista Software Inc.
+ *      Completed implementation.
+ *      Author: MontaVista Software, Inc.  <source@mvista.com>
+ *
+ *    Module name: walnut.c
  *
  *    Description:
  *      Architecture- / platform-specific boot-time initialization code for
- *      the IBM PowerPC 403GP "Walnut" evaluation board. Adapted from original
+ *      IBM PowerPC 4xx based boards. Adapted from original
  *      code by Gary Thomas, Cort Dougan <cort@fsmlabs.com>, and Dan Malek
  *      <dan@net4x.com>.
  *
+ * Please read the COPYING file for all license details.
  */
-
 #include <linux/config.h>
 #include <linux/init.h>
 #include <linux/smp.h>
 #include <linux/threads.h>
-#include <linux/interrupt.h>
 #include <linux/param.h>
 #include <linux/string.h>
 #include <linux/blk.h>
-#include <linux/seq_file.h>
+#include <linux/pci.h>
+#include <linux/rtc.h>
 
+#include <asm/system.h>
+#include <asm/pci-bridge.h>
 #include <asm/processor.h>
-#include <asm/board.h>
 #include <asm/machdep.h>
 #include <asm/page.h>
-
-#include "ppc4xx_pic.h"
 #include <asm/time.h>
-#include "walnut_setup.h"
-
-
-/* Function Prototypes */
-
-extern void abort(void);
-
-/* Global Variables */
-
-unsigned char __res[sizeof(bd_t)];
-
-
-/*
- * void __init walnut_init()
- *
- * Description:
- *   This routine...
- *
- * Input(s):
- *   r3 - Optional pointer to a board information structure.
- *   r4 - Optional pointer to the physical starting address of the init RAM
- *        disk.
- *   r5 - Optional pointer to the physical ending address of the init RAM
- *        disk.
- *   r6 - Optional pointer to the physical starting address of any kernel
- *        command-line parameters.
- *   r7 - Optional pointer to the physical ending address of any kernel
- *        command-line parameters.
- *
- * Output(s):
- *   N/A
- *
- * Returns:
- *   N/A
- *
+#include <asm/io.h>
+#include <asm/todc.h>
+#include <platforms/ibm_ocp.h>
+
+#undef DEBUG
+
+#ifdef DEBUG
+#define DBG(x...) printk(x)
+#else
+#define DBG(x...)
+#endif
+
+void *kb_cs;
+void *kb_data;
+void *walnut_rtc_base;
+
+#ifdef CONFIG_PCI
+/* Some IRQs unique to Walnut.
+ * Used by the generic 405 PCI setup functions in ppc4xx_pci.c
  */
+int __init
+ppc405_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
+	     */
+	{
+		{28, 28, 28, 28},	/* IDSEL 1 - PCI slot 1 */
+		{29, 29, 29, 29},	/* IDSEL 2 - PCI slot 2 */
+		{30, 30, 30, 30},	/* IDSEL 3 - PCI slot 3 */
+		{31, 31, 31, 31},	/* IDSEL 4 - PCI slot 4 */
+	};
+
+	const long min_idsel = 1, max_idsel = 4, irqs_per_slot = 4;
+	return PCI_IRQ_TABLE_LOOKUP;
+};
+#endif
+
 void __init
-walnut_init(unsigned long r3, unsigned long r4, unsigned long r5, 
-	    unsigned long r6, unsigned long r7)
+board_setup_arch(void)
 {
-	/*
-	 * If we were passed in a board information, copy it into the
-	 * residual data area.
-	 */
-	if (r3) {
-		memcpy((void *)__res, (void *)(r3 + KERNELBASE), sizeof(bd_t));
-	}
+#define WALNUT_PS2_BASE		0xF0100000
+#define WALNUT_FPGA_BASE	0xF0300000
 
-#if defined(CONFIG_BLK_DEV_INITRD)
-	/*
-	 * If the init RAM disk has been configured in, and there's a valid
-	 * starting address for it, set it up.
-	 */
-	if (r4) {
-		initrd_start = r4 + KERNELBASE;
-		initrd_end = r5 + KERNELBASE;
+	void *fpga_brdc;
+	unsigned char fpga_brdc_data;
+	void *fpga_enable;
+	void *fpga_polarity;
+	void *fpga_status;
+	void *fpga_trigger;
+
+	kb_data = ioremap(WALNUT_PS2_BASE, 8);
+	if (!kb_data) {
+		printk(KERN_CRIT
+		       "walnut_setup_arch() kb_data ioremap failed\n");
+		return;
 	}
-#endif /* CONFIG_BLK_DEV_INITRD */
 
-	/* Copy the kernel command line arguments to a safe place. */
+	kb_cs = kb_data + 1;
 
-	if (r6) {
- 		*(char *)(r7 + KERNELBASE) = 0;
-		strcpy(cmd_line, (char *)(r6 + KERNELBASE));
+	fpga_status = ioremap(WALNUT_FPGA_BASE, 8);
+	if (!fpga_status) {
+		printk(KERN_CRIT
+		       "walnut_setup_arch() fpga_status ioremap failed\n");
+		return;
 	}
 
-	/* Initialize machine-dependency vectors */
+	fpga_enable = fpga_status + 1;
+	fpga_polarity = fpga_status + 2;
+	fpga_trigger = fpga_status + 3;
+	fpga_brdc = fpga_status + 4;
 
-	ppc_md.setup_arch	 	= walnut_setup_arch;
-	ppc_md.show_percpuinfo	 	= walnut_show_percpuinfo;
-	ppc_md.irq_cannonicalize 	= NULL;
-	ppc_md.init_IRQ		 	= walnut_init_IRQ;
-	ppc_md.get_irq		 	= walnut_get_irq;
-	ppc_md.init		 	= NULL;
-
-	ppc_md.restart		 	= walnut_restart;
-	ppc_md.power_off	 	= walnut_power_off;
-	ppc_md.halt		 	= walnut_halt;
-
-	ppc_md.time_init	 	= walnut_time_init;
-	ppc_md.set_rtc_time	 	= walnut_set_rtc_time;
-	ppc_md.get_rtc_time	 	= walnut_get_rtc_time;
-	ppc_md.calibrate_decr	 	= walnut_calibrate_decr;
-
-	ppc_md.kbd_setkeycode    	= NULL;
-	ppc_md.kbd_getkeycode    	= NULL;
-	ppc_md.kbd_translate     	= NULL;
-	ppc_md.kbd_unexpected_up 	= NULL;
-	ppc_md.kbd_leds          	= NULL;
-	ppc_md.kbd_init_hw       	= NULL;
-	ppc_md.ppc_kbd_sysrq_xlate	= NULL;
-}
+	/* split the keyboard and mouse interrupts */
+	fpga_brdc_data = readb(fpga_brdc);
+	fpga_brdc_data |= 0x80;
+	writeb(fpga_brdc_data, fpga_brdc);
 
-/*
- * Document me.
- */
-void __init
-walnut_setup_arch(void)
-{
-	/* XXX - Implement me */
-}
+	writeb(0x3, fpga_enable);
 
-/*
- * int walnut_show_percpuinfo()
- *
- * Description:
- *   This routine pretty-prints the platform's internal CPU and bus clock
- *   frequencies into the buffer for usage in /proc/cpuinfo.
- *
- * Input(s):
- *  *buffer - Buffer into which CPU and bus clock frequencies are to be
- *            printed.
- *
- * Output(s):
- *  *buffer - Buffer with the CPU and bus clock frequencies.
- *
- * Returns:
- *   The number of bytes copied into 'buffer' if OK, otherwise zero or less
- *   on error.
- */
-int
-walnut_show_percpuinfo(struct seq_file *m)
-{
-	bd_t *bp = (bd_t *)__res;
+	writeb(0x3, fpga_polarity);
 
-	seq_printf(m, "clock\t\t: %dMHz\n"
-		   "bus clock\t\t: %dMHz\n",
-		   bp->bi_intfreq / 1000000,
-		   bp->bi_busfreq / 1000000);
+	writeb(0x3, fpga_trigger);
 
-	return 0;
+	/* RTC step for the walnut */
+	walnut_rtc_base = (void *) WALNUT_RTC_VADDR;
+	TODC_INIT(TODC_TYPE_DS1743, walnut_rtc_base, walnut_rtc_base,
+		  walnut_rtc_base, 8);
+	/* Identify the system */
+	printk("IBM Walnut port (C) 2000-2002 MontaVista Software, Inc. (source@mvista.com)\n");
 }
 
-/*
- * Document me.
- */
+#ifdef CONFIG_PCI
 void __init
-walnut_init_IRQ(void)
+bios_fixup(struct pci_controller *hose, struct pcil0_regs *pcip)
 {
-	int i;
-
-	ppc4xx_pic_init();
 
-	for (i = 0; i < NR_IRQS; i++) {
-		irq_desc[i].handler = ppc4xx_pic;
-	}
-
-	return;
-}
-
-/*
- * Document me.
- */
-int
-walnut_get_irq(struct pt_regs *regs)
-{
-	return (ppc4xx_pic_get_irq(regs));
-}
+	unsigned int bar_response, bar;
+	/*
+	 * Expected PCI mapping:
+	 *
+	 *  PLB addr             PCI memory addr
+	 *  ---------------------       ---------------------
+	 *  0000'0000 - 7fff'ffff <---  0000'0000 - 7fff'ffff
+	 *  8000'0000 - Bfff'ffff --->  8000'0000 - Bfff'ffff
+	 *
+	 *  PLB addr             PCI io addr
+	 *  ---------------------       ---------------------
+	 *  e800'0000 - e800'ffff --->  0000'0000 - 0001'0000
+	 *
+	 * The following code is simplified by assuming that the bootrom
+	 * has been well behaved in following this mapping.
+	 */
 
-/*
- * Document me.
- */
-void
-walnut_restart(char *cmd)
-{
-	abort();
-}
+#ifdef DEBUG
+	int i;
 
-/*
- * Document me.
- */
-void
-walnut_power_off(void)
-{
-	walnut_restart(NULL);
-}
+	printk("ioremap PCLIO_BASE = 0x%x\n", pcip);
+	printk("PCI bridge regs before fixup \n");
+	for (i = 0; i <= 3; i++) {
+		printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].ma)));
+		printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].la)));
+		printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].pcila)));
+		printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].pciha)));
+	}
+	printk(" ptm1ms\t0x%x\n", in_le32(&(pcip->ptm1ms)));
+	printk(" ptm1la\t0x%x\n", in_le32(&(pcip->ptm1la)));
+	printk(" ptm2ms\t0x%x\n", in_le32(&(pcip->ptm2ms)));
+	printk(" ptm2la\t0x%x\n", in_le32(&(pcip->ptm2la)));
+
+#endif
+
+	/* added for IBM boot rom version 1.15 bios bar changes  -AK */
+
+	/* Disable region first */
+	out_le32((void *) &(pcip->pmm[0].ma), 0x00000000);
+	/* PLB starting addr, PCI: 0x80000000 */
+	out_le32((void *) &(pcip->pmm[0].la), 0x80000000);
+	/* PCI start addr, 0x80000000 */
+	out_le32((void *) &(pcip->pmm[0].pcila), PPC405_PCI_MEM_BASE);
+	/* 512MB range of PLB to PCI */
+	out_le32((void *) &(pcip->pmm[0].pciha), 0x00000000);
+	/* Enable no pre-fetch, enable region */
+	out_le32((void *) &(pcip->pmm[0].ma), ((0xffffffff -
+						(PPC405_PCI_UPPER_MEM -
+						 PPC405_PCI_MEM_BASE)) | 0x01));
+
+	/* Disable region one */
+	out_le32((void *) &(pcip->pmm[1].ma), 0x00000000);
+	out_le32((void *) &(pcip->pmm[1].la), 0x00000000);
+	out_le32((void *) &(pcip->pmm[1].pcila), 0x00000000);
+	out_le32((void *) &(pcip->pmm[1].pciha), 0x00000000);
+	out_le32((void *) &(pcip->pmm[1].ma), 0x00000000);
+	out_le32((void *) &(pcip->ptm1ms), 0x00000000);
+
+	/* Disable region two */
+	out_le32((void *) &(pcip->pmm[2].ma), 0x00000000);
+	out_le32((void *) &(pcip->pmm[2].la), 0x00000000);
+	out_le32((void *) &(pcip->pmm[2].pcila), 0x00000000);
+	out_le32((void *) &(pcip->pmm[2].pciha), 0x00000000);
+	out_le32((void *) &(pcip->pmm[2].ma), 0x00000000);
+	out_le32((void *) &(pcip->ptm2ms), 0x00000000);
+
+	/* Zero config bars */
+	for (bar = PCI_BASE_ADDRESS_1; bar <= PCI_BASE_ADDRESS_2; bar += 4) {
+		early_write_config_dword(hose, hose->first_busno,
+					 PCI_FUNC(hose->first_busno), bar,
+					 0x00000000);
+		early_read_config_dword(hose, hose->first_busno,
+					PCI_FUNC(hose->first_busno), bar,
+					&bar_response);
+		DBG("BUS %d, device %d, Function %d bar 0x%8.8x is 0x%8.8x\n",
+		    hose->first_busno, PCI_SLOT(hose->first_busno),
+		    PCI_FUNC(hose->first_busno), bar, bar_response);
+	}
+	/* end work arround */
 
-/*
- * Document me.
- */
-void
-walnut_halt(void)
-{
-	walnut_restart(NULL);
-}
+#ifdef DEBUG
+	printk("PCI bridge regs after fixup \n");
+	for (i = 0; i <= 3; i++) {
+		printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].ma)));
+		printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].la)));
+		printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].pcila)));
+		printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].pciha)));
+	}
+	printk(" ptm1ms\t0x%x\n", in_le32(&(pcip->ptm1ms)));
+	printk(" ptm1la\t0x%x\n", in_le32(&(pcip->ptm1la)));
+	printk(" ptm2ms\t0x%x\n", in_le32(&(pcip->ptm2ms)));
+	printk(" ptm2la\t0x%x\n", in_le32(&(pcip->ptm2la)));
 
-/*
- * Document me.
- */
-long __init
-walnut_time_init(void)
-{
-	/* XXX - Implement me */
-	return 0;
+#endif
 }
+#endif
 
-/*
- * Document me.
- */
-int __init
-walnut_set_rtc_time(unsigned long time)
+void __init
+board_io_mapping(void)
 {
-	/* XXX - Implement me */
-
-	return (0);
+	io_block_mapping(WALNUT_RTC_VADDR,
+			 WALNUT_RTC_PADDR, WALNUT_RTC_SIZE, _PAGE_IO);
 }
 
-/*
- * Document me.
- */
-unsigned long __init
-walnut_get_rtc_time(void)
+void __init
+board_setup_irq(void)
 {
-	/* XXX - Implement me */
-
-	return (0);
 }
 
-/*
- * void __init walnut_calibrate_decr()
- *
- * Description:
- *   This routine retrieves the internal processor frequency from the board
- *   information structure, sets up the kernel timer decrementer based on
- *   that value, enables the 403 programmable interval timer (PIT) and sets
- *   it up for auto-reload.
- *
- * Input(s):
- *   N/A
- *
- * Output(s):
- *   N/A
- *
- * Returns:
- *   N/A
- *
- */
 void __init
-walnut_calibrate_decr(void)
+board_init(void)
 {
-	unsigned int freq;
-	bd_t *bip = (bd_t *)__res;
-
-	freq = bip->bi_intfreq;
-
-	decrementer_count = freq / HZ;
-	count_period_num = 1;
-	count_period_den = freq;
-
-	/* Enable the PIT and set auto-reload of its value */
-
-	mtspr(SPRN_TCR, TCR_PIE | TCR_ARE);
-
-	/* Clear any pending timer interrupts */
-
-	mtspr(SPRN_TSR, TSR_ENW | TSR_WIS | TSR_PIS | TSR_FIS);
+	ppc_md.time_init = todc_time_init;
+	ppc_md.set_rtc_time = todc_set_rtc_time;
+	ppc_md.get_rtc_time = todc_get_rtc_time;
+	ppc_md.nvram_read_val = todc_direct_read_val;
+	ppc_md.nvram_write_val = todc_direct_write_val;
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc/platforms/walnut.h linux-2.4.22-pre2/arch/ppc/platforms/walnut.h
--- linux-2.4.21/arch/ppc/platforms/walnut.h	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc/platforms/walnut.h	2003-06-26 21:43:11.000000000 +0000
@@ -1,50 +1,91 @@
 /*
  *
- *    Copyright (c) 1999-2000 Grant Erickson <grant@lcse.umn.edu>
+ *    Copyright (c) 1999 Grant Erickson <grant@lcse.umn.edu>
  *
- *    Module name: walnut_setup.c
+ *    Copyright 2000 MontaVista Software Inc.
+ *	PPC405 modifications
+ * 	Author: MontaVista Software, Inc.
+ *         	frank_rowand@mvista.com or source@mvista.com
+ * 	   	debbie_chu@mvista.com
+ *
+ *    Module name: ppc405.h
  *
  *    Description:
- *      Architecture- / platform-specific boot-time initialization code for
- *      the IBM PowerPC 405GP "Walnut" evaluation board. Adapted from original
- *      code by Gary Thomas, Cort Dougan <cort@cs.nmt.edu>, and Dan Malek
- *      <dan@netx4.com>.
+ *      Macros, definitions, and data structures specific to the IBM PowerPC
+ *      based boards.
+ *
+ *      This includes:
+ *
+ *         405GP "Walnut" evaluation board
  *
+ * Please read the COPYING file for all license details.
  */
 
-#ifndef	__WALNUT_SETUP_H__
-#define	__WALNUT_SETUP_H__
+#ifdef __KERNEL__
+#ifndef __ASM_WALNUT_H__
+#define __ASM_WALNUT_H__
 
-#include <asm/ptrace.h>
-#include <asm/board.h>
+/* We have a 405GP core */
+#include <platforms/ibm405gp.h>
 
+#ifndef __ASSEMBLY__
+/*
+ * Data structure defining board information maintained by the boot
+ * ROM on IBM's "Walnut" evaluation board. An effort has been made to
+ * keep the field names consistent with the 8xx 'bd_t' board info
+ * structures.
+ */
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern unsigned char	 __res[sizeof(bd_t)];
+typedef struct board_info {
+	unsigned char	 bi_s_version[4];	/* Version of this structure */
+	unsigned char	 bi_r_version[30];	/* Version of the IBM ROM */
+	unsigned int	 bi_memsize;		/* DRAM installed, in bytes */
+	unsigned char	 bi_enetaddr[6];	/* Local Ethernet MAC address */
+	unsigned char	 bi_pci_enetaddr[6];	/* PCI 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 */
+	unsigned int	 bi_opbfreq;		/* OPB Bus speed, in Hz */
+	int		 bi_iic_fast[1];	/* Use fast i2c mode */
+} bd_t;
+
+/* Some 4xx parts use a different timebase frequency from the internal clock.
+*/
+#define bi_tbfreq bi_intfreq
 
-extern void		 walnut_init(unsigned long r3,
-				  unsigned long ird_start,
-				  unsigned long ird_end,
-				  unsigned long cline_start,
-				  unsigned long cline_end);
-extern void		 walnut_setup_arch(void);
-extern int		 walnut_setup_residual(char *buffer);
-extern void		 walnut_init_IRQ(void);
-extern int		 walnut_get_irq(struct pt_regs *regs);
-extern void		 walnut_restart(char *cmd);
-extern void		 walnut_power_off(void);
-extern void		 walnut_halt(void);
-extern void		 walnut_time_init(void);
-extern int		 walnut_set_rtc_time(unsigned long now);
-extern unsigned long	 walnut_get_rtc_time(void);
-extern void		 walnut_calibrate_decr(void);
 
+/* Memory map for the IBM "Walnut" 405GP evaluation board.
+ * Generic 4xx plus RTC.
+ */
 
-#ifdef __cplusplus
-}
+extern void *walnut_rtc_base;
+#define WALNUT_RTC_PADDR	((uint)0xf0000000)
+#define WALNUT_RTC_VADDR	WALNUT_RTC_PADDR
+#define WALNUT_RTC_SIZE		((uint)8*1024)
+
+/* ps2 keyboard and mouse */
+#define KEYBOARD_IRQ		25
+#define AUX_IRQ			26
+
+#ifdef CONFIG_PPC405GP_INTERNAL_CLOCK
+#define BASE_BAUD		201600
+#else
+#define BASE_BAUD		691200
 #endif
 
-#endif /* __WALNUT_SETUP_H__ */
+#define WALNUT_PS2_BASE		0xF0100000
+#define WALNUT_FPGA_BASE	0xF0300000
+
+
+extern void *kb_cs;
+extern void *kb_data;
+#define kbd_read_input()	readb(kb_data)
+#define kbd_read_status()	readb(kb_cs)
+#define kbd_write_output(val)	writeb(val, kb_data)
+#define kbd_write_command(val)	writeb(val, kb_cs)
+
+#define PPC4xx_MACHINE_NAME	"IBM Walnut"
+
+#endif /* !__ASSEMBLY__ */
+#endif /* __ASM_WALNUT_H__ */
+#endif /* __KERNEL__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/Makefile linux-2.4.22-pre2/arch/ppc64/Makefile
--- linux-2.4.21/arch/ppc64/Makefile	2002-11-28 23:53:11.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/Makefile	2003-06-26 21:43:32.000000000 +0000
@@ -19,6 +19,13 @@
 CHECKS		= checks
 endif
 
+HAS_BIARCH      := $(shell if gcc -m64 -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo y; else echo n; fi;)
+ifeq ($(HAS_BIARCH),y)
+AS              := $(AS) -64
+LD              := $(LD) -m elf64ppc
+CC		:= gcc -m64
+endif
+
 LINKFLAGS	= -T arch/ppc64/vmlinux.lds -Bstatic \
 		-e $(KERNELLOAD) -Ttext $(KERNELLOAD)
 CFLAGS		:= $(CFLAGS) -fsigned-char -msoft-float -pipe \
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/boot/Makefile linux-2.4.22-pre2/arch/ppc64/boot/Makefile
--- linux-2.4.21/arch/ppc64/boot/Makefile	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/boot/Makefile	2003-06-26 21:43:22.000000000 +0000
@@ -52,7 +52,7 @@
 ifeq ($(CONFIG_PPC_ISERIES),y)
 all:	vmlinux.sm
 else
-all:	$(TOPDIR)/zImage
+all:	zImage
 endif
 
 
@@ -94,7 +94,7 @@
 
 zImage.o: $(TOPDIR)/vmlinux
 
-vmlinux .config System.map: % : $(TOPDIR)/%
+vmlinux .config System.map: % : $(TOPDIR)/% zImage.o
 	gzip -cvf9 $(TOPDIR)/$@ > kernel-$@.gz
 	$(OBJCOPY) zImage.o \
 		--add-section=.kernel:$@=kernel-$@.gz \
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/boot/addnote.c linux-2.4.22-pre2/arch/ppc64/boot/addnote.c
--- linux-2.4.21/arch/ppc64/boot/addnote.c	2002-08-03 00:39:43.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/boot/addnote.c	2003-06-26 21:43:22.000000000 +0000
@@ -14,6 +14,7 @@
  * Usage: addnote zImage
  */
 #include <stdio.h>
+#include <stdlib.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <string.h>
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/boot/zlib.c linux-2.4.22-pre2/arch/ppc64/boot/zlib.c
--- linux-2.4.21/arch/ppc64/boot/zlib.c	2002-08-03 00:39:43.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/boot/zlib.c	2003-06-26 21:43:29.000000000 +0000
@@ -735,7 +735,7 @@
       end-of-block.  Note however that the static length tree defines
       288 codes just to fill out the Huffman codes.  Codes 286 and 287
       cannot be used though, since there is no length base or extra bits
-      defined for them.  Similarily, there are up to 30 distance codes.
+      defined for them.  Similarly, there are up to 30 distance codes.
       However, static trees define 32 codes (all 5 bits) to fill out the
       Huffman codes, but the last two had better not show up in the data.
    7. Unzip can check dynamic Huffman blocks for complete code sets.
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/config.in linux-2.4.22-pre2/arch/ppc64/config.in
--- linux-2.4.21/arch/ppc64/config.in	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/config.in	2003-06-26 21:43:14.000000000 +0000
@@ -39,8 +39,13 @@
 bool 'MsChunks Physical to Absolute address translation support' CONFIG_MSCHUNKS
 tristate 'Firmware flash interface' CONFIG_RTAS_FLASH
 tristate 'Scanlog Dump interface' CONFIG_SCANLOG
+bool 'Support for RTAS (RunTime Abstraction Services) in /proc' CONFIG_PPC_RTAS
+     if [ "$CONFIG_PPC_RTAS" = "y" ]; then
+	bool 'RTAS Error Inject' CONFIG_RTAS_ERRINJCT
+     fi
 fi
 
+bool 'Shared kernel/user space addressing' CONFIG_SHARED_MEMORY_ADDRESSING
 
 endmenu
 
@@ -238,6 +243,7 @@
 bool 'Include kgdb kernel debugger' CONFIG_KGDB
 bool 'Include xmon kernel debugger' CONFIG_XMON
 bool 'Include kdb kernel debugger' CONFIG_KDB
+bool 'Debug memory allocations' CONFIG_DEBUG_SLAB
 if [ "$CONFIG_KDB" = "y" ]; then
   bool '  KDB off by default' CONFIG_KDB_OFF
   define_bool CONFIG_KALLSYMS y
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/configs/iSeries_devfs_defconfig linux-2.4.22-pre2/arch/ppc64/configs/iSeries_devfs_defconfig
--- linux-2.4.21/arch/ppc64/configs/iSeries_devfs_defconfig	2002-11-28 23:53:11.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/configs/iSeries_devfs_defconfig	2003-06-26 21:43:28.000000000 +0000
@@ -700,6 +700,6 @@
 # CONFIG_KDB_OFF is not set
 # CONFIG_KALLSYMS is not set
 # CONFIG_PPCDBG is not set
-CONFIG_DUMP=y
-CONFIG_DUMP_COMPRESS_RLE=y
-CONFIG_DUMP_COMPRESS_GZIP=y
+# CONFIG_DUMP is not set
+# CONFIG_DUMP_COMPRESS_RLE is not set
+# CONFIG_DUMP_COMPRESS_GZIP is not set
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/configs/iSeries_nodevfs_ideemul_defconfig linux-2.4.22-pre2/arch/ppc64/configs/iSeries_nodevfs_ideemul_defconfig
--- linux-2.4.21/arch/ppc64/configs/iSeries_nodevfs_ideemul_defconfig	2002-11-28 23:53:11.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/configs/iSeries_nodevfs_ideemul_defconfig	2003-06-26 21:43:12.000000000 +0000
@@ -635,6 +635,6 @@
 # CONFIG_KDB_OFF is not set
 # CONFIG_KALLSYMS is not set
 # CONFIG_PPCDBG is not set
-CONFIG_DUMP=y
-CONFIG_DUMP_COMPRESS_RLE=y
-CONFIG_DUMP_COMPRESS_GZIP=y
+# CONFIG_DUMP is not set
+# CONFIG_DUMP_COMPRESS_RLE is not set
+# CONFIG_DUMP_COMPRESS_GZIP is not set
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/configs/pSeries_defconfig linux-2.4.22-pre2/arch/ppc64/configs/pSeries_defconfig
--- linux-2.4.21/arch/ppc64/configs/pSeries_defconfig	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/configs/pSeries_defconfig	2003-06-26 21:43:17.000000000 +0000
@@ -27,6 +27,9 @@
 # CONFIG_MSCHUNKS is not set
 CONFIG_RTAS_FLASH=m
 CONFIG_SCANLOG=m
+CONFIG_PPC_RTAS=y
+# CONFIG_RTAS_ERRINJCT is not set
+# CONFIG_SHARED_MEMORY_ADDRESSING is not set
 
 #
 # Loadable module support
@@ -173,6 +176,7 @@
 # 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
@@ -726,9 +730,12 @@
 #
 CONFIG_MAGIC_SYSRQ=y
 # CONFIG_KGDB is not set
-CONFIG_XMON=y
-# CONFIG_KDB is not set
-# CONFIG_KDB is not set
-# CONFIG_KALLSYMS is not set
+# CONFIG_XMON is not set
+# CONFIG_KDB  is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_KDB_OFF is not set
+CONFIG_KALLSYMS=y
 CONFIG_PPCDBG=y
 # CONFIG_DUMP is not set
+# CONFIG_DUMP_COMPRESS_RLE is not set
+# CONFIG_DUMP_COMPRESS_GZIP is not set
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/defconfig linux-2.4.22-pre2/arch/ppc64/defconfig
--- linux-2.4.21/arch/ppc64/defconfig	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/defconfig	2003-06-26 21:43:20.000000000 +0000
@@ -27,6 +27,9 @@
 # CONFIG_MSCHUNKS is not set
 CONFIG_RTAS_FLASH=m
 CONFIG_SCANLOG=m
+CONFIG_PPC_RTAS=y
+# CONFIG_RTAS_ERRINJCT is not set
+# CONFIG_SHARED_MEMORY_ADDRESSING is not set
 
 #
 # Loadable module support
@@ -190,7 +193,7 @@
 # CONFIG_IDEDMA_ONLYDISK is not set
 CONFIG_BLK_DEV_IDEDMA=y
 # CONFIG_IDEDMA_PCI_WIP is not set
-CONFIG_BLK_DEV_ADMA=y
+# CONFIG_BLK_DEV_ADMA100 is not set
 # CONFIG_BLK_DEV_AEC62XX is not set
 # CONFIG_BLK_DEV_ALI15X3 is not set
 # CONFIG_WDC_ALI15X3 is not set
@@ -204,13 +207,11 @@
 # CONFIG_HPT34X_AUTODMA is not set
 # CONFIG_BLK_DEV_HPT366 is not set
 # CONFIG_BLK_DEV_PIIX is not set
-# CONFIG_BLK_DEV_NFORCE is not set
 # CONFIG_BLK_DEV_NS87415 is not set
 # CONFIG_BLK_DEV_OPTI621 is not set
 # CONFIG_BLK_DEV_PDC202XX_OLD is not set
 # CONFIG_PDC202XX_BURST is not set
 # CONFIG_BLK_DEV_PDC202XX_NEW is not set
-# CONFIG_PDC202XX_FORCE is not set
 # CONFIG_BLK_DEV_RZ1000 is not set
 # CONFIG_BLK_DEV_SC1200 is not set
 # CONFIG_BLK_DEV_SVWKS is not set
@@ -266,6 +267,7 @@
 # CONFIG_SCSI_AHA1740 is not set
 # CONFIG_SCSI_AACRAID is not set
 # CONFIG_SCSI_AIC7XXX is not set
+# CONFIG_SCSI_AIC79XX is not set
 # CONFIG_SCSI_AIC7XXX_OLD is not set
 # CONFIG_SCSI_DPT_I2O is not set
 # CONFIG_SCSI_ADVANSYS is not set
@@ -361,6 +363,7 @@
 # CONFIG_DGRS is not set
 # CONFIG_DM9102 is not set
 # CONFIG_EEPRO100 is not set
+# CONFIG_EEPRO100_PIO is not set
 CONFIG_E100=y
 # CONFIG_LNE390 is not set
 # CONFIG_FEALNX is not set
@@ -467,12 +470,14 @@
 CONFIG_FB_MATROX=y
 CONFIG_FB_MATROX_MILLENIUM=y
 CONFIG_FB_MATROX_MYSTIQUE=y
-CONFIG_FB_MATROX_G100=y
 # CONFIG_FB_MATROX_G450 is not set
+# CONFIG_FB_MATROX_G100A is not set
+# CONFIG_FB_MATROX_PROC is not set
 # CONFIG_FB_MATROX_MULTIHEAD is not set
 # CONFIG_FB_ATY is not set
 # CONFIG_FB_RADEON is not set
 # CONFIG_FB_ATY128 is not set
+# CONFIG_FB_INTEL is not set
 # CONFIG_FB_SIS is not set
 # CONFIG_FB_NEOMAGIC is not set
 # CONFIG_FB_3DFX is not set
@@ -726,9 +731,8 @@
 #
 CONFIG_MAGIC_SYSRQ=y
 # CONFIG_KGDB is not set
-CONFIG_XMON=y
+# CONFIG_XMON is not set
 # CONFIG_KDB is not set
-# CONFIG_KDB is not set
-# CONFIG_KALLSYMS is not set
+# CONFIG_DEBUG_SLAB is not set
 CONFIG_PPCDBG=y
 # CONFIG_DUMP is not set
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/LparData.c linux-2.4.22-pre2/arch/ppc64/kernel/LparData.c
--- linux-2.4.21/arch/ppc64/kernel/LparData.c	2002-11-28 23:53:11.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/LparData.c	2003-06-26 21:43:11.000000000 +0000
@@ -71,7 +71,7 @@
 	6,		/* TEMP: This allows non-GA driver */
 	4,		/* We are v5r2m0               */
 	3,		/* Min supported PLIC = v5r1m0 */
-	3,		/* Min usuable PLIC   = v5r1m0 */
+	3,		/* Min usable PLIC   = v5r1m0 */
 	{ 0xd3, 0x89, 0x95, 0xa4, /* "Linux 2.4   "*/
 	  0xa7, 0x40, 0xf2, 0x4b,
 	  0xf4, 0x4b, 0xf6, 0xf4 },
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/Makefile linux-2.4.22-pre2/arch/ppc64/kernel/Makefile
--- linux-2.4.21/arch/ppc64/kernel/Makefile	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/Makefile	2003-06-26 21:43:19.000000000 +0000
@@ -27,7 +27,7 @@
 			pmc.o mf_proc.o proc_pmc.o proc_pcifr.o iSeries_setup.o \
 			ItLpQueue.o hvCall.o mf.o HvLpEvent.o ras.o \
 			iSeries_proc.o HvCall.o flight_recorder.o HvLpConfig.o \
-			rtc.o perfmon.o
+			rtc.o perfmon.o cputable.o
 
 obj-$(CONFIG_PCI) +=  pci.o pci_dn.o pci_dma.o pSeries_lpar.o pSeries_hvCall.o
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/XmPciLpEvent.c linux-2.4.22-pre2/arch/ppc64/kernel/XmPciLpEvent.c
--- linux-2.4.21/arch/ppc64/kernel/XmPciLpEvent.c	2002-11-28 23:53:11.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/XmPciLpEvent.c	2003-06-26 21:43:10.000000000 +0000
@@ -34,7 +34,7 @@
 enum XmPciLpEvent_Subtype {
 	XmPciLpEvent_BusCreated	   = 0,		// PHB has been created
 	XmPciLpEvent_BusError	   = 1,		// PHB has failed
-	XmPciLpEvent_BusFailed	   = 2,		// Msg to Seconday, Primary failed bus
+	XmPciLpEvent_BusFailed	   = 2,		// Msg to Secondary, Primary failed bus
 	XmPciLpEvent_NodeFailed	   = 4,		// Multi-adapter bridge has failed
 	XmPciLpEvent_NodeRecovered = 5,		// Multi-adapter bridge has recovered
 	XmPciLpEvent_BusRecovered  = 12,	// PHB has been recovered
@@ -99,7 +99,7 @@
 			break;
 		}
 	}
-	else if (event) {
+	else if (eventParm) {
 		printk(KERN_ERR "XmPciLpEvent.c: Unrecognized PCI event type 0x%x\n",(int)eventParm->xType);
 	}
 	else {
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/align.c linux-2.4.22-pre2/arch/ppc64/kernel/align.c
--- linux-2.4.21/arch/ppc64/kernel/align.c	2002-11-28 23:53:11.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/align.c	2003-06-26 21:43:16.000000000 +0000
@@ -21,6 +21,7 @@
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #include <asm/cache.h>
+#include <asm/cputable.h>
 
 struct aligninfo {
 	unsigned char len;
@@ -238,7 +239,7 @@
 	dsisr = regs->dsisr;
 
 	/* Power4 doesn't set DSISR for an alignment interrupt */
-	if (__is_processor(PV_POWER4) || __is_processor(PV_POWER4p))
+	if (cur_cpu_spec->cpu_features & CPU_FTR_NODSISRALIGN)
 		dsisr = make_dsisr( *((unsigned *)regs->nip) );
 
 	/* extract the operation and registers from the dsisr */
@@ -306,6 +307,7 @@
 				/* Doing stfs, have to convert to single */
 				enable_kernel_fp();
 				cvt_df(&current->thread.fpr[reg], (float *)&data.v[4], &current->thread.fpscr);
+				disable_kernel_fp();
 			}
 			else
 				data.dd = current->thread.fpr[reg];
@@ -339,6 +341,7 @@
 				/* Doing lfs, have to convert to double */
 				enable_kernel_fp();
 				cvt_fd((float *)&data.v[4], &current->thread.fpr[reg], &current->thread.fpscr);
+				disable_kernel_fp();
 			}
 			else
 				current->thread.fpr[reg] = data.dd;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/chrp_setup.c linux-2.4.22-pre2/arch/ppc64/kernel/chrp_setup.c
--- linux-2.4.21/arch/ppc64/kernel/chrp_setup.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/chrp_setup.c	2003-06-26 21:43:29.000000000 +0000
@@ -65,6 +65,7 @@
 #include "open_pic.h"
 #include "xics.h"
 #include <asm/ppcdebug.h>
+#include <asm/cputable.h>
 
 extern volatile unsigned char *chrp_int_ack_special;
 
@@ -305,6 +306,32 @@
 	SYSRQ_KEY = 0x63;	/* Print Screen */
 #endif
 #endif
+        /* 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().
+         */
+	struct device_node * dn;
+	char * hypertas;
+	unsigned int len;
+	dn = find_path_device("/rtas");
+	cur_cpu_spec->firmware_features=0;
+	hypertas = get_property(dn, "ibm,hypertas-functions", &len);
+	if (hypertas) {
+	    while (len > 0){
+		int i;
+	    /* check value against table of strings */
+		for(i=0; i < FIRMWARE_MAX_FEATURES ;i++) {
+		    if ((firmware_features_table[i].name) && (strcmp(firmware_features_table[i].name,hypertas))==0) {
+		    /* we have a match */
+			cur_cpu_spec->firmware_features |= (1UL << firmware_features_table[i].val );
+			break;
+		    }
+		}
+		int hypertas_len = strlen(hypertas);
+		len -= hypertas_len +1;
+		hypertas+= hypertas_len +1;
+	    }
+	}
 }
 
 void __chrp
@@ -315,6 +342,8 @@
 	char *os;
 	static int display_character, set_indicator;
 	static int max_width;
+	static spinlock_t progress_lock = SPIN_LOCK_UNLOCKED;
+	static int pending_newline = 0;  /* did last write end with unprinted newline? */
 
 	if (!rtas.base)
 		return;
@@ -330,34 +359,79 @@
 		display_character = rtas_token("display-character");
 		set_indicator = rtas_token("set-indicator");
 	}
-	if (display_character == RTAS_UNKNOWN_SERVICE) {
-		/* use hex display */
-		if (set_indicator == RTAS_UNKNOWN_SERVICE)
-			return;
-		rtas_call(set_indicator, 3, 1, NULL, 6, 0, hex);
+
+	if(display_character == RTAS_UNKNOWN_SERVICE) {
+		/* use hex display if available */
+		if(set_indicator != RTAS_UNKNOWN_SERVICE)
+			rtas_call(set_indicator, 3, 1, NULL, 6, 0, hex);
 		return;
 	}
 
-	rtas_call(display_character, 1, 1, NULL, '\r');
+	spin_lock(&progress_lock);
 
+	/* Last write ended with newline, but we didn't print it since
+	 * it would just clear the bottom line of output. Print it now
+	 * instead.
+	 *
+	 * If no newline is pending, print a CR to start output at the
+	 * beginning of the line.
+	 */
+	if(pending_newline) {
+		rtas_call(display_character, 1, 1, NULL, '\r');
+		rtas_call(display_character, 1, 1, NULL, '\n');
+		pending_newline = 0;
+	} else
+		rtas_call(display_character, 1, 1, NULL, '\r');
+ 
 	width = max_width;
 	os = s;
-	while ( *os )
-	{
-		if ( (*os == '\n') || (*os == '\r') )
+	while (*os) {
+		if(*os == '\n' || *os == '\r') {
+			/* Blank to end of line. */
+			while(width-- > 0)
+				rtas_call(display_character, 1, 1, NULL, ' ');
+ 
+			/* If newline is the last character, save it
+			 * until next call to avoid bumping up the
+			 * display output.
+			 */
+			if(*os == '\n' && !os[1]) {
+				pending_newline = 1;
+				spin_unlock(&progress_lock);
+				return;
+			}
+ 
+			/* RTAS wants CR-LF, not just LF */
+ 
+			if(*os == '\n') {
+				rtas_call(display_character, 1, 1, NULL, '\r');
+				rtas_call(display_character, 1, 1, NULL, '\n');
+			} else {
+				/* CR might be used to re-draw a line, so we'll
+				 * leave it alone and not add LF.
+				 */
+				rtas_call(display_character, 1, 1, NULL, *os);
+			}
+ 
 			width = max_width;
-		else
+		} else {
 			width--;
-		rtas_call(display_character, 1, 1, NULL, *os++ );
+			rtas_call(display_character, 1, 1, NULL, *os);
+		}
+ 
+		os++;
+ 
 		/* if we overwrite the screen length */
-		if ( width == 0 )
+		if ( width <= 0 )
 			while ( (*os != 0) && (*os != '\n') && (*os != '\r') )
 				os++;
 	}
-
+ 
 	/* Blank to end of line. */
 	while ( width-- > 0 )
 		rtas_call(display_character, 1, 1, NULL, ' ' );
+
+	spin_unlock(&progress_lock);
 }
 
 extern void setup_default_decr(void);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/cputable.c linux-2.4.22-pre2/arch/ppc64/kernel/cputable.c
--- linux-2.4.21/arch/ppc64/kernel/cputable.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/cputable.c	2003-06-26 21:43:32.000000000 +0000
@@ -0,0 +1,127 @@
+/*
+ *  arch/ppc/kernel/cputable.c
+ *
+ *  Copyright (C) 2001 Ben. Herrenschmidt (benh@kernel.crashing.org)
+ *
+ *  Modifications for ppc64:
+ *      Copyright (C) 2003 Dave Engebretsen <engebret@us.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/string.h>
+#include <linux/sched.h>
+#include <linux/threads.h>
+#include <linux/init.h>
+#include <asm/cputable.h>
+
+struct cpu_spec* cur_cpu_spec = NULL;
+
+extern void __setup_cpu_power3(unsigned long offset, struct cpu_spec* spec);
+extern void __setup_cpu_power4(unsigned long offset, struct cpu_spec* spec);
+
+
+/* We only set the altivec features if the kernel was compiled with altivec
+ * support
+ */
+#ifdef CONFIG_ALTIVEC
+#define CPU_FTR_ALTIVEC_COMP	CPU_FTR_ALTIVEC
+#else
+#define CPU_FTR_ALTIVEC_COMP	0
+#endif
+
+struct cpu_spec	cpu_specs[] = {
+    {	/* Power3 */
+	    0xffff0000, 0x00400000, "Power3 (630)",
+	    CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE,
+	    COMMON_USER_PPC64,
+	    128, 128,
+	    __setup_cpu_power3,
+	    COMMON_PPC64_FW
+    },
+    {	/* Power3+ */
+	    0xffff0000, 0x00410000, "Power3 (630+)",
+	    CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE,
+	    COMMON_USER_PPC64,
+	    128, 128,
+	    __setup_cpu_power3,
+	    COMMON_PPC64_FW
+    },
+    {	/* Northstar */
+	    0xffff0000, 0x00330000, "Northstar",
+	    CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE,
+	    COMMON_USER_PPC64,
+	    128, 128,
+	    __setup_cpu_power3,
+	    COMMON_PPC64_FW
+    },
+    {	/* Pulsar */
+	    0xffff0000, 0x00340000, "Pulsar",
+	    CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE,
+	    COMMON_USER_PPC64,
+	    128, 128,
+	    __setup_cpu_power3,
+	    COMMON_PPC64_FW
+    },
+    {	/* I-star */
+	    0xffff0000, 0x00360000, "I-star",
+	    CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE,
+	    COMMON_USER_PPC64,
+	    128, 128,
+	    __setup_cpu_power3,
+	    COMMON_PPC64_FW
+    },
+    {	/* S-star */
+	    0xffff0000, 0x00370000, "S-star",
+	    CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE,
+	    COMMON_USER_PPC64,
+	    128, 128,
+	    __setup_cpu_power3,
+	    COMMON_PPC64_FW
+    },
+    {	/* Power4 */
+	    0xffff0000, 0x00350000, "Power4",
+	    CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE |
+	    CPU_FTR_PPCAS_ARCH_V2,
+	    COMMON_USER_PPC64,
+	    128, 128,
+	    __setup_cpu_power4,
+	    COMMON_PPC64_FW
+    },
+    {	/* Power4+ */
+	    0xffff0000, 0x00380000, "Power4+",
+	    CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE |
+	    CPU_FTR_PPCAS_ARCH_V2,
+	    COMMON_USER_PPC64,
+	    128, 128,
+	    __setup_cpu_power4,
+	    COMMON_PPC64_FW
+    },
+    {	/* default match */
+	    0x00000000, 0x00000000, "(Power4-Compatible)",
+  	    CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE |
+	    CPU_FTR_PPCAS_ARCH_V2,
+	    COMMON_USER_PPC64,
+	    128, 128,
+	    __setup_cpu_power4,
+	    COMMON_PPC64_FW
+    }
+};
+
+firmware_feature_t firmware_features_table[FIRMWARE_MAX_FEATURES] = {
+    {FW_FEATURE_PFT,		"hcall-pft"},
+    {FW_FEATURE_TCE,		"hcall-tce"},
+    {FW_FEATURE_SPRG0,		"hcall-sprg0"},
+    {FW_FEATURE_DABR,		"hcall-dabr"},
+    {FW_FEATURE_COPY,		"hcall-copy"},
+    {FW_FEATURE_ASR,		"hcall-asr"},
+    {FW_FEATURE_DEBUG,		"hcall-debug"},
+    {FW_FEATURE_PERF,		"hcall-perf"},
+    {FW_FEATURE_DUMP,		"hcall-dump"},
+    {FW_FEATURE_INTERRUPT,	"hcall-interrupt"},
+    {FW_FEATURE_MIGRATE,	"hcall-migrate"},
+};
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/eeh.c linux-2.4.22-pre2/arch/ppc64/kernel/eeh.c
--- linux-2.4.21/arch/ppc64/kernel/eeh.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/eeh.c	2003-06-26 21:43:18.000000000 +0000
@@ -129,17 +129,16 @@
 	int adapters_enabled;
 };
 
-/* Enable eeh for the given device node. */
-static void *early_enable_eeh(struct device_node *dn, void *data)
+
+/* Enable/disable eeh for the given device node. */
+static void *early_set_eeh(struct device_node *dn, struct eeh_early_enable_info *info, int enable)
 {
-	struct eeh_early_enable_info *info = data;
 	long ret;
 	char *status = get_property(dn, "status", 0);
 	u32 *class_code = (u32 *)get_property(dn, "class-code", 0);
 	u32 *vendor_id =(u32 *) get_property(dn, "vendor-id", 0);
 	u32 *device_id = (u32 *)get_property(dn, "device-id", 0);
 	u32 *regs;
-	int enable;
 
 	if (status && strcmp(status, "ok") != 0)
 		return NULL;	/* ignore devices with bad status */
@@ -161,15 +160,19 @@
 	 * hang waiting on status bits that won't change, etc.
 	 * But there are a few cases like display devices that make sense.
 	 */
-	enable = 1;	/* i.e. we will do checking */
-	if ((*class_code >> 16) == PCI_BASE_CLASS_DISPLAY)
-		enable = 0;
 
 	if (!eeh_check_opts_config(dn, *class_code, *vendor_id, *device_id, enable)) {
 		if (enable) {
 			printk(KERN_INFO "EEH: %s user requested to run without EEH.\n", dn->full_name);
 			enable = 0;
 		}
+#if 0
+	/* Turn off EEH automatically for graphics ... 
+	* but we don't want to do this, not really. .... */
+	} else 	if ((*class_code >> 16) == PCI_BASE_CLASS_DISPLAY) {
+		printk(KERN_INFO "EEH: %s DISPLAY automatically set to run without EEH.\n", dn->full_name);
+		enable = 0;
+#endif
 	}
 
 	if (!enable)
@@ -179,6 +182,16 @@
 	if (dn->parent && (dn->parent->eeh_mode & EEH_MODE_SUPPORTED)) {
 		/* Parent supports EEH. */
 		dn->eeh_mode |= EEH_MODE_SUPPORTED;
+
+		/* Recurse to parent to set EEH, since we are probably
+		 * a non-eeh supporting pci bridge chip on some card. 
+		 * But recurse only if our eeh setting is to be different.
+		 */
+		if ((enable && (EEH_MODE_NOCHECK == dn->eeh_mode)) ||
+		    (!enable && (EEH_MODE_NOCHECK != dn->eeh_mode))) 
+		{
+			early_set_eeh (dn->parent, info, enable);
+		}
 		dn->eeh_config_addr = dn->parent->eeh_config_addr;
 		return NULL;
 	}
@@ -187,19 +200,29 @@
 	regs = (u32 *)get_property(dn, "reg", 0);
 	if (regs) {
 		/* First register entry is addr (00BBSS00)  */
-		/* Try to enable eeh */
+		/* Try to enable/disable eeh */
 		ret = rtas_call(ibm_set_eeh_option, 4, 1, NULL,
 				regs[0], info->buid_hi, info->buid_lo,
-				EEH_ENABLE);
+				enable ? EEH_ENABLE : EEH_DISABLE);
 		if (ret == 0) {
 			info->adapters_enabled++;
 			dn->eeh_mode |= EEH_MODE_SUPPORTED;
 			dn->eeh_config_addr = regs[0];
+		} else {
+			printk(KERN_INFO "EEH: %s failed to %s ret=%ld\n", dn->full_name, enable ? "enable" : "disable", ret);
 		}
 	}
 	return NULL; 
 }
 
+/* Enable eeh for the given device node. */
+static void *early_enable_eeh(struct device_node *dn, void *data)
+{
+	struct eeh_early_enable_info *info = data;
+	/* Set enable to 1, i.e. we will do checking */
+	return early_set_eeh (dn, info, 1);
+}
+
 /*
  * Initialize eeh by trying to enable it for all of the adapters in the system.
  * As a side effect we can determine here if eeh is supported at all.
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/entry.S linux-2.4.22-pre2/arch/ppc64/kernel/entry.S
--- linux-2.4.21/arch/ppc64/kernel/entry.S	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/entry.S	2003-06-26 21:43:12.000000000 +0000
@@ -437,7 +437,7 @@
 	mfsrr1	r10
 	std	r10,_SRR1(r1)
 
-	/* Unfortunatly, the stack pointer and the MSR are also clobbered,
+	/* Unfortunately, the stack pointer and the MSR are also clobbered,
 	 * so they are saved in the PACA (SPRG3) which allows us to restore
 	 * our original state after RTAS returns.
          */
@@ -548,7 +548,7 @@
 	mfmsr	r11
 	std	r11,_MSR(r1)
 
-	/* Unfortunatly, the stack pointer is also clobbered, so it is saved
+	/* Unfortunately, the stack pointer is also clobbered, so it is saved
 	 * in the SPRG2 which allows us to restore our original state after
 	 * PROM returns.
          */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/head.S linux-2.4.22-pre2/arch/ppc64/kernel/head.S
--- linux-2.4.21/arch/ppc64/kernel/head.S	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/head.S	2003-06-26 21:43:10.000000000 +0000
@@ -32,6 +32,7 @@
 #include <linux/config.h>
 #include <asm/mmu.h>
 #include <asm/perfmon.h>
+#include <asm/cputable.h>
 
 #ifdef CONFIG_PPC_ISERIES
 #define DO_SOFT_DISABLE
@@ -746,6 +747,13 @@
 #ifdef CONFIG_XMON
 	bl	.xmon
 #endif
+#ifdef CONFIG_KDB
+        /*          kdb(KDB_REASON_FAULT,regs->trap,regs); */
+	li      r3,1
+	li 	r4,0x200
+	li      r5,0
+	bl	.kdb
+#endif
 4:	b	4b
 
 
@@ -781,11 +789,16 @@
 FPUnavailable_common:
 	EXCEPTION_PROLOG_COMMON
 	bne	.load_up_fpu		/* if from user, just load it up */
-	li	r20,0
+	addi	r3,r1,STACK_FRAME_OVERHEAD
+#ifdef DO_SOFT_DISABLE
+	ld	r20,SOFTE(r1)
+#else
+	rldicl	r20,r23,49,63   	/* copy EE bit from saved MSR */
+#endif
 	li	r6,0x800
-	bl      .save_remaining_regs    /* if from kernel, take a trap */
-	bl      .KernelFP
-	b       .ret_from_except
+	bl      .save_remaining_regs
+	bl      .KernelFPUnavailableException
+	BUG_OPCODE
 
 	.globl SystemCall_common
 SystemCall_common:
@@ -1390,6 +1403,11 @@
 	li	r0,0
 	stdu	r0,-STACK_FRAME_OVERHEAD(r1)
 
+	LOADADDR(r3,cpu_specs)
+	LOADADDR(r4,cur_cpu_spec)
+	li	r5,0
+	bl	.identify_cpu
+
 	LOADADDR(r2,__toc_start)
 	addi	r2,r2,0x4000
 	addi	r2,r2,0x4000
@@ -1619,21 +1637,19 @@
 	/* restore registers and return */
 	b	fast_exception_return
 
+
 /*
- * FP unavailable trap from kernel - print a message, but let
- * the task use FP in the kernel until it returns to user mode.
+ * disable_kernel_fp()
+ * Disable the FPU.
  */
-_GLOBAL(KernelFP)
-	ld	r3,_MSR(r1)
-	ori	r3,r3,MSR_FP
-	std	r3,_MSR(r1)		/* enable use of FP after return */
-	LOADADDR(r3,86f)
-	mfspr	r4,SPRG3		/* Get PACA */
-	ld	r4,PACACURRENT(r4)	/* current */
-	ld	r5,_NIP(r1)
-	b	.ret_from_except
-86:	.string	"floating point used in kernel (task=%p, pc=%x)\n"
-	.align	4
+_GLOBAL(disable_kernel_fp)
+	mfmsr   r3
+	rldicl  r0,r3,(63-MSR_FP_LG),1
+	rldicl  r3,r0,(MSR_FP_LG+1),0
+	mtmsrd  r3			/* disable use of fpu now */
+	isync
+	blr
+
 
 /*
  * giveup_fpu(tsk)
@@ -1861,6 +1877,13 @@
 	li	r0,0
 	stdu	r0,-STACK_FRAME_OVERHEAD(r1)
 
+	LOADADDR(r3,cpu_specs)
+	sub	r3,r3,r26
+	LOADADDR(r4,cur_cpu_spec)
+	sub	r4,r4,r26
+	mr	r5,r26
+	bl	.identify_cpu
+
 	/* set up the TOC (physical address) */
 	LOADADDR(r2,__toc_start)
 	addi    r2,r2,0x4000
@@ -1949,6 +1972,9 @@
 	addi    r2,r2,0x4000
 	addi    r2,r2,0x4000
 
+	li	r3,0
+	bl	.do_cpu_ftr_fixups
+
 	/* setup the systemcfg pointer                                       */
 	LOADADDR(r9,systemcfg)
 	SET_REG_TO_CONST(r8, KERNELBASE+0x5000)
@@ -2006,6 +2032,11 @@
 
 	bl .start_kernel
 
+_GLOBAL(__setup_cpu_power3)
+	blr
+_GLOBAL(__setup_cpu_power4)
+	blr
+
 _GLOBAL(hmt_init)
 #ifdef CONFIG_HMT
 	LOADADDR(r5, hmt_thread_data)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/htab.c linux-2.4.22-pre2/arch/ppc64/kernel/htab.c
--- linux-2.4.21/arch/ppc64/kernel/htab.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/htab.c	2003-06-26 21:43:29.000000000 +0000
@@ -46,6 +46,7 @@
 #include <asm/hvcall.h>
 #include <asm/iSeries/LparData.h>
 #include <asm/iSeries/HvCallHpt.h>
+#include <asm/cputable.h>
 
 /*
  * Note:  pte   --> Linux PTE
@@ -183,7 +184,9 @@
 
 	/* XXX we currently map kernel text rw, should fix this */
 	if ((systemcfg->platform & PLATFORM_PSERIES) &&
-	   cpu_has_largepage() && (systemcfg->physicalMemorySize > 256*MB)) {
+	    (cur_cpu_spec->cpu_features & 
+	     CPU_FTR_16M_PAGE) &&
+	    (systemcfg->physicalMemorySize > 256*MB)) {
 		create_pte_mapping((unsigned long)KERNELBASE, 
 				   KERNELBASE + 256*MB, mode_rw, mask, 0);
 		create_pte_mapping((unsigned long)KERNELBASE + 256*MB, 
@@ -334,11 +337,23 @@
 	 * Check the user's access rights to the page.  If access should be
 	 * prevented then send the problem up to do_page_fault.
 	 */
+#ifdef CONFIG_SHARED_MEMORY_ADDRESSING
+	access |= _PAGE_PRESENT;
+	if (unlikely(access & ~(pte_val(*ptep)))) {
+		if(!(((ea >> SMALLOC_EA_SHIFT) == 
+		      (SMALLOC_START >> SMALLOC_EA_SHIFT)) &&
+		     ((current->thread.flags) & PPC_FLAG_SHARED))) {
+			spin_unlock(&hash_table_lock[lock_slot].lock);
+			return 1;
+		}
+	}
+#else
 	access |= _PAGE_PRESENT;
 	if (unlikely(access & ~(pte_val(*ptep)))) {
 		spin_unlock(&hash_table_lock[lock_slot].lock);
 		return 1;
 	}
+#endif
 
 	/* 
 	 * We have found a pte (which was present).
@@ -446,6 +461,19 @@
 	case VMALLOC_REGION_ID:
 		mm = &init_mm;
 		vsid = get_kernel_vsid(ea);
+#ifdef CONFIG_SHARED_MEMORY_ADDRESSING
+                /*
+                 * Check if this is a user task with shared access to kernel
+                 * data & we got a protection fault.  If it is, the kernel
+                 * must have faulted in the segment and the protection flags
+                 * on the segment are kernel access only.  Just flush the
+                 * segment table & fault in the segment with the right flags.
+                 */
+                if(((current->thread.flags) & PPC_FLAG_SHARED) &&
+                   (access & _PAGE_USER)) {
+                        flush_stab();
+                }
+#endif
 		break;
 	case EEH_REGION_ID:
 		/*
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/i8259.c linux-2.4.22-pre2/arch/ppc64/kernel/i8259.c
--- linux-2.4.21/arch/ppc64/kernel/i8259.c	2002-08-03 00:39:43.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/i8259.c	2003-06-26 21:43:28.000000000 +0000
@@ -146,7 +146,7 @@
         /* init master interrupt controller */
         outb(0x11, 0x20); /* Start init sequence */
         outb(0x00, 0x21); /* Vector base */
-        outb(0x04, 0x21); /* edge tiggered, Cascade (slave) on IRQ2 */
+        outb(0x04, 0x21); /* edge triggered, Cascade (slave) on IRQ2 */
         outb(0x01, 0x21); /* Select 8086 mode */
         outb(0xFF, 0x21); /* Mask all */
         /* init slave interrupt controller */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/iSeries_IoMmTable.h linux-2.4.22-pre2/arch/ppc64/kernel/iSeries_IoMmTable.h
--- linux-2.4.21/arch/ppc64/kernel/iSeries_IoMmTable.h	2002-08-03 00:39:43.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/iSeries_IoMmTable.h	2003-06-26 21:43:30.000000000 +0000
@@ -71,7 +71,7 @@
 /* iSeries_xlateIoMmAddress                                             */
 /************************************************************************/
 /* - Translates an I/O Memory address to Device Node that has been the  */
-/*   allocated the psuedo I/O Address.                                  */
+/*   allocated the pseudo I/O Address.                                  */
 /*                                                                      */
 /* Parameters:                                                          */
 /* IoAddress = I/O Memory Address.                                      */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/iSeries_setup.c linux-2.4.22-pre2/arch/ppc64/kernel/iSeries_setup.c
--- linux-2.4.21/arch/ppc64/kernel/iSeries_setup.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/iSeries_setup.c	2003-06-26 21:43:32.000000000 +0000
@@ -49,6 +49,7 @@
 #include <asm/proc_pmc.h>
 #include <asm/perfmon.h>
 #include <asm/iSeries/mf.h>
+#include <asm/cputable.h>
 
 /* Function Prototypes */
 
@@ -249,7 +250,8 @@
 {
 	unsigned long i;
 	unsigned long mem_blocks = 0;
-	if (__is_processor(PV_POWER4) || __is_processor(PV_POWER4p))
+
+	if (cur_cpu_spec->cpu_features & CPU_FTR_SLB)
 		mem_blocks = iSeries_process_Regatta_mainstore_vpd( mb_array, max_entries );
 	else
 		mem_blocks = iSeries_process_Condor_mainstore_vpd( mb_array, max_entries );
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/ioctl32.c linux-2.4.22-pre2/arch/ppc64/kernel/ioctl32.c
--- linux-2.4.21/arch/ppc64/kernel/ioctl32.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/ioctl32.c	2003-06-26 21:43:28.000000000 +0000
@@ -581,6 +581,17 @@
 		len += sizeof(struct ethtool_regs);
 		break;
 	}
+	case ETHTOOL_GEEPROM: 
+	case ETHTOOL_SEEPROM: { 
+		struct ethtool_eeprom *promaddr = (struct ethtool_eeprom *)A(data); 
+		/* darned variable size arguments */ 
+		if (get_user(len, (u32 *)&promaddr->len)) { 
+			err = -EFAULT; 
+			goto out; 
+		} 
+		len += sizeof(struct ethtool_eeprom); 
+		break; 
+	} 
 	case ETHTOOL_GSET:
 	case ETHTOOL_SSET:	len = sizeof(struct ethtool_cmd); break;
 	default:
@@ -3070,7 +3081,7 @@
 #define DRM32_IOCTL_DMA	     DRM_IOWR(0x29, drm32_dma_t)
 
 /* RED PEN	The DRM layer blindly dereferences the send/request
- * 		indice/size arrays even though they are userland
+ * 		index/size arrays even though they are userland
  * 		pointers.  -DaveM
  */
 static int drm32_dma(unsigned int fd, unsigned int cmd, unsigned long arg)
@@ -3894,6 +3905,7 @@
 
 /* RAID */
 COMPATIBLE_IOCTL(RAID_VERSION),
+COMPATIBLE_IOCTL(RAID_AUTORUN),
 COMPATIBLE_IOCTL(GET_ARRAY_INFO),
 COMPATIBLE_IOCTL(GET_DISK_INFO),
 COMPATIBLE_IOCTL(PRINT_RAID_DEBUG),
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/mf.c linux-2.4.22-pre2/arch/ppc64/kernel/mf.c
--- linux-2.4.21/arch/ppc64/kernel/mf.c	2002-11-28 23:53:11.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/mf.c	2003-06-26 21:43:09.000000000 +0000
@@ -44,7 +44,7 @@
 extern struct pci_dev * iSeries_vio_dev;
 
 /*
- * This is the structure layout for the Machine Facilites LPAR event
+ * This is the structure layout for the Machine Facilities LPAR event
  * flows.
  */
 struct VspCmdData;
@@ -402,7 +402,8 @@
  */
 static int shutdown( void )
 {
-	int rc = kill_proc(1,SIGINT,1);
+	extern int cad_pid; /* from kernel/sys.c */
+	int rc = kill_proc(cad_pid,SIGINT,1);
 
 	if ( rc )
 	{
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/misc.S linux-2.4.22-pre2/arch/ppc64/kernel/misc.S
--- linux-2.4.21/arch/ppc64/kernel/misc.S	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/misc.S	2003-06-26 21:43:16.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- *  arch/ppc/kernel/misc.S
+ *  arch/ppc64/kernel/misc.S
  *
  *  
  *
@@ -25,6 +25,7 @@
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/cache.h>
+#include <asm/cputable.h>
 #include "ppc_asm.h"
 
 	.text
@@ -353,7 +354,6 @@
 	bdnz	00b
 	blr	
 
-_GLOBAL(ide_insw)
 _GLOBAL(_insw_ns)
 	cmpwi	0,r5,0
 	mtctr	r5
@@ -365,7 +365,6 @@
 	bdnz	00b
 	blr
 
-_GLOBAL(ide_outsw)
 _GLOBAL(_outsw_ns)
 	cmpwi	0,r5,0
 	mtctr	r5
@@ -480,6 +479,93 @@
 	blr
 
 /*
+ * identify_cpu,
+ * In:	 r3 = base of the cpu_specs array
+ *       r4 = address of cur_cpu_spec
+ *       r5 = relocation offset
+ */
+_GLOBAL(identify_cpu)
+	mfpvr	r7
+1:
+	lwz	r8,CPU_SPEC_PVR_MASK(r3)
+	and	r8,r8,r7
+	lwz	r9,CPU_SPEC_PVR_VALUE(r3)
+	cmplw	0,r9,r8
+	beq	1f
+	addi	r3,r3,CPU_SPEC_ENTRY_SIZE
+	b	1b
+1:
+	add	r3,r3,r5
+	std	r3,0(r4)
+	blr
+
+/*
+ * do_cpu_ftr_fixups - goes through the list of CPU feature fixups
+ * and writes nop's over sections of code that don't apply for this cpu.
+ * r3 = data offset (not changed)
+ */
+_GLOBAL(do_cpu_ftr_fixups)
+	/* Get CPU 0 features */
+	LOADADDR(r6,cur_cpu_spec)
+	sub	r6,r6,r3
+	ld	r4,0(r6)
+	sub	r4,r4,r3
+	ld	r4,CPU_SPEC_FEATURES(r4)
+	/* Get the fixup table */
+	LOADADDR(r6,__start___ftr_fixup)
+	sub	r6,r6,r3
+	LOADADDR(r7,__stop___ftr_fixup)
+	sub	r7,r7,r3
+	/* Do the fixup */
+1:	cmpld	r6,r7
+	bgelr
+	addi	r6,r6,32
+	ld	r8,-32(r6)	/* mask */
+	and	r8,r8,r4
+	ld	r9,-24(r6)	/* value */
+	cmpld	r8,r9
+	beq	1b
+	ld	r8,-16(r6)	/* section begin */
+	ld	r9,-8(r6)	/* section end */
+	subf.	r9,r8,r9
+	beq	1b
+	/* write nops over the section of code */
+	/* todo: if large section, add a branch at the start of it */
+	srwi	r9,r9,2
+	mtctr	r9
+	sub	r8,r8,r3
+	lis	r0,0x60000000@h	/* nop */
+3:	stw	r0,0(r8)
+	andi.	r10,r4,CPU_FTR_SPLIT_ID_CACHE@l
+	beq	2f
+	dcbst	0,r8		/* suboptimal, but simpler */
+	sync
+	icbi	0,r8
+2:	addi	r8,r8,4
+	bdnz	3b
+	sync			/* additional sync needed on g4 */
+	isync
+	b	1b
+
+/*
+ * call_setup_cpu - call the setup_cpu function for this cpu
+ * r3 = data offset
+ *
+ * Setup function is called with:
+ *   r3 = data offset
+ *   r4 = ptr to CPU spec (relocated)
+ */
+_GLOBAL(call_setup_cpu)
+	LOADADDR(r4, cur_cpu_spec)
+	sub	r4,r4,r3
+	lwz	r4,0(r4)		# load pointer to cpu_spec
+	sub	r4,r4,r3		# relocate
+	lwz	r6,CPU_SPEC_SETUP(r4)	# load function pointer
+	sub	r6,r6,r3	
+	mtctr	r6
+	bctr
+
+/*
  * Create a kernel thread
  *   arch_kernel_thread(fn, arg, flags)
  */
@@ -717,7 +803,24 @@
 	.llong .sys_madvise		/* 205 */
 	.llong .sys_mincore		/* 206 */
 	.llong .sys_gettid		/* 207 */
-	.rept NR_syscalls-208
+#if 0 /* Reserved syscalls */
+	.llong .sys_tkill		/* 208 */
+	.llong .sys_setxattr
+	.llong .sys_lsetxattr	/* 210 */
+	.llong .sys_fsetxattr
+	.llong .sys_getxattr
+	.llong .sys_lgetxattr
+	.llong .sys_fgetxattr
+	.llong .sys_listxattr	/* 215 */
+	.llong .sys_llistxattr
+	.llong .sys_flistxattr
+	.llong .sys_removexattr
+	.llong .sys_lremovexattr
+	.llong .sys_fremovexattr	/* 220 */
+	.llong .sys_futex
+#endif
+	.llong .sys_perfmonctl   /* Put this here for now ... */
+	.rept NR_syscalls-222
 		.llong .sys_ni_syscall
 	.endr
 #endif
@@ -931,6 +1034,23 @@
 	.llong .sys_madvise		/* 205 */
 	.llong .sys_mincore		/* 206 */
 	.llong .sys_gettid		/* 207 */
-	.rept NR_syscalls-208
+#if 0 /* Reserved syscalls */
+	.llong .sys_tkill		/* 208 */
+	.llong .sys_setxattr
+	.llong .sys_lsetxattr	/* 210 */
+	.llong .sys_fsetxattr
+	.llong .sys_getxattr
+	.llong .sys_lgetxattr
+	.llong .sys_fgetxattr
+	.llong .sys_listxattr	/* 215 */
+	.llong .sys_llistxattr
+	.llong .sys_flistxattr
+	.llong .sys_removexattr
+	.llong .sys_lremovexattr
+	.llong .sys_fremovexattr	/* 220 */
+	.llong .sys_futex
+#endif
+	.llong .sys_perfmonctl   /* Put this here for now ... */
+	.rept NR_syscalls-222
 	.llong .sys_ni_syscall
 	.endr
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/mk_defs.c linux-2.4.22-pre2/arch/ppc64/kernel/mk_defs.c
--- linux-2.4.21/arch/ppc64/kernel/mk_defs.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/mk_defs.c	2003-06-26 21:43:34.000000000 +0000
@@ -37,6 +37,7 @@
 #include <asm/iSeries/HvLpEvent.h>
 #include <asm/prom.h>
 #include <asm/rtas.h>
+#include <asm/cputable.h>
 
 #define DEFINE(sym, val) \
 	asm volatile("\n#define\t" #sym "\t%0" : : "i" (val))
@@ -188,5 +189,12 @@
 
 	DEFINE(CLONE_VM, CLONE_VM);
 
+	/* About the CPU features table */
+	DEFINE(CPU_SPEC_ENTRY_SIZE, sizeof(struct cpu_spec));
+	DEFINE(CPU_SPEC_PVR_MASK, offsetof(struct cpu_spec, pvr_mask));
+	DEFINE(CPU_SPEC_PVR_VALUE, offsetof(struct cpu_spec, pvr_value));
+	DEFINE(CPU_SPEC_FEATURES, offsetof(struct cpu_spec, cpu_features));
+	DEFINE(CPU_SPEC_SETUP, offsetof(struct cpu_spec, cpu_setup));
+
 	return 0;
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/pSeries_lpar.c linux-2.4.22-pre2/arch/ppc64/kernel/pSeries_lpar.c
--- linux-2.4.21/arch/ppc64/kernel/pSeries_lpar.c	2002-11-28 23:53:11.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/pSeries_lpar.c	2003-06-26 21:43:11.000000000 +0000
@@ -276,7 +276,6 @@
 
 
 
-/* Code for hvc_console.  Should move it back eventually. */
 
 int hvc_get_chars(int index, char *buf, int count)
 {
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/pci.c linux-2.4.22-pre2/arch/ppc64/kernel/pci.c
--- linux-2.4.21/arch/ppc64/kernel/pci.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/pci.c	2003-06-26 21:43:27.000000000 +0000
@@ -137,7 +137,7 @@
 	ioaddr = (addr > _IO_BASE) ? addr - _IO_BASE : 0;
 
 	pci_for_each_dev(dev) {
-		if ((dev->class >> 8) == PCI_BASE_CLASS_BRIDGE)
+  	        if ((dev->class >> 16) == PCI_BASE_CLASS_BRIDGE)
 			continue;
 		for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
 			unsigned long start = pci_resource_start(dev,i);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/pci.h linux-2.4.22-pre2/arch/ppc64/kernel/pci.h
--- linux-2.4.21/arch/ppc64/kernel/pci.h	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/pci.h	2003-06-26 21:43:28.000000000 +0000
@@ -71,7 +71,7 @@
 static inline struct device_node *pci_device_to_OF_node(struct pci_dev *dev)
 {
 	struct device_node *dn = (struct device_node *)(dev->sysdata);
-	if (dn->devfn == dev->devfn && dn->busno == dev->bus->number)
+	if (dn->devfn == dev->devfn && dn->busno == (dev->bus->number&0xff))
 		return dn;	/* fast path.  sysdata is good */
 	else
 		return fetch_dev_dn(dev);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/pci_dma.c linux-2.4.22-pre2/arch/ppc64/kernel/pci_dma.c
--- linux-2.4.21/arch/ppc64/kernel/pci_dma.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/pci_dma.c	2003-06-26 21:43:18.000000000 +0000
@@ -713,12 +713,6 @@
 	for (ln=bus_list->next; ln != bus_list; ln=ln->next) {
 		bus = pci_bus_b(ln);
 		busdn = PCI_GET_DN(bus);
-		/* NOTE: there should never be a window declared on a bus when
-		 * child devices also have a window.  If this should ever be
-		 * architected, we probably want children to have priority.
-		 * In reality, the PHB containing ISA has the property, but otherwise
-		 * it is the pci-bridges that have the property.
-		 */
 		dma_window = (u32 *)get_property(busdn, "ibm,dma-window", 0);
 		if (dma_window) {
 			/* Busno hasn't been copied yet.
@@ -726,8 +720,9 @@
 			 */
 			busdn->busno = bus->number;
 			create_pci_bus_tce_table((unsigned long)busdn);
-		} else
-			create_tce_tables_for_busesLP(&bus->children);
+		}
+		/* look for a window on a bridge even if the PHB had one */
+		create_tce_tables_for_busesLP(&bus->children);
 	}
 }
 
@@ -1349,7 +1344,7 @@
 {
 	struct TceTable * tbl;
 	unsigned numTces;
-	int num_dma;
+	int num_dma = 0;
 	dma_addr_t dma_handle;
 
 	PPCDBG(PPCDBG_TCE, "pci_map_sg:\n");
@@ -1373,6 +1368,8 @@
 		/* Create the tces and get the dma address */ 
 		dma_handle = create_tces_sg( tbl, sg, nents, numTces, direction );
 
+		if(dma_handle == NO_TCE) return 0;
+
 		/* Fill in the dma scatterlist */
 		num_dma = fill_scatterlist_sg( sg, nents, dma_handle, numTces );
 	}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/perfmon.c linux-2.4.22-pre2/arch/ppc64/kernel/perfmon.c
--- linux-2.4.21/arch/ppc64/kernel/perfmon.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/perfmon.c	2003-06-26 21:43:10.000000000 +0000
@@ -22,6 +22,7 @@
 #include <asm/perfmon.h>
 #include <asm/iSeries/HvCall.h>
 #include <asm/hvcall.h>
+#include <asm/cputable.h>
 
 extern char _stext[], _etext[], _end[];
 struct perfmon_base_struct perfmon_base = {0, 0, 0, 0, 0, 0, 0, PMC_STATE_INITIAL};
@@ -450,7 +451,7 @@
 	}
 	perfmon_base.state = PMC_STATE_PROFILE_KERN; 
 
-	if (__is_processor(PV_POWER4) || __is_processor(PV_POWER4p)) {
+	if (cur_cpu_spec->cpu_features & CPU_FTR_SLB) {
 		for(i = 0; i < 8; i++) 
 			pdata->pmc[i] = 0x0;
 		pdata->pmc[1] = 0x7f000000;
@@ -794,7 +795,7 @@
 	 * Flood enabled is required on GP for PMC cycle profile mode
 	 *   iSeries SP sets this by default.  pSeries requires the OS to enable.
 	 */
-	if (__is_processor(PV_POWER4) || __is_processor(PV_POWER4p)) {
+	if (cur_cpu_spec->cpu_features & CPU_FTR_SLB) {
 		/* Set up the debug bus to pmc mode - a feature of GP */
 		switch(systemcfg->platform) {
 		case PLATFORM_ISERIES_LPAR:
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/pmc.c linux-2.4.22-pre2/arch/ppc64/kernel/pmc.c
--- linux-2.4.21/arch/ppc64/kernel/pmc.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/pmc.c	2003-06-26 21:43:10.000000000 +0000
@@ -206,7 +206,7 @@
  *            the segment table.
  *
  * Input : unsigned long size: bytes of storage to allocate.
- * Return: void * : pointer to the kernal address of the buffer.
+ * Return: void * : pointer to the kernel address of the buffer.
  */
 void* btmalloc (unsigned long size) {
 	pgd_t *pgdp;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/ppc_ksyms.c linux-2.4.22-pre2/arch/ppc64/kernel/ppc_ksyms.c
--- linux-2.4.21/arch/ppc64/kernel/ppc_ksyms.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/ppc_ksyms.c	2003-06-26 21:43:33.000000000 +0000
@@ -78,6 +78,13 @@
 extern struct pci_dev * iSeries_veth_dev;
 extern struct pci_dev * iSeries_vio_dev;
 
+#ifdef CONFIG_SHARED_MEMORY_ADDRESSING
+extern void shared_malloc(unsigned long);
+extern void shared_free(void *);
+extern int shared_task_mark();
+extern int shared_task_unmark();
+#endif
+
 EXPORT_SYMBOL(do_signal);
 EXPORT_SYMBOL(syscall_trace);
 EXPORT_SYMBOL(do_IRQ);
@@ -309,3 +316,10 @@
 extern void dump_send_ipi(int (*dump_ipi_callback)(struct pt_regs *));
 EXPORT_SYMBOL(dump_send_ipi);
 #endif
+
+#ifdef CONFIG_SHARED_MEMORY_ADDRESSING
+EXPORT_SYMBOL(shared_malloc);
+EXPORT_SYMBOL(shared_free);
+EXPORT_SYMBOL(shared_task_mark);
+EXPORT_SYMBOL(shared_task_unmark);
+#endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/proc_pcifr.c linux-2.4.22-pre2/arch/ppc64/kernel/proc_pcifr.c
--- linux-2.4.21/arch/ppc64/kernel/proc_pcifr.c	2002-08-03 00:39:43.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/proc_pcifr.c	2003-06-26 21:43:10.000000000 +0000
@@ -198,10 +198,18 @@
 
 			/* look for the net devices out */
 			for (dev = dev_base; dev != NULL; dev = dev->next) 	{
-				if (dev->base_addr == PciDev->resource[0].start ) {
-					BufLen += sprintf(ProcBuffer+BufLen, "     - Net device: %s\n", dev->name);
+				int j;
+                               
+				if (!dev->base_addr) /* virtual device, no base address */
 					break;
-				} /* if */
+				
+				for (j=0;j<6;j++) { /* PCI has 6 base addresses */
+					if (dev->base_addr == PciDev->resource[j].start ) {
+						BufLen += sprintf(ProcBuffer+BufLen, "     - Net device: %s\n", dev->name);
+						break;
+					} /* if */
+				}
+				if (j!=6) break; /* found one */
 			} /* for */
 		} /* if(PCI_SLOT(PciDev->devfn) != 0)  */
 	}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/proc_pmc.c linux-2.4.22-pre2/arch/ppc64/kernel/proc_pmc.c
--- linux-2.4.21/arch/ppc64/kernel/proc_pmc.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/proc_pmc.c	2003-06-26 21:43:32.000000000 +0000
@@ -49,12 +49,12 @@
 
 static int proc_pmc_control_mode = 0;
 
-static struct proc_dir_entry *proc_ppc64_root = NULL;
+struct proc_dir_entry *proc_ppc64_root = NULL;
 static struct proc_dir_entry *proc_ppc64_pmc_root = NULL;
 static struct proc_dir_entry *proc_ppc64_pmc_system_root = NULL;
 static struct proc_dir_entry *proc_ppc64_pmc_cpu_root[NR_CPUS] = {NULL, };
 
-static spinlock_t proc_ppc64_lock;
+spinlock_t proc_ppc64_lock;
 static int proc_ppc64_page_read(char *page, char **start, off_t off,
 				int count, int *eof, void *data);
 static void proc_ppc64_create_paca(int num, struct proc_dir_entry *paca_dir);
@@ -145,8 +145,13 @@
 	 *   /proc/ppc64/pmc/cpu0 
 	 */
 	spin_lock(&proc_ppc64_lock);
-	proc_ppc64_root = proc_mkdir("ppc64", 0);
-	if (!proc_ppc64_root) return;
+	if (proc_ppc64_root == NULL) {
+		proc_ppc64_root = proc_mkdir("ppc64", 0);
+		if (!proc_ppc64_root) {
+			spin_unlock(&proc_ppc64_lock);
+			return;
+		}
+	}
 	spin_unlock(&proc_ppc64_lock);
 
 	ent = create_proc_entry("naca", S_IFREG|S_IRUGO, proc_ppc64_root);
@@ -173,7 +178,9 @@
 	}
 
 	/* Placeholder for rtas interfaces. */
-	rtas_proc_dir = proc_mkdir("rtas", proc_ppc64_root);
+	if (rtas_proc_dir == NULL) {
+		rtas_proc_dir = proc_mkdir("rtas", proc_ppc64_root);
+	}
 
 	/* Create the /proc/ppc64/pcifr for the Pci Flight Recorder.	 */
 	proc_pciFr_init(proc_ppc64_root);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/process.c linux-2.4.22-pre2/arch/ppc64/kernel/process.c
--- linux-2.4.21/arch/ppc64/kernel/process.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/process.c	2003-06-26 21:43:13.000000000 +0000
@@ -42,6 +42,7 @@
 #include <asm/ppcdebug.h>
 #include <asm/machdep.h>
 #include <asm/iSeries/HvCallHpt.h>
+#include <asm/cputable.h>
 
 int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpregs);
 
@@ -390,7 +391,7 @@
 	 * __get_free_pages() might give us a page > KERNBASE+256M which
 	 * is mapped with large ptes so we can't set up the guard page.
 	 */
-	if (__is_processor(PV_POWER4) || __is_processor(PV_POWER4p))
+	if (cur_cpu_spec->cpu_features & CPU_FTR_16M_PAGE)
 		return;
 
 	for (i=0; i < systemcfg->processorCount; i++) {
@@ -493,7 +494,7 @@
 			 * gets fixed.
 			 */
 			if (ip < first_sched || ip >= last_sched)
-				return (ip & 0xFFFFFFFF);
+				return (ip);
 		}
 	} while (count++ < 16);
 	return 0;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/prom.c linux-2.4.22-pre2/arch/ppc64/kernel/prom.c
--- linux-2.4.21/arch/ppc64/kernel/prom.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/prom.c	2003-06-26 21:43:32.000000000 +0000
@@ -363,7 +363,7 @@
 			 * d-cache and i-cache sizes... -Peter
 			 */
 			if ( num_cpus == 1 ) {
-				u32 size, lsize;
+				u32 size, lsize, sets;
 
 				call_prom(RELOC("getprop"), 4, 1, node,
 					  RELOC("d-cache-size"),
@@ -631,6 +631,7 @@
 	unsigned long offset = reloc_offset();
 	struct prom_t *_prom = PTRRELOC(&prom);
 	struct rtas_t *_rtas = PTRRELOC(&rtas);
+	struct naca_struct *_naca = RELOC(naca);
 	struct systemcfg *_systemcfg = RELOC(systemcfg);
 	ihandle prom_rtas;
         u32 getprop_rval;
@@ -1059,6 +1060,7 @@
         unsigned long *spinloop     = __v2a(&__secondary_hold_spinloop);
         unsigned long *acknowledge  = __v2a(&__secondary_hold_acknowledge);
         unsigned long secondary_hold = (unsigned long)__v2a(*PTRRELOC((unsigned long *)__secondary_hold));
+        struct naca_struct *_naca = RELOC(naca);
         struct systemcfg *_systemcfg = RELOC(systemcfg);
 	struct paca_struct *_xPaca = PTRRELOC(&paca[0]);
 	struct prom_t *_prom = PTRRELOC(&prom);
@@ -1237,7 +1239,7 @@
 #ifdef CONFIG_PPCDBG
 extern char *trace_names[];	/* defined in udbg.c -- need a better interface */
 
-static void parse_ppcdbg_optionlist(const char *cmd,
+void parse_ppcdbg_optionlist(const char *cmd,
 				    const char *cmdend)
 {
 	unsigned long offset = reloc_offset();
@@ -1559,7 +1561,7 @@
 	}
 
 	/* We assume the phys. address size is 3 cells */
-	RELOC(prom_mmu) = (ihandle)(unsigned long)getprop_rval;
+	prom_mmu = (ihandle)(unsigned long)getprop_rval;
 
 	if ((long)call_prom(RELOC("call-method"), 4, 4,
 				RELOC("translate"),
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/rtas-proc.c linux-2.4.22-pre2/arch/ppc64/kernel/rtas-proc.c
--- linux-2.4.21/arch/ppc64/kernel/rtas-proc.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/rtas-proc.c	2003-06-26 21:43:18.000000000 +0000
@@ -115,14 +115,18 @@
 
 
 /* Globals */
-static struct proc_dir_entry *proc_rtas;
 static struct rtas_sensors sensors;
-static struct device_node *rtas_node;
+static struct device_node *rtas_node = NULL;
 static unsigned long power_on_time = 0; /* Save the time the user set */
 static char progress_led[MAX_LINELENGTH];
 
 static unsigned long rtas_tone_frequency = 1000;
 static unsigned long rtas_tone_volume = 0;
+static unsigned int open_token = 0;
+
+extern struct proc_dir_entry *proc_ppc64_root;
+extern struct proc_dir_entry *rtas_proc_dir;
+extern spinlock_t proc_ppc64_lock;
 
 /* ****************STRUCTS******************************************* */
 struct individual_sensor {
@@ -160,6 +164,12 @@
 		size_t count, loff_t *ppos);
 static ssize_t ppc_rtas_tone_volume_read(struct file * file, char * buf,
 		size_t count, loff_t *ppos);
+static int ppc_rtas_errinjct_open(struct inode *inode, struct file *file);
+static int ppc_rtas_errinjct_release(struct inode *inode, struct file *file);
+static ssize_t ppc_rtas_errinjct_write(struct file * file, const char * buf,
+				   size_t count, loff_t *ppos);
+static ssize_t ppc_rtas_errinjct_read(struct file *file, char *buf,
+				      size_t count, loff_t *ppos);
 
 struct file_operations ppc_rtas_poweron_operations = {
 	.read =		ppc_rtas_poweron_read,
@@ -184,6 +194,13 @@
 	.write =	ppc_rtas_tone_volume_write
 };
 
+struct file_operations ppc_rtas_errinjct_operations = {
+    .open =		ppc_rtas_errinjct_open,
+    .read = 		ppc_rtas_errinjct_read,
+    .write = 		ppc_rtas_errinjct_write,
+    .release = 		ppc_rtas_errinjct_release
+};
+
 int ppc_rtas_find_all_sensors (void);
 int ppc_rtas_process_sensor(struct individual_sensor s, int state, 
 		int error, char * buf);
@@ -200,33 +217,54 @@
 	struct proc_dir_entry *entry;
 
 	rtas_node = find_devices("rtas");
-	if ((rtas_node == 0) || (systemcfg->platform == PLATFORM_ISERIES_LPAR)) {
+	if ((rtas_node == NULL) || (systemcfg->platform == PLATFORM_ISERIES_LPAR)) {
 		return;
 	}
 	
-	proc_rtas = proc_mkdir("rtas", 0);
-	if (proc_rtas == 0)
+	spin_lock(&proc_ppc64_lock);
+	if (proc_ppc64_root == NULL) {
+		proc_ppc64_root = proc_mkdir("ppc64", 0);
+		if (!proc_ppc64_root) {
+			spin_unlock(&proc_ppc64_lock);
+			return;
+		}		
+	}
+	spin_unlock(&proc_ppc64_lock);
+	
+	if (rtas_proc_dir == NULL) {
+		rtas_proc_dir = proc_mkdir("rtas", proc_ppc64_root);
+	}
+
+	if (rtas_proc_dir == NULL) {
+		printk(KERN_ERR "Failed to create /proc/ppc64/rtas in rtas_init\n");
 		return;
+	}
 
 	/* /proc/rtas entries */
 
-	entry = create_proc_entry("progress", S_IRUGO|S_IWUSR, proc_rtas);
+	entry = create_proc_entry("progress", S_IRUGO|S_IWUSR, rtas_proc_dir);
 	if (entry) entry->proc_fops = &ppc_rtas_progress_operations;
 
-	entry = create_proc_entry("clock", S_IRUGO|S_IWUSR, proc_rtas); 
+	entry = create_proc_entry("clock", S_IRUGO|S_IWUSR, rtas_proc_dir); 
 	if (entry) entry->proc_fops = &ppc_rtas_clock_operations;
 
-	entry = create_proc_entry("poweron", S_IWUSR|S_IRUGO, proc_rtas); 
+	entry = create_proc_entry("poweron", S_IWUSR|S_IRUGO, rtas_proc_dir); 
 	if (entry) entry->proc_fops = &ppc_rtas_poweron_operations;
 
-	create_proc_read_entry("sensors", S_IRUGO, proc_rtas, 
+	create_proc_read_entry("sensors", S_IRUGO, rtas_proc_dir, 
 			ppc_rtas_sensor_read, NULL);
 	
-	entry = create_proc_entry("frequency", S_IWUSR|S_IRUGO, proc_rtas); 
+	entry = create_proc_entry("frequency", S_IWUSR|S_IRUGO, rtas_proc_dir); 
 	if (entry) entry->proc_fops = &ppc_rtas_tone_freq_operations;
 
-	entry = create_proc_entry("volume", S_IWUSR|S_IRUGO, proc_rtas); 
+	entry = create_proc_entry("volume", S_IWUSR|S_IRUGO, rtas_proc_dir); 
 	if (entry) entry->proc_fops = &ppc_rtas_tone_volume_operations;
+
+#ifdef CONFIG_RTAS_ERRINJCT
+	entry = create_proc_entry("errinjct", S_IWUSR|S_IRUGO, rtas_proc_dir);
+	if (entry) entry->proc_fops = &ppc_rtas_errinjct_operations;
+#endif
+
 }
 
 /* ****************************************************************** */
@@ -405,10 +443,14 @@
 		j = sensors.sensor[i].quant;
 		/* A sensor may have multiple instances */
 		while (j >= 0) {
+
 			error =	rtas_call(get_sensor_state, 2, 2, &ret, 
-				  sensors.sensor[i].token, sensors.sensor[i].quant-j);
+				  	  sensors.sensor[i].token, 
+				  	  sensors.sensor[i].quant - j);
+
 			state = (int) ret;
-			n += ppc_rtas_process_sensor(sensors.sensor[i], state, error, buffer+n );
+			n += ppc_rtas_process_sensor(sensors.sensor[i], state, 
+					     	     error, buffer+n );
 			n += sprintf (buffer+n, "\n");
 			j--;
 		} /* while */
@@ -426,6 +468,7 @@
 		n = count;
 	else
 		*eof = 1;
+
 	memcpy(buf, buffer + off, n);
 	*start = buf;
 	kfree(buffer);
@@ -436,10 +479,10 @@
 
 int ppc_rtas_find_all_sensors (void)
 {
-	unsigned long *utmp;
-	int len, i, j;
+	unsigned int *utmp;
+	int len, i;
 
-	utmp = (unsigned long *) get_property(rtas_node, "rtas-sensors", &len);
+	utmp = (unsigned int *) get_property(rtas_node, "rtas-sensors", &len);
 	if (utmp == NULL) {
 		printk (KERN_ERR "error: could not get rtas-sensors\n");
 		return 1;
@@ -447,9 +490,9 @@
 
 	sensors.quant = len / 8;      /* int + int */
 
-	for (i=0, j=0; j<sensors.quant; i+=2, j++) {
-		sensors.sensor[j].token = utmp[i];
-		sensors.sensor[j].quant = utmp[i+1];
+	for (i=0; i<sensors.quant; i++) {
+		sensors.sensor[i].token = *utmp++;
+		sensors.sensor[i].quant = *utmp++;
 	}
 	return 0;
 }
@@ -515,6 +558,7 @@
 	int n = 0;
 
 	/* What kind of sensor do we have here? */
+	
 	switch (s.token) {
 		case KEY_SWITCH:
 			n += sprintf(buf+n, "Key switch:\t");
@@ -698,9 +742,9 @@
 	ret = (char *) get_property(rtas_node, rstr, &llen);
 
 	n=0;
-	if (ret[0] == '\0')
+	if (ret == NULL || ret[0] == '\0') {
 		n += sprintf ( buffer+n, "--- ");/* does not have a location */
-	else {
+	} else {
 		char t[50];
 		ret += pos;
 
@@ -794,3 +838,137 @@
 	*ppos += n;
 	return n;
 }
+
+/* ****************************************************************** */
+/* ERRINJCT			                                      */
+/* ****************************************************************** */
+static int ppc_rtas_errinjct_open(struct inode *inode, struct file *file)
+{
+	int rc;
+
+	/* We will only allow one process to use error inject at a
+	   time.  Since errinjct is usually only used for testing,
+	   this shouldn't be an issue */
+	if (open_token) {
+		return -EAGAIN;
+	}
+	rc = rtas_errinjct_open();
+	if (rc < 0) {
+		return -EIO;
+	}
+	open_token = rc;
+
+	return 0;
+}
+
+static ssize_t ppc_rtas_errinjct_write(struct file * file, const char * buf,
+				       size_t count, loff_t *ppos)
+{
+ 
+	char * ei_token;
+	char * workspace = NULL;
+	size_t max_len;
+	int token_len;
+	int rc;
+
+	/* Verify the errinjct token length */
+	if (count < ERRINJCT_TOKEN_LEN) {
+		max_len = count;
+	} else {
+		max_len = ERRINJCT_TOKEN_LEN;
+	}
+
+	token_len = strnlen(buf, max_len);
+	token_len++; /* Add one for the null termination */
+    
+	ei_token = (char *)kmalloc(token_len, GFP_KERNEL);
+	if (!ei_token) {
+		printk(KERN_WARNING "error: kmalloc failed\n");
+		return -ENOMEM;
+	}
+
+	strncpy(ei_token, buf, token_len);
+    
+	if (count > token_len + WORKSPACE_SIZE) {
+		count = token_len + WORKSPACE_SIZE;
+	}
+    
+	buf += token_len;
+
+	/* check if there is a workspace */
+	if (count > token_len) {
+		/* Verify the workspace size */
+		if ((count - token_len) > WORKSPACE_SIZE) {
+			max_len = WORKSPACE_SIZE;
+		} else {
+			max_len = count - token_len;
+		}
+
+		workspace = (char *)kmalloc(max_len, GFP_KERNEL);
+		if (!workspace) {
+			printk(KERN_WARNING "error: failed kmalloc\n");
+			kfree(ei_token);
+			return -ENOMEM;
+		}
+	
+		memcpy(workspace, buf, max_len);
+	}
+
+	rc = rtas_errinjct(open_token, ei_token, workspace);
+
+	if (count > token_len) {
+		kfree(workspace);
+	}
+	kfree(ei_token);
+
+	return rc < 0 ? rc : count;
+}
+
+static int ppc_rtas_errinjct_release(struct inode *inode, struct file *file)
+{
+	int rc;
+    
+	rc = rtas_errinjct_close(open_token);
+	if (rc) {
+		return rc;
+	}
+	open_token = 0;
+	return 0;
+}
+
+static ssize_t ppc_rtas_errinjct_read(struct file *file, char *buf,
+				      size_t count, loff_t *ppos) 
+{
+	char * buffer;
+	int i;
+	int n = 0;
+
+	buffer = (char *)kmalloc(MAX_ERRINJCT_TOKENS * (ERRINJCT_TOKEN_LEN+1),
+				 GFP_KERNEL);
+	if (!buffer) {
+		printk(KERN_ERR "error: kmalloc failed\n");
+		return -ENOMEM;
+	}
+
+	for (i = 0; i < MAX_ERRINJCT_TOKENS && ei_token_list[i].value; i++) {
+		n += sprintf(buffer+n, ei_token_list[i].name);
+		n += sprintf(buffer+n, "\n");
+	}
+
+	if (*ppos >= strlen(buffer)) {
+		kfree(buffer);
+		return 0;
+	}
+	if (n > strlen(buffer) - *ppos)
+		n = strlen(buffer) - *ppos;
+
+	if (n > count)
+		n = count;
+
+	memcpy(buf, buffer + *ppos, n);
+
+	*ppos += n;
+
+	kfree(buffer);
+	return n;
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/rtas.c linux-2.4.22-pre2/arch/ppc64/kernel/rtas.c
--- linux-2.4.21/arch/ppc64/kernel/rtas.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/rtas.c	2003-06-26 21:43:21.000000000 +0000
@@ -16,6 +16,7 @@
 #include <linux/types.h>
 #include <linux/spinlock.h>
 #include <linux/fs.h>
+#include <linux/slab.h>
 
 #include <asm/init.h>
 #include <asm/prom.h>
@@ -27,9 +28,11 @@
 #include <asm/system.h>
 #include <asm/abs_addr.h>
 #include <asm/udbg.h>
+#include <asm/uaccess.h>
 
 struct proc_dir_entry *rtas_proc_dir;	/* /proc/ppc64/rtas dir */
 struct flash_block_list_header rtas_firmware_flash_list = {0, 0};
+struct errinjct_token ei_token_list[MAX_ERRINJCT_TOKENS];
 
 /*
  * prom_init() is called very early on, before the kernel text
@@ -59,7 +62,7 @@
 extern unsigned long reloc_offset(void);
 
 spinlock_t rtas_data_buf_lock = SPIN_LOCK_UNLOCKED;
-char rtas_data_buf[RTAS_DATA_BUF_SIZE];
+char rtas_data_buf[RTAS_DATA_BUF_SIZE]__page_aligned;
 
 void
 phys_call_rtas(int token, int nargs, int nret, ...)
@@ -219,7 +222,11 @@
 			image_size += f->blocks[i].length;
 		}
 		next = f->next;
-		f->next = (struct flash_block_list *)virt_to_absolute((unsigned long)f->next);
+		/* Don't translate final NULL pointer */
+		if(f->next)
+			f->next = (struct flash_block_list *)virt_to_absolute((unsigned long)f->next);
+		else
+			f->next = 0LL;
 		/* make num_blocks into the version/length field */
 		f->num_blocks = (FLASH_BLOCK_LIST_VERSION << 56) | ((f->num_blocks+1)*16);
 	}
@@ -285,3 +292,108 @@
 		rtas_flash_bypass_warning();
         rtas_power_off();
 }
+
+int
+rtas_errinjct_open(void)
+{
+	u32 ret[2];
+	int open_token;
+	int rc;
+
+	/* The rc and open_token values are backwards due to a misprint in
+	 * the RPA */ 
+	open_token = rtas_call(rtas_token("ibm,open-errinjct"), 0, 2, (void *) &ret);
+	rc = ret[0];
+
+	if (rc < 0) {
+		printk(KERN_WARNING "error: ibm,open-errinjct failed (%d)\n", rc);
+		return rc;
+	}
+
+	return open_token;
+}
+
+int
+rtas_errinjct(unsigned int open_token, char * ei_token, char * in_workspace)
+{
+	struct errinjct_token * ei;
+	int rtas_ei_token = -1;
+	int rc;
+	int i;
+
+	ei = ei_token_list;
+	for (i = 0; i < MAX_ERRINJCT_TOKENS && ei->name; i++) {
+		if (strcmp(ei_token, ei->name) == 0) {
+			rtas_ei_token = ei->value;
+			break;
+		}
+		ei++;
+	}
+	if (rtas_ei_token == -1) {
+		return -EINVAL;
+	}
+
+	spin_lock(&rtas_data_buf_lock);
+
+	if (in_workspace) 
+		memcpy(rtas_data_buf, in_workspace, RTAS_DATA_BUF_SIZE);
+
+	rc = rtas_call(rtas_token("ibm,errinjct"), 3, 1, NULL, rtas_ei_token,
+		       open_token, __pa(rtas_data_buf));   
+
+	spin_unlock(&rtas_data_buf_lock);
+
+	return rc;
+}
+
+int
+rtas_errinjct_close(unsigned int open_token)
+{
+	int rc;
+
+	rc = rtas_call(rtas_token("ibm,close-errinjct"), 1, 1, NULL, open_token);
+	if (rc != 0) {
+		printk(KERN_WARNING "error: ibm,close-errinjct failed (%d)\n", rc);
+		return rc;
+	}
+
+	return 0;
+}
+
+#ifndef CONFIG_PPC_ISERIES
+static int __init rtas_errinjct_init(void)
+{
+	char * token_array;
+	char * end_array;
+	int array_len = 0;
+	int len;
+	int i, j;
+
+	token_array = (char *) get_property(rtas.dev, "ibm,errinjct-tokens",
+					    &array_len);    
+	/* if token is not found, then we fall through loop */
+	end_array = token_array + array_len;
+	for (i = 0, j = 0; i < MAX_ERRINJCT_TOKENS && token_array < end_array; i++) {
+
+		len = strnlen(token_array, ERRINJCT_TOKEN_LEN) + 1;
+		ei_token_list[i].name = (char *) kmalloc(len, GFP_KERNEL);
+		if (!ei_token_list[i].name) {
+			printk(KERN_WARNING "error: kmalloc failed\n");
+			return -ENOMEM;
+		}
+
+		strcpy(ei_token_list[i].name, token_array);
+		token_array += len;
+
+		ei_token_list[i].value = *(int *)token_array;
+		token_array += sizeof(int);
+	}
+	for (; i < MAX_ERRINJCT_TOKENS; i++) {
+		ei_token_list[i].name = 0;
+		ei_token_list[i].value = 0;
+	}
+	return 0;
+}
+
+__initcall(rtas_errinjct_init);
+#endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/rtasd.c linux-2.4.22-pre2/arch/ppc64/kernel/rtasd.c
--- linux-2.4.21/arch/ppc64/kernel/rtasd.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/rtasd.c	2003-06-26 21:43:11.000000000 +0000
@@ -49,6 +49,9 @@
 #define SURVEILLANCE_TIMEOUT	1
 #define SURVEILLANCE_SCANRATE	1
 
+extern struct proc_dir_entry *proc_ppc64_root;
+extern struct proc_dir_entry *rtas_proc_dir;
+extern spinlock_t proc_ppc64_lock;
 /*
  * Since we use 32 bit RTAS, the physical address of this must be below
  * 4G or else bad things happen. Allocate this in the kernel data and
@@ -821,12 +824,8 @@
 		current->cpus_allowed = 1UL << cpu_logical_map(cpu);
 
 		/* Check all cpus for pending events before sleeping*/
-		if (first_pass) {
-			schedule();
-		} else {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout((HZ*60/rtas_event_scan_rate) / 2);
-		}
+                set_current_state(TASK_INTERRUPTIBLE);
+                schedule_timeout(first_pass ? HZ : (HZ*60/rtas_event_scan_rate) / 2);
 	}
 
 error_vfree:
@@ -836,25 +835,45 @@
 	return -EINVAL;
 }
 
-static void __init rtas_init(void)
+static int __init rtas_init(void)
 {
-	struct proc_dir_entry *rtas_dir, *entry;
+	int ret = 0;
+	struct proc_dir_entry *entry;
 
-	rtas_dir = proc_mkdir("rtas", 0);
-	if (!rtas_dir) {
-		printk(KERN_ERR "Failed to create rtas proc directory\n");
+	spin_lock(&proc_ppc64_lock);
+	if (proc_ppc64_root == NULL) {
+		proc_ppc64_root = proc_mkdir("ppc64", 0);
+		if (!proc_ppc64_root) {
+			spin_unlock(&proc_ppc64_lock);
+			return -EINVAL;
+		}		
+	}
+	spin_unlock(&proc_ppc64_lock);
+	
+	if (rtas_proc_dir == NULL) {
+		rtas_proc_dir = proc_mkdir("rtas", proc_ppc64_root);
+	}
+
+	if (rtas_proc_dir == NULL) {
+		printk(KERN_ERR "Failed to create /proc/ppc64/rtas in rtas_init\n");
+		ret = -EINVAL;
 	} else {
-		entry = create_proc_entry("error_log", S_IRUSR, rtas_dir);
+		entry = create_proc_entry("error_log", S_IRUSR, rtas_proc_dir);
 		if (entry)
 			entry->proc_fops = &proc_rtas_log_operations;
-		else
+		else {
 			printk(KERN_ERR "Failed to create rtas/error_log proc entry\n");
+			ret = -EINVAL;
+		}
 	}
 
-	if (kernel_thread(rtasd, 0, CLONE_FS) < 0)
+	if (kernel_thread(rtasd, 0, CLONE_FS) < 0) { 
 		printk(KERN_ERR "Failed to start RTAS daemon\n");
+		ret = -EINVAL;
+	}
 
 	printk(KERN_ERR "RTAS daemon started\n");
+	return ret;
 }
 
 static int __init surveillance_setup(char *str)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/setup.c linux-2.4.22-pre2/arch/ppc64/kernel/setup.c
--- linux-2.4.21/arch/ppc64/kernel/setup.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/setup.c	2003-06-26 21:43:15.000000000 +0000
@@ -37,9 +37,7 @@
 #include <asm/paca.h>
 #include <asm/ppcdebug.h>
 #include <asm/time.h>
-#ifdef CONFIG_KDB
-#include <linux/kdb.h>
-#endif
+#include <asm/cputable.h>
 
 extern unsigned long klimit;
 /* extern void *stab; */
@@ -74,10 +72,6 @@
 extern void xmon_map_scc(void);
 #endif
 
-#ifdef CONFIG_KDB
-extern void kdb_map_scc(void);
-#endif
-
 char saved_command_line[256];
 unsigned char aux_device_present;
 
@@ -107,7 +101,7 @@
 };
 
 /*
- * Do some initial setup of the system.  The paramters are those which 
+ * Do some initial setup of the system.  The parameters are those which 
  * were passed in from the bootloader.
  */
 void setup_system(unsigned long r3, unsigned long r4, unsigned long r5,
@@ -187,6 +181,7 @@
 
 /* This is called just before console_init().
  * It will be obsolete when Linux gets real early console support (2.5?)
+ * We need to hack preferred_console to retain the correct behavior
  */
 void setup_before_console_init(void)
 {
@@ -244,6 +239,14 @@
 
 	pvr = paca[cpu_id].pvr;
 
+	if (cur_cpu_spec->pvr_mask)
+		seq_printf(m, "%s", cur_cpu_spec->cpu_name);
+	else
+		seq_printf(m, "unknown (%08x)", pvr);
+
+
+	seq_printf(m, "\n");
+#if 0
 	switch (PVR_VER(pvr)) {
 	case PV_NORTHSTAR:
 		seq_printf(m, "RS64-II (northstar)\n");
@@ -273,7 +276,7 @@
 		seq_printf(m, "Unknown (%08x)\n", pvr);
 		break;
 	}
-
+#endif
 	/*
 	 * Assume here that all clock rates are the same in a
 	 * smp system.  -- Cort
@@ -325,6 +328,7 @@
 void parse_cmd_line(unsigned long r3, unsigned long r4, unsigned long r5,
 		  unsigned long r6, unsigned long r7)
 {
+	struct device_node *chosen;
 	char *p;
 
 #ifdef CONFIG_BLK_DEV_INITRD
@@ -333,6 +337,7 @@
 		initrd_end = initrd_start + r4;
 		ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0);
 		initrd_below_start_ok = 1;
+		lmb_reserve(__pa(initrd_start),r4);
 	}
 #endif
 
@@ -495,12 +500,6 @@
 		xmon(0);
 #endif /* CONFIG_XMON */
 
-#ifdef CONFIG_KDB
-	kdb_map_scc();	
-	if (strstr(cmd_line, "kdb=early"))
-		kdb(KDB_REASON_CALL,0,0);
-#endif
-
 #if defined(CONFIG_KGDB)
 	kgdb_map_scc();
 	set_debug_traps();
@@ -560,28 +559,28 @@
 void ppc64_boot_msg(unsigned int src, const char *msg)
 {
 	ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_IPL_MESSAGE|src, msg);
-	printk("[boot]%04x %s\n", src, msg);
+	udbg_printf("[boot]%04x %s\n", src, msg);
 }
 
 /* Print a termination message (print only -- does not stop the kernel) */
 void ppc64_terminate_msg(unsigned int src, const char *msg)
 {
 	ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_TERM_MESSAGE|src, msg);
-	printk("[terminate]%04x %s\n", src, msg);
+	udbg_printf("[terminate]%04x %s\n", src, msg);
 }
 
 /* Print something that needs attention (device error, etc) */
 void ppc64_attention_msg(unsigned int src, const char *msg)
 {
 	ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_ATTN_MESSAGE|src, msg);
-	printk("[attention]%04x %s\n", src, msg);
+	udbg_printf("[attention]%04x %s\n", src, msg);
 }
 
 /* Print a dump progress message. */
 void ppc64_dump_msg(unsigned int src, const char *msg)
 {
 	ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_DUMP_MESSAGE|src, msg);
-	printk("[dump]%04x %s\n", src, msg);
+	udbg_printf("[dump]%04x %s\n", src, msg);
 }
 
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/signal.c linux-2.4.22-pre2/arch/ppc64/kernel/signal.c
--- linux-2.4.21/arch/ppc64/kernel/signal.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/signal.c	2003-06-26 21:43:32.000000000 +0000
@@ -101,6 +101,7 @@
 		err |= __put_user(from->si_pid, &to->si_pid);
 		switch (from->si_code >> 16) {
 		case __SI_FAULT >> 16:
+			err |= __put_user(from->si_addr, &to->si_addr);
 			break;
 		case __SI_CHLD >> 16:
 			err |= __put_user(from->si_utime, &to->si_utime);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/stab.c linux-2.4.22-pre2/arch/ppc64/kernel/stab.c
--- linux-2.4.21/arch/ppc64/kernel/stab.c	2002-11-28 23:53:11.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/stab.c	2003-06-26 21:43:17.000000000 +0000
@@ -17,6 +17,7 @@
 #include <asm/paca.h>
 #include <asm/naca.h>
 #include <asm/pmc.h>
+#include <asm/cputable.h>
 
 inline int make_ste(unsigned long stab, 
 		    unsigned long esid, unsigned long vsid);
@@ -35,10 +36,7 @@
 	esid = GET_ESID(KERNELBASE);
 	vsid = get_kernel_vsid(esid << SID_SHIFT); 
 
-	if (!__is_processor(PV_POWER4) && !__is_processor(PV_POWER4p)) {
-                __asm__ __volatile__("isync; slbia; isync":::"memory");
-		make_ste(stab, esid, vsid);
-	} else {
+	if (cur_cpu_spec->cpu_features & CPU_FTR_SLB) {
                 /* Invalidate the entire SLB & all the ERATS */
                 __asm__ __volatile__("isync" : : : "memory");
 #ifndef CONFIG_PPC_ISERIES
@@ -49,7 +47,10 @@
 #else
                 __asm__ __volatile__("isync; slbia; isync":::"memory");
 #endif
-        }
+	} else {
+                __asm__ __volatile__("isync; slbia; isync":::"memory");
+		make_ste(stab, esid, vsid);
+	}
 }
 
 /*
@@ -61,6 +62,15 @@
 	unsigned long entry, group, old_esid, castout_entry, i;
 	unsigned int global_entry;
 	STE *ste, *castout_ste;
+	unsigned char kp = 1;
+	
+#ifdef CONFIG_SHARED_MEMORY_ADDRESSING
+	if(((esid >> SMALLOC_ESID_SHIFT) == 
+	    (SMALLOC_START >> SMALLOC_EA_SHIFT)) && 
+	   (current->thread.flags & PPC_FLAG_SHARED)) {
+		kp = 0;
+	}
+#endif
 
 	/* Search the primary group first. */
 	global_entry = (esid & 0x1f) << 3;
@@ -77,7 +87,7 @@
 				__asm__ __volatile__ ("eieio" : : : "memory");
 				ste->dw0.dw0.esid = esid;
 				ste->dw0.dw0.v  = 1;
-				ste->dw0.dw0.kp = 1;
+				ste->dw0.dw0.kp = kp;
 				/* Order update     */
 				__asm__ __volatile__ ("sync" : : : "memory"); 
 
@@ -135,7 +145,7 @@
 	old_esid = castout_ste->dw0.dw0.esid;
 	castout_ste->dw0.dw0.esid = esid;
 	castout_ste->dw0.dw0.v  = 1;
-	castout_ste->dw0.dw0.kp = 1;
+	castout_ste->dw0.dw0.kp = kp;
 	__asm__ __volatile__ ("slbie  %0" : : "r" (old_esid << SID_SHIFT)); 
 	/* Ensure completion of slbie */
 	__asm__ __volatile__ ("sync" : : : "memory" );  
@@ -158,6 +168,15 @@
 		unsigned long word0;
 		slb_dword1    data;
 	} vsid_data;
+	unsigned char kp = 1;
+ 	
+#ifdef CONFIG_SHARED_MEMORY_ADDRESSING
+	if(((esid >> SMALLOC_ESID_SHIFT) == 
+	    (SMALLOC_START >> SMALLOC_EA_SHIFT)) && 
+	   (current->thread.flags & PPC_FLAG_SHARED)) {
+		kp = 0;
+	}
+#endif
 	
 	/*
 	 * Find an empty entry, if one exists.
@@ -171,7 +190,7 @@
 			 */
 			vsid_data.word0 = 0;
 			vsid_data.data.vsid = vsid;
-			vsid_data.data.kp = 1;
+			vsid_data.data.kp = kp;
 			if (large)
 				vsid_data.data.l = 1;
 
@@ -220,7 +239,7 @@
 	 */
 	vsid_data.word0 = 0;
 	vsid_data.data.vsid = vsid;
-	vsid_data.data.kp = 1;
+	vsid_data.data.kp = kp;
 	if (large)
 		vsid_data.data.l = 1;
 	
@@ -264,6 +283,15 @@
 		}
 	}
 
+#ifdef CONFIG_SHARED_MEMORY_ADDRESSING
+	/* Shared segments might be mapped into a user task space,
+	 * so we need to add them to the list of entries to flush
+	 */
+	if ((ea >> SMALLOC_EA_SHIFT) == (SMALLOC_START >> SMALLOC_EA_SHIFT)) {
+		kernel_segment = 0;
+	}
+#endif
+
 	esid = GET_ESID(ea);
 	if (trap == 0x380 || trap == 0x480) {
 #ifndef CONFIG_PPC_ISERIES
@@ -305,7 +333,15 @@
 	unsigned char *segments = get_paca()->xSegments;
 	unsigned long flags, i;
 
-	if (!__is_processor(PV_POWER4) && !__is_processor(PV_POWER4p)) {
+	if (cur_cpu_spec->cpu_features & CPU_FTR_SLB) {
+		unsigned long flags;
+
+		PMC_SW_PROCESSOR(stab_invalidations); 
+
+		__save_and_cli(flags);
+		__asm__ __volatile__("isync; slbia; isync":::"memory");
+		__restore_flags(flags);
+	} else {
 		unsigned long entry;
 		STE *ste;
 
@@ -330,7 +366,8 @@
 			    entry++, ste++) {
 				unsigned long ea;
 				ea = ste->dw0.dw0.esid << SID_SHIFT;
-				if (STAB_PRESSURE || (!REGION_ID(ea))) {
+				if (STAB_PRESSURE || (!REGION_ID(ea)) ||
+				    (REGION_ID(ea) == VMALLOC_REGION_ID)) {
 					ste->dw0.dw0.v = 0;
 					PMC_SW_PROCESSOR(stab_invalidations); 
 				}
@@ -347,13 +384,5 @@
 		__asm__ __volatile__ ("slbia" : : : "memory"); 
 		/* Force flush to complete.  */
 		__asm__ __volatile__ ("sync" : : : "memory");  
-	} else {
-		unsigned long flags;
-
-		PMC_SW_PROCESSOR(stab_invalidations); 
-
-		__save_and_cli(flags);
-		__asm__ __volatile__("isync; slbia; isync":::"memory");
-		__restore_flags(flags);
 	}
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/sys_ppc32.c linux-2.4.22-pre2/arch/ppc64/kernel/sys_ppc32.c
--- linux-2.4.21/arch/ppc64/kernel/sys_ppc32.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/sys_ppc32.c	2003-06-26 21:43:13.000000000 +0000
@@ -2311,7 +2311,11 @@
         u32 totalswap;
         u32 freeswap;
         unsigned short procs;
-        char _f[22];
+        unsigned short pad;
+        u32 totalhigh;
+        u32 freehigh;
+        u32 mem_unit;
+        char _f[20-2*sizeof(u32)-sizeof(int)];
 };
 
 extern asmlinkage long sys_sysinfo(struct sysinfo *info);
@@ -2320,6 +2324,7 @@
 {
 	struct sysinfo s;
 	int ret, err;
+	int bitcount = 0;
 	mm_segment_t old_fs = get_fs ();
 	
 	PPCDBG(PPCDBG_SYS32, "sys32_sysinfo - entered - pid=%ld current=%lx comm=%s \n", current->pid, current, current->comm);
@@ -2327,6 +2332,24 @@
 	set_fs (KERNEL_DS);
 	ret = sys_sysinfo(&s);
 	set_fs (old_fs);
+	/* Check to see if any memory value is too large for 32-bit and scale
+	 *  down if needed
+	 */
+	if ((s.totalram >> 32) || (s.totalswap >> 32)) {
+		while (s.mem_unit < PAGE_SIZE) {
+			s.mem_unit <<= 1;
+			bitcount++;
+		}
+		s.totalram >>= bitcount;
+		s.freeram >>= bitcount;
+		s.sharedram >>= bitcount;
+		s.bufferram >>= bitcount;
+		s.totalswap >>= bitcount;
+		s.freeswap >>= bitcount;
+		s.totalhigh >>= bitcount;
+		s.freehigh >>= bitcount;
+	}
+	
 	err = put_user (s.uptime, &info->uptime);
 	err |= __put_user (s.loads[0], &info->loads[0]);
 	err |= __put_user (s.loads[1], &info->loads[1]);
@@ -2338,6 +2361,10 @@
 	err |= __put_user (s.totalswap, &info->totalswap);
 	err |= __put_user (s.freeswap, &info->freeswap);
 	err |= __put_user (s.procs, &info->procs);
+	err |= __put_user (s.totalhigh, &info->totalhigh);
+	err |= __put_user (s.freehigh, &info->freehigh);
+	err |= __put_user (s.mem_unit, &info->mem_unit);
+	
 	if (err)
 		return -EFAULT;
 	
@@ -3029,7 +3056,7 @@
 		err = do_sys32_shmctl(first, second, (void *)AA(ptr));
 		break;
 	default:
-		err = -EINVAL;
+		err = -ENOSYS;
 		break;
 	}
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/syscalls.c linux-2.4.22-pre2/arch/ppc64/kernel/syscalls.c
--- linux-2.4.21/arch/ppc64/kernel/syscalls.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/syscalls.c	2003-06-26 21:43:28.000000000 +0000
@@ -72,7 +72,7 @@
 	version = call >> 16; /* hack for backward compatibility */
 	call &= 0xffff;
 
-	ret = -EINVAL;
+	ret = -ENOSYS;
 	switch (call) {
 	case SEMOP:
 		ret = sys_semop (first, (struct sembuf *)ptr, second);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/time.c linux-2.4.22-pre2/arch/ppc64/kernel/time.c
--- linux-2.4.21/arch/ppc64/kernel/time.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/time.c	2003-06-26 21:43:15.000000000 +0000
@@ -415,8 +415,8 @@
 	time_esterror = NTP_PHASE_LIMIT;
 
 	delta_xsec = mulhdu( (tb_last_stamp-systemcfg->tb_orig_stamp), systemcfg->tb_to_xs );
-	new_xsec = (new_usec * XSEC_PER_SEC) / USEC_PER_SEC;
-	new_xsec += new_sec * XSEC_PER_SEC;
+	new_xsec = (tv->tv_usec * XSEC_PER_SEC) / USEC_PER_SEC;
+	new_xsec += tv->tv_sec * XSEC_PER_SEC;
 	if ( new_xsec > delta_xsec ) {
 		systemcfg->stamp_xsec = new_xsec - delta_xsec;
 	}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/traps.c linux-2.4.22-pre2/arch/ppc64/kernel/traps.c
--- linux-2.4.21/arch/ppc64/kernel/traps.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/traps.c	2003-06-26 21:43:17.000000000 +0000
@@ -42,6 +42,7 @@
 #include <asm/io.h>
 #include <asm/processor.h>
 #include <asm/ppcdebug.h>
+#include <asm/machdep.h> /* for ppc_attention_msg */
 
 extern int fix_alignment(struct pt_regs *);
 extern void bad_page_fault(struct pt_regs *, unsigned long);
@@ -75,14 +76,11 @@
 void (*debugger_fault_handler)(struct pt_regs *regs);
 #else
 #ifdef CONFIG_KDB
-/* kdb has different call parms */
-/* ... */
-void (*debugger)(struct pt_regs *regs) = kdb;
+void (*debugger)(struct pt_regs *regs);
 int (*debugger_bpt)(struct pt_regs *regs);
 int (*debugger_sstep)(struct pt_regs *regs);
 int (*debugger_iabr_match)(struct pt_regs *regs);
-int (*debugger_dabr_match)(struct pt_regs *regs) = kdb;
-/* - only defined during (xmon) mread */
+int (*debugger_dabr_match)(struct pt_regs *regs);
 void (*debugger_fault_handler)(struct pt_regs *regs);
 #endif /* kdb */
 #endif /* kgdb */
@@ -100,13 +98,9 @@
 	if (!user_mode(regs))
 	{
 		show_regs(regs);
-#if defined(CONFIG_XMON) || defined(CONFIG_KGDB)
+#if defined(CONFIG_XMON) || defined(CONFIG_KGDB) || defined(CONFIG_KDB)
 		debugger(regs);
 #endif
-#if defined(CONFIG_KDB)
-		if (kdb(KDB_REASON_BREAK, 0, (kdb_eframe_t) regs))
-		    return;
-#endif
 		print_backtrace((unsigned long *)regs->gpr[1]);
 		panic("Exception in kernel pc %lx signal %d",regs->nip,signr);
 #if defined(CONFIG_PPCDBG) && (defined(CONFIG_XMON) || defined(CONFIG_KGDB))
@@ -164,30 +158,11 @@
 	}
 #if defined(CONFIG_XMON)
 	xmon(regs);
-	udbg_printf("leaving xmon...\n");
+	if (smp_processor_id() == 0)
+		udbg_printf("leaving xmon...\n");
 #endif
 #if defined(CONFIG_KDB)
-	{
-		int cpu = smp_processor_id();
-		static int reset_cpu = -1;
-		static spinlock_t reset_lock = SPIN_LOCK_UNLOCKED;
-
-		/* Give kdb some help serializing the reset */
-		spin_lock(&reset_lock);
-		if (reset_cpu == -1) {
-			reset_cpu = cpu;
-			spin_unlock(&reset_lock);
-			kdb(KDB_REASON_ENTER, regs->trap, (kdb_eframe_t) regs);
-			reset_cpu = -1;
-		} else {
-			spin_unlock(&reset_lock);
-			/* Let kdb catch this cpu with an IPI.
-			 * Ideally we need a way to enter kdb w/o it becoming
-			 * confused so we can precisely capture reset state.
-			 */
-			return;
-		}
-	}
+	kdb_reset_debugger(regs);
 #endif
 }
 
@@ -195,7 +170,6 @@
 void
 MachineCheckException(struct pt_regs *regs)
 {
-	siginfo_t info;
 
 	if (fwnmi_active) {
 		struct rtas_error_log *errhdr = FWNMI_get_errinfo(regs);
@@ -205,54 +179,31 @@
 		FWNMI_release_errinfo();
 	}
 
-	if ( !user_mode(regs) ) {
-#if defined(CONFIG_XMON) || defined(CONFIG_KGDB)
-		if (debugger_fault_handler) {
-			debugger_fault_handler(regs);
-			return;
-		}
-#endif
-		printk("Machine check in kernel mode.\n");
-		printk("Caused by (from SRR1=%lx): ", regs->msr);
-		show_regs(regs);
 #if defined(CONFIG_XMON) || defined(CONFIG_KGDB)
-		debugger(regs);
+	if (debugger_fault_handler) {
+		debugger_fault_handler(regs);
+		return;
+	}
 #endif
-#ifdef CONFIG_KDB
-		if (kdb(KDB_REASON_FAULT, 0, regs))
-			return ;
+	printk(KERN_EMERG "Unrecoverable Machine check.\n");
+	printk(KERN_EMERG "Caused by (from SRR1=%lx): ", regs->msr);
+	show_regs(regs);
+#if defined(CONFIG_XMON) || defined(CONFIG_KGDB) || defined(CONFIG_KDB)
+	debugger(regs);
 #endif
-		print_backtrace((unsigned long *)regs->gpr[1]);
-		panic("machine check");
-	}
-	
-	/*
-	 * XXX we should check RI bit on exception exit and kill the
-	 * task if it was cleared
-	 */
-	info.si_signo = SIGBUS;
-	info.si_errno = 0;
-	info.si_code = BUS_ADRERR;
-	info.si_addr = (void *)regs->nip;
-	_exception(SIGSEGV, &info, regs);
-
+	print_backtrace((unsigned long *)regs->gpr[1]);
+	panic("machine check");
 }
 
 void
 SMIException(struct pt_regs *regs)
 {
-#if defined(CONFIG_XMON) || defined(CONFIG_KGDB)
+#if defined(CONFIG_XMON) || defined(CONFIG_KGDB) || defined(CONFIG_KDB)
 	{
 		debugger(regs);
 		return;
 	}
 #endif
-#ifdef CONFIG_KDB
-	{
-		kdb(KDB_REASON_OOPS, 0, regs);
-		return;
-	}
-#endif
 	show_regs(regs);
 	print_backtrace((unsigned long *)regs->gpr[1]);
 	panic("System Management Interrupt");
@@ -278,15 +229,10 @@
 {
 	siginfo_t info;
 	
-#if defined(CONFIG_XMON) || defined(CONFIG_KGDB)
+#if defined(CONFIG_XMON) || defined(CONFIG_KGDB) || defined (CONFIG_KDB)
 	if (debugger_iabr_match(regs))
 		return;
 #endif
-#ifdef CONFIG_KDB
-	if (kdb(KDB_REASON_BREAK, 0, regs))
-		return;
-#endif
-
 	info.si_signo = SIGTRAP;
 	info.si_errno = 0;
 	info.si_code = TRAP_BRKPT;
@@ -353,14 +299,10 @@
 	} else if (regs->msr & 0x20000) {
 		/* trap exception */
 
-#if defined(CONFIG_XMON) || defined(CONFIG_KGDB)
+#if defined(CONFIG_XMON) || defined(CONFIG_KGDB) || defined(CONFIG_KDB)
 		if (debugger_bpt(regs))
 			return;
 #endif
-#ifdef CONFIG_KDB
-		if (kdb(KDB_REASON_BREAK, 0, regs))
-			return;
-#endif
 		info.si_signo = SIGTRAP;
 		info.si_errno = 0;
 		info.si_code = TRAP_BRKPT;
@@ -377,6 +319,14 @@
 	}
 }
 
+ void
+KernelFPUnavailableException(struct pt_regs *regs)
+{
+	printk("Illegal floating point used in kernel (task=0x%016lx, pc=0x%016lx, trap=0x%08x)\n",
+		current, regs->nip, regs->trap);
+	panic("Unrecoverable FP Unavailable Exception in Kernel");
+}
+
 void
 SingleStepException(struct pt_regs *regs)
 {
@@ -384,15 +334,10 @@
 
 	regs->msr &= ~MSR_SE;  /* Turn off 'trace' bit */
 
-#if defined(CONFIG_XMON) || defined(CONFIG_KGDB)
+#if defined(CONFIG_XMON) || defined(CONFIG_KGDB) || defined(CONFIG_KDB)
 	if (debugger_sstep(regs))
 		return;
 #endif
-#ifdef CONFIG_KDB
-	if (kdb(KDB_REASON_DEBUG, 0, regs))
-		return;
-#endif
-
 	info.si_signo = SIGTRAP;
 	info.si_errno = 0;
 	info.si_code = TRAP_TRACE;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/kernel/xics.c linux-2.4.22-pre2/arch/ppc64/kernel/xics.c
--- linux-2.4.21/arch/ppc64/kernel/xics.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/kernel/xics.c	2003-06-26 21:43:15.000000000 +0000
@@ -143,18 +143,22 @@
 	u_int		irq;
 	unsigned long	status;
 	long	        call_status;
+	unsigned int    interrupt_server = default_server;
 
 	virq -= XICS_IRQ_OFFSET;
 	irq = virt_irq_to_real(virq);
 	if (irq == XICS_IPI)
 		return;
+
 #ifdef CONFIG_IRQ_ALL_CPUS
-	call_status = rtas_call(ibm_set_xive, 3, 1, (unsigned long*)&status,
-				irq, smp_threads_ready ? default_distrib_server : default_server, DEFAULT_PRIORITY);
-#else
-	call_status = rtas_call(ibm_set_xive, 3, 1, (unsigned long*)&status,
-				irq, default_server, DEFAULT_PRIORITY);
+	if((smp_num_cpus == systemcfg->processorCount) &&
+	   (smp_threads_ready)) {
+		interrupt_server = default_distrib_server;
+	}
 #endif
+	call_status = rtas_call(ibm_set_xive, 3, 1, (unsigned long*)&status,
+				irq, interrupt_server, DEFAULT_PRIORITY);
+
 	if( call_status != 0 ) {
 		printk("xics_enable_irq: irq=%x: rtas_call failed; retn=%lx, status=%lx\n",
 		       irq, call_status, status);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/lib/copyuser.S linux-2.4.22-pre2/arch/ppc64/lib/copyuser.S
--- linux-2.4.21/arch/ppc64/lib/copyuser.S	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/lib/copyuser.S	2003-06-26 21:43:20.000000000 +0000
@@ -130,7 +130,7 @@
 6:	cmpwi	cr1,r5,8
 	addi	r3,r3,32
 	sld	r9,r9,r10
-	blt	cr1,.Ldo_tail
+	ble	cr1,.Ldo_tail
 34:	ld	r0,8(r4)
 	srd	r7,r0,r11
 	or	r9,r7,r9
@@ -483,8 +483,20 @@
  * on an exception, reset to the beginning and jump back into the
  * standard __copy_tofrom_user
  */
-100:	ld	r3,-24(r1)
-	ld	r4,-24(r1)
+100:	ld	r20,-120(1)
+	ld	r21,-112(1)
+	ld	r22,-104(1)
+	ld	r23,-96(1)
+	ld	r24,-88(1)
+	ld	r25,-80(1)
+	ld	r26,-72(1)
+	ld	r27,-64(1)
+	ld	r28,-56(1)
+	ld	r29,-48(1)
+	ld	r30,-40(1)
+	ld	r31,-32(1)
+	ld	r3,-24(r1)
+	ld	r4,-16(r1)
 	li	r5,4096
 	b	.Ldst_aligned
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/mm/fault.c linux-2.4.22-pre2/arch/ppc64/mm/fault.c
--- linux-2.4.21/arch/ppc64/mm/fault.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/mm/fault.c	2003-06-26 21:43:18.000000000 +0000
@@ -65,7 +65,7 @@
 void do_page_fault(struct pt_regs *regs, unsigned long address,
 		   unsigned long error_code)
 {
-	struct vm_area_struct * vma;
+	struct vm_area_struct * vma, * prev_vma;
 	struct mm_struct *mm = current->mm;
 	siginfo_t info;
 	unsigned long code = SEGV_MAPERR;
@@ -90,8 +90,8 @@
 	}
 #endif /* CONFIG_XMON || CONFIG_KGDB */
 
-	/* On an SLB miss we can only check for a valid exception entry */
-	if (regs->trap == 0x380) {
+	/* On a kernel SLB miss we can only check for a valid exception entry */
+	if (!user_mode(regs) && (regs->trap == 0x380)) {
 		bad_page_fault(regs, address);
 		return;
 	}
@@ -99,13 +99,8 @@
 #if defined(CONFIG_XMON) || defined(CONFIG_KGDB) || defined(CONFIG_KDB)
 	if (error_code & 0x00400000) {
 		/* DABR match */
-#if defined(CONFIG_KDB)
-	    if (kdb(KDB_REASON_BREAK,regs->trap,regs))
-			return;
-#else
 		if (debugger_dabr_match(regs))
 			return;
-#endif
 	}
 #endif /* CONFIG_XMON || CONFIG_KGDB || CONFIG_KDB */
 
@@ -128,6 +123,7 @@
 		PPCDBG(PPCDBG_MM, "\tdo_page_fault: vma->vm_flags = %lx, %lx\n", vma->vm_flags, VM_GROWSDOWN);
 		goto bad_area;
 	}
+	vma = find_vma_prev(mm, address, &prev_vma);
 	if (expand_stack(vma, address)) {
 		PPCDBG(PPCDBG_MM, "\tdo_page_fault: expand_stack\n");
 		goto bad_area;
@@ -243,13 +239,10 @@
 
 	/* kernel has accessed a bad area */
 	show_regs(regs);
-#if defined(CONFIG_XMON) || defined(CONFIG_KGDB)
+#if defined(CONFIG_XMON) || defined(CONFIG_KGDB) || defined(CONFIG_KDB)
 	if (debugger_kernel_faults)
 		debugger(regs);
 #endif
-#if defined(CONFIG_KDB)
-	kdb(KDB_REASON_FAULT, regs->trap, regs);
-#endif	
 	print_backtrace( (unsigned long *)regs->gpr[1] );
 	panic("kernel access of bad area pc %lx lr %lx address %lX tsk %s/%d",
 	      regs->nip,regs->link,address,current->comm,current->pid);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/mm/init.c linux-2.4.22-pre2/arch/ppc64/mm/init.c
--- linux-2.4.21/arch/ppc64/mm/init.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/mm/init.c	2003-06-26 21:43:13.000000000 +0000
@@ -279,7 +279,11 @@
 	/* Implemented to just flush the vmalloc area.
 	 * vmalloc is the only user of flush_tlb_all.
 	 */
+#ifdef CONFIG_SHARED_MEMORY_ADDRESSING
+	local_flush_tlb_range( NULL, VMALLOC_START, SMALLOC_END );
+#else
 	local_flush_tlb_range( NULL, VMALLOC_START, VMALLOC_END );
+#endif
 }
 
 void
@@ -292,11 +296,6 @@
 		for ( mp = mm->mmap; mp != NULL; mp = mp->vm_next )
 			local_flush_tlb_range( mm, mp->vm_start, mp->vm_end );
 	}
-	else	/* MIKEC: It is not clear why this is needed */
-		/* paulus: it is needed to clear out stale HPTEs
-		 * when an address space (represented by an mm_struct)
-		 * is being destroyed. */
-		local_flush_tlb_range( mm, USER_START, USER_END );
 
 	spin_unlock(&mm->page_table_lock);
 }
@@ -644,3 +643,131 @@
 	maddr = (unsigned long)page_address(page) + (addr & ~PAGE_MASK);
 	flush_icache_range(maddr, maddr + len);
 }
+
+#ifdef CONFIG_SHARED_MEMORY_ADDRESSING
+static spinlock_t shared_malloc_lock = SPIN_LOCK_UNLOCKED;
+struct vm_struct *shared_list = NULL;
+static struct vm_struct *get_shared_area(unsigned long size, 
+					 unsigned long flags);
+
+void *shared_malloc(unsigned long size) {
+	pgprot_t prot;
+	struct vm_struct *area;
+	unsigned long ea;
+
+	spin_lock(&shared_malloc_lock);
+
+	printk("shared_malloc1 (no _PAGE_USER): addr = 0x%lx, size = 0x%lx\n", 
+	       SMALLOC_START, size); 
+
+	area = get_shared_area(size, 0);
+	if (!area) {
+	spin_unlock(&shared_malloc_lock);
+		return NULL;
+	}
+
+	ea = (unsigned long) area->addr;
+
+	prot = __pgprot(pgprot_val(PAGE_KERNEL));
+	if (vmalloc_area_pages(VMALLOC_VMADDR(ea), size, GFP_KERNEL, prot)) { 
+	spin_unlock(&shared_malloc_lock);
+		return NULL;
+	} 
+
+	printk("shared_malloc: addr = 0x%lx, size = 0x%lx\n", ea, size); 
+
+	spin_unlock(&shared_malloc_lock);
+	return(ea); 
+}
+
+void shared_free(void *addr) {
+	struct vm_struct **p, *tmp;
+	unsigned long size = 0;
+
+	if (!addr)
+		return;
+	if ((PAGE_SIZE-1) & (unsigned long) addr) {
+		printk(KERN_ERR "Trying to shared_free() bad address (%p)\n", 
+		       addr);
+		return;
+	}
+	spin_lock(&shared_malloc_lock);
+
+	printk("shared_free: addr = 0x%lx\n", addr); 
+
+	/* Scan the memory list for an entry matching
+	 * the address to be freed, get the size (in bytes)
+	 * and free the entry.  The list lock is not dropped
+	 * until the page table entries are removed.
+	 */
+	for(p = &shared_list; (tmp = *p); p = &tmp->next ) {
+		if (tmp->addr == addr) {
+			*p = tmp->next;
+			vmfree_area_pages(VMALLOC_VMADDR(tmp->addr),tmp->size);
+			spin_unlock(&shared_malloc_lock);
+			kfree(tmp);
+			return;
+		}
+	}
+
+	spin_unlock(&shared_malloc_lock);
+	printk("shared_free: error\n"); 
+}
+
+static struct vm_struct *get_shared_area(unsigned long size, 
+					 unsigned long flags) {
+	unsigned long addr;
+	struct vm_struct **p, *tmp, *area;
+  
+	area = (struct vm_struct *) kmalloc(sizeof(*area), GFP_KERNEL);
+	if (!area) return NULL;
+
+	size += PAGE_SIZE;
+	if (!size) {
+		kfree (area);
+		return NULL;
+	}
+
+	addr = SMALLOC_START;
+	for (p = &shared_list; (tmp = *p) ; p = &tmp->next) {
+		if ((size + addr) < addr) {
+			kfree(area);
+			return NULL;
+		}
+		if (size + addr <= (unsigned long) tmp->addr)
+			break;
+		addr = tmp->size + (unsigned long) tmp->addr;
+		if (addr > SMALLOC_END-size) {
+			kfree(area);
+			return NULL;
+		}
+	}
+
+	if (addr + size > SMALLOC_END) {
+		kfree(area);
+		return NULL;
+	}
+	area->flags = flags;
+	area->addr = (void *)addr;
+	area->size = size;
+	area->next = *p;
+	*p = area;
+	return area;
+}
+
+int shared_task_mark() {
+	current->thread.flags |= PPC_FLAG_SHARED;
+	printk("current->thread.flags = 0x%lx\n", current->thread.flags);
+
+	return 0;
+}
+
+int shared_task_unmark() {
+	if(current->thread.flags & PPC_FLAG_SHARED) {
+		current->thread.flags &= (~PPC_FLAG_SHARED);
+		return 0;
+	} else {
+		return -1;
+	}
+}
+#endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/vmlinux.lds linux-2.4.22-pre2/arch/ppc64/vmlinux.lds
--- linux-2.4.21/arch/ppc64/vmlinux.lds	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/vmlinux.lds	2003-06-26 21:43:11.000000000 +0000
@@ -73,6 +73,9 @@
   __kallsyms : { *(__kallsyms) }
   __stop___kallsyms = .;
 
+  __start___ftr_fixup = .;
+  __ftr_fixup : { *(__ftr_fixup) }
+  __stop___ftr_fixup = .;
 
   . = ALIGN(4096);
   .data.page_aligned : { *(.data.page_aligned) }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/ppc64/xmon/xmon.c linux-2.4.22-pre2/arch/ppc64/xmon/xmon.c
--- linux-2.4.21/arch/ppc64/xmon/xmon.c	2003-06-26 21:45:05.000000000 +0000
+++ linux-2.4.22-pre2/arch/ppc64/xmon/xmon.c	2003-06-26 21:43:15.000000000 +0000
@@ -26,6 +26,7 @@
 #include <asm/naca.h>
 #include <asm/paca.h>
 #include <asm/ppcdebug.h>
+#include <asm/cputable.h>
 #include "nonstdio.h"
 #include "privinst.h"
 
@@ -33,9 +34,11 @@
 #define skipbl	xmon_skipbl
 
 #ifdef CONFIG_SMP
-static unsigned long cpus_in_xmon = 0;
-static unsigned long got_xmon = 0;
+static volatile unsigned long cpus_in_xmon = 0;
+static volatile unsigned long got_xmon = 0;
 static volatile int take_xmon = -1;
+static volatile int leaving_xmon = 0;
+
 #endif /* CONFIG_SMP */
 
 static unsigned long adrs;
@@ -190,7 +193,7 @@
 	asm volatile("sync; isync");
 }
 
-/* (Ref: 64-bit PowerPC ELF ABI Spplement; Ian Lance Taylor, Zembu Labs).
+/* (Ref: 64-bit PowerPC ELF ABI Supplement; Ian Lance Taylor, Zembu Labs).
  A PPC stack frame looks like this:
 
  High Address
@@ -250,12 +253,12 @@
 xmon(struct pt_regs *excp)
 {
 	struct pt_regs regs;
-	int cmd;
+	int cmd = 0;
 	unsigned long msr;
 
 	if (excp == NULL) {
 		/* Ok, grab regs as they are now.
-		 This won't do a particularily good job because the
+		 This won't do a particularly good job because the
 		 prologue has already been executed.
 		 ToDo: We could reach back into the callers save
 		 area to do a better job of representing the
@@ -309,9 +312,15 @@
 	xmon_regs[smp_processor_id()] = excp;
 	excprint(excp);
 #ifdef CONFIG_SMP
-	if (test_and_set_bit(smp_processor_id(), &cpus_in_xmon))
+	/* possible race condition here if a CPU is held up and gets
+	 * here while we are exiting */
+	leaving_xmon = 0;
+	if (test_and_set_bit(smp_processor_id(), &cpus_in_xmon)) {
+		/* xmon probably caused an exception itself */
+		printf("We are already in xmon\n");
 		for (;;)
 			;
+	}
 	while (test_and_set_bit(0, &got_xmon)) {
 		if (take_xmon == smp_processor_id()) {
 			take_xmon = -1;
@@ -327,6 +336,9 @@
 	if (cmd == 's') {
 		xmon_trace[smp_processor_id()] = SSTEP;
 		excp->msr |= MSR_SE;
+#ifdef CONFIG_SMP		
+		take_xmon = smp_processor_id();
+#endif		
 	} else if (at_breakpoint(excp->nip)) {
 		xmon_trace[smp_processor_id()] = BRSTEP;
 		excp->msr |= MSR_SE;
@@ -336,7 +348,9 @@
 	}
 	xmon_regs[smp_processor_id()] = 0;
 #ifdef CONFIG_SMP
-	clear_bit(0, &got_xmon);
+	leaving_xmon = 1;
+	if (cmd != 's')
+		clear_bit(0, &got_xmon);
 	clear_bit(smp_processor_id(), &cpus_in_xmon);
 #endif /* CONFIG_SMP */
 	set_msrd(msr);		/* restore interrupt enable */
@@ -442,7 +456,7 @@
 	int i;
 	struct bpt *bp;
 
-	if (systemcfg->platform != PLATFORM_PSERIES)
+	if (!(systemcfg->platform & PLATFORM_PSERIES))
 		return;
 	bp = bpts;
 	for (i = 0; i < NBPTS; ++i, ++bp) {
@@ -458,7 +472,7 @@
 		}
 	}
 
-	if (!__is_processor(PV_POWER4) && !__is_processor(PV_POWER4p)) {
+	if (!(cur_cpu_spec->cpu_features & CPU_FTR_SLB)) {
 		if (dabr.enabled)
 			set_dabr(dabr.address);
 		if (iabr.enabled)
@@ -473,11 +487,13 @@
 	struct bpt *bp;
 	unsigned instr;
 
-	if (systemcfg->platform != PLATFORM_PSERIES)
+	if (!(systemcfg->platform & PLATFORM_PSERIES))
 		return;
-	if (!__is_processor(PV_POWER4) && !__is_processor(PV_POWER4p)) {
-		set_dabr(0);
-		set_iabr(0);
+	if (!(cur_cpu_spec->cpu_features & CPU_FTR_SLB)) {
+		if (dabr.enabled)
+			set_dabr(0);
+		if (iabr.enabled)
+			set_iabr(0);
 	}
 
 	bp = bpts;
@@ -500,11 +516,15 @@
 static int
 cmds(struct pt_regs *excp)
 {
-	int cmd;
+	int cmd = 0;
 
 	last_cmd = NULL;
 	for(;;) {
 #ifdef CONFIG_SMP
+		/* Need to check if we should take any commands on
+		   this CPU. */
+		if (leaving_xmon)
+			return cmd;
 		printf("%d:", smp_processor_id());
 #endif /* CONFIG_SMP */
 		printf("mon> ");
@@ -767,10 +787,11 @@
 	cmd = inchar();
 	switch (cmd) {
 	case 'd':	/* bd - hardware data breakpoint */
-		if (__is_processor(PV_POWER4) || __is_processor(PV_POWER4p)) {
+		if (cur_cpu_spec->cpu_features & CPU_FTR_SLB) {
 			printf("Not implemented on POWER4\n");
 			break;
 		}
+			
 		mode = 7;
 		cmd = inchar();
 		if (cmd == 'r')
@@ -787,7 +808,7 @@
 			dabr.address = (dabr.address & ~7) | mode;
 		break;
 	case 'i':	/* bi - hardware instr breakpoint */
-		if (__is_processor(PV_POWER4) || __is_processor(PV_POWER4p)) {
+		if (cur_cpu_spec->cpu_features & CPU_FTR_SLB) {
 			printf("Not implemented on POWER4\n");
 			break;
 		}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/sparc64/boot/Makefile linux-2.4.22-pre2/arch/sparc64/boot/Makefile
--- linux-2.4.21/arch/sparc64/boot/Makefile	2003-06-26 21:45:06.000000000 +0000
+++ linux-2.4.22-pre2/arch/sparc64/boot/Makefile	2003-06-26 21:43:10.000000000 +0000
@@ -20,7 +20,7 @@
 	$(HOSTCC) $(HOSTCFLAGS) -o piggyback piggyback.c
 
 image: $(TOPDIR)/vmlinux
-	$(STRIP) -R .comment -R .note $(TOPDIR)/vmlinux -o $@
+	$(STRIP) -R .comment -R .note -K sun4u_init -K _end -K _start $(TOPDIR)/vmlinux -o $@
 
 dep:
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/sparc64/kernel/ioctl32.c linux-2.4.22-pre2/arch/sparc64/kernel/ioctl32.c
--- linux-2.4.21/arch/sparc64/kernel/ioctl32.c	2003-06-26 21:45:06.000000000 +0000
+++ linux-2.4.22-pre2/arch/sparc64/kernel/ioctl32.c	2003-06-26 21:43:31.000000000 +0000
@@ -4313,6 +4313,11 @@
 #define BNEPGETCONNLIST	_IOR('B', 210, int)
 #define BNEPGETCONNINFO	_IOR('B', 211, int)
 
+#define CMTPCONNADD	_IOW('C', 200, int)
+#define CMTPCONNDEL	_IOW('C', 201, int)
+#define CMTPGETCONNLIST	_IOR('C', 210, int)
+#define CMTPGETCONNINFO	_IOR('C', 211, int)
+
 struct ioctl_trans {
 	unsigned int cmd;
 	unsigned int handler;
@@ -4460,6 +4465,7 @@
 COMPATIBLE_IOCTL(STOP_ARRAY)
 COMPATIBLE_IOCTL(STOP_ARRAY_RO)
 COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
+COMPATIBLE_IOCTL(RAID_AUTORUN)
 
 /* Big K */
 COMPATIBLE_IOCTL(PIO_FONT)
@@ -5036,6 +5042,10 @@
 COMPATIBLE_IOCTL(BNEPCONNDEL)
 COMPATIBLE_IOCTL(BNEPGETCONNLIST)
 COMPATIBLE_IOCTL(BNEPGETCONNINFO)
+COMPATIBLE_IOCTL(CMTPCONNADD)
+COMPATIBLE_IOCTL(CMTPCONNDEL)
+COMPATIBLE_IOCTL(CMTPGETCONNLIST)
+COMPATIBLE_IOCTL(CMTPGETCONNINFO)
 /* Scanner */
 COMPATIBLE_IOCTL(SCANNER_IOCTL_VENDOR)
 COMPATIBLE_IOCTL(SCANNER_IOCTL_PRODUCT)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/sparc64/kernel/sys_sparc.c linux-2.4.22-pre2/arch/sparc64/kernel/sys_sparc.c
--- linux-2.4.21/arch/sparc64/kernel/sys_sparc.c	2003-06-26 21:45:06.000000000 +0000
+++ linux-2.4.22-pre2/arch/sparc64/kernel/sys_sparc.c	2003-06-26 21:43:27.000000000 +0000
@@ -223,9 +223,15 @@
 		}
 	if (call <= SHMCTL) 
 		switch (call) {
-		case SHMAT:
-			err = sys_shmat (first, (char *) ptr, second, (ulong *) third);
+		case SHMAT: {
+			ulong raddr;
+			err = sys_shmat (first, (char *) ptr, second, &raddr);
+			if (!err) {
+				if (put_user(raddr, (ulong *) third))
+					err = -EFAULT;
+			}
 			goto out;
+		}
 		case SHMDT:
 			err = sys_shmdt ((char *)ptr);
 			goto out;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/arch/sparc64/kernel/sys_sparc32.c linux-2.4.22-pre2/arch/sparc64/kernel/sys_sparc32.c
--- linux-2.4.21/arch/sparc64/kernel/sys_sparc32.c	2003-06-26 21:45:06.000000000 +0000
+++ linux-2.4.22-pre2/arch/sparc64/kernel/sys_sparc32.c	2003-06-26 21:43:28.000000000 +0000
@@ -1891,7 +1891,11 @@
         u32 totalswap;
         u32 freeswap;
         unsigned short procs;
-        char _f[22];
+	unsigned short pad;
+	u32 totalhigh;
+	u32 freehigh;
+	u32 mem_unit;
+	char _f[20-2*sizeof(int)-sizeof(int)];
 };
 
 extern asmlinkage int sys_sysinfo(struct sysinfo *info);
@@ -1900,11 +1904,30 @@
 {
 	struct sysinfo s;
 	int ret, err;
+	int bitcount = 0;
 	mm_segment_t old_fs = get_fs ();
 	
-	set_fs (KERNEL_DS);
+	set_fs(KERNEL_DS);
 	ret = sys_sysinfo(&s);
-	set_fs (old_fs);
+	set_fs(old_fs);
+	/* Check to see if any memory value is too large for 32-bit and
+         * scale down if needed.
+         */
+	if ((s.totalram >> 32) || (s.totalswap >> 32)) {
+		while (s.mem_unit < PAGE_SIZE) {
+			s.mem_unit <<= 1;
+			bitcount++;
+		}
+		s.totalram >>= bitcount;
+		s.freeram >>= bitcount;
+		s.sharedram >>= bitcount;
+		s.bufferram >>= bitcount;
+		s.totalswap >>= bitcount;
+		s.freeswap >>= bitcount;
+		s.totalhigh >>= bitcount;
+		s.freehigh >>= bitcount;
+	}
+
 	err = put_user (s.uptime, &info->uptime);
 	err |= __put_user (s.loads[0], &info->loads[0]);
 	err |= __put_user (s.loads[1], &info->loads[1]);
@@ -1916,6 +1939,9 @@
 	err |= __put_user (s.totalswap, &info->totalswap);
 	err |= __put_user (s.freeswap, &info->freeswap);
 	err |= __put_user (s.procs, &info->procs);
+	err |= __put_user (s.totalhigh, &info->totalhigh);
+	err |= __put_user (s.freehigh, &info->freehigh);
+	err |= __put_user (s.mem_unit, &info->mem_unit);
 	if (err)
 		return -EFAULT;
 	return ret;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/Config.in linux-2.4.22-pre2/drivers/acpi/Config.in
--- linux-2.4.21/drivers/acpi/Config.in	2001-06-21 00:47:39.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/Config.in	2003-06-26 21:43:31.000000000 +0000
@@ -1,17 +1,93 @@
 #
-# ACPI configuration
+# ACPI Configuration
 #
-#mainmenu_option next_comment
-#comment 'ACPI Configuration'
 
-dep_bool     '    ACPI Debug Statements' CONFIG_ACPI_DEBUG $CONFIG_ACPI
-dep_tristate '    ACPI Bus Manager' CONFIG_ACPI_BUSMGR $CONFIG_ACPI
+if [ "$CONFIG_X86" = "y" ]; then
 
-dep_tristate '      System' CONFIG_ACPI_SYS $CONFIG_ACPI_BUSMGR $CONFIG_ACPI
-dep_tristate '      Processor' CONFIG_ACPI_CPU $CONFIG_ACPI_BUSMGR $CONFIG_ACPI
-dep_tristate '      Button' CONFIG_ACPI_BUTTON $CONFIG_ACPI_BUSMGR $CONFIG_ACPI
-dep_tristate '      AC Adapter' CONFIG_ACPI_AC $CONFIG_ACPI_BUSMGR $CONFIG_ACPI
-dep_tristate '      Embedded Controller' CONFIG_ACPI_EC $CONFIG_ACPI_BUSMGR $CONFIG_ACPI
-dep_tristate '      Control Method Battery' CONFIG_ACPI_CMBATT $CONFIG_ACPI_BUSMGR $CONFIG_ACPI $CONFIG_ACPI_EC
-dep_tristate '      Thermal' CONFIG_ACPI_THERMAL $CONFIG_ACPI_BUSMGR $CONFIG_ACPI  $CONFIG_ACPI_EC
-#endmenu
+  mainmenu_option next_comment
+  comment 'ACPI Support'
+  bool         'ACPI Support' CONFIG_ACPI
+  if [ "$CONFIG_ACPI" = "y" ]; then
+    if [ "$CONFIG_X86_LOCAL_APIC" = "y" ]; then
+      bool         'CPU Enumeration Only' CONFIG_ACPI_HT_ONLY
+    else
+      define_bool CONFIG_ACPI_HT_ONLY n
+    fi
+
+    if [ "$CONFIG_ACPI_HT_ONLY" = "n" ]; then
+      define_bool CONFIG_ACPI_BOOT		y
+      define_bool CONFIG_ACPI_BUS		y
+      define_bool CONFIG_ACPI_INTERPRETER	y
+      define_bool CONFIG_ACPI_EC		y
+      define_bool CONFIG_ACPI_POWER		y
+      if [ "$CONFIG_PCI" = "y" ]; then
+        define_bool CONFIG_ACPI_PCI		y
+      fi
+      define_bool CONFIG_ACPI_SLEEP		y
+      define_bool CONFIG_ACPI_SYSTEM		y
+      tristate     '  AC Adapter'	CONFIG_ACPI_AC
+      tristate     '  Battery'		CONFIG_ACPI_BATTERY
+      tristate     '  Button'		CONFIG_ACPI_BUTTON
+      tristate     '  Fan'		CONFIG_ACPI_FAN
+      tristate     '  Processor'	CONFIG_ACPI_PROCESSOR
+      dep_tristate '  Thermal Zone' 	CONFIG_ACPI_THERMAL $CONFIG_ACPI_PROCESSOR
+      if [ "$CONFIG_NUMA" = "y" ]; then
+        dep_bool       '  NUMA support'     CONFIG_ACPI_NUMA $CONFIG_NUMA
+      fi
+      tristate     '  ASUS Laptop Extras'  CONFIG_ACPI_ASUS
+      tristate     '  Toshiba Laptop Extras'	CONFIG_ACPI_TOSHIBA
+      bool         '  Debug Statements'	CONFIG_ACPI_DEBUG
+    fi
+  fi
+
+  endmenu
+
+fi
+
+
+if [ "$CONFIG_IA64" = "y" ]; then
+
+  if [ "$CONFIG_IA64_SGI_SN" = "y" ]; then
+    mainmenu_option next_comment
+    comment 'ACPI Support'
+    define_bool CONFIG_ACPI		y
+    define_bool CONFIG_ACPI_EFI		y
+    define_bool CONFIG_ACPI_BOOT	y
+    define_bool CONFIG_ACPI_BUS		n
+    define_bool CONFIG_ACPI_INTERPRETER n
+    define_bool CONFIG_ACPI_PCI		n
+    define_bool CONFIG_ACPI_POWER 	n
+    define_bool CONFIG_ACPI_SYSTEM 	n
+    define_bool CONFIG_ACPI_BUTTON	n
+    define_bool CONFIG_ACPI_FAN		n
+    define_bool CONFIG_ACPI_PROCESSOR	n
+    define_bool CONFIG_ACPI_THERMAL	n
+    define_bool CONFIG_ACPI_NUMA	y
+    endmenu
+  fi
+
+  if [ "$CONFIG_IA64_HP_SIM" = "n" ]; then
+    mainmenu_option next_comment
+    comment 'ACPI Support'
+    if [ "$CONFIG_PCI" = "y" ]; then
+      define_bool CONFIG_ACPI_PCI 	y
+    fi
+    define_bool CONFIG_ACPI		y
+    define_bool CONFIG_ACPI_EFI		y
+    define_bool CONFIG_ACPI_BOOT	y
+    define_bool CONFIG_ACPI_BUS		y
+    define_bool CONFIG_ACPI_INTERPRETER y
+    define_bool CONFIG_ACPI_POWER 	y
+    define_bool CONFIG_ACPI_SYSTEM 	y
+    tristate     '  Button'		CONFIG_ACPI_BUTTON
+    tristate     '  Fan'		CONFIG_ACPI_FAN
+    tristate     '  Processor'		CONFIG_ACPI_PROCESSOR
+    dep_tristate '  Thermal Zone'       CONFIG_ACPI_THERMAL $CONFIG_ACPI_PROCESSOR
+    if [ "$CONFIG_NUMA" = "y" ]; then
+      dep_bool       '  NUMA support'       CONFIG_ACPI_NUMA $CONFIG_NUMA
+    fi
+    bool         '  Debug Statements' 	CONFIG_ACPI_DEBUG
+    endmenu
+  fi
+
+fi
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/Makefile linux-2.4.22-pre2/drivers/acpi/Makefile
--- linux-2.4.21/drivers/acpi/Makefile	2001-10-24 21:06:21.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/Makefile	2003-06-26 21:43:32.000000000 +0000
@@ -4,51 +4,55 @@
 
 O_TARGET := acpi.o
 
-export-objs := acpi_ksyms.o
-
 export ACPI_CFLAGS
 
-ACPI_CFLAGS := -D_LINUX -I$(CURDIR)/include
-
-#
-# CONFIG_ACPI_KERNEL_CONFIG is currently only IA64
-#
-ifdef CONFIG_ACPI_KERNEL_CONFIG
-  ACPI_CFLAGS += -DCONFIG_ACPI_KERNEL_CONFIG_ONLY
-endif
-
-acpi-subdirs := utilities dispatcher events hardware \
-		executer namespace parser resources tables
+ACPI_CFLAGS	:= -Os 
 
 ifdef CONFIG_ACPI_DEBUG
-  ACPI_CFLAGS += -DACPI_DEBUG -Wno-unused
-endif
-
-ifdef CONFIG_ACPI_DEBUGGER
-  ACPI_CFLAGS += -DENABLE_DEBUGGER
-  acpi-subdirs += debugger
+  ACPI_CFLAGS	+= -DACPI_DEBUG_OUTPUT
 endif
 
-EXTRA_CFLAGS += $(ACPI_CFLAGS)
+EXTRA_CFLAGS	+= $(ACPI_CFLAGS)
 
-mod-subdirs  := ospm
+export-objs 	:= acpi_ksyms.o processor.o
 
-subdir-$(CONFIG_ACPI) 		+= $(acpi-subdirs)
-subdir-$(CONFIG_ACPI_BUSMGR)	+= ospm
+obj-y		:= acpi_ksyms.o 
 
-obj-$(CONFIG_ACPI)	+= driver.o os.o acpi_ksyms.o
-obj-$(CONFIG_ACPI)	+= $(foreach dir,$(acpi-subdirs),$(dir)/$(dir).o) 
-ifdef CONFIG_ACPI_KERNEL_CONFIG
-   obj-$(CONFIG_ACPI) 	+= acpiconf.o osconf.o
+#
+# ACPI Boot-Time Table Parsing
+#
+ifeq ($(CONFIG_ACPI_BOOT),y)
+  obj-y		+= tables.o blacklist.o
 endif
 
-ifeq ($(CONFIG_ACPI_BUSMGR),y)
-	obj-y			+= ospm/ospm.o
+#
+# ACPI Core Subsystem (Interpreter)
+#
+ifeq ($(CONFIG_ACPI_INTERPRETER),y)
+  obj-y		+= osl.o utils.o
+  subdir-y	+= dispatcher events executer hardware namespace parser \
+		   resources tables utilities
+  obj-y 	+= $(foreach dir,$(subdir-y),$(dir)/$(dir).o)
 endif
 
-# commented out until we distribute it -ASG
-#ifeq ($(CONFIG_KDB),y)
-#	obj-m	+= kdb/kdbm_acpi.o
-#endif
+#
+# ACPI Bus and Device Drivers
+#
+ifeq ($(CONFIG_ACPI_BUS),y)
+  obj-y				+= bus.o 
+  obj-$(CONFIG_ACPI_AC) 	+= ac.o
+  obj-$(CONFIG_ACPI_BATTERY)	+= battery.o
+  obj-$(CONFIG_ACPI_BUTTON)	+= button.o
+  obj-$(CONFIG_ACPI_EC)		+= ec.o
+  obj-$(CONFIG_ACPI_FAN)	+= fan.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
+  obj-$(CONFIG_ACPI_THERMAL)	+= thermal.o
+  obj-$(CONFIG_ACPI_SYSTEM)	+= system.o
+  obj-$(CONFIG_ACPI_NUMA)	+= numa.o
+  obj-$(CONFIG_ACPI_ASUS)	+= asus_acpi.o
+  obj-$(CONFIG_ACPI_TOSHIBA)	+= toshiba_acpi.o
+endif
 
 include $(TOPDIR)/Rules.make
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ac.c linux-2.4.22-pre2/drivers/acpi/ac.c
--- linux-2.4.21/drivers/acpi/ac.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ac.c	2003-06-26 21:43:31.000000000 +0000
@@ -0,0 +1,346 @@
+/*
+ *  acpi_ac.c - ACPI AC Adapter Driver ($Revision: 26 $)
+ *
+ *  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/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/compatmac.h>
+#include <linux/proc_fs.h>
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+
+
+#define _COMPONENT		ACPI_AC_COMPONENT
+ACPI_MODULE_NAME		("acpi_ac")
+
+MODULE_AUTHOR("Paul Diefenbaugh");
+MODULE_DESCRIPTION(ACPI_AC_DRIVER_NAME);
+MODULE_LICENSE("GPL");
+
+#define PREFIX			"ACPI: "
+
+
+int acpi_ac_add (struct acpi_device *device);
+int acpi_ac_remove (struct acpi_device *device, int type);
+
+static struct acpi_driver acpi_ac_driver = {
+	.name =		ACPI_AC_DRIVER_NAME,
+	.class =	ACPI_AC_CLASS,
+	.ids =		ACPI_AC_HID,
+	.ops =		{
+				.add =		acpi_ac_add,
+				.remove =	acpi_ac_remove,
+			},
+};
+
+struct acpi_ac {
+	acpi_handle		handle;
+	unsigned long		state;
+};
+
+
+/* --------------------------------------------------------------------------
+                               AC Adapter Management
+   -------------------------------------------------------------------------- */
+
+static int
+acpi_ac_get_state (
+	struct acpi_ac		*ac)
+{
+	acpi_status		status = AE_OK;
+
+	ACPI_FUNCTION_TRACE("acpi_ac_get_state");
+
+	if (!ac)
+		return_VALUE(-EINVAL);
+
+	status = acpi_evaluate_integer(ac->handle, "_PSR", NULL, &ac->state);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Error reading AC Adapter state\n"));
+		ac->state = ACPI_AC_STATUS_UNKNOWN;
+		return_VALUE(-ENODEV);
+	}
+	
+	return_VALUE(0);
+}
+
+
+/* --------------------------------------------------------------------------
+                              FS Interface (/proc)
+   -------------------------------------------------------------------------- */
+
+struct proc_dir_entry		*acpi_ac_dir = NULL;
+
+static int
+acpi_ac_read_state (
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	struct acpi_ac		*ac = (struct acpi_ac *) data;
+	char			*p = page;
+	int			len = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_ac_read_state");
+
+	if (!ac || (off != 0))
+		goto end;
+
+	if (acpi_ac_get_state(ac)) {
+		p += sprintf(p, "ERROR: Unable to read AC Adapter state\n");
+		goto end;
+	}
+
+	p += sprintf(p, "state:                   ");
+	switch (ac->state) {
+	case ACPI_AC_STATUS_OFFLINE:
+		p += sprintf(p, "off-line\n");
+		break;
+	case ACPI_AC_STATUS_ONLINE:
+		p += sprintf(p, "on-line\n");
+		break;
+	default:
+		p += sprintf(p, "unknown\n");
+		break;
+	}
+
+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);
+}
+
+
+static int
+acpi_ac_add_fs (
+	struct acpi_device	*device)
+{
+	struct proc_dir_entry	*entry = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_ac_add_fs");
+
+	if (!acpi_device_dir(device)) {
+		acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
+			acpi_ac_dir);
+		if (!acpi_device_dir(device))
+			return_VALUE(-ENODEV);
+	}
+
+	/* 'state' [R] */
+	entry = create_proc_entry(ACPI_AC_FILE_STATE,
+		S_IRUGO, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_AC_FILE_STATE));
+	else {
+		entry->read_proc = acpi_ac_read_state;
+		entry->data = acpi_driver_data(device);
+	}
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_ac_remove_fs (
+	struct acpi_device	*device)
+{
+	ACPI_FUNCTION_TRACE("acpi_ac_remove_fs");
+
+	if (acpi_device_dir(device)) {
+		remove_proc_entry(acpi_device_bid(device), acpi_ac_dir);
+		acpi_device_dir(device) = NULL;
+	}
+
+	return_VALUE(0);
+}
+
+
+/* --------------------------------------------------------------------------
+                                   Driver Model
+   -------------------------------------------------------------------------- */
+
+void
+acpi_ac_notify (
+	acpi_handle		handle,
+	u32			event,
+	void			*data)
+{
+	struct acpi_ac		*ac = (struct acpi_ac *) data;
+	struct acpi_device	*device = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_ac_notify");
+
+	if (!ac)
+		return;
+
+	if (acpi_bus_get_device(ac->handle, &device))
+		return_VOID;
+
+	switch (event) {
+	case ACPI_AC_NOTIFY_STATUS:
+		acpi_ac_get_state(ac);
+		acpi_bus_generate_event(device, event, (u32) ac->state);
+		break;
+	default:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+			"Unsupported event [0x%x]\n", event));
+		break;
+	}
+
+	return_VOID;
+}
+
+
+int
+acpi_ac_add (
+	struct acpi_device	*device)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	struct acpi_ac		*ac = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_ac_add");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	ac = kmalloc(sizeof(struct acpi_ac), GFP_KERNEL);
+	if (!ac)
+		return_VALUE(-ENOMEM);
+	memset(ac, 0, sizeof(struct acpi_ac));
+
+	ac->handle = device->handle;
+	sprintf(acpi_device_name(device), "%s", ACPI_AC_DEVICE_NAME);
+	sprintf(acpi_device_class(device), "%s", ACPI_AC_CLASS);
+	acpi_driver_data(device) = ac;
+
+	result = acpi_ac_get_state(ac);
+	if (result)
+		goto end;
+
+	result = acpi_ac_add_fs(device);
+	if (result)
+		goto end;
+
+	status = acpi_install_notify_handler(ac->handle,
+		ACPI_DEVICE_NOTIFY, acpi_ac_notify, ac);
+	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] (%s)\n", 
+		acpi_device_name(device), acpi_device_bid(device), 
+		ac->state?"on-line":"off-line");
+
+end:
+	if (result) {
+		acpi_ac_remove_fs(device);
+		kfree(ac);
+	}
+
+	return_VALUE(result);
+}
+
+
+int
+acpi_ac_remove (
+	struct acpi_device	*device,
+	int			type)
+{
+	acpi_status		status = AE_OK;
+	struct acpi_ac		*ac = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_ac_remove");
+
+	if (!device || !acpi_driver_data(device))
+		return_VALUE(-EINVAL);
+
+	ac = (struct acpi_ac *) acpi_driver_data(device);
+
+	status = acpi_remove_notify_handler(ac->handle,
+		ACPI_DEVICE_NOTIFY, acpi_ac_notify);
+	if (ACPI_FAILURE(status))
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Error removing notify handler\n"));
+
+	acpi_ac_remove_fs(device);
+
+	kfree(ac);
+
+	return_VALUE(0);
+}
+
+
+int __init
+acpi_ac_init (void)
+{
+	int			result = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_ac_init");
+
+	acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir);
+	if (!acpi_ac_dir)
+		return_VALUE(-ENODEV);
+
+	result = acpi_bus_register_driver(&acpi_ac_driver);
+	if (result < 0) {
+		remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
+		return_VALUE(-ENODEV);
+	}
+
+	return_VALUE(0);
+}
+
+
+void __exit
+acpi_ac_exit (void)
+{
+	ACPI_FUNCTION_TRACE("acpi_ac_exit");
+
+	acpi_bus_unregister_driver(&acpi_ac_driver);
+
+	remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
+
+	return_VOID;
+}
+
+
+module_init(acpi_ac_init);
+module_exit(acpi_ac_exit);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/acpi_ksyms.c linux-2.4.22-pre2/drivers/acpi/acpi_ksyms.c
--- linux-2.4.21/drivers/acpi/acpi_ksyms.c	2003-06-26 21:45:06.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/acpi_ksyms.c	2003-06-26 21:43:17.000000000 +0000
@@ -1,64 +1,56 @@
 /*
- *  ksyms.c - ACPI exported symbols
+ *  acpi_ksyms.c - ACPI Kernel Symbols ($Revision: 15 $)
  *
- *  Copyright (C) 2000 Andrew Grover
+ *  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.
+ *  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 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/init.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
 #include <linux/acpi.h>
-#include "acpi.h"
-#include "acdebug.h"
 
-extern int acpi_in_debugger;
-extern FADT_DESCRIPTOR acpi_fadt;
+#ifdef CONFIG_ACPI_INTERPRETER
 
-#define _COMPONENT	OS_DEPENDENT
-	MODULE_NAME	("symbols")
+/* ACPI Debugger */
 
 #ifdef ENABLE_DEBUGGER
+
+extern int			acpi_in_debugger;
+
 EXPORT_SYMBOL(acpi_in_debugger);
 EXPORT_SYMBOL(acpi_db_user_commands);
-#endif
 
-#ifdef ACPI_DEBUG
+#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
-
-EXPORT_SYMBOL(acpi_gbl_FADT);
-
-EXPORT_SYMBOL(acpi_os_free);
-EXPORT_SYMBOL(acpi_os_printf);
-EXPORT_SYMBOL(acpi_os_callocate);
-EXPORT_SYMBOL(acpi_os_sleep);
-EXPORT_SYMBOL(acpi_os_stall);
-EXPORT_SYMBOL(acpi_os_queue_for_execution);
-
-EXPORT_SYMBOL(acpi_dbg_layer);
-EXPORT_SYMBOL(acpi_dbg_level);
-
-EXPORT_SYMBOL(acpi_format_exception);
+#endif /*ACPI_DEBUG_OUTPUT*/
 
 EXPORT_SYMBOL(acpi_get_handle);
 EXPORT_SYMBOL(acpi_get_parent);
@@ -69,7 +61,6 @@
 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);
@@ -78,40 +69,89 @@
 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_enable_event);
 EXPORT_SYMBOL(acpi_disable_event);
 EXPORT_SYMBOL(acpi_clear_event);
-
 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_read_port);
-EXPORT_SYMBOL(acpi_os_write_port);
+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_hw_register_bit_access);
-EXPORT_SYMBOL(acpi_hw_obtain_sleep_type_register_data);
-EXPORT_SYMBOL(acpi_enter_sleep_state);
-EXPORT_SYMBOL(acpi_get_system_info);
-EXPORT_SYMBOL(acpi_leave_sleep_state);
 EXPORT_SYMBOL(acpi_walk_namespace);
-/*EXPORT_SYMBOL(acpi_save_state_mem);*/
-/*EXPORT_SYMBOL(acpi_save_state_disk);*/
-EXPORT_SYMBOL(acpi_hw_register_read);
-EXPORT_SYMBOL(acpi_set_firmware_waking_vector);
-EXPORT_SYMBOL(acpi_subsystem_status);
+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);
+EXPORT_SYMBOL(acpi_bus_scan);
+EXPORT_SYMBOL(acpi_init);
+
+#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);
+extern int acpi_pci_irq_lookup (int segment, int bus, int device, int pin);
+EXPORT_SYMBOL(acpi_pci_irq_lookup);
+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
 
-EXPORT_SYMBOL(acpi_os_signal);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/asus_acpi.c linux-2.4.22-pre2/drivers/acpi/asus_acpi.c
--- linux-2.4.21/drivers/acpi/asus_acpi.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/asus_acpi.c	2003-06-26 21:43:11.000000000 +0000
@@ -0,0 +1,952 @@
+/*
+ *  asus_acpi.c - Asus Laptop ACPI Extras
+ *
+ *
+ *  Copyright (C) 2002, 2003 Julien Lerouge, Karol Kozimor
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the 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
+ *
+ *
+ *  The development page for this driver is located at
+ *  http://sourceforge.net/projects/acpi4asus/
+ *
+ *  Credits:
+ *  Johann Wiesner - Small compile fixes
+ *  John Belmonte  - ACPI code for Toshiba laptop was a good starting point.
+ *
+ *  TODO
+ *  add Fn key status
+ *  Add mode selection on module loading (parameter) -> still necessary ?
+ *  Complete display switching -- may require dirty hacks?
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/proc_fs.h>
+#include <acpi/acpi_drivers.h>
+#include <acpi/acpi_bus.h>
+
+#define ASUS_ACPI_VERSION "0.24a"
+
+#define PROC_ASUS       "asus"	//the directory
+#define PROC_MLED       "mled"
+#define PROC_WLED       "wled"
+#define PROC_INFOS      "info"
+#define PROC_LCD        "lcd"
+#define PROC_BRN        "brn"
+#define PROC_DISP       "disp"
+
+#define ACPI_HOTK_NAME          "Asus Laptop ACPI Extras Driver"
+#define ACPI_HOTK_CLASS         "hotkey"
+#define ACPI_HOTK_DEVICE_NAME   "Hotkey"
+#define ACPI_HOTK_HID           "ATK0100"
+
+/*
+ * Some events we use, same for all Asus
+ */
+#define BR_UP       0x10      		
+#define BR_DOWN     0x20
+
+/*
+ * Flags for hotk status
+ */
+#define MLED_ON     0x01	//is MLED ON ?
+#define WLED_ON     0x02
+
+MODULE_AUTHOR("Julien Lerouge, Karol Kozimor");
+MODULE_DESCRIPTION(ACPI_HOTK_NAME);
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
+
+
+static uid_t asus_uid = 0;
+static gid_t asus_gid = 0;
+MODULE_PARM(asus_uid, "i");
+MODULE_PARM_DESC(uid, "UID for entries in /proc/acpi/asus.\n");
+MODULE_PARM(asus_gid, "i");
+MODULE_PARM_DESC(gid, "GID for entries in /proc/acpi/asus.\n");
+
+
+/* For each model, all features implemented */
+struct model_data {
+	char *name;		//name of the laptop
+	char *mt_mled;		//method to handle mled
+	char *mled_status;	//node to handle mled reading
+	char *mt_wled;		//method to handle wled
+	char *wled_status;	//node to handle wled reading
+	char *mt_lcd_switch;	//method to turn LCD ON/OFF
+	char *lcd_status;	//node to read LCD panel state
+	char *brightness_up;	//method to set brightness up
+	char *brightness_down;	//guess what ?
+	char *brightness_set;	//method to set absolute brightness
+	char *brightness_get;	//method to get absolute brightness
+	char *brightness_status;//node to get brightness
+	char *display_set;	//method to set video output
+	char *display_get;	//method to get video output
+};
+
+/*
+ * This is the main structure, we can use it to store anything interesting
+ * about the hotk device
+ */
+struct asus_hotk {
+	struct acpi_device *device;	//the device we are in
+	acpi_handle handle;		//the handle of the hotk device
+	char status;			//status of the hotk, for LEDs, ...
+	struct model_data *methods;	//methods available on the laptop
+	u8 brightness;			//brighness level
+	enum {
+		L2X = 0,	//L200D -> TODO check Q11 (Fn+F8)
+				//	   Calling this method simply hang the
+				//	   computer, ISMI method hangs the laptop.
+		L3X,		//L3C
+		L3D,		//L3400D
+		M2X,		//M2400E
+		S1X,		//S1300A -> TODO special keys do not work ?
+		D1X,		//D1
+		L1X,		//L1400B
+		A1X, 		//A1340D, A1300F
+		J1X,		//S200 (J1)
+				//TODO  A1370D does not seems to have a ATK device 
+				//	L8400 model doesn't have ATK
+		END_MODEL,
+	} model;		//Models currently supported
+	u16 event_count[128];	//count for each event TODO make this better
+};
+
+/* Here we go */
+#define L3X_PREFIX "\\_SB.PCI0.PX40.ECD0."
+#define S1X_PREFIX "\\_SB.PCI0.PX40."
+#define L1X_PREFIX S1X_PREFIX
+#define A1X_PREFIX "\\_SB.PCI0.ISA.EC0."
+#define J1X_PREFIX A1X_PREFIX
+
+static struct model_data model_conf[END_MODEL] = {
+        /*
+	 * name|  mled |mled read|  wled |wled read| lcd sw |lcd read | 
+	 * br up|br down | br set | br read | br status|set disp | get disp
+	 *
+	 * br set and read shall be in hotk device !
+	 * same for set disp
+	 *
+	 * TODO I have seen a SWBX and AIBX method on some models, like L1400B,
+	 * it seems to be a kind of switch, but what for ?
+	 *
+	 */
+	{"L2X", "MLED", "\\SGP6", "WLED", "\\RCP3", "\\Q10", "\\SGP0", 
+	 "\\Q0E", "\\Q0F", NULL, NULL, NULL, "SDSP", "\\INFB"},
+
+	{"L3X", "MLED", NULL, "WLED", NULL, L3X_PREFIX "_Q10", "\\GL32", 
+	 L3X_PREFIX "_Q0F", L3X_PREFIX "_Q0E", "SPLV", "GPLV", "\\BLVL", "SDSP", 
+	 "\\_SB.PCI0.PCI1.VGAC.NMAP"},
+
+	{"L3D", "MLED", "\\MALD", "WLED", NULL, "\\Q10", "\\BKLG",
+	 "\\Q0E", "\\Q0F", "SPLV", "GPLV", "\\BLVL", "SDSP", "\\INFB"},
+
+	{"M2X", "MLED", NULL, "WLED", NULL, "\\Q10", "\\GP06", 
+	 "\\Q0E","\\Q0F", "SPLV", "GPLV", NULL, "SDSP", "\\INFB"},
+	
+	{"S1X", "MLED", "\\EMLE", "WLED", NULL, S1X_PREFIX "Q10", "\\PNOF", 
+	 S1X_PREFIX "Q0F", S1X_PREFIX "Q0E", "SPLV", "GPLV", "\\BRIT", NULL, NULL},
+	
+	{"D1X", "MLED", NULL, NULL, NULL, "\\Q0D", "\\GP11", 
+	 "\\Q0C", "\\Q0B", NULL, NULL, "\\BLVL", "SDSP","\\INFB"},
+
+	{"L1X", "MLED", NULL, "WLED", NULL, L1X_PREFIX "Q10", "\\PNOF", 
+	 L1X_PREFIX "Q0F", L1X_PREFIX "Q0E", "SPLV", "GPLV", "\\BRIT", NULL, NULL},
+
+	{"A1X", "MLED", "\\MAIL", NULL, NULL, A1X_PREFIX "_Q10", "\\BKLI",
+	 A1X_PREFIX "_Q0E", A1X_PREFIX "_Q0F", NULL, NULL, NULL, NULL, NULL},
+
+	{"J1X", "MLED", "\\MAIL", NULL, NULL, J1X_PREFIX "_Q10", "\\BKLI",
+	 J1X_PREFIX "_Q0B", J1X_PREFIX "_Q0A", NULL, NULL, NULL, NULL, NULL}
+};
+
+/* procdir we use */
+static struct proc_dir_entry *asus_proc_dir = NULL;
+
+/*
+ * This header is made available to allow proper configuration given model,
+ * revision number , ... this info cannot go in struct asus_hotk because it is
+ * available before the hotk
+ */
+static struct acpi_table_header *asus_info = NULL;
+
+/*
+ * The hotkey driver declaration
+ */
+static int asus_hotk_add(struct acpi_device *device);
+static int asus_hotk_remove(struct acpi_device *device, int type);
+static struct acpi_driver asus_hotk_driver = {
+	.name = 	ACPI_HOTK_NAME,
+	.class = 	ACPI_HOTK_CLASS,
+	.ids = 		ACPI_HOTK_HID,
+	.ops = 		{
+				.add = 		asus_hotk_add,
+				.remove = 	asus_hotk_remove,
+			},
+};
+
+/* 
+ * This function evaluates an ACPI method, given an int as parameter, the
+ * method is searched within the scope of the handle, can be NULL. The output
+ * of the method is written is output, which can also be NULL
+ *
+ * returns 1 if write is successful, 0 else. 
+ */
+static int write_acpi_int(acpi_handle handle, const char *method, int val,
+			  struct acpi_buffer *output)
+{
+	struct acpi_object_list params;	//list of input parameters (an int here)
+	union acpi_object in_obj;	//the only param we use
+	acpi_status status;
+
+	params.count = 1;
+	params.pointer = &in_obj;
+	in_obj.type = ACPI_TYPE_INTEGER;
+	in_obj.integer.value = val;
+
+	status = acpi_evaluate_object(handle, (char *) method, &params, output);
+	return (status == AE_OK);
+}
+
+
+static int read_acpi_int(acpi_handle handle, const char *method, int *val)
+{
+	struct acpi_buffer output;
+	union acpi_object out_obj;
+	acpi_status status;
+
+	output.length = sizeof(out_obj);
+	output.pointer = &out_obj;
+
+	status = acpi_evaluate_object(handle, (char*) method, NULL, &output);
+	*val = out_obj.integer.value;
+	return (status == AE_OK) && (out_obj.type == ACPI_TYPE_INTEGER);
+}
+
+/*
+ * We write our info in page, we begin at offset off and cannot write more
+ * than count bytes. We set eof to 1 if we handle those 2 values. We return the
+ * number of bytes written in page
+ */
+static int
+proc_read_info(char *page, char **start, off_t off, int count, int *eof,
+		void *data)
+{
+	int len = 0;
+	struct asus_hotk *hotk = (struct asus_hotk *) data;
+	char buf[16];		//enough for all info
+	/*
+	 * We use the easy way, we don't care of off and count, so we don't set eof
+	 * to 1
+	 */
+
+	len += sprintf(page, ACPI_HOTK_NAME " " ASUS_ACPI_VERSION "\n");
+	len +=
+	    sprintf(page + len, "Model reference    : %s\n",
+		    hotk->methods->name);
+	if (asus_info) {
+		snprintf(buf, 5, "%s", asus_info->signature);
+		len += sprintf(page + len, "ACPI signature     : %s\n", buf);
+		snprintf(buf, 16, "%d", asus_info->length);
+		len += sprintf(page + len, "Table length       : %s\n", buf);
+		snprintf(buf, 16, "%d", asus_info->revision);
+		len += sprintf(page + len, "ACPI minor version : %s\n", buf);
+		snprintf(buf, 16, "%d", asus_info->checksum);
+		len += sprintf(page + len, "Checksum           : %s\n", buf);
+		snprintf(buf, 7, "%s", asus_info->oem_id);
+		len += sprintf(page + len, "OEM identification : %s\n", buf);
+		snprintf(buf, 9, "%s", asus_info->oem_table_id);
+		len += sprintf(page + len, "OEM table id       : %s\n", buf);
+		snprintf(buf, 16, "%x", asus_info->oem_revision);
+		len += sprintf(page + len, "OEM rev number     : 0x%s\n", buf);
+		snprintf(buf, 5, "%s", asus_info->asl_compiler_id);
+		len += sprintf(page + len, "ASL comp vendor ID : %s\n", buf);
+		snprintf(buf, 16, "%x", asus_info->asl_compiler_revision);
+		len += sprintf(page + len, "ASL comp rev number: 0x%s\n", buf);
+	}
+
+	return len;
+}
+
+
+/* 
+ * proc file handlers
+ */
+static int
+proc_read_mled(char *page, char **start, off_t off, int count, int *eof,
+	       void *data)
+{
+	int len = 0;
+	struct asus_hotk *hotk = (struct asus_hotk *) data;
+	int led_status = 0;
+	/*
+	 * We use the easy way, we don't care of off and count, so we don't set eof
+	 * to 1
+	 */
+	if (hotk->methods->mled_status) {
+		if (read_acpi_int(NULL, hotk->methods->mled_status, 
+				  &led_status))
+			len =  sprintf(page, "%d\n", led_status);
+		else
+			printk(KERN_NOTICE "Asus ACPI: Error reading MLED "
+			       "status\n");
+	} else {
+		len = sprintf(page, "%d\n", (hotk->status & MLED_ON) ? 1 : 0);
+	}
+
+	return len;
+}
+
+
+static int
+proc_write_mled(struct file *file, const char *buffer,
+		unsigned long count, void *data)
+{
+	int value;
+	int led_out = 0;
+	struct asus_hotk *hotk = (struct asus_hotk *) data;
+
+
+
+	/* scan expression.  Multiple expressions may be delimited with ; */
+	if (sscanf(buffer, "%i", &value) == 1)
+		led_out = ~value & 1;
+
+	hotk->status =
+	    (value) ? (hotk->status | MLED_ON) : (hotk->status & ~MLED_ON);
+
+	/* We don't have to check mt_mled exists if we are here :) */
+	if (!write_acpi_int(hotk->handle, hotk->methods->mt_mled, led_out,
+			    NULL))
+		printk(KERN_NOTICE "Asus ACPI: MLED write failed\n");
+
+
+
+	return count;
+}
+
+/*
+ * We write our info in page, we begin at offset off and cannot write more
+ * than count bytes. We set eof to 1 if we handle those 2 values. We return the
+ * number of bytes written in page
+ */
+static int
+proc_read_wled(char *page, char **start, off_t off, int count, int *eof,
+	       void *data)
+{
+	int len = 0;
+	struct asus_hotk *hotk = (struct asus_hotk *) data;
+	int led_status;
+
+	if (hotk->methods->wled_status) {
+		if (read_acpi_int(NULL, hotk->methods->mled_status, 
+				  &led_status))
+			len = sprintf(page, "%d\n", led_status);
+		else
+			printk(KERN_NOTICE "Asus ACPI: Error reading WLED "
+			       "status\n");
+	} else {
+		len = sprintf(page, "%d\n", (hotk->status & WLED_ON) ? 1 : 0);
+	}
+
+	return len;
+}
+
+static int
+proc_write_wled(struct file *file, const char *buffer,
+		unsigned long count, void *data)
+{
+	int value;
+	int led_out = 0;
+	struct asus_hotk *hotk = (struct asus_hotk *) data;
+
+	/* scan expression.  Multiple expressions may be delimited with ; */
+	if (sscanf(buffer, "%i", &value) == 1)
+		led_out = value & 1;
+
+	hotk->status =
+	    (value) ? (hotk->status | WLED_ON) : (hotk->status & ~WLED_ON);
+
+	/* We don't have to check if mt_wled exists if we are here :) */
+	if (!write_acpi_int(hotk->handle, hotk->methods->mt_wled, led_out,
+			    NULL))
+		printk(KERN_NOTICE "Asus ACPI: WLED write failed\n");
+
+
+	return count;
+}
+
+
+static int get_lcd_state(struct asus_hotk *hotk)
+{
+	int lcd = 0;
+
+	/* We don't have to check anything, if we are here */
+	if (!read_acpi_int(NULL, hotk->methods->lcd_status, &lcd))
+		printk(KERN_NOTICE "Asus ACPI: Error reading LCD status\n");
+	
+	if (hotk->model == L2X)
+		lcd = ~lcd;
+	
+	return (lcd & 1);
+}
+
+
+static int
+proc_read_lcd(char *page, char **start, off_t off, int count, int *eof,
+	      void *data)
+{
+	return sprintf(page, "%d\n", get_lcd_state((struct asus_hotk *) data));
+}
+
+
+static int
+proc_write_lcd(struct file *file, const char *buffer,
+	       unsigned long count, void *data)
+{
+	int value;
+	int lcd = 0;
+	acpi_status status = 0;
+	int lcd_status = 0;
+	struct asus_hotk *hotk = (struct asus_hotk *) data;
+
+	/* scan expression.  Multiple expressions may be delimited with ; */
+	if (sscanf(buffer, "%i", &value) == 1)
+		lcd = value & 1;
+
+	lcd_status = get_lcd_state(hotk);
+
+	if (lcd_status != lcd) {
+		/* switch */
+		status =
+		    acpi_evaluate_object(NULL, hotk->methods->mt_lcd_switch,
+					 NULL, NULL);
+		if (ACPI_FAILURE(status))
+			printk(KERN_NOTICE "Asus ACPI: Error switching LCD\n");
+	}
+
+	return count;
+}
+
+
+/*
+ * Change the brightness level
+ */
+static void set_brightness(int value, struct asus_hotk *hotk)
+{
+	acpi_status status = 0;
+
+	/* ATKD laptop */
+	if(hotk->methods->brightness_set) {
+		if (!write_acpi_int(hotk->handle, hotk->methods->brightness_set, 
+				    value, NULL))
+			printk(KERN_NOTICE "Asus ACPI: Error changing brightness\n");
+		return;
+	}
+
+	/* HOTK laptop if we are here, act as appropriate */
+	value -= hotk->brightness;
+	while (value != 0) {
+		status = acpi_evaluate_object(NULL, (value > 0) ? 
+					      hotk->methods->brightness_up : 
+					      hotk->methods->brightness_down,
+					      NULL, NULL);
+		(value > 0) ? value-- : value++;
+		if (ACPI_FAILURE(status))
+			printk(KERN_NOTICE "Asus ACPI: Error changing brightness\n");
+	}
+	return;
+}
+
+static int read_brightness(struct asus_hotk *hotk)
+{
+	int value;
+	
+	if(hotk->methods->brightness_get) { /* ATKD laptop */
+		if (!read_acpi_int(hotk->handle, hotk->methods->brightness_get, 
+				   &value))
+			printk(KERN_NOTICE "Asus ACPI: Error reading brightness\n");
+	} else if (hotk->methods->brightness_status) { /* For D1 for example */
+		if (!read_acpi_int(NULL, hotk->methods->brightness_status, 
+				   &value))
+			printk(KERN_NOTICE "Asus ACPI: Error reading brightness\n");
+	} else /* HOTK laptop */
+		value = hotk->brightness;
+	return value;
+}
+
+static int
+proc_read_brn(char *page, char **start, off_t off, int count, int *eof,
+	      void *data)
+{
+	struct asus_hotk *hotk = (struct asus_hotk *) data;
+	return sprintf(page, "%d\n", read_brightness(hotk));
+}
+
+static int
+proc_write_brn(struct file *file, const char *buffer,
+	       unsigned long count, void *data)
+{
+	int value;
+	struct asus_hotk *hotk = (struct asus_hotk *) data;
+
+	/* scan expression.  Multiple expressions may be delimited with ; */
+	if (sscanf(buffer, "%d", &value) == 1) {
+		value = (0 < value) ? ((15 < value) ? 15 : value) : 0;
+			/* 0 <= value <= 15 */
+		set_brightness(value, hotk);
+	} else {
+		printk(KERN_NOTICE "Asus ACPI: Error reading user input\n");
+	}
+
+	return count;
+}
+
+static void set_display(int value, struct asus_hotk *hotk)
+{
+	/* no sanity check needed for now */
+	if (!write_acpi_int(hotk->handle, hotk->methods->display_set, 
+			    value, NULL))
+		printk(KERN_NOTICE "Asus ACPI: Error setting display\n");
+	return;
+}
+
+/*
+ * Now, *this* one could be more user-friendly, but so far, no-one has 
+ * complained. The significance of bits is the same as in proc_write_disp()
+ */
+
+static int
+proc_read_disp(char *page, char **start, off_t off, int count, int *eof,
+	      void *data)
+{
+	int value = 0;
+	struct asus_hotk *hotk = (struct asus_hotk *) data;
+	
+	if (!read_acpi_int(hotk->handle, hotk->methods->display_get, &value))
+		printk(KERN_NOTICE "Asus ACPI: Error reading display status\n");
+	return sprintf(page, "%d\n", value);
+}
+
+/*
+ * Preliminary support for display switching. As of now: 0x01 should activate 
+ * the LCD output, 0x02 should do for CRT, and 0x04 for TV-Out. Any combination 
+ * (bitwise) of these will suffice. I never actually tested 3 displays hooked up 
+ * simultaneously, so be warned.
+ */
+
+static int
+proc_write_disp(struct file *file, const char *buffer,
+	       unsigned long count, void *data)
+{
+	int value;
+	struct asus_hotk *hotk = (struct asus_hotk *) data;
+
+	/* scan expression.  Multiple expressions may be delimited with ; */
+	if (sscanf(buffer, "%d", &value) == 1)
+		set_display(value, hotk);
+	else {
+		printk(KERN_NOTICE "Asus ACPI: Error reading user input\n");
+	}
+
+	return count;
+}
+
+static int asus_hotk_add_fs(struct acpi_device *device)
+{
+	struct proc_dir_entry *proc;
+	struct asus_hotk *hotk = acpi_driver_data(device);
+	mode_t mode;
+	
+	/*
+	 * If parameter uid or gid is not changed, keep the default setting for
+	 * our proc entries (-rw-rw-rw-) else, it means we care about security,
+	 * and then set to -rw-rw----
+	 */
+
+	if ((asus_uid == 0) && (asus_gid == 0)){
+		mode = S_IFREG | S_IRUGO | S_IWUGO;
+	}else{
+		mode = S_IFREG | S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP;
+	}
+
+	acpi_device_dir(device) = asus_proc_dir;
+	if (!acpi_device_dir(device))
+		return(-ENODEV);
+
+	proc = create_proc_entry(PROC_INFOS, mode, acpi_device_dir(device));
+	if (proc) {
+		proc->read_proc = proc_read_info;
+		proc->data = acpi_driver_data(device);
+		proc->owner = THIS_MODULE;
+		proc->uid = asus_uid;
+		proc->gid = asus_gid;;
+	} else {
+		printk(KERN_NOTICE "  Unable to create " PROC_INFOS
+		       " fs entry\n");
+	}
+
+	if (hotk->methods->mt_wled) {
+		proc = create_proc_entry(PROC_WLED, mode, acpi_device_dir(device));
+		if (proc) {
+			proc->write_proc = proc_write_wled;
+			proc->read_proc = proc_read_wled;
+			proc->data = acpi_driver_data(device);
+			proc->owner = THIS_MODULE;
+			proc->uid = asus_uid;
+			proc->gid = asus_gid;;
+		} else {
+			printk(KERN_NOTICE "  Unable to create " PROC_WLED
+			       " fs entry\n");
+		}
+	}
+
+	if (hotk->methods->mt_mled) {
+		proc = create_proc_entry(PROC_MLED, mode, acpi_device_dir(device));
+		if (proc) {
+			proc->write_proc = proc_write_mled;
+			proc->read_proc = proc_read_mled;
+			proc->data = acpi_driver_data(device);
+			proc->owner = THIS_MODULE;
+			proc->uid = asus_uid;
+			proc->gid = asus_gid;;
+		} else {
+			printk(KERN_NOTICE "  Unable to create " PROC_MLED
+			       " fs entry\n");
+		}
+	}
+
+	/* 
+	 * We need both read node and write method as LCD switch is also accessible
+	 * from keyboard 
+	 */
+	if (hotk->methods->mt_lcd_switch && hotk->methods->lcd_status) {
+		proc = create_proc_entry(PROC_LCD, mode, acpi_device_dir(device));
+		if (proc) {
+			proc->write_proc = proc_write_lcd;
+			proc->read_proc = proc_read_lcd;
+			proc->data = acpi_driver_data(device);
+			proc->owner = THIS_MODULE;
+			proc->uid = asus_uid;
+			proc->gid = asus_gid;;
+		} else {
+			printk(KERN_NOTICE "  Unable to create " PROC_LCD
+			       " fs entry\n");
+		}
+	}
+	
+	if ((hotk->methods->brightness_up && hotk->methods->brightness_down) ||
+	    (hotk->methods->brightness_get && hotk->methods->brightness_get)) {
+		proc = create_proc_entry(PROC_BRN, mode, acpi_device_dir(device));
+		if (proc) {
+			proc->write_proc = proc_write_brn;
+			proc->read_proc = proc_read_brn;
+			proc->data = acpi_driver_data(device);
+			proc->owner = THIS_MODULE;
+			proc->uid = asus_uid;
+			proc->gid = asus_gid;;
+		} else {
+			printk(KERN_NOTICE "  Unable to create " PROC_BRN
+			       " fs entry\n");
+		}
+	}
+
+	if (hotk->methods->display_set) {
+		proc = create_proc_entry(PROC_DISP, mode, acpi_device_dir(device));
+		if (proc) {
+			proc->write_proc = proc_write_disp;
+			proc->read_proc = proc_read_disp;
+			proc->data = acpi_driver_data(device);
+			proc->owner = THIS_MODULE;
+			proc->uid = asus_uid;
+			proc->gid = asus_gid;;
+		} else {
+			printk(KERN_NOTICE "  Unable to create " PROC_DISP
+			       " fs entry\n");
+		}
+	}
+
+	return (AE_OK);
+}
+
+
+static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
+{
+	/* TODO Find a better way to handle events count. Here, in data, we receive
+	 * the hotk, so we can make anything !!
+	 */
+	struct asus_hotk *hotk = (struct asus_hotk *) data;
+
+	if (!hotk)
+		return;
+
+	if ((event & ~((u32) BR_UP)) < 16) {
+		hotk->brightness = (event & ~((u32) BR_UP));
+	} else if ((event & ~((u32) BR_DOWN)) < 16 ) {
+		hotk->brightness = (event & ~((u32) BR_DOWN));
+	}
+
+	acpi_bus_generate_event(hotk->device, event,
+				hotk->event_count[event % 128]++);
+
+	return;
+}
+
+/*
+ * This function is used to initialize the hotk with right values. In this
+ * method, we can make all the detection we want, and modify the hotk struct
+ */
+static int asus_hotk_get_info(struct asus_hotk *hotk)
+{
+	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+	union acpi_object *model = NULL;
+
+	/* 
+	 * We have to write 0 on init this far for all ASUS models
+	 */
+	if (!write_acpi_int(hotk->handle, "INIT", 0, &buffer)) {
+		printk(KERN_NOTICE "  Hotkey initialization failed\n");
+		return -ENODEV;
+	}
+
+	/*
+	 * Here, we also use asus_info to make decision. For example, on INIT
+	 * method, S1X and L1X models both reports to be L84F, but they don't
+	 * have the same methods (L1X has WLED, S1X don't)
+	 */
+	model = (union acpi_object *) buffer.pointer;
+	if (model->type == ACPI_TYPE_STRING) {
+		printk(KERN_NOTICE "  %s model detected, ", model->string.pointer);
+	}
+
+	hotk->model = END_MODEL;
+	if (strncmp(model->string.pointer, "L3D", 3) == 0)
+		hotk->model = L3D;
+		/*
+		 * L2B has same settings that L3X, except for GL32, but as
+		 * there is no node to get the LCD status, and as GL32 is never
+		 * used anywhere else, I assume it's safe, even if lcd get is
+		 * broken for this model (TODO fix it ?)
+		 */
+	else if (strncmp(model->string.pointer, "L3", 2) == 0 ||
+		 strncmp(model->string.pointer, "L2B", 3) == 0)
+		hotk->model = L3X;
+	else if (strncmp(model->string.pointer, "M2", 2) == 0)
+		hotk->model = M2X;
+	else if (strncmp(model->string.pointer, "L2", 2) == 0)
+		hotk->model = L2X;
+	else if (strncmp(model->string.pointer, "L8", 2) == 0)
+		/* S1300A reports L84F, but L1400B too */
+		if (strncmp(asus_info->oem_table_id, "L1", 2) == 0)
+			hotk->model = L1X;
+		else
+			hotk->model = S1X;
+	else if (strncmp(model->string.pointer, "D1", 2) == 0)
+		hotk->model = D1X;
+	else if (strncmp(model->string.pointer, "A1", 2) == 0)
+		hotk->model = A1X;
+	else if (strncmp(model->string.pointer, "J1", 2) == 0)
+		hotk->model = J1X;
+
+
+	if (hotk->model == END_MODEL) {
+		/* By default use the same values, as I don't know others */
+		printk("unsupported, trying default values, contact the "
+		       "developers\n");
+		hotk->model = L2X;
+	} else {
+		printk("supported\n");
+	}
+
+	hotk->methods = &model_conf[hotk->model];
+
+	acpi_os_free(model);
+
+	return AE_OK;
+}
+
+
+
+static int asus_hotk_check(struct asus_hotk *hotk)
+{
+	int result = 0;
+
+	if (!hotk)
+		return(-EINVAL);
+
+	result = acpi_bus_get_status(hotk->device);
+	if (result)
+		return(result);
+
+	if (hotk->device->status.present) {
+		result = asus_hotk_get_info(hotk);
+	} else {
+		printk(KERN_NOTICE "  Hotkey device not present, aborting\n");
+		return(-EINVAL);
+	}
+
+	return(result);
+}
+
+
+
+static int asus_hotk_add(struct acpi_device *device)
+{
+	struct asus_hotk *hotk = NULL;
+	acpi_status status = AE_OK;
+	int result;
+
+	if (!device)
+		return(-EINVAL);
+
+	hotk =
+	    (struct asus_hotk *) kmalloc(sizeof(struct asus_hotk), GFP_KERNEL);
+	if (!hotk)
+		return(-ENOMEM);
+	memset(hotk, 0, sizeof(struct asus_hotk));
+
+	hotk->handle = device->handle;
+	sprintf(acpi_device_name(device), "%s", ACPI_HOTK_DEVICE_NAME);
+	sprintf(acpi_device_class(device), "%s", ACPI_HOTK_CLASS);
+	acpi_driver_data(device) = hotk;
+	hotk->device = device;
+
+
+	result = asus_hotk_check(hotk);
+	if (result)
+		goto end;
+
+	result = asus_hotk_add_fs(device);
+	if (result)
+		goto end;
+
+	/*
+	 * We install the handler, it will receive the hotk in parameter, so, we
+	 * could add other data to the hotk struct
+	 */
+	status = acpi_install_notify_handler(hotk->handle, ACPI_SYSTEM_NOTIFY,
+					     asus_hotk_notify, hotk);
+	if (ACPI_FAILURE(status)) {
+		printk(KERN_NOTICE
+		       "  Error installing notify handler\n");
+	} else {
+		printk(KERN_DEBUG
+		       "  Notify Handler installed successfully\n");
+	}
+
+	/* For HOTK laptops: init the hotk->brightness value */
+	if ((!hotk->methods->brightness_get) && (!hotk->methods->brightness_status) &&
+	    (hotk->methods->brightness_up && hotk->methods->brightness_down)) {
+		status = acpi_evaluate_object(NULL, hotk->methods->brightness_down,
+					      NULL, NULL);
+		if (ACPI_FAILURE(status))
+			printk(KERN_NOTICE "  Error changing brightness\n");
+		status = acpi_evaluate_object(NULL, hotk->methods->brightness_up,
+					      NULL, NULL);
+		if (ACPI_FAILURE(status))
+			printk(KERN_NOTICE "  Error changing brightness\n");
+	}
+
+      end:
+	if (result) {
+		kfree(hotk);
+	}
+
+	return(result);
+}
+
+
+
+
+static int asus_hotk_remove(struct acpi_device *device, int type)
+{
+	acpi_status status = 0;
+	struct asus_hotk *hotk = NULL;
+
+	if (!device || !acpi_driver_data(device))
+		return(-EINVAL);
+
+	hotk = (struct asus_hotk *) acpi_driver_data(device);
+
+	status = acpi_remove_notify_handler(hotk->handle, ACPI_SYSTEM_NOTIFY,
+					    asus_hotk_notify);
+	if (ACPI_FAILURE(status))
+		printk(KERN_NOTICE "Error removing notify handler\n");
+
+	kfree(hotk);
+
+	return(0);
+}
+
+
+
+
+static int __init asus_acpi_init(void)
+{
+	int result = 0;
+	acpi_status status = 0;
+	struct acpi_buffer dsdt = { ACPI_ALLOCATE_BUFFER, NULL };
+
+	printk(KERN_NOTICE "Asus Laptop ACPI Extras version %s\n",
+	       ASUS_ACPI_VERSION);
+	/*
+	 * Here is the code to know the model we are running on. We need to
+	 * know this before calling the acpi_bus_register_driver function, in
+	 * case the HID for the laptop we are running on is different from
+	 * ACPI_HOTK_HID, which I have never seen yet :)
+	 * 
+	 * This information is then available in the global var asus_info
+	 */
+	status = acpi_get_table(ACPI_TABLE_DSDT, 1, &dsdt);
+	if (ACPI_FAILURE(status)) {
+		printk(KERN_NOTICE "  Couldn't get the DSDT table header\n");
+	} else {
+		asus_info = (struct acpi_table_header *) dsdt.pointer;
+	}
+
+	asus_proc_dir = proc_mkdir(PROC_ASUS, acpi_root_dir);
+	if (!asus_proc_dir)
+		return(-ENODEV);
+	asus_proc_dir->owner = THIS_MODULE;
+
+	result = acpi_bus_register_driver(&asus_hotk_driver);
+	if (result < 0) {
+		printk(KERN_NOTICE "  Error registering " ACPI_HOTK_NAME " \n");
+		remove_proc_entry(PROC_ASUS, acpi_root_dir);
+		return(-ENODEV);
+	}
+
+	return(0);
+}
+
+
+
+static void __exit asus_acpi_exit(void)
+{
+	acpi_bus_unregister_driver(&asus_hotk_driver);
+	remove_proc_entry(PROC_ASUS, acpi_root_dir);
+
+	acpi_os_free(asus_info);
+
+	return;
+}
+
+module_init(asus_acpi_init);
+module_exit(asus_acpi_exit);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/battery.c linux-2.4.22-pre2/drivers/acpi/battery.c
--- linux-2.4.21/drivers/acpi/battery.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/battery.c	2003-06-26 21:43:30.000000000 +0000
@@ -0,0 +1,825 @@
+/*
+ *  acpi_battery.c - ACPI Battery Driver ($Revision: 36 $)
+ *
+ *  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/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/compatmac.h>
+#include <linux/proc_fs.h>
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+
+
+#define _COMPONENT		ACPI_BATTERY_COMPONENT
+ACPI_MODULE_NAME		("acpi_battery")
+
+MODULE_AUTHOR("Paul Diefenbaugh");
+MODULE_DESCRIPTION(ACPI_BATTERY_DRIVER_NAME);
+MODULE_LICENSE("GPL");
+
+#define PREFIX			"ACPI: "
+
+
+#define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF
+
+#define ACPI_BATTERY_FORMAT_BIF	"NNNNNNNNNSSSS"
+#define ACPI_BATTERY_FORMAT_BST	"NNNN"
+
+static int acpi_battery_add (struct acpi_device *device);
+static int acpi_battery_remove (struct acpi_device *device, int type);
+
+static struct acpi_driver acpi_battery_driver = {
+	.name =		ACPI_BATTERY_DRIVER_NAME,
+	.class =	ACPI_BATTERY_CLASS,
+	.ids =		ACPI_BATTERY_HID,
+	.ops =		{
+				.add =		acpi_battery_add,
+				.remove =	acpi_battery_remove,
+			},
+};
+
+struct acpi_battery_status {
+	acpi_integer		state;
+	acpi_integer		present_rate;
+	acpi_integer		remaining_capacity;
+	acpi_integer		present_voltage;
+};
+
+struct acpi_battery_info {
+	acpi_integer		power_unit;
+	acpi_integer		design_capacity;
+	acpi_integer		last_full_capacity;
+	acpi_integer		battery_technology;
+	acpi_integer		design_voltage;
+	acpi_integer		design_capacity_warning;
+	acpi_integer		design_capacity_low;
+	acpi_integer		battery_capacity_granularity_1;
+	acpi_integer		battery_capacity_granularity_2;
+	acpi_string		model_number;
+	acpi_string		serial_number;
+	acpi_string		battery_type;
+	acpi_string		oem_info;
+};
+
+struct acpi_battery_flags {
+	u8			present:1;	/* Bay occupied? */
+	u8			power_unit:1;	/* 0=watts, 1=apms */
+	u8			alarm:1;	/* _BTP present? */
+	u8			reserved:5;
+};
+
+struct acpi_battery_trips {
+	unsigned long		warning;
+	unsigned long		low;
+};
+
+struct acpi_battery {
+	acpi_handle		handle;
+	struct acpi_battery_flags flags;
+	struct acpi_battery_trips trips;
+	unsigned long		alarm;
+	struct acpi_battery_info *info;
+};
+
+
+/* --------------------------------------------------------------------------
+                               Battery Management
+   -------------------------------------------------------------------------- */
+
+static int
+acpi_battery_get_info (
+	struct acpi_battery	*battery,
+	struct acpi_battery_info **bif)
+{
+	int			result = 0;
+	acpi_status 		status = 0;
+	struct acpi_buffer	buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+	struct acpi_buffer	format = {sizeof(ACPI_BATTERY_FORMAT_BIF),
+						ACPI_BATTERY_FORMAT_BIF};
+	struct acpi_buffer	data = {0, NULL};
+	union acpi_object	*package = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_battery_get_info");
+
+	if (!battery || !bif)
+		return_VALUE(-EINVAL);
+
+	/* Evalute _BIF */
+
+	status = acpi_evaluate_object(battery->handle, "_BIF", NULL, &buffer);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BIF\n"));
+		return_VALUE(-ENODEV);
+	}
+
+	package = (union acpi_object *) buffer.pointer;
+
+	/* Extract Package Data */
+
+	status = acpi_extract_package(package, &format, &data);
+	if (status != AE_BUFFER_OVERFLOW) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BIF\n"));
+		result = -ENODEV;
+		goto end;
+	}
+
+	data.pointer = kmalloc(data.length, GFP_KERNEL);
+	if (!data.pointer) {
+		result = -ENOMEM;
+		goto end;
+	}
+	memset(data.pointer, 0, data.length);
+
+	status = acpi_extract_package(package, &format, &data);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BIF\n"));
+		kfree(data.pointer);
+		result = -ENODEV;
+		goto end;
+	}
+
+end:
+	acpi_os_free(buffer.pointer);
+
+	if (!result)
+		(*bif) = (struct acpi_battery_info *) data.pointer;
+
+	return_VALUE(result);
+}
+
+static int
+acpi_battery_get_status (
+	struct acpi_battery	*battery,
+	struct acpi_battery_status **bst)
+{
+	int			result = 0;
+	acpi_status 		status = 0;
+	struct acpi_buffer	buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+	struct acpi_buffer	format = {sizeof(ACPI_BATTERY_FORMAT_BST),
+						ACPI_BATTERY_FORMAT_BST};
+	struct acpi_buffer	data = {0, NULL};
+	union acpi_object	*package = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_battery_get_status");
+
+	if (!battery || !bst)
+		return_VALUE(-EINVAL);
+
+	/* Evalute _BST */
+
+	status = acpi_evaluate_object(battery->handle, "_BST", NULL, &buffer);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BST\n"));
+		return_VALUE(-ENODEV);
+	}
+
+	package = (union acpi_object *) buffer.pointer;
+
+	/* Extract Package Data */
+
+	status = acpi_extract_package(package, &format, &data);
+	if (status != AE_BUFFER_OVERFLOW) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BST\n"));
+		result = -ENODEV;
+		goto end;
+	}
+
+	data.pointer = kmalloc(data.length, GFP_KERNEL);
+	if (!data.pointer) {
+		result = -ENOMEM;
+		goto end;
+	}
+	memset(data.pointer, 0, data.length);
+
+	status = acpi_extract_package(package, &format, &data);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BST\n"));
+		kfree(data.pointer);
+		result = -ENODEV;
+		goto end;
+	}
+
+end:
+	acpi_os_free(buffer.pointer);
+
+	if (!result)
+		(*bst) = (struct acpi_battery_status *) data.pointer;
+
+	return_VALUE(result);
+}
+
+
+static int
+acpi_battery_set_alarm (
+	struct acpi_battery	*battery,
+	unsigned long		alarm)
+{
+	acpi_status		status = 0;
+	union acpi_object	arg0 = {ACPI_TYPE_INTEGER};
+	struct acpi_object_list	arg_list = {1, &arg0};
+
+	ACPI_FUNCTION_TRACE("acpi_battery_set_alarm");
+
+	if (!battery)
+		return_VALUE(-EINVAL);
+
+	if (!battery->flags.alarm)
+		return_VALUE(-ENODEV);
+
+	arg0.integer.value = alarm;
+
+	status = acpi_evaluate_object(battery->handle, "_BTP", &arg_list, NULL);
+	if (ACPI_FAILURE(status))
+		return_VALUE(-ENODEV);
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Alarm set to %d\n", (u32) alarm));
+
+	battery->alarm = alarm;
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_battery_check (
+	struct acpi_battery	*battery)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	acpi_handle		handle = NULL;
+	struct acpi_device	*device = NULL;
+	struct acpi_battery_info *bif = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_battery_check");
+	
+	if (!battery)
+		return_VALUE(-EINVAL);
+
+	result = acpi_bus_get_device(battery->handle, &device);
+	if (result)
+		return_VALUE(result);
+
+	result = acpi_bus_get_status(device);
+	if (result)
+		return_VALUE(result);
+
+	/* Insertion? */
+
+	if (!battery->flags.present && device->status.battery_present) {
+
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Battery inserted\n"));
+
+		/* Evalute _BIF to get certain static information */
+
+		result = acpi_battery_get_info(battery, &bif);
+		if (result)
+			return_VALUE(result);
+
+		battery->flags.power_unit = bif->power_unit;
+		battery->trips.warning = bif->design_capacity_warning;
+		battery->trips.low = bif->design_capacity_low;
+		kfree(bif);
+
+		/* See if alarms are supported, and if so, set default */
+
+		status = acpi_get_handle(battery->handle, "_BTP", &handle);
+		if (ACPI_SUCCESS(status)) {
+			battery->flags.alarm = 1;
+			acpi_battery_set_alarm(battery, battery->trips.warning);
+		}
+	}
+
+	/* Removal? */
+
+	else if (battery->flags.present && !device->status.battery_present) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Battery removed\n"));
+	}
+
+	battery->flags.present = device->status.battery_present;
+
+	return_VALUE(result);
+}
+
+
+/* --------------------------------------------------------------------------
+                              FS Interface (/proc)
+   -------------------------------------------------------------------------- */
+
+struct proc_dir_entry		*acpi_battery_dir = NULL;
+
+static int
+acpi_battery_read_info (
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	int			result = 0;
+	struct acpi_battery	*battery = (struct acpi_battery *) data;
+	struct acpi_battery_info *bif = NULL;
+	char			*units = "?";
+	char			*p = page;
+	int			len = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_battery_read_info");
+
+	if (!battery)
+		goto end;
+
+	if (battery->flags.present)
+		p += sprintf(p, "present:                 yes\n");
+	else {
+		p += sprintf(p, "present:                 no\n");
+		goto end;
+	}
+
+	/* Battery Info (_BIF) */
+
+	result = acpi_battery_get_info(battery, &bif);
+	if (result || !bif) {
+		p += sprintf(p, "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");
+	else
+		p += sprintf(p, "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");
+	else
+		p += sprintf(p, "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");
+		break;
+	case 1:
+		p += sprintf(p, "battery technology:      rechargeable\n");
+		break;
+	default:
+		p += sprintf(p, "battery technology:      unknown\n");
+		break;
+	}
+
+	if (bif->design_voltage == ACPI_BATTERY_VALUE_UNKNOWN)
+		p += sprintf(p, "design voltage:          unknown\n");
+	else
+		p += sprintf(p, "design voltage:          %d mV\n",
+			(u32) bif->design_voltage);
+	
+	p += sprintf(p, "design capacity warning: %d %sh\n",
+		(u32) bif->design_capacity_warning, units);
+	p += sprintf(p, "design capacity low:     %d %sh\n",
+		(u32) bif->design_capacity_low, units);
+	p += sprintf(p, "capacity granularity 1:  %d %sh\n",
+		(u32) bif->battery_capacity_granularity_1, units);
+	p += sprintf(p, "capacity granularity 2:  %d %sh\n",
+		(u32) bif->battery_capacity_granularity_2, units);
+	p += sprintf(p, "model number:            %s\n",
+		bif->model_number);
+	p += sprintf(p, "serial number:           %s\n",
+		bif->serial_number);
+	p += sprintf(p, "battery type:            %s\n",
+		bif->battery_type);
+	p += sprintf(p, "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(len);
+}
+
+
+static int
+acpi_battery_read_state (
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	int			result = 0;
+	struct acpi_battery	*battery = (struct acpi_battery *) data;
+	struct acpi_battery_status *bst = NULL;
+	char			*units = "?";
+	char			*p = page;
+	int			len = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_battery_read_state");
+
+	if (!battery)
+		goto end;
+
+	if (battery->flags.present)
+		p += sprintf(p, "present:                 yes\n");
+	else {
+		p += sprintf(p, "present:                 no\n");
+		goto end;
+	}
+
+	/* Battery Units */
+
+	units = battery->flags.power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;
+
+	/* Battery Status (_BST) */
+
+	result = acpi_battery_get_status(battery, &bst);
+	if (result || !bst) {
+		p += sprintf(p, "ERROR: Unable to read battery status\n");
+		goto end;
+	}
+
+	if (!(bst->state & 0x04))
+		p += sprintf(p, "capacity state:          ok\n");
+	else
+		p += sprintf(p, "capacity state:          critical\n");
+
+	if ((bst->state & 0x01) && (bst->state & 0x02))
+		p += sprintf(p, "charging state:          charging/discharging\n");
+	else if (bst->state & 0x01)
+		p += sprintf(p, "charging state:          discharging\n");
+	else if (bst->state & 0x02)
+		p += sprintf(p, "charging state:          charging\n");
+	else
+		p += sprintf(p, "charging state:          unknown\n");
+
+	if (bst->present_rate == ACPI_BATTERY_VALUE_UNKNOWN)
+		p += sprintf(p, "present rate:            unknown\n");
+	else
+		p += sprintf(p, "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");
+	else
+		p += sprintf(p, "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");
+	else
+		p += sprintf(p, "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(len);
+}
+
+
+static int
+acpi_battery_read_alarm (
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	struct acpi_battery	*battery = (struct acpi_battery *) data;
+	char			*units = "?";
+	char			*p = page;
+	int			len = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_battery_read_alarm");
+
+	if (!battery)
+		goto end;
+
+	if (!battery->flags.present) {
+		p += sprintf(p, "present:                 no\n");
+		goto end;
+	}
+
+	/* Battery Units */
+	
+	units = battery->flags.power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;
+
+	/* Battery Alarm */
+
+	p += sprintf(p, "alarm:                   ");
+	if (!battery->alarm)
+		p += sprintf(p, "unsupported\n");
+	else
+		p += sprintf(p, "%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);
+}
+
+
+static int
+acpi_battery_write_alarm (
+	struct file		*file,
+	const char		*buffer,
+	unsigned long		count,
+	void			*data)
+{
+	int			result = 0;
+	struct acpi_battery	*battery = (struct acpi_battery *) data;
+	char			alarm_string[12] = {'\0'};
+
+	ACPI_FUNCTION_TRACE("acpi_battery_write_alarm");
+
+	if (!battery || (count > sizeof(alarm_string) - 1))
+		return_VALUE(-EINVAL);
+
+	if (!battery->flags.present)
+		return_VALUE(-ENODEV);
+
+	if (copy_from_user(alarm_string, buffer, count))
+		return_VALUE(-EFAULT);
+	
+	alarm_string[count] = '\0';
+
+	result = acpi_battery_set_alarm(battery, 
+		simple_strtoul(alarm_string, NULL, 0));
+	if (result)
+		return_VALUE(result);
+
+	return_VALUE(count);
+}
+
+
+static int
+acpi_battery_add_fs (
+	struct acpi_device	*device)
+{
+	struct proc_dir_entry	*entry = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_battery_add_fs");
+
+	if (!acpi_device_dir(device)) {
+		acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
+			acpi_battery_dir);
+		if (!acpi_device_dir(device))
+			return_VALUE(-ENODEV);
+	}
+
+	/* 'info' [R] */
+	entry = create_proc_entry(ACPI_BATTERY_FILE_INFO,
+		S_IRUGO, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_BATTERY_FILE_INFO));
+	else {
+		entry->read_proc = acpi_battery_read_info;
+		entry->data = acpi_driver_data(device);
+	}
+
+	/* 'status' [R] */
+	entry = create_proc_entry(ACPI_BATTERY_FILE_STATUS,
+		S_IRUGO, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_BATTERY_FILE_STATUS));
+	else {
+		entry->read_proc = acpi_battery_read_state;
+		entry->data = acpi_driver_data(device);
+	}
+
+	/* 'alarm' [R/W] */
+	entry = create_proc_entry(ACPI_BATTERY_FILE_ALARM,
+		S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"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->data = acpi_driver_data(device);
+	}
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_battery_remove_fs (
+	struct acpi_device	*device)
+{
+	ACPI_FUNCTION_TRACE("acpi_battery_remove_fs");
+
+	if (acpi_device_dir(device)) {
+		remove_proc_entry(acpi_device_bid(device), acpi_battery_dir);
+		acpi_device_dir(device) = NULL;
+	}
+
+	return_VALUE(0);
+}
+
+
+/* --------------------------------------------------------------------------
+                                 Driver Interface
+   -------------------------------------------------------------------------- */
+
+static void
+acpi_battery_notify (
+	acpi_handle		handle,
+	u32			event,
+	void			*data)
+{
+	struct acpi_battery	*battery = (struct acpi_battery *) data;
+	struct acpi_device	*device = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_battery_notify");
+
+	if (!battery)
+		return_VOID;
+
+	if (acpi_bus_get_device(handle, &device))
+		return_VOID;
+
+	switch (event) {
+	case ACPI_BATTERY_NOTIFY_STATUS:
+	case ACPI_BATTERY_NOTIFY_INFO:
+		acpi_battery_check(battery);
+		acpi_bus_generate_event(device, event, battery->flags.present);
+		break;
+	default:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+			"Unsupported event [0x%x]\n", event));
+		break;
+	}
+
+	return_VOID;
+}
+
+
+static int
+acpi_battery_add (
+	struct acpi_device	*device)
+{
+	int			result = 0;
+	acpi_status		status = 0;
+	struct acpi_battery	*battery = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_battery_add");
+	
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	battery = kmalloc(sizeof(struct acpi_battery), GFP_KERNEL);
+	if (!battery)
+		return_VALUE(-ENOMEM);
+	memset(battery, 0, sizeof(struct acpi_battery));
+
+	battery->handle = device->handle;
+	sprintf(acpi_device_name(device), "%s", ACPI_BATTERY_DEVICE_NAME);
+	sprintf(acpi_device_class(device), "%s", ACPI_BATTERY_CLASS);
+	acpi_driver_data(device) = battery;
+
+	result = acpi_battery_check(battery);
+	if (result)
+		goto end;
+
+	result = acpi_battery_add_fs(device);
+	if (result)
+		goto end;
+
+	status = acpi_install_notify_handler(battery->handle,
+		ACPI_DEVICE_NOTIFY, acpi_battery_notify, battery);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Error installing notify handler\n"));
+		result = -ENODEV;
+		goto end;
+	}
+
+	printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n",
+		ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device),
+		device->status.battery_present?"present":"absent");
+		
+end:
+	if (result) {
+		acpi_battery_remove_fs(device);
+		kfree(battery);
+	}
+
+	return_VALUE(result);
+}
+
+
+static int
+acpi_battery_remove (
+	struct acpi_device	*device,
+	int			type)
+{
+	acpi_status		status = 0;
+	struct acpi_battery	*battery = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_battery_remove");
+
+	if (!device || !acpi_driver_data(device))
+		return_VALUE(-EINVAL);
+
+	battery = (struct acpi_battery *) acpi_driver_data(device);
+
+	status = acpi_remove_notify_handler(battery->handle,
+		ACPI_DEVICE_NOTIFY, acpi_battery_notify);
+	if (ACPI_FAILURE(status))
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Error removing notify handler\n"));
+
+	acpi_battery_remove_fs(device);
+
+	kfree(battery);
+
+	return_VALUE(0);
+}
+
+
+static int __init
+acpi_battery_init (void)
+{
+	int			result = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_battery_init");
+
+	acpi_battery_dir = proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir);
+	if (!acpi_battery_dir)
+		return_VALUE(-ENODEV);
+
+	result = acpi_bus_register_driver(&acpi_battery_driver);
+	if (result < 0) {
+		remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir);
+		return_VALUE(-ENODEV);
+	}
+
+	return_VALUE(0);
+}
+
+
+static void __exit
+acpi_battery_exit (void)
+{
+	ACPI_FUNCTION_TRACE("acpi_battery_exit");
+
+	acpi_bus_unregister_driver(&acpi_battery_driver);
+
+	remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir);
+
+	return_VOID;
+}
+
+
+module_init(acpi_battery_init);
+module_exit(acpi_battery_exit);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/blacklist.c linux-2.4.22-pre2/drivers/acpi/blacklist.c
--- linux-2.4.21/drivers/acpi/blacklist.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/blacklist.c	2003-06-26 21:43:11.000000000 +0000
@@ -0,0 +1,141 @@
+/*
+ *  blacklist.c
+ *
+ *  Check to see if the given machine has a known bad ACPI BIOS
+ *
+ *  Copyright (C) 2002 Andy Grover <andrew.grover@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/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/acpi.h>
+#include <acpi/acpi_bus.h>
+
+#define	PREFIX			"ACPI: "
+
+enum acpi_blacklist_predicates
+{
+        all_versions,
+        less_than_or_equal,
+        equal,
+        greater_than_or_equal,
+};
+
+struct acpi_blacklist_item
+{
+        char            oem_id[7];
+        char            oem_table_id[9];
+        u32             oem_revision;
+        acpi_table_type table;
+        enum acpi_blacklist_predicates oem_revision_predicate;
+        char            *reason;
+        u32             is_critical_error;
+};
+
+/*
+ * POLICY: If *anything* doesn't work, put it on the blacklist.
+ *	   If they are critical errors, mark it critical, and abort driver load.
+ */
+static struct acpi_blacklist_item acpi_blacklist[] __initdata =
+{
+	/* Portege 7020, BIOS 8.10 */
+	{"TOSHIB", "7020CT  ", 0x19991112, ACPI_DSDT, all_versions, "Implicit Return", 0},
+	/* Portege 4030 */
+	{"TOSHIB", "4030    ", 0x19991112, ACPI_DSDT, all_versions, "Implicit Return", 0},
+	/* Portege 310/320, BIOS 7.1 */
+	{"TOSHIB", "310     ", 0x19990511, ACPI_DSDT, all_versions, "Implicit Return", 0},
+	/* Seattle 2, old bios rev. */
+	{"INTEL ", "440BX   ", 0x00001000, ACPI_DSDT, less_than_or_equal, "Field beyond end of region", 0},
+	/* ASUS K7M */
+	{"ASUS  ", "K7M     ", 0x00001000, ACPI_DSDT, less_than_or_equal, "Field beyond end of region", 0},
+	/* Intel 810 Motherboard? */
+	{"MNTRAL", "MO81010A", 0x00000012, ACPI_DSDT, less_than_or_equal, "Field beyond end of region", 0},
+	/* Compaq Presario 711FR */
+	{"COMAPQ", "EAGLES", 0x06040000, ACPI_DSDT, less_than_or_equal, "SCI issues (C2 disabled)", 0},
+	/* Compaq Presario 1700 */
+	{"PTLTD ", "  DSDT  ", 0x06040000, ACPI_DSDT, less_than_or_equal, "Multiple problems", 1},
+	/* Sony FX120, FX140, FX150? */
+	{"SONY  ", "U0      ", 0x20010313, ACPI_DSDT, less_than_or_equal, "ACPI driver problem", 1},
+	/* Compaq Presario 800, Insyde BIOS */
+	{"INT440", "SYSFexxx", 0x00001001, ACPI_DSDT, less_than_or_equal, "Does not use _REG to protect EC OpRegions", 1},
+	/* IBM 600E - _ADR should return 7, but it returns 1 */
+	{"IBM   ", "TP600E  ", 0x00000105, ACPI_DSDT, less_than_or_equal, "Incorrect _ADR", 1},
+	{"ASUS\0\0", "P2B-S   ", 0, ACPI_DSDT, all_versions, "Bogus PCI routing", 1},
+
+	{""}
+};
+
+
+int __init
+acpi_blacklisted(void)
+{
+	int i = 0;
+	int blacklisted = 0;
+	struct acpi_table_header *table_header;
+
+	while (acpi_blacklist[i].oem_id[0] != '\0')
+	{
+		if (acpi_get_table_header_early(acpi_blacklist[i].table, &table_header)) {
+			i++;
+			continue;
+		}
+
+		if (strncmp(acpi_blacklist[i].oem_id, table_header->oem_id, 6)) {
+			i++;
+			continue;
+		}
+
+		if (strncmp(acpi_blacklist[i].oem_table_id, table_header->oem_table_id, 8)) {
+			i++;
+			continue;
+		}
+
+		if ((acpi_blacklist[i].oem_revision_predicate == all_versions)
+		    || (acpi_blacklist[i].oem_revision_predicate == less_than_or_equal
+		        && table_header->oem_revision <= acpi_blacklist[i].oem_revision)
+		    || (acpi_blacklist[i].oem_revision_predicate == greater_than_or_equal
+		        && table_header->oem_revision >= acpi_blacklist[i].oem_revision)
+		    || (acpi_blacklist[i].oem_revision_predicate == equal
+		        && table_header->oem_revision == acpi_blacklist[i].oem_revision)) {
+
+			printk(KERN_ERR PREFIX "Vendor \"%6.6s\" System \"%8.8s\" "
+				"Revision 0x%x has a known ACPI BIOS problem.\n",
+				acpi_blacklist[i].oem_id,
+				acpi_blacklist[i].oem_table_id,
+				acpi_blacklist[i].oem_revision);
+
+			printk(KERN_ERR PREFIX "Reason: %s. This is a %s error\n",
+				acpi_blacklist[i].reason,
+				(acpi_blacklist[i].is_critical_error ? "non-recoverable" : "recoverable"));
+
+			blacklisted = acpi_blacklist[i].is_critical_error;
+			break;
+		}
+		else {
+			i++;
+		}
+	}
+
+	return blacklisted;
+}
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/bus.c linux-2.4.22-pre2/drivers/acpi/bus.c
--- linux-2.4.21/drivers/acpi/bus.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/bus.c	2003-06-26 21:43:10.000000000 +0000
@@ -0,0 +1,2092 @@
+/*
+ *  acpi_bus.c - ACPI Bus Driver ($Revision: 77 $)
+ *
+ *  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/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/version.h>
+#include <linux/ioport.h>
+#include <linux/list.h>
+#include <linux/sched.h>
+#include <linux/pm.h>
+#include <linux/proc_fs.h>
+#ifdef CONFIG_X86
+#include <asm/mpspec.h>
+#endif
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+#include <acpi/acinterp.h>	/* for acpi_ex_eisa_id_to_string() */
+
+
+#define _COMPONENT		ACPI_BUS_COMPONENT
+ACPI_MODULE_NAME		("acpi_bus")
+
+MODULE_AUTHOR("Paul Diefenbaugh");
+MODULE_DESCRIPTION(ACPI_BUS_DRIVER_NAME);
+MODULE_LICENSE("GPL");
+
+#define	PREFIX			"ACPI: "
+
+extern void eisa_set_level_irq(unsigned int irq);
+
+extern int			acpi_disabled;
+
+FADT_DESCRIPTOR			acpi_fadt;
+struct acpi_device		*acpi_root;
+struct proc_dir_entry		*acpi_root_dir;
+
+#define STRUCT_TO_INT(s)	(*((int*)&s))
+
+
+/* --------------------------------------------------------------------------
+                          Linux Driver Model (LDM) Support
+   -------------------------------------------------------------------------- */
+
+#ifdef CONFIG_LDM
+
+static int acpi_device_probe(struct device *dev);
+static int acpi_device_remove(struct device *dev);
+static int acpi_device_suspend(struct device *dev, u32 state, u32 stage);
+static int acpi_device_resume(struct device *dev, u32 stage);
+
+static struct device_driver acpi_bus_driver = {
+	.probe = acpi_device_probe,
+	.remove = acpi_device_remove,	
+	.suspend = acpi_device_suspend,
+	.resume = acpi_device_resume,
+};
+
+
+static int
+acpi_device_probe (
+	struct device		*dev)
+{
+	ACPI_FUNCTION_TRACE("acpi_device_probe");
+
+	if (!dev)
+		return_VALUE(-EINVAL);
+
+	/* TBD */
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_device_remove (
+	struct device		*dev)
+{
+	ACPI_FUNCTION_TRACE("acpi_device_remove");
+
+	if (!dev)
+		return_VALUE(-EINVAL);
+
+	/* TBD */
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_device_suspend (
+	struct device		*dev,
+	u32			state,
+	u32			stage)
+{
+	ACPI_FUNCTION_TRACE("acpi_device_suspend");
+
+	if (!dev)
+		return_VALUE(-EINVAL);
+
+	/* TBD */
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_device_resume (
+	struct device		*dev,
+	u32			stage)
+{
+	ACPI_FUNCTION_TRACE("acpi_device_resume");
+
+	if (!dev)
+		return_VALUE(-EINVAL);
+
+	/* TBD */
+
+	return_VALUE(0);
+}
+
+#if 0 /* not used ATM */
+static int
+acpi_platform_add (
+	struct device		*dev)
+{
+	ACPI_FUNCTION_TRACE("acpi_platform_add");
+
+	if (!dev)
+		return -EINVAL;
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device %s (%s) added\n",
+		dev->name, dev->bus_id));
+
+	/* TBD */
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_platform_remove (
+	struct device		*dev)
+{
+	ACPI_FUNCTION_TRACE("acpi_platform_add");
+
+	if (!dev)
+		return -EINVAL;
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device %s (%s) removed\n",
+		dev->name, dev->bus_id));
+
+	/* TBD */
+
+	return_VALUE(0);
+}
+#endif /* unused */
+
+
+#endif /*CONFIG_LDM*/
+
+
+static int
+acpi_device_register (
+	struct acpi_device	*device,
+	struct acpi_device	*parent)
+{
+	int			result = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_device_register");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+#ifdef CONFIG_LDM
+	sprintf(device->dev.name, "ACPI device %s:%s", 
+		device->pnp.hardware_id, device->pnp.unique_id);
+	strncpy(device->dev.bus_id, device->pnp.bus_id, sizeof(acpi_bus_id));
+	if (parent)
+		device->dev.parent = &parent->dev;
+	device->dev.driver = &acpi_bus_driver;
+
+	result = device_register(&device->dev);
+#endif /*CONFIG_LDM*/
+
+	return_VALUE(result);
+}
+
+
+static int
+acpi_device_unregister (
+	struct acpi_device	*device)
+{
+	ACPI_FUNCTION_TRACE("acpi_device_unregister");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+#ifdef CONFIG_LDM
+	put_device(&device->dev);
+#endif /*CONFIG_LDM*/
+
+	return_VALUE(0);
+}
+
+
+/* --------------------------------------------------------------------------
+                                Device Management
+   -------------------------------------------------------------------------- */
+
+static void
+acpi_bus_data_handler (
+	acpi_handle		handle,
+	u32			function,
+	void			*context)
+{
+	ACPI_FUNCTION_TRACE("acpi_bus_data_handler");
+
+	/* TBD */
+
+	return_VOID;
+}
+
+
+int
+acpi_bus_get_device (
+	acpi_handle		handle,
+	struct acpi_device	**device)
+{
+	acpi_status		status = AE_OK;
+
+	ACPI_FUNCTION_TRACE("acpi_bus_get_device");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	/* TBD: Support fixed-feature devices */
+
+	status = acpi_get_data(handle, acpi_bus_data_handler, (void**) device);
+	if (ACPI_FAILURE(status) || !*device) {
+		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error getting context for object [%p]\n",
+			handle));
+		return_VALUE(-ENODEV);
+	}
+
+	return_VALUE(0);
+}
+
+int
+acpi_bus_get_status (
+	struct acpi_device	*device)
+{
+	acpi_status		status = AE_OK;
+	unsigned long		sta = 0;
+	
+	ACPI_FUNCTION_TRACE("acpi_bus_get_status");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	/*
+	 * Evaluate _STA if present.
+	 */
+	if (device->flags.dynamic_status) {
+		status = acpi_evaluate_integer(device->handle, "_STA", NULL, &sta);
+		if (ACPI_FAILURE(status))
+			return_VALUE(-ENODEV);
+		STRUCT_TO_INT(device->status) = (int) sta;
+	}
+
+	/*
+	 * Otherwise we assume the status of our parent (unless we don't
+	 * have one, in which case status is implied).
+	 */
+	else if (device->parent)
+		device->status = device->parent->status;
+	else
+		STRUCT_TO_INT(device->status) = 0x0F;
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", 
+		device->pnp.bus_id, (u32) STRUCT_TO_INT(device->status)));
+
+	return_VALUE(0);
+}
+
+
+/*
+static int
+acpi_bus_create_device_fs (struct device *device)
+{
+	ACPI_FUNCTION_TRACE("acpi_bus_create_device_fs");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	if (device->dir.entry)
+		return_VALUE(-EEXIST);
+
+	if (!device->parent)
+		device->dir.entry = proc_mkdir(device->pnp.bus_id, NULL);
+	else
+		device->dir.entry = proc_mkdir(device->pnp.bus_id,
+			device->parent->fs.entry);
+
+	if (!device->dir.entry) {
+		printk(KERN_ERR PREFIX "Unable to create fs entry '%s'\n",
+			device->pnp.bus_id);
+		return_VALUE(-ENODEV);
+	}
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_bus_remove_device_fs (struct device *device)
+{
+	ACPI_FUNCTION_TRACE("acpi_bus_create_device_fs");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	if (!device->dir.entry)
+		return_VALUE(-ENODEV);
+
+	if (!device->parent)
+		remove_proc_entry(device->pnp_bus_id, NULL);
+	else
+		remove_proc_entry(device->pnp.bus_id, device->parent->fs.entry);
+
+	device->dir.entry = NULL;
+
+	return_VALUE(0);
+}
+*/
+
+
+/* --------------------------------------------------------------------------
+                                 Power Management
+   -------------------------------------------------------------------------- */
+
+int
+acpi_bus_get_power (
+	acpi_handle		handle,
+	int			*state)
+{
+	int			result = 0;
+	acpi_status             status = 0;
+	struct acpi_device	*device = NULL;
+	unsigned long		psc = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_bus_get_power");
+
+	result = acpi_bus_get_device(handle, &device);
+	if (result)
+		return_VALUE(result);
+
+	*state = ACPI_STATE_UNKNOWN;
+
+	if (!device->flags.power_manageable) {
+		/* TBD: Non-recursive algorithm for walking up hierarchy */
+		if (device->parent)
+			*state = device->parent->power.state;
+		else
+			*state = ACPI_STATE_D0;
+	}
+	else {
+		/*
+		 * Get the device's power state either directly (via _PSC) or 
+		 * indirectly (via power resources).
+		 */
+		if (device->power.flags.explicit_get) {
+			status = acpi_evaluate_integer(device->handle, "_PSC", 
+				NULL, &psc);
+			if (ACPI_FAILURE(status))
+				return_VALUE(-ENODEV);
+			device->power.state = (int) psc;
+		}
+		else if (device->power.flags.power_resources) {
+			result = acpi_power_get_inferred_state(device);
+			if (result)
+				return_VALUE(result);
+		}
+
+		*state = device->power.state;
+	}
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is D%d\n",
+		device->pnp.bus_id, device->power.state));
+
+	return_VALUE(0);
+}
+
+
+int
+acpi_bus_set_power (
+	acpi_handle		handle,
+	int			state)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	struct acpi_device	*device = NULL;
+	char			object_name[5] = {'_','P','S','0'+state,'\0'};
+
+	ACPI_FUNCTION_TRACE("acpi_bus_set_power");
+
+	result = acpi_bus_get_device(handle, &device);
+	if (result)
+		return_VALUE(result);
+
+	if ((state < ACPI_STATE_D0) || (state > ACPI_STATE_D3))
+		return_VALUE(-EINVAL);
+
+	/* Make sure this is a valid target state */
+
+	if (!device->flags.power_manageable) {
+		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device is not power manageable\n"));
+		return_VALUE(-ENODEV);
+	}
+	if (state == device->power.state) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", state));
+		return_VALUE(0);
+	}
+	if (!device->power.states[state].flags.valid) {
+		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device does not support D%d\n", state));
+		return_VALUE(-ENODEV);
+	}
+	if (device->parent && (state < device->parent->power.state)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Cannot set device to a higher-powered state than parent\n"));
+		return_VALUE(-ENODEV);
+	}
+
+	/*
+	 * Transition Power
+	 * ----------------
+	 * On transitions to a high-powered state we first apply power (via
+	 * power resources) then evalute _PSx.  Conversly for transitions to
+	 * a lower-powered state.
+	 */ 
+	if (state < device->power.state) {
+		if (device->power.flags.power_resources) {
+			result = acpi_power_transition(device, state);
+			if (result)
+				goto end;
+		}
+		if (device->power.states[state].flags.explicit_set) {
+			status = acpi_evaluate_object(device->handle, 
+				object_name, NULL, NULL);
+			if (ACPI_FAILURE(status)) {
+				result = -ENODEV;
+				goto end;
+			}
+		}
+	}
+	else {
+		if (device->power.states[state].flags.explicit_set) {
+			status = acpi_evaluate_object(device->handle, 
+				object_name, NULL, NULL);
+			if (ACPI_FAILURE(status)) {
+				result = -ENODEV;
+				goto end;
+			}
+		}
+		if (device->power.flags.power_resources) {
+			result = acpi_power_transition(device, state);
+			if (result)
+				goto end;
+		}
+	}
+
+end:
+	if (result)
+		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error transitioning device [%s] to D%d\n",
+			device->pnp.bus_id, state));
+	else
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] transitioned to D%d\n",
+			device->pnp.bus_id, state));
+
+	return_VALUE(result);
+}
+
+
+static int
+acpi_bus_get_power_flags (
+	struct acpi_device	*device)
+{
+	acpi_status             status = 0;
+	acpi_handle		handle = 0;
+	u32                     i = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_bus_get_power_flags");
+
+	if (!device)
+		return -ENODEV;
+
+	/*
+	 * Power Management Flags
+	 */
+	status = acpi_get_handle(device->handle, "_PSC", &handle);
+	if (ACPI_SUCCESS(status))
+		device->power.flags.explicit_get = 1;
+	status = acpi_get_handle(device->handle, "_IRC", &handle);
+	if (ACPI_SUCCESS(status))
+		device->power.flags.inrush_current = 1;
+	status = acpi_get_handle(device->handle, "_PRW", &handle);
+	if (ACPI_SUCCESS(status))
+		device->power.flags.wake_capable = 1;
+
+	/*
+	 * Enumerate supported power management states
+	 */
+	for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3; i++) {
+		struct acpi_device_power_state *ps = &device->power.states[i];
+		char		object_name[5] = {'_','P','R','0'+i,'\0'};
+
+		/* Evaluate "_PRx" to se if power resources are referenced */
+		acpi_evaluate_reference(device->handle, object_name, NULL,
+			&ps->resources);
+		if (ps->resources.count) {
+			device->power.flags.power_resources = 1;
+			ps->flags.valid = 1;
+		}
+
+		/* Evaluate "_PSx" to see if we can do explicit sets */
+		object_name[2] = 'S';
+		status = acpi_get_handle(device->handle, object_name, &handle);
+		if (ACPI_SUCCESS(status)) {
+			ps->flags.explicit_set = 1;
+			ps->flags.valid = 1;
+		}
+
+		/* State is valid if we have some power control */
+		if (ps->resources.count || ps->flags.explicit_set)
+			ps->flags.valid = 1;
+
+		ps->power = -1;		/* Unknown - driver assigned */
+		ps->latency = -1;	/* Unknown - driver assigned */
+	}
+
+	/* Set defaults for D0 and D3 states (always valid) */
+	device->power.states[ACPI_STATE_D0].flags.valid = 1;
+	device->power.states[ACPI_STATE_D0].power = 100;
+	device->power.states[ACPI_STATE_D3].flags.valid = 1;
+	device->power.states[ACPI_STATE_D3].power = 0;
+
+	/*
+	 * System Power States
+	 * -------------------
+	 */
+	/* TBD: S1-S4 power state support and resource requirements. */
+	/*
+	for (i=ACPI_STATE_S1; i<ACPI_STATE_S5; i++) {
+		char name[5] = {'_','S',('0'+i),'D','\0'};
+		status = acpi_evaluate_integer(device->handle, name, NULL,
+			&state);
+		if (ACPI_FAILURE(status))
+			continue;
+	}
+	*/
+
+	/* TBD: System wake support and resource requirements. */
+
+	device->power.state = ACPI_STATE_UNKNOWN;
+
+	return 0;
+}
+
+
+/* --------------------------------------------------------------------------
+                              Performance Management
+   -------------------------------------------------------------------------- */
+
+static int
+acpi_bus_get_perf_flags (
+	struct acpi_device	*device)
+{
+	ACPI_FUNCTION_TRACE("acpi_bus_get_perf_flags");
+
+	if (!device)
+		return -ENODEV;
+
+	device->performance.state = ACPI_STATE_UNKNOWN;
+
+	return 0;
+}
+
+
+/* --------------------------------------------------------------------------
+                                Event Management
+   -------------------------------------------------------------------------- */
+
+static spinlock_t		acpi_bus_event_lock = SPIN_LOCK_UNLOCKED;
+
+LIST_HEAD(acpi_bus_event_list);
+DECLARE_WAIT_QUEUE_HEAD(acpi_bus_event_queue);
+
+extern int			event_is_open;
+
+int
+acpi_bus_generate_event (
+	struct acpi_device	*device,
+	u8			type,
+	int			data)
+{
+	struct acpi_bus_event	*event = NULL;
+	u32			flags = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_bus_generate_event");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	/* drop event on the floor if no one's listening */
+	if (!event_is_open)
+		return_VALUE(0);
+
+	event = kmalloc(sizeof(struct acpi_bus_event), GFP_ATOMIC);
+	if (!event)
+		return_VALUE(-ENOMEM);
+
+	sprintf(event->device_class, "%s", device->pnp.device_class);
+	sprintf(event->bus_id, "%s", device->pnp.bus_id);
+	event->type = type;
+	event->data = data;
+
+	spin_lock_irqsave(&acpi_bus_event_lock, flags);
+	list_add_tail(&event->node, &acpi_bus_event_list);
+	spin_unlock_irqrestore(&acpi_bus_event_lock, flags);
+
+	wake_up_interruptible(&acpi_bus_event_queue);
+
+	return_VALUE(0);
+}
+
+int
+acpi_bus_receive_event (
+	struct acpi_bus_event	*event)
+{
+	u32			flags = 0;
+	struct acpi_bus_event	*entry = NULL;
+
+	DECLARE_WAITQUEUE(wait, current);
+
+	ACPI_FUNCTION_TRACE("acpi_bus_receive_event");
+
+	if (!event)
+		return -EINVAL;
+
+	if (list_empty(&acpi_bus_event_list)) {
+
+		set_current_state(TASK_INTERRUPTIBLE);
+		add_wait_queue(&acpi_bus_event_queue, &wait);
+
+		if (list_empty(&acpi_bus_event_list))
+			schedule();
+
+		remove_wait_queue(&acpi_bus_event_queue, &wait);
+		set_current_state(TASK_RUNNING);
+
+		if (signal_pending(current))
+			return_VALUE(-ERESTARTSYS);
+	}
+
+	spin_lock_irqsave(&acpi_bus_event_lock, flags);
+	entry = list_entry(acpi_bus_event_list.next, struct acpi_bus_event, node);
+	if (entry)
+		list_del(&entry->node);
+	spin_unlock_irqrestore(&acpi_bus_event_lock, flags);
+
+	if (!entry)
+		return_VALUE(-ENODEV);
+
+	memcpy(event, entry, sizeof(struct acpi_bus_event));
+
+	kfree(entry);
+
+	return_VALUE(0);
+}
+
+
+/* --------------------------------------------------------------------------
+                               Namespace Management
+   -------------------------------------------------------------------------- */
+
+#define WALK_UP			0
+#define WALK_DOWN		1
+
+typedef int (*acpi_bus_walk_callback)(struct acpi_device*, int, void*);
+
+#define HAS_CHILDREN(d)		((d)->children.next != &((d)->children))
+#define HAS_SIBLINGS(d)		(((d)->parent) && ((d)->node.next != &(d)->parent->children))
+#define NODE_TO_DEVICE(n)	(list_entry(n, struct acpi_device, node))
+
+
+/**
+ * acpi_bus_walk
+ * -------------
+ * Used to walk the ACPI Bus's device namespace.  Can walk down (depth-first)
+ * or up.  Able to parse starting at any node in the namespace.  Note that a
+ * callback return value of -ELOOP will terminate the walk.
+ *
+ * @start:	starting point
+ * callback:	function to call for every device encountered while parsing
+ * direction:	direction to parse (up or down)
+ * @data:	context for this search operation
+ */
+static int
+acpi_bus_walk (
+	struct acpi_device	*start, 
+	acpi_bus_walk_callback	callback, 
+	int			direction, 
+	void			*data)
+{
+	int			result = 0;
+	int			level = 0;
+	struct acpi_device	*device = NULL;
+
+	if (!start || !callback)
+		return -EINVAL;
+
+	device = start;
+
+	/*
+	 * Parse Namespace
+	 * ---------------
+	 * Parse a given subtree (specified by start) in the given direction.
+	 * Walking 'up' simply means that we execute the callback on leaf
+	 * devices prior to their parents (useful for things like removing
+	 * or powering down a subtree).
+	 */
+
+	while (device) {
+
+		if (direction == WALK_DOWN)
+			if (-ELOOP == callback(device, level, data))
+				break;
+
+		/* Depth First */
+
+		if (HAS_CHILDREN(device)) {
+			device = NODE_TO_DEVICE(device->children.next);
+			++level;
+			continue;
+		}
+
+		if (direction == WALK_UP)
+			if (-ELOOP == callback(device, level, data))
+				break;
+
+		/* Now Breadth */
+
+		if (HAS_SIBLINGS(device)) {
+			device = NODE_TO_DEVICE(device->node.next);
+			continue;
+		}
+
+		/* Scope Exhausted - Find Next */
+
+		while ((device = device->parent)) {
+			--level;
+			if (HAS_SIBLINGS(device)) {
+				device = NODE_TO_DEVICE(device->node.next);
+				break;
+			}
+		}
+	}
+
+	if ((direction == WALK_UP) && (result == 0))
+		callback(start, level, data);
+
+	return result;
+}
+
+
+/* --------------------------------------------------------------------------
+                             Notification Handling
+   -------------------------------------------------------------------------- */
+
+static int
+acpi_bus_check_device (
+	struct acpi_device	*device,
+	int			*status_changed)
+{
+	acpi_status             status = 0;
+	struct acpi_device_status old_status;
+
+	ACPI_FUNCTION_TRACE("acpi_bus_check_device");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	if (status_changed)
+		*status_changed = 0;
+
+	old_status = device->status;
+
+	/*
+	 * Make sure this device's parent is present before we go about
+	 * messing with the device.
+	 */
+	if (device->parent && !device->parent->status.present) {
+		device->status = device->parent->status;
+		if (STRUCT_TO_INT(old_status) != STRUCT_TO_INT(device->status)) {
+			if (status_changed)
+				*status_changed = 1;
+		}
+		return_VALUE(0);
+	}
+
+	status = acpi_bus_get_status(device);
+	if (ACPI_FAILURE(status))
+		return_VALUE(-ENODEV);
+
+	if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status))
+		return_VALUE(0);
+
+	if (status_changed)
+		*status_changed = 1;
+	
+	/*
+	 * Device Insertion/Removal
+	 */
+	if ((device->status.present) && !(old_status.present)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device insertion detected\n"));
+		/* TBD: Handle device insertion */
+	}
+	else if (!(device->status.present) && (old_status.present)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device removal detected\n"));
+		/* TBD: Handle device removal */
+	}
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_bus_check_scope (
+	struct acpi_device	*device)
+{
+	int			result = 0;
+	int			status_changed = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_bus_check_scope");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	/* Status Change? */
+	result = acpi_bus_check_device(device, &status_changed);
+	if (result)
+		return_VALUE(result);
+
+	if (!status_changed)
+		return_VALUE(0);
+
+	/*
+	 * TBD: Enumerate child devices within this device's scope and
+	 *       run acpi_bus_check_device()'s on them.
+	 */
+
+	return_VALUE(0);
+}
+
+
+/**
+ * acpi_bus_notify
+ * ---------------
+ * Callback for all 'system-level' device notifications (values 0x00-0x7F).
+ */
+static void 
+acpi_bus_notify (
+	acpi_handle             handle,
+	u32                     type,
+	void                    *data)
+{
+	int			result = 0;
+	struct acpi_device	*device = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_bus_notify");
+
+	if (acpi_bus_get_device(handle, &device))
+		return_VOID;
+
+	switch (type) {
+
+	case ACPI_NOTIFY_BUS_CHECK:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received BUS CHECK notification for device [%s]\n", 
+			device->pnp.bus_id));
+		result = acpi_bus_check_scope(device);
+		/* 
+		 * TBD: We'll need to outsource certain events to non-ACPI
+		 *	drivers via the device manager (device.c).
+		 */
+		break;
+
+	case ACPI_NOTIFY_DEVICE_CHECK:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received DEVICE CHECK notification for device [%s]\n", 
+			device->pnp.bus_id));
+		result = acpi_bus_check_device(device, NULL);
+		/* 
+		 * TBD: We'll need to outsource certain events to non-ACPI
+		 *	drivers via the device manager (device.c).
+		 */
+		break;
+
+	case ACPI_NOTIFY_DEVICE_WAKE:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received DEVICE WAKE notification for device [%s]\n", 
+			device->pnp.bus_id));
+		/* TBD */
+		break;
+
+	case ACPI_NOTIFY_EJECT_REQUEST:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received EJECT REQUEST notification for device [%s]\n", 
+			device->pnp.bus_id));
+		/* TBD */
+		break;
+
+	case ACPI_NOTIFY_DEVICE_CHECK_LIGHT:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received DEVICE CHECK LIGHT notification for device [%s]\n", 
+			device->pnp.bus_id));
+		/* TBD: Exactly what does 'light' mean? */
+		break;
+
+	case ACPI_NOTIFY_FREQUENCY_MISMATCH:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received FREQUENCY MISMATCH notification for device [%s]\n", 
+			device->pnp.bus_id));
+		/* TBD */
+		break;
+
+	case ACPI_NOTIFY_BUS_MODE_MISMATCH:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received BUS MODE MISMATCH notification for device [%s]\n", 
+			device->pnp.bus_id));
+		/* TBD */
+		break;
+
+	case ACPI_NOTIFY_POWER_FAULT:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received POWER FAULT notification for device [%s]\n", 
+			device->pnp.bus_id));
+		/* TBD */
+		break;
+
+	default:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received unknown/unsupported notification [%08x]\n", 
+			type));
+		break;
+	}
+
+	return_VOID;
+}
+
+
+/* --------------------------------------------------------------------------
+                                 Driver Management
+   -------------------------------------------------------------------------- */
+
+static LIST_HEAD(acpi_bus_drivers);
+static DECLARE_MUTEX(acpi_bus_drivers_lock);
+
+
+/**
+ * acpi_bus_match 
+ * --------------
+ * Checks the device's hardware (_HID) or compatible (_CID) ids to see if it
+ * matches the specified driver's criteria.
+ */
+static int
+acpi_bus_match (
+	struct acpi_device	*device,
+	struct acpi_driver	*driver)
+{
+	int error = 0;
+
+	if (device->flags.hardware_id)
+		if (strstr(driver->ids, device->pnp.hardware_id))
+			goto Done;
+
+	if (device->flags.compatible_ids) {
+		struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;
+		int i;
+
+		/* compare multiple _CID entries against driver ids */
+		for (i = 0; i < cid_list->count; i++)
+		{
+			if (strstr(driver->ids, cid_list->id[i].value))
+				goto Done;
+		}
+	}
+	error = -ENOENT;
+
+ Done:
+	
+	return error;
+}
+
+
+/**
+ * acpi_bus_driver_init 
+ * --------------------
+ * Used to initialize a device via its device driver.  Called whenever a 
+ * driver is bound to a device.  Invokes the driver's add() and start() ops.
+ */
+static int
+acpi_bus_driver_init (
+	struct acpi_device	*device, 
+	struct acpi_driver	*driver)
+{
+	int			result = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_bus_driver_init");
+
+	if (!device || !driver)
+		return_VALUE(-EINVAL);
+
+	if (!driver->ops.add)
+		return_VALUE(-ENOSYS);
+
+	result = driver->ops.add(device);
+	if (result) {
+		device->driver = NULL;
+		acpi_driver_data(device) = NULL;
+		return_VALUE(result);
+	}
+
+	device->driver = driver;
+
+	/*
+	 * TBD - Configuration Management: Assign resources to device based
+	 * upon possible configuration and currently allocated resources.
+	 */
+
+	if (driver->ops.start) {
+		result = driver->ops.start(device);
+		if (result && driver->ops.remove)
+			driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL);
+		return_VALUE(result);
+	}
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Driver successfully bound to device\n"));
+
+#ifdef CONFIG_LDM
+	/* 
+	 * Update the device information (in the global device hierarchy) now
+	 * that there's a driver bound to it.
+	 */
+	strncpy(device->dev.name, device->pnp.device_name, 
+		sizeof(device->dev.name));
+#endif
+
+	if (driver->ops.scan) {
+		driver->ops.scan(device);
+	}
+
+	return_VALUE(0);
+}
+
+
+/**
+ * acpi_bus_attach 
+ * -------------
+ * Callback for acpi_bus_walk() used to find devices that match a specific 
+ * driver's criteria and then attach the driver.
+ */
+static int
+acpi_bus_attach (
+	struct acpi_device	*device, 
+	int			level, 
+	void			*data)
+{
+	int			result = 0;
+	struct acpi_driver	*driver = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_bus_attach");
+
+	if (!device || !data)
+		return_VALUE(-EINVAL);
+
+	driver = (struct acpi_driver *) data;
+
+	if (device->driver)
+		return_VALUE(-EEXIST);
+
+	if (!device->status.present)
+		return_VALUE(-ENODEV);
+
+	result = acpi_bus_match(device, driver);
+	if (result)
+		return_VALUE(result);
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n",
+		driver->name, device->pnp.bus_id));
+	
+	result = acpi_bus_driver_init(device, driver);
+	if (result)
+		return_VALUE(result);
+
+	down(&acpi_bus_drivers_lock);
+	++driver->references;
+	up(&acpi_bus_drivers_lock);
+
+	return_VALUE(0);
+}
+
+
+/**
+ * acpi_bus_unattach 
+ * -----------------
+ * Callback for acpi_bus_walk() used to find devices that match a specific 
+ * driver's criteria and unattach the driver.
+ */
+static int
+acpi_bus_unattach (
+	struct acpi_device	*device, 
+	int			level, 
+	void			*data)
+{
+	int			result = 0;
+	struct acpi_driver	*driver = (struct acpi_driver *) data;
+
+	ACPI_FUNCTION_TRACE("acpi_bus_unattach");
+
+	if (!device || !driver)
+		return_VALUE(-EINVAL);
+
+	if (device->driver != driver)
+		return_VALUE(-ENOENT);
+
+	if (!driver->ops.remove)
+		return_VALUE(-ENOSYS);
+
+	result = driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL);
+	if (result)
+		return_VALUE(result);
+
+	device->driver = NULL;
+	acpi_driver_data(device) = NULL;
+
+	down(&acpi_bus_drivers_lock);
+	driver->references--;
+	up(&acpi_bus_drivers_lock);
+
+	return_VALUE(0);
+}
+
+
+/**
+ * acpi_bus_find_driver 
+ * --------------------
+ * Parses the list of registered drivers looking for a driver applicable for
+ * the specified device.
+ */
+static int
+acpi_bus_find_driver (
+	struct acpi_device	*device)
+{
+	int			result = -ENODEV;
+	struct list_head	*entry = NULL;
+	struct acpi_driver	*driver = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_bus_find_driver");
+
+	if (!device || device->driver)
+		return_VALUE(-EINVAL);
+
+	down(&acpi_bus_drivers_lock);
+
+	list_for_each(entry, &acpi_bus_drivers) {
+
+		driver = list_entry(entry, struct acpi_driver, node);
+
+		if (acpi_bus_match(device, driver))
+			continue;
+
+		result = acpi_bus_driver_init(device, driver);
+		if (!result)
+			++driver->references;
+
+		break;
+	}
+
+	up(&acpi_bus_drivers_lock);
+
+	return_VALUE(result);
+}
+
+
+/**
+ * acpi_bus_register_driver 
+ * ------------------------ 
+ * Registers a driver with the ACPI bus.  Searches the namespace for all
+ * devices that match the driver's criteria and binds.
+ */
+int
+acpi_bus_register_driver (
+	struct acpi_driver	*driver)
+{
+	ACPI_FUNCTION_TRACE("acpi_bus_register_driver");
+
+	if (!driver)
+		return_VALUE(-EINVAL);
+
+	if (acpi_disabled)
+		return_VALUE(-ENODEV);
+
+	down(&acpi_bus_drivers_lock);
+	list_add_tail(&driver->node, &acpi_bus_drivers);
+	up(&acpi_bus_drivers_lock);
+
+	acpi_bus_walk(acpi_root, acpi_bus_attach, 
+		WALK_DOWN, driver);
+
+	return_VALUE(driver->references);
+}
+
+
+/**
+ * acpi_bus_unregister_driver 
+ * --------------------------
+ * Unregisters a driver with the ACPI bus.  Searches the namespace for all
+ * devices that match the driver's criteria and unbinds.
+ */
+int
+acpi_bus_unregister_driver (
+	struct acpi_driver	*driver)
+{
+	ACPI_FUNCTION_TRACE("acpi_bus_unregister_driver");
+
+	if (!driver)
+		return_VALUE(-EINVAL);
+
+	acpi_bus_walk(acpi_root, acpi_bus_unattach, WALK_UP, driver);
+
+	if (driver->references)
+		return_VALUE(driver->references);
+
+	down(&acpi_bus_drivers_lock);
+	list_del(&driver->node);
+	up(&acpi_bus_drivers_lock);
+
+	return_VALUE(0);
+}
+
+
+/* --------------------------------------------------------------------------
+                                 Device Enumeration
+   -------------------------------------------------------------------------- */
+
+static int 
+acpi_bus_get_flags (
+	struct acpi_device	*device)
+{
+	acpi_status		status = AE_OK;
+	acpi_handle		temp = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_bus_get_flags");
+
+	/* Presence of _STA indicates 'dynamic_status' */
+	status = acpi_get_handle(device->handle, "_STA", &temp);
+	if (ACPI_SUCCESS(status))
+		device->flags.dynamic_status = 1;
+
+	/* Presence of _CID indicates 'compatible_ids' */
+	status = acpi_get_handle(device->handle, "_CID", &temp);
+	if (ACPI_SUCCESS(status))
+		device->flags.compatible_ids = 1;
+
+	/* Presence of _RMV indicates 'removable' */
+	status = acpi_get_handle(device->handle, "_RMV", &temp);
+	if (ACPI_SUCCESS(status))
+		device->flags.removable = 1;
+
+	/* Presence of _EJD|_EJ0 indicates 'ejectable' */
+	status = acpi_get_handle(device->handle, "_EJD", &temp);
+	if (ACPI_SUCCESS(status))
+		device->flags.ejectable = 1;
+	else {
+		status = acpi_get_handle(device->handle, "_EJ0", &temp);
+		if (ACPI_SUCCESS(status))
+			device->flags.ejectable = 1;
+	}
+
+	/* Presence of _LCK indicates 'lockable' */
+	status = acpi_get_handle(device->handle, "_LCK", &temp);
+	if (ACPI_SUCCESS(status))
+		device->flags.lockable = 1;
+
+	/* Presence of _PS0|_PR0 indicates 'power manageable' */
+	status = acpi_get_handle(device->handle, "_PS0", &temp);
+	if (ACPI_FAILURE(status))
+		status = acpi_get_handle(device->handle, "_PR0", &temp);
+	if (ACPI_SUCCESS(status))
+		device->flags.power_manageable = 1;
+
+	/* TBD: Peformance management */
+
+	return_VALUE(0);
+}
+
+
+static int 
+acpi_bus_add (
+	struct acpi_device	**child,
+	struct acpi_device	*parent,
+	acpi_handle		handle,
+	int			type)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	struct acpi_device	*device = NULL;
+	char			bus_id[5] = {'?',0};
+	struct acpi_buffer	buffer = {0, NULL};
+	struct acpi_device_info	*info;
+	char			*hid = NULL;
+	char			*uid = NULL;
+	struct acpi_compatible_id_list *cid_list = NULL;
+	int			i = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_bus_add");
+
+	if (!child)
+		return_VALUE(-EINVAL);
+
+	device = kmalloc(sizeof(struct acpi_device), GFP_KERNEL);
+	if (!device) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n"));
+		return_VALUE(-ENOMEM);
+	}
+	memset(device, 0, sizeof(struct acpi_device));
+
+	device->handle = handle;
+	device->parent = parent;
+
+	/*
+	 * Bus ID
+	 * ------
+	 * The device's Bus ID is simply the object name.
+	 * TBD: Shouldn't this value be unique (within the ACPI namespace)?
+	 */
+	switch (type) {
+	case ACPI_BUS_TYPE_SYSTEM:
+		sprintf(device->pnp.bus_id, "%s", "ACPI");
+		break;
+	case ACPI_BUS_TYPE_POWER_BUTTON:
+		sprintf(device->pnp.bus_id, "%s", "PWRF");
+		break;
+	case ACPI_BUS_TYPE_SLEEP_BUTTON:
+		sprintf(device->pnp.bus_id, "%s", "SLPF");
+		break;
+	default:
+		buffer.length = sizeof(bus_id);
+		buffer.pointer = bus_id;
+		acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer);
+		/* Clean up trailing underscores (if any) */
+		for (i = 3; i > 1; i--) {
+			if (bus_id[i] == '_')
+				bus_id[i] = '\0';
+			else
+				break;
+		}
+		sprintf(device->pnp.bus_id, "%s", bus_id);
+		buffer.pointer = NULL;
+		break;
+	}
+
+	/*
+	 * Flags
+	 * -----
+	 * Get prior to calling acpi_bus_get_status() so we know whether
+	 * or not _STA is present.  Note that we only look for object
+	 * handles -- cannot evaluate objects until we know the device is
+	 * present and properly initialized.
+	 */
+	result = acpi_bus_get_flags(device);
+	if (result)
+		goto end;
+
+	/*
+	 * Status
+	 * ------
+	 * See if the device is present.  We always assume that non-Device()
+	 * objects (e.g. thermal zones, power resources, processors, etc.) are
+	 * present, functioning, etc. (at least when parent object is present).
+	 * Note that _STA has a different meaning for some objects (e.g.
+	 * power resources) so we need to be careful how we use it.
+	 */
+	switch (type) {
+	case ACPI_BUS_TYPE_DEVICE:
+		result = acpi_bus_get_status(device);
+		if (result)
+			goto end;
+		break;
+	default:
+		STRUCT_TO_INT(device->status) = 0x0F;
+		break;
+	}
+	if (!device->status.present) {
+		result = -ENOENT;
+		goto end;
+	}
+
+	/*
+	 * Initialize Device
+	 * -----------------
+	 * TBD: Synch with Core's enumeration/initialization process.
+	 */
+
+	/*
+	 * Hardware ID, Unique ID, & Bus Address
+	 * -------------------------------------
+	 */
+	switch (type) {
+	case ACPI_BUS_TYPE_DEVICE:
+		buffer.length = ACPI_ALLOCATE_BUFFER;
+		buffer.pointer = NULL;
+		status = acpi_get_object_info(handle, &buffer);
+		if (ACPI_FAILURE(status)) {
+			ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+				"Error reading device info\n"));
+			result = -ENODEV;
+			goto end;
+		}
+		info = buffer.pointer;
+		if (info->valid & ACPI_VALID_HID)
+			hid = info->hardware_id.value;
+		if (info->valid & ACPI_VALID_UID)
+			uid = info->unique_id.value;
+		if (info->valid & ACPI_VALID_CID) {
+			cid_list = &info->compatibility_id;
+			device->pnp.cid_list = kmalloc(cid_list->size, GFP_KERNEL);
+			if (device->pnp.cid_list)
+				memcpy(device->pnp.cid_list, cid_list, cid_list->size);
+			else
+				ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n"));
+		}
+		if (info->valid & ACPI_VALID_ADR) {
+			device->pnp.bus_address = info->address;
+			device->flags.bus_address = 1;
+		}
+		break;
+	case ACPI_BUS_TYPE_POWER:
+		hid = ACPI_POWER_HID;
+		break;
+	case ACPI_BUS_TYPE_PROCESSOR:
+		hid = ACPI_PROCESSOR_HID;
+		break;
+	case ACPI_BUS_TYPE_SYSTEM:
+		hid = ACPI_SYSTEM_HID;
+		break;
+	case ACPI_BUS_TYPE_THERMAL:
+		hid = ACPI_THERMAL_HID;
+		break;
+	case ACPI_BUS_TYPE_POWER_BUTTON:
+		hid = ACPI_BUTTON_HID_POWERF;
+		break;
+	case ACPI_BUS_TYPE_SLEEP_BUTTON:
+		hid = ACPI_BUTTON_HID_SLEEPF;
+		break;
+	}
+
+	/* 
+	 * \_SB
+	 * ----
+	 * Fix for the system root bus device -- the only root-level device.
+	 */
+	if ((parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) {
+		hid = ACPI_BUS_HID;
+		sprintf(device->pnp.device_name, "%s", ACPI_BUS_DEVICE_NAME);
+		sprintf(device->pnp.device_class, "%s", ACPI_BUS_CLASS);
+	}
+
+	if (hid) {
+		sprintf(device->pnp.hardware_id, "%s", hid);
+		device->flags.hardware_id = 1;
+	}
+	if (uid) {
+		sprintf(device->pnp.unique_id, "%s", uid);
+		device->flags.unique_id = 1;
+	}
+
+	/*
+	 * If we called get_object_info, we now are finished with the buffer,
+	 * so we can free it.
+	 */
+	if (buffer.pointer)
+		acpi_os_free(buffer.pointer);
+
+	/*
+	 * Power Management
+	 * ----------------
+	 */
+	if (device->flags.power_manageable) {
+		result = acpi_bus_get_power_flags(device);
+		if (result)
+			goto end;
+	}
+
+	/*
+	 * Performance Management
+	 * ----------------------
+	 */
+	if (device->flags.performance_manageable) {
+		result = acpi_bus_get_perf_flags(device);
+		if (result)
+			goto end;
+	}
+
+	/*
+	 * Context
+	 * -------
+	 * Attach this 'struct acpi_device' to the ACPI object.  This makes
+	 * resolutions from handle->device very efficient.  Note that we need
+	 * to be careful with fixed-feature devices as they all attach to the
+	 * root object.
+	 */
+	switch (type) {
+	case ACPI_BUS_TYPE_POWER_BUTTON:
+	case ACPI_BUS_TYPE_SLEEP_BUTTON:
+		break;
+	default:
+		status = acpi_attach_data(device->handle,
+			acpi_bus_data_handler, device);
+		break;
+	}
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Error attaching device data\n"));
+		result = -ENODEV;
+		goto end;
+	}
+
+	/*
+	 * Linkage
+	 * -------
+	 * Link this device to its parent and siblings.
+	 */
+	INIT_LIST_HEAD(&device->children);
+	if (!device->parent)
+		INIT_LIST_HEAD(&device->node);
+	else
+		list_add_tail(&device->node, &device->parent->children);
+
+#ifdef CONFIG_ACPI_DEBUG
+	{
+		char			*type_string = NULL;
+		char			name[80] = {'?','\0'};
+		struct acpi_buffer	buffer = {sizeof(name), name};
+
+		acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
+
+		switch (type) {
+		case ACPI_BUS_TYPE_DEVICE:
+			type_string = "Device";
+			break;
+		case ACPI_BUS_TYPE_POWER:
+			type_string = "Power Resource";
+			break;
+		case ACPI_BUS_TYPE_PROCESSOR:
+			type_string = "Processor";
+			break;
+		case ACPI_BUS_TYPE_SYSTEM:
+			type_string = "System";
+			break;
+		case ACPI_BUS_TYPE_THERMAL:
+			type_string = "Thermal Zone";
+			break;
+		case ACPI_BUS_TYPE_POWER_BUTTON:
+			type_string = "Power Button";
+			sprintf(name, "PWRB");
+			break;
+		case ACPI_BUS_TYPE_SLEEP_BUTTON:
+			type_string = "Sleep Button";
+			sprintf(name, "SLPB");
+			break;
+		}
+
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %s %s [%p]\n", 
+			type_string, name, handle));
+	}
+#endif /*CONFIG_ACPI_DEBUG*/
+
+	/*
+	 * Global Device Hierarchy:
+	 * ------------------------
+	 * Register this device with the global device hierarchy.
+	 */
+	acpi_device_register(device, parent);
+
+	/*
+	 * Bind _ADR-Based Devices
+	 * -----------------------
+	 * If there's a a bus address (_ADR) then we utilize the parent's 
+	 * 'bind' function (if exists) to bind the ACPI- and natively-
+	 * enumerated device representations.
+	 */
+	if (device->flags.bus_address) {
+		if (device->parent && device->parent->ops.bind)
+			device->parent->ops.bind(device);
+	}
+
+	/*
+	 * Locate & Attach Driver
+	 * ----------------------
+	 * If there's a hardware id (_HID) or compatible ids (_CID) we check
+	 * to see if there's a driver installed for this kind of device.  Note
+	 * that drivers can install before or after a device is enumerated.
+	 *
+	 * TBD: Assumes LDM provides driver hot-plug capability.
+	 */
+	if (device->flags.hardware_id || device->flags.compatible_ids)
+		acpi_bus_find_driver(device);
+
+end:
+	if (result) {
+		if (device->pnp.cid_list) {
+			kfree(device->pnp.cid_list);
+		}
+		kfree(device);
+		return_VALUE(result);
+	}
+	*child = device;
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_bus_remove (
+	struct acpi_device	*device, 
+	int			type)
+{
+	ACPI_FUNCTION_TRACE("acpi_bus_remove");
+
+	if (!device)
+		return_VALUE(-ENODEV);
+
+	acpi_device_unregister(device);
+
+#if 0
+	if (device->pnp.cid_list)
+		kfree(device->pnp.cid_list);
+#endif
+	kfree(device);
+
+	return_VALUE(0);
+}
+
+
+int
+acpi_bus_scan (
+	struct acpi_device	*start)
+{
+	acpi_status		status = AE_OK;
+	struct acpi_device	*parent = NULL;
+	struct acpi_device	*child = NULL;
+	acpi_handle		phandle = 0;
+	acpi_handle		chandle = 0;
+	acpi_object_type	type = 0;
+	u32			level = 1;
+
+	ACPI_FUNCTION_TRACE("acpi_bus_scan");
+
+	if (!start)
+		return_VALUE(-EINVAL);
+
+	parent = start;
+	phandle = start->handle;
+	
+	/*
+	 * Parse through the ACPI namespace, identify all 'devices', and
+	 * create a new 'struct acpi_device' for each.
+	 */
+	while ((level > 0) && parent) {
+
+		status = acpi_get_next_object(ACPI_TYPE_ANY, phandle,
+			chandle, &chandle);
+
+		/*
+		 * If this scope is exhausted then move our way back up.
+		 */
+		if (ACPI_FAILURE(status)) {
+			level--;
+			chandle = phandle;
+			acpi_get_parent(phandle, &phandle);
+			if (parent->parent)
+				parent = parent->parent;
+			continue;
+		}
+
+		status = acpi_get_type(chandle, &type);
+		if (ACPI_FAILURE(status))
+			continue;
+
+		/*
+		 * If this is a scope object then parse it (depth-first).
+		 */
+		if (type == ACPI_TYPE_LOCAL_SCOPE) {
+			level++;
+			phandle = chandle;
+			chandle = 0;
+			continue;
+		}
+
+		/*
+		 * We're only interested in objects that we consider 'devices'.
+		 */
+		switch (type) {
+		case ACPI_TYPE_DEVICE:
+			type = ACPI_BUS_TYPE_DEVICE;
+			break;
+		case ACPI_TYPE_PROCESSOR:
+			type = ACPI_BUS_TYPE_PROCESSOR;
+			break;
+		case ACPI_TYPE_THERMAL:
+			type = ACPI_BUS_TYPE_THERMAL;
+			break;
+		case ACPI_TYPE_POWER:
+			type = ACPI_BUS_TYPE_POWER;
+			break;
+		default:
+			continue;
+		}
+
+		status = acpi_bus_add(&child, parent, chandle, type);
+		if (ACPI_FAILURE(status))
+			continue;
+
+		/*
+		 * If the device is present, enabled, and functioning then
+		 * parse its scope (depth-first).  Note that we need to
+		 * represent absent devices to facilitate PnP notifications
+		 * -- but only the subtree head (not all of its children,
+		 * which will be enumerated when the parent is inserted).
+		 *
+		 * TBD: Need notifications and other detection mechanisms
+		 *	in place before we can fully implement this.
+		 */
+		if (child->status.present) {
+			status = acpi_get_next_object(ACPI_TYPE_ANY, chandle,
+				0, NULL);
+			if (ACPI_SUCCESS(status)) {
+				level++;
+				phandle = chandle;
+				chandle = 0;
+				parent = child;
+			}
+		}
+	}
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_bus_scan_fixed (
+	struct acpi_device	*root)
+{
+	int			result = 0;
+	struct acpi_device	*device = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_bus_scan_fixed");
+
+	if (!root)
+		return_VALUE(-ENODEV);
+
+	/*
+	 * Enumerate all fixed-feature devices.
+	 */
+	if (acpi_fadt.pwr_button == 0)
+		result = acpi_bus_add(&device, acpi_root, 
+			NULL, ACPI_BUS_TYPE_POWER_BUTTON);
+
+	if (acpi_fadt.sleep_button == 0)
+		result = acpi_bus_add(&device, acpi_root, 
+			NULL, ACPI_BUS_TYPE_SLEEP_BUTTON);
+
+	return_VALUE(result);
+}
+
+
+/* --------------------------------------------------------------------------
+                             Initialization/Cleanup
+   -------------------------------------------------------------------------- */
+
+static int __init
+acpi_bus_init_irq (void)
+{
+	acpi_status		status = AE_OK;
+	union acpi_object	arg = {ACPI_TYPE_INTEGER};
+	struct acpi_object_list	arg_list = {1, &arg};
+	char			*message = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_bus_init_irq");
+
+	/* 
+	 * Let the system know what interrupt model we are using by
+	 * evaluating the \_PIC object, if exists.
+	 */
+
+	switch (acpi_irq_model) {
+	case ACPI_IRQ_MODEL_PIC:
+		message = "PIC";
+		break;
+	case ACPI_IRQ_MODEL_IOAPIC:
+		message = "IOAPIC";
+		break;
+	case ACPI_IRQ_MODEL_IOSAPIC:
+		message = "IOSAPIC";
+		break;
+	default:
+		printk(KERN_WARNING PREFIX "Unknown interrupt routing model\n");
+		return_VALUE(-ENODEV);
+	}
+
+	printk(KERN_INFO PREFIX "Using %s for interrupt routing\n", message);
+
+	arg.integer.value = acpi_irq_model;
+
+	status = acpi_evaluate_object(NULL, "\\_PIC", &arg_list, NULL);
+	if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PIC\n"));
+		return_VALUE(-ENODEV);
+	}
+
+	return_VALUE(0);
+}
+
+
+static int __init
+acpi_bus_init (void)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	struct acpi_buffer	buffer = {sizeof(acpi_fadt), &acpi_fadt};
+
+	ACPI_FUNCTION_TRACE("acpi_bus_init");
+
+	status = acpi_initialize_subsystem();
+	if (ACPI_FAILURE(status)) {
+		printk(KERN_ERR PREFIX "Unable to initialize the ACPI Interpreter\n");
+		goto error0;
+	}
+
+	status = acpi_load_tables();
+	if (ACPI_FAILURE(status)) {
+		printk(KERN_ERR PREFIX "Unable to load the System Description Tables\n");
+		goto error0;
+	}
+
+	/*
+	 * Get a separate copy of the FADT for use by other drivers.
+	 */
+	status = acpi_get_table(ACPI_TABLE_FADT, 1, &buffer);
+	if (ACPI_FAILURE(status)) {
+		printk(KERN_ERR PREFIX "Unable to get the FADT\n");
+		goto error1;
+	}
+
+#ifdef CONFIG_X86
+        /* Ensure the SCI is set to level-triggered, active-low */
+        if (acpi_ioapic)
+         	mp_config_ioapic_for_sci(acpi_fadt.sci_int);
+	else
+                eisa_set_level_irq(acpi_fadt.sci_int);
+#endif
+
+	status = acpi_enable_subsystem(ACPI_FULL_INITIALIZATION);
+	if (ACPI_FAILURE(status)) {
+		printk(KERN_ERR PREFIX "Unable to start the ACPI Interpreter\n");
+		goto error1;
+	}
+
+#ifdef CONFIG_ACPI_EC
+	/*
+	 * ACPI 2.0 requires the EC driver to be loaded and work before
+	 * the EC device is found in the namespace. This is accomplished
+	 * by looking for the ECDT table, and getting the EC parameters out
+	 * of that.
+	 */
+	result = acpi_ec_ecdt_probe();
+	if (result) {
+		goto error1;
+	}
+#endif
+
+	status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION);
+	if (ACPI_FAILURE(status)) {
+		printk(KERN_ERR PREFIX "Unable to initialize ACPI objects\n");
+		goto error1;
+	}
+
+	printk(KERN_INFO PREFIX "Interpreter enabled\n");
+
+	/*
+	 * Get the system interrupt model and evaluate \_PIC.
+	 */
+	result = acpi_bus_init_irq();
+	if (result)
+		goto error1;
+
+	/*
+	 * Register the for all standard device notifications.
+	 */
+	status = acpi_install_notify_handler(ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, &acpi_bus_notify, NULL);
+	if (ACPI_FAILURE(status)) {
+		printk(KERN_ERR PREFIX "Unable to register for device notifications\n");
+		result = -ENODEV;
+		goto error1;
+	}
+
+	/*
+	 * Create the root device in the bus's device tree
+	 */
+	result = acpi_bus_add(&acpi_root, NULL, ACPI_ROOT_OBJECT, 
+		ACPI_BUS_TYPE_SYSTEM);
+	if (result)
+		goto error2;
+
+	/*
+	 * Create the top ACPI proc directory
+	 */
+	acpi_device_dir(acpi_root) = proc_mkdir(ACPI_BUS_FILE_ROOT, NULL);
+	if (!acpi_root) {
+		result = -ENODEV;
+		goto error3;
+	}
+	acpi_root_dir = acpi_device_dir(acpi_root);
+
+	/*
+	 * Install drivers required for proper enumeration of the
+	 * ACPI namespace.
+	 */
+	acpi_system_init();	/* ACPI System */
+	acpi_power_init();	/* ACPI Bus Power Management */
+#ifdef CONFIG_ACPI_EC
+	acpi_ec_init();		/* ACPI Embedded Controller */
+#endif
+#ifdef CONFIG_ACPI_PCI
+	acpi_pci_link_init();	/* ACPI PCI Interrupt Link */
+	acpi_pci_root_init();	/* ACPI PCI Root Bridge */
+#endif
+	/*
+	 * Enumerate devices in the ACPI namespace.
+	 */
+	result = acpi_bus_scan_fixed(acpi_root);
+	if (result)
+		goto error4;
+	result = acpi_bus_scan(acpi_root);
+	if (result)
+		goto error4;
+
+	return_VALUE(0);
+
+	/* Mimic structured exception handling */
+error4:
+	remove_proc_entry(ACPI_BUS_FILE_ROOT, NULL);
+error3:
+	acpi_bus_remove(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
+error2:
+	acpi_remove_notify_handler(ACPI_ROOT_OBJECT,
+		ACPI_SYSTEM_NOTIFY, &acpi_bus_notify);
+error1:
+	acpi_terminate();
+error0:
+	return_VALUE(-ENODEV);
+}
+
+
+static void __exit
+acpi_bus_exit (void)
+{
+	acpi_status		status = AE_OK;
+
+	ACPI_FUNCTION_TRACE("acpi_bus_exit");
+
+	status = acpi_remove_notify_handler(ACPI_ROOT_OBJECT,
+		ACPI_SYSTEM_NOTIFY, acpi_bus_notify);
+	if (ACPI_FAILURE(status))
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Error removing notify handler\n"));
+
+#ifdef CONFIG_ACPI_PCI
+	acpi_pci_root_exit();
+	acpi_pci_link_exit();
+#endif
+#ifdef CONFIG_ACPI_EC
+	acpi_ec_exit();
+#endif
+	acpi_power_exit();
+	acpi_system_exit();
+
+	acpi_bus_remove(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
+
+	remove_proc_entry(ACPI_BUS_FILE_ROOT, NULL);
+
+	status = acpi_terminate();
+	if (ACPI_FAILURE(status))
+		printk(KERN_ERR PREFIX "Unable to terminate the ACPI Interpreter\n");
+	else
+		printk(KERN_ERR PREFIX "Interpreter disabled\n");
+
+	return_VOID;
+}
+
+
+int __init
+acpi_init (void)
+{
+	int			result = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_init");
+
+	printk(KERN_INFO PREFIX "Subsystem revision %08x\n",
+		ACPI_CA_VERSION);
+
+	/* Initial core debug level excludes drivers, so include them now */
+	acpi_set_debug(ACPI_DEBUG_LOW);
+
+	if (acpi_disabled) {
+		printk(KERN_INFO PREFIX "Disabled via command line (acpi=off)\n");
+		return -ENODEV;
+	}
+
+#ifdef CONFIG_PM
+	if (PM_IS_ACTIVE()) {
+		printk(KERN_INFO PREFIX "APM is already active, exiting\n");
+		return -ENODEV;
+	}
+#endif
+
+	result = acpi_bus_init();
+	if (result)
+		return_VALUE(result);
+
+#ifdef CONFIG_PM
+	pm_active = 1;
+#endif
+
+	return_VALUE(0);
+}
+
+
+void __exit
+acpi_exit (void)
+{
+	ACPI_FUNCTION_TRACE("acpi_exit");
+
+#ifdef CONFIG_PM
+	pm_active = 0;
+#endif
+
+	acpi_bus_exit();
+
+	return_VOID;
+}
+
+
+int __init
+acpi_setup(char *str)
+{
+	while (str && *str) {
+		if (strncmp(str, "off", 3) == 0)
+			acpi_disabled = 1;
+		str = strchr(str, ',');
+		if (str)
+			str += strspn(str, ", \t");
+	}
+	return 1;
+}
+
+
+__setup("acpi=", acpi_setup);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/button.c linux-2.4.22-pre2/drivers/acpi/button.c
--- linux-2.4.21/drivers/acpi/button.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/button.c	2003-06-26 21:43:30.000000000 +0000
@@ -0,0 +1,498 @@
+/*
+ *  acpi_button.c - ACPI Button Driver ($Revision: 29 $)
+ *
+ *  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/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/compatmac.h>
+#include <linux/proc_fs.h>
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+
+
+#define _COMPONENT		ACPI_BUTTON_COMPONENT
+ACPI_MODULE_NAME		("acpi_button")
+
+MODULE_AUTHOR("Paul Diefenbaugh");
+MODULE_DESCRIPTION(ACPI_BUTTON_DRIVER_NAME);
+MODULE_LICENSE("GPL");
+
+#define PREFIX			"ACPI: "
+
+
+static int acpi_button_add (struct acpi_device *device);
+static int acpi_button_remove (struct acpi_device *device, int type);
+
+static struct acpi_driver acpi_button_driver = {
+	.name =		ACPI_BUTTON_DRIVER_NAME,
+	.class =	ACPI_BUTTON_CLASS,
+	.ids =		"ACPI_FPB,ACPI_FSB,PNP0C0D,PNP0C0C,PNP0C0E",
+	.ops =		{
+				.add =		acpi_button_add,
+				.remove =	acpi_button_remove,
+			},
+};
+
+struct acpi_button {
+	acpi_handle		handle;
+	struct acpi_device	*device;	/* Fixed button kludge */
+	u8			type;
+	unsigned long		pushed;
+};
+
+
+/* --------------------------------------------------------------------------
+                              FS Interface (/proc)
+   -------------------------------------------------------------------------- */
+
+static struct proc_dir_entry	*acpi_button_dir = NULL;
+
+static int
+acpi_button_read_info (
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	struct acpi_button	*button = (struct acpi_button *) data;
+	char			*p = page;
+	int			len = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_button_read_info");
+
+	if (!button || !button->device)
+		goto end;
+
+	p += sprintf(p, "type:                    %s\n", 
+		acpi_device_name(button->device));
+
+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);
+}
+
+static int
+acpi_button_lid_read_state(
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	struct acpi_button	*button = (struct acpi_button *) data;
+	char			*p = page;
+	int			len = 0;
+	acpi_status		status=AE_OK;
+	unsigned long		state;
+
+	ACPI_FUNCTION_TRACE("acpi_button_lid_read_state");
+
+	if (!button || !button->device)
+		goto end;
+
+	status=acpi_evaluate_integer(button->handle,"_LID",NULL,&state);
+	if (ACPI_FAILURE(status)){
+	    p += sprintf(p, "state:      unsupported\n");
+	}
+	else{
+	    p += sprintf(p, "state:      %s\n", (state ? "open" : "closed")); 
+	}
+
+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);
+}
+
+static int
+acpi_button_add_fs (
+	struct acpi_device	*device)
+{
+	struct proc_dir_entry	*entry = NULL;
+	struct acpi_button	*button = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_button_add_fs");
+
+	if (!device || !acpi_driver_data(device))
+		return_VALUE(-EINVAL);
+
+	button = acpi_driver_data(device);
+
+	switch (button->type) {
+	case ACPI_BUTTON_TYPE_POWER:
+	case ACPI_BUTTON_TYPE_POWERF:
+			entry = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER, 
+				acpi_button_dir);
+		break;
+	case ACPI_BUTTON_TYPE_SLEEP:
+	case ACPI_BUTTON_TYPE_SLEEPF:
+			entry = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP, 
+				acpi_button_dir);
+		break;
+	case ACPI_BUTTON_TYPE_LID:
+			entry = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID, 
+				acpi_button_dir);
+		break;
+	}
+
+	acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry);
+	if (!acpi_device_dir(device))
+		return_VALUE(-ENODEV);
+
+	/* 'info' [R] */
+	entry = create_proc_entry(ACPI_BUTTON_FILE_INFO,
+		S_IRUGO, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_BUTTON_FILE_INFO));
+	else {
+		entry->read_proc = acpi_button_read_info;
+		entry->data = acpi_driver_data(device);
+	}
+	
+	if (button->type==ACPI_BUTTON_TYPE_LID){
+	    /* 'state' [R] */
+	    entry = create_proc_entry(ACPI_BUTTON_FILE_STATE,
+			S_IRUGO, acpi_device_dir(device));
+	    if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			  "Unable to create '%s' fs entry\n",
+			   ACPI_BUTTON_FILE_STATE));
+	    else {
+		entry->read_proc = acpi_button_lid_read_state;
+		entry->data = acpi_driver_data(device);
+	    }
+	}
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_button_remove_fs (
+	struct acpi_device	*device)
+{
+	ACPI_FUNCTION_TRACE("acpi_button_remove_fs");
+
+	if (acpi_device_dir(device)) {
+		remove_proc_entry(acpi_device_bid(device), acpi_button_dir);
+		acpi_device_dir(device) = NULL;
+	}
+
+	return_VALUE(0);
+}
+
+
+/* --------------------------------------------------------------------------
+                                Driver Interface
+   -------------------------------------------------------------------------- */
+
+void
+acpi_button_notify (
+	acpi_handle		handle,
+	u32			event,
+	void			*data)
+{
+	struct acpi_button	*button = (struct acpi_button *) data;
+
+	ACPI_FUNCTION_TRACE("acpi_button_notify");
+
+	if (!button || !button->device)
+		return_VOID;
+
+	switch (event) {
+	case ACPI_BUTTON_NOTIFY_STATUS:
+		acpi_bus_generate_event(button->device, event, ++button->pushed);
+		break;
+	default:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+			"Unsupported event [0x%x]\n", event));
+		break;
+	}
+
+	return_VOID;
+}
+
+
+acpi_status
+acpi_button_notify_fixed (
+	void			*data)
+{
+	struct acpi_button	*button = (struct acpi_button *) data;
+	
+	ACPI_FUNCTION_TRACE("acpi_button_notify_fixed");
+
+	if (!button)
+		return_ACPI_STATUS(AE_BAD_PARAMETER);
+
+	acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button);
+
+	return_ACPI_STATUS(AE_OK);
+}
+
+
+static int
+acpi_button_add (
+	struct acpi_device	*device)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	struct acpi_button	*button = NULL;
+
+	static struct acpi_device *power_button;
+	static struct acpi_device *sleep_button;
+	static struct acpi_device *lid_button;
+
+	ACPI_FUNCTION_TRACE("acpi_button_add");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	button = kmalloc(sizeof(struct acpi_button), GFP_KERNEL);
+	if (!button)
+		return_VALUE(-ENOMEM);
+	memset(button, 0, sizeof(struct acpi_button));
+
+	button->device = device;
+	button->handle = device->handle;
+	acpi_driver_data(device) = button;
+
+	/*
+	 * Determine the button type (via hid), as fixed-feature buttons
+	 * need to be handled a bit differently than generic-space.
+	 */
+	if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWER)) {
+		button->type = ACPI_BUTTON_TYPE_POWER;
+		sprintf(acpi_device_name(device), "%s",
+			ACPI_BUTTON_DEVICE_NAME_POWER);
+		sprintf(acpi_device_class(device), "%s/%s", 
+			ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER);
+	}
+	else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) {
+		button->type = ACPI_BUTTON_TYPE_POWERF;
+		sprintf(acpi_device_name(device), "%s",
+			ACPI_BUTTON_DEVICE_NAME_POWERF);
+		sprintf(acpi_device_class(device), "%s/%s", 
+			ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER);
+	}
+	else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEP)) {
+		button->type = ACPI_BUTTON_TYPE_SLEEP;
+		sprintf(acpi_device_name(device), "%s",
+			ACPI_BUTTON_DEVICE_NAME_SLEEP);
+		sprintf(acpi_device_class(device), "%s/%s", 
+			ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP);
+	}
+	else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) {
+		button->type = ACPI_BUTTON_TYPE_SLEEPF;
+		sprintf(acpi_device_name(device), "%s",
+			ACPI_BUTTON_DEVICE_NAME_SLEEPF);
+		sprintf(acpi_device_class(device), "%s/%s", 
+			ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP);
+	}
+	else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_LID)) {
+		button->type = ACPI_BUTTON_TYPE_LID;
+		sprintf(acpi_device_name(device), "%s",
+			ACPI_BUTTON_DEVICE_NAME_LID);
+		sprintf(acpi_device_class(device), "%s/%s", 
+			ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID);
+	}
+	else {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unsupported hid [%s]\n",
+			acpi_device_hid(device)));
+		result = -ENODEV;
+		goto end;
+	}
+
+	/*
+	 * Ensure only one button of each type is used.
+	 */
+	switch (button->type) {
+	case ACPI_BUTTON_TYPE_POWER:
+	case ACPI_BUTTON_TYPE_POWERF:
+		if (!power_button)
+			power_button = device;
+		else {
+			kfree(button);
+			return_VALUE(-ENODEV);
+		}
+		break;
+	case ACPI_BUTTON_TYPE_SLEEP:
+	case ACPI_BUTTON_TYPE_SLEEPF:
+		if (!sleep_button)
+			sleep_button = device;
+		else {
+			kfree(button);
+			return_VALUE(-ENODEV);
+		}
+		break;
+	case ACPI_BUTTON_TYPE_LID:
+		if (!lid_button)
+			lid_button = device;
+		else {
+			kfree(button);
+			return_VALUE(-ENODEV);
+		}
+		break;
+	}
+
+	result = acpi_button_add_fs(device);
+	if (result)
+		goto end;
+
+	switch (button->type) {
+	case ACPI_BUTTON_TYPE_POWERF:
+		status = acpi_install_fixed_event_handler (
+			ACPI_EVENT_POWER_BUTTON,
+			acpi_button_notify_fixed,
+			button);
+		break;
+	case ACPI_BUTTON_TYPE_SLEEPF:
+		status = acpi_install_fixed_event_handler (
+			ACPI_EVENT_SLEEP_BUTTON,
+			acpi_button_notify_fixed,
+			button);
+		break;
+	default:
+		status = acpi_install_notify_handler (
+			button->handle,
+			ACPI_DEVICE_NOTIFY,
+			acpi_button_notify,
+			button);
+		break;
+	}
+
+	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]\n", 
+		acpi_device_name(device), acpi_device_bid(device));
+
+end:
+	if (result) {
+		acpi_button_remove_fs(device);
+		kfree(button);
+	}
+
+	return_VALUE(result);
+}
+
+
+static int
+acpi_button_remove (struct acpi_device *device, int type)
+{
+	acpi_status		status = 0;
+	struct acpi_button	*button = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_button_remove");
+
+	if (!device || !acpi_driver_data(device))
+		return_VALUE(-EINVAL);
+
+	button = acpi_driver_data(device);
+
+	/* Unregister for device notifications. */
+	switch (button->type) {
+	case ACPI_BUTTON_TYPE_POWERF:
+		status = acpi_remove_fixed_event_handler(
+			ACPI_EVENT_POWER_BUTTON, acpi_button_notify_fixed);
+		break;
+	case ACPI_BUTTON_TYPE_SLEEPF:
+		status = acpi_remove_fixed_event_handler(
+			ACPI_EVENT_SLEEP_BUTTON, acpi_button_notify_fixed);
+		break;
+	default:
+		status = acpi_remove_notify_handler(button->handle,
+			ACPI_DEVICE_NOTIFY, acpi_button_notify);
+		break;
+	}
+
+	if (ACPI_FAILURE(status))
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Error removing notify handler\n"));
+
+	acpi_button_remove_fs(device);	
+
+	kfree(button);
+
+	return_VALUE(0);
+}
+
+
+static int __init
+acpi_button_init (void)
+{
+	int			result = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_button_init");
+
+	acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir);
+	if (!acpi_button_dir)
+		return_VALUE(-ENODEV);
+
+	result = acpi_bus_register_driver(&acpi_button_driver);
+	if (result < 0) {
+		remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
+		return_VALUE(-ENODEV);
+	}
+
+	return_VALUE(0);
+}
+
+
+static void __exit
+acpi_button_exit (void)
+{
+	ACPI_FUNCTION_TRACE("acpi_button_exit");
+
+	acpi_bus_unregister_driver(&acpi_button_driver);
+
+	remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
+
+	return_VOID;
+}
+
+
+module_init(acpi_button_init);
+module_exit(acpi_button_exit);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/debugger/Makefile linux-2.4.22-pre2/drivers/acpi/debugger/Makefile
--- linux-2.4.21/drivers/acpi/debugger/Makefile	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/debugger/Makefile	1970-01-01 00:00:00.000000000 +0000
@@ -1,12 +0,0 @@
-#
-# Makefile for all Linux ACPI interpreter subdirectories
-# EXCEPT for the ospm directory
-#
-
-O_TARGET := $(notdir $(CURDIR)).o
-
-obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
-
-EXTRA_CFLAGS += $(ACPI_CFLAGS)
-
-include $(TOPDIR)/Rules.make
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/debugger/dbcmds.c linux-2.4.22-pre2/drivers/acpi/debugger/dbcmds.c
--- linux-2.4.21/drivers/acpi/debugger/dbcmds.c	2001-10-24 21:06:21.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/debugger/dbcmds.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,996 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: dbcmds - debug commands and output routines
- *              $Revision: 66 $
- *
- ******************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include "acpi.h"
-#include "acparser.h"
-#include "acdispat.h"
-#include "amlcode.h"
-#include "acnamesp.h"
-#include "acparser.h"
-#include "acevents.h"
-#include "acinterp.h"
-#include "acdebug.h"
-#include "actables.h"
-#include "acresrc.h"
-
-#ifdef ENABLE_DEBUGGER
-
-#define _COMPONENT          ACPI_DEBUGGER
-	 MODULE_NAME         ("dbcmds")
-
-
-/*
- * Arguments for the Objects command
- * These object types map directly to the ACPI_TYPES
- */
-
-ARGUMENT_INFO         acpi_db_object_types [] =
-{ {"ANY"},
-	{"NUMBERS"},
-	{"STRINGS"},
-	{"BUFFERS"},
-	{"PACKAGES"},
-	{"FIELDS"},
-	{"DEVICES"},
-	{"EVENTS"},
-	{"METHODS"},
-	{"MUTEXES"},
-	{"REGIONS"},
-	{"POWERRESOURCES"},
-	{"PROCESSORS"},
-	{"THERMALZONES"},
-	{"BUFFERFIELDS"},
-	{"DDBHANDLES"},
-	{NULL}           /* Must be null terminated */
-};
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_walk_for_references
- *
- * PARAMETERS:  Callback from Walk_namespace
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Check if this namespace object refers to the target object
- *              that is passed in as the context value.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_db_walk_for_references (
-	acpi_handle             obj_handle,
-	u32                     nesting_level,
-	void                    *context,
-	void                    **return_value)
-{
-	acpi_operand_object     *obj_desc = (acpi_operand_object *) context;
-	acpi_namespace_node     *node = (acpi_namespace_node *) obj_handle;
-
-
-	/* Check for match against the namespace node itself */
-
-	if (node == (void *) obj_desc) {
-		acpi_os_printf ("Object is a Node [%4.4s]\n", &node->name);
-	}
-
-	/* Check for match against the object attached to the node */
-
-	if (node->object == obj_desc) {
-		acpi_os_printf ("Reference at Node->Object %p [%4.4s]\n", node, &node->name);
-	}
-
-	/* Check first child for a match */
-	/* TBD: [Investigate] probably now obsolete with new datastructure */
-
-	if (node->child == (void *) obj_desc) {
-		acpi_os_printf ("Reference at Node->Child %p [%4.4s]\n", node, &node->name);
-	}
-
-	return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_find_references
- *
- * PARAMETERS:  Object_arg      - String with hex value of the object
- *
- * RETURN:      None
- *
- * DESCRIPTION: Search namespace for all references to the input object
- *
- ******************************************************************************/
-
-void
-acpi_db_find_references (
-	NATIVE_CHAR             *object_arg)
-{
-	acpi_operand_object     *obj_desc;
-
-
-	/* Convert string to object pointer */
-
-	obj_desc = (acpi_operand_object *) STRTOUL (object_arg, NULL, 16);
-
-	/* Search all nodes in namespace */
-
-	acpi_walk_namespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
-			  acpi_db_walk_for_references, (void *) obj_desc, NULL);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_display_locks
- *
- * PARAMETERS:  None
- *
- * RETURN:      None
- *
- * DESCRIPTION: Display information about internal mutexes.
- *
- ******************************************************************************/
-
-void
-acpi_db_display_locks (void)
-{
-	u32                     i;
-
-
-	for (i = 0; i < MAX_MTX; i++) {
-		acpi_os_printf ("%26s : %s\n", acpi_ut_get_mutex_name (i),
-				 acpi_gbl_acpi_mutex_info[i].owner_id == ACPI_MUTEX_NOT_ACQUIRED
-						? "Locked" : "Unlocked");
-	}
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_display_table_info
- *
- * PARAMETERS:  Table_arg       - String with name of table to be displayed
- *
- * RETURN:      None
- *
- * DESCRIPTION: Display information about loaded tables.  Current
- *              implementation displays all loaded tables.
- *
- ******************************************************************************/
-
-void
-acpi_db_display_table_info (
-	NATIVE_CHAR             *table_arg)
-{
-	u32                     i;
-
-
-	for (i = 0; i < NUM_ACPI_TABLES; i++) {
-		if (acpi_gbl_acpi_tables[i].pointer) {
-			acpi_os_printf ("%s at %p length %X\n", acpi_gbl_acpi_table_data[i].name,
-					 acpi_gbl_acpi_tables[i].pointer, acpi_gbl_acpi_tables[i].length);
-		}
-	}
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_unload_acpi_table
- *
- * PARAMETERS:  Table_arg       - Name of the table to be unloaded
- *              Instance_arg    - Which instance of the table to unload (if
- *                                there are multiple tables of the same type)
- *
- * RETURN:      Nonde
- *
- * DESCRIPTION: Unload an ACPI table.
- *              Instance is not implemented
- *
- ******************************************************************************/
-
-void
-acpi_db_unload_acpi_table (
-	NATIVE_CHAR             *table_arg,
-	NATIVE_CHAR             *instance_arg)
-{
-	u32                     i;
-	acpi_status             status;
-
-
-	/* Search all tables for the target type */
-
-	for (i = 0; i < NUM_ACPI_TABLES; i++) {
-		if (!STRNCMP (table_arg, acpi_gbl_acpi_table_data[i].signature,
-				acpi_gbl_acpi_table_data[i].sig_length)) {
-			/* Found the table, unload it */
-
-			status = acpi_unload_table (i);
-			if (ACPI_SUCCESS (status)) {
-				acpi_os_printf ("[%s] unloaded and uninstalled\n", table_arg);
-			}
-			else {
-				acpi_os_printf ("%s, while unloading [%s]\n",
-					acpi_format_exception (status), table_arg);
-			}
-
-			return;
-		}
-	}
-
-	acpi_os_printf ("Unknown table type [%s]\n", table_arg);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_set_method_breakpoint
- *
- * PARAMETERS:  Location            - AML offset of breakpoint
- *              Walk_state          - Current walk info
- *              Op                  - Current Op (from parse walk)
- *
- * RETURN:      None
- *
- * DESCRIPTION: Set a breakpoint in a control method at the specified
- *              AML offset
- *
- ******************************************************************************/
-
-void
-acpi_db_set_method_breakpoint (
-	NATIVE_CHAR             *location,
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op)
-{
-	u32                     address;
-
-
-	if (!op) {
-		acpi_os_printf ("There is no method currently executing\n");
-		return;
-	}
-
-	/* Get and verify the breakpoint address */
-
-	address = STRTOUL (location, NULL, 16);
-	if (address <= op->aml_offset) {
-		acpi_os_printf ("Breakpoint %X is beyond current address %X\n", address, op->aml_offset);
-	}
-
-	/* Save breakpoint in current walk */
-
-	walk_state->method_breakpoint = address;
-	acpi_os_printf ("Breakpoint set at AML offset %X\n", address);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_set_method_call_breakpoint
- *
- * PARAMETERS:  Op                  - Current Op (from parse walk)
- *
- * RETURN:      None
- *
- * DESCRIPTION: Set a breakpoint in a control method at the specified
- *              AML offset
- *
- ******************************************************************************/
-
-void
-acpi_db_set_method_call_breakpoint (
-	acpi_parse_object       *op)
-{
-
-
-	if (!op) {
-		acpi_os_printf ("There is no method currently executing\n");
-		return;
-	}
-
-
-	acpi_gbl_step_to_next_call = TRUE;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_disassemble_aml
- *
- * PARAMETERS:  Statements          - Number of statements to disassemble
- *              Op                  - Current Op (from parse walk)
- *
- * RETURN:      None
- *
- * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
- *              of statements specified.
- *
- ******************************************************************************/
-
-void
-acpi_db_disassemble_aml (
-	NATIVE_CHAR             *statements,
-	acpi_parse_object       *op)
-{
-	u32                     num_statements = 8;
-
-
-	if (!op) {
-		acpi_os_printf ("There is no method currently executing\n");
-		return;
-	}
-
-	if (statements) {
-		num_statements = STRTOUL (statements, NULL, 0);
-	}
-
-
-	acpi_db_display_op (NULL, op, num_statements);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_dump_namespace
- *
- * PARAMETERS:  Start_arg       - Node to begin namespace dump
- *              Depth_arg       - Maximum tree depth to be dumped
- *
- * RETURN:      None
- *
- * DESCRIPTION: Dump entire namespace or a subtree.  Each node is displayed
- *              with type and other information.
- *
- ******************************************************************************/
-
-void
-acpi_db_dump_namespace (
-	NATIVE_CHAR             *start_arg,
-	NATIVE_CHAR             *depth_arg)
-{
-	acpi_handle             subtree_entry = acpi_gbl_root_node;
-	u32                     max_depth = ACPI_UINT32_MAX;
-
-
-	/* No argument given, just start at the root and dump entire namespace */
-
-	if (start_arg) {
-		/* Check if numeric argument, must be a Node */
-
-		if ((start_arg[0] >= 0x30) && (start_arg[0] <= 0x39)) {
-			subtree_entry = (acpi_handle) STRTOUL (start_arg, NULL, 16);
-			if (!acpi_os_readable (subtree_entry, sizeof (acpi_namespace_node))) {
-				acpi_os_printf ("Address %p is invalid in this address space\n", subtree_entry);
-				return;
-			}
-
-			if (!VALID_DESCRIPTOR_TYPE ((subtree_entry), ACPI_DESC_TYPE_NAMED)) {
-				acpi_os_printf ("Address %p is not a valid Named object\n", subtree_entry);
-				return;
-			}
-		}
-
-		/* Alpha argument */
-
-		else {
-			/* The parameter is a name string that must be resolved to a Named obj*/
-
-			subtree_entry = acpi_db_local_ns_lookup (start_arg);
-			if (!subtree_entry) {
-				subtree_entry = acpi_gbl_root_node;
-			}
-		}
-
-		/* Now we can check for the depth argument */
-
-		if (depth_arg) {
-			max_depth = STRTOUL (depth_arg, NULL, 0);
-		}
-	}
-
-
-	acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT);
-	acpi_os_printf ("ACPI Namespace (from %p subtree):\n", subtree_entry);
-
-	/* Display the subtree */
-
-	acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT);
-	acpi_ns_dump_objects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, max_depth, ACPI_UINT32_MAX, subtree_entry);
-	acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_dump_namespace_by_owner
- *
- * PARAMETERS:  Owner_arg       - Owner ID whose nodes will be displayed
- *              Depth_arg       - Maximum tree depth to be dumped
- *
- * RETURN:      None
- *
- * DESCRIPTION: Dump elements of the namespace that are owned by the Owner_id.
- *
- ******************************************************************************/
-
-void
-acpi_db_dump_namespace_by_owner (
-	NATIVE_CHAR             *owner_arg,
-	NATIVE_CHAR             *depth_arg)
-{
-	acpi_handle             subtree_entry = acpi_gbl_root_node;
-	u32                     max_depth = ACPI_UINT32_MAX;
-	u16                     owner_id;
-
-
-	owner_id = (u16) STRTOUL (owner_arg, NULL, 0);
-
-
-	/* Now we can check for the depth argument */
-
-	if (depth_arg) {
-		max_depth = STRTOUL (depth_arg, NULL, 0);
-	}
-
-
-	acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT);
-	acpi_os_printf ("ACPI Namespace by owner %X:\n", owner_id);
-
-	/* Display the subtree */
-
-	acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT);
-	acpi_ns_dump_objects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, max_depth, owner_id, subtree_entry);
-	acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_send_notify
- *
- * PARAMETERS:  Name            - Name of ACPI object to send the notify to
- *              Value           - Value of the notify to send.
- *
- * RETURN:      None
- *
- * DESCRIPTION: Send an ACPI notification.  The value specified is sent to the
- *              named object as an ACPI notify.
- *
- ******************************************************************************/
-
-void
-acpi_db_send_notify (
-	NATIVE_CHAR             *name,
-	u32                     value)
-{
-	acpi_namespace_node     *node;
-
-
-	/* Translate name to an Named object */
-
-	node = acpi_db_local_ns_lookup (name);
-	if (!node) {
-		return;
-	}
-
-	/* Decode Named object type */
-
-	switch (node->type) {
-	case ACPI_TYPE_DEVICE:
-	case ACPI_TYPE_THERMAL:
-
-		 /* Send the notify */
-
-		acpi_ev_queue_notify_request (node, value);
-		break;
-
-	default:
-		acpi_os_printf ("Named object is not a device or a thermal object\n");
-		break;
-	}
-
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_set_method_data
- *
- * PARAMETERS:  Type_arg        - L for local, A for argument
- *              Index_arg       - which one
- *              Value_arg       - Value to set.
- *
- * RETURN:      None
- *
- * DESCRIPTION: Set a local or argument for the running control method.
- *              NOTE: only object supported is Number.
- *
- ******************************************************************************/
-
-void
-acpi_db_set_method_data (
-	NATIVE_CHAR             *type_arg,
-	NATIVE_CHAR             *index_arg,
-	NATIVE_CHAR             *value_arg)
-{
-	NATIVE_CHAR             type;
-	u32                     index;
-	u32                     value;
-	acpi_walk_state         *walk_state;
-	acpi_operand_object     *obj_desc;
-
-
-	/* Validate Type_arg */
-
-	STRUPR (type_arg);
-	type = type_arg[0];
-	if ((type != 'L') &&
-		(type != 'A')) {
-		acpi_os_printf ("Invalid SET operand: %s\n", type_arg);
-		return;
-	}
-
-	/* Get the index and value */
-
-	index = STRTOUL (index_arg, NULL, 16);
-	value = STRTOUL (value_arg, NULL, 16);
-
-	walk_state = acpi_ds_get_current_walk_state (acpi_gbl_current_walk_list);
-	if (!walk_state) {
-		acpi_os_printf ("There is no method currently executing\n");
-		return;
-	}
-
-
-	/* Create and initialize the new object */
-
-	obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
-	if (!obj_desc) {
-		acpi_os_printf ("Could not create an internal object\n");
-		return;
-	}
-
-	obj_desc->integer.value = value;
-
-
-	/* Store the new object into the target */
-
-	switch (type) {
-	case 'A':
-
-		/* Set a method argument */
-
-		if (index > MTH_NUM_ARGS) {
-			acpi_os_printf ("Arg%d - Invalid argument name\n", index);
-			return;
-		}
-
-		acpi_ds_store_object_to_local (AML_ARG_OP, index, obj_desc, walk_state);
-		obj_desc = walk_state->arguments[index].object;
-
-		acpi_os_printf ("Arg%d: ", index);
-		acpi_db_display_internal_object (obj_desc, walk_state);
-		break;
-
-	case 'L':
-
-		/* Set a method local */
-
-		if (index > MTH_NUM_LOCALS) {
-			acpi_os_printf ("Local%d - Invalid local variable name\n", index);
-			return;
-		}
-
-		acpi_ds_store_object_to_local (AML_LOCAL_OP, index, obj_desc, walk_state);
-		obj_desc = walk_state->local_variables[index].object;
-
-		acpi_os_printf ("Local%d: ", index);
-		acpi_db_display_internal_object (obj_desc, walk_state);
-		break;
-
-	default:
-		break;
-	}
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_walk_for_specific_objects
- *
- * PARAMETERS:  Callback from Walk_namespace
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Display short info about objects in the namespace
- *
- ******************************************************************************/
-
-acpi_status
-acpi_db_walk_for_specific_objects (
-	acpi_handle             obj_handle,
-	u32                     nesting_level,
-	void                    *context,
-	void                    **return_value)
-{
-	acpi_operand_object     *obj_desc;
-	acpi_status             status;
-	u32                     buf_size;
-	NATIVE_CHAR             buffer[64];
-
-
-	obj_desc = ((acpi_namespace_node *)obj_handle)->object;
-	buf_size = sizeof (buffer) / sizeof (*buffer);
-
-	/* Get and display the full pathname to this object */
-
-	status = acpi_ns_handle_to_pathname (obj_handle, &buf_size, buffer);
-
-	if (ACPI_FAILURE (status)) {
-		acpi_os_printf ("Could Not get pathname for object %p\n", obj_handle);
-		return (AE_OK);
-	}
-
-	acpi_os_printf ("%32s", buffer);
-
-
-	/* Display short information about the object */
-
-	if (obj_desc) {
-		switch (obj_desc->common.type) {
-		case ACPI_TYPE_METHOD:
-			acpi_os_printf (" #Args %d Concurrency %X", obj_desc->method.param_count, obj_desc->method.concurrency);
-			break;
-
-		case ACPI_TYPE_INTEGER:
-			acpi_os_printf (" Value %X", obj_desc->integer.value);
-			break;
-
-		case ACPI_TYPE_STRING:
-			acpi_os_printf (" \"%s\"", obj_desc->string.pointer);
-			break;
-
-		case ACPI_TYPE_REGION:
-			acpi_os_printf (" Space_id %X Address %X Length %X", obj_desc->region.space_id, obj_desc->region.address, obj_desc->region.length);
-			break;
-
-		case ACPI_TYPE_PACKAGE:
-			acpi_os_printf (" #Elements %X", obj_desc->package.count);
-			break;
-
-		case ACPI_TYPE_BUFFER:
-			acpi_os_printf (" Length %X", obj_desc->buffer.length);
-			break;
-		}
-	}
-
-	acpi_os_printf ("\n");
-	return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_display_objects
- *
- * PARAMETERS:  Obj_type_arg        - Type of object to display
- *              Display_count_arg   - Max depth to display
- *
- * RETURN:      None
- *
- * DESCRIPTION: Display objects in the namespace of the requested type
- *
- ******************************************************************************/
-
-acpi_status
-acpi_db_display_objects (
-	NATIVE_CHAR             *obj_type_arg,
-	NATIVE_CHAR             *display_count_arg)
-{
-	acpi_object_type8       type;
-
-
-	/* Get the object type */
-
-	type = acpi_db_match_argument (obj_type_arg, acpi_db_object_types);
-	if (type == ACPI_TYPE_NOT_FOUND) {
-		acpi_os_printf ("Invalid or unsupported argument\n");
-		return (AE_OK);
-	}
-
-	acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT);
-	acpi_os_printf ("Objects of type [%s] defined in the current ACPI Namespace: \n", acpi_ut_get_type_name (type));
-
-	acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT);
-
-	/* Walk the namespace from the root */
-
-	acpi_walk_namespace (type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
-			   acpi_db_walk_for_specific_objects, (void *) &type, NULL);
-
-	acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
-	return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_walk_and_match_name
- *
- * PARAMETERS:  Callback from Walk_namespace
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Find a particular name/names within the namespace.  Wildcards
- *              are supported -- '?' matches any character.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_db_walk_and_match_name (
-	acpi_handle             obj_handle,
-	u32                     nesting_level,
-	void                    *context,
-	void                    **return_value)
-{
-	acpi_status             status;
-	NATIVE_CHAR             *requested_name = (NATIVE_CHAR *) context;
-	u32                     i;
-	u32                     buf_size;
-	NATIVE_CHAR             buffer[96];
-
-
-	/* Check for a name match */
-
-	for (i = 0; i < 4; i++) {
-		/* Wildcard support */
-
-		if ((requested_name[i] != '?') &&
-			(requested_name[i] != ((NATIVE_CHAR *) (&((acpi_namespace_node *) obj_handle)->name))[i])) {
-			/* No match, just exit */
-
-			return (AE_OK);
-		}
-	}
-
-
-	/* Get the full pathname to this object */
-
-	buf_size = sizeof (buffer) / sizeof (*buffer);
-
-	status = acpi_ns_handle_to_pathname (obj_handle, &buf_size, buffer);
-	if (ACPI_FAILURE (status)) {
-		acpi_os_printf ("Could Not get pathname for object %p\n", obj_handle);
-	}
-
-	else {
-		acpi_os_printf ("%32s (%p) - %s\n", buffer, obj_handle,
-			acpi_ut_get_type_name (((acpi_namespace_node *) obj_handle)->type));
-	}
-
-	return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_find_name_in_namespace
- *
- * PARAMETERS:  Name_arg        - The 4-character ACPI name to find.
- *                                wildcards are supported.
- *
- * RETURN:      None
- *
- * DESCRIPTION: Search the namespace for a given name (with wildcards)
- *
- ******************************************************************************/
-
-acpi_status
-acpi_db_find_name_in_namespace (
-	NATIVE_CHAR             *name_arg)
-{
-
-	if (STRLEN (name_arg) > 4) {
-		acpi_os_printf ("Name must be no longer than 4 characters\n");
-		return (AE_OK);
-	}
-
-	/* Walk the namespace from the root */
-
-	acpi_walk_namespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
-			   acpi_db_walk_and_match_name, name_arg, NULL);
-
-	acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
-	return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_set_scope
- *
- * PARAMETERS:  Name                - New scope path
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Set the "current scope" as maintained by this utility.
- *              The scope is used as a prefix to ACPI paths.
- *
- ******************************************************************************/
-
-void
-acpi_db_set_scope (
-	NATIVE_CHAR             *name)
-{
-
-	if (!name || name[0] == 0) {
-		acpi_os_printf ("Current scope: %s\n", acpi_gbl_db_scope_buf);
-		return;
-	}
-
-	acpi_db_prep_namestring (name);
-
-	/* TBD: [Future] Validate scope here */
-
-	if (name[0] == '\\') {
-		STRCPY (acpi_gbl_db_scope_buf, name);
-		STRCAT (acpi_gbl_db_scope_buf, "\\");
-	}
-
-	else {
-		STRCAT (acpi_gbl_db_scope_buf, name);
-		STRCAT (acpi_gbl_db_scope_buf, "\\");
-	}
-
-	acpi_os_printf ("New scope: %s\n", acpi_gbl_db_scope_buf);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_display_resources
- *
- * PARAMETERS:  Object_arg      - String with hex value of the object
- *
- * RETURN:      None
- *
- * DESCRIPTION:
- *
- ******************************************************************************/
-
-void
-acpi_db_display_resources (
-	NATIVE_CHAR             *object_arg)
-{
-#ifndef _IA16
-	acpi_operand_object     *obj_desc;
-	acpi_status             status;
-	acpi_buffer             return_obj;
-
-
-	acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT);
-
-	/* Convert string to object pointer */
-
-	obj_desc = (acpi_operand_object *) STRTOUL (object_arg, NULL, 16);
-
-	/* Prepare for a return object of arbitrary size */
-
-	return_obj.pointer          = acpi_gbl_db_buffer;
-	return_obj.length           = ACPI_DEBUG_BUFFER_SIZE;
-
-
-	/* _PRT */
-
-	acpi_os_printf ("Evaluating _PRT\n");
-
-	status = acpi_evaluate_object (obj_desc, "_PRT", NULL, &return_obj);
-	if (ACPI_FAILURE (status)) {
-		acpi_os_printf ("Could not obtain _PRT: %s\n", acpi_format_exception (status));
-		goto get_crs;
-	}
-
-	return_obj.pointer          = acpi_gbl_db_buffer;
-	return_obj.length           = ACPI_DEBUG_BUFFER_SIZE;
-
-	status = acpi_get_irq_routing_table (obj_desc, &return_obj);
-	if (ACPI_FAILURE (status)) {
-		acpi_os_printf ("Get_irq_routing_table failed: %s\n", acpi_format_exception (status));
-	}
-
-	else {
-		acpi_rs_dump_irq_list ((u8 *) acpi_gbl_db_buffer);
-	}
-
-
-	/* _CRS */
-
-get_crs:
-	acpi_os_printf ("Evaluating _CRS\n");
-
-	return_obj.pointer          = acpi_gbl_db_buffer;
-	return_obj.length           = ACPI_DEBUG_BUFFER_SIZE;
-
-	status = acpi_evaluate_object (obj_desc, "_CRS", NULL, &return_obj);
-	if (ACPI_FAILURE (status)) {
-		acpi_os_printf ("Could not obtain _CRS: %s\n", acpi_format_exception (status));
-		goto get_prs;
-	}
-
-	return_obj.pointer          = acpi_gbl_db_buffer;
-	return_obj.length           = ACPI_DEBUG_BUFFER_SIZE;
-
-	status = acpi_get_current_resources (obj_desc, &return_obj);
-	if (ACPI_FAILURE (status)) {
-		acpi_os_printf ("Acpi_get_current_resources failed: %s\n", acpi_format_exception (status));
-	}
-
-	else {
-		acpi_rs_dump_resource_list ((acpi_resource *) acpi_gbl_db_buffer);
-	}
-
-
-	/* _PRS */
-
-get_prs:
-	acpi_os_printf ("Evaluating _PRS\n");
-
-	return_obj.pointer          = acpi_gbl_db_buffer;
-	return_obj.length           = ACPI_DEBUG_BUFFER_SIZE;
-
-	status = acpi_evaluate_object (obj_desc, "_PRS", NULL, &return_obj);
-	if (ACPI_FAILURE (status)) {
-		acpi_os_printf ("Could not obtain _PRS: %s\n", acpi_format_exception (status));
-		goto cleanup;
-	}
-
-	return_obj.pointer          = acpi_gbl_db_buffer;
-	return_obj.length           = ACPI_DEBUG_BUFFER_SIZE;
-
-	status = acpi_get_possible_resources (obj_desc, &return_obj);
-	if (ACPI_FAILURE (status)) {
-		acpi_os_printf ("Acpi_get_possible_resources failed: %s\n", acpi_format_exception (status));
-	}
-
-	else {
-		acpi_rs_dump_resource_list ((acpi_resource *) acpi_gbl_db_buffer);
-	}
-
-
-cleanup:
-
-	acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
-	return;
-#endif
-
-}
-
-
-#endif /* ENABLE_DEBUGGER */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/debugger/dbdisasm.c linux-2.4.22-pre2/drivers/acpi/debugger/dbdisasm.c
--- linux-2.4.21/drivers/acpi/debugger/dbdisasm.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/debugger/dbdisasm.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,715 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: dbdisasm - parser op tree display routines
- *              $Revision: 50 $
- *
- ******************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include "acpi.h"
-#include "acparser.h"
-#include "amlcode.h"
-#include "acnamesp.h"
-#include "acdebug.h"
-
-
-#ifdef ENABLE_DEBUGGER
-
-#define _COMPONENT          ACPI_DEBUGGER
-	 MODULE_NAME         ("dbdisasm")
-
-
-#define MAX_SHOW_ENTRY      128
-#define BLOCK_PAREN         1
-#define BLOCK_BRACE         2
-#define DB_NO_OP_INFO       "            [%2.2d]  "
-#define DB_FULL_OP_INFO     "%5.5X #%4.4X [%2.2d]  "
-
-
-NATIVE_CHAR                 *acpi_gbl_db_disasm_indent = "....";
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_block_type
- *
- * PARAMETERS:  Op              - Object to be examined
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Type of block for this op (parens or braces)
- *
- ******************************************************************************/
-
-u32
-acpi_db_block_type (
-	acpi_parse_object       *op)
-{
-
-	switch (op->opcode) {
-	case AML_METHOD_OP:
-		return (BLOCK_BRACE);
-		break;
-
-	default:
-		break;
-	}
-
-	return (BLOCK_PAREN);
-
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ps_display_object_pathname
- *
- * PARAMETERS:  Op              - Object whose pathname is to be obtained
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Diplay the pathname associated with a named object.  Two
- *              versions. One searches the parse tree (for parser-only
- *              applications suchas Acpi_dump), and the other searches the
- *              ACPI namespace (the parse tree is probably deleted)
- *
- ******************************************************************************/
-
-#ifdef PARSER_ONLY
-
-acpi_status
-acpi_ps_display_object_pathname (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op)
-{
-	acpi_parse_object       *target_op;
-
-
-	/* Search parent tree up to the root if necessary */
-
-	target_op = acpi_ps_find (op, op->value.name, 0, 0);
-	if (!target_op) {
-		/*
-		 * Didn't find the name in the parse tree.  This may be
-		 * a problem, or it may simply be one of the predefined names
-		 * (such as _OS_).  Rather than worry about looking up all
-		 * the predefined names, just display the name as given
-		 */
-		acpi_os_printf (" **** Path not found in parse tree");
-	}
-
-	else {
-		/* The target was found, print the name and complete path */
-
-		acpi_os_printf (" (Path ");
-		acpi_db_display_path (target_op);
-		acpi_os_printf (")");
-	}
-
-	return (AE_OK);
-}
-
-#else
-
-acpi_status
-acpi_ps_display_object_pathname (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op)
-{
-	acpi_status             status;
-	acpi_namespace_node     *node;
-	NATIVE_CHAR             buffer[MAX_SHOW_ENTRY];
-	u32                     buffer_size = MAX_SHOW_ENTRY;
-	u32                     debug_level;
-
-
-	/* Save current debug level so we don't get extraneous debug output */
-
-	debug_level = acpi_dbg_level;
-	acpi_dbg_level = 0;
-
-	/* Just get the Node out of the Op object */
-
-	node = op->node;
-	if (!node) {
-		/* Node not defined in this scope, look it up */
-
-		status = acpi_ns_lookup (walk_state->scope_info, op->value.string, ACPI_TYPE_ANY,
-				  IMODE_EXECUTE, NS_SEARCH_PARENT, walk_state, &(node));
-
-		if (ACPI_FAILURE (status)) {
-			/*
-			 * We can't get the pathname since the object
-			 * is not in the namespace.  This can happen during single
-			 * stepping where a dynamic named object is *about* to be created.
-			 */
-			acpi_os_printf (" [Path not found]");
-			goto exit;
-		}
-
-		/* Save it for next time. */
-
-		op->node = node;
-	}
-
-	/* Convert Named_desc/handle to a full pathname */
-
-	status = acpi_ns_handle_to_pathname (node, &buffer_size, buffer);
-	if (ACPI_FAILURE (status)) {
-		acpi_os_printf ("****Could not get pathname****)");
-		goto exit;
-	}
-
-	acpi_os_printf (" (Path %s)", buffer);
-
-
-exit:
-	/* Restore the debug level */
-
-	acpi_dbg_level = debug_level;
-	return (status);
-}
-
-#endif
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_display_op
- *
- * PARAMETERS:  Origin          - Starting object
- *              Num_opcodes     - Max number of opcodes to be displayed
- *
- * RETURN:      None
- *
- * DESCRIPTION: Display parser object and its children
- *
- ******************************************************************************/
-
-void
-acpi_db_display_op (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *origin,
-	u32                     num_opcodes)
-{
-	acpi_parse_object       *op = origin;
-	acpi_parse_object       *arg;
-	acpi_parse_object       *depth;
-	u32                     depth_count = 0;
-	u32                     last_depth = 0;
-	u32                     i;
-	u32                     j;
-
-
-	if (op) {
-		while (op) {
-			/* indentation */
-
-			depth_count = 0;
-			if (!acpi_gbl_db_opt_verbose) {
-				depth_count++;
-			}
-
-			/* Determine the nesting depth of this argument */
-
-			for (depth = op->parent; depth; depth = depth->parent) {
-				arg = acpi_ps_get_arg (depth, 0);
-				while (arg && arg != origin) {
-					arg = arg->next;
-				}
-
-				if (arg) {
-					break;
-				}
-
-				depth_count++;
-			}
-
-
-			/* Open a new block if we are nested further than last time */
-
-			if (depth_count > last_depth) {
-				VERBOSE_PRINT ((DB_NO_OP_INFO, last_depth));
-				for (i = 0; i < last_depth; i++) {
-					acpi_os_printf ("%s", acpi_gbl_db_disasm_indent);
-				}
-
-				if (acpi_db_block_type (op) == BLOCK_PAREN) {
-					acpi_os_printf ("(\n");
-				}
-				else {
-					acpi_os_printf ("{\n");
-				}
-			}
-
-			/* Close a block if we are nested less than last time */
-
-			else if (depth_count < last_depth) {
-				for (j = 0; j < (last_depth - depth_count); j++) {
-					VERBOSE_PRINT ((DB_NO_OP_INFO, last_depth - j));
-					for (i = 0; i < (last_depth - j - 1); i++) {
-						acpi_os_printf ("%s", acpi_gbl_db_disasm_indent);
-					}
-
-					if (acpi_db_block_type (op) == BLOCK_PAREN) {
-						acpi_os_printf (")\n");
-					}
-					else {
-						acpi_os_printf ("}\n");
-					}
-				}
-			}
-
-			/* In verbose mode, print the AML offset, opcode and depth count */
-
-			VERBOSE_PRINT ((DB_FULL_OP_INFO, (unsigned) op->aml_offset, op->opcode, depth_count));
-
-
-			/* Indent the output according to the depth count */
-
-			for (i = 0; i < depth_count; i++) {
-				acpi_os_printf ("%s", acpi_gbl_db_disasm_indent);
-			}
-
-
-			/* Now print the opcode */
-
-			acpi_db_display_opcode (walk_state, op);
-
-			/* Resolve a name reference */
-
-			if ((op->opcode == AML_INT_NAMEPATH_OP && op->value.name)  &&
-				(op->parent) &&
-				(acpi_gbl_db_opt_verbose)) {
-				acpi_ps_display_object_pathname (walk_state, op);
-			}
-
-			acpi_os_printf ("\n");
-
-			/* Get the next node in the tree */
-
-			op = acpi_ps_get_depth_next (origin, op);
-			last_depth = depth_count;
-
-			num_opcodes--;
-			if (!num_opcodes) {
-				op = NULL;
-			}
-		}
-
-		/* Close the last block(s) */
-
-		depth_count = last_depth -1;
-		for (i = 0; i < last_depth; i++) {
-			VERBOSE_PRINT ((DB_NO_OP_INFO, last_depth - i));
-			for (j = 0; j < depth_count; j++) {
-				acpi_os_printf ("%s", acpi_gbl_db_disasm_indent);
-			}
-			acpi_os_printf ("}\n");
-			depth_count--;
-		}
-
-	}
-
-	else {
-		acpi_db_display_opcode (walk_state, op);
-	}
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_display_namestring
- *
- * PARAMETERS:  Name                - ACPI Name string to store
- *
- * RETURN:      None
- *
- * DESCRIPTION: Display namestring. Handles prefix characters
- *
- ******************************************************************************/
-
-void
-acpi_db_display_namestring (
-	NATIVE_CHAR             *name)
-{
-	u32                     seg_count;
-	u8                      do_dot = FALSE;
-
-
-	if (!name) {
-		acpi_os_printf ("<NULL NAME PTR>");
-		return;
-	}
-
-	if (acpi_ps_is_prefix_char (GET8 (name))) {
-		/* append prefix character */
-
-		acpi_os_printf ("%1c", GET8 (name));
-		name++;
-	}
-
-	switch (GET8 (name)) {
-	case AML_DUAL_NAME_PREFIX:
-		seg_count = 2;
-		name++;
-		break;
-
-	case AML_MULTI_NAME_PREFIX_OP:
-		seg_count = (u32) GET8 (name + 1);
-		name += 2;
-		break;
-
-	default:
-		seg_count = 1;
-		break;
-	}
-
-	while (seg_count--) {
-		/* append Name segment */
-
-		if (do_dot) {
-			/* append dot */
-
-			acpi_os_printf (".");
-		}
-
-		acpi_os_printf ("%4.4s", name);
-		do_dot = TRUE;
-
-		name += 4;
-	}
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_display_path
- *
- * PARAMETERS:  Op                  - Named Op whose path is to be constructed
- *
- * RETURN:      None
- *
- * DESCRIPTION: Walk backwards from current scope and display the name
- *              of each previous level of scope up to the root scope
- *              (like "pwd" does with file systems)
- *
- ******************************************************************************/
-
-void
-acpi_db_display_path (
-	acpi_parse_object       *op)
-{
-	acpi_parse_object       *prev;
-	acpi_parse_object       *search;
-	u32                     name;
-	u8                      do_dot = FALSE;
-	acpi_parse_object       *name_path;
-	const acpi_opcode_info  *op_info;
-
-
-	/* We are only interested in named objects */
-
-	op_info = acpi_ps_get_opcode_info (op->opcode);
-	if (!(op_info->flags & AML_NSNODE)) {
-		return;
-	}
-
-
-	if (op_info->flags & AML_CREATE) {
-		/* Field creation - check for a fully qualified namepath */
-
-		if (op->opcode == AML_CREATE_FIELD_OP) {
-			name_path = acpi_ps_get_arg (op, 3);
-		}
-		else {
-			name_path = acpi_ps_get_arg (op, 2);
-		}
-
-		if ((name_path) &&
-			(name_path->value.string) &&
-			(name_path->value.string[0] == '\\')) {
-			acpi_db_display_namestring (name_path->value.string);
-			return;
-		}
-	}
-
-	prev = NULL;            /* Start with Root Node */
-
-	while (prev != op) {
-		/* Search upwards in the tree to find scope with "prev" as its parent */
-
-		search = op;
-		for (; ;) {
-			if (search->parent == prev) {
-				break;
-			}
-
-			/* Go up one level */
-
-			search = search->parent;
-		}
-
-		if (prev) {
-			op_info = acpi_ps_get_opcode_info (search->opcode);
-			if (!(op_info->flags & AML_FIELD)) {
-				/* below root scope, append scope name */
-
-				if (do_dot) {
-					/* append dot */
-
-					acpi_os_printf (".");
-				}
-
-				if (op_info->flags & AML_CREATE) {
-					if (op->opcode == AML_CREATE_FIELD_OP) {
-						name_path = acpi_ps_get_arg (op, 3);
-					}
-					else {
-						name_path = acpi_ps_get_arg (op, 2);
-					}
-
-					if ((name_path) &&
-						(name_path->value.string)) {
-						acpi_os_printf ("%4.4s", name_path->value.string);
-					}
-				}
-
-				else {
-					name = acpi_ps_get_name (search);
-					acpi_os_printf ("%4.4s", &name);
-				}
-
-				do_dot = TRUE;
-			}
-		}
-
-		prev = search;
-	}
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_display_opcode
- *
- * PARAMETERS:  Op                  - Op that is to be printed
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Store printed op in a Buffer and return its length
- *              (or -1 if out of space)
- *
- * NOTE: Terse mode prints out ASL-like code.  Verbose mode adds more info.
- *
- ******************************************************************************/
-
-void
-acpi_db_display_opcode (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op)
-{
-	u8                      *byte_data;
-	u32                     byte_count;
-	u32                     i;
-	const acpi_opcode_info  *op_info = NULL;
-	u32                     name;
-
-
-	if (!op) {
-		acpi_os_printf ("<NULL OP PTR>");
-	}
-
-
-	/* op and arguments */
-
-	switch (op->opcode) {
-
-	case AML_BYTE_OP:
-
-		if (acpi_gbl_db_opt_verbose) {
-			acpi_os_printf ("(u8) 0x%2.2X", op->value.integer8);
-		}
-
-		else {
-			acpi_os_printf ("0x%2.2X", op->value.integer8);
-		}
-
-		break;
-
-
-	case AML_WORD_OP:
-
-		if (acpi_gbl_db_opt_verbose) {
-			acpi_os_printf ("(u16) 0x%4.4X", op->value.integer16);
-		}
-
-		else {
-			acpi_os_printf ("0x%4.4X", op->value.integer16);
-		}
-
-		break;
-
-
-	case AML_DWORD_OP:
-
-		if (acpi_gbl_db_opt_verbose) {
-			acpi_os_printf ("(u32) 0x%8.8X", op->value.integer32);
-		}
-
-		else {
-			acpi_os_printf ("0x%8.8X", op->value.integer32);
-		}
-
-		break;
-
-
-	case AML_QWORD_OP:
-
-		if (acpi_gbl_db_opt_verbose) {
-			acpi_os_printf ("(u64) 0x%8.8X%8.8X", op->value.integer64.hi,
-					 op->value.integer64.lo);
-		}
-
-		else {
-			acpi_os_printf ("0x%8.8X%8.8X", op->value.integer64.hi,
-					 op->value.integer64.lo);
-		}
-
-		break;
-
-
-	case AML_STRING_OP:
-
-		if (op->value.string) {
-			acpi_os_printf ("\"%s\"", op->value.string);
-		}
-
-		else {
-			acpi_os_printf ("<\"NULL STRING PTR\">");
-		}
-
-		break;
-
-
-	case AML_INT_STATICSTRING_OP:
-
-		if (op->value.string) {
-			acpi_os_printf ("\"%s\"", op->value.string);
-		}
-
-		else {
-			acpi_os_printf ("\"<NULL STATIC STRING PTR>\"");
-		}
-
-		break;
-
-
-	case AML_INT_NAMEPATH_OP:
-
-		acpi_db_display_namestring (op->value.name);
-		break;
-
-
-	case AML_INT_NAMEDFIELD_OP:
-
-		acpi_os_printf ("Named_field (Length 0x%8.8X)  ", op->value.integer32);
-		break;
-
-
-	case AML_INT_RESERVEDFIELD_OP:
-
-		acpi_os_printf ("Reserved_field (Length 0x%8.8X) ", op->value.integer32);
-		break;
-
-
-	case AML_INT_ACCESSFIELD_OP:
-
-		acpi_os_printf ("Access_field (Length 0x%8.8X) ", op->value.integer32);
-		break;
-
-
-	case AML_INT_BYTELIST_OP:
-
-		if (acpi_gbl_db_opt_verbose) {
-			acpi_os_printf ("Byte_list   (Length 0x%8.8X)  ", op->value.integer32);
-		}
-
-		else {
-			acpi_os_printf ("0x%2.2X", op->value.integer32);
-
-			byte_count = op->value.integer32;
-			byte_data = ((acpi_parse2_object *) op)->data;
-
-			for (i = 0; i < byte_count; i++) {
-				acpi_os_printf (", 0x%2.2X", byte_data[i]);
-			}
-		}
-
-		break;
-
-
-	default:
-
-		/* Just get the opcode name and print it */
-
-		op_info = acpi_ps_get_opcode_info (op->opcode);
-		acpi_os_printf ("%s", op_info->name);
-
-
-#ifndef PARSER_ONLY
-		if ((op->opcode == AML_INT_RETURN_VALUE_OP) &&
-			(walk_state->results) &&
-			(walk_state->results->results.num_results)) {
-			acpi_db_decode_internal_object (walk_state->results->results.obj_desc [walk_state->results->results.num_results-1]);
-		}
-#endif
-
-		break;
-	}
-
-	if (!op_info) {
-		/* If there is another element in the list, add a comma */
-
-		if (op->next) {
-			acpi_os_printf (",");
-		}
-	}
-
-	/*
-	 * If this is a named opcode, print the associated name value
-	 */
-	op_info = acpi_ps_get_opcode_info (op->opcode);
-	if (op && (op_info->flags & AML_NAMED)) {
-		name = acpi_ps_get_name (op);
-		acpi_os_printf (" %4.4s", &name);
-
-		if (acpi_gbl_db_opt_verbose) {
-			acpi_os_printf (" (Path \\");
-			acpi_db_display_path (op);
-			acpi_os_printf (")");
-		}
-	}
-}
-
-
-#endif  /* ENABLE_DEBUGGER */
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/debugger/dbdisply.c linux-2.4.22-pre2/drivers/acpi/debugger/dbdisply.c
--- linux-2.4.21/drivers/acpi/debugger/dbdisply.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/debugger/dbdisply.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,794 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: dbdisply - debug display commands
- *              $Revision: 57 $
- *
- ******************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include "acpi.h"
-#include "acparser.h"
-#include "amlcode.h"
-#include "acdispat.h"
-#include "acnamesp.h"
-#include "acparser.h"
-#include "acevents.h"
-#include "acinterp.h"
-#include "acdebug.h"
-
-
-#ifdef ENABLE_DEBUGGER
-
-
-#define _COMPONENT          ACPI_DEBUGGER
-	 MODULE_NAME         ("dbdisply")
-
-
-/******************************************************************************
- *
- * FUNCTION:    Acpi_db_get_pointer
- *
- * PARAMETERS:  Target          - Pointer to string to be converted
- *
- * RETURN:      Converted pointer
- *
- * DESCRIPTION: Convert an ascii pointer value to a real value
- *
- *****************************************************************************/
-
-void *
-acpi_db_get_pointer (
-	void                    *target)
-{
-	void                    *obj_ptr;
-
-
-#ifdef _IA16
-#include <stdio.h>
-
-	/* Have to handle 16-bit pointers of the form segment:offset */
-
-	if (!sscanf (target, "%p", &obj_ptr)) {
-		acpi_os_printf ("Invalid pointer: %s\n", target);
-		return (NULL);
-	}
-
-#else
-
-	/* Simple flat pointer */
-
-	obj_ptr = (void *) STRTOUL (target, NULL, 16);
-
-#endif
-
-	return (obj_ptr);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_dump_parser_descriptor
- *
- * PARAMETERS:  Op              - A parser Op descriptor
- *
- * RETURN:      None
- *
- * DESCRIPTION: Display a formatted parser object
- *
- ******************************************************************************/
-
-void
-acpi_db_dump_parser_descriptor (
-	acpi_parse_object       *op)
-{
-	const acpi_opcode_info  *info;
-
-
-	info = acpi_ps_get_opcode_info (op->opcode);
-
-	acpi_os_printf ("Parser Op Descriptor:\n");
-	acpi_os_printf ("%20.20s : %4.4X\n", "Opcode", op->opcode);
-
-	DEBUG_ONLY_MEMBERS (acpi_os_printf ("%20.20s : %s\n", "Opcode Name", info->name));
-
-	acpi_os_printf ("%20.20s : %p\n", "Value/Arg_list", op->value);
-	acpi_os_printf ("%20.20s : %p\n", "Parent", op->parent);
-	acpi_os_printf ("%20.20s : %p\n", "Next_op", op->next);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_decode_and_display_object
- *
- * PARAMETERS:  Target          - String with object to be displayed.  Names
- *                                and hex pointers are supported.
- *              Output_type     - Byte, Word, Dword, or Qword (B|W|D|Q)
- *
- * RETURN:      None
- *
- * DESCRIPTION: Display a formatted ACPI object
- *
- ******************************************************************************/
-
-void
-acpi_db_decode_and_display_object (
-	NATIVE_CHAR             *target,
-	NATIVE_CHAR             *output_type)
-{
-	void                    *obj_ptr;
-	acpi_namespace_node     *node;
-	u32                     display = DB_BYTE_DISPLAY;
-	NATIVE_CHAR             buffer[80];
-	acpi_buffer             ret_buf;
-	acpi_status             status;
-	u32                     size;
-
-
-	if (!target) {
-		return;
-	}
-
-	/* Decode the output type */
-
-	if (output_type) {
-		STRUPR (output_type);
-		if (output_type[0] == 'W') {
-			display = DB_WORD_DISPLAY;
-		}
-		else if (output_type[0] == 'D') {
-			display = DB_DWORD_DISPLAY;
-		}
-		else if (output_type[0] == 'Q') {
-			display = DB_QWORD_DISPLAY;
-		}
-	}
-
-
-	ret_buf.length = sizeof (buffer);
-	ret_buf.pointer = buffer;
-
-	/* Differentiate between a number and a name */
-
-	if ((target[0] >= 0x30) && (target[0] <= 0x39)) {
-		obj_ptr = acpi_db_get_pointer (target);
-		if (!acpi_os_readable (obj_ptr, 16)) {
-			acpi_os_printf ("Address %p is invalid in this address space\n", obj_ptr);
-			return;
-		}
-
-		/* Decode the object type */
-
-		if (VALID_DESCRIPTOR_TYPE ((obj_ptr), ACPI_DESC_TYPE_NAMED)) {
-			/* This is a Node */
-
-			if (!acpi_os_readable (obj_ptr, sizeof (acpi_namespace_node))) {
-				acpi_os_printf ("Cannot read entire Named object at address %p\n", obj_ptr);
-				return;
-			}
-
-			node = obj_ptr;
-			goto dump_nte;
-		}
-
-		else if (VALID_DESCRIPTOR_TYPE ((obj_ptr), ACPI_DESC_TYPE_INTERNAL)) {
-			/* This is an ACPI OBJECT */
-
-			if (!acpi_os_readable (obj_ptr, sizeof (acpi_operand_object))) {
-				acpi_os_printf ("Cannot read entire ACPI object at address %p\n", obj_ptr);
-				return;
-			}
-
-			acpi_ut_dump_buffer (obj_ptr, sizeof (acpi_operand_object), display, ACPI_UINT32_MAX);
-			acpi_ex_dump_object_descriptor (obj_ptr, 1);
-		}
-
-		else if (VALID_DESCRIPTOR_TYPE ((obj_ptr), ACPI_DESC_TYPE_PARSER)) {
-			/* This is an Parser Op object */
-
-			if (!acpi_os_readable (obj_ptr, sizeof (acpi_parse_object))) {
-				acpi_os_printf ("Cannot read entire Parser object at address %p\n", obj_ptr);
-				return;
-			}
-
-
-			acpi_ut_dump_buffer (obj_ptr, sizeof (acpi_parse_object), display, ACPI_UINT32_MAX);
-			acpi_db_dump_parser_descriptor ((acpi_parse_object *) obj_ptr);
-		}
-
-		else {
-			size = 16;
-			if (acpi_os_readable (obj_ptr, 64)) {
-				size = 64;
-			}
-
-			/* Just dump some memory */
-
-			acpi_ut_dump_buffer (obj_ptr, size, display, ACPI_UINT32_MAX);
-		}
-
-		return;
-	}
-
-
-	/* The parameter is a name string that must be resolved to a Named obj */
-
-	node = acpi_db_local_ns_lookup (target);
-	if (!node) {
-		return;
-	}
-
-
-dump_nte:
-	/* Now dump the Named obj */
-
-	status = acpi_get_name (node, ACPI_FULL_PATHNAME, &ret_buf);
-	if (ACPI_FAILURE (status)) {
-		acpi_os_printf ("Could not convert name to pathname\n");
-	}
-
-	else {
-		acpi_os_printf ("Object (%p) Pathname: %s\n", node, ret_buf.pointer);
-	}
-
-	if (!acpi_os_readable (node, sizeof (acpi_namespace_node))) {
-		acpi_os_printf ("Invalid Named object at address %p\n", node);
-		return;
-	}
-
-	acpi_ut_dump_buffer ((void *) node, sizeof (acpi_namespace_node), display, ACPI_UINT32_MAX);
-	acpi_ex_dump_node (node, 1);
-
-	if (node->object) {
-		acpi_os_printf ("\n_attached Object (%p):\n", node->object);
-		if (!acpi_os_readable (node->object, sizeof (acpi_operand_object))) {
-			acpi_os_printf ("Invalid internal ACPI Object at address %p\n", node->object);
-			return;
-		}
-
-		acpi_ut_dump_buffer ((void *) node->object, sizeof (acpi_operand_object), display, ACPI_UINT32_MAX);
-		acpi_ex_dump_object_descriptor (node->object, 1);
-	}
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_decode_internal_object
- *
- * PARAMETERS:  Obj_desc        - Object to be displayed
- *
- * RETURN:      None
- *
- * DESCRIPTION: Short display of an internal object.  Numbers and Strings.
- *
- ******************************************************************************/
-
-void
-acpi_db_decode_internal_object (
-	acpi_operand_object     *obj_desc)
-{
-	u32                     i;
-
-
-	if (!obj_desc) {
-		return;
-	}
-
-	acpi_os_printf (" %s", acpi_ut_get_type_name (obj_desc->common.type));
-
-	switch (obj_desc->common.type) {
-	case ACPI_TYPE_INTEGER:
-
-		acpi_os_printf (" %.8X%.8X", HIDWORD (obj_desc->integer.value),
-				 LODWORD (obj_desc->integer.value));
-		break;
-
-
-	case ACPI_TYPE_STRING:
-
-		acpi_os_printf ("(%d) \"%.24s",
-				obj_desc->string.length, obj_desc->string.pointer);
-
-		if (obj_desc->string.length > 24)
-		{
-			acpi_os_printf ("...");
-		}
-		else
-		{
-			acpi_os_printf ("\"");
-		}
-		break;
-
-
-	case ACPI_TYPE_BUFFER:
-
-		acpi_os_printf ("(%d)", obj_desc->buffer.length);
-		for (i = 0; (i < 8) && (i < obj_desc->buffer.length); i++) {
-			acpi_os_printf (" %2.2X", obj_desc->buffer.pointer[i]);
-		}
-		break;
-	}
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_display_internal_object
- *
- * PARAMETERS:  Obj_desc        - Object to be displayed
- *              Walk_state      - Current walk state
- *
- * RETURN:      None
- *
- * DESCRIPTION: Short display of an internal object
- *
- ******************************************************************************/
-
-void
-acpi_db_display_internal_object (
-	acpi_operand_object     *obj_desc,
-	acpi_walk_state         *walk_state)
-{
-	u8                      type;
-
-
-	acpi_os_printf ("%p ", obj_desc);
-
-	if (!obj_desc) {
-		acpi_os_printf ("<Null_obj>\n");
-		return;
-	}
-
-
-	/* Decode the object type */
-
-	else if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_PARSER)) {
-		acpi_os_printf ("<Parser> ");
-	}
-
-	else if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) {
-		acpi_os_printf ("<Node>          Name %4.4s Type-%s",
-				  &((acpi_namespace_node *)obj_desc)->name,
-				  acpi_ut_get_type_name (((acpi_namespace_node *) obj_desc)->type));
-		if (((acpi_namespace_node *) obj_desc)->flags & ANOBJ_METHOD_ARG) {
-			acpi_os_printf (" [Method Arg]");
-		}
-		if (((acpi_namespace_node *) obj_desc)->flags & ANOBJ_METHOD_LOCAL) {
-			acpi_os_printf (" [Method Local]");
-		}
-	}
-
-	else if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_INTERNAL)) {
-		type = obj_desc->common.type;
-		if (type > INTERNAL_TYPE_MAX) {
-			acpi_os_printf (" Type %x [Invalid Type]", type);
-			return;
-		}
-
-		/* Decode the ACPI object type */
-
-		switch (obj_desc->common.type) {
-		case INTERNAL_TYPE_REFERENCE:
-			switch (obj_desc->reference.opcode) {
-			case AML_ZERO_OP:
-				acpi_os_printf ("[Const]         Zero (0) [Null Target]", 0);
-				break;
-
-			case AML_ONES_OP:
-				acpi_os_printf ("[Const]         Ones (0xFFFFFFFFFFFFFFFF) [No Limit]");
-				break;
-
-			case AML_ONE_OP:
-				acpi_os_printf ("[Const]         One (1)");
-				break;
-
-			case AML_REVISION_OP:
-				acpi_os_printf ("[Const]         Revision (%X)", ACPI_CA_SUPPORT_LEVEL);
-				break;
-
-			case AML_LOCAL_OP:
-				acpi_os_printf ("[Local%d]", obj_desc->reference.offset);
-				if (walk_state) {
-					obj_desc = walk_state->local_variables[obj_desc->reference.offset].object;
-					acpi_os_printf (" %p", obj_desc);
-					acpi_db_decode_internal_object (obj_desc);
-				}
-				break;
-
-			case AML_ARG_OP:
-				acpi_os_printf ("[Arg%d] ", obj_desc->reference.offset);
-				if (walk_state) {
-					obj_desc = walk_state->arguments[obj_desc->reference.offset].object;
-					acpi_os_printf (" %p", obj_desc);
-					acpi_db_decode_internal_object (obj_desc);
-				}
-				break;
-
-			case AML_DEBUG_OP:
-				acpi_os_printf ("[Debug] ");
-				break;
-
-			case AML_INDEX_OP:
-				acpi_os_printf ("[Index]   ");
-				acpi_db_decode_internal_object (obj_desc->reference.object);
-				break;
-
-			default:
-				break;
-
-			}
-			break;
-
-		default:
-			acpi_os_printf ("<Obj> ");
-			acpi_os_printf ("         ");
-			acpi_db_decode_internal_object (obj_desc);
-			break;
-		}
-	}
-
-	else {
-		acpi_os_printf ("<Not a valid ACPI Object Descriptor> ");
-	}
-
-	acpi_os_printf ("\n");
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_display_method_info
- *
- * PARAMETERS:  Start_op        - Root of the control method parse tree
- *
- * RETURN:      None
- *
- * DESCRIPTION: Display information about the current method
- *
- ******************************************************************************/
-
-void
-acpi_db_display_method_info (
-	acpi_parse_object       *start_op)
-{
-	acpi_walk_state         *walk_state;
-	acpi_operand_object     *obj_desc;
-	acpi_namespace_node     *node;
-	acpi_parse_object       *root_op;
-	acpi_parse_object       *op;
-	const acpi_opcode_info  *op_info;
-	u32                     num_ops = 0;
-	u32                     num_operands = 0;
-	u32                     num_operators = 0;
-	u32                     num_remaining_ops = 0;
-	u32                     num_remaining_operands = 0;
-	u32                     num_remaining_operators = 0;
-	u32                     num_args;
-	u32                     concurrency;
-	u8                      count_remaining = FALSE;
-
-
-	walk_state = acpi_ds_get_current_walk_state (acpi_gbl_current_walk_list);
-	if (!walk_state) {
-		acpi_os_printf ("There is no method currently executing\n");
-		return;
-	}
-
-	obj_desc = walk_state->method_desc;
-	node = walk_state->method_node;
-
-	num_args = obj_desc->method.param_count;
-	concurrency = obj_desc->method.concurrency;
-
-	acpi_os_printf ("Currently executing control method is [%4.4s]\n", &node->name);
-	acpi_os_printf ("%X arguments, max concurrency = %X\n", num_args, concurrency);
-
-
-	root_op = start_op;
-	while (root_op->parent) {
-		root_op = root_op->parent;
-	}
-
-	op = root_op;
-
-	while (op) {
-		if (op == start_op) {
-			count_remaining = TRUE;
-		}
-
-		num_ops++;
-		if (count_remaining) {
-			num_remaining_ops++;
-		}
-
-		/* Decode the opcode */
-
-		op_info = acpi_ps_get_opcode_info (op->opcode);
-		switch (op_info->class) {
-		case AML_CLASS_ARGUMENT:
-			if (count_remaining) {
-				num_remaining_operands++;
-			}
-
-			num_operands++;
-			break;
-
-		case AML_CLASS_UNKNOWN:
-			/* Bad opcode or ASCII character */
-
-			continue;
-
-		default:
-			if (count_remaining) {
-				num_remaining_operators++;
-			}
-
-			num_operators++;
-			break;
-		}
-
-
-		op = acpi_ps_get_depth_next (start_op, op);
-	}
-
-	acpi_os_printf ("Method contains:     %X AML Opcodes - %X Operators, %X Operands\n",
-			 num_ops, num_operators, num_operands);
-
-	acpi_os_printf ("Remaining to execute: %X AML Opcodes - %X Operators, %X Operands\n",
-			 num_remaining_ops, num_remaining_operators, num_remaining_operands);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_display_locals
- *
- * PARAMETERS:  None
- *
- * RETURN:      None
- *
- * DESCRIPTION: Display all locals for the currently running control method
- *
- ******************************************************************************/
-
-void
-acpi_db_display_locals (void)
-{
-	u32                     i;
-	acpi_walk_state         *walk_state;
-	acpi_operand_object     *obj_desc;
-	acpi_namespace_node     *node;
-
-
-	walk_state = acpi_ds_get_current_walk_state (acpi_gbl_current_walk_list);
-	if (!walk_state) {
-		acpi_os_printf ("There is no method currently executing\n");
-		return;
-	}
-
-	obj_desc = walk_state->method_desc;
-	node = walk_state->method_node;
-
-
-	acpi_os_printf ("Local Variables for method [%4.4s]:\n", &node->name);
-
-	for (i = 0; i < MTH_NUM_LOCALS; i++) {
-		obj_desc = walk_state->local_variables[i].object;
-		acpi_os_printf ("Local%d: ", i);
-		acpi_db_display_internal_object (obj_desc, walk_state);
-	}
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_display_arguments
- *
- * PARAMETERS:  None
- *
- * RETURN:      None
- *
- * DESCRIPTION: Display all arguments for the currently running control method
- *
- ******************************************************************************/
-
-void
-acpi_db_display_arguments (void)
-{
-	u32                     i;
-	acpi_walk_state         *walk_state;
-	acpi_operand_object     *obj_desc;
-	u32                     num_args;
-	u32                     concurrency;
-	acpi_namespace_node     *node;
-
-
-	walk_state = acpi_ds_get_current_walk_state (acpi_gbl_current_walk_list);
-	if (!walk_state) {
-		acpi_os_printf ("There is no method currently executing\n");
-		return;
-	}
-
-	obj_desc = walk_state->method_desc;
-	node = walk_state->method_node;
-
-	num_args = obj_desc->method.param_count;
-	concurrency = obj_desc->method.concurrency;
-
-	acpi_os_printf ("Method [%4.4s] has %X arguments, max concurrency = %X\n", &node->name, num_args, concurrency);
-
-	for (i = 0; i < num_args; i++) {
-		obj_desc = walk_state->arguments[i].object;
-		acpi_os_printf ("Arg%d: ", i);
-		acpi_db_display_internal_object (obj_desc, walk_state);
-	}
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_display_results
- *
- * PARAMETERS:  None
- *
- * RETURN:      None
- *
- * DESCRIPTION: Display current contents of a method result stack
- *
- ******************************************************************************/
-
-void
-acpi_db_display_results (void)
-{
-	u32                     i;
-	acpi_walk_state         *walk_state;
-	acpi_operand_object     *obj_desc;
-	u32                     num_results = 0;
-	acpi_namespace_node     *node;
-
-
-	walk_state = acpi_ds_get_current_walk_state (acpi_gbl_current_walk_list);
-	if (!walk_state) {
-		acpi_os_printf ("There is no method currently executing\n");
-		return;
-	}
-
-	obj_desc = walk_state->method_desc;
-	node = walk_state->method_node;
-
-	if (walk_state->results) {
-		num_results = walk_state->results->results.num_results;
-	}
-
-	acpi_os_printf ("Method [%4.4s] has %X stacked result objects\n", &node->name, num_results);
-
-	for (i = 0; i < num_results; i++) {
-		obj_desc = walk_state->results->results.obj_desc[i];
-		acpi_os_printf ("Result%d: ", i);
-		acpi_db_display_internal_object (obj_desc, walk_state);
-	}
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_display_calling_tree
- *
- * PARAMETERS:  None
- *
- * RETURN:      None
- *
- * DESCRIPTION: Display current calling tree of nested control methods
- *
- ******************************************************************************/
-
-void
-acpi_db_display_calling_tree (void)
-{
-	u32                     i;
-	acpi_walk_state         *walk_state;
-	acpi_namespace_node     *node;
-
-
-	walk_state = acpi_ds_get_current_walk_state (acpi_gbl_current_walk_list);
-	if (!walk_state) {
-		acpi_os_printf ("There is no method currently executing\n");
-		return;
-	}
-
-	node = walk_state->method_node;
-
-	acpi_os_printf ("Current Control Method Call Tree\n");
-
-	for (i = 0; walk_state; i++) {
-		node = walk_state->method_node;
-
-		acpi_os_printf ("  [%4.4s]\n", &node->name);
-
-		walk_state = walk_state->next;
-	}
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_display_result_object
- *
- * PARAMETERS:  Obj_desc        - Object to be displayed
- *              Walk_state      - Current walk state
- *
- * RETURN:      None
- *
- * DESCRIPTION: Display the result of an AML opcode
- *
- ******************************************************************************/
-
-void
-acpi_db_display_result_object (
-	acpi_operand_object     *obj_desc,
-	acpi_walk_state         *walk_state)
-{
-
-	/* TBD: [Future] We don't always want to display the result.
-	 * For now, only display if single stepping
-	 * however, this output is very useful in other contexts also
-	 */
-	if (!acpi_gbl_cm_single_step) {
-		return;
-	}
-
-	acpi_os_printf ("Result_obj: ");
-	acpi_db_display_internal_object (obj_desc, walk_state);
-	acpi_os_printf ("\n");
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_display_argument_object
- *
- * PARAMETERS:  Obj_desc        - Object to be displayed
- *              Walk_state      - Current walk state
- *
- * RETURN:      None
- *
- * DESCRIPTION: Display the result of an AML opcode
- *
- ******************************************************************************/
-
-void
-acpi_db_display_argument_object (
-	acpi_operand_object     *obj_desc,
-	acpi_walk_state         *walk_state)
-{
-
-
-	if (!acpi_gbl_cm_single_step) {
-		return;
-	}
-
-	acpi_os_printf ("Arg_obj: ");
-	acpi_db_display_internal_object (obj_desc, walk_state);
-}
-
-#endif /* ENABLE_DEBUGGER */
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/debugger/dbexec.c linux-2.4.22-pre2/drivers/acpi/debugger/dbexec.c
--- linux-2.4.21/drivers/acpi/debugger/dbexec.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/debugger/dbexec.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,404 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: dbexec - debugger control method execution
- *              $Revision: 34 $
- *
- ******************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include "acpi.h"
-#include "acparser.h"
-#include "acdispat.h"
-#include "amlcode.h"
-#include "acnamesp.h"
-#include "acparser.h"
-#include "acevents.h"
-#include "acinterp.h"
-#include "acdebug.h"
-#include "actables.h"
-
-#ifdef ENABLE_DEBUGGER
-
-#define _COMPONENT          ACPI_DEBUGGER
-	 MODULE_NAME         ("dbexec")
-
-
-db_method_info              acpi_gbl_db_method_info;
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_execute_method
- *
- * PARAMETERS:  Info            - Valid info segment
- *              Return_obj      - Where to put return object
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Execute a control method.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_db_execute_method (
-	db_method_info          *info,
-	acpi_buffer             *return_obj)
-{
-	acpi_status             status;
-	acpi_object_list        param_objects;
-	acpi_object             params[MTH_NUM_ARGS];
-	u32                     i;
-
-
-	if (acpi_gbl_db_output_to_file && !acpi_dbg_level) {
-		acpi_os_printf ("Warning: debug output is not enabled!\n");
-	}
-
-	/* Are there arguments to the method? */
-
-	if (info->args && info->args[0]) {
-		for (i = 0; info->args[i] && i < MTH_NUM_ARGS; i++) {
-			params[i].type              = ACPI_TYPE_INTEGER;
-			params[i].integer.value     = STRTOUL (info->args[i], NULL, 16);
-		}
-
-		param_objects.pointer       = params;
-		param_objects.count         = i;
-	}
-
-	else {
-		/* Setup default parameters */
-
-		params[0].type              = ACPI_TYPE_INTEGER;
-		params[0].integer.value     = 0x01020304;
-
-		params[1].type              = ACPI_TYPE_STRING;
-		params[1].string.length     = 12;
-		params[1].string.pointer    = "AML Debugger";
-
-		param_objects.pointer       = params;
-		param_objects.count         = 2;
-	}
-
-	/* Prepare for a return object of arbitrary size */
-
-	return_obj->pointer          = acpi_gbl_db_buffer;
-	return_obj->length           = ACPI_DEBUG_BUFFER_SIZE;
-
-
-	/* Do the actual method execution */
-
-	status = acpi_evaluate_object (NULL, info->pathname, &param_objects, return_obj);
-
-	acpi_gbl_cm_single_step = FALSE;
-	acpi_gbl_method_executing = FALSE;
-
-	return (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_execute_setup
- *
- * PARAMETERS:  Info            - Valid method info
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Setup info segment prior to method execution
- *
- ******************************************************************************/
-
-void
-acpi_db_execute_setup (
-	db_method_info          *info)
-{
-
-	/* Catenate the current scope to the supplied name */
-
-	info->pathname[0] = 0;
-	if ((info->name[0] != '\\') &&
-		(info->name[0] != '/')) {
-		STRCAT (info->pathname, acpi_gbl_db_scope_buf);
-	}
-
-	STRCAT (info->pathname, info->name);
-	acpi_db_prep_namestring (info->pathname);
-
-	acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT);
-	acpi_os_printf ("Executing %s\n", info->pathname);
-
-	if (info->flags & EX_SINGLE_STEP) {
-		acpi_gbl_cm_single_step = TRUE;
-		acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
-	}
-
-	else {
-		/* No single step, allow redirection to a file */
-
-		acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT);
-	}
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_get_outstanding_allocations
- *
- * PARAMETERS:  None
- *
- * RETURN:      Current global allocation count minus cache entries
- *
- * DESCRIPTION: Determine the current number of "outstanding" allocations --
- *              those allocations that have not been freed and also are not
- *              in one of the various object caches.
- *
- ******************************************************************************/
-
-u32
-acpi_db_get_outstanding_allocations (void)
-{
-	u32                     i;
-	u32                     outstanding = 0;
-
-
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
-
-	for (i = ACPI_MEM_LIST_FIRST_CACHE_LIST; i < ACPI_NUM_MEM_LISTS; i++) {
-		outstanding += (acpi_gbl_memory_lists[i].total_allocated -
-				  acpi_gbl_memory_lists[i].total_freed -
-				  acpi_gbl_memory_lists[i].cache_depth);
-	}
-#endif
-
-	return (outstanding);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_execute
- *
- * PARAMETERS:  Name                - Name of method to execute
- *              Args                - Parameters to the method
- *              Flags               - single step/no single step
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Execute a control method.  Name is relative to the current
- *              scope.
- *
- ******************************************************************************/
-
-void
-acpi_db_execute (
-	NATIVE_CHAR             *name,
-	NATIVE_CHAR             **args,
-	u32                     flags)
-{
-	acpi_status             status;
-	acpi_buffer             return_obj;
-
-
-#ifdef ACPI_DEBUG
-	u32                     previous_allocations;
-	u32                     allocations;
-
-
-	/* Memory allocation tracking */
-
-	previous_allocations = acpi_db_get_outstanding_allocations ();
-#endif
-
-	acpi_gbl_db_method_info.name = name;
-	acpi_gbl_db_method_info.args = args;
-	acpi_gbl_db_method_info.flags = flags;
-
-	acpi_db_execute_setup (&acpi_gbl_db_method_info);
-	status = acpi_db_execute_method (&acpi_gbl_db_method_info, &return_obj);
-
-	/*
-	 * Allow any handlers in separate threads to complete.
-	 * (Such as Notify handlers invoked from AML executed above).
-	 */
-	acpi_os_sleep (0, 10);
-
-
-#ifdef ACPI_DEBUG
-
-	/* Memory allocation tracking */
-
-	allocations = acpi_db_get_outstanding_allocations () - previous_allocations;
-
-	acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT);
-
-	if (allocations > 0) {
-		acpi_os_printf ("Outstanding: %ld allocations after execution\n",
-				  allocations);
-	}
-#endif
-
-	if (ACPI_FAILURE (status)) {
-		acpi_os_printf ("Execution of %s failed with status %s\n",
-			acpi_gbl_db_method_info.pathname, acpi_format_exception (status));
-	}
-
-	else {
-		/* Display a return object, if any */
-
-		if (return_obj.length) {
-			acpi_os_printf ("Execution of %s returned object %p Buflen %X\n",
-				acpi_gbl_db_method_info.pathname, return_obj.pointer, return_obj.length);
-			acpi_db_dump_object (return_obj.pointer, 1);
-		}
-	}
-
-	acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_method_thread
- *
- * PARAMETERS:  Context             - Execution info segment
- *
- * RETURN:      None
- *
- * DESCRIPTION: Debugger execute thread.  Waits for a command line, then
- *              simply dispatches it.
- *
- ******************************************************************************/
-
-void
-acpi_db_method_thread (
-	void                    *context)
-{
-	acpi_status             status;
-	db_method_info          *info = context;
-	u32                     i;
-	acpi_buffer             return_obj;
-
-
-	for (i = 0; i < info->num_loops; i++) {
-		status = acpi_db_execute_method (info, &return_obj);
-		if (ACPI_SUCCESS (status)) {
-			if (return_obj.length) {
-				acpi_os_printf ("Execution of %s returned object %p Buflen %X\n",
-					info->pathname, return_obj.pointer, return_obj.length);
-				acpi_db_dump_object (return_obj.pointer, 1);
-			}
-		}
-	}
-
-	/* Signal our completion */
-
-	acpi_os_signal_semaphore (info->thread_gate, 1);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_create_execution_threads
- *
- * PARAMETERS:  Num_threads_arg         - Number of threads to create
- *              Num_loops_arg           - Loop count for the thread(s)
- *              Method_name_arg         - Control method to execute
- *
- * RETURN:      None
- *
- * DESCRIPTION: Create threads to execute method(s)
- *
- ******************************************************************************/
-
-void
-acpi_db_create_execution_threads (
-	NATIVE_CHAR             *num_threads_arg,
-	NATIVE_CHAR             *num_loops_arg,
-	NATIVE_CHAR             *method_name_arg)
-{
-	acpi_status             status;
-	u32                     num_threads;
-	u32                     num_loops;
-	u32                     i;
-	acpi_handle             thread_gate;
-
-
-	/* Get the arguments */
-
-	num_threads = STRTOUL (num_threads_arg, NULL, 0);
-	num_loops = STRTOUL (num_loops_arg, NULL, 0);
-
-	if (!num_threads || !num_loops) {
-		acpi_os_printf ("Bad argument: Threads %X, Loops %X\n", num_threads, num_loops);
-		return;
-	}
-
-
-	/* Create the synchronization semaphore */
-
-	status = acpi_os_create_semaphore (1, 0, &thread_gate);
-	if (ACPI_FAILURE (status)) {
-		acpi_os_printf ("Could not create semaphore, %s\n", acpi_format_exception (status));
-		return;
-	}
-
-	/* Setup the context to be passed to each thread */
-
-	acpi_gbl_db_method_info.name = method_name_arg;
-	acpi_gbl_db_method_info.args = NULL;
-	acpi_gbl_db_method_info.flags = 0;
-	acpi_gbl_db_method_info.num_loops = num_loops;
-	acpi_gbl_db_method_info.thread_gate = thread_gate;
-
-	acpi_db_execute_setup (&acpi_gbl_db_method_info);
-
-
-	/* Create the threads */
-
-	acpi_os_printf ("Creating %X threads to execute %X times each\n", num_threads, num_loops);
-
-	for (i = 0; i < (num_threads); i++) {
-		acpi_os_queue_for_execution (OSD_PRIORITY_MED, acpi_db_method_thread, &acpi_gbl_db_method_info);
-	}
-
-
-	/* Wait for all threads to complete */
-
-	i = num_threads;
-	while (i)   /* Brain damage for OSD implementations that only support wait of 1 unit */ {
-		status = acpi_os_wait_semaphore (thread_gate, 1, WAIT_FOREVER);
-		i--;
-	}
-
-	/* Cleanup and exit */
-
-	acpi_os_delete_semaphore (thread_gate);
-
-	acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT);
-	acpi_os_printf ("All threads (%X) have completed\n", num_threads);
-	acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
-}
-
-
-#endif /* ENABLE_DEBUGGER */
-
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/debugger/dbfileio.c linux-2.4.22-pre2/drivers/acpi/debugger/dbfileio.c
--- linux-2.4.21/drivers/acpi/debugger/dbfileio.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/debugger/dbfileio.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,381 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: dbfileio - Debugger file I/O commands.  These can't usually
- *              be used when running the debugger in Ring 0 (Kernel mode)
- *              $Revision: 53 $
- *
- ******************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include "acpi.h"
-#include "acdebug.h"
-#include "acnamesp.h"
-#include "acparser.h"
-#include "acevents.h"
-#include "actables.h"
-
-#ifdef ENABLE_DEBUGGER
-
-#define _COMPONENT          ACPI_DEBUGGER
-	 MODULE_NAME         ("dbfileio")
-
-
-/*
- * NOTE: this is here for lack of a better place.  It is used in all
- * flavors of the debugger, need LCD file
- */
-#ifdef ACPI_APPLICATION
-#include <stdio.h>
-FILE                        *acpi_gbl_debug_file = NULL;
-#endif
-
-
-acpi_table_header           *acpi_gbl_db_table_ptr = NULL;
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_match_argument
- *
- * PARAMETERS:  User_argument           - User command line
- *              Arguments               - Array of commands to match against
- *
- * RETURN:      Index into command array or ACPI_TYPE_NOT_FOUND if not found
- *
- * DESCRIPTION: Search command array for a command match
- *
- ******************************************************************************/
-
-acpi_object_type8
-acpi_db_match_argument (
-	NATIVE_CHAR             *user_argument,
-	ARGUMENT_INFO           *arguments)
-{
-	u32                     i;
-
-
-	if (!user_argument || user_argument[0] == 0) {
-		return (ACPI_TYPE_NOT_FOUND);
-	}
-
-	for (i = 0; arguments[i].name; i++) {
-		if (STRSTR (arguments[i].name, user_argument) == arguments[i].name) {
-			return ((acpi_object_type8) i);
-		}
-	}
-
-	/* Argument not recognized */
-
-	return (ACPI_TYPE_NOT_FOUND);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_close_debug_file
- *
- * PARAMETERS:  None
- *
- * RETURN:      Status
- *
- * DESCRIPTION: If open, close the current debug output file
- *
- ******************************************************************************/
-
-void
-acpi_db_close_debug_file (
-	void)
-{
-
-#ifdef ACPI_APPLICATION
-
-	if (acpi_gbl_debug_file) {
-	   fclose (acpi_gbl_debug_file);
-	   acpi_gbl_debug_file = NULL;
-	   acpi_gbl_db_output_to_file = FALSE;
-	   acpi_os_printf ("Debug output file %s closed\n", acpi_gbl_db_debug_filename);
-	}
-#endif
-
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_open_debug_file
- *
- * PARAMETERS:  Name                - Filename to open
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Open a file where debug output will be directed.
- *
- ******************************************************************************/
-
-void
-acpi_db_open_debug_file (
-	NATIVE_CHAR             *name)
-{
-
-#ifdef ACPI_APPLICATION
-
-	acpi_db_close_debug_file ();
-	acpi_gbl_debug_file = fopen (name, "w+");
-	if (acpi_gbl_debug_file) {
-		acpi_os_printf ("Debug output file %s opened\n", name);
-		STRCPY (acpi_gbl_db_debug_filename, name);
-		acpi_gbl_db_output_to_file = TRUE;
-	}
-	else {
-		acpi_os_printf ("Could not open debug file %s\n", name);
-	}
-
-#endif
-}
-
-
-#ifdef ACPI_APPLICATION
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_load_table
- *
- * PARAMETERS:  fp              - File that contains table
- *              Table_ptr       - Return value, buffer with table
- *              Table_lenght    - Return value, length of table
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Load the DSDT from the file pointer
- *
- ******************************************************************************/
-
-acpi_status
-acpi_db_load_table(
-	FILE                    *fp,
-	acpi_table_header       **table_ptr,
-	u32                     *table_length)
-{
-	acpi_table_header       table_header;
-	u8                      *aml_start;
-	u32                     aml_length;
-	u32                     actual;
-	acpi_status             status;
-
-
-	/* Read the table header */
-
-	if (fread (&table_header, 1, sizeof (table_header), fp) != sizeof (acpi_table_header)) {
-		acpi_os_printf ("Couldn't read the table header\n");
-		return (AE_BAD_SIGNATURE);
-	}
-
-
-	/* Validate the table header/length */
-
-	status = acpi_tb_validate_table_header (&table_header);
-	if ((ACPI_FAILURE (status)) ||
-		(table_header.length > 524288)) /* 1/2 Mbyte should be enough */ {
-		acpi_os_printf ("Table header is invalid!\n");
-		return (AE_ERROR);
-	}
-
-
-	/* We only support a limited number of table types */
-
-	if (STRNCMP ((char *) table_header.signature, DSDT_SIG, 4) &&
-		STRNCMP ((char *) table_header.signature, PSDT_SIG, 4) &&
-		STRNCMP ((char *) table_header.signature, SSDT_SIG, 4)) {
-		acpi_os_printf ("Table signature is invalid\n");
-		DUMP_BUFFER (&table_header, sizeof (acpi_table_header));
-		return (AE_ERROR);
-	}
-
-	/* Allocate a buffer for the table */
-
-	*table_length = table_header.length;
-	*table_ptr = acpi_os_allocate ((size_t) *table_length);
-	if (!*table_ptr) {
-		acpi_os_printf ("Could not allocate memory for ACPI table %4.4s (size=%X)\n",
-				 table_header.signature, table_header.length);
-		return (AE_NO_MEMORY);
-	}
-
-
-	aml_start = (u8 *) *table_ptr + sizeof (table_header);
-	aml_length = *table_length - sizeof (table_header);
-
-	/* Copy the header to the buffer */
-
-	MEMCPY (*table_ptr, &table_header, sizeof (table_header));
-
-	/* Get the rest of the table */
-
-	actual = fread (aml_start, 1, (size_t) aml_length, fp);
-	if (actual == aml_length) {
-		return (AE_OK);
-	}
-
-	if (actual > 0) {
-		acpi_os_printf ("Warning - reading table, asked for %X got %X\n", aml_length, actual);
-		return (AE_OK);
-	}
-
-
-	acpi_os_printf ("Error - could not read the table file\n");
-	acpi_os_free (*table_ptr);
-	*table_ptr = NULL;
-	*table_length = 0;
-
-	return (AE_ERROR);
-}
-#endif
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Ae_local_load_table
- *
- * PARAMETERS:  Table_ptr       - pointer to a buffer containing the entire
- *                                table to be loaded
- *
- * RETURN:      Status
- *
- * DESCRIPTION: This function is called to load a table from the caller's
- *              buffer.  The buffer must contain an entire ACPI Table including
- *              a valid header.  The header fields will be verified, and if it
- *              is determined that the table is invalid, the call will fail.
- *
- *              If the call fails an appropriate status will be returned.
- *
- ******************************************************************************/
-
-acpi_status
-ae_local_load_table (
-	acpi_table_header       *table_ptr)
-{
-	acpi_status             status;
-	acpi_table_desc         table_info;
-
-
-	FUNCTION_TRACE ("Ae_local_load_table");
-
-	if (!table_ptr) {
-		return_ACPI_STATUS (AE_BAD_PARAMETER);
-	}
-
-	/* Install the new table into the local data structures */
-
-	table_info.pointer = table_ptr;
-
-	status = acpi_tb_install_table (NULL, &table_info);
-	if (ACPI_FAILURE (status)) {
-		/* Free table allocated by Acpi_tb_get_table */
-
-		acpi_tb_delete_single_table (&table_info);
-		return_ACPI_STATUS (status);
-	}
-
-
-#ifndef PARSER_ONLY
-	status = acpi_ns_load_table (table_info.installed_desc, acpi_gbl_root_node);
-	if (ACPI_FAILURE (status)) {
-		/* Uninstall table and free the buffer */
-
-		acpi_tb_delete_acpi_table (ACPI_TABLE_DSDT);
-		return_ACPI_STATUS (status);
-	}
-#endif
-
-	return_ACPI_STATUS (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_load_acpi_table
- *
- * PARAMETERS:  Filname         - File where table is located
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Load an ACPI table from a file
- *
- ******************************************************************************/
-
-acpi_status
-acpi_db_load_acpi_table (
-	NATIVE_CHAR             *filename)
-{
-#ifdef ACPI_APPLICATION
-	FILE                    *fp;
-	acpi_status             status;
-	u32                     table_length;
-
-
-	/* Open the file */
-
-	fp = fopen (filename, "rb");
-	if (!fp) {
-		acpi_os_printf ("Could not open file %s\n", filename);
-		return (AE_ERROR);
-	}
-
-
-	/* Get the entire file */
-
-	acpi_os_printf ("Loading Acpi table from file %s\n", filename);
-	status = acpi_db_load_table (fp, &acpi_gbl_db_table_ptr, &table_length);
-	fclose(fp);
-
-	if (ACPI_FAILURE (status)) {
-		acpi_os_printf ("Couldn't get table from the file\n");
-		return (status);
-	}
-
-	/* Attempt to recognize and install the table */
-
-	status = ae_local_load_table (acpi_gbl_db_table_ptr);
-	if (ACPI_FAILURE (status)) {
-		if (status == AE_EXIST) {
-			acpi_os_printf ("Table %4.4s is already installed\n",
-					  &acpi_gbl_db_table_ptr->signature);
-		}
-		else {
-			acpi_os_printf ("Could not install table, %s\n",
-					  acpi_format_exception (status));
-		}
-
-		acpi_os_free (acpi_gbl_db_table_ptr);
-		return (status);
-	}
-
-	acpi_os_printf ("%4.4s at %p successfully installed and loaded\n",
-			  &acpi_gbl_db_table_ptr->signature, acpi_gbl_db_table_ptr);
-
-	acpi_gbl_acpi_hardware_present = FALSE;
-
-#endif  /* ACPI_APPLICATION */
-	return (AE_OK);
-}
-
-
-#endif  /* ENABLE_DEBUGGER */
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/debugger/dbhistry.c linux-2.4.22-pre2/drivers/acpi/debugger/dbhistry.c
--- linux-2.4.21/drivers/acpi/debugger/dbhistry.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/debugger/dbhistry.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,201 +0,0 @@
-/******************************************************************************
- *
- * Module Name: dbhistry - debugger HISTORY command
- *              $Revision: 19 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include "acpi.h"
-#include "acparser.h"
-#include "acdispat.h"
-#include "amlcode.h"
-#include "acnamesp.h"
-#include "acparser.h"
-#include "acevents.h"
-#include "acinterp.h"
-#include "acdebug.h"
-#include "actables.h"
-
-#ifdef ENABLE_DEBUGGER
-
-#define _COMPONENT          ACPI_DEBUGGER
-	 MODULE_NAME         ("dbhistry")
-
-
-#define HI_NO_HISTORY       0
-#define HI_RECORD_HISTORY   1
-#define HISTORY_SIZE        20
-
-
-typedef struct history_info
-{
-	NATIVE_CHAR             command[80];
-	u32                     cmd_num;
-
-} HISTORY_INFO;
-
-
-HISTORY_INFO                acpi_gbl_history_buffer[HISTORY_SIZE];
-u16                         acpi_gbl_lo_history = 0;
-u16                         acpi_gbl_num_history = 0;
-u16                         acpi_gbl_next_history_index = 0;
-u32                         acpi_gbl_next_cmd_num = 1;
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_add_to_history
- *
- * PARAMETERS:  Command_line    - Command to add
- *
- * RETURN:      None
- *
- * DESCRIPTION: Add a command line to the history buffer.
- *
- ******************************************************************************/
-
-void
-acpi_db_add_to_history (
-	NATIVE_CHAR             *command_line)
-{
-
-
-	/* Put command into the next available slot */
-
-	STRCPY (acpi_gbl_history_buffer[acpi_gbl_next_history_index].command, command_line);
-
-	acpi_gbl_history_buffer[acpi_gbl_next_history_index].cmd_num = acpi_gbl_next_cmd_num;
-
-	/* Adjust indexes */
-
-	if ((acpi_gbl_num_history == HISTORY_SIZE) &&
-		(acpi_gbl_next_history_index == acpi_gbl_lo_history)) {
-		acpi_gbl_lo_history++;
-		if (acpi_gbl_lo_history >= HISTORY_SIZE) {
-			acpi_gbl_lo_history = 0;
-		}
-	}
-
-	acpi_gbl_next_history_index++;
-	if (acpi_gbl_next_history_index >= HISTORY_SIZE) {
-		acpi_gbl_next_history_index = 0;
-	}
-
-
-	acpi_gbl_next_cmd_num++;
-	if (acpi_gbl_num_history < HISTORY_SIZE) {
-		acpi_gbl_num_history++;
-	}
-
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_display_history
- *
- * PARAMETERS:  None
- *
- * RETURN:      None
- *
- * DESCRIPTION: Display the contents of the history buffer
- *
- ******************************************************************************/
-
-void
-acpi_db_display_history (void)
-{
-	NATIVE_UINT             i;
-	u16                     history_index;
-
-
-	history_index = acpi_gbl_lo_history;
-
-	/* Dump entire history buffer */
-
-	for (i = 0; i < acpi_gbl_num_history; i++) {
-		acpi_os_printf ("%ld %s\n", acpi_gbl_history_buffer[history_index].cmd_num,
-				 acpi_gbl_history_buffer[history_index].command);
-
-		history_index++;
-		if (history_index >= HISTORY_SIZE) {
-			history_index = 0;
-		}
-	}
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_get_from_history
- *
- * PARAMETERS:  Command_num_arg         - String containing the number of the
- *                                        command to be retrieved
- *
- * RETURN:      None
- *
- * DESCRIPTION: Get a command from the history buffer
- *
- ******************************************************************************/
-
-NATIVE_CHAR *
-acpi_db_get_from_history (
-	NATIVE_CHAR             *command_num_arg)
-{
-	NATIVE_UINT             i;
-	u16                     history_index;
-	u32                     cmd_num;
-
-
-	if (command_num_arg == NULL) {
-		cmd_num = acpi_gbl_next_cmd_num - 1;
-	}
-
-	else {
-		cmd_num = STRTOUL (command_num_arg, NULL, 0);
-	}
-
-
-	/* Search history buffer */
-
-	history_index = acpi_gbl_lo_history;
-	for (i = 0; i < acpi_gbl_num_history; i++) {
-		if (acpi_gbl_history_buffer[history_index].cmd_num == cmd_num) {
-			/* Found the commnad, return it */
-
-			return (acpi_gbl_history_buffer[history_index].command);
-		}
-
-
-		history_index++;
-		if (history_index >= HISTORY_SIZE) {
-			history_index = 0;
-		}
-	}
-
-	acpi_os_printf ("Invalid history number: %d\n", history_index);
-	return (NULL);
-}
-
-
-#endif /* ENABLE_DEBUGGER */
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/debugger/dbinput.c linux-2.4.22-pre2/drivers/acpi/debugger/dbinput.c
--- linux-2.4.21/drivers/acpi/debugger/dbinput.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/debugger/dbinput.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,924 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: dbinput - user front-end to the AML debugger
- *              $Revision: 72 $
- *
- ******************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include "acpi.h"
-#include "acparser.h"
-#include "actables.h"
-#include "acnamesp.h"
-#include "acinterp.h"
-#include "acdebug.h"
-
-
-#ifdef ENABLE_DEBUGGER
-
-#define _COMPONENT          ACPI_DEBUGGER
-	 MODULE_NAME         ("dbinput")
-
-
-/*
- * Globals that are specific to the debugger
- */
-
-NATIVE_CHAR                 acpi_gbl_db_line_buf[80];
-NATIVE_CHAR                 acpi_gbl_db_parsed_buf[80];
-NATIVE_CHAR                 acpi_gbl_db_scope_buf[40];
-NATIVE_CHAR                 acpi_gbl_db_debug_filename[40];
-NATIVE_CHAR                 *acpi_gbl_db_args[DB_MAX_ARGS];
-NATIVE_CHAR                 *acpi_gbl_db_buffer = NULL;
-NATIVE_CHAR                 *acpi_gbl_db_filename = NULL;
-u8                          acpi_gbl_db_output_to_file = FALSE;
-
-u32                         acpi_gbl_db_debug_level = ACPI_LV_VERBOSITY2;
-u32                         acpi_gbl_db_console_debug_level = NORMAL_DEFAULT | ACPI_LV_TABLES;
-u8                          acpi_gbl_db_output_flags = DB_CONSOLE_OUTPUT;
-
-
-u8                          acpi_gbl_db_opt_tables    = FALSE;
-u8                          acpi_gbl_db_opt_disasm    = FALSE;
-u8                          acpi_gbl_db_opt_stats     = FALSE;
-u8                          acpi_gbl_db_opt_parse_jit = FALSE;
-u8                          acpi_gbl_db_opt_verbose   = TRUE;
-u8                          acpi_gbl_db_opt_ini_methods = TRUE;
-
-/*
- * Statistic globals
- */
-u16                         acpi_gbl_obj_type_count[INTERNAL_TYPE_NODE_MAX+1];
-u16                         acpi_gbl_node_type_count[INTERNAL_TYPE_NODE_MAX+1];
-u16                         acpi_gbl_obj_type_count_misc;
-u16                         acpi_gbl_node_type_count_misc;
-u32                         acpi_gbl_num_nodes;
-u32                         acpi_gbl_num_objects;
-
-
-u32                         acpi_gbl_size_of_parse_tree;
-u32                         acpi_gbl_size_of_method_trees;
-u32                         acpi_gbl_size_of_node_entries;
-u32                         acpi_gbl_size_of_acpi_objects;
-
-/*
- * Top-level debugger commands.
- *
- * This list of commands must match the string table below it
- */
-
-enum acpi_ex_debugger_commands
-{
-	CMD_NOT_FOUND = 0,
-	CMD_NULL,
-	CMD_ALLOCATIONS,
-	CMD_ARGS,
-	CMD_ARGUMENTS,
-	CMD_BREAKPOINT,
-	CMD_CALL,
-	CMD_CLOSE,
-	CMD_DEBUG,
-	CMD_DUMP,
-	CMD_ENABLEACPI,
-	CMD_EVENT,
-	CMD_EXECUTE,
-	CMD_EXIT,
-	CMD_FIND,
-	CMD_GO,
-	CMD_HELP,
-	CMD_HELP2,
-	CMD_HISTORY,
-	CMD_HISTORY_EXE,
-	CMD_HISTORY_LAST,
-	CMD_INFORMATION,
-	CMD_INTO,
-	CMD_LEVEL,
-	CMD_LIST,
-	CMD_LOAD,
-	CMD_LOCALS,
-	CMD_LOCKS,
-	CMD_METHODS,
-	CMD_NAMESPACE,
-	CMD_NOTIFY,
-	CMD_OBJECT,
-	CMD_OPEN,
-	CMD_OWNER,
-	CMD_PREFIX,
-	CMD_QUIT,
-	CMD_REFERENCES,
-	CMD_RESOURCES,
-	CMD_RESULTS,
-	CMD_SET,
-	CMD_STATS,
-	CMD_STOP,
-	CMD_TABLES,
-	CMD_TERMINATE,
-	CMD_THREADS,
-	CMD_TREE,
-	CMD_UNLOAD
-};
-
-#define CMD_FIRST_VALID     2
-
-
-const COMMAND_INFO          acpi_gbl_db_commands[] =
-{ {"<NOT FOUND>",  0},
-	{"<NULL>",       0},
-	{"ALLOCATIONS",  0},
-	{"ARGS",         0},
-	{"ARGUMENTS",    0},
-	{"BREAKPOINT",   1},
-	{"CALL",         0},
-	{"CLOSE",        0},
-	{"DEBUG",        1},
-	{"DUMP",         1},
-	{"ENABLEACPI",   0},
-	{"EVENT",        1},
-	{"EXECUTE",      1},
-	{"EXIT",         0},
-	{"FIND",         1},
-	{"GO",           0},
-	{"HELP",         0},
-	{"?",            0},
-	{"HISTORY",      0},
-	{"!",            1},
-	{"!!",           0},
-	{"INFORMATION",  0},
-	{"INTO",         0},
-	{"LEVEL",        0},
-	{"LIST",         0},
-	{"LOAD",         1},
-	{"LOCALS",       0},
-	{"LOCKS",        0},
-	{"METHODS",      0},
-	{"NAMESPACE",    0},
-	{"NOTIFY",       2},
-	{"OBJECT",       1},
-	{"OPEN",         1},
-	{"OWNER",        1},
-	{"PREFIX",       0},
-	{"QUIT",         0},
-	{"REFERENCES",   1},
-	{"RESOURCES",    1},
-	{"RESULTS",      0},
-	{"SET",          3},
-	{"STATS",        0},
-	{"STOP",         0},
-	{"TABLES",       0},
-	{"TERMINATE",    0},
-	{"THREADS",      3},
-	{"TREE",         0},
-	{"UNLOAD",       1},
-	{NULL,           0}
-};
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_display_help
- *
- * PARAMETERS:  Help_type       - Subcommand (optional)
- *
- * RETURN:      None
- *
- * DESCRIPTION: Print a usage message.
- *
- ******************************************************************************/
-
-void
-acpi_db_display_help (
-	NATIVE_CHAR             *help_type)
-{
-
-
-	/* No parameter, just give the overview */
-
-	if (!help_type)
-	{
-		acpi_os_printf ("ACPI CA Debugger Commands\n\n");
-		acpi_os_printf ("The following classes of commands are available. Help is available for\n");
-		acpi_os_printf ("each class by entering \"Help <Class_name>\"\n\n");
-		acpi_os_printf ("  [GENERAL]       General-Purpose Commands\n");
-		acpi_os_printf ("  [NAMESPACE]     Namespace Access Commands\n");
-		acpi_os_printf ("  [METHOD]        Control Method Execution Commands\n");
-		acpi_os_printf ("  [FILE]          File I/O Commands\n");
-		return;
-
-	}
-
-
-	/*
-	 * Parameter is the command class
-	 *
-	 * The idea here is to keep each class of commands smaller than a screenful
-	 */
-
-	switch (help_type[0])
-	{
-	case 'G':
-		acpi_os_printf ("\n_general-Purpose Commands\n\n");
-		acpi_os_printf ("Allocations                       Display list of current memory allocations\n");
-		acpi_os_printf ("Dump <Address>|<Namepath>\n");
-		acpi_os_printf ("   [Byte|Word|Dword|Qword]        Display ACPI objects or memory\n");
-		acpi_os_printf ("Enable_acpi                       Enable ACPI (hardware) mode\n");
-		acpi_os_printf ("Help                              This help screen\n");
-		acpi_os_printf ("History                           Display command history buffer\n");
-		acpi_os_printf ("Level [<Debug_level>] [console]   Get/Set debug level for file or console\n");
-		acpi_os_printf ("Locks                             Current status of internal mutexes\n");
-		acpi_os_printf ("Quit or Exit                      Exit this command\n");
-		acpi_os_printf ("Stats [Allocations|Memory|Misc\n");
-		acpi_os_printf ("     |Objects|Tables]             Display namespace and memory statistics\n");
-		acpi_os_printf ("Tables                            Display info about loaded ACPI tables\n");
-		acpi_os_printf ("Unload <Table_sig> [Instance]     Unload an ACPI table\n");
-		acpi_os_printf ("! <Command_number>                Execute command from history buffer\n");
-		acpi_os_printf ("!!                                Execute last command again\n");
-		return;
-
-	case 'N':
-		acpi_os_printf ("\n_namespace Access Commands\n\n");
-		acpi_os_printf ("Debug <Namepath> [Arguments]      Single Step a control method\n");
-		acpi_os_printf ("Event <F|G> <Value>               Generate Acpi_event (Fixed/GPE)\n");
-		acpi_os_printf ("Execute <Namepath> [Arguments]    Execute control method\n");
-		acpi_os_printf ("Find <Name> (? is wildcard)       Find ACPI name(s) with wildcards\n");
-		acpi_os_printf ("Method                            Display list of loaded control methods\n");
-		acpi_os_printf ("Namespace [<Addr>|<Path>] [Depth] Display loaded namespace tree/subtree\n");
-		acpi_os_printf ("Notify <Name_path> <Value>        Send a notification\n");
-		acpi_os_printf ("Objects <Object_type>             Display all objects of the given type\n");
-		acpi_os_printf ("Owner <Owner_id> [Depth]          Display loaded namespace by object owner\n");
-		acpi_os_printf ("Prefix [<Name_path>]              Set or Get current execution prefix\n");
-		acpi_os_printf ("References <Addr>                 Find all references to object at addr\n");
-		acpi_os_printf ("Resources xxx                     Get and display resources\n");
-		acpi_os_printf ("Terminate                         Delete namespace and all internal objects\n");
-		acpi_os_printf ("Thread <Threads><Loops><Name_path> Spawn threads to execute method(s)\n");
-		return;
-
-	case 'M':
-		acpi_os_printf ("\n_control Method Execution Commands\n\n");
-		acpi_os_printf ("Arguments (or Args)               Display method arguments\n");
-		acpi_os_printf ("Breakpoint <Aml_offset>           Set an AML execution breakpoint\n");
-		acpi_os_printf ("Call                              Run to next control method invocation\n");
-		acpi_os_printf ("Go                                Allow method to run to completion\n");
-		acpi_os_printf ("Information                       Display info about the current method\n");
-		acpi_os_printf ("Into                              Step into (not over) a method call\n");
-		acpi_os_printf ("List [# of Aml Opcodes]           Display method ASL statements\n");
-		acpi_os_printf ("Locals                            Display method local variables\n");
-		acpi_os_printf ("Results                           Display method result stack\n");
-		acpi_os_printf ("Set <A|L> <#> <Value>             Set method data (Arguments/Locals)\n");
-		acpi_os_printf ("Stop                              Terminate control method\n");
-		acpi_os_printf ("Tree                              Display control method calling tree\n");
-		acpi_os_printf ("<Enter>                           Single step next AML opcode (over calls)\n");
-		return;
-
-	case 'F':
-		acpi_os_printf ("\n_file I/O Commands\n\n");
-		acpi_os_printf ("Close                             Close debug output file\n");
-		acpi_os_printf ("Open <Output Filename>            Open a file for debug output\n");
-		acpi_os_printf ("Load <Input Filename>             Load ACPI table from a file\n");
-		return;
-
-	default:
-		acpi_os_printf ("Unrecognized Command Class: %x\n", help_type);
-		return;
-	}
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_get_next_token
- *
- * PARAMETERS:  String          - Command buffer
- *              Next            - Return value, end of next token
- *
- * RETURN:      Pointer to the start of the next token.
- *
- * DESCRIPTION: Command line parsing.  Get the next token on the command line
- *
- ******************************************************************************/
-
-NATIVE_CHAR *
-acpi_db_get_next_token (
-	NATIVE_CHAR             *string,
-	NATIVE_CHAR             **next)
-{
-	NATIVE_CHAR             *start;
-
-	/* At end of buffer? */
-
-	if (!string || !(*string))
-	{
-		return (NULL);
-	}
-
-
-	/* Get rid of any spaces at the beginning */
-
-	if (*string == ' ')
-	{
-		while (*string && (*string == ' '))
-		{
-			string++;
-		}
-
-		if (!(*string))
-		{
-			return (NULL);
-		}
-	}
-
-	start = string;
-
-	/* Find end of token */
-
-	while (*string && (*string != ' '))
-	{
-		string++;
-	}
-
-
-	if (!(*string))
-	{
-		*next = NULL;
-	}
-
-	else
-	{
-		*string = 0;
-		*next = string + 1;
-	}
-
-	return (start);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_get_line
- *
- * PARAMETERS:  Input_buffer        - Command line buffer
- *
- * RETURN:      None
- *
- * DESCRIPTION: Get the next command line from the user.  Gets entire line
- *              up to the next newline
- *
- ******************************************************************************/
-
-u32
-acpi_db_get_line (
-	NATIVE_CHAR             *input_buffer)
-{
-	u32                     i;
-	u32                     count;
-	NATIVE_CHAR             *next;
-	NATIVE_CHAR             *this;
-
-
-	STRCPY (acpi_gbl_db_parsed_buf, input_buffer);
-	STRUPR (acpi_gbl_db_parsed_buf);
-
-	this = acpi_gbl_db_parsed_buf;
-	for (i = 0; i < DB_MAX_ARGS; i++)
-	{
-		acpi_gbl_db_args[i] = acpi_db_get_next_token (this, &next);
-		if (!acpi_gbl_db_args[i])
-		{
-			break;
-		}
-
-		this = next;
-	}
-
-
-	/* Uppercase the actual command */
-
-	if (acpi_gbl_db_args[0])
-	{
-		STRUPR (acpi_gbl_db_args[0]);
-	}
-
-	count = i;
-	if (count)
-	{
-		count--;  /* Number of args only */
-	}
-
-	return (count);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_match_command
- *
- * PARAMETERS:  User_command            - User command line
- *
- * RETURN:      Index into command array, -1 if not found
- *
- * DESCRIPTION: Search command array for a command match
- *
- ******************************************************************************/
-
-u32
-acpi_db_match_command (
-	NATIVE_CHAR             *user_command)
-{
-	u32                     i;
-
-
-	if (!user_command || user_command[0] == 0)
-	{
-		return (CMD_NULL);
-	}
-
-	for (i = CMD_FIRST_VALID; acpi_gbl_db_commands[i].name; i++)
-	{
-		if (STRSTR (acpi_gbl_db_commands[i].name, user_command) == acpi_gbl_db_commands[i].name)
-		{
-			return (i);
-		}
-	}
-
-	/* Command not recognized */
-
-	return (CMD_NOT_FOUND);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_command_dispatch
- *
- * PARAMETERS:  Input_buffer        - Command line buffer
- *              Walk_state          - Current walk
- *              Op                  - Current (executing) parse op
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Command dispatcher.  Called from two places:
- *
- ******************************************************************************/
-
-acpi_status
-acpi_db_command_dispatch (
-	NATIVE_CHAR             *input_buffer,
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op)
-{
-	u32                     temp;
-	u32                     command_index;
-	u32                     param_count;
-	NATIVE_CHAR             *command_line;
-	acpi_status             status = AE_CTRL_TRUE;
-
-
-	/* If Acpi_terminate has been called, terminate this thread */
-
-	if (acpi_gbl_db_terminate_threads)
-	{
-		return (AE_CTRL_TERMINATE);
-	}
-
-	param_count = acpi_db_get_line (input_buffer);
-	command_index = acpi_db_match_command (acpi_gbl_db_args[0]);
-	temp = 0;
-
-	/* Verify that we have the minimum number of params */
-
-	if (param_count < acpi_gbl_db_commands[command_index].min_args)
-	{
-		acpi_os_printf ("%d parameters entered, [%s] requires %d parameters\n",
-				  param_count, acpi_gbl_db_commands[command_index].name, acpi_gbl_db_commands[command_index].min_args);
-		return (AE_CTRL_TRUE);
-	}
-
-	/* Decode and dispatch the command */
-
-	switch (command_index)
-	{
-	case CMD_NULL:
-		if (op)
-		{
-			return (AE_OK);
-		}
-		break;
-
-	case CMD_ALLOCATIONS:
-
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
-		acpi_ut_dump_allocations ((u32) -1, NULL);
-#endif
-		break;
-
-	case CMD_ARGS:
-	case CMD_ARGUMENTS:
-		acpi_db_display_arguments ();
-		break;
-
-	case CMD_BREAKPOINT:
-		acpi_db_set_method_breakpoint (acpi_gbl_db_args[1], walk_state, op);
-		break;
-
-	case CMD_CALL:
-		acpi_db_set_method_call_breakpoint (op);
-		status = AE_OK;
-		break;
-
-	case CMD_CLOSE:
-		acpi_db_close_debug_file ();
-		break;
-
-	case CMD_DEBUG:
-		acpi_db_execute (acpi_gbl_db_args[1], &acpi_gbl_db_args[2], EX_SINGLE_STEP);
-		break;
-
-	case CMD_DUMP:
-		acpi_db_decode_and_display_object (acpi_gbl_db_args[1], acpi_gbl_db_args[2]);
-		break;
-
-	case CMD_ENABLEACPI:
-		status = acpi_enable();
-		if (ACPI_FAILURE(status))
-		{
-			acpi_os_printf("Acpi_enable failed (Status=%X)\n", status);
-			return (status);
-		}
-		break;
-
-	case CMD_EVENT:
-		acpi_os_printf ("Event command not implemented\n");
-		break;
-
-	case CMD_EXECUTE:
-		acpi_db_execute (acpi_gbl_db_args[1], &acpi_gbl_db_args[2], EX_NO_SINGLE_STEP);
-		break;
-
-	case CMD_FIND:
-		acpi_db_find_name_in_namespace (acpi_gbl_db_args[1]);
-		break;
-
-	case CMD_GO:
-		acpi_gbl_cm_single_step = FALSE;
-		return (AE_OK);
-
-	case CMD_HELP:
-	case CMD_HELP2:
-		acpi_db_display_help (acpi_gbl_db_args[1]);
-		break;
-
-	case CMD_HISTORY:
-		acpi_db_display_history ();
-		break;
-
-	case CMD_HISTORY_EXE:
-		command_line = acpi_db_get_from_history (acpi_gbl_db_args[1]);
-		if (!command_line)
-		{
-			return (AE_CTRL_TRUE);
-		}
-
-		status = acpi_db_command_dispatch (command_line, walk_state, op);
-		if (ACPI_SUCCESS (status))
-		{
-			status = AE_CTRL_TRUE;
-		}
-		return (status);
-		break;
-
-	case CMD_HISTORY_LAST:
-		command_line = acpi_db_get_from_history (NULL);
-		if (!command_line)
-		{
-			return (AE_CTRL_TRUE);
-		}
-
-		status = acpi_db_command_dispatch (command_line, walk_state, op);
-		if (ACPI_SUCCESS (status))
-		{
-			status = AE_CTRL_TRUE;
-		}
-		return (status);
-
-	case CMD_INFORMATION:
-		acpi_db_display_method_info (op);
-		break;
-
-	case CMD_INTO:
-		if (op)
-		{
-			acpi_gbl_cm_single_step = TRUE;
-
-/* TBD: Must get current walk state */
-			/* Acpi_gbl_Method_breakpoint = 0; */
-			return (AE_OK);
-		}
-		break;
-
-	case CMD_LEVEL:
-		if (param_count == 0)
-		{
-			acpi_os_printf ("Current debug level for file output is:  %8.8lX\n", acpi_gbl_db_debug_level);
-			acpi_os_printf ("Current debug level for console output is: %8.8lX\n", acpi_gbl_db_console_debug_level);
-		}
-		else if (param_count == 2)
-		{
-			temp = acpi_gbl_db_console_debug_level;
-			acpi_gbl_db_console_debug_level = STRTOUL (acpi_gbl_db_args[1], NULL, 16);
-			acpi_os_printf ("Debug Level for console output was %8.8lX, now %8.8lX\n", temp, acpi_gbl_db_console_debug_level);
-		}
-		else
-		{
-			temp = acpi_gbl_db_debug_level;
-			acpi_gbl_db_debug_level = STRTOUL (acpi_gbl_db_args[1], NULL, 16);
-			acpi_os_printf ("Debug Level for file output was %8.8lX, now %8.8lX\n", temp, acpi_gbl_db_debug_level);
-		}
-		break;
-
-	case CMD_LIST:
-		acpi_db_disassemble_aml (acpi_gbl_db_args[1], op);
-		break;
-
-	case CMD_LOAD:
-		status = acpi_db_load_acpi_table (acpi_gbl_db_args[1]);
-		if (ACPI_FAILURE (status))
-		{
-			return (status);
-		}
-		break;
-
-	case CMD_LOCKS:
-		acpi_db_display_locks ();
-		break;
-
-	case CMD_LOCALS:
-		acpi_db_display_locals ();
-		break;
-
-	case CMD_METHODS:
-		acpi_db_display_objects ("METHOD", acpi_gbl_db_args[1]);
-		break;
-
-	case CMD_NAMESPACE:
-		acpi_db_dump_namespace (acpi_gbl_db_args[1], acpi_gbl_db_args[2]);
-		break;
-
-	case CMD_NOTIFY:
-		temp = STRTOUL (acpi_gbl_db_args[2], NULL, 0);
-		acpi_db_send_notify (acpi_gbl_db_args[1], temp);
-		break;
-
-	case CMD_OBJECT:
-		acpi_db_display_objects (STRUPR (acpi_gbl_db_args[1]), acpi_gbl_db_args[2]);
-		break;
-
-	case CMD_OPEN:
-		acpi_db_open_debug_file (acpi_gbl_db_args[1]);
-		break;
-
-	case CMD_OWNER:
-		acpi_db_dump_namespace_by_owner (acpi_gbl_db_args[1], acpi_gbl_db_args[2]);
-		break;
-
-	case CMD_PREFIX:
-		acpi_db_set_scope (acpi_gbl_db_args[1]);
-		break;
-
-	case CMD_REFERENCES:
-		acpi_db_find_references (acpi_gbl_db_args[1]);
-		break;
-
-	case CMD_RESOURCES:
-		acpi_db_display_resources (acpi_gbl_db_args[1]);
-		break;
-
-	case CMD_RESULTS:
-		acpi_db_display_results ();
-		break;
-
-	case CMD_SET:
-		acpi_db_set_method_data (acpi_gbl_db_args[1], acpi_gbl_db_args[2], acpi_gbl_db_args[3]);
-		break;
-
-	case CMD_STATS:
-		acpi_db_display_statistics (acpi_gbl_db_args[1]);
-		break;
-
-	case CMD_STOP:
-		return (AE_AML_ERROR);
-		break;
-
-	case CMD_TABLES:
-		acpi_db_display_table_info (acpi_gbl_db_args[1]);
-		break;
-
-	case CMD_TERMINATE:
-		acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT);
-		acpi_ut_subsystem_shutdown ();
-
-		/* TBD: [Restructure] Need some way to re-initialize without re-creating the semaphores! */
-
-		/*  Acpi_initialize (NULL); */
-		break;
-
-	case CMD_THREADS:
-		acpi_db_create_execution_threads (acpi_gbl_db_args[1], acpi_gbl_db_args[2], acpi_gbl_db_args[3]);
-		break;
-
-	case CMD_TREE:
-		acpi_db_display_calling_tree ();
-		break;
-
-	case CMD_UNLOAD:
-		acpi_db_unload_acpi_table (acpi_gbl_db_args[1], acpi_gbl_db_args[2]);
-		break;
-
-	case CMD_EXIT:
-	case CMD_QUIT:
-		if (op)
-		{
-			acpi_os_printf ("Method execution terminated\n");
-			return (AE_CTRL_TERMINATE);
-		}
-
-		if (!acpi_gbl_db_output_to_file)
-		{
-			acpi_dbg_level = DEBUG_DEFAULT;
-		}
-
-		/* Shutdown */
-
-		/* Acpi_ut_subsystem_shutdown (); */
-		acpi_db_close_debug_file ();
-
-		acpi_gbl_db_terminate_threads = TRUE;
-
-		return (AE_CTRL_TERMINATE);
-
-	case CMD_NOT_FOUND:
-		acpi_os_printf ("Unknown Command\n");
-		return (AE_CTRL_TRUE);
-	}
-
-
-	/* Add all commands that come here to the history buffer */
-
-	acpi_db_add_to_history (input_buffer);
-	return (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_execute_thread
- *
- * PARAMETERS:  Context         - Not used
- *
- * RETURN:      None
- *
- * DESCRIPTION: Debugger execute thread.  Waits for a command line, then
- *              simply dispatches it.
- *
- ******************************************************************************/
-
-void
-acpi_db_execute_thread (
-	void                    *context)
-{
-	acpi_status             status = AE_OK;
-
-
-	while (status != AE_CTRL_TERMINATE)
-	{
-		acpi_gbl_method_executing = FALSE;
-		acpi_gbl_step_to_next_call = FALSE;
-
-		acpi_ut_acquire_mutex (ACPI_MTX_DEBUG_CMD_READY);
-		status = acpi_db_command_dispatch (acpi_gbl_db_line_buf, NULL, NULL);
-		acpi_ut_release_mutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
-	}
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_single_thread
- *
- * PARAMETERS:  None
- *
- * RETURN:      None
- *
- * DESCRIPTION: Debugger execute thread.  Waits for a command line, then
- *              simply dispatches it.
- *
- ******************************************************************************/
-
-void
-acpi_db_single_thread (
-	void)
-{
-	acpi_status             status = AE_OK;
-
-
-	acpi_gbl_method_executing = FALSE;
-	acpi_gbl_step_to_next_call = FALSE;
-
-	status = acpi_db_command_dispatch (acpi_gbl_db_line_buf, NULL, NULL);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_user_commands
- *
- * PARAMETERS:  Prompt              - User prompt (depends on mode)
- *              Op                  - Current executing parse op
- *
- * RETURN:      None
- *
- * DESCRIPTION: Command line execution for the AML debugger.  Commands are
- *              matched and dispatched here.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_db_user_commands (
-	NATIVE_CHAR             prompt,
-	acpi_parse_object       *op)
-{
-	acpi_status             status = AE_OK;
-
-
-	/* TBD: [Restructure] Need a separate command line buffer for step mode */
-
-	while (!acpi_gbl_db_terminate_threads)
-	{
-		/* Force output to console until a command is entered */
-
-		acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
-
-		/* Different prompt if method is executing */
-
-		if (!acpi_gbl_method_executing)
-		{
-			acpi_os_printf ("%1c ", DB_COMMAND_PROMPT);
-		}
-		else
-		{
-			acpi_os_printf ("%1c ", DB_EXECUTE_PROMPT);
-		}
-
-		/* Get the user input line */
-
-		acpi_os_get_line (acpi_gbl_db_line_buf);
-
-
-		/* Check for single or multithreaded debug */
-
-		if (acpi_gbl_debugger_configuration & DEBUGGER_MULTI_THREADED)
-		{
-			/*
-			 * Signal the debug thread that we have a command to execute,
-			 * and wait for the command to complete.
-			 */
-			acpi_ut_release_mutex (ACPI_MTX_DEBUG_CMD_READY);
-			acpi_ut_acquire_mutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
-		}
-
-		else
-		{
-			/* Just call to the command line interpreter */
-
-			acpi_db_single_thread ();
-		}
-	}
-
-
-	/*
-	 * Only this thread (the original thread) should actually terminate the subsystem,
-	 * because all the semaphores are deleted during termination
-	 */
-	acpi_terminate ();
-	return (status);
-}
-
-
-#endif  /* ENABLE_DEBUGGER */
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/debugger/dbstats.c linux-2.4.22-pre2/drivers/acpi/debugger/dbstats.c
--- linux-2.4.21/drivers/acpi/debugger/dbstats.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/debugger/dbstats.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,456 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: dbstats - Generation and display of ACPI table statistics
- *              $Revision: 47 $
- *
- ******************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include <acpi.h>
-#include <acdebug.h>
-#include <amlcode.h>
-#include <acparser.h>
-#include <acnamesp.h>
-
-#ifdef ENABLE_DEBUGGER
-
-#define _COMPONENT          ACPI_DEBUGGER
-	 MODULE_NAME         ("dbstats")
-
-/*
- * Statistics subcommands
- */
-ARGUMENT_INFO               acpi_db_stat_types [] =
-{ {"ALLOCATIONS"},
-	{"OBJECTS"},
-	{"MEMORY"},
-	{"MISC"},
-	{"TABLES"},
-	{"SIZES"},
-	{"STACK"},
-	{NULL}           /* Must be null terminated */
-};
-
-#define CMD_ALLOCATIONS     0
-#define CMD_OBJECTS         1
-#define CMD_MEMORY          2
-#define CMD_MISC            3
-#define CMD_TABLES          4
-#define CMD_SIZES           5
-#define CMD_STACK           6
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_enumerate_object
- *
- * PARAMETERS:  Obj_desc            - Object to be counted
- *
- * RETURN:      None
- *
- * DESCRIPTION: Add this object to the global counts, by object type.
- *              Recursively handles subobjects and packages.
- *
- *              [TBD] Restructure - remove recursion.
- *
- ******************************************************************************/
-
-void
-acpi_db_enumerate_object (
-	acpi_operand_object     *obj_desc)
-{
-	u32                     type;
-	u32                     i;
-
-
-	if (!obj_desc)
-	{
-		return;
-	}
-
-
-	/* Enumerate this object first */
-
-	acpi_gbl_num_objects++;
-
-	type = obj_desc->common.type;
-	if (type > INTERNAL_TYPE_NODE_MAX)
-	{
-		acpi_gbl_obj_type_count_misc++;
-	}
-	else
-	{
-		acpi_gbl_obj_type_count [type]++;
-	}
-
-	/* Count the sub-objects */
-
-	switch (type)
-	{
-	case ACPI_TYPE_PACKAGE:
-		for (i = 0; i< obj_desc->package.count; i++)
-		{
-			acpi_db_enumerate_object (obj_desc->package.elements[i]);
-		}
-		break;
-
-	case ACPI_TYPE_DEVICE:
-		acpi_db_enumerate_object (obj_desc->device.sys_handler);
-		acpi_db_enumerate_object (obj_desc->device.drv_handler);
-		acpi_db_enumerate_object (obj_desc->device.addr_handler);
-		break;
-
-	case ACPI_TYPE_REGION:
-		acpi_db_enumerate_object (obj_desc->region.addr_handler);
-		break;
-
-	case ACPI_TYPE_POWER:
-		acpi_db_enumerate_object (obj_desc->power_resource.sys_handler);
-		acpi_db_enumerate_object (obj_desc->power_resource.drv_handler);
-		break;
-
-	case ACPI_TYPE_PROCESSOR:
-		acpi_db_enumerate_object (obj_desc->processor.sys_handler);
-		acpi_db_enumerate_object (obj_desc->processor.drv_handler);
-		acpi_db_enumerate_object (obj_desc->processor.addr_handler);
-		break;
-
-	case ACPI_TYPE_THERMAL:
-		acpi_db_enumerate_object (obj_desc->thermal_zone.sys_handler);
-		acpi_db_enumerate_object (obj_desc->thermal_zone.drv_handler);
-		acpi_db_enumerate_object (obj_desc->thermal_zone.addr_handler);
-		break;
-	}
-}
-
-
-#ifndef PARSER_ONLY
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_classify_one_object
- *
- * PARAMETERS:  Callback for Walk_namespace
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Enumerate both the object descriptor (including subobjects) and
- *              the parent namespace node.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_db_classify_one_object (
-	acpi_handle             obj_handle,
-	u32                     nesting_level,
-	void                    *context,
-	void                    **return_value)
-{
-	acpi_namespace_node     *node;
-	acpi_operand_object     *obj_desc;
-	u32                     type;
-
-
-	acpi_gbl_num_nodes++;
-
-	node = (acpi_namespace_node *) obj_handle;
-	obj_desc = ((acpi_namespace_node *) obj_handle)->object;
-
-	acpi_db_enumerate_object (obj_desc);
-
-	type = node->type;
-	if (type > INTERNAL_TYPE_NODE_MAX)
-	{
-		acpi_gbl_node_type_count_misc++;
-	}
-
-	else
-	{
-		acpi_gbl_node_type_count [type]++;
-	}
-
-	return AE_OK;
-
-
-	/* TBD: These need to be counted during the initial parsing phase */
-	/*
-	if (Acpi_ps_is_named_op (Op->Opcode))
-	{
-		Num_nodes++;
-	}
-
-	if (Is_method)
-	{
-		Num_method_elements++;
-	}
-
-	Num_grammar_elements++;
-	Op = Acpi_ps_get_depth_next (Root, Op);
-
-	Size_of_parse_tree          = (Num_grammar_elements - Num_method_elements) * (u32) sizeof (acpi_parse_object);
-	Size_of_method_trees        = Num_method_elements * (u32) sizeof (acpi_parse_object);
-	Size_of_node_entries        = Num_nodes * (u32) sizeof (acpi_namespace_node);
-	Size_of_acpi_objects        = Num_nodes * (u32) sizeof (acpi_operand_object);
-
-	*/
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_count_namespace_objects
- *
- * PARAMETERS:  None
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Count and classify the entire namespace, including all
- *              namespace nodes and attached objects.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_db_count_namespace_objects (
-	void)
-{
-	u32                     i;
-
-
-	acpi_gbl_num_nodes = 0;
-	acpi_gbl_num_objects = 0;
-
-	acpi_gbl_obj_type_count_misc = 0;
-	for (i = 0; i < (INTERNAL_TYPE_NODE_MAX -1); i++)
-	{
-		acpi_gbl_obj_type_count [i] = 0;
-		acpi_gbl_node_type_count [i] = 0;
-	}
-
-	acpi_ns_walk_namespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
-			   FALSE, acpi_db_classify_one_object, NULL, NULL);
-
-	return (AE_OK);
-}
-
-#endif
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_display_statistics
- *
- * PARAMETERS:  Type_arg        - Subcommand
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Display various statistics
- *
- ******************************************************************************/
-
-acpi_status
-acpi_db_display_statistics (
-	NATIVE_CHAR             *type_arg)
-{
-	u32                     i;
-	u32                     type;
-	u32                     outstanding;
-	u32                     size;
-
-
-	if (!acpi_gbl_DSDT)
-	{
-		acpi_os_printf ("*** Warning: There is no DSDT loaded\n");
-	}
-
-	if (!type_arg)
-	{
-		acpi_os_printf ("The following subcommands are available:\n  ALLOCATIONS, OBJECTS, MEMORY, MISC, SIZES, TABLES\n");
-		return (AE_OK);
-	}
-
-	STRUPR (type_arg);
-	type = acpi_db_match_argument (type_arg, acpi_db_stat_types);
-	if (type == (u32) -1)
-	{
-		acpi_os_printf ("Invalid or unsupported argument\n");
-		return (AE_OK);
-	}
-
-
-	switch (type)
-	{
-#ifndef PARSER_ONLY
-	case CMD_ALLOCATIONS:
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
-		acpi_ut_dump_allocation_info ();
-#endif
-		break;
-#endif
-
-	case CMD_TABLES:
-
-		acpi_os_printf ("ACPI Table Information:\n\n");
-		if (acpi_gbl_DSDT)
-		{
-			acpi_os_printf ("DSDT Length:................% 7ld (%X)\n", acpi_gbl_DSDT->length, acpi_gbl_DSDT->length);
-		}
-		break;
-
-	case CMD_OBJECTS:
-
-#ifndef PARSER_ONLY
-
-		acpi_db_count_namespace_objects ();
-
-		acpi_os_printf ("\n_objects defined in the current namespace:\n\n");
-
-		acpi_os_printf ("%16.16s % 10.10s % 10.10s\n", "ACPI_TYPE", "NODES", "OBJECTS");
-
-		for (i = 0; i < INTERNAL_TYPE_NODE_MAX; i++)
-		{
-			acpi_os_printf ("%16.16s % 10ld% 10ld\n", acpi_ut_get_type_name (i),
-				acpi_gbl_node_type_count [i], acpi_gbl_obj_type_count [i]);
-		}
-		acpi_os_printf ("%16.16s % 10ld% 10ld\n", "Misc/Unknown",
-			acpi_gbl_node_type_count_misc, acpi_gbl_obj_type_count_misc);
-
-		acpi_os_printf ("%16.16s % 10ld% 10ld\n", "TOTALS:",
-			acpi_gbl_num_nodes, acpi_gbl_num_objects);
-
-#endif
-		break;
-
-	case CMD_MEMORY:
-
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
-		acpi_os_printf ("\n----Object and Cache Statistics---------------------------------------------\n");
-
-		for (i = 0; i < ACPI_NUM_MEM_LISTS; i++)
-		{
-			acpi_os_printf ("\n%s\n", acpi_gbl_memory_lists[i].list_name);
-
-			if (acpi_gbl_memory_lists[i].max_cache_depth > 0)
-			{
-				acpi_os_printf ("  Cache: [Depth Max Avail Size]         % 7d % 7d % 7d % 7d B\n",
-						acpi_gbl_memory_lists[i].cache_depth,
-						acpi_gbl_memory_lists[i].max_cache_depth,
-						acpi_gbl_memory_lists[i].max_cache_depth - acpi_gbl_memory_lists[i].cache_depth,
-						(acpi_gbl_memory_lists[i].cache_depth * acpi_gbl_memory_lists[i].object_size));
-
-				acpi_os_printf ("  Cache: [Requests Hits Misses Obj_size] % 7d % 7d % 7d % 7d B\n",
-						acpi_gbl_memory_lists[i].cache_requests,
-						acpi_gbl_memory_lists[i].cache_hits,
-						acpi_gbl_memory_lists[i].cache_requests - acpi_gbl_memory_lists[i].cache_hits,
-						acpi_gbl_memory_lists[i].object_size);
-			}
-
-			outstanding = acpi_gbl_memory_lists[i].total_allocated -
-					  acpi_gbl_memory_lists[i].total_freed -
-					  acpi_gbl_memory_lists[i].cache_depth;
-
-			if (acpi_gbl_memory_lists[i].object_size)
-			{
-				size = ROUND_UP_TO_1K (outstanding * acpi_gbl_memory_lists[i].object_size);
-			}
-			else
-			{
-				size = ROUND_UP_TO_1K (acpi_gbl_memory_lists[i].current_total_size);
-			}
-
-			acpi_os_printf ("  Mem:   [Alloc Free Outstanding Size]  % 7d % 7d % 7d % 7d Kb\n",
-					acpi_gbl_memory_lists[i].total_allocated,
-					acpi_gbl_memory_lists[i].total_freed,
-					outstanding, size);
-		}
-#endif
-
-		break;
-
-	case CMD_MISC:
-
-		acpi_os_printf ("\n_miscellaneous Statistics:\n\n");
-		acpi_os_printf ("Calls to Acpi_ps_find:.. ........% 7ld\n", acpi_gbl_ps_find_count);
-		acpi_os_printf ("Calls to Acpi_ns_lookup:..........% 7ld\n", acpi_gbl_ns_lookup_count);
-
-		acpi_os_printf ("\n");
-
-		acpi_os_printf ("Mutex usage:\n\n");
-		for (i = 0; i < NUM_MTX; i++)
-		{
-			acpi_os_printf ("%-28s:     % 7ld\n", acpi_ut_get_mutex_name (i), acpi_gbl_acpi_mutex_info[i].use_count);
-		}
-		break;
-
-
-	case CMD_SIZES:
-
-		acpi_os_printf ("\n_internal object sizes:\n\n");
-
-		acpi_os_printf ("Common         %3d\n", sizeof (ACPI_OBJECT_COMMON));
-		acpi_os_printf ("Number         %3d\n", sizeof (ACPI_OBJECT_INTEGER));
-		acpi_os_printf ("String         %3d\n", sizeof (ACPI_OBJECT_STRING));
-		acpi_os_printf ("Buffer         %3d\n", sizeof (ACPI_OBJECT_BUFFER));
-		acpi_os_printf ("Package        %3d\n", sizeof (ACPI_OBJECT_PACKAGE));
-		acpi_os_printf ("Buffer_field   %3d\n", sizeof (ACPI_OBJECT_BUFFER_FIELD));
-		acpi_os_printf ("Device         %3d\n", sizeof (ACPI_OBJECT_DEVICE));
-		acpi_os_printf ("Event          %3d\n", sizeof (ACPI_OBJECT_EVENT));
-		acpi_os_printf ("Method         %3d\n", sizeof (ACPI_OBJECT_METHOD));
-		acpi_os_printf ("Mutex          %3d\n", sizeof (ACPI_OBJECT_MUTEX));
-		acpi_os_printf ("Region         %3d\n", sizeof (ACPI_OBJECT_REGION));
-		acpi_os_printf ("Power_resource %3d\n", sizeof (ACPI_OBJECT_POWER_RESOURCE));
-		acpi_os_printf ("Processor      %3d\n", sizeof (ACPI_OBJECT_PROCESSOR));
-		acpi_os_printf ("Thermal_zone   %3d\n", sizeof (ACPI_OBJECT_THERMAL_ZONE));
-		acpi_os_printf ("Region_field   %3d\n", sizeof (ACPI_OBJECT_REGION_FIELD));
-		acpi_os_printf ("Bank_field     %3d\n", sizeof (ACPI_OBJECT_BANK_FIELD));
-		acpi_os_printf ("Index_field    %3d\n", sizeof (ACPI_OBJECT_INDEX_FIELD));
-		acpi_os_printf ("Reference      %3d\n", sizeof (ACPI_OBJECT_REFERENCE));
-		acpi_os_printf ("Notify_handler %3d\n", sizeof (ACPI_OBJECT_NOTIFY_HANDLER));
-		acpi_os_printf ("Addr_handler   %3d\n", sizeof (ACPI_OBJECT_ADDR_HANDLER));
-		acpi_os_printf ("Extra          %3d\n", sizeof (ACPI_OBJECT_EXTRA));
-
-		acpi_os_printf ("\n");
-
-		acpi_os_printf ("Parse_object   %3d\n", sizeof (acpi_parse_object));
-		acpi_os_printf ("Parse2_object  %3d\n", sizeof (acpi_parse2_object));
-		acpi_os_printf ("Operand_object %3d\n", sizeof (acpi_operand_object));
-		acpi_os_printf ("Namespace_node %3d\n", sizeof (acpi_namespace_node));
-
-		break;
-
-
-	case CMD_STACK:
-
-		size = acpi_gbl_entry_stack_pointer - acpi_gbl_lowest_stack_pointer;
-
-		acpi_os_printf ("\n_subsystem Stack Usage:\n\n");
-		acpi_os_printf ("Entry Stack Pointer        %X\n", acpi_gbl_entry_stack_pointer);
-		acpi_os_printf ("Lowest Stack Pointer       %X\n", acpi_gbl_lowest_stack_pointer);
-		acpi_os_printf ("Stack Use                  %X (%d)\n", size, size);
-		acpi_os_printf ("Deepest Procedure Nesting  %d\n", acpi_gbl_deepest_nesting);
-		break;
-	}
-
-	acpi_os_printf ("\n");
-	return (AE_OK);
-}
-
-
-#endif /* ENABLE_DEBUGGER  */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/debugger/dbutils.c linux-2.4.22-pre2/drivers/acpi/debugger/dbutils.c
--- linux-2.4.21/drivers/acpi/debugger/dbutils.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/debugger/dbutils.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,384 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: dbutils - AML debugger utilities
- *              $Revision: 45 $
- *
- ******************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include "acpi.h"
-#include "acparser.h"
-#include "amlcode.h"
-#include "acnamesp.h"
-#include "acparser.h"
-#include "acevents.h"
-#include "acinterp.h"
-#include "acdebug.h"
-#include "acdispat.h"
-
-
-#ifdef ENABLE_DEBUGGER
-
-#define _COMPONENT          ACPI_DEBUGGER
-	 MODULE_NAME         ("dbutils")
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_set_output_destination
- *
- * PARAMETERS:  Output_flags        - Current flags word
- *
- * RETURN:      None
- *
- * DESCRIPTION: Set the current destination for debugger output.  Alos sets
- *              the debug output level accordingly.
- *
- ******************************************************************************/
-
-void
-acpi_db_set_output_destination (
-	u32                     output_flags)
-{
-
-	acpi_gbl_db_output_flags = (u8) output_flags;
-
-	if (output_flags & DB_REDIRECTABLE_OUTPUT) {
-		if (acpi_gbl_db_output_to_file) {
-			acpi_dbg_level = acpi_gbl_db_debug_level;
-		}
-	}
-	else {
-		acpi_dbg_level = acpi_gbl_db_console_debug_level;
-	}
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_dump_buffer
- *
- * PARAMETERS:  Address             - Pointer to the buffer
- *
- * RETURN:      None
- *
- * DESCRIPTION: Print a portion of a buffer
- *
- ******************************************************************************/
-
-void
-acpi_db_dump_buffer (
-	u32                     address)
-{
-
-	acpi_os_printf ("\n_location %X:\n", address);
-
-	acpi_dbg_level |= ACPI_LV_TABLES;
-	acpi_ut_dump_buffer ((u8 *) address, 64, DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_dump_object
- *
- * PARAMETERS:  Obj_desc        - External ACPI object to dump
- *              Level           - Nesting level.
- *
- * RETURN:      None
- *
- * DESCRIPTION: Dump the contents of an ACPI external object
- *
- ******************************************************************************/
-
-void
-acpi_db_dump_object (
-	acpi_object             *obj_desc,
-	u32                     level)
-{
-	u32                     i;
-
-
-	if (!obj_desc) {
-		acpi_os_printf ("[Null Object]\n");
-		return;
-	}
-
-	for (i = 0; i < level; i++) {
-		acpi_os_printf (" ");
-	}
-
-	switch (obj_desc->type) {
-	case ACPI_TYPE_ANY:
-
-		acpi_os_printf ("[Object Reference] = %p\n", obj_desc->reference.handle);
-		break;
-
-
-	case ACPI_TYPE_INTEGER:
-
-		acpi_os_printf ("[Integer] = %8.8X%8.8X\n", HIDWORD (obj_desc->integer.value),
-				 LODWORD (obj_desc->integer.value));
-		break;
-
-
-	case ACPI_TYPE_STRING:
-
-		acpi_os_printf ("[String] Value: ");
-		for (i = 0; i < obj_desc->string.length; i++) {
-			acpi_os_printf ("%c", obj_desc->string.pointer[i]);
-		}
-		acpi_os_printf ("\n");
-		break;
-
-
-	case ACPI_TYPE_BUFFER:
-
-		acpi_os_printf ("[Buffer] = ");
-		acpi_ut_dump_buffer ((u8 *) obj_desc->buffer.pointer, obj_desc->buffer.length, DB_DWORD_DISPLAY, _COMPONENT);
-		break;
-
-
-	case ACPI_TYPE_PACKAGE:
-
-		acpi_os_printf ("[Package] Contains %d Elements: \n", obj_desc->package.count);
-
-		for (i = 0; i < obj_desc->package.count; i++) {
-			acpi_db_dump_object (&obj_desc->package.elements[i], level+1);
-		}
-		break;
-
-
-	case INTERNAL_TYPE_REFERENCE:
-
-		acpi_os_printf ("[Object Reference] = %p\n", obj_desc->reference.handle);
-		break;
-
-
-	case ACPI_TYPE_PROCESSOR:
-
-		acpi_os_printf ("[Processor]\n");
-		break;
-
-
-	case ACPI_TYPE_POWER:
-
-		acpi_os_printf ("[Power Resource]\n");
-		break;
-
-
-	default:
-
-		acpi_os_printf ("[Unknown Type] %X \n", obj_desc->type);
-		break;
-	}
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_prep_namestring
- *
- * PARAMETERS:  Name            - String to prepare
- *
- * RETURN:      None
- *
- * DESCRIPTION: Translate all forward slashes and dots to backslashes.
- *
- ******************************************************************************/
-
-void
-acpi_db_prep_namestring (
-	NATIVE_CHAR             *name)
-{
-
-
-	if (!name) {
-		return;
-	}
-
-	STRUPR (name);
-
-	/* Convert a leading forward slash to a backslash */
-
-	if (*name == '/') {
-		*name = '\\';
-	}
-
-	/* Ignore a leading backslash, this is the root prefix */
-
-	if (*name == '\\') {
-		name++;
-	}
-
-	/* Convert all slash path separators to dots */
-
-	while (*name) {
-		if ((*name == '/') ||
-			(*name == '\\')) {
-			*name = '.';
-		}
-
-		name++;
-	}
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_second_pass_parse
- *
- * PARAMETERS:  Root            - Root of the parse tree
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Second pass parse of the ACPI tables.  We need to wait until
- *              second pass to parse the control methods
- *
- ******************************************************************************/
-
-acpi_status
-acpi_db_second_pass_parse (
-	acpi_parse_object       *root)
-{
-	acpi_parse_object       *op = root;
-	acpi_parse2_object      *method;
-	acpi_parse_object       *search_op;
-	acpi_parse_object       *start_op;
-	acpi_status             status = AE_OK;
-	u32                     base_aml_offset;
-	acpi_walk_state         *walk_state;
-
-
-	FUNCTION_ENTRY ();
-
-
-	acpi_os_printf ("Pass two parse ....\n");
-
-
-	while (op) {
-		if (op->opcode == AML_METHOD_OP) {
-			method = (acpi_parse2_object *) op;
-
-			walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
-					   NULL, NULL, NULL);
-			if (!walk_state) {
-				return (AE_NO_MEMORY);
-			}
-
-
-			walk_state->parser_state.aml        =
-			walk_state->parser_state.aml_start  = method->data;
-			walk_state->parser_state.aml_end    =
-			walk_state->parser_state.pkg_end    = method->data + method->length;
-			walk_state->parser_state.start_scope = op;
-
-			walk_state->descending_callback     = acpi_ds_load1_begin_op;
-			walk_state->ascending_callback      = acpi_ds_load1_end_op;
-
-
-			status = acpi_ps_parse_aml (walk_state);
-
-
-			base_aml_offset = (method->value.arg)->aml_offset + 1;
-			start_op = (method->value.arg)->next;
-			search_op = start_op;
-
-			while (search_op) {
-				search_op->aml_offset += base_aml_offset;
-				search_op = acpi_ps_get_depth_next (start_op, search_op);
-			}
-
-		}
-
-		if (op->opcode == AML_REGION_OP) {
-			/* TBD: [Investigate] this isn't quite the right thing to do! */
-			/*
-			 *
-			 * Method = (ACPI_DEFERRED_OP *) Op;
-			 * Status = Acpi_ps_parse_aml (Op, Method->Body, Method->Body_length);
-			 */
-		}
-
-		if (ACPI_FAILURE (status)) {
-			break;
-		}
-
-		op = acpi_ps_get_depth_next (root, op);
-	}
-
-	return (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_local_ns_lookup
- *
- * PARAMETERS:  Name            - Name to lookup
- *
- * RETURN:      Pointer to a namespace node
- *
- * DESCRIPTION: Lookup a name in the ACPI namespace
- *
- ******************************************************************************/
-
-acpi_namespace_node *
-acpi_db_local_ns_lookup (
-	NATIVE_CHAR             *name)
-{
-	NATIVE_CHAR             *internal_path;
-	acpi_status             status;
-	acpi_namespace_node     *node = NULL;
-
-
-	acpi_db_prep_namestring (name);
-
-	/* Build an internal namestring */
-
-	status = acpi_ns_internalize_name (name, &internal_path);
-	if (ACPI_FAILURE (status)) {
-		acpi_os_printf ("Invalid namestring: %s\n", name);
-		return (NULL);
-	}
-
-	/* Lookup the name */
-
-	/* TBD: [Investigate] what scope do we use? */
-	/* Use the root scope for the start of the search */
-
-	status = acpi_ns_lookup (NULL, internal_path, ACPI_TYPE_ANY, IMODE_EXECUTE,
-			   NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, NULL, &node);
-
-	if (ACPI_FAILURE (status)) {
-		acpi_os_printf ("Could not locate name: %s %s\n", name, acpi_format_exception (status));
-	}
-
-
-	ACPI_MEM_FREE (internal_path);
-
-	return (node);
-}
-
-
-#endif /* ENABLE_DEBUGGER */
-
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/debugger/dbxface.c linux-2.4.22-pre2/drivers/acpi/debugger/dbxface.c
--- linux-2.4.21/drivers/acpi/debugger/dbxface.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/debugger/dbxface.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,321 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: dbxface - AML Debugger external interfaces
- *              $Revision: 45 $
- *
- ******************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include "acpi.h"
-#include "acparser.h"
-#include "amlcode.h"
-#include "acnamesp.h"
-#include "acparser.h"
-#include "acevents.h"
-#include "acinterp.h"
-#include "acdebug.h"
-
-
-#ifdef ENABLE_DEBUGGER
-
-#define _COMPONENT          ACPI_DEBUGGER
-	 MODULE_NAME         ("dbxface")
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_single_step
- *
- * PARAMETERS:  Walk_state      - Current walk
- *              Op              - Current executing op
- *              Opcode_class    - Class of the current AML Opcode
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Called just before execution of an AML opcode.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_db_single_step (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op,
-	u32                     opcode_class)
-{
-	acpi_parse_object       *next;
-	acpi_status             status = AE_OK;
-	u32                     original_debug_level;
-	acpi_parse_object       *display_op;
-
-
-	FUNCTION_ENTRY ();
-
-	/* Is there a breakpoint set? */
-
-	if (walk_state->method_breakpoint) {
-		/* Check if the breakpoint has been reached or passed */
-
-		if (walk_state->method_breakpoint <= op->aml_offset) {
-			/* Hit the breakpoint, resume single step, reset breakpoint */
-
-			acpi_os_printf ("***Break*** at AML offset %X\n", op->aml_offset);
-			acpi_gbl_cm_single_step = TRUE;
-			acpi_gbl_step_to_next_call = FALSE;
-			walk_state->method_breakpoint = 0;
-		}
-	}
-
-	/*
-	 * Check if this is an opcode that we are interested in --
-	 * namely, opcodes that have arguments
-	 */
-	if (op->opcode == AML_INT_NAMEDFIELD_OP) {
-		return (AE_OK);
-	}
-
-	switch (opcode_class) {
-	case AML_CLASS_UNKNOWN:
-	case AML_CLASS_ARGUMENT:    /* constants, literals, etc.  do nothing */
-		return (AE_OK);
-		break;
-	}
-
-	/*
-	 * Under certain debug conditions, display this opcode and its operands
-	 */
-	if ((acpi_gbl_db_output_to_file)        ||
-		(acpi_gbl_cm_single_step)           ||
-		(acpi_dbg_level & ACPI_LV_PARSE)) {
-		if ((acpi_gbl_db_output_to_file)    ||
-			(acpi_dbg_level & ACPI_LV_PARSE)) {
-			acpi_os_printf ("\n[Aml_debug] Next AML Opcode to execute:\n");
-		}
-
-		/*
-		 * Display this op (and only this op - zero out the NEXT field temporarily,
-		 * and disable parser trace output for the duration of the display because
-		 * we don't want the extraneous debug output)
-		 */
-		original_debug_level = acpi_dbg_level;
-		acpi_dbg_level &= ~(ACPI_LV_PARSE | ACPI_LV_FUNCTIONS);
-		next = op->next;
-		op->next = NULL;
-
-
-		display_op = op;
-		if (op->parent) {
-			if ((op->parent->opcode == AML_IF_OP) ||
-				(op->parent->opcode == AML_WHILE_OP)) {
-				display_op = op->parent;
-			}
-		}
-
-		/* Now we can display it */
-
-		acpi_db_display_op (walk_state, display_op, ACPI_UINT32_MAX);
-
-		if ((op->opcode == AML_IF_OP) ||
-			(op->opcode == AML_WHILE_OP)) {
-			if (walk_state->control_state->common.value) {
-				acpi_os_printf ("Predicate was TRUE, executed block\n");
-			}
-			else {
-				acpi_os_printf ("Predicate is FALSE, skipping block\n");
-			}
-		}
-
-		else if (op->opcode == AML_ELSE_OP) {
-			/* TBD */
-		}
-
-		/* Restore everything */
-
-		op->next = next;
-		acpi_os_printf ("\n");
-		acpi_dbg_level = original_debug_level;
-	}
-
-	/* If we are not single stepping, just continue executing the method */
-
-	if (!acpi_gbl_cm_single_step) {
-		return (AE_OK);
-	}
-
-
-	/*
-	 * If we are executing a step-to-call command,
-	 * Check if this is a method call.
-	 */
-	if (acpi_gbl_step_to_next_call) {
-		if (op->opcode != AML_INT_METHODCALL_OP) {
-			/* Not a method call, just keep executing */
-
-			return (AE_OK);
-		}
-
-		/* Found a method call, stop executing */
-
-		acpi_gbl_step_to_next_call = FALSE;
-	}
-
-
-	/*
-	 * If the next opcode is a method call, we will "step over" it
-	 * by default.
-	 */
-	if (op->opcode == AML_INT_METHODCALL_OP) {
-		acpi_gbl_cm_single_step = FALSE; /* No more single step while executing called method */
-
-		/* Set the breakpoint on the call, it will stop execution as soon as we return */
-
-		/* TBD: [Future] don't kill the user breakpoint! */
-
-		walk_state->method_breakpoint = /* Op->Aml_offset + */ 1; /* Must be non-zero! */
-	}
-
-
-	/* TBD: [Investigate] what are the namespace locking issues here */
-
-	/* Acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); */
-
-	/* Go into the command loop and await next user command */
-
-	acpi_gbl_method_executing = TRUE;
-	status = AE_CTRL_TRUE;
-	while (status == AE_CTRL_TRUE) {
-		if (acpi_gbl_debugger_configuration == DEBUGGER_MULTI_THREADED) {
-			/* Handshake with the front-end that gets user command lines */
-
-			acpi_ut_release_mutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
-			acpi_ut_acquire_mutex (ACPI_MTX_DEBUG_CMD_READY);
-		}
-
-		else {
-			/* Single threaded, we must get a command line ourselves */
-
-			/* Force output to console until a command is entered */
-
-			acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
-
-			/* Different prompt if method is executing */
-
-			if (!acpi_gbl_method_executing) {
-				acpi_os_printf ("%1c ", DB_COMMAND_PROMPT);
-			}
-			else {
-				acpi_os_printf ("%1c ", DB_EXECUTE_PROMPT);
-			}
-
-			/* Get the user input line */
-
-			acpi_os_get_line (acpi_gbl_db_line_buf);
-		}
-
-		status = acpi_db_command_dispatch (acpi_gbl_db_line_buf, walk_state, op);
-	}
-
-	/* Acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); */
-
-	/* User commands complete, continue execution of the interrupted method */
-
-	return (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_initialize
- *
- * PARAMETERS:  None
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Init and start debugger
- *
- ******************************************************************************/
-
-int
-acpi_db_initialize (void)
-{
-
-
-	/* Init globals */
-
-	acpi_gbl_db_buffer = acpi_os_callocate (ACPI_DEBUG_BUFFER_SIZE);
-
-	/* Initial scope is the root */
-
-	acpi_gbl_db_scope_buf [0] = '\\';
-	acpi_gbl_db_scope_buf [1] = 0;
-
-
-	/*
-	 * If configured for multi-thread support, the debug executor runs in
-	 * a separate thread so that the front end can be in another address
-	 * space, environment, or even another machine.
-	 */
-	if (acpi_gbl_debugger_configuration & DEBUGGER_MULTI_THREADED) {
-		/* These were created with one unit, grab it */
-
-		acpi_ut_acquire_mutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
-		acpi_ut_acquire_mutex (ACPI_MTX_DEBUG_CMD_READY);
-
-		/* Create the debug execution thread to execute commands */
-
-		acpi_os_queue_for_execution (0, acpi_db_execute_thread, NULL);
-	}
-
-	if (!acpi_gbl_db_opt_verbose) {
-		acpi_gbl_db_disasm_indent = " ";
-		acpi_gbl_db_opt_disasm = TRUE;
-		acpi_gbl_db_opt_stats = FALSE;
-	}
-
-	return (0);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_db_terminate
- *
- * PARAMETERS:  None
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Stop debugger
- *
- ******************************************************************************/
-
-void
-acpi_db_terminate (void)
-{
-
-	if (acpi_gbl_db_table_ptr) {
-		acpi_os_free (acpi_gbl_db_table_ptr);
-	}
-	if (acpi_gbl_db_buffer) {
-		acpi_os_free (acpi_gbl_db_buffer);
-	}
-}
-
-
-#endif /* ENABLE_DEBUGGER */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/dispatcher/Makefile linux-2.4.22-pre2/drivers/acpi/dispatcher/Makefile
--- linux-2.4.21/drivers/acpi/dispatcher/Makefile	2001-06-21 00:47:39.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/dispatcher/Makefile	2003-06-26 21:43:13.000000000 +0000
@@ -1,11 +1,10 @@
 #
 # Makefile for all Linux ACPI interpreter subdirectories
-# EXCEPT for the ospm directory
 #
 
 O_TARGET := $(notdir $(CURDIR)).o
 
-obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/dispatcher/dsfield.c linux-2.4.22-pre2/drivers/acpi/dispatcher/dsfield.c
--- linux-2.4.21/drivers/acpi/dispatcher/dsfield.c	2002-11-28 23:53:12.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/dispatcher/dsfield.c	2003-06-26 21:43:12.000000000 +0000
@@ -1,78 +1,98 @@
 /******************************************************************************
  *
  * Module Name: dsfield - Dispatcher field routines
- *              $Revision: 46 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "amlcode.h"
-#include "acdispat.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "acparser.h"
+#include <acpi/acpi.h>
+#include <acpi/amlcode.h>
+#include <acpi/acdispat.h>
+#include <acpi/acinterp.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acparser.h>
 
 
 #define _COMPONENT          ACPI_DISPATCHER
-	 MODULE_NAME         ("dsfield")
+	 ACPI_MODULE_NAME    ("dsfield")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_create_buffer_field
+ * FUNCTION:    acpi_ds_create_buffer_field
  *
  * PARAMETERS:  Opcode              - The opcode to be executed
  *              Operands            - List of operands for the opcode
- *              Walk_state          - Current state
+ *              walk_state          - Current state
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Execute the Create_field operators:
- *              Create_bit_field_op,
- *              Create_byte_field_op,
- *              Create_word_field_op,
- *              Create_dWord_field_op,
- *              Create_qWord_field_op,
- *              Create_field_op     (all of which define fields in buffers)
+ * DESCRIPTION: Execute the create_field operators:
+ *              create_bit_field_op,
+ *              create_byte_field_op,
+ *              create_word_field_op,
+ *              create_dword_field_op,
+ *              create_qword_field_op,
+ *              create_field_op     (all of which define fields in buffers)
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ds_create_buffer_field (
-	acpi_parse_object       *op,
-	acpi_walk_state         *walk_state)
+	union acpi_parse_object         *op,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_parse_object       *arg;
-	acpi_namespace_node     *node;
-	acpi_status             status;
-	acpi_operand_object     *obj_desc;
+	union acpi_parse_object         *arg;
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
+	union acpi_operand_object       *obj_desc;
+	union acpi_operand_object       *second_desc = NULL;
+	u32                             flags;
 
 
-	FUNCTION_TRACE ("Ds_create_buffer_field");
+	ACPI_FUNCTION_TRACE ("ds_create_buffer_field");
 
 
-	/* Get the Name_string argument */
+	/* Get the name_string argument */
 
-	if (op->opcode == AML_CREATE_FIELD_OP) {
+	if (op->common.aml_opcode == AML_CREATE_FIELD_OP) {
 		arg = acpi_ps_get_arg (op, 3);
 	}
 	else {
@@ -86,13 +106,25 @@
 	}
 
 	/*
-	 * Enter the Name_string into the namespace
+	 * During the load phase, we want to enter the name of the field into
+	 * the namespace.  During the execute phase (when we evaluate the size
+	 * operand), we want to lookup the name
 	 */
-	status = acpi_ns_lookup (walk_state->scope_info, arg->value.string,
-			 INTERNAL_TYPE_DEF_ANY, IMODE_LOAD_PASS1,
-			 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
-			 walk_state, &(node));
+	if (walk_state->parse_flags & ACPI_PARSE_EXECUTE) {
+		flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE;
+	}
+	else {
+		flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND;
+	}
+
+	/*
+	 * Enter the name_string into the namespace
+	 */
+	status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string,
+			 ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1,
+			 flags, walk_state, &(node));
 	if (ACPI_FAILURE (status)) {
+		ACPI_REPORT_NSERROR (arg->common.value.string, status);
 		return_ACPI_STATUS (status);
 	}
 
@@ -100,14 +132,15 @@
 	 * for now, we will put it in the "op" object that the parser uses, so we
 	 * can get it again at the end of this scope
 	 */
-	op->node = node;
+	op->common.node = node;
 
 	/*
 	 * If there is no object attached to the node, this node was just created and
 	 * we need to create the field object.  Otherwise, this was a lookup of an
 	 * existing node and we don't want to create the field object again.
 	 */
-	if (node->object) {
+	obj_desc = acpi_ns_get_attached_object (node);
+	if (obj_desc) {
 		return_ACPI_STATUS (AE_OK);
 	}
 
@@ -125,27 +158,21 @@
 	}
 
 	/*
-	 * Allocate a method object for this field unit
-	 */
-	obj_desc->buffer_field.extra = acpi_ut_create_internal_object (
-			   INTERNAL_TYPE_EXTRA);
-	if (!obj_desc->buffer_field.extra) {
-		status = AE_NO_MEMORY;
-		goto cleanup;
-	}
-
-	/*
 	 * Remember location in AML stream of the field unit
 	 * opcode and operands -- since the buffer and index
 	 * operands must be evaluated.
 	 */
-	obj_desc->buffer_field.extra->extra.aml_start = ((acpi_parse2_object *) op)->data;
-	obj_desc->buffer_field.extra->extra.aml_length = ((acpi_parse2_object *) op)->length;
+	second_desc                 = obj_desc->common.next_object;
+	second_desc->extra.aml_start = op->named.data;
+	second_desc->extra.aml_length = op->named.length;
 	obj_desc->buffer_field.node = node;
 
-	/* Attach constructed field descriptor to parent node */
+	/* Attach constructed field descriptors to parent node */
 
 	status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_BUFFER_FIELD);
+	if (ACPI_FAILURE (status)) {
+		goto cleanup;
+	}
 
 
 cleanup:
@@ -159,10 +186,10 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_get_field_names
+ * FUNCTION:    acpi_ds_get_field_names
  *
- * PARAMETERS:  Info            - Create_field info structure
- *  `           Walk_state      - Current method state
+ * PARAMETERS:  Info            - create_field info structure
+ *  `           walk_state      - Current method state
  *              Arg             - First parser arg for the field name list
  *
  * RETURN:      Status
@@ -174,14 +201,15 @@
 
 acpi_status
 acpi_ds_get_field_names (
-	ACPI_CREATE_FIELD_INFO  *info,
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *arg)
+	struct acpi_create_field_info   *info,
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *arg)
 {
-	acpi_status             status;
+	acpi_status                     status;
+	acpi_integer                    position;
 
 
-	PROC_NAME("acpi_ds_get_field_names"); 
+	ACPI_FUNCTION_TRACE_PTR ("ds_get_field_names", info);
 
 
 	/* First field starts at bit zero */
@@ -194,51 +222,78 @@
 		/*
 		 * Three types of field elements are handled:
 		 * 1) Offset - specifies a bit offset
-		 * 2) Access_as - changes the access mode
+		 * 2) access_as - changes the access mode
 		 * 3) Name - Enters a new named field into the namespace
 		 */
-		switch (arg->opcode) {
+		switch (arg->common.aml_opcode) {
 		case AML_INT_RESERVEDFIELD_OP:
 
-			info->field_bit_position += arg->value.size;
+			position = (acpi_integer) info->field_bit_position
+					 + (acpi_integer) arg->common.value.size;
+
+			if (position > ACPI_UINT32_MAX) {
+				ACPI_REPORT_ERROR (("Bit offset within field too large (> 0xFFFFFFFF)\n"));
+				return_ACPI_STATUS (AE_SUPPORT);
+			}
+
+			info->field_bit_position = (u32) position;
 			break;
 
 
 		case AML_INT_ACCESSFIELD_OP:
 
 			/*
-			 * Get a new Access_type and Access_attribute for all
-			 * entries (until end or another Access_as keyword)
+			 * Get a new access_type and access_attribute -- to be used for all
+			 * field units that follow, until field end or another access_as keyword.
+			 *
+			 * In field_flags, preserve the flag bits other than the ACCESS_TYPE bits
 			 */
-			info->field_flags = (u8) ((info->field_flags & FIELD_ACCESS_TYPE_MASK) ||
-					  ((u8) (arg->value.integer >> 8)));
+			info->field_flags = (u8) ((info->field_flags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
+					  ((u8) ((u32) arg->common.value.integer >> 8)));
+
+			info->attribute = (u8) (arg->common.value.integer);
 			break;
 
 
 		case AML_INT_NAMEDFIELD_OP:
 
-			/* Enter a new field name into the namespace */
+			/* Lookup the name */
 
 			status = acpi_ns_lookup (walk_state->scope_info,
-					  (NATIVE_CHAR *) &((acpi_parse2_object *)arg)->name,
-					  info->field_type, IMODE_LOAD_PASS1,
-					  NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
-					  NULL, &info->field_node);
+					  (char *) &arg->named.name,
+					  info->field_type, ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE,
+					  walk_state, &info->field_node);
 			if (ACPI_FAILURE (status)) {
-				return_ACPI_STATUS (status);
+				ACPI_REPORT_NSERROR ((char *) &arg->named.name, status);
+				if (status != AE_ALREADY_EXISTS) {
+					return_ACPI_STATUS (status);
+				}
+
+				/* Already exists, ignore error */
+			}
+			else {
+				arg->common.node = info->field_node;
+				info->field_bit_length = arg->common.value.size;
+
+				/* Create and initialize an object for the new Field Node */
+
+				status = acpi_ex_prep_field_value (info);
+				if (ACPI_FAILURE (status)) {
+					return_ACPI_STATUS (status);
+				}
 			}
 
-			/* Create and initialize an object for the new Field Node */
+			/* Keep track of bit position for the next field */
 
-			info->field_bit_length = arg->value.size;
+			position = (acpi_integer) info->field_bit_position
+					 + (acpi_integer) arg->common.value.size;
 
-			status = acpi_ex_prep_field_value (info);
-			if (ACPI_FAILURE (status)) {
-				return_ACPI_STATUS (status);
+			if (position > ACPI_UINT32_MAX) {
+				ACPI_REPORT_ERROR (("Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n",
+						(char *) &info->field_node->name));
+				return_ACPI_STATUS (AE_SUPPORT);
 			}
 
-			/* Keep track of bit position for the next field */
-
 			info->field_bit_position += info->field_bit_length;
 			break;
 
@@ -246,12 +301,11 @@
 		default:
 
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid opcode in field list: %X\n",
-				arg->opcode));
-			return_ACPI_STATUS (AE_AML_ERROR);
-			break;
+				arg->common.aml_opcode));
+			return_ACPI_STATUS (AE_AML_BAD_OPCODE);
 		}
 
-		arg = arg->next;
+		arg = arg->common.next;
 	}
 
 	return_ACPI_STATUS (AE_OK);
@@ -260,11 +314,11 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_create_field
+ * FUNCTION:    acpi_ds_create_field
  *
  * PARAMETERS:  Op              - Op containing the Field definition and args
- *              Region_node     - Object for the containing Operation Region
- *  `           Walk_state      - Current method state
+ *              region_node     - Object for the containing Operation Region
+ *  `           walk_state      - Current method state
  *
  * RETURN:      Status
  *
@@ -274,41 +328,43 @@
 
 acpi_status
 acpi_ds_create_field (
-	acpi_parse_object       *op,
-	acpi_namespace_node     *region_node,
-	acpi_walk_state         *walk_state)
+	union acpi_parse_object         *op,
+	struct acpi_namespace_node      *region_node,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status = AE_AML_ERROR;
-	acpi_parse_object       *arg;
-	ACPI_CREATE_FIELD_INFO  info;
+	acpi_status                     status;
+	union acpi_parse_object         *arg;
+	struct acpi_create_field_info   info;
 
 
-	FUNCTION_TRACE_PTR ("Ds_create_field", op);
+	ACPI_FUNCTION_TRACE_PTR ("ds_create_field", op);
 
 
-	/* First arg is the name of the parent Op_region (must already exist) */
+	/* First arg is the name of the parent op_region (must already exist) */
 
-	arg = op->value.arg;
+	arg = op->common.value.arg;
 	if (!region_node) {
-		status = acpi_ns_lookup (walk_state->scope_info, arg->value.name,
-				  ACPI_TYPE_REGION, IMODE_EXECUTE,
-				  NS_SEARCH_PARENT, walk_state, &region_node);
+		status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.name,
+				  ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
+				  ACPI_NS_SEARCH_PARENT, walk_state, &region_node);
 		if (ACPI_FAILURE (status)) {
+			ACPI_REPORT_NSERROR (arg->common.value.name, status);
 			return_ACPI_STATUS (status);
 		}
 	}
 
 	/* Second arg is the field flags */
 
-	arg = arg->next;
-	info.field_flags = arg->value.integer8;
+	arg = arg->common.next;
+	info.field_flags = (u8) arg->common.value.integer;
+	info.attribute = 0;
 
 	/* Each remaining arg is a Named Field */
 
-	info.field_type = INTERNAL_TYPE_REGION_FIELD;
+	info.field_type = ACPI_TYPE_LOCAL_REGION_FIELD;
 	info.region_node = region_node;
 
-	status = acpi_ds_get_field_names (&info, walk_state, arg->next);
+	status = acpi_ds_get_field_names (&info, walk_state, arg->common.next);
 
 	return_ACPI_STATUS (status);
 }
@@ -316,11 +372,95 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_create_bank_field
+ * FUNCTION:    acpi_ds_init_field_objects
  *
  * PARAMETERS:  Op              - Op containing the Field definition and args
- *              Region_node     - Object for the containing Operation Region
- *  `           Walk_state      - Current method state
+ *  `           walk_state      - Current method state
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: For each "Field Unit" name in the argument list that is
+ *              part of the field declaration, enter the name into the
+ *              namespace.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ds_init_field_objects (
+	union acpi_parse_object         *op,
+	struct acpi_walk_state          *walk_state)
+{
+	acpi_status                     status;
+	union acpi_parse_object         *arg = NULL;
+	struct acpi_namespace_node      *node;
+	u8                              type = 0;
+
+
+	ACPI_FUNCTION_TRACE_PTR ("ds_init_field_objects", op);
+
+
+	switch (walk_state->opcode) {
+	case AML_FIELD_OP:
+		arg = acpi_ps_get_arg (op, 2);
+		type = ACPI_TYPE_LOCAL_REGION_FIELD;
+		break;
+
+	case AML_BANK_FIELD_OP:
+		arg = acpi_ps_get_arg (op, 4);
+		type = ACPI_TYPE_LOCAL_BANK_FIELD;
+		break;
+
+	case AML_INDEX_FIELD_OP:
+		arg = acpi_ps_get_arg (op, 3);
+		type = ACPI_TYPE_LOCAL_INDEX_FIELD;
+		break;
+
+	default:
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	}
+
+	/*
+	 * Walk the list of entries in the field_list
+	 */
+	while (arg) {
+		/* Ignore OFFSET and ACCESSAS terms here */
+
+		if (arg->common.aml_opcode == AML_INT_NAMEDFIELD_OP) {
+			status = acpi_ns_lookup (walk_state->scope_info,
+					  (char *) &arg->named.name,
+					  type, ACPI_IMODE_LOAD_PASS1,
+					  ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND,
+					  walk_state, &node);
+			if (ACPI_FAILURE (status)) {
+				ACPI_REPORT_NSERROR ((char *) &arg->named.name, status);
+				if (status != AE_ALREADY_EXISTS) {
+					return_ACPI_STATUS (status);
+				}
+
+				/* Name already exists, just ignore this error */
+
+				status = AE_OK;
+			}
+
+			arg->common.node = node;
+		}
+
+		/* Move to next field in the list */
+
+		arg = arg->common.next;
+	}
+
+	return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ds_create_bank_field
+ *
+ * PARAMETERS:  Op              - Op containing the Field definition and args
+ *              region_node     - Object for the containing Operation Region
+ *  `           walk_state      - Current method state
  *
  * RETURN:      Status
  *
@@ -330,56 +470,58 @@
 
 acpi_status
 acpi_ds_create_bank_field (
-	acpi_parse_object       *op,
-	acpi_namespace_node     *region_node,
-	acpi_walk_state         *walk_state)
+	union acpi_parse_object         *op,
+	struct acpi_namespace_node      *region_node,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status = AE_AML_ERROR;
-	acpi_parse_object       *arg;
-	ACPI_CREATE_FIELD_INFO  info;
+	acpi_status                     status;
+	union acpi_parse_object         *arg;
+	struct acpi_create_field_info   info;
 
 
-	FUNCTION_TRACE_PTR ("Ds_create_bank_field", op);
+	ACPI_FUNCTION_TRACE_PTR ("ds_create_bank_field", op);
 
 
-	/* First arg is the name of the parent Op_region (must already exist) */
+	/* First arg is the name of the parent op_region (must already exist) */
 
-	arg = op->value.arg;
+	arg = op->common.value.arg;
 	if (!region_node) {
-		status = acpi_ns_lookup (walk_state->scope_info, arg->value.name,
-				  ACPI_TYPE_REGION, IMODE_EXECUTE,
-				  NS_SEARCH_PARENT, walk_state, &region_node);
+		status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.name,
+				  ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
+				  ACPI_NS_SEARCH_PARENT, walk_state, &region_node);
 		if (ACPI_FAILURE (status)) {
+			ACPI_REPORT_NSERROR (arg->common.value.name, status);
 			return_ACPI_STATUS (status);
 		}
 	}
 
-	/* Second arg is the Bank Register (must already exist) */
+	/* Second arg is the Bank Register (Field) (must already exist) */
 
-	arg = arg->next;
-	status = acpi_ns_lookup (walk_state->scope_info, arg->value.string,
-			  INTERNAL_TYPE_BANK_FIELD_DEFN, IMODE_EXECUTE,
-			  NS_SEARCH_PARENT, walk_state, &info.register_node);
+	arg = arg->common.next;
+	status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string,
+			  ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+			  ACPI_NS_SEARCH_PARENT, walk_state, &info.register_node);
 	if (ACPI_FAILURE (status)) {
+		ACPI_REPORT_NSERROR (arg->common.value.string, status);
 		return_ACPI_STATUS (status);
 	}
 
-	/* Third arg is the Bank_value */
+	/* Third arg is the bank_value */
 
-	arg = arg->next;
-	info.bank_value = arg->value.integer32;
+	arg = arg->common.next;
+	info.bank_value = (u32) arg->common.value.integer;
 
 	/* Fourth arg is the field flags */
 
-	arg = arg->next;
-	info.field_flags = arg->value.integer8;
+	arg = arg->common.next;
+	info.field_flags = (u8) arg->common.value.integer;
 
 	/* Each remaining arg is a Named Field */
 
-	info.field_type = INTERNAL_TYPE_BANK_FIELD;
+	info.field_type = ACPI_TYPE_LOCAL_BANK_FIELD;
 	info.region_node = region_node;
 
-	status = acpi_ds_get_field_names (&info, walk_state, arg->next);
+	status = acpi_ds_get_field_names (&info, walk_state, arg->common.next);
 
 	return_ACPI_STATUS (status);
 }
@@ -387,11 +529,11 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_create_index_field
+ * FUNCTION:    acpi_ds_create_index_field
  *
  * PARAMETERS:  Op              - Op containing the Field definition and args
- *              Region_node     - Object for the containing Operation Region
- *  `           Walk_state      - Current method state
+ *              region_node     - Object for the containing Operation Region
+ *  `           walk_state      - Current method state
  *
  * RETURN:      Status
  *
@@ -401,50 +543,51 @@
 
 acpi_status
 acpi_ds_create_index_field (
-	acpi_parse_object       *op,
-	acpi_namespace_node     *region_node,
-	acpi_walk_state         *walk_state)
+	union acpi_parse_object         *op,
+	struct acpi_namespace_node      *region_node,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status;
-	acpi_parse_object       *arg;
-	ACPI_CREATE_FIELD_INFO  info;
+	acpi_status                     status;
+	union acpi_parse_object         *arg;
+	struct acpi_create_field_info   info;
 
 
-	FUNCTION_TRACE_PTR ("Ds_create_index_field", op);
+	ACPI_FUNCTION_TRACE_PTR ("ds_create_index_field", op);
 
 
 	/* First arg is the name of the Index register (must already exist) */
 
-	arg = op->value.arg;
-	status = acpi_ns_lookup (walk_state->scope_info, arg->value.string,
-			  ACPI_TYPE_ANY, IMODE_EXECUTE,
-			  NS_SEARCH_PARENT, walk_state, &info.register_node);
+	arg = op->common.value.arg;
+	status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string,
+			  ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+			  ACPI_NS_SEARCH_PARENT, walk_state, &info.register_node);
 	if (ACPI_FAILURE (status)) {
+		ACPI_REPORT_NSERROR (arg->common.value.string, status);
 		return_ACPI_STATUS (status);
 	}
 
 	/* Second arg is the data register (must already exist) */
 
-	arg = arg->next;
-	status = acpi_ns_lookup (walk_state->scope_info, arg->value.string,
-			  INTERNAL_TYPE_INDEX_FIELD_DEFN, IMODE_EXECUTE,
-			  NS_SEARCH_PARENT, walk_state, &info.data_register_node);
+	arg = arg->common.next;
+	status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string,
+			  ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+			  ACPI_NS_SEARCH_PARENT, walk_state, &info.data_register_node);
 	if (ACPI_FAILURE (status)) {
+		ACPI_REPORT_NSERROR (arg->common.value.string, status);
 		return_ACPI_STATUS (status);
 	}
 
 	/* Next arg is the field flags */
 
-	arg = arg->next;
-	info.field_flags = arg->value.integer8;
-
+	arg = arg->common.next;
+	info.field_flags = (u8) arg->common.value.integer;
 
 	/* Each remaining arg is a Named Field */
 
-	info.field_type = INTERNAL_TYPE_INDEX_FIELD;
+	info.field_type = ACPI_TYPE_LOCAL_INDEX_FIELD;
 	info.region_node = region_node;
 
-	status = acpi_ds_get_field_names (&info, walk_state, arg->next);
+	status = acpi_ds_get_field_names (&info, walk_state, arg->common.next);
 
 	return_ACPI_STATUS (status);
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/dispatcher/dsinit.c linux-2.4.22-pre2/drivers/acpi/dispatcher/dsinit.c
--- linux-2.4.21/drivers/acpi/dispatcher/dsinit.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/dispatcher/dsinit.c	2003-06-26 21:43:27.000000000 +0000
@@ -0,0 +1,235 @@
+/******************************************************************************
+ *
+ * Module Name: dsinit - Object initialization namespace walk
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+
+#include <acpi/acpi.h>
+#include <acpi/acdispat.h>
+#include <acpi/acnamesp.h>
+
+#define _COMPONENT          ACPI_DISPATCHER
+	 ACPI_MODULE_NAME    ("dsinit")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ds_init_one_object
+ *
+ * PARAMETERS:  obj_handle      - Node
+ *              Level           - Current nesting level
+ *              Context         - Points to a init info struct
+ *              return_value    - Not used
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Callback from acpi_walk_namespace. Invoked for every object
+ *              within the namespace.
+ *
+ *              Currently, the only objects that require initialization are:
+ *              1) Methods
+ *              2) Operation Regions
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ds_init_one_object (
+	acpi_handle                     obj_handle,
+	u32                             level,
+	void                            *context,
+	void                            **return_value)
+{
+	acpi_object_type                type;
+	acpi_status                     status;
+	struct acpi_init_walk_info      *info = (struct acpi_init_walk_info *) context;
+
+
+	ACPI_FUNCTION_NAME ("ds_init_one_object");
+
+
+	/*
+	 * We are only interested in objects owned by the table that
+	 * was just loaded
+	 */
+	if (((struct acpi_namespace_node *) obj_handle)->owner_id !=
+			info->table_desc->table_id) {
+		return (AE_OK);
+	}
+
+	info->object_count++;
+
+	/* And even then, we are only interested in a few object types */
+
+	type = acpi_ns_get_type (obj_handle);
+
+	switch (type) {
+	case ACPI_TYPE_REGION:
+
+		status = acpi_ds_initialize_region (obj_handle);
+		if (ACPI_FAILURE (status)) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region %p [%4.4s] - Init failure, %s\n",
+				obj_handle, ((struct acpi_namespace_node *) obj_handle)->name.ascii,
+				acpi_format_exception (status)));
+		}
+
+		info->op_region_count++;
+		break;
+
+
+	case ACPI_TYPE_METHOD:
+
+		info->method_count++;
+
+		/* Print a dot for each method unless we are going to print the entire pathname */
+
+		if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
+			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "."));
+		}
+
+		/*
+		 * Set the execution data width (32 or 64) based upon the
+		 * revision number of the parent ACPI table.
+		 * TBD: This is really for possible future support of integer width
+		 * on a per-table basis. Currently, we just use a global for the width.
+		 */
+		if (info->table_desc->pointer->revision == 1) {
+			((struct acpi_namespace_node *) obj_handle)->flags |= ANOBJ_DATA_WIDTH_32;
+		}
+
+		/*
+		 * Always parse methods to detect errors, we may delete
+		 * the parse tree below
+		 */
+		status = acpi_ds_parse_method (obj_handle);
+		if (ACPI_FAILURE (status)) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Method %p [%4.4s] - parse failure, %s\n",
+				obj_handle, ((struct acpi_namespace_node *) obj_handle)->name.ascii,
+				acpi_format_exception (status)));
+
+			/* This parse failed, but we will continue parsing more methods */
+
+			break;
+		}
+
+		/*
+		 * Delete the parse tree.  We simple re-parse the method
+		 * for every execution since there isn't much overhead
+		 */
+		acpi_ns_delete_namespace_subtree (obj_handle);
+		acpi_ns_delete_namespace_by_owner (((struct acpi_namespace_node *) obj_handle)->object->method.owning_id);
+		break;
+
+
+	case ACPI_TYPE_DEVICE:
+
+		info->device_count++;
+		break;
+
+
+	default:
+		break;
+	}
+
+	/*
+	 * We ignore errors from above, and always return OK, since
+	 * we don't want to abort the walk on a single error.
+	 */
+	return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ds_initialize_objects
+ *
+ * PARAMETERS:  table_desc      - Descriptor for parent ACPI table
+ *              start_node      - Root of subtree to be initialized.
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Walk the namespace starting at "start_node" and perform any
+ *              necessary initialization on the objects found therein
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ds_initialize_objects (
+	struct acpi_table_desc          *table_desc,
+	struct acpi_namespace_node      *start_node)
+{
+	acpi_status                     status;
+	struct acpi_init_walk_info      info;
+
+
+	ACPI_FUNCTION_TRACE ("ds_initialize_objects");
+
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+		"**** Starting initialization of namespace objects ****\n"));
+	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Parsing all Control Methods:"));
+
+	info.method_count   = 0;
+	info.op_region_count = 0;
+	info.object_count   = 0;
+	info.device_count   = 0;
+	info.table_desc     = table_desc;
+
+	/* Walk entire namespace from the supplied root */
+
+	status = acpi_walk_namespace (ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX,
+			  acpi_ds_init_one_object, &info, NULL);
+	if (ACPI_FAILURE (status)) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed, %s\n",
+			acpi_format_exception (status)));
+	}
+
+	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
+		"\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n",
+		table_desc->pointer->signature, table_desc->table_id, info.object_count,
+		info.device_count, info.method_count, info.op_region_count));
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+		"%hd Methods, %hd Regions\n", info.method_count, info.op_region_count));
+
+	return_ACPI_STATUS (AE_OK);
+}
+
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/dispatcher/dsmethod.c linux-2.4.22-pre2/drivers/acpi/dispatcher/dsmethod.c
--- linux-2.4.21/drivers/acpi/dispatcher/dsmethod.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/dispatcher/dsmethod.c	2003-06-26 21:43:21.000000000 +0000
@@ -1,51 +1,67 @@
 /******************************************************************************
  *
  * Module Name: dsmethod - Parser/Interpreter interface - control method parsing
- *              $Revision: 69 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "amlcode.h"
-#include "acdispat.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "actables.h"
-#include "acdebug.h"
+#include <acpi/acpi.h>
+#include <acpi/acparser.h>
+#include <acpi/amlcode.h>
+#include <acpi/acdispat.h>
+#include <acpi/acinterp.h>
+#include <acpi/acnamesp.h>
 
 
 #define _COMPONENT          ACPI_DISPATCHER
-	 MODULE_NAME         ("dsmethod")
+	 ACPI_MODULE_NAME    ("dsmethod")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_parse_method
+ * FUNCTION:    acpi_ds_parse_method
  *
- * PARAMETERS:  Obj_handle      - Node of the method
+ * PARAMETERS:  obj_handle      - Node of the method
  *              Level           - Current nesting level
  *              Context         - Points to a method counter
- *              Return_value    - Not used
+ *              return_value    - Not used
  *
  * RETURN:      Status
  *
@@ -58,17 +74,17 @@
 
 acpi_status
 acpi_ds_parse_method (
-	acpi_handle             obj_handle)
+	acpi_handle                     obj_handle)
 {
-	acpi_status             status;
-	acpi_operand_object     *obj_desc;
-	acpi_parse_object       *op;
-	acpi_namespace_node     *node;
-	acpi_owner_id           owner_id;
-	acpi_walk_state         *walk_state;
+	acpi_status                     status;
+	union acpi_operand_object       *obj_desc;
+	union acpi_parse_object         *op;
+	struct acpi_namespace_node      *node;
+	acpi_owner_id                   owner_id;
+	struct acpi_walk_state          *walk_state;
 
 
-	FUNCTION_TRACE_PTR ("Ds_parse_method", obj_handle);
+	ACPI_FUNCTION_TRACE_PTR ("ds_parse_method", obj_handle);
 
 
 	/* Parameter Validation */
@@ -77,14 +93,13 @@
 		return_ACPI_STATUS (AE_NULL_ENTRY);
 	}
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Parsing [%4.4s] **** Named_obj=%p\n",
-		(char*)&((acpi_namespace_node *)obj_handle)->name, obj_handle));
-
+	ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Parsing [%4.4s] **** named_obj=%p\n",
+		((struct acpi_namespace_node *) obj_handle)->name.ascii, obj_handle));
 
 	/* Extract the method object from the method Node */
 
-	node = (acpi_namespace_node *) obj_handle;
-	obj_desc = node->object;
+	node = (struct acpi_namespace_node *) obj_handle;
+	obj_desc = acpi_ns_get_attached_object (node);
 	if (!obj_desc) {
 		return_ACPI_STATUS (AE_NULL_OBJECT);
 	}
@@ -112,13 +127,20 @@
 
 	/* Init new op with the method name and pointer back to the Node */
 
-	acpi_ps_set_name (op, node->name);
-	op->node = node;
+	acpi_ps_set_name (op, node->name.integer);
+	op->common.node = node;
+
+	/*
+	 * Get a new owner_id for objects created by this method. Namespace
+	 * objects (such as Operation Regions) can be created during the
+	 * first pass parse.
+	 */
+	owner_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD);
+	obj_desc->method.owning_id = owner_id;
 
 	/* Create and initialize a new walk state */
 
-	walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
-			   NULL, NULL, NULL);
+	walk_state = acpi_ds_create_walk_state (owner_id, NULL, NULL, NULL);
 	if (!walk_state) {
 		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
@@ -126,7 +148,7 @@
 	status = acpi_ds_init_aml_walk (walk_state, op, node, obj_desc->method.aml_start,
 			  obj_desc->method.aml_length, NULL, NULL, 1);
 	if (ACPI_FAILURE (status)) {
-		/* TBD: delete walk state */
+		acpi_ds_delete_walk_state (walk_state);
 		return_ACPI_STATUS (status);
 	}
 
@@ -145,27 +167,22 @@
 		return_ACPI_STATUS (status);
 	}
 
-	/* Get a new Owner_id for objects created by this method */
-
-	owner_id = acpi_ut_allocate_owner_id (OWNER_TYPE_METHOD);
-	obj_desc->method.owning_id = owner_id;
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** [%4.4s] Parsed **** Named_obj=%p Op=%p\n",
-		(char*)&((acpi_namespace_node *)obj_handle)->name, obj_handle, op));
+	ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+		"**** [%4.4s] Parsed **** named_obj=%p Op=%p\n",
+		((struct acpi_namespace_node *) obj_handle)->name.ascii, obj_handle, op));
 
 	acpi_ps_delete_parse_tree (op);
-
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_begin_method_execution
+ * FUNCTION:    acpi_ds_begin_method_execution
  *
- * PARAMETERS:  Method_node         - Node of the method
- *              Obj_desc            - The method object
- *              Calling_method_node - Caller of this method (if non-null)
+ * PARAMETERS:  method_node         - Node of the method
+ *              obj_desc            - The method object
+ *              calling_method_node - Caller of this method (if non-null)
  *
  * RETURN:      Status
  *
@@ -179,21 +196,20 @@
 
 acpi_status
 acpi_ds_begin_method_execution (
-	acpi_namespace_node     *method_node,
-	acpi_operand_object     *obj_desc,
-	acpi_namespace_node     *calling_method_node)
+	struct acpi_namespace_node      *method_node,
+	union acpi_operand_object       *obj_desc,
+	struct acpi_namespace_node      *calling_method_node)
 {
-	acpi_status             status = AE_OK;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE_PTR ("Ds_begin_method_execution", method_node);
+	ACPI_FUNCTION_TRACE_PTR ("ds_begin_method_execution", method_node);
 
 
 	if (!method_node) {
 		return_ACPI_STATUS (AE_NULL_ENTRY);
 	}
 
-
 	/*
 	 * If there is a concurrency limit on this method, we need to
 	 * obtain a unit from the method semaphore.
@@ -201,7 +217,7 @@
 	if (obj_desc->method.semaphore) {
 		/*
 		 * Allow recursive method calls, up to the reentrancy/concurrency
-		 * limit imposed by the SERIALIZED rule and the Sync_level method
+		 * limit imposed by the SERIALIZED rule and the sync_level method
 		 * parameter.
 		 *
 		 * The point of this code is to avoid permanently blocking a
@@ -218,25 +234,23 @@
 		 * interpreter if we block
 		 */
 		status = acpi_ex_system_wait_semaphore (obj_desc->method.semaphore,
-				 WAIT_FOREVER);
+				 ACPI_WAIT_FOREVER);
 	}
 
-
 	/*
 	 * Increment the method parse tree thread count since it has been
 	 * reentered one more time (even if it is the same thread)
 	 */
 	obj_desc->method.thread_count++;
-
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_call_control_method
+ * FUNCTION:    acpi_ds_call_control_method
  *
- * PARAMETERS:  Walk_state          - Current state of the walk
+ * PARAMETERS:  walk_state          - Current state of the walk
  *              Op                  - Current Op to be walked
  *
  * RETURN:      Status
@@ -247,18 +261,18 @@
 
 acpi_status
 acpi_ds_call_control_method (
-	acpi_walk_list          *walk_list,
-	acpi_walk_state         *this_walk_state,
-	acpi_parse_object       *op)  /* TBD: This operand is obsolete */
+	struct acpi_thread_state        *thread,
+	struct acpi_walk_state          *this_walk_state,
+	union acpi_parse_object         *op)
 {
-	acpi_status             status;
-	acpi_namespace_node     *method_node;
-	acpi_operand_object     *obj_desc;
-	acpi_walk_state         *next_walk_state;
-	u32                     i;
+	acpi_status                     status;
+	struct acpi_namespace_node      *method_node;
+	union acpi_operand_object       *obj_desc;
+	struct acpi_walk_state          *next_walk_state;
+	u32                             i;
 
 
-	FUNCTION_TRACE_PTR ("Ds_call_control_method", this_walk_state);
+	ACPI_FUNCTION_TRACE_PTR ("ds_call_control_method", this_walk_state);
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Execute method %p, currentstate=%p\n",
 		this_walk_state->prev_op, this_walk_state));
@@ -276,6 +290,8 @@
 		return_ACPI_STATUS (AE_NULL_OBJECT);
 	}
 
+	obj_desc->method.owning_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD);
+
 	/* Init for new method, wait on concurrency semaphore */
 
 	status = acpi_ds_begin_method_execution (method_node, obj_desc,
@@ -284,19 +300,17 @@
 		return_ACPI_STATUS (status);
 	}
 
-
 	/* 1) Parse: Create a new walk state for the preempting walk */
 
 	next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id,
 			  op, obj_desc, NULL);
 	if (!next_walk_state) {
 		return_ACPI_STATUS (AE_NO_MEMORY);
-		goto cleanup;
 	}
 
 	/* Create and init a Root Node */
 
-	op = acpi_ps_alloc_op (AML_SCOPE_OP);
+	op = acpi_ps_create_scope_op ();
 	if (!op) {
 		status = AE_NO_MEMORY;
 		goto cleanup;
@@ -306,7 +320,7 @@
 			  obj_desc->method.aml_start, obj_desc->method.aml_length,
 			  NULL, NULL, 1);
 	if (ACPI_FAILURE (status)) {
-		/* TBD: delete walk state */
+		acpi_ds_delete_walk_state (next_walk_state);
 		goto cleanup;
 	}
 
@@ -315,11 +329,10 @@
 	status = acpi_ps_parse_aml (next_walk_state);
 	acpi_ps_delete_parse_tree (op);
 
-
 	/* 2) Execute: Create a new state for the preempting walk */
 
 	next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id,
-			  NULL, obj_desc, walk_list);
+			  NULL, obj_desc, thread);
 	if (!next_walk_state) {
 		status = AE_NO_MEMORY;
 		goto cleanup;
@@ -353,8 +366,8 @@
 
 	this_walk_state->num_operands = 0;
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Starting nested execution, newstate=%p\n",
-		next_walk_state));
+	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+		"Starting nested execution, newstate=%p\n", next_walk_state));
 
 	return_ACPI_STATUS (AE_OK);
 
@@ -362,7 +375,7 @@
 	/* On error, we must delete the new walk state */
 
 cleanup:
-	acpi_ds_terminate_control_method (next_walk_state);
+	(void) acpi_ds_terminate_control_method (next_walk_state);
 	acpi_ds_delete_walk_state (next_walk_state);
 	return_ACPI_STATUS (status);
 
@@ -371,9 +384,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_restart_control_method
+ * FUNCTION:    acpi_ds_restart_control_method
  *
- * PARAMETERS:  Walk_state          - State of the method when it was preempted
+ * PARAMETERS:  walk_state          - State of the method when it was preempted
  *              Op                  - Pointer to new current op
  *
  * RETURN:      Status
@@ -384,13 +397,13 @@
 
 acpi_status
 acpi_ds_restart_control_method (
-	acpi_walk_state         *walk_state,
-	acpi_operand_object     *return_desc)
+	struct acpi_walk_state          *walk_state,
+	union acpi_operand_object       *return_desc)
 {
-	acpi_status             status;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE_PTR ("Ds_restart_control_method", walk_state);
+	ACPI_FUNCTION_TRACE_PTR ("ds_restart_control_method", walk_state);
 
 
 	if (return_desc) {
@@ -405,7 +418,6 @@
 				return_ACPI_STATUS (status);
 			}
 		}
-
 		else {
 			/*
 			 * Delete the return value if it will not be used by the
@@ -413,24 +425,22 @@
 			 */
 			acpi_ut_remove_reference (return_desc);
 		}
-
 	}
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-		"Method=%p Return=%p Return_used?=%X Res_stack=%p State=%p\n",
+		"Method=%p Return=%p return_used?=%X res_stack=%p State=%p\n",
 		walk_state->method_call_op, return_desc, walk_state->return_used,
 		walk_state->results, walk_state));
 
-
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_terminate_control_method
+ * FUNCTION:    acpi_ds_terminate_control_method
  *
- * PARAMETERS:  Walk_state          - State of the method
+ * PARAMETERS:  walk_state          - State of the method
  *
  * RETURN:      Status
  *
@@ -442,16 +452,21 @@
 
 acpi_status
 acpi_ds_terminate_control_method (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_operand_object     *obj_desc;
-	acpi_namespace_node     *method_node;
+	union acpi_operand_object       *obj_desc;
+	struct acpi_namespace_node      *method_node;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE_PTR ("Ds_terminate_control_method", walk_state);
+	ACPI_FUNCTION_TRACE_PTR ("ds_terminate_control_method", walk_state);
 
 
-	/* The method object should be stored in the walk state */
+	if (!walk_state) {
+		return (AE_BAD_PARAMETER);
+	}
+
+	/* The current method object was saved in the walk state */
 
 	obj_desc = walk_state->method_desc;
 	if (!obj_desc) {
@@ -467,14 +482,22 @@
 	 * If this is the last thread executing the method,
 	 * we have additional cleanup to perform
 	 */
-	acpi_ut_acquire_mutex (ACPI_MTX_PARSER);
-
+	status = acpi_ut_acquire_mutex (ACPI_MTX_PARSER);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	/* Signal completion of the execution of this method if necessary */
 
 	if (walk_state->method_desc->method.semaphore) {
-		acpi_os_signal_semaphore (
-			walk_state->method_desc->method.semaphore, 1);
+		status = acpi_os_signal_semaphore (
+				  walk_state->method_desc->method.semaphore, 1);
+		if (ACPI_FAILURE (status)) {
+			ACPI_REPORT_ERROR (("Could not signal method semaphore\n"));
+			status = AE_OK;
+
+			/* Ignore error and continue cleanup */
+		}
 	}
 
 	/* Decrement the thread count on the method parse tree */
@@ -493,7 +516,11 @@
 		 * Delete any namespace entries created immediately underneath
 		 * the method
 		 */
-		acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+		status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
+		}
+
 		if (method_node->child) {
 			acpi_ns_delete_namespace_subtree (method_node);
 		}
@@ -503,11 +530,14 @@
 		 * the namespace
 		 */
 		acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owning_id);
-		acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+		status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
+		}
 	}
 
-	acpi_ut_release_mutex (ACPI_MTX_PARSER);
-	return_ACPI_STATUS (AE_OK);
+	status = acpi_ut_release_mutex (ACPI_MTX_PARSER);
+	return_ACPI_STATUS (status);
 }
 
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/dispatcher/dsmthdat.c linux-2.4.22-pre2/drivers/acpi/dispatcher/dsmthdat.c
--- linux-2.4.21/drivers/acpi/dispatcher/dsmthdat.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/dispatcher/dsmthdat.c	2003-06-26 21:43:17.000000000 +0000
@@ -1,193 +1,196 @@
 /*******************************************************************************
  *
  * Module Name: dsmthdat - control method arguments and local variables
- *              $Revision: 49 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "acdispat.h"
-#include "acinterp.h"
-#include "amlcode.h"
-#include "acnamesp.h"
+#include <acpi/acpi.h>
+#include <acpi/acdispat.h>
+#include <acpi/amlcode.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acinterp.h>
 
 
 #define _COMPONENT          ACPI_DISPATCHER
-	 MODULE_NAME         ("dsmthdat")
+	 ACPI_MODULE_NAME    ("dsmthdat")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_method_data_init
+ * FUNCTION:    acpi_ds_method_data_init
  *
- * PARAMETERS:  Walk_state          - Current walk state object
+ * PARAMETERS:  walk_state          - Current walk state object
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Initialize the data structures that hold the method's arguments
  *              and locals.  The data struct is an array of NTEs for each.
- *              This allows Ref_of and De_ref_of to work properly for these
+ *              This allows ref_of and de_ref_of to work properly for these
  *              special data types.
  *
+ * NOTES:       walk_state fields are initialized to zero by the
+ *              ACPI_MEM_CALLOCATE().
+ *
+ *              A pseudo-Namespace Node is assigned to each argument and local
+ *              so that ref_of() can return a pointer to the Node.
+ *
  ******************************************************************************/
 
-acpi_status
+void
 acpi_ds_method_data_init (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	u32                     i;
+	u32                             i;
 
 
-	FUNCTION_TRACE ("Ds_method_data_init");
+	ACPI_FUNCTION_TRACE ("ds_method_data_init");
 
-	/*
-	 * Walk_state fields are initialized to zero by the
-	 * ACPI_MEM_CALLOCATE().
-	 *
-	 * An Node is assigned to each argument and local so
-	 * that Ref_of() can return a pointer to the Node.
-	 */
 
 	/* Init the method arguments */
 
-	for (i = 0; i < MTH_NUM_ARGS; i++) {
-		MOVE_UNALIGNED32_TO_32 (&walk_state->arguments[i].name,
-				 NAMEOF_ARG_NTE);
-		walk_state->arguments[i].name      |= (i << 24);
-		walk_state->arguments[i].data_type  = ACPI_DESC_TYPE_NAMED;
-		walk_state->arguments[i].type       = ACPI_TYPE_ANY;
-		walk_state->arguments[i].flags      = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG;
+	for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) {
+		ACPI_MOVE_32_TO_32 (&walk_state->arguments[i].name,
+				   NAMEOF_ARG_NTE);
+		walk_state->arguments[i].name.integer |= (i << 24);
+		walk_state->arguments[i].descriptor   = ACPI_DESC_TYPE_NAMED;
+		walk_state->arguments[i].type         = ACPI_TYPE_ANY;
+		walk_state->arguments[i].flags        = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG;
 	}
 
 	/* Init the method locals */
 
-	for (i = 0; i < MTH_NUM_LOCALS; i++) {
-		MOVE_UNALIGNED32_TO_32 (&walk_state->local_variables[i].name,
-				 NAMEOF_LOCAL_NTE);
-
-		walk_state->local_variables[i].name  |= (i << 24);
-		walk_state->local_variables[i].data_type = ACPI_DESC_TYPE_NAMED;
-		walk_state->local_variables[i].type   = ACPI_TYPE_ANY;
-		walk_state->local_variables[i].flags  = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL;
+	for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) {
+		ACPI_MOVE_32_TO_32 (&walk_state->local_variables[i].name,
+				   NAMEOF_LOCAL_NTE);
+
+		walk_state->local_variables[i].name.integer |= (i << 24);
+		walk_state->local_variables[i].descriptor  = ACPI_DESC_TYPE_NAMED;
+		walk_state->local_variables[i].type        = ACPI_TYPE_ANY;
+		walk_state->local_variables[i].flags       = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL;
 	}
 
-	return_ACPI_STATUS (AE_OK);
+	return_VOID;
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_method_data_delete_all
+ * FUNCTION:    acpi_ds_method_data_delete_all
  *
- * PARAMETERS:  Walk_state          - Current walk state object
+ * PARAMETERS:  walk_state          - Current walk state object
  *
- * RETURN:      Status
+ * RETURN:      None
  *
  * DESCRIPTION: Delete method locals and arguments.  Arguments are only
  *              deleted if this method was called from another method.
  *
  ******************************************************************************/
 
-acpi_status
+void
 acpi_ds_method_data_delete_all (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	u32                     index;
-	acpi_operand_object     *object;
+	u32                             index;
 
 
-	FUNCTION_TRACE ("Ds_method_data_delete_all");
+	ACPI_FUNCTION_TRACE ("ds_method_data_delete_all");
 
 
-	/* Delete the locals */
+	/* Detach the locals */
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Deleting local variables in %p\n", walk_state));
+	for (index = 0; index < ACPI_METHOD_NUM_LOCALS; index++) {
+		if (walk_state->local_variables[index].object) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n",
+					index, walk_state->local_variables[index].object));
 
-	for (index = 0; index < MTH_NUM_LOCALS; index++) {
-		object = walk_state->local_variables[index].object;
-		if (object) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n", index, object));
+			/* Detach object (if present) and remove a reference */
 
-			/* Remove first */
-
-			walk_state->local_variables[index].object = NULL;
-
-			/* Was given a ref when stored */
-
-			acpi_ut_remove_reference (object);
-	   }
+			acpi_ns_detach_object (&walk_state->local_variables[index]);
+		}
 	}
 
+	/* Detach the arguments */
 
-	/* Delete the arguments */
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Deleting arguments in %p\n", walk_state));
-
-	for (index = 0; index < MTH_NUM_ARGS; index++) {
-		object = walk_state->arguments[index].object;
-		if (object) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", index, object));
-
-			/* Remove first */
-
-			walk_state->arguments[index].object = NULL;
+	for (index = 0; index < ACPI_METHOD_NUM_ARGS; index++) {
+		if (walk_state->arguments[index].object) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n",
+					index, walk_state->arguments[index].object));
 
-			 /* Was given a ref when stored */
+			/* Detach object (if present) and remove a reference */
 
-			acpi_ut_remove_reference (object);
+			acpi_ns_detach_object (&walk_state->arguments[index]);
 		}
 	}
 
-	return_ACPI_STATUS (AE_OK);
+	return_VOID;
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_method_data_init_args
+ * FUNCTION:    acpi_ds_method_data_init_args
  *
  * PARAMETERS:  *Params         - Pointer to a parameter list for the method
- *              Max_param_count - The arg count for this method
- *              Walk_state      - Current walk state object
+ *              max_param_count - The arg count for this method
+ *              walk_state      - Current walk state object
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Initialize arguments for a method
+ * DESCRIPTION: Initialize arguments for a method.  The parameter list is a list
+ *              of ACPI operand objects, either null terminated or whose length
+ *              is defined by max_param_count.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ds_method_data_init_args (
-	acpi_operand_object     **params,
-	u32                     max_param_count,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       **params,
+	u32                             max_param_count,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status;
-	u32                     mindex;
-	u32                     pindex;
+	acpi_status                     status;
+	u32                             index = 0;
 
 
-	FUNCTION_TRACE_PTR ("Ds_method_data_init_args", params);
+	ACPI_FUNCTION_TRACE_PTR ("ds_method_data_init_args", params);
 
 
 	if (!params) {
@@ -197,293 +200,224 @@
 
 	/* Copy passed parameters into the new method stack frame  */
 
-	for (pindex = mindex = 0;
-		(mindex < MTH_NUM_ARGS) && (pindex < max_param_count);
-		mindex++) {
-		if (params[pindex]) {
-			/*
-			 * A valid parameter.
-			 * Set the current method argument to the
-			 * Params[Pindex++] argument object descriptor
-			 */
-			status = acpi_ds_store_object_to_local (AML_ARG_OP, mindex,
-					  params[pindex], walk_state);
-			if (ACPI_FAILURE (status)) {
-				break;
-			}
-
-			pindex++;
+	while ((index < ACPI_METHOD_NUM_ARGS) && (index < max_param_count) && params[index]) {
+		/*
+		 * A valid parameter.
+		 * Store the argument in the method/walk descriptor
+		 */
+		status = acpi_ds_store_object_to_local (AML_ARG_OP, index, params[index],
+				 walk_state);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
 		}
 
-		else {
-			break;
-		}
+		index++;
 	}
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", pindex));
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", index));
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_method_data_get_entry
+ * FUNCTION:    acpi_ds_method_data_get_node
  *
  * PARAMETERS:  Opcode              - Either AML_LOCAL_OP or AML_ARG_OP
- *              Index               - Which local_var or argument to get
- *              Entry               - Pointer to where a pointer to the stack
- *                                    entry is returned.
- *              Walk_state          - Current walk state object
- *
- * RETURN:      Status
+ *              Index               - which local_var or argument whose type
+ *                                      to get
+ *              walk_state          - Current walk state object
  *
- * DESCRIPTION: Get the address of the object entry given by Opcode:Index
+ * RETURN:      Get the Node associated with a local or arg.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_ds_method_data_get_entry (
-	u16                     opcode,
-	u32                     index,
-	acpi_walk_state         *walk_state,
-	acpi_operand_object     ***entry)
+acpi_ds_method_data_get_node (
+	u16                             opcode,
+	u32                             index,
+	struct acpi_walk_state          *walk_state,
+	struct acpi_namespace_node      **node)
 {
-
-	FUNCTION_TRACE_U32 ("Ds_method_data_get_entry", index);
+	ACPI_FUNCTION_TRACE ("ds_method_data_get_node");
 
 
 	/*
-	 * Get the requested object.
-	 * The stack "Opcode" is either a Local_variable or an Argument
+	 * Method Locals and Arguments are supported
 	 */
 	switch (opcode) {
-
 	case AML_LOCAL_OP:
 
-		if (index > MTH_MAX_LOCAL) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local_var index %d is invalid (max %d)\n",
-				index, MTH_MAX_LOCAL));
-			return_ACPI_STATUS (AE_BAD_PARAMETER);
+		if (index > ACPI_METHOD_MAX_LOCAL) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n",
+				index, ACPI_METHOD_MAX_LOCAL));
+			return_ACPI_STATUS (AE_AML_INVALID_INDEX);
 		}
 
-		*entry = (acpi_operand_object  **)
-				 &walk_state->local_variables[index].object;
-		break;
+		/* Return a pointer to the pseudo-node */
 
+		*node = &walk_state->local_variables[index];
+		break;
 
 	case AML_ARG_OP:
 
-		if (index > MTH_MAX_ARG) {
+		if (index > ACPI_METHOD_MAX_ARG) {
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n",
-				index, MTH_MAX_ARG));
-			return_ACPI_STATUS (AE_BAD_PARAMETER);
+				index, ACPI_METHOD_MAX_ARG));
+			return_ACPI_STATUS (AE_AML_INVALID_INDEX);
 		}
 
-		*entry = (acpi_operand_object  **)
-				 &walk_state->arguments[index].object;
-		break;
+		/* Return a pointer to the pseudo-node */
 
+		*node = &walk_state->arguments[index];
+		break;
 
 	default:
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", opcode));
-		return_ACPI_STATUS (AE_BAD_PARAMETER);
+		return_ACPI_STATUS (AE_AML_BAD_OPCODE);
 	}
 
-
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_method_data_set_entry
+ * FUNCTION:    acpi_ds_method_data_set_value
  *
  * PARAMETERS:  Opcode              - Either AML_LOCAL_OP or AML_ARG_OP
- *              Index               - Which local_var or argument to get
+ *              Index               - which local_var or argument to get
  *              Object              - Object to be inserted into the stack entry
- *              Walk_state          - Current walk state object
+ *              walk_state          - Current walk state object
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index.
+ *              Note: There is no "implicit conversion" for locals.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_ds_method_data_set_entry (
-	u16                     opcode,
-	u32                     index,
-	acpi_operand_object     *object,
-	acpi_walk_state         *walk_state)
+acpi_ds_method_data_set_value (
+	u16                             opcode,
+	u32                             index,
+	union acpi_operand_object       *object,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status;
-	acpi_operand_object     **entry;
+	acpi_status                     status;
+	struct acpi_namespace_node      *node;
+
 
+	ACPI_FUNCTION_TRACE ("ds_method_data_set_value");
 
-	FUNCTION_TRACE ("Ds_method_data_set_entry");
 
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+		"obj %p op %X, ref count = %d [%s]\n", object,
+		opcode, object->common.reference_count,
+		acpi_ut_get_type_name (object->common.type)));
 
-	/* Get a pointer to the stack entry to set */
+	/* Get the namespace node for the arg/local */
 
-	status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry);
+	status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
 	if (ACPI_FAILURE (status)) {
 		return_ACPI_STATUS (status);
 	}
 
-	/* Increment ref count so object can't be deleted while installed */
-
+	/*
+	 * Increment ref count so object can't be deleted while installed.
+	 * NOTE: We do not copy the object in order to preserve the call by
+	 * reference semantics of ACPI Control Method invocation.
+	 * (See ACPI specification 2.0_c)
+	 */
 	acpi_ut_add_reference (object);
 
-	/* Install the object into the stack entry */
-
-	*entry = object;
+	/* Install the object */
 
-	return_ACPI_STATUS (AE_OK);
+	node->object = object;
+	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_method_data_get_type
+ * FUNCTION:    acpi_ds_method_data_get_type
  *
  * PARAMETERS:  Opcode              - Either AML_LOCAL_OP or AML_ARG_OP
- *              Index               - Which local_var or argument whose type
+ *              Index               - which local_var or argument whose type
  *                                      to get
- *              Walk_state          - Current walk state object
+ *              walk_state          - Current walk state object
  *
- * RETURN:      Data type of selected Arg or Local
- *              Used only in Exec_monadic2()/Type_op.
+ * RETURN:      Data type of current value of the selected Arg or Local
  *
  ******************************************************************************/
 
-acpi_object_type8
+acpi_object_type
 acpi_ds_method_data_get_type (
-	u16                     opcode,
-	u32                     index,
-	acpi_walk_state         *walk_state)
+	u16                             opcode,
+	u32                             index,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status;
-	acpi_operand_object     **entry;
-	acpi_operand_object     *object;
+	acpi_status                     status;
+	struct acpi_namespace_node      *node;
+	union acpi_operand_object       *object;
 
 
-	FUNCTION_TRACE ("Ds_method_data_get_type");
+	ACPI_FUNCTION_TRACE ("ds_method_data_get_type");
 
 
-	/* Get a pointer to the requested stack entry */
+	/* Get the namespace node for the arg/local */
 
-	status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry);
+	status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
 	if (ACPI_FAILURE (status)) {
 		return_VALUE ((ACPI_TYPE_NOT_FOUND));
 	}
 
-	/* Get the object from the method stack */
-
-	object = *entry;
-
-	/* Get the object type */
+	/* Get the object */
 
+	object = acpi_ns_get_attached_object (node);
 	if (!object) {
-		/* Any == 0 => "uninitialized" -- see spec 15.2.3.5.2.28 */
-		return_VALUE (ACPI_TYPE_ANY);
-	}
-
-	return_VALUE (object->common.type);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ds_method_data_get_node
- *
- * PARAMETERS:  Opcode              - Either AML_LOCAL_OP or AML_ARG_OP
- *              Index               - Which local_var or argument whose type
- *                                      to get
- *              Walk_state          - Current walk state object
- *
- * RETURN:      Get the Node associated with a local or arg.
- *
- ******************************************************************************/
+		/* Uninitialized local/arg, return TYPE_ANY */
 
-acpi_namespace_node *
-acpi_ds_method_data_get_node (
-	u16                     opcode,
-	u32                     index,
-	acpi_walk_state         *walk_state)
-{
-	acpi_namespace_node     *node = NULL;
-
-
-	FUNCTION_TRACE ("Ds_method_data_get_node");
-
-
-	switch (opcode) {
-
-	case AML_LOCAL_OP:
-
-		if (index > MTH_MAX_LOCAL) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n",
-				index, MTH_MAX_LOCAL));
-			return_PTR (node);
-		}
-
-		node =  &walk_state->local_variables[index];
-		break;
-
-
-	case AML_ARG_OP:
-
-		if (index > MTH_MAX_ARG) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n",
-				index, MTH_MAX_ARG));
-			return_PTR (node);
-		}
-
-		node = &walk_state->arguments[index];
-		break;
-
-
-	default:
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", opcode));
-		break;
+		return_VALUE (ACPI_TYPE_ANY);
 	}
 
+	/* Get the object type */
 
-	return_PTR (node);
+	return_VALUE (ACPI_GET_OBJECT_TYPE (object));
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_method_data_get_value
+ * FUNCTION:    acpi_ds_method_data_get_value
  *
  * PARAMETERS:  Opcode              - Either AML_LOCAL_OP or AML_ARG_OP
- *              Index               - Which local_var or argument to get
- *              Walk_state          - Current walk state object
- *              *Dest_desc          - Ptr to Descriptor into which selected Arg
+ *              Index               - which local_var or argument to get
+ *              walk_state          - Current walk state object
+ *              *dest_desc          - Ptr to Descriptor into which selected Arg
  *                                    or Local value should be copied
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Retrieve value of selected Arg or Local from the method frame
  *              at the current top of the method stack.
- *              Used only in Acpi_ex_resolve_to_value().
+ *              Used only in acpi_ex_resolve_to_value().
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ds_method_data_get_value (
-	u16                     opcode,
-	u32                     index,
-	acpi_walk_state         *walk_state,
-	acpi_operand_object     **dest_desc)
+	u16                             opcode,
+	u32                             index,
+	struct acpi_walk_state          *walk_state,
+	union acpi_operand_object       **dest_desc)
 {
-	acpi_status             status;
-	acpi_operand_object     **entry;
-	acpi_operand_object     *object;
+	acpi_status                     status;
+	struct acpi_namespace_node      *node;
+	union acpi_operand_object       *object;
 
 
-	FUNCTION_TRACE ("Ds_method_data_get_value");
+	ACPI_FUNCTION_TRACE ("ds_method_data_get_value");
 
 
 	/* Validate the object descriptor */
@@ -493,24 +427,22 @@
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
+	/* Get the namespace node for the arg/local */
 
-	/* Get a pointer to the requested method stack entry */
-
-	status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry);
+	status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
 	if (ACPI_FAILURE (status)) {
 		return_ACPI_STATUS (status);
 	}
 
-	/* Get the object from the method stack */
-
-	object = *entry;
+	/* Get the object from the node */
 
+	object = node->object;
 
 	/* Examine the returned object, it must be valid. */
 
 	if (!object) {
 		/*
-		 * Index points to uninitialized object stack value.
+		 * Index points to uninitialized object.
 		 * This means that either 1) The expected argument was
 		 * not passed to the method, or 2) A local variable
 		 * was referenced by the method (via the ASL)
@@ -519,25 +451,25 @@
 		switch (opcode) {
 		case AML_ARG_OP:
 
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at entry %p\n",
-				index, entry));
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at node %p\n",
+				index, node));
 
 			return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG);
-			break;
 
 		case AML_LOCAL_OP:
 
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Local[%d] at entry %p\n",
-				index, entry));
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Local[%d] at node %p\n",
+				index, node));
 
 			return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL);
-			break;
+
+		default:
+			return_ACPI_STATUS (AE_AML_INTERNAL);
 		}
 	}
 
-
 	/*
-	 * Index points to initialized and valid object stack value.
+	 * The Index points to an initialized and valid object.
 	 * Return an additional reference to the object
 	 */
 	*dest_desc = object;
@@ -549,125 +481,126 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_method_data_delete_value
+ * FUNCTION:    acpi_ds_method_data_delete_value
  *
  * PARAMETERS:  Opcode              - Either AML_LOCAL_OP or AML_ARG_OP
- *              Index               - Which local_var or argument to delete
- *              Walk_state          - Current walk state object
+ *              Index               - which local_var or argument to delete
+ *              walk_state          - Current walk state object
  *
- * RETURN:      Status
+ * RETURN:      None
  *
  * DESCRIPTION: Delete the entry at Opcode:Index on the method stack.  Inserts
  *              a null into the stack slot after the object is deleted.
  *
  ******************************************************************************/
 
-acpi_status
+void
 acpi_ds_method_data_delete_value (
-	u16                     opcode,
-	u32                     index,
-	acpi_walk_state         *walk_state)
+	u16                             opcode,
+	u32                             index,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status;
-	acpi_operand_object     **entry;
-	acpi_operand_object     *object;
+	acpi_status                     status;
+	struct acpi_namespace_node      *node;
+	union acpi_operand_object       *object;
 
 
-	FUNCTION_TRACE ("Ds_method_data_delete_value");
+	ACPI_FUNCTION_TRACE ("ds_method_data_delete_value");
 
 
-	/* Get a pointer to the requested entry */
+	/* Get the namespace node for the arg/local */
 
-	status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry);
+	status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
 	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
+		return_VOID;
 	}
 
-	/* Get the current entry in this slot k */
+	/* Get the associated object */
 
-	object = *entry;
+	object = acpi_ns_get_attached_object (node);
 
 	/*
 	 * Undefine the Arg or Local by setting its descriptor
 	 * pointer to NULL. Locals/Args can contain both
 	 * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs
 	 */
-	*entry = NULL;
+	node->object = NULL;
 
 	if ((object) &&
-		(VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_INTERNAL))) {
+		(ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_OPERAND)) {
 		/*
-		 * There is a valid object in this slot
+		 * There is a valid object.
 		 * Decrement the reference count by one to balance the
-		 * increment when the object was stored in the slot.
+		 * increment when the object was stored.
 		 */
 		acpi_ut_remove_reference (object);
 	}
 
-	return_ACPI_STATUS (AE_OK);
+	return_VOID;
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_store_object_to_local
+ * FUNCTION:    acpi_ds_store_object_to_local
  *
  * PARAMETERS:  Opcode              - Either AML_LOCAL_OP or AML_ARG_OP
- *              Index               - Which local_var or argument to set
- *              Src_desc            - Value to be stored
- *              Walk_state          - Current walk state
+ *              Index               - which local_var or argument to set
+ *              obj_desc            - Value to be stored
+ *              walk_state          - Current walk state
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Store a value in an Arg or Local.  The Src_desc is installed
+ * DESCRIPTION: Store a value in an Arg or Local.  The obj_desc is installed
  *              as the new value for the Arg or Local and the reference count
- *              for Src_desc is incremented.
+ *              for obj_desc is incremented.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ds_store_object_to_local (
-	u16                     opcode,
-	u32                     index,
-	acpi_operand_object     *src_desc,
-	acpi_walk_state         *walk_state)
+	u16                             opcode,
+	u32                             index,
+	union acpi_operand_object       *obj_desc,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status;
-	acpi_operand_object     **entry;
+	acpi_status                     status;
+	struct acpi_namespace_node      *node;
+	union acpi_operand_object       *current_obj_desc;
 
 
-	FUNCTION_TRACE ("Ds_method_data_set_value");
+	ACPI_FUNCTION_TRACE ("ds_store_object_to_local");
 	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%d Idx=%d Obj=%p\n",
-		opcode, index, src_desc));
+		opcode, index, obj_desc));
 
 
 	/* Parameter validation */
 
-	if (!src_desc) {
+	if (!obj_desc) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
+	/* Get the namespace node for the arg/local */
 
-	/* Get a pointer to the requested method stack entry */
-
-	status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry);
+	status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
 	if (ACPI_FAILURE (status)) {
-		goto cleanup;
+		return_ACPI_STATUS (status);
 	}
 
-	if (*entry == src_desc) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", src_desc));
-		goto cleanup;
+	current_obj_desc = acpi_ns_get_attached_object (node);
+	if (current_obj_desc == obj_desc) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n",
+			obj_desc));
+		return_ACPI_STATUS (status);
 	}
 
-
 	/*
 	 * If there is an object already in this slot, we either
 	 * have to delete it, or if this is an argument and there
 	 * is an object reference stored there, we have to do
 	 * an indirect store!
 	 */
-	if (*entry) {
+	if (current_obj_desc) {
 		/*
 		 * Check for an indirect store if an argument
 		 * contains an object reference (stored as an Node).
@@ -675,45 +608,46 @@
 		 * locals, since a store to a local should overwrite
 		 * anything there, including an object reference.
 		 *
-		 * If both Arg0 and Local0 contain Ref_of (Local4):
+		 * If both Arg0 and Local0 contain ref_of (Local4):
 		 *
 		 * Store (1, Arg0)             - Causes indirect store to local4
 		 * Store (1, Local0)           - Stores 1 in local0, overwriting
 		 *                                  the reference to local4
-		 * Store (1, De_refof (Local0)) - Causes indirect store to local4
+		 * Store (1, de_refof (Local0)) - Causes indirect store to local4
 		 *
 		 * Weird, but true.
 		 */
-		if ((opcode == AML_ARG_OP) &&
-			(VALID_DESCRIPTOR_TYPE (*entry, ACPI_DESC_TYPE_NAMED))) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
-				"Arg (%p) is an Obj_ref(Node), storing in %p\n",
-				src_desc, *entry));
-
-			/* Detach an existing object from the Node */
-
-			acpi_ns_detach_object ((acpi_namespace_node *) *entry);
-
+		if (opcode == AML_ARG_OP) {
 			/*
-			 * Store this object into the Node
-			 * (do the indirect store)
+			 * Make sure that the object is the correct type.  This may be overkill, but
+			 * it is here because references were NS nodes in the past.  Now they are
+			 * operand objects of type Reference.
 			 */
-			status = acpi_ns_attach_object ((acpi_namespace_node *) *entry, src_desc,
-					   src_desc->common.type);
-			return_ACPI_STATUS (status);
-		}
-
+			if (ACPI_GET_DESCRIPTOR_TYPE (current_obj_desc) != ACPI_DESC_TYPE_OPERAND) {
+				ACPI_REPORT_ERROR (("Invalid descriptor type while storing to method arg: %X\n",
+					current_obj_desc->common.type));
+				return_ACPI_STATUS (AE_AML_INTERNAL);
+			}
 
-#ifdef ACPI_ENABLE_IMPLICIT_CONVERSION
-		/*
-		 * Perform "Implicit conversion" of the new object to the type of the
-		 * existing object
-		 */
-		status = acpi_ex_convert_to_target_type ((*entry)->common.type, &src_desc, walk_state);
-		if (ACPI_FAILURE (status)) {
-			goto cleanup;
+			/*
+			 * If we have a valid reference object that came from ref_of(), do the
+			 * indirect store
+			 */
+			if ((current_obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) &&
+				(current_obj_desc->reference.opcode == AML_REF_OF_OP)) {
+				ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+					"Arg (%p) is an obj_ref(Node), storing in node %p\n",
+					obj_desc, current_obj_desc));
+
+				/*
+				 * Store this object to the Node
+				 * (perform the indirect store)
+				 */
+				status = acpi_ex_store_object_to_node (obj_desc,
+						 current_obj_desc->reference.object, walk_state);
+				return_ACPI_STATUS (status);
+			}
 		}
-#endif
 
 		/*
 		 * Delete the existing object
@@ -722,27 +656,14 @@
 		acpi_ds_method_data_delete_value (opcode, index, walk_state);
 	}
 
-
 	/*
-	 * Install the Obj_stack descriptor (*Src_desc) into
+	 * Install the obj_stack descriptor (*obj_desc) into
 	 * the descriptor for the Arg or Local.
 	 * Install the new object in the stack entry
 	 * (increments the object reference count by one)
 	 */
-	status = acpi_ds_method_data_set_entry (opcode, index, src_desc, walk_state);
-	if (ACPI_FAILURE (status)) {
-		goto cleanup;
-	}
-
-	/* Normal exit */
-
-	return_ACPI_STATUS (AE_OK);
-
-
-	/* Error exit */
-
-cleanup:
-
+	status = acpi_ds_method_data_set_value (opcode, index, obj_desc, walk_state);
 	return_ACPI_STATUS (status);
 }
 
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/dispatcher/dsobject.c linux-2.4.22-pre2/drivers/acpi/dispatcher/dsobject.c
--- linux-2.4.21/drivers/acpi/dispatcher/dsobject.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/dispatcher/dsobject.c	2003-06-26 21:43:10.000000000 +0000
@@ -1,692 +1,612 @@
 /******************************************************************************
  *
  * Module Name: dsobject - Dispatcher object management routines
- *              $Revision: 81 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "amlcode.h"
-#include "acdispat.h"
-#include "acinterp.h"
-#include "acnamesp.h"
+#include <acpi/acpi.h>
+#include <acpi/acparser.h>
+#include <acpi/amlcode.h>
+#include <acpi/acdispat.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acinterp.h>
 
 #define _COMPONENT          ACPI_DISPATCHER
-	 MODULE_NAME         ("dsobject")
+	 ACPI_MODULE_NAME    ("dsobject")
 
 
-/*******************************************************************************
+#ifndef ACPI_NO_METHOD_EXECUTION
+/*****************************************************************************
  *
- * FUNCTION:    Acpi_ds_init_one_object
+ * FUNCTION:    acpi_ds_build_internal_object
  *
- * PARAMETERS:  Obj_handle      - Node
- *              Level           - Current nesting level
- *              Context         - Points to a init info struct
- *              Return_value    - Not used
+ * PARAMETERS:  walk_state      - Current walk state
+ *              Op              - Parser object to be translated
+ *              obj_desc_ptr    - Where the ACPI internal object is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Callback from Acpi_walk_namespace. Invoked for every object
- *              within the  namespace.
- *
- *              Currently, the only objects that require initialization are:
- *              1) Methods
- *              2) Op Regions
+ * DESCRIPTION: Translate a parser Op object to the equivalent namespace object
+ *              Simple objects are any objects other than a package object!
  *
- ******************************************************************************/
+ ****************************************************************************/
 
 acpi_status
-acpi_ds_init_one_object (
-	acpi_handle             obj_handle,
-	u32                     level,
-	void                    *context,
-	void                    **return_value)
+acpi_ds_build_internal_object (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op,
+	union acpi_operand_object       **obj_desc_ptr)
 {
-	acpi_object_type8       type;
-	acpi_status             status;
-	acpi_init_walk_info     *info = (acpi_init_walk_info *) context;
-	u8                      table_revision;
-
-
-	PROC_NAME ("Ds_init_one_object");
-
-
-	info->object_count++;
-	table_revision = info->table_desc->pointer->revision;
-
-	/*
-	 * We are only interested in objects owned by the table that
-	 * was just loaded
-	 */
-	if (((acpi_namespace_node *) obj_handle)->owner_id !=
-			info->table_desc->table_id) {
-		return (AE_OK);
-	}
-
-
-	/* And even then, we are only interested in a few object types */
-
-	type = acpi_ns_get_type (obj_handle);
-
-	switch (type) {
+	union acpi_operand_object       *obj_desc;
+	acpi_status                     status;
 
-	case ACPI_TYPE_REGION:
 
-		acpi_ds_initialize_region (obj_handle);
+	ACPI_FUNCTION_TRACE ("ds_build_internal_object");
 
-		info->op_region_count++;
-		break;
-
-
-	case ACPI_TYPE_METHOD:
-
-		info->method_count++;
-
-		if (!(acpi_dbg_level & ACPI_LV_INIT)) {
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "."));
-		}
-
-		/*
-		 * Set the execution data width (32 or 64) based upon the
-		 * revision number of the parent ACPI table.
-		 */
-		if (table_revision == 1) {
-			((acpi_namespace_node *)obj_handle)->flags |= ANOBJ_DATA_WIDTH_32;
-		}
 
+	*obj_desc_ptr = NULL;
+	if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) {
 		/*
-		 * Always parse methods to detect errors, we may delete
-		 * the parse tree below
+		 * This is an named object reference.  If this name was
+		 * previously looked up in the namespace, it was stored in this op.
+		 * Otherwise, go ahead and look it up now
 		 */
-		status = acpi_ds_parse_method (obj_handle);
-		if (ACPI_FAILURE (status)) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Method %p [%4.4s] - parse failure, %s\n",
-				obj_handle, (char*)&((acpi_namespace_node *)obj_handle)->name,
-				acpi_format_exception (status)));
+		if (!op->common.node) {
+			status = acpi_ns_lookup (walk_state->scope_info, op->common.value.string,
+					  ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+					  ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL,
+					  (struct acpi_namespace_node **) &(op->common.node));
 
-			/* This parse failed, but we will continue parsing more methods */
-
-			break;
+			if (ACPI_FAILURE (status)) {
+				ACPI_REPORT_NSERROR (op->common.value.string, status);
+				return_ACPI_STATUS (status);
+			}
 		}
-
-		/*
-		 * Delete the parse tree.  We simple re-parse the method
-		 * for every execution since there isn't much overhead
-		 */
-		acpi_ns_delete_namespace_subtree (obj_handle);
-		break;
-
-	default:
-		break;
 	}
 
-	/*
-	 * We ignore errors from above, and always return OK, since
-	 * we don't want to abort the walk on a single error.
-	 */
-	return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ds_initialize_objects
- *
- * PARAMETERS:  None
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Walk the entire namespace and perform any necessary
- *              initialization on the objects found therein
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ds_initialize_objects (
-	acpi_table_desc         *table_desc,
-	acpi_namespace_node     *start_node)
-{
-	acpi_status             status;
-	acpi_init_walk_info     info;
-
-
-	FUNCTION_TRACE ("Ds_initialize_objects");
-
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-		"**** Starting initialization of namespace objects ****\n"));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "Parsing Methods:"));
-
-
-	info.method_count   = 0;
-	info.op_region_count = 0;
-	info.object_count   = 0;
-	info.table_desc     = table_desc;
-
+	/* Create and init the internal ACPI object */
 
-	/* Walk entire namespace from the supplied root */
+	obj_desc = acpi_ut_create_internal_object ((acpi_ps_get_opcode_info (op->common.aml_opcode))->object_type);
+	if (!obj_desc) {
+		return_ACPI_STATUS (AE_NO_MEMORY);
+	}
 
-	status = acpi_walk_namespace (ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX,
-			  acpi_ds_init_one_object, &info, NULL);
+	status = acpi_ds_init_object_from_op (walk_state, op, op->common.aml_opcode, &obj_desc);
 	if (ACPI_FAILURE (status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Walk_namespace failed! %x\n", status));
+		acpi_ut_remove_reference (obj_desc);
+		return_ACPI_STATUS (status);
 	}
 
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-		"\n%d Control Methods found and parsed (%d nodes total)\n",
-		info.method_count, info.object_count));
-	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-		"%d Control Methods found\n", info.method_count));
-	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-		"%d Op Regions found\n", info.op_region_count));
-
+	*obj_desc_ptr = obj_desc;
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ds_init_object_from_op
+ * FUNCTION:    acpi_ds_build_internal_buffer_obj
  *
- * PARAMETERS:  Op              - Parser op used to init the internal object
- *              Opcode          - AML opcode associated with the object
- *              Obj_desc        - Namespace object to be initialized
+ * PARAMETERS:  walk_state      - Current walk state
+ *              Op              - Parser object to be translated
+ *              buffer_length   - Length of the buffer
+ *              obj_desc_ptr    - Where the ACPI internal object is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Initialize a namespace object from a parser Op and its
- *              associated arguments.  The namespace object is a more compact
- *              representation of the Op and its arguments.
+ * DESCRIPTION: Translate a parser Op package object to the equivalent
+ *              namespace object
  *
  ****************************************************************************/
 
 acpi_status
-acpi_ds_init_object_from_op (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op,
-	u16                     opcode,
-	acpi_operand_object     **ret_obj_desc)
+acpi_ds_build_internal_buffer_obj (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op,
+	u32                             buffer_length,
+	union acpi_operand_object       **obj_desc_ptr)
 {
-	acpi_status             status;
-	acpi_parse_object       *arg;
-	acpi_parse2_object      *byte_list;
-	acpi_operand_object     *arg_desc;
-	const acpi_opcode_info  *op_info;
-	acpi_operand_object     *obj_desc;
-
+	union acpi_parse_object         *arg;
+	union acpi_operand_object       *obj_desc;
+	union acpi_parse_object         *byte_list;
+	u32                             byte_list_length = 0;
 
-	PROC_NAME ("Ds_init_object_from_op");
 
+	ACPI_FUNCTION_TRACE ("ds_build_internal_buffer_obj");
 
-	obj_desc = *ret_obj_desc;
-	op_info = acpi_ps_get_opcode_info (opcode);
-	if (op_info->class == AML_CLASS_UNKNOWN) {
-		/* Unknown opcode */
 
-		return (AE_TYPE);
+	obj_desc = *obj_desc_ptr;
+	if (obj_desc) {
+		/*
+		 * We are evaluating a Named buffer object "Name (xxxx, Buffer)".
+		 * The buffer object already exists (from the NS node)
+		 */
 	}
+	else {
+		/* Create a new buffer object */
 
-
-	/* Get and prepare the first argument */
-
-	switch (obj_desc->common.type) {
-	case ACPI_TYPE_BUFFER:
-
-		/* First arg is a number */
-
-		acpi_ds_create_operand (walk_state, op->value.arg, 0);
-		arg_desc = walk_state->operands [walk_state->num_operands - 1];
-		acpi_ds_obj_stack_pop (1, walk_state);
-
-		/* Resolve the object (could be an arg or local) */
-
-		status = acpi_ex_resolve_to_value (&arg_desc, walk_state);
-		if (ACPI_FAILURE (status)) {
-			acpi_ut_remove_reference (arg_desc);
-			return (status);
+		obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER);
+		*obj_desc_ptr = obj_desc;
+		if (!obj_desc) {
+			return_ACPI_STATUS (AE_NO_MEMORY);
 		}
+	}
 
-		/* We are expecting a number */
+	/*
+	 * Second arg is the buffer data (optional) byte_list can be either
+	 * individual bytes or a string initializer.  In either case, a
+	 * byte_list appears in the AML.
+	 */
+	arg = op->common.value.arg;         /* skip first arg */
 
-		if (arg_desc->common.type != ACPI_TYPE_INTEGER) {
+	byte_list = arg->named.next;
+	if (byte_list) {
+		if (byte_list->common.aml_opcode != AML_INT_BYTELIST_OP) {
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-				"Expecting number, got obj: %p type %X\n",
-				arg_desc, arg_desc->common.type));
-			acpi_ut_remove_reference (arg_desc);
+				"Expecting bytelist, got AML opcode %X in op %p\n",
+				byte_list->common.aml_opcode, byte_list));
+
+			acpi_ut_remove_reference (obj_desc);
 			return (AE_TYPE);
 		}
 
-		/* Get the value, delete the internal object */
+		byte_list_length = (u32) byte_list->common.value.integer;
+	}
 
-		obj_desc->buffer.length = (u32) arg_desc->integer.value;
-		acpi_ut_remove_reference (arg_desc);
+	/*
+	 * The buffer length (number of bytes) will be the larger of:
+	 * 1) The specified buffer length and
+	 * 2) The length of the initializer byte list
+	 */
+	obj_desc->buffer.length = buffer_length;
+	if (byte_list_length > buffer_length) {
+		obj_desc->buffer.length = byte_list_length;
+	}
 
-		/* Allocate the buffer */
+	/* Allocate the buffer */
 
-		if (obj_desc->buffer.length == 0) {
-			obj_desc->buffer.pointer = NULL;
-			REPORT_WARNING (("Buffer created with zero length in AML\n"));
-			break;
+	if (obj_desc->buffer.length == 0) {
+		obj_desc->buffer.pointer = NULL;
+		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+			"Buffer defined with zero length in AML, creating\n"));
+	}
+	else {
+		obj_desc->buffer.pointer = ACPI_MEM_CALLOCATE (
+				   obj_desc->buffer.length);
+		if (!obj_desc->buffer.pointer) {
+			acpi_ut_delete_object_desc (obj_desc);
+			return_ACPI_STATUS (AE_NO_MEMORY);
 		}
 
-		else {
-			obj_desc->buffer.pointer = ACPI_MEM_CALLOCATE (
-					   obj_desc->buffer.length);
+		/* Initialize buffer from the byte_list (if present) */
 
-			if (!obj_desc->buffer.pointer) {
-				return (AE_NO_MEMORY);
-			}
+		if (byte_list) {
+			ACPI_MEMCPY (obj_desc->buffer.pointer, byte_list->named.data,
+					  byte_list_length);
 		}
+	}
 
-		/*
-		 * Second arg is the buffer data (optional) Byte_list can be either
-		 * individual bytes or a string initializer.
-		 */
-		arg = op->value.arg;         /* skip first arg */
-
-		byte_list = (acpi_parse2_object *) arg->next;
-		if (byte_list) {
-			if (byte_list->opcode != AML_INT_BYTELIST_OP) {
-				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Expecting bytelist, got: %p\n",
-					byte_list));
-				return (AE_TYPE);
-			}
+	obj_desc->buffer.flags |= AOPOBJ_DATA_VALID;
+	op->common.node = (struct acpi_namespace_node *) obj_desc;
+	return_ACPI_STATUS (AE_OK);
+}
 
-			MEMCPY (obj_desc->buffer.pointer, byte_list->data,
-					obj_desc->buffer.length);
-		}
 
-		break;
+/*****************************************************************************
+ *
+ * FUNCTION:    acpi_ds_build_internal_package_obj
+ *
+ * PARAMETERS:  walk_state      - Current walk state
+ *              Op              - Parser object to be translated
+ *              package_length  - Number of elements in the package
+ *              obj_desc_ptr    - Where the ACPI internal object is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Translate a parser Op package object to the equivalent
+ *              namespace object
+ *
+ ****************************************************************************/
 
+acpi_status
+acpi_ds_build_internal_package_obj (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op,
+	u32                             package_length,
+	union acpi_operand_object       **obj_desc_ptr)
+{
+	union acpi_parse_object         *arg;
+	union acpi_parse_object         *parent;
+	union acpi_operand_object       *obj_desc = NULL;
+	u32                             package_list_length;
+	acpi_status                     status = AE_OK;
+	u32                             i;
 
-	case ACPI_TYPE_PACKAGE:
 
-		/*
-		 * When called, an internal package object has already been built and
-		 * is pointed to by Obj_desc. Acpi_ds_build_internal_object builds another
-		 * internal package object, so remove reference to the original so
-		 * that it is deleted.  Error checking is done within the remove
-		 * reference function.
-		 */
-		acpi_ut_remove_reference (obj_desc);
-		status = acpi_ds_build_internal_object (walk_state, op, ret_obj_desc);
-		break;
+	ACPI_FUNCTION_TRACE ("ds_build_internal_package_obj");
 
-	case ACPI_TYPE_INTEGER:
-		obj_desc->integer.value = op->value.integer;
-		break;
 
+	/* Find the parent of a possibly nested package */
 
-	case ACPI_TYPE_STRING:
-		obj_desc->string.pointer = op->value.string;
-		obj_desc->string.length = STRLEN (op->value.string);
+	parent = op->common.parent;
+	while ((parent->common.aml_opcode == AML_PACKAGE_OP)    ||
+		   (parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) {
+		parent = parent->common.parent;
+	}
 
+	obj_desc = *obj_desc_ptr;
+	if (obj_desc) {
 		/*
-		 * The string is contained in the ACPI table, don't ever try
-		 * to delete it
+		 * We are evaluating a Named package object "Name (xxxx, Package)".
+		 * Get the existing package object from the NS node
 		 */
-		obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
-		break;
-
-
-	case ACPI_TYPE_METHOD:
-		break;
-
-
-	case INTERNAL_TYPE_REFERENCE:
-
-		switch (op_info->type) {
-		case AML_TYPE_LOCAL_VARIABLE:
-
-			/* Split the opcode into a base opcode + offset */
-
-			obj_desc->reference.opcode = AML_LOCAL_OP;
-			obj_desc->reference.offset = opcode - AML_LOCAL_OP;
-			break;
+	}
+	else {
+		obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_PACKAGE);
+		*obj_desc_ptr = obj_desc;
+		if (!obj_desc) {
+			return_ACPI_STATUS (AE_NO_MEMORY);
+		}
 
+		obj_desc->package.node = parent->common.node;
+	}
 
-		case AML_TYPE_METHOD_ARGUMENT:
+	obj_desc->package.count = package_length;
 
-			/* Split the opcode into a base opcode + offset */
+	/* Count the number of items in the package list */
 
-			obj_desc->reference.opcode = AML_ARG_OP;
-			obj_desc->reference.offset = opcode - AML_ARG_OP;
-			break;
+	package_list_length = 0;
+	arg = op->common.value.arg;
+	arg = arg->common.next;
+	while (arg) {
+		package_list_length++;
+		arg = arg->common.next;
+	}
 
+	/*
+	 * The package length (number of elements) will be the greater
+	 * of the specified length and the length of the initializer list
+	 */
+	if (package_list_length > package_length) {
+		obj_desc->package.count = package_list_length;
+	}
 
-		default: /* Constants, Literals, etc.. */
+	/*
+	 * Allocate the pointer array (array of pointers to the
+	 * individual objects). Add an extra pointer slot so
+	 * that the list is always null terminated.
+	 */
+	obj_desc->package.elements = ACPI_MEM_CALLOCATE (
+			 ((acpi_size) obj_desc->package.count + 1) * sizeof (void *));
 
-			if (op->opcode == AML_INT_NAMEPATH_OP) {
-				/* Node was saved in Op */
+	if (!obj_desc->package.elements) {
+		acpi_ut_delete_object_desc (obj_desc);
+		return_ACPI_STATUS (AE_NO_MEMORY);
+	}
 
-				obj_desc->reference.node = op->node;
-			}
+	/*
+	 * Now init the elements of the package
+	 */
+	i = 0;
+	arg = op->common.value.arg;
+	arg = arg->common.next;
+	while (arg) {
+		if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) {
+			/* Object (package or buffer) is already built */
 
-			obj_desc->reference.opcode = opcode;
-			break;
+			obj_desc->package.elements[i] = ACPI_CAST_PTR (union acpi_operand_object, arg->common.node);
+		}
+		else {
+			status = acpi_ds_build_internal_object (walk_state, arg,
+					  &obj_desc->package.elements[i]);
 		}
 
-		break;
-
-
-	default:
-
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unimplemented data type: %x\n",
-			obj_desc->common.type));
-
-		break;
+		i++;
+		arg = arg->common.next;
 	}
 
-	return (AE_OK);
+	obj_desc->package.flags |= AOPOBJ_DATA_VALID;
+	op->common.node = (struct acpi_namespace_node *) obj_desc;
+	return_ACPI_STATUS (status);
 }
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ds_build_internal_simple_obj
+ * FUNCTION:    acpi_ds_create_node
  *
- * PARAMETERS:  Op              - Parser object to be translated
- *              Obj_desc_ptr    - Where the ACPI internal object is returned
+ * PARAMETERS:  walk_state      - Current walk state
+ *              Node            - NS Node to be initialized
+ *              Op              - Parser object to be translated
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Translate a parser Op object to the equivalent namespace object
- *              Simple objects are any objects other than a package object!
+ * DESCRIPTION: Create the object to be associated with a namespace node
  *
  ****************************************************************************/
 
-static acpi_status
-acpi_ds_build_internal_simple_obj (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op,
-	acpi_operand_object     **obj_desc_ptr)
+acpi_status
+acpi_ds_create_node (
+	struct acpi_walk_state          *walk_state,
+	struct acpi_namespace_node      *node,
+	union acpi_parse_object         *op)
 {
-	acpi_operand_object     *obj_desc;
-	acpi_object_type8       type;
-	acpi_status             status;
-	u32                     length;
-	char                    *name;
+	acpi_status                     status;
+	union acpi_operand_object       *obj_desc;
 
 
-	FUNCTION_TRACE ("Ds_build_internal_simple_obj");
-
-
-	if (op->opcode == AML_INT_NAMEPATH_OP) {
-		/*
-		 * This is an object reference.  If The name was
-		 * previously looked up in the NS, it is stored in this op.
-		 * Otherwise, go ahead and look it up now
-		 */
-		if (!op->node) {
-			status = acpi_ns_lookup (walk_state->scope_info,
-					  op->value.string, ACPI_TYPE_ANY,
-					  IMODE_EXECUTE,
-					  NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE,
-					  NULL,
-					  (acpi_namespace_node **)&(op->node));
+	ACPI_FUNCTION_TRACE_PTR ("ds_create_node", op);
 
-			if (ACPI_FAILURE (status)) {
-				if (status == AE_NOT_FOUND) {
-					name = NULL;
-					acpi_ns_externalize_name (ACPI_UINT32_MAX, op->value.string, &length, &name);
-
-					if (name) {
-						REPORT_WARNING (("Reference %s at AML %X not found\n",
-								 name, op->aml_offset));
-						ACPI_MEM_FREE (name);
-					}
-
-					else {
-						REPORT_WARNING (("Reference %s at AML %X not found\n",
-								   op->value.string, op->aml_offset));
-					}
-
-					*obj_desc_ptr = NULL;
-				}
-
-				else {
-					return_ACPI_STATUS (status);
-				}
-			}
-		}
 
-		/*
-		 * The reference will be a Reference
-		 * TBD: [Restructure] unless we really need a separate
-		 *  type of INTERNAL_TYPE_REFERENCE change
-		 *  Acpi_ds_map_opcode_to_data_type to handle this case
-		 */
-		type = INTERNAL_TYPE_REFERENCE;
-	}
-	else {
-		type = acpi_ds_map_opcode_to_data_type (op->opcode, NULL);
+	/*
+	 * Because of the execution pass through the non-control-method
+	 * parts of the table, we can arrive here twice.  Only init
+	 * the named object node the first time through
+	 */
+	if (acpi_ns_get_attached_object (node)) {
+		return_ACPI_STATUS (AE_OK);
 	}
 
+	if (!op->common.value.arg) {
+		/* No arguments, there is nothing to do */
 
-	/* Create and init the internal ACPI object */
-
-	obj_desc = acpi_ut_create_internal_object (type);
-	if (!obj_desc) {
-		return_ACPI_STATUS (AE_NO_MEMORY);
+		return_ACPI_STATUS (AE_OK);
 	}
 
-	status = acpi_ds_init_object_from_op (walk_state, op, op->opcode, &obj_desc);
+	/* Build an internal object for the argument(s) */
+
+	status = acpi_ds_build_internal_object (walk_state, op->common.value.arg, &obj_desc);
 	if (ACPI_FAILURE (status)) {
-		acpi_ut_remove_reference (obj_desc);
 		return_ACPI_STATUS (status);
 	}
 
-	*obj_desc_ptr = obj_desc;
+	/* Re-type the object according to its argument */
 
-	return_ACPI_STATUS (AE_OK);
+	node->type = ACPI_GET_OBJECT_TYPE (obj_desc);
+
+	/* Attach obj to node */
+
+	status = acpi_ns_attach_object (node, obj_desc, node->type);
+
+	/* Remove local reference to the object */
+
+	acpi_ut_remove_reference (obj_desc);
+	return_ACPI_STATUS (status);
 }
 
+#endif /* ACPI_NO_METHOD_EXECUTION */
+
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ds_build_internal_package_obj
+ * FUNCTION:    acpi_ds_init_object_from_op
  *
- * PARAMETERS:  Op              - Parser object to be translated
- *              Obj_desc_ptr    - Where the ACPI internal object is returned
+ * PARAMETERS:  walk_state      - Current walk state
+ *              Op              - Parser op used to init the internal object
+ *              Opcode          - AML opcode associated with the object
+ *              ret_obj_desc    - Namespace object to be initialized
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Translate a parser Op package object to the equivalent
- *              namespace object
+ * DESCRIPTION: Initialize a namespace object from a parser Op and its
+ *              associated arguments.  The namespace object is a more compact
+ *              representation of the Op and its arguments.
  *
  ****************************************************************************/
 
 acpi_status
-acpi_ds_build_internal_package_obj (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op,
-	acpi_operand_object     **obj_desc_ptr)
+acpi_ds_init_object_from_op (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op,
+	u16                             opcode,
+	union acpi_operand_object       **ret_obj_desc)
 {
-	acpi_parse_object       *arg;
-	acpi_operand_object     *obj_desc;
-	acpi_status             status = AE_OK;
+	const struct acpi_opcode_info   *op_info;
+	union acpi_operand_object       *obj_desc;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE ("Ds_build_internal_package_obj");
+	ACPI_FUNCTION_TRACE ("ds_init_object_from_op");
 
 
-	obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_PACKAGE);
-	*obj_desc_ptr = obj_desc;
-	if (!obj_desc) {
-		return_ACPI_STATUS (AE_NO_MEMORY);
+	obj_desc = *ret_obj_desc;
+	op_info = acpi_ps_get_opcode_info (opcode);
+	if (op_info->class == AML_CLASS_UNKNOWN) {
+		/* Unknown opcode */
+
+		return_ACPI_STATUS (AE_TYPE);
 	}
 
-	if (op->opcode == AML_VAR_PACKAGE_OP) {
+	/* Perform per-object initialization */
+
+	switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
+	case ACPI_TYPE_BUFFER:
+
 		/*
-		 * Variable length package parameters are evaluated JIT
+		 * Defer evaluation of Buffer term_arg operand
 		 */
-		return_ACPI_STATUS (AE_OK);
-	}
+		obj_desc->buffer.node     = (struct acpi_namespace_node *) walk_state->operands[0];
+		obj_desc->buffer.aml_start = op->named.data;
+		obj_desc->buffer.aml_length = op->named.length;
+		break;
 
-	/* The first argument must be the package length */
 
-	arg = op->value.arg;
-	obj_desc->package.count = arg->value.integer32;
+	case ACPI_TYPE_PACKAGE:
 
-	/*
-	 * Allocate the array of pointers (ptrs to the
-	 * individual objects) Add an extra pointer slot so
-	 * that the list is always null terminated.
-	 */
-	obj_desc->package.elements = ACPI_MEM_CALLOCATE (
-			 (obj_desc->package.count + 1) * sizeof (void *));
+		/*
+		 * Defer evaluation of Package term_arg operand
+		 */
+		obj_desc->package.node     = (struct acpi_namespace_node *) walk_state->operands[0];
+		obj_desc->package.aml_start = op->named.data;
+		obj_desc->package.aml_length = op->named.length;
+		break;
 
-	if (!obj_desc->package.elements) {
-		acpi_ut_delete_object_desc (obj_desc);
-		return_ACPI_STATUS (AE_NO_MEMORY);
-	}
 
-	obj_desc->package.next_element = obj_desc->package.elements;
+	case ACPI_TYPE_INTEGER:
 
-	/*
-	 * Now init the elements of the package
-	 */
-	arg = arg->next;
-	while (arg) {
-		if (arg->opcode == AML_PACKAGE_OP) {
-			status = acpi_ds_build_internal_package_obj (walk_state, arg,
-					  obj_desc->package.next_element);
-		}
+		switch (op_info->type) {
+		case AML_TYPE_CONSTANT:
+			/*
+			 * Resolve AML Constants here - AND ONLY HERE!
+			 * All constants are integers.
+			 * We mark the integer with a flag that indicates that it started life
+			 * as a constant -- so that stores to constants will perform as expected (noop).
+			 * (zero_op is used as a placeholder for optional target operands.)
+			 */
+			obj_desc->common.flags = AOPOBJ_AML_CONSTANT;
 
-		else {
-			status = acpi_ds_build_internal_simple_obj (walk_state, arg,
-					  obj_desc->package.next_element);
-		}
+			switch (opcode) {
+			case AML_ZERO_OP:
 
-		obj_desc->package.next_element++;
-		arg = arg->next;
-	}
+				obj_desc->integer.value = 0;
+				break;
 
-	obj_desc->package.flags |= AOPOBJ_DATA_VALID;
-	return_ACPI_STATUS (status);
-}
+			case AML_ONE_OP:
 
+				obj_desc->integer.value = 1;
+				break;
 
-/*****************************************************************************
- *
- * FUNCTION:    Acpi_ds_build_internal_object
- *
- * PARAMETERS:  Op              - Parser object to be translated
- *              Obj_desc_ptr    - Where the ACPI internal object is returned
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Translate a parser Op object to the equivalent namespace
- *              object
- *
- ****************************************************************************/
+			case AML_ONES_OP:
+
+				obj_desc->integer.value = ACPI_INTEGER_MAX;
+
+				/* Truncate value if we are executing from a 32-bit ACPI table */
+
+#ifndef ACPI_NO_METHOD_EXECUTION
+				acpi_ex_truncate_for32bit_table (obj_desc);
+#endif
+				break;
+
+			case AML_REVISION_OP:
+
+				obj_desc->integer.value = ACPI_CA_SUPPORT_LEVEL;
+				break;
+
+			default:
+
+				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown constant opcode %X\n", opcode));
+				status = AE_AML_OPERAND_TYPE;
+				break;
+			}
+			break;
 
-acpi_status
-acpi_ds_build_internal_object (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op,
-	acpi_operand_object     **obj_desc_ptr)
-{
-	acpi_status             status;
 
+		case AML_TYPE_LITERAL:
+
+			obj_desc->integer.value = op->common.value.integer;
+			break;
 
-	switch (op->opcode) {
-	case AML_PACKAGE_OP:
-	case AML_VAR_PACKAGE_OP:
 
-		status = acpi_ds_build_internal_package_obj (walk_state, op, obj_desc_ptr);
+		default:
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Integer type %X\n", op_info->type));
+			status = AE_AML_OPERAND_TYPE;
+			break;
+		}
 		break;
 
 
-	default:
+	case ACPI_TYPE_STRING:
 
-		status = acpi_ds_build_internal_simple_obj (walk_state, op, obj_desc_ptr);
+		obj_desc->string.pointer = op->common.value.string;
+		obj_desc->string.length = (u32) ACPI_STRLEN (op->common.value.string);
+
+		/*
+		 * The string is contained in the ACPI table, don't ever try
+		 * to delete it
+		 */
+		obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
 		break;
-	}
 
-	return (status);
-}
 
+	case ACPI_TYPE_METHOD:
+		break;
 
-/*****************************************************************************
- *
- * FUNCTION:    Acpi_ds_create_node
- *
- * PARAMETERS:  Op              - Parser object to be translated
- *              Obj_desc_ptr    - Where the ACPI internal object is returned
- *
- * RETURN:      Status
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
 
-acpi_status
-acpi_ds_create_node (
-	acpi_walk_state         *walk_state,
-	acpi_namespace_node     *node,
-	acpi_parse_object       *op)
-{
-	acpi_status             status;
-	acpi_operand_object     *obj_desc;
+	case ACPI_TYPE_LOCAL_REFERENCE:
 
+		switch (op_info->type) {
+		case AML_TYPE_LOCAL_VARIABLE:
 
-	FUNCTION_TRACE_PTR ("Ds_create_node", op);
+			/* Split the opcode into a base opcode + offset */
 
+			obj_desc->reference.opcode = AML_LOCAL_OP;
+			obj_desc->reference.offset = opcode - AML_LOCAL_OP;
 
-	/*
-	 * Because of the execution pass through the non-control-method
-	 * parts of the table, we can arrive here twice.  Only init
-	 * the named object node the first time through
-	 */
-	if (node->object) {
-		return_ACPI_STATUS (AE_OK);
-	}
+#ifndef ACPI_NO_METHOD_EXECUTION
+			status = acpi_ds_method_data_get_node (AML_LOCAL_OP, obj_desc->reference.offset,
+					 walk_state, (struct acpi_namespace_node **) &obj_desc->reference.object);
+#endif
+			break;
 
-	if (!op->value.arg) {
-		/* No arguments, there is nothing to do */
 
-		return_ACPI_STATUS (AE_OK);
-	}
+		case AML_TYPE_METHOD_ARGUMENT:
 
-	/* Build an internal object for the argument(s) */
+			/* Split the opcode into a base opcode + offset */
 
-	status = acpi_ds_build_internal_object (walk_state, op->value.arg, &obj_desc);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
+			obj_desc->reference.opcode = AML_ARG_OP;
+			obj_desc->reference.offset = opcode - AML_ARG_OP;
+			break;
 
-	/* Re-type the object according to it's argument */
+		default: /* Other literals, etc.. */
 
-	node->type = obj_desc->common.type;
+			if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) {
+				/* Node was saved in Op */
 
-	/* Init obj */
+				obj_desc->reference.node = op->common.node;
+			}
 
-	status = acpi_ns_attach_object (node, obj_desc, (u8) node->type);
+			obj_desc->reference.opcode = opcode;
+			break;
+		}
+		break;
 
-	/* Remove local reference to the object */
 
-	acpi_ut_remove_reference (obj_desc);
+	default:
+
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unimplemented data type: %X\n",
+			ACPI_GET_OBJECT_TYPE (obj_desc)));
+
+		status = AE_AML_OPERAND_TYPE;
+		break;
+	}
+
 	return_ACPI_STATUS (status);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/dispatcher/dsopcode.c linux-2.4.22-pre2/drivers/acpi/dispatcher/dsopcode.c
--- linux-2.4.21/drivers/acpi/dispatcher/dsopcode.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/dispatcher/dsopcode.c	2003-06-26 21:43:15.000000000 +0000
@@ -2,126 +2,118 @@
  *
  * Module Name: dsopcode - Dispatcher Op Region support and handling of
  *                         "control" opcodes
- *              $Revision: 56 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "amlcode.h"
-#include "acdispat.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "acevents.h"
-#include "actables.h"
+#include <acpi/acpi.h>
+#include <acpi/acparser.h>
+#include <acpi/amlcode.h>
+#include <acpi/acdispat.h>
+#include <acpi/acinterp.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acevents.h>
 
 #define _COMPONENT          ACPI_DISPATCHER
-	 MODULE_NAME         ("dsopcode")
+	 ACPI_MODULE_NAME    ("dsopcode")
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ds_get_buffer_field_arguments
+ * FUNCTION:    acpi_ds_execute_arguments
  *
- * PARAMETERS:  Obj_desc        - A valid Buffer_field object
+ * PARAMETERS:  Node                - Parent NS node
+ *              aml_length          - Length of executable AML
+ *              aml_start           - Pointer to the AML
  *
  * RETURN:      Status.
  *
- * DESCRIPTION: Get Buffer_field Buffer and Index. This implements the late
- *              evaluation of these field attributes.
+ * DESCRIPTION: Late execution of region or field arguments
  *
  ****************************************************************************/
 
 acpi_status
-acpi_ds_get_buffer_field_arguments (
-	acpi_operand_object     *obj_desc)
+acpi_ds_execute_arguments (
+	struct acpi_namespace_node      *node,
+	struct acpi_namespace_node      *scope_node,
+	u32                             aml_length,
+	u8                              *aml_start)
 {
-	acpi_operand_object     *extra_desc;
-	acpi_namespace_node     *node;
-	acpi_parse_object       *op;
-	acpi_parse_object       *field_op;
-	acpi_status             status;
-	acpi_table_desc         *table_desc;
-	acpi_walk_state         *walk_state;
-
+	acpi_status                     status;
+	union acpi_parse_object         *op;
+	struct acpi_walk_state          *walk_state;
+	union acpi_parse_object         *arg;
 
-	FUNCTION_TRACE_PTR ("Ds_get_buffer_field_arguments", obj_desc);
 
-
-	if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
-		return_ACPI_STATUS (AE_OK);
-	}
-
-
-	/* Get the AML pointer (method object) and Buffer_field node */
-
-	extra_desc = obj_desc->buffer_field.extra;
-	node = obj_desc->buffer_field.node;
-
-	DEBUG_EXEC(acpi_ut_display_init_pathname (node, " [Field]"));
-	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] Buffer_field JIT Init\n",
-		(char*)&node->name));
+	ACPI_FUNCTION_TRACE ("ds_execute_arguments");
 
 
 	/*
-	 * Allocate a new parser op to be the root of the parsed
-	 * Op_region tree
+	 * Allocate a new parser op to be the root of the parsed tree
 	 */
-	op = acpi_ps_alloc_op (AML_SCOPE_OP);
+	op = acpi_ps_alloc_op (AML_INT_EVAL_SUBTREE_OP);
 	if (!op) {
-		return (AE_NO_MEMORY);
+		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
 
-	/* Save the Node for use in Acpi_ps_parse_aml */
-
-	op->node = acpi_ns_get_parent_object (node);
+	/* Save the Node for use in acpi_ps_parse_aml */
 
-	/* Get a handle to the parent ACPI table */
-
-	status = acpi_tb_handle_to_object (node->owner_id, &table_desc);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
+	op->common.node = scope_node;
 
 	/* Create and initialize a new parser state */
 
-	walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
-			   NULL, NULL, NULL);
+	walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL);
 	if (!walk_state) {
 		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
 
-	status = acpi_ds_init_aml_walk (walk_state, op, NULL, extra_desc->extra.aml_start,
-			  extra_desc->extra.aml_length, NULL, NULL, 1);
+	status = acpi_ds_init_aml_walk (walk_state, op, NULL, aml_start,
+			  aml_length, NULL, NULL, 1);
 	if (ACPI_FAILURE (status)) {
-		/* TBD: delete walk state */
+		acpi_ds_delete_walk_state (walk_state);
 		return_ACPI_STATUS (status);
 	}
 
-	/* TBD: No Walk flags?? */
-
-	walk_state->parse_flags = 0;
+	walk_state->parse_flags = ACPI_PARSE_DEFERRED_OP;
 
-	/* Pass1: Parse the entire Buffer_field declaration */
+	/* Pass1: Parse the entire declaration */
 
 	status = acpi_ps_parse_aml (walk_state);
 	if (ACPI_FAILURE (status)) {
@@ -129,204 +121,250 @@
 		return_ACPI_STATUS (status);
 	}
 
-	/* Get and init the actual Field_unit Op created above */
-
-	field_op = op->value.arg;
-	op->node = node;
-
+	/* Get and init the Op created above */
 
-	field_op = op->value.arg;
-	field_op->node = node;
+	arg = op->common.value.arg;
+	op->common.node = node;
+	arg->common.node = node;
 	acpi_ps_delete_parse_tree (op);
 
-	/* Evaluate the address and length arguments for the Op_region */
+	/* Evaluate the address and length arguments for the Buffer Field */
 
-	op = acpi_ps_alloc_op (AML_SCOPE_OP);
+	op = acpi_ps_alloc_op (AML_INT_EVAL_SUBTREE_OP);
 	if (!op) {
-		return (AE_NO_MEMORY);
+		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
 
-	op->node = acpi_ns_get_parent_object (node);
+	op->common.node = scope_node;
 
 	/* Create and initialize a new parser state */
 
-	walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
-			   NULL, NULL, NULL);
+	walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL);
 	if (!walk_state) {
 		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
 
-	status = acpi_ds_init_aml_walk (walk_state, op, NULL, extra_desc->extra.aml_start,
-			  extra_desc->extra.aml_length, NULL, NULL, 3);
+	status = acpi_ds_init_aml_walk (walk_state, op, NULL, aml_start,
+			  aml_length, NULL, NULL, 3);
 	if (ACPI_FAILURE (status)) {
-		/* TBD: delete walk state */
+		acpi_ds_delete_walk_state (walk_state);
 		return_ACPI_STATUS (status);
 	}
 
 	status = acpi_ps_parse_aml (walk_state);
 	acpi_ps_delete_parse_tree (op);
-
-	/*
-	 * The pseudo-method object is no longer needed since the region is
-	 * now initialized
-	 */
-	acpi_ut_remove_reference (obj_desc->buffer_field.extra);
-	obj_desc->buffer_field.extra = NULL;
-
 	return_ACPI_STATUS (status);
 }
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ds_get_region_arguments
+ * FUNCTION:    acpi_ds_get_buffer_field_arguments
  *
- * PARAMETERS:  Obj_desc        - A valid region object
+ * PARAMETERS:  obj_desc        - A valid buffer_field object
  *
  * RETURN:      Status.
  *
- * DESCRIPTION: Get region address and length.  This implements the late
- *              evaluation of these region attributes.
+ * DESCRIPTION: Get buffer_field Buffer and Index. This implements the late
+ *              evaluation of these field attributes.
  *
  ****************************************************************************/
 
 acpi_status
-acpi_ds_get_region_arguments (
-	acpi_operand_object     *obj_desc)
+acpi_ds_get_buffer_field_arguments (
+	union acpi_operand_object       *obj_desc)
 {
-	acpi_operand_object     *extra_desc = NULL;
-	acpi_namespace_node     *node;
-	acpi_parse_object       *op;
-	acpi_parse_object       *region_op;
-	acpi_status             status;
-	acpi_table_desc         *table_desc;
-	acpi_walk_state         *walk_state;
+	union acpi_operand_object       *extra_desc;
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE_PTR ("Ds_get_region_arguments", obj_desc);
+	ACPI_FUNCTION_TRACE_PTR ("ds_get_buffer_field_arguments", obj_desc);
 
 
-	if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
+	if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
 		return_ACPI_STATUS (AE_OK);
 	}
 
+	/* Get the AML pointer (method object) and buffer_field node */
 
-	/* Get the AML pointer (method object) and region node */
+	extra_desc = acpi_ns_get_secondary_object (obj_desc);
+	node = obj_desc->buffer_field.node;
 
-	extra_desc = obj_desc->region.extra;
-	node = obj_desc->region.node;
+	ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname (ACPI_TYPE_BUFFER_FIELD, node, NULL));
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] buffer_field JIT Init\n",
+		node->name.ascii));
 
-	DEBUG_EXEC(acpi_ut_display_init_pathname (node, " [Operation Region]"));
+	/* Execute the AML code for the term_arg arguments */
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] Op_region Init at AML %p\n",
-		(char*)&node->name, extra_desc->extra.aml_start));
+	status = acpi_ds_execute_arguments (node, acpi_ns_get_parent_node (node),
+			 extra_desc->extra.aml_length, extra_desc->extra.aml_start);
+	return_ACPI_STATUS (status);
+}
 
-	/*
-	 * Allocate a new parser op to be the root of the parsed
-	 * Op_region tree
-	 */
-	op = acpi_ps_alloc_op (AML_SCOPE_OP);
-	if (!op) {
-		return (AE_NO_MEMORY);
-	}
 
-	/* Save the Node for use in Acpi_ps_parse_aml */
+/*****************************************************************************
+ *
+ * FUNCTION:    acpi_ds_get_buffer_arguments
+ *
+ * PARAMETERS:  obj_desc        - A valid Bufferobject
+ *
+ * RETURN:      Status.
+ *
+ * DESCRIPTION: Get Buffer length and initializer byte list.  This implements
+ *              the late evaluation of these attributes.
+ *
+ ****************************************************************************/
 
-	op->node = acpi_ns_get_parent_object (node);
+acpi_status
+acpi_ds_get_buffer_arguments (
+	union acpi_operand_object       *obj_desc)
+{
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
 
-	/* Get a handle to the parent ACPI table */
 
-	status = acpi_tb_handle_to_object (node->owner_id, &table_desc);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
+	ACPI_FUNCTION_TRACE_PTR ("ds_get_buffer_arguments", obj_desc);
 
-	/* Create and initialize a new parser state */
 
-	walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
-			   op, NULL, NULL);
-	if (!walk_state) {
-		return_ACPI_STATUS (AE_NO_MEMORY);
+	if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
+		return_ACPI_STATUS (AE_OK);
 	}
 
-	status = acpi_ds_init_aml_walk (walk_state, op, NULL, extra_desc->extra.aml_start,
-			  extra_desc->extra.aml_length, NULL, NULL, 1);
-	if (ACPI_FAILURE (status)) {
-		/* TBD: delete walk state */
-		return_ACPI_STATUS (status);
+	/* Get the Buffer node */
+
+	node = obj_desc->buffer.node;
+	if (!node) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"No pointer back to NS node in buffer %p\n", obj_desc));
+		return_ACPI_STATUS (AE_AML_INTERNAL);
 	}
 
-	/* TBD: No Walk flags?? */
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer JIT Init\n"));
 
-	walk_state->parse_flags = 0;
+	/* Execute the AML code for the term_arg arguments */
 
-	/* Parse the entire Op_region declaration, creating a parse tree */
+	status = acpi_ds_execute_arguments (node, node,
+			 obj_desc->buffer.aml_length, obj_desc->buffer.aml_start);
+	return_ACPI_STATUS (status);
+}
 
-	status = acpi_ps_parse_aml (walk_state);
-	if (ACPI_FAILURE (status)) {
-		acpi_ps_delete_parse_tree (op);
-		return_ACPI_STATUS (status);
-	}
 
-	/* Get and init the actual Region_op created above */
+/*****************************************************************************
+ *
+ * FUNCTION:    acpi_ds_get_package_arguments
+ *
+ * PARAMETERS:  obj_desc        - A valid Packageobject
+ *
+ * RETURN:      Status.
+ *
+ * DESCRIPTION: Get Package length and initializer byte list.  This implements
+ *              the late evaluation of these attributes.
+ *
+ ****************************************************************************/
 
-	region_op = op->value.arg;
-	op->node = node;
+acpi_status
+acpi_ds_get_package_arguments (
+	union acpi_operand_object       *obj_desc)
+{
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
 
 
-	region_op = op->value.arg;
-	region_op->node = node;
-	acpi_ps_delete_parse_tree (op);
+	ACPI_FUNCTION_TRACE_PTR ("ds_get_package_arguments", obj_desc);
 
-	/* Evaluate the address and length arguments for the Op_region */
 
-	op = acpi_ps_alloc_op (AML_SCOPE_OP);
-	if (!op) {
-		return (AE_NO_MEMORY);
+	if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
+		return_ACPI_STATUS (AE_OK);
 	}
 
-	op->node = acpi_ns_get_parent_object (node);
+	/* Get the Package node */
 
-	/* Create and initialize a new parser state */
+	node = obj_desc->package.node;
+	if (!node) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"No pointer back to NS node in package %p\n", obj_desc));
+		return_ACPI_STATUS (AE_AML_INTERNAL);
+	}
 
-	walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
-			   op, NULL, NULL);
-	if (!walk_state) {
-		return_ACPI_STATUS (AE_NO_MEMORY);
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package JIT Init\n"));
+
+	/* Execute the AML code for the term_arg arguments */
+
+	status = acpi_ds_execute_arguments (node, node,
+			 obj_desc->package.aml_length, obj_desc->package.aml_start);
+	return_ACPI_STATUS (status);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION:    acpi_ds_get_region_arguments
+ *
+ * PARAMETERS:  obj_desc        - A valid region object
+ *
+ * RETURN:      Status.
+ *
+ * DESCRIPTION: Get region address and length.  This implements the late
+ *              evaluation of these region attributes.
+ *
+ ****************************************************************************/
+
+acpi_status
+acpi_ds_get_region_arguments (
+	union acpi_operand_object       *obj_desc)
+{
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
+	union acpi_operand_object       *extra_desc;
+
+
+	ACPI_FUNCTION_TRACE_PTR ("ds_get_region_arguments", obj_desc);
+
+
+	if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
+		return_ACPI_STATUS (AE_OK);
 	}
 
-	status = acpi_ds_init_aml_walk (walk_state, op, NULL, extra_desc->extra.aml_start,
-			  extra_desc->extra.aml_length, NULL, NULL, 3);
-	if (ACPI_FAILURE (status)) {
-		/* TBD: delete walk state */
-		return_ACPI_STATUS (status);
+	extra_desc = acpi_ns_get_secondary_object (obj_desc);
+	if (!extra_desc) {
+		return_ACPI_STATUS (AE_NOT_EXIST);
 	}
 
-	status = acpi_ps_parse_aml (walk_state);
-	acpi_ps_delete_parse_tree (op);
+	/* Get the Region node */
+
+	node = obj_desc->region.node;
 
+	ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname (ACPI_TYPE_REGION, node, NULL));
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] op_region Init at AML %p\n",
+		node->name.ascii, extra_desc->extra.aml_start));
+
+
+	status = acpi_ds_execute_arguments (node, acpi_ns_get_parent_node (node),
+			 extra_desc->extra.aml_length, extra_desc->extra.aml_start);
 	return_ACPI_STATUS (status);
 }
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ds_initialize_region
+ * FUNCTION:    acpi_ds_initialize_region
  *
  * PARAMETERS:  Op              - A valid region Op object
  *
  * RETURN:      Status
  *
- * DESCRIPTION:
+ * DESCRIPTION: Front end to ev_initialize_region
  *
  ****************************************************************************/
 
 acpi_status
 acpi_ds_initialize_region (
-	acpi_handle             obj_handle)
+	acpi_handle                     obj_handle)
 {
-	acpi_operand_object     *obj_desc;
-	acpi_status             status;
+	union acpi_operand_object       *obj_desc;
+	acpi_status                     status;
 
 
 	obj_desc = acpi_ns_get_attached_object (obj_handle);
@@ -334,301 +372,276 @@
 	/* Namespace is NOT locked */
 
 	status = acpi_ev_initialize_region (obj_desc, FALSE);
-
 	return (status);
 }
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ds_eval_buffer_field_operands
+ * FUNCTION:    acpi_ds_init_buffer_field
  *
- * PARAMETERS:  Op              - A valid Buffer_field Op object
+ * PARAMETERS:  aml_opcode      - create_xxx_field
+ *              obj_desc        - buffer_field object
+ *              buffer_desc     - Host Buffer
+ *              offset_desc     - Offset into buffer
+ *              Length          - Length of field (CREATE_FIELD_OP only)
+ *              Result          - Where to store the result
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Get Buffer_field Buffer and Index
- *              Called from Acpi_ds_exec_end_op during Buffer_field parse tree walk
- *
- * ACPI SPECIFICATION REFERENCES:
- *  Each of the Buffer Field opcodes is defined as specified in in-line
- *  comments below. For each one, use the following definitions.
- *
- *  Def_bit_field   :=  Bit_field_op    Src_buf Bit_idx Destination
- *  Def_byte_field  :=  Byte_field_op   Src_buf Byte_idx Destination
- *  Def_create_field := Create_field_op Src_buf Bit_idx Num_bits Name_string
- *  Def_dWord_field :=  DWord_field_op  Src_buf Byte_idx Destination
- *  Def_word_field  :=  Word_field_op   Src_buf Byte_idx Destination
- *  Bit_index       :=  Term_arg=>Integer
- *  Byte_index      :=  Term_arg=>Integer
- *  Destination     :=  Name_string
- *  Num_bits        :=  Term_arg=>Integer
- *  Source_buf      :=  Term_arg=>Buffer
+ * DESCRIPTION: Perform actual initialization of a buffer field
  *
  ****************************************************************************/
 
 acpi_status
-acpi_ds_eval_buffer_field_operands (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op)
+acpi_ds_init_buffer_field (
+	u16                             aml_opcode,
+	union acpi_operand_object       *obj_desc,
+	union acpi_operand_object       *buffer_desc,
+	union acpi_operand_object       *offset_desc,
+	union acpi_operand_object       *length_desc,
+	union acpi_operand_object       *result_desc)
 {
-	acpi_status             status;
-	acpi_operand_object     *obj_desc;
-	acpi_namespace_node     *node;
-	acpi_parse_object       *next_op;
-	u32                     offset;
-	u32                     bit_offset;
-	u32                     bit_count;
-	u8                      field_flags;
-	acpi_operand_object     *res_desc = NULL;
-	acpi_operand_object     *cnt_desc = NULL;
-	acpi_operand_object     *off_desc = NULL;
-	acpi_operand_object     *src_desc = NULL;
-
-
-	FUNCTION_TRACE_PTR ("Ds_eval_buffer_field_operands", op);
-
-
-	/*
-	 * This is where we evaluate the address and length fields of the
-	 * Create_xxx_field declaration
-	 */
-	node =  op->node;
-
-	/* Next_op points to the op that holds the Buffer */
-
-	next_op = op->value.arg;
-
-	/* Acpi_evaluate/create the address and length operands */
-
-	status = acpi_ds_create_operands (walk_state, next_op);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
+	u32                             offset;
+	u32                             bit_offset;
+	u32                             bit_count;
+	u8                              field_flags;
+	acpi_status                     status;
 
-	obj_desc = acpi_ns_get_attached_object (node);
-	if (!obj_desc) {
-		return_ACPI_STATUS (AE_NOT_EXIST);
-	}
 
+	ACPI_FUNCTION_TRACE_PTR ("ds_init_buffer_field", obj_desc);
 
-	/* Resolve the operands */
 
-	status = acpi_ex_resolve_operands (op->opcode, WALK_OPERANDS, walk_state);
-	DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, acpi_ps_get_opcode_name (op->opcode),
-			  walk_state->num_operands, "after Acpi_ex_resolve_operands");
+	/* Host object must be a Buffer */
 
-	if (ACPI_FAILURE (status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n",
-			acpi_ps_get_opcode_name (op->opcode), status));
+	if (ACPI_GET_OBJECT_TYPE (buffer_desc) != ACPI_TYPE_BUFFER) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"Target of Create Field is not a Buffer object - %s\n",
+			acpi_ut_get_object_type_name (buffer_desc)));
 
+		status = AE_AML_OPERAND_TYPE;
 		goto cleanup;
 	}
 
-	/* Get the operands */
-
-	if (AML_CREATE_FIELD_OP == op->opcode) {
-		res_desc = walk_state->operands[3];
-		cnt_desc = walk_state->operands[2];
-	}
-	else {
-		res_desc = walk_state->operands[2];
-	}
-
-	off_desc = walk_state->operands[1];
-	src_desc = walk_state->operands[0];
-
-
-	offset = (u32) off_desc->integer.value;
-
 	/*
-	 * If Res_desc is a Name, it will be a direct name pointer after
-	 * Acpi_ex_resolve_operands()
+	 * The last parameter to all of these opcodes (result_desc) started
+	 * out as a name_string, and should therefore now be a NS node
+	 * after resolution in acpi_ex_resolve_operands().
 	 */
-	if (!VALID_DESCRIPTOR_TYPE (res_desc, ACPI_DESC_TYPE_NAMED)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination must be a Node\n",
-			acpi_ps_get_opcode_name (op->opcode)));
+	if (ACPI_GET_DESCRIPTOR_TYPE (result_desc) != ACPI_DESC_TYPE_NAMED) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination must be a NS Node\n",
+			acpi_ps_get_opcode_name (aml_opcode)));
 
 		status = AE_AML_OPERAND_TYPE;
 		goto cleanup;
 	}
 
+	offset = (u32) offset_desc->integer.value;
+
 	/*
 	 * Setup the Bit offsets and counts, according to the opcode
 	 */
-	switch (op->opcode) {
-
-	/* Def_create_field */
-
+	switch (aml_opcode) {
 	case AML_CREATE_FIELD_OP:
 
 		/* Offset is in bits, count is in bits */
 
-		bit_offset  = offset;
-		bit_count   = (u32) cnt_desc->integer.value;
-		field_flags = ACCESS_BYTE_ACC;
+		bit_offset = offset;
+		bit_count  = (u32) length_desc->integer.value;
+		field_flags = AML_FIELD_ACCESS_BYTE;
 		break;
 
-
-	/* Def_create_bit_field */
-
 	case AML_CREATE_BIT_FIELD_OP:
 
 		/* Offset is in bits, Field is one bit */
 
-		bit_offset  = offset;
-		bit_count   = 1;
-		field_flags = ACCESS_BYTE_ACC;
+		bit_offset = offset;
+		bit_count  = 1;
+		field_flags = AML_FIELD_ACCESS_BYTE;
 		break;
 
-
-	/* Def_create_byte_field */
-
 	case AML_CREATE_BYTE_FIELD_OP:
 
 		/* Offset is in bytes, field is one byte */
 
-		bit_offset  = 8 * offset;
-		bit_count   = 8;
-		field_flags = ACCESS_BYTE_ACC;
+		bit_offset = 8 * offset;
+		bit_count  = 8;
+		field_flags = AML_FIELD_ACCESS_BYTE;
 		break;
 
-
-	/* Def_create_word_field */
-
 	case AML_CREATE_WORD_FIELD_OP:
 
 		/* Offset is in bytes, field is one word */
 
-		bit_offset  = 8 * offset;
-		bit_count   = 16;
-		field_flags = ACCESS_WORD_ACC;
+		bit_offset = 8 * offset;
+		bit_count  = 16;
+		field_flags = AML_FIELD_ACCESS_WORD;
 		break;
 
-
-	/* Def_create_dWord_field */
-
 	case AML_CREATE_DWORD_FIELD_OP:
 
 		/* Offset is in bytes, field is one dword */
 
-		bit_offset  = 8 * offset;
-		bit_count   = 32;
-		field_flags = ACCESS_DWORD_ACC;
+		bit_offset = 8 * offset;
+		bit_count  = 32;
+		field_flags = AML_FIELD_ACCESS_DWORD;
 		break;
 
-
-	/* Def_create_qWord_field */
-
 	case AML_CREATE_QWORD_FIELD_OP:
 
 		/* Offset is in bytes, field is one qword */
 
-		bit_offset  = 8 * offset;
-		bit_count   = 64;
-		field_flags = ACCESS_QWORD_ACC;
+		bit_offset = 8 * offset;
+		bit_count  = 64;
+		field_flags = AML_FIELD_ACCESS_QWORD;
 		break;
 
-
 	default:
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-			"Internal error - unknown field creation opcode %02x\n",
-			op->opcode));
+			"Unknown field creation opcode %02x\n",
+			aml_opcode));
 		status = AE_AML_BAD_OPCODE;
 		goto cleanup;
 	}
 
 
+	/* Entire field must fit within the current length of the buffer */
+
+	if ((bit_offset + bit_count) >
+		(8 * (u32) buffer_desc->buffer.length)) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"Field size %d exceeds Buffer size %d (bits)\n",
+			 bit_offset + bit_count, 8 * (u32) buffer_desc->buffer.length));
+		status = AE_AML_BUFFER_LIMIT;
+		goto cleanup;
+	}
+
 	/*
-	 * Setup field according to the object type
+	 * Initialize areas of the field object that are common to all fields
+	 * For field_flags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE)
 	 */
-	switch (src_desc->common.type) {
+	status = acpi_ex_prep_common_field_object (obj_desc, field_flags, 0,
+			  bit_offset, bit_count);
+	if (ACPI_FAILURE (status)) {
+		goto cleanup;
+	}
 
-	/* Source_buff :=  Term_arg=>Buffer */
+	obj_desc->buffer_field.buffer_obj = buffer_desc;
 
-	case ACPI_TYPE_BUFFER:
+	/* Reference count for buffer_desc inherits obj_desc count */
 
-		if ((bit_offset + bit_count) >
-			(8 * (u32) src_desc->buffer.length)) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-				"Field size %d exceeds Buffer size %d (bits)\n",
-				 bit_offset + bit_count, 8 * (u32) src_desc->buffer.length));
-			status = AE_AML_BUFFER_LIMIT;
-			goto cleanup;
-		}
+	buffer_desc->common.reference_count = (u16) (buffer_desc->common.reference_count +
+			  obj_desc->common.reference_count);
 
 
-		/*
-		 * Initialize areas of the field object that are common to all fields
-		 * For Field_flags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE)
-		 */
-		status = acpi_ex_prep_common_field_object (obj_desc, field_flags,
-				  bit_offset, bit_count);
-		if (ACPI_FAILURE (status)) {
-			return_ACPI_STATUS (status);
-		}
+cleanup:
 
-		obj_desc->buffer_field.buffer_obj = src_desc;
+	/* Always delete the operands */
 
-		/* Reference count for Src_desc inherits Obj_desc count */
+	acpi_ut_remove_reference (offset_desc);
+	acpi_ut_remove_reference (buffer_desc);
 
-		src_desc->common.reference_count = (u16) (src_desc->common.reference_count +
-				  obj_desc->common.reference_count);
+	if (aml_opcode == AML_CREATE_FIELD_OP) {
+		acpi_ut_remove_reference (length_desc);
+	}
 
-		break;
+	/* On failure, delete the result descriptor */
 
+	if (ACPI_FAILURE (status)) {
+		acpi_ut_remove_reference (result_desc); /* Result descriptor */
+	}
+	else {
+		/* Now the address and length are valid for this buffer_field */
 
-	/* Improper object type */
+		obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID;
+	}
 
-	default:
+	return_ACPI_STATUS (status);
+}
 
-		if ((src_desc->common.type > (u8) INTERNAL_TYPE_REFERENCE) || !acpi_ut_valid_object_type (src_desc->common.type)) /* TBD: This line MUST be a single line until Acpi_src can handle it (block deletion) */ {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-				"Tried to create field in invalid object type %X\n",
-				src_desc->common.type));
-		}
 
-		else {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-				"Tried to create field in improper object type - %s\n",
-				acpi_ut_get_type_name (src_desc->common.type)));
-		}
+/*****************************************************************************
+ *
+ * FUNCTION:    acpi_ds_eval_buffer_field_operands
+ *
+ * PARAMETERS:  walk_state      - Current walk
+ *              Op              - A valid buffer_field Op object
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Get buffer_field Buffer and Index
+ *              Called from acpi_ds_exec_end_op during buffer_field parse tree walk
+ *
+ ****************************************************************************/
 
-		status = AE_AML_OPERAND_TYPE;
-		goto cleanup;
-	}
+acpi_status
+acpi_ds_eval_buffer_field_operands (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op)
+{
+	acpi_status                     status;
+	union acpi_operand_object       *obj_desc;
+	struct acpi_namespace_node      *node;
+	union acpi_parse_object         *next_op;
 
 
-	if (AML_CREATE_FIELD_OP == op->opcode) {
-		/* Delete object descriptor unique to Create_field */
+	ACPI_FUNCTION_TRACE_PTR ("ds_eval_buffer_field_operands", op);
 
-		acpi_ut_remove_reference (cnt_desc);
-		cnt_desc = NULL;
-	}
 
+	/*
+	 * This is where we evaluate the address and length fields of the
+	 * create_xxx_field declaration
+	 */
+	node =  op->common.node;
+
+	/* next_op points to the op that holds the Buffer */
 
-cleanup:
+	next_op = op->common.value.arg;
 
-	/* Always delete the operands */
+	/* Evaluate/create the address and length operands */
 
-	acpi_ut_remove_reference (off_desc);
-	acpi_ut_remove_reference (src_desc);
+	status = acpi_ds_create_operands (walk_state, next_op);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
-	if (AML_CREATE_FIELD_OP == op->opcode) {
-		acpi_ut_remove_reference (cnt_desc);
+	obj_desc = acpi_ns_get_attached_object (node);
+	if (!obj_desc) {
+		return_ACPI_STATUS (AE_NOT_EXIST);
 	}
 
-	/* On failure, delete the result descriptor */
+	/* Resolve the operands */
+
+	status = acpi_ex_resolve_operands (op->common.aml_opcode,
+			  ACPI_WALK_OPERANDS, walk_state);
+
+	ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
+			  acpi_ps_get_opcode_name (op->common.aml_opcode),
+			  walk_state->num_operands, "after acpi_ex_resolve_operands");
 
 	if (ACPI_FAILURE (status)) {
-		acpi_ut_remove_reference (res_desc); /* Result descriptor */
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n",
+			acpi_ps_get_opcode_name (op->common.aml_opcode), status));
+
+		return_ACPI_STATUS (status);
 	}
 
+	/* Initialize the Buffer Field */
+
+	if (op->common.aml_opcode == AML_CREATE_FIELD_OP) {
+		/* NOTE: Slightly different operands for this opcode */
+
+		status = acpi_ds_init_buffer_field (op->common.aml_opcode, obj_desc,
+				 walk_state->operands[0], walk_state->operands[1],
+				 walk_state->operands[2], walk_state->operands[3]);
+	}
 	else {
-		/* Now the address and length are valid for this Buffer_field */
+		/* All other, create_xxx_field opcodes */
 
-		obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID;
+		status = acpi_ds_init_buffer_field (op->common.aml_opcode, obj_desc,
+				 walk_state->operands[0], walk_state->operands[1],
+						  NULL, walk_state->operands[2]);
 	}
 
 	return_ACPI_STATUS (status);
@@ -637,46 +650,47 @@
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ds_eval_region_operands
+ * FUNCTION:    acpi_ds_eval_region_operands
  *
- * PARAMETERS:  Op              - A valid region Op object
+ * PARAMETERS:  walk_state      - Current walk
+ *              Op              - A valid region Op object
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Get region address and length
- *              Called from Acpi_ds_exec_end_op during Op_region parse tree walk
+ *              Called from acpi_ds_exec_end_op during op_region parse tree walk
  *
  ****************************************************************************/
 
 acpi_status
 acpi_ds_eval_region_operands (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op)
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op)
 {
-	acpi_status             status;
-	acpi_operand_object     *obj_desc;
-	acpi_operand_object     *operand_desc;
-	acpi_namespace_node     *node;
-	acpi_parse_object       *next_op;
+	acpi_status                     status;
+	union acpi_operand_object       *obj_desc;
+	union acpi_operand_object       *operand_desc;
+	struct acpi_namespace_node      *node;
+	union acpi_parse_object         *next_op;
 
 
-	FUNCTION_TRACE_PTR ("Ds_eval_region_operands", op);
+	ACPI_FUNCTION_TRACE_PTR ("ds_eval_region_operands", op);
 
 
 	/*
-	 * This is where we evaluate the address and length fields of the Op_region declaration
+	 * This is where we evaluate the address and length fields of the op_region declaration
 	 */
-	node =  op->node;
+	node =  op->common.node;
 
-	/* Next_op points to the op that holds the Space_iD */
+	/* next_op points to the op that holds the space_iD */
 
-	next_op = op->value.arg;
+	next_op = op->common.value.arg;
 
-	/* Next_op points to address op */
+	/* next_op points to address op */
 
-	next_op = next_op->next;
+	next_op = next_op->common.next;
 
-	/* Acpi_evaluate/create the address and length operands */
+	/* Evaluate/create the address and length operands */
 
 	status = acpi_ds_create_operands (walk_state, next_op);
 	if (ACPI_FAILURE (status)) {
@@ -685,15 +699,14 @@
 
 	/* Resolve the length and address operands to numbers */
 
-	status = acpi_ex_resolve_operands (op->opcode, WALK_OPERANDS, walk_state);
+	status = acpi_ex_resolve_operands (op->common.aml_opcode, ACPI_WALK_OPERANDS, walk_state);
 	if (ACPI_FAILURE (status)) {
 		return_ACPI_STATUS (status);
 	}
 
-	DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE,
-			  acpi_ps_get_opcode_name (op->opcode),
-			  1, "after Acpi_ex_resolve_operands");
-
+	ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
+			  acpi_ps_get_opcode_name (op->common.aml_opcode),
+			  1, "after acpi_ex_resolve_operands");
 
 	obj_desc = acpi_ns_get_attached_object (node);
 	if (!obj_desc) {
@@ -715,12 +728,12 @@
 	 */
 	operand_desc = walk_state->operands[walk_state->num_operands - 2];
 
-	obj_desc->region.address = (ACPI_PHYSICAL_ADDRESS) operand_desc->integer.value;
+	obj_desc->region.address = (acpi_physical_address) operand_desc->integer.value;
 	acpi_ut_remove_reference (operand_desc);
 
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Rgn_obj %p Addr %8.8X%8.8X Len %X\n",
-		obj_desc, HIDWORD(obj_desc->region.address), LODWORD(obj_desc->region.address),
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "rgn_obj %p Addr %8.8X%8.8X Len %X\n",
+		obj_desc,
+		ACPI_HIDWORD (obj_desc->region.address), ACPI_LODWORD (obj_desc->region.address),
 		obj_desc->region.length));
 
 	/* Now the address and length are valid for this opregion */
@@ -731,11 +744,106 @@
 }
 
 
+/*****************************************************************************
+ *
+ * FUNCTION:    acpi_ds_eval_data_object_operands
+ *
+ * PARAMETERS:  walk_state      - Current walk
+ *              Op              - A valid data_object Op object
+ *              obj_desc        - data_object
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Get the operands and complete the following data objec types:
+ *              Buffer
+ *              Package
+ *
+ ****************************************************************************/
+
+acpi_status
+acpi_ds_eval_data_object_operands (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op,
+	union acpi_operand_object       *obj_desc)
+{
+	acpi_status                     status;
+	union acpi_operand_object       *arg_desc;
+	u32                             length;
+
+
+	ACPI_FUNCTION_TRACE ("ds_eval_data_object_operands");
+
+
+	/* The first operand (for all of these data objects) is the length */
+
+	status = acpi_ds_create_operand (walk_state, op->common.value.arg, 1);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	status = acpi_ex_resolve_operands (walk_state->opcode,
+			  &(walk_state->operands [walk_state->num_operands -1]),
+			  walk_state);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/* Extract length operand */
+
+	arg_desc = walk_state->operands [walk_state->num_operands - 1];
+	length = (u32) arg_desc->integer.value;
+
+	/* Cleanup for length operand */
+
+	status = acpi_ds_obj_stack_pop (1, walk_state);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	acpi_ut_remove_reference (arg_desc);
+
+	/*
+	 * Create the actual data object
+	 */
+	switch (op->common.aml_opcode) {
+	case AML_BUFFER_OP:
+
+		status = acpi_ds_build_internal_buffer_obj (walk_state, op, length, &obj_desc);
+		break;
+
+	case AML_PACKAGE_OP:
+	case AML_VAR_PACKAGE_OP:
+
+		status = acpi_ds_build_internal_package_obj (walk_state, op, length, &obj_desc);
+		break;
+
+	default:
+		return_ACPI_STATUS (AE_AML_BAD_OPCODE);
+	}
+
+	if (ACPI_SUCCESS (status)) {
+		/*
+		 * Return the object in the walk_state, unless the parent is a package --
+		 * in this case, the return object will be stored in the parse tree
+		 * for the package.
+		 */
+		if ((!op->common.parent) ||
+			((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) &&
+			 (op->common.parent->common.aml_opcode != AML_VAR_PACKAGE_OP) &&
+			 (op->common.parent->common.aml_opcode != AML_NAME_OP))) {
+			walk_state->result_obj = obj_desc;
+		}
+	}
+
+	return_ACPI_STATUS (status);
+}
+
+
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_exec_begin_control_op
+ * FUNCTION:    acpi_ds_exec_begin_control_op
  *
- * PARAMETERS:  Walk_list       - The list that owns the walk stack
+ * PARAMETERS:  walk_list       - The list that owns the walk stack
  *              Op              - The control Op
  *
  * RETURN:      Status
@@ -747,20 +855,20 @@
 
 acpi_status
 acpi_ds_exec_begin_control_op (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op)
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op)
 {
-	acpi_status             status = AE_OK;
-	acpi_generic_state      *control_state;
+	acpi_status                     status = AE_OK;
+	union acpi_generic_state        *control_state;
 
 
-	PROC_NAME ("Ds_exec_begin_control_op");
+	ACPI_FUNCTION_NAME ("ds_exec_begin_control_op");
 
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op,
-		op->opcode, walk_state));
+		op->common.aml_opcode, walk_state));
 
-	switch (op->opcode) {
+	switch (op->common.aml_opcode) {
 	case AML_IF_OP:
 	case AML_WHILE_OP:
 
@@ -774,19 +882,19 @@
 			status = AE_NO_MEMORY;
 			break;
 		}
-
-		acpi_ut_push_generic_state (&walk_state->control_state, control_state);
-
 		/*
 		 * Save a pointer to the predicate for multiple executions
 		 * of a loop
 		 */
-		walk_state->control_state->control.aml_predicate_start =
-				 walk_state->parser_state.aml - 1;
-				 /* TBD: can this be removed? */
-				 /*Acpi_ps_pkg_length_encoding_size (GET8 (Walk_state->Parser_state->Aml));*/
-		break;
+		control_state->control.aml_predicate_start = walk_state->parser_state.aml - 1;
+		control_state->control.package_end = walk_state->parser_state.pkg_end;
+		control_state->control.opcode = op->common.aml_opcode;
+
 
+		/* Push the control state on this walk's control stack */
+
+		acpi_ut_push_generic_state (&walk_state->control_state, control_state);
+		break;
 
 	case AML_ELSE_OP:
 
@@ -799,12 +907,10 @@
 
 		break;
 
-
 	case AML_RETURN_OP:
 
 		break;
 
-
 	default:
 		break;
 	}
@@ -815,9 +921,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_exec_end_control_op
+ * FUNCTION:    acpi_ds_exec_end_control_op
  *
- * PARAMETERS:  Walk_list       - The list that owns the walk stack
+ * PARAMETERS:  walk_list       - The list that owns the walk stack
  *              Op              - The control Op
  *
  * RETURN:      Status
@@ -825,22 +931,21 @@
  * DESCRIPTION: Handles all control ops encountered during control method
  *              execution.
  *
- *
  ******************************************************************************/
 
 acpi_status
 acpi_ds_exec_end_control_op (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op)
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op)
 {
-	acpi_status             status = AE_OK;
-	acpi_generic_state      *control_state;
+	acpi_status                     status = AE_OK;
+	union acpi_generic_state        *control_state;
 
 
-	PROC_NAME ("Ds_exec_end_control_op");
+	ACPI_FUNCTION_NAME ("ds_exec_end_control_op");
 
 
-	switch (op->opcode) {
+	switch (op->common.aml_opcode) {
 	case AML_IF_OP:
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op));
@@ -890,17 +995,17 @@
 	case AML_RETURN_OP:
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-			"[RETURN_OP] Op=%p Arg=%p\n",op, op->value.arg));
+			"[RETURN_OP] Op=%p Arg=%p\n",op, op->common.value.arg));
 
 		/*
 		 * One optional operand -- the return value
 		 * It can be either an immediate operand or a result that
 		 * has been bubbled up the tree
 		 */
-		if (op->value.arg) {
+		if (op->common.value.arg) {
 			/* Return statement has an immediate operand */
 
-			status = acpi_ds_create_operands (walk_state, op->value.arg);
+			status = acpi_ds_create_operands (walk_state, op->common.value.arg);
 			if (ACPI_FAILURE (status)) {
 				return (status);
 			}
@@ -917,12 +1022,11 @@
 
 			/*
 			 * Get the return value and save as the last result
-			 * value.  This is the only place where Walk_state->Return_desc
+			 * value.  This is the only place where walk_state->return_desc
 			 * is set to anything other than zero!
 			 */
 			walk_state->return_desc = walk_state->operands[0];
 		}
-
 		else if ((walk_state->results) &&
 				 (walk_state->results->results.num_results > 0)) {
 			/*
@@ -934,18 +1038,17 @@
 			 *
 			 * Allow references created by the Index operator to return unchanged.
 			 */
-			if (VALID_DESCRIPTOR_TYPE (walk_state->results->results.obj_desc [0], ACPI_DESC_TYPE_INTERNAL) &&
-				((walk_state->results->results.obj_desc [0])->common.type == INTERNAL_TYPE_REFERENCE) &&
+			if ((ACPI_GET_DESCRIPTOR_TYPE (walk_state->results->results.obj_desc[0]) == ACPI_DESC_TYPE_OPERAND) &&
+				(ACPI_GET_OBJECT_TYPE (walk_state->results->results.obj_desc [0]) == ACPI_TYPE_LOCAL_REFERENCE) &&
 				((walk_state->results->results.obj_desc [0])->reference.opcode != AML_INDEX_OP)) {
-					status = acpi_ex_resolve_to_value (&walk_state->results->results.obj_desc [0], walk_state);
-					if (ACPI_FAILURE (status)) {
-						return (status);
-					}
+				status = acpi_ex_resolve_to_value (&walk_state->results->results.obj_desc [0], walk_state);
+				if (ACPI_FAILURE (status)) {
+					return (status);
+				}
 			}
 
 			walk_state->return_desc = walk_state->results->results.obj_desc [0];
 		}
-
 		else {
 			/* No return operand */
 
@@ -960,7 +1063,7 @@
 
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-			"Completed RETURN_OP State=%p, Ret_val=%p\n",
+			"Completed RETURN_OP State=%p, ret_val=%p\n",
 			walk_state, walk_state->return_desc));
 
 		/* End the control method execution right now */
@@ -979,7 +1082,7 @@
 
 		/* Call up to the OS service layer to handle this */
 
-		acpi_os_signal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode");
+		status = acpi_os_signal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode");
 
 		/* If and when it returns, all done. */
 
@@ -987,43 +1090,47 @@
 
 
 	case AML_BREAK_OP:
+	case AML_CONTINUE_OP: /* ACPI 2.0 */
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-			"Break to end of current package, Op=%p\n", op));
 
-		/* TBD: update behavior for ACPI 2.0 */
+		/* Pop and delete control states until we find a while */
 
-		/*
-		 * As per the ACPI specification:
-		 *      "The break operation causes the current package
-		 *          execution to complete"
-		 *      "Break -- Stop executing the current code package
-		 *          at this point"
-		 *
-		 * Returning AE_FALSE here will cause termination of
-		 * the current package, and execution will continue one
-		 * level up, starting with the completion of the parent Op.
-		 */
-		status = AE_CTRL_FALSE;
-		break;
+		while (walk_state->control_state &&
+				(walk_state->control_state->control.opcode != AML_WHILE_OP)) {
+			control_state = acpi_ut_pop_generic_state (&walk_state->control_state);
+			acpi_ut_delete_generic_state (control_state);
+		}
 
+		/* No while found? */
 
-	case AML_CONTINUE_OP: /* ACPI 2.0 */
+		if (!walk_state->control_state) {
+			return (AE_AML_NO_WHILE);
+		}
+
+		/* Was: walk_state->aml_last_while = walk_state->control_state->Control.aml_predicate_start; */
+
+		walk_state->aml_last_while = walk_state->control_state->control.package_end;
 
-		status = AE_NOT_IMPLEMENTED;
+		/* Return status depending on opcode */
+
+		if (op->common.aml_opcode == AML_BREAK_OP) {
+			status = AE_CTRL_BREAK;
+		}
+		else {
+			status = AE_CTRL_CONTINUE;
+		}
 		break;
 
 
 	default:
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown control opcode=%X Op=%p\n",
-			op->opcode, op));
+			op->common.aml_opcode, op));
 
 		status = AE_AML_BAD_OPCODE;
 		break;
 	}
 
-
 	return (status);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/dispatcher/dsutils.c linux-2.4.22-pre2/drivers/acpi/dispatcher/dsutils.c
--- linux-2.4.21/drivers/acpi/dispatcher/dsutils.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/dispatcher/dsutils.c	2003-06-26 21:43:21.000000000 +0000
@@ -1,48 +1,67 @@
 /*******************************************************************************
  *
  * Module Name: dsutils - Dispatcher utilities
- *              $Revision: 80 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "amlcode.h"
-#include "acdispat.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "acdebug.h"
+#include <acpi/acpi.h>
+#include <acpi/acparser.h>
+#include <acpi/amlcode.h>
+#include <acpi/acdispat.h>
+#include <acpi/acinterp.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acdebug.h>
 
 #define _COMPONENT          ACPI_DISPATCHER
-	 MODULE_NAME         ("dsutils")
+	 ACPI_MODULE_NAME    ("dsutils")
 
+#ifndef ACPI_NO_METHOD_EXECUTION
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_is_result_used
+ * FUNCTION:    acpi_ds_is_result_used
  *
  * PARAMETERS:  Op
- *              Result_obj
- *              Walk_state
+ *              result_obj
+ *              walk_state
  *
  * RETURN:      Status
  *
@@ -52,13 +71,13 @@
 
 u8
 acpi_ds_is_result_used (
-	acpi_parse_object       *op,
-	acpi_walk_state         *walk_state)
+	union acpi_parse_object         *op,
+	struct acpi_walk_state          *walk_state)
 {
-	const acpi_opcode_info  *parent_info;
+	const struct acpi_opcode_info   *parent_info;
 
 
-	FUNCTION_TRACE_PTR ("Ds_is_result_used", op);
+	ACPI_FUNCTION_TRACE_PTR ("ds_is_result_used", op);
 
 
 	/* Must have both an Op and a Result Object */
@@ -68,29 +87,25 @@
 		return_VALUE (TRUE);
 	}
 
-
 	/*
 	 * If there is no parent, the result can't possibly be used!
 	 * (An executing method typically has no parent, since each
 	 * method is parsed separately)  However, a method that is
 	 * invoked from another method has a parent.
 	 */
-	if (!op->parent) {
+	if (!op->common.parent) {
 		return_VALUE (FALSE);
 	}
 
-
 	/*
 	 * Get info on the parent.  The root Op is AML_SCOPE
 	 */
-
-	parent_info = acpi_ps_get_opcode_info (op->parent->opcode);
+	parent_info = acpi_ps_get_opcode_info (op->common.parent->common.aml_opcode);
 	if (parent_info->class == AML_CLASS_UNKNOWN) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown parent opcode. Op=%p\n", op));
 		return_VALUE (FALSE);
 	}
 
-
 	/*
 	 * Decide what to do with the result based on the parent.  If
 	 * the parent opcode will not use the result, delete the object.
@@ -98,88 +113,100 @@
 	 * as an operand later.
 	 */
 	switch (parent_info->class) {
-	/*
-	 * In these cases, the parent will never use the return object
-	 */
-	case AML_CLASS_CONTROL:        /* IF, ELSE, WHILE only */
+	case AML_CLASS_CONTROL:
 
-		switch (op->parent->opcode) {
+		switch (op->common.parent->common.aml_opcode) {
 		case AML_RETURN_OP:
 
 			/* Never delete the return value associated with a return opcode */
 
-			ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-				"Result used, [RETURN] opcode=%X Op=%p\n", op->opcode, op));
-			return_VALUE (TRUE);
-			break;
+			goto result_used;
 
 		case AML_IF_OP:
 		case AML_WHILE_OP:
 
 			/*
 			 * If we are executing the predicate AND this is the predicate op,
-			 * we will use the return value!
+			 * we will use the return value
 			 */
-			if ((walk_state->control_state->common.state == CONTROL_PREDICATE_EXECUTING) &&
+			if ((walk_state->control_state->common.state == ACPI_CONTROL_PREDICATE_EXECUTING) &&
 				(walk_state->control_state->control.predicate_op == op)) {
-				ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-					"Result used as a predicate, [IF/WHILE] opcode=%X Op=%p\n",
-					op->opcode, op));
-				return_VALUE (TRUE);
+				goto result_used;
 			}
+			break;
 
+		default:
+			/* Ignore other control opcodes */
 			break;
 		}
 
+		/* The general control opcode returns no result */
 
-		/* Fall through to not used case below */
+		goto result_not_used;
 
 
-	case AML_CLASS_NAMED_OBJECT:   /* Scope, method, etc. */
 	case AML_CLASS_CREATE:
 
 		/*
-		 * These opcodes allow Term_arg(s) as operands and therefore
-		 * method calls.  The result is used.
+		 * These opcodes allow term_arg(s) as operands and therefore
+		 * the operands can be method calls.  The result is used.
 		 */
-		if ((op->parent->opcode == AML_REGION_OP)               ||
-			(op->parent->opcode == AML_CREATE_FIELD_OP)         ||
-			(op->parent->opcode == AML_CREATE_BIT_FIELD_OP)     ||
-			(op->parent->opcode == AML_CREATE_BYTE_FIELD_OP)    ||
-			(op->parent->opcode == AML_CREATE_WORD_FIELD_OP)    ||
-			(op->parent->opcode == AML_CREATE_DWORD_FIELD_OP)   ||
-			(op->parent->opcode == AML_CREATE_QWORD_FIELD_OP)) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-				"Result used, [Region or Create_field] opcode=%X Op=%p\n",
-				op->opcode, op));
-			return_VALUE (TRUE);
+		goto result_used;
+
+
+	case AML_CLASS_NAMED_OBJECT:
+
+		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_PACKAGE_OP)     ||
+			(op->common.parent->common.aml_opcode == AML_VAR_PACKAGE_OP) ||
+			(op->common.parent->common.aml_opcode == AML_BUFFER_OP)      ||
+			(op->common.parent->common.aml_opcode == AML_INT_EVAL_SUBTREE_OP)) {
+			/*
+			 * These opcodes allow term_arg(s) as operands and therefore
+			 * the operands can be method calls.  The result is used.
+			 */
+			goto result_used;
 		}
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-			"Result not used, Parent opcode=%X Op=%p\n", op->opcode, op));
+		goto result_not_used;
 
-		return_VALUE (FALSE);
-		break;
 
-	/*
-	 * In all other cases. the parent will actually use the return
-	 * object, so keep it.
-	 */
 	default:
-		break;
+
+		/*
+		 * In all other cases. the parent will actually use the return
+		 * object, so keep it.
+		 */
+		goto result_used;
 	}
 
+
+result_used:
+	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Result of [%s] used by Parent [%s] Op=%p\n",
+			acpi_ps_get_opcode_name (op->common.aml_opcode),
+			acpi_ps_get_opcode_name (op->common.parent->common.aml_opcode), op));
+
 	return_VALUE (TRUE);
+
+
+result_not_used:
+	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Result of [%s] not used by Parent [%s] Op=%p\n",
+			acpi_ps_get_opcode_name (op->common.aml_opcode),
+			acpi_ps_get_opcode_name (op->common.parent->common.aml_opcode), op));
+
+	return_VALUE (FALSE);
+
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_delete_result_if_not_used
+ * FUNCTION:    acpi_ds_delete_result_if_not_used
  *
  * PARAMETERS:  Op
- *              Result_obj
- *              Walk_state
+ *              result_obj
+ *              walk_state
  *
  * RETURN:      Status
  *
@@ -192,15 +219,15 @@
 
 void
 acpi_ds_delete_result_if_not_used (
-	acpi_parse_object       *op,
-	acpi_operand_object     *result_obj,
-	acpi_walk_state         *walk_state)
+	union acpi_parse_object         *op,
+	union acpi_operand_object       *result_obj,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_operand_object     *obj_desc;
-	acpi_status             status;
+	union acpi_operand_object       *obj_desc;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE_PTR ("Ds_delete_result_if_not_used", result_obj);
+	ACPI_FUNCTION_TRACE_PTR ("ds_delete_result_if_not_used", result_obj);
 
 
 	if (!op) {
@@ -215,7 +242,7 @@
 
 	if (!acpi_ds_is_result_used (op, walk_state)) {
 		/*
-		 * Must pop the result stack (Obj_desc should be equal to Result_obj)
+		 * Must pop the result stack (obj_desc should be equal to result_obj)
 		 */
 		status = acpi_ds_result_pop (&obj_desc, walk_state);
 		if (ACPI_SUCCESS (status)) {
@@ -229,9 +256,89 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_create_operand
+ * FUNCTION:    acpi_ds_resolve_operands
+ *
+ * PARAMETERS:  walk_state          - Current walk state with operands on stack
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Resolve all operands to their values.  Used to prepare
+ *              arguments to a control method invocation (a call from one
+ *              method to another.)
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ds_resolve_operands (
+	struct acpi_walk_state          *walk_state)
+{
+	u32                             i;
+	acpi_status                     status = AE_OK;
+
+
+	ACPI_FUNCTION_TRACE_PTR ("ds_resolve_operands", walk_state);
+
+
+	/*
+	 * Attempt to resolve each of the valid operands
+	 * Method arguments are passed by value, not by reference
+	 */
+	for (i = 0; i < walk_state->num_operands; i++) {
+		status = acpi_ex_resolve_to_value (&walk_state->operands[i], walk_state);
+		if (ACPI_FAILURE (status)) {
+			break;
+		}
+	}
+
+	return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ds_clear_operands
+ *
+ * PARAMETERS:  walk_state          - Current walk state with operands on stack
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Clear all operands on the current walk state operand stack.
+ *
+ ******************************************************************************/
+
+void
+acpi_ds_clear_operands (
+	struct acpi_walk_state          *walk_state)
+{
+	u32                             i;
+
+
+	ACPI_FUNCTION_TRACE_PTR ("acpi_ds_clear_operands", walk_state);
+
+
+	/*
+	 * Remove a reference on each operand on the stack
+	 */
+	for (i = 0; i < walk_state->num_operands; i++) {
+		/*
+		 * Remove a reference to all operands, including both
+		 * "Arguments" and "Targets".
+		 */
+		acpi_ut_remove_reference (walk_state->operands[i]);
+		walk_state->operands[i] = NULL;
+	}
+
+	walk_state->num_operands = 0;
+	return_VOID;
+}
+#endif
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ds_create_operand
  *
- * PARAMETERS:  Walk_state
+ * PARAMETERS:  walk_state
  *              Arg
  *
  * RETURN:      Status
@@ -245,34 +352,32 @@
 
 acpi_status
 acpi_ds_create_operand (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *arg,
-	u32                     arg_index)
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *arg,
+	u32                             arg_index)
 {
-	acpi_status             status = AE_OK;
-	NATIVE_CHAR             *name_string;
-	u32                     name_length;
-	acpi_object_type8       data_type;
-	acpi_operand_object     *obj_desc;
-	acpi_parse_object       *parent_op;
-	u16                     opcode;
-	u32                     flags;
-	operating_mode          interpreter_mode;
-	const acpi_opcode_info  *op_info;
+	acpi_status                     status = AE_OK;
+	char                            *name_string;
+	u32                             name_length;
+	union acpi_operand_object       *obj_desc;
+	union acpi_parse_object         *parent_op;
+	u16                             opcode;
+	acpi_interpreter_mode           interpreter_mode;
+	const struct acpi_opcode_info   *op_info;
 
 
-	FUNCTION_TRACE_PTR ("Ds_create_operand", arg);
+	ACPI_FUNCTION_TRACE_PTR ("ds_create_operand", arg);
 
 
 	/* A valid name must be looked up in the namespace */
 
-	if ((arg->opcode == AML_INT_NAMEPATH_OP) &&
-		(arg->value.string)) {
+	if ((arg->common.aml_opcode == AML_INT_NAMEPATH_OP) &&
+		(arg->common.value.string)) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Getting a name: Arg=%p\n", arg));
 
 		/* Get the entire name string from the AML stream */
 
-		status = acpi_ex_get_name_string (ACPI_TYPE_ANY, arg->value.buffer,
+		status = acpi_ex_get_name_string (ACPI_TYPE_ANY, arg->common.value.buffer,
 				  &name_string, &name_length);
 
 		if (ACPI_FAILURE (status)) {
@@ -281,7 +386,7 @@
 
 		/*
 		 * All prefixes have been handled, and the name is
-		 * in Name_string
+		 * in name_string
 		 */
 
 		/*
@@ -290,46 +395,41 @@
 		 * IMODE_EXECUTE) in order to support the creation of
 		 * namespace objects during the execution of control methods.
 		 */
-		parent_op = arg->parent;
-		op_info = acpi_ps_get_opcode_info (parent_op->opcode);
+		parent_op = arg->common.parent;
+		op_info = acpi_ps_get_opcode_info (parent_op->common.aml_opcode);
 		if ((op_info->flags & AML_NSNODE) &&
-			(parent_op->opcode != AML_INT_METHODCALL_OP) &&
-			(parent_op->opcode != AML_REGION_OP) &&
-			(parent_op->opcode != AML_INT_NAMEPATH_OP)) {
+			(parent_op->common.aml_opcode != AML_INT_METHODCALL_OP) &&
+			(parent_op->common.aml_opcode != AML_REGION_OP) &&
+			(parent_op->common.aml_opcode != AML_INT_NAMEPATH_OP)) {
 			/* Enter name into namespace if not found */
 
-			interpreter_mode = IMODE_LOAD_PASS2;
+			interpreter_mode = ACPI_IMODE_LOAD_PASS2;
 		}
 
 		else {
 			/* Return a failure if name not found */
 
-			interpreter_mode = IMODE_EXECUTE;
+			interpreter_mode = ACPI_IMODE_EXECUTE;
 		}
 
 		status = acpi_ns_lookup (walk_state->scope_info, name_string,
 				 ACPI_TYPE_ANY, interpreter_mode,
-				 NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE,
+				 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
 				 walk_state,
-				 (acpi_namespace_node **) &obj_desc);
-
-		/* Free the namestring created above */
-
-		ACPI_MEM_FREE (name_string);
-
+				 ACPI_CAST_INDIRECT_PTR (struct acpi_namespace_node, &obj_desc));
 		/*
 		 * The only case where we pass through (ignore) a NOT_FOUND
-		 * error is for the Cond_ref_of opcode.
+		 * error is for the cond_ref_of opcode.
 		 */
 		if (status == AE_NOT_FOUND) {
-			if (parent_op->opcode == AML_COND_REF_OF_OP) {
+			if (parent_op->common.aml_opcode == AML_COND_REF_OF_OP) {
 				/*
 				 * For the Conditional Reference op, it's OK if
 				 * the name is not found;  We just need a way to
 				 * indicate this to the interpreter, set the
 				 * object to the root
 				 */
-				obj_desc = (acpi_operand_object *) acpi_gbl_root_node;
+				obj_desc = ACPI_CAST_PTR (union acpi_operand_object, acpi_gbl_root_node);
 				status = AE_OK;
 			}
 
@@ -339,14 +439,17 @@
 				 * very serious error at this point
 				 */
 				status = AE_AML_NAME_NOT_FOUND;
-
-				/* TBD: Externalize Name_string and print */
-
-				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-						"Object name was not found in namespace\n"));
 			}
 		}
 
+		if (ACPI_FAILURE (status)) {
+			ACPI_REPORT_NSERROR (name_string, status);
+		}
+
+		/* Free the namestring created above */
+
+		ACPI_MEM_FREE (name_string);
+
 		/* Check status from the lookup */
 
 		if (ACPI_FAILURE (status)) {
@@ -359,47 +462,42 @@
 		if (ACPI_FAILURE (status)) {
 			return_ACPI_STATUS (status);
 		}
-		DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state));
+		ACPI_DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state));
 	}
 
 
 	else {
 		/* Check for null name case */
 
-		if (arg->opcode == AML_INT_NAMEPATH_OP) {
+		if (arg->common.aml_opcode == AML_INT_NAMEPATH_OP) {
 			/*
 			 * If the name is null, this means that this is an
 			 * optional result parameter that was not specified
-			 * in the original ASL.  Create an Reference for a
-			 * placeholder
+			 * in the original ASL.  Create a Zero Constant for a
+			 * placeholder.  (Store to a constant is a Noop.)
 			 */
 			opcode = AML_ZERO_OP;       /* Has no arguments! */
 
 			ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Null namepath: Arg=%p\n", arg));
-
-			/*
-			 * TBD: [Investigate] anything else needed for the
-			 * zero op lvalue?
-			 */
 		}
 
 		else {
-			opcode = arg->opcode;
+			opcode = arg->common.aml_opcode;
 		}
 
+		/* Get the object type of the argument */
 
-		/* Get the data type of the argument */
-
-		data_type = acpi_ds_map_opcode_to_data_type (opcode, &flags);
-		if (data_type == INTERNAL_TYPE_INVALID) {
+		op_info = acpi_ps_get_opcode_info (opcode);
+		if (op_info->object_type == ACPI_TYPE_INVALID) {
 			return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
 		}
 
-		if (flags & OP_HAS_RETURN_VALUE) {
+		if (op_info->flags & AML_HAS_RETVAL) {
 			ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
 				"Argument previously created, already stacked \n"));
 
-			DEBUGGER_EXEC (acpi_db_display_argument_object (walk_state->operands [walk_state->num_operands - 1], walk_state));
+			ACPI_DEBUGGER_EXEC (acpi_db_display_argument_object (
+				walk_state->operands [walk_state->num_operands - 1], walk_state));
 
 			/*
 			 * Use value that was already previously returned
@@ -415,13 +513,11 @@
 					acpi_format_exception (status)));
 				return_ACPI_STATUS (status);
 			}
-
 		}
-
 		else {
 			/* Create an ACPI_INTERNAL_OBJECT for the argument */
 
-			obj_desc = acpi_ut_create_internal_object (data_type);
+			obj_desc = acpi_ut_create_internal_object (op_info->object_type);
 			if (!obj_desc) {
 				return_ACPI_STATUS (AE_NO_MEMORY);
 			}
@@ -434,7 +530,7 @@
 				acpi_ut_delete_object_desc (obj_desc);
 				return_ACPI_STATUS (status);
 			}
-	   }
+		}
 
 		/* Put the operand object on the object stack */
 
@@ -443,7 +539,7 @@
 			return_ACPI_STATUS (status);
 		}
 
-		DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state));
+		ACPI_DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state));
 	}
 
 	return_ACPI_STATUS (AE_OK);
@@ -452,9 +548,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_create_operands
+ * FUNCTION:    acpi_ds_create_operands
  *
- * PARAMETERS:  First_arg           - First argument of a parser argument tree
+ * PARAMETERS:  first_arg           - First argument of a parser argument tree
  *
  * RETURN:      Status
  *
@@ -466,15 +562,15 @@
 
 acpi_status
 acpi_ds_create_operands (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *first_arg)
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *first_arg)
 {
-	acpi_status             status = AE_OK;
-	acpi_parse_object       *arg;
-	u32                     arg_count = 0;
+	acpi_status                     status = AE_OK;
+	union acpi_parse_object         *arg;
+	u32                             arg_count = 0;
 
 
-	FUNCTION_TRACE_PTR ("Ds_create_operands", first_arg);
+	ACPI_FUNCTION_TRACE_PTR ("ds_create_operands", first_arg);
 
 
 	/* For all arguments in the list... */
@@ -491,7 +587,7 @@
 
 		/* Move on to next argument, if any */
 
-		arg = arg->next;
+		arg = arg->common.next;
 		arg_count++;
 	}
 
@@ -504,7 +600,7 @@
 	 * pop everything off of the operand stack and delete those
 	 * objects
 	 */
-	acpi_ds_obj_stack_pop_and_delete (arg_count, walk_state);
+	(void) acpi_ds_obj_stack_pop_and_delete (arg_count, walk_state);
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "While creating Arg %d - %s\n",
 		(arg_count + 1), acpi_format_exception (status)));
@@ -512,307 +608,3 @@
 }
 
 
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ds_resolve_operands
- *
- * PARAMETERS:  Walk_state          - Current walk state with operands on stack
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Resolve all operands to their values.  Used to prepare
- *              arguments to a control method invocation (a call from one
- *              method to another.)
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ds_resolve_operands (
-	acpi_walk_state         *walk_state)
-{
-	u32                     i;
-	acpi_status             status = AE_OK;
-
-
-	FUNCTION_TRACE_PTR ("Ds_resolve_operands", walk_state);
-
-
-	/*
-	 * Attempt to resolve each of the valid operands
-	 * Method arguments are passed by value, not by reference
-	 */
-
-	/*
-	 * TBD: [Investigate] Note from previous parser:
-	 *   Ref_of problem with Acpi_ex_resolve_to_value() conversion.
-	 */
-	for (i = 0; i < walk_state->num_operands; i++) {
-		status = acpi_ex_resolve_to_value (&walk_state->operands[i], walk_state);
-		if (ACPI_FAILURE (status)) {
-			break;
-		}
-	}
-
-	return_ACPI_STATUS (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ds_map_opcode_to_data_type
- *
- * PARAMETERS:  Opcode          - AML opcode to map
- *              Out_flags       - Additional info about the opcode
- *
- * RETURN:      The ACPI type associated with the opcode
- *
- * DESCRIPTION: Convert a raw AML opcode to the associated ACPI data type,
- *              if any.  If the opcode returns a value as part of the
- *              intepreter execution, a flag is returned in Out_flags.
- *
- ******************************************************************************/
-
-acpi_object_type8
-acpi_ds_map_opcode_to_data_type (
-	u16                     opcode,
-	u32                     *out_flags)
-{
-	acpi_object_type8       data_type = INTERNAL_TYPE_INVALID;
-	const acpi_opcode_info  *op_info;
-	u32                     flags = 0;
-
-
-	PROC_NAME ("Ds_map_opcode_to_data_type");
-
-
-	op_info = acpi_ps_get_opcode_info (opcode);
-	if (op_info->class == AML_CLASS_UNKNOWN) {
-		/* Unknown opcode */
-
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown AML opcode: %x\n", opcode));
-		return (data_type);
-	}
-
-
-/*
- * TBD: Use op class
- */
-
-	switch (op_info->type) {
-
-	case AML_TYPE_LITERAL:
-
-		switch (opcode) {
-		case AML_BYTE_OP:
-		case AML_WORD_OP:
-		case AML_DWORD_OP:
-		case AML_QWORD_OP:
-
-			data_type = ACPI_TYPE_INTEGER;
-			break;
-
-
-		case AML_STRING_OP:
-
-			data_type = ACPI_TYPE_STRING;
-			break;
-
-		case AML_INT_NAMEPATH_OP:
-			data_type = INTERNAL_TYPE_REFERENCE;
-			break;
-
-		default:
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-				"Unknown (type LITERAL) AML opcode: %x\n", opcode));
-			break;
-		}
-		break;
-
-
-	case AML_TYPE_DATA_TERM:
-
-		switch (opcode) {
-		case AML_BUFFER_OP:
-
-			data_type = ACPI_TYPE_BUFFER;
-			break;
-
-		case AML_PACKAGE_OP:
-		case AML_VAR_PACKAGE_OP:
-
-			data_type = ACPI_TYPE_PACKAGE;
-			break;
-
-		default:
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-				"Unknown (type DATA_TERM) AML opcode: %x\n", opcode));
-			break;
-		}
-		break;
-
-
-	case AML_TYPE_CONSTANT:
-	case AML_TYPE_METHOD_ARGUMENT:
-	case AML_TYPE_LOCAL_VARIABLE:
-
-		data_type = INTERNAL_TYPE_REFERENCE;
-		break;
-
-
-	case AML_TYPE_EXEC_1A_0T_1R:
-	case AML_TYPE_EXEC_1A_1T_1R:
-	case AML_TYPE_EXEC_2A_0T_1R:
-	case AML_TYPE_EXEC_2A_1T_1R:
-	case AML_TYPE_EXEC_2A_2T_1R:
-	case AML_TYPE_EXEC_3A_1T_1R:
-	case AML_TYPE_EXEC_6A_0T_1R:
-	case AML_TYPE_RETURN:
-
-		flags = OP_HAS_RETURN_VALUE;
-		data_type = ACPI_TYPE_ANY;
-		break;
-
-
-	case AML_TYPE_METHOD_CALL:
-
-		flags = OP_HAS_RETURN_VALUE;
-		data_type = ACPI_TYPE_METHOD;
-		break;
-
-
-	case AML_TYPE_NAMED_FIELD:
-	case AML_TYPE_NAMED_SIMPLE:
-	case AML_TYPE_NAMED_COMPLEX:
-	case AML_TYPE_NAMED_NO_OBJ:
-
-		data_type = acpi_ds_map_named_opcode_to_data_type (opcode);
-		break;
-
-
-	case AML_TYPE_EXEC_1A_0T_0R:
-	case AML_TYPE_EXEC_2A_0T_0R:
-	case AML_TYPE_EXEC_3A_0T_0R:
-	case AML_TYPE_EXEC_1A_1T_0R:
-	case AML_TYPE_CONTROL:
-
-		/* No mapping needed at this time */
-
-		break;
-
-
-	default:
-
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-			"Unimplemented data type opcode: %x\n", opcode));
-		break;
-	}
-
-	/* Return flags to caller if requested */
-
-	if (out_flags) {
-		*out_flags = flags;
-	}
-
-	return (data_type);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ds_map_named_opcode_to_data_type
- *
- * PARAMETERS:  Opcode              - The Named AML opcode to map
- *
- * RETURN:      The ACPI type associated with the named opcode
- *
- * DESCRIPTION: Convert a raw Named AML opcode to the associated data type.
- *              Named opcodes are a subsystem of the AML opcodes.
- *
- ******************************************************************************/
-
-acpi_object_type8
-acpi_ds_map_named_opcode_to_data_type (
-	u16                     opcode)
-{
-	acpi_object_type8       data_type;
-
-
-	FUNCTION_ENTRY ();
-
-
-	/* Decode Opcode */
-
-	switch (opcode) {
-	case AML_SCOPE_OP:
-		data_type = INTERNAL_TYPE_SCOPE;
-		break;
-
-	case AML_DEVICE_OP:
-		data_type = ACPI_TYPE_DEVICE;
-		break;
-
-	case AML_THERMAL_ZONE_OP:
-		data_type = ACPI_TYPE_THERMAL;
-		break;
-
-	case AML_METHOD_OP:
-		data_type = ACPI_TYPE_METHOD;
-		break;
-
-	case AML_POWER_RES_OP:
-		data_type = ACPI_TYPE_POWER;
-		break;
-
-	case AML_PROCESSOR_OP:
-		data_type = ACPI_TYPE_PROCESSOR;
-		break;
-
-	case AML_FIELD_OP:                              /* Field_op */
-		data_type = INTERNAL_TYPE_FIELD_DEFN;
-		break;
-
-	case AML_INDEX_FIELD_OP:                        /* Index_field_op */
-		data_type = INTERNAL_TYPE_INDEX_FIELD_DEFN;
-		break;
-
-	case AML_BANK_FIELD_OP:                         /* Bank_field_op */
-		data_type = INTERNAL_TYPE_BANK_FIELD_DEFN;
-		break;
-
-	case AML_INT_NAMEDFIELD_OP:                     /* NO CASE IN ORIGINAL  */
-		data_type = ACPI_TYPE_ANY;
-		break;
-
-	case AML_NAME_OP:                               /* Name_op - special code in original */
-	case AML_INT_NAMEPATH_OP:
-		data_type = ACPI_TYPE_ANY;
-		break;
-
-	case AML_ALIAS_OP:
-		data_type = INTERNAL_TYPE_ALIAS;
-		break;
-
-	case AML_MUTEX_OP:
-		data_type = ACPI_TYPE_MUTEX;
-		break;
-
-	case AML_EVENT_OP:
-		data_type = ACPI_TYPE_EVENT;
-		break;
-
-	case AML_DATA_REGION_OP:
-	case AML_REGION_OP:
-		data_type = ACPI_TYPE_REGION;
-		break;
-
-
-	default:
-		data_type = ACPI_TYPE_ANY;
-		break;
-
-	}
-
-	return (data_type);
-}
-
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/dispatcher/dswexec.c linux-2.4.22-pre2/drivers/acpi/dispatcher/dswexec.c
--- linux-2.4.21/drivers/acpi/dispatcher/dswexec.c	2002-11-28 23:53:12.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/dispatcher/dswexec.c	2003-06-26 21:43:33.000000000 +0000
@@ -2,45 +2,64 @@
  *
  * Module Name: dswexec - Dispatcher method execution callbacks;
  *                        dispatch to interpreter.
- *              $Revision: 79 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "amlcode.h"
-#include "acdispat.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "acdebug.h"
+#include <acpi/acpi.h>
+#include <acpi/acparser.h>
+#include <acpi/amlcode.h>
+#include <acpi/acdispat.h>
+#include <acpi/acinterp.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acdebug.h>
+#include <acpi/acdisasm.h>
 
 
 #define _COMPONENT          ACPI_DISPATCHER
-	 MODULE_NAME         ("dswexec")
+	 ACPI_MODULE_NAME    ("dswexec")
 
 /*
- * Dispatch tables for opcode classes
+ * Dispatch table for opcode classes
  */
-ACPI_EXECUTE_OP         acpi_gbl_op_type_dispatch [] = {
+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,
@@ -55,9 +74,9 @@
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ds_get_predicate_value
+ * FUNCTION:    acpi_ds_get_predicate_value
  *
- * PARAMETERS:  Walk_state      - Current state of the parse tree walk
+ * PARAMETERS:  walk_state      - Current state of the parse tree walk
  *
  * RETURN:      Status
  *
@@ -67,18 +86,18 @@
 
 acpi_status
 acpi_ds_get_predicate_value (
-	acpi_walk_state         *walk_state,
-	u32                     has_result_obj) {
-	acpi_status             status = AE_OK;
-	acpi_operand_object     *obj_desc;
+	struct acpi_walk_state          *walk_state,
+	union acpi_operand_object       *result_obj) {
+	acpi_status                     status = AE_OK;
+	union acpi_operand_object       *obj_desc;
 
 
-	FUNCTION_TRACE_PTR ("Ds_get_predicate_value", walk_state);
+	ACPI_FUNCTION_TRACE_PTR ("ds_get_predicate_value", walk_state);
 
 
 	walk_state->control_state->common.state = 0;
 
-	if (has_result_obj) {
+	if (result_obj) {
 		status = acpi_ds_result_pop (&obj_desc, walk_state);
 		if (ACPI_FAILURE (status)) {
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
@@ -88,7 +107,6 @@
 			return_ACPI_STATUS (status);
 		}
 	}
-
 	else {
 		status = acpi_ds_create_operand (walk_state, walk_state->op, 0);
 		if (ACPI_FAILURE (status)) {
@@ -104,30 +122,28 @@
 	}
 
 	if (!obj_desc) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No predicate Obj_desc=%p State=%p\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No predicate obj_desc=%p State=%p\n",
 			obj_desc, walk_state));
 
 		return_ACPI_STATUS (AE_AML_NO_OPERAND);
 	}
 
-
 	/*
 	 * Result of predicate evaluation currently must
 	 * be a number
 	 */
-	if (obj_desc->common.type != ACPI_TYPE_INTEGER) {
+	if (ACPI_GET_OBJECT_TYPE (obj_desc) != ACPI_TYPE_INTEGER) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-			"Bad predicate (not a number) Obj_desc=%p State=%p Type=%X\n",
-			obj_desc, walk_state, obj_desc->common.type));
+			"Bad predicate (not a number) obj_desc=%p State=%p Type=%X\n",
+			obj_desc, walk_state, ACPI_GET_OBJECT_TYPE (obj_desc)));
 
 		status = AE_AML_OPERAND_TYPE;
 		goto cleanup;
 	}
 
-
 	/* Truncate the predicate to 32-bits if necessary */
 
-	acpi_ex_truncate_for32bit_table (obj_desc, walk_state);
+	acpi_ex_truncate_for32bit_table (obj_desc);
 
 	/*
 	 * Save the result of the predicate evaluation on
@@ -136,7 +152,6 @@
 	if (obj_desc->integer.value) {
 		walk_state->control_state->common.value = TRUE;
 	}
-
 	else {
 		/*
 		 * Predicate is FALSE, we will just toss the
@@ -149,12 +164,12 @@
 
 cleanup:
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%pn",
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n",
 		walk_state->control_state->common.value, walk_state->op));
 
 	 /* Break to debugger to display result */
 
-	DEBUGGER_EXEC (acpi_db_display_result_object (obj_desc, walk_state));
+	ACPI_DEBUGGER_EXEC (acpi_db_display_result_object (obj_desc, walk_state));
 
 	/*
 	 * Delete the predicate result object (we know that
@@ -162,17 +177,17 @@
 	 */
 	acpi_ut_remove_reference (obj_desc);
 
-	walk_state->control_state->common.state = CONTROL_NORMAL;
+	walk_state->control_state->common.state = ACPI_CONTROL_NORMAL;
 	return_ACPI_STATUS (status);
 }
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ds_exec_begin_op
+ * FUNCTION:    acpi_ds_exec_begin_op
  *
- * PARAMETERS:  Walk_state      - Current state of the parse tree walk
- *              Out_op          - Return op if a new one is created
+ * PARAMETERS:  walk_state      - Current state of the parse tree walk
+ *              out_op          - Return op if a new one is created
  *
  * RETURN:      Status
  *
@@ -184,15 +199,15 @@
 
 acpi_status
 acpi_ds_exec_begin_op (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       **out_op)
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         **out_op)
 {
-	acpi_parse_object       *op;
-	acpi_status             status = AE_OK;
-	u32                     opcode_class;
+	union acpi_parse_object         *op;
+	acpi_status                     status = AE_OK;
+	u32                             opcode_class;
 
 
-	FUNCTION_TRACE_PTR ("Ds_exec_begin_op", walk_state);
+	ACPI_FUNCTION_TRACE_PTR ("ds_exec_begin_op", walk_state);
 
 
 	op = walk_state->op;
@@ -204,8 +219,18 @@
 
 		op = *out_op;
 		walk_state->op = op;
-		walk_state->op_info = acpi_ps_get_opcode_info (op->opcode);
-		walk_state->opcode = op->opcode;
+		walk_state->opcode = op->common.aml_opcode;
+		walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
+
+		if (acpi_ns_opens_scope (walk_state->op_info->object_type)) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
+				acpi_ut_get_type_name (walk_state->op_info->object_type), op));
+
+			status = acpi_ds_scope_stack_pop (walk_state);
+			if (ACPI_FAILURE (status)) {
+				return_ACPI_STATUS (status);
+			}
+		}
 	}
 
 	if (op == walk_state->origin) {
@@ -223,11 +248,11 @@
 	 */
 	if ((walk_state->control_state) &&
 		(walk_state->control_state->common.state ==
-			CONTROL_CONDITIONAL_EXECUTING)) {
+			ACPI_CONTROL_CONDITIONAL_EXECUTING)) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Exec predicate Op=%p State=%p\n",
 				  op, walk_state));
 
-		walk_state->control_state->common.state = CONTROL_PREDICATE_EXECUTING;
+		walk_state->control_state->common.state = ACPI_CONTROL_PREDICATE_EXECUTING;
 
 		/* Save start of predicate */
 
@@ -239,7 +264,7 @@
 
 	/* We want to send namepaths to the load code */
 
-	if (op->opcode == AML_INT_NAMEPATH_OP) {
+	if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) {
 		opcode_class = AML_CLASS_NAMED_OBJECT;
 	}
 
@@ -260,7 +285,7 @@
 
 	case AML_CLASS_NAMED_OBJECT:
 
-		if (walk_state->walk_type == WALK_METHOD) {
+		if (walk_state->walk_type == ACPI_WALK_METHOD) {
 			/*
 			 * Found a named object declaration during method
 			 * execution;  we must enter this object into the
@@ -271,19 +296,16 @@
 			status = acpi_ds_load2_begin_op (walk_state, NULL);
 		}
 
-
-		if (op->opcode == AML_REGION_OP) {
+		if (op->common.aml_opcode == AML_REGION_OP) {
 			status = acpi_ds_result_stack_push (walk_state);
 		}
-
 		break;
 
 
-	/* most operators with arguments */
-
 	case AML_CLASS_EXECUTE:
 	case AML_CLASS_CREATE:
 
+		/* most operators with arguments */
 		/* Start a new result/operand state */
 
 		status = acpi_ds_result_stack_push (walk_state);
@@ -302,9 +324,9 @@
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ds_exec_end_op
+ * FUNCTION:    acpi_ds_exec_end_op
  *
- * PARAMETERS:  Walk_state      - Current state of the parse tree walk
+ * PARAMETERS:  walk_state      - Current state of the parse tree walk
  *              Op              - Op that has been just been completed in the
  *                                walk;  Arguments have now been evaluated.
  *
@@ -318,18 +340,17 @@
 
 acpi_status
 acpi_ds_exec_end_op (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_parse_object       *op;
-	acpi_status             status = AE_OK;
-	u32                     op_type;
-	u32                     op_class;
-	acpi_parse_object       *next_op;
-	acpi_parse_object       *first_arg;
-	u32                     i;
+	union acpi_parse_object         *op;
+	acpi_status                     status = AE_OK;
+	u32                             op_type;
+	u32                             op_class;
+	union acpi_parse_object         *next_op;
+	union acpi_parse_object         *first_arg;
 
 
-	FUNCTION_TRACE_PTR ("Ds_exec_end_op", walk_state);
+	ACPI_FUNCTION_TRACE_PTR ("ds_exec_end_op", walk_state);
 
 
 	op      = walk_state->op;
@@ -337,11 +358,11 @@
 	op_class = walk_state->op_info->class;
 
 	if (op_class == AML_CLASS_UNKNOWN) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode %X\n", op->opcode));
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode %X\n", op->common.aml_opcode));
 		return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
 	}
 
-	first_arg = op->value.arg;
+	first_arg = op->common.value.arg;
 
 	/* Init the walk state */
 
@@ -349,22 +370,19 @@
 	walk_state->return_desc = NULL;
 	walk_state->result_obj = NULL;
 
-
 	/* Call debugger for single step support (DEBUG build only) */
 
-	DEBUGGER_EXEC (status = acpi_db_single_step (walk_state, op, op_class));
-	DEBUGGER_EXEC (if (ACPI_FAILURE (status)) {return_ACPI_STATUS (status);});
+	ACPI_DEBUGGER_EXEC (status = acpi_db_single_step (walk_state, op, op_class));
+	ACPI_DEBUGGER_EXEC (if (ACPI_FAILURE (status)) {return_ACPI_STATUS (status);});
 
-
-	switch (op_class) {
 	/* Decode the Opcode Class */
 
-	case AML_CLASS_ARGUMENT: /* constants, literals, etc.  do nothing */
+	switch (op_class) {
+	case AML_CLASS_ARGUMENT:    /* constants, literals, etc. -- do nothing */
 		break;
 
-	/* most operators with arguments */
 
-	case AML_CLASS_EXECUTE:
+	case AML_CLASS_EXECUTE:     /* most operators with arguments */
 
 		/* Build resolved operand stack */
 
@@ -385,48 +403,28 @@
 		status = acpi_ex_resolve_operands (walk_state->opcode,
 				  &(walk_state->operands [walk_state->num_operands -1]),
 				  walk_state);
-		if (ACPI_FAILURE (status)) {
-			/* TBD: must pop and delete operands */
-
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "[%s]: Could not resolve operands, %s\n",
-				acpi_ps_get_opcode_name (walk_state->opcode), acpi_format_exception (status)));
+		if (ACPI_SUCCESS (status)) {
+			ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
+					  acpi_ps_get_opcode_name (walk_state->opcode),
+					  walk_state->num_operands, "after ex_resolve_operands");
 
 			/*
-			 * On error, we must delete all the operands and clear the
-			 * operand stack
+			 * Dispatch the request to the appropriate interpreter handler
+			 * routine.  There is one routine per opcode "type" based upon the
+			 * number of opcode arguments and return type.
 			 */
-			for (i = 0; i < walk_state->num_operands; i++) {
-				acpi_ut_remove_reference (walk_state->operands[i]);
-				walk_state->operands[i] = NULL;
-			}
-
-			walk_state->num_operands = 0;
-			goto cleanup;
+			status = acpi_gbl_op_type_dispatch [op_type] (walk_state);
 		}
-
-		DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, acpi_ps_get_opcode_name (walk_state->opcode),
-				  walk_state->num_operands, "after Ex_resolve_operands");
-
-		/*
-		 * Dispatch the request to the appropriate interpreter handler
-		 * 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);
-
-
-		/* Delete argument objects and clear the operand stack */
-
-		for (i = 0; i < walk_state->num_operands; i++) {
-			/*
-			 * Remove a reference to all operands, including both
-			 * "Arguments" and "Targets".
-			 */
-			acpi_ut_remove_reference (walk_state->operands[i]);
-			walk_state->operands[i] = NULL;
+		else {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"[%s]: Could not resolve operands, %s\n",
+				acpi_ps_get_opcode_name (walk_state->opcode),
+				acpi_format_exception (status)));
 		}
 
-		walk_state->num_operands = 0;
+		/* Always delete the argument objects and clear the operand stack */
+
+		acpi_ds_clear_operands (walk_state);
 
 		/*
 		 * If a result object was returned from above, push it on the
@@ -445,11 +443,14 @@
 		switch (op_type) {
 		case AML_TYPE_CONTROL:    /* Type 1 opcode, IF/ELSE/WHILE/NOOP */
 
-			/* 1 Operand, 0 External_result, 0 Internal_result */
+			/* 1 Operand, 0 external_result, 0 internal_result */
 
 			status = acpi_ds_exec_end_control_op (walk_state, op);
+			if (ACPI_FAILURE (status)) {
+				break;
+			}
 
-			acpi_ds_result_stack_pop (walk_state);
+			status = acpi_ds_result_stack_pop (walk_state);
 			break;
 
 
@@ -461,13 +462,13 @@
 			 * (AML_METHODCALL) Op->Value->Arg->Node contains
 			 * the method Node pointer
 			 */
-			/* Next_op points to the op that holds the method name */
+			/* next_op points to the op that holds the method name */
 
 			next_op = first_arg;
 
-			/* Next_op points to first argument op */
+			/* next_op points to first argument op */
 
-			next_op = next_op->next;
+			next_op = next_op->common.next;
 
 			/*
 			 * Get the method's arguments and put them on the operand stack
@@ -478,13 +479,15 @@
 			}
 
 			/*
-			 * Since the operands will be passed to another
-			 * control method, we must resolve all local
-			 * references here (Local variables, arguments
-			 * to *this* method, etc.)
+			 * Since the operands will be passed to another control method,
+			 * we must resolve all local references here (Local variables,
+			 * arguments to *this* method, etc.)
 			 */
 			status = acpi_ds_resolve_operands (walk_state);
 			if (ACPI_FAILURE (status)) {
+				/* On error, clear all resolved operands */
+
+				acpi_ds_clear_operands (walk_state);
 				break;
 			}
 
@@ -499,13 +502,12 @@
 			 * especially the operand count!
 			 */
 			return_ACPI_STATUS (status);
-			break;
 
 
 		case AML_TYPE_CREATE_FIELD:
 
 			ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
-				"Executing Create_field Buffer/Index Op=%p\n", op));
+				"Executing create_field Buffer/Index Op=%p\n", op));
 
 			status = acpi_ds_load2_end_op (walk_state);
 			if (ACPI_FAILURE (status)) {
@@ -516,18 +518,65 @@
 			break;
 
 
+		case AML_TYPE_CREATE_OBJECT:
+
+			ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+				"Executing create_object (Buffer/Package) Op=%p\n", op));
+
+			switch (op->common.parent->common.aml_opcode) {
+			case AML_NAME_OP:
+
+				/*
+				 * Put the Node on the object stack (Contains the ACPI Name of
+				 * this object)
+				 */
+				walk_state->operands[0] = (void *) op->common.parent->common.node;
+				walk_state->num_operands = 1;
+
+				status = acpi_ds_create_node (walk_state, op->common.parent->common.node, op->common.parent);
+				if (ACPI_FAILURE (status)) {
+					break;
+				}
+
+				/* Fall through */
+				/*lint -fallthrough */
+
+			case AML_INT_EVAL_SUBTREE_OP:
+
+				status = acpi_ds_eval_data_object_operands (walk_state, op,
+						  acpi_ns_get_attached_object (op->common.parent->common.node));
+				break;
+
+			default:
+
+				status = acpi_ds_eval_data_object_operands (walk_state, op, NULL);
+				break;
+			}
+
+			/*
+			 * If a result object was returned from above, push it on the
+			 * current result stack
+			 */
+			if (ACPI_SUCCESS (status) &&
+				walk_state->result_obj) {
+				status = acpi_ds_result_push (walk_state->result_obj, walk_state);
+			}
+			break;
+
+
 		case AML_TYPE_NAMED_FIELD:
 		case AML_TYPE_NAMED_COMPLEX:
 		case AML_TYPE_NAMED_SIMPLE:
+		case AML_TYPE_NAMED_NO_OBJ:
 
 			status = acpi_ds_load2_end_op (walk_state);
 			if (ACPI_FAILURE (status)) {
 				break;
 			}
 
-			if (op->opcode == AML_REGION_OP) {
+			if (op->common.aml_opcode == AML_REGION_OP) {
 				ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
-					"Executing Op_region Address/Length Op=%p\n", op));
+					"Executing op_region Address/Length Op=%p\n", op));
 
 				status = acpi_ds_eval_region_operands (walk_state, op);
 				if (ACPI_FAILURE (status)) {
@@ -539,23 +588,26 @@
 
 			break;
 
+
 		case AML_TYPE_UNDEFINED:
 
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Undefined opcode type Op=%p\n", op));
 			return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
-			break;
 
 
 		case AML_TYPE_BOGUS:
-			ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Internal opcode=%X type Op=%p\n",
+
+			ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+				"Internal opcode=%X type Op=%p\n",
 				walk_state->opcode, op));
 			break;
 
+
 		default:
 
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 				"Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p\n",
-				op_class, op_type, op->opcode, op));
+				op_class, op_type, op->common.aml_opcode, op));
 
 			status = AE_NOT_IMPLEMENTED;
 			break;
@@ -563,10 +615,10 @@
 	}
 
 	/*
-	 * ACPI 2.0 support for 64-bit integers:
-	 * Truncate numeric result value if we are executing from a 32-bit ACPI table
+	 * ACPI 2.0 support for 64-bit integers: Truncate numeric
+	 * result value if we are executing from a 32-bit ACPI table
 	 */
-	acpi_ex_truncate_for32bit_table (walk_state->result_obj, walk_state);
+	acpi_ex_truncate_for32bit_table (walk_state->result_obj);
 
 	/*
 	 * Check if we just completed the evaluation of a
@@ -575,9 +627,9 @@
 
 	if ((walk_state->control_state) &&
 		(walk_state->control_state->common.state ==
-			CONTROL_PREDICATE_EXECUTING) &&
+			ACPI_CONTROL_PREDICATE_EXECUTING) &&
 		(walk_state->control_state->control.predicate_op == op)) {
-		status = acpi_ds_get_predicate_value (walk_state, !! walk_state->result_obj);
+		status = acpi_ds_get_predicate_value (walk_state, walk_state->result_obj);
 		walk_state->result_obj = NULL;
 	}
 
@@ -586,7 +638,7 @@
 	if (walk_state->result_obj) {
 		/* Break to debugger to display result */
 
-		DEBUGGER_EXEC (acpi_db_display_result_object (walk_state->result_obj, walk_state));
+		ACPI_DEBUGGER_EXEC (acpi_db_display_result_object (walk_state->result_obj, walk_state));
 
 		/*
 		 * Delete the result op if and only if:
@@ -596,12 +648,26 @@
 		acpi_ds_delete_result_if_not_used (op, walk_state->result_obj, walk_state);
 	}
 
+#ifdef _UNDER_DEVELOPMENT
+
+	if (walk_state->parser_state.aml == walk_state->parser_state.aml_end) {
+		acpi_db_method_end (walk_state);
+	}
+#endif
+
 	/* Always clear the object stack */
 
-	/* TBD: [Investigate] Clear stack of return value,
-	but don't delete it */
 	walk_state->num_operands = 0;
 
+#ifdef ACPI_DISASSEMBLER
+
+	/* On error, display method locals/args */
+
+	if (ACPI_FAILURE (status)) {
+		acpi_dm_dump_method_info (status, walk_state, op);
+	}
+#endif
+
 	return_ACPI_STATUS (status);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/dispatcher/dswload.c linux-2.4.22-pre2/drivers/acpi/dispatcher/dswload.c
--- linux-2.4.21/drivers/acpi/dispatcher/dswload.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/dispatcher/dswload.c	2003-06-26 21:43:11.000000000 +0000
@@ -1,48 +1,66 @@
 /******************************************************************************
  *
  * Module Name: dswload - Dispatcher namespace load callbacks
- *              $Revision: 50 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "amlcode.h"
-#include "acdispat.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "acevents.h"
+#include <acpi/acpi.h>
+#include <acpi/acparser.h>
+#include <acpi/amlcode.h>
+#include <acpi/acdispat.h>
+#include <acpi/acinterp.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acevents.h>
 
 
 #define _COMPONENT          ACPI_DISPATCHER
-	 MODULE_NAME         ("dswload")
+	 ACPI_MODULE_NAME    ("dswload")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_init_callbacks
+ * FUNCTION:    acpi_ds_init_callbacks
  *
- * PARAMETERS:  Walk_state      - Current state of the parse tree walk
- *              Pass_number     - 1, 2, or 3
+ * PARAMETERS:  walk_state      - Current state of the parse tree walk
+ *              pass_number     - 1, 2, or 3
  *
  * RETURN:      Status
  *
@@ -52,8 +70,8 @@
 
 acpi_status
 acpi_ds_init_callbacks (
-	acpi_walk_state         *walk_state,
-	u32                     pass_number)
+	struct acpi_walk_state          *walk_state,
+	u32                             pass_number)
 {
 
 	switch (pass_number) {
@@ -70,14 +88,15 @@
 		break;
 
 	case 3:
+#ifndef ACPI_NO_METHOD_EXECUTION
 		walk_state->parse_flags      |= ACPI_PARSE_EXECUTE  | ACPI_PARSE_DELETE_TREE;
 		walk_state->descending_callback = acpi_ds_exec_begin_op;
 		walk_state->ascending_callback = acpi_ds_exec_end_op;
+#endif
 		break;
 
 	default:
 		return (AE_BAD_PARAMETER);
-		break;
 	}
 
 	return (AE_OK);
@@ -86,9 +105,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_load1_begin_op
+ * FUNCTION:    acpi_ds_load1_begin_op
  *
- * PARAMETERS:  Walk_state      - Current state of the parse tree walk
+ * PARAMETERS:  walk_state      - Current state of the parse tree walk
  *              Op              - Op that has been just been reached in the
  *                                walk;  Arguments have not been evaluated yet.
  *
@@ -100,33 +119,42 @@
 
 acpi_status
 acpi_ds_load1_begin_op (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       **out_op)
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         **out_op)
 {
-	acpi_parse_object       *op;
-	acpi_namespace_node     *node;
-	acpi_status             status;
-	acpi_object_type8       data_type;
-	NATIVE_CHAR             *path;
+	union acpi_parse_object         *op;
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
+	acpi_object_type                object_type;
+	char                            *path;
+	u32                             flags;
+
 
+	ACPI_FUNCTION_NAME ("ds_load1_begin_op");
 
-	PROC_NAME ("Ds_load1_begin_op");
 
 	op = walk_state->op;
 	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state));
 
-
 	/* We are only interested in opcodes that have an associated name */
 
-	if (walk_state->op) {
-	   if (!(walk_state->op_info->flags & AML_NAMED)) {
+	if (op) {
+		if (!(walk_state->op_info->flags & AML_NAMED)) {
+#if 0
+			if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
+				(walk_state->op_info->class == AML_CLASS_CONTROL)) {
+				acpi_os_printf ("\n\n***EXECUTABLE OPCODE %s***\n\n", walk_state->op_info->name);
+				*out_op = op;
+				return (AE_CTRL_SKIP);
+			}
+#endif
 			*out_op = op;
 			return (AE_OK);
 		}
 
 		/* Check if this object has already been installed in the namespace */
 
-		if (op->node) {
+		if (op->common.node) {
 			*out_op = op;
 			return (AE_OK);
 		}
@@ -136,30 +164,117 @@
 
 	/* Map the raw opcode into an internal object type */
 
-	data_type = acpi_ds_map_named_opcode_to_data_type (walk_state->opcode);
-
+	object_type = walk_state->op_info->object_type;
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-		"State=%p Op=%p Type=%x\n", walk_state, op, data_type));
+		"State=%p Op=%p [%s] ", walk_state, op, acpi_ut_get_type_name (object_type)));
 
+	switch (walk_state->opcode) {
+	case AML_SCOPE_OP:
 
-	if (walk_state->opcode == AML_SCOPE_OP) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-			"State=%p Op=%p Type=%x\n", walk_state, op, data_type));
-	}
+		/*
+		 * The target name of the Scope() operator must exist at this point so
+		 * that we can actually open the scope to enter new names underneath it.
+		 * Allow search-to-root for single namesegs.
+		 */
+		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)) {
+			ACPI_REPORT_NSERROR (path, status);
+			return (status);
+		}
 
-	/*
-	 * Enter the named type into the internal namespace.  We enter the name
-	 * as we go downward in the parse tree.  Any necessary subobjects that involve
-	 * arguments to the opcode must be created as we go back up the parse tree later.
-	 */
-	status = acpi_ns_lookup (walk_state->scope_info, path, data_type,
-			  IMODE_LOAD_PASS1, NS_NO_UPSEARCH, walk_state, &(node));
+		/*
+		 * Check to make sure that the target is
+		 * one of the opcodes that actually opens a scope
+		 */
+		switch (node->type) {
+		case ACPI_TYPE_LOCAL_SCOPE:         /* Scope  */
+		case ACPI_TYPE_DEVICE:
+		case ACPI_TYPE_POWER:
+		case ACPI_TYPE_PROCESSOR:
+		case ACPI_TYPE_THERMAL:
+
+			/* These are acceptable types */
+			break;
 
-	if (ACPI_FAILURE (status)) {
-		return (status);
+		case ACPI_TYPE_INTEGER:
+		case ACPI_TYPE_STRING:
+		case ACPI_TYPE_BUFFER:
+
+			/*
+			 * These types we will allow, but we will change the type.  This
+			 * enables some existing code of the form:
+			 *
+			 *  Name (DEB, 0)
+			 *  Scope (DEB) { ... }
+			 *
+			 * Note: silently change the type here.  On the second pass, we will report a warning
+			 */
+
+			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
+				path, acpi_ut_get_type_name (node->type)));
+
+			node->type = ACPI_TYPE_ANY;
+			walk_state->scope_info->common.value = ACPI_TYPE_ANY;
+			break;
+
+		default:
+
+			/* All other types are an error */
+
+			ACPI_REPORT_ERROR (("Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n",
+				acpi_ut_get_type_name (node->type), path));
+
+			return (AE_AML_OPERAND_TYPE);
+		}
+		break;
+
+
+	default:
+
+		/*
+		 * For all other named opcodes, we will enter the name into the namespace.
+		 *
+		 * Setup the search flags.
+		 * Since we are entering a name into the namespace, we do not want to
+		 * enable the search-to-root upsearch.
+		 *
+		 * There are only two conditions where it is acceptable that the name
+		 * already exists:
+		 *    1) the Scope() operator can reopen a scoping object that was
+		 *       previously defined (Scope, Method, Device, etc.)
+		 *    2) Whenever we are parsing a deferred opcode (op_region, Buffer,
+		 *       buffer_field, or Package), the name of the object is already
+		 *       in the namespace.
+		 */
+		flags = ACPI_NS_NO_UPSEARCH;
+		if ((walk_state->opcode != AML_SCOPE_OP) &&
+			(!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) {
+			flags |= ACPI_NS_ERROR_IF_FOUND;
+			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DISPATCH, "Cannot already exist\n"));
+		}
+		else {
+			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DISPATCH, "Both Find or Create allowed\n"));
+		}
+
+		/*
+		 * Enter the named type into the internal namespace.  We enter the name
+		 * as we go downward in the parse tree.  Any necessary subobjects that involve
+		 * arguments to the opcode must be created as we go back up the parse tree later.
+		 */
+		status = acpi_ns_lookup (walk_state->scope_info, path, object_type,
+				  ACPI_IMODE_LOAD_PASS1, flags, walk_state, &(node));
+		if (ACPI_FAILURE (status)) {
+			ACPI_REPORT_NSERROR (path, status);
+			return (status);
+		}
+		break;
 	}
 
+
+	/* Common exit */
+
 	if (!op) {
 		/* Create a new op */
 
@@ -171,13 +286,18 @@
 
 	/* Initialize */
 
-	((acpi_parse2_object *)op)->name = node->name;
+	op->named.name = node->name.integer;
+
+#if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY))
+	op->named.path = (u8 *) path;
+#endif
+
 
 	/*
 	 * Put the Node in the "op" object that the parser uses, so we
 	 * can get it again quickly when this scope is closed
 	 */
-	op->node = node;
+	op->common.node = node;
 	acpi_ps_append_arg (acpi_ps_get_parent_scope (&walk_state->parser_state), op);
 
 	*out_op = op;
@@ -187,9 +307,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_load1_end_op
+ * FUNCTION:    acpi_ds_load1_end_op
  *
- * PARAMETERS:  Walk_state      - Current state of the parse tree walk
+ * PARAMETERS:  walk_state      - Current state of the parse tree walk
  *              Op              - Op that has been just been completed in the
  *                                walk;  Arguments have now been evaluated.
  *
@@ -202,57 +322,107 @@
 
 acpi_status
 acpi_ds_load1_end_op (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_parse_object       *op;
-	acpi_object_type8       data_type;
+	union acpi_parse_object         *op;
+	acpi_object_type                object_type;
+	acpi_status                     status = AE_OK;
+
 
+	ACPI_FUNCTION_NAME ("ds_load1_end_op");
 
-	PROC_NAME ("Ds_load1_end_op");
 
 	op = walk_state->op;
 	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state));
 
-
 	/* We are only interested in opcodes that have an associated name */
 
-	if (!(walk_state->op_info->flags & AML_NAMED)) {
+	if (!(walk_state->op_info->flags & (AML_NAMED | AML_FIELD))) {
 		return (AE_OK);
 	}
 
-	/* Get the type to determine if we should pop the scope */
+	/* Get the object type to determine if we should pop the scope */
 
-	data_type = acpi_ds_map_named_opcode_to_data_type (op->opcode);
+	object_type = walk_state->op_info->object_type;
 
-	if (op->opcode == AML_NAME_OP) {
-		/* For Name opcode, check the argument */
+#ifndef ACPI_NO_METHOD_EXECUTION
+	if (walk_state->op_info->flags & AML_FIELD) {
+		if (walk_state->opcode == AML_FIELD_OP         ||
+			walk_state->opcode == AML_BANK_FIELD_OP    ||
+			walk_state->opcode == AML_INDEX_FIELD_OP) {
+			status = acpi_ds_init_field_objects (op, walk_state);
+		}
+		return (status);
+	}
 
-		if (op->value.arg) {
-			data_type = acpi_ds_map_opcode_to_data_type (
-					  (op->value.arg)->opcode, NULL);
-			((acpi_namespace_node *)op->node)->type =
-					  (u8) data_type;
+
+	if (op->common.aml_opcode == AML_REGION_OP) {
+		status = acpi_ex_create_region (op->named.data, op->named.length,
+				   (acpi_adr_space_type) ((op->common.value.arg)->common.value.integer), walk_state);
+		if (ACPI_FAILURE (status)) {
+			return (status);
+		}
+	}
+#endif
+
+	if (op->common.aml_opcode == AML_NAME_OP) {
+		/* For Name opcode, get the object type from the argument */
+
+		if (op->common.value.arg) {
+			object_type = (acpi_ps_get_opcode_info ((op->common.value.arg)->common.aml_opcode))->object_type;
+			op->common.node->type = (u8) object_type;
+		}
+	}
+
+	if (op->common.aml_opcode == AML_METHOD_OP) {
+		/*
+		 * method_op pkg_length name_string method_flags term_list
+		 *
+		 * Note: We must create the method node/object pair as soon as we
+		 * see the method declaration.  This allows later pass1 parsing
+		 * of invocations of the method (need to know the number of
+		 * arguments.)
+		 */
+		ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+			"LOADING-Method: State=%p Op=%p named_obj=%p\n",
+			walk_state, op, op->named.node));
+
+		if (!acpi_ns_get_attached_object (op->named.node)) {
+			walk_state->operands[0] = (void *) op->named.node;
+			walk_state->num_operands = 1;
+
+			status = acpi_ds_create_operands (walk_state, op->common.value.arg);
+			if (ACPI_SUCCESS (status)) {
+				status = acpi_ex_create_method (op->named.data,
+						   op->named.length, walk_state);
+			}
+			walk_state->operands[0] = NULL;
+			walk_state->num_operands = 0;
+
+			if (ACPI_FAILURE (status)) {
+				return (status);
+			}
 		}
 	}
 
 	/* Pop the scope stack */
 
-	if (acpi_ns_opens_scope (data_type)) {
+	if (acpi_ns_opens_scope (object_type)) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n",
-			acpi_ut_get_type_name (data_type), op));
+			acpi_ut_get_type_name (object_type), op));
 
-		acpi_ds_scope_stack_pop (walk_state);
+		status = acpi_ds_scope_stack_pop (walk_state);
 	}
 
-	return (AE_OK);
+	return (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_load2_begin_op
+ * FUNCTION:    acpi_ds_load2_begin_op
  *
- * PARAMETERS:  Walk_state      - Current state of the parse tree walk
+ * PARAMETERS:  walk_state      - Current state of the parse tree walk
  *              Op              - Op that has been just been reached in the
  *                                walk;  Arguments have not been evaluated yet.
  *
@@ -264,35 +434,28 @@
 
 acpi_status
 acpi_ds_load2_begin_op (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       **out_op)
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         **out_op)
 {
-	acpi_parse_object       *op;
-	acpi_namespace_node     *node;
-	acpi_status             status;
-	acpi_object_type8       data_type;
-	NATIVE_CHAR             *buffer_ptr;
-	void                    *original = NULL;
+	union acpi_parse_object         *op;
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
+	acpi_object_type                object_type;
+	char                            *buffer_ptr;
 
 
-	PROC_NAME ("Ds_load2_begin_op");
+	ACPI_FUNCTION_TRACE ("ds_load2_begin_op");
+
 
 	op = walk_state->op;
 	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state));
 
-
 	if (op) {
 		/* We only care about Namespace opcodes here */
 
-		if (!(walk_state->op_info->flags & AML_NSOPCODE) &&
-			walk_state->opcode != AML_INT_NAMEPATH_OP) {
-			return (AE_OK);
-		}
-
-		/* TBD: [Restructure] Temp! same code as in psparse */
-
-		if (!(walk_state->op_info->flags & AML_NAMED)) {
-			return (AE_OK);
+		if ((!(walk_state->op_info->flags & AML_NSOPCODE) && (walk_state->opcode != AML_INT_NAMEPATH_OP)) ||
+			(!(walk_state->op_info->flags & AML_NAMED))) {
+			return_ACPI_STATUS (AE_OK);
 		}
 
 		/*
@@ -301,61 +464,125 @@
 		if (walk_state->opcode == AML_INT_NAMEPATH_OP) {
 			/* For Namepath op, get the path string */
 
-			buffer_ptr = op->value.string;
+			buffer_ptr = op->common.value.string;
 			if (!buffer_ptr) {
 				/* No name, just exit */
 
-				return (AE_OK);
+				return_ACPI_STATUS (AE_OK);
 			}
 		}
 		else {
 			/* Get name from the op */
 
-			buffer_ptr = (NATIVE_CHAR *) &((acpi_parse2_object *)op)->name;
+			buffer_ptr = (char *) &op->named.name;
 		}
 	}
 	else {
+		/* Get the namestring from the raw AML */
+
 		buffer_ptr = acpi_ps_get_next_namestring (&walk_state->parser_state);
 	}
 
+	/* Map the opcode into an internal object type */
 
-	/* Map the raw opcode into an internal object type */
-
-	data_type = acpi_ds_map_named_opcode_to_data_type (walk_state->opcode);
+	object_type = walk_state->op_info->object_type;
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-		"State=%p Op=%p Type=%x\n", walk_state, op, data_type));
+		"State=%p Op=%p Type=%X\n", walk_state, op, object_type));
+
 
+	switch (walk_state->opcode) {
+	case AML_FIELD_OP:
+	case AML_BANK_FIELD_OP:
+	case AML_INDEX_FIELD_OP:
 
-	if (walk_state->opcode == AML_FIELD_OP         ||
-		walk_state->opcode == AML_BANK_FIELD_OP    ||
-		walk_state->opcode == AML_INDEX_FIELD_OP) {
 		node = NULL;
 		status = AE_OK;
-	}
+		break;
+
+	case AML_INT_NAMEPATH_OP:
 
-	else if (walk_state->opcode == AML_INT_NAMEPATH_OP) {
 		/*
-		 * The Name_path is an object reference to an existing object. Don't enter the
+		 * The name_path is an object reference to an existing object. Don't enter the
 		 * name into the namespace, but look it up for use later
 		 */
-		status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, data_type,
-				  IMODE_EXECUTE, NS_SEARCH_PARENT, walk_state, &(node));
-	}
+		status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type,
+				  ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node));
+		break;
 
-	else {
-		if (op && op->node) {
-			original = op->node;
-			node = op->node;
+	case AML_SCOPE_OP:
 
-			if (acpi_ns_opens_scope (data_type)) {
-				status = acpi_ds_scope_stack_push (node, data_type, walk_state);
+		/*
+		 * The Path is an object reference to an existing object.  Don't enter the
+		 * name into the namespace, but look it up for use later
+		 */
+		status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type,
+				  ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node));
+		if (ACPI_FAILURE (status)) {
+			ACPI_REPORT_NSERROR (buffer_ptr, status);
+			return_ACPI_STATUS (status);
+		}
+		/*
+		 * We must check to make sure that the target is
+		 * one of the opcodes that actually opens a scope
+		 */
+		switch (node->type) {
+		case ACPI_TYPE_LOCAL_SCOPE:         /* Scope */
+		case ACPI_TYPE_DEVICE:
+		case ACPI_TYPE_POWER:
+		case ACPI_TYPE_PROCESSOR:
+		case ACPI_TYPE_THERMAL:
+
+			/* These are acceptable types */
+			break;
+
+		case ACPI_TYPE_INTEGER:
+		case ACPI_TYPE_STRING:
+		case ACPI_TYPE_BUFFER:
+
+			/*
+			 * These types we will allow, but we will change the type.  This
+			 * enables some existing code of the form:
+			 *
+			 *  Name (DEB, 0)
+			 *  Scope (DEB) { ... }
+			 */
+
+			ACPI_REPORT_WARNING (("Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
+				buffer_ptr, acpi_ut_get_type_name (node->type)));
+
+			node->type = ACPI_TYPE_ANY;
+			walk_state->scope_info->common.value = ACPI_TYPE_ANY;
+			break;
+
+		default:
+
+			/* All other types are an error */
+
+			ACPI_REPORT_ERROR (("Invalid type (%s) for target of Scope operator [%4.4s]\n",
+				acpi_ut_get_type_name (node->type), buffer_ptr));
+
+			return (AE_AML_OPERAND_TYPE);
+		}
+		break;
+
+	default:
+
+		/* All other opcodes */
+
+		if (op && op->common.node) {
+			/* This op/node was previously entered into the namespace */
+
+			node = op->common.node;
+
+			if (acpi_ns_opens_scope (object_type)) {
+				status = acpi_ds_scope_stack_push (node, object_type, walk_state);
 				if (ACPI_FAILURE (status)) {
-					return (status);
+					return_ACPI_STATUS (status);
 				}
 
 			}
-			return (AE_OK);
+			return_ACPI_STATUS (AE_OK);
 		}
 
 		/*
@@ -363,50 +590,50 @@
 		 * as we go downward in the parse tree.  Any necessary subobjects that involve
 		 * arguments to the opcode must be created as we go back up the parse tree later.
 		 */
-		status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, data_type,
-				  IMODE_EXECUTE, NS_NO_UPSEARCH, walk_state, &(node));
+		status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type,
+				  ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, walk_state, &(node));
+		break;
 	}
 
-	if (ACPI_SUCCESS (status)) {
-		if (!op) {
-			/* Create a new op */
+	if (ACPI_FAILURE (status)) {
+		ACPI_REPORT_NSERROR (buffer_ptr, status);
+		return_ACPI_STATUS (status);
+	}
 
-			op = acpi_ps_alloc_op (walk_state->opcode);
-			if (!op) {
-				return (AE_NO_MEMORY);
-			}
 
-			/* Initialize */
+	if (!op) {
+		/* Create a new op */
 
-			((acpi_parse2_object *)op)->name = node->name;
-			*out_op = op;
+		op = acpi_ps_alloc_op (walk_state->opcode);
+		if (!op) {
+			return_ACPI_STATUS (AE_NO_MEMORY);
 		}
 
-		/*
-		 * Put the Node in the "op" object that the parser uses, so we
-		 * can get it again quickly when this scope is closed
-		 */
-		op->node = node;
-
-		if (original) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "old %p new %p\n", original, node));
+		/* Initialize the new op */
 
-			if (original != node) {
-				ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-					"Lookup match error: old %p new %p\n", original, node));
-			}
+		if (node) {
+			op->named.name = node->name.integer;
+		}
+		if (out_op) {
+			*out_op = op;
 		}
 	}
 
-	return (status);
+	/*
+	 * Put the Node in the "op" object that the parser uses, so we
+	 * can get it again quickly when this scope is closed
+	 */
+	op->common.node = node;
+
+	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_load2_end_op
+ * FUNCTION:    acpi_ds_load2_end_op
  *
- * PARAMETERS:  Walk_state      - Current state of the parse tree walk
+ * PARAMETERS:  walk_state      - Current state of the parse tree walk
  *              Op              - Op that has been just been completed in the
  *                                walk;  Arguments have now been evaluated.
  *
@@ -419,48 +646,44 @@
 
 acpi_status
 acpi_ds_load2_end_op (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_parse_object       *op;
-	acpi_status             status = AE_OK;
-	acpi_object_type8       data_type;
-	acpi_namespace_node     *node;
-	acpi_parse_object       *arg;
-	acpi_namespace_node     *new_node;
-	u32                     i;
+	union acpi_parse_object         *op;
+	acpi_status                     status = AE_OK;
+	acpi_object_type                object_type;
+	struct acpi_namespace_node      *node;
+	union acpi_parse_object         *arg;
+	struct acpi_namespace_node      *new_node;
+#ifndef ACPI_NO_METHOD_EXECUTION
+	u32                             i;
+#endif
 
 
-	PROC_NAME ("Ds_load2_end_op");
+	ACPI_FUNCTION_TRACE ("ds_load2_end_op");
 
 	op = walk_state->op;
-	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state));
-
+	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
+			walk_state->op_info->name, op, walk_state));
 
 	/* Only interested in opcodes that have namespace objects */
 
 	if (!(walk_state->op_info->flags & AML_NSOBJECT)) {
-		return (AE_OK);
+		return_ACPI_STATUS (AE_OK);
 	}
 
-	if (op->opcode == AML_SCOPE_OP) {
+	if (op->common.aml_opcode == AML_SCOPE_OP) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
 			"Ending scope Op=%p State=%p\n", op, walk_state));
-
-		if (((acpi_parse2_object *)op)->name == -1) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unnamed scope! Op=%p State=%p\n",
-				op, walk_state));
-			return (AE_OK);
-		}
 	}
 
 
-	data_type = acpi_ds_map_named_opcode_to_data_type (op->opcode);
+	object_type = walk_state->op_info->object_type;
 
 	/*
 	 * Get the Node/name from the earlier lookup
 	 * (It was saved in the *op structure)
 	 */
-	node = op->node;
+	node = op->common.node;
 
 	/*
 	 * Put the Node on the object stack (Contains the ACPI Name of
@@ -471,11 +694,14 @@
 
 	/* Pop the scope stack */
 
-	if (acpi_ns_opens_scope (data_type)) {
-
+	if (acpi_ns_opens_scope (object_type) && (op->common.aml_opcode != AML_INT_METHODCALL_OP)) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
-			acpi_ut_get_type_name (data_type), op));
-		acpi_ds_scope_stack_pop (walk_state);
+			acpi_ut_get_type_name (object_type), op));
+
+		status = acpi_ds_scope_stack_pop (walk_state);
+		if (ACPI_FAILURE (status)) {
+			goto cleanup;
+		}
 	}
 
 	/*
@@ -507,14 +733,16 @@
 	 */
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-		"Create-Load [%s] State=%p Op=%p Named_obj=%p\n",
-		acpi_ps_get_opcode_name (op->opcode), walk_state, op, node));
+		"Create-Load [%s] State=%p Op=%p named_obj=%p\n",
+		acpi_ps_get_opcode_name (op->common.aml_opcode), walk_state, op, node));
 
 	/* Decode the opcode */
 
-	arg = op->value.arg;
+	arg = op->common.value.arg;
 
 	switch (walk_state->op_info->type) {
+#ifndef ACPI_NO_METHOD_EXECUTION
+
 	case AML_TYPE_CREATE_FIELD:
 
 		/*
@@ -527,24 +755,25 @@
 
 	 case AML_TYPE_NAMED_FIELD:
 
-		arg = op->value.arg;
-		switch (op->opcode) {
+		switch (op->common.aml_opcode) {
 		case AML_INDEX_FIELD_OP:
 
-			status = acpi_ds_create_index_field (op, (acpi_handle) arg->node,
+			status = acpi_ds_create_index_field (op, (acpi_handle) arg->common.node,
 					   walk_state);
 			break;
 
-
 		case AML_BANK_FIELD_OP:
 
-			status = acpi_ds_create_bank_field (op, arg->node, walk_state);
+			status = acpi_ds_create_bank_field (op, arg->common.node, walk_state);
 			break;
 
-
 		case AML_FIELD_OP:
 
-			status = acpi_ds_create_field (op, arg->node, walk_state);
+			status = acpi_ds_create_field (op, arg->common.node, walk_state);
+			break;
+
+		default:
+			/* All NAMED_FIELD opcodes must be handled above */
 			break;
 		}
 		break;
@@ -557,31 +786,27 @@
 			goto cleanup;
 		}
 
-		switch (op->opcode) {
+		switch (op->common.aml_opcode) {
 		case AML_PROCESSOR_OP:
 
 			status = acpi_ex_create_processor (walk_state);
 			break;
 
-
 		case AML_POWER_RES_OP:
 
 			status = acpi_ex_create_power_resource (walk_state);
 			break;
 
-
 		case AML_MUTEX_OP:
 
 			status = acpi_ex_create_mutex (walk_state);
 			break;
 
-
 		case AML_EVENT_OP:
 
 			status = acpi_ex_create_event (walk_state);
 			break;
 
-
 		case AML_DATA_REGION_OP:
 
 			status = acpi_ex_create_table_region (walk_state);
@@ -597,7 +822,6 @@
 
 			status = AE_OK;
 			goto cleanup;
-			break;
 		}
 
 		/* Delete operands */
@@ -608,40 +832,32 @@
 		}
 
 		break;
-
+#endif /* ACPI_NO_METHOD_EXECUTION */
 
 	case AML_TYPE_NAMED_COMPLEX:
 
-		switch (op->opcode) {
-		case AML_METHOD_OP:
-			/*
-			 * Method_op Pkg_length Names_string Method_flags Term_list
-			 */
-			ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-				"LOADING-Method: State=%p Op=%p Named_obj=%p\n",
-				walk_state, op, node));
-
-			if (!node->object) {
-				status = acpi_ds_create_operands (walk_state, arg);
-				if (ACPI_FAILURE (status)) {
-					goto cleanup;
-				}
-
-				status = acpi_ex_create_method (((acpi_parse2_object *) op)->data,
-						   ((acpi_parse2_object *) op)->length,
-						   walk_state);
-			}
-			break;
-
-
+		switch (op->common.aml_opcode) {
+#ifndef ACPI_NO_METHOD_EXECUTION
 		case AML_REGION_OP:
 			/*
-			 * The Op_region is not fully parsed at this time. Only valid argument is the Space_id.
+			 * The op_region is not fully parsed at this time. Only valid argument is the space_id.
 			 * (We must save the address of the AML of the address and length operands)
 			 */
-			status = acpi_ex_create_region (((acpi_parse2_object *) op)->data,
-					  ((acpi_parse2_object *) op)->length,
-							 (ACPI_ADR_SPACE_TYPE) arg->value.integer, walk_state);
+			/*
+			 * If we have a valid region, initialize it
+			 * Namespace is NOT locked at this point.
+			 */
+			status = acpi_ev_initialize_region (acpi_ns_get_attached_object (node), FALSE);
+			if (ACPI_FAILURE (status)) {
+				/*
+				 *  If AE_NOT_EXIST is returned, it is not fatal
+				 *  because many regions get created before a handler
+				 *  is installed for said region.
+				 */
+				if (AE_NOT_EXIST == status) {
+					status = AE_OK;
+				}
+			}
 			break;
 
 
@@ -649,6 +865,13 @@
 
 			status = acpi_ds_create_node (walk_state, node, op);
 			break;
+#endif /* ACPI_NO_METHOD_EXECUTION */
+
+
+		default:
+			/* All NAMED_COMPLEX opcodes must be handled above */
+			/* Note: Method objects were already created in Pass 1 */
+			break;
 		}
 		break;
 
@@ -662,29 +885,34 @@
 	case AML_CLASS_METHOD_CALL:
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-			"RESOLVING-Method_call: State=%p Op=%p Named_obj=%p\n",
+			"RESOLVING-method_call: State=%p Op=%p named_obj=%p\n",
 			walk_state, op, node));
 
 		/*
 		 * Lookup the method name and save the Node
 		 */
-		status = acpi_ns_lookup (walk_state->scope_info, arg->value.string,
-				  ACPI_TYPE_ANY, IMODE_LOAD_PASS2,
-				  NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE,
+		status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string,
+				  ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2,
+				  ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
 				  walk_state, &(new_node));
 		if (ACPI_SUCCESS (status)) {
-			/* TBD: has name already been resolved by here ??*/
-
-			/* TBD: [Restructure] Make sure that what we found is indeed a method! */
-			/* We didn't search for a method on purpose, to see if the name would resolve! */
+			/*
+			 * Make sure that what we found is indeed a method
+			 * We didn't search for a method on purpose, to see if the name would resolve
+			 */
+			if (new_node->type != ACPI_TYPE_METHOD) {
+				status = AE_AML_OPERAND_TYPE;
+			}
 
 			/* We could put the returned object (Node) on the object stack for later, but
 			 * for now, we will put it in the "op" object that the parser uses, so we
 			 * can get it again at the end of this scope
 			 */
-			op->node = new_node;
+			op->common.node = new_node;
+		}
+		else {
+			ACPI_REPORT_NSERROR (arg->common.value.string, status);
 		}
-
 		break;
 
 
@@ -692,14 +920,13 @@
 		break;
 	}
 
-
 cleanup:
 
 	/* Remove the Node pushed at the very beginning */
 
 	walk_state->operands[0] = NULL;
 	walk_state->num_operands = 0;
-	return (status);
+	return_ACPI_STATUS (status);
 }
 
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/dispatcher/dswscope.c linux-2.4.22-pre2/drivers/acpi/dispatcher/dswscope.c
--- linux-2.4.21/drivers/acpi/dispatcher/dswscope.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/dispatcher/dswscope.c	2003-06-26 21:43:33.000000000 +0000
@@ -1,36 +1,53 @@
 /******************************************************************************
  *
  * Module Name: dswscope - Scope stack manipulation
- *              $Revision: 49 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acinterp.h"
-#include "acdispat.h"
+#include <acpi/acpi.h>
+#include <acpi/acdispat.h>
 
 
 #define _COMPONENT          ACPI_DISPATCHER
-	 MODULE_NAME         ("dswscope")
+	 ACPI_MODULE_NAME    ("dswscope")
 
 
 #define STACK_POP(head) head
@@ -38,7 +55,7 @@
 
 /****************************************************************************
  *
- * FUNCTION:    Acpi_ds_scope_stack_clear
+ * FUNCTION:    acpi_ds_scope_stack_clear
  *
  * PARAMETERS:  None
  *
@@ -49,11 +66,11 @@
 
 void
 acpi_ds_scope_stack_clear (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_generic_state      *scope_info;
+	union acpi_generic_state        *scope_info;
 
-	PROC_NAME ("Ds_scope_stack_clear");
+	ACPI_FUNCTION_NAME ("ds_scope_stack_clear");
 
 
 	while (walk_state->scope_info) {
@@ -63,7 +80,7 @@
 		walk_state->scope_info = scope_info->scope.next;
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
-			"Popped object type %X\n", scope_info->common.value));
+			"Popped object type (%s)\n", acpi_ut_get_type_name (scope_info->common.value)));
 		acpi_ut_delete_generic_state (scope_info);
 	}
 }
@@ -71,7 +88,7 @@
 
 /****************************************************************************
  *
- * FUNCTION:    Acpi_ds_scope_stack_push
+ * FUNCTION:    acpi_ds_scope_stack_push
  *
  * PARAMETERS:  *Node,              - Name to be made current
  *              Type,               - Type of frame being pushed
@@ -83,27 +100,28 @@
 
 acpi_status
 acpi_ds_scope_stack_push (
-	acpi_namespace_node     *node,
-	acpi_object_type8       type,
-	acpi_walk_state         *walk_state)
+	struct acpi_namespace_node      *node,
+	acpi_object_type                type,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_generic_state      *scope_info;
+	union acpi_generic_state        *scope_info;
+	union acpi_generic_state        *old_scope_info;
 
 
-	FUNCTION_TRACE ("Ds_scope_stack_push");
+	ACPI_FUNCTION_TRACE ("ds_scope_stack_push");
 
 
 	if (!node) {
 		/* Invalid scope   */
 
-		REPORT_ERROR (("Ds_scope_stack_push: null scope passed\n"));
+		ACPI_REPORT_ERROR (("ds_scope_stack_push: null scope passed\n"));
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
 	/* Make sure object type is valid */
 
-	if (!acpi_ex_validate_object_type (type)) {
-		REPORT_WARNING (("Ds_scope_stack_push: type code out of range\n"));
+	if (!acpi_ut_valid_object_type (type)) {
+		ACPI_REPORT_WARNING (("ds_scope_stack_push: type code out of range\n"));
 	}
 
 
@@ -120,6 +138,28 @@
 	scope_info->scope.node      = node;
 	scope_info->common.value    = (u16) type;
 
+	walk_state->scope_depth++;
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+		"[%.2d] Pushed scope ", (u32) walk_state->scope_depth));
+
+	old_scope_info = walk_state->scope_info;
+	if (old_scope_info) {
+		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
+			"[%4.4s] (%10s)",
+			old_scope_info->scope.node->name.ascii,
+			acpi_ut_get_type_name (old_scope_info->common.value)));
+	}
+	else {
+		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
+			"[\\___] (%10s)", "ROOT"));
+	}
+
+	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
+		", New scope -> [%4.4s] (%s)\n",
+		scope_info->scope.node->name.ascii,
+		acpi_ut_get_type_name (scope_info->common.value)));
+
 	/* Push new scope object onto stack */
 
 	acpi_ut_push_generic_state (&walk_state->scope_info, scope_info);
@@ -130,7 +170,7 @@
 
 /****************************************************************************
  *
- * FUNCTION:    Acpi_ds_scope_stack_pop
+ * FUNCTION:    acpi_ds_scope_stack_pop
  *
  * PARAMETERS:  Type                - The type of frame to be found
  *
@@ -147,12 +187,13 @@
 
 acpi_status
 acpi_ds_scope_stack_pop (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_generic_state      *scope_info;
+	union acpi_generic_state        *scope_info;
+	union acpi_generic_state        *new_scope_info;
 
 
-	FUNCTION_TRACE ("Ds_scope_stack_pop");
+	ACPI_FUNCTION_TRACE ("ds_scope_stack_pop");
 
 
 	/*
@@ -163,8 +204,25 @@
 		return_ACPI_STATUS (AE_STACK_UNDERFLOW);
 	}
 
+	walk_state->scope_depth--;
+
 	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
-		"Popped object type %X\n", scope_info->common.value));
+		"[%.2d] Popped scope [%4.4s] (%10s), New scope -> ",
+		(u32) walk_state->scope_depth,
+		scope_info->scope.node->name.ascii,
+		acpi_ut_get_type_name (scope_info->common.value)));
+
+	new_scope_info = walk_state->scope_info;
+	if (new_scope_info) {
+		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
+			"[%4.4s] (%s)\n",
+			new_scope_info->scope.node->name.ascii,
+			acpi_ut_get_type_name (new_scope_info->common.value)));
+	}
+	else {
+		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
+			"[\\___] (ROOT)\n"));
+	}
 
 	acpi_ut_delete_generic_state (scope_info);
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/dispatcher/dswstate.c linux-2.4.22-pre2/drivers/acpi/dispatcher/dswstate.c
--- linux-2.4.21/drivers/acpi/dispatcher/dswstate.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/dispatcher/dswstate.c	2003-06-26 21:43:31.000000000 +0000
@@ -1,46 +1,62 @@
 /******************************************************************************
  *
  * Module Name: dswstate - Dispatcher parse tree walk management routines
- *              $Revision: 54 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "amlcode.h"
-#include "acparser.h"
-#include "acdispat.h"
-#include "acnamesp.h"
-#include "acinterp.h"
+#include <acpi/acpi.h>
+#include <acpi/acparser.h>
+#include <acpi/acdispat.h>
+#include <acpi/acnamesp.h>
 
 #define _COMPONENT          ACPI_DISPATCHER
-	 MODULE_NAME         ("dswstate")
+	 ACPI_MODULE_NAME    ("dswstate")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_result_insert
+ * FUNCTION:    acpi_ds_result_insert
  *
  * PARAMETERS:  Object              - Object to push
- *              Walk_state          - Current Walk state
+ *              walk_state          - Current Walk state
  *
  * RETURN:      Status
  *
@@ -50,14 +66,14 @@
 
 acpi_status
 acpi_ds_result_insert (
-	void                    *object,
-	u32                     index,
-	acpi_walk_state         *walk_state)
+	void                            *object,
+	u32                             index,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_generic_state      *state;
+	union acpi_generic_state        *state;
 
 
-	PROC_NAME ("Ds_result_insert");
+	ACPI_FUNCTION_NAME ("ds_result_insert");
 
 
 	state = walk_state->results;
@@ -67,7 +83,7 @@
 		return (AE_NOT_EXIST);
 	}
 
-	if (index >= OBJ_NUM_OPERANDS) {
+	if (index >= ACPI_OBJ_NUM_OPERANDS) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 			"Index out of range: %X Obj=%p State=%p Num=%X\n",
 			index, object, walk_state, state->results.num_results));
@@ -86,7 +102,7 @@
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
 		"Obj=%p [%s] State=%p Num=%X Cur=%X\n",
-		object, object ? acpi_ut_get_type_name (((acpi_operand_object *) object)->common.type) : "NULL",
+		object, object ? acpi_ut_get_object_type_name ((union acpi_operand_object *) object) : "NULL",
 		walk_state, state->results.num_results, walk_state->current_result));
 
 	return (AE_OK);
@@ -95,10 +111,10 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_result_remove
+ * FUNCTION:    acpi_ds_result_remove
  *
  * PARAMETERS:  Object              - Where to return the popped object
- *              Walk_state          - Current Walk state
+ *              walk_state          - Current Walk state
  *
  * RETURN:      Status
  *
@@ -109,14 +125,14 @@
 
 acpi_status
 acpi_ds_result_remove (
-	acpi_operand_object     **object,
-	u32                     index,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       **object,
+	u32                             index,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_generic_state      *state;
+	union acpi_generic_state        *state;
 
 
-	PROC_NAME ("Ds_result_remove");
+	ACPI_FUNCTION_NAME ("ds_result_remove");
 
 
 	state = walk_state->results;
@@ -126,13 +142,12 @@
 		return (AE_NOT_EXIST);
 	}
 
-	if (index >= OBJ_NUM_OPERANDS) {
+	if (index >= ACPI_OBJ_MAX_OPERAND) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 			"Index out of range: %X State=%p Num=%X\n",
 			index, walk_state, state->results.num_results));
 	}
 
-
 	/* Check for a valid result object */
 
 	if (!state->results.obj_desc [index]) {
@@ -151,7 +166,7 @@
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
 		"Obj=%p [%s] Index=%X State=%p Num=%X\n",
-		*object, (*object) ? acpi_ut_get_type_name ((*object)->common.type) : "NULL",
+		*object, (*object) ? acpi_ut_get_object_type_name (*object) : "NULL",
 		index, walk_state, state->results.num_results));
 
 	return (AE_OK);
@@ -160,10 +175,10 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_result_pop
+ * FUNCTION:    acpi_ds_result_pop
  *
  * PARAMETERS:  Object              - Where to return the popped object
- *              Walk_state          - Current Walk state
+ *              walk_state          - Current Walk state
  *
  * RETURN:      Status
  *
@@ -174,14 +189,14 @@
 
 acpi_status
 acpi_ds_result_pop (
-	acpi_operand_object     **object,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       **object,
+	struct acpi_walk_state          *walk_state)
 {
-	u32                     index;
-	acpi_generic_state      *state;
+	acpi_native_uint                index;
+	union acpi_generic_state        *state;
 
 
-	PROC_NAME ("Ds_result_pop");
+	ACPI_FUNCTION_NAME ("ds_result_pop");
 
 
 	state = walk_state->results;
@@ -199,7 +214,7 @@
 
 	state->results.num_results--;
 
-	for (index = OBJ_NUM_OPERANDS; index; index--) {
+	for (index = ACPI_OBJ_NUM_OPERANDS; index; index--) {
 		/* Check for a valid result object */
 
 		if (state->results.obj_desc [index -1]) {
@@ -207,8 +222,8 @@
 			state->results.obj_desc [index -1] = NULL;
 
 			ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] Index=%X State=%p Num=%X\n",
-				*object, (*object) ? acpi_ut_get_type_name ((*object)->common.type) : "NULL",
-				index -1, walk_state, state->results.num_results));
+				*object, (*object) ? acpi_ut_get_object_type_name (*object) : "NULL",
+				(u32) index -1, walk_state, state->results.num_results));
 
 			return (AE_OK);
 		}
@@ -220,10 +235,10 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_result_pop_from_bottom
+ * FUNCTION:    acpi_ds_result_pop_from_bottom
  *
  * PARAMETERS:  Object              - Where to return the popped object
- *              Walk_state          - Current Walk state
+ *              walk_state          - Current Walk state
  *
  * RETURN:      Status
  *
@@ -234,14 +249,14 @@
 
 acpi_status
 acpi_ds_result_pop_from_bottom (
-	acpi_operand_object     **object,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       **object,
+	struct acpi_walk_state          *walk_state)
 {
-	u32                     index;
-	acpi_generic_state      *state;
+	acpi_native_uint                index;
+	union acpi_generic_state        *state;
 
 
-	PROC_NAME ("Ds_result_pop_from_bottom");
+	ACPI_FUNCTION_NAME ("ds_result_pop_from_bottom");
 
 
 	state = walk_state->results;
@@ -251,7 +266,6 @@
 		return (AE_NOT_EXIST);
 	}
 
-
 	if (!state->results.num_results) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", walk_state));
 		return (AE_AML_NO_RETURN_VALUE);
@@ -273,12 +287,12 @@
 
 	if (!*object) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null operand! State=%p #Ops=%X, Index=%X\n",
-			walk_state, state->results.num_results, index));
+			walk_state, state->results.num_results, (u32) index));
 		return (AE_AML_NO_RETURN_VALUE);
 	}
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s], Results=%p State=%p\n",
-		*object, (*object) ? acpi_ut_get_type_name ((*object)->common.type) : "NULL",
+		*object, (*object) ? acpi_ut_get_object_type_name (*object) : "NULL",
 		state, walk_state));
 
 
@@ -288,10 +302,10 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_result_push
+ * FUNCTION:    acpi_ds_result_push
  *
  * PARAMETERS:  Object              - Where to return the popped object
- *              Walk_state          - Current Walk state
+ *              walk_state          - Current Walk state
  *
  * RETURN:      Status
  *
@@ -301,13 +315,13 @@
 
 acpi_status
 acpi_ds_result_push (
-	acpi_operand_object     *object,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       *object,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_generic_state      *state;
+	union acpi_generic_state        *state;
 
 
-	PROC_NAME ("Ds_result_push");
+	ACPI_FUNCTION_NAME ("ds_result_push");
 
 
 	state = walk_state->results;
@@ -316,7 +330,7 @@
 		return (AE_AML_INTERNAL);
 	}
 
-	if (state->results.num_results == OBJ_NUM_OPERANDS) {
+	if (state->results.num_results == ACPI_OBJ_NUM_OPERANDS) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 			"Result stack overflow: Obj=%p State=%p Num=%X\n",
 			object, walk_state, state->results.num_results));
@@ -329,12 +343,11 @@
 		return (AE_BAD_PARAMETER);
 	}
 
-
 	state->results.obj_desc [state->results.num_results] = object;
 	state->results.num_results++;
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
-		object, object ? acpi_ut_get_type_name (((acpi_operand_object *) object)->common.type) : "NULL",
+		object, object ? acpi_ut_get_object_type_name ((union acpi_operand_object *) object) : "NULL",
 		walk_state, state->results.num_results, walk_state->current_result));
 
 	return (AE_OK);
@@ -343,24 +356,24 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_result_stack_push
+ * FUNCTION:    acpi_ds_result_stack_push
  *
  * PARAMETERS:  Object              - Object to push
- *              Walk_state          - Current Walk state
+ *              walk_state          - Current Walk state
  *
  * RETURN:      Status
  *
- * DESCRIPTION:
+ * DESCRIPTION: Push an object onto the walk_state result stack.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ds_result_stack_push (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_generic_state      *state;
+	union acpi_generic_state        *state;
 
-	PROC_NAME ("Ds_result_stack_push");
+	ACPI_FUNCTION_NAME ("ds_result_stack_push");
 
 
 	state = acpi_ut_create_generic_state ();
@@ -380,23 +393,23 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_result_stack_pop
+ * FUNCTION:    acpi_ds_result_stack_pop
  *
- * PARAMETERS:  Walk_state          - Current Walk state
+ * PARAMETERS:  walk_state          - Current Walk state
  *
  * RETURN:      Status
  *
- * DESCRIPTION:
+ * DESCRIPTION: Pop an object off of the walk_state result stack.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ds_result_stack_pop (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_generic_state      *state;
+	union acpi_generic_state        *state;
 
-	PROC_NAME ("Ds_result_stack_pop");
+	ACPI_FUNCTION_NAME ("ds_result_stack_pop");
 
 
 	/* Check for stack underflow */
@@ -411,7 +424,7 @@
 	state = acpi_ut_pop_generic_state (&walk_state->results);
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
-		"Result=%p Remaining_results=%X State=%p\n",
+		"Result=%p remaining_results=%X State=%p\n",
 		state, state->results.num_results, walk_state));
 
 	acpi_ut_delete_generic_state (state);
@@ -422,9 +435,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_obj_stack_delete_all
+ * FUNCTION:    acpi_ds_obj_stack_delete_all
  *
- * PARAMETERS:  Walk_state          - Current Walk state
+ * PARAMETERS:  walk_state          - Current Walk state
  *
  * RETURN:      Status
  *
@@ -435,17 +448,17 @@
 
 acpi_status
 acpi_ds_obj_stack_delete_all (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	u32                     i;
+	u32                             i;
 
 
-	FUNCTION_TRACE_PTR ("Ds_obj_stack_delete_all", walk_state);
+	ACPI_FUNCTION_TRACE_PTR ("ds_obj_stack_delete_all", walk_state);
 
 
 	/* The stack size is configurable, but fixed */
 
-	for (i = 0; i < OBJ_NUM_OPERANDS; i++) {
+	for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) {
 		if (walk_state->operands[i]) {
 			acpi_ut_remove_reference (walk_state->operands[i]);
 			walk_state->operands[i] = NULL;
@@ -458,10 +471,10 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_obj_stack_push
+ * FUNCTION:    acpi_ds_obj_stack_push
  *
  * PARAMETERS:  Object              - Object to push
- *              Walk_state          - Current Walk state
+ *              walk_state          - Current Walk state
  *
  * RETURN:      Status
  *
@@ -471,15 +484,15 @@
 
 acpi_status
 acpi_ds_obj_stack_push (
-	void                    *object,
-	acpi_walk_state         *walk_state)
+	void                            *object,
+	struct acpi_walk_state          *walk_state)
 {
-	PROC_NAME ("Ds_obj_stack_push");
+	ACPI_FUNCTION_NAME ("ds_obj_stack_push");
 
 
 	/* Check for stack overflow */
 
-	if (walk_state->num_operands >= OBJ_NUM_OPERANDS) {
+	if (walk_state->num_operands >= ACPI_OBJ_NUM_OPERANDS) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 			"overflow! Obj=%p State=%p #Ops=%X\n",
 			object, walk_state, walk_state->num_operands));
@@ -492,7 +505,7 @@
 	walk_state->num_operands++;
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
-			  object, acpi_ut_get_type_name (((acpi_operand_object *) object)->common.type),
+			  object, acpi_ut_get_object_type_name ((union acpi_operand_object *) object),
 			  walk_state, walk_state->num_operands));
 
 	return (AE_OK);
@@ -502,10 +515,10 @@
 #if 0
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_obj_stack_pop_object
+ * FUNCTION:    acpi_ds_obj_stack_pop_object
  *
- * PARAMETERS:  Pop_count           - Number of objects/entries to pop
- *              Walk_state          - Current Walk state
+ * PARAMETERS:  pop_count           - Number of objects/entries to pop
+ *              walk_state          - Current Walk state
  *
  * RETURN:      Status
  *
@@ -516,10 +529,10 @@
 
 acpi_status
 acpi_ds_obj_stack_pop_object (
-	acpi_operand_object     **object,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       **object,
+	struct acpi_walk_state          *walk_state)
 {
-	PROC_NAME ("Ds_obj_stack_pop_object");
+	ACPI_FUNCTION_NAME ("ds_obj_stack_pop_object");
 
 
 	/* Check for stack underflow */
@@ -552,7 +565,7 @@
 	walk_state->operands [walk_state->num_operands] = NULL;
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
-			  *object, acpi_ut_get_type_name ((*object)->common.type),
+			  *object, acpi_ut_get_object_type_name (*object),
 			  walk_state, walk_state->num_operands));
 
 	return (AE_OK);
@@ -561,10 +574,10 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_obj_stack_pop
+ * FUNCTION:    acpi_ds_obj_stack_pop
  *
- * PARAMETERS:  Pop_count           - Number of objects/entries to pop
- *              Walk_state          - Current Walk state
+ * PARAMETERS:  pop_count           - Number of objects/entries to pop
+ *              walk_state          - Current Walk state
  *
  * RETURN:      Status
  *
@@ -575,12 +588,12 @@
 
 acpi_status
 acpi_ds_obj_stack_pop (
-	u32                     pop_count,
-	acpi_walk_state         *walk_state)
+	u32                             pop_count,
+	struct acpi_walk_state          *walk_state)
 {
-	u32                     i;
+	u32                             i;
 
-	PROC_NAME ("Ds_obj_stack_pop");
+	ACPI_FUNCTION_NAME ("ds_obj_stack_pop");
 
 
 	for (i = 0; i < pop_count; i++) {
@@ -608,10 +621,10 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_obj_stack_pop_and_delete
+ * FUNCTION:    acpi_ds_obj_stack_pop_and_delete
  *
- * PARAMETERS:  Pop_count           - Number of objects/entries to pop
- *              Walk_state          - Current Walk state
+ * PARAMETERS:  pop_count           - Number of objects/entries to pop
+ *              walk_state          - Current Walk state
  *
  * RETURN:      Status
  *
@@ -622,13 +635,13 @@
 
 acpi_status
 acpi_ds_obj_stack_pop_and_delete (
-	u32                     pop_count,
-	acpi_walk_state         *walk_state)
+	u32                             pop_count,
+	struct acpi_walk_state          *walk_state)
 {
-	u32                     i;
-	acpi_operand_object     *obj_desc;
+	u32                             i;
+	union acpi_operand_object       *obj_desc;
 
-	PROC_NAME ("Ds_obj_stack_pop_and_delete");
+	ACPI_FUNCTION_NAME ("ds_obj_stack_pop_and_delete");
 
 
 	for (i = 0; i < pop_count; i++) {
@@ -660,11 +673,11 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_obj_stack_get_value
+ * FUNCTION:    acpi_ds_obj_stack_get_value
  *
  * PARAMETERS:  Index               - Stack index whose value is desired.  Based
  *                                    on the top of the stack (index=0 == top)
- *              Walk_state          - Current Walk state
+ *              walk_state          - Current Walk state
  *
  * RETURN:      Status
  *
@@ -675,11 +688,11 @@
 
 void *
 acpi_ds_obj_stack_get_value (
-	u32                     index,
-	acpi_walk_state         *walk_state)
+	u32                             index,
+	struct acpi_walk_state          *walk_state)
 {
 
-	FUNCTION_TRACE_PTR ("Ds_obj_stack_get_value", walk_state);
+	ACPI_FUNCTION_TRACE_PTR ("ds_obj_stack_get_value", walk_state);
 
 
 	/* Can't do it if the stack is empty */
@@ -694,67 +707,66 @@
 		return_PTR (NULL);
 	}
 
-
-	return_PTR (walk_state->operands[(NATIVE_UINT)(walk_state->num_operands - 1) -
+	return_PTR (walk_state->operands[(acpi_native_uint)(walk_state->num_operands - 1) -
 			  index]);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_get_current_walk_state
+ * FUNCTION:    acpi_ds_get_current_walk_state
  *
- * PARAMETERS:  Walk_list       - Get current active state for this walk list
+ * PARAMETERS:  Thread          - Get current active state for this Thread
  *
  * RETURN:      Pointer to the current walk state
  *
  * DESCRIPTION: Get the walk state that is at the head of the list (the "current"
- *              walk state.
+ *              walk state.)
  *
  ******************************************************************************/
 
-acpi_walk_state *
+struct acpi_walk_state *
 acpi_ds_get_current_walk_state (
-	acpi_walk_list          *walk_list)
+	struct acpi_thread_state        *thread)
 
 {
-	PROC_NAME ("Ds_get_current_walk_state");
-
+	ACPI_FUNCTION_NAME ("ds_get_current_walk_state");
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Ds_get_current_walk_state, =%p\n",
-		walk_list->walk_state));
 
-	if (!walk_list) {
+	if (!thread) {
 		return (NULL);
 	}
 
-	return (walk_list->walk_state);
+	ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Current walk_state %p\n",
+		thread->walk_state_list));
+
+	return (thread->walk_state_list);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_push_walk_state
+ * FUNCTION:    acpi_ds_push_walk_state
  *
- * PARAMETERS:  Walk_state      - State to push
- *              Walk_list       - The list that owns the walk stack
+ * PARAMETERS:  walk_state      - State to push
+ *              walk_list       - The list that owns the walk stack
  *
  * RETURN:      None
  *
- * DESCRIPTION: Place the Walk_state at the head of the state list.
+ * DESCRIPTION: Place the walk_state at the head of the state list.
  *
  ******************************************************************************/
 
 void
 acpi_ds_push_walk_state (
-	acpi_walk_state         *walk_state,
-	acpi_walk_list          *walk_list)
+	struct acpi_walk_state          *walk_state,
+	struct acpi_thread_state        *thread)
 {
-	FUNCTION_TRACE ("Ds_push_walk_state");
+	ACPI_FUNCTION_TRACE ("ds_push_walk_state");
 
 
-	walk_state->next    = walk_list->walk_state;
-	walk_list->walk_state = walk_state;
+	walk_state->next      = thread->walk_state_list;
+	thread->walk_state_list = walk_state;
 
 	return_VOID;
 }
@@ -762,11 +774,11 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_pop_walk_state
+ * FUNCTION:    acpi_ds_pop_walk_state
  *
- * PARAMETERS:  Walk_list       - The list that owns the walk stack
+ * PARAMETERS:  walk_list       - The list that owns the walk stack
  *
- * RETURN:      A Walk_state object popped from the stack
+ * RETURN:      A walk_state object popped from the stack
  *
  * DESCRIPTION: Remove and return the walkstate object that is at the head of
  *              the walk stack for the given walk list.  NULL indicates that
@@ -774,27 +786,27 @@
  *
  ******************************************************************************/
 
-acpi_walk_state *
+struct acpi_walk_state *
 acpi_ds_pop_walk_state (
-	acpi_walk_list          *walk_list)
+	struct acpi_thread_state        *thread)
 {
-	acpi_walk_state         *walk_state;
+	struct acpi_walk_state          *walk_state;
 
 
-	FUNCTION_TRACE ("Ds_pop_walk_state");
+	ACPI_FUNCTION_TRACE ("ds_pop_walk_state");
 
 
-	walk_state = walk_list->walk_state;
+	walk_state = thread->walk_state_list;
 
 	if (walk_state) {
 		/* Next walk state becomes the current walk state */
 
-		walk_list->walk_state = walk_state->next;
+		thread->walk_state_list = walk_state->next;
 
 		/*
 		 * Don't clear the NEXT field, this serves as an indicator
 		 * that there is a parent WALK STATE
-		 *     Walk_state->Next = NULL;
+		 *     NO: walk_state->Next = NULL;
 		 */
 	}
 
@@ -804,30 +816,30 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_create_walk_state
+ * FUNCTION:    acpi_ds_create_walk_state
  *
  * PARAMETERS:  Origin          - Starting point for this walk
- *              Walk_list       - Owning walk list
+ *              Thread          - Current thread state
  *
  * RETURN:      Pointer to the new walk state.
  *
- * DESCRIPTION: Allocate and initialize a new walk state.  The current walk state
- *              is set to this new state.
+ * DESCRIPTION: Allocate and initialize a new walk state.  The current walk
+ *              state is set to this new state.
  *
  ******************************************************************************/
 
-acpi_walk_state *
+struct acpi_walk_state *
 acpi_ds_create_walk_state (
-	acpi_owner_id           owner_id,
-	acpi_parse_object       *origin,
-	acpi_operand_object     *mth_desc,
-	acpi_walk_list          *walk_list)
+	acpi_owner_id                   owner_id,
+	union acpi_parse_object         *origin,
+	union acpi_operand_object       *mth_desc,
+	struct acpi_thread_state        *thread)
 {
-	acpi_walk_state         *walk_state;
-	acpi_status             status;
+	struct acpi_walk_state          *walk_state;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Ds_create_walk_state");
+	ACPI_FUNCTION_TRACE ("ds_create_walk_state");
 
 
 	walk_state = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_WALK);
@@ -839,11 +851,13 @@
 	walk_state->owner_id        = owner_id;
 	walk_state->origin          = origin;
 	walk_state->method_desc     = mth_desc;
-	walk_state->walk_list       = walk_list;
+	walk_state->thread          = thread;
+
+	walk_state->parser_state.start_op = origin;
 
 	/* Init the method args/local */
 
-#ifndef _ACPI_ASL_COMPILER
+#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
 	acpi_ds_method_data_init (walk_state);
 #endif
 
@@ -856,20 +870,19 @@
 
 	/* Put the new state at the head of the walk list */
 
-	if (walk_list) {
-		acpi_ds_push_walk_state (walk_state, walk_list);
+	if (thread) {
+		acpi_ds_push_walk_state (walk_state, thread);
 	}
 
 	return_PTR (walk_state);
 }
 
 
-#ifndef _ACPI_ASL_COMPILER
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_init_aml_walk
+ * FUNCTION:    acpi_ds_init_aml_walk
  *
- * PARAMETERS:  Walk_state      - New state to be initialized
+ * PARAMETERS:  walk_state      - New state to be initialized
  *
  * RETURN:      None
  *
@@ -879,20 +892,21 @@
 
 acpi_status
 acpi_ds_init_aml_walk (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op,
-	acpi_namespace_node     *method_node,
-	u8                      *aml_start,
-	u32                     aml_length,
-	acpi_operand_object     **params,
-	acpi_operand_object     **return_obj_desc,
-	u32                     pass_number)
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op,
+	struct acpi_namespace_node      *method_node,
+	u8                              *aml_start,
+	u32                             aml_length,
+	union acpi_operand_object       **params,
+	union acpi_operand_object       **return_obj_desc,
+	u32                             pass_number)
 {
-	acpi_status             status;
-	acpi_parse_state        *parser_state = &walk_state->parser_state;
+	acpi_status                     status;
+	struct acpi_parse_state         *parser_state = &walk_state->parser_state;
+	union acpi_parse_object         *extra_op;
 
 
-	FUNCTION_TRACE ("Ds_init_aml_walk");
+	ACPI_FUNCTION_TRACE ("ds_init_aml_walk");
 
 
 	walk_state->parser_state.aml    =
@@ -900,8 +914,7 @@
 	walk_state->parser_state.aml_end =
 	walk_state->parser_state.pkg_end = aml_start + aml_length;
 
-	/* The Next_op of the Next_walk will be the beginning of the method */
-	/* TBD: [Restructure] -- obsolete? */
+	/* The next_op of the next_walk will be the beginning of the method */
 
 	walk_state->next_op             = NULL;
 	walk_state->params              = params;
@@ -914,11 +927,10 @@
 
 	if (method_node) {
 		walk_state->parser_state.start_node = method_node;
-		walk_state->walk_type               = WALK_METHOD;
+		walk_state->walk_type               = ACPI_WALK_METHOD;
 		walk_state->method_node             = method_node;
 		walk_state->method_desc             = acpi_ns_get_attached_object (method_node);
 
-
 		/* Push start scope on scope stack and make it current  */
 
 		status = acpi_ds_scope_stack_push (method_node, ACPI_TYPE_METHOD, walk_state);
@@ -928,13 +940,29 @@
 
 		/* Init the method arguments */
 
-		acpi_ds_method_data_init_args (params, MTH_NUM_ARGS, walk_state);
+		status = acpi_ds_method_data_init_args (params, ACPI_METHOD_NUM_ARGS, walk_state);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
+		}
 	}
-
 	else {
-		/* Setup the current scope */
+		/*
+		 * Setup the current scope.
+		 * Find a Named Op that has a namespace node associated with it.
+		 * search upwards from this Op.  Current scope is the first
+		 * Op with a namespace node.
+		 */
+		extra_op = parser_state->start_op;
+		while (extra_op && !extra_op->common.node) {
+			extra_op = extra_op->common.parent;
+		}
+		if (!extra_op) {
+			parser_state->start_node = NULL;
+		}
+		else {
+			parser_state->start_node = extra_op->common.node;
+		}
 
-		parser_state->start_node = parser_state->start_op->node;
 		if (parser_state->start_node) {
 			/* Push start scope on scope stack and make it current  */
 
@@ -946,18 +974,16 @@
 		}
 	}
 
-	acpi_ds_init_callbacks (walk_state, pass_number);
-
-	return_ACPI_STATUS (AE_OK);
+	status = acpi_ds_init_callbacks (walk_state, pass_number);
+	return_ACPI_STATUS (status);
 }
-#endif
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_delete_walk_state
+ * FUNCTION:    acpi_ds_delete_walk_state
  *
- * PARAMETERS:  Walk_state      - State to delete
+ * PARAMETERS:  walk_state      - State to delete
  *
  * RETURN:      Status
  *
@@ -967,12 +993,12 @@
 
 void
 acpi_ds_delete_walk_state (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_generic_state      *state;
+	union acpi_generic_state        *state;
 
 
-	FUNCTION_TRACE_PTR ("Ds_delete_walk_state", walk_state);
+	ACPI_FUNCTION_TRACE_PTR ("ds_delete_walk_state", walk_state);
 
 
 	if (!walk_state) {
@@ -984,7 +1010,6 @@
 		return;
 	}
 
-
 	if (walk_state->parser_state.scope) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p walk still has a scope list\n", walk_state));
 	}
@@ -1023,7 +1048,7 @@
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_ds_delete_walk_state_cache
+ * FUNCTION:    acpi_ds_delete_walk_state_cache
  *
  * PARAMETERS:  None
  *
@@ -1038,7 +1063,7 @@
 acpi_ds_delete_walk_state_cache (
 	void)
 {
-	FUNCTION_TRACE ("Ds_delete_walk_state_cache");
+	ACPI_FUNCTION_TRACE ("ds_delete_walk_state_cache");
 
 
 	acpi_ut_delete_generic_cache (ACPI_MEM_LIST_WALK);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/driver.c linux-2.4.22-pre2/drivers/acpi/driver.c
--- linux-2.4.21/drivers/acpi/driver.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/driver.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,217 +0,0 @@
-/*
- *  driver.c - ACPI driver
- *
- *  Copyright (C) 2000 Andrew Henroid
- *  Copyright (C) 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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
- */
-/*
- * Changes
- * David Woodhouse <dwmw2@redhat.com> 2000-12-6
- * - Fix interruptible_sleep_on() races
- * Andrew Grover <andrew.grover@intel.com> 2001-2-28
- * - Major revamping
- * Peter Breuer <ptb@it.uc3m.es> 2001-5-20
- * - parse boot time params.
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/proc_fs.h>
-#include <linux/sysctl.h>
-#include <linux/pm.h>
-#include <linux/acpi.h>
-#include <asm/uaccess.h>
-#include "acpi.h"
-
-
-#define _COMPONENT	OS_DEPENDENT
-	MODULE_NAME	("driver")
-
-FADT_DESCRIPTOR acpi_fadt;
-
-static int acpi_disabled = 0;
-
-enum acpi_blacklist_predicates
-{
-	all_versions,
-	less_than_or_equal,
-	equal,
-	greater_than_or_equal,
-};
-
-struct acpi_blacklist_item
-{
-	char oem_id[7];
-	char oem_table_id[9];
-	u32  oem_revision;
-	enum acpi_blacklist_predicates oem_revision_predicate;
-};
-
-/*
- * Currently, this blacklists based on items in the FADT. We may want to
- * expand this to using other ACPI tables in the future, too.
- */
-static struct acpi_blacklist_item acpi_blacklist[] __initdata = 
-{
-	{"TOSHIB", "750     ", 0x970814, less_than_or_equal}, /* Portege 7020, BIOS 8.10 */
-	{""}
-};
-
-int
-acpi_blacklisted(FADT_DESCRIPTOR *fadt)
-{
-	int i = 0;
-
-	while (acpi_blacklist[i].oem_id[0] != '\0')
-	{
-		if (strncmp(acpi_blacklist[i].oem_id, fadt->header.oem_id, 6)) {
-			i++;
-			continue;
-		}
-
-		if (strncmp(acpi_blacklist[i].oem_table_id, fadt->header.oem_table_id, 8)) {
-			i++;
-			continue;
-		}
-
-		if (acpi_blacklist[i].oem_revision_predicate == all_versions)
-			return TRUE;
-
-		if (acpi_blacklist[i].oem_revision_predicate == less_than_or_equal
-		    && fadt->header.oem_revision <= acpi_blacklist[i].oem_revision)
-			return TRUE;
-
-		if (acpi_blacklist[i].oem_revision_predicate == greater_than_or_equal
-		    && fadt->header.oem_revision >= acpi_blacklist[i].oem_revision)
-			return TRUE;
-
-		if (acpi_blacklist[i].oem_revision_predicate == equal
-		    && fadt->header.oem_revision == acpi_blacklist[i].oem_revision)
-			return TRUE;
-
-		i++;
-	}
-
-	return FALSE;
-}
-
-/*
- * Start the interpreter
- */
-int
-acpi_init(void)
-{
-	acpi_buffer		buffer;
-	acpi_system_info	sys_info;
-
-	if (PM_IS_ACTIVE()) {
-		printk(KERN_NOTICE "ACPI: APM is already active, exiting\n");
-		return -ENODEV;
-	}
-
-	if (acpi_disabled) {
-		printk(KERN_NOTICE "ACPI: disabled by cmdline, exiting\n");
-		return -ENODEV;
-	}
-
-	if (!ACPI_SUCCESS(acpi_initialize_subsystem())) {
-		printk(KERN_ERR "ACPI: Driver initialization failed\n");
-		return -ENODEV;
-	}
-
-	/* from this point on, on error we must call acpi_terminate() */
-	if (!ACPI_SUCCESS(acpi_load_tables())) {
-		printk(KERN_ERR "ACPI: System description table load failed\n");
-		acpi_terminate();
-		return -ENODEV;
-	}
-
-	/* get a separate copy of the FADT for use by other drivers */
-	memset(&acpi_fadt, 0, sizeof(acpi_fadt));
-	buffer.pointer = &acpi_fadt;
-	buffer.length = sizeof(acpi_fadt);
-
-	if (!ACPI_SUCCESS(acpi_get_table(ACPI_TABLE_FADT, 1, &buffer))) {
-		printk(KERN_ERR "ACPI: Could not get FADT\n");
-		acpi_terminate();
-		return -ENODEV;
-	}
-
-	if (acpi_blacklisted(&acpi_fadt)) {
-		printk(KERN_ERR "ACPI: On blacklist -- BIOS not fully ACPI compliant\n");
-		acpi_terminate();
-		return -ENODEV;
-	}
-
-	buffer.length  = sizeof(sys_info);
-	buffer.pointer = &sys_info;
-
-	if (!ACPI_SUCCESS (acpi_get_system_info(&buffer))) {
-		printk(KERN_ERR "ACPI: Could not get system info\n");
-		acpi_terminate();
-		return -ENODEV;
-	}
-
-	printk(KERN_INFO "ACPI: Core Subsystem version [%x]\n", sys_info.acpi_ca_version);
-
-	if (!ACPI_SUCCESS(acpi_enable_subsystem(ACPI_FULL_INITIALIZATION))) {
-		printk(KERN_ERR "ACPI: Subsystem enable failed\n");
-		acpi_terminate();
-		return -ENODEV;
-	}
-
-	printk(KERN_INFO "ACPI: Subsystem enabled\n");
-
-	pm_active = 1;
-
-	return 0;
-}
-
-/*
- * Terminate the interpreter
- */
-void
-acpi_exit(void)
-{
-	acpi_terminate();
-
-	pm_active = 0;
-
-	printk(KERN_ERR "ACPI: Subsystem disabled\n");
-}
-
-module_init(acpi_init);
-module_exit(acpi_exit);
-
-#ifndef MODULE
-static int __init acpi_setup(char *str) {
-	while (str && *str) {
-	if (strncmp(str, "off", 3) == 0)
-		acpi_disabled = 1;
-	str = strchr(str, ',');
-	if (str)
-		str += strspn(str, ", \t");
-	}
-	return 1;
-}
-
-__setup("acpi=", acpi_setup);
-#endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ec.c linux-2.4.22-pre2/drivers/acpi/ec.c
--- linux-2.4.21/drivers/acpi/ec.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ec.c	2003-06-26 21:43:14.000000000 +0000
@@ -0,0 +1,859 @@
+/*
+ *  acpi_ec.c - ACPI Embedded Controller Driver ($Revision: 36 $)
+ *
+ *  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/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/delay.h>
+#include <linux/compatmac.h>
+#include <linux/proc_fs.h>
+#include <asm/io.h>
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+
+
+#define _COMPONENT		ACPI_EC_COMPONENT
+ACPI_MODULE_NAME		("acpi_ec")
+
+#define PREFIX			"ACPI: "
+
+
+#define ACPI_EC_FLAG_OBF	0x01	/* Output buffer full */
+#define ACPI_EC_FLAG_IBF	0x02	/* Input buffer full */
+#define ACPI_EC_FLAG_SCI	0x20	/* EC-SCI occurred */
+
+#define ACPI_EC_EVENT_OBF	0x01	/* Output buffer full */
+#define ACPI_EC_EVENT_IBE	0x02	/* Input buffer empty */
+
+#define ACPI_EC_UDELAY		100	/* Poll @ 100us increments */
+#define ACPI_EC_UDELAY_COUNT	1000	/* Wait 10ms max. during EC ops */
+#define ACPI_EC_UDELAY_GLK	1000	/* Wait 1ms max. to get global lock */
+
+#define ACPI_EC_COMMAND_READ	0x80
+#define ACPI_EC_COMMAND_WRITE	0x81
+#define ACPI_EC_COMMAND_QUERY	0x84
+
+static int acpi_ec_add (struct acpi_device *device);
+static int acpi_ec_remove (struct acpi_device *device, int type);
+static int acpi_ec_start (struct acpi_device *device);
+static int acpi_ec_stop (struct acpi_device *device, int type);
+
+static struct acpi_driver acpi_ec_driver = {
+	.name =		ACPI_EC_DRIVER_NAME,
+	.class =	ACPI_EC_CLASS,
+	.ids =		ACPI_EC_HID,
+	.ops =		{
+				.add =		acpi_ec_add,
+				.remove =	acpi_ec_remove,
+				.start =	acpi_ec_start,
+				.stop =		acpi_ec_stop,
+			},
+};
+
+struct acpi_ec {
+	acpi_handle			handle;
+	unsigned long			uid;
+	unsigned long			gpe_bit;
+	struct acpi_generic_address	status_addr;
+	struct acpi_generic_address	command_addr;
+	struct acpi_generic_address	data_addr;
+	unsigned long			global_lock;
+	spinlock_t			lock;
+};
+
+/* If we find an EC via the ECDT, we need to keep a ptr to its context */
+static struct acpi_ec	*ec_ecdt;
+
+/* External interfaces use first EC only, so remember */
+static struct acpi_device *first_ec;
+
+/* --------------------------------------------------------------------------
+                             Transaction Management
+   -------------------------------------------------------------------------- */
+
+static int
+acpi_ec_wait (
+	struct acpi_ec		*ec,
+	u8			event)
+{
+	u32			acpi_ec_status = 0;
+	u32			i = ACPI_EC_UDELAY_COUNT;
+
+	if (!ec)
+		return -EINVAL;
+
+	/* Poll the EC status register waiting for the event to occur. */
+	switch (event) {
+	case ACPI_EC_EVENT_OBF:
+		do {
+			acpi_hw_low_level_read(8, &acpi_ec_status, &ec->status_addr);
+			if (acpi_ec_status & ACPI_EC_FLAG_OBF)
+				return 0;
+			udelay(ACPI_EC_UDELAY);
+		} while (--i>0);
+		break;
+	case ACPI_EC_EVENT_IBE:
+		do {
+			acpi_hw_low_level_read(8, &acpi_ec_status, &ec->status_addr);
+			if (!(acpi_ec_status & ACPI_EC_FLAG_IBF))
+				return 0;
+			udelay(ACPI_EC_UDELAY);
+		} while (--i>0);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return -ETIME;
+}
+
+
+static int
+acpi_ec_read (
+	struct acpi_ec		*ec,
+	u8			address,
+	u32			*data)
+{
+	acpi_status		status = AE_OK;
+	int			result = 0;
+	unsigned long		flags = 0;
+	u32			glk = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_ec_read");
+
+	if (!ec || !data)
+		return_VALUE(-EINVAL);
+
+	*data = 0;
+
+	if (ec->global_lock) {
+		status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
+		if (ACPI_FAILURE(status))
+			return_VALUE(-ENODEV);
+	}
+	
+	spin_lock_irqsave(&ec->lock, flags);
+
+	acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->command_addr);
+	result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
+	if (result)
+		goto end;
+
+	acpi_hw_low_level_write(8, address, &ec->data_addr);
+	result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
+	if (result)
+		goto end;
+
+
+	acpi_hw_low_level_read(8, data, &ec->data_addr);
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n",
+		*data, address));
+
+end:
+	spin_unlock_irqrestore(&ec->lock, flags);
+
+	if (ec->global_lock)
+		acpi_release_global_lock(glk);
+
+	return_VALUE(result);
+}
+
+
+static int
+acpi_ec_write (
+	struct acpi_ec		*ec,
+	u8			address,
+	u8			data)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	unsigned long		flags = 0;
+	u32			glk = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_ec_write");
+
+	if (!ec)
+		return_VALUE(-EINVAL);
+
+	if (ec->global_lock) {
+		status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
+		if (ACPI_FAILURE(status))
+			return_VALUE(-ENODEV);
+	}
+
+	spin_lock_irqsave(&ec->lock, flags);
+
+	acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->command_addr);
+	result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
+	if (result)
+		goto end;
+
+	acpi_hw_low_level_write(8, address, &ec->data_addr);
+	result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
+	if (result)
+		goto end;
+
+	acpi_hw_low_level_write(8, data, &ec->data_addr);
+	result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
+	if (result)
+		goto end;
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n",
+		data, address));
+
+end:
+	spin_unlock_irqrestore(&ec->lock, flags);
+
+	if (ec->global_lock)
+		acpi_release_global_lock(glk);
+
+	return_VALUE(result);
+}
+
+/*
+ * Externally callable EC access functions. For now, assume 1 EC only
+ */
+int
+ec_read(u8 addr, u8 *val)
+{
+	struct acpi_ec *ec;
+	int err;
+	u32 temp_data;
+
+	if (!first_ec)
+		return -ENODEV;
+
+	ec = acpi_driver_data(first_ec);
+
+	err = acpi_ec_read(ec, addr, &temp_data);
+
+	if (!err) {
+		*val = temp_data;
+		return 0;
+	}
+	else
+		return err;
+}
+
+int
+ec_write(u8 addr, u8 val)
+{
+	struct acpi_ec *ec;
+	int err;
+
+	if (!first_ec)
+		return -ENODEV;
+
+	ec = acpi_driver_data(first_ec);
+
+	err = acpi_ec_write(ec, addr, val);
+
+	return err;
+}
+
+
+static int
+acpi_ec_query (
+	struct acpi_ec		*ec,
+	u32			*data)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	unsigned long		flags = 0;
+	u32			glk = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_ec_query");
+
+	if (!ec || !data)
+		return_VALUE(-EINVAL);
+
+	*data = 0;
+
+	if (ec->global_lock) {
+		status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
+		if (ACPI_FAILURE(status))
+			return_VALUE(-ENODEV);
+	}
+
+	/*
+	 * Query the EC to find out which _Qxx method we need to evaluate.
+	 * Note that successful completion of the query causes the ACPI_EC_SCI
+	 * bit to be cleared (and thus clearing the interrupt source).
+	 */
+	spin_lock_irqsave(&ec->lock, flags);
+
+	acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->command_addr);
+	result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
+	if (result)
+		goto end;
+	
+	acpi_hw_low_level_read(8, data, &ec->data_addr);
+	if (!*data)
+		result = -ENODATA;
+
+end:
+	spin_unlock_irqrestore(&ec->lock, flags);
+
+	if (ec->global_lock)
+		acpi_release_global_lock(glk);
+
+	return_VALUE(result);
+}
+
+
+/* --------------------------------------------------------------------------
+                                Event Management
+   -------------------------------------------------------------------------- */
+
+struct acpi_ec_query_data {
+	acpi_handle		handle;
+	u8			data;
+};
+
+static void
+acpi_ec_gpe_query (
+	void			*ec_cxt)
+{
+	struct acpi_ec		*ec = (struct acpi_ec *) ec_cxt;
+	u32			value = 0;
+	unsigned long		flags = 0;
+	static char		object_name[5] = {'_','Q','0','0','\0'};
+	const char		hex[] = {'0','1','2','3','4','5','6','7',
+				         '8','9','A','B','C','D','E','F'};
+
+	ACPI_FUNCTION_TRACE("acpi_ec_gpe_query");
+
+	if (!ec_cxt)
+		goto end;	
+
+	spin_lock_irqsave(&ec->lock, flags);
+	acpi_hw_low_level_read(8, &value, &ec->command_addr);
+	spin_unlock_irqrestore(&ec->lock, flags);
+
+	/* TBD: Implement asynch events!
+	 * NOTE: All we care about are EC-SCI's.  Other EC events are
+	 * handled via polling (yuck!).  This is because some systems
+	 * treat EC-SCIs as level (versus EDGE!) triggered, preventing
+	 *  a purely interrupt-driven approach (grumble, grumble).
+	 */
+	if (!(value & ACPI_EC_FLAG_SCI))
+		goto end;
+
+	if (acpi_ec_query(ec, &value))
+		goto end;
+	
+	object_name[2] = hex[((value >> 4) & 0x0F)];
+	object_name[3] = hex[(value & 0x0F)];
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name));
+
+	acpi_evaluate_object(ec->handle, object_name, NULL, NULL);
+
+end:
+	acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
+}
+
+static void
+acpi_ec_gpe_handler (
+	void			*data)
+{
+	acpi_status		status = AE_OK;
+	struct acpi_ec		*ec = (struct acpi_ec *) data;
+
+	if (!ec)
+		return;
+
+	acpi_disable_gpe(NULL, ec->gpe_bit, ACPI_ISR);
+
+	status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
+		acpi_ec_gpe_query, ec);
+}
+
+/* --------------------------------------------------------------------------
+                             Address Space Management
+   -------------------------------------------------------------------------- */
+
+static acpi_status
+acpi_ec_space_setup (
+	acpi_handle		region_handle,
+	u32			function,
+	void			*handler_context,
+	void			**return_context)
+{
+	/*
+	 * The EC object is in the handler context and is needed
+	 * when calling the acpi_ec_space_handler.
+	 */
+	*return_context = handler_context;
+
+	return AE_OK;
+}
+
+
+static acpi_status
+acpi_ec_space_handler (
+	u32			function,
+	acpi_physical_address	address,
+	u32			bit_width,
+	acpi_integer		*value,
+	void			*handler_context,
+	void			*region_context)
+{
+	int			result = 0;
+	struct acpi_ec		*ec = NULL;
+	u32			temp = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_ec_space_handler");
+
+	if ((address > 0xFF) || (bit_width != 8) || !value || !handler_context)
+		return_VALUE(AE_BAD_PARAMETER);
+
+	ec = (struct acpi_ec *) handler_context;
+
+	switch (function) {
+	case ACPI_READ:
+		result = acpi_ec_read(ec, (u8) address, &temp);
+		*value = (acpi_integer) temp;
+		break;
+	case ACPI_WRITE:
+		result = acpi_ec_write(ec, (u8) address, (u8) *value);
+		break;
+	default:
+		result = -EINVAL;
+		break;
+	}
+
+	switch (result) {
+	case -EINVAL:
+		return_VALUE(AE_BAD_PARAMETER);
+		break;
+	case -ENODEV:
+		return_VALUE(AE_NOT_FOUND);
+		break;
+	case -ETIME:
+		return_VALUE(AE_TIME);
+		break;
+	default:
+		return_VALUE(AE_OK);
+	}
+
+}
+
+
+/* --------------------------------------------------------------------------
+                              FS Interface (/proc)
+   -------------------------------------------------------------------------- */
+
+struct proc_dir_entry		*acpi_ec_dir = NULL;
+
+
+static int
+acpi_ec_read_info (
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	struct acpi_ec		*ec = (struct acpi_ec *) data;
+	char			*p = page;
+	int			len = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_ec_read_info");
+
+	if (!ec || (off != 0))
+		goto end;
+
+	p += sprintf(p, "gpe bit:                 0x%02x\n",
+		(u32) ec->gpe_bit);
+	p += sprintf(p, "ports:                   0x%02x, 0x%02x\n",
+		(u32) ec->status_addr.address, (u32) ec->data_addr.address);
+	p += sprintf(p, "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(len);
+}
+
+
+static int
+acpi_ec_add_fs (
+	struct acpi_device	*device)
+{
+	struct proc_dir_entry	*entry = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_ec_add_fs");
+
+	if (!acpi_device_dir(device)) {
+		acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
+			acpi_ec_dir);
+		if (!acpi_device_dir(device))
+			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));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_WARN,
+			"Unable to create '%s' fs entry\n",
+			ACPI_EC_FILE_INFO));
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_ec_remove_fs (
+	struct acpi_device	*device)
+{
+	ACPI_FUNCTION_TRACE("acpi_ec_remove_fs");
+
+	return_VALUE(0);
+}
+
+
+/* --------------------------------------------------------------------------
+                               Driver Interface
+   -------------------------------------------------------------------------- */
+
+static int
+acpi_ec_add (
+	struct acpi_device	*device)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	struct acpi_ec		*ec = NULL;
+	unsigned long		uid;
+
+	ACPI_FUNCTION_TRACE("acpi_ec_add");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
+	if (!ec)
+		return_VALUE(-ENOMEM);
+	memset(ec, 0, sizeof(struct acpi_ec));
+
+	ec->handle = device->handle;
+	ec->uid = -1;
+	ec->lock = SPIN_LOCK_UNLOCKED;
+	sprintf(acpi_device_name(device), "%s", ACPI_EC_DEVICE_NAME);
+	sprintf(acpi_device_class(device), "%s", ACPI_EC_CLASS);
+	acpi_driver_data(device) = ec;
+
+	/* Use the global lock for all EC transactions? */
+	acpi_evaluate_integer(ec->handle, "_GLK", NULL, &ec->global_lock);
+
+	/* If our UID matches the UID for the ECDT-enumerated EC,
+	   we now have the *real* EC info, so kill the makeshift one.*/
+	acpi_evaluate_integer(ec->handle, "_UID", NULL, &uid);
+	if (ec_ecdt && ec_ecdt->uid == uid) {
+		acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
+			ACPI_ADR_SPACE_EC, &acpi_ec_space_handler);
+	
+		acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit, &acpi_ec_gpe_handler);
+
+		kfree(ec_ecdt);
+	}
+
+	/* Get GPE bit assignment (EC events). */
+	/* TODO: Add support for _GPE returning a package */
+	status = acpi_evaluate_integer(ec->handle, "_GPE", NULL, &ec->gpe_bit);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Error obtaining GPE bit assignment\n"));
+		result = -ENODEV;
+		goto end;
+	}
+
+	result = acpi_ec_add_fs(device);
+	if (result)
+		goto end;
+
+	printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n",
+		acpi_device_name(device), acpi_device_bid(device),
+		(u32) ec->gpe_bit);
+
+	if (!first_ec)
+		first_ec = device;
+
+end:
+	if (result)
+		kfree(ec);
+
+	return_VALUE(result);
+}
+
+
+static int
+acpi_ec_remove (
+	struct acpi_device	*device,
+	int			type)
+{
+	struct acpi_ec		*ec = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_ec_remove");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	ec = acpi_driver_data(device);
+
+	acpi_ec_remove_fs(device);
+
+	kfree(ec);
+
+	return_VALUE(0);
+}
+
+
+static acpi_status
+acpi_ec_io_ports (
+	struct acpi_resource	*resource,
+	void			*context)
+{
+	struct acpi_ec		*ec = (struct acpi_ec *) context;
+	struct acpi_generic_address *addr;
+
+	if (resource->id != ACPI_RSTYPE_IO) {
+		return AE_OK;
+	}
+
+	/*
+	 * The first address region returned is the data port, and
+	 * the second address region returned is the status/command
+	 * port.
+	 */
+	if (ec->data_addr.register_bit_width == 0) {
+		addr = &ec->data_addr;
+	} else if (ec->command_addr.register_bit_width == 0) {
+		addr = &ec->command_addr;
+	} else {
+		return AE_CTRL_TERMINATE;
+	}
+
+	addr->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO;
+	addr->register_bit_width = 8;
+	addr->register_bit_offset = 0;
+	addr->address = resource->data.io.min_base_address;
+
+	return AE_OK;
+}
+
+
+static int
+acpi_ec_start (
+	struct acpi_device	*device)
+{
+	acpi_status		status = AE_OK;
+	struct acpi_ec		*ec = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_ec_start");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	ec = acpi_driver_data(device);
+
+	if (!ec)
+		return_VALUE(-EINVAL);
+
+	/*
+	 * Get I/O port addresses. Convert to GAS format.
+	 */
+	status = acpi_walk_resources(ec->handle, METHOD_NAME__CRS,
+		acpi_ec_io_ports, ec);
+	if (ACPI_FAILURE(status) || ec->command_addr.register_bit_width == 0) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error getting I/O port addresses"));
+		return_VALUE(-ENODEV);
+	}
+
+	ec->status_addr = ec->command_addr;
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02x, ports=0x%2x,0x%2x\n",
+		(u32) ec->gpe_bit, (u32) ec->command_addr.address,
+		(u32) ec->data_addr.address));
+
+	/*
+	 * Install GPE handler
+	 */
+	status = acpi_install_gpe_handler(NULL, ec->gpe_bit,
+		ACPI_EVENT_EDGE_TRIGGERED, &acpi_ec_gpe_handler, ec);
+	if (ACPI_FAILURE(status)) {
+		return_VALUE(-ENODEV);
+	}
+
+	status = acpi_install_address_space_handler (ec->handle,
+			ACPI_ADR_SPACE_EC, &acpi_ec_space_handler,
+			&acpi_ec_space_setup, ec);
+	if (ACPI_FAILURE(status)) {
+		acpi_remove_gpe_handler(NULL, ec->gpe_bit, &acpi_ec_gpe_handler);
+		return_VALUE(-ENODEV);
+	}
+
+	return_VALUE(AE_OK);
+}
+
+
+static int
+acpi_ec_stop (
+	struct acpi_device	*device,
+	int			type)
+{
+	acpi_status		status = AE_OK;
+	struct acpi_ec		*ec = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_ec_stop");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	ec = acpi_driver_data(device);
+
+	status = acpi_remove_address_space_handler(ec->handle,
+		ACPI_ADR_SPACE_EC, &acpi_ec_space_handler);
+	if (ACPI_FAILURE(status))
+		return_VALUE(-ENODEV);
+
+	status = acpi_remove_gpe_handler(NULL, ec->gpe_bit, &acpi_ec_gpe_handler);
+	if (ACPI_FAILURE(status))
+		return_VALUE(-ENODEV);
+
+	return_VALUE(0);
+}
+
+
+int __init
+acpi_ec_ecdt_probe (void)
+{
+	acpi_status		status;
+	struct acpi_table_ecdt 	*ecdt_ptr;
+
+	status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING, 
+		(struct acpi_table_header **) &ecdt_ptr);
+	if (ACPI_FAILURE(status))
+		return 0;
+
+	printk(KERN_INFO PREFIX "Found ECDT\n");
+
+	 /*
+	 * Generate a temporary ec context to use until the namespace is scanned
+	 */
+	ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
+	if (!ec_ecdt)
+		return -ENOMEM;
+	memset(ec_ecdt, 0, sizeof(struct acpi_ec));
+
+	ec_ecdt->command_addr = ecdt_ptr->ec_control;
+	ec_ecdt->status_addr = ecdt_ptr->ec_control;
+	ec_ecdt->data_addr = ecdt_ptr->ec_data;
+	ec_ecdt->gpe_bit = ecdt_ptr->gpe_bit;
+	ec_ecdt->lock = SPIN_LOCK_UNLOCKED;
+	/* use the GL just to be safe */
+	ec_ecdt->global_lock = TRUE;
+	ec_ecdt->uid = ecdt_ptr->uid;
+
+	status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->handle);
+	if (ACPI_FAILURE(status)) {
+		goto error;
+	}
+
+	/*
+	 * Install GPE handler
+	 */
+	status = acpi_install_gpe_handler(NULL, ec_ecdt->gpe_bit,
+		ACPI_EVENT_EDGE_TRIGGERED, &acpi_ec_gpe_handler,
+		ec_ecdt);
+	if (ACPI_FAILURE(status)) {
+		goto error;
+	}
+
+	status = acpi_install_address_space_handler (ACPI_ROOT_OBJECT,
+			ACPI_ADR_SPACE_EC, &acpi_ec_space_handler,
+			&acpi_ec_space_setup, ec_ecdt);
+	if (ACPI_FAILURE(status)) {
+		acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit,
+			&acpi_ec_gpe_handler);
+		goto error;
+	}
+
+	return 0;
+
+error:
+	printk(KERN_ERR PREFIX "Could not use ECDT\n");
+	kfree(ec_ecdt);
+	ec_ecdt = NULL;
+
+	return -ENODEV;
+}
+
+
+int __init
+acpi_ec_init (void)
+{
+	int			result = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_ec_init");
+
+	acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
+	if (!acpi_ec_dir)
+		return_VALUE(-ENODEV);
+
+	result = acpi_bus_register_driver(&acpi_ec_driver);
+	if (result < 0) {
+		remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
+		return_VALUE(-ENODEV);
+	}
+
+	return_VALUE(0);
+}
+
+/* EC can't be unloaded atm, so don't compile these */
+#if 0
+void __exit
+acpi_ec_exit (void)
+{
+	ACPI_FUNCTION_TRACE("acpi_ec_exit");
+
+	acpi_bus_unregister_driver(&acpi_ec_driver);
+
+	remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
+
+	return_VOID;
+}
+#endif /* 0 */
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/events/Makefile linux-2.4.22-pre2/drivers/acpi/events/Makefile
--- linux-2.4.21/drivers/acpi/events/Makefile	2001-06-21 00:47:39.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/events/Makefile	2003-06-26 21:43:10.000000000 +0000
@@ -1,11 +1,10 @@
 #
 # Makefile for all Linux ACPI interpreter subdirectories
-# EXCEPT for the ospm directory
 #
 
 O_TARGET := $(notdir $(CURDIR)).o
 
-obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/events/evevent.c linux-2.4.22-pre2/drivers/acpi/events/evevent.c
--- linux-2.4.21/drivers/acpi/events/evevent.c	2002-11-28 23:53:12.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/events/evevent.c	2003-06-26 21:43:31.000000000 +0000
@@ -1,49 +1,62 @@
 /******************************************************************************
  *
- * Module Name: evevent - Fixed and General Purpose Acpi_event
- *                          handling and dispatch
- *              $Revision: 51 $
+ * Module Name: evevent - Fixed Event handling and dispatch
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
-#include "acpi.h"
-#include "achware.h"
-#include "acevents.h"
-#include "acnamesp.h"
+#include <acpi/acpi.h>
+#include <acpi/acevents.h>
 
 #define _COMPONENT          ACPI_EVENTS
-	 MODULE_NAME         ("evevent")
+	 ACPI_MODULE_NAME    ("evevent")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_initialize
+ * FUNCTION:    acpi_ev_initialize
  *
  * PARAMETERS:  None
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Ensures that the system control interrupt (SCI) is properly
- *              configured, disables SCI event sources, installs the SCI
- *              handler
+ * DESCRIPTION: Initialize global data structures for events.
  *
  ******************************************************************************/
 
@@ -51,10 +64,10 @@
 acpi_ev_initialize (
 	void)
 {
-	acpi_status             status;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Ev_initialize");
+	ACPI_FUNCTION_TRACE ("ev_initialize");
 
 
 	/* Make sure we have ACPI tables */
@@ -64,48 +77,60 @@
 		return_ACPI_STATUS (AE_NO_ACPI_TABLES);
 	}
 
-
-	/* Make sure the BIOS supports ACPI mode */
-
-	if (SYS_MODE_LEGACY == acpi_hw_get_mode_capabilities()) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "ACPI Mode is not supported!\n"));
-		return_ACPI_STATUS (AE_ERROR);
-	}
-
-
-	acpi_gbl_original_mode = acpi_hw_get_mode();
-
 	/*
-	 * Initialize the Fixed and General Purpose Acpi_events prior. This is
-	 * done prior to enabling SCIs to prevent interrupts from occuring
-	 * before handers are installed.
+	 * Initialize the Fixed and General Purpose Events. This is
+	 * done prior to enabling SCIs to prevent interrupts from
+	 * occurring before handers are installed.
 	 */
 	status = acpi_ev_fixed_event_initialize ();
 	if (ACPI_FAILURE (status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_FATAL, "Unable to initialize fixed events.\n"));
+		ACPI_REPORT_ERROR ((
+				"Unable to initialize fixed events, %s\n",
+				acpi_format_exception (status)));
 		return_ACPI_STATUS (status);
 	}
 
 	status = acpi_ev_gpe_initialize ();
 	if (ACPI_FAILURE (status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_FATAL, "Unable to initialize general purpose events.\n"));
+		ACPI_REPORT_ERROR ((
+				"Unable to initialize general purpose events, %s\n",
+				acpi_format_exception (status)));
 		return_ACPI_STATUS (status);
 	}
 
-	/* Install the SCI handler */
+	return_ACPI_STATUS (status);
+}
 
-	status = acpi_ev_install_sci_handler ();
-	if (ACPI_FAILURE (status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_FATAL, "Unable to install System Control Interrupt Handler\n"));
-		return_ACPI_STATUS (status);
-	}
 
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ev_handler_initialize
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Install interrupt handlers for the SCI and Global Lock
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ev_handler_initialize (
+	void)
+{
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_TRACE ("ev_handler_initialize");
 
-	/* Install handlers for control method GPE handlers (_Lxx, _Exx) */
 
-	status = acpi_ev_init_gpe_control_methods ();
+	/* Install the SCI handler */
+
+	status = acpi_ev_install_sci_handler ();
 	if (ACPI_FAILURE (status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_FATAL, "Unable to initialize Gpe control methods\n"));
+		ACPI_REPORT_ERROR ((
+				"Unable to install System Control Interrupt Handler, %s\n",
+				acpi_format_exception (status)));
 		return_ACPI_STATUS (status);
 	}
 
@@ -113,44 +138,55 @@
 
 	status = acpi_ev_init_global_lock_handler ();
 	if (ACPI_FAILURE (status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_FATAL, "Unable to initialize Global Lock handler\n"));
+		ACPI_REPORT_ERROR ((
+				"Unable to initialize Global Lock handler, %s\n",
+				acpi_format_exception (status)));
 		return_ACPI_STATUS (status);
 	}
 
-
+	acpi_gbl_events_initialized = TRUE;
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_fixed_event_initialize
+ * FUNCTION:    acpi_ev_fixed_event_initialize
  *
  * PARAMETERS:  None
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Initialize the Fixed Acpi_event data structures
+ * DESCRIPTION: Install the fixed event handlers and enable the fixed events.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_ev_fixed_event_initialize(void)
+acpi_ev_fixed_event_initialize (
+	void)
 {
-	int                     i = 0;
+	acpi_native_uint                i;
+	acpi_status                     status;
 
-	/* Initialize the structure that keeps track of fixed event handlers */
 
+	/*
+	 * Initialize the structure that keeps track of fixed event handlers
+	 * and enable the fixed events.
+	 */
 	for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
 		acpi_gbl_fixed_event_handlers[i].handler = NULL;
 		acpi_gbl_fixed_event_handlers[i].context = NULL;
-	}
 
-	acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, TMR_EN, 0);
-	acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, GBL_EN, 0);
-	acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, PWRBTN_EN, 0);
-	acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, SLPBTN_EN, 0);
-	acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, RTC_EN, 0);
+		/* Enable the fixed event */
+
+		if (acpi_gbl_fixed_event_info[i].enable_register_id != 0xFF) {
+			status = acpi_set_register (acpi_gbl_fixed_event_info[i].enable_register_id,
+					 0, ACPI_MTX_LOCK);
+			if (ACPI_FAILURE (status)) {
+				return (status);
+			}
+		}
+	}
 
 	return (AE_OK);
 }
@@ -158,7 +194,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_fixed_event_detect
+ * FUNCTION:    acpi_ev_fixed_event_detect
  *
  * PARAMETERS:  None
  *
@@ -169,54 +205,41 @@
  ******************************************************************************/
 
 u32
-acpi_ev_fixed_event_detect (void)
+acpi_ev_fixed_event_detect (
+	void)
 {
-	u32                     int_status = INTERRUPT_NOT_HANDLED;
-	u32                     status_register;
-	u32                     enable_register;
+	u32                             int_status = ACPI_INTERRUPT_NOT_HANDLED;
+	u32                             fixed_status;
+	u32                             fixed_enable;
+	acpi_native_uint                i;
 
 
-	PROC_NAME ("Ev_fixed_event_detect");
+	ACPI_FUNCTION_NAME ("ev_fixed_event_detect");
 
 
 	/*
 	 * Read the fixed feature status and enable registers, as all the cases
-	 * depend on their values.
+	 * depend on their values.  Ignore errors here.
 	 */
-	status_register = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, PM1_STS);
-	enable_register = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, PM1_EN);
+	(void) acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS, &fixed_status);
+	(void) acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_ENABLE, &fixed_enable);
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
-		"Fixed Acpi_event Block: Enable %08X Status %08X\n",
-		enable_register, status_register));
-
+		"Fixed Event Block: Enable %08X Status %08X\n",
+		fixed_enable, fixed_status));
 
-	/* power management timer roll over */
-
-	if ((status_register & ACPI_STATUS_PMTIMER) &&
-		(enable_register & ACPI_ENABLE_PMTIMER)) {
-		int_status |= acpi_ev_fixed_event_dispatch (ACPI_EVENT_PMTIMER);
-	}
-
-	/* global event (BIOS wants the global lock) */
-
-	if ((status_register & ACPI_STATUS_GLOBAL) &&
-		(enable_register & ACPI_ENABLE_GLOBAL)) {
-		int_status |= acpi_ev_fixed_event_dispatch (ACPI_EVENT_GLOBAL);
-	}
-
-	/* power button event */
-
-	if ((status_register & ACPI_STATUS_POWER_BUTTON) &&
-		(enable_register & ACPI_ENABLE_POWER_BUTTON)) {
-		int_status |= acpi_ev_fixed_event_dispatch (ACPI_EVENT_POWER_BUTTON);
-	}
+	/*
+	 * Check for all possible Fixed Events and dispatch those that are active
+	 */
+	for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
+		/* Both the status and enable bits must be on for this event */
 
-	/* sleep button event */
+		if ((fixed_status & acpi_gbl_fixed_event_info[i].status_bit_mask) &&
+			(fixed_enable & acpi_gbl_fixed_event_info[i].enable_bit_mask)) {
+			/* Found an active (signalled) event */
 
-	if ((status_register & ACPI_STATUS_SLEEP_BUTTON) &&
-		(enable_register & ACPI_ENABLE_SLEEP_BUTTON)) {
-		int_status |= acpi_ev_fixed_event_dispatch (ACPI_EVENT_SLEEP_BUTTON);
+			int_status |= acpi_ev_fixed_event_dispatch ((u32) i);
+		}
 	}
 
 	return (int_status);
@@ -225,7 +248,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_fixed_event_dispatch
+ * FUNCTION:    acpi_ev_fixed_event_dispatch
  *
  * PARAMETERS:  Event               - Event type
  *
@@ -238,590 +261,37 @@
 
 u32
 acpi_ev_fixed_event_dispatch (
-	u32                     event)
+	u32                             event)
 {
-	u32                     register_id;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/* Clear the status bit */
 
-	switch (event) {
-	case ACPI_EVENT_PMTIMER:
-		register_id = TMR_STS;
-		break;
-
-	case ACPI_EVENT_GLOBAL:
-		register_id = GBL_STS;
-		break;
-
-	case ACPI_EVENT_POWER_BUTTON:
-		register_id = PWRBTN_STS;
-		break;
-
-	case ACPI_EVENT_SLEEP_BUTTON:
-		register_id = SLPBTN_STS;
-		break;
-
-	case ACPI_EVENT_RTC:
-		register_id = RTC_STS;
-		break;
-
-	default:
-		return 0;
-		break;
-	}
-
-	acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK, register_id, 1);
+	(void) acpi_set_register (acpi_gbl_fixed_event_info[event].status_register_id,
+			 1, ACPI_MTX_DO_NOT_LOCK);
 
 	/*
 	 * Make sure we've got a handler.  If not, report an error.
 	 * The event is disabled to prevent further interrupts.
 	 */
 	if (NULL == acpi_gbl_fixed_event_handlers[event].handler) {
-		register_id = (PM1_EN | REGISTER_BIT_ID(register_id));
+		(void) acpi_set_register (acpi_gbl_fixed_event_info[event].enable_register_id,
+				0, ACPI_MTX_DO_NOT_LOCK);
 
-		acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK,
-				 register_id, 0);
-
-		REPORT_ERROR (
-			("Ev_gpe_dispatch: No installed handler for fixed event [%08X]\n",
+		ACPI_REPORT_ERROR (
+			("No installed handler for fixed event [%08X]\n",
 			event));
 
-		return (INTERRUPT_NOT_HANDLED);
+		return (ACPI_INTERRUPT_NOT_HANDLED);
 	}
 
-	/* Invoke the handler */
+	/* Invoke the Fixed Event handler */
 
 	return ((acpi_gbl_fixed_event_handlers[event].handler)(
 			  acpi_gbl_fixed_event_handlers[event].context));
 }
 
 
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ev_gpe_initialize
- *
- * PARAMETERS:  None
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Initialize the GPE data structures
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ev_gpe_initialize (void)
-{
-	u32                     i;
-	u32                     j;
-	u32                     register_index;
-	u32                     gpe_number;
-	u16                     gpe0register_count;
-	u16                     gpe1_register_count;
-
-
-	FUNCTION_TRACE ("Ev_gpe_initialize");
-
-	/*
-	 * Set up various GPE counts
-	 *
-	 * You may ask,why are the GPE register block lengths divided by 2?
-	 * From the ACPI 2.0 Spec, section, 4.7.1.6 General-Purpose Event
-	 * Registers, we have,
-	 *
-	 * "Each register block contains two registers of equal length
-	 * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the
-	 * GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN
-	 * The length of the GPE1_STS and GPE1_EN registers is equal to
-	 * half the GPE1_LEN. If a generic register block is not supported
-	 * then its respective block pointer and block length values in the
-	 * FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need
-	 * to be the same size."
-	 */
-	gpe0register_count          = (u16) DIV_2 (acpi_gbl_FADT->gpe0blk_len);
-	gpe1_register_count         = (u16) DIV_2 (acpi_gbl_FADT->gpe1_blk_len);
-	acpi_gbl_gpe_register_count = gpe0register_count + gpe1_register_count;
-
-	if (!acpi_gbl_gpe_register_count) {
-		REPORT_WARNING (("Zero GPEs are defined in the FADT\n"));
-		return_ACPI_STATUS (AE_OK);
-	}
-
-	/*
-	 * Allocate the Gpe information block
-	 */
-	acpi_gbl_gpe_registers = ACPI_MEM_CALLOCATE (acpi_gbl_gpe_register_count *
-			  sizeof (acpi_gpe_registers));
-	if (!acpi_gbl_gpe_registers) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-			"Could not allocate the Gpe_registers block\n"));
-		return_ACPI_STATUS (AE_NO_MEMORY);
-	}
-
-	/*
-	 * Allocate the Gpe dispatch handler block
-	 * There are eight distinct GP events per register.
-	 * Initialization to zeros is sufficient
-	 */
-	acpi_gbl_gpe_info = ACPI_MEM_CALLOCATE (MUL_8 (acpi_gbl_gpe_register_count) *
-			  sizeof (acpi_gpe_level_info));
-	if (!acpi_gbl_gpe_info) {
-		ACPI_MEM_FREE (acpi_gbl_gpe_registers);
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not allocate the Gpe_info block\n"));
-		return_ACPI_STATUS (AE_NO_MEMORY);
-	}
-
-	/* Set the Gpe validation table to GPE_INVALID */
-
-	MEMSET (acpi_gbl_gpe_valid, (int) ACPI_GPE_INVALID, ACPI_NUM_GPE);
-
-	/*
-	 * Initialize the Gpe information and validation blocks.  A goal of these
-	 * blocks is to hide the fact that there are two separate GPE register sets
-	 * In a given block, the status registers occupy the first half, and
-	 * the enable registers occupy the second half.
-	 */
-
-	/* GPE Block 0 */
-
-	register_index = 0;
-
-	for (i = 0; i < gpe0register_count; i++) {
-		acpi_gbl_gpe_registers[register_index].status_addr =
-				 (u16) (ACPI_GET_ADDRESS (acpi_gbl_FADT->Xgpe0blk.address) + i);
-
-		acpi_gbl_gpe_registers[register_index].enable_addr =
-				 (u16) (ACPI_GET_ADDRESS (acpi_gbl_FADT->Xgpe0blk.address) + i + gpe0register_count);
-
-		acpi_gbl_gpe_registers[register_index].gpe_base = (u8) MUL_8 (i);
-
-		for (j = 0; j < 8; j++) {
-			gpe_number = acpi_gbl_gpe_registers[register_index].gpe_base + j;
-			acpi_gbl_gpe_valid[gpe_number] = (u8) register_index;
-		}
-
-		/*
-		 * Clear the status/enable registers.  Note that status registers
-		 * are cleared by writing a '1', while enable registers are cleared
-		 * by writing a '0'.
-		 */
-		acpi_os_write_port (acpi_gbl_gpe_registers[register_index].enable_addr, 0x00, 8);
-		acpi_os_write_port (acpi_gbl_gpe_registers[register_index].status_addr, 0xFF, 8);
-
-		register_index++;
-	}
-
-	/* GPE Block 1 */
-
-	for (i = 0; i < gpe1_register_count; i++) {
-		acpi_gbl_gpe_registers[register_index].status_addr =
-				 (u16) (ACPI_GET_ADDRESS (acpi_gbl_FADT->Xgpe1_blk.address) + i);
-
-		acpi_gbl_gpe_registers[register_index].enable_addr =
-				 (u16) (ACPI_GET_ADDRESS (acpi_gbl_FADT->Xgpe1_blk.address) + i + gpe1_register_count);
-
-		acpi_gbl_gpe_registers[register_index].gpe_base =
-				 (u8) (acpi_gbl_FADT->gpe1_base + MUL_8 (i));
-
-		for (j = 0; j < 8; j++) {
-			gpe_number = acpi_gbl_gpe_registers[register_index].gpe_base + j;
-			acpi_gbl_gpe_valid[gpe_number] = (u8) register_index;
-		}
-
-		/*
-		 * Clear the status/enable registers.  Note that status registers
-		 * are cleared by writing a '1', while enable registers are cleared
-		 * by writing a '0'.
-		 */
-		acpi_os_write_port (acpi_gbl_gpe_registers[register_index].enable_addr, 0x00, 8);
-		acpi_os_write_port (acpi_gbl_gpe_registers[register_index].status_addr, 0xFF, 8);
-
-		register_index++;
-	}
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "GPE registers: %X@%8.8X%8.8X (Blk0) %X@%8.8X%8.8X (Blk1)\n",
-		gpe0register_count, HIDWORD(acpi_gbl_FADT->Xgpe0blk.address), LODWORD(acpi_gbl_FADT->Xgpe0blk.address),
-		gpe1_register_count, HIDWORD(acpi_gbl_FADT->Xgpe1_blk.address), LODWORD(acpi_gbl_FADT->Xgpe1_blk.address)));
-
-	return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ev_save_method_info
- *
- * PARAMETERS:  None
- *
- * RETURN:      None
- *
- * DESCRIPTION: Called from Acpi_walk_namespace. Expects each object to be a
- *              control method under the _GPE portion of the namespace.
- *              Extract the name and GPE type from the object, saving this
- *              information for quick lookup during GPE dispatch
- *
- *              The name of each GPE control method is of the form:
- *                  "_Lnn" or "_Enn"
- *              Where:
- *                  L      - means that the GPE is level triggered
- *                  E      - means that the GPE is edge triggered
- *                  nn     - is the GPE number
- *
- ******************************************************************************/
-
-static acpi_status
-acpi_ev_save_method_info (
-	acpi_handle             obj_handle,
-	u32                     level,
-	void                    *obj_desc,
-	void                    **return_value)
-{
-	u32                     gpe_number;
-	NATIVE_CHAR             name[ACPI_NAME_SIZE + 1];
-	u8                      type;
-
-
-	PROC_NAME ("Ev_save_method_info");
-
-
-	/* Extract the name from the object and convert to a string */
-
-	MOVE_UNALIGNED32_TO_32 (name, &((acpi_namespace_node *) obj_handle)->name);
-	name[ACPI_NAME_SIZE] = 0;
-
-	/*
-	 * Edge/Level determination is based on the 2nd s8 of the method name
-	 */
-	if (name[1] == 'L') {
-		type = ACPI_EVENT_LEVEL_TRIGGERED;
-	}
-	else if (name[1] == 'E') {
-		type = ACPI_EVENT_EDGE_TRIGGERED;
-	}
-	else {
-		/* Unknown method type, just ignore it! */
-
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-			"Unknown GPE method type: %s (name not of form _Lnn or _Enn)\n",
-			name));
-		return (AE_OK);
-	}
-
-	/* Convert the last two characters of the name to the Gpe Number */
-
-	gpe_number = STRTOUL (&name[2], NULL, 16);
-	if (gpe_number == ACPI_UINT32_MAX) {
-		/* Conversion failed; invalid method, just ignore it */
-
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-			"Could not extract GPE number from name: %s (name not of form _Lnn or _Enn)\n",
-			name));
-		return (AE_OK);
-	}
-
-	/* Ensure that we have a valid GPE number */
-
-	if (acpi_gbl_gpe_valid[gpe_number] == ACPI_GPE_INVALID) {
-		/* Not valid, all we can do here is ignore it */
-
-		return (AE_OK);
-	}
-
-	/*
-	 * Now we can add this information to the Gpe_info block
-	 * for use during dispatch of this GPE.
-	 */
-	acpi_gbl_gpe_info [gpe_number].type         = type;
-	acpi_gbl_gpe_info [gpe_number].method_handle = obj_handle;
-
-
-	/*
-	 * Enable the GPE (SCIs should be disabled at this point)
-	 */
-	acpi_hw_enable_gpe (gpe_number);
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Registered GPE method %s as GPE number %X\n",
-		name, gpe_number));
-	return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ev_init_gpe_control_methods
- *
- * PARAMETERS:  None
- *
- * RETURN:      None
- *
- * DESCRIPTION: Obtain the control methods associated with the GPEs.
- *
- *              NOTE: Must be called AFTER namespace initialization!
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ev_init_gpe_control_methods (void)
-{
-	acpi_status             status;
-
-
-	FUNCTION_TRACE ("Ev_init_gpe_control_methods");
-
-
-	/* Get a permanent handle to the _GPE object */
-
-	status = acpi_get_handle (NULL, "\\_GPE", &acpi_gbl_gpe_obj_handle);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
-
-	/* Traverse the namespace under \_GPE to find all methods there */
-
-	status = acpi_walk_namespace (ACPI_TYPE_METHOD, acpi_gbl_gpe_obj_handle,
-			  ACPI_UINT32_MAX, acpi_ev_save_method_info,
-			  NULL, NULL);
-
-	return_ACPI_STATUS (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ev_gpe_detect
- *
- * PARAMETERS:  None
- *
- * RETURN:      INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
- *
- * DESCRIPTION: Detect if any GP events have occurred
- *
- ******************************************************************************/
-
-u32
-acpi_ev_gpe_detect (void)
-{
-	u32                     int_status = INTERRUPT_NOT_HANDLED;
-	u32                     i;
-	u32                     j;
-	u8                      enabled_status_byte;
-	u8                      bit_mask;
-
-
-	PROC_NAME ("Ev_gpe_detect");
-
-
-	/*
-	 * Read all of the 8-bit GPE status and enable registers
-	 * in both of the register blocks, saving all of it.
-	 * Find all currently active GP events.
-	 */
-	for (i = 0; i < acpi_gbl_gpe_register_count; i++) {
-		acpi_os_read_port (acpi_gbl_gpe_registers[i].status_addr,
-				&acpi_gbl_gpe_registers[i].status, 8);
-
-		acpi_os_read_port (acpi_gbl_gpe_registers[i].enable_addr,
-				&acpi_gbl_gpe_registers[i].enable, 8);
-
-		ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
-			"GPE block at %X - Enable %08X Status %08X\n",
-			acpi_gbl_gpe_registers[i].enable_addr,
-			acpi_gbl_gpe_registers[i].status,
-			acpi_gbl_gpe_registers[i].enable));
-
-		/* First check if there is anything active at all in this register */
-
-		enabled_status_byte = (u8) (acpi_gbl_gpe_registers[i].status &
-				   acpi_gbl_gpe_registers[i].enable);
-
-		if (!enabled_status_byte) {
-			/* No active GPEs in this register, move on */
-
-			continue;
-		}
-
-		/* Now look at the individual GPEs in this byte register */
-
-		for (j = 0, bit_mask = 1; j < 8; j++, bit_mask <<= 1) {
-			/* Examine one GPE bit */
-
-			if (enabled_status_byte & bit_mask) {
-				/*
-				 * Found an active GPE.  Dispatch the event to a handler
-				 * or method.
-				 */
-				int_status |= acpi_ev_gpe_dispatch (
-						  acpi_gbl_gpe_registers[i].gpe_base + j);
-			}
-		}
-	}
-
-	return (int_status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ev_asynch_execute_gpe_method
- *
- * PARAMETERS:  Gpe_number      - The 0-based Gpe number
- *
- * RETURN:      None
- *
- * DESCRIPTION: Perform the actual execution of a GPE control method.  This
- *              function is called from an invocation of Acpi_os_queue_for_execution
- *              (and therefore does NOT execute at interrupt level) so that
- *              the control method itself is not executed in the context of
- *              the SCI interrupt handler.
- *
- ******************************************************************************/
-
-static void
-acpi_ev_asynch_execute_gpe_method (
-	void                    *context)
-{
-	unsigned long           gpe_number = (unsigned long) context;
-	acpi_gpe_level_info     gpe_info;
-
-
-	FUNCTION_TRACE ("Ev_asynch_execute_gpe_method");
-
-	/*
-	 * Take a snapshot of the GPE info for this level
-	 */
-	acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
-	gpe_info = acpi_gbl_gpe_info [gpe_number];
-	acpi_ut_release_mutex (ACPI_MTX_EVENTS);
-
-	/*
-	 * Method Handler (_Lxx, _Exx):
-	 * ----------------------------
-	 * Evaluate the _Lxx/_Exx control method that corresponds to this GPE.
-	 */
-	if (gpe_info.method_handle) {
-		acpi_ns_evaluate_by_handle (gpe_info.method_handle, NULL, NULL);
-	}
-
-	/*
-	 * Level-Triggered?
-	 * ----------------
-	 * If level-triggered we clear the GPE status bit after handling the event.
-	 */
-	if (gpe_info.type & ACPI_EVENT_LEVEL_TRIGGERED) {
-		acpi_hw_clear_gpe (gpe_number);
-	}
-
-	/*
-	 * Enable the GPE.
-	 */
-	acpi_hw_enable_gpe (gpe_number);
-
-	return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ev_gpe_dispatch
- *
- * PARAMETERS:  Gpe_number      - The 0-based Gpe number
- *
- * RETURN:      INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
- *
- * DESCRIPTION: Handle and dispatch a General Purpose Acpi_event.
- *              Clears the status bit for the requested event.
- *
- * TBD: [Investigate] is this still valid or necessary:
- * The Gpe handler differs from the fixed events in that it clears the enable
- * bit rather than the status bit to clear the interrupt.  This allows
- * software outside of interrupt context to determine what caused the SCI and
- * dispatch the correct AML.
- *
- ******************************************************************************/
-
-u32
-acpi_ev_gpe_dispatch (
-	u32                     gpe_number)
-{
-	acpi_gpe_level_info     gpe_info;
-
-
-	FUNCTION_TRACE ("Ev_gpe_dispatch");
-
-
-	/*
-	 * Valid GPE number?
-	 */
-	if (acpi_gbl_gpe_valid[gpe_number] == ACPI_GPE_INVALID) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid GPE bit [%X].\n", gpe_number));
-		return_VALUE (INTERRUPT_NOT_HANDLED);
-	}
-
-	/*
-	 * Disable the GPE.
-	 */
-	acpi_hw_disable_gpe (gpe_number);
-
-	gpe_info = acpi_gbl_gpe_info [gpe_number];
-
-	/*
-	 * Edge-Triggered?
-	 * ---------------
-	 * If edge-triggered, clear the GPE status bit now.  Note that
-	 * level-triggered events are cleared after the GPE is serviced.
-	 */
-	if (gpe_info.type & ACPI_EVENT_EDGE_TRIGGERED) {
-		acpi_hw_clear_gpe (gpe_number);
-	}
-		/*
-		 * Function Handler (e.g. EC)?
-		 */
-	if (gpe_info.handler) {
-		/* Invoke function handler (at interrupt level). */
-
-		gpe_info.handler (gpe_info.context);
-
-		/* Level-Triggered? */
-
-		if (gpe_info.type & ACPI_EVENT_LEVEL_TRIGGERED) {
-			acpi_hw_clear_gpe (gpe_number);
-		}
-
-		/* Enable GPE */
-
-		acpi_hw_enable_gpe (gpe_number);
-	}
-
-	/*
-	 * Method Handler (e.g. _Exx/_Lxx)?
-	 */
-	else if (gpe_info.method_handle) {
-		if (ACPI_FAILURE(acpi_os_queue_for_execution (OSD_PRIORITY_GPE,
-			acpi_ev_asynch_execute_gpe_method, (void*) (u64)gpe_number))) {
-			/*
-			 * Shoudn't occur, but if it does report an error. Note that
-			 * the GPE will remain disabled until the ACPI Core Subsystem
-			 * is restarted, or the handler is removed/reinstalled.
-			 */
-			REPORT_ERROR (("Acpi_ev_gpe_dispatch: Unable to queue handler for GPE bit [%X]\n", gpe_number));
-		}
-	}
-
-	/*
-	 * No Handler? Report an error and leave the GPE disabled.
-	 */
-	else {
-		REPORT_ERROR (("Acpi_ev_gpe_dispatch: No installed handler for GPE [%X]\n", gpe_number));
-
-		/* Level-Triggered? */
-
-		if (gpe_info.type & ACPI_EVENT_LEVEL_TRIGGERED) {
-			acpi_hw_clear_gpe (gpe_number);
-		}
-	}
-
-	return_VALUE (INTERRUPT_HANDLED);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/events/evgpe.c linux-2.4.22-pre2/drivers/acpi/events/evgpe.c
--- linux-2.4.21/drivers/acpi/events/evgpe.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/events/evgpe.c	2003-06-26 21:43:12.000000000 +0000
@@ -0,0 +1,425 @@
+/******************************************************************************
+ *
+ * Module Name: evgpe - General Purpose Event handling and dispatch
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#include <acpi/acpi.h>
+#include <acpi/acevents.h>
+#include <acpi/acnamesp.h>
+
+#define _COMPONENT          ACPI_EVENTS
+	 ACPI_MODULE_NAME    ("evgpe")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ev_get_gpe_event_info
+ *
+ * PARAMETERS:  gpe_device          - Device node.  NULL for GPE0/GPE1
+ *              gpe_number          - Raw GPE number
+ *
+ * RETURN:      A GPE event_info struct. NULL if not a valid GPE
+ *
+ * DESCRIPTION: Returns the event_info struct associated with this GPE.
+ *              Validates the gpe_block and the gpe_number
+ *
+ *              Should be called only when the GPE lists are semaphore locked
+ *              and not subject to change.
+ *
+ ******************************************************************************/
+
+struct acpi_gpe_event_info *
+acpi_ev_get_gpe_event_info (
+	acpi_handle                     gpe_device,
+	u32                             gpe_number)
+{
+	union acpi_operand_object       *obj_desc;
+	struct acpi_gpe_block_info      *gpe_block;
+	acpi_native_uint                i;
+
+
+	ACPI_FUNCTION_ENTRY ();
+
+
+	/* A NULL gpe_block means use the FADT-defined GPE block(s) */
+
+	if (!gpe_device) {
+		/* Examine GPE Block 0 and 1 (These blocks are permanent) */
+
+		for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) {
+			gpe_block = acpi_gbl_gpe_fadt_blocks[i];
+			if (gpe_block) {
+				if ((gpe_number >= gpe_block->block_base_number) &&
+					(gpe_number < gpe_block->block_base_number + (gpe_block->register_count * 8))) {
+					return (&gpe_block->event_info[gpe_number - gpe_block->block_base_number]);
+				}
+			}
+		}
+
+		/* The gpe_number was not in the range of either FADT GPE block */
+
+		return (NULL);
+	}
+
+	/*
+	 * A Non-null gpe_device means this is a GPE Block Device.
+	 */
+	obj_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) gpe_device);
+	if (!obj_desc ||
+		!obj_desc->device.gpe_block) {
+		return (NULL);
+	}
+
+	gpe_block = obj_desc->device.gpe_block;
+
+	if ((gpe_number >= gpe_block->block_base_number) &&
+		(gpe_number < gpe_block->block_base_number + (gpe_block->register_count * 8))) {
+		return (&gpe_block->event_info[gpe_number - gpe_block->block_base_number]);
+	}
+
+	return (NULL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ev_gpe_detect
+ *
+ * PARAMETERS:  gpe_xrupt_list      - Interrupt block for this interrupt.
+ *                                    Can have multiple GPE blocks attached.
+ *
+ * RETURN:      INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
+ *
+ * DESCRIPTION: Detect if any GP events have occurred.  This function is
+ *              executed at interrupt level.
+ *
+ ******************************************************************************/
+
+u32
+acpi_ev_gpe_detect (
+	struct acpi_gpe_xrupt_info      *gpe_xrupt_list)
+{
+	u32                             int_status = ACPI_INTERRUPT_NOT_HANDLED;
+	u8                              enabled_status_byte;
+	u8                              bit_mask;
+	struct acpi_gpe_register_info   *gpe_register_info;
+	u32                             in_value;
+	acpi_status                     status;
+	struct acpi_gpe_block_info      *gpe_block;
+	u32                             gpe_number;
+	u32                             i;
+	u32                             j;
+
+
+	ACPI_FUNCTION_NAME ("ev_gpe_detect");
+
+
+	/* Examine all GPE blocks attached to this interrupt level */
+
+	acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_ISR);
+	gpe_block = gpe_xrupt_list->gpe_block_list_head;
+	while (gpe_block) {
+		/*
+		 * Read all of the 8-bit GPE status and enable registers
+		 * in this GPE block, saving all of them.
+		 * Find all currently active GP events.
+		 */
+		for (i = 0; i < gpe_block->register_count; i++) {
+			/* Get the next status/enable pair */
+
+			gpe_register_info = &gpe_block->register_info[i];
+
+			/* Read the Status Register */
+
+			status = acpi_hw_low_level_read (ACPI_GPE_REGISTER_WIDTH, &in_value,
+					 &gpe_register_info->status_address);
+			gpe_register_info->status = (u8) in_value;
+			if (ACPI_FAILURE (status)) {
+				goto unlock_and_exit;
+			}
+
+			/* Read the Enable Register */
+
+			status = acpi_hw_low_level_read (ACPI_GPE_REGISTER_WIDTH, &in_value,
+					 &gpe_register_info->enable_address);
+			gpe_register_info->enable = (u8) in_value;
+			if (ACPI_FAILURE (status)) {
+				goto unlock_and_exit;
+			}
+
+			ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
+				"GPE pair: Status %8.8X%8.8X = %02X, Enable %8.8X%8.8X = %02X\n",
+				ACPI_HIDWORD (gpe_register_info->status_address.address),
+				ACPI_LODWORD (gpe_register_info->status_address.address),
+				gpe_register_info->status,
+				ACPI_HIDWORD (gpe_register_info->enable_address.address),
+				ACPI_LODWORD (gpe_register_info->enable_address.address),
+				gpe_register_info->enable));
+
+			/* First check if there is anything active at all in this register */
+
+			enabled_status_byte = (u8) (gpe_register_info->status &
+					   gpe_register_info->enable);
+			if (!enabled_status_byte) {
+				/* No active GPEs in this register, move on */
+
+				continue;
+			}
+
+			/* Now look at the individual GPEs in this byte register */
+
+			for (j = 0, bit_mask = 1; j < ACPI_GPE_REGISTER_WIDTH; j++, bit_mask <<= 1) {
+				/* Examine one GPE bit */
+
+				if (enabled_status_byte & bit_mask) {
+					/*
+					 * Found an active GPE. Dispatch the event to a handler
+					 * or method.
+					 */
+					gpe_number = (i * ACPI_GPE_REGISTER_WIDTH) + j;
+
+					int_status |= acpi_ev_gpe_dispatch (
+							  &gpe_block->event_info[gpe_number],
+							  gpe_number + gpe_block->register_info[gpe_number].base_gpe_number);
+				}
+			}
+		}
+
+		gpe_block = gpe_block->next;
+	}
+
+unlock_and_exit:
+
+	acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_ISR);
+	return (int_status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ev_asynch_execute_gpe_method
+ *
+ * PARAMETERS:  Context (gpe_event_info) - Info for this GPE
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Perform the actual execution of a GPE control method.  This
+ *              function is called from an invocation of acpi_os_queue_for_execution
+ *              (and therefore does NOT execute at interrupt level) so that
+ *              the control method itself is not executed in the context of
+ *              an interrupt handler.
+ *
+ ******************************************************************************/
+
+static void ACPI_SYSTEM_XFACE
+acpi_ev_asynch_execute_gpe_method (
+	void                            *context)
+{
+	struct acpi_gpe_event_info      *gpe_event_info = (void *) context;
+	u32                             gpe_number = 0;
+	acpi_status                     status;
+	struct acpi_gpe_event_info      local_gpe_event_info;
+
+
+	ACPI_FUNCTION_TRACE ("ev_asynch_execute_gpe_method");
+
+
+	status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+	if (ACPI_FAILURE (status)) {
+		return_VOID;
+	}
+
+	/* Must revalidate the gpe_number/gpe_block */
+
+	if (!acpi_ev_valid_gpe_event (gpe_event_info)) {
+		status = acpi_ut_release_mutex (ACPI_MTX_EVENTS);
+		return_VOID;
+	}
+
+	/*
+	 * Take a snapshot of the GPE info for this level - we copy the
+	 * info to prevent a race condition with remove_handler/remove_block.
+	 */
+	ACPI_MEMCPY (&local_gpe_event_info, gpe_event_info, sizeof (struct acpi_gpe_event_info));
+
+	status = acpi_ut_release_mutex (ACPI_MTX_EVENTS);
+	if (ACPI_FAILURE (status)) {
+		return_VOID;
+	}
+
+	if (local_gpe_event_info.method_node) {
+		/*
+		 * Invoke the GPE Method (_Lxx, _Exx):
+		 * (Evaluate the _Lxx/_Exx control method that corresponds to this GPE.)
+		 */
+		status = acpi_ns_evaluate_by_handle (local_gpe_event_info.method_node, NULL, NULL);
+		if (ACPI_FAILURE (status)) {
+			ACPI_REPORT_ERROR (("%s while evaluating method [%4.4s] for GPE[%2X]\n",
+				acpi_format_exception (status),
+				local_gpe_event_info.method_node->name.ascii, gpe_number));
+		}
+	}
+
+	if (local_gpe_event_info.flags & ACPI_EVENT_LEVEL_TRIGGERED) {
+		/*
+		 * GPE is level-triggered, we clear the GPE status bit after handling
+		 * the event.
+		 */
+		status = acpi_hw_clear_gpe (&local_gpe_event_info);
+		if (ACPI_FAILURE (status)) {
+			return_VOID;
+		}
+	}
+
+	/* Enable this GPE */
+
+	(void) acpi_hw_enable_gpe (&local_gpe_event_info);
+	return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ev_gpe_dispatch
+ *
+ * PARAMETERS:  gpe_event_info  - info for this GPE
+ *              gpe_number      - Number relative to the parent GPE block
+ *
+ * RETURN:      INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
+ *
+ * DESCRIPTION: Dispatch a General Purpose Event to either a function (e.g. EC)
+ *              or method (e.g. _Lxx/_Exx) handler.
+ *
+ *              This function executes at interrupt level.
+ *
+ ******************************************************************************/
+
+u32
+acpi_ev_gpe_dispatch (
+	struct acpi_gpe_event_info      *gpe_event_info,
+	u32                             gpe_number)
+{
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_TRACE ("ev_gpe_dispatch");
+
+
+	/*
+	 * If edge-triggered, clear the GPE status bit now.  Note that
+	 * level-triggered events are cleared after the GPE is serviced.
+	 */
+	if (gpe_event_info->flags & ACPI_EVENT_EDGE_TRIGGERED) {
+		status = acpi_hw_clear_gpe (gpe_event_info);
+		if (ACPI_FAILURE (status)) {
+			ACPI_REPORT_ERROR (("acpi_ev_gpe_dispatch: Unable to clear GPE[%2X]\n",
+				gpe_number));
+			return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
+		}
+	}
+
+	/*
+	 * Dispatch the GPE to either an installed handler, or the control
+	 * method associated with this GPE (_Lxx or _Exx).
+	 * If a handler exists, we invoke it and do not attempt to run the method.
+	 * If there is neither a handler nor a method, we disable the level to
+	 * prevent further events from coming in here.
+	 */
+	if (gpe_event_info->handler) {
+		/* Invoke the installed handler (at interrupt level) */
+
+		gpe_event_info->handler (gpe_event_info->context);
+	}
+	else if (gpe_event_info->method_node) {
+		/*
+		 * Disable GPE, so it doesn't keep firing before the method has a
+		 * chance to run.
+		 */
+		status = acpi_hw_disable_gpe (gpe_event_info);
+		if (ACPI_FAILURE (status)) {
+			ACPI_REPORT_ERROR (("acpi_ev_gpe_dispatch: Unable to disable GPE[%2X]\n",
+				gpe_number));
+			return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
+		}
+
+		/* Execute the method associated with the GPE. */
+
+		if (ACPI_FAILURE (acpi_os_queue_for_execution (OSD_PRIORITY_GPE,
+				 acpi_ev_asynch_execute_gpe_method,
+				 gpe_event_info))) {
+			ACPI_REPORT_ERROR ((
+				"acpi_ev_gpe_dispatch: Unable to queue handler for GPE[%2X], event is disabled\n",
+				gpe_number));
+		}
+	}
+	else {
+		/* No handler or method to run! */
+
+		ACPI_REPORT_ERROR ((
+			"acpi_ev_gpe_dispatch: No handler or method for GPE[%2X], disabling event\n",
+			gpe_number));
+
+		/*
+		 * Disable the GPE.  The GPE will remain disabled until the ACPI
+		 * Core Subsystem is restarted, or the handler is reinstalled.
+		 */
+		status = acpi_hw_disable_gpe (gpe_event_info);
+		if (ACPI_FAILURE (status)) {
+			ACPI_REPORT_ERROR (("acpi_ev_gpe_dispatch: Unable to disable GPE[%2X]\n",
+				gpe_number));
+			return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
+		}
+	}
+
+	/* It is now safe to clear level-triggered events. */
+
+	if (gpe_event_info->flags & ACPI_EVENT_LEVEL_TRIGGERED) {
+		status = acpi_hw_clear_gpe (gpe_event_info);
+		if (ACPI_FAILURE (status)) {
+			ACPI_REPORT_ERROR (("acpi_ev_gpe_dispatch: Unable to clear GPE[%2X]\n",
+				gpe_number));
+			return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
+		}
+	}
+
+	return_VALUE (ACPI_INTERRUPT_HANDLED);
+}
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/events/evgpeblk.c linux-2.4.22-pre2/drivers/acpi/events/evgpeblk.c
--- linux-2.4.21/drivers/acpi/events/evgpeblk.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/events/evgpeblk.c	2003-06-26 21:43:12.000000000 +0000
@@ -0,0 +1,903 @@
+/******************************************************************************
+ *
+ * Module Name: evgpeblk - GPE block creation and initialization.
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#include <acpi/acpi.h>
+#include <acpi/acevents.h>
+#include <acpi/acnamesp.h>
+
+#define _COMPONENT          ACPI_EVENTS
+	 ACPI_MODULE_NAME    ("evgpeblk")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ev_valid_gpe_event
+ *
+ * PARAMETERS:  gpe_event_info - Info for this GPE
+ *
+ * RETURN:      TRUE if the gpe_event is valid
+ *
+ * DESCRIPTION: Validate a GPE event.  DO NOT CALL FROM INTERRUPT LEVEL.
+ *              Should be called only when the GPE lists are semaphore locked
+ *              and not subject to change.
+ *
+ ******************************************************************************/
+
+u8
+acpi_ev_valid_gpe_event (
+	struct acpi_gpe_event_info      *gpe_event_info)
+{
+	struct acpi_gpe_xrupt_info      *gpe_xrupt_block;
+	struct acpi_gpe_block_info      *gpe_block;
+
+
+	ACPI_FUNCTION_ENTRY ();
+
+
+	/* No need for spin lock since we are not changing any list elements */
+
+	/* Walk the GPE interrupt levels */
+
+	gpe_xrupt_block = acpi_gbl_gpe_xrupt_list_head;
+	while (gpe_xrupt_block) {
+		gpe_block = gpe_xrupt_block->gpe_block_list_head;
+
+		/* Walk the GPE blocks on this interrupt level */
+
+		while (gpe_block) {
+			if ((&gpe_block->event_info[0] <= gpe_event_info) &&
+				(&gpe_block->event_info[((acpi_size) gpe_block->register_count) * 8] > gpe_event_info)) {
+				return (TRUE);
+			}
+
+			gpe_block = gpe_block->next;
+		}
+
+		gpe_xrupt_block = gpe_xrupt_block->next;
+	}
+
+	return (FALSE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ev_walk_gpe_list
+ *
+ * PARAMETERS:  gpe_walk_callback   - Routine called for each GPE block
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Walk the GPE lists.
+ *              FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ev_walk_gpe_list (
+	ACPI_GPE_CALLBACK       gpe_walk_callback)
+{
+	struct acpi_gpe_block_info      *gpe_block;
+	struct acpi_gpe_xrupt_info      *gpe_xrupt_info;
+	acpi_status                     status = AE_OK;
+
+
+	ACPI_FUNCTION_TRACE ("ev_walk_gpe_list");
+
+
+	acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_ISR);
+
+	/* Walk the interrupt level descriptor list */
+
+	gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
+	while (gpe_xrupt_info) {
+		/* Walk all Gpe Blocks attached to this interrupt level */
+
+		gpe_block = gpe_xrupt_info->gpe_block_list_head;
+		while (gpe_block) {
+			/* One callback per GPE block */
+
+			status = gpe_walk_callback (gpe_xrupt_info, gpe_block);
+			if (ACPI_FAILURE (status)) {
+				goto unlock_and_exit;
+			}
+
+			gpe_block = gpe_block->next;
+		}
+
+		gpe_xrupt_info = gpe_xrupt_info->next;
+	}
+
+unlock_and_exit:
+	acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_ISR);
+	return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ev_save_method_info
+ *
+ * PARAMETERS:  Callback from walk_namespace
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a
+ *              control method under the _GPE portion of the namespace.
+ *              Extract the name and GPE type from the object, saving this
+ *              information for quick lookup during GPE dispatch
+ *
+ *              The name of each GPE control method is of the form:
+ *                  "_Lnn" or "_Enn"
+ *                  Where:
+ *                      L      - means that the GPE is level triggered
+ *                      E      - means that the GPE is edge triggered
+ *                      nn     - is the GPE number [in HEX]
+ *
+ ******************************************************************************/
+
+static acpi_status
+acpi_ev_save_method_info (
+	acpi_handle                     obj_handle,
+	u32                             level,
+	void                            *obj_desc,
+	void                            **return_value)
+{
+	struct acpi_gpe_block_info      *gpe_block = (void *) obj_desc;
+	struct acpi_gpe_event_info      *gpe_event_info;
+	u32                             gpe_number;
+	char                            name[ACPI_NAME_SIZE + 1];
+	u8                              type;
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_TRACE ("ev_save_method_info");
+
+
+	/* Extract the name from the object and convert to a string */
+
+	ACPI_MOVE_32_TO_32 (name,
+			   &((struct acpi_namespace_node *) obj_handle)->name.integer);
+	name[ACPI_NAME_SIZE] = 0;
+
+	/*
+	 * Edge/Level determination is based on the 2nd character
+	 * of the method name
+	 */
+	switch (name[1]) {
+	case 'L':
+		type = ACPI_EVENT_LEVEL_TRIGGERED;
+		break;
+
+	case 'E':
+		type = ACPI_EVENT_EDGE_TRIGGERED;
+		break;
+
+	default:
+		/* Unknown method type, just ignore it! */
+
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"Unknown GPE method type: %s (name not of form _Lnn or _Enn)\n",
+			name));
+		return_ACPI_STATUS (AE_OK);
+	}
+
+	/* Convert the last two characters of the name to the GPE Number */
+
+	gpe_number = ACPI_STRTOUL (&name[2], NULL, 16);
+	if (gpe_number == ACPI_UINT32_MAX) {
+		/* Conversion failed; invalid method, just ignore it */
+
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"Could not extract GPE number from name: %s (name is not of form _Lnn or _Enn)\n",
+			name));
+		return_ACPI_STATUS (AE_OK);
+	}
+
+	/* Ensure that we have a valid GPE number for this GPE block */
+
+	if ((gpe_number < gpe_block->block_base_number) ||
+		(gpe_number >= (gpe_block->block_base_number + (gpe_block->register_count * 8)))) {
+		/*
+		 * Not valid for this GPE block, just ignore it
+		 * However, it may be valid for a different GPE block, since GPE0 and GPE1
+		 * methods both appear under \_GPE.
+		 */
+		return_ACPI_STATUS (AE_OK);
+	}
+
+	/*
+	 * Now we can add this information to the gpe_event_info block
+	 * for use during dispatch of this GPE.
+	 */
+	gpe_event_info = &gpe_block->event_info[gpe_number - gpe_block->block_base_number];
+
+	gpe_event_info->flags    = type;
+	gpe_event_info->method_node = (struct acpi_namespace_node *) obj_handle;
+
+	/* Enable the GPE (SCIs should be disabled at this point) */
+
+	status = acpi_hw_enable_gpe (gpe_event_info);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_LOAD,
+		"Registered GPE method %s as GPE number 0x%.2X\n",
+		name, gpe_number));
+	return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ev_get_gpe_xrupt_block
+ *
+ * PARAMETERS:  interrupt_level     - Interrupt for a GPE block
+ *
+ * RETURN:      A GPE interrupt block
+ *
+ * DESCRIPTION: Get or Create a GPE interrupt block.  There is one interrupt
+ *              block per unique interrupt level used for GPEs.
+ *              Should be called only when the GPE lists are semaphore locked
+ *              and not subject to change.
+ *
+ ******************************************************************************/
+
+static struct acpi_gpe_xrupt_info *
+acpi_ev_get_gpe_xrupt_block (
+	u32                             interrupt_level)
+{
+	struct acpi_gpe_xrupt_info      *next_gpe_xrupt;
+	struct acpi_gpe_xrupt_info      *gpe_xrupt;
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_TRACE ("ev_get_gpe_xrupt_block");
+
+
+	/* No need for spin lock since we are not changing any list elements here */
+
+	next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head;
+	while (next_gpe_xrupt) {
+		if (next_gpe_xrupt->interrupt_level == interrupt_level) {
+			return_PTR (next_gpe_xrupt);
+		}
+
+		next_gpe_xrupt = next_gpe_xrupt->next;
+	}
+
+	/* Not found, must allocate a new xrupt descriptor */
+
+	gpe_xrupt = ACPI_MEM_CALLOCATE (sizeof (struct acpi_gpe_xrupt_info));
+	if (!gpe_xrupt) {
+		return_PTR (NULL);
+	}
+
+	gpe_xrupt->interrupt_level = interrupt_level;
+
+	/* Install new interrupt descriptor with spin lock */
+
+	acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR);
+	if (acpi_gbl_gpe_xrupt_list_head) {
+		next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head;
+		while (next_gpe_xrupt->next) {
+			next_gpe_xrupt = next_gpe_xrupt->next;
+		}
+
+		next_gpe_xrupt->next = gpe_xrupt;
+		gpe_xrupt->previous = next_gpe_xrupt;
+	}
+	else {
+		acpi_gbl_gpe_xrupt_list_head = gpe_xrupt;
+	}
+	acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR);
+
+	/* Install new interrupt handler if not SCI_INT */
+
+	if (interrupt_level != acpi_gbl_FADT->sci_int) {
+		status = acpi_os_install_interrupt_handler (interrupt_level,
+				 acpi_ev_gpe_xrupt_handler, gpe_xrupt);
+		if (ACPI_FAILURE (status)) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"Could not install GPE interrupt handler at level 0x%X\n",
+				interrupt_level));
+			return_PTR (NULL);
+		}
+	}
+
+	return_PTR (gpe_xrupt);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ev_delete_gpe_xrupt
+ *
+ * PARAMETERS:  gpe_xrupt       - A GPE interrupt info block
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Remove and free a gpe_xrupt block. Remove an associated
+ *              interrupt handler if not the SCI interrupt.
+ *
+ ******************************************************************************/
+
+static acpi_status
+acpi_ev_delete_gpe_xrupt (
+	struct acpi_gpe_xrupt_info      *gpe_xrupt)
+{
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_TRACE ("ev_delete_gpe_xrupt");
+
+
+	/* We never want to remove the SCI interrupt handler */
+
+	if (gpe_xrupt->interrupt_level == acpi_gbl_FADT->sci_int) {
+		gpe_xrupt->gpe_block_list_head = NULL;
+		return_ACPI_STATUS (AE_OK);
+	}
+
+	/* Disable this interrupt */
+
+	status = acpi_os_remove_interrupt_handler (gpe_xrupt->interrupt_level,
+			   acpi_ev_gpe_xrupt_handler);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/* Unlink the interrupt block with lock */
+
+	acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR);
+	if (gpe_xrupt->previous) {
+		gpe_xrupt->previous->next = gpe_xrupt->next;
+	}
+
+	if (gpe_xrupt->next) {
+		gpe_xrupt->next->previous = gpe_xrupt->previous;
+	}
+	acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR);
+
+	/* Free the block */
+
+	ACPI_MEM_FREE (gpe_xrupt);
+	return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ev_install_gpe_block
+ *
+ * PARAMETERS:  gpe_block       - New GPE block
+ *              interrupt_level - Level to be associated with this GPE block
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Install new GPE block with mutex support
+ *
+ ******************************************************************************/
+
+static acpi_status
+acpi_ev_install_gpe_block (
+	struct acpi_gpe_block_info      *gpe_block,
+	u32                             interrupt_level)
+{
+	struct acpi_gpe_block_info      *next_gpe_block;
+	struct acpi_gpe_xrupt_info      *gpe_xrupt_block;
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_TRACE ("ev_install_gpe_block");
+
+
+	status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	gpe_xrupt_block = acpi_ev_get_gpe_xrupt_block (interrupt_level);
+	if (!gpe_xrupt_block) {
+		status = AE_NO_MEMORY;
+		goto unlock_and_exit;
+	}
+
+	/* Install the new block at the end of the list for this interrupt with lock */
+
+	acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR);
+	if (gpe_xrupt_block->gpe_block_list_head) {
+		next_gpe_block = gpe_xrupt_block->gpe_block_list_head;
+		while (next_gpe_block->next) {
+			next_gpe_block = next_gpe_block->next;
+		}
+
+		next_gpe_block->next = gpe_block;
+		gpe_block->previous = next_gpe_block;
+	}
+	else {
+		gpe_xrupt_block->gpe_block_list_head = gpe_block;
+	}
+
+	gpe_block->xrupt_block = gpe_xrupt_block;
+	acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR);
+
+unlock_and_exit:
+	status = acpi_ut_release_mutex (ACPI_MTX_EVENTS);
+	return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ev_delete_gpe_block
+ *
+ * PARAMETERS:  gpe_block       - Existing GPE block
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Install new GPE block with mutex support
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ev_delete_gpe_block (
+	struct acpi_gpe_block_info      *gpe_block)
+{
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_TRACE ("ev_install_gpe_block");
+
+
+	status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/* Disable all GPEs in this block */
+
+	status = acpi_hw_disable_gpe_block (gpe_block->xrupt_block, gpe_block);
+
+	if (!gpe_block->previous && !gpe_block->next) {
+		/* This is the last gpe_block on this interrupt */
+
+		status = acpi_ev_delete_gpe_xrupt (gpe_block->xrupt_block);
+		if (ACPI_FAILURE (status)) {
+			goto unlock_and_exit;
+		}
+	}
+	else {
+		/* Remove the block on this interrupt with lock */
+
+		acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR);
+		if (gpe_block->previous) {
+			gpe_block->previous->next = gpe_block->next;
+		}
+		else {
+			gpe_block->xrupt_block->gpe_block_list_head = gpe_block->next;
+		}
+
+		if (gpe_block->next) {
+			gpe_block->next->previous = gpe_block->previous;
+		}
+		acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR);
+	}
+
+	/* Free the gpe_block */
+
+	ACPI_MEM_FREE (gpe_block->register_info);
+	ACPI_MEM_FREE (gpe_block->event_info);
+	ACPI_MEM_FREE (gpe_block);
+
+unlock_and_exit:
+	status = acpi_ut_release_mutex (ACPI_MTX_EVENTS);
+	return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ev_create_gpe_info_blocks
+ *
+ * PARAMETERS:  gpe_block   - New GPE block
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Create the register_info and event_info blocks for this GPE block
+ *
+ ******************************************************************************/
+
+static acpi_status
+acpi_ev_create_gpe_info_blocks (
+	struct acpi_gpe_block_info      *gpe_block)
+{
+	struct acpi_gpe_register_info   *gpe_register_info = NULL;
+	struct acpi_gpe_event_info      *gpe_event_info = NULL;
+	struct acpi_gpe_event_info      *this_event;
+	struct acpi_gpe_register_info   *this_register;
+	acpi_native_uint                i;
+	acpi_native_uint                j;
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_TRACE ("ev_create_gpe_info_blocks");
+
+
+	/* Allocate the GPE register information block */
+
+	gpe_register_info = ACPI_MEM_CALLOCATE (
+			  (acpi_size) gpe_block->register_count *
+			  sizeof (struct acpi_gpe_register_info));
+	if (!gpe_register_info) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"Could not allocate the gpe_register_info table\n"));
+		return_ACPI_STATUS (AE_NO_MEMORY);
+	}
+
+	/*
+	 * Allocate the GPE event_info block. There are eight distinct GPEs
+	 * per register.  Initialization to zeros is sufficient.
+	 */
+	gpe_event_info = ACPI_MEM_CALLOCATE (
+			   ((acpi_size) gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH) *
+			   sizeof (struct acpi_gpe_event_info));
+	if (!gpe_event_info) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not allocate the gpe_event_info table\n"));
+		status = AE_NO_MEMORY;
+		goto error_exit;
+	}
+
+	/* Save the new Info arrays in the GPE block */
+
+	gpe_block->register_info = gpe_register_info;
+	gpe_block->event_info  = gpe_event_info;
+
+	/*
+	 * Initialize the GPE Register and Event structures.  A goal of these
+	 * tables is to hide the fact that there are two separate GPE register sets
+	 * in a given gpe hardware block, the status registers occupy the first half,
+	 * and the enable registers occupy the second half.
+	 */
+	this_register = gpe_register_info;
+	this_event   = gpe_event_info;
+
+	for (i = 0; i < gpe_block->register_count; i++) {
+		/* Init the register_info for this GPE register (8 GPEs) */
+
+		this_register->base_gpe_number = (u8) (gpe_block->block_base_number +
+				   (i * ACPI_GPE_REGISTER_WIDTH));
+
+		ACPI_STORE_ADDRESS (this_register->status_address.address,
+				 (gpe_block->block_address.address
+				 + i));
+
+		ACPI_STORE_ADDRESS (this_register->enable_address.address,
+				 (gpe_block->block_address.address
+				 + i
+				 + gpe_block->register_count));
+
+		this_register->status_address.address_space_id = gpe_block->block_address.address_space_id;
+		this_register->enable_address.address_space_id = gpe_block->block_address.address_space_id;
+		this_register->status_address.register_bit_width = ACPI_GPE_REGISTER_WIDTH;
+		this_register->enable_address.register_bit_width = ACPI_GPE_REGISTER_WIDTH;
+		this_register->status_address.register_bit_offset = ACPI_GPE_REGISTER_WIDTH;
+		this_register->enable_address.register_bit_offset = ACPI_GPE_REGISTER_WIDTH;
+
+		/* Init the event_info for each GPE within this register */
+
+		for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
+			this_event->bit_mask = acpi_gbl_decode_to8bit[j];
+			this_event->register_info = this_register;
+			this_event++;
+		}
+
+		/*
+		 * Clear the status/enable registers.  Note that status registers
+		 * are cleared by writing a '1', while enable registers are cleared
+		 * by writing a '0'.
+		 */
+		status = acpi_hw_low_level_write (ACPI_GPE_REGISTER_WIDTH, 0x00,
+				 &this_register->enable_address);
+		if (ACPI_FAILURE (status)) {
+			goto error_exit;
+		}
+
+		status = acpi_hw_low_level_write (ACPI_GPE_REGISTER_WIDTH, 0xFF,
+				 &this_register->status_address);
+		if (ACPI_FAILURE (status)) {
+			goto error_exit;
+		}
+
+		this_register++;
+	}
+
+	return_ACPI_STATUS (AE_OK);
+
+
+error_exit:
+	if (gpe_register_info) {
+		ACPI_MEM_FREE (gpe_register_info);
+	}
+	if (gpe_event_info) {
+		ACPI_MEM_FREE (gpe_event_info);
+	}
+
+	return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ev_create_gpe_block
+ *
+ * PARAMETERS:  gpe_device          - Handle to the parent GPE block
+ *              gpe_block_address   - Address and space_iD
+ *              register_count      - Number of GPE register pairs in the block
+ *              gpe_block_base_number - Starting GPE number for the block
+ *              interrupt_level     - H/W interrupt for the block
+ *              return_gpe_block    - Where the new block descriptor is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Create and Install a block of GPE registers
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ev_create_gpe_block (
+	struct acpi_namespace_node      *gpe_device,
+	struct acpi_generic_address     *gpe_block_address,
+	u32                             register_count,
+	u8                              gpe_block_base_number,
+	u32                             interrupt_level,
+	struct acpi_gpe_block_info      **return_gpe_block)
+{
+	struct acpi_gpe_block_info      *gpe_block;
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_TRACE ("ev_create_gpe_block");
+
+
+	if (!register_count) {
+		return_ACPI_STATUS (AE_OK);
+	}
+
+	/* Allocate a new GPE block */
+
+	gpe_block = ACPI_MEM_CALLOCATE (sizeof (struct acpi_gpe_block_info));
+	if (!gpe_block) {
+		return_ACPI_STATUS (AE_NO_MEMORY);
+	}
+
+	/* Initialize the new GPE block */
+
+	gpe_block->register_count = register_count;
+	gpe_block->block_base_number = gpe_block_base_number;
+
+	ACPI_MEMCPY (&gpe_block->block_address, gpe_block_address, sizeof (struct acpi_generic_address));
+
+	/* Create the register_info and event_info sub-structures */
+
+	status = acpi_ev_create_gpe_info_blocks (gpe_block);
+	if (ACPI_FAILURE (status)) {
+		ACPI_MEM_FREE (gpe_block);
+		return_ACPI_STATUS (status);
+	}
+
+	/* Install the new block in the global list(s) */
+
+	status = acpi_ev_install_gpe_block (gpe_block, interrupt_level);
+	if (ACPI_FAILURE (status)) {
+		ACPI_MEM_FREE (gpe_block);
+		return_ACPI_STATUS (status);
+	}
+
+	/* Dump info about this GPE block */
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "GPE %02d to %02d [%4.4s] %d regs at %8.8X%8.8X on int %d\n",
+		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_HIDWORD (gpe_block->block_address.address),
+		ACPI_LODWORD (gpe_block->block_address.address),
+		interrupt_level));
+
+	/* Find all GPE methods (_Lxx, _Exx) for this block */
+
+	status = acpi_ns_walk_namespace (ACPI_TYPE_METHOD, gpe_device,
+			  ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, acpi_ev_save_method_info,
+			  gpe_block, NULL);
+
+	/* Return the new block */
+
+	if (return_gpe_block) {
+		(*return_gpe_block) = gpe_block;
+	}
+
+	return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ev_gpe_initialize
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Initialize the GPE data structures
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ev_gpe_initialize (void)
+{
+	u32                             register_count0 = 0;
+	u32                             register_count1 = 0;
+	u32                             gpe_number_max = 0;
+	acpi_handle                     gpe_device;
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_TRACE ("ev_gpe_initialize");
+
+
+	/* Get a handle to the predefined _GPE object */
+
+	status = acpi_get_handle (NULL, "\\_GPE", &gpe_device);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/*
+	 * Initialize the GPE Blocks defined in the FADT
+	 *
+	 * Why the GPE register block lengths are divided by 2:  From the ACPI Spec,
+	 * section "General-Purpose Event Registers", we have:
+	 *
+	 * "Each register block contains two registers of equal length
+	 *  GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the
+	 *  GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN
+	 *  The length of the GPE1_STS and GPE1_EN registers is equal to
+	 *  half the GPE1_LEN. If a generic register block is not supported
+	 *  then its respective block pointer and block length values in the
+	 *  FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need
+	 *  to be the same size."
+	 */
+
+	/*
+	 * Determine the maximum GPE number for this machine.
+	 *
+	 * Note: both GPE0 and GPE1 are optional, and either can exist without
+	 * the other.
+	 *
+	 * If EITHER the register length OR the block address are zero, then that
+	 * particular block is not supported.
+	 */
+	if (acpi_gbl_FADT->gpe0_blk_len &&
+		acpi_gbl_FADT->xgpe0_blk.address) {
+		/* GPE block 0 exists (has both length and address > 0) */
+
+		register_count0 = (u16) (acpi_gbl_FADT->gpe0_blk_len / 2);
+
+		gpe_number_max = (register_count0 * ACPI_GPE_REGISTER_WIDTH) - 1;
+
+		/* Install GPE Block 0 */
+
+		status = acpi_ev_create_gpe_block (gpe_device, &acpi_gbl_FADT->xgpe0_blk,
+				 register_count0, 0, acpi_gbl_FADT->sci_int, &acpi_gbl_gpe_fadt_blocks[0]);
+		if (ACPI_FAILURE (status)) {
+			ACPI_REPORT_ERROR ((
+				"Could not create GPE Block 0, %s\n",
+				acpi_format_exception (status)));
+		}
+	}
+
+	if (acpi_gbl_FADT->gpe1_blk_len &&
+		acpi_gbl_FADT->xgpe1_blk.address) {
+		/* GPE block 1 exists (has both length and address > 0) */
+
+		register_count1 = (u16) (acpi_gbl_FADT->gpe1_blk_len / 2);
+
+		/* Check for GPE0/GPE1 overlap (if both banks exist) */
+
+		if ((register_count0) &&
+			(gpe_number_max >= acpi_gbl_FADT->gpe1_base)) {
+			ACPI_REPORT_ERROR ((
+				"GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1\n",
+				gpe_number_max, acpi_gbl_FADT->gpe1_base,
+				acpi_gbl_FADT->gpe1_base +
+				((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1)));
+
+			/* Ignore GPE1 block by setting the register count to zero */
+
+			register_count1 = 0;
+		}
+		else {
+			/* Install GPE Block 1 */
+
+			status = acpi_ev_create_gpe_block (gpe_device, &acpi_gbl_FADT->xgpe1_blk,
+					 register_count1, acpi_gbl_FADT->gpe1_base,
+					 acpi_gbl_FADT->sci_int, &acpi_gbl_gpe_fadt_blocks[1]);
+			if (ACPI_FAILURE (status)) {
+				ACPI_REPORT_ERROR ((
+					"Could not create GPE Block 1, %s\n",
+					acpi_format_exception (status)));
+			}
+
+			/*
+			 * GPE0 and GPE1 do not have to be contiguous in the GPE number
+			 * space. However, GPE0 always starts at GPE number zero.
+			 */
+			gpe_number_max = acpi_gbl_FADT->gpe1_base +
+					   ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1);
+		}
+	}
+
+	/* Exit if there are no GPE registers */
+
+	if ((register_count0 + register_count1) == 0) {
+		/* GPEs are not required by ACPI, this is OK */
+
+		ACPI_REPORT_INFO (("There are no GPE blocks defined in the FADT\n"));
+		return_ACPI_STATUS (AE_OK);
+	}
+
+	/* Check for Max GPE number out-of-range */
+
+	if (gpe_number_max > ACPI_GPE_MAX) {
+		ACPI_REPORT_ERROR (("Maximum GPE number from FADT is too large: 0x%X\n",
+			gpe_number_max));
+		return_ACPI_STATUS (AE_BAD_VALUE);
+	}
+
+	return_ACPI_STATUS (AE_OK);
+}
+
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/events/evmisc.c linux-2.4.22-pre2/drivers/acpi/events/evmisc.c
--- linux-2.4.21/drivers/acpi/events/evmisc.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/events/evmisc.c	2003-06-26 21:43:28.000000000 +0000
@@ -1,42 +1,92 @@
 /******************************************************************************
  *
- * Module Name: evmisc - ACPI device notification handler dispatch
- *                       and ACPI Global Lock support
- *              $Revision: 35 $
+ * Module Name: evmisc - Miscellaneous event manager support functions
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
-#include "acpi.h"
-#include "acevents.h"
-#include "acnamesp.h"
-#include "acinterp.h"
-#include "achware.h"
+#include <acpi/acpi.h>
+#include <acpi/acevents.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acinterp.h>
 
 #define _COMPONENT          ACPI_EVENTS
-	 MODULE_NAME         ("evmisc")
+	 ACPI_MODULE_NAME    ("evmisc")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_queue_notify_request
+ * FUNCTION:    acpi_ev_is_notify_object
+ *
+ * PARAMETERS:  Node            - Node to check
+ *
+ * RETURN:      TRUE if notifies allowed on this object
+ *
+ * DESCRIPTION: Check type of node for a object that supports notifies.
+ *
+ *              TBD: This could be replaced by a flag bit in the node.
+ *
+ ******************************************************************************/
+
+u8
+acpi_ev_is_notify_object (
+	struct acpi_namespace_node      *node)
+{
+	switch (node->type) {
+	case ACPI_TYPE_DEVICE:
+	case ACPI_TYPE_PROCESSOR:
+	case ACPI_TYPE_POWER:
+	case ACPI_TYPE_THERMAL:
+		/*
+		 * These are the ONLY objects that can receive ACPI notifications
+		 */
+		return (TRUE);
+
+	default:
+		return (FALSE);
+	}
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ev_queue_notify_request
  *
  * PARAMETERS:
  *
@@ -49,16 +99,16 @@
 
 acpi_status
 acpi_ev_queue_notify_request (
-	acpi_namespace_node     *node,
-	u32                     notify_value)
+	struct acpi_namespace_node      *node,
+	u32                             notify_value)
 {
-	acpi_operand_object     *obj_desc;
-	acpi_operand_object     *handler_obj = NULL;
-	acpi_generic_state      *notify_info;
-	acpi_status             status = AE_OK;
+	union acpi_operand_object       *obj_desc;
+	union acpi_operand_object       *handler_obj = NULL;
+	union acpi_generic_state        *notify_info;
+	acpi_status                     status = AE_OK;
 
 
-	PROC_NAME ("Ev_queue_notify_request");
+	ACPI_FUNCTION_NAME ("ev_queue_notify_request");
 
 
 	/*
@@ -92,43 +142,38 @@
 		break;
 	}
 
-
 	/*
-	 * Get the notify object attached to the device Node
+	 * Get the notify object attached to the NS Node
 	 */
 	obj_desc = acpi_ns_get_attached_object (node);
 	if (obj_desc) {
-
 		/* We have the notify object, Get the right handler */
 
 		switch (node->type) {
 		case ACPI_TYPE_DEVICE:
-			if (notify_value <= MAX_SYS_NOTIFY) {
-				handler_obj = obj_desc->device.sys_handler;
-			}
-			else {
-				handler_obj = obj_desc->device.drv_handler;
-			}
-			break;
-
 		case ACPI_TYPE_THERMAL:
-			if (notify_value <= MAX_SYS_NOTIFY) {
-				handler_obj = obj_desc->thermal_zone.sys_handler;
+		case ACPI_TYPE_PROCESSOR:
+		case ACPI_TYPE_POWER:
+
+			if (notify_value <= ACPI_MAX_SYS_NOTIFY) {
+				handler_obj = obj_desc->common_notify.system_notify;
 			}
 			else {
-				handler_obj = obj_desc->thermal_zone.drv_handler;
+				handler_obj = obj_desc->common_notify.device_notify;
 			}
 			break;
+
+		default:
+			/* All other types are not supported */
+			return (AE_TYPE);
 		}
 	}
 
-
 	/* If there is any handler to run, schedule the dispatcher */
 
-	if ((acpi_gbl_sys_notify.handler && (notify_value <= MAX_SYS_NOTIFY)) ||
-		(acpi_gbl_drv_notify.handler && (notify_value > MAX_SYS_NOTIFY)) ||
+	if ((acpi_gbl_system_notify.handler && (notify_value <= ACPI_MAX_SYS_NOTIFY)) ||
+		(acpi_gbl_device_notify.handler && (notify_value > ACPI_MAX_SYS_NOTIFY)) ||
 		handler_obj) {
-
 		notify_info = acpi_ut_create_generic_state ();
 		if (!notify_info) {
 			return (AE_NO_MEMORY);
@@ -149,7 +194,8 @@
 	if (!handler_obj) {
 		/* There is no per-device notify handler for this device */
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "No notify handler for node %p \n", node));
+		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+			"No notify handler for [%4.4s] node %p\n", node->name.ascii, node));
 	}
 
 	return (status);
@@ -158,7 +204,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_notify_dispatch
+ * FUNCTION:    acpi_ev_notify_dispatch
  *
  * PARAMETERS:
  *
@@ -169,42 +215,40 @@
  *
  ******************************************************************************/
 
-void
+void ACPI_SYSTEM_XFACE
 acpi_ev_notify_dispatch (
-	void                    *context)
+	void                            *context)
 {
-	acpi_generic_state      *notify_info = (acpi_generic_state *) context;
-	acpi_notify_handler     global_handler = NULL;
-	void                    *global_context = NULL;
-	acpi_operand_object     *handler_obj;
+	union acpi_generic_state        *notify_info = (union acpi_generic_state *) context;
+	acpi_notify_handler             global_handler = NULL;
+	void                            *global_context = NULL;
+	union acpi_operand_object       *handler_obj;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/*
 	 * We will invoke a global notify handler if installed.
 	 * This is done _before_ we invoke the per-device handler attached to the device.
 	 */
-	if (notify_info->notify.value <= MAX_SYS_NOTIFY) {
+	if (notify_info->notify.value <= ACPI_MAX_SYS_NOTIFY) {
 		/* Global system notification handler */
 
-		if (acpi_gbl_sys_notify.handler) {
-			global_handler = acpi_gbl_sys_notify.handler;
-			global_context = acpi_gbl_sys_notify.context;
+		if (acpi_gbl_system_notify.handler) {
+			global_handler = acpi_gbl_system_notify.handler;
+			global_context = acpi_gbl_system_notify.context;
 		}
 	}
-
 	else {
 		/* Global driver notification handler */
 
-		if (acpi_gbl_drv_notify.handler) {
-			global_handler = acpi_gbl_drv_notify.handler;
-			global_context = acpi_gbl_drv_notify.context;
+		if (acpi_gbl_device_notify.handler) {
+			global_handler = acpi_gbl_device_notify.handler;
+			global_context = acpi_gbl_device_notify.context;
 		}
 	}
 
-
 	/* Invoke the system handler first, if present */
 
 	if (global_handler) {
@@ -215,8 +259,8 @@
 
 	handler_obj = notify_info->notify.handler_obj;
 	if (handler_obj) {
-		handler_obj->notify_handler.handler (notify_info->notify.node, notify_info->notify.value,
-				  handler_obj->notify_handler.context);
+		handler_obj->notify.handler (notify_info->notify.node, notify_info->notify.value,
+				  handler_obj->notify.context);
 	}
 
 	/* All done with the info object */
@@ -227,7 +271,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_global_lock_thread
+ * FUNCTION:    acpi_ev_global_lock_thread
  *
  * RETURN:      None
  *
@@ -237,25 +281,30 @@
  *
  ******************************************************************************/
 
-static void
+static void ACPI_SYSTEM_XFACE
 acpi_ev_global_lock_thread (
-	void                    *context)
+	void                            *context)
 {
+	acpi_status                     status;
+
 
 	/* Signal threads that are waiting for the lock */
 
 	if (acpi_gbl_global_lock_thread_count) {
 		/* Send sufficient units to the semaphore */
 
-		acpi_os_signal_semaphore (acpi_gbl_global_lock_semaphore,
+		status = acpi_os_signal_semaphore (acpi_gbl_global_lock_semaphore,
 				 acpi_gbl_global_lock_thread_count);
+		if (ACPI_FAILURE (status)) {
+			ACPI_REPORT_ERROR (("Could not signal Global Lock semaphore\n"));
+		}
 	}
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_global_lock_handler
+ * FUNCTION:    acpi_ev_global_lock_handler
  *
  * RETURN:      Status
  *
@@ -267,10 +316,10 @@
 
 static u32
 acpi_ev_global_lock_handler (
-	void                    *context)
+	void                            *context)
 {
-	u8                      acquired = FALSE;
-	void                    *global_lock;
+	u8                              acquired = FALSE;
+	acpi_status                     status;
 
 
 	/*
@@ -278,8 +327,7 @@
 	 * If we don't get it now, it will be marked pending and we will
 	 * take another interrupt when it becomes free.
 	 */
-	global_lock = acpi_gbl_FACS->global_lock;
-	ACPI_ACQUIRE_GLOBAL_LOCK (global_lock, acquired);
+	ACPI_ACQUIRE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, acquired);
 	if (acquired) {
 		/* Got the lock, now wake all threads waiting for it */
 
@@ -287,17 +335,23 @@
 
 		/* Run the Global Lock thread which will signal all waiting threads */
 
-		acpi_os_queue_for_execution (OSD_PRIORITY_HIGH, acpi_ev_global_lock_thread,
-				  context);
+		status = acpi_os_queue_for_execution (OSD_PRIORITY_HIGH,
+				  acpi_ev_global_lock_thread, context);
+		if (ACPI_FAILURE (status)) {
+			ACPI_REPORT_ERROR (("Could not queue Global Lock thread, %s\n",
+				acpi_format_exception (status)));
+
+			return (ACPI_INTERRUPT_NOT_HANDLED);
+		}
 	}
 
-	return (INTERRUPT_HANDLED);
+	return (ACPI_INTERRUPT_HANDLED);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_init_global_lock_handler
+ * FUNCTION:    acpi_ev_init_global_lock_handler
  *
  * RETURN:      Status
  *
@@ -308,10 +362,10 @@
 acpi_status
 acpi_ev_init_global_lock_handler (void)
 {
-	acpi_status             status;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Ev_init_global_lock_handler");
+	ACPI_FUNCTION_TRACE ("ev_init_global_lock_handler");
 
 
 	acpi_gbl_global_lock_present = TRUE;
@@ -320,7 +374,7 @@
 
 	/*
 	 * If the global lock does not exist on this platform, the attempt
-	 * to enable GBL_STS will fail (the GBL_EN bit will not stick)
+	 * to enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick)
 	 * Map to AE_OK, but mark global lock as not present.
 	 * Any attempt to actually use the global lock will be flagged
 	 * with an error.
@@ -336,7 +390,7 @@
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_ev_acquire_global_lock
+ * FUNCTION:    acpi_ev_acquire_global_lock
  *
  * RETURN:      Status
  *
@@ -345,116 +399,170 @@
  *****************************************************************************/
 
 acpi_status
-acpi_ev_acquire_global_lock(void)
+acpi_ev_acquire_global_lock (
+	u16                             timeout)
 {
-	acpi_status             status = AE_OK;
-	u8                      acquired = FALSE;
-	void                    *global_lock;
+	acpi_status                     status = AE_OK;
+	u8                              acquired = FALSE;
 
 
-	FUNCTION_TRACE ("Ev_acquire_global_lock");
+	ACPI_FUNCTION_TRACE ("ev_acquire_global_lock");
 
+
+#ifndef ACPI_APPLICATION
 	/* Make sure that we actually have a global lock */
 
 	if (!acpi_gbl_global_lock_present) {
 		return_ACPI_STATUS (AE_NO_GLOBAL_LOCK);
 	}
+#endif
 
 	/* One more thread wants the global lock */
 
 	acpi_gbl_global_lock_thread_count++;
 
-
-	/* If we (OS side) have the hardware lock already, we are done */
+	/* If we (OS side vs. BIOS side) have the hardware lock already, we are done */
 
 	if (acpi_gbl_global_lock_acquired) {
 		return_ACPI_STATUS (AE_OK);
 	}
 
-	/* Only if the FACS is valid */
-
-	if (!acpi_gbl_FACS) {
-		return_ACPI_STATUS (AE_OK);
-	}
-
-
 	/* We must acquire the actual hardware lock */
 
-	global_lock = acpi_gbl_FACS->global_lock;
-	ACPI_ACQUIRE_GLOBAL_LOCK (global_lock, acquired);
+	ACPI_ACQUIRE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, acquired);
 	if (acquired) {
 	   /* We got the lock */
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Acquired the Global Lock\n"));
+		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Acquired the HW Global Lock\n"));
 
 		acpi_gbl_global_lock_acquired = TRUE;
 		return_ACPI_STATUS (AE_OK);
 	}
 
-
 	/*
 	 * Did not get the lock.  The pending bit was set above, and we must now
 	 * wait until we get the global lock released interrupt.
 	 */
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Waiting for the HW Global Lock\n"));
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Waiting for the HW Global Lock\n"));
 
-	 /*
-	  * Acquire the global lock semaphore first.
-	  * Since this wait will block, we must release the interpreter
-	  */
+	/*
+	 * Acquire the global lock semaphore first.
+	 * Since this wait will block, we must release the interpreter
+	 */
 	status = acpi_ex_system_wait_semaphore (acpi_gbl_global_lock_semaphore,
-			  ACPI_UINT32_MAX);
+			  timeout);
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_release_global_lock
+ * FUNCTION:    acpi_ev_release_global_lock
  *
  * DESCRIPTION: Releases ownership of the Global Lock.
  *
  ******************************************************************************/
 
-void
+acpi_status
 acpi_ev_release_global_lock (void)
 {
-	u8                      pending = FALSE;
-	void                    *global_lock;
+	u8                              pending = FALSE;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE ("Ev_release_global_lock");
+	ACPI_FUNCTION_TRACE ("ev_release_global_lock");
 
 
 	if (!acpi_gbl_global_lock_thread_count) {
-		REPORT_WARNING(("Global Lock has not be acquired, cannot release\n"));
-		return_VOID;
+		ACPI_REPORT_WARNING(("Cannot release HW Global Lock, it has not been acquired\n"));
+		return_ACPI_STATUS (AE_NOT_ACQUIRED);
 	}
 
-   /* One fewer thread has the global lock */
+	/* One fewer thread has the global lock */
 
 	acpi_gbl_global_lock_thread_count--;
+	if (acpi_gbl_global_lock_thread_count) {
+		/* There are still some threads holding the lock, cannot release */
 
-	/* Have all threads released the lock? */
+		return_ACPI_STATUS (AE_OK);
+	}
 
-	if (!acpi_gbl_global_lock_thread_count) {
-		/*
-		 * No more threads holding lock, we can do the actual hardware
-		 * release
-		 */
-		global_lock = acpi_gbl_FACS->global_lock;
-		ACPI_RELEASE_GLOBAL_LOCK (global_lock, pending);
-		acpi_gbl_global_lock_acquired = FALSE;
+	/*
+	 * No more threads holding lock, we can do the actual hardware
+	 * release
+	 */
+	ACPI_RELEASE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, pending);
+	acpi_gbl_global_lock_acquired = FALSE;
 
+	/*
+	 * If the pending bit was set, we must write GBL_RLS to the control
+	 * register
+	 */
+	if (pending) {
+		status = acpi_set_register (ACPI_BITREG_GLOBAL_LOCK_RELEASE, 1, ACPI_MTX_LOCK);
+	}
+
+	return_ACPI_STATUS (status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    acpi_ev_terminate
+ *
+ * PARAMETERS:  none
+ *
+ * RETURN:      none
+ *
+ * DESCRIPTION: Disable events and free memory allocated for table storage.
+ *
+ ******************************************************************************/
+
+void
+acpi_ev_terminate (void)
+{
+	acpi_native_uint                i;
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_TRACE ("ev_terminate");
+
+
+	if (acpi_gbl_events_initialized) {
 		/*
-		 * If the pending bit was set, we must write GBL_RLS to the control
-		 * register
+		 * Disable all event-related functionality.
+		 * In all cases, on error, print a message but obviously we don't abort.
 		 */
-		if (pending) {
-			acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK,
-					 GBL_RLS, 1);
+
+		/* Disable all fixed events */
+
+		for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
+			status = acpi_disable_event ((u32) i, 0);
+			if (ACPI_FAILURE (status)) {
+				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not disable fixed event %d\n", (u32) i));
+			}
+		}
+
+		/* Disable all GPEs in all GPE blocks */
+
+		status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block);
+
+		/* Remove SCI handler */
+
+		status = acpi_ev_remove_sci_handler ();
+		if (ACPI_FAILURE(status)) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not remove SCI handler\n"));
 		}
 	}
 
+	/* Return to original mode if necessary */
+
+	if (acpi_gbl_original_mode == ACPI_SYS_MODE_LEGACY) {
+		status = acpi_disable ();
+		if (ACPI_FAILURE (status)) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "acpi_disable failed\n"));
+		}
+	}
 	return_VOID;
 }
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/events/evregion.c linux-2.4.22-pre2/drivers/acpi/events/evregion.c
--- linux-2.4.21/drivers/acpi/events/evregion.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/events/evregion.c	2003-06-26 21:43:12.000000000 +0000
@@ -1,66 +1,93 @@
 /******************************************************************************
  *
- * Module Name: evregion - ACPI Address_space (Op_region) handler dispatch
- *              $Revision: 113 $
+ * Module Name: evregion - ACPI address_space (op_region) handler dispatch
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acevents.h"
-#include "acnamesp.h"
-#include "acinterp.h"
-#include "amlcode.h"
+#include <acpi/acpi.h>
+#include <acpi/acevents.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acinterp.h>
 
 #define _COMPONENT          ACPI_EVENTS
-	 MODULE_NAME         ("evregion")
+	 ACPI_MODULE_NAME    ("evregion")
+
+#define ACPI_NUM_DEFAULT_SPACES     4
+
+u8                              acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = {
+			 ACPI_ADR_SPACE_SYSTEM_MEMORY,
+			 ACPI_ADR_SPACE_SYSTEM_IO,
+			 ACPI_ADR_SPACE_PCI_CONFIG,
+			 ACPI_ADR_SPACE_DATA_TABLE};
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_install_default_address_space_handlers
+ * FUNCTION:    acpi_ev_init_address_spaces
  *
- * PARAMETERS:
+ * PARAMETERS:  None
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Installs the core subsystem address space handlers.
+ * DESCRIPTION: Installs the core subsystem default address space handlers.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_ev_install_default_address_space_handlers (
-	void)
-{
-	acpi_status             status;
+acpi_ev_init_address_spaces (
+	void) {
+	acpi_status                     status;
+	acpi_native_uint                i;
 
 
-	FUNCTION_TRACE ("Ev_install_default_address_space_handlers");
+	ACPI_FUNCTION_TRACE ("ev_init_address_spaces");
 
 
 	/*
 	 * All address spaces (PCI Config, EC, SMBus) are scope dependent
-	 * and registration must occur for a specific device.  In the case
-	 * system memory and IO address spaces there is currently no device
-	 * associated with the address space.  For these we use the root.
+	 * and registration must occur for a specific device.
+	 *
+	 * In the case of the system memory and IO address spaces there is currently
+	 * no device associated with the address space.  For these we use the root.
+	 *
 	 * We install the default PCI config space handler at the root so
 	 * that this space is immediately available even though the we have
 	 * not enumerated all the PCI Root Buses yet.  This is to conform
@@ -68,45 +95,39 @@
 	 * space must be always available -- even though we are nowhere
 	 * near ready to find the PCI root buses at this point.
 	 *
-	 * NOTE: We ignore AE_EXIST because this means that a handler has
-	 * already been installed (via Acpi_install_address_space_handler)
+	 * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler
+	 * has already been installed (via acpi_install_address_space_handler).
+	 * Similar for AE_SAME_HANDLER.
 	 */
-	status = acpi_install_address_space_handler (acpi_gbl_root_node,
-			   ACPI_ADR_SPACE_SYSTEM_MEMORY,
-			   ACPI_DEFAULT_HANDLER, NULL, NULL);
-	if ((ACPI_FAILURE (status)) &&
-		(status != AE_EXIST)) {
-		return_ACPI_STATUS (status);
-	}
-
-	status = acpi_install_address_space_handler (acpi_gbl_root_node,
-			   ACPI_ADR_SPACE_SYSTEM_IO,
-			   ACPI_DEFAULT_HANDLER, NULL, NULL);
-	if ((ACPI_FAILURE (status)) &&
-		(status != AE_EXIST)) {
-		return_ACPI_STATUS (status);
-	}
-
-	status = acpi_install_address_space_handler (acpi_gbl_root_node,
-			   ACPI_ADR_SPACE_PCI_CONFIG,
-			   ACPI_DEFAULT_HANDLER, NULL, NULL);
-	if ((ACPI_FAILURE (status)) &&
-		(status != AE_EXIST)) {
-		return_ACPI_STATUS (status);
-	}
 
+	for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) {
+		status = acpi_install_address_space_handler ((acpi_handle) acpi_gbl_root_node,
+				  acpi_gbl_default_address_spaces[i],
+				  ACPI_DEFAULT_HANDLER, NULL, NULL);
+		switch (status) {
+		case AE_OK:
+		case AE_SAME_HANDLER:
+		case AE_ALREADY_EXISTS:
+
+			/* These exceptions are all OK */
+
+			break;
+
+		default:
+
+			return_ACPI_STATUS (status);
+		}
+	}
 
 	return_ACPI_STATUS (AE_OK);
 }
 
 
-/* TBD: [Restructure] Move elsewhere */
-
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_execute_reg_method
+ * FUNCTION:    acpi_ev_execute_reg_method
  *
- * PARAMETERS:  Region_obj          - Object structure
+ * PARAMETERS:  region_obj          - Object structure
  *              Function            - On (1) or Off (0)
  *
  * RETURN:      Status
@@ -117,25 +138,31 @@
 
 static acpi_status
 acpi_ev_execute_reg_method (
-	acpi_operand_object    *region_obj,
-	u32                     function)
+	union acpi_operand_object      *region_obj,
+	u32                             function)
 {
-	acpi_operand_object    *params[3];
-	acpi_status             status;
+	union acpi_operand_object      *params[3];
+	union acpi_operand_object      *region_obj2;
+	acpi_status                     status;
+
 
+	ACPI_FUNCTION_TRACE ("ev_execute_reg_method");
 
-	FUNCTION_TRACE ("Ev_execute_reg_method");
 
+	region_obj2 = acpi_ns_get_secondary_object (region_obj);
+	if (!region_obj2) {
+		return_ACPI_STATUS (AE_NOT_EXIST);
+	}
 
-	if (region_obj->region.extra->extra.method_REG == NULL) {
+	if (region_obj2->extra.method_REG == NULL) {
 		return_ACPI_STATUS (AE_OK);
 	}
 
 	/*
-	 *  _REG method has two arguments
-	 *  Arg0:   Integer: Operation region space ID
-	 *          Same value as Region_obj->Region.Space_id
-	 *  Arg1:   Integer: connection status
+	 * _REG method has two arguments
+	 * Arg0:   Integer: Operation region space ID
+	 *          Same value as region_obj->Region.space_id
+	 * Arg1:   Integer: connection status
 	 *          1 for connecting the handler,
 	 *          0 for disconnecting the handler
 	 *          Passed as a parameter
@@ -151,18 +178,16 @@
 		goto cleanup;
 	}
 
-	/*
-	 *  Set up the parameter objects
-	 */
-	params[0]->integer.value  = region_obj->region.space_id;
+	/* Set up the parameter objects */
+
+	params[0]->integer.value = region_obj->region.space_id;
 	params[1]->integer.value = function;
 	params[2] = NULL;
 
-	/*
-	 *  Execute the method, no return value
-	 */
-	DEBUG_EXEC(acpi_ut_display_init_pathname (region_obj->region.extra->extra.method_REG, " [Method]"));
-	status = acpi_ns_evaluate_by_handle (region_obj->region.extra->extra.method_REG, params, NULL);
+	/* Execute the method, no return value */
+
+	ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname (ACPI_TYPE_METHOD, region_obj2->extra.method_REG, NULL));
+	status = acpi_ns_evaluate_by_handle (region_obj2->extra.method_REG, params, NULL);
 
 	acpi_ut_remove_reference (params[1]);
 
@@ -175,13 +200,13 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_address_space_dispatch
+ * FUNCTION:    acpi_ev_address_space_dispatch
  *
- * PARAMETERS:  Region_obj          - internal region object
- *              Space_id            - ID of the address space (0-255)
+ * PARAMETERS:  region_obj          - internal region object
+ *              space_id            - ID of the address space (0-255)
  *              Function            - Read or Write operation
  *              Address             - Where in the space to read or write
- *              Bit_width           - Field width in bits (8, 16, or 32)
+ *              bit_width           - Field width in bits (8, 16, 32, or 64)
  *              Value               - Pointer to in or out value
  *
  * RETURN:      Status
@@ -193,121 +218,142 @@
 
 acpi_status
 acpi_ev_address_space_dispatch (
-	acpi_operand_object     *region_obj,
-	u32                     function,
-	ACPI_PHYSICAL_ADDRESS   address,
-	u32                     bit_width,
-	u32                     *value)
+	union acpi_operand_object       *region_obj,
+	u32                             function,
+	acpi_physical_address           address,
+	u32                             bit_width,
+	void                            *value)
 {
-	acpi_status             status;
-	acpi_adr_space_handler  handler;
-	acpi_adr_space_setup    region_setup;
-	acpi_operand_object     *handler_desc;
-	void                    *region_context = NULL;
+	acpi_status                     status;
+	acpi_status                     status2;
+	acpi_adr_space_handler          handler;
+	acpi_adr_space_setup            region_setup;
+	union acpi_operand_object       *handler_desc;
+	union acpi_operand_object       *region_obj2;
+	void                            *region_context = NULL;
 
 
-	FUNCTION_TRACE ("Ev_address_space_dispatch");
+	ACPI_FUNCTION_TRACE ("ev_address_space_dispatch");
 
 
-	/*
-	 * Ensure that there is a handler associated with this region
-	 */
-	handler_desc = region_obj->region.addr_handler;
+	region_obj2 = acpi_ns_get_secondary_object (region_obj);
+	if (!region_obj2) {
+		return_ACPI_STATUS (AE_NOT_EXIST);
+	}
+
+	/* Ensure that there is a handler associated with this region */
+
+	handler_desc = region_obj->region.address_space;
 	if (!handler_desc) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "no handler for region(%p) [%s]\n",
 			region_obj, acpi_ut_get_region_name (region_obj->region.space_id)));
 
-		return_ACPI_STATUS(AE_NOT_EXIST);
+		return_ACPI_STATUS (AE_NOT_EXIST);
 	}
 
 	/*
 	 * It may be the case that the region has never been initialized
 	 * Some types of regions require special init code
 	 */
-	if (!(region_obj->region.flags & AOPOBJ_INITIALIZED)) {
+	if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) {
 		/*
 		 * This region has not been initialized yet, do it
 		 */
-		region_setup = handler_desc->addr_handler.setup;
+		region_setup = handler_desc->address_space.setup;
 		if (!region_setup) {
-			/*
-			 *  Bad news, no init routine and not init'd
-			 */
+			/* No initialization routine, exit with error */
+
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No init routine for region(%p) [%s]\n",
 				region_obj, acpi_ut_get_region_name (region_obj->region.space_id)));
-			return_ACPI_STATUS (AE_UNKNOWN_STATUS);
+			return_ACPI_STATUS (AE_NOT_EXIST);
 		}
 
 		/*
 		 * We must exit the interpreter because the region setup will potentially
-		 * execute control methods
+		 * execute control methods (e.g., _REG method for this region)
 		 */
 		acpi_ex_exit_interpreter ();
 
 		status = region_setup (region_obj, ACPI_REGION_ACTIVATE,
-				  handler_desc->addr_handler.context, &region_context);
+				  handler_desc->address_space.context, &region_context);
 
 		/* Re-enter the interpreter */
 
-		acpi_ex_enter_interpreter ();
+		status2 = acpi_ex_enter_interpreter ();
+		if (ACPI_FAILURE (status2)) {
+			return_ACPI_STATUS (status2);
+		}
+
+		/* Check for failure of the Region Setup */
 
-		/*
-		 *  Init routine may fail
-		 */
 		if (ACPI_FAILURE (status)) {
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region Init: %s [%s]\n",
 				acpi_format_exception (status),
 				acpi_ut_get_region_name (region_obj->region.space_id)));
-			return_ACPI_STATUS(status);
+			return_ACPI_STATUS (status);
 		}
 
-		region_obj->region.flags |= AOPOBJ_INITIALIZED;
-
 		/*
-		 *  Save the returned context for use in all accesses to
-		 *  this particular region.
+		 * Region initialization may have been completed by region_setup
 		 */
-		region_obj->region.extra->extra.region_context = region_context;
+		if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) {
+			region_obj->region.flags |= AOPOBJ_SETUP_COMPLETE;
+
+			if (region_obj2->extra.region_context) {
+				/* The handler for this region was already installed */
+
+				ACPI_MEM_FREE (region_context);
+			}
+			else {
+				/*
+				 * Save the returned context for use in all accesses to
+				 * this particular region
+				 */
+				region_obj2->extra.region_context = region_context;
+			}
+		}
 	}
 
-	/*
-	 *  We have everything we need, begin the process
-	 */
-	handler = handler_desc->addr_handler.handler;
+	/* We have everything we need, we can invoke the address space handler */
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
-		"Addrhandler %p (%p), Address %8.8X%8.8X\n",
-		&region_obj->region.addr_handler->addr_handler, handler, HIDWORD(address),
-		LODWORD(address)));
+	handler = handler_desc->address_space.handler;
 
-	if (!(handler_desc->addr_handler.flags & ADDR_HANDLER_DEFAULT_INSTALLED)) {
-		/*
-		 *  For handlers other than the default (supplied) handlers, we must
-		 *  exit the interpreter because the handler *might* block -- we don't
-		 *  know what it will do, so we can't hold the lock on the intepreter.
+	ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+		"Handler %p (@%p) Address %8.8X%8.8X [%s]\n",
+		&region_obj->region.address_space->address_space, handler,
+		ACPI_HIDWORD (address), ACPI_LODWORD (address),
+		acpi_ut_get_region_name (region_obj->region.space_id)));
+
+	if (!(handler_desc->address_space.flags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
+		/*
+		 * For handlers other than the default (supplied) handlers, we must
+		 * exit the interpreter because the handler *might* block -- we don't
+		 * know what it will do, so we can't hold the lock on the intepreter.
 		 */
 		acpi_ex_exit_interpreter();
 	}
 
-	/*
-	 *  Invoke the handler.
-	 */
+	/* Call the handler */
+
 	status = handler (function, address, bit_width, value,
-			 handler_desc->addr_handler.context,
-			 region_obj->region.extra->extra.region_context);
+			 handler_desc->address_space.context,
+			 region_obj2->extra.region_context);
 
 	if (ACPI_FAILURE (status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region handler: %s [%s]\n",
-			acpi_format_exception (status),
-			acpi_ut_get_region_name (region_obj->region.space_id)));
+		ACPI_REPORT_ERROR (("Handler for [%s] returned %s\n",
+			acpi_ut_get_region_name (region_obj->region.space_id),
+			acpi_format_exception (status)));
 	}
 
-	if (!(handler_desc->addr_handler.flags & ADDR_HANDLER_DEFAULT_INSTALLED)) {
+	if (!(handler_desc->address_space.flags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
 		/*
 		 * We just returned from a non-default handler, we must re-enter the
 		 * interpreter
 		 */
-		acpi_ex_enter_interpreter ();
+		status2 = acpi_ex_enter_interpreter ();
+		if (ACPI_FAILURE (status2)) {
+			return_ACPI_STATUS (status2);
+		}
 	}
 
 	return_ACPI_STATUS (status);
@@ -315,10 +361,10 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_disassociate_region_from_handler
+ * FUNCTION:    acpi_ev_detach_region
  *
- * PARAMETERS:  Region_obj      - Region Object
- *              Acpi_ns_is_locked - Namespace Region Already Locked?
+ * PARAMETERS:  region_obj      - Region Object
+ *              acpi_ns_is_locked - Namespace Region Already Locked?
  *
  * RETURN:      None
  *
@@ -328,112 +374,118 @@
  ******************************************************************************/
 
 void
-acpi_ev_disassociate_region_from_handler(
-	acpi_operand_object     *region_obj,
-	u8                      acpi_ns_is_locked)
+acpi_ev_detach_region(
+	union acpi_operand_object       *region_obj,
+	u8                              acpi_ns_is_locked)
 {
-	acpi_operand_object     *handler_obj;
-	acpi_operand_object     *obj_desc;
-	acpi_operand_object     **last_obj_ptr;
-	acpi_adr_space_setup    region_setup;
-	void                    *region_context;
-	acpi_status             status;
+	union acpi_operand_object       *handler_obj;
+	union acpi_operand_object       *obj_desc;
+	union acpi_operand_object       **last_obj_ptr;
+	acpi_adr_space_setup            region_setup;
+	void                            *region_context;
+	union acpi_operand_object       *region_obj2;
+	acpi_status                     status;
+
 
+	ACPI_FUNCTION_TRACE ("ev_detach_region");
 
-	FUNCTION_TRACE ("Ev_disassociate_region_from_handler");
 
+	region_obj2 = acpi_ns_get_secondary_object (region_obj);
+	if (!region_obj2) {
+		return_VOID;
+	}
+	region_context = region_obj2->extra.region_context;
 
-	region_context = region_obj->region.extra->extra.region_context;
+	/* Get the address handler from the region object */
 
-	/*
-	 *  Get the address handler from the region object
-	 */
-	handler_obj = region_obj->region.addr_handler;
+	handler_obj = region_obj->region.address_space;
 	if (!handler_obj) {
-		/*
-		 *  This region has no handler, all done
-		 */
+		/* This region has no handler, all done */
+
 		return_VOID;
 	}
 
+	/* Find this region in the handler's list */
 
-	/*
-	 *  Find this region in the handler's list
-	 */
-	obj_desc = handler_obj->addr_handler.region_list;
-	last_obj_ptr = &handler_obj->addr_handler.region_list;
+	obj_desc = handler_obj->address_space.region_list;
+	last_obj_ptr = &handler_obj->address_space.region_list;
 
 	while (obj_desc) {
-		/*
-		 *  See if this is the one
-		 */
+		/* Is this the correct Region? */
+
 		if (obj_desc == region_obj) {
 			ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
 				"Removing Region %p from address handler %p\n",
 				region_obj, handler_obj));
-			/*
-			 *  This is it, remove it from the handler's list
-			 */
+
+			/* This is it, remove it from the handler's list */
+
 			*last_obj_ptr = obj_desc->region.next;
 			obj_desc->region.next = NULL;           /* Must clear field */
 
 			if (acpi_ns_is_locked) {
-				acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+				status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+				if (ACPI_FAILURE (status)) {
+					return_VOID;
+				}
 			}
 
-			/*
-			 *  Now stop region accesses by executing the _REG method
-			 */
-			acpi_ev_execute_reg_method (region_obj, 0);
+			/* Now stop region accesses by executing the _REG method */
+
+			status = acpi_ev_execute_reg_method (region_obj, 0);
+			if (ACPI_FAILURE (status)) {
+				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s from region _REG, [%s]\n",
+					acpi_format_exception (status),
+					acpi_ut_get_region_name (region_obj->region.space_id)));
+			}
 
 			if (acpi_ns_is_locked) {
-				acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+				status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+				if (ACPI_FAILURE (status)) {
+					return_VOID;
+				}
 			}
 
-			/*
-			 *  Call the setup handler with the deactivate notification
-			 */
-			region_setup = handler_obj->addr_handler.setup;
+			/* Call the setup handler with the deactivate notification */
+
+			region_setup = handler_obj->address_space.setup;
 			status = region_setup (region_obj, ACPI_REGION_DEACTIVATE,
-					  handler_obj->addr_handler.context, &region_context);
+					  handler_obj->address_space.context, &region_context);
+
+			/* Init routine may fail, Just ignore errors */
 
-			/*
-			 *  Init routine may fail, Just ignore errors
-			 */
 			if (ACPI_FAILURE (status)) {
 				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s from region init, [%s]\n",
 					acpi_format_exception (status),
 					acpi_ut_get_region_name (region_obj->region.space_id)));
 			}
 
-			region_obj->region.flags &= ~(AOPOBJ_INITIALIZED);
+			region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE);
 
 			/*
-			 *  Remove handler reference in the region
+			 * Remove handler reference in the region
 			 *
-			 *  NOTE: this doesn't mean that the region goes away
-			 *  The region is just inaccessible as indicated to
-			 *  the _REG method
+			 * NOTE: this doesn't mean that the region goes away
+			 * The region is just inaccessible as indicated to
+			 * the _REG method
 			 *
-			 *  If the region is on the handler's list
-			 *  this better be the region's handler
+			 * If the region is on the handler's list
+			 * this better be the region's handler
 			 */
-			region_obj->region.addr_handler = NULL;
+			region_obj->region.address_space = NULL;
+			acpi_ut_remove_reference (handler_obj);
 
 			return_VOID;
+		}
 
-		} /* found the right handler */
+		/* Walk the linked list of handlers */
 
-		/*
-		 *  Move through the linked list of handlers
-		 */
 		last_obj_ptr = &obj_desc->region.next;
 		obj_desc = obj_desc->region.next;
 	}
 
-	/*
-	 *  If we get here, the region was not in the handler's region list
-	 */
+	/* If we get here, the region was not in the handler's region list */
+
 	ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
 		"Cannot remove region %p from address handler %p\n",
 		region_obj, handler_obj));
@@ -444,11 +496,11 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_associate_region_and_handler
+ * FUNCTION:    acpi_ev_attach_region
  *
- * PARAMETERS:  Handler_obj     - Handler Object
- *              Region_obj      - Region Object
- *              Acpi_ns_is_locked - Namespace Region Already Locked?
+ * PARAMETERS:  handler_obj     - Handler Object
+ *              region_obj      - Region Object
+ *              acpi_ns_is_locked - Namespace Region Already Locked?
  *
  * RETURN:      None
  *
@@ -458,15 +510,16 @@
  ******************************************************************************/
 
 acpi_status
-acpi_ev_associate_region_and_handler (
-	acpi_operand_object     *handler_obj,
-	acpi_operand_object     *region_obj,
-	u8                      acpi_ns_is_locked)
+acpi_ev_attach_region (
+	union acpi_operand_object       *handler_obj,
+	union acpi_operand_object       *region_obj,
+	u8                              acpi_ns_is_locked)
 {
-	acpi_status     status;
+	acpi_status                     status;
+	acpi_status                     status2;
 
 
-	FUNCTION_TRACE ("Ev_associate_region_and_handler");
+	ACPI_FUNCTION_TRACE ("ev_attach_region");
 
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
@@ -474,28 +527,38 @@
 		region_obj, handler_obj, acpi_ut_get_region_name (region_obj->region.space_id)));
 
 
-	/*
-	 *  Link this region to the front of the handler's list
-	 */
-	region_obj->region.next = handler_obj->addr_handler.region_list;
-	handler_obj->addr_handler.region_list = region_obj;
+	/* Link this region to the front of the handler's list */
 
-	/*
-	 *  set the region's handler
-	 */
-	region_obj->region.addr_handler = handler_obj;
+	region_obj->region.next = handler_obj->address_space.region_list;
+	handler_obj->address_space.region_list = region_obj;
+
+	/* Install the region's handler */
+
+	if (region_obj->region.address_space) {
+		return_ACPI_STATUS (AE_ALREADY_EXISTS);
+	}
+
+	region_obj->region.address_space = handler_obj;
+	acpi_ut_add_reference (handler_obj);
 
 	/*
-	 *  Last thing, tell all users that this region is usable
+	 * Tell all users that this region is usable by running the _REG
+	 * method
 	 */
 	if (acpi_ns_is_locked) {
-		acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+		status2 = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+		if (ACPI_FAILURE (status2)) {
+			return_ACPI_STATUS (status2);
+		}
 	}
 
 	status = acpi_ev_execute_reg_method (region_obj, 1);
 
 	if (acpi_ns_is_locked) {
-		acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+		status2 = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+		if (ACPI_FAILURE (status2)) {
+			return_ACPI_STATUS (status2);
+		}
 	}
 
 	return_ACPI_STATUS (status);
@@ -504,14 +567,14 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_addr_handler_helper
+ * FUNCTION:    acpi_ev_install_handler
  *
  * PARAMETERS:  Handle              - Node to be dumped
  *              Level               - Nesting level of the handle
- *              Context             - Passed into Acpi_ns_walk_namespace
+ *              Context             - Passed into acpi_ns_walk_namespace
  *
- * DESCRIPTION: This routine checks to see if the object is a Region if it
- *              is then the address handler is installed in it.
+ * DESCRIPTION: This routine installs an address handler into objects that are
+ *              of type Region or Device.
  *
  *              If the Object is a Device, and the device has a handler of
  *              the same type then the search is terminated in that branch.
@@ -522,23 +585,23 @@
  ******************************************************************************/
 
 acpi_status
-acpi_ev_addr_handler_helper (
-	acpi_handle             obj_handle,
-	u32                     level,
-	void                    *context,
-	void                    **return_value)
+acpi_ev_install_handler (
+	acpi_handle                     obj_handle,
+	u32                             level,
+	void                            *context,
+	void                            **return_value)
 {
-	acpi_operand_object     *handler_obj;
-	acpi_operand_object     *tmp_obj;
-	acpi_operand_object     *obj_desc;
-	acpi_namespace_node     *node;
-	acpi_status             status;
+	union acpi_operand_object       *handler_obj;
+	union acpi_operand_object       *next_handler_obj;
+	union acpi_operand_object       *obj_desc;
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
 
 
-	PROC_NAME ("Ev_addr_handler_helper");
+	ACPI_FUNCTION_NAME ("ev_install_handler");
 
 
-	handler_obj = (acpi_operand_object *) context;
+	handler_obj = (union acpi_operand_object   *) context;
 
 	/* Parameter validation */
 
@@ -554,8 +617,8 @@
 	}
 
 	/*
-	 *  We only care about regions.and objects
-	 *  that can have address handlers
+	 * We only care about regions.and objects
+	 * that are allowed to have address space handlers
 	 */
 	if ((node->type != ACPI_TYPE_DEVICE) &&
 		(node->type != ACPI_TYPE_REGION) &&
@@ -567,81 +630,70 @@
 
 	obj_desc = acpi_ns_get_attached_object (node);
 	if (!obj_desc) {
-		/*
-		 *  The object DNE, we don't care about it
-		 */
+		/* No object, just exit */
+
 		return (AE_OK);
 	}
 
-	/*
-	 *  Devices are handled different than regions
-	 */
-	if (IS_THIS_OBJECT_TYPE (obj_desc, ACPI_TYPE_DEVICE)) {
-		/*
-		 *  See if this guy has any handlers
-		 */
-		tmp_obj = obj_desc->device.addr_handler;
-		while (tmp_obj) {
-			/*
-			 *  Now let's see if it's for the same address space.
-			 */
-			if (tmp_obj->addr_handler.space_id == handler_obj->addr_handler.space_id) {
-				/*
-				 *  It's for the same address space
-				 */
+	/* Devices are handled different than regions */
+
+	if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_DEVICE) {
+		/* Check if this Device already has a handler for this address space */
+
+		next_handler_obj = obj_desc->device.address_space;
+		while (next_handler_obj) {
+			/* Found a handler, is it for the same address space? */
+
+			if (next_handler_obj->address_space.space_id == handler_obj->address_space.space_id) {
 				ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
 					"Found handler for region [%s] in device %p(%p) handler %p\n",
-					acpi_ut_get_region_name (handler_obj->addr_handler.space_id),
-					obj_desc, tmp_obj, handler_obj));
+					acpi_ut_get_region_name (handler_obj->address_space.space_id),
+					obj_desc, next_handler_obj, handler_obj));
 
 				/*
-				 *  Since the object we found it on was a device, then it
-				 *  means that someone has already installed a handler for
-				 *  the branch of the namespace from this device on.  Just
-				 *  bail out telling the walk routine to not traverse this
-				 *  branch.  This preserves the scoping rule for handlers.
+				 * Since the object we found it on was a device, then it
+				 * means that someone has already installed a handler for
+				 * the branch of the namespace from this device on.  Just
+				 * bail out telling the walk routine to not traverse this
+				 * branch.  This preserves the scoping rule for handlers.
 				 */
 				return (AE_CTRL_DEPTH);
 			}
 
-			/*
-			 *  Move through the linked list of handlers
-			 */
-			tmp_obj = tmp_obj->addr_handler.next;
+			/* Walk the linked list of handlers attached to this device */
+
+			next_handler_obj = next_handler_obj->address_space.next;
 		}
 
 		/*
-		 *  As long as the device didn't have a handler for this
-		 *  space we don't care about it.  We just ignore it and
-		 *  proceed.
+		 * As long as the device didn't have a handler for this
+		 * space we don't care about it.  We just ignore it and
+		 * proceed.
 		 */
 		return (AE_OK);
 	}
 
-	/*
-	 *  Only here if it was a region
-	 */
-	if (obj_desc->region.space_id != handler_obj->addr_handler.space_id) {
+	/* Object is a Region */
+
+	if (obj_desc->region.space_id != handler_obj->address_space.space_id) {
 		/*
-		 *  This region is for a different address space
-		 *  ignore it
+		 * This region is for a different address space
+		 * -- just ignore it
 		 */
 		return (AE_OK);
 	}
 
 	/*
-	 *  Now we have a region and it is for the handler's address
-	 *  space type.
+	 * Now we have a region and it is for the handler's address
+	 * space type.
 	 *
-	 *  First disconnect region for any previous handler (if any)
+	 * First disconnect region for any previous handler (if any)
 	 */
-	acpi_ev_disassociate_region_from_handler (obj_desc, FALSE);
+	acpi_ev_detach_region (obj_desc, FALSE);
 
-	/*
-	 *  Then connect the region to the new handler
-	 */
-	status = acpi_ev_associate_region_and_handler (handler_obj, obj_desc, FALSE);
+	/* Connect the region to the new handler */
 
+	status = acpi_ev_attach_region (handler_obj, obj_desc, FALSE);
 	return (status);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/events/evrgnini.c linux-2.4.22-pre2/drivers/acpi/events/evrgnini.c
--- linux-2.4.21/drivers/acpi/events/evrgnini.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/events/evrgnini.c	2003-06-26 21:43:11.000000000 +0000
@@ -1,47 +1,63 @@
 /******************************************************************************
  *
- * Module Name: evrgnini- ACPI Address_space (Op_region) init
- *              $Revision: 48 $
+ * Module Name: evrgnini- ACPI address_space (op_region) init
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acevents.h"
-#include "acnamesp.h"
-#include "acinterp.h"
-#include "amlcode.h"
+#include <acpi/acpi.h>
+#include <acpi/acevents.h>
+#include <acpi/acnamesp.h>
 
 #define _COMPONENT          ACPI_EVENTS
-	 MODULE_NAME         ("evrgnini")
+	 ACPI_MODULE_NAME    ("evrgnini")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_system_memory_region_setup
+ * FUNCTION:    acpi_ev_system_memory_region_setup
  *
- * PARAMETERS:  Region_obj          - region we are interested in
- *              Function            - start or stop
- *              Handler_context     - Address space handler context
- *              Region_context      - Region specific context
+ * PARAMETERS:  region_obj          - Region we are interested in
+ *              Function            - Start or stop
+ *              handler_context     - Address space handler context
+ *              region_context      - Region specific context
  *
  * RETURN:      Status
  *
@@ -51,12 +67,16 @@
 
 acpi_status
 acpi_ev_system_memory_region_setup (
-	acpi_handle             handle,
-	u32                     function,
-	void                    *handler_context,
-	void                    **region_context)
+	acpi_handle                     handle,
+	u32                             function,
+	void                            *handler_context,
+	void                            **region_context)
 {
-	FUNCTION_TRACE ("Ev_system_memory_region_setup");
+	union acpi_operand_object       *region_desc = (union acpi_operand_object *) handle;
+	struct acpi_mem_space_context   *local_region_context;
+
+
+	ACPI_FUNCTION_TRACE ("ev_system_memory_region_setup");
 
 
 	if (function == ACPI_REGION_DEACTIVATE) {
@@ -67,26 +87,31 @@
 		return_ACPI_STATUS (AE_OK);
 	}
 
+	/* Create a new context */
 
-	/* Activate.  Create a new context */
-
-	*region_context = ACPI_MEM_CALLOCATE (sizeof (acpi_mem_space_context));
-	if (!(*region_context)) {
+	local_region_context = ACPI_MEM_CALLOCATE (sizeof (struct acpi_mem_space_context));
+	if (!(local_region_context)) {
 		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
 
+	/* Save the region length and address for use in the handler */
+
+	local_region_context->length = region_desc->region.length;
+	local_region_context->address = region_desc->region.address;
+
+	*region_context = local_region_context;
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_io_space_region_setup
+ * FUNCTION:    acpi_ev_io_space_region_setup
  *
- * PARAMETERS:  Region_obj          - region we are interested in
- *              Function            - start or stop
- *              Handler_context     - Address space handler context
- *              Region_context      - Region specific context
+ * PARAMETERS:  region_obj          - Region we are interested in
+ *              Function            - Start or stop
+ *              handler_context     - Address space handler context
+ *              region_context      - Region specific context
  *
  * RETURN:      Status
  *
@@ -96,12 +121,12 @@
 
 acpi_status
 acpi_ev_io_space_region_setup (
-	acpi_handle             handle,
-	u32                     function,
-	void                    *handler_context,
-	void                    **region_context)
+	acpi_handle                     handle,
+	u32                             function,
+	void                            *handler_context,
+	void                            **region_context)
 {
-	FUNCTION_TRACE ("Ev_io_space_region_setup");
+	ACPI_FUNCTION_TRACE ("ev_io_space_region_setup");
 
 
 	if (function == ACPI_REGION_DEACTIVATE) {
@@ -117,12 +142,12 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_pci_config_region_setup
+ * FUNCTION:    acpi_ev_pci_config_region_setup
  *
- * PARAMETERS:  Region_obj          - region we are interested in
- *              Function            - start or stop
- *              Handler_context     - Address space handler context
- *              Region_context      - Region specific context
+ * PARAMETERS:  region_obj          - Region we are interested in
+ *              Function            - Start or stop
+ *              handler_context     - Address space handler context
+ *              region_context      - Region specific context
  *
  * RETURN:      Status
  *
@@ -134,128 +159,155 @@
 
 acpi_status
 acpi_ev_pci_config_region_setup (
-	acpi_handle             handle,
-	u32                     function,
-	void                    *handler_context,
-	void                    **region_context)
+	acpi_handle                     handle,
+	u32                             function,
+	void                            *handler_context,
+	void                            **region_context)
 {
-	acpi_status             status = AE_OK;
-	acpi_integer            temp;
-	acpi_pci_id             *pci_id = *region_context;
-	acpi_operand_object     *handler_obj;
-	acpi_namespace_node     *node;
-	acpi_operand_object     *region_obj = (acpi_operand_object *) handle;
-	acpi_device_id          object_hID;
+	acpi_status                     status = AE_OK;
+	acpi_integer                    pci_value;
+	struct acpi_pci_id              *pci_id = *region_context;
+	union acpi_operand_object       *handler_obj;
+	struct acpi_namespace_node      *parent_node;
+	struct acpi_namespace_node      *pci_root_node;
+	union acpi_operand_object       *region_obj = (union acpi_operand_object   *) handle;
+	struct acpi_device_id           object_hID;
 
 
-	FUNCTION_TRACE ("Ev_pci_config_region_setup");
+	ACPI_FUNCTION_TRACE ("ev_pci_config_region_setup");
 
 
-	handler_obj = region_obj->region.addr_handler;
+	handler_obj = region_obj->region.address_space;
 	if (!handler_obj) {
 		/*
-		 *  No installed handler. This shouldn't happen because the dispatch
-		 *  routine checks before we get here, but we check again just in case.
+		 * No installed handler. This shouldn't happen because the dispatch
+		 * routine checks before we get here, but we check again just in case.
 		 */
 		ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
 			"Attempting to init a region %p, with no handler\n", region_obj));
 		return_ACPI_STATUS (AE_NOT_EXIST);
 	}
 
+	*region_context = NULL;
 	if (function == ACPI_REGION_DEACTIVATE) {
 		if (pci_id) {
 			ACPI_MEM_FREE (pci_id);
-			*region_context = NULL;
 		}
-
 		return_ACPI_STATUS (status);
 	}
 
-
-	/* Create a new context */
-
-	pci_id = ACPI_MEM_CALLOCATE (sizeof (acpi_pci_id));
-	if (!pci_id) {
-		return_ACPI_STATUS (AE_NO_MEMORY);
-	}
-
-	/*
-	 *  For PCI Config space access, we have to pass the segment, bus,
-	 *  device and function numbers.  This routine must acquire those.
-	 */
+	parent_node = acpi_ns_get_parent_node (region_obj->region.node);
 
 	/*
-	 *  First get device and function numbers from the _ADR object
-	 *  in the parent's scope.
-	 */
-	node = acpi_ns_get_parent_object (region_obj->region.node);
-
-
-	/* Acpi_evaluate the _ADR object */
-
-	status = acpi_ut_evaluate_numeric_object (METHOD_NAME__ADR, node, &temp);
-
-	/*
-	 *  The default is zero, since the allocation above zeroed the data, just
-	 *  do nothing on failures.
-	 */
-	if (ACPI_SUCCESS (status)) {
-		pci_id->device = HIWORD (temp);
-		pci_id->function = LOWORD (temp);
-	}
-
-	/*
-	 *  Get the _SEG and _BBN values from the device upon which the handler
-	 *  is installed.
+	 * Get the _SEG and _BBN values from the device upon which the handler
+	 * is installed.
 	 *
-	 *  We need to get the _SEG and _BBN objects relative to the PCI BUS device.
-	 *  This is the device the handler has been registered to handle.
+	 * We need to get the _SEG and _BBN objects relative to the PCI BUS device.
+	 * This is the device the handler has been registered to handle.
 	 */
 
 	/*
-	 *  If the Addr_handler.Node is still pointing to the root, we need
-	 *  to scan upward for a PCI Root bridge and re-associate the Op_region
-	 *  handlers with that device.
+	 * If the address_space.Node is still pointing to the root, we need
+	 * to scan upward for a PCI Root bridge and re-associate the op_region
+	 * handlers with that device.
 	 */
-	if (handler_obj->addr_handler.node == acpi_gbl_root_node) {
-		/*
-		 * Node is currently the parent object
-		 */
-		while (node != acpi_gbl_root_node) {
-			status = acpi_ut_execute_HID (node, &object_hID);
+	if (handler_obj->address_space.node == acpi_gbl_root_node) {
+		/* Start search from the parent object */
+
+		pci_root_node = parent_node;
+		while (pci_root_node != acpi_gbl_root_node) {
+			status = acpi_ut_execute_HID (pci_root_node, &object_hID);
 			if (ACPI_SUCCESS (status)) {
-				if (!(STRNCMP (object_hID.buffer, PCI_ROOT_HID_STRING,
+				/* Got a valid _HID, check if this is a PCI root */
+
+				if (!(ACPI_STRNCMP (object_hID.value, PCI_ROOT_HID_STRING,
 						   sizeof (PCI_ROOT_HID_STRING)))) {
-					acpi_install_address_space_handler (node,
+					/* Install a handler for this PCI root bridge */
+
+					status = acpi_install_address_space_handler ((acpi_handle) pci_root_node,
 							   ACPI_ADR_SPACE_PCI_CONFIG,
 							   ACPI_DEFAULT_HANDLER, NULL, NULL);
+					if (ACPI_FAILURE (status)) {
+						if (status == AE_SAME_HANDLER) {
+							/*
+							 * It is OK if the handler is already installed on the root
+							 * bridge.  Still need to return a context object for the
+							 * new PCI_Config operation region, however.
+							 */
+							status = AE_OK;
+						}
+						else {
+							ACPI_REPORT_ERROR ((
+								"Could not install pci_config handler for Root Bridge %4.4s, %s\n",
+								pci_root_node->name.ascii, acpi_format_exception (status)));
+						}
+					}
 					break;
 				}
 			}
 
-			node = acpi_ns_get_parent_object (node);
+			pci_root_node = acpi_ns_get_parent_node (pci_root_node);
 		}
+
+		/* PCI root bridge not found, use namespace root node */
 	}
 	else {
-		node = handler_obj->addr_handler.node;
+		pci_root_node = handler_obj->address_space.node;
 	}
 
 	/*
-	 * The PCI segment number comes from the _SEG method
+	 * If this region is now initialized, we are done.
+	 * (install_address_space_handler could have initialized it)
 	 */
-	status = acpi_ut_evaluate_numeric_object (METHOD_NAME__SEG, node, &temp);
-	if (ACPI_SUCCESS (status)) {
-		pci_id->segment = LOWORD (temp);
+	if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) {
+		return_ACPI_STATUS (AE_OK);
+	}
+
+	/* Region is still not initialized. Create a new context */
+
+	pci_id = ACPI_MEM_CALLOCATE (sizeof (struct acpi_pci_id));
+	if (!pci_id) {
+		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
 
 	/*
-	 * The PCI bus number comes from the _BBN method
+	 * For PCI_Config space access, we need the segment, bus,
+	 * device and function numbers.  Acquire them here.
+	 */
+
+	/*
+	 * Get the PCI device and function numbers from the _ADR object
+	 * contained in the parent's scope.
+	 */
+	status = acpi_ut_evaluate_numeric_object (METHOD_NAME__ADR, parent_node, &pci_value);
+
+	/*
+	 * The default is zero, and since the allocation above zeroed
+	 * the data, just do nothing on failure.
 	 */
-	status = acpi_ut_evaluate_numeric_object (METHOD_NAME__BBN, node, &temp);
 	if (ACPI_SUCCESS (status)) {
-		pci_id->bus = LOWORD (temp);
+		pci_id->device  = ACPI_HIWORD (ACPI_LODWORD (pci_value));
+		pci_id->function = ACPI_LOWORD (ACPI_LODWORD (pci_value));
 	}
 
+	/* The PCI segment number comes from the _SEG method */
+
+	status = acpi_ut_evaluate_numeric_object (METHOD_NAME__SEG, pci_root_node, &pci_value);
+	if (ACPI_SUCCESS (status)) {
+		pci_id->segment = ACPI_LOWORD (pci_value);
+	}
+
+	/* The PCI bus number comes from the _BBN method */
+
+	status = acpi_ut_evaluate_numeric_object (METHOD_NAME__BBN, pci_root_node, &pci_value);
+	if (ACPI_SUCCESS (status)) {
+		pci_id->bus = ACPI_LOWORD (pci_value);
+	}
+
+	/* Complete this device's pci_id */
+
+	acpi_os_derive_pci_id (pci_root_node, region_obj->region.node, &pci_id);
+
 	*region_context = pci_id;
 	return_ACPI_STATUS (AE_OK);
 }
@@ -263,12 +315,12 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_pci_bar_region_setup
+ * FUNCTION:    acpi_ev_pci_bar_region_setup
  *
- * PARAMETERS:  Region_obj          - region we are interested in
- *              Function            - start or stop
- *              Handler_context     - Address space handler context
- *              Region_context      - Region specific context
+ * PARAMETERS:  region_obj          - Region we are interested in
+ *              Function            - Start or stop
+ *              handler_context     - Address space handler context
+ *              region_context      - Region specific context
  *
  * RETURN:      Status
  *
@@ -280,13 +332,12 @@
 
 acpi_status
 acpi_ev_pci_bar_region_setup (
-	acpi_handle             handle,
-	u32                     function,
-	void                    *handler_context,
-	void                    **region_context)
+	acpi_handle                     handle,
+	u32                             function,
+	void                            *handler_context,
+	void                            **region_context)
 {
-
-	FUNCTION_TRACE ("Ev_pci_bar_region_setup");
+	ACPI_FUNCTION_TRACE ("ev_pci_bar_region_setup");
 
 
 	return_ACPI_STATUS (AE_OK);
@@ -295,12 +346,12 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_cmos_region_setup
+ * FUNCTION:    acpi_ev_cmos_region_setup
  *
- * PARAMETERS:  Region_obj          - region we are interested in
- *              Function            - start or stop
- *              Handler_context     - Address space handler context
- *              Region_context      - Region specific context
+ * PARAMETERS:  region_obj          - Region we are interested in
+ *              Function            - Start or stop
+ *              handler_context     - Address space handler context
+ *              region_context      - Region specific context
  *
  * RETURN:      Status
  *
@@ -312,13 +363,12 @@
 
 acpi_status
 acpi_ev_cmos_region_setup (
-	acpi_handle             handle,
-	u32                     function,
-	void                    *handler_context,
-	void                    **region_context)
+	acpi_handle                     handle,
+	u32                             function,
+	void                            *handler_context,
+	void                            **region_context)
 {
-
-	FUNCTION_TRACE ("Ev_cmos_region_setup");
+	ACPI_FUNCTION_TRACE ("ev_cmos_region_setup");
 
 
 	return_ACPI_STATUS (AE_OK);
@@ -327,12 +377,12 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_default_region_setup
+ * FUNCTION:    acpi_ev_default_region_setup
  *
- * PARAMETERS:  Region_obj          - region we are interested in
- *              Function            - start or stop
- *              Handler_context     - Address space handler context
- *              Region_context      - Region specific context
+ * PARAMETERS:  region_obj          - Region we are interested in
+ *              Function            - Start or stop
+ *              handler_context     - Address space handler context
+ *              region_context      - Region specific context
  *
  * RETURN:      Status
  *
@@ -342,12 +392,12 @@
 
 acpi_status
 acpi_ev_default_region_setup (
-	acpi_handle             handle,
-	u32                     function,
-	void                    *handler_context,
-	void                    **region_context)
+	acpi_handle                     handle,
+	u32                             function,
+	void                            *handler_context,
+	void                            **region_context)
 {
-	FUNCTION_TRACE ("Ev_default_region_setup");
+	ACPI_FUNCTION_TRACE ("ev_default_region_setup");
 
 
 	if (function == ACPI_REGION_DEACTIVATE) {
@@ -363,9 +413,10 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_initialize_region
+ * FUNCTION:    acpi_ev_initialize_region
  *
- * PARAMETERS:  Region_obj - Region we are initializing
+ * PARAMETERS:  region_obj      - Region we are initializing
+ *              acpi_ns_locked  - Is namespace locked?
  *
  * RETURN:      Status
  *
@@ -375,7 +426,7 @@
  *              Get the appropriate address space handler for a newly
  *              created region.
  *
- *              This also performs address space specific intialization.  For
+ *              This also performs address space specific initialization.  For
  *              example, PCI regions must have an _ADR object that contains
  *              a PCI address in the scope of the definition.  This address is
  *              required to perform an access to PCI config space.
@@ -384,113 +435,124 @@
 
 acpi_status
 acpi_ev_initialize_region (
-	acpi_operand_object     *region_obj,
-	u8                      acpi_ns_locked)
+	union acpi_operand_object       *region_obj,
+	u8                              acpi_ns_locked)
 {
-	acpi_operand_object     *handler_obj;
-	acpi_operand_object     *obj_desc;
-	ACPI_ADR_SPACE_TYPE     space_id;
-	acpi_namespace_node     *node;
-	acpi_status             status;
-	acpi_namespace_node     *method_node;
-	acpi_name               *reg_name_ptr = (acpi_name *) METHOD_NAME__REG;
+	union acpi_operand_object       *handler_obj;
+	union acpi_operand_object       *obj_desc;
+	acpi_adr_space_type             space_id;
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
+	struct acpi_namespace_node      *method_node;
+	acpi_name                       *reg_name_ptr = (acpi_name *) METHOD_NAME__REG;
+	union acpi_operand_object       *region_obj2;
 
 
-	FUNCTION_TRACE_U32 ("Ev_initialize_region", acpi_ns_locked);
+	ACPI_FUNCTION_TRACE_U32 ("ev_initialize_region", acpi_ns_locked);
 
 
 	if (!region_obj) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-	node = acpi_ns_get_parent_object (region_obj->region.node);
+	if (region_obj->common.flags & AOPOBJ_OBJECT_INITIALIZED) {
+		return_ACPI_STATUS (AE_OK);
+	}
+
+	region_obj2 = acpi_ns_get_secondary_object (region_obj);
+	if (!region_obj2) {
+		return_ACPI_STATUS (AE_NOT_EXIST);
+	}
+
+	node = acpi_ns_get_parent_node (region_obj->region.node);
 	space_id = region_obj->region.space_id;
 
-	region_obj->region.addr_handler = NULL;
-	region_obj->region.extra->extra.method_REG = NULL;
-	region_obj->region.flags &= ~(AOPOBJ_INITIALIZED);
+	/* Setup defaults */
+
+	region_obj->region.address_space = NULL;
+	region_obj2->extra.method_REG = NULL;
+	region_obj->common.flags &= ~(AOPOBJ_SETUP_COMPLETE);
+	region_obj->common.flags |= AOPOBJ_OBJECT_INITIALIZED;
+
+	/* Find any "_REG" method associated with this region definition */
 
-	/*
-	 *  Find any "_REG" associated with this region definition
-	 */
 	status = acpi_ns_search_node (*reg_name_ptr, node,
 			  ACPI_TYPE_METHOD, &method_node);
 	if (ACPI_SUCCESS (status)) {
 		/*
-		 *  The _REG method is optional and there can be only one per region
-		 *  definition.  This will be executed when the handler is attached
-		 *  or removed
+		 * The _REG method is optional and there can be only one per region
+		 * definition.  This will be executed when the handler is attached
+		 * or removed
 		 */
-		region_obj->region.extra->extra.method_REG = method_node;
+		region_obj2->extra.method_REG = method_node;
 	}
 
 	/*
-	 *  The following loop depends upon the root Node having no parent
-	 *  ie: Acpi_gbl_Root_node->Parent_entry being set to NULL
+	 * The following loop depends upon the root Node having no parent
+	 * ie: acpi_gbl_root_node->parent_entry being set to NULL
 	 */
 	while (node) {
-		/*
-		 *  Check to see if a handler exists
-		 */
+		/* Check to see if a handler exists */
+
 		handler_obj = NULL;
 		obj_desc = acpi_ns_get_attached_object (node);
 		if (obj_desc) {
-			/*
-			 *  can only be a handler if the object exists
-			 */
+			/* Can only be a handler if the object exists */
+
 			switch (node->type) {
 			case ACPI_TYPE_DEVICE:
 
-				handler_obj = obj_desc->device.addr_handler;
+				handler_obj = obj_desc->device.address_space;
 				break;
 
 			case ACPI_TYPE_PROCESSOR:
 
-				handler_obj = obj_desc->processor.addr_handler;
+				handler_obj = obj_desc->processor.address_space;
 				break;
 
 			case ACPI_TYPE_THERMAL:
 
-				handler_obj = obj_desc->thermal_zone.addr_handler;
+				handler_obj = obj_desc->thermal_zone.address_space;
+				break;
+
+			default:
+				/* Ignore other objects */
 				break;
 			}
 
 			while (handler_obj) {
-				/*
-				 *  This guy has at least one address handler
-				 *  see if it has the type we want
-				 */
-				if (handler_obj->addr_handler.space_id == space_id) {
+				/* Is this handler of the correct type? */
+
+				if (handler_obj->address_space.space_id == space_id) {
+					/* Found correct handler */
+
 					ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
 						"Found handler %p for region %p in obj %p\n",
 						handler_obj, region_obj, obj_desc));
 
-					/*
-					 *  Found it! Now update the region and the handler
-					 */
-					acpi_ev_associate_region_and_handler (handler_obj, region_obj,
-							acpi_ns_locked);
+					status = acpi_ev_attach_region (handler_obj, region_obj,
+							 acpi_ns_locked);
+
 					return_ACPI_STATUS (AE_OK);
 				}
 
-				handler_obj = handler_obj->addr_handler.next;
+				/* Try next handler in the list */
 
-			} /* while handlerobj */
+				handler_obj = handler_obj->address_space.next;
+			}
 		}
 
 		/*
-		 *  This one does not have the handler we need
-		 *  Pop up one level
+		 * This node does not have the handler we need;
+		 * Pop up one level
 		 */
-		node = acpi_ns_get_parent_object (node);
+		node = acpi_ns_get_parent_node (node);
+	}
 
-	} /* while Node != ROOT */
+	/* If we get here, there is no handler for this region */
 
-	/*
-	 *  If we get here, there is no handler for this region
-	 */
 	ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
-		"No handler for Region_type %s(%X) (Region_obj %p)\n",
+		"No handler for region_type %s(%X) (region_obj %p)\n",
 		acpi_ut_get_region_name (space_id), space_id, region_obj));
 
 	return_ACPI_STATUS (AE_NOT_EXIST);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/events/evsci.c linux-2.4.22-pre2/drivers/acpi/events/evsci.c
--- linux-2.4.21/drivers/acpi/events/evsci.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/events/evsci.c	2003-06-26 21:43:29.000000000 +0000
@@ -2,281 +2,198 @@
  *
  * Module Name: evsci - System Control Interrupt configuration and
  *                      legacy to ACPI mode state transition functions
- *              $Revision: 74 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
-#include "acpi.h"
-#include "acnamesp.h"
-#include "achware.h"
-#include "acevents.h"
+#include <acpi/acpi.h>
+#include <acpi/acevents.h>
 
 
 #define _COMPONENT          ACPI_EVENTS
-	 MODULE_NAME         ("evsci")
-
-
-/*
- * Elements correspond to counts for TMR, NOT_USED, GBL, PWR_BTN, SLP_BTN, RTC,
- * and GENERAL respectively.  These counts are modified by the ACPI interrupt
- * handler.
- *
- * TBD: [Investigate] Note that GENERAL should probably be split out into
- * one element for each bit in the GPE registers
- */
+	 ACPI_MODULE_NAME    ("evsci")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_sci_handler
+ * FUNCTION:    acpi_ev_sci_xrupt_handler
  *
  * PARAMETERS:  Context   - Calling Context
  *
  * RETURN:      Status code indicates whether interrupt was handled.
  *
  * DESCRIPTION: Interrupt handler that will figure out what function or
- *              control method to call to deal with a SCI.  Installed
- *              using BU interrupt support.
+ *              control method to call to deal with a SCI.
  *
  ******************************************************************************/
 
-static u32
-acpi_ev_sci_handler (void *context)
+static u32 ACPI_SYSTEM_XFACE
+acpi_ev_sci_xrupt_handler (
+	void                            *context)
 {
-	u32                     interrupt_handled = INTERRUPT_NOT_HANDLED;
+	struct acpi_gpe_xrupt_info      *gpe_xrupt_list = context;
+	u32                             interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;
 
 
-	FUNCTION_TRACE("Ev_sci_handler");
+	ACPI_FUNCTION_TRACE("ev_sci_xrupt_handler");
 
 
 	/*
-	 * Make sure that ACPI is enabled by checking SCI_EN.  Note that we are
-	 * required to treat the SCI interrupt as sharable, level, active low.
+	 * We are guaranteed by the ACPI CA initialization/shutdown code that
+	 * if this interrupt handler is installed, ACPI is enabled.
 	 */
-	if (!acpi_hw_register_bit_access (ACPI_READ, ACPI_MTX_DO_NOT_LOCK, SCI_EN)) {
-		/* ACPI is not enabled;  this interrupt cannot be for us */
-
-		return_VALUE (INTERRUPT_NOT_HANDLED);
-	}
 
 	/*
-	 * Fixed Acpi_events:
-	 * -------------
-	 * Check for and dispatch any Fixed Acpi_events that have occurred
+	 * Fixed Events:
+	 * Check for and dispatch any Fixed Events that have occurred
 	 */
 	interrupt_handled |= acpi_ev_fixed_event_detect ();
 
 	/*
-	 * GPEs:
-	 * -----
+	 * General Purpose Events:
 	 * Check for and dispatch any GPEs that have occurred
 	 */
-	interrupt_handled |= acpi_ev_gpe_detect ();
+	interrupt_handled |= acpi_ev_gpe_detect (gpe_xrupt_list);
 
 	return_VALUE (interrupt_handled);
 }
 
 
-/******************************************************************************
- *
- * FUNCTION:    Acpi_ev_install_sci_handler
- *
- * PARAMETERS:  none
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Installs SCI handler.
- *
- ******************************************************************************/
-
-u32
-acpi_ev_install_sci_handler (void)
-{
-	u32                     status = AE_OK;
-
-
-	FUNCTION_TRACE ("Ev_install_sci_handler");
-
-
-	status = acpi_os_install_interrupt_handler ((u32) acpi_gbl_FADT->sci_int,
-			   acpi_ev_sci_handler, NULL);
-	return_ACPI_STATUS (status);
-}
-
-
-/******************************************************************************
-
+/*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_remove_sci_handler
+ * FUNCTION:    acpi_ev_gpe_xrupt_handler
  *
- * PARAMETERS:  none
+ * PARAMETERS:  Context   - Calling Context
  *
- * RETURN:      E_OK if handler uninstalled OK, E_ERROR if handler was not
- *              installed to begin with
+ * RETURN:      Status code indicates whether interrupt was handled.
  *
- * DESCRIPTION: Restores original status of all fixed event enable bits and
- *              removes SCI handler.
+ * DESCRIPTION: Handler for GPE Block Device interrupts
  *
  ******************************************************************************/
 
-acpi_status
-acpi_ev_remove_sci_handler (void)
+u32 ACPI_SYSTEM_XFACE
+acpi_ev_gpe_xrupt_handler (
+	void                            *context)
 {
-	FUNCTION_TRACE ("Ev_remove_sci_handler");
-
+	struct acpi_gpe_xrupt_info      *gpe_xrupt_list = context;
+	u32                             interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;
 
-#if 0
-	/* TBD:[Investigate] Figure this out!!  Disable all events first ???  */
 
-	if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (TMR_FIXED_EVENT)) {
-		acpi_event_disable_event (TMR_FIXED_EVENT);
-	}
+	ACPI_FUNCTION_TRACE("ev_gpe_xrupt_handler");
 
-	if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (GBL_FIXED_EVENT)) {
-		acpi_event_disable_event (GBL_FIXED_EVENT);
-	}
 
-	if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (PWR_BTN_FIXED_EVENT)) {
-		acpi_event_disable_event (PWR_BTN_FIXED_EVENT);
-	}
-
-	if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (SLP_BTN_FIXED_EVENT)) {
-		acpi_event_disable_event (SLP_BTN_FIXED_EVENT);
-	}
-
-	if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (RTC_FIXED_EVENT)) {
-		acpi_event_disable_event (RTC_FIXED_EVENT);
-	}
-
-	original_fixed_enable_bit_status = 0;
-
-#endif
+	/*
+	 * We are guaranteed by the ACPI CA initialization/shutdown code that
+	 * if this interrupt handler is installed, ACPI is enabled.
+	 */
 
-	acpi_os_remove_interrupt_handler ((u32) acpi_gbl_FADT->sci_int,
-			   acpi_ev_sci_handler);
+	/*
+	 * GPEs:
+	 * Check for and dispatch any GPEs that have occurred
+	 */
+	interrupt_handled |= acpi_ev_gpe_detect (gpe_xrupt_list);
 
-	return_ACPI_STATUS (AE_OK);
+	return_VALUE (interrupt_handled);
 }
 
 
-/*******************************************************************************
+/******************************************************************************
  *
- * FUNCTION:    Acpi_ev_restore_acpi_state
+ * FUNCTION:    acpi_ev_install_sci_handler
  *
  * PARAMETERS:  none
  *
- * RETURN:      none
+ * RETURN:      Status
  *
- * DESCRIPTION: Restore the original ACPI state of the machine
+ * DESCRIPTION: Installs SCI handler.
  *
  ******************************************************************************/
 
-void
-acpi_ev_restore_acpi_state (void)
+u32
+acpi_ev_install_sci_handler (void)
 {
-	u32                     index;
-
-
-	FUNCTION_TRACE ("Ev_restore_acpi_state");
-
-
-	/* Restore the state of the chipset enable bits. */
+	u32                             status = AE_OK;
 
-	if (acpi_gbl_restore_acpi_chipset == TRUE) {
-		/* Restore the fixed events */
 
-		if (acpi_hw_register_read (ACPI_MTX_LOCK, PM1_EN) !=
-				acpi_gbl_pm1_enable_register_save) {
-			acpi_hw_register_write (ACPI_MTX_LOCK, PM1_EN,
-				acpi_gbl_pm1_enable_register_save);
-		}
+	ACPI_FUNCTION_TRACE ("ev_install_sci_handler");
 
 
-		/* Ensure that all status bits are clear */
-
-		acpi_hw_clear_acpi_status ();
-
-
-		/* Now restore the GPEs */
-
-		for (index = 0; index < DIV_2 (acpi_gbl_FADT->gpe0blk_len); index++) {
-			if (acpi_hw_register_read (ACPI_MTX_LOCK, GPE0_EN_BLOCK | index) !=
-					acpi_gbl_gpe0enable_register_save[index]) {
-				acpi_hw_register_write (ACPI_MTX_LOCK, GPE0_EN_BLOCK | index,
-					acpi_gbl_gpe0enable_register_save[index]);
-			}
-		}
-
-		/* GPE 1 present? */
-
-		if (acpi_gbl_FADT->gpe1_blk_len) {
-			for (index = 0; index < DIV_2 (acpi_gbl_FADT->gpe1_blk_len); index++) {
-				if (acpi_hw_register_read (ACPI_MTX_LOCK, GPE1_EN_BLOCK | index) !=
-					acpi_gbl_gpe1_enable_register_save[index]) {
-					acpi_hw_register_write (ACPI_MTX_LOCK, GPE1_EN_BLOCK | index,
-						acpi_gbl_gpe1_enable_register_save[index]);
-				}
-			}
-		}
-
-		if (acpi_hw_get_mode() != acpi_gbl_original_mode) {
-			acpi_hw_set_mode (acpi_gbl_original_mode);
-		}
-	}
-
-	return_VOID;
+	status = acpi_os_install_interrupt_handler ((u32) acpi_gbl_FADT->sci_int,
+			   acpi_ev_sci_xrupt_handler, acpi_gbl_gpe_xrupt_list_head);
+	return_ACPI_STATUS (status);
 }
 
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_ev_terminate
+ * FUNCTION:    acpi_ev_remove_sci_handler
  *
  * PARAMETERS:  none
  *
- * RETURN:      none
+ * RETURN:      E_OK if handler uninstalled OK, E_ERROR if handler was not
+ *              installed to begin with
+ *
+ * DESCRIPTION: Remove the SCI interrupt handler.  No further SCIs will be
+ *              taken.
  *
- * DESCRIPTION: free memory allocated for table storage.
+ * Note:  It doesn't seem important to disable all events or set the event
+ *        enable registers to their original values.  The OS should disable
+ *        the SCI interrupt level when the handler is removed, so no more
+ *        events will come in.
  *
  ******************************************************************************/
 
-void
-acpi_ev_terminate (void)
+acpi_status
+acpi_ev_remove_sci_handler (void)
 {
+	acpi_status                     status;
 
-	FUNCTION_TRACE ("Ev_terminate");
 
+	ACPI_FUNCTION_TRACE ("ev_remove_sci_handler");
 
-	/*
-	 * Free global tables, etc.
-	 */
-	if (acpi_gbl_gpe_registers) {
-		ACPI_MEM_FREE (acpi_gbl_gpe_registers);
-	}
-
-	if (acpi_gbl_gpe_info) {
-		ACPI_MEM_FREE (acpi_gbl_gpe_info);
-	}
 
-	return_VOID;
+	/* Just let the OS remove the handler and disable the level */
+
+	status = acpi_os_remove_interrupt_handler ((u32) acpi_gbl_FADT->sci_int,
+			   acpi_ev_sci_xrupt_handler);
+
+	return_ACPI_STATUS (status);
 }
 
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/events/evxface.c linux-2.4.22-pre2/drivers/acpi/events/evxface.c
--- linux-2.4.21/drivers/acpi/events/evxface.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/events/evxface.c	2003-06-26 21:43:28.000000000 +0000
@@ -1,43 +1,59 @@
 /******************************************************************************
  *
  * Module Name: evxface - External interfaces for ACPI events
- *              $Revision: 116 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "achware.h"
-#include "acnamesp.h"
-#include "acevents.h"
-#include "amlcode.h"
-#include "acinterp.h"
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acevents.h>
+#include <acpi/acinterp.h>
 
 #define _COMPONENT          ACPI_EVENTS
-	 MODULE_NAME         ("evxface")
+	 ACPI_MODULE_NAME    ("evxface")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_install_fixed_event_handler
+ * FUNCTION:    acpi_install_fixed_event_handler
  *
  * PARAMETERS:  Event           - Event type to enable.
  *              Handler         - Pointer to the handler function for the
@@ -53,14 +69,14 @@
 
 acpi_status
 acpi_install_fixed_event_handler (
-	u32                     event,
-	acpi_event_handler      handler,
-	void                    *context)
+	u32                             event,
+	acpi_event_handler              handler,
+	void                            *context)
 {
-	acpi_status             status;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Acpi_install_fixed_event_handler");
+	ACPI_FUNCTION_TRACE ("acpi_install_fixed_event_handler");
 
 
 	/* Parameter validation */
@@ -69,23 +85,25 @@
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-	acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+	status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	/* Don't allow two handlers. */
 
 	if (NULL != acpi_gbl_fixed_event_handlers[event].handler) {
-		status = AE_EXIST;
+		status = AE_ALREADY_EXISTS;
 		goto cleanup;
 	}
 
-
 	/* Install the handler before enabling the event */
 
 	acpi_gbl_fixed_event_handlers[event].handler = handler;
 	acpi_gbl_fixed_event_handlers[event].context = context;
 
-	status = acpi_enable_event (event, ACPI_EVENT_FIXED, 0);
-	if (!ACPI_SUCCESS (status)) {
+	status = acpi_enable_event (event, 0);
+	if (ACPI_FAILURE (status)) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Could not enable fixed event.\n"));
 
 		/* Remove the handler */
@@ -93,7 +111,6 @@
 		acpi_gbl_fixed_event_handlers[event].handler = NULL;
 		acpi_gbl_fixed_event_handlers[event].context = NULL;
 	}
-
 	else {
 		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
 			"Enabled fixed event %X, Handler=%p\n", event, handler));
@@ -101,14 +118,14 @@
 
 
 cleanup:
-	acpi_ut_release_mutex (ACPI_MTX_EVENTS);
+	(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_remove_fixed_event_handler
+ * FUNCTION:    acpi_remove_fixed_event_handler
  *
  * PARAMETERS:  Event           - Event type to disable.
  *              Handler         - Address of the handler
@@ -121,13 +138,13 @@
 
 acpi_status
 acpi_remove_fixed_event_handler (
-	u32                     event,
-	acpi_event_handler      handler)
+	u32                             event,
+	acpi_event_handler              handler)
 {
-	acpi_status             status = AE_OK;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE ("Acpi_remove_fixed_event_handler");
+	ACPI_FUNCTION_TRACE ("acpi_remove_fixed_event_handler");
 
 
 	/* Parameter validation */
@@ -136,18 +153,21 @@
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-	acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+	status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	/* Disable the event before removing the handler */
 
-	status = acpi_disable_event(event, ACPI_EVENT_FIXED, 0);
+	status = acpi_disable_event (event, 0);
 
 	/* Always Remove the handler */
 
 	acpi_gbl_fixed_event_handlers[event].handler = NULL;
 	acpi_gbl_fixed_event_handlers[event].context = NULL;
 
-	if (!ACPI_SUCCESS (status)) {
+	if (ACPI_FAILURE (status)) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_WARN,
 			"Could not write to fixed event enable register.\n"));
 	}
@@ -155,19 +175,19 @@
 		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Disabled fixed event %X.\n", event));
 	}
 
-	acpi_ut_release_mutex (ACPI_MTX_EVENTS);
+	(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_install_notify_handler
+ * FUNCTION:    acpi_install_notify_handler
  *
  * PARAMETERS:  Device          - The device for which notifies will be handled
- *              Handler_type    - The type of handler:
- *                                  ACPI_SYSTEM_NOTIFY: System_handler (00-7f)
- *                                  ACPI_DEVICE_NOTIFY: Driver_handler (80-ff)
+ *              handler_type    - The type of handler:
+ *                                  ACPI_SYSTEM_NOTIFY: system_handler (00-7f)
+ *                                  ACPI_DEVICE_NOTIFY: driver_handler (80-ff)
  *              Handler         - Address of the handler
  *              Context         - Value passed to the handler on each GPE
  *
@@ -179,33 +199,37 @@
 
 acpi_status
 acpi_install_notify_handler (
-	acpi_handle             device,
-	u32                     handler_type,
-	acpi_notify_handler     handler,
-	void                    *context)
+	acpi_handle                     device,
+	u32                             handler_type,
+	acpi_notify_handler             handler,
+	void                            *context)
 {
-	acpi_operand_object     *obj_desc;
-	acpi_operand_object     *notify_obj;
-	acpi_namespace_node     *device_node;
-	acpi_status             status = AE_OK;
+	union acpi_operand_object       *obj_desc;
+	union acpi_operand_object       *notify_obj;
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Acpi_install_notify_handler");
+	ACPI_FUNCTION_TRACE ("acpi_install_notify_handler");
 
 
 	/* Parameter validation */
 
-	if ((!handler) ||
+	if ((!device)  ||
+		(!handler) ||
 		(handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	/* Convert and validate the device handle */
 
-	device_node = acpi_ns_map_handle_to_node (device);
-	if (!device_node) {
+	node = acpi_ns_map_handle_to_node (device);
+	if (!node) {
 		status = AE_BAD_PARAMETER;
 		goto unlock_and_exit;
 	}
@@ -220,22 +244,22 @@
 		/* Make sure the handler is not already installed */
 
 		if (((handler_type == ACPI_SYSTEM_NOTIFY) &&
-			  acpi_gbl_sys_notify.handler) ||
+				acpi_gbl_system_notify.handler)        ||
 			((handler_type == ACPI_DEVICE_NOTIFY) &&
-			  acpi_gbl_drv_notify.handler)) {
-			status = AE_EXIST;
+				acpi_gbl_device_notify.handler)) {
+			status = AE_ALREADY_EXISTS;
 			goto unlock_and_exit;
 		}
 
 		if (handler_type == ACPI_SYSTEM_NOTIFY) {
-			acpi_gbl_sys_notify.node = device_node;
-			acpi_gbl_sys_notify.handler = handler;
-			acpi_gbl_sys_notify.context = context;
+			acpi_gbl_system_notify.node  = node;
+			acpi_gbl_system_notify.handler = handler;
+			acpi_gbl_system_notify.context = context;
 		}
 		else /* ACPI_DEVICE_NOTIFY */ {
-			acpi_gbl_drv_notify.node = device_node;
-			acpi_gbl_drv_notify.handler = handler;
-			acpi_gbl_drv_notify.context = context;
+			acpi_gbl_device_notify.node  = node;
+			acpi_gbl_device_notify.handler = handler;
+			acpi_gbl_device_notify.context = context;
 		}
 
 		/* Global notify handler installed */
@@ -247,37 +271,31 @@
 	 * Note that only certain object types can receive notifications.
 	 */
 	else {
-		/*
-		 * These are the ONLY objects that can receive ACPI notifications
-		 */
-		if ((device_node->type != ACPI_TYPE_DEVICE)    &&
-			(device_node->type != ACPI_TYPE_PROCESSOR) &&
-			(device_node->type != ACPI_TYPE_POWER)     &&
-			(device_node->type != ACPI_TYPE_THERMAL)) {
-			status = AE_BAD_PARAMETER;
+		/* Notifies allowed on this object? */
+
+		if (!acpi_ev_is_notify_object (node)) {
+			status = AE_TYPE;
 			goto unlock_and_exit;
 		}
 
 		/* Check for an existing internal object */
 
-		obj_desc = acpi_ns_get_attached_object (device_node);
+		obj_desc = acpi_ns_get_attached_object (node);
 		if (obj_desc) {
-
 			/* Object exists - make sure there's no handler */
 
 			if (((handler_type == ACPI_SYSTEM_NOTIFY) &&
-				  obj_desc->device.sys_handler) ||
+					obj_desc->common_notify.system_notify) ||
 				((handler_type == ACPI_DEVICE_NOTIFY) &&
-				  obj_desc->device.drv_handler)) {
-				status = AE_EXIST;
+					obj_desc->common_notify.device_notify)) {
+				status = AE_ALREADY_EXISTS;
 				goto unlock_and_exit;
 			}
 		}
-
 		else {
 			/* Create a new object */
 
-			obj_desc = acpi_ut_create_internal_object (device_node->type);
+			obj_desc = acpi_ut_create_internal_object (node->type);
 			if (!obj_desc) {
 				status = AE_NO_MEMORY;
 				goto unlock_and_exit;
@@ -285,7 +303,12 @@
 
 			/* Attach new object to the Node */
 
-			status = acpi_ns_attach_object (device, obj_desc, (u8) device_node->type);
+			status = acpi_ns_attach_object (device, obj_desc, node->type);
+
+			/* Remove local reference to the object */
+
+			acpi_ut_remove_reference (obj_desc);
+
 			if (ACPI_FAILURE (status)) {
 				goto unlock_and_exit;
 			}
@@ -293,41 +316,39 @@
 
 		/* Install the handler */
 
-		notify_obj = acpi_ut_create_internal_object (INTERNAL_TYPE_NOTIFY);
+		notify_obj = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_NOTIFY);
 		if (!notify_obj) {
 			status = AE_NO_MEMORY;
 			goto unlock_and_exit;
 		}
 
-		notify_obj->notify_handler.node = device_node;
-		notify_obj->notify_handler.handler = handler;
-		notify_obj->notify_handler.context = context;
-
+		notify_obj->notify.node   = node;
+		notify_obj->notify.handler = handler;
+		notify_obj->notify.context = context;
 
 		if (handler_type == ACPI_SYSTEM_NOTIFY) {
-			obj_desc->device.sys_handler = notify_obj;
+			obj_desc->common_notify.system_notify = notify_obj;
 		}
-
 		else /* ACPI_DEVICE_NOTIFY */ {
-			obj_desc->device.drv_handler = notify_obj;
+			obj_desc->common_notify.device_notify = notify_obj;
 		}
 	}
 
 
 unlock_and_exit:
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_remove_notify_handler
+ * FUNCTION:    acpi_remove_notify_handler
  *
  * PARAMETERS:  Device          - The device for which notifies will be handled
- *              Handler_type    - The type of handler:
- *                                  ACPI_SYSTEM_NOTIFY: System_handler (00-7f)
- *                                  ACPI_DEVICE_NOTIFY: Driver_handler (80-ff)
+ *              handler_type    - The type of handler:
+ *                                  ACPI_SYSTEM_NOTIFY: system_handler (00-7f)
+ *                                  ACPI_DEVICE_NOTIFY: driver_handler (80-ff)
  *              Handler         - Address of the handler
  * RETURN:      Status
  *
@@ -337,32 +358,36 @@
 
 acpi_status
 acpi_remove_notify_handler (
-	acpi_handle             device,
-	u32                     handler_type,
-	acpi_notify_handler     handler)
+	acpi_handle                     device,
+	u32                             handler_type,
+	acpi_notify_handler             handler)
 {
-	acpi_operand_object     *notify_obj;
-	acpi_operand_object     *obj_desc;
-	acpi_namespace_node     *device_node;
-	acpi_status             status = AE_OK;
+	union acpi_operand_object       *notify_obj;
+	union acpi_operand_object       *obj_desc;
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Acpi_remove_notify_handler");
+	ACPI_FUNCTION_TRACE ("acpi_remove_notify_handler");
 
 
 	/* Parameter validation */
 
-	if ((!handler) ||
+	if ((!device)  ||
+		(!handler) ||
 		(handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	/* Convert and validate the device handle */
 
-	device_node = acpi_ns_map_handle_to_node (device);
-	if (!device_node) {
+	node = acpi_ns_map_handle_to_node (device);
+	if (!node) {
 		status = AE_BAD_PARAMETER;
 		goto unlock_and_exit;
 	}
@@ -374,22 +399,22 @@
 		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing notify handler for ROOT object.\n"));
 
 		if (((handler_type == ACPI_SYSTEM_NOTIFY) &&
-			  !acpi_gbl_sys_notify.handler) ||
+			  !acpi_gbl_system_notify.handler) ||
 			((handler_type == ACPI_DEVICE_NOTIFY) &&
-			  !acpi_gbl_drv_notify.handler)) {
+			  !acpi_gbl_device_notify.handler)) {
 			status = AE_NOT_EXIST;
 			goto unlock_and_exit;
 		}
 
 		if (handler_type == ACPI_SYSTEM_NOTIFY) {
-			acpi_gbl_sys_notify.node  = NULL;
-			acpi_gbl_sys_notify.handler = NULL;
-			acpi_gbl_sys_notify.context = NULL;
+			acpi_gbl_system_notify.node  = NULL;
+			acpi_gbl_system_notify.handler = NULL;
+			acpi_gbl_system_notify.context = NULL;
 		}
 		else {
-			acpi_gbl_drv_notify.node  = NULL;
-			acpi_gbl_drv_notify.handler = NULL;
-			acpi_gbl_drv_notify.context = NULL;
+			acpi_gbl_device_notify.node  = NULL;
+			acpi_gbl_device_notify.handler = NULL;
+			acpi_gbl_device_notify.context = NULL;
 		}
 	}
 
@@ -397,20 +422,16 @@
 	 * All Other Objects
 	 */
 	else {
-		/*
-		 * These are the ONLY objects that can receive ACPI notifications
-		 */
-		if ((device_node->type != ACPI_TYPE_DEVICE)    &&
-			(device_node->type != ACPI_TYPE_PROCESSOR) &&
-			(device_node->type != ACPI_TYPE_POWER)     &&
-			(device_node->type != ACPI_TYPE_THERMAL)) {
-			status = AE_BAD_PARAMETER;
+		/* Notifies allowed on this object? */
+
+		if (!acpi_ev_is_notify_object (node)) {
+			status = AE_TYPE;
 			goto unlock_and_exit;
 		}
 
 		/* Check for an existing internal object */
 
-		obj_desc = acpi_ns_get_attached_object (device_node);
+		obj_desc = acpi_ns_get_attached_object (node);
 		if (!obj_desc) {
 			status = AE_NOT_EXIST;
 			goto unlock_and_exit;
@@ -419,14 +440,14 @@
 		/* Object exists - make sure there's an existing handler */
 
 		if (handler_type == ACPI_SYSTEM_NOTIFY) {
-			notify_obj = obj_desc->device.sys_handler;
+			notify_obj = obj_desc->common_notify.system_notify;
 		}
 		else {
-			notify_obj = obj_desc->device.drv_handler;
+			notify_obj = obj_desc->common_notify.device_notify;
 		}
 
 		if ((!notify_obj) ||
-			(notify_obj->notify_handler.handler != handler)) {
+			(notify_obj->notify.handler != handler)) {
 			status = AE_BAD_PARAMETER;
 			goto unlock_and_exit;
 		}
@@ -434,10 +455,10 @@
 		/* Remove the handler */
 
 		if (handler_type == ACPI_SYSTEM_NOTIFY) {
-			obj_desc->device.sys_handler = NULL;
+			obj_desc->common_notify.system_notify = NULL;
 		}
 		else {
-			obj_desc->device.drv_handler = NULL;
+			obj_desc->common_notify.device_notify = NULL;
 		}
 
 		acpi_ut_remove_reference (notify_obj);
@@ -445,17 +466,17 @@
 
 
 unlock_and_exit:
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_install_gpe_handler
+ * FUNCTION:    acpi_install_gpe_handler
  *
- * PARAMETERS:  Gpe_number      - The GPE number.  The numbering scheme is
- *                                bank 0 first, then bank 1.
+ * PARAMETERS:  gpe_number      - The GPE number within the GPE block
+ *              gpe_block       - GPE block (NULL == FADT GPEs)
  *              Type            - Whether this GPE should be treated as an
  *                                edge- or level-triggered interrupt.
  *              Handler         - Address of the handler
@@ -469,124 +490,150 @@
 
 acpi_status
 acpi_install_gpe_handler (
-	u32                     gpe_number,
-	u32                     type,
-	acpi_gpe_handler        handler,
-	void                    *context)
+	acpi_handle                     gpe_device,
+	u32                             gpe_number,
+	u32                             type,
+	acpi_gpe_handler                handler,
+	void                            *context)
 {
-	acpi_status             status = AE_OK;
+	acpi_status                     status;
+	struct acpi_gpe_event_info      *gpe_event_info;
 
 
-	FUNCTION_TRACE ("Acpi_install_gpe_handler");
+	ACPI_FUNCTION_TRACE ("acpi_install_gpe_handler");
 
 
 	/* Parameter validation */
 
-	if (!handler || (gpe_number > ACPI_GPE_MAX)) {
+	if (!handler) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
+	status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
 	/* Ensure that we have a valid GPE number */
 
-	if (acpi_gbl_gpe_valid[gpe_number] == ACPI_GPE_INVALID) {
-		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number);
+	if (!gpe_event_info) {
+		status = AE_BAD_PARAMETER;
+		goto unlock_and_exit;
 	}
 
-	acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
-
 	/* Make sure that there isn't a handler there already */
 
-	if (acpi_gbl_gpe_info[gpe_number].handler) {
-		status = AE_EXIST;
-		goto cleanup;
+	if (gpe_event_info->handler) {
+		status = AE_ALREADY_EXISTS;
+		goto unlock_and_exit;
 	}
 
 	/* Install the handler */
 
-	acpi_gbl_gpe_info[gpe_number].handler = handler;
-	acpi_gbl_gpe_info[gpe_number].context = context;
-	acpi_gbl_gpe_info[gpe_number].type = (u8) type;
+	acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR);
+	gpe_event_info->handler = handler;
+	gpe_event_info->context = context;
+	gpe_event_info->flags = (u8) type;
+	acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR);
 
 	/* Clear the GPE (of stale events), the enable it */
 
-	acpi_hw_clear_gpe (gpe_number);
-	acpi_hw_enable_gpe (gpe_number);
+	status = acpi_hw_clear_gpe (gpe_event_info);
+	if (ACPI_FAILURE (status)) {
+		goto unlock_and_exit;
+	}
+
+	status = acpi_hw_enable_gpe (gpe_event_info);
 
 
-cleanup:
-	acpi_ut_release_mutex (ACPI_MTX_EVENTS);
+unlock_and_exit:
+	(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_remove_gpe_handler
+ * FUNCTION:    acpi_remove_gpe_handler
  *
- * PARAMETERS:  Gpe_number      - The event to remove a handler
+ * PARAMETERS:  gpe_number      - The event to remove a handler
+ *              gpe_block       - GPE block (NULL == FADT GPEs)
  *              Handler         - Address of the handler
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Remove a handler for a General Purpose Acpi_event.
+ * DESCRIPTION: Remove a handler for a General Purpose acpi_event.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_remove_gpe_handler (
-	u32                     gpe_number,
-	acpi_gpe_handler        handler)
+	acpi_handle                     gpe_device,
+	u32                             gpe_number,
+	acpi_gpe_handler                handler)
 {
-	acpi_status             status = AE_OK;
+	acpi_status                     status;
+	struct acpi_gpe_event_info      *gpe_event_info;
 
 
-	FUNCTION_TRACE ("Acpi_remove_gpe_handler");
+	ACPI_FUNCTION_TRACE ("acpi_remove_gpe_handler");
 
 
 	/* Parameter validation */
 
-	if (!handler || (gpe_number > ACPI_GPE_MAX)) {
+	if (!handler) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
+	status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
 	/* Ensure that we have a valid GPE number */
 
-	if (acpi_gbl_gpe_valid[gpe_number] == ACPI_GPE_INVALID) {
-		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number);
+	if (!gpe_event_info) {
+		status = AE_BAD_PARAMETER;
+		goto unlock_and_exit;
 	}
 
 	/* Disable the GPE before removing the handler */
 
-	acpi_hw_disable_gpe (gpe_number);
-
-	acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+	status = acpi_hw_disable_gpe (gpe_event_info);
+	if (ACPI_FAILURE (status)) {
+		goto unlock_and_exit;
+	}
 
 	/* Make sure that the installed handler is the same */
 
-	if (acpi_gbl_gpe_info[gpe_number].handler != handler) {
-		acpi_hw_enable_gpe (gpe_number);
+	if (gpe_event_info->handler != handler) {
+		(void) acpi_hw_enable_gpe (gpe_event_info);
 		status = AE_BAD_PARAMETER;
-		goto cleanup;
+		goto unlock_and_exit;
 	}
 
 	/* Remove the handler */
 
-	acpi_gbl_gpe_info[gpe_number].handler = NULL;
-	acpi_gbl_gpe_info[gpe_number].context = NULL;
+	acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR);
+	gpe_event_info->handler = NULL;
+	gpe_event_info->context = NULL;
+	acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR);
 
 
-cleanup:
-	acpi_ut_release_mutex (ACPI_MTX_EVENTS);
+unlock_and_exit:
+	(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_acquire_global_lock
+ * FUNCTION:    acpi_acquire_global_lock
  *
  * PARAMETERS:  Timeout         - How long the caller is willing to wait
- *              Out_handle      - A handle to the lock if acquired
+ *              out_handle      - A handle to the lock if acquired
  *
  * RETURN:      Status
  *
@@ -596,32 +643,38 @@
 
 acpi_status
 acpi_acquire_global_lock (
-	void)
+	u16                             timeout,
+	u32                             *handle)
 {
-	acpi_status             status;
+	acpi_status                     status;
+
 
+	if (!handle) {
+		return (AE_BAD_PARAMETER);
+	}
 
 	status = acpi_ex_enter_interpreter ();
 	if (ACPI_FAILURE (status)) {
 		return (status);
 	}
 
-	/*
-	 * TBD: [Restructure] add timeout param to internal interface, and
-	 * perhaps INTERPRETER_LOCKED
-	 */
-	status = acpi_ev_acquire_global_lock ();
+	status = acpi_ev_acquire_global_lock (timeout);
 	acpi_ex_exit_interpreter ();
 
+	if (ACPI_SUCCESS (status)) {
+		acpi_gbl_global_lock_handle++;
+		*handle = acpi_gbl_global_lock_handle;
+	}
+
 	return (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_release_global_lock
+ * FUNCTION:    acpi_release_global_lock
  *
- * PARAMETERS:  Handle      - Returned from Acpi_acquire_global_lock
+ * PARAMETERS:  Handle      - Returned from acpi_acquire_global_lock
  *
  * RETURN:      Status
  *
@@ -631,11 +684,17 @@
 
 acpi_status
 acpi_release_global_lock (
-	void)
+	u32                             handle)
 {
+	acpi_status                     status;
+
 
-	acpi_ev_release_global_lock ();
-	return (AE_OK);
+	if (handle != acpi_gbl_global_lock_handle) {
+		return (AE_NOT_ACQUIRED);
+	}
+
+	status = acpi_ev_release_global_lock ();
+	return (status);
 }
 
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/events/evxfevnt.c linux-2.4.22-pre2/drivers/acpi/events/evxfevnt.c
--- linux-2.4.21/drivers/acpi/events/evxfevnt.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/events/evxfevnt.c	2003-06-26 21:43:15.000000000 +0000
@@ -1,43 +1,58 @@
 /******************************************************************************
  *
  * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
- *              $Revision: 38 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "achware.h"
-#include "acnamesp.h"
-#include "acevents.h"
-#include "amlcode.h"
-#include "acinterp.h"
+#include <acpi/acpi.h>
+#include <acpi/acevents.h>
+#include <acpi/acnamesp.h>
 
 #define _COMPONENT          ACPI_EVENTS
-	 MODULE_NAME         ("evxfevnt")
+	 ACPI_MODULE_NAME    ("evxfevnt")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_enable
+ * FUNCTION:    acpi_enable
  *
  * PARAMETERS:  None
  *
@@ -50,74 +65,79 @@
 acpi_status
 acpi_enable (void)
 {
-	acpi_status             status;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE ("Acpi_enable");
+	ACPI_FUNCTION_TRACE ("acpi_enable");
 
 
-	/* Make sure we've got ACPI tables */
+	/* Make sure we have the FADT*/
 
-	if (!acpi_gbl_DSDT) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No ACPI tables present!\n"));
+	if (!acpi_gbl_FADT) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No FADT information present!\n"));
 		return_ACPI_STATUS (AE_NO_ACPI_TABLES);
 	}
 
-	/* Make sure the BIOS supports ACPI mode */
-
-	if (SYS_MODE_LEGACY == acpi_hw_get_mode_capabilities()) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Only legacy mode supported!\n"));
-		return_ACPI_STATUS (AE_ERROR);
+	if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n"));
 	}
+	else {
+		/* Transition to ACPI mode */
 
-	/* Transition to ACPI mode */
+		status = acpi_hw_set_mode (ACPI_SYS_MODE_ACPI);
+		if (ACPI_FAILURE (status)) {
+			ACPI_REPORT_ERROR (("Could not transition to ACPI mode.\n"));
+			return_ACPI_STATUS (status);
+		}
 
-	status = acpi_hw_set_mode (SYS_MODE_ACPI);
-	if (ACPI_FAILURE (status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_FATAL, "Could not transition to ACPI mode.\n"));
-		return_ACPI_STATUS (status);
+		ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Transition to ACPI mode successful\n"));
 	}
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_OK, "Transition to ACPI mode successful\n"));
-
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_disable
+ * FUNCTION:    acpi_disable
  *
  * PARAMETERS:  None
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Returns the system to original ACPI/legacy mode, and
- *              uninstalls the SCI interrupt handler.
+ * DESCRIPTION: Transfers the system into LEGACY mode.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_disable (void)
 {
-	acpi_status             status;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE ("Acpi_disable");
+	ACPI_FUNCTION_TRACE ("acpi_disable");
 
 
-	/* Restore original mode  */
+	if (!acpi_gbl_FADT) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No FADT information present!\n"));
+		return_ACPI_STATUS (AE_NO_ACPI_TABLES);
+	}
 
-	status = acpi_hw_set_mode (acpi_gbl_original_mode);
-	if (ACPI_FAILURE (status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unable to transition to original mode"));
-		return_ACPI_STATUS (status);
+	if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in legacy (non-ACPI) mode\n"));
 	}
+	else {
+		/* Transition to LEGACY mode */
+
+		status = acpi_hw_set_mode (ACPI_SYS_MODE_LEGACY);
 
-	/* Unload the SCI interrupt handler  */
+		if (ACPI_FAILURE (status)) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not exit ACPI mode to legacy mode"));
+			return_ACPI_STATUS (status);
+		}
 
-	acpi_ev_remove_sci_handler ();
-	acpi_ev_restore_acpi_state ();
+		ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n"));
+	}
 
 	return_ACPI_STATUS (status);
 }
@@ -125,107 +145,179 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_enable_event
+ * FUNCTION:    acpi_enable_event
  *
- * PARAMETERS:  Event           - The fixed event or GPE to be enabled
- *              Type            - The type of event
- *              Flags           - Just enable, or also wake enable?
+ * PARAMETERS:  Event           - The fixed eventto be enabled
+ *              Flags           - Reserved
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Enable an ACPI event (fixed and general purpose)
+ * DESCRIPTION: Enable an ACPI event (fixed)
  *
  ******************************************************************************/
 
 acpi_status
 acpi_enable_event (
-	u32                     event,
-	u32                     type,
-	u32                     flags)
+	u32                             event,
+	u32                             flags)
 {
-	acpi_status             status = AE_OK;
-	u32                     register_id;
+	acpi_status                     status = AE_OK;
+	u32                             value;
 
 
-	FUNCTION_TRACE ("Acpi_enable_event");
+	ACPI_FUNCTION_TRACE ("acpi_enable_event");
 
 
-	/* The Type must be either Fixed Acpi_event or GPE */
+	/* Decode the Fixed Event */
 
-	switch (type) {
+	if (event > ACPI_EVENT_MAX) {
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	}
 
-	case ACPI_EVENT_FIXED:
+	/*
+	 * Enable the requested fixed event (by writing a one to the
+	 * enable register bit)
+	 */
+	status = acpi_set_register (acpi_gbl_fixed_event_info[event].enable_register_id,
+			 1, ACPI_MTX_LOCK);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
-		/* Decode the Fixed Acpi_event */
+	/* Make sure that the hardware responded */
 
-		switch (event) {
-		case ACPI_EVENT_PMTIMER:
-			register_id = TMR_EN;
-			break;
+	status = acpi_get_register (acpi_gbl_fixed_event_info[event].enable_register_id,
+			  &value, ACPI_MTX_LOCK);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
-		case ACPI_EVENT_GLOBAL:
-			register_id = GBL_EN;
-			break;
+	if (value != 1) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"Could not enable %s event\n", acpi_ut_get_event_name (event)));
+		return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
+	}
 
-		case ACPI_EVENT_POWER_BUTTON:
-			register_id = PWRBTN_EN;
-			break;
+	return_ACPI_STATUS (status);
+}
 
-		case ACPI_EVENT_SLEEP_BUTTON:
-			register_id = SLPBTN_EN;
-			break;
 
-		case ACPI_EVENT_RTC:
-			register_id = RTC_EN;
-			break;
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_enable_gpe
+ *
+ * PARAMETERS:  gpe_device      - Parent GPE Device
+ *              gpe_number      - GPE level within the GPE block
+ *              Flags           - Just enable, or also wake enable?
+ *                                Called from ISR or not
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Enable an ACPI event (general purpose)
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_enable_gpe (
+	acpi_handle                     gpe_device,
+	u32                             gpe_number,
+	u32                             flags)
+{
+	acpi_status                     status = AE_OK;
+	struct acpi_gpe_event_info      *gpe_event_info;
 
-		default:
-			return_ACPI_STATUS (AE_BAD_PARAMETER);
-			break;
-		}
 
-		/*
-		 * Enable the requested fixed event (by writing a one to the
-		 * enable register bit)
-		 */
-		acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, register_id, 1);
-
-		if (1 != acpi_hw_register_bit_access(ACPI_READ, ACPI_MTX_LOCK, register_id)) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-				"Fixed event bit clear when it should be set\n"));
-			return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
+	ACPI_FUNCTION_TRACE ("acpi_enable_gpe");
+
+
+	/* Use semaphore lock if not executing at interrupt level */
+
+	if (flags & ACPI_NOT_ISR) {
+		status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
 		}
+	}
 
-		break;
+	/* Ensure that we have a valid GPE number */
 
+	gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number);
+	if (!gpe_event_info) {
+		status = AE_BAD_PARAMETER;
+		goto unlock_and_exit;
+	}
 
-	case ACPI_EVENT_GPE:
+	/* Enable the requested GPE number */
 
-		/* Ensure that we have a valid GPE number */
+	status = acpi_hw_enable_gpe (gpe_event_info);
+	if (ACPI_FAILURE (status)) {
+		goto unlock_and_exit;
+	}
 
-		if ((event > ACPI_GPE_MAX) ||
-			(acpi_gbl_gpe_valid[event] == ACPI_GPE_INVALID)) {
-			return_ACPI_STATUS (AE_BAD_PARAMETER);
-		}
+	if (flags & ACPI_EVENT_WAKE_ENABLE) {
+		acpi_hw_enable_gpe_for_wakeup (gpe_event_info);
+	}
 
+unlock_and_exit:
+	if (flags & ACPI_NOT_ISR) {
+		(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
+	}
+	return_ACPI_STATUS (status);
+}
 
-		/* Enable the requested GPE number */
 
-		if (flags & ACPI_EVENT_ENABLE) {
-			acpi_hw_enable_gpe (event);
-		}
-		if (flags & ACPI_EVENT_WAKE_ENABLE) {
-			acpi_hw_enable_gpe_for_wakeup (event);
-		}
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_disable_event
+ *
+ * PARAMETERS:  Event           - The fixed eventto be enabled
+ *              Flags           - Reserved
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Disable an ACPI event (fixed)
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_disable_event (
+	u32                             event,
+	u32                             flags)
+{
+	acpi_status                     status = AE_OK;
+	u32                             value;
 
-		break;
 
+	ACPI_FUNCTION_TRACE ("acpi_disable_event");
 
-	default:
 
-		status = AE_BAD_PARAMETER;
+	/* Decode the Fixed Event */
+
+	if (event > ACPI_EVENT_MAX) {
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	}
+
+	/*
+	 * Disable the requested fixed event (by writing a zero to the
+	 * enable register bit)
+	 */
+	status = acpi_set_register (acpi_gbl_fixed_event_info[event].enable_register_id,
+			 0, ACPI_MTX_LOCK);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	status = acpi_get_register (acpi_gbl_fixed_event_info[event].enable_register_id,
+			 &value, ACPI_MTX_LOCK);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
 	}
 
+	if (value != 0) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"Could not disable %s events\n", acpi_ut_get_event_name (event)));
+		return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
+	}
 
 	return_ACPI_STATUS (status);
 }
@@ -233,293 +325,412 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_disable_event
+ * FUNCTION:    acpi_disable_gpe
  *
- * PARAMETERS:  Event           - The fixed event or GPE to be enabled
- *              Type            - The type of event, fixed or general purpose
- *              Flags           - Wake disable vs. non-wake disable
+ * PARAMETERS:  gpe_device      - Parent GPE Device
+ *              gpe_number      - GPE level within the GPE block
+ *              Flags           - Just enable, or also wake enable?
+ *                                Called from ISR or not
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Disable an ACPI event (fixed and general purpose)
+ * DESCRIPTION: Disable an ACPI event (general purpose)
  *
  ******************************************************************************/
 
 acpi_status
-acpi_disable_event (
-	u32                     event,
-	u32                     type,
-	u32                     flags)
+acpi_disable_gpe (
+	acpi_handle                     gpe_device,
+	u32                             gpe_number,
+	u32                             flags)
 {
-	acpi_status             status = AE_OK;
-	u32                     register_id;
+	acpi_status                     status = AE_OK;
+	struct acpi_gpe_event_info      *gpe_event_info;
+
+
+	ACPI_FUNCTION_TRACE ("acpi_disable_gpe");
+
+
+	/* Use semaphore lock if not executing at interrupt level */
+
+	if (flags & ACPI_NOT_ISR) {
+		status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
+		}
+	}
 
+	/* Ensure that we have a valid GPE number */
 
-	FUNCTION_TRACE ("Acpi_disable_event");
+	gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number);
+	if (!gpe_event_info) {
+		status = AE_BAD_PARAMETER;
+		goto unlock_and_exit;
+	}
+
+	/*
+	 * Only disable the requested GPE number for wake if specified.
+	 * Otherwise, turn it totally off
+	 */
+	if (flags & ACPI_EVENT_WAKE_DISABLE) {
+		acpi_hw_disable_gpe_for_wakeup (gpe_event_info);
+	}
+	else {
+		status = acpi_hw_disable_gpe (gpe_event_info);
+	}
 
+unlock_and_exit:
+	if (flags & ACPI_NOT_ISR) {
+		(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
+	}
+	return_ACPI_STATUS (status);
+}
 
-	/* The Type must be either Fixed Acpi_event or GPE */
 
-	switch (type) {
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_clear_event
+ *
+ * PARAMETERS:  Event           - The fixed event to be cleared
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Clear an ACPI event (fixed)
+ *
+ ******************************************************************************/
 
-	case ACPI_EVENT_FIXED:
+acpi_status
+acpi_clear_event (
+	u32                             event)
+{
+	acpi_status                     status = AE_OK;
 
-		/* Decode the Fixed Acpi_event */
 
-		switch (event) {
-		case ACPI_EVENT_PMTIMER:
-			register_id = TMR_EN;
-			break;
+	ACPI_FUNCTION_TRACE ("acpi_clear_event");
 
-		case ACPI_EVENT_GLOBAL:
-			register_id = GBL_EN;
-			break;
 
-		case ACPI_EVENT_POWER_BUTTON:
-			register_id = PWRBTN_EN;
-			break;
+	/* Decode the Fixed Event */
 
-		case ACPI_EVENT_SLEEP_BUTTON:
-			register_id = SLPBTN_EN;
-			break;
+	if (event > ACPI_EVENT_MAX) {
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	}
 
-		case ACPI_EVENT_RTC:
-			register_id = RTC_EN;
-			break;
+	/*
+	 * Clear the requested fixed event (By writing a one to the
+	 * status register bit)
+	 */
+	status = acpi_set_register (acpi_gbl_fixed_event_info[event].status_register_id,
+			1, ACPI_MTX_LOCK);
 
-		default:
-			return_ACPI_STATUS (AE_BAD_PARAMETER);
-			break;
-		}
+	return_ACPI_STATUS (status);
+}
 
-		/*
-		 * Disable the requested fixed event (by writing a zero to the
-		 * enable register bit)
-		 */
-		acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, register_id, 0);
-
-		if (0 != acpi_hw_register_bit_access(ACPI_READ, ACPI_MTX_LOCK, register_id)) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-				"Fixed event bit set when it should be clear,\n"));
-			return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
-		}
 
-		break;
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_clear_gpe
+ *
+ * PARAMETERS:  gpe_device      - Parent GPE Device
+ *              gpe_number      - GPE level within the GPE block
+ *              Flags           - Called from an ISR or not
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Clear an ACPI event (general purpose)
+ *
+ ******************************************************************************/
 
+acpi_status
+acpi_clear_gpe (
+	acpi_handle                     gpe_device,
+	u32                             gpe_number,
+	u32                             flags)
+{
+	acpi_status                     status = AE_OK;
+	struct acpi_gpe_event_info      *gpe_event_info;
 
-	case ACPI_EVENT_GPE:
 
-		/* Ensure that we have a valid GPE number */
+	ACPI_FUNCTION_TRACE ("acpi_clear_gpe");
 
-		if ((event > ACPI_GPE_MAX) ||
-			(acpi_gbl_gpe_valid[event] == ACPI_GPE_INVALID)) {
-			return_ACPI_STATUS (AE_BAD_PARAMETER);
-		}
 
-		/* Disable the requested GPE number */
+	/* Use semaphore lock if not executing at interrupt level */
 
-		if (flags & ACPI_EVENT_DISABLE) {
-			acpi_hw_disable_gpe (event);
-		}
-		if (flags & ACPI_EVENT_WAKE_DISABLE) {
-			acpi_hw_disable_gpe_for_wakeup (event);
+	if (flags & ACPI_NOT_ISR) {
+		status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
 		}
+	}
 
-		break;
-
+	/* Ensure that we have a valid GPE number */
 
-	default:
+	gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number);
+	if (!gpe_event_info) {
 		status = AE_BAD_PARAMETER;
+		goto unlock_and_exit;
 	}
 
+	status = acpi_hw_clear_gpe (gpe_event_info);
+
+unlock_and_exit:
+	if (flags & ACPI_NOT_ISR) {
+		(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
+	}
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_clear_event
+ * FUNCTION:    acpi_get_event_status
  *
- * PARAMETERS:  Event           - The fixed event or GPE to be cleared
- *              Type            - The type of event
+ * PARAMETERS:  Event           - The fixed event
+ *              Event Status    - Where the current status of the event will
+ *                                be returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Clear an ACPI event (fixed and general purpose)
+ * DESCRIPTION: Obtains and returns the current status of the event
  *
  ******************************************************************************/
 
 acpi_status
-acpi_clear_event (
-	u32                     event,
-	u32                     type)
+acpi_get_event_status (
+	u32                             event,
+	acpi_event_status               *event_status)
 {
-	acpi_status             status = AE_OK;
-	u32                     register_id;
-
+	acpi_status                     status = AE_OK;
 
-	FUNCTION_TRACE ("Acpi_clear_event");
 
+	ACPI_FUNCTION_TRACE ("acpi_get_event_status");
 
-	/* The Type must be either Fixed Acpi_event or GPE */
 
-	switch (type) {
+	if (!event_status) {
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	}
 
-	case ACPI_EVENT_FIXED:
+	/* Decode the Fixed Event */
 
-		/* Decode the Fixed Acpi_event */
+	if (event > ACPI_EVENT_MAX) {
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	}
 
-		switch (event) {
-		case ACPI_EVENT_PMTIMER:
-			register_id = TMR_STS;
-			break;
+	/* Get the status of the requested fixed event */
 
-		case ACPI_EVENT_GLOBAL:
-			register_id = GBL_STS;
-			break;
+	status = acpi_get_register (acpi_gbl_fixed_event_info[event].status_register_id,
+			  event_status, ACPI_MTX_LOCK);
 
-		case ACPI_EVENT_POWER_BUTTON:
-			register_id = PWRBTN_STS;
-			break;
+	return_ACPI_STATUS (status);
+}
 
-		case ACPI_EVENT_SLEEP_BUTTON:
-			register_id = SLPBTN_STS;
-			break;
 
-		case ACPI_EVENT_RTC:
-			register_id = RTC_STS;
-			break;
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_get_gpe_status
+ *
+ * PARAMETERS:  gpe_device      - Parent GPE Device
+ *              gpe_number      - GPE level within the GPE block
+ *              Flags           - Called from an ISR or not
+ *              Event Status    - Where the current status of the event will
+ *                                be returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Get status of an event (general purpose)
+ *
+ ******************************************************************************/
 
-		default:
-			return_ACPI_STATUS (AE_BAD_PARAMETER);
-			break;
-		}
+acpi_status
+acpi_get_gpe_status (
+	acpi_handle                     gpe_device,
+	u32                             gpe_number,
+	u32                             flags,
+	acpi_event_status               *event_status)
+{
+	acpi_status                     status = AE_OK;
+	struct acpi_gpe_event_info      *gpe_event_info;
 
-		/*
-		 * Clear the requested fixed event (By writing a one to the
-		 * status register bit)
-		 */
-		acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, register_id, 1);
-		break;
 
+	ACPI_FUNCTION_TRACE ("acpi_get_gpe_status");
 
-	case ACPI_EVENT_GPE:
 
-		/* Ensure that we have a valid GPE number */
+	/* Use semaphore lock if not executing at interrupt level */
 
-		if ((event > ACPI_GPE_MAX) ||
-			(acpi_gbl_gpe_valid[event] == ACPI_GPE_INVALID)) {
-			return_ACPI_STATUS (AE_BAD_PARAMETER);
+	if (flags & ACPI_NOT_ISR) {
+		status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
 		}
+	}
 
+	/* Ensure that we have a valid GPE number */
 
-		acpi_hw_clear_gpe (event);
-		break;
+	gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number);
+	if (!gpe_event_info) {
+		status = AE_BAD_PARAMETER;
+		goto unlock_and_exit;
+	}
 
+	/* Obtain status on the requested GPE number */
 
-	default:
+	status = acpi_hw_get_gpe_status (gpe_event_info, event_status);
 
-		status = AE_BAD_PARAMETER;
+unlock_and_exit:
+	if (flags & ACPI_NOT_ISR) {
+		(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
 	}
-
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_get_event_status
+ * FUNCTION:    acpi_install_gpe_block
  *
- * PARAMETERS:  Event           - The fixed event or GPE
- *              Type            - The type of event
- *              Status          - Where the current status of the event will
- *                                be returned
+ * PARAMETERS:  gpe_device          - Handle to the parent GPE Block Device
+ *              gpe_block_address   - Address and space_iD
+ *              register_count      - Number of GPE register pairs in the block
+ *              interrupt_level     - H/W interrupt for the block
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Obtains and returns the current status of the event
+ * DESCRIPTION: Create and Install a block of GPE registers
  *
  ******************************************************************************/
 
-
 acpi_status
-acpi_get_event_status (
-	u32                     event,
-	u32                     type,
-	acpi_event_status       *event_status)
+acpi_install_gpe_block (
+	acpi_handle                     gpe_device,
+	struct acpi_generic_address     *gpe_block_address,
+	u32                             register_count,
+	u32                             interrupt_level)
 {
-	acpi_status             status = AE_OK;
-	u32                     register_id;
+	acpi_status                     status;
+	union acpi_operand_object       *obj_desc;
+	struct acpi_namespace_node      *node;
+	struct acpi_gpe_block_info      *gpe_block;
 
 
-	FUNCTION_TRACE ("Acpi_get_event_status");
+	ACPI_FUNCTION_TRACE ("acpi_install_gpe_block");
 
 
-	if (!event_status) {
+	if ((!gpe_device)      ||
+		(!gpe_block_address) ||
+		(!register_count)) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return (status);
+	}
 
-	/* The Type must be either Fixed Acpi_event or GPE */
-
-	switch (type) {
+	node = acpi_ns_map_handle_to_node (gpe_device);
+	if (!node) {
+		status = AE_BAD_PARAMETER;
+		goto unlock_and_exit;
+	}
 
-	case ACPI_EVENT_FIXED:
+	/*
+	 * For user-installed GPE Block Devices, the gpe_block_base_number
+	 * is always zero
+	 */
+	status = acpi_ev_create_gpe_block (node, gpe_block_address, register_count,
+			  0, interrupt_level, &gpe_block);
+	if (ACPI_FAILURE (status)) {
+		goto unlock_and_exit;
+	}
 
-		/* Decode the Fixed Acpi_event */
+	/* Get the device_object attached to the node */
 
-		switch (event) {
-		case ACPI_EVENT_PMTIMER:
-			register_id = TMR_STS;
-			break;
+	obj_desc = acpi_ns_get_attached_object (node);
+	if (!obj_desc) {
+		/* No object, create a new one */
 
-		case ACPI_EVENT_GLOBAL:
-			register_id = GBL_STS;
-			break;
+		obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_DEVICE);
+		if (!obj_desc) {
+			status = AE_NO_MEMORY;
+			goto unlock_and_exit;
+		}
 
-		case ACPI_EVENT_POWER_BUTTON:
-			register_id = PWRBTN_STS;
-			break;
+		status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_DEVICE);
 
-		case ACPI_EVENT_SLEEP_BUTTON:
-			register_id = SLPBTN_STS;
-			break;
+		/* Remove local reference to the object */
 
-		case ACPI_EVENT_RTC:
-			register_id = RTC_STS;
-			break;
+		acpi_ut_remove_reference (obj_desc);
 
-		default:
-			return_ACPI_STATUS (AE_BAD_PARAMETER);
-			break;
+		if (ACPI_FAILURE (status)) {
+			goto unlock_and_exit;
 		}
+	}
+
+	/* Install the GPE block in the device_object */
 
-		/* Get the status of the requested fixed event */
+	obj_desc->device.gpe_block = gpe_block;
 
-		*event_status = acpi_hw_register_bit_access (ACPI_READ, ACPI_MTX_LOCK, register_id);
-		break;
 
+unlock_and_exit:
+	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	return_ACPI_STATUS (status);
+}
 
-	case ACPI_EVENT_GPE:
 
-		/* Ensure that we have a valid GPE number */
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_remove_gpe_block
+ *
+ * PARAMETERS:  gpe_device          - Handle to the parent GPE Block Device
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Remove a previously installed block of GPE registers
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_remove_gpe_block (
+	acpi_handle                     gpe_device)
+{
+	union acpi_operand_object       *obj_desc;
+	acpi_status                     status;
+	struct acpi_namespace_node      *node;
 
-		if ((event > ACPI_GPE_MAX) ||
-			(acpi_gbl_gpe_valid[event] == ACPI_GPE_INVALID)) {
-			return_ACPI_STATUS (AE_BAD_PARAMETER);
-		}
 
+	ACPI_FUNCTION_TRACE ("acpi_remove_gpe_block");
 
-		/* Obtain status on the requested GPE number */
 
-		acpi_hw_get_gpe_status (event, event_status);
-		break;
+	if (!gpe_device) {
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	}
 
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return (status);
+	}
 
-	default:
+	node = acpi_ns_map_handle_to_node (gpe_device);
+	if (!node) {
 		status = AE_BAD_PARAMETER;
+		goto unlock_and_exit;
+	}
+
+	/* Get the device_object attached to the node */
+
+	obj_desc = acpi_ns_get_attached_object (node);
+	if (!obj_desc ||
+		!obj_desc->device.gpe_block) {
+		return_ACPI_STATUS (AE_NULL_OBJECT);
+	}
+
+	/* Delete the GPE block (but not the device_object) */
+
+	status = acpi_ev_delete_gpe_block (obj_desc->device.gpe_block);
+	if (ACPI_SUCCESS (status)) {
+		obj_desc->device.gpe_block = NULL;
 	}
 
+unlock_and_exit:
+	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return_ACPI_STATUS (status);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/events/evxfregn.c linux-2.4.22-pre2/drivers/acpi/events/evxfregn.c
--- linux-2.4.21/drivers/acpi/events/evxfregn.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/events/evxfregn.c	2003-06-26 21:43:12.000000000 +0000
@@ -2,84 +2,101 @@
  *
  * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and
  *                         Address Spaces.
- *              $Revision: 40 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "achware.h"
-#include "acnamesp.h"
-#include "acevents.h"
-#include "amlcode.h"
-#include "acinterp.h"
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acevents.h>
+#include <acpi/acinterp.h>
 
 #define _COMPONENT          ACPI_EVENTS
-	 MODULE_NAME         ("evxfregn")
+	 ACPI_MODULE_NAME    ("evxfregn")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_install_address_space_handler
+ * FUNCTION:    acpi_install_address_space_handler
  *
  * PARAMETERS:  Device          - Handle for the device
- *              Space_id        - The address space ID
+ *              space_id        - The address space ID
  *              Handler         - Address of the handler
  *              Setup           - Address of the setup function
  *              Context         - Value passed to the handler on each access
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Install a handler for all Op_regions of a given Space_id.
+ * DESCRIPTION: Install a handler for all op_regions of a given space_id.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_install_address_space_handler (
-	acpi_handle             device,
-	ACPI_ADR_SPACE_TYPE     space_id,
-	acpi_adr_space_handler  handler,
-	acpi_adr_space_setup    setup,
-	void                    *context)
+	acpi_handle                     device,
+	acpi_adr_space_type             space_id,
+	acpi_adr_space_handler          handler,
+	acpi_adr_space_setup            setup,
+	void                            *context)
 {
-	acpi_operand_object     *obj_desc;
-	acpi_operand_object     *handler_obj;
-	acpi_namespace_node     *node;
-	acpi_status             status = AE_OK;
-	acpi_object_type8       type;
-	u16                     flags = 0;
+	union acpi_operand_object       *obj_desc;
+	union acpi_operand_object       *handler_obj;
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
+	acpi_object_type                type;
+	u16                             flags = 0;
 
 
-	FUNCTION_TRACE ("Acpi_install_address_space_handler");
+	ACPI_FUNCTION_TRACE ("acpi_install_address_space_handler");
 
 
 	/* Parameter validation */
 
-	if ((!device)   ||
-		((!handler)  && (handler != ACPI_DEFAULT_HANDLER)) ||
-		(space_id > ACPI_MAX_ADDRESS_SPACE)) {
+	if (!device) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	/* Convert and validate the device handle */
 
@@ -103,7 +120,7 @@
 	}
 
 	if (handler == ACPI_DEFAULT_HANDLER) {
-		flags = ADDR_HANDLER_DEFAULT_INSTALLED;
+		flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED;
 
 		switch (space_id) {
 		case ACPI_ADR_SPACE_SYSTEM_MEMORY:
@@ -131,55 +148,65 @@
 			setup   = acpi_ev_pci_bar_region_setup;
 			break;
 
+		case ACPI_ADR_SPACE_DATA_TABLE:
+			handler = acpi_ex_data_table_space_handler;
+			setup   = NULL;
+			break;
+
 		default:
-			status = AE_NOT_EXIST;
+			status = AE_BAD_PARAMETER;
 			goto unlock_and_exit;
-			break;
 		}
 	}
 
-	/*
-	 * If the caller hasn't specified a setup routine, use the default
-	 */
+	/* If the caller hasn't specified a setup routine, use the default */
+
 	if (!setup) {
 		setup = acpi_ev_default_region_setup;
 	}
 
-	/*
-	 * Check for an existing internal object
-	 */
+	/* Check for an existing internal object */
+
 	obj_desc = acpi_ns_get_attached_object (node);
 	if (obj_desc) {
 		/*
-		 * The object exists.
+		 * The attached device object already exists.
 		 * Make sure the handler is not already installed.
 		 */
+		handler_obj = obj_desc->device.address_space;
 
-		/* check the address handler the user requested */
+		/* Walk the handler list for this device */
 
-		handler_obj = obj_desc->device.addr_handler;
 		while (handler_obj) {
-			/*
-			 * We have an Address handler, see if user requested this
-			 * address space.
-			 */
-			if(handler_obj->addr_handler.space_id == space_id) {
-				status = AE_EXIST;
+			/* Same space_id indicates a handler already installed */
+
+			if(handler_obj->address_space.space_id == space_id) {
+				if (handler_obj->address_space.handler == handler) {
+					/*
+					 * It is (relatively) OK to attempt to install the SAME
+					 * handler twice. This can easily happen with PCI_Config space.
+					 */
+					status = AE_SAME_HANDLER;
+					goto unlock_and_exit;
+				}
+				else {
+					/* A handler is already installed */
+
+					status = AE_ALREADY_EXISTS;
+				}
 				goto unlock_and_exit;
 			}
 
-			/*
-			 * Move through the linked list of handlers
-			 */
-			handler_obj = handler_obj->addr_handler.next;
+			/* Walk the linked list of handlers */
+
+			handler_obj = handler_obj->address_space.next;
 		}
 	}
-
 	else {
 		ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
 			"Creating object on Device %p while installing handler\n", node));
 
-		/* Obj_desc does not exist, create one */
+		/* obj_desc does not exist, create one */
 
 		if (node->type == ACPI_TYPE_ANY) {
 			type = ACPI_TYPE_DEVICE;
@@ -200,110 +227,117 @@
 
 		/* Attach the new object to the Node */
 
-		status = acpi_ns_attach_object (node, obj_desc, (u8) type);
+		status = acpi_ns_attach_object (node, obj_desc, type);
+
+		/* Remove local reference to the object */
+
+		acpi_ut_remove_reference (obj_desc);
+
 		if (ACPI_FAILURE (status)) {
-			acpi_ut_remove_reference (obj_desc);
 			goto unlock_and_exit;
 		}
 	}
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
-		"Installing address handler for region %s(%X) on Device %p(%p)\n",
-		acpi_ut_get_region_name (space_id), space_id, node, obj_desc));
+		"Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n",
+		acpi_ut_get_region_name (space_id), space_id, node->name.ascii, node, obj_desc));
 
 	/*
-	 * Now we can install the handler
+	 * Install the handler
 	 *
-	 * At this point we know that there is no existing handler.
-	 * So, we just allocate the object for the handler and link it
+	 * At this point there is no existing handler.
+	 * Just allocate the object for the handler and link it
 	 * into the list.
 	 */
-	handler_obj = acpi_ut_create_internal_object (INTERNAL_TYPE_ADDRESS_HANDLER);
+	handler_obj = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_ADDRESS_HANDLER);
 	if (!handler_obj) {
 		status = AE_NO_MEMORY;
 		goto unlock_and_exit;
 	}
 
-	handler_obj->addr_handler.space_id  = (u8) space_id;
-	handler_obj->addr_handler.hflags    = flags;
-	handler_obj->addr_handler.next      = obj_desc->device.addr_handler;
-	handler_obj->addr_handler.region_list = NULL;
-	handler_obj->addr_handler.node      = node;
-	handler_obj->addr_handler.handler   = handler;
-	handler_obj->addr_handler.context   = context;
-	handler_obj->addr_handler.setup     = setup;
+	/* Init handler obj */
+
+	handler_obj->address_space.space_id  = (u8) space_id;
+	handler_obj->address_space.hflags    = flags;
+	handler_obj->address_space.region_list = NULL;
+	handler_obj->address_space.node      = node;
+	handler_obj->address_space.handler   = handler;
+	handler_obj->address_space.context   = context;
+	handler_obj->address_space.setup     = setup;
+
+	/* Install at head of Device.address_space list */
+
+	handler_obj->address_space.next      = obj_desc->device.address_space;
+
+	/*
+	 * The Device object is the first reference on the handler_obj.
+	 * Each region that uses the handler adds a reference.
+	 */
+	obj_desc->device.address_space = handler_obj;
 
 	/*
-	 * Now walk the namespace finding all of the regions this
+	 * Walk the namespace finding all of the regions this
 	 * handler will manage.
 	 *
-	 * We start at the device and search the branch toward
+	 * Start at the device and search the branch toward
 	 * the leaf nodes until either the leaf is encountered or
 	 * a device is detected that has an address handler of the
 	 * same type.
 	 *
-	 * In either case we back up and search down the remainder
+	 * In either case, back up and search down the remainder
 	 * of the branch
 	 */
-	status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, device,
-			 ACPI_UINT32_MAX, NS_WALK_UNLOCK,
-			 acpi_ev_addr_handler_helper,
-			 handler_obj, NULL);
-
-	/*
-	 * Place this handler 1st on the list
-	 */
-	handler_obj->common.reference_count =
-			 (u16) (handler_obj->common.reference_count +
-			 obj_desc->common.reference_count - 1);
-	obj_desc->device.addr_handler = handler_obj;
-
+	status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, device, ACPI_UINT32_MAX,
+			  ACPI_NS_WALK_UNLOCK, acpi_ev_install_handler,
+			  handler_obj, NULL);
 
 unlock_and_exit:
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_remove_address_space_handler
+ * FUNCTION:    acpi_remove_address_space_handler
  *
- * PARAMETERS:  Space_id        - The address space ID
+ * PARAMETERS:  Device          - Handle for the device
+ *              space_id        - The address space ID
  *              Handler         - Address of the handler
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Install a handler for accesses on an Operation Region
+ * DESCRIPTION: Remove a previously installed handler.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_remove_address_space_handler (
-	acpi_handle             device,
-	ACPI_ADR_SPACE_TYPE     space_id,
-	acpi_adr_space_handler  handler)
+	acpi_handle                     device,
+	acpi_adr_space_type             space_id,
+	acpi_adr_space_handler          handler)
 {
-	acpi_operand_object     *obj_desc;
-	acpi_operand_object     *handler_obj;
-	acpi_operand_object     *region_obj;
-	acpi_operand_object     **last_obj_ptr;
-	acpi_namespace_node     *node;
-	acpi_status             status = AE_OK;
+	union acpi_operand_object       *obj_desc;
+	union acpi_operand_object       *handler_obj;
+	union acpi_operand_object       *region_obj;
+	union acpi_operand_object       **last_obj_ptr;
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Acpi_remove_address_space_handler");
+	ACPI_FUNCTION_TRACE ("acpi_remove_address_space_handler");
 
 
 	/* Parameter validation */
 
-	if ((!device)   ||
-		((!handler)  && (handler != ACPI_DEFAULT_HANDLER)) ||
-		(space_id > ACPI_MAX_ADDRESS_SPACE)) {
+	if (!device) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	/* Convert and validate the device handle */
 
@@ -313,7 +347,6 @@
 		goto unlock_and_exit;
 	}
 
-
 	/* Make sure the internal object exists */
 
 	obj_desc = acpi_ns_get_attached_object (node);
@@ -322,25 +355,22 @@
 		goto unlock_and_exit;
 	}
 
-	/*
-	 * find the address handler the user requested
-	 */
-	handler_obj = obj_desc->device.addr_handler;
-	last_obj_ptr = &obj_desc->device.addr_handler;
+	/* Find the address handler the user requested */
+
+	handler_obj = obj_desc->device.address_space;
+	last_obj_ptr = &obj_desc->device.address_space;
 	while (handler_obj) {
-		/*
-		 * We have a handler, see if user requested this one
-		 */
-		if (handler_obj->addr_handler.space_id == space_id) {
-			/*
-			 * Got it, first dereference this in the Regions
-			 */
+		/* We have a handler, see if user requested this one */
+
+		if (handler_obj->address_space.space_id == space_id) {
+			/* Matched space_id, first dereference this in the Regions */
+
 			ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
 				"Removing address handler %p(%p) for region %s on Device %p(%p)\n",
 				handler_obj, handler, acpi_ut_get_region_name (space_id),
 				node, obj_desc));
 
-			region_obj = handler_obj->addr_handler.region_list;
+			region_obj = handler_obj->address_space.region_list;
 
 			/* Walk the handler's region list */
 
@@ -352,51 +382,42 @@
 				 * The region is just inaccessible as indicated to
 				 * the _REG method
 				 */
-				acpi_ev_disassociate_region_from_handler(region_obj, TRUE);
+				acpi_ev_detach_region (region_obj, TRUE);
 
 				/*
-				 * Walk the list, since we took the first region and it
-				 * was removed from the list by the dissassociate call
-				 * we just get the first item on the list again
+				 * Walk the list: Just grab the head because the
+				 * detach_region removed the previous head.
 				 */
-				region_obj = handler_obj->addr_handler.region_list;
+				region_obj = handler_obj->address_space.region_list;
 
 			}
 
-			/*
-			 * Remove this Handler object from the list
-			 */
-			*last_obj_ptr = handler_obj->addr_handler.next;
-
-			/*
-			 * Now we can delete the handler object
-			 */
-			acpi_ut_remove_reference (handler_obj);
-			acpi_ut_remove_reference (handler_obj);
+			/* Remove this Handler object from the list */
 
+			*last_obj_ptr = handler_obj->address_space.next;
+
+			/* Now we can delete the handler object */
+
+			acpi_ut_remove_reference (handler_obj);
 			goto unlock_and_exit;
 		}
 
-		/*
-		 * Move through the linked list of handlers
-		 */
-		last_obj_ptr = &handler_obj->addr_handler.next;
-		handler_obj = handler_obj->addr_handler.next;
+		/* Walk the linked list of handlers */
+
+		last_obj_ptr = &handler_obj->address_space.next;
+		handler_obj = handler_obj->address_space.next;
 	}
 
+	/* The handler does not exist */
 
-	/*
-	 * The handler does not exist
-	 */
 	ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
-		"Unable to remove address handler %p for %s(%X), Dev_node %p, obj %p\n",
+		"Unable to remove address handler %p for %s(%X), dev_node %p, obj %p\n",
 		handler, acpi_ut_get_region_name (space_id), space_id, node, obj_desc));
 
 	status = AE_NOT_EXIST;
 
-
 unlock_and_exit:
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return_ACPI_STATUS (status);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/Makefile linux-2.4.22-pre2/drivers/acpi/executer/Makefile
--- linux-2.4.21/drivers/acpi/executer/Makefile	2001-06-21 00:47:40.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/Makefile	2003-06-26 21:43:12.000000000 +0000
@@ -1,11 +1,10 @@
 #
 # Makefile for all Linux ACPI interpreter subdirectories
-# EXCEPT for the ospm directory
 #
 
 O_TARGET := $(notdir $(CURDIR)).o
 
-obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exconfig.c linux-2.4.22-pre2/drivers/acpi/executer/exconfig.c
--- linux-2.4.21/drivers/acpi/executer/exconfig.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exconfig.c	2003-06-26 21:43:28.000000000 +0000
@@ -1,242 +1,459 @@
 /******************************************************************************
  *
  * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes)
- *              $Revision: 44 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "acinterp.h"
-#include "amlcode.h"
-#include "acnamesp.h"
-#include "acevents.h"
-#include "actables.h"
-#include "acdispat.h"
+#include <acpi/acpi.h>
+#include <acpi/acinterp.h>
+#include <acpi/amlcode.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acevents.h>
+#include <acpi/actables.h>
 
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exconfig")
+	 ACPI_MODULE_NAME    ("exconfig")
 
 
-/*****************************************************************************
+/*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_load_table_op
+ * FUNCTION:    acpi_ex_add_table
  *
- * PARAMETERS:  Rgn_desc        - Op region where the table will be obtained
- *              Ddb_handle      - Where a handle to the table will be returned
+ * PARAMETERS:  Table               - Pointer to raw table
+ *              parent_node         - Where to load the table (scope)
+ *              ddb_handle          - Where to return the table handle.
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Common function to Install and Load an ACPI table with a
+ *              returned table handle.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ex_add_table (
+	struct acpi_table_header        *table,
+	struct acpi_namespace_node      *parent_node,
+	union acpi_operand_object       **ddb_handle)
+{
+	acpi_status                     status;
+	struct acpi_table_desc          table_info;
+	union acpi_operand_object       *obj_desc;
+
+
+	ACPI_FUNCTION_TRACE ("ex_add_table");
+
+
+	/* Create an object to be the table handle */
+
+	obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_REFERENCE);
+	if (!obj_desc) {
+		return_ACPI_STATUS (AE_NO_MEMORY);
+	}
+
+	/* Install the new table into the local data structures */
+
+	table_info.pointer     = table;
+	table_info.length      = (acpi_size) table->length;
+	table_info.allocation  = ACPI_MEM_ALLOCATED;
+
+	status = acpi_tb_install_table (&table_info);
+	if (ACPI_FAILURE (status)) {
+		goto cleanup;
+	}
+
+	/* Add the table to the namespace */
+
+	status = acpi_ns_load_table (table_info.installed_desc, parent_node);
+	if (ACPI_FAILURE (status)) {
+		/* Uninstall table on error */
+
+		(void) acpi_tb_uninstall_table (table_info.installed_desc);
+		goto cleanup;
+	}
+
+	/* Init the table handle */
+
+	obj_desc->reference.opcode = AML_LOAD_OP;
+	obj_desc->reference.object = table_info.installed_desc;
+	*ddb_handle = obj_desc;
+	return_ACPI_STATUS (AE_OK);
+
+
+cleanup:
+	acpi_ut_remove_reference (obj_desc);
+	return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ex_load_table_op
+ *
+ * PARAMETERS:  walk_state          - Current state with operands
+ *              return_desc         - Where to store the return object
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Load an ACPI table
  *
- ****************************************************************************/
+ ******************************************************************************/
 
 acpi_status
-acpi_ex_load_op (
-	acpi_operand_object     *rgn_desc,
-	acpi_operand_object     *ddb_handle)
+acpi_ex_load_table_op (
+	struct acpi_walk_state          *walk_state,
+	union acpi_operand_object       **return_desc)
 {
-	acpi_status             status;
-	acpi_operand_object     *table_desc = NULL;
-	u8                      *table_ptr;
-	u8                      *table_data_ptr;
-	acpi_table_header       table_header;
-	acpi_table_desc         table_info;
-	u32                     i;
+	acpi_status                     status;
+	union acpi_operand_object       **operand = &walk_state->operands[0];
+	struct acpi_table_header        *table;
+	struct acpi_namespace_node      *parent_node;
+	struct acpi_namespace_node      *start_node;
+	struct acpi_namespace_node      *parameter_node = NULL;
+	union acpi_operand_object       *ddb_handle;
+
 
+	ACPI_FUNCTION_TRACE ("ex_load_table_op");
 
-	FUNCTION_TRACE ("Ex_load_op");
 
-	/* TBD: [Unhandled] Object can be either a field or an opregion */
+#if 0
+	/*
+	 * Make sure that the signature does not match one of the tables that
+	 * is already loaded.
+	 */
+	status = acpi_tb_match_signature (operand[0]->string.pointer, NULL);
+	if (status == AE_OK) {
+		/* Signature matched -- don't allow override */
 
+		return_ACPI_STATUS (AE_ALREADY_EXISTS);
+	}
+#endif
 
-	/* Get the table header */
+	/* Find the ACPI table */
 
-	table_header.length = 0;
-	for (i = 0; i < sizeof (acpi_table_header); i++) {
-		status = acpi_ev_address_space_dispatch (rgn_desc, ACPI_READ_ADR_SPACE,
-				   (ACPI_PHYSICAL_ADDRESS) i, 8,
-				   (u32 *) ((u8 *) &table_header + i));
+	status = acpi_tb_find_table (operand[0]->string.pointer,
+			   operand[1]->string.pointer,
+			   operand[2]->string.pointer, &table);
+	if (ACPI_FAILURE (status)) {
+		if (status != AE_NOT_FOUND) {
+			return_ACPI_STATUS (status);
+		}
+
+		/* Not found, return an Integer=0 and AE_OK */
+
+		ddb_handle = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
+		if (!ddb_handle) {
+			return_ACPI_STATUS (AE_NO_MEMORY);
+		}
+
+		ddb_handle->integer.value = 0;
+		*return_desc = ddb_handle;
+
+		return_ACPI_STATUS (AE_OK);
+	}
+
+	/* Default nodes */
+
+	start_node = walk_state->scope_info->scope.node;
+	parent_node = acpi_gbl_root_node;
+
+	/* root_path (optional parameter) */
+
+	if (operand[3]->string.length > 0) {
+		/*
+		 * Find the node referenced by the root_path_string. This is the
+		 * location within the namespace where the table will be loaded.
+		 */
+		status = acpi_ns_get_node_by_path (operand[3]->string.pointer, start_node,
+				   ACPI_NS_SEARCH_PARENT, &parent_node);
 		if (ACPI_FAILURE (status)) {
 			return_ACPI_STATUS (status);
 		}
 	}
 
-	/* Allocate a buffer for the entire table */
+	/* parameter_path (optional parameter) */
 
-	table_ptr = ACPI_MEM_ALLOCATE (table_header.length);
-	if (!table_ptr) {
-		return_ACPI_STATUS (AE_NO_MEMORY);
+	if (operand[4]->string.length > 0) {
+		if ((operand[4]->string.pointer[0] != '\\') &&
+			(operand[4]->string.pointer[0] != '^')) {
+			/*
+			 * Path is not absolute, so it will be relative to the node
+			 * referenced by the root_path_string (or the NS root if omitted)
+			 */
+			start_node = parent_node;
+		}
+
+		/*
+		 * Find the node referenced by the parameter_path_string
+		 */
+		status = acpi_ns_get_node_by_path (operand[4]->string.pointer, start_node,
+				   ACPI_NS_SEARCH_PARENT, &parameter_node);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
+		}
 	}
 
-	/* Copy the header to the buffer */
+	/* Load the table into the namespace */
 
-	MEMCPY (table_ptr, &table_header, sizeof (acpi_table_header));
-	table_data_ptr = table_ptr + sizeof (acpi_table_header);
+	status = acpi_ex_add_table (table, parent_node, &ddb_handle);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
+	/* Parameter Data (optional) */
 
-	/* Get the table from the op region */
+	if (parameter_node) {
+		/* Store the parameter data into the optional parameter object */
 
-	for (i = 0; i < table_header.length; i++) {
-		status = acpi_ev_address_space_dispatch (rgn_desc, ACPI_READ_ADR_SPACE,
-				   (ACPI_PHYSICAL_ADDRESS) i, 8,
-				   (u32 *) (table_data_ptr + i));
+		status = acpi_ex_store (operand[5], ACPI_CAST_PTR (union acpi_operand_object, parameter_node),
+				 walk_state);
 		if (ACPI_FAILURE (status)) {
-			goto cleanup;
+			(void) acpi_ex_unload_table (ddb_handle);
 		}
 	}
 
+	return_ACPI_STATUS  (status);
+}
 
-	/* Table must be either an SSDT or a PSDT */
 
-	if ((!STRNCMP (table_header.signature,
-			  acpi_gbl_acpi_table_data[ACPI_TABLE_PSDT].signature,
-			  acpi_gbl_acpi_table_data[ACPI_TABLE_PSDT].sig_length)) &&
-		(!STRNCMP (table_header.signature,
-				 acpi_gbl_acpi_table_data[ACPI_TABLE_SSDT].signature,
-				 acpi_gbl_acpi_table_data[ACPI_TABLE_SSDT].sig_length))) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-			"Table has invalid signature [%4.4s], must be SSDT or PSDT\n",
-			(char*)table_header.signature));
-		status = AE_BAD_SIGNATURE;
-		goto cleanup;
-	}
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ex_load_op
+ *
+ * PARAMETERS:  obj_desc        - Region or Field where the table will be
+ *                                obtained
+ *              Target          - Where a handle to the table will be stored
+ *              walk_state      - Current state
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Load an ACPI table from a field or operation region
+ *
+ ******************************************************************************/
 
-	/* Create an object to be the table handle */
+acpi_status
+acpi_ex_load_op (
+	union acpi_operand_object       *obj_desc,
+	union acpi_operand_object       *target,
+	struct acpi_walk_state          *walk_state)
+{
+	acpi_status                     status;
+	union acpi_operand_object       *ddb_handle;
+	union acpi_operand_object       *buffer_desc = NULL;
+	struct acpi_table_header        *table_ptr = NULL;
+	u8                              *table_data_ptr;
+	struct acpi_table_header        table_header;
+	u32                             i;
+
+	ACPI_FUNCTION_TRACE ("ex_load_op");
+
+
+	/* Object can be either an op_region or a Field */
+
+	switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
+	case ACPI_TYPE_REGION:
+
+		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Region %p %s\n",
+			obj_desc, acpi_ut_get_object_type_name (obj_desc)));
+
+		/* Get the table header */
+
+		table_header.length = 0;
+		for (i = 0; i < sizeof (struct acpi_table_header); i++) {
+			status = acpi_ev_address_space_dispatch (obj_desc, ACPI_READ,
+					   (acpi_physical_address) i, 8,
+					   ((u8 *) &table_header) + i);
+			if (ACPI_FAILURE (status)) {
+				return_ACPI_STATUS (status);
+			}
+		}
 
-	table_desc = acpi_ut_create_internal_object (INTERNAL_TYPE_REFERENCE);
-	if (!table_desc) {
-		status = AE_NO_MEMORY;
-		goto cleanup;
-	}
+		/* Allocate a buffer for the entire table */
 
+		table_ptr = ACPI_MEM_ALLOCATE (table_header.length);
+		if (!table_ptr) {
+			return_ACPI_STATUS (AE_NO_MEMORY);
+		}
 
-	/* Install the new table into the local data structures */
+		/* Copy the header to the buffer */
 
-	table_info.pointer     = (acpi_table_header *) table_ptr;
-	table_info.length      = table_header.length;
-	table_info.allocation  = ACPI_MEM_ALLOCATED;
-	table_info.base_pointer = table_ptr;
+		ACPI_MEMCPY (table_ptr, &table_header, sizeof (struct acpi_table_header));
+		table_data_ptr = ACPI_PTR_ADD (u8, table_ptr, sizeof (struct acpi_table_header));
 
-	status = acpi_tb_install_table (NULL, &table_info);
-	if (ACPI_FAILURE (status)) {
-		goto cleanup;
-	}
+		/* Get the table from the op region */
 
-	/* Add the table to the namespace */
+		for (i = 0; i < table_header.length; i++) {
+			status = acpi_ev_address_space_dispatch (obj_desc, ACPI_READ,
+					   (acpi_physical_address) i, 8,
+					   ((u8 *) table_data_ptr + i));
+			if (ACPI_FAILURE (status)) {
+				goto cleanup;
+			}
+		}
+		break;
 
-	/* TBD: [Restructure] - change to whatever new interface is appropriate */
-/*
-	Status = Acpi_load_namespace ();
-	if (ACPI_FAILURE (Status))
-	{
-*/
-		/* TBD: [Errors] Unload the table on failure ? */
-/*
-		goto Cleanup;
+
+	case ACPI_TYPE_LOCAL_REGION_FIELD:
+	case ACPI_TYPE_LOCAL_BANK_FIELD:
+	case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Field %p %s\n",
+			obj_desc, acpi_ut_get_object_type_name (obj_desc)));
+
+		/*
+		 * The length of the field must be at least as large as the table.
+		 * Read the entire field and thus the entire table.  Buffer is
+		 * allocated during the read.
+		 */
+		status = acpi_ex_read_data_from_field (walk_state, obj_desc, &buffer_desc);
+		if (ACPI_FAILURE (status)) {
+			goto cleanup;
+		}
+
+		table_ptr = ACPI_CAST_PTR (struct acpi_table_header, buffer_desc->buffer.pointer);
+		break;
+
+
+	default:
+		return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 	}
-*/
 
+	/* The table must be either an SSDT or a PSDT */
 
-	/* TBD: [Investigate] we need a pointer to the table desc */
+	if ((!ACPI_STRNCMP (table_ptr->signature,
+			  acpi_gbl_table_data[ACPI_TABLE_PSDT].signature,
+			  acpi_gbl_table_data[ACPI_TABLE_PSDT].sig_length)) &&
+		(!ACPI_STRNCMP (table_ptr->signature,
+				 acpi_gbl_table_data[ACPI_TABLE_SSDT].signature,
+				 acpi_gbl_table_data[ACPI_TABLE_SSDT].sig_length))) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"Table has invalid signature [%4.4s], must be SSDT or PSDT\n",
+			table_ptr->signature));
+		status = AE_BAD_SIGNATURE;
+		goto cleanup;
+	}
 
-	/* Init the table handle */
+	/* Install the new table into the local data structures */
 
-	table_desc->reference.opcode = AML_LOAD_OP;
-	table_desc->reference.object = table_info.installed_desc;
+	status = acpi_ex_add_table (table_ptr, acpi_gbl_root_node, &ddb_handle);
+	if (ACPI_FAILURE (status)) {
+		goto cleanup;
+	}
 
-	/* TBD: store the tabledesc into the Ddb_handle target */
-	/* Ddb_handle = Table_desc; */
+	/* Store the ddb_handle into the Target operand */
+
+	status = acpi_ex_store (ddb_handle, target, walk_state);
+	if (ACPI_FAILURE (status)) {
+		(void) acpi_ex_unload_table (ddb_handle);
+	}
 
 	return_ACPI_STATUS (status);
 
 
 cleanup:
 
-	ACPI_MEM_FREE (table_desc);
-	ACPI_MEM_FREE (table_ptr);
+	if (buffer_desc) {
+		acpi_ut_remove_reference (buffer_desc);
+	}
+	else {
+		ACPI_MEM_FREE (table_ptr);
+	}
 	return_ACPI_STATUS (status);
 }
 
 
-/*****************************************************************************
+/*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_unload_table
+ * FUNCTION:    acpi_ex_unload_table
  *
- * PARAMETERS:  Ddb_handle          - Handle to a previously loaded table
+ * PARAMETERS:  ddb_handle          - Handle to a previously loaded table
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Unload an ACPI table
  *
- ****************************************************************************/
+ ******************************************************************************/
 
 acpi_status
 acpi_ex_unload_table (
-	acpi_operand_object     *ddb_handle)
+	union acpi_operand_object       *ddb_handle)
 {
-	acpi_status             status = AE_NOT_IMPLEMENTED;
-	acpi_operand_object     *table_desc = ddb_handle;
-	acpi_table_desc         *table_info;
+	acpi_status                     status = AE_NOT_IMPLEMENTED;
+	union acpi_operand_object       *table_desc = ddb_handle;
+	struct acpi_table_desc          *table_info;
 
 
-	FUNCTION_TRACE ("Ex_unload_table");
+	ACPI_FUNCTION_TRACE ("ex_unload_table");
 
 
 	/*
 	 * Validate the handle
-	 * Although the handle is partially validated in Acpi_ex_reconfiguration(),
-	 * when it calls Acpi_ex_resolve_operands(), the handle is more completely
+	 * Although the handle is partially validated in acpi_ex_reconfiguration(),
+	 * when it calls acpi_ex_resolve_operands(), the handle is more completely
 	 * validated here.
 	 */
 	if ((!ddb_handle) ||
-		(!VALID_DESCRIPTOR_TYPE (ddb_handle, ACPI_DESC_TYPE_INTERNAL)) ||
-		(((acpi_operand_object  *)ddb_handle)->common.type !=
-				INTERNAL_TYPE_REFERENCE)) {
+		(ACPI_GET_DESCRIPTOR_TYPE (ddb_handle) != ACPI_DESC_TYPE_OPERAND) ||
+		(ACPI_GET_OBJECT_TYPE (ddb_handle) != ACPI_TYPE_LOCAL_REFERENCE)) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-	/* Get the actual table descriptor from the Ddb_handle */
+	/* Get the actual table descriptor from the ddb_handle */
 
-	table_info = (acpi_table_desc *) table_desc->reference.object;
+	table_info = (struct acpi_table_desc *) table_desc->reference.object;
 
 	/*
 	 * Delete the entire namespace under this table Node
-	 * (Offset contains the Table_id)
+	 * (Offset contains the table_id)
 	 */
-	status = acpi_ns_delete_namespace_by_owner (table_info->table_id);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
+	acpi_ns_delete_namespace_by_owner (table_info->table_id);
 
 	/* Delete the table itself */
 
-	acpi_tb_uninstall_table (table_info->installed_desc);
+	(void) acpi_tb_uninstall_table (table_info->installed_desc);
 
-	/* Delete the table descriptor (Ddb_handle) */
+	/* Delete the table descriptor (ddb_handle) */
 
 	acpi_ut_remove_reference (table_desc);
-
 	return_ACPI_STATUS (status);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exconvrt.c linux-2.4.22-pre2/drivers/acpi/executer/exconvrt.c
--- linux-2.4.21/drivers/acpi/executer/exconvrt.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exconvrt.c	2003-06-26 21:43:11.000000000 +0000
@@ -1,49 +1,63 @@
 /******************************************************************************
  *
  * Module Name: exconvrt - Object conversion routines
- *              $Revision: 24 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "acnamesp.h"
-#include "acinterp.h"
-#include "acevents.h"
-#include "amlcode.h"
-#include "acdispat.h"
+#include <acpi/acpi.h>
+#include <acpi/acinterp.h>
+#include <acpi/amlcode.h>
 
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exconvrt")
+	 ACPI_MODULE_NAME    ("exconvrt")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_convert_to_integer
+ * FUNCTION:    acpi_ex_convert_to_integer
  *
- * PARAMETERS:  *Obj_desc       - Object to be converted.  Must be an
+ * PARAMETERS:  *obj_desc       - Object to be converted.  Must be an
  *                                Integer, Buffer, or String
- *              Walk_state      - Current method state
+ *              walk_state      - Current method state
  *
  * RETURN:      Status
  *
@@ -53,60 +67,40 @@
 
 acpi_status
 acpi_ex_convert_to_integer (
-	acpi_operand_object     *obj_desc,
-	acpi_operand_object     **result_desc,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       *obj_desc,
+	union acpi_operand_object       **result_desc,
+	struct acpi_walk_state          *walk_state)
 {
-	u32                     i;
-	acpi_operand_object     *ret_desc;
-	u32                     count;
-	char                    *pointer;
-	acpi_integer            result;
-	u32                     integer_size = sizeof (acpi_integer);
+	u32                             i;
+	union acpi_operand_object       *ret_desc;
+	u32                             count;
+	u8                              *pointer;
+	acpi_integer                    result;
+	acpi_status                     status;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_TRACE_PTR ("ex_convert_to_integer", obj_desc);
 
 
-	switch (obj_desc->common.type) {
+	switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
 	case ACPI_TYPE_INTEGER:
 		*result_desc = obj_desc;
-		return (AE_OK);
+		return_ACPI_STATUS (AE_OK);
 
 	case ACPI_TYPE_STRING:
-		pointer = obj_desc->string.pointer;
+		pointer = (u8 *) obj_desc->string.pointer;
 		count   = obj_desc->string.length;
 		break;
 
 	case ACPI_TYPE_BUFFER:
-		pointer = (char *) obj_desc->buffer.pointer;
+		pointer = obj_desc->buffer.pointer;
 		count   = obj_desc->buffer.length;
 		break;
 
 	default:
-		return (AE_TYPE);
-	}
-
-	/*
-	 * Create a new integer
-	 */
-	ret_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
-	if (!ret_desc) {
-		return (AE_NO_MEMORY);
-	}
-
-
-	/* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */
-
-	if (walk_state->method_node->flags & ANOBJ_DATA_WIDTH_32) {
-		/*
-		 * We are running a method that exists in a 32-bit ACPI table.
-		 * Truncate the value to 32 bits by zeroing out the upper 32-bit field
-		 */
-		integer_size = sizeof (u32);
+		return_ACPI_STATUS (AE_TYPE);
 	}
 
-
 	/*
 	 * Convert the buffer/string to an integer.  Note that both buffers and
 	 * strings are treated as raw data - we don't convert ascii to hex for
@@ -120,23 +114,24 @@
 
 	/* Transfer no more than an integer's worth of data */
 
-	if (count > integer_size) {
-		count = integer_size;
+	if (count > acpi_gbl_integer_byte_width) {
+		count = acpi_gbl_integer_byte_width;
 	}
 
 	/*
 	 * String conversion is different than Buffer conversion
 	 */
-	switch (obj_desc->common.type) {
+	switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
 	case ACPI_TYPE_STRING:
 
-		/* TBD: Need to use 64-bit STRTOUL */
-
 		/*
 		 * Convert string to an integer
 		 * String must be hexadecimal as per the ACPI specification
 		 */
-		result = STRTOUL (pointer, NULL, 16);
+		status = acpi_ut_strtoul64 ((char *) pointer, 16, &result);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
+		}
 		break;
 
 
@@ -154,14 +149,31 @@
 			 */
 			result |= (((acpi_integer) pointer[i]) << (i * 8));
 		}
+		break;
 
+
+	default:
+		/* No other types can get here */
 		break;
 	}
 
-	/* Save the Result, delete original descriptor, store new descriptor */
+	/*
+	 * Create a new integer
+	 */
+	ret_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
+	if (!ret_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);
@@ -169,139 +181,152 @@
 	}
 
 	*result_desc = ret_desc;
-	return (AE_OK);
+	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_convert_to_buffer
+ * FUNCTION:    acpi_ex_convert_to_buffer
  *
- * PARAMETERS:  *Obj_desc       - Object to be converted.  Must be an
+ * PARAMETERS:  *obj_desc       - Object to be converted.  Must be an
  *                                Integer, Buffer, or String
- *              Walk_state      - Current method state
+ *              walk_state      - Current method state
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Convert an ACPI Object to an Buffer
+ * DESCRIPTION: Convert an ACPI Object to a Buffer
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ex_convert_to_buffer (
-	acpi_operand_object     *obj_desc,
-	acpi_operand_object     **result_desc,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       *obj_desc,
+	union acpi_operand_object       **result_desc,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_operand_object     *ret_desc;
-	u32                     i;
-	u32                     integer_size = sizeof (acpi_integer);
-	u8                      *new_buf;
+	union acpi_operand_object       *ret_desc;
+	u32                             i;
+	u8                              *new_buf;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_TRACE_PTR ("ex_convert_to_buffer", obj_desc);
 
 
-	switch (obj_desc->common.type) {
-	case ACPI_TYPE_INTEGER:
+	switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
+	case ACPI_TYPE_BUFFER:
 
-		/*
-		 * Create a new Buffer
-		 */
-		ret_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER);
-		if (!ret_desc) {
-			return (AE_NO_MEMORY);
-		}
+		/* No conversion necessary */
 
-		/* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */
+		*result_desc = obj_desc;
+		return_ACPI_STATUS (AE_OK);
 
-		if (walk_state->method_node->flags & ANOBJ_DATA_WIDTH_32) {
-			/*
-			 * We are running a method that exists in a 32-bit ACPI table.
-			 * Truncate the value to 32 bits by zeroing out the upper
-			 * 32-bit field
-			 */
-			integer_size = sizeof (u32);
-		}
 
-		/* Need enough space for one integers */
+	case ACPI_TYPE_INTEGER:
 
-		ret_desc->buffer.length = integer_size;
-		new_buf = ACPI_MEM_CALLOCATE (integer_size);
-		if (!new_buf) {
-			REPORT_ERROR
-				(("Ex_convert_to_buffer: Buffer allocation failure\n"));
-			acpi_ut_remove_reference (ret_desc);
-			return (AE_NO_MEMORY);
+		/*
+		 * 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_ACPI_STATUS (AE_NO_MEMORY);
 		}
 
 		/* Copy the integer to the buffer */
 
-		for (i = 0; i < integer_size; i++) {
+		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));
 		}
-		ret_desc->buffer.pointer = new_buf;
-
-		/* Return the new buffer descriptor */
-
-		if (*result_desc == obj_desc) {
-			if (walk_state->opcode != AML_STORE_OP) {
-				acpi_ut_remove_reference (obj_desc);
-			}
-		}
-
-		*result_desc = ret_desc;
 		break;
 
 
 	case ACPI_TYPE_STRING:
-		*result_desc = obj_desc;
-		break;
 
+		/*
+		 * 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_ACPI_STATUS (AE_NO_MEMORY);
+		}
 
-	case ACPI_TYPE_BUFFER:
-		*result_desc = obj_desc;
+		/* Copy the string to the buffer */
+
+		new_buf = ret_desc->buffer.pointer;
+		ACPI_STRNCPY ((char *) new_buf, (char *) obj_desc->string.pointer,
+			obj_desc->string.length);
 		break;
 
 
 	default:
-		return (AE_TYPE);
-		break;
-   }
+		return_ACPI_STATUS (AE_TYPE);
+	}
+
+	/* 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);
+		}
+	}
 
-	return (AE_OK);
+	*result_desc = ret_desc;
+	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_convert_ascii
+ * FUNCTION:    acpi_ex_convert_ascii
  *
- * PARAMETERS:  Integer
+ * PARAMETERS:  Integer         - Value to be converted
+ *              Base            - 10 or 16
+ *              String          - Where the string is returned
+ *              data_width      - Size of data item to be converted
  *
  * RETURN:      Actual string length
  *
- * DESCRIPTION: Convert an ACPI Integer to a hex string
+ * DESCRIPTION: Convert an ACPI Integer to a hex or decimal string
  *
  ******************************************************************************/
 
 u32
 acpi_ex_convert_to_ascii (
-	acpi_integer            integer,
-	u32                     base,
-	u8                      *string)
+	acpi_integer                    integer,
+	u32                             base,
+	u8                              *string,
+	u8                              data_width)
 {
-	u32                     i;
-	u32                     j;
-	u32                     k = 0;
-	u8                      hex_digit;
-	acpi_integer            digit;
-	u32                     remainder;
-	u32                     length = sizeof (acpi_integer);
-	u8                      leading_zero = TRUE;
+	u32                             i;
+	u32                             j;
+	u32                             k = 0;
+	char                            hex_digit;
+	acpi_integer                    digit;
+	u32                             remainder;
+	u32                             length;
+	u8                              leading_zero;
 
 
-	FUNCTION_ENTRY ();
+	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) {
@@ -313,7 +338,7 @@
 
 			digit = integer;
 			for (j = 1; j < i; j++) {
-				acpi_ut_short_divide (&digit, 10, &digit, &remainder);
+				(void) acpi_ut_short_divide (&digit, 10, &digit, &remainder);
 			}
 
 			/* Create the decimal digit */
@@ -323,7 +348,7 @@
 			}
 
 			if (!leading_zero) {
-				string[k] = (u8) (ASCII_ZERO + remainder);
+				string[k] = (u8) (ACPI_ASCII_ZERO + remainder);
 				k++;
 			}
 		}
@@ -336,12 +361,12 @@
 		for (i = 0, j = ((length * 2) -1); i < (length * 2); i++, j--) {
 
 			hex_digit = acpi_ut_hex_to_ascii_char (integer, (j * 4));
-			if (hex_digit != ASCII_ZERO) {
+			if (hex_digit != ACPI_ASCII_ZERO) {
 				leading_zero = FALSE;
 			}
 
 			if (!leading_zero) {
-				string[k] = hex_digit;
+				string[k] = (u8) hex_digit;
 				k++;
 			}
 		}
@@ -358,22 +383,22 @@
 	 * Finally, null terminate the string and return the length
 	 */
 	if (!k) {
-		string [0] = ASCII_ZERO;
+		string [0] = ACPI_ASCII_ZERO;
 		k = 1;
 	}
-	string [k] = 0;
 
+	string [k] = 0;
 	return (k);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_convert_to_string
+ * FUNCTION:    acpi_ex_convert_to_string
  *
- * PARAMETERS:  *Obj_desc       - Object to be converted.  Must be an
+ * PARAMETERS:  *obj_desc       - Object to be converted.  Must be an
  *                                Integer, Buffer, or String
- *              Walk_state      - Current method state
+ *              walk_state      - Current method state
  *
  * RETURN:      Status
  *
@@ -383,39 +408,39 @@
 
 acpi_status
 acpi_ex_convert_to_string (
-	acpi_operand_object     *obj_desc,
-	acpi_operand_object     **result_desc,
-	u32                     base,
-	u32                     max_length,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       *obj_desc,
+	union acpi_operand_object       **result_desc,
+	u32                             base,
+	u32                             max_length,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_operand_object     *ret_desc;
-	u32                     i;
-	u32                     index;
-	u32                     string_length;
-	u32                     integer_size = sizeof (acpi_integer);
-	u8                      *new_buf;
-	u8                      *pointer;
+	union acpi_operand_object       *ret_desc;
+	u32                             i;
+	u32                             string_length;
+	u8                              *new_buf;
+	u8                              *pointer;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_TRACE_PTR ("ex_convert_to_string", obj_desc);
 
 
-	switch (obj_desc->common.type) {
-	case ACPI_TYPE_INTEGER:
+	switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
+	case ACPI_TYPE_STRING:
 
-		/* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */
+		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 */
 
-		if (walk_state->method_node->flags & ANOBJ_DATA_WIDTH_32) {
-			/*
-			 * We are running a method that exists in a 32-bit ACPI table.
-			 * Truncate the value to 32 bits by zeroing out the upper
-			 * 32-bit field
-			 */
-			integer_size = sizeof (u32);
+			return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
 		}
 
-		string_length = integer_size * 2;
+
+	case ACPI_TYPE_INTEGER:
+
+		string_length = acpi_gbl_integer_byte_width * 2;
 		if (base == 10) {
 			string_length = ACPI_MAX_DECIMAL_DIGITS;
 		}
@@ -425,23 +450,22 @@
 		 */
 		ret_desc = acpi_ut_create_internal_object (ACPI_TYPE_STRING);
 		if (!ret_desc) {
-			return (AE_NO_MEMORY);
+			return_ACPI_STATUS (AE_NO_MEMORY);
 		}
 
 		/* Need enough space for one ASCII integer plus null terminator */
 
-		new_buf = ACPI_MEM_CALLOCATE (string_length + 1);
+		new_buf = ACPI_MEM_CALLOCATE ((acpi_size) string_length + 1);
 		if (!new_buf) {
-			REPORT_ERROR
-				(("Ex_convert_to_string: Buffer allocation failure\n"));
+			ACPI_REPORT_ERROR
+				(("ex_convert_to_string: Buffer allocation failure\n"));
 			acpi_ut_remove_reference (ret_desc);
-			return (AE_NO_MEMORY);
+			return_ACPI_STATUS (AE_NO_MEMORY);
 		}
 
-
 		/* Convert */
 
-		i = acpi_ex_convert_to_ascii (obj_desc->integer.value, base, new_buf);
+		i = acpi_ex_convert_to_ascii (obj_desc->integer.value, base, new_buf, sizeof (acpi_integer));
 
 		/* Null terminate at the correct place */
 
@@ -455,29 +479,25 @@
 		}
 
 		ret_desc->buffer.pointer = new_buf;
-
-		/* Return the new buffer descriptor */
-
-		if (*result_desc == obj_desc) {
-			if (walk_state->opcode != AML_STORE_OP) {
-				acpi_ut_remove_reference (obj_desc);
-			}
-		}
-
-		*result_desc = ret_desc;
 		break;
 
 
 	case ACPI_TYPE_BUFFER:
 
-		string_length = obj_desc->buffer.length * 3;
-		if (base == 10) {
-			string_length = obj_desc->buffer.length * 4;
+		/* Find the string length */
+
+		pointer = obj_desc->buffer.pointer;
+		for (string_length = 0; string_length < obj_desc->buffer.length; string_length++) {
+			/* Exit on null terminator */
+
+			if (!pointer[string_length]) {
+				break;
+			}
 		}
 
 		if (max_length > ACPI_MAX_STRING_CONVERSION) {
 			if (string_length > ACPI_MAX_STRING_CONVERSION) {
-				return (AE_AML_STRING_LIMIT);
+				return_ACPI_STATUS (AE_AML_STRING_LIMIT);
 			}
 		}
 
@@ -486,7 +506,7 @@
 		 */
 		ret_desc = acpi_ut_create_internal_object (ACPI_TYPE_STRING);
 		if (!ret_desc) {
-			return (AE_NO_MEMORY);
+			return_ACPI_STATUS (AE_NO_MEMORY);
 		}
 
 		/* String length is the lesser of the Max or the actual length */
@@ -495,92 +515,77 @@
 			string_length = max_length;
 		}
 
-		new_buf = ACPI_MEM_CALLOCATE (string_length + 1);
+		new_buf = ACPI_MEM_CALLOCATE ((acpi_size) string_length + 1);
 		if (!new_buf) {
-			REPORT_ERROR
-				(("Ex_convert_to_string: Buffer allocation failure\n"));
+			ACPI_REPORT_ERROR
+				(("ex_convert_to_string: Buffer allocation failure\n"));
 			acpi_ut_remove_reference (ret_desc);
-			return (AE_NO_MEMORY);
+			return_ACPI_STATUS (AE_NO_MEMORY);
 		}
 
-		/*
-		 * Convert each byte of the buffer to two ASCII characters plus a space.
-		 */
-		pointer = obj_desc->buffer.pointer;
-		index = 0;
-		for (i = 0, index = 0; i < obj_desc->buffer.length; i++) {
-			index = acpi_ex_convert_to_ascii (pointer[i], base, &new_buf[index]);
+		/* Copy the appropriate number of buffer characters */
 
-			new_buf[index] = ' ';
-			index++;
-		}
+		ACPI_MEMCPY (new_buf, pointer, string_length);
 
 		/* Null terminate */
 
-		new_buf [index-1] = 0;
+		new_buf [string_length] = 0;
 		ret_desc->buffer.pointer = new_buf;
-		ret_desc->string.length = STRLEN ((char *) new_buf);
-
-
-		/* Return the new buffer descriptor */
-
-		if (*result_desc == obj_desc) {
-			if (walk_state->opcode != AML_STORE_OP) {
-				acpi_ut_remove_reference (obj_desc);
-			}
-		}
-
-		*result_desc = ret_desc;
+		ret_desc->string.length = string_length;
 		break;
 
 
-	case ACPI_TYPE_STRING:
-
-		if (max_length >= obj_desc->string.length) {
-			*result_desc = obj_desc;
-		}
+	default:
+		return_ACPI_STATUS (AE_TYPE);
+	}
 
-		else {
-			/* Must copy the string first and then truncate it */
 
-			return (AE_NOT_IMPLEMENTED);
+	/*
+	 * 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);
 		}
-		break;
-
-
-	default:
-		return (AE_TYPE);
-		break;
-   }
+	}
 
-	return (AE_OK);
+	*result_desc = ret_desc;
+	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_convert_to_target_type
+ * FUNCTION:    acpi_ex_convert_to_target_type
  *
- * PARAMETERS:  *Obj_desc       - Object to be converted.
- *              Walk_state      - Current method state
+ * PARAMETERS:  destination_type    - Current type of the destination
+ *              source_desc         - Source object to be converted.
+ *              walk_state          - Current method state
  *
  * RETURN:      Status
  *
- * DESCRIPTION:
+ * DESCRIPTION: Implements "implicit conversion" rules for storing an object.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ex_convert_to_target_type (
-	acpi_object_type8       destination_type,
-	acpi_operand_object     **obj_desc,
-	acpi_walk_state         *walk_state)
+	acpi_object_type                destination_type,
+	union acpi_operand_object       *source_desc,
+	union acpi_operand_object       **result_desc,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status = AE_OK;
+	acpi_status                     status = AE_OK;
+
 
+	ACPI_FUNCTION_TRACE ("ex_convert_to_target_type");
 
-	FUNCTION_TRACE ("Ex_convert_to_target_type");
 
+	/* Default behavior */
+
+	*result_desc = source_desc;
 
 	/*
 	 * If required by the target,
@@ -592,7 +597,7 @@
 	case ARGI_INTEGER_REF:      /* Handles Increment, Decrement cases */
 
 		switch (destination_type) {
-		case INTERNAL_TYPE_REGION_FIELD:
+		case ACPI_TYPE_LOCAL_REGION_FIELD:
 			/*
 			 * Named field can always handle conversions
 			 */
@@ -601,10 +606,10 @@
 		default:
 			/* No conversion allowed for these types */
 
-			if (destination_type != (*obj_desc)->common.type) {
-				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-					"Target does not allow conversion of type %s to %s\n",
-					acpi_ut_get_type_name ((*obj_desc)->common.type),
+			if (destination_type != ACPI_GET_OBJECT_TYPE (source_desc)) {
+				ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+					"Explicit operator, will store (%s) over existing type (%s)\n",
+					acpi_ut_get_object_type_name (source_desc),
 					acpi_ut_get_type_name (destination_type)));
 				status = AE_TYPE;
 			}
@@ -617,13 +622,13 @@
 		switch (destination_type) {
 		case ACPI_TYPE_INTEGER:
 		case ACPI_TYPE_BUFFER_FIELD:
-		case INTERNAL_TYPE_BANK_FIELD:
-		case INTERNAL_TYPE_INDEX_FIELD:
+		case ACPI_TYPE_LOCAL_BANK_FIELD:
+		case ACPI_TYPE_LOCAL_INDEX_FIELD:
 			/*
 			 * 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 (*obj_desc, obj_desc, walk_state);
+			status = acpi_ex_convert_to_integer (source_desc, result_desc, walk_state);
 			break;
 
 
@@ -633,17 +638,22 @@
 			 * The operand must be a String.  We can convert an
 			 * Integer or Buffer if necessary
 			 */
-			status = acpi_ex_convert_to_string (*obj_desc, obj_desc, 16, ACPI_UINT32_MAX, walk_state);
+			status = acpi_ex_convert_to_string (source_desc, result_desc, 16, ACPI_UINT32_MAX, walk_state);
 			break;
 
 
 		case ACPI_TYPE_BUFFER:
 
 			/*
-			 * The operand must be a String.  We can convert an
-			 * Integer or Buffer if necessary
+			 * The operand must be a Buffer.  We can convert an
+			 * Integer or String if necessary
 			 */
-			status = acpi_ex_convert_to_buffer (*obj_desc, obj_desc, walk_state);
+			status = acpi_ex_convert_to_buffer (source_desc, result_desc, walk_state);
+			break;
+
+
+		default:
+			status = AE_AML_INTERNAL;
 			break;
 		}
 		break;
@@ -651,21 +661,20 @@
 
 	case ARGI_REFERENCE:
 		/*
-		 * Create_xxxx_field cases - we are storing the field object into the name
+		 * create_xxxx_field cases - we are storing the field object into the name
 		 */
 		break;
 
 
 	default:
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-			"Unknown Target type ID 0x%X Op %s Dest_type %s\n",
+			"Unknown Target type ID 0x%X Op %s dest_type %s\n",
 			GET_CURRENT_ARG_TYPE (walk_state->op_info->runtime_args),
 			walk_state->op_info->name, acpi_ut_get_type_name (destination_type)));
 
 		status = AE_AML_INTERNAL;
 	}
 
-
 	/*
 	 * Source-to-Target conversion semantics:
 	 *
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/excreate.c linux-2.4.22-pre2/drivers/acpi/executer/excreate.c
--- linux-2.4.21/drivers/acpi/executer/excreate.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/excreate.c	2003-06-26 21:43:18.000000000 +0000
@@ -1,48 +1,65 @@
 /******************************************************************************
  *
  * Module Name: excreate - Named object creation
- *              $Revision: 71 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "acinterp.h"
-#include "amlcode.h"
-#include "acnamesp.h"
-#include "acevents.h"
-#include "acdispat.h"
+#include <acpi/acpi.h>
+#include <acpi/acinterp.h>
+#include <acpi/amlcode.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acevents.h>
+#include <acpi/actables.h>
 
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("excreate")
+	 ACPI_MODULE_NAME    ("excreate")
 
 
+#ifndef ACPI_NO_METHOD_EXECUTION
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ex_create_alias
+ * FUNCTION:    acpi_ex_create_alias
  *
- * PARAMETERS:  Walk_state           - Current state, contains List of
- *                                      operands for the opcode
+ * PARAMETERS:  walk_state           - Current state, contains operands
  *
  * RETURN:      Status
  *
@@ -52,32 +69,69 @@
 
 acpi_status
 acpi_ex_create_alias (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_namespace_node     *source_node;
-	acpi_status             status;
+	struct acpi_namespace_node      *target_node;
+	struct acpi_namespace_node      *alias_node;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE ("Ex_create_alias");
+	ACPI_FUNCTION_TRACE ("ex_create_alias");
 
 
 	/* Get the source/alias operands (both namespace nodes) */
 
-	source_node = (acpi_namespace_node *) walk_state->operands[1];
+	alias_node = (struct acpi_namespace_node *) walk_state->operands[0];
+	target_node = (struct acpi_namespace_node *) walk_state->operands[1];
 
-
-	/* Attach the original source object to the new Alias Node */
-
-	status = acpi_ns_attach_object ((acpi_namespace_node *) walk_state->operands[0],
-			   source_node->object,
-			   source_node->type);
+	if (target_node->type == ACPI_TYPE_LOCAL_ALIAS) {
+		/*
+		 * Dereference an existing alias so that we don't create a chain
+		 * of aliases.  With this code, we guarantee that an alias is
+		 * always exactly one level of indirection away from the
+		 * actual aliased name.
+		 */
+		target_node = (struct acpi_namespace_node *) target_node->object;
+	}
 
 	/*
-	 * The new alias assumes the type of the source, but it points
-	 * to the same object.  The reference count of the object has an
-	 * additional reference to prevent deletion out from under either the
-	 * source or the alias Node
+	 * For objects that can never change (i.e., the NS node will
+	 * permanently point to the same object), we can simply attach
+	 * the object to the new NS node.  For other objects (such as
+	 * Integers, buffers, etc.), we have to point the Alias node
+	 * to the original Node.
 	 */
+	switch (target_node->type) {
+	case ACPI_TYPE_INTEGER:
+	case ACPI_TYPE_STRING:
+	case ACPI_TYPE_BUFFER:
+	case ACPI_TYPE_PACKAGE:
+	case ACPI_TYPE_BUFFER_FIELD:
+
+		/*
+		 * The new alias has the type ALIAS and points to the original
+		 * NS node, not the object itself.  This is because for these
+		 * types, the object can change dynamically via a Store.
+		 */
+		alias_node->type = ACPI_TYPE_LOCAL_ALIAS;
+		alias_node->object = ACPI_CAST_PTR (union acpi_operand_object, target_node);
+		break;
+
+	default:
+
+		/* Attach the original source object to the new Alias Node */
+
+		/*
+		 * The new alias assumes the type of the target, and it points
+		 * to the same object.  The reference count of the object has an
+		 * additional reference to prevent deletion out from under either the
+		 * target node or the alias Node
+		 */
+		status = acpi_ns_attach_object (alias_node,
+				 acpi_ns_get_attached_object (target_node),
+				 target_node->type);
+		break;
+	}
 
 	/* Since both operands are Nodes, we don't need to delete them */
 
@@ -87,9 +141,9 @@
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ex_create_event
+ * FUNCTION:    acpi_ex_create_event
  *
- * PARAMETERS:  Walk_state          - Current state
+ * PARAMETERS:  walk_state          - Current state
  *
  * RETURN:      Status
  *
@@ -99,13 +153,13 @@
 
 acpi_status
 acpi_ex_create_event (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status;
-	acpi_operand_object     *obj_desc;
+	acpi_status                     status;
+	union acpi_operand_object       *obj_desc;
 
 
-	FUNCTION_TRACE ("Ex_create_event");
+	ACPI_FUNCTION_TRACE ("ex_create_event");
 
 
 	obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_EVENT);
@@ -114,11 +168,11 @@
 		goto cleanup;
 	}
 
-	/* Create the actual OS semaphore */
-
-	/* TBD: [Investigate] should be created with 0 or 1 units? */
-
-	status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 1,
+	/*
+	 * Create the actual OS semaphore, with zero initial units -- meaning
+	 * that the event is created in an unsignalled state
+	 */
+	status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 0,
 			   &obj_desc->event.semaphore);
 	if (ACPI_FAILURE (status)) {
 		goto cleanup;
@@ -126,8 +180,8 @@
 
 	/* Attach object to the Node */
 
-	status = acpi_ns_attach_object ((acpi_namespace_node *) walk_state->operands[0],
-			   obj_desc, (u8) ACPI_TYPE_EVENT);
+	status = acpi_ns_attach_object ((struct acpi_namespace_node *) walk_state->operands[0],
+			   obj_desc, ACPI_TYPE_EVENT);
 
 cleanup:
 	/*
@@ -141,27 +195,27 @@
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ex_create_mutex
+ * FUNCTION:    acpi_ex_create_mutex
  *
- * PARAMETERS:  Walk_state          - Current state
+ * PARAMETERS:  walk_state          - Current state
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Create a new mutex object
  *
- *              Mutex (Name[0], Sync_level[1])
+ *              Mutex (Name[0], sync_level[1])
  *
  ****************************************************************************/
 
 acpi_status
 acpi_ex_create_mutex (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status = AE_OK;
-	acpi_operand_object     *obj_desc;
+	acpi_status                     status = AE_OK;
+	union acpi_operand_object       *obj_desc;
 
 
-	FUNCTION_TRACE_PTR ("Ex_create_mutex", WALK_OPERANDS);
+	ACPI_FUNCTION_TRACE_PTR ("ex_create_mutex", ACPI_WALK_OPERANDS);
 
 
 	/* Create the new mutex object */
@@ -172,8 +226,11 @@
 		goto cleanup;
 	}
 
-	/* Create the actual OS semaphore */
-
+	/*
+	 * Create the actual OS semaphore.
+	 * One unit max to make it a mutex, with one initial unit to allow
+	 * the mutex to be acquired.
+	 */
 	status = acpi_os_create_semaphore (1, 1, &obj_desc->mutex.semaphore);
 	if (ACPI_FAILURE (status)) {
 		goto cleanup;
@@ -182,9 +239,10 @@
 	/* Init object and attach to NS node */
 
 	obj_desc->mutex.sync_level = (u8) walk_state->operands[1]->integer.value;
+	obj_desc->mutex.node = (struct acpi_namespace_node *) walk_state->operands[0];
 
-	status = acpi_ns_attach_object ((acpi_namespace_node *) walk_state->operands[0],
-			  obj_desc, (u8) ACPI_TYPE_MUTEX);
+	status = acpi_ns_attach_object (obj_desc->mutex.node,
+			 obj_desc, ACPI_TYPE_MUTEX);
 
 
 cleanup:
@@ -199,12 +257,12 @@
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ex_create_region
+ * FUNCTION:    acpi_ex_create_region
  *
- * PARAMETERS:  Aml_start           - Pointer to the region declaration AML
- *              Aml_length          - Max length of the declaration AML
+ * PARAMETERS:  aml_start           - Pointer to the region declaration AML
+ *              aml_length          - Max length of the declaration AML
  *              Operands            - List of operands for the opcode
- *              Walk_state          - Current state
+ *              walk_state          - Current state
  *
  * RETURN:      Status
  *
@@ -214,28 +272,29 @@
 
 acpi_status
 acpi_ex_create_region (
-	u8                      *aml_start,
-	u32                     aml_length,
-	u8                      region_space,
-	acpi_walk_state         *walk_state)
+	u8                              *aml_start,
+	u32                             aml_length,
+	u8                              region_space,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status;
-	acpi_operand_object     *obj_desc;
-	acpi_namespace_node     *node;
+	acpi_status                     status;
+	union acpi_operand_object       *obj_desc;
+	struct acpi_namespace_node      *node;
+	union acpi_operand_object       *region_obj2;
 
 
-	FUNCTION_TRACE ("Ex_create_region");
+	ACPI_FUNCTION_TRACE ("ex_create_region");
 
 
 	/* Get the Node from the object stack  */
 
-	node = (acpi_namespace_node *) walk_state->operands[0];
+	node = walk_state->op->common.node;
 
 	/*
 	 * If the region object is already attached to this node,
 	 * just return
 	 */
-	if (node->object) {
+	if (acpi_ns_get_attached_object (node)) {
 		return_ACPI_STATUS (AE_OK);
 	}
 
@@ -243,9 +302,9 @@
 	 * Space ID must be one of the predefined IDs, or in the user-defined
 	 * range
 	 */
-	if ((region_space >= NUM_REGION_TYPES) &&
-		(region_space < USER_REGION_BEGIN)) {
-		REPORT_ERROR (("Invalid Address_space type %X\n", region_space));
+	if ((region_space >= ACPI_NUM_PREDEFINED_REGIONS) &&
+		(region_space < ACPI_USER_REGION_BEGIN)) {
+		ACPI_REPORT_ERROR (("Invalid address_space type %X\n", region_space));
 		return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID);
 	}
 
@@ -261,21 +320,13 @@
 		goto cleanup;
 	}
 
-	/* Allocate a method object for this region */
-
-	obj_desc->region.extra = acpi_ut_create_internal_object (
-			 INTERNAL_TYPE_EXTRA);
-	if (!obj_desc->region.extra) {
-		status = AE_NO_MEMORY;
-		goto cleanup;
-	}
-
 	/*
 	 * Remember location in AML stream of address & length
 	 * operands since they need to be evaluated at run time.
 	 */
-	obj_desc->region.extra->extra.aml_start = aml_start;
-	obj_desc->region.extra->extra.aml_length = aml_length;
+	region_obj2                 = obj_desc->common.next_object;
+	region_obj2->extra.aml_start = aml_start;
+	region_obj2->extra.aml_length = aml_length;
 
 	/* Init the region from the operands */
 
@@ -286,102 +337,137 @@
 
 	/* Install the new region object in the parent Node */
 
-	status = acpi_ns_attach_object (node, obj_desc,
-			  (u8) ACPI_TYPE_REGION);
-	if (ACPI_FAILURE (status)) {
-		goto cleanup;
-	}
+	status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_REGION);
 
-	/*
-	 * If we have a valid region, initialize it
-	 * Namespace is NOT locked at this point.
-	 */
-	status = acpi_ev_initialize_region (obj_desc, FALSE);
-	if (ACPI_FAILURE (status)) {
-		/*
-		 *  If AE_NOT_EXIST is returned, it is not fatal
-		 *  because many regions get created before a handler
-		 *  is installed for said region.
-		 */
-		if (AE_NOT_EXIST == status) {
-			status = AE_OK;
-		}
-	}
 
 cleanup:
 
 	/* Remove local reference to the object */
 
 	acpi_ut_remove_reference (obj_desc);
-
 	return_ACPI_STATUS (status);
 }
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ex_create_table_region
+ * FUNCTION:    acpi_ex_create_table_region
  *
- * PARAMETERS:  Walk_state          - Current state
+ * PARAMETERS:  walk_state          - Current state
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Create a new Data_table_region object
+ * DESCRIPTION: Create a new data_table_region object
  *
  ****************************************************************************/
 
 acpi_status
 acpi_ex_create_table_region (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status = AE_OK;
+	acpi_status                     status;
+	union acpi_operand_object       **operand = &walk_state->operands[0];
+	union acpi_operand_object       *obj_desc;
+	struct acpi_namespace_node      *node;
+	struct acpi_table_header        *table;
+	union acpi_operand_object       *region_obj2;
 
 
-	FUNCTION_TRACE ("Ex_create_table_region");
+	ACPI_FUNCTION_TRACE ("ex_create_table_region");
 
-/*
-	acpi_operand_object     *Obj_desc;
-	Obj_desc = Acpi_ut_create_internal_object (ACPI_TYPE_REGION);
-	if (!Obj_desc)
-	{
-		Status = AE_NO_MEMORY;
-		goto Cleanup;
+	/* Get the Node from the object stack  */
+
+	node = walk_state->op->common.node;
+
+	/*
+	 * If the region object is already attached to this node,
+	 * just return
+	 */
+	if (acpi_ns_get_attached_object (node)) {
+		return_ACPI_STATUS (AE_OK);
 	}
 
+	/* Find the ACPI table */
 
-Cleanup:
-*/
+	status = acpi_tb_find_table (operand[1]->string.pointer,
+			   operand[2]->string.pointer,
+			   operand[3]->string.pointer, &table);
+
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/* Create the region descriptor */
+
+	obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_REGION);
+	if (!obj_desc) {
+		return_ACPI_STATUS (AE_NO_MEMORY);
+	}
+
+	region_obj2                     = obj_desc->common.next_object;
+	region_obj2->extra.region_context = NULL;
+
+	/* Init the region from the operands */
+
+	obj_desc->region.space_id = REGION_DATA_TABLE;
+	obj_desc->region.address = (acpi_physical_address) ACPI_TO_INTEGER (table);
+	obj_desc->region.length = table->length;
+	obj_desc->region.node   = node;
+	obj_desc->region.flags  = AOPOBJ_DATA_VALID;
 
+	/* Install the new region object in the parent Node */
+
+	status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_REGION);
+	if (ACPI_FAILURE (status)) {
+		goto cleanup;
+	}
+
+	status = acpi_ev_initialize_region (obj_desc, FALSE);
+	if (ACPI_FAILURE (status)) {
+		if (status == AE_NOT_EXIST) {
+			status = AE_OK;
+		}
+		else {
+			goto cleanup;
+		}
+	}
+
+	obj_desc->region.flags |= AOPOBJ_SETUP_COMPLETE;
+
+
+cleanup:
+
+	/* Remove local reference to the object */
+
+	acpi_ut_remove_reference (obj_desc);
 	return_ACPI_STATUS (status);
 }
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ex_create_processor
+ * FUNCTION:    acpi_ex_create_processor
  *
- * PARAMETERS:  Op              - Op containing the Processor definition and
- *                                args
- *              Processor_node  - Parent Node for the processor object
+ * PARAMETERS:  walk_state          - Current state
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Create a new processor object and populate the fields
  *
- *              Processor (Name[0], Cpu_iD[1], Pblock_addr[2], Pblock_length[3])
+ *              Processor (Name[0], cpu_iD[1], pblock_addr[2], pblock_length[3])
  *
  ****************************************************************************/
 
 acpi_status
 acpi_ex_create_processor (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_operand_object     **operand = &walk_state->operands[0];
-	acpi_operand_object     *obj_desc;
-	acpi_status             status;
+	union acpi_operand_object       **operand = &walk_state->operands[0];
+	union acpi_operand_object       *obj_desc;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE_PTR ("Ex_create_processor", walk_state);
+	ACPI_FUNCTION_TRACE_PTR ("ex_create_processor", walk_state);
 
 
 	/* Create the processor object */
@@ -395,13 +481,13 @@
 	 * Initialize the processor object from the operands
 	 */
 	obj_desc->processor.proc_id = (u8)          operand[1]->integer.value;
-	obj_desc->processor.address = (ACPI_IO_ADDRESS) operand[2]->integer.value;
+	obj_desc->processor.address = (acpi_io_address) operand[2]->integer.value;
 	obj_desc->processor.length = (u8)           operand[3]->integer.value;
 
 	/* Install the processor object in the parent Node */
 
-	status = acpi_ns_attach_object ((acpi_namespace_node *) operand[0],
-			  obj_desc, (u8) ACPI_TYPE_PROCESSOR);
+	status = acpi_ns_attach_object ((struct acpi_namespace_node *) operand[0],
+			  obj_desc, ACPI_TYPE_PROCESSOR);
 
 
 	/* Remove local reference to the object */
@@ -413,30 +499,28 @@
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ex_create_power_resource
+ * FUNCTION:    acpi_ex_create_power_resource
  *
- * PARAMETERS:  Op              - Op containing the Power_resource definition
- *                                and args
- *              Power_node      - Parent Node for the power object
+ * PARAMETERS:  walk_state          - Current state
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Create a new Power_resource object and populate the fields
+ * DESCRIPTION: Create a new power_resource object and populate the fields
  *
- *              Power_resource (Name[0], System_level[1], Resource_order[2])
+ *              power_resource (Name[0], system_level[1], resource_order[2])
  *
  ****************************************************************************/
 
 acpi_status
 acpi_ex_create_power_resource (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_operand_object     **operand = &walk_state->operands[0];
-	acpi_status             status;
-	acpi_operand_object     *obj_desc;
+	union acpi_operand_object       **operand = &walk_state->operands[0];
+	acpi_status                     status;
+	union acpi_operand_object       *obj_desc;
 
 
-	FUNCTION_TRACE_PTR ("Ex_create_power_resource", walk_state);
+	ACPI_FUNCTION_TRACE_PTR ("ex_create_power_resource", walk_state);
 
 
 	/* Create the power resource object */
@@ -453,8 +537,8 @@
 
 	/* Install the  power resource object in the parent Node */
 
-	status = acpi_ns_attach_object ((acpi_namespace_node *) operand[0],
-			  obj_desc, (u8) ACPI_TYPE_POWER);
+	status = acpi_ns_attach_object ((struct acpi_namespace_node *) operand[0],
+			  obj_desc, ACPI_TYPE_POWER);
 
 
 	/* Remove local reference to the object */
@@ -463,15 +547,15 @@
 	return_ACPI_STATUS (status);
 }
 
+#endif
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ex_create_method
+ * FUNCTION:    acpi_ex_create_method
  *
- * PARAMETERS:  Aml_start       - First byte of the method's AML
- *              Aml_length      - AML byte count for this method
- *              Method_flags    - AML method flag byte
- *              Method          - Method Node
+ * PARAMETERS:  aml_start       - First byte of the method's AML
+ *              aml_length      - AML byte count for this method
+ *              walk_state      - Current state
  *
  * RETURN:      Status
  *
@@ -481,17 +565,17 @@
 
 acpi_status
 acpi_ex_create_method (
-	u8                      *aml_start,
-	u32                     aml_length,
-	acpi_walk_state         *walk_state)
+	u8                              *aml_start,
+	u32                             aml_length,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_operand_object     **operand = &walk_state->operands[0];
-	acpi_operand_object     *obj_desc;
-	acpi_status             status;
-	u8                      method_flags;
+	union acpi_operand_object       **operand = &walk_state->operands[0];
+	union acpi_operand_object       *obj_desc;
+	acpi_status                     status;
+	u8                              method_flags;
 
 
-	FUNCTION_TRACE_PTR ("Ex_create_method", walk_state);
+	ACPI_FUNCTION_TRACE_PTR ("ex_create_method", walk_state);
 
 
 	/* Create a new method object */
@@ -520,7 +604,7 @@
 	if (method_flags & METHOD_FLAGS_SERIALIZED) {
 		/*
 		 * ACPI 1.0: Concurrency = 1
-		 * ACPI 2.0: Concurrency = (Sync_level (in method declaration) + 1)
+		 * ACPI 2.0: Concurrency = (sync_level (in method declaration) + 1)
 		 */
 		obj_desc->method.concurrency = (u8)
 				  (((method_flags & METHOD_FLAGS_SYNCH_LEVEL) >> 4) + 1);
@@ -532,8 +616,8 @@
 
 	/* Attach the new object to the method Node */
 
-	status = acpi_ns_attach_object ((acpi_namespace_node *) operand[0],
-			  obj_desc, (u8) ACPI_TYPE_METHOD);
+	status = acpi_ns_attach_object ((struct acpi_namespace_node *) operand[0],
+			  obj_desc, ACPI_TYPE_METHOD);
 
 	/* Remove local reference to the object */
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exdump.c linux-2.4.22-pre2/drivers/acpi/executer/exdump.c
--- linux-2.4.21/drivers/acpi/executer/exdump.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exdump.c	2003-06-26 21:43:11.000000000 +0000
@@ -1,271 +1,198 @@
 /******************************************************************************
  *
  * Module Name: exdump - Interpreter debug output routines
- *              $Revision: 126 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acinterp.h"
-#include "amlcode.h"
-#include "acnamesp.h"
-#include "actables.h"
-#include "acparser.h"
+#include <acpi/acpi.h>
+#include <acpi/acinterp.h>
+#include <acpi/amlcode.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acparser.h>
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exdump")
+	 ACPI_MODULE_NAME    ("exdump")
 
 
 /*
  * The following routines are used for debug output only
  */
 
-#if defined(ACPI_DEBUG) || defined(ENABLE_DEBUGGER)
+#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ex_show_hex_value
+ * FUNCTION:    acpi_ex_dump_operand
  *
- * PARAMETERS:  Byte_count          - Number of bytes to print (1, 2, or 4)
- *              *Aml_start            - Address in AML stream of bytes to print
- *              Interpreter_mode    - Current running mode (load1/Load2/Exec)
- *              Lead_space          - # of spaces to print ahead of value
- *                                    0 => none ahead but one behind
- *
- * DESCRIPTION: Print Byte_count byte(s) starting at Aml_start as a single
- *              value, in hex.  If Byte_count > 1 or the value printed is > 9, also
- *              print in decimal.
- *
- ****************************************************************************/
-
-void
-acpi_ex_show_hex_value (
-	u32                     byte_count,
-	u8                      *aml_start,
-	u32                     lead_space)
-{
-	u32                     value;                  /*  Value retrieved from AML stream */
-	u32                     show_decimal_value;
-	u32                     length;                 /*  Length of printed field */
-	u8                      *current_aml_ptr = NULL; /* Pointer to current byte of AML value    */
-
-
-	FUNCTION_TRACE ("Ex_show_hex_value");
-
-
-	if (!aml_start) {
-		REPORT_ERROR (("Ex_show_hex_value: null pointer\n"));
-	}
-
-	/*
-	 * AML numbers are always stored little-endian,
-	 * even if the processor is big-endian.
-	 */
-	for (current_aml_ptr = aml_start + byte_count,
-			value = 0;
-			current_aml_ptr > aml_start; ) {
-		value = (value << 8) + (u32)* --current_aml_ptr;
-	}
-
-	length = lead_space * byte_count + 2;
-	if (byte_count > 1) {
-		length += (byte_count - 1);
-	}
-
-	show_decimal_value = (byte_count > 1 || value > 9);
-	if (show_decimal_value) {
-		length += 3 + acpi_ex_digits_needed (value, 10);
-	}
-
-	for (length = lead_space; length; --length ) {
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_LOAD, " "));
-	}
-
-	while (byte_count--) {
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_LOAD, "%02x", *aml_start++));
-
-		if (byte_count) {
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_LOAD, " "));
-		}
-	}
-
-	if (show_decimal_value) {
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_LOAD, " [%d]", value));
-	}
-
-	if (0 == lead_space) {
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_LOAD, " "));
-	}
-
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_LOAD, "\n"));
-	return_VOID;
-}
-
-
-/*****************************************************************************
- *
- * FUNCTION:    Acpi_ex_dump_operand
- *
- * PARAMETERS:  *Entry_desc         - Pointer to entry to be dumped
+ * PARAMETERS:  *obj_desc         - Pointer to entry to be dumped
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Dump a stack entry
+ * DESCRIPTION: Dump an operand object
  *
  ****************************************************************************/
 
-acpi_status
+void
 acpi_ex_dump_operand (
-	acpi_operand_object     *entry_desc)
+	union acpi_operand_object       *obj_desc)
 {
-	u8                      *buf = NULL;
-	u32                     length;
-	u32                     i;
+	u8                              *buf = NULL;
+	u32                             length;
+	union acpi_operand_object       **element;
+	u16                             element_index;
 
 
-	PROC_NAME ("Ex_dump_operand")
+	ACPI_FUNCTION_NAME ("ex_dump_operand")
 
 
-	if (!entry_desc) {
+	if (!((ACPI_LV_EXEC & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) {
+		return;
+	}
+
+	if (!obj_desc) {
 		/*
 		 * This usually indicates that something serious is wrong --
 		 * since most (if not all)
 		 * code that dumps the stack expects something to be there!
 		 */
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null stack entry ptr\n"));
-		return (AE_OK);
+		acpi_os_printf ("Null stack entry ptr\n");
+		return;
 	}
 
-	if (VALID_DESCRIPTOR_TYPE (entry_desc, ACPI_DESC_TYPE_NAMED)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%p NS Node: ", entry_desc));
-		DUMP_ENTRY (entry_desc, ACPI_LV_INFO);
-		return (AE_OK);
+	if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p NS Node: ", obj_desc));
+		ACPI_DUMP_ENTRY (obj_desc, ACPI_LV_EXEC);
+		return;
 	}
 
-	if (!VALID_DESCRIPTOR_TYPE (entry_desc, ACPI_DESC_TYPE_INTERNAL)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%p Is not a local object \n", entry_desc));
-		DUMP_BUFFER (entry_desc, sizeof (acpi_operand_object));
-		return (AE_OK);
+	if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p is not a local object\n", obj_desc));
+		ACPI_DUMP_BUFFER (obj_desc, sizeof (union acpi_operand_object));
+		return;
 	}
 
-	/*  Entry_desc is a valid object */
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%p ", entry_desc));
-
-	switch (entry_desc->common.type) {
-	case INTERNAL_TYPE_REFERENCE:
-
-		switch (entry_desc->reference.opcode) {
-		case AML_ZERO_OP:
-
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Reference: Zero\n"));
-			break;
-
+	/*  obj_desc is a valid object */
 
-		case AML_ONE_OP:
-
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Reference: One\n"));
-			break;
-
-
-		case AML_ONES_OP:
-
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Reference: Ones\n"));
-			break;
-
-
-		case AML_REVISION_OP:
-
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Reference: Revision\n"));
-			break;
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", obj_desc));
 
+	switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
+	case ACPI_TYPE_LOCAL_REFERENCE:
 
+		switch (obj_desc->reference.opcode) {
 		case AML_DEBUG_OP:
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Reference: Debug\n"));
+			acpi_os_printf ("Reference: Debug\n");
 			break;
 
 
 		case AML_NAME_OP:
 
-			DUMP_PATHNAME (entry_desc->reference.object, "Reference: Name: ",
+			ACPI_DUMP_PATHNAME (obj_desc->reference.object, "Reference: Name: ",
 					  ACPI_LV_INFO, _COMPONENT);
-			DUMP_ENTRY (entry_desc->reference.object, ACPI_LV_INFO);
+			ACPI_DUMP_ENTRY (obj_desc->reference.object, ACPI_LV_INFO);
 			break;
 
 
 		case AML_INDEX_OP:
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Reference: Index %p\n",
-					 entry_desc->reference.object));
+			acpi_os_printf ("Reference: Index %p\n",
+					 obj_desc->reference.object);
+			break;
+
+
+		case AML_REF_OF_OP:
+
+			acpi_os_printf ("Reference: (ref_of) %p\n",
+					 obj_desc->reference.object);
 			break;
 
 
 		case AML_ARG_OP:
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Reference: Arg%d",
-					 entry_desc->reference.offset));
+			acpi_os_printf ("Reference: Arg%d",
+					 obj_desc->reference.offset);
 
-			if (ACPI_TYPE_INTEGER == entry_desc->common.type) {
+			if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) {
 				/* Value is a Number */
 
-				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, " value is [%8.8X%8.8x]",
-						  HIDWORD(entry_desc->integer.value),
-						  LODWORD(entry_desc->integer.value)));
+				acpi_os_printf (" value is [%8.8X%8.8x]",
+						 ACPI_HIDWORD(obj_desc->integer.value),
+						 ACPI_LODWORD(obj_desc->integer.value));
 			}
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "\n"));
+			acpi_os_printf ("\n");
 			break;
 
 
 		case AML_LOCAL_OP:
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Reference: Local%d",
-					 entry_desc->reference.offset));
+			acpi_os_printf ("Reference: Local%d",
+					 obj_desc->reference.offset);
 
-			if (ACPI_TYPE_INTEGER == entry_desc->common.type) {
+			if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) {
 
 				/* Value is a Number */
 
-				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, " value is [%8.8X%8.8x]",
-						  HIDWORD(entry_desc->integer.value),
-						  LODWORD(entry_desc->integer.value)));
+				acpi_os_printf (" value is [%8.8X%8.8x]",
+						 ACPI_HIDWORD(obj_desc->integer.value),
+						 ACPI_LODWORD(obj_desc->integer.value));
 			}
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "\n"));
+			acpi_os_printf ("\n");
 			break;
 
 
 		case AML_INT_NAMEPATH_OP:
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Reference.Node->Name %X\n",
-					 entry_desc->reference.node->name));
+
+			acpi_os_printf ("Reference.Node->Name %X\n",
+					 obj_desc->reference.node->name.integer);
 			break;
 
+
 		default:
 
 			/*  unknown opcode  */
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Unknown opcode=%X\n",
-				entry_desc->reference.opcode));
+			acpi_os_printf ("Unknown Reference opcode=%X\n",
+				obj_desc->reference.opcode);
 			break;
 
 		}
@@ -275,11 +202,11 @@
 
 	case ACPI_TYPE_BUFFER:
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Buffer len %X @ %p \n",
-				 entry_desc->buffer.length,
-				 entry_desc->buffer.pointer));
+		acpi_os_printf ("Buffer len %X @ %p \n",
+				 obj_desc->buffer.length,
+				 obj_desc->buffer.pointer);
 
-		length = entry_desc->buffer.length;
+		length = obj_desc->buffer.length;
 
 		if (length > 64) {
 			length = 64;
@@ -287,13 +214,13 @@
 
 		/* Debug only -- dump the buffer contents */
 
-		if (entry_desc->buffer.pointer) {
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Buffer Contents: "));
+		if (obj_desc->buffer.pointer) {
+			acpi_os_printf ("Buffer Contents: ");
 
-			for (buf = entry_desc->buffer.pointer; length--; ++buf) {
-				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, " %02x", *buf));
+			for (buf = obj_desc->buffer.pointer; length--; ++buf) {
+				acpi_os_printf (" %02x", *buf);
 			}
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,"\n"));
+			acpi_os_printf ("\n");
 		}
 
 		break;
@@ -301,135 +228,104 @@
 
 	case ACPI_TYPE_INTEGER:
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Integer %8.8X%8.8X\n",
-				 HIDWORD (entry_desc->integer.value),
-				 LODWORD (entry_desc->integer.value)));
-		break;
-
-
-	case INTERNAL_TYPE_IF:
-
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "If [Integer] %8.8X%8.8X\n",
-				 HIDWORD (entry_desc->integer.value),
-				 LODWORD (entry_desc->integer.value)));
-		break;
-
-
-	case INTERNAL_TYPE_WHILE:
-
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "While [Integer] %8.8X%8.8X\n",
-				 HIDWORD (entry_desc->integer.value),
-				 LODWORD (entry_desc->integer.value)));
+		acpi_os_printf ("Integer %8.8X%8.8X\n",
+				 ACPI_HIDWORD (obj_desc->integer.value),
+				 ACPI_LODWORD (obj_desc->integer.value));
 		break;
 
 
 	case ACPI_TYPE_PACKAGE:
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Package count %X @ %p\n",
-				 entry_desc->package.count, entry_desc->package.elements));
+		acpi_os_printf ("Package count %X @ %p\n",
+				 obj_desc->package.count, obj_desc->package.elements);
 
 		/*
 		 * If elements exist, package vector pointer is valid,
 		 * and debug_level exceeds 1, dump package's elements.
 		 */
-		if (entry_desc->package.count &&
-			entry_desc->package.elements &&
+		if (obj_desc->package.count &&
+			obj_desc->package.elements &&
 			acpi_dbg_level > 1) {
-			acpi_operand_object**element;
-			u16                 element_index;
-
-			for (element_index = 0, element = entry_desc->package.elements;
-				  element_index < entry_desc->package.count;
+			for (element_index = 0, element = obj_desc->package.elements;
+				  element_index < obj_desc->package.count;
 				  ++element_index, ++element) {
 				acpi_ex_dump_operand (*element);
 			}
 		}
-
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "\n"));
-
+		acpi_os_printf ("\n");
 		break;
 
 
 	case ACPI_TYPE_REGION:
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Region %s (%X)",
-			acpi_ut_get_region_name (entry_desc->region.space_id),
-			entry_desc->region.space_id));
+		acpi_os_printf ("Region %s (%X)",
+			acpi_ut_get_region_name (obj_desc->region.space_id),
+			obj_desc->region.space_id);
 
 		/*
 		 * If the address and length have not been evaluated,
 		 * don't print them.
 		 */
-		if (!(entry_desc->region.flags & AOPOBJ_DATA_VALID)) {
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "\n"));
+		if (!(obj_desc->region.flags & AOPOBJ_DATA_VALID)) {
+			acpi_os_printf ("\n");
 		}
 		else {
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, " base %8.8X%8.8X Length %X\n",
-				HIDWORD(entry_desc->region.address),
-				LODWORD(entry_desc->region.address),
-				entry_desc->region.length));
+			acpi_os_printf (" base %8.8X%8.8X Length %X\n",
+				ACPI_HIDWORD (obj_desc->region.address),
+				ACPI_LODWORD (obj_desc->region.address),
+				obj_desc->region.length);
 		}
 		break;
 
 
 	case ACPI_TYPE_STRING:
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "String length %X @ %p \"",
-				 entry_desc->string.length, entry_desc->string.pointer));
-
-		for (i = 0; i < entry_desc->string.length; i++) {
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "%c",
-					 entry_desc->string.pointer[i]));
-		}
-
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "\"\n"));
+		acpi_os_printf ("String length %X @ %p ",
+				 obj_desc->string.length, obj_desc->string.pointer);
+		acpi_ut_print_string (obj_desc->string.pointer, ACPI_UINT8_MAX);
+		acpi_os_printf ("\n");
 		break;
 
 
-	case INTERNAL_TYPE_BANK_FIELD:
+	case ACPI_TYPE_LOCAL_BANK_FIELD:
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Bank_field\n"));
+		acpi_os_printf ("bank_field\n");
 		break;
 
 
-	case INTERNAL_TYPE_REGION_FIELD:
+	case ACPI_TYPE_LOCAL_REGION_FIELD:
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
-			"Region_field: bits=%X bitaccwidth=%X lock=%X update=%X at byte=%X bit=%X of below:\n",
-			entry_desc->field.bit_length,    entry_desc->field.access_bit_width,
-			entry_desc->field.lock_rule,     entry_desc->field.update_rule,
-			entry_desc->field.base_byte_offset, entry_desc->field.start_field_bit_offset));
-		DUMP_STACK_ENTRY (entry_desc->field.region_obj);
+		acpi_os_printf (
+			"region_field: Bits=%X acc_width=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n",
+			obj_desc->field.bit_length, obj_desc->field.access_byte_width,
+			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);
 		break;
 
 
-	case INTERNAL_TYPE_INDEX_FIELD:
+	case ACPI_TYPE_LOCAL_INDEX_FIELD:
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Index_field\n"));
+		acpi_os_printf ("index_field\n");
 		break;
 
 
 	case ACPI_TYPE_BUFFER_FIELD:
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
-			"Buffer_field: %X bits at byte %X bit %X of \n",
-			entry_desc->buffer_field.bit_length, entry_desc->buffer_field.base_byte_offset,
-			entry_desc->buffer_field.start_field_bit_offset));
+		acpi_os_printf (
+			"buffer_field: %X bits at byte %X bit %X of \n",
+			obj_desc->buffer_field.bit_length, obj_desc->buffer_field.base_byte_offset,
+			obj_desc->buffer_field.start_field_bit_offset);
 
-		if (!entry_desc->buffer_field.buffer_obj)
-		{
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "*NULL* \n"));
+		if (!obj_desc->buffer_field.buffer_obj) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL* \n"));
 		}
-
-		else if (ACPI_TYPE_BUFFER !=
-				  entry_desc->buffer_field.buffer_obj->common.type)
-		{
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "*not a Buffer* \n"));
+		else if (ACPI_GET_OBJECT_TYPE (obj_desc->buffer_field.buffer_obj) != ACPI_TYPE_BUFFER) {
+			acpi_os_printf ("*not a Buffer* \n");
 		}
-
-		else
-		{
-			DUMP_STACK_ENTRY (entry_desc->buffer_field.buffer_obj);
+		else {
+			ACPI_DUMP_STACK_ENTRY (obj_desc->buffer_field.buffer_obj);
 		}
 
 		break;
@@ -437,81 +333,67 @@
 
 	case ACPI_TYPE_EVENT:
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Event\n"));
+		acpi_os_printf ("Event\n");
 		break;
 
 
 	case ACPI_TYPE_METHOD:
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
+		acpi_os_printf (
 			"Method(%X) @ %p:%X\n",
-			entry_desc->method.param_count,
-			entry_desc->method.aml_start, entry_desc->method.aml_length));
+			obj_desc->method.param_count,
+			obj_desc->method.aml_start, obj_desc->method.aml_length);
 		break;
 
 
 	case ACPI_TYPE_MUTEX:
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Mutex\n"));
+		acpi_os_printf ("Mutex\n");
 		break;
 
 
 	case ACPI_TYPE_DEVICE:
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Device\n"));
+		acpi_os_printf ("Device\n");
 		break;
 
 
 	case ACPI_TYPE_POWER:
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Power\n"));
+		acpi_os_printf ("Power\n");
 		break;
 
 
 	case ACPI_TYPE_PROCESSOR:
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Processor\n"));
+		acpi_os_printf ("Processor\n");
 		break;
 
 
 	case ACPI_TYPE_THERMAL:
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Thermal\n"));
+		acpi_os_printf ("Thermal\n");
 		break;
 
 
 	default:
-		/*  unknown Entry_desc->Common.Type value   */
-
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Unknown Type %X\n",
-			entry_desc->common.type));
-
-		/* Back up to previous entry */
-
-		entry_desc--;
-
+		/* Unknown Type */
 
-		/* TBD: [Restructure]  Change to use dump object routine !! */
-		/*       What is all of this?? */
-
-		DUMP_BUFFER (entry_desc, sizeof (acpi_operand_object));
-		DUMP_BUFFER (++entry_desc, sizeof (acpi_operand_object));
-		DUMP_BUFFER (++entry_desc, sizeof (acpi_operand_object));
+		acpi_os_printf ("Unknown Type %X\n", ACPI_GET_OBJECT_TYPE (obj_desc));
 		break;
-
 	}
 
-	return (AE_OK);
+	return;
 }
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ex_dump_operands
+ * FUNCTION:    acpi_ex_dump_operands
  *
- * PARAMETERS:  Interpreter_mode     - Load or Exec
+ * PARAMETERS:  interpreter_mode     - Load or Exec
  *              *Ident              - Identification
- *              Num_levels          - # of stack entries to dump above line
+ *              num_levels          - # of stack entries to dump above line
  *              *Note               - Output notation
  *
  * DESCRIPTION: Dump the object stack
@@ -520,54 +402,45 @@
 
 void
 acpi_ex_dump_operands (
-	acpi_operand_object     **operands,
-	operating_mode          interpreter_mode,
-	NATIVE_CHAR             *ident,
-	u32                     num_levels,
-	NATIVE_CHAR             *note,
-	NATIVE_CHAR             *module_name,
-	u32                     line_number)
+	union acpi_operand_object       **operands,
+	acpi_interpreter_mode           interpreter_mode,
+	char                            *ident,
+	u32                             num_levels,
+	char                            *note,
+	char                            *module_name,
+	u32                             line_number)
 {
-	NATIVE_UINT             i;
-	acpi_operand_object     **entry_desc;
+	acpi_native_uint                i;
+	union acpi_operand_object       **obj_desc;
 
 
-	PROC_NAME ("Ex_dump_operands");
+	ACPI_FUNCTION_NAME ("ex_dump_operands");
 
 
-	if (!ident)
-	{
+	if (!ident) {
 		ident = "?";
 	}
 
-	if (!note)
-	{
+	if (!note) {
 		note = "?";
 	}
 
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
 		"************* Operand Stack Contents (Opcode [%s], %d Operands)\n",
 		ident, num_levels));
 
-	if (num_levels == 0)
-	{
+	if (num_levels == 0) {
 		num_levels = 1;
 	}
 
-	/* Dump the stack starting at the top, working down */
-
-	for (i = 0; num_levels > 0; i--, num_levels--)
-	{
-		entry_desc = &operands[i];
+	/* Dump the operand stack starting at the top */
 
-		if (ACPI_FAILURE (acpi_ex_dump_operand (*entry_desc)))
-		{
-			break;
-		}
+	for (i = 0; num_levels > 0; i--, num_levels--) {
+		obj_desc = &operands[i];
+		acpi_ex_dump_operand (*obj_desc);
 	}
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
 		"************* Stack dump from %s(%d), %s\n",
 		module_name, line_number, note));
 	return;
@@ -576,7 +449,59 @@
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ex_dump_node
+ * FUNCTION:    acpi_ex_out*
+ *
+ * PARAMETERS:  Title               - Descriptive text
+ *              Value               - Value to be displayed
+ *
+ * DESCRIPTION: Object dump output formatting functions.  These functions
+ *              reduce the number of format strings required and keeps them
+ *              all in one place for easy modification.
+ *
+ ****************************************************************************/
+
+void
+acpi_ex_out_string (
+	char                            *title,
+	char                            *value)
+{
+	acpi_os_printf ("%20s : %s\n", title, value);
+}
+
+void
+acpi_ex_out_pointer (
+	char                            *title,
+	void                            *value)
+{
+	acpi_os_printf ("%20s : %p\n", title, value);
+}
+
+void
+acpi_ex_out_integer (
+	char                            *title,
+	u32                             value)
+{
+	acpi_os_printf ("%20s : %X\n", title, value);
+}
+
+void
+acpi_ex_out_address (
+	char                            *title,
+	acpi_physical_address           value)
+{
+
+#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_HIDWORD (value), ACPI_LODWORD (value));
+#endif
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION:    acpi_ex_dump_node
  *
  * PARAMETERS:  *Node           - Descriptor to dump
  *              Flags               - Force display
@@ -587,37 +512,34 @@
 
 void
 acpi_ex_dump_node (
-	acpi_namespace_node     *node,
-	u32                     flags)
+	struct acpi_namespace_node      *node,
+	u32                             flags)
 {
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
-	if (!flags)
-	{
-		if (!((ACPI_LV_OBJECTS & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer)))
-		{
+	if (!flags) {
+		if (!((ACPI_LV_OBJECTS & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) {
 			return;
 		}
 	}
 
-
-	acpi_os_printf ("%20s : %4.4s\n", "Name",           (char*)&node->name);
-	acpi_os_printf ("%20s : %s\n",  "Type",             acpi_ut_get_type_name (node->type));
-	acpi_os_printf ("%20s : %X\n",  "Flags",            node->flags);
-	acpi_os_printf ("%20s : %X\n",  "Owner Id",         node->owner_id);
-	acpi_os_printf ("%20s : %X\n",  "Reference Count",  node->reference_count);
-	acpi_os_printf ("%20s : %p\n",  "Attached Object",  node->object);
-	acpi_os_printf ("%20s : %p\n",  "Child_list",       node->child);
-	acpi_os_printf ("%20s : %p\n",  "Next_peer",        node->peer);
-	acpi_os_printf ("%20s : %p\n",  "Parent",           acpi_ns_get_parent_object (node));
+	acpi_os_printf ("%20s : %4.4s\n",     "Name", node->name.ascii);
+	acpi_ex_out_string ("Type",           acpi_ut_get_type_name (node->type));
+	acpi_ex_out_integer ("Flags",         node->flags);
+	acpi_ex_out_integer ("Owner Id",      node->owner_id);
+	acpi_ex_out_integer ("Reference Count", node->reference_count);
+	acpi_ex_out_pointer ("Attached Object", acpi_ns_get_attached_object (node));
+	acpi_ex_out_pointer ("child_list",    node->child);
+	acpi_ex_out_pointer ("next_peer",     node->peer);
+	acpi_ex_out_pointer ("Parent",        acpi_ns_get_parent_node (node));
 }
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ex_dump_object_descriptor
+ * FUNCTION:    acpi_ex_dump_object_descriptor
  *
  * PARAMETERS:  *Object             - Descriptor to dump
  *              Flags               - Force display
@@ -628,253 +550,240 @@
 
 void
 acpi_ex_dump_object_descriptor (
-	acpi_operand_object     *obj_desc,
-	u32                     flags)
+	union acpi_operand_object       *obj_desc,
+	u32                             flags)
 {
-	const acpi_opcode_info  *op_info;
+	u32                             i;
 
 
-	FUNCTION_TRACE ("Ex_dump_object_descriptor");
+	ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor");
 
 
-	if (!flags)
-	{
-		if (!((ACPI_LV_OBJECTS & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer)))
-		{
-			return;
+	if (!flags) {
+		if (!((ACPI_LV_OBJECTS & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) {
+			return_VOID;
 		}
 	}
 
-	if (!(VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_INTERNAL)))
-	{
-		acpi_os_printf ("%p is not a valid ACPI object\n", obj_desc);
+	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;
 	}
 
+	if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) {
+		acpi_os_printf ("ex_dump_object_descriptor: %p is not a valid ACPI object\n", obj_desc);
+		return_VOID;
+	}
+
 	/* Common Fields */
 
-	acpi_os_printf ("%20s : %X\n", "Reference Count", obj_desc->common.reference_count);
-	acpi_os_printf ("%20s : %X\n", "Flags", obj_desc->common.flags);
+	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);
 
 	/* Object-specific Fields */
 
-	switch (obj_desc->common.type)
-	{
+	switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
 	case ACPI_TYPE_INTEGER:
 
-		acpi_os_printf ("%20s : %s\n", "Type", "Integer");
-		acpi_os_printf ("%20s : %X%8.8X\n", "Value", HIDWORD (obj_desc->integer.value),
-				  LODWORD (obj_desc->integer.value));
+		acpi_os_printf ("%20s : %8.8X%8.8X\n", "Value",
+				  ACPI_HIDWORD (obj_desc->integer.value),
+				  ACPI_LODWORD (obj_desc->integer.value));
 		break;
 
 
 	case ACPI_TYPE_STRING:
 
-		acpi_os_printf ("%20s : %s\n", "Type", "String");
-		acpi_os_printf ("%20s : %X\n", "Length", obj_desc->string.length);
-		acpi_os_printf ("%20s : %p\n", "Pointer", obj_desc->string.pointer);
+		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);
+		acpi_os_printf ("\n");
 		break;
 
 
 	case ACPI_TYPE_BUFFER:
 
-		acpi_os_printf ("%20s : %s\n", "Type", "Buffer");
-		acpi_os_printf ("%20s : %X\n", "Length", obj_desc->buffer.length);
-		acpi_os_printf ("%20s : %p\n", "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_os_printf ("%20s : %s\n", "Type", "Package");
-		acpi_os_printf ("%20s : %X\n", "Flags", obj_desc->package.flags);
-		acpi_os_printf ("%20s : %X\n", "Count", obj_desc->package.count);
-		acpi_os_printf ("%20s : %p\n", "Elements", obj_desc->package.elements);
-		acpi_os_printf ("%20s : %p\n", "Next_element", obj_desc->package.next_element);
-		break;
-
-
-	case ACPI_TYPE_BUFFER_FIELD:
-
-		acpi_os_printf ("%20s : %s\n", "Type", "Buffer_field");
-		acpi_os_printf ("%20s : %X\n", "Bit_length", obj_desc->buffer_field.bit_length);
-		acpi_os_printf ("%20s : %X\n", "Bit_offset", obj_desc->buffer_field.start_field_bit_offset);
-		acpi_os_printf ("%20s : %X\n", "Base_byte_offset",obj_desc->buffer_field.base_byte_offset);
-		acpi_os_printf ("%20s : %p\n", "Buffer_obj", obj_desc->buffer_field.buffer_obj);
+		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 */
+
+		if (obj_desc->package.count > 0) {
+			acpi_os_printf ("\nPackage Contents:\n");
+			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 ("\n");
+			}
+		}
 		break;
 
 
 	case ACPI_TYPE_DEVICE:
 
-		acpi_os_printf ("%20s : %s\n", "Type", "Device");
-		acpi_os_printf ("%20s : %p\n", "Addr_handler", obj_desc->device.addr_handler);
-		acpi_os_printf ("%20s : %p\n", "Sys_handler", obj_desc->device.sys_handler);
-		acpi_os_printf ("%20s : %p\n", "Drv_handler", obj_desc->device.drv_handler);
+		acpi_ex_out_pointer ("address_space", obj_desc->device.address_space);
+		acpi_ex_out_pointer ("system_notify", obj_desc->device.system_notify);
+		acpi_ex_out_pointer ("device_notify", obj_desc->device.device_notify);
 		break;
 
+
 	case ACPI_TYPE_EVENT:
 
-		acpi_os_printf ("%20s : %s\n", "Type", "Event");
-		acpi_os_printf ("%20s : %X\n", "Semaphore", obj_desc->event.semaphore);
+		acpi_ex_out_pointer ("Semaphore",    obj_desc->event.semaphore);
 		break;
 
 
 	case ACPI_TYPE_METHOD:
 
-		acpi_os_printf ("%20s : %s\n", "Type", "Method");
-		acpi_os_printf ("%20s : %X\n", "Param_count", obj_desc->method.param_count);
-		acpi_os_printf ("%20s : %X\n", "Concurrency", obj_desc->method.concurrency);
-		acpi_os_printf ("%20s : %p\n", "Semaphore", obj_desc->method.semaphore);
-		acpi_os_printf ("%20s : %X\n", "Aml_length", obj_desc->method.aml_length);
-		acpi_os_printf ("%20s : %X\n", "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_os_printf ("%20s : %s\n", "Type", "Mutex");
-		acpi_os_printf ("%20s : %X\n", "Sync_level", obj_desc->mutex.sync_level);
-		acpi_os_printf ("%20s : %p\n", "Owner", obj_desc->mutex.owner);
-		acpi_os_printf ("%20s : %X\n", "Acquisition_depth", obj_desc->mutex.acquisition_depth);
-		acpi_os_printf ("%20s : %p\n", "Semaphore", obj_desc->mutex.semaphore);
+		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);
 		break;
 
 
 	case ACPI_TYPE_REGION:
 
-		acpi_os_printf ("%20s : %s\n", "Type", "Region");
-		acpi_os_printf ("%20s : %X\n", "Space_id", obj_desc->region.space_id);
-		acpi_os_printf ("%20s : %X\n", "Flags", obj_desc->region.flags);
-		acpi_os_printf ("%20s : %X\n", "Address", obj_desc->region.address);
-		acpi_os_printf ("%20s : %X\n", "Length", obj_desc->region.length);
-		acpi_os_printf ("%20s : %p\n", "Addr_handler", obj_desc->region.addr_handler);
-		acpi_os_printf ("%20s : %p\n", "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 ("address_space", obj_desc->region.address_space);
+		acpi_ex_out_pointer ("Next",         obj_desc->region.next);
 		break;
 
 
 	case ACPI_TYPE_POWER:
 
-		acpi_os_printf ("%20s : %s\n", "Type", "Power_resource");
-		acpi_os_printf ("%20s : %X\n", "System_level", obj_desc->power_resource.system_level);
-		acpi_os_printf ("%20s : %X\n", "Resource_order", obj_desc->power_resource.resource_order);
-		acpi_os_printf ("%20s : %p\n", "Sys_handler", obj_desc->power_resource.sys_handler);
-		acpi_os_printf ("%20s : %p\n", "Drv_handler", obj_desc->power_resource.drv_handler);
+		acpi_ex_out_integer ("system_level", obj_desc->power_resource.system_level);
+		acpi_ex_out_integer ("resource_order", obj_desc->power_resource.resource_order);
+		acpi_ex_out_pointer ("system_notify", obj_desc->power_resource.system_notify);
+		acpi_ex_out_pointer ("device_notify", obj_desc->power_resource.device_notify);
 		break;
 
 
 	case ACPI_TYPE_PROCESSOR:
 
-		acpi_os_printf ("%20s : %s\n", "Type", "Processor");
-		acpi_os_printf ("%20s : %X\n", "Processor ID", obj_desc->processor.proc_id);
-		acpi_os_printf ("%20s : %X\n", "Length", obj_desc->processor.length);
-		acpi_os_printf ("%20s : %X\n", "Address", obj_desc->processor.address);
-		acpi_os_printf ("%20s : %p\n", "Sys_handler", obj_desc->processor.sys_handler);
-		acpi_os_printf ("%20s : %p\n", "Drv_handler", obj_desc->processor.drv_handler);
-		acpi_os_printf ("%20s : %p\n", "Addr_handler", obj_desc->processor.addr_handler);
+		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_pointer ("system_notify", obj_desc->processor.system_notify);
+		acpi_ex_out_pointer ("device_notify", obj_desc->processor.device_notify);
+		acpi_ex_out_pointer ("address_space", obj_desc->processor.address_space);
 		break;
 
 
 	case ACPI_TYPE_THERMAL:
 
-		acpi_os_printf ("%20s : %s\n", "Type", "Thermal_zone");
-		acpi_os_printf ("%20s : %p\n", "Sys_handler", obj_desc->thermal_zone.sys_handler);
-		acpi_os_printf ("%20s : %p\n", "Drv_handler", obj_desc->thermal_zone.drv_handler);
-		acpi_os_printf ("%20s : %p\n", "Addr_handler", obj_desc->thermal_zone.addr_handler);
+		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 ("address_space", obj_desc->thermal_zone.address_space);
 		break;
 
 
-	case INTERNAL_TYPE_REGION_FIELD:
-
-		acpi_os_printf ("%20s : %p\n", "Access_bit_width", obj_desc->field.access_bit_width);
-		acpi_os_printf ("%20s : %p\n", "Bit_length", obj_desc->field.bit_length);
-		acpi_os_printf ("%20s : %p\n", "Base_byte_offset",obj_desc->field.base_byte_offset);
-		acpi_os_printf ("%20s : %p\n", "Bit_offset", obj_desc->field.start_field_bit_offset);
-		acpi_os_printf ("%20s : %p\n", "Region_obj", obj_desc->field.region_obj);
-		break;
-
-
-	case INTERNAL_TYPE_BANK_FIELD:
-
-		acpi_os_printf ("%20s : %s\n", "Type", "Bank_field");
-		acpi_os_printf ("%20s : %X\n", "Access_bit_width", obj_desc->bank_field.access_bit_width);
-		acpi_os_printf ("%20s : %X\n", "Lock_rule", obj_desc->bank_field.lock_rule);
-		acpi_os_printf ("%20s : %X\n", "Update_rule", obj_desc->bank_field.update_rule);
-		acpi_os_printf ("%20s : %X\n", "Bit_length", obj_desc->bank_field.bit_length);
-		acpi_os_printf ("%20s : %X\n", "Bit_offset", obj_desc->bank_field.start_field_bit_offset);
-		acpi_os_printf ("%20s : %X\n", "Base_byte_offset", obj_desc->bank_field.base_byte_offset);
-		acpi_os_printf ("%20s : %X\n", "Value", obj_desc->bank_field.value);
-		acpi_os_printf ("%20s : %p\n", "Region_obj", obj_desc->bank_field.region_obj);
-		acpi_os_printf ("%20s : %X\n", "Bank_register_obj", obj_desc->bank_field.bank_register_obj);
-		break;
-
-
-	case INTERNAL_TYPE_INDEX_FIELD:
-
-		acpi_os_printf ("%20s : %s\n", "Type", "Index_field");
-		acpi_os_printf ("%20s : %X\n", "Access_bit_width", obj_desc->index_field.access_bit_width);
-		acpi_os_printf ("%20s : %X\n", "Lock_rule", obj_desc->index_field.lock_rule);
-		acpi_os_printf ("%20s : %X\n", "Update_rule", obj_desc->index_field.update_rule);
-		acpi_os_printf ("%20s : %X\n", "Bit_length", obj_desc->index_field.bit_length);
-		acpi_os_printf ("%20s : %X\n", "Bit_offset", obj_desc->index_field.start_field_bit_offset);
-		acpi_os_printf ("%20s : %X\n", "Value", obj_desc->index_field.value);
-		acpi_os_printf ("%20s : %X\n", "Index", obj_desc->index_field.index_obj);
-		acpi_os_printf ("%20s : %X\n", "Data", obj_desc->index_field.data_obj);
-		break;
-
-
-	case INTERNAL_TYPE_REFERENCE:
-
-		op_info = acpi_ps_get_opcode_info (obj_desc->reference.opcode);
+	case ACPI_TYPE_BUFFER_FIELD:
+	case ACPI_TYPE_LOCAL_REGION_FIELD:
+	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 ("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);
+
+		switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
+		case ACPI_TYPE_BUFFER_FIELD:
+			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);
+			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);
+			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);
+			break;
 
-		acpi_os_printf ("%20s : %s\n", "Type", "Reference");
-		acpi_os_printf ("%20s : %X\n", "Target_type", obj_desc->reference.target_type);
-		acpi_os_printf ("%20s : %s\n", "Opcode", op_info->name);
-		acpi_os_printf ("%20s : %X\n", "Offset", obj_desc->reference.offset);
-		acpi_os_printf ("%20s : %p\n", "Obj_desc", obj_desc->reference.object);
-		acpi_os_printf ("%20s : %p\n", "Node", obj_desc->reference.node);
-		acpi_os_printf ("%20s : %p\n", "Where", obj_desc->reference.where);
+		default:
+			/* All object types covered above */
+			break;
+		}
 		break;
 
 
-	case INTERNAL_TYPE_ADDRESS_HANDLER:
+	case ACPI_TYPE_LOCAL_REFERENCE:
 
-		acpi_os_printf ("%20s : %s\n", "Type", "Address Handler");
-		acpi_os_printf ("%20s : %X\n", "Space_id", obj_desc->addr_handler.space_id);
-		acpi_os_printf ("%20s : %p\n", "Next", obj_desc->addr_handler.next);
-		acpi_os_printf ("%20s : %p\n", "Region_list", obj_desc->addr_handler.region_list);
-		acpi_os_printf ("%20s : %p\n", "Node", obj_desc->addr_handler.node);
-		acpi_os_printf ("%20s : %p\n", "Handler", obj_desc->addr_handler.handler);
-		acpi_os_printf ("%20s : %p\n", "Context", obj_desc->addr_handler.context);
+		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 INTERNAL_TYPE_NOTIFY:
+	case ACPI_TYPE_LOCAL_ADDRESS_HANDLER:
 
-		acpi_os_printf ("%20s : %s\n", "Type", "Notify Handler");
-		acpi_os_printf ("%20s : %p\n", "Node", obj_desc->notify_handler.node);
-		acpi_os_printf ("%20s : %p\n", "Handler", obj_desc->notify_handler.handler);
-		acpi_os_printf ("%20s : %p\n", "Context", obj_desc->notify_handler.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 INTERNAL_TYPE_ALIAS:
-	case INTERNAL_TYPE_FIELD_DEFN:
-	case INTERNAL_TYPE_BANK_FIELD_DEFN:
-	case INTERNAL_TYPE_INDEX_FIELD_DEFN:
-	case INTERNAL_TYPE_IF:
-	case INTERNAL_TYPE_ELSE:
-	case INTERNAL_TYPE_WHILE:
-	case INTERNAL_TYPE_SCOPE:
-	case INTERNAL_TYPE_DEF_ANY:
+	case ACPI_TYPE_LOCAL_NOTIFY:
 
-		acpi_os_printf ("*** Structure display not implemented for type %X! ***\n",
-			obj_desc->common.type);
+		acpi_ex_out_pointer ("Node",         obj_desc->notify.node);
+		acpi_ex_out_pointer ("Context",      obj_desc->notify.context);
 		break;
 
 
+	case ACPI_TYPE_LOCAL_ALIAS:
+	case ACPI_TYPE_LOCAL_EXTRA:
+	case ACPI_TYPE_LOCAL_DATA:
 	default:
 
-		acpi_os_printf ("*** Cannot display unknown type %X! ***\n", obj_desc->common.type);
+		acpi_os_printf ("ex_dump_object_descriptor: Display not implemented for object type %s\n",
+			acpi_ut_get_object_type_name (obj_desc));
 		break;
 	}
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exfield.c linux-2.4.22-pre2/drivers/acpi/executer/exfield.c
--- linux-2.4.21/drivers/acpi/executer/exfield.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exfield.c	2003-06-26 21:43:11.000000000 +0000
@@ -1,69 +1,85 @@
 /******************************************************************************
  *
  * Module Name: exfield - ACPI AML (p-code) execution - field manipulation
- *              $Revision: 95 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acdispat.h"
-#include "acinterp.h"
-#include "amlcode.h"
-#include "acnamesp.h"
-#include "achware.h"
-#include "acevents.h"
+#include <acpi/acpi.h>
+#include <acpi/acdispat.h>
+#include <acpi/acinterp.h>
 
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exfield")
+	 ACPI_MODULE_NAME    ("exfield")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_read_data_from_field
+ * FUNCTION:    acpi_ex_read_data_from_field
  *
- * PARAMETERS:  Mode                - ACPI_READ or ACPI_WRITE
- *              *Field_node         - Parent node for field to be accessed
- *              *Buffer             - Value(s) to be read or written
- *              Buffer_length       - Number of bytes to transfer
+ * PARAMETERS:  walk_state          - Current execution state
+ *              obj_desc            - The named field
+ *              ret_buffer_desc     - Where the return data object is stored
  *
- * RETURN:      Status3
+ * RETURN:      Status
  *
- * DESCRIPTION: Read or write a named field
+ * DESCRIPTION: Read from a named field.  Returns either an Integer or a
+ *              Buffer, depending on the size of the field.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ex_read_data_from_field (
-	acpi_operand_object     *obj_desc,
-	acpi_operand_object     **ret_buffer_desc)
+	struct acpi_walk_state          *walk_state,
+	union acpi_operand_object       *obj_desc,
+	union acpi_operand_object       **ret_buffer_desc)
 {
-	acpi_status             status;
-	acpi_operand_object     *buffer_desc;
-	u32                     length;
-	void                    *buffer;
+	acpi_status                     status;
+	union acpi_operand_object       *buffer_desc;
+	acpi_size                       length;
+	void                            *buffer;
+	u8                              locked;
 
 
-	FUNCTION_TRACE_PTR ("Ex_read_data_from_field", obj_desc);
+	ACPI_FUNCTION_TRACE_PTR ("ex_read_data_from_field", obj_desc);
 
 
 	/* Parameter validation */
@@ -72,6 +88,44 @@
 		return_ACPI_STATUS (AE_AML_NO_OPERAND);
 	}
 
+	if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_BUFFER_FIELD) {
+		/*
+		 * If the buffer_field arguments have not been previously evaluated,
+		 * evaluate them now and save the results.
+		 */
+		if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
+			status = acpi_ds_get_buffer_field_arguments (obj_desc);
+			if (ACPI_FAILURE (status)) {
+				return_ACPI_STATUS (status);
+			}
+		}
+	}
+	else if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_REGION_FIELD) &&
+			 (obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_SMBUS)) {
+		/*
+		 * This is an SMBus read.  We must create a buffer to hold the data
+		 * and directly access the region handler.
+		 */
+		buffer_desc = acpi_ut_create_buffer_object (ACPI_SMBUS_BUFFER_SIZE);
+		if (!buffer_desc) {
+			return_ACPI_STATUS (AE_NO_MEMORY);
+		}
+
+		/* Lock entire transaction if requested */
+
+		locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags);
+
+		/*
+		 * Perform the read.
+		 * Note: Smbus protocol value is passed in upper 16-bits of Function
+		 */
+		status = acpi_ex_access_region (obj_desc, 0,
+				  ACPI_CAST_PTR (acpi_integer, buffer_desc->buffer.pointer),
+				  ACPI_READ | (obj_desc->field.attribute << 16));
+		acpi_ex_release_global_lock (locked);
+		goto exit;
+	}
+
 	/*
 	 * Allocate a buffer for the contents of the field.
 	 *
@@ -82,28 +136,16 @@
 	 *
 	 * Note: Field.length is in bits.
 	 */
-	length = ROUND_BITS_UP_TO_BYTES (obj_desc->field.bit_length);
-
-	if (length > sizeof (acpi_integer)) {
+	length = (acpi_size) ACPI_ROUND_BITS_UP_TO_BYTES (obj_desc->field.bit_length);
+	if (length > acpi_gbl_integer_byte_width) {
 		/* Field is too large for an Integer, create a Buffer instead */
 
-		buffer_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER);
+		buffer_desc = acpi_ut_create_buffer_object (length);
 		if (!buffer_desc) {
 			return_ACPI_STATUS (AE_NO_MEMORY);
 		}
-
-		/* Create the actual read buffer */
-
-		buffer_desc->buffer.pointer = ACPI_MEM_CALLOCATE (length);
-		if (!buffer_desc->buffer.pointer) {
-			acpi_ut_remove_reference (buffer_desc);
-			return_ACPI_STATUS (AE_NO_MEMORY);
-		}
-
-		buffer_desc->buffer.length = length;
 		buffer = buffer_desc->buffer.pointer;
 	}
-
 	else {
 		/* Field will fit within an Integer (normal case) */
 
@@ -112,39 +154,34 @@
 			return_ACPI_STATUS (AE_NO_MEMORY);
 		}
 
-		length = sizeof (buffer_desc->integer.value);
+		length = acpi_gbl_integer_byte_width;
+		buffer_desc->integer.value = 0;
 		buffer = &buffer_desc->integer.value;
 	}
 
+	ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+		"Obj=%p Type=%X Buf=%p Len=%X\n",
+		obj_desc, ACPI_GET_OBJECT_TYPE (obj_desc), buffer, (u32) length));
+	ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+		"field_write: bit_len=%X bit_off=%X byte_off=%X\n",
+		obj_desc->common_field.bit_length,
+		obj_desc->common_field.start_field_bit_offset,
+		obj_desc->common_field.base_byte_offset));
 
-	/* Read from the appropriate field */
-
-	switch (obj_desc->common.type) {
-	case ACPI_TYPE_BUFFER_FIELD:
-		status = acpi_ex_access_buffer_field (ACPI_READ, obj_desc, buffer, length);
-		break;
-
-	case INTERNAL_TYPE_REGION_FIELD:
-		status = acpi_ex_access_region_field (ACPI_READ, obj_desc, buffer, length);
-		break;
+	/* Lock entire transaction if requested */
 
-	case INTERNAL_TYPE_BANK_FIELD:
-		status = acpi_ex_access_bank_field (ACPI_READ, obj_desc, buffer, length);
-		break;
+	locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags);
 
-	case INTERNAL_TYPE_INDEX_FIELD:
-		status = acpi_ex_access_index_field (ACPI_READ, obj_desc, buffer, length);
-		break;
+	/* Read from the field */
 
-	default:
-		status = AE_AML_INTERNAL;
-	}
+	status = acpi_ex_extract_from_field (obj_desc, buffer, (u32) length);
+	acpi_ex_release_global_lock (locked);
 
 
+exit:
 	if (ACPI_FAILURE (status)) {
 		acpi_ut_remove_reference (buffer_desc);
 	}
-
 	else if (ret_buffer_desc) {
 		*ret_buffer_desc = buffer_desc;
 	}
@@ -155,31 +192,33 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_write_data_to_field
+ * FUNCTION:    acpi_ex_write_data_to_field
  *
- * PARAMETERS:  Mode                - ACPI_READ or ACPI_WRITE
- *              *Field_node         - Parent node for field to be accessed
- *              *Buffer             - Value(s) to be read or written
- *              Buffer_length       - Number of bytes to transfer
+ * PARAMETERS:  source_desc         - Contains data to write
+ *              obj_desc            - The named field
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Read or write a named field
+ * DESCRIPTION: Write to a named field
  *
  ******************************************************************************/
 
-
 acpi_status
 acpi_ex_write_data_to_field (
-	acpi_operand_object     *source_desc,
-	acpi_operand_object     *obj_desc)
+	union acpi_operand_object       *source_desc,
+	union acpi_operand_object       *obj_desc,
+	union acpi_operand_object       **result_desc)
 {
-	acpi_status             status;
-	u32                     length;
-	void                    *buffer;
+	acpi_status                     status;
+	u32                             length;
+	u32                             required_length;
+	void                            *buffer;
+	void                            *new_buffer;
+	u8                              locked;
+	union acpi_operand_object       *buffer_desc;
 
 
-	FUNCTION_TRACE_PTR ("Ex_write_data_to_field", obj_desc);
+	ACPI_FUNCTION_TRACE_PTR ("ex_write_data_to_field", obj_desc);
 
 
 	/* Parameter validation */
@@ -188,11 +227,67 @@
 		return_ACPI_STATUS (AE_AML_NO_OPERAND);
 	}
 
+	if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_BUFFER_FIELD) {
+		/*
+		 * If the buffer_field arguments have not been previously evaluated,
+		 * evaluate them now and save the results.
+		 */
+		if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
+			status = acpi_ds_get_buffer_field_arguments (obj_desc);
+			if (ACPI_FAILURE (status)) {
+				return_ACPI_STATUS (status);
+			}
+		}
+	}
+	else if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_REGION_FIELD) &&
+			 (obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_SMBUS)) {
+		/*
+		 * This is an SMBus write.  We will bypass the entire field mechanism
+		 * and handoff the buffer directly to the handler.
+		 *
+		 * Source must be a buffer of sufficient size (ACPI_SMBUS_BUFFER_SIZE).
+		 */
+		if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_BUFFER) {
+			ACPI_REPORT_ERROR (("SMBus write requires Buffer, found type %s\n",
+				acpi_ut_get_object_type_name (source_desc)));
+			return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+		}
+
+		if (source_desc->buffer.length < ACPI_SMBUS_BUFFER_SIZE) {
+			ACPI_REPORT_ERROR (("SMBus write requires Buffer of length %X, found length %X\n",
+				ACPI_SMBUS_BUFFER_SIZE, source_desc->buffer.length));
+			return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
+		}
+
+		buffer_desc = acpi_ut_create_buffer_object (ACPI_SMBUS_BUFFER_SIZE);
+		if (!buffer_desc) {
+			return_ACPI_STATUS (AE_NO_MEMORY);
+		}
+
+		buffer = buffer_desc->buffer.pointer;
+		ACPI_MEMCPY (buffer, source_desc->buffer.pointer, ACPI_SMBUS_BUFFER_SIZE);
+
+		/* Lock entire transaction if requested */
+
+		locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags);
+
+		/*
+		 * Perform the write (returns status and perhaps data in the same buffer)
+		 * Note: SMBus protocol type is passed in upper 16-bits of Function.
+		 */
+		status = acpi_ex_access_region (obj_desc, 0,
+				  (acpi_integer *) buffer,
+				  ACPI_WRITE | (obj_desc->field.attribute << 16));
+		acpi_ex_release_global_lock (locked);
+
+		*result_desc = buffer_desc;
+		return_ACPI_STATUS (status);
+	}
 
 	/*
 	 * Get a pointer to the data to be written
 	 */
-	switch (source_desc->common.type) {
+	switch (ACPI_GET_OBJECT_TYPE (source_desc)) {
 	case ACPI_TYPE_INTEGER:
 		buffer = &source_desc->integer.value;
 		length = sizeof (source_desc->integer.value);
@@ -212,315 +307,58 @@
 		return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 	}
 
-
 	/*
-	 * Decode the type of field to be written
+	 * We must have a buffer that is at least as long as the field
+	 * we are writing to.  This is because individual fields are
+	 * indivisible and partial writes are not supported -- as per
+	 * the ACPI specification.
 	 */
-	switch (obj_desc->common.type) {
-	case ACPI_TYPE_BUFFER_FIELD:
-		status = acpi_ex_access_buffer_field (ACPI_WRITE, obj_desc, buffer, length);
-		break;
-
-	case INTERNAL_TYPE_REGION_FIELD:
-		status = acpi_ex_access_region_field (ACPI_WRITE, obj_desc, buffer, length);
-		break;
-
-	case INTERNAL_TYPE_BANK_FIELD:
-		status = acpi_ex_access_bank_field (ACPI_WRITE, obj_desc, buffer, length);
-		break;
-
-	case INTERNAL_TYPE_INDEX_FIELD:
-		status = acpi_ex_access_index_field (ACPI_WRITE, obj_desc, buffer, length);
-		break;
-
-	default:
-		return_ACPI_STATUS (AE_AML_INTERNAL);
-	}
-
-
-	return_ACPI_STATUS (status);
-}
+	new_buffer = NULL;
+	required_length = ACPI_ROUND_BITS_UP_TO_BYTES (obj_desc->common_field.bit_length);
 
+	if (length < required_length) {
+		/* We need to create a new buffer */
 
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ex_access_buffer_field
- *
- * PARAMETERS:  Mode                - ACPI_READ or ACPI_WRITE
- *              *Field_node         - Parent node for field to be accessed
- *              *Buffer             - Value(s) to be read or written
- *              Buffer_length       - Number of bytes to transfer
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Read or write a named field
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ex_access_buffer_field (
-	u32                     mode,
-	acpi_operand_object     *obj_desc,
-	void                    *buffer,
-	u32                     buffer_length)
-{
-	acpi_status             status;
-
-
-	FUNCTION_TRACE_PTR ("Ex_access_buffer_field", obj_desc);
-
-
-	/*
-	 * If the Buffer_field arguments have not been previously evaluated,
-	 * evaluate them now and save the results.
-	 */
-	if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
-		status = acpi_ds_get_buffer_field_arguments (obj_desc);
-		if (ACPI_FAILURE (status)) {
-			return_ACPI_STATUS (status);
+		new_buffer = ACPI_MEM_CALLOCATE (required_length);
+		if (!new_buffer) {
+			return_ACPI_STATUS (AE_NO_MEMORY);
 		}
-	}
-
-
-	status = acpi_ex_common_access_field (mode, obj_desc, buffer, buffer_length);
-
-	return_ACPI_STATUS (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ex_access_region_field
- *
- * PARAMETERS:  Mode                - ACPI_READ or ACPI_WRITE
- *              *Field_node         - Parent node for field to be accessed
- *              *Buffer             - Value(s) to be read or written
- *              Buffer_length       - Number of bytes to transfer
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Read or write a named field
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ex_access_region_field (
-	u32                     mode,
-	acpi_operand_object     *obj_desc,
-	void                    *buffer,
-	u32                     buffer_length)
-{
-	acpi_status             status;
-	u8                      locked;
-
-
-	FUNCTION_TRACE_PTR ("Ex_access_region_field", obj_desc);
-
-
-	/*
-	 * Get the global lock if needed
-	 */
-	locked = acpi_ex_acquire_global_lock (obj_desc->field.lock_rule);
-
-	status = acpi_ex_common_access_field (mode, obj_desc, buffer, buffer_length);
 
-
-	/*
-	 * Release global lock if we acquired it earlier
-	 */
-	acpi_ex_release_global_lock (locked);
-
-	return_ACPI_STATUS (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ex_access_bank_field
- *
- * PARAMETERS:  Mode                - ACPI_READ or ACPI_WRITE
- *              *Field_node         - Parent node for field to be accessed
- *              *Buffer             - Value(s) to be read or written
- *              Buffer_length       - Number of bytes to transfer
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Read or write a Bank Field
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ex_access_bank_field (
-	u32                     mode,
-	acpi_operand_object     *obj_desc,
-	void                    *buffer,
-	u32                     buffer_length)
-{
-	acpi_status             status;
-	u8                      locked;
-
-
-	FUNCTION_TRACE_PTR ("Ex_access_bank_field", obj_desc);
-
-
-	/*
-	 * Get the global lock if needed
-	 */
-	locked = acpi_ex_acquire_global_lock (obj_desc->bank_field.lock_rule);
-
-
-	/*
-	 * Write the Bank_value to the Bank_register to select the bank.
-	 * The Bank_value for this Bank_field is specified in the
-	 * Bank_field ASL declaration. The Bank_register is always a Field in
-	 * an operation region.
-	 */
-	status = acpi_ex_common_access_field (ACPI_WRITE,
-			 obj_desc->bank_field.bank_register_obj,
-			 &obj_desc->bank_field.value,
-			 sizeof (obj_desc->bank_field.value));
-	if (ACPI_FAILURE (status)) {
-		goto cleanup;
-	}
-
-	/*
-	 * The bank was successfully selected, now read or write the actual
-	 * data.
-	 */
-	status = acpi_ex_common_access_field (mode, obj_desc, buffer, buffer_length);
-
-
-cleanup:
-	/*
-	 * Release global lock if we acquired it earlier
-	 */
-	acpi_ex_release_global_lock (locked);
-
-	return_ACPI_STATUS (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ex_access_index_field
- *
- * PARAMETERS:  Mode                - ACPI_READ or ACPI_WRITE
- *              *Field_node         - Parent node for field to be accessed
- *              *Buffer             - Value(s) to be read or written
- *              Buffer_length       - Number of bytes to transfer
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Read or write a Index Field
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ex_access_index_field (
-	u32                     mode,
-	acpi_operand_object     *obj_desc,
-	void                    *buffer,
-	u32                     buffer_length)
-{
-	acpi_status             status;
-	u8                      locked;
-
-
-	FUNCTION_TRACE_PTR ("Ex_access_index_field", obj_desc);
-
-
-	/*
-	 * Get the global lock if needed
-	 */
-	locked = acpi_ex_acquire_global_lock (obj_desc->index_field.lock_rule);
-
-
-	/*
-	 * Set Index value to select proper Data register
-	 */
-	status = acpi_ex_common_access_field (ACPI_WRITE,
-			 obj_desc->index_field.index_obj,
-			 &obj_desc->index_field.value,
-			 sizeof (obj_desc->index_field.value));
-	if (ACPI_FAILURE (status)) {
-		goto cleanup;
-	}
-
-	/* Now read/write the data register */
-
-	status = acpi_ex_common_access_field (mode, obj_desc->index_field.data_obj,
-			  buffer, buffer_length);
-
-cleanup:
-	/*
-	 * Release global lock if we acquired it earlier
-	 */
-	acpi_ex_release_global_lock (locked);
-
-	return_ACPI_STATUS (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ex_common_access_field
- *
- * PARAMETERS:  Mode                - ACPI_READ or ACPI_WRITE
- *              *Field_node         - Parent node for field to be accessed
- *              *Buffer             - Value(s) to be read or written
- *              Buffer_length       - Size of buffer, in bytes.  Must be large
- *                                    enough for all bits of the field.
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Read or write a named field
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ex_common_access_field (
-	u32                     mode,
-	acpi_operand_object     *obj_desc,
-	void                    *buffer,
-	u32                     buffer_length)
-{
-	acpi_status             status;
-
-
-	FUNCTION_TRACE_PTR ("Ex_common_access_field", obj_desc);
-
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Obj=%p Type=%X Buf=%p Len=%X\n",
-		obj_desc, obj_desc->common.type, buffer, buffer_length));
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode=%d Bit_len=%X Bit_off=%X Byte_off=%X\n",
-		mode, obj_desc->common_field.bit_length,
+		/*
+		 * Copy the original data to the new buffer, starting
+		 * at Byte zero.  All unused (upper) bytes of the
+		 * buffer will be 0.
+		 */
+		ACPI_MEMCPY ((char *) new_buffer, (char *) buffer, length);
+		buffer = new_buffer;
+		length = required_length;
+	}
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+		"Obj=%p Type=%X Buf=%p Len=%X\n",
+		obj_desc, ACPI_GET_OBJECT_TYPE (obj_desc), buffer, length));
+	ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+		"field_read: bit_len=%X bit_off=%X byte_off=%X\n",
+		obj_desc->common_field.bit_length,
 		obj_desc->common_field.start_field_bit_offset,
 		obj_desc->common_field.base_byte_offset));
 
+	/* Lock entire transaction if requested */
 
-	/* Perform the actual read or write of the field */
+	locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags);
 
-	switch (mode) {
-	case ACPI_READ:
-
-		status = acpi_ex_extract_from_field (obj_desc, buffer, buffer_length);
-		break;
-
-
-	case ACPI_WRITE:
-
-		status = acpi_ex_insert_into_field (obj_desc, buffer, buffer_length);
-		break;
+	/* Write to the field */
 
+	status = acpi_ex_insert_into_field (obj_desc, buffer, length);
+	acpi_ex_release_global_lock (locked);
 
-	default:
+	/* Free temporary buffer if we used one */
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown I/O Mode: %X\n", mode));
-		status = AE_BAD_PARAMETER;
-		break;
+	if (new_buffer) {
+		ACPI_MEM_FREE (new_buffer);
 	}
 
-
 	return_ACPI_STATUS (status);
 }
 
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exfldio.c linux-2.4.22-pre2/drivers/acpi/executer/exfldio.c
--- linux-2.4.21/drivers/acpi/executer/exfldio.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exfldio.c	2003-06-26 21:43:16.000000000 +0000
@@ -1,73 +1,94 @@
 /******************************************************************************
  *
  * Module Name: exfldio - Aml Field I/O
- *              $Revision: 66 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acinterp.h"
-#include "amlcode.h"
-#include "acnamesp.h"
-#include "achware.h"
-#include "acevents.h"
-#include "acdispat.h"
+#include <acpi/acpi.h>
+#include <acpi/acinterp.h>
+#include <acpi/amlcode.h>
+#include <acpi/acevents.h>
+#include <acpi/acdispat.h>
 
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exfldio")
+	 ACPI_MODULE_NAME    ("exfldio")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_setup_field
+ * FUNCTION:    acpi_ex_setup_region
  *
- * PARAMETERS:  *Obj_desc           - Field to be read or written
- *              Field_datum_byte_offset  - Current offset into the field
+ * PARAMETERS:  *obj_desc               - Field to be read or written
+ *              field_datum_byte_offset - Byte offset of this datum within the
+ *                                        parent field
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Common processing for Acpi_ex_extract_from_field and
- *              Acpi_ex_insert_into_field
+ * DESCRIPTION: Common processing for acpi_ex_extract_from_field and
+ *              acpi_ex_insert_into_field. Initialize the
  *
  ******************************************************************************/
 
 acpi_status
-acpi_ex_setup_field (
-	acpi_operand_object     *obj_desc,
-	u32                     field_datum_byte_offset)
+acpi_ex_setup_region (
+	union acpi_operand_object       *obj_desc,
+	u32                             field_datum_byte_offset)
 {
-	acpi_status             status = AE_OK;
-	acpi_operand_object     *rgn_desc;
+	acpi_status                     status = AE_OK;
+	union acpi_operand_object       *rgn_desc;
 
 
-	FUNCTION_TRACE_U32 ("Ex_setup_field", field_datum_byte_offset);
+	ACPI_FUNCTION_TRACE_U32 ("ex_setup_region", field_datum_byte_offset);
 
 
 	rgn_desc = obj_desc->common_field.region_obj;
 
-	if (ACPI_TYPE_REGION != rgn_desc->common.type) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Needed Region, found type %x %s\n",
-			rgn_desc->common.type, acpi_ut_get_type_name (rgn_desc->common.type)));
+	/* We must have a valid region */
+
+	if (ACPI_GET_OBJECT_TYPE (rgn_desc) != ACPI_TYPE_REGION) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Needed Region, found type %X (%s)\n",
+			ACPI_GET_OBJECT_TYPE (rgn_desc),
+			acpi_ut_get_object_type_name (rgn_desc)));
+
 		return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 	}
 
@@ -76,30 +97,36 @@
 	 * evaluate them now and save the results.
 	 */
 	if (!(rgn_desc->region.flags & AOPOBJ_DATA_VALID)) {
-
 		status = acpi_ds_get_region_arguments (rgn_desc);
 		if (ACPI_FAILURE (status)) {
 			return_ACPI_STATUS (status);
 		}
 	}
 
+	if (rgn_desc->region.space_id == ACPI_ADR_SPACE_SMBUS) {
+		/* SMBus has a non-linear address space */
+
+		return_ACPI_STATUS (AE_OK);
+	}
+
 	/*
 	 * Validate the request.  The entire request from the byte offset for a
 	 * length of one field datum (access width) must fit within the region.
 	 * (Region length is specified in bytes)
 	 */
-	if (rgn_desc->region.length < (obj_desc->common_field.base_byte_offset +
-			   field_datum_byte_offset +
-			   obj_desc->common_field.access_byte_width)) {
+	if (rgn_desc->region.length < (obj_desc->common_field.base_byte_offset
+			   + field_datum_byte_offset
+			   + obj_desc->common_field.access_byte_width)) {
 		if (rgn_desc->region.length < obj_desc->common_field.access_byte_width) {
 			/*
-			 * This is the case where the Access_type (Acc_word, etc.) is wider
+			 * This is the case where the access_type (acc_word, etc.) is wider
 			 * than the region itself.  For example, a region of length one
 			 * byte, and a field with Dword access specified.
 			 */
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-				"Field access width (%d bytes) too large for region size (%X)\n",
-				obj_desc->common_field.access_byte_width, rgn_desc->region.length));
+				"Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)\n",
+				obj_desc->common_field.node->name.ascii, obj_desc->common_field.access_byte_width,
+				rgn_desc->region.node->name.ascii, rgn_desc->region.length));
 		}
 
 		/*
@@ -107,10 +134,10 @@
 		 * exceeds region length, indicate an error
 		 */
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-			"Field base+offset+width %X+%X+%X exceeds region size (%X bytes) field=%p region=%p\n",
-			obj_desc->common_field.base_byte_offset, field_datum_byte_offset,
-			obj_desc->common_field.access_byte_width,
-			rgn_desc->region.length, obj_desc, rgn_desc));
+			"Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)\n",
+			obj_desc->common_field.node->name.ascii, obj_desc->common_field.base_byte_offset,
+			field_datum_byte_offset, obj_desc->common_field.access_byte_width,
+			rgn_desc->region.node->name.ascii, rgn_desc->region.length));
 
 		return_ACPI_STATUS (AE_AML_REGION_LIMIT);
 	}
@@ -121,116 +148,415 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_read_field_datum
+ * FUNCTION:    acpi_ex_access_region
  *
- * PARAMETERS:  *Obj_desc           - Field to be read
- *              *Value              - Where to store value (must be 32 bits)
+ * PARAMETERS:  *obj_desc               - Field to be read
+ *              field_datum_byte_offset - Byte offset of this datum within the
+ *                                        parent field
+ *              *Value                  - Where to store value (must at least
+ *                                        the size of acpi_integer)
+ *              Function                - Read or Write flag plus other region-
+ *                                        dependent flags
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Retrieve the value of the given field
+ * DESCRIPTION: Read or Write a single field datum to an Operation Region.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_ex_read_field_datum (
-	acpi_operand_object     *obj_desc,
-	u32                     field_datum_byte_offset,
-	u32                     *value)
+acpi_ex_access_region (
+	union acpi_operand_object       *obj_desc,
+	u32                             field_datum_byte_offset,
+	acpi_integer                    *value,
+	u32                             function)
 {
-	acpi_status             status;
-	acpi_operand_object     *rgn_desc;
-	ACPI_PHYSICAL_ADDRESS   address;
-	u32                     local_value;
+	acpi_status                     status;
+	union acpi_operand_object       *rgn_desc;
+	acpi_physical_address           address;
+
+
+	ACPI_FUNCTION_TRACE ("ex_access_region");
+
+
+	/*
+	 * Ensure that the region operands are fully evaluated and verify
+	 * the validity of the request
+	 */
+	status = acpi_ex_setup_region (obj_desc, field_datum_byte_offset);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/*
+	 * The physical address of this field datum is:
+	 *
+	 * 1) The base of the region, plus
+	 * 2) The base offset of the field, plus
+	 * 3) The current offset into the field
+	 */
+	rgn_desc = obj_desc->common_field.region_obj;
+	address = rgn_desc->region.address
+			 + obj_desc->common_field.base_byte_offset
+			 + field_datum_byte_offset;
+
+	if ((function & ACPI_IO_MASK) == ACPI_READ) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[READ]"));
+	}
+	else {
+		ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[WRITE]"));
+	}
+
+	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_BFIELD,
+		" Region[%s-%X] Access %X Base:Off %X:%X at %8.8X%8.8X\n",
+		acpi_ut_get_region_name (rgn_desc->region.space_id),
+		rgn_desc->region.space_id,
+		obj_desc->common_field.access_byte_width,
+		obj_desc->common_field.base_byte_offset,
+		field_datum_byte_offset,
+		ACPI_HIDWORD (address), ACPI_LODWORD (address)));
+
+	/* Invoke the appropriate address_space/op_region handler */
+
+	status = acpi_ev_address_space_dispatch (rgn_desc, function,
+			  address, ACPI_MUL_8 (obj_desc->common_field.access_byte_width), value);
+
+	if (ACPI_FAILURE (status)) {
+		if (status == AE_NOT_IMPLEMENTED) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"Region %s(%X) not implemented\n",
+				acpi_ut_get_region_name (rgn_desc->region.space_id),
+				rgn_desc->region.space_id));
+		}
+		else if (status == AE_NOT_EXIST) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"Region %s(%X) has no handler\n",
+				acpi_ut_get_region_name (rgn_desc->region.space_id),
+				rgn_desc->region.space_id));
+		}
+	}
+
+	return_ACPI_STATUS (status);
+}
+
 
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ex_register_overflow
+ *
+ * PARAMETERS:  *obj_desc               - Register(Field) to be written
+ *              Value                   - Value to be stored
+ *
+ * RETURN:      TRUE if value overflows the field, FALSE otherwise
+ *
+ * DESCRIPTION: Check if a value is out of range of the field being written.
+ *              Used to check if the values written to Index and Bank registers
+ *              are out of range.  Normally, the value is simply truncated
+ *              to fit the field, but this case is most likely a serious
+ *              coding error in the ASL.
+ *
+ ******************************************************************************/
 
-	FUNCTION_TRACE_U32 ("Ex_read_field_datum", field_datum_byte_offset);
+u8
+acpi_ex_register_overflow (
+	union acpi_operand_object       *obj_desc,
+	acpi_integer                    value)
+{
 
+	if (obj_desc->common_field.bit_length >= ACPI_INTEGER_BIT_SIZE) {
+		/*
+		 * The field is large enough to hold the maximum integer, so we can
+		 * never overflow it.
+		 */
+		return (FALSE);
+	}
 
-	if (!value) {
-		local_value = 0;
-		value = &local_value;   /*  support reads without saving value  */
+	if (value >= ((acpi_integer) 1 << obj_desc->common_field.bit_length)) {
+		/*
+		 * The Value is larger than the maximum value that can fit into
+		 * the register.
+		 */
+		return (TRUE);
 	}
 
-	/* Clear the entire return buffer first, [Very Important!] */
+	/* The Value will fit into the field with no truncation */
+
+	return (FALSE);
+}
 
-	*value = 0;
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ex_field_datum_io
+ *
+ * PARAMETERS:  *obj_desc               - Field to be read
+ *              field_datum_byte_offset - Byte offset of this datum within the
+ *                                        parent field
+ *              *Value                  - Where to store value (must be 64 bits)
+ *              read_write              - Read or Write flag
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Read or Write a single datum of a field.  The field_type is
+ *              demultiplexed here to handle the different types of fields
+ *              (buffer_field, region_field, index_field, bank_field)
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ex_field_datum_io (
+	union acpi_operand_object       *obj_desc,
+	u32                             field_datum_byte_offset,
+	acpi_integer                    *value,
+	u32                             read_write)
+{
+	acpi_status                     status;
+	acpi_integer                    local_value;
+
+
+	ACPI_FUNCTION_TRACE_U32 ("ex_field_datum_io", field_datum_byte_offset);
+
+
+	if (read_write == ACPI_READ) {
+		if (!value) {
+			local_value = 0;
+			value = &local_value; /* To support reads without saving return value */
+		}
+
+		/* Clear the entire return buffer first, [Very Important!] */
+
+		*value = 0;
+	}
 
 	/*
-	 * Buffer_fields - Read from a Buffer
-	 * Other Fields - Read from a Operation Region.
+	 * The four types of fields are:
+	 *
+	 * buffer_fields - Read/write from/to a Buffer
+	 * region_fields - Read/write from/to a Operation Region.
+	 * bank_fields  - Write to a Bank Register, then read/write from/to an op_region
+	 * index_fields - Write to an Index Register, then read/write from/to a Data Register
 	 */
-	switch (obj_desc->common.type) {
+	switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
 	case ACPI_TYPE_BUFFER_FIELD:
-
 		/*
-		 * For Buffer_fields, we only need to copy the data from the
-		 * source buffer.  Length is the field width in bytes.
+		 * If the buffer_field arguments have not been previously evaluated,
+		 * evaluate them now and save the results.
 		 */
-		MEMCPY (value, (obj_desc->buffer_field.buffer_obj)->buffer.pointer
-				  + obj_desc->buffer_field.base_byte_offset + field_datum_byte_offset,
-				  obj_desc->common_field.access_byte_width);
+		if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
+			status = acpi_ds_get_buffer_field_arguments (obj_desc);
+			if (ACPI_FAILURE (status)) {
+				return_ACPI_STATUS (status);
+			}
+		}
+
+		if (read_write == ACPI_READ) {
+			/*
+			 * Copy the data from the source buffer.
+			 * Length is the field width in bytes.
+			 */
+			ACPI_MEMCPY (value, (obj_desc->buffer_field.buffer_obj)->buffer.pointer
+					  + obj_desc->buffer_field.base_byte_offset
+					  + field_datum_byte_offset,
+					  obj_desc->common_field.access_byte_width);
+		}
+		else {
+			/*
+			 * Copy the data to the target buffer.
+			 * Length is the field width in bytes.
+			 */
+			ACPI_MEMCPY ((obj_desc->buffer_field.buffer_obj)->buffer.pointer
+					+ obj_desc->buffer_field.base_byte_offset
+					+ field_datum_byte_offset,
+					value, obj_desc->common_field.access_byte_width);
+		}
+
 		status = AE_OK;
 		break;
 
 
-	case INTERNAL_TYPE_REGION_FIELD:
-	case INTERNAL_TYPE_BANK_FIELD:
+	case ACPI_TYPE_LOCAL_BANK_FIELD:
+
+		/* Ensure that the bank_value is not beyond the capacity of the register */
+
+		if (acpi_ex_register_overflow (obj_desc->bank_field.bank_obj,
+				  (acpi_integer) obj_desc->bank_field.value)) {
+			return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
+		}
 
 		/*
-		 * For other fields, we need to go through an Operation Region
-		 * (Only types that will get here are Region_fields and Bank_fields)
+		 * For bank_fields, we must write the bank_value to the bank_register
+		 * (itself a region_field) before we can access the data.
 		 */
-		status = acpi_ex_setup_field (obj_desc, field_datum_byte_offset);
+		status = acpi_ex_insert_into_field (obj_desc->bank_field.bank_obj,
+				 &obj_desc->bank_field.value,
+				 sizeof (obj_desc->bank_field.value));
 		if (ACPI_FAILURE (status)) {
 			return_ACPI_STATUS (status);
 		}
 
 		/*
-		 * The physical address of this field datum is:
-		 *
-		 * 1) The base of the region, plus
-		 * 2) The base offset of the field, plus
-		 * 3) The current offset into the field
-		 */
-		rgn_desc = obj_desc->common_field.region_obj;
-		address = rgn_desc->region.address + obj_desc->common_field.base_byte_offset +
-				 field_datum_byte_offset;
-
-		ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Region %s(%X) width %X base:off %X:%X at %8.8X%8.8X\n",
-			acpi_ut_get_region_name (rgn_desc->region.space_id),
-			rgn_desc->region.space_id, obj_desc->common_field.access_bit_width,
-			obj_desc->common_field.base_byte_offset, field_datum_byte_offset,
-			HIDWORD(address), LODWORD(address)));
+		 * Now that the Bank has been selected, fall through to the
+		 * region_field case and write the datum to the Operation Region
+		 */
 
-		/* Invoke the appropriate Address_space/Op_region handler */
+		/*lint -fallthrough */
 
-		status = acpi_ev_address_space_dispatch (rgn_desc, ACPI_READ_ADR_SPACE,
-				  address, obj_desc->common_field.access_bit_width, value);
-		if (status == AE_NOT_IMPLEMENTED) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region %s(%X) not implemented\n",
-				acpi_ut_get_region_name (rgn_desc->region.space_id),
-				rgn_desc->region.space_id));
+
+	case ACPI_TYPE_LOCAL_REGION_FIELD:
+		/*
+		 * For simple region_fields, we just directly access the owning
+		 * Operation Region.
+		 */
+		status = acpi_ex_access_region (obj_desc, field_datum_byte_offset, value,
+				  read_write);
+		break;
+
+
+	case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+
+		/* Ensure that the index_value is not beyond the capacity of the register */
+
+		if (acpi_ex_register_overflow (obj_desc->index_field.index_obj,
+				  (acpi_integer) obj_desc->index_field.value)) {
+			return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
 		}
 
-		else if (status == AE_NOT_EXIST) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region %s(%X) has no handler\n",
-				acpi_ut_get_region_name (rgn_desc->region.space_id),
-				rgn_desc->region.space_id));
+		/* Write the index value to the index_register (itself a region_field) */
+
+		status = acpi_ex_insert_into_field (obj_desc->index_field.index_obj,
+				 &obj_desc->index_field.value,
+				 sizeof (obj_desc->index_field.value));
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
+		}
+
+		if (read_write == ACPI_READ) {
+			/* Read the datum from the data_register */
+
+			status = acpi_ex_extract_from_field (obj_desc->index_field.data_obj,
+					  value, obj_desc->common_field.access_byte_width);
+		}
+		else {
+			/* Write the datum to the Data register */
+
+			status = acpi_ex_insert_into_field (obj_desc->index_field.data_obj,
+					  value, obj_desc->common_field.access_byte_width);
 		}
 		break;
 
 
 	default:
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p, wrong source type - %s\n",
-			obj_desc, acpi_ut_get_type_name (obj_desc->common.type)));
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p, Wrong object type - %s\n",
+			obj_desc, acpi_ut_get_object_type_name (obj_desc)));
 		status = AE_AML_INTERNAL;
 		break;
 	}
 
+	if (ACPI_SUCCESS (status)) {
+		if (read_write == ACPI_READ) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Read=%8.8X%8.8X\n",
+					   ACPI_HIDWORD (*value), ACPI_LODWORD (*value)));
+		}
+		else {
+			ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Written=%8.8X%8.8X\n",
+					   ACPI_HIDWORD (*value), ACPI_LODWORD (*value)));
+		}
+	}
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Returned value=%08X \n", *value));
+	return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ex_write_with_update_rule
+ *
+ * PARAMETERS:  *obj_desc           - Field to be set
+ *              Value               - Value to store
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Apply the field update rule to a field write
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ex_write_with_update_rule (
+	union acpi_operand_object       *obj_desc,
+	acpi_integer                    mask,
+	acpi_integer                    field_value,
+	u32                             field_datum_byte_offset)
+{
+	acpi_status                     status = AE_OK;
+	acpi_integer                    merged_value;
+	acpi_integer                    current_value;
+
+
+	ACPI_FUNCTION_TRACE_U32 ("ex_write_with_update_rule", mask);
+
+
+	/* Start with the new bits  */
+
+	merged_value = field_value;
+
+	/* If the mask is all ones, we don't need to worry about the update rule */
+
+	if (mask != ACPI_INTEGER_MAX) {
+		/* Decode the update rule */
+
+		switch (obj_desc->common_field.field_flags & AML_FIELD_UPDATE_RULE_MASK) {
+		case AML_FIELD_UPDATE_PRESERVE:
+			/*
+			 * Check if update rule needs to be applied (not if mask is all
+			 * ones)  The left shift drops the bits we want to ignore.
+			 */
+			if ((~mask << (ACPI_MUL_8 (sizeof (mask)) -
+					 ACPI_MUL_8 (obj_desc->common_field.access_byte_width))) != 0) {
+				/*
+				 * Read the current contents of the byte/word/dword containing
+				 * the field, and merge with the new field value.
+				 */
+				status = acpi_ex_field_datum_io (obj_desc, field_datum_byte_offset,
+						  &current_value, ACPI_READ);
+				merged_value |= (current_value & ~mask);
+			}
+			break;
+
+		case AML_FIELD_UPDATE_WRITE_AS_ONES:
+
+			/* Set positions outside the field to all ones */
+
+			merged_value |= ~mask;
+			break;
+
+		case AML_FIELD_UPDATE_WRITE_AS_ZEROS:
+
+			/* Set positions outside the field to all zeros */
+
+			merged_value &= mask;
+			break;
+
+		default:
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"write_with_update_rule: Unknown update_rule setting: %X\n",
+				(obj_desc->common_field.field_flags & AML_FIELD_UPDATE_RULE_MASK)));
+			return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
+		}
+	}
+
+	/* Write the merged value */
+
+	status = acpi_ex_field_datum_io (obj_desc, field_datum_byte_offset,
+			  &merged_value, ACPI_WRITE);
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+		"Mask %8.8X%8.8X datum_offset %X Value %8.8X%8.8X, merged_value %8.8X%8.8X\n",
+		ACPI_HIDWORD (mask), ACPI_LODWORD (mask),
+		field_datum_byte_offset,
+		ACPI_HIDWORD (field_value), ACPI_LODWORD (field_value),
+		ACPI_HIDWORD (merged_value),ACPI_LODWORD (merged_value)));
 
 	return_ACPI_STATUS (status);
 }
@@ -238,43 +564,65 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_get_buffer_datum
+ * FUNCTION:    acpi_ex_get_buffer_datum
  *
- * PARAMETERS:  Merged_datum        - Value to store
- *              Buffer              - Receiving buffer
- *              Byte_granularity    - 1/2/4 Granularity of the field
+ * PARAMETERS:  Datum               - Where the Datum is returned
+ *              Buffer              - Raw field buffer
+ *              buffer_length       - Entire length (used for big-endian only)
+ *              byte_granularity    - 1/2/4/8 Granularity of the field
  *                                    (aka Datum Size)
- *              Offset              - Datum offset into the buffer
+ *              buffer_offset       - Datum offset into the buffer
  *
  * RETURN:      none
  *
- * DESCRIPTION: Store the merged datum to the buffer according to the
+ * DESCRIPTION: Get a datum from the buffer according to the buffer field
  *              byte granularity
  *
  ******************************************************************************/
 
-static void
-acpi_ex_get_buffer_datum(
-	u32                     *datum,
-	void                    *buffer,
-	u32                     byte_granularity,
-	u32                     offset)
+void
+acpi_ex_get_buffer_datum (
+	acpi_integer                    *datum,
+	void                            *buffer,
+	u32                             buffer_length,
+	u32                             byte_granularity,
+	u32                             buffer_offset)
 {
+	u32                             index;
+
+
+	ACPI_FUNCTION_ENTRY ();
 
-	FUNCTION_ENTRY ();
 
+	/* Get proper index into buffer (handles big/little endian) */
+
+	index = ACPI_BUFFER_INDEX (buffer_length, buffer_offset, byte_granularity);
+
+	/* Move the requested number of bytes */
 
 	switch (byte_granularity) {
 	case ACPI_FIELD_BYTE_GRANULARITY:
-		*datum = ((u8 *) buffer) [offset];
+
+		*datum = ((u8 *) buffer) [index];
 		break;
 
 	case ACPI_FIELD_WORD_GRANULARITY:
-		MOVE_UNALIGNED16_TO_32 (datum, &(((u16 *) buffer) [offset]));
+
+		ACPI_MOVE_16_TO_64 (datum, &(((u16 *) buffer) [index]));
 		break;
 
 	case ACPI_FIELD_DWORD_GRANULARITY:
-		MOVE_UNALIGNED32_TO_32 (datum, &(((u32 *) buffer) [offset]));
+
+		ACPI_MOVE_32_TO_64 (datum, &(((u32 *) buffer) [index]));
+		break;
+
+	case ACPI_FIELD_QWORD_GRANULARITY:
+
+		ACPI_MOVE_64_TO_64 (datum, &(((u64 *) buffer) [index]));
+		break;
+
+	default:
+		/* Should not get here */
 		break;
 	}
 }
@@ -282,13 +630,14 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_set_buffer_datum
+ * FUNCTION:    acpi_ex_set_buffer_datum
  *
- * PARAMETERS:  Merged_datum        - Value to store
+ * PARAMETERS:  merged_datum        - Value to store
  *              Buffer              - Receiving buffer
- *              Byte_granularity    - 1/2/4 Granularity of the field
+ *              buffer_length       - Entire length (used for big-endian only)
+ *              byte_granularity    - 1/2/4/8 Granularity of the field
  *                                    (aka Datum Size)
- *              Offset              - Datum offset into the buffer
+ *              buffer_offset       - Datum offset into the buffer
  *
  * RETURN:      none
  *
@@ -297,28 +646,48 @@
  *
  ******************************************************************************/
 
-static void
+void
 acpi_ex_set_buffer_datum (
-	u32                     merged_datum,
-	void                    *buffer,
-	u32                     byte_granularity,
-	u32                     offset)
+	acpi_integer                    merged_datum,
+	void                            *buffer,
+	u32                             buffer_length,
+	u32                             byte_granularity,
+	u32                             buffer_offset)
 {
+	u32                             index;
+
+	ACPI_FUNCTION_ENTRY ();
+
+
+	/* Get proper index into buffer (handles big/little endian) */
 
-	FUNCTION_ENTRY ();
+	index = ACPI_BUFFER_INDEX (buffer_length, buffer_offset, byte_granularity);
 
+	/* Move the requested number of bytes */
 
 	switch (byte_granularity) {
 	case ACPI_FIELD_BYTE_GRANULARITY:
-		((u8 *) buffer) [offset] = (u8) merged_datum;
+
+		((u8 *) buffer) [index] = (u8) merged_datum;
 		break;
 
 	case ACPI_FIELD_WORD_GRANULARITY:
-		MOVE_UNALIGNED16_TO_16 (&(((u16 *) buffer)[offset]), &merged_datum);
+
+		ACPI_MOVE_64_TO_16 (&(((u16 *) buffer)[index]), &merged_datum);
 		break;
 
 	case ACPI_FIELD_DWORD_GRANULARITY:
-		MOVE_UNALIGNED32_TO_32 (&(((u32 *) buffer)[offset]), &merged_datum);
+
+		ACPI_MOVE_64_TO_32 (&(((u32 *) buffer)[index]), &merged_datum);
+		break;
+
+	case ACPI_FIELD_QWORD_GRANULARITY:
+
+		ACPI_MOVE_64_TO_64 (&(((u64 *) buffer)[index]), &merged_datum);
+		break;
+
+	default:
+		/* Should not get here */
 		break;
 	}
 }
@@ -326,9 +695,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_extract_from_field
+ * FUNCTION:    acpi_ex_extract_from_field
  *
- * PARAMETERS:  *Obj_desc           - Field to be read
+ * PARAMETERS:  *obj_desc           - Field to be read
  *              *Value              - Where to store value
  *
  * RETURN:      Status
@@ -339,29 +708,30 @@
 
 acpi_status
 acpi_ex_extract_from_field (
-	acpi_operand_object     *obj_desc,
-	void                    *buffer,
-	u32                     buffer_length)
+	union acpi_operand_object       *obj_desc,
+	void                            *buffer,
+	u32                             buffer_length)
 {
-	acpi_status             status;
-	u32                     field_datum_byte_offset;
-	u32                     datum_offset;
-	u32                     previous_raw_datum;
-	u32                     this_raw_datum = 0;
-	u32                     merged_datum = 0;
-	u32                     byte_field_length;
-	u32                     datum_count;
+	acpi_status                     status;
+	u32                             field_datum_byte_offset;
+	u32                             datum_offset;
+	acpi_integer                    previous_raw_datum;
+	acpi_integer                    this_raw_datum = 0;
+	acpi_integer                    merged_datum = 0;
+	u32                             byte_field_length;
+	u32                             datum_count;
 
 
-	FUNCTION_TRACE ("Ex_extract_from_field");
+	ACPI_FUNCTION_TRACE ("ex_extract_from_field");
 
 
 	/*
 	 * The field must fit within the caller's buffer
 	 */
-	byte_field_length = ROUND_BITS_UP_TO_BYTES (obj_desc->common_field.bit_length);
+	byte_field_length = ACPI_ROUND_BITS_UP_TO_BYTES (obj_desc->common_field.bit_length);
 	if (byte_field_length > buffer_length) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Field size %X (bytes) too large for buffer (%X)\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+			"Field size %X (bytes) too large for buffer (%X)\n",
 			byte_field_length, buffer_length));
 
 		return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
@@ -369,26 +739,27 @@
 
 	/* Convert field byte count to datum count, round up if necessary */
 
-	datum_count = ROUND_UP_TO (byte_field_length, obj_desc->common_field.access_byte_width);
+	datum_count = ACPI_ROUND_UP_TO (byte_field_length,
+			   obj_desc->common_field.access_byte_width);
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-		"Byte_len=%x, Datum_len=%x, Bit_gran=%x, Byte_gran=%x\n",
-		byte_field_length, datum_count, obj_desc->common_field.access_bit_width,
-		obj_desc->common_field.access_byte_width));
+	ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+		"byte_len=%X, datum_len=%X, byte_gran=%X\n",
+		byte_field_length, datum_count,obj_desc->common_field.access_byte_width));
 
 	/*
 	 * Clear the caller's buffer (the whole buffer length as given)
 	 * This is very important, especially in the cases where a byte is read,
 	 * but the buffer is really a u32 (4 bytes).
 	 */
-	MEMSET (buffer, 0, buffer_length);
+	ACPI_MEMSET (buffer, 0, buffer_length);
 
 	/* Read the first raw datum to prime the loop */
 
 	field_datum_byte_offset = 0;
 	datum_offset= 0;
 
-	status = acpi_ex_read_field_datum (obj_desc, field_datum_byte_offset, &previous_raw_datum);
+	status = acpi_ex_field_datum_io (obj_desc, field_datum_byte_offset,
+			  &previous_raw_datum, ACPI_READ);
 	if (ACPI_FAILURE (status)) {
 		return_ACPI_STATUS (status);
 	}
@@ -397,7 +768,7 @@
 	/* We might actually be done if the request fits in one datum */
 
 	if ((datum_count == 1) &&
-		(obj_desc->common_field.access_flags & AFIELD_SINGLE_DATUM)) {
+		(obj_desc->common_field.flags & AOPOBJ_SINGLE_DATUM)) {
 		/* 1) Shift the valid data bits down to start at bit 0 */
 
 		merged_datum = (previous_raw_datum >> obj_desc->common_field.start_field_bit_offset);
@@ -405,13 +776,13 @@
 		/* 2) Mask off any upper unused bits (bits not part of the field) */
 
 		if (obj_desc->common_field.end_buffer_valid_bits) {
-			merged_datum &= MASK_BITS_ABOVE (obj_desc->common_field.end_buffer_valid_bits);
+			merged_datum &= ACPI_MASK_BITS_ABOVE (obj_desc->common_field.end_buffer_valid_bits);
 		}
 
 		/* Store the datum to the caller buffer */
 
-		acpi_ex_set_buffer_datum (merged_datum, buffer, obj_desc->common_field.access_byte_width,
-				datum_offset);
+		acpi_ex_set_buffer_datum (merged_datum, buffer, buffer_length,
+				obj_desc->common_field.access_byte_width, datum_offset);
 
 		return_ACPI_STATUS (AE_OK);
 	}
@@ -427,17 +798,18 @@
 		 * to perform a final read, since this would potentially read
 		 * past the end of the region.
 		 *
-		 * TBD: [Investigate] It may make more sense to just split the aligned
-		 * and non-aligned cases since the aligned case is so very simple,
+		 * We could just split the aligned and non-aligned cases since the
+		 * aligned case is so very simple, but this would require more code.
 		 */
-		if ((obj_desc->common_field.start_field_bit_offset != 0)  ||
+		if ((obj_desc->common_field.start_field_bit_offset != 0) ||
 			((obj_desc->common_field.start_field_bit_offset == 0) &&
 			(datum_offset < (datum_count -1)))) {
 			/*
 			 * Get the next raw datum, it contains some or all bits
 			 * of the current field datum
 			 */
-			status = acpi_ex_read_field_datum (obj_desc, field_datum_byte_offset, &this_raw_datum);
+			status = acpi_ex_field_datum_io (obj_desc, field_datum_byte_offset,
+					  &this_raw_datum, ACPI_READ);
 			if (ACPI_FAILURE (status)) {
 				return_ACPI_STATUS (status);
 			}
@@ -451,7 +823,6 @@
 
 			merged_datum = previous_raw_datum;
 		}
-
 		else {
 			/*
 			 * Put together the appropriate bits of the two raw data to make a
@@ -474,7 +845,7 @@
 				 */
 				if (obj_desc->common_field.end_buffer_valid_bits) {
 					merged_datum &=
-						MASK_BITS_ABOVE (obj_desc->common_field.end_buffer_valid_bits);
+						ACPI_MASK_BITS_ABOVE (obj_desc->common_field.end_buffer_valid_bits);
 				}
 			}
 		}
@@ -483,8 +854,8 @@
 		 * Store the merged field datum in the caller's buffer, according to
 		 * the granularity of the field (size of each datum).
 		 */
-		acpi_ex_set_buffer_datum (merged_datum, buffer, obj_desc->common_field.access_byte_width,
-				datum_offset);
+		acpi_ex_set_buffer_datum (merged_datum, buffer, buffer_length,
+				obj_desc->common_field.access_byte_width, datum_offset);
 
 		/*
 		 * Save the raw datum that was just acquired since it may contain bits
@@ -500,214 +871,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_write_field_datum
- *
- * PARAMETERS:  *Obj_desc           - Field to be set
- *              Value               - Value to store
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Store the value into the given field
- *
- ******************************************************************************/
-
-static acpi_status
-acpi_ex_write_field_datum (
-	acpi_operand_object     *obj_desc,
-	u32                     field_datum_byte_offset,
-	u32                     value)
-{
-	acpi_status             status = AE_OK;
-	acpi_operand_object     *rgn_desc = NULL;
-	ACPI_PHYSICAL_ADDRESS   address;
-
-
-	FUNCTION_TRACE_U32 ("Ex_write_field_datum", field_datum_byte_offset);
-
-
-	/*
-	 * Buffer_fields - Read from a Buffer
-	 * Other Fields - Read from a Operation Region.
-	 */
-	switch (obj_desc->common.type) {
-	case ACPI_TYPE_BUFFER_FIELD:
-
-		/*
-		 * For Buffer_fields, we only need to copy the data to the
-		 * target buffer.  Length is the field width in bytes.
-		 */
-		MEMCPY ((obj_desc->buffer_field.buffer_obj)->buffer.pointer
-				+ obj_desc->buffer_field.base_byte_offset + field_datum_byte_offset,
-				&value, obj_desc->common_field.access_byte_width);
-		status = AE_OK;
-		break;
-
-
-	case INTERNAL_TYPE_REGION_FIELD:
-	case INTERNAL_TYPE_BANK_FIELD:
-
-		/*
-		 * For other fields, we need to go through an Operation Region
-		 * (Only types that will get here are Region_fields and Bank_fields)
-		 */
-		status = acpi_ex_setup_field (obj_desc, field_datum_byte_offset);
-		if (ACPI_FAILURE (status)) {
-			return_ACPI_STATUS (status);
-		}
-
-		/*
-		 * The physical address of this field datum is:
-		 *
-		 * 1) The base of the region, plus
-		 * 2) The base offset of the field, plus
-		 * 3) The current offset into the field
-		 */
-		rgn_desc = obj_desc->common_field.region_obj;
-		address = rgn_desc->region.address +
-				 obj_desc->common_field.base_byte_offset +
-				 field_datum_byte_offset;
-
-		ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
-			"Store %X in Region %s(%X) at %8.8X%8.8X width %X\n",
-			value, acpi_ut_get_region_name (rgn_desc->region.space_id),
-			rgn_desc->region.space_id, HIDWORD(address), LODWORD(address),
-			obj_desc->common_field.access_bit_width));
-
-		/* Invoke the appropriate Address_space/Op_region handler */
-
-		status = acpi_ev_address_space_dispatch (rgn_desc, ACPI_WRITE_ADR_SPACE,
-				  address, obj_desc->common_field.access_bit_width, &value);
-
-		if (status == AE_NOT_IMPLEMENTED) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-				"**** Region type %s(%X) not implemented\n",
-				acpi_ut_get_region_name (rgn_desc->region.space_id),
-				rgn_desc->region.space_id));
-		}
-
-		else if (status == AE_NOT_EXIST) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-				"**** Region type %s(%X) does not have a handler\n",
-				acpi_ut_get_region_name (rgn_desc->region.space_id),
-				rgn_desc->region.space_id));
-		}
-
-		break;
-
-
-	default:
-
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p, wrong source type - %s\n",
-			obj_desc, acpi_ut_get_type_name (obj_desc->common.type)));
-		status = AE_AML_INTERNAL;
-		break;
-	}
-
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value written=%08X \n", value));
-	return_ACPI_STATUS (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ex_write_field_datum_with_update_rule
- *
- * PARAMETERS:  *Obj_desc           - Field to be set
- *              Value               - Value to store
- *
- * RETURN:      Status
+ * FUNCTION:    acpi_ex_insert_into_field
  *
- * DESCRIPTION: Apply the field update rule to a field write
- *
- ******************************************************************************/
-
-static acpi_status
-acpi_ex_write_field_datum_with_update_rule (
-	acpi_operand_object     *obj_desc,
-	u32                     mask,
-	u32                     field_value,
-	u32                     field_datum_byte_offset)
-{
-	acpi_status             status = AE_OK;
-	u32                     merged_value;
-	u32                     current_value;
-
-
-	FUNCTION_TRACE ("Ex_write_field_datum_with_update_rule");
-
-
-	/* Start with the new bits  */
-
-	merged_value = field_value;
-
-	/* If the mask is all ones, we don't need to worry about the update rule */
-
-	if (mask != ACPI_UINT32_MAX) {
-		/* Decode the update rule */
-
-		switch (obj_desc->common_field.update_rule) {
-		case UPDATE_PRESERVE:
-			/*
-			 * Check if update rule needs to be applied (not if mask is all
-			 * ones)  The left shift drops the bits we want to ignore.
-			 */
-			if ((~mask << (sizeof (mask) * 8 -
-					  obj_desc->common_field.access_bit_width)) != 0) {
-				/*
-				 * Read the current contents of the byte/word/dword containing
-				 * the field, and merge with the new field value.
-				 */
-				status = acpi_ex_read_field_datum (obj_desc, field_datum_byte_offset,
-						  &current_value);
-				merged_value |= (current_value & ~mask);
-			}
-			break;
-
-
-		case UPDATE_WRITE_AS_ONES:
-
-			/* Set positions outside the field to all ones */
-
-			merged_value |= ~mask;
-			break;
-
-
-		case UPDATE_WRITE_AS_ZEROS:
-
-			/* Set positions outside the field to all zeros */
-
-			merged_value &= mask;
-			break;
-
-
-		default:
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-				"Write_with_update_rule: Unknown Update_rule setting: %x\n",
-				obj_desc->common_field.update_rule));
-			return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
-			break;
-		}
-	}
-
-
-	/* Write the merged value */
-
-	status = acpi_ex_write_field_datum (obj_desc, field_datum_byte_offset,
-			  merged_value);
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Mask %X Datum_offset %X Value %X, Merged_value %X\n",
-		mask, field_datum_byte_offset, field_value, merged_value));
-
-	return_ACPI_STATUS (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ex_insert_into_field
- *
- * PARAMETERS:  *Obj_desc           - Field to be set
+ * PARAMETERS:  *obj_desc           - Field to be set
  *              Buffer              - Value to store
  *
  * RETURN:      Status
@@ -718,22 +884,22 @@
 
 acpi_status
 acpi_ex_insert_into_field (
-	acpi_operand_object     *obj_desc,
-	void                    *buffer,
-	u32                     buffer_length)
+	union acpi_operand_object       *obj_desc,
+	void                            *buffer,
+	u32                             buffer_length)
 {
-	acpi_status             status;
-	u32                     field_datum_byte_offset;
-	u32                     datum_offset;
-	u32                     mask;
-	u32                     merged_datum;
-	u32                     previous_raw_datum;
-	u32                     this_raw_datum;
-	u32                     byte_field_length;
-	u32                     datum_count;
+	acpi_status                     status;
+	u32                             field_datum_byte_offset;
+	u32                             datum_offset;
+	acpi_integer                    mask;
+	acpi_integer                    merged_datum;
+	acpi_integer                    previous_raw_datum;
+	acpi_integer                    this_raw_datum;
+	u32                             byte_field_length;
+	u32                             datum_count;
 
 
-	FUNCTION_TRACE ("Ex_insert_into_field");
+	ACPI_FUNCTION_TRACE ("ex_insert_into_field");
 
 
 	/*
@@ -742,24 +908,21 @@
 	 * larger than the field, this typically happens when an integer is
 	 * written to a field that is actually smaller than an integer.
 	 */
-	byte_field_length = ROUND_BITS_UP_TO_BYTES (obj_desc->common_field.bit_length);
+	byte_field_length = ACPI_ROUND_BITS_UP_TO_BYTES (obj_desc->common_field.bit_length);
 	if (buffer_length < byte_field_length) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Buffer length %X too small for field %X\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Buffer length %X too small for field %X\n",
 			buffer_length, byte_field_length));
 
-		/* TBD: Need a better error code */
-
 		return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
 	}
 
 	/* Convert byte count to datum count, round up if necessary */
 
-	datum_count = ROUND_UP_TO (byte_field_length, obj_desc->common_field.access_byte_width);
+	datum_count = ACPI_ROUND_UP_TO (byte_field_length, obj_desc->common_field.access_byte_width);
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-		"Byte_len=%x, Datum_len=%x, Bit_gran=%x, Byte_gran=%x\n",
-		byte_field_length, datum_count, obj_desc->common_field.access_bit_width,
-		obj_desc->common_field.access_byte_width));
+	ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+		"byte_len=%X, datum_len=%X, byte_gran=%X\n",
+		byte_field_length, datum_count, obj_desc->common_field.access_byte_width));
 
 	/*
 	 * Break the request into up to three parts (similar to an I/O request):
@@ -772,7 +935,7 @@
 
 	/* Get a single datum from the caller's buffer */
 
-	acpi_ex_get_buffer_datum (&previous_raw_datum, buffer,
+	acpi_ex_get_buffer_datum (&previous_raw_datum, buffer, buffer_length,
 			obj_desc->common_field.access_byte_width, datum_offset);
 
 	/*
@@ -781,19 +944,19 @@
 	 * Note: The code in this section also handles the aligned case
 	 *
 	 * Construct Mask with 1 bits where the field is, 0 bits elsewhere
-	 * (Only the bottom 5 bits of Bit_length are valid for a shift operation)
+	 * (Only the bottom 5 bits of bit_length are valid for a shift operation)
 	 *
 	 * Mask off bits that are "below" the field (if any)
 	 */
-	mask = MASK_BITS_BELOW (obj_desc->common_field.start_field_bit_offset);
+	mask = ACPI_MASK_BITS_BELOW (obj_desc->common_field.start_field_bit_offset);
 
 	/* If the field fits in one datum, may need to mask upper bits */
 
-	if ((obj_desc->common_field.access_flags & AFIELD_SINGLE_DATUM) &&
+	if ((obj_desc->common_field.flags & AOPOBJ_SINGLE_DATUM) &&
 		 obj_desc->common_field.end_field_valid_bits) {
 		/* There are bits above the field, mask them off also */
 
-		mask &= MASK_BITS_ABOVE (obj_desc->common_field.end_field_valid_bits);
+		mask &= ACPI_MASK_BITS_ABOVE (obj_desc->common_field.end_field_valid_bits);
 	}
 
 	/* Shift and mask the value into the field position */
@@ -803,7 +966,7 @@
 
 	/* Apply the update rule (if necessary) and write the datum to the field */
 
-	status = acpi_ex_write_field_datum_with_update_rule (obj_desc, mask, merged_datum,
+	status = acpi_ex_write_with_update_rule (obj_desc, mask, merged_datum,
 			   field_datum_byte_offset);
 	if (ACPI_FAILURE (status)) {
 		return_ACPI_STATUS (status);
@@ -812,7 +975,7 @@
 	/* If the entire field fits within one datum, we are done. */
 
 	if ((datum_count == 1) &&
-	   (obj_desc->common_field.access_flags & AFIELD_SINGLE_DATUM)) {
+	   (obj_desc->common_field.flags & AOPOBJ_SINGLE_DATUM)) {
 		return_ACPI_STATUS (AE_OK);
 	}
 
@@ -835,7 +998,7 @@
 		 * Get the next raw buffer datum.  It may contain bits of the previous
 		 * field datum
 		 */
-		acpi_ex_get_buffer_datum (&this_raw_datum, buffer,
+		acpi_ex_get_buffer_datum (&this_raw_datum, buffer, buffer_length,
 				obj_desc->common_field.access_byte_width, datum_offset);
 
 		/* Create the field datum based on the field alignment */
@@ -849,7 +1012,6 @@
 				(previous_raw_datum >> obj_desc->common_field.datum_valid_bits) |
 				(this_raw_datum << obj_desc->common_field.start_field_bit_offset);
 		}
-
 		else {
 			/* Field began aligned on datum boundary */
 
@@ -874,24 +1036,23 @@
 				 *
 				 * Mask off the unused bits above (after) the end-of-field
 				 */
-				mask = MASK_BITS_ABOVE (obj_desc->common_field.end_field_valid_bits);
+				mask = ACPI_MASK_BITS_ABOVE (obj_desc->common_field.end_field_valid_bits);
 				merged_datum &= mask;
 
 				/* Write the last datum with the update rule */
 
-				status = acpi_ex_write_field_datum_with_update_rule (obj_desc, mask,
-						  merged_datum, field_datum_byte_offset);
+				status = acpi_ex_write_with_update_rule (obj_desc, mask, merged_datum,
+						   field_datum_byte_offset);
 				if (ACPI_FAILURE (status)) {
 					return_ACPI_STATUS (status);
 				}
 			}
 		}
-
 		else {
 			/* Normal case -- write the completed datum */
 
-			status = acpi_ex_write_field_datum (obj_desc,
-					  field_datum_byte_offset, merged_datum);
+			status = acpi_ex_field_datum_io (obj_desc, field_datum_byte_offset,
+					  &merged_datum, ACPI_WRITE);
 			if (ACPI_FAILURE (status)) {
 				return_ACPI_STATUS (status);
 			}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exmisc.c linux-2.4.22-pre2/drivers/acpi/executer/exmisc.c
--- linux-2.4.21/drivers/acpi/executer/exmisc.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exmisc.c	2003-06-26 21:43:31.000000000 +0000
@@ -2,122 +2,229 @@
 /******************************************************************************
  *
  * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes
- *              $Revision: 92 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "acinterp.h"
-#include "amlcode.h"
-#include "acdispat.h"
+#include <acpi/acpi.h>
+#include <acpi/acinterp.h>
+#include <acpi/amlcode.h>
 
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exmisc")
+	 ACPI_MODULE_NAME    ("exmisc")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_get_object_reference
+ * FUNCTION:    acpi_ex_get_object_reference
  *
- * PARAMETERS:  Obj_desc        - Create a reference to this object
- *              Return_desc        - Where to store the reference
+ * PARAMETERS:  obj_desc            - Create a reference to this object
+ *              return_desc         - Where to store the reference
+ *              walk_state          - Current state
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Obtain and return a "reference" to the target object
- *              Common code for the Ref_of_op and the Cond_ref_of_op.
+ *              Common code for the ref_of_op and the cond_ref_of_op.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ex_get_object_reference (
-	acpi_operand_object     *obj_desc,
-	acpi_operand_object     **return_desc,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       *obj_desc,
+	union acpi_operand_object       **return_desc,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status = AE_OK;
+	union acpi_operand_object       *reference_obj;
+	union acpi_operand_object       *referenced_obj;
 
 
-	FUNCTION_TRACE_PTR ("Ex_get_object_reference", obj_desc);
+	ACPI_FUNCTION_TRACE_PTR ("ex_get_object_reference", obj_desc);
 
 
-	if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_INTERNAL)) {
-		if (obj_desc->common.type != INTERNAL_TYPE_REFERENCE) {
-			*return_desc = NULL;
-			status = AE_TYPE;
-			goto cleanup;
+	*return_desc = NULL;
+
+	switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) {
+	case ACPI_DESC_TYPE_OPERAND:
+
+		if (ACPI_GET_OBJECT_TYPE (obj_desc) != ACPI_TYPE_LOCAL_REFERENCE) {
+			return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 		}
 
 		/*
-		 * Not a Name -- an indirect name pointer would have
-		 * been converted to a direct name pointer in Acpi_ex_resolve_operands
+		 * Must be a reference to a Local or Arg
 		 */
 		switch (obj_desc->reference.opcode) {
 		case AML_LOCAL_OP:
 		case AML_ARG_OP:
 
-			*return_desc = (void *) acpi_ds_method_data_get_node (obj_desc->reference.opcode,
-					  obj_desc->reference.offset, walk_state);
+			/* The referenced object is the pseudo-node for the local/arg */
+
+			referenced_obj = obj_desc->reference.object;
 			break;
 
 		default:
 
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(Internal) Unknown Ref subtype %02x\n",
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference subtype %X\n",
 				obj_desc->reference.opcode));
-			*return_desc = NULL;
-			status = AE_AML_INTERNAL;
-			goto cleanup;
+			return_ACPI_STATUS (AE_AML_INTERNAL);
 		}
+		break;
 
-	}
 
-	else if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) {
-		/* Must be a named object;  Just return the Node */
+	case ACPI_DESC_TYPE_NAMED:
 
-		*return_desc = obj_desc;
+		/*
+		 * A named reference that has already been resolved to a Node
+		 */
+		referenced_obj = obj_desc;
+		break;
+
+
+	default:
+
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid descriptor type %X in %p\n",
+			ACPI_GET_DESCRIPTOR_TYPE (obj_desc), obj_desc));
+		return_ACPI_STATUS (AE_TYPE);
 	}
 
-	else {
-		*return_desc = NULL;
-		status = AE_TYPE;
+
+	/* Create a new reference object */
+
+	reference_obj = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_REFERENCE);
+	if (!reference_obj) {
+		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
 
+	reference_obj->reference.opcode = AML_REF_OF_OP;
+	reference_obj->reference.object = referenced_obj;
+	*return_desc = reference_obj;
 
-cleanup:
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object %p Type [%s], returning Reference %p\n",
+		obj_desc, acpi_ut_get_object_type_name (obj_desc), *return_desc));
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p Ref=%p\n", obj_desc, *return_desc));
-	return_ACPI_STATUS (status);
+	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_do_concatenate
+ * FUNCTION:    acpi_ex_concat_template
  *
- * PARAMETERS:  *Obj_desc           - Object to be converted.  Must be an
+ * PARAMETERS:  *obj_desc           - Object to be converted.  Must be an
  *                                    Integer, Buffer, or String
- *              Walk_state          - Current walk state
+ *              walk_state          - Current walk state
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Concatenate two resource templates
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ex_concat_template (
+	union acpi_operand_object       *obj_desc1,
+	union acpi_operand_object       *obj_desc2,
+	union acpi_operand_object       **actual_return_desc,
+	struct acpi_walk_state          *walk_state)
+{
+	union acpi_operand_object       *return_desc;
+	u8                              *new_buf;
+	u8                              *end_tag1;
+	u8                              *end_tag2;
+	acpi_size                       length1;
+	acpi_size                       length2;
+
+
+	ACPI_FUNCTION_TRACE ("ex_concat_template");
+
+
+	/* 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);
+	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) +
+			  2; /* Size of END_TAG */
+
+	/* Create a new buffer object for the result */
+
+	return_desc = acpi_ut_create_buffer_object (length1 + length2);
+	if (!return_desc) {
+		return_ACPI_STATUS (AE_NO_MEMORY);
+	}
+
+	/* 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);
+
+	/* Compute the new checksum */
+
+	new_buf[return_desc->buffer.length - 1] =
+			acpi_ut_generate_checksum (return_desc->buffer.pointer,
+					   (return_desc->buffer.length - 1));
+
+	/* Return the completed template descriptor */
+
+	*actual_return_desc = return_desc;
+	return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ex_do_concatenate
+ *
+ * PARAMETERS:  obj_desc1           - First source object
+ *              obj_desc2           - Second source object
+ *              actual_return_desc  - Where to place the return object
+ *              walk_state          - Current walk state
  *
  * RETURN:      Status
  *
@@ -127,75 +234,54 @@
 
 acpi_status
 acpi_ex_do_concatenate (
-	acpi_operand_object     *obj_desc,
-	acpi_operand_object     *obj_desc2,
-	acpi_operand_object     **actual_return_desc,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       *obj_desc1,
+	union acpi_operand_object       *obj_desc2,
+	union acpi_operand_object       **actual_return_desc,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status;
-	u32                     i;
-	acpi_integer            this_integer;
-	acpi_operand_object     *return_desc;
-	NATIVE_CHAR             *new_buf;
-	u32                     integer_size = sizeof (acpi_integer);
+	acpi_status                     status;
+	u32                             i;
+	acpi_integer                    this_integer;
+	union acpi_operand_object       *return_desc;
+	char                            *new_buf;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/*
 	 * There are three cases to handle:
-	 * 1) Two Integers concatenated to produce a buffer
-	 * 2) Two Strings concatenated to produce a string
-	 * 3) Two Buffers concatenated to produce a buffer
+	 *
+	 * 1) Two Integers concatenated to produce a new Buffer
+	 * 2) Two Strings concatenated to produce a new String
+	 * 3) Two Buffers concatenated to produce a new Buffer
 	 */
-	switch (obj_desc->common.type) {
+	switch (ACPI_GET_OBJECT_TYPE (obj_desc1)) {
 	case ACPI_TYPE_INTEGER:
 
-		/* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */
-
-		if (walk_state->method_node->flags & ANOBJ_DATA_WIDTH_32) {
-			/*
-			 * We are running a method that exists in a 32-bit ACPI table.
-			 * Truncate the value to 32 bits by zeroing out the upper
-			 * 32-bit field
-			 */
-			integer_size = sizeof (u32);
-		}
-
-		/* Result of two integers is a buffer */
+		/* Result of two Integers is a Buffer */
+		/* Need enough buffer space for two integers */
 
-		return_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER);
+		return_desc = acpi_ut_create_buffer_object (acpi_gbl_integer_byte_width * 2);
 		if (!return_desc) {
 			return (AE_NO_MEMORY);
 		}
 
-		/* Need enough space for two integers */
-
-		return_desc->buffer.length = integer_size * 2;
-		new_buf = ACPI_MEM_CALLOCATE (return_desc->buffer.length);
-		if (!new_buf) {
-			REPORT_ERROR
-				(("Ex_do_concatenate: Buffer allocation failure\n"));
-			status = AE_NO_MEMORY;
-			goto cleanup;
-		}
-
-		return_desc->buffer.pointer = (u8 *) new_buf;
+		new_buf = (char *) return_desc->buffer.pointer;
 
 		/* Convert the first integer */
 
-		this_integer = obj_desc->integer.value;
-		for (i = 0; i < integer_size; i++) {
-			new_buf[i] = (u8) this_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;
 		}
 
 		/* Convert the second integer */
 
 		this_integer = obj_desc2->integer.value;
-		for (; i < (integer_size * 2); i++) {
-			new_buf[i] = (u8) this_integer;
+		for (; i < (ACPI_MUL_2 (acpi_gbl_integer_byte_width)); i++) {
+			new_buf[i] = (char) this_integer;
 			this_integer >>= 8;
 		}
 
@@ -204,6 +290,8 @@
 
 	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);
@@ -211,66 +299,60 @@
 
 		/* Operand0 is string  */
 
-		new_buf = ACPI_MEM_ALLOCATE (obj_desc->string.length +
-				  obj_desc2->string.length + 1);
+		new_buf = ACPI_MEM_CALLOCATE ((acpi_size) obj_desc1->string.length +
+				   (acpi_size) obj_desc2->string.length + 1);
 		if (!new_buf) {
-			REPORT_ERROR
-				(("Ex_do_concatenate: String allocation failure\n"));
+			ACPI_REPORT_ERROR
+				(("ex_do_concatenate: String allocation failure\n"));
 			status = AE_NO_MEMORY;
 			goto cleanup;
 		}
 
-		STRCPY (new_buf, obj_desc->string.pointer);
-		STRCPY (new_buf + obj_desc->string.length,
+		/* Concatenate the strings */
+
+		ACPI_STRCPY (new_buf, obj_desc1->string.pointer);
+		ACPI_STRCPY (new_buf + obj_desc1->string.length,
 				  obj_desc2->string.pointer);
 
-		/* Point the return object to the new string */
+		/* Complete the String object initialization */
 
 		return_desc->string.pointer = new_buf;
-		return_desc->string.length = obj_desc->string.length +=
-				  obj_desc2->string.length;
+		return_desc->string.length = obj_desc1->string.length +
+				   obj_desc2->string.length;
 		break;
 
 
 	case ACPI_TYPE_BUFFER:
 
-		/* Operand0 is a buffer */
+		/* Result of two Buffers is a Buffer */
 
-		return_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER);
+		return_desc = acpi_ut_create_buffer_object (
+				   (acpi_size) obj_desc1->buffer.length +
+				   (acpi_size) obj_desc2->buffer.length);
 		if (!return_desc) {
 			return (AE_NO_MEMORY);
 		}
 
-		new_buf = ACPI_MEM_ALLOCATE (obj_desc->buffer.length +
-				  obj_desc2->buffer.length);
-		if (!new_buf) {
-			REPORT_ERROR
-				(("Ex_do_concatenate: Buffer allocation failure\n"));
-			status = AE_NO_MEMORY;
-			goto cleanup;
-		}
+		new_buf = (char *) return_desc->buffer.pointer;
 
-		MEMCPY (new_buf, obj_desc->buffer.pointer,
-				  obj_desc->buffer.length);
-		MEMCPY (new_buf + obj_desc->buffer.length, obj_desc2->buffer.pointer,
-				   obj_desc2->buffer.length);
+		/* Concatenate the buffers */
 
-		/*
-		 * Point the return object to the new buffer
-		 */
+		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);
 
-		return_desc->buffer.pointer    = (u8 *) new_buf;
-		return_desc->buffer.length     = obj_desc->buffer.length +
-				 obj_desc2->buffer.length;
 		break;
 
 
 	default:
+
+		/* Invalid object type, should not happen here */
+
 		status = AE_AML_INTERNAL;
 		return_desc = NULL;
 	}
 
-
 	*actual_return_desc = return_desc;
 	return (AE_OK);
 
@@ -284,11 +366,11 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_do_math_op
+ * FUNCTION:    acpi_ex_do_math_op
  *
  * PARAMETERS:  Opcode              - AML opcode
  *              Operand0            - Integer operand #0
- *              Operand0            - Integer operand #1
+ *              Operand1            - Integer operand #1
  *
  * RETURN:      Integer result of the operation
  *
@@ -300,9 +382,9 @@
 
 acpi_integer
 acpi_ex_do_math_op (
-	u16                     opcode,
-	acpi_integer            operand0,
-	acpi_integer            operand1)
+	u16                             opcode,
+	acpi_integer                    operand0,
+	acpi_integer                    operand1)
 {
 
 
@@ -342,12 +424,12 @@
 		return (operand0 * operand1);
 
 
-	case AML_SHIFT_LEFT_OP:         /* Shift_left (Operand, Shift_count, Result) */
+	case AML_SHIFT_LEFT_OP:         /* shift_left (Operand, shift_count, Result) */
 
 		return (operand0 << operand1);
 
 
-	case AML_SHIFT_RIGHT_OP:        /* Shift_right (Operand, Shift_count, Result) */
+	case AML_SHIFT_RIGHT_OP:        /* shift_right (Operand, shift_count, Result) */
 
 		return (operand0 >> operand1);
 
@@ -365,11 +447,11 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_do_logical_op
+ * FUNCTION:    acpi_ex_do_logical_op
  *
  * PARAMETERS:  Opcode              - AML opcode
  *              Operand0            - Integer operand #0
- *              Operand0            - Integer operand #1
+ *              Operand1            - Integer operand #1
  *
  * RETURN:      TRUE/FALSE result of the operation
  *
@@ -386,9 +468,9 @@
 
 u8
 acpi_ex_do_logical_op (
-	u16                     opcode,
-	acpi_integer            operand0,
-	acpi_integer            operand1)
+	u16                             opcode,
+	acpi_integer                    operand0,
+	acpi_integer                    operand1)
 {
 
 
@@ -432,6 +514,9 @@
 			return (TRUE);
 		}
 		break;
+
+	default:
+		break;
 	}
 
 	return (FALSE);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exmutex.c linux-2.4.22-pre2/drivers/acpi/executer/exmutex.c
--- linux-2.4.21/drivers/acpi/executer/exmutex.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exmutex.c	2003-06-26 21:43:30.000000000 +0000
@@ -2,107 +2,136 @@
 /******************************************************************************
  *
  * Module Name: exmutex - ASL Mutex Acquire/Release functions
- *              $Revision: 7 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "achware.h"
-#include "acevents.h"
+#include <acpi/acpi.h>
+#include <acpi/acinterp.h>
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exmutex")
+	 ACPI_MODULE_NAME    ("exmutex")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_unlink_mutex
+ * FUNCTION:    acpi_ex_unlink_mutex
  *
- * PARAMETERS:  *Obj_desc           - The mutex to be unlinked
+ * PARAMETERS:  *obj_desc           - The mutex to be unlinked
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Remove a mutex from the "Acquired_mutex" list
+ * DESCRIPTION: Remove a mutex from the "acquired_mutex" list
  *
  ******************************************************************************/
 
 void
 acpi_ex_unlink_mutex (
-	acpi_operand_object     *obj_desc)
+	union acpi_operand_object       *obj_desc)
 {
+	struct acpi_thread_state        *thread = obj_desc->mutex.owner_thread;
+
+
+	if (!thread) {
+		return;
+	}
 
 	if (obj_desc->mutex.next) {
 		(obj_desc->mutex.next)->mutex.prev = obj_desc->mutex.prev;
 	}
+
 	if (obj_desc->mutex.prev) {
 		(obj_desc->mutex.prev)->mutex.next = obj_desc->mutex.next;
 	}
+	else {
+		thread->acquired_mutex_list = obj_desc->mutex.next;
+	}
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_link_mutex
+ * FUNCTION:    acpi_ex_link_mutex
  *
- * PARAMETERS:  *Obj_desc           - The mutex to be linked
- *              *List_head          - head of the "Acquired_mutex" list
+ * PARAMETERS:  *obj_desc           - The mutex to be linked
+ *              *list_head          - head of the "acquired_mutex" list
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Add a mutex to the "Acquired_mutex" list for this walk
+ * DESCRIPTION: Add a mutex to the "acquired_mutex" list for this walk
  *
  ******************************************************************************/
 
 void
 acpi_ex_link_mutex (
-	acpi_operand_object     *obj_desc,
-	acpi_operand_object     *list_head)
+	union acpi_operand_object       *obj_desc,
+	struct acpi_thread_state        *thread)
 {
+	union acpi_operand_object       *list_head;
+
+
+	list_head = thread->acquired_mutex_list;
 
 	/* This object will be the first object in the list */
 
-	obj_desc->mutex.prev = list_head;
-	obj_desc->mutex.next = list_head->mutex.next;
+	obj_desc->mutex.prev = NULL;
+	obj_desc->mutex.next = list_head;
 
 	/* Update old first object to point back to this object */
 
-	if (list_head->mutex.next) {
-		(list_head->mutex.next)->mutex.prev = obj_desc;
+	if (list_head) {
+		list_head->mutex.prev = obj_desc;
 	}
 
 	/* Update list head */
 
-	list_head->mutex.next = obj_desc;
+	thread->acquired_mutex_list = obj_desc;
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_acquire_mutex
+ * FUNCTION:    acpi_ex_acquire_mutex
  *
- * PARAMETERS:  *Time_desc          - The 'time to delay' object descriptor
- *              *Obj_desc           - The object descriptor for this op
+ * PARAMETERS:  *time_desc          - The 'time to delay' object descriptor
+ *              *obj_desc           - The object descriptor for this op
  *
  * RETURN:      Status
  *
@@ -112,32 +141,48 @@
 
 acpi_status
 acpi_ex_acquire_mutex (
-	acpi_operand_object     *time_desc,
-	acpi_operand_object     *obj_desc,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       *time_desc,
+	union acpi_operand_object       *obj_desc,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status;
+	acpi_status                     status;
+
 
+	ACPI_FUNCTION_TRACE_PTR ("ex_acquire_mutex", obj_desc);
 
-	FUNCTION_TRACE_PTR ("Ex_acquire_mutex", obj_desc);
 
 	if (!obj_desc) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
+	/* Sanity check -- we must have a valid thread ID */
+
+	if (!walk_state->thread) {
+		ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], null thread info\n",
+				obj_desc->mutex.node->name.ascii));
+		return_ACPI_STATUS (AE_AML_INTERNAL);
+	}
+
 	/*
 	 * Current Sync must be less than or equal to the sync level of the
 	 * mutex.  This mechanism provides some deadlock prevention
 	 */
-	if (walk_state->current_sync_level > obj_desc->mutex.sync_level) {
+	if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) {
+		ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], incorrect sync_level\n",
+				obj_desc->mutex.node->name.ascii));
 		return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
 	}
 
 	/*
-	 * If the mutex is already owned by this thread,
-	 * just increment the acquisition depth
+	 * Support for multiple acquires by the owning thread
 	 */
-	if (obj_desc->mutex.owner == walk_state) {
+
+	if ((obj_desc->mutex.owner_thread) &&
+		(obj_desc->mutex.owner_thread->thread_id == walk_state->thread->thread_id)) {
+		/*
+		 * The mutex is already owned by this thread,
+		 * just increment the acquisition depth
+		 */
 		obj_desc->mutex.acquisition_depth++;
 		return_ACPI_STATUS (AE_OK);
 	}
@@ -146,21 +191,21 @@
 
 	status = acpi_ex_system_acquire_mutex (time_desc, obj_desc);
 	if (ACPI_FAILURE (status)) {
-		/* Includes failure from a timeout on Time_desc */
+		/* Includes failure from a timeout on time_desc */
 
 		return_ACPI_STATUS (status);
 	}
 
 	/* Have the mutex, update mutex and walk info */
 
-	obj_desc->mutex.owner = walk_state;
+	obj_desc->mutex.owner_thread    = walk_state->thread;
 	obj_desc->mutex.acquisition_depth = 1;
-	walk_state->current_sync_level = obj_desc->mutex.sync_level;
 
-	/* Link the mutex to the walk state for force-unlock at method exit */
+	walk_state->thread->current_sync_level = obj_desc->mutex.sync_level;
 
-	acpi_ex_link_mutex (obj_desc, (acpi_operand_object *)
-			 &(walk_state->walk_list->acquired_mutex_list));
+	/* Link the mutex to the current thread for force-unlock at method exit */
+
+	acpi_ex_link_mutex (obj_desc, walk_state->thread);
 
 	return_ACPI_STATUS (AE_OK);
 }
@@ -168,9 +213,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_release_mutex
+ * FUNCTION:    acpi_ex_release_mutex
  *
- * PARAMETERS:  *Obj_desc           - The object descriptor for this op
+ * PARAMETERS:  *obj_desc           - The object descriptor for this op
  *
  * RETURN:      Status
  *
@@ -180,13 +225,13 @@
 
 acpi_status
 acpi_ex_release_mutex (
-	acpi_operand_object     *obj_desc,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       *obj_desc,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Ex_release_mutex");
+	ACPI_FUNCTION_TRACE ("ex_release_mutex");
 
 
 	if (!obj_desc) {
@@ -195,13 +240,28 @@
 
 	/* The mutex must have been previously acquired in order to release it */
 
-	if (!obj_desc->mutex.owner) {
+	if (!obj_desc->mutex.owner_thread) {
+		ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], not acquired\n",
+				obj_desc->mutex.node->name.ascii));
 		return_ACPI_STATUS (AE_AML_MUTEX_NOT_ACQUIRED);
 	}
 
+	/* Sanity check -- we must have a valid thread ID */
+
+	if (!walk_state->thread) {
+		ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], null thread info\n",
+				obj_desc->mutex.node->name.ascii));
+		return_ACPI_STATUS (AE_AML_INTERNAL);
+	}
+
 	/* The Mutex is owned, but this thread must be the owner */
 
-	if (obj_desc->mutex.owner != walk_state) {
+	if (obj_desc->mutex.owner_thread->thread_id != walk_state->thread->thread_id) {
+		ACPI_REPORT_ERROR ((
+			"Thread %X cannot release Mutex [%4.4s] acquired by thread %X\n",
+			walk_state->thread->thread_id,
+			obj_desc->mutex.node->name.ascii,
+			obj_desc->mutex.owner_thread->thread_id));
 		return_ACPI_STATUS (AE_AML_NOT_OWNER);
 	}
 
@@ -209,7 +269,9 @@
 	 * The sync level of the mutex must be less than or
 	 * equal to the current sync level
 	 */
-	if (obj_desc->mutex.sync_level > walk_state->current_sync_level) {
+	if (obj_desc->mutex.sync_level > walk_state->thread->current_sync_level) {
+		ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], incorrect sync_level\n",
+				obj_desc->mutex.node->name.ascii));
 		return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
 	}
 
@@ -223,6 +285,9 @@
 		return_ACPI_STATUS (AE_OK);
 	}
 
+	/* Unlink the mutex from the owner's list */
+
+	acpi_ex_unlink_mutex (obj_desc);
 
 	/* Release the mutex */
 
@@ -230,12 +295,8 @@
 
 	/* Update the mutex and walk state */
 
-	obj_desc->mutex.owner = NULL;
-	walk_state->current_sync_level = obj_desc->mutex.sync_level;
-
-	/* Unlink the mutex from the owner's list */
-
-	acpi_ex_unlink_mutex (obj_desc);
+	obj_desc->mutex.owner_thread = NULL;
+	walk_state->thread->current_sync_level = obj_desc->mutex.sync_level;
 
 	return_ACPI_STATUS (status);
 }
@@ -243,9 +304,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_release_all_mutexes
+ * FUNCTION:    acpi_ex_release_all_mutexes
  *
- * PARAMETERS:  *Mutex_list           - Head of the mutex list
+ * PARAMETERS:  *mutex_list           - Head of the mutex list
  *
  * RETURN:      Status
  *
@@ -253,15 +314,16 @@
  *
  ******************************************************************************/
 
-acpi_status
+void
 acpi_ex_release_all_mutexes (
-	acpi_operand_object     *list_head)
+	struct acpi_thread_state        *thread)
 {
-	acpi_operand_object     *next = list_head->mutex.next;
-	acpi_operand_object     *this;
+	union acpi_operand_object       *next = thread->acquired_mutex_list;
+	union acpi_operand_object       *this;
+	acpi_status                     status;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/*
@@ -271,19 +333,21 @@
 		this = next;
 		next = this->mutex.next;
 
-		/* Mark mutex un-owned */
-
-		this->mutex.owner = NULL;
-		this->mutex.prev = NULL;
-		this->mutex.next = NULL;
-		this->mutex.acquisition_depth = 0;
+		this->mutex.acquisition_depth = 1;
+		this->mutex.prev             = NULL;
+		this->mutex.next             = NULL;
 
 		 /* Release the mutex */
 
-		acpi_ex_system_release_mutex (this);
-	}
+		status = acpi_ex_system_release_mutex (this);
+		if (ACPI_FAILURE (status)) {
+			continue;
+		}
+
+		/* Mark mutex unowned */
 
-	return (AE_OK);
+		this->mutex.owner_thread     = NULL;
+	}
 }
 
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exnames.c linux-2.4.22-pre2/drivers/acpi/executer/exnames.c
--- linux-2.4.21/drivers/acpi/executer/exnames.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exnames.c	2003-06-26 21:43:16.000000000 +0000
@@ -2,36 +2,53 @@
 /******************************************************************************
  *
  * Module Name: exnames - interpreter/scanner name load/execute
- *              $Revision: 83 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acinterp.h"
-#include "amlcode.h"
-#include "acnamesp.h"
+#include <acpi/acpi.h>
+#include <acpi/acinterp.h>
+#include <acpi/amlcode.h>
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exnames")
+	 ACPI_MODULE_NAME    ("exnames")
 
 
 /* AML Package Length encodings */
@@ -44,11 +61,11 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_allocate_name_string
+ * FUNCTION:    acpi_ex_allocate_name_string
  *
- * PARAMETERS:  Prefix_count        - Count of parent levels. Special cases:
+ * PARAMETERS:  prefix_count        - Count of parent levels. Special cases:
  *                                    (-1) = root,  0 = none
- *              Num_name_segs       - count of 4-character name segments
+ *              num_name_segs       - count of 4-character name segments
  *
  * RETURN:      A pointer to the allocated string segment.  This segment must
  *              be deleted by the caller.
@@ -58,24 +75,24 @@
  *
  ******************************************************************************/
 
-NATIVE_CHAR *
+char *
 acpi_ex_allocate_name_string (
-	u32                     prefix_count,
-	u32                     num_name_segs)
+	u32                             prefix_count,
+	u32                             num_name_segs)
 {
-	NATIVE_CHAR             *temp_ptr;
-	NATIVE_CHAR             *name_string;
-	u32                      size_needed;
+	char                            *temp_ptr;
+	char                            *name_string;
+	u32                              size_needed;
 
-	FUNCTION_TRACE ("Ex_allocate_name_string");
+	ACPI_FUNCTION_TRACE ("ex_allocate_name_string");
 
 
 	/*
-	 * Allow room for all \ and ^ prefixes, all segments, and a Multi_name_prefix.
+	 * Allow room for all \ and ^ prefixes, all segments, and a multi_name_prefix.
 	 * Also, one byte for the null terminator.
 	 * This may actually be somewhat longer than needed.
 	 */
-	if (prefix_count == (u32) -1) {
+	if (prefix_count == ACPI_UINT32_MAX) {
 		/* Special case for root */
 
 		size_needed = 1 + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1;
@@ -90,7 +107,7 @@
 	 */
 	name_string = ACPI_MEM_ALLOCATE (size_needed);
 	if (!name_string) {
-		REPORT_ERROR (("Ex_allocate_name_string: Could not allocate size %d\n", size_needed));
+		ACPI_REPORT_ERROR (("ex_allocate_name_string: Could not allocate size %d\n", size_needed));
 		return_PTR (NULL);
 	}
 
@@ -98,10 +115,9 @@
 
 	/* Set up Root or Parent prefixes if needed */
 
-	if (prefix_count == (u32) -1) {
+	if (prefix_count == ACPI_UINT32_MAX) {
 		*temp_ptr++ = AML_ROOT_PREFIX;
 	}
-
 	else {
 		while (prefix_count--) {
 			*temp_ptr++ = AML_PARENT_PREFIX;
@@ -117,7 +133,6 @@
 		*temp_ptr++ = AML_MULTI_NAME_PREFIX_OP;
 		*temp_ptr++ = (char) num_name_segs;
 	}
-
 	else if (2 == num_name_segs) {
 		/* Set up dual prefixes */
 
@@ -125,7 +140,7 @@
 	}
 
 	/*
-	 * Terminate string following prefixes. Acpi_ex_name_segment() will
+	 * Terminate string following prefixes. acpi_ex_name_segment() will
 	 * append the segment(s)
 	 */
 	*temp_ptr = 0;
@@ -135,9 +150,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_name_segment
+ * FUNCTION:    acpi_ex_name_segment
  *
- * PARAMETERS:  Interpreter_mode    - Current running mode (load1/Load2/Exec)
+ * PARAMETERS:  interpreter_mode    - Current running mode (load1/Load2/Exec)
  *
  * RETURN:      Status
  *
@@ -147,16 +162,16 @@
 
 acpi_status
 acpi_ex_name_segment (
-	u8                      **in_aml_address,
-	NATIVE_CHAR             *name_string)
+	u8                              **in_aml_address,
+	char                            *name_string)
 {
-	u8                      *aml_address = *in_aml_address;
-	acpi_status             status = AE_OK;
-	u32                     index;
-	NATIVE_CHAR             char_buf[5];
+	char                            *aml_address = (void *) *in_aml_address;
+	acpi_status                     status = AE_OK;
+	u32                             index;
+	char                            char_buf[5];
 
 
-	FUNCTION_TRACE ("Ex_name_segment");
+	ACPI_FUNCTION_TRACE ("ex_name_segment");
 
 
 	/*
@@ -172,34 +187,32 @@
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Bytes from stream:\n"));
 
-	for (index = 4;
-		(index > 0) && (acpi_ut_valid_acpi_character (*aml_address));
-		--index) {
-		char_buf[4 - index] = *aml_address++;
-		ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "%c\n", char_buf[4 - index]));
+	for (index = 0;
+		(index < ACPI_NAME_SIZE) && (acpi_ut_valid_acpi_character (*aml_address));
+		index++) {
+		char_buf[index] = *aml_address++;
+		ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "%c\n", char_buf[index]));
 	}
 
 
 	/* Valid name segment  */
 
-	if (0 == index) {
+	if (index == 4) {
 		/* Found 4 valid characters */
 
 		char_buf[4] = '\0';
 
 		if (name_string) {
-			STRCAT (name_string, char_buf);
+			ACPI_STRCAT (name_string, char_buf);
 			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
 				"Appended to - %s \n", name_string));
 		}
-
 		else {
 			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
 				"No Name string - %s \n", char_buf));
 		}
 	}
-
-	else if (4 == index) {
+	else if (index == 0) {
 		/*
 		 * First character was not a valid name character,
 		 * so we are looking at something other than a name.
@@ -209,7 +222,6 @@
 			char_buf[0]));
 		status = AE_CTRL_PENDING;
 	}
-
 	else {
 		/* Segment started with one or more valid characters, but fewer than 4 */
 
@@ -218,16 +230,16 @@
 			*aml_address, aml_address));
 	}
 
-	*in_aml_address = aml_address;
+	*in_aml_address = (u8 *) aml_address;
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_get_name_string
+ * FUNCTION:    acpi_ex_get_name_string
  *
- * PARAMETERS:  Data_type           - Data type to be associated with this name
+ * PARAMETERS:  data_type           - Data type to be associated with this name
  *
  * RETURN:      Status
  *
@@ -235,30 +247,28 @@
  *
  ******************************************************************************/
 
-
 acpi_status
 acpi_ex_get_name_string (
-	acpi_object_type8       data_type,
-	u8                      *in_aml_address,
-	NATIVE_CHAR             **out_name_string,
-	u32                     *out_name_length)
+	acpi_object_type                data_type,
+	u8                              *in_aml_address,
+	char                            **out_name_string,
+	u32                             *out_name_length)
 {
-	acpi_status             status = AE_OK;
-	u8                      *aml_address = in_aml_address;
-	NATIVE_CHAR             *name_string = NULL;
-	u32                     num_segments;
-	u32                     prefix_count = 0;
-	u8                      prefix = 0;
-	u8                      has_prefix = FALSE;
-
-
-	FUNCTION_TRACE_PTR ("Ex_get_name_string", aml_address);
-
-
-	if (INTERNAL_TYPE_REGION_FIELD == data_type  ||
-		INTERNAL_TYPE_BANK_FIELD == data_type    ||
-		INTERNAL_TYPE_INDEX_FIELD == data_type) {
-		/* Disallow prefixes for types associated with Field_unit names */
+	acpi_status                     status = AE_OK;
+	u8                              *aml_address = in_aml_address;
+	char                            *name_string = NULL;
+	u32                             num_segments;
+	u32                             prefix_count = 0;
+	u8                              has_prefix = FALSE;
+
+
+	ACPI_FUNCTION_TRACE_PTR ("ex_get_name_string", aml_address);
+
+
+	if (ACPI_TYPE_LOCAL_REGION_FIELD == data_type  ||
+		ACPI_TYPE_LOCAL_BANK_FIELD == data_type    ||
+		ACPI_TYPE_LOCAL_INDEX_FIELD == data_type) {
+		/* Disallow prefixes for types associated with field_unit names */
 
 		name_string = acpi_ex_allocate_name_string (0, 1);
 		if (!name_string) {
@@ -268,24 +278,22 @@
 			status = acpi_ex_name_segment (&aml_address, name_string);
 		}
 	}
-
 	else {
 		/*
-		 * Data_type is not a field name.
+		 * data_type is not a field name.
 		 * Examine first character of name for root or parent prefix operators
 		 */
 		switch (*aml_address) {
-
 		case AML_ROOT_PREFIX:
 
-			prefix = *aml_address++;
-			ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Root_prefix: %x\n", prefix));
+			ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "root_prefix(\\) at %p\n", aml_address));
 
 			/*
-			 * Remember that we have a Root_prefix --
-			 * see comment in Acpi_ex_allocate_name_string()
+			 * Remember that we have a root_prefix --
+			 * see comment in acpi_ex_allocate_name_string()
 			 */
-			prefix_count = (u32) -1;
+			aml_address++;
+			prefix_count = ACPI_UINT32_MAX;
 			has_prefix = TRUE;
 			break;
 
@@ -295,18 +303,21 @@
 			/* Increment past possibly multiple parent prefixes */
 
 			do {
-				prefix = *aml_address++;
-				ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Parent_prefix: %x\n", prefix));
+				ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "parent_prefix (^) at %p\n", aml_address));
 
-				++prefix_count;
+				aml_address++;
+				prefix_count++;
 
 			} while (*aml_address == AML_PARENT_PREFIX);
+
 			has_prefix = TRUE;
 			break;
 
 
 		default:
 
+			/* Not a prefix character */
+
 			break;
 		}
 
@@ -314,12 +325,11 @@
 		/* Examine first character of name for name segment prefix operator */
 
 		switch (*aml_address) {
-
 		case AML_DUAL_NAME_PREFIX:
 
-			prefix = *aml_address++;
-			ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Dual_name_prefix: %x\n", prefix));
+			ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "dual_name_prefix at %p\n", aml_address));
 
+			aml_address++;
 			name_string = acpi_ex_allocate_name_string (prefix_count, 2);
 			if (!name_string) {
 				status = AE_NO_MEMORY;
@@ -339,12 +349,12 @@
 
 		case AML_MULTI_NAME_PREFIX_OP:
 
-			prefix = *aml_address++;
-			ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Multi_name_prefix: %x\n", prefix));
+			ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "multi_name_prefix at %p\n", aml_address));
 
 			/* Fetch count of segments remaining in name path */
 
-			num_segments = *aml_address++;
+			aml_address++;
+			num_segments = *aml_address;
 
 			name_string = acpi_ex_allocate_name_string (prefix_count, num_segments);
 			if (!name_string) {
@@ -354,11 +364,12 @@
 
 			/* Indicate that we processed a prefix */
 
+			aml_address++;
 			has_prefix = TRUE;
 
 			while (num_segments &&
 					(status = acpi_ex_name_segment (&aml_address, name_string)) == AE_OK) {
-				--num_segments;
+				num_segments--;
 			}
 
 			break;
@@ -366,10 +377,10 @@
 
 		case 0:
 
-			/* Null_name valid as of 8-12-98 ASL/AML Grammar Update */
+			/* null_name valid as of 8-12-98 ASL/AML Grammar Update */
 
-			if (-1 == prefix_count) {
-				ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Name_seg is \"\\\" followed by NULL\n"));
+			if (prefix_count == ACPI_UINT32_MAX) {
+				ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "name_seg is \"\\\" followed by NULL\n"));
 			}
 
 			/* Consume the NULL byte */
@@ -396,20 +407,17 @@
 
 			status = acpi_ex_name_segment (&aml_address, name_string);
 			break;
-
-		}   /* Switch (Peek_op ())   */
+		}
 	}
 
-
 	if (AE_CTRL_PENDING == status && has_prefix) {
 		/* Ran out of segments after processing a prefix */
 
-		REPORT_ERROR (
-			("Ex_do_name: Malformed Name at %p\n", name_string));
+		ACPI_REPORT_ERROR (
+			("ex_do_name: Malformed Name at %p\n", name_string));
 		status = AE_AML_BAD_NAME;
 	}
 
-
 	*out_name_string = name_string;
 	*out_name_length = (u32) (aml_address - in_aml_address);
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exoparg1.c linux-2.4.22-pre2/drivers/acpi/executer/exoparg1.c
--- linux-2.4.21/drivers/acpi/executer/exoparg1.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exoparg1.c	2003-06-26 21:43:32.000000000 +0000
@@ -2,39 +2,57 @@
 /******************************************************************************
  *
  * Module Name: exoparg1 - AML execution - opcodes with 1 argument
- *              $Revision: 120 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "acdispat.h"
-#include "acinterp.h"
-#include "amlcode.h"
-#include "acnamesp.h"
+#include <acpi/acpi.h>
+#include <acpi/acparser.h>
+#include <acpi/acdispat.h>
+#include <acpi/acinterp.h>
+#include <acpi/amlcode.h>
+#include <acpi/acnamesp.h>
 
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exoparg1")
+	 ACPI_MODULE_NAME    ("exoparg1")
 
 
 /*!
@@ -59,12 +77,11 @@
  * fully resolved operands.
 !*/
 
-
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_opcode_1A_0T_0R
+ * FUNCTION:    acpi_ex_opcode_1A_0T_0R
  *
- * PARAMETERS:  Walk_state          - Current state (contains AML opcode)
+ * PARAMETERS:  walk_state          - Current state (contains AML opcode)
  *
  * RETURN:      Status
  *
@@ -75,45 +92,45 @@
 
 acpi_status
 acpi_ex_opcode_1A_0T_0R (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_operand_object     **operand = &walk_state->operands[0];
-	acpi_status             status = AE_OK;
+	union acpi_operand_object       **operand = &walk_state->operands[0];
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE_STR ("Ex_opcode_1A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
+	ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
 
 
-	/* Examine the opcode */
+	/* Examine the AML opcode */
 
 	switch (walk_state->opcode) {
-	case AML_RELEASE_OP:    /*  Release (Mutex_object) */
+	case AML_RELEASE_OP:    /*  Release (mutex_object) */
 
 		status = acpi_ex_release_mutex (operand[0], walk_state);
 		break;
 
 
-	case AML_RESET_OP:      /*  Reset (Event_object) */
+	case AML_RESET_OP:      /*  Reset (event_object) */
 
 		status = acpi_ex_system_reset_event (operand[0]);
 		break;
 
 
-	case AML_SIGNAL_OP:     /*  Signal (Event_object) */
+	case AML_SIGNAL_OP:     /*  Signal (event_object) */
 
 		status = acpi_ex_system_signal_event (operand[0]);
 		break;
 
 
-	case AML_SLEEP_OP:      /*  Sleep (Msec_time) */
+	case AML_SLEEP_OP:      /*  Sleep (msec_time) */
 
-		acpi_ex_system_do_suspend ((u32) operand[0]->integer.value);
+		status = acpi_ex_system_do_suspend ((u32) operand[0]->integer.value);
 		break;
 
 
-	case AML_STALL_OP:      /*  Stall (Usec_time) */
+	case AML_STALL_OP:      /*  Stall (usec_time) */
 
-		acpi_ex_system_do_stall ((u32) operand[0]->integer.value);
+		status = acpi_ex_system_do_stall ((u32) operand[0]->integer.value);
 		break;
 
 
@@ -125,7 +142,7 @@
 
 	default:                /*  Unknown opcode  */
 
-		REPORT_ERROR (("Acpi_ex_opcode_1A_0T_0R: Unknown opcode %X\n",
+		ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_0T_0R: Unknown opcode %X\n",
 			walk_state->opcode));
 		status = AE_AML_BAD_OPCODE;
 		break;
@@ -137,9 +154,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_opcode_1A_1T_0R
+ * FUNCTION:    acpi_ex_opcode_1A_1T_0R
  *
- * PARAMETERS:  Walk_state          - Current state (contains AML opcode)
+ * PARAMETERS:  walk_state          - Current state (contains AML opcode)
  *
  * RETURN:      Status
  *
@@ -150,25 +167,26 @@
 
 acpi_status
 acpi_ex_opcode_1A_1T_0R (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status = AE_OK;
-	acpi_operand_object     **operand = &walk_state->operands[0];
+	acpi_status                     status = AE_OK;
+	union acpi_operand_object       **operand = &walk_state->operands[0];
 
 
-	FUNCTION_TRACE_STR ("Ex_opcode_1A_1T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
+	ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
 
 
-	switch (walk_state->opcode) {
+	/* Examine the AML opcode */
 
+	switch (walk_state->opcode) {
 	case AML_LOAD_OP:
 
-		status = acpi_ex_load_op (operand[0], operand[1]);
+		status = acpi_ex_load_op (operand[0], operand[1], walk_state);
 		break;
 
 	default:                        /* Unknown opcode */
 
-		REPORT_ERROR (("Acpi_ex_opcode_1A_1T_0R: Unknown opcode %X\n",
+		ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_1T_0R: Unknown opcode %X\n",
 			walk_state->opcode));
 		status = AE_AML_BAD_OPCODE;
 		goto cleanup;
@@ -183,9 +201,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_opcode_1A_1T_1R
+ * FUNCTION:    acpi_ex_opcode_1A_1T_1R
  *
- * PARAMETERS:  Walk_state          - Current state (contains AML opcode)
+ * PARAMETERS:  walk_state          - Current state (contains AML opcode)
  *
  * RETURN:      Status
  *
@@ -196,22 +214,22 @@
 
 acpi_status
 acpi_ex_opcode_1A_1T_1R (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status = AE_OK;
-	acpi_operand_object     **operand = &walk_state->operands[0];
-	acpi_operand_object     *return_desc = NULL;
-	acpi_operand_object     *return_desc2 = NULL;
-	u32                     temp32;
-	u32                     i;
-	u32                     j;
-	acpi_integer            digit;
+	acpi_status                     status = AE_OK;
+	union acpi_operand_object       **operand = &walk_state->operands[0];
+	union acpi_operand_object       *return_desc = NULL;
+	union acpi_operand_object       *return_desc2 = NULL;
+	u32                             temp32;
+	u32                             i;
+	u32                             power_of_ten;
+	acpi_integer                    digit;
 
 
-	FUNCTION_TRACE_STR ("Ex_opcode_1A_1T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
+	ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
 
 
-	/* Create a return object of type Integer for most opcodes */
+	/* Examine the AML opcode */
 
 	switch (walk_state->opcode) {
 	case AML_BIT_NOT_OP:
@@ -221,156 +239,162 @@
 	case AML_TO_BCD_OP:
 	case AML_COND_REF_OF_OP:
 
+		/* Create a return object of type Integer for these opcodes */
+
 		return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
 		if (!return_desc) {
 			status = AE_NO_MEMORY;
 			goto cleanup;
 		}
 
-		break;
-	}
+		switch (walk_state->opcode) {
+		case AML_BIT_NOT_OP:            /* Not (Operand, Result)  */
 
+			return_desc->integer.value = ~operand[0]->integer.value;
+			break;
 
-	switch (walk_state->opcode) {
 
-	case AML_BIT_NOT_OP:            /* Not (Operand, Result)  */
+		case AML_FIND_SET_LEFT_BIT_OP:  /* find_set_left_bit (Operand, Result) */
 
-		return_desc->integer.value = ~operand[0]->integer.value;
-		break;
+			return_desc->integer.value = operand[0]->integer.value;
 
+			/*
+			 * 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) {
+				return_desc->integer.value >>= 1;
+			}
 
-	case AML_FIND_SET_LEFT_BIT_OP:  /* Find_set_left_bit (Operand, Result) */
+			return_desc->integer.value = temp32;
+			break;
 
 
-		return_desc->integer.value = operand[0]->integer.value;
+		case AML_FIND_SET_RIGHT_BIT_OP: /* find_set_right_bit (Operand, Result) */
 
-		/*
-		 * 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) {
-			return_desc->integer.value >>= 1;
-		}
+			return_desc->integer.value = operand[0]->integer.value;
 
-		return_desc->integer.value = temp32;
-		break;
+			/*
+			 * 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) {
+				return_desc->integer.value <<= 1;
+			}
 
+			/* Since the bit position is one-based, subtract from 33 (65) */
 
-	case AML_FIND_SET_RIGHT_BIT_OP: /* Find_set_right_bit (Operand, Result) */
+			return_desc->integer.value = temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - temp32;
+			break;
 
 
-		return_desc->integer.value = operand[0]->integer.value;
+		case AML_FROM_BCD_OP:           /* from_bcd (BCDValue, Result) */
 
-		/*
-		 * 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) {
-			return_desc->integer.value <<= 1;
-		}
+			/*
+			 * The 64-bit ACPI integer can hold 16 4-bit BCD characters
+			 * (if table is 32-bit, integer can hold 8 BCD characters)
+			 * Convert each 4-bit BCD value
+			 */
+			power_of_ten = 1;
+			return_desc->integer.value = 0;
+			digit = operand[0]->integer.value;
 
-		/* Since the bit position is one-based, subtract from 33 (65) */
+			/* Convert each BCD digit (each is one nybble wide) */
 
-		return_desc->integer.value = temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - temp32;
-		break;
+			for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) {
+				/* Get the least significant 4-bit BCD digit */
 
+				temp32 = ((u32) digit) & 0xF;
 
-	case AML_FROM_BCD_OP:           /* From_bcd (BCDValue, Result) */
+				/* Check the range of the digit */
 
-		/*
-		 * The 64-bit ACPI integer can hold 16 4-bit BCD integers
-		 */
-		return_desc->integer.value = 0;
-		for (i = 0; i < ACPI_MAX_BCD_DIGITS; i++) {
-			/* Get one BCD digit */
+				if (temp32 > 9) {
+					ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+						"BCD digit too large (not decimal): 0x%X\n",
+						temp32));
 
-			digit = (acpi_integer) ((operand[0]->integer.value >> (i * 4)) & 0xF);
+					status = AE_AML_NUMERIC_OVERFLOW;
+					goto cleanup;
+				}
 
-			/* Check the range of the digit */
+				/* Sum the digit into the result with the current power of 10 */
 
-			if (digit > 9) {
-				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "BCD digit too large: %d\n",
-					(u32) digit));
-				status = AE_AML_NUMERIC_OVERFLOW;
-				goto cleanup;
-			}
+				return_desc->integer.value += (((acpi_integer) temp32) * power_of_ten);
 
-			if (digit > 0) {
-				/* Sum into the result with the appropriate power of 10 */
+				/* Shift to next BCD digit */
 
-				for (j = 0; j < i; j++) {
-					digit *= 10;
-				}
+				digit >>= 4;
 
-				return_desc->integer.value += digit;
+				/* Next power of 10 */
+
+				power_of_ten *= 10;
 			}
-		}
-		break;
+			break;
 
 
-	case AML_TO_BCD_OP:             /* To_bcd (Operand, Result) */
+		case AML_TO_BCD_OP:             /* to_bcd (Operand, Result) */
 
-		if (operand[0]->integer.value > ACPI_MAX_BCD_VALUE) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "BCD overflow: %8.8X%8.8X\n",
-				HIDWORD(operand[0]->integer.value), LODWORD(operand[0]->integer.value)));
-			status = AE_AML_NUMERIC_OVERFLOW;
-			goto cleanup;
-		}
+			return_desc->integer.value = 0;
+			digit = operand[0]->integer.value;
 
-		return_desc->integer.value = 0;
-		for (i = 0; i < ACPI_MAX_BCD_DIGITS; i++) {
-			/* Divide by nth factor of 10 */
+			/* Each BCD digit is one nybble wide */
 
-			temp32 = 0;
-			digit = operand[0]->integer.value;
-			for (j = 0; j < i; j++) {
-				acpi_ut_short_divide (&digit, 10, &digit, &temp32);
+			for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) {
+				(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));
 			}
 
-			/* Create the BCD digit from the remainder above */
+			/* Overflow if there is any data left in Digit */
 
 			if (digit > 0) {
-				return_desc->integer.value += (temp32 << (i * 4));
+				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Integer too large to convert to BCD: %8.8X%8.8X\n",
+					ACPI_HIDWORD(operand[0]->integer.value),
+					ACPI_LODWORD(operand[0]->integer.value)));
+				status = AE_AML_NUMERIC_OVERFLOW;
+				goto cleanup;
 			}
-		}
-		break;
+			break;
 
 
-	case AML_COND_REF_OF_OP:        /* Cond_ref_of (Source_object, Result) */
+		case AML_COND_REF_OF_OP:        /* cond_ref_of (source_object, Result) */
 
-		/*
-		 * This op is a little strange because the internal return value is
-		 * different than the return value stored in the result descriptor
-		 * (There are really two return values)
-		 */
-		if ((acpi_namespace_node *) operand[0] == acpi_gbl_root_node) {
 			/*
-			 * This means that the object does not exist in the namespace,
-			 * return FALSE
+			 * This op is a little strange because the internal return value is
+			 * different than the return value stored in the result descriptor
+			 * (There are really two return values)
 			 */
-			return_desc->integer.value = 0;
+			if ((struct acpi_namespace_node *) operand[0] == acpi_gbl_root_node) {
+				/*
+				 * This means that the object does not exist in the namespace,
+				 * return FALSE
+				 */
+				return_desc->integer.value = 0;
+				goto cleanup;
+			}
 
-			/*
-			 * Must delete the result descriptor since there is no reference
-			 * being returned
-			 */
-			acpi_ut_remove_reference (operand[1]);
-			goto cleanup;
-		}
+			/* Get the object reference, store it, and remove our reference */
 
-		/* Get the object reference and store it */
+			status = acpi_ex_get_object_reference (operand[0], &return_desc2, walk_state);
+			if (ACPI_FAILURE (status)) {
+				goto cleanup;
+			}
 
-		status = acpi_ex_get_object_reference (operand[0], &return_desc2, walk_state);
-		if (ACPI_FAILURE (status)) {
-			goto cleanup;
-		}
+			status = acpi_ex_store (return_desc2, operand[1], walk_state);
+			acpi_ut_remove_reference (return_desc2);
 
-		status = acpi_ex_store (return_desc2, operand[1], walk_state);
+			/* The object exists in the namespace, return TRUE */
 
-		/* The object exists in the namespace, return TRUE */
+			return_desc->integer.value = ACPI_INTEGER_MAX;
+			goto cleanup;
 
-		return_desc->integer.value = ACPI_INTEGER_MAX;
-		goto cleanup;
+
+		default:
+			/* No other opcodes get here */
+			break;
+		}
 		break;
 
 
@@ -386,16 +410,19 @@
 			return_ACPI_STATUS (status);
 		}
 
-		/*
-		 * Normally, we would remove a reference on the Operand[0] parameter;
-		 * But since it is being used as the internal return object
-		 * (meaning we would normally increment it), the two cancel out,
-		 * and we simply don't do anything.
-		 */
-		walk_state->result_obj = operand[0];
-		walk_state->operands[0] = NULL; /* Prevent deletion */
+		/* It is possible that the Store already produced a return object */
+
+		if (!walk_state->result_obj) {
+			/*
+			 * Normally, we would remove a reference on the Operand[0] parameter;
+			 * But since it is being used as the internal return object
+			 * (meaning we would normally increment it), the two cancel out,
+			 * and we simply don't do anything.
+			 */
+			walk_state->result_obj = operand[0];
+			walk_state->operands[0] = NULL; /* Prevent deletion */
+		}
 		return_ACPI_STATUS (status);
-		break;
 
 
 	/*
@@ -403,58 +430,54 @@
 	 */
 	case AML_COPY_OP:               /* Copy (Source, Target) */
 
-		status = AE_NOT_IMPLEMENTED;
-		goto cleanup;
+		status = acpi_ut_copy_iobject_to_iobject (operand[0], &return_desc, walk_state);
 		break;
 
 
-	case AML_TO_DECSTRING_OP:       /* To_decimal_string (Data, Result) */
+	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);
 		break;
 
 
-	case AML_TO_HEXSTRING_OP:       /* To_hex_string (Data, Result) */
+	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);
 		break;
 
 
-	case AML_TO_BUFFER_OP:          /* To_buffer (Data, Result) */
+	case AML_TO_BUFFER_OP:          /* to_buffer (Data, Result) */
 
 		status = acpi_ex_convert_to_buffer (operand[0], &return_desc, walk_state);
 		break;
 
 
-	case AML_TO_INTEGER_OP:         /* To_integer (Data, Result) */
+	case AML_TO_INTEGER_OP:         /* to_integer (Data, Result) */
 
 		status = acpi_ex_convert_to_integer (operand[0], &return_desc, walk_state);
 		break;
 
 
-	/*
-	 * These are two obsolete opcodes
-	 */
-	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)));
 		status = AE_SUPPORT;
 		goto cleanup;
-		break;
 
 
 	default:                        /* Unknown opcode */
 
-		REPORT_ERROR (("Acpi_ex_opcode_1A_1T_1R: Unknown opcode %X\n",
+		ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_1T_1R: Unknown opcode %X\n",
 			walk_state->opcode));
 		status = AE_AML_BAD_OPCODE;
 		goto cleanup;
 	}
 
-
 	/*
 	 * Store the return value computed above into the target object
 	 */
@@ -463,7 +486,9 @@
 
 cleanup:
 
-	walk_state->result_obj = return_desc;
+	if (!walk_state->result_obj) {
+		walk_state->result_obj = return_desc;
+	}
 
 	/* Delete return object on error */
 
@@ -477,9 +502,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_opcode_1A_0T_1R
+ * FUNCTION:    acpi_ex_opcode_1A_0T_1R
  *
- * PARAMETERS:  Walk_state          - Current state (contains AML opcode)
+ * PARAMETERS:  walk_state          - Current state (contains AML opcode)
  *
  * RETURN:      Status
  *
@@ -489,23 +514,22 @@
 
 acpi_status
 acpi_ex_opcode_1A_0T_1R (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_operand_object     **operand = &walk_state->operands[0];
-	acpi_operand_object     *temp_desc;
-	acpi_operand_object     *return_desc = NULL;
-	acpi_status             status = AE_OK;
-	u32                     type;
-	acpi_integer            value;
+	union acpi_operand_object       **operand = &walk_state->operands[0];
+	union acpi_operand_object       *temp_desc;
+	union acpi_operand_object       *return_desc = NULL;
+	acpi_status                     status = AE_OK;
+	u32                             type;
+	acpi_integer                    value;
 
 
-	FUNCTION_TRACE_STR ("Ex_opcode_1A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
+	ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
 
 
-	/* Get the operand and decode the opcode */
+	/* Examine the AML opcode */
 
 	switch (walk_state->opcode) {
-
 	case AML_LNOT_OP:               /* LNot (Operand) */
 
 		return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
@@ -523,18 +547,18 @@
 
 		/*
 		 * Since we are expecting a Reference operand, it
-		 * can be either a Node or an internal object.
+		 * can be either a NS Node or an internal object.
 		 */
 		return_desc = operand[0];
-		if (VALID_DESCRIPTOR_TYPE (operand[0], ACPI_DESC_TYPE_INTERNAL)) {
+		if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) == ACPI_DESC_TYPE_OPERAND) {
 			/* Internal reference object - prevent deletion */
 
 			acpi_ut_add_reference (return_desc);
 		}
 
 		/*
-		 * Convert the Return_desc Reference to a Number
-		 * (This removes a reference on the Return_desc object)
+		 * Convert the return_desc Reference to a Number
+		 * (This removes a reference on the return_desc object)
 		 */
 		status = acpi_ex_resolve_operands (AML_LNOT_OP, &return_desc, walk_state);
 		if (ACPI_FAILURE (status)) {
@@ -545,7 +569,7 @@
 		}
 
 		/*
-		 * Return_desc is now guaranteed to be an Integer object
+		 * return_desc is now guaranteed to be an Integer object
 		 * Do the actual increment or decrement
 		 */
 		if (AML_INCREMENT_OP == walk_state->opcode) {
@@ -561,83 +585,13 @@
 		break;
 
 
-	case AML_TYPE_OP:               /* Object_type (Source_object) */
-
-		if (INTERNAL_TYPE_REFERENCE == operand[0]->common.type) {
-			/*
-			 * Not a Name -- an indirect name pointer would have
-			 * been converted to a direct name pointer in Resolve_operands
-			 */
-			switch (operand[0]->reference.opcode) {
-			case AML_ZERO_OP:
-			case AML_ONE_OP:
-			case AML_ONES_OP:
-			case AML_REVISION_OP:
-
-				/* Constants are of type Integer */
-
-				type = ACPI_TYPE_INTEGER;
-				break;
-
+	case AML_TYPE_OP:               /* object_type (source_object) */
 
-			case AML_DEBUG_OP:
-
-				/* Per 1.0b spec, Debug object is of type "Debug_object" */
-
-				type = ACPI_TYPE_DEBUG_OBJECT;
-				break;
-
-
-			case AML_INDEX_OP:
-
-				/* Get the type of this reference (index into another object) */
-
-				type = operand[0]->reference.target_type;
-				if (type == ACPI_TYPE_PACKAGE) {
-					/*
-					 * The main object is a package, we want to get the type
-					 * of the individual package element that is referenced by
-					 * the index.
-					 */
-					type = (*(operand[0]->reference.where))->common.type;
-				}
-
-				break;
-
-
-			case AML_LOCAL_OP:
-			case AML_ARG_OP:
-
-				type = acpi_ds_method_data_get_type (operand[0]->reference.opcode,
-						  operand[0]->reference.offset, walk_state);
-				break;
-
-
-			default:
-
-				REPORT_ERROR (("Acpi_ex_opcode_1A_0T_1R/Type_op: Internal error - Unknown Reference subtype %X\n",
-					operand[0]->reference.opcode));
-				status = AE_AML_INTERNAL;
-				goto cleanup;
-			}
-		}
-
-		else {
-			/*
-			 * It's not a Reference, so it must be a direct name pointer.
-			 */
-			type = acpi_ns_get_type ((acpi_namespace_node *) operand[0]);
-
-			/* Convert internal types to external types */
-
-			switch (type) {
-			case INTERNAL_TYPE_REGION_FIELD:
-			case INTERNAL_TYPE_BANK_FIELD:
-			case INTERNAL_TYPE_INDEX_FIELD:
-
-				type = ACPI_TYPE_FIELD_UNIT;
-			}
+		/* 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. */
@@ -652,44 +606,38 @@
 		break;
 
 
-	case AML_SIZE_OF_OP:            /* Size_of (Source_object) */
+	case AML_SIZE_OF_OP:            /* size_of (source_object) */
 
-		temp_desc = operand[0];
-		if (VALID_DESCRIPTOR_TYPE (operand[0], ACPI_DESC_TYPE_NAMED)) {
-			temp_desc = acpi_ns_get_attached_object ((acpi_namespace_node *) operand[0]);
-		}
+		/* Get the base object */
 
-		if (!temp_desc) {
-			value = 0;
+		status = acpi_ex_resolve_multiple (walk_state, operand[0], &type, &temp_desc);
+		if (ACPI_FAILURE (status)) {
+			goto cleanup;
 		}
 
-		else {
-			switch (temp_desc->common.type) {
-			case ACPI_TYPE_BUFFER:
-				value = temp_desc->buffer.length;
-				break;
-
-			case ACPI_TYPE_STRING:
-				value = temp_desc->string.length;
-				break;
-
-			case ACPI_TYPE_PACKAGE:
-				value = temp_desc->package.count;
-				break;
-
-			case INTERNAL_TYPE_REFERENCE:
-
-				/* TBD: this must be a reference to a buf/str/pkg?? */
-
-				value = 4;
-				break;
-
-			default:
-				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Not Buf/Str/Pkg - found type %X\n",
-					temp_desc->common.type));
-				status = AE_AML_OPERAND_TYPE;
-				goto cleanup;
-			}
+		/*
+		 * 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.)
+		 */
+		switch (type) {
+		case ACPI_TYPE_BUFFER:
+			value = temp_desc->buffer.length;
+			break;
+
+		case ACPI_TYPE_STRING:
+			value = temp_desc->string.length;
+			break;
+
+		case ACPI_TYPE_PACKAGE:
+			value = temp_desc->package.count;
+			break;
+
+		default:
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "size_of, Not Buf/Str/Pkg - found type %s\n",
+				acpi_ut_get_type_name (type)));
+			status = AE_AML_OPERAND_TYPE;
+			goto cleanup;
 		}
 
 		/*
@@ -706,7 +654,7 @@
 		break;
 
 
-	case AML_REF_OF_OP:             /* Ref_of (Source_object) */
+	case AML_REF_OF_OP:             /* ref_of (source_object) */
 
 		status = acpi_ex_get_object_reference (operand[0], &return_desc, walk_state);
 		if (ACPI_FAILURE (status)) {
@@ -715,79 +663,113 @@
 		break;
 
 
-	case AML_DEREF_OF_OP:           /* Deref_of (Obj_reference) */
+	case AML_DEREF_OF_OP:           /* deref_of (obj_reference | String) */
 
-		/* Check for a method local or argument */
+		/* Check for a method local or argument, or standalone String */
 
-		if (!VALID_DESCRIPTOR_TYPE (operand[0], ACPI_DESC_TYPE_NAMED)) {
-			/*
-			 * Must resolve/dereference the local/arg reference first
-			 */
-			switch (operand[0]->reference.opcode) {
-			/* Set Operand[0] to the value of the local/arg */
+		if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) != ACPI_DESC_TYPE_NAMED) {
+			switch (ACPI_GET_OBJECT_TYPE (operand[0])) {
+			case ACPI_TYPE_LOCAL_REFERENCE:
+				/*
+				 * This is a deref_of (local_x | arg_x)
+				 *
+				 * Must resolve/dereference the local/arg reference first
+				 */
+				switch (operand[0]->reference.opcode) {
+				case AML_LOCAL_OP:
+				case AML_ARG_OP:
+
+					/* Set Operand[0] to the value of the local/arg */
+
+					status = acpi_ds_method_data_get_value (operand[0]->reference.opcode,
+							 operand[0]->reference.offset, walk_state, &temp_desc);
+					if (ACPI_FAILURE (status)) {
+						goto cleanup;
+					}
 
-			case AML_LOCAL_OP:
-			case AML_ARG_OP:
+					/*
+					 * Delete our reference to the input object and
+					 * point to the object just retrieved
+					 */
+					acpi_ut_remove_reference (operand[0]);
+					operand[0] = temp_desc;
+					break;
 
-				acpi_ds_method_data_get_value (operand[0]->reference.opcode,
-						operand[0]->reference.offset, walk_state, &temp_desc);
+				case AML_REF_OF_OP:
 
-				/*
-				 * Delete our reference to the input object and
-				 * point to the object just retrieved
-				 */
-				acpi_ut_remove_reference (operand[0]);
-				operand[0] = temp_desc;
-				break;
+					/* Get the object to which the reference refers */
 
-			default:
+					temp_desc = operand[0]->reference.object;
+					acpi_ut_remove_reference (operand[0]);
+					operand[0] = temp_desc;
+					break;
 
-				/* Index op - handled below */
-				break;
-			}
-		}
+				default:
 
+					/* Must be an Index op - handled below */
+					break;
+				}
+				break;
 
-		/* Operand[0] may have changed from the code above */
 
-		if (VALID_DESCRIPTOR_TYPE (operand[0], ACPI_DESC_TYPE_NAMED)) {
-			/* Get the actual object from the Node (This is the dereference) */
+			case ACPI_TYPE_STRING:
 
-			return_desc = ((acpi_namespace_node *) operand[0])->object;
+				/*
+				 * This is a deref_of (String). The string is a reference to a named ACPI object.
+				 *
+				 * 1) Find the owning Node
+				 * 2) Dereference the node to an actual object.  Could be a Field, so we nee
+				 *    to resolve the node to a value.
+				 */
+				status = acpi_ns_get_node_by_path (operand[0]->string.pointer,
+						  walk_state->scope_info->scope.node, ACPI_NS_SEARCH_PARENT,
+						  ACPI_CAST_INDIRECT_PTR (struct acpi_namespace_node, &return_desc));
+				if (ACPI_FAILURE (status)) {
+					goto cleanup;
+				}
 
-			/* Returning a pointer to the object, add another reference! */
+				status = acpi_ex_resolve_node_to_value (
+						  ACPI_CAST_INDIRECT_PTR (struct acpi_namespace_node, &return_desc), walk_state);
+				goto cleanup;
 
-			acpi_ut_add_reference (return_desc);
-		}
 
-		else {
-			/*
-			 * This must be a reference object produced by the Index
-			 * ASL operation -- check internal opcode
-			 */
-			if ((operand[0]->reference.opcode != AML_INDEX_OP) &&
-				(operand[0]->reference.opcode != AML_REF_OF_OP)) {
-				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode in ref(%p) - %X\n",
-					operand[0], operand[0]->reference.opcode));
+			default:
 
-				status = AE_TYPE;
+				status = AE_AML_OPERAND_TYPE;
 				goto cleanup;
 			}
+		}
 
+		/* Operand[0] may have changed from the code above */
 
+		if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) == ACPI_DESC_TYPE_NAMED) {
+			/*
+			 * This is a deref_of (object_reference)
+			 * Get the actual object from the Node (This is the dereference).
+			 * -- This case may only happen when a local_x or arg_x is dereferenced above.
+			 */
+			return_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) operand[0]);
+		}
+		else {
+			/*
+			 * This must be a reference object produced by either the Index() or
+			 * ref_of() operator
+			 */
 			switch (operand[0]->reference.opcode) {
 			case AML_INDEX_OP:
 
 				/*
-				 * Supported target types for the Index operator are
-				 * 1) A Buffer
-				 * 2) A Package
+				 * The target type for the Index operator must be
+				 * either a Buffer or a Package
 				 */
-				if (operand[0]->reference.target_type == ACPI_TYPE_BUFFER_FIELD) {
+				switch (operand[0]->reference.target_type) {
+				case ACPI_TYPE_BUFFER_FIELD:
+
+					temp_desc = operand[0]->reference.object;
+
 					/*
-					 * The target is a buffer, we must create a new object that
-					 * contains one element of the buffer, the element pointed
-					 * to by the index.
+					 * Create a new object that contains one element of the
+					 * buffer -- the element pointed to by the index.
 					 *
 					 * NOTE: index into a buffer is NOT a pointer to a
 					 * sub-buffer of the main buffer, it is only a pointer to a
@@ -799,20 +781,21 @@
 						goto cleanup;
 					}
 
-					temp_desc = operand[0]->reference.object;
+					/*
+					 * Since we are returning the value of the buffer at the
+					 * indexed location, we don't need to add an additional
+					 * reference to the buffer itself.
+					 */
 					return_desc->integer.value =
 						temp_desc->buffer.pointer[operand[0]->reference.offset];
+					break;
 
-					/* TBD: [Investigate] (see below) Don't add an additional
-					 * ref!
-					 */
-				}
 
-				else if (operand[0]->reference.target_type == ACPI_TYPE_PACKAGE) {
+				case ACPI_TYPE_PACKAGE:
+
 					/*
-					 * The target is a package, we want to return the referenced
-					 * element of the package.  We must add another reference to
-					 * this object, however.
+					 * Return the referenced element of the package.  We must add
+					 * another reference to the referenced object, however.
 					 */
 					return_desc = *(operand[0]->reference.where);
 					if (!return_desc) {
@@ -821,7 +804,6 @@
 						 * an uninitialized package element and is thus a
 						 * severe error.
 						 */
-
 						ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "NULL package element obj %p\n",
 							operand[0]));
 						status = AE_AML_UNINITIALIZED_ELEMENT;
@@ -829,15 +811,16 @@
 					}
 
 					acpi_ut_add_reference (return_desc);
-				}
+					break;
+
+
+				default:
 
-				else {
-					ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown 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;
 				}
-
 				break;
 
 
@@ -845,19 +828,31 @@
 
 				return_desc = operand[0]->reference.object;
 
+				if (ACPI_GET_DESCRIPTOR_TYPE (return_desc) == ACPI_DESC_TYPE_NAMED) {
+
+					return_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) return_desc);
+				}
+
 				/* Add another reference to the object! */
 
 				acpi_ut_add_reference (return_desc);
 				break;
+
+
+			default:
+				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode in ref(%p) - %X\n",
+					operand[0], operand[0]->reference.opcode));
+
+				status = AE_TYPE;
+				goto cleanup;
 			}
 		}
-
 		break;
 
 
 	default:
 
-		REPORT_ERROR (("Acpi_ex_opcode_1A_0T_1R: Unknown opcode %X\n",
+		ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_0T_1R: Unknown opcode %X\n",
 			walk_state->opcode));
 		status = AE_AML_BAD_OPCODE;
 		goto cleanup;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exoparg2.c linux-2.4.22-pre2/drivers/acpi/executer/exoparg2.c
--- linux-2.4.21/drivers/acpi/executer/exoparg2.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exoparg2.c	2003-06-26 21:43:22.000000000 +0000
@@ -1,40 +1,56 @@
 /******************************************************************************
  *
  * Module Name: exoparg2 - AML execution - opcodes with 2 arguments
- *              $Revision: 97 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "acnamesp.h"
-#include "acinterp.h"
-#include "acevents.h"
-#include "amlcode.h"
-#include "acdispat.h"
+#include <acpi/acpi.h>
+#include <acpi/acparser.h>
+#include <acpi/acinterp.h>
+#include <acpi/acevents.h>
+#include <acpi/amlcode.h>
 
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exoparg2")
+	 ACPI_MODULE_NAME    ("exoparg2")
 
 
 /*!
@@ -62,9 +78,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_opcode_2A_0T_0R
+ * FUNCTION:    acpi_ex_opcode_2A_0T_0R
  *
- * PARAMETERS:  Walk_state          - Current walk state
+ * PARAMETERS:  walk_state          - Current walk state
  *
  * RETURN:      Status
  *
@@ -77,57 +93,52 @@
 
 acpi_status
 acpi_ex_opcode_2A_0T_0R (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_operand_object     **operand = &walk_state->operands[0];
-	acpi_namespace_node     *node;
-	acpi_status             status = AE_OK;
+	union acpi_operand_object       **operand = &walk_state->operands[0];
+	struct acpi_namespace_node      *node;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE_STR ("Ex_opcode_2A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
+	ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_0T_0R",
+			acpi_ps_get_opcode_name (walk_state->opcode));
 
 
 	/* Examine the opcode */
 
 	switch (walk_state->opcode) {
-
-	case AML_NOTIFY_OP:         /* Notify (Notify_object, Notify_value) */
+	case AML_NOTIFY_OP:         /* Notify (notify_object, notify_value) */
 
 		/* The first operand is a namespace node */
 
-		node = (acpi_namespace_node *) operand[0];
+		node = (struct acpi_namespace_node *) operand[0];
 
-		/* The node must refer to a device or thermal zone */
+		/* Notifies allowed on this object? */
 
-		if (node && operand[1])     /* TBD: is this check necessary? */ {
-			switch (node->type) {
-			case ACPI_TYPE_DEVICE:
-			case ACPI_TYPE_THERMAL:
-
-				/*
-				 * Dispatch the notify to the appropriate handler
-				 * NOTE: the request is queued for execution after this method
-				 * completes.  The notify handlers are NOT invoked synchronously
-				 * from this thread -- because handlers may in turn run other
-				 * control methods.
-				 */
-				status = acpi_ev_queue_notify_request (node,
-						 (u32) operand[1]->integer.value);
-				break;
-
-			default:
-				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unexpected notify object type %X\n",
-					node->type));
+		if (!acpi_ev_is_notify_object (node)) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unexpected notify object type [%s]\n",
+					acpi_ut_get_type_name (node->type)));
 
-				status = AE_AML_OPERAND_TYPE;
-				break;
-			}
+			status = AE_AML_OPERAND_TYPE;
+			break;
 		}
+
+		/*
+		 * Dispatch the notify to the appropriate handler
+		 * NOTE: the request is queued for execution after this method
+		 * completes.  The notify handlers are NOT invoked synchronously
+		 * from this thread -- because handlers may in turn run other
+		 * control methods.
+		 */
+		status = acpi_ev_queue_notify_request (node,
+				  (u32) operand[1]->integer.value);
 		break;
 
+
 	default:
 
-		REPORT_ERROR (("Acpi_ex_opcode_2A_0T_0R: Unknown opcode %X\n", walk_state->opcode));
+		ACPI_REPORT_ERROR (("acpi_ex_opcode_2A_0T_0R: Unknown opcode %X\n",
+				walk_state->opcode));
 		status = AE_AML_BAD_OPCODE;
 	}
 
@@ -137,9 +148,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_opcode_2A_2T_1R
+ * FUNCTION:    acpi_ex_opcode_2A_2T_1R
  *
- * PARAMETERS:  Walk_state          - Current walk state
+ * PARAMETERS:  walk_state          - Current walk state
  *
  * RETURN:      Status
  *
@@ -150,22 +161,22 @@
 
 acpi_status
 acpi_ex_opcode_2A_2T_1R (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_operand_object     **operand = &walk_state->operands[0];
-	acpi_operand_object     *return_desc1 = NULL;
-	acpi_operand_object     *return_desc2 = NULL;
-	acpi_status             status;
+	union acpi_operand_object       **operand = &walk_state->operands[0];
+	union acpi_operand_object       *return_desc1 = NULL;
+	union acpi_operand_object       *return_desc2 = NULL;
+	acpi_status                     status;
 
 
-	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));
 
 
 	/*
 	 * Execute the opcode
 	 */
 	switch (walk_state->opcode) {
-	case AML_DIVIDE_OP:             /* Divide (Dividend, Divisor, Remainder_result Quotient_result) */
+	case AML_DIVIDE_OP:             /* Divide (Dividend, Divisor, remainder_result quotient_result) */
 
 		return_desc1 = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
 		if (!return_desc1) {
@@ -179,7 +190,7 @@
 			goto cleanup;
 		}
 
-		/* Quotient to Return_desc1, remainder to Return_desc2 */
+		/* 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);
@@ -191,11 +202,10 @@
 
 	default:
 
-		REPORT_ERROR (("Acpi_ex_opcode_2A_2T_1R: Unknown opcode %X\n",
+		ACPI_REPORT_ERROR (("acpi_ex_opcode_2A_2T_1R: Unknown opcode %X\n",
 				walk_state->opcode));
 		status = AE_AML_BAD_OPCODE;
 		goto cleanup;
-		break;
 	}
 
 
@@ -235,9 +245,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_opcode_2A_1T_1R
+ * FUNCTION:    acpi_ex_opcode_2A_1T_1R
  *
- * PARAMETERS:  Walk_state          - Current walk state
+ * PARAMETERS:  walk_state          - Current walk state
  *
  * RETURN:      Status
  *
@@ -248,16 +258,17 @@
 
 acpi_status
 acpi_ex_opcode_2A_1T_1R (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_operand_object     **operand   = &walk_state->operands[0];
-	acpi_operand_object     *return_desc = NULL;
-	acpi_operand_object     *temp_desc;
-	u32                     index;
-	acpi_status             status      = AE_OK;
+	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;
 
 
-	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));
 
 
 	/*
@@ -280,7 +291,7 @@
 
 
 	switch (walk_state->opcode) {
-	case AML_MOD_OP:                /* Mod (Dividend, Divisor, Remainder_result (ACPI 2.0) */
+	case AML_MOD_OP:                /* Mod (Dividend, Divisor, remainder_result (ACPI 2.0) */
 
 		return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
 		if (!return_desc) {
@@ -288,11 +299,10 @@
 			goto cleanup;
 		}
 
-		/* Return_desc will contain the remainder */
+		/* return_desc will contain the remainder */
 
 		status = acpi_ut_divide (&operand[0]->integer.value, &operand[1]->integer.value,
 				  NULL, &return_desc->integer.value);
-
 		break;
 
 
@@ -305,17 +315,17 @@
 		 * guaranteed to be either Integer/String/Buffer by the operand
 		 * resolution mechanism above.
 		 */
-		switch (operand[0]->common.type) {
+		switch (ACPI_GET_OBJECT_TYPE (operand[0])) {
 		case ACPI_TYPE_INTEGER:
-			status = acpi_ex_convert_to_integer (operand[1], &operand[1], walk_state);
+			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], &operand[1], 16, ACPI_UINT32_MAX, walk_state);
+			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], &operand[1], walk_state);
+			status = acpi_ex_convert_to_buffer (operand[1], &temp_desc, walk_state);
 			break;
 
 		default:
@@ -331,20 +341,69 @@
 		 * (Both are Integer, String, or Buffer), and we can now perform the
 		 * concatenation.
 		 */
-		status = acpi_ex_do_concatenate (operand[0], operand[1], &return_desc, walk_state);
+		status = acpi_ex_do_concatenate (operand[0], temp_desc, &return_desc, walk_state);
+		if (temp_desc != operand[1]) {
+			acpi_ut_remove_reference (temp_desc);
+		}
 		break;
 
 
-	case AML_TO_STRING_OP:          /* To_string (Buffer, Length, Result) (ACPI 2.0) */
+	case AML_TO_STRING_OP:          /* to_string (Buffer, Length, Result) (ACPI 2.0) */
+
+		/*
+		 * Input object is guaranteed to be a buffer at this point (it may have
+		 * been converted.)  Copy the raw buffer data to a new object of type String.
+		 */
+
+		/* Get the length of the new 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;
+		}
+
+		/* Create the internal return object */
 
-		status = acpi_ex_convert_to_string (operand[0], &return_desc, 16,
-				  (u32) operand[1]->integer.value, walk_state);
+		return_desc = acpi_ut_create_internal_object (ACPI_TYPE_STRING);
+		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 */
+
+		ACPI_MEMCPY (return_desc->string.pointer, operand[0]->buffer.pointer, length);
+
+		/* Set the string length */
+
+		return_desc->string.length = (u32) length;
 		break;
 
 
-	case AML_CONCAT_RES_OP:         /* Concatenate_res_template (Buffer, Buffer, Result) (ACPI 2.0) */
+	case AML_CONCAT_RES_OP:         /* concatenate_res_template (Buffer, Buffer, Result) (ACPI 2.0) */
 
-		status = AE_NOT_IMPLEMENTED;
+		status = acpi_ex_concat_template (operand[0], operand[1], &return_desc, walk_state);
 		break;
 
 
@@ -352,7 +411,7 @@
 
 		/* Create the internal return object */
 
-		return_desc = acpi_ut_create_internal_object (INTERNAL_TYPE_REFERENCE);
+		return_desc = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_REFERENCE);
 		if (!return_desc) {
 			status = AE_NO_MEMORY;
 			goto cleanup;
@@ -363,73 +422,52 @@
 		/*
 		 * At this point, the Source operand is either a Package or a Buffer
 		 */
-		if (operand[0]->common.type == ACPI_TYPE_PACKAGE) {
+		if (ACPI_GET_OBJECT_TYPE (operand[0]) == ACPI_TYPE_PACKAGE) {
 			/* Object to be indexed is a Package */
 
 			if (index >= operand[0]->package.count) {
-				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Index value beyond package end\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;
 			}
 
-			if ((operand[2]->common.type == INTERNAL_TYPE_REFERENCE) &&
-				(operand[2]->reference.opcode == AML_ZERO_OP)) {
-				/*
-				 * There is no actual result descriptor (the Zero_op Result
-				 * descriptor is a placeholder), so just delete the placeholder and
-				 * return a reference to the package element
-				 */
-				acpi_ut_remove_reference (operand[2]);
-			}
-
-			else {
-				/*
-				 * Each element of the package is an internal object.  Get the one
-				 * we are after.
-				 */
-				temp_desc                        = operand[0]->package.elements [index];
-				return_desc->reference.opcode    = AML_INDEX_OP;
-				return_desc->reference.target_type = temp_desc->common.type;
-				return_desc->reference.object    = temp_desc;
-
-				status = acpi_ex_store (return_desc, operand[2], walk_state);
-				return_desc->reference.object    = NULL;
-			}
-
-			/*
-			 * The local return object must always be a reference to the package element,
-			 * not the element itself.
-			 */
-			return_desc->reference.opcode    = AML_INDEX_OP;
 			return_desc->reference.target_type = ACPI_TYPE_PACKAGE;
+			return_desc->reference.object    = operand[0]->package.elements [index];
 			return_desc->reference.where     = &operand[0]->package.elements [index];
 		}
-
 		else {
 			/* Object to be indexed is a Buffer */
 
 			if (index >= operand[0]->buffer.length) {
-				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Index value beyond end of buffer\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;
 			}
 
-			return_desc->reference.opcode      = AML_INDEX_OP;
 			return_desc->reference.target_type = ACPI_TYPE_BUFFER_FIELD;
-			return_desc->reference.object      = operand[0];
-			return_desc->reference.offset      = index;
-
-			status = acpi_ex_store (return_desc, operand[2], walk_state);
+			return_desc->reference.object    = operand[0];
 		}
 
+		/* Complete the Index reference object */
+
+		return_desc->reference.opcode    = AML_INDEX_OP;
+		return_desc->reference.offset    = index;
+
+		/* Store the reference to the Target */
+
+		status = acpi_ex_store (return_desc, operand[2], walk_state);
+
+		/* Return the reference */
+
 		walk_state->result_obj = return_desc;
 		goto cleanup;
-		break;
 
 
 	default:
 
-		REPORT_ERROR (("Acpi_ex_opcode_2A_1T_1R: Unknown opcode %X\n",
+		ACPI_REPORT_ERROR (("acpi_ex_opcode_2A_1T_1R: Unknown opcode %X\n",
 				walk_state->opcode));
 		status = AE_AML_BAD_OPCODE;
 		break;
@@ -440,7 +478,7 @@
 
 	if (ACPI_SUCCESS (status)) {
 		/*
-		 * Store the result of the operation (which is now in Return_desc) into
+		 * Store the result of the operation (which is now in return_desc) into
 		 * the Target descriptor.
 		 */
 		status = acpi_ex_store (return_desc, operand[2], walk_state);
@@ -448,7 +486,9 @@
 			goto cleanup;
 		}
 
-		walk_state->result_obj = return_desc;
+		if (!walk_state->result_obj) {
+			walk_state->result_obj = return_desc;
+		}
 	}
 
 
@@ -466,9 +506,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_opcode_2A_0T_1R
+ * FUNCTION:    acpi_ex_opcode_2A_0T_1R
  *
- * PARAMETERS:  Walk_state          - Current walk state
+ * PARAMETERS:  walk_state          - Current walk state
  *
  * RETURN:      Status
  *
@@ -478,15 +518,15 @@
 
 acpi_status
 acpi_ex_opcode_2A_0T_1R (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_operand_object     **operand = &walk_state->operands[0];
-	acpi_operand_object     *return_desc = NULL;
-	acpi_status             status = AE_OK;
-	u8                      logical_result = FALSE;
+	union acpi_operand_object       **operand = &walk_state->operands[0];
+	union acpi_operand_object       *return_desc = NULL;
+	acpi_status                     status = AE_OK;
+	u8                              logical_result = FALSE;
 
 
-	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 */
@@ -500,7 +540,7 @@
 	/*
 	 * Execute the Opcode
 	 */
-	if (walk_state->op_info->flags & AML_LOGICAL) /* Logical_op (Operand0, Operand1) */ {
+	if (walk_state->op_info->flags & AML_LOGICAL) /* logical_op (Operand0, Operand1) */ {
 		logical_result = acpi_ex_do_logical_op (walk_state->opcode,
 				 operand[0]->integer.value,
 				 operand[1]->integer.value);
@@ -509,7 +549,7 @@
 
 
 	switch (walk_state->opcode) {
-	case AML_ACQUIRE_OP:            /* Acquire (Mutex_object, Timeout) */
+	case AML_ACQUIRE_OP:            /* Acquire (mutex_object, Timeout) */
 
 		status = acpi_ex_acquire_mutex (operand[1], operand[0], walk_state);
 		if (status == AE_TIME) {
@@ -519,7 +559,7 @@
 		break;
 
 
-	case AML_WAIT_OP:               /* Wait (Event_object, Timeout) */
+	case AML_WAIT_OP:               /* Wait (event_object, Timeout) */
 
 		status = acpi_ex_system_wait_event (operand[1], operand[0]);
 		if (status == AE_TIME) {
@@ -531,16 +571,16 @@
 
 	default:
 
-		REPORT_ERROR (("Acpi_ex_opcode_2A_0T_1R: Unknown opcode %X\n", walk_state->opcode));
+		ACPI_REPORT_ERROR (("acpi_ex_opcode_2A_0T_1R: Unknown opcode %X\n",
+			walk_state->opcode));
 		status = AE_AML_BAD_OPCODE;
 		goto cleanup;
-		break;
 	}
 
 
 store_logical_result:
 	/*
-	 * Set return value to according to Logical_result. logical TRUE (all ones)
+	 * Set return value to according to logical_result. logical TRUE (all ones)
 	 * Default is FALSE (zero)
 	 */
 	if (logical_result) {
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exoparg3.c linux-2.4.22-pre2/drivers/acpi/executer/exoparg3.c
--- linux-2.4.21/drivers/acpi/executer/exoparg3.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exoparg3.c	2003-06-26 21:43:10.000000000 +0000
@@ -2,37 +2,55 @@
 /******************************************************************************
  *
  * Module Name: exoparg3 - AML execution - opcodes with 3 arguments
- *              $Revision: 3 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acinterp.h"
-#include "acparser.h"
-#include "amlcode.h"
+#include <acpi/acpi.h>
+#include <acpi/acinterp.h>
+#include <acpi/acparser.h>
+#include <acpi/amlcode.h>
 
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exoparg3")
+	 ACPI_MODULE_NAME    ("exoparg3")
 
 
 /*!
@@ -60,9 +78,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_opcode_3A_0T_0R
+ * FUNCTION:    acpi_ex_opcode_3A_0T_0R
  *
- * PARAMETERS:  Walk_state          - Current walk state
+ * PARAMETERS:  walk_state          - Current walk state
  *
  * RETURN:      Status
  *
@@ -72,27 +90,27 @@
 
 acpi_status
 acpi_ex_opcode_3A_0T_0R (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_operand_object     **operand = &walk_state->operands[0];
-	ACPI_SIGNAL_FATAL_INFO  *fatal;
-	acpi_status             status = AE_OK;
+	union acpi_operand_object       **operand = &walk_state->operands[0];
+	struct acpi_signal_fatal_info   *fatal;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE_STR ("Ex_opcode_3A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
+	ACPI_FUNCTION_TRACE_STR ("ex_opcode_3A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
 
 
 	switch (walk_state->opcode) {
 
-	case AML_FATAL_OP:          /* Fatal (Fatal_type Fatal_code Fatal_arg)   */
+	case AML_FATAL_OP:          /* Fatal (fatal_type fatal_code fatal_arg)   */
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-			"Fatal_op: Type %x Code %x Arg %x <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n",
+			"fatal_op: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n",
 			(u32) operand[0]->integer.value, (u32) operand[1]->integer.value,
 			(u32) operand[2]->integer.value));
 
 
-		fatal = ACPI_MEM_ALLOCATE (sizeof (ACPI_SIGNAL_FATAL_INFO));
+		fatal = ACPI_MEM_ALLOCATE (sizeof (struct acpi_signal_fatal_info));
 		if (fatal) {
 			fatal->type     = (u32) operand[0]->integer.value;
 			fatal->code     = (u32) operand[1]->integer.value;
@@ -102,7 +120,7 @@
 		/*
 		 * Always signal the OS!
 		 */
-		acpi_os_signal (ACPI_SIGNAL_FATAL, fatal);
+		status = acpi_os_signal (ACPI_SIGNAL_FATAL, fatal);
 
 		/* Might return while OS is shutting down, just continue */
 
@@ -112,11 +130,10 @@
 
 	default:
 
-		REPORT_ERROR (("Acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n",
+		ACPI_REPORT_ERROR (("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n",
 				walk_state->opcode));
 		status = AE_AML_BAD_OPCODE;
 		goto cleanup;
-		break;
 	}
 
 
@@ -128,9 +145,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_opcode_3A_1T_1R
+ * FUNCTION:    acpi_ex_opcode_3A_1T_1R
  *
- * PARAMETERS:  Walk_state          - Current walk state
+ * PARAMETERS:  walk_state          - Current walk state
  *
  * RETURN:      Status
  *
@@ -140,17 +157,17 @@
 
 acpi_status
 acpi_ex_opcode_3A_1T_1R (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_operand_object     **operand = &walk_state->operands[0];
-	acpi_operand_object     *return_desc = NULL;
-	char                    *buffer;
-	acpi_status             status = AE_OK;
-	u32                     index;
-	u32                     length;
+	union acpi_operand_object       **operand = &walk_state->operands[0];
+	union acpi_operand_object       *return_desc = NULL;
+	char                            *buffer;
+	acpi_status                     status = AE_OK;
+	acpi_native_uint                index;
+	acpi_size                       length;
 
 
-	FUNCTION_TRACE_STR ("Ex_opcode_3A_1T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
+	ACPI_FUNCTION_TRACE_STR ("ex_opcode_3A_1T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
 
 
 	switch (walk_state->opcode) {
@@ -160,7 +177,7 @@
 		 * Create the return object.  The Source operand is guaranteed to be
 		 * either a String or a Buffer, so just use its type.
 		 */
-		return_desc = acpi_ut_create_internal_object (operand[0]->common.type);
+		return_desc = acpi_ut_create_internal_object (ACPI_GET_OBJECT_TYPE (operand[0]));
 		if (!return_desc) {
 			status = AE_NO_MEMORY;
 			goto cleanup;
@@ -168,8 +185,8 @@
 
 		/* Get the Integer values from the objects */
 
-		index = (u32) operand[1]->integer.value;
-		length = (u32) operand[2]->integer.value;
+		index = (acpi_native_uint) operand[1]->integer.value;
+		length = (acpi_size) operand[2]->integer.value;
 
 		/*
 		 * If the index is beyond the length of the String/Buffer, or if the
@@ -181,37 +198,36 @@
 
 			if ((index + length) >
 				operand[0]->string.length) {
-				length = operand[0]->string.length - index;
+				length = (acpi_size) operand[0]->string.length - index;
 			}
 
 			/* Allocate a new buffer for the String/Buffer */
 
-			buffer = ACPI_MEM_CALLOCATE (length + 1);
+			buffer = ACPI_MEM_CALLOCATE ((acpi_size) length + 1);
 			if (!buffer) {
-				return (AE_NO_MEMORY);
+				status = AE_NO_MEMORY;
+				goto cleanup;
 			}
 
 			/* Copy the portion requested */
 
-			MEMCPY (buffer, operand[0]->string.pointer + index,
-					length);
+			ACPI_MEMCPY (buffer, operand[0]->string.pointer + index,
+					  length);
 
 			/* Set the length of the new String/Buffer */
 
 			return_desc->string.pointer = buffer;
-			return_desc->string.length = length;
+			return_desc->string.length = (u32) length;
 		}
-
 		break;
 
 
 	default:
 
-		REPORT_ERROR (("Acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n",
+		ACPI_REPORT_ERROR (("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n",
 				walk_state->opcode));
 		status = AE_AML_BAD_OPCODE;
 		goto cleanup;
-		break;
 	}
 
 	/* Store the result in the target */
@@ -228,7 +244,9 @@
 
 	/* Set the return object and exit */
 
-	walk_state->result_obj = return_desc;
+	if (!walk_state->result_obj) {
+		walk_state->result_obj = return_desc;
+	}
 	return_ACPI_STATUS (status);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exoparg6.c linux-2.4.22-pre2/drivers/acpi/executer/exoparg6.c
--- linux-2.4.21/drivers/acpi/executer/exoparg6.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exoparg6.c	2003-06-26 21:43:13.000000000 +0000
@@ -2,37 +2,55 @@
 /******************************************************************************
  *
  * Module Name: exoparg6 - AML execution - opcodes with 6 arguments
- *              $Revision: 4 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acinterp.h"
-#include "acparser.h"
-#include "amlcode.h"
+#include <acpi/acpi.h>
+#include <acpi/acinterp.h>
+#include <acpi/acparser.h>
+#include <acpi/amlcode.h>
 
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exoparg6")
+	 ACPI_MODULE_NAME    ("exoparg6")
 
 
 /*!
@@ -60,11 +78,11 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_do_match
+ * FUNCTION:    acpi_ex_do_match
  *
- * PARAMETERS:  Match_op        - The AML match operand
- *              Package_value   - Value from the target package
- *              Match_value     - Value to be matched
+ * PARAMETERS:  match_op        - The AML match operand
+ *              package_value   - Value from the target package
+ *              match_value     - Value to be matched
  *
  * RETURN:      TRUE if the match is successful, FALSE otherwise
  *
@@ -74,9 +92,9 @@
 
 u8
 acpi_ex_do_match (
-	u32                     match_op,
-	acpi_integer            package_value,
-	acpi_integer            match_value)
+	u32                             match_op,
+	acpi_integer                    package_value,
+	acpi_integer                    match_value)
 {
 
 	switch (match_op) {
@@ -137,9 +155,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_opcode_6A_0T_1R
+ * FUNCTION:    acpi_ex_opcode_6A_0T_1R
  *
- * PARAMETERS:  Walk_state          - Current walk state
+ * PARAMETERS:  walk_state          - Current walk state
  *
  * RETURN:      Status
  *
@@ -149,23 +167,23 @@
 
 acpi_status
 acpi_ex_opcode_6A_0T_1R (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_operand_object     **operand = &walk_state->operands[0];
-	acpi_operand_object     *return_desc = NULL;
-	acpi_status             status = AE_OK;
-	u32                     index;
-	acpi_operand_object     *this_element;
+	union acpi_operand_object       **operand = &walk_state->operands[0];
+	union acpi_operand_object       *return_desc = NULL;
+	acpi_status                     status = AE_OK;
+	u32                             index;
+	union acpi_operand_object       *this_element;
 
 
-	FUNCTION_TRACE_STR ("Ex_opcode_6A_0T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
+	ACPI_FUNCTION_TRACE_STR ("ex_opcode_6A_0T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
 
 
 	switch (walk_state->opcode) {
 	case AML_MATCH_OP:
 		/*
-		 * Match (Search_package[0], Match_op1[1], Match_object1[2],
-		 *                          Match_op2[3], Match_object2[4], Start_index[5])
+		 * Match (search_package[0], match_op1[1], match_object1[2],
+		 *                          match_op2[3], match_object2[4], start_index[5])
 		 */
 
 		/* Validate match comparison sub-opcodes */
@@ -199,8 +217,9 @@
 		 * Examine each element until a match is found.  Within the loop,
 		 * "continue" signifies that the current element does not match
 		 * and the next should be examined.
+		 *
 		 * Upon finding a match, the loop will terminate via "break" at
-		 * the bottom.  If it terminates "normally", Match_value will be -1
+		 * the bottom.  If it terminates "normally", match_value will be -1
 		 * (its initial value) indicating that no match was found.  When
 		 * returned as a Number, this will produce the Ones value as specified.
 		 */
@@ -209,27 +228,21 @@
 
 			/*
 			 * Treat any NULL or non-numeric elements as non-matching.
-			 * TBD [Unhandled] - if an element is a Name,
-			 *      should we examine its value?
 			 */
 			if (!this_element ||
-				this_element->common.type != ACPI_TYPE_INTEGER) {
+				ACPI_GET_OBJECT_TYPE (this_element) != ACPI_TYPE_INTEGER) {
 				continue;
 			}
 
-
 			/*
-			 * Within these switch statements:
-			 *      "break" (exit from the switch) signifies a match;
-			 *      "continue" (proceed to next iteration of enclosing
-			 *          "for" loop) signifies a non-match.
+			 * "continue" (proceed to next iteration of enclosing
+			 * "for" loop) signifies a non-match.
 			 */
 			if (!acpi_ex_do_match ((u32) operand[1]->integer.value,
 					   this_element->integer.value, operand[2]->integer.value)) {
 				continue;
 			}
 
-
 			if (!acpi_ex_do_match ((u32) operand[3]->integer.value,
 					   this_element->integer.value, operand[4]->integer.value)) {
 				continue;
@@ -246,18 +259,16 @@
 
 	case AML_LOAD_TABLE_OP:
 
-		status = AE_NOT_IMPLEMENTED;
-		goto cleanup;
+		status = acpi_ex_load_table_op (walk_state, &return_desc);
 		break;
 
 
 	default:
 
-		REPORT_ERROR (("Acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n",
+		ACPI_REPORT_ERROR (("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n",
 				walk_state->opcode));
 		status = AE_AML_BAD_OPCODE;
 		goto cleanup;
-		break;
 	}
 
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exprep.c linux-2.4.22-pre2/drivers/acpi/executer/exprep.c
--- linux-2.4.21/drivers/acpi/executer/exprep.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exprep.c	2003-06-26 21:43:13.000000000 +0000
@@ -2,292 +2,348 @@
 /******************************************************************************
  *
  * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities
- *              $Revision: 99 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acinterp.h"
-#include "amlcode.h"
-#include "acnamesp.h"
-#include "acparser.h"
+#include <acpi/acpi.h>
+#include <acpi/acinterp.h>
+#include <acpi/amlcode.h>
+#include <acpi/acnamesp.h>
 
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exprep")
+	 ACPI_MODULE_NAME    ("exprep")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_decode_field_access_type
+ * FUNCTION:    acpi_ex_decode_field_access
  *
  * PARAMETERS:  Access          - Encoded field access bits
  *              Length          - Field length.
  *
- * RETURN:      Field granularity (8, 16, 32 or 64)
+ * RETURN:      Field granularity (8, 16, 32 or 64) and
+ *              byte_alignment (1, 2, 3, or 4)
  *
- * DESCRIPTION: Decode the Access_type bits of a field definition.
+ * DESCRIPTION: Decode the access_type bits of a field definition.
  *
  ******************************************************************************/
 
 static u32
-acpi_ex_decode_field_access_type (
-	u32                     access,
-	u16                     length,
-	u32                     *alignment)
+acpi_ex_decode_field_access (
+	union acpi_operand_object       *obj_desc,
+	u8                              field_flags,
+	u32                             *return_byte_alignment)
 {
-	PROC_NAME ("Ex_decode_field_access_type");
+	u32                             access;
+	u8                              byte_alignment;
+	u8                              bit_length;
+/*    u32                             Length; */
 
 
+	ACPI_FUNCTION_NAME ("ex_decode_field_access");
+
+
+	access = (field_flags & AML_FIELD_ACCESS_TYPE_MASK);
+
 	switch (access) {
-	case ACCESS_ANY_ACC:
+	case AML_FIELD_ACCESS_ANY:
+
+		byte_alignment = 1;
+		bit_length = 8;
 
-		*alignment = 8;
+#if 0
+		/*
+		 * TBD: optimize
+		 *
+		 * Any attempt to optimize the access size to the size of the field
+		 * must take into consideration the length of the region and take
+		 * care that an access to the field will not attempt to access
+		 * beyond the end of the region.
+		 */
 
 		/* Use the length to set the access type */
 
+		length = obj_desc->common_field.bit_length;
+
 		if (length <= 8) {
-			return (8);
+			bit_length = 8;
 		}
 		else if (length <= 16) {
-			return (16);
+			bit_length = 16;
 		}
 		else if (length <= 32) {
-			return (32);
+			bit_length = 32;
 		}
 		else if (length <= 64) {
-			return (64);
+			bit_length = 64;
 		}
+		else {
+			/* Larger than Qword - just use byte-size chunks */
 
-		/* Default is 8 (byte) */
-
-		return (8);
+			bit_length = 8;
+		}
+#endif
 		break;
 
-	case ACCESS_BYTE_ACC:
-		*alignment = 8;
-		return (8);
+	case AML_FIELD_ACCESS_BYTE:
+	case AML_FIELD_ACCESS_BUFFER:   /* ACPI 2.0 (SMBus Buffer) */
+		byte_alignment = 1;
+		bit_length    = 8;
 		break;
 
-	case ACCESS_WORD_ACC:
-		*alignment = 16;
-		return (16);
+	case AML_FIELD_ACCESS_WORD:
+		byte_alignment = 2;
+		bit_length    = 16;
 		break;
 
-	case ACCESS_DWORD_ACC:
-		*alignment = 32;
-		return (32);
+	case AML_FIELD_ACCESS_DWORD:
+		byte_alignment = 4;
+		bit_length    = 32;
 		break;
 
-	case ACCESS_QWORD_ACC:  /* ACPI 2.0 */
-		*alignment = 64;
-		return (64);
+	case AML_FIELD_ACCESS_QWORD:    /* ACPI 2.0 */
+		byte_alignment = 8;
+		bit_length    = 64;
 		break;
 
 	default:
 		/* Invalid field access type */
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-			"Unknown field access type %x\n",
+			"Unknown field access type %X\n",
 			access));
 		return (0);
 	}
+
+	if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_BUFFER_FIELD) {
+		/*
+		 * buffer_field access can be on any byte boundary, so the
+		 * byte_alignment is always 1 byte -- regardless of any byte_alignment
+		 * implied by the field access type.
+		 */
+		byte_alignment = 1;
+	}
+
+	*return_byte_alignment = byte_alignment;
+	return (bit_length);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_prep_common_field_object
+ * FUNCTION:    acpi_ex_prep_common_field_object
  *
- * PARAMETERS:  Obj_desc            - The field object
- *              Field_flags         - Access, Lock_rule, and Update_rule.
- *                                    The format of a Field_flag is described
+ * PARAMETERS:  obj_desc            - The field object
+ *              field_flags         - Access, lock_rule, and update_rule.
+ *                                    The format of a field_flag is described
  *                                    in the ACPI specification
- *              Field_bit_position  - Field start position
- *              Field_bit_length    - Field length in number of bits
+ *              field_bit_position  - Field start position
+ *              field_bit_length    - Field length in number of bits
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Initialize the areas of the field object that are common
- *              to the various types of fields.
+ *              to the various types of fields.  Note: This is very "sensitive"
+ *              code because we are solving the general case for field
+ *              alignment.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ex_prep_common_field_object (
-	acpi_operand_object     *obj_desc,
-	u8                      field_flags,
-	u32                     field_bit_position,
-	u32                     field_bit_length)
+	union acpi_operand_object       *obj_desc,
+	u8                              field_flags,
+	u8                              field_attribute,
+	u32                             field_bit_position,
+	u32                             field_bit_length)
 {
-	u32                     access_bit_width;
-	u32                     alignment;
-	u32                     nearest_byte_address;
+	u32                             access_bit_width;
+	u32                             byte_alignment;
+	u32                             nearest_byte_address;
 
 
-	FUNCTION_TRACE ("Ex_prep_common_field_object");
+	ACPI_FUNCTION_TRACE ("ex_prep_common_field_object");
 
 
 	/*
 	 * Note: the structure being initialized is the
-	 * ACPI_COMMON_FIELD_INFO;  No structure fields outside of the common area
-	 * are initialized by this procedure.
+	 * ACPI_COMMON_FIELD_INFO;  No structure fields outside of the common
+	 * area are initialized by this procedure.
 	 */
-
-	/* Demultiplex the Field_flags byte */
-
-	obj_desc->common_field.lock_rule = (u8) ((field_flags & LOCK_RULE_MASK)
-			 >> LOCK_RULE_SHIFT);
-	obj_desc->common_field.update_rule = (u8) ((field_flags & UPDATE_RULE_MASK)
-			 >> UPDATE_RULE_SHIFT);
-	/* Other misc fields */
-
-	obj_desc->common_field.bit_length = (u16) field_bit_length;
+	obj_desc->common_field.field_flags = field_flags;
+	obj_desc->common_field.attribute = field_attribute;
+	obj_desc->common_field.bit_length = field_bit_length;
 
 	/*
 	 * Decode the access type so we can compute offsets.  The access type gives
 	 * two pieces of information - the width of each field access and the
-	 * necessary alignment of the access.  For Any_acc, the width used is the
-	 * largest necessary/possible in an attempt to access the whole field in one
-	 * I/O operation.  However, for Any_acc, the alignment is 8. For all other
-	 * access types (Byte, Word, Dword, Qword), the width is the same as the
-	 * alignment.
+	 * necessary byte_alignment (address granularity) of the access.
+	 *
+	 * For any_acc, the access_bit_width is the largest width that is both
+	 * necessary and possible in an attempt to access the whole field in one
+	 * I/O operation.  However, for any_acc, the byte_alignment is always one
+	 * byte.
+	 *
+	 * For all Buffer Fields, the byte_alignment is always one byte.
+	 *
+	 * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is
+	 * the same (equivalent) as the byte_alignment.
 	 */
-	access_bit_width = acpi_ex_decode_field_access_type (
-			   ((field_flags & ACCESS_TYPE_MASK) >> ACCESS_TYPE_SHIFT),
-			   obj_desc->field.bit_length, &alignment);
+	access_bit_width = acpi_ex_decode_field_access (obj_desc, field_flags,
+			  &byte_alignment);
 	if (!access_bit_width) {
 		return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
 	}
 
 	/* Setup width (access granularity) fields */
 
-	obj_desc->common_field.access_bit_width = (u8) access_bit_width;         /* 8, 16, 32, 64 */
-	obj_desc->common_field.access_byte_width = (u8) DIV_8 (access_bit_width); /* 1, 2,  4,  8 */
-
-	if (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD) {
-		/*
-		 * Buffer_field access can be on any byte boundary, so the
-		 * alignment is always 8 (regardless of any alignment implied by the
-		 * field access type.)
-		 */
-		alignment = 8;
-	}
-
+	obj_desc->common_field.access_byte_width = (u8)
+			ACPI_DIV_8 (access_bit_width); /* 1, 2, 4,  8 */
 
 	/*
-	 * Base_byte_offset is the address of the start of the field within the region. It is
-	 * the byte address of the first *datum* (field-width data unit) of the field.
-	 * (i.e., the first datum that contains at least the first *bit* of the field.)
+	 * base_byte_offset is the address of the start of the field within the
+	 * region.  It is the byte address of the first *datum* (field-width data
+	 * unit) of the field. (i.e., the first datum that contains at least the
+	 * first *bit* of the field.)
+	 *
+	 * Note: byte_alignment is always either equal to the access_bit_width or 8
+	 * (Byte access), and it defines the addressing granularity of the parent
+	 * region or buffer.
 	 */
-	nearest_byte_address                      = ROUND_BITS_DOWN_TO_BYTES (field_bit_position);
-	obj_desc->common_field.base_byte_offset   = ROUND_DOWN (nearest_byte_address,
-			   DIV_8 (alignment));
+	nearest_byte_address =
+			ACPI_ROUND_BITS_DOWN_TO_BYTES (field_bit_position);
+	obj_desc->common_field.base_byte_offset =
+			ACPI_ROUND_DOWN (nearest_byte_address, byte_alignment);
 
 	/*
-	 * Start_field_bit_offset is the offset of the first bit of the field within a field datum.
-	 * This is calculated as the number of bits from the Base_byte_offset. In other words,
-	 * the start of the field is relative to a byte address, regardless of the access type
-	 * of the field.
+	 * start_field_bit_offset is the offset of the first bit of the field within
+	 * a field datum.
 	 */
-	obj_desc->common_field.start_field_bit_offset = (u8) (MOD_8 (field_bit_position));
+	obj_desc->common_field.start_field_bit_offset = (u8)
+		(field_bit_position - ACPI_MUL_8 (obj_desc->common_field.base_byte_offset));
 
 	/*
-	 * Datum_valid_bits is the number of valid field bits in the first field datum.
+	 * Valid bits -- the number of bits that compose a partial datum,
+	 * 1) At the end of the field within the region (arbitrary starting bit
+	 *    offset)
+	 * 2) At the end of a buffer used to contain the field (starting offset
+	 *    always zero)
 	 */
-	obj_desc->common_field.datum_valid_bits   = (u8) (access_bit_width -
-			   obj_desc->common_field.start_field_bit_offset);
+	obj_desc->common_field.end_field_valid_bits = (u8)
+		((obj_desc->common_field.start_field_bit_offset + field_bit_length) %
+				  access_bit_width);
+	/* start_buffer_bit_offset always = 0 */
+
+	obj_desc->common_field.end_buffer_valid_bits = (u8)
+		(field_bit_length % access_bit_width);
 
 	/*
-	 * Valid bits -- the number of bits that compose a partial datum,
-	 * 1) At the end of the field within the region (arbitrary starting bit offset)
-	 * 2) At the end of a buffer used to contain the field (starting offset always zero)
+	 * datum_valid_bits is the number of valid field bits in the first
+	 * field datum.
 	 */
-	obj_desc->common_field.end_field_valid_bits = (u8) ((obj_desc->common_field.start_field_bit_offset +
-			   field_bit_length) % access_bit_width);
-	obj_desc->common_field.end_buffer_valid_bits = (u8) (field_bit_length % access_bit_width); /* Start_buffer_bit_offset always = 0 */
-
+	obj_desc->common_field.datum_valid_bits  = (u8)
+		(access_bit_width - obj_desc->common_field.start_field_bit_offset);
 
 	/*
-	 * Does the entire field fit within a single field access element
-	 * (datum)?  (without crossing a datum boundary)
+	 * Does the entire field fit within a single field access element? (datum)
+	 * (i.e., without crossing a datum boundary)
 	 */
-	if ((obj_desc->common_field.start_field_bit_offset + obj_desc->common_field.bit_length) <=
-		(u16) obj_desc->common_field.access_bit_width) {
-		obj_desc->common_field.access_flags |= AFIELD_SINGLE_DATUM;
+	if ((obj_desc->common_field.start_field_bit_offset + field_bit_length) <=
+			(u16) access_bit_width) {
+		obj_desc->common.flags |= AOPOBJ_SINGLE_DATUM;
 	}
 
-
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_prep_field_value
+ * FUNCTION:    acpi_ex_prep_field_value
  *
  * PARAMETERS:  Node                - Owning Node
- *              Region_node         - Region in which field is being defined
- *              Field_flags         - Access, Lock_rule, and Update_rule.
- *              Field_bit_position  - Field start position
- *              Field_bit_length    - Field length in number of bits
+ *              region_node         - Region in which field is being defined
+ *              field_flags         - Access, lock_rule, and update_rule.
+ *              field_bit_position  - Field start position
+ *              field_bit_length    - Field length in number of bits
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Construct an acpi_operand_object of type Def_field and
+ * DESCRIPTION: Construct an union acpi_operand_object of type def_field and
  *              connect it to the parent Node.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ex_prep_field_value (
-	ACPI_CREATE_FIELD_INFO  *info)
+	struct acpi_create_field_info   *info)
 {
-	acpi_operand_object     *obj_desc;
-	u32                     type;
-	acpi_status             status;
+	union acpi_operand_object       *obj_desc;
+	u32                             type;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Ex_prep_field_value");
+	ACPI_FUNCTION_TRACE ("ex_prep_field_value");
 
 
 	/* Parameter validation */
 
-	if (info->field_type != INTERNAL_TYPE_INDEX_FIELD) {
+	if (info->field_type != ACPI_TYPE_LOCAL_INDEX_FIELD) {
 		if (!info->region_node) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Region_node\n"));
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null region_node\n"));
 			return_ACPI_STATUS (AE_AML_NO_OPERAND);
 		}
 
 		type = acpi_ns_get_type (info->region_node);
 		if (type != ACPI_TYPE_REGION) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Needed Region, found type %X %s\n",
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"Needed Region, found type %X %s\n",
 				type, acpi_ut_get_type_name (type)));
 
 			return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 		}
 	}
 
-	/* Allocate a new region object */
+	/* Allocate a new field object */
 
 	obj_desc = acpi_ut_create_internal_object (info->field_type);
 	if (!obj_desc) {
@@ -296,8 +352,9 @@
 
 	/* Initialize areas of the object that are common to all fields */
 
+	obj_desc->common_field.node = info->field_node;
 	status = acpi_ex_prep_common_field_object (obj_desc, info->field_flags,
-			  info->field_bit_position, info->field_bit_length);
+			 info->attribute, info->field_bit_position, info->field_bit_length);
 	if (ACPI_FAILURE (status)) {
 		acpi_ut_delete_object_desc (obj_desc);
 		return_ACPI_STATUS (status);
@@ -306,44 +363,48 @@
 	/* Initialize areas of the object that are specific to the field type */
 
 	switch (info->field_type) {
-	case INTERNAL_TYPE_REGION_FIELD:
+	case ACPI_TYPE_LOCAL_REGION_FIELD:
 
-		obj_desc->field.region_obj  = acpi_ns_get_attached_object (info->region_node);
+		obj_desc->field.region_obj   = acpi_ns_get_attached_object (info->region_node);
 
 		/* An additional reference for the container */
 
 		acpi_ut_add_reference (obj_desc->field.region_obj);
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Region_field: Bitoff=%X Off=%X Gran=%X Region %p\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+			"region_field: Bitoff=%X Off=%X Gran=%X Region %p\n",
 			obj_desc->field.start_field_bit_offset, obj_desc->field.base_byte_offset,
-			obj_desc->field.access_bit_width, obj_desc->field.region_obj));
+			obj_desc->field.access_byte_width, obj_desc->field.region_obj));
 		break;
 
 
-	case INTERNAL_TYPE_BANK_FIELD:
+	case ACPI_TYPE_LOCAL_BANK_FIELD:
 
-		obj_desc->bank_field.value         = info->bank_value;
-		obj_desc->bank_field.region_obj    = acpi_ns_get_attached_object (info->region_node);
-		obj_desc->bank_field.bank_register_obj = acpi_ns_get_attached_object (info->register_node);
+		obj_desc->bank_field.value   = info->bank_value;
+		obj_desc->bank_field.region_obj = acpi_ns_get_attached_object (info->region_node);
+		obj_desc->bank_field.bank_obj = acpi_ns_get_attached_object (info->register_node);
 
 		/* An additional reference for the attached objects */
 
 		acpi_ut_add_reference (obj_desc->bank_field.region_obj);
-		acpi_ut_add_reference (obj_desc->bank_field.bank_register_obj);
+		acpi_ut_add_reference (obj_desc->bank_field.bank_obj);
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Bank Field: Bit_off=%X Off=%X Gran=%X Region %p Bank_reg %p\n",
-			obj_desc->bank_field.start_field_bit_offset, obj_desc->bank_field.base_byte_offset,
-			obj_desc->field.access_bit_width, obj_desc->bank_field.region_obj,
-			obj_desc->bank_field.bank_register_obj));
+		ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+			"Bank Field: bit_off=%X Off=%X Gran=%X Region %p bank_reg %p\n",
+			obj_desc->bank_field.start_field_bit_offset,
+			obj_desc->bank_field.base_byte_offset,
+			obj_desc->field.access_byte_width,
+			obj_desc->bank_field.region_obj,
+			obj_desc->bank_field.bank_obj));
 		break;
 
 
-	case INTERNAL_TYPE_INDEX_FIELD:
+	case ACPI_TYPE_LOCAL_INDEX_FIELD:
 
 		obj_desc->index_field.index_obj = acpi_ns_get_attached_object (info->register_node);
 		obj_desc->index_field.data_obj = acpi_ns_get_attached_object (info->data_register_node);
-		obj_desc->index_field.value  = (u32) (info->field_bit_position /
-				  obj_desc->field.access_bit_width);
+		obj_desc->index_field.value  = (u32)
+			(info->field_bit_position / ACPI_MUL_8 (obj_desc->field.access_byte_width));
 
 		if (!obj_desc->index_field.data_obj || !obj_desc->index_field.index_obj) {
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Index Object\n"));
@@ -355,22 +416,29 @@
 		acpi_ut_add_reference (obj_desc->index_field.data_obj);
 		acpi_ut_add_reference (obj_desc->index_field.index_obj);
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Index_field: bitoff=%X off=%X gran=%X Index %p Data %p\n",
-			obj_desc->index_field.start_field_bit_offset, obj_desc->index_field.base_byte_offset,
-			obj_desc->field.access_bit_width, obj_desc->index_field.index_obj,
+		ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+			"index_field: bitoff=%X off=%X gran=%X Index %p Data %p\n",
+			obj_desc->index_field.start_field_bit_offset,
+			obj_desc->index_field.base_byte_offset,
+			obj_desc->field.access_byte_width,
+			obj_desc->index_field.index_obj,
 			obj_desc->index_field.data_obj));
 		break;
+
+	default:
+		/* No other types should get here */
+		break;
 	}
 
 	/*
-	 * Store the constructed descriptor (Obj_desc) into the parent Node,
-	 * preserving the current type of that Named_obj.
+	 * Store the constructed descriptor (obj_desc) into the parent Node,
+	 * preserving the current type of that named_obj.
 	 */
 	status = acpi_ns_attach_object (info->field_node, obj_desc,
-			  (u8) acpi_ns_get_type (info->field_node));
+			  acpi_ns_get_type (info->field_node));
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "set Named_obj %p (%4.4s) val = %p\n",
-		info->field_node, (char*)&(info->field_node->name), obj_desc));
+	ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "set named_obj %p (%4.4s) val = %p\n",
+			info->field_node, info->field_node->name.ascii, obj_desc));
 
 	/* Remove local reference to the object */
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exregion.c linux-2.4.22-pre2/drivers/acpi/executer/exregion.c
--- linux-2.4.21/drivers/acpi/executer/exregion.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exregion.c	2003-06-26 21:43:12.000000000 +0000
@@ -1,52 +1,66 @@
 
 /******************************************************************************
  *
- * Module Name: exregion - ACPI default Op_region (address space) handlers
- *              $Revision: 61 $
+ * Module Name: exregion - ACPI default op_region (address space) handlers
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acinterp.h"
-#include "amlcode.h"
-#include "acnamesp.h"
-#include "achware.h"
-#include "acevents.h"
+#include <acpi/acpi.h>
+#include <acpi/acinterp.h>
 
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exregion")
+	 ACPI_MODULE_NAME    ("exregion")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_system_memory_space_handler
+ * FUNCTION:    acpi_ex_system_memory_space_handler
  *
  * PARAMETERS:  Function            - Read or Write operation
  *              Address             - Where in the space to read or write
- *              Bit_width           - Field width in bits (8, 16, or 32)
+ *              bit_width           - Field width in bits (8, 16, or 32)
  *              Value               - Pointer to in or out value
- *              Handler_context     - Pointer to Handler's context
- *              Region_context      - Pointer to context specific to the
+ *              handler_context     - Pointer to Handler's context
+ *              region_context      - Pointer to context specific to the
  *                                    accessed region
  *
  * RETURN:      Status
@@ -57,20 +71,23 @@
 
 acpi_status
 acpi_ex_system_memory_space_handler (
-	u32                     function,
-	ACPI_PHYSICAL_ADDRESS   address,
-	u32                     bit_width,
-	u32                     *value,
-	void                    *handler_context,
-	void                    *region_context)
+	u32                             function,
+	acpi_physical_address           address,
+	u32                             bit_width,
+	acpi_integer                    *value,
+	void                            *handler_context,
+	void                            *region_context)
 {
-	acpi_status             status = AE_OK;
-	void                    *logical_addr_ptr = NULL;
-	acpi_mem_space_context  *mem_info = region_context;
-	u32                     length;
+	acpi_status                     status = AE_OK;
+	void                            *logical_addr_ptr = NULL;
+	struct acpi_mem_space_context   *mem_info = region_context;
+	u32                             length;
+	acpi_size                       window_size;
+#ifndef ACPI_MISALIGNED_TRANSFERS
+	u32                             remainder;
+#endif
 
-
-	FUNCTION_TRACE ("Ex_system_memory_space_handler");
+	ACPI_FUNCTION_TRACE ("ex_system_memory_space_handler");
 
 
 	/* Validate and translate the bit width */
@@ -88,14 +105,28 @@
 		length = 4;
 		break;
 
+	case 64:
+		length = 8;
+		break;
+
 	default:
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid System_memory width %d\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid system_memory width %d\n",
 			bit_width));
 		return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
-		break;
 	}
 
 
+#ifndef ACPI_MISALIGNED_TRANSFERS
+	/*
+	 * Hardware does not support non-aligned data transfers, we must verify
+	 * the request.
+	 */
+	(void) acpi_ut_short_divide ((acpi_integer *) &address, length, NULL, &remainder);
+	if (remainder != 0) {
+		return_ACPI_STATUS (AE_AML_ALIGNMENT);
+	}
+#endif
+
 	/*
 	 * Does the request fit into the cached memory mapping?
 	 * Is 1) Address below the current mapping? OR
@@ -115,61 +146,80 @@
 					   mem_info->mapped_length);
 		}
 
-		mem_info->mapped_length = 0; /* In case of failure below */
+		/*
+		 * Don't attempt to map memory beyond the end of the region, and
+		 * constrain the maximum mapping size to something reasonable.
+		 */
+		window_size = (acpi_size) ((mem_info->address + mem_info->length) - address);
+		if (window_size > ACPI_SYSMEM_REGION_WINDOW_SIZE) {
+			window_size = ACPI_SYSMEM_REGION_WINDOW_SIZE;
+		}
 
 		/* Create a new mapping starting at the address given */
 
-		status = acpi_os_map_memory (address, SYSMEM_REGION_WINDOW_SIZE,
+		status = acpi_os_map_memory (address, window_size,
 				  (void **) &mem_info->mapped_logical_address);
 		if (ACPI_FAILURE (status)) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %8.8X%8.8X, size %X\n",
+				ACPI_HIDWORD (address), ACPI_LODWORD (address), (u32) window_size));
+			mem_info->mapped_length = 0;
 			return_ACPI_STATUS (status);
 		}
 
 		/* Save the physical address and mapping size */
 
 		mem_info->mapped_physical_address = address;
-		mem_info->mapped_length = SYSMEM_REGION_WINDOW_SIZE;
+		mem_info->mapped_length = window_size;
 	}
 
-
 	/*
 	 * Generate a logical pointer corresponding to the address we want to
 	 * access
 	 */
-
-	/* TBD: should these pointers go to 64-bit in all cases ? */
-
 	logical_addr_ptr = mem_info->mapped_logical_address +
 			  ((acpi_integer) address - (acpi_integer) mem_info->mapped_physical_address);
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-		"System_memory %d (%d width) Address=%8.8X%8.8X\n", function, bit_width,
-		HIDWORD (address), LODWORD (address)));
-
-   /* Perform the memory read or write */
+		"system_memory %d (%d width) Address=%8.8X%8.8X\n", function, bit_width,
+		ACPI_HIDWORD (address), ACPI_LODWORD (address)));
 
+   /*
+	* Perform the memory read or write
+	*
+	* Note: For machines that do not support non-aligned transfers, the target
+	* address was checked for alignment above.  We do not attempt to break the
+	* transfer up into smaller (byte-size) chunks because the AML specifically
+	* asked for a transfer width that the hardware may require.
+	*/
 	switch (function) {
+	case ACPI_READ:
 
-	case ACPI_READ_ADR_SPACE:
-
+		*value = 0;
 		switch (bit_width) {
 		case 8:
-			*value = (u32)* (u8 *) logical_addr_ptr;
+			*value = (acpi_integer) *((u8 *) logical_addr_ptr);
 			break;
 
 		case 16:
-			MOVE_UNALIGNED16_TO_32 (value, logical_addr_ptr);
+			*value = (acpi_integer) *((u16 *) logical_addr_ptr);
 			break;
 
 		case 32:
-			MOVE_UNALIGNED32_TO_32 (value, logical_addr_ptr);
+			*value = (acpi_integer) *((u32 *) logical_addr_ptr);
 			break;
-		}
 
+#if ACPI_MACHINE_WIDTH != 16
+		case 64:
+			*value = (acpi_integer) *((u64 *) logical_addr_ptr);
+			break;
+#endif
+		default:
+			/* bit_width was already validated */
+			break;
+		}
 		break;
 
-
-	case ACPI_WRITE_ADR_SPACE:
+	case ACPI_WRITE:
 
 		switch (bit_width) {
 		case 8:
@@ -177,16 +227,24 @@
 			break;
 
 		case 16:
-			MOVE_UNALIGNED16_TO_16 (logical_addr_ptr, value);
+			*(u16 *) logical_addr_ptr = (u16) *value;
 			break;
 
 		case 32:
-			MOVE_UNALIGNED32_TO_32 (logical_addr_ptr, value);
+			*(u32 *) logical_addr_ptr = (u32) *value;
 			break;
-		}
 
-		break;
+#if ACPI_MACHINE_WIDTH != 16
+		case 64:
+			*(u64 *) logical_addr_ptr = (u64) *value;
+			break;
+#endif
 
+		default:
+			/* bit_width was already validated */
+			break;
+		}
+		break;
 
 	default:
 		status = AE_BAD_PARAMETER;
@@ -199,14 +257,14 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_system_io_space_handler
+ * FUNCTION:    acpi_ex_system_io_space_handler
  *
  * PARAMETERS:  Function            - Read or Write operation
  *              Address             - Where in the space to read or write
- *              Bit_width           - Field width in bits (8, 16, or 32)
+ *              bit_width           - Field width in bits (8, 16, or 32)
  *              Value               - Pointer to in or out value
- *              Handler_context     - Pointer to Handler's context
- *              Region_context      - Pointer to context specific to the
+ *              handler_context     - Pointer to Handler's context
+ *              region_context      - Pointer to context specific to the
  *                                    accessed region
  *
  * RETURN:      Status
@@ -217,40 +275,38 @@
 
 acpi_status
 acpi_ex_system_io_space_handler (
-	u32                     function,
-	ACPI_PHYSICAL_ADDRESS   address,
-	u32                     bit_width,
-	u32                     *value,
-	void                    *handler_context,
-	void                    *region_context)
+	u32                             function,
+	acpi_physical_address           address,
+	u32                             bit_width,
+	acpi_integer                    *value,
+	void                            *handler_context,
+	void                            *region_context)
 {
-	acpi_status             status = AE_OK;
+	acpi_status                     status = AE_OK;
+	u32                             value32;
 
 
-	FUNCTION_TRACE ("Ex_system_io_space_handler");
+	ACPI_FUNCTION_TRACE ("ex_system_io_space_handler");
 
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-		"System_iO %d (%d width) Address=%8.8X%8.8X\n", function, bit_width,
-		HIDWORD (address), LODWORD (address)));
+		"system_iO %d (%d width) Address=%8.8X%8.8X\n", function, bit_width,
+		ACPI_HIDWORD (address), ACPI_LODWORD (address)));
 
 	/* Decode the function parameter */
 
 	switch (function) {
+	case ACPI_READ:
 
-	case ACPI_READ_ADR_SPACE:
-
-		*value = 0;
-		status = acpi_os_read_port ((ACPI_IO_ADDRESS) address, value, bit_width);
+		status = acpi_os_read_port ((acpi_io_address) address, &value32, bit_width);
+		*value = value32;
 		break;
 
+	case ACPI_WRITE:
 
-	case ACPI_WRITE_ADR_SPACE:
-
-		status = acpi_os_write_port ((ACPI_IO_ADDRESS) address, *value, bit_width);
+		status = acpi_os_write_port ((acpi_io_address) address, (u32) *value, bit_width);
 		break;
 
-
 	default:
 		status = AE_BAD_PARAMETER;
 		break;
@@ -262,14 +318,14 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_pci_config_space_handler
+ * FUNCTION:    acpi_ex_pci_config_space_handler
  *
  * PARAMETERS:  Function            - Read or Write operation
  *              Address             - Where in the space to read or write
- *              Bit_width           - Field width in bits (8, 16, or 32)
+ *              bit_width           - Field width in bits (8, 16, or 32)
  *              Value               - Pointer to in or out value
- *              Handler_context     - Pointer to Handler's context
- *              Region_context      - Pointer to context specific to the
+ *              handler_context     - Pointer to Handler's context
+ *              region_context      - Pointer to context specific to the
  *                                    accessed region
  *
  * RETURN:      Status
@@ -280,56 +336,53 @@
 
 acpi_status
 acpi_ex_pci_config_space_handler (
-	u32                     function,
-	ACPI_PHYSICAL_ADDRESS   address,
-	u32                     bit_width,
-	u32                     *value,
-	void                    *handler_context,
-	void                    *region_context)
+	u32                             function,
+	acpi_physical_address           address,
+	u32                             bit_width,
+	acpi_integer                    *value,
+	void                            *handler_context,
+	void                            *region_context)
 {
-	acpi_status             status = AE_OK;
-	acpi_pci_id             *pci_id;
-	u16                     pci_register;
+	acpi_status                     status = AE_OK;
+	struct acpi_pci_id              *pci_id;
+	u16                             pci_register;
 
 
-	FUNCTION_TRACE ("Ex_pci_config_space_handler");
+	ACPI_FUNCTION_TRACE ("ex_pci_config_space_handler");
 
 
 	/*
-	 *  The arguments to Acpi_os(Read|Write)Pci_cfg(Byte|Word|Dword) are:
+	 *  The arguments to acpi_os(Read|Write)pci_configuration are:
 	 *
-	 *  Pci_segment is the PCI bus segment range 0-31
-	 *  Pci_bus     is the PCI bus number range 0-255
-	 *  Pci_device  is the PCI device number range 0-31
-	 *  Pci_function is the PCI device function number
-	 *  Pci_register is the Config space register range 0-255 bytes
+	 *  pci_segment is the PCI bus segment range 0-31
+	 *  pci_bus     is the PCI bus number range 0-255
+	 *  pci_device  is the PCI device number range 0-31
+	 *  pci_function is the PCI device function number
+	 *  pci_register is the Config space register range 0-255 bytes
 	 *
 	 *  Value - input value for write, output address for read
 	 *
 	 */
-	pci_id      = (acpi_pci_id *) region_context;
-	pci_register = (u16) address;
+	pci_id      = (struct acpi_pci_id *) region_context;
+	pci_register = (u16) (u32) address;
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-		"Pci_config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n",
+		"pci_config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n",
 		function, bit_width, pci_id->segment, pci_id->bus, pci_id->device,
 		pci_id->function, pci_register));
 
 	switch (function) {
-
-	case ACPI_READ_ADR_SPACE:
+	case ACPI_READ:
 
 		*value = 0;
 		status = acpi_os_read_pci_configuration (pci_id, pci_register, value, bit_width);
 		break;
 
-
-	case ACPI_WRITE_ADR_SPACE:
+	case ACPI_WRITE:
 
 		status = acpi_os_write_pci_configuration (pci_id, pci_register, *value, bit_width);
 		break;
 
-
 	default:
 
 		status = AE_BAD_PARAMETER;
@@ -342,14 +395,14 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_cmos_space_handler
+ * FUNCTION:    acpi_ex_cmos_space_handler
  *
  * PARAMETERS:  Function            - Read or Write operation
  *              Address             - Where in the space to read or write
- *              Bit_width           - Field width in bits (8, 16, or 32)
+ *              bit_width           - Field width in bits (8, 16, or 32)
  *              Value               - Pointer to in or out value
- *              Handler_context     - Pointer to Handler's context
- *              Region_context      - Pointer to context specific to the
+ *              handler_context     - Pointer to Handler's context
+ *              region_context      - Pointer to context specific to the
  *                                    accessed region
  *
  * RETURN:      Status
@@ -360,17 +413,17 @@
 
 acpi_status
 acpi_ex_cmos_space_handler (
-	u32                     function,
-	ACPI_PHYSICAL_ADDRESS   address,
-	u32                     bit_width,
-	u32                     *value,
-	void                    *handler_context,
-	void                    *region_context)
+	u32                             function,
+	acpi_physical_address           address,
+	u32                             bit_width,
+	acpi_integer                    *value,
+	void                            *handler_context,
+	void                            *region_context)
 {
-	acpi_status             status = AE_OK;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE ("Ex_cmos_space_handler");
+	ACPI_FUNCTION_TRACE ("ex_cmos_space_handler");
 
 
 	return_ACPI_STATUS (status);
@@ -379,37 +432,97 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_pci_bar_space_handler
+ * FUNCTION:    acpi_ex_pci_bar_space_handler
  *
  * PARAMETERS:  Function            - Read or Write operation
  *              Address             - Where in the space to read or write
- *              Bit_width           - Field width in bits (8, 16, or 32)
+ *              bit_width           - Field width in bits (8, 16, or 32)
  *              Value               - Pointer to in or out value
- *              Handler_context     - Pointer to Handler's context
- *              Region_context      - Pointer to context specific to the
+ *              handler_context     - Pointer to Handler's context
+ *              region_context      - Pointer to context specific to the
  *                                    accessed region
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Handler for the PCI Bar_target address space (Op Region)
+ * DESCRIPTION: Handler for the PCI bar_target address space (Op Region)
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ex_pci_bar_space_handler (
-	u32                     function,
-	ACPI_PHYSICAL_ADDRESS   address,
-	u32                     bit_width,
-	u32                     *value,
-	void                    *handler_context,
-	void                    *region_context)
+	u32                             function,
+	acpi_physical_address           address,
+	u32                             bit_width,
+	acpi_integer                    *value,
+	void                            *handler_context,
+	void                            *region_context)
 {
-	acpi_status             status = AE_OK;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE ("Ex_pci_bar_space_handler");
+	ACPI_FUNCTION_TRACE ("ex_pci_bar_space_handler");
 
 
 	return_ACPI_STATUS (status);
 }
 
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ex_data_table_space_handler
+ *
+ * PARAMETERS:  Function            - Read or Write operation
+ *              Address             - Where in the space to read or write
+ *              bit_width           - Field width in bits (8, 16, or 32)
+ *              Value               - Pointer to in or out value
+ *              handler_context     - Pointer to Handler's context
+ *              region_context      - Pointer to context specific to the
+ *                                    accessed region
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Handler for the Data Table address space (Op Region)
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ex_data_table_space_handler (
+	u32                             function,
+	acpi_physical_address           address,
+	u32                             bit_width,
+	acpi_integer                    *value,
+	void                            *handler_context,
+	void                            *region_context)
+{
+	acpi_status                     status = AE_OK;
+	u32                             byte_width = ACPI_DIV_8 (bit_width);
+	u32                             i;
+	char                            *logical_addr_ptr;
+
+
+	ACPI_FUNCTION_TRACE ("ex_data_table_space_handler");
+
+
+	logical_addr_ptr = ACPI_PHYSADDR_TO_PTR (address);
+
+
+   /* Perform the memory read or write */
+
+	switch (function) {
+	case ACPI_READ:
+
+		for (i = 0; i < byte_width; i++) {
+			((char *) value) [i] = logical_addr_ptr[i];
+		}
+		break;
+
+	case ACPI_WRITE:
+	default:
+
+		return_ACPI_STATUS (AE_SUPPORT);
+	}
+
+	return_ACPI_STATUS (status);
+}
+
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exresnte.c linux-2.4.22-pre2/drivers/acpi/executer/exresnte.c
--- linux-2.4.21/drivers/acpi/executer/exresnte.c	2002-08-03 00:39:43.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exresnte.c	2003-06-26 21:43:14.000000000 +0000
@@ -2,51 +2,65 @@
 /******************************************************************************
  *
  * Module Name: exresnte - AML Interpreter object resolution
- *              $Revision: 43 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "amlcode.h"
-#include "acparser.h"
-#include "acdispat.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "actables.h"
-#include "acevents.h"
+#include <acpi/acpi.h>
+#include <acpi/acdispat.h>
+#include <acpi/acinterp.h>
+#include <acpi/acnamesp.h>
 
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exresnte")
+	 ACPI_MODULE_NAME    ("exresnte")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_resolve_node_to_value
+ * FUNCTION:    acpi_ex_resolve_node_to_value
  *
- * PARAMETERS:  Object_ptr      - Pointer to a location that contains
+ * PARAMETERS:  object_ptr      - Pointer to a location that contains
  *                                a pointer to a NS node, and will receive a
  *                                pointer to the resolved object.
- *              Walk_state      - Current state.  Valid only if executing AML
+ *              walk_state      - Current state.  Valid only if executing AML
  *                                code.  NULL if simply resolving an object
  *
  * RETURN:      Status
@@ -67,32 +81,39 @@
 
 acpi_status
 acpi_ex_resolve_node_to_value (
-	acpi_namespace_node     **object_ptr,
-	acpi_walk_state         *walk_state)
+	struct acpi_namespace_node      **object_ptr,
+	struct acpi_walk_state          *walk_state)
 
 {
-	acpi_status             status = AE_OK;
-	acpi_operand_object     *source_desc;
-	acpi_operand_object     *obj_desc = NULL;
-	acpi_namespace_node     *node;
-	acpi_object_type8       entry_type;
-	acpi_integer            temp_val;
+	acpi_status                     status = AE_OK;
+	union acpi_operand_object       *source_desc;
+	union acpi_operand_object       *obj_desc = NULL;
+	struct acpi_namespace_node      *node;
+	acpi_object_type                entry_type;
 
 
-	FUNCTION_TRACE ("Ex_resolve_node_to_value");
+	ACPI_FUNCTION_TRACE ("ex_resolve_node_to_value");
 
 
 	/*
-	 * The stack pointer points to a acpi_namespace_node (Node).  Get the
+	 * The stack pointer points to a struct acpi_namespace_node (Node).  Get the
 	 * object that is attached to the Node.
 	 */
-	node      = *object_ptr;
-	source_desc  = acpi_ns_get_attached_object (node);
+	node       = *object_ptr;
+	source_desc = acpi_ns_get_attached_object (node);
 	entry_type = acpi_ns_get_type ((acpi_handle) node);
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p Source_desc=%p Type=%X\n",
-		 node, source_desc, entry_type));
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p source_desc=%p [%s]\n",
+		 node, source_desc, acpi_ut_get_type_name (entry_type)));
 
+	if (entry_type == ACPI_TYPE_LOCAL_ALIAS) {
+		/* There is always exactly one level of indirection */
+
+		node       = (struct acpi_namespace_node *) node->object;
+		source_desc = acpi_ns_get_attached_object (node);
+		entry_type = acpi_ns_get_type ((acpi_handle) node);
+		*object_ptr = node;
+	}
 
 	/*
 	 * Several object types require no further processing:
@@ -115,42 +136,47 @@
 	 * of the attached object or pointer
 	 */
 	switch (entry_type) {
-
 	case ACPI_TYPE_PACKAGE:
 
-		if (ACPI_TYPE_PACKAGE != source_desc->common.type) {
+		if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_PACKAGE) {
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a Package, type %s\n",
-				acpi_ut_get_type_name (source_desc->common.type)));
+				acpi_ut_get_object_type_name (source_desc)));
 			return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 		}
 
-		/* Return an additional reference to the object */
+		status = acpi_ds_get_package_arguments (source_desc);
+		if (ACPI_SUCCESS (status)) {
+			/* Return an additional reference to the object */
 
-		obj_desc = source_desc;
-		acpi_ut_add_reference (obj_desc);
+			obj_desc = source_desc;
+			acpi_ut_add_reference (obj_desc);
+		}
 		break;
 
 
 	case ACPI_TYPE_BUFFER:
 
-		if (ACPI_TYPE_BUFFER != source_desc->common.type) {
+		if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_BUFFER) {
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a Buffer, type %s\n",
-				acpi_ut_get_type_name (source_desc->common.type)));
+				acpi_ut_get_object_type_name (source_desc)));
 			return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 		}
 
-		/* Return an additional reference to the object */
+		status = acpi_ds_get_buffer_arguments (source_desc);
+		if (ACPI_SUCCESS (status)) {
+			/* Return an additional reference to the object */
 
-		obj_desc = source_desc;
-		acpi_ut_add_reference (obj_desc);
+			obj_desc = source_desc;
+			acpi_ut_add_reference (obj_desc);
+		}
 		break;
 
 
 	case ACPI_TYPE_STRING:
 
-		if (ACPI_TYPE_STRING != source_desc->common.type) {
+		if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_STRING) {
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a String, type %s\n",
-				acpi_ut_get_type_name (source_desc->common.type)));
+				acpi_ut_get_object_type_name (source_desc)));
 			return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 		}
 
@@ -163,9 +189,9 @@
 
 	case ACPI_TYPE_INTEGER:
 
-		if (ACPI_TYPE_INTEGER != source_desc->common.type) {
+		if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_INTEGER) {
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a Integer, type %s\n",
-				acpi_ut_get_type_name (source_desc->common.type)));
+				acpi_ut_get_object_type_name (source_desc)));
 			return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 		}
 
@@ -177,17 +203,16 @@
 
 
 	case ACPI_TYPE_BUFFER_FIELD:
-	case INTERNAL_TYPE_REGION_FIELD:
-	case INTERNAL_TYPE_BANK_FIELD:
-	case INTERNAL_TYPE_INDEX_FIELD:
+	case ACPI_TYPE_LOCAL_REGION_FIELD:
+	case ACPI_TYPE_LOCAL_BANK_FIELD:
+	case ACPI_TYPE_LOCAL_INDEX_FIELD:
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Field_read Node=%p Source_desc=%p Type=%X\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "field_read Node=%p source_desc=%p Type=%X\n",
 			node, source_desc, entry_type));
 
-		status = acpi_ex_read_data_from_field (source_desc, &obj_desc);
+		status = acpi_ex_read_data_from_field (walk_state, source_desc, &obj_desc);
 		break;
 
-
 	/*
 	 * For these objects, just return the object attached to the Node
 	 */
@@ -206,7 +231,7 @@
 		break;
 
 
-	/* TYPE_Any is untyped, and thus there is no object associated with it */
+	/* TYPE_ANY is untyped, and thus there is no object associated with it */
 
 	case ACPI_TYPE_ANY:
 
@@ -214,64 +239,16 @@
 			node));
 
 		return_ACPI_STATUS (AE_AML_OPERAND_TYPE);  /* Cannot be AE_TYPE */
-		break;
-
-
-	/*
-	 * The only named references allowed are named constants
-	 *   e.g. -- Name (\OSFL, Ones)
-	 */
-	case INTERNAL_TYPE_REFERENCE:
 
-		switch (source_desc->reference.opcode) {
 
-		case AML_ZERO_OP:
+	case ACPI_TYPE_LOCAL_REFERENCE:
 
-			temp_val = 0;
-			break;
+		/* No named references are allowed here */
 
-		case AML_ONE_OP:
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported Reference opcode %X\n",
+			source_desc->reference.opcode));
 
-			temp_val = 1;
-			break;
-
-		case AML_ONES_OP:
-
-			temp_val = ACPI_INTEGER_MAX;
-			break;
-
-		case AML_REVISION_OP:
-
-			temp_val = ACPI_CA_SUPPORT_LEVEL;
-			break;
-
-		default:
-
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported reference opcode %X\n",
-				source_desc->reference.opcode));
-
-			return_ACPI_STATUS (AE_AML_BAD_OPCODE);
-		}
-
-		/* Create object for result */
-
-		obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
-		if (!obj_desc) {
-			return_ACPI_STATUS (AE_NO_MEMORY);
-		}
-
-		obj_desc->integer.value = temp_val;
-
-		/*
-		 * Truncate value if we are executing from a 32-bit ACPI table
-		 * AND actually executing AML code.  If we are resolving
-		 * an object in the namespace via an external call to the
-		 * subsystem, we will have a null Walk_state
-		 */
-		if (walk_state) {
-			acpi_ex_truncate_for32bit_table (obj_desc, walk_state);
-		}
-		break;
+		return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 
 
 	/* Default case is for unknown types */
@@ -283,7 +260,7 @@
 
 		return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 
-	} /* switch (Entry_type) */
+	} /* switch (entry_type) */
 
 
 	/* Put the object descriptor on the stack */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exresolv.c linux-2.4.22-pre2/drivers/acpi/executer/exresolv.c
--- linux-2.4.21/drivers/acpi/executer/exresolv.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exresolv.c	2003-06-26 21:43:18.000000000 +0000
@@ -2,156 +2,66 @@
 /******************************************************************************
  *
  * Module Name: exresolv - AML Interpreter object resolution
- *              $Revision: 101 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "amlcode.h"
-#include "acparser.h"
-#include "acdispat.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "actables.h"
-#include "acevents.h"
+#include <acpi/acpi.h>
+#include <acpi/amlcode.h>
+#include <acpi/acdispat.h>
+#include <acpi/acinterp.h>
+#include <acpi/acnamesp.h>
 
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exresolv")
+	 ACPI_MODULE_NAME    ("exresolv")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_get_buffer_field_value
+ * FUNCTION:    acpi_ex_resolve_to_value
  *
- * PARAMETERS:  *Obj_desc           - Pointer to a Buffer_field
- *              *Result_desc        - Pointer to an empty descriptor which will
- *                                    become an Integer with the field's value
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Retrieve the value from a Buffer_field
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ex_get_buffer_field_value (
-	acpi_operand_object     *obj_desc,
-	acpi_operand_object     *result_desc)
-{
-	acpi_status             status;
-	u32                     mask;
-	u8                      *location;
-
-
-	FUNCTION_TRACE ("Ex_get_buffer_field_value");
-
-
-	/*
-	 * Parameter validation
-	 */
-	if (!obj_desc) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null field pointer\n"));
-		return_ACPI_STATUS (AE_AML_NO_OPERAND);
-	}
-
-	if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
-		status = acpi_ds_get_buffer_field_arguments (obj_desc);
-		if (ACPI_FAILURE (status)) {
-			return_ACPI_STATUS (status);
-		}
-	}
-
-	if (!obj_desc->buffer_field.buffer_obj) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null container pointer\n"));
-		return_ACPI_STATUS (AE_AML_INTERNAL);
-	}
-
-	if (ACPI_TYPE_BUFFER != obj_desc->buffer_field.buffer_obj->common.type) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - container is not a Buffer\n"));
-		return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
-	}
-
-	if (!result_desc) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null result pointer\n"));
-		return_ACPI_STATUS (AE_AML_INTERNAL);
-	}
-
-
-	/* Field location is (base of buffer) + (byte offset) */
-
-	location = obj_desc->buffer_field.buffer_obj->buffer.pointer
-			 + obj_desc->buffer_field.base_byte_offset;
-
-	/*
-	 * Construct Mask with as many 1 bits as the field width
-	 *
-	 * NOTE: Only the bottom 5 bits are valid for a shift operation, so
-	 *  special care must be taken for any shift greater than 31 bits.
-	 *
-	 * TBD: [Unhandled] Fields greater than 32 bits will not work.
-	 */
-	if (obj_desc->buffer_field.bit_length < 32) {
-		mask = ((u32) 1 << obj_desc->buffer_field.bit_length) - (u32) 1;
-	}
-	else {
-		mask = ACPI_UINT32_MAX;
-	}
-
-	result_desc->integer.type = (u8) ACPI_TYPE_INTEGER;
-
-	/* Get the 32 bit value at the location */
-
-	MOVE_UNALIGNED32_TO_32 (&result_desc->integer.value, location);
-
-	/*
-	 * Shift the 32-bit word containing the field, and mask off the
-	 * resulting value
-	 */
-	result_desc->integer.value =
-		(result_desc->integer.value >> obj_desc->buffer_field.start_field_bit_offset) & mask;
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-		"** Read from buffer %p byte %d bit %d width %d addr %p mask %08X val %8.8X%8.8X\n",
-		obj_desc->buffer_field.buffer_obj->buffer.pointer,
-		obj_desc->buffer_field.base_byte_offset,
-		obj_desc->buffer_field.start_field_bit_offset,
-		obj_desc->buffer_field.bit_length,
-		location, mask,
-		HIDWORD(result_desc->integer.value),
-		LODWORD(result_desc->integer.value)));
-
-	return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ex_resolve_to_value
- *
- * PARAMETERS:  **Stack_ptr         - Points to entry on Obj_stack, which can
- *                                    be either an (acpi_operand_object *)
+ * PARAMETERS:  **stack_ptr         - Points to entry on obj_stack, which can
+ *                                    be either an (union acpi_operand_object *)
  *                                    or an acpi_handle.
- *              Walk_state          - Current method state
+ *              walk_state          - Current method state
  *
  * RETURN:      Status
  *
@@ -161,13 +71,13 @@
 
 acpi_status
 acpi_ex_resolve_to_value (
-	acpi_operand_object     **stack_ptr,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       **stack_ptr,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE_PTR ("Ex_resolve_to_value", stack_ptr);
+	ACPI_FUNCTION_TRACE_PTR ("ex_resolve_to_value", stack_ptr);
 
 
 	if (!stack_ptr || !*stack_ptr) {
@@ -175,13 +85,12 @@
 		return_ACPI_STATUS (AE_AML_NO_OPERAND);
 	}
 
-
 	/*
-	 * The entity pointed to by the Stack_ptr can be either
-	 * 1) A valid acpi_operand_object, or
-	 * 2) A acpi_namespace_node (Named_obj)
+	 * The entity pointed to by the stack_ptr can be either
+	 * 1) A valid union acpi_operand_object, or
+	 * 2) A struct acpi_namespace_node (named_obj)
 	 */
-	if (VALID_DESCRIPTOR_TYPE (*stack_ptr, ACPI_DESC_TYPE_INTERNAL)) {
+	if (ACPI_GET_DESCRIPTOR_TYPE (*stack_ptr) == ACPI_DESC_TYPE_OPERAND) {
 		status = acpi_ex_resolve_object_to_value (stack_ptr, walk_state);
 		if (ACPI_FAILURE (status)) {
 			return_ACPI_STATUS (status);
@@ -189,30 +98,30 @@
 	}
 
 	/*
-	 * Object on the stack may have changed if Acpi_ex_resolve_object_to_value()
+	 * Object on the stack may have changed if acpi_ex_resolve_object_to_value()
 	 * was called (i.e., we can't use an _else_ here.)
 	 */
-	if (VALID_DESCRIPTOR_TYPE (*stack_ptr, ACPI_DESC_TYPE_NAMED)) {
-		status = acpi_ex_resolve_node_to_value ((acpi_namespace_node **) stack_ptr,
+	if (ACPI_GET_DESCRIPTOR_TYPE (*stack_ptr) == ACPI_DESC_TYPE_NAMED) {
+		status = acpi_ex_resolve_node_to_value (
+				  ACPI_CAST_INDIRECT_PTR (struct acpi_namespace_node, stack_ptr),
 				  walk_state);
 		if (ACPI_FAILURE (status)) {
 			return_ACPI_STATUS (status);
 		}
 	}
 
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Resolved object %p\n", *stack_ptr));
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *stack_ptr));
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_resolve_object_to_value
+ * FUNCTION:    acpi_ex_resolve_object_to_value
  *
- * PARAMETERS:  Stack_ptr       - Pointer to a stack location that contains a
+ * PARAMETERS:  stack_ptr       - Pointer to a stack location that contains a
  *                                ptr to an internal object.
- *              Walk_state      - Current method state
+ *              walk_state      - Current method state
  *
  * RETURN:      Status
  *
@@ -223,36 +132,34 @@
 
 acpi_status
 acpi_ex_resolve_object_to_value (
-	acpi_operand_object     **stack_ptr,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       **stack_ptr,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status = AE_OK;
-	acpi_operand_object     *stack_desc;
-	void                    *temp_node;
-	acpi_operand_object     *obj_desc;
-	u16                     opcode;
+	acpi_status                     status = AE_OK;
+	union acpi_operand_object       *stack_desc;
+	void                            *temp_node;
+	union acpi_operand_object       *obj_desc;
+	u16                             opcode;
 
 
-	FUNCTION_TRACE ("Ex_resolve_object_to_value");
+	ACPI_FUNCTION_TRACE ("ex_resolve_object_to_value");
 
 
 	stack_desc = *stack_ptr;
 
-	/* This is an acpi_operand_object  */
+	/* This is an union acpi_operand_object    */
 
-	switch (stack_desc->common.type) {
-
-	case INTERNAL_TYPE_REFERENCE:
+	switch (ACPI_GET_OBJECT_TYPE (stack_desc)) {
+	case ACPI_TYPE_LOCAL_REFERENCE:
 
 		opcode = stack_desc->reference.opcode;
 
 		switch (opcode) {
-
 		case AML_NAME_OP:
 
 			/*
 			 * Convert indirect name ptr to a direct name ptr.
-			 * Then, Acpi_ex_resolve_node_to_value can be used to get the value
+			 * Then, acpi_ex_resolve_node_to_value can be used to get the value
 			 */
 			temp_node = stack_desc->reference.object;
 
@@ -286,58 +193,11 @@
 			acpi_ut_remove_reference (stack_desc);
 			*stack_ptr = obj_desc;
 
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "[Arg/Local %d] Value_obj is %p\n",
+			ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %d] value_obj is %p\n",
 				stack_desc->reference.offset, obj_desc));
 			break;
 
 
-		/*
-		 * For constants, we must change the reference/constant object
-		 * to a real integer object
-		 */
-		case AML_ZERO_OP:
-		case AML_ONE_OP:
-		case AML_ONES_OP:
-		case AML_REVISION_OP:
-
-			/* Create a new integer object */
-
-			obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
-			if (!obj_desc) {
-				return_ACPI_STATUS (AE_NO_MEMORY);
-			}
-
-			switch (opcode) {
-			case AML_ZERO_OP:
-				obj_desc->integer.value = 0;
-				break;
-
-			case AML_ONE_OP:
-				obj_desc->integer.value = 1;
-				break;
-
-			case AML_ONES_OP:
-				obj_desc->integer.value = ACPI_INTEGER_MAX;
-
-				/* Truncate value if we are executing from a 32-bit ACPI table */
-
-				acpi_ex_truncate_for32bit_table (obj_desc, walk_state);
-				break;
-
-			case AML_REVISION_OP:
-				obj_desc->integer.value = ACPI_CA_SUPPORT_LEVEL;
-				break;
-			}
-
-			/*
-			 * Remove a reference from the original reference object
-			 * and put the new object in its place
-			 */
-			acpi_ut_remove_reference (stack_desc);
-			*stack_ptr = obj_desc;
-			break;
-
-
 		case AML_INDEX_OP:
 
 			switch (stack_desc->reference.target_type) {
@@ -348,6 +208,7 @@
 
 
 			case ACPI_TYPE_PACKAGE:
+
 				obj_desc = *stack_desc->reference.where;
 				if (obj_desc) {
 					/*
@@ -359,7 +220,6 @@
 					acpi_ut_add_reference (obj_desc);
 					*stack_ptr = obj_desc;
 				}
-
 				else {
 					/*
 					 * A NULL object descriptor means an unitialized element of
@@ -372,83 +232,243 @@
 				}
 				break;
 
+
 			default:
+
 				/* Invalid reference object */
 
 				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-					"Unknown Target_type %X in Index/Reference obj %p\n",
+					"Unknown target_type %X in Index/Reference obj %p\n",
 					stack_desc->reference.target_type, stack_desc));
 				status = AE_AML_INTERNAL;
 				break;
 			}
-
 			break;
 
 
+		case AML_REF_OF_OP:
 		case AML_DEBUG_OP:
 
 			/* Just leave the object as-is */
+
 			break;
 
 
 		default:
 
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference object subtype %02X in %p\n",
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference opcode %X in %p\n",
 				opcode, stack_desc));
 			status = AE_AML_INTERNAL;
 			break;
+		}
+		break;
 
-		}   /* switch (Opcode) */
 
-		break; /* case INTERNAL_TYPE_REFERENCE */
+	case ACPI_TYPE_BUFFER:
 
+		status = acpi_ds_get_buffer_arguments (stack_desc);
+		break;
 
-	case ACPI_TYPE_BUFFER_FIELD:
 
-		obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_ANY);
-		if (!obj_desc) {
-			return_ACPI_STATUS (AE_NO_MEMORY);
-		}
+	case ACPI_TYPE_PACKAGE:
+
+		status = acpi_ds_get_package_arguments (stack_desc);
+		break;
 
-		status = acpi_ex_get_buffer_field_value (stack_desc, obj_desc);
-		if (ACPI_FAILURE (status)) {
-			acpi_ut_remove_reference (obj_desc);
-			obj_desc = NULL;
-		}
 
+	/*
+	 * These cases may never happen here, but just in case..
+	 */
+	case ACPI_TYPE_BUFFER_FIELD:
+	case ACPI_TYPE_LOCAL_REGION_FIELD:
+	case ACPI_TYPE_LOCAL_BANK_FIELD:
+	case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "field_read source_desc=%p Type=%X\n",
+			stack_desc, ACPI_GET_OBJECT_TYPE (stack_desc)));
+
+		status = acpi_ex_read_data_from_field (walk_state, stack_desc, &obj_desc);
 		*stack_ptr = (void *) obj_desc;
 		break;
 
+	default:
+		break;
+	}
 
-	case INTERNAL_TYPE_BANK_FIELD:
+	return_ACPI_STATUS (status);
+}
 
-		obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_ANY);
-		if (!obj_desc) {
-			return_ACPI_STATUS (AE_NO_MEMORY);
-		}
 
-		/* TBD: WRONG! */
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ex_resolve_multiple
+ *
+ * PARAMETERS:  walk_state          - Current state (contains AML opcode)
+ *              Operand             - Starting point for resolution
+ *              return_type         - Where the object type is returned
+ *              return_desc         - Where the resolved object is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Return the base object and type.  Traverse a reference list if
+ *              necessary to get to the base object.
+ *
+ ******************************************************************************/
 
-		status = acpi_ex_get_buffer_field_value (stack_desc, obj_desc);
-		if (ACPI_FAILURE (status)) {
-			acpi_ut_remove_reference (obj_desc);
-			obj_desc = NULL;
+acpi_status
+acpi_ex_resolve_multiple (
+	struct acpi_walk_state          *walk_state,
+	union acpi_operand_object       *operand,
+	acpi_object_type                *return_type,
+	union acpi_operand_object       **return_desc)
+{
+	union acpi_operand_object       *obj_desc = (void *) operand;
+	struct acpi_namespace_node      *node;
+	acpi_object_type                type;
+
+
+	ACPI_FUNCTION_TRACE ("acpi_ex_resolve_multiple");
+
+
+	/*
+	 * 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
+	 * the list of possibly many nested references.
+	 */
+	while (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_REFERENCE) {
+		switch (obj_desc->reference.opcode) {
+		case AML_REF_OF_OP:
+
+			/* Dereference the reference pointer */
+
+			node = obj_desc->reference.object;
+
+			/* All "References" point to a NS node */
+
+			if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) {
+				return_ACPI_STATUS (AE_AML_INTERNAL);
+			}
+
+			/* Get the attached object */
+
+			obj_desc = acpi_ns_get_attached_object (node);
+			if (!obj_desc) {
+				/* No object, use the NS node type */
+
+				type = acpi_ns_get_type (node);
+				goto exit;
+			}
+
+			/* Check for circular references */
+
+			if (obj_desc == operand) {
+				return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE);
+			}
+			break;
+
+
+		case AML_INDEX_OP:
+
+			/* Get the type of this reference (index into another object) */
+
+			type = obj_desc->reference.target_type;
+			if (type != ACPI_TYPE_PACKAGE) {
+				goto exit;
+			}
+
+			/*
+			 * The main object is a package, we want to get the type
+			 * of the individual package element that is referenced by
+			 * the index.
+			 *
+			 * This could of course in turn be another reference object.
+			 */
+			obj_desc = *(obj_desc->reference.where);
+			break;
+
+
+		case AML_INT_NAMEPATH_OP:
+
+			/* Dereference the reference pointer */
+
+			node = obj_desc->reference.node;
+
+			/* All "References" point to a NS node */
+
+			if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) {
+				return_ACPI_STATUS (AE_AML_INTERNAL);
+			}
+
+			/* Get the attached object */
+
+			obj_desc = acpi_ns_get_attached_object (node);
+			if (!obj_desc) {
+				/* No object, use the NS node type */
+
+				type = acpi_ns_get_type (node);
+				goto exit;
+			}
+
+			/* Check for circular references */
+
+			if (obj_desc == operand) {
+				return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE);
+			}
+			break;
+
+
+		case AML_DEBUG_OP:
+
+			/* The Debug Object is of type "debug_object" */
+
+			type = ACPI_TYPE_DEBUG_OBJECT;
+			goto exit;
+
+
+		default:
+
+			ACPI_REPORT_ERROR (("acpi_ex_resolve_multiple: Unknown Reference subtype %X\n",
+				obj_desc->reference.opcode));
+			return_ACPI_STATUS (AE_AML_INTERNAL);
 		}
+	}
 
-		*stack_ptr = (void *) obj_desc;
-		break;
+	/*
+	 * Now we are guaranteed to have an object that has not been created
+	 * via the ref_of or Index operators.
+	 */
+	type = ACPI_GET_OBJECT_TYPE (obj_desc);
 
 
-	/* TBD: [Future] - may need to handle Index_field, and Def_field someday */
+exit:
+	/* Convert internal types to external types */
 
-	default:
+	switch (type) {
+	case ACPI_TYPE_LOCAL_REGION_FIELD:
+	case ACPI_TYPE_LOCAL_BANK_FIELD:
+	case ACPI_TYPE_LOCAL_INDEX_FIELD:
 
+		type = ACPI_TYPE_FIELD_UNIT;
 		break;
 
-	}   /* switch (Stack_desc->Common.Type) */
+	case ACPI_TYPE_LOCAL_SCOPE:
 
+		/* Per ACPI Specification, Scope is untyped */
 
-	return_ACPI_STATUS (status);
+		type = ACPI_TYPE_ANY;
+		break;
+
+	default:
+		/* No change to Type required */
+		break;
+	}
+
+	*return_type = type;
+	if (return_desc) {
+		*return_desc = obj_desc;
+	}
+	return_ACPI_STATUS (AE_OK);
 }
 
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exresop.c linux-2.4.22-pre2/drivers/acpi/executer/exresop.c
--- linux-2.4.21/drivers/acpi/executer/exresop.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exresop.c	2003-06-26 21:43:31.000000000 +0000
@@ -2,49 +2,63 @@
 /******************************************************************************
  *
  * Module Name: exresop - AML Interpreter operand/object resolution
- *              $Revision: 41 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "amlcode.h"
-#include "acparser.h"
-#include "acdispat.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "actables.h"
-#include "acevents.h"
+#include <acpi/acpi.h>
+#include <acpi/amlcode.h>
+#include <acpi/acparser.h>
+#include <acpi/acinterp.h>
 
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exresop")
+	 ACPI_MODULE_NAME    ("exresop")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_check_object_type
+ * FUNCTION:    acpi_ex_check_object_type
  *
- * PARAMETERS:  Type_needed         Object type needed
- *              This_type           Actual object type
+ * PARAMETERS:  type_needed         Object type needed
+ *              this_type           Actual object type
  *              Object              Object pointer
  *
  * RETURN:      Status
@@ -55,11 +69,11 @@
 
 acpi_status
 acpi_ex_check_object_type (
-	acpi_object_type        type_needed,
-	acpi_object_type        this_type,
-	void                    *object)
+	acpi_object_type                type_needed,
+	acpi_object_type                this_type,
+	void                            *object)
 {
-	PROC_NAME ("Ex_check_object_type");
+	ACPI_FUNCTION_NAME ("ex_check_object_type");
 
 
 	if (type_needed == ACPI_TYPE_ANY) {
@@ -68,8 +82,20 @@
 		return (AE_OK);
 	}
 
+	if (type_needed == ACPI_TYPE_LOCAL_REFERENCE) {
+		/*
+		 * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference
+		 * objects and thus allow them to be targets.  (As per the ACPI
+		 * specification, a store to a constant is a noop.)
+		 */
+		if ((this_type == ACPI_TYPE_INTEGER) &&
+			(((union acpi_operand_object *) object)->common.flags & AOPOBJ_AML_CONSTANT)) {
+			return (AE_OK);
+		}
+	}
+
 	if (type_needed != this_type) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 			"Needed [%s], found [%s] %p\n",
 			acpi_ut_get_type_name (type_needed),
 			acpi_ut_get_type_name (this_type), object));
@@ -83,40 +109,42 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_resolve_operands
+ * FUNCTION:    acpi_ex_resolve_operands
  *
- * PARAMETERS:  Opcode              Opcode being interpreted
- *              Stack_ptr           Top of operand stack
+ * PARAMETERS:  Opcode              - Opcode being interpreted
+ *              stack_ptr           - Pointer to the operand stack to be
+ *                                    resolved
+ *              walk_state          - Current state
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Convert stack entries to required types
- *
- *      Each nibble in Arg_types represents one required operand
- *      and indicates the required Type:
+ * DESCRIPTION: Convert multiple input operands to the types required by the
+ *              target operator.
  *
- *      The corresponding stack entry will be converted to the
- *      required type if possible, else return an exception
+ *      Each 5-bit group in arg_types represents one required
+ *      operand and indicates the required Type. The corresponding operand
+ *      will be converted to the required type if possible, otherwise we
+ *      abort with an exception.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ex_resolve_operands (
-	u16                     opcode,
-	acpi_operand_object     **stack_ptr,
-	acpi_walk_state         *walk_state)
+	u16                             opcode,
+	union acpi_operand_object       **stack_ptr,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_operand_object     *obj_desc;
-	acpi_status             status = AE_OK;
-	u8                      object_type;
-	void                    *temp_node;
-	u32                     arg_types;
-	const acpi_opcode_info  *op_info;
-	u32                     this_arg_type;
-	acpi_object_type        type_needed;
+	union acpi_operand_object       *obj_desc;
+	acpi_status                     status = AE_OK;
+	u8                              object_type;
+	void                            *temp_node;
+	u32                             arg_types;
+	const struct acpi_opcode_info   *op_info;
+	u32                             this_arg_type;
+	acpi_object_type                type_needed;
 
 
-	FUNCTION_TRACE_U32 ("Ex_resolve_operands", opcode);
+	ACPI_FUNCTION_TRACE_U32 ("ex_resolve_operands", opcode);
 
 
 	op_info = acpi_ps_get_opcode_info (opcode);
@@ -124,7 +152,6 @@
 		return_ACPI_STATUS (AE_AML_BAD_OPCODE);
 	}
 
-
 	arg_types = op_info->runtime_args;
 	if (arg_types == ARGI_INVALID_OPCODE) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - %X is not a valid AML opcode\n",
@@ -133,12 +160,11 @@
 		return_ACPI_STATUS (AE_AML_INTERNAL);
 	}
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode %X Operand_types=%X \n",
-		opcode, arg_types));
-
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode %X [%s] operand_types=%X \n",
+		opcode, op_info->name, arg_types));
 
 	/*
-	 * Normal exit is with (Arg_types == 0) at end of argument list.
+	 * Normal exit is with (arg_types == 0) at end of argument list.
 	 * Function will return an exception from within the loop upon
 	 * finding an entry which is not (or cannot be converted
 	 * to) the required type; if stack underflows; or upon
@@ -158,27 +184,31 @@
 
 		/* Decode the descriptor type */
 
-		if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) {
+		switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) {
+		case ACPI_DESC_TYPE_NAMED:
+
 			/* Node */
 
-			object_type = ((acpi_namespace_node *) obj_desc)->type;
-		}
+			object_type = ((struct acpi_namespace_node *) obj_desc)->type;
+			break;
+
+
+		case ACPI_DESC_TYPE_OPERAND:
 
-		else if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_INTERNAL)) {
 			/* ACPI internal object */
 
-			object_type = obj_desc->common.type;
+			object_type = ACPI_GET_OBJECT_TYPE (obj_desc);
 
 			/* Check for bad acpi_object_type */
 
-			if (!acpi_ex_validate_object_type (object_type)) {
+			if (!acpi_ut_valid_object_type (object_type)) {
 				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad operand object type [%X]\n",
 					object_type));
 
 				return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 			}
 
-			if (object_type == (u8) INTERNAL_TYPE_REFERENCE) {
+			if (object_type == (u8) ACPI_TYPE_LOCAL_REFERENCE) {
 				/*
 				 * Decode the Reference
 				 */
@@ -187,39 +217,36 @@
 					return_ACPI_STATUS (AE_AML_BAD_OPCODE);
 				}
 
-
 				switch (obj_desc->reference.opcode) {
-				case AML_ZERO_OP:
-				case AML_ONE_OP:
-				case AML_ONES_OP:
 				case AML_DEBUG_OP:
 				case AML_NAME_OP:
 				case AML_INDEX_OP:
+				case AML_REF_OF_OP:
 				case AML_ARG_OP:
 				case AML_LOCAL_OP:
-				case AML_REVISION_OP:
 
-					DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+					ACPI_DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
 						"Reference Opcode: %s\n", op_info->name)));
 					break;
 
 				default:
-					ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-						"Reference Opcode: Unknown [%02x]\n",
+					ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+						"Unknown Reference Opcode %X\n",
 						obj_desc->reference.opcode));
 
 					return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
-					break;
 				}
 			}
-		}
+			break;
+
+
+		default:
 
-		else {
 			/* Invalid descriptor */
 
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 				"Bad descriptor type %X in Obj %p\n",
-				obj_desc->common.data_type, obj_desc));
+				ACPI_GET_DESCRIPTOR_TYPE (obj_desc), obj_desc));
 
 			return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 		}
@@ -231,34 +258,45 @@
 		this_arg_type = GET_CURRENT_ARG_TYPE (arg_types);
 		INCREMENT_ARG_LIST (arg_types);
 
-
 		/*
 		 * Handle cases where the object does not need to be
 		 * resolved to a value
 		 */
 		switch (this_arg_type) {
+		case ARGI_REF_OR_STRING:        /* Can be a String or Reference */
 
-		case ARGI_REFERENCE:            /* References */
+			if ((ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_OPERAND) &&
+				(ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_STRING)) {
+				/*
+				 * String found - the string references a named object and must be
+				 * resolved to a node
+				 */
+				goto next_operand;
+			}
+
+			/* Else not a string - fall through to the normal Reference case below */
+			/*lint -fallthrough */
+
+		case ARGI_REFERENCE:            /* References: */
 		case ARGI_INTEGER_REF:
 		case ARGI_OBJECT_REF:
 		case ARGI_DEVICE_REF:
-		case ARGI_TARGETREF:            /* TBD: must implement implicit conversion rules before store */
+		case ARGI_TARGETREF:            /* Allows implicit conversion rules before store */
 		case ARGI_FIXED_TARGET:         /* No implicit conversion before store to target */
-		case ARGI_SIMPLE_TARGET:        /* Name, Local, or Arg - no implicit conversion */
+		case ARGI_SIMPLE_TARGET:        /* Name, Local, or Arg - no implicit conversion  */
 
-			/* Need an operand of type INTERNAL_TYPE_REFERENCE */
+			/* Need an operand of type ACPI_TYPE_LOCAL_REFERENCE */
 
-			if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED))            /* direct name ptr OK as-is */ {
+			if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) /* Node (name) ptr OK as-is */ {
 				goto next_operand;
 			}
 
-			status = acpi_ex_check_object_type (INTERNAL_TYPE_REFERENCE,
+			status = acpi_ex_check_object_type (ACPI_TYPE_LOCAL_REFERENCE,
 					  object_type, obj_desc);
 			if (ACPI_FAILURE (status)) {
 				return_ACPI_STATUS (status);
 			}
 
-
 			if (AML_NAME_OP == obj_desc->reference.opcode) {
 				/*
 				 * Convert an indirect name ptr to direct name ptr and put
@@ -268,25 +306,27 @@
 				acpi_ut_remove_reference (obj_desc);
 				(*stack_ptr) = temp_node;
 			}
-
 			goto next_operand;
-			break;
 
 
 		case ARGI_ANYTYPE:
 
 			/*
-			 * We don't want to resolve Index_op reference objects during
-			 * a store because this would be an implicit De_ref_of operation.
+			 * We don't want to resolve index_op reference objects during
+			 * a store because this would be an implicit de_ref_of operation.
 			 * Instead, we just want to store the reference object.
 			 * -- All others must be resolved below.
 			 */
 			if ((opcode == AML_STORE_OP) &&
-				((*stack_ptr)->common.type == INTERNAL_TYPE_REFERENCE) &&
+				(ACPI_GET_OBJECT_TYPE (*stack_ptr) == ACPI_TYPE_LOCAL_REFERENCE) &&
 				((*stack_ptr)->reference.opcode == AML_INDEX_OP)) {
 				goto next_operand;
 			}
 			break;
+
+		default:
+			/* All cases covered above */
+			break;
 		}
 
 
@@ -298,6 +338,9 @@
 			return_ACPI_STATUS (status);
 		}
 
+		/* Get the resolved object */
+
+		obj_desc = *stack_ptr;
 
 		/*
 		 * Check the resulting object (value) type
@@ -321,20 +364,6 @@
 			type_needed = ACPI_TYPE_EVENT;
 			break;
 
-		case ARGI_REGION:
-
-			/* Need an operand of type ACPI_TYPE_REGION */
-
-			type_needed = ACPI_TYPE_REGION;
-			break;
-
-		case ARGI_IF:   /* If */
-
-			/* Need an operand of type INTERNAL_TYPE_IF */
-
-			type_needed = INTERNAL_TYPE_IF;
-			break;
-
 		case ARGI_PACKAGE:   /* Package */
 
 			/* Need an operand of type ACPI_TYPE_PACKAGE */
@@ -358,22 +387,21 @@
 			/*
 			 * Need an operand of type ACPI_TYPE_INTEGER,
 			 * But we can implicitly convert from a STRING or BUFFER
+			 * Aka - "Implicit Source Operand Conversion"
 			 */
-			status = acpi_ex_convert_to_integer (*stack_ptr, stack_ptr, walk_state);
+			status = acpi_ex_convert_to_integer (obj_desc, stack_ptr, walk_state);
 			if (ACPI_FAILURE (status)) {
 				if (status == AE_TYPE) {
-					ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+					ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 						"Needed [Integer/String/Buffer], found [%s] %p\n",
-						acpi_ut_get_type_name ((*stack_ptr)->common.type), *stack_ptr));
+						acpi_ut_get_object_type_name (obj_desc), obj_desc));
 
 					return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 				}
 
 				return_ACPI_STATUS (status);
 			}
-
 			goto next_operand;
-			break;
 
 
 		case ARGI_BUFFER:
@@ -381,22 +409,21 @@
 			/*
 			 * Need an operand of type ACPI_TYPE_BUFFER,
 			 * But we can implicitly convert from a STRING or INTEGER
+			 * Aka - "Implicit Source Operand Conversion"
 			 */
-			status = acpi_ex_convert_to_buffer (*stack_ptr, stack_ptr, walk_state);
+			status = acpi_ex_convert_to_buffer (obj_desc, stack_ptr, walk_state);
 			if (ACPI_FAILURE (status)) {
 				if (status == AE_TYPE) {
-					ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+					ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 						"Needed [Integer/String/Buffer], found [%s] %p\n",
-						acpi_ut_get_type_name ((*stack_ptr)->common.type), *stack_ptr));
+						acpi_ut_get_object_type_name (obj_desc), obj_desc));
 
 					return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 				}
 
 				return_ACPI_STATUS (status);
 			}
-
 			goto next_operand;
-			break;
 
 
 		case ARGI_STRING:
@@ -404,95 +431,146 @@
 			/*
 			 * Need an operand of type ACPI_TYPE_STRING,
 			 * But we can implicitly convert from a BUFFER or INTEGER
+			 * Aka - "Implicit Source Operand Conversion"
 			 */
-			status = acpi_ex_convert_to_string (*stack_ptr, stack_ptr, 16, ACPI_UINT32_MAX, walk_state);
+			status = acpi_ex_convert_to_string (obj_desc, stack_ptr, 16, ACPI_UINT32_MAX, walk_state);
 			if (ACPI_FAILURE (status)) {
 				if (status == AE_TYPE) {
-					ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+					ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 						"Needed [Integer/String/Buffer], found [%s] %p\n",
-						acpi_ut_get_type_name ((*stack_ptr)->common.type), *stack_ptr));
+						acpi_ut_get_object_type_name (obj_desc), obj_desc));
 
 					return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 				}
 
 				return_ACPI_STATUS (status);
 			}
-
 			goto next_operand;
-			break;
 
 
 		case ARGI_COMPUTEDATA:
 
 			/* Need an operand of type INTEGER, STRING or BUFFER */
 
-			if ((ACPI_TYPE_INTEGER != (*stack_ptr)->common.type) &&
-				(ACPI_TYPE_STRING != (*stack_ptr)->common.type) &&
-				(ACPI_TYPE_BUFFER != (*stack_ptr)->common.type)) {
-				ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+			switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
+			case ACPI_TYPE_INTEGER:
+			case ACPI_TYPE_STRING:
+			case ACPI_TYPE_BUFFER:
+
+				/* Valid operand */
+			   break;
+
+			default:
+				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 					"Needed [Integer/String/Buffer], found [%s] %p\n",
-					acpi_ut_get_type_name ((*stack_ptr)->common.type), *stack_ptr));
+					acpi_ut_get_object_type_name (obj_desc), obj_desc));
 
 				return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 			}
 			goto next_operand;
-			break;
 
 
-		case ARGI_DATAOBJECT:
-			/*
-			 * ARGI_DATAOBJECT is only used by the Size_of operator.
-			 *
-			 * The ACPI specification allows Size_of to return the size of
-			 *  a Buffer, String or Package.  However, the MS ACPI.SYS AML
-			 *  Interpreter also allows an Node reference to return without
-			 *  error with a size of 4.
-			 */
+		case ARGI_BUFFER_OR_STRING:
+
+			/* Need an operand of type STRING or BUFFER */
+
+			switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
+			case ACPI_TYPE_STRING:
+			case ACPI_TYPE_BUFFER:
 
-			/* Need a buffer, string, package or Node reference */
+				/* Valid operand */
+			   break;
 
-			if (((*stack_ptr)->common.type != ACPI_TYPE_BUFFER) &&
-				((*stack_ptr)->common.type != ACPI_TYPE_STRING) &&
-				((*stack_ptr)->common.type != ACPI_TYPE_PACKAGE) &&
-				((*stack_ptr)->common.type != INTERNAL_TYPE_REFERENCE)) {
-				ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-					"Needed [Buf/Str/Pkg/Ref], found [%s] %p\n",
-					acpi_ut_get_type_name ((*stack_ptr)->common.type), *stack_ptr));
+			case ACPI_TYPE_INTEGER:
+
+				/* Highest priority conversion is to type Buffer */
+
+				status = acpi_ex_convert_to_buffer (obj_desc, stack_ptr, walk_state);
+				if (ACPI_FAILURE (status)) {
+					return_ACPI_STATUS (status);
+				}
+				break;
+
+			default:
+				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+					"Needed [Integer/String/Buffer], found [%s] %p\n",
+					acpi_ut_get_object_type_name (obj_desc), obj_desc));
 
 				return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 			}
+			goto next_operand;
+
 
+		case ARGI_DATAOBJECT:
 			/*
-			 * If this is a reference, only allow a reference to an Node.
+			 * ARGI_DATAOBJECT is only used by the size_of operator.
+			 * Need a buffer, string, package, or ref_of reference.
+			 *
+			 * The only reference allowed here is a direct reference to
+			 * a namespace node.
 			 */
-			if ((*stack_ptr)->common.type == INTERNAL_TYPE_REFERENCE) {
-				if (!(*stack_ptr)->reference.node) {
-					ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-						"Needed [Node Reference], found [%p]\n",
-						*stack_ptr));
+			switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
+			case ACPI_TYPE_PACKAGE:
+			case ACPI_TYPE_STRING:
+			case ACPI_TYPE_BUFFER:
+			case ACPI_TYPE_LOCAL_REFERENCE:
+
+				/* Valid operand */
+				break;
+
+			default:
+				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+					"Needed [Buffer/String/Package/Reference], found [%s] %p\n",
+					acpi_ut_get_object_type_name (obj_desc), obj_desc));
 
-					return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
-				}
+				return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 			}
 			goto next_operand;
-			break;
 
 
 		case ARGI_COMPLEXOBJ:
 
 			/* Need a buffer or package or (ACPI 2.0) String */
 
-			if (((*stack_ptr)->common.type != ACPI_TYPE_BUFFER) &&
-				((*stack_ptr)->common.type != ACPI_TYPE_STRING) &&
-				((*stack_ptr)->common.type != ACPI_TYPE_PACKAGE)) {
-				ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-					"Needed [Buf/Pkg], found [%s] %p\n",
-					acpi_ut_get_type_name ((*stack_ptr)->common.type), *stack_ptr));
+			switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
+			case ACPI_TYPE_PACKAGE:
+			case ACPI_TYPE_STRING:
+			case ACPI_TYPE_BUFFER:
+
+				/* Valid operand */
+				break;
+
+			default:
+				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+					"Needed [Buffer/String/Package], found [%s] %p\n",
+					acpi_ut_get_object_type_name (obj_desc), obj_desc));
+
+				return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+			}
+			goto next_operand;
+
+
+		case ARGI_REGION_OR_FIELD:
+
+			/* Need an operand of type ACPI_TYPE_REGION or a FIELD in a region */
+
+			switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
+			case ACPI_TYPE_REGION:
+			case ACPI_TYPE_LOCAL_REGION_FIELD:
+			case ACPI_TYPE_LOCAL_BANK_FIELD:
+			case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+				/* Valid operand */
+				break;
+
+			default:
+				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+					"Needed [Region/region_field], found [%s] %p\n",
+					acpi_ut_get_object_type_name (obj_desc), obj_desc));
 
 				return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 			}
 			goto next_operand;
-			break;
 
 
 		default:
@@ -500,27 +578,25 @@
 			/* Unknown type */
 
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-				"Internal - Unknown ARGI type %X\n",
+				"Internal - Unknown ARGI (required operand) type %X\n",
 				this_arg_type));
 
 			return_ACPI_STATUS (AE_BAD_PARAMETER);
 		}
 
-
 		/*
 		 * Make sure that the original object was resolved to the
 		 * required object type (Simple cases only).
 		 */
 		status = acpi_ex_check_object_type (type_needed,
-				  (*stack_ptr)->common.type, *stack_ptr);
+				  ACPI_GET_OBJECT_TYPE (*stack_ptr), *stack_ptr);
 		if (ACPI_FAILURE (status)) {
 			return_ACPI_STATUS (status);
 		}
 
-
 next_operand:
 		/*
-		 * If more operands needed, decrement Stack_ptr to point
+		 * If more operands needed, decrement stack_ptr to point
 		 * to next operand on stack
 		 */
 		if (GET_CURRENT_ARG_TYPE (arg_types)) {
@@ -529,7 +605,6 @@
 
 	}   /* while (*Types) */
 
-
 	return_ACPI_STATUS (status);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exstore.c linux-2.4.22-pre2/drivers/acpi/executer/exstore.c
--- linux-2.4.21/drivers/acpi/executer/exstore.c	2002-11-28 23:53:12.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exstore.c	2003-06-26 21:43:19.000000000 +0000
@@ -2,113 +2,142 @@
 /******************************************************************************
  *
  * Module Name: exstore - AML Interpreter object store support
- *              $Revision: 150 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "acdispat.h"
-#include "acinterp.h"
-#include "amlcode.h"
-#include "acnamesp.h"
-#include "actables.h"
+#include <acpi/acpi.h>
+#include <acpi/acdispat.h>
+#include <acpi/acinterp.h>
+#include <acpi/amlcode.h>
+#include <acpi/acnamesp.h>
 
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exstore")
+	 ACPI_MODULE_NAME    ("exstore")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_store
+ * FUNCTION:    acpi_ex_store
  *
- * PARAMETERS:  *Source_desc        - Value to be stored
- *              *Dest_desc          - Where to store it.  Must be an NS node
- *                                    or an acpi_operand_object of type
+ * PARAMETERS:  *source_desc        - Value to be stored
+ *              *dest_desc          - Where to store it.  Must be an NS node
+ *                                    or an union acpi_operand_object of type
  *                                    Reference;
+ *              walk_state          - Current walk state
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Store the value described by Source_desc into the location
- *              described by Dest_desc. Called by various interpreter
+ * DESCRIPTION: Store the value described by source_desc into the location
+ *              described by dest_desc. Called by various interpreter
  *              functions to store the result of an operation into
- *              the destination operand.
+ *              the destination operand -- not just simply the actual "Store"
+ *              ASL operator.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ex_store (
-	acpi_operand_object     *source_desc,
-	acpi_operand_object     *dest_desc,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       *source_desc,
+	union acpi_operand_object       *dest_desc,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status = AE_OK;
-	acpi_operand_object     *ref_desc = dest_desc;
+	acpi_status                     status = AE_OK;
+	union acpi_operand_object       *ref_desc = dest_desc;
 
 
-	FUNCTION_TRACE_PTR ("Ex_store", dest_desc);
+	ACPI_FUNCTION_TRACE_PTR ("ex_store", dest_desc);
 
 
 	/* Validate parameters */
 
 	if (!source_desc || !dest_desc) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null pointer\n"));
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null parameter\n"));
 		return_ACPI_STATUS (AE_AML_NO_OPERAND);
 	}
 
-	/* Dest_desc can be either a namespace node or an ACPI object */
+	/* dest_desc can be either a namespace node or an ACPI object */
 
-	if (VALID_DESCRIPTOR_TYPE (dest_desc, ACPI_DESC_TYPE_NAMED)) {
+	if (ACPI_GET_DESCRIPTOR_TYPE (dest_desc) == ACPI_DESC_TYPE_NAMED) {
 		/*
 		 * Dest is a namespace node,
-		 * Storing an object into a Name "container"
+		 * Storing an object into a Named node.
 		 */
 		status = acpi_ex_store_object_to_node (source_desc,
-				 (acpi_namespace_node *) dest_desc, walk_state);
-
-		/* All done, that's it */
+				 (struct acpi_namespace_node *) dest_desc, walk_state);
 
 		return_ACPI_STATUS (status);
 	}
 
+	/* Destination object must be a Reference or a Constant object */
+
+	switch (ACPI_GET_OBJECT_TYPE (dest_desc)) {
+	case ACPI_TYPE_LOCAL_REFERENCE:
+		break;
+
+	case ACPI_TYPE_INTEGER:
+
+		/* Allow stores to Constants -- a Noop as per ACPI spec */
+
+		if (dest_desc->common.flags & AOPOBJ_AML_CONSTANT) {
+			return_ACPI_STATUS (AE_OK);
+		}
+
+		/*lint -fallthrough */
 
-	/* Destination object must be an object of type Reference */
+	default:
 
-	if (dest_desc->common.type != INTERNAL_TYPE_REFERENCE) {
 		/* Destination is not an Reference */
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-			"Destination is not a Reference_obj [%p]\n", dest_desc));
+			"Destination is not a Reference or Constant object [%p]\n", dest_desc));
 
-		DUMP_STACK_ENTRY (source_desc);
-		DUMP_STACK_ENTRY (dest_desc);
-		DUMP_OPERANDS (&dest_desc, IMODE_EXECUTE, "Ex_store",
-				  2, "Target is not a Reference_obj");
+		ACPI_DUMP_STACK_ENTRY (source_desc);
+		ACPI_DUMP_STACK_ENTRY (dest_desc);
+		ACPI_DUMP_OPERANDS (&dest_desc, ACPI_IMODE_EXECUTE, "ex_store",
+				  2, "Target is not a Reference or Constant object");
 
 		return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 	}
 
-
 	/*
 	 * Examine the Reference opcode.  These cases are handled:
 	 *
@@ -116,11 +145,10 @@
 	 * 2) Store to an indexed area of a Buffer or Package
 	 * 3) Store to a Method Local or Arg
 	 * 4) Store to the debug object
-	 * 5) Store to a constant -- a noop
 	 */
 	switch (ref_desc->reference.opcode) {
-
 	case AML_NAME_OP:
+	case AML_REF_OF_OP:
 
 		/* Storing an object into a Name "container" */
 
@@ -153,23 +181,24 @@
 		 * 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_INFO, "**** Write to Debug Object: ****:\n\n"));
+		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Write to Debug Object: ****:\n\n"));
 
 		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %s: ",
-				  acpi_ut_get_type_name (source_desc->common.type)));
+				  acpi_ut_get_object_type_name (source_desc)));
 
-		switch (source_desc->common.type) {
+		switch (ACPI_GET_OBJECT_TYPE (source_desc)) {
 		case ACPI_TYPE_INTEGER:
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%X (%d)\n",
-				(u32) source_desc->integer.value, (u32) source_desc->integer.value));
+			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%8.8X%8.8X\n",
+					ACPI_HIDWORD (source_desc->integer.value),
+					ACPI_LODWORD (source_desc->integer.value)));
 			break;
 
 
 		case ACPI_TYPE_BUFFER:
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length 0x%X\n",
-				(u32) source_desc->buffer.length));
+			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length %.2X\n",
+					(u32) source_desc->buffer.length));
 			break;
 
 
@@ -181,47 +210,31 @@
 
 		case ACPI_TYPE_PACKAGE:
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Elements - %p\n",
-				source_desc->package.elements));
+			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Elements Ptr - %p\n",
+					source_desc->package.elements));
 			break;
 
 
 		default:
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "@0x%p\n", source_desc));
+			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Type %s %p\n",
+					acpi_ut_get_object_type_name (source_desc), source_desc));
 			break;
 		}
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "\n"));
-		break;
-
-
-	case AML_ZERO_OP:
-	case AML_ONE_OP:
-	case AML_ONES_OP:
-	case AML_REVISION_OP:
-
-		/*
-		 * Storing to a constant is a no-op -- see ACPI Specification
-		 * Delete the reference descriptor, however
-		 */
+		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));
 		break;
 
 
 	default:
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - Unknown Reference subtype %02x\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference opcode %X\n",
 			ref_desc->reference.opcode));
-
-		/* TBD: [Restructure] use object dump routine !! */
-
-		DUMP_BUFFER (ref_desc, sizeof (acpi_operand_object));
+		ACPI_DUMP_ENTRY (ref_desc, ACPI_LV_ERROR);
 
 		status = AE_AML_INTERNAL;
 		break;
-
-	}   /* switch (Ref_desc->Reference.Opcode) */
-
+	}
 
 	return_ACPI_STATUS (status);
 }
@@ -229,38 +242,38 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_store_object_to_index
+ * FUNCTION:    acpi_ex_store_object_to_index
  *
- * PARAMETERS:  *Source_desc          - Value to be stored
- *              *Node               - Named object to receive the value
+ * PARAMETERS:  *source_desc            - Value to be stored
+ *              *dest_desc              - Named object to receive the value
+ *              walk_state              - Current walk state
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Store the object to the named object.
+ * DESCRIPTION: Store the object to indexed Buffer or Package element
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ex_store_object_to_index (
-	acpi_operand_object     *source_desc,
-	acpi_operand_object     *dest_desc,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       *source_desc,
+	union acpi_operand_object       *index_desc,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status = AE_OK;
-	acpi_operand_object     *obj_desc;
-	u32                     length;
-	u32                     i;
-	u8                      value = 0;
+	acpi_status                     status = AE_OK;
+	union acpi_operand_object       *obj_desc;
+	union acpi_operand_object       *new_desc;
+	u8                              value = 0;
 
 
-	FUNCTION_TRACE ("Ex_store_object_to_index");
+	ACPI_FUNCTION_TRACE ("ex_store_object_to_index");
 
 
 	/*
 	 * Destination must be a reference pointer, and
 	 * must point to either a buffer or a package
 	 */
-	switch (dest_desc->reference.target_type) {
+	switch (index_desc->reference.target_type) {
 	case ACPI_TYPE_PACKAGE:
 		/*
 		 * Storing to a package element is not simple.  The source must be
@@ -268,74 +281,34 @@
 		 * source is copied into the destination - we can't just point to the
 		 * source object.
 		 */
-		if (dest_desc->reference.target_type == ACPI_TYPE_PACKAGE) {
-			/*
-			 * The object at *(Dest_desc->Reference.Where) is the
-			 * element within the package that is to be modified.
-			 */
-			obj_desc = *(dest_desc->reference.where);
-			if (obj_desc) {
-				/*
-				 * If the Destination element is a package, we will delete
-				 *  that object and construct a new one.
-				 *
-				 * TBD: [Investigate] Should both the src and dest be required
-				 *      to be packages?
-				 *       && (Source_desc->Common.Type == ACPI_TYPE_PACKAGE)
-				 */
-				if (obj_desc->common.type == ACPI_TYPE_PACKAGE) {
-					/* Take away the reference for being part of a package */
-
-					acpi_ut_remove_reference (obj_desc);
-					obj_desc = NULL;
-				}
-			}
+		/*
+		 * The object at *(index_desc->Reference.Where) is the
+		 * element within the package that is to be modified.
+		 */
+		obj_desc = *(index_desc->reference.where);
+
+		/* Do the conversion/store */
 
-			if (!obj_desc) {
-				/*
-				 * If the Obj_desc is NULL, it means that an uninitialized package
-				 * element has been used as a destination (this is OK), therefore,
-				 * we must create the destination element to match the type of the
-				 * source element NOTE: Source_desccan be of any type.
-				 */
-				obj_desc = acpi_ut_create_internal_object (source_desc->common.type);
-				if (!obj_desc) {
-					return_ACPI_STATUS (AE_NO_MEMORY);
-				}
-
-				/*
-				 * If the source is a package, copy the source to the new dest
-				 */
-				if (ACPI_TYPE_PACKAGE == obj_desc->common.type) {
-					status = acpi_ut_copy_ipackage_to_ipackage (source_desc, obj_desc, walk_state);
-					if (ACPI_FAILURE (status)) {
-						acpi_ut_remove_reference (obj_desc);
-						return_ACPI_STATUS (status);
-					}
-				}
+		status = acpi_ex_store_object_to_object (source_desc, obj_desc, &new_desc,
+				  walk_state);
+		if (ACPI_FAILURE (status)) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"Could not store object to indexed package element\n"));
+			return_ACPI_STATUS (status);
+		}
 
-				/* Install the new descriptor into the package */
+		/*
+		 * If a new object was created, we must install it as the new
+		 * package element
+		 */
+		if (new_desc != obj_desc) {
+			acpi_ut_remove_reference (obj_desc);
+			*(index_desc->reference.where) = new_desc;
 
-				*(dest_desc->reference.where) = obj_desc;
-			}
+			/* If same as the original source, add a reference */
 
-			if (ACPI_TYPE_PACKAGE != obj_desc->common.type) {
-				/*
-				 * The destination element is not a package, so we need to
-				 * convert the contents of the source (Source_desc) and copy into
-				 * the destination (Obj_desc)
-				 */
-				status = acpi_ex_store_object_to_object (source_desc, obj_desc,
-						  walk_state);
-				if (ACPI_FAILURE (status)) {
-					/*
-					 * An error occurrered when copying the internal object
-					 * so delete the reference.
-					 */
-					ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-						"Unable to copy the internal object\n"));
-					return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
-				}
+			if (new_desc == source_desc) {
+				acpi_ut_add_reference (new_desc);
 			}
 		}
 		break;
@@ -343,21 +316,20 @@
 
 	case ACPI_TYPE_BUFFER_FIELD:
 
-
-		/* TBD: can probably call the generic Buffer/Field routines */
-
 		/*
-		 * Storing into a buffer at a location defined by an Index.
+		 * Store into a Buffer (not actually a real buffer_field) at a
+		 * location defined by an Index.
 		 *
-		 * Each 8-bit element of the source object is written to the
-		 * 8-bit Buffer Field of the Index destination object.
+		 * The first 8-bit element of the source object is written to the
+		 * 8-bit Buffer location defined by the Index destination object,
+		 * according to the ACPI 2.0 specification.
 		 */
 
 		/*
-		 * Set the Obj_desc to the destination object and type check.
+		 * Make sure the target is a Buffer
 		 */
-		obj_desc = dest_desc->reference.object;
-		if (obj_desc->common.type != ACPI_TYPE_BUFFER) {
+		obj_desc = index_desc->reference.object;
+		if (ACPI_GET_OBJECT_TYPE (obj_desc) != ACPI_TYPE_BUFFER) {
 			return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 		}
 
@@ -365,84 +337,65 @@
 		 * The assignment of the individual elements will be slightly
 		 * different for each source type.
 		 */
-		switch (source_desc->common.type) {
+		switch (ACPI_GET_OBJECT_TYPE (source_desc)) {
 		case ACPI_TYPE_INTEGER:
-			/*
-			 * Type is Integer, assign bytewise
-			 * This loop to assign each of the elements is somewhat
-			 * backward because of the Big Endian-ness of IA-64
-			 */
-			length = sizeof (acpi_integer);
-			for (i = length; i != 0; i--) {
-				value = (u8)(source_desc->integer.value >> (MUL_8 (i - 1)));
-				obj_desc->buffer.pointer[dest_desc->reference.offset] = value;
-			}
-			break;
 
+			/* Use the least-significant byte of the integer */
 
-		case ACPI_TYPE_BUFFER:
-			/*
-			 * Type is Buffer, the Length is in the structure.
-			 * Just loop through the elements and assign each one in turn.
-			 */
-			length = source_desc->buffer.length;
-			for (i = 0; i < length; i++) {
-				value = source_desc->buffer.pointer[i];
-				obj_desc->buffer.pointer[dest_desc->reference.offset] = value;
-			}
+			value = (u8) (source_desc->integer.value);
 			break;
 
+		case ACPI_TYPE_BUFFER:
 
-		case ACPI_TYPE_STRING:
-			/*
-			 * Type is String, the Length is in the structure.
-			 * Just loop through the elements and assign each one in turn.
-			 */
-			length = source_desc->string.length;
-			for (i = 0; i < length; i++) {
-				value = source_desc->string.pointer[i];
-				obj_desc->buffer.pointer[dest_desc->reference.offset] = value;
-			}
+			value = source_desc->buffer.pointer[0];
 			break;
 
+		case ACPI_TYPE_STRING:
+
+			value = (u8) source_desc->string.pointer[0];
+			break;
 
 		default:
 
-			/* Other types are invalid */
+			/* All other types are invalid */
 
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-				"Source must be Number/Buffer/String type, not %X\n",
-				source_desc->common.type));
-			status = AE_AML_OPERAND_TYPE;
-			break;
+				"Source must be Integer/Buffer/String type, not %s\n",
+				acpi_ut_get_object_type_name (source_desc)));
+			return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 		}
+
+		/* Store the source value into the target buffer byte */
+
+		obj_desc->buffer.pointer[index_desc->reference.offset] = value;
 		break;
 
 
 	default:
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Target is not a Package or Buffer_field\n"));
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"Target is not a Package or buffer_field\n"));
 		status = AE_AML_OPERAND_TYPE;
 		break;
 	}
 
-
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_store_object_to_node
+ * FUNCTION:    acpi_ex_store_object_to_node
  *
- * PARAMETERS:  *Source_desc           - Value to be stored
- *              *Node                  - Named object to receive the value
+ * PARAMETERS:  source_desc             - Value to be stored
+ *              Node                    - Named object to receive the value
+ *              walk_state              - Current walk state
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Store the object to the named object.
  *
  *              The Assignment of an object to a named object is handled here
- *              The val passed in will replace the current value (if any)
+ *              The value passed in will replace the current value (if any)
  *              with the input value.
  *
  *              When storing into an object the data is converted to the
@@ -450,41 +403,34 @@
  *              that the target object type (for an initialized target) will
  *              not be changed by a store operation.
  *
- *              NOTE: the global lock is acquired early.  This will result
- *              in the global lock being held a bit longer.  Also, if the
- *              function fails during set up we may get the lock when we
- *              don't really need it.  I don't think we care.
+ *              Assumes parameters are already validated.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ex_store_object_to_node (
-	acpi_operand_object     *source_desc,
-	acpi_namespace_node     *node,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       *source_desc,
+	struct acpi_namespace_node      *node,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status = AE_OK;
-	acpi_operand_object     *target_desc;
-	acpi_object_type8       target_type = ACPI_TYPE_ANY;
+	acpi_status                     status = AE_OK;
+	union acpi_operand_object       *target_desc;
+	union acpi_operand_object       *new_desc;
+	acpi_object_type                target_type;
 
 
-	FUNCTION_TRACE ("Ex_store_object_to_node");
+	ACPI_FUNCTION_TRACE_PTR ("ex_store_object_to_node", source_desc);
 
 
 	/*
-	 * Assuming the parameters were already validated
-	 */
-
-	/*
 	 * Get current type of the node, and object attached to Node
 	 */
 	target_type = acpi_ns_get_type (node);
 	target_desc = acpi_ns_get_attached_object (node);
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Storing %p(%s) into node %p(%s)\n",
-		node, acpi_ut_get_type_name (source_desc->common.type),
-		source_desc, acpi_ut_get_type_name (target_type)));
-
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n",
+		source_desc, acpi_ut_get_object_type_name (source_desc),
+			  node, acpi_ut_get_type_name (target_type)));
 
 	/*
 	 * Resolve the source object to an actual value
@@ -495,20 +441,19 @@
 		return_ACPI_STATUS (status);
 	}
 
-
 	/*
 	 * Do the actual store operation
 	 */
 	switch (target_type) {
 	case ACPI_TYPE_BUFFER_FIELD:
-	case INTERNAL_TYPE_REGION_FIELD:
-	case INTERNAL_TYPE_BANK_FIELD:
-	case INTERNAL_TYPE_INDEX_FIELD:
+	case ACPI_TYPE_LOCAL_REGION_FIELD:
+	case ACPI_TYPE_LOCAL_BANK_FIELD:
+	case ACPI_TYPE_LOCAL_INDEX_FIELD:
 
 		/*
 		 * For fields, copy the source data to the target field.
 		 */
-		status = acpi_ex_write_data_to_field (source_desc, target_desc);
+		status = acpi_ex_write_data_to_field (source_desc, target_desc, &walk_state->result_obj);
 		break;
 
 
@@ -522,122 +467,44 @@
 		 *
 		 * Copy and/or convert the source object to a new target object
 		 */
-		status = acpi_ex_store_object (source_desc, target_type, &target_desc, walk_state);
+		status = acpi_ex_store_object_to_object (source_desc, target_desc, &new_desc, walk_state);
 		if (ACPI_FAILURE (status)) {
 			return_ACPI_STATUS (status);
 		}
 
-		/*
-		 * Store the new Target_desc as the new value of the Name, and set
-		 * the Name's type to that of the value being stored in it.
-		 * Source_desc reference count is incremented by Attach_object.
-		 */
-		status = acpi_ns_attach_object (node, target_desc, target_type);
+		if (new_desc != target_desc) {
+			/*
+			 * Store the new new_desc as the new value of the Name, and set
+			 * the Name's type to that of the value being stored in it.
+			 * source_desc reference count is incremented by attach_object.
+			 *
+			 * Note: This may change the type of the node if an explicit store
+			 * has been performed such that the node/object type has been
+			 * changed.
+			 */
+			status = acpi_ns_attach_object (node, new_desc, new_desc->common.type);
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-			"Store %s into %s via Convert/Attach\n",
-			acpi_ut_get_type_name (target_desc->common.type),
-			acpi_ut_get_type_name (target_type)));
+			ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+				"Store %s into %s via Convert/Attach\n",
+				acpi_ut_get_object_type_name (source_desc),
+				acpi_ut_get_object_type_name (new_desc)));
+		}
 		break;
 
 
 	default:
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
 			"Storing %s (%p) directly into node (%p), no implicit conversion\n",
-			acpi_ut_get_type_name (source_desc->common.type), source_desc, node));
+			acpi_ut_get_object_type_name (source_desc), source_desc, node));
 
 		/* No conversions for all other types.  Just attach the source object */
 
-		status = acpi_ns_attach_object (node, source_desc, source_desc->common.type);
+		status = acpi_ns_attach_object (node, source_desc, ACPI_GET_OBJECT_TYPE (source_desc));
 		break;
 	}
 
-
 	return_ACPI_STATUS (status);
 }
 
 
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ex_store_object_to_object
- *
- * PARAMETERS:  *Source_desc           - Value to be stored
- *              *Dest_desc          - Object to receive the value
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Store an object to another object.
- *
- *              The Assignment of an object to another (not named) object
- *              is handled here.
- *              The val passed in will replace the current value (if any)
- *              with the input value.
- *
- *              When storing into an object the data is converted to the
- *              target object type then stored in the object.  This means
- *              that the target object type (for an initialized target) will
- *              not be changed by a store operation.
- *
- *              This module allows destination types of Number, String,
- *              and Buffer.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ex_store_object_to_object (
-	acpi_operand_object     *source_desc,
-	acpi_operand_object     *dest_desc,
-	acpi_walk_state         *walk_state)
-{
-	acpi_status             status = AE_OK;
-	acpi_object_type8       destination_type = dest_desc->common.type;
-
-
-	FUNCTION_TRACE ("Ex_store_object_to_object");
-
-
-	/*
-	 *  Assuming the parameters are valid!
-	 */
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Storing %p(%s) to %p(%s)\n",
-			  source_desc, acpi_ut_get_type_name (source_desc->common.type),
-			  dest_desc, acpi_ut_get_type_name (dest_desc->common.type)));
-
-
-	/*
-	 * From this interface, we only support Integers/Strings/Buffers
-	 */
-	switch (destination_type) {
-	case ACPI_TYPE_INTEGER:
-	case ACPI_TYPE_STRING:
-	case ACPI_TYPE_BUFFER:
-		break;
-
-	default:
-		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into %s not implemented\n",
-			acpi_ut_get_type_name (dest_desc->common.type)));
-
-		return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
-	}
-
-
-	/*
-	 * Resolve the source object to an actual value
-	 * (If it is a reference object)
-	 */
-	status = acpi_ex_resolve_object (&source_desc, destination_type, walk_state);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
-
-
-	/*
-	 * Copy and/or convert the source object to the destination object
-	 */
-	status = acpi_ex_store_object (source_desc, destination_type, &dest_desc, walk_state);
-
-
-	return_ACPI_STATUS (status);
-}
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exstoren.c linux-2.4.22-pre2/drivers/acpi/executer/exstoren.c
--- linux-2.4.21/drivers/acpi/executer/exstoren.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exstoren.c	2003-06-26 21:43:12.000000000 +0000
@@ -3,128 +3,136 @@
  *
  * Module Name: exstoren - AML Interpreter object store support,
  *                        Store to Node (namespace object)
- *              $Revision: 40 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "acdispat.h"
-#include "acinterp.h"
-#include "amlcode.h"
-#include "acnamesp.h"
-#include "actables.h"
+#include <acpi/acpi.h>
+#include <acpi/acinterp.h>
 
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exstoren")
+	 ACPI_MODULE_NAME    ("exstoren")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_resolve_object
+ * FUNCTION:    acpi_ex_resolve_object
  *
- * PARAMETERS:  Source_desc_ptr     - Pointer to the source object
- *              Target_type         - Current type of the target
- *              Walk_state          - Current walk state
+ * PARAMETERS:  source_desc_ptr     - Pointer to the source object
+ *              target_type         - Current type of the target
+ *              walk_state          - Current walk state
  *
- * RETURN:      Status, resolved object in Source_desc_ptr.
+ * RETURN:      Status, resolved object in source_desc_ptr.
  *
  * DESCRIPTION: Resolve an object.  If the object is a reference, dereference
- *              it and return the actual object in the Source_desc_ptr.
+ *              it and return the actual object in the source_desc_ptr.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ex_resolve_object (
-	acpi_operand_object     **source_desc_ptr,
-	acpi_object_type8       target_type,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       **source_desc_ptr,
+	acpi_object_type                target_type,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_operand_object     *source_desc = *source_desc_ptr;
-	acpi_status             status = AE_OK;
+	union acpi_operand_object       *source_desc = *source_desc_ptr;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE ("Ex_resolve_object");
+	ACPI_FUNCTION_TRACE ("ex_resolve_object");
 
 
 	/*
-	 * Ensure we have a Source that can be stored in the target
+	 * Ensure we have a Target that can be stored to
 	 */
 	switch (target_type) {
-
-	/* This case handles the "interchangeable" types Integer, String, and Buffer. */
-
-	/*
-	 * These cases all require only Integers or values that
-	 * can be converted to Integers (Strings or Buffers)
-	 */
 	case ACPI_TYPE_BUFFER_FIELD:
-	case INTERNAL_TYPE_REGION_FIELD:
-	case INTERNAL_TYPE_BANK_FIELD:
-	case INTERNAL_TYPE_INDEX_FIELD:
+	case ACPI_TYPE_LOCAL_REGION_FIELD:
+	case ACPI_TYPE_LOCAL_BANK_FIELD:
+	case ACPI_TYPE_LOCAL_INDEX_FIELD:
+		/*
+		 * These cases all require only Integers or values that
+		 * can be converted to Integers (Strings or Buffers)
+		 */
 
-	/*
-	 * Stores into a Field/Region or into a Buffer/String
-	 * are all essentially the same.
-	 */
 	case ACPI_TYPE_INTEGER:
 	case ACPI_TYPE_STRING:
 	case ACPI_TYPE_BUFFER:
 
+		/*
+		 * Stores into a Field/Region or into a Integer/Buffer/String
+		 * are all essentially the same.  This case handles the
+		 * "interchangeable" types Integer, String, and Buffer.
+		 */
+		if (ACPI_GET_OBJECT_TYPE (source_desc) == ACPI_TYPE_LOCAL_REFERENCE) {
+			/* Resolve a reference object first */
 
-		/* TBD: FIX - check for source==REF, resolve, then check type */
+			status = acpi_ex_resolve_to_value (source_desc_ptr, walk_state);
+			if (ACPI_FAILURE (status)) {
+				break;
+			}
+		}
 
 		/*
-		 * If Source_desc is not a valid type, try to resolve it to one.
+		 * Must have a Integer, Buffer, or String
 		 */
-		if ((source_desc->common.type != ACPI_TYPE_INTEGER)    &&
-			(source_desc->common.type != ACPI_TYPE_BUFFER)     &&
-			(source_desc->common.type != ACPI_TYPE_STRING)) {
+		if ((ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_INTEGER)    &&
+			(ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_BUFFER)     &&
+			(ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_STRING)) {
 			/*
-			 * Initially not a valid type, convert
+			 * Conversion successful but still not a valid type
 			 */
-			status = acpi_ex_resolve_to_value (source_desc_ptr, walk_state);
-			if (ACPI_SUCCESS (status) &&
-				(source_desc->common.type != ACPI_TYPE_INTEGER)    &&
-				(source_desc->common.type != ACPI_TYPE_BUFFER)     &&
-				(source_desc->common.type != ACPI_TYPE_STRING)) {
-				/*
-				 * Conversion successful but still not a valid type
-				 */
-				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-					"Cannot assign type %s to %s (must be type Int/Str/Buf)\n",
-					acpi_ut_get_type_name ((*source_desc_ptr)->common.type),
-					acpi_ut_get_type_name (target_type)));
-				status = AE_AML_OPERAND_TYPE;
-			}
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"Cannot assign type %s to %s (must be type Int/Str/Buf)\n",
+				acpi_ut_get_object_type_name (source_desc),
+				acpi_ut_get_type_name (target_type)));
+			status = AE_AML_OPERAND_TYPE;
 		}
 		break;
 
 
-	case INTERNAL_TYPE_ALIAS:
+	case ACPI_TYPE_LOCAL_ALIAS:
 
 		/*
-		 * Aliases are resolved by Acpi_ex_prep_operands
+		 * Aliases are resolved by acpi_ex_prep_operands
 		 */
 		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into Alias - should never happen\n"));
 		status = AE_AML_INTERNAL;
@@ -147,12 +155,12 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_store_object
+ * FUNCTION:    acpi_ex_store_object_to_object
  *
- * PARAMETERS:  Source_desc         - Object to store
- *              Target_type         - Current type of the target
- *              Target_desc_ptr     - Pointer to the target
- *              Walk_state          - Current walk state
+ * PARAMETERS:  source_desc         - Object to store
+ *              dest_desc           - Object to receive a copy of the source
+ *              new_desc            - New object if dest_desc is obsoleted
+ *              walk_state          - Current walk state
  *
  * RETURN:      Status
  *
@@ -161,93 +169,123 @@
  *              conversion), and a copy of the value of the source to
  *              the target.
  *
+ *              The Assignment of an object to another (not named) object
+ *              is handled here.
+ *              The Source passed in will replace the current value (if any)
+ *              with the input value.
+ *
+ *              When storing into an object the data is converted to the
+ *              target object type then stored in the object.  This means
+ *              that the target object type (for an initialized target) will
+ *              not be changed by a store operation.
+ *
+ *              This module allows destination types of Number, String,
+ *              Buffer, and Package.
+ *
+ *              Assumes parameters are already validated.  NOTE: source_desc
+ *              resolution (from a reference object) must be performed by
+ *              the caller if necessary.
+ *
  ******************************************************************************/
 
 acpi_status
-acpi_ex_store_object (
-	acpi_operand_object     *source_desc,
-	acpi_object_type8       target_type,
-	acpi_operand_object     **target_desc_ptr,
-	acpi_walk_state         *walk_state)
+acpi_ex_store_object_to_object (
+	union acpi_operand_object       *source_desc,
+	union acpi_operand_object       *dest_desc,
+	union acpi_operand_object       **new_desc,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_operand_object     *target_desc = *target_desc_ptr;
-	acpi_status             status = AE_OK;
+	union acpi_operand_object       *actual_src_desc;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE ("Ex_store_object");
+	ACPI_FUNCTION_TRACE_PTR ("ex_store_object_to_object", source_desc);
 
 
-	/*
-	 * Perform the "implicit conversion" of the source to the current type
-	 * of the target - As per the ACPI specification.
-	 *
-	 * If no conversion performed, Source_desc is left alone, otherwise it
-	 * is updated with a new object.
-	 */
-	status = acpi_ex_convert_to_target_type (target_type, &source_desc, walk_state);
-	if (ACPI_FAILURE (status)) {
+	actual_src_desc = source_desc;
+	if (!dest_desc) {
+		/*
+		 * There is no destination object (An uninitialized node or
+		 * package element), so we can simply copy the source object
+		 * creating a new destination object
+		 */
+		status = acpi_ut_copy_iobject_to_iobject (actual_src_desc, new_desc, walk_state);
 		return_ACPI_STATUS (status);
 	}
 
-	/*
-	 * We now have two objects of identical types, and we can perform a
-	 * copy of the *value* of the source object.
-	 */
-	switch (target_type) {
-	case ACPI_TYPE_ANY:
-	case INTERNAL_TYPE_DEF_ANY:
-
+	if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_GET_OBJECT_TYPE (dest_desc)) {
 		/*
-		 * The target namespace node is uninitialized (has no target object),
-		 * and will take on the type of the source object
+		 * The source type does not match the type of the destination.
+		 * Perform the "implicit conversion" of the source to the current type
+		 * of the target as per the ACPI specification.
+		 *
+		 * If no conversion performed, actual_src_desc = source_desc.
+		 * Otherwise, actual_src_desc is a temporary object to hold the
+		 * converted object.
 		 */
-		*target_desc_ptr = source_desc;
-		break;
+		status = acpi_ex_convert_to_target_type (ACPI_GET_OBJECT_TYPE (dest_desc), source_desc,
+				  &actual_src_desc, walk_state);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
+		}
 
+		if (source_desc == actual_src_desc) {
+			/*
+			 * No conversion was performed.  Return the source_desc as the
+			 * new object.
+			 */
+			*new_desc = source_desc;
+			return_ACPI_STATUS (AE_OK);
+		}
+	}
 
+	/*
+	 * We now have two objects of identical types, and we can perform a
+	 * copy of the *value* of the source object.
+	 */
+	switch (ACPI_GET_OBJECT_TYPE (dest_desc)) {
 	case ACPI_TYPE_INTEGER:
 
-		target_desc->integer.value = source_desc->integer.value;
+		dest_desc->integer.value = actual_src_desc->integer.value;
 
 		/* Truncate value if we are executing from a 32-bit ACPI table */
 
-		acpi_ex_truncate_for32bit_table (target_desc, walk_state);
+		acpi_ex_truncate_for32bit_table (dest_desc);
 		break;
 
 	case ACPI_TYPE_STRING:
 
-		status = acpi_ex_copy_string_to_string (source_desc, target_desc);
+		status = acpi_ex_store_string_to_string (actual_src_desc, dest_desc);
 		break;
 
-
 	case ACPI_TYPE_BUFFER:
 
-		status = acpi_ex_copy_buffer_to_buffer (source_desc, target_desc);
+		status = acpi_ex_store_buffer_to_buffer (actual_src_desc, dest_desc);
 		break;
 
-
 	case ACPI_TYPE_PACKAGE:
 
-		/*
-		 * TBD: [Unhandled] Not real sure what to do here
-		 */
-		status = AE_NOT_IMPLEMENTED;
+		status = acpi_ut_copy_iobject_to_iobject (actual_src_desc, &dest_desc, walk_state);
 		break;
 
-
 	default:
-
 		/*
 		 * All other types come here.
 		 */
 		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into type %s not implemented\n",
-			acpi_ut_get_type_name (target_type)));
+			acpi_ut_get_object_type_name (dest_desc)));
 
 		status = AE_NOT_IMPLEMENTED;
 		break;
 	}
 
+	if (actual_src_desc != source_desc) {
+		/* Delete the intermediate (temporary) source object */
+
+		acpi_ut_remove_reference (actual_src_desc);
+	}
 
+	*new_desc = dest_desc;
 	return_ACPI_STATUS (status);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exstorob.c linux-2.4.22-pre2/drivers/acpi/executer/exstorob.c
--- linux-2.4.21/drivers/acpi/executer/exstorob.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exstorob.c	2003-06-26 21:43:32.000000000 +0000
@@ -2,48 +2,61 @@
 /******************************************************************************
  *
  * Module Name: exstorob - AML Interpreter object store support, store to object
- *              $Revision: 37 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "acdispat.h"
-#include "acinterp.h"
-#include "amlcode.h"
-#include "acnamesp.h"
-#include "actables.h"
+#include <acpi/acpi.h>
+#include <acpi/acinterp.h>
 
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exstorob")
+	 ACPI_MODULE_NAME    ("exstorob")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_copy_buffer_to_buffer
+ * FUNCTION:    acpi_ex_store_buffer_to_buffer
  *
- * PARAMETERS:  Source_desc         - Source object to copy
- *              Target_desc         - Destination object of the copy
+ * PARAMETERS:  source_desc         - Source object to copy
+ *              target_desc         - Destination object of the copy
  *
  * RETURN:      Status
  *
@@ -52,33 +65,35 @@
  ******************************************************************************/
 
 acpi_status
-acpi_ex_copy_buffer_to_buffer (
-	acpi_operand_object     *source_desc,
-	acpi_operand_object     *target_desc)
+acpi_ex_store_buffer_to_buffer (
+	union acpi_operand_object       *source_desc,
+	union acpi_operand_object       *target_desc)
 {
-	u32                     length;
-	u8                      *buffer;
+	u32                             length;
+	u8                              *buffer;
 
 
-	PROC_NAME ("Ex_copy_buffer_to_buffer");
+	ACPI_FUNCTION_TRACE_PTR ("ex_store_buffer_to_buffer", source_desc);
 
 
 	/*
-	 * We know that Source_desc is a buffer by now
+	 * We know that source_desc is a buffer by now
 	 */
 	buffer = (u8 *) source_desc->buffer.pointer;
 	length = source_desc->buffer.length;
 
 	/*
-	 * If target is a buffer of length zero, allocate a new
-	 * buffer of the proper length
+	 * If target is a buffer of length zero or is a static buffer,
+	 * allocate a new buffer of the proper length
 	 */
-	if (target_desc->buffer.length == 0) {
+	if ((target_desc->buffer.length == 0) ||
+		(target_desc->common.flags & AOPOBJ_STATIC_POINTER)) {
 		target_desc->buffer.pointer = ACPI_MEM_ALLOCATE (length);
 		if (!target_desc->buffer.pointer) {
-			return (AE_NO_MEMORY);
+			return_ACPI_STATUS (AE_NO_MEMORY);
 		}
 
+		target_desc->common.flags &= ~AOPOBJ_STATIC_POINTER;
 		target_desc->buffer.length = length;
 	}
 
@@ -89,31 +104,33 @@
 	if (length <= target_desc->buffer.length) {
 		/* Clear existing buffer and copy in the new one */
 
-		MEMSET (target_desc->buffer.pointer, 0, target_desc->buffer.length);
-		MEMCPY (target_desc->buffer.pointer, buffer, length);
+		ACPI_MEMSET (target_desc->buffer.pointer, 0, target_desc->buffer.length);
+		ACPI_MEMCPY (target_desc->buffer.pointer, buffer, length);
 	}
-
 	else {
 		/*
 		 * Truncate the source, copy only what will fit
 		 */
-		MEMCPY (target_desc->buffer.pointer, buffer, target_desc->buffer.length);
+		ACPI_MEMCPY (target_desc->buffer.pointer, buffer, target_desc->buffer.length);
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
 			"Truncating src buffer from %X to %X\n",
 			length, target_desc->buffer.length));
 	}
 
-	return (AE_OK);
+	/* Copy flags */
+
+	target_desc->buffer.flags = source_desc->buffer.flags;
+	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_copy_string_to_string
+ * FUNCTION:    acpi_ex_store_string_to_string
  *
- * PARAMETERS:  Source_desc         - Source object to copy
- *              Target_desc         - Destination object of the copy
+ * PARAMETERS:  source_desc         - Source object to copy
+ *              target_desc         - Destination object of the copy
  *
  * RETURN:      Status
  *
@@ -122,36 +139,39 @@
  ******************************************************************************/
 
 acpi_status
-acpi_ex_copy_string_to_string (
-	acpi_operand_object     *source_desc,
-	acpi_operand_object     *target_desc)
+acpi_ex_store_string_to_string (
+	union acpi_operand_object       *source_desc,
+	union acpi_operand_object       *target_desc)
 {
-	u32                     length;
-	u8                      *buffer;
+	u32                             length;
+	u8                              *buffer;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_TRACE_PTR ("ex_store_string_to_string", source_desc);
 
 
 	/*
-	 * We know that Source_desc is a string by now.
+	 * We know that source_desc is a string by now.
 	 */
 	buffer = (u8 *) source_desc->string.pointer;
 	length = source_desc->string.length;
 
 	/*
-	 * Setting a string value replaces the old string
+	 * Replace existing string value if it will fit and the string
+	 * pointer is not a static pointer (part of an ACPI table)
 	 */
-	if (length < target_desc->string.length) {
-		/* Clear old string and copy in the new one */
-
-		MEMSET (target_desc->string.pointer, 0, target_desc->string.length);
-		MEMCPY (target_desc->string.pointer, buffer, length);
+	if ((length < target_desc->string.length) &&
+	   (!(target_desc->common.flags & AOPOBJ_STATIC_POINTER))) {
+		/*
+		 * String will fit in existing non-static buffer.
+		 * Clear old string and copy in the new one
+		 */
+		ACPI_MEMSET (target_desc->string.pointer, 0, (acpi_size) target_desc->string.length + 1);
+		ACPI_MEMCPY (target_desc->string.pointer, buffer, length);
 	}
-
 	else {
 		/*
-		 * Free the current buffer, then allocate a buffer
+		 * Free the current buffer, then allocate a new buffer
 		 * large enough to hold the value
 		 */
 		if (target_desc->string.pointer &&
@@ -162,16 +182,19 @@
 			ACPI_MEM_FREE (target_desc->string.pointer);
 		}
 
-		target_desc->string.pointer = ACPI_MEM_ALLOCATE (length + 1);
+		target_desc->string.pointer = ACPI_MEM_CALLOCATE ((acpi_size) length + 1);
 		if (!target_desc->string.pointer) {
-			return (AE_NO_MEMORY);
+			return_ACPI_STATUS (AE_NO_MEMORY);
 		}
 
-		target_desc->string.length = length;
-		MEMCPY (target_desc->string.pointer, buffer, length);
+		target_desc->common.flags &= ~AOPOBJ_STATIC_POINTER;
+		ACPI_MEMCPY (target_desc->string.pointer, buffer, length);
 	}
 
-	return (AE_OK);
+	/* Set the new target length */
+
+	target_desc->string.length = length;
+	return_ACPI_STATUS (AE_OK);
 }
 
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exsystem.c linux-2.4.22-pre2/drivers/acpi/executer/exsystem.c
--- linux-2.4.21/drivers/acpi/executer/exsystem.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exsystem.c	2003-06-26 21:43:12.000000000 +0000
@@ -2,42 +2,58 @@
 /******************************************************************************
  *
  * Module Name: exsystem - Interface to OS services
- *              $Revision: 67 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "achware.h"
-#include "acevents.h"
+#include <acpi/acpi.h>
+#include <acpi/acinterp.h>
+#include <acpi/acevents.h>
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exsystem")
+	 ACPI_MODULE_NAME    ("exsystem")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_system_wait_semaphore
+ * FUNCTION:    acpi_ex_system_wait_semaphore
  *
  * PARAMETERS:  Semaphore           - OSD semaphore to wait on
  *              Timeout             - Max time to wait
@@ -52,13 +68,14 @@
 
 acpi_status
 acpi_ex_system_wait_semaphore (
-	acpi_handle             semaphore,
-	u32                     timeout)
+	acpi_handle                     semaphore,
+	u16                             timeout)
 {
-	acpi_status             status;
+	acpi_status                     status;
+	acpi_status                     status2;
 
 
-	FUNCTION_TRACE ("Ex_system_wait_semaphore");
+	ACPI_FUNCTION_TRACE ("ex_system_wait_semaphore");
 
 
 	status = acpi_os_wait_semaphore (semaphore, 1, 0);
@@ -78,11 +95,11 @@
 
 		/* Reacquire the interpreter */
 
-		status = acpi_ex_enter_interpreter ();
-		if (ACPI_SUCCESS (status)) {
-			/* Restore the timeout exception */
+		status2 = acpi_ex_enter_interpreter ();
+		if (ACPI_FAILURE (status2)) {
+			/* Report fatal error, could not acquire interpreter */
 
-			status = AE_TIME;
+			return_ACPI_STATUS (status2);
 		}
 	}
 
@@ -92,21 +109,24 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_system_do_stall
+ * FUNCTION:    acpi_ex_system_do_stall
  *
- * PARAMETERS:  How_long            - The amount of time to stall
+ * PARAMETERS:  how_long            - The amount of time to stall
  *
- * RETURN:      None
+ * RETURN:      Status
  *
  * DESCRIPTION: Suspend running thread for specified amount of time.
  *
  ******************************************************************************/
 
-void
+acpi_status
 acpi_ex_system_do_stall (
-	u32                     how_long)
+	u32                             how_long)
 {
-	FUNCTION_ENTRY ();
+	acpi_status                     status = AE_OK;
+
+
+	ACPI_FUNCTION_ENTRY ();
 
 
 	if (how_long > 1000) /* 1 millisecond */ {
@@ -114,24 +134,26 @@
 
 		acpi_ex_exit_interpreter ();
 
-		acpi_os_stall (how_long);
+		acpi_os_sleep (0, (how_long / 1000) + 1);
 
 		/* And now we must get the interpreter again */
 
-		acpi_ex_enter_interpreter ();
+		status = acpi_ex_enter_interpreter ();
 	}
 
 	else {
-		acpi_os_sleep (0, (how_long / 1000) + 1);
+		acpi_os_stall (how_long);
 	}
+
+	return (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_system_do_suspend
+ * FUNCTION:    acpi_ex_system_do_suspend
  *
- * PARAMETERS:  How_long            - The amount of time to suspend
+ * PARAMETERS:  how_long            - The amount of time to suspend
  *
  * RETURN:      None
  *
@@ -139,12 +161,14 @@
  *
  ******************************************************************************/
 
-void
+acpi_status
 acpi_ex_system_do_suspend (
-	u32                     how_long)
+	u32                             how_long)
 {
+	acpi_status                     status;
 
-	FUNCTION_ENTRY ();
+
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/* Since this thread will sleep, we must release the interpreter */
@@ -156,34 +180,35 @@
 
 	/* And now we must get the interpreter again */
 
-	acpi_ex_enter_interpreter ();
+	status = acpi_ex_enter_interpreter ();
+	return (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_system_acquire_mutex
+ * FUNCTION:    acpi_ex_system_acquire_mutex
  *
- * PARAMETERS:  *Time_desc          - The 'time to delay' object descriptor
- *              *Obj_desc           - The object descriptor for this op
+ * PARAMETERS:  *time_desc          - The 'time to delay' object descriptor
+ *              *obj_desc           - The object descriptor for this op
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Provides an access point to perform synchronization operations
  *              within the AML.  This function will cause a lock to be generated
- *              for the Mutex pointed to by Obj_desc.
+ *              for the Mutex pointed to by obj_desc.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ex_system_acquire_mutex (
-	acpi_operand_object     *time_desc,
-	acpi_operand_object     *obj_desc)
+	union acpi_operand_object       *time_desc,
+	union acpi_operand_object       *obj_desc)
 {
-	acpi_status             status = AE_OK;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE_PTR ("Ex_system_acquire_mutex", obj_desc);
+	ACPI_FUNCTION_TRACE_PTR ("ex_system_acquire_mutex", obj_desc);
 
 
 	if (!obj_desc) {
@@ -194,21 +219,21 @@
 	 * Support for the _GL_ Mutex object -- go get the global lock
 	 */
 	if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) {
-		status = acpi_ev_acquire_global_lock ();
+		status = acpi_ev_acquire_global_lock ((u16) time_desc->integer.value);
 		return_ACPI_STATUS (status);
 	}
 
 	status = acpi_ex_system_wait_semaphore (obj_desc->mutex.semaphore,
-			  (u32) time_desc->integer.value);
+			  (u16) time_desc->integer.value);
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_system_release_mutex
+ * FUNCTION:    acpi_ex_system_release_mutex
  *
- * PARAMETERS:  *Obj_desc           - The object descriptor for this op
+ * PARAMETERS:  *obj_desc           - The object descriptor for this op
  *
  * RETURN:      Status
  *
@@ -221,12 +246,12 @@
 
 acpi_status
 acpi_ex_system_release_mutex (
-	acpi_operand_object     *obj_desc)
+	union acpi_operand_object       *obj_desc)
 {
-	acpi_status             status = AE_OK;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE ("Ex_system_release_mutex");
+	ACPI_FUNCTION_TRACE ("ex_system_release_mutex");
 
 
 	if (!obj_desc) {
@@ -237,8 +262,8 @@
 	 * Support for the _GL_ Mutex object -- release the global lock
 	 */
 	if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) {
-		acpi_ev_release_global_lock ();
-		return_ACPI_STATUS (AE_OK);
+		status = acpi_ev_release_global_lock ();
+		return_ACPI_STATUS (status);
 	}
 
 	status = acpi_os_signal_semaphore (obj_desc->mutex.semaphore, 1);
@@ -248,9 +273,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_system_signal_event
+ * FUNCTION:    acpi_ex_system_signal_event
  *
- * PARAMETERS:  *Obj_desc           - The object descriptor for this op
+ * PARAMETERS:  *obj_desc           - The object descriptor for this op
  *
  * RETURN:      AE_OK
  *
@@ -261,12 +286,12 @@
 
 acpi_status
 acpi_ex_system_signal_event (
-	acpi_operand_object     *obj_desc)
+	union acpi_operand_object       *obj_desc)
 {
-	acpi_status             status = AE_OK;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE ("Ex_system_signal_event");
+	ACPI_FUNCTION_TRACE ("ex_system_signal_event");
 
 
 	if (obj_desc) {
@@ -279,10 +304,10 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_system_wait_event
+ * FUNCTION:    acpi_ex_system_wait_event
  *
- * PARAMETERS:  *Time_desc          - The 'time to delay' object descriptor
- *              *Obj_desc           - The object descriptor for this op
+ * PARAMETERS:  *time_desc          - The 'time to delay' object descriptor
+ *              *obj_desc           - The object descriptor for this op
  *
  * RETURN:      Status
  *
@@ -294,30 +319,29 @@
 
 acpi_status
 acpi_ex_system_wait_event (
-	acpi_operand_object     *time_desc,
-	acpi_operand_object     *obj_desc)
+	union acpi_operand_object       *time_desc,
+	union acpi_operand_object       *obj_desc)
 {
-	acpi_status             status = AE_OK;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE ("Ex_system_wait_event");
+	ACPI_FUNCTION_TRACE ("ex_system_wait_event");
 
 
 	if (obj_desc) {
 		status = acpi_ex_system_wait_semaphore (obj_desc->event.semaphore,
-				  (u32) time_desc->integer.value);
+				  (u16) time_desc->integer.value);
 	}
 
-
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_system_reset_event
+ * FUNCTION:    acpi_ex_system_reset_event
  *
- * PARAMETERS:  *Obj_desc           - The object descriptor for this op
+ * PARAMETERS:  *obj_desc           - The object descriptor for this op
  *
  * RETURN:      Status
  *
@@ -327,13 +351,13 @@
 
 acpi_status
 acpi_ex_system_reset_event (
-	acpi_operand_object     *obj_desc)
+	union acpi_operand_object       *obj_desc)
 {
-	acpi_status             status = AE_OK;
-	void                    *temp_semaphore;
+	acpi_status                     status = AE_OK;
+	void                            *temp_semaphore;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/*
@@ -342,7 +366,7 @@
 	 */
 	status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 0, &temp_semaphore);
 	if (ACPI_SUCCESS (status)) {
-		acpi_os_delete_semaphore (obj_desc->event.semaphore);
+		(void) acpi_os_delete_semaphore (obj_desc->event.semaphore);
 		obj_desc->event.semaphore = temp_semaphore;
 	}
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/executer/exutils.c linux-2.4.22-pre2/drivers/acpi/executer/exutils.c
--- linux-2.4.21/drivers/acpi/executer/exutils.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/executer/exutils.c	2003-06-26 21:43:13.000000000 +0000
@@ -2,26 +2,44 @@
 /******************************************************************************
  *
  * Module Name: exutils - interpreter/scanner utilities
- *              $Revision: 85 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
@@ -41,45 +59,48 @@
 
 #define DEFINE_AML_GLOBALS
 
-#include "acpi.h"
-#include "acparser.h"
-#include "acinterp.h"
-#include "amlcode.h"
-#include "acnamesp.h"
-#include "acevents.h"
-#include "acparser.h"
+#include <acpi/acpi.h>
+#include <acpi/acinterp.h>
+#include <acpi/amlcode.h>
+#include <acpi/acevents.h>
 
 #define _COMPONENT          ACPI_EXECUTER
-	 MODULE_NAME         ("exutils")
+	 ACPI_MODULE_NAME    ("exutils")
 
 
+#ifndef ACPI_NO_METHOD_EXECUTION
+
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_enter_interpreter
+ * FUNCTION:    acpi_ex_enter_interpreter
  *
  * PARAMETERS:  None
  *
- * DESCRIPTION: Enter the interpreter execution region
- *              TBD: should be a macro
+ * DESCRIPTION: Enter the interpreter execution region.  Failure to enter
+ *              the interpreter region is a fatal system error
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ex_enter_interpreter (void)
 {
-	acpi_status             status;
+	acpi_status                     status;
 
-	FUNCTION_TRACE ("Ex_enter_interpreter");
+	ACPI_FUNCTION_TRACE ("ex_enter_interpreter");
 
 
 	status = acpi_ut_acquire_mutex (ACPI_MTX_EXECUTE);
+	if (ACPI_FAILURE (status)) {
+		ACPI_REPORT_ERROR (("Could not acquire interpreter mutex\n"));
+	}
+
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_exit_interpreter
+ * FUNCTION:    acpi_ex_exit_interpreter
  *
  * PARAMETERS:  None
  *
@@ -95,56 +116,31 @@
  *          already executing
  *      7) About to invoke a user-installed opregion handler
  *
- *              TBD: should be a macro
- *
  ******************************************************************************/
 
 void
 acpi_ex_exit_interpreter (void)
 {
-	FUNCTION_TRACE ("Ex_exit_interpreter");
-
-
-	acpi_ut_release_mutex (ACPI_MTX_EXECUTE);
-
-	return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ex_validate_object_type
- *
- * PARAMETERS:  Type            Object type to validate
- *
- * DESCRIPTION: Determine if a type is a valid ACPI object type
- *
- ******************************************************************************/
+	acpi_status                     status;
 
-u8
-acpi_ex_validate_object_type (
-	acpi_object_type        type)
-{
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_TRACE ("ex_exit_interpreter");
 
 
-	if ((type > ACPI_TYPE_MAX && type < INTERNAL_TYPE_BEGIN) ||
-		(type > INTERNAL_TYPE_MAX)) {
-		return (FALSE);
+	status = acpi_ut_release_mutex (ACPI_MTX_EXECUTE);
+	if (ACPI_FAILURE (status)) {
+		ACPI_REPORT_ERROR (("Could not release interpreter mutex\n"));
 	}
 
-	return (TRUE);
+	return_VOID;
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_truncate_for32bit_table
+ * FUNCTION:    acpi_ex_truncate_for32bit_table
  *
- * PARAMETERS:  Obj_desc        - Object to be truncated
- *              Walk_state      - Current walk state
- *                                (A method must be executing)
+ * PARAMETERS:  obj_desc        - Object to be truncated
  *
  * RETURN:      none
  *
@@ -155,11 +151,10 @@
 
 void
 acpi_ex_truncate_for32bit_table (
-	acpi_operand_object     *obj_desc,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       *obj_desc)
 {
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/*
@@ -167,12 +162,11 @@
 	 * a control method
 	 */
 	if ((!obj_desc) ||
-		(obj_desc->common.type != ACPI_TYPE_INTEGER) ||
-		(!walk_state->method_node)) {
+		(ACPI_GET_OBJECT_TYPE (obj_desc) != ACPI_TYPE_INTEGER)) {
 		return;
 	}
 
-	if (walk_state->method_node->flags & ANOBJ_DATA_WIDTH_32) {
+	if (acpi_gbl_integer_byte_width == 4) {
 		/*
 		 * We are running a method that exists in a 32-bit ACPI table.
 		 * Truncate the value to 32 bits by zeroing out the upper 32-bit field
@@ -184,9 +178,10 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_acquire_global_lock
+ * FUNCTION:    acpi_ex_acquire_global_lock
  *
- * PARAMETERS:  Rule            - Lock rule: Always_lock, Never_lock
+ * PARAMETERS:  field_flags           - Flags with Lock rule:
+ *                                      always_lock or never_lock
  *
  * RETURN:      TRUE/FALSE indicating whether the lock was actually acquired
  *
@@ -198,25 +193,24 @@
 
 u8
 acpi_ex_acquire_global_lock (
-	u32                     rule)
+	u32                             field_flags)
 {
-	u8                      locked = FALSE;
-	acpi_status             status;
+	u8                              locked = FALSE;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Ex_acquire_global_lock");
+	ACPI_FUNCTION_TRACE ("ex_acquire_global_lock");
 
 
-	/* Only attempt lock if the Rule says so */
+	/* Only attempt lock if the always_lock bit is set */
 
-	if (rule == (u32) GLOCK_ALWAYS_LOCK) {
-		/* We should attempt to get the lock */
+	if (field_flags & AML_FIELD_LOCK_RULE_MASK) {
+		/* We should attempt to get the lock, wait forever */
 
-		status = acpi_ev_acquire_global_lock ();
+		status = acpi_ev_acquire_global_lock (ACPI_WAIT_FOREVER);
 		if (ACPI_SUCCESS (status)) {
 			locked = TRUE;
 		}
-
 		else {
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not acquire Global Lock, %s\n",
 				acpi_format_exception (status)));
@@ -229,10 +223,10 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_release_global_lock
+ * FUNCTION:    acpi_ex_release_global_lock
  *
- * PARAMETERS:  Locked_by_me    - Return value from corresponding call to
- *                                Acquire_global_lock.
+ * PARAMETERS:  locked_by_me    - Return value from corresponding call to
+ *                                acquire_global_lock.
  *
  * RETURN:      Status
  *
@@ -240,12 +234,14 @@
  *
  ******************************************************************************/
 
-acpi_status
+void
 acpi_ex_release_global_lock (
-	u8                      locked_by_me)
+	u8                              locked_by_me)
 {
+	acpi_status                     status;
 
-	FUNCTION_TRACE ("Ex_release_global_lock");
+
+	ACPI_FUNCTION_TRACE ("ex_release_global_lock");
 
 
 	/* Only attempt unlock if the caller locked it */
@@ -253,17 +249,22 @@
 	if (locked_by_me) {
 		/* OK, now release the lock */
 
-		acpi_ev_release_global_lock ();
-	}
+		status = acpi_ev_release_global_lock ();
+		if (ACPI_FAILURE (status)) {
+			/* Report the error, but there isn't much else we can do */
 
+			ACPI_REPORT_ERROR (("Could not release ACPI Global Lock, %s\n",
+				acpi_format_exception (status)));
+		}
+	}
 
-	return_ACPI_STATUS (AE_OK);
+	return_VOID;
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_digits_needed
+ * FUNCTION:    acpi_ex_digits_needed
  *
  * PARAMETERS:  Value           - Value to be represented
  *              Base            - Base of representation
@@ -274,26 +275,30 @@
 
 u32
 acpi_ex_digits_needed (
-	acpi_integer            value,
-	u32                     base)
+	acpi_integer                    value,
+	u32                             base)
 {
-	u32                     num_digits = 0;
+	u32                             num_digits;
+	acpi_integer                    current_value;
+	acpi_integer                    quotient;
 
 
-	FUNCTION_TRACE ("Ex_digits_needed");
+	ACPI_FUNCTION_TRACE ("ex_digits_needed");
 
 
-	if (base < 1) {
-		REPORT_ERROR (("Ex_digits_needed: Internal error - Invalid base\n"));
+	/*
+	 * acpi_integer is unsigned, so we don't worry about a '-'
+	 */
+	if ((current_value = value) == 0) {
+	    return_VALUE (1);
 	}
 
-	else {
-		/*
-		 * acpi_integer is unsigned, which is why we don't worry about a '-'
-		 */
-		for (num_digits = 1;
-			(acpi_ut_short_divide (&value, base, &value, NULL));
-			++num_digits) { ; }
+	num_digits = 0;
+
+	while (current_value) {
+		(void) acpi_ut_short_divide (&current_value, base, &quotient, NULL);
+		num_digits++;
+		current_value = quotient;
 	}
 
 	return_VALUE (num_digits);
@@ -302,115 +307,74 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    ntohl
- *
- * PARAMETERS:  Value           - Value to be converted
- *
- * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
- *
- ******************************************************************************/
-
-static u32
-_ntohl (
-	u32                     value)
-{
-	union {
-		u32                 value;
-		u8                  bytes[4];
-	} out;
-
-	union {
-		u32                 value;
-		u8                  bytes[4];
-	} in;
-
-
-	FUNCTION_ENTRY ();
-
-
-	in.value = value;
-
-	out.bytes[0] = in.bytes[3];
-	out.bytes[1] = in.bytes[2];
-	out.bytes[2] = in.bytes[1];
-	out.bytes[3] = in.bytes[0];
-
-	return (out.value);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ex_eisa_id_to_string
+ * FUNCTION:    acpi_ex_eisa_id_to_string
  *
- * PARAMETERS:  Numeric_id      - EISA ID to be converted
- *              Out_string      - Where to put the converted string (8 bytes)
+ * PARAMETERS:  numeric_id      - EISA ID to be converted
+ *              out_string      - Where to put the converted string (8 bytes)
  *
  * DESCRIPTION: Convert a numeric EISA ID to string representation
  *
  ******************************************************************************/
 
-acpi_status
+void
 acpi_ex_eisa_id_to_string (
-	u32                     numeric_id,
-	NATIVE_CHAR             *out_string)
+	u32                             numeric_id,
+	char                            *out_string)
 {
-	u32                     id;
+	u32                             eisa_id;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
-	/* swap to big-endian to get contiguous bits */
+	/* Swap ID to big-endian to get contiguous bits */
 
-	id = _ntohl (numeric_id);
+	eisa_id = acpi_ut_dword_byte_swap (numeric_id);
 
-	out_string[0] = (char) ('@' + ((id >> 26) & 0x1f));
-	out_string[1] = (char) ('@' + ((id >> 21) & 0x1f));
-	out_string[2] = (char) ('@' + ((id >> 16) & 0x1f));
-	out_string[3] = acpi_ut_hex_to_ascii_char (id, 12);
-	out_string[4] = acpi_ut_hex_to_ascii_char (id, 8);
-	out_string[5] = acpi_ut_hex_to_ascii_char (id, 4);
-	out_string[6] = acpi_ut_hex_to_ascii_char (id, 0);
+	out_string[0] = (char) ('@' + (((unsigned long) eisa_id >> 26) & 0x1f));
+	out_string[1] = (char) ('@' + ((eisa_id >> 21) & 0x1f));
+	out_string[2] = (char) ('@' + ((eisa_id >> 16) & 0x1f));
+	out_string[3] = acpi_ut_hex_to_ascii_char ((acpi_integer) eisa_id, 12);
+	out_string[4] = acpi_ut_hex_to_ascii_char ((acpi_integer) eisa_id, 8);
+	out_string[5] = acpi_ut_hex_to_ascii_char ((acpi_integer) eisa_id, 4);
+	out_string[6] = acpi_ut_hex_to_ascii_char ((acpi_integer) eisa_id, 0);
 	out_string[7] = 0;
-
-	return (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_unsigned_integer_to_string
+ * FUNCTION:    acpi_ex_unsigned_integer_to_string
  *
  * PARAMETERS:  Value           - Value to be converted
- *              Out_string      - Where to put the converted string (8 bytes)
+ *              out_string      - Where to put the converted string (8 bytes)
  *
  * RETURN:      Convert a number to string representation
  *
  ******************************************************************************/
 
-acpi_status
+void
 acpi_ex_unsigned_integer_to_string (
-	acpi_integer            value,
-	NATIVE_CHAR             *out_string)
+	acpi_integer                    value,
+	char                            *out_string)
 {
-	u32                     count;
-	u32                     digits_needed;
-	u32                     remainder;
+	u32                             count;
+	u32                             digits_needed;
+	u32                             remainder;
+	acpi_integer                    quotient;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	digits_needed = acpi_ex_digits_needed (value, 10);
 	out_string[digits_needed] = 0;
 
 	for (count = digits_needed; count > 0; count--) {
-		acpi_ut_short_divide (&value, 10, &value, &remainder);
-		out_string[count-1] = (NATIVE_CHAR) ('0' + remainder);
+		(void) acpi_ut_short_divide (&value, 10, &quotient, &remainder);
+		out_string[count-1] = (char) ('0' + remainder);\
+		value = quotient;
 	}
-
-	return (AE_OK);
 }
 
-
+#endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/fan.c linux-2.4.22-pre2/drivers/acpi/fan.c
--- linux-2.4.21/drivers/acpi/fan.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/fan.c	2003-06-26 21:43:12.000000000 +0000
@@ -0,0 +1,296 @@
+/*
+ *  acpi_fan.c - ACPI Fan Driver ($Revision: 28 $)
+ *
+ *  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/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/compatmac.h>
+#include <linux/proc_fs.h>
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+
+
+#define _COMPONENT		ACPI_FAN_COMPONENT
+ACPI_MODULE_NAME		("acpi_fan")
+
+MODULE_AUTHOR("Paul Diefenbaugh");
+MODULE_DESCRIPTION(ACPI_FAN_DRIVER_NAME);
+MODULE_LICENSE("GPL");
+
+#define PREFIX			"ACPI: "
+
+
+int acpi_fan_add (struct acpi_device *device);
+int acpi_fan_remove (struct acpi_device *device, int type);
+
+static struct acpi_driver acpi_fan_driver = {
+	.name =		ACPI_FAN_DRIVER_NAME,
+	.class =	ACPI_FAN_CLASS,
+	.ids =		ACPI_FAN_HID,
+	.ops =		{
+				.add =		acpi_fan_add,
+				.remove =	acpi_fan_remove,
+			},
+};
+
+struct acpi_fan {
+	acpi_handle		handle;
+};
+
+
+/* --------------------------------------------------------------------------
+                              FS Interface (/proc)
+   -------------------------------------------------------------------------- */
+
+struct proc_dir_entry		*acpi_fan_dir = NULL;
+
+
+static int
+acpi_fan_read_state (
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	struct acpi_fan		*fan = (struct acpi_fan *) data;
+	char			*p = page;
+	int			len = 0;
+	int			state = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_fan_read_state");
+
+	if (!fan || (off != 0))
+		goto end;
+
+	if (acpi_bus_get_power(fan->handle, &state))
+		goto end;
+
+	p += sprintf(p, "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);
+}
+
+
+static int
+acpi_fan_write_state (
+	struct file		*file,
+	const char		*buffer,
+	unsigned long		count,
+	void			*data)
+{
+	int			result = 0;
+	struct acpi_fan		*fan = (struct acpi_fan *) data;
+	char			state_string[12] = {'\0'};
+
+	ACPI_FUNCTION_TRACE("acpi_fan_write_state");
+
+	if (!fan || (count > sizeof(state_string) - 1))
+		return_VALUE(-EINVAL);
+	
+	if (copy_from_user(state_string, buffer, count))
+		return_VALUE(-EFAULT);
+	
+	state_string[count] = '\0';
+	
+	result = acpi_bus_set_power(fan->handle, 
+		simple_strtoul(state_string, NULL, 0));
+	if (result)
+		return_VALUE(result);
+
+	return_VALUE(count);
+}
+
+
+static int
+acpi_fan_add_fs (
+	struct acpi_device	*device)
+{
+	struct proc_dir_entry	*entry = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_fan_add_fs");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	if (!acpi_device_dir(device)) {
+		acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
+			acpi_fan_dir);
+		if (!acpi_device_dir(device))
+			return_VALUE(-ENODEV);
+	}
+
+	/* 'status' [R/W] */
+	entry = create_proc_entry(ACPI_FAN_FILE_STATE,
+		S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"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->data = acpi_driver_data(device);
+	}
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_fan_remove_fs (
+	struct acpi_device	*device)
+{
+	ACPI_FUNCTION_TRACE("acpi_fan_remove_fs");
+
+	if (acpi_device_dir(device)) {
+		remove_proc_entry(acpi_device_bid(device), acpi_fan_dir);
+		acpi_device_dir(device) = NULL;
+	}
+
+	return_VALUE(0);
+}
+
+
+/* --------------------------------------------------------------------------
+                                 Driver Interface
+   -------------------------------------------------------------------------- */
+
+int
+acpi_fan_add (
+	struct acpi_device	*device)
+{
+	int			result = 0;
+	struct acpi_fan		*fan = NULL;
+	int			state = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_fan_add");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	fan = kmalloc(sizeof(struct acpi_fan), GFP_KERNEL);
+	if (!fan)
+		return_VALUE(-ENOMEM);
+	memset(fan, 0, sizeof(struct acpi_fan));
+
+	fan->handle = device->handle;
+	sprintf(acpi_device_name(device), "%s", ACPI_FAN_DEVICE_NAME);
+	sprintf(acpi_device_class(device), "%s", ACPI_FAN_CLASS);
+	acpi_driver_data(device) = fan;
+
+	result = acpi_bus_get_power(fan->handle, &state);
+	if (result) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Error reading power state\n"));
+		goto end;
+	}
+
+	result = acpi_fan_add_fs(device);
+	if (result)
+		goto end;
+
+	printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
+		acpi_device_name(device), acpi_device_bid(device),
+		!device->power.state?"on":"off");
+
+end:
+	if (result)
+		kfree(fan);
+
+	return_VALUE(result);
+}
+
+
+int
+acpi_fan_remove (
+	struct acpi_device	*device,
+	int			type)
+{
+	struct acpi_fan		*fan = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_fan_remove");
+
+	if (!device || !acpi_driver_data(device))
+		return_VALUE(-EINVAL);
+
+	fan = (struct acpi_fan *) acpi_driver_data(device);
+
+	acpi_fan_remove_fs(device);
+
+	kfree(fan);
+
+	return_VALUE(0);
+}
+
+
+int __init
+acpi_fan_init (void)
+{
+	int			result = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_fan_init");
+
+	acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir);
+	if (!acpi_fan_dir)
+		return_VALUE(-ENODEV);
+
+	result = acpi_bus_register_driver(&acpi_fan_driver);
+	if (result < 0) {
+		remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir);
+		return_VALUE(-ENODEV);
+	}
+
+	return_VALUE(0);
+}
+
+
+void __exit
+acpi_fan_exit (void)
+{
+	ACPI_FUNCTION_TRACE("acpi_fan_exit");
+
+	acpi_bus_unregister_driver(&acpi_fan_driver);
+
+	remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir);
+
+	return_VOID;
+}
+
+
+module_init(acpi_fan_init);
+module_exit(acpi_fan_exit);
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/hardware/Makefile linux-2.4.22-pre2/drivers/acpi/hardware/Makefile
--- linux-2.4.21/drivers/acpi/hardware/Makefile	2001-06-21 00:47:40.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/hardware/Makefile	2003-06-26 21:43:18.000000000 +0000
@@ -1,11 +1,10 @@
 #
 # Makefile for all Linux ACPI interpreter subdirectories
-# EXCEPT for the ospm directory
 #
 
 O_TARGET := $(notdir $(CURDIR)).o
 
-obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/hardware/hwacpi.c linux-2.4.22-pre2/drivers/acpi/hardware/hwacpi.c
--- linux-2.4.21/drivers/acpi/hardware/hwacpi.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/hardware/hwacpi.c	2003-06-26 21:43:10.000000000 +0000
@@ -2,40 +2,57 @@
 /******************************************************************************
  *
  * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface
- *              $Revision: 46 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "achware.h"
+#include <acpi/acpi.h>
 
 
 #define _COMPONENT          ACPI_HARDWARE
-	 MODULE_NAME         ("hwacpi")
+	 ACPI_MODULE_NAME    ("hwacpi")
 
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_hw_initialize
+ * FUNCTION:    acpi_hw_initialize
  *
  * PARAMETERS:  None
  *
@@ -49,182 +66,120 @@
 acpi_hw_initialize (
 	void)
 {
-	acpi_status             status = AE_OK;
-	u32                     index;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Hw_initialize");
+	ACPI_FUNCTION_TRACE ("hw_initialize");
 
 
 	/* We must have the ACPI tables by the time we get here */
 
 	if (!acpi_gbl_FADT) {
-		acpi_gbl_restore_acpi_chipset = FALSE;
-
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No FADT!\n"));
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "A FADT is not loaded\n"));
 
 		return_ACPI_STATUS (AE_NO_ACPI_TABLES);
 	}
 
-	/* Identify current ACPI/legacy mode   */
-
-	switch (acpi_gbl_system_flags & SYS_MODES_MASK) {
-	case (SYS_MODE_ACPI):
-
-		acpi_gbl_original_mode = SYS_MODE_ACPI;
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "System supports ACPI mode only.\n"));
-		break;
-
-
-	case (SYS_MODE_LEGACY):
-
-		acpi_gbl_original_mode = SYS_MODE_LEGACY;
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-			"Tables loaded from buffer, hardware assumed to support LEGACY mode only.\n"));
-		break;
-
+	/* Sanity check the FADT for valid values */
 
-	case (SYS_MODE_ACPI | SYS_MODE_LEGACY):
-
-		if (acpi_hw_get_mode () == SYS_MODE_ACPI) {
-			acpi_gbl_original_mode = SYS_MODE_ACPI;
-		}
-		else {
-			acpi_gbl_original_mode = SYS_MODE_LEGACY;
-		}
-
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-			"System supports both ACPI and LEGACY modes.\n"));
-
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-			"System is currently in %s mode.\n",
-			(acpi_gbl_original_mode == SYS_MODE_ACPI) ? "ACPI" : "LEGACY"));
-		break;
+	status = acpi_ut_validate_fadt ();
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
 	}
 
-
-	if (acpi_gbl_system_flags & SYS_MODE_ACPI) {
-		/* Target system supports ACPI mode */
-
-		/*
-		 * The purpose of this code is to save the initial state
-		 * of the ACPI event enable registers. An exit function will be
-		 * registered which will restore this state when the application
-		 * exits. The exit function will also clear all of the ACPI event
-		 * status bits prior to restoring the original mode.
-		 *
-		 * The location of the PM1a_evt_blk enable registers is defined as the
-		 * base of PM1a_evt_blk + DIV_2(PM1a_evt_blk_length). Since the spec further
-		 * fully defines the PM1a_evt_blk to be a total of 4 bytes, the offset
-		 * for the enable registers is always 2 from the base. It is hard
-		 * coded here. If this changes in the spec, this code will need to
-		 * be modified. The PM1b_evt_blk behaves as expected.
-		 */
-		acpi_gbl_pm1_enable_register_save = (u16) acpi_hw_register_read (
-				   ACPI_MTX_LOCK, PM1_EN);
-
-
-		/*
-		 * The GPEs behave similarly, except that the length of the register
-		 * block is not fixed, so the buffer must be allocated with malloc
-		 */
-		if (ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xgpe0blk.address) &&
-			acpi_gbl_FADT->gpe0blk_len) {
-			/* GPE0 specified in FADT  */
-
-			acpi_gbl_gpe0enable_register_save = ACPI_MEM_ALLOCATE (
-					   DIV_2 (acpi_gbl_FADT->gpe0blk_len));
-			if (!acpi_gbl_gpe0enable_register_save) {
-				return_ACPI_STATUS (AE_NO_MEMORY);
-			}
-
-			/* Save state of GPE0 enable bits */
-
-			for (index = 0; index < DIV_2 (acpi_gbl_FADT->gpe0blk_len); index++) {
-				acpi_gbl_gpe0enable_register_save[index] =
-					(u8) acpi_hw_register_read (ACPI_MTX_LOCK, GPE0_EN_BLOCK | index);
-			}
-		}
-
-		else {
-			acpi_gbl_gpe0enable_register_save = NULL;
-		}
-
-		if (ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xgpe1_blk.address) &&
-			acpi_gbl_FADT->gpe1_blk_len) {
-			/* GPE1 defined */
-
-			acpi_gbl_gpe1_enable_register_save = ACPI_MEM_ALLOCATE (
-					   DIV_2 (acpi_gbl_FADT->gpe1_blk_len));
-			if (!acpi_gbl_gpe1_enable_register_save) {
-				return_ACPI_STATUS (AE_NO_MEMORY);
-			}
-
-			/* save state of GPE1 enable bits */
-
-			for (index = 0; index < DIV_2 (acpi_gbl_FADT->gpe1_blk_len); index++) {
-				acpi_gbl_gpe1_enable_register_save[index] =
-					(u8) acpi_hw_register_read (ACPI_MTX_LOCK, GPE1_EN_BLOCK | index);
-			}
-		}
-
-		else {
-			acpi_gbl_gpe1_enable_register_save = NULL;
-		}
-	}
-
-	return_ACPI_STATUS (status);
+	return_ACPI_STATUS (AE_OK);
 }
 
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_hw_set_mode
+ * FUNCTION:    acpi_hw_set_mode
  *
  * PARAMETERS:  Mode            - SYS_MODE_ACPI or SYS_MODE_LEGACY
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Transitions the system into the requested mode or does nothing
- *              if the system is already in that mode.
+ * DESCRIPTION: Transitions the system into the requested mode.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_hw_set_mode (
-	u32                     mode)
+	u32                             mode)
 {
 
-	acpi_status             status = AE_NO_HARDWARE_RESPONSE;
+	acpi_status                     status;
+	u32                             retry;
 
 
-	FUNCTION_TRACE ("Hw_set_mode");
+	ACPI_FUNCTION_TRACE ("hw_set_mode");
 
+	/*
+	 * ACPI 2.0 clarified that if SMI_CMD in FADT is zero,
+	 * system does not support mode transition.
+	 */
+	if (!acpi_gbl_FADT->smi_cmd) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No SMI_CMD in FADT, mode transition failed.\n"));
+		return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
+	}
+
+	/*
+	 * ACPI 2.0 clarified the meaning of ACPI_ENABLE and ACPI_DISABLE
+	 * in FADT: If it is zero, enabling or disabling is not supported.
+	 * As old systems may have used zero for mode transition,
+	 * we make sure both the numbers are zero to determine these
+	 * transitions are not supported.
+	 */
+	if (!acpi_gbl_FADT->acpi_enable && !acpi_gbl_FADT->acpi_disable) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "No mode transition supported in this system.\n"));
+		return_ACPI_STATUS (AE_OK);
+	}
+
+	switch (mode) {
+	case ACPI_SYS_MODE_ACPI:
 
-	if (mode == SYS_MODE_ACPI) {
 		/* BIOS should have disabled ALL fixed and GP events */
 
-		acpi_os_write_port (acpi_gbl_FADT->smi_cmd, acpi_gbl_FADT->acpi_enable, 8);
+		status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd,
+				  (u32) acpi_gbl_FADT->acpi_enable, 8);
 		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable ACPI mode\n"));
-	}
+		break;
+
+	case ACPI_SYS_MODE_LEGACY:
 
-	else if (mode == SYS_MODE_LEGACY) {
 		/*
 		 * BIOS should clear all fixed status bits and restore fixed event
 		 * enable bits to default
 		 */
-		acpi_os_write_port (acpi_gbl_FADT->smi_cmd, acpi_gbl_FADT->acpi_disable, 8);
+		status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd,
+				 (u32) acpi_gbl_FADT->acpi_disable, 8);
 		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
 				 "Attempting to enable Legacy (non-ACPI) mode\n"));
+		break;
+
+	default:
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-	/* Give the platform some time to react */
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
-	acpi_os_stall (20000);
+	/*
+	 * Some hardware takes a LONG time to switch modes. Give them 3 sec to
+	 * do so, but allow faster systems to proceed more quickly.
+	 */
+	retry = 3000;
+	while (retry) {
+		status = AE_NO_HARDWARE_RESPONSE;
 
-	if (acpi_hw_get_mode () == mode) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n", mode));
-		status = AE_OK;
+		if (acpi_hw_get_mode() == mode) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n", mode));
+			status = AE_OK;
+			break;
+		}
+		acpi_os_stall(1000);
+		retry--;
 	}
 
 	return_ACPI_STATUS (status);
@@ -233,7 +188,7 @@
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_hw_get_mode
+ * FUNCTION:    acpi_hw_get_mode
  *
  * PARAMETERS:  none
  *
@@ -247,74 +202,21 @@
 u32
 acpi_hw_get_mode (void)
 {
+	acpi_status                     status;
+	u32                             value;
 
-	FUNCTION_TRACE ("Hw_get_mode");
 
+	ACPI_FUNCTION_TRACE ("hw_get_mode");
 
-	if (acpi_hw_register_bit_access (ACPI_READ, ACPI_MTX_LOCK, SCI_EN)) {
-		return_VALUE (SYS_MODE_ACPI);
-	}
-	else {
-		return_VALUE (SYS_MODE_LEGACY);
+	status = acpi_get_register (ACPI_BITREG_SCI_ENABLE, &value, ACPI_MTX_LOCK);
+	if (ACPI_FAILURE (status)) {
+		return_VALUE (ACPI_SYS_MODE_LEGACY);
 	}
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    Acpi_hw_get_mode_capabilities
- *
- * PARAMETERS:  none
- *
- * RETURN:      logical OR of SYS_MODE_ACPI and SYS_MODE_LEGACY determined at initial
- *              system state.
- *
- * DESCRIPTION: Returns capablities of system
- *
- ******************************************************************************/
-
-u32
-acpi_hw_get_mode_capabilities (void)
-{
-
-	FUNCTION_TRACE ("Hw_get_mode_capabilities");
-
-
-	if (!(acpi_gbl_system_flags & SYS_MODES_MASK)) {
-		if (acpi_hw_get_mode () == SYS_MODE_LEGACY) {
-			/*
-			 * Assume that if this call is being made, Acpi_init has been called
-			 * and ACPI support has been established by the presence of the
-			 * tables.  Therefore since we're in SYS_MODE_LEGACY, the system
-			 * must support both modes
-			 */
-			acpi_gbl_system_flags |= (SYS_MODE_ACPI | SYS_MODE_LEGACY);
-		}
-
-		else {
-			/* TBD: [Investigate] !!! this may be unsafe... */
-			/*
-			 * system is is ACPI mode, so try to switch back to LEGACY to see if
-			 * it is supported
-			 */
-			acpi_hw_set_mode (SYS_MODE_LEGACY);
-
-			if (acpi_hw_get_mode () == SYS_MODE_LEGACY) {
-				/* Now in SYS_MODE_LEGACY, so both are supported */
-
-				acpi_gbl_system_flags |= (SYS_MODE_ACPI | SYS_MODE_LEGACY);
-				acpi_hw_set_mode (SYS_MODE_ACPI);
-			}
-
-			else {
-				/* Still in SYS_MODE_ACPI so this must be an ACPI only system */
 
-				acpi_gbl_system_flags |= SYS_MODE_ACPI;
-			}
-		}
+	if (value) {
+		return_VALUE (ACPI_SYS_MODE_ACPI);
+	}
+	else {
+		return_VALUE (ACPI_SYS_MODE_LEGACY);
 	}
-
-	return_VALUE (acpi_gbl_system_flags & SYS_MODES_MASK);
 }
-
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/hardware/hwgpe.c linux-2.4.22-pre2/drivers/acpi/hardware/hwgpe.c
--- linux-2.4.21/drivers/acpi/hardware/hwgpe.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/hardware/hwgpe.c	2003-06-26 21:43:10.000000000 +0000
@@ -2,42 +2,58 @@
 /******************************************************************************
  *
  * Module Name: hwgpe - Low level GPE enable/disable/clear functions
- *              $Revision: 35 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
-#include "acpi.h"
-#include "achware.h"
-#include "acnamesp.h"
-#include "acevents.h"
+#include <acpi/acpi.h>
+#include <acpi/acevents.h>
 
 #define _COMPONENT          ACPI_HARDWARE
-	 MODULE_NAME         ("hwgpe")
+	 ACPI_MODULE_NAME    ("hwgpe")
 
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_hw_enable_gpe
+ * FUNCTION:    acpi_hw_enable_gpe
  *
- * PARAMETERS:  Gpe_number      - The GPE
+ * PARAMETERS:  gpe_number      - The GPE
  *
  * RETURN:      None
  *
@@ -45,43 +61,41 @@
  *
  ******************************************************************************/
 
-void
+acpi_status
 acpi_hw_enable_gpe (
-	u32                     gpe_number)
+	struct acpi_gpe_event_info      *gpe_event_info)
 {
-	u32                     in_byte;
-	u32                     register_index;
-	u32                     bit_mask;
-
-
-	FUNCTION_ENTRY ();
+	u32                             in_byte;
+	acpi_status                     status;
 
 
-	/*
-	 * Translate GPE number to index into global registers array.
-	 */
-	register_index = acpi_gbl_gpe_valid[gpe_number];
+	ACPI_FUNCTION_ENTRY ();
 
-	/*
-	 * Figure out the bit offset for this GPE within the target register.
-	 */
-	bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
 
 	/*
 	 * Read the current value of the register, set the appropriate bit
 	 * to enable the GPE, and write out the new register.
 	 */
-	in_byte = 0;
-	acpi_os_read_port (acpi_gbl_gpe_registers[register_index].enable_addr, &in_byte, 8);
-	acpi_os_write_port (acpi_gbl_gpe_registers[register_index].enable_addr,
-			   (in_byte | bit_mask), 8);
+	status = acpi_hw_low_level_read (8, &in_byte,
+			  &gpe_event_info->register_info->enable_address);
+	if (ACPI_FAILURE (status)) {
+		return (status);
+	}
+
+	/* Write with the new GPE bit enabled */
+
+	status = acpi_hw_low_level_write (8, (in_byte | gpe_event_info->bit_mask),
+			  &gpe_event_info->register_info->enable_address);
+
+	return (status);
 }
 
+
 /******************************************************************************
  *
- * FUNCTION:    Acpi_hw_enable_gpe_for_wakeup
+ * FUNCTION:    acpi_hw_enable_gpe_for_wakeup
  *
- * PARAMETERS:  Gpe_number      - The GPE
+ * PARAMETERS:  gpe_number      - The GPE
  *
  * RETURN:      None
  *
@@ -92,36 +106,33 @@
 
 void
 acpi_hw_enable_gpe_for_wakeup (
-	u32                     gpe_number)
+	struct acpi_gpe_event_info      *gpe_event_info)
 {
-	u32                     register_index;
-	u32                     bit_mask;
+	struct acpi_gpe_register_info   *gpe_register_info;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
-	/*
-	 * Translate GPE number to index into global registers array.
-	 */
-	register_index = acpi_gbl_gpe_valid[gpe_number];
+	/* Get the info block for the entire GPE register */
 
-	/*
-	 * Figure out the bit offset for this GPE within the target register.
-	 */
-	bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
+	gpe_register_info = gpe_event_info->register_info;
+	if (!gpe_register_info) {
+		return;
+	}
 
 	/*
 	 * Set the bit so we will not disable this when sleeping
 	 */
-	acpi_gbl_gpe_registers[register_index].wake_enable |= bit_mask;
+	gpe_register_info->wake_enable |= gpe_event_info->bit_mask;
 }
 
+
 /******************************************************************************
  *
- * FUNCTION:    Acpi_hw_disable_gpe
+ * FUNCTION:    acpi_hw_disable_gpe
  *
- * PARAMETERS:  Gpe_number      - The GPE
+ * PARAMETERS:  gpe_number      - The GPE
  *
  * RETURN:      None
  *
@@ -129,45 +140,53 @@
  *
  ******************************************************************************/
 
-void
+acpi_status
 acpi_hw_disable_gpe (
-	u32                     gpe_number)
+	struct acpi_gpe_event_info      *gpe_event_info)
 {
-	u32                     in_byte;
-	u32                     register_index;
-	u32                     bit_mask;
+	u32                             in_byte;
+	acpi_status                     status;
+	struct acpi_gpe_register_info   *gpe_register_info;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
-	/*
-	 * Translate GPE number to index into global registers array.
-	 */
-	register_index = acpi_gbl_gpe_valid[gpe_number];
+	/* Get the info block for the entire GPE register */
 
-	/*
-	 * Figure out the bit offset for this GPE within the target register.
-	 */
-	bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
+	gpe_register_info = gpe_event_info->register_info;
+	if (!gpe_register_info) {
+		return (AE_BAD_PARAMETER);
+	}
 
 	/*
 	 * Read the current value of the register, clear the appropriate bit,
 	 * and write out the new register value to disable the GPE.
 	 */
-	in_byte = 0;
-	acpi_os_read_port (acpi_gbl_gpe_registers[register_index].enable_addr, &in_byte, 8);
-	acpi_os_write_port (acpi_gbl_gpe_registers[register_index].enable_addr,
-			 (in_byte & ~bit_mask), 8);
+	status = acpi_hw_low_level_read (8, &in_byte,
+			  &gpe_register_info->enable_address);
+	if (ACPI_FAILURE (status)) {
+		return (status);
+	}
+
+	/* Write the byte with this GPE bit cleared */
+
+	status = acpi_hw_low_level_write (8, (in_byte & ~(gpe_event_info->bit_mask)),
+			  &gpe_register_info->enable_address);
+	if (ACPI_FAILURE (status)) {
+		return (status);
+	}
 
-	acpi_hw_disable_gpe_for_wakeup(gpe_number);
+	acpi_hw_disable_gpe_for_wakeup (gpe_event_info);
+	return (AE_OK);
 }
 
+
 /******************************************************************************
  *
- * FUNCTION:    Acpi_hw_disable_gpe_for_wakeup
+ * FUNCTION:    acpi_hw_disable_gpe_for_wakeup
  *
- * PARAMETERS:  Gpe_number      - The GPE
+ * PARAMETERS:  gpe_number      - The GPE
  *
  * RETURN:      None
  *
@@ -178,36 +197,33 @@
 
 void
 acpi_hw_disable_gpe_for_wakeup (
-	u32                     gpe_number)
+	struct acpi_gpe_event_info      *gpe_event_info)
 {
-	u32                     register_index;
-	u32                     bit_mask;
+	struct acpi_gpe_register_info   *gpe_register_info;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
-	/*
-	 * Translate GPE number to index into global registers array.
-	 */
-	register_index = acpi_gbl_gpe_valid[gpe_number];
+	/* Get the info block for the entire GPE register */
 
-	/*
-	 * Figure out the bit offset for this GPE within the target register.
-	 */
-	bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
+	gpe_register_info = gpe_event_info->register_info;
+	if (!gpe_register_info) {
+		return;
+	}
 
 	/*
 	 * Clear the bit so we will disable this when sleeping
 	 */
-	acpi_gbl_gpe_registers[register_index].wake_enable &= ~bit_mask;
+	gpe_register_info->wake_enable &= ~(gpe_event_info->bit_mask);
 }
 
+
 /******************************************************************************
  *
- * FUNCTION:    Acpi_hw_clear_gpe
+ * FUNCTION:    acpi_hw_clear_gpe
  *
- * PARAMETERS:  Gpe_number      - The GPE
+ * PARAMETERS:  gpe_number      - The GPE
  *
  * RETURN:      None
  *
@@ -215,40 +231,32 @@
  *
  ******************************************************************************/
 
-void
+acpi_status
 acpi_hw_clear_gpe (
-	u32                     gpe_number)
+	struct acpi_gpe_event_info      *gpe_event_info)
 {
-	u32                     register_index;
-	u32                     bit_mask;
+	acpi_status                     status;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/*
-	 * Translate GPE number to index into global registers array.
-	 */
-	register_index = acpi_gbl_gpe_valid[gpe_number];
-
-	/*
-	 * Figure out the bit offset for this GPE within the target register.
-	 */
-	bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
-
-	/*
 	 * Write a one to the appropriate bit in the status register to
 	 * clear this GPE.
 	 */
-	acpi_os_write_port (acpi_gbl_gpe_registers[register_index].status_addr, bit_mask, 8);
+	status = acpi_hw_low_level_write (8, gpe_event_info->bit_mask,
+			  &gpe_event_info->register_info->status_address);
+
+	return (status);
 }
 
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_hw_get_gpe_status
+ * FUNCTION:    acpi_hw_get_gpe_status
  *
- * PARAMETERS:  Gpe_number      - The GPE
+ * PARAMETERS:  gpe_number      - The GPE
  *
  * RETURN:      None
  *
@@ -256,127 +264,317 @@
  *
  ******************************************************************************/
 
-void
+acpi_status
 acpi_hw_get_gpe_status (
-	u32                     gpe_number,
-	acpi_event_status       *event_status)
+	struct acpi_gpe_event_info      *gpe_event_info,
+	acpi_event_status               *event_status)
 {
-	u32                     in_byte = 0;
-	u32                     register_index = 0;
-	u32                     bit_mask = 0;
+	u32                             in_byte;
+	u8                              bit_mask;
+	struct acpi_gpe_register_info   *gpe_register_info;
+	acpi_status                     status;
+	acpi_event_status               local_event_status = 0;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	if (!event_status) {
-		return;
+		return (AE_BAD_PARAMETER);
 	}
 
-	(*event_status) = 0;
+	/* Get the info block for the entire GPE register */
 
-	/*
-	 * Translate GPE number to index into global registers array.
-	 */
-	register_index = acpi_gbl_gpe_valid[gpe_number];
+	gpe_register_info = gpe_event_info->register_info;
 
-	/*
-	 * Figure out the bit offset for this GPE within the target register.
-	 */
-	bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
+	/* Get the register bitmask for this GPE */
+
+	bit_mask = gpe_event_info->bit_mask;
+
+	/* GPE Enabled? */
+
+	status = acpi_hw_low_level_read (8, &in_byte, &gpe_register_info->enable_address);
+	if (ACPI_FAILURE (status)) {
+		goto unlock_and_exit;
+	}
 
-	/*
-	 * Enabled?:
-	 */
-	in_byte = 0;
-	acpi_os_read_port (acpi_gbl_gpe_registers[register_index].enable_addr, &in_byte, 8);
 	if (bit_mask & in_byte) {
-		(*event_status) |= ACPI_EVENT_FLAG_ENABLED;
+		local_event_status |= ACPI_EVENT_FLAG_ENABLED;
 	}
 
-	/*
-	 * Enabled for wake?:
-	 */
-	if (bit_mask & acpi_gbl_gpe_registers[register_index].wake_enable) {
-		(*event_status) |= ACPI_EVENT_FLAG_WAKE_ENABLED;
+	/* GPE Enabled for wake? */
+
+	if (bit_mask & gpe_register_info->wake_enable) {
+		local_event_status |= ACPI_EVENT_FLAG_WAKE_ENABLED;
+	}
+
+	/* GPE active (set)? */
+
+	status = acpi_hw_low_level_read (8, &in_byte, &gpe_register_info->status_address);
+	if (ACPI_FAILURE (status)) {
+		goto unlock_and_exit;
 	}
 
-	/*
-	 * Set?
-	 */
-	in_byte = 0;
-	acpi_os_read_port (acpi_gbl_gpe_registers[register_index].status_addr, &in_byte, 8);
 	if (bit_mask & in_byte) {
-		(*event_status) |= ACPI_EVENT_FLAG_SET;
+		local_event_status |= ACPI_EVENT_FLAG_SET;
 	}
+
+	/* Set return value */
+
+	(*event_status) = local_event_status;
+
+
+unlock_and_exit:
+	return (status);
 }
 
+
 /******************************************************************************
  *
- * FUNCTION:    Acpi_hw_disable_non_wakeup_gpes
+ * FUNCTION:    acpi_hw_disable_gpe_block
  *
- * PARAMETERS:  None
+ * PARAMETERS:  gpe_xrupt_info      - GPE Interrupt info
+ *              gpe_block           - Gpe Block info
  *
- * RETURN:      None
+ * RETURN:      Status
  *
- * DESCRIPTION: Disable all non-wakeup GPEs
- *              Call with interrupts disabled. The interrupt handler also
- *              modifies Acpi_gbl_Gpe_registers[i].Enable, so it should not be
- *              given the chance to run until after non-wake GPEs are
- *              re-enabled.
+ * DESCRIPTION: Disable all GPEs within a GPE block
  *
  ******************************************************************************/
 
-void
-acpi_hw_disable_non_wakeup_gpes (
-	void)
+acpi_status
+acpi_hw_disable_gpe_block (
+	struct acpi_gpe_xrupt_info      *gpe_xrupt_info,
+	struct acpi_gpe_block_info      *gpe_block)
 {
-	u32                     i;
+	u32                             i;
+	struct acpi_gpe_register_info   *gpe_register_info;
+	acpi_status                     status;
 
-	FUNCTION_ENTRY ();
 
-	for (i = 0; i < acpi_gbl_gpe_register_count; i++) {
+	/* Get the register info for the entire GPE block */
+
+	gpe_register_info = gpe_block->register_info;
+
+	/* Examine each GPE Register within the block */
+
+	for (i = 0; i < gpe_block->register_count; i++) {
+		status = acpi_hw_low_level_write (8, 0x00,
+				 &gpe_block->register_info[i].enable_address);
+		if (ACPI_FAILURE (status)) {
+			return (status);
+		}
+	}
+
+	return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    acpi_hw_clear_gpe_block
+ *
+ * PARAMETERS:  gpe_xrupt_info      - GPE Interrupt info
+ *              gpe_block           - Gpe Block info
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Clear all GPEs within a GPE block
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_hw_clear_gpe_block (
+	struct acpi_gpe_xrupt_info      *gpe_xrupt_info,
+	struct acpi_gpe_block_info      *gpe_block)
+{
+	u32                             i;
+	struct acpi_gpe_register_info   *gpe_register_info;
+	acpi_status                     status;
+
+
+	/* Get the register info for the entire GPE block */
+
+	gpe_register_info = gpe_block->register_info;
+
+	/* Examine each GPE Register within the block */
+
+	for (i = 0; i < gpe_block->register_count; i++) {
+		status = acpi_hw_low_level_write (8, 0xFF,
+				 &gpe_block->register_info[i].status_address);
+		if (ACPI_FAILURE (status)) {
+			return (status);
+		}
+	}
+
+	return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    acpi_hw_disable_non_wakeup_gpe_block
+ *
+ * PARAMETERS:  gpe_xrupt_info      - GPE Interrupt info
+ *              gpe_block           - Gpe Block info
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Disable all GPEs except wakeup GPEs in a GPE block
+ *
+ ******************************************************************************/
+
+static acpi_status
+acpi_hw_disable_non_wakeup_gpe_block (
+	struct acpi_gpe_xrupt_info      *gpe_xrupt_info,
+	struct acpi_gpe_block_info      *gpe_block)
+{
+	u32                             i;
+	struct acpi_gpe_register_info   *gpe_register_info;
+	u32                             in_value;
+	acpi_status                     status;
+
+
+	/* Get the register info for the entire GPE block */
+
+	gpe_register_info = gpe_block->register_info;
+
+	/* Examine each GPE Register within the block */
+
+	for (i = 0; i < gpe_block->register_count; i++) {
 		/*
 		 * Read the enabled status of all GPEs. We
 		 * will be using it to restore all the GPEs later.
 		 */
-		acpi_os_read_port (acpi_gbl_gpe_registers[i].enable_addr,
-				&acpi_gbl_gpe_registers[i].enable, 8);
+		status = acpi_hw_low_level_read (8, &in_value,
+				 &gpe_register_info->enable_address);
+		if (ACPI_FAILURE (status)) {
+			return (status);
+		}
+
+		gpe_register_info->enable = (u8) in_value;
 
 		/*
-		 * Disable all GPEs but wakeup GPEs.
+		 * Disable all GPEs except wakeup GPEs.
 		 */
-		acpi_os_write_port(acpi_gbl_gpe_registers[i].enable_addr,
-				acpi_gbl_gpe_registers[i].wake_enable, 8);
+		status = acpi_hw_low_level_write (8, gpe_register_info->wake_enable,
+				&gpe_register_info->enable_address);
+		if (ACPI_FAILURE (status)) {
+			return (status);
+		}
+
+		gpe_register_info++;
 	}
+
+	return (AE_OK);
 }
 
+
 /******************************************************************************
  *
- * FUNCTION:    Acpi_hw_enable_non_wakeup_gpes
+ * FUNCTION:    acpi_hw_disable_non_wakeup_gpes
  *
  * PARAMETERS:  None
  *
  * RETURN:      None
  *
- * DESCRIPTION: Enable all non-wakeup GPEs we previously enabled.
+ * DESCRIPTION: Disable all non-wakeup GPEs
+ *              Called with interrupts disabled. The interrupt handler also
+ *              modifies gpe_register_info->Enable, so it should not be
+ *              given the chance to run until after non-wake GPEs are
+ *              re-enabled.
  *
  ******************************************************************************/
 
-void
-acpi_hw_enable_non_wakeup_gpes (
+acpi_status
+acpi_hw_disable_non_wakeup_gpes (
 	void)
 {
-	u32                     i;
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_ENTRY ();
+
+
+	status = acpi_ev_walk_gpe_list (acpi_hw_disable_non_wakeup_gpe_block);
+
+	return (status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    acpi_hw_enable_non_wakeup_gpe_block
+ *
+ * PARAMETERS:  gpe_xrupt_info      - GPE Interrupt info
+ *              gpe_block           - Gpe Block info
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Enable a single GPE.
+ *
+ ******************************************************************************/
+
+static acpi_status
+acpi_hw_enable_non_wakeup_gpe_block (
+	struct acpi_gpe_xrupt_info      *gpe_xrupt_info,
+	struct acpi_gpe_block_info      *gpe_block)
+{
+	u32                             i;
+	struct acpi_gpe_register_info   *gpe_register_info;
+	acpi_status                     status;
+
+
+	/* This callback processes one entire GPE block */
 
-	FUNCTION_ENTRY ();
+	/* Get the register info for the entire GPE block */
 
-	for (i = 0; i < acpi_gbl_gpe_register_count; i++) {
+	gpe_register_info = gpe_block->register_info;
+
+	/* Examine each GPE register within the block */
+
+	for (i = 0; i < gpe_block->register_count; i++) {
 		/*
 		 * We previously stored the enabled status of all GPEs.
 		 * Blast them back in.
 		 */
-		acpi_os_write_port(acpi_gbl_gpe_registers[i].enable_addr,
-				acpi_gbl_gpe_registers[i].enable, 8);
+		status = acpi_hw_low_level_write (8, gpe_register_info->enable,
+				 &gpe_register_info->enable_address);
+		if (ACPI_FAILURE (status)) {
+			return (status);
+		}
+
+		gpe_register_info++;
 	}
+
+
+	return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    acpi_hw_enable_non_wakeup_gpes
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Enable all non-wakeup GPEs we previously enabled.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_hw_enable_non_wakeup_gpes (
+	void)
+{
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_ENTRY ();
+
+
+	status = acpi_ev_walk_gpe_list (acpi_hw_enable_non_wakeup_gpe_block);
+
+	return (status);
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/hardware/hwregs.c linux-2.4.22-pre2/drivers/acpi/hardware/hwregs.c
--- linux-2.4.21/drivers/acpi/hardware/hwregs.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/hardware/hwregs.c	2003-06-26 21:43:31.000000000 +0000
@@ -3,71 +3,60 @@
  *
  * Module Name: hwregs - Read/write access functions for the various ACPI
  *                       control and status registers.
- *              $Revision: 110 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "achware.h"
-#include "acnamesp.h"
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acevents.h>
 
 #define _COMPONENT          ACPI_HARDWARE
-	 MODULE_NAME         ("hwregs")
+	 ACPI_MODULE_NAME    ("hwregs")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_hw_get_bit_shift
+ * FUNCTION:    acpi_hw_clear_acpi_status
  *
- * PARAMETERS:  Mask            - Input mask to determine bit shift from.
- *                                Must have at least 1 bit set.
- *
- * RETURN:      Bit location of the lsb of the mask
- *
- * DESCRIPTION: Returns the bit number for the low order bit that's set.
- *
- ******************************************************************************/
-
-u32
-acpi_hw_get_bit_shift (
-	u32                     mask)
-{
-	u32                     shift;
-
-
-	FUNCTION_TRACE ("Hw_get_bit_shift");
-
-
-	for (shift = 0; ((mask >> shift) & 1) == 0; shift++) { ; }
-
-	return_VALUE (shift);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_hw_clear_acpi_status
- *
- * PARAMETERS:  none
+ * PARAMETERS:  Flags           - Lock the hardware or not
  *
  * RETURN:      none
  *
@@ -75,506 +64,403 @@
  *
  ******************************************************************************/
 
-void
-acpi_hw_clear_acpi_status (void)
+acpi_status
+acpi_hw_clear_acpi_status (
+	u32                             flags)
 {
-	u16                     gpe_length;
-	u16                     index;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Hw_clear_acpi_status");
+	ACPI_FUNCTION_TRACE ("hw_clear_acpi_status");
 
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %04X\n",
-		ALL_FIXED_STS_BITS,
-		(u16) ACPI_GET_ADDRESS (acpi_gbl_FADT->Xpm1a_evt_blk.address)));
-
+		ACPI_BITMASK_ALL_FIXED_STATUS,
+		(u16) acpi_gbl_FADT->xpm1a_evt_blk.address));
 
-	acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE);
-
-	acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, PM1_STS, ALL_FIXED_STS_BITS);
-
-
-	if (ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xpm1b_evt_blk.address)) {
-		acpi_os_write_port ((ACPI_IO_ADDRESS)
-			ACPI_GET_ADDRESS (acpi_gbl_FADT->Xpm1b_evt_blk.address),
-			ALL_FIXED_STS_BITS, 16);
+	if (flags & ACPI_MTX_LOCK) {
+		status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
+		}
 	}
 
-	/* now clear the GPE Bits */
+	status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS,
+			  ACPI_BITMASK_ALL_FIXED_STATUS);
+	if (ACPI_FAILURE (status)) {
+		goto unlock_and_exit;
+	}
 
-	if (acpi_gbl_FADT->gpe0blk_len) {
-		gpe_length = (u16) DIV_2 (acpi_gbl_FADT->gpe0blk_len);
+	/* Clear the fixed events */
 
-		for (index = 0; index < gpe_length; index++) {
-			acpi_os_write_port ((ACPI_IO_ADDRESS) (
-				ACPI_GET_ADDRESS (acpi_gbl_FADT->Xgpe0blk.address) + index),
-					0xFF, 8);
+	if (acpi_gbl_FADT->xpm1b_evt_blk.address) {
+		status = acpi_hw_low_level_write (16, ACPI_BITMASK_ALL_FIXED_STATUS,
+				 &acpi_gbl_FADT->xpm1b_evt_blk);
+		if (ACPI_FAILURE (status)) {
+			goto unlock_and_exit;
 		}
 	}
 
-	if (acpi_gbl_FADT->gpe1_blk_len) {
-		gpe_length = (u16) DIV_2 (acpi_gbl_FADT->gpe1_blk_len);
+	/* Clear the GPE Bits in all GPE registers in all GPE blocks */
 
-		for (index = 0; index < gpe_length; index++) {
-			acpi_os_write_port ((ACPI_IO_ADDRESS) (
-				ACPI_GET_ADDRESS (acpi_gbl_FADT->Xgpe1_blk.address) + index),
-				0xFF, 8);
-		}
-	}
+	status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block);
 
-	acpi_ut_release_mutex (ACPI_MTX_HARDWARE);
-	return_VOID;
+unlock_and_exit:
+	if (flags & ACPI_MTX_LOCK) {
+		(void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE);
+	}
+	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_hw_obtain_sleep_type_register_data
+ * FUNCTION:    acpi_get_sleep_type_data
  *
- * PARAMETERS:  Sleep_state       - Numeric state requested
- *              *Slp_Typ_a         - Pointer to byte to receive SLP_TYPa value
- *              *Slp_Typ_b         - Pointer to byte to receive SLP_TYPb value
+ * PARAMETERS:  sleep_state         - Numeric sleep state
+ *              *sleep_type_a        - Where SLP_TYPa is returned
+ *              *sleep_type_b        - Where SLP_TYPb is returned
  *
  * RETURN:      Status - ACPI status
  *
- * DESCRIPTION: Acpi_hw_obtain_sleep_type_register_data() obtains the SLP_TYP and
- *              SLP_TYPb values for the sleep state requested.
+ * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep
+ *              state.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_hw_obtain_sleep_type_register_data (
-	u8                      sleep_state,
-	u8                      *slp_typ_a,
-	u8                      *slp_typ_b)
+acpi_get_sleep_type_data (
+	u8                              sleep_state,
+	u8                              *sleep_type_a,
+	u8                              *sleep_type_b)
 {
-	acpi_status             status = AE_OK;
-	acpi_operand_object     *obj_desc;
+	acpi_status                     status = AE_OK;
+	union acpi_operand_object       *obj_desc;
 
 
-	FUNCTION_TRACE ("Hw_obtain_sleep_type_register_data");
+	ACPI_FUNCTION_TRACE ("acpi_get_sleep_type_data");
 
 
 	/*
-	 *  Validate parameters
+	 * Validate parameters
 	 */
 	if ((sleep_state > ACPI_S_STATES_MAX) ||
-		!slp_typ_a || !slp_typ_b) {
+		!sleep_type_a || !sleep_type_b) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
 	/*
-	 *  Acpi_evaluate the namespace object containing the values for this state
+	 * Evaluate the namespace object containing the values for this state
 	 */
-	status = acpi_ns_evaluate_by_name ((NATIVE_CHAR *) acpi_gbl_db_sleep_states[sleep_state],
+	status = acpi_ns_evaluate_by_name ((char *) acpi_gbl_db_sleep_states[sleep_state],
 			  NULL, &obj_desc);
 	if (ACPI_FAILURE (status)) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s while evaluating sleep_state [%s]\n",
+			acpi_format_exception (status), acpi_gbl_db_sleep_states[sleep_state]));
+
 		return_ACPI_STATUS (status);
 	}
 
+	/* Must have a return object */
+
 	if (!obj_desc) {
-		REPORT_ERROR (("Missing Sleep State object\n"));
-		return_ACPI_STATUS (AE_NOT_EXIST);
+		ACPI_REPORT_ERROR (("Missing Sleep State object\n"));
+		status = AE_NOT_EXIST;
 	}
 
-	/*
-	 *  We got something, now ensure it is correct.  The object must
-	 *  be a package and must have at least 2 numeric values as the
-	 *  two elements
-	 */
+	/* It must be of type Package */
 
-	/* Even though Acpi_evaluate_object resolves package references,
-	 * Ns_evaluate dpesn't. So, we do it here.
-	 */
-	status = acpi_ut_resolve_package_references(obj_desc);
+	else if (ACPI_GET_OBJECT_TYPE (obj_desc) != ACPI_TYPE_PACKAGE) {
+		ACPI_REPORT_ERROR (("Sleep State object not a Package\n"));
+		status = AE_AML_OPERAND_TYPE;
+	}
 
-	if (obj_desc->package.count < 2) {
-		/* Must have at least two elements */
+	/* The package must have at least two elements */
 
-		REPORT_ERROR (("Sleep State package does not have at least two elements\n"));
-		status = AE_ERROR;
+	else if (obj_desc->package.count < 2) {
+		ACPI_REPORT_ERROR (("Sleep State package does not have at least two elements\n"));
+		status = AE_AML_NO_OPERAND;
 	}
 
-	else if (((obj_desc->package.elements[0])->common.type !=
-			 ACPI_TYPE_INTEGER) ||
-			 ((obj_desc->package.elements[1])->common.type !=
-				ACPI_TYPE_INTEGER)) {
-		/* Must have two  */
+	/* The first two elements must both be of type Integer */
 
-		REPORT_ERROR (("Sleep State package elements are not both of type Number\n"));
-		status = AE_ERROR;
+	else if ((ACPI_GET_OBJECT_TYPE (obj_desc->package.elements[0]) != ACPI_TYPE_INTEGER) ||
+			 (ACPI_GET_OBJECT_TYPE (obj_desc->package.elements[1]) != ACPI_TYPE_INTEGER)) {
+		ACPI_REPORT_ERROR (("Sleep State package elements are not both Integers (%s, %s)\n",
+			acpi_ut_get_object_type_name (obj_desc->package.elements[0]),
+			acpi_ut_get_object_type_name (obj_desc->package.elements[1])));
+		status = AE_AML_OPERAND_TYPE;
 	}
-
 	else {
 		/*
-		 *  Valid _Sx_ package size, type, and value
+		 * Valid _Sx_ package size, type, and value
 		 */
-		*slp_typ_a = (u8) (obj_desc->package.elements[0])->integer.value;
-
-		*slp_typ_b = (u8) (obj_desc->package.elements[1])->integer.value;
+		*sleep_type_a = (u8) (obj_desc->package.elements[0])->integer.value;
+		*sleep_type_b = (u8) (obj_desc->package.elements[1])->integer.value;
 	}
 
-
 	if (ACPI_FAILURE (status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad Sleep object %p type %X\n",
-			obj_desc, obj_desc->common.type));
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "While evaluating sleep_state [%s], bad Sleep object %p type %s\n",
+			acpi_gbl_db_sleep_states[sleep_state], obj_desc, acpi_ut_get_object_type_name (obj_desc)));
 	}
 
 	acpi_ut_remove_reference (obj_desc);
-
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_hw_register_bit_access
+ * FUNCTION:    acpi_hw_get_register_bit_mask
  *
- * PARAMETERS:  Read_write      - Either ACPI_READ or ACPI_WRITE.
- *              Use_lock        - Lock the hardware
- *              Register_id     - index of ACPI Register to access
- *              Value           - (only used on write) value to write to the
- *                                Register.  Shifted all the way right.
+ * PARAMETERS:  register_id         - Index of ACPI Register to access
  *
- * RETURN:      Value written to or read from specified Register.  This value
- *              is shifted all the way right.
+ * RETURN:      The bit mask to be used when accessing the register
  *
- * DESCRIPTION: Generic ACPI Register read/write function.
+ * DESCRIPTION: Map register_id into a register bit mask.
  *
  ******************************************************************************/
 
-u32
-acpi_hw_register_bit_access (
-	NATIVE_UINT             read_write,
-	u8                      use_lock,
-	u32                     register_id,
-	...)                    /* Value (only used on write) */
+struct acpi_bit_register_info *
+acpi_hw_get_bit_register_info (
+	u32                             register_id)
 {
-	u32                     register_value = 0;
-	u32                     mask = 0;
-	u32                     value = 0;
-	va_list                 marker;
-
+	ACPI_FUNCTION_NAME ("hw_get_bit_register_info");
 
-	FUNCTION_TRACE ("Hw_register_bit_access");
 
-
-	if (read_write == ACPI_WRITE) {
-		va_start (marker, register_id);
-		value = va_arg (marker, u32);
-		va_end (marker);
+	if (register_id > ACPI_BITREG_MAX) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid bit_register ID: %X\n", register_id));
+		return (NULL);
 	}
 
-	if (ACPI_MTX_LOCK == use_lock) {
-		acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE);
-	}
+	return (&acpi_gbl_bit_register_info[register_id]);
+}
 
-	/*
-	 * Decode the Register ID
-	 * Register id = Register block id | bit id
-	 *
-	 * Check bit id to fine locate Register offset.
-	 * Check Mask to determine Register offset, and then read-write.
-	 */
-	switch (REGISTER_BLOCK_ID (register_id)) {
-	case PM1_STS:
 
-		switch (register_id) {
-		case TMR_STS:
-			mask = TMR_STS_MASK;
-			break;
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_get_register
+ *
+ * PARAMETERS:  register_id     - ID of ACPI bit_register to access
+ *              return_value    - Value that was read from the register
+ *              Flags           - Lock the hardware or not
+ *
+ * RETURN:      Value is read from specified Register.  Value returned is
+ *              normalized to bit0 (is shifted all the way right)
+ *
+ * DESCRIPTION: ACPI bit_register read function.
+ *
+ ******************************************************************************/
 
-		case BM_STS:
-			mask = BM_STS_MASK;
-			break;
+acpi_status
+acpi_get_register (
+	u32                             register_id,
+	u32                             *return_value,
+	u32                             flags)
+{
+	u32                             register_value = 0;
+	struct acpi_bit_register_info   *bit_reg_info;
+	acpi_status                     status;
 
-		case GBL_STS:
-			mask = GBL_STS_MASK;
-			break;
 
-		case PWRBTN_STS:
-			mask = PWRBTN_STS_MASK;
-			break;
+	ACPI_FUNCTION_TRACE ("acpi_get_register");
 
-		case SLPBTN_STS:
-			mask = SLPBTN_STS_MASK;
-			break;
 
-		case RTC_STS:
-			mask = RTC_STS_MASK;
-			break;
+	/* Get the info structure corresponding to the requested ACPI Register */
 
-		case WAK_STS:
-			mask = WAK_STS_MASK;
-			break;
+	bit_reg_info = acpi_hw_get_bit_register_info (register_id);
+	if (!bit_reg_info) {
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	}
 
-		default:
-			mask = 0;
-			break;
+	if (flags & ACPI_MTX_LOCK) {
+		status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
 		}
+	}
 
-		register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, PM1_STS);
+	status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK,
+			  bit_reg_info->parent_register, &register_value);
 
-		if (read_write == ACPI_WRITE) {
-			/*
-			 * Status Registers are different from the rest.  Clear by
-			 * writing 1, writing 0 has no effect.  So, the only relevent
-			 * information is the single bit we're interested in, all
-			 * others should be written as 0 so they will be left
-			 * unchanged
-			 */
-			value <<= acpi_hw_get_bit_shift (mask);
-			value &= mask;
+	if (flags & ACPI_MTX_LOCK) {
+		(void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE);
+	}
 
-			if (value) {
-				acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, PM1_STS,
-					(u16) value);
-				register_value = 0;
-			}
-		}
+	if (ACPI_SUCCESS (status)) {
+		/* Normalize the value that was read */
 
-		break;
+		register_value = ((register_value & bit_reg_info->access_bit_mask)
+				   >> bit_reg_info->bit_position);
 
+		*return_value = register_value;
 
-	case PM1_EN:
+		ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read value %8.8X register %X\n",
+				register_value, bit_reg_info->parent_register));
+	}
 
-		switch (register_id) {
-		case TMR_EN:
-			mask = TMR_EN_MASK;
-			break;
+	return_ACPI_STATUS (status);
+}
 
-		case GBL_EN:
-			mask = GBL_EN_MASK;
-			break;
 
-		case PWRBTN_EN:
-			mask = PWRBTN_EN_MASK;
-			break;
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_set_register
+ *
+ * PARAMETERS:  register_id     - ID of ACPI bit_register to access
+ *              Value           - (only used on write) value to write to the
+ *                                Register, NOT pre-normalized to the bit pos.
+ *              Flags           - Lock the hardware or not
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: ACPI Bit Register write function.
+ *
+ ******************************************************************************/
 
-		case SLPBTN_EN:
-			mask = SLPBTN_EN_MASK;
-			break;
+acpi_status
+acpi_set_register (
+	u32                             register_id,
+	u32                             value,
+	u32                             flags)
+{
+	u32                             register_value = 0;
+	struct acpi_bit_register_info   *bit_reg_info;
+	acpi_status                     status;
 
-		case RTC_EN:
-			mask = RTC_EN_MASK;
-			break;
 
-		default:
-			mask = 0;
-			break;
-		}
+	ACPI_FUNCTION_TRACE_U32 ("acpi_set_register", register_id);
 
-		register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, PM1_EN);
 
-		if (read_write == ACPI_WRITE) {
-			register_value &= ~mask;
-			value          <<= acpi_hw_get_bit_shift (mask);
-			value          &= mask;
-			register_value |= value;
+	/* Get the info structure corresponding to the requested ACPI Register */
 
-			acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, PM1_EN, (u16) register_value);
+	bit_reg_info = acpi_hw_get_bit_register_info (register_id);
+	if (!bit_reg_info) {
+		ACPI_REPORT_ERROR (("Bad ACPI HW register_id: %X\n", register_id));
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	}
+
+	if (flags & ACPI_MTX_LOCK) {
+		status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
 		}
+	}
 
-		break;
+	/* Always do a register read first so we can insert the new bits  */
 
+	status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK,
+			  bit_reg_info->parent_register, &register_value);
+	if (ACPI_FAILURE (status)) {
+		goto unlock_and_exit;
+	}
 
-	case PM1_CONTROL:
+	/*
+	 * Decode the Register ID
+	 * Register id = Register block id | bit id
+	 *
+	 * Check bit id to fine locate Register offset.
+	 * Check Mask to determine Register offset, and then read-write.
+	 */
+	switch (bit_reg_info->parent_register) {
+	case ACPI_REGISTER_PM1_STATUS:
 
-		switch (register_id) {
-		case SCI_EN:
-			mask = SCI_EN_MASK;
-			break;
+		/*
+		 * Status Registers are different from the rest.  Clear by
+		 * writing 1, writing 0 has no effect.  So, the only relevant
+		 * information is the single bit we're interested in, all others should
+		 * be written as 0 so they will be left unchanged
+		 */
+		value = ACPI_REGISTER_PREPARE_BITS (value,
+				 bit_reg_info->bit_position, bit_reg_info->access_bit_mask);
+		if (value) {
+			status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
+					 ACPI_REGISTER_PM1_STATUS, (u16) value);
+			register_value = 0;
+		}
+		break;
 
-		case BM_RLD:
-			mask = BM_RLD_MASK;
-			break;
 
-		case GBL_RLS:
-			mask = GBL_RLS_MASK;
-			break;
+	case ACPI_REGISTER_PM1_ENABLE:
 
-		case SLP_TYPE_A:
-		case SLP_TYPE_B:
-			mask = SLP_TYPE_X_MASK;
-			break;
+		ACPI_REGISTER_INSERT_VALUE (register_value, bit_reg_info->bit_position,
+				bit_reg_info->access_bit_mask, value);
 
-		case SLP_EN:
-			mask = SLP_EN_MASK;
-			break;
+		status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
+				  ACPI_REGISTER_PM1_ENABLE, (u16) register_value);
+		break;
 
-		default:
-			mask = 0;
-			break;
-		}
 
+	case ACPI_REGISTER_PM1_CONTROL:
 
 		/*
 		 * Read the PM1 Control register.
 		 * Note that at this level, the fact that there are actually TWO
-		 * registers (A and B) and that B may not exist, are abstracted.
+		 * registers (A and B - and that B may not exist) is abstracted.
 		 */
-		register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, PM1_CONTROL);
-
 		ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM1 control: Read %X\n", register_value));
 
-		if (read_write == ACPI_WRITE) {
-			register_value &= ~mask;
-			value          <<= acpi_hw_get_bit_shift (mask);
-			value          &= mask;
-			register_value |= value;
+		ACPI_REGISTER_INSERT_VALUE (register_value, bit_reg_info->bit_position,
+				bit_reg_info->access_bit_mask, value);
 
-			/*
-			 * SLP_TYPE_x Registers are written differently
-			 * than any other control Registers with
-			 * respect to A and B Registers.  The value
-			 * for A may be different than the value for B
-			 *
-			 * Therefore, pass the Register_id, not just generic PM1_CONTROL,
-			 * because we need to do different things. Yuck.
-			 */
-			acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, register_id,
-					(u16) register_value);
-		}
+		status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, register_id,
+				(u16) register_value);
 		break;
 
 
-	case PM2_CONTROL:
+	case ACPI_REGISTER_PM2_CONTROL:
 
-		switch (register_id) {
-		case ARB_DIS:
-			mask = ARB_DIS_MASK;
-			break;
-
-		default:
-			mask = 0;
-			break;
+		status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK,
+				 ACPI_REGISTER_PM2_CONTROL, &register_value);
+		if (ACPI_FAILURE (status)) {
+			goto unlock_and_exit;
 		}
 
-		register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, PM2_CONTROL);
-
 		ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM2 control: Read %X from %8.8X%8.8X\n",
-			register_value, HIDWORD(acpi_gbl_FADT->Xpm2_cnt_blk.address),
-			LODWORD(acpi_gbl_FADT->Xpm2_cnt_blk.address)));
-
-		if (read_write == ACPI_WRITE) {
-			register_value &= ~mask;
-			value          <<= acpi_hw_get_bit_shift (mask);
-			value          &= mask;
-			register_value |= value;
-
-			ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %8.8X%8.8X\n",
-				register_value,
-				HIDWORD(acpi_gbl_FADT->Xpm2_cnt_blk.address),
-				LODWORD(acpi_gbl_FADT->Xpm2_cnt_blk.address)));
-
-			acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
-					   PM2_CONTROL, (u8) (register_value));
-		}
-		break;
-
-
-	case PM_TIMER:
-
-		mask = TMR_VAL_MASK;
-		register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK,
-				 PM_TIMER);
-		ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM_TIMER: Read %X from %8.8X%8.8X\n",
 			register_value,
-			HIDWORD(acpi_gbl_FADT->Xpm_tmr_blk.address),
-			LODWORD(acpi_gbl_FADT->Xpm_tmr_blk.address)));
-
-		break;
-
-
-	case GPE1_EN_BLOCK:
-	case GPE1_STS_BLOCK:
-	case GPE0_EN_BLOCK:
-	case GPE0_STS_BLOCK:
-
-		/* Determine the bit to be accessed
-		 *
-		 *  (u32) Register_id:
-		 *      31      24       16       8        0
-		 *      +--------+--------+--------+--------+
-		 *      |  gpe_block_id   |  gpe_bit_number |
-		 *      +--------+--------+--------+--------+
-		 *
-		 *     gpe_block_id is one of GPE[01]_EN_BLOCK and GPE[01]_STS_BLOCK
-		 *     gpe_bit_number is relative from the gpe_block (0x00~0xFF)
-		 */
-		mask = REGISTER_BIT_ID(register_id); /* gpe_bit_number */
-		register_id = REGISTER_BLOCK_ID(register_id) | (mask >> 3);
-		mask = acpi_gbl_decode_to8bit [mask % 8];
-
-		/*
-		 * The base address of the GPE 0 Register Block
-		 * Plus 1/2 the length of the GPE 0 Register Block
-		 * The enable Register is the Register following the Status Register
-		 * and each Register is defined as 1/2 of the total Register Block
-		 */
-
-		/*
-		 * This sets the bit within Enable_bit that needs to be written to
-		 * the Register indicated in Mask to a 1, all others are 0
-		 */
+			ACPI_HIDWORD (acpi_gbl_FADT->xpm2_cnt_blk.address),
+			ACPI_LODWORD (acpi_gbl_FADT->xpm2_cnt_blk.address)));
 
-		/* Now get the current Enable Bits in the selected Reg */
+		ACPI_REGISTER_INSERT_VALUE (register_value, bit_reg_info->bit_position,
+				bit_reg_info->access_bit_mask, value);
 
-		register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, register_id);
-		ACPI_DEBUG_PRINT ((ACPI_DB_IO, "GPE Enable bits: Read %X from %X\n",
-			register_value, register_id));
-
-		if (read_write == ACPI_WRITE) {
-			register_value &= ~mask;
-			value          <<= acpi_hw_get_bit_shift (mask);
-			value          &= mask;
-			register_value |= value;
+		ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %4.4X to %8.8X%8.8X\n",
+			register_value,
+			ACPI_HIDWORD (acpi_gbl_FADT->xpm2_cnt_blk.address),
+			ACPI_LODWORD (acpi_gbl_FADT->xpm2_cnt_blk.address)));
 
-			/*
-			 * This write will put the Action state into the General Purpose
-			 * Enable Register indexed by the value in Mask
-			 */
-			ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %04X\n",
-				register_value, register_id));
-			acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, register_id,
-				(u8) register_value);
-			register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK,
-					   register_id);
-		}
+		status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
+				   ACPI_REGISTER_PM2_CONTROL, (u8) (register_value));
 		break;
 
 
-	case SMI_CMD_BLOCK:
-	case PROCESSOR_BLOCK:
-
-		/* Not used by any callers at this time - therefore, not implemented */
-
 	default:
-
-		mask = 0;
 		break;
 	}
 
-	if (ACPI_MTX_LOCK == use_lock) {
-		acpi_ut_release_mutex (ACPI_MTX_HARDWARE);
+
+unlock_and_exit:
+
+	if (flags & ACPI_MTX_LOCK) {
+		(void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE);
 	}
 
+	/* Normalize the value that was read */
 
-	register_value &= mask;
-	register_value >>= acpi_hw_get_bit_shift (mask);
+	ACPI_DEBUG_EXEC (register_value = ((register_value & bit_reg_info->access_bit_mask) >> bit_reg_info->bit_position));
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Register I/O: returning %X\n", register_value));
-	return_VALUE (register_value);
+	ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Set bits: %8.8X actual %8.8X register %X\n",
+			value, register_value, bit_reg_info->parent_register));
+	return_ACPI_STATUS (status);
 }
 
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_hw_register_read
+ * FUNCTION:    acpi_hw_register_read
  *
- * PARAMETERS:  Use_lock               - Mutex hw access.
- *              Register_id            - Register_iD + Offset.
+ * PARAMETERS:  use_lock               - Mutex hw access.
+ *              register_id            - register_iD + Offset.
  *
  * RETURN:      Value read or written.
  *
@@ -583,112 +469,109 @@
  *
  ******************************************************************************/
 
-u32
+acpi_status
 acpi_hw_register_read (
-	u8                      use_lock,
-	u32                     register_id)
+	u8                              use_lock,
+	u32                             register_id,
+	u32                             *return_value)
 {
-	u32                     value = 0;
-	u32                     bank_offset;
+	u32                             value1 = 0;
+	u32                             value2 = 0;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Hw_register_read");
+	ACPI_FUNCTION_TRACE ("hw_register_read");
 
 
 	if (ACPI_MTX_LOCK == use_lock) {
-		acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE);
+		status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
+		}
 	}
 
+	switch (register_id) {
+	case ACPI_REGISTER_PM1_STATUS:           /* 16-bit access */
 
-	switch (REGISTER_BLOCK_ID(register_id)) {
-	case PM1_STS: /* 16-bit access */
-
-		value =  acpi_hw_low_level_read (16, &acpi_gbl_FADT->Xpm1a_evt_blk, 0);
-		value |= acpi_hw_low_level_read (16, &acpi_gbl_FADT->Xpm1b_evt_blk, 0);
-		break;
-
+		status = acpi_hw_low_level_read (16, &value1, &acpi_gbl_FADT->xpm1a_evt_blk);
+		if (ACPI_FAILURE (status)) {
+			goto unlock_and_exit;
+		}
 
-	case PM1_EN: /* 16-bit access*/
+		/* PM1B is optional */
 
-		bank_offset = DIV_2 (acpi_gbl_FADT->pm1_evt_len);
-		value =  acpi_hw_low_level_read (16, &acpi_gbl_FADT->Xpm1a_evt_blk, bank_offset);
-		value |= acpi_hw_low_level_read (16, &acpi_gbl_FADT->Xpm1b_evt_blk, bank_offset);
+		status = acpi_hw_low_level_read (16, &value2, &acpi_gbl_FADT->xpm1b_evt_blk);
+		value1 |= value2;
 		break;
 
 
-	case PM1_CONTROL: /* 16-bit access */
-
-		value =  acpi_hw_low_level_read (16, &acpi_gbl_FADT->Xpm1a_cnt_blk, 0);
-		value |= acpi_hw_low_level_read (16, &acpi_gbl_FADT->Xpm1b_cnt_blk, 0);
-		break;
+	case ACPI_REGISTER_PM1_ENABLE:           /* 16-bit access */
 
+		status = acpi_hw_low_level_read (16, &value1, &acpi_gbl_xpm1a_enable);
+		if (ACPI_FAILURE (status)) {
+			goto unlock_and_exit;
+		}
 
-	case PM2_CONTROL: /* 8-bit access */
+		/* PM1B is optional */
 
-		value =  acpi_hw_low_level_read (8, &acpi_gbl_FADT->Xpm2_cnt_blk, 0);
+		status = acpi_hw_low_level_read (16, &value2, &acpi_gbl_xpm1b_enable);
+		value1 |= value2;
 		break;
 
 
-	case PM_TIMER: /* 32-bit access */
-
-		value =  acpi_hw_low_level_read (32, &acpi_gbl_FADT->Xpm_tmr_blk, 0);
-		break;
-
+	case ACPI_REGISTER_PM1_CONTROL:          /* 16-bit access */
 
-	/*
-	 * For the GPE? Blocks, the lower word of Register_id contains the
-	 * byte offset for which to read, as each part of each block may be
-	 * several bytes long.
-	 */
-	case GPE0_STS_BLOCK: /* 8-bit access */
+		status = acpi_hw_low_level_read (16, &value1, &acpi_gbl_FADT->xpm1a_cnt_blk);
+		if (ACPI_FAILURE (status)) {
+			goto unlock_and_exit;
+		}
 
-		bank_offset = REGISTER_BIT_ID(register_id);
-		value = acpi_hw_low_level_read (8, &acpi_gbl_FADT->Xgpe0blk, bank_offset);
+		status = acpi_hw_low_level_read (16, &value2, &acpi_gbl_FADT->xpm1b_cnt_blk);
+		value1 |= value2;
 		break;
 
-	case GPE0_EN_BLOCK: /* 8-bit access */
-
-		bank_offset = DIV_2 (acpi_gbl_FADT->gpe0blk_len) + REGISTER_BIT_ID(register_id);
-		value = acpi_hw_low_level_read (8, &acpi_gbl_FADT->Xgpe0blk, bank_offset);
-		break;
 
-	case GPE1_STS_BLOCK: /* 8-bit access */
+	case ACPI_REGISTER_PM2_CONTROL:          /* 8-bit access */
 
-		bank_offset = REGISTER_BIT_ID(register_id);
-		value = acpi_hw_low_level_read (8, &acpi_gbl_FADT->Xgpe1_blk, bank_offset);
+		status = acpi_hw_low_level_read (8, &value1, &acpi_gbl_FADT->xpm2_cnt_blk);
 		break;
 
-	case GPE1_EN_BLOCK: /* 8-bit access */
 
-		bank_offset = DIV_2 (acpi_gbl_FADT->gpe1_blk_len) + REGISTER_BIT_ID(register_id);
-		value = acpi_hw_low_level_read (8, &acpi_gbl_FADT->Xgpe1_blk, bank_offset);
+	case ACPI_REGISTER_PM_TIMER:             /* 32-bit access */
+
+		status = acpi_hw_low_level_read (32, &value1, &acpi_gbl_FADT->xpm_tmr_blk);
 		break;
 
-	case SMI_CMD_BLOCK: /* 8bit */
+	case ACPI_REGISTER_SMI_COMMAND_BLOCK:    /* 8-bit access */
 
-		acpi_os_read_port (acpi_gbl_FADT->smi_cmd, &value, 8);
+		status = acpi_os_read_port (acpi_gbl_FADT->smi_cmd, &value1, 8);
 		break;
 
 	default:
-		/* Value will be returned as 0 */
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Register ID: %X\n", register_id));
+		status = AE_BAD_PARAMETER;
 		break;
 	}
 
-
+unlock_and_exit:
 	if (ACPI_MTX_LOCK == use_lock) {
-		acpi_ut_release_mutex (ACPI_MTX_HARDWARE);
+		(void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE);
+	}
+
+	if (ACPI_SUCCESS (status)) {
+		*return_value = value1;
 	}
 
-	return_VALUE (value);
+	return_ACPI_STATUS (status);
 }
 
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_hw_register_write
+ * FUNCTION:    acpi_hw_register_write
  *
- * PARAMETERS:  Use_lock               - Mutex hw access.
- *              Register_id            - Register_iD + Offset.
+ * PARAMETERS:  use_lock               - Mutex hw access.
+ *              register_id            - register_iD + Offset.
  *
  * RETURN:      Value read or written.
  *
@@ -697,160 +580,147 @@
  *
  ******************************************************************************/
 
-void
+acpi_status
 acpi_hw_register_write (
-	u8                      use_lock,
-	u32                     register_id,
-	u32                     value)
+	u8                              use_lock,
+	u32                             register_id,
+	u32                             value)
 {
-	u32                     bank_offset;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Hw_register_write");
+	ACPI_FUNCTION_TRACE ("hw_register_write");
 
 
 	if (ACPI_MTX_LOCK == use_lock) {
-		acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE);
+		status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
+		}
 	}
 
+	switch (register_id) {
+	case ACPI_REGISTER_PM1_STATUS:           /* 16-bit access */
 
-	switch (REGISTER_BLOCK_ID (register_id)) {
-	case PM1_STS: /* 16-bit access */
-
-		acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1a_evt_blk, 0);
-		acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1b_evt_blk, 0);
-		break;
-
-
-	case PM1_EN: /* 16-bit access*/
-
-		bank_offset = DIV_2 (acpi_gbl_FADT->pm1_evt_len);
-		acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1a_evt_blk, bank_offset);
-		acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1b_evt_blk, bank_offset);
-		break;
-
+		status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1a_evt_blk);
+		if (ACPI_FAILURE (status)) {
+			goto unlock_and_exit;
+		}
 
-	case PM1_CONTROL: /* 16-bit access */
+		/* PM1B is optional */
 
-		acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1a_cnt_blk, 0);
-		acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1b_cnt_blk, 0);
+		status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1b_evt_blk);
 		break;
 
 
-	case PM1A_CONTROL: /* 16-bit access */
-
-		acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1a_cnt_blk, 0);
-		break;
+	case ACPI_REGISTER_PM1_ENABLE:           /* 16-bit access*/
 
+		status = acpi_hw_low_level_write (16, value, &acpi_gbl_xpm1a_enable);
+		if (ACPI_FAILURE (status)) {
+			goto unlock_and_exit;
+		}
 
-	case PM1B_CONTROL: /* 16-bit access */
+		/* PM1B is optional */
 
-		acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1b_cnt_blk, 0);
+		status = acpi_hw_low_level_write (16, value, &acpi_gbl_xpm1b_enable);
 		break;
 
 
-	case PM2_CONTROL: /* 8-bit access */
-
-		acpi_hw_low_level_write (8, value, &acpi_gbl_FADT->Xpm2_cnt_blk, 0);
-		break;
-
+	case ACPI_REGISTER_PM1_CONTROL:          /* 16-bit access */
 
-	case PM_TIMER: /* 32-bit access */
+		status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1a_cnt_blk);
+		if (ACPI_FAILURE (status)) {
+			goto unlock_and_exit;
+		}
 
-		acpi_hw_low_level_write (32, value, &acpi_gbl_FADT->Xpm_tmr_blk, 0);
+		status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1b_cnt_blk);
 		break;
 
 
-	case GPE0_STS_BLOCK: /* 8-bit access */
+	case ACPI_REGISTER_PM1A_CONTROL:         /* 16-bit access */
 
-		bank_offset = REGISTER_BIT_ID(register_id);
-		acpi_hw_low_level_write (8, value, &acpi_gbl_FADT->Xgpe0blk, bank_offset);
+		status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1a_cnt_blk);
 		break;
 
 
-	case GPE0_EN_BLOCK: /* 8-bit access */
+	case ACPI_REGISTER_PM1B_CONTROL:         /* 16-bit access */
 
-		bank_offset = DIV_2 (acpi_gbl_FADT->gpe0blk_len) + REGISTER_BIT_ID(register_id);
-		acpi_hw_low_level_write (8, value, &acpi_gbl_FADT->Xgpe0blk, bank_offset);
+		status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1b_cnt_blk);
 		break;
 
 
-	case GPE1_STS_BLOCK: /* 8-bit access */
+	case ACPI_REGISTER_PM2_CONTROL:          /* 8-bit access */
 
-		bank_offset = REGISTER_BIT_ID(register_id);
-		acpi_hw_low_level_write (8, value, &acpi_gbl_FADT->Xgpe1_blk, bank_offset);
+		status = acpi_hw_low_level_write (8, value, &acpi_gbl_FADT->xpm2_cnt_blk);
 		break;
 
 
-	case GPE1_EN_BLOCK: /* 8-bit access */
+	case ACPI_REGISTER_PM_TIMER:             /* 32-bit access */
 
-		bank_offset = DIV_2 (acpi_gbl_FADT->gpe1_blk_len) + REGISTER_BIT_ID(register_id);
-		acpi_hw_low_level_write (8, value, &acpi_gbl_FADT->Xgpe1_blk, bank_offset);
+		status = acpi_hw_low_level_write (32, value, &acpi_gbl_FADT->xpm_tmr_blk);
 		break;
 
 
-	case SMI_CMD_BLOCK: /* 8bit */
+	case ACPI_REGISTER_SMI_COMMAND_BLOCK:    /* 8-bit access */
 
-		/* For 2.0, SMI_CMD is always in IO space */
-		/* TBD: what about 1.0? 0.71? */
+		/* SMI_CMD is currently always in IO space */
 
-		acpi_os_write_port (acpi_gbl_FADT->smi_cmd, value, 8);
+		status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, value, 8);
 		break;
 
 
 	default:
-		value = 0;
+		status = AE_BAD_PARAMETER;
 		break;
 	}
 
-
+unlock_and_exit:
 	if (ACPI_MTX_LOCK == use_lock) {
-		acpi_ut_release_mutex (ACPI_MTX_HARDWARE);
+		(void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE);
 	}
 
-	return_VOID;
+	return_ACPI_STATUS (status);
 }
 
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_hw_low_level_read
+ * FUNCTION:    acpi_hw_low_level_read
  *
- * PARAMETERS:  Register            - GAS register structure
- *              Offset              - Offset from the base address in the GAS
- *              Width               - 8, 16, or 32
+ * PARAMETERS:  Width               - 8, 16, or 32
+ *              Value               - Where the value is returned
+ *              Register            - GAS register structure
  *
- * RETURN:      Value read
+ * RETURN:      Status
  *
  * DESCRIPTION: Read from either memory, IO, or PCI config space.
  *
  ******************************************************************************/
 
-u32
+acpi_status
 acpi_hw_low_level_read (
-	u32                     width,
-	acpi_generic_address    *reg,
-	u32                     offset)
+	u32                             width,
+	u32                             *value,
+	struct acpi_generic_address     *reg)
 {
-	u32                     value = 0;
-	ACPI_PHYSICAL_ADDRESS   mem_address;
-	ACPI_IO_ADDRESS         io_address;
-	acpi_pci_id             pci_id;
-	u16                     pci_register;
+	struct acpi_pci_id              pci_id;
+	u16                             pci_register;
+	acpi_status                     status;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_NAME ("hw_low_level_read");
 
 
 	/*
 	 * Must have a valid pointer to a GAS structure, and
-	 * a non-zero address within
+	 * 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) ||
-		(!ACPI_VALID_ADDRESS (reg->address))) {
-		return 0;
+		(!reg->address)) {
+		return (AE_OK);
 	}
-
+	*value = 0;
 
 	/*
 	 * Three address spaces supported:
@@ -859,17 +729,16 @@
 	switch (reg->address_space_id) {
 	case ACPI_ADR_SPACE_SYSTEM_MEMORY:
 
-		mem_address = (ACPI_PHYSICAL_ADDRESS) (ACPI_GET_ADDRESS (reg->address) + offset);
-
-		acpi_os_read_memory (mem_address, &value, width);
+		status = acpi_os_read_memory (
+				 (acpi_physical_address) reg->address,
+				 value, width);
 		break;
 
 
 	case ACPI_ADR_SPACE_SYSTEM_IO:
 
-		io_address = (ACPI_IO_ADDRESS) (ACPI_GET_ADDRESS (reg->address) + offset);
-
-		acpi_os_read_port (io_address, &value, width);
+		status = acpi_os_read_port ((acpi_io_address) reg->address,
+				 value, width);
 		break;
 
 
@@ -877,60 +746,68 @@
 
 		pci_id.segment = 0;
 		pci_id.bus     = 0;
-		pci_id.device  = ACPI_PCI_DEVICE (ACPI_GET_ADDRESS (reg->address));
-		pci_id.function = ACPI_PCI_FUNCTION (ACPI_GET_ADDRESS (reg->address));
-		pci_register   = (u16) (ACPI_PCI_REGISTER (ACPI_GET_ADDRESS (reg->address)) + offset);
+		pci_id.device  = ACPI_PCI_DEVICE (reg->address);
+		pci_id.function = ACPI_PCI_FUNCTION (reg->address);
+		pci_register   = (u16) ACPI_PCI_REGISTER (reg->address);
 
-		acpi_os_read_pci_configuration (&pci_id, pci_register, &value, width);
+		status = acpi_os_read_pci_configuration (&pci_id, pci_register,
+				 value, width);
 		break;
+
+
+	default:
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"Unsupported address space: %X\n", reg->address_space_id));
+		return (AE_BAD_PARAMETER);
 	}
 
-	return value;
+	ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read:  %8.8X width %2d from %8.8X%8.8X (%s)\n",
+			*value, width,
+			ACPI_HIDWORD (reg->address),
+			ACPI_LODWORD (reg->address),
+			acpi_ut_get_region_name (reg->address_space_id)));
+
+	return (status);
 }
 
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_hw_low_level_write
+ * FUNCTION:    acpi_hw_low_level_write
  *
  * PARAMETERS:  Width               - 8, 16, or 32
  *              Value               - To be written
  *              Register            - GAS register structure
- *              Offset              - Offset from the base address in the GAS
  *
+ * RETURN:      Status
  *
- * RETURN:      Value read
- *
- * DESCRIPTION: Read from either memory, IO, or PCI config space.
+ * DESCRIPTION: Write to either memory, IO, or PCI config space.
  *
  ******************************************************************************/
 
-void
+acpi_status
 acpi_hw_low_level_write (
-	u32                     width,
-	u32                     value,
-	acpi_generic_address    *reg,
-	u32                     offset)
+	u32                             width,
+	u32                             value,
+	struct acpi_generic_address     *reg)
 {
-	ACPI_PHYSICAL_ADDRESS   mem_address;
-	ACPI_IO_ADDRESS         io_address;
-	acpi_pci_id             pci_id;
-	u16                     pci_register;
+	struct acpi_pci_id              pci_id;
+	u16                             pci_register;
+	acpi_status                     status;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_NAME ("hw_low_level_write");
 
 
 	/*
 	 * Must have a valid pointer to a GAS structure, and
-	 * a non-zero address within
+	 * 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) ||
-		(!ACPI_VALID_ADDRESS (reg->address))) {
-		return;
+		(!reg->address)) {
+		return (AE_OK);
 	}
-
-
 	/*
 	 * Three address spaces supported:
 	 * Memory, Io, or PCI config.
@@ -938,17 +815,16 @@
 	switch (reg->address_space_id) {
 	case ACPI_ADR_SPACE_SYSTEM_MEMORY:
 
-		mem_address = (ACPI_PHYSICAL_ADDRESS) (ACPI_GET_ADDRESS (reg->address) + offset);
-
-		acpi_os_write_memory (mem_address, value, width);
+		status = acpi_os_write_memory (
+				 (acpi_physical_address) reg->address,
+				 value, width);
 		break;
 
 
 	case ACPI_ADR_SPACE_SYSTEM_IO:
 
-		io_address = (ACPI_IO_ADDRESS) (ACPI_GET_ADDRESS (reg->address) + offset);
-
-		acpi_os_write_port (io_address, value, width);
+		status = acpi_os_write_port ((acpi_io_address) reg->address,
+				 value, width);
 		break;
 
 
@@ -956,11 +832,26 @@
 
 		pci_id.segment = 0;
 		pci_id.bus     = 0;
-		pci_id.device  = ACPI_PCI_DEVICE (ACPI_GET_ADDRESS (reg->address));
-		pci_id.function = ACPI_PCI_FUNCTION (ACPI_GET_ADDRESS (reg->address));
-		pci_register   = (u16) (ACPI_PCI_REGISTER (ACPI_GET_ADDRESS (reg->address)) + offset);
+		pci_id.device  = ACPI_PCI_DEVICE (reg->address);
+		pci_id.function = ACPI_PCI_FUNCTION (reg->address);
+		pci_register   = (u16) ACPI_PCI_REGISTER (reg->address);
 
-		acpi_os_write_pci_configuration (&pci_id, pci_register, value, width);
+		status = acpi_os_write_pci_configuration (&pci_id, pci_register,
+				 (acpi_integer) value, width);
 		break;
+
+
+	default:
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"Unsupported address space: %X\n", reg->address_space_id));
+		return (AE_BAD_PARAMETER);
 	}
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Wrote: %8.8X width %2d   to %8.8X%8.8X (%s)\n",
+			value, width,
+			ACPI_HIDWORD (reg->address),
+			ACPI_LODWORD (reg->address),
+			acpi_ut_get_region_name (reg->address_space_id)));
+
+	return (status);
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/hardware/hwsleep.c linux-2.4.22-pre2/drivers/acpi/hardware/hwsleep.c
--- linux-2.4.21/drivers/acpi/hardware/hwsleep.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/hardware/hwsleep.c	2003-06-26 21:43:11.000000000 +0000
@@ -2,70 +2,82 @@
 /******************************************************************************
  *
  * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface
- *              $Revision: 22 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
-#include "acpi.h"
-#include "acnamesp.h"
-#include "achware.h"
+#include <acpi/acpi.h>
 
 #define _COMPONENT          ACPI_HARDWARE
-	 MODULE_NAME         ("hwsleep")
+	 ACPI_MODULE_NAME    ("hwsleep")
 
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_set_firmware_waking_vector
+ * FUNCTION:    acpi_set_firmware_waking_vector
  *
- * PARAMETERS:  Physical_address    - Physical address of ACPI real mode
+ * PARAMETERS:  physical_address    - Physical address of ACPI real mode
  *                                    entry point.
  *
- * RETURN:      AE_OK or AE_ERROR
+ * RETURN:      Status
  *
- * DESCRIPTION: Access function for d_firmware_waking_vector field in FACS
+ * DESCRIPTION: access function for d_firmware_waking_vector field in FACS
  *
  ******************************************************************************/
 
 acpi_status
 acpi_set_firmware_waking_vector (
-	ACPI_PHYSICAL_ADDRESS physical_address)
+	acpi_physical_address physical_address)
 {
 
-	FUNCTION_TRACE ("Acpi_set_firmware_waking_vector");
-
-
-	/* Make sure that we have an FACS */
+	ACPI_FUNCTION_TRACE ("acpi_set_firmware_waking_vector");
 
-	if (!acpi_gbl_FACS) {
-		return_ACPI_STATUS (AE_NO_ACPI_TABLES);
-	}
 
 	/* Set the vector */
 
-	if (acpi_gbl_FACS->vector_width == 32) {
-		* (u32 *) acpi_gbl_FACS->firmware_waking_vector = (u32) physical_address;
+	if (acpi_gbl_common_fACS.vector_width == 32) {
+		*(ACPI_CAST_PTR (u32, acpi_gbl_common_fACS.firmware_waking_vector))
+				= (u32) physical_address;
 	}
 	else {
-		*acpi_gbl_FACS->firmware_waking_vector = physical_address;
+		*acpi_gbl_common_fACS.firmware_waking_vector
+				= physical_address;
 	}
 
 	return_ACPI_STATUS (AE_OK);
@@ -74,167 +86,300 @@
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_get_firmware_waking_vector
+ * FUNCTION:    acpi_get_firmware_waking_vector
  *
- * PARAMETERS:  *Physical_address   - Output buffer where contents of
- *                                    the Firmware_waking_vector field of
+ * PARAMETERS:  *physical_address   - Output buffer where contents of
+ *                                    the firmware_waking_vector field of
  *                                    the FACS will be stored.
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Access function for d_firmware_waking_vector field in FACS
+ * DESCRIPTION: Access function for firmware_waking_vector field in FACS
  *
  ******************************************************************************/
 
 acpi_status
 acpi_get_firmware_waking_vector (
-	ACPI_PHYSICAL_ADDRESS *physical_address)
+	acpi_physical_address *physical_address)
 {
 
-	FUNCTION_TRACE ("Acpi_get_firmware_waking_vector");
+	ACPI_FUNCTION_TRACE ("acpi_get_firmware_waking_vector");
 
 
 	if (!physical_address) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-	/* Make sure that we have an FACS */
-
-	if (!acpi_gbl_FACS) {
-		return_ACPI_STATUS (AE_NO_ACPI_TABLES);
-	}
-
 	/* Get the vector */
 
-	if (acpi_gbl_FACS->vector_width == 32) {
-		*physical_address = * (u32 *) acpi_gbl_FACS->firmware_waking_vector;
+	if (acpi_gbl_common_fACS.vector_width == 32) {
+		*physical_address = (acpi_physical_address)
+			*(ACPI_CAST_PTR (u32, acpi_gbl_common_fACS.firmware_waking_vector));
 	}
 	else {
-		*physical_address = *acpi_gbl_FACS->firmware_waking_vector;
+		*physical_address =
+			*acpi_gbl_common_fACS.firmware_waking_vector;
 	}
 
 	return_ACPI_STATUS (AE_OK);
 }
 
+
 /******************************************************************************
  *
- * FUNCTION:    Acpi_enter_sleep_state
+ * FUNCTION:    acpi_enter_sleep_state_prep
  *
- * PARAMETERS:  Sleep_state         - Which sleep state to enter
+ * PARAMETERS:  sleep_state         - Which sleep state to enter
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231)
+ * DESCRIPTION: Prepare to enter a system sleep state (see ACPI 2.0 spec p 231)
+ *              This function must execute with interrupts enabled.
+ *              We break sleeping into 2 stages so that OSPM can handle
+ *              various OS-specific tasks between the two steps.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_enter_sleep_state (
-	u8                  sleep_state)
+acpi_enter_sleep_state_prep (
+	u8                          sleep_state)
 {
-	acpi_status         status;
-	acpi_object_list    arg_list;
-	acpi_object         arg;
-	u8                  type_a;
-	u8                  type_b;
-	u16                 PM1Acontrol;
-	u16                 PM1Bcontrol;
+	acpi_status                 status;
+	struct acpi_object_list     arg_list;
+	union acpi_object           arg;
 
 
-	FUNCTION_TRACE ("Acpi_enter_sleep_state");
+	ACPI_FUNCTION_TRACE ("acpi_enter_sleep_state_prep");
 
 
 	/*
 	 * _PSW methods could be run here to enable wake-on keyboard, LAN, etc.
 	 */
-	status = acpi_hw_obtain_sleep_type_register_data (sleep_state, &type_a, &type_b);
-	if (!ACPI_SUCCESS (status)) {
-		return status;
+	status = acpi_get_sleep_type_data (sleep_state,
+			  &acpi_gbl_sleep_type_a, &acpi_gbl_sleep_type_b);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
 	}
 
-	/* run the _PTS and _GTS methods */
+	/* Setup parameter object */
 
-	MEMSET(&arg_list, 0, sizeof(arg_list));
 	arg_list.count = 1;
 	arg_list.pointer = &arg;
 
-	MEMSET(&arg, 0, sizeof(arg));
 	arg.type = ACPI_TYPE_INTEGER;
 	arg.integer.value = sleep_state;
 
-	acpi_evaluate_object (NULL, "\\_PTS", &arg_list, NULL);
-	acpi_evaluate_object (NULL, "\\_GTS", &arg_list, NULL);
+	/* Run the _PTS and _GTS methods */
 
-	/* clear wake status */
+	status = acpi_evaluate_object (NULL, "\\_PTS", &arg_list, NULL);
+	if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) {
+		return_ACPI_STATUS (status);
+	}
 
-	acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, WAK_STS, 1);
+	status = acpi_evaluate_object (NULL, "\\_GTS", &arg_list, NULL);
+	if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) {
+		return_ACPI_STATUS (status);
+	}
 
-	disable ();
+	return_ACPI_STATUS (AE_OK);
+}
 
-	acpi_hw_disable_non_wakeup_gpes();
 
-	PM1Acontrol = (u16) acpi_hw_register_read (ACPI_MTX_LOCK, PM1_CONTROL);
+/******************************************************************************
+ *
+ * FUNCTION:    acpi_enter_sleep_state
+ *
+ * PARAMETERS:  sleep_state         - Which sleep state to enter
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231)
+ *              THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
+ *
+ ******************************************************************************/
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_OK, "Entering S%d\n", sleep_state));
+acpi_status
+acpi_enter_sleep_state (
+	u8                              sleep_state)
+{
+	u32                             PM1Acontrol;
+	u32                             PM1Bcontrol;
+	struct acpi_bit_register_info   *sleep_type_reg_info;
+	struct acpi_bit_register_info   *sleep_enable_reg_info;
+	u32                             in_value;
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_TRACE ("acpi_enter_sleep_state");
+
+
+	if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) ||
+		(acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) {
+		ACPI_REPORT_ERROR (("Sleep values out of range: A=%X B=%X\n",
+			acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b));
+		return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
+	}
+
+
+	sleep_type_reg_info = acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_TYPE_A);
+	sleep_enable_reg_info = acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_ENABLE);
+
+	/* Clear wake status */
+
+	status = acpi_set_register (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	status = acpi_hw_clear_acpi_status(ACPI_MTX_DO_NOT_LOCK);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/* Disable BM arbitration */
+
+	status = acpi_set_register (ACPI_BITREG_ARB_DISABLE, 1, ACPI_MTX_DO_NOT_LOCK);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	status = acpi_hw_disable_non_wakeup_gpes();
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/* Get current value of PM1A control */
+
+	status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+	ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Entering sleep state [S%d]\n", sleep_state));
 
-	/* mask off SLP_EN and SLP_TYP fields */
+	/* Clear SLP_EN and SLP_TYP fields */
 
-	PM1Acontrol &= ~(SLP_TYPE_X_MASK | SLP_EN_MASK);
+	PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | sleep_enable_reg_info->access_bit_mask);
 	PM1Bcontrol = PM1Acontrol;
 
-	/* mask in SLP_TYP */
+	/* Insert SLP_TYP bits */
 
-	PM1Acontrol |= (type_a << acpi_hw_get_bit_shift (SLP_TYPE_X_MASK));
-	PM1Bcontrol |= (type_b << acpi_hw_get_bit_shift (SLP_TYPE_X_MASK));
+	PM1Acontrol |= (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position);
+	PM1Bcontrol |= (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position);
 
-	/* write #1: fill in SLP_TYP data */
+	/* Write #1: fill in SLP_TYP data */
 
-	acpi_hw_register_write (ACPI_MTX_LOCK, PM1A_CONTROL, PM1Acontrol);
-	acpi_hw_register_write (ACPI_MTX_LOCK, PM1B_CONTROL, PM1Bcontrol);
+	status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
-	/* mask in SLP_EN */
+	/* Insert SLP_ENABLE bit */
 
-	PM1Acontrol |= (1 << acpi_hw_get_bit_shift (SLP_EN_MASK));
-	PM1Bcontrol |= (1 << acpi_hw_get_bit_shift (SLP_EN_MASK));
+	PM1Acontrol |= sleep_enable_reg_info->access_bit_mask;
+	PM1Bcontrol |= sleep_enable_reg_info->access_bit_mask;
 
-	/* flush caches */
+	/* Write #2: SLP_TYP + SLP_EN */
 
-	wbinvd();
+	ACPI_FLUSH_CPU_CACHE ();
 
-	/* write #2: SLP_TYP + SLP_EN */
+	status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
-	acpi_hw_register_write (ACPI_MTX_LOCK, PM1A_CONTROL, PM1Acontrol);
-	acpi_hw_register_write (ACPI_MTX_LOCK, PM1B_CONTROL, PM1Bcontrol);
+	status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	/*
 	 * Wait a second, then try again. This is to get S4/5 to work on all machines.
 	 */
 	if (sleep_state > ACPI_STATE_S3) {
-		acpi_os_stall(1000000);
-
-		acpi_hw_register_write (ACPI_MTX_LOCK, PM1_CONTROL,
-			(1 << acpi_hw_get_bit_shift (SLP_EN_MASK)));
+		/*
+		 * We wait so long to allow chipsets that poll this reg very slowly to
+		 * still read the right value. Ideally, this entire block would go
+		 * away entirely.
+		 */
+		acpi_os_stall (10000000);
+
+		status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_CONTROL,
+				 sleep_enable_reg_info->access_bit_mask);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
+		}
 	}
 
-	/* wait until we enter sleep state */
+	/* Wait until we enter sleep state */
 
 	do {
-		acpi_os_stall(10000);
-	}
-	while (!acpi_hw_register_bit_access (ACPI_READ, ACPI_MTX_LOCK, WAK_STS));
+		status = acpi_get_register (ACPI_BITREG_WAKE_STATUS, &in_value, ACPI_MTX_DO_NOT_LOCK);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
+		}
 
-	acpi_hw_enable_non_wakeup_gpes();
+		/* Spin until we wake */
 
-	enable ();
+	} while (!in_value);
 
 	return_ACPI_STATUS (AE_OK);
 }
 
+
 /******************************************************************************
  *
- * FUNCTION:    Acpi_leave_sleep_state
+ * FUNCTION:    acpi_enter_sleep_state_s4bios
  *
- * PARAMETERS:  Sleep_state         - Which sleep state we just exited
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Perform a S4 bios request.
+ *              THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_enter_sleep_state_s4bios (
+	void)
+{
+	u32                             in_value;
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_TRACE ("acpi_enter_sleep_state_s4bios");
+
+	acpi_set_register (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK);
+	acpi_hw_clear_acpi_status(ACPI_MTX_DO_NOT_LOCK);
+
+	acpi_hw_disable_non_wakeup_gpes();
+
+	ACPI_FLUSH_CPU_CACHE();
+
+	status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, (u32) acpi_gbl_FADT->S4bios_req, 8);
+
+	do {
+		acpi_os_stall(1000);
+		status = acpi_get_register (ACPI_BITREG_WAKE_STATUS, &in_value, ACPI_MTX_DO_NOT_LOCK);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
+		}
+	} while (!in_value);
+
+	return_ACPI_STATUS (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    acpi_leave_sleep_state
+ *
+ * PARAMETERS:  sleep_state         - Which sleep state we just exited
  *
  * RETURN:      Status
  *
@@ -244,29 +389,49 @@
 
 acpi_status
 acpi_leave_sleep_state (
-	u8                  sleep_state)
+	u8                          sleep_state)
 {
-	acpi_object_list    arg_list;
-	acpi_object         arg;
+	struct acpi_object_list     arg_list;
+	union acpi_object           arg;
+	acpi_status                 status;
 
 
-	FUNCTION_TRACE ("Acpi_leave_sleep_state");
+	ACPI_FUNCTION_TRACE ("acpi_leave_sleep_state");
 
 
-	MEMSET (&arg_list, 0, sizeof(arg_list));
+	/* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */
+
+	acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID;
+
+	/* Setup parameter object */
+
 	arg_list.count = 1;
 	arg_list.pointer = &arg;
 
-	MEMSET (&arg, 0, sizeof(arg));
 	arg.type = ACPI_TYPE_INTEGER;
 	arg.integer.value = sleep_state;
 
-	acpi_evaluate_object (NULL, "\\_BFS", &arg_list, NULL);
-	acpi_evaluate_object (NULL, "\\_WAK", &arg_list, NULL);
+	/* Ignore any errors from these methods */
+
+	status = acpi_evaluate_object (NULL, "\\_BFS", &arg_list, NULL);
+	if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) {
+		ACPI_REPORT_ERROR (("Method _BFS failed, %s\n", acpi_format_exception (status)));
+	}
+
+	status = acpi_evaluate_object (NULL, "\\_WAK", &arg_list, NULL);
+	if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) {
+		ACPI_REPORT_ERROR (("Method _WAK failed, %s\n", acpi_format_exception (status)));
+	}
 
 	/* _WAK returns stuff - do we want to look at it? */
 
-	acpi_hw_enable_non_wakeup_gpes();
+	status = acpi_hw_enable_non_wakeup_gpes();
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
-	return_ACPI_STATUS (AE_OK);
+	/* Disable BM arbitration */
+	status = acpi_set_register (ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_LOCK);
+
+	return_ACPI_STATUS (status);
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/hardware/hwtimer.c linux-2.4.22-pre2/drivers/acpi/hardware/hwtimer.c
--- linux-2.4.21/drivers/acpi/hardware/hwtimer.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/hardware/hwtimer.c	2003-06-26 21:43:12.000000000 +0000
@@ -2,38 +2,55 @@
 /******************************************************************************
  *
  * Name: hwtimer.c - ACPI Power Management Timer Interface
- *              $Revision: 14 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
-#include "acpi.h"
-#include "achware.h"
+#include <acpi/acpi.h>
 
 #define _COMPONENT          ACPI_HARDWARE
-	 MODULE_NAME         ("hwtimer")
+	 ACPI_MODULE_NAME    ("hwtimer")
 
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_get_timer_resolution
+ * FUNCTION:    acpi_get_timer_resolution
  *
  * PARAMETERS:  none
  *
@@ -45,9 +62,9 @@
 
 acpi_status
 acpi_get_timer_resolution (
-	u32                     *resolution)
+	u32                             *resolution)
 {
-	FUNCTION_TRACE ("Acpi_get_timer_resolution");
+	ACPI_FUNCTION_TRACE ("acpi_get_timer_resolution");
 
 
 	if (!resolution) {
@@ -57,7 +74,6 @@
 	if (0 == acpi_gbl_FADT->tmr_val_ext) {
 		*resolution = 24;
 	}
-
 	else {
 		*resolution = 32;
 	}
@@ -68,7 +84,7 @@
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_get_timer
+ * FUNCTION:    acpi_get_timer
  *
  * PARAMETERS:  none
  *
@@ -80,31 +96,33 @@
 
 acpi_status
 acpi_get_timer (
-	u32                     *ticks)
+	u32                             *ticks)
 {
-	FUNCTION_TRACE ("Acpi_get_timer");
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_TRACE ("acpi_get_timer");
 
 
 	if (!ticks) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-	acpi_os_read_port ((ACPI_IO_ADDRESS)
-		ACPI_GET_ADDRESS (acpi_gbl_FADT->Xpm_tmr_blk.address), ticks, 32);
+	status = acpi_hw_low_level_read (32, ticks, &acpi_gbl_FADT->xpm_tmr_blk);
 
-	return_ACPI_STATUS (AE_OK);
+	return_ACPI_STATUS (status);
 }
 
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_get_timer_duration
+ * FUNCTION:    acpi_get_timer_duration
  *
- * PARAMETERS:  Start_ticks
- *              End_ticks
- *              Time_elapsed
+ * PARAMETERS:  start_ticks
+ *              end_ticks
+ *              time_elapsed
  *
- * RETURN:      Time_elapsed
+ * RETURN:      time_elapsed
  *
  * DESCRIPTION: Computes the time elapsed (in microseconds) between two
  *              PM Timer time stamps, taking into account the possibility of
@@ -115,27 +133,29 @@
  *              transitions (unlike many CPU timestamp counters) -- making it
  *              a versatile and accurate timer.
  *
- *              Note that this function accomodates only a single timer
+ *              Note that this function accommodates only a single timer
  *              rollover.  Thus for 24-bit timers, this function should only
  *              be used for calculating durations less than ~4.6 seconds
- *              (~20 hours for 32-bit timers).
+ *              (~20 minutes for 32-bit timers) -- calculations below
+ *
+ *              2**24 Ticks / 3,600,000 Ticks/Sec = 4.66 sec
+ *              2**32 Ticks / 3,600,000 Ticks/Sec = 1193 sec or 19.88 minutes
  *
  ******************************************************************************/
 
 acpi_status
 acpi_get_timer_duration (
-	u32                     start_ticks,
-	u32                     end_ticks,
-	u32                     *time_elapsed)
+	u32                             start_ticks,
+	u32                             end_ticks,
+	u32                             *time_elapsed)
 {
-	u32                     delta_ticks = 0;
-	u32                     seconds = 0;
-	u32                     milliseconds = 0;
-	u32                     microseconds = 0;
-	u32                     remainder = 0;
+	u32                             delta_ticks = 0;
+	union uint64_overlay            normalized_ticks;
+	acpi_status                     status;
+	acpi_integer                    out_quotient;
 
 
-	FUNCTION_TRACE ("Acpi_get_timer_duration");
+	ACPI_FUNCTION_TRACE ("acpi_get_timer_duration");
 
 
 	if (!time_elapsed) {
@@ -150,21 +170,18 @@
 	if (start_ticks < end_ticks) {
 		delta_ticks = end_ticks - start_ticks;
 	}
-
 	else if (start_ticks > end_ticks) {
-		/* 24-bit Timer */
-
 		if (0 == acpi_gbl_FADT->tmr_val_ext) {
+			/* 24-bit Timer */
+
 			delta_ticks = (((0x00FFFFFF - start_ticks) + end_ticks) & 0x00FFFFFF);
 		}
-
-		/* 32-bit Timer */
-
 		else {
+			/* 32-bit Timer */
+
 			delta_ticks = (0xFFFFFFFF - start_ticks) + end_ticks;
 		}
 	}
-
 	else {
 		*time_elapsed = 0;
 		return_ACPI_STATUS (AE_OK);
@@ -173,49 +190,18 @@
 	/*
 	 * Compute Duration:
 	 * -----------------
-	 * Since certain compilers (gcc/Linux, argh!) don't support 64-bit
-	 * divides in kernel-space we have to do some trickery to preserve
-	 * accuracy while using 32-bit math.
-	 *
-	 * TBD: Change to use 64-bit math when supported.
 	 *
-	 * The process is as follows:
-	 *  1. Compute the number of seconds by dividing Delta Ticks by
-	 *     the timer frequency.
-	 *  2. Compute the number of milliseconds in the remainder from step #1
-	 *     by multiplying by 1000 and then dividing by the timer frequency.
-	 *  3. Compute the number of microseconds in the remainder from step #2
-	 *     by multiplying by 1000 and then dividing by the timer frequency.
-	 *  4. Add the results from steps 1, 2, and 3 to get the total duration.
+	 * Requires a 64-bit divide:
 	 *
-	 * Example: The time elapsed for Delta_ticks = 0xFFFFFFFF should be
-	 *          1199864031 microseconds.  This is computed as follows:
-	 *          Step #1: Seconds = 1199; Remainder = 3092840
-	 *          Step #2: Milliseconds = 864; Remainder = 113120
-	 *          Step #3: Microseconds = 31; Remainder = <don't care!>
+	 * time_elapsed = (delta_ticks * 1000000) / PM_TIMER_FREQUENCY;
 	 */
+	normalized_ticks.full = ((u64) delta_ticks) * 1000000;
 
-	/* Step #1 */
-
-	seconds = delta_ticks / PM_TIMER_FREQUENCY;
-	remainder = delta_ticks % PM_TIMER_FREQUENCY;
-
-	/* Step #2 */
-
-	milliseconds = (remainder * 1000) / PM_TIMER_FREQUENCY;
-	remainder = (remainder * 1000) % PM_TIMER_FREQUENCY;
+	status = acpi_ut_short_divide (&normalized_ticks.full, PM_TIMER_FREQUENCY,
+			   &out_quotient, NULL);
 
-	/* Step #3 */
-
-	microseconds = (remainder * 1000) / PM_TIMER_FREQUENCY;
-
-	/* Step #4 */
-
-	*time_elapsed = seconds * 1000000;
-	*time_elapsed += milliseconds * 1000;
-	*time_elapsed += microseconds;
-
-	return_ACPI_STATUS (AE_OK);
+	*time_elapsed = (u32) out_quotient;
+	return_ACPI_STATUS (status);
 }
 
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/acconfig.h linux-2.4.22-pre2/drivers/acpi/include/acconfig.h
--- linux-2.4.21/drivers/acpi/include/acconfig.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/acconfig.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,162 +0,0 @@
-/******************************************************************************
- *
- * Name: acconfig.h - Global configuration constants
- *       $Revision: 74 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef _ACCONFIG_H
-#define _ACCONFIG_H
-
-
-/******************************************************************************
- *
- * Compile-time options
- *
- *****************************************************************************/
-
-/*
- * ACPI_DEBUG           - This switch enables all the debug facilities of the ACPI
- *                          subsystem.  This includes the DEBUG_PRINT output statements
- *                          When disabled, all DEBUG_PRINT statements are compiled out.
- *
- * ACPI_APPLICATION     - Use this switch if the subsystem is going to be run
- *                          at the application level.
- *
- */
-
-
-/******************************************************************************
- *
- * Subsystem Constants
- *
- *****************************************************************************/
-
-
-/* Version string */
-
-#define ACPI_CA_VERSION             0x20011018
-
-/* Version of ACPI supported */
-
-#define ACPI_CA_SUPPORT_LEVEL       2
-
-
-/* Maximum objects in the various object caches */
-
-#define MAX_STATE_CACHE_DEPTH       64         /* State objects for stacks */
-#define MAX_PARSE_CACHE_DEPTH       96          /* Parse tree objects */
-#define MAX_EXTPARSE_CACHE_DEPTH    64          /* Parse tree objects */
-#define MAX_OBJECT_CACHE_DEPTH      64          /* Interpreter operand objects */
-#define MAX_WALK_CACHE_DEPTH        4           /* Objects for parse tree walks (method execution) */
-
-
-/* String size constants */
-
-#define MAX_STRING_LENGTH           512
-#define PATHNAME_MAX                256     /* A full namespace pathname */
-
-
-/* Maximum count for a semaphore object */
-
-#define MAX_SEMAPHORE_COUNT         256
-
-
-/* Max reference count (for debug only) */
-
-#define MAX_REFERENCE_COUNT         0x400
-
-
-/* Size of cached memory mapping for system memory operation region */
-
-#define SYSMEM_REGION_WINDOW_SIZE   4096
-
-
-/*
- * Debugger threading model
- * Use single threaded if the entire subsystem is contained in an application
- * Use multiple threaded when the subsystem is running in the kernel.
- *
- * By default the model is single threaded if ACPI_APPLICATION is set,
- * multi-threaded if ACPI_APPLICATION is not set.
- */
-
-#define DEBUGGER_SINGLE_THREADED    0
-#define DEBUGGER_MULTI_THREADED     1
-
-#ifdef ACPI_APPLICATION
-#define DEBUGGER_THREADING          DEBUGGER_SINGLE_THREADED
-
-#else
-#define DEBUGGER_THREADING          DEBUGGER_MULTI_THREADED
-#endif
-
-
-/******************************************************************************
- *
- * ACPI Specification constants (Do not change unless the specification changes)
- *
- *****************************************************************************/
-
-/*
- * Method info (in WALK_STATE), containing local variables and argumetns
- */
-
-#define MTH_NUM_LOCALS              8
-#define MTH_MAX_LOCAL               7
-
-#define MTH_NUM_ARGS                7
-#define MTH_MAX_ARG                 6
-
-/* Maximum length of resulting string when converting from a buffer */
-
-#define ACPI_MAX_STRING_CONVERSION  200
-
-/*
- * Operand Stack (in WALK_STATE), Must be large enough to contain MTH_MAX_ARG
- */
-
-#define OBJ_NUM_OPERANDS            8
-#define OBJ_MAX_OPERAND             7
-
-/* Names within the namespace are 4 bytes long */
-
-#define ACPI_NAME_SIZE              4
-#define PATH_SEGMENT_LENGTH         5           /* 4 chars for name + 1 s8 for separator */
-#define PATH_SEPARATOR              '.'
-
-
-/* Constants used in searching for the RSDP in low memory */
-
-#define LO_RSDP_WINDOW_BASE         0           /* Physical Address */
-#define HI_RSDP_WINDOW_BASE         0xE0000     /* Physical Address */
-#define LO_RSDP_WINDOW_SIZE         0x400
-#define HI_RSDP_WINDOW_SIZE         0x20000
-#define RSDP_SCAN_STEP              16
-
-/* Maximum Space_ids for Operation Regions */
-
-#define ACPI_MAX_ADDRESS_SPACE      255
-#define ACPI_NUM_ADDRESS_SPACES     256
-
-
-#endif /* _ACCONFIG_H */
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/acdebug.h linux-2.4.22-pre2/drivers/acpi/include/acdebug.h
--- linux-2.4.21/drivers/acpi/include/acdebug.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/acdebug.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,410 +0,0 @@
-/******************************************************************************
- *
- * Name: acdebug.h - ACPI/AML debugger
- *       $Revision: 50 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACDEBUG_H__
-#define __ACDEBUG_H__
-
-
-#define DB_MAX_ARGS             8  /* Must be max method args + 1 */
-
-#define DB_COMMAND_PROMPT      '-'
-#define DB_EXECUTE_PROMPT      '%'
-
-
-extern int                      optind;
-extern NATIVE_CHAR              *optarg;
-extern u8                       *aml_start;
-extern u32                      aml_length;
-
-extern u8                       acpi_gbl_db_opt_tables;
-extern u8                       acpi_gbl_db_opt_disasm;
-extern u8                       acpi_gbl_db_opt_stats;
-extern u8                       acpi_gbl_db_opt_parse_jit;
-extern u8                       acpi_gbl_db_opt_verbose;
-extern u8                       acpi_gbl_db_opt_ini_methods;
-
-
-extern NATIVE_CHAR              *acpi_gbl_db_args[DB_MAX_ARGS];
-extern NATIVE_CHAR              acpi_gbl_db_line_buf[80];
-extern NATIVE_CHAR              acpi_gbl_db_scope_buf[40];
-extern NATIVE_CHAR              acpi_gbl_db_debug_filename[40];
-extern u8                       acpi_gbl_db_output_to_file;
-extern NATIVE_CHAR              *acpi_gbl_db_buffer;
-extern NATIVE_CHAR              *acpi_gbl_db_filename;
-extern NATIVE_CHAR              *acpi_gbl_db_disasm_indent;
-extern u8                       acpi_gbl_db_output_flags;
-extern u32                      acpi_gbl_db_debug_level;
-extern u32                      acpi_gbl_db_console_debug_level;
-extern acpi_table_header        *acpi_gbl_db_table_ptr;
-
-/*
- * Statistic globals
- */
-extern u16                      acpi_gbl_obj_type_count[INTERNAL_TYPE_NODE_MAX+1];
-extern u16                      acpi_gbl_node_type_count[INTERNAL_TYPE_NODE_MAX+1];
-extern u16                      acpi_gbl_obj_type_count_misc;
-extern u16                      acpi_gbl_node_type_count_misc;
-extern u32                      acpi_gbl_num_nodes;
-extern u32                      acpi_gbl_num_objects;
-
-
-extern u32                      acpi_gbl_size_of_parse_tree;
-extern u32                      acpi_gbl_size_of_method_trees;
-extern u32                      acpi_gbl_size_of_node_entries;
-extern u32                      acpi_gbl_size_of_acpi_objects;
-
-
-#define ACPI_DEBUG_BUFFER_SIZE  4196
-
-#define DB_REDIRECTABLE_OUTPUT  0x01
-#define DB_CONSOLE_OUTPUT       0x02
-#define DB_DUPLICATE_OUTPUT     0x03
-
-
-typedef struct command_info
-{
-	NATIVE_CHAR             *name;          /* Command Name */
-	u8                      min_args;       /* Minimum arguments required */
-
-} COMMAND_INFO;
-
-
-typedef struct argument_info
-{
-	NATIVE_CHAR             *name;          /* Argument Name */
-
-} ARGUMENT_INFO;
-
-
-#define PARAM_LIST(pl)                  pl
-
-#define DBTEST_OUTPUT_LEVEL(lvl)        if (acpi_gbl_db_opt_verbose)
-
-#define VERBOSE_PRINT(fp)               DBTEST_OUTPUT_LEVEL(lvl) {\
-			  acpi_os_printf PARAM_LIST(fp);}
-
-#define EX_NO_SINGLE_STEP       1
-#define EX_SINGLE_STEP          2
-
-
-/* Prototypes */
-
-
-/*
- * dbapi - external debugger interfaces
- */
-
-int
-acpi_db_initialize (
-	void);
-
-void
-acpi_db_terminate (
-	void);
-
-acpi_status
-acpi_db_single_step (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op,
-	u32                     op_type);
-
-
-/*
- * dbcmds - debug commands and output routines
- */
-
-
-void
-acpi_db_display_table_info (
-	NATIVE_CHAR             *table_arg);
-
-void
-acpi_db_unload_acpi_table (
-	NATIVE_CHAR             *table_arg,
-	NATIVE_CHAR             *instance_arg);
-
-void
-acpi_db_set_method_breakpoint (
-	NATIVE_CHAR             *location,
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op);
-
-void
-acpi_db_set_method_call_breakpoint (
-	acpi_parse_object       *op);
-
-void
-acpi_db_disassemble_aml (
-	NATIVE_CHAR             *statements,
-	acpi_parse_object       *op);
-
-void
-acpi_db_dump_namespace (
-	NATIVE_CHAR             *start_arg,
-	NATIVE_CHAR             *depth_arg);
-
-void
-acpi_db_dump_namespace_by_owner (
-	NATIVE_CHAR             *owner_arg,
-	NATIVE_CHAR             *depth_arg);
-
-void
-acpi_db_send_notify (
-	NATIVE_CHAR             *name,
-	u32                     value);
-
-void
-acpi_db_set_method_data (
-	NATIVE_CHAR             *type_arg,
-	NATIVE_CHAR             *index_arg,
-	NATIVE_CHAR             *value_arg);
-
-acpi_status
-acpi_db_display_objects (
-	NATIVE_CHAR             *obj_type_arg,
-	NATIVE_CHAR             *display_count_arg);
-
-acpi_status
-acpi_db_find_name_in_namespace (
-	NATIVE_CHAR             *name_arg);
-
-void
-acpi_db_set_scope (
-	NATIVE_CHAR             *name);
-
-void
-acpi_db_find_references (
-	NATIVE_CHAR             *object_arg);
-
-void
-acpi_db_display_locks (void);
-
-
-void
-acpi_db_display_resources (
-	NATIVE_CHAR             *object_arg);
-
-
-/*
- * dbdisasm - AML disassembler
- */
-
-void
-acpi_db_display_op (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *origin,
-	u32                     num_opcodes);
-
-void
-acpi_db_display_namestring (
-	NATIVE_CHAR             *name);
-
-void
-acpi_db_display_path (
-	acpi_parse_object       *op);
-
-void
-acpi_db_display_opcode (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op);
-
-void
-acpi_db_decode_internal_object (
-	acpi_operand_object     *obj_desc);
-
-
-/*
- * dbdisply - debug display commands
- */
-
-
-void
-acpi_db_display_method_info (
-	acpi_parse_object       *op);
-
-void
-acpi_db_decode_and_display_object (
-	NATIVE_CHAR             *target,
-	NATIVE_CHAR             *output_type);
-
-void
-acpi_db_display_result_object (
-	acpi_operand_object     *obj_desc,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_db_display_all_methods (
-	NATIVE_CHAR             *display_count_arg);
-
-void
-acpi_db_display_internal_object (
-	acpi_operand_object     *obj_desc,
-	acpi_walk_state         *walk_state);
-
-void
-acpi_db_display_arguments (
-	void);
-
-void
-acpi_db_display_locals (
-	void);
-
-void
-acpi_db_display_results (
-	void);
-
-void
-acpi_db_display_calling_tree (
-	void);
-
-void
-acpi_db_display_argument_object (
-	acpi_operand_object     *obj_desc,
-	acpi_walk_state         *walk_state);
-
-
-/*
- * dbexec - debugger control method execution
- */
-
-void
-acpi_db_execute (
-	NATIVE_CHAR             *name,
-	NATIVE_CHAR             **args,
-	u32                     flags);
-
-void
-acpi_db_create_execution_threads (
-	NATIVE_CHAR             *num_threads_arg,
-	NATIVE_CHAR             *num_loops_arg,
-	NATIVE_CHAR             *method_name_arg);
-
-
-/*
- * dbfileio - Debugger file I/O commands
- */
-
-acpi_object_type8
-acpi_db_match_argument (
-	NATIVE_CHAR             *user_argument,
-	ARGUMENT_INFO           *arguments);
-
-
-void
-acpi_db_close_debug_file (
-	void);
-
-void
-acpi_db_open_debug_file (
-	NATIVE_CHAR             *name);
-
-acpi_status
-acpi_db_load_acpi_table (
-	NATIVE_CHAR             *filename);
-
-
-/*
- * dbhistry - debugger HISTORY command
- */
-
-void
-acpi_db_add_to_history (
-	NATIVE_CHAR             *command_line);
-
-void
-acpi_db_display_history (void);
-
-NATIVE_CHAR *
-acpi_db_get_from_history (
-	NATIVE_CHAR             *command_num_arg);
-
-
-/*
- * dbinput - user front-end to the AML debugger
- */
-
-acpi_status
-acpi_db_command_dispatch (
-	NATIVE_CHAR             *input_buffer,
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op);
-
-void
-acpi_db_execute_thread (
-	void                    *context);
-
-acpi_status
-acpi_db_user_commands (
-	NATIVE_CHAR             prompt,
-	acpi_parse_object       *op);
-
-
-/*
- * dbstats - Generation and display of ACPI table statistics
- */
-
-void
-acpi_db_generate_statistics (
-	acpi_parse_object       *root,
-	u8                      is_method);
-
-
-acpi_status
-acpi_db_display_statistics (
-	NATIVE_CHAR             *type_arg);
-
-
-/*
- * dbutils - AML debugger utilities
- */
-
-void
-acpi_db_set_output_destination (
-	u32                     where);
-
-void
-acpi_db_dump_buffer (
-	u32                     address);
-
-void
-acpi_db_dump_object (
-	acpi_object             *obj_desc,
-	u32                     level);
-
-void
-acpi_db_prep_namestring (
-	NATIVE_CHAR             *name);
-
-
-acpi_status
-acpi_db_second_pass_parse (
-	acpi_parse_object       *root);
-
-acpi_namespace_node *
-acpi_db_local_ns_lookup (
-	NATIVE_CHAR             *name);
-
-
-#endif  /* __ACDEBUG_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/acdispat.h linux-2.4.22-pre2/drivers/acpi/include/acdispat.h
--- linux-2.4.21/drivers/acpi/include/acdispat.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/acdispat.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,453 +0,0 @@
-/******************************************************************************
- *
- * Name: acdispat.h - dispatcher (parser to interpreter interface)
- *       $Revision: 45 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#ifndef _ACDISPAT_H_
-#define _ACDISPAT_H_
-
-
-#define NAMEOF_LOCAL_NTE    "__L0"
-#define NAMEOF_ARG_NTE      "__A0"
-
-
-/* Common interfaces */
-
-acpi_status
-acpi_ds_obj_stack_push (
-	void                    *object,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_obj_stack_pop (
-	u32                     pop_count,
-	acpi_walk_state         *walk_state);
-
-void *
-acpi_ds_obj_stack_get_value (
-	u32                     index,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_obj_stack_pop_object (
-	acpi_operand_object     **object,
-	acpi_walk_state         *walk_state);
-
-
-/* dsopcode - support for late evaluation */
-
-acpi_status
-acpi_ds_get_buffer_field_arguments (
-	acpi_operand_object     *obj_desc);
-
-acpi_status
-acpi_ds_get_region_arguments (
-	acpi_operand_object     *rgn_desc);
-
-
-/* dsctrl - Parser/Interpreter interface, control stack routines */
-
-
-acpi_status
-acpi_ds_exec_begin_control_op (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op);
-
-acpi_status
-acpi_ds_exec_end_control_op (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op);
-
-
-/* dsexec - Parser/Interpreter interface, method execution callbacks */
-
-
-acpi_status
-acpi_ds_get_predicate_value (
-	acpi_walk_state         *walk_state,
-	u32                     has_result_obj);
-
-acpi_status
-acpi_ds_exec_begin_op (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       **out_op);
-
-acpi_status
-acpi_ds_exec_end_op (
-	acpi_walk_state         *state);
-
-
-/* dsfield - Parser/Interpreter interface for AML fields */
-
-acpi_status
-acpi_ds_create_field (
-	acpi_parse_object       *op,
-	acpi_namespace_node     *region_node,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_create_bank_field (
-	acpi_parse_object       *op,
-	acpi_namespace_node     *region_node,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_create_index_field (
-	acpi_parse_object       *op,
-	acpi_namespace_node     *region_node,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_create_buffer_field (
-	acpi_parse_object       *op,
-	acpi_walk_state         *walk_state);
-
-
-/* dsload - Parser/Interpreter interface, namespace load callbacks */
-
-acpi_status
-acpi_ds_load1_begin_op (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       **out_op);
-
-acpi_status
-acpi_ds_load1_end_op (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_load2_begin_op (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       **out_op);
-
-acpi_status
-acpi_ds_load2_end_op (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_init_callbacks (
-	acpi_walk_state         *walk_state,
-	u32                     pass_number);
-
-
-/* dsmthdat - method data (locals/args) */
-
-
-acpi_status
-acpi_ds_store_object_to_local (
-	u16                     opcode,
-	u32                     index,
-	acpi_operand_object     *src_desc,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_method_data_get_entry (
-	u16                     opcode,
-	u32                     index,
-	acpi_walk_state         *walk_state,
-	acpi_operand_object     ***node);
-
-acpi_status
-acpi_ds_method_data_delete_all (
-	acpi_walk_state         *walk_state);
-
-u8
-acpi_ds_is_method_value (
-	acpi_operand_object     *obj_desc);
-
-acpi_object_type8
-acpi_ds_method_data_get_type (
-	u16                     opcode,
-	u32                     index,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_method_data_get_value (
-	u16                     opcode,
-	u32                     index,
-	acpi_walk_state         *walk_state,
-	acpi_operand_object     **dest_desc);
-
-acpi_status
-acpi_ds_method_data_delete_value (
-	u16                     opcode,
-	u32                     index,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_method_data_init_args (
-	acpi_operand_object     **params,
-	u32                     max_param_count,
-	acpi_walk_state         *walk_state);
-
-acpi_namespace_node *
-acpi_ds_method_data_get_node (
-	u16                     opcode,
-	u32                     index,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_method_data_init (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_method_data_set_entry (
-	u16                     opcode,
-	u32                     index,
-	acpi_operand_object     *object,
-	acpi_walk_state         *walk_state);
-
-
-/* dsmethod - Parser/Interpreter interface - control method parsing */
-
-acpi_status
-acpi_ds_parse_method (
-	acpi_handle             obj_handle);
-
-acpi_status
-acpi_ds_call_control_method (
-	acpi_walk_list          *walk_list,
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op);
-
-acpi_status
-acpi_ds_restart_control_method (
-	acpi_walk_state         *walk_state,
-	acpi_operand_object     *return_desc);
-
-acpi_status
-acpi_ds_terminate_control_method (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_begin_method_execution (
-	acpi_namespace_node     *method_node,
-	acpi_operand_object     *obj_desc,
-	acpi_namespace_node     *calling_method_node);
-
-
-/* dsobj - Parser/Interpreter interface - object initialization and conversion */
-
-acpi_status
-acpi_ds_init_one_object (
-	acpi_handle             obj_handle,
-	u32                     level,
-	void                    *context,
-	void                    **return_value);
-
-acpi_status
-acpi_ds_initialize_objects (
-	acpi_table_desc         *table_desc,
-	acpi_namespace_node     *start_node);
-
-acpi_status
-acpi_ds_build_internal_package_obj (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op,
-	acpi_operand_object     **obj_desc);
-
-acpi_status
-acpi_ds_build_internal_object (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op,
-	acpi_operand_object     **obj_desc_ptr);
-
-acpi_status
-acpi_ds_init_object_from_op (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op,
-	u16                     opcode,
-	acpi_operand_object     **obj_desc);
-
-acpi_status
-acpi_ds_create_node (
-	acpi_walk_state         *walk_state,
-	acpi_namespace_node     *node,
-	acpi_parse_object       *op);
-
-
-/* dsregn - Parser/Interpreter interface - Op Region parsing */
-
-acpi_status
-acpi_ds_eval_buffer_field_operands (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op);
-
-acpi_status
-acpi_ds_eval_region_operands (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op);
-
-acpi_status
-acpi_ds_initialize_region (
-	acpi_handle             obj_handle);
-
-
-/* dsutils - Parser/Interpreter interface utility routines */
-
-u8
-acpi_ds_is_result_used (
-	acpi_parse_object       *op,
-	acpi_walk_state         *walk_state);
-
-void
-acpi_ds_delete_result_if_not_used (
-	acpi_parse_object       *op,
-	acpi_operand_object     *result_obj,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_create_operand (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *arg,
-	u32                     args_remaining);
-
-acpi_status
-acpi_ds_create_operands (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *first_arg);
-
-acpi_status
-acpi_ds_resolve_operands (
-	acpi_walk_state         *walk_state);
-
-acpi_object_type8
-acpi_ds_map_opcode_to_data_type (
-	u16                     opcode,
-	u32                     *out_flags);
-
-acpi_object_type8
-acpi_ds_map_named_opcode_to_data_type (
-	u16                     opcode);
-
-
-/*
- * dswscope - Scope Stack manipulation
- */
-
-acpi_status
-acpi_ds_scope_stack_push (
-	acpi_namespace_node     *node,
-	acpi_object_type8       type,
-	acpi_walk_state         *walk_state);
-
-
-acpi_status
-acpi_ds_scope_stack_pop (
-	acpi_walk_state         *walk_state);
-
-void
-acpi_ds_scope_stack_clear (
-	acpi_walk_state         *walk_state);
-
-
-/* dswstate - parser WALK_STATE management routines */
-
-acpi_walk_state *
-acpi_ds_create_walk_state (
-	acpi_owner_id           owner_id,
-	acpi_parse_object       *origin,
-	acpi_operand_object     *mth_desc,
-	acpi_walk_list          *walk_list);
-
-acpi_status
-acpi_ds_init_aml_walk (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op,
-	acpi_namespace_node     *method_node,
-	u8                      *aml_start,
-	u32                     aml_length,
-	acpi_operand_object     **params,
-	acpi_operand_object     **return_obj_desc,
-	u32                     pass_number);
-
-acpi_status
-acpi_ds_obj_stack_delete_all (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_obj_stack_pop_and_delete (
-	u32                     pop_count,
-	acpi_walk_state         *walk_state);
-
-void
-acpi_ds_delete_walk_state (
-	acpi_walk_state         *walk_state);
-
-acpi_walk_state *
-acpi_ds_pop_walk_state (
-	acpi_walk_list          *walk_list);
-
-void
-acpi_ds_push_walk_state (
-	acpi_walk_state         *walk_state,
-	acpi_walk_list          *walk_list);
-
-acpi_status
-acpi_ds_result_stack_pop (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_result_stack_push (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_result_stack_clear (
-	acpi_walk_state         *walk_state);
-
-acpi_walk_state *
-acpi_ds_get_current_walk_state (
-	acpi_walk_list          *walk_list);
-
-void
-acpi_ds_delete_walk_state_cache (
-	void);
-
-acpi_status
-acpi_ds_result_insert (
-	void                    *object,
-	u32                     index,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_result_remove (
-	acpi_operand_object     **object,
-	u32                     index,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_result_pop (
-	acpi_operand_object     **object,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_result_push (
-	acpi_operand_object     *object,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ds_result_pop_from_bottom (
-	acpi_operand_object     **object,
-	acpi_walk_state         *walk_state);
-
-#endif /* _ACDISPAT_H_ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/acevents.h linux-2.4.22-pre2/drivers/acpi/include/acevents.h
--- linux-2.4.21/drivers/acpi/include/acevents.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/acevents.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,217 +0,0 @@
-/******************************************************************************
- *
- * Name: acevents.h - Event subcomponent prototypes and defines
- *       $Revision: 66 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACEVENTS_H__
-#define __ACEVENTS_H__
-
-
-acpi_status
-acpi_ev_initialize (
-	void);
-
-
-/*
- * Acpi_evfixed - Fixed event handling
- */
-
-acpi_status
-acpi_ev_fixed_event_initialize (
-	void);
-
-u32
-acpi_ev_fixed_event_detect (
-	void);
-
-u32
-acpi_ev_fixed_event_dispatch (
-	u32                     acpi_event);
-
-
-/*
- * Acpi_evglock - Global Lock support
- */
-
-acpi_status
-acpi_ev_acquire_global_lock(
-	void);
-
-void
-acpi_ev_release_global_lock(
-	void);
-
-acpi_status
-acpi_ev_init_global_lock_handler (
-	void);
-
-
-/*
- * Acpi_evgpe - GPE handling and dispatch
- */
-
-acpi_status
-acpi_ev_gpe_initialize (
-	void);
-
-acpi_status
-acpi_ev_init_gpe_control_methods (
-	void);
-
-u32
-acpi_ev_gpe_dispatch (
-	u32                     gpe_number);
-
-u32
-acpi_ev_gpe_detect (
-	void);
-
-
-/*
- * Acpi_evnotify - Device Notify handling and dispatch
- */
-
-acpi_status
-acpi_ev_queue_notify_request (
-	acpi_namespace_node     *node,
-	u32                     notify_value);
-
-void
-acpi_ev_notify_dispatch (
-	void                    *context);
-
-/*
- * Acpi_evregion - Address Space handling
- */
-
-acpi_status
-acpi_ev_install_default_address_space_handlers (
-	void);
-
-acpi_status
-acpi_ev_address_space_dispatch (
-	acpi_operand_object    *region_obj,
-	u32                     function,
-	ACPI_PHYSICAL_ADDRESS   address,
-	u32                     bit_width,
-	u32                     *value);
-
-
-acpi_status
-acpi_ev_addr_handler_helper (
-	acpi_handle             obj_handle,
-	u32                     level,
-	void                    *context,
-	void                    **return_value);
-
-void
-acpi_ev_disassociate_region_from_handler(
-	acpi_operand_object    *region_obj,
-	u8                      acpi_ns_is_locked);
-
-
-acpi_status
-acpi_ev_associate_region_and_handler (
-	acpi_operand_object     *handler_obj,
-	acpi_operand_object     *region_obj,
-	u8                      acpi_ns_is_locked);
-
-
-/*
- * Acpi_evregini - Region initialization and setup
- */
-
-acpi_status
-acpi_ev_system_memory_region_setup (
-	acpi_handle             handle,
-	u32                     function,
-	void                    *handler_context,
-	void                    **region_context);
-
-acpi_status
-acpi_ev_io_space_region_setup (
-	acpi_handle             handle,
-	u32                     function,
-	void                    *handler_context,
-	void                    **region_context);
-
-acpi_status
-acpi_ev_pci_config_region_setup (
-	acpi_handle             handle,
-	u32                     function,
-	void                    *handler_context,
-	void                    **region_context);
-
-acpi_status
-acpi_ev_cmos_region_setup (
-	acpi_handle             handle,
-	u32                     function,
-	void                    *handler_context,
-	void                    **region_context);
-
-acpi_status
-acpi_ev_pci_bar_region_setup (
-	acpi_handle             handle,
-	u32                     function,
-	void                    *handler_context,
-	void                    **region_context);
-
-acpi_status
-acpi_ev_default_region_setup (
-	acpi_handle             handle,
-	u32                     function,
-	void                    *handler_context,
-	void                    **region_context);
-
-acpi_status
-acpi_ev_initialize_region (
-	acpi_operand_object     *region_obj,
-	u8                      acpi_ns_locked);
-
-
-/*
- * Evsci - SCI (System Control Interrupt) handling/dispatch
- */
-
-u32
-acpi_ev_install_sci_handler (
-	void);
-
-acpi_status
-acpi_ev_remove_sci_handler (
-	void);
-
-u32
-acpi_ev_initialize_sCI (
-	u32                     program_sCI);
-
-void
-acpi_ev_restore_acpi_state (
-	void);
-
-void
-acpi_ev_terminate (
-	void);
-
-
-#endif  /* __ACEVENTS_H__  */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/acexcep.h linux-2.4.22-pre2/drivers/acpi/include/acexcep.h
--- linux-2.4.21/drivers/acpi/include/acexcep.h	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/acexcep.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,248 +0,0 @@
-/******************************************************************************
- *
- * Name: acexcep.h - Exception codes returned by the ACPI subsystem
- *       $Revision: 50 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACEXCEP_H__
-#define __ACEXCEP_H__
-
-
-/*
- * Exceptions returned by external ACPI interfaces
- */
-
-#define AE_CODE_ENVIRONMENTAL           0x0000
-#define AE_CODE_PROGRAMMER              0x1000
-#define AE_CODE_ACPI_TABLES             0x2000
-#define AE_CODE_AML                     0x3000
-#define AE_CODE_CONTROL                 0x4000
-#define AE_CODE_MASK                    0xF000
-
-
-#define ACPI_SUCCESS(a)                 (!(a))
-#define ACPI_FAILURE(a)                 (a)
-
-
-#define AE_OK                           (acpi_status) 0x0000
-
-/*
- * Environmental exceptions
- */
-#define AE_ERROR                        (acpi_status) (0x0001 | AE_CODE_ENVIRONMENTAL)
-#define AE_NO_ACPI_TABLES               (acpi_status) (0x0002 | AE_CODE_ENVIRONMENTAL)
-#define AE_NO_NAMESPACE                 (acpi_status) (0x0003 | AE_CODE_ENVIRONMENTAL)
-#define AE_NO_MEMORY                    (acpi_status) (0x0004 | AE_CODE_ENVIRONMENTAL)
-#define AE_NOT_FOUND                    (acpi_status) (0x0005 | AE_CODE_ENVIRONMENTAL)
-#define AE_NOT_EXIST                    (acpi_status) (0x0006 | AE_CODE_ENVIRONMENTAL)
-#define AE_EXIST                        (acpi_status) (0x0007 | AE_CODE_ENVIRONMENTAL)
-#define AE_TYPE                         (acpi_status) (0x0008 | AE_CODE_ENVIRONMENTAL)
-#define AE_NULL_OBJECT                  (acpi_status) (0x0009 | AE_CODE_ENVIRONMENTAL)
-#define AE_NULL_ENTRY                   (acpi_status) (0x000A | AE_CODE_ENVIRONMENTAL)
-#define AE_BUFFER_OVERFLOW              (acpi_status) (0x000B | AE_CODE_ENVIRONMENTAL)
-#define AE_STACK_OVERFLOW               (acpi_status) (0x000C | AE_CODE_ENVIRONMENTAL)
-#define AE_STACK_UNDERFLOW              (acpi_status) (0x000D | AE_CODE_ENVIRONMENTAL)
-#define AE_NOT_IMPLEMENTED              (acpi_status) (0x000E | AE_CODE_ENVIRONMENTAL)
-#define AE_VERSION_MISMATCH             (acpi_status) (0x000F | AE_CODE_ENVIRONMENTAL)
-#define AE_SUPPORT                      (acpi_status) (0x0010 | AE_CODE_ENVIRONMENTAL)
-#define AE_SHARE                        (acpi_status) (0x0011 | AE_CODE_ENVIRONMENTAL)
-#define AE_LIMIT                        (acpi_status) (0x0012 | AE_CODE_ENVIRONMENTAL)
-#define AE_TIME                         (acpi_status) (0x0013 | AE_CODE_ENVIRONMENTAL)
-#define AE_UNKNOWN_STATUS               (acpi_status) (0x0014 | AE_CODE_ENVIRONMENTAL)
-#define AE_ACQUIRE_DEADLOCK             (acpi_status) (0x0015 | AE_CODE_ENVIRONMENTAL)
-#define AE_RELEASE_DEADLOCK             (acpi_status) (0x0016 | AE_CODE_ENVIRONMENTAL)
-#define AE_NOT_ACQUIRED                 (acpi_status) (0x0017 | AE_CODE_ENVIRONMENTAL)
-#define AE_ALREADY_ACQUIRED             (acpi_status) (0x0018 | AE_CODE_ENVIRONMENTAL)
-#define AE_NO_HARDWARE_RESPONSE         (acpi_status) (0x0019 | AE_CODE_ENVIRONMENTAL)
-#define AE_NO_GLOBAL_LOCK               (acpi_status) (0x001A | AE_CODE_ENVIRONMENTAL)
-
-#define AE_CODE_ENV_MAX                 0x001A
-
-/*
- * Programmer exceptions
- */
-#define AE_BAD_PARAMETER                (acpi_status) (0x0001 | AE_CODE_PROGRAMMER)
-#define AE_BAD_CHARACTER                (acpi_status) (0x0002 | AE_CODE_PROGRAMMER)
-#define AE_BAD_PATHNAME                 (acpi_status) (0x0003 | AE_CODE_PROGRAMMER)
-#define AE_BAD_DATA                     (acpi_status) (0x0004 | AE_CODE_PROGRAMMER)
-#define AE_BAD_ADDRESS                  (acpi_status) (0x0005 | AE_CODE_PROGRAMMER)
-
-#define AE_CODE_PGM_MAX                 0x0005
-
-
-/*
- * Acpi table exceptions
- */
-#define AE_BAD_SIGNATURE                (acpi_status) (0x0001 | AE_CODE_ACPI_TABLES)
-#define AE_BAD_HEADER                   (acpi_status) (0x0002 | AE_CODE_ACPI_TABLES)
-#define AE_BAD_CHECKSUM                 (acpi_status) (0x0003 | AE_CODE_ACPI_TABLES)
-#define AE_BAD_VALUE                    (acpi_status) (0x0004 | AE_CODE_ACPI_TABLES)
-
-#define AE_CODE_TBL_MAX                 0x0003
-
-
-/*
- * AML exceptions.  These are caused by problems with
- * the actual AML byte stream
- */
-#define AE_AML_ERROR                    (acpi_status) (0x0001 | AE_CODE_AML)
-#define AE_AML_PARSE                    (acpi_status) (0x0002 | AE_CODE_AML)
-#define AE_AML_BAD_OPCODE               (acpi_status) (0x0003 | AE_CODE_AML)
-#define AE_AML_NO_OPERAND               (acpi_status) (0x0004 | AE_CODE_AML)
-#define AE_AML_OPERAND_TYPE             (acpi_status) (0x0005 | AE_CODE_AML)
-#define AE_AML_OPERAND_VALUE            (acpi_status) (0x0006 | AE_CODE_AML)
-#define AE_AML_UNINITIALIZED_LOCAL      (acpi_status) (0x0007 | AE_CODE_AML)
-#define AE_AML_UNINITIALIZED_ARG        (acpi_status) (0x0008 | AE_CODE_AML)
-#define AE_AML_UNINITIALIZED_ELEMENT    (acpi_status) (0x0009 | AE_CODE_AML)
-#define AE_AML_NUMERIC_OVERFLOW         (acpi_status) (0x000A | AE_CODE_AML)
-#define AE_AML_REGION_LIMIT             (acpi_status) (0x000B | AE_CODE_AML)
-#define AE_AML_BUFFER_LIMIT             (acpi_status) (0x000C | AE_CODE_AML)
-#define AE_AML_PACKAGE_LIMIT            (acpi_status) (0x000D | AE_CODE_AML)
-#define AE_AML_DIVIDE_BY_ZERO           (acpi_status) (0x000E | AE_CODE_AML)
-#define AE_AML_BAD_NAME                 (acpi_status) (0x000F | AE_CODE_AML)
-#define AE_AML_NAME_NOT_FOUND           (acpi_status) (0x0010 | AE_CODE_AML)
-#define AE_AML_INTERNAL                 (acpi_status) (0x0011 | AE_CODE_AML)
-#define AE_AML_INVALID_SPACE_ID         (acpi_status) (0x0012 | AE_CODE_AML)
-#define AE_AML_STRING_LIMIT             (acpi_status) (0x0013 | AE_CODE_AML)
-#define AE_AML_NO_RETURN_VALUE          (acpi_status) (0x0014 | AE_CODE_AML)
-#define AE_AML_METHOD_LIMIT             (acpi_status) (0x0015 | AE_CODE_AML)
-#define AE_AML_NOT_OWNER                (acpi_status) (0x0016 | AE_CODE_AML)
-#define AE_AML_MUTEX_ORDER              (acpi_status) (0x0017 | AE_CODE_AML)
-#define AE_AML_MUTEX_NOT_ACQUIRED       (acpi_status) (0x0018 | AE_CODE_AML)
-#define AE_AML_INVALID_RESOURCE_TYPE    (acpi_status) (0x0019 | AE_CODE_AML)
-
-#define AE_CODE_AML_MAX                 0x0019
-
-/*
- * Internal exceptions used for control
- */
-#define AE_CTRL_RETURN_VALUE            (acpi_status) (0x0001 | AE_CODE_CONTROL)
-#define AE_CTRL_PENDING                 (acpi_status) (0x0002 | AE_CODE_CONTROL)
-#define AE_CTRL_TERMINATE               (acpi_status) (0x0003 | AE_CODE_CONTROL)
-#define AE_CTRL_TRUE                    (acpi_status) (0x0004 | AE_CODE_CONTROL)
-#define AE_CTRL_FALSE                   (acpi_status) (0x0005 | AE_CODE_CONTROL)
-#define AE_CTRL_DEPTH                   (acpi_status) (0x0006 | AE_CODE_CONTROL)
-#define AE_CTRL_END                     (acpi_status) (0x0007 | AE_CODE_CONTROL)
-#define AE_CTRL_TRANSFER                (acpi_status) (0x0008 | AE_CODE_CONTROL)
-
-#define AE_CODE_CTRL_MAX                0x0008
-
-
-#ifdef DEFINE_ACPI_GLOBALS
-
-/*
- * String versions of the exception codes above
- * These strings must match the corresponding defines exactly
- */
-NATIVE_CHAR const   *acpi_gbl_exception_names_env[] =
-{
-	"AE_OK",
-	"AE_ERROR",
-	"AE_NO_ACPI_TABLES",
-	"AE_NO_NAMESPACE",
-	"AE_NO_MEMORY",
-	"AE_NOT_FOUND",
-	"AE_NOT_EXIST",
-	"AE_EXIST",
-	"AE_TYPE",
-	"AE_NULL_OBJECT",
-	"AE_NULL_ENTRY",
-	"AE_BUFFER_OVERFLOW",
-	"AE_STACK_OVERFLOW",
-	"AE_STACK_UNDERFLOW",
-	"AE_NOT_IMPLEMENTED",
-	"AE_VERSION_MISMATCH",
-	"AE_SUPPORT",
-	"AE_SHARE",
-	"AE_LIMIT",
-	"AE_TIME",
-	"AE_UNKNOWN_STATUS",
-	"AE_ACQUIRE_DEADLOCK",
-	"AE_RELEASE_DEADLOCK",
-	"AE_NOT_ACQUIRED",
-	"AE_ALREADY_ACQUIRED",
-	"AE_NO_HARDWARE_RESPONSE",
-	"AE_NO_GLOBAL_LOCK",
-};
-
-NATIVE_CHAR const   *acpi_gbl_exception_names_pgm[] =
-{
-	"AE_BAD_PARAMETER",
-	"AE_BAD_CHARACTER",
-	"AE_BAD_PATHNAME",
-	"AE_BAD_DATA",
-	"AE_BAD_ADDRESS",
-};
-
-NATIVE_CHAR const   *acpi_gbl_exception_names_tbl[] =
-{
-	"AE_BAD_SIGNATURE",
-	"AE_BAD_HEADER",
-	"AE_BAD_CHECKSUM",
-	"AE_BAD_VALUE",
-};
-
-NATIVE_CHAR const   *acpi_gbl_exception_names_aml[] =
-{
-	"AE_AML_ERROR",
-	"AE_AML_PARSE",
-	"AE_AML_BAD_OPCODE",
-	"AE_AML_NO_OPERAND",
-	"AE_AML_OPERAND_TYPE",
-	"AE_AML_OPERAND_VALUE",
-	"AE_AML_UNINITIALIZED_LOCAL",
-	"AE_AML_UNINITIALIZED_ARG",
-	"AE_AML_UNINITIALIZED_ELEMENT",
-	"AE_AML_NUMERIC_OVERFLOW",
-	"AE_AML_REGION_LIMIT",
-	"AE_AML_BUFFER_LIMIT",
-	"AE_AML_PACKAGE_LIMIT",
-	"AE_AML_DIVIDE_BY_ZERO",
-	"AE_AML_BAD_NAME",
-	"AE_AML_NAME_NOT_FOUND",
-	"AE_AML_INTERNAL",
-	"AE_AML_INVALID_SPACE_ID",
-	"AE_AML_STRING_LIMIT",
-	"AE_AML_NO_RETURN_VALUE",
-	"AE_AML_METHOD_LIMIT",
-	"AE_AML_NOT_OWNER",
-	"AE_AML_MUTEX_ORDER",
-	"AE_AML_MUTEX_NOT_ACQUIRED",
-	"AE_AML_INVALID_RESOURCE_TYPE",
-};
-
-NATIVE_CHAR const   *acpi_gbl_exception_names_ctrl[] =
-{
-	"AE_CTRL_RETURN_VALUE",
-	"AE_CTRL_PENDING",
-	"AE_CTRL_TERMINATE",
-	"AE_CTRL_TRUE",
-	"AE_CTRL_FALSE",
-	"AE_CTRL_DEPTH",
-	"AE_CTRL_END",
-	"AE_CTRL_TRANSFER",
-};
-
-#endif /* ACPI GLOBALS */
-
-
-#endif /* __ACEXCEP_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/acglobal.h linux-2.4.22-pre2/drivers/acpi/include/acglobal.h
--- linux-2.4.21/drivers/acpi/include/acglobal.h	2002-11-28 23:53:12.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/acglobal.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,232 +0,0 @@
-/******************************************************************************
- *
- * Name: acglobal.h - Declarations for global variables
- *       $Revision: 106 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACGLOBAL_H__
-#define __ACGLOBAL_H__
-
-
-/*
- * Ensure that the globals are actually defined only once.
- *
- * The use of these defines allows a single list of globals (here) in order
- * to simplify maintenance of the code.
- */
-#ifdef DEFINE_ACPI_GLOBALS
-#define ACPI_EXTERN
-#else
-#define ACPI_EXTERN extern
-#endif
-
-
-/*****************************************************************************
- *
- * Debug support
- *
- ****************************************************************************/
-
-/* Runtime configuration of debug print levels */
-
-extern      u32                         acpi_dbg_level;
-extern      u32                         acpi_dbg_layer;
-
-/* Procedure nesting level for debug output */
-
-extern      u32                         acpi_gbl_nesting_level;
-
-
-/*****************************************************************************
- *
- * ACPI Table globals
- *
- ****************************************************************************/
-
-/*
- * Table pointers.
- * Although these pointers are somewhat redundant with the global Acpi_table,
- * they are convenient because they are typed pointers.
- *
- * These tables are single-table only; meaning that there can be at most one
- * of each in the system.  Each global points to the actual table.
- *
- */
-ACPI_EXTERN RSDP_DESCRIPTOR             *acpi_gbl_RSDP;
-ACPI_EXTERN xsdt_descriptor             *acpi_gbl_XSDT;
-ACPI_EXTERN FADT_DESCRIPTOR             *acpi_gbl_FADT;
-ACPI_EXTERN acpi_table_header           *acpi_gbl_DSDT;
-ACPI_EXTERN acpi_common_facs            *acpi_gbl_FACS;
-
-/*
- * Since there may be multiple SSDTs and PSDTS, a single pointer is not
- * sufficient; Therefore, there isn't one!
- */
-
-
-/*
- * ACPI Table info arrays
- */
-extern      acpi_table_desc             acpi_gbl_acpi_tables[NUM_ACPI_TABLES];
-extern      ACPI_TABLE_SUPPORT          acpi_gbl_acpi_table_data[NUM_ACPI_TABLES];
-
-/*
- * Predefined mutex objects.  This array contains the
- * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs.
- * (The table maps local handles to the real OS handles)
- */
-ACPI_EXTERN acpi_mutex_info             acpi_gbl_acpi_mutex_info [NUM_MTX];
-
-
-/*****************************************************************************
- *
- * Miscellaneous globals
- *
- ****************************************************************************/
-
-
-ACPI_EXTERN ACPI_MEMORY_LIST            acpi_gbl_memory_lists[ACPI_NUM_MEM_LISTS];
-ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER  acpi_gbl_drv_notify;
-ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER  acpi_gbl_sys_notify;
-ACPI_EXTERN u8                         *acpi_gbl_gpe0enable_register_save;
-ACPI_EXTERN u8                         *acpi_gbl_gpe1_enable_register_save;
-ACPI_EXTERN acpi_walk_state            *acpi_gbl_breakpoint_walk;
-ACPI_EXTERN acpi_handle                 acpi_gbl_global_lock_semaphore;
-
-ACPI_EXTERN u32                         acpi_gbl_global_lock_thread_count;
-ACPI_EXTERN u32                         acpi_gbl_restore_acpi_chipset;
-ACPI_EXTERN u32                         acpi_gbl_original_mode;
-ACPI_EXTERN u32                         acpi_gbl_edge_level_save;
-ACPI_EXTERN u32                         acpi_gbl_irq_enable_save;
-ACPI_EXTERN u32                         acpi_gbl_rsdp_original_location;
-ACPI_EXTERN u32                         acpi_gbl_ns_lookup_count;
-ACPI_EXTERN u32                         acpi_gbl_ps_find_count;
-ACPI_EXTERN u16                         acpi_gbl_pm1_enable_register_save;
-ACPI_EXTERN u16                         acpi_gbl_next_table_owner_id;
-ACPI_EXTERN u16                         acpi_gbl_next_method_owner_id;
-ACPI_EXTERN u8                          acpi_gbl_debugger_configuration;
-ACPI_EXTERN u8                          acpi_gbl_global_lock_acquired;
-ACPI_EXTERN u8                          acpi_gbl_step_to_next_call;
-ACPI_EXTERN u8                          acpi_gbl_acpi_hardware_present;
-ACPI_EXTERN u8                          acpi_gbl_global_lock_present;
-
-extern u8                               acpi_gbl_shutdown;
-extern u32                              acpi_gbl_system_flags;
-extern u32                              acpi_gbl_startup_flags;
-extern const u8                         acpi_gbl_decode_to8bit[8];
-extern const NATIVE_CHAR                *acpi_gbl_db_sleep_states[ACPI_NUM_SLEEP_STATES];
-
-
-/*****************************************************************************
- *
- * Namespace globals
- *
- ****************************************************************************/
-
-#define NUM_NS_TYPES                    INTERNAL_TYPE_INVALID+1
-#define NUM_PREDEFINED_NAMES            9
-
-
-ACPI_EXTERN acpi_namespace_node         acpi_gbl_root_node_struct;
-ACPI_EXTERN acpi_namespace_node        *acpi_gbl_root_node;
-
-extern const u8                         acpi_gbl_ns_properties[NUM_NS_TYPES];
-extern const predefined_names           acpi_gbl_pre_defined_names [NUM_PREDEFINED_NAMES];
-
-#ifdef ACPI_DEBUG
-ACPI_EXTERN u32                         acpi_gbl_current_node_count;
-ACPI_EXTERN u32                         acpi_gbl_current_node_size;
-ACPI_EXTERN u32                         acpi_gbl_max_concurrent_node_count;
-ACPI_EXTERN unsigned long               acpi_gbl_entry_stack_pointer;
-ACPI_EXTERN u32                         acpi_gbl_lowest_stack_pointer;
-ACPI_EXTERN u32                         acpi_gbl_deepest_nesting;
-#endif
-
-/*****************************************************************************
- *
- * Interpreter globals
- *
- ****************************************************************************/
-
-
-ACPI_EXTERN acpi_walk_list             *acpi_gbl_current_walk_list;
-
-/* Address Space handlers */
-
-ACPI_EXTERN acpi_adr_space_info         acpi_gbl_address_spaces[ACPI_NUM_ADDRESS_SPACES];
-
-/* Control method single step flag */
-
-ACPI_EXTERN u8                          acpi_gbl_cm_single_step;
-
-
-/*****************************************************************************
- *
- * Parser globals
- *
- ****************************************************************************/
-
-ACPI_EXTERN acpi_parse_object           *acpi_gbl_parsed_namespace_root;
-
-
-/*****************************************************************************
- *
- * Event globals
- *
- ****************************************************************************/
-
-ACPI_EXTERN acpi_fixed_event_info       acpi_gbl_fixed_event_handlers[ACPI_NUM_FIXED_EVENTS];
-ACPI_EXTERN acpi_handle                 acpi_gbl_gpe_obj_handle;
-ACPI_EXTERN u32                         acpi_gbl_gpe_register_count;
-ACPI_EXTERN acpi_gpe_registers         *acpi_gbl_gpe_registers;
-ACPI_EXTERN acpi_gpe_level_info        *acpi_gbl_gpe_info;
-
-/*
- * Gpe validation and translation table
- * Indexed by the GPE number, returns GPE_INVALID if the GPE is not supported.
- * Otherwise, returns a valid index into the global GPE table.
- *
- * This table is needed because the GPE numbers supported by block 1 do not
- * have to be contiguous with the GPE numbers supported by block 0.
- */
-ACPI_EXTERN u8                          acpi_gbl_gpe_valid [ACPI_NUM_GPE];
-
-/* Acpi_event counter for debug only */
-
-#ifdef ACPI_DEBUG
-ACPI_EXTERN u32                         acpi_gbl_event_count[ACPI_NUM_FIXED_EVENTS];
-#endif
-
-
-/*****************************************************************************
- *
- * Debugger globals
- *
- ****************************************************************************/
-
-#ifdef ENABLE_DEBUGGER
-ACPI_EXTERN u8                          acpi_gbl_method_executing;
-ACPI_EXTERN u8                          acpi_gbl_db_terminate_threads;
-#endif
-
-
-#endif /* __ACGLOBAL_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/achware.h linux-2.4.22-pre2/drivers/acpi/include/achware.h
--- linux-2.4.21/drivers/acpi/include/achware.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/achware.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,166 +0,0 @@
-/******************************************************************************
- *
- * Name: achware.h -- hardware specific interfaces
- *       $Revision: 56 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACHWARE_H__
-#define __ACHWARE_H__
-
-
-/* PM Timer ticks per second (HZ) */
-#define PM_TIMER_FREQUENCY  3579545
-
-
-/* Prototypes */
-
-
-acpi_status
-acpi_hw_initialize (
-	void);
-
-acpi_status
-acpi_hw_shutdown (
-	void);
-
-acpi_status
-acpi_hw_initialize_system_info (
-	void);
-
-acpi_status
-acpi_hw_set_mode (
-	u32                     mode);
-
-u32
-acpi_hw_get_mode (
-	void);
-
-u32
-acpi_hw_get_mode_capabilities (
-	void);
-
-/* Register I/O Prototypes */
-
-
-u32
-acpi_hw_register_bit_access (
-	NATIVE_UINT             read_write,
-	u8                      use_lock,
-	u32                     register_id,
-	... /* DWORD Write Value */);
-
-u32
-acpi_hw_register_read (
-	u8                      use_lock,
-	u32                     register_id);
-
-void
-acpi_hw_register_write (
-	u8                      use_lock,
-	u32                     register_id,
-	u32                     value);
-
-u32
-acpi_hw_low_level_read (
-	u32                     width,
-	acpi_generic_address    *reg,
-	u32                     offset);
-
-void
-acpi_hw_low_level_write (
-	u32                     width,
-	u32                     value,
-	acpi_generic_address    *reg,
-	u32                     offset);
-
-void
-acpi_hw_clear_acpi_status (
-   void);
-
-u32
-acpi_hw_get_bit_shift (
-	u32                     mask);
-
-
-/* GPE support */
-
-void
-acpi_hw_enable_gpe (
-	u32                     gpe_number);
-
-void
-acpi_hw_enable_gpe_for_wakeup (
-	u32                     gpe_number);
-
-void
-acpi_hw_disable_gpe (
-	u32                     gpe_number);
-
-void
-acpi_hw_disable_gpe_for_wakeup (
-	u32                     gpe_number);
-
-void
-acpi_hw_clear_gpe (
-	u32                     gpe_number);
-
-void
-acpi_hw_get_gpe_status (
-	u32                     gpe_number,
-	acpi_event_status       *event_status);
-
-void
-acpi_hw_disable_non_wakeup_gpes (
-	void);
-
-void
-acpi_hw_enable_non_wakeup_gpes (
-	void);
-
-
-/* Sleep Prototypes */
-
-acpi_status
-acpi_hw_obtain_sleep_type_register_data (
-	u8                      sleep_state,
-	u8                      *slp_typ_a,
-	u8                      *slp_typ_b);
-
-
-/* ACPI Timer prototypes */
-
-acpi_status
-acpi_get_timer_resolution (
-	u32                     *resolution);
-
-acpi_status
-acpi_get_timer (
-	u32                     *ticks);
-
-acpi_status
-acpi_get_timer_duration (
-	u32                     start_ticks,
-	u32                     end_ticks,
-	u32                     *time_elapsed);
-
-
-#endif /* __ACHWARE_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/acinterp.h linux-2.4.22-pre2/drivers/acpi/include/acinterp.h
--- linux-2.4.21/drivers/acpi/include/acinterp.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/acinterp.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,704 +0,0 @@
-/******************************************************************************
- *
- * Name: acinterp.h - Interpreter subcomponent prototypes and defines
- *       $Revision: 116 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACINTERP_H__
-#define __ACINTERP_H__
-
-
-#define WALK_OPERANDS       &(walk_state->operands [walk_state->num_operands -1])
-
-
-/* Interpreter constants */
-
-#define AML_END_OF_BLOCK            -1
-#define PUSH_PKG_LENGTH             1
-#define DO_NOT_PUSH_PKG_LENGTH      0
-
-
-#define STACK_TOP                   0
-#define STACK_BOTTOM                (u32) -1
-
-/* Constants for global "When_to_parse_methods" */
-
-#define METHOD_PARSE_AT_INIT        0x0
-#define METHOD_PARSE_JUST_IN_TIME   0x1
-#define METHOD_DELETE_AT_COMPLETION 0x2
-
-
-acpi_status
-acpi_ex_resolve_operands (
-	u16                     opcode,
-	acpi_operand_object     **stack_ptr,
-	acpi_walk_state         *walk_state);
-
-
-/*
- * amxface - External interpreter interfaces
- */
-
-acpi_status
-acpi_ex_load_table (
-	acpi_table_type         table_id);
-
-acpi_status
-acpi_ex_execute_method (
-	acpi_namespace_node     *method_node,
-	acpi_operand_object     **params,
-	acpi_operand_object     **return_obj_desc);
-
-
-/*
- * amconvrt - object conversion
- */
-
-acpi_status
-acpi_ex_convert_to_integer (
-	acpi_operand_object     *obj_desc,
-	acpi_operand_object     **result_desc,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_convert_to_buffer (
-	acpi_operand_object     *obj_desc,
-	acpi_operand_object     **result_desc,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_convert_to_string (
-	acpi_operand_object     *obj_desc,
-	acpi_operand_object     **result_desc,
-	u32                     base,
-	u32                     max_length,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_convert_to_target_type (
-	acpi_object_type8       destination_type,
-	acpi_operand_object     **obj_desc,
-	acpi_walk_state         *walk_state);
-
-
-/*
- * amfield - ACPI AML (p-code) execution - field manipulation
- */
-
-acpi_status
-acpi_ex_extract_from_field (
-	acpi_operand_object     *obj_desc,
-	void                    *buffer,
-	u32                     buffer_length);
-
-acpi_status
-acpi_ex_insert_into_field (
-	acpi_operand_object     *obj_desc,
-	void                    *buffer,
-	u32                     buffer_length);
-
-acpi_status
-acpi_ex_setup_field (
-	acpi_operand_object     *obj_desc,
-	u32                     field_byte_offset);
-
-acpi_status
-acpi_ex_read_field_datum (
-	acpi_operand_object     *obj_desc,
-	u32                     field_byte_offset,
-	u32                     *value);
-
-acpi_status
-acpi_ex_common_access_field (
-	u32                     mode,
-	acpi_operand_object     *obj_desc,
-	void                    *buffer,
-	u32                     buffer_length);
-
-
-acpi_status
-acpi_ex_access_index_field (
-	u32                     mode,
-	acpi_operand_object     *obj_desc,
-	void                    *buffer,
-	u32                     buffer_length);
-
-acpi_status
-acpi_ex_access_bank_field (
-	u32                     mode,
-	acpi_operand_object     *obj_desc,
-	void                    *buffer,
-	u32                     buffer_length);
-
-acpi_status
-acpi_ex_access_region_field (
-	u32                     mode,
-	acpi_operand_object     *obj_desc,
-	void                    *buffer,
-	u32                     buffer_length);
-
-
-acpi_status
-acpi_ex_access_buffer_field (
-	u32                     mode,
-	acpi_operand_object     *obj_desc,
-	void                    *buffer,
-	u32                     buffer_length);
-
-acpi_status
-acpi_ex_read_data_from_field (
-	acpi_operand_object     *obj_desc,
-	acpi_operand_object     **ret_buffer_desc);
-
-acpi_status
-acpi_ex_write_data_to_field (
-	acpi_operand_object     *source_desc,
-	acpi_operand_object     *obj_desc);
-
-/*
- * ammisc - ACPI AML (p-code) execution - specific opcodes
- */
-
-acpi_status
-acpi_ex_opcode_3A_0T_0R (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_opcode_3A_1T_1R (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_opcode_6A_0T_1R (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_get_object_reference (
-	acpi_operand_object     *obj_desc,
-	acpi_operand_object     **return_desc,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_do_concatenate (
-	acpi_operand_object     *obj_desc,
-	acpi_operand_object     *obj_desc2,
-	acpi_operand_object     **actual_return_desc,
-	acpi_walk_state         *walk_state);
-
-u8
-acpi_ex_do_logical_op (
-	u16                     opcode,
-	acpi_integer            operand0,
-	acpi_integer            operand1);
-
-acpi_integer
-acpi_ex_do_math_op (
-	u16                     opcode,
-	acpi_integer            operand0,
-	acpi_integer            operand1);
-
-acpi_status
-acpi_ex_load_op (
-	acpi_operand_object     *rgn_desc,
-	acpi_operand_object     *ddb_handle);
-
-acpi_status
-acpi_ex_unload_table (
-	acpi_operand_object     *ddb_handle);
-
-acpi_status
-acpi_ex_create_mutex (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_create_processor (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_create_power_resource (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_create_region (
-	u8                      *aml_start,
-	u32                     aml_length,
-	u8                      region_space,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_create_table_region (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_create_event (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_create_alias (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_create_method (
-	u8                      *aml_start,
-	u32                     aml_length,
-	acpi_walk_state         *walk_state);
-
-
-/*
- * ammutex - mutex support
- */
-
-acpi_status
-acpi_ex_acquire_mutex (
-	acpi_operand_object     *time_desc,
-	acpi_operand_object     *obj_desc,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_release_mutex (
-	acpi_operand_object     *obj_desc,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_release_all_mutexes (
-	acpi_operand_object     *mutex_list);
-
-void
-acpi_ex_unlink_mutex (
-	acpi_operand_object     *obj_desc);
-
-
-/*
- * amprep - ACPI AML (p-code) execution - prep utilities
- */
-
-acpi_status
-acpi_ex_prep_common_field_object (
-	acpi_operand_object     *obj_desc,
-	u8                      field_flags,
-	u32                     field_position,
-	u32                     field_length);
-
-acpi_status
-acpi_ex_prep_region_field_value (
-	acpi_namespace_node     *node,
-	acpi_handle             region,
-	u8                      field_flags,
-	u32                     field_position,
-	u32                     field_length);
-
-acpi_status
-acpi_ex_prep_bank_field_value (
-	acpi_namespace_node     *node,
-	acpi_namespace_node     *region_node,
-	acpi_namespace_node     *bank_register_node,
-	u32                     bank_val,
-	u8                      field_flags,
-	u32                     field_position,
-	u32                     field_length);
-
-acpi_status
-acpi_ex_prep_index_field_value (
-	acpi_namespace_node     *node,
-	acpi_namespace_node     *index_reg,
-	acpi_namespace_node     *data_reg,
-	u8                      field_flags,
-	u32                     field_position,
-	u32                     field_length);
-
-acpi_status
-acpi_ex_prep_field_value (
-	ACPI_CREATE_FIELD_INFO  *info);
-
-/*
- * amsystem - Interface to OS services
- */
-
-acpi_status
-acpi_ex_system_do_notify_op (
-	acpi_operand_object     *value,
-	acpi_operand_object     *obj_desc);
-
-void
-acpi_ex_system_do_suspend(
-	u32                     time);
-
-void
-acpi_ex_system_do_stall (
-	u32                     time);
-
-acpi_status
-acpi_ex_system_acquire_mutex(
-	acpi_operand_object     *time,
-	acpi_operand_object     *obj_desc);
-
-acpi_status
-acpi_ex_system_release_mutex(
-	acpi_operand_object     *obj_desc);
-
-acpi_status
-acpi_ex_system_signal_event(
-	acpi_operand_object     *obj_desc);
-
-acpi_status
-acpi_ex_system_wait_event(
-	acpi_operand_object     *time,
-	acpi_operand_object     *obj_desc);
-
-acpi_status
-acpi_ex_system_reset_event(
-	acpi_operand_object     *obj_desc);
-
-acpi_status
-acpi_ex_system_wait_semaphore (
-	acpi_handle             semaphore,
-	u32                     timeout);
-
-
-/*
- * ammonadic - ACPI AML (p-code) execution, monadic operators
- */
-
-acpi_status
-acpi_ex_opcode_1A_0T_0R (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_opcode_1A_0T_1R (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_opcode_1A_1T_1R (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_opcode_1A_1T_0R (
-	acpi_walk_state         *walk_state);
-
-/*
- * amdyadic - ACPI AML (p-code) execution, dyadic operators
- */
-
-acpi_status
-acpi_ex_opcode_2A_0T_0R (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_opcode_2A_0T_1R (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_opcode_2A_1T_1R (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_opcode_2A_2T_1R (
-	acpi_walk_state         *walk_state);
-
-
-/*
- * amresolv  - Object resolution and get value functions
- */
-
-acpi_status
-acpi_ex_resolve_to_value (
-	acpi_operand_object     **stack_ptr,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_resolve_node_to_value (
-	acpi_namespace_node     **stack_ptr,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_resolve_object_to_value (
-	acpi_operand_object     **stack_ptr,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_get_buffer_field_value (
-	acpi_operand_object     *field_desc,
-	acpi_operand_object     *result_desc);
-
-
-/*
- * amdump - Scanner debug output routines
- */
-
-void
-acpi_ex_show_hex_value (
-	u32                     byte_count,
-	u8                      *aml_start,
-	u32                     lead_space);
-
-
-acpi_status
-acpi_ex_dump_operand (
-	acpi_operand_object     *entry_desc);
-
-void
-acpi_ex_dump_operands (
-	acpi_operand_object     **operands,
-	operating_mode          interpreter_mode,
-	NATIVE_CHAR             *ident,
-	u32                     num_levels,
-	NATIVE_CHAR             *note,
-	NATIVE_CHAR             *module_name,
-	u32                     line_number);
-
-void
-acpi_ex_dump_object_descriptor (
-	acpi_operand_object     *object,
-	u32                     flags);
-
-
-void
-acpi_ex_dump_node (
-	acpi_namespace_node     *node,
-	u32                     flags);
-
-
-/*
- * amnames - interpreter/scanner name load/execute
- */
-
-NATIVE_CHAR *
-acpi_ex_allocate_name_string (
-	u32                     prefix_count,
-	u32                     num_name_segs);
-
-u32
-acpi_ex_good_char (
-	u32                     character);
-
-acpi_status
-acpi_ex_name_segment (
-	u8                      **in_aml_address,
-	NATIVE_CHAR             *name_string);
-
-acpi_status
-acpi_ex_get_name_string (
-	acpi_object_type8       data_type,
-	u8                      *in_aml_address,
-	NATIVE_CHAR             **out_name_string,
-	u32                     *out_name_length);
-
-acpi_status
-acpi_ex_do_name (
-	acpi_object_type        data_type,
-	operating_mode          load_exec_mode);
-
-
-/*
- * amstore - Object store support
- */
-
-acpi_status
-acpi_ex_store (
-	acpi_operand_object     *val_desc,
-	acpi_operand_object     *dest_desc,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_store_object_to_index (
-	acpi_operand_object     *val_desc,
-	acpi_operand_object     *dest_desc,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_store_object_to_node (
-	acpi_operand_object     *source_desc,
-	acpi_namespace_node     *node,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_store_object_to_object (
-	acpi_operand_object     *source_desc,
-	acpi_operand_object     *dest_desc,
-	acpi_walk_state         *walk_state);
-
-
-/*
- *
- */
-
-acpi_status
-acpi_ex_resolve_object (
-	acpi_operand_object     **source_desc_ptr,
-	acpi_object_type8       target_type,
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ex_store_object (
-	acpi_operand_object     *source_desc,
-	acpi_object_type8       target_type,
-	acpi_operand_object     **target_desc_ptr,
-	acpi_walk_state         *walk_state);
-
-
-/*
- * amcopy - object copy
- */
-
-acpi_status
-acpi_ex_copy_buffer_to_buffer (
-	acpi_operand_object     *source_desc,
-	acpi_operand_object     *target_desc);
-
-acpi_status
-acpi_ex_copy_string_to_string (
-	acpi_operand_object     *source_desc,
-	acpi_operand_object     *target_desc);
-
-acpi_status
-acpi_ex_copy_integer_to_index_field (
-	acpi_operand_object     *source_desc,
-	acpi_operand_object     *target_desc);
-
-acpi_status
-acpi_ex_copy_integer_to_bank_field (
-	acpi_operand_object     *source_desc,
-	acpi_operand_object     *target_desc);
-
-acpi_status
-acpi_ex_copy_data_to_named_field (
-	acpi_operand_object     *source_desc,
-	acpi_namespace_node     *node);
-
-acpi_status
-acpi_ex_copy_integer_to_buffer_field (
-	acpi_operand_object     *source_desc,
-	acpi_operand_object     *target_desc);
-
-/*
- * amutils - interpreter/scanner utilities
- */
-
-acpi_status
-acpi_ex_enter_interpreter (
-	void);
-
-void
-acpi_ex_exit_interpreter (
-	void);
-
-void
-acpi_ex_truncate_for32bit_table (
-	acpi_operand_object     *obj_desc,
-	acpi_walk_state         *walk_state);
-
-u8
-acpi_ex_validate_object_type (
-	acpi_object_type        type);
-
-u8
-acpi_ex_acquire_global_lock (
-	u32                     rule);
-
-acpi_status
-acpi_ex_release_global_lock (
-	u8                      locked);
-
-u32
-acpi_ex_digits_needed (
-	acpi_integer            value,
-	u32                     base);
-
-acpi_status
-acpi_ex_eisa_id_to_string (
-	u32                     numeric_id,
-	NATIVE_CHAR             *out_string);
-
-acpi_status
-acpi_ex_unsigned_integer_to_string (
-	acpi_integer            value,
-	NATIVE_CHAR             *out_string);
-
-
-/*
- * amregion - default Op_region handlers
- */
-
-acpi_status
-acpi_ex_system_memory_space_handler (
-	u32                     function,
-	ACPI_PHYSICAL_ADDRESS   address,
-	u32                     bit_width,
-	u32                     *value,
-	void                    *handler_context,
-	void                    *region_context);
-
-acpi_status
-acpi_ex_system_io_space_handler (
-	u32                     function,
-	ACPI_PHYSICAL_ADDRESS   address,
-	u32                     bit_width,
-	u32                     *value,
-	void                    *handler_context,
-	void                    *region_context);
-
-acpi_status
-acpi_ex_pci_config_space_handler (
-	u32                     function,
-	ACPI_PHYSICAL_ADDRESS   address,
-	u32                     bit_width,
-	u32                     *value,
-	void                    *handler_context,
-	void                    *region_context);
-
-acpi_status
-acpi_ex_cmos_space_handler (
-	u32                     function,
-	ACPI_PHYSICAL_ADDRESS   address,
-	u32                     bit_width,
-	u32                     *value,
-	void                    *handler_context,
-	void                    *region_context);
-
-acpi_status
-acpi_ex_pci_bar_space_handler (
-	u32                     function,
-	ACPI_PHYSICAL_ADDRESS   address,
-	u32                     bit_width,
-	u32                     *value,
-	void                    *handler_context,
-	void                    *region_context);
-
-acpi_status
-acpi_ex_embedded_controller_space_handler (
-	u32                     function,
-	ACPI_PHYSICAL_ADDRESS   address,
-	u32                     bit_width,
-	u32                     *value,
-	void                    *handler_context,
-	void                    *region_context);
-
-acpi_status
-acpi_ex_sm_bus_space_handler (
-	u32                     function,
-	ACPI_PHYSICAL_ADDRESS   address,
-	u32                     bit_width,
-	u32                     *value,
-	void                    *handler_context,
-	void                    *region_context);
-
-
-#endif /* __INTERP_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/aclocal.h linux-2.4.22-pre2/drivers/acpi/include/aclocal.h
--- linux-2.4.21/drivers/acpi/include/aclocal.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/aclocal.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,973 +0,0 @@
-/******************************************************************************
- *
- * Name: aclocal.h - Internal data types used across the ACPI subsystem
- *       $Revision: 138 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACLOCAL_H__
-#define __ACLOCAL_H__
-
-
-#define WAIT_FOREVER                    ((u32) -1)
-
-typedef void*                           acpi_mutex;
-typedef u32                             ACPI_MUTEX_HANDLE;
-
-
-#define ACPI_MEMORY_MODE                0x01
-#define ACPI_LOGICAL_ADDRESSING         0x00
-#define ACPI_PHYSICAL_ADDRESSING        0x01
-
-/* Object descriptor types */
-
-#define ACPI_CACHED_OBJECT              0x11    /* ORed in when object is cached */
-#define ACPI_DESC_TYPE_STATE            0x20
-#define ACPI_DESC_TYPE_STATE_UPDATE     0x21
-#define ACPI_DESC_TYPE_STATE_PACKAGE    0x22
-#define ACPI_DESC_TYPE_STATE_CONTROL    0x23
-#define ACPI_DESC_TYPE_STATE_RPSCOPE    0x24
-#define ACPI_DESC_TYPE_STATE_PSCOPE     0x25
-#define ACPI_DESC_TYPE_STATE_WSCOPE     0x26
-#define ACPI_DESC_TYPE_STATE_RESULT     0x27
-#define ACPI_DESC_TYPE_STATE_NOTIFY     0x28
-#define ACPI_DESC_TYPE_WALK             0x44
-#define ACPI_DESC_TYPE_PARSER           0x66
-#define ACPI_DESC_TYPE_INTERNAL         0x88
-#define ACPI_DESC_TYPE_NAMED            0xAA
-
-
-/*****************************************************************************
- *
- * Mutex typedefs and structs
- *
- ****************************************************************************/
-
-
-/*
- * Predefined handles for the mutex objects used within the subsystem
- * All mutex objects are automatically created by Acpi_ut_mutex_initialize.
- *
- * The acquire/release ordering protocol is implied via this list.  Mutexes
- * with a lower value must be acquired before mutexes with a higher value.
- *
- * NOTE: any changes here must be reflected in the Acpi_gbl_Mutex_names table also!
- */
-
-#define ACPI_MTX_EXECUTE                0
-#define ACPI_MTX_INTERPRETER            1
-#define ACPI_MTX_PARSER                 2
-#define ACPI_MTX_DISPATCHER             3
-#define ACPI_MTX_TABLES                 4
-#define ACPI_MTX_OP_REGIONS             5
-#define ACPI_MTX_NAMESPACE              6
-#define ACPI_MTX_EVENTS                 7
-#define ACPI_MTX_HARDWARE               8
-#define ACPI_MTX_CACHES                 9
-#define ACPI_MTX_MEMORY                 10
-#define ACPI_MTX_DEBUG_CMD_COMPLETE     11
-#define ACPI_MTX_DEBUG_CMD_READY        12
-
-#define MAX_MTX                         12
-#define NUM_MTX                         MAX_MTX+1
-
-
-#if defined(ACPI_DEBUG) || defined(ENABLE_DEBUGGER)
-#ifdef DEFINE_ACPI_GLOBALS
-
-/* Names for the mutexes used in the subsystem */
-
-static NATIVE_CHAR          *acpi_gbl_mutex_names[] =
-{
-	"ACPI_MTX_Execute",
-	"ACPI_MTX_Interpreter",
-	"ACPI_MTX_Parser",
-	"ACPI_MTX_Dispatcher",
-	"ACPI_MTX_Tables",
-	"ACPI_MTX_Op_regions",
-	"ACPI_MTX_Namespace",
-	"ACPI_MTX_Events",
-	"ACPI_MTX_Hardware",
-	"ACPI_MTX_Caches",
-	"ACPI_MTX_Memory",
-	"ACPI_MTX_Debug_cmd_complete",
-	"ACPI_MTX_Debug_cmd_ready",
-};
-
-#endif
-#endif
-
-
-/* Table for the global mutexes */
-
-typedef struct acpi_mutex_info
-{
-	acpi_mutex                  mutex;
-	u32                         use_count;
-	u32                         owner_id;
-
-} acpi_mutex_info;
-
-/* This owner ID means that the mutex is not in use (unlocked) */
-
-#define ACPI_MUTEX_NOT_ACQUIRED         (u32) (-1)
-
-
-/* Lock flag parameter for various interfaces */
-
-#define ACPI_MTX_DO_NOT_LOCK            0
-#define ACPI_MTX_LOCK                   1
-
-
-typedef u16                             acpi_owner_id;
-#define OWNER_TYPE_TABLE                0x0
-#define OWNER_TYPE_METHOD               0x1
-#define FIRST_METHOD_ID                 0x0000
-#define FIRST_TABLE_ID                  0x8000
-
-/* TBD: [Restructure] get rid of the need for this! */
-
-#define TABLE_ID_DSDT                   (acpi_owner_id) 0x8000
-
-
-/* Field access granularities */
-
-#define ACPI_FIELD_BYTE_GRANULARITY     1
-#define ACPI_FIELD_WORD_GRANULARITY     2
-#define ACPI_FIELD_DWORD_GRANULARITY    4
-#define ACPI_FIELD_QWORD_GRANULARITY    8
-
-/*****************************************************************************
- *
- * Namespace typedefs and structs
- *
- ****************************************************************************/
-
-
-/* Operational modes of the AML interpreter/scanner */
-
-typedef enum
-{
-	IMODE_LOAD_PASS1                = 0x01,
-	IMODE_LOAD_PASS2                = 0x02,
-	IMODE_EXECUTE                   = 0x0E
-
-} operating_mode;
-
-
-/*
- * The Node describes a named object that appears in the AML
- * An Acpi_node is used to store Nodes.
- *
- * Data_type is used to differentiate between internal descriptors, and MUST
- * be the first byte in this structure.
- */
-
-typedef struct acpi_node
-{
-	u8                      data_type;
-	u8                      type;           /* Type associated with this name */
-	u16                     owner_id;
-	u32                     name;           /* ACPI Name, always 4 chars per ACPI spec */
-
-
-	union acpi_operand_obj  *object;        /* Pointer to attached ACPI object (optional) */
-	struct acpi_node        *child;         /* first child */
-	struct acpi_node        *peer;          /* Next peer*/
-	u16                     reference_count; /* Current count of references and children */
-	u8                      flags;
-
-} acpi_namespace_node;
-
-
-#define ENTRY_NOT_FOUND             NULL
-
-
-/* Node flags */
-
-#define ANOBJ_AML_ATTACHMENT            0x01
-#define ANOBJ_END_OF_PEER_LIST          0x02
-#define ANOBJ_DATA_WIDTH_32             0x04     /* Parent table is 64-bits */
-#define ANOBJ_METHOD_ARG                0x08
-#define ANOBJ_METHOD_LOCAL              0x10
-#define ANOBJ_METHOD_NO_RETVAL          0x20
-#define ANOBJ_METHOD_SOME_NO_RETVAL     0x40
-
-#define ANOBJ_IS_BIT_OFFSET             0x80
-
-
-/*
- * ACPI Table Descriptor.  One per ACPI table
- */
-typedef struct acpi_table_desc
-{
-	struct acpi_table_desc  *prev;
-	struct acpi_table_desc  *next;
-	struct acpi_table_desc  *installed_desc;
-	acpi_table_header       *pointer;
-	void                    *base_pointer;
-	u8                      *aml_start;
-	u64                     physical_address;
-	u32                     aml_length;
-	u32                     length;
-	u32                     count;
-	acpi_owner_id           table_id;
-	u8                      type;
-	u8                      allocation;
-	u8                      loaded_into_namespace;
-
-} acpi_table_desc;
-
-
-typedef struct
-{
-	NATIVE_CHAR             *search_for;
-	acpi_handle             *list;
-	u32                     *count;
-
-} find_context;
-
-
-typedef struct
-{
-	acpi_namespace_node     *node;
-} ns_search_data;
-
-
-/*
- * Predefined Namespace items
- */
-typedef struct
-{
-	NATIVE_CHAR             *name;
-	acpi_object_type8       type;
-	NATIVE_CHAR             *val;
-
-} predefined_names;
-
-
-/* Object types used during package copies */
-
-
-#define ACPI_COPY_TYPE_SIMPLE           0
-#define ACPI_COPY_TYPE_PACKAGE          1
-
-/* Info structure used to convert external<->internal namestrings */
-
-typedef struct acpi_namestring_info
-{
-	NATIVE_CHAR             *external_name;
-	NATIVE_CHAR             *next_external_char;
-	NATIVE_CHAR             *internal_name;
-	u32                     length;
-	u32                     num_segments;
-	u32                     num_carats;
-	u8                      fully_qualified;
-
-} acpi_namestring_info;
-
-
-/* Field creation info */
-
-typedef struct
-{
-	acpi_namespace_node     *region_node;
-	acpi_namespace_node     *field_node;
-	acpi_namespace_node     *register_node;
-	acpi_namespace_node     *data_register_node;
-	u32                     bank_value;
-	u32                     field_bit_position;
-	u32                     field_bit_length;
-	u8                      field_flags;
-	u8                      field_type;
-
-} ACPI_CREATE_FIELD_INFO;
-
-/*
- * Field flags: Bits 00 - 03 : Access_type (Any_acc, Byte_acc, etc.)
- *                   04      : Lock_rule (1 == Lock)
- *                   05 - 06 : Update_rule
- */
-
-#define FIELD_ACCESS_TYPE_MASK      0x0F
-#define FIELD_LOCK_RULE_MASK        0x10
-#define FIELD_UPDATE_RULE_MASK      0x60
-
-
-/*****************************************************************************
- *
- * Event typedefs and structs
- *
- ****************************************************************************/
-
-
-/* Status bits. */
-
-#define ACPI_STATUS_PMTIMER             0x0001
-#define ACPI_STATUS_BUSMASTER           0x0010
-#define ACPI_STATUS_GLOBAL              0x0020
-#define ACPI_STATUS_POWER_BUTTON        0x0100
-#define ACPI_STATUS_SLEEP_BUTTON        0x0200
-#define ACPI_STATUS_RTC_ALARM           0x0400
-
-/* Enable bits. */
-
-#define ACPI_ENABLE_PMTIMER             0x0001
-#define ACPI_ENABLE_GLOBAL              0x0020
-#define ACPI_ENABLE_POWER_BUTTON        0x0100
-#define ACPI_ENABLE_SLEEP_BUTTON        0x0200
-#define ACPI_ENABLE_RTC_ALARM           0x0400
-
-
-/*
- * Entry in the Address_space (AKA Operation Region) table
- */
-
-typedef struct
-{
-	acpi_adr_space_handler  handler;
-	void                    *context;
-
-} acpi_adr_space_info;
-
-
-/* Values and addresses of the GPE registers (both banks) */
-
-typedef struct
-{
-	u16                     status_addr;    /* Address of status reg */
-	u16                     enable_addr;    /* Address of enable reg */
-	u8                      status;         /* Current value of status reg */
-	u8                      enable;         /* Current value of enable reg */
-	u8                      wake_enable;    /* Mask of bits to keep enabled when sleeping */
-	u8                      gpe_base;       /* Base GPE number */
-
-} acpi_gpe_registers;
-
-
-#define ACPI_GPE_LEVEL_TRIGGERED        1
-#define ACPI_GPE_EDGE_TRIGGERED         2
-
-
-/* Information about each particular GPE level */
-
-typedef struct
-{
-	u8                      type;           /* Level or Edge */
-
-	acpi_handle             method_handle;  /* Method handle for direct (fast) execution */
-	acpi_gpe_handler        handler;        /* Address of handler, if any */
-	void                    *context;       /* Context to be passed to handler */
-
-} acpi_gpe_level_info;
-
-
-/* Information about each particular fixed event */
-
-typedef struct
-{
-	acpi_event_handler      handler;        /* Address of handler. */
-	void                    *context;       /* Context to be passed to handler */
-
-} acpi_fixed_event_info;
-
-
-/* Information used during field processing */
-
-typedef struct
-{
-	u8                      skip_field;
-	u8                      field_flag;
-	u32                     pkg_length;
-
-} acpi_field_info;
-
-
-/*****************************************************************************
- *
- * Generic "state" object for stacks
- *
- ****************************************************************************/
-
-
-#define CONTROL_NORMAL                  0xC0
-#define CONTROL_CONDITIONAL_EXECUTING   0xC1
-#define CONTROL_PREDICATE_EXECUTING     0xC2
-#define CONTROL_PREDICATE_FALSE         0xC3
-#define CONTROL_PREDICATE_TRUE          0xC4
-
-
-/* Forward declarations */
-struct acpi_walk_state;
-struct acpi_walk_list;
-struct acpi_parse_obj;
-struct acpi_obj_mutex;
-
-
-#define ACPI_STATE_COMMON                  /* Two 32-bit fields and a pointer */\
-	u8                      data_type;          /* To differentiate various internal objs */\
-	u8                      flags; \
-	u16                     value; \
-	u16                     state; \
-	u16                     acpi_eval; \
-	void                    *next; \
-
-typedef struct acpi_common_state
-{
-	ACPI_STATE_COMMON
-} acpi_common_state;
-
-
-/*
- * Update state - used to traverse complex objects such as packages
- */
-typedef struct acpi_update_state
-{
-	ACPI_STATE_COMMON
-	union acpi_operand_obj  *object;
-
-} acpi_update_state;
-
-
-/*
- * Pkg state - used to traverse nested package structures
- */
-typedef struct acpi_pkg_state
-{
-	ACPI_STATE_COMMON
-	union acpi_operand_obj  *source_object;
-	union acpi_operand_obj  *dest_object;
-	struct acpi_walk_state  *walk_state;
-	void                    *this_target_obj;
-	u32                     num_packages;
-	u16                     index;
-
-} acpi_pkg_state;
-
-
-/*
- * Control state - one per if/else and while constructs.
- * Allows nesting of these constructs
- */
-typedef struct acpi_control_state
-{
-	ACPI_STATE_COMMON
-	struct acpi_parse_obj   *predicate_op;
-	u8                      *aml_predicate_start; /* Start of if/while predicate */
-
-} acpi_control_state;
-
-
-/*
- * Scope state - current scope during namespace lookups
- */
-typedef struct acpi_scope_state
-{
-	ACPI_STATE_COMMON
-	acpi_namespace_node     *node;
-
-} acpi_scope_state;
-
-
-typedef struct acpi_pscope_state
-{
-	ACPI_STATE_COMMON
-	struct acpi_parse_obj   *op;            /* current op being parsed */
-	u8                      *arg_end;       /* current argument end */
-	u8                      *pkg_end;       /* current package end */
-	u32                     arg_list;       /* next argument to parse */
-	u32                     arg_count;      /* Number of fixed arguments */
-
-} acpi_pscope_state;
-
-
-/*
- * Result values - used to accumulate the results of nested
- * AML arguments
- */
-typedef struct acpi_result_values
-{
-	ACPI_STATE_COMMON
-	union acpi_operand_obj  *obj_desc [OBJ_NUM_OPERANDS];
-	u8                      num_results;
-	u8                      last_insert;
-
-} acpi_result_values;
-
-
-typedef
-acpi_status (*acpi_parse_downwards) (
-	struct acpi_walk_state  *walk_state,
-	struct acpi_parse_obj   **out_op);
-
-typedef
-acpi_status (*acpi_parse_upwards) (
-	struct acpi_walk_state  *walk_state);
-
-
-/*
- * Notify info - used to pass info to the deferred notify
- * handler/dispatcher.
- */
-typedef struct acpi_notify_info
-{
-	ACPI_STATE_COMMON
-	acpi_namespace_node     *node;
-	union acpi_operand_obj  *handler_obj;
-
-} acpi_notify_info;
-
-
-/* Generic state is union of structs above */
-
-typedef union acpi_gen_state
-{
-	acpi_common_state       common;
-	acpi_control_state      control;
-	acpi_update_state       update;
-	acpi_scope_state        scope;
-	acpi_pscope_state       parse_scope;
-	acpi_pkg_state          pkg;
-	acpi_result_values      results;
-	acpi_notify_info        notify;
-
-} acpi_generic_state;
-
-
-/*****************************************************************************
- *
- * Interpreter typedefs and structs
- *
- ****************************************************************************/
-
-typedef
-acpi_status (*ACPI_EXECUTE_OP) (
-	struct acpi_walk_state  *walk_state);
-
-
-/*****************************************************************************
- *
- * Parser typedefs and structs
- *
- ****************************************************************************/
-
-/*
- * AML opcode, name, and argument layout
- */
-typedef struct acpi_opcode_info
-{
-	u32                     parse_args;     /* Grammar/Parse time arguments */
-	u32                     runtime_args;   /* Interpret time arguments */
-	u16                     flags;          /* Misc flags */
-	u8                      class;          /* Opcode class */
-	u8                      type;           /* Opcode type */
-
-#ifdef _OPCODE_NAMES
-	NATIVE_CHAR             *name;          /* op name (debug only) */
-#endif
-
-} acpi_opcode_info;
-
-
-typedef union acpi_parse_val
-{
-	acpi_integer            integer;        /* integer constant (Up to 64 bits) */
-	uint64_struct           integer64;      /* Structure overlay for 2 32-bit Dwords */
-	u32                     integer32;      /* integer constant, 32 bits only */
-	u16                     integer16;      /* integer constant, 16 bits only */
-	u8                      integer8;       /* integer constant, 8 bits only */
-	u32                     size;           /* bytelist or field size */
-	NATIVE_CHAR             *string;        /* NULL terminated string */
-	u8                      *buffer;        /* buffer or string */
-	NATIVE_CHAR             *name;          /* NULL terminated string */
-	struct acpi_parse_obj   *arg;           /* arguments and contained ops */
-
-} acpi_parse_value;
-
-
-#define ACPI_PARSE_COMMON \
-	u8                      data_type;      /* To differentiate various internal objs */\
-	u8                      flags;          /* Type of Op */\
-	u16                     opcode;         /* AML opcode */\
-	u32                     aml_offset;     /* offset of declaration in AML */\
-	struct acpi_parse_obj   *parent;        /* parent op */\
-	struct acpi_parse_obj   *next;          /* next op */\
-	DEBUG_ONLY_MEMBERS (\
-	NATIVE_CHAR             op_name[16])    /* op name (debug only) */\
-			  /* NON-DEBUG members below: */\
-	acpi_namespace_node     *node;          /* for use by interpreter */\
-	acpi_parse_value        value;          /* Value or args associated with the opcode */\
-
-
-/*
- * generic operation (eg. If, While, Store)
- */
-typedef struct acpi_parse_obj
-{
-	ACPI_PARSE_COMMON
-} acpi_parse_object;
-
-
-/*
- * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and Op_regions),
- * and bytelists.
- */
-typedef struct acpi_parse2_obj
-{
-	ACPI_PARSE_COMMON
-	u8                      *data;          /* AML body or bytelist data */
-	u32                     length;         /* AML length */
-	u32                     name;           /* 4-byte name or zero if no name */
-
-} acpi_parse2_object;
-
-
-/*
- * Parse state - one state per parser invocation and each control
- * method.
- */
-typedef struct acpi_parse_state
-{
-	u32                     aml_size;
-	u8                      *aml_start;     /* first AML byte */
-	u8                      *aml;           /* next AML byte */
-	u8                      *aml_end;       /* (last + 1) AML byte */
-	u8                      *pkg_start;     /* current package begin */
-	u8                      *pkg_end;       /* current package end */
-
-	struct acpi_parse_obj   *start_op;      /* root of parse tree */
-	struct acpi_node        *start_node;
-	union acpi_gen_state    *scope;         /* current scope */
-
-
-	struct acpi_parse_obj   *start_scope;
-
-
-} acpi_parse_state;
-
-
-/*****************************************************************************
- *
- * Hardware and PNP
- *
- ****************************************************************************/
-
-
-/* PCI */
-#define PCI_ROOT_HID_STRING             "PNP0A03"
-
-/*
- * The #define's and enum below establish an abstract way of identifying what
- * register block and register is to be accessed.  Do not change any of the
- * values as they are used in switch statements and offset calculations.
- */
-
-#define REGISTER_BLOCK_MASK             0xFF00  /* Register Block Id    */
-#define BIT_IN_REGISTER_MASK            0x00FF  /* Bit Id in the Register Block Id    */
-#define BYTE_IN_REGISTER_MASK           0x00FF  /* Register Offset in the Register Block    */
-
-#define REGISTER_BLOCK_ID(reg_id)       (reg_id & REGISTER_BLOCK_MASK)
-#define REGISTER_BIT_ID(reg_id)         (reg_id & BIT_IN_REGISTER_MASK)
-#define REGISTER_OFFSET(reg_id)         (reg_id & BYTE_IN_REGISTER_MASK)
-
-/*
- * Access Rule
- *  To access a Register Bit:
- *  -> Use Bit Name (= Register Block Id | Bit Id) defined in the enum.
- *
- *  To access a Register:
- *  -> Use Register Id (= Register Block Id | Register Offset)
- */
-
-
-/*
- * Register Block Id
- */
-#define PM1_STS                         0x0100
-#define PM1_EN                          0x0200
-#define PM1_CONTROL                     0x0300
-#define PM1A_CONTROL                    0x0400
-#define PM1B_CONTROL                    0x0500
-#define PM2_CONTROL                     0x0600
-#define PM_TIMER                        0x0700
-#define PROCESSOR_BLOCK                 0x0800
-#define GPE0_STS_BLOCK                  0x0900
-#define GPE0_EN_BLOCK                   0x0A00
-#define GPE1_STS_BLOCK                  0x0B00
-#define GPE1_EN_BLOCK                   0x0C00
-#define SMI_CMD_BLOCK                   0x0D00
-
-/*
- * Address space bitmasks for mmio or io spaces
- */
-
-#define SMI_CMD_ADDRESS_SPACE           0x01
-#define PM1_BLK_ADDRESS_SPACE           0x02
-#define PM2_CNT_BLK_ADDRESS_SPACE       0x04
-#define PM_TMR_BLK_ADDRESS_SPACE        0x08
-#define GPE0_BLK_ADDRESS_SPACE          0x10
-#define GPE1_BLK_ADDRESS_SPACE          0x20
-
-/*
- * Control bit definitions
- */
-#define TMR_STS                         (PM1_STS | 0x01)
-#define BM_STS                          (PM1_STS | 0x02)
-#define GBL_STS                         (PM1_STS | 0x03)
-#define PWRBTN_STS                      (PM1_STS | 0x04)
-#define SLPBTN_STS                      (PM1_STS | 0x05)
-#define RTC_STS                         (PM1_STS | 0x06)
-#define WAK_STS                         (PM1_STS | 0x07)
-
-#define TMR_EN                          (PM1_EN | 0x01)
-			 /* no BM_EN */
-#define GBL_EN                          (PM1_EN | 0x03)
-#define PWRBTN_EN                       (PM1_EN | 0x04)
-#define SLPBTN_EN                       (PM1_EN | 0x05)
-#define RTC_EN                          (PM1_EN | 0x06)
-#define WAK_EN                          (PM1_EN | 0x07)
-
-#define SCI_EN                          (PM1_CONTROL | 0x01)
-#define BM_RLD                          (PM1_CONTROL | 0x02)
-#define GBL_RLS                         (PM1_CONTROL | 0x03)
-#define SLP_TYPE_A                      (PM1_CONTROL | 0x04)
-#define SLP_TYPE_B                      (PM1_CONTROL | 0x05)
-#define SLP_EN                          (PM1_CONTROL | 0x06)
-
-#define ARB_DIS                         (PM2_CONTROL | 0x01)
-
-#define TMR_VAL                         (PM_TIMER | 0x01)
-
-#define GPE0_STS                        (GPE0_STS_BLOCK | 0x01)
-#define GPE0_EN                         (GPE0_EN_BLOCK  | 0x01)
-
-#define GPE1_STS                        (GPE1_STS_BLOCK | 0x01)
-#define GPE1_EN                         (GPE1_EN_BLOCK  | 0x01)
-
-
-#define TMR_STS_MASK                    0x0001
-#define BM_STS_MASK                     0x0010
-#define GBL_STS_MASK                    0x0020
-#define PWRBTN_STS_MASK                 0x0100
-#define SLPBTN_STS_MASK                 0x0200
-#define RTC_STS_MASK                    0x0400
-#define WAK_STS_MASK                    0x8000
-
-#define ALL_FIXED_STS_BITS              (TMR_STS_MASK   | BM_STS_MASK  | GBL_STS_MASK \
-					  | PWRBTN_STS_MASK | SLPBTN_STS_MASK \
-					  | RTC_STS_MASK | WAK_STS_MASK)
-
-#define TMR_EN_MASK                     0x0001
-#define GBL_EN_MASK                     0x0020
-#define PWRBTN_EN_MASK                  0x0100
-#define SLPBTN_EN_MASK                  0x0200
-#define RTC_EN_MASK                     0x0400
-
-#define SCI_EN_MASK                     0x0001
-#define BM_RLD_MASK                     0x0002
-#define GBL_RLS_MASK                    0x0004
-#define SLP_TYPE_X_MASK                 0x1C00
-#define SLP_EN_MASK                     0x2000
-
-#define ARB_DIS_MASK                    0x0001
-#define TMR_VAL_MASK                    0xFFFFFFFF
-
-#define GPE0_STS_MASK
-#define GPE0_EN_MASK
-
-#define GPE1_STS_MASK
-#define GPE1_EN_MASK
-
-
-#define ACPI_READ                       1
-#define ACPI_WRITE                      2
-
-
-/*****************************************************************************
- *
- * Resource descriptors
- *
- ****************************************************************************/
-
-
-/* Resource_type values */
-
-#define RESOURCE_TYPE_MEMORY_RANGE              0
-#define RESOURCE_TYPE_IO_RANGE                  1
-#define RESOURCE_TYPE_BUS_NUMBER_RANGE          2
-
-/* Resource descriptor types and masks */
-
-#define RESOURCE_DESC_TYPE_LARGE                0x80
-#define RESOURCE_DESC_TYPE_SMALL                0x00
-
-#define RESOURCE_DESC_TYPE_MASK                 0x80
-#define RESOURCE_DESC_SMALL_MASK                0x78        /* Only bits 6:3 contain the type */
-
-
-/*
- * Small resource descriptor types
- * Note: The 3 length bits (2:0) must be zero
- */
-#define RESOURCE_DESC_IRQ_FORMAT                0x20
-#define RESOURCE_DESC_DMA_FORMAT                0x28
-#define RESOURCE_DESC_START_DEPENDENT           0x30
-#define RESOURCE_DESC_END_DEPENDENT             0x38
-#define RESOURCE_DESC_IO_PORT                   0x40
-#define RESOURCE_DESC_FIXED_IO_PORT             0x48
-#define RESOURCE_DESC_SMALL_VENDOR              0x70
-#define RESOURCE_DESC_END_TAG                   0x78
-
-/*
- * Large resource descriptor types
- */
-
-#define RESOURCE_DESC_MEMORY_24                 0x81
-#define RESOURCE_DESC_GENERAL_REGISTER          0x82
-#define RESOURCE_DESC_LARGE_VENDOR              0x84
-#define RESOURCE_DESC_MEMORY_32                 0x85
-#define RESOURCE_DESC_FIXED_MEMORY_32           0x86
-#define RESOURCE_DESC_DWORD_ADDRESS_SPACE       0x87
-#define RESOURCE_DESC_WORD_ADDRESS_SPACE        0x88
-#define RESOURCE_DESC_EXTENDED_XRUPT            0x89
-#define RESOURCE_DESC_QWORD_ADDRESS_SPACE       0x8A
-
-
-/* String version of device HIDs and UIDs */
-
-#define ACPI_DEVICE_ID_LENGTH                   0x09
-
-typedef struct
-{
-	char            buffer[ACPI_DEVICE_ID_LENGTH];
-
-} acpi_device_id;
-
-
-/*****************************************************************************
- *
- * Miscellaneous
- *
- ****************************************************************************/
-
-#define ASCII_ZERO                      0x30
-
-/*****************************************************************************
- *
- * Debugger
- *
- ****************************************************************************/
-
-typedef struct dbmethodinfo
-{
-	acpi_handle             thread_gate;
-	NATIVE_CHAR             *name;
-	NATIVE_CHAR             **args;
-	u32                     flags;
-	u32                     num_loops;
-	NATIVE_CHAR             pathname[128];
-
-} db_method_info;
-
-
-/*****************************************************************************
- *
- * Debug
- *
- ****************************************************************************/
-
-typedef struct
-{
-	u32                     component_id;
-	NATIVE_CHAR             *proc_name;
-	NATIVE_CHAR             *module_name;
-
-} acpi_debug_print_info;
-
-
-/* Entry for a memory allocation (debug only) */
-
-
-#define MEM_MALLOC                      0
-#define MEM_CALLOC                      1
-#define MAX_MODULE_NAME                 16
-
-#define ACPI_COMMON_DEBUG_MEM_HEADER \
-	struct acpi_debug_mem_block *previous; \
-	struct acpi_debug_mem_block *next; \
-	u32                         size; \
-	u32                         component; \
-	u32                         line; \
-	NATIVE_CHAR                 module[MAX_MODULE_NAME]; \
-	u8                          alloc_type;
-
-
-typedef struct
-{
-	ACPI_COMMON_DEBUG_MEM_HEADER
-
-} acpi_debug_mem_header;
-
-typedef struct acpi_debug_mem_block
-{
-	ACPI_COMMON_DEBUG_MEM_HEADER
-	u64                         user_space;
-
-} acpi_debug_mem_block;
-
-
-#define ACPI_MEM_LIST_GLOBAL            0
-#define ACPI_MEM_LIST_NSNODE            1
-
-#define ACPI_MEM_LIST_FIRST_CACHE_LIST  2
-#define ACPI_MEM_LIST_STATE             2
-#define ACPI_MEM_LIST_PSNODE            3
-#define ACPI_MEM_LIST_PSNODE_EXT        4
-#define ACPI_MEM_LIST_OPERAND           5
-#define ACPI_MEM_LIST_WALK              6
-#define ACPI_MEM_LIST_MAX               6
-#define ACPI_NUM_MEM_LISTS              7
-
-
-typedef struct
-{
-	void                        *list_head;
-	u16                         link_offset;
-	u16                         max_cache_depth;
-	u16                         cache_depth;
-	u16                         object_size;
-
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
-
-	/* Statistics for debug memory tracking only */
-
-	u32                         total_allocated;
-	u32                         total_freed;
-	u32                         current_total_size;
-	u32                         cache_requests;
-	u32                         cache_hits;
-	char                        *list_name;
-#endif
-
-} ACPI_MEMORY_LIST;
-
-
-#endif /* __ACLOCAL_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/acmacros.h linux-2.4.22-pre2/drivers/acpi/include/acmacros.h
--- linux-2.4.21/drivers/acpi/include/acmacros.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/acmacros.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,584 +0,0 @@
-/******************************************************************************
- *
- * Name: acmacros.h - C macros for the entire subsystem.
- *       $Revision: 97 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACMACROS_H__
-#define __ACMACROS_H__
-
-
-/*
- * Data manipulation macros
- */
-
-#ifndef LOWORD
-#define LOWORD(l)                       ((u16)(NATIVE_UINT)(l))
-#endif
-
-#ifndef HIWORD
-#define HIWORD(l)                       ((u16)((((NATIVE_UINT)(l)) >> 16) & 0xFFFF))
-#endif
-
-#ifndef LOBYTE
-#define LOBYTE(l)                       ((u8)(u16)(l))
-#endif
-
-#ifndef HIBYTE
-#define HIBYTE(l)                       ((u8)((((u16)(l)) >> 8) & 0xFF))
-#endif
-
-#define BIT0(x)                         ((((x) & 0x01) > 0) ? 1 : 0)
-#define BIT1(x)                         ((((x) & 0x02) > 0) ? 1 : 0)
-#define BIT2(x)                         ((((x) & 0x04) > 0) ? 1 : 0)
-
-#define BIT3(x)                         ((((x) & 0x08) > 0) ? 1 : 0)
-#define BIT4(x)                         ((((x) & 0x10) > 0) ? 1 : 0)
-#define BIT5(x)                         ((((x) & 0x20) > 0) ? 1 : 0)
-#define BIT6(x)                         ((((x) & 0x40) > 0) ? 1 : 0)
-#define BIT7(x)                         ((((x) & 0x80) > 0) ? 1 : 0)
-
-#define LOW_BASE(w)                     ((u16) ((w) & 0x0000FFFF))
-#define MID_BASE(b)                     ((u8) (((b) & 0x00FF0000) >> 16))
-#define HI_BASE(b)                      ((u8) (((b) & 0xFF000000) >> 24))
-#define LOW_LIMIT(w)                    ((u16) ((w) & 0x0000FFFF))
-#define HI_LIMIT(b)                     ((u8) (((b) & 0x00FF0000) >> 16))
-
-
-#ifdef _IA16
-/*
- * For 16-bit addresses, we have to assume that the upper 32 bits
- * are zero.
- */
-#ifndef LODWORD
-#define LODWORD(l)                      (l)
-#endif
-
-#ifndef HIDWORD
-#define HIDWORD(l)                      (0)
-#endif
-
-#define ACPI_GET_ADDRESS(a)             ((a).lo)
-#define ACPI_STORE_ADDRESS(a,b)         {(a).hi=0;(a).lo=(b);}
-#define ACPI_VALID_ADDRESS(a)           ((a).hi | (a).lo)
-
-#else
-#ifdef ACPI_NO_INTEGER64_SUPPORT
-/*
- * acpi_integer is 32-bits, no 64-bit support on this platform
- */
-#ifndef LODWORD
-#define LODWORD(l)                      ((u32)(l))
-#endif
-
-#ifndef HIDWORD
-#define HIDWORD(l)                      (0)
-#endif
-
-#define ACPI_GET_ADDRESS(a)             (a)
-#define ACPI_STORE_ADDRESS(a,b)         ((a)=(b))
-#define ACPI_VALID_ADDRESS(a)           (a)
-
-#else
-
-/*
- * Full 64-bit address/integer on both 32-bit and 64-bit platforms
- */
-#ifndef LODWORD
-#define LODWORD(l)                      ((u32)(u64)(l))
-#endif
-
-#ifndef HIDWORD
-#define HIDWORD(l)                      ((u32)(((*(uint64_struct *)(&l))).hi))
-#endif
-
-#define ACPI_GET_ADDRESS(a)             (a)
-#define ACPI_STORE_ADDRESS(a,b)         ((a)=(b))
-#define ACPI_VALID_ADDRESS(a)           (a)
-#endif
-#endif
-
- /*
-  * Extract a byte of data using a pointer.  Any more than a byte and we
-  * get into potential aligment issues -- see the STORE macros below
-  */
-#define GET8(addr)                      (*(u8*)(addr))
-
-/* Pointer arithmetic */
-
-
-#define POINTER_ADD(t,a,b)              (t *) ((NATIVE_UINT)(a) + (NATIVE_UINT)(b))
-#define POINTER_DIFF(a,b)               ((u32) ((NATIVE_UINT)(a) - (NATIVE_UINT)(b)))
-
-/*
- * Macros for moving data around to/from buffers that are possibly unaligned.
- * If the hardware supports the transfer of unaligned data, just do the store.
- * Otherwise, we have to move one byte at a time.
- */
-
-#ifdef _HW_ALIGNMENT_SUPPORT
-
-/* The hardware supports unaligned transfers, just do the move */
-
-#define MOVE_UNALIGNED16_TO_16(d,s)     *(u16*)(d) = *(u16*)(s)
-#define MOVE_UNALIGNED32_TO_32(d,s)     *(u32*)(d) = *(u32*)(s)
-#define MOVE_UNALIGNED16_TO_32(d,s)     *(u32*)(d) = *(u16*)(s)
-#define MOVE_UNALIGNED64_TO_64(d,s)     *(u64*)(d) = *(u64*)(s)
-
-#else
-/*
- * The hardware does not support unaligned transfers.  We must move the
- * data one byte at a time.  These macros work whether the source or
- * the destination (or both) is/are unaligned.
- */
-
-#define MOVE_UNALIGNED16_TO_16(d,s)     {((u8 *)(d))[0] = ((u8 *)(s))[0];\
-	 ((u8 *)(d))[1] = ((u8 *)(s))[1];}
-
-#define MOVE_UNALIGNED32_TO_32(d,s)     {((u8 *)(d))[0] = ((u8 *)(s))[0];\
-			  ((u8 *)(d))[1] = ((u8 *)(s))[1];\
-			  ((u8 *)(d))[2] = ((u8 *)(s))[2];\
-			  ((u8 *)(d))[3] = ((u8 *)(s))[3];}
-
-#define MOVE_UNALIGNED16_TO_32(d,s)     {(*(u32*)(d)) = 0; MOVE_UNALIGNED16_TO_16(d,s);}
-
-#define MOVE_UNALIGNED64_TO_64(d,s)     {((u8 *)(d))[0] = ((u8 *)(s))[0];\
-					   ((u8 *)(d))[1] = ((u8 *)(s))[1];\
-					   ((u8 *)(d))[2] = ((u8 *)(s))[2];\
-					   ((u8 *)(d))[3] = ((u8 *)(s))[3];\
-					   ((u8 *)(d))[4] = ((u8 *)(s))[4];\
-					   ((u8 *)(d))[5] = ((u8 *)(s))[5];\
-					   ((u8 *)(d))[6] = ((u8 *)(s))[6];\
-					   ((u8 *)(d))[7] = ((u8 *)(s))[7];}
-
-#endif
-
-
-/*
- * Fast power-of-two math macros for non-optimized compilers
- */
-
-#define _DIV(value,power_of2)           ((u32) ((value) >> (power_of2)))
-#define _MUL(value,power_of2)           ((u32) ((value) << (power_of2)))
-#define _MOD(value,divisor)             ((u32) ((value) & ((divisor) -1)))
-
-#define DIV_2(a)                        _DIV(a,1)
-#define MUL_2(a)                        _MUL(a,1)
-#define MOD_2(a)                        _MOD(a,2)
-
-#define DIV_4(a)                        _DIV(a,2)
-#define MUL_4(a)                        _MUL(a,2)
-#define MOD_4(a)                        _MOD(a,4)
-
-#define DIV_8(a)                        _DIV(a,3)
-#define MUL_8(a)                        _MUL(a,3)
-#define MOD_8(a)                        _MOD(a,8)
-
-#define DIV_16(a)                       _DIV(a,4)
-#define MUL_16(a)                       _MUL(a,4)
-#define MOD_16(a)                       _MOD(a,16)
-
-
-/*
- * Rounding macros (Power of two boundaries only)
- */
-#define ROUND_DOWN(value,boundary)      ((value) & (~((boundary)-1)))
-#define ROUND_UP(value,boundary)        (((value) + ((boundary)-1)) & (~((boundary)-1)))
-
-#define ROUND_DOWN_TO_32_BITS(a)        ROUND_DOWN(a,4)
-#define ROUND_DOWN_TO_64_BITS(a)        ROUND_DOWN(a,8)
-#define ROUND_DOWN_TO_NATIVE_WORD(a)    ROUND_DOWN(a,ALIGNED_ADDRESS_BOUNDARY)
-
-#define ROUND_UP_TO_32_bITS(a)          ROUND_UP(a,4)
-#define ROUND_UP_TO_64_bITS(a)          ROUND_UP(a,8)
-#define ROUND_UP_TO_NATIVE_WORD(a)      ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY)
-
-#define ROUND_PTR_UP_TO_4(a,b)          ((b *)(((NATIVE_UINT)(a) + 3) & ~3))
-#define ROUND_PTR_UP_TO_8(a,b)          ((b *)(((NATIVE_UINT)(a) + 7) & ~7))
-
-#define ROUND_BITS_UP_TO_BYTES(a)       DIV_8((a) + 7)
-#define ROUND_BITS_DOWN_TO_BYTES(a)     DIV_8((a))
-
-#define ROUND_UP_TO_1K(a)               (((a) + 1023) >> 10)
-
-/* Generic (non-power-of-two) rounding */
-
-#define ROUND_UP_TO(value,boundary)     (((value) + ((boundary)-1)) / (boundary))
-
-/*
- * Bitmask creation
- * Bit positions start at zero.
- * MASK_BITS_ABOVE creates a mask starting AT the position and above
- * MASK_BITS_BELOW creates a mask starting one bit BELOW the position
- */
-#define MASK_BITS_ABOVE(position)       (~(((u32)(-1)) << ((u32) (position))))
-#define MASK_BITS_BELOW(position)       (((u32)(-1)) << ((u32) (position)))
-
-
-/* Macros for GAS addressing */
-
-#ifndef _IA16
-
-#define ACPI_PCI_DEVICE_MASK            (u64) 0x0000FFFF00000000
-#define ACPI_PCI_FUNCTION_MASK          (u64) 0x00000000FFFF0000
-#define ACPI_PCI_REGISTER_MASK          (u64) 0x000000000000FFFF
-
-#define ACPI_PCI_FUNCTION(a)            (u16) ((((a) & ACPI_PCI_FUNCTION_MASK) >> 16))
-#define ACPI_PCI_DEVICE(a)              (u16) ((((a) & ACPI_PCI_DEVICE_MASK) >> 32))
-#define ACPI_PCI_REGISTER(a)            (u16) (((a) & ACPI_PCI_REGISTER_MASK))
-
-#else
-
-/* No support for GAS and PCI IDs in 16-bit mode  */
-
-#define ACPI_PCI_FUNCTION(a)            (u16) ((a) & 0xFFFF0000)
-#define ACPI_PCI_DEVICE(a)              (u16) ((a) & 0x0000FFFF)
-#define ACPI_PCI_REGISTER(a)            (u16) ((a) & 0x0000FFFF)
-
-#endif
-
-/*
- * An acpi_handle (which is actually an acpi_namespace_node *) can appear in some contexts,
- * such as on ap_obj_stack, where a pointer to an acpi_operand_object can also
- * appear.  This macro is used to distinguish them.
- *
- * The Data_type field is the first field in both structures.
- */
-#define VALID_DESCRIPTOR_TYPE(d,t)      (((acpi_namespace_node *)d)->data_type == t)
-
-
-/* Macro to test the object type */
-
-#define IS_THIS_OBJECT_TYPE(d,t)        (((acpi_operand_object  *)d)->common.type == (u8)t)
-
-/* Macro to check the table flags for SINGLE or MULTIPLE tables are allowed */
-
-#define IS_SINGLE_TABLE(x)              (((x) & 0x01) == ACPI_TABLE_SINGLE ? 1 : 0)
-
-/*
- * Macro to check if a pointer is within an ACPI table.
- * Parameter (a) is the pointer to check.  Parameter (b) must be defined
- * as a pointer to an acpi_table_header.  (b+1) then points past the header,
- * and ((u8 *)b+b->Length) points one byte past the end of the table.
- */
-#ifndef _IA16
-#define IS_IN_ACPI_TABLE(a,b)           (((u8 *)(a) >= (u8 *)(b + 1)) &&\
-							   ((u8 *)(a) < ((u8 *)b + b->length)))
-
-#else
-#define IS_IN_ACPI_TABLE(a,b)           (_segment)(a) == (_segment)(b) &&\
-									 (((u8 *)(a) >= (u8 *)(b + 1)) &&\
-									 ((u8 *)(a) < ((u8 *)b + b->length)))
-#endif
-
-/*
- * Macros for the master AML opcode table
- */
-#ifdef ACPI_DEBUG
-#define ACPI_OP(name,Pargs,Iargs,class,type,flags)     {Pargs,Iargs,flags,class,type,name}
-#else
-#define ACPI_OP(name,Pargs,Iargs,class,type,flags)     {Pargs,Iargs,flags,class,type}
-#endif
-
-#define ARG_TYPE_WIDTH                  5
-#define ARG_1(x)                        ((u32)(x))
-#define ARG_2(x)                        ((u32)(x) << (1 * ARG_TYPE_WIDTH))
-#define ARG_3(x)                        ((u32)(x) << (2 * ARG_TYPE_WIDTH))
-#define ARG_4(x)                        ((u32)(x) << (3 * ARG_TYPE_WIDTH))
-#define ARG_5(x)                        ((u32)(x) << (4 * ARG_TYPE_WIDTH))
-#define ARG_6(x)                        ((u32)(x) << (5 * ARG_TYPE_WIDTH))
-
-#define ARGI_LIST1(a)                   (ARG_1(a))
-#define ARGI_LIST2(a,b)                 (ARG_1(b)|ARG_2(a))
-#define ARGI_LIST3(a,b,c)               (ARG_1(c)|ARG_2(b)|ARG_3(a))
-#define ARGI_LIST4(a,b,c,d)             (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a))
-#define ARGI_LIST5(a,b,c,d,e)           (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a))
-#define ARGI_LIST6(a,b,c,d,e,f)         (ARG_1(f)|ARG_2(e)|ARG_3(d)|ARG_4(c)|ARG_5(b)|ARG_6(a))
-
-#define ARGP_LIST1(a)                   (ARG_1(a))
-#define ARGP_LIST2(a,b)                 (ARG_1(a)|ARG_2(b))
-#define ARGP_LIST3(a,b,c)               (ARG_1(a)|ARG_2(b)|ARG_3(c))
-#define ARGP_LIST4(a,b,c,d)             (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d))
-#define ARGP_LIST5(a,b,c,d,e)           (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e))
-#define ARGP_LIST6(a,b,c,d,e,f)         (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)|ARG_6(f))
-
-#define GET_CURRENT_ARG_TYPE(list)      (list & ((u32) 0x1F))
-#define INCREMENT_ARG_LIST(list)        (list >>= ((u32) ARG_TYPE_WIDTH))
-
-
-/*
- * Build a GAS structure from earlier ACPI table entries (V1.0 and 0.71 extensions)
- *
- * 1) Address space
- * 2) Length in bytes -- convert to length in bits
- * 3) Bit offset is zero
- * 4) Reserved field is zero
- * 5) Expand address to 64 bits
- */
-#define ASL_BUILD_GAS_FROM_ENTRY(a,b,c,d)   {a.address_space_id = (u8) d;\
-											 a.register_bit_width = (u8) MUL_8 (b);\
-											 a.register_bit_offset = 0;\
-											 a.reserved = 0;\
-											 ACPI_STORE_ADDRESS (a.address,c);}
-
-/* ACPI V1.0 entries -- address space is always I/O */
-
-#define ASL_BUILD_GAS_FROM_V1_ENTRY(a,b,c)  ASL_BUILD_GAS_FROM_ENTRY(a,b,c,ACPI_ADR_SPACE_SYSTEM_IO)
-
-
-/*
- * Reporting macros that are never compiled out
- */
-
-#define PARAM_LIST(pl)                  pl
-
-/*
- * Error reporting.  These versions add callers module and line#.  Since
- * _THIS_MODULE gets compiled out when ACPI_DEBUG isn't defined, only
- * use it in debug mode.
- */
-
-#ifdef ACPI_DEBUG
-
-#define REPORT_INFO(fp)                 {acpi_ut_report_info(_THIS_MODULE,__LINE__,_COMPONENT); \
-											acpi_os_printf PARAM_LIST(fp);}
-#define REPORT_ERROR(fp)                {acpi_ut_report_error(_THIS_MODULE,__LINE__,_COMPONENT); \
-											acpi_os_printf PARAM_LIST(fp);}
-#define REPORT_WARNING(fp)              {acpi_ut_report_warning(_THIS_MODULE,__LINE__,_COMPONENT); \
-											acpi_os_printf PARAM_LIST(fp);}
-
-#else
-
-#define REPORT_INFO(fp)                 {acpi_ut_report_info("ACPI",__LINE__,_COMPONENT); \
-											acpi_os_printf PARAM_LIST(fp);}
-#define REPORT_ERROR(fp)                {acpi_ut_report_error("ACPI",__LINE__,_COMPONENT); \
-											acpi_os_printf PARAM_LIST(fp);}
-#define REPORT_WARNING(fp)              {acpi_ut_report_warning("ACPI",__LINE__,_COMPONENT); \
-											acpi_os_printf PARAM_LIST(fp);}
-
-#endif
-
-/* Error reporting.  These versions pass thru the module and line# */
-
-#define _REPORT_INFO(a,b,c,fp)          {acpi_ut_report_info(a,b,c); \
-											acpi_os_printf PARAM_LIST(fp);}
-#define _REPORT_ERROR(a,b,c,fp)         {acpi_ut_report_error(a,b,c); \
-											acpi_os_printf PARAM_LIST(fp);}
-#define _REPORT_WARNING(a,b,c,fp)       {acpi_ut_report_warning(a,b,c); \
-											acpi_os_printf PARAM_LIST(fp);}
-
-/*
- * Debug macros that are conditionally compiled
- */
-
-#ifdef ACPI_DEBUG
-
-#define MODULE_NAME(name)               static char *_THIS_MODULE = name;
-
-/*
- * Function entry tracing.
- * The first parameter should be the procedure name as a quoted string.  This is declared
- * as a local string ("_Proc_name) so that it can be also used by the function exit macros below.
- */
-
-#define PROC_NAME(a)                    acpi_debug_print_info _dbg;     \
-										_dbg.component_id = _COMPONENT; \
-										_dbg.proc_name   = a;           \
-										_dbg.module_name = _THIS_MODULE;
-
-#define FUNCTION_TRACE(a)               PROC_NAME(a)\
-										acpi_ut_trace(__LINE__,&_dbg)
-#define FUNCTION_TRACE_PTR(a,b)         PROC_NAME(a)\
-										acpi_ut_trace_ptr(__LINE__,&_dbg,(void *)b)
-#define FUNCTION_TRACE_U32(a,b)         PROC_NAME(a)\
-										acpi_ut_trace_u32(__LINE__,&_dbg,(u32)b)
-#define FUNCTION_TRACE_STR(a,b)         PROC_NAME(a)\
-										acpi_ut_trace_str(__LINE__,&_dbg,(NATIVE_CHAR *)b)
-
-#define FUNCTION_ENTRY()                acpi_ut_track_stack_ptr()
-
-/*
- * Function exit tracing.
- * WARNING: These macros include a return statement.  This is usually considered
- * bad form, but having a separate exit macro is very ugly and difficult to maintain.
- * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros
- * so that "_Proc_name" is defined.
- */
-#define return_VOID                     {acpi_ut_exit(__LINE__,&_dbg);return;}
-#define return_ACPI_STATUS(s)           {acpi_ut_status_exit(__LINE__,&_dbg,s);return(s);}
-#define return_VALUE(s)                 {acpi_ut_value_exit(__LINE__,&_dbg,s);return(s);}
-#define return_PTR(s)                   {acpi_ut_ptr_exit(__LINE__,&_dbg,(u8 *)s);return(s);}
-
-
-/* Conditional execution */
-
-#define DEBUG_EXEC(a)                   a
-#define NORMAL_EXEC(a)
-
-#define DEBUG_DEFINE(a)                 a;
-#define DEBUG_ONLY_MEMBERS(a)           a;
-#define _OPCODE_NAMES
-#define _VERBOSE_STRUCTURES
-
-
-/* Stack and buffer dumping */
-
-#define DUMP_STACK_ENTRY(a)             acpi_ex_dump_operand(a)
-#define DUMP_OPERANDS(a,b,c,d,e)        acpi_ex_dump_operands(a,b,c,d,e,_THIS_MODULE,__LINE__)
-
-
-#define DUMP_ENTRY(a,b)                 acpi_ns_dump_entry (a,b)
-#define DUMP_TABLES(a,b)                acpi_ns_dump_tables(a,b)
-#define DUMP_PATHNAME(a,b,c,d)          acpi_ns_dump_pathname(a,b,c,d)
-#define DUMP_RESOURCE_LIST(a)           acpi_rs_dump_resource_list(a)
-#define DUMP_BUFFER(a,b)                acpi_ut_dump_buffer((u8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT)
-#define BREAK_MSG(a)                    acpi_os_signal (ACPI_SIGNAL_BREAKPOINT,(a))
-
-
-/*
- * Generate INT3 on ACPI_ERROR (Debug only!)
- */
-
-#define ERROR_BREAK
-#ifdef  ERROR_BREAK
-#define BREAK_ON_ERROR(lvl)              if ((lvl)&ACPI_ERROR) acpi_os_signal(ACPI_SIGNAL_BREAKPOINT,"Fatal error encountered\n")
-#else
-#define BREAK_ON_ERROR(lvl)
-#endif
-
-/*
- * Master debug print macros
- * Print iff:
- *    1) Debug print for the current component is enabled
- *    2) Debug error level or trace level for the print statement is enabled
- */
-
-#define ACPI_DEBUG_PRINT(pl)            acpi_ut_debug_print PARAM_LIST(pl)
-#define ACPI_DEBUG_PRINT_RAW(pl)        acpi_ut_debug_print_raw PARAM_LIST(pl)
-
-
-#else
-/*
- * This is the non-debug case -- make everything go away,
- * leaving no executable debug code!
- */
-
-#define MODULE_NAME(name)
-#define _THIS_MODULE ""
-
-#define DEBUG_EXEC(a)
-#define NORMAL_EXEC(a)                  a;
-
-#define DEBUG_DEFINE(a)
-#define DEBUG_ONLY_MEMBERS(a)
-#define PROC_NAME(a)
-#define FUNCTION_TRACE(a)
-#define FUNCTION_TRACE_PTR(a,b)
-#define FUNCTION_TRACE_U32(a,b)
-#define FUNCTION_TRACE_STR(a,b)
-#define FUNCTION_EXIT
-#define FUNCTION_STATUS_EXIT(s)
-#define FUNCTION_VALUE_EXIT(s)
-#define FUNCTION_ENTRY()
-#define DUMP_STACK_ENTRY(a)
-#define DUMP_OPERANDS(a,b,c,d,e)
-#define DUMP_ENTRY(a,b)
-#define DUMP_TABLES(a,b)
-#define DUMP_PATHNAME(a,b,c,d)
-#define DUMP_RESOURCE_LIST(a)
-#define DUMP_BUFFER(a,b)
-#define ACPI_DEBUG_PRINT(pl)
-#define ACPI_DEBUG_PRINT_RAW(pl)
-#define BREAK_MSG(a)
-
-#define return_VOID                     return
-#define return_ACPI_STATUS(s)           return(s)
-#define return_VALUE(s)                 return(s)
-#define return_PTR(s)                   return(s)
-
-#endif
-
-/*
- * Some code only gets executed when the debugger is built in.
- * Note that this is entirely independent of whether the
- * DEBUG_PRINT stuff (set by ACPI_DEBUG) is on, or not.
- */
-#ifdef ENABLE_DEBUGGER
-#define DEBUGGER_EXEC(a)                a
-#else
-#define DEBUGGER_EXEC(a)
-#endif
-
-
-/*
- * For 16-bit code, we want to shrink some things even though
- * we are using ACPI_DEBUG to get the debug output
- */
-#ifdef _IA16
-#undef DEBUG_ONLY_MEMBERS
-#undef _VERBOSE_STRUCTURES
-#define DEBUG_ONLY_MEMBERS(a)
-#endif
-
-
-#ifdef ACPI_DEBUG
-/*
- * 1) Set name to blanks
- * 2) Copy the object name
- */
-#define ADD_OBJECT_NAME(a,b)            MEMSET (a->common.name, ' ', sizeof (a->common.name));\
-										STRNCPY (a->common.name, acpi_gbl_ns_type_names[b], sizeof (a->common.name))
-#else
-
-#define ADD_OBJECT_NAME(a,b)
-#endif
-
-
-/*
- * Memory allocation tracking (DEBUG ONLY)
- */
-
-#ifndef ACPI_DBG_TRACK_ALLOCATIONS
-
-/* Memory allocation */
-
-#define ACPI_MEM_ALLOCATE(a)            acpi_os_allocate(a)
-#define ACPI_MEM_CALLOCATE(a)           acpi_os_callocate(a)
-#define ACPI_MEM_FREE(a)                acpi_os_free(a)
-#define ACPI_MEM_TRACKING(a)
-
-
-#else
-
-/* Memory allocation */
-
-#define ACPI_MEM_ALLOCATE(a)            acpi_ut_allocate(a,_COMPONENT,_THIS_MODULE,__LINE__)
-#define ACPI_MEM_CALLOCATE(a)           acpi_ut_callocate(a, _COMPONENT,_THIS_MODULE,__LINE__)
-#define ACPI_MEM_FREE(a)                acpi_ut_free(a,_COMPONENT,_THIS_MODULE,__LINE__)
-#define ACPI_MEM_TRACKING(a)            a
-
-#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
-
-
-#define ACPI_GET_STACK_POINTER          _asm {mov eax, ebx}
-
-#endif /* ACMACROS_H */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/acnamesp.h linux-2.4.22-pre2/drivers/acpi/include/acnamesp.h
--- linux-2.4.21/drivers/acpi/include/acnamesp.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/acnamesp.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,423 +0,0 @@
-/******************************************************************************
- *
- * Name: acnamesp.h - Namespace subcomponent prototypes and defines
- *       $Revision: 110 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACNAMESP_H__
-#define __ACNAMESP_H__
-
-
-/* To search the entire name space, pass this as Search_base */
-
-#define NS_ALL                  ((acpi_handle)0)
-
-/*
- * Elements of Acpi_ns_properties are bit significant
- * and should be one-to-one with values of acpi_object_type
- */
-#define NSP_NORMAL              0
-#define NSP_NEWSCOPE            1   /* a definition of this type opens a name scope */
-#define NSP_LOCAL               2   /* suppress search of enclosing scopes */
-
-
-/* Definitions of the predefined namespace names  */
-
-#define ACPI_UNKNOWN_NAME       (u32) 0x3F3F3F3F     /* Unknown name is  "????" */
-#define ACPI_ROOT_NAME          (u32) 0x2F202020     /* Root name is     "/   " */
-#define ACPI_SYS_BUS_NAME       (u32) 0x5F53425F     /* Sys bus name is  "_SB_" */
-
-#define NS_ROOT_PATH            "/"
-#define NS_SYSTEM_BUS           "_SB_"
-
-
-/* Flags for Acpi_ns_lookup, Acpi_ns_search_and_enter */
-
-#define NS_NO_UPSEARCH          0
-#define NS_SEARCH_PARENT        0x01
-#define NS_DONT_OPEN_SCOPE      0x02
-#define NS_NO_PEER_SEARCH       0x04
-#define NS_ERROR_IF_FOUND       0x08
-
-#define NS_WALK_UNLOCK          TRUE
-#define NS_WALK_NO_UNLOCK       FALSE
-
-
-acpi_status
-acpi_ns_load_namespace (
-	void);
-
-acpi_status
-acpi_ns_initialize_objects (
-	void);
-
-acpi_status
-acpi_ns_initialize_devices (
-	void);
-
-
-/* Namespace init - nsxfinit */
-
-acpi_status
-acpi_ns_init_one_device (
-	acpi_handle             obj_handle,
-	u32                     nesting_level,
-	void                    *context,
-	void                    **return_value);
-
-acpi_status
-acpi_ns_init_one_object (
-	acpi_handle             obj_handle,
-	u32                     level,
-	void                    *context,
-	void                    **return_value);
-
-
-acpi_status
-acpi_ns_walk_namespace (
-	acpi_object_type8       type,
-	acpi_handle             start_object,
-	u32                     max_depth,
-	u8                      unlock_before_callback,
-	acpi_walk_callback      user_function,
-	void                    *context,
-	void                    **return_value);
-
-acpi_namespace_node *
-acpi_ns_get_next_node (
-	acpi_object_type8       type,
-	acpi_namespace_node     *parent,
-	acpi_namespace_node     *child);
-
-acpi_status
-acpi_ns_delete_namespace_by_owner (
-	u16                     table_id);
-
-
-/* Namespace loading - nsload */
-
-acpi_status
-acpi_ns_one_complete_parse (
-	u32                     pass_number,
-	acpi_table_desc         *table_desc);
-
-acpi_status
-acpi_ns_parse_table (
-	acpi_table_desc         *table_desc,
-	acpi_namespace_node     *scope);
-
-acpi_status
-acpi_ns_load_table (
-	acpi_table_desc         *table_desc,
-	acpi_namespace_node     *node);
-
-acpi_status
-acpi_ns_load_table_by_type (
-	acpi_table_type         table_type);
-
-
-/*
- * Top-level namespace access - nsaccess
- */
-
-
-acpi_status
-acpi_ns_root_initialize (
-	void);
-
-acpi_status
-acpi_ns_lookup (
-	acpi_generic_state      *scope_info,
-	NATIVE_CHAR             *name,
-	acpi_object_type8       type,
-	operating_mode          interpreter_mode,
-	u32                     flags,
-	acpi_walk_state         *walk_state,
-	acpi_namespace_node     **ret_node);
-
-
-/*
- * Named object allocation/deallocation - nsalloc
- */
-
-
-acpi_namespace_node *
-acpi_ns_create_node (
-	u32                     name);
-
-void
-acpi_ns_delete_node (
-	acpi_namespace_node     *node);
-
-acpi_status
-acpi_ns_delete_namespace_subtree (
-	acpi_namespace_node     *parent_handle);
-
-void
-acpi_ns_detach_object (
-	acpi_namespace_node     *node);
-
-void
-acpi_ns_delete_children (
-	acpi_namespace_node     *parent);
-
-
-/*
- * Namespace modification - nsmodify
- */
-
-acpi_status
-acpi_ns_unload_namespace (
-	acpi_handle             handle);
-
-acpi_status
-acpi_ns_delete_subtree (
-	acpi_handle             start_handle);
-
-
-/*
- * Namespace dump/print utilities - nsdump
- */
-
-void
-acpi_ns_dump_tables (
-	acpi_handle             search_base,
-	u32                     max_depth);
-
-void
-acpi_ns_dump_entry (
-	acpi_handle             handle,
-	u32                     debug_level);
-
-acpi_status
-acpi_ns_dump_pathname (
-	acpi_handle             handle,
-	NATIVE_CHAR             *msg,
-	u32                     level,
-	u32                     component);
-
-void
-acpi_ns_dump_root_devices (
-	void);
-
-void
-acpi_ns_dump_objects (
-	acpi_object_type8       type,
-	u8                      display_type,
-	u32                     max_depth,
-	u32                     ownder_id,
-	acpi_handle             start_handle);
-
-
-/*
- * Namespace evaluation functions - nseval
- */
-
-acpi_status
-acpi_ns_evaluate_by_handle (
-	acpi_namespace_node     *prefix_node,
-	acpi_operand_object     **params,
-	acpi_operand_object     **return_object);
-
-acpi_status
-acpi_ns_evaluate_by_name (
-	NATIVE_CHAR             *pathname,
-	acpi_operand_object     **params,
-	acpi_operand_object     **return_object);
-
-acpi_status
-acpi_ns_evaluate_relative (
-	acpi_namespace_node     *prefix_node,
-	NATIVE_CHAR             *pathname,
-	acpi_operand_object     **params,
-	acpi_operand_object     **return_object);
-
-acpi_status
-acpi_ns_execute_control_method (
-	acpi_namespace_node     *method_node,
-	acpi_operand_object     **params,
-	acpi_operand_object     **return_obj_desc);
-
-acpi_status
-acpi_ns_get_object_value (
-	acpi_namespace_node     *object_node,
-	acpi_operand_object     **return_obj_desc);
-
-
-/*
- * Parent/Child/Peer utility functions - nsfamily
- */
-
-acpi_name
-acpi_ns_find_parent_name (
-	acpi_namespace_node     *node_to_search);
-
-u8
-acpi_ns_exist_downstream_sibling (
-	acpi_namespace_node     *this_node);
-
-
-/*
- * Scope manipulation - nsscope
- */
-
-u32
-acpi_ns_opens_scope (
-	acpi_object_type8       type);
-
-NATIVE_CHAR *
-acpi_ns_get_table_pathname (
-	acpi_namespace_node     *node);
-
-NATIVE_CHAR *
-acpi_ns_name_of_current_scope (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ns_handle_to_pathname (
-	acpi_handle             obj_handle,
-	u32                     *buf_size,
-	NATIVE_CHAR             *user_buffer);
-
-u8
-acpi_ns_pattern_match (
-	acpi_namespace_node     *obj_node,
-	NATIVE_CHAR             *search_for);
-
-acpi_status
-acpi_ns_get_node (
-	NATIVE_CHAR             *pathname,
-	acpi_namespace_node     *in_prefix_node,
-	acpi_namespace_node     **out_node);
-
-u32
-acpi_ns_get_pathname_length (
-	acpi_namespace_node     *node);
-
-
-/*
- * Object management for NTEs - nsobject
- */
-
-acpi_status
-acpi_ns_attach_object (
-	acpi_namespace_node     *node,
-	acpi_operand_object     *object,
-	acpi_object_type8       type);
-
-
-/*
- * Namespace searching and entry - nssearch
- */
-
-acpi_status
-acpi_ns_search_and_enter (
-	u32                     entry_name,
-	acpi_walk_state         *walk_state,
-	acpi_namespace_node     *node,
-	operating_mode          interpreter_mode,
-	acpi_object_type8       type,
-	u32                     flags,
-	acpi_namespace_node     **ret_node);
-
-acpi_status
-acpi_ns_search_node (
-	u32                     entry_name,
-	acpi_namespace_node     *node,
-	acpi_object_type8       type,
-	acpi_namespace_node     **ret_node);
-
-void
-acpi_ns_install_node (
-	acpi_walk_state         *walk_state,
-	acpi_namespace_node     *parent_node,   /* Parent */
-	acpi_namespace_node     *node,      /* New Child*/
-	acpi_object_type8       type);
-
-
-/*
- * Utility functions - nsutils
- */
-
-u8
-acpi_ns_valid_root_prefix (
-	NATIVE_CHAR             prefix);
-
-u8
-acpi_ns_valid_path_separator (
-	NATIVE_CHAR             sep);
-
-acpi_object_type8
-acpi_ns_get_type (
-	acpi_namespace_node     *node);
-
-void *
-acpi_ns_get_attached_object (
-	acpi_namespace_node     *node);
-
-u32
-acpi_ns_local (
-	acpi_object_type8       type);
-
-acpi_status
-acpi_ns_build_internal_name (
-	acpi_namestring_info    *info);
-
-acpi_status
-acpi_ns_get_internal_name_length (
-	acpi_namestring_info    *info);
-
-acpi_status
-acpi_ns_internalize_name (
-	NATIVE_CHAR             *dotted_name,
-	NATIVE_CHAR             **converted_name);
-
-acpi_status
-acpi_ns_externalize_name (
-	u32                     internal_name_length,
-	NATIVE_CHAR             *internal_name,
-	u32                     *converted_name_length,
-	NATIVE_CHAR             **converted_name);
-
-acpi_namespace_node *
-acpi_ns_map_handle_to_node (
-	acpi_handle             handle);
-
-acpi_handle
-acpi_ns_convert_entry_to_handle(
-	acpi_namespace_node     *node);
-
-void
-acpi_ns_terminate (
-	void);
-
-acpi_namespace_node *
-acpi_ns_get_parent_object (
-	acpi_namespace_node     *node);
-
-
-acpi_namespace_node *
-acpi_ns_get_next_valid_node (
-	acpi_namespace_node     *node);
-
-
-#endif /* __ACNAMESP_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/acobject.h linux-2.4.22-pre2/drivers/acpi/include/acobject.h
--- linux-2.4.21/drivers/acpi/include/acobject.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/acobject.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,451 +0,0 @@
-
-/******************************************************************************
- *
- * Name: acobject.h - Definition of acpi_operand_object  (Internal object only)
- *       $Revision: 93 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef _ACOBJECT_H
-#define _ACOBJECT_H
-
-
-/*
- * The acpi_operand_object  is used to pass AML operands from the dispatcher
- * to the interpreter, and to keep track of the various handlers such as
- * address space handlers and notify handlers.  The object is a constant
- * size in order to allow them to be cached and reused.
- *
- * All variants of the acpi_operand_object  are defined with the same
- * sequence of field types, with fields that are not used in a particular
- * variant being named "Reserved".  This is not strictly necessary, but
- * may in some circumstances simplify understanding if these structures
- * need to be displayed in a debugger having limited (or no) support for
- * union types.  It also simplifies some debug code in Dump_table() which
- * dumps multi-level values: fetching Buffer.Pointer suffices to pick up
- * the value or next level for any of several types.
- */
-
-/******************************************************************************
- *
- * Common Descriptors
- *
- *****************************************************************************/
-
-/*
- * Common area for all objects.
- *
- * Data_type is used to differentiate between internal descriptors, and MUST
- * be the first byte in this structure.
- */
-
-
-#define ACPI_OBJECT_COMMON_HEADER           /* SIZE/ALIGNMENT: 32-bits plus trailing 8-bit flag */\
-	u8                          data_type;          /* To differentiate various internal objs */\
-	u8                          type;               /* acpi_object_type */\
-	u16                         reference_count;    /* For object deletion management */\
-	u8                          flags; \
-
-/* Defines for flag byte above */
-
-#define AOPOBJ_STATIC_ALLOCATION    0x1
-#define AOPOBJ_STATIC_POINTER       0x2
-#define AOPOBJ_DATA_VALID           0x4
-#define AOPOBJ_ZERO_CONST           0x4
-#define AOPOBJ_INITIALIZED          0x8
-
-
-/*
- * Common bitfield for the field objects
- * "Field Datum"    -- a datum from the actual field object
- * "Buffer Datum"   -- a datum from a user buffer, read from or to be written to the field
- */
-#define ACPI_COMMON_FIELD_INFO              /* SIZE/ALIGNMENT: 24 bits + three 32-bit values */\
-	u8                          access_flags;\
-	u16                         bit_length;         /* Length of field in bits */\
-	u32                         base_byte_offset;   /* Byte offset within containing object */\
-	u8                          access_bit_width;   /* Read/Write size in bits (from ASL Access_type)*/\
-	u8                          access_byte_width;  /* Read/Write size in bytes */\
-	u8                          update_rule;        /* How neighboring field bits are handled */\
-	u8                          lock_rule;          /* Global Lock: 1 = "Must Lock" */\
-	u8                          start_field_bit_offset;/* Bit offset within first field datum (0-63) */\
-	u8                          datum_valid_bits;   /* Valid bit in first "Field datum" */\
-	u8                          end_field_valid_bits; /* Valid bits in the last "field datum" */\
-	u8                          end_buffer_valid_bits; /* Valid bits in the last "buffer datum" */\
-	u32                         value;              /* Value to store into the Bank or Index register */
-
-
-/* Access flag bits */
-
-#define AFIELD_SINGLE_DATUM         0x1
-
-
-/*
- * Fields common to both Strings and Buffers
- */
-#define ACPI_COMMON_BUFFER_INFO \
-	u32                         length;
-
-
-/******************************************************************************
- *
- * Individual Object Descriptors
- *
- *****************************************************************************/
-
-
-typedef struct /* COMMON */
-{
-	ACPI_OBJECT_COMMON_HEADER
-
-} ACPI_OBJECT_COMMON;
-
-
-typedef struct /* CACHE_LIST */
-{
-	ACPI_OBJECT_COMMON_HEADER
-	union acpi_operand_obj      *next;              /* Link for object cache and internal lists*/
-
-} ACPI_OBJECT_CACHE_LIST;
-
-
-typedef struct /* NUMBER - has value */
-{
-	ACPI_OBJECT_COMMON_HEADER
-
-	acpi_integer                value;
-
-} ACPI_OBJECT_INTEGER;
-
-
-typedef struct /* STRING - has length and pointer - Null terminated, ASCII characters only */
-{
-	ACPI_OBJECT_COMMON_HEADER
-	ACPI_COMMON_BUFFER_INFO
-	NATIVE_CHAR                 *pointer;           /* String value in AML stream or in allocated space */
-
-} ACPI_OBJECT_STRING;
-
-
-typedef struct /* BUFFER - has length and pointer - not null terminated */
-{
-	ACPI_OBJECT_COMMON_HEADER
-	ACPI_COMMON_BUFFER_INFO
-	u8                          *pointer;           /* Buffer value in AML stream or in allocated space */
-
-} ACPI_OBJECT_BUFFER;
-
-
-typedef struct /* PACKAGE - has count, elements, next element */
-{
-	ACPI_OBJECT_COMMON_HEADER
-
-	u32                         count;              /* # of elements in package */
-	union acpi_operand_obj      **elements;         /* Array of pointers to Acpi_objects */
-	union acpi_operand_obj      **next_element;     /* used only while initializing */
-
-} ACPI_OBJECT_PACKAGE;
-
-
-typedef struct /* DEVICE - has handle and notification handler/context */
-{
-	ACPI_OBJECT_COMMON_HEADER
-
-	union acpi_operand_obj      *sys_handler;        /* Handler for system notifies */
-	union acpi_operand_obj      *drv_handler;        /* Handler for driver notifies */
-	union acpi_operand_obj      *addr_handler;       /* Handler for Address space */
-
-} ACPI_OBJECT_DEVICE;
-
-
-typedef struct /* EVENT */
-{
-	ACPI_OBJECT_COMMON_HEADER
-	void                        *semaphore;
-
-} ACPI_OBJECT_EVENT;
-
-
-#define INFINITE_CONCURRENCY        0xFF
-
-typedef struct /* METHOD */
-{
-	ACPI_OBJECT_COMMON_HEADER
-	u8                          method_flags;
-	u8                          param_count;
-
-	u32                         aml_length;
-
-	void                        *semaphore;
-	u8                          *aml_start;
-
-	u8                          concurrency;
-	u8                          thread_count;
-	acpi_owner_id               owning_id;
-
-} ACPI_OBJECT_METHOD;
-
-
-typedef struct acpi_obj_mutex /* MUTEX */
-{
-	ACPI_OBJECT_COMMON_HEADER
-	u16                         sync_level;
-	u16                         acquisition_depth;
-
-	void                        *semaphore;
-	void                        *owner;
-	union acpi_operand_obj      *prev;              /* Link for list of acquired mutexes */
-	union acpi_operand_obj      *next;              /* Link for list of acquired mutexes */
-
-} ACPI_OBJECT_MUTEX;
-
-
-typedef struct /* REGION */
-{
-	ACPI_OBJECT_COMMON_HEADER
-
-	u8                          space_id;
-	u32                         length;
-	ACPI_PHYSICAL_ADDRESS       address;
-	union acpi_operand_obj      *extra;             /* Pointer to executable AML (in region definition) */
-
-	union acpi_operand_obj      *addr_handler;      /* Handler for system notifies */
-	acpi_namespace_node         *node;              /* containing object */
-	union acpi_operand_obj      *next;
-
-} ACPI_OBJECT_REGION;
-
-
-typedef struct /* POWER RESOURCE - has Handle and notification handler/context*/
-{
-	ACPI_OBJECT_COMMON_HEADER
-
-	u32                         system_level;
-	u32                         resource_order;
-
-	union acpi_operand_obj      *sys_handler;       /* Handler for system notifies */
-	union acpi_operand_obj      *drv_handler;       /* Handler for driver notifies */
-
-} ACPI_OBJECT_POWER_RESOURCE;
-
-
-typedef struct /* PROCESSOR - has Handle and notification handler/context*/
-{
-	ACPI_OBJECT_COMMON_HEADER
-
-	u32                         proc_id;
-	u32                         length;
-	ACPI_IO_ADDRESS             address;
-
-	union acpi_operand_obj      *sys_handler;       /* Handler for system notifies */
-	union acpi_operand_obj      *drv_handler;       /* Handler for driver notifies */
-	union acpi_operand_obj      *addr_handler;      /* Handler for Address space */
-
-} ACPI_OBJECT_PROCESSOR;
-
-
-typedef struct /* THERMAL ZONE - has Handle and Handler/Context */
-{
-	ACPI_OBJECT_COMMON_HEADER
-
-	union acpi_operand_obj      *sys_handler;       /* Handler for system notifies */
-	union acpi_operand_obj      *drv_handler;       /* Handler for driver notifies */
-	union acpi_operand_obj      *addr_handler;      /* Handler for Address space */
-
-} ACPI_OBJECT_THERMAL_ZONE;
-
-
-/*
- * Fields.  All share a common header/info field.
- */
-
-typedef struct /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */
-{
-	ACPI_OBJECT_COMMON_HEADER
-	ACPI_COMMON_FIELD_INFO
-	union acpi_operand_obj      *region_obj;        /* Containing Operation Region object */
-			 /* (REGION/BANK fields only) */
-} ACPI_OBJECT_FIELD_COMMON;
-
-
-typedef struct /* REGION FIELD */
-{
-	ACPI_OBJECT_COMMON_HEADER
-	ACPI_COMMON_FIELD_INFO
-	union acpi_operand_obj      *region_obj;        /* Containing Op_region object */
-
-} ACPI_OBJECT_REGION_FIELD;
-
-
-typedef struct /* BANK FIELD */
-{
-	ACPI_OBJECT_COMMON_HEADER
-	ACPI_COMMON_FIELD_INFO
-
-	union acpi_operand_obj      *region_obj;        /* Containing Op_region object */
-	union acpi_operand_obj      *bank_register_obj; /* Bank_select Register object */
-
-} ACPI_OBJECT_BANK_FIELD;
-
-
-typedef struct /* INDEX FIELD */
-{
-	ACPI_OBJECT_COMMON_HEADER
-	ACPI_COMMON_FIELD_INFO
-
-	/*
-	 * No "Region_obj" pointer needed since the Index and Data registers
-	 * are each field definitions unto themselves.
-	 */
-	union acpi_operand_obj      *index_obj;         /* Index register */
-	union acpi_operand_obj      *data_obj;          /* Data register */
-
-
-} ACPI_OBJECT_INDEX_FIELD;
-
-
-/* The Buffer_field is different in that it is part of a Buffer, not an Op_region */
-
-typedef struct /* BUFFER FIELD */
-{
-	ACPI_OBJECT_COMMON_HEADER
-	ACPI_COMMON_FIELD_INFO
-
-	union acpi_operand_obj      *extra;             /* Pointer to executable AML (in field definition) */
-	acpi_namespace_node         *node;              /* Parent (containing) object node */
-	union acpi_operand_obj      *buffer_obj;        /* Containing Buffer object */
-
-} ACPI_OBJECT_BUFFER_FIELD;
-
-
-/*
- * Handlers
- */
-
-typedef struct /* NOTIFY HANDLER */
-{
-	ACPI_OBJECT_COMMON_HEADER
-
-	acpi_namespace_node         *node;               /* Parent device */
-	acpi_notify_handler         handler;
-	void                        *context;
-
-} ACPI_OBJECT_NOTIFY_HANDLER;
-
-
-/* Flags for address handler */
-
-#define ADDR_HANDLER_DEFAULT_INSTALLED  0x1
-
-
-typedef struct /* ADDRESS HANDLER */
-{
-	ACPI_OBJECT_COMMON_HEADER
-
-	u8                          space_id;
-	u16                         hflags;
-	acpi_adr_space_handler      handler;
-
-	acpi_namespace_node         *node;              /* Parent device */
-	void                        *context;
-	acpi_adr_space_setup        setup;
-	union acpi_operand_obj      *region_list;       /* regions using this handler */
-	union acpi_operand_obj      *next;
-
-} ACPI_OBJECT_ADDR_HANDLER;
-
-
-/*
- * The Reference object type is used for these opcodes:
- * Arg[0-6], Local[0-7], Index_op, Name_op, Zero_op, One_op, Ones_op, Debug_op
- */
-
-typedef struct /* Reference - Local object type */
-{
-	ACPI_OBJECT_COMMON_HEADER
-
-	u8                          target_type;        /* Used for Index_op */
-	u16                         opcode;
-	u32                         offset;             /* Used for Arg_op, Local_op, and Index_op */
-
-	void                        *object;            /* Name_op=>HANDLE to obj, Index_op=>acpi_operand_object */
-	acpi_namespace_node         *node;
-	union acpi_operand_obj      **where;
-
-} ACPI_OBJECT_REFERENCE;
-
-
-/*
- * Extra object is used as additional storage for types that
- * have AML code in their declarations (Term_args) that must be
- * evaluated at run time.
- *
- * Currently: Region and Field_unit types
- */
-
-typedef struct /* EXTRA */
-{
-	ACPI_OBJECT_COMMON_HEADER
-	u8                          byte_fill1;
-	u16                         word_fill1;
-	u32                         aml_length;
-	u8                          *aml_start;
-	acpi_namespace_node         *method_REG;        /* _REG method for this region (if any) */
-	void                        *region_context;    /* Region-specific data */
-
-} ACPI_OBJECT_EXTRA;
-
-
-/******************************************************************************
- *
- * acpi_operand_object  Descriptor - a giant union of all of the above
- *
- *****************************************************************************/
-
-typedef union acpi_operand_obj
-{
-	ACPI_OBJECT_COMMON          common;
-	ACPI_OBJECT_CACHE_LIST      cache;
-	ACPI_OBJECT_INTEGER         integer;
-	ACPI_OBJECT_STRING          string;
-	ACPI_OBJECT_BUFFER          buffer;
-	ACPI_OBJECT_PACKAGE         package;
-	ACPI_OBJECT_BUFFER_FIELD    buffer_field;
-	ACPI_OBJECT_DEVICE          device;
-	ACPI_OBJECT_EVENT           event;
-	ACPI_OBJECT_METHOD          method;
-	ACPI_OBJECT_MUTEX           mutex;
-	ACPI_OBJECT_REGION          region;
-	ACPI_OBJECT_POWER_RESOURCE  power_resource;
-	ACPI_OBJECT_PROCESSOR       processor;
-	ACPI_OBJECT_THERMAL_ZONE    thermal_zone;
-	ACPI_OBJECT_FIELD_COMMON    common_field;
-	ACPI_OBJECT_REGION_FIELD    field;
-	ACPI_OBJECT_BANK_FIELD      bank_field;
-	ACPI_OBJECT_INDEX_FIELD     index_field;
-	ACPI_OBJECT_REFERENCE       reference;
-	ACPI_OBJECT_NOTIFY_HANDLER  notify_handler;
-	ACPI_OBJECT_ADDR_HANDLER    addr_handler;
-	ACPI_OBJECT_EXTRA           extra;
-
-} acpi_operand_object;
-
-#endif /* _ACOBJECT_H */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/acoutput.h linux-2.4.22-pre2/drivers/acpi/include/acoutput.h
--- linux-2.4.21/drivers/acpi/include/acoutput.h	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/acoutput.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,182 +0,0 @@
-/******************************************************************************
- *
- * Name: acoutput.h -- debug output
- *       $Revision: 84 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACOUTPUT_H__
-#define __ACOUTPUT_H__
-
-/*
- * Debug levels and component IDs.  These are used to control the
- * granularity of the output of the DEBUG_PRINT macro -- on a per-
- * component basis and a per-exception-type basis.
- */
-
-/* Component IDs are used in the global "Debug_layer" */
-
-#define ACPI_UTILITIES              0x00000001
-#define ACPI_HARDWARE               0x00000002
-#define ACPI_EVENTS                 0x00000004
-#define ACPI_TABLES                 0x00000008
-#define ACPI_NAMESPACE              0x00000010
-#define ACPI_PARSER                 0x00000020
-#define ACPI_DISPATCHER             0x00000040
-#define ACPI_EXECUTER               0x00000080
-#define ACPI_RESOURCES              0x00000100
-#define ACPI_DEBUGGER               0x00000200
-#define ACPI_OS_SERVICES            0x00000400
-
-#define ACPI_BUS                    0x00010000
-#define ACPI_SYSTEM                 0x00020000
-#define ACPI_POWER                  0x00040000
-#define ACPI_EC                     0x00080000
-#define ACPI_AC_ADAPTER             0x00100000
-#define ACPI_BATTERY                0x00200000
-#define ACPI_BUTTON                 0x00400000
-#define ACPI_PROCESSOR              0x00800000
-#define ACPI_THERMAL                0x01000000
-#define ACPI_FAN                    0x02000000
-
-#define ACPI_ALL_COMPONENTS         0x0FFFFFFF
-
-#define ACPI_COMPONENT_DEFAULT      (ACPI_ALL_COMPONENTS)
-
-
-#define ACPI_COMPILER               0x10000000
-#define ACPI_TOOLS                  0x20000000
-
-
-/*
- * Raw debug output levels, do not use these in the DEBUG_PRINT macros
- */
-
-#define ACPI_LV_OK                  0x00000001
-#define ACPI_LV_INFO                0x00000002
-#define ACPI_LV_WARN                0x00000004
-#define ACPI_LV_ERROR               0x00000008
-#define ACPI_LV_FATAL               0x00000010
-#define ACPI_LV_DEBUG_OBJECT        0x00000020
-#define ACPI_LV_ALL_EXCEPTIONS      0x0000003F
-
-
-/* Trace verbosity level 1 [Standard Trace Level] */
-
-#define ACPI_LV_PARSE               0x00000040
-#define ACPI_LV_LOAD                0x00000080
-#define ACPI_LV_DISPATCH            0x00000100
-#define ACPI_LV_EXEC                0x00000200
-#define ACPI_LV_NAMES               0x00000400
-#define ACPI_LV_OPREGION            0x00000800
-#define ACPI_LV_BFIELD              0x00001000
-#define ACPI_LV_TABLES              0x00002000
-#define ACPI_LV_VALUES              0x00004000
-#define ACPI_LV_OBJECTS             0x00008000
-#define ACPI_LV_RESOURCES           0x00010000
-#define ACPI_LV_USER_REQUESTS       0x00020000
-#define ACPI_LV_PACKAGE             0x00040000
-#define ACPI_LV_INIT                0x00080000
-#define ACPI_LV_VERBOSITY1          0x000FFF40 | ACPI_LV_ALL_EXCEPTIONS
-
-/* Trace verbosity level 2 [Function tracing and memory allocation] */
-
-#define ACPI_LV_ALLOCATIONS         0x00100000
-#define ACPI_LV_FUNCTIONS           0x00200000
-#define ACPI_LV_VERBOSITY2          0x00300000 | ACPI_LV_VERBOSITY1
-#define ACPI_LV_ALL                 ACPI_LV_VERBOSITY2
-
-/* Trace verbosity level 3 [Threading, I/O, and Interrupts] */
-
-#define ACPI_LV_MUTEX               0x01000000
-#define ACPI_LV_THREADS             0x02000000
-#define ACPI_LV_IO                  0x04000000
-#define ACPI_LV_INTERRUPTS          0x08000000
-#define ACPI_LV_VERBOSITY3          0x0F000000 | ACPI_LV_VERBOSITY2
-
-/*
- * Debug level macros that are used in the DEBUG_PRINT macros
- */
-
-#define ACPI_DEBUG_LEVEL(dl)       dl,__LINE__,&_dbg
-
-/* Exception level -- used in the global "Debug_level" */
-
-#define ACPI_DB_OK                  ACPI_DEBUG_LEVEL (ACPI_LV_OK)
-#define ACPI_DB_INFO                ACPI_DEBUG_LEVEL (ACPI_LV_INFO)
-#define ACPI_DB_WARN                ACPI_DEBUG_LEVEL (ACPI_LV_WARN)
-#define ACPI_DB_ERROR               ACPI_DEBUG_LEVEL (ACPI_LV_ERROR)
-#define ACPI_DB_FATAL               ACPI_DEBUG_LEVEL (ACPI_LV_FATAL)
-#define ACPI_DB_DEBUG_OBJECT        ACPI_DEBUG_LEVEL (ACPI_LV_DEBUG_OBJECT)
-#define ACPI_DB_ALL_EXCEPTIONS      ACPI_DEBUG_LEVEL (ACPI_LV_ALL_EXCEPTIONS)
-
-
-/* Trace level -- also used in the global "Debug_level" */
-
-#define ACPI_DB_THREADS             ACPI_DEBUG_LEVEL (ACPI_LV_THREADS)
-#define ACPI_DB_PARSE               ACPI_DEBUG_LEVEL (ACPI_LV_PARSE)
-#define ACPI_DB_DISPATCH            ACPI_DEBUG_LEVEL (ACPI_LV_DISPATCH)
-#define ACPI_DB_LOAD                ACPI_DEBUG_LEVEL (ACPI_LV_LOAD)
-#define ACPI_DB_EXEC                ACPI_DEBUG_LEVEL (ACPI_LV_EXEC)
-#define ACPI_DB_NAMES               ACPI_DEBUG_LEVEL (ACPI_LV_NAMES)
-#define ACPI_DB_OPREGION            ACPI_DEBUG_LEVEL (ACPI_LV_OPREGION)
-#define ACPI_DB_BFIELD              ACPI_DEBUG_LEVEL (ACPI_LV_BFIELD)
-#define ACPI_DB_TABLES              ACPI_DEBUG_LEVEL (ACPI_LV_TABLES)
-#define ACPI_DB_FUNCTIONS           ACPI_DEBUG_LEVEL (ACPI_LV_FUNCTIONS)
-#define ACPI_DB_VALUES              ACPI_DEBUG_LEVEL (ACPI_LV_VALUES)
-#define ACPI_DB_OBJECTS             ACPI_DEBUG_LEVEL (ACPI_LV_OBJECTS)
-#define ACPI_DB_ALLOCATIONS         ACPI_DEBUG_LEVEL (ACPI_LV_ALLOCATIONS)
-#define ACPI_DB_RESOURCES           ACPI_DEBUG_LEVEL (ACPI_LV_RESOURCES)
-#define ACPI_DB_IO                  ACPI_DEBUG_LEVEL (ACPI_LV_IO)
-#define ACPI_DB_INTERRUPTS          ACPI_DEBUG_LEVEL (ACPI_LV_INTERRUPTS)
-#define ACPI_DB_USER_REQUESTS       ACPI_DEBUG_LEVEL (ACPI_LV_USER_REQUESTS)
-#define ACPI_DB_PACKAGE             ACPI_DEBUG_LEVEL (ACPI_LV_PACKAGE)
-#define ACPI_DB_MUTEX               ACPI_DEBUG_LEVEL (ACPI_LV_MUTEX)
-#define ACPI_DB_INIT                ACPI_DEBUG_LEVEL (ACPI_LV_INIT)
-
-#define ACPI_DB_ALL                 ACPI_DEBUG_LEVEL (0x0FFFFF80)
-
-
-/* Exceptionally verbose output -- also used in the global "Debug_level" */
-
-#define ACPI_DB_AML_DISASSEMBLE     0x10000000
-#define ACPI_DB_VERBOSE_INFO        0x20000000
-#define ACPI_DB_FULL_TABLES         0x40000000
-#define ACPI_DB_EVENTS              0x80000000
-
-#define ACPI_DB_VERBOSE             0xF0000000
-
-
-/* Defaults for Debug_level, debug and normal */
-
-#define DEBUG_DEFAULT               (ACPI_LV_OK | ACPI_LV_WARN | ACPI_LV_ERROR | ACPI_LV_DEBUG_OBJECT)
-#define NORMAL_DEFAULT              (ACPI_LV_OK | ACPI_LV_WARN | ACPI_LV_ERROR | ACPI_LV_DEBUG_OBJECT)
-#define DEBUG_ALL                   (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL)
-
-/* Misc defines */
-
-#define HEX                         0x01
-#define ASCII                       0x02
-#define FULL_ADDRESS                0x04
-#define CHARS_PER_LINE              16          /* used in Dump_buf function */
-
-
-#endif /* __ACOUTPUT_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/acparser.h linux-2.4.22-pre2/drivers/acpi/include/acparser.h
--- linux-2.4.21/drivers/acpi/include/acparser.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/acparser.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,293 +0,0 @@
-/******************************************************************************
- *
- * Module Name: acparser.h - AML Parser subcomponent prototypes and defines
- *       $Revision: 54 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#ifndef __ACPARSER_H__
-#define __ACPARSER_H__
-
-
-#define OP_HAS_RETURN_VALUE         1
-
-/* variable # arguments */
-
-#define ACPI_VAR_ARGS               ACPI_UINT32_MAX
-
-/* maximum virtual address */
-
-#define ACPI_MAX_AML                ((u8 *)(~0UL))
-
-
-#define ACPI_PARSE_DELETE_TREE          0x0001
-#define ACPI_PARSE_NO_TREE_DELETE       0x0000
-#define ACPI_PARSE_TREE_MASK            0x0001
-
-#define ACPI_PARSE_LOAD_PASS1           0x0010
-#define ACPI_PARSE_LOAD_PASS2           0x0020
-#define ACPI_PARSE_EXECUTE              0x0030
-#define ACPI_PARSE_MODE_MASK            0x0030
-
-/* psapi - Parser external interfaces */
-
-acpi_status
-acpi_psx_load_table (
-	u8                      *pcode_addr,
-	u32                     pcode_length);
-
-acpi_status
-acpi_psx_execute (
-	acpi_namespace_node     *method_node,
-	acpi_operand_object     **params,
-	acpi_operand_object     **return_obj_desc);
-
-/******************************************************************************
- *
- * Parser interfaces
- *
- *****************************************************************************/
-
-
-/* psargs - Parse AML opcode arguments */
-
-u8 *
-acpi_ps_get_next_package_end (
-	acpi_parse_state        *parser_state);
-
-u32
-acpi_ps_get_next_package_length (
-	acpi_parse_state        *parser_state);
-
-NATIVE_CHAR *
-acpi_ps_get_next_namestring (
-	acpi_parse_state        *parser_state);
-
-void
-acpi_ps_get_next_simple_arg (
-	acpi_parse_state        *parser_state,
-	u32                     arg_type,       /* type of argument */
-	acpi_parse_object       *arg);           /* (OUT) argument data */
-
-void
-acpi_ps_get_next_namepath (
-	acpi_parse_state        *parser_state,
-	acpi_parse_object       *arg,
-	u32                     *arg_count,
-	u8                      method_call);
-
-acpi_parse_object *
-acpi_ps_get_next_field (
-	acpi_parse_state        *parser_state);
-
-acpi_parse_object *
-acpi_ps_get_next_arg (
-	acpi_parse_state        *parser_state,
-	u32                     arg_type,
-	u32                     *arg_count);
-
-
-/* psopcode - AML Opcode information */
-
-const acpi_opcode_info *
-acpi_ps_get_opcode_info (
-	u16                     opcode);
-
-NATIVE_CHAR *
-acpi_ps_get_opcode_name (
-	u16                     opcode);
-
-
-/* psparse - top level parsing routines */
-
-acpi_status
-acpi_ps_find_object (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       **out_op);
-
-void
-acpi_ps_delete_parse_tree (
-	acpi_parse_object       *root);
-
-acpi_status
-acpi_ps_parse_loop (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ps_parse_aml (
-	acpi_walk_state         *walk_state);
-
-acpi_status
-acpi_ps_parse_table (
-	u8                      *aml,
-	u32                     aml_size,
-	acpi_parse_downwards    descending_callback,
-	acpi_parse_upwards      ascending_callback,
-	acpi_parse_object       **root_object);
-
-u16
-acpi_ps_peek_opcode (
-	acpi_parse_state        *state);
-
-
-/* psscope - Scope stack management routines */
-
-
-acpi_status
-acpi_ps_init_scope (
-	acpi_parse_state        *parser_state,
-	acpi_parse_object       *root);
-
-acpi_parse_object *
-acpi_ps_get_parent_scope (
-	acpi_parse_state        *state);
-
-u8
-acpi_ps_has_completed_scope (
-	acpi_parse_state        *parser_state);
-
-void
-acpi_ps_pop_scope (
-	acpi_parse_state        *parser_state,
-	acpi_parse_object       **op,
-	u32                     *arg_list,
-	u32                     *arg_count);
-
-acpi_status
-acpi_ps_push_scope (
-	acpi_parse_state        *parser_state,
-	acpi_parse_object       *op,
-	u32                     remaining_args,
-	u32                     arg_count);
-
-void
-acpi_ps_cleanup_scope (
-	acpi_parse_state        *state);
-
-
-/* pstree - parse tree manipulation routines */
-
-void
-acpi_ps_append_arg(
-	acpi_parse_object       *op,
-	acpi_parse_object       *arg);
-
-acpi_parse_object*
-acpi_ps_find (
-	acpi_parse_object       *scope,
-	NATIVE_CHAR             *path,
-	u16                     opcode,
-	u32                     create);
-
-acpi_parse_object *
-acpi_ps_get_arg(
-	acpi_parse_object       *op,
-	u32                      argn);
-
-acpi_parse_object *
-acpi_ps_get_child (
-	acpi_parse_object       *op);
-
-acpi_parse_object *
-acpi_ps_get_depth_next (
-	acpi_parse_object       *origin,
-	acpi_parse_object       *op);
-
-
-/* pswalk - parse tree walk routines */
-
-acpi_status
-acpi_ps_walk_parsed_aml (
-	acpi_parse_object       *start_op,
-	acpi_parse_object       *end_op,
-	acpi_operand_object     *mth_desc,
-	acpi_namespace_node     *start_node,
-	acpi_operand_object     **params,
-	acpi_operand_object     **caller_return_desc,
-	acpi_owner_id           owner_id,
-	acpi_parse_downwards    descending_callback,
-	acpi_parse_upwards      ascending_callback);
-
-acpi_status
-acpi_ps_get_next_walk_op (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op,
-	acpi_parse_upwards      ascending_callback);
-
-
-/* psutils - parser utilities */
-
-void
-acpi_ps_init_op (
-	acpi_parse_object       *op,
-	u16                     opcode);
-
-acpi_parse_object *
-acpi_ps_alloc_op (
-	u16                     opcode);
-
-void
-acpi_ps_free_op (
-	acpi_parse_object       *op);
-
-void
-acpi_ps_delete_parse_cache (
-	void);
-
-u8
-acpi_ps_is_leading_char (
-	u32                     c);
-
-u8
-acpi_ps_is_prefix_char (
-	u32                     c);
-
-u32
-acpi_ps_get_name(
-	acpi_parse_object       *op);
-
-void
-acpi_ps_set_name(
-	acpi_parse_object       *op,
-	u32                     name);
-
-
-/* psdump - display parser tree */
-
-u32
-acpi_ps_sprint_path (
-	NATIVE_CHAR             *buffer_start,
-	u32                     buffer_size,
-	acpi_parse_object       *op);
-
-u32
-acpi_ps_sprint_op (
-	NATIVE_CHAR             *buffer_start,
-	u32                     buffer_size,
-	acpi_parse_object       *op);
-
-void
-acpi_ps_show (
-	acpi_parse_object       *op);
-
-
-#endif /* __ACPARSER_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/acpi.h linux-2.4.22-pre2/drivers/acpi/include/acpi.h
--- linux-2.4.21/drivers/acpi/include/acpi.h	2001-06-21 00:47:40.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/acpi.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,51 +0,0 @@
-/******************************************************************************
- *
- * Name: acpi.h - Master include file, Publics and external data.
- *       $Revision: 54 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACPI_H__
-#define __ACPI_H__
-
-/*
- * Common includes for all ACPI driver files
- * We put them here because we don't want to duplicate them
- * in the rest of the source code again and again.
- */
-#include "acconfig.h"           /* Configuration constants */
-#include "platform/acenv.h"     /* Target environment specific items */
-#include "actypes.h"            /* Fundamental common data types */
-#include "acexcep.h"            /* ACPI exception codes */
-#include "acmacros.h"           /* C macros */
-#include "actbl.h"              /* ACPI table definitions */
-#include "aclocal.h"            /* Internal data types */
-#include "acoutput.h"           /* Error output and Debug macros */
-#include "acpiosxf.h"           /* Interfaces to the ACPI-to-OS layer*/
-#include "acpixf.h"             /* ACPI core subsystem external interfaces */
-#include "acobject.h"           /* ACPI internal object */
-#include "acstruct.h"           /* Common structures */
-#include "acglobal.h"           /* All global variables */
-#include "achware.h"            /* Hardware defines and interfaces */
-#include "acutils.h"            /* Utility interfaces */
-
-
-#endif /* __ACPI_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/acpiosxf.h linux-2.4.22-pre2/drivers/acpi/include/acpiosxf.h
--- linux-2.4.21/drivers/acpi/include/acpiosxf.h	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/acpiosxf.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,307 +0,0 @@
-
-/******************************************************************************
- *
- * Name: acpiosxf.h - All interfaces to the OS Services Layer (OSL).  These
- *                    interfaces must be implemented by OSL to interface the
- *                    ACPI components to the host operating system.
- *
- *****************************************************************************/
-
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACPIOSXF_H__
-#define __ACPIOSXF_H__
-
-#include "platform/acenv.h"
-#include "actypes.h"
-
-
-/* Priorities for Acpi_os_queue_for_execution */
-
-#define OSD_PRIORITY_GPE            1
-#define OSD_PRIORITY_HIGH           2
-#define OSD_PRIORITY_MED            3
-#define OSD_PRIORITY_LO             4
-
-#define ACPI_NO_UNIT_LIMIT          ((u32) -1)
-#define ACPI_MUTEX_SEM              1
-
-
-/* Functions for Acpi_os_signal */
-
-#define ACPI_SIGNAL_FATAL           0
-#define ACPI_SIGNAL_BREAKPOINT      1
-
-typedef struct acpi_fatal_info
-{
-	u32                     type;
-	u32                     code;
-	u32                     argument;
-
-} ACPI_SIGNAL_FATAL_INFO;
-
-
-/*
- * Types specific to the OS service interfaces
- */
-
-typedef
-u32 (*OSD_HANDLER) (
-	void                    *context);
-
-typedef
-void (*OSD_EXECUTION_CALLBACK) (
-	void                    *context);
-
-
-/*
- * OSL Initialization and shutdown primitives
- */
-
-acpi_status
-acpi_os_initialize (
-	void);
-
-acpi_status
-acpi_os_terminate (
-	void);
-
-acpi_status
-acpi_os_get_root_pointer (
-	u32                     flags,
-	ACPI_PHYSICAL_ADDRESS   *rsdp_physical_address);
-
-
-/*
- * Synchronization primitives
- */
-
-acpi_status
-acpi_os_create_semaphore (
-	u32                     max_units,
-	u32                     initial_units,
-	acpi_handle             *out_handle);
-
-acpi_status
-acpi_os_delete_semaphore (
-	acpi_handle             handle);
-
-acpi_status
-acpi_os_wait_semaphore (
-	acpi_handle             handle,
-	u32                     units,
-	u32                     timeout);
-
-acpi_status
-acpi_os_signal_semaphore (
-	acpi_handle             handle,
-	u32                     units);
-
-
-/*
- * Memory allocation and mapping
- */
-
-void *
-acpi_os_allocate (
-	u32                     size);
-
-void *
-acpi_os_callocate (
-	u32                     size);
-
-void
-acpi_os_free (
-	void *                  memory);
-
-acpi_status
-acpi_os_map_memory (
-	ACPI_PHYSICAL_ADDRESS   physical_address,
-	u32                     length,
-	void                    **logical_address);
-
-void
-acpi_os_unmap_memory (
-	void                    *logical_address,
-	u32                     length);
-
-acpi_status
-acpi_os_get_physical_address (
-	void                    *logical_address,
-	ACPI_PHYSICAL_ADDRESS   *physical_address);
-
-
-/*
- * Interrupt handlers
- */
-
-acpi_status
-acpi_os_install_interrupt_handler (
-	u32                     interrupt_number,
-	OSD_HANDLER             service_routine,
-	void                    *context);
-
-acpi_status
-acpi_os_remove_interrupt_handler (
-	u32                     interrupt_number,
-	OSD_HANDLER             service_routine);
-
-
-/*
- * Threads and Scheduling
- */
-
-u32
-acpi_os_get_thread_id (
-	void);
-
-acpi_status
-acpi_os_queue_for_execution (
-	u32                     priority,
-	OSD_EXECUTION_CALLBACK  function,
-	void                    *context);
-
-void
-acpi_os_sleep (
-	u32                     seconds,
-	u32                     milliseconds);
-
-void
-acpi_os_stall (
-	u32                     microseconds);
-
-
-/*
- * Platform and hardware-independent I/O interfaces
- */
-
-acpi_status
-acpi_os_read_port (
-	ACPI_IO_ADDRESS         address,
-	void                    *value,
-	u32                     width);
-
-
-acpi_status
-acpi_os_write_port (
-	ACPI_IO_ADDRESS         address,
-	NATIVE_UINT             value,
-	u32                     width);
-
-
-/*
- * Platform and hardware-independent physical memory interfaces
- */
-
-acpi_status
-acpi_os_read_memory (
-	ACPI_PHYSICAL_ADDRESS   address,
-	void                    *value,
-	u32                     width);
-
-
-acpi_status
-acpi_os_write_memory (
-	ACPI_PHYSICAL_ADDRESS   address,
-	NATIVE_UINT             value,
-	u32                     width);
-
-
-/*
- * Platform and hardware-independent PCI configuration space access
- */
-
-acpi_status
-acpi_os_read_pci_configuration (
-	acpi_pci_id             *pci_id,
-	u32                     register,
-	void                    *value,
-	u32                     width);
-
-
-acpi_status
-acpi_os_write_pci_configuration (
-	acpi_pci_id             *pci_id,
-	u32                     register,
-	NATIVE_UINT             value,
-	u32                     width);
-
-
-/*
- * Miscellaneous
- */
-
-u8
-acpi_os_readable (
-	void                    *pointer,
-	u32                     length);
-
-
-u8
-acpi_os_writable (
-	void                    *pointer,
-	u32                     length);
-
-u32
-acpi_os_get_timer (
-	void);
-
-acpi_status
-acpi_os_signal (
-	u32                     function,
-	void                    *info);
-
-/*
- * Debug print routines
- */
-
-s32
-acpi_os_printf (
-	const NATIVE_CHAR       *format,
-	...);
-
-s32
-acpi_os_vprintf (
-	const NATIVE_CHAR       *format,
-	va_list                 args);
-
-
-/*
- * Debug input
- */
-
-u32
-acpi_os_get_line (
-	NATIVE_CHAR             *buffer);
-
-
-/*
- * Debug
- */
-
-void
-acpi_os_dbg_assert(
-	void                    *failed_assertion,
-	void                    *file_name,
-	u32                     line_number,
-	NATIVE_CHAR             *message);
-
-
-#endif /* __ACPIOSXF_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/acpixf.h linux-2.4.22-pre2/drivers/acpi/include/acpixf.h
--- linux-2.4.21/drivers/acpi/include/acpixf.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/acpixf.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,326 +0,0 @@
-
-/******************************************************************************
- *
- * Name: acpixf.h - External interfaces to the ACPI subsystem
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#ifndef __ACXFACE_H__
-#define __ACXFACE_H__
-
-#include "actypes.h"
-#include "actbl.h"
-
-
- /*
- * Global interfaces
- */
-
-acpi_status
-acpi_initialize_subsystem (
-	void);
-
-acpi_status
-acpi_enable_subsystem (
-	u32                     flags);
-
-acpi_status
-acpi_terminate (
-	void);
-
-acpi_status
-acpi_subsystem_status (
-	void);
-
-acpi_status
-acpi_enable (
-	void);
-
-acpi_status
-acpi_disable (
-	void);
-
-acpi_status
-acpi_get_system_info (
-	acpi_buffer             *ret_buffer);
-
-const char *
-acpi_format_exception (
-	acpi_status             exception);
-
-
-/*
- * ACPI Memory manager
- */
-
-void *
-acpi_allocate (
-	u32                     size);
-
-void *
-acpi_callocate (
-	u32                     size);
-
-void
-acpi_free (
-	void                    *address);
-
-
-/*
- * ACPI table manipulation interfaces
- */
-
-acpi_status
-acpi_find_root_pointer (
-	u32                     flags,
-	ACPI_PHYSICAL_ADDRESS   *rsdp_physical_address);
-
-acpi_status
-acpi_load_tables (
-	void);
-
-acpi_status
-acpi_load_table (
-	acpi_table_header       *table_ptr);
-
-acpi_status
-acpi_unload_table (
-	acpi_table_type         table_type);
-
-acpi_status
-acpi_get_table_header (
-	acpi_table_type         table_type,
-	u32                     instance,
-	acpi_table_header       *out_table_header);
-
-acpi_status
-acpi_get_table (
-	acpi_table_type         table_type,
-	u32                     instance,
-	acpi_buffer             *ret_buffer);
-
-acpi_status
-acpi_get_firmware_table (
-	acpi_string             signature,
-	u32                     instance,
-	u32                     flags,
-	acpi_table_header       **table_pointer);
-
-
-/*
- * Namespace and name interfaces
- */
-
-acpi_status
-acpi_walk_namespace (
-	acpi_object_type        type,
-	acpi_handle             start_object,
-	u32                     max_depth,
-	acpi_walk_callback      user_function,
-	void                    *context,
-	void *                  *return_value);
-
-acpi_status
-acpi_get_devices (
-	NATIVE_CHAR             *HID,
-	acpi_walk_callback      user_function,
-	void                    *context,
-	void                    **return_value);
-
-acpi_status
-acpi_get_name (
-	acpi_handle             handle,
-	u32                     name_type,
-	acpi_buffer             *ret_path_ptr);
-
-acpi_status
-acpi_get_handle (
-	acpi_handle             parent,
-	acpi_string             pathname,
-	acpi_handle             *ret_handle);
-
-
-/*
- * Object manipulation and enumeration
- */
-
-acpi_status
-acpi_evaluate_object (
-	acpi_handle             object,
-	acpi_string             pathname,
-	acpi_object_list        *parameter_objects,
-	acpi_buffer             *return_object_buffer);
-
-acpi_status
-acpi_get_object_info (
-	acpi_handle             device,
-	acpi_device_info        *info);
-
-acpi_status
-acpi_get_next_object (
-	acpi_object_type        type,
-	acpi_handle             parent,
-	acpi_handle             child,
-	acpi_handle             *out_handle);
-
-acpi_status
-acpi_get_type (
-	acpi_handle             object,
-	acpi_object_type        *out_type);
-
-acpi_status
-acpi_get_parent (
-	acpi_handle             object,
-	acpi_handle             *out_handle);
-
-
-/*
- * Event handler interfaces
- */
-
-acpi_status
-acpi_install_fixed_event_handler (
-	u32                     acpi_event,
-	acpi_event_handler      handler,
-	void                    *context);
-
-acpi_status
-acpi_remove_fixed_event_handler (
-	u32                     acpi_event,
-	acpi_event_handler      handler);
-
-acpi_status
-acpi_install_notify_handler (
-	acpi_handle             device,
-	u32                     handler_type,
-	acpi_notify_handler     handler,
-	void                    *context);
-
-acpi_status
-acpi_remove_notify_handler (
-	acpi_handle             device,
-	u32                     handler_type,
-	acpi_notify_handler     handler);
-
-acpi_status
-acpi_install_address_space_handler (
-	acpi_handle             device,
-	ACPI_ADR_SPACE_TYPE     space_id,
-	acpi_adr_space_handler  handler,
-	acpi_adr_space_setup    setup,
-	void                    *context);
-
-acpi_status
-acpi_remove_address_space_handler (
-	acpi_handle             device,
-	ACPI_ADR_SPACE_TYPE     space_id,
-	acpi_adr_space_handler  handler);
-
-acpi_status
-acpi_install_gpe_handler (
-	u32                     gpe_number,
-	u32                     type,
-	acpi_gpe_handler        handler,
-	void                    *context);
-
-acpi_status
-acpi_acquire_global_lock (
-	void);
-
-acpi_status
-acpi_release_global_lock (
-	void);
-
-acpi_status
-acpi_remove_gpe_handler (
-	u32                     gpe_number,
-	acpi_gpe_handler        handler);
-
-acpi_status
-acpi_enable_event (
-	u32                     acpi_event,
-	u32                     type,
-	u32                     flags);
-
-acpi_status
-acpi_disable_event (
-	u32                     acpi_event,
-	u32                     type,
-	u32                     flags);
-
-acpi_status
-acpi_clear_event (
-	u32                     acpi_event,
-	u32                     type);
-
-acpi_status
-acpi_get_event_status (
-	u32                     acpi_event,
-	u32                     type,
-	acpi_event_status       *event_status);
-
-/*
- * Resource interfaces
- */
-
-acpi_status
-acpi_get_current_resources(
-	acpi_handle             device_handle,
-	acpi_buffer             *ret_buffer);
-
-acpi_status
-acpi_get_possible_resources(
-	acpi_handle             device_handle,
-	acpi_buffer             *ret_buffer);
-
-acpi_status
-acpi_set_current_resources (
-	acpi_handle             device_handle,
-	acpi_buffer             *in_buffer);
-
-acpi_status
-acpi_get_irq_routing_table (
-	acpi_handle             bus_device_handle,
-	acpi_buffer             *ret_buffer);
-
-
-/*
- * Hardware (ACPI device) interfaces
- */
-
-acpi_status
-acpi_set_firmware_waking_vector (
-	ACPI_PHYSICAL_ADDRESS   physical_address);
-
-acpi_status
-acpi_get_firmware_waking_vector (
-	ACPI_PHYSICAL_ADDRESS   *physical_address);
-
-acpi_status
-acpi_enter_sleep_state (
-	u8 sleep_state);
-
-acpi_status
-acpi_leave_sleep_state (
-	u8 sleep_state);
-
-#endif /* __ACXFACE_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/acresrc.h linux-2.4.22-pre2/drivers/acpi/include/acresrc.h
--- linux-2.4.21/drivers/acpi/include/acresrc.h	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/acresrc.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,320 +0,0 @@
-/******************************************************************************
- *
- * Name: acresrc.h - Resource Manager function prototypes
- *       $Revision: 25 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACRESRC_H__
-#define __ACRESRC_H__
-
-
-/*
- *  Function prototypes called from Acpi* APIs
- */
-
-acpi_status
-acpi_rs_get_prt_method_data (
-	acpi_handle             handle,
-	acpi_buffer             *ret_buffer);
-
-
-acpi_status
-acpi_rs_get_crs_method_data (
-	acpi_handle             handle,
-	acpi_buffer             *ret_buffer);
-
-acpi_status
-acpi_rs_get_prs_method_data (
-	acpi_handle             handle,
-	acpi_buffer             *ret_buffer);
-
-acpi_status
-acpi_rs_set_srs_method_data (
-	acpi_handle             handle,
-	acpi_buffer             *ret_buffer);
-
-acpi_status
-acpi_rs_create_resource_list (
-	acpi_operand_object     *byte_stream_buffer,
-	u8                      *output_buffer,
-	u32                     *output_buffer_length);
-
-acpi_status
-acpi_rs_create_byte_stream (
-	acpi_resource           *linked_list_buffer,
-	u8                      *output_buffer,
-	u32                     *output_buffer_length);
-
-acpi_status
-acpi_rs_create_pci_routing_table (
-	acpi_operand_object     *method_return_object,
-	u8                      *output_buffer,
-	u32                     *output_buffer_length);
-
-
-/*
- *Function prototypes called from Acpi_rs_create*APIs
- */
-
-void
-acpi_rs_dump_resource_list (
-	acpi_resource           *resource);
-
-void
-acpi_rs_dump_irq_list (
-	u8                      *route_table);
-
-acpi_status
-acpi_rs_get_byte_stream_start (
-	u8                      *byte_stream_buffer,
-	u8                      **byte_stream_start,
-	u32                     *size);
-
-acpi_status
-acpi_rs_calculate_list_length (
-	u8                      *byte_stream_buffer,
-	u32                     byte_stream_buffer_length,
-	u32                     *size_needed);
-
-acpi_status
-acpi_rs_calculate_byte_stream_length (
-	acpi_resource           *linked_list_buffer,
-	u32                     *size_needed);
-
-acpi_status
-acpi_rs_calculate_pci_routing_table_length (
-	acpi_operand_object     *package_object,
-	u32                     *buffer_size_needed);
-
-acpi_status
-acpi_rs_byte_stream_to_list (
-	u8                      *byte_stream_buffer,
-	u32                     byte_stream_buffer_length,
-	u8                      **output_buffer);
-
-acpi_status
-acpi_rs_list_to_byte_stream (
-	acpi_resource           *linked_list,
-	u32                     byte_stream_size_needed,
-	u8                      **output_buffer);
-
-acpi_status
-acpi_rs_io_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size);
-
-acpi_status
-acpi_rs_fixed_io_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size);
-
-acpi_status
-acpi_rs_io_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed);
-
-acpi_status
-acpi_rs_fixed_io_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed);
-
-acpi_status
-acpi_rs_irq_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size);
-
-acpi_status
-acpi_rs_irq_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed);
-
-acpi_status
-acpi_rs_dma_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size);
-
-acpi_status
-acpi_rs_dma_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed);
-
-acpi_status
-acpi_rs_address16_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size);
-
-acpi_status
-acpi_rs_address16_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed);
-
-acpi_status
-acpi_rs_address32_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size);
-
-acpi_status
-acpi_rs_address32_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed);
-
-acpi_status
-acpi_rs_address64_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size);
-
-acpi_status
-acpi_rs_address64_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed);
-
-acpi_status
-acpi_rs_start_dependent_functions_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size);
-
-acpi_status
-acpi_rs_end_dependent_functions_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size);
-
-acpi_status
-acpi_rs_start_dependent_functions_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed);
-
-acpi_status
-acpi_rs_end_dependent_functions_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed);
-
-acpi_status
-acpi_rs_memory24_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size);
-
-acpi_status
-acpi_rs_memory24_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed);
-
-acpi_status
-acpi_rs_memory32_range_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size
-);
-
-acpi_status
-acpi_rs_fixed_memory32_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size);
-
-acpi_status
-acpi_rs_memory32_range_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed);
-
-acpi_status
-acpi_rs_fixed_memory32_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed);
-
-acpi_status
-acpi_rs_extended_irq_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size);
-
-acpi_status
-acpi_rs_extended_irq_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed);
-
-acpi_status
-acpi_rs_end_tag_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size);
-
-acpi_status
-acpi_rs_end_tag_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed);
-
-acpi_status
-acpi_rs_vendor_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size);
-
-acpi_status
-acpi_rs_vendor_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed);
-
-u8
-acpi_rs_get_resource_type (
-	u8                      resource_start_byte);
-
-#endif  /* __ACRESRC_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/acstruct.h linux-2.4.22-pre2/drivers/acpi/include/acstruct.h
--- linux-2.4.21/drivers/acpi/include/acstruct.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/acstruct.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,199 +0,0 @@
-/******************************************************************************
- *
- * Name: acstruct.h - Internal structs
- *       $Revision: 10 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACSTRUCT_H__
-#define __ACSTRUCT_H__
-
-
-/*****************************************************************************
- *
- * Tree walking typedefs and structs
- *
- ****************************************************************************/
-
-
-/*
- * Walk state - current state of a parse tree walk.  Used for both a leisurely stroll through
- * the tree (for whatever reason), and for control method execution.
- */
-
-#define NEXT_OP_DOWNWARD    1
-#define NEXT_OP_UPWARD      2
-
-#define WALK_NON_METHOD     0
-#define WALK_METHOD         1
-#define WALK_METHOD_RESTART 2
-
-typedef struct acpi_walk_state
-{
-	u8                      data_type;                          /* To differentiate various internal objs MUST BE FIRST!*/\
-	acpi_owner_id           owner_id;                           /* Owner of objects created during the walk */
-	u8                      last_predicate;                     /* Result of last predicate */
-	u8                      current_result;                     /* */
-	u8                      next_op_info;                       /* Info about Next_op */
-	u8                      num_operands;                       /* Stack pointer for Operands[] array */
-	u8                      return_used;
-	u8                      walk_type;
-	u16                     current_sync_level;                 /* Mutex Sync (nested acquire) level */
-	u16                     opcode;                             /* Current AML opcode */
-	u32                     arg_count;                          /* push for fixed or var args */
-	u32                     aml_offset;
-	u32                     arg_types;
-	u32                     method_breakpoint;                  /* For single stepping */
-	u32                     parse_flags;
-	u32                     prev_arg_types;
-
-
-	u8                      *aml_last_while;
-	struct acpi_node        arguments[MTH_NUM_ARGS];            /* Control method arguments */
-	union acpi_operand_obj  **caller_return_desc;
-	acpi_generic_state      *control_state;                     /* List of control states (nested IFs) */
-	struct acpi_node        local_variables[MTH_NUM_LOCALS];    /* Control method locals */
-	struct acpi_node        *method_call_node;                  /* Called method Node*/
-	acpi_parse_object       *method_call_op;                    /* Method_call Op if running a method */
-	union acpi_operand_obj  *method_desc;                       /* Method descriptor if running a method */
-	struct acpi_node        *method_node;                       /* Method Node if running a method */
-	acpi_parse_object       *op;                                /* Current parser op */
-	union acpi_operand_obj  *operands[OBJ_NUM_OPERANDS+1];      /* Operands passed to the interpreter (+1 for NULL terminator) */
-	const acpi_opcode_info  *op_info;                           /* Info on current opcode */
-	acpi_parse_object       *origin;                            /* Start of walk [Obsolete] */
-	union acpi_operand_obj  **params;
-	acpi_parse_state        parser_state;                       /* Current state of parser */
-	union acpi_operand_obj  *result_obj;
-	acpi_generic_state      *results;                           /* Stack of accumulated results */
-	union acpi_operand_obj  *return_desc;                       /* Return object, if any */
-	acpi_generic_state      *scope_info;                        /* Stack of nested scopes */
-
-/* TBD: Obsolete with removal of WALK procedure ? */
-	acpi_parse_object       *prev_op;                           /* Last op that was processed */
-	acpi_parse_object       *next_op;                           /* next op to be processed */
-
-
-	acpi_parse_downwards    descending_callback;
-	acpi_parse_upwards      ascending_callback;
-	struct acpi_walk_list   *walk_list;
-	struct acpi_walk_state  *next;                              /* Next Walk_state in list */
-
-
-} acpi_walk_state;
-
-
-/*
- * Walk list - head of a tree of walk states.  Multiple walk states are created when there
- * are nested control methods executing.
- */
-typedef struct acpi_walk_list
-{
-
-	acpi_walk_state         *walk_state;
-	ACPI_OBJECT_MUTEX       acquired_mutex_list;               /* List of all currently acquired mutexes */
-
-} acpi_walk_list;
-
-
-/* Info used by Acpi_ps_init_objects */
-
-typedef struct acpi_init_walk_info
-{
-	u16                     method_count;
-	u16                     op_region_count;
-	u16                     field_count;
-	u16                     op_region_init;
-	u16                     field_init;
-	u16                     object_count;
-	acpi_table_desc         *table_desc;
-
-} acpi_init_walk_info;
-
-
-/* Info used by TBD */
-
-typedef struct acpi_device_walk_info
-{
-	u16                     device_count;
-	u16                     num_STA;
-	u16                     num_INI;
-	acpi_table_desc         *table_desc;
-
-} acpi_device_walk_info;
-
-
-/* TBD: [Restructure] Merge with struct above */
-
-typedef struct acpi_walk_info
-{
-	u32                     debug_level;
-	u32                     owner_id;
-	u8                      display_type;
-
-} acpi_walk_info;
-
-/* Display Types */
-
-#define ACPI_DISPLAY_SUMMARY    0
-#define ACPI_DISPLAY_OBJECTS    1
-
-typedef struct acpi_get_devices_info
-{
-	acpi_walk_callback      user_function;
-	void                    *context;
-	NATIVE_CHAR             *hid;
-
-} acpi_get_devices_info;
-
-
-typedef union acpi_aml_operands
-{
-	acpi_operand_object         *operands[7];
-
-	struct
-	{
-		ACPI_OBJECT_INTEGER     *type;
-		ACPI_OBJECT_INTEGER     *code;
-		ACPI_OBJECT_INTEGER     *argument;
-
-	} fatal;
-
-	struct
-	{
-		acpi_operand_object     *source;
-		ACPI_OBJECT_INTEGER     *index;
-		acpi_operand_object     *target;
-
-	} index;
-
-	struct
-	{
-		acpi_operand_object     *source;
-		ACPI_OBJECT_INTEGER     *index;
-		ACPI_OBJECT_INTEGER     *length;
-		acpi_operand_object     *target;
-
-	} mid;
-
-} ACPI_AML_OPERANDS;
-
-
-#endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/actables.h linux-2.4.22-pre2/drivers/acpi/include/actables.h
--- linux-2.4.21/drivers/acpi/include/actables.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/actables.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,200 +0,0 @@
-/******************************************************************************
- *
- * Name: actables.h - ACPI table management
- *       $Revision: 32 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACTABLES_H__
-#define __ACTABLES_H__
-
-
-/* Used in Acpi_tb_map_acpi_table for size parameter if table header is to be used */
-
-#define SIZE_IN_HEADER          0
-
-
-acpi_status
-acpi_tb_handle_to_object (
-	u16                     table_id,
-	acpi_table_desc         **table_desc);
-
-/*
- * tbconvrt - Table conversion routines
- */
-
-acpi_status
-acpi_tb_convert_to_xsdt (
-	acpi_table_desc         *table_info,
-	u32                     *number_of_tables);
-
-acpi_status
-acpi_tb_convert_table_fadt (
-	void);
-
-acpi_status
-acpi_tb_build_common_facs (
-	acpi_table_desc         *table_info);
-
-u32
-acpi_tb_get_table_count (
-	RSDP_DESCRIPTOR         *RSDP,
-	acpi_table_header       *RSDT);
-
-/*
- * tbget - Table "get" routines
- */
-
-acpi_status
-acpi_tb_get_table_ptr (
-	acpi_table_type         table_type,
-	u32                     instance,
-	acpi_table_header       **table_ptr_loc);
-
-acpi_status
-acpi_tb_get_table (
-	ACPI_PHYSICAL_ADDRESS   physical_address,
-	acpi_table_header       *buffer_ptr,
-	acpi_table_desc         *table_info);
-
-acpi_status
-acpi_tb_verify_rsdp (
-	ACPI_PHYSICAL_ADDRESS   RSDP_physical_address);
-
-acpi_status
-acpi_tb_get_table_facs (
-	acpi_table_header       *buffer_ptr,
-	acpi_table_desc         *table_info);
-
-ACPI_PHYSICAL_ADDRESS
-acpi_tb_get_rsdt_address (
-	void);
-
-acpi_status
-acpi_tb_validate_rsdt (
-	acpi_table_header       *table_ptr);
-
-acpi_status
-acpi_tb_get_table_pointer (
-	ACPI_PHYSICAL_ADDRESS   physical_address,
-	u32                     flags,
-	u32                     *size,
-	acpi_table_header       **table_ptr);
-
-/*
- * tbgetall - Get all firmware ACPI tables
- */
-
-acpi_status
-acpi_tb_get_all_tables (
-	u32                     number_of_tables,
-	acpi_table_header       *buffer_ptr);
-
-
-/*
- * tbinstall - Table installation
- */
-
-acpi_status
-acpi_tb_install_table (
-	acpi_table_header       *table_ptr,
-	acpi_table_desc         *table_info);
-
-acpi_status
-acpi_tb_recognize_table (
-	acpi_table_header       *table_ptr,
-	acpi_table_desc         *table_info);
-
-acpi_status
-acpi_tb_init_table_descriptor (
-	acpi_table_type         table_type,
-	acpi_table_desc         *table_info);
-
-
-/*
- * tbremove - Table removal and deletion
- */
-
-void
-acpi_tb_delete_acpi_tables (
-	void);
-
-void
-acpi_tb_delete_acpi_table (
-	acpi_table_type         type);
-
-void
-acpi_tb_delete_single_table (
-	acpi_table_desc         *table_desc);
-
-acpi_table_desc *
-acpi_tb_uninstall_table (
-	acpi_table_desc         *table_desc);
-
-void
-acpi_tb_free_acpi_tables_of_type (
-	acpi_table_desc         *table_info);
-
-
-/*
- * tbrsd - RSDP, RSDT utilities
- */
-
-acpi_status
-acpi_tb_get_table_rsdt (
-	u32                     *number_of_tables);
-
-u8 *
-acpi_tb_scan_memory_for_rsdp (
-	u8                      *start_address,
-	u32                     length);
-
-acpi_status
-acpi_tb_find_rsdp (
-	acpi_table_desc         *table_info,
-	u32                     flags);
-
-
-/*
- * tbutils - common table utilities
- */
-
-acpi_status
-acpi_tb_map_acpi_table (
-	ACPI_PHYSICAL_ADDRESS   physical_address,
-	u32                     *size,
-	acpi_table_header       **logical_address);
-
-acpi_status
-acpi_tb_verify_table_checksum (
-	acpi_table_header       *table_header);
-
-u8
-acpi_tb_checksum (
-	void                    *buffer,
-	u32                     length);
-
-acpi_status
-acpi_tb_validate_table_header (
-	acpi_table_header       *table_header);
-
-
-#endif /* __ACTABLES_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/actbl.h linux-2.4.22-pre2/drivers/acpi/include/actbl.h
--- linux-2.4.21/drivers/acpi/include/actbl.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/actbl.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,217 +0,0 @@
-/******************************************************************************
- *
- * Name: actbl.h - Table data structures defined in ACPI specification
- *       $Revision: 46 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACTBL_H__
-#define __ACTBL_H__
-
-
-/*
- *  Values for description table header signatures
- */
-
-#define RSDP_NAME               "RSDP"
-#define RSDP_SIG                "RSD PTR "  /* RSDT Pointer signature */
-#define APIC_SIG                "APIC"      /* Multiple APIC Description Table */
-#define DSDT_SIG                "DSDT"      /* Differentiated System Description Table */
-#define FADT_SIG                "FACP"      /* Fixed ACPI Description Table */
-#define FACS_SIG                "FACS"      /* Firmware ACPI Control Structure */
-#define PSDT_SIG                "PSDT"      /* Persistent System Description Table */
-#define RSDT_SIG                "RSDT"      /* Root System Description Table */
-#define XSDT_SIG                "XSDT"      /* Extended  System Description Table */
-#define SSDT_SIG                "SSDT"      /* Secondary System Description Table */
-#define SBST_SIG                "SBST"      /* Smart Battery Specification Table */
-#define SPIC_SIG                "SPIC"      /* iosapic table */
-#define BOOT_SIG                "BOOT"      /* Boot table */
-
-
-#define GL_OWNED                0x02        /* Ownership of global lock is bit 1 */
-
-/* values of Mapic.Model */
-
-#define DUAL_PIC                0
-#define MULTIPLE_APIC           1
-
-/* values of Type in APIC_HEADER */
-
-#define APIC_PROC               0
-#define APIC_IO                 1
-
-
-/*
- * Common table types.  The base code can remain
- * constant if the underlying tables are changed
- */
-#define RSDT_DESCRIPTOR         RSDT_DESCRIPTOR_REV2
-#define xsdt_descriptor         XSDT_DESCRIPTOR_REV2
-#define FACS_DESCRIPTOR         facs_descriptor_rev2
-#define FADT_DESCRIPTOR         fadt_descriptor_rev2
-
-
-#pragma pack(1)
-
-/*
- * Architecture-independent tables
- * The architecture dependent tables are in separate files
- */
-
-typedef struct  /* Root System Descriptor Pointer */
-{
-	NATIVE_CHAR             signature [8];          /* contains "RSD PTR " */
-	u8                      checksum;               /* to make sum of struct == 0 */
-	NATIVE_CHAR             oem_id [6];             /* OEM identification */
-	u8                      revision;               /* Must be 0 for 1.0, 2 for 2.0 */
-	u32                     rsdt_physical_address;  /* 32-bit physical address of RSDT */
-	u32                     length;                 /* XSDT Length in bytes including hdr */
-	u64                     xsdt_physical_address;  /* 64-bit physical address of XSDT */
-	u8                      extended_checksum;      /* Checksum of entire table */
-	NATIVE_CHAR             reserved [3];           /* reserved field must be 0 */
-
-} RSDP_DESCRIPTOR;
-
-
-typedef struct  /* ACPI common table header */
-{
-	NATIVE_CHAR             signature [4];          /* identifies type of table */
-	u32                     length;                 /* length of table, in bytes,
-			  * including header */
-	u8                      revision;               /* specification minor version # */
-	u8                      checksum;               /* to make sum of entire table == 0 */
-	NATIVE_CHAR             oem_id [6];             /* OEM identification */
-	NATIVE_CHAR             oem_table_id [8];       /* OEM table identification */
-	u32                     oem_revision;           /* OEM revision number */
-	NATIVE_CHAR             asl_compiler_id [4];    /* ASL compiler vendor ID */
-	u32                     asl_compiler_revision;  /* ASL compiler revision number */
-
-} acpi_table_header;
-
-
-typedef struct  /* Common FACS for internal use */
-{
-	u32                     *global_lock;
-	u64                     *firmware_waking_vector;
-	u8                      vector_width;
-
-} acpi_common_facs;
-
-
-typedef struct  /* APIC Table */
-{
-	acpi_table_header       header;                 /* table header */
-	u32                     local_apic_address;     /* Physical address for accessing local APICs */
-	u32                     PCATcompat      : 1;    /* a one indicates system also has dual 8259s */
-	u32                     reserved1       : 31;
-
-} APIC_TABLE;
-
-
-typedef struct  /* APIC Header */
-{
-	u8                      type;                   /* APIC type.  Either APIC_PROC or APIC_IO */
-	u8                      length;                 /* Length of APIC structure */
-
-} APIC_HEADER;
-
-
-typedef struct  /* Processor APIC */
-{
-	APIC_HEADER             header;
-	u8                      processor_apic_id;      /* ACPI processor id */
-	u8                      local_apic_id;          /* processor's local APIC id */
-	u32                     processor_enabled: 1;   /* Processor is usable if set */
-	u32                     reserved1       : 31;
-
-} PROCESSOR_APIC;
-
-
-typedef struct  /* IO APIC */
-{
-	APIC_HEADER             header;
-	u8                      io_apic_id;             /* I/O APIC ID */
-	u8                      reserved;               /* reserved - must be zero */
-	u32                     io_apic_address;        /* APIC's physical address */
-	u32                     vector;                 /* interrupt vector index where INTI
-			  * lines start */
-} IO_APIC;
-
-
-/*
-**  IA64 TODO:  Add SAPIC Tables
-*/
-
-/*
-**  IA64 TODO:  Modify Smart Battery Description to comply with ACPI IA64
-**              extensions.
-*/
-typedef struct  /* Smart Battery Description Table */
-{
-	acpi_table_header       header;
-	u32                     warning_level;
-	u32                     low_level;
-	u32                     critical_level;
-
-} SMART_BATTERY_DESCRIPTION_TABLE;
-
-
-#pragma pack()
-
-
-/*
- * ACPI Table information.  We save the table address, length,
- * and type of memory allocation (mapped or allocated) for each
- * table for 1) when we exit, and 2) if a new table is installed
- */
-
-#define ACPI_MEM_NOT_ALLOCATED  0
-#define ACPI_MEM_ALLOCATED      1
-#define ACPI_MEM_MAPPED         2
-
-/* Definitions for the Flags bitfield member of ACPI_TABLE_SUPPORT */
-
-#define ACPI_TABLE_SINGLE       0
-#define ACPI_TABLE_MULTIPLE     1
-
-
-/* Data about each known table type */
-
-typedef struct _acpi_table_support
-{
-	NATIVE_CHAR             *name;
-	NATIVE_CHAR             *signature;
-	u8                      sig_length;
-	u8                      flags;
-	u16                     status;
-	void                    **global_ptr;
-
-} ACPI_TABLE_SUPPORT;
-
-/*
- * Get the architecture-specific tables
- */
-
-#include "actbl1.h"   /* Acpi 1.0 table defintions */
-#include "actbl71.h"  /* Acpi 0.71 IA-64 Extension table defintions */
-#include "actbl2.h"   /* Acpi 2.0 table definitions */
-
-#endif /* __ACTBL_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/actbl1.h linux-2.4.22-pre2/drivers/acpi/include/actbl1.h
--- linux-2.4.21/drivers/acpi/include/actbl1.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/actbl1.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,123 +0,0 @@
-/******************************************************************************
- *
- * Name: actbl1.h - ACPI 1.0 tables
- *       $Revision: 17 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACTBL1_H__
-#define __ACTBL1_H__
-
-#pragma pack(1)
-
-/*************************************/
-/* ACPI Specification Rev 1.0 for    */
-/* the Root System Description Table */
-/*************************************/
-typedef struct
-{
-	acpi_table_header       header;                 /* Table header */
-	u32                     table_offset_entry [1]; /* Array of pointers to other */
-			 /* ACPI tables */
-} RSDT_DESCRIPTOR_REV1;
-
-
-/***************************************/
-/* ACPI Specification Rev 1.0 for      */
-/* the Firmware ACPI Control Structure */
-/***************************************/
-typedef struct
-{
-	NATIVE_CHAR             signature[4];           /* signature "FACS" */
-	u32                     length;                 /* length of structure, in bytes */
-	u32                     hardware_signature;     /* hardware configuration signature */
-	u32                     firmware_waking_vector; /* ACPI OS waking vector */
-	u32                     global_lock;            /* Global Lock */
-	u32                     S4bios_f        : 1;    /* Indicates if S4BIOS support is present */
-	u32                     reserved1       : 31;   /* must be 0 */
-	u8                      resverved3 [40];        /* reserved - must be zero */
-
-} facs_descriptor_rev1;
-
-
-/************************************/
-/* ACPI Specification Rev 1.0 for   */
-/* the Fixed ACPI Description Table */
-/************************************/
-typedef struct
-{
-	acpi_table_header       header;                 /* table header */
-	u32                     firmware_ctrl;          /* Physical address of FACS */
-	u32                     dsdt;                   /* Physical address of DSDT */
-	u8                      model;                  /* System Interrupt Model */
-	u8                      reserved1;              /* reserved */
-	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                      reserved2;              /* reserved - must be zero */
-	u32                     pm1a_evt_blk;           /* Port address of Power Mgt 1a Acpi_event Reg Blk */
-	u32                     pm1b_evt_blk;           /* Port address of Power Mgt 1b Acpi_event Reg Blk */
-	u32                     pm1a_cnt_blk;           /* Port address of Power Mgt 1a Control Reg Blk */
-	u32                     pm1b_cnt_blk;           /* Port address of Power Mgt 1b Control Reg Blk */
-	u32                     pm2_cnt_blk;            /* Port address of Power Mgt 2 Control Reg Blk */
-	u32                     pm_tmr_blk;             /* Port address of Power Mgt Timer Ctrl Reg Blk */
-	u32                     gpe0blk;                /* Port addr of General Purpose Acpi_event 0 Reg Blk */
-	u32                     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                      gpe0blk_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                      reserved3;              /* reserved */
-	u16                     plvl2_lat;              /* worst case HW latency to enter/exit C2 state */
-	u16                     plvl3_lat;              /* worst case HW latency to enter/exit C3 state */
-	u16                     flush_size;             /* Size of area read to flush caches */
-	u16                     flush_stride;           /* Stride used in flushing caches */
-	u8                      duty_offset;            /* bit location of duty cycle field in p_cnt reg */
-	u8                      duty_width;             /* bit width of duty cycle field in p_cnt reg */
-	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 */
-	u8                      reserved4;              /* reserved */
-	u8                      reserved4a;             /* reserved */
-	u8                      reserved4b;             /* reserved */
-	u32                     wb_invd         : 1;    /* wbinvd instruction works properly */
-	u32                     wb_invd_flush   : 1;    /* wbinvd flushes but does not invalidate */
-	u32                     proc_c1         : 1;    /* all processors support C1 state */
-	u32                     plvl2_up        : 1;    /* C2 state works on MP system */
-	u32                     pwr_button      : 1;    /* Power button is handled as a generic feature */
-	u32                     sleep_button    : 1;    /* Sleep button is handled as a generic feature, or not present */
-	u32                     fixed_rTC       : 1;    /* RTC wakeup stat not in fixed register space */
-	u32                     rtcs4           : 1;    /* RTC wakeup stat not possible from S4 */
-	u32                     tmr_val_ext     : 1;    /* tmr_val is 32 bits */
-	u32                     reserved5       : 23;   /* reserved - must be zero */
-
-}  fadt_descriptor_rev1;
-
-#pragma pack()
-
-#endif /* __ACTBL1_H__ */
-
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/actbl2.h linux-2.4.22-pre2/drivers/acpi/include/actbl2.h
--- linux-2.4.21/drivers/acpi/include/actbl2.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/actbl2.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,186 +0,0 @@
-/******************************************************************************
- *
- * Name: actbl2.h - ACPI Specification Revision 2.0 Tables
- *       $Revision: 24 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACTBL2_H__
-#define __ACTBL2_H__
-
-/*
- * Prefered Power Management Profiles
- */
-#define PM_UNSPECIFIED                  0
-#define PM_DESKTOP                      1
-#define PM_MOBILE                       2
-#define PM_WORKSTATION                  3
-#define PM_ENTERPRISE_SERVER            4
-#define PM_SOHO_SERVER                  5
-#define PM_APPLIANCE_PC                 6
-
-/*
- * ACPI Boot Arch Flags
- */
-#define BAF_LEGACY_DEVICES              0x0001
-#define BAF_8042_KEYBOARD_CONTROLLER    0x0002
-
-#define FADT2_REVISION_ID               3
-
-
-#pragma pack(1)
-
-/*
- * ACPI Specification Rev 2.0 for the Root System Description Table
- */
-typedef struct
-{
-	acpi_table_header       header;                 /* Table header */
-	u32                     table_offset_entry [1]; /* Array of pointers to  */
-			 /* other tables' headers */
-} RSDT_DESCRIPTOR_REV2;
-
-
-/*
- * ACPI Specification Rev 2.0 for the Extended System Description Table (XSDT)
- */
-typedef struct
-{
-	acpi_table_header       header;                 /* Table header */
-	u64                     table_offset_entry [1]; /* Array of pointers to  */
-			 /* other tables' headers */
-} XSDT_DESCRIPTOR_REV2;
-
-
-/*
- * ACPI Specification Rev 2.0 for the Firmware ACPI Control Structure
- */
-typedef struct
-{
-	NATIVE_CHAR             signature[4];           /* signature "FACS" */
-	u32                     length;                 /* length of structure, in bytes */
-	u32                     hardware_signature;     /* hardware configuration signature */
-	u32                     firmware_waking_vector; /* 32bit physical address of the Firmware Waking Vector. */
-	u32                     global_lock;            /* Global Lock used to synchronize access to shared hardware resources */
-	u32                     S4bios_f        : 1;    /* Indicates if S4BIOS support is present */
-	u32                     reserved1       : 31;   /* must be 0 */
-	u64                     Xfirmware_waking_vector; /* 64bit physical address of the Firmware Waking Vector. */
-	u8                      version;                /* Version of this table */
-	u8                      reserved3 [31];         /* reserved - must be zero */
-
-} facs_descriptor_rev2;
-
-
-/*
- * ACPI Specification Rev 2.0 for the Generic Address Structure (GAS)
- */
-typedef struct
-{
-	u8                      address_space_id;       /* Address space where struct or register exists. */
-	u8                      register_bit_width;     /* Size in bits of given register */
-	u8                      register_bit_offset;    /* Bit offset within the register */
-	u8                      reserved;               /* Must be 0 */
-	u64                     address;                /* 64-bit address of struct or register */
-
-} acpi_generic_address;
-
-
-/*
- * ACPI Specification Rev 2.0 for the Fixed ACPI Description Table
- */
-typedef struct
-{
-	acpi_table_header       header;             /* 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_gpe0blk;         /* 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                      gpe0blk_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*/
-	u8                      reserved2;          /* reserved */
-	u32                     wb_invd     : 1;    /* wbinvd instruction works properly */
-	u32                     wb_invd_flush : 1;  /* wbinvd flushes but does not invalidate */
-	u32                     proc_c1     : 1;    /* all processors support C1 state */
-	u32                     plvl2_up    : 1;    /* C2 state works on MP system */
-	u32                     pwr_button  : 1;    /* Power button is handled as a generic feature */
-	u32                     sleep_button : 1;   /* Sleep button is handled as a generic feature, or not present */
-	u32                     fixed_rTC   : 1;    /* RTC wakeup stat not in fixed register space */
-	u32                     rtcs4       : 1;    /* RTC wakeup stat not possible from S4 */
-	u32                     tmr_val_ext : 1;    /* tmr_val is 32 bits */
-	u32                     dock_cap    : 1;    /* Supports Docking */
-	u32                     reset_reg_sup : 1;  /* Indicates system supports system reset via the FADT RESET_REG*/
-	u32                     sealed_case : 1;    /* Indicates system has no internal expansion capabilities and case is sealed. */
-	u32                     headless    : 1;    /* Indicates system does not have local video capabilities or local input devices.*/
-	u32                     cpu_sw_sleep : 1;   /* Indicates to OSPM that a processor native instruction */
-			   /* must be executed after writing the SLP_TYPx register. */
-	u32                     reserved6   : 18;   /* reserved - must be zero */
-
-	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 */
-	u64                     Xfirmware_ctrl;     /* 64-bit physical address of FACS */
-	u64                     Xdsdt;              /* 64-bit physical address of DSDT */
-	acpi_generic_address    Xpm1a_evt_blk;      /* Extended Power Mgt 1a Acpi_event Reg Blk address */
-	acpi_generic_address    Xpm1b_evt_blk;      /* Extended Power Mgt 1b Acpi_event Reg Blk address */
-	acpi_generic_address    Xpm1a_cnt_blk;      /* Extended Power Mgt 1a Control Reg Blk address */
-	acpi_generic_address    Xpm1b_cnt_blk;      /* Extended Power Mgt 1b Control Reg Blk address */
-	acpi_generic_address    Xpm2_cnt_blk;       /* Extended Power Mgt 2 Control Reg Blk address */
-	acpi_generic_address    Xpm_tmr_blk;        /* Extended Power Mgt Timer Ctrl Reg Blk address */
-	acpi_generic_address    Xgpe0blk;           /* Extended General Purpose Acpi_event 0 Reg Blk address */
-	acpi_generic_address    Xgpe1_blk;          /* Extended General Purpose Acpi_event 1 Reg Blk address */
-
-}  fadt_descriptor_rev2;
-
-
-#pragma pack()
-
-#endif /* __ACTBL2_H__ */
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/actbl71.h linux-2.4.22-pre2/drivers/acpi/include/actbl71.h
--- linux-2.4.21/drivers/acpi/include/actbl71.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/actbl71.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,147 +0,0 @@
-/******************************************************************************
- *
- * Name: actbl71.h - IA-64 Extensions to the ACPI Spec Rev. 0.71
- *                   This file includes tables specific to this
- *                   specification revision.
- *       $Revision: 11 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACTBL71_H__
-#define __ACTBL71_H__
-
-
-/* 0.71 FADT Address_space data item bitmasks defines */
-/* If the associated bit is zero then it is in memory space else in io space */
-
-#define SMI_CMD_ADDRESS_SPACE       0x01
-#define PM1_BLK_ADDRESS_SPACE       0x02
-#define PM2_CNT_BLK_ADDRESS_SPACE   0x04
-#define PM_TMR_BLK_ADDRESS_SPACE    0x08
-#define GPE0_BLK_ADDRESS_SPACE      0x10
-#define GPE1_BLK_ADDRESS_SPACE      0x20
-
-/* Only for clarity in declarations */
-
-typedef u64                 IO_ADDRESS;
-
-
-#pragma pack(1)
-typedef struct  /* Root System Descriptor Pointer */
-{
-	NATIVE_CHAR             signature [8];          /* contains "RSD PTR " */
-	u8                      checksum;               /* to make sum of struct == 0 */
-	NATIVE_CHAR             oem_id [6];             /* OEM identification */
-	u8                      reserved;               /* Must be 0 for 1.0, 2 for 2.0 */
-	u64                     rsdt_physical_address;  /* 64-bit physical address of RSDT */
-} RSDP_DESCRIPTOR_REV071;
-
-
-/*****************************************/
-/* IA64 Extensions to ACPI Spec Rev 0.71 */
-/* for the Root System Description Table */
-/*****************************************/
-typedef struct
-{
-	acpi_table_header   header;                 /* Table header */
-	u32                 reserved_pad;           /* IA64 alignment, must be 0 */
-	u64                 table_offset_entry [1]; /* Array of pointers to other */
-			   /* tables' headers */
-} RSDT_DESCRIPTOR_REV071;
-
-
-/*******************************************/
-/* IA64 Extensions to ACPI Spec Rev 0.71   */
-/* for the Firmware ACPI Control Structure */
-/*******************************************/
-typedef struct
-{
-	NATIVE_CHAR         signature[4];         /* signature "FACS" */
-	u32                 length;               /* length of structure, in bytes */
-	u32                 hardware_signature;   /* hardware configuration signature */
-	u32                 reserved4;            /* must be 0 */
-	u64                 firmware_waking_vector; /* ACPI OS waking vector */
-	u64                 global_lock;          /* Global Lock */
-	u32                 S4bios_f      : 1;    /* Indicates if S4BIOS support is present */
-	u32                 reserved1     : 31;   /* must be 0 */
-	u8                  reserved3 [28];       /* reserved - must be zero */
-
-} facs_descriptor_rev071;
-
-
-/******************************************/
-/* IA64 Extensions to ACPI Spec Rev 0.71  */
-/* for the Fixed ACPI Description Table   */
-/******************************************/
-typedef struct
-{
-	acpi_table_header   header;             /* table header */
-	u32                 reserved_pad;       /* IA64 alignment, must be 0 */
-	u64                 firmware_ctrl;      /* 64-bit Physical address of FACS */
-	u64                 dsdt;               /* 64-bit Physical address of DSDT */
-	u8                  model;              /* System Interrupt Model */
-	u8                  address_space;      /* Address Space Bitmask */
-	u16                 sci_int;            /* System vector of SCI interrupt */
-	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                  reserved2;          /* reserved - must be zero */
-	u64                 smi_cmd;            /* Port address of SMI command port */
-	u64                 pm1a_evt_blk;       /* Port address of Power Mgt 1a Acpi_event Reg Blk */
-	u64                 pm1b_evt_blk;       /* Port address of Power Mgt 1b Acpi_event Reg Blk */
-	u64                 pm1a_cnt_blk;       /* Port address of Power Mgt 1a Control Reg Blk */
-	u64                 pm1b_cnt_blk;       /* Port address of Power Mgt 1b Control Reg Blk */
-	u64                 pm2_cnt_blk;        /* Port address of Power Mgt 2 Control Reg Blk */
-	u64                 pm_tmr_blk;         /* Port address of Power Mgt Timer Ctrl Reg Blk */
-	u64                 gpe0blk;            /* Port addr of General Purpose Acpi_event 0 Reg Blk */
-	u64                 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                  gpe0blk_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                  reserved3;          /* reserved */
-	u16                 plvl2_lat;          /* worst case HW latency to enter/exit C2 state */
-	u16                 plvl3_lat;          /* worst case HW latency to enter/exit C3 state */
-	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 */
-	u8                  reserved4;          /* reserved */
-	u32                 flush_cash  : 1;    /* PAL_FLUSH_CACHE is correctly supported */
-	u32                 reserved5   : 1;    /* reserved - must be zero */
-	u32                 proc_c1     : 1;    /* all processors support C1 state */
-	u32                 plvl2_up    : 1;    /* C2 state works on MP system */
-	u32                 pwr_button  : 1;    /* Power button is handled as a generic feature */
-	u32                 sleep_button : 1;   /* Sleep button is handled as a generic feature, or not present */
-	u32                 fixed_rTC   : 1;    /* RTC wakeup stat not in fixed register space */
-	u32                 rtcs4       : 1;    /* RTC wakeup stat not possible from S4 */
-	u32                 tmr_val_ext : 1;    /* tmr_val is 32 bits */
-	u32                 dock_cap    : 1;    /* Supports Docking */
-	u32                 reserved6   : 22;    /* reserved - must be zero */
-
-}  fadt_descriptor_rev071;
-
-#pragma pack()
-
-#endif /* __ACTBL71_H__ */
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/actypes.h linux-2.4.22-pre2/drivers/acpi/include/actypes.h
--- linux-2.4.21/drivers/acpi/include/actypes.h	2002-11-28 23:53:12.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/actypes.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,1118 +0,0 @@
-/******************************************************************************
- *
- * Name: actypes.h - Common data types for the entire ACPI subsystem
- *       $Revision: 193 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACTYPES_H__
-#define __ACTYPES_H__
-
-/*! [Begin] no source code translation (keep the typedefs) */
-
-/*
- * Data types - Fixed across all compilation models
- *
- * BOOLEAN      Logical Boolean.
- *              1 byte value containing a 0 for FALSE or a 1 for TRUE.
- *              Other values are undefined.
- *
- * INT8         8-bit  (1 byte) signed value
- * UINT8        8-bit  (1 byte) unsigned value
- * INT16        16-bit (2 byte) signed value
- * UINT16       16-bit (2 byte) unsigned value
- * INT32        32-bit (4 byte) signed value
- * UINT32       32-bit (4 byte) unsigned value
- * INT64        64-bit (8 byte) signed value
- * UINT64       64-bit (8 byte) unsigned value
- * NATIVE_INT   32-bit on IA-32, 64-bit on IA-64 signed value
- * NATIVE_UINT  32-bit on IA-32, 64-bit on IA-64 unsigned value
- * UCHAR        Character. 1 byte unsigned value.
- */
-
-#ifndef BITS_PER_LONG
-#error "define BITS_PER_LONG"
-#endif
-
-#if BITS_PER_LONG == 64
-/*
- * 64-bit type definitions
- */
-typedef unsigned char                   UINT8;
-typedef unsigned char                   BOOLEAN;
-typedef unsigned char                   UCHAR;
-typedef unsigned short                  UINT16;
-typedef int                             INT32;
-typedef unsigned int                    UINT32;
-typedef COMPILER_DEPENDENT_UINT64       UINT64;
-
-typedef UINT64                          NATIVE_UINT;
-typedef long long                          NATIVE_INT;
-
-typedef NATIVE_UINT                     ACPI_TBLPTR;
-typedef UINT64                          ACPI_IO_ADDRESS;
-typedef UINT64                          ACPI_PHYSICAL_ADDRESS;
-
-#define ALIGNED_ADDRESS_BOUNDARY        0x00000008      /* No hardware alignment support in IA64 */
-#define ACPI_USE_NATIVE_DIVIDE                          /* Native 64-bit integer support */
-
-
-#elif BITS_PER_LONG == 16
-/*
- * 16-bit type definitions
- */
-typedef unsigned char                   UINT8;
-typedef unsigned char                   BOOLEAN;
-typedef unsigned char                   UCHAR;
-typedef unsigned int                    UINT16;
-typedef long                            INT32;
-typedef int                             INT16;
-typedef unsigned long                   UINT32;
-
-typedef struct
-{
-	UINT32                                  Lo;
-	UINT32                                  Hi;
-
-} UINT64;
-
-typedef UINT16                          NATIVE_UINT;
-typedef INT16                           NATIVE_INT;
-
-typedef UINT32                          ACPI_TBLPTR;
-typedef UINT32                          ACPI_IO_ADDRESS;
-typedef char                            *ACPI_PHYSICAL_ADDRESS;
-
-#define ALIGNED_ADDRESS_BOUNDARY        0x00000002
-#define _HW_ALIGNMENT_SUPPORT
-#define ACPI_USE_NATIVE_DIVIDE                          /* No 64-bit integers, ok to use native divide */
-
-/*
- * (16-bit only) internal integers must be 32-bits, so
- * 64-bit integers cannot be supported
- */
-#define ACPI_NO_INTEGER64_SUPPORT
-
-
-#elif BITS_PER_LONG == 32
-/*
- * 32-bit type definitions (default)
- */
-typedef unsigned char                   UINT8;
-typedef unsigned char                   BOOLEAN;
-typedef unsigned char                   UCHAR;
-typedef unsigned short                  UINT16;
-typedef int                             INT32;
-typedef unsigned int                    UINT32;
-typedef COMPILER_DEPENDENT_UINT64       UINT64;
-
-typedef UINT32                          NATIVE_UINT;
-typedef INT32                           NATIVE_INT;
-
-typedef NATIVE_UINT                     ACPI_TBLPTR;
-typedef UINT32                          ACPI_IO_ADDRESS;
-typedef UINT64                          ACPI_PHYSICAL_ADDRESS;
-
-#define ALIGNED_ADDRESS_BOUNDARY        0x00000004
-#define _HW_ALIGNMENT_SUPPORT
-
-#else
-#error "unknown BITS_PER_LONG"
-#endif
-
-
-
-/*
- * Miscellaneous common types
- */
-
-typedef UINT32                          UINT32_BIT;
-typedef NATIVE_UINT                     ACPI_PTRDIFF;
-typedef char                            NATIVE_CHAR;
-
-
-/*
- * Data type ranges
- */
-
-#define ACPI_UINT8_MAX                  (UINT8)  0xFF
-#define ACPI_UINT16_MAX                 (UINT16) 0xFFFF
-#define ACPI_UINT32_MAX                 (UINT32) 0xFFFFFFFF
-#define ACPI_UINT64_MAX                 (UINT64) 0xFFFFFFFFFFFFFFFF
-
-
-#ifdef DEFINE_ALTERNATE_TYPES
-/*
- * Types used only in translated source
- */
-typedef INT32                           s32;
-typedef UINT8                           u8;
-typedef UINT16                          u16;
-typedef UINT32                          u32;
-typedef UINT64                          u64;
-#endif
-/*! [End] no source code translation !*/
-
-
-/*
- * Useful defines
- */
-
-#ifdef FALSE
-#undef FALSE
-#endif
-#define FALSE                           (1 == 0)
-
-#ifdef TRUE
-#undef TRUE
-#endif
-#define TRUE                            (1 == 1)
-
-#ifndef NULL
-#define NULL                            (void *) 0
-#endif
-
-
-/*
- * Local datatypes
- */
-
-typedef u32                             acpi_status;    /* All ACPI Exceptions */
-typedef u32                             acpi_name;      /* 4-byte ACPI name */
-typedef char*                           acpi_string;    /* Null terminated ASCII string */
-typedef void*                           acpi_handle;    /* Actually a ptr to an Node */
-
-typedef struct
-{
-	u32                         lo;
-	u32                         hi;
-
-} uint64_struct;
-
-typedef union
-{
-	u64                         full;
-	uint64_struct               part;
-
-} uint64_overlay;
-
-
-/*
- * Acpi integer width. In ACPI version 1, integers are
- * 32 bits.  In ACPI version 2, integers are 64 bits.
- * Note that this pertains to the ACPI integer type only, not
- * other integers used in the implementation of the ACPI CA
- * subsystem.
- */
-#ifdef ACPI_NO_INTEGER64_SUPPORT
-
-/* 32-bit integers only, no 64-bit support */
-
-typedef u32                             acpi_integer;
-#define ACPI_INTEGER_MAX                ACPI_UINT32_MAX
-#define ACPI_INTEGER_BIT_SIZE           32
-#define ACPI_MAX_BCD_VALUE              99999999
-#define ACPI_MAX_BCD_DIGITS             8
-#define ACPI_MAX_DECIMAL_DIGITS         10
-
-#define ACPI_USE_NATIVE_DIVIDE          /* Use compiler native 32-bit divide */
-
-
-#else
-
-/* 64-bit integers */
-
-typedef u64                             acpi_integer;
-#define ACPI_INTEGER_MAX                ACPI_UINT64_MAX
-#define ACPI_INTEGER_BIT_SIZE           64
-#define ACPI_MAX_BCD_VALUE              9999999999999999
-#define ACPI_MAX_BCD_DIGITS             16
-#define ACPI_MAX_DECIMAL_DIGITS         19
-
-#ifdef _IA64
-#define ACPI_USE_NATIVE_DIVIDE          /* Use compiler native 64-bit divide */
-#endif
-#endif
-
-
-/*
- * Constants with special meanings
- */
-
-#define ACPI_ROOT_OBJECT                (acpi_handle)(-1)
-
-
-/*
- * Initialization sequence
- */
-#define ACPI_FULL_INITIALIZATION        0x00
-#define ACPI_NO_ADDRESS_SPACE_INIT      0x01
-#define ACPI_NO_HARDWARE_INIT           0x02
-#define ACPI_NO_EVENT_INIT              0x04
-#define ACPI_NO_ACPI_ENABLE             0x08
-#define ACPI_NO_DEVICE_INIT             0x10
-#define ACPI_NO_OBJECT_INIT             0x20
-
-/*
- * Initialization state
- */
-#define ACPI_INITIALIZED_OK             0x01
-
-/*
- * Power state values
- */
-
-#define ACPI_STATE_UNKNOWN              (u8) 0xFF
-
-#define ACPI_STATE_S0                   (u8) 0
-#define ACPI_STATE_S1                   (u8) 1
-#define ACPI_STATE_S2                   (u8) 2
-#define ACPI_STATE_S3                   (u8) 3
-#define ACPI_STATE_S4                   (u8) 4
-#define ACPI_STATE_S5                   (u8) 5
-#define ACPI_S_STATES_MAX               ACPI_STATE_S5
-#define ACPI_S_STATE_COUNT              6
-
-#define ACPI_STATE_D0                   (u8) 0
-#define ACPI_STATE_D1                   (u8) 1
-#define ACPI_STATE_D2                   (u8) 2
-#define ACPI_STATE_D3                   (u8) 3
-#define ACPI_D_STATES_MAX               ACPI_STATE_D3
-#define ACPI_D_STATE_COUNT              4
-
-/*
- * Standard notify values
- */
-#define ACPI_NOTIFY_BUS_CHECK           (u8) 0
-#define ACPI_NOTIFY_DEVICE_CHECK        (u8) 1
-#define ACPI_NOTIFY_DEVICE_WAKE         (u8) 2
-#define ACPI_NOTIFY_EJECT_REQUEST       (u8) 3
-#define ACPI_NOTIFY_DEVICE_CHECK_LIGHT  (u8) 4
-#define ACPI_NOTIFY_FREQUENCY_MISMATCH  (u8) 5
-#define ACPI_NOTIFY_BUS_MODE_MISMATCH   (u8) 6
-#define ACPI_NOTIFY_POWER_FAULT         (u8) 7
-
-
-/*
- *  Table types.  These values are passed to the table related APIs
- */
-
-typedef u32                             acpi_table_type;
-
-#define ACPI_TABLE_RSDP                 (acpi_table_type) 0
-#define ACPI_TABLE_DSDT                 (acpi_table_type) 1
-#define ACPI_TABLE_FADT                 (acpi_table_type) 2
-#define ACPI_TABLE_FACS                 (acpi_table_type) 3
-#define ACPI_TABLE_PSDT                 (acpi_table_type) 4
-#define ACPI_TABLE_SSDT                 (acpi_table_type) 5
-#define ACPI_TABLE_XSDT                 (acpi_table_type) 6
-#define ACPI_TABLE_MAX                  6
-#define NUM_ACPI_TABLES                 (ACPI_TABLE_MAX+1)
-
-
-/*
- * Types associated with names.  The first group of
- * values correspond to the definition of the ACPI
- * Object_type operator (See the ACPI Spec). Therefore,
- * only add to the first group if the spec changes!
- *
- * Types must be kept in sync with the Acpi_ns_properties
- * and Acpi_ns_type_names arrays
- */
-
-typedef u32                             acpi_object_type;
-typedef u8                              acpi_object_type8;
-
-
-#define ACPI_TYPE_ANY                   0  /* 0x00  */
-#define ACPI_TYPE_INTEGER               1  /* 0x01  Byte/Word/Dword/Zero/One/Ones */
-#define ACPI_TYPE_STRING                2  /* 0x02  */
-#define ACPI_TYPE_BUFFER                3  /* 0x03  */
-#define ACPI_TYPE_PACKAGE               4  /* 0x04  Byte_const, multiple Data_term/Constant/Super_name */
-#define ACPI_TYPE_FIELD_UNIT            5  /* 0x05  */
-#define ACPI_TYPE_DEVICE                6  /* 0x06  Name, multiple Node */
-#define ACPI_TYPE_EVENT                 7  /* 0x07  */
-#define ACPI_TYPE_METHOD                8  /* 0x08  Name, Byte_const, multiple Code */
-#define ACPI_TYPE_MUTEX                 9  /* 0x09  */
-#define ACPI_TYPE_REGION                10 /* 0x0A  */
-#define ACPI_TYPE_POWER                 11 /* 0x0B  Name,Byte_const,Word_const,multi Node */
-#define ACPI_TYPE_PROCESSOR             12 /* 0x0C  Name,Byte_const,DWord_const,Byte_const,multi Nm_o */
-#define ACPI_TYPE_THERMAL               13 /* 0x0D  Name, multiple Node */
-#define ACPI_TYPE_BUFFER_FIELD          14 /* 0x0E  */
-#define ACPI_TYPE_DDB_HANDLE            15 /* 0x0F  */
-#define ACPI_TYPE_DEBUG_OBJECT          16 /* 0x10  */
-
-#define ACPI_TYPE_MAX                   16
-
-/*
- * This section contains object types that do not relate to the ACPI Object_type operator.
- * They are used for various internal purposes only.  If new predefined ACPI_TYPEs are
- * added (via the ACPI specification), these internal types must move upwards.
- * Also, values exceeding the largest official ACPI Object_type must not overlap with
- * defined AML opcodes.
- */
-#define INTERNAL_TYPE_BEGIN             17
-
-#define INTERNAL_TYPE_REGION_FIELD      17 /* 0x11  */
-#define INTERNAL_TYPE_BANK_FIELD        18 /* 0x12  */
-#define INTERNAL_TYPE_INDEX_FIELD       19 /* 0x13  */
-#define INTERNAL_TYPE_REFERENCE         20 /* 0x14  Arg#, Local#, Name, Debug; used only in descriptors */
-#define INTERNAL_TYPE_ALIAS             21 /* 0x15  */
-#define INTERNAL_TYPE_NOTIFY            22 /* 0x16  */
-#define INTERNAL_TYPE_ADDRESS_HANDLER   23 /* 0x17  */
-#define INTERNAL_TYPE_RESOURCE          24 /* 0x18  */
-#define INTERNAL_TYPE_RESOURCE_FIELD    25 /* 0x19  */
-
-
-#define INTERNAL_TYPE_NODE_MAX          25
-
-/* These are pseudo-types because there are never any namespace nodes with these types */
-
-#define INTERNAL_TYPE_FIELD_DEFN        26 /* 0x1A  Name, Byte_const, multiple Field_element */
-#define INTERNAL_TYPE_BANK_FIELD_DEFN   27 /* 0x1B  2 Name,DWord_const,Byte_const,multi Field_element */
-#define INTERNAL_TYPE_INDEX_FIELD_DEFN  28 /* 0x1C  2 Name, Byte_const, multiple Field_element */
-#define INTERNAL_TYPE_IF                29 /* 0x1D  */
-#define INTERNAL_TYPE_ELSE              30 /* 0x1E  */
-#define INTERNAL_TYPE_WHILE             31 /* 0x1F  */
-#define INTERNAL_TYPE_SCOPE             32 /* 0x20  Name, multiple Node */
-#define INTERNAL_TYPE_DEF_ANY           33 /* 0x21  type is Any, suppress search of enclosing scopes */
-#define INTERNAL_TYPE_EXTRA             34 /* 0x22  */
-
-#define INTERNAL_TYPE_MAX               34
-
-#define INTERNAL_TYPE_INVALID           35
-#define ACPI_TYPE_NOT_FOUND             0xFF
-
-
-/*
- * Bitmapped ACPI types
- * Used internally only
- */
-#define ACPI_BTYPE_ANY                  0x00000000
-#define ACPI_BTYPE_INTEGER              0x00000001
-#define ACPI_BTYPE_STRING               0x00000002
-#define ACPI_BTYPE_BUFFER               0x00000004
-#define ACPI_BTYPE_PACKAGE              0x00000008
-#define ACPI_BTYPE_FIELD_UNIT           0x00000010
-#define ACPI_BTYPE_DEVICE               0x00000020
-#define ACPI_BTYPE_EVENT                0x00000040
-#define ACPI_BTYPE_METHOD               0x00000080
-#define ACPI_BTYPE_MUTEX                0x00000100
-#define ACPI_BTYPE_REGION               0x00000200
-#define ACPI_BTYPE_POWER                0x00000400
-#define ACPI_BTYPE_PROCESSOR            0x00000800
-#define ACPI_BTYPE_THERMAL              0x00001000
-#define ACPI_BTYPE_BUFFER_FIELD         0x00002000
-#define ACPI_BTYPE_DDB_HANDLE           0x00004000
-#define ACPI_BTYPE_DEBUG_OBJECT         0x00008000
-#define ACPI_BTYPE_REFERENCE            0x00010000
-#define ACPI_BTYPE_RESOURCE             0x00020000
-
-#define ACPI_BTYPE_COMPUTE_DATA         (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER)
-
-#define ACPI_BTYPE_DATA                 (ACPI_BTYPE_COMPUTE_DATA  | ACPI_BTYPE_PACKAGE)
-#define ACPI_BTYPE_DATA_REFERENCE       (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE)
-#define ACPI_BTYPE_DEVICE_OBJECTS       (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR)
-#define ACPI_BTYPE_OBJECTS_AND_REFS     0x0001FFFF  /* ARG or LOCAL */
-#define ACPI_BTYPE_ALL_OBJECTS          0x0000FFFF
-
-
-/*
- * Acpi_event Types:
- * ------------
- * Fixed & general purpose...
- */
-
-typedef u32                             acpi_event_type;
-
-#define ACPI_EVENT_FIXED                (acpi_event_type) 0
-#define ACPI_EVENT_GPE                  (acpi_event_type) 1
-
-/*
- * Fixed events
- */
-
-#define ACPI_EVENT_PMTIMER              (acpi_event_type) 0
-	/*
-	 * There's no bus master event so index 1 is used for IRQ's that are not
-	 * handled by the SCI handler
-	 */
-#define ACPI_EVENT_NOT_USED             (acpi_event_type) 1
-#define ACPI_EVENT_GLOBAL               (acpi_event_type) 2
-#define ACPI_EVENT_POWER_BUTTON         (acpi_event_type) 3
-#define ACPI_EVENT_SLEEP_BUTTON         (acpi_event_type) 4
-#define ACPI_EVENT_RTC                  (acpi_event_type) 5
-#define ACPI_EVENT_GENERAL              (acpi_event_type) 6
-#define ACPI_EVENT_MAX                  6
-#define ACPI_NUM_FIXED_EVENTS           (acpi_event_type) 7
-
-#define ACPI_GPE_INVALID                0xFF
-#define ACPI_GPE_MAX                    0xFF
-#define ACPI_NUM_GPE                    256
-
-#define ACPI_EVENT_LEVEL_TRIGGERED      (acpi_event_type) 1
-#define ACPI_EVENT_EDGE_TRIGGERED       (acpi_event_type) 2
-
-/*
- * GPEs
- */
-#define ACPI_EVENT_ENABLE               0x1
-#define ACPI_EVENT_WAKE_ENABLE	        0x2
-
-#define ACPI_EVENT_DISABLE              0x1
-#define ACPI_EVENT_WAKE_DISABLE         0x2
-
-
-/*
- * Acpi_event Status:
- * -------------
- * The encoding of acpi_event_status is illustrated below.
- * Note that a set bit (1) indicates the property is TRUE
- * (e.g. if bit 0 is set then the event is enabled).
- * +-------------+-+-+-+
- * |   Bits 31:3 |2|1|0|
- * +-------------+-+-+-+
- *          |     | | |
- *          |     | | +- Enabled?
- *          |     | +--- Enabled for wake?
- *          |     +----- Set?
- *          +----------- <Reserved>
- */
-typedef u32                             acpi_event_status;
-
-#define ACPI_EVENT_FLAG_DISABLED        (acpi_event_status) 0x00
-#define ACPI_EVENT_FLAG_ENABLED         (acpi_event_status) 0x01
-#define ACPI_EVENT_FLAG_WAKE_ENABLED    (acpi_event_status) 0x02
-#define ACPI_EVENT_FLAG_SET             (acpi_event_status) 0x04
-
-
-/* Notify types */
-
-#define ACPI_SYSTEM_NOTIFY              0
-#define ACPI_DEVICE_NOTIFY              1
-#define ACPI_MAX_NOTIFY_HANDLER_TYPE    1
-
-#define MAX_SYS_NOTIFY                  0x7f
-
-
-/* Address Space (Operation Region) Types */
-
-typedef u8                              ACPI_ADR_SPACE_TYPE;
-
-#define ACPI_ADR_SPACE_SYSTEM_MEMORY    (ACPI_ADR_SPACE_TYPE) 0
-#define ACPI_ADR_SPACE_SYSTEM_IO        (ACPI_ADR_SPACE_TYPE) 1
-#define ACPI_ADR_SPACE_PCI_CONFIG       (ACPI_ADR_SPACE_TYPE) 2
-#define ACPI_ADR_SPACE_EC               (ACPI_ADR_SPACE_TYPE) 3
-#define ACPI_ADR_SPACE_SMBUS            (ACPI_ADR_SPACE_TYPE) 4
-#define ACPI_ADR_SPACE_CMOS             (ACPI_ADR_SPACE_TYPE) 5
-#define ACPI_ADR_SPACE_PCI_BAR_TARGET   (ACPI_ADR_SPACE_TYPE) 6
-
-
-/*
- * External ACPI object definition
- */
-
-typedef union acpi_obj
-{
-	acpi_object_type            type;   /* See definition of Acpi_ns_type for values */
-	struct
-	{
-		acpi_object_type            type;
-		acpi_integer                value;      /* The actual number */
-	} integer;
-
-	struct
-	{
-		acpi_object_type            type;
-		u32                         length;     /* # of bytes in string, excluding trailing null */
-		NATIVE_CHAR                 *pointer;   /* points to the string value */
-	} string;
-
-	struct
-	{
-		acpi_object_type            type;
-		u32                         length;     /* # of bytes in buffer */
-		u8                          *pointer;   /* points to the buffer */
-	} buffer;
-
-	struct
-	{
-		acpi_object_type            type;
-		u32                         fill1;
-		acpi_handle                 handle;     /* object reference */
-	} reference;
-
-	struct
-	{
-		acpi_object_type            type;
-		u32                         count;      /* # of elements in package */
-		union acpi_obj              *elements;  /* Pointer to an array of ACPI_OBJECTs */
-	} package;
-
-	struct
-	{
-		acpi_object_type            type;
-		u32                         proc_id;
-		ACPI_IO_ADDRESS             pblk_address;
-		u32                         pblk_length;
-	} processor;
-
-	struct
-	{
-		acpi_object_type            type;
-		u32                         system_level;
-		u32                         resource_order;
-	} power_resource;
-
-} acpi_object, *PACPI_OBJECT;
-
-
-/*
- * List of objects, used as a parameter list for control method evaluation
- */
-
-typedef struct acpi_obj_list
-{
-	u32                         count;
-	acpi_object                 *pointer;
-
-} acpi_object_list, *PACPI_OBJECT_LIST;
-
-
-/*
- * Miscellaneous common Data Structures used by the interfaces
- */
-
-typedef struct
-{
-	u32                         length;         /* Length in bytes of the buffer */
-	void                        *pointer;       /* pointer to buffer */
-
-} acpi_buffer;
-
-
-/*
- * Name_type for Acpi_get_name
- */
-
-#define ACPI_FULL_PATHNAME              0
-#define ACPI_SINGLE_NAME                1
-#define ACPI_NAME_TYPE_MAX              1
-
-
-/*
- * Structure and flags for Acpi_get_system_info
- */
-
-#define SYS_MODE_UNKNOWN                0x0000
-#define SYS_MODE_ACPI                   0x0001
-#define SYS_MODE_LEGACY                 0x0002
-#define SYS_MODES_MASK                  0x0003
-
-
-/*
- * ACPI Table Info.  One per ACPI table _type_
- */
-typedef struct acpi_table_info
-{
-	u32                         count;
-
-} acpi_table_info;
-
-
-/*
- * System info returned by Acpi_get_system_info()
- */
-
-typedef struct _acpi_sys_info
-{
-	u32                         acpi_ca_version;
-	u32                         flags;
-	u32                         timer_resolution;
-	u32                         reserved1;
-	u32                         reserved2;
-	u32                         debug_level;
-	u32                         debug_layer;
-	u32                         num_table_types;
-	acpi_table_info             table_info [NUM_ACPI_TABLES];
-
-} acpi_system_info;
-
-
-/*
- * Various handlers and callback procedures
- */
-
-typedef
-u32 (*acpi_event_handler) (
-	void                        *context);
-
-typedef
-void (*acpi_gpe_handler) (
-	void                        *context);
-
-typedef
-void (*acpi_notify_handler) (
-	acpi_handle                 device,
-	u32                         value,
-	void                        *context);
-
-
-/* Address Spaces (Operation Regions */
-
-#define ACPI_READ_ADR_SPACE     1
-#define ACPI_WRITE_ADR_SPACE    2
-
-typedef
-acpi_status (*acpi_adr_space_handler) (
-	u32                         function,
-	ACPI_PHYSICAL_ADDRESS       address,
-	u32                         bit_width,
-	u32                         *value,
-	void                        *handler_context,
-	void                        *region_context);
-
-#define ACPI_DEFAULT_HANDLER            ((acpi_adr_space_handler) NULL)
-
-
-typedef
-acpi_status (*acpi_adr_space_setup) (
-	acpi_handle                 region_handle,
-	u32                         function,
-	void                        *handler_context,
-	void                        **region_context);
-
-#define ACPI_REGION_ACTIVATE    0
-#define ACPI_REGION_DEACTIVATE  1
-
-typedef
-acpi_status (*acpi_walk_callback) (
-	acpi_handle                 obj_handle,
-	u32                         nesting_level,
-	void                        *context,
-	void                        **return_value);
-
-
-/* Interrupt handler return values */
-
-#define INTERRUPT_NOT_HANDLED           0x00
-#define INTERRUPT_HANDLED               0x01
-
-
-/* Structure and flags for Acpi_get_device_info */
-
-#define ACPI_VALID_HID                  0x1
-#define ACPI_VALID_UID                  0x2
-#define ACPI_VALID_ADR                  0x4
-#define ACPI_VALID_STA                  0x8
-
-
-#define ACPI_COMMON_OBJ_INFO \
-	acpi_object_type            type;           /* ACPI object type */ \
-	acpi_name                   name            /* ACPI object Name */
-
-
-typedef struct
-{
-	ACPI_COMMON_OBJ_INFO;
-} acpi_obj_info_header;
-
-
-typedef struct
-{
-	ACPI_COMMON_OBJ_INFO;
-
-	u32                         valid;              /*  Are the next bits legit? */
-	NATIVE_CHAR                 hardware_id[9];     /*  _HID value if any */
-	NATIVE_CHAR                 unique_id[9];       /*  _UID value if any */
-	acpi_integer                address;            /*  _ADR value if any */
-	u32                         current_status;     /*  _STA value */
-} acpi_device_info;
-
-
-/* Context structs for address space handlers */
-
-typedef struct
-{
-	u16                         segment;
-	u16                         bus;
-	u16                         device;
-	u16                         function;
-} acpi_pci_id;
-
-
-typedef struct
-{
-	ACPI_PHYSICAL_ADDRESS       mapped_physical_address;
-	u8                          *mapped_logical_address;
-	u32                         mapped_length;
-} acpi_mem_space_context;
-
-
-/* Sleep states */
-
-#define ACPI_NUM_SLEEP_STATES           7
-
-
-/*
- * Definitions for Resource Attributes
- */
-
-/*
- *  Memory Attributes
- */
-#define READ_ONLY_MEMORY                (u8) 0x00
-#define READ_WRITE_MEMORY               (u8) 0x01
-
-#define NON_CACHEABLE_MEMORY            (u8) 0x00
-#define CACHABLE_MEMORY                 (u8) 0x01
-#define WRITE_COMBINING_MEMORY          (u8) 0x02
-#define PREFETCHABLE_MEMORY             (u8) 0x03
-
-/*
- *  IO Attributes
- *  The ISA IO ranges are:     n000-n0FFh,  n400-n4_fFh, n800-n8_fFh, n_c00-n_cFFh.
- *  The non-ISA IO ranges are: n100-n3_fFh, n500-n7_fFh, n900-n_bFFh, n_cD0-n_fFFh.
- */
-#define NON_ISA_ONLY_RANGES             (u8) 0x01
-#define ISA_ONLY_RANGES                 (u8) 0x02
-#define ENTIRE_RANGE                    (NON_ISA_ONLY_RANGES | ISA_ONLY_RANGES)
-
-/*
- *  IO Port Descriptor Decode
- */
-#define DECODE_10                       (u8) 0x00    /* 10-bit IO address decode */
-#define DECODE_16                       (u8) 0x01    /* 16-bit IO address decode */
-
-/*
- *  IRQ Attributes
- */
-#define EDGE_SENSITIVE                  (u8) 0x00
-#define LEVEL_SENSITIVE                 (u8) 0x01
-
-#define ACTIVE_HIGH                     (u8) 0x00
-#define ACTIVE_LOW                      (u8) 0x01
-
-#define EXCLUSIVE                       (u8) 0x00
-#define SHARED                          (u8) 0x01
-
-/*
- *  DMA Attributes
- */
-#define COMPATIBILITY                   (u8) 0x00
-#define TYPE_A                          (u8) 0x01
-#define TYPE_B                          (u8) 0x02
-#define TYPE_F                          (u8) 0x03
-
-#define NOT_BUS_MASTER                  (u8) 0x00
-#define BUS_MASTER                      (u8) 0x01
-
-#define TRANSFER_8                      (u8) 0x00
-#define TRANSFER_8_16                   (u8) 0x01
-#define TRANSFER_16                     (u8) 0x02
-
-/*
- * Start Dependent Functions Priority definitions
- */
-#define GOOD_CONFIGURATION              (u8) 0x00
-#define ACCEPTABLE_CONFIGURATION        (u8) 0x01
-#define SUB_OPTIMAL_CONFIGURATION       (u8) 0x02
-
-/*
- *  16, 32 and 64-bit Address Descriptor resource types
- */
-#define MEMORY_RANGE                    (u8) 0x00
-#define IO_RANGE                        (u8) 0x01
-#define BUS_NUMBER_RANGE                (u8) 0x02
-
-#define ADDRESS_NOT_FIXED               (u8) 0x00
-#define ADDRESS_FIXED                   (u8) 0x01
-
-#define POS_DECODE                      (u8) 0x00
-#define SUB_DECODE                      (u8) 0x01
-
-#define PRODUCER                        (u8) 0x00
-#define CONSUMER                        (u8) 0x01
-
-
-/*
- *  Structures used to describe device resources
- */
-typedef struct
-{
-	u32                         edge_level;
-	u32                         active_high_low;
-	u32                         shared_exclusive;
-	u32                         number_of_interrupts;
-	u32                         interrupts[1];
-
-} acpi_resource_irq;
-
-typedef struct
-{
-	u32                         type;
-	u32                         bus_master;
-	u32                         transfer;
-	u32                         number_of_channels;
-	u32                         channels[1];
-
-} acpi_resource_dma;
-
-typedef struct
-{
-	u32                         compatibility_priority;
-	u32                         performance_robustness;
-
-} acpi_resource_start_dpf;
-
-/*
- * END_DEPENDENT_FUNCTIONS_RESOURCE struct is not
- *  needed because it has no fields
- */
-
-typedef struct
-{
-	u32                         io_decode;
-	u32                         min_base_address;
-	u32                         max_base_address;
-	u32                         alignment;
-	u32                         range_length;
-
-} acpi_resource_io;
-
-typedef struct
-{
-	u32                         base_address;
-	u32                         range_length;
-
-} acpi_resource_fixed_io;
-
-typedef struct
-{
-	u32                         length;
-	u8                          reserved[1];
-
-} acpi_resource_vendor;
-
-typedef struct
-{
-	u32                         read_write_attribute;
-	u32                         min_base_address;
-	u32                         max_base_address;
-	u32                         alignment;
-	u32                         range_length;
-
-} acpi_resource_mem24;
-
-typedef struct
-{
-	u32                         read_write_attribute;
-	u32                         min_base_address;
-	u32                         max_base_address;
-	u32                         alignment;
-	u32                         range_length;
-
-} acpi_resource_mem32;
-
-typedef struct
-{
-	u32                         read_write_attribute;
-	u32                         range_base_address;
-	u32                         range_length;
-
-} acpi_resource_fixed_mem32;
-
-typedef struct
-{
-	u16                         cache_attribute;
-	u16                         read_write_attribute;
-
-} acpi_memory_attribute;
-
-typedef struct
-{
-	u16                         range_attribute;
-	u16                         reserved;
-
-} acpi_io_attribute;
-
-typedef struct
-{
-	u16                         reserved1;
-	u16                         reserved2;
-
-} acpi_bus_attribute;
-
-typedef union
-{
-	acpi_memory_attribute       memory;
-	acpi_io_attribute           io;
-	acpi_bus_attribute          bus;
-
-} acpi_resource_attribute;
-
-typedef struct
-{
-	u32                         index;
-	u32                         string_length;
-	NATIVE_CHAR                 *string_ptr;
-
-} acpi_resource_source;
-
-typedef struct
-{
-	u32                         resource_type;
-	u32                         producer_consumer;
-	u32                         decode;
-	u32                         min_address_fixed;
-	u32                         max_address_fixed;
-	acpi_resource_attribute     attribute;
-	u32                         granularity;
-	u32                         min_address_range;
-	u32                         max_address_range;
-	u32                         address_translation_offset;
-	u32                         address_length;
-	acpi_resource_source        resource_source;
-
-} acpi_resource_address16;
-
-typedef struct
-{
-	u32                         resource_type;
-	u32                         producer_consumer;
-	u32                         decode;
-	u32                         min_address_fixed;
-	u32                         max_address_fixed;
-	acpi_resource_attribute     attribute;
-	u32                         granularity;
-	u32                         min_address_range;
-	u32                         max_address_range;
-	u32                         address_translation_offset;
-	u32                         address_length;
-	acpi_resource_source        resource_source;
-
-} acpi_resource_address32;
-
-typedef struct
-{
-	u32                         resource_type;
-	u32                         producer_consumer;
-	u32                         decode;
-	u32                         min_address_fixed;
-	u32                         max_address_fixed;
-	acpi_resource_attribute     attribute;
-	u64                         granularity;
-	u64                         min_address_range;
-	u64                         max_address_range;
-	u64                         address_translation_offset;
-	u64                         address_length;
-	acpi_resource_source        resource_source;
-
-} acpi_resource_address64;
-
-typedef struct
-{
-	u32                         producer_consumer;
-	u32                         edge_level;
-	u32                         active_high_low;
-	u32                         shared_exclusive;
-	u32                         number_of_interrupts;
-	acpi_resource_source        resource_source;
-	u32                         interrupts[1];
-
-} acpi_resource_ext_irq;
-
-
-/* ACPI_RESOURCE_TYPEs */
-
-#define ACPI_RSTYPE_IRQ                 0
-#define ACPI_RSTYPE_DMA                 1
-#define ACPI_RSTYPE_START_DPF           2
-#define ACPI_RSTYPE_END_DPF             3
-#define ACPI_RSTYPE_IO                  4
-#define ACPI_RSTYPE_FIXED_IO            5
-#define ACPI_RSTYPE_VENDOR              6
-#define ACPI_RSTYPE_END_TAG             7
-#define ACPI_RSTYPE_MEM24               8
-#define ACPI_RSTYPE_MEM32               9
-#define ACPI_RSTYPE_FIXED_MEM32         10
-#define ACPI_RSTYPE_ADDRESS16           11
-#define ACPI_RSTYPE_ADDRESS32           12
-#define ACPI_RSTYPE_ADDRESS64           13
-#define ACPI_RSTYPE_EXT_IRQ             14
-
-typedef u32                     acpi_resource_type;
-
-typedef union
-{
-	acpi_resource_irq           irq;
-	acpi_resource_dma           dma;
-	acpi_resource_start_dpf     start_dpf;
-	acpi_resource_io            io;
-	acpi_resource_fixed_io      fixed_io;
-	acpi_resource_vendor        vendor_specific;
-	acpi_resource_mem24         memory24;
-	acpi_resource_mem32         memory32;
-	acpi_resource_fixed_mem32   fixed_memory32;
-	acpi_resource_address16     address16;
-	acpi_resource_address32     address32;
-	acpi_resource_address64     address64;
-	acpi_resource_ext_irq       extended_irq;
-
-} acpi_resource_data;
-
-typedef struct acpi_resource
-{
-	acpi_resource_type          id;
-	u32                         length;
-	acpi_resource_data          data;
-
-} acpi_resource;
-
-#define ACPI_RESOURCE_LENGTH            12
-#define ACPI_RESOURCE_LENGTH_NO_DATA    8       /* Id + Length fields */
-
-#define SIZEOF_RESOURCE(type)   (ACPI_RESOURCE_LENGTH_NO_DATA + sizeof (type))
-
-#define NEXT_RESOURCE(res)      (acpi_resource *)((u8 *) res + res->length)
-
-
-/*
- * END: Definitions for Resource Attributes
- */
-
-
-typedef struct pci_routing_table
-{
-	u32                         length;
-	u32                         pin;
-	acpi_integer                address;        /* here for 64-bit alignment */
-	u32                         source_index;
-	NATIVE_CHAR                 source[4];      /* pad to 64 bits so sizeof() works in all cases */
-
-} pci_routing_table;
-
-
-/*
- * END: Definitions for PCI Routing tables
- */
-
-#endif /* __ACTYPES_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/acutils.h linux-2.4.22-pre2/drivers/acpi/include/acutils.h
--- linux-2.4.21/drivers/acpi/include/acutils.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/acutils.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,662 +0,0 @@
-/******************************************************************************
- *
- * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures
- *       $Revision: 117 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef _ACUTILS_H
-#define _ACUTILS_H
-
-
-typedef
-acpi_status (*ACPI_PKG_CALLBACK) (
-	u8                      object_type,
-	acpi_operand_object     *source_object,
-	acpi_generic_state      *state,
-	void                    *context);
-
-
-acpi_status
-acpi_ut_walk_package_tree (
-	acpi_operand_object     *source_object,
-	void                    *target_object,
-	ACPI_PKG_CALLBACK       walk_callback,
-	void                    *context);
-
-
-typedef struct acpi_pkg_info
-{
-	u8                      *free_space;
-	u32                     length;
-	u32                     object_space;
-	u32                     num_packages;
-} acpi_pkg_info;
-
-#define REF_INCREMENT       (u16) 0
-#define REF_DECREMENT       (u16) 1
-#define REF_FORCE_DELETE    (u16) 2
-
-/* Acpi_ut_dump_buffer */
-
-#define DB_BYTE_DISPLAY     1
-#define DB_WORD_DISPLAY     2
-#define DB_DWORD_DISPLAY    4
-#define DB_QWORD_DISPLAY    8
-
-
-/* Global initialization interfaces */
-
-void
-acpi_ut_init_globals (
-	void);
-
-void
-acpi_ut_terminate (
-	void);
-
-
-/*
- * Ut_init - miscellaneous initialization and shutdown
- */
-
-acpi_status
-acpi_ut_hardware_initialize (
-	void);
-
-acpi_status
-acpi_ut_subsystem_shutdown (
-	void);
-
-acpi_status
-acpi_ut_validate_fadt (
-	void);
-
-/*
- * Ut_global - Global data structures and procedures
- */
-
-#ifdef ACPI_DEBUG
-
-NATIVE_CHAR *
-acpi_ut_get_mutex_name (
-	u32                     mutex_id);
-
-NATIVE_CHAR *
-acpi_ut_get_type_name (
-	u32                     type);
-
-NATIVE_CHAR *
-acpi_ut_get_region_name (
-	u8                      space_id);
-
-#endif
-
-
-u8
-acpi_ut_hex_to_ascii_char (
-	acpi_integer            integer,
-	u32                     position);
-
-u8
-acpi_ut_valid_object_type (
-	u32                     type);
-
-acpi_owner_id
-acpi_ut_allocate_owner_id (
-	u32                     id_type);
-
-
-/*
- * Ut_clib - Local implementations of C library functions
- */
-
-#ifndef ACPI_USE_SYSTEM_CLIBRARY
-
-u32
-acpi_ut_strlen (
-	const NATIVE_CHAR       *string);
-
-NATIVE_CHAR *
-acpi_ut_strcpy (
-	NATIVE_CHAR             *dst_string,
-	const NATIVE_CHAR       *src_string);
-
-NATIVE_CHAR *
-acpi_ut_strncpy (
-	NATIVE_CHAR             *dst_string,
-	const NATIVE_CHAR       *src_string,
-	NATIVE_UINT             count);
-
-u32
-acpi_ut_strncmp (
-	const NATIVE_CHAR       *string1,
-	const NATIVE_CHAR       *string2,
-	NATIVE_UINT             count);
-
-u32
-acpi_ut_strcmp (
-	const NATIVE_CHAR       *string1,
-	const NATIVE_CHAR       *string2);
-
-NATIVE_CHAR *
-acpi_ut_strcat (
-	NATIVE_CHAR             *dst_string,
-	const NATIVE_CHAR       *src_string);
-
-NATIVE_CHAR *
-acpi_ut_strncat (
-	NATIVE_CHAR             *dst_string,
-	const NATIVE_CHAR       *src_string,
-	NATIVE_UINT             count);
-
-u32
-acpi_ut_strtoul (
-	const NATIVE_CHAR       *string,
-	NATIVE_CHAR             **terminator,
-	u32                     base);
-
-NATIVE_CHAR *
-acpi_ut_strstr (
-	NATIVE_CHAR             *string1,
-	NATIVE_CHAR             *string2);
-
-void *
-acpi_ut_memcpy (
-	void                    *dest,
-	const void              *src,
-	NATIVE_UINT             count);
-
-void *
-acpi_ut_memset (
-	void                    *dest,
-	NATIVE_UINT             value,
-	NATIVE_UINT             count);
-
-u32
-acpi_ut_to_upper (
-	u32                     c);
-
-u32
-acpi_ut_to_lower (
-	u32                     c);
-
-#endif /* ACPI_USE_SYSTEM_CLIBRARY */
-
-/*
- * Ut_copy - Object construction and conversion interfaces
- */
-
-acpi_status
-acpi_ut_build_simple_object(
-	acpi_operand_object     *obj,
-	acpi_object             *user_obj,
-	u8                      *data_space,
-	u32                     *buffer_space_used);
-
-acpi_status
-acpi_ut_build_package_object (
-	acpi_operand_object     *obj,
-	u8                      *buffer,
-	u32                     *space_used);
-
-acpi_status
-acpi_ut_copy_iobject_to_eobject (
-	acpi_operand_object     *obj,
-	acpi_buffer             *ret_buffer);
-
-acpi_status
-acpi_ut_copy_esimple_to_isimple(
-	acpi_object             *user_obj,
-	acpi_operand_object     **return_obj);
-
-acpi_status
-acpi_ut_copy_eobject_to_iobject (
-	acpi_object             *obj,
-	acpi_operand_object     **internal_obj);
-
-acpi_status
-acpi_ut_copy_isimple_to_isimple (
-	acpi_operand_object     *source_obj,
-	acpi_operand_object     *dest_obj);
-
-acpi_status
-acpi_ut_copy_ipackage_to_ipackage (
-	acpi_operand_object     *source_obj,
-	acpi_operand_object     *dest_obj,
-	acpi_walk_state         *walk_state);
-
-
-/*
- * Ut_create - Object creation
- */
-
-acpi_status
-acpi_ut_update_object_reference (
-	acpi_operand_object     *object,
-	u16                     action);
-
-
-/*
- * Ut_debug - Debug interfaces
- */
-
-void
-acpi_ut_init_stack_ptr_trace (
-	void);
-
-void
-acpi_ut_track_stack_ptr (
-	void);
-
-void
-acpi_ut_trace (
-	u32                     line_number,
-	acpi_debug_print_info   *dbg_info);
-
-void
-acpi_ut_trace_ptr (
-	u32                     line_number,
-	acpi_debug_print_info   *dbg_info,
-	void                    *pointer);
-
-void
-acpi_ut_trace_u32 (
-	u32                     line_number,
-	acpi_debug_print_info   *dbg_info,
-	u32                     integer);
-
-void
-acpi_ut_trace_str (
-	u32                     line_number,
-	acpi_debug_print_info   *dbg_info,
-	NATIVE_CHAR             *string);
-
-void
-acpi_ut_exit (
-	u32                     line_number,
-	acpi_debug_print_info   *dbg_info);
-
-void
-acpi_ut_status_exit (
-	u32                     line_number,
-	acpi_debug_print_info   *dbg_info,
-	acpi_status             status);
-
-void
-acpi_ut_value_exit (
-	u32                     line_number,
-	acpi_debug_print_info   *dbg_info,
-	acpi_integer            value);
-
-void
-acpi_ut_ptr_exit (
-	u32                     line_number,
-	acpi_debug_print_info   *dbg_info,
-	u8                      *ptr);
-
-void
-acpi_ut_report_info (
-	NATIVE_CHAR             *module_name,
-	u32                     line_number,
-	u32                     component_id);
-
-void
-acpi_ut_report_error (
-	NATIVE_CHAR             *module_name,
-	u32                     line_number,
-	u32                     component_id);
-
-void
-acpi_ut_report_warning (
-	NATIVE_CHAR             *module_name,
-	u32                     line_number,
-	u32                     component_id);
-
-void
-acpi_ut_dump_buffer (
-	u8                      *buffer,
-	u32                     count,
-	u32                     display,
-	u32                     component_id);
-
-void
-acpi_ut_debug_print (
-	u32                     requested_debug_level,
-	u32                     line_number,
-	acpi_debug_print_info   *dbg_info,
-	char                    *format,
-	...) ACPI_PRINTF_LIKE_FUNC;
-
-void
-acpi_ut_debug_print_raw (
-	u32                     requested_debug_level,
-	u32                     line_number,
-	acpi_debug_print_info   *dbg_info,
-	char                    *format,
-	...) ACPI_PRINTF_LIKE_FUNC;
-
-
-/*
- * Ut_delete - Object deletion
- */
-
-void
-acpi_ut_delete_internal_obj (
-	acpi_operand_object     *object);
-
-void
-acpi_ut_delete_internal_package_object (
-	acpi_operand_object     *object);
-
-void
-acpi_ut_delete_internal_simple_object (
-	acpi_operand_object     *object);
-
-acpi_status
-acpi_ut_delete_internal_object_list (
-	acpi_operand_object     **obj_list);
-
-
-/*
- * Ut_eval - object evaluation
- */
-
-/* Method name strings */
-
-#define METHOD_NAME__HID        "_HID"
-#define METHOD_NAME__UID        "_UID"
-#define METHOD_NAME__ADR        "_ADR"
-#define METHOD_NAME__STA        "_STA"
-#define METHOD_NAME__REG        "_REG"
-#define METHOD_NAME__SEG        "_SEG"
-#define METHOD_NAME__BBN        "_BBN"
-#define METHOD_NAME__PRT        "_PRT"
-
-
-acpi_status
-acpi_ut_evaluate_numeric_object (
-	NATIVE_CHAR             *object_name,
-	acpi_namespace_node     *device_node,
-	acpi_integer            *address);
-
-acpi_status
-acpi_ut_execute_HID (
-	acpi_namespace_node     *device_node,
-	acpi_device_id          *hid);
-
-acpi_status
-acpi_ut_execute_STA (
-	acpi_namespace_node     *device_node,
-	u32                     *status_flags);
-
-acpi_status
-acpi_ut_execute_UID (
-	acpi_namespace_node     *device_node,
-	acpi_device_id          *uid);
-
-
-/*
- * Ut_mutex - mutual exclusion interfaces
- */
-
-acpi_status
-acpi_ut_mutex_initialize (
-	void);
-
-void
-acpi_ut_mutex_terminate (
-	void);
-
-acpi_status
-acpi_ut_create_mutex (
-	ACPI_MUTEX_HANDLE       mutex_id);
-
-acpi_status
-acpi_ut_delete_mutex (
-	ACPI_MUTEX_HANDLE       mutex_id);
-
-acpi_status
-acpi_ut_acquire_mutex (
-	ACPI_MUTEX_HANDLE       mutex_id);
-
-acpi_status
-acpi_ut_release_mutex (
-	ACPI_MUTEX_HANDLE       mutex_id);
-
-
-/*
- * Ut_object - internal object create/delete/cache routines
- */
-
-acpi_operand_object  *
-acpi_ut_create_internal_object_dbg (
-	NATIVE_CHAR             *module_name,
-	u32                     line_number,
-	u32                     component_id,
-	acpi_object_type8       type);
-
-void *
-acpi_ut_allocate_object_desc_dbg (
-	NATIVE_CHAR             *module_name,
-	u32                     line_number,
-	u32                     component_id);
-
-#define acpi_ut_create_internal_object(t) acpi_ut_create_internal_object_dbg (_THIS_MODULE,__LINE__,_COMPONENT,t)
-#define acpi_ut_allocate_object_desc()  acpi_ut_allocate_object_desc_dbg (_THIS_MODULE,__LINE__,_COMPONENT)
-
-void
-acpi_ut_delete_object_desc (
-	acpi_operand_object     *object);
-
-u8
-acpi_ut_valid_internal_object (
-	void                    *object);
-
-
-/*
- * Ut_ref_cnt - Object reference count management
- */
-
-void
-acpi_ut_add_reference (
-	acpi_operand_object     *object);
-
-void
-acpi_ut_remove_reference (
-	acpi_operand_object     *object);
-
-/*
- * Ut_size - Object size routines
- */
-
-acpi_status
-acpi_ut_get_simple_object_size (
-	acpi_operand_object     *obj,
-	u32                     *obj_length);
-
-acpi_status
-acpi_ut_get_package_object_size (
-	acpi_operand_object     *obj,
-	u32                     *obj_length);
-
-acpi_status
-acpi_ut_get_object_size(
-	acpi_operand_object     *obj,
-	u32                     *obj_length);
-
-
-/*
- * Ut_state - Generic state creation/cache routines
- */
-
-void
-acpi_ut_push_generic_state (
-	acpi_generic_state      **list_head,
-	acpi_generic_state      *state);
-
-acpi_generic_state *
-acpi_ut_pop_generic_state (
-	acpi_generic_state      **list_head);
-
-
-acpi_generic_state *
-acpi_ut_create_generic_state (
-	void);
-
-acpi_generic_state *
-acpi_ut_create_update_state (
-	acpi_operand_object     *object,
-	u16                     action);
-
-acpi_generic_state *
-acpi_ut_create_pkg_state (
-	void                    *internal_object,
-	void                    *external_object,
-	u16                     index);
-
-acpi_status
-acpi_ut_create_update_state_and_push (
-	acpi_operand_object     *object,
-	u16                     action,
-	acpi_generic_state      **state_list);
-
-acpi_status
-acpi_ut_create_pkg_state_and_push (
-	void                    *internal_object,
-	void                    *external_object,
-	u16                     index,
-	acpi_generic_state      **state_list);
-
-acpi_generic_state *
-acpi_ut_create_control_state (
-	void);
-
-void
-acpi_ut_delete_generic_state (
-	acpi_generic_state      *state);
-
-void
-acpi_ut_delete_generic_state_cache (
-	void);
-
-void
-acpi_ut_delete_object_cache (
-	void);
-
-/*
- * utmisc
- */
-
-acpi_status
-acpi_ut_divide (
-	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,
-	u32                     divisor,
-	acpi_integer            *out_quotient,
-	u32                     *out_remainder);
-
-u8
-acpi_ut_valid_acpi_name (
-	u32                     name);
-
-u8
-acpi_ut_valid_acpi_character (
-	NATIVE_CHAR             character);
-
-NATIVE_CHAR *
-acpi_ut_strupr (
-	NATIVE_CHAR             *src_string);
-
-acpi_status
-acpi_ut_resolve_package_references (
-	acpi_operand_object     *obj_desc);
-
-
-#ifdef ACPI_DEBUG
-void
-acpi_ut_display_init_pathname (
-	acpi_handle             obj_handle,
-	char                    *path);
-
-#endif
-
-
-/*
- * Utalloc - memory allocation and object caching
- */
-
-void *
-acpi_ut_acquire_from_cache (
-	u32                     list_id);
-
-void
-acpi_ut_release_to_cache (
-	u32                     list_id,
-	void                    *object);
-
-void
-acpi_ut_delete_generic_cache (
-	u32                     list_id);
-
-
-/* Debug Memory allocation functions */
-
-void *
-acpi_ut_allocate (
-	u32                     size,
-	u32                     component,
-	NATIVE_CHAR             *module,
-	u32                     line);
-
-void *
-acpi_ut_callocate (
-	u32                     size,
-	u32                     component,
-	NATIVE_CHAR             *module,
-	u32                     line);
-
-void
-acpi_ut_free (
-	void                    *address,
-	u32                     component,
-	NATIVE_CHAR             *module,
-	u32                     line);
-
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
-void
-acpi_ut_dump_allocation_info (
-	void);
-
-void
-acpi_ut_dump_allocations (
-	u32                     component,
-	NATIVE_CHAR             *module);
-#endif
-
-
-#endif /* _ACUTILS_H */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/amlcode.h linux-2.4.22-pre2/drivers/acpi/include/amlcode.h
--- linux-2.4.21/drivers/acpi/include/amlcode.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/amlcode.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,459 +0,0 @@
-/******************************************************************************
- *
- * Name: amlcode.h - Definitions for AML, as included in "definition blocks"
- *                   Declarations and definitions contained herein are derived
- *                   directly from the ACPI specification.
- *       $Revision: 58 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __AMLCODE_H__
-#define __AMLCODE_H__
-
-
-/* primary opcodes */
-
-#define AML_NULL_CHAR               (u16) 0x00
-
-#define AML_ZERO_OP                 (u16) 0x00
-#define AML_ONE_OP                  (u16) 0x01
-#define AML_UNASSIGNED              (u16) 0x02
-#define AML_ALIAS_OP                (u16) 0x06
-#define AML_NAME_OP                 (u16) 0x08
-#define AML_BYTE_OP                 (u16) 0x0a
-#define AML_WORD_OP                 (u16) 0x0b
-#define AML_DWORD_OP                (u16) 0x0c
-#define AML_STRING_OP               (u16) 0x0d
-#define AML_QWORD_OP                (u16) 0x0e     /* ACPI 2.0 */
-#define AML_SCOPE_OP                (u16) 0x10
-#define AML_BUFFER_OP               (u16) 0x11
-#define AML_PACKAGE_OP              (u16) 0x12
-#define AML_VAR_PACKAGE_OP          (u16) 0x13     /* ACPI 2.0 */
-#define AML_METHOD_OP               (u16) 0x14
-#define AML_DUAL_NAME_PREFIX        (u16) 0x2e
-#define AML_MULTI_NAME_PREFIX_OP    (u16) 0x2f
-#define AML_NAME_CHAR_SUBSEQ        (u16) 0x30
-#define AML_NAME_CHAR_FIRST         (u16) 0x41
-#define AML_OP_PREFIX               (u16) 0x5b
-#define AML_ROOT_PREFIX             (u16) 0x5c
-#define AML_PARENT_PREFIX           (u16) 0x5e
-#define AML_LOCAL_OP                (u16) 0x60
-#define AML_LOCAL0                  (u16) 0x60
-#define AML_LOCAL1                  (u16) 0x61
-#define AML_LOCAL2                  (u16) 0x62
-#define AML_LOCAL3                  (u16) 0x63
-#define AML_LOCAL4                  (u16) 0x64
-#define AML_LOCAL5                  (u16) 0x65
-#define AML_LOCAL6                  (u16) 0x66
-#define AML_LOCAL7                  (u16) 0x67
-#define AML_ARG_OP                  (u16) 0x68
-#define AML_ARG0                    (u16) 0x68
-#define AML_ARG1                    (u16) 0x69
-#define AML_ARG2                    (u16) 0x6a
-#define AML_ARG3                    (u16) 0x6b
-#define AML_ARG4                    (u16) 0x6c
-#define AML_ARG5                    (u16) 0x6d
-#define AML_ARG6                    (u16) 0x6e
-#define AML_STORE_OP                (u16) 0x70
-#define AML_REF_OF_OP               (u16) 0x71
-#define AML_ADD_OP                  (u16) 0x72
-#define AML_CONCAT_OP               (u16) 0x73
-#define AML_SUBTRACT_OP             (u16) 0x74
-#define AML_INCREMENT_OP            (u16) 0x75
-#define AML_DECREMENT_OP            (u16) 0x76
-#define AML_MULTIPLY_OP             (u16) 0x77
-#define AML_DIVIDE_OP               (u16) 0x78
-#define AML_SHIFT_LEFT_OP           (u16) 0x79
-#define AML_SHIFT_RIGHT_OP          (u16) 0x7a
-#define AML_BIT_AND_OP              (u16) 0x7b
-#define AML_BIT_NAND_OP             (u16) 0x7c
-#define AML_BIT_OR_OP               (u16) 0x7d
-#define AML_BIT_NOR_OP              (u16) 0x7e
-#define AML_BIT_XOR_OP              (u16) 0x7f
-#define AML_BIT_NOT_OP              (u16) 0x80
-#define AML_FIND_SET_LEFT_BIT_OP    (u16) 0x81
-#define AML_FIND_SET_RIGHT_BIT_OP   (u16) 0x82
-#define AML_DEREF_OF_OP             (u16) 0x83
-#define AML_CONCAT_RES_OP           (u16) 0x84     /* ACPI 2.0 */
-#define AML_MOD_OP                  (u16) 0x85     /* ACPI 2.0 */
-#define AML_NOTIFY_OP               (u16) 0x86
-#define AML_SIZE_OF_OP              (u16) 0x87
-#define AML_INDEX_OP                (u16) 0x88
-#define AML_MATCH_OP                (u16) 0x89
-#define AML_CREATE_DWORD_FIELD_OP   (u16) 0x8a
-#define AML_CREATE_WORD_FIELD_OP    (u16) 0x8b
-#define AML_CREATE_BYTE_FIELD_OP    (u16) 0x8c
-#define AML_CREATE_BIT_FIELD_OP     (u16) 0x8d
-#define AML_TYPE_OP                 (u16) 0x8e
-#define AML_CREATE_QWORD_FIELD_OP   (u16) 0x8f     /* ACPI 2.0 */
-#define AML_LAND_OP                 (u16) 0x90
-#define AML_LOR_OP                  (u16) 0x91
-#define AML_LNOT_OP                 (u16) 0x92
-#define AML_LEQUAL_OP               (u16) 0x93
-#define AML_LGREATER_OP             (u16) 0x94
-#define AML_LLESS_OP                (u16) 0x95
-#define AML_TO_BUFFER_OP            (u16) 0x96     /* ACPI 2.0 */
-#define AML_TO_DECSTRING_OP         (u16) 0x97     /* ACPI 2.0 */
-#define AML_TO_HEXSTRING_OP         (u16) 0x98     /* ACPI 2.0 */
-#define AML_TO_INTEGER_OP           (u16) 0x99     /* ACPI 2.0 */
-#define AML_TO_STRING_OP            (u16) 0x9c     /* ACPI 2.0 */
-#define AML_COPY_OP                 (u16) 0x9d     /* ACPI 2.0 */
-#define AML_MID_OP                  (u16) 0x9e     /* ACPI 2.0 */
-#define AML_CONTINUE_OP             (u16) 0x9f     /* ACPI 2.0 */
-#define AML_IF_OP                   (u16) 0xa0
-#define AML_ELSE_OP                 (u16) 0xa1
-#define AML_WHILE_OP                (u16) 0xa2
-#define AML_NOOP_OP                 (u16) 0xa3
-#define AML_RETURN_OP               (u16) 0xa4
-#define AML_BREAK_OP                (u16) 0xa5
-#define AML_BREAK_POINT_OP          (u16) 0xcc
-#define AML_ONES_OP                 (u16) 0xff
-
-/* prefixed opcodes */
-
-#define AML_EXTOP                   (u16) 0x005b
-
-
-#define AML_MUTEX_OP                (u16) 0x5b01
-#define AML_EVENT_OP                (u16) 0x5b02
-#define AML_SHIFT_RIGHT_BIT_OP      (u16) 0x5b10
-#define AML_SHIFT_LEFT_BIT_OP       (u16) 0x5b11
-#define AML_COND_REF_OF_OP          (u16) 0x5b12
-#define AML_CREATE_FIELD_OP         (u16) 0x5b13
-#define AML_LOAD_TABLE_OP           (u16) 0x5b1f     /* ACPI 2.0 */
-#define AML_LOAD_OP                 (u16) 0x5b20
-#define AML_STALL_OP                (u16) 0x5b21
-#define AML_SLEEP_OP                (u16) 0x5b22
-#define AML_ACQUIRE_OP              (u16) 0x5b23
-#define AML_SIGNAL_OP               (u16) 0x5b24
-#define AML_WAIT_OP                 (u16) 0x5b25
-#define AML_RESET_OP                (u16) 0x5b26
-#define AML_RELEASE_OP              (u16) 0x5b27
-#define AML_FROM_BCD_OP             (u16) 0x5b28
-#define AML_TO_BCD_OP               (u16) 0x5b29
-#define AML_UNLOAD_OP               (u16) 0x5b2a
-#define AML_REVISION_OP             (u16) 0x5b30
-#define AML_DEBUG_OP                (u16) 0x5b31
-#define AML_FATAL_OP                (u16) 0x5b32
-#define AML_REGION_OP               (u16) 0x5b80
-#define AML_FIELD_OP                (u16) 0x5b81
-#define AML_DEVICE_OP               (u16) 0x5b82
-#define AML_PROCESSOR_OP            (u16) 0x5b83
-#define AML_POWER_RES_OP            (u16) 0x5b84
-#define AML_THERMAL_ZONE_OP         (u16) 0x5b85
-#define AML_INDEX_FIELD_OP          (u16) 0x5b86
-#define AML_BANK_FIELD_OP           (u16) 0x5b87
-#define AML_DATA_REGION_OP          (u16) 0x5b88     /* ACPI 2.0 */
-
-
-/* Bogus opcodes (they are actually two separate opcodes) */
-
-#define AML_LGREATEREQUAL_OP        (u16) 0x9295
-#define AML_LLESSEQUAL_OP           (u16) 0x9294
-#define AML_LNOTEQUAL_OP            (u16) 0x9293
-
-
-/*
- * Internal opcodes
- * Use only "Unknown" AML opcodes, don't attempt to use
- * any valid ACPI ASCII values (A-Z, 0-9, '-')
- */
-
-#define AML_INT_NAMEPATH_OP         (u16) 0x002d
-#define AML_INT_NAMEDFIELD_OP       (u16) 0x0030
-#define AML_INT_RESERVEDFIELD_OP    (u16) 0x0031
-#define AML_INT_ACCESSFIELD_OP      (u16) 0x0032
-#define AML_INT_BYTELIST_OP         (u16) 0x0033
-#define AML_INT_STATICSTRING_OP     (u16) 0x0034
-#define AML_INT_METHODCALL_OP       (u16) 0x0035
-#define AML_INT_RETURN_VALUE_OP     (u16) 0x0036
-
-
-#define ARG_NONE                    0x0
-
-/*
- * Argument types for the AML Parser
- * Each field in the Arg_types u32 is 5 bits, allowing for a maximum of 6 arguments.
- * There can be up to 31 unique argument types
- */
-
-#define ARGP_BYTEDATA               0x01
-#define ARGP_BYTELIST               0x02
-#define ARGP_CHARLIST               0x03
-#define ARGP_DATAOBJ                0x04
-#define ARGP_DATAOBJLIST            0x05
-#define ARGP_DWORDDATA              0x06
-#define ARGP_FIELDLIST              0x07
-#define ARGP_NAME                   0x08
-#define ARGP_NAMESTRING             0x09
-#define ARGP_OBJLIST                0x0A
-#define ARGP_PKGLENGTH              0x0B
-#define ARGP_SUPERNAME              0x0C
-#define ARGP_TARGET                 0x0D
-#define ARGP_TERMARG                0x0E
-#define ARGP_TERMLIST               0x0F
-#define ARGP_WORDDATA               0x10
-#define ARGP_QWORDDATA              0x11
-#define ARGP_SIMPLENAME             0x12
-
-/*
- * Resolved argument types for the AML Interpreter
- * Each field in the Arg_types u32 is 5 bits, allowing for a maximum of 6 arguments.
- * There can be up to 31 unique argument types (0 is end-of-arg-list indicator)
- */
-
-/* "Standard" ACPI types are 1-15 (0x0F) */
-
-#define ARGI_INTEGER                ACPI_TYPE_INTEGER       /* 1 */
-#define ARGI_STRING                 ACPI_TYPE_STRING        /* 2 */
-#define ARGI_BUFFER                 ACPI_TYPE_BUFFER        /* 3 */
-#define ARGI_PACKAGE                ACPI_TYPE_PACKAGE       /* 4 */
-#define ARGI_EVENT                  ACPI_TYPE_EVENT
-#define ARGI_MUTEX                  ACPI_TYPE_MUTEX
-#define ARGI_REGION                 ACPI_TYPE_REGION
-#define ARGI_DDBHANDLE              ACPI_TYPE_DDB_HANDLE
-
-/* Custom types are 0x10 through 0x1F */
-
-#define ARGI_IF                     0x10
-#define ARGI_ANYOBJECT              0x11
-#define ARGI_ANYTYPE                0x12
-#define ARGI_COMPUTEDATA            0x13     /* Buffer, String, or Integer */
-#define ARGI_DATAOBJECT             0x14     /* Buffer, String, package or reference to a Node - Used only by Size_of operator*/
-#define ARGI_COMPLEXOBJ             0x15     /* Buffer, String, or package (Used by INDEX op only) */
-#define ARGI_INTEGER_REF            0x16
-#define ARGI_OBJECT_REF             0x17
-#define ARGI_DEVICE_REF             0x18
-#define ARGI_REFERENCE              0x19
-#define ARGI_TARGETREF              0x1A     /* Target, subject to implicit conversion */
-#define ARGI_FIXED_TARGET           0x1B     /* Target, no implicit conversion */
-#define ARGI_SIMPLE_TARGET          0x1C     /* Name, Local, Arg -- no implicit conversion */
-#define ARGI_BUFFERSTRING           0x1D
-
-#define ARGI_INVALID_OPCODE         0xFFFFFFFF
-
-
-/*
- * hash offsets
- */
-#define AML_EXTOP_HASH_OFFSET       22
-#define AML_LNOT_HASH_OFFSET        19
-
-
-/*
- * opcode groups and types
- */
-
-#define OPGRP_NAMED                 0x01
-#define OPGRP_FIELD                 0x02
-#define OPGRP_BYTELIST              0x04
-
-
-/*
- * Opcode information
- */
-
-/* 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
-
-/* Convenient flag groupings */
-
-#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
-#define AML_FLAGS_EXEC_1A_1T_1R     AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* Monadic2_r */
-#define AML_FLAGS_EXEC_2A_0T_0R     AML_HAS_ARGS                                   /* Dyadic1   */
-#define AML_FLAGS_EXEC_2A_0T_1R     AML_HAS_ARGS |                  AML_HAS_RETVAL /* Dyadic2   */
-#define AML_FLAGS_EXEC_2A_1T_1R     AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* Dyadic2_r  */
-#define AML_FLAGS_EXEC_2A_2T_1R     AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL
-#define AML_FLAGS_EXEC_3A_0T_0R     AML_HAS_ARGS
-#define AML_FLAGS_EXEC_3A_1T_1R     AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL
-#define AML_FLAGS_EXEC_6A_0T_1R     AML_HAS_ARGS |                  AML_HAS_RETVAL
-
-
-/*
- * 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
-/* End of types used in dispatch table */
-
-#define AML_TYPE_LITERAL            0x0B
-#define AML_TYPE_CONSTANT           0x0C
-#define AML_TYPE_METHOD_ARGUMENT    0x0D
-#define AML_TYPE_LOCAL_VARIABLE     0x0E
-#define AML_TYPE_DATA_TERM          0x0F
-
-/* Generic for an op that returns a value */
-
-#define AML_TYPE_METHOD_CALL        0x10
-
-/* Misc */
-
-#define AML_TYPE_CREATE_FIELD       0x11
-#define AML_TYPE_CONTROL            0x12
-#define AML_TYPE_NAMED_NO_OBJ       0x13
-#define AML_TYPE_NAMED_FIELD        0x14
-#define AML_TYPE_NAMED_SIMPLE       0x15
-#define AML_TYPE_NAMED_COMPLEX      0x16
-#define AML_TYPE_RETURN             0x17
-
-#define AML_TYPE_UNDEFINED          0x18
-#define AML_TYPE_BOGUS              0x19
-
-
-/*
- * Opcode classes
- */
-#define AML_CLASS_EXECUTE           0x00
-#define AML_CLASS_CREATE            0x01
-#define AML_CLASS_ARGUMENT          0x02
-#define AML_CLASS_NAMED_OBJECT      0x03
-#define AML_CLASS_CONTROL           0x04
-#define AML_CLASS_ASCII             0x05
-#define AML_CLASS_PREFIX            0x06
-#define AML_CLASS_INTERNAL          0x07
-#define AML_CLASS_RETURN_VALUE      0x08
-#define AML_CLASS_METHOD_CALL       0x09
-#define AML_CLASS_UNKNOWN           0x0A
-
-
-/* Predefined Operation Region Space_iDs */
-
-typedef enum
-{
-	REGION_MEMORY                   = 0,
-	REGION_IO,
-	REGION_PCI_CONFIG,
-	REGION_EC,
-	REGION_SMBUS,
-	REGION_CMOS,
-	REGION_PCI_BAR,
-	REGION_FIXED_HW                 = 0x7F,
-
-} AML_REGION_TYPES;
-
-
-/* Comparison operation codes for Match_op operator */
-
-typedef enum
-{
-	MATCH_MTR                       = 0,
-	MATCH_MEQ                       = 1,
-	MATCH_MLE                       = 2,
-	MATCH_MLT                       = 3,
-	MATCH_MGE                       = 4,
-	MATCH_MGT                       = 5
-
-} AML_MATCH_OPERATOR;
-
-#define MAX_MATCH_OPERATOR          5
-
-
-/* Field Access Types */
-
-#define ACCESS_TYPE_MASK            0x0f
-#define ACCESS_TYPE_SHIFT           0
-
-typedef enum
-{
-	ACCESS_ANY_ACC                  = 0,
-	ACCESS_BYTE_ACC                 = 1,
-	ACCESS_WORD_ACC                 = 2,
-	ACCESS_DWORD_ACC                = 3,
-	ACCESS_QWORD_ACC                = 4,    /* ACPI 2.0 */
-	ACCESS_BLOCK_ACC                = 4,
-	ACCESS_SMBSEND_RECV_ACC         = 5,
-	ACCESS_SMBQUICK_ACC             = 6
-
-} AML_ACCESS_TYPE;
-
-
-/* Field Lock Rules */
-
-#define LOCK_RULE_MASK              0x10
-#define LOCK_RULE_SHIFT             4
-
-typedef enum
-{
-	GLOCK_NEVER_LOCK                = 0,
-	GLOCK_ALWAYS_LOCK               = 1
-
-} AML_LOCK_RULE;
-
-
-/* Field Update Rules */
-
-#define UPDATE_RULE_MASK            0x060
-#define UPDATE_RULE_SHIFT           5
-
-typedef enum
-{
-	UPDATE_PRESERVE                 = 0,
-	UPDATE_WRITE_AS_ONES            = 1,
-	UPDATE_WRITE_AS_ZEROS           = 2
-
-} AML_UPDATE_RULE;
-
-
-/* bit fields in Method_flags byte */
-
-#define METHOD_FLAGS_ARG_COUNT      0x07
-#define METHOD_FLAGS_SERIALIZED     0x08
-#define METHOD_FLAGS_SYNCH_LEVEL    0xF0
-
-
-/* Array sizes.  Used for range checking also */
-
-#define NUM_REGION_TYPES            7
-#define NUM_ACCESS_TYPES            7
-#define NUM_UPDATE_RULES            3
-#define NUM_MATCH_OPS               7
-#define NUM_OPCODES                 256
-#define NUM_FIELD_NAMES             2
-
-
-#define USER_REGION_BEGIN           0x80
-
-
-#endif /* __AMLCODE_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/platform/acenv.h linux-2.4.22-pre2/drivers/acpi/include/platform/acenv.h
--- linux-2.4.21/drivers/acpi/include/platform/acenv.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/platform/acenv.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,294 +0,0 @@
-/******************************************************************************
- *
- * Name: acenv.h - Generation environment specific items
- *       $Revision: 77 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACENV_H__
-#define __ACENV_H__
-
-
-/*
- * Configuration for ACPI tools and utilities
- */
-
-#ifdef _ACPI_DUMP_APP
-#define ACPI_DEBUG
-#define ACPI_APPLICATION
-#define ENABLE_DEBUGGER
-#define ACPI_USE_SYSTEM_CLIBRARY
-#define PARSER_ONLY
-#endif
-
-#ifdef _ACPI_EXEC_APP
-#undef DEBUGGER_THREADING
-#define DEBUGGER_THREADING      DEBUGGER_SINGLE_THREADED
-#define ACPI_DEBUG
-#define ACPI_APPLICATION
-#define ENABLE_DEBUGGER
-#define ACPI_USE_SYSTEM_CLIBRARY
-#endif
-
-#ifdef _ACPI_ASL_COMPILER
-#define ACPI_DEBUG
-#define ACPI_APPLICATION
-#define ENABLE_DEBUGGER
-#define ACPI_USE_SYSTEM_CLIBRARY
-#endif
-
-/*
- * Memory allocation tracking.  Used only if
- * 1) This is the debug version
- * 2) This is NOT a 16-bit version of the code (not enough real-mode memory)
- */
-#ifdef ACPI_DEBUG
-#ifndef _IA16
-#define ACPI_DBG_TRACK_ALLOCATIONS
-#endif
-#endif
-
-/*
- * Environment configuration.  The purpose of this file is to interface to the
- * local generation environment.
- *
- * 1) ACPI_USE_SYSTEM_CLIBRARY - Define this if linking to an actual C library.
- *      Otherwise, local versions of string/memory functions will be used.
- * 2) ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and
- *      the standard header files may be used.
- *
- * The ACPI subsystem only uses low level C library functions that do not call
- * operating system services and may therefore be inlined in the code.
- *
- * It may be necessary to tailor these include files to the target
- * generation environment.
- *
- *
- * Functions and constants used from each header:
- *
- * string.h:    memcpy
- *              memset
- *              strcat
- *              strcmp
- *              strcpy
- *              strlen
- *              strncmp
- *              strncat
- *              strncpy
- *
- * stdlib.h:    strtoul
- *
- * stdarg.h:    va_list
- *              va_arg
- *              va_start
- *              va_end
- *
- */
-
-/*! [Begin] no source code translation */
-
-#ifdef _LINUX
-#include "aclinux.h"
-
-#elif _AED_EFI
-#include "acefi.h"
-
-#elif WIN32
-#include "acwin.h"
-
-#elif __FreeBSD__
-#include "acfreebsd.h"
-
-#else
-
-/* All other environments */
-
-#define ACPI_USE_STANDARD_HEADERS
-
-/* Name of host operating system (returned by the _OS_ namespace object) */
-
-#define ACPI_OS_NAME         "Intel ACPI/CA Core Subsystem"
-
-/* This macro is used to tag functions as "printf-like" because
- * some compilers can catch printf format string problems. MSVC
- * doesn't, so this is proprocessed away.
- */
-#define ACPI_PRINTF_LIKE_FUNC
-
-#endif
-
-
-/*! [End] no source code translation !*/
-
-/******************************************************************************
- *
- * C library configuration
- *
- *****************************************************************************/
-
-#ifdef ACPI_USE_SYSTEM_CLIBRARY
-/*
- * Use the standard C library headers.
- * We want to keep these to a minimum.
- *
- */
-
-#ifdef ACPI_USE_STANDARD_HEADERS
-/*
- * Use the standard headers from the standard locations
- */
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#endif /* ACPI_USE_STANDARD_HEADERS */
-
-/*
- * We will be linking to the standard Clib functions
- */
-
-#define STRSTR(s1,s2)   strstr((s1), (s2))
-#define STRUPR(s)       acpi_ut_strupr ((s))
-#define STRLEN(s)       (u32) strlen((s))
-#define STRCPY(d,s)     strcpy((d), (s))
-#define STRNCPY(d,s,n)  strncpy((d), (s), (NATIVE_INT)(n))
-#define STRNCMP(d,s,n)  strncmp((d), (s), (NATIVE_INT)(n))
-#define STRCMP(d,s)     strcmp((d), (s))
-#define STRCAT(d,s)     strcat((d), (s))
-#define STRNCAT(d,s,n)  strncat((d), (s), (NATIVE_INT)(n))
-#define STRTOUL(d,s,n)  strtoul((d), (s), (NATIVE_INT)(n))
-#define MEMCPY(d,s,n)   memcpy((d), (s), (NATIVE_INT)(n))
-#define MEMSET(d,s,n)   memset((d), (s), (NATIVE_INT)(n))
-#define TOUPPER         toupper
-#define TOLOWER         tolower
-#define IS_XDIGIT       isxdigit
-
-/******************************************************************************
- *
- * Not using native C library, use local implementations
- *
- *****************************************************************************/
-#else
-
-/*
- * Use local definitions of C library macros and functions
- * NOTE: The function implementations may not be as efficient
- * as an inline or assembly code implementation provided by a
- * native C library.
- */
-
-#ifndef va_arg
-
-#ifndef _VALIST
-#define _VALIST
-typedef char *va_list;
-#endif /* _VALIST */
-
-/*
- * Storage alignment properties
- */
-
-#define  _AUPBND         (sizeof (NATIVE_INT) - 1)
-#define  _ADNBND         (sizeof (NATIVE_INT) - 1)
-
-/*
- * Variable argument list macro definitions
- */
-
-#define _bnd(X, bnd)    (((sizeof (X)) + (bnd)) & (~(bnd)))
-#define va_arg(ap, T)   (*(T *)(((ap) += (_bnd (T, _AUPBND))) - (_bnd (T,_ADNBND))))
-#define va_end(ap)      (void) 0
-#define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_bnd (A,_AUPBND))))
-
-#endif /* va_arg */
-
-
-#define STRSTR(s1,s2)    acpi_ut_strstr ((s1), (s2))
-#define STRUPR(s)        acpi_ut_strupr ((s))
-#define STRLEN(s)        acpi_ut_strlen ((s))
-#define STRCPY(d,s)      acpi_ut_strcpy ((d), (s))
-#define STRNCPY(d,s,n)   acpi_ut_strncpy ((d), (s), (n))
-#define STRNCMP(d,s,n)   acpi_ut_strncmp ((d), (s), (n))
-#define STRCMP(d,s)      acpi_ut_strcmp ((d), (s))
-#define STRCAT(d,s)      acpi_ut_strcat ((d), (s))
-#define STRNCAT(d,s,n)   acpi_ut_strncat ((d), (s), (n))
-#define STRTOUL(d,s,n)   acpi_ut_strtoul ((d), (s),(n))
-#define MEMCPY(d,s,n)    acpi_ut_memcpy ((d), (s), (n))
-#define MEMSET(d,v,n)    acpi_ut_memset ((d), (v), (n))
-#define TOUPPER          acpi_ut_to_upper
-#define TOLOWER          acpi_ut_to_lower
-
-#endif /* ACPI_USE_SYSTEM_CLIBRARY */
-
-
-/******************************************************************************
- *
- * Assembly code macros
- *
- *****************************************************************************/
-
-/*
- * Handle platform- and compiler-specific assembly language differences.
- * These should already have been defined by the platform includes above.
- *
- * Notes:
- * 1) Interrupt 3 is used to break into a debugger
- * 2) Interrupts are turned off during ACPI register setup
- */
-
-/* Unrecognized compiler, use defaults */
-#ifndef ACPI_ASM_MACROS
-
-#define ACPI_ASM_MACROS
-#define causeinterrupt(level)
-#define BREAKPOINT3
-#define disable()
-#define enable()
-#define halt()
-#define ACPI_ACQUIRE_GLOBAL_LOCK(Glptr, acq)
-#define ACPI_RELEASE_GLOBAL_LOCK(Glptr, acq)
-
-#endif /* ACPI_ASM_MACROS */
-
-
-#ifdef ACPI_APPLICATION
-
-/* Don't want software interrupts within a ring3 application */
-
-#undef causeinterrupt
-#undef BREAKPOINT3
-#define causeinterrupt(level)
-#define BREAKPOINT3
-#endif
-
-
-/******************************************************************************
- *
- * Compiler-specific
- *
- *****************************************************************************/
-
-/* this has been moved to compiler-specific headers, which are included from the
-   platform header. */
-
-
-#endif /* __ACENV_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/platform/acgcc.h linux-2.4.22-pre2/drivers/acpi/include/platform/acgcc.h
--- linux-2.4.21/drivers/acpi/include/platform/acgcc.h	2002-11-28 23:53:12.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/platform/acgcc.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,196 +0,0 @@
-/******************************************************************************
- *
- * Name: acgcc.h - GCC specific defines, etc.
- *       $Revision: 14 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACGCC_H__
-#define __ACGCC_H__
-
-
-#ifdef __ia64__
-#define _IA64
-
-#define COMPILER_DEPENDENT_UINT64   unsigned long
-/* Single threaded */
-#define ACPI_APPLICATION
-
-#define ACPI_ASM_MACROS
-#define causeinterrupt(level)
-#define BREAKPOINT3
-#define disable() __cli()
-#define enable()  __sti()
-
-/*! [Begin] no source code translation */
-
-#include <asm/pal.h>
-
-#define halt()              ia64_pal_halt_light()           /* PAL_HALT[_LIGHT] */
-#define safe_halt()         ia64_pal_halt(1)                /* PAL_HALT */
-
-
-#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \
-	do { \
-	__asm__ volatile ("1:  ld4      r29=%1\n"  \
-		";;\n"                  \
-		"mov    ar.ccv=r29\n"   \
-		"mov    r2=r29\n"       \
-		"shr.u  r30=r29,1\n"    \
-		"and    r29=-4,r29\n"   \
-		";;\n"                  \
-		"add    r29=2,r29\n"    \
-		"and    r30=1,r30\n"    \
-		";;\n"                  \
-		"add    r29=r29,r30\n"  \
-		";;\n"                  \
-		"cmpxchg4.acq   r30=%1,r29,ar.ccv\n" \
-		";;\n"                  \
-		"cmp.eq p6,p7=r2,r30\n" \
-		"(p7) br.dpnt.few 1b\n" \
-		"cmp.gt p8,p9=3,r29\n"  \
-		";;\n"                  \
-		"(p8) mov %0=-1\n"      \
-		"(p9) mov %0=r0\n"      \
-		:"=r"(Acq):"m"(GLptr):"r2","r29","r30","memory"); \
-	} while (0)
-
-#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \
-	do { \
-	__asm__ volatile ("1:  ld4      r29=%1\n" \
-		";;\n"                  \
-		"mov    ar.ccv=r29\n"   \
-		"mov    r2=r29\n"       \
-		"and    r29=-4,r29\n"   \
-		";;\n"                  \
-		"cmpxchg4.acq   r30=%1,r29,ar.ccv\n" \
-		";;\n"                  \
-		"cmp.eq p6,p7=r2,r30\n" \
-		"(p7) br.dpnt.few 1b\n" \
-		"and    %0=1,r2\n"      \
-		";;\n"                  \
-		:"=r"(Acq):"m"(GLptr):"r2","r29","r30","memory"); \
-	} while (0)
-/*! [End] no source code translation !*/
-
-
-#elif __i386__ /* DO IA32 */
-#define COMPILER_DEPENDENT_UINT64   unsigned long long
-#define ACPI_ASM_MACROS
-#define causeinterrupt(level)
-#define BREAKPOINT3
-#define disable() __cli()
-#define enable()  __sti()
-#define halt()    __asm__ __volatile__ ("sti; hlt":::"memory")
-
-/*! [Begin] no source code translation
- *
- * A brief explanation as GNU inline assembly is a bit hairy
- *  %0 is the output parameter in EAX ("=a")
- *  %1 and %2 are the input parameters in ECX ("c")
- *  and an immediate value ("i") respectively
- *  All actual register references are preceded with "%%" as in "%%edx"
- *  Immediate values in the assembly are preceded by "$" as in "$0x1"
- *  The final asm parameter are the operation altered non-output registers.
- */
-#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \
-	do { \
-		int dummy; \
-		asm("1:     movl (%1),%%eax;" \
-			"movl   %%eax,%%edx;" \
-			"andl   %2,%%edx;" \
-			"btsl   $0x1,%%edx;" \
-			"adcl   $0x0,%%edx;" \
-			"lock;  cmpxchgl %%edx,(%1);" \
-			"jnz    1b;" \
-			"cmpb   $0x3,%%dl;" \
-			"sbbl   %%eax,%%eax" \
-			:"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~1L):"dx"); \
-	} while(0)
-
-#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \
-	do { \
-		int dummy; \
-		asm("1:     movl (%1),%%eax;" \
-			"movl   %%eax,%%edx;" \
-			"andl   %2,%%edx;" \
-			"lock;  cmpxchgl %%edx,(%1);" \
-			"jnz    1b;" \
-			"andl   $0x1,%%eax" \
-			:"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~3L):"dx"); \
-	} while(0)
-#elif __x86_64__ 
-#define COMPILER_DEPENDENT_UINT64   unsigned long long
-#define ACPI_ASM_MACROS
-#define causeinterrupt(level)
-#define BREAKPOINT3
-#define disable() __cli()
-#define enable()  __sti()
-#define halt()    __asm__ __volatile__ ("sti; hlt":::"memory")
-
-/*! [Begin] no source code translation
- *
- * A brief explanation as GNU inline assembly is a bit hairy
- *  %0 is the output parameter in RAX ("=a")
- *  %1 and %2 are the input parameters in RCX ("c")
- *  and an immediate value ("i") respectively
- *  All actual register references are preceded with "%%" as in "%%edx"
- *  Immediate values in the assembly are preceded by "$" as in "$0x1"
- *  The final asm parameter are the operation altered non-output registers.
- */
-#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \
-	do { \
-		unsigned long dummy; \
-		asm("1:     movl (%2),%%eax;" \
-			"movl   %%eax,%%edx;" \
-			"andq   %2,%%rdx;" \
-			"btsl   $0x1,%%edx;" \
-			"adcl   $0x0,%%edx;" \
-			"lock;  cmpxchgl %%edx,(%1);" \
-			"jnz    1b;" \
-			"cmpb   $0x3,%%dl;" \
-			"sbbl   %%eax,%%eax" \
-			:"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~1L):"dx"); \
-	} while(0)
-
-#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \
-	do { \
-		unsigned long dummy; \
-		asm("1:     movl (%2),%%eax;" \
-			"movl   %%eax,%%edx;" \
-			"andq   %2,%%rdx;" \
-			"lock;  cmpxchgl %%edx,(%1);" \
-			"jnz    1b;" \
-			"andl   $0x1,%%eax" \
-			:"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~3L):"dx"); \
-	} while(0)
-
-/*! [End] no source code translation !*/
-
-#endif
-
-/* This macro is used to tag functions as "printf-like" because
- * some compilers (like GCC) can catch printf format string problems.
- */
-#define ACPI_PRINTF_LIKE_FUNC __attribute__ ((__format__ (__printf__, 4, 5)))
-
-
-#endif /* __ACGCC_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/include/platform/aclinux.h linux-2.4.22-pre2/drivers/acpi/include/platform/aclinux.h
--- linux-2.4.21/drivers/acpi/include/platform/aclinux.h	2002-11-28 23:53:12.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/include/platform/aclinux.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,71 +0,0 @@
-/******************************************************************************
- *
- * Name: aclinux.h - OS specific defines, etc.
- *       $Revision: 14 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 R. Byron Moore
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __ACLINUX_H__
-#define __ACLINUX_H__
-
-#define ACPI_OS_NAME                "Linux"
-
-#define ACPI_USE_SYSTEM_CLIBRARY
-
-#ifdef __KERNEL__
-
-#include <linux/config.h>
-#include <linux/string.h>
-#include <linux/kernel.h>
-#include <linux/ctype.h>
-#include <asm/system.h>
-#include <asm/atomic.h>
-#include <asm/div64.h>
-
-#define strtoul simple_strtoul
-
-#else
-
-#include <stdarg.h>
-#include <string.h>
-#include <stdlib.h>
-#include <ctype.h>
-
-#endif
-
-/* Linux uses GCC */
-
-#include "acgcc.h"
-
-#undef DEBUGGER_THREADING
-#define DEBUGGER_THREADING          DEBUGGER_SINGLE_THREADED
-
-#if BITS_PER_LONG < 64
-/* Linux ia32 can't do int64 well */
-#define ACPI_NO_INTEGER64_SUPPORT
-/* And the ia32 kernel doesn't include 64-bit divide support */
-#define ACPI_DIV64(dividend, divisor) do_div(dividend, divisor)
-#else
-#define ACPI_DIV64(dividend, divisor) ACPI_DIVIDE(dividend, divisor)
-#endif
-
-
-#endif /* __ACLINUX_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/kdb/README.txt linux-2.4.22-pre2/drivers/acpi/kdb/README.txt
--- linux-2.4.21/drivers/acpi/kdb/README.txt	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/kdb/README.txt	1970-01-01 00:00:00.000000000 +0000
@@ -1,36 +0,0 @@
-Using the ACPI debugger with kdb
---------------------------------
-
-ACPI CA includes a full-featured debugger, which allows the examination of
-a running system's ACPI tables, as well as running and stepping through
-control methods.
-
-Configuration
--------------
-1) Edit the main acpi Makefile. On the ACPI_CFLAGS line, remove the '#', thus
-   enabling the debugger.
-
-2) Download the latest kdb patch from:
-
-   ftp://oss.sgi.com/www/projects/kdb/download/ix86/ 
-
-   Follow the instructions at http://oss.sgi.com/projects/kdb/ on how to
-   install the patch and configure KDB.
-
-3) This would probably be a good time to recompile the kernel, and make sure
-   kdb works (Hitting the Pause key should drop you into it. Type "go" to exit
-   it.
-
-4) The kdb <--> ACPI debugger interface is a module. Type "make modules", and
-   it will be built and placed in drivers/acpi/kdb.
-
-5) Change to that directory and type "insmod kdbm_acpi.o". This loads the
-   module we just built.
-
-6) Break back into kdb. If you type help, you should now see "acpi" listed as
-   a command, at the bottom.
-
-7) Type "acpi". You are now in the ACPI debugger. While hosted by kdb, it is
-   wholly separate, and has many ACPI-specific commands. Type "?" or "help"
-   to get a listing of the command categories, and then "help <category>" for
-   a list of commands and their descriptions
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/kdb/kdbm_acpi.c linux-2.4.22-pre2/drivers/acpi/kdb/kdbm_acpi.c
--- linux-2.4.21/drivers/acpi/kdb/kdbm_acpi.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/kdb/kdbm_acpi.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,54 +0,0 @@
-/*
- *  kdbm_acpi.c - kdb debugger module interface for ACPI debugger
- *
- *  Copyright (C) 2000 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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/types.h>
-#include <linux/kdb.h>
-#include <linux/module.h>
-
-#include "acpi.h"
-#include "acdebug.h"
-
-extern int acpi_in_debugger;
-
-static int
-kdbm_acpi(int argc, const char **argv, const char **envp, struct pt_regs *regs)
-{
-	acpi_in_debugger = 1;
-
-	acpi_db_user_commands(DB_COMMAND_PROMPT, NULL);
-
-	acpi_in_debugger = 0;
-
-	return 0;
-}
-
-int
-init_module(void)
-{
-	kdb_register("acpi", kdbm_acpi, "", "Enter ACPI debugger", 0);
-
-	return 0;
-}
-
-void
-cleanup_module(void)
-{
-	kdb_unregister("acpi");
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/namespace/Makefile linux-2.4.22-pre2/drivers/acpi/namespace/Makefile
--- linux-2.4.21/drivers/acpi/namespace/Makefile	2001-06-21 00:47:40.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/namespace/Makefile	2003-06-26 21:43:12.000000000 +0000
@@ -1,11 +1,10 @@
 #
 # Makefile for all Linux ACPI interpreter subdirectories
-# EXCEPT for the ospm directory
 #
 
 O_TARGET := $(notdir $(CURDIR)).o
 
-obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/namespace/nsaccess.c linux-2.4.22-pre2/drivers/acpi/namespace/nsaccess.c
--- linux-2.4.21/drivers/acpi/namespace/nsaccess.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/namespace/nsaccess.c	2003-06-26 21:43:32.000000000 +0000
@@ -1,43 +1,60 @@
 /*******************************************************************************
  *
  * Module Name: nsaccess - Top-level functions for accessing ACPI namespace
- *              $Revision: 135 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "amlcode.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "acdispat.h"
+#include <acpi/acpi.h>
+#include <acpi/amlcode.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acdispat.h>
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-	 MODULE_NAME         ("nsaccess")
+	 ACPI_MODULE_NAME    ("nsaccess")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_root_initialize
+ * FUNCTION:    acpi_ns_root_initialize
  *
  * PARAMETERS:  None
  *
@@ -52,42 +69,44 @@
 acpi_status
 acpi_ns_root_initialize (void)
 {
-	acpi_status             status = AE_OK;
-	const predefined_names  *init_val = NULL;
-	acpi_namespace_node     *new_node;
-	acpi_operand_object     *obj_desc;
+	acpi_status                         status;
+	const struct acpi_predefined_names *init_val = NULL;
+	struct acpi_namespace_node          *new_node;
+	union acpi_operand_object           *obj_desc;
+	acpi_string                         val = NULL;
 
 
-	FUNCTION_TRACE ("Ns_root_initialize");
+	ACPI_FUNCTION_TRACE ("ns_root_initialize");
 
 
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	/*
 	 * The global root ptr is initially NULL, so a non-NULL value indicates
-	 * that Acpi_ns_root_initialize() has already been called; just return.
+	 * that acpi_ns_root_initialize() has already been called; just return.
 	 */
 	if (acpi_gbl_root_node) {
 		status = AE_OK;
 		goto unlock_and_exit;
 	}
 
-
 	/*
 	 * Tell the rest of the subsystem that the root is initialized
 	 * (This is OK because the namespace is locked)
 	 */
 	acpi_gbl_root_node = &acpi_gbl_root_node_struct;
 
-
 	/* Enter the pre-defined names in the name table */
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Entering predefined entries into namespace\n"));
+	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+		"Entering predefined entries into namespace\n"));
 
 	for (init_val = acpi_gbl_pre_defined_names; init_val->name; init_val++) {
 		status = acpi_ns_lookup (NULL, init_val->name, init_val->type,
-				 IMODE_LOAD_PASS2, NS_NO_UPSEARCH,
-				 NULL, &new_node);
+				  ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, NULL, &new_node);
 
 		if (ACPI_FAILURE (status) || (!new_node)) /* Must be on same line for code converter */ {
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
@@ -97,10 +116,20 @@
 
 		/*
 		 * Name entered successfully.
-		 * If entry in Pre_defined_names[] specifies an
+		 * If entry in pre_defined_names[] specifies an
 		 * initial value, create the initial value.
 		 */
 		if (init_val->val) {
+			status = acpi_os_predefined_override (init_val, &val);
+			if (ACPI_FAILURE (status)) {
+				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not override predefined %s\n",
+					init_val->name));
+			}
+
+			if (!val) {
+				val = init_val->val;
+			}
+
 			/*
 			 * Entry requests an initial value, allocate a
 			 * descriptor for it.
@@ -116,13 +145,24 @@
 			 * internal representation. Only types actually
 			 * used for initial values are implemented here.
 			 */
-
 			switch (init_val->type) {
+			case ACPI_TYPE_METHOD:
+				obj_desc->method.param_count =
+						(u8) ACPI_STRTOUL (val, NULL, 10);
+				obj_desc->common.flags |= AOPOBJ_DATA_VALID;
+
+#if defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
+
+				/* Compiler cheats by putting parameter count in the owner_iD */
+
+				new_node->owner_id = obj_desc->method.param_count;
+#endif
+				break;
 
 			case ACPI_TYPE_INTEGER:
 
 				obj_desc->integer.value =
-						(acpi_integer) STRTOUL (init_val->val, NULL, 10);
+						(acpi_integer) ACPI_STRTOUL (val, NULL, 10);
 				break;
 
 
@@ -131,25 +171,25 @@
 				/*
 				 * Build an object around the static string
 				 */
-				obj_desc->string.length = STRLEN (init_val->val);
-				obj_desc->string.pointer = init_val->val;
+				obj_desc->string.length = (u32) ACPI_STRLEN (val);
+				obj_desc->string.pointer = val;
 				obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
 				break;
 
 
 			case ACPI_TYPE_MUTEX:
 
+				obj_desc->mutex.node = new_node;
 				obj_desc->mutex.sync_level =
-						 (u16) STRTOUL (init_val->val, NULL, 10);
+						 (u16) ACPI_STRTOUL (val, NULL, 10);
 
-				if (STRCMP (init_val->name, "_GL_") == 0) {
+				if (ACPI_STRCMP (init_val->name, "_GL_") == 0) {
 					/*
 					 * Create a counting semaphore for the
 					 * global lock
 					 */
 					status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT,
 							 1, &obj_desc->mutex.semaphore);
-
 					if (ACPI_FAILURE (status)) {
 						goto unlock_and_exit;
 					}
@@ -160,13 +200,11 @@
 					 */
 					acpi_gbl_global_lock_semaphore = obj_desc->mutex.semaphore;
 				}
-
 				else {
 					/* Create a mutex */
 
 					status = acpi_os_create_semaphore (1, 1,
 							   &obj_desc->mutex.semaphore);
-
 					if (ACPI_FAILURE (status)) {
 						goto unlock_and_exit;
 					}
@@ -175,7 +213,7 @@
 
 
 			default:
-				REPORT_ERROR (("Unsupported initial type value %X\n",
+				ACPI_REPORT_ERROR (("Unsupported initial type value %X\n",
 					init_val->type));
 				acpi_ut_remove_reference (obj_desc);
 				obj_desc = NULL;
@@ -184,7 +222,7 @@
 
 			/* Store pointer to value descriptor in the Node */
 
-			acpi_ns_attach_object (new_node, obj_desc, obj_desc->common.type);
+			status = acpi_ns_attach_object (new_node, obj_desc, ACPI_GET_OBJECT_TYPE (obj_desc));
 
 			/* Remove local reference to the object */
 
@@ -194,23 +232,23 @@
 
 
 unlock_and_exit:
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_lookup
+ * FUNCTION:    acpi_ns_lookup
  *
- * PARAMETERS:  Prefix_node     - Search scope if name is not fully qualified
+ * PARAMETERS:  prefix_node     - Search scope if name is not fully qualified
  *              Pathname        - Search pathname, in internal format
  *                                (as represented in the AML stream)
  *              Type            - Type associated with name
- *              Interpreter_mode - IMODE_LOAD_PASS2 => add name if not found
+ *              interpreter_mode - IMODE_LOAD_PASS2 => add name if not found
  *              Flags           - Flags describing the search restrictions
- *              Walk_state      - Current state of the walk
- *              Return_node     - Where the Node is placed (if found
+ *              walk_state      - Current state of the walk
+ *              return_node     - Where the Node is placed (if found
  *                                or created successfully)
  *
  * RETURN:      Status
@@ -224,44 +262,41 @@
 
 acpi_status
 acpi_ns_lookup (
-	acpi_generic_state      *scope_info,
-	NATIVE_CHAR             *pathname,
-	acpi_object_type8       type,
-	operating_mode          interpreter_mode,
-	u32                     flags,
-	acpi_walk_state         *walk_state,
-	acpi_namespace_node     **return_node)
+	union acpi_generic_state        *scope_info,
+	char                            *pathname,
+	acpi_object_type                type,
+	acpi_interpreter_mode           interpreter_mode,
+	u32                             flags,
+	struct acpi_walk_state          *walk_state,
+	struct acpi_namespace_node      **return_node)
 {
-	acpi_status             status;
-	acpi_namespace_node     *prefix_node;
-	acpi_namespace_node     *current_node = NULL;
-	acpi_namespace_node     *scope_to_push = NULL;
-	acpi_namespace_node     *this_node = NULL;
-	u32                     num_segments;
-	acpi_name               simple_name;
-	u8                      null_name_path = FALSE;
-	acpi_object_type8       type_to_check_for;
-	acpi_object_type8       this_search_type;
-	u32                     local_flags = flags & ~NS_ERROR_IF_FOUND;
-
-	DEBUG_EXEC              (u32 i;)
+	acpi_status                     status;
+	char                            *path = pathname;
+	struct acpi_namespace_node      *prefix_node;
+	struct acpi_namespace_node      *current_node = NULL;
+	struct acpi_namespace_node      *this_node = NULL;
+	u32                             num_segments;
+	u32                             num_carats;
+	acpi_name                       simple_name;
+	acpi_object_type                type_to_check_for;
+	acpi_object_type                this_search_type;
+	u32                             search_parent_flag = ACPI_NS_SEARCH_PARENT;
+	u32                             local_flags = flags & ~(ACPI_NS_ERROR_IF_FOUND |
+			   ACPI_NS_SEARCH_PARENT);
 
 
-	FUNCTION_TRACE ("Ns_lookup");
+	ACPI_FUNCTION_TRACE ("ns_lookup");
 
 
 	if (!return_node) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-
 	acpi_gbl_ns_lookup_count++;
-
-	*return_node = ENTRY_NOT_FOUND;
-
+	*return_node = ACPI_ENTRY_NOT_FOUND;
 
 	if (!acpi_gbl_root_node) {
-		return (AE_NO_NAMESPACE);
+		return_ACPI_STATUS (AE_NO_NAMESPACE);
 	}
 
 	/*
@@ -270,248 +305,273 @@
 	 */
 	if ((!scope_info) ||
 		(!scope_info->scope.node)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Null scope prefix, using root node (%p)\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+			"Null scope prefix, using root node (%p)\n",
 			acpi_gbl_root_node));
 
 		prefix_node = acpi_gbl_root_node;
 	}
 	else {
 		prefix_node = scope_info->scope.node;
-	}
-
-
-	/*
-	 * This check is explicitly split to relax the Type_to_check_for
-	 * conditions for Bank_field_defn. Originally, both Bank_field_defn and
-	 * Def_field_defn caused Type_to_check_for to be set to ACPI_TYPE_REGION,
-	 * but the Bank_field_defn may also check for a Field definition as well
-	 * as an Operation_region.
-	 */
-	if (INTERNAL_TYPE_FIELD_DEFN == type) {
-		/* Def_field_defn defines fields in a Region */
-
-		type_to_check_for = ACPI_TYPE_REGION;
-	}
-
-	else if (INTERNAL_TYPE_BANK_FIELD_DEFN == type) {
-		/* Bank_field_defn defines data fields in a Field Object */
-
-		type_to_check_for = ACPI_TYPE_ANY;
-	}
+		if (ACPI_GET_DESCRIPTOR_TYPE (prefix_node) != ACPI_DESC_TYPE_NAMED) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "[%p] Not a namespace node\n",
+				prefix_node));
+			return_ACPI_STATUS (AE_AML_INTERNAL);
+		}
 
-	else {
-		type_to_check_for = type;
+		/*
+		 * This node might not be a actual "scope" node (such as a
+		 * Device/Method, etc.)  It could be a Package or other object node.
+		 * Backup up the tree to find the containing scope node.
+		 */
+		while (!acpi_ns_opens_scope (prefix_node->type) &&
+				prefix_node->type != ACPI_TYPE_ANY) {
+			prefix_node = acpi_ns_get_parent_node (prefix_node);
+		}
 	}
 
+	/* Save type   TBD: may be no longer necessary */
 
-	/* TBD: [Restructure] - Move the pathname stuff into a new procedure */
-
-	/* Examine the name pointer */
+	type_to_check_for = type;
 
+	/*
+	 * Begin examination of the actual pathname
+	 */
 	if (!pathname) {
-		/*  8-12-98 ASL Grammar Update supports null Name_path  */
+		/* A Null name_path is allowed and refers to the root */
 
-		null_name_path = TRUE;
 		num_segments = 0;
-		this_node = acpi_gbl_root_node;
+		this_node    = acpi_gbl_root_node;
+		path     = "";
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
-			"Null Pathname (Zero segments),  Flags=%x\n", flags));
+			"Null Pathname (Zero segments), Flags=%X\n", flags));
 	}
-
 	else {
 		/*
-		 * Valid name pointer (Internal name format)
+		 * Name pointer is valid (and must be in internal name format)
 		 *
-		 * Check for prefixes.  As represented in the AML stream, a
-		 * Pathname consists of an optional scope prefix followed by
-		 * a segment part.
+		 * Check for scope prefixes:
 		 *
-		 * If present, the scope prefix is either a Root_prefix (in
-		 * which case the name is fully qualified), or zero or more
-		 * Parent_prefixes (in which case the name's scope is relative
-		 * to the current scope).
+		 * As represented in the AML stream, a namepath consists of an
+		 * optional scope prefix followed by a name segment part.
 		 *
-		 * The segment part consists of either:
-		 *  - A single 4-byte name segment, or
-		 *  - A Dual_name_prefix followed by two 4-byte name segments, or
-		 *  - A Multi_name_prefix_op, followed by a byte indicating the
-		 *    number of segments and the segments themselves.
+		 * If present, the scope prefix is either a Root Prefix (in
+		 * which case the name is fully qualified), or one or more
+		 * Parent Prefixes (in which case the name's scope is relative
+		 * to the current scope).
 		 */
-		if (*pathname == AML_ROOT_PREFIX) {
-			/* Pathname is fully qualified, look in root name table */
-
-			current_node = acpi_gbl_root_node;
+		if (*path == (u8) AML_ROOT_PREFIX) {
+			/* Pathname is fully qualified, start from the root */
 
-			/* point to segment part */
+			this_node = acpi_gbl_root_node;
+			search_parent_flag = ACPI_NS_NO_UPSEARCH;
 
-			pathname++;
+			/* Point to name segment part */
 
-			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching from root [%p]\n",
-				current_node));
+			path++;
 
-			/* Direct reference to root, "\" */
-
-			if (!(*pathname)) {
-				this_node = acpi_gbl_root_node;
-				goto check_for_new_scope_and_exit;
-			}
+			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+				"Path is absolute from root [%p]\n", this_node));
 		}
-
 		else {
 			/* Pathname is relative to current scope, start there */
 
-			current_node = prefix_node;
-
-			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching relative to pfx scope [%p]\n",
-				prefix_node));
+			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+				"Searching relative to prefix scope [%4.4s] (%p)\n",
+				prefix_node->name.ascii, prefix_node));
 
 			/*
-			 * Handle up-prefix (carat).  More than one prefix
-			 * is supported
+			 * Handle multiple Parent Prefixes (carat) by just getting
+			 * the parent node for each prefix instance.
 			 */
-			while (*pathname == AML_PARENT_PREFIX) {
-				/* Point to segment part or next Parent_prefix */
+			this_node = prefix_node;
+			num_carats = 0;
+			while (*path == (u8) AML_PARENT_PREFIX) {
+				/* Name is fully qualified, no search rules apply */
 
-				pathname++;
+				search_parent_flag = ACPI_NS_NO_UPSEARCH;
+				/*
+				 * Point past this prefix to the name segment
+				 * part or the next Parent Prefix
+				 */
+				path++;
 
-				/*  Backup to the parent's scope  */
+				/* Backup to the parent node */
 
-				this_node = acpi_ns_get_parent_object (current_node);
+				num_carats++;
+				this_node = acpi_ns_get_parent_node (this_node);
 				if (!this_node) {
 					/* Current scope has no parent scope */
 
-					REPORT_ERROR (
-						("Too many parent prefixes (^) - reached root\n"));
+					ACPI_REPORT_ERROR (
+						("ACPI path has too many parent prefixes (^) - reached beyond root node\n"));
 					return_ACPI_STATUS (AE_NOT_FOUND);
 				}
+			}
 
-				current_node = this_node;
+			if (search_parent_flag == ACPI_NS_NO_UPSEARCH) {
+				ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+					"Search scope is [%4.4s], path has %d carat(s)\n",
+					this_node->name.ascii, num_carats));
 			}
 		}
 
-
 		/*
-		 * Examine the name prefix opcode, if any,
-		 * to determine the number of segments
+		 * Determine the number of ACPI name segments in this pathname.
+		 *
+		 * The segment part consists of either:
+		 *  - A Null name segment (0)
+		 *  - A dual_name_prefix followed by two 4-byte name segments
+		 *  - A multi_name_prefix followed by a byte indicating the
+		 *      number of segments and the segments themselves.
+		 *  - A single 4-byte name segment
+		 *
+		 * Examine the name prefix opcode, if any, to determine the number of
+		 * segments.
 		 */
-		if (*pathname == AML_DUAL_NAME_PREFIX) {
-			num_segments = 2;
+		switch (*path) {
+		case 0:
+			/*
+			 * Null name after a root or parent prefixes. We already
+			 * have the correct target node and there are no name segments.
+			 */
+			num_segments = 0;
+			type = this_node->type;
+
+			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+				"Prefix-only Pathname (Zero name segments), Flags=%X\n", flags));
+			break;
+
+		case AML_DUAL_NAME_PREFIX:
+
+			/* More than one name_seg, search rules do not apply */
 
-			/* point to first segment */
+			search_parent_flag = ACPI_NS_NO_UPSEARCH;
 
-			pathname++;
+			/* Two segments, point to first name segment */
+
+			num_segments = 2;
+			path++;
 
 			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
 				"Dual Pathname (2 segments, Flags=%X)\n", flags));
-		}
+			break;
+
+		case AML_MULTI_NAME_PREFIX_OP:
 
-		else if (*pathname == AML_MULTI_NAME_PREFIX_OP) {
-			num_segments = (u32)* (u8 *) ++pathname;
+			/* More than one name_seg, search rules do not apply */
 
-			/* point to first segment */
+			search_parent_flag = ACPI_NS_NO_UPSEARCH;
 
-			pathname++;
+			/* Extract segment count, point to first name segment */
+
+			path++;
+			num_segments = (u32) (u8) *path;
+			path++;
 
 			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
 				"Multi Pathname (%d Segments, Flags=%X) \n",
 				num_segments, flags));
-		}
+			break;
 
-		else {
+		default:
 			/*
-			 * No Dual or Multi prefix, hence there is only one
-			 * segment and Pathname is already pointing to it.
+			 * Not a Null name, no Dual or Multi prefix, hence there is
+			 * only one name segment and Pathname is already pointing to it.
 			 */
 			num_segments = 1;
 
 			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
 				"Simple Pathname (1 segment, Flags=%X)\n", flags));
+			break;
 		}
 
-#ifdef ACPI_DEBUG
-
-		/* TBD: [Restructure] Make this a procedure */
-
-		/* Debug only: print the entire name that we are about to lookup */
-
-		ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
-
-		for (i = 0; i < num_segments; i++) {
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_NAMES, "%4.4s/", (char*)&pathname[i * 4]));
-		}
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_NAMES, "]\n"));
-#endif
+		ACPI_DEBUG_EXEC (acpi_ns_print_pathname (num_segments, path));
 	}
 
 
 	/*
-	 * Search namespace for each segment of the name.
-	 * Loop through and verify/add each name segment.
+	 * Search namespace for each segment of the name.  Loop through and
+	 * verify (or add to the namespace) each name segment.
+	 *
+	 * The object type is significant only at the last name
+	 * segment.  (We don't care about the types along the path, only
+	 * the type of the final target object.)
 	 */
-	while (num_segments-- && current_node) {
-		/*
-		 * Search for the current name segment under the current
-		 * named object.  The Type is significant only at the last (topmost)
-		 * level.  (We don't care about the types along the path, only
-		 * the type of the final target object.)
-		 */
-		this_search_type = ACPI_TYPE_ANY;
+	this_search_type = ACPI_TYPE_ANY;
+	current_node = this_node;
+	while (num_segments && current_node) {
+		num_segments--;
 		if (!num_segments) {
+			/*
+			 * This is the last segment, enable typechecking
+			 */
 			this_search_type = type;
-			local_flags = flags;
-		}
 
-		/* Pluck one ACPI name from the front of the pathname */
+			/*
+			 * Only allow automatic parent search (search rules) if the caller
+			 * requested it AND we have a single, non-fully-qualified name_seg
+			 */
+			if ((search_parent_flag != ACPI_NS_NO_UPSEARCH) &&
+				(flags & ACPI_NS_SEARCH_PARENT)) {
+				local_flags |= ACPI_NS_SEARCH_PARENT;
+			}
+
+			/* Set error flag according to caller */
 
-		MOVE_UNALIGNED32_TO_32 (&simple_name, pathname);
+			if (flags & ACPI_NS_ERROR_IF_FOUND) {
+				local_flags |= ACPI_NS_ERROR_IF_FOUND;
+			}
+		}
 
-		/* Try to find the ACPI name */
+		/* Extract one ACPI name from the front of the pathname */
 
-		status = acpi_ns_search_and_enter (simple_name, walk_state,
-				   current_node, interpreter_mode,
-				   this_search_type, local_flags,
-				   &this_node);
+		ACPI_MOVE_32_TO_32 (&simple_name, path);
 
+		/* 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);
 		if (ACPI_FAILURE (status)) {
 			if (status == AE_NOT_FOUND) {
-				/* Name not found in ACPI namespace  */
+				/* Name not found in ACPI namespace */
 
 				ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
-					"Name [%4.4s] not found in scope %p\n",
-					(char*)&simple_name, current_node));
+					"Name [%4.4s] not found in scope [%4.4s] %p\n",
+					(char *) &simple_name, (char *) &current_node->name,
+					current_node));
 			}
 
+			*return_node = this_node;
 			return_ACPI_STATUS (status);
 		}
 
-
 		/*
-		 * If 1) This is the last segment (Num_segments == 0)
-		 *    2) and looking for a specific type
+		 * Sanity typecheck of the target object:
+		 *
+		 * If 1) This is the last segment (num_segments == 0)
+		 *    2) And we are looking for a specific type
 		 *       (Not checking for TYPE_ANY)
 		 *    3) Which is not an alias
-		 *    4) which is not a local type (TYPE_DEF_ANY)
-		 *    5) which is not a local type (TYPE_SCOPE)
-		 *    6) which is not a local type (TYPE_INDEX_FIELD_DEFN)
-		 *    7) and type of object is known (not TYPE_ANY)
-		 *    8) and object does not match request
+		 *    4) Which is not a local type (TYPE_SCOPE)
+		 *    5) And the type of target object is known (not TYPE_ANY)
+		 *    6) And target object does not match what we are looking for
 		 *
 		 * Then we have a type mismatch.  Just warn and ignore it.
 		 */
 		if ((num_segments       == 0)                               &&
 			(type_to_check_for  != ACPI_TYPE_ANY)                   &&
-			(type_to_check_for  != INTERNAL_TYPE_ALIAS)             &&
-			(type_to_check_for  != INTERNAL_TYPE_DEF_ANY)           &&
-			(type_to_check_for  != INTERNAL_TYPE_SCOPE)             &&
-			(type_to_check_for  != INTERNAL_TYPE_INDEX_FIELD_DEFN)  &&
+			(type_to_check_for  != ACPI_TYPE_LOCAL_ALIAS)           &&
+			(type_to_check_for  != ACPI_TYPE_LOCAL_SCOPE)           &&
 			(this_node->type    != ACPI_TYPE_ANY)                   &&
 			(this_node->type    != type_to_check_for)) {
 			/* Complain about a type mismatch */
 
-			REPORT_WARNING (
-				("Ns_lookup: %4.4s, type %X, checking for type %X\n",
-				(char*)&simple_name, this_node->type, type_to_check_for));
+			ACPI_REPORT_WARNING (
+				("ns_lookup: Type mismatch on %4.4s (%s), searching for (%s)\n",
+				(char *) &simple_name, acpi_ut_get_type_name (this_node->type),
+				acpi_ut_get_type_name (type_to_check_for)));
 		}
 
 		/*
@@ -519,57 +579,29 @@
 		 * specific type, but the type of found object is known, use that type
 		 * to see if it opens a scope.
 		 */
-		if ((0 == num_segments) && (ACPI_TYPE_ANY == type)) {
+		if ((num_segments == 0) && (type == ACPI_TYPE_ANY)) {
 			type = this_node->type;
 		}
 
-		if ((num_segments || acpi_ns_opens_scope (type)) &&
-			(this_node->child == NULL)) {
-			/*
-			 * More segments or the type implies enclosed scope,
-			 * and the next scope has not been allocated.
-			 */
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Load mode=%X  This_node=%p\n",
-				interpreter_mode, this_node));
-		}
+		/* Point to next name segment and make this node current */
 
+		path += ACPI_NAME_SIZE;
 		current_node = this_node;
-
-		/* point to next name segment */
-
-		pathname += ACPI_NAME_SIZE;
 	}
 
-
 	/*
 	 * Always check if we need to open a new scope
 	 */
-check_for_new_scope_and_exit:
-
-	if (!(flags & NS_DONT_OPEN_SCOPE) && (walk_state)) {
+	if (!(flags & ACPI_NS_DONT_OPEN_SCOPE) && (walk_state)) {
 		/*
-		 * If entry is a type which opens a scope,
-		 * push the new scope on the scope stack.
+		 * If entry is a type which opens a scope, push the new scope on the
+		 * scope stack.
 		 */
-		if (acpi_ns_opens_scope (type_to_check_for)) {
-			/*  8-12-98 ASL Grammar Update supports null Name_path  */
-
-			if (null_name_path) {
-				/* TBD: [Investigate] - is this the correct thing to do? */
-
-				scope_to_push = NULL;
-			}
-			else {
-				scope_to_push = this_node;
-			}
-
-			status = acpi_ds_scope_stack_push (scope_to_push, type,
-					   walk_state);
+		if (acpi_ns_opens_scope (type)) {
+			status = acpi_ds_scope_stack_push (this_node, type, walk_state);
 			if (ACPI_FAILURE (status)) {
 				return_ACPI_STATUS (status);
 			}
-
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Set global scope to %p\n", scope_to_push));
 		}
 	}
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/namespace/nsalloc.c linux-2.4.22-pre2/drivers/acpi/namespace/nsalloc.c
--- linux-2.4.21/drivers/acpi/namespace/nsalloc.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/namespace/nsalloc.c	2003-06-26 21:43:22.000000000 +0000
@@ -1,43 +1,60 @@
 /*******************************************************************************
  *
  * Module Name: nsalloc - Namespace allocation and deletion utilities
- *              $Revision: 60 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acnamesp.h"
-#include "acinterp.h"
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-	 MODULE_NAME         ("nsalloc")
+	 ACPI_MODULE_NAME    ("nsalloc")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_create_node
+ * FUNCTION:    acpi_ns_create_node
  *
- * PARAMETERS:  Acpi_name       - Name of the new node
+ * PARAMETERS:  acpi_name       - Name of the new node
  *
  * RETURN:      None
  *
@@ -45,26 +62,26 @@
  *
  ******************************************************************************/
 
-acpi_namespace_node *
+struct acpi_namespace_node *
 acpi_ns_create_node (
-	u32                     name)
+	u32                             name)
 {
-	acpi_namespace_node     *node;
+	struct acpi_namespace_node      *node;
 
 
-	FUNCTION_TRACE ("Ns_create_node");
+	ACPI_FUNCTION_TRACE ("ns_create_node");
 
 
-	node = ACPI_MEM_CALLOCATE (sizeof (acpi_namespace_node));
+	node = ACPI_MEM_CALLOCATE (sizeof (struct acpi_namespace_node));
 	if (!node) {
 		return_PTR (NULL);
 	}
 
 	ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_allocated++);
 
-	node->data_type      = ACPI_DESC_TYPE_NAMED;
-	node->name           = name;
+	node->name.integer   = name;
 	node->reference_count = 1;
+	ACPI_SET_DESCRIPTOR_TYPE (node, ACPI_DESC_TYPE_NAMED);
 
 	return_PTR (node);
 }
@@ -72,7 +89,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_delete_node
+ * FUNCTION:    acpi_ns_delete_node
  *
  * PARAMETERS:  Node            - Node to be deleted
  *
@@ -84,78 +101,150 @@
 
 void
 acpi_ns_delete_node (
-	acpi_namespace_node     *node)
+	struct acpi_namespace_node      *node)
 {
-	acpi_namespace_node     *parent_node;
-	acpi_namespace_node     *prev_node;
-	acpi_namespace_node     *next_node;
+	struct acpi_namespace_node      *parent_node;
+	struct acpi_namespace_node      *prev_node;
+	struct acpi_namespace_node      *next_node;
 
 
-	FUNCTION_TRACE_PTR ("Ns_delete_node", node);
+	ACPI_FUNCTION_TRACE_PTR ("ns_delete_node", node);
 
 
-	parent_node = acpi_ns_get_parent_object (node);
+	parent_node = acpi_ns_get_parent_node (node);
 
 	prev_node = NULL;
 	next_node = parent_node->child;
 
+	/* Find the node that is the previous peer in the parent's child list */
+
 	while (next_node != node) {
 		prev_node = next_node;
 		next_node = prev_node->peer;
 	}
 
 	if (prev_node) {
+		/* Node is not first child, unlink it */
+
 		prev_node->peer = next_node->peer;
 		if (next_node->flags & ANOBJ_END_OF_PEER_LIST) {
 			prev_node->flags |= ANOBJ_END_OF_PEER_LIST;
 		}
 	}
 	else {
-		parent_node->child = next_node->peer;
+		/* Node is first child (has no previous peer) */
+
+		if (next_node->flags & ANOBJ_END_OF_PEER_LIST) {
+			/* No peers at all */
+
+			parent_node->child = NULL;
+		}
+		else {   /* Link peer list to parent */
+
+			parent_node->child = next_node->peer;
+		}
 	}
 
 
 	ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++);
 
 	/*
-	 * Detach an object if there is one
+	 * Detach an object if there is one then delete the node
 	 */
-	if (node->object) {
-		acpi_ns_detach_object (node);
-	}
-
+	acpi_ns_detach_object (node);
 	ACPI_MEM_FREE (node);
 	return_VOID;
 }
 
 
+#ifdef ACPI_ALPHABETIC_NAMESPACE
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_compare_names
+ *
+ * PARAMETERS:  Name1           - First name to compare
+ *              Name2           - Second name to compare
+ *
+ * RETURN:      value from strncmp
+ *
+ * DESCRIPTION: Compare two ACPI names.  Names that are prefixed with an
+ *              underscore are forced to be alphabetically first.
+ *
+ ******************************************************************************/
+
+int
+acpi_ns_compare_names (
+	char                            *name1,
+	char                            *name2)
+{
+	char                            reversed_name1[ACPI_NAME_SIZE];
+	char                            reversed_name2[ACPI_NAME_SIZE];
+	u32                             i;
+	u32                             j;
+
+
+	/*
+	 * Replace all instances of "underscore" with a value that is smaller so
+	 * that all names that are prefixed with underscore(s) are alphabetically
+	 * first.
+	 *
+	 * Reverse the name bytewise so we can just do a 32-bit compare instead
+	 * of a strncmp.
+	 */
+	for (i = 0, j= (ACPI_NAME_SIZE - 1); i < ACPI_NAME_SIZE; i++, j--) {
+		reversed_name1[j] = name1[i];
+		if (name1[i] == '_') {
+			reversed_name1[j] = '*';
+		}
+
+		reversed_name2[j] = name2[i];
+		if (name2[i] == '_') {
+			reversed_name2[j] = '*';
+		}
+	}
+
+	return (*(int *) reversed_name1 - *(int *) reversed_name2);
+}
+#endif
+
+
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_install_node
+ * FUNCTION:    acpi_ns_install_node
  *
- * PARAMETERS:  Walk_state      - Current state of the walk
- *              Parent_node     - The parent of the new Node
+ * PARAMETERS:  walk_state      - Current state of the walk
+ *              parent_node     - The parent of the new Node
  *              Node            - The new Node to install
  *              Type            - ACPI object type of the new Node
  *
  * RETURN:      None
  *
- * DESCRIPTION: Initialize a new entry within a namespace table.
+ * DESCRIPTION: Initialize a new namespace node and install it amongst
+ *              its peers.
+ *
+ *              Note: Current namespace lookup is linear search.  However, the
+ *              nodes are linked in alphabetical order to 1) put all reserved
+ *              names (start with underscore) first, and to 2) make a readable
+ *              namespace dump.
  *
  ******************************************************************************/
 
 void
 acpi_ns_install_node (
-	acpi_walk_state         *walk_state,
-	acpi_namespace_node     *parent_node,   /* Parent */
-	acpi_namespace_node     *node,          /* New Child*/
-	acpi_object_type8       type)
+	struct acpi_walk_state          *walk_state,
+	struct acpi_namespace_node      *parent_node,   /* Parent */
+	struct acpi_namespace_node      *node,          /* New Child*/
+	acpi_object_type                type)
 {
-	u16                     owner_id = TABLE_ID_DSDT;
-	acpi_namespace_node     *child_node;
+	u16                             owner_id = 0;
+	struct acpi_namespace_node      *child_node;
+#ifdef ACPI_ALPHABETIC_NAMESPACE
+
+	struct acpi_namespace_node      *previous_child_node;
+#endif
 
 
-	FUNCTION_TRACE ("Ns_install_node");
+	ACPI_FUNCTION_TRACE ("ns_install_node");
 
 
 	/*
@@ -167,17 +256,65 @@
 		owner_id = walk_state->owner_id;
 	}
 
-
-	/* link the new entry into the parent and existing children */
-
-	/* TBD: Could be first, last, or alphabetic */
+	/* Link the new entry into the parent and existing children */
 
 	child_node = parent_node->child;
 	if (!child_node) {
 		parent_node->child = node;
+		node->flags |= ANOBJ_END_OF_PEER_LIST;
+		node->peer = parent_node;
 	}
-
 	else {
+#ifdef ACPI_ALPHABETIC_NAMESPACE
+		/*
+		 * Walk the list whilst searching for the the correct
+		 * alphabetic placement.
+		 */
+		previous_child_node = NULL;
+		while (acpi_ns_compare_names (child_node->name.ascii, node->name.ascii) < 0) {
+			if (child_node->flags & ANOBJ_END_OF_PEER_LIST) {
+				/* Last peer;  Clear end-of-list flag */
+
+				child_node->flags &= ~ANOBJ_END_OF_PEER_LIST;
+
+				/* This node is the new peer to the child node */
+
+				child_node->peer = node;
+
+				/* This node is the new end-of-list */
+
+				node->flags |= ANOBJ_END_OF_PEER_LIST;
+				node->peer = parent_node;
+				break;
+			}
+
+			/* Get next peer */
+
+			previous_child_node = child_node;
+			child_node = child_node->peer;
+		}
+
+		/* Did the node get inserted at the end-of-list? */
+
+		if (!(node->flags & ANOBJ_END_OF_PEER_LIST)) {
+			/*
+			 * Loop above terminated without reaching the end-of-list.
+			 * Insert the new node at the current location
+			 */
+			if (previous_child_node) {
+				/* Insert node alphabetically */
+
+				node->peer = child_node;
+				previous_child_node->peer = node;
+			}
+			else {
+				/* Insert node alphabetically at start of list */
+
+				node->peer = child_node;
+				parent_node->child = node;
+			}
+		}
+#else
 		while (!(child_node->flags & ANOBJ_END_OF_PEER_LIST)) {
 			child_node = child_node->peer;
 		}
@@ -187,61 +324,25 @@
 		/* Clear end-of-list flag */
 
 		child_node->flags &= ~ANOBJ_END_OF_PEER_LIST;
+		node->flags     |= ANOBJ_END_OF_PEER_LIST;
+		node->peer = parent_node;
+#endif
 	}
 
 	/* Init the new entry */
 
-	node->owner_id  = owner_id;
-	node->flags     |= ANOBJ_END_OF_PEER_LIST;
-	node->peer      = parent_node;
-
-
-	/*
-	 * If adding a name with unknown type, or having to
-	 * add the region in order to define fields in it, we
-	 * have a forward reference.
-	 */
-	if ((ACPI_TYPE_ANY == type) ||
-		(INTERNAL_TYPE_FIELD_DEFN == type) ||
-		(INTERNAL_TYPE_BANK_FIELD_DEFN == type)) {
-		/*
-		 * We don't want to abort here, however!
-		 * We will fill in the actual type when the
-		 * real definition is found later.
-		 */
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "[%4.4s] is a forward reference\n",
-			(char*)&node->name));
-	}
-
-	/*
-	 * The Def_field_defn and Bank_field_defn cases are actually
-	 * looking up the Region in which the field will be defined
-	 */
-	if ((INTERNAL_TYPE_FIELD_DEFN == type) ||
-		(INTERNAL_TYPE_BANK_FIELD_DEFN == type)) {
-		type = ACPI_TYPE_REGION;
-	}
-
-	/*
-	 * Scope, Def_any, and Index_field_defn are bogus "types" which do
-	 * not actually have anything to do with the type of the name
-	 * being looked up.  Save any other value of Type as the type of
-	 * the entry.
-	 */
-	if ((type != INTERNAL_TYPE_SCOPE) &&
-		(type != INTERNAL_TYPE_DEF_ANY) &&
-		(type != INTERNAL_TYPE_INDEX_FIELD_DEFN)) {
-		node->type = (u8) type;
-	}
+	node->owner_id = owner_id;
+	node->type = (u8) type;
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%4.4s added to %p at %p\n",
-		(char*)&node->name, parent_node, node));
+	ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%4.4s (%s) added to %4.4s (%s) %p at %p\n",
+		node->name.ascii, acpi_ut_get_type_name (node->type),
+		parent_node->name.ascii, acpi_ut_get_type_name (parent_node->type), parent_node, node));
 
 	/*
 	 * Increment the reference count(s) of all parents up to
 	 * the root!
 	 */
-	while ((node = acpi_ns_get_parent_object (node)) != NULL) {
+	while ((node = acpi_ns_get_parent_node (node)) != NULL) {
 		node->reference_count++;
 	}
 
@@ -251,27 +352,28 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_delete_children
+ * FUNCTION:    acpi_ns_delete_children
  *
- * PARAMETERS:  Parent_node     - Delete this objects children
+ * PARAMETERS:  parent_node     - Delete this objects children
  *
  * RETURN:      None.
  *
- * DESCRIPTION: Delete all children of the parent object. Deletes a
- *              "scope".
+ * DESCRIPTION: Delete all children of the parent object. In other words,
+ *              deletes a "scope".
  *
  ******************************************************************************/
 
 void
 acpi_ns_delete_children (
-	acpi_namespace_node     *parent_node)
+	struct acpi_namespace_node      *parent_node)
 {
-	acpi_namespace_node     *child_node;
-	acpi_namespace_node     *next_node;
-	u8                      flags;
+	struct acpi_namespace_node      *child_node;
+	struct acpi_namespace_node      *next_node;
+	struct acpi_namespace_node      *node;
+	u8                              flags;
 
 
-	FUNCTION_TRACE_PTR ("Ns_delete_children", parent_node);
+	ACPI_FUNCTION_TRACE_PTR ("ns_delete_children", parent_node);
 
 
 	if (!parent_node) {
@@ -305,13 +407,32 @@
 
 		ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++);
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Object %p, Remaining %X\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p, Remaining %X\n",
 			child_node, acpi_gbl_current_node_count));
 
 		/*
 		 * Detach an object if there is one, then free the child node
 		 */
 		acpi_ns_detach_object (child_node);
+
+		/*
+		 * Decrement the reference count(s) of all parents up to
+		 * the root! (counts were incremented when the node was created)
+		 */
+		node = child_node;
+		while ((node = acpi_ns_get_parent_node (node)) != NULL) {
+			node->reference_count--;
+		}
+
+		/* There should be only one reference remaining on this node */
+
+		if (child_node->reference_count != 1) {
+			ACPI_REPORT_WARNING (("Existing references (%d) on node being deleted (%p)\n",
+				child_node->reference_count, child_node));
+		}
+
+		/* Now we can delete the node */
+
 		ACPI_MEM_FREE (child_node);
 
 		/* And move on to the next child in the list */
@@ -331,30 +452,30 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_delete_namespace_subtree
+ * FUNCTION:    acpi_ns_delete_namespace_subtree
  *
- * PARAMETERS:  Parent_node     - Root of the subtree to be deleted
+ * PARAMETERS:  parent_node     - Root of the subtree to be deleted
  *
  * RETURN:      None.
  *
  * DESCRIPTION: Delete a subtree of the namespace.  This includes all objects
- *              stored within the subtree.  Scope tables are deleted also
+ *              stored within the subtree.
  *
  ******************************************************************************/
 
-acpi_status
+void
 acpi_ns_delete_namespace_subtree (
-	acpi_namespace_node     *parent_node)
+	struct acpi_namespace_node      *parent_node)
 {
-	acpi_namespace_node     *child_node = NULL;
-	u32                     level = 1;
+	struct acpi_namespace_node      *child_node = NULL;
+	u32                             level = 1;
 
 
-	FUNCTION_TRACE ("Ns_delete_namespace_subtree");
+	ACPI_FUNCTION_TRACE ("ns_delete_namespace_subtree");
 
 
 	if (!parent_node) {
-		return_ACPI_STATUS (AE_OK);
+		return_VOID;
 	}
 
 	/*
@@ -383,7 +504,6 @@
 				child_node    = 0;
 			}
 		}
-
 		else {
 			/*
 			 * No more children of this parent node.
@@ -403,17 +523,17 @@
 
 			/* Move up the tree to the grandparent */
 
-			parent_node = acpi_ns_get_parent_object (parent_node);
+			parent_node = acpi_ns_get_parent_node (parent_node);
 		}
 	}
 
-	return_ACPI_STATUS (AE_OK);
+	return_VOID;
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_remove_reference
+ * FUNCTION:    acpi_ns_remove_reference
  *
  * PARAMETERS:  Node           - Named node whose reference count is to be
  *                               decremented
@@ -426,47 +546,50 @@
  *
  ******************************************************************************/
 
-static void
+void
 acpi_ns_remove_reference (
-	acpi_namespace_node     *node)
+	struct acpi_namespace_node      *node)
 {
-	acpi_namespace_node     *next_node;
+	struct acpi_namespace_node      *parent_node;
+	struct acpi_namespace_node      *this_node;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/*
 	 * Decrement the reference count(s) of this node and all
 	 * nodes up to the root,  Delete anything with zero remaining references.
 	 */
-	next_node = node;
-	while (next_node) {
-		/* Decrement the reference count on this node*/
+	this_node = node;
+	while (this_node) {
+		/* Prepare to move up to parent */
+
+		parent_node = acpi_ns_get_parent_node (this_node);
+
+		/* Decrement the reference count on this node */
 
-		next_node->reference_count--;
+		this_node->reference_count--;
 
 		/* Delete the node if no more references */
 
-		if (!next_node->reference_count) {
+		if (!this_node->reference_count) {
 			/* Delete all children and delete the node */
 
-			acpi_ns_delete_children (next_node);
-			acpi_ns_delete_node (next_node);
+			acpi_ns_delete_children (this_node);
+			acpi_ns_delete_node (this_node);
 		}
 
-		/* Move up to parent */
-
-		next_node = acpi_ns_get_parent_object (next_node);
+		this_node = parent_node;
 	}
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_delete_namespace_by_owner
+ * FUNCTION:    acpi_ns_delete_namespace_by_owner
  *
- * PARAMETERS:  Owner_id    - All nodes with this owner will be deleted
+ * PARAMETERS:  owner_id    - All nodes with this owner will be deleted
  *
  * RETURN:      Status
  *
@@ -476,65 +599,71 @@
  *
  ******************************************************************************/
 
-acpi_status
+void
 acpi_ns_delete_namespace_by_owner (
-	u16                     owner_id)
+	u16                             owner_id)
 {
-	acpi_namespace_node     *child_node;
-	u32                     level;
-	acpi_namespace_node     *parent_node;
+	struct acpi_namespace_node      *child_node;
+	struct acpi_namespace_node      *deletion_node;
+	u32                             level;
+	struct acpi_namespace_node      *parent_node;
 
 
-	FUNCTION_TRACE ("Ns_delete_namespace_by_owner");
+	ACPI_FUNCTION_TRACE_U32 ("ns_delete_namespace_by_owner", owner_id);
 
 
-	parent_node = acpi_gbl_root_node;
-	child_node  = 0;
-	level       = 1;
+	parent_node   = acpi_gbl_root_node;
+	child_node    = NULL;
+	deletion_node = NULL;
+	level         = 1;
 
 	/*
 	 * Traverse the tree of nodes until we bubble back up
 	 * to where we started.
 	 */
 	while (level > 0) {
-		/* Get the next node in this scope (NULL if none) */
+		/*
+		 * Get the next child of this parent node. When child_node is NULL,
+		 * the first child of the parent is returned
+		 */
+		child_node = acpi_ns_get_next_node (ACPI_TYPE_ANY, parent_node, child_node);
+
+		if (deletion_node) {
+			acpi_ns_remove_reference (deletion_node);
+			deletion_node = NULL;
+		}
 
-		child_node = acpi_ns_get_next_node (ACPI_TYPE_ANY, parent_node,
-				 child_node);
 		if (child_node) {
 			if (child_node->owner_id == owner_id) {
-				/* Found a child node - detach any attached object */
+				/* Found a matching child node - detach any attached object */
 
 				acpi_ns_detach_object (child_node);
 			}
 
 			/* Check if this node has any children */
 
-			if (acpi_ns_get_next_node (ACPI_TYPE_ANY, child_node, 0)) {
+			if (acpi_ns_get_next_node (ACPI_TYPE_ANY, child_node, NULL)) {
 				/*
 				 * There is at least one child of this node,
 				 * visit the node
 				 */
 				level++;
 				parent_node   = child_node;
-				child_node    = 0;
+				child_node    = NULL;
 			}
-
 			else if (child_node->owner_id == owner_id) {
-				acpi_ns_remove_reference (child_node);
+				deletion_node = child_node;
 			}
 		}
-
 		else {
 			/*
 			 * No more children of this parent node.
 			 * Move up to the grandparent.
 			 */
 			level--;
-
 			if (level != 0) {
 				if (parent_node->owner_id == owner_id) {
-					acpi_ns_remove_reference (parent_node);
+					deletion_node = parent_node;
 				}
 			}
 
@@ -544,11 +673,11 @@
 
 			/* Move up the tree to the grandparent */
 
-			parent_node = acpi_ns_get_parent_object (parent_node);
+			parent_node = acpi_ns_get_parent_node (parent_node);
 		}
 	}
 
-	return_ACPI_STATUS (AE_OK);
+	return_VOID;
 }
 
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/namespace/nsdump.c linux-2.4.22-pre2/drivers/acpi/namespace/nsdump.c
--- linux-2.4.21/drivers/acpi/namespace/nsdump.c	2002-11-28 23:53:12.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/namespace/nsdump.c	2003-06-26 21:43:32.000000000 +0000
@@ -1,45 +1,102 @@
 /******************************************************************************
  *
  * Module Name: nsdump - table dumping routines for debug
- *              $Revision: 105 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "actables.h"
-#include "acparser.h"
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acparser.h>
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-	 MODULE_NAME         ("nsdump")
+	 ACPI_MODULE_NAME    ("nsdump")
 
+#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
 
-#if defined(ACPI_DEBUG) || defined(ENABLE_DEBUGGER)
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_dump_pathname
+ * FUNCTION:    acpi_ns_print_pathname
+ *
+ * PARAMETERS:  num_segment         - Number of ACPI name segments
+ *              Pathname            - The compressed (internal) path
+ *
+ * DESCRIPTION: Print an object's full namespace pathname
+ *
+ ******************************************************************************/
+
+void
+acpi_ns_print_pathname (
+	u32                             num_segments,
+	char                            *pathname)
+{
+	ACPI_FUNCTION_NAME ("ns_print_pathname");
+
+
+	if (!(acpi_dbg_level & ACPI_LV_NAMES) || !(acpi_dbg_layer & ACPI_NAMESPACE)) {
+		return;
+	}
+
+		/* Print the entire name */
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
+
+	while (num_segments) {
+		acpi_os_printf ("%4.4s", pathname);
+		pathname += ACPI_NAME_SIZE;
+
+		num_segments--;
+		if (num_segments) {
+			acpi_os_printf (".");
+		}
+	}
+
+	acpi_os_printf ("]\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_dump_pathname
  *
  * PARAMETERS:  Handle              - Object
  *              Msg                 - Prefix message
@@ -51,85 +108,65 @@
  *
  ******************************************************************************/
 
-acpi_status
+void
 acpi_ns_dump_pathname (
-	acpi_handle             handle,
-	NATIVE_CHAR             *msg,
-	u32                     level,
-	u32                     component)
+	acpi_handle                     handle,
+	char                            *msg,
+	u32                             level,
+	u32                             component)
 {
-	NATIVE_CHAR             *buffer;
-	u32                     length;
-
 
-	FUNCTION_TRACE ("Ns_dump_pathname");
+	ACPI_FUNCTION_TRACE ("ns_dump_pathname");
 
 
 	/* Do this only if the requested debug level and component are enabled */
 
 	if (!(acpi_dbg_level & level) || !(acpi_dbg_layer & component)) {
-		return_ACPI_STATUS (AE_OK);
-	}
-
-	buffer = ACPI_MEM_ALLOCATE (PATHNAME_MAX);
-	if (!buffer) {
-		return_ACPI_STATUS (AE_NO_MEMORY);
+		return_VOID;
 	}
 
 	/* Convert handle to a full pathname and print it (with supplied message) */
 
-	length = PATHNAME_MAX;
-	if (ACPI_SUCCESS (acpi_ns_handle_to_pathname (handle, &length, buffer))) {
-		acpi_os_printf ("%s %s (%p)\n", msg, buffer, handle);
-	}
-
-	ACPI_MEM_FREE (buffer);
-
-	return_ACPI_STATUS (AE_OK);
+	acpi_ns_print_node_pathname (handle, msg);
+	acpi_os_printf ("\n");
+	return_VOID;
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_dump_one_object
+ * FUNCTION:    acpi_ns_dump_one_object
  *
  * PARAMETERS:  Handle              - Node to be dumped
  *              Level               - Nesting level of the handle
- *              Context             - Passed into Walk_namespace
+ *              Context             - Passed into walk_namespace
  *
  * DESCRIPTION: Dump a single Node
- *              This procedure is a User_function called by Acpi_ns_walk_namespace.
+ *              This procedure is a user_function called by acpi_ns_walk_namespace.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ns_dump_one_object (
-	acpi_handle             obj_handle,
-	u32                     level,
-	void                    *context,
-	void                    **return_value)
+	acpi_handle                     obj_handle,
+	u32                             level,
+	void                            *context,
+	void                            **return_value)
 {
-	acpi_walk_info          *info = (acpi_walk_info *) context;
-	acpi_namespace_node     *this_node;
-	acpi_operand_object     *obj_desc = NULL;
-	acpi_object_type8       obj_type;
-	acpi_object_type8       type;
-	u32                     bytes_to_dump;
-	u32                     downstream_sibling_mask = 0;
-	u32                     level_tmp;
-	u32                     which_bit;
-	u32                     i;
-
+	struct acpi_walk_info           *info = (struct acpi_walk_info *) context;
+	struct acpi_namespace_node      *this_node;
+	union acpi_operand_object       *obj_desc = NULL;
+	acpi_object_type                obj_type;
+	acpi_object_type                type;
+	u32                             bytes_to_dump;
+	u32                             dbg_level;
+	u32                             i;
 
-	PROC_NAME ("Ns_dump_one_object");
 
+	ACPI_FUNCTION_NAME ("ns_dump_one_object");
 
-	this_node = acpi_ns_map_handle_to_node (obj_handle);
-
-	level_tmp   = level;
-	type        = this_node->type;
-	which_bit   = 1;
 
+	/* Is output enabled? */
 
 	if (!(acpi_dbg_level & info->debug_level)) {
 		return (AE_OK);
@@ -140,6 +177,9 @@
 		return (AE_OK);
 	}
 
+	this_node = acpi_ns_map_handle_to_node (obj_handle);
+	type = this_node->type;
+
 	/* Check if the owner matches */
 
 	if ((info->owner_id != ACPI_UINT32_MAX) &&
@@ -147,68 +187,30 @@
 		return (AE_OK);
 	}
 
-
 	/* Indent the object according to the level */
 
-	while (level_tmp--) {
-
-		/* Print appropriate characters to form tree structure */
-
-		if (level_tmp) {
-			if (downstream_sibling_mask & which_bit) {
-				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "|"));
-			}
-
-			else {
-				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " "));
-			}
-
-			which_bit <<= 1;
-		}
-
-		else {
-			if (acpi_ns_exist_downstream_sibling (this_node + 1)) {
-				downstream_sibling_mask |= (1 << (level - 1));
-				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "+"));
-			}
-
-			else {
-				downstream_sibling_mask &= ACPI_UINT32_MAX ^ (1 << (level - 1));
-				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "+"));
-			}
-
-			if (this_node->child == NULL) {
-				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "-"));
-			}
-
-			else if (acpi_ns_exist_downstream_sibling (this_node->child)) {
-				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "+"));
-			}
-
-			else {
-				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "-"));
-			}
-		}
-	}
-
+	acpi_os_printf ("%2d%*s", (u32) level - 1, (int) level * 2, " ");
 
-	/* Check the integrity of our data */
+	/* Check the node type and name */
 
-	if (type > INTERNAL_TYPE_MAX) {
-		type = INTERNAL_TYPE_DEF_ANY;                                /* prints as *ERROR* */
+	if (type > ACPI_TYPE_LOCAL_MAX) {
+		ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", type));
 	}
 
-	if (!acpi_ut_valid_acpi_name (this_node->name)) {
-		REPORT_WARNING (("Invalid ACPI Name %08X\n", this_node->name));
+	if (!acpi_ut_valid_acpi_name (this_node->name.integer)) {
+		ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", this_node->name.integer));
 	}
 
 	/*
 	 * Now we can print out the pertinent information
 	 */
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " %4.4s %-12s %p",
-			(char*)&this_node->name, acpi_ut_get_type_name (type), this_node));
+	acpi_os_printf ("%4.4s %-12s %p ",
+			this_node->name.ascii, acpi_ut_get_type_name (type), this_node);
 
-	obj_desc = this_node->object;
+	dbg_level = acpi_dbg_level;
+	acpi_dbg_level = 0;
+	obj_desc = acpi_ns_get_attached_object (this_node);
+	acpi_dbg_level = dbg_level;
 
 	switch (info->display_type) {
 	case ACPI_DISPLAY_SUMMARY:
@@ -216,110 +218,148 @@
 		if (!obj_desc) {
 			/* No attached object, we are done */
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "\n"));
+			acpi_os_printf ("\n");
 			return (AE_OK);
 		}
 
-
 		switch (type) {
 		case ACPI_TYPE_PROCESSOR:
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " ID %d Addr %.4X Len %.4X\n",
+
+			acpi_os_printf ("ID %X Len %.4X Addr %p\n",
 					 obj_desc->processor.proc_id,
-					 obj_desc->processor.address,
-					 (unsigned)obj_desc->processor.length));
+					 obj_desc->processor.length,
+					 (char *) obj_desc->processor.address);
 			break;
 
+
 		case ACPI_TYPE_DEVICE:
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Notification object: %p", obj_desc));
+
+			acpi_os_printf ("Notify object: %p", obj_desc);
 			break;
 
+
 		case ACPI_TYPE_METHOD:
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Args %d Len %.4X Aml %p \n",
-					 obj_desc->method.param_count,
+
+			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));
+					 obj_desc->method.aml_start);
 			break;
 
+
 		case ACPI_TYPE_INTEGER:
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " = %8.8X%8.8X\n",
-					 HIDWORD (obj_desc->integer.value),
-					 LODWORD (obj_desc->integer.value)));
+
+			acpi_os_printf ("= %8.8X%8.8X\n",
+					 ACPI_HIDWORD (obj_desc->integer.value),
+					 ACPI_LODWORD (obj_desc->integer.value));
 			break;
 
+
 		case ACPI_TYPE_PACKAGE:
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Elements %.2X\n",
-					 obj_desc->package.count));
+
+			if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
+				acpi_os_printf ("Elements %.2X\n",
+						 obj_desc->package.count);
+			}
+			else {
+				acpi_os_printf ("[Length not yet evaluated]\n");
+			}
 			break;
 
-		case ACPI_TYPE_BUFFER:
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Len %.2X",
-					 obj_desc->buffer.length));
 
-			/* Dump some of the buffer */
+		case ACPI_TYPE_BUFFER:
 
-			if (obj_desc->buffer.length > 0) {
-				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " ="));
-				for (i = 0; (i < obj_desc->buffer.length && i < 12); i++) {
-					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " %.2X",
-							obj_desc->buffer.pointer[i]));
+			if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
+				acpi_os_printf ("Len %.2X",
+						 obj_desc->buffer.length);
+
+				/* Dump some of the buffer */
+
+				if (obj_desc->buffer.length > 0) {
+					acpi_os_printf (" =");
+					for (i = 0; (i < obj_desc->buffer.length && i < 12); i++) {
+						acpi_os_printf (" %.2hX", obj_desc->buffer.pointer[i]);
+					}
 				}
+				acpi_os_printf ("\n");
+			}
+			else {
+				acpi_os_printf ("[Length not yet evaluated]\n");
 			}
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "\n"));
 			break;
 
+
 		case ACPI_TYPE_STRING:
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Len %.2X",
-					 obj_desc->string.length));
 
-			if (obj_desc->string.length > 0) {
-				 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " = \"%.32s\"...",
-						 obj_desc->string.pointer));
-			}
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "\n"));
+			acpi_os_printf ("Len %.2X ", obj_desc->string.length);
+			acpi_ut_print_string (obj_desc->string.pointer, 32);
+			acpi_os_printf ("\n");
 			break;
 
+
 		case ACPI_TYPE_REGION:
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " [%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_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Addr %8.8X%8.8X Len %.4X\n",
-						 HIDWORD(obj_desc->region.address),
-						 LODWORD(obj_desc->region.address),
-						 obj_desc->region.length));
+				acpi_os_printf (" Addr %8.8X%8.8X Len %.4X\n",
+						 ACPI_HIDWORD (obj_desc->region.address),
+						 ACPI_LODWORD (obj_desc->region.address),
+						 obj_desc->region.length);
 			}
 			else {
-				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " [Address/Length not evaluated]\n"));
+				acpi_os_printf (" [Address/Length not yet evaluated]\n");
 			}
 			break;
 
-		case INTERNAL_TYPE_REFERENCE:
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " [%s]\n",
-					 acpi_ps_get_opcode_name (obj_desc->reference.opcode)));
+
+		case ACPI_TYPE_LOCAL_REFERENCE:
+
+			acpi_os_printf ("[%s]\n",
+					acpi_ps_get_opcode_name (obj_desc->reference.opcode));
 			break;
 
+
 		case ACPI_TYPE_BUFFER_FIELD:
 
-			/* TBD: print Buffer name when we can easily get it */
+			if (obj_desc->buffer_field.buffer_obj &&
+				obj_desc->buffer_field.buffer_obj->buffer.node) {
+				acpi_os_printf ("Buf [%4.4s]",
+						obj_desc->buffer_field.buffer_obj->buffer.node->name.ascii);
+			}
 			break;
 
-		case INTERNAL_TYPE_REGION_FIELD:
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Rgn [%4.4s]",
-					 (char *) &obj_desc->common_field.region_obj->region.node->name));
+
+		case ACPI_TYPE_LOCAL_REGION_FIELD:
+
+			acpi_os_printf ("Rgn [%4.4s]",
+					obj_desc->common_field.region_obj->region.node->name.ascii);
 			break;
 
-		case INTERNAL_TYPE_BANK_FIELD:
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Rgn [%4.4s]",
-					 (char *) &obj_desc->common_field.region_obj->region.node->name));
+
+		case ACPI_TYPE_LOCAL_BANK_FIELD:
+
+			acpi_os_printf ("Rgn [%4.4s] Bnk [%4.4s]",
+					obj_desc->common_field.region_obj->region.node->name.ascii,
+					obj_desc->bank_field.bank_obj->common_field.node->name.ascii);
 			break;
 
-		case INTERNAL_TYPE_INDEX_FIELD:
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Rgn [%4.4s]",
-					 (char *) &obj_desc->index_field.index_obj->common_field.region_obj->region.node->name));
+
+		case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+			acpi_os_printf ("Idx [%4.4s] Dat [%4.4s]",
+					obj_desc->index_field.index_obj->common_field.node->name.ascii,
+					obj_desc->index_field.data_obj->common_field.node->name.ascii);
+			break;
+
+
+		case ACPI_TYPE_LOCAL_ALIAS:
+
+			acpi_os_printf ("Target %4.4s (%p)\n", ((struct acpi_namespace_node *) obj_desc)->name.ascii, obj_desc);
 			break;
 
 		default:
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Object %p\n", obj_desc));
+			acpi_os_printf ("Object %p\n", obj_desc);
 			break;
 		}
 
@@ -327,77 +367,74 @@
 
 		switch (type) {
 		case ACPI_TYPE_BUFFER_FIELD:
-		case INTERNAL_TYPE_REGION_FIELD:
-		case INTERNAL_TYPE_BANK_FIELD:
-		case INTERNAL_TYPE_INDEX_FIELD:
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Off %.2X Len %.2X Acc %.2d\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_bit_width));
+		case ACPI_TYPE_LOCAL_REGION_FIELD:
+		case ACPI_TYPE_LOCAL_BANK_FIELD:
+		case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+			acpi_os_printf (" Off %.2X 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);
 			break;
-		}
 
+		default:
+			break;
+		}
 		break;
 
 
 	case ACPI_DISPLAY_OBJECTS:
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "%p O:%p",
-				this_node, obj_desc));
-
+		acpi_os_printf ("O:%p", obj_desc);
 		if (!obj_desc) {
 			/* No attached object, we are done */
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "\n"));
+			acpi_os_printf ("\n");
 			return (AE_OK);
 		}
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "(R%d)",
-				obj_desc->common.reference_count));
+		acpi_os_printf ("(R%d)",
+				obj_desc->common.reference_count);
 
 		switch (type) {
-
 		case ACPI_TYPE_METHOD:
 
 			/* Name is a Method and its AML offset/length are set */
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " M:%p-%X\n",
-					 obj_desc->method.aml_start,
-					 obj_desc->method.aml_length));
-
+			acpi_os_printf (" M:%p-%X\n", obj_desc->method.aml_start,
+					  obj_desc->method.aml_length);
 			break;
 
-
 		case ACPI_TYPE_INTEGER:
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " N:%X%X\n",
-					 HIDWORD(obj_desc->integer.value),
-					 LODWORD(obj_desc->integer.value)));
+			acpi_os_printf (" N:%X%X\n", ACPI_HIDWORD(obj_desc->integer.value),
+					 ACPI_LODWORD(obj_desc->integer.value));
 			break;
 
-
 		case ACPI_TYPE_STRING:
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " S:%p-%X\n",
-					 obj_desc->string.pointer,
-					 obj_desc->string.length));
+			acpi_os_printf (" S:%p-%X\n", obj_desc->string.pointer,
+					  obj_desc->string.length);
 			break;
 
-
 		case ACPI_TYPE_BUFFER:
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " B:%p-%X\n",
-					 obj_desc->buffer.pointer,
-					 obj_desc->buffer.length));
+			acpi_os_printf (" B:%p-%X\n", obj_desc->buffer.pointer,
+					  obj_desc->buffer.length);
 			break;
 
-
 		default:
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "\n"));
+			acpi_os_printf ("\n");
 			break;
 		}
 		break;
+
+
+	default:
+		acpi_os_printf ("\n");
+		break;
 	}
 
 	/* If debug turned off, done */
@@ -409,48 +446,55 @@
 
 	/* If there is an attached object, display it */
 
-	obj_desc = this_node->object;
+	dbg_level    = acpi_dbg_level;
+	acpi_dbg_level = 0;
+	obj_desc     = acpi_ns_get_attached_object (this_node);
+	acpi_dbg_level = dbg_level;
 
 	/* Dump attached objects */
 
 	while (obj_desc) {
-		obj_type = INTERNAL_TYPE_INVALID;
+		obj_type = ACPI_TYPE_INVALID;
+		acpi_os_printf ("      Attached Object %p: ", obj_desc);
 
 		/* Decode the type of attached object and dump the contents */
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "        Attached Object %p: ", obj_desc));
+		switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) {
+		case ACPI_DESC_TYPE_NAMED:
 
-		if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) {
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "(Ptr to Node)\n"));
-			bytes_to_dump = sizeof (acpi_namespace_node);
-		}
+			acpi_os_printf ("(Ptr to Node)\n");
+			bytes_to_dump = sizeof (struct acpi_namespace_node);
+			break;
 
 
-		else if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_INTERNAL)) {
-			obj_type = obj_desc->common.type;
+		case ACPI_DESC_TYPE_OPERAND:
 
-			if (obj_type > INTERNAL_TYPE_MAX) {
-				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "(Ptr to ACPI Object type %X [UNKNOWN])\n", obj_type));
+			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);
 				bytes_to_dump = 32;
 			}
-
 			else {
-				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "(Ptr to ACPI Object type %2.2X [%s])\n",
-						   obj_type, acpi_ut_get_type_name (obj_type)));
-				bytes_to_dump = sizeof (acpi_operand_object);
+				acpi_os_printf ("(Ptr to ACPI Object type %s, %X)\n",
+						   acpi_ut_get_type_name (obj_type), obj_type);
+				bytes_to_dump = sizeof (union acpi_operand_object);
 			}
-		}
+			break;
+
+
+		default:
 
-		else {
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "(String or Buffer - not descriptor)\n"));
+			acpi_os_printf ("(String or Buffer ptr - not an object descriptor)\n");
 			bytes_to_dump = 16;
+			break;
 		}
 
-		DUMP_BUFFER (obj_desc, bytes_to_dump);
+		ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump);
 
 		/* If value is NOT an internal object, we are done */
 
-		if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) {
+		if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) {
 			goto cleanup;
 		}
 
@@ -459,78 +503,78 @@
 		 */
 		switch (obj_type) {
 		case ACPI_TYPE_STRING:
-			obj_desc = (acpi_operand_object *) obj_desc->string.pointer;
+			obj_desc = (void *) obj_desc->string.pointer;
 			break;
 
 		case ACPI_TYPE_BUFFER:
-			obj_desc = (acpi_operand_object *) obj_desc->buffer.pointer;
+			obj_desc = (void *) obj_desc->buffer.pointer;
 			break;
 
 		case ACPI_TYPE_BUFFER_FIELD:
-			obj_desc = (acpi_operand_object *) obj_desc->buffer_field.buffer_obj;
+			obj_desc = (union acpi_operand_object *) obj_desc->buffer_field.buffer_obj;
 			break;
 
 		case ACPI_TYPE_PACKAGE:
-			obj_desc = (acpi_operand_object *) obj_desc->package.elements;
+			obj_desc = (void *) obj_desc->package.elements;
 			break;
 
 		case ACPI_TYPE_METHOD:
-			obj_desc = (acpi_operand_object *) obj_desc->method.aml_start;
+			obj_desc = (void *) obj_desc->method.aml_start;
 			break;
 
-		case INTERNAL_TYPE_REGION_FIELD:
-			obj_desc = (acpi_operand_object *) obj_desc->field.region_obj;
+		case ACPI_TYPE_LOCAL_REGION_FIELD:
+			obj_desc = (void *) obj_desc->field.region_obj;
 			break;
 
-		case INTERNAL_TYPE_BANK_FIELD:
-			obj_desc = (acpi_operand_object *) obj_desc->bank_field.region_obj;
+		case ACPI_TYPE_LOCAL_BANK_FIELD:
+			obj_desc = (void *) obj_desc->bank_field.region_obj;
 			break;
 
-		case INTERNAL_TYPE_INDEX_FIELD:
-			obj_desc = (acpi_operand_object *) obj_desc->index_field.index_obj;
+		case ACPI_TYPE_LOCAL_INDEX_FIELD:
+			obj_desc = (void *) obj_desc->index_field.index_obj;
 			break;
 
-	   default:
+		default:
 			goto cleanup;
 		}
 
-		obj_type = INTERNAL_TYPE_INVALID;    /* Terminate loop after next pass */
+		obj_type = ACPI_TYPE_INVALID;  /* Terminate loop after next pass */
 	}
 
 cleanup:
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "\n"));
+	acpi_os_printf ("\n");
 	return (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_dump_objects
+ * 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
+ *              owner_id            - Dump only objects owned by this ID.  Use
  *                                    ACPI_UINT32_MAX to match all owners.
- *              Start_handle        - Where in namespace to start/end search
+ *              start_handle        - Where in namespace to start/end search
  *
  * DESCRIPTION: Dump typed objects within the loaded namespace.
- *              Uses Acpi_ns_walk_namespace in conjunction with Acpi_ns_dump_one_object.
+ *              Uses acpi_ns_walk_namespace in conjunction with acpi_ns_dump_one_object.
  *
  ******************************************************************************/
 
 void
 acpi_ns_dump_objects (
-	acpi_object_type8       type,
-	u8                      display_type,
-	u32                     max_depth,
-	u32                     owner_id,
-	acpi_handle             start_handle)
+	acpi_object_type                type,
+	u8                              display_type,
+	u32                             max_depth,
+	u32                             owner_id,
+	acpi_handle                     start_handle)
 {
-	acpi_walk_info          info;
+	struct acpi_walk_info           info;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	info.debug_level = ACPI_LV_TABLES;
@@ -538,97 +582,19 @@
 	info.display_type = display_type;
 
 
-	acpi_ns_walk_namespace (type, start_handle, max_depth, NS_WALK_NO_UNLOCK, acpi_ns_dump_one_object,
-			   (void *) &info, NULL);
-}
-
-
-#ifndef _ACPI_ASL_COMPILER
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ns_dump_one_device
- *
- * PARAMETERS:  Handle              - Node to be dumped
- *              Level               - Nesting level of the handle
- *              Context             - Passed into Walk_namespace
- *
- * DESCRIPTION: Dump a single Node that represents a device
- *              This procedure is a User_function called by Acpi_ns_walk_namespace.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ns_dump_one_device (
-	acpi_handle             obj_handle,
-	u32                     level,
-	void                    *context,
-	void                    **return_value)
-{
-	acpi_device_info        info;
-	acpi_status             status;
-	u32                     i;
-
-
-	PROC_NAME ("Ns_dump_one_device");
-
-
-	status = acpi_ns_dump_one_object (obj_handle, level, context, return_value);
-
-	status = acpi_get_object_info (obj_handle, &info);
-	if (ACPI_SUCCESS (status)) {
-		for (i = 0; i < level; i++) {
-			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, HIDWORD(info.address), LODWORD(info.address), info.current_status));
-	}
-
-	return (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ns_dump_root_devices
- *
- * PARAMETERS:  None
- *
- * DESCRIPTION: Dump all objects of type "device"
- *
- ******************************************************************************/
-
-void
-acpi_ns_dump_root_devices (void)
-{
-	acpi_handle             sys_bus_handle;
-
-
-	PROC_NAME ("Ns_dump_root_devices");
-
-
-	/* Only dump the table if tracing is enabled */
-
-	if (!(ACPI_LV_TABLES & acpi_dbg_level)) {
-		return;
-	}
-
-	acpi_get_handle (0, NS_SYSTEM_BUS, &sys_bus_handle);
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Display of all devices in the namespace:\n"));
-	acpi_ns_walk_namespace (ACPI_TYPE_DEVICE, sys_bus_handle, ACPI_UINT32_MAX, NS_WALK_NO_UNLOCK,
-			   acpi_ns_dump_one_device, NULL, NULL);
+	(void) acpi_ns_walk_namespace (type, start_handle, max_depth,
+			 ACPI_NS_WALK_NO_UNLOCK, acpi_ns_dump_one_object,
+			 (void *) &info, NULL);
 }
 
-#endif
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_dump_tables
+ * FUNCTION:    acpi_ns_dump_tables
  *
- * PARAMETERS:  Search_base         - Root of subtree to be dumped, or
+ * PARAMETERS:  search_base         - Root of subtree to be dumped, or
  *                                    NS_ALL to dump the entire namespace
- *              Max_depth           - Maximum depth of dump.  Use INT_MAX
+ *              max_depth           - Maximum depth of dump.  Use INT_MAX
  *                                    for an effectively unlimited depth.
  *
  * DESCRIPTION: Dump the name space, or a portion of it.
@@ -637,13 +603,13 @@
 
 void
 acpi_ns_dump_tables (
-	acpi_handle             search_base,
-	u32                     max_depth)
+	acpi_handle                     search_base,
+	u32                             max_depth)
 {
-	acpi_handle             search_handle = search_base;
+	acpi_handle                     search_handle = search_base;
 
 
-	FUNCTION_TRACE ("Ns_dump_tables");
+	ACPI_FUNCTION_TRACE ("ns_dump_tables");
 
 
 	if (!acpi_gbl_root_node) {
@@ -651,11 +617,11 @@
 		 * If the name space has not been initialized,
 		 * there is nothing to dump.
 		 */
-		ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "name space not initialized!\n"));
+		ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n"));
 		return_VOID;
 	}
 
-	if (NS_ALL == search_base) {
+	if (ACPI_NS_ALL == search_base) {
 		/*  entire namespace    */
 
 		search_handle = acpi_gbl_root_node;
@@ -671,10 +637,10 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_dump_entry
+ * FUNCTION:    acpi_ns_dump_entry
  *
  * PARAMETERS:  Handle              - Node to be dumped
- *              Debug_level         - Output level
+ *              debug_level         - Output level
  *
  * DESCRIPTION: Dump a single Node
  *
@@ -682,19 +648,20 @@
 
 void
 acpi_ns_dump_entry (
-	acpi_handle             handle,
-	u32                     debug_level)
+	acpi_handle                     handle,
+	u32                             debug_level)
 {
-	acpi_walk_info          info;
+	struct acpi_walk_info           info;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	info.debug_level = debug_level;
 	info.owner_id = ACPI_UINT32_MAX;
+	info.display_type = ACPI_DISPLAY_SUMMARY;
 
-	acpi_ns_dump_one_object (handle, 1, &info, NULL);
+	(void) acpi_ns_dump_one_object (handle, 1, &info, NULL);
 }
 
 #endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/namespace/nsdumpdv.c linux-2.4.22-pre2/drivers/acpi/namespace/nsdumpdv.c
--- linux-2.4.21/drivers/acpi/namespace/nsdumpdv.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/namespace/nsdumpdv.c	2003-06-26 21:43:15.000000000 +0000
@@ -0,0 +1,145 @@
+/******************************************************************************
+ *
+ * Module Name: nsdump - table dumping routines for debug
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
+
+
+#define _COMPONENT          ACPI_NAMESPACE
+	 ACPI_MODULE_NAME    ("nsdumpdv")
+
+
+#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_dump_one_device
+ *
+ * PARAMETERS:  Handle              - Node to be dumped
+ *              Level               - Nesting level of the handle
+ *              Context             - Passed into walk_namespace
+ *
+ * DESCRIPTION: Dump a single Node that represents a device
+ *              This procedure is a user_function called by acpi_ns_walk_namespace.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ns_dump_one_device (
+	acpi_handle                     obj_handle,
+	u32                             level,
+	void                            *context,
+	void                            **return_value)
+{
+	struct acpi_buffer              buffer;
+	struct acpi_device_info         *info;
+	acpi_status                     status;
+	u32                             i;
+
+
+	ACPI_FUNCTION_NAME ("ns_dump_one_device");
+
+
+	status = acpi_ns_dump_one_object (obj_handle, level, context, return_value);
+
+	buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
+	status = acpi_get_object_info (obj_handle, &buffer);
+	if (ACPI_SUCCESS (status)) {
+		info = buffer.pointer;
+		for (i = 0; i < level; i++) {
+			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_HIDWORD (info->address), ACPI_LODWORD (info->address),
+				  info->current_status));
+		ACPI_MEM_FREE (info);
+	}
+
+	return (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_dump_root_devices
+ *
+ * PARAMETERS:  None
+ *
+ * DESCRIPTION: Dump all objects of type "device"
+ *
+ ******************************************************************************/
+
+void
+acpi_ns_dump_root_devices (void)
+{
+	acpi_handle                     sys_bus_handle;
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_NAME ("ns_dump_root_devices");
+
+
+	/* Only dump the table if tracing is enabled */
+
+	if (!(ACPI_LV_TABLES & acpi_dbg_level)) {
+		return;
+	}
+
+	status = acpi_get_handle (0, ACPI_NS_SYSTEM_BUS, &sys_bus_handle);
+	if (ACPI_FAILURE (status)) {
+		return;
+	}
+
+	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,
+			 acpi_ns_dump_one_device, NULL, NULL);
+}
+
+#endif
+
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/namespace/nseval.c linux-2.4.22-pre2/drivers/acpi/namespace/nseval.c
--- linux-2.4.21/drivers/acpi/namespace/nseval.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/namespace/nseval.c	2003-06-26 21:43:18.000000000 +0000
@@ -2,51 +2,68 @@
  *
  * Module Name: nseval - Object evaluation interfaces -- includes control
  *                       method lookup and execution.
- *              $Revision: 102 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "amlcode.h"
-#include "acparser.h"
-#include "acinterp.h"
-#include "acnamesp.h"
+#include <acpi/acpi.h>
+#include <acpi/acparser.h>
+#include <acpi/acinterp.h>
+#include <acpi/acnamesp.h>
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-	 MODULE_NAME         ("nseval")
+	 ACPI_MODULE_NAME    ("nseval")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_evaluate_relative
+ * FUNCTION:    acpi_ns_evaluate_relative
  *
  * PARAMETERS:  Handle              - The relative containing object
- *              *Pathname           - Name of method to execute, If NULL, the
+ *              Pathname            - Name of method to execute, If NULL, the
  *                                    handle is the object to execute
- *              **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.
- *              *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.
  *
  * RETURN:      Status
@@ -60,19 +77,19 @@
 
 acpi_status
 acpi_ns_evaluate_relative (
-	acpi_namespace_node     *handle,
-	NATIVE_CHAR             *pathname,
-	acpi_operand_object     **params,
-	acpi_operand_object     **return_object)
+	struct acpi_namespace_node      *handle,
+	char                            *pathname,
+	union acpi_operand_object       **params,
+	union acpi_operand_object       **return_object)
 {
-	acpi_namespace_node     *prefix_node;
-	acpi_status             status;
-	acpi_namespace_node     *node = NULL;
-	NATIVE_CHAR             *internal_path = NULL;
-	acpi_generic_state      scope_info;
+	struct acpi_namespace_node      *prefix_node;
+	acpi_status                     status;
+	struct acpi_namespace_node      *node = NULL;
+	char                            *internal_path = NULL;
+	union acpi_generic_state        scope_info;
 
 
-	FUNCTION_TRACE ("Ns_evaluate_relative");
+	ACPI_FUNCTION_TRACE ("ns_evaluate_relative");
 
 
 	/*
@@ -91,11 +108,14 @@
 
 	/* Get the prefix handle and Node */
 
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	prefix_node = acpi_ns_map_handle_to_node (handle);
 	if (!prefix_node) {
-		acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+		(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 		status = AE_BAD_PARAMETER;
 		goto cleanup;
 	}
@@ -104,13 +124,13 @@
 
 	scope_info.scope.node = prefix_node;
 	status = acpi_ns_lookup (&scope_info, internal_path, ACPI_TYPE_ANY,
-			 IMODE_EXECUTE, NS_NO_UPSEARCH, NULL,
+			 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL,
 			 &node);
 
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 
 	if (ACPI_FAILURE (status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Object [%s] not found [%s]\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Object [%s] not found [%s]\n",
 			pathname, acpi_format_exception (status)));
 		goto cleanup;
 	}
@@ -119,12 +139,12 @@
 	 * Now that we have a handle to the object, we can attempt
 	 * to evaluate it.
 	 */
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s [%p] Value %p\n",
-		pathname, node, node->object));
+	ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n",
+		pathname, node, acpi_ns_get_attached_object (node)));
 
 	status = acpi_ns_evaluate_by_handle (node, params, return_object);
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "*** Completed eval of object %s ***\n",
+	ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n",
 		pathname));
 
 cleanup:
@@ -136,12 +156,12 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_evaluate_by_name
+ * FUNCTION:    acpi_ns_evaluate_by_name
  *
  * PARAMETERS:  Pathname            - Fully qualified pathname to the object
- *              *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.
  *
@@ -156,16 +176,16 @@
 
 acpi_status
 acpi_ns_evaluate_by_name (
-	NATIVE_CHAR             *pathname,
-	acpi_operand_object     **params,
-	acpi_operand_object     **return_object)
+	char                            *pathname,
+	union acpi_operand_object       **params,
+	union acpi_operand_object       **return_object)
 {
-	acpi_status             status;
-	acpi_namespace_node     *node = NULL;
-	NATIVE_CHAR             *internal_path = NULL;
+	acpi_status                     status;
+	struct acpi_namespace_node      *node = NULL;
+	char                            *internal_path = NULL;
 
 
-	FUNCTION_TRACE ("Ns_evaluate_by_name");
+	ACPI_FUNCTION_TRACE ("ns_evaluate_by_name");
 
 
 	/* Build an internal name string for the method */
@@ -175,18 +195,21 @@
 		return_ACPI_STATUS (status);
 	}
 
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	/* Lookup the name in the namespace */
 
 	status = acpi_ns_lookup (NULL, internal_path, ACPI_TYPE_ANY,
-			 IMODE_EXECUTE, NS_NO_UPSEARCH, NULL,
+			 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL,
 			 &node);
 
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 
 	if (ACPI_FAILURE (status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "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;
 	}
@@ -195,12 +218,12 @@
 	 * Now that we have a handle to the object, we can attempt
 	 * to evaluate it.
 	 */
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s [%p] Value %p\n",
-		pathname, node, node->object));
+	ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n",
+		pathname, node, acpi_ns_get_attached_object (node)));
 
 	status = acpi_ns_evaluate_by_handle (node, params, return_object);
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "*** Completed eval of object %s ***\n",
+	ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n",
 		pathname));
 
 
@@ -218,13 +241,13 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_evaluate_by_handle
+ * FUNCTION:    acpi_ns_evaluate_by_handle
  *
  * PARAMETERS:  Handle              - Method Node to execute
- *              **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.
- *              *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.
  *
  * RETURN:      Status
@@ -237,16 +260,16 @@
 
 acpi_status
 acpi_ns_evaluate_by_handle (
-	acpi_namespace_node     *handle,
-	acpi_operand_object     **params,
-	acpi_operand_object     **return_object)
+	struct acpi_namespace_node      *handle,
+	union acpi_operand_object       **params,
+	union acpi_operand_object       **return_object)
 {
-	acpi_namespace_node     *node;
-	acpi_status             status;
-	acpi_operand_object     *local_return_object;
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
+	union acpi_operand_object       *local_return_object;
 
 
-	FUNCTION_TRACE ("Ns_evaluate_by_handle");
+	ACPI_FUNCTION_TRACE ("ns_evaluate_by_handle");
 
 
 	/* Check if namespace has been initialized */
@@ -269,15 +292,17 @@
 
 	/* Get the prefix handle and Node */
 
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	node = acpi_ns_map_handle_to_node (handle);
 	if (!node) {
-		acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+		(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-
 	/*
 	 * Two major cases here:
 	 * 1) The object is an actual control method -- execute it.
@@ -285,7 +310,7 @@
 	 *      value
 	 *
 	 * In both cases, the namespace is unlocked by the
-	 *  Acpi_ns* procedure
+	 *  acpi_ns* procedure
 	 */
 	if (acpi_ns_get_type (node) == ACPI_TYPE_METHOD) {
 		/*
@@ -294,7 +319,6 @@
 		status = acpi_ns_execute_control_method (node, params,
 				 &local_return_object);
 	}
-
 	else {
 		/*
 		 * Case 2) Object is NOT a method, just return its
@@ -303,7 +327,6 @@
 		status = acpi_ns_get_object_value (node, &local_return_object);
 	}
 
-
 	/*
 	 * Check if there is a return value on the stack that must
 	 * be dealt with
@@ -323,16 +346,13 @@
 			*return_object = local_return_object;
 		}
 
+		/* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */
 
-		/* Map AE_RETURN_VALUE to AE_OK, we are done with it */
-
-		if (status == AE_CTRL_RETURN_VALUE) {
-			status = AE_OK;
-		}
+		status = AE_OK;
 	}
 
 	/*
-	 * Namespace was unlocked by the handling Acpi_ns* function,
+	 * Namespace was unlocked by the handling acpi_ns* function,
 	 * so we just return
 	 */
 	return_ACPI_STATUS (status);
@@ -341,13 +361,13 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_execute_control_method
+ * FUNCTION:    acpi_ns_execute_control_method
  *
- * PARAMETERS:  Method_node     - The object/method
- *              **Params            - List of parameters to pass to the 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
+ *              return_obj_desc     - List of result objects to be returned
  *                                    from the method.
  *
  * RETURN:      Status
@@ -360,15 +380,15 @@
 
 acpi_status
 acpi_ns_execute_control_method (
-	acpi_namespace_node     *method_node,
-	acpi_operand_object     **params,
-	acpi_operand_object     **return_obj_desc)
+	struct acpi_namespace_node      *method_node,
+	union acpi_operand_object       **params,
+	union acpi_operand_object       **return_obj_desc)
 {
-	acpi_status             status;
-	acpi_operand_object     *obj_desc;
+	acpi_status                     status;
+	union acpi_operand_object       *obj_desc;
 
 
-	FUNCTION_TRACE ("Ns_execute_control_method");
+	ACPI_FUNCTION_TRACE ("ns_execute_control_method");
 
 
 	/* Verify that there is a method associated with this object */
@@ -377,21 +397,16 @@
 	if (!obj_desc) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No attached method object\n"));
 
-		acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+		(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 		return_ACPI_STATUS (AE_NULL_OBJECT);
 	}
 
+	ACPI_DUMP_PATHNAME (method_node, "Execute Method:",
+		ACPI_LV_INFO, _COMPONENT);
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Control method at Offset %p Length %x]\n",
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Method at AML address %p Length %X\n",
 		obj_desc->method.aml_start + 1, obj_desc->method.aml_length - 1));
 
-	DUMP_PATHNAME (method_node, "Ns_execute_control_method: Executing",
-		ACPI_LV_NAMES, _COMPONENT);
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "At offset %p\n",
-			obj_desc->method.aml_start + 1));
-
-
 	/*
 	 * Unlock the namespace before execution.  This allows namespace access
 	 * via the external Acpi* interfaces while a method is being executed.
@@ -399,7 +414,10 @@
 	 * interpreter locks to ensure that no thread is using the portion of the
 	 * namespace that is being deleted.
 	 */
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	/*
 	 * Execute the method via the interpreter.  The interpreter is locked
@@ -419,129 +437,79 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_get_object_value
+ * FUNCTION:    acpi_ns_get_object_value
  *
- * PARAMETERS:  Node         - The object
+ * PARAMETERS:  Node                - The object
+ *              return_obj_desc     - Where the objects value is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Return the current value of the object
  *
- * MUTEX:       Assumes namespace is locked
+ * MUTEX:       Assumes namespace is locked, leaves namespace unlocked
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ns_get_object_value (
-	acpi_namespace_node     *node,
-	acpi_operand_object     **return_obj_desc)
+	struct acpi_namespace_node      *node,
+	union acpi_operand_object       **return_obj_desc)
 {
-	acpi_status             status = AE_OK;
-	acpi_operand_object     *obj_desc;
-	acpi_operand_object     *source_desc;
+	acpi_status                     status = AE_OK;
+	struct acpi_namespace_node      *resolved_node = node;
 
 
-	FUNCTION_TRACE ("Ns_get_object_value");
+	ACPI_FUNCTION_TRACE ("ns_get_object_value");
 
 
 	/*
-	 *  We take the value from certain objects directly
+	 * 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.
 	 */
-	if ((node->type == ACPI_TYPE_PROCESSOR) ||
-		(node->type == ACPI_TYPE_POWER)) {
-		/*
-		 *  Create a Reference object to contain the object
-		 */
-		obj_desc = acpi_ut_create_internal_object (node->type);
-		if (!obj_desc) {
-		   status = AE_NO_MEMORY;
-		   goto unlock_and_exit;
-		}
-
-		/*
-		 *  Get the attached object
-		 */
-		source_desc = acpi_ns_get_attached_object (node);
-		if (!source_desc) {
-			status = AE_NULL_OBJECT;
-			goto unlock_and_exit;
-		}
-
-		/*
-		 * Just copy from the original to the return object
-		 *
-		 * TBD: [Future] - need a low-level object copy that handles
-		 * the reference count automatically.  (Don't want to copy it)
-		 */
-		MEMCPY (obj_desc, source_desc, sizeof (acpi_operand_object));
-		obj_desc->common.reference_count = 1;
-		acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
-	}
-
 
 	/*
-	 * Other objects require a reference object wrapper which we
-	 * then attempt to resolve.
+	 * 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.)
+	 *
+	 * 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.
 	 */
-	else {
-		/* Create an Reference object to contain the object */
-
-		obj_desc = acpi_ut_create_internal_object (INTERNAL_TYPE_REFERENCE);
-		if (!obj_desc) {
-		   status = AE_NO_MEMORY;
-		   goto unlock_and_exit;
-		}
-
-		/* Construct a descriptor pointing to the name */
-
-		obj_desc->reference.opcode = (u8) AML_NAME_OP;
-		obj_desc->reference.object = (void *) node;
+	status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
+	status = acpi_ex_enter_interpreter ();
+	if (ACPI_SUCCESS (status)) {
+		status = acpi_ex_resolve_node_to_value (&resolved_node, NULL);
 		/*
-		 * Use Resolve_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
-		 *
-		 * 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.
+		 * If acpi_ex_resolve_node_to_value() succeeded, the return value was
+		 * placed in resolved_node.
 		 */
-		acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
-		status = acpi_ex_enter_interpreter ();
-		if (ACPI_SUCCESS (status)) {
-			status = acpi_ex_resolve_to_value (&obj_desc, NULL);
+		acpi_ex_exit_interpreter ();
 
-			acpi_ex_exit_interpreter ();
+		if (ACPI_SUCCESS (status)) {
+			status = AE_CTRL_RETURN_VALUE;
+			*return_obj_desc = ACPI_CAST_PTR (union acpi_operand_object, resolved_node);
+			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n",
+				*return_obj_desc, acpi_ut_get_object_type_name (*return_obj_desc)));
 		}
 	}
 
-	/*
-	 * If Acpi_ex_resolve_to_value() succeeded, the return value was
-	 * placed in Obj_desc.
-	 */
-	if (ACPI_SUCCESS (status)) {
-		status = AE_CTRL_RETURN_VALUE;
-
-		*return_obj_desc = obj_desc;
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Returning obj %p\n", *return_obj_desc));
-	}
-
 	/* Namespace is unlocked */
 
 	return_ACPI_STATUS (status);
-
-
-unlock_and_exit:
-
-	/* Unlock the namespace */
-
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
-	return_ACPI_STATUS (status);
 }
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/namespace/nsinit.c linux-2.4.22-pre2/drivers/acpi/namespace/nsinit.c
--- linux-2.4.21/drivers/acpi/namespace/nsinit.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/namespace/nsinit.c	2003-06-26 21:43:17.000000000 +0000
@@ -1,41 +1,59 @@
 /******************************************************************************
  *
  * Module Name: nsinit - namespace initialization
- *              $Revision: 33 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acnamesp.h"
-#include "acdispat.h"
-#include "acinterp.h"
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acdispat.h>
+#include <acpi/acinterp.h>
 
 #define _COMPONENT          ACPI_NAMESPACE
-	 MODULE_NAME         ("nsinit")
+	 ACPI_MODULE_NAME    ("nsinit")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_initialize_objects
+ * FUNCTION:    acpi_ns_initialize_objects
  *
  * PARAMETERS:  None
  *
@@ -50,24 +68,20 @@
 acpi_ns_initialize_objects (
 	void)
 {
-	acpi_status             status;
-	acpi_init_walk_info     info;
+	acpi_status                     status;
+	struct acpi_init_walk_info      info;
 
 
-	FUNCTION_TRACE ("Ns_initialize_objects");
+	ACPI_FUNCTION_TRACE ("ns_initialize_objects");
 
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
 		"**** Starting initialization of namespace objects ****\n"));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "Completing Region and Field initialization:"));
+	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Completing Region/Field/Buffer/Package initialization:"));
 
+	/* Set all init info to zero */
 
-	info.field_count = 0;
-	info.field_init = 0;
-	info.op_region_count = 0;
-	info.op_region_init = 0;
-	info.object_count = 0;
-
+	ACPI_MEMSET (&info, 0, sizeof (struct acpi_init_walk_info));
 
 	/* Walk entire namespace from the supplied root */
 
@@ -75,17 +89,21 @@
 			  ACPI_UINT32_MAX, acpi_ns_init_one_object,
 			  &info, NULL);
 	if (ACPI_FAILURE (status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Walk_namespace failed! %x\n", status));
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed! %s\n",
+			acpi_format_exception (status)));
 	}
 
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-		"\n%d/%d Regions, %d/%d Fields initialized (%d nodes total)\n",
-		info.op_region_init, info.op_region_count, info.field_init,
-		info.field_count, info.object_count));
+	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
+		"\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd Buffers %hd/%hd Packages (%hd nodes)\n",
+		info.op_region_init, info.op_region_count,
+		info.field_init,    info.field_count,
+		info.buffer_init,   info.buffer_count,
+		info.package_init,  info.package_count, info.object_count));
+
 	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-		"%d Control Methods found\n", info.method_count));
+		"%hd Control Methods found\n", info.method_count));
 	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-		"%d Op Regions found\n", info.op_region_count));
+		"%hd Op Regions found\n", info.op_region_count));
 
 	return_ACPI_STATUS (AE_OK);
 }
@@ -93,7 +111,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_initialize_devices
+ * FUNCTION:    acpi_ns_initialize_devices
  *
  * PARAMETERS:  None
  *
@@ -111,30 +129,33 @@
 acpi_ns_initialize_devices (
 	void)
 {
-	acpi_status             status;
-	acpi_device_walk_info   info;
+	acpi_status                     status;
+	struct acpi_device_walk_info    info;
+
 
+	ACPI_FUNCTION_TRACE ("ns_initialize_devices");
 
-	FUNCTION_TRACE ("Ns_initialize_devices");
 
+	/* Init counters */
 
 	info.device_count = 0;
 	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_OK, "Executing device _INI methods:"));
+	/* Walk namespace for all objects of type Device */
 
 	status = acpi_ns_walk_namespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
 			  ACPI_UINT32_MAX, FALSE, acpi_ns_init_one_device, &info, NULL);
 
 	if (ACPI_FAILURE (status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Walk_namespace failed! %x\n", status));
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed! %s\n",
+			acpi_format_exception (status)));
 	}
 
-
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-		"\n%d Devices found: %d _STA, %d _INI\n",
+	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
+		"\n%hd Devices found containing: %hd _STA, %hd _INI methods\n",
 		info.device_count, info.num_STA, info.num_INI));
 
 	return_ACPI_STATUS (status);
@@ -143,16 +164,16 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_init_one_object
+ * FUNCTION:    acpi_ns_init_one_object
  *
- * PARAMETERS:  Obj_handle      - Node
+ * PARAMETERS:  obj_handle      - Node
  *              Level           - Current nesting level
  *              Context         - Points to a init info struct
- *              Return_value    - Not used
+ *              return_value    - Not used
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Callback from Acpi_walk_namespace. Invoked for every object
+ * DESCRIPTION: Callback from acpi_walk_namespace. Invoked for every object
  *              within the  namespace.
  *
  *              Currently, the only objects that require initialization are:
@@ -163,37 +184,62 @@
 
 acpi_status
 acpi_ns_init_one_object (
-	acpi_handle             obj_handle,
-	u32                     level,
-	void                    *context,
-	void                    **return_value)
+	acpi_handle                     obj_handle,
+	u32                             level,
+	void                            *context,
+	void                            **return_value)
 {
-	acpi_object_type8       type;
-	acpi_status             status;
-	acpi_init_walk_info     *info = (acpi_init_walk_info *) context;
-	acpi_namespace_node     *node = (acpi_namespace_node *) obj_handle;
-	acpi_operand_object     *obj_desc;
+	acpi_object_type                type;
+	acpi_status                     status;
+	struct acpi_init_walk_info      *info = (struct acpi_init_walk_info *) context;
+	struct acpi_namespace_node      *node = (struct acpi_namespace_node *) obj_handle;
+	union acpi_operand_object       *obj_desc;
 
 
-	PROC_NAME ("Ns_init_one_object");
+	ACPI_FUNCTION_NAME ("ns_init_one_object");
 
 
 	info->object_count++;
 
-
 	/* And even then, we are only interested in a few object types */
 
 	type = acpi_ns_get_type (obj_handle);
-	obj_desc = node->object;
+	obj_desc = acpi_ns_get_attached_object (node);
 	if (!obj_desc) {
 		return (AE_OK);
 	}
 
-	if ((type != ACPI_TYPE_REGION) &&
-		(type != ACPI_TYPE_BUFFER_FIELD)) {
+	/* Increment counters for object types we are looking for */
+
+	switch (type) {
+	case ACPI_TYPE_REGION:
+		info->op_region_count++;
+		break;
+
+	case ACPI_TYPE_BUFFER_FIELD:
+		info->field_count++;
+		break;
+
+	case ACPI_TYPE_BUFFER:
+		info->buffer_count++;
+		break;
+
+	case ACPI_TYPE_PACKAGE:
+		info->package_count++;
+		break;
+
+	default:
+
+		/* No init required, just exit now */
 		return (AE_OK);
 	}
 
+	/*
+	 * If the object is already initialized, nothing else to do
+	 */
+	if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
+		return (AE_OK);
+	}
 
 	/*
 	 * Must lock the interpreter before executing AML code
@@ -203,61 +249,59 @@
 		return (status);
 	}
 
+	/*
+	 * Each of these types can contain executable AML code within
+	 * the declaration.
+	 */
 	switch (type) {
-
 	case ACPI_TYPE_REGION:
 
-		info->op_region_count++;
-		if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
-			break;
-		}
-
 		info->op_region_init++;
 		status = acpi_ds_get_region_arguments (obj_desc);
-		if (ACPI_FAILURE (status)) {
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR, "\n"));
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-					"%s while getting region arguments [%4.4s]\n",
-					acpi_format_exception (status), (char*)&node->name));
-		}
-
-		if (!(acpi_dbg_level & ACPI_LV_INIT)) {
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "."));
-		}
-
 		break;
 
 
 	case ACPI_TYPE_BUFFER_FIELD:
 
-		info->field_count++;
-		if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
-			break;
-		}
-
 		info->field_init++;
 		status = acpi_ds_get_buffer_field_arguments (obj_desc);
-		if (ACPI_FAILURE (status)) {
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR, "\n"));
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-					"%s while getting buffer field arguments [%4.4s]\n",
-					acpi_format_exception (status), (char*)&node->name));
-		}
-		if (!(acpi_dbg_level & ACPI_LV_INIT)) {
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "."));
-		}
+		break;
+
 
+	case ACPI_TYPE_BUFFER:
 
+		info->buffer_init++;
+		status = acpi_ds_get_buffer_arguments (obj_desc);
+		break;
+
+
+	case ACPI_TYPE_PACKAGE:
+
+		info->package_init++;
+		status = acpi_ds_get_package_arguments (obj_desc);
 		break;
 
 	default:
+		/* No other types can get here */
 		break;
 	}
 
+	if (ACPI_FAILURE (status)) {
+		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR, "\n"));
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"Could not execute arguments for [%4.4s] (%s), %s\n",
+				node->name.ascii, acpi_ut_get_type_name (type), acpi_format_exception (status)));
+	}
+
+	/* 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 a single error.
+	 * we don't want to abort the walk on any single error.
 	 */
 	acpi_ex_exit_interpreter ();
 	return (AE_OK);
@@ -266,7 +310,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_init_one_device
+ * FUNCTION:    acpi_ns_init_one_device
  *
  * PARAMETERS:  acpi_walk_callback
  *
@@ -280,40 +324,46 @@
 
 acpi_status
 acpi_ns_init_one_device (
-	acpi_handle             obj_handle,
-	u32                     nesting_level,
-	void                    *context,
-	void                    **return_value)
+	acpi_handle                     obj_handle,
+	u32                             nesting_level,
+	void                            *context,
+	void                            **return_value)
 {
-	acpi_status             status;
-	acpi_namespace_node    *node;
-	u32                     flags;
-	acpi_device_walk_info  *info = (acpi_device_walk_info *) context;
+	acpi_status                     status;
+	struct acpi_namespace_node     *node;
+	u32                             flags;
+	struct acpi_device_walk_info   *info = (struct acpi_device_walk_info *) context;
 
 
-	FUNCTION_TRACE ("Ns_init_one_device");
+	ACPI_FUNCTION_TRACE ("ns_init_one_device");
 
 
-	if (!(acpi_dbg_level & ACPI_LV_INIT)) {
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "."));
+	if ((acpi_dbg_level <= ACPI_LV_ALL_EXCEPTIONS) && (!(acpi_dbg_level & ACPI_LV_INFO))) {
+		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "."));
 	}
 
 	info->device_count++;
 
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	node = acpi_ns_map_handle_to_node (obj_handle);
 	if (!node) {
-		acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
-		return (AE_BAD_PARAMETER);
+		(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	/*
 	 * Run _STA to determine if we can run _INI on the device.
 	 */
-	DEBUG_EXEC (acpi_ut_display_init_pathname (node, "_STA [Method]"));
+	ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD, node, "_STA"));
 	status = acpi_ut_execute_STA (node, &flags);
 	if (ACPI_FAILURE (status)) {
 		/* Ignore error and move on to next device */
@@ -329,36 +379,41 @@
 		return_ACPI_STATUS(AE_CTRL_DEPTH);
 	}
 
-
 	/*
 	 * The device is present. Run _INI.
 	 */
-	DEBUG_EXEC (acpi_ut_display_init_pathname (obj_handle, "_INI [Method]"));
+	ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD, obj_handle, "_INI"));
 	status = acpi_ns_evaluate_relative (obj_handle, "_INI", NULL, NULL);
-	if (AE_NOT_FOUND == status) {
-		/* No _INI means device requires no initialization */
+	if (ACPI_FAILURE (status)) {
+		/* No _INI (AE_NOT_FOUND) means device requires no initialization */
 
-		status = AE_OK;
-	}
+		if (status != AE_NOT_FOUND) {
+			/* Ignore error and move on to next device */
 
-	else if (ACPI_FAILURE (status)) {
-		/* Ignore error and move on to next device */
+	#ifdef ACPI_DEBUG_OUTPUT
+			char                *scope_name = acpi_ns_get_external_pathname (obj_handle);
 
-#ifdef ACPI_DEBUG
-		NATIVE_CHAR *scope_name = acpi_ns_get_table_pathname (obj_handle);
+			ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%s._INI failed: %s\n",
+					scope_name, acpi_format_exception (status)));
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%s._INI failed: %s\n",
-				scope_name, acpi_format_exception (status)));
+			ACPI_MEM_FREE (scope_name);
+	#endif
+		}
 
-		ACPI_MEM_FREE (scope_name);
-#endif
+		status = AE_OK;
 	}
-
 	else {
 		/* Count of successful INIs */
 
 		info->num_INI++;
 	}
 
-	return_ACPI_STATUS (AE_OK);
+	if (acpi_gbl_init_handler) {
+		/* External initialization handler is present, call it */
+
+		status = acpi_gbl_init_handler (obj_handle, ACPI_INIT_DEVICE_INI);
+	}
+
+
+	return_ACPI_STATUS (status);
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/namespace/nsload.c linux-2.4.22-pre2/drivers/acpi/namespace/nsload.c
--- linux-2.4.21/drivers/acpi/namespace/nsload.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/namespace/nsload.c	2003-06-26 21:43:32.000000000 +0000
@@ -1,239 +1,91 @@
 /******************************************************************************
  *
  * Module Name: nsload - namespace loading/expanding/contracting procedures
- *              $Revision: 47 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "amlcode.h"
-#include "acparser.h"
-#include "acdispat.h"
-#include "acdebug.h"
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acdispat.h>
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-	 MODULE_NAME         ("nsload")
+	 ACPI_MODULE_NAME    ("nsload")
 
 
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_load_namespace
- *
- * PARAMETERS:  Display_aml_during_load
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Load the name space from what ever is pointed to by DSDT.
- *              (DSDT points to either the BIOS or a buffer.)
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ns_load_namespace (
-	void)
-{
-	acpi_status             status;
-
-
-	FUNCTION_TRACE ("Acpi_load_name_space");
-
-
-	/* There must be at least a DSDT installed */
-
-	if (acpi_gbl_DSDT == NULL) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "DSDT is not in memory\n"));
-		return_ACPI_STATUS (AE_NO_ACPI_TABLES);
-	}
-
-
-	/*
-	 * Load the namespace.  The DSDT is required,
-	 * but the SSDT and PSDT tables are optional.
-	 */
-	status = acpi_ns_load_table_by_type (ACPI_TABLE_DSDT);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
-
-	/* Ignore exceptions from these */
-
-	acpi_ns_load_table_by_type (ACPI_TABLE_SSDT);
-	acpi_ns_load_table_by_type (ACPI_TABLE_PSDT);
-
-
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-		"ACPI Namespace successfully loaded at root %p\n",
-		acpi_gbl_root_node));
-
-
-	return_ACPI_STATUS (status);
-}
-
+#ifndef ACPI_NO_METHOD_EXECUTION
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_one_parse_pass
+ * FUNCTION:    acpi_ns_load_table
  *
- * PARAMETERS:
+ * PARAMETERS:  table_desc      - Descriptor for table to be loaded
+ *              Node            - Owning NS node
  *
  * RETURN:      Status
  *
- * DESCRIPTION:
+ * DESCRIPTION: Load one ACPI table into the namespace
  *
  ******************************************************************************/
 
 acpi_status
-acpi_ns_one_complete_parse (
-	u32                     pass_number,
-	acpi_table_desc         *table_desc)
+acpi_ns_load_table (
+	struct acpi_table_desc          *table_desc,
+	struct acpi_namespace_node      *node)
 {
-	acpi_parse_object       *parse_root;
-	acpi_status             status;
-	acpi_walk_state         *walk_state;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Ns_one_complete_parse");
-
-
-	/* Create and init a Root Node */
-
-	parse_root = acpi_ps_alloc_op (AML_SCOPE_OP);
-	if (!parse_root) {
-		return_ACPI_STATUS (AE_NO_MEMORY);
-	}
-
-	((acpi_parse2_object *) parse_root)->name = ACPI_ROOT_NAME;
+	ACPI_FUNCTION_TRACE ("ns_load_table");
 
 
-	/* Create and initialize a new walk state */
+	/* Check if table contains valid AML (must be DSDT, PSDT, SSDT, etc.) */
 
-	walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
-			   NULL, NULL, NULL);
-	if (!walk_state) {
-		acpi_ps_free_op (parse_root);
-		return_ACPI_STATUS (AE_NO_MEMORY);
-	}
+	if (!(acpi_gbl_table_data[table_desc->type].flags & ACPI_TABLE_EXECUTABLE)) {
+		/* Just ignore this table */
 
-	status = acpi_ds_init_aml_walk (walk_state, parse_root, NULL, table_desc->aml_start,
-			  table_desc->aml_length, NULL, NULL, pass_number);
-	if (ACPI_FAILURE (status)) {
-		acpi_ds_delete_walk_state (walk_state);
-		return_ACPI_STATUS (status);
+		return_ACPI_STATUS (AE_OK);
 	}
 
-	/* Parse the AML */
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "*PARSE* pass %d parse\n", pass_number));
-	status = acpi_ps_parse_aml (walk_state);
-
-	acpi_ps_delete_parse_tree (parse_root);
-	return_ACPI_STATUS (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ns_parse_table
- *
- * PARAMETERS:  Table_desc      - An ACPI table descriptor for table to parse
- *              Start_node      - Where to enter the table into the namespace
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Parse AML within an ACPI table and return a tree of ops
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ns_parse_table (
-	acpi_table_desc         *table_desc,
-	acpi_namespace_node     *start_node)
-{
-	acpi_status             status;
-
-
-	FUNCTION_TRACE ("Ns_parse_table");
-
-
-	/*
-	 * AML Parse, pass 1
-	 *
-	 * In this pass, we load most of the namespace.  Control methods
-	 * are not parsed until later.  A parse tree is not created.  Instead,
-	 * each Parser Op subtree is deleted when it is finished.  This saves
-	 * a great deal of memory, and allows a small cache of parse objects
-	 * to service the entire parse.  The second pass of the parse then
-	 * performs another complete parse of the AML..
-	 */
-	status = acpi_ns_one_complete_parse (1, table_desc);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
-
-
-	/*
-	 * AML Parse, pass 2
-	 *
-	 * In this pass, we resolve forward references and other things
-	 * that could not be completed during the first pass.
-	 * Another complete parse of the AML is performed, but the
-	 * overhead of this is compensated for by the fact that the
-	 * parse objects are all cached.
-	 */
-	status = acpi_ns_one_complete_parse (2, table_desc);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
-
-	return_ACPI_STATUS (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ns_load_table
- *
- * PARAMETERS:  Table_desc      - Descriptor for table to be loaded
- *              Node            - Owning NS node
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Load one ACPI table into the namespace
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ns_load_table (
-	acpi_table_desc         *table_desc,
-	acpi_namespace_node     *node)
-{
-	acpi_status             status;
-
-
-	FUNCTION_TRACE ("Ns_load_table");
-
+	/* Check validity of the AML start and length */
 
 	if (!table_desc->aml_start) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null AML pointer\n"));
@@ -242,13 +94,13 @@
 
 	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_DEBUG_PRINT ((ACPI_DB_ERROR, "Zero-length AML block\n"));
-		return_ACPI_STATUS (AE_BAD_PARAMETER);
+		ACPI_REPORT_WARNING (("Zero-length AML block in table [%4.4s]\n", table_desc->pointer->signature));
+		return_ACPI_STATUS (AE_OK);
 	}
 
-
 	/*
 	 * Parse the table and load the namespace with all named
 	 * objects found within.  Control methods are NOT parsed
@@ -260,9 +112,13 @@
 	 */
 	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Loading table into namespace ****\n"));
 
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
 	status = acpi_ns_parse_table (table_desc, node->child);
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 
 	if (ACPI_FAILURE (status)) {
 		return_ACPI_STATUS (status);
@@ -288,9 +144,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_load_table_by_type
+ * FUNCTION:    acpi_ns_load_table_by_type
  *
- * PARAMETERS:  Table_type          - Id of the table type to load
+ * PARAMETERS:  table_type          - Id of the table type to load
  *
  * RETURN:      Status
  *
@@ -302,30 +158,31 @@
 
 acpi_status
 acpi_ns_load_table_by_type (
-	acpi_table_type         table_type)
+	acpi_table_type                 table_type)
 {
-	u32                     i;
-	acpi_status             status = AE_OK;
-	acpi_table_desc         *table_desc;
-
+	u32                             i;
+	acpi_status                     status;
+	struct acpi_table_desc          *table_desc;
 
-	FUNCTION_TRACE ("Ns_load_table_by_type");
 
+	ACPI_FUNCTION_TRACE ("ns_load_table_by_type");
 
-	acpi_ut_acquire_mutex (ACPI_MTX_TABLES);
 
+	status = acpi_ut_acquire_mutex (ACPI_MTX_TABLES);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	/*
 	 * Table types supported are:
 	 * DSDT (one), SSDT/PSDT (multiple)
 	 */
 	switch (table_type) {
-
 	case ACPI_TABLE_DSDT:
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading DSDT\n"));
 
-		table_desc = &acpi_gbl_acpi_tables[ACPI_TABLE_DSDT];
+		table_desc = acpi_gbl_table_lists[ACPI_TABLE_DSDT].next;
 
 		/* If table already loaded into namespace, just return */
 
@@ -333,8 +190,6 @@
 			goto unlock_and_exit;
 		}
 
-		table_desc->table_id = TABLE_ID_DSDT;
-
 		/* Now load the single DSDT */
 
 		status = acpi_ns_load_table (table_desc, acpi_gbl_root_node);
@@ -348,13 +203,13 @@
 	case ACPI_TABLE_SSDT:
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading %d SSDTs\n",
-			acpi_gbl_acpi_tables[ACPI_TABLE_SSDT].count));
+			acpi_gbl_table_lists[ACPI_TABLE_SSDT].count));
 
 		/*
 		 * Traverse list of SSDT tables
 		 */
-		table_desc = &acpi_gbl_acpi_tables[ACPI_TABLE_SSDT];
-		for (i = 0; i < acpi_gbl_acpi_tables[ACPI_TABLE_SSDT].count; i++) {
+		table_desc = acpi_gbl_table_lists[ACPI_TABLE_SSDT].next;
+		for (i = 0; i < acpi_gbl_table_lists[ACPI_TABLE_SSDT].count; i++) {
 			/*
 			 * Only attempt to load table if it is not
 			 * already loaded!
@@ -376,14 +231,14 @@
 	case ACPI_TABLE_PSDT:
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading %d PSDTs\n",
-			acpi_gbl_acpi_tables[ACPI_TABLE_PSDT].count));
+			acpi_gbl_table_lists[ACPI_TABLE_PSDT].count));
 
 		/*
 		 * Traverse list of PSDT tables
 		 */
-		table_desc = &acpi_gbl_acpi_tables[ACPI_TABLE_PSDT];
+		table_desc = acpi_gbl_table_lists[ACPI_TABLE_PSDT].next;
 
-		for (i = 0; i < acpi_gbl_acpi_tables[ACPI_TABLE_PSDT].count; i++) {
+		for (i = 0; i < acpi_gbl_table_lists[ACPI_TABLE_PSDT].count; i++) {
 			/* Only attempt to load table if it is not already loaded! */
 
 			if (!table_desc->loaded_into_namespace) {
@@ -408,43 +263,92 @@
 
 
 unlock_and_exit:
+	(void) acpi_ut_release_mutex (ACPI_MTX_TABLES);
+	return_ACPI_STATUS (status);
+}
 
-	acpi_ut_release_mutex (ACPI_MTX_TABLES);
 
-	return_ACPI_STATUS (status);
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_load_namespace
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Load the name space from what ever is pointed to by DSDT.
+ *              (DSDT points to either the BIOS or a buffer.)
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ns_load_namespace (
+	void)
+{
+	acpi_status                     status;
+
 
+	ACPI_FUNCTION_TRACE ("acpi_load_name_space");
+
+
+	/* There must be at least a DSDT installed */
+
+	if (acpi_gbl_DSDT == NULL) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "DSDT is not in memory\n"));
+		return_ACPI_STATUS (AE_NO_ACPI_TABLES);
+	}
+
+	/*
+	 * Load the namespace.  The DSDT is required,
+	 * but the SSDT and PSDT tables are optional.
+	 */
+	status = acpi_ns_load_table_by_type (ACPI_TABLE_DSDT);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/* Ignore exceptions from these */
+
+	(void) acpi_ns_load_table_by_type (ACPI_TABLE_SSDT);
+	(void) acpi_ns_load_table_by_type (ACPI_TABLE_PSDT);
+
+	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
+		"ACPI Namespace successfully loaded at root %p\n",
+		acpi_gbl_root_node));
+
+	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_delete_subtree
+ * FUNCTION:    acpi_ns_delete_subtree
  *
- * PARAMETERS:  Start_handle        - Handle in namespace where search begins
+ * PARAMETERS:  start_handle        - Handle in namespace where search begins
  *
  * RETURNS      Status
  *
  * DESCRIPTION: Walks the namespace starting at the given handle and deletes
  *              all objects, entries, and scopes in the entire subtree.
  *
- *              TBD: [Investigate] What if any part of this subtree is in use?
- *              (i.e. on one of the object stacks?)
+ *              Namespace/Interpreter should be locked or the subsystem should
+ *              be in shutdown before this routine is called.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ns_delete_subtree (
-	acpi_handle             start_handle)
+	acpi_handle                     start_handle)
 {
-	acpi_status             status;
-	acpi_handle             child_handle;
-	acpi_handle             parent_handle;
-	acpi_handle             next_child_handle;
-	acpi_handle             dummy;
-	u32                     level;
+	acpi_status                     status;
+	acpi_handle                     child_handle;
+	acpi_handle                     parent_handle;
+	acpi_handle                     next_child_handle;
+	acpi_handle                     dummy;
+	u32                             level;
 
 
-	FUNCTION_TRACE ("Ns_delete_subtree");
+	ACPI_FUNCTION_TRACE ("ns_delete_subtree");
 
 
 	parent_handle = start_handle;
@@ -463,7 +367,6 @@
 
 		child_handle = next_child_handle;
 
-
 		/* Did we get a new object? */
 
 		if (ACPI_SUCCESS (status)) {
@@ -480,7 +383,6 @@
 				child_handle = 0;
 			}
 		}
-
 		else {
 			/*
 			 * No more children in this object, go back up to
@@ -493,7 +395,10 @@
 			acpi_ns_delete_children (child_handle);
 
 			child_handle = parent_handle;
-			acpi_get_parent (parent_handle, &parent_handle);
+			status = acpi_get_parent (parent_handle, &parent_handle);
+			if (ACPI_FAILURE (status)) {
+				return_ACPI_STATUS (status);
+			}
 		}
 	}
 
@@ -507,7 +412,7 @@
 
 /*******************************************************************************
  *
- *  FUNCTION:       Acpi_ns_unload_name_space
+ *  FUNCTION:       acpi_ns_unload_name_space
  *
  *  PARAMETERS:     Handle          - Root of namespace subtree to be deleted
  *
@@ -521,12 +426,12 @@
 
 acpi_status
 acpi_ns_unload_namespace (
-	acpi_handle             handle)
+	acpi_handle                     handle)
 {
-	acpi_status             status;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Ns_unload_name_space");
+	ACPI_FUNCTION_TRACE ("ns_unload_name_space");
 
 
 	/* Parameter validation */
@@ -539,7 +444,6 @@
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-
 	/* This function does the real work */
 
 	status = acpi_ns_delete_subtree (handle);
@@ -547,4 +451,5 @@
 	return_ACPI_STATUS (status);
 }
 
+#endif
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/namespace/nsnames.c linux-2.4.22-pre2/drivers/acpi/namespace/nsnames.c
--- linux-2.4.21/drivers/acpi/namespace/nsnames.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/namespace/nsnames.c	2003-06-26 21:43:34.000000000 +0000
@@ -1,126 +1,175 @@
 /*******************************************************************************
  *
  * Module Name: nsnames - Name manipulation and search
- *              $Revision: 64 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "amlcode.h"
-#include "acinterp.h"
-#include "acnamesp.h"
+#include <acpi/acpi.h>
+#include <acpi/amlcode.h>
+#include <acpi/acnamesp.h>
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-	 MODULE_NAME         ("nsnames")
+	 ACPI_MODULE_NAME    ("nsnames")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_get_table_pathname
+ * FUNCTION:    acpi_ns_build_external_path
  *
- * PARAMETERS:  Node        - Scope whose name is needed
+ * PARAMETERS:  Node            - NS node whose pathname is needed
+ *              Size            - Size of the pathname
+ *              *name_buffer    - Where to return the pathname
  *
- * RETURN:      Pointer to storage containing the fully qualified name of
- *              the scope, in Label format (all segments strung together
- *              with no separators)
+ * RETURN:      Places the pathname into the name_buffer, in external format
+ *              (name segments separated by path separators)
  *
- * DESCRIPTION: Used for debug printing in Acpi_ns_search_table().
+ * DESCRIPTION: Generate a full pathaname
  *
  ******************************************************************************/
 
-NATIVE_CHAR *
-acpi_ns_get_table_pathname (
-	acpi_namespace_node     *node)
+void
+acpi_ns_build_external_path (
+	struct acpi_namespace_node      *node,
+	acpi_size                       size,
+	char                            *name_buffer)
 {
-	NATIVE_CHAR             *name_buffer;
-	u32                     size;
-	acpi_name               name;
-	acpi_namespace_node     *child_node;
-	acpi_namespace_node     *parent_node;
+	acpi_size                       index;
+	struct acpi_namespace_node      *parent_node;
 
 
-	FUNCTION_TRACE_PTR ("Ns_get_table_pathname", node);
+	ACPI_FUNCTION_NAME ("ns_build_external_path");
 
 
-	if (!acpi_gbl_root_node || !node) {
-		/*
-		 * If the name space has not been initialized,
-		 * this function should not have been called.
-		 */
-		return_PTR (NULL);
+	/* Special case for root */
+
+	index = size - 1;
+	if (index < ACPI_NAME_SIZE) {
+		name_buffer[0] = AML_ROOT_PREFIX;
+		name_buffer[1] = 0;
+		return;
 	}
 
-	child_node = node->child;
+	/* Store terminator byte, then build name backwards */
 
+	parent_node = node;
+	name_buffer[index] = 0;
 
-	/* Calculate required buffer size based on depth below root */
+	while ((index > ACPI_NAME_SIZE) && (parent_node != acpi_gbl_root_node)) {
+		index -= ACPI_NAME_SIZE;
+
+		/* Put the name into the buffer */
 
-	size = 1;
-	parent_node = child_node;
-	while (parent_node) {
-		parent_node = acpi_ns_get_parent_object (parent_node);
-		if (parent_node) {
-			size += ACPI_NAME_SIZE;
-		}
+		ACPI_MOVE_32_TO_32 ((name_buffer + index), &parent_node->name);
+		parent_node = acpi_ns_get_parent_node (parent_node);
+
+		/* Prefix name with the path separator */
+
+		index--;
+		name_buffer[index] = ACPI_PATH_SEPARATOR;
 	}
 
+	/* Overwrite final separator with the root prefix character */
 
-	/* Allocate a buffer to be returned to caller */
+	name_buffer[index] = AML_ROOT_PREFIX;
 
-	name_buffer = ACPI_MEM_CALLOCATE (size + 1);
-	if (!name_buffer) {
-		REPORT_ERROR (("Ns_get_table_pathname: allocation failure\n"));
-		return_PTR (NULL);
+	if (index != 0) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"Could not construct pathname; index=%X, size=%X, Path=%s\n",
+			(u32) index, (u32) size, &name_buffer[size]));
 	}
 
+	return;
+}
 
-	/* Store terminator byte, then build name backwards */
 
-	name_buffer[size] = '\0';
-	while ((size > ACPI_NAME_SIZE) &&
-		acpi_ns_get_parent_object (child_node)) {
-		size -= ACPI_NAME_SIZE;
-		name = acpi_ns_find_parent_name (child_node);
+#ifdef ACPI_DEBUG_OUTPUT
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_get_external_pathname
+ *
+ * PARAMETERS:  Node            - NS node whose pathname is needed
+ *
+ * RETURN:      Pointer to storage containing the fully qualified name of
+ *              the node, In external format (name segments separated by path
+ *              separators.)
+ *
+ * DESCRIPTION: Used for debug printing in acpi_ns_search_table().
+ *
+ ******************************************************************************/
 
-		/* Put the name into the buffer */
+char *
+acpi_ns_get_external_pathname (
+	struct acpi_namespace_node      *node)
+{
+	char                            *name_buffer;
+	acpi_size                       size;
+
+
+	ACPI_FUNCTION_TRACE_PTR ("ns_get_external_pathname", node);
 
-		MOVE_UNALIGNED32_TO_32 ((name_buffer + size), &name);
-		child_node = acpi_ns_get_parent_object (child_node);
-	}
 
-	name_buffer[--size] = AML_ROOT_PREFIX;
+	/* Calculate required buffer size based on depth below root */
+
+	size = acpi_ns_get_pathname_length (node);
+
+	/* Allocate a buffer to be returned to caller */
 
-	if (size != 0) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad pointer returned; size=%X\n", size));
+	name_buffer = ACPI_MEM_CALLOCATE (size);
+	if (!name_buffer) {
+		ACPI_REPORT_ERROR (("ns_get_table_pathname: allocation failure\n"));
+		return_PTR (NULL);
 	}
 
+	/* Build the path in the allocated buffer */
+
+	acpi_ns_build_external_path (node, size, name_buffer);
 	return_PTR (name_buffer);
 }
+#endif
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_get_pathname_length
+ * FUNCTION:    acpi_ns_get_pathname_length
  *
  * PARAMETERS:  Node        - Namespace node
  *
@@ -130,31 +179,27 @@
  *
  ******************************************************************************/
 
-u32
+acpi_size
 acpi_ns_get_pathname_length (
-	acpi_namespace_node     *node)
+	struct acpi_namespace_node      *node)
 {
-	u32                     size;
-	acpi_namespace_node     *next_node;
+	acpi_size                       size;
+	struct acpi_namespace_node      *next_node;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/*
 	 * Compute length of pathname as 5 * number of name segments.
 	 * Go back up the parent tree to the root
 	 */
-	for (size = 0, next_node = node;
-		  acpi_ns_get_parent_object (next_node);
-		  next_node = acpi_ns_get_parent_object (next_node)) {
-		size += PATH_SEGMENT_LENGTH;
-	}
-
-	/* Special case for size still 0 - no parent for "special" nodes */
+	size = 0;
+	next_node = node;
 
-	if (!size) {
-		size = PATH_SEGMENT_LENGTH;
+	while (next_node && (next_node != acpi_gbl_root_node)) {
+		size += ACPI_PATH_SEGMENT_LENGTH;
+		next_node = acpi_ns_get_parent_node (next_node);
 	}
 
 	return (size + 1);
@@ -163,100 +208,53 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_handle_to_pathname
+ * FUNCTION:    acpi_ns_handle_to_pathname
  *
- * PARAMETERS:  Target_handle           - Handle of named object whose name is
+ * PARAMETERS:  target_handle           - Handle of named object whose name is
  *                                        to be found
- *              Buf_size                - Size of the buffer provided
- *              User_buffer             - Where the pathname is returned
+ *              Buffer                  - Where the pathname is returned
  *
  * RETURN:      Status, Buffer is filled with pathname if status is AE_OK
  *
  * DESCRIPTION: Build and return a full namespace pathname
  *
- * MUTEX:       Locks Namespace
- *
  ******************************************************************************/
 
 acpi_status
 acpi_ns_handle_to_pathname (
-	acpi_handle             target_handle,
-	u32                     *buf_size,
-	NATIVE_CHAR             *user_buffer)
+	acpi_handle                     target_handle,
+	struct acpi_buffer              *buffer)
 {
-	acpi_status             status = AE_OK;
-	acpi_namespace_node     *node;
-	u32                     path_length;
-	u32                     user_buf_size;
-	acpi_name               name;
-	u32                     size;
-
-
-	FUNCTION_TRACE_PTR ("Ns_handle_to_pathname", target_handle);
-
-
-	if (!acpi_gbl_root_node) {
-		/*
-		 * If the name space has not been initialized,
-		 * this function should not have been called.
-		 */
-		return_ACPI_STATUS (AE_NO_NAMESPACE);
-	}
+	acpi_status                     status;
+	struct acpi_namespace_node      *node;
+	acpi_size                       required_size;
 
-	node = acpi_ns_map_handle_to_node (target_handle);
-	if (!node) {
-		return_ACPI_STATUS (AE_BAD_PARAMETER);
-	}
-
-
-	/* Set return length to the required path length */
-
-	path_length = acpi_ns_get_pathname_length (node);
-	size = path_length - 1;
 
-	user_buf_size = *buf_size;
-	*buf_size = path_length;
+	ACPI_FUNCTION_TRACE_PTR ("ns_handle_to_pathname", target_handle);
 
-	/* Check if the user buffer is sufficiently large */
 
-	if (path_length > user_buf_size) {
-		status = AE_BUFFER_OVERFLOW;
-		goto exit;
+	node = acpi_ns_map_handle_to_node (target_handle);
+	if (!node) {
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-	/* Store null terminator */
+	/* Determine size required for the caller buffer */
 
-	user_buffer[size] = 0;
-	size -= ACPI_NAME_SIZE;
+	required_size = acpi_ns_get_pathname_length (node);
 
-	/* Put the original ACPI name at the end of the path */
+	/* Validate/Allocate/Clear caller buffer */
 
-	MOVE_UNALIGNED32_TO_32 ((user_buffer + size),
-			 &node->name);
-
-	user_buffer[--size] = PATH_SEPARATOR;
-
-	/* Build name backwards, putting "." between segments */
-
-	while ((size > ACPI_NAME_SIZE) && node) {
-		size -= ACPI_NAME_SIZE;
-		name = acpi_ns_find_parent_name (node);
-		MOVE_UNALIGNED32_TO_32 ((user_buffer + size), &name);
-
-		user_buffer[--size] = PATH_SEPARATOR;
-		node = acpi_ns_get_parent_object (node);
+	status = acpi_ut_initialize_buffer (buffer, required_size);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
 	}
 
-	/*
-	 * Overlay the "." preceding the first segment with
-	 * the root name "\"
-	 */
-	user_buffer[size] = '\\';
+	/* Build the path in the caller buffer */
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Len=%X, %s \n", path_length, user_buffer));
+	acpi_ns_build_external_path (node, required_size, buffer->pointer);
 
-exit:
-	return_ACPI_STATUS (status);
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X] \n", (char *) buffer->pointer, (u32) required_size));
+	return_ACPI_STATUS (AE_OK);
 }
 
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/namespace/nsobject.c linux-2.4.22-pre2/drivers/acpi/namespace/nsobject.c
--- linux-2.4.21/drivers/acpi/namespace/nsobject.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/namespace/nsobject.c	2003-06-26 21:43:18.000000000 +0000
@@ -2,43 +2,58 @@
  *
  * Module Name: nsobject - Utilities for objects attached to namespace
  *                         table entries
- *              $Revision: 67 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "amlcode.h"
-#include "acnamesp.h"
-#include "acinterp.h"
-#include "actables.h"
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-	 MODULE_NAME         ("nsobject")
+	 ACPI_MODULE_NAME    ("nsobject")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_attach_object
+ * FUNCTION:    acpi_ns_attach_object
  *
  * PARAMETERS:  Node                - Parent Node
  *              Object              - Object to be attached
@@ -48,6 +63,8 @@
  * DESCRIPTION: Record the given object as the value associated with the
  *              name whose acpi_handle is passed.  If Object is NULL
  *              and Type is ACPI_TYPE_ANY, set the name as having no value.
+ *              Note: Future may require that the Node->Flags field be passed
+ *              as a parameter.
  *
  * MUTEX:       Assumes namespace is locked
  *
@@ -55,206 +72,169 @@
 
 acpi_status
 acpi_ns_attach_object (
-	acpi_namespace_node     *node,
-	acpi_operand_object     *object,
-	acpi_object_type8       type)
+	struct acpi_namespace_node      *node,
+	union acpi_operand_object       *object,
+	acpi_object_type                type)
 {
-	acpi_operand_object     *obj_desc;
-	acpi_operand_object     *previous_obj_desc;
-	acpi_object_type8       obj_type = ACPI_TYPE_ANY;
-	u8                      flags;
+	union acpi_operand_object       *obj_desc;
+	union acpi_operand_object       *last_obj_desc;
+	acpi_object_type                object_type = ACPI_TYPE_ANY;
 
 
-	FUNCTION_TRACE ("Ns_attach_object");
+	ACPI_FUNCTION_TRACE ("ns_attach_object");
 
 
 	/*
 	 * Parameter validation
 	 */
-	if (!acpi_gbl_root_node) {
-		/* Name space not initialized  */
-
-		REPORT_ERROR (("Ns_attach_object: Namespace not initialized\n"));
-		return_ACPI_STATUS (AE_NO_NAMESPACE);
-	}
-
 	if (!node) {
 		/* Invalid handle */
 
-		REPORT_ERROR (("Ns_attach_object: Null Named_obj handle\n"));
+		ACPI_REPORT_ERROR (("ns_attach_object: Null named_obj handle\n"));
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
 	if (!object && (ACPI_TYPE_ANY != type)) {
 		/* Null object */
 
-		REPORT_ERROR (("Ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n"));
+		ACPI_REPORT_ERROR (("ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n"));
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-	if (!VALID_DESCRIPTOR_TYPE (node, ACPI_DESC_TYPE_NAMED)) {
+	if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) {
 		/* Not a name handle */
 
-		REPORT_ERROR (("Ns_attach_object: Invalid handle\n"));
+		ACPI_REPORT_ERROR (("ns_attach_object: Invalid handle\n"));
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
 	/* Check if this object is already attached */
 
 	if (node->object == object) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj %p already installed in Name_obj %p\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj %p already installed in name_obj %p\n",
 			object, node));
 
 		return_ACPI_STATUS (AE_OK);
 	}
 
-
-	/* Get the current flags field of the Node */
-
-	flags = node->flags;
-	flags &= ~ANOBJ_AML_ATTACHMENT;
-
-
 	/* If null object, we will just install it */
 
 	if (!object) {
-		obj_desc = NULL;
-		obj_type = ACPI_TYPE_ANY;
+		obj_desc   = NULL;
+		object_type = ACPI_TYPE_ANY;
 	}
 
 	/*
 	 * If the source object is a namespace Node with an attached object,
 	 * we will use that (attached) object
 	 */
-	else if (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_NAMED) &&
-			((acpi_namespace_node *) object)->object) {
+	else if ((ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) &&
+			((struct acpi_namespace_node *) object)->object) {
 		/*
 		 * Value passed is a name handle and that name has a
 		 * non-null value.  Use that name's value and type.
 		 */
-		obj_desc = ((acpi_namespace_node *) object)->object;
-		obj_type = ((acpi_namespace_node *) object)->type;
-
-		/*
-		 * Copy appropriate flags
-		 */
-		if (((acpi_namespace_node *) object)->flags & ANOBJ_AML_ATTACHMENT) {
-			flags |= ANOBJ_AML_ATTACHMENT;
-		}
+		obj_desc   = ((struct acpi_namespace_node *) object)->object;
+		object_type = ((struct acpi_namespace_node *) object)->type;
 	}
 
-
 	/*
 	 * Otherwise, we will use the parameter object, but we must type
 	 * it first
 	 */
 	else {
-		obj_desc = (acpi_operand_object *) object;
+		obj_desc = (union acpi_operand_object   *) object;
 
-		/* If a valid type (non-ANY) was given, just use it */
-
-		if (ACPI_TYPE_ANY != type) {
-			obj_type = type;
-		}
+		/* Use the given type */
 
-		else {
-			/*
-			 * Cannot figure out the type -- set to Def_any which
-			 * will print as an error in the name table dump
-			 */
-			if (acpi_dbg_level > 0) {
-				DUMP_PATHNAME (node,
-					"Ns_attach_object confused: setting bogus type for ",
-					ACPI_LV_INFO, _COMPONENT);
-
-				if (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_NAMED)) {
-					DUMP_PATHNAME (object, "name ", ACPI_LV_INFO, _COMPONENT);
-				}
-
-				else {
-					DUMP_PATHNAME (object, "object ", ACPI_LV_INFO, _COMPONENT);
-					DUMP_STACK_ENTRY (object);
-				}
-			}
-
-			obj_type = INTERNAL_TYPE_DEF_ANY;
-		}
+		object_type = type;
 	}
 
-
 	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n",
-		obj_desc, node, (char*)&node->name));
+		obj_desc, node, node->name.ascii));
 
+	/* Detach an existing attached object if present */
 
-	/*
-	 * Must increment the new value's reference count
-	 * (if it is an internal object)
-	 */
-	acpi_ut_add_reference (obj_desc);
-
-	/* Save the existing object (if any) for deletion later */
-
-	previous_obj_desc = node->object;
-
-	/* Install the object and set the type, flags */
-
-	node->object   = obj_desc;
-	node->type     = (u8) obj_type;
-	node->flags    |= flags;
-
+	if (node->object) {
+		acpi_ns_detach_object (node);
+	}
 
-	/*
-	 * Delete an existing attached object.
-	 */
-	if (previous_obj_desc) {
-		/* One for the attach to the Node */
+	if (obj_desc) {
+		/*
+		 * Must increment the new value's reference count
+		 * (if it is an internal object)
+		 */
+		acpi_ut_add_reference (obj_desc);
 
-		acpi_ut_remove_reference (previous_obj_desc);
+		/*
+		 * Handle objects with multiple descriptors - walk
+		 * to the end of the descriptor list
+		 */
+		last_obj_desc = obj_desc;
+		while (last_obj_desc->common.next_object) {
+			last_obj_desc = last_obj_desc->common.next_object;
+		}
 
-		/* Now delete */
+		/* Install the object at the front of the object list */
 
-		acpi_ut_remove_reference (previous_obj_desc);
+		last_obj_desc->common.next_object = node->object;
 	}
 
+	node->type     = (u8) object_type;
+	node->object   = obj_desc;
+
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_detach_object
+ * FUNCTION:    acpi_ns_detach_object
  *
- * PARAMETERS:  Node           - An object whose Value will be deleted
+ * PARAMETERS:  Node           - An node whose object will be detached
  *
  * RETURN:      None.
  *
- * DESCRIPTION: Delete the Value associated with a namespace object.  If the
- *              Value is an allocated object, it is freed.  Otherwise, the
- *              field is simply cleared.
+ * DESCRIPTION: Detach/delete an object associated with a namespace node.
+ *              if the object is an allocated object, it is freed.
+ *              Otherwise, the field is simply cleared.
  *
  ******************************************************************************/
 
 void
 acpi_ns_detach_object (
-	acpi_namespace_node     *node)
+	struct acpi_namespace_node      *node)
 {
-	acpi_operand_object     *obj_desc;
+	union acpi_operand_object       *obj_desc;
 
 
-	FUNCTION_TRACE ("Ns_detach_object");
+	ACPI_FUNCTION_TRACE ("ns_detach_object");
 
 
 	obj_desc = node->object;
-	if (!obj_desc) {
+
+	if (!obj_desc ||
+		(ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA)) {
 		return_VOID;
 	}
 
 	/* Clear the entry in all cases */
 
 	node->object = NULL;
+	if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_OPERAND) {
+		node->object = obj_desc->common.next_object;
+		if (node->object &&
+		   (ACPI_GET_OBJECT_TYPE (node->object) != ACPI_TYPE_LOCAL_DATA)) {
+			node->object = node->object->common.next_object;
+		}
+	}
+
+	/* Reset the node type to untyped */
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Object=%p Value=%p Name %4.4s\n",
-		node, obj_desc, (char*)&node->name));
+	node->type = ACPI_TYPE_ANY;
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n",
+		node, node->name.ascii, obj_desc));
 
 	/* Remove one reference on the object (and all subobjects) */
 
@@ -265,30 +245,216 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_get_attached_object
+ * FUNCTION:    acpi_ns_get_attached_object
  *
  * PARAMETERS:  Node             - Parent Node to be examined
  *
  * RETURN:      Current value of the object field from the Node whose
  *              handle is passed
  *
+ * DESCRIPTION: Obtain the object attached to a namespace node.
+ *
  ******************************************************************************/
 
-void *
+union acpi_operand_object *
 acpi_ns_get_attached_object (
-	acpi_namespace_node     *node)
+	struct acpi_namespace_node      *node)
 {
-	FUNCTION_TRACE_PTR ("Ns_get_attached_object", node);
+	ACPI_FUNCTION_TRACE_PTR ("ns_get_attached_object", node);
 
 
 	if (!node) {
-		/* handle invalid */
-
 		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Null Node ptr\n"));
 		return_PTR (NULL);
 	}
 
+	if (!node->object ||
+			((ACPI_GET_DESCRIPTOR_TYPE (node->object) != ACPI_DESC_TYPE_OPERAND) &&
+			 (ACPI_GET_DESCRIPTOR_TYPE (node->object) != ACPI_DESC_TYPE_NAMED))  ||
+		(ACPI_GET_OBJECT_TYPE (node->object) == ACPI_TYPE_LOCAL_DATA)) {
+		return_PTR (NULL);
+	}
+
 	return_PTR (node->object);
 }
 
 
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_get_secondary_object
+ *
+ * PARAMETERS:  Node             - Parent Node to be examined
+ *
+ * RETURN:      Current value of the object field from the Node whose
+ *              handle is passed.
+ *
+ * DESCRIPTION: Obtain a secondary object associated with a namespace node.
+ *
+ ******************************************************************************/
+
+union acpi_operand_object *
+acpi_ns_get_secondary_object (
+	union acpi_operand_object       *obj_desc)
+{
+	ACPI_FUNCTION_TRACE_PTR ("ns_get_secondary_object", obj_desc);
+
+
+	if ((!obj_desc)                                               ||
+		(ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) ||
+		(!obj_desc->common.next_object)                           ||
+		(ACPI_GET_OBJECT_TYPE (obj_desc->common.next_object) == ACPI_TYPE_LOCAL_DATA)) {
+		return_PTR (NULL);
+	}
+
+	return_PTR (obj_desc->common.next_object);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_attach_data
+ *
+ * PARAMETERS:  Node            - Namespace node
+ *              Handler         - Handler to be associated with the data
+ *              Data            - Data to be attached
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Low-level attach data.  Create and attach a Data object.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ns_attach_data (
+	struct acpi_namespace_node      *node,
+	acpi_object_handler             handler,
+	void                            *data)
+{
+	union acpi_operand_object       *prev_obj_desc;
+	union acpi_operand_object       *obj_desc;
+	union acpi_operand_object       *data_desc;
+
+
+	/* We only allow one attachment per handler */
+
+	prev_obj_desc = NULL;
+	obj_desc = node->object;
+	while (obj_desc) {
+		if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) &&
+			(obj_desc->data.handler == handler)) {
+			return (AE_ALREADY_EXISTS);
+		}
+
+		prev_obj_desc = obj_desc;
+		obj_desc = obj_desc->common.next_object;
+	}
+
+	/* Create an internal object for the data */
+
+	data_desc = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_DATA);
+	if (!data_desc) {
+		return (AE_NO_MEMORY);
+	}
+
+	data_desc->data.handler = handler;
+	data_desc->data.pointer = data;
+
+	/* Install the data object */
+
+	if (prev_obj_desc) {
+		prev_obj_desc->common.next_object = data_desc;
+	}
+	else {
+		node->object = data_desc;
+	}
+
+	return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_detach_data
+ *
+ * PARAMETERS:  Node            - Namespace node
+ *              Handler         - Handler associated with the data
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Low-level detach data.  Delete the data node, but the caller
+ *              is responsible for the actual data.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ns_detach_data (
+	struct acpi_namespace_node      *node,
+	acpi_object_handler             handler)
+{
+	union acpi_operand_object       *obj_desc;
+	union acpi_operand_object       *prev_obj_desc;
+
+
+	prev_obj_desc = NULL;
+	obj_desc = node->object;
+	while (obj_desc) {
+		if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) &&
+			(obj_desc->data.handler == handler)) {
+			if (prev_obj_desc) {
+				prev_obj_desc->common.next_object = obj_desc->common.next_object;
+			}
+			else {
+				node->object = obj_desc->common.next_object;
+			}
+
+			acpi_ut_remove_reference (obj_desc);
+			return (AE_OK);
+		}
+
+		prev_obj_desc = obj_desc;
+		obj_desc = obj_desc->common.next_object;
+	}
+
+	return (AE_NOT_FOUND);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_get_attached_data
+ *
+ * PARAMETERS:  Node            - Namespace node
+ *              Handler         - Handler associated with the data
+ *              Data            - Where the data is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Low level interface to obtain data previously associated with
+ *              a namespace node.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ns_get_attached_data (
+	struct acpi_namespace_node      *node,
+	acpi_object_handler             handler,
+	void                            **data)
+{
+	union acpi_operand_object       *obj_desc;
+
+
+	obj_desc = node->object;
+	while (obj_desc) {
+		if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) &&
+			(obj_desc->data.handler == handler)) {
+			*data = obj_desc->data.pointer;
+			return (AE_OK);
+		}
+
+		obj_desc = obj_desc->common.next_object;
+	}
+
+	return (AE_NOT_FOUND);
+}
+
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/namespace/nsparse.c linux-2.4.22-pre2/drivers/acpi/namespace/nsparse.c
--- linux-2.4.21/drivers/acpi/namespace/nsparse.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/namespace/nsparse.c	2003-06-26 21:43:11.000000000 +0000
@@ -0,0 +1,170 @@
+/******************************************************************************
+ *
+ * Module Name: nsparse - namespace interface to AML parser
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acparser.h>
+#include <acpi/acdispat.h>
+
+
+#define _COMPONENT          ACPI_NAMESPACE
+	 ACPI_MODULE_NAME    ("nsparse")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    ns_one_complete_parse
+ *
+ * PARAMETERS:  pass_number             - 1 or 2
+ *              table_desc              - The table to be parsed.
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Perform one complete parse of an ACPI/AML table.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ns_one_complete_parse (
+	u32                             pass_number,
+	struct acpi_table_desc          *table_desc)
+{
+	union acpi_parse_object         *parse_root;
+	acpi_status                     status;
+	struct acpi_walk_state          *walk_state;
+
+
+	ACPI_FUNCTION_TRACE ("ns_one_complete_parse");
+
+
+	/* Create and init a Root Node */
+
+	parse_root = acpi_ps_create_scope_op ();
+	if (!parse_root) {
+		return_ACPI_STATUS (AE_NO_MEMORY);
+	}
+
+	/* Create and initialize a new walk state */
+
+	walk_state = acpi_ds_create_walk_state (table_desc->table_id,
+			   NULL, NULL, NULL);
+	if (!walk_state) {
+		acpi_ps_free_op (parse_root);
+		return_ACPI_STATUS (AE_NO_MEMORY);
+	}
+
+	status = acpi_ds_init_aml_walk (walk_state, parse_root, NULL, table_desc->aml_start,
+			  table_desc->aml_length, NULL, NULL, pass_number);
+	if (ACPI_FAILURE (status)) {
+		acpi_ds_delete_walk_state (walk_state);
+		return_ACPI_STATUS (status);
+	}
+
+	/* Parse the AML */
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "*PARSE* pass %d parse\n", pass_number));
+	status = acpi_ps_parse_aml (walk_state);
+
+	acpi_ps_delete_parse_tree (parse_root);
+	return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_parse_table
+ *
+ * PARAMETERS:  table_desc      - An ACPI table descriptor for table to parse
+ *              start_node      - Where to enter the table into the namespace
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Parse AML within an ACPI table and return a tree of ops
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ns_parse_table (
+	struct acpi_table_desc          *table_desc,
+	struct acpi_namespace_node      *start_node)
+{
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_TRACE ("ns_parse_table");
+
+
+	/*
+	 * AML Parse, pass 1
+	 *
+	 * In this pass, we load most of the namespace.  Control methods
+	 * are not parsed until later.  A parse tree is not created.  Instead,
+	 * each Parser Op subtree is deleted when it is finished.  This saves
+	 * a great deal of memory, and allows a small cache of parse objects
+	 * to service the entire parse.  The second pass of the parse then
+	 * performs another complete parse of the AML..
+	 */
+	status = acpi_ns_one_complete_parse (1, table_desc);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/*
+	 * AML Parse, pass 2
+	 *
+	 * In this pass, we resolve forward references and other things
+	 * that could not be completed during the first pass.
+	 * Another complete parse of the AML is performed, but the
+	 * overhead of this is compensated for by the fact that the
+	 * parse objects are all cached.
+	 */
+	status = acpi_ns_one_complete_parse (2, table_desc);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	return_ACPI_STATUS (status);
+}
+
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/namespace/nssearch.c linux-2.4.22-pre2/drivers/acpi/namespace/nssearch.c
--- linux-2.4.21/drivers/acpi/namespace/nssearch.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/namespace/nssearch.c	2003-06-26 21:43:32.000000000 +0000
@@ -1,52 +1,69 @@
 /*******************************************************************************
  *
  * Module Name: nssearch - Namespace search
- *              $Revision: 75 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "amlcode.h"
-#include "acinterp.h"
-#include "acnamesp.h"
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-	 MODULE_NAME         ("nssearch")
+	 ACPI_MODULE_NAME    ("nssearch")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_search_node
+ * FUNCTION:    acpi_ns_search_node
  *
- * PARAMETERS:  *Target_name        - Ascii ACPI name to search for
- *              *Node               - Starting table where search will begin
+ * 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 Named obj is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Search a single namespace table.  Performs a simple search,
- *              does not add entries or search parents.
+ * DESCRIPTION: Search a single level of the namespace.  Performs a
+ *              simple search of the specified level, and does not add
+ *              entries or search parents.
  *
  *
  *      Named object lists are built (and subsequently dumped) in the
@@ -62,75 +79,52 @@
 
 acpi_status
 acpi_ns_search_node (
-	u32                     target_name,
-	acpi_namespace_node     *node,
-	acpi_object_type8       type,
-	acpi_namespace_node     **return_node)
+	u32                             target_name,
+	struct acpi_namespace_node      *node,
+	acpi_object_type                type,
+	struct acpi_namespace_node      **return_node)
 {
-	acpi_namespace_node     *next_node;
+	struct acpi_namespace_node      *next_node;
 
 
-	FUNCTION_TRACE ("Ns_search_node");
+	ACPI_FUNCTION_TRACE ("ns_search_node");
 
 
-#ifdef ACPI_DEBUG
+#ifdef ACPI_DEBUG_OUTPUT
 	if (ACPI_LV_NAMES & acpi_dbg_level) {
-		NATIVE_CHAR         *scope_name;
+		char                        *scope_name;
 
-		scope_name = acpi_ns_get_table_pathname (node);
+		scope_name = acpi_ns_get_external_pathname (node);
 		if (scope_name) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching %s [%p] For %4.4s (type %X)\n",
-				scope_name, node, (char*)&target_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);
 		}
 	}
 #endif
 
-
 	/*
-	 * Search for name in this table, which is to say that we must search
-	 * for the name among the children of this object
+	 * Search for name at this namespace level, which is to say that we
+	 * must search for the name among the children of this object
 	 */
 	next_node = node->child;
 	while (next_node) {
 		/* Check for match against the name */
 
-		if (next_node->name == target_name) {
-			/*
-			 * Found matching entry.  Capture the type if appropriate, before
-			 * returning the entry.
-			 *
-			 * The Def_field_defn and Bank_field_defn cases are actually looking up
-			 * the Region in which the field will be defined
-			 */
-			if ((INTERNAL_TYPE_FIELD_DEFN == type) ||
-				(INTERNAL_TYPE_BANK_FIELD_DEFN == type)) {
-				type = ACPI_TYPE_REGION;
-			}
-
+		if (next_node->name.integer == target_name) {
 			/*
-			 * Scope, Def_any, and Index_field_defn are bogus "types" which do not
-			 * actually have anything to do with the type of the name being
-			 * looked up.  For any other value of Type, if the type stored in
-			 * the entry is Any (i.e. unknown), save the actual type.
+			 * Found matching entry.
 			 */
-			if (type != INTERNAL_TYPE_SCOPE &&
-				type != INTERNAL_TYPE_DEF_ANY &&
-				type != INTERNAL_TYPE_INDEX_FIELD_DEFN &&
-				next_node->type == ACPI_TYPE_ANY) {
-				next_node->type = (u8) type;
-			}
-
 			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
-				"Name %4.4s (actual type %X) found at %p\n",
-				(char*)&target_name, next_node->type, next_node));
+				"Name %4.4s Type [%s] found in scope [%4.4s] %p\n",
+				(char *) &target_name, acpi_ut_get_type_name (next_node->type),
+				next_node->name.ascii, next_node));
 
 			*return_node = next_node;
 			return_ACPI_STATUS (AE_OK);
 		}
 
-
 		/*
 		 * The last entry in the list points back to the parent,
 		 * so a flag is used to indicate the end-of-list
@@ -146,11 +140,12 @@
 		next_node = next_node->peer;
 	}
 
+	/* Searched entire namespace level, not found */
 
-	/* Searched entire table, not found */
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Name %4.4s (type %X) not found at %p\n",
-		(char*)&target_name, type, next_node));
+	ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+		"Name %4.4s Type [%s] not found in search in scope [%4.4s] %p first child %p\n",
+		(char *) &target_name, acpi_ut_get_type_name (type),
+		node->name.ascii, node, node->child));
 
 	return_ACPI_STATUS (AE_NOT_FOUND);
 }
@@ -158,18 +153,18 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_search_parent_tree
+ * FUNCTION:    acpi_ns_search_parent_tree
  *
- * PARAMETERS:  *Target_name        - Ascii ACPI name to search for
- *              *Node               - Starting table where search will begin
+ * 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 Named Obj is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Called when a name has not been found in the current namespace
- *              table.  Before adding it or giving up, ACPI scope rules require
- *              searching enclosing scopes in cases identified by Acpi_ns_local().
+ *              level.  Before adding it or giving up, ACPI scope rules require
+ *              searching enclosing scopes in cases identified by acpi_ns_local().
  *
  *              "A name is located by finding the matching name in the current
  *              name space, and then in the parent name space. If the parent
@@ -183,55 +178,53 @@
 
 static acpi_status
 acpi_ns_search_parent_tree (
-	u32                     target_name,
-	acpi_namespace_node     *node,
-	acpi_object_type8       type,
-	acpi_namespace_node     **return_node)
+	u32                             target_name,
+	struct acpi_namespace_node      *node,
+	acpi_object_type                type,
+	struct acpi_namespace_node      **return_node)
 {
-	acpi_status             status;
-	acpi_namespace_node     *parent_node;
+	acpi_status                     status;
+	struct acpi_namespace_node      *parent_node;
 
 
-	FUNCTION_TRACE ("Ns_search_parent_tree");
+	ACPI_FUNCTION_TRACE ("ns_search_parent_tree");
 
 
-	parent_node = acpi_ns_get_parent_object (node);
+	parent_node = acpi_ns_get_parent_node (node);
 
 	/*
-	 * If there is no parent (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 ((acpi_ns_local (type)) ||
-		(!parent_node)) {
-		if (!parent_node) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n",
-				(char*)&target_name));
-		}
-
-		if (acpi_ns_local (type)) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] type %X is local(no search)\n",
-				(char*)&target_name, type));
-		}
+	if (!parent_node) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n",
+			(char *) &target_name));
+		 return_ACPI_STATUS (AE_NOT_FOUND);
+	}
 
+	if (acpi_ns_local (type)) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+			"[%4.4s] type [%s] must be local to this scope (no parent search)\n",
+			(char *) &target_name, acpi_ut_get_type_name (type)));
 		return_ACPI_STATUS (AE_NOT_FOUND);
 	}
 
-
 	/* 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 for %4.4s\n", (char *) &target_name));
 
 	/*
 	 * Search parents until found the target or we have backed up to
 	 * the root
 	 */
 	while (parent_node) {
-		/* Search parent scope */
-		/* TBD: [Investigate] Why ACPI_TYPE_ANY? */
-
+		/*
+		 * Search parent scope.  Use TYPE_ANY because we don't care about the
+		 * object type at this point, we only care about the existence of
+		 * the actual name we are searching for.  Typechecking comes later.
+		 */
 		status = acpi_ns_search_node (target_name, parent_node,
 				   ACPI_TYPE_ANY, return_node);
-
 		if (ACPI_SUCCESS (status)) {
 			return_ACPI_STATUS (status);
 		}
@@ -240,10 +233,9 @@
 		 * Not found here, go up another level
 		 * (until we reach the root)
 		 */
-		parent_node = acpi_ns_get_parent_object (parent_node);
+		parent_node = acpi_ns_get_parent_node (parent_node);
 	}
 
-
 	/* Not found in parent tree */
 
 	return_ACPI_STATUS (AE_NOT_FOUND);
@@ -252,71 +244,67 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_search_and_enter
+ * FUNCTION:    acpi_ns_search_and_enter
  *
- * PARAMETERS:  Target_name         - Ascii ACPI name to search for (4 chars)
- *              Walk_state          - Current state of the walk
- *              *Node               - Starting table where search will begin
- *              Interpreter_mode    - Add names only in MODE_Load_pass_x.
+ * PARAMETERS:  target_name         - Ascii ACPI name to search for (4 chars)
+ *              walk_state          - Current state of the walk
+ *              *Node               - Starting node where search will begin
+ *              interpreter_mode    - Add names only in ACPI_MODE_LOAD_PASS_x.
  *                                    Otherwise,search only.
  *              Type                - Object type to match
  *              Flags               - Flags describing the search restrictions
- *              **Return_node       - Where the Node is returned
+ *              **return_node       - Where the Node is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Search for a name segment in a single name table,
+ * DESCRIPTION: Search for a name segment in a single namespace level,
  *              optionally adding it if it is not found.  If the passed
  *              Type is not Any and the type previously stored in the
  *              entry was Any (i.e. unknown), update the stored type.
  *
- *              In IMODE_EXECUTE, search only.
+ *              In ACPI_IMODE_EXECUTE, search only.
  *              In other modes, search and add if not found.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ns_search_and_enter (
-	u32                     target_name,
-	acpi_walk_state         *walk_state,
-	acpi_namespace_node     *node,
-	operating_mode          interpreter_mode,
-	acpi_object_type8       type,
-	u32                     flags,
-	acpi_namespace_node     **return_node)
+	u32                             target_name,
+	struct acpi_walk_state          *walk_state,
+	struct acpi_namespace_node      *node,
+	acpi_interpreter_mode           interpreter_mode,
+	acpi_object_type                type,
+	u32                             flags,
+	struct acpi_namespace_node      **return_node)
 {
-	acpi_status             status;
-	acpi_namespace_node     *new_node;
+	acpi_status                     status;
+	struct acpi_namespace_node      *new_node;
 
 
-	FUNCTION_TRACE ("Ns_search_and_enter");
+	ACPI_FUNCTION_TRACE ("ns_search_and_enter");
 
 
 	/* Parameter validation */
 
 	if (!node || !target_name || !return_node) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null param-  Table %p Name %X Return %p\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null param: Node %p Name %X return_node %p\n",
 			node, target_name, return_node));
 
-		REPORT_ERROR (("Ns_search_and_enter: bad (null) parameter\n"));
+		ACPI_REPORT_ERROR (("ns_search_and_enter: Null parameter\n"));
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-
 	/* Name must consist of printable characters */
 
 	if (!acpi_ut_valid_acpi_name (target_name)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "*** Bad character in name: %08x *** \n",
+		ACPI_REPORT_ERROR (("ns_search_and_enter: Bad character in ACPI Name: %X\n",
 			target_name));
-
-		REPORT_ERROR (("Ns_search_and_enter: Bad character in ACPI Name\n"));
 		return_ACPI_STATUS (AE_BAD_CHARACTER);
 	}
 
+	/* Try to find the name in the namespace level specified by the caller */
 
-	/* Try to find the name in the table specified by the caller */
-
-	*return_node = ENTRY_NOT_FOUND;
+	*return_node = ACPI_ENTRY_NOT_FOUND;
 	status = acpi_ns_search_node (target_name, node, type, return_node);
 	if (status != AE_NOT_FOUND) {
 		/*
@@ -324,8 +312,8 @@
 		 * return the error
 		 */
 		if ((status == AE_OK) &&
-			(flags & NS_ERROR_IF_FOUND)) {
-			status = AE_EXIST;
+			(flags & ACPI_NS_ERROR_IF_FOUND)) {
+			status = AE_ALREADY_EXISTS;
 		}
 
 		/*
@@ -335,9 +323,8 @@
 		return_ACPI_STATUS (status);
 	}
 
-
 	/*
-	 * Not found in the table.  If we are NOT performing the
+	 * 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
@@ -345,10 +332,10 @@
 	 * the search when namespace references are being resolved
 	 * (load pass 2) and during the execution phase.
 	 */
-	if ((interpreter_mode != IMODE_LOAD_PASS1) &&
-		(flags & NS_SEARCH_PARENT)) {
+	if ((interpreter_mode != ACPI_IMODE_LOAD_PASS1) &&
+		(flags & ACPI_NS_SEARCH_PARENT)) {
 		/*
-		 * Not found in table - search parent tree according
+		 * Not found at this level - search parent tree according
 		 * to ACPI specification
 		 */
 		status = acpi_ns_search_parent_tree (target_name, node,
@@ -358,18 +345,16 @@
 		}
 	}
 
-
 	/*
 	 * In execute mode, just search, never add names.  Exit now.
 	 */
-	if (interpreter_mode == IMODE_EXECUTE) {
+	if (interpreter_mode == ACPI_IMODE_EXECUTE) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%4.4s Not found in %p [Not adding]\n",
-			(char*)&target_name, node));
+			(char *) &target_name, node));
 
 		return_ACPI_STATUS (AE_NOT_FOUND);
 	}
 
-
 	/* Create the new named object */
 
 	new_node = acpi_ns_create_node (target_name);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/namespace/nsutils.c linux-2.4.22-pre2/drivers/acpi/namespace/nsutils.c
--- linux-2.4.21/drivers/acpi/namespace/nsutils.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/namespace/nsutils.c	2003-06-26 21:43:21.000000000 +0000
@@ -2,42 +2,198 @@
  *
  * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing
  *                        parents and siblings and Scope manipulation
- *              $Revision: 92 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acnamesp.h"
-#include "acinterp.h"
-#include "amlcode.h"
-#include "actables.h"
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
+#include <acpi/amlcode.h>
+#include <acpi/actables.h>
 
 #define _COMPONENT          ACPI_NAMESPACE
-	 MODULE_NAME         ("nsutils")
+	 ACPI_MODULE_NAME    ("nsutils")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_valid_root_prefix
+ * FUNCTION:    acpi_ns_report_error
+ *
+ * PARAMETERS:  module_name         - Caller's module name (for error output)
+ *              line_number         - Caller's line number (for error output)
+ *              component_id        - Caller's component ID (for error output)
+ *              Message             - Error message to use on failure
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Print warning message with full pathname
+ *
+ ******************************************************************************/
+
+void
+acpi_ns_report_error (
+	char                            *module_name,
+	u32                             line_number,
+	u32                             component_id,
+	char                            *internal_name,
+	acpi_status                     lookup_status)
+{
+	acpi_status                     status;
+	char                            *name = NULL;
+
+
+	acpi_os_printf ("%8s-%04d: *** Error: Looking up ",
+		module_name, line_number);
+
+	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)));
+	}
+	else {
+		/* Convert path to external format */
+
+		status = acpi_ns_externalize_name (ACPI_UINT32_MAX, internal_name, NULL, &name);
+
+		/* Print target name */
+
+		if (ACPI_SUCCESS (status)) {
+			acpi_os_printf ("[%s]", name);
+		}
+		else {
+			acpi_os_printf ("[COULD NOT EXTERNALIZE NAME]");
+		}
+
+		if (name) {
+			ACPI_MEM_FREE (name);
+		}
+	}
+
+	acpi_os_printf (" in namespace, %s\n",
+		acpi_format_exception (lookup_status));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_report_method_error
+ *
+ * PARAMETERS:  module_name         - Caller's module name (for error output)
+ *              line_number         - Caller's line number (for error output)
+ *              component_id        - Caller's component ID (for error output)
+ *              Message             - Error message to use on failure
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Print warning message with full pathname
+ *
+ ******************************************************************************/
+
+void
+acpi_ns_report_method_error (
+	char                            *module_name,
+	u32                             line_number,
+	u32                             component_id,
+	char                            *message,
+	struct acpi_namespace_node      *prefix_node,
+	char                            *path,
+	acpi_status                     method_status)
+{
+	acpi_status                     status;
+	struct acpi_namespace_node      *node = prefix_node;
+
+
+	if (path) {
+		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;
+		}
+	}
+
+	acpi_os_printf ("%8s-%04d: *** Error: ", module_name, line_number);
+	acpi_ns_print_node_pathname (node, message);
+	acpi_os_printf (", %s\n", acpi_format_exception (method_status));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_print_node_pathname
+ *
+ * PARAMETERS:  Node                - Object
+ *              Msg                 - Prefix message
+ *
+ * DESCRIPTION: Print an object's full namespace pathname
+ *              Manages allocation/freeing of a pathname buffer
+ *
+ ******************************************************************************/
+
+void
+acpi_ns_print_node_pathname (
+	struct acpi_namespace_node      *node,
+	char                            *msg)
+{
+	struct acpi_buffer              buffer;
+	acpi_status                     status;
+
+
+	/* Convert handle to a full pathname and print it (with supplied message) */
+
+	buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
+
+	status = acpi_ns_handle_to_pathname (node, &buffer);
+	if (ACPI_SUCCESS (status)) {
+		if (msg) {
+			acpi_os_printf ("%s ", msg);
+		}
+
+		acpi_os_printf ("[%s] (Node %p)", (char *) buffer.pointer, node);
+		ACPI_MEM_FREE (buffer.pointer);
+	}
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_valid_root_prefix
  *
  * PARAMETERS:  Prefix          - Character to be checked
  *
@@ -49,7 +205,7 @@
 
 u8
 acpi_ns_valid_root_prefix (
-	NATIVE_CHAR             prefix)
+	char                            prefix)
 {
 
 	return ((u8) (prefix == '\\'));
@@ -58,7 +214,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_valid_path_separator
+ * FUNCTION:    acpi_ns_valid_path_separator
  *
  * PARAMETERS:  Sep              - Character to be checked
  *
@@ -70,7 +226,7 @@
 
 u8
 acpi_ns_valid_path_separator (
-	NATIVE_CHAR             sep)
+	char                            sep)
 {
 
 	return ((u8) (sep == '.'));
@@ -79,7 +235,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_get_type
+ * FUNCTION:    acpi_ns_get_type
  *
  * PARAMETERS:  Handle              - Parent Node to be examined
  *
@@ -87,25 +243,25 @@
  *
  ******************************************************************************/
 
-acpi_object_type8
+acpi_object_type
 acpi_ns_get_type (
-	acpi_namespace_node     *node)
+	struct acpi_namespace_node      *node)
 {
-	FUNCTION_TRACE ("Ns_get_type");
+	ACPI_FUNCTION_TRACE ("ns_get_type");
 
 
 	if (!node) {
-		REPORT_WARNING (("Ns_get_type: Null Node ptr"));
+		ACPI_REPORT_WARNING (("ns_get_type: Null Node ptr"));
 		return_VALUE (ACPI_TYPE_ANY);
 	}
 
-	return_VALUE (node->type);
+	return_VALUE ((acpi_object_type) node->type);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_local
+ * FUNCTION:    acpi_ns_local
  *
  * PARAMETERS:  Type            - A namespace object type
  *
@@ -116,25 +272,25 @@
 
 u32
 acpi_ns_local (
-	acpi_object_type8       type)
+	acpi_object_type                type)
 {
-	FUNCTION_TRACE ("Ns_local");
+	ACPI_FUNCTION_TRACE ("ns_local");
 
 
 	if (!acpi_ut_valid_object_type (type)) {
 		/* Type code out of range  */
 
-		REPORT_WARNING (("Ns_local: Invalid Object Type\n"));
-		return_VALUE (NSP_NORMAL);
+		ACPI_REPORT_WARNING (("ns_local: Invalid Object Type\n"));
+		return_VALUE (ACPI_NS_NORMAL);
 	}
 
-	return_VALUE ((u32) acpi_gbl_ns_properties[type] & NSP_LOCAL);
+	return_VALUE ((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_get_internal_name_length
+ * FUNCTION:    acpi_ns_get_internal_name_length
  *
  * PARAMETERS:  Info            - Info struct initialized with the
  *                                external name pointer.
@@ -146,15 +302,15 @@
  *
  ******************************************************************************/
 
-acpi_status
+void
 acpi_ns_get_internal_name_length (
-	acpi_namestring_info    *info)
+	struct acpi_namestring_info     *info)
 {
-	NATIVE_CHAR             *next_external_char;
-	u32                     i;
+	char                            *next_external_char;
+	u32                             i;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	next_external_char = info->external_name;
@@ -164,18 +320,17 @@
 
 	/*
 	 * For the internal name, the required length is 4 bytes
-	 * per segment, plus 1 each for Root_prefix, Multi_name_prefix_op,
+	 * 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
+	 * 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;
 		next_external_char++;
 	}
-
 	else {
 		/*
 		 * Handle Carat prefixes
@@ -205,14 +360,12 @@
 			  4 + info->num_carats;
 
 	info->next_external_char = next_external_char;
-
-	return (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_build_internal_name
+ * FUNCTION:    acpi_ns_build_internal_name
  *
  * PARAMETERS:  Info            - Info struct fully initialized
  *
@@ -225,16 +378,16 @@
 
 acpi_status
 acpi_ns_build_internal_name (
-	acpi_namestring_info    *info)
+	struct acpi_namestring_info     *info)
 {
-	u32                     num_segments = info->num_segments;
-	NATIVE_CHAR             *internal_name = info->internal_name;
-	NATIVE_CHAR             *external_name = info->next_external_char;
-	NATIVE_CHAR             *result = NULL;
-	u32                     i;
+	u32                             num_segments = info->num_segments;
+	char                            *internal_name = info->internal_name;
+	char                            *external_name = info->next_external_char;
+	char                            *result = NULL;
+	acpi_native_uint                i;
 
 
-	FUNCTION_TRACE ("Ns_build_internal_name");
+	ACPI_FUNCTION_TRACE ("ns_build_internal_name");
 
 
 	/* Setup the correct prefixes, counts, and pointers */
@@ -255,7 +408,6 @@
 			result = &internal_name[3];
 		}
 	}
-
 	else {
 		/*
 		 * Not fully qualified.
@@ -268,23 +420,20 @@
 			}
 		}
 
-		if (num_segments == 1) {
+		if (num_segments <= 1) {
 			result = &internal_name[i];
 		}
-
 		else if (num_segments == 2) {
 			internal_name[i] = AML_DUAL_NAME_PREFIX;
-			result = &internal_name[i+1];
+			result = &internal_name[(acpi_native_uint) (i+1)];
 		}
-
 		else {
 			internal_name[i] = AML_MULTI_NAME_PREFIX_OP;
-			internal_name[i+1] = (char) num_segments;
-			result = &internal_name[i+2];
+			internal_name[(acpi_native_uint) (i+1)] = (char) num_segments;
+			result = &internal_name[(acpi_native_uint) (i+2)];
 		}
 	}
 
-
 	/* Build the name (minus path separators) */
 
 	for (; num_segments; num_segments--) {
@@ -295,11 +444,10 @@
 
 				result[i] = '_';
 			}
-
 			else {
 				/* Convert the character to uppercase and save it */
 
-				result[i] = (char) TOUPPER (*external_name);
+				result[i] = (char) ACPI_TOUPPER ((int) *external_name);
 				external_name++;
 			}
 		}
@@ -317,18 +465,17 @@
 		result += ACPI_NAME_SIZE;
 	}
 
-
 	/* Terminate the string */
 
 	*result = 0;
 
 	if (info->fully_qualified) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "returning [%p] (abs) \"\\%s\"\n",
-			internal_name, &internal_name[0]));
+			internal_name, internal_name));
 	}
 	else {
 		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "returning [%p] (rel) \"%s\"\n",
-			internal_name, &internal_name[2]));
+			internal_name, internal_name));
 	}
 
 	return_ACPI_STATUS (AE_OK);
@@ -337,9 +484,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_internalize_name
+ * FUNCTION:    acpi_ns_internalize_name
  *
- * PARAMETERS:  *External_name          - External representation of name
+ * PARAMETERS:  *external_name          - External representation of name
  *              **Converted Name        - Where to return the resulting
  *                                        internal represention of the name
  *
@@ -352,15 +499,15 @@
 
 acpi_status
 acpi_ns_internalize_name (
-	NATIVE_CHAR             *external_name,
-	NATIVE_CHAR             **converted_name)
+	char                            *external_name,
+	char                            **converted_name)
 {
-	NATIVE_CHAR             *internal_name;
-	acpi_namestring_info    info;
-	acpi_status             status;
+	char                            *internal_name;
+	struct acpi_namestring_info     info;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Ns_internalize_name");
+	ACPI_FUNCTION_TRACE ("ns_internalize_name");
 
 
 	if ((!external_name)     ||
@@ -369,7 +516,6 @@
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-
 	/* Get the length of the new internal name */
 
 	info.external_name = external_name;
@@ -398,10 +544,10 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_externalize_name
+ * FUNCTION:    acpi_ns_externalize_name
  *
- * PARAMETERS:  *Internal_name         - Internal representation of name
- *              **Converted_name       - Where to return the resulting
+ * PARAMETERS:  *internal_name         - Internal representation of name
+ *              **converted_name       - Where to return the resulting
  *                                       external representation of name
  *
  * RETURN:      Status
@@ -413,29 +559,28 @@
 
 acpi_status
 acpi_ns_externalize_name (
-	u32                     internal_name_length,
-	char                    *internal_name,
-	u32                     *converted_name_length,
-	char                    **converted_name)
-{
-	u32                     prefix_length = 0;
-	u32                     names_index = 0;
-	u32                     names_count = 0;
-	u32                     i = 0;
-	u32                     j = 0;
+	u32                             internal_name_length,
+	char                            *internal_name,
+	u32                             *converted_name_length,
+	char                            **converted_name)
+{
+	acpi_native_uint                names_index = 0;
+	acpi_native_uint                num_segments = 0;
+	acpi_native_uint                required_length;
+	acpi_native_uint                prefix_length = 0;
+	acpi_native_uint                i = 0;
+	acpi_native_uint                j = 0;
 
 
-	FUNCTION_TRACE ("Ns_externalize_name");
+	ACPI_FUNCTION_TRACE ("ns_externalize_name");
 
 
 	if (!internal_name_length   ||
 		!internal_name          ||
-		!converted_name_length  ||
 		!converted_name) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-
 	/*
 	 * Check for a prefix (one '\' | one or more '^').
 	 */
@@ -446,9 +591,12 @@
 
 	case '^':
 		for (i = 0; i < internal_name_length; i++) {
-			if (internal_name[i] != '^') {
+			if (internal_name[i] == '^') {
 				prefix_length = i + 1;
 			}
+			else {
+				break;
+			}
 		}
 
 		if (i == internal_name_length) {
@@ -456,6 +604,9 @@
 		}
 
 		break;
+
+	default:
+		break;
 	}
 
 	/*
@@ -464,62 +615,61 @@
 	 */
 	if (prefix_length < internal_name_length) {
 		switch (internal_name[prefix_length]) {
+		case AML_MULTI_NAME_PREFIX_OP:
 
-		/* <count> 4-byte names */
+			/* <count> 4-byte names */
 
-		case AML_MULTI_NAME_PREFIX_OP:
 			names_index = prefix_length + 2;
-			names_count = (u32) internal_name[prefix_length + 1];
+			num_segments = (acpi_native_uint) (u8) internal_name[(acpi_native_uint) (prefix_length + 1)];
 			break;
 
+		case AML_DUAL_NAME_PREFIX:
 
-		/* two 4-byte names */
+			/* Two 4-byte names */
 
-		case AML_DUAL_NAME_PREFIX:
 			names_index = prefix_length + 1;
-			names_count = 2;
+			num_segments = 2;
 			break;
 
+		case 0:
 
-		/* Null_name */
+			/* null_name */
 
-		case 0:
 			names_index = 0;
-			names_count = 0;
+			num_segments = 0;
 			break;
 
+		default:
 
-		/* one 4-byte name */
+			/* one 4-byte name */
 
-		default:
 			names_index = prefix_length;
-			names_count = 1;
+			num_segments = 1;
 			break;
 		}
 	}
 
 	/*
-	 * Calculate the length of Converted_name, which equals the length
+	 * Calculate the length of converted_name, which equals the length
 	 * of the prefix, length of all object names, length of any required
 	 * punctuation ('.') between object names, plus the NULL terminator.
 	 */
-	*converted_name_length = prefix_length + (4 * names_count) +
-			   ((names_count > 0) ? (names_count - 1) : 0) + 1;
+	required_length = prefix_length + (4 * num_segments) +
+			   ((num_segments > 0) ? (num_segments - 1) : 0) + 1;
 
 	/*
 	 * Check to see if we're still in bounds.  If not, there's a problem
-	 * with Internal_name (invalid format).
+	 * with internal_name (invalid format).
 	 */
-	if (*converted_name_length > internal_name_length) {
-		REPORT_ERROR (("Ns_externalize_name: Invalid internal name\n"));
+	if (required_length > internal_name_length) {
+		ACPI_REPORT_ERROR (("ns_externalize_name: Invalid internal name\n"));
 		return_ACPI_STATUS (AE_BAD_PATHNAME);
 	}
 
 	/*
-	 * Build Converted_name...
+	 * Build converted_name...
 	 */
-
-	(*converted_name) = ACPI_MEM_CALLOCATE (*converted_name_length);
+	*converted_name = ACPI_MEM_CALLOCATE (required_length);
 	if (!(*converted_name)) {
 		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
@@ -530,8 +680,8 @@
 		(*converted_name)[j++] = internal_name[i];
 	}
 
-	if (names_count > 0) {
-		for (i = 0; i < names_count; i++) {
+	if (num_segments > 0) {
+		for (i = 0; i < num_segments; i++) {
 			if (i > 0) {
 				(*converted_name)[j++] = '.';
 			}
@@ -543,13 +693,17 @@
 		}
 	}
 
+	if (converted_name_length) {
+		*converted_name_length = (u32) required_length;
+	}
+
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_map_handle_to_node
+ * FUNCTION:    acpi_ns_map_handle_to_node
  *
  * PARAMETERS:  Handle          - Handle to be converted to an Node
  *
@@ -557,20 +711,21 @@
  *
  * DESCRIPTION: Convert a namespace handle to a real Node
  *
+ * Note: Real integer handles allow for more verification
+ *       and keep all pointers within this subsystem.
+ *
  ******************************************************************************/
 
-acpi_namespace_node *
+struct acpi_namespace_node *
 acpi_ns_map_handle_to_node (
-	acpi_handle             handle)
+	acpi_handle                     handle)
 {
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/*
-	 * Simple implementation for now;
-	 * TBD: [Future] Real integer handles allow for more verification
-	 * and keep all pointers within this subsystem!
+	 * Simple implementation.
 	 */
 	if (!handle) {
 		return (NULL);
@@ -580,20 +735,19 @@
 		return (acpi_gbl_root_node);
 	}
 
-
 	/* We can at least attempt to verify the handle */
 
-	if (!VALID_DESCRIPTOR_TYPE (handle, ACPI_DESC_TYPE_NAMED)) {
+	if (ACPI_GET_DESCRIPTOR_TYPE (handle) != ACPI_DESC_TYPE_NAMED) {
 		return (NULL);
 	}
 
-	return ((acpi_namespace_node *) handle);
+	return ((struct acpi_namespace_node *) handle);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_convert_entry_to_handle
+ * FUNCTION:    acpi_ns_convert_entry_to_handle
  *
  * PARAMETERS:  Node          - Node to be converted to a Handle
  *
@@ -605,14 +759,12 @@
 
 acpi_handle
 acpi_ns_convert_entry_to_handle (
-	acpi_namespace_node         *node)
+	struct acpi_namespace_node          *node)
 {
 
 
 	/*
 	 * Simple implementation for now;
-	 * TBD: [Future] Real integer handles allow for more verification
-	 * and keep all pointers within this subsystem!
 	 */
 	return ((acpi_handle) node);
 
@@ -624,7 +776,7 @@
 		return (NULL);
 	}
 
-	if (Node == Acpi_gbl_Root_node)
+	if (Node == acpi_gbl_root_node)
 	{
 		return (ACPI_ROOT_OBJECT);
 	}
@@ -637,7 +789,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_terminate
+ * FUNCTION:    acpi_ns_terminate
  *
  * PARAMETERS:  none
  *
@@ -650,39 +802,32 @@
 void
 acpi_ns_terminate (void)
 {
-	acpi_operand_object     *obj_desc;
-	acpi_namespace_node     *this_node;
+	union acpi_operand_object       *obj_desc;
 
 
-	FUNCTION_TRACE ("Ns_terminate");
+	ACPI_FUNCTION_TRACE ("ns_terminate");
 
 
-	this_node = acpi_gbl_root_node;
-
 	/*
-	 * 1) Free the entire namespace -- all objects, tables, and stacks
+	 * 1) Free the entire namespace -- all nodes and objects
 	 *
-	 * Delete all objects linked to the root
-	 * (additional table descriptors)
+	 * Delete all object descriptors attached to namepsace nodes
 	 */
-	acpi_ns_delete_namespace_subtree (this_node);
+	acpi_ns_delete_namespace_subtree (acpi_gbl_root_node);
 
-	/* Detach any object(s) attached to the root */
+	/* Detach any objects attached to the root */
 
-	obj_desc = acpi_ns_get_attached_object (this_node);
+	obj_desc = acpi_ns_get_attached_object (acpi_gbl_root_node);
 	if (obj_desc) {
-		acpi_ns_detach_object (this_node);
-		acpi_ut_remove_reference (obj_desc);
+		acpi_ns_detach_object (acpi_gbl_root_node);
 	}
 
-	acpi_ns_delete_children (this_node);
 	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n"));
 
-
 	/*
 	 * 2) Now we can delete the ACPI tables
 	 */
-	acpi_tb_delete_acpi_tables ();
+	acpi_tb_delete_all_tables ();
 	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n"));
 
 	return_VOID;
@@ -691,7 +836,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_opens_scope
+ * FUNCTION:    acpi_ns_opens_scope
  *
  * PARAMETERS:  Type        - A valid namespace type
  *
@@ -702,34 +847,36 @@
 
 u32
 acpi_ns_opens_scope (
-	acpi_object_type8       type)
+	acpi_object_type                type)
 {
-	FUNCTION_TRACE_U32 ("Ns_opens_scope", type);
+	ACPI_FUNCTION_TRACE_STR ("ns_opens_scope", acpi_ut_get_type_name (type));
 
 
 	if (!acpi_ut_valid_object_type (type)) {
 		/* type code out of range  */
 
-		REPORT_WARNING (("Ns_opens_scope: Invalid Object Type\n"));
-		return_VALUE (NSP_NORMAL);
+		ACPI_REPORT_WARNING (("ns_opens_scope: Invalid Object Type %X\n", type));
+		return_VALUE (ACPI_NS_NORMAL);
 	}
 
-	return_VALUE (((u32) acpi_gbl_ns_properties[type]) & NSP_NEWSCOPE);
+	return_VALUE (((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_get_node
+ * FUNCTION:    acpi_ns_get_node_by_path
  *
  * PARAMETERS:  *Pathname   - Name to be found, in external (ASL) format. The
  *                            \ (backslash) and ^ (carat) prefixes, and the
  *                            . (period) to separate segments are supported.
- *              Start_node  - Root of subtree to be searched, or NS_ALL for the
+ *              start_node  - Root of subtree to be searched, or NS_ALL for the
  *                            root of the name space.  If Name is fully
  *                            qualified (first s8 is '\'), the passed value
  *                            of Scope will not be accessed.
- *              Return_node - Where the Node is returned
+ *              Flags       - Used to indicate whether to perform upsearch or
+ *                            not.
+ *              return_node - Where the Node is returned
  *
  * DESCRIPTION: Look up a name relative to a given scope and return the
  *              corresponding Node.  NOTE: Scope can be null.
@@ -739,40 +886,36 @@
  ******************************************************************************/
 
 acpi_status
-acpi_ns_get_node (
-	NATIVE_CHAR             *pathname,
-	acpi_namespace_node     *start_node,
-	acpi_namespace_node     **return_node)
+acpi_ns_get_node_by_path (
+	char                            *pathname,
+	struct acpi_namespace_node      *start_node,
+	u32                             flags,
+	struct acpi_namespace_node      **return_node)
 {
-	acpi_generic_state      scope_info;
-	acpi_status             status;
-	NATIVE_CHAR             *internal_path = NULL;
+	union acpi_generic_state        scope_info;
+	acpi_status                     status;
+	char                            *internal_path = NULL;
 
 
-	FUNCTION_TRACE_PTR ("Ns_get_node", pathname);
+	ACPI_FUNCTION_TRACE_PTR ("ns_get_node_by_path", pathname);
 
 
-	/* Ensure that the namespace has been initialized */
-
-	if (!acpi_gbl_root_node) {
-		return_ACPI_STATUS (AE_NO_NAMESPACE);
-	}
+	if (pathname) {
+		/* Convert path to internal representation */
 
-	if (!pathname) {
-		return_ACPI_STATUS (AE_BAD_PARAMETER);
+		status = acpi_ns_internalize_name (pathname, &internal_path);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
+		}
 	}
 
+	/* Must lock namespace during lookup */
 
-	/* Convert path to internal representation */
-
-	status = acpi_ns_internalize_name (pathname, &internal_path);
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
 	if (ACPI_FAILURE (status)) {
 		return_ACPI_STATUS (status);
 	}
 
-
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
-
 	/* Setup lookup scope (search starting point) */
 
 	scope_info.scope.node = start_node;
@@ -780,30 +923,30 @@
 	/* Lookup the name in the namespace */
 
 	status = acpi_ns_lookup (&scope_info, internal_path,
-			 ACPI_TYPE_ANY, IMODE_EXECUTE,
-			 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
+			 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+			 (flags | ACPI_NS_DONT_OPEN_SCOPE),
 			 NULL, return_node);
-
 	if (ACPI_FAILURE (status)) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s, %s\n",
 				internal_path, acpi_format_exception (status)));
 	}
 
-
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
-
 	/* Cleanup */
 
-	ACPI_MEM_FREE (internal_path);
+	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+
+	if (internal_path) {
+		ACPI_MEM_FREE (internal_path);
+	}
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_find_parent_name
+ * FUNCTION:    acpi_ns_find_parent_name
  *
- * PARAMETERS:  *Child_node            - Named Obj whose name is to be found
+ * PARAMETERS:  *child_node            - Named Obj whose name is to be found
  *
  * RETURN:      The ACPI name
  *
@@ -815,75 +958,39 @@
 
 acpi_name
 acpi_ns_find_parent_name (
-	acpi_namespace_node     *child_node)
+	struct acpi_namespace_node      *child_node)
 {
-	acpi_namespace_node     *parent_node;
+	struct acpi_namespace_node      *parent_node;
 
 
-	FUNCTION_TRACE ("Ns_find_parent_name");
+	ACPI_FUNCTION_TRACE ("ns_find_parent_name");
 
 
 	if (child_node) {
 		/* Valid entry.  Get the parent Node */
 
-		parent_node = acpi_ns_get_parent_object (child_node);
+		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",
-				child_node, (char*)&child_node->name, parent_node, (char*)&parent_node->name));
+				child_node, child_node->name.ascii,
+				parent_node, parent_node->name.ascii));
 
-			if (parent_node->name) {
-				return_VALUE (parent_node->name);
+			if (parent_node->name.integer) {
+				return_VALUE ((acpi_name) parent_node->name.integer);
 			}
 		}
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "unable to find parent of %p (%4.4s)\n",
-			child_node, (char*)&child_node->name));
+			child_node, child_node->name.ascii));
 	}
 
 	return_VALUE (ACPI_UNKNOWN_NAME);
 }
 
 
-#if defined(ACPI_DEBUG) || defined(ENABLE_DEBUGGER)
-
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_exist_downstream_sibling
- *
- * PARAMETERS:  *Node          - pointer to first Node to examine
- *
- * RETURN:      TRUE if sibling is found, FALSE otherwise
- *
- * DESCRIPTION: Searches remainder of scope being processed to determine
- *              whether there is a downstream sibling to the current
- *              object.  This function is used to determine what type of
- *              line drawing character to use when displaying namespace
- *              trees.
- *
- ******************************************************************************/
-
-u8
-acpi_ns_exist_downstream_sibling (
-	acpi_namespace_node     *node)
-{
-
-	if (!node) {
-		return (FALSE);
-	}
-
-	if (node->name) {
-		return (TRUE);
-	}
-
-	return (FALSE);
-}
-
-#endif /* ACPI_DEBUG */
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ns_get_parent_object
+ * FUNCTION:    acpi_ns_get_parent_node
  *
  * PARAMETERS:  Node       - Current table entry
  *
@@ -894,13 +1001,11 @@
  ******************************************************************************/
 
 
-acpi_namespace_node *
-acpi_ns_get_parent_object (
-	acpi_namespace_node     *node)
+struct acpi_namespace_node *
+acpi_ns_get_parent_node (
+	struct acpi_namespace_node      *node)
 {
-
-
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	if (!node) {
@@ -925,7 +1030,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_get_next_valid_node
+ * FUNCTION:    acpi_ns_get_next_valid_node
  *
  * PARAMETERS:  Node       - Current table entry
  *
@@ -938,9 +1043,9 @@
  ******************************************************************************/
 
 
-acpi_namespace_node *
+struct acpi_namespace_node *
 acpi_ns_get_next_valid_node (
-	acpi_namespace_node     *node)
+	struct acpi_namespace_node      *node)
 {
 
 	/* If we are at the end of this peer list, return NULL */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/namespace/nswalk.c linux-2.4.22-pre2/drivers/acpi/namespace/nswalk.c
--- linux-2.4.21/drivers/acpi/namespace/nswalk.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/namespace/nswalk.c	2003-06-26 21:43:33.000000000 +0000
@@ -1,49 +1,66 @@
 /******************************************************************************
  *
  * Module Name: nswalk - Functions for walking the ACPI namespace
- *              $Revision: 26 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acinterp.h"
-#include "acnamesp.h"
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-	 MODULE_NAME         ("nswalk")
+	 ACPI_MODULE_NAME    ("nswalk")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_get_next_node
+ * FUNCTION:    acpi_ns_get_next_node
  *
  * PARAMETERS:  Type                - Type of node to be searched for
- *              Parent_node         - Parent node whose children we are
+ *              parent_node         - Parent node whose children we are
  *                                     getting
- *              Child_node          - Previous child that was found.
+ *              child_node          - Previous child that was found.
  *                                    The NEXT child will be returned
  *
- * RETURN:      acpi_namespace_node - Pointer to the NEXT child or NULL if
+ * RETURN:      struct acpi_namespace_node - Pointer to the NEXT child or NULL if
  *                                    none is found.
  *
  * DESCRIPTION: Return the next peer node within the namespace.  If Handle
@@ -52,16 +69,16 @@
  *
  ******************************************************************************/
 
-acpi_namespace_node *
+struct acpi_namespace_node *
 acpi_ns_get_next_node (
-	acpi_object_type8       type,
-	acpi_namespace_node     *parent_node,
-	acpi_namespace_node     *child_node)
+	acpi_object_type                type,
+	struct acpi_namespace_node      *parent_node,
+	struct acpi_namespace_node      *child_node)
 {
-	acpi_namespace_node     *next_node = NULL;
+	struct acpi_namespace_node      *next_node = NULL;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	if (!child_node) {
@@ -81,7 +98,7 @@
 	/* If any type is OK, we are done */
 
 	if (type == ACPI_TYPE_ANY) {
-		/* Next_node is NULL if we are at the end-of-list */
+		/* next_node is NULL if we are at the end-of-list */
 
 		return (next_node);
 	}
@@ -108,22 +125,22 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_walk_namespace
+ * FUNCTION:    acpi_ns_walk_namespace
  *
  * PARAMETERS:  Type                - acpi_object_type to search for
- *              Start_node          - Handle in namespace where search begins
- *              Max_depth           - Depth to which search is to reach
- *              Unlock_before_callback- Whether to unlock the NS before invoking
+ *              start_node          - Handle in namespace where search begins
+ *              max_depth           - Depth to which search is to reach
+ *              unlock_before_callback- Whether to unlock the NS before invoking
  *                                    the callback routine
- *              User_function       - Called when an object of "Type" is found
+ *              user_function       - Called when an object of "Type" is found
  *              Context             - Passed to user function
- *              Return_value        - from the User_function if terminated early.
+ *              return_value        - from the user_function if terminated early.
  *                                    Otherwise, returns NULL.
  * RETURNS:     Status
  *
  * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
- *              starting (and ending) at the node specified by Start_handle.
- *              The User_function is called whenever a node that matches
+ *              starting (and ending) at the node specified by start_handle.
+ *              The user_function is called whenever a node that matches
  *              the type parameter is found.  If the user function returns
  *              a non-zero value, the search is terminated immediately and this
  *              value is returned to the caller.
@@ -138,22 +155,23 @@
 
 acpi_status
 acpi_ns_walk_namespace (
-	acpi_object_type8       type,
-	acpi_handle             start_node,
-	u32                     max_depth,
-	u8                      unlock_before_callback,
-	acpi_walk_callback      user_function,
-	void                    *context,
-	void                    **return_value)
+	acpi_object_type                type,
+	acpi_handle                     start_node,
+	u32                             max_depth,
+	u8                              unlock_before_callback,
+	acpi_walk_callback              user_function,
+	void                            *context,
+	void                            **return_value)
 {
-	acpi_status             status;
-	acpi_namespace_node     *child_node;
-	acpi_namespace_node     *parent_node;
-	acpi_object_type8        child_type;
-	u32                     level;
+	acpi_status                     status;
+	acpi_status                     mutex_status;
+	struct acpi_namespace_node      *child_node;
+	struct acpi_namespace_node      *parent_node;
+	acpi_object_type                child_type;
+	u32                             level;
 
 
-	FUNCTION_TRACE ("Ns_walk_namespace");
+	ACPI_FUNCTION_TRACE ("ns_walk_namespace");
 
 
 	/* Special case for the namespace Root Node */
@@ -172,7 +190,7 @@
 	/*
 	 * Traverse the tree of nodes until we bubble back up to where we
 	 * started. When Level is zero, the loop is done because we have
-	 * bubbled up to (and passed) the original parent handle (Start_entry)
+	 * bubbled up to (and passed) the original parent handle (start_entry)
 	 */
 	while (level > 0) {
 		/* Get the next node in this scope.  Null if not found */
@@ -194,14 +212,20 @@
 				 * callback function
 				 */
 				if (unlock_before_callback) {
-					acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+					mutex_status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+					if (ACPI_FAILURE (mutex_status)) {
+						return_ACPI_STATUS (mutex_status);
+					}
 				}
 
 				status = user_function (child_node, level,
 						 context, return_value);
 
 				if (unlock_before_callback) {
-					acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+					mutex_status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+					if (ACPI_FAILURE (mutex_status)) {
+						return_ACPI_STATUS (mutex_status);
+					}
 				}
 
 				switch (status) {
@@ -216,14 +240,12 @@
 					/* Exit now, with OK status */
 
 					return_ACPI_STATUS (AE_OK);
-					break;
 
 				default:
 
 					/* All others are valid exceptions */
 
 					return_ACPI_STATUS (status);
-					break;
 				}
 			}
 
@@ -247,16 +269,15 @@
 				}
 			}
 		}
-
 		else {
 			/*
-			 * No more children of this node (Acpi_ns_get_next_node
+			 * No more children of this node (acpi_ns_get_next_node
 			 * failed), go back upwards in the namespace tree to
 			 * the node's parent.
 			 */
 			level--;
 			child_node = parent_node;
-			parent_node = acpi_ns_get_parent_object (parent_node);
+			parent_node = acpi_ns_get_parent_node (parent_node);
 		}
 	}
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/namespace/nsxfeval.c linux-2.4.22-pre2/drivers/acpi/namespace/nsxfeval.c
--- linux-2.4.21/drivers/acpi/namespace/nsxfeval.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/namespace/nsxfeval.c	2003-06-26 21:43:16.000000000 +0000
@@ -0,0 +1,747 @@
+/*******************************************************************************
+ *
+ * Module Name: nsxfeval - Public interfaces to the ACPI subsystem
+ *                         ACPI Object evaluation interfaces
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
+
+
+#define _COMPONENT          ACPI_NAMESPACE
+	 ACPI_MODULE_NAME    ("nsxfeval")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_evaluate_object_typed
+ *
+ * PARAMETERS:  Handle              - Object handle (optional)
+ *              *Pathname           - Object pathname (optional)
+ *              **external_params   - List of parameters to pass to method,
+ *                                    terminated by NULL.  May be NULL
+ *                                    if no parameters are being passed.
+ *              *return_buffer      - Where to put method's return value (if
+ *                                    any).  If NULL, no value is returned.
+ *              return_type         - Expected type of return object
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Find and evaluate the given object, passing the given
+ *              parameters if necessary.  One of "Handle" or "Pathname" must
+ *              be valid (non-null)
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_evaluate_object_typed (
+	acpi_handle                     handle,
+	acpi_string                     pathname,
+	struct acpi_object_list         *external_params,
+	struct acpi_buffer              *return_buffer,
+	acpi_object_type                return_type)
+{
+	acpi_status                     status;
+	u8                              must_free = FALSE;
+
+
+	ACPI_FUNCTION_TRACE ("acpi_evaluate_object_typed");
+
+
+	/* Return buffer must be valid */
+
+	if (!return_buffer) {
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	}
+
+	if (return_buffer->length == ACPI_ALLOCATE_BUFFER) {
+		must_free = TRUE;
+	}
+
+	/* Evaluate the object */
+
+	status = acpi_evaluate_object (handle, pathname, external_params, return_buffer);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/* Type ANY means "don't care" */
+
+	if (return_type == ACPI_TYPE_ANY) {
+		return_ACPI_STATUS (AE_OK);
+	}
+
+	if (return_buffer->length == 0) {
+		/* Error because caller specifically asked for a return value */
+
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"No return value\n"));
+
+		return_ACPI_STATUS (AE_NULL_OBJECT);
+	}
+
+	/* Examine the object type returned from evaluate_object */
+
+	if (((union acpi_object *) return_buffer->pointer)->type == return_type) {
+		return_ACPI_STATUS (AE_OK);
+	}
+
+	/* Return object type does not match requested type */
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+		"Incorrect return type [%s] requested [%s]\n",
+		acpi_ut_get_type_name (((union acpi_object *) return_buffer->pointer)->type),
+		acpi_ut_get_type_name (return_type)));
+
+	if (must_free) {
+		/* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */
+
+		acpi_os_free (return_buffer->pointer);
+		return_buffer->pointer = NULL;
+	}
+
+	return_buffer->length = 0;
+	return_ACPI_STATUS (AE_TYPE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_evaluate_object
+ *
+ * PARAMETERS:  Handle              - Object handle (optional)
+ *              *Pathname           - Object pathname (optional)
+ *              **external_params   - List of parameters to pass to method,
+ *                                    terminated by NULL.  May be NULL
+ *                                    if no parameters are being passed.
+ *              *return_buffer      - Where to put method's return value (if
+ *                                    any).  If NULL, no value is returned.
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Find and evaluate the given object, passing the given
+ *              parameters if necessary.  One of "Handle" or "Pathname" must
+ *              be valid (non-null)
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_evaluate_object (
+	acpi_handle                     handle,
+	acpi_string                     pathname,
+	struct acpi_object_list         *external_params,
+	struct acpi_buffer              *return_buffer)
+{
+	acpi_status                     status;
+	union acpi_operand_object       **internal_params = NULL;
+	union acpi_operand_object       *internal_return_obj = NULL;
+	acpi_size                       buffer_space_needed;
+	u32                             i;
+
+
+	ACPI_FUNCTION_TRACE ("acpi_evaluate_object");
+
+
+	/*
+	 * If there are parameters to be passed to the object
+	 * (which must be a control method), the external objects
+	 * must be converted to internal objects
+	 */
+	if (external_params && external_params->count) {
+		/*
+		 * Allocate a new parameter block for the internal objects
+		 * Add 1 to count to allow for null terminated internal list
+		 */
+		internal_params = ACPI_MEM_CALLOCATE (((acpi_size) external_params->count + 1) *
+				  sizeof (void *));
+		if (!internal_params) {
+			return_ACPI_STATUS (AE_NO_MEMORY);
+		}
+
+		/*
+		 * Convert each external object in the list to an
+		 * internal object
+		 */
+		for (i = 0; i < external_params->count; i++) {
+			status = acpi_ut_copy_eobject_to_iobject (&external_params->pointer[i],
+					 &internal_params[i]);
+			if (ACPI_FAILURE (status)) {
+				acpi_ut_delete_internal_object_list (internal_params);
+				return_ACPI_STATUS (status);
+			}
+		}
+		internal_params[external_params->count] = NULL;
+	}
+
+	/*
+	 * Three major cases:
+	 * 1) Fully qualified pathname
+	 * 2) No handle, not fully qualified pathname (error)
+	 * 3) Valid handle
+	 */
+	if ((pathname) &&
+		(acpi_ns_valid_root_prefix (pathname[0]))) {
+		/*
+		 *  The path is fully qualified, just evaluate by name
+		 */
+		status = acpi_ns_evaluate_by_name (pathname, internal_params,
+				 &internal_return_obj);
+	}
+	else if (!handle) {
+		/*
+		 * A handle is optional iff a fully qualified pathname
+		 * is specified.  Since we've already handled fully
+		 * qualified names above, this is an error
+		 */
+		if (!pathname) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"Both Handle and Pathname are NULL\n"));
+		}
+		else {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"Handle is NULL and Pathname is relative\n"));
+		}
+
+		status = AE_BAD_PARAMETER;
+	}
+	else {
+		/*
+		 * We get here if we have a handle -- and if we have a
+		 * pathname it is relative.  The handle will be validated
+		 * in the lower procedures
+		 */
+		if (!pathname) {
+			/*
+			 * The null pathname case means the handle is for
+			 * the actual object to be evaluated
+			 */
+			status = acpi_ns_evaluate_by_handle (handle, internal_params,
+					  &internal_return_obj);
+		}
+		else {
+		   /*
+			* Both a Handle and a relative Pathname
+			*/
+			status = acpi_ns_evaluate_relative (handle, pathname, internal_params,
+					  &internal_return_obj);
+		}
+	}
+
+
+	/*
+	 * If we are expecting a return value, and all went well above,
+	 * copy the return value to an external object.
+	 */
+	if (return_buffer) {
+		if (!internal_return_obj) {
+			return_buffer->length = 0;
+		}
+		else {
+			if (ACPI_GET_DESCRIPTOR_TYPE (internal_return_obj) == ACPI_DESC_TYPE_NAMED) {
+				/*
+				 * If we received a NS Node as a return object, this means that
+				 * the object we are evaluating has nothing interesting to
+				 * return (such as a mutex, etc.)  We return an error because
+				 * these types are essentially unsupported by this interface.
+				 * We don't check up front because this makes it easier to add
+				 * support for various types at a later date if necessary.
+				 */
+				status = AE_TYPE;
+				internal_return_obj = NULL; /* No need to delete a NS Node */
+				return_buffer->length = 0;
+			}
+
+			if (ACPI_SUCCESS (status)) {
+				/*
+				 * Find out how large a buffer is needed
+				 * to contain the returned object
+				 */
+				status = acpi_ut_get_object_size (internal_return_obj,
+						   &buffer_space_needed);
+				if (ACPI_SUCCESS (status)) {
+					/* Validate/Allocate/Clear caller buffer */
+
+					status = acpi_ut_initialize_buffer (return_buffer, buffer_space_needed);
+					if (ACPI_FAILURE (status)) {
+						/*
+						 * Caller's buffer is too small or a new one can't be allocated
+						 */
+						ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+							"Needed buffer size %X, %s\n",
+							(u32) buffer_space_needed, acpi_format_exception (status)));
+					}
+					else {
+						/*
+						 *  We have enough space for the object, build it
+						 */
+						status = acpi_ut_copy_iobject_to_eobject (internal_return_obj,
+								  return_buffer);
+					}
+				}
+			}
+		}
+	}
+
+	/* Delete the return and parameter objects */
+
+	if (internal_return_obj) {
+		/*
+		 * Delete the internal return object. (Or at least
+		 * decrement the reference count by one)
+		 */
+		acpi_ut_remove_reference (internal_return_obj);
+	}
+
+	/*
+	 * Free the input parameter list (if we created one),
+	 */
+	if (internal_params) {
+		/* Free the allocated parameter block */
+
+		acpi_ut_delete_internal_object_list (internal_params);
+	}
+
+	return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_walk_namespace
+ *
+ * PARAMETERS:  Type                - acpi_object_type to search for
+ *              start_object        - Handle in namespace where search begins
+ *              max_depth           - Depth to which search is to reach
+ *              user_function       - Called when an object of "Type" is found
+ *              Context             - Passed to user function
+ *              return_value        - Location where return value of
+ *                                    user_function is put if terminated early
+ *
+ * RETURNS      Return value from the user_function if terminated early.
+ *              Otherwise, returns NULL.
+ *
+ * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
+ *              starting (and ending) at the object specified by start_handle.
+ *              The user_function is called whenever an object that matches
+ *              the type parameter is found.  If the user function returns
+ *              a non-zero value, the search is terminated immediately and this
+ *              value is returned to the caller.
+ *
+ *              The point of this procedure is to provide a generic namespace
+ *              walk routine that can be called from multiple places to
+ *              provide multiple services;  the User Function can be tailored
+ *              to each task, whether it is a print function, a compare
+ *              function, etc.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_walk_namespace (
+	acpi_object_type                type,
+	acpi_handle                     start_object,
+	u32                             max_depth,
+	acpi_walk_callback              user_function,
+	void                            *context,
+	void                            **return_value)
+{
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_TRACE ("acpi_walk_namespace");
+
+
+	/* Parameter validation */
+
+	if ((type > ACPI_TYPE_EXTERNAL_MAX) ||
+		(!max_depth)                    ||
+		(!user_function)) {
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	}
+
+	/*
+	 * Lock the namespace around the walk.
+	 * The namespace will be unlocked/locked around each call
+	 * to the user function - since this function
+	 * must be allowed to make Acpi calls itself.
+	 */
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	status = acpi_ns_walk_namespace (type, start_object, max_depth, ACPI_NS_WALK_UNLOCK,
+			  user_function, context, return_value);
+
+	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_get_device_callback
+ *
+ * PARAMETERS:  Callback from acpi_get_device
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Takes callbacks from walk_namespace and filters out all non-
+ *              present devices, or if they specified a HID, it filters based
+ *              on that.
+ *
+ ******************************************************************************/
+
+static acpi_status
+acpi_ns_get_device_callback (
+	acpi_handle                     obj_handle,
+	u32                             nesting_level,
+	void                            *context,
+	void                            **return_value)
+{
+	struct acpi_get_devices_info    *info = context;
+	acpi_status                     status;
+	struct acpi_namespace_node      *node;
+	u32                             flags;
+	struct acpi_device_id           hid;
+	struct acpi_compatible_id_list *cid;
+	acpi_native_uint                i;
+
+
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return (status);
+	}
+
+	node = acpi_ns_map_handle_to_node (obj_handle);
+	status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return (status);
+	}
+
+	if (!node) {
+		return (AE_BAD_PARAMETER);
+	}
+
+	/* Run _STA to determine if device is present */
+
+	status = acpi_ut_execute_STA (node, &flags);
+	if (ACPI_FAILURE (status)) {
+		return (AE_CTRL_DEPTH);
+	}
+
+	if (!(flags & 0x01)) {
+		/* Don't return at the device or children of the device if not there */
+
+		return (AE_CTRL_DEPTH);
+	}
+
+	/* Filter based on device HID & CID */
+
+	if (info->hid != NULL) {
+		status = acpi_ut_execute_HID (node, &hid);
+		if (status == AE_NOT_FOUND) {
+			return (AE_OK);
+		}
+		else if (ACPI_FAILURE (status)) {
+			return (AE_CTRL_DEPTH);
+		}
+
+		if (ACPI_STRNCMP (hid.value, info->hid, sizeof (hid.value)) != 0) {
+			/* Get the list of Compatible IDs */
+
+			status = acpi_ut_execute_CID (node, &cid);
+			if (status == AE_NOT_FOUND) {
+				return (AE_OK);
+			}
+			else if (ACPI_FAILURE (status)) {
+				return (AE_CTRL_DEPTH);
+			}
+
+			/* Walk the CID list */
+
+			for (i = 0; i < cid->count; i++) {
+				if (ACPI_STRNCMP (cid->id[i].value, info->hid,
+						 sizeof (struct acpi_compatible_id)) != 0) {
+					ACPI_MEM_FREE (cid);
+					return (AE_OK);
+				}
+			}
+			ACPI_MEM_FREE (cid);
+		}
+	}
+
+	status = info->user_function (obj_handle, nesting_level, info->context, return_value);
+	return (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_get_devices
+ *
+ * PARAMETERS:  HID                 - HID to search for. Can be NULL.
+ *              user_function       - Called when a matching object is found
+ *              Context             - Passed to user function
+ *              return_value        - Location where return value of
+ *                                    user_function is put if terminated early
+ *
+ * RETURNS      Return value from the user_function if terminated early.
+ *              Otherwise, returns NULL.
+ *
+ * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
+ *              starting (and ending) at the object specified by start_handle.
+ *              The user_function is called whenever an object of type
+ *              Device is found.  If the user function returns
+ *              a non-zero value, the search is terminated immediately and this
+ *              value is returned to the caller.
+ *
+ *              This is a wrapper for walk_namespace, but the callback performs
+ *              additional filtering. Please see acpi_get_device_callback.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_get_devices (
+	char                            *HID,
+	acpi_walk_callback              user_function,
+	void                            *context,
+	void                            **return_value)
+{
+	acpi_status                     status;
+	struct acpi_get_devices_info    info;
+
+
+	ACPI_FUNCTION_TRACE ("acpi_get_devices");
+
+
+	/* Parameter validation */
+
+	if (!user_function) {
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	}
+
+	/*
+	 * We're going to call their callback from OUR callback, so we need
+	 * to know what it is, and their context parameter.
+	 */
+	info.context      = context;
+	info.user_function = user_function;
+	info.hid          = HID;
+
+	/*
+	 * Lock the namespace around the walk.
+	 * The namespace will be unlocked/locked around each call
+	 * to the user function - since this function
+	 * must be allowed to make Acpi calls itself.
+	 */
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	status = acpi_ns_walk_namespace (ACPI_TYPE_DEVICE,
+			   ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
+			   ACPI_NS_WALK_UNLOCK,
+			   acpi_ns_get_device_callback, &info,
+			   return_value);
+
+	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_attach_data
+ *
+ * PARAMETERS:  obj_handle          - Namespace node
+ *              Handler             - Handler for this attachment
+ *              Data                - Pointer to data to be attached
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Attach arbitrary data and handler to a namespace node.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_attach_data (
+	acpi_handle                     obj_handle,
+	acpi_object_handler             handler,
+	void                            *data)
+{
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
+
+
+	/* Parameter validation */
+
+	if (!obj_handle ||
+		!handler    ||
+		!data) {
+		return (AE_BAD_PARAMETER);
+	}
+
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return (status);
+	}
+
+	/* Convert and validate the handle */
+
+	node = acpi_ns_map_handle_to_node (obj_handle);
+	if (!node) {
+		status = AE_BAD_PARAMETER;
+		goto unlock_and_exit;
+	}
+
+	status = acpi_ns_attach_data (node, handler, data);
+
+unlock_and_exit:
+	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	return (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_detach_data
+ *
+ * PARAMETERS:  obj_handle          - Namespace node handle
+ *              Handler             - Handler used in call to acpi_attach_data
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Remove data that was previously attached to a node.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_detach_data (
+	acpi_handle                     obj_handle,
+	acpi_object_handler             handler)
+{
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
+
+
+	/* Parameter validation */
+
+	if (!obj_handle ||
+		!handler) {
+		return (AE_BAD_PARAMETER);
+	}
+
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return (status);
+	}
+
+	/* Convert and validate the handle */
+
+	node = acpi_ns_map_handle_to_node (obj_handle);
+	if (!node) {
+		status = AE_BAD_PARAMETER;
+		goto unlock_and_exit;
+	}
+
+	status = acpi_ns_detach_data (node, handler);
+
+unlock_and_exit:
+	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	return (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_get_data
+ *
+ * PARAMETERS:  obj_handle          - Namespace node
+ *              Handler             - Handler used in call to attach_data
+ *              Data                - Where the data is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Retrieve data that was previously attached to a namespace node.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_get_data (
+	acpi_handle                     obj_handle,
+	acpi_object_handler             handler,
+	void                            **data)
+{
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
+
+
+	/* Parameter validation */
+
+	if (!obj_handle ||
+		!handler    ||
+		!data) {
+		return (AE_BAD_PARAMETER);
+	}
+
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return (status);
+	}
+
+	/* Convert and validate the handle */
+
+	node = acpi_ns_map_handle_to_node (obj_handle);
+	if (!node) {
+		status = AE_BAD_PARAMETER;
+		goto unlock_and_exit;
+	}
+
+	status = acpi_ns_get_attached_data (node, handler, data);
+
+unlock_and_exit:
+	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	return (status);
+}
+
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/namespace/nsxfname.c linux-2.4.22-pre2/drivers/acpi/namespace/nsxfname.c
--- linux-2.4.21/drivers/acpi/namespace/nsxfname.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/namespace/nsxfname.c	2003-06-26 21:43:13.000000000 +0000
@@ -2,50 +2,63 @@
  *
  * Module Name: nsxfname - Public interfaces to the ACPI subsystem
  *                         ACPI Namespace oriented interfaces
- *              $Revision: 82 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "amlcode.h"
-#include "acparser.h"
-#include "acdispat.h"
-#include "acevents.h"
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-	 MODULE_NAME         ("nsxfname")
+	 ACPI_MODULE_NAME    ("nsxfname")
 
 
-/****************************************************************************
+/******************************************************************************
  *
- * FUNCTION:    Acpi_get_handle
+ * FUNCTION:    acpi_get_handle
  *
  * PARAMETERS:  Parent          - Object to search under (search scope).
- *              Path_name       - Pointer to an asciiz string containing the
+ *              path_name       - Pointer to an asciiz string containing the
  *                                  name
- *              Ret_handle      - Where the return handle is placed
+ *              ret_handle      - Where the return handle is placed
  *
  * RETURN:      Status
  *
@@ -58,16 +71,16 @@
 
 acpi_status
 acpi_get_handle (
-	acpi_handle             parent,
-	acpi_string             pathname,
-	acpi_handle             *ret_handle)
+	acpi_handle                     parent,
+	acpi_string                     pathname,
+	acpi_handle                     *ret_handle)
 {
-	acpi_status             status;
-	acpi_namespace_node     *node = NULL;
-	acpi_namespace_node     *prefix_node = NULL;
+	acpi_status                     status;
+	struct acpi_namespace_node      *node = NULL;
+	struct acpi_namespace_node      *prefix_node = NULL;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/* Parameter Validation */
@@ -79,20 +92,26 @@
 	/* Convert a parent handle to a prefix node */
 
 	if (parent) {
-		acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+		status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+		if (ACPI_FAILURE (status)) {
+			return (status);
+		}
 
 		prefix_node = acpi_ns_map_handle_to_node (parent);
 		if (!prefix_node) {
-			acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+			(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 			return (AE_BAD_PARAMETER);
 		}
 
-		acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+		status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+		if (ACPI_FAILURE (status)) {
+			return (status);
+		}
 	}
 
 	/* Special case for root, since we can't search for it */
 
-	if (STRCMP (pathname, NS_ROOT_PATH) == 0) {
+	if (ACPI_STRCMP (pathname, ACPI_NS_ROOT_PATH) == 0) {
 		*ret_handle = acpi_ns_convert_entry_to_handle (acpi_gbl_root_node);
 		return (AE_OK);
 	}
@@ -100,7 +119,8 @@
 	/*
 	 *  Find the Node and convert to a handle
 	 */
-	status = acpi_ns_get_node (pathname, prefix_node, &node);
+	status = acpi_ns_get_node_by_path (pathname, prefix_node, ACPI_NS_NO_UPSEARCH,
+			  &node);
 
 	*ret_handle = NULL;
 	if (ACPI_SUCCESS (status)) {
@@ -111,90 +131,90 @@
 }
 
 
-/****************************************************************************
+/******************************************************************************
  *
- * FUNCTION:    Acpi_get_name
+ * FUNCTION:    acpi_get_name
  *
  * PARAMETERS:  Handle          - Handle to be converted to a pathname
- *              Name_type       - Full pathname or single segment
- *              Ret_path_ptr    - Buffer for returned path
+ *              name_type       - Full pathname or single segment
+ *              Buffer          - Buffer for returned path
  *
  * RETURN:      Pointer to a string containing the fully qualified Name.
  *
  * DESCRIPTION: This routine returns the fully qualified name associated with
- *              the Handle parameter.  This and the Acpi_pathname_to_handle are
+ *              the Handle parameter.  This and the acpi_pathname_to_handle are
  *              complementary functions.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_get_name (
-	acpi_handle             handle,
-	u32                     name_type,
-	acpi_buffer             *ret_path_ptr)
+	acpi_handle                     handle,
+	u32                             name_type,
+	struct acpi_buffer              *buffer)
 {
-	acpi_status             status;
-	acpi_namespace_node     *node;
+	acpi_status                     status;
+	struct acpi_namespace_node      *node;
 
 
-	/* Buffer pointer must be valid always */
+	/* Parameter validation */
 
-	if (!ret_path_ptr || (name_type > ACPI_NAME_TYPE_MAX)) {
+	if (name_type > ACPI_NAME_TYPE_MAX) {
 		return (AE_BAD_PARAMETER);
 	}
 
-	/* Allow length to be zero and ignore the pointer */
-
-	if ((ret_path_ptr->length) &&
-	   (!ret_path_ptr->pointer)) {
-		return (AE_BAD_PARAMETER);
+	status = acpi_ut_validate_buffer (buffer);
+	if (ACPI_FAILURE (status)) {
+		return (status);
 	}
 
 	if (name_type == ACPI_FULL_PATHNAME) {
 		/* Get the full pathname (From the namespace root) */
 
-		status = acpi_ns_handle_to_pathname (handle, &ret_path_ptr->length,
-				   ret_path_ptr->pointer);
+		status = acpi_ns_handle_to_pathname (handle, buffer);
 		return (status);
 	}
 
 	/*
 	 * Wants the single segment ACPI name.
-	 * Validate handle and convert to an Node
+	 * Validate handle and convert to a namespace Node
 	 */
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return (status);
+	}
+
 	node = acpi_ns_map_handle_to_node (handle);
 	if (!node) {
 		status = AE_BAD_PARAMETER;
 		goto unlock_and_exit;
 	}
 
-	/* Check if name will fit in buffer */
+	/* Validate/Allocate/Clear caller buffer */
 
-	if (ret_path_ptr->length < PATH_SEGMENT_LENGTH) {
-		ret_path_ptr->length = PATH_SEGMENT_LENGTH;
-		status = AE_BUFFER_OVERFLOW;
+	status = acpi_ut_initialize_buffer (buffer, ACPI_PATH_SEGMENT_LENGTH);
+	if (ACPI_FAILURE (status)) {
 		goto unlock_and_exit;
 	}
 
 	/* Just copy the ACPI name from the Node and zero terminate it */
 
-	STRNCPY (ret_path_ptr->pointer, (NATIVE_CHAR *) &node->name,
+	ACPI_STRNCPY (buffer->pointer, node->name.ascii,
 			 ACPI_NAME_SIZE);
-	((NATIVE_CHAR *) ret_path_ptr->pointer) [ACPI_NAME_SIZE] = 0;
+	((char *) buffer->pointer) [ACPI_NAME_SIZE] = 0;
 	status = AE_OK;
 
 
 unlock_and_exit:
 
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return (status);
 }
 
 
-/****************************************************************************
+/******************************************************************************
  *
- * FUNCTION:    Acpi_get_object_info
+ * FUNCTION:    acpi_get_object_info
  *
  * PARAMETERS:  Handle          - Object Handle
  *              Info            - Where the info is returned
@@ -209,93 +229,127 @@
 
 acpi_status
 acpi_get_object_info (
-	acpi_handle             handle,
-	acpi_device_info        *info)
+	acpi_handle                     handle,
+	struct acpi_buffer              *buffer)
 {
-	acpi_device_id          hid;
-	acpi_device_id          uid;
-	acpi_status             status;
-	u32                     device_status = 0;
-	acpi_integer            address = 0;
-	acpi_namespace_node     *node;
+	acpi_status                     status;
+	struct acpi_namespace_node      *node;
+	struct acpi_device_info         info;
+	struct acpi_device_info         *return_info;
+	struct acpi_compatible_id_list *cid_list = NULL;
+	acpi_size                       size;
 
 
 	/* Parameter validation */
 
-	if (!handle || !info) {
+	if (!handle || !buffer) {
 		return (AE_BAD_PARAMETER);
 	}
 
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	status = acpi_ut_validate_buffer (buffer);
+	if (ACPI_FAILURE (status)) {
+		return (status);
+	}
+
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return (status);
+	}
 
 	node = acpi_ns_map_handle_to_node (handle);
 	if (!node) {
-		acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+		(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 		return (AE_BAD_PARAMETER);
 	}
 
-	info->type      = node->type;
-	info->name      = node->name;
+	/* Init return structure */
 
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	size = sizeof (struct acpi_device_info);
+	ACPI_MEMSET (&info, 0, size);
 
-	/*
-	 * If not a device, we are all done.
-	 */
-	if (info->type != ACPI_TYPE_DEVICE) {
-		return (AE_OK);
+	info.type  = node->type;
+	info.name  = node->name.integer;
+	info.valid = 0;
+
+	status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return (status);
 	}
 
+	/* If not a device, we are all done */
 
-	/*
-	 * Get extra info for ACPI devices only.  Run the
-	 * _HID, _UID, _STA, and _ADR methods.  Note: none
-	 * of these methods are required, so they may or may
-	 * not be present.  The Info->Valid bits are used
-	 * to indicate which methods ran successfully.
-	 */
-	info->valid = 0;
+	if (info.type == ACPI_TYPE_DEVICE) {
+		/*
+		 * Get extra info for ACPI Devices objects only:
+		 * Run the Device _HID, _UID, _CID, _STA, and _ADR methods.
+		 *
+		 * Note: none of these methods are required, so they may or may
+		 * not be present for this device.  The Info.Valid bitfield is used
+		 * to indicate which methods were found and ran successfully.
+		 */
+
+		/* Execute the Device._HID method */
+
+		status = acpi_ut_execute_HID (node, &info.hardware_id);
+		if (ACPI_SUCCESS (status)) {
+			info.valid |= ACPI_VALID_HID;
+		}
 
-	/* Execute the _HID method and save the result */
+		/* Execute the Device._UID method */
 
-	status = acpi_ut_execute_HID (node, &hid);
-	if (ACPI_SUCCESS (status)) {
-		STRNCPY (info->hardware_id, hid.buffer, sizeof(info->hardware_id));
+		status = acpi_ut_execute_UID (node, &info.unique_id);
+		if (ACPI_SUCCESS (status)) {
+			info.valid |= ACPI_VALID_UID;
+		}
 
-		info->valid |= ACPI_VALID_HID;
-	}
+		/* Execute the Device._CID method */
 
-	/* Execute the _UID method and save the result */
+		status = acpi_ut_execute_CID (node, &cid_list);
+		if (ACPI_SUCCESS (status)) {
+			size += ((acpi_size) cid_list->count - 1) *
+					 sizeof (struct acpi_compatible_id);
+			info.valid |= ACPI_VALID_CID;
+		}
 
-	status = acpi_ut_execute_UID (node, &uid);
-	if (ACPI_SUCCESS (status)) {
-		STRCPY (info->unique_id, uid.buffer);
+		/* Execute the Device._STA method */
 
-		info->valid |= ACPI_VALID_UID;
+		status = acpi_ut_execute_STA (node, &info.current_status);
+		if (ACPI_SUCCESS (status)) {
+			info.valid |= ACPI_VALID_STA;
+		}
+
+		/* Execute the Device._ADR method */
+
+		status = acpi_ut_evaluate_numeric_object (METHOD_NAME__ADR, node,
+				  &info.address);
+		if (ACPI_SUCCESS (status)) {
+			info.valid |= ACPI_VALID_ADR;
+		}
+
+		status = AE_OK;
 	}
 
-	/*
-	 * Execute the _STA method and save the result
-	 * _STA is not always present
-	 */
-	status = acpi_ut_execute_STA (node, &device_status);
-	if (ACPI_SUCCESS (status)) {
-		info->current_status = device_status;
-		info->valid |= ACPI_VALID_STA;
+	/* Validate/Allocate/Clear caller buffer */
+
+	status = acpi_ut_initialize_buffer (buffer, size);
+	if (ACPI_FAILURE (status)) {
+		goto cleanup;
 	}
 
-	/*
-	 * Execute the _ADR method and save result if successful
-	 * _ADR is not always present
-	 */
-	status = acpi_ut_evaluate_numeric_object (METHOD_NAME__ADR,
-			  node, &address);
+	/* Populate the return buffer */
 
-	if (ACPI_SUCCESS (status)) {
-		info->address = address;
-		info->valid |= ACPI_VALID_ADR;
+	return_info = buffer->pointer;
+	ACPI_MEMCPY (return_info, &info, sizeof (struct acpi_device_info));
+
+	if (cid_list) {
+		ACPI_MEMCPY (&return_info->compatibility_id, cid_list, cid_list->size);
 	}
 
-	return (AE_OK);
+
+cleanup:
+	if (cid_list) {
+		ACPI_MEM_FREE (cid_list);
+	}
+	return (status);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/namespace/nsxfobj.c linux-2.4.22-pre2/drivers/acpi/namespace/nsxfobj.c
--- linux-2.4.21/drivers/acpi/namespace/nsxfobj.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/namespace/nsxfobj.c	2003-06-26 21:43:09.000000000 +0000
@@ -2,345 +2,60 @@
  *
  * Module Name: nsxfobj - Public interfaces to the ACPI subsystem
  *                         ACPI Object oriented interfaces
- *              $Revision: 95 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "acdispat.h"
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-	 MODULE_NAME         ("nsxfobj")
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_evaluate_object
- *
- * PARAMETERS:  Handle              - Object handle (optional)
- *              *Pathname           - Object pathname (optional)
- *              **External_params   - List of parameters to pass to method,
- *                                    terminated by NULL.  May be NULL
- *                                    if no parameters are being passed.
- *              *Return_buffer      - Where to put method's return value (if
- *                                    any).  If NULL, no value is returned.
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Find and evaluate the given object, passing the given
- *              parameters if necessary.  One of "Handle" or "Pathname" must
- *              be valid (non-null)
- *
- ******************************************************************************/
-
-acpi_status
-acpi_evaluate_object (
-	acpi_handle             handle,
-	acpi_string             pathname,
-	acpi_object_list        *external_params,
-	acpi_buffer             *return_buffer)
-{
-	acpi_status             status;
-	acpi_operand_object     **internal_params = NULL;
-	acpi_operand_object     *internal_return_obj = NULL;
-	u32                     buffer_space_needed;
-	u32                     user_buffer_length;
-	u32                     i;
-
-
-	FUNCTION_TRACE ("Acpi_evaluate_object");
-
-
-	/*
-	 * If there are parameters to be passed to the object
-	 * (which must be a control method), the external objects
-	 * must be converted to internal objects
-	 */
-	if (external_params && external_params->count) {
-		/*
-		 * Allocate a new parameter block for the internal objects
-		 * Add 1 to count to allow for null terminated internal list
-		 */
-		internal_params = ACPI_MEM_CALLOCATE ((external_params->count + 1) * sizeof (void *));
-		if (!internal_params) {
-			return_ACPI_STATUS (AE_NO_MEMORY);
-		}
-
-
-		/*
-		 * Convert each external object in the list to an
-		 * internal object
-		 */
-		for (i = 0; i < external_params->count; i++) {
-			status = acpi_ut_copy_eobject_to_iobject (&external_params->pointer[i],
-					 &internal_params[i]);
-
-			if (ACPI_FAILURE (status)) {
-				acpi_ut_delete_internal_object_list (internal_params);
-				return_ACPI_STATUS (status);
-			}
-		}
-		internal_params[external_params->count] = NULL;
-	}
-
-
-	/*
-	 * Three major cases:
-	 * 1) Fully qualified pathname
-	 * 2) No handle, not fully qualified pathname (error)
-	 * 3) Valid handle
-	 */
-	if ((pathname) &&
-		(acpi_ns_valid_root_prefix (pathname[0]))) {
-		/*
-		 *  The path is fully qualified, just evaluate by name
-		 */
-		status = acpi_ns_evaluate_by_name (pathname, internal_params, &internal_return_obj);
-	}
-
-	else if (!handle) {
-		/*
-		 * A handle is optional iff a fully qualified pathname
-		 * is specified.  Since we've already handled fully
-		 * qualified names above, this is an error
-		 */
-		if (!pathname) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Both Handle and Pathname are NULL\n"));
-		}
-
-		else {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Handle is NULL and Pathname is relative\n"));
-		}
-
-		status = AE_BAD_PARAMETER;
-	}
-
-	else {
-		/*
-		 * We get here if we have a handle -- and if we have a
-		 * pathname it is relative.  The handle will be validated
-		 * in the lower procedures
-		 */
-		if (!pathname) {
-			/*
-			 * The null pathname case means the handle is for
-			 * the actual object to be evaluated
-			 */
-			status = acpi_ns_evaluate_by_handle (handle, internal_params, &internal_return_obj);
-		}
-
-		else {
-		   /*
-			* Both a Handle and a relative Pathname
-			*/
-			status = acpi_ns_evaluate_relative (handle, pathname, internal_params,
-					 &internal_return_obj);
-		}
-	}
-
-
-	/*
-	 * If we are expecting a return value, and all went well above,
-	 * copy the return value to an external object.
-	 */
-
-	if (return_buffer) {
-		user_buffer_length = return_buffer->length;
-		return_buffer->length = 0;
-
-		if (internal_return_obj) {
-			if (VALID_DESCRIPTOR_TYPE (internal_return_obj, ACPI_DESC_TYPE_NAMED)) {
-				/*
-				 * If we got an Node as a return object,
-				 * this means the object we are evaluating
-				 * has nothing interesting to return (such
-				 * as a mutex, etc.)  We return an error
-				 * because these types are essentially
-				 * unsupported by this interface.  We
-				 * don't check up front because this makes
-				 * it easier to add support for various
-				 * types at a later date if necessary.
-				 */
-				status = AE_TYPE;
-				internal_return_obj = NULL; /* No need to delete an Node */
-			}
-
-			if (ACPI_SUCCESS (status)) {
-				/*
-				 * Find out how large a buffer is needed
-				 * to contain the returned object
-				 */
-				status = acpi_ut_get_object_size (internal_return_obj,
-						   &buffer_space_needed);
-				if (ACPI_SUCCESS (status)) {
-					/*
-					 * Check if there is enough room in the
-					 * caller's buffer
-					 */
-					if (user_buffer_length < buffer_space_needed) {
-						/*
-						 * Caller's buffer is too small, can't
-						 * give him partial results fail the call
-						 * but return the buffer size needed
-						 */
-						ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-							"Needed buffer size %X, received %X\n",
-							buffer_space_needed, user_buffer_length));
-
-						return_buffer->length = buffer_space_needed;
-						status = AE_BUFFER_OVERFLOW;
-					}
-
-					else {
-						/*
-						 *  We have enough space for the object, build it
-						 */
-						status = acpi_ut_copy_iobject_to_eobject (internal_return_obj,
-								  return_buffer);
-						return_buffer->length = buffer_space_needed;
-					}
-				}
-			}
-		}
-	}
-
-
-	/* Delete the return and parameter objects */
-
-	if (internal_return_obj) {
-		/*
-		 * Delete the internal return object. (Or at least
-		 * decrement the reference count by one)
-		 */
-		acpi_ut_remove_reference (internal_return_obj);
-	}
-
-	/*
-	 * Free the input parameter list (if we created one),
-	 */
-	if (internal_params) {
-		/* Free the allocated parameter block */
-
-		acpi_ut_delete_internal_object_list (internal_params);
-	}
-
-	return_ACPI_STATUS (status);
-}
-
+	 ACPI_MODULE_NAME    ("nsxfobj")
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_get_next_object
- *
- * PARAMETERS:  Type            - Type of object to be searched for
- *              Parent          - Parent object whose children we are getting
- *              Last_child      - Previous child that was found.
- *                                The NEXT child will be returned
- *              Ret_handle      - Where handle to the next object is placed
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Return the next peer object within the namespace.  If Handle is
- *              valid, Scope is ignored.  Otherwise, the first object within
- *              Scope is returned.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_get_next_object (
-	acpi_object_type        type,
-	acpi_handle             parent,
-	acpi_handle             child,
-	acpi_handle             *ret_handle)
-{
-	acpi_status             status = AE_OK;
-	acpi_namespace_node     *node;
-	acpi_namespace_node     *parent_node = NULL;
-	acpi_namespace_node     *child_node = NULL;
-
-
-	/* Parameter validation */
-
-	if (type > ACPI_TYPE_MAX) {
-		return (AE_BAD_PARAMETER);
-	}
-
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
-
-	/* If null handle, use the parent */
-
-	if (!child) {
-		/* Start search at the beginning of the specified scope */
-
-		parent_node = acpi_ns_map_handle_to_node (parent);
-		if (!parent_node) {
-			status = AE_BAD_PARAMETER;
-			goto unlock_and_exit;
-		}
-	}
-
-	/* Non-null handle, ignore the parent */
-
-	else {
-		/* Convert and validate the handle */
-
-		child_node = acpi_ns_map_handle_to_node (child);
-		if (!child_node) {
-			status = AE_BAD_PARAMETER;
-			goto unlock_and_exit;
-		}
-	}
-
-
-	/* Internal function does the real work */
-
-	node = acpi_ns_get_next_node ((acpi_object_type8) type,
-			   parent_node, child_node);
-	if (!node) {
-		status = AE_NOT_FOUND;
-		goto unlock_and_exit;
-	}
-
-	if (ret_handle) {
-		*ret_handle = acpi_ns_convert_entry_to_handle (node);
-	}
-
-
-unlock_and_exit:
-
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
-	return (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_get_type
+ * FUNCTION:    acpi_get_type
  *
  * PARAMETERS:  Handle          - Handle of object whose type is desired
- *              *Ret_type       - Where the type will be placed
+ *              *ret_type       - Where the type will be placed
  *
  * RETURN:      Status
  *
@@ -350,10 +65,11 @@
 
 acpi_status
 acpi_get_type (
-	acpi_handle             handle,
-	acpi_object_type        *ret_type)
+	acpi_handle                     handle,
+	acpi_object_type                *ret_type)
 {
-	acpi_namespace_node     *node;
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
 
 
 	/* Parameter Validation */
@@ -371,30 +87,33 @@
 		return (AE_OK);
 	}
 
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return (status);
+	}
 
 	/* Convert and validate the handle */
 
 	node = acpi_ns_map_handle_to_node (handle);
 	if (!node) {
-		acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+		(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 		return (AE_BAD_PARAMETER);
 	}
 
 	*ret_type = node->type;
 
 
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
-	return (AE_OK);
+	status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	return (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_get_parent
+ * FUNCTION:    acpi_get_parent
  *
  * PARAMETERS:  Handle          - Handle of object whose parent is desired
- *              Ret_handle      - Where the parent handle will be placed
+ *              ret_handle      - Where the parent handle will be placed
  *
  * RETURN:      Status
  *
@@ -405,11 +124,11 @@
 
 acpi_status
 acpi_get_parent (
-	acpi_handle             handle,
-	acpi_handle             *ret_handle)
+	acpi_handle                     handle,
+	acpi_handle                     *ret_handle)
 {
-	acpi_namespace_node     *node;
-	acpi_status             status = AE_OK;
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
 
 
 	if (!ret_handle) {
@@ -422,8 +141,10 @@
 		return (AE_NULL_ENTRY);
 	}
 
-
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return (status);
+	}
 
 	/* Convert and validate the handle */
 
@@ -433,237 +154,106 @@
 		goto unlock_and_exit;
 	}
 
-
 	/* Get the parent entry */
 
 	*ret_handle =
-		acpi_ns_convert_entry_to_handle (acpi_ns_get_parent_object (node));
+		acpi_ns_convert_entry_to_handle (acpi_ns_get_parent_node (node));
 
-	/* Return exeption if parent is null */
+	/* Return exception if parent is null */
 
-	if (!acpi_ns_get_parent_object (node)) {
+	if (!acpi_ns_get_parent_node (node)) {
 		status = AE_NULL_ENTRY;
 	}
 
 
 unlock_and_exit:
 
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_walk_namespace
- *
- * PARAMETERS:  Type                - acpi_object_type to search for
- *              Start_object        - Handle in namespace where search begins
- *              Max_depth           - Depth to which search is to reach
- *              User_function       - Called when an object of "Type" is found
- *              Context             - Passed to user function
- *              Return_value        - Location where return value of
- *                                    User_function is put if terminated early
- *
- * RETURNS      Return value from the User_function if terminated early.
- *              Otherwise, returns NULL.
- *
- * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
- *              starting (and ending) at the object specified by Start_handle.
- *              The User_function is called whenever an object that matches
- *              the type parameter is found.  If the user function returns
- *              a non-zero value, the search is terminated immediately and this
- *              value is returned to the caller.
- *
- *              The point of this procedure is to provide a generic namespace
- *              walk routine that can be called from multiple places to
- *              provide multiple services;  the User Function can be tailored
- *              to each task, whether it is a print function, a compare
- *              function, etc.
+ * FUNCTION:    acpi_get_next_object
  *
- ******************************************************************************/
-
-acpi_status
-acpi_walk_namespace (
-	acpi_object_type        type,
-	acpi_handle             start_object,
-	u32                     max_depth,
-	acpi_walk_callback      user_function,
-	void                    *context,
-	void                    **return_value)
-{
-	acpi_status             status;
-
-
-	FUNCTION_TRACE ("Acpi_walk_namespace");
-
-
-	/* Parameter validation */
-
-	if ((type > ACPI_TYPE_MAX)  ||
-		(!max_depth)            ||
-		(!user_function)) {
-		return_ACPI_STATUS (AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Lock the namespace around the walk.
-	 * The namespace will be unlocked/locked around each call
-	 * to the user function - since this function
-	 * must be allowed to make Acpi calls itself.
-	 */
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
-	status = acpi_ns_walk_namespace ((acpi_object_type8) type, start_object,
-			  max_depth, NS_WALK_UNLOCK, user_function, context,
-			  return_value);
-
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
-
-	return_ACPI_STATUS (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ns_get_device_callback
- *
- * PARAMETERS:  Callback from Acpi_get_device
+ * PARAMETERS:  Type            - Type of object to be searched for
+ *              Parent          - Parent object whose children we are getting
+ *              last_child      - Previous child that was found.
+ *                                The NEXT child will be returned
+ *              ret_handle      - Where handle to the next object is placed
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Takes callbacks from Walk_namespace and filters out all non-
- *              present devices, or if they specified a HID, it filters based
- *              on that.
+ * DESCRIPTION: Return the next peer object within the namespace.  If Handle is
+ *              valid, Scope is ignored.  Otherwise, the first object within
+ *              Scope is returned.
  *
  ******************************************************************************/
 
-static acpi_status
-acpi_ns_get_device_callback (
-	acpi_handle             obj_handle,
-	u32                     nesting_level,
-	void                    *context,
-	void                    **return_value)
+acpi_status
+acpi_get_next_object (
+	acpi_object_type                type,
+	acpi_handle                     parent,
+	acpi_handle                     child,
+	acpi_handle                     *ret_handle)
 {
-	acpi_status             status;
-	acpi_namespace_node     *node;
-	u32                     flags;
-	acpi_device_id          device_id;
-	acpi_get_devices_info   *info;
+	acpi_status                     status;
+	struct acpi_namespace_node      *node;
+	struct acpi_namespace_node      *parent_node = NULL;
+	struct acpi_namespace_node      *child_node = NULL;
 
 
-	info = context;
-
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
-	node = acpi_ns_map_handle_to_node (obj_handle);
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	/* Parameter validation */
 
-	if (!node) {
+	if (type > ACPI_TYPE_EXTERNAL_MAX) {
 		return (AE_BAD_PARAMETER);
 	}
 
-	/*
-	 * Run _STA to determine if device is present
-	 */
-	status = acpi_ut_execute_STA (node, &flags);
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
 	if (ACPI_FAILURE (status)) {
-		return (AE_CTRL_DEPTH);
+		return (status);
 	}
 
-	if (!(flags & 0x01)) {
-		/* don't return at the device or children of the device if not there */
-		return (AE_CTRL_DEPTH);
-	}
+	/* If null handle, use the parent */
 
-	/*
-	 * Filter based on device HID
-	 */
-	if (info->hid != NULL) {
-		status = acpi_ut_execute_HID (node, &device_id);
-		if (status == AE_NOT_FOUND) {
-			return (AE_OK);
-		}
+	if (!child) {
+		/* Start search at the beginning of the specified scope */
 
-		else if (ACPI_FAILURE (status)) {
-			return (AE_CTRL_DEPTH);
+		parent_node = acpi_ns_map_handle_to_node (parent);
+		if (!parent_node) {
+			status = AE_BAD_PARAMETER;
+			goto unlock_and_exit;
 		}
+	}
+	else {
+		/* Non-null handle, ignore the parent */
+		/* Convert and validate the handle */
 
-		if (STRNCMP (device_id.buffer, info->hid, sizeof (device_id.buffer)) != 0) {
-			return (AE_OK);
+		child_node = acpi_ns_map_handle_to_node (child);
+		if (!child_node) {
+			status = AE_BAD_PARAMETER;
+			goto unlock_and_exit;
 		}
 	}
 
-	info->user_function (obj_handle, nesting_level, info->context, return_value);
-	return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_get_devices
- *
- * PARAMETERS:  HID                 - HID to search for. Can be NULL.
- *              User_function       - Called when a matching object is found
- *              Context             - Passed to user function
- *              Return_value        - Location where return value of
- *                                    User_function is put if terminated early
- *
- * RETURNS      Return value from the User_function if terminated early.
- *              Otherwise, returns NULL.
- *
- * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
- *              starting (and ending) at the object specified by Start_handle.
- *              The User_function is called whenever an object that matches
- *              the type parameter is found.  If the user function returns
- *              a non-zero value, the search is terminated immediately and this
- *              value is returned to the caller.
- *
- *              This is a wrapper for Walk_namespace, but the callback performs
- *              additional filtering. Please see Acpi_get_device_callback.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_get_devices (
-	NATIVE_CHAR             *HID,
-	acpi_walk_callback      user_function,
-	void                    *context,
-	void                    **return_value)
-{
-	acpi_status             status;
-	acpi_get_devices_info   info;
-
-
-	FUNCTION_TRACE ("Acpi_get_devices");
-
-
-	/* Parameter validation */
+	/* Internal function does the real work */
 
-	if (!user_function) {
-		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	node = acpi_ns_get_next_node (type, parent_node, child_node);
+	if (!node) {
+		status = AE_NOT_FOUND;
+		goto unlock_and_exit;
 	}
 
-	/*
-	 * We're going to call their callback from OUR callback, so we need
-	 * to know what it is, and their context parameter.
-	 */
-	info.context      = context;
-	info.user_function = user_function;
-	info.hid          = HID;
+	if (ret_handle) {
+		*ret_handle = acpi_ns_convert_entry_to_handle (node);
+	}
 
-	/*
-	 * Lock the namespace around the walk.
-	 * The namespace will be unlocked/locked around each call
-	 * to the user function - since this function
-	 * must be allowed to make Acpi calls itself.
-	 */
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
-	status = acpi_ns_walk_namespace (ACPI_TYPE_DEVICE,
-			   ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
-			   NS_WALK_UNLOCK,
-			   acpi_ns_get_device_callback, &info,
-			   return_value);
 
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+unlock_and_exit:
 
-	return_ACPI_STATUS (status);
+	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	return (status);
 }
+
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/numa.c linux-2.4.22-pre2/drivers/acpi/numa.c
--- linux-2.4.21/drivers/acpi/numa.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/numa.c	2003-06-26 21:43:22.000000000 +0000
@@ -0,0 +1,187 @@
+/*
+ *  acpi_numa.c - ACPI NUMA support
+ *
+ *  Copyright (C) 2002 Takayoshi Kochi <t-kochi@bq.jp.nec.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/config.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/acpi.h>
+
+#define PREFIX			"ACPI: "
+
+extern int __init acpi_table_parse_madt_family (enum acpi_table_id id, unsigned long madt_size, int entry_id, acpi_madt_entry_handler handler);
+
+void __init
+acpi_table_print_srat_entry (
+	acpi_table_entry_header	*header)
+{
+	if (!header)
+		return;
+
+	switch (header->type) {
+
+	case ACPI_SRAT_PROCESSOR_AFFINITY:
+	{
+		struct acpi_table_processor_affinity *p =
+			(struct acpi_table_processor_affinity*) header;
+		printk(KERN_INFO PREFIX "SRAT Processor (id[0x%02x] eid[0x%02x]) in proximity domain %d %s\n",
+		       p->apic_id, p->lsapic_eid, p->proximity_domain,
+		       p->flags.enabled?"enabled":"disabled");
+	}
+		break;
+
+	case ACPI_SRAT_MEMORY_AFFINITY:
+	{
+		struct acpi_table_memory_affinity *p =
+			(struct acpi_table_memory_affinity*) header;
+		printk(KERN_INFO PREFIX "SRAT Memory (0x%08x%08x length 0x%08x%08x type 0x%x) in proximity domain %d %s%s\n",
+		       p->base_addr_hi, p->base_addr_lo, p->length_hi, p->length_lo,
+		       p->memory_type, p->proximity_domain,
+		       p->flags.enabled ? "enabled" : "disabled",
+		       p->flags.hot_pluggable ? " hot-pluggable" : "");
+	}
+		break;
+
+	default:
+		printk(KERN_WARNING PREFIX "Found unsupported SRAT entry (type = 0x%x)\n",
+			header->type);
+		break;
+	}
+}
+
+
+static int __init
+acpi_parse_slit (unsigned long phys_addr, unsigned long size)
+{
+	struct acpi_table_slit	*slit;
+	u32			localities;
+
+	if (!phys_addr || !size)
+		return -EINVAL;
+
+	slit = (struct acpi_table_slit *) __va(phys_addr);
+
+	/* downcast just for %llu vs %lu for i386/ia64  */
+	localities = (u32) slit->localities;
+
+	printk(KERN_INFO PREFIX "SLIT localities %ux%u\n", localities, localities);
+
+	acpi_numa_slit_init(slit);
+
+	return 0;
+}
+
+
+static int __init
+acpi_parse_processor_affinity (acpi_table_entry_header *header)
+{
+	struct acpi_table_processor_affinity *processor_affinity = NULL;
+
+	processor_affinity = (struct acpi_table_processor_affinity*) header;
+	if (!processor_affinity)
+		return -EINVAL;
+
+	acpi_table_print_srat_entry(header);
+
+	/* let architecture-dependent part to do it */
+	acpi_numa_processor_affinity_init(processor_affinity);
+
+	return 0;
+}
+
+
+static int __init
+acpi_parse_memory_affinity (acpi_table_entry_header *header)
+{
+	struct acpi_table_memory_affinity *memory_affinity = NULL;
+
+	memory_affinity = (struct acpi_table_memory_affinity*) header;
+	if (!memory_affinity)
+		return -EINVAL;
+
+	acpi_table_print_srat_entry(header);
+
+	/* let architecture-dependent part to do it */
+	acpi_numa_memory_affinity_init(memory_affinity);
+
+	return 0;
+}
+
+
+static int __init
+acpi_parse_srat (unsigned long phys_addr, unsigned long size)
+{
+	struct acpi_table_srat	*srat = NULL;
+
+	if (!phys_addr || !size)
+		return -EINVAL;
+
+	srat = (struct acpi_table_srat *) __va(phys_addr);
+
+	printk(KERN_INFO PREFIX "SRAT revision %d\n", srat->table_revision);
+
+	return 0;
+}
+
+
+int __init
+acpi_table_parse_srat (
+	enum acpi_srat_entry_id	id,
+	acpi_madt_entry_handler	handler)
+{
+	return acpi_table_parse_madt_family(ACPI_SRAT, sizeof(struct acpi_table_srat),
+					    id, handler);
+}
+
+
+int __init
+acpi_numa_init()
+{
+	int			result;
+
+	/* SRAT: Static Resource Affinity Table */
+	result = acpi_table_parse(ACPI_SRAT, acpi_parse_srat);
+
+	if (result > 0) {
+		result = acpi_table_parse_srat(ACPI_SRAT_PROCESSOR_AFFINITY,
+					       acpi_parse_processor_affinity);
+		result = acpi_table_parse_srat(ACPI_SRAT_MEMORY_AFFINITY,
+					       acpi_parse_memory_affinity);
+	} else {
+		/* FIXME */
+		printk("Warning: acpi_table_parse(ACPI_SRAT) returned %d!\n",result);
+	}
+
+	/* SLIT: System Locality Information Table */
+	result = acpi_table_parse(ACPI_SLIT, acpi_parse_slit);
+	if (result < 1) {
+		/* FIXME */
+		printk("Warning: acpi_table_parse(ACPI_SLIT) returned %d!\n",result);
+	}
+
+	acpi_numa_arch_fixup();
+	return 0;
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/os.c linux-2.4.22-pre2/drivers/acpi/os.c
--- linux-2.4.21/drivers/acpi/os.c	2002-11-28 23:53:12.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/os.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,920 +0,0 @@
-/******************************************************************************
- * 
- * Module Name: os.c - Linux OSL functions
- *		$Revision: 49 $
- *
- *****************************************************************************/
-
-/*
- *  os.c - OS-dependent functions
- *
- *  Copyright (C) 2000 Andrew Henroid
- *  Copyright (C) 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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
- */
-/* Changes
- *
- * Christopher Liebman <liebman@sponsera.com> 2001-5-15
- * - Fixed improper kernel_thread parameters 
- */
-
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/mm.h>
-#include <linux/pci.h>
-#include <linux/interrupt.h>
-#include <linux/kmod.h>
-#include <linux/delay.h>
-#include <asm/io.h>
-#include <acpi.h>
-
-#ifdef CONFIG_ACPI_EFI
-#include <linux/efi.h>
-#endif
-
-#ifdef _IA64
-#include <asm/hw_irq.h>
-#endif 
-
-#define _COMPONENT	ACPI_OS_SERVICES
-	MODULE_NAME	("os")
-
-typedef struct 
-{
-    OSD_EXECUTION_CALLBACK  function;
-    void		    *context;
-} ACPI_OS_DPC;
-
-
-/*****************************************************************************
- *			       Debugger Stuff
- *****************************************************************************/
-
-#ifdef ENABLE_DEBUGGER
-
-#include <linux/kdb.h>
-
-/* stuff for debugger support */
-int acpi_in_debugger = 0;
-extern NATIVE_CHAR line_buf[80];
-
-#endif
-
-
-/*****************************************************************************
- *				    Globals
- *****************************************************************************/
-
-static int acpi_irq_irq = 0;
-static OSD_HANDLER acpi_irq_handler = NULL;
-static void *acpi_irq_context = NULL;
-
-
-/******************************************************************************
- *				   Functions
- *****************************************************************************/
-
-acpi_status
-acpi_os_initialize(void)
-{
-	return AE_OK;
-}
-
-acpi_status
-acpi_os_terminate(void)
-{
-	if (acpi_irq_handler) {
-		acpi_os_remove_interrupt_handler(acpi_irq_irq,
-						 acpi_irq_handler);
-	}
-
-	return AE_OK;
-}
-
-s32
-acpi_os_printf(const NATIVE_CHAR *fmt,...)
-{
-	s32 size;
-	va_list args;
-	va_start(args, fmt);
-	size = acpi_os_vprintf(fmt, args);
-	va_end(args);
-
-	return size;
-}
-
-s32
-acpi_os_vprintf(const NATIVE_CHAR *fmt, va_list args)
-{
-	static char buffer[512];
-	int size = vsprintf(buffer, fmt, args);
-
-#ifdef ENABLE_DEBUGGER
-	if (acpi_in_debugger) {
-		kdb_printf("%s", buffer);
-	} else {
-		printk("%s", buffer);
-	}
-#else
-	printk("%s", buffer);
-#endif
-
-	return size;
-}
-
-void *
-acpi_os_allocate(u32 size)
-{
-	return kmalloc(size, GFP_KERNEL);
-}
-
-void *
-acpi_os_callocate(u32 size)
-{
-	void *ptr = acpi_os_allocate(size);
-	if (ptr)
-		memset(ptr, 0, size);
-
-	return ptr;
-}
-
-void
-acpi_os_free(void *ptr)
-{
-	kfree(ptr);
-}
-
-
-acpi_status
-acpi_os_get_root_pointer(u32 flags, ACPI_PHYSICAL_ADDRESS *phys_addr)
-{
-#ifndef CONFIG_ACPI_EFI
-	if (ACPI_FAILURE(acpi_find_root_pointer(flags, phys_addr))) {
-		printk(KERN_ERR "ACPI: System description tables not found\n");
-		return AE_ERROR;
-	}
-#else /*CONFIG_ACPI_EFI*/
-	if (efi.acpi20)
-		*phys_addr = (ACPI_PHYSICAL_ADDRESS) efi.acpi20;
-	else if (efi.acpi)
-		*phys_addr = (ACPI_PHYSICAL_ADDRESS) efi.acpi;
-	else {
-		printk(KERN_ERR "ACPI: System description tables not found\n");
-		*phys_addr = NULL;
-		return AE_ERROR;
-	}
-#endif /*CONFIG_ACPI_EFI*/
-
-	return AE_OK;
-}
-
-acpi_status
-acpi_os_map_memory(ACPI_PHYSICAL_ADDRESS phys, u32 size, void **virt)
-{
-	if (phys > ULONG_MAX) {
-		printk(KERN_ERR "ACPI: Cannot map memory that high\n");
-		return AE_ERROR;
-	}
-
-	*virt = ioremap((unsigned long) phys, size);
-	if (!*virt)
-		return AE_ERROR;
-
-	return AE_OK;
-}
-
-void
-acpi_os_unmap_memory(void *virt, u32 size)
-{
-	iounmap(virt);
-}
-
-acpi_status
-acpi_os_get_physical_address(void *virt, ACPI_PHYSICAL_ADDRESS *phys)
-{
-	if(!phys || !virt)
-		return AE_BAD_PARAMETER;
-
-	*phys = virt_to_phys(virt);
-
-	return AE_OK;
-}
-
-static void
-acpi_irq(int irq, void *dev_id, struct pt_regs *regs)
-{
-	(*acpi_irq_handler)(acpi_irq_context);
-}
-
-acpi_status
-acpi_os_install_interrupt_handler(u32 irq, OSD_HANDLER handler, void *context)
-{
-#ifdef _IA64
-	irq = isa_irq_to_vector(irq);
-#endif /*_IA64*/
-	acpi_irq_irq = irq;
-	acpi_irq_handler = handler;
-	acpi_irq_context = context;
-	if (request_irq(irq,
-			acpi_irq,
-			SA_SHIRQ,
-			"acpi",
-			acpi_irq)) {
-		printk(KERN_ERR "ACPI: SCI (IRQ%d) allocation failed\n", irq);
-		return AE_ERROR;
-	}
-
-	return AE_OK;
-}
-
-acpi_status
-acpi_os_remove_interrupt_handler(u32 irq, OSD_HANDLER handler)
-{
-	if (acpi_irq_handler) {
-#ifdef _IA64
-		irq = isa_irq_to_vector(irq);
-#endif /*_IA64*/
-		free_irq(irq, acpi_irq);
-		acpi_irq_handler = NULL;
-	}
-
-	return AE_OK;
-}
-
-/*
- * Running in interpreter thread context, safe to sleep
- */
-
-void
-acpi_os_sleep(u32 sec, u32 ms)
-{
-	current->state = TASK_INTERRUPTIBLE;
-	schedule_timeout(HZ * sec + (ms * HZ) / 1000);
-}
-
-void
-acpi_os_stall(u32 us)
-{
-	if (us > 10000) {
-		mdelay(us / 1000);
-	}
-	else {
-		udelay(us);
-	}
-}
-
-acpi_status
-acpi_os_read_port(
-	ACPI_IO_ADDRESS	port,
-	void		*value,
-	u32		width)
-{
-	u32 dummy;
-
-	if (!value)
-		value = &dummy;
-
-	switch (width)
-	{
-	case 8:
-		*(u8*)  value = inb(port);
-		break;
-	case 16:
-		*(u16*) value = inw(port);
-		break;
-	case 32:
-		*(u32*) value = inl(port);
-		break;
-	default:
-		BUG();
-	}
-
-	return AE_OK;
-}
-
-acpi_status
-acpi_os_write_port(
-	ACPI_IO_ADDRESS	port,
-	NATIVE_UINT	value,
-	u32		width)
-{
-	switch (width)
-	{
-	case 8:
-		outb(value, port);
-		break;
-	case 16:
-		outw(value, port);
-		break;
-	case 32:
-		outl(value, port);
-		break;
-	default:
-		BUG();
-	}
-
-	return AE_OK;
-}
-
-acpi_status
-acpi_os_read_memory(
-	ACPI_PHYSICAL_ADDRESS	phys_addr,
-	void			*value,
-	u32			width)
-{
-	u32 dummy;
-
-	if (!value)
-		value = &dummy;
-
-	switch (width)
-	{
-	case 8:
-		*(u8*) value = *(u8*) phys_to_virt(phys_addr);
-		break;
-	case 16:
-		*(u16*) value = *(u16*) phys_to_virt(phys_addr);
-		break;
-	case 32:
-		*(u32*) value = *(u32*) phys_to_virt(phys_addr);
-		break;
-	default:
-		BUG();
-	}
-
-	return AE_OK;
-}
-
-acpi_status
-acpi_os_write_memory(
-	ACPI_PHYSICAL_ADDRESS	phys_addr,
-	NATIVE_UINT		value,
-	u32			width)
-{
-	switch (width)
-	{
-	case 8:
-		*(u8*) phys_to_virt(phys_addr) = value;
-		break;
-	case 16:
-		*(u16*) phys_to_virt(phys_addr) = value;
-		break;
-	case 32:
-		*(u32*) phys_to_virt(phys_addr) = value;
-		break;
-	default:
-		BUG();
-	}
-
-	return AE_OK;
-}
-
-
-#ifdef CONFIG_ACPI_PCI
-
-/* Architecture-dependent low-level PCI configuration access functions. */
-extern int (*pci_config_read)(int seg, int bus, int dev, int fn, int reg, int len, u32 *val);
-extern int (*pci_config_write)(int seg, int bus, int dev, int fn, int reg, int len, u32 val);
-
-acpi_status
-acpi_os_read_pci_configuration (
-	acpi_pci_id             *pci_id,
-	u32                     reg,
-	void                    *value,
-	u32                     width)
-{
-	int			result = 0;
-	if (!value)
-		return AE_ERROR;
-
-	switch (width)
-	{
-	case 8:
-		result = pci_config_read(pci_id->segment, pci_id->bus, 
-			pci_id->device, pci_id->function, reg, 1, value);
-		break;
-	case 16:
-		result = pci_config_read(pci_id->segment, pci_id->bus, 
-			pci_id->device, pci_id->function, reg, 2, value);
-		break;
-	case 32:
-		result = pci_config_read(pci_id->segment, pci_id->bus, 
-			pci_id->device, pci_id->function, reg, 4, value);
-		break;
-	default:
-		BUG();
-	}
-
-	return (result ? AE_ERROR : AE_OK);
-}
-
-ACPI_STATUS
-acpi_os_write_pci_configuration (
-	acpi_pci_id             *pci_id,
-	u32                     reg,
-	NATIVE_UINT             value,
-	u32                     width)
-{
-	int			result = 0;
-
-	switch (width)
-	{
-	case 8:
-		result = pci_config_write(pci_id->segment, pci_id->bus, 
-			pci_id->device, pci_id->function, reg, 1, value);
-		break;
-	case 16:
-		result = pci_config_write(pci_id->segment, pci_id->bus, 
-			pci_id->device, pci_id->function, reg, 2, value);
-		break;
-	case 32:
-		result = pci_config_write(pci_id->segment, pci_id->bus, 
-			pci_id->device, pci_id->function, reg, 4, value);
-		break;
-	default:
-		BUG();
-	}
-
-	return (result ? AE_ERROR : AE_OK);
-}
-
-#else /*CONFIG_ACPI_PCI*/
-
-acpi_status
-acpi_os_read_pci_configuration (
-	acpi_pci_id	*pci_id,
-	u32		reg,
-	void		*value,
-	u32		width)
-{
-	int devfn = PCI_DEVFN(pci_id->device, pci_id->function);
-	struct pci_dev *dev = pci_find_slot(pci_id->bus, devfn);
-
-	if (!value || !dev)
-		return AE_ERROR;
-
-	switch (width)
-	{
-	case 8:
-		if (pci_read_config_byte(dev, reg, (u8*) value))
-			return AE_ERROR;
-		break;
-	case 16:
-		if (pci_read_config_word(dev, reg, (u16*) value))
-			return AE_ERROR;
-		break;
-	case 32:
-		if (pci_read_config_dword(dev, reg, (u32*) value))
-			return AE_ERROR;
-		break;
-	default:
-		BUG();
-	}
-
-	return AE_OK;
-}
-
-acpi_status
-acpi_os_write_pci_configuration (
-	acpi_pci_id	*pci_id,
-	u32		reg,
-	NATIVE_UINT	value,
-	u32		width)
-{
-	int devfn = PCI_DEVFN(pci_id->device, pci_id->function);
-	struct pci_dev *dev = pci_find_slot(pci_id->bus, devfn);
-
-	if (!dev)
-		return AE_ERROR;
-
-	switch (width)
-	{
-	case 8:
-		if (pci_write_config_byte(dev, reg, value))
-			return AE_ERROR;
-		break;
-	case 16:
-		if (pci_write_config_word(dev, reg, value))
-			return AE_ERROR;
-		break;
-	case 32:
-		if (pci_write_config_dword(dev, reg, value))
-			return AE_ERROR;
-		break;
-	default:
-		BUG();
-	}
-
-	return AE_OK;
-}
-
-#endif /*CONFIG_ACPI_PCI*/
-
-
-acpi_status
-acpi_os_load_module (
-	char *module_name)
-{
-	PROC_NAME("acpi_os_load_module");
-
-	if (!module_name)
-		return AE_BAD_PARAMETER;
-
-	if (0 > request_module(module_name)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Unable to load module [%s].\n", module_name));
-		return AE_ERROR;
-	}
-
-	return AE_OK;
-}
-
-acpi_status
-acpi_os_unload_module (
-	char *module_name)
-{
-	if (!module_name)
-		return AE_BAD_PARAMETER;
-
-	/* TODO: How on Linux? */
-	/* this is done automatically for all modules with
-	use_count = 0, I think. see: MOD_INC_USE_COUNT -ASG */
-
-	return AE_OK;
-}
-
-
-/*
- * See acpi_os_queue_for_execution()
- */
-static int
-acpi_os_queue_exec (
-	void *context)
-{
-	ACPI_OS_DPC		*dpc = (ACPI_OS_DPC*)context;
-
-	PROC_NAME("acpi_os_queue_exec");
-
-	daemonize();
-	strcpy(current->comm, "kacpidpc");
-    
-	if (!dpc || !dpc->function)
-		return AE_BAD_PARAMETER;
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Executing function [%p(%p)].\n", dpc->function, dpc->context));
-
-	dpc->function(dpc->context);
-
-	kfree(dpc);
-
-	return 1;
-}
-
-static void
-acpi_os_schedule_exec (
-	void *context)
-{
-	ACPI_OS_DPC		*dpc = NULL;
-	int			thread_pid = -1;
-
-	PROC_NAME("acpi_os_schedule_exec");
-
-	dpc = (ACPI_OS_DPC*)context;
-	if (!dpc) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid (NULL) context.\n"));
-		return;
-	}
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Creating new thread to run function [%p(%p)].\n", dpc->function, dpc->context));
-
-	thread_pid = kernel_thread(acpi_os_queue_exec, dpc, 
-		(CLONE_FS | CLONE_FILES | SIGCHLD));
-	if (thread_pid < 0) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Call to kernel_thread() failed.\n"));
-		acpi_os_free(dpc);
-	}
-}
-
-acpi_status
-acpi_os_queue_for_execution(
-	u32			priority,
-	OSD_EXECUTION_CALLBACK	function,
-	void			*context)
-{
-	acpi_status 		status = AE_OK;
-	ACPI_OS_DPC 		*dpc = NULL;
-
-	PROC_NAME("acpi_os_queue_for_execution");
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Scheduling function [%p(%p)] for deferred execution.\n", function, context));
-
-	if (!function)
-		return AE_BAD_PARAMETER;
-
-	/*
-	 * Queue via DPC:
-	 * --------------
-	 * Note that we have to use two different processes for queuing DPCs:
-	 *	 Interrupt-Level: Use schedule_task; can't spawn a new thread.
-	 *	    Kernel-Level: Spawn a new kernel thread, as schedule_task has
-	 *			  its limitations (e.g. single-threaded model), and
-	 *			  all other task queues run at interrupt-level.
-	 */
-	switch (priority) {
-
-	case OSD_PRIORITY_GPE:
-	{
-		static struct tq_struct task;
-
-		/*
-		 * Allocate/initialize DPC structure.  Note that this memory will be
-		 * freed by the callee.
-		 */
-		dpc = kmalloc(sizeof(ACPI_OS_DPC), GFP_ATOMIC);
-		if (!dpc) 
-			return AE_NO_MEMORY;
-
-		dpc->function = function;
-		dpc->context = context;
-
-		memset(&task, 0, sizeof(struct tq_struct));
-
-		task.routine = acpi_os_schedule_exec;
-		task.data = (void*)dpc;
-
-		if (schedule_task(&task) < 0) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Call to schedule_task() failed.\n"));
-			status = AE_ERROR;
-		}
-	}
-	break;
-
-	default:
-		/*
-		 * Allocate/initialize DPC structure.  Note that this memory will be
-		 * freed by the callee.
-		 */
-		dpc = kmalloc(sizeof(ACPI_OS_DPC), GFP_KERNEL);
-		if (!dpc) 
-			return AE_NO_MEMORY;
-
-		dpc->function = function;
-		dpc->context = context;
-
-		acpi_os_schedule_exec(dpc);
-		break;
-	}
-
-	return status;
-}
-
-
-acpi_status
-acpi_os_create_semaphore(
-	u32		max_units,
-	u32		initial_units,
-	acpi_handle	*handle)
-{
-	struct semaphore	*sem = NULL;
-
-	PROC_NAME("acpi_os_create_semaphore");
-
-	sem = acpi_os_callocate(sizeof(struct semaphore));
-	if (!sem)
-		return AE_NO_MEMORY;
-
-	sema_init(sem, initial_units);
-
-	*handle = (acpi_handle*)sem;
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Creating semaphore[%p|%d].\n", *handle, initial_units));
-
-	return AE_OK;
-}
-
-
-/* 
- * TODO: A better way to delete semaphores?  Linux doesn't have a
- * 'delete_semaphore()' function -- may result in an invalid
- * pointer dereference for non-synchronized consumers.	Should
- * we at least check for blocked threads and signal/cancel them?
- */
-
-acpi_status
-acpi_os_delete_semaphore(
-	acpi_handle	handle)
-{
-	struct semaphore *sem = (struct semaphore*) handle;
-
-	PROC_NAME("acpi_os_delete_semaphore");
-
-	if (!sem) 
-		return AE_BAD_PARAMETER;
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Deleting semaphore[%p].\n", handle));
-
-	acpi_os_free(sem); sem =  NULL;
-
-	return AE_OK;
-}
-
-
-/*
- * TODO: The kernel doesn't have a 'down_timeout' function -- had to
- * improvise.  The process is to sleep for one scheduler quantum
- * until the semaphore becomes available.  Downside is that this
- * may result in starvation for timeout-based waits when there's
- * lots of semaphore activity.
- *
- * TODO: Support for units > 1?
- */
-acpi_status
-acpi_os_wait_semaphore(
-	acpi_handle		handle,
-	u32			units,
-	u32			timeout)
-{
-	acpi_status		status = AE_OK;
-	struct semaphore	*sem = (struct semaphore*)handle;
-	int			ret = 0;
-
-	PROC_NAME("acpi_os_wait_semaphore");
-
-	if (!sem || (units < 1)) 
-		return AE_BAD_PARAMETER;
-
-	if (units > 1)
-		return AE_SUPPORT;
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Waiting for semaphore[%p|%d|%d]\n", handle, units, timeout));
-
-	switch (timeout)
-	{
-		/*
-		 * No Wait:
-		 * --------
-		 * A zero timeout value indicates that we shouldn't wait - just
-		 * acquire the semaphore if available otherwise return AE_TIME
-		 * (a.k.a. 'would block').
-		 */
-		case 0:
-		if(down_trylock(sem))
-			status = AE_TIME;
-		break;
-
-		/*
-		 * Wait Indefinitely:
-		 * ------------------
-		 */
-		case WAIT_FOREVER:
-		ret = down_interruptible(sem);
-		if (ret < 0)
-			status = AE_ERROR;
-		break;
-
-		/*
-		 * Wait w/ Timeout:
-		 * ----------------
-		 */
-		default:
-		// TODO: A better timeout algorithm?
-		{
-			int i = 0;
-			static const int quantum_ms = 1000/HZ;
-
-			ret = down_trylock(sem);
-			for (i = timeout; (i > 0 && ret < 0); i -= quantum_ms) {
-				current->state = TASK_INTERRUPTIBLE;
-				schedule_timeout(1);
-				ret = down_trylock(sem);
-			}
-	
-			if (ret != 0)
-			 status = AE_TIME;
-			}
-		break;
-	}
-
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Failed to acquire semaphore[%p|%d|%d]\n", handle, units, timeout));
-	}
-	else {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Acquired semaphore[%p|%d|%d]\n", handle, units, timeout));
-	}
-
-	return status;
-}
-
-
-/*
- * TODO: Support for units > 1?
- */
-acpi_status
-acpi_os_signal_semaphore(
-    acpi_handle 	    handle, 
-    u32 		    units)
-{
-	struct semaphore *sem = (struct semaphore *) handle;
-
-	PROC_NAME("acpi_os_signal_semaphore");
-
-	if (!sem || (units < 1)) 
-		return AE_BAD_PARAMETER;
-
-	if (units > 1)
-		return AE_SUPPORT;
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Signaling semaphore[%p|%d]\n", handle, units));
-
-	up(sem);
-
-	return AE_OK;
-}
-
-u32
-acpi_os_get_line(NATIVE_CHAR *buffer)
-{
-
-#ifdef ENABLE_DEBUGGER
-	if (acpi_in_debugger) {
-		u32 chars;
-
-		kdb_read(buffer, sizeof(line_buf));
-
-		/* remove the CR kdb includes */ 
-		chars = strlen(buffer) - 1;
-		buffer[chars] = '\0';
-	}
-#endif
-
-	return 0;
-}
-
-/*
- * We just have to assume we're dealing with valid memory
- */
-
-BOOLEAN
-acpi_os_readable(void *ptr, u32 len)
-{
-	return 1;
-}
-
-BOOLEAN
-acpi_os_writable(void *ptr, u32 len)
-{
-	return 1;
-}
-
-u32
-acpi_os_get_thread_id (void)
-{
-	if (!in_interrupt())
-		return current->pid;
-
-	return 0;
-}
-
-acpi_status
-acpi_os_signal (
-    u32		function,
-    void	*info)
-{
-	switch (function)
-	{
-	case ACPI_SIGNAL_FATAL:
-		printk(KERN_ERR "ACPI: Fatal opcode executed\n");
-		break;
-	case ACPI_SIGNAL_BREAKPOINT:
-		{
-			char *bp_info = (char*) info;
-
-			printk(KERN_ERR "ACPI breakpoint: %s\n", bp_info);
-		}
-	default:
-		break;
-	}
-
-	return AE_OK;
-}
-
-acpi_status
-acpi_os_breakpoint(NATIVE_CHAR *msg)
-{
-	acpi_os_printf("breakpoint: %s", msg);
-	
-	return AE_OK;
-}
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/osl.c linux-2.4.22-pre2/drivers/acpi/osl.c
--- linux-2.4.21/drivers/acpi/osl.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/osl.c	2003-06-26 21:43:10.000000000 +0000
@@ -0,0 +1,1014 @@
+/*
+ *  acpi_osl.c - OS-dependent functions ($Revision: 80 $)
+ *
+ *  Copyright (C) 2000       Andrew Henroid
+ *  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/config.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/mm.h>
+#include <linux/pci.h>
+#include <linux/interrupt.h>
+#include <linux/kmod.h>
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <asm/io.h>
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi.h>
+
+#ifdef CONFIG_ACPI_EFI
+#include <linux/efi.h>
+u64 efi_mem_attributes (u64 phys_addr);
+#endif
+
+
+#define _COMPONENT		ACPI_OS_SERVICES
+ACPI_MODULE_NAME	("osl")
+
+#define PREFIX		"ACPI: "
+
+struct acpi_os_dpc
+{
+    OSD_EXECUTION_CALLBACK  function;
+    void		    *context;
+};
+
+
+#ifdef ENABLE_DEBUGGER
+#include <linux/kdb.h>
+/* stuff for debugger support */
+int acpi_in_debugger = 0;
+extern char line_buf[80];
+#endif /*ENABLE_DEBUGGER*/
+
+static int acpi_irq_irq = 0;
+static OSD_HANDLER acpi_irq_handler = NULL;
+static void *acpi_irq_context = NULL;
+
+
+acpi_status
+acpi_os_initialize(void)
+{
+	/*
+	 * Initialize PCI configuration space access, as we'll need to access
+	 * it while walking the namespace (bus 0 and root bridges w/ _BBNs).
+	 */
+#ifdef CONFIG_ACPI_PCI
+	pcibios_config_init();
+	if (!pci_config_read || !pci_config_write) {
+		printk(KERN_ERR PREFIX "Access to PCI configuration space unavailable\n");
+		return AE_NULL_ENTRY;
+	}
+#endif
+
+	return AE_OK;
+}
+
+acpi_status
+acpi_os_terminate(void)
+{
+	if (acpi_irq_handler) {
+		acpi_os_remove_interrupt_handler(acpi_irq_irq,
+						 acpi_irq_handler);
+	}
+
+	return AE_OK;
+}
+
+void
+acpi_os_printf(const char *fmt,...)
+{
+	va_list args;
+	va_start(args, fmt);
+	acpi_os_vprintf(fmt, args);
+	va_end(args);
+}
+
+void
+acpi_os_vprintf(const char *fmt, va_list args)
+{
+	static char buffer[512];
+	
+	vsprintf(buffer, fmt, args);
+
+#ifdef ENABLE_DEBUGGER
+	if (acpi_in_debugger) {
+		kdb_printf("%s", buffer);
+	} else {
+		printk("%s", buffer);
+	}
+#else
+	printk("%s", buffer);
+#endif
+}
+
+void *
+acpi_os_allocate(acpi_size size)
+{
+	return kmalloc(size, GFP_KERNEL);
+}
+
+void
+acpi_os_free(void *ptr)
+{
+	kfree(ptr);
+}
+
+acpi_status
+acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr)
+{
+#ifdef CONFIG_ACPI_EFI
+	addr->pointer_type = ACPI_PHYSICAL_POINTER;
+	if (efi.acpi20)
+		addr->pointer.physical = (acpi_physical_address) virt_to_phys(efi.acpi20);
+	else if (efi.acpi)
+		addr->pointer.physical = (acpi_physical_address) virt_to_phys(efi.acpi);
+	else {
+		printk(KERN_ERR PREFIX "System description tables not found\n");
+		return AE_NOT_FOUND;
+	}
+#else
+	if (ACPI_FAILURE(acpi_find_root_pointer(flags, addr))) {
+		printk(KERN_ERR PREFIX "System description tables not found\n");
+		return AE_NOT_FOUND;
+	}
+#endif /*CONFIG_ACPI_EFI*/
+
+	return AE_OK;
+}
+
+acpi_status
+acpi_os_map_memory(acpi_physical_address phys, acpi_size size, void **virt)
+{
+#ifdef CONFIG_ACPI_EFI
+	if (EFI_MEMORY_WB & efi_mem_attributes(phys)) {
+		*virt = phys_to_virt(phys);
+	} else {
+		*virt = ioremap(phys, size);
+	}
+#else
+	if (phys > ULONG_MAX) {
+		printk(KERN_ERR PREFIX "Cannot map memory that high\n");
+		return AE_BAD_PARAMETER;
+	}
+	/*
+	 * ioremap checks to ensure this is in reserved space
+	 */
+	*virt = ioremap((unsigned long) phys, size);
+#endif
+
+	if (!*virt)
+		return AE_NO_MEMORY;
+
+	return AE_OK;
+}
+
+void
+acpi_os_unmap_memory(void *virt, acpi_size size)
+{
+	iounmap(virt);
+}
+
+acpi_status
+acpi_os_get_physical_address(void *virt, acpi_physical_address *phys)
+{
+	if(!phys || !virt)
+		return AE_BAD_PARAMETER;
+
+	*phys = virt_to_phys(virt);
+
+	return AE_OK;
+}
+
+#define ACPI_MAX_OVERRIDE_LEN 100
+
+static char __initdata acpi_os_name[ACPI_MAX_OVERRIDE_LEN];
+
+acpi_status
+acpi_os_predefined_override (const struct acpi_predefined_names *init_val,
+		             acpi_string *new_val)
+{
+	if (!init_val || !new_val)
+		return AE_BAD_PARAMETER;
+
+	*new_val = NULL;
+	if (!memcmp (init_val->name, "_OS_", 4) && strlen(acpi_os_name)) {
+		printk(KERN_INFO PREFIX "Overriding _OS definition: %s\n",
+		       acpi_os_name);
+		*new_val = acpi_os_name;
+	}
+
+	return AE_OK;
+}
+
+acpi_status
+acpi_os_table_override (struct acpi_table_header *existing_table,
+			struct acpi_table_header **new_table)
+{
+	if (!existing_table || !new_table)
+		return AE_BAD_PARAMETER;
+
+	*new_table = NULL;
+	return AE_OK;
+}
+
+static void
+acpi_irq(int irq, void *dev_id, struct pt_regs *regs)
+{
+	(*acpi_irq_handler)(acpi_irq_context);
+}
+
+acpi_status
+acpi_os_install_interrupt_handler(u32 irq, OSD_HANDLER handler, void *context)
+{
+	/*
+	 * Ignore the irq from the core, and use the value in our copy of the
+	 * FADT. It may not be the same if an interrupt source override exists
+	 * for the SCI.
+	 */
+	irq = acpi_fadt.sci_int;
+
+#ifdef CONFIG_IA64
+	irq = gsi_to_vector(irq);
+#endif
+	acpi_irq_irq = irq;
+	acpi_irq_handler = handler;
+	acpi_irq_context = context;
+	if (request_irq(irq, acpi_irq, SA_SHIRQ, "acpi", acpi_irq)) {
+		printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq);
+		return AE_NOT_ACQUIRED;
+	}
+
+	return AE_OK;
+}
+
+acpi_status
+acpi_os_remove_interrupt_handler(u32 irq, OSD_HANDLER handler)
+{
+	if (acpi_irq_handler) {
+#ifdef CONFIG_IA64
+		irq = gsi_to_vector(irq);
+#endif
+		free_irq(irq, acpi_irq);
+		acpi_irq_handler = NULL;
+	}
+
+	return AE_OK;
+}
+
+/*
+ * Running in interpreter thread context, safe to sleep
+ */
+
+void
+acpi_os_sleep(u32 sec, u32 ms)
+{
+	current->state = TASK_INTERRUPTIBLE;
+	schedule_timeout(HZ * sec + (ms * HZ) / 1000);
+}
+
+void
+acpi_os_stall(u32 us)
+{
+	if (us > 10000) {
+		mdelay(us / 1000);
+	}
+	else {
+		udelay(us);
+	}
+}
+
+acpi_status
+acpi_os_read_port(
+	acpi_io_address	port,
+	u32		*value,
+	u32		width)
+{
+	u32 dummy;
+
+	if (!value)
+		value = &dummy;
+
+	switch (width)
+	{
+	case 8:
+		*(u8*)  value = inb(port);
+		break;
+	case 16:
+		*(u16*) value = inw(port);
+		break;
+	case 32:
+		*(u32*) value = inl(port);
+		break;
+	default:
+		BUG();
+	}
+
+	return AE_OK;
+}
+
+acpi_status
+acpi_os_write_port(
+	acpi_io_address	port,
+	u32		value,
+	u32		width)
+{
+	switch (width)
+	{
+	case 8:
+		outb(value, port);
+		break;
+	case 16:
+		outw(value, port);
+		break;
+	case 32:
+		outl(value, port);
+		break;
+	default:
+		BUG();
+	}
+
+	return AE_OK;
+}
+
+acpi_status
+acpi_os_read_memory(
+	acpi_physical_address	phys_addr,
+	u32			*value,
+	u32			width)
+{
+	u32			dummy;
+	void			*virt_addr;
+
+#ifdef CONFIG_ACPI_EFI
+	int			iomem = 0;
+
+	if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) {
+		virt_addr = phys_to_virt(phys_addr);
+	} else {
+		iomem = 1;
+		virt_addr = ioremap(phys_addr, width);
+	}
+#else
+	virt_addr = phys_to_virt(phys_addr);
+#endif
+	if (!value)
+		value = &dummy;
+
+	switch (width) {
+	case 8:
+		*(u8*) value = *(u8*) virt_addr;
+		break;
+	case 16:
+		*(u16*) value = *(u16*) virt_addr;
+		break;
+	case 32:
+		*(u32*) value = *(u32*) virt_addr;
+		break;
+	default:
+		BUG();
+	}
+
+#ifdef CONFIG_ACPI_EFI
+	if (iomem)
+		iounmap(virt_addr);
+#endif
+
+	return AE_OK;
+}
+
+acpi_status
+acpi_os_write_memory(
+	acpi_physical_address	phys_addr,
+	u32			value,
+	u32			width)
+{
+	void			*virt_addr;
+
+#ifdef CONFIG_ACPI_EFI
+	int			iomem = 0;
+
+	if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) {
+		virt_addr = phys_to_virt(phys_addr);
+	} else {
+		iomem = 1;
+		virt_addr = ioremap(phys_addr, width);
+	}
+#else
+	virt_addr = phys_to_virt(phys_addr);
+#endif
+
+	switch (width) {
+	case 8:
+		*(u8*) virt_addr = value;
+		break;
+	case 16:
+		*(u16*) virt_addr = value;
+		break;
+	case 32:
+		*(u32*) virt_addr = value;
+		break;
+	default:
+		BUG();
+	}
+
+#ifdef CONFIG_ACPI_EFI
+	if (iomem)
+		iounmap(virt_addr);
+#endif
+
+	return AE_OK;
+}
+
+#ifdef CONFIG_ACPI_PCI
+
+acpi_status
+acpi_os_read_pci_configuration (
+	struct acpi_pci_id	*pci_id,
+	u32			reg,
+	void			*value,
+	u32			width)
+{
+	int			result = 0;
+	if (!value)
+		return AE_BAD_PARAMETER;
+
+	switch (width)
+	{
+	case 8:
+		result = pci_config_read(pci_id->segment, pci_id->bus,
+			pci_id->device, pci_id->function, reg, 1, value);
+		break;
+	case 16:
+		result = pci_config_read(pci_id->segment, pci_id->bus,
+			pci_id->device, pci_id->function, reg, 2, value);
+		break;
+	case 32:
+		result = pci_config_read(pci_id->segment, pci_id->bus,
+			pci_id->device, pci_id->function, reg, 4, value);
+		break;
+	default:
+		BUG();
+	}
+
+	return (result ? AE_ERROR : AE_OK);
+}
+
+acpi_status
+acpi_os_write_pci_configuration (
+	struct acpi_pci_id	*pci_id,
+	u32			reg,
+	acpi_integer		value,
+	u32			width)
+{
+	int			result = 0;
+
+	switch (width)
+	{
+	case 8:
+		result = pci_config_write(pci_id->segment, pci_id->bus,
+			pci_id->device, pci_id->function, reg, 1, value);
+		break;
+	case 16:
+		result = pci_config_write(pci_id->segment, pci_id->bus,
+			pci_id->device, pci_id->function, reg, 2, value);
+		break;
+	case 32:
+		result = pci_config_write(pci_id->segment, pci_id->bus,
+			pci_id->device, pci_id->function, reg, 4, value);
+		break;
+	default:
+		BUG();
+	}
+
+	return (result ? AE_ERROR : AE_OK);
+}
+
+static void
+acpi_os_derive_pci_id_2 (
+	acpi_handle		rhandle,        /* upper bound  */
+	acpi_handle		chandle,        /* current node */
+	struct acpi_pci_id	**id,
+	int			*is_bridge,
+	u8			*bus_number)
+{
+	acpi_handle		handle;
+	struct acpi_pci_id	*pci_id = *id;
+	acpi_status		status;
+	unsigned long		temp;
+	acpi_object_type	type;
+	u8			tu8;
+
+	acpi_get_parent(chandle, &handle);
+	if (handle != rhandle) {
+		acpi_os_derive_pci_id_2(rhandle, handle, &pci_id, is_bridge, bus_number);
+
+		status = acpi_get_type(handle, &type);
+		if ( (ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE) )
+			return;
+
+		status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &temp);
+		if (ACPI_SUCCESS(status)) {
+			pci_id->device  = ACPI_HIWORD (ACPI_LODWORD (temp));
+			pci_id->function = ACPI_LOWORD (ACPI_LODWORD (temp));
+
+			if (*is_bridge)
+				pci_id->bus = *bus_number;
+
+			/* any nicer way to get bus number of bridge ? */
+			status = acpi_os_read_pci_configuration(pci_id, 0x0e, &tu8, 8);
+			if (ACPI_SUCCESS(status) &&
+			    ((tu8 & 0x7f) == 1 || (tu8 & 0x7f) == 2)) {
+				status = acpi_os_read_pci_configuration(pci_id, 0x18, &tu8, 8);
+				if (!ACPI_SUCCESS(status)) {
+					/* Certainly broken...  FIX ME */
+					return;
+				}
+				*is_bridge = 1;
+				pci_id->bus = tu8;
+				status = acpi_os_read_pci_configuration(pci_id, 0x19, &tu8, 8);
+				if (ACPI_SUCCESS(status)) {
+					*bus_number = tu8;
+				}
+			} else
+				*is_bridge = 0;
+		}
+	}
+}
+
+void
+acpi_os_derive_pci_id (
+	acpi_handle		rhandle,        /* upper bound  */
+	acpi_handle		chandle,        /* current node */
+	struct acpi_pci_id	**id)
+{
+	int is_bridge = 1;
+	u8 bus_number = (*id)->bus;
+
+	acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number);
+}
+
+#else /*!CONFIG_ACPI_PCI*/
+
+acpi_status
+acpi_os_write_pci_configuration (
+	struct acpi_pci_id	*pci_id,
+	u32			reg,
+	acpi_integer		value,
+	u32			width)
+{
+	return (AE_SUPPORT);
+}
+
+acpi_status
+acpi_os_read_pci_configuration (
+	struct acpi_pci_id	*pci_id,
+	u32			reg,
+	void			*value,
+	u32			width)
+{
+	return (AE_SUPPORT);
+}
+
+void
+acpi_os_derive_pci_id (
+	acpi_handle		rhandle,        /* upper bound  */
+	acpi_handle		chandle,        /* current node */
+	struct acpi_pci_id	**id)
+{
+}
+
+#endif /*CONFIG_ACPI_PCI*/
+
+static void
+acpi_os_execute_deferred (
+	void *context)
+{
+	struct acpi_os_dpc	*dpc = NULL;
+
+	ACPI_FUNCTION_TRACE ("os_execute_deferred");
+
+	dpc = (struct acpi_os_dpc *) context;
+	if (!dpc) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid (NULL) context.\n"));
+		return_VOID;
+	}
+
+	dpc->function(dpc->context);
+
+	kfree(dpc);
+
+	return_VOID;
+}
+
+acpi_status
+acpi_os_queue_for_execution(
+	u32			priority,
+	OSD_EXECUTION_CALLBACK	function,
+	void			*context)
+{
+	acpi_status 		status = AE_OK;
+	struct acpi_os_dpc	*dpc = NULL;
+	struct tq_struct	*task;
+
+	ACPI_FUNCTION_TRACE ("os_queue_for_execution");
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Scheduling function [%p(%p)] for deferred execution.\n", function, context));
+
+	if (!function)
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+
+	/*
+	 * Allocate/initialize DPC structure.  Note that this memory will be
+	 * freed by the callee.  The kernel handles the tq_struct list  in a
+	 * way that allows us to also free its memory inside the callee.
+	 * Because we may want to schedule several tasks with different
+	 * parameters we can't use the approach some kernel code uses of
+	 * having a static tq_struct.
+	 * We can save time and code by allocating the DPC and tq_structs
+	 * from the same memory.
+	 */
+	dpc = kmalloc(sizeof(struct acpi_os_dpc)+sizeof(struct tq_struct), GFP_ATOMIC);
+	if (!dpc)
+		return_ACPI_STATUS (AE_NO_MEMORY);
+
+	dpc->function = function;
+	dpc->context = context;
+
+	task = (void *)(dpc+1);
+	INIT_TQUEUE(task, acpi_os_execute_deferred, (void*)dpc);
+
+	if (!schedule_task(task)) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Call to schedule_task() failed.\n"));
+		kfree(dpc);
+		status = AE_ERROR;
+	}
+
+	return_ACPI_STATUS (status);
+}
+
+/*
+ * Allocate the memory for a spinlock and initialize it.
+ */
+acpi_status
+acpi_os_create_lock (
+	acpi_handle	*out_handle)
+{
+	spinlock_t *lock_ptr;
+
+	ACPI_FUNCTION_TRACE ("os_create_lock");
+
+	lock_ptr = acpi_os_allocate(sizeof(spinlock_t));
+
+	spin_lock_init(lock_ptr);
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Creating spinlock[%p].\n", lock_ptr));
+
+	*out_handle = lock_ptr;
+
+	return_ACPI_STATUS (AE_OK);
+}
+
+
+/*
+ * Deallocate the memory for a spinlock.
+ */
+void
+acpi_os_delete_lock (
+	acpi_handle	handle)
+{
+	ACPI_FUNCTION_TRACE ("os_create_lock");
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Deleting spinlock[%p].\n", handle));
+
+	acpi_os_free(handle);
+
+	return_VOID;
+}
+
+/*
+ * Acquire a spinlock.
+ *
+ * handle is a pointer to the spinlock_t.
+ * flags is *not* the result of save_flags - it is an ACPI-specific flag variable
+ *   that indicates whether we are at interrupt level.
+ */
+void
+acpi_os_acquire_lock (
+	acpi_handle	handle,
+	u32		flags)
+{
+	ACPI_FUNCTION_TRACE ("os_acquire_lock");
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Acquiring spinlock[%p] from %s level\n", handle,
+		((flags & ACPI_NOT_ISR) ? "non-interrupt" : "interrupt")));
+
+	if (flags & ACPI_NOT_ISR)
+		ACPI_DISABLE_IRQS();
+
+	spin_lock(handle);
+
+	return_VOID;
+}
+
+
+/*
+ * Release a spinlock. See above.
+ */
+void
+acpi_os_release_lock (
+	acpi_handle	handle,
+	u32		flags)
+{
+	ACPI_FUNCTION_TRACE ("os_release_lock");
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Releasing spinlock[%p] from %s level\n", handle,
+		((flags & ACPI_NOT_ISR) ? "non-interrupt" : "interrupt")));
+
+	spin_unlock(handle);
+
+	if (flags & ACPI_NOT_ISR)
+		ACPI_ENABLE_IRQS();
+
+	return_VOID;
+}
+
+
+acpi_status
+acpi_os_create_semaphore(
+	u32		max_units,
+	u32		initial_units,
+	acpi_handle	*handle)
+{
+	struct semaphore	*sem = NULL;
+
+	ACPI_FUNCTION_TRACE ("os_create_semaphore");
+
+	sem = acpi_os_allocate(sizeof(struct semaphore));
+	if (!sem)
+		return_ACPI_STATUS (AE_NO_MEMORY);
+	memset(sem, 0, sizeof(struct semaphore));
+
+	sema_init(sem, initial_units);
+
+	*handle = (acpi_handle*)sem;
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n", *handle, initial_units));
+
+	return_ACPI_STATUS (AE_OK);
+}
+
+
+/*
+ * TODO: A better way to delete semaphores?  Linux doesn't have a
+ * 'delete_semaphore()' function -- may result in an invalid
+ * pointer dereference for non-synchronized consumers.	Should
+ * we at least check for blocked threads and signal/cancel them?
+ */
+
+acpi_status
+acpi_os_delete_semaphore(
+	acpi_handle	handle)
+{
+	struct semaphore *sem = (struct semaphore*) handle;
+
+	ACPI_FUNCTION_TRACE ("os_delete_semaphore");
+
+	if (!sem)
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle));
+
+	acpi_os_free(sem); sem =  NULL;
+
+	return_ACPI_STATUS (AE_OK);
+}
+
+
+/*
+ * TODO: The kernel doesn't have a 'down_timeout' function -- had to
+ * improvise.  The process is to sleep for one scheduler quantum
+ * until the semaphore becomes available.  Downside is that this
+ * may result in starvation for timeout-based waits when there's
+ * lots of semaphore activity.
+ *
+ * TODO: Support for units > 1?
+ */
+acpi_status
+acpi_os_wait_semaphore(
+	acpi_handle		handle,
+	u32			units,
+	u16			timeout)
+{
+	acpi_status		status = AE_OK;
+	struct semaphore	*sem = (struct semaphore*)handle;
+	int			ret = 0;
+
+	ACPI_FUNCTION_TRACE ("os_wait_semaphore");
+
+	if (!sem || (units < 1))
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+
+	if (units > 1)
+		return_ACPI_STATUS (AE_SUPPORT);
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n", handle, units, timeout));
+
+	if (in_interrupt())
+		timeout = 0;
+
+	switch (timeout)
+	{
+		/*
+		 * No Wait:
+		 * --------
+		 * A zero timeout value indicates that we shouldn't wait - just
+		 * acquire the semaphore if available otherwise return AE_TIME
+		 * (a.k.a. 'would block').
+		 */
+		case 0:
+		if(down_trylock(sem))
+			status = AE_TIME;
+		break;
+
+		/*
+		 * Wait Indefinitely:
+		 * ------------------
+		 */
+		case ACPI_WAIT_FOREVER:
+		down(sem);
+		break;
+
+		/*
+		 * Wait w/ Timeout:
+		 * ----------------
+		 */
+		default:
+		// TODO: A better timeout algorithm?
+		{
+			int i = 0;
+			static const int quantum_ms = 1000/HZ;
+
+			ret = down_trylock(sem);
+			for (i = timeout; (i > 0 && ret < 0); i -= quantum_ms) {
+				current->state = TASK_INTERRUPTIBLE;
+				schedule_timeout(1);
+				ret = down_trylock(sem);
+			}
+	
+			if (ret != 0)
+				status = AE_TIME;
+		}
+		break;
+	}
+
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Failed to acquire semaphore[%p|%d|%d], %s\n", 
+			handle, units, timeout, acpi_format_exception(status)));
+	}
+	else {
+		ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Acquired semaphore[%p|%d|%d]\n", handle, units, timeout));
+	}
+
+	return_ACPI_STATUS (status);
+}
+
+
+/*
+ * TODO: Support for units > 1?
+ */
+acpi_status
+acpi_os_signal_semaphore(
+    acpi_handle 	    handle,
+    u32 		    units)
+{
+	struct semaphore *sem = (struct semaphore *) handle;
+
+	ACPI_FUNCTION_TRACE ("os_signal_semaphore");
+
+	if (!sem || (units < 1))
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+
+	if (units > 1)
+		return_ACPI_STATUS (AE_SUPPORT);
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle, units));
+
+	up(sem);
+
+	return_ACPI_STATUS (AE_OK);
+}
+
+u32
+acpi_os_get_line(char *buffer)
+{
+
+#ifdef ENABLE_DEBUGGER
+	if (acpi_in_debugger) {
+		u32 chars;
+
+		kdb_read(buffer, sizeof(line_buf));
+
+		/* remove the CR kdb includes */
+		chars = strlen(buffer) - 1;
+		buffer[chars] = '\0';
+	}
+#endif
+
+	return 0;
+}
+
+/*
+ * We just have to assume we're dealing with valid memory
+ */
+
+u8
+acpi_os_readable(void *ptr, acpi_size len)
+{
+	return 1;
+}
+
+u8
+acpi_os_writable(void *ptr, acpi_size len)
+{
+	return 1;
+}
+
+u32
+acpi_os_get_thread_id (void)
+{
+	if (!in_interrupt())
+		return current->pid;
+
+	return 0;
+}
+
+acpi_status
+acpi_os_signal (
+    u32		function,
+    void	*info)
+{
+	switch (function)
+	{
+	case ACPI_SIGNAL_FATAL:
+		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);
+		}
+	default:
+		break;
+	}
+
+	return AE_OK;
+}
+
+int __init
+acpi_os_name_setup(char *str)
+{
+	char *p = acpi_os_name;
+	int count = ACPI_MAX_OVERRIDE_LEN-1;
+
+	if (!str || !*str)
+		return 0;
+
+	for (; count-- && str && *str; str++) {
+		if (isalnum(*str) || *str == ' ' || *str == ':')
+			*p++ = *str;
+		else if (*str == '\'' || *str == '"')
+			continue;
+		else
+			break;
+	}
+	*p = 0;
+
+	return 1;
+		
+}
+
+__setup("acpi_os_name=", acpi_os_name_setup);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/Makefile linux-2.4.22-pre2/drivers/acpi/ospm/Makefile
--- linux-2.4.21/drivers/acpi/ospm/Makefile	2001-06-21 00:47:40.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/Makefile	1970-01-01 00:00:00.000000000 +0000
@@ -1,22 +0,0 @@
-#
-# Makefile for the Linux OSPM code.
-#
-
-O_TARGET := $(notdir $(CURDIR)).o
-
-ACPI_CFLAGS += -I$(CURDIR)/include
-
-EXTRA_CFLAGS += $(ACPI_CFLAGS)
-
-subdir-$(CONFIG_ACPI_BUSMGR)	+= busmgr
-subdir-$(CONFIG_ACPI_EC)	+= ec
-subdir-$(CONFIG_ACPI_SYS)	+= system
-subdir-$(CONFIG_ACPI_CPU)	+= processor
-subdir-$(CONFIG_ACPI_CMBATT)	+= battery
-subdir-$(CONFIG_ACPI_AC)	+= ac_adapter
-subdir-$(CONFIG_ACPI_BUTTON)	+= button
-subdir-$(CONFIG_ACPI_THERMAL)	+= thermal
-
-obj-y				+= $(foreach dir,$(subdir-y),$(dir)/ospm_$(dir).o)
-
-include $(TOPDIR)/Rules.make
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/ac_adapter/Makefile linux-2.4.22-pre2/drivers/acpi/ospm/ac_adapter/Makefile
--- linux-2.4.21/drivers/acpi/ospm/ac_adapter/Makefile	2001-06-21 00:47:40.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/ac_adapter/Makefile	1970-01-01 00:00:00.000000000 +0000
@@ -1,6 +0,0 @@
-O_TARGET	:= ospm_$(notdir $(CURDIR)).o
-obj-m		:= $(O_TARGET)
-EXTRA_CFLAGS	+= $(ACPI_CFLAGS)
-obj-y		:= $(patsubst %.c,%.o,$(wildcard *.c))
-
-include $(TOPDIR)/Rules.make
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/ac_adapter/ac.c linux-2.4.22-pre2/drivers/acpi/ospm/ac_adapter/ac.c
--- linux-2.4.21/drivers/acpi/ospm/ac_adapter/ac.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/ac_adapter/ac.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,398 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: ac.c
- *   $Revision: 23 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <acpi.h>
-#include "ac.h"
-
-
-#define _COMPONENT		ACPI_AC_ADAPTER
-	MODULE_NAME 		("ac")
-
-
-/****************************************************************************
- *                            Internal Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:	ac_print
- *
- * PARAMETERS:	
- *
- * RETURN:	
- *
- * DESCRIPTION: Prints out information on a specific ac_adapter.
- *
- ****************************************************************************/
-
-void
-ac_print (
-	AC_CONTEXT		*ac_adapter)
-{
-#ifdef ACPI_DEBUG
-
-	acpi_buffer		buffer;
-
-	PROC_NAME("ac_print");
-
-	if (!ac_adapter) {
-		return;
-	}
-
-	buffer.length = 256;
-	buffer.pointer = acpi_os_callocate(buffer.length);
-	if (!buffer.pointer) {
-		return;
-	}
-
-	/*
-	 * Get the full pathname for this ACPI object.
-	 */
-	acpi_get_name(ac_adapter->acpi_handle, ACPI_FULL_PATHNAME, &buffer);
-
-	/*
-	 * Print out basic adapter information.
-	 */
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "| AC Adapter[%02x]:[%p] %s\n", ac_adapter->device_handle, ac_adapter->acpi_handle, (char*)buffer.pointer));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
-
-	acpi_os_free(buffer.pointer);
-#endif /*ACPI_DEBUG*/
-
-	return;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	ac_add_device
- *
- * PARAMETERS:	
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ac_add_device(
-	BM_HANDLE		device_handle,
-	void			**context)
-{
-	acpi_status 		status = AE_OK;
-	BM_DEVICE		*device = NULL;
-	AC_CONTEXT		*ac_adapter = NULL;
-	acpi_device_info	info;
-
-	FUNCTION_TRACE("ac_add_device");
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Adding ac_adapter device [%02x].\n", device_handle));
-
-	if (!context || *context) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid (NULL) context."));
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Get information on this device.
-	 */
-	status = bm_get_device_info(device_handle, &device);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Allocate a new AC_CONTEXT structure.
-	 */
-	ac_adapter = acpi_os_callocate(sizeof(AC_CONTEXT));
-	if (!ac_adapter) {
-		return_ACPI_STATUS(AE_NO_MEMORY);
-	}
-
-	ac_adapter->device_handle = device->handle;
-	ac_adapter->acpi_handle = device->acpi_handle;
-
-	/*
-	 * Get information on this object.
-	 */
-	status = acpi_get_object_info(ac_adapter->acpi_handle, &info);
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unable to get object info for ac_adapter device."));
-		goto end;
-	}
-
-	/*
-	 * _UID?
-	 * -----
-	 */
-	if (info.valid & ACPI_VALID_UID) {
-		strncpy(ac_adapter->uid, info.unique_id, sizeof(info.unique_id));
-	}
-	else {
-		strncpy(ac_adapter->uid, "0", sizeof("0"));
-	}
-
-	/*
-	 * _STA?
-	 * -----
-	 */
-	if (!(info.valid & ACPI_VALID_STA)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Must have valid _STA.\n"));
-		status = AE_ERROR;
-		goto end;
-	}
-
-	status = ac_osl_add_device(ac_adapter);
-	if (ACPI_FAILURE(status)) {
-		goto end;
-	}
-
-	*context = ac_adapter;
-
-	ac_print(ac_adapter);
-
-end:
-	if (ACPI_FAILURE(status)) {
-		acpi_os_free(ac_adapter);
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	ac_remove_device
- *
- * PARAMETERS:	
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ac_remove_device (
-	void			**context)
-{
-	acpi_status 		status = AE_OK;
-	AC_CONTEXT		*ac_adapter = NULL;
-
-	FUNCTION_TRACE("ac_remove_device");
-
-	if (!context || !*context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	ac_adapter = (AC_CONTEXT*)*context;
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing ac_adapter device [%02x].\n", ac_adapter->device_handle));
-
-	ac_osl_remove_device(ac_adapter);
-
-	acpi_os_free(ac_adapter);
-
-	*context = NULL;
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *                             External Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:	ac_initialize
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ac_initialize (void)
-{
-	acpi_status		status = AE_OK;
-	BM_DEVICE_ID		criteria;
-	BM_DRIVER		driver;
-
-	FUNCTION_TRACE("ac_initialize");
-
-	MEMSET(&criteria, 0, sizeof(BM_DEVICE_ID));
-	MEMSET(&driver, 0, sizeof(BM_DRIVER));
-
-	driver.notify = &ac_notify;
-	driver.request = &ac_request;
-
-	/*
-	 * Register driver for AC Adapter devices.
-	 */
-	MEMCPY(criteria.hid, AC_HID_AC_ADAPTER, sizeof(AC_HID_AC_ADAPTER));
-
-	status = bm_register_driver(&criteria, &driver);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	ac_terminate
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ac_terminate (void)
-{
-	acpi_status 		status = AE_OK;
-	BM_DEVICE_ID		criteria;
-	BM_DRIVER		driver;
-
-	FUNCTION_TRACE("ac_terminate");
-
-	MEMSET(&criteria, 0, sizeof(BM_DEVICE_ID));
-	MEMSET(&driver, 0, sizeof(BM_DRIVER));
-
-	/*
-	 * Unregister driver for AC Adapter devices.
-	 */
-	MEMCPY(criteria.hid, AC_HID_AC_ADAPTER, sizeof(AC_HID_AC_ADAPTER));
-
-	driver.notify = &ac_notify;
-	driver.request = &ac_request;
-
-	status = bm_unregister_driver(&criteria, &driver);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/*****************************************************************************
- *
- * FUNCTION:	ac_notify
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-acpi_status
-ac_notify (
-	BM_NOTIFY		notify_type,
-	BM_HANDLE		device_handle,
-	void			**context)
-{
-	acpi_status 		status = AE_OK;
-
-	FUNCTION_TRACE("ac_notify");
-
-	if (!context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	switch (notify_type) {
-
-	case BM_NOTIFY_DEVICE_ADDED:
-		status = ac_add_device(device_handle, context);
-		break;
-
-	case BM_NOTIFY_DEVICE_REMOVED:
-		status = ac_remove_device(context);
-		break;
-
-	case AC_NOTIFY_STATUS_CHANGE:
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status change event detected.\n"));
-		status = ac_osl_generate_event(notify_type,
-			((AC_CONTEXT*)*context));
-		break;
-
-	default:
-		status = AE_SUPPORT;
-		break;
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	ac_request
- *
- * PARAMETERS:	
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ac_request (
-	BM_REQUEST		*request,
-	void			*context)
-{
-	acpi_status 		status = AE_OK;
-
-	FUNCTION_TRACE("ac_request");
-
-	/*
-	 * Must have a valid request structure and context.
-	 */
-	if (!request || !context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Handle Request:
-	 * ---------------
-	 */
-	switch (request->command) {
-
-	default:
-		status = AE_SUPPORT;
-		break;
-	}
-
-	request->status = status;
-
-	return_ACPI_STATUS(status);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/ac_adapter/ac_osl.c linux-2.4.22-pre2/drivers/acpi/ospm/ac_adapter/ac_osl.c
--- linux-2.4.21/drivers/acpi/ospm/ac_adapter/ac_osl.c	2001-12-21 17:41:53.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/ac_adapter/ac_osl.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,257 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: ac_osl.c
- *   $Revision: 10 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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/proc_fs.h>
-#include <acpi.h>
-#include "ac.h"
-
-
-MODULE_AUTHOR("Andrew Grover");
-MODULE_DESCRIPTION("ACPI Component Architecture (CA) - AC Adapter Driver");
-MODULE_LICENSE("GPL");
-
-
-#define AC_PROC_ROOT		"ac_adapter"
-#define AC_PROC_STATUS		"status"
-#define AC_ON_LINE		"on-line"
-#define AC_OFF_LINE		"off-line"
-
-extern struct proc_dir_entry	*bm_proc_root;
-static struct proc_dir_entry	*ac_proc_root = NULL;
-
-
-/****************************************************************************
- *
- * FUNCTION:	ac_osl_proc_read_status
- *
- ****************************************************************************/
-
-static int
-ac_osl_proc_read_status (
-	char			*page,
-	char			**start,
-	off_t			off,
-	int 			count,
-	int 			*eof,
-	void			*context)
-{
-	acpi_status 		status = AE_OK;
-	AC_CONTEXT		*ac_adapter = NULL;
-	char			*p = page;
-	int			len;
-
-	if (!context) {
-		goto end;
-	}
-
-	ac_adapter = (AC_CONTEXT*)context;
-
-	/* don't get status more than once for a single proc read */
-	if (off != 0) {
-		goto end;
-	}
-
-	status = bm_evaluate_simple_integer(ac_adapter->acpi_handle,
-		"_PSR", &(ac_adapter->is_online));
-	if (ACPI_FAILURE(status)) {
-		p += sprintf(p, "Error reading AC Adapter status\n");
-		goto end;
-	}
-
-	if (ac_adapter->is_online) {
-		p += sprintf(p, "Status:                  %s\n",
-			AC_ON_LINE);
-	}
-	else {
-		p += sprintf(p, "Status:                  %s\n",
-			AC_OFF_LINE);
-	}
-
-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(len);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	ac_osl_add_device
- *
- ****************************************************************************/
-
-acpi_status
-ac_osl_add_device(
-	AC_CONTEXT		*ac_adapter)
-{
-	struct proc_dir_entry	*proc_entry = NULL;
-
-	if (!ac_adapter) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	printk(KERN_INFO "ACPI: AC Adapter found\n");
-
-	proc_entry = proc_mkdir(ac_adapter->uid, ac_proc_root);
-	if (!proc_entry) {
-		return(AE_ERROR);
-	}
-
-	create_proc_read_entry(AC_PROC_STATUS, S_IFREG | S_IRUGO,
-		proc_entry, ac_osl_proc_read_status, (void*)ac_adapter);
-
-	return(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	ac_osl_remove_device
- *
- ****************************************************************************/
-
-acpi_status
-ac_osl_remove_device (
-	AC_CONTEXT		*ac_adapter)
-{
-	char			proc_entry[64];
-
-	if (!ac_adapter) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	sprintf(proc_entry, "%s/%s", ac_adapter->uid, AC_PROC_STATUS);
-	remove_proc_entry(proc_entry, ac_proc_root);
-
-	sprintf(proc_entry, "%s", ac_adapter->uid);
-	remove_proc_entry(proc_entry, ac_proc_root);
-
-	return(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	ac_osl_generate_event
- *
- ****************************************************************************/
-
-acpi_status
-ac_osl_generate_event (
-	u32			event,
-	AC_CONTEXT		*ac_adapter)
-{
-	acpi_status		status = AE_OK;
-
-	if (!ac_adapter) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	switch (event) {
-
-	case AC_NOTIFY_STATUS_CHANGE:
-		status = bm_osl_generate_event(ac_adapter->device_handle,
-			AC_PROC_ROOT, ac_adapter->uid, event, 0);
-		break;
-
-	default:
-		return(AE_BAD_PARAMETER);
-		break;
-	}
-
-	return(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	ac_osl_init
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	0: Success
- *
- * DESCRIPTION: Module initialization.
- *
- ****************************************************************************/
-
-static int __init
-ac_osl_init (void)
-{
-	acpi_status		status = AE_OK;
-
-	ac_proc_root = proc_mkdir(AC_PROC_ROOT, bm_proc_root);
-	if (!ac_proc_root) {
-		status = AE_ERROR;
-	}
-	else {
-		status = ac_initialize();
-		if (ACPI_FAILURE(status)) {
-			remove_proc_entry(AC_PROC_ROOT, bm_proc_root);
-		}
-
-	}
-
-	return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	ac_osl_cleanup
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	<none>
- *
- * DESCRIPTION: Module cleanup.
- *
- ****************************************************************************/
-
-static void __exit
-ac_osl_cleanup (void)
-{
-	ac_terminate();
-
-	if (ac_proc_root) {
-		remove_proc_entry(AC_PROC_ROOT, bm_proc_root);
-	}
-
-	return;
-}
-
-
-module_init(ac_osl_init);
-module_exit(ac_osl_cleanup);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/battery/Makefile linux-2.4.22-pre2/drivers/acpi/ospm/battery/Makefile
--- linux-2.4.21/drivers/acpi/ospm/battery/Makefile	2001-06-21 00:47:40.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/battery/Makefile	1970-01-01 00:00:00.000000000 +0000
@@ -1,6 +0,0 @@
-O_TARGET	:= ospm_$(notdir $(CURDIR)).o
-obj-m		:= $(O_TARGET)
-EXTRA_CFLAGS	+= $(ACPI_CFLAGS)
-obj-y		:= $(patsubst %.c,%.o,$(wildcard *.c))
-
-include $(TOPDIR)/Rules.make
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/battery/bt.c linux-2.4.22-pre2/drivers/acpi/ospm/battery/bt.c
--- linux-2.4.21/drivers/acpi/ospm/battery/bt.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/battery/bt.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,654 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: bt.c
- *   $Revision: 29 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <acpi.h>
-#include "bt.h"
-
-
-#define _COMPONENT		ACPI_BATTERY
-	MODULE_NAME 		("bt")
-
-
-/****************************************************************************
- *                            Internal Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:	bt_print
- *
- * PARAMETERS:	
- *
- * RETURN:	
- *
- * DESCRIPTION: Prints out information on a specific battery.
- *
- ****************************************************************************/
-
-void
-bt_print (
-	BT_CONTEXT		*battery)
-{
-#ifdef ACPI_DEBUG
-	acpi_buffer 		buffer;
-
-	PROC_NAME("bt_print");
-
-	if (!battery) {
-		return;
-	}
-
-	buffer.length = 256;
-	buffer.pointer = acpi_os_callocate(buffer.length);
-	if (!buffer.pointer) {
-		return;
-	}
-
-	/*
-	 * Get the full pathname for this ACPI object.
-	 */
-	acpi_get_name(battery->acpi_handle, ACPI_FULL_PATHNAME, &buffer);
-
-	/*
-	 * Print out basic battery information.
-	 */
-
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "| Battery[%02x]:[%p] %s\n", battery->device_handle, battery->acpi_handle, (char*)buffer.pointer));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   uid[%s] is_present[%d] power_units[%s]\n", battery->uid, battery->is_present, battery->power_units));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
-
-	acpi_os_free(buffer.pointer);
-#endif /*ACPI_DEBUG*/
-
-	return;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	bt_get_info
- *
- * PARAMETERS:	
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- * NOTES:	Allocates battery_info - which must be freed by the caller.
- *
- ****************************************************************************/
-
-acpi_status
-bt_get_info (
-	BT_CONTEXT		*battery,
-	BT_BATTERY_INFO 	**battery_info)
-{
-	acpi_status 		status = AE_OK;
-	acpi_buffer 		bif_buffer, package_format, package_data;
-	acpi_object 		*package = NULL;
-
-	FUNCTION_TRACE("bt_get_info");
-
-	if (!battery || !battery_info || *battery_info) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	memset(&bif_buffer, 0, sizeof(acpi_buffer));
-
-	/*
-	 * Evalute _BIF:
-	 * -------------
-	 * And be sure to deallocate bif_buffer.pointer!
-	 */
-	status = bm_evaluate_object(battery->acpi_handle, "_BIF", NULL,
-		&bif_buffer);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Extract Package Data:
-	 * ---------------------
-	 * Type-cast this bif_buffer to a package and use helper
-	 * functions to convert results into BT_BATTERY_INFO structure.
-	 * The first attempt is just to get the size of the package
-	 * data; the second gets the data (once we know the required
-	 * bif_buffer size).
-	 */
-	status = bm_cast_buffer(&bif_buffer, (void**)&package,
-		sizeof(acpi_object));
-	if (ACPI_FAILURE(status)) {
-		goto end;
-	}
-
-	package_format.length = sizeof("NNNNNNNNNSSSS");
-	package_format.pointer = "NNNNNNNNNSSSS";
-
-	memset(&package_data, 0, sizeof(acpi_buffer));
-
-	status = bm_extract_package_data(package, &package_format,
-		&package_data);
-	if (status != AE_BUFFER_OVERFLOW) {
-		if (status == AE_OK) {
-			status = AE_ERROR;
-		}
-		goto end;
-	}
-
-	package_data.pointer = acpi_os_callocate(package_data.length);
-	if (!package_data.pointer) {
-		return_ACPI_STATUS(AE_NO_MEMORY);
-	}
-
-	status = bm_extract_package_data(package, &package_format,
-		&package_data);
-	if (ACPI_FAILURE(status)) {
-		acpi_os_free(package_data.pointer);
-		goto end;
-	}
-
-	*battery_info = package_data.pointer;
-
-end:
-	acpi_os_free(bif_buffer.pointer);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	bt_get_status
- *
- * PARAMETERS:	
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bt_get_status (
-	BT_CONTEXT		*battery,
-	BT_BATTERY_STATUS	**battery_status)
-{
-	acpi_status 		status = AE_OK;
-	acpi_buffer 		bst_buffer, package_format, package_data;
-	acpi_object 		*package = NULL;
-
-	FUNCTION_TRACE("bt_get_status");
-
-	if (!battery || !battery_status || *battery_status) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	memset(&bst_buffer, 0, sizeof(acpi_buffer));
-
-	/*
-	 * Evalute _BST:
-	 * -------------
-	 * And be sure to deallocate bst_buffer.pointer!
-	 */
-	status = bm_evaluate_object(battery->acpi_handle, "_BST",
-		NULL, &bst_buffer);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Extract Package Data:
-	 * ---------------------
-	 * Type-cast this bst_buffer to a package and use helper
-	 * functions to convert results into BT_BATTERY_STATUS structure.
-	 * The first attempt is just to get the size of the package data;
-	 * the second gets the data (once we know the required bst_buffer
-	 * size).
-	 */
-	status = bm_cast_buffer(&bst_buffer, (void**)&package,
-		sizeof(acpi_object));
-	if (ACPI_FAILURE(status)) {
-		goto end;
-	}
-
-	package_format.length = sizeof("NNNN");
-	package_format.pointer = "NNNN";
-
-	memset(&package_data, 0, sizeof(acpi_buffer));
-
-	status = bm_extract_package_data(package, &package_format,
-		&package_data);
-	if (status != AE_BUFFER_OVERFLOW) {
-		if (status == AE_OK) {
-			status = AE_ERROR;
-		}
-		goto end;
-	}
-
-	package_data.pointer = acpi_os_callocate(package_data.length);
-	if (!package_data.pointer) {
-		return_ACPI_STATUS(AE_NO_MEMORY);
-	}
-
-	status = bm_extract_package_data(package, &package_format,
-		&package_data);
-	if (ACPI_FAILURE(status)) {
-		acpi_os_free(package_data.pointer);
-		goto end;
-	}
-
-	*battery_status = package_data.pointer;
-
-end:
-	acpi_os_free(bst_buffer.pointer);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	bt_check_device
- *
- * PARAMETERS:	
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bt_check_device (
-	BT_CONTEXT		*battery)
-{
-	acpi_status 		status = AE_OK;
-	BM_DEVICE_STATUS	battery_status = BM_STATUS_UNKNOWN;
-	u32 			was_present = FALSE;
-	BT_BATTERY_INFO 	*battery_info = NULL;
-
-	FUNCTION_TRACE("bt_check_device");
-
-	if (!battery) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	was_present = battery->is_present;
-
-	/*
-	 * Battery Present?
-	 * ----------------
-	 * Get the device status and check if battery slot is occupied.
-	 */
-	status = bm_get_device_status(battery->device_handle, &battery_status);
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Unable to get battery status.\n"));
-		return_ACPI_STATUS(status);
-	}
-
-	if (battery_status & BM_STATUS_BATTERY_PRESENT) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Battery socket occupied.\n"));
-		battery->is_present = TRUE;
-	}
-	else {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Battery socket not occupied.\n"));
-		battery->is_present = FALSE;
-	}
-
-	/*
-	 * Battery Appeared?
-	 * -----------------
-	 */
-	if (!was_present && battery->is_present) {
-
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Battery insertion detected.\n"));
-
-		/*
-		 * Units of Power?
-		 * ---------------
-		 * Get the 'units of power', as we'll need this to report
-		 * status information.
-		 */
-		status = bt_get_info(battery, &battery_info);
-		if (ACPI_SUCCESS(status)) {
-			battery->power_units = (battery_info->power_unit)
-				? BT_POWER_UNITS_AMPS : BT_POWER_UNITS_WATTS;
-			acpi_os_free(battery_info);
-		}
-	}
-
-	/*
-	 * Battery Disappeared?
-	 * --------------------
-	 */
-	else if (was_present && !battery->is_present) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Battery removal detected.\n"));
-		battery->power_units = BT_POWER_UNITS_DEFAULT;
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/*****************************************************************************
- *
- * FUNCTION:	bt_add_device
- *
- * PARAMETERS:	
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bt_add_device (
-	BM_HANDLE		device_handle,
-	void			**context)
-{
-	acpi_status 		status = AE_OK;
-	BM_DEVICE		*device = NULL;
-	BT_CONTEXT		*battery = NULL;
-
-	FUNCTION_TRACE("bt_add_device");
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Adding battery device [%02x].\n", device_handle));
-
-	if (!context || *context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Get information on this device.
-	 */
-	status = bm_get_device_info(device_handle, &device);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Allocate a new BT_CONTEXT structure.
-	 */
-	battery = acpi_os_callocate(sizeof(BT_CONTEXT));
-	if (!battery) {
-		return_ACPI_STATUS(AE_NO_MEMORY);
-	}
-
-	battery->device_handle = device->handle;
-	battery->acpi_handle = device->acpi_handle;
-	strncpy(battery->uid, device->id.uid, sizeof(battery->uid));
-
-	battery->power_units = BT_POWER_UNITS_DEFAULT;
-	battery->is_present = FALSE;
-
-	/*
-	 * See if battery is really present.
-	 */
-	status = bt_check_device(battery);
-	if (ACPI_FAILURE(status)) {
-		goto end;
-	}
-
-	status = bt_osl_add_device(battery);
-	if (ACPI_FAILURE(status)) {
-		goto end;
-	}
-
-	*context = battery;
-
-	bt_print(battery);
-
-end:
-	if (ACPI_FAILURE(status)) {
-		acpi_os_free(battery);
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/*****************************************************************************
- *
- * FUNCTION:	bt_remove_device
- *
- * PARAMETERS:	
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bt_remove_device (
-	void			**context)
-{
-	acpi_status 		status = AE_OK;
-	BT_CONTEXT		*battery = NULL;
-
-	FUNCTION_TRACE("bt_remove_device");
-
-	if (!context || !*context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	battery = (BT_CONTEXT*)*context;
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing battery device [%02x].\n", battery->device_handle));
-
-	bt_osl_remove_device(battery);
-
-	acpi_os_free(battery);
-
-	*context = NULL;
-
-	return_ACPI_STATUS(status);
-}
-
-
-/*****************************************************************************
- *                               External Functions
- *****************************************************************************/
-
-/*****************************************************************************
- *
- * FUNCTION:	bt_initialize
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bt_initialize (void)
-{
-	acpi_status		status = AE_OK;
-	BM_DEVICE_ID		criteria;
-	BM_DRIVER		driver;
-
-	FUNCTION_TRACE("bt_initialize");
-
-	memset(&criteria, 0, sizeof(BM_DEVICE_ID));
-	memset(&driver, 0, sizeof(BM_DRIVER));
-
-	/*
-	 * Register driver for driver method battery devices.
-	 */
-	MEMCPY(criteria.hid, BT_HID_CM_BATTERY, sizeof(BT_HID_CM_BATTERY));
-
-	driver.notify = &bt_notify;
-	driver.request = &bt_request;
-
-	status = bm_register_driver(&criteria, &driver);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	bt_terminate
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bt_terminate (void)
-{
-	acpi_status		status = AE_OK;
-	BM_DEVICE_ID		criteria;
-	BM_DRIVER		driver;
-
-	FUNCTION_TRACE("bt_terminate");
-
-	memset(&criteria, 0, sizeof(BM_DEVICE_ID));
-	memset(&driver, 0, sizeof(BM_DRIVER));
-
-	/*
-	 * Unregister driver for driver method battery devices.
-	 */
-	MEMCPY(criteria.hid, BT_HID_CM_BATTERY, sizeof(BT_HID_CM_BATTERY));
-
-	driver.notify = &bt_notify;
-	driver.request = &bt_request;
-
-	status = bm_unregister_driver(&criteria, &driver);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	bt_notify
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bt_notify (
-	BM_NOTIFY		notify_type,
-	BM_HANDLE		device_handle,
-	void			**context)
-{
-	acpi_status 		status = AE_OK;
-
-	FUNCTION_TRACE("bt_notify");
-
-	if (!context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	switch (notify_type) {
-
-	case BM_NOTIFY_DEVICE_ADDED:
-		status = bt_add_device(device_handle, context);
-		break;
-
-	case BM_NOTIFY_DEVICE_REMOVED:
-		status = bt_remove_device(context);
-		break;
-
-	case BT_NOTIFY_STATUS_CHANGE:
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status change (_BST) event detected.\n"));
-		status = bt_osl_generate_event(notify_type,
-			((BT_CONTEXT*)*context));
-		break;
-
-	case BT_NOTIFY_INFORMATION_CHANGE:
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Information change (_BIF) event detected.\n"));
-		status = bt_check_device((BT_CONTEXT*)*context);
-		if (ACPI_SUCCESS(status)) {
-			status = bt_osl_generate_event(notify_type,
-				((BT_CONTEXT*)*context));
-		}
-		break;
-
-	default:
-		status = AE_SUPPORT;
-		break;
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	bt_request
- *
- * PARAMETERS:	
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bt_request (
-	BM_REQUEST		*request,
-	void			*context)
-{
-	acpi_status 		status = AE_OK;
-
-	FUNCTION_TRACE("bt_request");
-
-	/*
-	 * Must have a valid request structure and context.
-	 */
-	if (!request || !context)
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-
-	/*
-	 * Handle request:
-	 * ---------------
-	 */
-	switch (request->command) {
-
-	default:
-		status = AE_SUPPORT;
-		break;
-	}
-
-	request->status = status;
-
-	return_ACPI_STATUS(status);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/battery/bt_osl.c linux-2.4.22-pre2/drivers/acpi/ospm/battery/bt_osl.c
--- linux-2.4.21/drivers/acpi/ospm/battery/bt_osl.c	2001-12-21 17:41:53.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/battery/bt_osl.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,443 +0,0 @@
-/******************************************************************************
- *
- * Module Name: bt_osl.c
- *   $Revision: 24 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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
- */
-
-/*
- * Changes:
- * Brendan Burns <bburns@wso.williams.edu> 2000-11-15
- * - added proc battery interface
- * - parse returned data from _BST and _BIF
- * Andy Grover <andrew.grover@intel.com> 2000-12-8
- * - improved proc interface
- */
-
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/proc_fs.h>
-#include <acpi.h>
-#include "bt.h"
-
-
-MODULE_AUTHOR("Andrew Grover");
-MODULE_DESCRIPTION("ACPI Component Architecture (CA) - Control Method Battery Driver");
-MODULE_LICENSE("GPL");
-
-
-#define BT_PROC_ROOT		"battery"
-#define BT_PROC_STATUS		"status"
-#define BT_PROC_INFO		"info"
-
-extern struct proc_dir_entry	*bm_proc_root;
-static struct proc_dir_entry	*bt_proc_root = NULL;
-
-
-/****************************************************************************
- *
- * FUNCTION:	bt_osl_proc_read_info
- *
- ****************************************************************************/
-
-static int
-bt_osl_proc_read_info (
-	char			*page,
-	char			**start,
-	off_t			off,
-	int 			count,
-	int 			*eof,
-	void			*context)
-{
-	BT_CONTEXT		*battery = NULL;
-	BT_BATTERY_INFO 	*battery_info = NULL;
-	char			*p = page;
-	int 			len = 0;
-
-	if (!context || (off != 0)) {
-		goto end;
-	}
-
-	battery = (BT_CONTEXT*)context;
-
-	/*
-	 * Battery Present?
-	 * ----------------
-	 */
-	if (!battery->is_present) {
-		p += sprintf(p, "Present:                 no\n");
-		goto end;
-	}
-	else {
-		p += sprintf(p, "Present:                 yes\n");
-	}
-
-	/*
-	 * Get Battery Information:
-	 * ------------------------
-	 */
-	if (ACPI_FAILURE(bt_get_info(battery, &battery_info))) {
-		p += sprintf(p, "Error reading battery information (_BIF)\n");
-		goto end;
-	}
-
-	if (battery_info->design_capacity == BT_UNKNOWN) {
-		p += sprintf(p, "Design Capacity:         unknown\n");
-	}
-	else {
-		p += sprintf(p, "Design Capacity:         %d %sh\n",
-			 (u32)battery_info->design_capacity,
-			 battery->power_units);
-	}
-	
-	if (battery_info->last_full_capacity == BT_UNKNOWN) {
-		p += sprintf(p, "Last Full Capacity:      unknown\n");
-	}
-	else {
-		p += sprintf(p, "Last Full Capacity:      %d %sh\n",
-			 (u32)battery_info->last_full_capacity,
-			 battery->power_units);
-	}
-
-	if (battery_info->battery_technology == 0) {
-		p += sprintf(p, "Battery Technology:      primary (non-rechargeable)\n");
-	}
-	else if (battery_info->battery_technology == 1) {
-		p += sprintf(p, "Battery Technology:      secondary (rechargeable)\n");
-	}
-	else {
-		p += sprintf(p, "Battery Technology:      unknown\n");
-	}
-
-	if (battery_info->design_voltage == BT_UNKNOWN) {
-		p += sprintf(p, "Design Voltage:          unknown\n");
-	}
-	else {
-		p += sprintf(p, "Design Voltage:          %d mV\n",
-			 (u32)battery_info->design_voltage);
-	}
-	
-	p += sprintf(p, "Design Capacity Warning: %d %sh\n",
-		(u32)battery_info->design_capacity_warning,
-		battery->power_units);
-	p += sprintf(p, "Design Capacity Low:     %d %sh\n",
-		(u32)battery_info->design_capacity_low,
-		battery->power_units);
-	p += sprintf(p, "Capacity Granularity 1:  %d %sh\n",
-		(u32)battery_info->battery_capacity_granularity_1,
-		battery->power_units);
-	p += sprintf(p, "Capacity Granularity 2:  %d %sh\n",
-		(u32)battery_info->battery_capacity_granularity_2,
-		battery->power_units);
-	p += sprintf(p, "Model Number:            %s\n",
-		battery_info->model_number);
-	p += sprintf(p, "Serial Number:           %s\n",
-		battery_info->serial_number);
-	p += sprintf(p, "Battery Type:            %s\n",
-		battery_info->battery_type);
-	p += sprintf(p, "OEM Info:                %s\n",
-		battery_info->oem_info);
-	
-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;
-
-	acpi_os_free(battery_info);
-
-	return(len);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	bt_osl_proc_read_status
- *
- ****************************************************************************/
-
-static int
-bt_osl_proc_read_status (
-	char			*page,
-	char			**start,
-	off_t			off,
-	int 			count,
-	int 			*eof,
-	void			*context)
-{
-	BT_CONTEXT		*battery = NULL;
-	BT_BATTERY_STATUS	*battery_status = NULL;
-	char			*p = page;
-	int 			len = 0;
-
-	if (!context || (off != 0)) {
-		goto end;
-	}
-
-	battery = (BT_CONTEXT*)context;
-
-	/*
-	 * Battery Present?
-	 * ----------------
-	 */
-	if (!battery->is_present) {
-		p += sprintf(p, "Present:                 no\n");
-		goto end;
-	}
-	else {
-		p += sprintf(p, "Present:                 yes\n");
-	}
-
-	/*
-	 * Get Battery Status:
-	 * -------------------
-	 */
-	if (ACPI_FAILURE(bt_get_status(battery, &battery_status))) {
-		p += sprintf(p, "Error reading battery status (_BST)\n");
-		goto end;
-	}
-
-	/*
-	 * Store Data:
-	 * -----------
-	 */
-
-	if (!battery_status->state) {
-		p += sprintf(p, "State:                   ok\n");
-	}
-	else {
-		if (battery_status->state & 0x1)
-			p += sprintf(p, "State:                   discharging\n");
-		if (battery_status->state & 0x2)
-			p += sprintf(p, "State:                   charging\n");
-		if (battery_status->state & 0x4)
-			p += sprintf(p, "State:                   critically low\n");
-	}
-
-	if (battery_status->present_rate == BT_UNKNOWN) {
-		p += sprintf(p, "Present Rate:            unknown\n");
-	}
-	else {
-		p += sprintf(p, "Present Rate:            %d %s\n",
-			(u32)battery_status->present_rate,
-			battery->power_units);
-	}
-
-	if (battery_status->remaining_capacity == BT_UNKNOWN) {
-		p += sprintf(p, "Remaining Capacity:      unknown\n");
-	}
-	else {
-		p += sprintf(p, "Remaining Capacity:      %d %sh\n",
-			(u32)battery_status->remaining_capacity,
-			battery->power_units);
-	}
-
-	if (battery_status->present_voltage == BT_UNKNOWN) {
-		p += sprintf(p, "Battery Voltage:         unknown\n");
-	}
-	else {
-		p += sprintf(p, "Battery Voltage:         %d mV\n",
-			(u32)battery_status->present_voltage);
-	}
-
-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;
-
-	acpi_os_free(battery_status);
-
-	return(len);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	bt_osl_add_device
- *
- ****************************************************************************/
-
-acpi_status
-bt_osl_add_device(
-	BT_CONTEXT		*battery)
-{
-	struct proc_dir_entry	*proc_entry = NULL;
-
-	if (!battery) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	if (battery->is_present) {
-		printk("ACPI: Battery socket found, battery present\n");
-	}
-	else {
-		printk("ACPI: Battery socket found, battery absent\n");
-	}
-
-	proc_entry = proc_mkdir(battery->uid, bt_proc_root);
-	if (!proc_entry) {
-		return(AE_ERROR);
-	}
-
-	create_proc_read_entry(BT_PROC_STATUS, S_IFREG | S_IRUGO,
-		proc_entry, bt_osl_proc_read_status, (void*)battery);
-
-	create_proc_read_entry(BT_PROC_INFO, S_IFREG | S_IRUGO,
-		proc_entry, bt_osl_proc_read_info, (void*)battery);
-
-	return(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	bt_osl_remove_device
- *
- ****************************************************************************/
-
-acpi_status
-bt_osl_remove_device (
-	BT_CONTEXT		*battery)
-{
-	char			proc_entry[64];
-
-	if (!battery) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	sprintf(proc_entry, "%s/%s", battery->uid, BT_PROC_INFO);
-	remove_proc_entry(proc_entry, bt_proc_root);
-
-	sprintf(proc_entry, "%s/%s", battery->uid, BT_PROC_STATUS);
-	remove_proc_entry(proc_entry, bt_proc_root);
-
-	sprintf(proc_entry, "%s", battery->uid);
-	remove_proc_entry(proc_entry, bt_proc_root);
-
-	return(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	bt_osl_generate_event
- *
- ****************************************************************************/
-
-acpi_status
-bt_osl_generate_event (
-	u32			event,
-	BT_CONTEXT		*battery)
-{
-	acpi_status		status = AE_OK;
-
-	if (!battery) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	switch (event) {
-
-	case BT_NOTIFY_STATUS_CHANGE:
-	case BT_NOTIFY_INFORMATION_CHANGE:
-		status = bm_osl_generate_event(battery->device_handle,
-			BT_PROC_ROOT, battery->uid, event, 0);
-		break;
-
-	default:
-		return(AE_BAD_PARAMETER);
-		break;
-	}
-
-	return(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	bt_osl_init
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	0: Success
- *
- * DESCRIPTION: Module initialization.
- *
- ****************************************************************************/
-
-static int __init
-bt_osl_init (void)
-{
-	acpi_status		status = AE_OK;
-
-	/* abort if no busmgr */
-	if (!bm_proc_root)
-		return -ENODEV;
-
-	bt_proc_root = proc_mkdir(BT_PROC_ROOT, bm_proc_root);
-	if (!bt_proc_root) {
-		status = AE_ERROR;
-	}
-	else {
-		status = bt_initialize();
-		if (ACPI_FAILURE(status)) {
-			remove_proc_entry(BT_PROC_ROOT, bm_proc_root);
-		}
-	}
-
-	return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	bt_osl_cleanup
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	<none>
- *
- * DESCRIPTION: Module cleanup.
- *
- ****************************************************************************/
-
-static void __exit
-bt_osl_cleanup (void)
-{
-	bt_terminate();
-
-	if (bt_proc_root) {
-		remove_proc_entry(BT_PROC_ROOT, bm_proc_root);
-	}
-
-	return;
-}
-
-
-module_init(bt_osl_init);
-module_exit(bt_osl_cleanup);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/busmgr/Makefile linux-2.4.22-pre2/drivers/acpi/ospm/busmgr/Makefile
--- linux-2.4.21/drivers/acpi/ospm/busmgr/Makefile	2001-09-02 14:48:02.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/busmgr/Makefile	1970-01-01 00:00:00.000000000 +0000
@@ -1,8 +0,0 @@
-export-objs	:= bm_osl.o
-
-O_TARGET	:= ospm_$(notdir $(CURDIR)).o
-obj-m		:= $(O_TARGET)
-EXTRA_CFLAGS	+= $(ACPI_CFLAGS)
-obj-y		:= $(patsubst %.c,%.o,$(wildcard *.c))
-
-include $(TOPDIR)/Rules.make
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/busmgr/bm.c linux-2.4.22-pre2/drivers/acpi/ospm/busmgr/bm.c
--- linux-2.4.21/drivers/acpi/ospm/busmgr/bm.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/busmgr/bm.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,1146 +0,0 @@
-/******************************************************************************
- *
- * Module Name: bm.c
- *   $Revision: 48 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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 <acpi.h>
-#include "bm.h"
-
-
-#define _COMPONENT		ACPI_BUS
-	MODULE_NAME		("bm")
-
-
-/****************************************************************************
- *                                  Globals
- ****************************************************************************/
-
-extern fadt_descriptor_rev2	acpi_fadt;
-/* TBD: Make dynamically sizeable. */
-BM_NODE_LIST			node_list;
-
-
-/****************************************************************************
- *                            Internal Functions
- ****************************************************************************/
-
-/*****************************************************************************
- *
- * FUNCTION:    bm_print_object
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-void
-bm_print_object (
-	acpi_handle		handle)
-{
-	acpi_buffer		buffer;
-	acpi_handle		parent;
-	acpi_object_type	type;
-
-	buffer.length = 256;
-	buffer.pointer = acpi_os_callocate(buffer.length);
-	if (!buffer.pointer) {
-		return;
-	}
-
-	acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
-	acpi_get_parent(handle, &parent);
-	acpi_get_type(handle, &type);
-
-	/*
-	 * TBD: Hack to get around scope identification problem.
-	 */
-	if (type == ACPI_TYPE_ANY) {
-		if (ACPI_SUCCESS(acpi_get_next_object(ACPI_TYPE_ANY,
-			handle, 0, NULL))) {
-			type = INTERNAL_TYPE_SCOPE;
-		}
-	}
-
-	switch (type)
-	 {
-	case INTERNAL_TYPE_SCOPE:
-		acpi_os_printf("SCOPE: ");
-		break;
-	case ACPI_TYPE_INTEGER:
-		acpi_os_printf("SIMPLE (number): ");
-		break;
-	case ACPI_TYPE_STRING:
-		acpi_os_printf("SIMPLE (string): ");
-		break;
-	case ACPI_TYPE_BUFFER:
-		acpi_os_printf("SIMPLE (buffer): ");
-		break;
-	case ACPI_TYPE_PACKAGE:
-		acpi_os_printf("SIMPLE (package): ");
-		break;
-	case ACPI_TYPE_FIELD_UNIT:
-		acpi_os_printf("FIELD UNIT: ");
-		break;
-	case ACPI_TYPE_DEVICE:
-		acpi_os_printf("DEVICE: ");
-		break;
-	case ACPI_TYPE_EVENT:
-		acpi_os_printf("EVENT: ");
-		break;
-	case ACPI_TYPE_METHOD:
-		acpi_os_printf("CONTROL METHOD: ");
-		break;
-	case ACPI_TYPE_MUTEX:
-		acpi_os_printf("MUTEX: ");
-		break;
-	case ACPI_TYPE_REGION:
-		acpi_os_printf("OPERATION REGION: ");
-		break;
-	case ACPI_TYPE_POWER:
-		acpi_os_printf("POWER RESOURCE: ");
-		break;
-	case ACPI_TYPE_PROCESSOR:
-		acpi_os_printf("PROCESSOR: ");
-		break;
-	case ACPI_TYPE_THERMAL:
-		acpi_os_printf("THERMAL ZONE: ");
-		break;
-	case ACPI_TYPE_BUFFER_FIELD:
-		acpi_os_printf("BUFFER FIELD: ");
-		break;
-	case ACPI_TYPE_DDB_HANDLE:
-		acpi_os_printf("DDB HANDLE: ");
-		break;
-	default:
-		acpi_os_printf("OTHER (%d): ", type);
-		break;
-	}
-
-	acpi_os_printf("Object[%p][%s] parent[%p].\n", handle, (char*)buffer.pointer, parent);
-
-	acpi_os_free(buffer.pointer);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_print_node
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-void
-bm_print_node (
-	BM_NODE			*node,
-	u32                     flags)
-{
-#ifdef ACPI_DEBUG
-	acpi_buffer             buffer;
-	BM_DEVICE		*device = NULL;
-	char                    *type_string = NULL;
-
-	PROC_NAME("bm_print_node");
-
-	if (!node) {
-		return;
-	}
-
-	device = &(node->device);
-
-	if (flags & BM_PRINT_PRESENT) {
-		if (!BM_DEVICE_PRESENT(device)) {
-			return;
-		}
-	}
-
-	buffer.length = 256;
-	buffer.pointer = acpi_os_callocate(buffer.length);
-	if (!buffer.pointer) {
-		return;
-	}
-
-	acpi_get_name(device->acpi_handle, ACPI_FULL_PATHNAME, &buffer);
-
-	switch(device->id.type) {
-	case BM_TYPE_SYSTEM:
-		type_string = " System";
-		break;
-	case BM_TYPE_SCOPE:
-		type_string = "  Scope";
-		break;
-	case BM_TYPE_PROCESSOR:
-		type_string = "   Proc";
-		break;
-	case BM_TYPE_THERMAL_ZONE:
-		type_string = "Thermal";
-		break;
-	case BM_TYPE_POWER_RESOURCE:
-		type_string = "  Power";
-		break;
-	case BM_TYPE_FIXED_BUTTON:
-		type_string = " Button";
-		break;
-	case BM_TYPE_DEVICE:
-		type_string = " Device";
-		break;
-	default:
-		type_string = "Unknown";
-		break;
-	}
-
-	if (!(flags & BM_PRINT_GROUP)) {
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+-------------------------------------------------------------------------------\n"));
-	}
-
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "| %s[%02x]:[%p] flags[%02x] hid[%s] %s\n", type_string, device->handle, device->acpi_handle, device->flags, (device->id.hid[0] ? device->id.hid : "       "), (char*)buffer.pointer));
-
-	if (flags & BM_PRINT_IDENTIFICATION) {
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   identification: uid[%s] adr[%08x]\n", device->id.uid, device->id.adr));
-	}
-
-	if (flags & BM_PRINT_LINKAGE) {
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   linkage: this[%p] parent[%p] next[%p]\n", node, node->parent, node->next));
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|     scope.head[%p] scope.tail[%p]\n", node->scope.head, node->scope.tail));
-	}
-
-	if (flags & BM_PRINT_POWER) {
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   power: state[D%d] flags[%08x]\n", device->power.state, device->power.flags));
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|     S0[%02x] S1[%02x] S2[%02x] S3[%02x] S4[%02x] S5[%02x]\n", device->power.dx_supported[0], device->power.dx_supported[1], device->power.dx_supported[2], device->power.dx_supported[3], device->power.dx_supported[4], device->power.dx_supported[5]));
-	}
-
-	if (!(flags & BM_PRINT_GROUP)) {
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+-------------------------------------------------------------------------------\n"));
-	}
-
-	acpi_os_free(buffer.pointer);
-#endif /*ACPI_DEBUG*/
-
-	return;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_print_hierarchy
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-void
-bm_print_hierarchy (void)
-{
-#ifdef ACPI_DEBUG
-	u32			i = 0;
-
-	FUNCTION_TRACE("bm_print_hierarchy");
-
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
-
-	for (i = 0; i < node_list.count; i++) {
-		bm_print_node(node_list.nodes[i], BM_PRINT_GROUP | BM_PRINT_PRESENT);
-	}
-
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
-#endif /*ACPI_DEBUG*/
-
-	return_VOID;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_get_status
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_get_status (
-	BM_DEVICE		*device)
-{
-	acpi_status           status = AE_OK;
-
-	if (!device) {
-		return AE_BAD_PARAMETER;
-	}
-
-	device->status = BM_STATUS_UNKNOWN;
-
-	/*
-	 * Dynamic Status?
-	 * ---------------
-	 * If _STA isn't present we just return the default status.
-	 */
-	if (!(device->flags & BM_FLAGS_DYNAMIC_STATUS)) {
-		device->status = BM_STATUS_DEFAULT;
-		return AE_OK;
-	}
-
-	/*
-	 * Evaluate _STA:
-	 * --------------
-	 */
-	status = bm_evaluate_simple_integer(device->acpi_handle, "_STA",
-		&(device->status));
-
-	return status;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_get_identification
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_get_identification (
-	BM_DEVICE		*device)
-{
-	acpi_status             status = AE_OK;
-	acpi_device_info        info;
-
-	if (!device) {
-		return AE_BAD_PARAMETER;
-	}
-
-	if (!(device->flags & BM_FLAGS_IDENTIFIABLE)) {
-		return AE_OK;
-	}
-
-	device->id.uid[0] = BM_UID_UNKNOWN;
-	device->id.hid[0] = BM_HID_UNKNOWN;
-	device->id.adr = BM_ADDRESS_UNKNOWN;
-
-	/*
-	 * Get Object Info:
-	 * ----------------
-	 * Evalute _UID, _HID, and _ADR...
-	 */
-	status = acpi_get_object_info(device->acpi_handle, &info);
-	if (ACPI_FAILURE(status)) {
-		return status;
-	}
-
-	if (info.valid & ACPI_VALID_UID) {
-		MEMCPY((void*)device->id.uid, (void*)info.unique_id,
-			sizeof(BM_DEVICE_UID));
-	}
-
-	if (info.valid & ACPI_VALID_HID) {
-		MEMCPY((void*)device->id.hid, (void*)info.hardware_id,
-			sizeof(BM_DEVICE_HID));
-	}
-
-	if (info.valid & ACPI_VALID_ADR) {
-		device->id.adr = info.address;
-	}
-
-	return status;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_get_flags
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_get_flags (
-	BM_DEVICE		*device)
-{
-	acpi_handle		acpi_handle = NULL;
-
-	if (!device) {
-		return AE_BAD_PARAMETER;
-	}
-
-	device->flags = BM_FLAGS_UNKNOWN;
-
-	switch (device->id.type) {
-
-	case BM_TYPE_DEVICE:
-
-		/*
-		 * Presence of _DCK indicates a docking station.
-		 */
-		if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
-			"_DCK", &acpi_handle))) {
-			device->flags |= BM_FLAGS_DOCKING_STATION;
-		}
-
-		/*
-		 * Presence of _EJD and/or _EJx indicates 'ejectable'.
-		 * TBD: _EJx...
-		 */
-		if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
-			"_EJD", &acpi_handle))) {
-			device->flags |= BM_FLAGS_EJECTABLE;
-		}
-
-		/*
-		 * Presence of _PR0 or _PS0 indicates 'power manageable'.
-		 */
-		if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
-			"_PR0", &acpi_handle)) ||
-			ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
-			"_PS0", &acpi_handle))) {
-			device->flags |= BM_FLAGS_POWER_CONTROL;
-		}
-
-		/*
-		 * Presence of _CRS indicates 'configurable'.
-		 */
-		if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
-			"_CRS", &acpi_handle))) {
-			device->flags |= BM_FLAGS_CONFIGURABLE;
-		}
-
-		/* Fall through to next case statement. */
-
-	case BM_TYPE_PROCESSOR:
-	case BM_TYPE_THERMAL_ZONE:
-	case BM_TYPE_POWER_RESOURCE:
-		/*
-		 * Presence of _HID or _ADR indicates 'identifiable'.
-		 */
-		if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
-			"_HID", &acpi_handle)) ||
-		   ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
-		   "_ADR", &acpi_handle))) {
-			device->flags |= BM_FLAGS_IDENTIFIABLE;
-		}
-
-		/*
-		 * Presence of _STA indicates 'dynamic status'.
-		 */
-		if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
-			"_STA", &acpi_handle))) {
-			device->flags |= BM_FLAGS_DYNAMIC_STATUS;
-		}
-
-		break;
-	}
-
-	return AE_OK;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_add_namespace_device
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_add_namespace_device (
-	acpi_handle             acpi_handle,
-	acpi_object_type        acpi_type,
-	BM_NODE			*parent,
-	BM_NODE			**child)
-{
-	acpi_status             status = AE_OK;
-	BM_NODE			*node = NULL;
-	BM_DEVICE		*device = NULL;
-
-	FUNCTION_TRACE("bm_add_namespace_device");
-
-	if (!parent || !child) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	if (node_list.count > BM_HANDLES_MAX) {
-		return_ACPI_STATUS(AE_NO_MEMORY);
-	}
-
-	(*child) = NULL;
-
-	/*
-	 * Create Node:
-	 * ------------
-	 */
-	node = acpi_os_callocate(sizeof(BM_NODE));
-	if (!node) {
-		return_ACPI_STATUS(AE_NO_MEMORY);
-	}
-
-	node->parent = parent;
-	node->next = NULL;
-
-	device = &(node->device);
-
-	device->handle = node_list.count;
-	device->acpi_handle = acpi_handle;
-
-	/*
-	 * Device Type:
-	 * ------------
-	 */
-	switch (acpi_type) {
-	case INTERNAL_TYPE_SCOPE:
-		device->id.type = BM_TYPE_SCOPE;
-		break;
-	case ACPI_TYPE_PROCESSOR:
-		device->id.type = BM_TYPE_PROCESSOR;
-		break;
-	case ACPI_TYPE_THERMAL:
-		device->id.type = BM_TYPE_THERMAL_ZONE;
-		break;
-	case ACPI_TYPE_POWER:
-		device->id.type = BM_TYPE_POWER_RESOURCE;
-		break;
-	case ACPI_TYPE_DEVICE:
-		device->id.type = BM_TYPE_DEVICE;
-		break;
-	}
-
-	/*
-	 * Get Other Device Info:
-	 * ----------------------
-	 * But only if this device's parent is present (which implies
-	 * this device MAY be present).
-	 */
-	if (BM_NODE_PRESENT(node->parent)) {
-		/*
-		 * Device Flags
-		 */
-		status = bm_get_flags(device);
-		if (ACPI_FAILURE(status)) {
-			goto end;
-		}
-
-		/*
-		 * Device Identification
-		 */
-		status = bm_get_identification(device);
-		if (ACPI_FAILURE(status)) {
-			goto end;
-		}
-
-		/*
-		 * Device Status
-		 */
-		status = bm_get_status(device);
-		if (ACPI_FAILURE(status)) {
-			goto end;
-		}
-
-		/*
-		 * Power Management:
-		 * -----------------
-		 * If this node doesn't provide direct power control
-		 * then we inherit PM capabilities from its parent.
-		 *
-		 * TBD: Inherit!
-		 */
-		if (BM_IS_POWER_CONTROL(device)) {
-			status = bm_get_pm_capabilities(node);
-			if (ACPI_FAILURE(status)) {
-				goto end;
-			}
-		}
-	}
-
-end:
-	if (ACPI_FAILURE(status)) {
-		acpi_os_free(node);
-	}
-	else {
-		/*
-		 * Add to the node_list.
-		 */
-		node_list.nodes[node_list.count++] = node;
-
-		/*
-		 * Formulate Hierarchy:
-		 * --------------------
-		 * Arrange within the namespace by assigning the parent and
-		 * adding to the parent device's list of children (scope).
-		 */
-		if (!parent->scope.head) {
-			parent->scope.head = node;
-		}
-		else {
-			if (!parent->scope.tail) {
-				(parent->scope.head)->next = node;
-			}
-			else {
-				(parent->scope.tail)->next = node;
-			}
-		}
-		parent->scope.tail = node;
-
-		(*child) = node;
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_enumerate_namespace
- *
- * PARAMETERS:  <none>
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_enumerate_namespace (void)
-{
-	acpi_status		status = AE_OK;
-	acpi_handle             parent_handle = ACPI_ROOT_OBJECT;
-	acpi_handle             child_handle = NULL;
-	BM_NODE			*parent = NULL;
-	BM_NODE			*child = NULL;
-	acpi_object_type        acpi_type = 0;
-	u32                     level = 1;
-
-	FUNCTION_TRACE("bm_enumerate_namespace");
-
-	parent = node_list.nodes[0];
-
-	/*
-	 * Enumerate ACPI Namespace:
-	 * -------------------------
-	 * Parse through the ACPI namespace, identify all 'devices',
-	 * and create a new entry for each in our collection.
-	 */
-	while (level > 0) {
-
-		/*
-		 * Get the next object at this level.
-		 */
-		status = acpi_get_next_object(ACPI_TYPE_ANY, parent_handle, child_handle, &child_handle);
-		if (ACPI_SUCCESS(status)) {
-			/*
-			 * TBD: This is a hack to get around the problem
-			 *       identifying scope objects.  Scopes
-			 *       somehow need to be uniquely identified.
-			 */
-			status = acpi_get_type(child_handle, &acpi_type);
-			if (ACPI_SUCCESS(status) && (acpi_type == ACPI_TYPE_ANY)) {
-				status = acpi_get_next_object(ACPI_TYPE_ANY, child_handle, 0, NULL);
-				if (ACPI_SUCCESS(status)) {
-					acpi_type = INTERNAL_TYPE_SCOPE;
-				}
-			}
-
-			/*
-			 * Device?
-			 * -------
-			 * If this object is a 'device', insert into the
-			 * ACPI Bus Manager's local hierarchy and search
-			 * the object's scope for any child devices (a
-			 * depth-first search).
-			 */
-			switch (acpi_type) {
-			case INTERNAL_TYPE_SCOPE:
-			case ACPI_TYPE_DEVICE:
-			case ACPI_TYPE_PROCESSOR:
-			case ACPI_TYPE_THERMAL:
-			case ACPI_TYPE_POWER:
-				status = bm_add_namespace_device(child_handle, acpi_type, parent, &child);
-				if (ACPI_SUCCESS(status)) {
-					status = acpi_get_next_object(ACPI_TYPE_ANY, child_handle, 0, NULL);
-					if (ACPI_SUCCESS(status)) {
-						level++;
-						parent_handle = child_handle;
-						child_handle = 0;
-						parent = child;
-					}
-				}
-				break;
-			}
-		}
-
-		/*
-		 * Scope Exhausted:
-		 * ----------------
-		 * No more children in this object's scope, Go back up
-		 * in the namespace tree to the object's parent.
-		 */
-		else {
-			level--;
-			child_handle = parent_handle;
-			acpi_get_parent(parent_handle,
-				&parent_handle);
-
-			if (parent) {
-				parent = parent->parent;
-			}
-			else {
-				return_ACPI_STATUS(AE_NULL_ENTRY);
-			}
-		}
-	}
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_add_fixed_feature_device
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_add_fixed_feature_device (
-	BM_NODE			*parent,
-	BM_DEVICE_TYPE		device_type,
-	char			*device_hid)
-{
-	acpi_status             status = AE_OK;
-	BM_NODE			*node = NULL;
-
-	FUNCTION_TRACE("bm_add_fixed_feature_device");
-
-	if (!parent) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	if (node_list.count > BM_HANDLES_MAX) {
-		return_ACPI_STATUS(AE_NO_MEMORY);
-	}
-
-	/*
-	 * Allocate the new device and add to the device array.
-	 */
-	node = acpi_os_callocate(sizeof(BM_NODE));
-	if (!node) {
-		return_ACPI_STATUS(AE_NO_MEMORY);
-	}
-
-	/*
-	 * Get device info.
-	 */
-	node->device.handle = node_list.count;
-	node->device.acpi_handle = ACPI_ROOT_OBJECT;
-	node->device.id.type = BM_TYPE_FIXED_BUTTON;
-	if (device_hid) {
-		MEMCPY((void*)node->device.id.hid, device_hid,
-			sizeof(node->device.id.hid));
-	}
-	node->device.flags = BM_FLAGS_FIXED_FEATURE;
-	node->device.status = BM_STATUS_DEFAULT;
-	/* TBD: Device PM capabilities */
-
-	/*
-	 * Add to the node_list.
-	 */
-	node_list.nodes[node_list.count++] = node;
-
-	/*
-	 * Formulate Hierarchy:
-	 * --------------------
-	 * Arrange within the namespace by assigning the parent and
-	 * adding to the parent device's list of children (scope).
-	 */
-	node->parent = parent;
-	node->next = NULL;
-
-	if (parent) {
-		if (!parent->scope.head) {
-			parent->scope.head = node;
-		}
-		else {
-			if (!parent->scope.tail) {
-				(parent->scope.head)->next = node;
-			}
-			else {
-				(parent->scope.tail)->next = node;
-			}
-		}
-		parent->scope.tail = node;
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_enumerate_fixed_features
- *
- * PARAMETERS:  <none>
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_enumerate_fixed_features (void)
-{
-	FUNCTION_TRACE("bm_enumerate_fixed_features");
-
-	/*
-	 * Root Object:
-	 * ------------
-	 * Fabricate the root object, which happens to always get a
-	 * device_handle of zero.
-	 */
-	node_list.nodes[0] = acpi_os_callocate(sizeof(BM_NODE));
-	if (NULL == (node_list.nodes[0])) {
-		return_ACPI_STATUS(AE_NO_MEMORY);
-	}
-
-	node_list.nodes[0]->device.handle = BM_HANDLE_ROOT;
-	node_list.nodes[0]->device.acpi_handle = ACPI_ROOT_OBJECT;
-	node_list.nodes[0]->device.flags = BM_FLAGS_UNKNOWN;
-	node_list.nodes[0]->device.status = BM_STATUS_DEFAULT;
-	node_list.nodes[0]->device.id.type = BM_TYPE_SYSTEM;
-	/* TBD: Get system PM capabilities (Sx states?) */
-
-	node_list.count++;
-
-	/*
-	 * Fixed Features:
-	 * ---------------
-	 * Enumerate fixed-feature devices (e.g. power and sleep buttons).
-	 */
-	if (acpi_fadt.pwr_button == 0) {
-		bm_add_fixed_feature_device(node_list.nodes[0],
-			BM_TYPE_FIXED_BUTTON, BM_HID_POWER_BUTTON);
-	}
-
-	if (acpi_fadt.sleep_button == 0) {
-		bm_add_fixed_feature_device(node_list.nodes[0],
-			BM_TYPE_FIXED_BUTTON, BM_HID_SLEEP_BUTTON);
-	}
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_get_handle
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_get_handle (
-	acpi_handle             acpi_handle,
-	BM_HANDLE               *device_handle)
-{
-	acpi_status             status = AE_NOT_FOUND;
-	u32			i = 0;
-
-	FUNCTION_TRACE("bm_get_handle");
-
-	if (!device_handle) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	*device_handle = BM_HANDLE_UNKNOWN;
-
-	/*
-	 * Search all devices for a match on the ACPI handle.
-	 */
-	for (i=0; i<node_list.count; i++) {
-
-		if (!node_list.nodes[i]) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid (NULL) node entry [%p] detected.\n", device_handle));
-			status = AE_NULL_ENTRY;
-			break;
-		}
-
-		if (node_list.nodes[i]->device.acpi_handle == acpi_handle) {
-			*device_handle = node_list.nodes[i]->device.handle;
-			status = AE_OK;
-			break;
-		}
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_get_node
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_get_node (
-	BM_HANDLE               device_handle,
-	acpi_handle             acpi_handle,
-	BM_NODE			**node)
-{
-	acpi_status             status = AE_OK;
-
-	FUNCTION_TRACE("bm_get_node");
-
-	if (!node) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/* busmgr failed to init, but we're being called by subordinate drivers */
-	if (node_list.count < 1) {
-		return_ACPI_STATUS(AE_NOT_FOUND);
-	}
-
-	/*
-	 * If no device handle, resolve acpi handle to device handle.
-	 */
-	if (!device_handle && acpi_handle) {
-		status = bm_get_handle(acpi_handle, &device_handle);
-		if (ACPI_FAILURE(status))
-			return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Valid device handle?
-	 */
-	if (device_handle > BM_HANDLES_MAX) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid node handle [%02x] detected.\n", device_handle));
-		return_ACPI_STATUS(AE_ERROR);
-	}
-
-	*node = node_list.nodes[device_handle];
-
-	/*
-	 * Valid node?
-	 */
-	if (!(*node)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid (NULL) node entry [%02x] detected.\n", device_handle));
-		return_ACPI_STATUS(AE_NULL_ENTRY);
-	}
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *                            External Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:    bm_initialize
- *
- * PARAMETERS:  <none>
- *
- * RETURN:      Exception code.
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_initialize (void)
-{
-	acpi_status             status = AE_OK;
-	u32                     start = 0;
-	u32                     stop = 0;
-	u32                     elapsed = 0;
-
-	FUNCTION_TRACE("bm_initialize");
-
-	MEMSET(&node_list, 0, sizeof(BM_NODE_LIST));
-
-	status = acpi_get_timer(&start);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Building device hierarchy.\n"));
-
-	/*
-	 * Enumerate ACPI fixed-feature devices.
-	 */
-	status = bm_enumerate_fixed_features();
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Enumerate the ACPI namespace.
-	 */
-	status = bm_enumerate_namespace();
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	acpi_get_timer(&stop);
-	acpi_get_timer_duration(start, stop, &elapsed);
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Building device hierarchy took [%d] microseconds.\n", elapsed));
-
-	/*
-	 * Display hierarchy.
-	 */
-	bm_print_hierarchy();
-
-	/*
-	 * Register for all standard and device-specific notifications.
-	 */
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Registering for all device notifications.\n"));
-
-	status = acpi_install_notify_handler(ACPI_ROOT_OBJECT,
-		ACPI_SYSTEM_NOTIFY, &bm_notify, NULL);
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unable to register for standard notifications.\n"));
-		return_ACPI_STATUS(status);
-	}
-
-	status = acpi_install_notify_handler(ACPI_ROOT_OBJECT,
-		ACPI_DEVICE_NOTIFY, &bm_notify, NULL);
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unable to register for device-specific notifications.\n"));
-		return_ACPI_STATUS(status);
-	}
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Bus Manager enabled.\n"));
-
-	/*
-	 * Initialize built-in power resource driver.
-	 */
-	bm_pr_initialize();
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_terminate
- *
- * PARAMETERS:  <none>
- *
- * RETURN:      Exception code.
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_terminate (void)
-{
-	acpi_status             status = AE_OK;
-	u32                     i = 0;
-
-	FUNCTION_TRACE("bm_terminate");
-
-	/*
-	 * Terminate built-in power resource driver.
-	 */
-	bm_pr_terminate();
-
-	/*
-	 * Unregister for all notifications.
-	 */
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Unregistering for device notifications.\n"));
-
-	status = acpi_remove_notify_handler(ACPI_ROOT_OBJECT,
-		ACPI_SYSTEM_NOTIFY, &bm_notify);
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unable to un-register for standard notifications.\n"));
-	}
-
-	status = acpi_remove_notify_handler(ACPI_ROOT_OBJECT,
-		ACPI_DEVICE_NOTIFY, &bm_notify);
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unable to un-register for device-specific notifications.\n"));
-	}
-
-	/*
-	 * Parse through the device array, freeing all entries.
-	 */
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing device hierarchy.\n"));
-	for (i = 0; i < node_list.count; i++) {
-		if (node_list.nodes[i]) {
-			acpi_os_free(node_list.nodes[i]);
-		}
-	}
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Bus Manager disabled.\n"));
-
-	return_ACPI_STATUS(AE_OK);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/busmgr/bm_osl.c linux-2.4.22-pre2/drivers/acpi/ospm/busmgr/bm_osl.c
--- linux-2.4.21/drivers/acpi/ospm/busmgr/bm_osl.c	2002-11-28 23:53:12.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/busmgr/bm_osl.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,390 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: bm_osl.c
- *   $Revision: 17 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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/proc_fs.h>
-#include <linux/spinlock.h>
-#include <linux/poll.h>
-#include <asm/uaccess.h>
-#include <acpi.h>
-#include "bm.h"
-
-
-MODULE_AUTHOR("Andrew Grover");
-MODULE_DESCRIPTION("ACPI Component Architecture (CA) - ACPI Bus Manager");
-MODULE_LICENSE("GPL");
-
-
-/*****************************************************************************
- *                               Types & Defines
- *****************************************************************************/
-
-typedef struct
-{
-	BM_HANDLE		device_handle;
-	char			*device_type;
-	char			*device_instance;
-	u32			event_type;
-	u32			event_data;
-	struct list_head	list;
-} BM_OSL_EVENT;
-
-
-#define BM_PROC_ROOT		"acpi"
-#define BM_PROC_EVENT		"event"
-#define BM_PROC_DEVICES		"devices"
-
-#define BM_MAX_STRING_LENGTH	80
-
-
-/****************************************************************************
- *                                  Globals
- ****************************************************************************/
-
-struct proc_dir_entry		*bm_proc_root = NULL;
-static struct proc_dir_entry	*bm_proc_event = NULL;
-
-#ifdef ACPI_DEBUG
-static u32			save_dbg_layer;
-static u32			save_dbg_level;
-#endif /*ACPI_DEBUG*/
-
-extern BM_NODE_LIST		node_list;
-
-static spinlock_t		bm_osl_event_lock = SPIN_LOCK_UNLOCKED;
-
-static LIST_HEAD(bm_event_list);
-
-static DECLARE_WAIT_QUEUE_HEAD(bm_event_wait_queue);
-
-static int event_is_open = 0;
-
-
-/****************************************************************************
- *                                 Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:	bm_osl_generate_event
- *
- * DESCRIPTION: Generates an event for user-space consumption by writing
- *              the event data to the 'event' file.
- *
- ****************************************************************************/
-
-acpi_status
-bm_osl_generate_event (
-	BM_HANDLE		device_handle,
-	char			*device_type,
-	char			*device_instance,
-	u32			event_type,
-	u32			event_data)
-{
-	BM_OSL_EVENT		*event = NULL;
-	unsigned long		flags = 0;
-
-	/* drop event on the floor if no one's listening */
-	if (!event_is_open)
-		return (AE_OK);
-
-	/*
-	 * Allocate a new event structure.
-	 */
-	event = acpi_os_callocate(sizeof(BM_OSL_EVENT));
-	if (!event)
-		goto alloc_error;
-
-	event->device_type = acpi_os_callocate(strlen(device_type)
-		+ sizeof(char));
-	if (!event->device_type)
-		goto alloc_error;
-
-	event->device_instance = acpi_os_callocate(strlen(device_instance)
-		+ sizeof(char));
-	if (!event->device_instance)
-		goto alloc_error;
-
-	/*
-	 * Set event data.
-	 */
-	event->device_handle = device_handle;
-	strcpy(event->device_type, device_type);
-	strcpy(event->device_instance, device_instance);
-	event->event_type = event_type;
-	event->event_data = event_data;
-
-	/*
-	 * Add to the end of our event list.
-	 */
-	spin_lock_irqsave(&bm_osl_event_lock, flags);
-	list_add_tail(&event->list, &bm_event_list);
-	spin_unlock_irqrestore(&bm_osl_event_lock, flags);
-
-	/*
-	 * Signal waiting threads (if any).
-	 */
-	wake_up_interruptible(&bm_event_wait_queue);
-
-	return(AE_OK);
-
-alloc_error:
-	if (event->device_instance)
-		acpi_os_free(event->device_instance);
-
-	if (event->device_type)
-		acpi_os_free(event->device_type);
-
-	if (event)
-		acpi_os_free(event);		
-
-	return (AE_NO_MEMORY);
-}
-
-static int bm_osl_open_event(struct inode *inode, struct file *file)
-{
-	spin_lock_irq (&bm_osl_event_lock);
-
-	if(event_is_open)
-		goto out_busy;
-
-	event_is_open = 1;
-
-	spin_unlock_irq (&bm_osl_event_lock);
-	return 0;
-
-out_busy:
-	spin_unlock_irq (&bm_osl_event_lock);
-	return -EBUSY;
-}
-
-
-static int bm_osl_close_event(struct inode *inode, struct file *file)
-{
-	event_is_open = 0;
-	return 0;
-}
-
-/****************************************************************************
- *
- * FUNCTION:	bm_osl_read_event
- *
- * DESCRIPTION: Handles reads to the 'event' file by blocking user-mode
- *              threads until data (an event) is generated.
- *
- ****************************************************************************/
-static ssize_t
-bm_osl_read_event(
-	struct file		*file,
-	char			*buf,
-	size_t			count,
-	loff_t			*ppos)
-{
-	BM_OSL_EVENT		*event = NULL;
-	unsigned long		flags = 0;
-	static char		str[BM_MAX_STRING_LENGTH];
-	static int		chars_remaining = 0;
-	static char 		*ptr;
-
-	if (!chars_remaining) {
-		DECLARE_WAITQUEUE(wait, current);
-
-		if (list_empty(&bm_event_list)) {
-
-			if (file->f_flags & O_NONBLOCK)
-				return -EAGAIN;
-
-			set_current_state(TASK_INTERRUPTIBLE);
-			add_wait_queue(&bm_event_wait_queue, &wait);
-
-			if (list_empty(&bm_event_list)) {
-				schedule();
-			}
-
-			remove_wait_queue(&bm_event_wait_queue, &wait);
-			set_current_state(TASK_RUNNING);
-
-			if (signal_pending(current)) {
-				return -ERESTARTSYS;
-			}
-		}
-
-		spin_lock_irqsave(&bm_osl_event_lock, flags);
-		event = list_entry(bm_event_list.next, BM_OSL_EVENT, list);
-		list_del(&event->list);
-		spin_unlock_irqrestore(&bm_osl_event_lock, flags);
-
-		chars_remaining = sprintf(str, "%s %s %08x %08x\n",
-			event->device_type, event->device_instance,
-			event->event_type, event->event_data);
-		ptr = str;
-
-		acpi_os_free(event->device_type);
-		acpi_os_free(event->device_instance);
-		acpi_os_free(event);
-	}
-
-	if (chars_remaining < count)
-		count = chars_remaining;
-	
-	if (copy_to_user(buf, ptr, count))
-		return -EFAULT;
-
-	*ppos += count;
-	chars_remaining -= count;
-	ptr += count;
-
-	return count;
-}
-
-/****************************************************************************
- *
- * FUNCTION:	bm_osl_poll_event
- *
- * DESCRIPTION: Handles poll() of the 'event' file by blocking user-mode 
- *              threads until data (an event) is generated.
- *
- ****************************************************************************/
-static unsigned int
-bm_osl_poll_event(
-	struct file		*file, 
-	poll_table		*wait)
-{
-	poll_wait(file, &bm_event_wait_queue, wait);
-	if (!list_empty(&bm_event_list))
-		return POLLIN | POLLRDNORM;
-	return 0;
-}
-
-struct file_operations proc_event_operations = {
-	open:		bm_osl_open_event,
-	read:		bm_osl_read_event,
-	release:	bm_osl_close_event,
-	poll:		bm_osl_poll_event,	
-};
-
-/****************************************************************************
- *
- * FUNCTION:    bm_osl_init
- *
- ****************************************************************************/
-
-int
-bm_osl_init(void)
-{
-	acpi_status		status = AE_OK;
-
-	status = acpi_subsystem_status();
-	if (ACPI_FAILURE(status))
-		return -ENODEV;
-
-	bm_proc_root = proc_mkdir(BM_PROC_ROOT, NULL);
-	if (!bm_proc_root) {
-		return(AE_ERROR);
-	}
-
-	bm_proc_event = create_proc_entry(BM_PROC_EVENT, S_IRUSR, bm_proc_root);
-	if (bm_proc_event) {
-		bm_proc_event->proc_fops = &proc_event_operations;
-	}
-
-	status = bm_initialize();
-
-	return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_osl_cleanup
- *
- ****************************************************************************/
-
-void
-bm_osl_cleanup(void)
-{
-	bm_terminate();
-
-	if (bm_proc_event) {
-		remove_proc_entry(BM_PROC_EVENT, bm_proc_root);
-		bm_proc_event = NULL;
-	}
-
-	if (bm_proc_root) {
-		remove_proc_entry(BM_PROC_ROOT, NULL);
-		bm_proc_root = NULL;
-	}
-
-	return;
-}
-
-
-module_init(bm_osl_init);
-module_exit(bm_osl_cleanup);
-
-
-/****************************************************************************
- *                                  Symbols
- ****************************************************************************/
-
-/* bm.c */
-
-EXPORT_SYMBOL(bm_get_node);
-
-/* bmdriver.c */
-
-EXPORT_SYMBOL(bm_get_device_power_state);
-EXPORT_SYMBOL(bm_set_device_power_state);
-EXPORT_SYMBOL(bm_get_device_info);
-EXPORT_SYMBOL(bm_get_device_status);
-EXPORT_SYMBOL(bm_get_device_context);
-EXPORT_SYMBOL(bm_register_driver);
-EXPORT_SYMBOL(bm_unregister_driver);
-
-/* bmsearch.c */
-
-EXPORT_SYMBOL(bm_search);
-
-/* bmrequest.c */
-
-EXPORT_SYMBOL(bm_request);
-
-/* bmutils.c */
-
-EXPORT_SYMBOL(bm_extract_package_data);
-EXPORT_SYMBOL(bm_evaluate_object);
-EXPORT_SYMBOL(bm_evaluate_simple_integer);
-EXPORT_SYMBOL(bm_evaluate_reference_list);
-EXPORT_SYMBOL(bm_copy_to_buffer);
-EXPORT_SYMBOL(bm_cast_buffer);
-
-/* bm_proc.c */
-
-EXPORT_SYMBOL(bm_osl_generate_event);
-EXPORT_SYMBOL(bm_proc_root);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/busmgr/bmdriver.c linux-2.4.22-pre2/drivers/acpi/ospm/busmgr/bmdriver.c
--- linux-2.4.21/drivers/acpi/ospm/busmgr/bmdriver.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/busmgr/bmdriver.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,469 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: bmdriver.c
- *   $Revision: 21 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include <acpi.h>
-#include "bm.h"
-
-#define _COMPONENT		ACPI_BUS
-	MODULE_NAME		("bmdriver")
-
-
-/****************************************************************************
- *                            External Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:    bm_get_device_power_state
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_get_device_power_state (
-	BM_HANDLE               device_handle,
-	BM_POWER_STATE		*state)
-{
-	acpi_status             status = AE_OK;
-	BM_NODE			*node = NULL;
-
-	FUNCTION_TRACE("bm_get_device_power_state");
-
-	if (!state) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	*state = ACPI_STATE_UNKNOWN;
-
-	/*
-	 * Resolve device handle to node.
-	 */
-	status = bm_get_node(device_handle, 0, &node);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Get the current power state.
-	 */
-	status = bm_get_power_state(node);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	*state = node->device.power.state;
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_set_device_power_state
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_set_device_power_state (
-	BM_HANDLE               device_handle,
-	BM_POWER_STATE		state)
-{
-	acpi_status           status = AE_OK;
-	BM_NODE			*node = NULL;
-
-	FUNCTION_TRACE("bm_set_device_power_state");
-
-	/*
-	 * Resolve device handle to node.
-	 */
-	status = bm_get_node(device_handle, 0, &node);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Set the current power state.
-	 */
-	status = bm_set_power_state(node, state);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_get_device_status
- *
- * PARAMETERS:
- *    device_handle is really an index number into the array of BM_DEVICE
- *                  structures in info_list.  This data item is passed to
- *                  the registered program's "notify" callback.  It is used
- *                  to retrieve the specific BM_DEVICE structure instance
- *                  associated with the callback.
- *    device_status is a pointer that receives the result of processing
- *                  the device's associated ACPI _STA.
- *
- * RETURN:
- *    The acpi_status value indicates success AE_OK or failure of the function
- *
- * DESCRIPTION: Evaluates the device's ACPI _STA, if it is present.
- *
- ****************************************************************************/
-
-acpi_status
-bm_get_device_status (
-	BM_HANDLE               device_handle,
-	BM_DEVICE_STATUS        *device_status)
-{
-	acpi_status           status = AE_OK;
-	BM_NODE			*node = NULL;
-
-	FUNCTION_TRACE("bm_get_device_status");
-
-	if (!device_status) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	*device_status = BM_STATUS_UNKNOWN;
-
-	/*
-	 * Resolve device handle to node.
-	 */
-	status = bm_get_node(device_handle, 0, &node);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Parent Present?
-	 * ---------------
-	 * If the parent isn't present we can't evalute _STA on the child.
-	 * Return an unknown status.
-	 */
-	if (!BM_NODE_PRESENT(node->parent)) {
-		return_ACPI_STATUS(AE_OK);
-	}
-	
-	/*
-	 * Dynamic Status?
-	 * ---------------
-	 * If _STA isn't present we just return the default status.
-	 */
-	if (!(node->device.flags & BM_FLAGS_DYNAMIC_STATUS)) {
-		*device_status = BM_STATUS_DEFAULT;
-		return_ACPI_STATUS(AE_OK);
-	}
-
-	/*
-	 * Evaluate _STA:
-	 * --------------
-	 */
-	status = bm_evaluate_simple_integer(node->device.acpi_handle, "_STA",
-		&(node->device.status));
-	if (ACPI_SUCCESS(status)) {
-		*device_status = node->device.status;
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_get_device_info
- *
- * PARAMETERS:
- *    device_handle An index used to retrieve the associated BM_DEVICE info.
- *    device        A pointer to a BM_DEVICE structure instance pointer.
- *                  This pointed to BM_DEVICE structure will contain the
- *                  this device's information.
- *
- * RETURN:
- *    The acpi_status value indicates success AE_OK or failure of the function
- *
- * DESCRIPTION:
- *    Using the device_handle this function retrieves this device's
- *    BM_DEVICE structure instance and save's it in device.
- *
- ****************************************************************************/
-
-acpi_status
-bm_get_device_info (
-	BM_HANDLE               device_handle,
-	BM_DEVICE               **device)
-{
-	acpi_status           status = AE_OK;
-	BM_NODE			*node = NULL;
-
-	FUNCTION_TRACE("bm_get_device_info");
-
-	if (!device) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Resolve device handle to internal device.
-	 */
-	status = bm_get_node(device_handle, 0, &node);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	*device = &(node->device);
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_get_device_context
- *
- *    device_handle An index used to retrieve the associated BM_DEVICE info.
- *    context       A pointer to a BM_DRIVER_CONTEXT structure instance.
- *
- * RETURN:
- *    The acpi_status value indicates success AE_OK or failure of the function
- *
- * DESCRIPTION:
- *    Using the device_handle this function retrieves this device's
- *    BM_DRIVER_CONTEXT structure instance and save's it in context.
- *
- ****************************************************************************/
-
-acpi_status
-bm_get_device_context (
-	BM_HANDLE               device_handle,
-	BM_DRIVER_CONTEXT	*context)
-{
-	acpi_status           status = AE_OK;
-	BM_NODE			*node = NULL;
-
-	FUNCTION_TRACE("bm_get_device_context");
-
-	if (!context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	*context = NULL;
-
-	/*
-	 * Resolve device handle to internal device.
-	 */
-	status = bm_get_node(device_handle, 0, &node);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	if (!node->driver.context) {
-		return_ACPI_STATUS(AE_NULL_ENTRY);
-	}
-
-	*context = node->driver.context;
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_register_driver
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_register_driver (
-	BM_DEVICE_ID		*criteria,
-	BM_DRIVER		*driver)
-{
-	acpi_status           status = AE_NOT_FOUND;
-	BM_HANDLE_LIST          device_list;
-	BM_NODE			*node = NULL;
-	BM_DEVICE		*device = NULL;
-	u32                     i = 0;
-
-	FUNCTION_TRACE("bm_register_driver");
-
-	if (!criteria || !driver || !driver->notify || !driver->request) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	MEMSET(&device_list, 0, sizeof(BM_HANDLE_LIST));
-
-	/*
-	 * Find Matches:
-	 * -------------
-	 * Search through the entire device hierarchy for matches against
-	 * the given device criteria.
-	 */
-	status = bm_search(BM_HANDLE_ROOT, criteria, &device_list);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Install driver:
-	 * ----------------
-	 * For each match, record the driver information and execute the
-	 * driver's Notify() funciton (if present) to notify the driver
-	 * of the device's presence.
-	 */
-	for (i = 0; i < device_list.count; i++) {
-
-		/* Resolve the device handle. */
-		status = bm_get_node(device_list.handles[i], 0, &node);
-		if (ACPI_FAILURE(status)) {
-			continue;
-		}
-
-		device = &(node->device);
-
-		/*
-		 * Make sure another driver hasn't already registered for
-		 * this device.
-		 */
-		if (BM_IS_DRIVER_CONTROL(device)) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Another driver has already registered for device [%02x].\n", device->handle));
-			continue;
-		}
-
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Registering driver for device [%02x].\n", device->handle));
-
-		/* Notify driver of new device. */
-		status = driver->notify(BM_NOTIFY_DEVICE_ADDED,
-			node->device.handle, &(node->driver.context));
-		if (ACPI_SUCCESS(status)) {
-			node->driver.notify = driver->notify;
-			node->driver.request = driver->request;
-			node->device.flags |= BM_FLAGS_DRIVER_CONTROL;
-		}
-	}
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_unregister_driver
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_unregister_driver (
-	BM_DEVICE_ID		*criteria,
-	BM_DRIVER		*driver)
-{
-	acpi_status           status = AE_NOT_FOUND;
-	BM_HANDLE_LIST          device_list;
-	BM_NODE			*node = NULL;
-	BM_DEVICE		*device = NULL;
-	u32                     i = 0;
-
-	FUNCTION_TRACE("bm_unregister_driver");
-
-	if (!criteria || !driver || !driver->notify || !driver->request) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	MEMSET(&device_list, 0, sizeof(BM_HANDLE_LIST));
-
-	/*
-	 * Find Matches:
-	 * -------------
-	 * Search through the entire device hierarchy for matches against
-	 * the given device criteria.
-	 */
-	status = bm_search(BM_HANDLE_ROOT, criteria, &device_list);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Remove driver:
-	 * ---------------
-	 * For each match, execute the driver's Notify() function to allow
-	 * the driver to cleanup each device instance.
-	 */
-	for (i = 0; i < device_list.count; i++) {
-
-		/* Resolve the device handle. */
-		status = bm_get_node(device_list.handles[i], 0, &node);
-		if (ACPI_FAILURE(status)) {
-			continue;
-		}
-
-		device = &(node->device);
-
-		/*
-		 * Make sure driver has really registered for this device.
-		 */
-		if (!BM_IS_DRIVER_CONTROL(device)) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Driver hasn't registered for device [%02x].\n", device->handle));
-			continue;
-		}
-
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Unregistering driver for device [%02x].\n", device->handle));
-
-		/* Notify driver of device removal. */
-		status = node->driver.notify(BM_NOTIFY_DEVICE_REMOVED,
-			node->device.handle, &(node->driver.context));
-		if (ACPI_SUCCESS(status)) {
-			node->driver.notify = NULL;
-			node->driver.request = NULL;
-			node->driver.context = NULL;
-			node->device.flags &= ~BM_FLAGS_DRIVER_CONTROL;
-		}
-	}
-
-	return_ACPI_STATUS(AE_OK);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/busmgr/bmnotify.c linux-2.4.22-pre2/drivers/acpi/ospm/busmgr/bmnotify.c
--- linux-2.4.21/drivers/acpi/ospm/busmgr/bmnotify.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/busmgr/bmnotify.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,312 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: bmnotify.c
- *   $Revision: 21 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include <acpi.h>
-#include "bm.h"
-
-
-#define _COMPONENT		ACPI_BUS
-	 MODULE_NAME		("bmnotify")
-
-
-/****************************************************************************
- *                            Internal Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:    bm_generate_notify
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_generate_notify (
-	BM_NODE			*node,
-	u32			notify_type)
-{
-	acpi_status		status = AE_OK;
-	BM_DEVICE		*device = NULL;
-
-	FUNCTION_TRACE("bm_generate_notify");
-
-	if (!node) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	device = &(node->device);
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Sending notify [%02x] to device [%02x].\n", notify_type, node->device.handle));
-
-	if (!BM_IS_DRIVER_CONTROL(device)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "No driver installed for device [%02x].\n", device->handle));
-		return_ACPI_STATUS(AE_NOT_EXIST);
-	}
-
-	status = node->driver.notify(notify_type, node->device.handle,
-		&(node->driver.context));
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_device_check
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_device_check (
-	BM_NODE			*node,
-	u32			*status_change)
-{
-	acpi_status             status = AE_OK;
-	BM_DEVICE		*device = NULL;
-	BM_DEVICE_STATUS	old_status = BM_STATUS_UNKNOWN;
-
-	FUNCTION_TRACE("bm_device_check");
-
-	if (!node) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	device = &(node->device);
-
-	if (status_change) {
-		*status_change = FALSE;
-	}
-
-	old_status = device->status;
-
-	/*
-	 * Parent Present?
-	 * ---------------
-	 * Only check this device if its parent is present (which implies
-	 * this device MAY be present).
-	 */
-	if (!BM_NODE_PRESENT(node->parent)) {
-		return_ACPI_STATUS(AE_OK);
-	}
-
-	/*
-	 * Get Status:
-	 * -----------
-	 * And see if the status has changed.
-	 */
-	status = bm_get_status(device);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-	
-	if (old_status == node->device.status) {
-		return_ACPI_STATUS(AE_OK);
-	}
-
-	if (status_change) {
-		*status_change = TRUE;
-	}
-	
-	/*
-	 * Device Insertion?
-	 * -----------------
-	 */
-	if ((device->status & BM_STATUS_PRESENT) &&
-		!(old_status & BM_STATUS_PRESENT)) {
-		/* TBD: Make sure driver is loaded, and if not, load. */
-		status = bm_generate_notify(node, BM_NOTIFY_DEVICE_ADDED);
-	}
-
-	/*
-	 * Device Removal?
-	 * ---------------
-	 */
-	else if (!(device->status & BM_STATUS_PRESENT) &&
-		(old_status & BM_STATUS_PRESENT)) {
-		/* TBD: Unload driver if last device instance. */
-		status = bm_generate_notify(node, BM_NOTIFY_DEVICE_REMOVED);
-	}
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_bus_check
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_bus_check (
-	BM_NODE			*parent_node)
-{
-	acpi_status             status = AE_OK;
-	u32			status_change = FALSE;
-
-	FUNCTION_TRACE("bm_bus_check");
-
-	if (!parent_node) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Status Change?
-	 * --------------
-	 */
-	status = bm_device_check(parent_node, &status_change);
-	if (ACPI_FAILURE(status) || !status_change) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Enumerate Scope:
-	 * ----------------
-	 * TBD: Enumerate child devices within this device's scope and
-	 *       run bm_device_check()'s on them...
-	 */
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *                            External Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:    bm_notify
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-void
-bm_notify (
-	acpi_handle             acpi_handle,
-	u32                     notify_value,
-	void                    *context)
-{
-	acpi_status             status = AE_OK;
-	BM_NODE			*node = NULL;
-
-	FUNCTION_TRACE("bm_notify");
-
-	/*
-	 * Resolve the ACPI handle.
-	 */
-	status = bm_get_node(0, acpi_handle, &node);
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Recieved notify [%02x] for unknown device [%p].\n", notify_value, acpi_handle));
-		return_VOID;
-	}
-
-	/*
-	 * Device-Specific or Standard?
-	 * ----------------------------
-	 * Device-specific notifies are forwarded to the control module's
-	 * notify() function for processing.  Standard notifies are handled
-	 * internally.
-	 */
-	if (notify_value > 0x7F) {
-		status = bm_generate_notify(node, notify_value);
-	}
-	else {
-		switch (notify_value) {
-
-		case BM_NOTIFY_BUS_CHECK:
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Received BUS CHECK notification for device [%02x].\n", node->device.handle));
-			status = bm_bus_check(node);
-			break;
-
-		case BM_NOTIFY_DEVICE_CHECK:
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Received DEVICE CHECK notification for device [%02x].\n", node->device.handle));
-			status = bm_device_check(node, NULL);
-			break;
-
-		case BM_NOTIFY_DEVICE_WAKE:
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Received DEVICE WAKE notification for device [%02x].\n", node->device.handle));
-			/* TBD */
-			break;
-
-		case BM_NOTIFY_EJECT_REQUEST:
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Received EJECT REQUEST notification for device [%02x].\n", node->device.handle));
-			/* TBD */
-			break;
-
-		case BM_NOTIFY_DEVICE_CHECK_LIGHT:
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Received DEVICE CHECK LIGHT notification for device [%02x].\n", node->device.handle));
-			/* TBD: Exactly what does the 'light' mean? */
-			status = bm_device_check(node, NULL);
-			break;
-
-		case BM_NOTIFY_FREQUENCY_MISMATCH:
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Received FREQUENCY MISMATCH notification for device [%02x].\n", node->device.handle));
-			/* TBD */
-			break;
-
-		case BM_NOTIFY_BUS_MODE_MISMATCH:
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Received BUS MODE MISMATCH notification for device [%02x].\n", node->device.handle));
-			/* TBD */
-			break;
-
-		case BM_NOTIFY_POWER_FAULT:
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Received POWER FAULT notification.\n"));
-			/* TBD */
-			break;
-
-		default:
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Received unknown/unsupported notification.\n"));
-			break;
-		}
-	}
-
-	return_VOID;
-}
-
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/busmgr/bmpm.c linux-2.4.22-pre2/drivers/acpi/ospm/busmgr/bmpm.c
--- linux-2.4.21/drivers/acpi/ospm/busmgr/bmpm.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/busmgr/bmpm.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,442 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: bmpm.c
- *   $Revision: 14 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include <acpi.h>
-#include "bm.h"
-#include "bmpower.h"
-
-
-#define _COMPONENT		ACPI_BUS
-	MODULE_NAME		("bmpm")
-
-
-/****************************************************************************
- *                             Internal Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:    bm_get_inferred_power_state
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_get_inferred_power_state (
-	BM_DEVICE               *device)
-{
-	acpi_status             status = AE_OK;
-	BM_HANDLE_LIST          pr_list;
-	BM_POWER_STATE          list_state = ACPI_STATE_UNKNOWN;
-	char                    object_name[5] = {'_','P','R','0','\0'};
-	u32                     i = 0;
-
-	FUNCTION_TRACE("bm_get_inferred_power_state");
-
-	if (!device) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	MEMSET(&pr_list, 0, sizeof(BM_HANDLE_LIST));
-
-	device->power.state = ACPI_STATE_D3;
-
-	/*
-	 * Calculate Power State:
-	 * ----------------------
-	 * Try to infer the devices's power state by checking the state of
-	 * the devices's power resources.  We start by evaluating _PR0
-	 * (resource requirements at D0) and work through _PR1 and _PR2.
-	 * We know the current devices power state when all resources (for
-	 * a give Dx state) are ON.  If no power resources are on then the
-	 * device is assumed to be off (D3).
-	 */
-	for (i=ACPI_STATE_D0; i<ACPI_STATE_D3; i++) {
-
-		object_name[3] = '0' + i;
-
-		status = bm_evaluate_reference_list(device->acpi_handle,
-			object_name, &pr_list);
-
-		if (ACPI_SUCCESS(status)) {
-
-			status = bm_pr_list_get_state(&pr_list, &list_state);
-
-			if (ACPI_SUCCESS(status)) {
-
-				if (list_state == ACPI_STATE_D0) {
-					device->power.state = i;
-					break;
-				}
-			}
-		}
-	}
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *                             External Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:    bm_get_power_state
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_get_power_state (
-	BM_NODE			*node)
-{
-	acpi_status             status = AE_OK;
-	BM_DEVICE               *device = NULL;
-
-	FUNCTION_TRACE("bm_get_power_state");
-
-	if (!node || !node->parent) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	device = &(node->device);
-
-	device->power.state = ACPI_STATE_UNKNOWN;
-
-	/*
-	 * Power Control?
-	 * --------------
-	 * If this device isn't directly power manageable (e.g. doesn't
-	 * include _PR0/_PS0) then there's nothing to do (state is static).
-	 */
-	if (!BM_IS_POWER_CONTROL(device)) {
-		return_ACPI_STATUS(AE_OK);
-	}
-
-	/*
-	 * Parent Present?
-	 * ---------------
-	 * Make sure the parent is present before mucking with the child.
-	 */
-	if (!BM_NODE_PRESENT(node->parent)) {
-		return_ACPI_STATUS(AE_NOT_EXIST);
-	}
-	
-	/*
-	 * Get Power State:
-	 * ----------------
-	 * Either directly (via _PSC) or inferred (via power resource
-	 * dependencies).
-	 */
-	if (BM_IS_POWER_STATE(device)) {
-		status = bm_evaluate_simple_integer(device->acpi_handle,
-			"_PSC", &(device->power.state));
-	}
-	else {
-		status = bm_get_inferred_power_state(device);
-	}
-
-	if (ACPI_SUCCESS(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Device [%02x] is at power state [D%d].\n", device->handle, device->power.state));
-	}
-	else {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Error getting power state for device [%02x]\n", device->handle));
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_set_power_state
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_set_power_state (
-	BM_NODE			*node,
-	BM_POWER_STATE          state)
-{
-	acpi_status             status = AE_OK;
-	BM_DEVICE		*device = NULL;
-	BM_DEVICE		*parent_device = NULL;
-	BM_HANDLE_LIST          current_list;
-	BM_HANDLE_LIST          target_list;
-	char                    object_name[5] = {'_','P','R','0','\0'};
-
-	FUNCTION_TRACE("bm_set_power_state");
-
-	if (!node || !node->parent || (state > ACPI_STATE_D3)) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	MEMSET(&current_list, 0, sizeof(BM_HANDLE_LIST));
-	MEMSET(&target_list, 0, sizeof(BM_HANDLE_LIST));
-
-	device = &(node->device);
-	parent_device = &(node->parent->device);
-
-	/*
-	 * Power Control?
-	 * --------------
-	 * If this device isn't directly power manageable (e.g. doesn't
-	 * include _PR0/_PS0) then return an error (can't set state).
-	 */
-	if (!BM_IS_POWER_CONTROL(device)) {
-		return_ACPI_STATUS(AE_ERROR);
-	}
-
-	/*
-	 * Parent Present?
-	 * ---------------
-	 * Make sure the parent is present before mucking with the child.
-	 */
-	if (!BM_NODE_PRESENT(node->parent)) {
-		return_ACPI_STATUS(AE_NOT_EXIST);
-	}
-	
-	/*
-	 * Check Parent's Power State:
-	 * ---------------------------
-	 * Can't be in a higher power state (lower Dx value) than parent.
-	 */
-	if (state < parent_device->power.state) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Cannot set device [%02x] to a higher-powered state than parent_device.\n", device->handle));
-		return_ACPI_STATUS(AE_ERROR);
-	}
-
-	/*
-	 * Get Resources:
-	 * --------------
-	 * Get the power resources associated with the device's current
-	 * and target power states.
-	 */
-	if (device->power.state != ACPI_STATE_UNKNOWN) {
-		object_name[3] = '0' + device->power.state;
-		bm_evaluate_reference_list(device->acpi_handle,
-			object_name, &current_list);
-	}
-
-	object_name[3] = '0' + state;
-	bm_evaluate_reference_list(device->acpi_handle, object_name,
-		&target_list);
-
-	/*
-	 * Transition Resources:
-	 * ---------------------
-	 * Transition all power resources referenced by this device to
-	 * the correct power state (taking into consideration sequencing
-	 * and dependencies to other devices).
-	 */
-	if (current_list.count || target_list.count) {
-		status = bm_pr_list_transition(&current_list, &target_list);
-	}
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Execute _PSx:
-	 * -------------
-	 * Execute the _PSx method corresponding to the target Dx state,
-	 * if it exists.
-	 */
-	object_name[2] = 'S';
-	object_name[3] = '0' + state;
-	bm_evaluate_object(device->acpi_handle, object_name, NULL, NULL);
-
-	if (ACPI_SUCCESS(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Device [%02x] is now at [D%d].\n", device->handle, state));
-		device->power.state = state;
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_get_pm_capabilities
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_get_pm_capabilities (
-	BM_NODE			*node)
-{
-	acpi_status             status = AE_OK;
-	BM_DEVICE		*device = NULL;
-	BM_DEVICE		*parent_device = NULL;
-	acpi_handle             acpi_handle = NULL;
-	BM_POWER_STATE          dx_supported = ACPI_STATE_UNKNOWN;
-	char                    object_name[5] = {'_','S','0','D','\0'};
-	u32                     i = 0;
-
-	FUNCTION_TRACE("bm_get_pm_capabilities");
-
-	if (!node || !node->parent) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	device = &(node->device);
-	parent_device = &(node->parent->device);
-
-	/*
-	 * Power Management Flags:
-	 * -----------------------
-	 */
-	if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PSC",
-		&acpi_handle))) {
-		device->power.flags |= BM_FLAGS_POWER_STATE;
-	}
-
-	if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_IRC",
-		&acpi_handle))) {
-		device->power.flags |= BM_FLAGS_INRUSH_CURRENT;
-	}
-
-	if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PRW",
-		&acpi_handle))) {
-		device->power.flags |= BM_FLAGS_WAKE_CAPABLE;
-	}
-
-	/*
-	 * Device Power State:
-	 * -------------------
-	 * Note that we can't get the device's power state until we've
-	 * initialized all power resources, so for now we just set to
-	 * unknown.
-	 */
-	device->power.state = ACPI_STATE_UNKNOWN;
-
-	/*
-	 * Dx Supported in S0:
-	 * -------------------
-	 * Figure out which Dx states are supported by this device for the
-	 * S0 (working) state.  Note that D0 and D3 are required (assumed).
-	 */
-	device->power.dx_supported[ACPI_STATE_S0] = BM_FLAGS_D0_SUPPORT |
-		BM_FLAGS_D3_SUPPORT;
-
-	if ((ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PR1",
-		&acpi_handle))) ||
-		(ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PS1",
-		&acpi_handle)))) {
-		device->power.dx_supported[ACPI_STATE_S0] |=
-			BM_FLAGS_D1_SUPPORT;
-	}
-
-	if ((ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PR2",
-		&acpi_handle))) ||
-		(ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PS2",
-		&acpi_handle)))) {
-		device->power.dx_supported[ACPI_STATE_S0] |=
-			BM_FLAGS_D2_SUPPORT;
-	}
-
-	/*
-	 * Dx Supported in S1-S5:
-	 * ----------------------
-	 * Figure out which Dx states are supported by this device for
-	 * all other Sx states.
-	 */
-	for (i = ACPI_STATE_S1; i <= ACPI_STATE_S5; i++) {
-
-		/*
-		 * D3 support is assumed (off is always possible!).
-		 */
-		device->power.dx_supported[i] = BM_FLAGS_D3_SUPPORT;
-
-		/*
-		 * Evalute _Sx_d:
-		 * -------------
-		 * Which returns the highest (power) Dx state supported in
-		 * this system (Sx) state.  We convert this value to a bit
-		 * mask of supported states (conceptually simpler).
-		 */
-		status = bm_evaluate_simple_integer(device->acpi_handle,
-			object_name, &dx_supported);
-		if (ACPI_SUCCESS(status)) {
-			switch (dx_supported) {
-			case 0:
-				device->power.dx_supported[i] |=
-					BM_FLAGS_D0_SUPPORT;
-				/* fall through */
-			case 1:
-				device->power.dx_supported[i] |=
-					BM_FLAGS_D1_SUPPORT;
-				/* fall through */
-			case 2:
-				device->power.dx_supported[i] |=
-					BM_FLAGS_D2_SUPPORT;
-				/* fall through */
-			case 3:
-				device->power.dx_supported[i] |=
-					BM_FLAGS_D3_SUPPORT;
-				break;
-			}
-
-			/*
-			 * Validate:
-			 * ---------
-			 * Mask of any states that _Sx_d falsely advertises
-			 * (e.g.claims D1 support but neither _PR2 or _PS2
-			 * exist).  In other words, S1-S5 can't offer a Dx
-			 * state that isn't supported by S0.
-			 */
-			device->power.dx_supported[i] &=
-				device->power.dx_supported[ACPI_STATE_S0];
-		}
-
-		object_name[2]++;
-	}
-
-	return_ACPI_STATUS(AE_OK);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/busmgr/bmpower.c linux-2.4.22-pre2/drivers/acpi/ospm/busmgr/bmpower.c
--- linux-2.4.21/drivers/acpi/ospm/busmgr/bmpower.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/busmgr/bmpower.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,664 +0,0 @@
-/****************************************************************************
- *
- * Module Name: bmpower.c - Driver for ACPI Power Resource 'devices'
- *   $Revision: 20 $
- *
- ****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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
- */
-
-/*
- * TBD: 1. Sequencing of power resource list transitions.
- *	2. Global serialization of power resource transtions (see ACPI
- *         spec section 7.1.2/7.1.3).
- *      3. Better error handling.
- */
-
-
-#include <acpi.h>
-#include "bm.h"
-#include "bmpower.h"
-
-
-#define _COMPONENT		ACPI_BUS
-	MODULE_NAME		("bmpower")
-
-
-/****************************************************************************
- *                             Function Prototypes
- ****************************************************************************/
-
-acpi_status
-bm_pr_notify (
-	BM_NOTIFY               notify_type,
-	BM_HANDLE               device_handle,
-	void                    **context);
-	
-acpi_status
-bm_pr_request (
-	BM_REQUEST		*request,
-	void                    *context);
-
-	
-/****************************************************************************
- *                             Internal Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:    bm_pr_print
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_pr_print (
-	BM_POWER_RESOURCE	*pr)
-{
-	acpi_buffer             buffer;
-
-	PROC_NAME("bm_pr_print");
-
-	if (!pr) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	buffer.length = 256;
-	buffer.pointer = acpi_os_callocate(buffer.length);
-	if (!buffer.pointer) {
-		return(AE_NO_MEMORY);
-	}
-
-	acpi_get_name(pr->acpi_handle, ACPI_FULL_PATHNAME, &buffer);
-
-	acpi_os_printf("Power Resource: found\n");
-
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "| Power_resource[%02x]:[%p] %s\n", pr->device_handle, pr->acpi_handle, (char*)buffer.pointer));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   system_level[S%d] resource_order[%d]\n", pr->system_level, pr->resource_order));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   state[D%d] reference_count[%d]\n", pr->state, pr->reference_count));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
-
-	acpi_os_free(buffer.pointer);
-
-	return(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_pr_get_state
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_pr_get_state (
-	BM_POWER_RESOURCE	*pr)
-{
-	acpi_status             status = AE_OK;
-	BM_DEVICE_STATUS        device_status = BM_STATUS_UNKNOWN;
-
-	FUNCTION_TRACE("bm_pr_get_state");
-
-	if (!pr) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	pr->state = ACPI_STATE_UNKNOWN;
-
-	/*
-	 * Evaluate _STA:
-	 * --------------
-	 * Evalute _STA to determine whether the power resource is ON or OFF.
-	 * Note that if the power resource isn't present we'll get AE_OK but
-	 * an unknown status.
-	 */
-	status = bm_get_device_status(pr->device_handle, &device_status);
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Error reading status for power resource [%02x].\n", pr->device_handle));
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Mask off all bits but the first as some systems return non-standard
-	 * values (e.g. 0x51).
-	 */
-	switch (device_status & 0x01) {
-	case 0:
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Power resource [%02x] is OFF.\n", pr->device_handle));
-		pr->state = ACPI_STATE_D3;
-		break;
-	case 1:
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Power resource [%02x] is ON.\n", pr->device_handle));
-		pr->state = ACPI_STATE_D0;
-		break;
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_pr_set_state
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_pr_set_state (
-	BM_POWER_RESOURCE	*pr,
-	BM_POWER_STATE          target_state)
-{
-	acpi_status             status = AE_OK;
-
-	FUNCTION_TRACE("bm_pr_set_state");
-
-	if (!pr) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	status = bm_pr_get_state(pr);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	if (target_state == pr->state) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Power resource [%02x] already at target power state [D%d].\n", pr->device_handle, pr->state));
-		return_ACPI_STATUS(AE_OK);
-	}
-
-	switch (target_state) {
-
-	case ACPI_STATE_D0:
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Turning power resource [%02x] ON.\n", pr->device_handle));
-		status = bm_evaluate_object(pr->acpi_handle, "_ON", NULL, NULL);
-		break;
-
-	case ACPI_STATE_D3:
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Turning power resource [%02x] OFF.\n", pr->device_handle));
-		status = bm_evaluate_object(pr->acpi_handle, "_OFF", NULL, NULL);
-		break;
-
-	default:
-		status = AE_BAD_PARAMETER;
-		break;
-	}
-
-	status = bm_pr_get_state(pr);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_pr_list_get_state
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_pr_list_get_state (
-	BM_HANDLE_LIST          *pr_list,
-	BM_POWER_STATE          *power_state)
-{
-	acpi_status             status = AE_OK;
-	BM_POWER_RESOURCE	*pr = NULL;
-	u32                     i = 0;
-
-	FUNCTION_TRACE("bm_pr_list_get_state");
-
-	if (!pr_list || !power_state) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	if (pr_list->count < 1) {
-		pr->state = ACPI_STATE_UNKNOWN;
-		return_ACPI_STATUS(AE_ERROR);
-	}
-
-	(*power_state) = ACPI_STATE_D0;
-
-	/*
-	 * Calculate Current power_state:
-	 * -----------------------------
-	 * The current state of a list of power resources is ON if all
-	 * power resources are currently in the ON state.  In other words,
-	 * if any power resource in the list is OFF then the collection
-	 * isn't fully ON.
-	 */
-	for (i = 0; i < pr_list->count; i++) {
-
-		status = bm_get_device_context(pr_list->handles[i],
-			(BM_DRIVER_CONTEXT*)(&pr));
-		if (ACPI_FAILURE(status)) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Invalid reference to power resource [%02x].\n", pr_list->handles[i]));
-			(*power_state) = ACPI_STATE_UNKNOWN;
-			break;
-		}
-
-		status = bm_pr_get_state(pr);
-		if (ACPI_FAILURE(status)) {
-			(*power_state) = ACPI_STATE_UNKNOWN;
-			break;
-		}
-
-		if (pr->state != ACPI_STATE_D0) {
-			(*power_state) = pr->state;
-			break;
-		}
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_pr_list_transition
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_pr_list_transition (
-	BM_HANDLE_LIST          *current_list,
-	BM_HANDLE_LIST          *target_list)
-{
-	acpi_status             status = AE_OK;
-	BM_POWER_RESOURCE	*pr = NULL;
-	u32                     i = 0;
-
-	FUNCTION_TRACE("bm_pr_list_transition");
-
-	if (!current_list || !target_list) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Reference Target:
-	 * -----------------
-	 * Reference all resources for the target power state first (so
-	 * the device doesn't get turned off while transitioning).  Power
-	 * resources that aren't on (new reference count of 1) are turned on.
-	 */
-	for (i = 0; i < target_list->count; i++) {
-
-		status = bm_get_device_context(target_list->handles[i],
-			(BM_DRIVER_CONTEXT*)(&pr));
-		if (ACPI_FAILURE(status)) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Invalid reference to power resource [%02x].\n", target_list->handles[i]));
-			continue;
-		}
-
-		if (++pr->reference_count == 1) {
-			/* TBD: Need ordering based upon resource_order */
-			status = bm_pr_set_state(pr, ACPI_STATE_D0);
-			if (ACPI_FAILURE(status)) {
-				/* TBD: How do we handle this? */
-				ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Unable to change power state for power resource [%02x].\n", target_list->handles[i]));
-			}
-		}
-	}
-
-	/*
-	 * Dereference Current:
-	 * --------------------
-	 * Dereference all resources for the current power state.  Power
-	 * resources no longer referenced (new reference count of 0) are
-	 * turned off.
-	 */
-	for (i = 0; i < current_list->count; i++) {
-
-		status = bm_get_device_context(current_list->handles[i],
-			(BM_DRIVER_CONTEXT*)(&pr));
-		if (ACPI_FAILURE(status)) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Invalid reference to power resource [%02x].\n", target_list->handles[i]));
-			continue;
-		}
-
-		if (--pr->reference_count == 0) {
-			/* TBD: Need ordering based upon resource_order */
-			status = bm_pr_set_state(pr, ACPI_STATE_D3);
-			if (ACPI_FAILURE(status)) {
-				/* TBD: How do we handle this? */
-				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unable to change power state for power resource [%02x].\n", current_list->handles[i]));
-			}
-		}
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_pr_add_device
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_pr_add_device (
-	BM_HANDLE               device_handle,
-	void                    **context)
-{
-	acpi_status             status = AE_OK;
-	BM_POWER_RESOURCE	*pr = NULL;
-	BM_DEVICE		*device = NULL;
-	acpi_buffer		buffer;
-	acpi_object		acpi_object;
-
-	FUNCTION_TRACE("bm_pr_add_device");
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Adding power resource [%02x].\n", device_handle));
-
-	if (!context || *context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	buffer.length = sizeof(acpi_object);
-	buffer.pointer = &acpi_object;
-
-	/*
-	 * Get information on this device.
-	 */
-	status = bm_get_device_info(device_handle, &device);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Allocate a new BM_POWER_RESOURCE structure.
-	 */
-	pr = acpi_os_callocate(sizeof(BM_POWER_RESOURCE));
-	if (!pr) {
-		return_ACPI_STATUS(AE_NO_MEMORY);
-	}
-
-	pr->device_handle = device->handle;
-	pr->acpi_handle = device->acpi_handle;
-
-	/*
-	 * Get information on this power resource.
-	 */
-	status = acpi_evaluate_object(pr->acpi_handle, NULL, NULL, &buffer);
-	if (ACPI_FAILURE(status)) {
-		goto end;
-	}
-
-	pr->system_level = acpi_object.power_resource.system_level;
-	pr->resource_order = acpi_object.power_resource.resource_order;
-	pr->state = ACPI_STATE_UNKNOWN;
-	pr->reference_count = 0;
-
-	/*
-	 * Get the power resource's current state (ON|OFF).
-	 */
-	status = bm_pr_get_state(pr);
-
-end:
-	if (ACPI_FAILURE(status)) {
-		acpi_os_free(pr);
-	}
-	else {
-		*context = pr;
-		bm_pr_print(pr);
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_pr_remove_device
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_pr_remove_device (
-	void                    **context)
-{
-	acpi_status             status = AE_OK;
-	BM_POWER_RESOURCE	*pr = NULL;
-
-	FUNCTION_TRACE("bm_pr_remove_device");
-
-	if (!context || !*context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	pr = (BM_POWER_RESOURCE*)*context;
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing power resource [%02x].\n", pr->device_handle));
-
-	acpi_os_free(pr);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *                             External Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:    bm_pr_initialize
- *
- * PARAMETERS:  <none>
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_pr_initialize (void)
-{
-	acpi_status             status = AE_OK;
-	BM_DEVICE_ID		criteria;
-	BM_DRIVER		driver;
-
-	FUNCTION_TRACE("bm_pr_initialize");
-
-	MEMSET(&criteria, 0, sizeof(BM_DEVICE_ID));
-	MEMSET(&driver, 0, sizeof(BM_DRIVER));
-
-	criteria.type = BM_TYPE_POWER_RESOURCE;
-
-	driver.notify = &bm_pr_notify;
-	driver.request = &bm_pr_request;
-
-	status = bm_register_driver(&criteria, &driver);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_pr_terminate
- *
- * PARAMETERS:
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_pr_terminate (void)
-{
-	acpi_status             status = AE_OK;
-	BM_DEVICE_ID		criteria;
-	BM_DRIVER		driver;
-
-	FUNCTION_TRACE("bm_pr_terminate");
-
-	MEMSET(&criteria, 0, sizeof(BM_DEVICE_ID));
-	MEMSET(&driver, 0, sizeof(BM_DRIVER));
-
-	criteria.type = BM_TYPE_POWER_RESOURCE;
-
-	driver.notify = &bm_pr_notify;
-	driver.request = &bm_pr_request;
-
-	status = bm_unregister_driver(&criteria, &driver);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_pr_notify
- *
- * PARAMETERS:
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_pr_notify (
-	BM_NOTIFY               notify_type,
-	BM_HANDLE               device_handle,
-	void                    **context)
-{
-	acpi_status             status = AE_OK;
-
-	FUNCTION_TRACE("bm_pr_notify");
-
-	switch (notify_type) {
-
-	case BM_NOTIFY_DEVICE_ADDED:
-		status = bm_pr_add_device(device_handle, context);
-		break;
-
-	case BM_NOTIFY_DEVICE_REMOVED:
-		status = bm_pr_remove_device(context);
-		break;
-
-	default:
-		status = AE_SUPPORT;
-		break;
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_pr_request
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_pr_request (
-	BM_REQUEST		*request,
-	void                    *context)
-{
-	acpi_status             status = AE_OK;
-	BM_POWER_RESOURCE	*pr = NULL;
-
-	FUNCTION_TRACE("bm_pr_request");
-
-	/*
-	 * Must have a valid request structure and context.
-	 */
-	if (!request || !context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * context contains information specific to this power resource.
-	 */
-	pr = (BM_POWER_RESOURCE*)context;
-
-	/*
-	 * Handle request:
-	 * ---------------
-	 */
-	switch (request->command) {
-
-	default:
-		status = AE_SUPPORT;
-		break;
-	}
-
-	request->status = status;
-
-	return_ACPI_STATUS(status);
-}
-
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/busmgr/bmrequest.c linux-2.4.22-pre2/drivers/acpi/ospm/busmgr/bmrequest.c
--- linux-2.4.21/drivers/acpi/ospm/busmgr/bmrequest.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/busmgr/bmrequest.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,164 +0,0 @@
-/******************************************************************************
- *
- * Module Name: bmrequest.c
- *   $Revision: 16 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include <acpi.h>
-#include "bm.h"
-
-#define _COMPONENT		ACPI_BUS
-	MODULE_NAME		("bmrequest")
-
-
-/****************************************************************************
- *                            External Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:    bm_generate_request
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_generate_request (
-	BM_NODE			*node,
-	BM_REQUEST		*request)
-{
-	acpi_status             status = AE_OK;
-	BM_DEVICE		*device = NULL;
-
-	FUNCTION_TRACE("bm_generate_request");
-
-	if (!node || !request) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	device = &(node->device);
-
-	if (!BM_IS_DRIVER_CONTROL(device)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No driver installed for device [%02x].\n", device->handle));
-		return_ACPI_STATUS(AE_NOT_EXIST);
-	}
-
-	status = node->driver.request(request, node->driver.context);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_request
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_request (
-	BM_REQUEST              *request)
-{
-	acpi_status             status = AE_OK;
-	BM_NODE			*node = NULL;
-	BM_DEVICE		*device = NULL;
-
-	FUNCTION_TRACE("bm_request");
-
-	/*
-	 * Must have a valid request structure.
-	 */
-	if (!request) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Received request for device [%02x] command [%02x].\n", request->handle, request->command));
-
-	/*
-	 * Resolve the node.
-	 */
-	status = bm_get_node(request->handle, 0, &node);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	device = &(node->device);
-
-	/*
-	 * Device-Specific Request?
-	 * ------------------------
-	 * If a device-specific command (>=0x80) forward this request to
-	 * the appropriate driver.
-	 */
-	if (request->command & BM_COMMAND_DEVICE_SPECIFIC) {
-		status = bm_generate_request(node, request);
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Bus-Specific Requests:
-	 * ----------------------
-	 */
-	switch (request->command) {
-
-	case BM_COMMAND_GET_POWER_STATE:
-		status = bm_get_power_state(node);
-		if (ACPI_FAILURE(status)) {
-			break;
-		}
-		status = bm_copy_to_buffer(&(request->buffer),
-			&(device->power.state), sizeof(BM_POWER_STATE));
-		break;
-
-	case BM_COMMAND_SET_POWER_STATE:
-	 {
-		BM_POWER_STATE *power_state = NULL;
-
-		status = bm_cast_buffer(&(request->buffer),
-			(void**)&power_state, sizeof(BM_POWER_STATE));
-		if (ACPI_FAILURE(status)) {
-			break;
-		}
-		status = bm_set_power_state(node, *power_state);
-	}
-		break;
-
-	default:
-		status = AE_SUPPORT;
-		request->status = AE_SUPPORT;
-		break;
-	}
-
-	return_ACPI_STATUS(status);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/busmgr/bmsearch.c linux-2.4.22-pre2/drivers/acpi/ospm/busmgr/bmsearch.c
--- linux-2.4.21/drivers/acpi/ospm/busmgr/bmsearch.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/busmgr/bmsearch.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,192 +0,0 @@
-/******************************************************************************
- *
- * Module Name: bmsearch.c
- *   $Revision: 16 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include <acpi.h>
-#include "bm.h"
-
-
-#define _COMPONENT		ACPI_BUS
-	MODULE_NAME		("bmsearch")
-
-
-/****************************************************************************
- *                            External Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:    bm_compare
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_compare (
-	BM_DEVICE               *device,
-	BM_DEVICE_ID            *criteria)
-{
-	if (!device || !criteria) {
-		return AE_BAD_PARAMETER;
-	}
-
-	/*
-	 * Present?
-	 * --------
-	 * We're only going to match on devices that are present.
-	 * TBD: Optimize in bm_search (don't have to call here).
-	 */
-	if (!BM_DEVICE_PRESENT(device)) {
-		return AE_NOT_FOUND;
-	}
-
-	/*
-	 * Type?
-	 */
-	if (criteria->type && (criteria->type != device->id.type)) {
-		return AE_NOT_FOUND;
-	}
-
-	/*
-	 * HID?
-	 */
-	if ((criteria->hid[0]) && (0 != STRNCMP(criteria->hid,
-		device->id.hid, sizeof(BM_DEVICE_HID)))) {
-		return AE_NOT_FOUND;
-	}
-
-	/*
-	 * ADR?
-	 */
-	if ((criteria->adr) && (criteria->adr != device->id.adr)) {
-		return AE_NOT_FOUND;
-	}
-
-	return AE_OK;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_search
- *
- * PARAMETERS:
- *
- * RETURN:      AE_BAD_PARAMETER- invalid input parameter
- *              AE_NOT_EXIST    - start_device_handle doesn't exist
- *              AE_NOT_FOUND    - no matches to Search_info.criteria found
- *              AE_OK           - success
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_search(
-	BM_HANDLE               device_handle,
-	BM_DEVICE_ID            *criteria,
-	BM_HANDLE_LIST          *results)
-{
-	acpi_status             status = AE_OK;
-	BM_NODE			*node = NULL;
-
-	FUNCTION_TRACE("bm_search");
-
-	if (!criteria || !results) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	results->count = 0;
-
-	/*
-	 * Locate Starting Point:
-	 * ----------------------
-	 * Locate the node in the hierarchy where we'll begin our search.
-	 */
-	status = bm_get_node(device_handle, 0, &node);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Parse Hierarchy:
-	 * ----------------
-	 * Parse through the node hierarchy looking for matches.
-	 */
-	while (node && (results->count<=BM_HANDLES_MAX)) {
-		/*
-		 * Depth-first:
-		 * ------------
-		 * Searches are always performed depth-first.
-		 */
-		if (node->scope.head) {
-			status = bm_compare(&(node->device), criteria);
-			if (ACPI_SUCCESS(status)) {
-				results->handles[results->count++] =
-					node->device.handle;
-			}
-			node = node->scope.head;
-		}
-
-		/*
-		 * Now Breadth:
-		 * ------------
-		 * Search all peers until scope is exhausted.
-		 */
-		else {
-			status = bm_compare(&(node->device), criteria);
-			if (ACPI_SUCCESS(status)) {
-				results->handles[results->count++] =
-					node->device.handle;
-			}
-
-			/*
-			 * Locate Next Device:
-			 * -------------------
-			 * The next node is either a peer at this level
-			 * (node->next is valid), or we work are way back
-			 * up the tree until we either find a non-parsed
-			 * peer or hit the top (node->parent is NULL).
-			 */
-			while (!node->next && node->parent) {
-				node = node->parent;
-			}
-			node = node->next;
-		}
-	}
-
-	if (results->count == 0) {
-		return_ACPI_STATUS(AE_NOT_FOUND);
-	}
-	else {
-		return_ACPI_STATUS(AE_OK);
-	}
-}
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/busmgr/bmutils.c linux-2.4.22-pre2/drivers/acpi/ospm/busmgr/bmutils.c
--- linux-2.4.21/drivers/acpi/ospm/busmgr/bmutils.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/busmgr/bmutils.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,611 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: bmutils.c
- *   $Revision: 43 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include <acpi.h>
-#include "bm.h"
-
-
-#define _COMPONENT		ACPI_BUS
-	MODULE_NAME		("bmutils")
-
-
-#ifdef ACPI_DEBUG
-#define DEBUG_EVAL_ERROR(l,h,p,s)    bm_print_eval_error(l,h,p,s)
-#else
-#define DEBUG_EVAL_ERROR(l,h,p,s)
-#endif
-
-
-/****************************************************************************
- *                            External Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:    bm_print_eval_error
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-void
-bm_print_eval_error (
-	u32                     debug_level,
-	acpi_handle             handle,
-	acpi_string             pathname,
-	acpi_status             status)
-{
-	acpi_buffer		buffer;
-	acpi_status		local_status;
-
-	PROC_NAME("bm_print_eval_error");
-
-	buffer.length = 256;
-	buffer.pointer = acpi_os_callocate(buffer.length);
-	if (!buffer.pointer) {
-		return;
-	}
-
-	local_status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
-	if (ACPI_FAILURE(local_status)) {
-		ACPI_DEBUG_PRINT((ACPI_DEBUG_LEVEL(debug_level), "Evaluate object [%p], %s\n", handle,
-			acpi_format_exception(status)));
-		return;
-	}
-
-	if (pathname) {
-		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluate object [%s.%s], %s\n", (char*)buffer.pointer, pathname,
-			acpi_format_exception(status)));
-	}
-	else {
-		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluate object [%s], %s\n", (char*)buffer.pointer,
-			acpi_format_exception(status)));
-	}
-
-	acpi_os_free(buffer.pointer);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_copy_to_buffer
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_copy_to_buffer (
-	acpi_buffer             *buffer,
-	void                    *data,
-	u32                     length)
-{
-	FUNCTION_TRACE("bm_copy_to_buffer");
-
-	if (!buffer || (!buffer->pointer) || !data || (length == 0)) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	if (length > buffer->length) {
-		buffer->length = length;
-		return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
-	}
-
-	buffer->length = length;
-	MEMCPY(buffer->pointer, data, length);
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_cast_buffer
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_cast_buffer (
-	acpi_buffer             *buffer,
-	void                    **pointer,
-	u32                     length)
-{
-	FUNCTION_TRACE("bm_cast_buffer");
-
-	if (!buffer || !buffer->pointer || !pointer || length == 0) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	if (length > buffer->length) {
-		return_ACPI_STATUS(AE_BAD_DATA);
-	}
-
-	*pointer = buffer->pointer;
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_extract_package_data
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_extract_package_data (
-	acpi_object             *package,
-	acpi_buffer             *format,
-	acpi_buffer             *buffer)
-{
-	u32                     tail_offset = 0;
-	u32                     size_required = 0;
-	char			*format_string = NULL;
-	u32                     format_count = 0;
-	u32                     i = 0;
-	u8                      *head = NULL;
-	u8                      *tail = NULL;
-
-	FUNCTION_TRACE("bm_extract_package_data");
-
-	if (!package || (package->type != ACPI_TYPE_PACKAGE) || (package->package.count < 1)) {
-		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'package' argument\n"));
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	if (!format || !format->pointer || (format->length < 1)) {
-		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'format' argument\n"));
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	if (!buffer) {
-		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'buffer' argument\n"));
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	format_count = (format->length/sizeof(char)) - 1;
-	if (format_count > package->package.count) {
-		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Format specifies more objects [%d] than exist in package [%d].", format_count, package->package.count));
-		return_ACPI_STATUS(AE_BAD_DATA);
-	}
-
-	format_string = (char*)format->pointer;
-
-	/*
-	 * Calculate size_required.
-	 */
-	for (i=0; i<format_count; i++) {
-
-		acpi_object *element = &(package->package.elements[i]);
-
-		if (!element) {
-			return_ACPI_STATUS(AE_BAD_DATA);
-		}
-
-		switch (element->type) {
-
-		case ACPI_TYPE_INTEGER:
-			switch (format_string[i]) {
-			case 'N':
-				size_required += sizeof(acpi_integer);
-				tail_offset += sizeof(acpi_integer);
-				break;
-			case 'S':
-				size_required += sizeof(char*) + sizeof(acpi_integer) + sizeof(char);
-				tail_offset += sizeof(char*);
-				break;
-			default:
-				ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid package element [%d]: got number, expecing [%c].\n", i, format_string[i]));
-				return_ACPI_STATUS(AE_BAD_DATA);
-				break;
-			}
-			break;
-
-		case ACPI_TYPE_STRING:
-		case ACPI_TYPE_BUFFER:
-			switch (format_string[i]) {
-			case 'S':
-				size_required += sizeof(char*) + (element->string.length * sizeof(char)) + sizeof(char);
-				tail_offset += sizeof(char*);
-				break;
-			case 'B':
-				size_required += sizeof(u8*) + (element->buffer.length * sizeof(u8));
-				tail_offset += sizeof(u8*);
-				break;
-			default:
-				ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid package element [%d] got string/buffer, expecing [%c].\n", i, format_string[i]));
-				return_ACPI_STATUS(AE_BAD_DATA);
-				break;
-			}
-			break;
-
-		case ACPI_TYPE_PACKAGE:
-		default:
-			ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unsupported element at index=%d\n", i));
-			/* TBD: handle nested packages... */
-			return_ACPI_STATUS(AE_SUPPORT);
-			break;
-		}
-	}
-
-	/* 
-	 * Validate output buffer. 
-	 */
-	if (buffer->length < size_required) {
-		buffer->length = size_required;
-		return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
-	}
-	else if (buffer->length != size_required || !buffer->pointer) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	head = buffer->pointer;
-	tail = buffer->pointer + tail_offset;
-
-	/* 
-	 * Extract package data.
-	 */
-	for (i=0; i<format_count; i++) {
-
-		u8 **pointer = NULL;
-		acpi_object *element = &(package->package.elements[i]);
-
-		switch (element->type) {
-
-		case ACPI_TYPE_INTEGER:
-			switch (format_string[i]) {
-			case 'N':
-				*((acpi_integer*)head) = element->integer.value;
-				head += sizeof(acpi_integer);
-				break;
-			case 'S':
-				pointer = (u8**)head;
-				*pointer = tail;
-				*((acpi_integer*)tail) = element->integer.value;
-				head += sizeof(acpi_integer*);
-				tail += sizeof(acpi_integer);
-				/* NULL terminate string */
-				*tail = (char)0;
-				tail += sizeof(char);
-				break;
-			default:
-				/* Should never get here */
-				break;
-			}
-			break;
-
-		case ACPI_TYPE_STRING:
-		case ACPI_TYPE_BUFFER:
-			switch (format_string[i]) {
-			case 'S':
-				pointer = (u8**)head;
-				*pointer = tail;
-				memcpy(tail, element->string.pointer, element->string.length);
-				head += sizeof(char*);
-				tail += element->string.length * sizeof(char);
-				/* NULL terminate string */
-				*tail = (char)0;
-				tail += sizeof(char);
-				break;
-			case 'B':
-				pointer = (u8**)head;
-				*pointer = tail;
-				memcpy(tail, element->buffer.pointer, element->buffer.length);
-				head += sizeof(u8*);
-				tail += element->buffer.length * sizeof(u8);
-				break;
-			default:
-				/* Should never get here */
-				break;
-			}
-			break;
-
-		case ACPI_TYPE_PACKAGE:
-			/* TBD: handle nested packages... */
-		default:
-			/* Should never get here */
-			break;
-		}
-	}
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_evaluate_object
- *
- * PARAMETERS:
- *
- * RETURN:      AE_OK
- *              AE_BUFFER_OVERFLOW  Evaluated object returned data, but
- *                                  caller did not provide buffer.
- *
- * DESCRIPTION: Helper for acpi_evaluate_object that handles buffer
- *              allocation.  Note that the caller is responsible for
- *              freeing buffer->pointer!
- *
- ****************************************************************************/
-
-acpi_status
-bm_evaluate_object (
-	acpi_handle             handle,
-	acpi_string             pathname,
-	acpi_object_list        *arguments,
-	acpi_buffer             *buffer)
-{
-	acpi_status             status = AE_OK;
-
-	FUNCTION_TRACE("bm_evaluate_object");
-
-	/* If caller provided a buffer it must be unallocated/zero'd. */
-	if ((buffer) && (buffer->length != 0 || buffer->pointer)) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Evalute Object:
-	 * ---------------
-	 * The first attempt is just to get the size of the object data
-	 * (that is unless there's no return data, e.g. _INI); the second
-	 * gets the data.
-	 */
-	status = acpi_evaluate_object(handle, pathname, arguments, buffer);
-	if (ACPI_SUCCESS(status)) {
-		return_ACPI_STATUS(status);
-	}
-	else if ((buffer) && (status == AE_BUFFER_OVERFLOW)) {
-
-		/* Gotta allocate -- CALLER MUST FREE! */
-		buffer->pointer = acpi_os_callocate(buffer->length);
-		if (!buffer->pointer) {
-			return_ACPI_STATUS(AE_NO_MEMORY);
-		}
-
-		/* Re-evaluate -- this time it should work */
-		status = acpi_evaluate_object(handle, pathname,
-			arguments, buffer);
-	}
-
-	if (ACPI_FAILURE(status)) {
-		if (status != AE_NOT_FOUND) {
-			DEBUG_EVAL_ERROR(ACPI_LV_WARN, handle, pathname,
-				status);
-		}
-		if (buffer && buffer->pointer) {
-			acpi_os_free(buffer->pointer);
-			buffer->pointer = NULL;
-			buffer->length = 0;
-		}
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_evaluate_simple_integer
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bm_evaluate_simple_integer (
-	acpi_handle             handle,
-	acpi_string             pathname,
-	u32                     *data)
-{
-	acpi_status             status = AE_OK;
-	acpi_object             *element = NULL;
-	acpi_buffer             buffer;
-
-	FUNCTION_TRACE("bm_evaluate_simple_integer");
-
-	if (!data) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	MEMSET(&buffer, 0, sizeof(acpi_buffer));
-
-	/*
-	 * Evaluate Object:
-	 * ----------------
-	 */
-	status = bm_evaluate_object(handle, pathname, NULL, &buffer);
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "failed to evaluate object (%s)\n",
-			acpi_format_exception(status)));
-		goto end;
-	}
-
-	/*
-	 * Validate Data:
-	 * --------------
-	 */
-	status = bm_cast_buffer(&buffer, (void**)&element,
-		sizeof(acpi_object));
-	if (ACPI_FAILURE(status)) {
-		DEBUG_EVAL_ERROR(ACPI_LV_WARN, handle, pathname, status);
-		goto end;
-	}
-
-	if (element->type != ACPI_TYPE_INTEGER) {
-		status = AE_BAD_DATA;
-		DEBUG_EVAL_ERROR(ACPI_LV_WARN, handle, pathname, status);
-		goto end;
-	}
-
-	*data = element->integer.value;
-
-end:
-	acpi_os_free(buffer.pointer);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bm_evaluate_reference_list
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status  
-bm_evaluate_reference_list (
-	acpi_handle             handle,
-	acpi_string             pathname,
-	BM_HANDLE_LIST          *reference_list)
-{
-	acpi_status             status = AE_OK;
-	acpi_object             *package = NULL;
-	acpi_object             *element = NULL;
-	acpi_handle  		reference_handle = NULL;
-	acpi_buffer             buffer;
-	u32                     i = 0;
-
-	FUNCTION_TRACE("bm_evaluate_reference_list");
-
-	if (!reference_list) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	MEMSET(&buffer, 0, sizeof(acpi_buffer));
-
-	/*
-	 * Evaluate Object:
-	 * ----------------
-	 */
-	status = bm_evaluate_object(handle, pathname, NULL, &buffer);
-	if (ACPI_FAILURE(status)) {
-		goto end;
-	}
-
-	/*
-	 * Validate Package:
-	 * -----------------
-	 */
-	status = bm_cast_buffer(&buffer, (void**)&package,
-		sizeof(acpi_object));
-	if (ACPI_FAILURE(status)) {
-		DEBUG_EVAL_ERROR(ACPI_LV_WARN, handle, pathname, status);
-		goto end;
-	}
-
-	if (package->type != ACPI_TYPE_PACKAGE) {
-		status = AE_BAD_DATA;
-		DEBUG_EVAL_ERROR(ACPI_LV_WARN, handle, pathname, status);
-		goto end;
-	}
-
-	if (package->package.count > BM_HANDLES_MAX) {
-		package->package.count = BM_HANDLES_MAX;
-	}
-
-	/*
-	 * Parse Package Data:
-	 * -------------------
-	 */
-	for (i = 0; i < package->package.count; i++) {
-
-		element = &(package->package.elements[i]);
-
-		if (!element || (element->type != ACPI_TYPE_STRING)) {
-			status = AE_BAD_DATA;
-			ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid element in package (not a device reference).\n"));
-			DEBUG_EVAL_ERROR (ACPI_LV_WARN, handle, pathname, status);
-			break;
-		}
-
-		/*
-		 * Resolve reference string (e.g. "\_PR_.CPU_") to an
-		 * acpi_handle.
-		 */
-		status = acpi_get_handle(handle,
-			element->string.pointer, &reference_handle);
-		if (ACPI_FAILURE(status)) {
-			status = AE_BAD_DATA;
-			ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Unable to resolve device reference [%s].\n", element->string.pointer));
-			DEBUG_EVAL_ERROR (ACPI_LV_WARN, handle, pathname, status);
-			break;
-		}
-
-		/*
-		 * Resolve acpi_handle to BM_HANDLE.
-		 */
-		status = bm_get_handle(reference_handle,
-			&(reference_list->handles[i]));
-		if (ACPI_FAILURE(status)) {
-			status = AE_BAD_DATA;
-			ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Unable to resolve device reference for [%p].\n", reference_handle));
-			DEBUG_EVAL_ERROR (ACPI_LV_WARN, handle, pathname, status);
-			break;
-		}
-
-		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resolved reference [%s]->[%p]->[%02x]\n", element->string.pointer, reference_handle, reference_list->handles[i]));
-
-		(reference_list->count)++;
-	}
-
-end:
-	acpi_os_free(buffer.pointer);
-
-	return_ACPI_STATUS(status);
-}
-
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/button/Makefile linux-2.4.22-pre2/drivers/acpi/ospm/button/Makefile
--- linux-2.4.21/drivers/acpi/ospm/button/Makefile	2001-06-21 00:47:40.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/button/Makefile	1970-01-01 00:00:00.000000000 +0000
@@ -1,6 +0,0 @@
-O_TARGET	:= ospm_$(notdir $(CURDIR)).o
-obj-m		:= $(O_TARGET)
-EXTRA_CFLAGS	+= $(ACPI_CFLAGS)
-obj-y		:= $(patsubst %.c,%.o,$(wildcard *.c))
-
-include $(TOPDIR)/Rules.make
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/button/bn.c linux-2.4.22-pre2/drivers/acpi/ospm/button/bn.c
--- linux-2.4.21/drivers/acpi/ospm/button/bn.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/button/bn.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,507 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: bn.c
- *   $Revision: 27 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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 Plxxe, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include <acpi.h>
-#include "bn.h"
-
-
-#define _COMPONENT		ACPI_BUTTON
-	MODULE_NAME		("bn")
-
-
-/*****************************************************************************
- *                            Internal Functions
- *****************************************************************************/
-
-/*****************************************************************************
- *
- * FUNCTION:	bn_print
- *
- * PARAMETERS:	
- *
- * RETURN:	
- *
- * DESCRIPTION: Prints out information on a specific button.
- *
- ****************************************************************************/
-
-void
-bn_print (
-	BN_CONTEXT		*button)
-{
-#ifdef ACPI_DEBUG
-	acpi_buffer		buffer;
-
-	PROC_NAME("bn_print");
-
-	if (!button) {
-		return;
-	}
-
-	buffer.length = 256;
-	buffer.pointer = acpi_os_callocate(buffer.length);
-	if (!buffer.pointer) {
-		return;
-	}
-
-	/*
-	 * Get the full pathname for this ACPI object.
-	 */
-	acpi_get_name(button->acpi_handle, ACPI_FULL_PATHNAME, &buffer);
-
-	/*
-	 * Print out basic button information.
-	 */
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
-
-	switch (button->type) {
-
-	case BN_TYPE_POWER_BUTTON:
-	case BN_TYPE_POWER_BUTTON_FIXED:
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "| Power_button[%02x]:[%p] %s\n", button->device_handle, button->acpi_handle, (char*)buffer.pointer));
-		break;
-
-	case BN_TYPE_SLEEP_BUTTON:
-	case BN_TYPE_SLEEP_BUTTON_FIXED:
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "| Sleep_button[%02x]:[%p] %s\n", button->device_handle, button->acpi_handle, (char*)buffer.pointer));
-		break;
-
-	case BN_TYPE_LID_SWITCH:
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "| Lid_switch[%02x]:[%p] %s\n", button->device_handle, button->acpi_handle, (char*)buffer.pointer));
-		break;
-	}
-
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
-
-	acpi_os_free(buffer.pointer);
-#endif /*ACPI_DEBUG*/
-
-	return;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	bn_add_device
- *
- * PARAMETERS:	
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bn_add_device(
-	BM_HANDLE		device_handle,
-	void			**context)
-{
-	acpi_status		status = AE_OK;
-	BM_DEVICE		*device = NULL;
-	BN_CONTEXT		*button = NULL;
-
-	FUNCTION_TRACE("bn_add_device");
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Adding button device [%02x].\n", device_handle));
-
-	if (!context || *context) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid context.\n"));
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Get information on this device.
-	 */
-	status = bm_get_device_info( device_handle, &device );
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Allocate a new BN_CONTEXT structure.
-	 */
-	button = acpi_os_callocate(sizeof(BN_CONTEXT));
-	if (!button) {
-		return_ACPI_STATUS(AE_NO_MEMORY);
-	}
-
-	button->device_handle = device->handle;
-	button->acpi_handle = device->acpi_handle;
-
-	/*
-	 * Power Button?
-	 * -------------
-	 * Either fixed-feature or generic (namespace) types.
-	 */
-	if (strncmp(device->id.hid, BN_HID_POWER_BUTTON,
-		sizeof(BM_DEVICE_HID)) == 0) {
-
-		if (device->id.type == BM_TYPE_FIXED_BUTTON) {
-
-			button->type = BN_TYPE_POWER_BUTTON_FIXED;
-
-			/* Register for fixed-feature events. */
-			status = acpi_install_fixed_event_handler(
-				ACPI_EVENT_POWER_BUTTON, bn_notify_fixed,
-				(void*)button);
-		}
-		else {
-			button->type = BN_TYPE_POWER_BUTTON;
-		}
-
-	}
-
-	/*
-	 * Sleep Button?
-	 * -------------
-	 * Either fixed-feature or generic (namespace) types.
-	 */
-	else if (strncmp( device->id.hid, BN_HID_SLEEP_BUTTON,
-		sizeof(BM_DEVICE_HID)) == 0) {
-
-		if (device->id.type == BM_TYPE_FIXED_BUTTON) {
-
-			button->type = BN_TYPE_SLEEP_BUTTON_FIXED;
-
-			/* Register for fixed-feature events. */
-			status = acpi_install_fixed_event_handler(
-				ACPI_EVENT_SLEEP_BUTTON, bn_notify_fixed,
-				(void*)button);
-		}
-		else {
-			button->type = BN_TYPE_SLEEP_BUTTON;
-		}
-	}
-
-	/*
-	 * LID Switch?
-	 * -----------
-	 */
-	else if (strncmp( device->id.hid, BN_HID_LID_SWITCH,
-		sizeof(BM_DEVICE_HID)) == 0) {
-		button->type = BN_TYPE_LID_SWITCH;
-	}
-
-	status = bn_osl_add_device(button);
-	if (ACPI_FAILURE(status)) {
-		goto end;
-	}
-
-	*context = button;
-
-	bn_print(button);
-
-end:
-	if (ACPI_FAILURE(status)) {
-		acpi_os_free(button);
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	bn_remove_device
- *
- * PARAMETERS:	
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bn_remove_device(
-	void			**context)
-{
-	acpi_status		status = AE_OK;
-	BN_CONTEXT		*button = NULL;
-
-	FUNCTION_TRACE("bn_remove_device");
-
-	if (!context || !*context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	button = (BN_CONTEXT*)*context;
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing button device [%02x].\n", button->device_handle));
-
-	/*
-	 * Unregister for fixed-feature events.
-	 */
-	switch (button->type) {
-	case BN_TYPE_POWER_BUTTON_FIXED:
-		status = acpi_remove_fixed_event_handler(
-			ACPI_EVENT_POWER_BUTTON, bn_notify_fixed);
-		break;
-	case BN_TYPE_SLEEP_BUTTON_FIXED:
-		status = acpi_remove_fixed_event_handler(
-			ACPI_EVENT_SLEEP_BUTTON, bn_notify_fixed);
-		break;
-	}
-
-	bn_osl_remove_device(button);
-
-	acpi_os_free(button);
-
-	*context = NULL;
-
-	return_ACPI_STATUS(status);
-}
-
-
-/*****************************************************************************
- *			      External Functions
- *****************************************************************************/
-
-/*****************************************************************************
- *
- * FUNCTION:	bn_initialize
- *
- * PARAMETERS:	<none>
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
-
- ****************************************************************************/
-
-acpi_status
-bn_initialize (void)
-{
-	BM_DEVICE_ID		criteria;
-	BM_DRIVER		driver;
-
-	FUNCTION_TRACE("bn_initialize");
-
-	MEMSET(&criteria, 0, sizeof(BM_DEVICE_ID));
-	MEMSET(&driver, 0, sizeof(BM_DRIVER));
-
-	driver.notify = &bn_notify;
-	driver.request = &bn_request;
-
-	/*
-	 * Register for power buttons.
-	 */
-	MEMCPY(criteria.hid, BN_HID_POWER_BUTTON, sizeof(BN_HID_POWER_BUTTON));
-	bm_register_driver(&criteria, &driver);
-
-	/*
-	 * Register for sleep buttons.
-	 */
-	MEMCPY(criteria.hid, BN_HID_SLEEP_BUTTON, sizeof(BN_HID_SLEEP_BUTTON));
-	bm_register_driver(&criteria, &driver);
-
-	/*
-	 * Register for LID switches.
-	 */
-	MEMCPY(criteria.hid, BN_HID_LID_SWITCH, sizeof(BN_HID_LID_SWITCH));
-	bm_register_driver(&criteria, &driver);
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	bn_terminate
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bn_terminate (void)
-{
-	acpi_status		status = AE_OK;
-	BM_DEVICE_ID		criteria;
-	BM_DRIVER		driver;
-
-	FUNCTION_TRACE("bn_terminate");
-
-	MEMSET(&criteria, 0, sizeof(BM_DEVICE_ID));
-	MEMSET(&driver, 0, sizeof(BM_DRIVER));
-
-	driver.notify = &bn_notify;
-	driver.request = &bn_request;
-
-	/*
-	 * Unregister for power buttons.
-	 */
-	MEMCPY(criteria.hid, BN_HID_POWER_BUTTON, sizeof(BN_HID_POWER_BUTTON));
-	status = bm_unregister_driver(&criteria, &driver);
-
-	/*
-	 * Unregister for sleep buttons.
-	 */
-	MEMCPY(criteria.hid, BN_HID_SLEEP_BUTTON, sizeof(BN_HID_SLEEP_BUTTON));
-	status = bm_unregister_driver(&criteria, &driver);
-
-	/*
-	 * Unregister for LID switches.
-	 */
-	MEMCPY(criteria.hid, BN_HID_LID_SWITCH, sizeof(BN_HID_LID_SWITCH));
-	status = bm_unregister_driver(&criteria, &driver);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	bn_notify_fixed
- *
- * PARAMETERS:	<none>
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bn_notify_fixed (
-	void			*context)
-{
-	acpi_status		status = AE_OK;
-
-	FUNCTION_TRACE("bn_notify_fixed");
-
-	if (!context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status change event detected.\n"));
-
-	status = bn_osl_generate_event(BN_NOTIFY_STATUS_CHANGE,
-		((BN_CONTEXT*)context));
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	bn_notify
- *
- * PARAMETERS:	<none>
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bn_notify (
-	BM_NOTIFY		notify_type,
-	BM_HANDLE		device_handle,
-	void			**context)
-{
-	acpi_status		status = AE_OK;
-
-	FUNCTION_TRACE("bn_notify");
-
-	if (!context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	switch (notify_type) {
-	case BM_NOTIFY_DEVICE_ADDED:
-		status = bn_add_device(device_handle, context);
-		break;
-		
-	case BM_NOTIFY_DEVICE_REMOVED:
-		status = bn_remove_device(context);
-		break;
-		
-	case BN_NOTIFY_STATUS_CHANGE:
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status change event detected.\n"));
-		status = bn_osl_generate_event(BN_NOTIFY_STATUS_CHANGE,
-			((BN_CONTEXT*)*context));
-		break;
-
-	default:
-		status = AE_SUPPORT;
-		break;
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	bn_request
- *
- * PARAMETERS:	
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-bn_request (
-	BM_REQUEST		*request,
-	void			*context)
-{
-	acpi_status		status = AE_OK;
-
-	FUNCTION_TRACE("bn_request");
-
-	/*
-	 * Must have a valid request structure and context.
-	 */
-	if (!request || !context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Handle Request:
-	 * ---------------
-	 */
-	switch (request->command) {
-
-	default:
-		status = AE_SUPPORT;
-		break;
-	}
-
-	request->status = status;
-
-	return_ACPI_STATUS(status);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/button/bn_osl.c linux-2.4.22-pre2/drivers/acpi/ospm/button/bn_osl.c
--- linux-2.4.21/drivers/acpi/ospm/button/bn_osl.c	2001-12-21 17:41:53.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/button/bn_osl.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,311 +0,0 @@
-/******************************************************************************
- *
- * Module Name: bn_osl.c
- *   $Revision: 16 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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/proc_fs.h>
-#include <acpi.h>
-#include "bn.h"
-
-
-MODULE_AUTHOR("Andrew Grover");
-MODULE_DESCRIPTION("ACPI Component Architecture (CA) - Button Driver");
-MODULE_LICENSE("GPL");
-
-
-#define BN_PROC_ROOT		"button"
-#define BN_PROC_POWER_BUTTON	"power"
-#define BN_PROC_SLEEP_BUTTON	"sleep"
-#define BN_PROC_LID_SWITCH	"lid"
-
-extern struct proc_dir_entry	*bm_proc_root;
-static struct proc_dir_entry	*bn_proc_root = NULL;
-
-
-#define BN_TYPE_UNKNOWN		0
-#define BN_TYPE_FIXED		1
-#define BN_TYPE_GENERIC		2
-
-static int bn_power_button = BN_TYPE_UNKNOWN;
-static int bn_sleep_button = BN_TYPE_UNKNOWN;
-static int bn_lid_switch = BN_TYPE_UNKNOWN;
-
-
-/****************************************************************************
- *
- * FUNCTION:	bn_osl_add_device
- *
- ****************************************************************************/
-
-acpi_status
-bn_osl_add_device(
-	BN_CONTEXT		*button)
-{
-	acpi_status		status = AE_OK;
-
-	if (!button) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	switch (button->type) {
-
-	case BN_TYPE_POWER_BUTTON_FIXED:
-		bn_power_button = BN_TYPE_FIXED;
-		printk(KERN_INFO "ACPI: Power Button (FF) found\n");
-		if (!proc_mkdir(BN_PROC_POWER_BUTTON, bn_proc_root)) {
-			status = AE_ERROR;
-		}
-		break;
-
-	case BN_TYPE_POWER_BUTTON:
-		/* 
-		 * Avoid creating multiple /proc entries when (buggy) ACPI
-		 * BIOS tables erroneously list both fixed- and generic-
-		 * feature buttons.  Note that fixed-feature buttons are 
-		 * always enumerated first (and there can only be one) so
-		 * we only need to check here.
-		 */
-		switch (bn_power_button) {
-		case BN_TYPE_GENERIC:
-			printk(KERN_WARNING "ACPI: Multiple generic-space power buttons detected, using first\n");
-			break;
-		case BN_TYPE_FIXED:
-			printk(KERN_WARNING "ACPI: Multiple power buttons detected, ignoring fixed-feature\n");
-		default:
-			printk(KERN_INFO "ACPI: Power Button (CM) found\n");
-			bn_power_button = BN_TYPE_GENERIC;
-			if (!proc_mkdir(BN_PROC_POWER_BUTTON, bn_proc_root)) {
-				status = AE_ERROR;
-			}
-			break;
-		}
-		break;
-
-	case BN_TYPE_SLEEP_BUTTON_FIXED:
-		bn_sleep_button = BN_TYPE_FIXED;
-		printk(KERN_INFO "ACPI: Sleep Button (FF) found\n");
-		if (!proc_mkdir(BN_PROC_SLEEP_BUTTON, bn_proc_root)) {
-			status = AE_ERROR;
-		}
-		break;
-
-	case BN_TYPE_SLEEP_BUTTON:
-		/* 
-		 * Avoid creating multiple /proc entries when (buggy) ACPI
-		 * BIOS tables erroneously list both fixed- and generic-
-		 * feature buttons.  Note that fixed-feature buttons are 
-		 * always enumerated first (and there can only be one) so
-		 * we only need to check here.
-		 */
-		switch (bn_sleep_button) {
-		case BN_TYPE_GENERIC:
-			printk(KERN_WARNING "ACPI: Multiple generic-space sleep buttons detected, using first\n");
-			break;
-		case BN_TYPE_FIXED:
-			printk(KERN_WARNING "ACPI: Multiple sleep buttons detected, ignoring fixed-feature\n");
-		default:
-			bn_sleep_button = BN_TYPE_GENERIC;
-			printk(KERN_INFO "ACPI: Sleep Button (CM) found\n");
-			if (!proc_mkdir(BN_PROC_SLEEP_BUTTON, bn_proc_root)) {
-				status = AE_ERROR;
-			}
-			break;
-		}
-		break;
-
-	case BN_TYPE_LID_SWITCH:
-		if (bn_lid_switch) {
-			printk(KERN_WARNING "ACPI: Multiple generic-space lid switches detected, using first\n");
-			break;
-		}
-		bn_lid_switch = BN_TYPE_GENERIC;
-		printk(KERN_INFO "ACPI: Lid Switch (CM) found\n");
-		if (!proc_mkdir(BN_PROC_LID_SWITCH, bn_proc_root)) {
-			status = AE_ERROR;
-		}
-		break;
-	}
-
-	return(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	bn_osl_remove_device
- *
- ****************************************************************************/
-
-acpi_status
-bn_osl_remove_device (
-	BN_CONTEXT		*button)
-{
-	if (!button) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	switch (button->type) {
-
-	case BN_TYPE_POWER_BUTTON:
-	case BN_TYPE_POWER_BUTTON_FIXED:
-		remove_proc_entry(BN_PROC_POWER_BUTTON, bn_proc_root);
-		break;
-
-	case BN_TYPE_SLEEP_BUTTON:
-	case BN_TYPE_SLEEP_BUTTON_FIXED:
-		remove_proc_entry(BN_PROC_SLEEP_BUTTON, bn_proc_root);
-		break;
-
-	case BN_TYPE_LID_SWITCH:
-		remove_proc_entry(BN_PROC_LID_SWITCH, bn_proc_root);
-		break;
-	}
-
-	return(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	bn_osl_generate_event
- *
- ****************************************************************************/
-
-acpi_status
-bn_osl_generate_event (
-	u32			event,
-	BN_CONTEXT		*button)
-{
-	acpi_status		status = AE_OK;
-
-	if (!button) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	switch (event) {
-
-	case BN_NOTIFY_STATUS_CHANGE:
-
-		switch(button->type) {
-
-		case BN_TYPE_POWER_BUTTON:
-		case BN_TYPE_POWER_BUTTON_FIXED:
-			status = bm_osl_generate_event(button->device_handle,
-				BN_PROC_ROOT, BN_PROC_POWER_BUTTON, event, 0);
-			break;
-
-		case BN_TYPE_SLEEP_BUTTON:
-		case BN_TYPE_SLEEP_BUTTON_FIXED:
-			status = bm_osl_generate_event(button->device_handle,
-				BN_PROC_ROOT, BN_PROC_SLEEP_BUTTON, event, 0);
-			break;
-
-		case BN_TYPE_LID_SWITCH:
-			status = bm_osl_generate_event(button->device_handle,
-				BN_PROC_ROOT, BN_PROC_LID_SWITCH, event, 0);
-			break;
-
-		default:
-			status = AE_SUPPORT;
-			break;
-		}
-
-		break;
-
-	default:
-		return(AE_BAD_PARAMETER);
-		break;
-	}
-
-	return(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bn_osl_init
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	0: Success
- *
- * DESCRIPTION: Module initialization.
- *
- ****************************************************************************/
-
-static int __init
-bn_osl_init (void)
-{
-	acpi_status		status = AE_OK;
-
-	/* abort if no busmgr */
-	if (!bm_proc_root)
-		return -ENODEV;
-
-	bn_proc_root = proc_mkdir(BN_PROC_ROOT, bm_proc_root);
-	if (!bn_proc_root) {
-		status = AE_ERROR;
-	}
-	else {
-		status = bn_initialize();
-		if (ACPI_FAILURE(status)) {
-			remove_proc_entry(BN_PROC_ROOT, bm_proc_root);
-		}
-	}
-
-	return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    bn_osl_cleanup
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	<none>
- *
- * DESCRIPTION: Module cleanup.
- *
- ****************************************************************************/
-
-static void __exit
-bn_osl_cleanup (void)
-{
-	bn_terminate();
-
-	if (bn_proc_root) {
-		remove_proc_entry(BN_PROC_ROOT, bm_proc_root);
-	}
-
-	return;
-}
-
-
-module_init(bn_osl_init);
-module_exit(bn_osl_cleanup);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/ec/Makefile linux-2.4.22-pre2/drivers/acpi/ospm/ec/Makefile
--- linux-2.4.21/drivers/acpi/ospm/ec/Makefile	2001-06-21 00:47:40.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/ec/Makefile	1970-01-01 00:00:00.000000000 +0000
@@ -1,6 +0,0 @@
-O_TARGET	:= ospm_$(notdir $(CURDIR)).o
-obj-m		:= $(O_TARGET)
-EXTRA_CFLAGS	+= $(ACPI_CFLAGS)
-obj-y		:= $(patsubst %.c,%.o,$(wildcard *.c))
-
-include $(TOPDIR)/Rules.make
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/ec/ec_osl.c linux-2.4.22-pre2/drivers/acpi/ospm/ec/ec_osl.c
--- linux-2.4.21/drivers/acpi/ospm/ec/ec_osl.c	2001-12-21 17:41:53.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/ec/ec_osl.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,91 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: ec_osl.c
- *   $Revision: 11 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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/proc_fs.h>
-#include <acpi.h>
-#include <bm.h>
-#include "ec.h"
-
-
-MODULE_AUTHOR("Andrew Grover");
-MODULE_DESCRIPTION("ACPI Component Architecture (CA) - Embedded Controller Driver");
-MODULE_LICENSE("GPL");
-
-extern struct proc_dir_entry	*bm_proc_root;
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_osl_init
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	0: Success
- *
- * DESCRIPTION: Module initialization.
- *
- ****************************************************************************/
-
-static int __init
-ec_osl_init (void)
-{
-	acpi_status		status = AE_OK;
-
-	/* abort if no busmgr */
-	if (!bm_proc_root)
-		return -ENODEV;
-
-	status = ec_initialize();
-
-	return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
-}
-
-/****************************************************************************
- *
- * FUNCTION:    ec_osl_cleanup
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	<none>
- *
- * DESCRIPTION: Module cleanup.
- *
- ****************************************************************************/
-
-static void __exit
-ec_osl_cleanup(void)
-{
-	ec_terminate();
-
-	return;
-}
-
-module_init(ec_osl_init);
-module_exit(ec_osl_cleanup);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/ec/ecgpe.c linux-2.4.22-pre2/drivers/acpi/ospm/ec/ecgpe.c
--- linux-2.4.21/drivers/acpi/ospm/ec/ecgpe.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/ec/ecgpe.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,249 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: ecgpe.c
- *   $Revision: 28 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include <acpi.h>
-#include "ec.h"
-
-#define _COMPONENT		ACPI_EC
-	MODULE_NAME		("ecgpe")
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_query_handler
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-void
-ec_query_handler (
-	void                    *context)
-{
-	EC_CONTEXT		*ec = (EC_CONTEXT*)context;
-	static char		object_name[5] = {'_','Q','0','0','\0'};
-	const char		hex[] = {'0','1','2','3','4','5','6','7','8',
-					'9','A','B','C','D','E','F'};
-
-	FUNCTION_TRACE("ec_query_handler");
-
-	if (!ec) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid (NULL) context.\n"));
-		return_VOID;
-	}
-
-	/*
-	 * Evaluate _Qxx:
-	 * --------------
-	 * Evaluate corresponding _Qxx method.  Note that a zero query value
-	 * indicates a spurious EC_SCI (no such thing as _Q00).
-	 */
-	object_name[2] = hex[((ec->query_data >> 4) & 0x0F)];
-	object_name[3] = hex[(ec->query_data & 0x0F)];
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Evaluating [%s] for ec [%02x].\n", object_name, ec->device_handle));
-
-	bm_evaluate_object(ec->acpi_handle, object_name, NULL, NULL);
-
-	return_VOID;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_gpe_handler
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-void
-ec_gpe_handler (
-	void                    *context)
-{
-	acpi_status             status = AE_OK;
-	EC_CONTEXT              *ec = (EC_CONTEXT*)context;
-	EC_STATUS               ec_status = 0;
-
-	FUNCTION_TRACE("ec_gpe_handler");
-
-	if (!ec) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid (NULL) context.\n"));
-		return_VOID;
-	}
-
-	/* TBD: synchronize w/ transaction (ectransx). */
-
-	/*
-	 * EC_SCI?
-	 * -------
-	 * Check the EC_SCI bit to see if this is an EC_SCI event.  If not (e.g.
-	 * OBF/IBE) just return, as we already poll to detect these events.
-	 */
-	acpi_os_read_port(ec->status_port, &ec_status, 8);
-	if (!(ec_status & EC_FLAG_SCI)) {
-		return_VOID;
-	}
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "EC_SCI event detected on ec [%02x] - running query.\n", ec->device_handle));
-
-	/*
-	 * Run Query:
-	 * ----------
-	 * Query the EC to find out which _Qxx method we need to evaluate.
-	 * Note that successful completion of the query causes the EC_SCI
-	 * bit to be cleared (and thus clearing the interrupt source).
-	 */
-	status = ec_io_write(ec, ec->command_port, EC_COMMAND_QUERY,
-		EC_EVENT_OUTPUT_BUFFER_FULL);
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Unable to send 'query command' to EC.\n"));
-		return_VOID;
-	}
-
-	status = ec_io_read(ec, ec->data_port, &(ec->query_data),
-		EC_EVENT_NONE);
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Error reading query data.\n"));
-		return_VOID;
-	}
-
-	/* TBD: un-synchronize w/ transaction (ectransx). */
-
-	/*
-	 * Spurious EC_SCI?
-	 * ----------------
-	 */
-	if (!ec->query_data) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Spurious EC SCI detected.\n"));
-		return_VOID;
-	}
-
-	/*
-	 * Defer _Qxx Execution:
-	 * ---------------------
-	 * Can't evaluate this method now 'cause we're at interrupt-level.
-	 */
-	status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
-		ec_query_handler, ec);
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Unable to defer _Qxx method evaluation.\n"));
-		return_VOID;
-	}
-
-	return_VOID;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_install_gpe_handler
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ec_install_gpe_handler (
-	EC_CONTEXT              *ec)
-{
-	acpi_status             status = AE_OK;
-
-	FUNCTION_TRACE("ec_install_gpe_handler");
-
-	if (!ec) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Evaluate _GPE:
-	 * --------------
-	 * Evaluate the "_GPE" object (required) to find out which GPE bit
-	 * is used by this EC to signal events (SCIs).
-	 */
-	status = bm_evaluate_simple_integer(ec->acpi_handle,
-		"_GPE", &(ec->gpe_bit));
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Install GPE Handler:
-	 * --------------------
-	 * Install a handler for this EC's GPE bit.
-	 */
-	status = acpi_install_gpe_handler(ec->gpe_bit, ACPI_EVENT_EDGE_TRIGGERED,
-		&ec_gpe_handler, ec);
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "acpi_install_gpe_handler() failed for GPE bit [%02x] with status [%08x].\n", ec->gpe_bit, status));
-		ec->gpe_bit = EC_GPE_UNKNOWN;
-		return_ACPI_STATUS(status);
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_remove_gpe_handler
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ec_remove_gpe_handler (
-	EC_CONTEXT              *ec)
-{
-	acpi_status             status = AE_OK;
-
-	FUNCTION_TRACE("ec_remove_gpe_handler");
-
-	if (!ec) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	status = acpi_remove_gpe_handler(ec->gpe_bit, &ec_gpe_handler);
-
-	return_ACPI_STATUS(status);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/ec/ecmain.c linux-2.4.22-pre2/drivers/acpi/ospm/ec/ecmain.c
--- linux-2.4.21/drivers/acpi/ospm/ec/ecmain.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/ec/ecmain.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,498 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: ecmain.c
- *   $Revision: 29 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include <acpi.h>
-#include "ec.h"
-
-#define _COMPONENT		ACPI_EC
-	MODULE_NAME		("ecmain")
-
-
-/****************************************************************************
- *                            Internal Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:    ec_print
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION: Prints out information on a specific ec.
- *
- ****************************************************************************/
-
-void
-ec_print (
-	EC_CONTEXT              *ec)
-{
-#ifdef ACPI_DEBUG
-	acpi_buffer             buffer;
-#endif /*ACPI_DEBUG*/
-
-	PROC_NAME("ec_print");
-
-	if (!ec) {
-		return;
-	}
-
-	acpi_os_printf("EC: found, GPE %d\n", ec->gpe_bit);
-
-#ifdef ACPI_DEBUG
-	buffer.length = 256;
-	buffer.pointer = acpi_os_callocate(buffer.length);
-	if (!buffer.pointer) {
-		return;
-	}
-
-	/*
-	 * Get the full pathname for this ACPI object.
-	 */
-	acpi_get_name(ec->acpi_handle, ACPI_FULL_PATHNAME, &buffer);
-
-	/*
-	 * Print out basic thermal zone information.
-	 */
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "| Embedded_controller[%02x]:[%p] %s\n", ec->device_handle, ec->acpi_handle, (char*)buffer.pointer));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   gpe_bit[%02x] status/command_port[%02x] data_port[%02x]\n", ec->gpe_bit, ec->status_port, ec->data_port));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
-
-	acpi_os_free(buffer.pointer);
-#endif /*ACPI_DEBUG*/
-
-	return;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_get_port_values
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION: Evaluate _CRS to get the current resources (I/O port
- *              addresses) for this EC.
- *
- ****************************************************************************/
-
-acpi_status
-ec_get_port_values(
-	EC_CONTEXT              *ec)
-{
-	acpi_status             status = AE_OK;
-	acpi_buffer             buffer;
-	acpi_resource           *resource = NULL;
-
-	FUNCTION_TRACE("ec_get_port_values");
-
-	if (!ec) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	buffer.length = 0;
-	buffer.pointer = NULL;
-
-	status = acpi_get_current_resources(ec->acpi_handle, &buffer);
-	if (status != AE_BUFFER_OVERFLOW) {
-		return_ACPI_STATUS(status);
-	}
-
-	buffer.pointer = acpi_os_callocate(buffer.length);
-	if (!buffer.pointer) {
-		return_ACPI_STATUS(AE_NO_MEMORY);
-	}
-
-	status = acpi_get_current_resources(ec->acpi_handle, &buffer);
-	if (ACPI_FAILURE(status)) {
-		goto end;
-	}
-
-	resource = (acpi_resource *) buffer.pointer;
-	ec->data_port = resource->data.io.min_base_address;
-
-	resource = NEXT_RESOURCE(resource);
-
-	ec->status_port = ec->command_port =
-		resource->data.io.min_base_address;
-end:
-	acpi_os_free(buffer.pointer);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_add_device
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ec_add_device(
-	BM_HANDLE               device_handle,
-	void                    **context)
-{
-	acpi_status             status = AE_OK;
-	BM_DEVICE		*device = NULL;
-	EC_CONTEXT              *ec = NULL;
-	u8                      gpe_handler = FALSE;
-	u8                      space_handler = FALSE;
-
-	FUNCTION_TRACE("ec_add_device");
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Adding EC device [%02x].\n", device_handle));
-
-	if (!context || *context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Get information on this device.
-	 */
-	status = bm_get_device_info(device_handle, &device);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Allocate a new EC_CONTEXT structure.
-	 */
-	ec = acpi_os_callocate(sizeof(EC_CONTEXT));
-	if (!ec) {
-		return_ACPI_STATUS(AE_NO_MEMORY);
-	}
-
-	ec->device_handle = device->handle;
-	ec->acpi_handle = device->acpi_handle;
-
-	/*
-	 * Get the I/O port addresses for the command/status and data ports.
-	 */
-	status = ec_get_port_values(ec);
-	if (ACPI_FAILURE(status)) {
-		goto end;
-	}
-
-	/*
-	 * See if we need to obtain the global lock for EC transactions.
-	 */
-	status = bm_evaluate_simple_integer(ec->acpi_handle, "_GLK",
-		&ec->use_global_lock);
-	if (status == AE_NOT_FOUND) {
-		ec->use_global_lock = 0;
-	}
-	else if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "EC _GLK failed\n"));
-		goto end;
-	}
-
-	/*
-	 * Install a handler for servicing this EC's GPE.
-	 */
-	status = ec_install_gpe_handler(ec);
-	if (ACPI_FAILURE(status)) {
-		goto end;
-	}
-	else {
-		gpe_handler = TRUE;
-	}
-
-	/*
-	 * Install a handler for servicing this EC's address space.
-	 */
-	status = ec_install_space_handler(ec);
-	if (ACPI_FAILURE(status)) {
-		goto end;
-	}
-	else {
-		space_handler = TRUE;
-	}
-
-	/*
-	 * Create a semaphore to serialize EC transactions.
-	 */
-	status = acpi_os_create_semaphore(1,1, &(ec->mutex));
-	if (ACPI_FAILURE(status)) {
-		goto end;
-	}
-
-	/*
-	 * Context now contains information specific to this EC.  Note
-	 * that we'll get this pointer back on every ec_request() and
-	 * ec_notify().
-	 */
-	*context = ec;
-
-	ec_print(ec);
-
-end:
-	if (ACPI_FAILURE(status)) {
-
-		if (gpe_handler) {
-			ec_remove_gpe_handler(ec);
-		}
-
-		if (space_handler) {
-			ec_remove_space_handler(ec);
-		}
-
-		if (ec->mutex) {
-			acpi_os_delete_semaphore(ec->mutex);
-		}
-
-		acpi_os_free(ec);
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_remove_device
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ec_remove_device(
-	void                    **context)
-{
-	acpi_status             status = AE_OK;
-	EC_CONTEXT              *ec = NULL;
-
-	FUNCTION_TRACE("ec_remove_device");
-
-	if (!context || !*context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	ec = (EC_CONTEXT*)*context;
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing EC device [%02x].\n", ec->device_handle));
-
-	ec_remove_space_handler(ec);
-
-	ec_remove_gpe_handler(ec);
-
-	if (ec->mutex) {
-		acpi_os_delete_semaphore(ec->mutex);
-	}
-
-	acpi_os_free(ec);
-
-	*context = NULL;
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *                             External Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:    ec_initialize
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ec_initialize (void)
-{
-	acpi_status             status = AE_OK;
-	BM_DEVICE_ID		criteria;
-	BM_DRIVER		driver;
-
-	FUNCTION_TRACE("ec_initialize");
-
-	MEMSET(&criteria, 0, sizeof(BM_DEVICE_ID));
-	MEMSET(&driver, 0, sizeof(BM_DRIVER));
-
-	/*
-	 * Register driver for AC Adapter devices.
-	 */
-	MEMCPY(criteria.hid, EC_HID_EC, sizeof(EC_HID_EC));
-
-	driver.notify = &ec_notify;
-	driver.request = &ec_request;
-
-	status = bm_register_driver(&criteria, &driver);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_terminate
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ec_terminate(void)
-{
-	acpi_status             status = AE_OK;
-	BM_DEVICE_ID		criteria;
-	BM_DRIVER		driver;
-
-	FUNCTION_TRACE("ec_terminate");
-
-	MEMSET(&criteria, 0, sizeof(BM_DEVICE_ID));
-	MEMSET(&driver, 0, sizeof(BM_DRIVER));
-
-	/*
-	 * Unregister driver for AC Adapter devices.
-	 */
-	MEMCPY(criteria.hid, EC_HID_EC, sizeof(EC_HID_EC));
-
-	driver.notify = &ec_notify;
-	driver.request = &ec_request;
-
-	status = bm_unregister_driver(&criteria, &driver);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_notify
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ec_notify (
-	BM_NOTIFY               notify,
-	BM_HANDLE               device_handle,
-	void                    **context)
-{
-	acpi_status             status = AE_OK;
-
-	FUNCTION_TRACE("ec_notify");
-
-	switch (notify) {
-
-	case BM_NOTIFY_DEVICE_ADDED:
-		status = ec_add_device(device_handle, context);
-		break;
-
-	case BM_NOTIFY_DEVICE_REMOVED:
-		status = ec_remove_device(context);
-		break;
-
-	default:
-		status = AE_SUPPORT;
-		break;
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_request
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ec_request (
-	BM_REQUEST              *request,
-	void                    *context)
-{
-	acpi_status             status = AE_OK;
-	EC_REQUEST              *ec_request = NULL;
-	EC_CONTEXT              *ec = NULL;
-
-	FUNCTION_TRACE("ec_request");
-
-	/*
-	 * Must have a valid request structure and context.
-	 */
-	if (!request || !context)
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-
-	/*
-	 * buffer must contain a valid EC_REQUEST structure.
-	 */
-	status = bm_cast_buffer(&(request->buffer), (void**)&ec_request,
-		sizeof(EC_REQUEST));
-	if (ACPI_FAILURE(status))
-		return_ACPI_STATUS(status);
-
-	/*
-	 * context contains information specific to this EC.
-	 */
-	ec = (EC_CONTEXT*)context;
-
-	/*
-	 * Perform the Transaction.
-	 */
-	status = ec_transaction(ec, ec_request);
-
-	return_ACPI_STATUS(status);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/ec/ecspace.c linux-2.4.22-pre2/drivers/acpi/ospm/ec/ecspace.c
--- linux-2.4.21/drivers/acpi/ospm/ec/ecspace.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/ec/ecspace.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,192 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: ecspace.c
- *   $Revision: 23 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include <acpi.h>
-#include "ec.h"
-
-#define _COMPONENT		ACPI_EC
-	MODULE_NAME		("ecspace")
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_space_setup
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ec_space_setup (
-	acpi_handle		region_handle,
-	u32			function,
-	void			*handler_context,
-	void			**return_context)
-{
-	/*
-	 * The EC object is in the handler context and is needed
-	 * when calling the ec_space_handler.
-	 */
-	*return_context = handler_context;
-
-	return AE_OK;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_space_handler
- *
- * PARAMETERS:  function            - Read or Write operation
- *              address             - Where in the space to read or write
- *              bit_width           - Field width in bits (should be 8)
- *              value               - Pointer to in or out value
- *              context             - context pointer
- *
- * RETURN:
- *
- * DESCRIPTION: Handler for the Embedded Controller (EC) address space
- *              (Op Region)
- *
- ****************************************************************************/
-
-acpi_status
-ec_space_handler (
-	u32                     function,
-	ACPI_PHYSICAL_ADDRESS   address,
-	u32                     bit_width,
-	u32                     *value,
-	void                    *handler_context,
-	void                    *region_context)
-{
-	acpi_status             status = AE_OK;
-	EC_CONTEXT              *ec = NULL;
-	EC_REQUEST              ec_request;
-
-	FUNCTION_TRACE("ec_space_handler");
-
-	if (address > 0xFF || bit_width != 8 || !value || !handler_context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	ec = (EC_CONTEXT*)handler_context;
-
-	switch (function) {
-
-	case ACPI_READ_ADR_SPACE:
-		ec_request.command = EC_COMMAND_READ;
-		ec_request.address = address;
-		ec_request.data = 0;
-		break;
-
-	case ACPI_WRITE_ADR_SPACE:
-		ec_request.command = EC_COMMAND_WRITE;
-		ec_request.address = address;
-		ec_request.data = (u8)(*value);
-		break;
-
-	default:
-		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Received request with invalid function [%X].\n", function));
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-		break;
-	}
-
-	/*
-	 * Perform the Transaction.
-	 */
-	status = ec_transaction(ec, &ec_request);
-	if (ACPI_SUCCESS(status)) {
-		(*value) = (u32)ec_request.data;
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_install_space_handler
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ec_install_space_handler (
-	EC_CONTEXT              *ec)
-{
-	acpi_status             status = AE_OK;
-
-	FUNCTION_TRACE("ec_install_space_handler");
-
-	if (!ec) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	status = acpi_install_address_space_handler (ec->acpi_handle,
-		ACPI_ADR_SPACE_EC, &ec_space_handler, &ec_space_setup, ec);
-	
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_remove_space_handler
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ec_remove_space_handler (
-	EC_CONTEXT              *ec)
-{
-	acpi_status             status = AE_OK;
-
-	FUNCTION_TRACE("ec_remove_space_handler");
-
-	if (!ec) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	status = acpi_remove_address_space_handler(ec->acpi_handle,
-		ACPI_ADR_SPACE_EC, &ec_space_handler);
-
-	return_ACPI_STATUS(status);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/ec/ectransx.c linux-2.4.22-pre2/drivers/acpi/ospm/ec/ectransx.c
--- linux-2.4.21/drivers/acpi/ospm/ec/ectransx.c	2002-11-28 23:53:12.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/ec/ectransx.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,343 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: ectransx.c
- *   $Revision: 24 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include <acpi.h>
-#include "ec.h"
-
-#define _COMPONENT		ACPI_EC
-	MODULE_NAME             ("ectransx")
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_io_wait
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ec_io_wait (
-	EC_CONTEXT              *ec,
-	EC_EVENT                wait_event)
-{
-	EC_STATUS               ec_status = 0;
-	u32                     i = 100;
-
-	if (!ec || ((wait_event != EC_EVENT_OUTPUT_BUFFER_FULL)
-		&& (wait_event != EC_EVENT_INPUT_BUFFER_EMPTY))) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Wait for Event:
-	 * ---------------
-	 * Poll the EC status register waiting for the event to occur.
-	 * Note that we'll wait a maximum of 1ms in 10us chunks.
-	 */
-	switch (wait_event) {
-
-	case EC_EVENT_OUTPUT_BUFFER_FULL:
-		do {
-			acpi_os_read_port(ec->status_port, &ec_status, 8);
-			if (ec_status & EC_FLAG_OUTPUT_BUFFER) {
-				return(AE_OK);
-			}
-			acpi_os_stall(10);
-		} while (--i>0);
-		break;
-
-	case EC_EVENT_INPUT_BUFFER_EMPTY:
-		do {
-			acpi_os_read_port(ec->status_port, &ec_status, 8);
-			if (!(ec_status & EC_FLAG_INPUT_BUFFER)) {
-				return(AE_OK);
-			}
-			acpi_os_stall(10);
-		} while (--i>0);
-		break;
-	}
-
-	return(AE_TIME);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_io_read
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ec_io_read (
-	EC_CONTEXT              *ec,
-	u32		        io_port,
-	u8                      *data,
-	EC_EVENT                wait_event)
-{
-	acpi_status             status = AE_OK;
-
-	if (!ec || !data) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	acpi_os_read_port(io_port, (u32*) data, 8);
-
-	if (wait_event) {
-		status = ec_io_wait(ec, wait_event);
-	}
-
-	return(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_io_write
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ec_io_write (
-	EC_CONTEXT              *ec,
-	u32		       io_port,
-	u8                      data,
-	EC_EVENT                wait_event)
-{
-	acpi_status             status = AE_OK;
-
-	if (!ec) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	acpi_os_write_port(io_port, data, 8);
-
-	if (wait_event) {
-		status = ec_io_wait(ec, wait_event);
-	}
-
-	return(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_read
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ec_read (
-	EC_CONTEXT              *ec,
-	u8                      address,
-	u8                      *data)
-{
-	acpi_status             status = AE_OK;
-
-	FUNCTION_TRACE("ec_read");
-
-	if (!ec || !data) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	if (ec->use_global_lock) {
-		status = acpi_acquire_global_lock();
-		if (ACPI_FAILURE(status)) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Could not acquire Global Lock\n"));
-			return_ACPI_STATUS(status);
-		}
-	}
-
-	status = ec_io_write(ec, ec->command_port, EC_COMMAND_READ,
-		EC_EVENT_INPUT_BUFFER_EMPTY);
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Unable to send 'read command' to EC.\n"));
-		return_ACPI_STATUS(status);
-	}
-
-	status = ec_io_write(ec, ec->data_port, address,
-		EC_EVENT_OUTPUT_BUFFER_FULL);
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Unable to send 'read address' to EC.\n"));
-		return_ACPI_STATUS(status);
-	}
-
-	status = ec_io_read(ec, ec->data_port, data, EC_EVENT_NONE);
-
-	if (ec->use_global_lock) {
-		acpi_release_global_lock();
-	}
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Read data [%02x] from address [%02x] on ec [%02x].\n", (*data), address, ec->device_handle));
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_write
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ec_write (
-	EC_CONTEXT              *ec,
-	u8                      address,
-	u8                      data)
-{
-	acpi_status             status = AE_OK;
-
-	FUNCTION_TRACE("ec_write");
-
-	if (!ec)
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-
-	if (ec->use_global_lock) {
-		status = acpi_acquire_global_lock();
-		if (ACPI_FAILURE(status)) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Could not acquire Global Lock\n"));
-			return_ACPI_STATUS(status);
-		}
-	}
-
-	status = ec_io_write(ec, ec->command_port, EC_COMMAND_WRITE,
-		EC_EVENT_INPUT_BUFFER_EMPTY);
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Unable to send 'write command' to EC.\n"));
-		return_ACPI_STATUS(status);
-	}
-
-	status = ec_io_write(ec, ec->data_port, address,
-		EC_EVENT_INPUT_BUFFER_EMPTY);
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Unable to send 'write address' to EC.\n"));
-		return_ACPI_STATUS(status);
-	}
-
-	status = ec_io_write(ec, ec->data_port, data,
-		EC_EVENT_INPUT_BUFFER_EMPTY);
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Unable to send 'write data' to EC.\n"));
-		return_ACPI_STATUS(status);
-	}
-
-	if (ec->use_global_lock) {
-		acpi_release_global_lock();
-	}
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Wrote data [%02x] to address [%02x] on ec [%02x].\n", data, address, ec->device_handle));
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    ec_transaction
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-ec_transaction (
-	EC_CONTEXT              *ec,
-	EC_REQUEST              *request)
-{
-	acpi_status             status = AE_OK;
-
-	FUNCTION_TRACE("ec_transaction");
-
-	if (!ec || !request) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Obtain mutex to serialize all EC transactions.
-	 */
-	status = acpi_os_wait_semaphore(ec->mutex, 1, EC_DEFAULT_TIMEOUT);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Perform the transaction.
-	 */
-	switch (request->command) {
-
-	case EC_COMMAND_READ:
-		status = ec_read(ec, request->address, &(request->data));
-		break;
-
-	case EC_COMMAND_WRITE:
-		status = ec_write(ec, request->address, request->data);
-		break;
-
-	default:
-		status = AE_SUPPORT;
-		break;
-	}
-
-	/*
-	 * Signal the mutex to indicate transaction completion.
-	 */
-	acpi_os_signal_semaphore(ec->mutex, 1);
-
-	return_ACPI_STATUS(status);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/include/ac.h linux-2.4.22-pre2/drivers/acpi/ospm/include/ac.h
--- linux-2.4.21/drivers/acpi/ospm/include/ac.h	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/include/ac.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,102 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: ac.h
- *   $Revision: 6 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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 __AC_H__
-#define __AC_H__
-
-#include <actypes.h>
-#include <acexcep.h>
-#include <bm.h>
-
-
-/*****************************************************************************
- *                            Types & Other Defines
- *****************************************************************************/
-
-/*
- * Notifications:
- * --------------
- */
-#define AC_NOTIFY_STATUS_CHANGE	((BM_NOTIFY) 0x80)
-
-/*
- * Hardware IDs:
- * -------------
- */
-#define AC_HID_AC_ADAPTER	"ACPI0003"
-
-
-/*
- * Device Context:
- * ---------------
- */
-typedef struct
-{
-	BM_HANDLE		device_handle;
-	acpi_handle		acpi_handle;
-	char			uid[9];
-	u32 			is_online;
-} AC_CONTEXT;
-
-
-/*****************************************************************************
- *                              Function Prototypes
- *****************************************************************************/
-
-acpi_status
-ac_initialize (void);
-
-acpi_status
-ac_terminate (void);
-
-acpi_status
-ac_notify (
-	u32			notify_type,
-	u32 			device,
-	void			**context);
-
-acpi_status
-ac_request(
-	BM_REQUEST		*request_info,
-	void			*context);
-
-/* AC Adapter Driver OSL */
-
-acpi_status
-ac_osl_add_device (
-	AC_CONTEXT		*ac_adapter);
-
-acpi_status
-ac_osl_remove_device (
-	AC_CONTEXT		*ac_adapter);
-
-acpi_status
-ac_osl_generate_event (
-	u32			event,
-	AC_CONTEXT		*ac_adapter);
-
-
-#endif	/* __AC_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/include/bm.h linux-2.4.22-pre2/drivers/acpi/ospm/include/bm.h
--- linux-2.4.21/drivers/acpi/ospm/include/bm.h	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/include/bm.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,583 +0,0 @@
-/*****************************************************************************
- *
- * Module name: bm.h
- *   $Revision: 41 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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 __BM_H__
-#define __BM_H__
-
-#include <actypes.h>
-#include <acexcep.h>
-
-
-/*****************************************************************************
- *                               Types & Defines
- *****************************************************************************/
-
-/*
- * Output Flags (Debug):
- * ---------------------
- */
-#define BM_PRINT_ALL		(0x00000000)
-#define BM_PRINT_GROUP		(0x00000001)
-#define BM_PRINT_LINKAGE	(0x00000002)
-#define BM_PRINT_IDENTIFICATION	(0x00000004)
-#define BM_PRINT_POWER		(0x00000008)
-#define BM_PRINT_PRESENT	(0x00000010)
-
-
-/*
- * BM_COMMAND:
- * -----------
- */
-typedef u32			BM_COMMAND;
-
-#define BM_COMMAND_UNKNOWN	((BM_COMMAND) 0x00)
-
-#define BM_COMMAND_GET_POWER_STATE ((BM_COMMAND) 0x01)
-#define BM_COMMAND_SET_POWER_STATE ((BM_COMMAND) 0x02)
-
-#define BM_COMMAND_DEVICE_SPECIFIC ((BM_COMMAND) 0x80)
-
-/*
- * BM_NOTIFY:
- * ----------
- * Standard ACPI notification values, from section 5.6.3 of the ACPI 2.0
- * specification.  Note that the Bus Manager internally handles all
- * standard ACPI notifications -- driver modules are never sent these
- * values (see "Bus Manager Notifications", below).
- */
-typedef u32			BM_NOTIFY;
-
-#define BM_NOTIFY_BUS_CHECK	((BM_NOTIFY) 0x00)
-#define BM_NOTIFY_DEVICE_CHECK	((BM_NOTIFY) 0x01)
-#define BM_NOTIFY_DEVICE_WAKE	((BM_NOTIFY) 0x02)
-#define BM_NOTIFY_EJECT_REQUEST	((BM_NOTIFY) 0x03)
-#define BM_NOTIFY_DEVICE_CHECK_LIGHT ((BM_NOTIFY) 0x04)
-#define BM_NOTIFY_FREQUENCY_MISMATCH ((BM_NOTIFY) 0x05)
-#define BM_NOTIFY_BUS_MODE_MISMATCH ((BM_NOTIFY) 0x06)
-#define BM_NOTIFY_POWER_FAULT	((BM_NOTIFY) 0x07)
-
-/*
- * These are a higher-level abstraction of ACPI notifications, intended
- * for consumption by driver modules to facilitate Pn_p.
- */
-#define BM_NOTIFY_UNKNOWN	((BM_NOTIFY) 0x00)
-#define BM_NOTIFY_DEVICE_ADDED	((BM_NOTIFY) 0x01)
-#define BM_NOTIFY_DEVICE_REMOVED ((BM_NOTIFY) 0x02)
-
-
-/*
- * BM_HANDLE:
- * ----------
- */
-typedef u32			BM_HANDLE;
-
-#define BM_HANDLE_ROOT		((BM_HANDLE) 0x00000000)
-#define BM_HANDLE_UNKNOWN	((BM_HANDLE) 0xFFFFFFFF)
-#define BM_HANDLES_MAX		100
-
-
-/*
- * BM_HANDLE_LIST:
- * ---------------
- */
-typedef struct
-{
-	u32			count;
-	BM_HANDLE		handles[BM_HANDLES_MAX];
-} BM_HANDLE_LIST;
-
-
-/*
- * BM_DEVICE_TYPE:
- * ---------------
- */
-typedef u32			BM_DEVICE_TYPE;
-
-#define BM_TYPE_UNKNOWN		((BM_DEVICE_TYPE) 0x00000000)
-
-#define BM_TYPE_SYSTEM		((BM_DEVICE_TYPE) 0x00000001)
-#define BM_TYPE_SCOPE		((BM_DEVICE_TYPE) 0x00000002)
-#define BM_TYPE_PROCESSOR	((BM_DEVICE_TYPE) 0x00000003)
-#define BM_TYPE_THERMAL_ZONE	((BM_DEVICE_TYPE) 0x00000004)
-#define BM_TYPE_POWER_RESOURCE	((BM_DEVICE_TYPE) 0x00000005)
-#define BM_TYPE_DEVICE		((BM_DEVICE_TYPE) 0x00000006)
-#define BM_TYPE_FIXED_BUTTON	((BM_DEVICE_TYPE) 0x00000007)
-
-
-/*
- * BM_DEVICE_UID:
- * --------------
- */
-typedef char			BM_DEVICE_UID[9];
-
-#define BM_UID_UNKNOWN		'0'
-
-
-/*
- * BM_DEVICE_HID:
- * --------------
- */
-typedef char			BM_DEVICE_HID[9];
-
-#define BM_HID_UNKNOWN		'\0'
-#define BM_HID_POWER_BUTTON	"PNP0C0C"
-#define BM_HID_SLEEP_BUTTON	"PNP0C0E"
-
-/*
- * BM_DEVICE_ADR:
- * --------------
- */
-typedef u32			BM_DEVICE_ADR;
-
-#define BM_ADDRESS_UNKNOWN	0
-
-
-/*
- * BM_DEVICE_FLAGS:
- * ----------------
- * The encoding of BM_DEVICE_FLAGS is illustrated below.
- * Note that a set bit (1) indicates the property is TRUE
- * (e.g. if bit 0 is set then the device has dynamic status).
- * +--+------------+-+-+-+-+-+-+-+
- * |31| Bits 30:7  |6|5|4|3|2|1|0|
- * +--+------------+-+-+-+-+-+-+-+
- *   |       |      | | | | | | |
- *   |       |      | | | | | | +- Dynamic status?
- *   |       |      | | | | | +--- Identifiable?
- *   |       |      | | | | +----- Configurable?
- *   |       |      | | | +------- Power Control?
- *   |       |      | | +--------- Ejectable?
- *   |       |      | +----------- Docking Station?
- *   |       |      +------------- Fixed-Feature?
- *   |       +-------------------- <Reserved>
- *   +---------------------------- Driver Control?
- *
- * Dynamic status:  Device has a _STA object.
- * Identifiable:    Device has a _HID and/or _ADR and possibly other
- *                  identification objects defined.
- * Configurable:    Device has a _CRS and possibly other configuration
- *                  objects defined.
- * Power Control:   Device has a _PR0 and/or _PS0 and possibly other
- *                  power management objects defined.
- * Ejectable:       Device has an _EJD and/or _EJx and possibly other
- *                  dynamic insertion/removal objects defined.
- * Docking Station: Device has a _DCK object defined.
- * Fixed-Feature:   Device does not exist in the namespace; was
- *                  enumerated as a fixed-feature (e.g. power button).
- * Driver Control:  A driver has been installed for this device.
- */
-typedef u32			BM_DEVICE_FLAGS;
-
-#define BM_FLAGS_UNKNOWN	((BM_DEVICE_FLAGS) 0x00000000)
-
-#define BM_FLAGS_DYNAMIC_STATUS	((BM_DEVICE_FLAGS) 0x00000001)
-#define BM_FLAGS_IDENTIFIABLE	((BM_DEVICE_FLAGS) 0x00000002)
-#define BM_FLAGS_CONFIGURABLE	((BM_DEVICE_FLAGS) 0x00000004)
-#define BM_FLAGS_POWER_CONTROL	((BM_DEVICE_FLAGS) 0x00000008)
-#define BM_FLAGS_EJECTABLE	((BM_DEVICE_FLAGS) 0x00000010)
-#define BM_FLAGS_DOCKING_STATION ((BM_DEVICE_FLAGS) 0x00000020)
-#define BM_FLAGS_FIXED_FEATURE	((BM_DEVICE_FLAGS) 0x00000040)
-#define BM_FLAGS_DRIVER_CONTROL	((BM_DEVICE_FLAGS) 0x80000000)
-
-
-/*
- * Device PM Flags:
- * ----------------
- * +-----------+-+-+-+-+-+-+-+
- * | Bits 31:7 |6|5|4|3|2|1|0|
- * +-----------+-+-+-+-+-+-+-+
- *       |      | | | | | | |
- *       |      | | | | | | +- D0 Support?
- *       |      | | | | | +--- D1 Support?
- *       |      | | | | +----- D2 Support?
- *       |      | | | +------- D3 Support?
- *       |      | | +--------- Power State Queriable?
- *       |      | +----------- Inrush Current?
- *       |      +------------- Wake Capable?
- *       +-------------------- <Reserved>
- *
- * D0-D3 Support:   Device supports corresponding Dx state.
- * Power State:     Device has a _PSC (current power state) object defined.
- * Inrush Current:  Device has an _IRC (inrush current) object defined.
- * Wake Capable:    Device has a _PRW (wake-capable) object defined.
- */
-#define BM_FLAGS_D0_SUPPORT	((BM_DEVICE_FLAGS) 0x00000001)
-#define BM_FLAGS_D1_SUPPORT	((BM_DEVICE_FLAGS) 0x00000002)
-#define BM_FLAGS_D2_SUPPORT	((BM_DEVICE_FLAGS) 0x00000004)
-#define BM_FLAGS_D3_SUPPORT	((BM_DEVICE_FLAGS) 0x00000008)
-#define BM_FLAGS_POWER_STATE	((BM_DEVICE_FLAGS) 0x00000010)
-#define BM_FLAGS_INRUSH_CURRENT	((BM_DEVICE_FLAGS) 0x00000020)
-#define BM_FLAGS_WAKE_CAPABLE	((BM_DEVICE_FLAGS) 0x00000040)
-
-
-/*
- * BM_DEVICE_STATUS:
- * -----------------
- * The encoding of BM_DEVICE_STATUS is illustrated below.
- * Note that a set bit (1) indicates the property is TRUE
- * (e.g. if bit 0 is set then the device is present).
- * +-----------+-+-+-+-+-+
- * | Bits 31:4 |4|3|2|1|0|
- * +-----------+-+-+-+-+-+
- *       |      | | | | |
- *       |      | | | | +- Present?
- *       |      | | | +--- Enabled?
- *       |      | | +----- Show in UI?
- *       |      | +------- Functioning?
- *       |      +--------- Battery Present?
- *       +---------------- <Reserved>
- */
-typedef u32			BM_DEVICE_STATUS;
-
-#define BM_STATUS_UNKNOWN	((BM_DEVICE_STATUS) 0x00000000)
-#define BM_STATUS_PRESENT	((BM_DEVICE_STATUS) 0x00000001)
-#define BM_STATUS_ENABLED	((BM_DEVICE_STATUS) 0x00000002)
-#define BM_STATUS_SHOW_UI	((BM_DEVICE_STATUS) 0x00000004)
-#define BM_STATUS_FUNCTIONING	((BM_DEVICE_STATUS) 0x00000008)
-#define BM_STATUS_BATTERY_PRESENT ((BM_DEVICE_STATUS) 0x00000010)
-#define BM_STATUS_DEFAULT	((BM_DEVICE_STATUS) 0x0000000F)
-
-
-/*
- * BM_POWER_STATE:
- * ---------------
- */
-typedef u32			BM_POWER_STATE;
-
-
-/*
- * BM_DEVICE_ID:
- * -------------
- */
-typedef struct
-{
-	BM_DEVICE_TYPE		type;
-	BM_DEVICE_UID		uid;
-	BM_DEVICE_HID		hid;
-	BM_DEVICE_ADR		adr;
-} BM_DEVICE_ID;
-
-
-/*
- * BM_DEVICE_POWER:
- * ----------------
- * Structure containing basic device power management information.
- */
-typedef struct
-{
-	BM_DEVICE_FLAGS		flags;
-	BM_POWER_STATE		state;
-	BM_DEVICE_FLAGS		dx_supported[ACPI_S_STATE_COUNT];
-} BM_DEVICE_POWER;
-
-
-/*
- * BM_DEVICE:
- * ----------
- */
-typedef struct
-{
-	BM_HANDLE		handle;
-	acpi_handle  		acpi_handle;
-	BM_DEVICE_FLAGS		flags;
-	BM_DEVICE_STATUS	status;
-	BM_DEVICE_ID		id;
-	BM_DEVICE_POWER		power;
-} BM_DEVICE;
-
-
-/*
- * BM_SEARCH:
- * ----------
- * Structure used for searching the ACPI Bus Manager's device hierarchy.
- */
-typedef struct
-{
-	BM_DEVICE_ID		criteria;
-	BM_HANDLE_LIST		results;
-} BM_SEARCH;
-
-
-/*
- * BM_REQUEST:
- * -----------
- * Structure used for sending requests to/through the ACPI Bus Manager.
- */
-typedef struct
-{
-	acpi_status		status;
-	BM_COMMAND		command;
-	BM_HANDLE		handle;
-	acpi_buffer		buffer;
-} BM_REQUEST;
-
-
-/*
- * Driver Registration:
- * --------------------
- */
-
-/* Driver Context */
-typedef void *			BM_DRIVER_CONTEXT;
-
-/* Notification Callback Function */
-typedef
-acpi_status (*BM_DRIVER_NOTIFY) (
-	BM_NOTIFY		notify_type,
-	BM_HANDLE		device_handle,
-	BM_DRIVER_CONTEXT	*context);
-
-/* Request Callback Function */
-typedef
-acpi_status (*BM_DRIVER_REQUEST) (
-	BM_REQUEST		*request,
-	BM_DRIVER_CONTEXT	context);
-
-/* Driver Registration */
-typedef struct
-{
-	BM_DRIVER_NOTIFY	notify;
-	BM_DRIVER_REQUEST	request;
-	BM_DRIVER_CONTEXT	context;
-} BM_DRIVER;
-
-
-/*
- * BM_NODE:
- * --------
- * Structure used to maintain the device hierarchy.
- */
-typedef struct _BM_NODE
-{
-	BM_DEVICE		device;
-	BM_DRIVER		driver;
-	struct _BM_NODE		*parent;
-	struct _BM_NODE		*next;
-	struct
-	{
-		struct _BM_NODE		*head;
-		struct _BM_NODE		*tail;
-	}			scope;
-} BM_NODE;
-
-
-/*
- * BM_NODE_LIST:
- * -------------
- * Structure used to maintain an array of node pointers.
- */
-typedef struct
-{
-	u32			count;
-	BM_NODE			*nodes[BM_HANDLES_MAX];
-} BM_NODE_LIST;
-
-
-/*****************************************************************************
- *                                  Macros
- *****************************************************************************/
-
-/*
- * Device Presence:
- * ----------------
- * Note that status (_STA) means something different for power resources
- * (they're assumed to always be present).
- */
-#define BM_DEVICE_PRESENT(d)	((d->id.type!=BM_TYPE_POWER_RESOURCE)?(d->status & BM_STATUS_PRESENT):TRUE)
-#define BM_NODE_PRESENT(n)	((n->device.id.type!=BM_TYPE_POWER_RESOURCE)?(n->device.status & BM_STATUS_PRESENT):TRUE)
-
-/*
- * Device Flags:
- * -------------
- */
-#define BM_IS_DRIVER_CONTROL(d)	(d->flags & BM_FLAGS_DRIVER_CONTROL)
-#define BM_IS_POWER_CONTROL(d)	(d->flags & BM_FLAGS_POWER_CONTROL)
-
- /*
- * Device Power Flags:
- * -------------------
- */
-#define BM_IS_POWER_STATE(d)	(d->power.flags & BM_FLAGS_POWER_STATE)
-
-/*****************************************************************************
- *                             Function Prototypes
- *****************************************************************************/
-
-/* bm.c */
-
-acpi_status
-bm_initialize (void);
-
-acpi_status
-bm_terminate (void);
-
-acpi_status
-bm_get_status (
-	BM_DEVICE		*device);
-
-acpi_status
-bm_get_handle (
-	acpi_handle             acpi_handle,
-	BM_HANDLE               *device_handle);
-
-acpi_status
-bm_get_node (
-	BM_HANDLE               device_handle,
-	acpi_handle             acpi_handle,
-	BM_NODE			**node);
-
-/* bmsearch.c */
-
-acpi_status
-bm_search(
-	BM_HANDLE               device_handle,
-	BM_DEVICE_ID            *criteria,
-	BM_HANDLE_LIST          *results);
-
-/* bmnotify.c */
-
-void
-bm_notify (
-	acpi_handle             acpi_handle,
-	u32                     notify_value,
-	void                    *context);
-
-/* bm_request.c */
-
-acpi_status
-bm_request (
-	BM_REQUEST		*request_info);
-
-/* bmdriver.c */
-
-acpi_status
-bm_get_device_power_state (
-	BM_HANDLE               device_handle,
-	BM_POWER_STATE		*state);
-
-acpi_status
-bm_set_device_power_state (
-	BM_HANDLE               device_handle,
-	BM_POWER_STATE		state);
-
-acpi_status
-bm_get_device_status (
-	BM_HANDLE               device_handle,
-	BM_DEVICE_STATUS        *device_status);
-
-acpi_status
-bm_get_device_info (
-	BM_HANDLE               device_handle,
-	BM_DEVICE		**device_info);
-
-acpi_status
-bm_get_device_context (
-	BM_HANDLE               device_handle,
-	BM_DRIVER_CONTEXT	*context);
-
-acpi_status
-bm_register_driver (
-	BM_DEVICE_ID		*criteria,
-	BM_DRIVER		*driver);
-
-acpi_status
-bm_unregister_driver (
-	BM_DEVICE_ID		*criteria,
-	BM_DRIVER		*driver);
-
-/* bmpm.c */
-
-acpi_status
-bm_get_pm_capabilities (
-	BM_NODE			*node);
-
-acpi_status
-bm_get_power_state (
-	BM_NODE			*node);
-
-acpi_status
-bm_set_power_state (
-	BM_NODE			*node,
-	BM_POWER_STATE          target_state);
-
-/* bmpower.c */
-
-acpi_status
-bm_pr_initialize (void);
-
-acpi_status
-bm_pr_terminate (void);
-	
-/* bmutils.c */
-
-acpi_status
-bm_cast_buffer (
-	acpi_buffer             *buffer,
-	void                    **pointer,
-	u32                     length);
-
-acpi_status
-bm_copy_to_buffer (
-	acpi_buffer             *buffer,
-	void                    *data,
-	u32                     length);
-
-acpi_status
-bm_extract_package_data (
-	acpi_object             *package,
-	acpi_buffer             *format,
-	acpi_buffer             *buffer);
-
-acpi_status
-bm_evaluate_object (
-	acpi_handle             acpi_handle,
-	acpi_string             pathname,
-	acpi_object_list        *arguments,
-	acpi_buffer             *buffer);
-
-acpi_status
-bm_evaluate_simple_integer (
-	acpi_handle             acpi_handle,
-	acpi_string             pathname,
-	u32                     *data);
-
-acpi_status
-bm_evaluate_reference_list (
-	acpi_handle             acpi_handle,
-	acpi_string             pathname,
-	BM_HANDLE_LIST          *reference_list);
-
-/* ACPI Bus Driver OSL */
-
-acpi_status
-bm_osl_generate_event (
-	BM_HANDLE		device_handle,
-	char			*device_type,
-	char			*device_instance,
-	u32			event_type,
-	u32			event_data);
-
-
-#endif  /* __BM_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/include/bmpower.h linux-2.4.22-pre2/drivers/acpi/ospm/include/bmpower.h
--- linux-2.4.21/drivers/acpi/ospm/include/bmpower.h	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/include/bmpower.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,75 +0,0 @@
-/*****************************************************************************
- *
- * Module name: bmpower.h
- *   $Revision: 9 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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 __BMPOWER_H__
-#define __BMPOWER_H__
-
-#include "bm.h"
-
-
-/*****************************************************************************
- *                               Types & Defines
- *****************************************************************************/
-
-
-/*
- * BM_POWER_RESOURCE:
- * ------------------
- */
-typedef struct
-{
-	BM_HANDLE           device_handle;
-	acpi_handle         acpi_handle;
-	BM_POWER_STATE      system_level;
-	u32                 resource_order;
-	BM_POWER_STATE      state;
-	u32                 reference_count;
-} BM_POWER_RESOURCE;
-
-
-/*****************************************************************************
- *                             Function Prototypes
- *****************************************************************************/
-
-/* bmpower.c */
-
-acpi_status
-bm_pr_initialize (void);
-
-acpi_status
-bm_pr_terminate (void);
-
-acpi_status
-bm_pr_list_get_state (
-	BM_HANDLE_LIST          *resource_list,
-	BM_POWER_STATE          *power_state);
-
-acpi_status
-bm_pr_list_transition (
-	BM_HANDLE_LIST          *current_list,
-	BM_HANDLE_LIST          *target_list);
-
-
-#endif  /* __BMPOWER_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/include/bn.h linux-2.4.22-pre2/drivers/acpi/ospm/include/bn.h
--- linux-2.4.21/drivers/acpi/ospm/include/bn.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/include/bn.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,122 +0,0 @@
-/******************************************************************************
- *
- * Module Name: bn.h
- *   $Revision: 12 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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 __BN_H__
-#define __BN_H__
-
-#include <actypes.h>
-#include <acexcep.h>
-#include <bm.h>
-
-
-/*****************************************************************************
- *                            Types & Other Defines
- *****************************************************************************/
-
-/*
- * Notifications:
- * ---------------------
- */
-#define BN_NOTIFY_STATUS_CHANGE	((BM_NOTIFY) 0x80)
-
-
-/*
- * Types:
- * ------
- */
-#define BN_TYPE_POWER_BUTTON	0x01
-#define BN_TYPE_POWER_BUTTON_FIXED 0x02
-#define BN_TYPE_SLEEP_BUTTON	0x03
-#define BN_TYPE_SLEEP_BUTTON_FIXED 0x04
-#define BN_TYPE_LID_SWITCH	0x05
-
-
-/*
- * Hardware IDs:
- * -------------
- * TBD: Power and Sleep button HIDs also exist in <bm.h>.  Should all
- *      HIDs (ACPI well-known devices) exist in one place (e.g.
- *      acpi_hid.h)?
- */
-#define BN_HID_POWER_BUTTON	"PNP0C0C"
-#define BN_HID_SLEEP_BUTTON	"PNP0C0E"
-#define BN_HID_LID_SWITCH	"PNP0C0D"
-
-
-/*
- * Device Context:
- * ---------------
- */
-typedef struct
-{
-	BM_HANDLE		device_handle;
-	acpi_handle		acpi_handle;
-	u32			type;
-} BN_CONTEXT;
-
-
-/******************************************************************************
- *                              Function Prototypes
- *****************************************************************************/
-
-acpi_status
-bn_initialize (void);
-
-acpi_status
-bn_terminate (void);
-
-acpi_status
-bn_notify_fixed (
-	void			*context);
-
-acpi_status
-bn_notify (
-	u32			notify_type,
-	u32			device,
-	void			**context);
-
-acpi_status
-bn_request(
-	BM_REQUEST		*request_info,
-	void			*context);
-
-/* Button OSL */
-
-acpi_status
-bn_osl_add_device (
-	BN_CONTEXT		*button);
-
-acpi_status
-bn_osl_remove_device (
-	BN_CONTEXT		*button);
-
-acpi_status
-bn_osl_generate_event (
-	u32			event,
-	BN_CONTEXT		*button);
-
-
-#endif	/* __BN_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/include/bt.h linux-2.4.22-pre2/drivers/acpi/ospm/include/bt.h
--- linux-2.4.21/drivers/acpi/ospm/include/bt.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/include/bt.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,164 +0,0 @@
-/******************************************************************************
- *
- * Module Name: bt.h
- *   $Revision: 18 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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 __BT_H__
-#define __BT_H__
-
-#include <actypes.h>
-#include <acexcep.h>
-#include <bm.h>
-
-
-/*****************************************************************************
- *                Types & Other Defines
- *****************************************************************************/
-
-/*! [Begin] no source code translation */
-
-#define BT_UNKNOWN		0xFFFFFFFF
-#define BT_POWER_UNITS_DEFAULT  "?"
-#define BT_POWER_UNITS_WATTS    "mW"
-#define BT_POWER_UNITS_AMPS	"mA"
-
-/*! [End] no source code translation !*/
-
-/*
- * Battery Notifications:
- * ----------------------
- */
-#define BT_NOTIFY_STATUS_CHANGE ((BM_NOTIFY) 0x80)
-#define BT_NOTIFY_INFORMATION_CHANGE ((BM_NOTIFY) 0x81)
-
-
-/*
- * Hardware IDs:
- * -------------
- */
-#define BT_HID_CM_BATTERY   "PNP0C0A"
-
-
-/*
- * BT_CM_BATTERY_INFO:
- * -------------------
- */
-typedef struct
-{
-	acpi_integer    power_unit;
-	acpi_integer    design_capacity;
-	acpi_integer    last_full_capacity;
-	acpi_integer    battery_technology;
-	acpi_integer    design_voltage;
-	acpi_integer    design_capacity_warning;
-	acpi_integer    design_capacity_low;
-	acpi_integer    battery_capacity_granularity_1;
-	acpi_integer    battery_capacity_granularity_2;
-	acpi_string     model_number;
-	acpi_string     serial_number;
-	acpi_string     battery_type;
-	acpi_string     oem_info;
-
-} BT_BATTERY_INFO;
-
-
-/*
- * BT_CM_BATTERY_STATUS:
- * ---------------------
- */
-typedef struct
-{
-	acpi_integer    state;
-	acpi_integer    present_rate;
-	acpi_integer    remaining_capacity;
-	acpi_integer    present_voltage;
-
-} BT_BATTERY_STATUS;
-
-
-/*
- * BT_CONTEXT:
- * -----------
- */
-typedef struct
-{
-	BM_HANDLE       device_handle;
-	acpi_handle     acpi_handle;
-	char            uid[9];
-	acpi_string     power_units;
-	u8              is_present;
-
-} BT_CONTEXT;
-
-
-/*****************************************************************************
- *              Function Prototypes
- *****************************************************************************/
-
-/* bt.c */
-
-acpi_status
-bt_initialize (void);
-
-acpi_status
-bt_terminate (void);
-
-acpi_status
-bt_notify (
-	u32         notify_type,
-	u32         device,
-	void        **context);
-
-acpi_status
-bt_request(
-	BM_REQUEST  *request_info,
-	void        *context);
-
-acpi_status
-bt_get_status (
-	BT_CONTEXT		*battery,
-	BT_BATTERY_STATUS   **battery_status);
-
-acpi_status
-bt_get_info (
-	BT_CONTEXT      *battery,
-	BT_BATTERY_INFO **battery_info);
-
-/* Battery OSL */
-
-acpi_status
-bt_osl_add_device (
-	BT_CONTEXT      *battery);
-
-acpi_status
-bt_osl_remove_device (
-	BT_CONTEXT      *battery);
-
-acpi_status
-bt_osl_generate_event (
-	u32         event,
-	BT_CONTEXT      *battery);
-
-
-#endif  /* __BT_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/include/ec.h linux-2.4.22-pre2/drivers/acpi/ospm/include/ec.h
--- linux-2.4.21/drivers/acpi/ospm/include/ec.h	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/include/ec.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,202 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: ec.h
- *   $Revision: 19 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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 __EC_H__
-#define __EC_H__
-
-#include <linux/spinlock.h>
-#include <asm/semaphore.h>
-#include <actypes.h>
-#include <acexcep.h>
-#include <bm.h>
-
-
-/*****************************************************************************
- *                            Types & Other Defines
- *****************************************************************************/
-
-#define EC_DEFAULT_TIMEOUT	1000		/* 1 second */
-#define EC_GPE_UNKNOWN		0xFFFFFFFF
-#define EC_PORT_UNKNOWN		0x00000000
-#define EC_BURST_ENABLE_ACKNOWLEDGE 0x90
-
-
-/*
- * Commands:
- * ---------
- */
-typedef u8			EC_COMMAND;
-
-#define EC_COMMAND_UNKNOWN	((EC_COMMAND) 0x00)
-#define EC_COMMAND_READ		((EC_COMMAND) 0x80)
-#define EC_COMMAND_WRITE	((EC_COMMAND) 0x81)
-#define EC_COMMAND_QUERY	((EC_COMMAND) 0x84)
-
-
-/*
- * EC_STATUS:
- * ----------
- * The encoding of the EC status register is illustrated below.
- * Note that a set bit (1) indicates the property is TRUE
- * (e.g. if bit 0 is set then the output buffer is full).
- * +-+-+-+-+-+-+-+-+
- * |7|6|5|4|3|2|1|0|
- * +-+-+-+-+-+-+-+-+
- *  | | | | | | | |
- *  | | | | | | | +- Output Buffer Full (OBF)?
- *  | | | | | | +--- Input Buffer Full (IBF)?
- *  | | | | | +----- <reserved>
- *  | | | | +------- data Register is command Byte?
- *  | | | +--------- Burst Mode Enabled?
- *  | | +----------- SCI event?
- *  | +------------- SMI event?
- *  +--------------- <Reserved>
- *
- */
-typedef u32			EC_STATUS;
-
-#define EC_FLAG_OUTPUT_BUFFER	((EC_STATUS) 0x01)
-#define EC_FLAG_INPUT_BUFFER	((EC_STATUS) 0x02)
-#define EC_FLAG_BURST_MODE	((EC_STATUS) 0x10)
-#define EC_FLAG_SCI		((EC_STATUS) 0x20)
-
-
-/*
- * EC_EVENT:
- * ---------
- */
-typedef u32			EC_EVENT;
-
-#define EC_EVENT_UNKNOWN	((EC_EVENT) 0x00)
-#define EC_EVENT_NONE		((EC_EVENT) 0x00)
-#define EC_EVENT_OUTPUT_BUFFER_FULL ((EC_EVENT) 0x01)
-#define EC_EVENT_INPUT_BUFFER_EMPTY ((EC_EVENT) 0x02)
-#define EC_EVENT_SCI		((EC_EVENT) 0x03)
-
-
-/*
- * Hardware IDs:
- * -------------
- */
-#define EC_HID_EC		"PNP0C09"
-
-
-/*
- * EC_REQUEST:
- * -----------
- */
-typedef struct
-{
-	EC_COMMAND              command;
-	u8                      address;
-	u8                      data;
-} EC_REQUEST;
-
-
-/*
- * Device Context:
- * ---------------
- */
-typedef struct
-{
-	BM_HANDLE               device_handle;
-	acpi_handle             acpi_handle;
-	u32                     gpe_bit;
-	u32			status_port;
-	u32			command_port;
-	u32			data_port;
-	u32			use_global_lock;
-	u8                      query_data;
-	acpi_handle             mutex;
-} EC_CONTEXT;
-
-
-/*****************************************************************************
- *                             Function Prototypes
- *****************************************************************************/
-
-/* ec.c */
-
-acpi_status
-ec_initialize(void);
-
-acpi_status
-ec_terminate(void);
-
-acpi_status
-ec_notify (
-	u32                     notify_type,
-	u32                     device,
-	void                    **context);
-
-acpi_status
-ec_request(
-	BM_REQUEST              *request_info,
-	void                    *context);
-
-/* ectransx.c */
-
-acpi_status
-ec_transaction (
-	EC_CONTEXT              *ec,
-	EC_REQUEST              *ec_request);
-
-acpi_status
-ec_io_read (
-	EC_CONTEXT              *ec,
-	u32         		io_port,
-	u8                      *data,
-	EC_EVENT                wait_event);
-
-acpi_status
-ec_io_write (
-	EC_CONTEXT              *ec,
-	u32         		io_port,
-	u8                      data,
-	EC_EVENT                wait_event);
-
-/* ecgpe.c */
-
-acpi_status
-ec_install_gpe_handler (
-	EC_CONTEXT              *ec);
-
-acpi_status
-ec_remove_gpe_handler (
-	EC_CONTEXT              *ec);
-
-/* ecspace.c */
-
-acpi_status
-ec_install_space_handler (
-	EC_CONTEXT              *ec);
-
-acpi_status
-ec_remove_space_handler (
-	EC_CONTEXT              *ec);
-
-
-#endif  /* __EC_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/include/pr.h linux-2.4.22-pre2/drivers/acpi/ospm/include/pr.h
--- linux-2.4.21/drivers/acpi/ospm/include/pr.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/include/pr.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,265 +0,0 @@
-/******************************************************************************
- *
- * Module Name: processor.h
- *              $Revision: 13 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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 __PR_H__
-#define __PR_H__
-
-#include <bm.h>
-
-
-/*****************************************************************************
- *                             Types & Other Defines
- *****************************************************************************/
-
-
-#define PR_MAX_POWER_STATES	4
-#define PR_MAX_THROTTLE_STATES  8
-#define PR_MAX_PERF_STATES	32
-#define PR_MAX_C2_LATENCY	100
-#define PR_MAX_C3_LATENCY	1000
-
-
-/*
- * Commands:
- * ---------
- */
-#define PR_COMMAND_GET_POWER_INFO ((BM_COMMAND) 0x80)
-#define PR_COMMAND_SET_POWER_INFO ((BM_COMMAND) 0x81)
-#define PR_COMMAND_GET_PERF_INFO ((BM_COMMAND) 0x82)
-#define PR_COMMAND_GET_PERF_STATE ((BM_COMMAND) 0x83)
-#define PR_COMMAND_SET_PERF_LIMIT ((BM_COMMAND) 0x84)
-
-
-/*
- * Notifications:
- * --------------
- */
-#define PR_NOTIFY_PERF_STATES	((BM_NOTIFY) 0x80)
-#define PR_NOTIFY_POWER_STATES	((BM_NOTIFY) 0x81)
-
-
-/*
- * Performance Control:
- * --------------------
- */
-#define PR_PERF_DEC		0x00
-#define PR_PERF_INC		0x01
-#define PR_PERF_MAX		0xFF
-
-
-/*
- * Power States:
- * -------------
- */
-#define PR_C0			0x00
-#define PR_C1			0x01
-#define PR_C2			0x02
-#define PR_C3			0x03
-
-#define PR_C1_FLAG		0x01;
-#define PR_C2_FLAG		0x02;
-#define PR_C3_FLAG		0x04;
-
-
-/*
- * PR_CX_POLICY_VALUES:
- * --------------------
- */
-typedef struct
-{
-	u32			time_threshold;
-	u32			count_threshold;
-	u32                     bm_threshold;
-	u32         		target_state;
-	u32			count;
-} PR_CX_POLICY_VALUES;
-
-
-/*
- * PR_CX:
- * ------
- */
-typedef struct
-{
-	u32                     latency;
-	u32                     utilization;
-	u8                      is_valid;
-	PR_CX_POLICY_VALUES     promotion;
-	PR_CX_POLICY_VALUES     demotion;
-} PR_CX;
-
-
-/*
- * PR_POWER:
- * ---------
- */
-typedef struct
-{
-	ACPI_PHYSICAL_ADDRESS   p_lvl2;
-	ACPI_PHYSICAL_ADDRESS   p_lvl3;
-	u32                     bm_activity;
-	u32                     active_state;
-	u32			default_state;
-	u32			busy_metric;
-	u32                     state_count;
-	PR_CX                   state[PR_MAX_POWER_STATES];
-} PR_POWER;
-
-
-/*
- * PR_PERFORMANCE_STATE:
- * ---------------------
- */
-typedef struct
-{
-	u32                     performance;
-	u32                     power;
-} PR_PERFORMANCE_STATE;
-
-
-/*
- * PR_PERFORMANCE:
- * ---------------
- */
-typedef struct
-{
-	u32                     active_state;
-	u32			thermal_limit;
-	u32			power_limit;
-	u32                     state_count;
-	PR_PERFORMANCE_STATE    state[PR_MAX_PERF_STATES];
-} PR_PERFORMANCE;
-
-
-/*
- * PR_PBLOCK:
- * ----------
- */
-typedef struct
-{
-	u32                     length;
-	ACPI_PHYSICAL_ADDRESS   address;
-} PR_PBLOCK;
-
-
-/*
- * PR_CONTEXT:
- * -----------
- */
-typedef struct
-{
-	BM_HANDLE               device_handle;
-	acpi_handle             acpi_handle;
-	u32                     uid;
-	PR_PBLOCK               pblk;
-	PR_POWER		power;
-	PR_PERFORMANCE		performance;
-} PR_CONTEXT;
-
-
-/******************************************************************************
- *                             Function Prototypes
- *****************************************************************************/
-
-/* processor.c */
-
-acpi_status
-pr_initialize(void);
-
-acpi_status
-pr_terminate(void);
-
-acpi_status
-pr_notify (
-	BM_NOTIFY               notify_type,
-	BM_HANDLE               device_handle,
-	void                    **context);
-
-acpi_status
-pr_request(
-	BM_REQUEST		*request,
-	void                    *context);
-
-/* prpower.c */
-
-void
-pr_power_idle (void);
-
-acpi_status
-pr_power_add_device (
-	PR_CONTEXT              *processor);
-
-acpi_status
-pr_power_remove_device (
-	PR_CONTEXT              *processor);
-
-acpi_status
-pr_power_initialize (void);
-
-acpi_status
-pr_power_terminate (void);
-
-/* prperf.c */
-
-acpi_status
-pr_perf_get_state (
-	PR_CONTEXT              *processor,
-	u32                     *state);
-
-acpi_status
-pr_perf_set_state (
-	PR_CONTEXT              *processor,
-	u32                     state);
-
-acpi_status
-pr_perf_set_limit (
-	PR_CONTEXT              *processor,
-	u32                     limit);
-
-acpi_status
-pr_perf_add_device (
-	PR_CONTEXT              *processor);
-
-acpi_status
-pr_perf_remove_device (
-	PR_CONTEXT              *processor);
-
-/* Processor Driver OSL */
-
-acpi_status
-pr_osl_add_device (
-	PR_CONTEXT		*processor);
-
-acpi_status
-pr_osl_remove_device (
-	PR_CONTEXT		*processor);
-
-acpi_status
-pr_osl_generate_event (
-	u32			event,
-	PR_CONTEXT		*processor);
-
-
-#endif  /* __PR_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/include/sm.h linux-2.4.22-pre2/drivers/acpi/ospm/include/sm.h
--- linux-2.4.21/drivers/acpi/ospm/include/sm.h	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/include/sm.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,91 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: sm.h
- *   $Revision: 3 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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 __SM_H__
-#define __SM_H__
-
-#include <actypes.h>
-#include <acexcep.h>
-#include <bm.h>
-
-
-/*****************************************************************************
- *                            Types & Other Defines
- *****************************************************************************/
-
-#define SM_MAX_SYSTEM_STATES	6	/* S0-S5 */
-
-
- /*
- * Device Context:
- * ---------------
- */
-typedef struct
-{
-	BM_HANDLE		device_handle;
-	acpi_handle 		acpi_handle;
-	u8			states[SM_MAX_SYSTEM_STATES];
-} SM_CONTEXT;
-
-
-/*****************************************************************************
- *                              Function Prototypes
- *****************************************************************************/
-
-acpi_status
-sm_initialize (void);
-
-acpi_status
-sm_terminate (void);
-
-acpi_status
-sm_notify (
-	u32			notify_type,
-	u32 			device,
-	void			**context);
-
-acpi_status
-sm_request(
-	BM_REQUEST		*request_info,
-	void			*context);
-
-/* System Driver OSL */
-
-acpi_status
-sm_osl_add_device (
-	SM_CONTEXT		*system);
-
-acpi_status
-sm_osl_remove_device (
-	SM_CONTEXT		*system);
-
-acpi_status
-sm_osl_generate_event (
-	u32			event,
-	SM_CONTEXT		*system);
-
-
-#endif	/* __SM_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/include/tz.h linux-2.4.22-pre2/drivers/acpi/ospm/include/tz.h
--- linux-2.4.21/drivers/acpi/ospm/include/tz.h	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/include/tz.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,252 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: tz.h
- *   $Revision: 24 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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 __TZ_H__
-#define __TZ_H__
-
-/* TBD: Linux-specific */
-#include <linux/module.h>
-#include <linux/timer.h>
-
-#include <bm.h>
-#include <pr.h>
-
-
-/*****************************************************************************
- *                             Types & Other Defines
- *****************************************************************************/
-
-#define TZ_MAX_THRESHOLDS	12	/* _AC0 through _AC9 + _CRT + _PSV */
-#define TZ_MAX_ACTIVE_THRESHOLDS 10	/* _AC0 through _AC9 */
-#define TZ_MAX_COOLING_DEVICES	10	/* TBD: Make size dynamic */
-
-
-/*
- * Notifications:
- * --------------
- */
-#define TZ_NOTIFY_TEMPERATURE_CHANGE ((BM_NOTIFY) 0x80)
-#define TZ_NOTIFY_THRESHOLD_CHANGE ((BM_NOTIFY) 0x81)
-#define TZ_NOTIFY_DEVICE_LISTS_CHANGE ((BM_NOTIFY) 0x82)
-
-
-/*
- * TZ_THRESHOLD_TYPE:
- * ------------------
- */
-typedef u32			TZ_THRESHOLD_TYPE;
-
-#define TZ_THRESHOLD_UNKNOWN	((TZ_THRESHOLD_TYPE) 0x00)
-#define TZ_THRESHOLD_CRITICAL	((TZ_THRESHOLD_TYPE) 0x01)
-
-#define TZ_THRESHOLD_PASSIVE	((TZ_THRESHOLD_TYPE) 0x02)
-#define TZ_THRESHOLD_ACTIVE	((TZ_THRESHOLD_TYPE) 0x03)
-
-
-/*
- * TZ_COOLING_STATE:
- * -----------------
- */
-typedef u32			TZ_COOLING_STATE;
-
-#define TZ_COOLING_UNKNOWN	((TZ_COOLING_STATE) 0x00)
-#define TZ_COOLING_ENABLED	((TZ_COOLING_STATE) 0x01)
-#define TZ_COOLING_DISABLED	((TZ_COOLING_STATE) 0x02)
-
-
-/*
- * TZ_COOLING_MODE:
- * ----------------
- */
-typedef u32			TZ_COOLING_MODE;
-
-#define TZ_COOLING_MODE_ACTIVE	((TZ_COOLING_MODE) 0x00)
-#define TZ_COOLING_MODE_PASSIVE	((TZ_COOLING_MODE) 0x01)
-
-
-/*
- * Thermal State:
- * --------------
- * The encoding of TZ_STATE is illustrated below.
- * Note that a set bit (1) indicates the property is TRUE
- * (e.g. if bit 0 is set then the device has dynamic status).
- * No bits set indicates an OK cooling state.
- * +--+--+--+-----------+----------+
- * |31|30|29| Bits 27:4 | Bits 3:0 |
- * +--+--+--+-----------+----------+
- *  |  |  |       |          |
- *  |  |  |       |          +------ Active Index
- *  |  |  |       +----------------- <reserved>
- *  |  |  +------------------------- Active
- *  |  +---------------------------- Passive
- *  +------------------------------- Critical
- *
- * Active Index:    Value representing the level of active cooling
- *                  presently applied (e.g. 0=_AL0, 9=_AL9).  Only
- *                  valid when 'Active' is set.
- * Active:          If set, indicates that the system temperature
- *                  has crossed at least one active threshold (_ALx).
- * Passive:         If set, indicates that the system temperature
- *                  has crossed the passive threshold (_PSL).
- * Passive:         If set, indicates that the system temperature
- *                  has crossed the critical threshold (_CRT).
- */
-typedef u32			TZ_STATE;
-
-#define TZ_STATE_OK		((TZ_STATE) 0x00000000)
-#define TZ_STATE_HOT		((TZ_STATE) 0x10000000)
-#define TZ_STATE_ACTIVE		((TZ_STATE) 0x20000000)
-#define TZ_STATE_PASSIVE	((TZ_STATE) 0x40000000)
-#define TZ_STATE_CRITICAL	((TZ_STATE) 0x80000000)
-
-typedef struct {
-	u32			temperature;
-} TZ_CRITICAL_THRESHOLD;
-
-typedef struct {
-	u8			is_valid;
-	u32			temperature;
-} TZ_HOT_THRESHOLD;
-
-typedef struct {
-	u8			is_valid;
-	u32			temperature;
-	u32			tc1;
-	u32			tc2;
-	u32			tsp;
-	BM_HANDLE_LIST		devices;
-} TZ_PASSIVE_THRESHOLD;
-
-typedef struct {
-	u8			is_valid;
-	u32			temperature;
-	TZ_COOLING_STATE	cooling_state;
-	BM_HANDLE_LIST		devices;
-} TZ_ACTIVE_THRESHOLD;
-
-typedef struct {
-	TZ_CRITICAL_THRESHOLD	critical;
-	TZ_HOT_THRESHOLD	hot;
-	TZ_PASSIVE_THRESHOLD	passive;
-	TZ_ACTIVE_THRESHOLD	active[TZ_MAX_ACTIVE_THRESHOLDS];
-} TZ_THRESHOLDS;
-
-/*
- * TZ_POLICY:
- * ---------
- */
-typedef struct {
-	u32			temperature;
-	TZ_STATE		state;
-	TZ_COOLING_MODE		cooling_mode;
-	u32			polling_freq;
-	TZ_THRESHOLDS		thresholds;
-	struct timer_list	timer;
-} TZ_POLICY;
-
-
-/*
- * TZ_CONTEXT:
- * -----------
- */
-typedef struct {
-	BM_HANDLE		device_handle;
-	acpi_handle		acpi_handle;
-	char			uid[9];
-	TZ_POLICY		policy;
-} TZ_CONTEXT;
-
-
-/*****************************************************************************
- *                             Function Prototypes
- *****************************************************************************/
-
-/* tz.c */
-
-acpi_status
-tz_initialize (void);
-
-acpi_status
-tz_terminate (void);
-
-acpi_status
-tz_notify (
-	BM_NOTIFY               notify_type,
-	BM_HANDLE               device_handle,
-	BM_DRIVER_CONTEXT	*context);
-
-acpi_status
-tz_request (
-	BM_REQUEST              *request,
-	BM_DRIVER_CONTEXT	context);
-
-acpi_status
-tz_get_temperature (
-	TZ_CONTEXT		*tz);
-
-acpi_status
-tz_get_thresholds (
-	TZ_CONTEXT		*tz);
-
-acpi_status
-tz_set_cooling_preference (
-	TZ_CONTEXT              *tz,
-	TZ_COOLING_MODE         cooling_mode);
-
-void
-tz_print (
-	TZ_CONTEXT              *tz);
-
-/* tzpolicy.c */
-
-acpi_status
-tz_policy_add_device (
-	TZ_CONTEXT              *tz);
-
-acpi_status
-tz_policy_remove_device (
-	TZ_CONTEXT              *tz);
-
-void
-tz_policy_check (
-	void                    *context);
-
-/* tz_osl.c */
-
-acpi_status
-tz_osl_add_device (
-	TZ_CONTEXT		*tz);
-
-acpi_status
-tz_osl_remove_device (
-	TZ_CONTEXT		*tz);
-
-acpi_status
-tz_osl_generate_event (
-	u32			event,
-	TZ_CONTEXT		*tz);
-
-
-#endif  /* __TZ_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/processor/Makefile linux-2.4.22-pre2/drivers/acpi/ospm/processor/Makefile
--- linux-2.4.21/drivers/acpi/ospm/processor/Makefile	2001-06-21 00:47:40.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/processor/Makefile	1970-01-01 00:00:00.000000000 +0000
@@ -1,6 +0,0 @@
-O_TARGET	:= ospm_$(notdir $(CURDIR)).o
-obj-m		:= $(O_TARGET)
-EXTRA_CFLAGS	+= $(ACPI_CFLAGS)
-obj-y		:= $(patsubst %.c,%.o,$(wildcard *.c))
-
-include $(TOPDIR)/Rules.make
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/processor/pr.c linux-2.4.22-pre2/drivers/acpi/ospm/processor/pr.c
--- linux-2.4.21/drivers/acpi/ospm/processor/pr.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/processor/pr.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,497 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: pr.c
- *   $Revision: 34 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include <acpi.h>
-#include <bm.h>
-#include "pr.h"
-
-
-#define _COMPONENT		ACPI_PROCESSOR
-	MODULE_NAME		("pr")
-
-
-/****************************************************************************
- *                                  Globals
- ****************************************************************************/
-
-extern fadt_descriptor_rev2	acpi_fadt;
-
-
-/****************************************************************************
- *                             Internal Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:    pr_print
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION: Prints out information on a specific thermal zone.
- *
- ****************************************************************************/
-
-void
-pr_print (
-	PR_CONTEXT              *processor)
-{
-#ifdef ACPI_DEBUG
-	acpi_buffer             buffer;
-
-	FUNCTION_TRACE("pr_print");
-
-	buffer.length = 256;
-	buffer.pointer = acpi_os_callocate(buffer.length);
-	if (!buffer.pointer) {
-		return;
-	}
-
-	/*
-	 * Get the full pathname for this ACPI object.
-	 */
-	acpi_get_name(processor->acpi_handle, ACPI_FULL_PATHNAME, &buffer);
-
-	/*
-	 * Print out basic processor information.
-	 */
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "| Processor[%02x]:[%p] uid[%02x] %s\n", processor->device_handle, processor->acpi_handle, processor->uid, (char*)buffer.pointer));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   power: %cC0 %cC1 %cC2[%d] %cC3[%d]\n", (processor->power.state[0].is_valid?'+':'-'), (processor->power.state[1].is_valid?'+':'-'), (processor->power.state[2].is_valid?'+':'-'), processor->power.state[2].latency, (processor->power.state[3].is_valid?'+':'-'), processor->power.state[3].latency));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   performance: states[%d]\n", processor->performance.state_count));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
-
-	acpi_os_free(buffer.pointer);
-#endif /* ACPI_DEBUG */
-
-	return;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    pr_add_device
- *
- * PARAMETERS:  <none>
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-pr_add_device(
-	BM_HANDLE		device_handle,
-	void			**context)
-{
-	acpi_status		status = AE_OK;
-	PR_CONTEXT		*processor = NULL;
-	BM_DEVICE		*device = NULL;
-	acpi_buffer		buffer;
-	acpi_object		acpi_object;
-	static u32		processor_count = 0;
-
-
-	FUNCTION_TRACE("pr_add_device");
-
-	if (!context || *context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	status = bm_get_device_info(device_handle, &device);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	processor = acpi_os_callocate(sizeof(PR_CONTEXT));
-	if (!processor) {
-		return AE_NO_MEMORY;
-	}
-
-	processor->device_handle = device->handle;
-	processor->acpi_handle = device->acpi_handle;
-
-	/*
-	 * Processor Block:
-	 * ----------------
-	 */
-	memset(&acpi_object, 0, sizeof(acpi_object));
-
-	buffer.length = sizeof(acpi_object);
-	buffer.pointer = &acpi_object;
-
-	status = acpi_evaluate_object(processor->acpi_handle, NULL, NULL, &buffer);
-	if (ACPI_FAILURE(status)) {
-		goto end;
-	}
-
-	/*
-	 * Processor ID:
-	 * -------------
-	 * TBD:  We need to synchronize the processor ID values in ACPI
-	 *       with those of the APIC.  For example, an IBM T20 has a
-	 *       proc_id value of '1', where the Linux value for the
-	 *       first CPU on this system is '0'.  Since x86 CPUs are
-	 *       mapped 1:1 we can simply use a zero-based counter.  Note
-	 *       that this assumes that processor objects are enumerated
-	 *       in the proper order.
-	 */
-	/* processor->uid = acpi_object.processor.proc_id; */
-	processor->uid = processor_count++;
-
-	processor->pblk.length = acpi_object.processor.pblk_length;
-	processor->pblk.address = acpi_object.processor.pblk_address;
-
-	status = pr_power_add_device(processor);
-	if (ACPI_FAILURE(status)) {
-		goto end;
-	}
-
-	status = pr_perf_add_device(processor);
-	if (ACPI_FAILURE(status)) {
-		goto end;
-	}
-
-	status = pr_osl_add_device(processor);
-	if (ACPI_FAILURE(status)) {
-		goto end;
-	}
-
-	*context = processor;
-
-	pr_print(processor);
-
-end:
-	if (ACPI_FAILURE(status)) {
-		acpi_os_free(processor);
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    pr_remove_device
- *
- * PARAMETERS:  <none>
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-pr_remove_device (
-	void			**context)
-{
-	acpi_status		status = AE_OK;
-	PR_CONTEXT		*processor= NULL;
-
-	FUNCTION_TRACE("pr_remove_device");
-
-	if (!context || !*context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	processor = (PR_CONTEXT*)(*context);
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing processor device [%02x].\n", processor->device_handle));
-
-	pr_osl_remove_device(processor);
-
-	pr_perf_remove_device(processor);
-
-	pr_power_remove_device(processor);
-
-	acpi_os_free(processor);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *                            External Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:    pr_initialize
- *
- * PARAMETERS:  <none>
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-pr_initialize (void)
-{
-	acpi_status		status = AE_OK;
-	BM_DEVICE_ID		criteria;
-	BM_DRIVER		driver;
-
-	FUNCTION_TRACE("pr_initialize");
-
-	memset(&criteria, 0, sizeof(BM_DEVICE_ID));
-	memset(&driver, 0, sizeof(BM_DRIVER));
-
-	/*
-	 * Initialize power (Cx state) policy.
-	 */
-	status = pr_power_initialize();
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Register driver for processor devices.
-	 */
-	criteria.type = BM_TYPE_PROCESSOR;
-
-	driver.notify = &pr_notify;
-	driver.request = &pr_request;
-
-	status = bm_register_driver(&criteria, &driver);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    pr_terminate
- *
- * PARAMETERS:  <none>
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-pr_terminate (void)
-{
-	acpi_status             status = AE_OK;
-	BM_DEVICE_ID		criteria;
-	BM_DRIVER		driver;
-
-	FUNCTION_TRACE("pr_terminate");
-
-	memset(&criteria, 0, sizeof(BM_DEVICE_ID));
-	memset(&driver, 0, sizeof(BM_DRIVER));
-
-	/*
-	 * Terminate power (Cx state) policy.
-	 */
-	status = pr_power_terminate();
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Unegister driver for processor devices.
-	 */
-	criteria.type = BM_TYPE_PROCESSOR;
-
-	driver.notify = &pr_notify;
-	driver.request = &pr_request;
-
-	status = bm_unregister_driver(&criteria, &driver);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    pr_notify
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-pr_notify (
-	BM_NOTIFY		notify_type,
-	BM_HANDLE		device_handle,
-	void			**context)
-{
-	acpi_status		status = AE_OK;
-	PR_CONTEXT		*processor = NULL;
-
-	FUNCTION_TRACE("pr_notify");
-
-	processor = (PR_CONTEXT*)*context;
-
-	switch (notify_type) {
-
-	case BM_NOTIFY_DEVICE_ADDED:
-		status = pr_add_device(device_handle, context);
-		break;
-
-	case BM_NOTIFY_DEVICE_REMOVED:
-		status = pr_remove_device(context);
-		break;
-
-	case PR_NOTIFY_PERF_STATES:
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Performance states change event detected on processor [%02x].\n", device_handle));
-		/* TBD: Streamline (this is simple but overkill). */
-		status = pr_perf_remove_device(processor);
-		if (ACPI_SUCCESS(status)) {
-			status = pr_perf_add_device(processor);
-		}
-		if (ACPI_SUCCESS(status)) {
-			status = pr_osl_generate_event(notify_type,
-				(processor));
-		}
-		break;
-
-	case PR_NOTIFY_POWER_STATES:
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Power states change event detected on processor [%02x].\n", device_handle));
-		/* TBD: Streamline (this is simple but overkill). */
-		status = pr_power_remove_device(processor);
-		if (ACPI_SUCCESS(status)) {
-			status = pr_power_add_device(processor);
-		}
-		if (ACPI_SUCCESS(status)) {
-			status = pr_osl_generate_event(notify_type,
-				(processor));
-		}
-		break;
-
-	default:
-		status = AE_SUPPORT;
-		break;
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    pr_request
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-pr_request (
-	BM_REQUEST		*request,
-	void			*context)
-{
-	acpi_status		status = AE_OK;
-	PR_CONTEXT		*processor = NULL;
-
-	FUNCTION_TRACE("pr_request");
-
-	/*
-	 * Must have a valid request structure and context.
-	 */
-	if (!request || !context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	processor = (PR_CONTEXT*)context;
-
-	/*
-	 * Handle request:
-	 * ---------------
-	 */
-	switch (request->command) {
-
-	case PR_COMMAND_GET_POWER_INFO:
-		status = bm_copy_to_buffer(&(request->buffer),
-			&(processor->power), sizeof(PR_POWER));
-		break;
-
-	case PR_COMMAND_SET_POWER_INFO:
-	 {
-		PR_POWER *power_info = NULL;
-		u32 i = 0;
-
-		status = bm_cast_buffer(&(request->buffer),
-			(void**)&power_info, sizeof(PR_POWER));
-		if (ACPI_SUCCESS(status)) {
-			for (i=0; i<processor->power.state_count; i++) {
-				MEMCPY(&(processor->power.state[i].promotion),
-					&(power_info->state[i].promotion),
-					sizeof(PR_CX_POLICY_VALUES));
-				MEMCPY(&(processor->power.state[i].demotion),
-					&(power_info->state[i].demotion),
-					sizeof(PR_CX_POLICY_VALUES));
-			}
-		}
-	}
-		break;
-
-	case PR_COMMAND_GET_PERF_INFO:
-		status = bm_copy_to_buffer(&(request->buffer),
-			&(processor->performance), sizeof(PR_PERFORMANCE));
-		break;
-
-	case PR_COMMAND_GET_PERF_STATE:
-		status = bm_copy_to_buffer(&(request->buffer),
-			&(processor->performance.active_state), sizeof(u32));
-		break;
-
-	case PR_COMMAND_SET_PERF_LIMIT:
-	 {
-		u32 *limit = NULL;
-
-		status = bm_cast_buffer(&(request->buffer),
-			(void**)&limit, sizeof(u32));
-		if (ACPI_SUCCESS(status)) {
-			status = pr_perf_set_limit(processor, *limit);
-		}
-	}
-		break;
-
-	default:
-		status = AE_SUPPORT;
-		break;
-	}
-
-	request->status = status;
-
-	return_ACPI_STATUS(status);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/processor/pr_osl.c linux-2.4.22-pre2/drivers/acpi/ospm/processor/pr_osl.c
--- linux-2.4.21/drivers/acpi/ospm/processor/pr_osl.c	2001-12-21 17:41:53.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/processor/pr_osl.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,344 +0,0 @@
-/******************************************************************************
- *
- * Module Name: pr_osl.c
- *   $Revision: 21 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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/proc_fs.h>
-#include <linux/pci.h>
-#include <acpi.h>
-#include <bm.h>
-#include "pr.h"
-
-
-MODULE_AUTHOR("Andrew Grover");
-MODULE_DESCRIPTION("ACPI Component Architecture (CA) - IA32 Processor Driver");
-MODULE_LICENSE("GPL");
-
-
-#define PR_PROC_ROOT		"processor"
-#define PR_PROC_STATUS		"status"
-#define PR_PROC_INFO		"info"
-
-extern struct proc_dir_entry	*bm_proc_root;
-static struct proc_dir_entry	*pr_proc_root = NULL;
-extern unsigned short		acpi_piix4_bmisx;
-
-
-/****************************************************************************
- *
- * FUNCTION:	pr_osl_proc_read_status
- *
- ****************************************************************************/
-
-static int
-pr_osl_proc_read_status (
-	char			*page,
-	char			**start,
-	off_t			off,
-	int 			count,
-	int 			*eof,
-	void			*context)
-{
-	PR_CONTEXT		*processor = NULL;
-	char			*p = page;
-	int 			len = 0;
-
-	if (!context || (off != 0)) {
-		goto end;
-	}
-
-	processor = (PR_CONTEXT*)context;
-
-	p += sprintf(p, "Bus Mastering Activity:  %08x\n",
-		processor->power.bm_activity);
-
-	p += sprintf(p, "C-State Utilization:     C1[%d] C2[%d] C3[%d]\n",
-		processor->power.state[PR_C1].utilization,
-		processor->power.state[PR_C2].utilization,
-		processor->power.state[PR_C3].utilization);
-
-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(len);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	pr_osl_proc_read_info
- *
- ****************************************************************************/
-
-static int
-pr_osl_proc_read_info (
-	char			*page,
-	char			**start,
-	off_t			off,
-	int 			count,
-	int 			*eof,
-	void			*context)
-{
-	PR_CONTEXT		*processor = NULL;
-	char			*p = page;
-	int 			len = 0;
-
-	if (!context || (off != 0)) {
-		goto end;
-	}
-
-	processor = (PR_CONTEXT*)context;
-
-	p += sprintf(p, "<TBD>\n");
-
-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(len);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	pr_osl_add_device
- *
- ****************************************************************************/
-
-acpi_status
-pr_osl_add_device(
-	PR_CONTEXT		*processor)
-{
-	u32			i = 0;
-	struct proc_dir_entry	*proc_entry = NULL, *proc;
-	char			processor_uid[16];
-
-	if (!processor) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	printk("Processor[%x]:", processor->uid);
-	for (i=0; i<processor->power.state_count; i++) {
-		if (processor->power.state[i].is_valid) {
-			printk(" C%d", i);
-		}
-	}
-	if (processor->performance.state_count > 1)
-		printk(", %d throttling states", processor->performance.state_count);
-	if (acpi_piix4_bmisx && processor->power.state[3].is_valid)
-		printk(" (PIIX errata enabled)");
-	printk("\n");
-
-	sprintf(processor_uid, "%d", processor->uid);
-
-	proc_entry = proc_mkdir(processor_uid, pr_proc_root);
-	if (!proc_entry)
-		return(AE_ERROR);
-
-	proc = create_proc_read_entry(PR_PROC_STATUS, S_IFREG | S_IRUGO, 
-				      proc_entry, pr_osl_proc_read_status, (void*)processor);
-	if (!proc_entry)
-		return(AE_ERROR);
-
-	proc = create_proc_read_entry(PR_PROC_INFO, S_IFREG | S_IRUGO, 
-				      proc_entry, pr_osl_proc_read_info, (void*)processor);
-	if (!proc_entry)
-		return(AE_ERROR);
-
-	return(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	pr_osl_remove_device
- *
- ****************************************************************************/
-
-acpi_status
-pr_osl_remove_device (
-	PR_CONTEXT		*processor)
-{
-	char			proc_entry[64];
-
-	if (!processor) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	sprintf(proc_entry, "%d/%s", processor->uid, PR_PROC_INFO);
-	remove_proc_entry(proc_entry, pr_proc_root);
-
-	sprintf(proc_entry, "%d/%s", processor->uid, PR_PROC_STATUS);
-	remove_proc_entry(proc_entry, pr_proc_root);
-
-	sprintf(proc_entry, "%d", processor->uid);
-	remove_proc_entry(proc_entry, pr_proc_root);
-
-	return(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	pr_osl_generate_event
- *
- ****************************************************************************/
-
-acpi_status
-pr_osl_generate_event (
-	u32			event,
-	PR_CONTEXT		*processor)
-{
-	acpi_status		status = AE_OK;
-	char			processor_uid[16];
-
-	if (!processor) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	switch (event) {
-
-	case PR_NOTIFY_PERF_STATES:
-	case PR_NOTIFY_POWER_STATES:
-		sprintf(processor_uid, "%d", processor->uid);
-		status = bm_osl_generate_event(processor->device_handle,
-			PR_PROC_ROOT, processor_uid, event, 0);
-		break;
-
-	default:
-		return(AE_BAD_PARAMETER);
-		break;
-	}
-
-	return(status);
-}
-
-
-/****************************************************************************
- *                              Errata Handling
- ****************************************************************************/
-
-void acpi_pr_errata (void)
-{
-	struct pci_dev		*dev = NULL;
-
-	while ((dev = pci_find_subsys(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, 
-		PCI_ANY_ID, PCI_ANY_ID, dev))) {
-		switch (dev->device) {
-		case PCI_DEVICE_ID_INTEL_82801BA_8:	/* PIIX4U4 */
-		case PCI_DEVICE_ID_INTEL_82801BA_9:	/* PIIX4U3 */
-		case PCI_DEVICE_ID_INTEL_82451NX:	/* PIIX4NX */
-		case PCI_DEVICE_ID_INTEL_82372FB_1:	/* PIIX4U2 */
-		case PCI_DEVICE_ID_INTEL_82801AA_1:	/* PIIX4U */
-		case PCI_DEVICE_ID_INTEL_82443MX_1:	/* PIIX4E2 */
-		case PCI_DEVICE_ID_INTEL_82801AB_1:	/* PIIX4E */
-		case PCI_DEVICE_ID_INTEL_82371AB:	/* PIIX4 */
-			acpi_piix4_bmisx = pci_resource_start(dev, 4);
-			return;
-		}
-	}
-
-	return;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	pr_osl_init
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	0: Success
- *
- * DESCRIPTION: Module initialization.
- *
- ****************************************************************************/
-
-static int __init
-pr_osl_init (void)
-{
-	acpi_status		status = AE_OK;
-
-	/* abort if no busmgr */
-	if (!bm_proc_root)
-		return -ENODEV;
-
-	acpi_pr_errata();
-
-	pr_proc_root = proc_mkdir(PR_PROC_ROOT, bm_proc_root);
-	if (!pr_proc_root) {
-		status = AE_ERROR;
-	}
-	else {
-		status = pr_initialize();
-		if (ACPI_FAILURE(status)) {
-			remove_proc_entry(PR_PROC_ROOT, bm_proc_root);
-		}
-
-	}
-
-	return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    pr_osl_cleanup
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	<none>
- *
- * DESCRIPTION: Module cleanup.
- *
- ****************************************************************************/
-
-static void __exit
-pr_osl_cleanup (void)
-{
-	pr_terminate();
-
-	if (pr_proc_root) {
-		remove_proc_entry(PR_PROC_ROOT, bm_proc_root);
-	}
-
-	return;
-}
-
-
-module_init(pr_osl_init);
-module_exit(pr_osl_cleanup);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/processor/prperf.c linux-2.4.22-pre2/drivers/acpi/ospm/processor/prperf.c
--- linux-2.4.21/drivers/acpi/ospm/processor/prperf.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/processor/prperf.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,456 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: prperf.c
- *              $Revision: 21 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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
- */
-
-/*
- * TBD: 1. Support ACPI 2.0 processor performance states (not just throttling).
- *      2. Fully implement thermal -vs- power management limit control.
- */
-
-
-#include <acpi.h>
-#include <bm.h>
-#include "pr.h"
-
-#define _COMPONENT		ACPI_PROCESSOR
-	MODULE_NAME		("prperf")
-
-
-/****************************************************************************
- *                                  Globals
- ****************************************************************************/
-
-extern fadt_descriptor_rev2	acpi_fadt;
-const u32			POWER_OF_2[] = {1,2,4,8,16,32,64,128,256,512};
-
-
-/****************************************************************************
- *
- * FUNCTION:    pr_perf_get_frequency
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-pr_perf_get_frequency (
-	PR_CONTEXT		*processor,
-	u32			*frequency) {
-	acpi_status		status = AE_OK;
-
-	FUNCTION_TRACE("pr_perf_get_frequency");
-
-	if (!processor || !frequency) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/* TBD: Generic method to calculate processor frequency. */
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    pr_perf_get_state
- *
- * PARAMETERS:
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-/* TBD:	Include support for _real_ performance states (not just throttling). */
-
-acpi_status
-pr_perf_get_state (
-	PR_CONTEXT              *processor,
-	u32                     *state)
-{
-	u32                     pblk_value = 0;
-	u32                     duty_mask = 0;
-	u32                     duty_cycle = 0;
-
-	FUNCTION_TRACE("pr_perf_get_state");
-
-	if (!processor || !state) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	if (processor->performance.state_count == 1) {
-		*state = 0;
-		return_ACPI_STATUS(AE_OK);
-	}
-
-	acpi_os_read_port(processor->pblk.address, &pblk_value, 32);
-
-	/*
-	 * Throttling Enabled?
-	 * -------------------
-	 * If so, calculate the current throttling state, otherwise return
-	 * '100% performance' (state 0).
-	 */
-	if (pblk_value & 0x00000010) {
-
-		duty_mask = processor->performance.state_count - 1;
-		duty_mask <<= acpi_fadt.duty_offset;
-
-		duty_cycle = pblk_value & duty_mask;
-		duty_cycle >>= acpi_fadt.duty_offset;
-
-		if (duty_cycle == 0) {
-			*state = 0;
-		}
-		else {
-			*state = processor->performance.state_count -
-				duty_cycle;
-		}
-	}
-	else {
-		*state = 0;
-	}
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Processor [%02x] is at performance state [%d%%].\n", processor->device_handle, processor->performance.state[*state].performance));
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    pr_perf_set_state
- *
- * PARAMETERS:
- *
- * RETURN:      AE_OK
- *              AE_BAD_PARAMETER
- *              AE_BAD_DATA         Invalid target throttling state.
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-/* TBD: Includes support for _real_ performance states (not just throttling). */
-
-acpi_status
-pr_perf_set_state (
-	PR_CONTEXT              *processor,
-	u32                     state)
-{
-	u32                     pblk_value = 0;
-	u32                     duty_mask = 0;
-	u32                     duty_cycle = 0;
-	u32                     i = 0;
-
-	FUNCTION_TRACE ("pr_perf_set_state");
-
-	if (!processor) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	if (state > (processor->performance.state_count - 1)) {
-		return_ACPI_STATUS(AE_BAD_DATA);
-	}
-
-	if ((state == processor->performance.active_state) ||
-		(processor->performance.state_count == 1)) {
-		return_ACPI_STATUS(AE_OK);
-	}
-
-	/*
-	 * Calculate Duty Cycle/Mask:
-	 * --------------------------
-	 * Note that we don't support duty_cycle values that span bit 4.
-	 */
-	if (state) {
-		duty_cycle = processor->performance.state_count - state;
-		duty_cycle <<= acpi_fadt.duty_offset;
-	}
-	else {
-		duty_cycle = 0;
-	}
-
-	duty_mask = ~((u32)(processor->performance.state_count - 1));
-	for (i=0; i<acpi_fadt.duty_offset; i++) {
-		duty_mask <<= acpi_fadt.duty_offset;
-		duty_mask += 1;
-	}
-
-	/*
-	 * Disable Throttling:
-	 * -------------------
-	 * Got to turn it off before you can change the duty_cycle value.
-	 * Throttling is disabled by writing a 0 to bit 4.
-	 */
-	acpi_os_read_port(processor->pblk.address, &pblk_value, 32);
-	if (pblk_value & 0x00000010) {
-		pblk_value &= 0xFFFFFFEF;
-		acpi_os_write_port(processor->pblk.address, pblk_value, 32);
-	}
-
-	/*
-	 * Set Duty Cycle:
-	 * ---------------
-	 * Mask off the old duty_cycle value, mask in the new.
-	 */
-	pblk_value &= duty_mask;
-	pblk_value |= duty_cycle;
-	acpi_os_write_port(processor->pblk.address, pblk_value, 32);
-
-	/*
-	 * Enable Throttling:
-	 * ------------------
-	 * But only for non-zero (non-100% performance) states.
-	 */
-	if (state) {
-		pblk_value |= 0x00000010;
-		acpi_os_write_port(processor->pblk.address, pblk_value, 32);
-	}
-
-	processor->performance.active_state = state;
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Processor [%02x] set to performance state [%d%%].\n", processor->device_handle, processor->performance.state[state].performance));
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    pr_perf_set_limit
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-pr_perf_set_limit (
-	PR_CONTEXT              *processor,
-	u32                     limit)
-{
-	acpi_status		status = AE_OK;
-	PR_PERFORMANCE		*performance = NULL;
-
-	FUNCTION_TRACE ("pr_perf_set_limit");
-
-	if (!processor) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	performance = &(processor->performance);
-
-	/*
-	 * Set Limit:
-	 * ----------
-	 * TBD:  Properly manage thermal and power limits (only set
-	 *	 performance state iff...).
-	 */
-	switch (limit) {
-
-	case PR_PERF_DEC:
-		if (performance->active_state <
-			(performance->state_count-1)) {
-			status = pr_perf_set_state(processor,
-				(performance->active_state+1));
-		}
-		break;
-
-	case PR_PERF_INC:
-		if (performance->active_state > 0) {
-			status = pr_perf_set_state(processor,
-				(performance->active_state-1));
-		}
-		break;
-
-	case PR_PERF_MAX:
-		if (performance->active_state != 0) {
-			status = pr_perf_set_state(processor, 0);
-		}
-		break;
-
-	default:
-		return_ACPI_STATUS(AE_BAD_DATA);
-		break;
-	}
-
-	if (ACPI_SUCCESS(status)) {
-		performance->thermal_limit = performance->active_state;
-	}
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Processor [%02x] thermal performance limit set to [%d%%].\n", processor->device_handle, processor->performance.state[performance->active_state].performance));
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *                             External Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:    pr_perf_add_device
- *
- * PARAMETERS:  processor		Our processor-specific context.
- *
- * RETURN:      AE_OK
- *              AE_BAD_PARAMETER
- *
- * DESCRIPTION: Calculates the number of throttling states and the state
- *              performance/power values.
- *
- ****************************************************************************/
-
-/* TBD: Support duty_cycle values that span bit 4. */
-
-acpi_status
-pr_perf_add_device (
-	PR_CONTEXT              *processor)
-{
-	acpi_status             status = AE_OK;
-	u32                     i = 0;
-	u32                     performance_step = 0;
-	u32                     percentage = 0;
-
-	FUNCTION_TRACE("pr_perf_add_device");
-
-	if (!processor) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Valid PBLK?
-	 * -----------
-	 * For SMP it is common to have the first (boot) processor have a
-	 * valid PBLK while all others do not -- which implies that
-	 * throttling has system-wide effects (duty_cycle programmed into
-	 * the chipset effects all processors).
-	 */
-	if ((processor->pblk.length < 6) || !processor->pblk.address) {
-		processor->performance.state_count = 1;
-	}
-
-	/*
-	 * Valid Duty Offset/Width?
-	 * ------------------------
-	 * We currently only support duty_cycle values that fall within
-	 * bits 0-3, as things get complicated when this value spans bit 4
-	 * (the throttling enable/disable bit).
-	 */
-	else if ((acpi_fadt.duty_offset + acpi_fadt.duty_width) > 4) {
-		processor->performance.state_count = 1;
-	}
-
-	/*
-	 * Compute State Count:
-	 * --------------------
-	 * The number of throttling states is computed as 2^duty_width,
-	 * but limited by PR_MAX_THROTTLE_STATES.  Note that a duty_width
-	 * of zero results is one throttling state (100%).
-	 */
-	else {
-		processor->performance.state_count =
-			POWER_OF_2[acpi_fadt.duty_width];
-	}
-
-	if (processor->performance.state_count > PR_MAX_THROTTLE_STATES) {
-		processor->performance.state_count = PR_MAX_THROTTLE_STATES;
-	}
-
-	/*
-	 * Compute State Values:
-	 * ---------------------
-	 * Note that clock throttling displays a linear power/performance
-	 * relationship (at 50% performance the CPU will consume 50% power).
-	 */
-	performance_step = (1000 / processor->performance.state_count);
-
-	for (i=0; i<processor->performance.state_count; i++) {
-		percentage = (1000 - (performance_step * i))/10;
-		processor->performance.state[i].performance = percentage;
-		processor->performance.state[i].power = percentage;
-	}
-
-	/*
-	 * Get Current State:
-	 * ------------------
-	 */
-	status = pr_perf_get_state(processor, &(processor->performance.active_state));
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Set to Maximum Performance:
-	 * ---------------------------
-	 * We'll let subsequent policy (e.g. thermal/power) decide to lower
-	 * performance if it so chooses, but for now crank up the speed.
-	 */
-	if (0 != processor->performance.active_state) {
-		status = pr_perf_set_state(processor, 0);
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    pr_perf_remove_device
- *
- * PARAMETERS:
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-pr_perf_remove_device (
-	PR_CONTEXT              *processor)
-{
-	acpi_status             status = AE_OK;
-
-	FUNCTION_TRACE("pr_perf_remove_device");
-
-	if (!processor) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	MEMSET(&(processor->performance), 0, sizeof(PR_PERFORMANCE));
-
-	return_ACPI_STATUS(status);
-}
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/processor/prpower.c linux-2.4.22-pre2/drivers/acpi/ospm/processor/prpower.c
--- linux-2.4.21/drivers/acpi/ospm/processor/prpower.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/processor/prpower.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,665 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: prpower.c
- *   $Revision: 32 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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
- */
-
-
-/* TBD: Linux specific */
-#include <linux/sched.h>
-#include <linux/pm.h>
-#include <asm/io.h>
-
-#include <acpi.h>
-#include <bm.h>
-#include "pr.h"
-
-#define _COMPONENT		ACPI_PROCESSOR
-	MODULE_NAME		("prpower")
-
-
-/****************************************************************************
- *                                  Globals
- ****************************************************************************/
-
-extern FADT_DESCRIPTOR		acpi_fadt;
-static u32			last_idle_jiffies = 0;
-static PR_CONTEXT		*processor_list[NR_CPUS];
-static void			(*pr_pm_idle_save)(void) = NULL;
-static u8			bm_control = 0;
-
-
-/* Used for PIIX4 errata handling. */
-unsigned short			acpi_piix4_bmisx = 0;
-
-
-/****************************************************************************
- *                             External Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:    pr_power_activate_state
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-void
-pr_power_activate_state (
-	PR_CONTEXT		*processor,
-	u32			next_state)
-{
-
-	PROC_NAME("pr_power_activate_state");
-
-	if (!processor) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid (NULL) context.\n"));
-		return;
-	}
-
-	processor->power.state[processor->power.active_state].promotion.count = 0;
-	processor->power.state[processor->power.active_state].demotion.count = 0;
-
-	/*
-	 * Cleanup from old state.
-	 */
-	switch (processor->power.active_state) {
-
-	case PR_C3:
-		/* Disable bus master reload */
-		acpi_hw_register_bit_access(ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK,
-			BM_RLD, 0);
-		break;
-	}
-
-	/*
-	 * Prepare to use new state.
-	 */
-	switch (next_state) {
-
-	case PR_C3:
-		/* Enable bus master reload */
-		acpi_hw_register_bit_access(ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK,
-			BM_RLD, 1);
-		break;
-	}
-
-	processor->power.active_state = next_state;
-	
-	return;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    pr_power_idle
- *
- * PARAMETERS:  <none>
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-void
-pr_power_idle (void)
-{
-	PR_CX			*c_state = NULL;
-	u32			next_state = 0;
-	u32			start_ticks, end_ticks, time_elapsed;
-	PR_CONTEXT		*processor = NULL;
-
-	PROC_NAME("pr_power_idle");
-
-	processor = processor_list[smp_processor_id()];
-
-	if (!processor || processor->power.active_state == PR_C0) {
-		return;
-	}
-
-	next_state = processor->power.active_state;
-
-	/*
-	 * Check OS Idleness:
-	 * ------------------
-	 * If the OS has been busy (hasn't called the idle handler in a while)
-	 * then automatically demote to the default power state (e.g. C1).
-	 *
-	 * TBD: Optimize by having scheduler determine business instead
-	 *      of having us try to calculate it.
-	 */
-	if (processor->power.active_state != processor->power.default_state) {
-		if ((jiffies - last_idle_jiffies) >= processor->power.busy_metric) {
-			next_state = processor->power.default_state;
-			if (next_state != processor->power.active_state) {
-				pr_power_activate_state(processor, next_state);
-			}
-		}
-	}
-
-	disable();
-
-	/*
-	 * Log BM Activity:
-	 * ----------------
-	 * Read BM_STS and record its value for later use by C3 policy.
-	 * (Note that we save the BM_STS values for the last 32 cycles).
-	 */
-	if (bm_control) {
-		processor->power.bm_activity <<= 1;
-		if (acpi_hw_register_bit_access(ACPI_READ, ACPI_MTX_DO_NOT_LOCK, BM_STS)) {
-			processor->power.bm_activity |= 1;
-			acpi_hw_register_bit_access(ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK,
-				BM_STS, 1);
-		}
-		else if (acpi_piix4_bmisx) {
-			/*
-			 * PIIX4 Errata:
-			 * -------------
-			 * This code is a workaround for errata #18 "C3 Power State/
-			 * BMIDE and Type-F DMA Livelock" from the July '01 PIIX4
-			 * specification update.  Note that BM_STS doesn't always
-			 * reflect the true state of bus mastering activity; forcing
-			 * us to manually check the BMIDEA bit of each IDE channel.
-			 */
-			if ((inb_p(acpi_piix4_bmisx + 0x02) & 0x01) ||
-				(inb_p(acpi_piix4_bmisx + 0x0A) & 0x01))
-				processor->power.bm_activity |= 1;
-		}
-	}
-
-	c_state = &(processor->power.state[processor->power.active_state]);
-
-	c_state->utilization++;
-
-	/*
-	 * Sleep:
-	 * ------
-	 * Invoke the current Cx state to put the processor to sleep.
-	 */
-	switch (processor->power.active_state) {
-
-	case PR_C1:
-		/* Invoke C1 */
-		enable(); halt();
-		/*
-	 * TBD: Can't get time duration while in C1, as resumes
-		 *      go to an ISR rather than here.
-		 */
-		time_elapsed = 0xFFFFFFFF;
-		break;
-
-	case PR_C2:
-		/* See how long we're asleep for */
-		acpi_get_timer(&start_ticks);
-		/* Invoke C2 */
-		acpi_os_read_port(processor->power.p_lvl2, NULL, 8);
-		/* Dummy op - must do something useless after P_LVL2 read */
-		acpi_hw_register_bit_access(ACPI_READ, ACPI_MTX_DO_NOT_LOCK, BM_STS);
-		/* Compute time elapsed */
-		acpi_get_timer(&end_ticks);
-		/* Re-enable interrupts */
-		enable();
-		acpi_get_timer_duration(start_ticks, end_ticks, &time_elapsed);
-		break;
-
-	case PR_C3:
-		/* Disable bus master arbitration */
-		acpi_hw_register_bit_access(ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK, ARB_DIS, 1);
-		/* See how long we're asleep for */
-		acpi_get_timer(&start_ticks);
-		/* Invoke C3 */
-		acpi_os_read_port(processor->power.p_lvl3, NULL, 8);
-		/* Dummy op - must do something useless after P_LVL3 read */
-		acpi_hw_register_bit_access(ACPI_READ, ACPI_MTX_DO_NOT_LOCK, BM_STS);
-		/* Compute time elapsed */
-		acpi_get_timer(&end_ticks);
-		/* Enable bus master arbitration */
-		acpi_hw_register_bit_access(ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK,
-			ARB_DIS, 0);
-		/* Re-enable interrupts */
-		enable();
-		acpi_get_timer_duration(start_ticks, end_ticks, &time_elapsed);
-		break;
-
-	default:
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Attempt to use unsupported power state C%d.\n", processor->power.active_state));
-		enable();
-		break;
-	}
-
-	/*
-	 * Promotion?
-	 * ----------
-	 * Track the number of successful sleeps (time asleep is greater
-	 * than time_threshold) and promote when count_threshold is
-	 * reached.
-	 */
-	if ((c_state->promotion.target_state) && 	
-		(time_elapsed >= c_state->promotion.time_threshold)) {
-
-		c_state->promotion.count++;
- 		c_state->demotion.count = 0;
-
-		if (c_state->promotion.count >= c_state->promotion.count_threshold) {
-			/*
-			 * Bus Mastering Activity, if active and used
-			 * by this state's promotion policy, prevents
-			 * promotions from occuring.
-			 */
-			if (!bm_control || !(processor->power.bm_activity & c_state->promotion.bm_threshold))
-				next_state = c_state->promotion.target_state;
-		}
-	}
-
-	/*
-	 * Demotion?
-	 * ---------
-	 * Track the number of shorts (time asleep is less than
-	 * time_threshold) and demote when count_threshold is reached.
-	 */
-	if (c_state->demotion.target_state) {
-			
-		if (time_elapsed < c_state->demotion.time_threshold) {
-
-			c_state->demotion.count++;
-			c_state->promotion.count = 0;
-
-			if (c_state->demotion.count >=
-				c_state->demotion.count_threshold) {
-				next_state = c_state->demotion.target_state;
-			}
-		}
-
-		/*
-		 * Bus Mastering Activity, if active and used by this
-		 * state's promotion policy, causes an immediate demotion
-		 * to occur.
-		 */
-		if (bm_control && (processor->power.bm_activity & c_state->demotion.bm_threshold))
-			next_state = c_state->demotion.target_state;
-	}
-
-	/*
-	 * New Cx State?
-	 * -------------
-	 * If we're going to start using a new Cx state we must clean up
-	 * from the previous and prepare to use the new.
-	 */
-	if (next_state != processor->power.active_state) {
-		pr_power_activate_state(processor, next_state);
-		processor->power.active_state = processor->power.active_state;
-	}
-
-	/*
-	 * Track OS Idleness:
-	 * ------------------
-	 * Record a jiffies timestamp to compute time elapsed between calls
-	 * to the idle handler.
-	 */
-	last_idle_jiffies = jiffies;
-
-	return;
-}
-
-
-/*****************************************************************************
- *
- * FUNCTION:    pr_power_set_default_policy
- *
- * PARAMETERS:
- *
- * RETURN:	
- *
- * DESCRIPTION: Sets the default Cx state policy (OS idle handler).  Our
- *              scheme is to promote quickly to C2 but more conservatively
- *              to C3.  We're favoring C2 for its characteristics of low
- *              latency (quick response), good power savings, and ability
- *              to allow bus mastering activity.
- *
- *              Note that Cx state policy is completely customizable, with
- *              the goal of having heuristics to alter policy dynamically.
- *
- ****************************************************************************/
-
-acpi_status
-pr_power_set_default_policy (
-	PR_CONTEXT                 *processor)
-{
-	FUNCTION_TRACE("pr_power_set_default_policy");
-
-	if (!processor) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Busy Metric:
-	 * ------------
-	 * Used to determine when the OS has been busy and thus when
-	 * policy should return to using the default Cx state (e.g. C1).
-	 * On Linux we use the number of jiffies (scheduler quantums)
-	 * that transpire between calls to the idle handler.
-	 *
-	 * TBD: Linux-specific.
-	 */
-	processor->power.busy_metric = 2;
-
-	/*
-	 * C1:
-	 * ---
-	 * C1 serves as our default state.  It must be valid.
-	 */
-	if (processor->power.state[PR_C1].is_valid) {
-		processor->power.active_state =
-			processor->power.default_state = PR_C1;
-	}
-	else {
-		processor->power.active_state =
-			processor->power.default_state = PR_C0;
-		return_ACPI_STATUS(AE_OK);
-	}
-
-	/*
-	 * C2:
-	 * ---
-	 * Set default C1 promotion and C2 demotion policies.
-	 */
-	if (processor->power.state[PR_C2].is_valid) {
-		/*
-		 * Promote from C1 to C2 anytime we're asleep in C1 for
-		 * longer than two times the C2 latency (to amortize cost
-		 * of transition).  Demote from C2 to C1 anytime we're
-		 * asleep in C2 for less than this time.
-		 */
-		processor->power.state[PR_C1].promotion.count_threshold = 10;
-		processor->power.state[PR_C1].promotion.time_threshold =
-			2 * processor->power.state[PR_C2].latency;
-		processor->power.state[PR_C1].promotion.target_state = PR_C2;
-
-		processor->power.state[PR_C2].demotion.count_threshold = 1;
-		processor->power.state[PR_C2].demotion.time_threshold =
-			2 * processor->power.state[PR_C2].latency;
-		processor->power.state[PR_C2].demotion.target_state = PR_C1;
-	}
-
-	/*
-	 * C3:
-	 * ---
-	 * Set default C2 promotion and C3 demotion policies.
-	 */
-	if ((processor->power.state[PR_C2].is_valid) &&
-		(processor->power.state[PR_C3].is_valid)) {
-		/*
-		 * Promote from C2 to C3 after 4 cycles of no bus
-		 * mastering activity (while maintaining sleep time
-		 * criteria).  Demote immediately on a short or
-		 * whenever bus mastering activity occurs.
-		 */
-		processor->power.state[PR_C2].promotion.count_threshold = 1;
-		processor->power.state[PR_C2].promotion.time_threshold =
-			2 * processor->power.state[PR_C3].latency;
-		processor->power.state[PR_C2].promotion.bm_threshold =
-			0x0000000F;
-		processor->power.state[PR_C2].promotion.target_state =
-			PR_C3;
-
-		processor->power.state[PR_C3].demotion.count_threshold = 1;
-		processor->power.state[PR_C3].demotion.time_threshold =
-			2 * processor->power.state[PR_C3].latency;
-		processor->power.state[PR_C3].demotion.bm_threshold =
-			0x0000000F;
-		processor->power.state[PR_C3].demotion.target_state =
-			PR_C2;
-	}
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-/*****************************************************************************
- *
- * FUNCTION:    pr_power_add_device
- *
- * PARAMETERS:  <none>
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-/*
- * TBD: 1. PROC_C1 support.
- *      2. Symmetric Cx state support (different Cx states supported
- *         by different CPUs results in lowest common denominator).
- */
-
-acpi_status
-pr_power_add_device (
-	PR_CONTEXT                 *processor)
-{
-	FUNCTION_TRACE("pr_power_add_device");
-
-	if (!processor) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * State Count:
-	 * ------------
-	 * Fixed at four (C0-C3).  We use is_valid to determine whether or
-	 * not a state actually gets used.
-	 */
-	processor->power.state_count = PR_MAX_POWER_STATES;
-
-	/*
-	 * C0:
-	 * ---
-	 * C0 exists only as filler in our array. (Let's assume its valid!)
-	 */
-	processor->power.state[PR_C0].is_valid = TRUE;
-
-	/*
-	 * C1:
-	 * ---
-	 * ACPI states that C1 must be supported by all processors
-	 * with a latency so small that it can be ignored.
-	 *
-	 * TBD: What about PROC_C1 support?
-	 */
-	processor->power.state[PR_C1].is_valid = TRUE;
-
-	/*
-	 * C2:
-	 * ---
-	 * We're only supporting C2 on UP systems with latencies <= 100us.
-	 *
-	 * TBD: Support for C2 on MP (P_LVL2_UP) -- I'm taking the
-	 *      conservative approach for now.
-	 */
-	processor->power.state[PR_C2].latency = acpi_fadt.plvl2_lat;
-
-#ifdef CONFIG_SMP
-	if (smp_num_cpus == 1) {
-#endif /*CONFIG_SMP*/
-		if (acpi_fadt.plvl2_lat <= PR_MAX_C2_LATENCY) {
-			processor->power.state[PR_C2].is_valid = TRUE;
-			processor->power.p_lvl2 = processor->pblk.address + 4;
-		}
-#ifdef CONFIG_SMP
-	}
-#endif /*CONFIG_SMP*/
-
-
-	/*
-	 * C3:
-	 * ---
-	 * We're only supporting C3 on UP systems with latencies <= 1000us,
-	 * and that include the ability to disable bus mastering while in
-	 * C3 (ARB_DIS) but allows bus mastering requests to wake the system
-	 * from C3 (BM_RLD).  Note his method of maintaining cache coherency
-	 * (disabling of bus mastering) cannot be used on SMP systems, and
-	 * flushing caches (e.g. WBINVD) is simply too costly at this time.
-	 *
-	 * TBD: Support for C3 on MP -- I'm taking the conservative
-	 *      approach for now.
-	 */
-	processor->power.state[PR_C3].latency = acpi_fadt.plvl3_lat;
-
-#ifdef CONFIG_SMP
-	if (smp_num_cpus == 1) {
-#endif /*CONFIG_SMP*/
-		if ((acpi_fadt.plvl3_lat <= PR_MAX_C3_LATENCY) && bm_control) {
-			processor->power.state[PR_C3].is_valid = TRUE;
-			processor->power.p_lvl3 = processor->pblk.address + 5;
-		}
-#ifdef CONFIG_SMP
-	}
-#endif /*CONFIG_SMP*/
-
-	/*
-	 * Set Default Policy:
-	 * -------------------
-	 * Now that we know which state are supported, set the default
-	 * policy.  Note that this policy can be changed dynamically
-	 * (e.g. encourage deeper sleeps to conserve battery life when
-	 * not on AC).
-	 */
-	pr_power_set_default_policy(processor);
-
-	/*
-	 * Save Processor Context:
-	 * -----------------------
-	 * TBD: Enhance Linux idle handler to take processor context
-	 *      parameter.
-	 */
-	processor_list[processor->uid] = processor;
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    pr_power_remove_device
- *
- * PARAMETERS:
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-pr_power_remove_device (
-	PR_CONTEXT              *processor)
-{
-	acpi_status             status = AE_OK;
-
-	FUNCTION_TRACE("pr_power_remove_device");
-
-	if (!processor) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	MEMSET(&(processor->power), 0, sizeof(PR_POWER));
-
-	processor_list[processor->uid] = NULL;
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    pr_power_initialize
- *
- * PARAMETERS:  <none>
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-pr_power_initialize (void)
-{
-	u32			i = 0;
-
-	FUNCTION_TRACE("pr_power_initialize");
-
-	/* TBD: Linux-specific. */
-	for (i=0; i<NR_CPUS; i++) {
-		processor_list[i] = NULL;
-	}
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Max CPUs[%d], this CPU[%d].\n", NR_CPUS, smp_processor_id()));
-
-	/* Only use C3 if we can control bus mastering. */
-	if (acpi_fadt.V1_pm2_cnt_blk && acpi_fadt.pm2_cnt_len)
-		bm_control = 1;
-
-	/*
-	 * Install idle handler.
-	 *
-	 * TBD: Linux-specific (need OSL function).
-	 */
-	pr_pm_idle_save = pm_idle;
-	pm_idle = pr_power_idle;
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    pr_power_terminate
- *
- * PARAMETERS:  <none>
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-pr_power_terminate (void)
-{
-	FUNCTION_TRACE("pr_power_terminate");
-
-	/*
-	 * Remove idle handler.
-	 *
-	 * TBD: Linux-specific (need OSL function).
-	 */
-	pm_idle = pr_pm_idle_save;
-
-	return_ACPI_STATUS(AE_OK);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/system/Makefile linux-2.4.22-pre2/drivers/acpi/ospm/system/Makefile
--- linux-2.4.21/drivers/acpi/ospm/system/Makefile	2001-06-21 00:47:40.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/system/Makefile	1970-01-01 00:00:00.000000000 +0000
@@ -1,6 +0,0 @@
-O_TARGET	:= ospm_$(notdir $(CURDIR)).o
-obj-m		:= $(O_TARGET)
-EXTRA_CFLAGS	+= $(ACPI_CFLAGS)
-obj-y		:= $(patsubst %.c,%.o,$(wildcard *.c))
-
-include $(TOPDIR)/Rules.make
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/system/sm.c linux-2.4.22-pre2/drivers/acpi/ospm/system/sm.c
--- linux-2.4.21/drivers/acpi/ospm/system/sm.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/system/sm.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,373 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: sm.c
- *   $Revision: 20 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <acpi.h>
-#include "sm.h"
-
-
-#define _COMPONENT		ACPI_SYSTEM
-	MODULE_NAME 		("sm")
-
-
-/****************************************************************************
- *                            Internal Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:	sm_print
- *
- * PARAMETERS:	
- *
- * RETURN:	
- *
- * DESCRIPTION: Prints out information on a specific system.
- *
- ****************************************************************************/
-
-void
-sm_print (
-	SM_CONTEXT		*system)
-{
-#ifdef ACPI_DEBUG
-	acpi_buffer		buffer;
-
-	PROC_NAME("sm_print");
-
-	buffer.length = 256;
-	buffer.pointer = acpi_os_callocate(buffer.length);
-	if (!buffer.pointer) {
-		return;
-	}
-
-	/*
-	 * Get the full pathname for this ACPI object.
-	 */
-	acpi_get_name(system->acpi_handle, ACPI_FULL_PATHNAME, &buffer);
-
-	/*
-	 * Print out basic system information.
-	 */
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "| System[%02x]:[%p] %s\n", system->device_handle, system->acpi_handle, (char*)buffer.pointer));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   states: %cS0 %cS1 %cS2 %cS3 %cS4 %cS5\n", (system->states[0]?'+':'-'), (system->states[1]?'+':'-'), (system->states[2]?'+':'-'), (system->states[3]?'+':'-'), (system->states[4]?'+':'-'), (system->states[5]?'+':'-')));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
-
-	acpi_os_free(buffer.pointer);
-#endif /*ACPI_DEBUG*/
-
-	return;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	sm_add_device
- *
- * PARAMETERS:	
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-sm_add_device(
-	BM_HANDLE		device_handle,
-	void			**context)
-{
-	acpi_status 		status = AE_OK;
-	BM_DEVICE		*device = NULL;
-	SM_CONTEXT		*system = NULL;
-	u8			i, type_a, type_b;
-
-
-	FUNCTION_TRACE("sm_add_device");
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Adding system device [%02x].\n", device_handle));
-
-	if (!context || *context) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid (NULL) context."));
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Allocate a new SM_CONTEXT structure.
-	 */
-	system = acpi_os_callocate(sizeof(SM_CONTEXT));
-	if (!system) {
-		return_ACPI_STATUS(AE_NO_MEMORY);
-	}
-
-	/*
-	 * Get information on this device.
-	 */
-	status = bm_get_device_info(device_handle, &device);
-	if (ACPI_FAILURE(status)) {
-		goto end;
-	}
-
-	system->device_handle = device->handle;
-	system->acpi_handle = device->acpi_handle;
-
-	/*
-	 * Sx States:
-	 * ----------
-	 * Figure out which Sx states are supported.
-	 */
-	for (i=0; i<SM_MAX_SYSTEM_STATES; i++) {
-		if (ACPI_SUCCESS(acpi_hw_obtain_sleep_type_register_data(
-			i,
-			&type_a,
-			&type_b))) {
-			system->states[i] = TRUE;
-		}
-	}
-
-	status = sm_osl_add_device(system);
-	if (ACPI_FAILURE(status)) {
-		goto end;
-	}
-
-	*context = system;
-
-	sm_print(system);
-
-end:
-	if (ACPI_FAILURE(status)) {
-		acpi_os_free(system);
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	sm_remove_device
- *
- * PARAMETERS:	
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-sm_remove_device (
-	void			**context)
-{
-	acpi_status 		status = AE_OK;
-	SM_CONTEXT		*system = NULL;
-
-	FUNCTION_TRACE("sm_remove_device");
-
-	if (!context || !*context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	system = (SM_CONTEXT*)*context;
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing system device [%02x].\n", system->device_handle));
-
-	status = sm_osl_remove_device(system);
-
-	acpi_os_free(system);
-
-	*context = NULL;
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *                             External Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:	sm_initialize
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-sm_initialize (void)
-{
-	acpi_status		status = AE_OK;
-	BM_DEVICE_ID		criteria;
-	BM_DRIVER		driver;
-
-	FUNCTION_TRACE("sm_initialize");
-
-	MEMSET(&criteria, 0, sizeof(BM_DEVICE_ID));
-	MEMSET(&driver, 0, sizeof(BM_DRIVER));
-
-	/*
-	 * Register driver for the System device.
-	 */
-	criteria.type = BM_TYPE_SYSTEM;
-
-	driver.notify = &sm_notify;
-	driver.request = &sm_request;
-
-	status = bm_register_driver(&criteria, &driver);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	sm_terminate
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-sm_terminate (void)
-{
-	acpi_status 		status = AE_OK;
-	BM_DEVICE_ID		criteria;
-	BM_DRIVER		driver;
-
-	FUNCTION_TRACE("sm_terminate");
-
-	MEMSET(&criteria, 0, sizeof(BM_DEVICE_ID));
-	MEMSET(&driver, 0, sizeof(BM_DRIVER));
-
-	/*
-	 * Unregister driver for System devices.
-	 */
-	criteria.type = BM_TYPE_SYSTEM;
-
-	driver.notify = &sm_notify;
-	driver.request = &sm_request;
-
-	status = bm_unregister_driver(&criteria, &driver);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/*****************************************************************************
- *
- * FUNCTION:	sm_notify
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-acpi_status
-sm_notify (
-	BM_NOTIFY		notify_type,
-	BM_HANDLE		device_handle,
-	void			**context)
-{
-	acpi_status 		status = AE_OK;
-
-	FUNCTION_TRACE("sm_notify");
-
-	if (!context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	switch (notify_type) {
-
-	case BM_NOTIFY_DEVICE_ADDED:
-		status = sm_add_device(device_handle, context);
-		break;
-
-	case BM_NOTIFY_DEVICE_REMOVED:
-		status = sm_remove_device(context);
-		break;
-
-	default:
-		status = AE_SUPPORT;
-		break;
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	sm_request
- *
- * PARAMETERS:	
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-sm_request (
-	BM_REQUEST		*request,
-	void			*context)
-{
-	acpi_status 		status = AE_OK;
-
-	FUNCTION_TRACE("sm_request");
-
-	/*
-	 * Must have a valid request structure and context.
-	 */
-	if (!request || !context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Handle Request:
-	 * ---------------
-	 */
-	switch (request->command) {
-
-	default:
-		status = AE_SUPPORT;
-		break;
-	}
-
-	request->status = status;
-
-	return_ACPI_STATUS(status);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/system/sm_osl.c linux-2.4.22-pre2/drivers/acpi/ospm/system/sm_osl.c
--- linux-2.4.21/drivers/acpi/ospm/system/sm_osl.c	2002-11-28 23:53:12.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/system/sm_osl.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,922 +0,0 @@
-/******************************************************************************
- *
- * Module Name: sm_osl.c
- *   $Revision: 16 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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/proc_fs.h>
-#include <linux/pm.h>
-#include <asm/uaccess.h>
-#include <linux/acpi.h>
-#include <asm/io.h>
-#include <linux/mc146818rtc.h>
-#include <linux/delay.h>
-
-#include <acpi.h>
-#include "sm.h"
-
-
-MODULE_AUTHOR("Andrew Grover");
-MODULE_DESCRIPTION("ACPI Component Architecture (CA) - ACPI System Driver");
-MODULE_LICENSE("GPL");
-
-
-#define SM_PROC_INFO		"info"
-#define SM_PROC_DSDT		"dsdt"
-
-extern struct proc_dir_entry	*bm_proc_root;
-struct proc_dir_entry		*sm_proc_root = NULL;
-static void 			(*sm_pm_power_off)(void) = NULL;
-
-static ssize_t sm_osl_read_dsdt(struct file *, char *, size_t, loff_t *);
-
-static struct file_operations proc_dsdt_operations = {
-	read:		sm_osl_read_dsdt,
-};
-
-static acpi_status sm_osl_suspend(u32 state);
-
-struct proc_dir_entry *bm_proc_sleep;
-struct proc_dir_entry *bm_proc_alarm;
-struct proc_dir_entry *bm_proc_gpe;
-
-static int
-sm_osl_proc_read_sleep (
-        char                    *page,
-        char                    **start,
-        off_t                   off,
-        int                     count,
-        int                     *eof,
-        void                    *context)
-{
-	SM_CONTEXT    *system = (SM_CONTEXT*) context;
-	char          *str = page;
-	int           len;
-	int           i;
-
-	if (!system)
-               goto end;
-
-	if (off != 0)
-               goto end;
-
-	for (i = 0; i <= ACPI_S5; i++) {
-		if (system->states[i])
-			str += sprintf(str,"S%d ", i);
-	}
-
-	str += sprintf(str, "\n");
-
-end:
-
-	len = (str - page);
-	if (len < (off + count))
-		*eof = 1;
-
-	*start = page + off;
-	len -= off;
-
-	if (len > count)
-		len = count;
-
-	if (len < 0)
-		len = 0;
-
-	return (len);
-}
-
-int sm_osl_proc_write_sleep (struct file *file,
-			     const char *buffer,
-			     unsigned long count,
-			     void *data)
-{
-	SM_CONTEXT    *system = (SM_CONTEXT*) data;
-	char          str[10];
-	char          *strend;
-	unsigned long value;
-	
-	if (count > (sizeof(str) - 1))
-		return -EINVAL;
-	
-	if (copy_from_user(str,buffer,count))
-		return -EFAULT;
-	
-	str[count] = '\0';
-	
-	value = simple_strtoul(str,&strend,0);
-	if (str == strend)
-		return -EINVAL;
-	
-	if (value == 0 || value >= ACPI_S5)
-		return -EINVAL;
-	
-	/*
-	 * make sure that the sleep state is supported
-	 */
-	if (system->states[value] != TRUE)
-		return -EINVAL;
-	
-	sm_osl_suspend(value);
-	
-	return (count);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	sm_osl_proc_read_info
- *
- ****************************************************************************/
-
-static int
-sm_osl_proc_read_info (
-	char			*page,
-	char			**start,
-	off_t			off,
-	int 			count,
-	int 			*eof,
-	void			*context)
-{
-	acpi_status		status = AE_OK;
-	SM_CONTEXT		*system = NULL;
-	char			*p = page;
-	int			len;
-	acpi_system_info	system_info;
-	acpi_buffer		buffer;
-	u32			i = 0;
-
-	if (!context) {
-		goto end;
-	}
-
-	system = (SM_CONTEXT*) context;
-
-	/* don't get status more than once for a single proc read */
-	if (off != 0) {
-		goto end;
-	}
-
-	/*
-	 * Get ACPI CA Information.
-	 */
-	buffer.length  = sizeof(system_info);
-	buffer.pointer = &system_info;
-
-	status = acpi_get_system_info(&buffer);
-	if (ACPI_FAILURE(status)) {
-		p += sprintf(p, "ACPI-CA Version:         unknown\n");
-	}
-	else {
-		p += sprintf(p, "ACPI-CA Version:         %x\n",
-			system_info.acpi_ca_version);
-	}
-
-	p += sprintf(p, "Sx States Supported:     ");
-	for (i=0; i<SM_MAX_SYSTEM_STATES; i++) {
-		if (system->states[i]) {
-			p += sprintf(p, "S%d ", i);
-		}
-	}
-	p += sprintf(p, "\n");
-
-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(len);
-}
-
-/****************************************************************************
- *
- * FUNCTION:	sm_osl_read_dsdt
- *
- ****************************************************************************/
-
-static ssize_t
-sm_osl_read_dsdt(
-	struct file		*file,
-	char			*buf,
-	size_t			count,
-	loff_t			*ppos)
-{
-	acpi_buffer		acpi_buf;
-	void			*data;
-	size_t			size = 0;
-
-	acpi_buf.length = 0;
-	acpi_buf.pointer = NULL;
-
-
-	/* determine what buffer size we will need */
-	if (acpi_get_table(ACPI_TABLE_DSDT, 1, &acpi_buf) != AE_BUFFER_OVERFLOW) {
-		return 0;
-	}
-
-	acpi_buf.pointer = kmalloc(acpi_buf.length, GFP_KERNEL);
-	if (!acpi_buf.pointer) {
-		return -ENOMEM;
-	}
-
-	/* get the table for real */
-	if (!ACPI_SUCCESS(acpi_get_table(ACPI_TABLE_DSDT, 1, &acpi_buf))) {
-		kfree(acpi_buf.pointer);
-		return 0;
-	}
-
-	if (*ppos < acpi_buf.length) {
-		data = acpi_buf.pointer + file->f_pos;
-		size = acpi_buf.length - file->f_pos;
-		if (size > count)
-			size = count;
-		if (copy_to_user(buf, data, size)) {
-			kfree(acpi_buf.pointer);
-			return -EFAULT;
-		}
-	}
-
-	kfree(acpi_buf.pointer);
-
-	*ppos += size;
-
-	return size;
-}
-
-static int
-sm_osl_proc_read_alarm (
-	char                    *page,
-	char                    **start,
-	off_t                   off,
-	int                     count,
-	int                     *eof,
-	void                    *context)
-{
-	char *str = page;
-	int len;
-	u32 sec,min,hr;
-	u32 day,mo,yr;
-
-	if (off != 0) goto out;
-
-	spin_lock(&rtc_lock);
-	sec = CMOS_READ(RTC_SECONDS_ALARM);
-	min = CMOS_READ(RTC_MINUTES_ALARM);
-	hr = CMOS_READ(RTC_HOURS_ALARM);
-
-#if 0
-	/* if I ever get an FACP with proper values, maybe I'll enable this code */
-	if (acpi_gbl_FADT->day_alrm)
-		day = CMOS_READ(acpi_gbl_FADT->day_alrm);
-	else
-		day =  CMOS_READ(RTC_DAY_OF_MONTH);
-	if (acpi_gbl_FADT->mon_alrm)
-		mo = CMOS_READ(acpi_gbl_FADT->mon_alrm);
-	else
-		mo = CMOS_READ(RTC_MONTH);;
-	if (acpi_gbl_FADT->century)
-		yr = CMOS_READ(acpi_gbl_FADT->century) * 100 + CMOS_READ(RTC_YEAR);
-	else
-		yr = CMOS_READ(RTC_YEAR);
-#else
-	day = CMOS_READ(RTC_DAY_OF_MONTH);
-	mo = CMOS_READ(RTC_MONTH);
-	yr = CMOS_READ(RTC_YEAR);
-#endif
-	spin_unlock(&rtc_lock);
-
-	BCD_TO_BIN(sec);
-	BCD_TO_BIN(min);
-	BCD_TO_BIN(hr);
-	BCD_TO_BIN(day);
-	BCD_TO_BIN(mo);
-	BCD_TO_BIN(yr);
-
-	str += sprintf(str,"%4.4u-",yr);
-
-	str += (mo > 12) ?
-		sprintf(str,"**-") :
-		sprintf(str,"%2.2u-",mo);
-
-	str += (day > 31) ?
-		sprintf(str,"** ") :
-		sprintf(str,"%2.2u ",day);
-
-	str += (hr > 23) ?
-		sprintf(str,"**:") :
-		sprintf(str,"%2.2u:",hr);
-
-	str += (min > 59) ?
-		sprintf(str,"**:") :
-		sprintf(str,"%2.2u:",min);
-
-	str += (sec > 59) ?
-		sprintf(str,"**\n") :
-		sprintf(str,"%2.2u\n",sec);
-
- out:
-	len = str - page;
-
-	if (len < count) *eof = 1;
-	else if (len > count) len = count;
-
-	if (len < 0) len = 0;
-
-	*start = page;
-
-	return len;
-}
-
-static int get_date_field(char **str, u32 *value)
-{
-	char *next,*strend;
-	int error = -EINVAL;
-
-	/* try to find delimeter, only to insert null;
-	 *  the end of string won't have one, but is still valid
-	 */
-	next = strpbrk(*str,"- :");
-	if (next) *next++ = '\0';
-
-	*value = simple_strtoul(*str,&strend,10);
-
-	/* signal success if we got a good digit */
-	if (strend != *str) error = 0;
-
-	if (next) *str = next;
-	return error;
-}
-
-
-
-int sm_osl_proc_write_alarm (
-	struct file *file,
-	const char *buffer,
-	unsigned long count,
-	void *data)
-{
-	char buf[30];
-	char *str = buf;
-	u32 sec,min,hr;
-	u32 day,mo,yr;
-	int adjust = 0;
-	unsigned char rtc_control;
-	int error = -EINVAL;
-
-	if (count > sizeof(buf) - 1) return -EINVAL;
-	
-	if (copy_from_user(str,buffer,count)) return -EFAULT;
-
-	str[count] = '\0';
-	/* check for time adjustment */
-	if (str[0] == '+') {
-		str++;
-		adjust = 1;
-	}
-
-	if ((error = get_date_field(&str,&yr)))  goto out;
-	if ((error = get_date_field(&str,&mo)))  goto out;
-	if ((error = get_date_field(&str,&day))) goto out;
-	if ((error = get_date_field(&str,&hr)))  goto out;
-	if ((error = get_date_field(&str,&min))) goto out;
-	if ((error = get_date_field(&str,&sec))) goto out;
-
-
-	if (sec > 59) {
-		min += 1;
-		sec -= 60;
-	}
-	if (min > 59) {
-		hr += 1;
-		min -= 60;
-	} 
-	if (hr > 23) {
-		day += 1;
-		hr -= 24;
-	}
-	if (day > 31) { 
-		mo += 1;
-		day -= 31;
-	}
-	if (mo > 12) {
-		yr += 1;
-		mo -= 12;
-	}
-
-	spin_lock_irq(&rtc_lock);
-	rtc_control = CMOS_READ(RTC_CONTROL);
-	if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
-		BIN_TO_BCD(yr);
-		BIN_TO_BCD(mo);
-		BIN_TO_BCD(day);
-		BIN_TO_BCD(hr);
-		BIN_TO_BCD(min);
-		BIN_TO_BCD(sec);
-	}
-
-	if (adjust) {
-		yr  += CMOS_READ(RTC_YEAR);
-		mo  += CMOS_READ(RTC_MONTH);
-		day += CMOS_READ(RTC_DAY_OF_MONTH);
-		hr  += CMOS_READ(RTC_HOURS);
-		min += CMOS_READ(RTC_MINUTES);
-		sec += CMOS_READ(RTC_SECONDS);
-	}
-	spin_unlock_irq(&rtc_lock);
-
-	if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
-		BCD_TO_BIN(yr);
-		BCD_TO_BIN(mo);
-		BCD_TO_BIN(day);
-		BCD_TO_BIN(hr);
-		BCD_TO_BIN(min);
-		BCD_TO_BIN(sec);
-	}
-
-	if (sec > 59) {
-		min++;
-		sec -= 60;
-	}
-	if (min > 59) {
-		hr++;
-		min -= 60;
-	}
-	if (hr > 23) {
-		day++;
-		hr -= 24;
-	}
-	if (day > 31) {
-		mo++;
-		day -= 31;
-	}
-	if (mo > 12) {
-		yr++;
-		mo -= 12;
-	}
-	if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
-		BIN_TO_BCD(yr);
-		BIN_TO_BCD(mo);
-		BIN_TO_BCD(day);
-		BIN_TO_BCD(hr);
-		BIN_TO_BCD(min);
-		BIN_TO_BCD(sec);
-	}
-
-	spin_lock_irq(&rtc_lock);
-	/* write the fields the rtc knows about */
-	CMOS_WRITE(hr,RTC_HOURS_ALARM);
-	CMOS_WRITE(min,RTC_MINUTES_ALARM);
-	CMOS_WRITE(sec,RTC_SECONDS_ALARM);
-
-	/* If the system supports an enhanced alarm, it will have non-zero
-	 * offsets into the CMOS RAM here.
-	 * Which for some reason are pointing to the RTC area of memory.
-	 */
-#if 0
-	if (acpi_gbl_FADT->day_alrm) CMOS_WRITE(day,acpi_gbl_FADT->day_alrm);
-	if (acpi_gbl_FADT->mon_alrm) CMOS_WRITE(mo,acpi_gbl_FADT->mon_alrm);
-	if (acpi_gbl_FADT->century)  CMOS_WRITE(yr / 100,acpi_gbl_FADT->century);
-#endif
-	/* enable the rtc alarm interrupt */
-	if (!(rtc_control & RTC_AIE)) {
-		rtc_control |= RTC_AIE;
-		CMOS_WRITE(rtc_control,RTC_CONTROL);
-		CMOS_READ(RTC_INTR_FLAGS);
-	}
-
-	/* unlock the lock on the rtc now that we're done with it */
-	spin_unlock_irq(&rtc_lock);
-
-	acpi_hw_register_bit_access(ACPI_WRITE,ACPI_MTX_LOCK, RTC_EN, 1);
-
-	file->f_pos += count;
-
-	error = 0;
- out:
-	return error ? error : count;
-}
-
-static int 
-sm_osl_proc_read_gpe(
-	char                    *page,
-	char                    **start,
-	off_t                   off,
-	int                     count,
-	int                     *eof,
-	void                    *context)
-{
-	char *str = page;
-	int size;
-	int length;
-	int i;
-	u32 addr,data;
-	
-	if (off) goto out;
-
-	if (acpi_gbl_FADT->V1_gpe0blk) {
-		length = acpi_gbl_FADT->gpe0blk_len / 2;
-
-		str += sprintf(str,"GPE0: ");
-
-		for (i = length; i > 0; i--) {
-			addr = GPE0_EN_BLOCK | (i - 1);
-			data = acpi_hw_register_read(ACPI_MTX_LOCK,addr);
-			str += sprintf(str,"%2.2x ",data);
-		}
-		str += sprintf(str,"\n");
-
-		str += sprintf(str,"Status: ");
-		for (i = length; i > 0; i--) {
-			addr = GPE0_STS_BLOCK | (i - 1);
-			data = acpi_hw_register_read(ACPI_MTX_LOCK,addr);
-			str += sprintf(str,"%2.2x ",data);
-		}
-		str += sprintf(str,"\n");
-	}
-
-	if (acpi_gbl_FADT->V1_gpe1_blk) {
-		length = acpi_gbl_FADT->gpe1_blk_len / 2;
-
-
-		str += sprintf(str,"GPE1: ");
-		for (i = length; i > 0; i--) {
-			addr = GPE1_EN_BLOCK | (i - 1);
-			data = acpi_hw_register_read(ACPI_MTX_LOCK,addr);
-			str += sprintf(str,"%2.2x",data);
-		}
-		str += sprintf(str,"\n");
-
-		str += sprintf(str,"Status: ");
-		for (i = length; i > 0; i--) {
-			addr = GPE1_STS_BLOCK | (i - 1);
-			data = acpi_hw_register_read(ACPI_MTX_LOCK,addr);
-			str += sprintf(str,"%2.2x",data);
-		}
-		str += sprintf(str,"\n");
-	}
- out:
-	size = str - page;
-	if (size < count) *eof = 1;
-	else if (size > count) size = count;
-
-	if (size < 0) size = 0;
-	*start = page;
-
-	return size;
-}
-
-static int
-sm_osl_proc_write_gpe (
-	struct file *file,
-	const char *buffer,
-	unsigned long count,
-	void *data)
-{
-	char buf[256];
-	char *str = buf;
-	char *next;
-	int error = -EINVAL;
-	u32 addr,value = 0;
-
-	if (count > sizeof(buf) + 1) return -EINVAL;
-	
-	if (copy_from_user(str,buffer,count)) return -EFAULT;
-
-	str[count] = '\0';
-
-	/* set addr to which block to refer to */
-	if (!strncmp(str,"GPE0 ",5))      addr = GPE0_EN_BLOCK;
-	else if (!strncmp(str,"GPE1 ",5)) addr = GPE1_EN_BLOCK;
-	else goto out;
-
-	str += 5;
-
-	/* set low order bits to index of bit to set */
-	addr |= simple_strtoul(str,&next,0);
-	if (next == str) goto out;
-
-	if (next) {
-		str = ++next;
-		value = simple_strtoul(str,&next,0);
-		if (next == str) value = 1;
-	}
-
-	value = acpi_hw_register_bit_access(ACPI_WRITE,ACPI_MTX_LOCK,addr,(value ? 1 : 0));
-
-	error = 0;
- out:
-	return error ? error : count;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    sm_osl_suspend
- *
- * PARAMETERS:  %state: Sleep state to enter. Assumed that caller has filtered
- *              out bogus values, so it's one of S1, S2, S3 or S4
- *
- * RETURN:      ACPI_STATUS, whether or not we successfully entered and
- *              exited sleep.
- *
- * DESCRIPTION:
- * This function is the meat of the sleep routine, as far as the ACPI-CA is
- * concerned.
- *
- * See Chapter 9 of the ACPI 2.0 spec for details concerning the methodology here.
- *
- * It will do the following things:
- * - Call arch-specific routines to save the processor and kernel state
- * - Call acpi_enter_sleep_state to actually go to sleep
- * ....
- * When we wake back up, we will:
- * - Restore the processor and kernel state
- * - Return to the user
- *
- * By having this routine in here, it hides it from every part of the CA,
- * so it can remain OS-independent. The only function that calls this is
- * sm_proc_write_sleep, which gets the sleep state to enter from the user.
- *
- ****************************************************************************/
-static acpi_status
-sm_osl_suspend(u32 state)
-{
-	acpi_status status = AE_ERROR;
-	unsigned long wakeup_address;
-
-	/* get out if state is invalid */
-	if (state < ACPI_S1 || state > ACPI_S5) 
-		goto acpi_sleep_done;
-
-	/* make sure we don't get any suprises */
-	disable();
-
-	/* TODO: save device state and suspend them */
-	
-	/* save the processor state to memory if going into S2 or S3;
-	 * save it to disk if going into S4.
-	 * Also, set the FWV if going into an STR state
-	 */
-	if (state == ACPI_S2 || state == ACPI_S3) {
-#ifdef DONT_USE_UNTIL_LOWLEVEL_CODE_EXISTS
-		/* That && trick is *not going to work*. Read gcc
-		   specs. That explicitely says: jumping from other
-		   function is *not allowed*. */ 
-		wakeup_address = acpi_save_state_mem((unsigned long)&&acpi_sleep_done);
-
-		if (!wakeup_address) goto acpi_sleep_done;
-
-		acpi_set_firmware_waking_vector(
-			(ACPI_PHYSICAL_ADDRESS)wakeup_address);
-#endif
-	} else if (state == ACPI_S4)
-#ifdef DONT_USE_UNTIL_LOWLEVEL_CODE_EXISTS
-		if (acpi_save_state_disk((unsigned long)&&acpi_sleep_done)) 
-			goto acpi_sleep_done;
-#endif
-
-	/* set status, since acpi_enter_sleep_state won't return unless something
-	 * goes wrong, or it's just S1.
-	 */
-	status = AE_OK;
-
-	mdelay(10);
-	status = acpi_enter_sleep_state(state);
-
- acpi_sleep_done:
-
-	/* pause for a bit to allow devices to come back on */
-	mdelay(10);
-
-	/* make sure that the firmware waking vector is reset */
-	acpi_set_firmware_waking_vector((ACPI_PHYSICAL_ADDRESS)0);
-
-	acpi_leave_sleep_state(state);
-
-	/* TODO: resume devices and restore their state */
-
-	enable();
-	return status;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	sm_osl_power_down
- *
- ****************************************************************************/
-
-void
-sm_osl_power_down (void)
-{
-	/* Power down the system (S5 = soft off). */
-	sm_osl_suspend(ACPI_S5);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	sm_osl_add_device
- *
- ****************************************************************************/
-
-acpi_status
-sm_osl_add_device(
-	SM_CONTEXT		*system)
-{
-	u32			i = 0;
-	struct proc_dir_entry	*bm_proc_dsdt;
-
-	if (!system) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	printk("ACPI: System firmware supports");
-	for (i=0; i<SM_MAX_SYSTEM_STATES; i++) {
-		if (system->states[i]) {
-			printk(" S%d", i);
-		}
-	}
-	printk("\n");
-
-	if (system->states[ACPI_STATE_S5]) {
-		sm_pm_power_off = pm_power_off;
-		pm_power_off = sm_osl_power_down;
-	}
-
-	create_proc_read_entry(SM_PROC_INFO, S_IRUGO,
-		sm_proc_root, sm_osl_proc_read_info, (void*)system);
-
-	bm_proc_sleep = create_proc_read_entry("sleep", S_IFREG | S_IRUGO | S_IWUSR,
-					    sm_proc_root, sm_osl_proc_read_sleep, (void*)system);
-	if (bm_proc_sleep)
-		bm_proc_sleep->write_proc = sm_osl_proc_write_sleep;
-
-	bm_proc_alarm = create_proc_read_entry("alarm", S_IFREG | S_IRUGO | S_IWUSR,
-					       sm_proc_root,sm_osl_proc_read_alarm, NULL);
-	if (bm_proc_alarm)
-		bm_proc_alarm->write_proc = sm_osl_proc_write_alarm;
-
-	bm_proc_gpe = create_proc_read_entry("gpe", S_IFREG | S_IRUGO | S_IWUSR,
-					     sm_proc_root,sm_osl_proc_read_gpe,NULL);
-	if (bm_proc_gpe)
-		bm_proc_gpe->write_proc = sm_osl_proc_write_gpe;
-	
-	/*
-	 * Get a wakeup address for use when we come back from sleep.
-	 * At least on IA-32, this needs to be in low memory.
-	 * When sleep is supported on other arch's, then we may want
-	 * to move this out to another place, but GFP_LOW should suffice
-	 * for now.
-	 */
-#if 0
-	if (system->states[ACPI_S3] || system->states[ACPI_S4]) {
-		acpi_wakeup_address = (unsigned long)virt_to_phys(get_free_page(GFP_LOWMEM));
-		printk(KERN_INFO "ACPI: Have wakeup address 0x%8.8x\n",acpi_wakeup_address);
-	}
-#endif
-
-	/*
-	 * This returns more than a page, so we need to use our own file ops,
-	 * not proc's generic ones
-	 */
-	bm_proc_dsdt = create_proc_entry(SM_PROC_DSDT, S_IRUSR, sm_proc_root);
-	if (bm_proc_dsdt) {
-		bm_proc_dsdt->proc_fops = &proc_dsdt_operations;
-	}
-
-	return(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	sm_osl_remove_device
- *
- ****************************************************************************/
-
-acpi_status
-sm_osl_remove_device (
-	SM_CONTEXT		*system)
-{
-	if (!system) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	remove_proc_entry(SM_PROC_INFO, sm_proc_root);
-	remove_proc_entry(SM_PROC_DSDT, sm_proc_root);
-
-	return(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	sm_osl_generate_event
- *
- ****************************************************************************/
-
-acpi_status
-sm_osl_generate_event (
-	u32			event,
-	SM_CONTEXT		*system)
-{
-	acpi_status		status = AE_OK;
-
-	if (!system) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	switch (event) {
-
-	default:
-		return(AE_BAD_PARAMETER);
-		break;
-	}
-
-	return(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	sm_osl_init
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	0: Success
- *
- * DESCRIPTION: Module initialization.
- *
- ****************************************************************************/
-
-static int __init
-sm_osl_init (void)
-{
-	acpi_status		status = AE_OK;
-
-	/* abort if no busmgr */
-	if (!bm_proc_root)
-		return -ENODEV;
-
-	sm_proc_root = bm_proc_root;
-	if (!sm_proc_root) {
-		status = AE_ERROR;
-	}
-	else {
-		status = sm_initialize();
-	}
-
-	return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	sm_osl_cleanup
- *
- * PARAMETERS:	<none>
- *
- * RETURN:	<none>
- *
- * DESCRIPTION: Module cleanup.
- *
- ****************************************************************************/
-
-static void __exit
-sm_osl_cleanup (void)
-{
-	sm_terminate();
-
-	return;
-}
-
-
-module_init(sm_osl_init);
-module_exit(sm_osl_cleanup);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/thermal/Makefile linux-2.4.22-pre2/drivers/acpi/ospm/thermal/Makefile
--- linux-2.4.21/drivers/acpi/ospm/thermal/Makefile	2001-06-21 00:47:40.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/thermal/Makefile	1970-01-01 00:00:00.000000000 +0000
@@ -1,6 +0,0 @@
-O_TARGET	:= ospm_$(notdir $(CURDIR)).o
-obj-m		:= $(O_TARGET)
-EXTRA_CFLAGS	+= $(ACPI_CFLAGS)
-obj-y		:= $(patsubst %.c,%.o,$(wildcard *.c))
-
-include $(TOPDIR)/Rules.make
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/thermal/tz.c linux-2.4.22-pre2/drivers/acpi/ospm/thermal/tz.c
--- linux-2.4.21/drivers/acpi/ospm/thermal/tz.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/thermal/tz.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,642 +0,0 @@
-/*****************************************************************************
- *
- * Module Name: tz.c
- *   $Revision: 44 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include <acpi.h>
-#include <bm.h>
-#include "tz.h"
-
-
-#define _COMPONENT		ACPI_THERMAL
-	MODULE_NAME		("tz")
-
-
-/****************************************************************************
- *                                  Globals
- ****************************************************************************/
-
-extern int TZP;
-
-
-/****************************************************************************
- *                            Internal Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:    tz_print
- *
- ****************************************************************************/
-
-void
-tz_print (
-	TZ_CONTEXT		*tz)
-{
-#ifdef ACPI_DEBUG
-	acpi_buffer		buffer;
-	u32			i,j = 0;
-	TZ_THRESHOLDS		*thresholds = NULL;
-
-	FUNCTION_TRACE("tz_print");
-
-	if (!tz)
-		return;
-
-	thresholds = &(tz->policy.thresholds);
-
-	buffer.length = 256;
-	buffer.pointer = acpi_os_callocate(buffer.length);
-	if (!buffer.pointer)
-		return;
-
-	/*
-	 * Get the full pathname for this ACPI object.
-	 */
-	acpi_get_name(tz->acpi_handle, ACPI_FULL_PATHNAME, &buffer);
-
-	/*
-	 * Print out basic thermal zone information.
-	 */
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "| Thermal_zone[%02x]:[%p] %s\n", tz->device_handle, tz->acpi_handle, (char*)buffer.pointer));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   temperature[%d] state[%08x]\n", tz->policy.temperature, tz->policy.state));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   cooling_mode[%08x] polling_freq[%d]\n", tz->policy.cooling_mode, tz->policy.polling_freq));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   critical[%d]\n", thresholds->critical.temperature));
-	if (thresholds->hot.is_valid)
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   hot[%d]\n", thresholds->hot.temperature));
-	if (thresholds->passive.is_valid) {
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   passive[%d]: tc1[%d] tc2[%d] tsp[%d]\n", thresholds->passive.temperature, thresholds->passive.tc1, thresholds->passive.tc2, thresholds->passive.tsp));
-		if (thresholds->passive.devices.count > 0) {
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|     devices"));
-			for (j=0; (j<thresholds->passive.devices.count && j<10); j++) {
-				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "[%02x]", thresholds->passive.devices.handles[j]));
-			}
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "\n"));
-		}
-	}
-	for (i=0; i<TZ_MAX_ACTIVE_THRESHOLDS; i++) {
-		if (!thresholds->active[i].is_valid)
-			break;
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   active[%d]: index[%d]\n", thresholds->active[i].temperature, i));
-		if (thresholds->active[i].devices.count > 0) {
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|     devices"));
-			for (j=0; (j<thresholds->active[i].devices.count && j<10); j++) {
-				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "[%02x]", thresholds->active[i].devices.handles[j]));
-			}
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "\n"));
-		}
-	}
-
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
-
-	acpi_os_free(buffer.pointer);
-#endif /*ACPI_DEBUG*/
-
-	return;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    tz_get_temperaturee
- *
- ****************************************************************************/
-
-acpi_status
-tz_get_temperature (
-	TZ_CONTEXT		*tz)
-{
-	acpi_status             status = AE_OK;
-
-	FUNCTION_TRACE("tz_get_temperature");
-
-	if (!tz) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Evaluate the _TMP method to get the current temperature.
-	 */
-	status = bm_evaluate_simple_integer(tz->acpi_handle, "_TMP", &(tz->policy.temperature));
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %d d_k\n", tz->policy.temperature));
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    tz_set_cooling_preference
- *
- ****************************************************************************/
-
-acpi_status
-tz_set_cooling_preference (
-	TZ_CONTEXT              *tz,
-	TZ_COOLING_MODE         cooling_mode)
-{
-	acpi_status             status = AE_OK;
-	acpi_object_list        arg_list;
-	acpi_object             arg0;
-
-	FUNCTION_TRACE("tz_set_cooling_preference");
-
-	if (!tz || ((cooling_mode != TZ_COOLING_MODE_ACTIVE) && (cooling_mode != TZ_COOLING_MODE_PASSIVE))) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Build the argument list, which simply consists of the current
-	 * cooling preference.
-	 */
-	memset(&arg_list, 0, sizeof(acpi_object));
-	arg_list.count = 1;
-	arg_list.pointer = &arg0;
-
-	memset(&arg0, 0, sizeof(acpi_object));
-	arg0.type = ACPI_TYPE_INTEGER;
-	arg0.integer.value = cooling_mode;
-
-	/*
-	 * Evaluate "_SCP" - setting the new cooling preference.
-	 */
-	status = acpi_evaluate_object(tz->acpi_handle, "_SCP", &arg_list, NULL);
-	if (ACPI_FAILURE(status)) {
-		tz->policy.cooling_mode = -1;
-		return_ACPI_STATUS(status);
-	}
-
-	tz->policy.cooling_mode = cooling_mode;
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    tz_get_thresholds
- *
- ****************************************************************************/
-
-acpi_status
-tz_get_thresholds (
-	TZ_CONTEXT		*tz)
-{
-	acpi_status		status = AE_OK;
-	TZ_THRESHOLDS		*thresholds = NULL;
-	u32			value = 0;
-	u32                     i = 0;
-
-	FUNCTION_TRACE("acpi_tz_get_thresholds");
-
-	if (!tz) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	thresholds = &(tz->policy.thresholds);
-
-	/* Critical Shutdown (required) */
-
-	status = bm_evaluate_simple_integer(tz->acpi_handle, "_CRT", &value);
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No critical threshold\n"));
-		return_ACPI_STATUS(status);
-	}
-	else {
-		thresholds->critical.temperature = value;
-		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found critical threshold [%d]\n", thresholds->critical.temperature));
-
-	}
-
-	/* Critical Sleep (optional) */
-
-	status = bm_evaluate_simple_integer(tz->acpi_handle, "_HOT", &value);
-	if (ACPI_FAILURE(status)) {
-		thresholds->hot.is_valid = 0;
-		thresholds->hot.temperature = 0;
-	}
-	else {
-		thresholds->hot.is_valid = 1;
-		thresholds->hot.temperature = value;
-		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found hot threshold [%d]\n", thresholds->hot.temperature));
-	}
-
-	/* Passive: Processors (optional) */
-
-	status = bm_evaluate_simple_integer(tz->acpi_handle, "_PSV", &value);
-	if (ACPI_FAILURE(status)) {
-		thresholds->passive.is_valid = 0;
-		thresholds->passive.temperature = 0;
-	}
-	else {
-		thresholds->passive.is_valid = 1;
-		thresholds->passive.temperature = value;
-
-		status = bm_evaluate_simple_integer(tz->acpi_handle, "_TC1", &value);
-		if (ACPI_FAILURE(status)) {
-			thresholds->passive.is_valid = 0;
-		}
-		thresholds->passive.tc1 = value;
-
-		status = bm_evaluate_simple_integer(tz->acpi_handle, "_TC2", &value);
-		if (ACPI_FAILURE(status)) {
-			thresholds->passive.is_valid = 0;
-		}
-		thresholds->passive.tc2 = value;
-
-		status = bm_evaluate_simple_integer(tz->acpi_handle, "_TSP", &value);
-		if (ACPI_FAILURE(status)) {
-			thresholds->passive.is_valid = 0;
-		}
-		thresholds->passive.tsp = value;
-
-		status = bm_evaluate_reference_list(tz->acpi_handle, "_PSL", &(thresholds->passive.devices));
-		if (ACPI_FAILURE(status)) {
-			thresholds->passive.is_valid = 0;
-		}
-
-		if (thresholds->passive.is_valid) {
-			ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found passive threshold [%d]\n", thresholds->passive.temperature));
-		}
-		else {
-			ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid passive threshold\n"));
-		}
-	}
-
-	/* Active: Fans, etc. (optional) */
-
-	for (i=0; i<TZ_MAX_ACTIVE_THRESHOLDS; i++) {
-
-		char name[5] = {'_','A','C',('0'+i),'\0'};
-
-		status = bm_evaluate_simple_integer(tz->acpi_handle, name, &value);
-		if (ACPI_FAILURE(status)) {
-			thresholds->active[i].is_valid = 0;
-			thresholds->active[i].temperature = 0;
-			break;
-		}
-
-		thresholds->active[i].temperature = value;
-		name[2] = 'L';
-
-		status = bm_evaluate_reference_list(tz->acpi_handle, name, &(thresholds->active[i].devices));
-		if (ACPI_SUCCESS(status)) {
-			thresholds->active[i].is_valid = 1;
-			ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found active threshold [%d]:[%d]\n", i, thresholds->active[i].temperature));
-		}
-		else {
-			ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid active threshold [%d]\n", i));
-		}
-	}
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    tz_add_device
- *
- ****************************************************************************/
-
-acpi_status
-tz_add_device (
-	BM_HANDLE               device_handle,
-	void                    **context)
-{
-	acpi_status             status = AE_OK;
-	TZ_CONTEXT              *tz = NULL;
-	BM_DEVICE		*device = NULL;
-	acpi_handle             tmp_handle = NULL;
-	static u32		zone_count = 0;
-
-	FUNCTION_TRACE("tz_add_device");
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Adding thermal zone [%02x].\n", device_handle));
-
-	if (!context || *context) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Invalid context for device [%02x].\n", device_handle));
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	/*
-	 * Get information on this device.
-	 */
-	status = bm_get_device_info(device_handle, &device);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Allocate a new Thermal Zone device.
-	 */
-	tz = acpi_os_callocate(sizeof(TZ_CONTEXT));
-	if (!tz) {
-		return_ACPI_STATUS(AE_NO_MEMORY);
-	}
-
-	tz->device_handle = device->handle;
-	tz->acpi_handle = device->acpi_handle;
-
-	/* TBD: How to manage 'uid' when zones are Pn_p? */
-	sprintf(tz->uid, "%d", zone_count++);
-
-	/*
-	 * Temperature:
-	 * ------------
-	 * Make sure we can read the zone's current temperature (_TMP).
-	 * If we can't, there's no use in doing any policy (abort).
-	 */
-	status = tz_get_temperature(tz);
-	if (ACPI_FAILURE(status))
-		goto end;
-
-	/*
-	 * Polling Frequency:
-	 * ------------------
-	 * If _TZP doesn't exist use the OS default polling frequency.
-	 */
-	status = bm_evaluate_simple_integer(tz->acpi_handle, "_TZP", &(tz->policy.polling_freq));
-	if (ACPI_FAILURE(status)) {
-		tz->policy.polling_freq = TZP;
-	}
-	status = AE_OK;
-
-	/*
-	 * Cooling Preference:
-	 * -------------------
-	 * Default to ACTIVE (noisy) cooling until policy decides otherwise.
-	 * Note that _SCP is optional.
-	 */
-	tz_set_cooling_preference(tz, TZ_COOLING_MODE_ACTIVE);
-
-	/*
-	 * Start Policy:
-	 * -------------
-	 * Thermal policy is included in the kernel (this driver) because
-	 * of the critical role it plays in avoiding nuclear meltdown. =O
-	 */
-	status = tz_policy_add_device(tz);
-	if (ACPI_FAILURE(status))
-		goto end;
-
-	status = tz_osl_add_device(tz);
-	if (ACPI_FAILURE(status))
-		goto end;
-
-	*context = tz;
-
-	tz_print(tz);
-
-end:
-	if (ACPI_FAILURE(status))
-		acpi_os_free(tz);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    tz_remove_device
- *
- ****************************************************************************/
-
-acpi_status
-tz_remove_device (
-	void			**context)
-{
-	acpi_status		status = AE_OK;
-	TZ_CONTEXT		*tz = NULL;
-
-	FUNCTION_TRACE("tz_remove_device");
-
-	if (!context || !*context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	tz = (TZ_CONTEXT*)(*context);
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing thermal zone [%02x].\n", tz->device_handle));
-
-	status = tz_osl_remove_device(tz);
-
-	/*
-	 * Remove Policy:
-	 * --------------
-	 * TBD: Move all thermal zone policy to user-mode daemon...
-	 */
-	status = tz_policy_remove_device(tz);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	acpi_os_free(tz);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *                            External Functions
- ****************************************************************************/
-
-/****************************************************************************
- *
- * FUNCTION:    tz_initialize
- *
- ****************************************************************************/
-
-acpi_status
-tz_initialize (void)
-{
-	acpi_status             status = AE_OK;
-	BM_DEVICE_ID		criteria;
-	BM_DRIVER		driver;
-
-	FUNCTION_TRACE("tz_initialize");
-
-	memset(&criteria, 0, sizeof(BM_DEVICE_ID));
-	memset(&driver, 0, sizeof(BM_DRIVER));
-
-	/*
-	 * Register driver for thermal zone devices.
-	 */
-	criteria.type = BM_TYPE_THERMAL_ZONE;
-
-	driver.notify = &tz_notify;
-	driver.request = &tz_request;
-
-	status = bm_register_driver(&criteria, &driver);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    tz_terminate
- *
- ****************************************************************************/
-
-acpi_status
-tz_terminate (void)
-{
-	acpi_status             status = AE_OK;
-	BM_DEVICE_ID		criteria;
-	BM_DRIVER		driver;
-
-	FUNCTION_TRACE("tz_terminate");
-
-	memset(&criteria, 0, sizeof(BM_DEVICE_ID));
-	memset(&driver, 0, sizeof(BM_DRIVER));
-
-	/*
-	 * Unregister driver for thermal zone devices.
-	 */
-	criteria.type = BM_TYPE_THERMAL_ZONE;
-
-	driver.notify = &tz_notify;
-	driver.request = &tz_request;
-
-	status = bm_unregister_driver(&criteria, &driver);
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    tz_notify
- *
- ****************************************************************************/
-
-acpi_status
-tz_notify (
-	BM_NOTIFY               notify_type,
-	BM_HANDLE               device_handle,
-	void                    **context)
-{
-	acpi_status             status = AE_OK;
-	TZ_CONTEXT		*tz = NULL;
-
-	FUNCTION_TRACE("tz_notify");
-
-	if (!context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	tz = (TZ_CONTEXT*)*context;
-
-	switch (notify_type) {
-
-	case BM_NOTIFY_DEVICE_ADDED:
-		status = tz_add_device(device_handle, context);
-		break;
-
-	case BM_NOTIFY_DEVICE_REMOVED:
-		status = tz_remove_device(context);
-		break;
-
-	case TZ_NOTIFY_TEMPERATURE_CHANGE:
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Temperature (_TMP) change event detected.\n"));
-		tz_policy_check(*context);
-		status = tz_get_temperature(tz);
-		if (ACPI_SUCCESS(status)) {
-			status = tz_osl_generate_event(notify_type, tz);
-		}
-		break;
-
-	case TZ_NOTIFY_THRESHOLD_CHANGE:
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Threshold (_SCP) change event detected.\n"));
-		status = tz_policy_remove_device(tz);
-		if (ACPI_SUCCESS(status)) {
-			status = tz_policy_add_device(tz);
-		}
-		status = tz_osl_generate_event(notify_type, tz);
-		break;
-
-	case TZ_NOTIFY_DEVICE_LISTS_CHANGE:
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Device lists (_ALx, _PSL, _TZD) change event detected.\n"));
-		status = tz_policy_remove_device(tz);
-		if (ACPI_SUCCESS(status)) {
-			status = tz_policy_add_device(tz);
-		}
-		status = tz_osl_generate_event(notify_type, tz);
-		break;
-
-	default:
-		status = AE_SUPPORT;
-		break;
-	}
-
-	return_ACPI_STATUS(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    tz_request
- *
- ****************************************************************************/
-
-acpi_status
-tz_request (
-	BM_REQUEST		*request,
-	void                    *context)
-{
-	acpi_status             status = AE_OK;
-	TZ_CONTEXT              *tz = NULL;
-
-	FUNCTION_TRACE("tz_request");
-
-	/*
-	 * Must have a valid request structure and context.
-	 */
-	if (!request || !context) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	tz = (TZ_CONTEXT*)context;
-
-	/*
-	 * Handle request:
-	 * ---------------
-	 */
-	switch (request->command) {
-
-	default:
-		status = AE_SUPPORT;
-		break;
-	}
-
-	request->status = status;
-
-	return_ACPI_STATUS(status);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/thermal/tz_osl.c linux-2.4.22-pre2/drivers/acpi/ospm/thermal/tz_osl.c
--- linux-2.4.21/drivers/acpi/ospm/thermal/tz_osl.c	2001-12-21 17:41:53.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/thermal/tz_osl.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,398 +0,0 @@
-/******************************************************************************
- *
- * Module Name: tz_osl.c
- *   $Revision: 25 $
- *
- *****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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/proc_fs.h>
-#include <acpi.h>
-#include "tz.h"
-
-
-MODULE_AUTHOR("Andrew Grover");
-MODULE_DESCRIPTION("ACPI Component Architecture (CA) - Thermal Zone Driver");
-MODULE_LICENSE("GPL");
-
-int TZP = 0;
-MODULE_PARM(TZP, "i");
-MODULE_PARM_DESC(TZP, "Thermal zone polling frequency, in 1/10 seconds.\n");
-
-
-#define TZ_PROC_ROOT		"thermal"
-#define TZ_PROC_STATUS		"status"
-#define TZ_PROC_INFO		"info"
-
-extern struct proc_dir_entry	*bm_proc_root;
-static struct proc_dir_entry	*tz_proc_root = NULL;
-
-
-/****************************************************************************
- *
- * FUNCTION:	tz_osl_proc_read_info
- *
- ****************************************************************************/
-
-static int
-tz_osl_proc_read_info (
-	char			*page,
-	char			**start,
-	off_t			off,
-	int 			count,
-	int 			*eof,
-	void			*context)
-{
-	acpi_status		status = AE_OK;
-	char			name[5];
-	acpi_buffer		buffer = {sizeof(name), &name};
-	TZ_CONTEXT		*tz = NULL;
-	TZ_THRESHOLDS		*thresholds = NULL;
-	char			*p = page;
-	int 			len = 0;
-	u32			i,j;
-	u32			t = 0;
-
-	if (!context || (off != 0))
-		goto end;
-
-	tz = (TZ_CONTEXT*)context;
-
-	thresholds = &(tz->policy.thresholds);
-
-	p += sprintf(p, "critical (S5): trip=%d\n", thresholds->critical.temperature);
-	
-	if (thresholds->hot.is_valid)
-		p += sprintf(p, "critical (S4): trip=%d\n", thresholds->hot.temperature);
-
-	if (thresholds->passive.is_valid) {
-		p += sprintf(p, "passive:       trip=%d tc1=%d tc2=%d tsp=%d devices=", thresholds->passive.temperature, thresholds->passive.tc1, thresholds->passive.tc2, thresholds->passive.tsp);
-		for (j=0; j<thresholds->passive.devices.count; j++)
-			p += sprintf(p, "%08x%c", thresholds->passive.devices.handles[j], (j==thresholds->passive.devices.count-1)?'\n':',');
-	}
-
-	for (i=0; i<TZ_MAX_ACTIVE_THRESHOLDS; i++) {
-		if (!(thresholds->active[i].is_valid))
-			break;
-		p += sprintf(p, "active[%d]:     trip=%d devices=", i, thresholds->active[i].temperature);
-		for (j=0; j<thresholds->active[i].devices.count; j++)
-			p += sprintf(p, "%08x%c", thresholds->active[i].devices.handles[j], (j==thresholds->passive.devices.count-1)?'\n':',');
-	}
-
-	p += sprintf(p, "cooling mode:  ");
-	switch (tz->policy.cooling_mode) {
-	case TZ_COOLING_MODE_ACTIVE:
-		p += sprintf(p, "active (noisy)\n");
-		break;
-	case TZ_COOLING_MODE_PASSIVE:
-		p += sprintf(p, "passive (quiet)\n");
-		break;
-	default:
-		p += sprintf(p, "unknown\n");
-		break;
-	}
-
-	p += sprintf(p, "polling:       ");
-	switch (tz->policy.polling_freq) {
-	case 0:
-		p += sprintf(p, "disabled\n");
-		break;
-	default:
-		p += sprintf(p, "%d dS\n", tz->policy.polling_freq);
-		break;
-	}
-
-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 len;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	tz_osl_proc_write_info
- *
- ****************************************************************************/
-
-static int tz_osl_proc_write_info (
-        struct file		*file, 
-        const char		*buffer, 
-        unsigned long		count, 
-        void			*data)
-{
-	TZ_CONTEXT		*tz = NULL;
-	u32			state = 0;
-	u32			size = 0;
-
-	if (!buffer || (count==0) || !data) {
-		goto end;
-	}
-
-	tz = (TZ_CONTEXT*)data;
-
-	size = strlen(buffer);
-	if (size < 4)
-		goto end;
-	
-	/* Cooling preference: "scp=0" (active) or "scp=1" (passive) */
-	if (0 == strncmp(buffer, "scp=", 4)) {
-		tz_set_cooling_preference(tz, (buffer[4] - '0'));
-	}
-
-	/* Polling frequency: "tzp=X" (poll every X [0-9] seconds) */
-	else if (0 == strncmp(buffer, "tzp=", 4)) {
-		tz->policy.polling_freq = (buffer[4] - '0') * 10;
-		tz_policy_check(tz);
-	}
-
-end:
-        return count;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	tz_osl_proc_read_status
- *
- ****************************************************************************/
-
-static int
-tz_osl_proc_read_status (
-	char			*page,
-	char			**start,
-	off_t			off,
-	int 			count,
-	int 			*eof,
-	void			*context)
-{
-	TZ_CONTEXT		*tz = NULL;
-	char			*p = page;
-	int 			len = 0;
-
-	if (!context || (off != 0)) {
-		goto end;
-	}
-
-	tz = (TZ_CONTEXT*)context;
-
-	/* Temperature */
-
-	tz_get_temperature(tz);
-
-	p += sprintf(p, "temperature:   %d dK\n", tz->policy.temperature);
-
-	p += sprintf(p, "state:         ");
-	if (tz->policy.state == 0)
-		p += sprintf(p, "ok\n");
-	else if (tz->policy.state & TZ_STATE_CRITICAL)
-		p += sprintf(p, "critical\n");
-	else if (tz->policy.state & TZ_STATE_HOT)
-		p += sprintf(p, "hot\n");
-	else {
-		if (tz->policy.state & TZ_STATE_ACTIVE)
-			p += sprintf(p, "active[%d] ", tz->policy.state & 0x07);
-		if (tz->policy.state & TZ_STATE_PASSIVE)
-			p += sprintf(p, "passive ");
-		p += sprintf(p, "\n");
-	}
-
-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(len);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	tz_osl_add_device
- *
- ****************************************************************************/
-
-acpi_status
-tz_osl_add_device(
-	TZ_CONTEXT		*tz)
-{
-	struct proc_dir_entry	*proc_entry = NULL;
-	struct proc_dir_entry	*proc_child_entry = NULL;
-
-	if (!tz) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	printk("ACPI: Thermal Zone found\n");
-
-	proc_entry = proc_mkdir(tz->uid, tz_proc_root);
-	if (!proc_entry) 
-		return(AE_ERROR);
-
-	proc_child_entry = create_proc_read_entry(TZ_PROC_STATUS, S_IFREG | S_IRUGO, proc_entry, tz_osl_proc_read_status, (void*)tz);
-	if (!proc_child_entry) 
-		return(AE_ERROR);
-
-	proc_child_entry = create_proc_entry(TZ_PROC_INFO, S_IFREG | 0644, proc_entry);
-	if (!proc_child_entry)
-		return(AE_ERROR);
-
-	proc_child_entry->read_proc = tz_osl_proc_read_info;
-	proc_child_entry->write_proc = tz_osl_proc_write_info;
-	proc_child_entry->data = (void*)tz;
-
-	return(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	tz_osl_remove_device
- *
- ****************************************************************************/
-
-acpi_status
-tz_osl_remove_device (
-	TZ_CONTEXT		*tz)
-{
-	char			proc_entry[64];
-
-	if (!tz) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	sprintf(proc_entry, "%s/%s", tz->uid, TZ_PROC_INFO);
-	remove_proc_entry(proc_entry, tz_proc_root);
-
-	sprintf(proc_entry, "%s/%s", tz->uid, TZ_PROC_STATUS);
-	remove_proc_entry(proc_entry, tz_proc_root);
-
-	sprintf(proc_entry, "%s", tz->uid);
-	remove_proc_entry(proc_entry, tz_proc_root);
-
-	return(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	tz_osl_generate_event
- *
- ****************************************************************************/
-
-acpi_status
-tz_osl_generate_event (
-	u32			event,
-	TZ_CONTEXT		*tz)
-{
-	acpi_status		status = AE_OK;
-
-	if (!tz) {
-		return(AE_BAD_PARAMETER);
-	}
-
-	switch (event) {
-
-	case TZ_NOTIFY_TEMPERATURE_CHANGE:
-		status = bm_osl_generate_event(tz->device_handle,
-			TZ_PROC_ROOT, tz->uid, event,
-			tz->policy.temperature);
-		break;
-
-	case TZ_NOTIFY_THRESHOLD_CHANGE:
-	case TZ_NOTIFY_DEVICE_LISTS_CHANGE:
-		status = bm_osl_generate_event(tz->device_handle,
-			TZ_PROC_ROOT, tz->uid, event, 0);
-		break;
-
-	default:
-		return(AE_BAD_PARAMETER);
-		break;
-	}
-
-	return(status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	tz_osl_init
- *
- ****************************************************************************/
-
-static int __init
-tz_osl_init (void)
-{
-	acpi_status		status = AE_OK;
-
-	/* abort if no busmgr */
-	if (!bm_proc_root)
-		return -ENODEV;
-
-	tz_proc_root = proc_mkdir(TZ_PROC_ROOT, bm_proc_root);
-	if (!tz_proc_root) {
-		status = AE_ERROR;
-	}
-	else {
-		status = tz_initialize();
-		if (ACPI_FAILURE(status)) {
-			remove_proc_entry(TZ_PROC_ROOT, bm_proc_root);
-		}
-
-	}
-
-	return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:	tz_osl_cleanup
- *
- ****************************************************************************/
-
-static void __exit
-tz_osl_cleanup (void)
-{
-	tz_terminate();
-
-	if (tz_proc_root) {
-		remove_proc_entry(TZ_PROC_ROOT, bm_proc_root);
-	}
-
-	return;
-}
-
-
-module_init(tz_osl_init);
-module_exit(tz_osl_cleanup);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/ospm/thermal/tzpolicy.c linux-2.4.22-pre2/drivers/acpi/ospm/thermal/tzpolicy.c
--- linux-2.4.21/drivers/acpi/ospm/thermal/tzpolicy.c	2002-11-28 23:53:12.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/ospm/thermal/tzpolicy.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,578 +0,0 @@
-/****************************************************************************
- *
- * Module Name: tzpolicy.c -
- *   $Revision: 30 $
- *
- ****************************************************************************/
-
-/*
- *  Copyright (C) 2000, 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the 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
- */
-
-/*
- * TBD: 1. Support performance-limit control for non-processor devices
- *         (those listed in _TZD, e.g. graphics).
- */
-
-#include <linux/proc_fs.h>
-#include <linux/sysctl.h>
-#include <linux/pm.h>
-
-#include <acpi.h>
-#include <bm.h>
-#include "tz.h"
-
-
-#define _COMPONENT		ACPI_THERMAL
-	MODULE_NAME		("tzpolicy")
-
-
-/****************************************************************************
- *                                  Globals
- ****************************************************************************/
-
-void
-tz_policy_run (
-	unsigned long           data);
-
-
-/****************************************************************************
- *                              Internal Functions
- ****************************************************************************/
-
-acpi_status
-set_performance_limit (
-	BM_HANDLE               device_handle,
-	u32			flag)
-{
-	acpi_status             status;
-	BM_REQUEST              request;
-
-	request.status = AE_OK;
-	request.handle = device_handle;
-	request.command = PR_COMMAND_SET_PERF_LIMIT;
-	request.buffer.length = sizeof(u32);
-	request.buffer.pointer = &flag;
-
-	status = bm_request(&request);
-
-	if (ACPI_FAILURE(status))
-		return status;
-	else
-		return request.status;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    tz_policy_critical
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-tz_policy_critical(
-	TZ_CONTEXT		*tz)
-{
-	FUNCTION_TRACE("tz_policy_critical");
-
-	if (!tz) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	if (tz->policy.temperature >= tz->policy.thresholds.critical.temperature) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Critical (S5) threshold reached.\n"));
-		/* TBD:	Need method for shutting down system. */
-	}
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    tz_policy_hot
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-tz_policy_hot(
-	TZ_CONTEXT		*tz)
-{
-	FUNCTION_TRACE("tz_policy_hot");
-
-	if (!tz || !tz->policy.thresholds.hot.is_valid) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	if (tz->policy.temperature >= tz->policy.thresholds.hot.temperature) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Critical (S4) threshold reached.\n"));
-		/* TBD:	Need method for invoking OS-level critical suspend. */
-	}
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    tz_policy_passive
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-tz_policy_passive(
-	TZ_CONTEXT		*tz)
-{
-	TZ_PASSIVE_THRESHOLD	*passive = NULL;
-	static u32		last_temperature = 0;
-	s32			trend = 0;
-	u32			i = 0;
-
-	FUNCTION_TRACE("tz_policy_passive");
-
-	if (!tz || !tz->policy.thresholds.passive.is_valid) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	passive = &(tz->policy.thresholds.passive);
-
-	if (tz->policy.temperature >= passive->temperature) {
-		/*
-		 * Thermal trend?
-		 * --------------
-		 * Using the passive cooling equation (see the ACPI
-		 * Specification), calculate the current thermal trend
-		 * (a.k.a. performance delta).
-		 */
-		trend = passive->tc1 * (tz->policy.temperature - last_temperature) + passive->tc2 * (tz->policy.temperature - passive->temperature);
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "trend[%d] = TC1[%d]*(temp[%d]-last[%d]) + TC2[%d]*(temp[%d]-passive[%d])\n", trend, passive->tc1, tz->policy.temperature, last_temperature, passive->tc2, tz->policy.temperature, passive->temperature));
-
-		last_temperature = tz->policy.temperature;
-
-		/*
-		 * Heating Up?
-		 * -----------
-		 * Decrease thermal performance limit on all passive
-		 * cooling devices (processors).
-		 */
-		if (trend > 0) {
-			for (i=0; i<passive->devices.count; i++)
-				set_performance_limit(passive->devices.handles[i], PR_PERF_DEC);
-		}
-		/*
-		 * Cooling Off?
-		 * ------------
-		 * Increase thermal performance limit on all passive
-		 * cooling devices (processors).
-		 */
-		else if (trend < 0) {
-			for (i=0; i<passive->devices.count; i++)
-				set_performance_limit(passive->devices.handles[i], PR_PERF_INC);
-		}
-	}
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    tz_policy_active
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-tz_policy_active(
-	TZ_CONTEXT              *tz)
-{
-	acpi_status             status = AE_OK;
-	TZ_ACTIVE_THRESHOLD	*active = NULL;
-	u32                     i,j = 0;
-
-	FUNCTION_TRACE("tz_policy_active");
-
-	if (!tz || !tz->policy.thresholds.active[0].is_valid) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	for (i=0; i<TZ_MAX_ACTIVE_THRESHOLDS; i++) {
-
-		active = &(tz->policy.thresholds.active[i]);
-		if (!active || !active->is_valid)
-			break;
-
-		/*
-		 * Above Threshold?
-		 * ----------------
-		 * If not already enabled, turn ON all cooling devices
-		 * associated with this active threshold.
-		 */
-		if ((tz->policy.temperature >= active->temperature) && (active->cooling_state != TZ_COOLING_ENABLED)) {
-			for (j = 0; j < active->devices.count; j++) {
-				status = bm_set_device_power_state(active->devices.handles[j], ACPI_STATE_D0);
-				if (ACPI_SUCCESS(status)) {
-					ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Cooling device [%02x] now ON.\n", active->devices.handles[j]));
-				}
-				else {
-					ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Unable to turn ON cooling device [%02x].\n", active->devices.handles[j]));
-				}
-			}
-  			active->cooling_state = TZ_COOLING_ENABLED;
-		}
-		/*
-		 * Below Threshold?
-		 * ----------------
-		 * Turn OFF all cooling devices associated with this
-		 * threshold.  Note that by checking "if not disabled" we
-		 * turn off all cooling devices for thresholds in the
-		 * TZ_COOLING_STATE_UNKNOWN state, useful as a level-set
-		 * during the first pass.
-		 */
-		else if (active->cooling_state != TZ_COOLING_DISABLED) {
-			for (j = 0; j < active->devices.count; j++) {
-				status = bm_set_device_power_state(active->devices.handles[j], ACPI_STATE_D3);
-				if (ACPI_SUCCESS(status)) {
-					ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Cooling device [%02x] now OFF.\n", active->devices.handles[j]));
-				}
-				else {
-					ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Unable to turn OFF cooling device [%02x].\n", active->devices.handles[j]));
-				}
-			}
-			active->cooling_state = TZ_COOLING_DISABLED;
-		}
-	}
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    tz_policy_check
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION: Note that this function will get called whenever:
- *                1. A thermal event occurs.
- *                2. The polling/sampling time period expires.
- *
- ****************************************************************************/
-
-void
-tz_policy_check (
-	void                    *context)
-{
-	acpi_status             status = AE_OK;
-	TZ_CONTEXT              *tz = NULL;
-	TZ_POLICY		*policy = NULL;
-	TZ_THRESHOLDS		*thresholds = NULL;
-	u32                     previous_temperature = 0;
-	u32                     previous_state = 0;
-	u32                     active_index = 0;
-	u32                     i = 0;
-	u32                     sleep_time = 0;
-
-	FUNCTION_TRACE("tz_policy_check");
-
-	if (!context) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid (NULL) context.\n"));
-		return_VOID;
-	}
-
-	tz = (TZ_CONTEXT*)context;
-	policy = &(tz->policy);
-	thresholds = &(tz->policy.thresholds);
-
-	/*
-	 * Preserve Previous State:
-	 * ------------------------
-	 */
-	previous_temperature = tz->policy.temperature;
-	previous_state = tz->policy.state;
-
-	/*
-	 * Get Temperature:
-	 * ----------------
-	 */
-	status = tz_get_temperature(tz);
-	if (ACPI_FAILURE(status)) {
-		return_VOID;
-	}
-
-	/*
-	 * Calculate State:
-	 * ----------------
-	 */
-	policy->state = TZ_STATE_OK;
-
-	/* Critical? */
-	if (policy->temperature >= thresholds->critical.temperature)
-		policy->state |= TZ_STATE_CRITICAL;
-
-	/* Hot? */
-	if ((thresholds->hot.is_valid) &&  (policy->temperature >= thresholds->hot.temperature))
-		policy->state |= TZ_STATE_CRITICAL;
-
-	/* Passive? */
-	if ((thresholds->passive.is_valid) && (policy->temperature >= thresholds->passive.temperature))
-		policy->state |= TZ_STATE_PASSIVE;
-
-	/* Active? */
-	if (thresholds->active[0].is_valid) {
-		for (i=0; i<TZ_MAX_ACTIVE_THRESHOLDS; i++) {
-			if ((thresholds->active[i].is_valid) && (policy->temperature >= thresholds->active[i].temperature)) {
-				policy->state |= TZ_STATE_ACTIVE;
-				if (i > active_index)
-					active_index = i;
-			}
-		}
-		policy->state |= active_index;
-	}
-
-	/*
-	 * Invoke Policy:
-	 * --------------
-	 * Note that policy must be invoked both when 'going into' a
-	 * policy state (e.g. to allow fans to be turned on) and 'going
-	 * out of' a policy state (e.g. to allow fans to be turned off);
-	 * thus we must preserve the previous state.
-	 */
-	if (policy->state & TZ_STATE_CRITICAL)
-		tz_policy_critical(tz);
-	if (policy->state & TZ_STATE_HOT)
-		tz_policy_hot(tz);
-	if ((policy->state & TZ_STATE_PASSIVE) || (previous_state & TZ_STATE_PASSIVE))
-		tz_policy_passive(tz);
-	if ((policy->state & TZ_STATE_ACTIVE) || (previous_state & TZ_STATE_ACTIVE))
-		tz_policy_active(tz);
-
-	/*
-	 * Calculate Sleep Time:
-	 * ---------------------
-	 * If we're in the passive state, use _TSP's value.  Otherwise
-	 * use _TZP or the OS's default polling frequency.  If no polling
-	 * frequency is specified then we'll wait forever (that is, until
-	 * a thermal event occurs -- e.g. never poll).  Note that _TSP
-	 * and _TZD values are given in 1/10th seconds.
-	 */
-	if (policy->state & TZ_STATE_PASSIVE)
-		sleep_time = thresholds->passive.tsp * 100;
-	else if (policy->polling_freq > 0)
-		sleep_time = policy->polling_freq * 100;
-	else
-		sleep_time = WAIT_FOREVER;
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Thermal_zone[%02x]: temperature[%d] state[%08x]\n", tz->device_handle, policy->temperature, policy->state));
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Scheduling next poll in [%d]ms.\n", sleep_time));
-
-	/*
-	 * Schedule Next Poll:
-	 * -------------------
-	 */
-	if (sleep_time < WAIT_FOREVER) {
-		if (timer_pending(&(policy->timer)))
-			mod_timer(&(policy->timer), (HZ*sleep_time)/1000);
-		else {
-			policy->timer.data = (unsigned long)tz;
-			policy->timer.function = tz_policy_run;
-			policy->timer.expires = jiffies + (HZ*sleep_time)/1000;
-			add_timer(&(policy->timer));
-		}
-	}
-	else {
-		if (timer_pending(&(policy->timer)))
-			del_timer(&(policy->timer));
-	}
-
-	return_VOID;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    tz_policy_run
- *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-
-void
-tz_policy_run (
-	unsigned long           data)
-{
-	acpi_status             status = AE_OK;
-
-	FUNCTION_TRACE("tz_policy_run");
-
-	if (!data) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid (NULL) context.\n"));
-		return_VOID;
-	}
-
-	/*
-	 * Defer to Non-Interrupt Level:
-	 * -----------------------------
-	 * Note that all Linux kernel timers run at interrupt-level (ack!).
-	 */
-	status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,  tz_policy_check, (void*)data);
-	if (ACPI_FAILURE(status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Error invoking thermal policy.\n"));
-	}
-
-	return_VOID;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION:    tz_policy_add_device
- *
- * PARAMETERS:
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-tz_policy_add_device (
-	TZ_CONTEXT		*tz)
-{
-	acpi_status             status = AE_OK;
-	TZ_THRESHOLDS           *thresholds = NULL;
-	u32                     i,j = 0;
-
-	FUNCTION_TRACE("tz_policy_add_device");
-
-	if (!tz) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Adding policy for thermal zone [%02x].\n", tz->device_handle));
-
-	/*
-	 * Get Thresholds:
-	 * ---------------
-	 */
-	status = tz_get_thresholds(tz);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/*
-	 * Initialize Policies:
-	 * --------------------
-	 */
-	if (tz->policy.thresholds.passive.is_valid) {
-		for (i=0; i<tz->policy.thresholds.passive.devices.count; i++)
-			set_performance_limit(tz->policy.thresholds.passive.devices.handles[i], PR_PERF_MAX);
-		tz_policy_passive(tz);
-	}
-	if (tz->policy.thresholds.active[0].is_valid)
-		tz_policy_active(tz);
-
-	/*
-	 * Initialize Policy Timer:
-	 * ------------------------
-	 */
-	init_timer(&(tz->policy.timer));
-
-	/*
-	 * Start Policy:
-	 * -------------
-	 * Run an initial check using this zone's policy.
-	 */
-	tz_policy_check(tz);
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-
-/*****************************************************************************
- *
- * FUNCTION:    tz_policy_remove_device
- *
- * PARAMETERS:
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
- ****************************************************************************/
-
-acpi_status
-tz_policy_remove_device(
-	TZ_CONTEXT		*tz)
-{
-	u32			i = 0;
-
-	FUNCTION_TRACE("tz_remove_device");
-
-	if (!tz) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing policy for thermal zone [%02x].\n", tz->device_handle));
-
-	/*
-	 * Delete the thermal zone policy timer entry, if exists.
-	 */
-	if (timer_pending(&(tz->policy.timer)))
-		del_timer(&(tz->policy.timer));
-
-	/*
-	 * Reset thermal performance limit on all processors back to max.
-	 */
-	if (tz->policy.thresholds.passive.is_valid) {
-		for (i=0; i<tz->policy.thresholds.passive.devices.count; i++)
-			set_performance_limit(tz->policy.thresholds.passive.devices.handles[i], PR_PERF_MAX);
-	}
-
-	return_ACPI_STATUS(AE_OK);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/parser/Makefile linux-2.4.22-pre2/drivers/acpi/parser/Makefile
--- linux-2.4.21/drivers/acpi/parser/Makefile	2001-06-21 00:47:40.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/parser/Makefile	2003-06-26 21:43:27.000000000 +0000
@@ -1,11 +1,10 @@
 #
 # Makefile for all Linux ACPI interpreter subdirectories
-# EXCEPT for the ospm directory
 #
 
 O_TARGET := $(notdir $(CURDIR)).o
 
-obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/parser/psargs.c linux-2.4.22-pre2/drivers/acpi/parser/psargs.c
--- linux-2.4.21/drivers/acpi/parser/psargs.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/parser/psargs.c	2003-06-26 21:43:16.000000000 +0000
@@ -1,43 +1,61 @@
 /******************************************************************************
  *
  * Module Name: psargs - Parse AML opcode arguments
- *              $Revision: 52 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "amlcode.h"
-#include "acnamesp.h"
+#include <acpi/acpi.h>
+#include <acpi/acparser.h>
+#include <acpi/amlcode.h>
+#include <acpi/acnamesp.h>
 
 #define _COMPONENT          ACPI_PARSER
-	 MODULE_NAME         ("psargs")
+	 ACPI_MODULE_NAME    ("psargs")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_get_next_package_length
+ * FUNCTION:    acpi_ps_get_next_package_length
  *
- * PARAMETERS:  Parser_state        - Current parser state object
+ * PARAMETERS:  parser_state        - Current parser state object
  *
  * RETURN:      Decoded package length.  On completion, the AML pointer points
  *              past the length byte or bytes.
@@ -48,16 +66,16 @@
 
 u32
 acpi_ps_get_next_package_length (
-	acpi_parse_state        *parser_state)
+	struct acpi_parse_state         *parser_state)
 {
-	u32                     encoded_length;
-	u32                     length = 0;
+	u32                             encoded_length;
+	u32                             length = 0;
 
 
-	FUNCTION_TRACE ("Ps_get_next_package_length");
+	ACPI_FUNCTION_TRACE ("ps_get_next_package_length");
 
 
-	encoded_length = (u32) GET8 (parser_state->aml);
+	encoded_length = (u32) ACPI_GET8 (parser_state->aml);
 	parser_state->aml++;
 
 
@@ -70,7 +88,7 @@
 
 	case 1: /* 2-byte encoding (next byte + bits 0-3) */
 
-		length = ((GET8 (parser_state->aml) << 04) |
+		length = ((ACPI_GET8 (parser_state->aml) << 04) |
 				 (encoded_length & 0x0F));
 		parser_state->aml++;
 		break;
@@ -78,8 +96,8 @@
 
 	case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */
 
-		length = ((GET8 (parser_state->aml + 1) << 12) |
-				  (GET8 (parser_state->aml)    << 04) |
+		length = ((ACPI_GET8 (parser_state->aml + 1) << 12) |
+				  (ACPI_GET8 (parser_state->aml)    << 04) |
 				  (encoded_length & 0x0F));
 		parser_state->aml += 2;
 		break;
@@ -87,12 +105,17 @@
 
 	case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */
 
-		length = ((GET8 (parser_state->aml + 2) << 20) |
-				  (GET8 (parser_state->aml + 1) << 12) |
-				  (GET8 (parser_state->aml)    << 04) |
+		length = ((ACPI_GET8 (parser_state->aml + 2) << 20) |
+				  (ACPI_GET8 (parser_state->aml + 1) << 12) |
+				  (ACPI_GET8 (parser_state->aml)    << 04) |
 				  (encoded_length & 0x0F));
 		parser_state->aml += 3;
 		break;
+
+	default:
+
+		/* Can't get here, only 2 bits / 4 cases */
+		break;
 	}
 
 	return_VALUE (length);
@@ -101,9 +124,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_get_next_package_end
+ * FUNCTION:    acpi_ps_get_next_package_end
  *
- * PARAMETERS:  Parser_state        - Current parser state object
+ * PARAMETERS:  parser_state        - Current parser state object
  *
  * RETURN:      Pointer to end-of-package +1
  *
@@ -114,16 +137,18 @@
 
 u8 *
 acpi_ps_get_next_package_end (
-	acpi_parse_state        *parser_state)
+	struct acpi_parse_state         *parser_state)
 {
-	u8                      *start = parser_state->aml;
-	NATIVE_UINT             length;
+	u8                              *start = parser_state->aml;
+	acpi_native_uint                length;
 
 
-	FUNCTION_TRACE ("Ps_get_next_package_end");
+	ACPI_FUNCTION_TRACE ("ps_get_next_package_end");
 
 
-	length = (NATIVE_UINT) acpi_ps_get_next_package_length (parser_state);
+	/* Function below changes parser_state->Aml */
+
+	length = (acpi_native_uint) acpi_ps_get_next_package_length (parser_state);
 
 	return_PTR (start + length); /* end of package */
 }
@@ -131,9 +156,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_get_next_namestring
+ * FUNCTION:    acpi_ps_get_next_namestring
  *
- * PARAMETERS:  Parser_state        - Current parser state object
+ * PARAMETERS:  parser_state        - Current parser state object
  *
  * RETURN:      Pointer to the start of the name string (pointer points into
  *              the AML.
@@ -144,32 +169,31 @@
  *
  ******************************************************************************/
 
-NATIVE_CHAR *
+char *
 acpi_ps_get_next_namestring (
-	acpi_parse_state        *parser_state)
+	struct acpi_parse_state         *parser_state)
 {
-	u8                       *start = parser_state->aml;
-	u8                       *end = parser_state->aml;
-	u32                     length;
+	u8                              *start = parser_state->aml;
+	u8                              *end = parser_state->aml;
 
 
-	FUNCTION_TRACE ("Ps_get_next_namestring");
+	ACPI_FUNCTION_TRACE ("ps_get_next_namestring");
 
 
 	/* Handle multiple prefix characters */
 
-	while (acpi_ps_is_prefix_char (GET8 (end))) {
-		/* include prefix '\\' or '^' */
+	while (acpi_ps_is_prefix_char (ACPI_GET8 (end))) {
+		/* Include prefix '\\' or '^' */
 
 		end++;
 	}
 
 	/* Decode the path */
 
-	switch (GET8 (end)) {
+	switch (ACPI_GET8 (end)) {
 	case 0:
 
-		/* Null_name */
+		/* null_name */
 
 		if (end == start) {
 			start = NULL;
@@ -177,183 +201,77 @@
 		end++;
 		break;
 
-
 	case AML_DUAL_NAME_PREFIX:
 
-		/* two name segments */
+		/* Two name segments */
 
-		end += 9;
+		end += 1 + (2 * ACPI_NAME_SIZE);
 		break;
 
-
 	case AML_MULTI_NAME_PREFIX_OP:
 
-		/* multiple name segments */
+		/* Multiple name segments, 4 chars each */
 
-		length = (u32) GET8 (end + 1) * 4;
-		end += 2 + length;
+		end += 2 + ((acpi_size) ACPI_GET8 (end + 1) * ACPI_NAME_SIZE);
 		break;
 
-
 	default:
 
-		/* single name segment */
-		/* assert (Acpi_ps_is_lead (GET8 (End))); */
+		/* Single name segment */
 
-		end += 4;
+		end += ACPI_NAME_SIZE;
 		break;
 	}
 
 	parser_state->aml = (u8*) end;
-
-	return_PTR ((NATIVE_CHAR *) start);
+	return_PTR ((char *) start);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_get_next_namepath
+ * FUNCTION:    acpi_ps_get_next_namepath
  *
- * PARAMETERS:  Parser_state        - Current parser state object
+ * PARAMETERS:  parser_state        - Current parser state object
  *              Arg                 - Where the namepath will be stored
- *              Arg_count           - If the namepath points to a control method
+ *              arg_count           - If the namepath points to a control method
  *                                    the method's argument is returned here.
- *              Method_call         - Whether the namepath can be the start
- *                                    of a method call
+ *              method_call         - Whether the namepath can possibly be the
+ *                                    start of a method call
  *
- * RETURN:      None
+ * RETURN:      Status
  *
- * DESCRIPTION: Get next name (if method call, push appropriate # args).  Names
- *              are looked up in either the parsed or internal namespace to
- *              determine if the name represents a control method.  If a method
+ * DESCRIPTION: Get next name (if method call, return # of required args).
+ *              Names are looked up in the internal namespace to determine
+ *              if the name represents a control method.  If a method
  *              is found, the number of arguments to the method is returned.
  *              This information is critical for parsing to continue correctly.
  *
  ******************************************************************************/
 
-
-#ifdef PARSER_ONLY
-
-void
-acpi_ps_get_next_namepath (
-	acpi_parse_state        *parser_state,
-	acpi_parse_object       *arg,
-	u32                     *arg_count,
-	u8                      method_call)
-{
-	NATIVE_CHAR             *path;
-	acpi_parse_object       *name_op;
-	acpi_parse_object       *op;
-	acpi_parse_object       *count;
-
-
-	FUNCTION_TRACE ("Ps_get_next_namepath");
-
-
-	path = acpi_ps_get_next_namestring (parser_state);
-	if (!path || !method_call) {
-		/* Null name case, create a null namepath object */
-
-		acpi_ps_init_op (arg, AML_INT_NAMEPATH_OP);
-		arg->value.name = path;
-		return_VOID;
-	}
-
-
-	if (acpi_gbl_parsed_namespace_root) {
-		/*
-		 * Lookup the name in the parsed namespace
-		 */
-		op = NULL;
-		if (method_call) {
-			op = acpi_ps_find (acpi_ps_get_parent_scope (parser_state),
-					   path, AML_METHOD_OP, 0);
-		}
-
-		if (op) {
-			if (op->opcode == AML_METHOD_OP) {
-				/*
-				 * The name refers to a control method, so this namepath is a
-				 * method invocation.  We need to 1) Get the number of arguments
-				 * associated with this method, and 2) Change the NAMEPATH
-				 * object into a METHODCALL object.
-				 */
-				count = acpi_ps_get_arg (op, 0);
-				if (count && count->opcode == AML_BYTE_OP) {
-					name_op = acpi_ps_alloc_op (AML_INT_NAMEPATH_OP);
-					if (name_op) {
-						/* Change arg into a METHOD CALL and attach the name */
-
-						acpi_ps_init_op (arg, AML_INT_METHODCALL_OP);
-
-						name_op->value.name = path;
-
-						/* Point METHODCALL/NAME to the METHOD Node */
-
-						name_op->node = (acpi_namespace_node *) op;
-						acpi_ps_append_arg (arg, name_op);
-
-						*arg_count = (u32) count->value.integer &
-								 METHOD_FLAGS_ARG_COUNT;
-					}
-				}
-
-				return_VOID;
-			}
-
-			/*
-			 * Else this is normal named object reference.
-			 * Just init the NAMEPATH object with the pathname.
-			 * (See code below)
-			 */
-		}
-	}
-
-	/*
-	 * Either we didn't find the object in the namespace, or the object is
-	 * something other than a control method.  Just initialize the Op with the
-	 * pathname
-	 */
-	acpi_ps_init_op (arg, AML_INT_NAMEPATH_OP);
-	arg->value.name = path;
-
-
-	return_VOID;
-}
-
-
-#else
-
-
-void
+acpi_status
 acpi_ps_get_next_namepath (
-	acpi_parse_state        *parser_state,
-	acpi_parse_object       *arg,
-	u32                     *arg_count,
-	u8                      method_call)
+	struct acpi_walk_state          *walk_state,
+	struct acpi_parse_state         *parser_state,
+	union acpi_parse_object         *arg,
+	u8                              method_call)
 {
-	NATIVE_CHAR             *path;
-	acpi_parse_object       *name_op;
-	acpi_status             status;
-	acpi_namespace_node     *method_node = NULL;
-	acpi_namespace_node     *node;
-	acpi_generic_state      scope_info;
+	char                            *path;
+	union acpi_parse_object         *name_op;
+	acpi_status                     status = AE_OK;
+	union acpi_operand_object       *method_desc;
+	struct acpi_namespace_node      *node;
+	union acpi_generic_state        scope_info;
 
 
-	FUNCTION_TRACE ("Ps_get_next_namepath");
+	ACPI_FUNCTION_TRACE ("ps_get_next_namepath");
 
 
 	path = acpi_ps_get_next_namestring (parser_state);
-	if (!path || !method_call) {
-		/* Null name case, create a null namepath object */
 
-		acpi_ps_init_op (arg, AML_INT_NAMEPATH_OP);
-		arg->value.name = path;
-		return_VOID;
-	}
+	/* Null path case is allowed */
 
-
-	if (method_call) {
+	if (path) {
 		/*
 		 * Lookup the name in the internal namespace
 		 */
@@ -369,36 +287,48 @@
 		 * parent tree, but don't open a new scope -- we just want to lookup the
 		 * object  (MUST BE mode EXECUTE to perform upsearch)
 		 */
-		status = acpi_ns_lookup (&scope_info, path, ACPI_TYPE_ANY, IMODE_EXECUTE,
-				 NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, NULL,
-				 &node);
-		if (ACPI_SUCCESS (status)) {
+		status = acpi_ns_lookup (&scope_info, path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+				 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &node);
+		if (ACPI_SUCCESS (status) && method_call) {
 			if (node->type == ACPI_TYPE_METHOD) {
-				method_node = node;
-				ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "method - %p Path=%p\n",
-					method_node, path));
+				/*
+				 * This name is actually a control method invocation
+				 */
+				method_desc = acpi_ns_get_attached_object (node);
+				ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+					"Control Method - %p Desc %p Path=%p\n",
+					node, method_desc, path));
 
 				name_op = acpi_ps_alloc_op (AML_INT_NAMEPATH_OP);
-				if (name_op) {
-					/* Change arg into a METHOD CALL and attach name to it */
-
-					acpi_ps_init_op (arg, AML_INT_METHODCALL_OP);
+				if (!name_op) {
+					return_ACPI_STATUS (AE_NO_MEMORY);
+				}
 
-					name_op->value.name = path;
+				/* Change arg into a METHOD CALL and attach name to it */
 
-					/* Point METHODCALL/NAME to the METHOD Node */
+				acpi_ps_init_op (arg, AML_INT_METHODCALL_OP);
+				name_op->common.value.name = path;
 
-					name_op->node = method_node;
-					acpi_ps_append_arg (arg, name_op);
+				/* Point METHODCALL/NAME to the METHOD Node */
 
-					if (!method_node->object) {
-						return_VOID;
-					}
+				name_op->common.node = node;
+				acpi_ps_append_arg (arg, name_op);
 
-					*arg_count = (method_node->object)->method.param_count;
+				if (!method_desc) {
+					ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+						"Control Method - %p has no attached object\n",
+						node));
+					return_ACPI_STATUS (AE_AML_INTERNAL);
 				}
 
-				return_VOID;
+				ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+					"Control Method - %p Args %X\n",
+					node, method_desc->method.param_count));
+
+				/* Get the number of arguments to expect */
+
+				walk_state->arg_count = method_desc->method.param_count;
+				return_ACPI_STATUS (AE_OK);
 			}
 
 			/*
@@ -407,28 +337,53 @@
 			 * (See code below)
 			 */
 		}
+
+		if (ACPI_FAILURE (status)) {
+			/*
+			 * 1) Any error other than NOT_FOUND is always severe
+			 * 2) NOT_FOUND is only important if we are executing a method.
+			 * 3) If executing a cond_ref_of opcode, NOT_FOUND is ok.
+			 */
+			if ((((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) &&
+				(status == AE_NOT_FOUND)                                                &&
+				(walk_state->op->common.aml_opcode != AML_COND_REF_OF_OP)) ||
+
+				(status != AE_NOT_FOUND)) {
+				ACPI_REPORT_NSERROR (path, status);
+
+				acpi_os_printf ("search_node %p start_node %p return_node %p\n",
+					scope_info.scope.node, parser_state->start_node, node);
+
+
+			}
+			else {
+				/*
+				 * We got a NOT_FOUND during table load or we encountered
+				 * a cond_ref_of(x) where the target does not exist.
+				 * -- either case is ok
+				 */
+				status = AE_OK;
+			}
+		}
 	}
 
 	/*
-	 * Either we didn't find the object in the namespace, or the object is
-	 * something other than a control method.  Just initialize the Op with the
-	 * pathname.
+	 * Regardless of success/failure above,
+	 * Just initialize the Op with the pathname.
 	 */
 	acpi_ps_init_op (arg, AML_INT_NAMEPATH_OP);
-	arg->value.name = path;
-
+	arg->common.value.name = path;
 
-	return_VOID;
+	return_ACPI_STATUS (status);
 }
 
-#endif
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_get_next_simple_arg
+ * FUNCTION:    acpi_ps_get_next_simple_arg
  *
- * PARAMETERS:  Parser_state        - Current parser state object
- *              Arg_type            - The argument type (AML_*_ARG)
+ * PARAMETERS:  parser_state        - Current parser state object
+ *              arg_type            - The argument type (AML_*_ARG)
  *              Arg                 - Where the argument is returned
  *
  * RETURN:      None
@@ -439,20 +394,19 @@
 
 void
 acpi_ps_get_next_simple_arg (
-	acpi_parse_state        *parser_state,
-	u32                     arg_type,
-	acpi_parse_object       *arg)
+	struct acpi_parse_state         *parser_state,
+	u32                             arg_type,
+	union acpi_parse_object         *arg)
 {
 
-	FUNCTION_TRACE_U32 ("Ps_get_next_simple_arg", arg_type);
+	ACPI_FUNCTION_TRACE_U32 ("ps_get_next_simple_arg", arg_type);
 
 
 	switch (arg_type) {
-
 	case ARGP_BYTEDATA:
 
 		acpi_ps_init_op (arg, AML_BYTE_OP);
-		arg->value.integer = (u32) GET8 (parser_state->aml);
+		arg->common.value.integer = (u32) ACPI_GET8 (parser_state->aml);
 		parser_state->aml++;
 		break;
 
@@ -463,7 +417,7 @@
 
 		/* Get 2 bytes from the AML stream */
 
-		MOVE_UNALIGNED16_TO_32 (&arg->value.integer, parser_state->aml);
+		ACPI_MOVE_16_TO_32 (&arg->common.value.integer, parser_state->aml);
 		parser_state->aml += 2;
 		break;
 
@@ -474,7 +428,7 @@
 
 		/* Get 4 bytes from the AML stream */
 
-		MOVE_UNALIGNED32_TO_32 (&arg->value.integer, parser_state->aml);
+		ACPI_MOVE_32_TO_32 (&arg->common.value.integer, parser_state->aml);
 		parser_state->aml += 4;
 		break;
 
@@ -485,7 +439,7 @@
 
 		/* Get 8 bytes from the AML stream */
 
-		MOVE_UNALIGNED64_TO_64 (&arg->value.integer, parser_state->aml);
+		ACPI_MOVE_64_TO_64 (&arg->common.value.integer, parser_state->aml);
 		parser_state->aml += 8;
 		break;
 
@@ -493,9 +447,9 @@
 	case ARGP_CHARLIST:
 
 		acpi_ps_init_op (arg, AML_STRING_OP);
-		arg->value.string = (char*) parser_state->aml;
+		arg->common.value.string = (char *) parser_state->aml;
 
-		while (GET8 (parser_state->aml) != '\0') {
+		while (ACPI_GET8 (parser_state->aml) != '\0') {
 			parser_state->aml++;
 		}
 		parser_state->aml++;
@@ -506,7 +460,13 @@
 	case ARGP_NAMESTRING:
 
 		acpi_ps_init_op (arg, AML_INT_NAMEPATH_OP);
-		arg->value.name = acpi_ps_get_next_namestring (parser_state);
+		arg->common.value.name = acpi_ps_get_next_namestring (parser_state);
+		break;
+
+
+	default:
+
+		ACPI_REPORT_ERROR (("Invalid arg_type %X\n", arg_type));
 		break;
 	}
 
@@ -516,47 +476,44 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_get_next_field
+ * FUNCTION:    acpi_ps_get_next_field
  *
- * PARAMETERS:  Parser_state        - Current parser state object
+ * PARAMETERS:  parser_state        - Current parser state object
  *
  * RETURN:      A newly allocated FIELD op
  *
- * DESCRIPTION: Get next field (Named_field, Reserved_field, or Access_field)
+ * DESCRIPTION: Get next field (named_field, reserved_field, or access_field)
  *
  ******************************************************************************/
 
-acpi_parse_object *
+union acpi_parse_object *
 acpi_ps_get_next_field (
-	acpi_parse_state        *parser_state)
+	struct acpi_parse_state         *parser_state)
 {
-	u32                     aml_offset = parser_state->aml -
-			 parser_state->aml_start;
-	acpi_parse_object       *field;
-	u16                     opcode;
-	u32                     name;
+	u32                             aml_offset = ACPI_PTR_DIFF (parser_state->aml,
+			 parser_state->aml_start);
+	union acpi_parse_object         *field;
+	u16                             opcode;
+	u32                             name;
 
 
-	FUNCTION_TRACE ("Ps_get_next_field");
+	ACPI_FUNCTION_TRACE ("ps_get_next_field");
 
 
 	/* determine field type */
 
-	switch (GET8 (parser_state->aml)) {
-
+	switch (ACPI_GET8 (parser_state->aml)) {
 	default:
 
 		opcode = AML_INT_NAMEDFIELD_OP;
 		break;
 
-
 	case 0x00:
 
 		opcode = AML_INT_RESERVEDFIELD_OP;
 		parser_state->aml++;
 		break;
 
-
 	case 0x01:
 
 		opcode = AML_INT_ACCESSFIELD_OP;
@@ -568,43 +525,53 @@
 	/* Allocate a new field op */
 
 	field = acpi_ps_alloc_op (opcode);
-	if (field) {
-		field->aml_offset = aml_offset;
+	if (!field) {
+		return_PTR (NULL);
+	}
 
-		/* Decode the field type */
+	field->common.aml_offset = aml_offset;
 
-		switch (opcode) {
-		case AML_INT_NAMEDFIELD_OP:
+	/* Decode the field type */
 
-			/* Get the 4-character name */
+	switch (opcode) {
+	case AML_INT_NAMEDFIELD_OP:
 
-			MOVE_UNALIGNED32_TO_32 (&name, parser_state->aml);
-			acpi_ps_set_name (field, name);
-			parser_state->aml += 4;
+		/* Get the 4-character name */
 
-			/* Get the length which is encoded as a package length */
+		ACPI_MOVE_32_TO_32 (&name, parser_state->aml);
+		acpi_ps_set_name (field, name);
+		parser_state->aml += ACPI_NAME_SIZE;
 
-			field->value.size = acpi_ps_get_next_package_length (parser_state);
-			break;
+		/* Get the length which is encoded as a package length */
 
+		field->common.value.size = acpi_ps_get_next_package_length (parser_state);
+		break;
 
-		case AML_INT_RESERVEDFIELD_OP:
 
-			/* Get the length which is encoded as a package length */
+	case AML_INT_RESERVEDFIELD_OP:
 
-			field->value.size = acpi_ps_get_next_package_length (parser_state);
-			break;
+		/* Get the length which is encoded as a package length */
 
+		field->common.value.size = acpi_ps_get_next_package_length (parser_state);
+		break;
 
-		case AML_INT_ACCESSFIELD_OP:
 
-			/* Get Access_type and Access_atrib and merge into the field Op */
+	case AML_INT_ACCESSFIELD_OP:
 
-			field->value.integer = ((GET8 (parser_state->aml) << 8) |
-					  GET8 (parser_state->aml));
-			parser_state->aml += 2;
-			break;
-		}
+		/*
+		 * Get access_type and access_attrib and merge into the field Op
+		 * access_type is first operand, access_attribute is second
+		 */
+		field->common.value.integer = (ACPI_GET8 (parser_state->aml) << 8);
+		parser_state->aml++;
+		field->common.value.integer |= ACPI_GET8 (parser_state->aml);
+		parser_state->aml++;
+		break;
+
+	default:
+
+		/* Opcode was set in previous switch */
+		break;
 	}
 
 	return_PTR (field);
@@ -613,33 +580,35 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_get_next_arg
+ * FUNCTION:    acpi_ps_get_next_arg
  *
- * PARAMETERS:  Parser_state        - Current parser state object
- *              Arg_type            - The argument type (AML_*_ARG)
- *              Arg_count           - If the argument points to a control method
+ * PARAMETERS:  parser_state        - Current parser state object
+ *              arg_type            - The argument type (AML_*_ARG)
+ *              arg_count           - If the argument points to a control method
  *                                    the method's argument is returned here.
  *
- * RETURN:      An op object containing the next argument.
+ * RETURN:      Status, and an op object containing the next argument.
  *
  * DESCRIPTION: Get next argument (including complex list arguments that require
  *              pushing the parser stack)
  *
  ******************************************************************************/
 
-acpi_parse_object *
+acpi_status
 acpi_ps_get_next_arg (
-	acpi_parse_state        *parser_state,
-	u32                     arg_type,
-	u32                     *arg_count)
+	struct acpi_walk_state          *walk_state,
+	struct acpi_parse_state         *parser_state,
+	u32                             arg_type,
+	union acpi_parse_object         **return_arg)
 {
-	acpi_parse_object       *arg = NULL;
-	acpi_parse_object       *prev = NULL;
-	acpi_parse_object       *field;
-	u32                     subop;
+	union acpi_parse_object         *arg = NULL;
+	union acpi_parse_object         *prev = NULL;
+	union acpi_parse_object         *field;
+	u32                             subop;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE_PTR ("Ps_get_next_arg", parser_state);
+	ACPI_FUNCTION_TRACE_PTR ("ps_get_next_arg", parser_state);
 
 
 	switch (arg_type) {
@@ -653,15 +622,16 @@
 		/* constants, strings, and namestrings are all the same size */
 
 		arg = acpi_ps_alloc_op (AML_BYTE_OP);
-		if (arg) {
-			acpi_ps_get_next_simple_arg (parser_state, arg_type, arg);
+		if (!arg) {
+			return_ACPI_STATUS (AE_NO_MEMORY);
 		}
+		acpi_ps_get_next_simple_arg (parser_state, arg_type, arg);
 		break;
 
 
 	case ARGP_PKGLENGTH:
 
-		/* package length, nothing returned */
+		/* Package length, nothing returned */
 
 		parser_state->pkg_end = acpi_ps_get_next_package_end (parser_state);
 		break;
@@ -670,18 +640,17 @@
 	case ARGP_FIELDLIST:
 
 		if (parser_state->aml < parser_state->pkg_end) {
-			/* non-empty list */
+			/* Non-empty list */
 
 			while (parser_state->aml < parser_state->pkg_end) {
 				field = acpi_ps_get_next_field (parser_state);
 				if (!field) {
-					break;
+					return_ACPI_STATUS (AE_NO_MEMORY);
 				}
 
 				if (prev) {
-					prev->next = field;
+					prev->common.next = field;
 				}
-
 				else {
 					arg = field;
 				}
@@ -689,7 +658,7 @@
 				prev = field;
 			}
 
-			/* skip to End of byte data */
+			/* Skip to End of byte data */
 
 			parser_state->aml = parser_state->pkg_end;
 		}
@@ -699,17 +668,20 @@
 	case ARGP_BYTELIST:
 
 		if (parser_state->aml < parser_state->pkg_end) {
-			/* non-empty list */
+			/* Non-empty list */
 
 			arg = acpi_ps_alloc_op (AML_INT_BYTELIST_OP);
-			if (arg) {
-				/* fill in bytelist data */
-
-				arg->value.size = (parser_state->pkg_end - parser_state->aml);
-				((acpi_parse2_object *) arg)->data = parser_state->aml;
+			if (!arg) {
+				return_ACPI_STATUS (AE_NO_MEMORY);
 			}
 
-			/* skip to End of byte data */
+			/* Fill in bytelist data */
+
+			arg->common.value.size = ACPI_PTR_DIFF (parser_state->pkg_end,
+					  parser_state->aml);
+			arg->named.data = parser_state->aml;
+
+			/* Skip to End of byte data */
 
 			parser_state->aml = parser_state->pkg_end;
 		}
@@ -717,24 +689,26 @@
 
 
 	case ARGP_TARGET:
-	case ARGP_SUPERNAME: {
-			subop = acpi_ps_peek_opcode (parser_state);
-			if (subop == 0              ||
-				acpi_ps_is_leading_char (subop) ||
-				acpi_ps_is_prefix_char (subop)) {
-				/* Null_name or Name_string */
-
-				arg = acpi_ps_alloc_op (AML_INT_NAMEPATH_OP);
-				if (arg) {
-					acpi_ps_get_next_namepath (parser_state, arg, arg_count, 0);
-				}
+	case ARGP_SUPERNAME:
+	case ARGP_SIMPLENAME:
+
+		subop = acpi_ps_peek_opcode (parser_state);
+		if (subop == 0                  ||
+			acpi_ps_is_leading_char (subop) ||
+			acpi_ps_is_prefix_char (subop)) {
+			/* null_name or name_string */
+
+			arg = acpi_ps_alloc_op (AML_INT_NAMEPATH_OP);
+			if (!arg) {
+				return_ACPI_STATUS (AE_NO_MEMORY);
 			}
 
-			else {
-				/* single complex argument, nothing returned */
+			status = acpi_ps_get_next_namepath (walk_state, parser_state, arg, 0);
+		}
+		else {
+			/* single complex argument, nothing returned */
 
-				*arg_count = 1;
-			}
+			walk_state->arg_count = 1;
 		}
 		break;
 
@@ -744,7 +718,7 @@
 
 		/* single complex argument, nothing returned */
 
-		*arg_count = 1;
+		walk_state->arg_count = 1;
 		break;
 
 
@@ -755,10 +729,18 @@
 		if (parser_state->aml < parser_state->pkg_end) {
 			/* non-empty list of variable arguments, nothing returned */
 
-			*arg_count = ACPI_VAR_ARGS;
+			walk_state->arg_count = ACPI_VAR_ARGS;
 		}
 		break;
+
+
+	default:
+
+		ACPI_REPORT_ERROR (("Invalid arg_type: %X\n", arg_type));
+		status = AE_AML_OPERAND_TYPE;
+		break;
 	}
 
-	return_PTR (arg);
+	*return_arg = arg;
+	return_ACPI_STATUS (status);
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/parser/psopcode.c linux-2.4.22-pre2/drivers/acpi/parser/psopcode.c
--- linux-2.4.21/drivers/acpi/parser/psopcode.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/parser/psopcode.c	2003-06-26 21:43:12.000000000 +0000
@@ -1,36 +1,54 @@
 /******************************************************************************
  *
  * Module Name: psopcode - Parser/Interpreter opcode information table
- *              $Revision: 49 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "amlcode.h"
+#include <acpi/acpi.h>
+#include <acpi/acparser.h>
+#include <acpi/amlcode.h>
 
 
 #define _COMPONENT          ACPI_PARSER
-	 MODULE_NAME         ("psopcode")
+	 ACPI_MODULE_NAME    ("psopcode")
 
 
 #define _UNK                        0x6B
@@ -45,14 +63,14 @@
 #define _UNKNOWN_OPCODE             0x02    /* An example unknown opcode */
 
 #define MAX_EXTENDED_OPCODE         0x88
-#define NUM_EXTENDED_OPCODE         MAX_EXTENDED_OPCODE + 1
+#define NUM_EXTENDED_OPCODE         (MAX_EXTENDED_OPCODE + 1)
 #define MAX_INTERNAL_OPCODE
-#define NUM_INTERNAL_OPCODE         MAX_INTERNAL_OPCODE + 1
+#define NUM_INTERNAL_OPCODE         (MAX_INTERNAL_OPCODE + 1)
 
 
 /*******************************************************************************
  *
- * NAME:        Acpi_gbl_Aml_op_info
+ * NAME:        acpi_gbl_aml_op_info
  *
  * DESCRIPTION: Opcode table. Each entry contains <opcode, type, name, operands>
  *              The name is a simple ascii string, the operand specifier is an
@@ -184,7 +202,7 @@
 #define ARGP_TO_STRING_OP               ARGP_LIST3 (ARGP_TERMARG,    ARGP_TERMARG,       ARGP_TARGET)
 #define ARGP_TYPE_OP                    ARGP_LIST1 (ARGP_SUPERNAME)
 #define ARGP_UNLOAD_OP                  ARGP_LIST1 (ARGP_SUPERNAME)
-#define ARGP_VAR_PACKAGE_OP             ARGP_LIST3 (ARGP_PKGLENGTH,  ARGP_BYTEDATA,      ARGP_DATAOBJLIST)
+#define ARGP_VAR_PACKAGE_OP             ARGP_LIST3 (ARGP_PKGLENGTH,  ARGP_TERMARG,       ARGP_DATAOBJLIST)
 #define ARGP_WAIT_OP                    ARGP_LIST2 (ARGP_SUPERNAME,  ARGP_TERMARG)
 #define ARGP_WHILE_OP                   ARGP_LIST3 (ARGP_PKGLENGTH,  ARGP_TERMARG,       ARGP_TERMLIST)
 #define ARGP_WORD_OP                    ARGP_LIST1 (ARGP_WORDDATA)
@@ -195,7 +213,7 @@
  * All AML opcodes and the runtime arguments for each.  Used by the AML interpreter  Each list is compressed
  * into a 32-bit number and stored in the master opcode table at the end of this file.
  *
- * (Used by Prep_operands procedure and the ASL Compiler)
+ * (Used by prep_operands procedure and the ASL Compiler)
  */
 
 
@@ -219,7 +237,7 @@
 #define ARGI_BIT_XOR_OP                 ARGI_LIST3 (ARGI_INTEGER,    ARGI_INTEGER,       ARGI_TARGETREF)
 #define ARGI_BREAK_OP                   ARG_NONE
 #define ARGI_BREAK_POINT_OP             ARG_NONE
-#define ARGI_BUFFER_OP                  ARGI_INVALID_OPCODE
+#define ARGI_BUFFER_OP                  ARGI_LIST1 (ARGI_INTEGER)
 #define ARGI_BYTE_OP                    ARGI_INVALID_OPCODE
 #define ARGI_BYTELIST_OP                ARGI_INVALID_OPCODE
 #define ARGI_CONCAT_OP                  ARGI_LIST3 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA,   ARGI_TARGETREF)
@@ -236,7 +254,7 @@
 #define ARGI_DATA_REGION_OP             ARGI_LIST3 (ARGI_STRING,     ARGI_STRING,       ARGI_STRING)
 #define ARGI_DEBUG_OP                   ARG_NONE
 #define ARGI_DECREMENT_OP               ARGI_LIST1 (ARGI_INTEGER_REF)
-#define ARGI_DEREF_OF_OP                ARGI_LIST1 (ARGI_REFERENCE)
+#define ARGI_DEREF_OF_OP                ARGI_LIST1 (ARGI_REF_OR_STRING)
 #define ARGI_DEVICE_OP                  ARGI_INVALID_OPCODE
 #define ARGI_DIVIDE_OP                  ARGI_LIST4 (ARGI_INTEGER,    ARGI_INTEGER,       ARGI_TARGETREF,    ARGI_TARGETREF)
 #define ARGI_DWORD_OP                   ARGI_INVALID_OPCODE
@@ -259,8 +277,8 @@
 #define ARGI_LLESSEQUAL_OP              ARGI_INVALID_OPCODE
 #define ARGI_LNOT_OP                    ARGI_LIST1 (ARGI_INTEGER)
 #define ARGI_LNOTEQUAL_OP               ARGI_INVALID_OPCODE
-#define ARGI_LOAD_OP                    ARGI_LIST2 (ARGI_REGION,     ARGI_TARGETREF)
-#define ARGI_LOAD_TABLE_OP              ARGI_LIST6 (ARGI_STRING,     ARGI_STRING,        ARGI_STRING,       ARGI_STRING,    ARGI_STRING, ARGI_TARGETREF)
+#define ARGI_LOAD_OP                    ARGI_LIST2 (ARGI_REGION_OR_FIELD,ARGI_TARGETREF)
+#define ARGI_LOAD_TABLE_OP              ARGI_LIST6 (ARGI_STRING,     ARGI_STRING,        ARGI_STRING,       ARGI_STRING,    ARGI_STRING, ARGI_ANYTYPE)
 #define ARGI_LOCAL0                     ARG_NONE
 #define ARGI_LOCAL1                     ARG_NONE
 #define ARGI_LOCAL2                     ARG_NONE
@@ -273,7 +291,7 @@
 #define ARGI_MATCH_OP                   ARGI_LIST6 (ARGI_PACKAGE,    ARGI_INTEGER,       ARGI_INTEGER,      ARGI_INTEGER,   ARGI_INTEGER,   ARGI_INTEGER)
 #define ARGI_METHOD_OP                  ARGI_INVALID_OPCODE
 #define ARGI_METHODCALL_OP              ARGI_INVALID_OPCODE
-#define ARGI_MID_OP                     ARGI_LIST4 (ARGI_BUFFERSTRING,ARGI_INTEGER,      ARGI_INTEGER,      ARGI_TARGETREF)
+#define ARGI_MID_OP                     ARGI_LIST4 (ARGI_BUFFER_OR_STRING,ARGI_INTEGER,  ARGI_INTEGER,      ARGI_TARGETREF)
 #define ARGI_MOD_OP                     ARGI_LIST3 (ARGI_INTEGER,    ARGI_INTEGER,       ARGI_TARGETREF)
 #define ARGI_MULTIPLY_OP                ARGI_LIST3 (ARGI_INTEGER,    ARGI_INTEGER,       ARGI_TARGETREF)
 #define ARGI_MUTEX_OP                   ARGI_INVALID_OPCODE
@@ -284,7 +302,7 @@
 #define ARGI_NOTIFY_OP                  ARGI_LIST2 (ARGI_DEVICE_REF, ARGI_INTEGER)
 #define ARGI_ONE_OP                     ARG_NONE
 #define ARGI_ONES_OP                    ARG_NONE
-#define ARGI_PACKAGE_OP                 ARGI_INVALID_OPCODE
+#define ARGI_PACKAGE_OP                 ARGI_LIST1 (ARGI_INTEGER)
 #define ARGI_POWER_RES_OP               ARGI_INVALID_OPCODE
 #define ARGI_PROCESSOR_OP               ARGI_INVALID_OPCODE
 #define ARGI_QWORD_OP                   ARGI_INVALID_OPCODE
@@ -315,7 +333,7 @@
 #define ARGI_TO_STRING_OP               ARGI_LIST3 (ARGI_BUFFER,     ARGI_INTEGER,       ARGI_FIXED_TARGET)
 #define ARGI_TYPE_OP                    ARGI_LIST1 (ARGI_ANYTYPE)
 #define ARGI_UNLOAD_OP                  ARGI_LIST1 (ARGI_DDBHANDLE)
-#define ARGI_VAR_PACKAGE_OP             ARGI_INVALID_OPCODE
+#define ARGI_VAR_PACKAGE_OP             ARGI_LIST1 (ARGI_INTEGER)
 #define ARGI_WAIT_OP                    ARGI_LIST2 (ARGI_EVENT,      ARGI_INTEGER)
 #define ARGI_WHILE_OP                   ARGI_INVALID_OPCODE
 #define ARGI_WORD_OP                    ARGI_INVALID_OPCODE
@@ -328,7 +346,7 @@
 
 /******************************************************************************
 
- Opcodes that have associated namespace objects
+ Opcodes that have associated namespace objects (AML_NSOBJECT flag)
 
 	AML_SCOPE_OP
 	AML_DEVICE_OP
@@ -354,7 +372,7 @@
 	AML_INT_METHODCALL_OP
 	AML_INT_NAMEPATH_OP
 
-  Opcodes that are "namespace" opcodes
+  Opcodes that are "namespace" opcodes (AML_NSOPCODE flag)
 
 	AML_SCOPE_OP
 	AML_DEVICE_OP
@@ -372,7 +390,7 @@
 	AML_REGION_OP
 	AML_INT_NAMEDFIELD_OP
 
-  Opcodes that have an associated namespace node
+  Opcodes that have an associated namespace node (AML_NSNODE flag)
 
 	AML_SCOPE_OP
 	AML_DEVICE_OP
@@ -395,7 +413,7 @@
 	AML_INT_METHODCALL_OP
 	AML_INT_NAMEPATH_OP
 
-  Opcodes that define named ACPI objects
+  Opcodes that define named ACPI objects (AML_NAMED flag)
 
 	AML_SCOPE_OP
 	AML_DEVICE_OP
@@ -410,8 +428,8 @@
 	AML_REGION_OP
 	AML_INT_NAMEDFIELD_OP
 
-	Opcodes that contain executable AML as part of the definition that
-	must be deferred until needed
+  Opcodes that contain executable AML as part of the definition that
+  must be deferred until needed
 
 	AML_METHOD_OP
 	AML_VAR_PACKAGE_OP
@@ -422,6 +440,7 @@
 	AML_CREATE_DWORD_FIELD_OP
 	AML_CREATE_QWORD_FIELD_OP
 	AML_REGION_OP
+	AML_BUFFER_OP
 
   Field opcodes
 
@@ -447,146 +466,149 @@
  */
 
 
-static const acpi_opcode_info    aml_op_info[] =
+const struct acpi_opcode_info     acpi_gbl_aml_op_info[AML_NUM_OPCODES] =
 {
-/* Index           Name                 Parser Args               Interpreter Args                 Class                      Type                  Flags */
+/*! [Begin] no source code translation */
+/* Index           Name                 Parser Args               Interpreter Args                ObjectType                    Class                      Type                  Flags */
 
-/* 00 */ ACPI_OP ("Zero",               ARGP_ZERO_OP,              ARGI_ZERO_OP,               AML_CLASS_ARGUMENT,        AML_TYPE_CONSTANT,        0),
-/* 01 */ ACPI_OP ("One",                ARGP_ONE_OP,               ARGI_ONE_OP,                AML_CLASS_ARGUMENT,        AML_TYPE_CONSTANT,        0),
-/* 02 */ ACPI_OP ("Alias",              ARGP_ALIAS_OP,             ARGI_ALIAS_OP,              AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 03 */ ACPI_OP ("Name",               ARGP_NAME_OP,              ARGI_NAME_OP,               AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_COMPLEX,   AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 04 */ ACPI_OP ("Byte_const",         ARGP_BYTE_OP,              ARGI_BYTE_OP,               AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         0),
-/* 05 */ ACPI_OP ("Word_const",         ARGP_WORD_OP,              ARGI_WORD_OP,               AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         0),
-/* 06 */ ACPI_OP ("Dword_const",        ARGP_DWORD_OP,             ARGI_DWORD_OP,              AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         0),
-/* 07 */ ACPI_OP ("String",             ARGP_STRING_OP,            ARGI_STRING_OP,             AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         0),
-/* 08 */ ACPI_OP ("Scope",              ARGP_SCOPE_OP,             ARGI_SCOPE_OP,              AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_NO_OBJ,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 09 */ ACPI_OP ("Buffer",             ARGP_BUFFER_OP,            ARGI_BUFFER_OP,             AML_CLASS_ARGUMENT,        AML_TYPE_DATA_TERM,       AML_HAS_ARGS),
-/* 0A */ ACPI_OP ("Package",            ARGP_PACKAGE_OP,           ARGI_PACKAGE_OP,            AML_CLASS_ARGUMENT,        AML_TYPE_DATA_TERM,       AML_HAS_ARGS),
-/* 0B */ ACPI_OP ("Method",             ARGP_METHOD_OP,            ARGI_METHOD_OP,             AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_COMPLEX,   AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER),
-/* 0C */ ACPI_OP ("Local0",             ARGP_LOCAL0,               ARGI_LOCAL0,                AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
-/* 0D */ ACPI_OP ("Local1",             ARGP_LOCAL1,               ARGI_LOCAL1,                AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
-/* 0E */ ACPI_OP ("Local2",             ARGP_LOCAL2,               ARGI_LOCAL2,                AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
-/* 0F */ ACPI_OP ("Local3",             ARGP_LOCAL3,               ARGI_LOCAL3,                AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
-/* 10 */ ACPI_OP ("Local4",             ARGP_LOCAL4,               ARGI_LOCAL4,                AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
-/* 11 */ ACPI_OP ("Local5",             ARGP_LOCAL5,               ARGI_LOCAL5,                AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
-/* 12 */ ACPI_OP ("Local6",             ARGP_LOCAL6,               ARGI_LOCAL6,                AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
-/* 13 */ ACPI_OP ("Local7",             ARGP_LOCAL7,               ARGI_LOCAL7,                AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
-/* 14 */ ACPI_OP ("Arg0",               ARGP_ARG0,                 ARGI_ARG0,                  AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
-/* 15 */ ACPI_OP ("Arg1",               ARGP_ARG1,                 ARGI_ARG1,                  AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
-/* 16 */ ACPI_OP ("Arg2",               ARGP_ARG2,                 ARGI_ARG2,                  AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
-/* 17 */ ACPI_OP ("Arg3",               ARGP_ARG3,                 ARGI_ARG3,                  AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
-/* 18 */ ACPI_OP ("Arg4",               ARGP_ARG4,                 ARGI_ARG4,                  AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
-/* 19 */ ACPI_OP ("Arg5",               ARGP_ARG5,                 ARGI_ARG5,                  AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
-/* 1_a */ ACPI_OP ("Arg6",              ARGP_ARG6,                 ARGI_ARG6,                  AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
-/* 1_b */ ACPI_OP ("Store",             ARGP_STORE_OP,             ARGI_STORE_OP,              AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 1_c */ ACPI_OP ("Ref_of",            ARGP_REF_OF_OP,            ARGI_REF_OF_OP,             AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
-/* 1_d */ ACPI_OP ("Add",               ARGP_ADD_OP,               ARGI_ADD_OP,                AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
-/* 1_e */ ACPI_OP ("Concatenate",       ARGP_CONCAT_OP,            ARGI_CONCAT_OP,             AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R),
-/* 1_f */ ACPI_OP ("Subtract",          ARGP_SUBTRACT_OP,          ARGI_SUBTRACT_OP,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
-/* 20 */ ACPI_OP ("Increment",          ARGP_INCREMENT_OP,         ARGI_INCREMENT_OP,          AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
-/* 21 */ ACPI_OP ("Decrement",          ARGP_DECREMENT_OP,         ARGI_DECREMENT_OP,          AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
-/* 22 */ ACPI_OP ("Multiply",           ARGP_MULTIPLY_OP,          ARGI_MULTIPLY_OP,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
-/* 23 */ ACPI_OP ("Divide",             ARGP_DIVIDE_OP,            ARGI_DIVIDE_OP,             AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_2T_1R,   AML_FLAGS_EXEC_2A_2T_1R),
-/* 24 */ ACPI_OP ("Shift_left",         ARGP_SHIFT_LEFT_OP,        ARGI_SHIFT_LEFT_OP,         AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
-/* 25 */ ACPI_OP ("Shift_right",        ARGP_SHIFT_RIGHT_OP,       ARGI_SHIFT_RIGHT_OP,        AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
-/* 26 */ ACPI_OP ("And",                ARGP_BIT_AND_OP,           ARGI_BIT_AND_OP,            AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
-/* 27 */ ACPI_OP ("NAnd",               ARGP_BIT_NAND_OP,          ARGI_BIT_NAND_OP,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
-/* 28 */ ACPI_OP ("Or",                 ARGP_BIT_OR_OP,            ARGI_BIT_OR_OP,             AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
-/* 29 */ ACPI_OP ("NOr",                ARGP_BIT_NOR_OP,           ARGI_BIT_NOR_OP,            AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
-/* 2_a */ ACPI_OP ("XOr",               ARGP_BIT_XOR_OP,           ARGI_BIT_XOR_OP,            AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
-/* 2_b */ ACPI_OP ("Not",               ARGP_BIT_NOT_OP,           ARGI_BIT_NOT_OP,            AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 2_c */ ACPI_OP ("Find_set_left_bit", ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP,  AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 2_d */ ACPI_OP ("Find_set_right_bit", ARGP_FIND_SET_RIGHT_BIT_OP,ARGI_FIND_SET_RIGHT_BIT_OP, AML_CLASS_EXECUTE,        AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 2_e */ ACPI_OP ("Deref_of",          ARGP_DEREF_OF_OP,          ARGI_DEREF_OF_OP,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
-/* 2_f */ ACPI_OP ("Notify",            ARGP_NOTIFY_OP,            ARGI_NOTIFY_OP,             AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_0R,   AML_FLAGS_EXEC_2A_0T_0R),
-/* 30 */ ACPI_OP ("Size_of",            ARGP_SIZE_OF_OP,           ARGI_SIZE_OF_OP,            AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
-/* 31 */ ACPI_OP ("Index",              ARGP_INDEX_OP,             ARGI_INDEX_OP,              AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R),
-/* 32 */ ACPI_OP ("Match",              ARGP_MATCH_OP,             ARGI_MATCH_OP,              AML_CLASS_EXECUTE,         AML_TYPE_EXEC_6A_0T_1R,   AML_FLAGS_EXEC_6A_0T_1R),
-/* 33 */ ACPI_OP ("Create_dWord_field", ARGP_CREATE_DWORD_FIELD_OP,ARGI_CREATE_DWORD_FIELD_OP, AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
-/* 34 */ ACPI_OP ("Create_word_field",  ARGP_CREATE_WORD_FIELD_OP, ARGI_CREATE_WORD_FIELD_OP,  AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
-/* 35 */ ACPI_OP ("Create_byte_field",  ARGP_CREATE_BYTE_FIELD_OP, ARGI_CREATE_BYTE_FIELD_OP,  AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
-/* 36 */ ACPI_OP ("Create_bit_field",   ARGP_CREATE_BIT_FIELD_OP,  ARGI_CREATE_BIT_FIELD_OP,   AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
-/* 37 */ ACPI_OP ("Object_type",        ARGP_TYPE_OP,              ARGI_TYPE_OP,               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,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL),
-/* 39 */ ACPI_OP ("LOr",                ARGP_LOR_OP,               ARGI_LOR_OP,                AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL),
-/* 3_a */ ACPI_OP ("LNot",              ARGP_LNOT_OP,              ARGI_LNOT_OP,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
-/* 3_b */ ACPI_OP ("LEqual",            ARGP_LEQUAL_OP,            ARGI_LEQUAL_OP,             AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL),
-/* 3_c */ ACPI_OP ("LGreater",          ARGP_LGREATER_OP,          ARGI_LGREATER_OP,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL),
-/* 3_d */ ACPI_OP ("LLess",             ARGP_LLESS_OP,             ARGI_LLESS_OP,              AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL),
-/* 3_e */ ACPI_OP ("If",                ARGP_IF_OP,                ARGI_IF_OP,                 AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         AML_HAS_ARGS),
-/* 3_f */ ACPI_OP ("Else",              ARGP_ELSE_OP,              ARGI_ELSE_OP,               AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         AML_HAS_ARGS),
-/* 40 */ ACPI_OP ("While",              ARGP_WHILE_OP,             ARGI_WHILE_OP,              AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         AML_HAS_ARGS),
-/* 41 */ ACPI_OP ("Noop",               ARGP_NOOP_OP,              ARGI_NOOP_OP,               AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         0),
-/* 42 */ ACPI_OP ("Return",             ARGP_RETURN_OP,            ARGI_RETURN_OP,             AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         AML_HAS_ARGS),
-/* 43 */ ACPI_OP ("Break",              ARGP_BREAK_OP,             ARGI_BREAK_OP,              AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         0),
-/* 44 */ ACPI_OP ("Break_point",        ARGP_BREAK_POINT_OP,       ARGI_BREAK_POINT_OP,        AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         0),
-/* 45 */ ACPI_OP ("Ones",               ARGP_ONES_OP,              ARGI_ONES_OP,               AML_CLASS_ARGUMENT,        AML_TYPE_CONSTANT,        0),
+/* 00 */ ACPI_OP ("Zero",               ARGP_ZERO_OP,              ARGI_ZERO_OP,               ACPI_TYPE_INTEGER,           AML_CLASS_ARGUMENT,        AML_TYPE_CONSTANT,        AML_CONSTANT),
+/* 01 */ ACPI_OP ("One",                ARGP_ONE_OP,               ARGI_ONE_OP,                ACPI_TYPE_INTEGER,           AML_CLASS_ARGUMENT,        AML_TYPE_CONSTANT,        AML_CONSTANT),
+/* 02 */ ACPI_OP ("Alias",              ARGP_ALIAS_OP,             ARGI_ALIAS_OP,              ACPI_TYPE_LOCAL_ALIAS,       AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 03 */ ACPI_OP ("Name",               ARGP_NAME_OP,              ARGI_NAME_OP,               ACPI_TYPE_ANY,               AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_COMPLEX,   AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 04 */ ACPI_OP ("ByteConst",          ARGP_BYTE_OP,              ARGI_BYTE_OP,               ACPI_TYPE_INTEGER,           AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         AML_CONSTANT),
+/* 05 */ ACPI_OP ("WordConst",          ARGP_WORD_OP,              ARGI_WORD_OP,               ACPI_TYPE_INTEGER,           AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         AML_CONSTANT),
+/* 06 */ ACPI_OP ("DwordConst",         ARGP_DWORD_OP,             ARGI_DWORD_OP,              ACPI_TYPE_INTEGER,           AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         AML_CONSTANT),
+/* 07 */ ACPI_OP ("String",             ARGP_STRING_OP,            ARGI_STRING_OP,             ACPI_TYPE_STRING,            AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         AML_CONSTANT),
+/* 08 */ ACPI_OP ("Scope",              ARGP_SCOPE_OP,             ARGI_SCOPE_OP,              ACPI_TYPE_LOCAL_SCOPE,       AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_NO_OBJ,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 09 */ ACPI_OP ("Buffer",             ARGP_BUFFER_OP,            ARGI_BUFFER_OP,             ACPI_TYPE_BUFFER,            AML_CLASS_CREATE,          AML_TYPE_CREATE_OBJECT,   AML_HAS_ARGS | AML_DEFER | AML_CONSTANT),
+/* 0A */ ACPI_OP ("Package",            ARGP_PACKAGE_OP,           ARGI_PACKAGE_OP,            ACPI_TYPE_PACKAGE,           AML_CLASS_CREATE,          AML_TYPE_CREATE_OBJECT,   AML_HAS_ARGS | AML_DEFER | AML_CONSTANT),
+/* 0B */ ACPI_OP ("Method",             ARGP_METHOD_OP,            ARGI_METHOD_OP,             ACPI_TYPE_METHOD,            AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_COMPLEX,   AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER),
+/* 0C */ ACPI_OP ("Local0",             ARGP_LOCAL0,               ARGI_LOCAL0,                ACPI_TYPE_LOCAL_REFERENCE,   AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
+/* 0D */ ACPI_OP ("Local1",             ARGP_LOCAL1,               ARGI_LOCAL1,                ACPI_TYPE_LOCAL_REFERENCE,   AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
+/* 0E */ ACPI_OP ("Local2",             ARGP_LOCAL2,               ARGI_LOCAL2,                ACPI_TYPE_LOCAL_REFERENCE,   AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
+/* 0F */ ACPI_OP ("Local3",             ARGP_LOCAL3,               ARGI_LOCAL3,                ACPI_TYPE_LOCAL_REFERENCE,   AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
+/* 10 */ ACPI_OP ("Local4",             ARGP_LOCAL4,               ARGI_LOCAL4,                ACPI_TYPE_LOCAL_REFERENCE,   AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
+/* 11 */ ACPI_OP ("Local5",             ARGP_LOCAL5,               ARGI_LOCAL5,                ACPI_TYPE_LOCAL_REFERENCE,   AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
+/* 12 */ ACPI_OP ("Local6",             ARGP_LOCAL6,               ARGI_LOCAL6,                ACPI_TYPE_LOCAL_REFERENCE,   AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
+/* 13 */ ACPI_OP ("Local7",             ARGP_LOCAL7,               ARGI_LOCAL7,                ACPI_TYPE_LOCAL_REFERENCE,   AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
+/* 14 */ ACPI_OP ("Arg0",               ARGP_ARG0,                 ARGI_ARG0,                  ACPI_TYPE_LOCAL_REFERENCE,   AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
+/* 15 */ ACPI_OP ("Arg1",               ARGP_ARG1,                 ARGI_ARG1,                  ACPI_TYPE_LOCAL_REFERENCE,   AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
+/* 16 */ ACPI_OP ("Arg2",               ARGP_ARG2,                 ARGI_ARG2,                  ACPI_TYPE_LOCAL_REFERENCE,   AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
+/* 17 */ ACPI_OP ("Arg3",               ARGP_ARG3,                 ARGI_ARG3,                  ACPI_TYPE_LOCAL_REFERENCE,   AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
+/* 18 */ ACPI_OP ("Arg4",               ARGP_ARG4,                 ARGI_ARG4,                  ACPI_TYPE_LOCAL_REFERENCE,   AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
+/* 19 */ ACPI_OP ("Arg5",               ARGP_ARG5,                 ARGI_ARG5,                  ACPI_TYPE_LOCAL_REFERENCE,   AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
+/* 1A */ ACPI_OP ("Arg6",               ARGP_ARG6,                 ARGI_ARG6,                  ACPI_TYPE_LOCAL_REFERENCE,   AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
+/* 1B */ ACPI_OP ("Store",              ARGP_STORE_OP,             ARGI_STORE_OP,              ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
+/* 1C */ ACPI_OP ("RefOf",              ARGP_REF_OF_OP,            ARGI_REF_OF_OP,             ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
+/* 1D */ ACPI_OP ("Add",                ARGP_ADD_OP,               ARGI_ADD_OP,                ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
+/* 1E */ ACPI_OP ("Concatenate",        ARGP_CONCAT_OP,            ARGI_CONCAT_OP,             ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
+/* 1F */ ACPI_OP ("Subtract",           ARGP_SUBTRACT_OP,          ARGI_SUBTRACT_OP,           ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
+/* 20 */ ACPI_OP ("Increment",          ARGP_INCREMENT_OP,         ARGI_INCREMENT_OP,          ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
+/* 21 */ ACPI_OP ("Decrement",          ARGP_DECREMENT_OP,         ARGI_DECREMENT_OP,          ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
+/* 22 */ ACPI_OP ("Multiply",           ARGP_MULTIPLY_OP,          ARGI_MULTIPLY_OP,           ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
+/* 23 */ ACPI_OP ("Divide",             ARGP_DIVIDE_OP,            ARGI_DIVIDE_OP,             ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_2T_1R,   AML_FLAGS_EXEC_2A_2T_1R | AML_CONSTANT),
+/* 24 */ ACPI_OP ("ShiftLeft",          ARGP_SHIFT_LEFT_OP,        ARGI_SHIFT_LEFT_OP,         ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
+/* 25 */ ACPI_OP ("ShiftRight",         ARGP_SHIFT_RIGHT_OP,       ARGI_SHIFT_RIGHT_OP,        ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
+/* 26 */ ACPI_OP ("And",                ARGP_BIT_AND_OP,           ARGI_BIT_AND_OP,            ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
+/* 27 */ ACPI_OP ("NAnd",               ARGP_BIT_NAND_OP,          ARGI_BIT_NAND_OP,           ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
+/* 28 */ ACPI_OP ("Or",                 ARGP_BIT_OR_OP,            ARGI_BIT_OR_OP,             ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
+/* 29 */ ACPI_OP ("NOr",                ARGP_BIT_NOR_OP,           ARGI_BIT_NOR_OP,            ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
+/* 2A */ ACPI_OP ("XOr",                ARGP_BIT_XOR_OP,           ARGI_BIT_XOR_OP,            ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
+/* 2B */ ACPI_OP ("Not",                ARGP_BIT_NOT_OP,           ARGI_BIT_NOT_OP,            ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
+/* 2C */ ACPI_OP ("FindSetLeftBit",     ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP,  ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
+/* 2D */ ACPI_OP ("FindSetRightBit",    ARGP_FIND_SET_RIGHT_BIT_OP,ARGI_FIND_SET_RIGHT_BIT_OP, ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
+/* 2E */ ACPI_OP ("DerefOf",            ARGP_DEREF_OF_OP,          ARGI_DEREF_OF_OP,           ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
+/* 2F */ ACPI_OP ("Notify",             ARGP_NOTIFY_OP,            ARGI_NOTIFY_OP,             ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_0R,   AML_FLAGS_EXEC_2A_0T_0R),
+/* 30 */ ACPI_OP ("SizeOf",             ARGP_SIZE_OF_OP,           ARGI_SIZE_OF_OP,            ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
+/* 31 */ ACPI_OP ("Index",              ARGP_INDEX_OP,             ARGI_INDEX_OP,              ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
+/* 32 */ ACPI_OP ("Match",              ARGP_MATCH_OP,             ARGI_MATCH_OP,              ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_6A_0T_1R,   AML_FLAGS_EXEC_6A_0T_1R | AML_CONSTANT),
+/* 33 */ ACPI_OP ("CreateDWordField",   ARGP_CREATE_DWORD_FIELD_OP,ARGI_CREATE_DWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD,      AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
+/* 34 */ ACPI_OP ("CreateWordField",    ARGP_CREATE_WORD_FIELD_OP, ARGI_CREATE_WORD_FIELD_OP,  ACPI_TYPE_BUFFER_FIELD,      AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
+/* 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),
+/* 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),
+/* 3D */ ACPI_OP ("LLess",              ARGP_LLESS_OP,             ARGI_LLESS_OP,              ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT),
+/* 3E */ ACPI_OP ("If",                 ARGP_IF_OP,                ARGI_IF_OP,                 ACPI_TYPE_ANY,               AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         AML_HAS_ARGS),
+/* 3F */ ACPI_OP ("Else",               ARGP_ELSE_OP,              ARGI_ELSE_OP,               ACPI_TYPE_ANY,               AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         AML_HAS_ARGS),
+/* 40 */ ACPI_OP ("While",              ARGP_WHILE_OP,             ARGI_WHILE_OP,              ACPI_TYPE_ANY,               AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         AML_HAS_ARGS),
+/* 41 */ ACPI_OP ("Noop",               ARGP_NOOP_OP,              ARGI_NOOP_OP,               ACPI_TYPE_ANY,               AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         0),
+/* 42 */ ACPI_OP ("Return",             ARGP_RETURN_OP,            ARGI_RETURN_OP,             ACPI_TYPE_ANY,               AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         AML_HAS_ARGS),
+/* 43 */ ACPI_OP ("Break",              ARGP_BREAK_OP,             ARGI_BREAK_OP,              ACPI_TYPE_ANY,               AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         0),
+/* 44 */ ACPI_OP ("BreakPoint",         ARGP_BREAK_POINT_OP,       ARGI_BREAK_POINT_OP,        ACPI_TYPE_ANY,               AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         0),
+/* 45 */ ACPI_OP ("Ones",               ARGP_ONES_OP,              ARGI_ONES_OP,               ACPI_TYPE_INTEGER,           AML_CLASS_ARGUMENT,        AML_TYPE_CONSTANT,        AML_CONSTANT),
 
 /* Prefixed opcodes (Two-byte opcodes with a prefix op) */
 
-/* 46 */ ACPI_OP ("Mutex",              ARGP_MUTEX_OP,             ARGI_MUTEX_OP,              AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 47 */ ACPI_OP ("Event",              ARGP_EVENT_OP,             ARGI_EVENT_OP,              AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ),
-/* 48 */ ACPI_OP ("Cond_ref_of",        ARGP_COND_REF_OF_OP,       ARGI_COND_REF_OF_OP,        AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 49 */ ACPI_OP ("Create_field",       ARGP_CREATE_FIELD_OP,      ARGI_CREATE_FIELD_OP,       AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_FIELD | AML_CREATE),
-/* 4_a */ ACPI_OP ("Load",              ARGP_LOAD_OP,              ARGI_LOAD_OP,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_0R,   AML_FLAGS_EXEC_1A_1T_0R),
-/* 4_b */ ACPI_OP ("Stall",             ARGP_STALL_OP,             ARGI_STALL_OP,              AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
-/* 4_c */ ACPI_OP ("Sleep",             ARGP_SLEEP_OP,             ARGI_SLEEP_OP,              AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
-/* 4_d */ ACPI_OP ("Acquire",           ARGP_ACQUIRE_OP,           ARGI_ACQUIRE_OP,            AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R),
-/* 4_e */ ACPI_OP ("Signal",            ARGP_SIGNAL_OP,            ARGI_SIGNAL_OP,             AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
-/* 4_f */ ACPI_OP ("Wait",              ARGP_WAIT_OP,              ARGI_WAIT_OP,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R),
-/* 50 */ ACPI_OP ("Reset",              ARGP_RESET_OP,             ARGI_RESET_OP,              AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
-/* 51 */ ACPI_OP ("Release",            ARGP_RELEASE_OP,           ARGI_RELEASE_OP,            AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
-/* 52 */ ACPI_OP ("From_bCD",           ARGP_FROM_BCD_OP,          ARGI_FROM_BCD_OP,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 53 */ ACPI_OP ("To_bCD",             ARGP_TO_BCD_OP,            ARGI_TO_BCD_OP,             AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 54 */ ACPI_OP ("Unload",             ARGP_UNLOAD_OP,            ARGI_UNLOAD_OP,             AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
-/* 55 */ ACPI_OP ("Revision",           ARGP_REVISION_OP,          ARGI_REVISION_OP,           AML_CLASS_ARGUMENT,        AML_TYPE_CONSTANT,        0),
-/* 56 */ ACPI_OP ("Debug",              ARGP_DEBUG_OP,             ARGI_DEBUG_OP,              AML_CLASS_ARGUMENT,        AML_TYPE_CONSTANT,        0),
-/* 57 */ ACPI_OP ("Fatal",              ARGP_FATAL_OP,             ARGI_FATAL_OP,              AML_CLASS_EXECUTE,         AML_TYPE_EXEC_3A_0T_0R,   AML_FLAGS_EXEC_3A_0T_0R),
-/* 58 */ ACPI_OP ("Op_region",          ARGP_REGION_OP,            ARGI_REGION_OP,             AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_COMPLEX,   AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER),
-/* 59 */ ACPI_OP ("Field",              ARGP_FIELD_OP,             ARGI_FIELD_OP,              AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_FIELD,     AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
-/* 5_a */ ACPI_OP ("Device",            ARGP_DEVICE_OP,            ARGI_DEVICE_OP,             AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_NO_OBJ,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 5_b */ ACPI_OP ("Processor",         ARGP_PROCESSOR_OP,         ARGI_PROCESSOR_OP,          AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 5_c */ ACPI_OP ("Power_resource",    ARGP_POWER_RES_OP,         ARGI_POWER_RES_OP,          AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 5_d */ ACPI_OP ("Thermal_zone",      ARGP_THERMAL_ZONE_OP,      ARGI_THERMAL_ZONE_OP,       AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_NO_OBJ,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 5_e */ ACPI_OP ("Index_field",       ARGP_INDEX_FIELD_OP,       ARGI_INDEX_FIELD_OP,        AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_FIELD,     AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
-/* 5_f */ ACPI_OP ("Bank_field",        ARGP_BANK_FIELD_OP,        ARGI_BANK_FIELD_OP,         AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_FIELD,     AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
+/* 46 */ ACPI_OP ("Mutex",              ARGP_MUTEX_OP,             ARGI_MUTEX_OP,              ACPI_TYPE_MUTEX,             AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 47 */ ACPI_OP ("Event",              ARGP_EVENT_OP,             ARGI_EVENT_OP,              ACPI_TYPE_EVENT,             AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ),
+/* 48 */ ACPI_OP ("CondRefOf",          ARGP_COND_REF_OF_OP,       ARGI_COND_REF_OF_OP,        ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
+/* 49 */ ACPI_OP ("CreateField",        ARGP_CREATE_FIELD_OP,      ARGI_CREATE_FIELD_OP,       ACPI_TYPE_BUFFER_FIELD,      AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_FIELD | AML_CREATE),
+/* 4A */ ACPI_OP ("Load",               ARGP_LOAD_OP,              ARGI_LOAD_OP,               ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_0R,   AML_FLAGS_EXEC_1A_1T_0R),
+/* 4B */ ACPI_OP ("Stall",              ARGP_STALL_OP,             ARGI_STALL_OP,              ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
+/* 4C */ ACPI_OP ("Sleep",              ARGP_SLEEP_OP,             ARGI_SLEEP_OP,              ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
+/* 4D */ ACPI_OP ("Acquire",            ARGP_ACQUIRE_OP,           ARGI_ACQUIRE_OP,            ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R),
+/* 4E */ ACPI_OP ("Signal",             ARGP_SIGNAL_OP,            ARGI_SIGNAL_OP,             ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
+/* 4F */ ACPI_OP ("Wait",               ARGP_WAIT_OP,              ARGI_WAIT_OP,               ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R),
+/* 50 */ ACPI_OP ("Reset",              ARGP_RESET_OP,             ARGI_RESET_OP,              ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
+/* 51 */ ACPI_OP ("Release",            ARGP_RELEASE_OP,           ARGI_RELEASE_OP,            ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
+/* 52 */ ACPI_OP ("FromBCD",            ARGP_FROM_BCD_OP,          ARGI_FROM_BCD_OP,           ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
+/* 53 */ ACPI_OP ("ToBCD",              ARGP_TO_BCD_OP,            ARGI_TO_BCD_OP,             ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
+/* 54 */ ACPI_OP ("Unload",             ARGP_UNLOAD_OP,            ARGI_UNLOAD_OP,             ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
+/* 55 */ ACPI_OP ("Revision",           ARGP_REVISION_OP,          ARGI_REVISION_OP,           ACPI_TYPE_INTEGER,           AML_CLASS_ARGUMENT,        AML_TYPE_CONSTANT,        0),
+/* 56 */ ACPI_OP ("Debug",              ARGP_DEBUG_OP,             ARGI_DEBUG_OP,              ACPI_TYPE_LOCAL_REFERENCE,   AML_CLASS_ARGUMENT,        AML_TYPE_CONSTANT,        0),
+/* 57 */ ACPI_OP ("Fatal",              ARGP_FATAL_OP,             ARGI_FATAL_OP,              ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_3A_0T_0R,   AML_FLAGS_EXEC_3A_0T_0R),
+/* 58 */ ACPI_OP ("OperationRegion",    ARGP_REGION_OP,            ARGI_REGION_OP,             ACPI_TYPE_REGION,            AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_COMPLEX,   AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER),
+/* 59 */ ACPI_OP ("Field",              ARGP_FIELD_OP,             ARGI_FIELD_OP,              ACPI_TYPE_ANY,               AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_FIELD,     AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
+/* 5A */ ACPI_OP ("Device",             ARGP_DEVICE_OP,            ARGI_DEVICE_OP,             ACPI_TYPE_DEVICE,            AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_NO_OBJ,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 5B */ ACPI_OP ("Processor",          ARGP_PROCESSOR_OP,         ARGI_PROCESSOR_OP,          ACPI_TYPE_PROCESSOR,         AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 5C */ ACPI_OP ("PowerResource",      ARGP_POWER_RES_OP,         ARGI_POWER_RES_OP,          ACPI_TYPE_POWER,             AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 5D */ ACPI_OP ("ThermalZone",        ARGP_THERMAL_ZONE_OP,      ARGI_THERMAL_ZONE_OP,       ACPI_TYPE_THERMAL,           AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_NO_OBJ,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 5E */ ACPI_OP ("IndexField",         ARGP_INDEX_FIELD_OP,       ARGI_INDEX_FIELD_OP,        ACPI_TYPE_ANY,               AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_FIELD,     AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
+/* 5F */ ACPI_OP ("BankField",          ARGP_BANK_FIELD_OP,        ARGI_BANK_FIELD_OP,         ACPI_TYPE_ANY,               AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_FIELD,     AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
 
 /* Internal opcodes that map to invalid AML opcodes */
 
-/* 60 */ ACPI_OP ("LNot_equal",         ARGP_LNOTEQUAL_OP,         ARGI_LNOTEQUAL_OP,          AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           AML_HAS_ARGS),
-/* 61 */ ACPI_OP ("LLess_equal",        ARGP_LLESSEQUAL_OP,        ARGI_LLESSEQUAL_OP,         AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           AML_HAS_ARGS),
-/* 62 */ ACPI_OP ("LGreater_equal",     ARGP_LGREATEREQUAL_OP,     ARGI_LGREATEREQUAL_OP,      AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           AML_HAS_ARGS),
-/* 63 */ ACPI_OP ("[Name_path]",        ARGP_NAMEPATH_OP,          ARGI_NAMEPATH_OP,           AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         AML_NSOBJECT | AML_NSNODE ),
-/* 64 */ ACPI_OP ("[Method_call]",      ARGP_METHODCALL_OP,        ARGI_METHODCALL_OP,         AML_CLASS_METHOD_CALL,     AML_TYPE_METHOD_CALL,     AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE),
-/* 65 */ ACPI_OP ("[Byte_list]",        ARGP_BYTELIST_OP,          ARGI_BYTELIST_OP,           AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         0),
-/* 66 */ ACPI_OP ("[Reserved_field]",   ARGP_RESERVEDFIELD_OP,     ARGI_RESERVEDFIELD_OP,      AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           0),
-/* 67 */ ACPI_OP ("[Named_field]",      ARGP_NAMEDFIELD_OP,        ARGI_NAMEDFIELD_OP,         AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ),
-/* 68 */ ACPI_OP ("[Access_field]",     ARGP_ACCESSFIELD_OP,       ARGI_ACCESSFIELD_OP,        AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           0),
-/* 69 */ ACPI_OP ("[Static_string",     ARGP_STATICSTRING_OP,      ARGI_STATICSTRING_OP,       AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           0),
-/* 6_a */ ACPI_OP ("[Return Value]",    ARG_NONE,                  ARG_NONE,                   AML_CLASS_RETURN_VALUE,    AML_TYPE_RETURN,          AML_HAS_ARGS | AML_HAS_RETVAL),
-/* 6_b */ ACPI_OP ("UNKNOWN_OP!",       ARG_NONE,                  ARG_NONE,                   AML_CLASS_UNKNOWN,         AML_TYPE_BOGUS,           AML_HAS_ARGS),
-/* 6_c */ ACPI_OP ("ASCII_ONLY!",       ARG_NONE,                  ARG_NONE,                   AML_CLASS_ASCII,           AML_TYPE_BOGUS,           AML_HAS_ARGS),
-/* 6_d */ ACPI_OP ("PREFIX_ONLY!",      ARG_NONE,                  ARG_NONE,                   AML_CLASS_PREFIX,          AML_TYPE_BOGUS,           AML_HAS_ARGS),
+/* 60 */ ACPI_OP ("LNotEqual",          ARGP_LNOTEQUAL_OP,         ARGI_LNOTEQUAL_OP,          ACPI_TYPE_ANY,               AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           AML_HAS_ARGS | AML_CONSTANT),
+/* 61 */ ACPI_OP ("LLessEqual",         ARGP_LLESSEQUAL_OP,        ARGI_LLESSEQUAL_OP,         ACPI_TYPE_ANY,               AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           AML_HAS_ARGS | AML_CONSTANT),
+/* 62 */ ACPI_OP ("LGreaterEqual",      ARGP_LGREATEREQUAL_OP,     ARGI_LGREATEREQUAL_OP,      ACPI_TYPE_ANY,               AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           AML_HAS_ARGS | AML_CONSTANT),
+/* 63 */ ACPI_OP ("-NamePath-",         ARGP_NAMEPATH_OP,          ARGI_NAMEPATH_OP,           ACPI_TYPE_LOCAL_REFERENCE,   AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         AML_NSOBJECT | AML_NSNODE ),
+/* 64 */ ACPI_OP ("-MethodCall-",       ARGP_METHODCALL_OP,        ARGI_METHODCALL_OP,         ACPI_TYPE_METHOD,            AML_CLASS_METHOD_CALL,     AML_TYPE_METHOD_CALL,     AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE),
+/* 65 */ ACPI_OP ("-ByteList-",         ARGP_BYTELIST_OP,          ARGI_BYTELIST_OP,           ACPI_TYPE_ANY,               AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         0),
+/* 66 */ ACPI_OP ("-ReservedField-",    ARGP_RESERVEDFIELD_OP,     ARGI_RESERVEDFIELD_OP,      ACPI_TYPE_ANY,               AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           0),
+/* 67 */ ACPI_OP ("-NamedField-",       ARGP_NAMEDFIELD_OP,        ARGI_NAMEDFIELD_OP,         ACPI_TYPE_ANY,               AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ),
+/* 68 */ ACPI_OP ("-AccessField-",      ARGP_ACCESSFIELD_OP,       ARGI_ACCESSFIELD_OP,        ACPI_TYPE_ANY,               AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           0),
+/* 69 */ ACPI_OP ("-StaticString",      ARGP_STATICSTRING_OP,      ARGI_STATICSTRING_OP,       ACPI_TYPE_ANY,               AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           0),
+/* 6A */ ACPI_OP ("-Return Value-",     ARG_NONE,                  ARG_NONE,                   ACPI_TYPE_ANY,               AML_CLASS_RETURN_VALUE,    AML_TYPE_RETURN,          AML_HAS_ARGS | AML_HAS_RETVAL),
+/* 6B */ ACPI_OP ("-UNKNOWN_OP-",       ARG_NONE,                  ARG_NONE,                   ACPI_TYPE_INVALID,           AML_CLASS_UNKNOWN,         AML_TYPE_BOGUS,           AML_HAS_ARGS),
+/* 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 */
 
-/* 6_e */ ACPI_OP ("Qword_const",       ARGP_QWORD_OP,             ARGI_QWORD_OP,              AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         0),
-/* 6_f */ ACPI_OP ("Var_package",       ARGP_VAR_PACKAGE_OP,       ARGI_VAR_PACKAGE_OP,        AML_CLASS_ARGUMENT,        AML_TYPE_DATA_TERM,       AML_HAS_ARGS | AML_DEFER),
-/* 70 */ ACPI_OP ("Concat_res",         ARGP_CONCAT_RES_OP,        ARGI_CONCAT_RES_OP,         AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R),
-/* 71 */ ACPI_OP ("Mod",                ARGP_MOD_OP,               ARGI_MOD_OP,                AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R),
-/* 72 */ ACPI_OP ("Create_qWord_field", ARGP_CREATE_QWORD_FIELD_OP,ARGI_CREATE_QWORD_FIELD_OP, AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
-/* 73 */ ACPI_OP ("To_buffer",          ARGP_TO_BUFFER_OP,         ARGI_TO_BUFFER_OP,          AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 74 */ ACPI_OP ("To_decimal_string",  ARGP_TO_DEC_STR_OP,        ARGI_TO_DEC_STR_OP,         AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 75 */ ACPI_OP ("To_hex_string",      ARGP_TO_HEX_STR_OP,        ARGI_TO_HEX_STR_OP,         AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 76 */ ACPI_OP ("To_integer",         ARGP_TO_INTEGER_OP,        ARGI_TO_INTEGER_OP,         AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 77 */ ACPI_OP ("To_string",          ARGP_TO_STRING_OP,         ARGI_TO_STRING_OP,          AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R),
-/* 78 */ ACPI_OP ("Copy_object",        ARGP_COPY_OP,              ARGI_COPY_OP,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 79 */ ACPI_OP ("Mid",                ARGP_MID_OP,               ARGI_MID_OP,                AML_CLASS_EXECUTE,         AML_TYPE_EXEC_3A_1T_1R,   AML_FLAGS_EXEC_3A_1T_1R),
-/* 7_a */ ACPI_OP ("Continue",          ARGP_CONTINUE_OP,          ARGI_CONTINUE_OP,           AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         0),
-/* 7_b */ ACPI_OP ("Load_table",        ARGP_LOAD_TABLE_OP,        ARGI_LOAD_TABLE_OP,         AML_CLASS_EXECUTE,         AML_TYPE_EXEC_6A_0T_1R,   AML_FLAGS_EXEC_6A_0T_1R),
-/* 7_c */ ACPI_OP ("Data_op_region",    ARGP_DATA_REGION_OP,       ARGI_DATA_REGION_OP,        AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
+/* 6E */ ACPI_OP ("QwordConst",         ARGP_QWORD_OP,             ARGI_QWORD_OP,              ACPI_TYPE_INTEGER,           AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         AML_CONSTANT),
+/* 6F */ ACPI_OP ("Package /*Var*/",    ARGP_VAR_PACKAGE_OP,       ARGI_VAR_PACKAGE_OP,        ACPI_TYPE_PACKAGE,           AML_CLASS_CREATE,          AML_TYPE_CREATE_OBJECT,   AML_HAS_ARGS | AML_DEFER),
+/* 70 */ ACPI_OP ("ConcatenateResTemplate", ARGP_CONCAT_RES_OP,    ARGI_CONCAT_RES_OP,         ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
+/* 71 */ ACPI_OP ("Mod",                ARGP_MOD_OP,               ARGI_MOD_OP,                ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
+/* 72 */ ACPI_OP ("CreateQWordField",   ARGP_CREATE_QWORD_FIELD_OP,ARGI_CREATE_QWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD,      AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
+/* 73 */ ACPI_OP ("ToBuffer",           ARGP_TO_BUFFER_OP,         ARGI_TO_BUFFER_OP,          ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
+/* 74 */ ACPI_OP ("ToDecimalString",    ARGP_TO_DEC_STR_OP,        ARGI_TO_DEC_STR_OP,         ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
+/* 75 */ ACPI_OP ("ToHexString",        ARGP_TO_HEX_STR_OP,        ARGI_TO_HEX_STR_OP,         ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
+/* 76 */ ACPI_OP ("ToInteger",          ARGP_TO_INTEGER_OP,        ARGI_TO_INTEGER_OP,         ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
+/* 77 */ ACPI_OP ("ToString",           ARGP_TO_STRING_OP,         ARGI_TO_STRING_OP,          ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
+/* 78 */ ACPI_OP ("CopyObject",         ARGP_COPY_OP,              ARGI_COPY_OP,               ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
+/* 79 */ ACPI_OP ("Mid",                ARGP_MID_OP,               ARGI_MID_OP,                ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_3A_1T_1R,   AML_FLAGS_EXEC_3A_1T_1R | AML_CONSTANT),
+/* 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)
 
+/*! [End] no source code translation !*/
 };
 
 /*
@@ -594,7 +616,7 @@
  * index into the table above
  */
 
-static const u8 aml_short_op_info_index[256] =
+static const u8 acpi_gbl_short_op_index[256] =
 {
 /*              0     1     2     3     4     5     6     7  */
 /*              8     9     A     B     C     D     E     F  */
@@ -604,7 +626,7 @@
 /* 0x18 */	_UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
 /* 0x20 */	_UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
 /* 0x28 */	_UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX,
-/* 0x30 */	0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, _UNK,
+/* 0x30 */	0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D,
 /* 0x38 */	_UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
 /* 0x40 */	_UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
 /* 0x48 */	_ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
@@ -633,7 +655,7 @@
 };
 
 
-static const u8 aml_long_op_info_index[NUM_EXTENDED_OPCODE] =
+static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] =
 {
 /*              0     1     2     3     4     5     6     7  */
 /*              8     9     A     B     C     D     E     F  */
@@ -660,7 +682,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_get_opcode_info
+ * FUNCTION:    acpi_ps_get_opcode_info
  *
  * PARAMETERS:  Opcode              - The AML opcode
  *
@@ -672,67 +694,50 @@
  *
  ******************************************************************************/
 
-const acpi_opcode_info *
+const struct acpi_opcode_info *
 acpi_ps_get_opcode_info (
-	u16                     opcode)
+	u16                             opcode)
 {
-	const acpi_opcode_info  *op_info;
-	u8                      upper_opcode;
-	u8                      lower_opcode;
-
-
-	PROC_NAME ("Ps_get_opcode_info");
-
-
-	/* Split the 16-bit opcode into separate bytes */
-
-	upper_opcode = (u8) (opcode >> 8);
-	lower_opcode = (u8) opcode;
-
-	/* Default is "unknown opcode" */
-
-	op_info = &aml_op_info [_UNK];
+	ACPI_FUNCTION_NAME ("ps_get_opcode_info");
 
 
 	/*
 	 * Detect normal 8-bit opcode or extended 16-bit opcode
 	 */
-
-	switch (upper_opcode) {
+	switch ((u8) (opcode >> 8)) {
 	case 0:
 
 		/* Simple (8-bit) opcode: 0-255, can't index beyond table  */
 
-		op_info = &aml_op_info [aml_short_op_info_index [lower_opcode]];
-		break;
-
+		return (&acpi_gbl_aml_op_info [acpi_gbl_short_op_index [(u8) opcode]]);
 
 	case AML_EXTOP:
 
 		/* Extended (16-bit, prefix+opcode) opcode */
 
-		if (lower_opcode <= MAX_EXTENDED_OPCODE) {
-			op_info = &aml_op_info [aml_long_op_info_index [lower_opcode]];
+		if (((u8) opcode) <= MAX_EXTENDED_OPCODE) {
+			return (&acpi_gbl_aml_op_info [acpi_gbl_long_op_index [(u8) opcode]]);
 		}
-		break;
 
+		/* Else fall through to error case below */
+		/*lint -fallthrough */
 
 	default:
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown extended opcode=%X\n", opcode));
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown extended opcode [%X]\n", opcode));
 		break;
 	}
 
 
-	/* Get the Op info pointer for this opcode */
+	/* Default is "unknown opcode" */
 
-	return (op_info);
+	return (&acpi_gbl_aml_op_info [_UNK]);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_get_opcode_name
+ * FUNCTION:    acpi_ps_get_opcode_name
  *
  * PARAMETERS:  Opcode              - The AML opcode
  *
@@ -743,22 +748,24 @@
  *
  ******************************************************************************/
 
-NATIVE_CHAR *
+char *
 acpi_ps_get_opcode_name (
-	u16                     opcode)
+	u16                             opcode)
 {
-	const acpi_opcode_info  *op;
+#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
+
+	const struct acpi_opcode_info   *op;
 
 
 	op = acpi_ps_get_opcode_info (opcode);
 
 	/* Always guaranteed to return a valid pointer */
 
-#ifdef ACPI_DEBUG
 	return (op->name);
+
 #else
 	return ("AE_NOT_CONFIGURED");
+
 #endif
 }
 
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/parser/psparse.c linux-2.4.22-pre2/drivers/acpi/parser/psparse.c
--- linux-2.4.21/drivers/acpi/parser/psparse.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/parser/psparse.c	2003-06-26 21:43:12.000000000 +0000
@@ -1,26 +1,44 @@
 /******************************************************************************
  *
  * Module Name: psparse - Parser top level AML parse routines
- *              $Revision: 104 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
@@ -30,28 +48,26 @@
  * generated parser to tightly constrain stack and dynamic memory
  * usage.  At the same time, parsing is kept flexible and the code
  * fairly compact by parsing based on a list of AML opcode
- * templates in Aml_op_info[]
+ * templates in aml_op_info[]
  */
 
-#include "acpi.h"
-#include "acparser.h"
-#include "acdispat.h"
-#include "amlcode.h"
-#include "acnamesp.h"
-#include "acdebug.h"
-#include "acinterp.h"
+#include <acpi/acpi.h>
+#include <acpi/acparser.h>
+#include <acpi/acdispat.h>
+#include <acpi/amlcode.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acinterp.h>
 
 #define _COMPONENT          ACPI_PARSER
-	 MODULE_NAME         ("psparse")
+	 ACPI_MODULE_NAME    ("psparse")
 
 
-u32                         acpi_gbl_depth = 0;
-extern u32                  acpi_gbl_scope_depth;
+static u32                          acpi_gbl_depth = 0;
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_get_opcode_size
+ * FUNCTION:    acpi_ps_get_opcode_size
  *
  * PARAMETERS:  Opcode          - An AML opcode
  *
@@ -61,9 +77,9 @@
  *
  ******************************************************************************/
 
-static u32
+u32
 acpi_ps_get_opcode_size (
-	u32                     opcode)
+	u32                             opcode)
 {
 
 	/* Extended (2-byte) opcode if > 255 */
@@ -80,9 +96,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_peek_opcode
+ * FUNCTION:    acpi_ps_peek_opcode
  *
- * PARAMETERS:  Parser_state        - A parser state object
+ * PARAMETERS:  parser_state        - A parser state object
  *
  * RETURN:      Status
  *
@@ -92,122 +108,59 @@
 
 u16
 acpi_ps_peek_opcode (
-	acpi_parse_state        *parser_state)
+	struct acpi_parse_state         *parser_state)
 {
-	u8                      *aml;
-	u16                     opcode;
+	u8                              *aml;
+	u16                             opcode;
 
 
 	aml = parser_state->aml;
-	opcode = (u16) GET8 (aml);
+	opcode = (u16) ACPI_GET8 (aml);
 
-	aml++;
 
-
-	/*
-	 * Original code special cased LNOTEQUAL, LLESSEQUAL, LGREATEREQUAL.
-	 * These opcodes are no longer recognized. Instead, they are broken into
-	 * two opcodes.
-	 *
-	 *
-	 *    if (Opcode == AML_EXTOP
-	 *       || (Opcode == AML_LNOT
-	 *          && (GET8 (Aml) == AML_LEQUAL
-	 *               || GET8 (Aml) == AML_LGREATER
-	 *               || GET8 (Aml) == AML_LLESS)))
-	 *
-	 *     extended Opcode, !=, <=, or >=
-	 */
 	if (opcode == AML_EXTOP) {
 		/* Extended opcode */
 
-		opcode = (u16) ((opcode << 8) | GET8 (aml));
+		aml++;
+		opcode = (u16) ((opcode << 8) | ACPI_GET8 (aml));
 	}
 
-
 	return (opcode);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_find_object
- *
- * PARAMETERS:  Opcode          - Current opcode
- *              Parser_state    - Current state
- *              Walk_state      - Current state
- *              *Op             - Where found/new op is returned
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Find a named object.  Two versions - one to search the parse
- *              tree (for parser-only applications such as acpidump), another
- *              to search the ACPI internal namespace (the parse tree may no
- *              longer exist)
- *
- ******************************************************************************/
-
-#ifdef PARSER_ONLY
-
-acpi_status
-acpi_ps_find_object (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       **out_op)
-{
-	NATIVE_CHAR             *path;
-
-
-	/* We are only interested in opcodes that have an associated name */
-
-	if (!(walk_state->op_info->flags & AML_NAMED)) {
-		*out_op = walk_state->op;
-		return (AE_OK);
-	}
-
-	/* Find the name in the parse tree */
-
-	path = acpi_ps_get_next_namestring (&walk_state->parser_state);
-
-	*out_op = acpi_ps_find (acpi_ps_get_parent_scope (&walk_state->parser_state),
-			  path, walk_state->opcode, 1);
-
-	if (!(*out_op)) {
-		return (AE_NOT_FOUND);
-	}
-
-	return (AE_OK);
-}
-
-#endif
-
-
-/*******************************************************************************
+ * FUNCTION:    acpi_ps_complete_this_op
  *
- * FUNCTION:    Acpi_ps_complete_this_op
- *
- * PARAMETERS:  Walk_state      - Current State
+ * PARAMETERS:  walk_state      - Current State
  *              Op              - Op to complete
  *
- * RETURN:      TRUE if Op and subtree was deleted
+ * RETURN:      None.
  *
  * DESCRIPTION: Perform any cleanup at the completion of an Op.
  *
  ******************************************************************************/
 
-static u8
+void
 acpi_ps_complete_this_op (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op)
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op)
 {
-#ifndef PARSER_ONLY
-	acpi_parse_object       *prev;
-	acpi_parse_object       *next;
-	const acpi_opcode_info  *parent_info;
-	acpi_parse_object       *replacement_op = NULL;
+	union acpi_parse_object         *prev;
+	union acpi_parse_object         *next;
+	const struct acpi_opcode_info   *parent_info;
+	union acpi_parse_object         *replacement_op = NULL;
+
 
+	ACPI_FUNCTION_TRACE_PTR ("ps_complete_this_op", op);
 
-	FUNCTION_TRACE_PTR ("Ps_complete_this_op", op);
 
+	/* Check for null Op, can happen if AML code is corrupt */
+
+	if (!op) {
+		return_VOID;
+	}
 
 	/* Delete this op and the subtree below it if asked to */
 
@@ -215,60 +168,84 @@
 		(walk_state->op_info->class != AML_CLASS_ARGUMENT)) {
 		/* Make sure that we only delete this subtree */
 
-		if (op->parent) {
+		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->parent->opcode);
+			parent_info = acpi_ps_get_opcode_info (op->common.parent->common.aml_opcode);
 
 			switch (parent_info->class) {
-			case AML_CLASS_CONTROL:        /* IF, ELSE, WHILE only */
+			case AML_CLASS_CONTROL:
 				break;
 
-			case AML_CLASS_NAMED_OBJECT:   /* Scope, method, etc. */
 			case AML_CLASS_CREATE:
 
 				/*
-				 * These opcodes contain Term_arg operands. The current
-				 * op must be replace by a placeholder return op
+				 * These opcodes contain term_arg operands. The current
+				 * op must be replaced by a placeholder return op
 				 */
-				if ((op->parent->opcode == AML_REGION_OP)               ||
-					(op->parent->opcode == AML_CREATE_FIELD_OP)         ||
-					(op->parent->opcode == AML_CREATE_BIT_FIELD_OP)     ||
-					(op->parent->opcode == AML_CREATE_BYTE_FIELD_OP)    ||
-					(op->parent->opcode == AML_CREATE_WORD_FIELD_OP)    ||
-					(op->parent->opcode == AML_CREATE_DWORD_FIELD_OP)   ||
-					(op->parent->opcode == AML_CREATE_QWORD_FIELD_OP)) {
+				replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP);
+				if (!replacement_op) {
+					return_VOID;
+				}
+				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 (!replacement_op) {
-						return_VALUE (FALSE);
+						return_VOID;
 					}
 				}
 
+				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;
+						}
+
+						replacement_op->named.data = op->named.data;
+						replacement_op->named.length = op->named.length;
+					}
+				}
 				break;
 
 			default:
 				replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP);
 				if (!replacement_op) {
-					return_VALUE (FALSE);
+					return_VOID;
 				}
 			}
 
 			/* We must unlink this op from the parent tree */
 
-			prev = op->parent->value.arg;
+			prev = op->common.parent->common.value.arg;
 			if (prev == op) {
 				/* This op is the first in the list */
 
 				if (replacement_op) {
-					replacement_op->parent   = op->parent;
-					replacement_op->value.arg = NULL;
-					op->parent->value.arg    = replacement_op;
-					replacement_op->next     = op->next;
+					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->parent->value.arg    = op->next;
+					op->common.parent->common.value.arg    = op->common.next;
 				}
 			}
 
@@ -277,66 +254,61 @@
 			else while (prev) {
 				/* Traverse all siblings in the parent's argument list */
 
-				next = prev->next;
+				next = prev->common.next;
 				if (next == op) {
 					if (replacement_op) {
-						replacement_op->parent = op->parent;
-						replacement_op->value.arg = NULL;
-						prev->next = replacement_op;
-						replacement_op->next = op->next;
+						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->next = op->next;
+						prev->common.next = op->common.next;
 						next = NULL;
 					}
 				}
 
 				prev = next;
 			}
-
 		}
 
 		/* Now we can actually delete the subtree rooted at op */
 
 		acpi_ps_delete_parse_tree (op);
 
-		return_VALUE (TRUE);
+		return_VOID;
 	}
 
-	return_VALUE (FALSE);
-
-#else
-	return (FALSE);
-#endif
+	return_VOID;
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_next_parse_state
+ * FUNCTION:    acpi_ps_next_parse_state
  *
- * PARAMETERS:  Parser_state        - Current parser state object
+ * PARAMETERS:  parser_state        - Current parser state object
  *
- * RETURN:
+ * RETURN:      Status
  *
- * DESCRIPTION:
+ * DESCRIPTION: Update the parser state based upon the return exception from
+ *              the parser callback.
  *
  ******************************************************************************/
 
-static acpi_status
+acpi_status
 acpi_ps_next_parse_state (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op,
-	acpi_status             callback_status)
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op,
+	acpi_status                     callback_status)
 {
-	acpi_parse_state        *parser_state = &walk_state->parser_state;
-	acpi_status             status = AE_CTRL_PENDING;
-	u8                      *start;
-	u32                     package_length;
+	struct acpi_parse_state         *parser_state = &walk_state->parser_state;
+	acpi_status                     status = AE_CTRL_PENDING;
 
 
-	FUNCTION_TRACE_PTR ("Ps_next_parse_state", op);
+	ACPI_FUNCTION_TRACE_PTR ("ps_next_parse_state", op);
 
 
 	switch (callback_status) {
@@ -351,32 +323,40 @@
 		break;
 
 
-	case AE_CTRL_PENDING:
+	case AE_CTRL_BREAK:
+
+		parser_state->aml = walk_state->aml_last_while;
+		walk_state->control_state->common.value = FALSE;
+		status = AE_CTRL_BREAK;
+		break;
+
+	case AE_CTRL_CONTINUE:
 
-		/*
-		 * Predicate of a WHILE was true and the loop just completed an
-		 * execution.  Go back to the start of the loop and reevaluate the
-		 * predicate.
-		 */
 
-		/* TBD: How to handle a break within a while. */
-		/* This code attempts it */
+		parser_state->aml = walk_state->aml_last_while;
+		status = AE_CTRL_CONTINUE;
+		break;
+
+	case AE_CTRL_PENDING:
 
 		parser_state->aml = walk_state->aml_last_while;
 		break;
 
+#if 0
+	case AE_CTRL_SKIP:
+
+		parser_state->aml = parser_state->scope->parse_scope.pkg_end;
+		status = AE_OK;
+		break;
+#endif
 
 	case AE_CTRL_TRUE:
+
 		/*
 		 * Predicate of an IF was true, and we are at the matching ELSE.
 		 * Just close out this package
-		 *
-		 * Note: Parser_state->Aml is modified by the package length procedure
-		 * TBD: [Investigate] perhaps it shouldn't, too much trouble
 		 */
-		start = parser_state->aml;
-		package_length = acpi_ps_get_next_package_length (parser_state);
-		parser_state->aml = start + package_length;
+		parser_state->aml = acpi_ps_get_next_package_end (parser_state);
 		break;
 
 
@@ -406,7 +386,7 @@
 		status = AE_CTRL_TRANSFER;
 		walk_state->prev_op = op;
 		walk_state->method_call_op = op;
-		walk_state->method_call_node = (op->value.arg)->node;
+		walk_state->method_call_node = (op->common.value.arg)->common.node;
 
 		/* Will return value (if any) be used by the caller? */
 
@@ -428,9 +408,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_parse_loop
+ * FUNCTION:    acpi_ps_parse_loop
  *
- * PARAMETERS:  Parser_state        - Current parser state object
+ * PARAMETERS:  parser_state        - Current parser state object
  *
  * RETURN:      Status
  *
@@ -441,24 +421,28 @@
 
 acpi_status
 acpi_ps_parse_loop (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status = AE_OK;
-	acpi_parse_object       *op = NULL;     /* current op */
-	acpi_parse_object       *arg = NULL;
-	acpi_parse_object       pre_op;
-	acpi_parse_state        *parser_state;
-	u8                      *aml_op_start;
+	acpi_status                     status = AE_OK;
+	union acpi_parse_object         *op = NULL;     /* current op */
+	union acpi_parse_object         *arg = NULL;
+	union acpi_parse_object         pre_op;
+	struct acpi_parse_state         *parser_state;
+	u8                              *aml_op_start = NULL;
+
 
+	ACPI_FUNCTION_TRACE_PTR ("ps_parse_loop", walk_state);
 
-	FUNCTION_TRACE_PTR ("Ps_parse_loop", walk_state);
+	if (walk_state->descending_callback == NULL) {
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	}
 
 
 	parser_state = &walk_state->parser_state;
 	walk_state->arg_types = 0;
 
-#ifndef PARSER_ONLY
-	if (walk_state->walk_type & WALK_METHOD_RESTART) {
+#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
+	if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) {
 		/* We are restarting a preempted control method */
 
 		if (acpi_ps_has_completed_scope (parser_state)) {
@@ -467,18 +451,17 @@
 			 * was just completed
 			 */
 			if ((parser_state->scope->parse_scope.op) &&
-			   ((parser_state->scope->parse_scope.op->opcode == AML_IF_OP) ||
-				(parser_state->scope->parse_scope.op->opcode == AML_WHILE_OP)) &&
+			   ((parser_state->scope->parse_scope.op->common.aml_opcode == AML_IF_OP) ||
+				(parser_state->scope->parse_scope.op->common.aml_opcode == AML_WHILE_OP)) &&
 				(walk_state->control_state) &&
 				(walk_state->control_state->common.state ==
-					CONTROL_PREDICATE_EXECUTING)) {
-
+					ACPI_CONTROL_PREDICATE_EXECUTING)) {
 				/*
 				 * A predicate was just completed, get the value of the
 				 * predicate and branch based on that value
 				 */
 				walk_state->op = NULL;
-				status = acpi_ds_get_predicate_value (walk_state, TRUE);
+				status = acpi_ds_get_predicate_value (walk_state, ACPI_TO_POINTER (TRUE));
 				if (ACPI_FAILURE (status) &&
 					((status & AE_CODE_MASK) != AE_CODE_CONTROL)) {
 					if (status == AE_AML_NO_RETURN_VALUE) {
@@ -487,7 +470,7 @@
 							acpi_format_exception (status)));
 
 					}
-					ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Get_predicate Failed, %s\n",
+					ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "get_predicate Failed, %s\n",
 						acpi_format_exception (status)));
 					return_ACPI_STATUS (status);
 				}
@@ -495,10 +478,10 @@
 				status = acpi_ps_next_parse_state (walk_state, op, status);
 			}
 
-			acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, &walk_state->arg_count);
+			acpi_ps_pop_scope (parser_state, &op,
+				&walk_state->arg_types, &walk_state->arg_count);
 			ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op));
 		}
-
 		else if (walk_state->prev_op) {
 			/* We were in the middle of an op */
 
@@ -512,12 +495,13 @@
 	 * Iterative parsing loop, while there is more aml to process:
 	 */
 	while ((parser_state->aml < parser_state->aml_end) || (op)) {
+		aml_op_start = parser_state->aml;
 		if (!op) {
 			/* Get the next opcode from the AML stream */
 
-			aml_op_start = parser_state->aml;
-			walk_state->aml_offset = parser_state->aml - parser_state->aml_start;
-			walk_state->opcode    = acpi_ps_peek_opcode (parser_state);
+			walk_state->aml_offset = ACPI_PTR_DIFF (parser_state->aml,
+					   parser_state->aml_start);
+			walk_state->opcode   = acpi_ps_peek_opcode (parser_state);
 
 			/*
 			 * First cut to determine what we have found:
@@ -542,10 +526,10 @@
 				/* The opcode is unrecognized.  Just skip unknown opcodes */
 
 				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-					"Found unknown opcode %X at AML offset %X, ignoring\n",
-					walk_state->opcode, walk_state->aml_offset));
+					"Found unknown opcode %X at AML address %p offset %X, ignoring\n",
+					walk_state->opcode, parser_state->aml, walk_state->aml_offset));
 
-				DUMP_BUFFER (parser_state->aml, 128);
+				ACPI_DUMP_BUFFER (parser_state->aml, 128);
 
 				/* Assume one-byte bad opcode */
 
@@ -559,70 +543,76 @@
 				parser_state->aml += acpi_ps_get_opcode_size (walk_state->opcode);
 				walk_state->arg_types = walk_state->op_info->parse_args;
 				break;
-
 			}
 
-
 			/* Create Op structure and append to parent's argument list */
 
 			if (walk_state->op_info->flags & AML_NAMED) {
-				pre_op.value.arg = NULL;
-				pre_op.opcode = walk_state->opcode;
+				pre_op.common.value.arg = NULL;
+				pre_op.common.aml_opcode = walk_state->opcode;
+
+				/*
+				 * Get and append arguments until we find the node that contains
+				 * the name (the type ARGP_NAME).
+				 */
+				while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) &&
+					  (GET_CURRENT_ARG_TYPE (walk_state->arg_types) != ARGP_NAME)) {
+					status = acpi_ps_get_next_arg (walk_state, parser_state,
+							 GET_CURRENT_ARG_TYPE (walk_state->arg_types), &arg);
+					if (ACPI_FAILURE (status)) {
+						goto close_this_op;
+					}
 
-				while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) != ARGP_NAME) {
-					arg = acpi_ps_get_next_arg (parser_state,
-							 GET_CURRENT_ARG_TYPE (walk_state->arg_types),
-							 &walk_state->arg_count);
 					acpi_ps_append_arg (&pre_op, arg);
 					INCREMENT_ARG_LIST (walk_state->arg_types);
 				}
 
+				/* 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);
+				}
 
 				/* We know that this arg is a name, move to next arg */
 
 				INCREMENT_ARG_LIST (walk_state->arg_types);
 
-				if (walk_state->descending_callback != NULL) {
-					/*
-					 * Find the object.  This will either insert the object into
-					 * the namespace or simply look it up
-					 */
-					walk_state->op = NULL;
-
-					status = walk_state->descending_callback (walk_state, &op);
+				/*
+				 * Find the object.  This will either insert the object into
+				 * the namespace or simply look it up
+				 */
+				walk_state->op = NULL;
 
-					/* TBD: check status here? */
+				status = walk_state->descending_callback (walk_state, &op);
+				if (ACPI_FAILURE (status)) {
+					ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "During name lookup/catalog, %s\n",
+							acpi_format_exception (status)));
+					goto close_this_op;
+				}
 
-					if (ACPI_FAILURE (status)) {
-						ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "During name lookup/catalog, %s\n",
-								acpi_format_exception (status)));
-						goto close_this_op;
-					}
+				if (op == NULL) {
+					continue;
+				}
 
-					if (op == NULL) {
-						continue;
-					}
-					status = acpi_ps_next_parse_state (walk_state, op, status);
-					if (status == AE_CTRL_PENDING) {
-						status = AE_OK;
-						goto close_this_op;
-					}
+				status = acpi_ps_next_parse_state (walk_state, op, status);
+				if (status == AE_CTRL_PENDING) {
+					status = AE_OK;
+					goto close_this_op;
+				}
 
-					if (ACPI_FAILURE (status)) {
-						goto close_this_op;
-					}
+				if (ACPI_FAILURE (status)) {
+					goto close_this_op;
 				}
 
-				acpi_ps_append_arg (op, pre_op.value.arg);
+				acpi_ps_append_arg (op, pre_op.common.value.arg);
 				acpi_gbl_depth++;
 
-
-				if (op->opcode == AML_REGION_OP) {
+				if (op->common.aml_opcode == AML_REGION_OP) {
 					/*
-					 * Defer final parsing of an Operation_region body,
+					 * Defer final parsing of an operation_region body,
 					 * because we don't have enough info in the first pass
 					 * to parse it correctly (i.e., there may be method
-					 * calls within the Term_arg elements of the body.
+					 * calls within the term_arg elements of the body.)
 					 *
 					 * However, we must continue parsing because
 					 * the opregion is not a standalone package --
@@ -630,12 +620,10 @@
 					 *
 					 * (Length is unknown until parse of the body complete)
 					 */
-					((acpi_parse2_object * ) op)->data    = aml_op_start;
-					((acpi_parse2_object * ) op)->length  = 0;
+					op->named.data    = aml_op_start;
+					op->named.length  = 0;
 				}
 			}
-
-
 			else {
 				/* Not a named opcode, just allocate Op and append to parent */
 
@@ -645,14 +633,13 @@
 					return_ACPI_STATUS (AE_NO_MEMORY);
 				}
 
-
 				if (walk_state->op_info->flags & AML_CREATE) {
 					/*
-					 * Backup to beginning of Create_xXXfield declaration
-					 * Body_length is unknown until we parse the body
+					 * Backup to beginning of create_xXXfield declaration
+					 * body_length is unknown until we parse the body
 					 */
-					((acpi_parse2_object * ) op)->data    = aml_op_start;
-					((acpi_parse2_object * ) op)->length  = 0;
+					op->named.data    = aml_op_start;
+					op->named.length  = 0;
 				}
 
 				acpi_ps_append_arg (acpi_ps_get_parent_scope (parser_state), op);
@@ -662,7 +649,7 @@
 					 * Find the object.  This will either insert the object into
 					 * the namespace or simply look it up
 					 */
-					walk_state->op    = op;
+					walk_state->op = op;
 
 					status = walk_state->descending_callback (walk_state, &op);
 					status = acpi_ps_next_parse_state (walk_state, op, status);
@@ -677,40 +664,44 @@
 				}
 			}
 
-			op->aml_offset = walk_state->aml_offset;
+			op->common.aml_offset = walk_state->aml_offset;
 
 			if (walk_state->op_info) {
 				ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
-					"Op=%p Opcode=%4.4X Aml %p Oft=%5.5X\n",
-					 op, op->opcode, parser_state->aml, op->aml_offset));
+					"Opcode %4.4X [%s] Op %p Aml %p aml_offset %5.5X\n",
+					 (u32) op->common.aml_opcode, walk_state->op_info->name,
+					 op, parser_state->aml, op->common.aml_offset));
 			}
 		}
 
 
-		/* Start Arg_count at zero because we don't know if there are any args yet */
+		/* Start arg_count at zero because we don't know if there are any args yet */
 
 		walk_state->arg_count = 0;
 
-
 		if (walk_state->arg_types) /* Are there any arguments that must be processed? */ {
-			/* get arguments */
+			/* Get arguments */
 
-			switch (op->opcode) {
+			switch (op->common.aml_opcode) {
 			case AML_BYTE_OP:       /* AML_BYTEDATA_ARG */
 			case AML_WORD_OP:       /* AML_WORDDATA_ARG */
 			case AML_DWORD_OP:      /* AML_DWORDATA_ARG */
 			case AML_QWORD_OP:      /* AML_QWORDATA_ARG */
 			case AML_STRING_OP:     /* AML_ASCIICHARLIST_ARG */
 
-				/* fill in constant or string argument directly */
+				/* Fill in constant or string argument directly */
 
 				acpi_ps_get_next_simple_arg (parser_state,
-						 GET_CURRENT_ARG_TYPE (walk_state->arg_types), op);
+					GET_CURRENT_ARG_TYPE (walk_state->arg_types), op);
 				break;
 
 			case AML_INT_NAMEPATH_OP:   /* AML_NAMESTRING_ARG */
 
-				acpi_ps_get_next_namepath (parser_state, op, &walk_state->arg_count, 1);
+				status = acpi_ps_get_next_namepath (walk_state, parser_state, op, 1);
+				if (ACPI_FAILURE (status)) {
+					goto close_this_op;
+				}
+
 				walk_state->arg_types = 0;
 				break;
 
@@ -719,202 +710,268 @@
 
 				/* Op is not a constant or string, append each argument */
 
-				while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) && !walk_state->arg_count) {
-					walk_state->aml_offset = parser_state->aml - parser_state->aml_start;
-					arg = acpi_ps_get_next_arg (parser_state,
-							 GET_CURRENT_ARG_TYPE (walk_state->arg_types),
-							 &walk_state->arg_count);
+				while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) &&
+						!walk_state->arg_count) {
+					walk_state->aml_offset = ACPI_PTR_DIFF (parser_state->aml,
+							   parser_state->aml_start);
+					status = acpi_ps_get_next_arg (walk_state, parser_state,
+							 GET_CURRENT_ARG_TYPE (walk_state->arg_types), &arg);
+					if (ACPI_FAILURE (status)) {
+						goto close_this_op;
+					}
+
 					if (arg) {
-						arg->aml_offset = walk_state->aml_offset;
+						arg->common.aml_offset = walk_state->aml_offset;
 						acpi_ps_append_arg (op, arg);
 					}
-
 					INCREMENT_ARG_LIST (walk_state->arg_types);
 				}
 
+				switch (op->common.aml_opcode) {
+				case AML_METHOD_OP:
 
-				/* For a method, save the length and address of the body */
+					/* For a method, save the length and address of the body */
 
-				if (op->opcode == AML_METHOD_OP) {
 					/*
 					 * Skip parsing of control method or opregion body,
 					 * because we don't have enough info in the first pass
 					 * to parse them correctly.
 					 */
-					((acpi_parse2_object * ) op)->data    = parser_state->aml;
-					((acpi_parse2_object * ) op)->length  = (u32) (parser_state->pkg_end -
-							   parser_state->aml);
-
+					op->named.data   = parser_state->aml;
+					op->named.length = (u32) (parser_state->pkg_end - parser_state->aml);
 					/*
-					 * Skip body of method.  For Op_regions, we must continue
+					 * Skip body of method.  For op_regions, we must continue
 					 * parsing because the opregion is not a standalone
 					 * package (We don't know where the end is).
 					 */
 					parser_state->aml   = parser_state->pkg_end;
-					walk_state->arg_count          = 0;
-				}
+					walk_state->arg_count = 0;
+					break;
+
+				case AML_BUFFER_OP:
+				case AML_PACKAGE_OP:
+				case AML_VAR_PACKAGE_OP:
+
+					if ((op->common.parent) &&
+						(op->common.parent->common.aml_opcode == AML_NAME_OP) &&
+						(walk_state->descending_callback != acpi_ds_exec_begin_op)) {
+						/*
+						 * Skip parsing of
+						 * because we don't have enough info in the first pass
+						 * to parse them correctly.
+						 */
+						op->named.data   = aml_op_start;
+						op->named.length = (u32) (parser_state->pkg_end - aml_op_start);
+						/*
+						 * Skip body
+						 */
+						parser_state->aml   = parser_state->pkg_end;
+						walk_state->arg_count = 0;
+					}
+					break;
+
+				case AML_WHILE_OP:
+
+					if (walk_state->control_state) {
+						walk_state->control_state->control.package_end = parser_state->pkg_end;
+					}
+					break;
 
+				default:
+					/* No action for all other opcodes */
+					break;
+				}
 				break;
 			}
 		}
 
+		/* Check for arguments that need to be processed */
 
-		/*
-		 * Zero Arg_count means that all arguments for this op have been processed
-		 */
-		if (!walk_state->arg_count) {
-			/* completed Op, prepare for next */
+		if (walk_state->arg_count) {
+			/* There are arguments (complex ones), push Op and prepare for argument */
 
-			walk_state->op_info = acpi_ps_get_opcode_info (op->opcode);
-			if (walk_state->op_info->flags & AML_NAMED) {
-				if (acpi_gbl_depth) {
-					acpi_gbl_depth--;
-				}
+			status = acpi_ps_push_scope (parser_state, op,
+					 walk_state->arg_types, walk_state->arg_count);
+			if (ACPI_FAILURE (status)) {
+				return_ACPI_STATUS (status);
+			}
+			op = NULL;
+			continue;
+		}
 
-				if (op->opcode == AML_REGION_OP) {
-					/*
-					 * Skip parsing of control method or opregion body,
-					 * because we don't have enough info in the first pass
-					 * to parse them correctly.
-					 *
-					 * Completed parsing an Op_region declaration, we now
-					 * know the length.
-					 */
-					((acpi_parse2_object * ) op)->length = (u32) (parser_state->aml -
-							   ((acpi_parse2_object * ) op)->data);
-				}
+		/* All arguments have been processed -- Op is complete, prepare for next */
+
+		walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
+		if (walk_state->op_info->flags & AML_NAMED) {
+			if (acpi_gbl_depth) {
+				acpi_gbl_depth--;
 			}
 
-			if (walk_state->op_info->flags & AML_CREATE) {
+			if (op->common.aml_opcode == AML_REGION_OP) {
 				/*
-				 * Backup to beginning of Create_xXXfield declaration (1 for
-				 * Opcode)
+				 * Skip parsing of control method or opregion body,
+				 * because we don't have enough info in the first pass
+				 * to parse them correctly.
 				 *
-				 * Body_length is unknown until we parse the body
+				 * Completed parsing an op_region declaration, we now
+				 * know the length.
 				 */
-				((acpi_parse2_object * ) op)->length = (u32) (parser_state->aml -
-						   ((acpi_parse2_object * ) op)->data);
+				op->named.length = (u32) (parser_state->aml - op->named.data);
 			}
+		}
 
-			/* This op complete, notify the dispatcher */
+		if (walk_state->op_info->flags & AML_CREATE) {
+			/*
+			 * Backup to beginning of create_xXXfield declaration (1 for
+			 * Opcode)
+			 *
+			 * body_length is unknown until we parse the body
+			 */
+			op->named.length = (u32) (parser_state->aml - op->named.data);
+		}
 
-			if (walk_state->ascending_callback != NULL) {
-				walk_state->op    = op;
-				walk_state->opcode = op->opcode;
+		/* This op complete, notify the dispatcher */
 
-				status = walk_state->ascending_callback (walk_state);
-				status = acpi_ps_next_parse_state (walk_state, op, status);
-				if (status == AE_CTRL_PENDING) {
-					status = AE_OK;
-					goto close_this_op;
-				}
+		if (walk_state->ascending_callback != NULL) {
+			walk_state->op    = op;
+			walk_state->opcode = op->common.aml_opcode;
+
+			status = walk_state->ascending_callback (walk_state);
+			status = acpi_ps_next_parse_state (walk_state, op, status);
+			if (status == AE_CTRL_PENDING) {
+				status = AE_OK;
+				goto close_this_op;
 			}
+		}
 
 
 close_this_op:
+		/*
+		 * Finished one argument of the containing scope
+		 */
+		parser_state->scope->parse_scope.arg_count--;
 
-			/*
-			 * Finished one argument of the containing scope
-			 */
-			parser_state->scope->parse_scope.arg_count--;
-
-			/* Close this Op (may result in parse subtree deletion) */
-
-			if (acpi_ps_complete_this_op (walk_state, op)) {
-				op = NULL;
-			}
+		/* Close this Op (will result in parse subtree deletion) */
 
+		acpi_ps_complete_this_op (walk_state, op);
+		op = NULL;
 
-			switch (status) {
-			case AE_OK:
-				break;
+		switch (status) {
+		case AE_OK:
+			break;
 
 
-			case AE_CTRL_TRANSFER:
+		case AE_CTRL_TRANSFER:
 
-				/*
-				 * We are about to transfer to a called method.
-				 */
-				walk_state->prev_op = op;
-				walk_state->prev_arg_types = walk_state->arg_types;
-				return_ACPI_STATUS (status);
-				break;
+			/*
+			 * We are about to transfer to a called method.
+			 */
+			walk_state->prev_op = op;
+			walk_state->prev_arg_types = walk_state->arg_types;
+			return_ACPI_STATUS (status);
 
 
-			case AE_CTRL_END:
+		case AE_CTRL_END:
 
-				acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, &walk_state->arg_count);
+			acpi_ps_pop_scope (parser_state, &op,
+				&walk_state->arg_types, &walk_state->arg_count);
 
+			if (op) {
 				walk_state->op    = op;
-				walk_state->op_info = acpi_ps_get_opcode_info (op->opcode);
-				walk_state->opcode = op->opcode;
+				walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
+				walk_state->opcode = op->common.aml_opcode;
 
 				status = walk_state->ascending_callback (walk_state);
 				status = acpi_ps_next_parse_state (walk_state, op, status);
 
 				acpi_ps_complete_this_op (walk_state, op);
 				op = NULL;
-				status = AE_OK;
-				break;
+			}
+			status = AE_OK;
+			break;
 
 
-			case AE_CTRL_TERMINATE:
+		case AE_CTRL_BREAK:
+		case AE_CTRL_CONTINUE:
 
-				status = AE_OK;
+			/* Pop off scopes until we find the While */
 
-				/* Clean up */
-				do {
-					if (op) {
-						acpi_ps_complete_this_op (walk_state, op);
-					}
+			while (!op || (op->common.aml_opcode != AML_WHILE_OP)) {
+				acpi_ps_pop_scope (parser_state, &op,
+					&walk_state->arg_types, &walk_state->arg_count);
+			}
 
-					acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, &walk_state->arg_count);
-				} while (op);
+			/* Close this iteration of the While loop */
 
-				return_ACPI_STATUS (status);
-				break;
+			walk_state->op    = op;
+			walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
+			walk_state->opcode = op->common.aml_opcode;
+
+			status = walk_state->ascending_callback (walk_state);
+			status = acpi_ps_next_parse_state (walk_state, op, status);
+
+			acpi_ps_complete_this_op (walk_state, op);
+			op = NULL;
 
+			status = AE_OK;
+			break;
 
-			default:  /* All other non-AE_OK status */
 
-				if (op == NULL) {
-					acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, &walk_state->arg_count);
+		case AE_CTRL_TERMINATE:
+
+			status = AE_OK;
+
+			/* Clean up */
+			do {
+				if (op) {
+					acpi_ps_complete_this_op (walk_state, op);
 				}
-				walk_state->prev_op = op;
-				walk_state->prev_arg_types = walk_state->arg_types;
+				acpi_ps_pop_scope (parser_state, &op,
+					&walk_state->arg_types, &walk_state->arg_count);
 
-				/*
-				 * TEMP:
-				 */
+			} while (op);
 
-				return_ACPI_STATUS (status);
-				break;
-			}
+			return_ACPI_STATUS (status);
 
-			/* This scope complete? */
 
-			if (acpi_ps_has_completed_scope (parser_state)) {
-				acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, &walk_state->arg_count);
-				ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op));
-			}
+		default:  /* All other non-AE_OK status */
 
-			else {
-				op = NULL;
-			}
+			do {
+				if (op) {
+					acpi_ps_complete_this_op (walk_state, op);
+				}
+				acpi_ps_pop_scope (parser_state, &op,
+					&walk_state->arg_types, &walk_state->arg_count);
 
-		}
+			} while (op);
 
 
-		/* Arg_count is non-zero */
+			/*
+			 * TBD: Cleanup parse ops on error
+			 */
+#if 0
+			if (op == NULL) {
+				acpi_ps_pop_scope (parser_state, &op,
+					&walk_state->arg_types, &walk_state->arg_count);
+			}
+#endif
+			walk_state->prev_op = op;
+			walk_state->prev_arg_types = walk_state->arg_types;
+			return_ACPI_STATUS (status);
+		}
 
-		else {
-			/* complex argument, push Op and prepare for argument */
+		/* This scope complete? */
 
-			acpi_ps_push_scope (parser_state, op, walk_state->arg_types, walk_state->arg_count);
+		if (acpi_ps_has_completed_scope (parser_state)) {
+			acpi_ps_pop_scope (parser_state, &op,
+				&walk_state->arg_types, &walk_state->arg_count);
+			ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op));
+		}
+		else {
 			op = NULL;
 		}
 
-	} /* while Parser_state->Aml */
+	} /* while parser_state->Aml */
 
 
 	/*
@@ -928,8 +985,8 @@
 		if (op) {
 			if (walk_state->ascending_callback != NULL) {
 				walk_state->op    = op;
-				walk_state->op_info = acpi_ps_get_opcode_info (op->opcode);
-				walk_state->opcode = op->opcode;
+				walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
+				walk_state->opcode = op->common.aml_opcode;
 
 				status = walk_state->ascending_callback (walk_state);
 				status = acpi_ps_next_parse_state (walk_state, op, status);
@@ -947,7 +1004,8 @@
 							acpi_ps_complete_this_op (walk_state, op);
 						}
 
-						acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, &walk_state->arg_count);
+						acpi_ps_pop_scope (parser_state, &op,
+							&walk_state->arg_types, &walk_state->arg_count);
 
 					} while (op);
 
@@ -963,7 +1021,8 @@
 			acpi_ps_complete_this_op (walk_state, op);
 		}
 
-		acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, &walk_state->arg_count);
+		acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types,
+			&walk_state->arg_count);
 
 	} while (op);
 
@@ -973,12 +1032,12 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_parse_aml
+ * FUNCTION:    acpi_ps_parse_aml
  *
- * PARAMETERS:  Start_scope     - The starting point of the parse.  Becomes the
+ * PARAMETERS:  start_scope     - The starting point of the parse.  Becomes the
  *                                root of the parsed op tree.
  *              Aml             - Pointer to the raw AML code to parse
- *              Aml_size        - Length of the AML to parse
+ *              aml_size        - Length of the AML to parse
  *
  *
  * RETURN:      Status
@@ -989,33 +1048,36 @@
 
 acpi_status
 acpi_ps_parse_aml (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status;
-	acpi_walk_list          walk_list;
-	acpi_walk_list          *prev_walk_list = acpi_gbl_current_walk_list;
-	acpi_walk_state         *previous_walk_state;
+	acpi_status                     status;
+	acpi_status                     terminate_status;
+	struct acpi_thread_state        *thread;
+	struct acpi_thread_state        *prev_walk_list = acpi_gbl_current_walk_list;
+	struct acpi_walk_state          *previous_walk_state;
 
 
-	FUNCTION_TRACE ("Ps_parse_aml");
+	ACPI_FUNCTION_TRACE ("ps_parse_aml");
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Entered with Walk_state=%p Aml=%p size=%X\n",
+	ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Entered with walk_state=%p Aml=%p size=%X\n",
 		walk_state, walk_state->parser_state.aml, walk_state->parser_state.aml_size));
 
 
-	/* Create and initialize a new walk list */
+	/* Create and initialize a new thread state */
 
-	walk_list.walk_state            = NULL;
-	walk_list.acquired_mutex_list.prev = NULL;
-	walk_list.acquired_mutex_list.next = NULL;
-
-	walk_state->walk_list = &walk_list;
-	acpi_ds_push_walk_state (walk_state, &walk_list);
+	thread = acpi_ut_create_thread_state ();
+	if (!thread) {
+		return_ACPI_STATUS (AE_NO_MEMORY);
+	}
 
+	walk_state->thread = thread;
+	acpi_ds_push_walk_state (walk_state, thread);
 
-	/* TBD: [Restructure] TEMP until we pass Walk_state to the interpreter
+	/*
+	 * This global allows the AML debugger to get a handle to the currently
+	 * executing control method.
 	 */
-	acpi_gbl_current_walk_list = &walk_list;
+	acpi_gbl_current_walk_list = thread;
 
 	/*
 	 * Execute the walk loop as long as there is a valid Walk State.  This
@@ -1027,37 +1089,41 @@
 	while (walk_state) {
 		if (ACPI_SUCCESS (status)) {
 			/*
-			 * The Parse_loop executes AML until the method terminates
+			 * The parse_loop executes AML until the method terminates
 			 * or calls another method.
 			 */
 			status = acpi_ps_parse_loop (walk_state);
 		}
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
-			"Completed one call to walk loop, State=%p\n", walk_state));
+			"Completed one call to walk loop, %s State=%p\n",
+			acpi_format_exception (status), walk_state));
 
 		if (status == AE_CTRL_TRANSFER) {
 			/*
 			 * A method call was detected.
 			 * Transfer control to the called control method
 			 */
-			status = acpi_ds_call_control_method (&walk_list, walk_state, NULL);
+			status = acpi_ds_call_control_method (thread, walk_state, NULL);
 
 			/*
 			 * If the transfer to the new method method call worked, a new walk
 			 * state was created -- get it
 			 */
-			walk_state = acpi_ds_get_current_walk_state (&walk_list);
+			walk_state = acpi_ds_get_current_walk_state (thread);
 			continue;
 		}
-
 		else if (status == AE_CTRL_TERMINATE) {
 			status = AE_OK;
 		}
+		else if (status != AE_OK) {
+			ACPI_REPORT_METHOD_ERROR ("Method execution failed",
+				walk_state->method_node, NULL, status);
+		}
 
 		/* We are done with this walk, move on to the parent if any */
 
-		walk_state = acpi_ds_pop_walk_state (&walk_list);
+		walk_state = acpi_ds_pop_walk_state (thread);
 
 		/* Reset the current scope to the beginning of scope stack */
 
@@ -1068,7 +1134,13 @@
 		 * there's lots of cleanup to do
 		 */
 		if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) {
-			acpi_ds_terminate_control_method (walk_state);
+			terminate_status = acpi_ds_terminate_control_method (walk_state);
+			if (ACPI_FAILURE (terminate_status)) {
+				ACPI_REPORT_ERROR ((
+					"Could not terminate control method properly\n"));
+
+				/* Ignore error and continue */
+			}
 		}
 
 		/* Delete this walk state and all linked control states */
@@ -1077,22 +1149,29 @@
 
 		previous_walk_state = walk_state;
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Return_value=%p, State=%p\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "return_value=%p, State=%p\n",
 			walk_state->return_desc, walk_state));
 
 		/* Check if we have restarted a preempted walk */
 
-		walk_state = acpi_ds_get_current_walk_state (&walk_list);
+		walk_state = acpi_ds_get_current_walk_state (thread);
 		if (walk_state) {
 			if (ACPI_SUCCESS (status)) {
-				/* There is another walk state, restart it */
-
 				/*
-				 * If the method returned value is not used by the parent,
+				 * There is another walk state, restart it.
+				 * If the method return value is not used by the parent,
 				 * The object is deleted
 				 */
-				acpi_ds_restart_control_method (walk_state, previous_walk_state->return_desc);
-				walk_state->walk_type |= WALK_METHOD_RESTART;
+				status = acpi_ds_restart_control_method (walk_state,
+						 previous_walk_state->return_desc);
+				if (ACPI_SUCCESS (status)) {
+					walk_state->walk_type |= ACPI_WALK_METHOD_RESTART;
+				}
+			}
+			else {
+				/* On error, delete any return object */
+
+				acpi_ut_remove_reference (previous_walk_state->return_desc);
 			}
 		}
 
@@ -1103,7 +1182,6 @@
 		else if (previous_walk_state->caller_return_desc) {
 			*(previous_walk_state->caller_return_desc) = previous_walk_state->return_desc; /* NULL if no return value */
 		}
-
 		else if (previous_walk_state->return_desc) {
 			/* Caller doesn't want it, must delete it */
 
@@ -1113,10 +1191,10 @@
 		acpi_ds_delete_walk_state (previous_walk_state);
 	}
 
-
 	/* Normal exit */
 
-	acpi_ex_release_all_mutexes ((acpi_operand_object *) &walk_list.acquired_mutex_list);
+	acpi_ex_release_all_mutexes (thread);
+	acpi_ut_delete_generic_state (ACPI_CAST_PTR (union acpi_generic_state, thread));
 	acpi_gbl_current_walk_list = prev_walk_list;
 	return_ACPI_STATUS (status);
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/parser/psscope.c linux-2.4.22-pre2/drivers/acpi/parser/psscope.c
--- linux-2.4.21/drivers/acpi/parser/psscope.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/parser/psscope.c	2003-06-26 21:43:11.000000000 +0000
@@ -1,41 +1,59 @@
 /******************************************************************************
  *
  * Module Name: psscope - Parser scope stack management routines
- *              $Revision: 30 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
+#include <acpi/acpi.h>
+#include <acpi/acparser.h>
 
 #define _COMPONENT          ACPI_PARSER
-	 MODULE_NAME         ("psscope")
+	 ACPI_MODULE_NAME    ("psscope")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_get_parent_scope
+ * FUNCTION:    acpi_ps_get_parent_scope
  *
- * PARAMETERS:  Parser_state        - Current parser state object
+ * PARAMETERS:  parser_state        - Current parser state object
  *
  * RETURN:      Pointer to an Op object
  *
@@ -43,9 +61,9 @@
  *
  ******************************************************************************/
 
-acpi_parse_object *
+union acpi_parse_object *
 acpi_ps_get_parent_scope (
-	acpi_parse_state        *parser_state)
+	struct acpi_parse_state         *parser_state)
 {
 	return (parser_state->scope->parse_scope.op);
 }
@@ -53,9 +71,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_has_completed_scope
+ * FUNCTION:    acpi_ps_has_completed_scope
  *
- * PARAMETERS:  Parser_state        - Current parser state object
+ * PARAMETERS:  parser_state        - Current parser state object
  *
  * RETURN:      Boolean, TRUE = scope completed.
  *
@@ -67,7 +85,7 @@
 
 u8
 acpi_ps_has_completed_scope (
-	acpi_parse_state        *parser_state)
+	struct acpi_parse_state         *parser_state)
 {
 	return ((u8) ((parser_state->aml >= parser_state->scope->parse_scope.arg_end ||
 			   !parser_state->scope->parse_scope.arg_count)));
@@ -76,9 +94,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_init_scope
+ * FUNCTION:    acpi_ps_init_scope
  *
- * PARAMETERS:  Parser_state        - Current parser state object
+ * PARAMETERS:  parser_state        - Current parser state object
  *              Root                - the Root Node of this new scope
  *
  * RETURN:      Status
@@ -89,13 +107,13 @@
 
 acpi_status
 acpi_ps_init_scope (
-	acpi_parse_state        *parser_state,
-	acpi_parse_object       *root_op)
+	struct acpi_parse_state         *parser_state,
+	union acpi_parse_object         *root_op)
 {
-	acpi_generic_state      *scope;
+	union acpi_generic_state        *scope;
 
 
-	FUNCTION_TRACE_PTR ("Ps_init_scope", root_op);
+	ACPI_FUNCTION_TRACE_PTR ("ps_init_scope", root_op);
 
 
 	scope = acpi_ut_create_generic_state ();
@@ -118,12 +136,12 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_push_scope
+ * FUNCTION:    acpi_ps_push_scope
  *
- * PARAMETERS:  Parser_state        - Current parser state object
+ * PARAMETERS:  parser_state        - Current parser state object
  *              Op                  - Current op to be pushed
- *              Remaining_args      - List of args remaining
- *              Arg_count           - Fixed or variable number of args
+ *              remaining_args      - List of args remaining
+ *              arg_count           - Fixed or variable number of args
  *
  * RETURN:      Status
  *
@@ -133,20 +151,20 @@
 
 acpi_status
 acpi_ps_push_scope (
-	acpi_parse_state        *parser_state,
-	acpi_parse_object       *op,
-	u32                     remaining_args,
-	u32                     arg_count)
+	struct acpi_parse_state         *parser_state,
+	union acpi_parse_object         *op,
+	u32                             remaining_args,
+	u32                             arg_count)
 {
-	acpi_generic_state      *scope;
+	union acpi_generic_state        *scope;
 
 
-	FUNCTION_TRACE_PTR ("Ps_push_scope", op);
+	ACPI_FUNCTION_TRACE_PTR ("ps_push_scope", op);
 
 
 	scope = acpi_ut_create_generic_state ();
 	if (!scope) {
-		return (AE_NO_MEMORY);
+		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
 
 
@@ -170,7 +188,7 @@
 	else {
 		/* single argument */
 
-		scope->parse_scope.arg_end = ACPI_MAX_AML;
+		scope->parse_scope.arg_end = ACPI_TO_POINTER (ACPI_MAX_PTR);
 	}
 
 	return_ACPI_STATUS (AE_OK);
@@ -179,13 +197,13 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_pop_scope
+ * FUNCTION:    acpi_ps_pop_scope
  *
- * PARAMETERS:  Parser_state        - Current parser state object
+ * PARAMETERS:  parser_state        - Current parser state object
  *              Op                  - Where the popped op is returned
- *              Arg_list            - Where the popped "next argument" is
+ *              arg_list            - Where the popped "next argument" is
  *                                    returned
- *              Arg_count           - Count of objects in Arg_list
+ *              arg_count           - Count of objects in arg_list
  *
  * RETURN:      Status
  *
@@ -195,15 +213,15 @@
 
 void
 acpi_ps_pop_scope (
-	acpi_parse_state        *parser_state,
-	acpi_parse_object       **op,
-	u32                     *arg_list,
-	u32                     *arg_count)
+	struct acpi_parse_state         *parser_state,
+	union acpi_parse_object         **op,
+	u32                             *arg_list,
+	u32                             *arg_count)
 {
-	acpi_generic_state      *scope = parser_state->scope;
+	union acpi_generic_state        *scope = parser_state->scope;
 
 
-	FUNCTION_TRACE ("Ps_pop_scope");
+	ACPI_FUNCTION_TRACE ("ps_pop_scope");
 
 
 	/*
@@ -240,9 +258,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_cleanup_scope
+ * FUNCTION:    acpi_ps_cleanup_scope
  *
- * PARAMETERS:  Parser_state        - Current parser state object
+ * PARAMETERS:  parser_state        - Current parser state object
  *
  * RETURN:      Status
  *
@@ -253,11 +271,11 @@
 
 void
 acpi_ps_cleanup_scope (
-	acpi_parse_state        *parser_state)
+	struct acpi_parse_state         *parser_state)
 {
-	acpi_generic_state      *scope;
+	union acpi_generic_state        *scope;
 
-	FUNCTION_TRACE_PTR ("Ps_cleanup_scope", parser_state);
+	ACPI_FUNCTION_TRACE_PTR ("ps_cleanup_scope", parser_state);
 
 
 	if (!parser_state) {
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/parser/pstree.c linux-2.4.22-pre2/drivers/acpi/parser/pstree.c
--- linux-2.4.21/drivers/acpi/parser/pstree.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/parser/pstree.c	2003-06-26 21:43:16.000000000 +0000
@@ -1,40 +1,58 @@
 /******************************************************************************
  *
  * Module Name: pstree - Parser op tree manipulation/traversal/search
- *              $Revision: 35 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "amlcode.h"
+#include <acpi/acpi.h>
+#include <acpi/acparser.h>
+#include <acpi/amlcode.h>
 
 #define _COMPONENT          ACPI_PARSER
-	 MODULE_NAME         ("pstree")
+	 ACPI_MODULE_NAME    ("pstree")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_get_arg
+ * FUNCTION:    acpi_ps_get_arg
  *
  * PARAMETERS:  Op              - Get an argument for this op
  *              Argn            - Nth argument to get
@@ -45,21 +63,21 @@
  *
  ******************************************************************************/
 
-acpi_parse_object *
+union acpi_parse_object *
 acpi_ps_get_arg (
-	acpi_parse_object       *op,
-	u32                     argn)
+	union acpi_parse_object         *op,
+	u32                             argn)
 {
-	acpi_parse_object       *arg = NULL;
-	const acpi_opcode_info  *op_info;
+	union acpi_parse_object         *arg = NULL;
+	const struct acpi_opcode_info   *op_info;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/* Get the info structure for this opcode */
 
-	op_info = acpi_ps_get_opcode_info (op->opcode);
+	op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
 	if (op_info->class == AML_CLASS_UNKNOWN) {
 		/* Invalid opcode or ASCII character */
 
@@ -76,10 +94,10 @@
 
 	/* Get the requested argument object */
 
-	arg = op->value.arg;
+	arg = op->common.value.arg;
 	while (arg && argn) {
 		argn--;
-		arg = arg->next;
+		arg = arg->common.next;
 	}
 
 	return (arg);
@@ -88,7 +106,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_append_arg
+ * FUNCTION:    acpi_ps_append_arg
  *
  * PARAMETERS:  Op              - Append an argument to this Op.
  *              Arg             - Argument Op to append
@@ -101,14 +119,14 @@
 
 void
 acpi_ps_append_arg (
-	acpi_parse_object       *op,
-	acpi_parse_object       *arg)
+	union acpi_parse_object         *op,
+	union acpi_parse_object         *arg)
 {
-	acpi_parse_object       *prev_arg;
-	const acpi_opcode_info  *op_info;
+	union acpi_parse_object         *prev_arg;
+	const struct acpi_opcode_info   *op_info;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	if (!op) {
@@ -117,11 +135,12 @@
 
 	/* Get the info structure for this opcode */
 
-	op_info = acpi_ps_get_opcode_info (op->opcode);
+	op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
 	if (op_info->class == AML_CLASS_UNKNOWN) {
 		/* Invalid opcode */
 
-		REPORT_ERROR (("Ps_append_arg: Invalid AML Opcode: 0x%2.2X\n", op->opcode));
+		ACPI_REPORT_ERROR (("ps_append_arg: Invalid AML Opcode: 0x%2.2X\n",
+			op->common.aml_opcode));
 		return;
 	}
 
@@ -136,35 +155,35 @@
 
 	/* Append the argument to the linked argument list */
 
-	if (op->value.arg) {
+	if (op->common.value.arg) {
 		/* Append to existing argument list */
 
-		prev_arg = op->value.arg;
-		while (prev_arg->next) {
-			prev_arg = prev_arg->next;
+		prev_arg = op->common.value.arg;
+		while (prev_arg->common.next) {
+			prev_arg = prev_arg->common.next;
 		}
-		prev_arg->next = arg;
+		prev_arg->common.next = arg;
 	}
 
 	else {
 		/* No argument list, this will be the first argument */
 
-		op->value.arg = arg;
+		op->common.value.arg = arg;
 	}
 
 
 	/* Set the parent in this arg and any args linked after it */
 
 	while (arg) {
-		arg->parent = op;
-		arg = arg->next;
+		arg->common.parent = op;
+		arg = arg->common.next;
 	}
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_get_child
+ * FUNCTION:    acpi_ps_get_child
  *
  * PARAMETERS:  Op              - Get the child of this Op
  *
@@ -174,17 +193,17 @@
  *
  ******************************************************************************/
 
-acpi_parse_object *
+union acpi_parse_object *
 acpi_ps_get_child (
-	acpi_parse_object       *op)
+	union acpi_parse_object         *op)
 {
-	acpi_parse_object       *child = NULL;
+	union acpi_parse_object         *child = NULL;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
-	switch (op->opcode) {
+	switch (op->common.aml_opcode) {
 	case AML_SCOPE_OP:
 	case AML_ELSE_OP:
 	case AML_DEVICE_OP:
@@ -219,6 +238,10 @@
 		child = acpi_ps_get_arg (op, 3);
 		break;
 
+
+	default:
+		/* All others have no children */
+		break;
 	}
 
 	return (child);
@@ -227,7 +250,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_get_depth_next
+ * FUNCTION:    acpi_ps_get_depth_next
  *
  * PARAMETERS:  Origin          - Root of subtree to search
  *              Op              - Last (previous) Op that was found
@@ -239,17 +262,17 @@
  *
  ******************************************************************************/
 
-acpi_parse_object *
+union acpi_parse_object *
 acpi_ps_get_depth_next (
-	acpi_parse_object       *origin,
-	acpi_parse_object       *op)
+	union acpi_parse_object         *origin,
+	union acpi_parse_object         *op)
 {
-	acpi_parse_object       *next = NULL;
-	acpi_parse_object       *parent;
-	acpi_parse_object       *arg;
+	union acpi_parse_object         *next = NULL;
+	union acpi_parse_object         *parent;
+	union acpi_parse_object         *arg;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	if (!op) {
@@ -265,19 +288,19 @@
 
 	/* look for a sibling */
 
-	next = op->next;
+	next = op->common.next;
 	if (next) {
 		return (next);
 	}
 
 	/* look for a sibling of parent */
 
-	parent = op->parent;
+	parent = op->common.parent;
 
 	while (parent) {
 		arg = acpi_ps_get_arg (parent, 0);
 		while (arg && (arg != origin) && (arg != op)) {
-			arg = arg->next;
+			arg = arg->common.next;
 		}
 
 		if (arg == origin) {
@@ -286,13 +309,14 @@
 			return (NULL);
 		}
 
-		if (parent->next) {
+		if (parent->common.next) {
 			/* found sibling of parent */
-			return (parent->next);
+
+			return (parent->common.next);
 		}
 
 		op = parent;
-		parent = parent->parent;
+		parent = parent->common.parent;
 	}
 
 	return (next);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/parser/psutils.c linux-2.4.22-pre2/drivers/acpi/parser/psutils.c
--- linux-2.4.21/drivers/acpi/parser/psutils.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/parser/psutils.c	2003-06-26 21:43:28.000000000 +0000
@@ -1,47 +1,89 @@
 /******************************************************************************
  *
  * Module Name: psutils - Parser miscellaneous utilities (Parser only)
- *              $Revision: 44 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "amlcode.h"
+#include <acpi/acpi.h>
+#include <acpi/acparser.h>
+#include <acpi/amlcode.h>
+#include <acpi/acnamesp.h>
 
 #define _COMPONENT          ACPI_PARSER
-	 MODULE_NAME         ("psutils")
+	 ACPI_MODULE_NAME    ("psutils")
 
 
-#define PARSEOP_GENERIC     0x01
-#define PARSEOP_NAMED       0x02
-#define PARSEOP_DEFERRED    0x04
-#define PARSEOP_BYTELIST    0x08
-#define PARSEOP_IN_CACHE    0x80
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ps_create_scope_op
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      scope_op
+ *
+ * DESCRIPTION: Create a Scope and associated namepath op with the root name
+ *
+ ******************************************************************************/
+
+union acpi_parse_object *
+acpi_ps_create_scope_op (
+	void)
+{
+	union acpi_parse_object         *scope_op;
+
+
+	scope_op = acpi_ps_alloc_op (AML_SCOPE_OP);
+	if (!scope_op) {
+		return (NULL);
+	}
+
+
+	scope_op->named.name = ACPI_ROOT_NAME;
+	return (scope_op);
+}
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_init_op
+ * FUNCTION:    acpi_ps_init_op
  *
  * PARAMETERS:  Op              - A newly allocated Op object
  *              Opcode          - Opcode to store in the Op
@@ -55,28 +97,23 @@
 
 void
 acpi_ps_init_op (
-	acpi_parse_object       *op,
-	u16                     opcode)
+	union acpi_parse_object         *op,
+	u16                             opcode)
 {
-	const acpi_opcode_info  *aml_op;
-
-
-	FUNCTION_ENTRY ();
-
+	ACPI_FUNCTION_ENTRY ();
 
-	op->data_type = ACPI_DESC_TYPE_PARSER;
-	op->opcode = opcode;
 
-	aml_op = acpi_ps_get_opcode_info (opcode);
+	op->common.data_type = ACPI_DESC_TYPE_PARSER;
+	op->common.aml_opcode = opcode;
 
-	DEBUG_ONLY_MEMBERS (STRNCPY (op->op_name, aml_op->name,
-			   sizeof (op->op_name)));
+	ACPI_DISASM_ONLY_MEMBERS (ACPI_STRNCPY (op->common.aml_op_name,
+			(acpi_ps_get_opcode_info (opcode))->name, sizeof (op->common.aml_op_name)));
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_alloc_op
+ * FUNCTION:    acpi_ps_alloc_op
  *
  * PARAMETERS:  Opcode          - Opcode that will be stored in the new Op
  *
@@ -88,17 +125,17 @@
  *
  ******************************************************************************/
 
-acpi_parse_object*
+union acpi_parse_object*
 acpi_ps_alloc_op (
-	u16                     opcode)
+	u16                             opcode)
 {
-	acpi_parse_object       *op = NULL;
-	u32                     size;
-	u8                      flags;
-	const acpi_opcode_info  *op_info;
+	union acpi_parse_object         *op = NULL;
+	u32                             size;
+	u8                              flags;
+	const struct acpi_opcode_info   *op_info;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	op_info = acpi_ps_get_opcode_info (opcode);
@@ -106,33 +143,28 @@
 	/* Allocate the minimum required size object */
 
 	if (op_info->flags & AML_DEFER) {
-		size = sizeof (acpi_parse2_object);
-		flags = PARSEOP_DEFERRED;
+		size = sizeof (struct acpi_parse_obj_named);
+		flags = ACPI_PARSEOP_DEFERRED;
 	}
-
 	else if (op_info->flags & AML_NAMED) {
-		size = sizeof (acpi_parse2_object);
-		flags = PARSEOP_NAMED;
+		size = sizeof (struct acpi_parse_obj_named);
+		flags = ACPI_PARSEOP_NAMED;
 	}
-
 	else if (opcode == AML_INT_BYTELIST_OP) {
-		size = sizeof (acpi_parse2_object);
-		flags = PARSEOP_BYTELIST;
+		size = sizeof (struct acpi_parse_obj_named);
+		flags = ACPI_PARSEOP_BYTELIST;
 	}
-
 	else {
-		size = sizeof (acpi_parse_object);
-		flags = PARSEOP_GENERIC;
+		size = sizeof (struct acpi_parse_obj_common);
+		flags = ACPI_PARSEOP_GENERIC;
 	}
 
-
-	if (size == sizeof (acpi_parse_object)) {
+	if (size == sizeof (struct acpi_parse_obj_common)) {
 		/*
 		 * The generic op is by far the most common (16 to 1)
 		 */
 		op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE);
 	}
-
 	else {
 		op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE_EXT);
 	}
@@ -141,7 +173,7 @@
 
 	if (op) {
 		acpi_ps_init_op (op, opcode);
-		op->flags = flags;
+		op->common.flags = flags;
 	}
 
 	return (op);
@@ -150,7 +182,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_free_op
+ * FUNCTION:    acpi_ps_free_op
  *
  * PARAMETERS:  Op              - Op to be freed
  *
@@ -163,19 +195,18 @@
 
 void
 acpi_ps_free_op (
-	acpi_parse_object       *op)
+	union acpi_parse_object         *op)
 {
-	PROC_NAME ("Ps_free_op");
+	ACPI_FUNCTION_NAME ("ps_free_op");
 
 
-	if (op->opcode == AML_INT_RETURN_VALUE_OP) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Free retval op: %p\n", op));
+	if (op->common.aml_opcode == AML_INT_RETURN_VALUE_OP) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Free retval op: %p\n", op));
 	}
 
-	if (op->flags == PARSEOP_GENERIC) {
+	if (op->common.flags & ACPI_PARSEOP_GENERIC) {
 		acpi_ut_release_to_cache (ACPI_MEM_LIST_PSNODE, op);
 	}
-
 	else {
 		acpi_ut_release_to_cache (ACPI_MEM_LIST_PSNODE_EXT, op);
 	}
@@ -184,7 +215,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_delete_parse_cache
+ * FUNCTION:    acpi_ps_delete_parse_cache
  *
  * PARAMETERS:  None
  *
@@ -198,7 +229,7 @@
 acpi_ps_delete_parse_cache (
 	void)
 {
-	FUNCTION_TRACE ("Ps_delete_parse_cache");
+	ACPI_FUNCTION_TRACE ("ps_delete_parse_cache");
 
 
 	acpi_ut_delete_generic_cache (ACPI_MEM_LIST_PSNODE);
@@ -221,7 +252,7 @@
  */
 u8
 acpi_ps_is_leading_char (
-	u32                     c)
+	u32                             c)
 {
 	return ((u8) (c == '_' || (c >= 'A' && c <= 'Z')));
 }
@@ -232,7 +263,7 @@
  */
 u8
 acpi_ps_is_prefix_char (
-	u32                     c)
+	u32                             c)
 {
 	return ((u8) (c == '\\' || c == '^'));
 }
@@ -243,19 +274,19 @@
  */
 u32
 acpi_ps_get_name (
-	acpi_parse_object       *op)
+	union acpi_parse_object         *op)
 {
 
 
 	/* The "generic" object has no name associated with it */
 
-	if (op->flags & PARSEOP_GENERIC) {
+	if (op->common.flags & ACPI_PARSEOP_GENERIC) {
 		return (0);
 	}
 
 	/* Only the "Extended" parse objects have a name */
 
-	return (((acpi_parse2_object *) op)->name);
+	return (op->named.name);
 }
 
 
@@ -264,16 +295,16 @@
  */
 void
 acpi_ps_set_name (
-	acpi_parse_object       *op,
-	u32                     name)
+	union acpi_parse_object         *op,
+	u32                             name)
 {
 
 	/* The "generic" object has no name associated with it */
 
-	if (op->flags & PARSEOP_GENERIC) {
+	if (op->common.flags & ACPI_PARSEOP_GENERIC) {
 		return;
 	}
 
-	((acpi_parse2_object *) op)->name = name;
+	op->named.name = name;
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/parser/pswalk.c linux-2.4.22-pre2/drivers/acpi/parser/pswalk.c
--- linux-2.4.21/drivers/acpi/parser/pswalk.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/parser/pswalk.c	2003-06-26 21:43:13.000000000 +0000
@@ -1,47 +1,62 @@
 /******************************************************************************
  *
  * Module Name: pswalk - Parser routines to walk parsed op tree(s)
- *              $Revision: 58 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "amlcode.h"
-#include "acparser.h"
-#include "acdispat.h"
-#include "acnamesp.h"
-#include "acinterp.h"
+#include <acpi/acpi.h>
+#include <acpi/acparser.h>
+#include <acpi/acdispat.h>
 
 #define _COMPONENT          ACPI_PARSER
-	 MODULE_NAME         ("pswalk")
+	 ACPI_MODULE_NAME    ("pswalk")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_get_next_walk_op
+ * FUNCTION:    acpi_ps_get_next_walk_op
  *
- * PARAMETERS:  Walk_state          - Current state of the walk
+ * PARAMETERS:  walk_state          - Current state of the walk
  *              Op                  - Current Op to be walked
- *              Ascending_callback  - Procedure called when Op is complete
+ *              ascending_callback  - Procedure called when Op is complete
  *
  * RETURN:      Status
  *
@@ -51,22 +66,22 @@
 
 acpi_status
 acpi_ps_get_next_walk_op (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op,
-	acpi_parse_upwards      ascending_callback)
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op,
+	acpi_parse_upwards              ascending_callback)
 {
-	acpi_parse_object       *next;
-	acpi_parse_object       *parent;
-	acpi_parse_object       *grand_parent;
-	acpi_status             status;
+	union acpi_parse_object         *next;
+	union acpi_parse_object         *parent;
+	union acpi_parse_object         *grand_parent;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE_PTR ("Ps_get_next_walk_op", op);
+	ACPI_FUNCTION_TRACE_PTR ("ps_get_next_walk_op", op);
 
 
 	/* Check for a argument only if we are descending in the tree */
 
-	if (walk_state->next_op_info != NEXT_OP_UPWARD) {
+	if (walk_state->next_op_info != ACPI_NEXT_OP_UPWARD) {
 		/* Look for an argument or child of the current op */
 
 		next = acpi_ps_get_arg (op, 0);
@@ -75,22 +90,21 @@
 
 			walk_state->prev_op     = op;
 			walk_state->next_op     = next;
-			walk_state->next_op_info = NEXT_OP_DOWNWARD;
+			walk_state->next_op_info = ACPI_NEXT_OP_DOWNWARD;
 
 			return_ACPI_STATUS (AE_OK);
 		}
 
-
 		/*
 		 * No more children, this Op is complete.  Save Next and Parent
 		 * in case the Op object gets deleted by the callback routine
 		 */
-		next    = op->next;
-		parent  = op->parent;
+		next    = op->common.next;
+		parent  = op->common.parent;
 
 		walk_state->op    = op;
-		walk_state->op_info = acpi_ps_get_opcode_info (op->opcode);
-		walk_state->opcode = op->opcode;
+		walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
+		walk_state->opcode = op->common.aml_opcode;
 
 		status = ascending_callback (walk_state);
 
@@ -115,7 +129,7 @@
 
 			walk_state->prev_op     = op;
 			walk_state->next_op     = next;
-			walk_state->next_op_info = NEXT_OP_DOWNWARD;
+			walk_state->next_op_info = ACPI_NEXT_OP_DOWNWARD;
 
 			/* Continue downward */
 
@@ -127,7 +141,6 @@
 		 * the tree
 		 */
 	}
-
 	else {
 		/*
 		 * We are resuming a walk, and we were (are) going upward in the tree.
@@ -136,7 +149,6 @@
 		parent = op;
 	}
 
-
 	/*
 	 * Look for a sibling of the current Op's parent
 	 * Continue moving up the tree until we find a node that has not been
@@ -145,12 +157,12 @@
 	while (parent) {
 		/* We are moving up the tree, therefore this parent Op is complete */
 
-		grand_parent = parent->parent;
-		next        = parent->next;
+		grand_parent = parent->common.parent;
+		next        = parent->common.next;
 
 		walk_state->op    = parent;
-		walk_state->op_info = acpi_ps_get_opcode_info (parent->opcode);
-		walk_state->opcode = parent->opcode;
+		walk_state->op_info = acpi_ps_get_opcode_info (parent->common.aml_opcode);
+		walk_state->opcode = parent->common.aml_opcode;
 
 		status = ascending_callback (walk_state);
 
@@ -175,7 +187,7 @@
 
 			walk_state->prev_op     = parent;
 			walk_state->next_op     = next;
-			walk_state->next_op_info = NEXT_OP_DOWNWARD;
+			walk_state->next_op_info = ACPI_NEXT_OP_DOWNWARD;
 
 			return_ACPI_STATUS (status);
 		}
@@ -188,9 +200,10 @@
 	}
 
 
-	/* Got all the way to the top of the tree, we must be done! */
-	/* However, the code should have terminated in the loop above */
-
+	/*
+	 * Got all the way to the top of the tree, we must be done!
+	 * However, the code should have terminated in the loop above
+	 */
 	walk_state->next_op     = NULL;
 
 	return_ACPI_STATUS (AE_OK);
@@ -199,22 +212,22 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_delete_completed_op
+ * FUNCTION:    acpi_ps_delete_completed_op
  *
  * PARAMETERS:  State           - Walk state
  *              Op              - Completed op
  *
  * RETURN:      AE_OK
  *
- * DESCRIPTION: Callback function for Acpi_ps_get_next_walk_op(). Used during
- *              Acpi_ps_delete_parse tree to delete Op objects when all sub-objects
+ * DESCRIPTION: Callback function for acpi_ps_get_next_walk_op(). Used during
+ *              acpi_ps_delete_parse tree to delete Op objects when all sub-objects
  *              have been visited (and deleted.)
  *
  ******************************************************************************/
 
-static acpi_status
+acpi_status
 acpi_ps_delete_completed_op (
-	acpi_walk_state         *walk_state)
+	struct acpi_walk_state          *walk_state)
 {
 
 	acpi_ps_free_op (walk_state->op);
@@ -224,9 +237,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ps_delete_parse_tree
+ * FUNCTION:    acpi_ps_delete_parse_tree
  *
- * PARAMETERS:  Subtree_root        - Root of tree (or subtree) to delete
+ * PARAMETERS:  subtree_root        - Root of tree (or subtree) to delete
  *
  * RETURN:      None
  *
@@ -236,13 +249,14 @@
 
 void
 acpi_ps_delete_parse_tree (
-	acpi_parse_object       *subtree_root)
+	union acpi_parse_object         *subtree_root)
 {
-	acpi_walk_state         *walk_state;
-	acpi_walk_list          walk_list;
+	struct acpi_walk_state          *walk_state;
+	struct acpi_thread_state        *thread;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE_PTR ("Ps_delete_parse_tree", subtree_root);
+	ACPI_FUNCTION_TRACE_PTR ("ps_delete_parse_tree", subtree_root);
 
 
 	if (!subtree_root) {
@@ -251,11 +265,12 @@
 
 	/* Create and initialize a new walk list */
 
-	walk_list.walk_state = NULL;
-	walk_list.acquired_mutex_list.prev = NULL;
-	walk_list.acquired_mutex_list.next = NULL;
+	thread = acpi_ut_create_thread_state ();
+	if (!thread) {
+		return_VOID;
+	}
 
-	walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT, NULL, NULL, &walk_list);
+	walk_state = acpi_ds_create_walk_state (0, NULL, NULL, thread);
 	if (!walk_state) {
 		return_VOID;
 	}
@@ -264,25 +279,26 @@
 	walk_state->descending_callback = NULL;
 	walk_state->ascending_callback  = NULL;
 
-
 	walk_state->origin = subtree_root;
 	walk_state->next_op = subtree_root;
 
-
 	/* Head downward in the tree */
 
-	walk_state->next_op_info = NEXT_OP_DOWNWARD;
+	walk_state->next_op_info = ACPI_NEXT_OP_DOWNWARD;
 
 	/* Visit all nodes in the subtree */
 
 	while (walk_state->next_op) {
-		acpi_ps_get_next_walk_op (walk_state, walk_state->next_op,
+		status = acpi_ps_get_next_walk_op (walk_state, walk_state->next_op,
 				 acpi_ps_delete_completed_op);
+		if (ACPI_FAILURE (status)) {
+			break;
+		}
 	}
 
 	/* We are done with this walk */
 
-	acpi_ex_release_all_mutexes ((acpi_operand_object *) &walk_list.acquired_mutex_list);
+	acpi_ut_delete_generic_state (ACPI_CAST_PTR (union acpi_generic_state, thread));
 	acpi_ds_delete_walk_state (walk_state);
 
 	return_VOID;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/parser/psxface.c linux-2.4.22-pre2/drivers/acpi/parser/psxface.c
--- linux-2.4.21/drivers/acpi/parser/psxface.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/parser/psxface.c	2003-06-26 21:43:31.000000000 +0000
@@ -1,51 +1,68 @@
 /******************************************************************************
  *
  * Module Name: psxface - Parser external interfaces
- *              $Revision: 52 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "acdispat.h"
-#include "acinterp.h"
-#include "amlcode.h"
-#include "acnamesp.h"
+#include <acpi/acpi.h>
+#include <acpi/acparser.h>
+#include <acpi/acdispat.h>
+#include <acpi/acinterp.h>
+#include <acpi/acnamesp.h>
 
 
 #define _COMPONENT          ACPI_PARSER
-	 MODULE_NAME         ("psxface")
+	 ACPI_MODULE_NAME    ("psxface")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_psx_execute
+ * FUNCTION:    acpi_psx_execute
  *
- * PARAMETERS:  Method_node         - A method object containing both the AML
+ * PARAMETERS:  method_node         - A method object containing both the AML
  *                                    address and length.
  *              **Params            - List of parameters to pass to method,
  *                                    terminated by NULL. Params itself may be
  *                                    NULL if no parameters are being passed.
- *              **Return_obj_desc   - Return object from execution of the
+ *              **return_obj_desc   - Return object from execution of the
  *                                    method.
  *
  * RETURN:      Status
@@ -56,18 +73,18 @@
 
 acpi_status
 acpi_psx_execute (
-	acpi_namespace_node     *method_node,
-	acpi_operand_object     **params,
-	acpi_operand_object     **return_obj_desc)
+	struct acpi_namespace_node      *method_node,
+	union acpi_operand_object       **params,
+	union acpi_operand_object       **return_obj_desc)
 {
-	acpi_status             status;
-	acpi_operand_object     *obj_desc;
-	u32                     i;
-	acpi_parse_object       *op;
-	acpi_walk_state         *walk_state;
+	acpi_status                     status;
+	union acpi_operand_object       *obj_desc;
+	u32                             i;
+	union acpi_parse_object         *op;
+	struct acpi_walk_state          *walk_state;
 
 
-	FUNCTION_TRACE ("Psx_execute");
+	ACPI_FUNCTION_TRACE ("psx_execute");
 
 
 	/* Validate the Node and get the attached object */
@@ -102,20 +119,27 @@
 	 * 1) Perform the first pass parse of the method to enter any
 	 * named objects that it creates into the namespace
 	 */
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+	ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
 		"**** Begin Method Parse **** Entry=%p obj=%p\n",
 		method_node, obj_desc));
 
 	/* Create and init a Root Node */
 
-	op = acpi_ps_alloc_op (AML_SCOPE_OP);
+	op = acpi_ps_create_scope_op ();
 	if (!op) {
 		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
 
+	/*
+	 * Get a new owner_id for objects created by this method. Namespace
+	 * objects (such as Operation Regions) can be created during the
+	 * first pass parse.
+	 */
+	obj_desc->method.owning_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD);
+
 	/* Create and initialize a new walk state */
 
-	walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
+	walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id,
 			   NULL, NULL, NULL);
 	if (!walk_state) {
 		return_ACPI_STATUS (AE_NO_MEMORY);
@@ -124,7 +148,7 @@
 	status = acpi_ds_init_aml_walk (walk_state, op, method_node, obj_desc->method.aml_start,
 			  obj_desc->method.aml_length, NULL, NULL, 1);
 	if (ACPI_FAILURE (status)) {
-		/* TBD: delete walk state */
+		acpi_ds_delete_walk_state (walk_state);
 		return_ACPI_STATUS (status);
 	}
 
@@ -133,30 +157,28 @@
 	status = acpi_ps_parse_aml (walk_state);
 	acpi_ps_delete_parse_tree (op);
 
-
 	/*
 	 * 2) Execute the method.  Performs second pass parse simultaneously
 	 */
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+	ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
 		"**** Begin Method Execution **** Entry=%p obj=%p\n",
 		method_node, obj_desc));
 
 	/* Create and init a Root Node */
 
-	op = acpi_ps_alloc_op (AML_SCOPE_OP);
+	op = acpi_ps_create_scope_op ();
 	if (!op) {
 		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
 
 	/* Init new op with the method name and pointer back to the NS node */
 
-	acpi_ps_set_name (op, method_node->name);
-	op->node = method_node;
+	acpi_ps_set_name (op, method_node->name.integer);
+	op->common.node = method_node;
 
 	/* Create and initialize a new walk state */
 
-	walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
-			   NULL, NULL, NULL);
+	walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL);
 	if (!walk_state) {
 		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
@@ -164,7 +186,7 @@
 	status = acpi_ds_init_aml_walk (walk_state, op, method_node, obj_desc->method.aml_start,
 			  obj_desc->method.aml_length, params, return_obj_desc, 3);
 	if (ACPI_FAILURE (status)) {
-		/* TBD: delete walk state */
+		acpi_ds_delete_walk_state (walk_state);
 		return_ACPI_STATUS (status);
 	}
 
@@ -178,30 +200,24 @@
 		/* Take away the extra reference that we gave the parameters above */
 
 		for (i = 0; params[i]; i++) {
-			acpi_ut_update_object_reference (params[i], REF_DECREMENT);
-		}
-	}
-
+			/* Ignore errors, just do them all */
 
-	if (ACPI_FAILURE (status)) {
-		DUMP_PATHNAME (method_node, "Ps_execute: method failed -",
-			ACPI_LV_ERROR, _COMPONENT);
+			(void) acpi_ut_update_object_reference (params[i], REF_DECREMENT);
+		}
 	}
 
-
 	/*
 	 * If the method has returned an object, signal this to the caller with
 	 * a control exception code
 	 */
 	if (*return_obj_desc) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Method returned Obj_desc=%p\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned obj_desc=%p\n",
 			*return_obj_desc));
-		DUMP_STACK_ENTRY (*return_obj_desc);
+		ACPI_DUMP_STACK_ENTRY (*return_obj_desc);
 
 		status = AE_CTRL_RETURN_VALUE;
 	}
 
-
 	return_ACPI_STATUS (status);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/pci_bind.c linux-2.4.22-pre2/drivers/acpi/pci_bind.c
--- linux-2.4.21/drivers/acpi/pci_bind.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/pci_bind.c	2003-06-26 21:43:16.000000000 +0000
@@ -0,0 +1,309 @@
+/*
+ *  pci_bind.c - ACPI PCI Device Binding ($Revision: 3 $)
+ *
+ *  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/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/proc_fs.h>
+#include <linux/spinlock.h>
+#include <linux/pm.h>
+#include <linux/pci.h>
+#include <linux/acpi.h>
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+
+
+#define _COMPONENT		ACPI_PCI_COMPONENT
+ACPI_MODULE_NAME		("pci_bind")
+
+#define PREFIX			"ACPI: "
+
+
+struct acpi_pci_data {
+	struct acpi_pci_id	id;
+	struct pci_bus		*bus;
+	struct pci_dev		*dev;
+};
+
+
+void
+acpi_pci_data_handler (
+	acpi_handle		handle,
+	u32			function,
+	void			*context)
+{
+	ACPI_FUNCTION_TRACE("acpi_pci_data_handler");
+
+	/* TBD: Anything we need to do here? */
+
+	return_VOID;
+}
+
+
+/**
+ * acpi_os_get_pci_id
+ * ------------------
+ * This function is used by the ACPI Interpreter (a.k.a. Core Subsystem)
+ * to resolve PCI information for ACPI-PCI devices defined in the namespace.
+ * This typically occurs when resolving PCI operation region information.
+ */
+acpi_status
+acpi_os_get_pci_id (
+	acpi_handle		handle,
+	struct acpi_pci_id	*id)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	struct acpi_device	*device = NULL;
+	struct acpi_pci_data	*data = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_os_get_pci_id");
+
+	if (!id)
+		return_ACPI_STATUS(AE_BAD_PARAMETER);
+
+	result = acpi_bus_get_device(handle, &device);
+	if (result) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 
+			"Invalid ACPI Bus context for device %s\n",
+			acpi_device_bid(device)));
+		return_ACPI_STATUS(AE_NOT_EXIST);
+	}
+
+	status = acpi_get_data(handle, acpi_pci_data_handler, (void**) &data);
+	if (ACPI_FAILURE(status) || !data || !data->dev) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 
+			"Invalid ACPI-PCI context for device %s\n",
+			acpi_device_bid(device)));
+		return_ACPI_STATUS(status);
+	}
+
+	*id = data->id;
+	
+	/*
+	id->segment = data->id.segment;
+	id->bus = data->id.bus;
+	id->device = data->id.device;
+	id->function = data->id.function;
+	*/
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+		"Device %s has PCI address %02x:%02x:%02x.%02x\n", 
+		acpi_device_bid(device), id->segment, id->bus, 
+		id->device, id->function));
+
+	return_ACPI_STATUS(AE_OK);
+}
+
+	
+int
+acpi_pci_bind (
+	struct acpi_device	*device)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	struct acpi_pci_data	*data = NULL;
+	struct acpi_pci_data	*pdata = NULL;
+	char			pathname[ACPI_PATHNAME_MAX] = {0};
+	struct acpi_buffer	buffer = {ACPI_PATHNAME_MAX, pathname};
+	acpi_handle		handle = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_bind");
+
+	if (!device || !device->parent)
+		return_VALUE(-EINVAL);
+
+	data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
+	if (!data)
+		return_VALUE(-ENOMEM);
+	memset(data, 0, sizeof(struct acpi_pci_data));
+
+	acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n", 
+		pathname));
+
+	/* 
+	 * Segment & Bus
+	 * -------------
+	 * These are obtained via the parent device's ACPI-PCI context.
+	 */
+	status = acpi_get_data(device->parent->handle, acpi_pci_data_handler, 
+		(void**) &pdata);
+	if (ACPI_FAILURE(status) || !pdata || !pdata->bus) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 
+			"Invalid ACPI-PCI context for parent device %s\n",
+			acpi_device_bid(device->parent)));
+		result = -ENODEV;
+		goto end;
+	}
+	data->id.segment = pdata->id.segment;
+	data->id.bus = pdata->bus->number;
+
+	/*
+	 * Device & Function
+	 * -----------------
+	 * These are simply obtained from the device's _ADR method.  Note
+	 * that a value of zero is valid.
+	 */
+	data->id.device = device->pnp.bus_address >> 16;
+	data->id.function = device->pnp.bus_address & 0xFFFF;
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "...to %02x:%02x:%02x.%02x\n",
+		data->id.segment, data->id.bus, data->id.device, 
+		data->id.function));
+
+	/*
+	 * TBD: Support slot devices (e.g. function=0xFFFF).
+	 */
+
+	/* 
+	 * Locate PCI Device
+	 * -----------------
+	 * Locate matching device in PCI namespace.  If it doesn't exist
+	 * this typically means that the device isn't currently inserted
+	 * (e.g. docking station, port replicator, etc.).
+	 */
+	data->dev = pci_find_slot(data->id.bus, PCI_DEVFN(data->id.device, data->id.function));
+	if (!data->dev) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+			"Device %02x:%02x:%02x.%02x not present in PCI namespace\n",
+			data->id.segment, data->id.bus, 
+			data->id.device, data->id.function));
+		result = -ENODEV;
+		goto end;
+	}
+	if (!data->dev->bus) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 
+			"Device %02x:%02x:%02x.%02x has invalid 'bus' field\n",
+			data->id.segment, data->id.bus, 
+			data->id.device, data->id.function));
+		result = -ENODEV;
+		goto end;
+	}
+
+	/*
+	 * PCI Bridge?
+	 * -----------
+	 * If so, set the 'bus' field and install the 'bind' function to 
+	 * facilitate callbacks for all of its children.
+	 */
+	if (data->dev->subordinate) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+			"Device %02x:%02x:%02x.%02x is a PCI bridge\n",
+			data->id.segment, data->id.bus, 
+			data->id.device, data->id.function));
+		data->bus = data->dev->subordinate;
+		device->ops.bind = acpi_pci_bind;
+	}
+
+	/*
+	 * Attach ACPI-PCI Context
+	 * -----------------------
+	 * Thus binding the ACPI and PCI devices.
+	 */
+	status = acpi_attach_data(device->handle, acpi_pci_data_handler, data);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to attach ACPI-PCI context to device %s\n",
+			acpi_device_bid(device)));
+		result = -ENODEV;
+		goto end;
+	}
+
+	/*
+	 * PCI Routing Table
+	 * -----------------
+	 * Evaluate and parse _PRT, if exists.  This code is independent of 
+	 * PCI bridges (above) to allow parsing of _PRT objects within the
+	 * scope of non-bridge devices.  Note that _PRTs within the scope of
+	 * a PCI bridge assume the bridge's subordinate bus number.
+	 *
+	 * TBD: Can _PRTs exist within the scope of non-bridge PCI devices?
+	 */
+	status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
+	if (ACPI_SUCCESS(status)) {
+		if (data->bus)				    /* PCI-PCI bridge */
+			acpi_pci_irq_add_prt(device->handle, data->id.segment, 
+				data->bus->number);
+		else				     /* non-bridge PCI device */
+			acpi_pci_irq_add_prt(device->handle, data->id.segment,
+				data->id.bus);
+	}
+
+end:
+	if (result)
+		kfree(data);
+
+	return_VALUE(result);
+}
+
+
+int 
+acpi_pci_bind_root (
+	struct acpi_device	*device,
+	struct acpi_pci_id	*id,
+	struct pci_bus		*bus) 
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	struct acpi_pci_data	*data = NULL;
+	char			pathname[ACPI_PATHNAME_MAX] = {0};
+	struct acpi_buffer	buffer = {ACPI_PATHNAME_MAX, pathname};
+
+	ACPI_FUNCTION_TRACE("acpi_pci_bind_root");
+
+	if (!device || !id || !bus)
+		return_VALUE(-EINVAL);
+
+	data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
+	if (!data)
+		return_VALUE(-ENOMEM);
+	memset(data, 0, sizeof(struct acpi_pci_data));
+
+	data->id = *id;
+	data->bus = bus;
+	device->ops.bind = acpi_pci_bind;
+
+	acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI root bridge [%s] to "
+		"%02x:%02x\n", pathname, id->segment, id->bus));
+
+	status = acpi_attach_data(device->handle, acpi_pci_data_handler, data);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to attach ACPI-PCI context to device %s\n",
+			pathname));
+		result = -ENODEV;
+		goto end;
+	}
+
+end:
+	if (result != 0)
+		kfree(data);
+
+	return_VALUE(result);
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/pci_irq.c linux-2.4.22-pre2/drivers/acpi/pci_irq.c
--- linux-2.4.21/drivers/acpi/pci_irq.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/pci_irq.c	2003-06-26 21:43:33.000000000 +0000
@@ -0,0 +1,411 @@
+/*
+ *  pci_irq.c - ACPI PCI Interrupt Routing ($Revision: 11 $)
+ *
+ *  Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
+ *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
+ *  Copyright (C) 2002       Dominik Brodowski <devel@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/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/proc_fs.h>
+#include <linux/spinlock.h>
+#include <linux/pm.h>
+#include <linux/pci.h>
+#include <linux/acpi.h>
+#ifdef CONFIG_X86_IO_APIC
+#include <asm/mpspec.h>
+#endif
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+
+
+#define _COMPONENT		ACPI_PCI_COMPONENT
+ACPI_MODULE_NAME		("pci_irq")
+
+#define PREFIX			"PCI: "
+
+struct acpi_prt_list		acpi_prt;
+
+#ifdef CONFIG_X86
+extern void eisa_set_level_irq(unsigned int irq);
+#endif
+
+
+/* --------------------------------------------------------------------------
+                         PCI IRQ Routing Table (PRT) Support
+   -------------------------------------------------------------------------- */
+
+static struct acpi_prt_entry *
+acpi_pci_irq_find_prt_entry (
+	int			segment,
+	int			bus,
+	int			device,
+	int			pin)
+{
+	struct list_head	*node = NULL;
+	struct acpi_prt_entry	*entry = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_irq_find_prt_entry");
+
+	/*
+	 * Parse through all PRT entries looking for a match on the specified
+	 * PCI device's segment, bus, device, and pin (don't care about func).
+	 *
+	 * TBD: Acquire/release lock
+	 */
+	list_for_each(node, &acpi_prt.entries) {
+		entry = list_entry(node, struct acpi_prt_entry, node);
+		if ((segment == entry->id.segment) 
+			&& (bus == entry->id.bus) 
+			&& (device == entry->id.device)
+			&& (pin == entry->pin)) {
+			return_PTR(entry);
+		}
+	}
+
+	return_PTR(NULL);
+}
+
+
+static int
+acpi_pci_irq_add_entry (
+	acpi_handle			handle,
+	int				segment,
+	int				bus,
+	struct acpi_pci_routing_table	*prt)
+{
+	struct acpi_prt_entry	*entry = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_irq_add_entry");
+
+	if (!prt)
+		return_VALUE(-EINVAL);
+
+	entry = kmalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL);
+	if (!entry)
+		return_VALUE(-ENOMEM);
+	memset(entry, 0, sizeof(struct acpi_prt_entry));
+
+	entry->id.segment = segment;
+	entry->id.bus = bus;
+	entry->id.device = (prt->address >> 16) & 0xFFFF;
+	entry->id.function = prt->address & 0xFFFF;
+	entry->pin = prt->pin;
+
+	/*
+	 * Type 1: Dynamic
+	 * ---------------
+	 * The 'source' field specifies the PCI interrupt link device used to
+	 * configure the IRQ assigned to this slot|dev|pin.  The 'source_index'
+	 * indicates which resource descriptor in the resource template (of
+	 * the link device) this interrupt is allocated from.
+	 * 
+	 * NOTE: Don't query the Link Device for IRQ information at this time
+	 *       because Link Device enumeration may not have occurred yet
+	 *       (e.g. exists somewhere 'below' this _PRT entry in the ACPI
+	 *       namespace).
+	 */
+	if (prt->source[0]) {
+		acpi_get_handle(handle, prt->source, &entry->link.handle);
+		entry->link.index = prt->source_index;
+	}
+	/*
+	 * Type 2: Static
+	 * --------------
+	 * The 'source' field is NULL, and the 'source_index' field specifies
+	 * the IRQ value, which is hardwired to specific interrupt inputs on
+	 * the interrupt controller.
+	 */
+	else
+		entry->link.index = prt->source_index;
+
+	ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO,
+		"      %02X:%02X:%02X[%c] -> %s[%d]\n", 
+		entry->id.segment, entry->id.bus, entry->id.device, 
+		('A' + entry->pin), prt->source, entry->link.index));
+
+	/* TBD: Acquire/release lock */
+	list_add_tail(&entry->node, &acpi_prt.entries);
+	acpi_prt.count++;
+
+	return_VALUE(0);
+}
+
+
+int
+acpi_pci_irq_add_prt (
+	acpi_handle		handle,
+	int			segment,
+	int			bus)
+{
+	acpi_status			status = AE_OK;
+	char				pathname[ACPI_PATHNAME_MAX] = {0};
+	struct acpi_buffer		buffer = {0, NULL};
+	struct acpi_pci_routing_table	*prt = NULL;
+	struct acpi_pci_routing_table	*entry = NULL;
+	static int			first_time = 1;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_irq_add_prt");
+
+	if (first_time) {
+		acpi_prt.count = 0;
+		INIT_LIST_HEAD(&acpi_prt.entries);
+		first_time = 0;
+	}
+
+	/* 
+	 * NOTE: We're given a 'handle' to the _PRT object's parent device
+	 *       (either a PCI root bridge or PCI-PCI bridge).
+	 */
+
+	buffer.length = sizeof(pathname);
+	buffer.pointer = pathname;
+	acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
+
+	printk(KERN_DEBUG "ACPI: PCI Interrupt Routing Table [%s._PRT]\n",
+		pathname);
+
+	/* 
+	 * Evaluate this _PRT and add its entries to our global list (acpi_prt).
+	 */
+
+	buffer.length = 0;
+	buffer.pointer = NULL;
+	status = acpi_get_irq_routing_table(handle, &buffer);
+	if (status != AE_BUFFER_OVERFLOW) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRT [%s]\n",
+			acpi_format_exception(status)));
+		return_VALUE(-ENODEV);
+	}
+
+	prt = kmalloc(buffer.length, GFP_KERNEL);
+	if (!prt)
+		return_VALUE(-ENOMEM);
+	memset(prt, 0, buffer.length);
+	buffer.pointer = prt;
+
+	status = acpi_get_irq_routing_table(handle, &buffer);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRT [%s]\n",
+			acpi_format_exception(status)));
+		kfree(buffer.pointer);
+		return_VALUE(-ENODEV);
+	}
+
+	entry = prt;
+
+	while (entry && (entry->length > 0)) {
+		acpi_pci_irq_add_entry(handle, segment, bus, entry);
+		entry = (struct acpi_pci_routing_table *)
+			((unsigned long) entry + entry->length);
+	}
+
+	kfree(prt);
+
+	return_VALUE(0);
+}
+
+
+/* --------------------------------------------------------------------------
+                          PCI Interrupt Routing Support
+   -------------------------------------------------------------------------- */
+
+int
+acpi_pci_irq_lookup (
+	int			segment,
+	int			bus,
+	int			device,
+	int			pin)
+{
+	struct acpi_prt_entry	*entry = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_irq_lookup");
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+		"Searching for PRT entry for %02x:%02x:%02x[%c]\n", 
+		segment, bus, device, ('A' + pin)));
+
+	entry = acpi_pci_irq_find_prt_entry(segment, bus, device, pin); 
+	if (!entry) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "PRT entry not found\n"));
+		return_VALUE(0);
+	}
+
+	if (!entry->irq && entry->link.handle) {
+		entry->irq = acpi_pci_link_get_irq(entry->link.handle, entry->link.index);
+		if (!entry->irq) {
+			ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid IRQ link routing entry\n"));
+			return_VALUE(0);
+		}
+	}
+	else if (!entry->irq) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Invalid static routing entry (IRQ 0)\n"));
+		return_VALUE(0);
+	}
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", entry->irq));
+
+	return_VALUE(entry->irq);
+}
+
+
+static int
+acpi_pci_irq_derive (
+	struct pci_dev		*dev,
+	int			pin)
+{
+	struct pci_dev		*bridge = dev;
+	int			irq = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_irq_derive");
+
+	if (!dev)
+		return_VALUE(-EINVAL);
+
+	/* 
+	 * Attempt to derive an IRQ for this device from a parent bridge's
+	 * PCI interrupt routing entry (a.k.a. the "bridge swizzle").
+	 */
+	while (!irq && bridge->bus->self) {
+		pin = (pin + PCI_SLOT(bridge->devfn)) % 4;
+		bridge = bridge->bus->self;
+		irq = acpi_pci_irq_lookup(0, bridge->bus->number, PCI_SLOT(bridge->devfn), pin);
+	}
+
+	if (!irq) {
+		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Unable to derive IRQ for device %s\n", dev->slot_name));
+		return_VALUE(0);
+	}
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Derived IRQ %d\n", irq));
+
+	return_VALUE(irq);
+}
+
+
+int
+acpi_pci_irq_enable (
+	struct pci_dev		*dev)
+{
+	int			irq = 0;
+	u8			pin = 0;
+	static u16		irq_mask = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_irq_enable");
+
+	if (!dev)
+		return_VALUE(-EINVAL);
+	
+	pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
+	if (!pin) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No interrupt pin configured for device %s\n", dev->slot_name));
+		return_VALUE(0);
+	}
+	pin--;
+
+	if (!dev->bus) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) 'bus' field\n"));
+		return_VALUE(-ENODEV);
+	}
+
+	/* 
+	 * First we check the PCI IRQ routing table (PRT) for an IRQ.  PRT
+	 * values override any BIOS-assigned IRQs set during boot.
+	 */
+ 	irq = acpi_pci_irq_lookup(0, dev->bus->number, PCI_SLOT(dev->devfn), pin);
+ 
+	/*
+	 * If no PRT entry was found, we'll try to derive an IRQ from the
+	 * device's parent bridge.
+	 */
+	if (!irq)
+ 		irq = acpi_pci_irq_derive(dev, pin);
+ 
+	/*
+	 * No IRQ known to the ACPI subsystem - maybe the BIOS / 
+	 * driver reported one, then use it. Exit in any case.
+	 */
+	if (!irq) {
+		printk(KERN_WARNING PREFIX "No IRQ known for interrupt pin %c of device %s", ('A' + pin), dev->slot_name);
+		/* Interrupt Line values above 0xF are forbidden */
+		if (dev->irq && dev->irq >= 0xF) {
+			printk(" - using IRQ %d\n", dev->irq);
+			return_VALUE(dev->irq);
+		}
+		else {
+			printk("\n");
+			return_VALUE(0);
+		}
+ 	}
+
+	dev->irq = irq;
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device %s using IRQ %d\n", dev->slot_name, dev->irq));
+
+	/* 
+	 * Make sure all (legacy) PCI IRQs are set as level-triggered.
+	 */
+#ifdef CONFIG_X86
+	if ((dev->irq < 16) &&  !((1 << dev->irq) & irq_mask)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Setting IRQ %d as level-triggered\n", dev->irq));
+		irq_mask |= (1 << dev->irq);
+		eisa_set_level_irq(dev->irq);
+	}
+#endif
+
+	return_VALUE(dev->irq);
+}
+
+
+int __init
+acpi_pci_irq_init (void)
+{
+	struct pci_dev          *dev = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_irq_init");
+
+	if (!acpi_prt.count) {
+		printk(KERN_WARNING PREFIX "ACPI tables contain no PCI IRQ "
+			"routing entries\n");
+		return_VALUE(-ENODEV);
+	}
+
+	/* Make sure all link devices have a valid IRQ. */
+	acpi_pci_link_check();
+
+#ifdef CONFIG_X86_IO_APIC
+	/* Program IOAPICs using data from PRT entries. */
+	if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC)
+		mp_parse_prt();
+#endif
+#ifdef CONFIG_IOSAPIC
+	if (acpi_irq_model == ACPI_IRQ_MODEL_IOSAPIC)
+		iosapic_parse_prt();
+#endif
+
+	pci_for_each_dev(dev)
+		acpi_pci_irq_enable(dev);
+
+	return_VALUE(0);
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/pci_link.c linux-2.4.22-pre2/drivers/acpi/pci_link.c
--- linux-2.4.21/drivers/acpi/pci_link.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/pci_link.c	2003-06-26 21:43:22.000000000 +0000
@@ -0,0 +1,603 @@
+/*
+ *  pci_link.c - ACPI PCI Interrupt Link Device Driver ($Revision: 35 $)
+ *
+ *  Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
+ *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
+ *  Copyright (C) 2002       Dominik Brodowski <devel@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.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * TBD: 
+ *      1. Support more than one IRQ resource entry per link device (index).
+ *	2. Implement start/stop mechanism and use ACPI Bus Driver facilities
+ *	   for IRQ management (e.g. start()->_SRS).
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/proc_fs.h>
+#include <linux/spinlock.h>
+#include <linux/pm.h>
+#include <linux/pci.h>
+
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+
+
+#define _COMPONENT		ACPI_PCI_COMPONENT
+ACPI_MODULE_NAME		("pci_link")
+
+#define PREFIX			"ACPI: "
+
+
+#define ACPI_PCI_LINK_MAX_POSSIBLE 16
+
+static int acpi_pci_link_add (struct acpi_device *device);
+static int acpi_pci_link_remove (struct acpi_device *device, int type);
+
+static struct acpi_driver acpi_pci_link_driver = {
+	.name =		ACPI_PCI_LINK_DRIVER_NAME,
+	.class =	ACPI_PCI_LINK_CLASS,
+	.ids =		ACPI_PCI_LINK_HID,
+	.ops =		{
+				.add =    acpi_pci_link_add,
+				.remove = acpi_pci_link_remove,
+			},
+};
+
+struct acpi_pci_link_irq {
+	u8			active;			/* Current IRQ */
+	u8			possible_count;
+	u8			possible[ACPI_PCI_LINK_MAX_POSSIBLE];
+};
+
+struct acpi_pci_link {
+	struct list_head	node;
+	struct acpi_device	*device;
+	acpi_handle		handle;
+	struct acpi_pci_link_irq irq;
+};
+
+static struct {
+	int			count;
+	struct list_head	entries;
+}				acpi_link;
+
+
+/* --------------------------------------------------------------------------
+                            PCI Link Device Management
+   -------------------------------------------------------------------------- */
+
+static acpi_status
+acpi_pci_link_check_possible (
+	struct acpi_resource	*resource,
+	void			*context)
+{
+	struct acpi_pci_link	*link = (struct acpi_pci_link *) context;
+	int			i = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible");
+
+	switch (resource->id) {
+	case ACPI_RSTYPE_START_DPF:
+		return 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;
+		}
+		for (i = 0; (i<p->number_of_interrupts && i<ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
+			if (!p->interrupts[i]) {
+				ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid IRQ %d\n", p->interrupts[i]));
+				continue;
+			}
+			link->irq.possible[i] = p->interrupts[i];
+			link->irq.possible_count++;
+		}
+		break;
+	}
+	case ACPI_RSTYPE_EXT_IRQ:
+	{
+		struct acpi_resource_ext_irq *p = &resource->data.extended_irq;
+		if (!p || !p->number_of_interrupts) {
+			ACPI_DEBUG_PRINT((ACPI_DB_WARN, 
+				"Blank IRQ resource\n"));
+			return AE_OK;
+		}
+		for (i = 0; (i<p->number_of_interrupts && i<ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
+			if (!p->interrupts[i]) {
+				ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid IRQ %d\n", p->interrupts[i]));
+				continue;
+			}
+			link->irq.possible[i] = p->interrupts[i];
+			link->irq.possible_count++;
+		}
+		break;
+	}
+	default:
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 
+			"Resource is not an IRQ entry\n"));
+		return AE_OK;
+	}
+
+	return AE_CTRL_TERMINATE;
+}
+
+
+static int
+acpi_pci_link_get_possible (
+	struct acpi_pci_link	*link)
+{
+	acpi_status		status;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_link_get_possible");
+
+	if (!link)
+		return_VALUE(-EINVAL);
+
+	status = acpi_walk_resources(link->handle, METHOD_NAME__PRS,
+			acpi_pci_link_check_possible, link);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRS\n"));
+		return_VALUE(-ENODEV);
+	}
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+		"Found %d possible IRQs\n", link->irq.possible_count));
+
+	return_VALUE(0);
+}
+
+
+static acpi_status
+acpi_pci_link_check_current (
+	struct acpi_resource	*resource,
+	void			*context)
+{
+	int			*irq = (int *) context;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_link_check_current");
+
+	switch (resource->id) {
+	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;
+		}
+		*irq = p->interrupts[0];
+		break;
+	}
+	case ACPI_RSTYPE_EXT_IRQ:
+	{
+		struct acpi_resource_ext_irq *p = &resource->data.extended_irq;
+		if (!p || !p->number_of_interrupts) {
+			ACPI_DEBUG_PRINT((ACPI_DB_WARN,
+				"Blank IRQ resource\n"));
+			return AE_OK;
+		}
+		*irq = p->interrupts[0];
+		break;
+	}
+	default:
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Resource isn't an IRQ\n"));
+		return AE_OK;
+	}
+	return AE_CTRL_TERMINATE;
+}
+
+
+static int
+acpi_pci_link_get_current (
+	struct acpi_pci_link	*link)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	int			irq = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_link_get_current");
+
+	if (!link || !link->handle)
+		return_VALUE(-EINVAL);
+
+	link->irq.active = 0;
+
+	/* Make sure the link is enabled (no use querying if it isn't). */
+	result = acpi_bus_get_status(link->device);
+	if (result) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to read status\n"));
+		goto end;
+	}
+	if (!link->device->status.enabled) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link disabled\n"));
+		return_VALUE(0);
+	}
+
+	/* 
+	 * Query and parse _CRS to get the current IRQ assignment. 
+	 */
+
+	status = acpi_walk_resources(link->handle, METHOD_NAME__CRS,
+			acpi_pci_link_check_current, &irq);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _CRS\n"));
+		result = -ENODEV;
+		goto end;
+	}
+
+	if (!irq) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No IRQ resource found\n"));
+		result = -ENODEV;
+		goto end;
+	}
+
+	/*
+	 * Note that we don't validate that the current IRQ (_CRS) exists
+	 * within the possible IRQs (_PRS): we blindly assume that whatever
+	 * IRQ a boot-enabled Link device is set to is the correct one.
+	 * (Required to support systems such as the Toshiba 5005-S504.)
+	 */
+
+	link->irq.active = irq;
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link at IRQ %d \n", link->irq.active));
+
+end:
+	return_VALUE(result);
+}
+
+
+static int
+acpi_pci_link_set (
+	struct acpi_pci_link	*link,
+	int			irq)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	struct {
+		struct acpi_resource	res;
+		struct acpi_resource	end;
+	}                       resource;
+	struct acpi_buffer	buffer = {sizeof(resource)+1, &resource};
+	int			i = 0;
+	int			valid = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_link_set");
+
+	if (!link || !irq)
+		return_VALUE(-EINVAL);
+
+	/* See if we're already at the target IRQ. */
+	if (irq == link->irq.active)
+		return_VALUE(0);
+
+	/* Make sure the target IRQ in the list of possible IRQs. */
+	for (i=0; i<link->irq.possible_count; i++) {
+		if (irq == link->irq.possible[i])
+			valid = 1;
+	}
+	if (!valid) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Target IRQ %d invalid\n", irq));
+		return_VALUE(-EINVAL);
+	}
+
+	memset(&resource, 0, sizeof(resource));
+
+	/* NOTE: PCI interrupts are always level / active_low / shared. */
+	if (irq <= 15) {
+		resource.res.id = ACPI_RSTYPE_IRQ;
+		resource.res.length = sizeof(struct acpi_resource);
+		resource.res.data.irq.edge_level = ACPI_LEVEL_SENSITIVE;
+		resource.res.data.irq.active_high_low = ACPI_ACTIVE_LOW;
+		resource.res.data.irq.shared_exclusive = ACPI_SHARED;
+		resource.res.data.irq.number_of_interrupts = 1;
+		resource.res.data.irq.interrupts[0] = irq;
+	}
+	else {
+		resource.res.id = ACPI_RSTYPE_EXT_IRQ;
+		resource.res.length = sizeof(struct acpi_resource);
+		resource.res.data.extended_irq.producer_consumer = ACPI_CONSUMER;
+		resource.res.data.extended_irq.edge_level = ACPI_LEVEL_SENSITIVE;
+		resource.res.data.extended_irq.active_high_low = ACPI_ACTIVE_LOW;
+		resource.res.data.extended_irq.shared_exclusive = ACPI_SHARED;
+		resource.res.data.extended_irq.number_of_interrupts = 1;
+		resource.res.data.extended_irq.interrupts[0] = irq;
+		/* ignore resource_source, it's optional */
+	}
+	resource.end.id = ACPI_RSTYPE_END_TAG;
+
+	status = acpi_set_current_resources(link->handle, &buffer);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _SRS\n"));
+		return_VALUE(-ENODEV);
+	}
+
+	/* Make sure the device is enabled. */
+	result = acpi_bus_get_status(link->device);
+	if (result) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to read status\n"));
+		return_VALUE(result);
+	}
+	if (!link->device->status.enabled) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link disabled\n"));
+		return_VALUE(-ENODEV);
+	}
+
+	/* Make sure the active IRQ is the one we requested. */
+	result = acpi_pci_link_get_current(link);
+	if (result) {
+		return_VALUE(result);
+	}
+	if (link->irq.active != irq) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 
+			"Attempt to enable at IRQ %d resulted in IRQ %d\n", 
+			irq, link->irq.active));
+		link->irq.active = 0;
+		return_VALUE(-ENODEV);
+	}
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Set IRQ %d\n", link->irq.active));
+	
+	return_VALUE(0);
+}
+
+
+/* --------------------------------------------------------------------------
+                            PCI Link IRQ Management
+   -------------------------------------------------------------------------- */
+
+#define ACPI_MAX_IRQS		256
+#define ACPI_MAX_ISA_IRQ	16
+
+/*
+ * IRQ penalties are used to promote PCI IRQ balancing.  We set each ISA-
+ * possible IRQ (0-15) with a default penalty relative to its feasibility
+ * for PCI's use:
+ *
+ *   Never use:		0, 1, 2 (timer, keyboard, and cascade)
+ *   Avoid using:	13, 14, and 15 (FP error and IDE)
+ *   Penalize:		3, 4, 6, 7, 12 (known ISA uses)
+ *
+ * Thus we're left with IRQs 5, 9, 10, 11, and everything above 15 (IO[S]APIC)
+ * as 'best bets' for PCI use.
+ */
+
+static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
+	1000000,  1000000,  1000000,    10000, 
+	  10000,        0,    10000,    10000,
+	  10000,        0,        0,        0, 
+	  10000,   100000,   100000,   100000,
+};
+
+
+int
+acpi_pci_link_check (void)
+{
+	struct list_head	*node = NULL;
+	struct acpi_pci_link    *link = NULL;
+	int			i = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_link_check");
+
+	/*
+	 * Pass #1: Update penalties to facilitate IRQ balancing.
+	 */
+	list_for_each(node, &acpi_link.entries) {
+
+		link = list_entry(node, struct acpi_pci_link, node);
+		if (!link) {
+			ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
+			continue;
+		}
+
+		if (link->irq.active)
+			acpi_irq_penalty[link->irq.active] += 100;
+		else if (link->irq.possible_count) {
+			int penalty = 100 / link->irq.possible_count;
+			for (i=0; i<link->irq.possible_count; i++) {
+				if (link->irq.possible[i] < ACPI_MAX_ISA_IRQ)
+					acpi_irq_penalty[link->irq.possible[i]] += penalty;
+			}
+		}
+	}
+
+	/*
+	 * Pass #2: Enable boot-disabled Links at 'best' IRQ.
+	 */
+	list_for_each(node, &acpi_link.entries) {
+		int		irq = 0;
+		int		i = 0;
+
+		link = list_entry(node, struct acpi_pci_link, node);
+		if (!link || !link->irq.possible_count) {
+			ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
+			continue;
+		}
+
+		if (link->irq.active)
+			continue;
+
+		irq = link->irq.possible[0];
+
+		/* 
+		 * Select the best IRQ.  This is done in reverse to promote 
+		 * the use of IRQs 9, 10, 11, and >15.
+		 */
+		for (i=(link->irq.possible_count-1); i>0; i--) {
+			if (acpi_irq_penalty[irq] > acpi_irq_penalty[link->irq.possible[i]])
+				irq = link->irq.possible[i];
+		}
+
+		/* Enable the link device at this IRQ. */
+		acpi_pci_link_set(link, irq);
+
+		acpi_irq_penalty[link->irq.active] += 100;
+
+		printk(PREFIX "%s [%s] enabled at IRQ %d\n", 
+			acpi_device_name(link->device),
+			acpi_device_bid(link->device), link->irq.active);
+	}
+
+	return_VALUE(0);
+}
+
+
+int
+acpi_pci_link_get_irq (
+	acpi_handle		handle,
+	int			index)
+{
+	int                     result = 0;
+	struct acpi_device	*device = NULL;
+	struct acpi_pci_link	*link = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_link_get_irq");
+
+	result = acpi_bus_get_device(handle, &device);
+	if (result) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link device\n"));
+		return_VALUE(0);
+	}
+
+	link = (struct acpi_pci_link *) acpi_driver_data(device);
+	if (!link) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
+		return_VALUE(0);
+	}
+
+	/* 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);
+	}
+
+	if (!link->irq.active) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link disabled\n"));
+		return_VALUE(0);
+	}
+
+	return_VALUE(link->irq.active);
+}
+
+
+/* --------------------------------------------------------------------------
+                                 Driver Interface
+   -------------------------------------------------------------------------- */
+
+static int
+acpi_pci_link_add (
+	struct acpi_device *device)
+{
+	int			result = 0;
+	struct acpi_pci_link	*link = NULL;
+	int			i = 0;
+	int			found = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_link_add");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	link = kmalloc(sizeof(struct acpi_pci_link), GFP_KERNEL);
+	if (!link)
+		return_VALUE(-ENOMEM);
+	memset(link, 0, sizeof(struct acpi_pci_link));
+
+	link->device = device;
+	link->handle = device->handle;
+	sprintf(acpi_device_name(device), "%s", ACPI_PCI_LINK_DEVICE_NAME);
+	sprintf(acpi_device_class(device), "%s", ACPI_PCI_LINK_CLASS);
+	acpi_driver_data(device) = link;
+
+	result = acpi_pci_link_get_possible(link);
+	if (result)
+		goto end;
+
+	acpi_pci_link_get_current(link);
+
+	printk(PREFIX "%s [%s] (IRQs", acpi_device_name(device), acpi_device_bid(device));
+	for (i = 0; i < link->irq.possible_count; i++) {
+		if (link->irq.active == link->irq.possible[i]) {
+			printk(" *%d", link->irq.possible[i]);
+			found = 1;
+		}
+		else
+			printk(" %d", link->irq.possible[i]);
+	}
+	if (!link->irq.active)
+		printk(", disabled");
+	else if (!found)
+		printk(", enabled at IRQ %d", link->irq.active);
+	printk(")\n");
+
+	/* TBD: Acquire/release lock */
+	list_add_tail(&link->node, &acpi_link.entries);
+	acpi_link.count++;
+
+end:
+	if (result)
+		kfree(link);
+
+	return_VALUE(result);
+}
+
+
+static int
+acpi_pci_link_remove (
+	struct acpi_device	*device,
+	int			type)
+{
+	struct acpi_pci_link *link = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_link_remove");
+
+	if (!device || !acpi_driver_data(device))
+		return_VALUE(-EINVAL);
+
+	link = (struct acpi_pci_link *) acpi_driver_data(device);
+
+	/* TBD: Acquire/release lock */
+	list_del(&link->node);
+
+	kfree(link);
+
+	return_VALUE(0);
+}
+
+
+int __init
+acpi_pci_link_init (void)
+{
+	ACPI_FUNCTION_TRACE("acpi_pci_link_init");
+
+	acpi_link.count = 0;
+	INIT_LIST_HEAD(&acpi_link.entries);
+
+	if (acpi_bus_register_driver(&acpi_pci_link_driver) < 0)
+		return_VALUE(-ENODEV);
+
+	return_VALUE(0);
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/pci_root.c linux-2.4.22-pre2/drivers/acpi/pci_root.c
--- linux-2.4.21/drivers/acpi/pci_root.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/pci_root.c	2003-06-26 21:43:10.000000000 +0000
@@ -0,0 +1,394 @@
+/*
+ *  pci_root.c - ACPI PCI Root Bridge Driver ($Revision: 41 $)
+ *
+ *  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/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/proc_fs.h>
+#include <linux/spinlock.h>
+#include <linux/pm.h>
+#include <linux/pci.h>
+#include <linux/acpi.h>
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+
+
+#define _COMPONENT		ACPI_PCI_COMPONENT
+ACPI_MODULE_NAME		("pci_root")
+
+extern struct pci_ops *pci_root_ops;
+
+#define PREFIX			"ACPI: "
+
+static int acpi_pci_root_add (struct acpi_device *device);
+static int acpi_pci_root_remove (struct acpi_device *device, int type);
+
+static struct acpi_driver acpi_pci_root_driver = {
+	.name =		ACPI_PCI_ROOT_DRIVER_NAME,
+	.class =	ACPI_PCI_ROOT_CLASS,
+	.ids =		ACPI_PCI_ROOT_HID,
+	.ops =		{
+				.add =    acpi_pci_root_add,
+				.remove = acpi_pci_root_remove,
+			},
+};
+
+struct acpi_pci_root {
+	struct list_head	node;
+	acpi_handle		handle;
+	struct acpi_pci_id	id;
+	struct pci_bus		*bus;
+	u64			mem_tra;
+	u64			io_tra;
+};
+
+struct list_head		acpi_pci_roots;
+
+static struct acpi_pci_driver *sub_driver;
+
+int acpi_pci_register_driver(struct acpi_pci_driver *driver)
+{
+	int n = 0;
+	struct list_head *entry;
+
+	struct acpi_pci_driver **pptr = &sub_driver;
+	while (*pptr)
+		pptr = &(*pptr)->next;
+	*pptr = driver;
+
+	if (!driver->add)
+		return 0;
+
+	list_for_each(entry, &acpi_pci_roots) {
+		struct acpi_pci_root *root;
+		root = list_entry(entry, struct acpi_pci_root, node);
+		driver->add(root->handle);
+		n++;
+	}
+
+	return n;
+}
+
+void acpi_pci_unregister_driver(struct acpi_pci_driver *driver)
+{
+	struct list_head *entry;
+
+	struct acpi_pci_driver **pptr = &sub_driver;
+	while (*pptr) {
+		if (*pptr != driver)
+			continue;
+		*pptr = (*pptr)->next;
+		break;
+	}
+
+	if (!driver->remove)
+		return;
+
+	list_for_each(entry, &acpi_pci_roots) {
+		struct acpi_pci_root *root;
+		root = list_entry(entry, struct acpi_pci_root, node);
+		driver->remove(root->handle);
+	}
+}
+
+void
+acpi_pci_get_translations (
+	struct acpi_pci_id	*id,
+	u64			*mem_tra,
+	u64			*io_tra)
+{
+	struct list_head	*node = NULL;
+	struct acpi_pci_root	*entry;
+
+	/* TBD: Locking */
+	list_for_each(node, &acpi_pci_roots) {
+		entry = list_entry(node, struct acpi_pci_root, node);
+		if ((id->segment == entry->id.segment)
+			&& (id->bus == entry->id.bus)) {
+			*mem_tra = entry->mem_tra;
+			*io_tra = entry->io_tra;
+			return;
+		}
+	}
+
+	*mem_tra = 0;
+	*io_tra = 0;
+}
+
+
+static u64
+acpi_pci_root_bus_tra (
+       struct acpi_resource	*resource,
+       int			type)
+{
+	struct acpi_resource_address16 *address16;
+	struct acpi_resource_address32 *address32;
+	struct acpi_resource_address64 *address64;
+
+	while (1) {
+		switch (resource->id) {
+		case ACPI_RSTYPE_END_TAG:
+			return 0;
+
+		case ACPI_RSTYPE_ADDRESS16:
+			address16 = (struct acpi_resource_address16 *) &resource->data;
+			if (type == address16->resource_type) {
+				return address16->address_translation_offset;
+			}
+			break;
+
+		case ACPI_RSTYPE_ADDRESS32:
+			address32 = (struct acpi_resource_address32 *) &resource->data;
+			if (type == address32->resource_type) {
+				return address32->address_translation_offset;
+			}
+			break;
+
+		case ACPI_RSTYPE_ADDRESS64:
+			address64 = (struct acpi_resource_address64 *) &resource->data;
+			if (type == address64->resource_type) {
+				return address64->address_translation_offset;
+			}
+			break;
+		}
+		resource = ACPI_PTR_ADD (struct acpi_resource,
+				resource, resource->length);
+	}
+
+	return 0;
+}
+
+
+static int
+acpi_pci_evaluate_crs (
+	struct acpi_pci_root	*root)
+{
+	acpi_status		status;
+	struct acpi_buffer	buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+
+	ACPI_FUNCTION_TRACE("acpi_pci_evaluate_crs");
+
+	status = acpi_get_current_resources (root->handle, &buffer);
+	if (ACPI_FAILURE(status))
+		return_VALUE(-ENODEV);
+
+	root->io_tra = acpi_pci_root_bus_tra ((struct acpi_resource *)
+			buffer.pointer, ACPI_IO_RANGE);
+	root->mem_tra = acpi_pci_root_bus_tra ((struct acpi_resource *)
+			buffer.pointer, ACPI_MEMORY_RANGE);
+
+	acpi_os_free(buffer.pointer);
+	return_VALUE(0);
+}
+
+
+static int
+acpi_pci_root_add (
+	struct acpi_device	*device)
+{
+	int			result = 0;
+	struct acpi_pci_root	*root = NULL;
+	acpi_status		status = AE_OK;
+	unsigned long		value = 0;
+	acpi_handle		handle = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_root_add");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	root = kmalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
+	if (!root)
+		return_VALUE(-ENOMEM);
+	memset(root, 0, sizeof(struct acpi_pci_root));
+
+	root->handle = device->handle;
+	sprintf(acpi_device_name(device), "%s", ACPI_PCI_ROOT_DEVICE_NAME);
+	sprintf(acpi_device_class(device), "%s", ACPI_PCI_ROOT_CLASS);
+	acpi_driver_data(device) = root;
+
+	/*
+	 * TBD: Doesn't the bus driver automatically set this?
+	 */
+	device->ops.bind = acpi_pci_bind;
+
+	/* 
+	 * Segment
+	 * -------
+	 * Obtained via _SEG, if exists, otherwise assumed to be zero (0).
+	 */
+	status = acpi_evaluate_integer(root->handle, METHOD_NAME__SEG, NULL, 
+		&value);
+	switch (status) {
+	case AE_OK:
+		root->id.segment = (u16) value;
+		printk("_SEG exists! Unsupported. Abort.\n");
+		BUG();
+		break;
+	case AE_NOT_FOUND:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+			"Assuming segment 0 (no _SEG)\n"));
+		root->id.segment = 0;
+		break;
+	default:
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _SEG\n"));
+		result = -ENODEV;
+		goto end;
+	}
+
+	/* 
+	 * Bus
+	 * ---
+	 * Obtained via _BBN, if exists, otherwise assumed to be zero (0).
+	 */
+	status = acpi_evaluate_integer(root->handle, METHOD_NAME__BBN, NULL, 
+		&value);
+	switch (status) {
+	case AE_OK:
+		root->id.bus = (u16) value;
+		break;
+	case AE_NOT_FOUND:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Assuming bus 0 (no _BBN)\n"));
+		root->id.bus = 0;
+		break;
+	default:
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BBN\n"));
+		result = -ENODEV;
+		goto end;
+	}
+
+	/*
+	 * Device & Function
+	 * -----------------
+	 * Obtained from _ADR (which has already been evaluated for us).
+	 */
+	root->id.device = device->pnp.bus_address >> 16;
+	root->id.function = device->pnp.bus_address & 0xFFFF;
+
+	/*
+	 * Evaluate _CRS to get root bridge resources
+	 * TBD: Need PCI interface for enumeration/configuration of roots.
+	 */
+ 	acpi_pci_evaluate_crs(root);
+
+ 	/* TBD: Locking */
+ 	list_add_tail(&root->node, &acpi_pci_roots);
+
+	printk(KERN_INFO PREFIX "%s [%s] (%02x:%02x)\n", 
+		acpi_device_name(device), acpi_device_bid(device),
+		root->id.segment, root->id.bus);
+
+	/*
+	 * Scan the Root Bridge
+	 * --------------------
+	 * Must do this prior to any attempt to bind the root device, as the
+	 * PCI namespace does not get created until this call is made (and 
+	 * thus the root bridge's pci_dev does not exist).
+	 */
+	root->bus = pcibios_scan_root(root->id.bus);
+	if (!root->bus) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 
+			"Bus %02x:%02x not present in PCI namespace\n", 
+			root->id.segment, root->id.bus));
+		result = -ENODEV;
+		goto end;
+	}
+
+	/*
+	 * Attach ACPI-PCI Context
+	 * -----------------------
+	 * Thus binding the ACPI and PCI devices.
+	 */
+	result = acpi_pci_bind_root(device, &root->id, root->bus);
+	if (result)
+		goto end;
+
+	/*
+	 * PCI Routing Table
+	 * -----------------
+	 * Evaluate and parse _PRT, if exists.
+	 */
+	status = acpi_get_handle(root->handle, METHOD_NAME__PRT, &handle);
+	if (ACPI_SUCCESS(status))
+		result = acpi_pci_irq_add_prt(root->handle, root->id.segment,
+			root->id.bus);
+
+end:
+	if (result)
+		kfree(root);
+
+	return_VALUE(result);
+}
+
+
+static int
+acpi_pci_root_remove (
+	struct acpi_device	*device,
+	int			type)
+{
+	struct acpi_pci_root	*root = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_root_remove");
+
+	if (!device || !acpi_driver_data(device))
+		return_VALUE(-EINVAL);
+
+	root = (struct acpi_pci_root *) acpi_driver_data(device);
+
+	kfree(root);
+
+	return_VALUE(0);
+}
+
+
+int __init
+acpi_pci_root_init (void)
+{
+	ACPI_FUNCTION_TRACE("acpi_pci_root_init");
+
+	/* DEBUG:
+	acpi_dbg_layer = ACPI_PCI_COMPONENT;
+	acpi_dbg_level = 0xFFFFFFFF;
+	 */
+
+ 	INIT_LIST_HEAD(&acpi_pci_roots);
+
+	if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0)
+		return_VALUE(-ENODEV);
+
+	return_VALUE(0);
+}
+
+
+void __exit
+acpi_pci_root_exit (void)
+{
+	ACPI_FUNCTION_TRACE("acpi_pci_root_exit");
+
+	acpi_bus_unregister_driver(&acpi_pci_root_driver);
+
+	return_VOID;
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/power.c linux-2.4.22-pre2/drivers/acpi/power.c
--- linux-2.4.21/drivers/acpi/power.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/power.c	2003-06-26 21:43:11.000000000 +0000
@@ -0,0 +1,604 @@
+/*
+ *  acpi_power.c - ACPI Bus Power Management ($Revision: 38 $)
+ *
+ *  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/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/compatmac.h>
+#include <linux/proc_fs.h>
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+
+
+#define _COMPONENT		ACPI_POWER_COMPONENT
+ACPI_MODULE_NAME		("acpi_power")
+
+#define PREFIX			"ACPI: "
+
+
+int acpi_power_add (struct acpi_device *device);
+int acpi_power_remove (struct acpi_device *device, int type);
+
+static struct acpi_driver acpi_power_driver = {
+	.name =		ACPI_POWER_DRIVER_NAME,
+	.class =	ACPI_POWER_CLASS,
+	.ids =		ACPI_POWER_HID,
+	.ops =		{
+				.add =		acpi_power_add,
+				.remove =	acpi_power_remove,
+			},
+};
+
+struct acpi_power_resource
+{
+	acpi_handle		handle;
+	acpi_bus_id		name;
+	u32			system_level;
+	u32			order;
+	int			state;
+	int			references;
+};
+
+static struct list_head		acpi_power_resource_list;
+
+
+/* --------------------------------------------------------------------------
+                             Power Resource Management
+   -------------------------------------------------------------------------- */
+
+static int
+acpi_power_get_context (
+	acpi_handle		handle,
+	struct acpi_power_resource **resource)
+{
+	int			result = 0;
+	struct acpi_device	*device = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_power_get_context");
+
+	if (!resource)
+		return_VALUE(-ENODEV);
+
+	result = acpi_bus_get_device(handle, &device);
+	if (result) {
+		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error getting context [%p]\n",
+			handle));
+		return_VALUE(result);
+	}
+
+	*resource = (struct acpi_power_resource *) acpi_driver_data(device);
+	if (!resource)
+		return_VALUE(-ENODEV);
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_power_get_state (
+	struct acpi_power_resource *resource)
+{
+	acpi_status		status = AE_OK;
+	unsigned long		sta = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_power_get_state");
+
+	if (!resource)
+		return_VALUE(-EINVAL);
+
+	status = acpi_evaluate_integer(resource->handle, "_STA", NULL, &sta);
+	if (ACPI_FAILURE(status))
+		return_VALUE(-ENODEV);
+
+	if (sta & 0x01)
+		resource->state = ACPI_POWER_RESOURCE_STATE_ON;
+	else
+		resource->state = ACPI_POWER_RESOURCE_STATE_OFF;
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n",
+		resource->name, resource->state?"on":"off"));
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_power_get_list_state (
+	struct acpi_handle_list	*list,
+	int			*state)
+{
+	int			result = 0;
+	struct acpi_power_resource *resource = NULL;
+	u32			i = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_power_get_list_state");
+
+	if (!list || !state)
+		return_VALUE(-EINVAL);
+
+	/* The state of the list is 'on' IFF all resources are 'on'. */
+
+	for (i=0; i<list->count; i++) {
+		result = acpi_power_get_context(list->handles[i], &resource);
+		if (result)
+			return_VALUE(result);
+		result = acpi_power_get_state(resource);
+		if (result)
+			return_VALUE(result);
+
+		*state = resource->state;
+
+		if (*state != ACPI_POWER_RESOURCE_STATE_ON)
+			break;
+	}
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource list is %s\n",
+		*state?"on":"off"));
+
+	return_VALUE(result);
+}
+
+
+static int
+acpi_power_on (
+	acpi_handle		handle)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	struct acpi_device	*device = NULL;
+	struct acpi_power_resource *resource = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_power_on");
+
+	result = acpi_power_get_context(handle, &resource);
+	if (result)
+		return_VALUE(result);
+
+	resource->references++;
+
+	if ((resource->references > 1) 
+		|| (resource->state == ACPI_POWER_RESOURCE_STATE_ON)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already on\n",
+			resource->name));
+		return_VALUE(0);
+	}
+
+	status = acpi_evaluate_object(resource->handle, "_ON", NULL, NULL);
+	if (ACPI_FAILURE(status))
+		return_VALUE(-ENODEV);
+
+	result = acpi_power_get_state(resource);
+	if (result)
+		return_VALUE(result);
+	if (resource->state != ACPI_POWER_RESOURCE_STATE_ON)
+		return_VALUE(-ENOEXEC);
+
+	/* Update the power resource's _device_ power state */
+	result = acpi_bus_get_device(resource->handle, &device);
+	if (result)
+		return_VALUE(result);
+	device->power.state = ACPI_STATE_D0;
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned on\n",
+		resource->name));
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_power_off_device (
+	acpi_handle		handle)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	struct acpi_device	*device = NULL;
+	struct acpi_power_resource *resource = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_power_off_device");
+
+	result = acpi_power_get_context(handle, &resource);
+	if (result)
+		return_VALUE(result);
+
+	if (resource->references)
+		resource->references--;
+
+	if (resource->references) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+			"Resource [%s] is still in use, dereferencing\n",
+			device->pnp.bus_id));
+		return_VALUE(0);
+	}
+
+	if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n",
+			device->pnp.bus_id));
+		return_VALUE(0);
+	}
+
+	status = acpi_evaluate_object(resource->handle, "_OFF", NULL, NULL);
+	if (ACPI_FAILURE(status))
+		return_VALUE(-ENODEV);
+
+	result = acpi_power_get_state(resource);
+	if (result)
+		return_VALUE(result);
+	if (resource->state != ACPI_POWER_RESOURCE_STATE_OFF)
+		return_VALUE(-ENOEXEC);
+
+	/* Update the power resource's _device_ power state */
+	result = acpi_bus_get_device(resource->handle, &device);
+	if (result)
+		return_VALUE(result);
+	device->power.state = ACPI_STATE_D3;
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n",
+		resource->name));
+
+	return_VALUE(0);
+}
+
+
+/* --------------------------------------------------------------------------
+                             Device Power Management
+   -------------------------------------------------------------------------- */
+
+int
+acpi_power_get_inferred_state (
+	struct acpi_device	*device)
+{
+	int			result = 0;
+	struct acpi_handle_list	*list = NULL;
+	int			list_state = 0;
+	int			i = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_power_get_inferred_state");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	device->power.state = ACPI_STATE_UNKNOWN;
+
+	/*
+	 * We know a device's inferred power state when all the resources
+	 * required for a given D-state are 'on'.
+	 */
+	for (i=ACPI_STATE_D0; i<ACPI_STATE_D3; i++) {
+		list = &device->power.states[i].resources;
+		if (list->count < 1)
+			continue;
+
+		result = acpi_power_get_list_state(list, &list_state);
+		if (result)
+			return_VALUE(result);
+
+		if (list_state == ACPI_POWER_RESOURCE_STATE_ON) {
+			device->power.state = i;
+			return_VALUE(0);
+		}
+	}
+
+	device->power.state = ACPI_STATE_D3;
+
+	return_VALUE(0);
+}
+
+
+int
+acpi_power_transition (
+	struct acpi_device	*device,
+	int			state)
+{
+	int			result = 0;
+	struct acpi_handle_list	*cl = NULL;	/* Current Resources */
+	struct acpi_handle_list	*tl = NULL;	/* Target Resources */
+	int			i = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_power_transition");
+
+	if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3))
+		return_VALUE(-EINVAL);
+
+	cl = &device->power.states[device->power.state].resources;
+	tl = &device->power.states[state].resources;
+
+	device->power.state = ACPI_STATE_UNKNOWN;
+
+	if (!cl->count && !tl->count) {
+		result = -ENODEV;
+		goto end;
+	}
+
+	/* TBD: Resources must be ordered. */
+
+	/*
+	 * First we reference all power resources required in the target list
+	 * (e.g. so the device doesn't loose power while transitioning).
+	 */
+	for (i=0; i<tl->count; i++) {
+		result = acpi_power_on(tl->handles[i]);
+		if (result)
+			goto end;
+	}
+
+	device->power.state = state;
+
+	/*
+	 * Then we dereference all power resources used in the current list.
+	 */
+	for (i=0; i<cl->count; i++) {
+		result = acpi_power_off_device(cl->handles[i]);
+		if (result)
+			goto end;
+	}
+
+end:
+	if (result)
+		ACPI_DEBUG_PRINT((ACPI_DB_WARN, 
+			"Error transitioning device [%s] to D%d\n",
+			device->pnp.bus_id, state));
+
+	return_VALUE(result);
+}
+
+
+/* --------------------------------------------------------------------------
+                              FS Interface (/proc)
+   -------------------------------------------------------------------------- */
+
+struct proc_dir_entry		*acpi_power_dir = NULL;
+
+
+static int
+acpi_power_read_status (
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	struct acpi_power_resource *resource = NULL;
+	char			*p = page;
+	int			len;
+
+	ACPI_FUNCTION_TRACE("acpi_power_read_status");
+
+	if (!data || (off != 0))
+		goto end;
+
+	resource = (struct acpi_power_resource *) data;
+
+	p += sprintf(p, "state:                   ");
+	switch (resource->state) {
+	case ACPI_POWER_RESOURCE_STATE_ON:
+		p += sprintf(p, "on\n");
+		break;
+	case ACPI_POWER_RESOURCE_STATE_OFF:
+		p += sprintf(p, "off\n");
+		break;
+	default:
+		p += sprintf(p, "unknown\n");
+		break;
+	}
+
+	p += sprintf(p, "system level:            S%d\n",
+		resource->system_level);
+	p += sprintf(p, "order:                   %d\n",
+		resource->order);
+	p += sprintf(p, "reference count:         %d\n",
+		resource->references);
+
+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);
+}
+
+
+static int
+acpi_power_add_fs (
+	struct acpi_device	*device)
+{
+	struct proc_dir_entry	*entry = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_power_add_fs");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	if (!acpi_device_dir(device)) {
+		acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
+			acpi_power_dir);
+		if (!acpi_device_dir(device))
+			return_VALUE(-ENODEV);
+	}
+
+	/* 'status' [R] */
+	entry = create_proc_entry(ACPI_POWER_FILE_STATUS,
+		S_IRUGO, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_POWER_FILE_STATUS));
+	else {
+		entry->read_proc = acpi_power_read_status;
+		entry->data = acpi_driver_data(device);
+	}
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_power_remove_fs (
+	struct acpi_device	*device)
+{
+	ACPI_FUNCTION_TRACE("acpi_power_remove_fs");
+
+	if (acpi_device_dir(device)) {
+		remove_proc_entry(acpi_device_bid(device), acpi_power_dir);
+		acpi_device_dir(device) = NULL;
+	}
+
+	return_VALUE(0);
+}
+
+
+/* --------------------------------------------------------------------------
+                                Driver Interface
+   -------------------------------------------------------------------------- */
+
+int
+acpi_power_add (
+	struct acpi_device	*device)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	struct acpi_power_resource *resource = NULL;
+	union acpi_object	acpi_object;
+	struct acpi_buffer	buffer = {sizeof(acpi_object), &acpi_object};
+
+	ACPI_FUNCTION_TRACE("acpi_power_add");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	resource = kmalloc(sizeof(struct acpi_power_resource), GFP_KERNEL);
+	if (!resource)
+		return_VALUE(-ENOMEM);
+	memset(resource, 0, sizeof(struct acpi_power_resource));
+
+	resource->handle = device->handle;
+	sprintf(resource->name, "%s", device->pnp.bus_id);
+	sprintf(acpi_device_name(device), "%s", ACPI_POWER_DEVICE_NAME);
+	sprintf(acpi_device_class(device), "%s", ACPI_POWER_CLASS);
+	acpi_driver_data(device) = resource;
+
+	/* Evalute the object to get the system level and resource order. */
+	status = acpi_evaluate_object(resource->handle, NULL, NULL, &buffer);
+	if (ACPI_FAILURE(status)) {
+		result = -ENODEV;
+		goto end;
+	}
+	resource->system_level = acpi_object.power_resource.system_level;
+	resource->order = acpi_object.power_resource.resource_order;
+
+	result = acpi_power_get_state(resource);
+	if (result)
+		goto end;
+
+	switch (resource->state) {
+	case ACPI_POWER_RESOURCE_STATE_ON:
+		device->power.state = ACPI_STATE_D0;
+		break;
+	case ACPI_POWER_RESOURCE_STATE_OFF:
+		device->power.state = ACPI_STATE_D3;
+		break;
+	default:
+		device->power.state = ACPI_STATE_UNKNOWN;
+		break;
+	}
+
+	result = acpi_power_add_fs(device);
+	if (result)
+		goto end;
+	
+	printk(KERN_INFO PREFIX "%s [%s] (%s)\n", acpi_device_name(device),
+		acpi_device_bid(device), resource->state?"on":"off");
+
+end:
+	if (result)
+		kfree(resource);
+	
+	return_VALUE(result);
+}
+
+
+int
+acpi_power_remove (
+	struct acpi_device	*device,
+	int			type)
+{
+	struct acpi_power_resource *resource = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_power_remove");
+
+	if (!device || !acpi_driver_data(device))
+		return_VALUE(-EINVAL);
+
+	resource = (struct acpi_power_resource *) acpi_driver_data(device);
+
+	acpi_power_remove_fs(device);
+
+	kfree(resource);
+
+	return_VALUE(0);
+}
+
+
+int __init
+acpi_power_init (void)
+{
+	int			result = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_power_init");
+
+	INIT_LIST_HEAD(&acpi_power_resource_list);
+
+	acpi_power_dir = proc_mkdir(ACPI_POWER_CLASS, acpi_root_dir);
+	if (!acpi_power_dir)
+		return_VALUE(-ENODEV);
+
+	result = acpi_bus_register_driver(&acpi_power_driver);
+	if (result < 0) {
+		remove_proc_entry(ACPI_POWER_CLASS, acpi_root_dir);
+		return_VALUE(-ENODEV);
+	}
+
+	return_VALUE(0);
+}
+
+
+void __exit
+acpi_power_exit (void)
+{
+	ACPI_FUNCTION_TRACE("acpi_power_exit");
+
+	/* TBD: Empty acpi_power_resource_list */
+
+	acpi_bus_unregister_driver(&acpi_power_driver);
+
+	remove_proc_entry(ACPI_POWER_CLASS, acpi_root_dir);
+
+	return_VOID;
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/processor.c linux-2.4.22-pre2/drivers/acpi/processor.c
--- linux-2.4.21/drivers/acpi/processor.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/processor.c	2003-06-26 21:43:22.000000000 +0000
@@ -0,0 +1,2329 @@
+/*
+ * acpi_processor.c - ACPI Processor Driver ($Revision: 69 $)
+ *
+ *  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.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *  TBD:
+ *	1. Make # power/performance states dynamic.
+ *	2. Support duty_cycle values that span bit 4.
+ *	3. Optimize by having scheduler determine business instead of
+ *	   having us try to calculate it here.
+ *	4. Need C1 timing -- must modify kernel (IRQ handler) to get this.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/pm.h>
+#include <asm/io.h>
+#include <asm/system.h>
+#include <asm/delay.h>
+#include <linux/compatmac.h>
+#include <linux/proc_fs.h>
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+
+
+#define _COMPONENT		ACPI_PROCESSOR_COMPONENT
+ACPI_MODULE_NAME		("acpi_processor")
+
+MODULE_AUTHOR("Paul Diefenbaugh");
+MODULE_DESCRIPTION(ACPI_PROCESSOR_DRIVER_NAME);
+MODULE_LICENSE("GPL");
+
+#define PREFIX				"ACPI: "
+
+#define US_TO_PM_TIMER_TICKS(t)		((t * (PM_TIMER_FREQUENCY/1000)) / 1000)
+#define C2_OVERHEAD			4	/* 1us (3.579 ticks per us) */
+#define C3_OVERHEAD			4	/* 1us (3.579 ticks per us) */
+
+#define ACPI_PROCESSOR_BUSY_METRIC	10
+
+#define ACPI_PROCESSOR_MAX_POWER	ACPI_C_STATE_COUNT
+#define ACPI_PROCESSOR_MAX_C2_LATENCY	100
+#define ACPI_PROCESSOR_MAX_C3_LATENCY	1000
+
+#define ACPI_PROCESSOR_MAX_PERFORMANCE	8
+
+#define ACPI_PROCESSOR_MAX_THROTTLING	16
+#define ACPI_PROCESSOR_MAX_THROTTLE	250	/* 25% */
+#define ACPI_PROCESSOR_MAX_DUTY_WIDTH	4
+
+const u32 POWER_OF_2[] = {1,2,4,8,16,32,64};
+
+#define ACPI_PROCESSOR_LIMIT_USER	0
+#define ACPI_PROCESSOR_LIMIT_THERMAL	1
+
+static int acpi_processor_add (struct acpi_device *device);
+static int acpi_processor_remove (struct acpi_device *device, int type);
+
+static struct acpi_driver acpi_processor_driver = {
+	.name =		ACPI_PROCESSOR_DRIVER_NAME,
+	.class =	ACPI_PROCESSOR_CLASS,
+	.ids =		ACPI_PROCESSOR_HID,
+	.ops =		{
+				.add =		acpi_processor_add,
+				.remove =	acpi_processor_remove,
+			},
+};
+
+/* Power Management */
+
+struct acpi_processor_cx_policy {
+	u32			count;
+	int			state;
+	struct {
+		u32			time;
+		u32			ticks;
+		u32			count;
+		u32			bm;
+	}			threshold;
+};
+
+struct acpi_processor_cx {
+	u8			valid;
+	u32			address;
+	u32			latency;
+	u32			latency_ticks;
+	u32			power;
+	u32			usage;
+	struct acpi_processor_cx_policy promotion;
+	struct acpi_processor_cx_policy demotion;
+};
+
+struct acpi_processor_power {
+	int			state;
+	int			default_state;
+	u32			bm_activity;
+	struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER];
+};
+
+/* Performance Management */
+
+struct acpi_pct_register {
+	u8			descriptor;
+	u16			length;
+	u8			space_id;
+	u8			bit_width;
+	u8			bit_offset;
+	u8			reserved;
+	u64			address;
+} __attribute__ ((packed));
+
+struct acpi_processor_px {
+	acpi_integer		core_frequency;		/* megahertz */
+	acpi_integer		power;			/* milliWatts */
+	acpi_integer		transition_latency;	/* microseconds */
+	acpi_integer		bus_master_latency;	/* microseconds */
+	acpi_integer		control;		/* control value */
+	acpi_integer		status;			/* success indicator */
+};
+
+struct acpi_processor_performance {
+	int			state;
+	int			platform_limit;
+	u16			control_register;
+	u16			status_register;
+	int			state_count;
+	struct acpi_processor_px states[ACPI_PROCESSOR_MAX_PERFORMANCE];
+};
+
+
+/* Throttling Control */
+
+struct acpi_processor_tx {
+	u16			power;
+	u16			performance;
+};
+
+struct acpi_processor_throttling {
+	int			state;
+	u32			address;
+	u8			duty_offset;
+	u8			duty_width;
+	int			state_count;
+	struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING];
+};
+
+/* Limit Interface */
+
+struct acpi_processor_lx {
+	int			px;		/* performace state */	
+	int			tx;		/* throttle level */
+};
+
+struct acpi_processor_limit {
+	struct acpi_processor_lx state;		/* current limit */
+	struct acpi_processor_lx thermal;	/* thermal limit */
+	struct acpi_processor_lx user;		/* user limit */
+};
+
+
+struct acpi_processor_flags {
+	u8			power:1;
+	u8			performance:1;
+	u8			throttling:1;
+	u8			limit:1;
+	u8			bm_control:1;
+	u8			bm_check:1;
+	u8			reserved:2;
+};
+
+struct acpi_processor {
+	acpi_handle		handle;
+	u32			acpi_id;
+	u32			id;
+	struct acpi_processor_flags flags;
+	struct acpi_processor_power power;
+	struct acpi_processor_performance performance;
+	struct acpi_processor_throttling throttling;
+	struct acpi_processor_limit limit;
+};
+
+struct acpi_processor_errata {
+	u8			smp;
+	struct {
+		u8			throttle:1;
+		u8			fdma:1;
+		u8			reserved:6;
+		u32			bmisx;
+	}			piix4;
+};
+
+static struct acpi_processor	*processors[NR_CPUS];
+static struct acpi_processor_errata errata;
+static void (*pm_idle_save)(void) = NULL;
+
+
+/* --------------------------------------------------------------------------
+                                Errata Handling
+   -------------------------------------------------------------------------- */
+
+int
+acpi_processor_errata_piix4 (
+	struct pci_dev		*dev)
+{
+	u8			rev = 0;
+	u8			value1 = 0;
+	u8			value2 = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_errata_piix4");
+
+	if (!dev)
+		return_VALUE(-EINVAL);
+
+	/*
+	 * Note that 'dev' references the PIIX4 ACPI Controller.
+	 */
+
+	pci_read_config_byte(dev, PCI_REVISION_ID, &rev);
+
+	switch (rev) {
+	case 0:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 A-step\n"));
+		break;
+	case 1:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 B-step\n"));
+		break;
+	case 2:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4E\n"));
+		break;
+	case 3:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4M\n"));
+		break;
+	default:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unknown PIIX4\n"));
+		break;
+	}
+
+	switch (rev) {
+
+	case 0:		/* PIIX4 A-step */
+	case 1:		/* PIIX4 B-step */
+		/*
+		 * See specification changes #13 ("Manual Throttle Duty Cycle")
+		 * and #14 ("Enabling and Disabling Manual Throttle"), plus
+		 * erratum #5 ("STPCLK# Deassertion Time") from the January 
+		 * 2002 PIIX4 specification update.  Applies to only older 
+		 * PIIX4 models.
+		 */
+		errata.piix4.throttle = 1;
+
+	case 2:		/* PIIX4E */
+	case 3:		/* PIIX4M */
+		/*
+		 * See erratum #18 ("C3 Power State/BMIDE and Type-F DMA 
+		 * Livelock") from the January 2002 PIIX4 specification update.
+		 * Applies to all PIIX4 models.
+		 */
+
+		/* 
+		 * BM-IDE
+		 * ------
+		 * Find the PIIX4 IDE Controller and get the Bus Master IDE 
+		 * Status register address.  We'll use this later to read 
+		 * each IDE controller's DMA status to make sure we catch all
+		 * DMA activity.
+		 */
+		dev = pci_find_subsys(PCI_VENDOR_ID_INTEL,
+		           PCI_DEVICE_ID_INTEL_82371AB, 
+                           PCI_ANY_ID, PCI_ANY_ID, NULL);
+		if (dev)
+			errata.piix4.bmisx = pci_resource_start(dev, 4);
+
+		/* 
+		 * Type-F DMA
+		 * ----------
+		 * Find the PIIX4 ISA Controller and read the Motherboard
+		 * DMA controller's status to see if Type-F (Fast) DMA mode
+		 * is enabled (bit 7) on either channel.  Note that we'll 
+		 * 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, 
+			PCI_DEVICE_ID_INTEL_82371AB_0, 
+			PCI_ANY_ID, PCI_ANY_ID, NULL);
+		if (dev) {
+			pci_read_config_byte(dev, 0x76, &value1);
+			pci_read_config_byte(dev, 0x77, &value2);
+			if ((value1 & 0x80) || (value2 & 0x80))
+				errata.piix4.fdma = 1;
+		}
+
+		break;
+	}
+
+	if (errata.piix4.bmisx)
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+			"Bus master activity detection (BM-IDE) erratum enabled\n"));
+	if (errata.piix4.fdma)
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+			"Type-F DMA livelock erratum (C3 disabled)\n"));
+
+	return_VALUE(0);
+}
+
+
+int
+acpi_processor_errata (
+	struct acpi_processor	*pr)
+{
+	int			result = 0;
+	struct pci_dev		*dev = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_errata");
+
+	if (!pr)
+		return_VALUE(-EINVAL);
+
+	/*
+	 * PIIX4
+	 */
+	dev = pci_find_subsys(PCI_VENDOR_ID_INTEL, 
+		PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID, PCI_ANY_ID, NULL);
+	if (dev)
+		result = acpi_processor_errata_piix4(dev);
+
+	return_VALUE(result);
+}
+
+
+/* --------------------------------------------------------------------------
+                                Power Management
+   -------------------------------------------------------------------------- */
+
+static inline u32
+ticks_elapsed (
+	u32			t1,
+	u32			t2)
+{
+	if (t2 >= t1)
+		return (t2 - t1);
+	else if (!acpi_fadt.tmr_val_ext)
+		return (((0x00FFFFFF - t1) + t2) & 0x00FFFFFF);
+	else
+		return ((0xFFFFFFFF - t1) + t2);
+}
+
+
+static void
+acpi_processor_power_activate (
+	struct acpi_processor	*pr,
+	int			state)
+{
+	if (!pr)
+		return;
+
+	pr->power.states[pr->power.state].promotion.count = 0;
+	pr->power.states[pr->power.state].demotion.count = 0;
+
+	/* Cleanup from old state. */
+	switch (pr->power.state) {
+	case ACPI_STATE_C3:
+		/* Disable bus master reload */
+		acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0, ACPI_MTX_DO_NOT_LOCK);
+		break;
+	}
+
+	/* Prepare to use new state. */
+	switch (state) {
+	case ACPI_STATE_C3:
+		/* Enable bus master reload */
+		acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 1, ACPI_MTX_DO_NOT_LOCK);
+		break;
+	}
+
+	pr->power.state = state;
+
+	return;
+}
+
+
+static void
+acpi_processor_idle (void)
+{
+	struct acpi_processor	*pr = NULL;
+	struct acpi_processor_cx *cx = NULL;
+	int			next_state = 0;
+	int			sleep_ticks = 0;
+	u32			t1, t2 = 0;
+
+	pr = processors[smp_processor_id()];
+	if (!pr)
+		return;
+
+	/*
+	 * Interrupts must be disabled during bus mastering calculations and
+	 * for C2/C3 transitions.
+	 */
+	__cli();
+
+	cx = &(pr->power.states[pr->power.state]);
+
+	/*
+	 * Check BM Activity
+	 * -----------------
+	 * Check for bus mastering activity (if required), record, and check
+	 * for demotion.
+	 */
+	if (pr->flags.bm_check) {
+		u32		bm_status = 0;
+
+		pr->power.bm_activity <<= 1;
+
+		acpi_get_register(ACPI_BITREG_BUS_MASTER_STATUS, 
+			&bm_status, ACPI_MTX_DO_NOT_LOCK);
+		if (bm_status) {
+			pr->power.bm_activity++;
+			acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS,
+				1, ACPI_MTX_DO_NOT_LOCK);
+		}
+		/*
+		 * PIIX4 Erratum #18: Note that BM_STS doesn't always reflect
+		 * the true state of bus mastering activity; forcing us to 
+		 * manually check the BMIDEA bit of each IDE channel.
+		 */
+		else if (errata.piix4.bmisx) {
+			if ((inb_p(errata.piix4.bmisx + 0x02) & 0x01) 
+				|| (inb_p(errata.piix4.bmisx + 0x0A) & 0x01))
+				pr->power.bm_activity++;
+		}
+		/*
+		 * Apply bus mastering demotion policy.  Automatically demote
+		 * to avoid a faulty transition.  Note that the processor 
+		 * won't enter a low-power state during this call (to this 
+		 * funciton) but should upon the next.
+		 *
+		 * TBD: A better policy might be to fallback to the demotion 
+		 *      state (use it for this quantum only) istead of 
+		 *      demoting -- and rely on duration as our sole demotion
+		 *      qualification.  This may, however, introduce DMA 
+		 *      issues (e.g. floppy DMA transfer overrun/underrun).
+		 */
+		if (pr->power.bm_activity & cx->demotion.threshold.bm) {
+			__sti();
+			next_state = cx->demotion.state;
+			goto end;
+		}
+	}
+
+	cx->usage++;
+
+	/*
+	 * Sleep:
+	 * ------
+	 * Invoke the current Cx state to put the processor to sleep.
+	 */
+	switch (pr->power.state) {
+
+	case ACPI_STATE_C1:
+		/* Invoke C1. */
+		safe_halt();
+		/*
+                 * TBD: Can't get time duration while in C1, as resumes
+		 *      go to an ISR rather than here.  Need to instrument
+		 *      base interrupt handler.
+		 */
+		sleep_ticks = 0xFFFFFFFF;
+		break;
+
+	case ACPI_STATE_C2:
+		/* Get start time (ticks) */
+		t1 = inl(acpi_fadt.xpm_tmr_blk.address);
+		/* Invoke C2 */
+		inb(pr->power.states[ACPI_STATE_C2].address);
+		/* Dummy op - must do something useless after P_LVL2 read */
+		t2 = inl(acpi_fadt.xpm_tmr_blk.address);
+		/* Get end time (ticks) */
+		t2 = inl(acpi_fadt.xpm_tmr_blk.address);
+		/* Re-enable interrupts */
+		__sti();
+		/* Compute time (ticks) that we were actually asleep */
+		sleep_ticks = ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD;
+		break;
+
+	case ACPI_STATE_C3:
+		/* Disable bus master arbitration */
+		acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1, ACPI_MTX_DO_NOT_LOCK);
+		/* Get start time (ticks) */
+		t1 = inl(acpi_fadt.xpm_tmr_blk.address);
+		/* Invoke C3 */
+		inb(pr->power.states[ACPI_STATE_C3].address);
+		/* Dummy op - must do something useless after P_LVL3 read */
+		t2 = inl(acpi_fadt.xpm_tmr_blk.address);
+		/* Get end time (ticks) */
+		t2 = inl(acpi_fadt.xpm_tmr_blk.address);
+		/* Enable bus master arbitration */
+		acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_DO_NOT_LOCK);
+		/* Re-enable interrupts */
+		__sti();
+		/* Compute time (ticks) that we were actually asleep */
+		sleep_ticks = ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD;
+		break;
+
+	default:
+		__sti();
+		return;
+	}
+
+	next_state = pr->power.state;
+
+	/*
+	 * Promotion?
+	 * ----------
+	 * 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.
+	 */
+	if (cx->promotion.state) {
+		if (sleep_ticks > cx->promotion.threshold.ticks) {
+			cx->promotion.count++;
+ 			cx->demotion.count = 0;
+			if (cx->promotion.count >= cx->promotion.threshold.count) {
+				if (pr->flags.bm_check) {
+					if (!(pr->power.bm_activity & cx->promotion.threshold.bm)) {
+						next_state = cx->promotion.state;
+						goto end;
+					}
+				}
+				else {
+					next_state = cx->promotion.state;
+					goto end;
+				}
+			}
+		}
+	}
+
+	/*
+	 * Demotion?
+	 * ---------
+	 * Track the number of shorts (time asleep is less than time threshold)
+	 * and demote when the usage threshold is reached.
+	 */
+	if (cx->demotion.state) {
+		if (sleep_ticks < cx->demotion.threshold.ticks) {
+			cx->demotion.count++;
+			cx->promotion.count = 0;
+			if (cx->demotion.count >= cx->demotion.threshold.count) {
+				next_state = cx->demotion.state;
+				goto end;
+			}
+		}
+	}
+
+end:
+	/*
+	 * New Cx State?
+	 * -------------
+	 * If we're going to start using a new Cx state we must clean up
+	 * from the previous and prepare to use the new.
+	 */
+	if (next_state != pr->power.state)
+		acpi_processor_power_activate(pr, next_state);
+
+	return;
+}
+
+
+static int
+acpi_processor_set_power_policy (
+	struct acpi_processor	*pr)
+{
+	ACPI_FUNCTION_TRACE("acpi_processor_set_power_policy");
+
+	/*
+	 * This function sets the default Cx state policy (OS idle handler).
+	 * Our scheme is to promote quickly to C2 but more conservatively
+	 * to C3.  We're favoring C2  for its characteristics of low latency
+	 * (quick response), good power savings, and ability to allow bus
+	 * mastering activity.  Note that the Cx state policy is completely
+	 * customizable and can be altered dynamically.
+	 */
+
+	if (!pr)
+		return_VALUE(-EINVAL);
+
+	/*
+	 * C0/C1
+	 * -----
+	 */
+	pr->power.state = ACPI_STATE_C1;
+	pr->power.default_state = ACPI_STATE_C1;
+
+	/*
+	 * C1/C2
+	 * -----
+	 * Set the default C1 promotion and C2 demotion policies, where we
+	 * promote from C1 to C2 after several (10) successive C1 transitions,
+	 * as we cannot (currently) measure the time spent in C1. Demote from
+	 * C2 to C1 anytime we experience a 'short' (time spent in C2 is less
+	 * than the C2 transtion latency).  Note the simplifying assumption 
+	 * that the 'cost' of a transition is amortized when we sleep for at
+	 * least as long as the transition's latency (thus the total transition
+	 * time is two times the latency).
+	 *
+	 * TBD: Measure C1 sleep times by instrumenting the core IRQ handler.
+	 * TBD: Demote to default C-State after long periods of activity.
+	 * TBD: Investigate policy's use of CPU utilization -vs- sleep duration.
+	 */
+	if (pr->power.states[ACPI_STATE_C2].valid) {
+		pr->power.states[ACPI_STATE_C1].promotion.threshold.count = 10;
+		pr->power.states[ACPI_STATE_C1].promotion.threshold.ticks =
+			pr->power.states[ACPI_STATE_C2].latency_ticks;
+		pr->power.states[ACPI_STATE_C1].promotion.state = ACPI_STATE_C2;
+
+		pr->power.states[ACPI_STATE_C2].demotion.threshold.count = 1;
+		pr->power.states[ACPI_STATE_C2].demotion.threshold.ticks =
+			pr->power.states[ACPI_STATE_C2].latency_ticks;
+		pr->power.states[ACPI_STATE_C2].demotion.state = ACPI_STATE_C1;
+	}
+
+	/*
+	 * C2/C3
+	 * -----
+	 * Set default C2 promotion and C3 demotion policies, where we promote
+	 * from C2 to C3 after several (4) cycles of no bus mastering activity
+	 * while maintaining sleep time criteria.  Demote immediately on a
+	 * short or whenever bus mastering activity occurs.
+	 */
+	if ((pr->power.states[ACPI_STATE_C2].valid) &&
+		(pr->power.states[ACPI_STATE_C3].valid)) {
+		pr->power.states[ACPI_STATE_C2].promotion.threshold.count = 4;
+		pr->power.states[ACPI_STATE_C2].promotion.threshold.ticks =
+			pr->power.states[ACPI_STATE_C3].latency_ticks;
+		pr->power.states[ACPI_STATE_C2].promotion.threshold.bm = 0x0F;
+		pr->power.states[ACPI_STATE_C2].promotion.state = ACPI_STATE_C3;
+
+		pr->power.states[ACPI_STATE_C3].demotion.threshold.count = 1;
+		pr->power.states[ACPI_STATE_C3].demotion.threshold.ticks =
+			pr->power.states[ACPI_STATE_C3].latency_ticks;
+		pr->power.states[ACPI_STATE_C3].demotion.threshold.bm = 0x0F;
+		pr->power.states[ACPI_STATE_C3].demotion.state = ACPI_STATE_C2;
+	}
+
+	return_VALUE(0);
+}
+
+
+int
+acpi_processor_get_power_info (
+	struct acpi_processor	*pr)
+{
+	int			result = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_get_power_info");
+
+	if (!pr)
+		return_VALUE(-EINVAL);
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+		"lvl2[0x%08x] lvl3[0x%08x]\n",
+		pr->power.states[ACPI_STATE_C2].address,
+		pr->power.states[ACPI_STATE_C3].address));
+
+	/* TBD: Support ACPI 2.0 objects */
+
+	/*
+	 * C0
+	 * --
+	 * This state exists only as filler in our array.
+	 */
+	pr->power.states[ACPI_STATE_C0].valid = 1;
+
+	/*
+	 * C1
+	 * --
+	 * ACPI requires C1 support for all processors.
+	 *
+	 * TBD: What about PROC_C1?
+	 */
+	pr->power.states[ACPI_STATE_C1].valid = 1;
+
+	/*
+	 * C2
+	 * --
+	 * We're (currently) only supporting C2 on UP systems.
+	 *
+	 * TBD: Support for C2 on MP (P_LVL2_UP).
+	 */
+	if (pr->power.states[ACPI_STATE_C2].address) {
+
+		pr->power.states[ACPI_STATE_C2].latency = acpi_fadt.plvl2_lat;
+
+		/*
+		 * C2 latency must be less than or equal to 100 microseconds.
+		 */
+		if (acpi_fadt.plvl2_lat > ACPI_PROCESSOR_MAX_C2_LATENCY)
+			ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+				"C2 latency too large [%d]\n",
+				acpi_fadt.plvl2_lat));
+		/*
+		 * Only support C2 on UP systems (see TBD above).
+		 */
+		else if (errata.smp)
+			ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+				"C2 not supported in SMP mode\n"));
+		/*
+		 * Otherwise we've met all of our C2 requirements.
+		 * Normalize the C2 latency to expidite policy.
+		 */
+		else {
+			pr->power.states[ACPI_STATE_C2].valid = 1;
+			pr->power.states[ACPI_STATE_C2].latency_ticks = 
+				US_TO_PM_TIMER_TICKS(acpi_fadt.plvl2_lat);
+		}
+	}
+
+	/*
+	 * C3
+	 * --
+	 * TBD: Investigate use of WBINVD on UP/SMP system in absence of
+	 *	bm_control.
+	 */
+	if (pr->power.states[ACPI_STATE_C3].address) {
+
+		pr->power.states[ACPI_STATE_C3].latency = acpi_fadt.plvl3_lat;
+
+		/*
+		 * C3 latency must be less than or equal to 1000 microseconds.
+		 */
+		if (acpi_fadt.plvl3_lat > ACPI_PROCESSOR_MAX_C3_LATENCY)
+			ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+				"C3 latency too large [%d]\n", 
+				acpi_fadt.plvl3_lat));
+		/*
+		 * Only support C3 when bus mastering arbitration control
+		 * is present (able to disable bus mastering to maintain
+		 * cache coherency while in C3).
+		 */
+		else if (!pr->flags.bm_control)
+			ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+				"C3 support requires bus mastering control\n"));
+		/*
+		 * Only support C3 on UP systems, as bm_control is only viable
+		 * on a UP system and flushing caches (e.g. WBINVD) is simply 
+		 * too costly (at this time).
+		 */
+		else if (errata.smp)
+			ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+				"C3 not supported in SMP mode\n"));
+		/*
+		 * PIIX4 Erratum #18: We don't support C3 when Type-F (fast) 
+		 * DMA transfers are used by any ISA device to avoid livelock.
+		 * Note that we could disable Type-F DMA (as recommended by
+		 * the erratum), but this is known to disrupt certain ISA 
+		 * devices thus we take the conservative approach.
+		 */
+		else if (errata.piix4.fdma) {
+			ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+				"C3 not supported on PIIX4 with Type-F DMA\n"));
+		}
+		/*
+		 * Otherwise we've met all of our C3 requirements.  
+		 * Normalize the C2 latency to expidite policy.  Enable
+		 * checking of bus mastering status (bm_check) so we can 
+		 * use this in our C3 policy.
+		 */
+		else {
+			pr->power.states[ACPI_STATE_C3].valid = 1;
+			pr->power.states[ACPI_STATE_C3].latency_ticks = 
+				US_TO_PM_TIMER_TICKS(acpi_fadt.plvl3_lat);
+			pr->flags.bm_check = 1;
+		}
+	}
+
+	/*
+	 * Set Default Policy
+	 * ------------------
+	 * Now that we know which state are supported, set the default
+	 * policy.  Note that this policy can be changed dynamically
+	 * (e.g. encourage deeper sleeps to conserve battery life when
+	 * not on AC).
+	 */
+	result = acpi_processor_set_power_policy(pr);
+	if (result)
+		return_VALUE(result);
+
+	/*
+	 * If this processor supports C2 or C3 we denote it as being 'power
+	 * manageable'.  Note that there's really no policy involved for
+	 * when only C1 is supported.
+	 */
+	if (pr->power.states[ACPI_STATE_C2].valid 
+		|| pr->power.states[ACPI_STATE_C3].valid)
+		pr->flags.power = 1;
+
+	return_VALUE(0);
+}
+
+
+/* --------------------------------------------------------------------------
+                              Performance Management
+   -------------------------------------------------------------------------- */
+
+static int 
+acpi_processor_get_platform_limit (
+	struct acpi_processor*	pr)
+{
+	acpi_status		status = 0;
+	unsigned long		ppc = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_get_platform_limit");
+
+	if (!pr)
+		return_VALUE(-EINVAL);
+
+	/*
+	 * _PPC indicates the maximum state currently supported by the platform
+	 * (e.g. 0 = states 0..n; 1 = states 1..n; etc.
+	 */
+	status = acpi_evaluate_integer(pr->handle, "_PPC", NULL, &ppc);
+	if(ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PPC\n"));
+		return_VALUE(-ENODEV);
+	}
+
+	pr->performance.platform_limit = (int) ppc;
+
+	return_VALUE(0);
+}
+
+
+static int 
+acpi_processor_get_performance_control (
+	struct acpi_processor	*pr)
+{
+	int			result = 0;
+	acpi_status		status = 0;
+	struct acpi_buffer	buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+	union acpi_object	*pct = NULL;
+	union acpi_object	obj = {0};
+	struct acpi_pct_register *reg = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_get_performance_control");
+
+	status = acpi_evaluate_object(pr->handle, "_PCT", NULL, &buffer);
+	if(ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PCT\n"));
+		return_VALUE(-ENODEV);
+	}
+
+	pct = (union acpi_object *) buffer.pointer;
+	if (!pct || (pct->type != ACPI_TYPE_PACKAGE) 
+		|| (pct->package.count != 2)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PCT data\n"));
+		result = -EFAULT;
+		goto end;
+	}
+
+	/*
+	 * control_register
+	 */
+
+	obj = pct->package.elements[0];
+
+	if ((obj.type != ACPI_TYPE_BUFFER) 
+		|| (obj.buffer.length < sizeof(struct acpi_pct_register)) 
+		|| (obj.buffer.pointer == NULL)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 
+			"Invalid _PCT data (control_register)\n"));
+		result = -EFAULT;
+		goto end;
+	}
+
+	reg = (struct acpi_pct_register *) (obj.buffer.pointer);
+
+	if (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unsupported address space [%d] (control_register)\n",
+			(u32) reg->space_id));
+		result = -EFAULT;
+		goto end;
+	}
+
+	pr->performance.control_register = (u16) reg->address;
+
+	/*
+	 * status_register
+	 */
+
+	obj = pct->package.elements[1];
+
+	if ((obj.type != ACPI_TYPE_BUFFER) 
+		|| (obj.buffer.length < sizeof(struct acpi_pct_register)) 
+		|| (obj.buffer.pointer == NULL)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 
+			"Invalid _PCT data (status_register)\n"));
+		result = -EFAULT;
+		goto end;
+	}
+
+	reg = (struct acpi_pct_register *) (obj.buffer.pointer);
+
+	if (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unsupported address space [%d] (status_register)\n",
+			(u32) reg->space_id));
+		result = -EFAULT;
+		goto end;
+	}
+
+	pr->performance.status_register = (u16) reg->address;
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+		"control_register[0x%04x] status_register[0x%04x]\n",
+		pr->performance.control_register,
+		pr->performance.status_register));
+
+end:
+	acpi_os_free(buffer.pointer);
+
+	return_VALUE(result);
+}
+
+
+static int 
+acpi_processor_get_performance_states (
+	struct acpi_processor*	pr)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	struct acpi_buffer	buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+	struct acpi_buffer	format = {sizeof("NNNNNN"), "NNNNNN"};
+	struct acpi_buffer	state = {0, NULL};
+	union acpi_object 	*pss = NULL;
+	int			i = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_get_performance_states");
+
+	status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer);
+	if(ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PSS\n"));
+		return_VALUE(-ENODEV);
+	}
+
+	pss = (union acpi_object *) buffer.pointer;
+	if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSS data\n"));
+		result = -EFAULT;
+		goto end;
+	}
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d performance states\n", 
+		pss->package.count));
+
+	if (pss->package.count > ACPI_PROCESSOR_MAX_PERFORMANCE) {
+		pr->performance.state_count = ACPI_PROCESSOR_MAX_PERFORMANCE;
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+			"Limiting number of states to max (%d)\n", 
+			ACPI_PROCESSOR_MAX_PERFORMANCE));
+	}
+	else
+		pr->performance.state_count = pss->package.count;
+
+	if (pr->performance.state_count > 1)
+		pr->flags.performance = 1;
+
+	for (i = 0; i < pr->performance.state_count; i++) {
+
+		struct acpi_processor_px *px = &(pr->performance.states[i]);
+
+		state.length = sizeof(struct acpi_processor_px);
+		state.pointer = px;
+
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Extracting state %d\n", i));
+
+		status = acpi_extract_package(&(pss->package.elements[i]), 
+			&format, &state);
+		if (ACPI_FAILURE(status)) {
+			ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSS data\n"));
+			result = -EFAULT;
+			goto end;
+		}
+
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+			"State [%d]: core_frequency[%d] power[%d] transition_latency[%d] bus_master_latency[%d] control[0x%x] status[0x%x]\n",
+			i, 
+			(u32) px->core_frequency, 
+			(u32) px->power, 
+			(u32) px->transition_latency, 
+			(u32) px->bus_master_latency,
+			(u32) px->control, 
+			(u32) px->status));
+	}
+
+end:
+	acpi_os_free(buffer.pointer);
+
+	return_VALUE(result);
+}
+
+
+static int
+acpi_processor_set_performance (
+	struct acpi_processor	*pr,
+	int			state)
+{
+	u16			port = 0;
+	u8			value = 0;
+	int			i = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_set_performance");
+
+	if (!pr)
+		return_VALUE(-EINVAL);
+
+	if (!pr->flags.performance)
+		return_VALUE(-ENODEV);
+
+	if (state >= pr->performance.state_count) {
+		ACPI_DEBUG_PRINT((ACPI_DB_WARN, 
+			"Invalid target state (P%d)\n", state));
+		return_VALUE(-ENODEV);
+	}
+
+	if (state < pr->performance.platform_limit) {
+		ACPI_DEBUG_PRINT((ACPI_DB_WARN, 
+			"Platform limit (P%d) overrides target state (P%d)\n",
+			pr->performance.platform_limit, state));
+		return_VALUE(-ENODEV);
+	}
+
+	if (state == pr->performance.state) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+			"Already at target state (P%d)\n", state));
+		return_VALUE(0);
+	}
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Transitioning from P%d to P%d\n",
+		pr->performance.state, state));
+
+	/*
+	 * First we write the target state's 'control' value to the
+	 * control_register.
+	 */
+
+	port = pr->performance.control_register;
+	value = (u16) pr->performance.states[state].control;
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+		"Writing 0x%02x to port 0x%04x\n", value, port));
+
+	outb(value, port); 
+
+	/*
+	 * 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 = pr->performance.status_register;
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+		"Looking for 0x%02x from port 0x%04x\n",
+		(u8) pr->performance.states[state].status, port));
+
+	for (i=0; i<100; i++) {
+		value = inb(port);
+		if (value == (u8) pr->performance.states[state].status)
+			break;
+		udelay(10);
+	}
+
+	if (value != pr->performance.states[state].status) {
+		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Transition failed\n"));
+		return_VALUE(-ENODEV);
+	}
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+		"Transition successful after %d microseconds\n",
+		i * 10));
+
+	pr->performance.state = state;
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_processor_get_performance_info (
+	struct acpi_processor	*pr)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	acpi_handle		handle = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_get_performance_info");
+
+	if (!pr)
+		return_VALUE(-EINVAL);
+
+	status = acpi_get_handle(pr->handle, "_PCT", &handle);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+			"ACPI-based processor performance control unavailable\n"));
+		return_VALUE(0);
+	}
+
+	result = acpi_processor_get_performance_control(pr);
+	if (result)
+		return_VALUE(result);
+
+	result = acpi_processor_get_performance_states(pr);
+	if (result)
+		return_VALUE(result);
+
+	result = acpi_processor_get_platform_limit(pr);
+	if (result)
+		return_VALUE(result);
+
+	/* 
+	 * TBD: Don't trust the latency values we get from BIOS, but rather
+	 *      measure the latencies during run-time (e.g. get_latencies).
+	 */
+
+	return_VALUE(0);
+}
+
+
+/* --------------------------------------------------------------------------
+                              Throttling Control
+   -------------------------------------------------------------------------- */
+
+static int
+acpi_processor_get_throttling (
+	struct acpi_processor	*pr)
+{
+	int			state = 0;
+	u32			value = 0;
+	u32			duty_mask = 0;
+	u32			duty_value = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_get_throttling");
+
+	if (!pr)
+		return_VALUE(-EINVAL);
+
+	if (!pr->flags.throttling)
+		return_VALUE(-ENODEV);
+
+	pr->throttling.state = 0;
+
+	__cli();
+
+	duty_mask = pr->throttling.state_count - 1;
+
+	duty_mask <<= pr->throttling.duty_offset;
+
+	value = inl(pr->throttling.address);
+
+	/*
+	 * Compute the current throttling state when throttling is enabled
+	 * (bit 4 is on).
+	 */
+	if (value & 0x10) {
+		duty_value = value & duty_mask;
+		duty_value >>= pr->throttling.duty_offset;
+
+		if (duty_value)
+			state = pr->throttling.state_count-duty_value;
+	}
+
+	pr->throttling.state = state;
+
+	__sti();
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+		"Throttling state is T%d (%d%% throttling applied)\n",
+		state, pr->throttling.states[state].performance));
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_processor_set_throttling (
+	struct acpi_processor	*pr,
+	int			state)
+{
+	u32                     value = 0;
+	u32                     duty_mask = 0;
+	u32                     duty_value = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_set_throttling");
+
+	if (!pr)
+		return_VALUE(-EINVAL);
+
+	if ((state < 0) || (state > (pr->throttling.state_count - 1)))
+		return_VALUE(-EINVAL);
+
+	if (!pr->flags.throttling)
+		return_VALUE(-ENODEV);
+
+	if (state == pr->throttling.state)
+		return_VALUE(0);
+
+	__cli();
+
+	/*
+	 * Calculate the duty_value and duty_mask.
+	 */
+	if (state) {
+		duty_value = pr->throttling.state_count - state;
+
+		duty_value <<= pr->throttling.duty_offset;
+
+		/* Used to clear all duty_value bits */
+		duty_mask = pr->throttling.state_count - 1;
+
+		duty_mask <<= acpi_fadt.duty_offset;
+		duty_mask = ~duty_mask;
+	}
+
+	/*
+	 * Disable throttling by writing a 0 to bit 4.  Note that we must
+	 * turn it off before you can change the duty_value.
+	 */
+	value = inl(pr->throttling.address);
+	if (value & 0x10) {
+		value &= 0xFFFFFFEF;
+		outl(value, pr->throttling.address);
+	}
+
+	/*
+	 * Write the new duty_value and then enable throttling.  Note
+	 * that a state value of 0 leaves throttling disabled.
+	 */
+	if (state) {
+		value &= duty_mask;
+		value |= duty_value;
+		outl(value, pr->throttling.address);
+
+		value |= 0x00000010;
+		outl(value, pr->throttling.address);
+	}
+
+	pr->throttling.state = state;
+
+	__sti();
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+		"Throttling state set to T%d (%d%%)\n", state, 
+		(pr->throttling.states[state].performance?pr->throttling.states[state].performance/10:0)));
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_processor_get_throttling_info (
+	struct acpi_processor	*pr)
+{
+	int			result = 0;
+	int			step = 0;
+	int			i = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_get_throttling_info");
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+		"pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
+		pr->throttling.address,
+		pr->throttling.duty_offset,
+		pr->throttling.duty_width));
+
+	if (!pr)
+		return_VALUE(-EINVAL);
+
+	/* TBD: Support ACPI 2.0 objects */
+
+	if (!pr->throttling.address) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
+		return_VALUE(0);
+	}
+	else if (!pr->throttling.duty_width) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n"));
+		return_VALUE(0);
+	}
+	/* TBD: Support duty_cycle values that span bit 4. */
+	else if ((pr->throttling.duty_offset
+		+ pr->throttling.duty_width) > 4) {
+		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "duty_cycle spans bit 4\n"));
+		return_VALUE(0);
+	}
+
+	/*
+	 * PIIX4 Errata: We don't support throttling on the original PIIX4.
+	 * This shouldn't be an issue as few (if any) mobile systems ever
+	 * used this part.
+	 */
+	if (errata.piix4.throttle) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+			"Throttling not supported on PIIX4 A- or B-step\n"));
+		return_VALUE(0);
+	}
+
+	pr->throttling.state_count = POWER_OF_2[acpi_fadt.duty_width];
+
+	/*
+	 * Compute state values. Note that throttling displays a linear power/
+	 * performance relationship (at 50% performance the CPU will consume
+	 * 50% power).  Values are in 1/10th of a percent to preserve accuracy.
+	 */
+
+	step = (1000 / pr->throttling.state_count);
+
+	for (i=0; i<pr->throttling.state_count; i++) {
+		pr->throttling.states[i].performance = step * i;
+		pr->throttling.states[i].power = step * i;
+	}
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n", 
+		pr->throttling.state_count));
+
+	pr->flags.throttling = 1;
+
+	/*
+	 * Disable throttling (if enabled).  We'll let subsequent policy (e.g. 
+	 * thermal) decide to lower performance if it so chooses, but for now 
+	 * we'll crank up the speed.
+	 */
+
+	result = acpi_processor_get_throttling(pr);
+	if (result)
+		goto end;
+
+	if (pr->throttling.state) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabling throttling (was T%d)\n", 
+			pr->throttling.state));
+		result = acpi_processor_set_throttling(pr, 0);
+		if (result)
+			goto end;
+	}
+
+end:
+	if (result)
+		pr->flags.throttling = 0;
+
+	return_VALUE(result);
+}
+
+
+/* --------------------------------------------------------------------------
+                                 Limit Interface
+   -------------------------------------------------------------------------- */
+
+static int
+acpi_processor_apply_limit (
+	struct acpi_processor* 	pr)
+{
+	int			result = 0;
+	u16			px = 0;
+	u16			tx = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_apply_limit");
+
+	if (!pr)
+		return_VALUE(-EINVAL);
+
+	if (!pr->flags.limit)
+		return_VALUE(-ENODEV);
+
+	if (pr->flags.performance) {
+		px = pr->performance.platform_limit;
+		if (pr->limit.user.px > px)
+			px = pr->limit.user.px;
+		if (pr->limit.thermal.px > px)
+			px = pr->limit.thermal.px;
+
+		result = acpi_processor_set_performance(pr, px);
+		if (result)
+			goto end;
+	}
+
+	if (pr->flags.throttling) {
+		if (pr->limit.user.tx > tx)
+			tx = pr->limit.user.tx;
+		if (pr->limit.thermal.tx > tx)
+			tx = pr->limit.thermal.tx;
+
+		result = acpi_processor_set_throttling(pr, tx);
+		if (result)
+			goto end;
+	}
+
+	pr->limit.state.px = px;
+	pr->limit.state.tx = tx;
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d] limit set to (P%d:T%d)\n",
+		pr->id,
+		pr->limit.state.px,
+		pr->limit.state.tx));
+
+end:
+	if (result)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to set limit\n"));
+
+	return_VALUE(result);
+}
+
+
+int
+acpi_processor_set_thermal_limit (
+	acpi_handle		handle,
+	int			type)
+{
+	int			result = 0;
+	struct acpi_processor	*pr = NULL;
+	struct acpi_device	*device = NULL;
+	int			px = 0;
+	int			tx = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_set_thermal_limit");
+
+	if ((type < ACPI_PROCESSOR_LIMIT_NONE) 
+		|| (type > ACPI_PROCESSOR_LIMIT_DECREMENT))
+		return_VALUE(-EINVAL);
+
+	result = acpi_bus_get_device(handle, &device);
+	if (result)
+		return_VALUE(result);
+
+	pr = (struct acpi_processor *) acpi_driver_data(device);
+	if (!pr)
+		return_VALUE(-ENODEV);
+
+	if (!pr->flags.limit)
+		return_VALUE(-ENODEV);
+
+	/* Thermal limits are always relative to the current Px/Tx state. */
+	if (pr->flags.performance)
+		pr->limit.thermal.px = pr->performance.state;
+	if (pr->flags.throttling)
+		pr->limit.thermal.tx = pr->throttling.state;
+
+	/*
+	 * Our default policy is to only use throttling at the lowest
+	 * performance state.
+	 */
+
+	px = pr->limit.thermal.px;
+	tx = pr->limit.thermal.tx;
+
+	switch (type) {
+
+	case ACPI_PROCESSOR_LIMIT_NONE:
+		px = 0;
+		tx = 0;
+		break;
+
+	case ACPI_PROCESSOR_LIMIT_INCREMENT:
+		if (pr->flags.performance) {
+			if (px == (pr->performance.state_count - 1))
+				ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+					"At maximum performance state\n"));
+			else {
+				px++;
+				goto end;
+			}
+		}
+		if (pr->flags.throttling) {
+			if (tx == (pr->throttling.state_count - 1))
+				ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+					"At maximum throttling state\n"));
+			else
+				tx++;
+		}
+		break;
+
+	case ACPI_PROCESSOR_LIMIT_DECREMENT:
+		if (pr->flags.performance) {
+			if (px == pr->performance.platform_limit)
+				ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+					"At minimum performance state\n"));
+			else  {
+				px--;
+				goto end;
+			}
+		}
+		if (pr->flags.throttling) {
+			if (tx == 0)
+				ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+					"At minimum throttling state\n"));
+			else
+				tx--;
+		}
+		break;
+	}
+
+end:
+	pr->limit.thermal.px = px;
+	pr->limit.thermal.tx = tx;
+
+	result = acpi_processor_apply_limit(pr);
+	if (result)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 
+			"Unable to set thermal limit\n"));
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Thermal limit now (P%d:T%d)\n",
+		pr->limit.thermal.px,
+		pr->limit.thermal.tx));
+
+	return_VALUE(result);
+}
+
+
+static int
+acpi_processor_get_limit_info (
+	struct acpi_processor	*pr)
+{
+	ACPI_FUNCTION_TRACE("acpi_processor_get_limit_info");
+
+	if (!pr)
+		return_VALUE(-EINVAL);
+
+	if (pr->flags.performance || pr->flags.throttling)
+		pr->flags.limit = 1;
+
+	return_VALUE(0);
+}
+
+
+/* --------------------------------------------------------------------------
+                              FS Interface (/proc)
+   -------------------------------------------------------------------------- */
+
+struct proc_dir_entry		*acpi_processor_dir = NULL;
+
+static int
+acpi_processor_read_info (
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	struct acpi_processor	*pr = (struct acpi_processor *) data;
+	char			*p = page;
+	int			len = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_read_info");
+
+	if (!pr || (off != 0))
+		goto end;
+
+	p += sprintf(p, "processor id:            %d\n",
+		pr->id);
+
+	p += sprintf(p, "acpi id:                 %d\n",
+		pr->acpi_id);
+
+	p += sprintf(p, "bus mastering control:   %s\n",
+		pr->flags.bm_control ? "yes" : "no");
+
+	p += sprintf(p, "power management:        %s\n",
+		pr->flags.power ? "yes" : "no");
+
+	p += sprintf(p, "throttling control:      %s\n",
+		pr->flags.throttling ? "yes" : "no");
+
+	p += sprintf(p, "performance management:  %s\n",
+		pr->flags.performance ? "yes" : "no");
+
+	p += sprintf(p, "limit interface:         %s\n",
+		pr->flags.limit ? "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(len);
+}
+
+
+static int
+acpi_processor_read_power (
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	struct acpi_processor	*pr = (struct acpi_processor *) data;
+	char			*p = page;
+	int			len = 0;
+	int			i = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_read_power");
+
+	if (!pr || (off != 0))
+		goto end;
+
+	p += sprintf(p, "active state:            C%d\n",
+		pr->power.state);
+
+	p += sprintf(p, "default state:           C%d\n",
+		pr->power.default_state);
+
+	p += sprintf(p, "bus master activity:     %08x\n",
+		pr->power.bm_activity);
+
+	p += sprintf(p, "states:\n");
+
+	for (i=1; i<ACPI_C_STATE_COUNT; i++) {
+
+		p += sprintf(p, "   %cC%d:                  ", 
+			(i == pr->power.state?'*':' '), i);
+
+		if (!pr->power.states[i].valid) {
+			p += sprintf(p, "<not supported>\n");
+			continue;
+		}
+
+		if (pr->power.states[i].promotion.state)
+			p += sprintf(p, "promotion[C%d] ",
+				pr->power.states[i].promotion.state);
+		else
+			p += sprintf(p, "promotion[--] ");
+
+		if (pr->power.states[i].demotion.state)
+			p += sprintf(p, "demotion[C%d] ",
+				pr->power.states[i].demotion.state);
+		else
+			p += sprintf(p, "demotion[--] ");
+
+		p += sprintf(p, "latency[%03d] usage[%08d]\n",
+			pr->power.states[i].latency,
+			pr->power.states[i].usage);
+	}
+
+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);
+}
+
+
+static int
+acpi_processor_read_performance (
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	struct acpi_processor	*pr = (struct acpi_processor *) data;
+	char			*p = page;
+	int			len = 0;
+	int			i = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_read_performance");
+
+	if (!pr || (off != 0))
+		goto end;
+
+	if (!pr->flags.performance) {
+		p += sprintf(p, "<not supported>\n");
+		goto end;
+	}
+
+	p += sprintf(p, "state count:             %d\n",
+		pr->performance.state_count);
+
+	p += sprintf(p, "active state:            P%d\n",
+		pr->performance.state);
+
+	p += sprintf(p, "states:\n");
+
+	for (i=0; i<pr->performance.state_count; i++)
+		p += sprintf(p, "   %cP%d:                  %d MHz, %d mW, %d uS\n",
+			(i == pr->performance.state?'*':' '), i,
+			(u32) pr->performance.states[i].core_frequency,
+			(u32) pr->performance.states[i].power,
+			(u32) pr->performance.states[i].transition_latency);
+
+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);
+}
+
+
+static int
+acpi_processor_write_performance (
+        struct file		*file,
+        const char		*buffer,
+        unsigned long		count,
+        void			*data)
+{
+	int			result = 0;
+	struct acpi_processor	*pr = (struct acpi_processor *) data;
+	char			state_string[12] = {'\0'};
+
+	ACPI_FUNCTION_TRACE("acpi_processor_write_performance");
+
+	if (!pr || (count > sizeof(state_string) - 1))
+		return_VALUE(-EINVAL);
+	
+	if (copy_from_user(state_string, buffer, count))
+		return_VALUE(-EFAULT);
+	
+	state_string[count] = '\0';
+
+	result = acpi_processor_set_performance(pr, 
+		simple_strtoul(state_string, NULL, 0));
+	if (result)
+		return_VALUE(result);
+
+	return_VALUE(count);
+}
+
+
+static int
+acpi_processor_read_throttling (
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	struct acpi_processor	*pr = (struct acpi_processor *) data;
+	char			*p = page;
+	int			len = 0;
+	int			i = 0;
+	int                     result = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_read_throttling");
+
+	if (!pr || (off != 0))
+		goto end;
+
+	if (!(pr->throttling.state_count > 0)) {
+		p += sprintf(p, "<not supported>\n");
+		goto end;
+	}
+
+	result = acpi_processor_get_throttling(pr);
+
+	if (result) {
+		p += sprintf(p, "Could not determine current throttling state.\n");
+		goto end;
+	}
+
+	p += sprintf(p, "state count:             %d\n",
+		pr->throttling.state_count);
+
+	p += sprintf(p, "active state:            T%d\n",
+		pr->throttling.state);
+
+	p += sprintf(p, "states:\n");
+
+	for (i=0; i<pr->throttling.state_count; i++)
+		p += sprintf(p, "   %cT%d:                  %02d%%\n",
+			(i == pr->throttling.state?'*':' '), i,
+			(pr->throttling.states[i].performance?pr->throttling.states[i].performance/10:0));
+
+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);
+}
+
+
+static int
+acpi_processor_write_throttling (
+        struct file		*file,
+        const char		*buffer,
+        unsigned long		count,
+        void			*data)
+{
+	int			result = 0;
+	struct acpi_processor	*pr = (struct acpi_processor *) data;
+	char			state_string[12] = {'\0'};
+
+	ACPI_FUNCTION_TRACE("acpi_processor_write_throttling");
+
+	if (!pr || (count > sizeof(state_string) - 1))
+		return_VALUE(-EINVAL);
+	
+	if (copy_from_user(state_string, buffer, count))
+		return_VALUE(-EFAULT);
+	
+	state_string[count] = '\0';
+	
+	result = acpi_processor_set_throttling(pr, 
+		simple_strtoul(state_string, NULL, 0));
+	if (result)
+		return_VALUE(result);
+
+	return_VALUE(count);
+}
+
+
+static int
+acpi_processor_read_limit (
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	struct acpi_processor	*pr = (struct acpi_processor *) data;
+	char			*p = page;
+	int			len = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_read_limit");
+
+	if (!pr || (off != 0))
+		goto end;
+
+	if (!pr->flags.limit) {
+		p += sprintf(p, "<not supported>\n");
+		goto end;
+	}
+
+	p += sprintf(p, "active limit:            P%d:T%d\n",
+		pr->limit.state.px, pr->limit.state.tx);
+
+	p += sprintf(p, "platform limit:          P%d:T0\n",
+		pr->flags.performance?pr->performance.platform_limit:0);
+
+	p += sprintf(p, "user limit:              P%d:T%d\n",
+		pr->limit.user.px, pr->limit.user.tx);
+
+	p += sprintf(p, "thermal limit:           P%d:T%d\n",
+		pr->limit.thermal.px, pr->limit.thermal.tx);
+
+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);
+}
+
+
+static int
+acpi_processor_write_limit (
+        struct file		*file,
+        const char		*buffer,
+        unsigned long		count,
+        void			*data)
+{
+	int			result = 0;
+	struct acpi_processor	*pr = (struct acpi_processor *) data;
+	char			limit_string[25] = {'\0'};
+	int			px = 0;
+	int			tx = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_write_limit");
+
+	if (!pr || (count > sizeof(limit_string) - 1)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument\n"));
+		return_VALUE(-EINVAL);
+	}
+	
+	if (copy_from_user(limit_string, buffer, count)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n"));
+		return_VALUE(-EFAULT);
+	}
+	
+	limit_string[count] = '\0';
+
+	if (sscanf(limit_string, "%d:%d", &px, &tx) != 2) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n"));
+		return_VALUE(-EINVAL);
+	}
+
+	if (pr->flags.performance) {
+		if ((px < pr->performance.platform_limit) 
+			|| (px > (pr->performance.state_count - 1))) {
+			ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid px\n"));
+			return_VALUE(-EINVAL);
+		}
+		pr->limit.user.px = px;
+	}
+
+	if (pr->flags.throttling) {
+		if ((tx < 0) || (tx > (pr->throttling.state_count - 1))) {
+			ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid tx\n"));
+			return_VALUE(-EINVAL);
+		}
+		pr->limit.user.tx = tx;
+	}
+
+	result = acpi_processor_apply_limit(pr);
+
+	return_VALUE(count);
+}
+
+
+static int
+acpi_processor_add_fs (
+	struct acpi_device	*device)
+{
+	struct proc_dir_entry	*entry = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_add_fs");
+
+	if (!acpi_device_dir(device)) {
+		acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
+			acpi_processor_dir);
+		if (!acpi_device_dir(device))
+			return_VALUE(-ENODEV);
+	}
+
+	/* 'info' [R] */
+	entry = create_proc_entry(ACPI_PROCESSOR_FILE_INFO,
+		S_IRUGO, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_PROCESSOR_FILE_INFO));
+	else {
+		entry->read_proc = acpi_processor_read_info;
+		entry->data = acpi_driver_data(device);
+	}
+
+	/* 'power' [R] */
+	entry = create_proc_entry(ACPI_PROCESSOR_FILE_POWER,
+		S_IRUGO, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_PROCESSOR_FILE_POWER));
+	else {
+		entry->read_proc = acpi_processor_read_power;
+		entry->data = acpi_driver_data(device);
+	}
+
+	/* 'performance' [R/W] */
+	entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE,
+		S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_PROCESSOR_FILE_PERFORMANCE));
+	else {
+		entry->read_proc = acpi_processor_read_performance;
+		entry->write_proc = acpi_processor_write_performance;
+		entry->data = acpi_driver_data(device);
+	}
+
+	/* 'throttling' [R/W] */
+	entry = create_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING,
+		S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_PROCESSOR_FILE_THROTTLING));
+	else {
+		entry->read_proc = acpi_processor_read_throttling;
+		entry->write_proc = acpi_processor_write_throttling;
+		entry->data = acpi_driver_data(device);
+	}
+
+	/* 'limit' [R/W] */
+	entry = create_proc_entry(ACPI_PROCESSOR_FILE_LIMIT,
+		S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_PROCESSOR_FILE_LIMIT));
+	else {
+		entry->read_proc = acpi_processor_read_limit;
+		entry->write_proc = acpi_processor_write_limit;
+		entry->data = acpi_driver_data(device);
+	}
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_processor_remove_fs (
+	struct acpi_device	*device)
+{
+	ACPI_FUNCTION_TRACE("acpi_processor_remove_fs");
+
+	if (acpi_device_dir(device)) {
+		remove_proc_entry(acpi_device_bid(device), acpi_processor_dir);
+		acpi_device_dir(device) = NULL;
+	}
+
+	return_VALUE(0);
+}
+
+
+/* --------------------------------------------------------------------------
+                                 Driver Interface
+   -------------------------------------------------------------------------- */
+
+static int
+acpi_processor_get_info (
+	struct acpi_processor	*pr)
+{
+	acpi_status		status = 0;
+	union acpi_object	object = {0};
+	struct acpi_buffer	buffer = {sizeof(union acpi_object), &object};
+	static int		cpu_index = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_get_info");
+
+	if (!pr)
+		return_VALUE(-EINVAL);
+
+#ifdef CONFIG_SMP
+	if (smp_num_cpus > 1)
+		errata.smp = smp_num_cpus;
+
+	/*
+	 *  Extra Processor objects may be enumerated on MP systems with
+	 *  less than the max # of CPUs. They should be ignored.
+	 */
+	if ((cpu_index + 1) > smp_num_cpus)
+		return_VALUE(-ENODEV);
+#endif
+
+	acpi_processor_errata(pr);
+
+	/*
+	 * Check to see if we have bus mastering arbitration control.  This
+	 * is required for proper C3 usage (to maintain cache coherency).
+	 */
+	if (acpi_fadt.V1_pm2_cnt_blk && acpi_fadt.pm2_cnt_len) {
+		pr->flags.bm_control = 1;
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+			"Bus mastering arbitration control present\n"));
+	}
+	else
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+			"No bus mastering arbitration control\n"));
+
+	/*
+	 * Evalute the processor object.  Note that it is common on SMP to
+	 * have the first (boot) processor with a valid PBLK address while
+	 * all others have a NULL address.
+	 */
+	status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Error evaluating processor object\n"));
+		return_VALUE(-ENODEV);
+	}
+
+	/*
+	 * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP.
+	 *	>>> 'acpi_get_processor_id(acpi_id, &id)' in arch/xxx/acpi.c
+	 */
+	pr->id = cpu_index++;
+	pr->acpi_id = object.processor.proc_id;
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d:%d]\n", pr->id, 
+		pr->acpi_id));
+
+	if (!object.processor.pblk_address)
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n"));
+	else if (object.processor.pblk_length != 6)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid PBLK length [%d]\n",
+			object.processor.pblk_length));
+	else {
+		pr->throttling.address = object.processor.pblk_address;
+		pr->throttling.duty_offset = acpi_fadt.duty_offset;
+		pr->throttling.duty_width = acpi_fadt.duty_width;
+		pr->power.states[ACPI_STATE_C2].address =
+			object.processor.pblk_address + 4;
+		pr->power.states[ACPI_STATE_C3].address =
+			object.processor.pblk_address + 5;
+	}
+
+	acpi_processor_get_power_info(pr);
+	acpi_processor_get_performance_info(pr);
+	acpi_processor_get_throttling_info(pr);
+	acpi_processor_get_limit_info(pr);
+
+	return_VALUE(0);
+}
+
+
+static void
+acpi_processor_notify (
+	acpi_handle		handle,
+	u32			event,
+	void			*data)
+{
+	int			result = 0;
+	struct acpi_processor	*pr = (struct acpi_processor *) data;
+	struct acpi_device	*device = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_notify");
+
+	if (!pr)
+		return_VOID;
+
+	if (acpi_bus_get_device(pr->handle, &device))
+		return_VOID;
+
+	switch (event) {
+	case ACPI_PROCESSOR_NOTIFY_PERFORMANCE:
+		result = acpi_processor_get_platform_limit(pr);
+		if (!result)
+			acpi_processor_apply_limit(pr);
+
+		acpi_bus_generate_event(device, event, 
+			pr->performance.platform_limit);
+		break;
+	case ACPI_PROCESSOR_NOTIFY_POWER:
+		/* TBD */
+		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_processor_add (
+	struct acpi_device	*device)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	struct acpi_processor	*pr = NULL;
+	u32			i = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_add");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	pr = kmalloc(sizeof(struct acpi_processor), GFP_KERNEL);
+	if (!pr)
+		return_VALUE(-ENOMEM);
+	memset(pr, 0, sizeof(struct acpi_processor));
+
+	pr->handle = device->handle;
+	sprintf(acpi_device_name(device), "%s", ACPI_PROCESSOR_DEVICE_NAME);
+	sprintf(acpi_device_class(device), "%s", ACPI_PROCESSOR_CLASS);
+	acpi_driver_data(device) = pr;
+
+	result = acpi_processor_get_info(pr);
+	if (result)
+		goto end;
+
+	result = acpi_processor_add_fs(device);
+	if (result)
+		goto end;
+
+	status = acpi_install_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, 
+		acpi_processor_notify, pr);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 
+			"Error installing notify handler\n"));
+		result = -ENODEV;
+		goto end;
+	}
+
+	processors[pr->id] = pr;
+
+	/*
+	 * Install the idle handler if processor power management is supported.
+	 * Note that the default idle handler (default_idle) 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;
+	}
+	
+	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.performance)
+		printk(", %d performance states", pr->performance.state_count);
+	if (pr->flags.throttling)
+		printk(", %d throttling states", pr->throttling.state_count);
+	printk(")\n");
+
+end:
+	if (result) {
+		acpi_processor_remove_fs(device);
+		kfree(pr);
+	}
+
+	return_VALUE(result);
+}
+
+
+static int
+acpi_processor_remove (
+	struct acpi_device	*device,
+	int			type)
+{
+	acpi_status		status = AE_OK;
+	struct acpi_processor	*pr = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_remove");
+
+	if (!device || !acpi_driver_data(device))
+		return_VALUE(-EINVAL);
+
+	pr = (struct acpi_processor *) acpi_driver_data(device);
+
+	/* Unregister the idle handler when processor #0 is removed. */
+	if (pr->id == 0)
+		pm_idle = pm_idle_save;
+
+	status = acpi_remove_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, 
+		acpi_processor_notify);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 
+			"Error removing notify handler\n"));
+		return_VALUE(-ENODEV);
+	}
+
+	acpi_processor_remove_fs(device);
+
+	processors[pr->id] = NULL;
+
+	kfree(pr);
+
+	return_VALUE(0);
+}
+
+
+static int __init
+acpi_processor_init (void)
+{
+	int			result = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_init");
+
+	memset(&processors, 0, sizeof(processors));
+	memset(&errata, 0, sizeof(errata));
+
+	acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir);
+	if (!acpi_processor_dir)
+		return_VALUE(-ENODEV);
+
+	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);
+}
+
+
+static void __exit
+acpi_processor_exit (void)
+{
+	ACPI_FUNCTION_TRACE("acpi_processor_exit");
+
+	acpi_bus_unregister_driver(&acpi_processor_driver);
+
+	remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
+
+	return_VOID;
+}
+
+
+module_init(acpi_processor_init);
+module_exit(acpi_processor_exit);
+
+EXPORT_SYMBOL(acpi_processor_set_thermal_limit);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/resources/Makefile linux-2.4.22-pre2/drivers/acpi/resources/Makefile
--- linux-2.4.21/drivers/acpi/resources/Makefile	2001-06-21 00:47:40.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/resources/Makefile	2003-06-26 21:43:12.000000000 +0000
@@ -1,11 +1,10 @@
 #
 # Makefile for all Linux ACPI interpreter subdirectories
-# EXCEPT for the ospm directory
 #
 
 O_TARGET := $(notdir $(CURDIR)).o
 
-obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/resources/rsaddr.c linux-2.4.22-pre2/drivers/acpi/resources/rsaddr.c
--- linux-2.4.21/drivers/acpi/resources/rsaddr.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/resources/rsaddr.c	2003-06-26 21:43:10.000000000 +0000
@@ -1,81 +1,98 @@
 /*******************************************************************************
  *
  * Module Name: rsaddr - Address resource descriptors (16/32/64)
- *              $Revision: 19 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acresrc.h"
+#include <acpi/acpi.h>
+#include <acpi/acresrc.h>
 
 #define _COMPONENT          ACPI_RESOURCES
-	 MODULE_NAME         ("rsaddr")
+	 ACPI_MODULE_NAME    ("rsaddr")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_address16_resource
+ * FUNCTION:    acpi_rs_address16_resource
  *
- * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
+ * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the byte_stream_buffer is
+ *                                        returned
+ *              output_buffer           - Pointer to the return data buffer
+ *              structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the Output_buffer. Return the
+ *              structure pointed to by the output_buffer. Return the
  *              number of bytes consumed from the byte stream.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_rs_address16_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size)
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size)
 {
-	u8                      *buffer = byte_stream_buffer;
-	acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
-	NATIVE_CHAR             *temp_ptr;
-	u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_address16);
-	u32                     index;
-	u16                     temp16;
-	u8                      temp8;
+	u8                              *buffer = byte_stream_buffer;
+	struct acpi_resource            *output_struct = (void *) *output_buffer;
+	u8                              *temp_ptr;
+	acpi_size                       struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address16);
+	u32                             index;
+	u16                             temp16;
+	u8                              temp8;
 
 
-	FUNCTION_TRACE ("Rs_address16_resource");
+	ACPI_FUNCTION_TRACE ("rs_address16_resource");
 
 	/*
 	 * Point past the Descriptor to get the number of bytes consumed
 	 */
 	buffer += 1;
-	MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 	*bytes_consumed = temp16 + 3;
 	output_struct->id = ACPI_RSTYPE_ADDRESS16;
@@ -87,6 +104,7 @@
 	temp8 = *buffer;
 
 	/* Values 0-2 are valid */
+
 	if (temp8 > 2) {
 		return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
 	}
@@ -99,24 +117,20 @@
 	buffer += 1;
 	temp8 = *buffer;
 
-	/*
-	 * Producer / Consumer
-	 */
+	/* Producer / Consumer */
+
 	output_struct->data.address16.producer_consumer = temp8 & 0x01;
 
-	/*
-	 * Decode
-	 */
+	/* Decode */
+
 	output_struct->data.address16.decode = (temp8 >> 1) & 0x01;
 
-	/*
-	 * Min Address Fixed
-	 */
+	/* Min Address Fixed */
+
 	output_struct->data.address16.min_address_fixed = (temp8 >> 2) & 0x01;
 
-	/*
-	 * Max Address Fixed
-	 */
+	/* Max Address Fixed */
+
 	output_struct->data.address16.max_address_fixed = (temp8 >> 3) & 0x01;
 
 	/*
@@ -125,21 +139,21 @@
 	buffer += 1;
 	temp8 = *buffer;
 
-	if (MEMORY_RANGE == output_struct->data.address16.resource_type) {
+	if (ACPI_MEMORY_RANGE == output_struct->data.address16.resource_type) {
 		output_struct->data.address16.attribute.memory.read_write_attribute =
 				(u16) (temp8 & 0x01);
 		output_struct->data.address16.attribute.memory.cache_attribute =
 				(u16) ((temp8 >> 1) & 0x0F);
 	}
-
 	else {
-		if (IO_RANGE == output_struct->data.address16.resource_type) {
+		if (ACPI_IO_RANGE == output_struct->data.address16.resource_type) {
 			output_struct->data.address16.attribute.io.range_attribute =
 				(u16) (temp8 & 0x03);
+			output_struct->data.address16.attribute.io.translation_attribute =
+				(u16) ((temp8 >> 4) & 0x03);
 		}
-
 		else {
-			/* BUS_NUMBER_RANGE == Address16.Data->Resource_type */
+			/* BUS_NUMBER_RANGE == Address16.Data->resource_type */
 			/* Nothing needs to be filled in */
 		}
 	}
@@ -148,36 +162,31 @@
 	 * Get Granularity (Bytes 6-7)
 	 */
 	buffer += 1;
-	MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.granularity,
-			 buffer);
+	ACPI_MOVE_16_TO_32 (&output_struct->data.address16.granularity, buffer);
 
 	/*
-	 * Get Min_address_range (Bytes 8-9)
+	 * Get min_address_range (Bytes 8-9)
 	 */
 	buffer += 2;
-	MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.min_address_range,
-			 buffer);
+	ACPI_MOVE_16_TO_32 (&output_struct->data.address16.min_address_range, buffer);
 
 	/*
-	 * Get Max_address_range (Bytes 10-11)
+	 * Get max_address_range (Bytes 10-11)
 	 */
 	buffer += 2;
-	MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.max_address_range,
-			 buffer);
+	ACPI_MOVE_16_TO_32 (&output_struct->data.address16.max_address_range, buffer);
 
 	/*
-	 * Get Address_translation_offset (Bytes 12-13)
+	 * Get address_translation_offset (Bytes 12-13)
 	 */
 	buffer += 2;
-	MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.address_translation_offset,
-			 buffer);
+	ACPI_MOVE_16_TO_32 (&output_struct->data.address16.address_translation_offset, buffer);
 
 	/*
-	 * Get Address_length (Bytes 14-15)
+	 * Get address_length (Bytes 14-15)
 	 */
 	buffer += 2;
-	MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.address_length,
-			 buffer);
+	ACPI_MOVE_16_TO_32 (&output_struct->data.address16.address_length, buffer);
 
 	/*
 	 * Resource Source Index (if present)
@@ -204,9 +213,9 @@
 		/* Point the String pointer to the end of this structure */
 
 		output_struct->data.address16.resource_source.string_ptr =
-				(NATIVE_CHAR *)((u8 * )output_struct + struct_size);
+				(char *)((u8 * )output_struct + struct_size);
 
-		temp_ptr = output_struct->data.address16.resource_source.string_ptr;
+		temp_ptr = (u8 *) output_struct->data.address16.resource_source.string_ptr;
 
 		/* Copy the string into the buffer */
 
@@ -228,14 +237,13 @@
 		output_struct->data.address16.resource_source.string_length = index + 1;
 
 		/*
-		 * In order for the Struct_size to fall on a 32-bit boundary,
+		 * In order for the struct_size to fall on a 32-bit boundary,
 		 * calculate the length of the string and expand the
-		 * Struct_size to the next 32-bit boundary.
+		 * struct_size to the next 32-bit boundary.
 		 */
 		temp8 = (u8) (index + 1);
-		struct_size += ROUND_UP_TO_32_bITS (temp8);
+		struct_size += ACPI_ROUND_UP_to_32_bITS (temp8);
 	}
-
 	else {
 		output_struct->data.address16.resource_source.index = 0x00;
 		output_struct->data.address16.resource_source.string_length = 0;
@@ -245,7 +253,7 @@
 	/*
 	 * Set the Length parameter
 	 */
-	output_struct->length = struct_size;
+	output_struct->length = (u32) struct_size;
 
 	/*
 	 * Return the final size of the structure
@@ -257,13 +265,12 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_address16_stream
+ * FUNCTION:    acpi_rs_address16_stream
  *
- * PARAMETERS:  Linked_list             - Pointer to the resource linked list
- *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ * PARAMETERS:  linked_list             - Pointer to the resource linked list
+ *              output_buffer           - Pointer to the user's return buffer
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -274,18 +281,18 @@
 
 acpi_status
 acpi_rs_address16_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed)
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed)
 {
-	u8                      *buffer = *output_buffer;
-	u8                      *length_field;
-	u8                      temp8;
-	NATIVE_CHAR             *temp_pointer = NULL;
-	u32                     actual_bytes;
+	u8                              *buffer = *output_buffer;
+	u8                              *length_field;
+	u8                              temp8;
+	char                            *temp_pointer = NULL;
+	acpi_size                       actual_bytes;
 
 
-	FUNCTION_TRACE ("Rs_address16_stream");
+	ACPI_FUNCTION_TRACE ("rs_address16_stream");
 
 
 	/*
@@ -301,7 +308,7 @@
 	buffer += 2;
 
 	/*
-	 * Set the Resource Type (Memory, Io, Bus_number)
+	 * Set the Resource Type (Memory, Io, bus_number)
 	 */
 	temp8 = (u8) (linked_list->data.address16.resource_type & 0x03);
 	*buffer = temp8;
@@ -324,7 +331,7 @@
 	 */
 	temp8 = 0;
 
-	if (MEMORY_RANGE == linked_list->data.address16.resource_type) {
+	if (ACPI_MEMORY_RANGE == linked_list->data.address16.resource_type) {
 		temp8 = (u8)
 			(linked_list->data.address16.attribute.memory.read_write_attribute &
 			 0x01);
@@ -333,11 +340,13 @@
 			(linked_list->data.address16.attribute.memory.cache_attribute &
 			 0x0F) << 1;
 	}
-
-	else if (IO_RANGE == linked_list->data.address16.resource_type) {
+	else if (ACPI_IO_RANGE == linked_list->data.address16.resource_type) {
 		temp8 = (u8)
 			(linked_list->data.address16.attribute.io.range_attribute &
 			 0x03);
+		temp8 |=
+			(linked_list->data.address16.attribute.io.translation_attribute &
+			 0x03) << 4;
 	}
 
 	*buffer = temp8;
@@ -346,36 +355,31 @@
 	/*
 	 * Set the address space granularity
 	 */
-	MOVE_UNALIGNED16_TO_16 (buffer,
-			   &linked_list->data.address16.granularity);
+	ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.granularity);
 	buffer += 2;
 
 	/*
 	 * Set the address range minimum
 	 */
-	MOVE_UNALIGNED16_TO_16 (buffer,
-			   &linked_list->data.address16.min_address_range);
+	ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.min_address_range);
 	buffer += 2;
 
 	/*
 	 * Set the address range maximum
 	 */
-	MOVE_UNALIGNED16_TO_16 (buffer,
-			   &linked_list->data.address16.max_address_range);
+	ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.max_address_range);
 	buffer += 2;
 
 	/*
 	 * Set the address translation offset
 	 */
-	MOVE_UNALIGNED16_TO_16 (buffer,
-			   &linked_list->data.address16.address_translation_offset);
+	ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.address_translation_offset);
 	buffer += 2;
 
 	/*
 	 * Set the address length
 	 */
-	MOVE_UNALIGNED16_TO_16 (buffer,
-			   &linked_list->data.address16.address_length);
+	ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.address_length);
 	buffer += 2;
 
 	/*
@@ -387,26 +391,25 @@
 		*buffer = temp8;
 		buffer += 1;
 
-		temp_pointer = (NATIVE_CHAR *) buffer;
+		temp_pointer = (char *) buffer;
 
 		/*
 		 * Copy the string
 		 */
-		STRCPY (temp_pointer,
+		ACPI_STRCPY (temp_pointer,
 				linked_list->data.address16.resource_source.string_ptr);
 
 		/*
 		 * Buffer needs to be set to the length of the sting + one for the
 		 *  terminating null
 		 */
-		buffer += (STRLEN (linked_list->data.address16.resource_source.string_ptr)
-				 + 1);
+		buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.address16.resource_source.string_ptr) + 1);
 	}
 
 	/*
 	 * Return the number of bytes consumed in this operation
 	 */
-	actual_bytes = POINTER_DIFF (buffer, *output_buffer);
+	actual_bytes = ACPI_PTR_DIFF (buffer, *output_buffer);
 	*bytes_consumed = actual_bytes;
 
 	/*
@@ -414,63 +417,59 @@
 	 * minus the header size (3 bytes)
 	 */
 	actual_bytes -= 3;
-	MOVE_UNALIGNED16_TO_16 (length_field, &actual_bytes);
+	ACPI_MOVE_SIZE_TO_16 (length_field, &actual_bytes);
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_address32_resource
+ * FUNCTION:    acpi_rs_address32_resource
  *
- * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
+ * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the byte_stream_buffer is
+ *                                        returned
+ *              output_buffer           - Pointer to the return data buffer
+ *              structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the Output_buffer. Return the
+ *              structure pointed to by the output_buffer. Return the
  *              number of bytes consumed from the byte stream.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_rs_address32_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size)
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size)
 {
-	u8                      *buffer;
-	acpi_resource           *output_struct;
-	u16                     temp16;
-	u8                      temp8;
-	NATIVE_CHAR             *temp_ptr;
-	u32                     struct_size;
-	u32                     index;
+	u8                              *buffer;
+	struct acpi_resource            *output_struct= (void *) *output_buffer;
+	u16                             temp16;
+	u8                              temp8;
+	u8                              *temp_ptr;
+	acpi_size                       struct_size;
+	u32                             index;
 
 
-	FUNCTION_TRACE ("Rs_address32_resource");
+	ACPI_FUNCTION_TRACE ("rs_address32_resource");
 
 
 	buffer = byte_stream_buffer;
-	output_struct = (acpi_resource *) *output_buffer;
-
-	struct_size = SIZEOF_RESOURCE (acpi_resource_address32);
+	struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address32);
 
 	/*
 	 * Point past the Descriptor to get the number of bytes consumed
 	 */
 	buffer += 1;
-	MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
-
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 	*bytes_consumed = temp16 + 3;
 
 	output_struct->id = ACPI_RSTYPE_ADDRESS32;
@@ -520,22 +519,22 @@
 	buffer += 1;
 	temp8 = *buffer;
 
-	if (MEMORY_RANGE == output_struct->data.address32.resource_type) {
+	if (ACPI_MEMORY_RANGE == output_struct->data.address32.resource_type) {
 		output_struct->data.address32.attribute.memory.read_write_attribute =
 				(u16) (temp8 & 0x01);
 
 		output_struct->data.address32.attribute.memory.cache_attribute =
 				(u16) ((temp8 >> 1) & 0x0F);
 	}
-
 	else {
-		if (IO_RANGE == output_struct->data.address32.resource_type) {
+		if (ACPI_IO_RANGE == output_struct->data.address32.resource_type) {
 			output_struct->data.address32.attribute.io.range_attribute =
 				(u16) (temp8 & 0x03);
+			output_struct->data.address32.attribute.io.translation_attribute =
+				(u16) ((temp8 >> 4) & 0x03);
 		}
-
 		else {
-			/* BUS_NUMBER_RANGE == Output_struct->Data.Address32.Resource_type */
+			/* BUS_NUMBER_RANGE == output_struct->Data.Address32.resource_type */
 			/* Nothing needs to be filled in */
 		}
 	}
@@ -544,36 +543,31 @@
 	 * Get Granularity (Bytes 6-9)
 	 */
 	buffer += 1;
-	MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.granularity,
-			 buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.address32.granularity, buffer);
 
 	/*
-	 * Get Min_address_range (Bytes 10-13)
+	 * Get min_address_range (Bytes 10-13)
 	 */
 	buffer += 4;
-	MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.min_address_range,
-			 buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.address32.min_address_range, buffer);
 
 	/*
-	 * Get Max_address_range (Bytes 14-17)
+	 * Get max_address_range (Bytes 14-17)
 	 */
 	buffer += 4;
-	MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.max_address_range,
-			 buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.address32.max_address_range, buffer);
 
 	/*
-	 * Get Address_translation_offset (Bytes 18-21)
+	 * Get address_translation_offset (Bytes 18-21)
 	 */
 	buffer += 4;
-	MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.address_translation_offset,
-			 buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.address32.address_translation_offset, buffer);
 
 	/*
-	 * Get Address_length (Bytes 22-25)
+	 * Get address_length (Bytes 22-25)
 	 */
 	buffer += 4;
-	MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.address_length,
-			 buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.address32.address_length, buffer);
 
 	/*
 	 * Resource Source Index (if present)
@@ -599,14 +593,13 @@
 		/* Point the String pointer to the end of this structure */
 
 		output_struct->data.address32.resource_source.string_ptr =
-				(NATIVE_CHAR *)((u8 *)output_struct + struct_size);
+				(char *)((u8 *)output_struct + struct_size);
 
-		temp_ptr = output_struct->data.address32.resource_source.string_ptr;
+		temp_ptr = (u8 *) output_struct->data.address32.resource_source.string_ptr;
 
 		/* Copy the string into the buffer */
 
 		index = 0;
-
 		while (0x00 != *buffer) {
 			*temp_ptr = *buffer;
 
@@ -622,14 +615,13 @@
 		output_struct->data.address32.resource_source.string_length = index + 1;
 
 		/*
-		 * In order for the Struct_size to fall on a 32-bit boundary,
+		 * In order for the struct_size to fall on a 32-bit boundary,
 		 *  calculate the length of the string and expand the
-		 *  Struct_size to the next 32-bit boundary.
+		 *  struct_size to the next 32-bit boundary.
 		 */
 		temp8 = (u8) (index + 1);
-		struct_size += ROUND_UP_TO_32_bITS (temp8);
+		struct_size += ACPI_ROUND_UP_to_32_bITS (temp8);
 	}
-
 	else {
 		output_struct->data.address32.resource_source.index = 0x00;
 		output_struct->data.address32.resource_source.string_length = 0;
@@ -639,7 +631,7 @@
 	/*
 	 * Set the Length parameter
 	 */
-	output_struct->length = struct_size;
+	output_struct->length = (u32) struct_size;
 
 	/*
 	 * Return the final size of the structure
@@ -651,13 +643,12 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_address32_stream
+ * FUNCTION:    acpi_rs_address32_stream
  *
- * PARAMETERS:  Linked_list             - Pointer to the resource linked list
- *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ * PARAMETERS:  linked_list             - Pointer to the resource linked list
+ *              output_buffer           - Pointer to the user's return buffer
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -668,17 +659,17 @@
 
 acpi_status
 acpi_rs_address32_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed)
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed)
 {
-	u8                      *buffer;
-	u16                     *length_field;
-	u8                      temp8;
-	NATIVE_CHAR             *temp_pointer;
+	u8                              *buffer;
+	u16                             *length_field;
+	u8                              temp8;
+	char                            *temp_pointer;
 
 
-	FUNCTION_TRACE ("Rs_address32_stream");
+	ACPI_FUNCTION_TRACE ("rs_address32_stream");
 
 
 	buffer = *output_buffer;
@@ -692,12 +683,11 @@
 	/*
 	 * Set a pointer to the Length field - to be filled in later
 	 */
-
-	length_field = (u16 *) buffer;
+	length_field = ACPI_CAST_PTR (u16, buffer);
 	buffer += 2;
 
 	/*
-	 * Set the Resource Type (Memory, Io, Bus_number)
+	 * Set the Resource Type (Memory, Io, bus_number)
 	 */
 	temp8 = (u8) (linked_list->data.address32.resource_type & 0x03);
 
@@ -720,7 +710,7 @@
 	 */
 	temp8 = 0;
 
-	if(MEMORY_RANGE == linked_list->data.address32.resource_type) {
+	if (ACPI_MEMORY_RANGE == linked_list->data.address32.resource_type) {
 		temp8 = (u8)
 			(linked_list->data.address32.attribute.memory.read_write_attribute &
 			0x01);
@@ -729,11 +719,13 @@
 			(linked_list->data.address32.attribute.memory.cache_attribute &
 			 0x0F) << 1;
 	}
-
-	else if (IO_RANGE == linked_list->data.address32.resource_type) {
+	else if (ACPI_IO_RANGE == linked_list->data.address32.resource_type) {
 		temp8 = (u8)
 			(linked_list->data.address32.attribute.io.range_attribute &
 			 0x03);
+		temp8 |=
+			(linked_list->data.address32.attribute.io.translation_attribute &
+			 0x03) << 4;
 	}
 
 	*buffer = temp8;
@@ -742,36 +734,31 @@
 	/*
 	 * Set the address space granularity
 	 */
-	MOVE_UNALIGNED32_TO_32 (buffer,
-			  &linked_list->data.address32.granularity);
+	ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.granularity);
 	buffer += 4;
 
 	/*
 	 * Set the address range minimum
 	 */
-	MOVE_UNALIGNED32_TO_32 (buffer,
-			  &linked_list->data.address32.min_address_range);
+	ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.min_address_range);
 	buffer += 4;
 
 	/*
 	 * Set the address range maximum
 	 */
-	MOVE_UNALIGNED32_TO_32 (buffer,
-			  &linked_list->data.address32.max_address_range);
+	ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.max_address_range);
 	buffer += 4;
 
 	/*
 	 * Set the address translation offset
 	 */
-	MOVE_UNALIGNED32_TO_32 (buffer,
-			  &linked_list->data.address32.address_translation_offset);
+	ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.address_translation_offset);
 	buffer += 4;
 
 	/*
 	 * Set the address length
 	 */
-	MOVE_UNALIGNED32_TO_32 (buffer,
-			  &linked_list->data.address32.address_length);
+	ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.address_length);
 	buffer += 4;
 
 	/*
@@ -783,25 +770,25 @@
 		*buffer = temp8;
 		buffer += 1;
 
-		temp_pointer = (NATIVE_CHAR *) buffer;
+		temp_pointer = (char *) buffer;
 
 		/*
 		 * Copy the string
 		 */
-		STRCPY (temp_pointer,
+		ACPI_STRCPY (temp_pointer,
 			linked_list->data.address32.resource_source.string_ptr);
 
 		/*
 		 * Buffer needs to be set to the length of the sting + one for the
 		 *  terminating null
 		 */
-		buffer += (STRLEN (linked_list->data.address32.resource_source.string_ptr) + 1);
+		buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.address32.resource_source.string_ptr) + 1);
 	}
 
 	/*
 	 * Return the number of bytes consumed in this operation
 	 */
-	*bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+	*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
 
 	/*
 	 * Set the length field to the number of bytes consumed
@@ -814,55 +801,52 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_address64_resource
+ * FUNCTION:    acpi_rs_address64_resource
  *
- * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
+ * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the byte_stream_buffer is
+ *                                        returned
+ *              output_buffer           - Pointer to the return data buffer
+ *              structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the Output_buffer. Return the
+ *              structure pointed to by the output_buffer. Return the
  *              number of bytes consumed from the byte stream.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_rs_address64_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size)
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size)
 {
-	u8                      *buffer;
-	acpi_resource           *output_struct;
-	u16                     temp16;
-	u8                      temp8;
-	NATIVE_CHAR             *temp_ptr;
-	u32                     struct_size;
-	u32                     index;
+	u8                              *buffer;
+	struct acpi_resource            *output_struct = (void *) *output_buffer;
+	u16                             temp16;
+	u8                              temp8;
+	u8                              *temp_ptr;
+	acpi_size                       struct_size;
+	u32                             index;
 
 
-	FUNCTION_TRACE ("Rs_address64_resource");
+	ACPI_FUNCTION_TRACE ("rs_address64_resource");
 
 
 	buffer = byte_stream_buffer;
-	output_struct = (acpi_resource *) *output_buffer;
-
-	struct_size = SIZEOF_RESOURCE (acpi_resource_address64);
+	struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address64);
 
 	/*
 	 * Point past the Descriptor to get the number of bytes consumed
 	 */
 	buffer += 1;
-	MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 	*bytes_consumed = temp16 + 3;
 	output_struct->id = ACPI_RSTYPE_ADDRESS64;
@@ -874,6 +858,7 @@
 	temp8 = *buffer;
 
 	/* Values 0-2 are valid */
+
 	if(temp8 > 2) {
 		return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
 	}
@@ -912,22 +897,22 @@
 	buffer += 1;
 	temp8 = *buffer;
 
-	if (MEMORY_RANGE == output_struct->data.address64.resource_type) {
+	if (ACPI_MEMORY_RANGE == output_struct->data.address64.resource_type) {
 		output_struct->data.address64.attribute.memory.read_write_attribute =
 				(u16) (temp8 & 0x01);
 
 		output_struct->data.address64.attribute.memory.cache_attribute =
 				(u16) ((temp8 >> 1) & 0x0F);
 	}
-
 	else {
-		if (IO_RANGE == output_struct->data.address64.resource_type) {
+		if (ACPI_IO_RANGE == output_struct->data.address64.resource_type) {
 			output_struct->data.address64.attribute.io.range_attribute =
 				(u16) (temp8 & 0x03);
+			output_struct->data.address64.attribute.io.translation_attribute =
+				(u16) ((temp8 >> 4) & 0x03);
 		}
-
 		else {
-			/* BUS_NUMBER_RANGE == Output_struct->Data.Address64.Resource_type */
+			/* BUS_NUMBER_RANGE == output_struct->Data.Address64.resource_type */
 			/* Nothing needs to be filled in */
 		}
 	}
@@ -936,36 +921,31 @@
 	 * Get Granularity (Bytes 6-13)
 	 */
 	buffer += 1;
-	MOVE_UNALIGNED64_TO_64 (&output_struct->data.address64.granularity,
-			 buffer);
+	ACPI_MOVE_64_TO_64 (&output_struct->data.address64.granularity, buffer);
 
 	/*
-	 * Get Min_address_range (Bytes 14-21)
+	 * Get min_address_range (Bytes 14-21)
 	 */
 	buffer += 8;
-	MOVE_UNALIGNED64_TO_64 (&output_struct->data.address64.min_address_range,
-			 buffer);
+	ACPI_MOVE_64_TO_64 (&output_struct->data.address64.min_address_range, buffer);
 
 	/*
-	 * Get Max_address_range (Bytes 22-29)
+	 * Get max_address_range (Bytes 22-29)
 	 */
 	buffer += 8;
-	MOVE_UNALIGNED64_TO_64 (&output_struct->data.address64.max_address_range,
-			 buffer);
+	ACPI_MOVE_64_TO_64 (&output_struct->data.address64.max_address_range, buffer);
 
 	/*
-	 * Get Address_translation_offset (Bytes 30-37)
+	 * Get address_translation_offset (Bytes 30-37)
 	 */
 	buffer += 8;
-	MOVE_UNALIGNED64_TO_64 (&output_struct->data.address64.address_translation_offset,
-			 buffer);
+	ACPI_MOVE_64_TO_64 (&output_struct->data.address64.address_translation_offset, buffer);
 
 	/*
-	 * Get Address_length (Bytes 38-45)
+	 * Get address_length (Bytes 38-45)
 	 */
 	buffer += 8;
-	MOVE_UNALIGNED64_TO_64 (&output_struct->data.address64.address_length,
-			 buffer);
+	ACPI_MOVE_64_TO_64 (&output_struct->data.address64.address_length, buffer);
 
 	/*
 	 * Resource Source Index (if present)
@@ -993,14 +973,13 @@
 		/* Point the String pointer to the end of this structure */
 
 		output_struct->data.address64.resource_source.string_ptr =
-				(NATIVE_CHAR *)((u8 *)output_struct + struct_size);
+				(char *)((u8 *)output_struct + struct_size);
 
-		temp_ptr = output_struct->data.address64.resource_source.string_ptr;
+		temp_ptr = (u8 *) output_struct->data.address64.resource_source.string_ptr;
 
 		/* Copy the string into the buffer */
 
 		index = 0;
-
 		while (0x00 != *buffer) {
 			*temp_ptr = *buffer;
 
@@ -1017,14 +996,13 @@
 		output_struct->data.address64.resource_source.string_length = index + 1;
 
 		/*
-		 * In order for the Struct_size to fall on a 32-bit boundary,
+		 * In order for the struct_size to fall on a 32-bit boundary,
 		 * calculate the length of the string and expand the
-		 * Struct_size to the next 32-bit boundary.
+		 * struct_size to the next 32-bit boundary.
 		 */
 		temp8 = (u8) (index + 1);
-		struct_size += ROUND_UP_TO_32_bITS (temp8);
+		struct_size += ACPI_ROUND_UP_to_32_bITS (temp8);
 	}
-
 	else {
 		output_struct->data.address64.resource_source.index = 0x00;
 		output_struct->data.address64.resource_source.string_length = 0;
@@ -1034,7 +1012,7 @@
 	/*
 	 * Set the Length parameter
 	 */
-	output_struct->length = struct_size;
+	output_struct->length = (u32) struct_size;
 
 	/*
 	 * Return the final size of the structure
@@ -1046,13 +1024,12 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_address64_stream
+ * FUNCTION:    acpi_rs_address64_stream
  *
- * PARAMETERS:  Linked_list             - Pointer to the resource linked list
- *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ * PARAMETERS:  linked_list             - Pointer to the resource linked list
+ *              output_buffer           - Pointer to the user's return buffer
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -1063,17 +1040,17 @@
 
 acpi_status
 acpi_rs_address64_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed)
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed)
 {
-	u8                      *buffer;
-	u16                     *length_field;
-	u8                      temp8;
-	NATIVE_CHAR             *temp_pointer;
+	u8                              *buffer;
+	u16                             *length_field;
+	u8                              temp8;
+	char                            *temp_pointer;
 
 
-	FUNCTION_TRACE ("Rs_address64_stream");
+	ACPI_FUNCTION_TRACE ("rs_address64_stream");
 
 
 	buffer = *output_buffer;
@@ -1088,11 +1065,11 @@
 	 * Set a pointer to the Length field - to be filled in later
 	 */
 
-	length_field = (u16 *)buffer;
+	length_field = ACPI_CAST_PTR (u16, buffer);
 	buffer += 2;
 
 	/*
-	 * Set the Resource Type (Memory, Io, Bus_number)
+	 * Set the Resource Type (Memory, Io, bus_number)
 	 */
 	temp8 = (u8) (linked_list->data.address64.resource_type & 0x03);
 
@@ -1115,7 +1092,7 @@
 	 */
 	temp8 = 0;
 
-	if(MEMORY_RANGE == linked_list->data.address64.resource_type) {
+	if (ACPI_MEMORY_RANGE == linked_list->data.address64.resource_type) {
 		temp8 = (u8)
 			(linked_list->data.address64.attribute.memory.read_write_attribute &
 			0x01);
@@ -1124,11 +1101,13 @@
 			(linked_list->data.address64.attribute.memory.cache_attribute &
 			 0x0F) << 1;
 	}
-
-	else if (IO_RANGE == linked_list->data.address64.resource_type) {
+	else if (ACPI_IO_RANGE == linked_list->data.address64.resource_type) {
 		temp8 = (u8)
 			(linked_list->data.address64.attribute.io.range_attribute &
 			 0x03);
+		temp8 |=
+			(linked_list->data.address64.attribute.io.range_attribute &
+			 0x03) << 4;
 	}
 
 	*buffer = temp8;
@@ -1137,36 +1116,31 @@
 	/*
 	 * Set the address space granularity
 	 */
-	MOVE_UNALIGNED64_TO_64 (buffer,
-			   &linked_list->data.address64.granularity);
+	ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.granularity);
 	buffer += 8;
 
 	/*
 	 * Set the address range minimum
 	 */
-	MOVE_UNALIGNED64_TO_64 (buffer,
-			   &linked_list->data.address64.min_address_range);
+	ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.min_address_range);
 	buffer += 8;
 
 	/*
 	 * Set the address range maximum
 	 */
-	MOVE_UNALIGNED64_TO_64 (buffer,
-			   &linked_list->data.address64.max_address_range);
+	ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.max_address_range);
 	buffer += 8;
 
 	/*
 	 * Set the address translation offset
 	 */
-	MOVE_UNALIGNED64_TO_64 (buffer,
-			   &linked_list->data.address64.address_translation_offset);
+	ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.address_translation_offset);
 	buffer += 8;
 
 	/*
 	 * Set the address length
 	 */
-	MOVE_UNALIGNED64_TO_64 (buffer,
-			   &linked_list->data.address64.address_length);
+	ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.address_length);
 	buffer += 8;
 
 	/*
@@ -1178,24 +1152,24 @@
 		*buffer = temp8;
 		buffer += 1;
 
-		temp_pointer = (NATIVE_CHAR *) buffer;
+		temp_pointer = (char *) buffer;
 
 		/*
 		 * Copy the string
 		 */
-		STRCPY (temp_pointer, linked_list->data.address64.resource_source.string_ptr);
+		ACPI_STRCPY (temp_pointer, linked_list->data.address64.resource_source.string_ptr);
 
 		/*
 		 * Buffer needs to be set to the length of the sting + one for the
 		 *  terminating null
 		 */
-		buffer += (STRLEN (linked_list->data.address64.resource_source.string_ptr) + 1);
+		buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.address64.resource_source.string_ptr) + 1);
 	}
 
 	/*
 	 * Return the number of bytes consumed in this operation
 	 */
-	*bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+	*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
 
 	/*
 	 * Set the length field to the number of bytes consumed
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/resources/rscalc.c linux-2.4.22-pre2/drivers/acpi/resources/rscalc.c
--- linux-2.4.21/drivers/acpi/resources/rscalc.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/resources/rscalc.c	2003-06-26 21:43:22.000000000 +0000
@@ -1,44 +1,62 @@
 /*******************************************************************************
  *
  * Module Name: rscalc - Calculate stream and list lengths
- *              $Revision: 32 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acresrc.h"
-#include "amlcode.h"
-#include "acnamesp.h"
+#include <acpi/acpi.h>
+#include <acpi/acresrc.h>
+#include <acpi/amlcode.h>
+#include <acpi/acnamesp.h>
 
 #define _COMPONENT          ACPI_RESOURCES
-	 MODULE_NAME         ("rscalc")
+	 ACPI_MODULE_NAME    ("rscalc")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_calculate_byte_stream_length
+ * FUNCTION:    acpi_rs_get_byte_stream_length
  *
- * PARAMETERS:  Linked_list         - Pointer to the resource linked list
- *              Size_needed         - u32 pointer of the size buffer needed
+ * PARAMETERS:  linked_list         - Pointer to the resource linked list
+ *              size_needed         - u32 pointer of the size buffer needed
  *                                    to properly return the parsed data
  *
  * RETURN:      Status
@@ -50,17 +68,17 @@
  ******************************************************************************/
 
 acpi_status
-acpi_rs_calculate_byte_stream_length (
-	acpi_resource           *linked_list,
-	u32                     *size_needed)
+acpi_rs_get_byte_stream_length (
+	struct acpi_resource            *linked_list,
+	acpi_size                       *size_needed)
 {
-	u32                     byte_stream_size_needed = 0;
-	u32                     segment_size;
-	acpi_resource_ext_irq   *ex_irq = NULL;
-	u8                      done = FALSE;
+	acpi_size                       byte_stream_size_needed = 0;
+	acpi_size                       segment_size;
+	struct acpi_resource_ext_irq    *ex_irq = NULL;
+	u8                              done = FALSE;
 
 
-	FUNCTION_TRACE ("Rs_calculate_byte_stream_length");
+	ACPI_FUNCTION_TRACE ("rs_get_byte_stream_length");
 
 
 	while (!done) {
@@ -90,7 +108,7 @@
 		case ACPI_RSTYPE_START_DPF:
 			/*
 			 * Start Dependent Functions Resource
-			 * For a Start_dependent_functions Resource, Byte 1,
+			 * For a start_dependent_functions Resource, Byte 1,
 			 * although optional, will always be created.
 			 */
 			segment_size = 2;
@@ -180,9 +198,9 @@
 			 */
 			segment_size = 16;
 
-			if (NULL != linked_list->data.address16.resource_source.string_ptr) {
-				segment_size += (1 +
-					linked_list->data.address16.resource_source.string_length);
+			if (linked_list->data.address16.resource_source.string_ptr) {
+				segment_size += linked_list->data.address16.resource_source.string_length;
+				segment_size++;
 			}
 			break;
 
@@ -196,9 +214,9 @@
 			 */
 			segment_size = 26;
 
-			if (NULL != linked_list->data.address32.resource_source.string_ptr) {
-				segment_size += (1 +
-					linked_list->data.address32.resource_source.string_length);
+			if (linked_list->data.address32.resource_source.string_ptr) {
+				segment_size += linked_list->data.address32.resource_source.string_length;
+				segment_size++;
 			}
 			break;
 
@@ -212,9 +230,9 @@
 			 */
 			segment_size = 46;
 
-			if (NULL != linked_list->data.address64.resource_source.string_ptr) {
-				segment_size += (1 +
-					linked_list->data.address64.resource_source.string_length);
+			if (linked_list->data.address64.resource_source.string_ptr) {
+				segment_size += linked_list->data.address64.resource_source.string_length;
+				segment_size++;
 			}
 			break;
 
@@ -229,11 +247,11 @@
 			 * Resource Source + 1 for the null.
 			 */
 			segment_size = 9 +
-				((linked_list->data.extended_irq.number_of_interrupts - 1) * 4);
+				(((acpi_size) linked_list->data.extended_irq.number_of_interrupts - 1) * 4);
 
-			if (NULL != ex_irq->resource_source.string_ptr) {
-				segment_size += (1 +
-					linked_list->data.extended_irq.resource_source.string_length);
+			if (ex_irq && ex_irq->resource_source.string_ptr) {
+				segment_size += linked_list->data.extended_irq.resource_source.string_length;
+				segment_size++;
 			}
 			break;
 
@@ -243,9 +261,8 @@
 			 * so exit with an error
 			 */
 			return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
-			break;
 
-		} /* switch (Linked_list->Id) */
+		} /* switch (linked_list->Id) */
 
 		/*
 		 * Update the total
@@ -255,7 +272,7 @@
 		/*
 		 * Point to the next object
 		 */
-		linked_list = POINTER_ADD (acpi_resource,
+		linked_list = ACPI_PTR_ADD (struct acpi_resource,
 				  linked_list, linked_list->length);
 	}
 
@@ -269,11 +286,11 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_calculate_list_length
+ * FUNCTION:    acpi_rs_get_list_length
  *
- * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource byte stream
- *              Byte_stream_buffer_length - Size of Byte_stream_buffer
- *              Size_needed             - u32 pointer of the size buffer
+ * PARAMETERS:  byte_stream_buffer      - Pointer to the resource byte stream
+ *              byte_stream_buffer_length - Size of byte_stream_buffer
+ *              size_needed             - u32 pointer of the size buffer
  *                                        needed to properly return the
  *                                        parsed data
  *
@@ -286,26 +303,26 @@
  ******************************************************************************/
 
 acpi_status
-acpi_rs_calculate_list_length (
-	u8                      *byte_stream_buffer,
-	u32                     byte_stream_buffer_length,
-	u32                     *size_needed)
+acpi_rs_get_list_length (
+	u8                              *byte_stream_buffer,
+	u32                             byte_stream_buffer_length,
+	acpi_size                       *size_needed)
 {
-	u32                     buffer_size = 0;
-	u32                     bytes_parsed = 0;
-	u8                      number_of_interrupts = 0;
-	u8                      number_of_channels = 0;
-	u8                      resource_type;
-	u32                     structure_size;
-	u32                     bytes_consumed;
-	u8                      *buffer;
-	u8                      temp8;
-	u16                     temp16;
-	u8                      index;
-	u8                      additional_bytes;
+	u32                             buffer_size = 0;
+	u32                             bytes_parsed = 0;
+	u8                              number_of_interrupts = 0;
+	u8                              number_of_channels = 0;
+	u8                              resource_type;
+	u32                             structure_size;
+	u32                             bytes_consumed;
+	u8                              *buffer;
+	u8                              temp8;
+	u16                             temp16;
+	u8                              index;
+	u8                              additional_bytes;
 
 
-	FUNCTION_TRACE ("Rs_calculate_list_length");
+	ACPI_FUNCTION_TRACE ("rs_get_list_length");
 
 
 	while (bytes_parsed < byte_stream_buffer_length) {
@@ -315,65 +332,65 @@
 		resource_type = acpi_rs_get_resource_type (*byte_stream_buffer);
 
 		switch (resource_type) {
-		case RESOURCE_DESC_MEMORY_24:
+		case ACPI_RDESC_TYPE_MEMORY_24:
 			/*
 			 * 24-Bit Memory Resource
 			 */
 			bytes_consumed = 12;
 
-			structure_size = SIZEOF_RESOURCE (acpi_resource_mem24);
+			structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_mem24);
 			break;
 
 
-		case RESOURCE_DESC_LARGE_VENDOR:
+		case ACPI_RDESC_TYPE_LARGE_VENDOR:
 			/*
 			 * Vendor Defined Resource
 			 */
 			buffer = byte_stream_buffer;
 			++buffer;
 
-			MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+			ACPI_MOVE_16_TO_16 (&temp16, buffer);
 			bytes_consumed = temp16 + 3;
 
 			/*
 			 * Ensure a 32-bit boundary for the structure
 			 */
-			temp16 = (u16) ROUND_UP_TO_32_bITS (temp16);
+			temp16 = (u16) ACPI_ROUND_UP_to_32_bITS (temp16);
 
-			structure_size = SIZEOF_RESOURCE (acpi_resource_vendor) +
+			structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_vendor) +
 					   (temp16 * sizeof (u8));
 			break;
 
 
-		case RESOURCE_DESC_MEMORY_32:
+		case ACPI_RDESC_TYPE_MEMORY_32:
 			/*
 			 * 32-Bit Memory Range Resource
 			 */
 
 			bytes_consumed = 20;
 
-			structure_size = SIZEOF_RESOURCE (acpi_resource_mem32);
+			structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_mem32);
 			break;
 
 
-		case RESOURCE_DESC_FIXED_MEMORY_32:
+		case ACPI_RDESC_TYPE_FIXED_MEMORY_32:
 			/*
 			 * 32-Bit Fixed Memory Resource
 			 */
 			bytes_consumed = 12;
 
-			structure_size = SIZEOF_RESOURCE (acpi_resource_fixed_mem32);
+			structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_fixed_mem32);
 			break;
 
 
-		case RESOURCE_DESC_QWORD_ADDRESS_SPACE:
+		case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE:
 			/*
 			 * 64-Bit Address Resource
 			 */
 			buffer = byte_stream_buffer;
 
 			++buffer;
-			MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+			ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 			bytes_consumed = temp16 + 3;
 
@@ -397,21 +414,21 @@
 			/*
 			 * Ensure a 64-bit boundary for the structure
 			 */
-			temp8 = (u8) ROUND_UP_TO_64_bITS (temp8);
+			temp8 = (u8) ACPI_ROUND_UP_to_64_bITS (temp8);
 
-			structure_size = SIZEOF_RESOURCE (acpi_resource_address64) +
+			structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address64) +
 					   (temp8 * sizeof (u8));
 			break;
 
 
-		case RESOURCE_DESC_DWORD_ADDRESS_SPACE:
+		case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE:
 			/*
 			 * 32-Bit Address Resource
 			 */
 			buffer = byte_stream_buffer;
 
 			++buffer;
-			MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+			ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 			bytes_consumed = temp16 + 3;
 
@@ -435,21 +452,21 @@
 			/*
 			 * Ensure a 32-bit boundary for the structure
 			 */
-			temp8 = (u8) ROUND_UP_TO_32_bITS (temp8);
+			temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8);
 
-			structure_size = SIZEOF_RESOURCE (acpi_resource_address32) +
+			structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address32) +
 					   (temp8 * sizeof (u8));
 			break;
 
 
-		case RESOURCE_DESC_WORD_ADDRESS_SPACE:
+		case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE:
 			/*
 			 * 16-Bit Address Resource
 			 */
 			buffer = byte_stream_buffer;
 
 			++buffer;
-			MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+			ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 			bytes_consumed = temp16 + 3;
 
@@ -473,21 +490,21 @@
 			/*
 			 * Ensure a 32-bit boundary for the structure
 			 */
-			temp8 = (u8) ROUND_UP_TO_32_bITS (temp8);
+			temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8);
 
-			structure_size = SIZEOF_RESOURCE (acpi_resource_address16) +
+			structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address16) +
 					   (temp8 * sizeof (u8));
 			break;
 
 
-		case RESOURCE_DESC_EXTENDED_XRUPT:
+		case ACPI_RDESC_TYPE_EXTENDED_XRUPT:
 			/*
 			 * Extended IRQ
 			 */
 			buffer = byte_stream_buffer;
 
 			++buffer;
-			MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+			ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 			bytes_consumed = temp16 + 3;
 
@@ -518,7 +535,6 @@
 			if (9 + additional_bytes < temp16) {
 				temp8 = (u8) (temp16 - (9 + additional_bytes));
 			}
-
 			else {
 				temp8 = 0;
 			}
@@ -526,15 +542,15 @@
 			/*
 			 * Ensure a 32-bit boundary for the structure
 			 */
-			temp8 = (u8) ROUND_UP_TO_32_bITS (temp8);
+			temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8);
 
-			structure_size = SIZEOF_RESOURCE (acpi_resource_ext_irq) +
+			structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_ext_irq) +
 					   (additional_bytes * sizeof (u8)) +
 					   (temp8 * sizeof (u8));
 			break;
 
 
-		case RESOURCE_DESC_IRQ_FORMAT:
+		case ACPI_RDESC_TYPE_IRQ_FORMAT:
 			/*
 			 * IRQ Resource.
 			 * Determine if it there are two or three trailing bytes
@@ -545,7 +561,6 @@
 			if(temp8 & 0x01) {
 				bytes_consumed = 4;
 			}
-
 			else {
 				bytes_consumed = 3;
 			}
@@ -558,7 +573,7 @@
 			/*
 			 * Look at the number of bits set
 			 */
-			MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+			ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 			for (index = 0; index < 16; index++) {
 				if (temp16 & 0x1) {
@@ -568,12 +583,12 @@
 				temp16 >>= 1;
 			}
 
-			structure_size = SIZEOF_RESOURCE (acpi_resource_io) +
+			structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_io) +
 					   (number_of_interrupts * sizeof (u32));
 			break;
 
 
-		case RESOURCE_DESC_DMA_FORMAT:
+		case ACPI_RDESC_TYPE_DMA_FORMAT:
 			/*
 			 * DMA Resource
 			 */
@@ -598,12 +613,12 @@
 				temp8 >>= 1;
 			}
 
-			structure_size = SIZEOF_RESOURCE (acpi_resource_dma) +
+			structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_dma) +
 					   (number_of_channels * sizeof (u32));
 			break;
 
 
-		case RESOURCE_DESC_START_DEPENDENT:
+		case ACPI_RDESC_TYPE_START_DEPENDENT:
 			/*
 			 * Start Dependent Functions Resource
 			 * Determine if it there are two or three trailing bytes
@@ -618,11 +633,11 @@
 				bytes_consumed = 1;
 			}
 
-			structure_size = SIZEOF_RESOURCE (acpi_resource_start_dpf);
+			structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_start_dpf);
 			break;
 
 
-		case RESOURCE_DESC_END_DEPENDENT:
+		case ACPI_RDESC_TYPE_END_DEPENDENT:
 			/*
 			 * End Dependent Functions Resource
 			 */
@@ -631,25 +646,25 @@
 			break;
 
 
-		case RESOURCE_DESC_IO_PORT:
+		case ACPI_RDESC_TYPE_IO_PORT:
 			/*
 			 * IO Port Resource
 			 */
 			bytes_consumed = 8;
-			structure_size = SIZEOF_RESOURCE (acpi_resource_io);
+			structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_io);
 			break;
 
 
-		case RESOURCE_DESC_FIXED_IO_PORT:
+		case ACPI_RDESC_TYPE_FIXED_IO_PORT:
 			/*
 			 * Fixed IO Port Resource
 			 */
 			bytes_consumed = 4;
-			structure_size = SIZEOF_RESOURCE (acpi_resource_fixed_io);
+			structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_fixed_io);
 			break;
 
 
-		case RESOURCE_DESC_SMALL_VENDOR:
+		case ACPI_RDESC_TYPE_SMALL_VENDOR:
 			/*
 			 * Vendor Specific Resource
 			 */
@@ -662,13 +677,13 @@
 			/*
 			 * Ensure a 32-bit boundary for the structure
 			 */
-			temp8 = (u8) ROUND_UP_TO_32_bITS (temp8);
-			structure_size = SIZEOF_RESOURCE (acpi_resource_vendor) +
+			temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8);
+			structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_vendor) +
 					   (temp8 * sizeof (u8));
 			break;
 
 
-		case RESOURCE_DESC_END_TAG:
+		case ACPI_RDESC_TYPE_END_TAG:
 			/*
 			 * End Tag
 			 */
@@ -684,14 +699,12 @@
 			 *  so exit with an error
 			 */
 			return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
-			break;
 		}
 
-
 		/*
 		 * Update the return value and counter
 		 */
-		buffer_size += structure_size;
+		buffer_size += ACPI_ALIGN_RESOURCE_SIZE(structure_size);
 		bytes_parsed += bytes_consumed;
 
 		/*
@@ -700,7 +713,6 @@
 		byte_stream_buffer += bytes_consumed;
 	}
 
-
 	/*
 	 * This is the data the caller needs
 	 */
@@ -711,10 +723,10 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_calculate_pci_routing_table_length
+ * FUNCTION:    acpi_rs_get_pci_routing_table_length
  *
- * PARAMETERS:  Package_object          - Pointer to the package object
- *              Buffer_size_needed      - u32 pointer of the size buffer
+ * PARAMETERS:  package_object          - Pointer to the package object
+ *              buffer_size_needed      - u32 pointer of the size buffer
  *                                        needed to properly return the
  *                                        parsed data
  *
@@ -727,21 +739,21 @@
  ******************************************************************************/
 
 acpi_status
-acpi_rs_calculate_pci_routing_table_length (
-	acpi_operand_object     *package_object,
-	u32                     *buffer_size_needed)
+acpi_rs_get_pci_routing_table_length (
+	union acpi_operand_object       *package_object,
+	acpi_size                       *buffer_size_needed)
 {
-	u32                     number_of_elements;
-	u32                     temp_size_needed = 0;
-	acpi_operand_object     **top_object_list;
-	u32                     index;
-	acpi_operand_object     *package_element;
-	acpi_operand_object     **sub_object_list;
-	u8                      name_found;
-	u32                     table_index;
+	u32                             number_of_elements;
+	acpi_size                       temp_size_needed = 0;
+	union acpi_operand_object       **top_object_list;
+	u32                             index;
+	union acpi_operand_object       *package_element;
+	union acpi_operand_object       **sub_object_list;
+	u8                              name_found;
+	u32                             table_index;
 
 
-	FUNCTION_TRACE ("Rs_calculate_pci_routing_table_length");
+	ACPI_FUNCTION_TRACE ("rs_get_pci_routing_table_length");
 
 
 	number_of_elements = package_object->package.count;
@@ -765,23 +777,22 @@
 		package_element = *top_object_list;
 
 		/*
-		 * The Sub_object_list will now point to an array of the
-		 * four IRQ elements: Address, Pin, Source and Source_index
+		 * The sub_object_list will now point to an array of the
+		 * four IRQ elements: Address, Pin, Source and source_index
 		 */
 		sub_object_list = package_element->package.elements;
 
 		/*
-		 * Scan the Irq_table_elements for the Source Name String
+		 * Scan the irq_table_elements for the Source Name String
 		 */
 		name_found = FALSE;
 
 		for (table_index = 0; table_index < 4 && !name_found; table_index++) {
-			if ((ACPI_TYPE_STRING == (*sub_object_list)->common.type) ||
-				((INTERNAL_TYPE_REFERENCE == (*sub_object_list)->common.type) &&
+			if ((ACPI_TYPE_STRING == ACPI_GET_OBJECT_TYPE (*sub_object_list)) ||
+				((ACPI_TYPE_LOCAL_REFERENCE == ACPI_GET_OBJECT_TYPE (*sub_object_list)) &&
 					((*sub_object_list)->reference.opcode == AML_INT_NAMEPATH_OP))) {
 				name_found = TRUE;
 			}
-
 			else {
 				/*
 				 * Look at the next element
@@ -790,26 +801,24 @@
 			}
 		}
 
-		temp_size_needed += (sizeof (pci_routing_table) - 4);
+		temp_size_needed += (sizeof (struct acpi_pci_routing_table) - 4);
 
 		/*
 		 * Was a String type found?
 		 */
-		if (TRUE == name_found) {
-			if (ACPI_TYPE_STRING == (*sub_object_list)->common.type) {
+		if (name_found) {
+			if (ACPI_GET_OBJECT_TYPE (*sub_object_list) == ACPI_TYPE_STRING) {
 				/*
-				 * The length String.Length field includes the
-				 * terminating NULL
+				 * The length String.Length field does not include the
+				 * terminating NULL, add 1
 				 */
-				temp_size_needed += (*sub_object_list)->string.length;
+				temp_size_needed += ((acpi_size) (*sub_object_list)->string.length + 1);
 			}
-
 			else {
 				temp_size_needed += acpi_ns_get_pathname_length (
 						   (*sub_object_list)->reference.node);
 			}
 		}
-
 		else {
 			/*
 			 * If no name was found, then this is a NULL, which is
@@ -820,18 +829,17 @@
 
 		/* Round up the size since each element must be aligned */
 
-		temp_size_needed = ROUND_UP_TO_64_bITS (temp_size_needed);
+		temp_size_needed = ACPI_ROUND_UP_to_64_bITS (temp_size_needed);
 
 		/*
-		 * Point to the next acpi_operand_object
+		 * Point to the next union acpi_operand_object
 		 */
 		top_object_list++;
 	}
 
-
 	/*
 	 * Adding an extra element to the end of the list, essentially a NULL terminator
 	 */
-	*buffer_size_needed = temp_size_needed + sizeof (pci_routing_table);
+	*buffer_size_needed = temp_size_needed + sizeof (struct acpi_pci_routing_table);
 	return_ACPI_STATUS (AE_OK);
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/resources/rscreate.c linux-2.4.22-pre2/drivers/acpi/resources/rscreate.c
--- linux-2.4.21/drivers/acpi/resources/rscreate.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/resources/rscreate.c	2003-06-26 21:43:17.000000000 +0000
@@ -1,50 +1,67 @@
 /*******************************************************************************
  *
  * Module Name: rscreate - Create resource lists/tables
- *              $Revision: 36 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acresrc.h"
-#include "amlcode.h"
-#include "acnamesp.h"
+#include <acpi/acpi.h>
+#include <acpi/acresrc.h>
+#include <acpi/amlcode.h>
+#include <acpi/acnamesp.h>
 
 #define _COMPONENT          ACPI_RESOURCES
-	 MODULE_NAME         ("rscreate")
+	 ACPI_MODULE_NAME    ("rscreate")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_create_resource_list
+ * FUNCTION:    acpi_rs_create_resource_list
  *
- * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource byte stream
- *              Output_buffer           - Pointer to the user's buffer
- *              Output_buffer_length    - Pointer to the size of Output_buffer
+ * PARAMETERS:  byte_stream_buffer      - Pointer to the resource byte stream
+ *              output_buffer           - Pointer to the user's buffer
  *
  * RETURN:      Status  - AE_OK if okay, else a valid acpi_status code
- *              If Output_buffer is not large enough, Output_buffer_length
- *              indicates how large Output_buffer should be, else it
- *              indicates how may u8 elements of Output_buffer are valid.
+ *              If output_buffer is not large enough, output_buffer_length
+ *              indicates how large output_buffer should be, else it
+ *              indicates how may u8 elements of output_buffer are valid.
  *
  * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method
  *              execution and parses the stream to create a linked list
@@ -54,21 +71,21 @@
 
 acpi_status
 acpi_rs_create_resource_list (
-	acpi_operand_object     *byte_stream_buffer,
-	u8                      *output_buffer,
-	u32                     *output_buffer_length)
+	union acpi_operand_object       *byte_stream_buffer,
+	struct acpi_buffer              *output_buffer)
 {
 
-	acpi_status             status;
-	u8                      *byte_stream_start;
-	u32                     list_size_needed = 0;
-	u32                     byte_stream_buffer_length;
+	acpi_status                     status;
+	u8                              *byte_stream_start;
+	acpi_size                       list_size_needed = 0;
+	u32                             byte_stream_buffer_length;
 
 
-	FUNCTION_TRACE ("Rs_create_resource_list");
+	ACPI_FUNCTION_TRACE ("rs_create_resource_list");
 
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Byte_stream_buffer = %p\n", byte_stream_buffer));
+	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "byte_stream_buffer = %p\n",
+		byte_stream_buffer));
 
 	/*
 	 * Params already validated, so we don't re-validate here
@@ -77,300 +94,280 @@
 	byte_stream_start = byte_stream_buffer->buffer.pointer;
 
 	/*
-	 * Pass the Byte_stream_buffer into a module that can calculate
+	 * Pass the byte_stream_buffer into a module that can calculate
 	 * the buffer size needed for the linked list
 	 */
-	status = acpi_rs_calculate_list_length (byte_stream_start, byte_stream_buffer_length,
+	status = acpi_rs_get_list_length (byte_stream_start, byte_stream_buffer_length,
 			 &list_size_needed);
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X List_size_needed=%X\n",
-		status, list_size_needed));
-
-	/*
-	 * Exit with the error passed back
-	 */
+	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X list_size_needed=%X\n",
+		status, (u32) list_size_needed));
 	if (ACPI_FAILURE (status)) {
 		return_ACPI_STATUS (status);
 	}
 
-	/*
-	 * If the linked list will fit into the available buffer
-	 * call to fill in the list
-	 */
-	if (list_size_needed <= *output_buffer_length) {
-		/*
-		 * Zero out the return buffer before proceeding
-		 */
-		MEMSET (output_buffer, 0x00, *output_buffer_length);
-
-		status = acpi_rs_byte_stream_to_list (byte_stream_start, byte_stream_buffer_length,
-				 &output_buffer);
+	/* Validate/Allocate/Clear caller buffer */
 
-		/*
-		 * Exit with the error passed back
-		 */
-		if (ACPI_FAILURE (status)) {
-			return_ACPI_STATUS (status);
-		}
-
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Output_buffer = %p\n", output_buffer));
+	status = acpi_ut_initialize_buffer (output_buffer, list_size_needed);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
 	}
 
-	else {
-		*output_buffer_length = list_size_needed;
-		return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
+	/* Do the conversion */
+
+	status = acpi_rs_byte_stream_to_list (byte_stream_start, byte_stream_buffer_length,
+			  output_buffer->pointer);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
 	}
 
-	*output_buffer_length = list_size_needed;
+	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "output_buffer %p Length %X\n",
+			output_buffer->pointer, (u32) output_buffer->length));
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_create_pci_routing_table
+ * FUNCTION:    acpi_rs_create_pci_routing_table
  *
- * PARAMETERS:  Package_object          - Pointer to an acpi_operand_object
+ * PARAMETERS:  package_object          - Pointer to an union acpi_operand_object
  *                                        package
- *              Output_buffer           - Pointer to the user's buffer
- *              Output_buffer_length    - Size of Output_buffer
+ *              output_buffer           - Pointer to the user's buffer
  *
  * RETURN:      Status  AE_OK if okay, else a valid acpi_status code.
- *              If the Output_buffer is too small, the error will be
- *              AE_BUFFER_OVERFLOW and Output_buffer_length will point
+ *              If the output_buffer is too small, the error will be
+ *              AE_BUFFER_OVERFLOW and output_buffer->Length will point
  *              to the size buffer needed.
  *
- * DESCRIPTION: Takes the acpi_operand_object  package and creates a
+ * DESCRIPTION: Takes the union acpi_operand_object    package and creates a
  *              linked list of PCI interrupt descriptions
  *
+ * NOTE: It is the caller's responsibility to ensure that the start of the
+ * output buffer is aligned properly (if necessary).
+ *
  ******************************************************************************/
 
 acpi_status
 acpi_rs_create_pci_routing_table (
-	acpi_operand_object     *package_object,
-	u8                      *output_buffer,
-	u32                     *output_buffer_length)
+	union acpi_operand_object       *package_object,
+	struct acpi_buffer              *output_buffer)
 {
-	u8                      *buffer = output_buffer;
-	acpi_operand_object     **top_object_list = NULL;
-	acpi_operand_object     **sub_object_list = NULL;
-	acpi_operand_object     *package_element = NULL;
-	u32                     buffer_size_needed = 0;
-	u32                     number_of_elements = 0;
-	u32                     index = 0;
-	pci_routing_table       *user_prt = NULL;
-	acpi_namespace_node     *node;
-	acpi_status             status;
+	u8                              *buffer;
+	union acpi_operand_object       **top_object_list;
+	union acpi_operand_object       **sub_object_list;
+	union acpi_operand_object       *obj_desc;
+	acpi_size                       buffer_size_needed = 0;
+	u32                             number_of_elements;
+	u32                             index;
+	struct acpi_pci_routing_table   *user_prt;
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
+	struct acpi_buffer              path_buffer;
 
 
-	FUNCTION_TRACE ("Rs_create_pci_routing_table");
+	ACPI_FUNCTION_TRACE ("rs_create_pci_routing_table");
 
 
+	/* Params already validated, so we don't re-validate here */
+
 	/*
-	 * Params already validated, so we don't re-validate here
+	 * Get the required buffer length
 	 */
-	status = acpi_rs_calculate_pci_routing_table_length (package_object,
+	status = acpi_rs_get_pci_routing_table_length (package_object,
 			 &buffer_size_needed);
-
-	if (!ACPI_SUCCESS(status)) {
+	if (ACPI_FAILURE (status)) {
 		return_ACPI_STATUS (status);
 	}
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Buffer_size_needed = %X\n", buffer_size_needed));
+	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "buffer_size_needed = %X\n",
+		(u32) buffer_size_needed));
+
+	/* Validate/Allocate/Clear caller buffer */
+
+	status = acpi_ut_initialize_buffer (output_buffer, buffer_size_needed);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	/*
-	 * If the data will fit into the available buffer
-	 * call to fill in the list
+	 * Loop through the ACPI_INTERNAL_OBJECTS - Each object
+	 * should be a package that in turn contains an
+	 * acpi_integer Address, a u8 Pin, a Name and a u8 source_index.
 	 */
-	if (buffer_size_needed <= *output_buffer_length) {
+	top_object_list  = package_object->package.elements;
+	number_of_elements = package_object->package.count;
+	buffer           = output_buffer->pointer;
+	user_prt         = ACPI_CAST_PTR (struct acpi_pci_routing_table, buffer);
+
+	for (index = 0; index < number_of_elements; index++) {
 		/*
-		 * Zero out the return buffer before proceeding
+		 * Point user_prt past this current structure
+		 *
+		 * NOTE: On the first iteration, user_prt->Length will
+		 * be zero because we cleared the return buffer earlier
 		 */
-		MEMSET (output_buffer, 0x00, *output_buffer_length);
+		buffer += user_prt->length;
+		user_prt = ACPI_CAST_PTR (struct acpi_pci_routing_table, buffer);
 
 		/*
-		 * Loop through the ACPI_INTERNAL_OBJECTS - Each object should
-		 * contain a u32 Address, a u8 Pin, a Name and a u8
-		 * Source_index.
+		 * Fill in the Length field with the information we have at this point.
+		 * The minus four is to subtract the size of the u8 Source[4] member
+		 * because it is added below.
 		 */
-		top_object_list     = package_object->package.elements;
-		number_of_elements  = package_object->package.count;
-		user_prt            = (pci_routing_table *) buffer;
-
-
-		buffer = ROUND_PTR_UP_TO_8 (buffer, u8);
-
-		for (index = 0; index < number_of_elements; index++) {
-			/*
-			 * Point User_prt past this current structure
-			 *
-			 * NOTE: On the first iteration, User_prt->Length will
-			 * be zero because we cleared the return buffer earlier
-			 */
-			buffer += user_prt->length;
-			user_prt = (pci_routing_table *) buffer;
+		user_prt->length = (sizeof (struct acpi_pci_routing_table) - 4);
 
+		/*
+		 * Each element of the top-level package must also be a package
+		 */
+		if (ACPI_GET_OBJECT_TYPE (*top_object_list) != ACPI_TYPE_PACKAGE) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"(PRT[%X]) Need sub-package, found %s\n",
+				index, acpi_ut_get_object_type_name (*top_object_list)));
+			return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+		}
 
-			/*
-			 * Fill in the Length field with the information we
-			 * have at this point.
-			 * The minus four is to subtract the size of the
-			 * u8 Source[4] member because it is added below.
-			 */
-			user_prt->length = (sizeof (pci_routing_table) -4);
-
-			/*
-			 * Dereference the sub-package
-			 */
-			package_element = *top_object_list;
-
-			/*
-			 * The Sub_object_list will now point to an array of
-			 * the four IRQ elements: Address, Pin, Source and
-			 * Source_index
-			 */
-			sub_object_list = package_element->package.elements;
+		/* Each sub-package must be of length 4 */
 
-			/*
-			 * 1) First subobject:  Dereference the Address
-			 */
-			if (ACPI_TYPE_INTEGER == (*sub_object_list)->common.type) {
-				user_prt->address = (*sub_object_list)->integer.value;
-			}
+		if ((*top_object_list)->package.count != 4) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"(PRT[%X]) Need package of length 4, found length %d\n",
+				index, (*top_object_list)->package.count));
+			return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT);
+		}
 
-			else {
-				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need Integer, found %s\n",
-					acpi_ut_get_type_name ((*sub_object_list)->common.type)));
-				return_ACPI_STATUS (AE_BAD_DATA);
-			}
+		/*
+		 * Dereference the sub-package.
+		 * The sub_object_list will now point to an array of the four IRQ
+		 * elements: [Address, Pin, Source, source_index]
+		 */
+		sub_object_list = (*top_object_list)->package.elements;
 
-			/*
-			 * 2) Second subobject: Dereference the Pin
-			 */
-			sub_object_list++;
+		/*
+		 * 1) First subobject: Dereference the PRT.Address
+		 */
+		obj_desc = sub_object_list[0];
+		if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) {
+			user_prt->address = obj_desc->integer.value;
+		}
+		else {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"(PRT[%X].Address) Need Integer, found %s\n",
+				index, acpi_ut_get_object_type_name (obj_desc)));
+			return_ACPI_STATUS (AE_BAD_DATA);
+		}
 
-			if (ACPI_TYPE_INTEGER == (*sub_object_list)->common.type) {
-				user_prt->pin = (u32) (*sub_object_list)->integer.value;
-			}
+		/*
+		 * 2) Second subobject: Dereference the PRT.Pin
+		 */
+		obj_desc = sub_object_list[1];
+		if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) {
+			user_prt->pin = (u32) obj_desc->integer.value;
+		}
+		else {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"(PRT[%X].Pin) Need Integer, found %s\n",
+				index, acpi_ut_get_object_type_name (obj_desc)));
+			return_ACPI_STATUS (AE_BAD_DATA);
+		}
 
-			else {
-				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need Integer, found %s\n",
-					acpi_ut_get_type_name ((*sub_object_list)->common.type)));
+		/*
+		 * 3) Third subobject: Dereference the PRT.source_name
+		 */
+		obj_desc = sub_object_list[2];
+		switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
+		case ACPI_TYPE_LOCAL_REFERENCE:
+
+			if (obj_desc->reference.opcode != AML_INT_NAMEPATH_OP) {
+				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+					"(PRT[%X].Source) Need name, found reference op %X\n",
+					index, obj_desc->reference.opcode));
 				return_ACPI_STATUS (AE_BAD_DATA);
 			}
 
-			/*
-			 * 3) Third subobject: Dereference the Source Name
-			 */
-			sub_object_list++;
+			node = obj_desc->reference.node;
 
-			switch ((*sub_object_list)->common.type) {
-			case INTERNAL_TYPE_REFERENCE:
+			/* Use *remaining* length of the buffer as max for pathname */
 
-				if ((*sub_object_list)->reference.opcode != AML_INT_NAMEPATH_OP) {
-				   ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need name, found reference op %X\n",
-						(*sub_object_list)->reference.opcode));
-					return_ACPI_STATUS (AE_BAD_DATA);
-				}
+			path_buffer.length = output_buffer->length -
+					   (u32) ((u8 *) user_prt->source -
+					   (u8 *) output_buffer->pointer);
+			path_buffer.pointer = user_prt->source;
 
-				node = (*sub_object_list)->reference.node;
+			status = acpi_ns_handle_to_pathname ((acpi_handle) node, &path_buffer);
 
-				/* TBD: use *remaining* length of the buffer! */
+			user_prt->length += (u32) ACPI_STRLEN (user_prt->source) + 1; /* include null terminator */
+			break;
 
-				status = acpi_ns_handle_to_pathname ((acpi_handle *) node,
-						 output_buffer_length, user_prt->source);
 
-				user_prt->length += STRLEN (user_prt->source) + 1; /* include null terminator */
-				break;
+		case ACPI_TYPE_STRING:
 
+			ACPI_STRCPY (user_prt->source, obj_desc->string.pointer);
 
-			case ACPI_TYPE_STRING:
+			/* Add to the Length field the length of the string (add 1 for terminator) */
 
-				STRCPY (user_prt->source,
-					  (*sub_object_list)->string.pointer);
+			user_prt->length += obj_desc->string.length + 1;
+			break;
 
-				/*
-				 * Add to the Length field the length of the string
-				 */
-				user_prt->length += (*sub_object_list)->string.length;
-				break;
-
-
-			case ACPI_TYPE_INTEGER:
-				/*
-				 * If this is a number, then the Source Name
-				 * is NULL, since the entire buffer was zeroed
-				 * out, we can leave this alone.
-				 */
-				/*
-				 * Add to the Length field the length of
-				 * the u32 NULL
-				 */
-				user_prt->length += sizeof (u32);
-				break;
-
-
-			default:
-
-			   ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need Integer, found %s\n",
-					acpi_ut_get_type_name ((*sub_object_list)->common.type)));
-			   return_ACPI_STATUS (AE_BAD_DATA);
-			   break;
-			}
-
-			/* Now align the current length */
-
-			user_prt->length = ROUND_UP_TO_64_bITS (user_prt->length);
 
+		case ACPI_TYPE_INTEGER:
 			/*
-			 * 4) Fourth subobject: Dereference the Source Index
+			 * If this is a number, then the Source Name is NULL, since the
+			 * entire buffer was zeroed out, we can leave this alone.
+			 *
+			 * Add to the Length field the length of the u32 NULL
 			 */
-			sub_object_list++;
+			user_prt->length += sizeof (u32);
+			break;
 
-			if (ACPI_TYPE_INTEGER == (*sub_object_list)->common.type) {
-				user_prt->source_index = (u32) (*sub_object_list)->integer.value;
-			}
 
-			else {
-				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need Integer, found %s\n",
-					acpi_ut_get_type_name ((*sub_object_list)->common.type)));
-				return_ACPI_STATUS (AE_BAD_DATA);
-			}
+		default:
 
-			/*
-			 * Point to the next acpi_operand_object
-			 */
-			top_object_list++;
+		   ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			   "(PRT[%X].Source) Need Ref/String/Integer, found %s\n",
+				index, acpi_ut_get_object_type_name (obj_desc)));
+		   return_ACPI_STATUS (AE_BAD_DATA);
 		}
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Output_buffer = %p\n", output_buffer));
-	}
+		/* Now align the current length */
+
+		user_prt->length = ACPI_ROUND_UP_to_64_bITS (user_prt->length);
+
+		/*
+		 * 4) Fourth subobject: Dereference the PRT.source_index
+		 */
+		obj_desc = sub_object_list[3];
+		if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) {
+			user_prt->source_index = (u32) obj_desc->integer.value;
+		}
+		else {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"(PRT[%X].source_index) Need Integer, found %s\n",
+				index, acpi_ut_get_object_type_name (obj_desc)));
+			return_ACPI_STATUS (AE_BAD_DATA);
+		}
 
-	else {
-		*output_buffer_length = buffer_size_needed;
+		/* Point to the next union acpi_operand_object in the top level package */
 
-		return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
+		top_object_list++;
 	}
 
-	/*
-	 * Report the amount of buffer used
-	 */
-	*output_buffer_length = buffer_size_needed;
+	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "output_buffer %p Length %X\n",
+			output_buffer->pointer, (u32) output_buffer->length));
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_create_byte_stream
+ * FUNCTION:    acpi_rs_create_byte_stream
  *
- * PARAMETERS:  Linked_list_buffer      - Pointer to the resource linked list
- *              Output_buffer           - Pointer to the user's buffer
- *              Output_buffer_length    - Size of Output_buffer
+ * PARAMETERS:  linked_list_buffer      - Pointer to the resource linked list
+ *              output_buffer           - Pointer to the user's buffer
  *
  * RETURN:      Status  AE_OK if okay, else a valid acpi_status code.
- *              If the Output_buffer is too small, the error will be
- *              AE_BUFFER_OVERFLOW and Output_buffer_length will point
+ *              If the output_buffer is too small, the error will be
+ *              AE_BUFFER_OVERFLOW and output_buffer->Length will point
  *              to the size buffer needed.
  *
  * DESCRIPTION: Takes the linked list of device resources and
@@ -381,66 +378,51 @@
 
 acpi_status
 acpi_rs_create_byte_stream (
-	acpi_resource           *linked_list_buffer,
-	u8                      *output_buffer,
-	u32                     *output_buffer_length)
+	struct acpi_resource            *linked_list_buffer,
+	struct acpi_buffer              *output_buffer)
 {
-	acpi_status             status;
-	u32                     byte_stream_size_needed = 0;
+	acpi_status                     status;
+	acpi_size                       byte_stream_size_needed = 0;
 
 
-	FUNCTION_TRACE ("Rs_create_byte_stream");
+	ACPI_FUNCTION_TRACE ("rs_create_byte_stream");
 
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Linked_list_buffer = %p\n", linked_list_buffer));
+	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "linked_list_buffer = %p\n",
+		linked_list_buffer));
 
 	/*
 	 * Params already validated, so we don't re-validate here
 	 *
-	 * Pass the Linked_list_buffer into a module that can calculate
+	 * Pass the linked_list_buffer into a module that calculates
 	 * the buffer size needed for the byte stream.
 	 */
-	status = acpi_rs_calculate_byte_stream_length (linked_list_buffer,
+	status = acpi_rs_get_byte_stream_length (linked_list_buffer,
 			 &byte_stream_size_needed);
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Byte_stream_size_needed=%X, %s\n",
-		byte_stream_size_needed, acpi_format_exception (status)));
-
-	/*
-	 * Exit with the error passed back
-	 */
+	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "byte_stream_size_needed=%X, %s\n",
+		(u32) byte_stream_size_needed, acpi_format_exception (status)));
 	if (ACPI_FAILURE (status)) {
 		return_ACPI_STATUS (status);
 	}
 
-	/*
-	 * If the linked list will fit into the available buffer
-	 * call to fill in the list
-	 */
-	if (byte_stream_size_needed <= *output_buffer_length) {
-		/*
-		 * Zero out the return buffer before proceeding
-		 */
-		MEMSET (output_buffer, 0x00, *output_buffer_length);
-
-		status = acpi_rs_list_to_byte_stream (linked_list_buffer, byte_stream_size_needed,
-				 &output_buffer);
+	/* Validate/Allocate/Clear caller buffer */
 
-		/*
-		 * Exit with the error passed back
-		 */
-		if (ACPI_FAILURE (status)) {
-			return_ACPI_STATUS (status);
-		}
-
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Output_buffer = %p\n", output_buffer));
+	status = acpi_ut_initialize_buffer (output_buffer, byte_stream_size_needed);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
 	}
 
-	else {
-		*output_buffer_length = byte_stream_size_needed;
-		return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
+	/* Do the conversion */
+
+	status = acpi_rs_list_to_byte_stream (linked_list_buffer, byte_stream_size_needed,
+			  output_buffer->pointer);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
 	}
 
+	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "output_buffer %p Length %X\n",
+			output_buffer->pointer, (u32) output_buffer->length));
 	return_ACPI_STATUS (AE_OK);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/resources/rsdump.c linux-2.4.22-pre2/drivers/acpi/resources/rsdump.c
--- linux-2.4.21/drivers/acpi/resources/rsdump.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/resources/rsdump.c	2003-06-26 21:43:10.000000000 +0000
@@ -1,41 +1,59 @@
 /*******************************************************************************
  *
  * Module Name: rsdump - Functions to display the resource structures.
- *              $Revision: 23 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acresrc.h"
+#include <acpi/acpi.h>
+#include <acpi/acresrc.h>
 
 #define _COMPONENT          ACPI_RESOURCES
-	 MODULE_NAME         ("rsdump")
+	 ACPI_MODULE_NAME    ("rsdump")
 
 
-#ifdef ACPI_DEBUG
+#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_dump_irq
+ * FUNCTION:    acpi_rs_dump_irq
  *
  * PARAMETERS:  Data            - pointer to the resource structure to dump.
  *
@@ -47,25 +65,25 @@
 
 void
 acpi_rs_dump_irq (
-	acpi_resource_data      *data)
+	union acpi_resource_data        *data)
 {
-	acpi_resource_irq       *irq_data = (acpi_resource_irq *) data;
-	u8                      index = 0;
+	struct acpi_resource_irq        *irq_data = (struct acpi_resource_irq *) data;
+	u8                              index = 0;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	acpi_os_printf ("IRQ Resource\n");
 
 	acpi_os_printf ("  %s Triggered\n",
-			 LEVEL_SENSITIVE == irq_data->edge_level ? "Level" : "Edge");
+			 ACPI_LEVEL_SENSITIVE == irq_data->edge_level ? "Level" : "Edge");
 
 	acpi_os_printf ("  Active %s\n",
-			 ACTIVE_LOW == irq_data->active_high_low ? "Low" : "High");
+			 ACPI_ACTIVE_LOW == irq_data->active_high_low ? "Low" : "High");
 
 	acpi_os_printf ("  %s\n",
-			 SHARED == irq_data->shared_exclusive ? "Shared" : "Exclusive");
+			 ACPI_SHARED == irq_data->shared_exclusive ? "Shared" : "Exclusive");
 
 	acpi_os_printf ("  %X Interrupts ( ", irq_data->number_of_interrupts);
 
@@ -80,7 +98,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_dump_dma
+ * FUNCTION:    acpi_rs_dump_dma
  *
  * PARAMETERS:  Data            - pointer to the resource structure to dump.
  *
@@ -92,31 +110,31 @@
 
 void
 acpi_rs_dump_dma (
-	acpi_resource_data      *data)
+	union acpi_resource_data        *data)
 {
-	acpi_resource_dma       *dma_data = (acpi_resource_dma *) data;
-	u8                      index = 0;
+	struct acpi_resource_dma        *dma_data = (struct acpi_resource_dma *) data;
+	u8                              index = 0;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	acpi_os_printf ("DMA Resource\n");
 
 	switch (dma_data->type) {
-	case COMPATIBILITY:
+	case ACPI_COMPATIBILITY:
 		acpi_os_printf ("  Compatibility mode\n");
 		break;
 
-	case TYPE_A:
+	case ACPI_TYPE_A:
 		acpi_os_printf ("  Type A\n");
 		break;
 
-	case TYPE_B:
+	case ACPI_TYPE_B:
 		acpi_os_printf ("  Type B\n");
 		break;
 
-	case TYPE_F:
+	case ACPI_TYPE_F:
 		acpi_os_printf ("  Type F\n");
 		break;
 
@@ -126,19 +144,19 @@
 	}
 
 	acpi_os_printf ("  %sBus Master\n",
-			 BUS_MASTER == dma_data->bus_master ? "" : "Not a ");
+			 ACPI_BUS_MASTER == dma_data->bus_master ? "" : "Not a ");
 
 
 	switch (dma_data->transfer) {
-	case TRANSFER_8:
+	case ACPI_TRANSFER_8:
 		acpi_os_printf ("  8-bit only transfer\n");
 		break;
 
-	case TRANSFER_8_16:
+	case ACPI_TRANSFER_8_16:
 		acpi_os_printf ("  8 and 16-bit transfer\n");
 		break;
 
-	case TRANSFER_16:
+	case ACPI_TRANSFER_16:
 		acpi_os_printf ("  16 bit only transfer\n");
 		break;
 
@@ -160,7 +178,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_dump_start_dependent_functions
+ * FUNCTION:    acpi_rs_dump_start_depend_fns
  *
  * PARAMETERS:  Data            - pointer to the resource structure to dump.
  *
@@ -171,27 +189,27 @@
  ******************************************************************************/
 
 void
-acpi_rs_dump_start_dependent_functions (
-	acpi_resource_data          *data)
+acpi_rs_dump_start_depend_fns (
+	union acpi_resource_data        *data)
 {
-	acpi_resource_start_dpf     *sdf_data = (acpi_resource_start_dpf *) data;
+	struct acpi_resource_start_dpf *sdf_data = (struct acpi_resource_start_dpf *) data;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	acpi_os_printf ("Start Dependent Functions Resource\n");
 
 	switch (sdf_data->compatibility_priority) {
-	case GOOD_CONFIGURATION:
+	case ACPI_GOOD_CONFIGURATION:
 		acpi_os_printf ("  Good configuration\n");
 		break;
 
-	case ACCEPTABLE_CONFIGURATION:
+	case ACPI_ACCEPTABLE_CONFIGURATION:
 		acpi_os_printf ("  Acceptable configuration\n");
 		break;
 
-	case SUB_OPTIMAL_CONFIGURATION:
+	case ACPI_SUB_OPTIMAL_CONFIGURATION:
 		acpi_os_printf ("  Sub-optimal configuration\n");
 		break;
 
@@ -201,15 +219,15 @@
 	}
 
 	switch(sdf_data->performance_robustness) {
-	case GOOD_CONFIGURATION:
+	case ACPI_GOOD_CONFIGURATION:
 		acpi_os_printf ("  Good configuration\n");
 		break;
 
-	case ACCEPTABLE_CONFIGURATION:
+	case ACPI_ACCEPTABLE_CONFIGURATION:
 		acpi_os_printf ("  Acceptable configuration\n");
 		break;
 
-	case SUB_OPTIMAL_CONFIGURATION:
+	case ACPI_SUB_OPTIMAL_CONFIGURATION:
 		acpi_os_printf ("  Sub-optimal configuration\n");
 		break;
 
@@ -225,7 +243,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_dump_io
+ * FUNCTION:    acpi_rs_dump_io
  *
  * PARAMETERS:  Data            - pointer to the resource structure to dump.
  *
@@ -237,18 +255,18 @@
 
 void
 acpi_rs_dump_io (
-	acpi_resource_data      *data)
+	union acpi_resource_data        *data)
 {
-	acpi_resource_io        *io_data = (acpi_resource_io *) data;
+	struct acpi_resource_io         *io_data = (struct acpi_resource_io *) data;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	acpi_os_printf ("Io Resource\n");
 
 	acpi_os_printf ("  %d bit decode\n",
-			 DECODE_16 == io_data->io_decode ? 16 : 10);
+			 ACPI_DECODE_16 == io_data->io_decode ? 16 : 10);
 
 	acpi_os_printf ("  Range minimum base: %08X\n",
 			 io_data->min_base_address);
@@ -268,7 +286,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_dump_fixed_io
+ * FUNCTION:    acpi_rs_dump_fixed_io
  *
  * PARAMETERS:  Data            - pointer to the resource structure to dump.
  *
@@ -280,12 +298,12 @@
 
 void
 acpi_rs_dump_fixed_io (
-	acpi_resource_data      *data)
+	union acpi_resource_data        *data)
 {
-	acpi_resource_fixed_io  *fixed_io_data = (acpi_resource_fixed_io *) data;
+	struct acpi_resource_fixed_io   *fixed_io_data = (struct acpi_resource_fixed_io *) data;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	acpi_os_printf ("Fixed Io Resource\n");
@@ -301,7 +319,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_dump_vendor_specific
+ * FUNCTION:    acpi_rs_dump_vendor_specific
  *
  * PARAMETERS:  Data            - pointer to the resource structure to dump.
  *
@@ -313,13 +331,13 @@
 
 void
 acpi_rs_dump_vendor_specific (
-	acpi_resource_data      *data)
+	union acpi_resource_data        *data)
 {
-	acpi_resource_vendor    *vendor_data = (acpi_resource_vendor *) data;
-	u16                     index = 0;
+	struct acpi_resource_vendor     *vendor_data = (struct acpi_resource_vendor *) data;
+	u16                             index = 0;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	acpi_os_printf ("Vendor Specific Resource\n");
@@ -337,7 +355,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_dump_memory24
+ * FUNCTION:    acpi_rs_dump_memory24
  *
  * PARAMETERS:  Data            - pointer to the resource structure to dump.
  *
@@ -349,18 +367,18 @@
 
 void
 acpi_rs_dump_memory24 (
-	acpi_resource_data      *data)
+	union acpi_resource_data        *data)
 {
-	acpi_resource_mem24     *memory24_data = (acpi_resource_mem24 *) data;
+	struct acpi_resource_mem24      *memory24_data = (struct acpi_resource_mem24 *) data;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	acpi_os_printf ("24-Bit Memory Range Resource\n");
 
 	acpi_os_printf ("  Read%s\n",
-			 READ_WRITE_MEMORY ==
+			 ACPI_READ_WRITE_MEMORY ==
 			 memory24_data->read_write_attribute ?
 			 "/Write" : " only");
 
@@ -382,7 +400,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_dump_memory32
+ * FUNCTION:    acpi_rs_dump_memory32
  *
  * PARAMETERS:  Data            - pointer to the resource structure to dump.
  *
@@ -394,18 +412,18 @@
 
 void
 acpi_rs_dump_memory32 (
-	acpi_resource_data      *data)
+	union acpi_resource_data        *data)
 {
-	acpi_resource_mem32     *memory32_data = (acpi_resource_mem32 *) data;
+	struct acpi_resource_mem32      *memory32_data = (struct acpi_resource_mem32 *) data;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	acpi_os_printf ("32-Bit Memory Range Resource\n");
 
 	acpi_os_printf ("  Read%s\n",
-			 READ_WRITE_MEMORY ==
+			 ACPI_READ_WRITE_MEMORY ==
 			 memory32_data->read_write_attribute ?
 			 "/Write" : " only");
 
@@ -427,7 +445,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_dump_fixed_memory32
+ * FUNCTION:    acpi_rs_dump_fixed_memory32
  *
  * PARAMETERS:  Data            - pointer to the resource structure to dump.
  *
@@ -439,18 +457,18 @@
 
 void
 acpi_rs_dump_fixed_memory32 (
-	acpi_resource_data          *data)
+	union acpi_resource_data            *data)
 {
-	acpi_resource_fixed_mem32   *fixed_memory32_data = (acpi_resource_fixed_mem32 *) data;
+	struct acpi_resource_fixed_mem32    *fixed_memory32_data = (struct acpi_resource_fixed_mem32 *) data;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	acpi_os_printf ("32-Bit Fixed Location Memory Range Resource\n");
 
 	acpi_os_printf ("  Read%s\n",
-			 READ_WRITE_MEMORY ==
+			 ACPI_READ_WRITE_MEMORY ==
 			 fixed_memory32_data->read_write_attribute ?
 			 "/Write" : " Only");
 
@@ -466,7 +484,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_dump_address16
+ * FUNCTION:    acpi_rs_dump_address16
  *
  * PARAMETERS:  Data            - pointer to the resource structure to dump.
  *
@@ -478,39 +496,39 @@
 
 void
 acpi_rs_dump_address16 (
-	acpi_resource_data      *data)
+	union acpi_resource_data        *data)
 {
-	acpi_resource_address16 *address16_data = (acpi_resource_address16 *) data;
+	struct acpi_resource_address16 *address16_data = (struct acpi_resource_address16 *) data;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	acpi_os_printf ("16-Bit Address Space Resource\n");
 	acpi_os_printf ("  Resource Type: ");
 
 	switch (address16_data->resource_type) {
-	case MEMORY_RANGE:
+	case ACPI_MEMORY_RANGE:
 
 		acpi_os_printf ("Memory Range\n");
 
 		switch (address16_data->attribute.memory.cache_attribute) {
-		case NON_CACHEABLE_MEMORY:
+		case ACPI_NON_CACHEABLE_MEMORY:
 			acpi_os_printf ("  Type Specific: "
 					  "Noncacheable memory\n");
 			break;
 
-		case CACHABLE_MEMORY:
+		case ACPI_CACHABLE_MEMORY:
 			acpi_os_printf ("  Type Specific: "
 					  "Cacheable memory\n");
 			break;
 
-		case WRITE_COMBINING_MEMORY:
+		case ACPI_WRITE_COMBINING_MEMORY:
 			acpi_os_printf ("  Type Specific: "
 					  "Write-combining memory\n");
 			break;
 
-		case PREFETCHABLE_MEMORY:
+		case ACPI_PREFETCHABLE_MEMORY:
 			acpi_os_printf ("  Type Specific: "
 					  "Prefetchable memory\n");
 			break;
@@ -522,27 +540,27 @@
 		}
 
 		acpi_os_printf ("  Type Specific: Read%s\n",
-			READ_WRITE_MEMORY ==
+			ACPI_READ_WRITE_MEMORY ==
 			address16_data->attribute.memory.read_write_attribute ?
 			"/Write" : " Only");
 		break;
 
-	case IO_RANGE:
+	case ACPI_IO_RANGE:
 
 		acpi_os_printf ("I/O Range\n");
 
 		switch (address16_data->attribute.io.range_attribute) {
-		case NON_ISA_ONLY_RANGES:
+		case ACPI_NON_ISA_ONLY_RANGES:
 			acpi_os_printf ("  Type Specific: "
 					  "Non-ISA Io Addresses\n");
 			break;
 
-		case ISA_ONLY_RANGES:
+		case ACPI_ISA_ONLY_RANGES:
 			acpi_os_printf ("  Type Specific: "
 					  "ISA Io Addresses\n");
 			break;
 
-		case ENTIRE_RANGE:
+		case ACPI_ENTIRE_RANGE:
 			acpi_os_printf ("  Type Specific: "
 					  "ISA and non-ISA Io Addresses\n");
 			break;
@@ -552,9 +570,14 @@
 					  "Invalid range attribute\n");
 			break;
 		}
+
+		acpi_os_printf (" Type Specific: %s Translation\n",
+			ACPI_SPARSE_TRANSLATION ==
+			address16_data->attribute.io.translation_attribute ?
+			"Sparse" : "Dense");
 		break;
 
-	case BUS_NUMBER_RANGE:
+	case ACPI_BUS_NUMBER_RANGE:
 
 		acpi_os_printf ("Bus Number Range\n");
 		break;
@@ -566,19 +589,19 @@
 	}
 
 	acpi_os_printf ("  Resource %s\n",
-			CONSUMER == address16_data->producer_consumer ?
+			ACPI_CONSUMER == address16_data->producer_consumer ?
 			"Consumer" : "Producer");
 
 	acpi_os_printf ("  %s decode\n",
-			 SUB_DECODE == address16_data->decode ?
+			 ACPI_SUB_DECODE == address16_data->decode ?
 			 "Subtractive" : "Positive");
 
 	acpi_os_printf ("  Min address is %s fixed\n",
-			 ADDRESS_FIXED == address16_data->min_address_fixed ?
+			 ACPI_ADDRESS_FIXED == address16_data->min_address_fixed ?
 			 "" : "not");
 
 	acpi_os_printf ("  Max address is %s fixed\n",
-			 ADDRESS_FIXED == address16_data->max_address_fixed ?
+			 ACPI_ADDRESS_FIXED == address16_data->max_address_fixed ?
 			 "" : "not");
 
 	acpi_os_printf ("  Granularity: %08X\n",
@@ -609,7 +632,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_dump_address32
+ * FUNCTION:    acpi_rs_dump_address32
  *
  * PARAMETERS:  Data            - pointer to the resource structure to dump.
  *
@@ -621,38 +644,38 @@
 
 void
 acpi_rs_dump_address32 (
-	acpi_resource_data      *data)
+	union acpi_resource_data        *data)
 {
-	acpi_resource_address32 *address32_data = (acpi_resource_address32 *) data;
+	struct acpi_resource_address32 *address32_data = (struct acpi_resource_address32 *) data;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	acpi_os_printf ("32-Bit Address Space Resource\n");
 
 	switch (address32_data->resource_type) {
-	case MEMORY_RANGE:
+	case ACPI_MEMORY_RANGE:
 
 		acpi_os_printf ("  Resource Type: Memory Range\n");
 
 		switch (address32_data->attribute.memory.cache_attribute) {
-		case NON_CACHEABLE_MEMORY:
+		case ACPI_NON_CACHEABLE_MEMORY:
 			acpi_os_printf ("  Type Specific: "
 					  "Noncacheable memory\n");
 			break;
 
-		case CACHABLE_MEMORY:
+		case ACPI_CACHABLE_MEMORY:
 			acpi_os_printf ("  Type Specific: "
 					  "Cacheable memory\n");
 			break;
 
-		case WRITE_COMBINING_MEMORY:
+		case ACPI_WRITE_COMBINING_MEMORY:
 			acpi_os_printf ("  Type Specific: "
 					  "Write-combining memory\n");
 			break;
 
-		case PREFETCHABLE_MEMORY:
+		case ACPI_PREFETCHABLE_MEMORY:
 			acpi_os_printf ("  Type Specific: "
 					  "Prefetchable memory\n");
 			break;
@@ -664,39 +687,44 @@
 		}
 
 		acpi_os_printf ("  Type Specific: Read%s\n",
-			READ_WRITE_MEMORY ==
+			ACPI_READ_WRITE_MEMORY ==
 			address32_data->attribute.memory.read_write_attribute ?
 			"/Write" : " Only");
 		break;
 
-	case IO_RANGE:
+	case ACPI_IO_RANGE:
 
 		acpi_os_printf ("  Resource Type: Io Range\n");
 
 		switch (address32_data->attribute.io.range_attribute) {
-			case NON_ISA_ONLY_RANGES:
-				acpi_os_printf ("  Type Specific: "
-						  "Non-ISA Io Addresses\n");
-				break;
+		case ACPI_NON_ISA_ONLY_RANGES:
+			acpi_os_printf ("  Type Specific: "
+					  "Non-ISA Io Addresses\n");
+			break;
 
-			case ISA_ONLY_RANGES:
-				acpi_os_printf ("  Type Specific: "
-						  "ISA Io Addresses\n");
-				break;
+		case ACPI_ISA_ONLY_RANGES:
+			acpi_os_printf ("  Type Specific: "
+					  "ISA Io Addresses\n");
+			break;
 
-			case ENTIRE_RANGE:
-				acpi_os_printf ("  Type Specific: "
-						  "ISA and non-ISA Io Addresses\n");
-				break;
+		case ACPI_ENTIRE_RANGE:
+			acpi_os_printf ("  Type Specific: "
+					  "ISA and non-ISA Io Addresses\n");
+			break;
 
-			default:
-				acpi_os_printf ("  Type Specific: "
-						  "Invalid Range attribute");
-				break;
-			}
+		default:
+			acpi_os_printf ("  Type Specific: "
+					  "Invalid Range attribute");
+			break;
+		}
+
+		acpi_os_printf (" Type Specific: %s Translation\n",
+			ACPI_SPARSE_TRANSLATION ==
+			address32_data->attribute.io.translation_attribute ?
+			"Sparse" : "Dense");
 		break;
 
-	case BUS_NUMBER_RANGE:
+	case ACPI_BUS_NUMBER_RANGE:
 
 		acpi_os_printf ("  Resource Type: Bus Number Range\n");
 		break;
@@ -708,19 +736,19 @@
 	}
 
 	acpi_os_printf ("  Resource %s\n",
-			 CONSUMER == address32_data->producer_consumer ?
+			 ACPI_CONSUMER == address32_data->producer_consumer ?
 			 "Consumer" : "Producer");
 
 	acpi_os_printf ("  %s decode\n",
-			 SUB_DECODE == address32_data->decode ?
+			 ACPI_SUB_DECODE == address32_data->decode ?
 			 "Subtractive" : "Positive");
 
 	acpi_os_printf ("  Min address is %s fixed\n",
-			 ADDRESS_FIXED == address32_data->min_address_fixed ?
+			 ACPI_ADDRESS_FIXED == address32_data->min_address_fixed ?
 			 "" : "not ");
 
 	acpi_os_printf ("  Max address is %s fixed\n",
-			 ADDRESS_FIXED == address32_data->max_address_fixed ?
+			 ACPI_ADDRESS_FIXED == address32_data->max_address_fixed ?
 			 "" : "not ");
 
 	acpi_os_printf ("  Granularity: %08X\n",
@@ -751,7 +779,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_dump_address64
+ * FUNCTION:    acpi_rs_dump_address64
  *
  * PARAMETERS:  Data            - pointer to the resource structure to dump.
  *
@@ -763,38 +791,38 @@
 
 void
 acpi_rs_dump_address64 (
-	acpi_resource_data      *data)
+	union acpi_resource_data        *data)
 {
-	acpi_resource_address64 *address64_data = (acpi_resource_address64 *) data;
+	struct acpi_resource_address64 *address64_data = (struct acpi_resource_address64 *) data;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	acpi_os_printf ("64-Bit Address Space Resource\n");
 
 	switch (address64_data->resource_type) {
-	case MEMORY_RANGE:
+	case ACPI_MEMORY_RANGE:
 
 		acpi_os_printf ("  Resource Type: Memory Range\n");
 
 		switch (address64_data->attribute.memory.cache_attribute) {
-		case NON_CACHEABLE_MEMORY:
+		case ACPI_NON_CACHEABLE_MEMORY:
 			acpi_os_printf ("  Type Specific: "
 					  "Noncacheable memory\n");
 			break;
 
-		case CACHABLE_MEMORY:
+		case ACPI_CACHABLE_MEMORY:
 			acpi_os_printf ("  Type Specific: "
 					  "Cacheable memory\n");
 			break;
 
-		case WRITE_COMBINING_MEMORY:
+		case ACPI_WRITE_COMBINING_MEMORY:
 			acpi_os_printf ("  Type Specific: "
 					  "Write-combining memory\n");
 			break;
 
-		case PREFETCHABLE_MEMORY:
+		case ACPI_PREFETCHABLE_MEMORY:
 			acpi_os_printf ("  Type Specific: "
 					  "Prefetchable memory\n");
 			break;
@@ -806,39 +834,44 @@
 		}
 
 		acpi_os_printf ("  Type Specific: Read%s\n",
-			READ_WRITE_MEMORY ==
+			ACPI_READ_WRITE_MEMORY ==
 			address64_data->attribute.memory.read_write_attribute ?
 			"/Write" : " Only");
 		break;
 
-	case IO_RANGE:
+	case ACPI_IO_RANGE:
 
 		acpi_os_printf ("  Resource Type: Io Range\n");
 
 		switch (address64_data->attribute.io.range_attribute) {
-			case NON_ISA_ONLY_RANGES:
-				acpi_os_printf ("  Type Specific: "
-						  "Non-ISA Io Addresses\n");
-				break;
+		case ACPI_NON_ISA_ONLY_RANGES:
+			acpi_os_printf ("  Type Specific: "
+					  "Non-ISA Io Addresses\n");
+			break;
 
-			case ISA_ONLY_RANGES:
-				acpi_os_printf ("  Type Specific: "
-						  "ISA Io Addresses\n");
-				break;
+		case ACPI_ISA_ONLY_RANGES:
+			acpi_os_printf ("  Type Specific: "
+					  "ISA Io Addresses\n");
+			break;
 
-			case ENTIRE_RANGE:
-				acpi_os_printf ("  Type Specific: "
-						  "ISA and non-ISA Io Addresses\n");
-				break;
+		case ACPI_ENTIRE_RANGE:
+			acpi_os_printf ("  Type Specific: "
+					  "ISA and non-ISA Io Addresses\n");
+			break;
 
-			default:
-				acpi_os_printf ("  Type Specific: "
-						  "Invalid Range attribute");
-				break;
-			}
+		default:
+			acpi_os_printf ("  Type Specific: "
+					  "Invalid Range attribute");
+			break;
+		}
+
+		acpi_os_printf (" Type Specific: %s Translation\n",
+			ACPI_SPARSE_TRANSLATION ==
+			address64_data->attribute.io.translation_attribute ?
+			"Sparse" : "Dense");
 		break;
 
-	case BUS_NUMBER_RANGE:
+	case ACPI_BUS_NUMBER_RANGE:
 
 		acpi_os_printf ("  Resource Type: Bus Number Range\n");
 		break;
@@ -850,35 +883,40 @@
 	}
 
 	acpi_os_printf ("  Resource %s\n",
-			 CONSUMER == address64_data->producer_consumer ?
+			 ACPI_CONSUMER == address64_data->producer_consumer ?
 			 "Consumer" : "Producer");
 
 	acpi_os_printf ("  %s decode\n",
-			 SUB_DECODE == address64_data->decode ?
+			 ACPI_SUB_DECODE == address64_data->decode ?
 			 "Subtractive" : "Positive");
 
 	acpi_os_printf ("  Min address is %s fixed\n",
-			 ADDRESS_FIXED == address64_data->min_address_fixed ?
+			 ACPI_ADDRESS_FIXED == address64_data->min_address_fixed ?
 			 "" : "not ");
 
 	acpi_os_printf ("  Max address is %s fixed\n",
-			 ADDRESS_FIXED == address64_data->max_address_fixed ?
+			 ACPI_ADDRESS_FIXED == address64_data->max_address_fixed ?
 			 "" : "not ");
 
-	acpi_os_printf ("  Granularity: %16X\n",
-			 address64_data->granularity);
-
-	acpi_os_printf ("  Address range min: %16X\n",
-			 address64_data->min_address_range);
-
-	acpi_os_printf ("  Address range max: %16X\n",
-			 address64_data->max_address_range);
-
-	acpi_os_printf ("  Address translation offset: %16X\n",
-			 address64_data->address_translation_offset);
-
-	acpi_os_printf ("  Address Length: %16X\n",
-			 address64_data->address_length);
+	acpi_os_printf ("  Granularity: %8.8X%8.8X\n",
+			 ACPI_HIDWORD (address64_data->granularity),
+			 ACPI_LODWORD (address64_data->granularity));
+
+	acpi_os_printf ("  Address range min: %8.8X%8.8X\n",
+			 ACPI_HIDWORD (address64_data->min_address_range),
+			 ACPI_HIDWORD (address64_data->min_address_range));
+
+	acpi_os_printf ("  Address range max: %8.8X%8.8X\n",
+			 ACPI_HIDWORD (address64_data->max_address_range),
+			 ACPI_HIDWORD (address64_data->max_address_range));
+
+	acpi_os_printf ("  Address translation offset: %8.8X%8.8X\n",
+			 ACPI_HIDWORD (address64_data->address_translation_offset),
+			 ACPI_HIDWORD (address64_data->address_translation_offset));
+
+	acpi_os_printf ("  Address Length: %8.8X%8.8X\n",
+			 ACPI_HIDWORD (address64_data->address_length),
+			 ACPI_HIDWORD (address64_data->address_length));
 
 	if(0xFF != address64_data->resource_source.index) {
 		acpi_os_printf ("  Resource Source Index: %X\n",
@@ -893,7 +931,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_dump_extended_irq
+ * FUNCTION:    acpi_rs_dump_extended_irq
  *
  * PARAMETERS:  Data            - pointer to the resource structure to dump.
  *
@@ -905,31 +943,31 @@
 
 void
 acpi_rs_dump_extended_irq (
-	acpi_resource_data      *data)
+	union acpi_resource_data        *data)
 {
-	acpi_resource_ext_irq   *ext_irq_data = (acpi_resource_ext_irq *) data;
-	u8                      index = 0;
+	struct acpi_resource_ext_irq    *ext_irq_data = (struct acpi_resource_ext_irq *) data;
+	u8                              index = 0;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	acpi_os_printf ("Extended IRQ Resource\n");
 
 	acpi_os_printf ("  Resource %s\n",
-			 CONSUMER == ext_irq_data->producer_consumer ?
+			 ACPI_CONSUMER == ext_irq_data->producer_consumer ?
 			 "Consumer" : "Producer");
 
 	acpi_os_printf ("  %s\n",
-			 LEVEL_SENSITIVE == ext_irq_data->edge_level ?
+			 ACPI_LEVEL_SENSITIVE == ext_irq_data->edge_level ?
 			 "Level" : "Edge");
 
 	acpi_os_printf ("  Active %s\n",
-			 ACTIVE_LOW == ext_irq_data->active_high_low ?
+			 ACPI_ACTIVE_LOW == ext_irq_data->active_high_low ?
 			 "low" : "high");
 
 	acpi_os_printf ("  %s\n",
-			 SHARED == ext_irq_data->shared_exclusive ?
+			 ACPI_SHARED == ext_irq_data->shared_exclusive ?
 			 "Shared" : "Exclusive");
 
 	acpi_os_printf ("  Interrupts : %X ( ",
@@ -954,7 +992,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_dump_resource_list
+ * FUNCTION:    acpi_rs_dump_resource_list
  *
  * PARAMETERS:  Data            - pointer to the resource structure to dump.
  *
@@ -966,18 +1004,18 @@
 
 void
 acpi_rs_dump_resource_list (
-	acpi_resource       *resource)
+	struct acpi_resource        *resource)
 {
-	u8                  count = 0;
-	u8                  done = FALSE;
+	u8                          count = 0;
+	u8                          done = FALSE;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	if (acpi_dbg_level & ACPI_LV_RESOURCES && _COMPONENT & acpi_dbg_layer) {
 		while (!done) {
-			acpi_os_printf ("Resource structure %x.\n", count++);
+			acpi_os_printf ("Resource structure %X.\n", count++);
 
 			switch (resource->id) {
 			case ACPI_RSTYPE_IRQ:
@@ -989,12 +1027,12 @@
 				break;
 
 			case ACPI_RSTYPE_START_DPF:
-				acpi_rs_dump_start_dependent_functions (&resource->data);
+				acpi_rs_dump_start_depend_fns (&resource->data);
 				break;
 
 			case ACPI_RSTYPE_END_DPF:
-				acpi_os_printf ("End_dependent_functions Resource\n");
-				/* Acpi_rs_dump_end_dependent_functions (Resource->Data);*/
+				acpi_os_printf ("end_dependent_functions Resource\n");
+				/* acpi_rs_dump_end_dependent_functions (Resource->Data);*/
 				break;
 
 			case ACPI_RSTYPE_IO:
@@ -1010,8 +1048,8 @@
 				break;
 
 			case ACPI_RSTYPE_END_TAG:
-				/*Rs_dump_end_tag (Resource->Data);*/
-				acpi_os_printf ("End_tag Resource\n");
+				/*rs_dump_end_tag (Resource->Data);*/
+				acpi_os_printf ("end_tag Resource\n");
 				done = TRUE;
 				break;
 
@@ -1049,7 +1087,7 @@
 
 			}
 
-			resource = POINTER_ADD (acpi_resource, resource, resource->length);
+			resource = ACPI_PTR_ADD (struct acpi_resource, resource, resource->length);
 		}
 	}
 
@@ -1058,7 +1096,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_dump_irq_list
+ * FUNCTION:    acpi_rs_dump_irq_list
  *
  * PARAMETERS:  Data            - pointer to the routing table to dump.
  *
@@ -1070,36 +1108,37 @@
 
 void
 acpi_rs_dump_irq_list (
-	u8                  *route_table)
+	u8                              *route_table)
 {
-	u8                  *buffer = route_table;
-	u8                  count = 0;
-	u8                  done = FALSE;
-	pci_routing_table   *prt_element;
+	u8                              *buffer = route_table;
+	u8                              count = 0;
+	u8                              done = FALSE;
+	struct acpi_pci_routing_table   *prt_element;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	if (acpi_dbg_level & ACPI_LV_RESOURCES && _COMPONENT & acpi_dbg_layer) {
-		prt_element = (pci_routing_table *) buffer;
+		prt_element = ACPI_CAST_PTR (struct acpi_pci_routing_table, buffer);
 
 		while (!done) {
 			acpi_os_printf ("PCI IRQ Routing Table structure %X.\n", count++);
 
-			acpi_os_printf ("  Address: %X\n",
-					 prt_element->address);
+			acpi_os_printf ("  Address: %8.8X%8.8X\n",
+					 ACPI_HIDWORD (prt_element->address),
+					 ACPI_LODWORD (prt_element->address));
 
 			acpi_os_printf ("  Pin: %X\n", prt_element->pin);
 
 			acpi_os_printf ("  Source: %s\n", prt_element->source);
 
-			acpi_os_printf ("  Source_index: %X\n",
+			acpi_os_printf ("  source_index: %X\n",
 					 prt_element->source_index);
 
 			buffer += prt_element->length;
 
-			prt_element = (pci_routing_table *) buffer;
+			prt_element = ACPI_CAST_PTR (struct acpi_pci_routing_table, buffer);
 
 			if(0 == prt_element->length) {
 				done = TRUE;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/resources/rsio.c linux-2.4.22-pre2/drivers/acpi/resources/rsio.c
--- linux-2.4.21/drivers/acpi/resources/rsio.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/resources/rsio.c	2003-06-26 21:43:10.000000000 +0000
@@ -1,73 +1,90 @@
 /*******************************************************************************
  *
  * Module Name: rsio - IO and DMA resource descriptors
- *              $Revision: 14 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acresrc.h"
+#include <acpi/acpi.h>
+#include <acpi/acresrc.h>
 
 #define _COMPONENT          ACPI_RESOURCES
-	 MODULE_NAME         ("rsio")
+	 ACPI_MODULE_NAME    ("rsio")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_io_resource
+ * FUNCTION:    acpi_rs_io_resource
  *
- * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
+ * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the byte_stream_buffer is
+ *                                        returned
+ *              output_buffer           - Pointer to the return data buffer
+ *              structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the Output_buffer. Return the
+ *              structure pointed to by the output_buffer. Return the
  *              number of bytes consumed from the byte stream.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_rs_io_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size)
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size)
 {
-	u8                      *buffer = byte_stream_buffer;
-	acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
-	u16                     temp16 = 0;
-	u8                      temp8 = 0;
-	u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_io);
+	u8                              *buffer = byte_stream_buffer;
+	struct acpi_resource            *output_struct = (void *) *output_buffer;
+	u16                             temp16 = 0;
+	u8                              temp8 = 0;
+	acpi_size                       struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_io);
 
 
-	FUNCTION_TRACE ("Rs_io_resource");
+	ACPI_FUNCTION_TRACE ("rs_io_resource");
 
 
 	/*
@@ -86,18 +103,18 @@
 	output_struct->data.io.io_decode = temp8 & 0x01;
 
 	/*
-	 * Check Min_base Address
+	 * Check min_base Address
 	 */
 	buffer += 1;
-	MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 	output_struct->data.io.min_base_address = temp16;
 
 	/*
-	 * Check Max_base Address
+	 * Check max_base Address
 	 */
 	buffer += 2;
-	MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 	output_struct->data.io.max_base_address = temp16;
 
@@ -110,7 +127,7 @@
 	output_struct->data.io.alignment = temp8;
 
 	/*
-	 * Check Range_length
+	 * Check range_length
 	 */
 	buffer += 1;
 	temp8 = *buffer;
@@ -120,7 +137,7 @@
 	/*
 	 * Set the Length parameter
 	 */
-	output_struct->length = struct_size;
+	output_struct->length = (u32) struct_size;
 
 	/*
 	 * Return the final size of the structure
@@ -132,41 +149,40 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_fixed_io_resource
+ * FUNCTION:    acpi_rs_fixed_io_resource
  *
- * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
+ * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the byte_stream_buffer is
+ *                                        returned
+ *              output_buffer           - Pointer to the return data buffer
+ *              structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the Output_buffer. Return the
+ *              structure pointed to by the output_buffer. Return the
  *              number of bytes consumed from the byte stream.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_rs_fixed_io_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size)
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size)
 {
-	u8                      *buffer = byte_stream_buffer;
-	acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
-	u16                     temp16 = 0;
-	u8                      temp8 = 0;
-	u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_fixed_io);
+	u8                              *buffer = byte_stream_buffer;
+	struct acpi_resource            *output_struct = (void *) *output_buffer;
+	u16                             temp16 = 0;
+	u8                              temp8 = 0;
+	acpi_size                       struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_fixed_io);
 
 
-	FUNCTION_TRACE ("Rs_fixed_io_resource");
+	ACPI_FUNCTION_TRACE ("rs_fixed_io_resource");
 
 
 	/*
@@ -180,12 +196,12 @@
 	 * Check Range Base Address
 	 */
 	buffer += 1;
-	MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 	output_struct->data.fixed_io.base_address = temp16;
 
 	/*
-	 * Check Range_length
+	 * Check range_length
 	 */
 	buffer += 2;
 	temp8 = *buffer;
@@ -195,7 +211,7 @@
 	/*
 	 * Set the Length parameter
 	 */
-	output_struct->length = struct_size;
+	output_struct->length = (u32) struct_size;
 
 	/*
 	 * Return the final size of the structure
@@ -207,13 +223,12 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_io_stream
+ * FUNCTION:    acpi_rs_io_stream
  *
- * PARAMETERS:  Linked_list             - Pointer to the resource linked list
- *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ * PARAMETERS:  linked_list             - Pointer to the resource linked list
+ *              output_buffer           - Pointer to the user's return buffer
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -224,16 +239,16 @@
 
 acpi_status
 acpi_rs_io_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed)
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed)
 {
-	u8                      *buffer = *output_buffer;
-	u16                     temp16 = 0;
-	u8                      temp8 = 0;
+	u8                              *buffer = *output_buffer;
+	u16                             temp16 = 0;
+	u8                              temp8 = 0;
 
 
-	FUNCTION_TRACE ("Rs_io_stream");
+	ACPI_FUNCTION_TRACE ("rs_io_stream");
 
 
 	/*
@@ -255,7 +270,7 @@
 	 */
 	temp16 = (u16) linked_list->data.io.min_base_address;
 
-	MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+	ACPI_MOVE_16_TO_16 (buffer, &temp16);
 	buffer += 2;
 
 	/*
@@ -263,7 +278,7 @@
 	 */
 	temp16 = (u16) linked_list->data.io.max_base_address;
 
-	MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+	ACPI_MOVE_16_TO_16 (buffer, &temp16);
 	buffer += 2;
 
 	/*
@@ -285,20 +300,19 @@
 	/*
 	 * Return the number of bytes consumed in this operation
 	 */
-	*bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+	*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_fixed_io_stream
+ * FUNCTION:    acpi_rs_fixed_io_stream
  *
- * PARAMETERS:  Linked_list             - Pointer to the resource linked list
- *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ * PARAMETERS:  linked_list             - Pointer to the resource linked list
+ *              output_buffer           - Pointer to the user's return buffer
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -309,16 +323,16 @@
 
 acpi_status
 acpi_rs_fixed_io_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed)
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed)
 {
-	u8                      *buffer = *output_buffer;
-	u16                     temp16 = 0;
-	u8                      temp8 = 0;
+	u8                              *buffer = *output_buffer;
+	u16                             temp16 = 0;
+	u8                              temp8 = 0;
 
 
-	FUNCTION_TRACE ("Rs_fixed_io_stream");
+	ACPI_FUNCTION_TRACE ("rs_fixed_io_stream");
 
 
 	/*
@@ -333,7 +347,7 @@
 	 */
 	temp16 = (u16) linked_list->data.fixed_io.base_address;
 
-	MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+	ACPI_MOVE_16_TO_16 (buffer, &temp16);
 	buffer += 2;
 
 	/*
@@ -347,49 +361,48 @@
 	/*
 	 * Return the number of bytes consumed in this operation
 	 */
-	*bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+	*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_dma_resource
+ * FUNCTION:    acpi_rs_dma_resource
  *
- * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
+ * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the byte_stream_buffer is
+ *                                        returned
+ *              output_buffer           - Pointer to the return data buffer
+ *              structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the Output_buffer. Return the
+ *              structure pointed to by the output_buffer. Return the
  *              number of bytes consumed from the byte stream.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_rs_dma_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size)
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size)
 {
-	u8                      *buffer = byte_stream_buffer;
-	acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
-	u8                      temp8 = 0;
-	u8                      index;
-	u8                      i;
-	u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_dma);
+	u8                              *buffer = byte_stream_buffer;
+	struct acpi_resource            *output_struct = (void *) *output_buffer;
+	u8                              temp8 = 0;
+	u8                              index;
+	u8                              i;
+	acpi_size                       struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_dma);
 
 
-	FUNCTION_TRACE ("Rs_dma_resource");
+	ACPI_FUNCTION_TRACE ("rs_dma_resource");
 
 
 	/*
@@ -404,7 +417,7 @@
 	buffer += 1;
 	temp8 = *buffer;
 
-	/* Decode the IRQ bits */
+	/* Decode the DMA channel bits */
 
 	for (i = 0, index = 0; index < 8; index++) {
 		if ((temp8 >> index) & 0x01) {
@@ -412,13 +425,16 @@
 			i++;
 		}
 	}
-	output_struct->data.dma.number_of_channels = i;
 
+	/* Zero DMA channels is valid */
 
-	/*
-	 * Calculate the structure size based upon the number of interrupts
-	 */
-	struct_size += (output_struct->data.dma.number_of_channels - 1) * 4;
+	output_struct->data.dma.number_of_channels = i;
+	if (i > 0) {
+		/*
+		 * Calculate the structure size based upon the number of interrupts
+		 */
+		struct_size += ((acpi_size) i - 1) * 4;
+	}
 
 	/*
 	 * Point to Byte 2
@@ -432,6 +448,7 @@
 	output_struct->data.dma.transfer = temp8 & 0x03;
 
 	if (0x03 == output_struct->data.dma.transfer) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid DMA.Transfer preference (3)\n"));
 		return_ACPI_STATUS (AE_BAD_DATA);
 	}
 
@@ -448,7 +465,7 @@
 	/*
 	 * Set the Length parameter
 	 */
-	output_struct->length = struct_size;
+	output_struct->length = (u32) struct_size;
 
 	/*
 	 * Return the final size of the structure
@@ -460,13 +477,12 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_dma_stream
+ * FUNCTION:    acpi_rs_dma_stream
  *
- * PARAMETERS:  Linked_list             - Pointer to the resource linked list
- *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ * PARAMETERS:  linked_list             - Pointer to the resource linked list
+ *              output_buffer           - Pointer to the user's return buffer
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -477,17 +493,17 @@
 
 acpi_status
 acpi_rs_dma_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed)
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed)
 {
-	u8                      *buffer = *output_buffer;
-	u16                     temp16 = 0;
-	u8                      temp8 = 0;
-	u8                      index;
+	u8                              *buffer = *output_buffer;
+	u16                             temp16 = 0;
+	u8                              temp8 = 0;
+	u8                              index;
 
 
-	FUNCTION_TRACE ("Rs_dma_stream");
+	ACPI_FUNCTION_TRACE ("rs_dma_stream");
 
 
 	/*
@@ -523,7 +539,7 @@
 	/*
 	 * Return the number of bytes consumed in this operation
 	 */
-	*bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+	*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
 	return_ACPI_STATUS (AE_OK);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/resources/rsirq.c linux-2.4.22-pre2/drivers/acpi/resources/rsirq.c
--- linux-2.4.21/drivers/acpi/resources/rsirq.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/resources/rsirq.c	2003-06-26 21:43:20.000000000 +0000
@@ -1,75 +1,92 @@
 /*******************************************************************************
  *
  * Module Name: rsirq - IRQ resource descriptors
- *              $Revision: 18 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acresrc.h"
+#include <acpi/acpi.h>
+#include <acpi/acresrc.h>
 
 #define _COMPONENT          ACPI_RESOURCES
-	 MODULE_NAME         ("rsirq")
+	 ACPI_MODULE_NAME    ("rsirq")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_irq_resource
+ * FUNCTION:    acpi_rs_irq_resource
  *
- * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
+ * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the byte_stream_buffer is
+ *                                        returned
+ *              output_buffer           - Pointer to the return data buffer
+ *              structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the Output_buffer. Return the
+ *              structure pointed to by the output_buffer. Return the
  *              number of bytes consumed from the byte stream.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_rs_irq_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size)
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size)
 {
-	u8                      *buffer = byte_stream_buffer;
-	acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
-	u16                     temp16 = 0;
-	u8                      temp8 = 0;
-	u8                      index;
-	u8                      i;
-	u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_irq);
+	u8                              *buffer = byte_stream_buffer;
+	struct acpi_resource            *output_struct = (void *) *output_buffer;
+	u16                             temp16 = 0;
+	u8                              temp8 = 0;
+	u8                              index;
+	u8                              i;
+	acpi_size                       struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_irq);
 
 
-	FUNCTION_TRACE ("Rs_irq_resource");
+	ACPI_FUNCTION_TRACE ("rs_irq_resource");
 
 
 	/*
@@ -84,24 +101,28 @@
 	 * Point to the 16-bits of Bytes 1 and 2
 	 */
 	buffer += 1;
-	MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 	output_struct->data.irq.number_of_interrupts = 0;
 
 	/* Decode the IRQ bits */
 
 	for (i = 0, index = 0; index < 16; index++) {
-		if((temp16 >> index) & 0x01) {
+		if ((temp16 >> index) & 0x01) {
 			output_struct->data.irq.interrupts[i] = index;
 			i++;
 		}
 	}
-	output_struct->data.irq.number_of_interrupts = i;
 
-	/*
-	 * Calculate the structure size based upon the number of interrupts
-	 */
-	struct_size += (output_struct->data.irq.number_of_interrupts - 1) * 4;
+	/* Zero interrupts is valid */
+
+	output_struct->data.irq.number_of_interrupts = i;
+	if (i > 0) {
+		/*
+		 * Calculate the structure size based upon the number of interrupts
+		 */
+		struct_size += ((acpi_size) i - 1) * 4;
+	}
 
 	/*
 	 * Point to Byte 3 if it is used
@@ -114,22 +135,21 @@
 		 * Check for HE, LL or HL
 		 */
 		if (temp8 & 0x01) {
-			output_struct->data.irq.edge_level = EDGE_SENSITIVE;
-			output_struct->data.irq.active_high_low = ACTIVE_HIGH;
+			output_struct->data.irq.edge_level = ACPI_EDGE_SENSITIVE;
+			output_struct->data.irq.active_high_low = ACPI_ACTIVE_HIGH;
 		}
-
 		else {
 			if (temp8 & 0x8) {
-				output_struct->data.irq.edge_level = LEVEL_SENSITIVE;
-				output_struct->data.irq.active_high_low = ACTIVE_LOW;
+				output_struct->data.irq.edge_level = ACPI_LEVEL_SENSITIVE;
+				output_struct->data.irq.active_high_low = ACPI_ACTIVE_LOW;
 			}
-
 			else {
 				/*
 				 * Only _LL and _HE polarity/trigger interrupts
 				 * are allowed (ACPI spec v1.0b ection 6.4.2.1),
 				 * so an error will occur if we reach this point
 				 */
+				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid interrupt polarity/trigger in resource list\n"));
 				return_ACPI_STATUS (AE_BAD_DATA);
 			}
 		}
@@ -139,21 +159,20 @@
 		 */
 		output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01;
 	}
-
 	else {
 		/*
 		 * Assume Edge Sensitive, Active High, Non-Sharable
 		 * per ACPI Specification
 		 */
-		output_struct->data.irq.edge_level = EDGE_SENSITIVE;
-		output_struct->data.irq.active_high_low = ACTIVE_HIGH;
-		output_struct->data.irq.shared_exclusive = EXCLUSIVE;
+		output_struct->data.irq.edge_level = ACPI_EDGE_SENSITIVE;
+		output_struct->data.irq.active_high_low = ACPI_ACTIVE_HIGH;
+		output_struct->data.irq.shared_exclusive = ACPI_EXCLUSIVE;
 	}
 
 	/*
 	 * Set the Length parameter
 	 */
-	output_struct->length = struct_size;
+	output_struct->length = (u32) struct_size;
 
 	/*
 	 * Return the final size of the structure
@@ -165,13 +184,12 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_irq_stream
+ * FUNCTION:    acpi_rs_irq_stream
  *
- * PARAMETERS:  Linked_list             - Pointer to the resource linked list
- *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ * PARAMETERS:  linked_list             - Pointer to the resource linked list
+ *              output_buffer           - Pointer to the user's return buffer
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -182,34 +200,33 @@
 
 acpi_status
 acpi_rs_irq_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed)
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed)
 {
-	u8                      *buffer = *output_buffer;
-	u16                     temp16 = 0;
-	u8                      temp8 = 0;
-	u8                      index;
-	u8                      IRQinfo_byte_needed;
+	u8                              *buffer = *output_buffer;
+	u16                             temp16 = 0;
+	u8                              temp8 = 0;
+	u8                              index;
+	u8                              IRqinfo_byte_needed;
 
 
-	FUNCTION_TRACE ("Rs_irq_stream");
+	ACPI_FUNCTION_TRACE ("rs_irq_stream");
 
 
 	/*
 	 * The descriptor field is set based upon whether a third byte is
 	 * needed to contain the IRQ Information.
 	 */
-	if (EDGE_SENSITIVE == linked_list->data.irq.edge_level &&
-		ACTIVE_HIGH == linked_list->data.irq.active_high_low &&
-		EXCLUSIVE == linked_list->data.irq.shared_exclusive) {
+	if (ACPI_EDGE_SENSITIVE == linked_list->data.irq.edge_level &&
+		ACPI_ACTIVE_HIGH == linked_list->data.irq.active_high_low &&
+		ACPI_EXCLUSIVE == linked_list->data.irq.shared_exclusive) {
 		*buffer = 0x22;
-		IRQinfo_byte_needed = FALSE;
+		IRqinfo_byte_needed = FALSE;
 	}
-
 	else {
 		*buffer = 0x23;
-		IRQinfo_byte_needed = TRUE;
+		IRqinfo_byte_needed = TRUE;
 	}
 
 	buffer += 1;
@@ -225,22 +242,21 @@
 		temp16 |= 0x1 << temp8;
 	}
 
-	MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+	ACPI_MOVE_16_TO_16 (buffer, &temp16);
 	buffer += 2;
 
 	/*
 	 * Set the IRQ Info byte if needed.
 	 */
-	if (IRQinfo_byte_needed) {
+	if (IRqinfo_byte_needed) {
 		temp8 = 0;
 		temp8 = (u8) ((linked_list->data.irq.shared_exclusive &
 				 0x01) << 4);
 
-		if (LEVEL_SENSITIVE == linked_list->data.irq.edge_level &&
-			ACTIVE_LOW == linked_list->data.irq.active_high_low) {
+		if (ACPI_LEVEL_SENSITIVE == linked_list->data.irq.edge_level &&
+			ACPI_ACTIVE_LOW == linked_list->data.irq.active_high_low) {
 			temp8 |= 0x08;
 		}
-
 		else {
 			temp8 |= 0x01;
 		}
@@ -252,57 +268,56 @@
 	/*
 	 * Return the number of bytes consumed in this operation
 	 */
-	*bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+	*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_extended_irq_resource
+ * FUNCTION:    acpi_rs_extended_irq_resource
  *
- * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
+ * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the byte_stream_buffer is
+ *                                        returned
+ *              output_buffer           - Pointer to the return data buffer
+ *              structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the Output_buffer. Return the
+ *              structure pointed to by the output_buffer. Return the
  *              number of bytes consumed from the byte stream.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_rs_extended_irq_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size)
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size)
 {
-	u8                      *buffer = byte_stream_buffer;
-	acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
-	u16                     temp16 = 0;
-	u8                      temp8 = 0;
-	NATIVE_CHAR             *temp_ptr;
-	u8                      index;
-	u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_ext_irq);
+	u8                              *buffer = byte_stream_buffer;
+	struct acpi_resource            *output_struct = (void *) *output_buffer;
+	u16                             temp16 = 0;
+	u8                              temp8 = 0;
+	u8                              *temp_ptr;
+	u8                              index;
+	acpi_size                       struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_ext_irq);
 
 
-	FUNCTION_TRACE ("Rs_extended_irq_resource");
+	ACPI_FUNCTION_TRACE ("rs_extended_irq_resource");
 
 
 	/*
 	 * Point past the Descriptor to get the number of bytes consumed
 	 */
 	buffer += 1;
-	MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 	*bytes_consumed = temp16 + 3;
 	output_struct->id = ACPI_RSTYPE_EXT_IRQ;
@@ -316,28 +331,20 @@
 	output_struct->data.extended_irq.producer_consumer = temp8 & 0x01;
 
 	/*
-	 * Check for HE, LL or HL
+	 * Check for Interrupt Mode
+	 *
+	 * The definition of an Extended IRQ changed between ACPI spec v1.0b
+	 * and ACPI spec 2.0 (section 6.4.3.6 in both).
+	 *
+	 * - Edge/Level are defined opposite in the table vs the headers
 	 */
-	if(temp8 & 0x02) {
-		output_struct->data.extended_irq.edge_level = EDGE_SENSITIVE;
-		output_struct->data.extended_irq.active_high_low = ACTIVE_HIGH;
-	}
+	output_struct->data.extended_irq.edge_level =
+			   (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE;
 
-	else {
-		if(temp8 & 0x4) {
-			output_struct->data.extended_irq.edge_level = LEVEL_SENSITIVE;
-			output_struct->data.extended_irq.active_high_low = ACTIVE_LOW;
-		}
-
-		else {
-			/*
-			 * Only _LL and _HE polarity/trigger interrupts
-			 * are allowed (ACPI spec v1.0b ection 6.4.2.1),
-			 * so an error will occur if we reach this point
-			 */
-			return_ACPI_STATUS (AE_BAD_DATA);
-		}
-	}
+	/*
+	 * Check Interrupt Polarity
+	 */
+	output_struct->data.extended_irq.active_high_low = (temp8 >> 2) & 0x1;
 
 	/*
 	 * Check for sharable
@@ -367,8 +374,8 @@
 	 * Cycle through every IRQ in the table
 	 */
 	for (index = 0; index < temp8; index++) {
-		output_struct->data.extended_irq.interrupts[index] =
-				(u32)*buffer;
+		ACPI_MOVE_32_TO_32 (
+			&output_struct->data.extended_irq.interrupts[index], buffer);
 
 		/* Point to the next IRQ */
 
@@ -383,7 +390,7 @@
 	 * stream that are default.
 	 */
 	if (*bytes_consumed >
-		(u32)(output_struct->data.extended_irq.number_of_interrupts * 4) + 5) {
+		((acpi_size) output_struct->data.extended_irq.number_of_interrupts * 4) + 5) {
 		/* Dereference the Index */
 
 		temp8 = *buffer;
@@ -397,14 +404,13 @@
 		 * Point the String pointer to the end of this structure.
 		 */
 		output_struct->data.extended_irq.resource_source.string_ptr =
-				(NATIVE_CHAR *)(output_struct + struct_size);
+				(char *)(output_struct + struct_size);
 
-		temp_ptr = output_struct->data.extended_irq.resource_source.string_ptr;
+		temp_ptr = (u8 *) output_struct->data.extended_irq.resource_source.string_ptr;
 
 		/* Copy the string into the buffer */
 
 		index = 0;
-
 		while (0x00 != *buffer) {
 			*temp_ptr = *buffer;
 
@@ -420,14 +426,13 @@
 		output_struct->data.extended_irq.resource_source.string_length = index + 1;
 
 		/*
-		 * In order for the Struct_size to fall on a 32-bit boundary,
+		 * In order for the struct_size to fall on a 32-bit boundary,
 		 * calculate the length of the string and expand the
-		 * Struct_size to the next 32-bit boundary.
+		 * struct_size to the next 32-bit boundary.
 		 */
 		temp8 = (u8) (index + 1);
-		struct_size += ROUND_UP_TO_32_bITS (temp8);
+		struct_size += ACPI_ROUND_UP_to_32_bITS (temp8);
 	}
-
 	else {
 		output_struct->data.extended_irq.resource_source.index = 0x00;
 		output_struct->data.extended_irq.resource_source.string_length = 0;
@@ -437,7 +442,7 @@
 	/*
 	 * Set the Length parameter
 	 */
-	output_struct->length = struct_size;
+	output_struct->length = (u32) struct_size;
 
 	/*
 	 * Return the final size of the structure
@@ -449,13 +454,12 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_extended_irq_stream
+ * FUNCTION:    acpi_rs_extended_irq_stream
  *
- * PARAMETERS:  Linked_list             - Pointer to the resource linked list
- *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ * PARAMETERS:  linked_list             - Pointer to the resource linked list
+ *              output_buffer           - Pointer to the user's return buffer
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -466,18 +470,18 @@
 
 acpi_status
 acpi_rs_extended_irq_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed)
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed)
 {
-	u8                      *buffer = *output_buffer;
-	u16                     *length_field;
-	u8                      temp8 = 0;
-	u8                      index;
-	NATIVE_CHAR             *temp_pointer = NULL;
+	u8                              *buffer = *output_buffer;
+	u16                             *length_field;
+	u8                              temp8 = 0;
+	u8                              index;
+	char                            *temp_pointer = NULL;
 
 
-	FUNCTION_TRACE ("Rs_extended_irq_stream");
+	ACPI_FUNCTION_TRACE ("rs_extended_irq_stream");
 
 
 	/*
@@ -489,7 +493,7 @@
 	/*
 	 * Set a pointer to the Length field - to be filled in later
 	 */
-	length_field = (u16 *)buffer;
+	length_field = ACPI_CAST_PTR (u16, buffer);
 	buffer += 2;
 
 	/*
@@ -498,14 +502,24 @@
 	temp8 = (u8)(linked_list->data.extended_irq.producer_consumer & 0x01);
 	temp8 |= ((linked_list->data.extended_irq.shared_exclusive & 0x01) << 3);
 
-	if (LEVEL_SENSITIVE == linked_list->data.extended_irq.edge_level &&
-	   ACTIVE_LOW == linked_list->data.extended_irq.active_high_low) {
-		temp8 |= 0x04;
-	}
-	else {
-		temp8 |= 0x02;
+	/*
+	 * Set the Interrupt Mode
+	 *
+	 * The definition of an Extended IRQ changed between ACPI spec v1.0b
+	 * and ACPI spec 2.0 (section 6.4.3.6 in both).  This code does not
+	 * implement the more restrictive definition of 1.0b
+	 *
+	 * - Edge/Level are defined opposite in the table vs the headers
+	 */
+	if (ACPI_EDGE_SENSITIVE == linked_list->data.extended_irq.edge_level) {
+		temp8 |= 0x2;
 	}
 
+	/*
+	 * Set the Interrupt Polarity
+	 */
+	temp8 |= ((linked_list->data.extended_irq.active_high_low & 0x1) << 2);
+
 	*buffer = temp8;
 	buffer += 1;
 
@@ -519,7 +533,7 @@
 
 	for (index = 0; index < linked_list->data.extended_irq.number_of_interrupts;
 		 index++) {
-		MOVE_UNALIGNED32_TO_32 (buffer,
+		ACPI_MOVE_32_TO_32 (buffer,
 				  &linked_list->data.extended_irq.interrupts[index]);
 		buffer += 4;
 	}
@@ -531,25 +545,25 @@
 		*buffer = (u8) linked_list->data.extended_irq.resource_source.index;
 		buffer += 1;
 
-		temp_pointer = (NATIVE_CHAR *) buffer;
+		temp_pointer = (char *) buffer;
 
 		/*
 		 * Copy the string
 		 */
-		STRCPY (temp_pointer,
+		ACPI_STRCPY (temp_pointer,
 			linked_list->data.extended_irq.resource_source.string_ptr);
 
 		/*
 		 * Buffer needs to be set to the length of the sting + one for the
 		 * terminating null
 		 */
-		buffer += (STRLEN (linked_list->data.extended_irq.resource_source.string_ptr) + 1);
+		buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.extended_irq.resource_source.string_ptr) + 1);
 	}
 
 	/*
 	 * Return the number of bytes consumed in this operation
 	 */
-	*bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+	*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
 
 	/*
 	 * Set the length field to the number of bytes consumed
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/resources/rslist.c linux-2.4.22-pre2/drivers/acpi/resources/rslist.c
--- linux-2.4.21/drivers/acpi/resources/rslist.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/resources/rslist.c	2003-06-26 21:43:33.000000000 +0000
@@ -1,41 +1,59 @@
 /*******************************************************************************
  *
  * Module Name: rslist - Linked list utilities
- *              $Revision: 19 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acresrc.h"
+#include <acpi/acpi.h>
+#include <acpi/acresrc.h>
 
 #define _COMPONENT          ACPI_RESOURCES
-	 MODULE_NAME         ("rslist")
+	 ACPI_MODULE_NAME    ("rslist")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_get_resource_type
+ * FUNCTION:    acpi_rs_get_resource_type
  *
- * PARAMETERS:  Resource_start_byte     - Byte 0 of a resource descriptor
+ * PARAMETERS:  resource_start_byte     - Byte 0 of a resource descriptor
  *
  * RETURN:      The Resource Type (Name) with no extraneous bits
  *
@@ -46,31 +64,34 @@
 
 u8
 acpi_rs_get_resource_type (
-	u8                      resource_start_byte)
+	u8                              resource_start_byte)
 {
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/*
 	 * Determine if this is a small or large resource
 	 */
-	switch (resource_start_byte & RESOURCE_DESC_TYPE_MASK) {
-	case RESOURCE_DESC_TYPE_SMALL:
+	switch (resource_start_byte & ACPI_RDESC_TYPE_MASK) {
+	case ACPI_RDESC_TYPE_SMALL:
 
 		/*
 		 * Small Resource Type -- Only bits 6:3 are valid
 		 */
-		return ((u8) (resource_start_byte & RESOURCE_DESC_SMALL_MASK));
-		break;
+		return ((u8) (resource_start_byte & ACPI_RDESC_SMALL_MASK));
 
 
-	case RESOURCE_DESC_TYPE_LARGE:
+	case ACPI_RDESC_TYPE_LARGE:
 
 		/*
 		 * Large Resource Type -- All bits are valid
 		 */
 		return (resource_start_byte);
+
+
+	default:
+		/* No other types of resource descriptor */
 		break;
 	}
 
@@ -80,11 +101,11 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_byte_stream_to_list
+ * FUNCTION:    acpi_rs_byte_stream_to_list
  *
- * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource byte stream
- *              Byte_stream_buffer_length - Length of Byte_stream_buffer
- *              Output_buffer           - Pointer to the buffer that will
+ * PARAMETERS:  byte_stream_buffer      - Pointer to the resource byte stream
+ *              byte_stream_buffer_length - Length of byte_stream_buffer
+ *              output_buffer           - Pointer to the buffer that will
  *                                        contain the output structures
  *
  * RETURN:      Status
@@ -96,185 +117,184 @@
 
 acpi_status
 acpi_rs_byte_stream_to_list (
-	u8                      *byte_stream_buffer,
-	u32                     byte_stream_buffer_length,
-	u8                      **output_buffer)
+	u8                              *byte_stream_buffer,
+	u32                             byte_stream_buffer_length,
+	u8                              *output_buffer)
 {
-	acpi_status             status;
-	u32                     bytes_parsed = 0;
-	u8                      resource_type = 0;
-	u32                     bytes_consumed = 0;
-	u8                      **buffer = output_buffer;
-	u32                     structure_size = 0;
-	u8                      end_tag_processed = FALSE;
+	acpi_status                     status;
+	acpi_size                       bytes_parsed = 0;
+	u8                              resource_type = 0;
+	acpi_size                       bytes_consumed = 0;
+	u8                              *buffer = output_buffer;
+	acpi_size                       structure_size = 0;
+	u8                              end_tag_processed = FALSE;
+	struct acpi_resource            *resource;
 
-
-	FUNCTION_TRACE ("Rs_byte_stream_to_list");
+	ACPI_FUNCTION_TRACE ("rs_byte_stream_to_list");
 
 
 	while (bytes_parsed < byte_stream_buffer_length &&
-			FALSE == end_tag_processed) {
+			!end_tag_processed) {
 		/*
 		 * The next byte in the stream is the resource type
 		 */
 		resource_type = acpi_rs_get_resource_type (*byte_stream_buffer);
 
 		switch (resource_type) {
-		case RESOURCE_DESC_MEMORY_24:
+		case ACPI_RDESC_TYPE_MEMORY_24:
 			/*
 			 * 24-Bit Memory Resource
 			 */
 			status = acpi_rs_memory24_resource (byte_stream_buffer,
-					 &bytes_consumed, buffer, &structure_size);
+					 &bytes_consumed, &buffer, &structure_size);
 			break;
 
 
-		case RESOURCE_DESC_LARGE_VENDOR:
+		case ACPI_RDESC_TYPE_LARGE_VENDOR:
 			/*
 			 * Vendor Defined Resource
 			 */
 			status = acpi_rs_vendor_resource (byte_stream_buffer,
-					 &bytes_consumed, buffer, &structure_size);
+					 &bytes_consumed, &buffer, &structure_size);
 			break;
 
 
-		case RESOURCE_DESC_MEMORY_32:
+		case ACPI_RDESC_TYPE_MEMORY_32:
 			/*
 			 * 32-Bit Memory Range Resource
 			 */
 			status = acpi_rs_memory32_range_resource (byte_stream_buffer,
-					 &bytes_consumed, buffer, &structure_size);
+					 &bytes_consumed, &buffer, &structure_size);
 			break;
 
 
-		case RESOURCE_DESC_FIXED_MEMORY_32:
+		case ACPI_RDESC_TYPE_FIXED_MEMORY_32:
 			/*
 			 * 32-Bit Fixed Memory Resource
 			 */
 			status = acpi_rs_fixed_memory32_resource (byte_stream_buffer,
-					 &bytes_consumed, buffer, &structure_size);
+					 &bytes_consumed, &buffer, &structure_size);
 			break;
 
 
-		case RESOURCE_DESC_QWORD_ADDRESS_SPACE:
+		case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE:
 			/*
 			 * 64-Bit Address Resource
 			 */
 			status = acpi_rs_address64_resource (byte_stream_buffer,
-					 &bytes_consumed, buffer, &structure_size);
+					 &bytes_consumed, &buffer, &structure_size);
 			break;
 
 
-		case RESOURCE_DESC_DWORD_ADDRESS_SPACE:
+		case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE:
 			/*
 			 * 32-Bit Address Resource
 			 */
 			status = acpi_rs_address32_resource (byte_stream_buffer,
-					 &bytes_consumed, buffer, &structure_size);
+					 &bytes_consumed, &buffer, &structure_size);
 			break;
 
 
-		case RESOURCE_DESC_WORD_ADDRESS_SPACE:
+		case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE:
 			/*
 			 * 16-Bit Address Resource
 			 */
 			status = acpi_rs_address16_resource (byte_stream_buffer,
-					 &bytes_consumed, buffer, &structure_size);
+					 &bytes_consumed, &buffer, &structure_size);
 			break;
 
 
-		case RESOURCE_DESC_EXTENDED_XRUPT:
+		case ACPI_RDESC_TYPE_EXTENDED_XRUPT:
 			/*
 			 * Extended IRQ
 			 */
 			status = acpi_rs_extended_irq_resource (byte_stream_buffer,
-					 &bytes_consumed, buffer, &structure_size);
+					 &bytes_consumed, &buffer, &structure_size);
 			break;
 
 
-		case RESOURCE_DESC_IRQ_FORMAT:
+		case ACPI_RDESC_TYPE_IRQ_FORMAT:
 			/*
 			 * IRQ Resource
 			 */
 			status = acpi_rs_irq_resource (byte_stream_buffer,
-					 &bytes_consumed, buffer, &structure_size);
+					 &bytes_consumed, &buffer, &structure_size);
 			break;
 
 
-		case RESOURCE_DESC_DMA_FORMAT:
+		case ACPI_RDESC_TYPE_DMA_FORMAT:
 			/*
 			 * DMA Resource
 			 */
 			status = acpi_rs_dma_resource (byte_stream_buffer,
-					 &bytes_consumed, buffer, &structure_size);
+					 &bytes_consumed, &buffer, &structure_size);
 			break;
 
 
-		case RESOURCE_DESC_START_DEPENDENT:
+		case ACPI_RDESC_TYPE_START_DEPENDENT:
 			/*
 			 * Start Dependent Functions Resource
 			 */
-			status = acpi_rs_start_dependent_functions_resource (byte_stream_buffer,
-					 &bytes_consumed, buffer, &structure_size);
+			status = acpi_rs_start_depend_fns_resource (byte_stream_buffer,
+					 &bytes_consumed, &buffer, &structure_size);
 			break;
 
 
-		case RESOURCE_DESC_END_DEPENDENT:
+		case ACPI_RDESC_TYPE_END_DEPENDENT:
 			/*
 			 * End Dependent Functions Resource
 			 */
-			status = acpi_rs_end_dependent_functions_resource (byte_stream_buffer,
-					 &bytes_consumed, buffer, &structure_size);
+			status = acpi_rs_end_depend_fns_resource (byte_stream_buffer,
+					 &bytes_consumed, &buffer, &structure_size);
 			break;
 
 
-		case RESOURCE_DESC_IO_PORT:
+		case ACPI_RDESC_TYPE_IO_PORT:
 			/*
 			 * IO Port Resource
 			 */
 			status = acpi_rs_io_resource (byte_stream_buffer,
-					 &bytes_consumed, buffer, &structure_size);
+					 &bytes_consumed, &buffer, &structure_size);
 			break;
 
 
-		case RESOURCE_DESC_FIXED_IO_PORT:
+		case ACPI_RDESC_TYPE_FIXED_IO_PORT:
 			/*
 			 * Fixed IO Port Resource
 			 */
 			status = acpi_rs_fixed_io_resource (byte_stream_buffer,
-					 &bytes_consumed, buffer, &structure_size);
+					 &bytes_consumed, &buffer, &structure_size);
 			break;
 
 
-		case RESOURCE_DESC_SMALL_VENDOR:
+		case ACPI_RDESC_TYPE_SMALL_VENDOR:
 			/*
 			 * Vendor Specific Resource
 			 */
 			status = acpi_rs_vendor_resource (byte_stream_buffer,
-					 &bytes_consumed, buffer, &structure_size);
+					 &bytes_consumed, &buffer, &structure_size);
 			break;
 
 
-		case RESOURCE_DESC_END_TAG:
+		case ACPI_RDESC_TYPE_END_TAG:
 			/*
 			 * End Tag
 			 */
 			end_tag_processed = TRUE;
 			status = acpi_rs_end_tag_resource (byte_stream_buffer,
-					 &bytes_consumed, buffer, &structure_size);
+					 &bytes_consumed, &buffer, &structure_size);
 			break;
 
 
 		default:
 			/*
-			 * Invalid/Unknowns resource type
+			 * Invalid/Unknown resource type
 			 */
-			status = AE_AML_ERROR;
+			status = AE_AML_INVALID_RESOURCE_TYPE;
 			break;
 		}
 
-
-		if (!ACPI_SUCCESS(status)) {
+		if (ACPI_FAILURE (status)) {
 			return_ACPI_STATUS (status);
 		}
 
@@ -291,15 +311,17 @@
 		/*
 		 * Set the Buffer to the next structure
 		 */
-		*buffer += structure_size;
+		resource = ACPI_CAST_PTR (struct acpi_resource, buffer);
+		resource->length = ACPI_ALIGN_RESOURCE_SIZE(resource->length);
+		buffer += ACPI_ALIGN_RESOURCE_SIZE(structure_size);
 
 	} /*  end while */
 
 	/*
 	 * Check the reason for exiting the while loop
 	 */
-	if (TRUE != end_tag_processed) {
-		return_ACPI_STATUS (AE_AML_ERROR);
+	if (!end_tag_processed) {
+		return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
 	}
 
 	return_ACPI_STATUS (AE_OK);
@@ -308,16 +330,16 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_list_to_byte_stream
+ * FUNCTION:    acpi_rs_list_to_byte_stream
  *
- * PARAMETERS:  Linked_list             - Pointer to the resource linked list
- *              Byte_steam_size_needed  - Calculated size of the byte stream
+ * PARAMETERS:  linked_list             - Pointer to the resource linked list
+ *              byte_steam_size_needed  - Calculated size of the byte stream
  *                                        needed from calling
- *                                        Acpi_rs_calculate_byte_stream_length()
- *                                        The size of the Output_buffer is
+ *                                        acpi_rs_get_byte_stream_length()
+ *                                        The size of the output_buffer is
  *                                        guaranteed to be >=
- *                                        Byte_stream_size_needed
- *              Output_buffer           - Pointer to the buffer that will
+ *                                        byte_stream_size_needed
+ *              output_buffer           - Pointer to the buffer that will
  *                                        contain the byte stream
  *
  * RETURN:      Status
@@ -329,17 +351,17 @@
 
 acpi_status
 acpi_rs_list_to_byte_stream (
-	acpi_resource           *linked_list,
-	u32                     byte_stream_size_needed,
-	u8                      **output_buffer)
+	struct acpi_resource            *linked_list,
+	acpi_size                       byte_stream_size_needed,
+	u8                              *output_buffer)
 {
-	acpi_status             status;
-	u8                      *buffer = *output_buffer;
-	u32                     bytes_consumed = 0;
-	u8                      done = FALSE;
+	acpi_status                     status;
+	u8                              *buffer = output_buffer;
+	acpi_size                       bytes_consumed = 0;
+	u8                              done = FALSE;
 
 
-	FUNCTION_TRACE ("Rs_list_to_byte_stream");
+	ACPI_FUNCTION_TRACE ("rs_list_to_byte_stream");
 
 
 	while (!done) {
@@ -362,7 +384,7 @@
 			/*
 			 * Start Dependent Functions Resource
 			 */
-			status = acpi_rs_start_dependent_functions_stream (linked_list,
+			status = acpi_rs_start_depend_fns_stream (linked_list,
 					  &buffer, &bytes_consumed);
 			break;
 
@@ -370,7 +392,7 @@
 			/*
 			 * End Dependent Functions Resource
 			 */
-			status = acpi_rs_end_dependent_functions_stream (linked_list,
+			status = acpi_rs_end_depend_fns_stream (linked_list,
 					  &buffer, &bytes_consumed);
 			break;
 
@@ -467,13 +489,14 @@
 			 * If we get here, everything is out of sync,
 			 *  so exit with an error
 			 */
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid descriptor type (%X) in resource list\n",
+				linked_list->id));
 			status = AE_BAD_DATA;
 			break;
 
-		} /* switch (Linked_list->Id) */
-
+		} /* switch (linked_list->Id) */
 
-		if (!ACPI_SUCCESS(status)) {
+		if (ACPI_FAILURE (status)) {
 			return_ACPI_STATUS (status);
 		}
 
@@ -485,7 +508,7 @@
 		/*
 		 * Point to the next object
 		 */
-		linked_list = POINTER_ADD (acpi_resource,
+		linked_list = ACPI_PTR_ADD (struct acpi_resource,
 				  linked_list, linked_list->length);
 	}
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/resources/rsmemory.c linux-2.4.22-pre2/drivers/acpi/resources/rsmemory.c
--- linux-2.4.21/drivers/acpi/resources/rsmemory.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/resources/rsmemory.c	2003-06-26 21:43:15.000000000 +0000
@@ -1,73 +1,90 @@
 /*******************************************************************************
  *
  * Module Name: rsmem24 - Memory resource descriptors
- *              $Revision: 14 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acresrc.h"
+#include <acpi/acpi.h>
+#include <acpi/acresrc.h>
 
 #define _COMPONENT          ACPI_RESOURCES
-	 MODULE_NAME         ("rsmemory")
+	 ACPI_MODULE_NAME    ("rsmemory")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_memory24_resource
+ * FUNCTION:    acpi_rs_memory24_resource
  *
- * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
+ * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the byte_stream_buffer is
+ *                                        returned
+ *              output_buffer           - Pointer to the return data buffer
+ *              structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the Output_buffer. Return the
+ *              structure pointed to by the output_buffer. Return the
  *              number of bytes consumed from the byte stream.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_rs_memory24_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size)
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size)
 {
-	u8                      *buffer = byte_stream_buffer;
-	acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
-	u16                     temp16 = 0;
-	u8                      temp8 = 0;
-	u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_mem24);
+	u8                              *buffer = byte_stream_buffer;
+	struct acpi_resource            *output_struct = (void *) *output_buffer;
+	u16                             temp16 = 0;
+	u8                              temp8 = 0;
+	acpi_size                       struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_mem24);
 
 
-	FUNCTION_TRACE ("Rs_memory24_resource");
+	ACPI_FUNCTION_TRACE ("rs_memory24_resource");
 
 
 	/*
@@ -75,9 +92,9 @@
 	 */
 	buffer += 1;
 
-	MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 	buffer += 2;
-	*bytes_consumed = temp16 + 3;
+	*bytes_consumed = (acpi_size) temp16 + 3;
 	output_struct->id = ACPI_RSTYPE_MEM24;
 
 	/*
@@ -88,36 +105,36 @@
 	output_struct->data.memory24.read_write_attribute = temp8 & 0x01;
 
 	/*
-	 * Get Min_base_address (Bytes 4-5)
+	 * Get min_base_address (Bytes 4-5)
 	 */
-	MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 	buffer += 2;
 	output_struct->data.memory24.min_base_address = temp16;
 
 	/*
-	 * Get Max_base_address (Bytes 6-7)
+	 * Get max_base_address (Bytes 6-7)
 	 */
-	MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 	buffer += 2;
 	output_struct->data.memory24.max_base_address = temp16;
 
 	/*
 	 * Get Alignment (Bytes 8-9)
 	 */
-	MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 	buffer += 2;
 	output_struct->data.memory24.alignment = temp16;
 
 	/*
-	 * Get Range_length (Bytes 10-11)
+	 * Get range_length (Bytes 10-11)
 	 */
-	MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 	output_struct->data.memory24.range_length = temp16;
 
 	/*
 	 * Set the Length parameter
 	 */
-	output_struct->length = struct_size;
+	output_struct->length = (u32) struct_size;
 
 	/*
 	 * Return the final size of the structure
@@ -129,13 +146,12 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_memory24_stream
+ * FUNCTION:    acpi_rs_memory24_stream
  *
- * PARAMETERS:  Linked_list             - Pointer to the resource linked list
- *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ * PARAMETERS:  linked_list             - Pointer to the resource linked list
+ *              output_buffer           - Pointer to the user's return buffer
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -146,16 +162,16 @@
 
 acpi_status
 acpi_rs_memory24_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed)
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed)
 {
-	u8                      *buffer = *output_buffer;
-	u16                     temp16 = 0;
-	u8                      temp8 = 0;
+	u8                              *buffer = *output_buffer;
+	u16                             temp16 = 0;
+	u8                              temp8 = 0;
 
 
-	FUNCTION_TRACE ("Rs_memory24_stream");
+	ACPI_FUNCTION_TRACE ("rs_memory24_stream");
 
 
 	/*
@@ -168,7 +184,7 @@
 	 * The length field is static
 	 */
 	temp16 = 0x09;
-	MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+	ACPI_MOVE_16_TO_16 (buffer, &temp16);
 	buffer += 2;
 
 	/*
@@ -181,72 +197,71 @@
 	/*
 	 * Set the Range minimum base address
 	 */
-	MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.min_base_address);
+	ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.min_base_address);
 	buffer += 2;
 
 	/*
 	 * Set the Range maximum base address
 	 */
-	MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.max_base_address);
+	ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.max_base_address);
 	buffer += 2;
 
 	/*
 	 * Set the base alignment
 	 */
-	MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.alignment);
+	ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.alignment);
 	buffer += 2;
 
 	/*
 	 * Set the range length
 	 */
-	MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.range_length);
+	ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.range_length);
 	buffer += 2;
 
 	/*
 	 * Return the number of bytes consumed in this operation
 	 */
-	*bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+	*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_memory32_range_resource
+ * FUNCTION:    acpi_rs_memory32_range_resource
  *
- * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
+ * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the byte_stream_buffer is
+ *                                        returned
+ *              output_buffer           - Pointer to the return data buffer
+ *              structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the Output_buffer. Return the
+ *              structure pointed to by the output_buffer. Return the
  *              number of bytes consumed from the byte stream.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_rs_memory32_range_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size)
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size)
 {
-	u8                      *buffer = byte_stream_buffer;
-	acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
-	u16                     temp16 = 0;
-	u8                      temp8 = 0;
-	u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_mem32);
+	u8                              *buffer = byte_stream_buffer;
+	struct acpi_resource            *output_struct = (void *) *output_buffer;
+	u16                             temp16 = 0;
+	u8                              temp8 = 0;
+	acpi_size                       struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_mem32);
 
 
-	FUNCTION_TRACE ("Rs_memory32_range_resource");
+	ACPI_FUNCTION_TRACE ("rs_memory32_range_resource");
 
 
 	/*
@@ -254,19 +269,19 @@
 	 */
 	buffer += 1;
 
-	MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 	buffer += 2;
-	*bytes_consumed = temp16 + 3;
+	*bytes_consumed = (acpi_size) temp16 + 3;
 
 	output_struct->id = ACPI_RSTYPE_MEM32;
 
 	/*
 	 *  Point to the place in the output buffer where the data portion will
 	 *  begin.
-	 *  1. Set the RESOURCE_DATA * Data to point to it's own address, then
+	 *  1. Set the RESOURCE_DATA * Data to point to its own address, then
 	 *  2. Set the pointer to the next address.
 	 *
-	 *  NOTE: Output_struct->Data is cast to u8, otherwise, this addition adds
+	 *  NOTE: output_struct->Data is cast to u8, otherwise, this addition adds
 	 *  4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(u8)
 	 */
 
@@ -279,34 +294,32 @@
 	output_struct->data.memory32.read_write_attribute = temp8 & 0x01;
 
 	/*
-	 * Get Min_base_address (Bytes 4-7)
+	 * Get min_base_address (Bytes 4-7)
 	 */
-	MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.min_base_address,
-			 buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.min_base_address, buffer);
 	buffer += 4;
 
 	/*
-	 * Get Max_base_address (Bytes 8-11)
+	 * Get max_base_address (Bytes 8-11)
 	 */
-	MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.max_base_address,
-			 buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.max_base_address, buffer);
 	buffer += 4;
 
 	/*
 	 * Get Alignment (Bytes 12-15)
 	 */
-	MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.alignment, buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.alignment, buffer);
 	buffer += 4;
 
 	/*
-	 * Get Range_length (Bytes 16-19)
+	 * Get range_length (Bytes 16-19)
 	 */
-	MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.range_length, buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.range_length, buffer);
 
 	/*
 	 * Set the Length parameter
 	 */
-	output_struct->length = struct_size;
+	output_struct->length = (u32) struct_size;
 
 	/*
 	 * Return the final size of the structure
@@ -318,51 +331,50 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_fixed_memory32_resource
+ * FUNCTION:    acpi_rs_fixed_memory32_resource
  *
- * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
+ * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the byte_stream_buffer is
+ *                                        returned
+ *              output_buffer           - Pointer to the return data buffer
+ *              structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the Output_buffer. Return the
+ *              structure pointed to by the output_buffer. Return the
  *              number of bytes consumed from the byte stream.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_rs_fixed_memory32_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size)
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size)
 {
-	u8                      *buffer = byte_stream_buffer;
-	acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
-	u16                     temp16 = 0;
-	u8                      temp8 = 0;
-	u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_fixed_mem32);
+	u8                              *buffer = byte_stream_buffer;
+	struct acpi_resource            *output_struct = (void *) *output_buffer;
+	u16                             temp16 = 0;
+	u8                              temp8 = 0;
+	acpi_size                       struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_fixed_mem32);
 
 
-	FUNCTION_TRACE ("Rs_fixed_memory32_resource");
+	ACPI_FUNCTION_TRACE ("rs_fixed_memory32_resource");
 
 
 	/*
 	 * Point past the Descriptor to get the number of bytes consumed
 	 */
 	buffer += 1;
-	MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+	ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 	buffer += 2;
-	*bytes_consumed = temp16 + 3;
+	*bytes_consumed = (acpi_size) temp16 + 3;
 
 	output_struct->id = ACPI_RSTYPE_FIXED_MEM32;
 
@@ -374,22 +386,20 @@
 	output_struct->data.fixed_memory32.read_write_attribute = temp8 & 0x01;
 
 	/*
-	 * Get Range_base_address (Bytes 4-7)
+	 * Get range_base_address (Bytes 4-7)
 	 */
-	MOVE_UNALIGNED32_TO_32 (&output_struct->data.fixed_memory32.range_base_address,
-			 buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_base_address, buffer);
 	buffer += 4;
 
 	/*
-	 * Get Range_length (Bytes 8-11)
+	 * Get range_length (Bytes 8-11)
 	 */
-	MOVE_UNALIGNED32_TO_32 (&output_struct->data.fixed_memory32.range_length,
-			 buffer);
+	ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_length, buffer);
 
 	/*
 	 * Set the Length parameter
 	 */
-	output_struct->length = struct_size;
+	output_struct->length = (u32) struct_size;
 
 	/*
 	 * Return the final size of the structure
@@ -401,13 +411,12 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_memory32_range_stream
+ * FUNCTION:    acpi_rs_memory32_range_stream
  *
- * PARAMETERS:  Linked_list             - Pointer to the resource linked list
- *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ * PARAMETERS:  linked_list             - Pointer to the resource linked list
+ *              output_buffer           - Pointer to the user's return buffer
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -418,16 +427,16 @@
 
 acpi_status
 acpi_rs_memory32_range_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed)
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed)
 {
-	u8                      *buffer = *output_buffer;
-	u16                     temp16 = 0;
-	u8                      temp8 = 0;
+	u8                              *buffer = *output_buffer;
+	u16                             temp16 = 0;
+	u8                              temp8 = 0;
 
 
-	FUNCTION_TRACE ("Rs_memory32_range_stream");
+	ACPI_FUNCTION_TRACE ("rs_memory32_range_stream");
 
 
 	/*
@@ -441,7 +450,7 @@
 	 */
 	temp16 = 0x11;
 
-	MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+	ACPI_MOVE_16_TO_16 (buffer, &temp16);
 	buffer += 2;
 
 	/*
@@ -454,44 +463,43 @@
 	/*
 	 * Set the Range minimum base address
 	 */
-	MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.min_base_address);
+	ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.min_base_address);
 	buffer += 4;
 
 	/*
 	 * Set the Range maximum base address
 	 */
-	MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.max_base_address);
+	ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.max_base_address);
 	buffer += 4;
 
 	/*
 	 * Set the base alignment
 	 */
-	MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.alignment);
+	ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.alignment);
 	buffer += 4;
 
 	/*
 	 * Set the range length
 	 */
-	MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.range_length);
+	ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.range_length);
 	buffer += 4;
 
 	/*
 	 * Return the number of bytes consumed in this operation
 	 */
-	*bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+	*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_fixed_memory32_stream
+ * FUNCTION:    acpi_rs_fixed_memory32_stream
  *
- * PARAMETERS:  Linked_list             - Pointer to the resource linked list
- *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ * PARAMETERS:  linked_list             - Pointer to the resource linked list
+ *              output_buffer           - Pointer to the user's return buffer
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -502,16 +510,16 @@
 
 acpi_status
 acpi_rs_fixed_memory32_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed)
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed)
 {
-	u8                      *buffer = *output_buffer;
-	u16                     temp16 = 0;
-	u8                      temp8 = 0;
+	u8                              *buffer = *output_buffer;
+	u16                             temp16 = 0;
+	u8                              temp8 = 0;
 
 
-	FUNCTION_TRACE ("Rs_fixed_memory32_stream");
+	ACPI_FUNCTION_TRACE ("rs_fixed_memory32_stream");
 
 
 	/*
@@ -525,7 +533,7 @@
 	 */
 	temp16 = 0x09;
 
-	MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+	ACPI_MOVE_16_TO_16 (buffer, &temp16);
 	buffer += 2;
 
 	/*
@@ -538,21 +546,21 @@
 	/*
 	 * Set the Range base address
 	 */
-	MOVE_UNALIGNED32_TO_32 (buffer,
+	ACPI_MOVE_32_TO_32 (buffer,
 			 &linked_list->data.fixed_memory32.range_base_address);
 	buffer += 4;
 
 	/*
 	 * Set the range length
 	 */
-	MOVE_UNALIGNED32_TO_32 (buffer,
+	ACPI_MOVE_32_TO_32 (buffer,
 			 &linked_list->data.fixed_memory32.range_length);
 	buffer += 4;
 
 	/*
 	 * Return the number of bytes consumed in this operation
 	 */
-	*bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+	*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
 	return_ACPI_STATUS (AE_OK);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/resources/rsmisc.c linux-2.4.22-pre2/drivers/acpi/resources/rsmisc.c
--- linux-2.4.21/drivers/acpi/resources/rsmisc.c	2001-09-23 16:42:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/resources/rsmisc.c	2003-06-26 21:43:14.000000000 +0000
@@ -1,70 +1,87 @@
 /*******************************************************************************
  *
  * Module Name: rsmisc - Miscellaneous resource descriptors
- *              $Revision: 16 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acresrc.h"
+#include <acpi/acpi.h>
+#include <acpi/acresrc.h>
 
 #define _COMPONENT          ACPI_RESOURCES
-	 MODULE_NAME         ("rsmisc")
+	 ACPI_MODULE_NAME    ("rsmisc")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_end_tag_resource
+ * FUNCTION:    acpi_rs_end_tag_resource
  *
- * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
+ * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the byte_stream_buffer is
+ *                                        returned
+ *              output_buffer           - Pointer to the return data buffer
+ *              structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the Output_buffer. Return the
+ *              structure pointed to by the output_buffer. Return the
  *              number of bytes consumed from the byte stream.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_rs_end_tag_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size)
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size)
 {
-	acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
-	u32                     struct_size = ACPI_RESOURCE_LENGTH;
+	struct acpi_resource            *output_struct = (void *) *output_buffer;
+	acpi_size                       struct_size = ACPI_RESOURCE_LENGTH;
 
 
-	FUNCTION_TRACE ("Rs_end_tag_resource");
+	ACPI_FUNCTION_TRACE ("rs_end_tag_resource");
 
 
 	/*
@@ -92,13 +109,12 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_end_tag_stream
+ * FUNCTION:    acpi_rs_end_tag_stream
  *
- * PARAMETERS:  Linked_list             - Pointer to the resource linked list
- *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ * PARAMETERS:  linked_list             - Pointer to the resource linked list
+ *              output_buffer           - Pointer to the user's return buffer
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -109,15 +125,15 @@
 
 acpi_status
 acpi_rs_end_tag_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed)
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed)
 {
-	u8                      *buffer = *output_buffer;
-	u8                      temp8 = 0;
+	u8                              *buffer = *output_buffer;
+	u8                              temp8 = 0;
 
 
-	FUNCTION_TRACE ("Rs_end_tag_stream");
+	ACPI_FUNCTION_TRACE ("rs_end_tag_stream");
 
 
 	/*
@@ -138,49 +154,48 @@
 	/*
 	 * Return the number of bytes consumed in this operation
 	 */
-	*bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+	*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_vendor_resource
+ * FUNCTION:    acpi_rs_vendor_resource
  *
- * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
+ * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the byte_stream_buffer is
+ *                                        returned
+ *              output_buffer           - Pointer to the return data buffer
+ *              structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the Output_buffer. Return the
+ *              structure pointed to by the output_buffer. Return the
  *              number of bytes consumed from the byte stream.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_rs_vendor_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size)
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size)
 {
-	u8                      *buffer = byte_stream_buffer;
-	acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
-	u16                     temp16 = 0;
-	u8                      temp8 = 0;
-	u8                      index;
-	u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_vendor);
+	u8                              *buffer = byte_stream_buffer;
+	struct acpi_resource            *output_struct = (void *) *output_buffer;
+	u16                             temp16 = 0;
+	u8                              temp8 = 0;
+	u8                              index;
+	acpi_size                       struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_vendor);
 
 
-	FUNCTION_TRACE ("Rs_vendor_resource");
+	ACPI_FUNCTION_TRACE ("rs_vendor_resource");
 
 
 	/*
@@ -190,34 +205,31 @@
 
 	if (temp8 & 0x80) {
 		/*
-		 * Large Item
-		 * Point to the length field
+		 * Large Item, point to the length field
 		 */
 		buffer += 1;
 
 		/* Dereference */
 
-		MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+		ACPI_MOVE_16_TO_16 (&temp16, buffer);
 
 		/* Calculate bytes consumed */
 
-		*bytes_consumed = temp16 + 3;
+		*bytes_consumed = (acpi_size) temp16 + 3;
 
 		/* Point to the first vendor byte */
 
 		buffer += 2;
 	}
-
 	else {
 		/*
-		 * Small Item
-		 * Dereference the size
+		 * Small Item, dereference the size
 		 */
 		temp16 = (u8)(*buffer & 0x07);
 
 		/* Calculate bytes consumed */
 
-		*bytes_consumed = temp16 + 1;
+		*bytes_consumed = (acpi_size) temp16 + 1;
 
 		/* Point to the first vendor byte */
 
@@ -233,16 +245,16 @@
 	}
 
 	/*
-	 * In order for the Struct_size to fall on a 32-bit boundary,
+	 * In order for the struct_size to fall on a 32-bit boundary,
 	 * calculate the length of the vendor string and expand the
-	 * Struct_size to the next 32-bit boundary.
+	 * struct_size to the next 32-bit boundary.
 	 */
-	struct_size += ROUND_UP_TO_32_bITS (temp16);
+	struct_size += ACPI_ROUND_UP_to_32_bITS (temp16);
 
 	/*
 	 * Set the Length parameter
 	 */
-	output_struct->length = struct_size;
+	output_struct->length = (u32) struct_size;
 
 	/*
 	 * Return the final size of the structure
@@ -254,13 +266,12 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_vendor_stream
+ * FUNCTION:    acpi_rs_vendor_stream
  *
- * PARAMETERS:  Linked_list             - Pointer to the resource linked list
- *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ * PARAMETERS:  linked_list             - Pointer to the resource linked list
+ *              output_buffer           - Pointer to the user's return buffer
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -271,17 +282,17 @@
 
 acpi_status
 acpi_rs_vendor_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed)
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed)
 {
-	u8                      *buffer = *output_buffer;
-	u16                     temp16 = 0;
-	u8                      temp8 = 0;
-	u8                      index;
+	u8                              *buffer = *output_buffer;
+	u16                             temp16 = 0;
+	u8                              temp8 = 0;
+	u8                              index;
 
 
-	FUNCTION_TRACE ("Rs_vendor_stream");
+	ACPI_FUNCTION_TRACE ("rs_vendor_stream");
 
 
 	/*
@@ -289,25 +300,22 @@
 	 */
 	if(linked_list->data.vendor_specific.length > 7) {
 		/*
-		 * Large Item
-		 * Set the descriptor field and length bytes
+		 * Large Item, Set the descriptor field and length bytes
 		 */
 		*buffer = 0x84;
 		buffer += 1;
 
 		temp16 = (u16) linked_list->data.vendor_specific.length;
 
-		MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+		ACPI_MOVE_16_TO_16 (buffer, &temp16);
 		buffer += 2;
 	}
-
 	else {
 		/*
-		 * Small Item
-		 * Set the descriptor field
+		 * Small Item, Set the descriptor field
 		 */
 		temp8 = 0x70;
-		temp8 |= linked_list->data.vendor_specific.length;
+		temp8 |= (u8) linked_list->data.vendor_specific.length;
 
 		*buffer = temp8;
 		buffer += 1;
@@ -326,47 +334,46 @@
 	/*
 	 * Return the number of bytes consumed in this operation
 	 */
-	*bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+	*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_start_dependent_functions_resource
+ * FUNCTION:    acpi_rs_start_depend_fns_resource
  *
- * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
+ * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the byte_stream_buffer is
+ *                                        returned
+ *              output_buffer           - Pointer to the return data buffer
+ *              structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the Output_buffer. Return the
+ *              structure pointed to by the output_buffer. Return the
  *              number of bytes consumed from the byte stream.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_start_dependent_functions_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size)
+acpi_rs_start_depend_fns_resource (
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size)
 {
-	u8                      *buffer = byte_stream_buffer;
-	acpi_resource          *output_struct = (acpi_resource *) *output_buffer;
-	u8                      temp8 = 0;
-	u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_start_dpf);
+	u8                              *buffer = byte_stream_buffer;
+	struct acpi_resource            *output_struct = (void *) *output_buffer;
+	u8                              temp8 = 0;
+	acpi_size                       struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_start_dpf);
 
 
-	FUNCTION_TRACE ("Rs_start_dependent_functions_resource");
+	ACPI_FUNCTION_TRACE ("rs_start_depend_fns_resource");
 
 
 	/*
@@ -391,7 +398,7 @@
 		output_struct->data.start_dpf.compatibility_priority = temp8 & 0x03;
 
 		if (3 == output_struct->data.start_dpf.compatibility_priority) {
-			return_ACPI_STATUS (AE_AML_ERROR);
+			return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);
 		}
 
 		/*
@@ -400,22 +407,21 @@
 		output_struct->data.start_dpf.performance_robustness = (temp8 >> 2) & 0x03;
 
 		if (3 == output_struct->data.start_dpf.performance_robustness) {
-			return_ACPI_STATUS (AE_AML_ERROR);
+			return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);
 		}
 	}
-
 	else {
 		output_struct->data.start_dpf.compatibility_priority =
-				ACCEPTABLE_CONFIGURATION;
+				ACPI_ACCEPTABLE_CONFIGURATION;
 
 		output_struct->data.start_dpf.performance_robustness =
-				ACCEPTABLE_CONFIGURATION;
+				ACPI_ACCEPTABLE_CONFIGURATION;
 	}
 
 	/*
 	 * Set the Length parameter
 	 */
-	output_struct->length = struct_size;
+	output_struct->length = (u32) struct_size;
 
 	/*
 	 * Return the final size of the structure
@@ -427,38 +433,37 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_end_dependent_functions_resource
+ * FUNCTION:    acpi_rs_end_depend_fns_resource
  *
- * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
+ * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the byte_stream_buffer is
+ *                                        returned
+ *              output_buffer           - Pointer to the return data buffer
+ *              structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the Output_buffer. Return the
+ *              structure pointed to by the output_buffer. Return the
  *              number of bytes consumed from the byte stream.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_end_dependent_functions_resource (
-	u8                      *byte_stream_buffer,
-	u32                     *bytes_consumed,
-	u8                      **output_buffer,
-	u32                     *structure_size)
+acpi_rs_end_depend_fns_resource (
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size)
 {
-	acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
-	u32                     struct_size = ACPI_RESOURCE_LENGTH;
+	struct acpi_resource            *output_struct = (void *) *output_buffer;
+	acpi_size                       struct_size = ACPI_RESOURCE_LENGTH;
 
 
-	FUNCTION_TRACE ("Rs_end_dependent_functions_resource");
+	ACPI_FUNCTION_TRACE ("rs_end_depend_fns_resource");
 
 
 	/*
@@ -474,7 +479,7 @@
 	/*
 	 * Set the Length parameter
 	 */
-	output_struct->length = struct_size;
+	output_struct->length = (u32) struct_size;
 
 	/*
 	 * Return the final size of the structure
@@ -486,13 +491,13 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_start_dependent_functions_stream
+ * FUNCTION:    acpi_rs_start_depend_fns_stream
  *
- * PARAMETERS:  Linked_list             - Pointer to the resource linked list
- *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
+ * PARAMETERS:  linked_list             - Pointer to the resource linked list
+ *              output_buffer           - Pointer to the user's return buffer
+ *              bytes_consumed          - u32 pointer that is filled with
  *                                        the number of bytes of the
- *                                        Output_buffer used
+ *                                        output_buffer used
  *
  * RETURN:      Status
  *
@@ -502,25 +507,25 @@
  ******************************************************************************/
 
 acpi_status
-acpi_rs_start_dependent_functions_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed)
+acpi_rs_start_depend_fns_stream (
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed)
 {
-	u8                      *buffer = *output_buffer;
-	u8                      temp8 = 0;
+	u8                              *buffer = *output_buffer;
+	u8                              temp8 = 0;
 
 
-	FUNCTION_TRACE ("Rs_start_dependent_functions_stream");
+	ACPI_FUNCTION_TRACE ("rs_start_depend_fns_stream");
 
 
 	/*
 	 * The descriptor field is set based upon whether a byte is needed
 	 * to contain Priority data.
 	 */
-	if (ACCEPTABLE_CONFIGURATION ==
+	if (ACPI_ACCEPTABLE_CONFIGURATION ==
 			linked_list->data.start_dpf.compatibility_priority &&
-		ACCEPTABLE_CONFIGURATION ==
+		ACPI_ACCEPTABLE_CONFIGURATION ==
 			linked_list->data.start_dpf.performance_robustness) {
 		*buffer = 0x30;
 	}
@@ -544,20 +549,19 @@
 	/*
 	 * Return the number of bytes consumed in this operation
 	 */
-	*bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+	*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_end_dependent_functions_stream
+ * FUNCTION:    acpi_rs_end_depend_fns_stream
  *
- * PARAMETERS:  Linked_list             - Pointer to the resource linked list
- *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ * PARAMETERS:  linked_list             - Pointer to the resource linked list
+ *              output_buffer           - Pointer to the user's return buffer
+ *              bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -567,16 +571,15 @@
  ******************************************************************************/
 
 acpi_status
-acpi_rs_end_dependent_functions_stream (
-	acpi_resource           *linked_list,
-	u8                      **output_buffer,
-	u32                     *bytes_consumed
-	)
+acpi_rs_end_depend_fns_stream (
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed)
 {
-	u8                      *buffer = *output_buffer;
+	u8                              *buffer = *output_buffer;
 
 
-	FUNCTION_TRACE ("Rs_end_dependent_functions_stream");
+	ACPI_FUNCTION_TRACE ("rs_end_depend_fns_stream");
 
 
 	/*
@@ -588,7 +591,7 @@
 	/*
 	 * Return the number of bytes consumed in this operation
 	 */
-	*bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+	*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
 	return_ACPI_STATUS (AE_OK);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/resources/rsutils.c linux-2.4.22-pre2/drivers/acpi/resources/rsutils.c
--- linux-2.4.21/drivers/acpi/resources/rsutils.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/resources/rsutils.c	2003-06-26 21:43:11.000000000 +0000
@@ -1,44 +1,62 @@
 /*******************************************************************************
  *
  * Module Name: rsutils - Utilities for the resource manager
- *              $Revision: 23 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acnamesp.h"
-#include "acresrc.h"
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acresrc.h>
 
 
 #define _COMPONENT          ACPI_RESOURCES
-	 MODULE_NAME         ("rsutils")
+	 ACPI_MODULE_NAME    ("rsutils")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_get_prt_method_data
+ * FUNCTION:    acpi_rs_get_prt_method_data
  *
  * PARAMETERS:  Handle          - a handle to the containing object
- *              Ret_buffer      - a pointer to a buffer structure for the
+ *              ret_buffer      - a pointer to a buffer structure for the
  *                                  results
  *
  * RETURN:      Status
@@ -53,78 +71,45 @@
 
 acpi_status
 acpi_rs_get_prt_method_data (
-	acpi_handle             handle,
-	acpi_buffer             *ret_buffer)
+	acpi_handle                     handle,
+	struct acpi_buffer              *ret_buffer)
 {
-	acpi_operand_object     *ret_obj;
-	acpi_status             status;
-	u32                     buffer_space_needed;
+	union acpi_operand_object       *obj_desc;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Rs_get_prt_method_data");
+	ACPI_FUNCTION_TRACE ("rs_get_prt_method_data");
 
 
-	/* already validated params, so we won't repeat here */
-
-	buffer_space_needed = ret_buffer->length;
+	/* Parameters guaranteed valid by caller */
 
 	/*
-	 *  Execute the method, no parameters
+	 * Execute the method, no parameters
 	 */
-	status = acpi_ns_evaluate_relative (handle, "_PRT", NULL, &ret_obj);
+	status = acpi_ut_evaluate_object (handle, "_PRT", ACPI_BTYPE_PACKAGE, &obj_desc);
 	if (ACPI_FAILURE (status)) {
 		return_ACPI_STATUS (status);
 	}
 
-	if (!ret_obj) {
-		/* Return object is required */
-
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from _PRT\n"));
-		return_ACPI_STATUS (AE_TYPE);
-	}
-
-
-	/*
-	 * The return object will be a package, so check the
-	 *  parameters.  If the return object is not a package,
-	 *  then the underlying AML code is corrupt or improperly
-	 *  written.
-	 */
-	if (ACPI_TYPE_PACKAGE != ret_obj->common.type) {
-		status = AE_AML_OPERAND_TYPE;
-		goto cleanup;
-	}
-
-	/*
-	 * Make the call to create a resource linked list from the
-	 *  byte stream buffer that comes back from the _CRS method
-	 *  execution.
-	 */
-	status = acpi_rs_create_pci_routing_table (ret_obj, ret_buffer->pointer,
-			  &buffer_space_needed);
-
 	/*
-	 * Tell the user how much of the buffer we have used or is needed
-	 *  and return the final status.
+	 * Create a resource linked list from the byte stream buffer that comes
+	 * back from the _CRS method execution.
 	 */
-	ret_buffer->length = buffer_space_needed;
-
+	status = acpi_rs_create_pci_routing_table (obj_desc, ret_buffer);
 
 	/* On exit, we must delete the object returned by evaluate_object */
 
-cleanup:
-
-	acpi_ut_remove_reference (ret_obj);
+	acpi_ut_remove_reference (obj_desc);
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_get_crs_method_data
+ * FUNCTION:    acpi_rs_get_crs_method_data
  *
  * PARAMETERS:  Handle          - a handle to the containing object
- *              Ret_buffer      - a pointer to a buffer structure for the
+ *              ret_buffer      - a pointer to a buffer structure for the
  *                                  results
  *
  * RETURN:      Status
@@ -139,76 +124,46 @@
 
 acpi_status
 acpi_rs_get_crs_method_data (
-	acpi_handle             handle,
-	acpi_buffer             *ret_buffer)
+	acpi_handle                     handle,
+	struct acpi_buffer              *ret_buffer)
 {
-	acpi_operand_object     *ret_obj;
-	acpi_status             status;
-	u32                     buffer_space_needed = ret_buffer->length;
+	union acpi_operand_object       *obj_desc;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Rs_get_crs_method_data");
+	ACPI_FUNCTION_TRACE ("rs_get_crs_method_data");
 
 
-	/* already validated params, so we won't repeat here */
+	/* Parameters guaranteed valid by caller */
 
 	/*
-	 *  Execute the method, no parameters
+	 * Execute the method, no parameters
 	 */
-	status = acpi_ns_evaluate_relative (handle, "_CRS", NULL, &ret_obj);
+	status = acpi_ut_evaluate_object (handle, "_CRS", ACPI_BTYPE_BUFFER, &obj_desc);
 	if (ACPI_FAILURE (status)) {
 		return_ACPI_STATUS (status);
 	}
 
-	if (!ret_obj) {
-		/* Return object is required */
-
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from _CRS\n"));
-		return_ACPI_STATUS (AE_TYPE);
-	}
-
-	/*
-	 * The return object will be a buffer, but check the
-	 *  parameters.  If the return object is not a buffer,
-	 *  then the underlying AML code is corrupt or improperly
-	 *  written.
-	 */
-	if (ACPI_TYPE_BUFFER != ret_obj->common.type) {
-		status = AE_AML_OPERAND_TYPE;
-		goto cleanup;
-	}
-
 	/*
 	 * Make the call to create a resource linked list from the
-	 *  byte stream buffer that comes back from the _CRS method
-	 *  execution.
+	 * byte stream buffer that comes back from the _CRS method
+	 * execution.
 	 */
-	status = acpi_rs_create_resource_list (ret_obj, ret_buffer->pointer,
-			 &buffer_space_needed);
+	status = acpi_rs_create_resource_list (obj_desc, ret_buffer);
 
+	/* on exit, we must delete the object returned by evaluate_object */
 
-	/*
-	 * Tell the user how much of the buffer we have used or is needed
-	 *  and return the final status.
-	 */
-	ret_buffer->length = buffer_space_needed;
-
-
-	/* On exit, we must delete the object returned by evaluate_object */
-
-cleanup:
-
-	acpi_ut_remove_reference (ret_obj);
+	acpi_ut_remove_reference (obj_desc);
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_get_prs_method_data
+ * FUNCTION:    acpi_rs_get_prs_method_data
  *
  * PARAMETERS:  Handle          - a handle to the containing object
- *              Ret_buffer      - a pointer to a buffer structure for the
+ *              ret_buffer      - a pointer to a buffer structure for the
  *                                  results
  *
  * RETURN:      Status
@@ -223,75 +178,100 @@
 
 acpi_status
 acpi_rs_get_prs_method_data (
-	acpi_handle             handle,
-	acpi_buffer             *ret_buffer)
+	acpi_handle                     handle,
+	struct acpi_buffer              *ret_buffer)
 {
-	acpi_operand_object     *ret_obj;
-	acpi_status             status;
-	u32                     buffer_space_needed = ret_buffer->length;
+	union acpi_operand_object       *obj_desc;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Rs_get_prs_method_data");
+	ACPI_FUNCTION_TRACE ("rs_get_prs_method_data");
 
 
-	/* already validated params, so we won't repeat here */
+	/* Parameters guaranteed valid by caller */
 
 	/*
-	 *  Execute the method, no parameters
+	 * Execute the method, no parameters
 	 */
-	status = acpi_ns_evaluate_relative (handle, "_PRS", NULL, &ret_obj);
+	status = acpi_ut_evaluate_object (handle, "_PRS", ACPI_BTYPE_BUFFER, &obj_desc);
 	if (ACPI_FAILURE (status)) {
 		return_ACPI_STATUS (status);
 	}
 
-	if (!ret_obj) {
-		/* Return object is required */
+	/*
+	 * Make the call to create a resource linked list from the
+	 * byte stream buffer that comes back from the _CRS method
+	 * execution.
+	 */
+	status = acpi_rs_create_resource_list (obj_desc, ret_buffer);
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from _PRS\n"));
-		return_ACPI_STATUS (AE_TYPE);
-	}
+	/* on exit, we must delete the object returned by evaluate_object */
+
+	acpi_ut_remove_reference (obj_desc);
+	return_ACPI_STATUS (status);
+}
 
-	/*
-	 * The return object will be a buffer, but check the
-	 *  parameters.  If the return object is not a buffer,
-	 *  then the underlying AML code is corrupt or improperly
-	 *  written..
-	 */
-	if (ACPI_TYPE_BUFFER != ret_obj->common.type) {
-		status = AE_AML_OPERAND_TYPE;
-		goto cleanup;
-	}
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_rs_get_method_data
+ *
+ * PARAMETERS:  Handle          - a handle to the containing object
+ *              ret_buffer      - a pointer to a buffer structure for the
+ *                                  results
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: This function is called to get the _CRS or _PRS value of an
+ *              object contained in an object specified by the handle passed in
+ *
+ *              If the function fails an appropriate status will be returned
+ *              and the contents of the callers buffer is undefined.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_rs_get_method_data (
+	acpi_handle                     handle,
+	char                            *path,
+	struct acpi_buffer              *ret_buffer)
+{
+	union acpi_operand_object       *obj_desc;
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_TRACE ("rs_get_method_data");
+
+
+	/* Parameters guaranteed valid by caller */
 
 	/*
-	 * Make the call to create a resource linked list from the
-	 *  byte stream buffer that comes back from the _CRS method
-	 *  execution.
+	 * Execute the method, no parameters
 	 */
-	status = acpi_rs_create_resource_list (ret_obj, ret_buffer->pointer,
-			 &buffer_space_needed);
+	status = acpi_ut_evaluate_object (handle, path, ACPI_BTYPE_BUFFER, &obj_desc);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	/*
-	 * Tell the user how much of the buffer we have used or is needed
-	 *  and return the final status.
+	 * Make the call to create a resource linked list from the
+	 * byte stream buffer that comes back from the method
+	 * execution.
 	 */
-	ret_buffer->length = buffer_space_needed;
-
+	status = acpi_rs_create_resource_list (obj_desc, ret_buffer);
 
 	/* On exit, we must delete the object returned by evaluate_object */
 
-cleanup:
-
-	acpi_ut_remove_reference (ret_obj);
+	acpi_ut_remove_reference (obj_desc);
 	return_ACPI_STATUS (status);
 }
 
-
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_set_srs_method_data
+ * FUNCTION:    acpi_rs_set_srs_method_data
  *
  * PARAMETERS:  Handle          - a handle to the containing object
- *              In_buffer       - a pointer to a buffer structure of the
+ *              in_buffer       - a pointer to a buffer structure of the
  *                                  parameter
  *
  * RETURN:      Status
@@ -306,55 +286,30 @@
 
 acpi_status
 acpi_rs_set_srs_method_data (
-	acpi_handle             handle,
-	acpi_buffer             *in_buffer)
+	acpi_handle                     handle,
+	struct acpi_buffer              *in_buffer)
 {
-	acpi_operand_object     *params[2];
-	acpi_status             status;
-	u8                      *byte_stream = NULL;
-	u32                     buffer_size_needed = 0;
+	union acpi_operand_object       *params[2];
+	acpi_status                     status;
+	struct acpi_buffer              buffer;
 
 
-	FUNCTION_TRACE ("Rs_set_srs_method_data");
+	ACPI_FUNCTION_TRACE ("rs_set_srs_method_data");
 
 
-	/* already validated params, so we won't repeat here */
+	/* Parameters guaranteed valid by caller */
 
 	/*
-	 * The In_buffer parameter will point to a linked list of
+	 * The in_buffer parameter will point to a linked list of
 	 * resource parameters.  It needs to be formatted into a
-	 * byte stream to be sent in as an input parameter.
-	 */
-	buffer_size_needed = 0;
-
-	/*
-	 * First call is to get the buffer size needed
-	 */
-	status = acpi_rs_create_byte_stream (in_buffer->pointer, byte_stream,
-			 &buffer_size_needed);
-	/*
-	 * We expect a return of AE_BUFFER_OVERFLOW
-	 * if not, exit with the error
-	 */
-	if (AE_BUFFER_OVERFLOW != status) {
-		return_ACPI_STATUS (status);
-	}
-
-	/*
-	 * Allocate the buffer needed
+	 * byte stream to be sent in as an input parameter to _SRS
+	 *
+	 * Convert the linked list into a byte stream
 	 */
-	byte_stream = ACPI_MEM_CALLOCATE (buffer_size_needed);
-	if (NULL == byte_stream) {
-		return_ACPI_STATUS (AE_NO_MEMORY);
-	}
-
-	/*
-	 * Now call to convert the linked list into a byte stream
-	 */
-	status = acpi_rs_create_byte_stream (in_buffer->pointer, byte_stream,
-			 &buffer_size_needed);
+	buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
+	status = acpi_rs_create_byte_stream (in_buffer->pointer, &buffer);
 	if (ACPI_FAILURE (status)) {
-		goto cleanup;
+		return_ACPI_STATUS (status);
 	}
 
 	/*
@@ -362,28 +317,27 @@
 	 */
 	params[0] = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER);
 	if (!params[0]) {
-		status = AE_NO_MEMORY;
-		goto cleanup;
+		acpi_os_free (buffer.pointer);
+		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
-	params [1] = NULL;
 
 	/*
-	 *  Set up the parameter object
+	 * Set up the parameter object
 	 */
-	params[0]->buffer.length  = buffer_size_needed;
-	params[0]->buffer.pointer = byte_stream;
+	params[0]->buffer.length  = (u32) buffer.length;
+	params[0]->buffer.pointer = buffer.pointer;
+	params[0]->common.flags   = AOPOBJ_DATA_VALID;
+	params[1] = NULL;
 
 	/*
 	 * Execute the method, no return value
 	 */
 	status = acpi_ns_evaluate_relative (handle, "_SRS", params, NULL);
-	acpi_ut_remove_reference (params[0]);
 
 	/*
-	 * Clean up and return the status from Acpi_ns_evaluate_relative
+	 * Clean up and return the status from acpi_ns_evaluate_relative
 	 */
-cleanup:
-
+	acpi_ut_remove_reference (params[0]);
 	return_ACPI_STATUS (status);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/resources/rsxface.c linux-2.4.22-pre2/drivers/acpi/resources/rsxface.c
--- linux-2.4.21/drivers/acpi/resources/rsxface.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/resources/rsxface.c	2003-06-26 21:43:12.000000000 +0000
@@ -1,44 +1,60 @@
 /*******************************************************************************
  *
  * Module Name: rsxface - Public interfaces to the resource manager
- *              $Revision: 15 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "acresrc.h"
+#include <acpi/acpi.h>
+#include <acpi/acresrc.h>
 
 #define _COMPONENT          ACPI_RESOURCES
-	 MODULE_NAME         ("rsxface")
+	 ACPI_MODULE_NAME    ("rsxface")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_get_irq_routing_table
+ * FUNCTION:    acpi_get_irq_routing_table
  *
- * PARAMETERS:  Device_handle   - a handle to the Bus device we are querying
- *              Ret_buffer      - a pointer to a buffer to receive the
+ * PARAMETERS:  device_handle   - a handle to the Bus device we are querying
+ *              ret_buffer      - a pointer to a buffer to receive the
  *                                current resources for the device
  *
  * RETURN:      Status
@@ -46,25 +62,25 @@
  * DESCRIPTION: This function is called to get the IRQ routing table for a
  *              specific bus.  The caller must first acquire a handle for the
  *              desired bus.  The routine table is placed in the buffer pointed
- *              to by the Ret_buffer variable parameter.
+ *              to by the ret_buffer variable parameter.
  *
  *              If the function fails an appropriate status will be returned
- *              and the value of Ret_buffer is undefined.
+ *              and the value of ret_buffer is undefined.
  *
  *              This function attempts to execute the _PRT method contained in
- *              the object indicated by the passed Device_handle.
+ *              the object indicated by the passed device_handle.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_get_irq_routing_table (
-	acpi_handle             device_handle,
-	acpi_buffer             *ret_buffer)
+	acpi_handle                     device_handle,
+	struct acpi_buffer              *ret_buffer)
 {
-	acpi_status             status;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Acpi_get_irq_routing_table ");
+	ACPI_FUNCTION_TRACE ("acpi_get_irq_routing_table ");
 
 
 	/*
@@ -73,12 +89,15 @@
 	 * we also need a valid pointer in the buffer. If it's a zero buffer length,
 	 * we'll be returning the needed buffer size, so keep going.
 	 */
-	if ((!device_handle)        ||
-		(!ret_buffer)           ||
-		((!ret_buffer->pointer) && (ret_buffer->length))) {
+	if (!device_handle) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
+	status = acpi_ut_validate_buffer (ret_buffer);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
 	status = acpi_rs_get_prt_method_data (device_handle, ret_buffer);
 	return_ACPI_STATUS (status);
 }
@@ -86,11 +105,11 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_get_current_resources
+ * FUNCTION:    acpi_get_current_resources
  *
- * PARAMETERS:  Device_handle   - a handle to the device object for the
+ * PARAMETERS:  device_handle   - a handle to the device object for the
  *                                device we are querying
- *              Ret_buffer      - a pointer to a buffer to receive the
+ *              ret_buffer      - a pointer to a buffer to receive the
  *                                current resources for the device
  *
  * RETURN:      Status
@@ -98,25 +117,25 @@
  * DESCRIPTION: This function is called to get the current resources for a
  *              specific device.  The caller must first acquire a handle for
  *              the desired device.  The resource data is placed in the buffer
- *              pointed to by the Ret_buffer variable parameter.
+ *              pointed to by the ret_buffer variable parameter.
  *
  *              If the function fails an appropriate status will be returned
- *              and the value of Ret_buffer is undefined.
+ *              and the value of ret_buffer is undefined.
  *
  *              This function attempts to execute the _CRS method contained in
- *              the object indicated by the passed Device_handle.
+ *              the object indicated by the passed device_handle.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_get_current_resources (
-	acpi_handle             device_handle,
-	acpi_buffer             *ret_buffer)
+	acpi_handle                     device_handle,
+	struct acpi_buffer              *ret_buffer)
 {
-	acpi_status             status;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Acpi_get_current_resources");
+	ACPI_FUNCTION_TRACE ("acpi_get_current_resources");
 
 
 	/*
@@ -125,12 +144,15 @@
 	 * we also need a valid pointer in the buffer. If it's a zero buffer length,
 	 * we'll be returning the needed buffer size, so keep going.
 	 */
-	if ((!device_handle)        ||
-		(!ret_buffer)           ||
-		((ret_buffer->length) && (!ret_buffer->pointer))) {
+	if (!device_handle) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
+	status = acpi_ut_validate_buffer (ret_buffer);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
 	status = acpi_rs_get_crs_method_data (device_handle, ret_buffer);
 	return_ACPI_STATUS (status);
 }
@@ -138,11 +160,11 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_get_possible_resources
+ * FUNCTION:    acpi_get_possible_resources
  *
- * PARAMETERS:  Device_handle   - a handle to the device object for the
+ * PARAMETERS:  device_handle   - a handle to the device object for the
  *                                device we are querying
- *              Ret_buffer      - a pointer to a buffer to receive the
+ *              ret_buffer      - a pointer to a buffer to receive the
  *                                resources for the device
  *
  * RETURN:      Status
@@ -150,22 +172,22 @@
  * DESCRIPTION: This function is called to get a list of the possible resources
  *              for a specific device.  The caller must first acquire a handle
  *              for the desired device.  The resource data is placed in the
- *              buffer pointed to by the Ret_buffer variable.
+ *              buffer pointed to by the ret_buffer variable.
  *
  *              If the function fails an appropriate status will be returned
- *              and the value of Ret_buffer is undefined.
+ *              and the value of ret_buffer is undefined.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_get_possible_resources (
-	acpi_handle             device_handle,
-	acpi_buffer             *ret_buffer)
+	acpi_handle                     device_handle,
+	struct acpi_buffer              *ret_buffer)
 {
-	acpi_status             status;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Acpi_get_possible_resources");
+	ACPI_FUNCTION_TRACE ("acpi_get_possible_resources");
 
 
 	/*
@@ -174,12 +196,15 @@
 	 * we also need a valid pointer in the buffer. If it's a zero buffer length,
 	 * we'll be returning the needed buffer size, so keep going.
 	 */
-	if ((!device_handle)        ||
-		(!ret_buffer)           ||
-		((ret_buffer->length) && (!ret_buffer->pointer))) {
+	if (!device_handle) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
+	status = acpi_ut_validate_buffer (ret_buffer);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
 	status = acpi_rs_get_prs_method_data (device_handle, ret_buffer);
 	return_ACPI_STATUS (status);
 }
@@ -187,11 +212,96 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_set_current_resources
+ * FUNCTION:    acpi_walk_resources
+ *
+ * PARAMETERS:  device_handle   - a handle to the device object for the
+ *                                device we are querying
+ *              Path            - method name of the resources we want
+ *                                (METHOD_NAME__CRS or METHOD_NAME__PRS)
+ *              user_function   - called for each resource
+ *              Context         - passed to user_function
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Retrieves the current or possible resource list for the
+ *              specified device.  The user_function is called once for
+ *              each resource in the list.
  *
- * PARAMETERS:  Device_handle   - a handle to the device object for the
+ ******************************************************************************/
+
+acpi_status
+acpi_walk_resources (
+	acpi_handle                             device_handle,
+	char                                    *path,
+	ACPI_WALK_RESOURCE_CALLBACK     user_function,
+	void                                    *context)
+{
+	acpi_status                         status;
+	struct acpi_buffer                  buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+	struct acpi_resource                *resource;
+
+
+	ACPI_FUNCTION_TRACE ("acpi_walk_resources");
+
+
+	if (!device_handle ||
+		(ACPI_STRNCMP (path, METHOD_NAME__CRS, sizeof (METHOD_NAME__CRS)) &&
+		 ACPI_STRNCMP (path, METHOD_NAME__PRS, sizeof (METHOD_NAME__PRS)))) {
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	}
+
+	status = acpi_rs_get_method_data (device_handle, path, &buffer);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	resource = (struct acpi_resource *) buffer.pointer;
+	for (;;) {
+		if (!resource || resource->id == ACPI_RSTYPE_END_TAG) {
+			break;
+		}
+
+		status = user_function (resource, context);
+
+		switch (status) {
+		case AE_OK:
+		case AE_CTRL_DEPTH:
+
+			/* Just keep going */
+			status = AE_OK;
+			break;
+
+		case AE_CTRL_TERMINATE:
+
+			/* Exit now, with OK stats */
+
+			status = AE_OK;
+			goto cleanup;
+
+		default:
+
+			/* All others are valid exceptions */
+
+			goto cleanup;
+		}
+
+		resource = ACPI_NEXT_RESOURCE (resource);
+	}
+
+cleanup:
+
+	acpi_os_free (buffer.pointer);
+	return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_set_current_resources
+ *
+ * PARAMETERS:  device_handle   - a handle to the device object for the
  *                                device we are changing the resources of
- *              In_buffer       - a pointer to a buffer containing the
+ *              in_buffer       - a pointer to a buffer containing the
  *                                resources to be set for the device
  *
  * RETURN:      Status
@@ -199,19 +309,19 @@
  * DESCRIPTION: This function is called to set the current resources for a
  *              specific device.  The caller must first acquire a handle for
  *              the desired device.  The resource data is passed to the routine
- *              the buffer pointed to by the In_buffer variable.
+ *              the buffer pointed to by the in_buffer variable.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_set_current_resources (
-	acpi_handle             device_handle,
-	acpi_buffer             *in_buffer)
+	acpi_handle                     device_handle,
+	struct acpi_buffer              *in_buffer)
 {
-	acpi_status             status;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Acpi_set_current_resources");
+	ACPI_FUNCTION_TRACE ("acpi_set_current_resources");
 
 
 	/*
@@ -227,3 +337,76 @@
 	status = acpi_rs_set_srs_method_data (device_handle, in_buffer);
 	return_ACPI_STATUS (status);
 }
+
+
+#define ACPI_COPY_FIELD(out, in, field)  ((out)->field = (in)->field)
+#define ACPI_COPY_ADDRESS(out, in)                      \
+	ACPI_COPY_FIELD(out, in, resource_type);             \
+	ACPI_COPY_FIELD(out, in, producer_consumer);         \
+	ACPI_COPY_FIELD(out, in, decode);                    \
+	ACPI_COPY_FIELD(out, in, min_address_fixed);         \
+	ACPI_COPY_FIELD(out, in, max_address_fixed);         \
+	ACPI_COPY_FIELD(out, in, attribute);                 \
+	ACPI_COPY_FIELD(out, in, granularity);               \
+	ACPI_COPY_FIELD(out, in, min_address_range);         \
+	ACPI_COPY_FIELD(out, in, max_address_range);         \
+	ACPI_COPY_FIELD(out, in, address_translation_offset); \
+	ACPI_COPY_FIELD(out, in, address_length);            \
+	ACPI_COPY_FIELD(out, in, resource_source);
+
+/******************************************************************************
+ *
+ * FUNCTION:    acpi_resource_to_address64
+ *
+ * PARAMETERS:  resource                - Pointer to a resource
+ *              out                     - Pointer to the users's return
+ *                                        buffer (a struct
+ *                                        struct acpi_resource_address64)
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: If the resource is an address16, address32, or address64,
+ *              copy it to the address64 return buffer.  This saves the
+ *              caller from having to duplicate code for different-sized
+ *              addresses.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_resource_to_address64 (
+	struct acpi_resource                *resource,
+	struct acpi_resource_address64      *out)
+{
+	struct acpi_resource_address16      *address16;
+	struct acpi_resource_address32      *address32;
+
+
+	switch (resource->id) {
+	case ACPI_RSTYPE_ADDRESS16:
+
+		address16 = (struct acpi_resource_address16 *) &resource->data;
+		ACPI_COPY_ADDRESS(out, address16);
+		break;
+
+
+	case ACPI_RSTYPE_ADDRESS32:
+
+		address32 = (struct acpi_resource_address32 *) &resource->data;
+		ACPI_COPY_ADDRESS(out, address32);
+		break;
+
+
+	case ACPI_RSTYPE_ADDRESS64:
+
+		/* Simple copy for 64 bit source */
+
+		ACPI_MEMCPY (out, &resource->data, sizeof (struct acpi_resource_address64));
+		break;
+
+
+	default:
+		return (AE_BAD_PARAMETER);
+	}
+
+	return (AE_OK);
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/system.c linux-2.4.22-pre2/drivers/acpi/system.c
--- linux-2.4.21/drivers/acpi/system.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/system.c	2003-06-26 21:43:18.000000000 +0000
@@ -0,0 +1,1327 @@
+/*
+ *  acpi_system.c - ACPI System Driver ($Revision: 57 $)
+ *
+ *  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/config.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/spinlock.h>
+#include <linux/poll.h>
+#include <linux/delay.h>
+#include <linux/sysrq.h>
+#include <linux/compatmac.h>
+#include <linux/proc_fs.h>
+#include <linux/pm.h>
+#include <asm/uaccess.h>
+#include <asm/acpi.h>
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+
+#ifdef CONFIG_X86
+#ifdef CONFIG_ACPI_SLEEP
+#include <linux/mc146818rtc.h>
+#include <linux/irq.h>
+#include <asm/hw_irq.h>
+#endif
+#endif
+
+
+#define _COMPONENT		ACPI_SYSTEM_COMPONENT
+ACPI_MODULE_NAME		("acpi_system")
+
+#define PREFIX			"ACPI: "
+
+extern FADT_DESCRIPTOR		acpi_fadt;
+
+static int acpi_system_add (struct acpi_device *device);
+static int acpi_system_remove (struct acpi_device *device, int type);
+
+static struct acpi_driver acpi_system_driver = {
+	.name =		ACPI_SYSTEM_DRIVER_NAME,
+	.class =	ACPI_SYSTEM_CLASS,
+	.ids =		ACPI_SYSTEM_HID,
+	.ops =		{
+				.add =		acpi_system_add,
+				.remove =	acpi_system_remove
+			},
+};
+
+struct acpi_system
+{
+	acpi_handle		handle;
+	u8			states[ACPI_S_STATE_COUNT];
+};
+
+/* Global vars for handling event proc entry */
+static spinlock_t		acpi_system_event_lock = SPIN_LOCK_UNLOCKED;
+int				event_is_open = 0;
+extern struct list_head		acpi_bus_event_list;
+extern wait_queue_head_t	acpi_bus_event_queue;
+
+/* --------------------------------------------------------------------------
+                                  System Sleep
+   -------------------------------------------------------------------------- */
+
+#ifdef CONFIG_PM
+
+static void
+acpi_power_off (void)
+{
+	acpi_enter_sleep_state_prep(ACPI_STATE_S5);
+	ACPI_DISABLE_IRQS();
+	acpi_enter_sleep_state(ACPI_STATE_S5);
+}
+
+#endif /*CONFIG_PM*/
+
+
+#ifdef CONFIG_ACPI_SLEEP
+
+/**
+ * acpi_system_restore_state - OS-specific restoration of state
+ * @state:	sleep state we're exiting
+ *
+ * Note that if we're coming back from S4, the memory image should have
+ * already been loaded from the disk and is already in place.  (Otherwise how
+ * else would we be here?).
+ */
+acpi_status
+acpi_system_restore_state(
+	u32			state)
+{
+	/* 
+	 * We should only be here if we're coming back from STR or STD.
+	 * And, in the case of the latter, the memory image should have already
+	 * been loaded from disk.
+	 */
+	if (state > ACPI_STATE_S1) {
+		acpi_restore_state_mem();
+
+		/* Do _early_ resume for irqs.  Required by
+		 * ACPI specs.
+		 */
+		/* TBD: call arch dependant reinitialization of the 
+		 * interrupts.
+		 */
+#ifdef CONFIG_X86
+		init_8259A(0);
+#endif
+		/* wait for power to come back */
+		mdelay(1000);
+
+	}
+
+	/* Be really sure that irqs are disabled. */
+	ACPI_DISABLE_IRQS();
+
+	/* Wait a little again, just in case... */
+	mdelay(1000);
+
+	/* enable interrupts once again */
+	ACPI_ENABLE_IRQS();
+
+	/* turn all the devices back on */
+	if (state > ACPI_STATE_S1)
+		pm_send_all(PM_RESUME, (void *)0);
+
+	return AE_OK;
+}
+
+
+/**
+ * acpi_system_save_state - save OS specific state and power down devices
+ * @state:	sleep state we're entering.
+ *
+ * This handles saving all context to memory, and possibly disk.
+ * First, we call to the device driver layer to save device state.
+ * Once we have that, we save whatevery processor and kernel state we
+ * need to memory.
+ * If we're entering S4, we then write the memory image to disk.
+ *
+ * Only then it is safe for us to power down devices, since we may need
+ * the disks and upstream buses to write to.
+ */
+acpi_status
+acpi_system_save_state(
+	u32			state)
+{
+	int			error = 0;
+
+	/* Send notification to devices that they will be suspended.
+	 * If any device or driver cannot make the transition, either up
+	 * or down, we'll get an error back.
+	 */
+	if (state > ACPI_STATE_S1) {
+		error = pm_send_all(PM_SAVE_STATE, (void *)3);
+		if (error)
+			return AE_ERROR;
+	}
+
+	if (state < ACPI_STATE_S5) {
+		/* Tell devices to stop I/O and actually save their state.
+		 * It is theoretically possible that something could fail,
+		 * so handle that gracefully..
+		 */
+		if (state > ACPI_STATE_S1 && state != ACPI_STATE_S5) {
+			error = pm_send_all(PM_SUSPEND, (void *)3);
+			if (error) {
+				/* Tell devices to restore state if they have
+				 * it saved and to start taking I/O requests.
+				 */
+				pm_send_all(PM_RESUME, (void *)0);
+				return error;
+			}
+		}
+		
+		/* flush caches */
+		ACPI_FLUSH_CPU_CACHE();
+
+		/* Do arch specific saving of state. */
+		if (state > ACPI_STATE_S1) {
+			error = acpi_save_state_mem();
+
+			/* TBD: if no s4bios, write codes for
+			 * acpi_save_state_disk()...
+			 */
+#if 0
+			if (!error && (state == ACPI_STATE_S4))
+				error = acpi_save_state_disk();
+#endif
+			if (error) {
+				pm_send_all(PM_RESUME, (void *)0);
+				return error;
+			}
+		}
+	}
+	/* disable interrupts
+	 * Note that acpi_suspend -- our caller -- will do this once we return.
+	 * But, we want it done early, so we don't get any suprises during
+	 * the device suspend sequence.
+	 */
+	ACPI_DISABLE_IRQS();
+
+	/* Unconditionally turn off devices.
+	 * Obvious if we enter a sleep state.
+	 * If entering S5 (soft off), this should put devices in a
+	 * quiescent state.
+	 */
+
+	if (state > ACPI_STATE_S1) {
+		error = pm_send_all(PM_SUSPEND, (void *)3);
+
+		/* We're pretty screwed if we got an error from this.
+		 * We try to recover by simply calling our own restore_state
+		 * function; see above for definition.
+		 *
+		 * If it's S5 though, go through with it anyway..
+		 */
+		if (error && state != ACPI_STATE_S5)
+			acpi_system_restore_state(state);
+	}
+	return error ? AE_ERROR : AE_OK;
+}
+
+
+/****************************************************************************
+ *
+ * FUNCTION:    acpi_system_suspend
+ *
+ * PARAMETERS:  %state: Sleep state to enter.
+ *
+ * RETURN:      acpi_status, whether or not we successfully entered and
+ *              exited sleep.
+ *
+ * DESCRIPTION: Perform OS-specific action to enter sleep state.
+ *              This is the final step in going to sleep, per spec.  If we
+ *              know we're coming back (i.e. not entering S5), we save the
+ *              processor flags. [ We'll have to save and restore them anyway,
+ *              so we use the arch-agnostic save_flags and restore_flags
+ *              here.]  We then set the place to return to in arch-specific
+ *              globals using arch_set_return_point. Finally, we call the
+ *              ACPI function to write the proper values to I/O ports.
+ *
+ ****************************************************************************/
+
+acpi_status
+acpi_system_suspend(
+	u32		state)
+{
+	acpi_status		status = AE_ERROR;
+	unsigned long		flags = 0;
+
+	local_irq_save(flags);
+	/* kernel_fpu_begin(); */
+
+	switch (state) {
+	case ACPI_STATE_S1:
+	case ACPI_STATE_S5:
+		barrier();
+		status = acpi_enter_sleep_state(state);
+		break;
+	case ACPI_STATE_S4:
+		do_suspend_lowlevel_s4bios(0);
+		break;
+	}
+
+	/* kernel_fpu_end(); */
+	local_irq_restore(flags);
+
+	return status;
+}
+
+
+
+/**
+ * acpi_suspend - OS-agnostic system suspend/resume support (S? states)
+ * @state:	state we're entering
+ *
+ */
+acpi_status
+acpi_suspend (
+	u32			state)
+{
+	acpi_status status;
+
+	/* only support S1 and S5 on kernel 2.4 */
+	if (state != ACPI_STATE_S1 && state != ACPI_STATE_S4
+	    && state != ACPI_STATE_S5)
+		return AE_ERROR;
+
+
+	if (ACPI_STATE_S4 == state) {
+		/* For s4bios, we need a wakeup address. */
+		if (1 == acpi_gbl_FACS->S4bios_f &&
+		    0 != acpi_gbl_FADT->smi_cmd) {
+			if (!acpi_wakeup_address)
+				return AE_ERROR;
+			acpi_set_firmware_waking_vector((acpi_physical_address) acpi_wakeup_address);
+		} else
+			/* We don't support S4 under 2.4.  Give up */
+			return AE_ERROR;
+	}
+
+	status = acpi_system_save_state(state);
+	if (!ACPI_SUCCESS(status) && state != ACPI_STATE_S5)
+		return status;
+
+	acpi_enter_sleep_state_prep(state);
+
+	/* disable interrupts and flush caches */
+	ACPI_DISABLE_IRQS();
+	ACPI_FLUSH_CPU_CACHE();
+
+	/* perform OS-specific sleep actions */
+	status = acpi_system_suspend(state);
+
+	/* Even if we failed to go to sleep, all of the devices are in an suspended
+	 * mode. So, we run these unconditionaly to make sure we have a usable system
+	 * no matter what.
+	 */
+	acpi_leave_sleep_state(state);
+	acpi_system_restore_state(state);
+
+	/* make sure interrupts are enabled */
+	ACPI_ENABLE_IRQS();
+
+	/* reset firmware waking vector */
+	acpi_set_firmware_waking_vector((acpi_physical_address) 0);
+
+	return status;
+}
+
+#endif /* CONFIG_ACPI_SLEEP */
+
+
+/* --------------------------------------------------------------------------
+                              FS Interface (/proc)
+   -------------------------------------------------------------------------- */
+
+static int
+acpi_system_read_info (
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	struct acpi_system	*system = (struct acpi_system *) data;
+	char			*p = page;
+	int			size = 0;
+	u32			i = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_system_read_info");
+
+	if (!system || (off != 0))
+		goto end;
+
+	p += sprintf(p, "version:                 %x\n", ACPI_CA_VERSION);
+
+	p += sprintf(p, "states:                  ");
+	for (i=0; i<ACPI_S_STATE_COUNT; i++) {
+		if (system->states[i]) {
+			p += sprintf(p, "S%d ", i);
+			if (i == ACPI_STATE_S4 &&
+			    acpi_gbl_FACS->S4bios_f &&
+			    0 != acpi_gbl_FADT->smi_cmd)
+				p += sprintf(p, "S4Bios ");
+		}
+	}
+	p += sprintf(p, "\n");
+
+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;
+
+	return_VALUE(size);
+}
+
+static int acpi_system_open_event(struct inode *inode, struct file *file);
+static ssize_t acpi_system_read_event (struct file*, char*, size_t, loff_t*);
+static int acpi_system_close_event(struct inode *inode, struct file *file);
+static unsigned int acpi_system_poll_event(struct file *file, poll_table *wait);
+
+
+static struct file_operations acpi_system_event_ops = {
+	.open =		acpi_system_open_event,
+	.read =		acpi_system_read_event,
+	.release =	acpi_system_close_event,
+	.poll =		acpi_system_poll_event,
+};
+
+static int
+acpi_system_open_event(struct inode *inode, struct file *file)
+{
+	spin_lock_irq (&acpi_system_event_lock);
+
+	if(event_is_open)
+		goto out_busy;
+
+	event_is_open = 1;
+
+	spin_unlock_irq (&acpi_system_event_lock);
+	return 0;
+
+out_busy:
+	spin_unlock_irq (&acpi_system_event_lock);
+	return -EBUSY;
+}
+
+static ssize_t
+acpi_system_read_event (
+	struct file		*file,
+	char			*buffer,
+	size_t			count,
+	loff_t			*ppos)
+{
+	int			result = 0;
+	struct acpi_bus_event	event;
+	static char		str[ACPI_MAX_STRING];
+	static int		chars_remaining = 0;
+	static char		*ptr;
+
+
+	ACPI_FUNCTION_TRACE("acpi_system_read_event");
+
+	if (!chars_remaining) {
+		memset(&event, 0, sizeof(struct acpi_bus_event));
+
+		if ((file->f_flags & O_NONBLOCK)
+		    && (list_empty(&acpi_bus_event_list)))
+			return_VALUE(-EAGAIN);
+
+		result = acpi_bus_receive_event(&event);
+		if (result) {
+			return_VALUE(-EIO);
+		}
+
+		chars_remaining = sprintf(str, "%s %s %08x %08x\n", 
+			event.device_class?event.device_class:"<unknown>",
+			event.bus_id?event.bus_id:"<unknown>", 
+			event.type, event.data);
+		ptr = str;
+	}
+
+	if (chars_remaining < count) {
+		count = chars_remaining;
+	}
+
+	if (copy_to_user(buffer, ptr, count))
+		return_VALUE(-EFAULT);
+
+	*ppos += count;
+	chars_remaining -= count;
+	ptr += count;
+
+	return_VALUE(count);
+}
+
+static int
+acpi_system_close_event(struct inode *inode, struct file *file)
+{
+	spin_lock_irq (&acpi_system_event_lock);
+	event_is_open = 0;
+	spin_unlock_irq (&acpi_system_event_lock);
+	return 0;
+}
+
+static unsigned int
+acpi_system_poll_event(
+	struct file		*file,
+	poll_table		*wait)
+{
+	poll_wait(file, &acpi_bus_event_queue, wait);
+	if (!list_empty(&acpi_bus_event_list))
+		return POLLIN | POLLRDNORM;
+	return 0;
+}
+
+static ssize_t acpi_system_read_dsdt (struct file*, char*, size_t, loff_t*);
+
+static struct file_operations acpi_system_dsdt_ops = {
+	.read =			acpi_system_read_dsdt,
+};
+
+static ssize_t
+acpi_system_read_dsdt (
+	struct file		*file,
+	char			*buffer,
+	size_t			count,
+	loff_t			*ppos)
+{
+	acpi_status		status = AE_OK;
+	struct acpi_buffer	dsdt = {ACPI_ALLOCATE_BUFFER, NULL};
+	void			*data = 0;
+	size_t			size = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_system_read_dsdt");
+
+	status = acpi_get_table(ACPI_TABLE_DSDT, 1, &dsdt);
+	if (ACPI_FAILURE(status))
+		return_VALUE(-ENODEV);
+
+	if (*ppos < dsdt.length) {
+		data = dsdt.pointer + file->f_pos;
+		size = dsdt.length - file->f_pos;
+		if (size > count)
+			size = count;
+		if (copy_to_user(buffer, data, size)) {
+			acpi_os_free(dsdt.pointer);
+			return_VALUE(-EFAULT);
+		}
+	}
+
+	acpi_os_free(dsdt.pointer);
+
+	*ppos += size;
+
+	return_VALUE(size);
+}
+
+
+static ssize_t acpi_system_read_fadt (struct file*, char*, size_t, loff_t*);
+
+static struct file_operations acpi_system_fadt_ops = {
+	.read =			acpi_system_read_fadt,
+};
+
+static ssize_t
+acpi_system_read_fadt (
+	struct file		*file,
+	char			*buffer,
+	size_t			count,
+	loff_t			*ppos)
+{
+	acpi_status		status = AE_OK;
+	struct acpi_buffer	fadt = {ACPI_ALLOCATE_BUFFER, NULL};
+	void			*data = 0;
+	size_t			size = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_system_read_fadt");
+
+	status = acpi_get_table(ACPI_TABLE_FADT, 1, &fadt);
+	if (ACPI_FAILURE(status))
+		return_VALUE(-ENODEV);
+
+	if (*ppos < fadt.length) {
+		data = fadt.pointer + file->f_pos;
+		size = fadt.length - file->f_pos;
+		if (size > count)
+			size = count;
+		if (copy_to_user(buffer, data, size)) {
+			acpi_os_free(fadt.pointer);
+			return_VALUE(-EFAULT);
+		}
+	}
+
+	acpi_os_free(fadt.pointer);
+
+	*ppos += size;
+
+	return_VALUE(size);
+}
+
+
+#ifdef ACPI_DEBUG_OUTPUT
+
+static int
+acpi_system_read_debug (
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	char			*p = page;
+	int 			size = 0;
+
+	if (off != 0)
+		goto end;
+
+	switch ((unsigned long) data) {
+	case 0:
+		p += sprintf(p, "0x%08x\n", acpi_dbg_layer);
+		break;
+	case 1:
+		p += sprintf(p, "0x%08x\n", acpi_dbg_level);
+		break;
+	default:
+		p += sprintf(p, "Invalid debug option\n");
+		break;
+	}
+	
+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;
+
+	return size;
+}
+
+
+static int
+acpi_system_write_debug (
+	struct file             *file,
+        const char              *buffer,
+	unsigned long           count,
+        void                    *data)
+{
+	char			debug_string[12] = {'\0'};
+
+	ACPI_FUNCTION_TRACE("acpi_system_write_debug");
+
+	if (count > sizeof(debug_string) - 1)
+		return_VALUE(-EINVAL);
+
+	if (copy_from_user(debug_string, buffer, count))
+		return_VALUE(-EFAULT);
+
+	debug_string[count] = '\0';
+
+	switch ((unsigned long) data) {
+	case 0:
+		acpi_dbg_layer = simple_strtoul(debug_string, NULL, 0);
+		break;
+	case 1:
+		acpi_dbg_level = simple_strtoul(debug_string, NULL, 0);
+		break;
+	default:
+		return_VALUE(-EINVAL);
+	}
+
+	return_VALUE(count);
+}
+
+#endif /* ACPI_DEBUG_OUTPUT */
+
+
+#ifdef CONFIG_ACPI_SLEEP
+
+static int
+acpi_system_read_sleep (
+        char                    *page,
+        char                    **start,
+        off_t                   off,
+        int                     count,
+        int                     *eof,
+        void                    *data)
+{
+	struct acpi_system	*system = (struct acpi_system *) data;
+	char			*p = page;
+	int			size;
+	int			i;
+
+	ACPI_FUNCTION_TRACE("acpi_system_read_sleep");
+
+	if (!system || (off != 0))
+		goto end;
+
+	for (i = 0; i <= ACPI_STATE_S5; i++) {
+		if (system->states[i]) {
+			p += sprintf(p,"S%d ", i);
+			if (i == ACPI_STATE_S4 && acpi_gbl_FACS->S4bios_f &&
+			    acpi_gbl_FADT->smi_cmd != 0)
+				p += sprintf(p, "S4Bios ");
+		}
+	}
+
+	p += sprintf(p, "\n");
+
+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;
+
+	return_VALUE(size);
+}
+
+
+static int
+acpi_system_write_sleep (
+	struct file		*file,
+	const char		*buffer,
+	unsigned long		count,
+	void			*data)
+{
+	acpi_status		status = AE_OK;
+	struct acpi_system	*system = (struct acpi_system *) data;
+	char			state_string[12] = {'\0'};
+	u32			state = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_system_write_sleep");
+
+	if (!system || (count > sizeof(state_string) - 1))
+		return_VALUE(-EINVAL);
+
+	if (copy_from_user(state_string, buffer, count))
+		return_VALUE(-EFAULT);
+	
+	state_string[count] = '\0';
+	
+	state = simple_strtoul(state_string, NULL, 0);
+	
+	if (!system->states[state])
+		return_VALUE(-ENODEV);
+
+	/*
+	 * If S4 is supported by the OS, then we should assume that
+	 * echo 4b > /proc/acpi/sleep is for s4bios.
+	 * Since we have only s4bios, we assume that acpi_suspend failed
+	 * if no s4bios support.
+	 */
+	status = acpi_suspend(state);
+	if (ACPI_FAILURE(status))
+		return_VALUE(-ENODEV);
+	
+	return_VALUE(count);
+}
+
+
+static int
+acpi_system_read_alarm (
+	char                    *page,
+	char                    **start,
+	off_t                   off,
+	int                     count,
+	int                     *eof,
+	void                    *context)
+{
+	char			*p = page;
+	int			size = 0;
+	u32			sec, min, hr;
+	u32			day, mo, yr;
+
+	ACPI_FUNCTION_TRACE("acpi_system_read_alarm");
+
+	if (off != 0)
+		goto end;
+
+	spin_lock(&rtc_lock);
+
+	sec = CMOS_READ(RTC_SECONDS_ALARM);
+	min = CMOS_READ(RTC_MINUTES_ALARM);
+	hr = CMOS_READ(RTC_HOURS_ALARM);
+
+#if 0	/* If we ever get an FACP with proper values... */
+	if (acpi_gbl_FADT->day_alrm)
+		day = CMOS_READ(acpi_gbl_FADT->day_alrm);
+	else
+		day =  CMOS_READ(RTC_DAY_OF_MONTH);
+	if (acpi_gbl_FADT->mon_alrm)
+		mo = CMOS_READ(acpi_gbl_FADT->mon_alrm);
+	else
+		mo = CMOS_READ(RTC_MONTH);;
+	if (acpi_gbl_FADT->century)
+		yr = CMOS_READ(acpi_gbl_FADT->century) * 100 + CMOS_READ(RTC_YEAR);
+	else
+		yr = CMOS_READ(RTC_YEAR);
+#else
+	day = CMOS_READ(RTC_DAY_OF_MONTH);
+	mo = CMOS_READ(RTC_MONTH);
+	yr = CMOS_READ(RTC_YEAR);
+#endif
+
+	spin_unlock(&rtc_lock);
+
+	BCD_TO_BIN(sec);
+	BCD_TO_BIN(min);
+	BCD_TO_BIN(hr);
+	BCD_TO_BIN(day);
+	BCD_TO_BIN(mo);
+	BCD_TO_BIN(yr);
+
+#if 0
+	/* we're trusting the FADT (see above)*/
+#else
+	/* If we're not trusting the FADT, we should at least make it
+	 * right for _this_ century... ehm, what is _this_ century?
+	 *
+	 * TBD:
+	 *  ASAP: find piece of code in the kernel, e.g. star tracker driver,
+	 *        which we can trust to determine the century correctly. Atom
+	 *        watch driver would be nice, too...
+	 *
+	 *  if that has not happened, change for first release in 2050:
+ 	 *        if (yr<50)
+	 *                yr += 2100;
+	 *        else
+	 *                yr += 2000;   // current line of code
+	 *
+	 *  if that has not happened either, please do on 2099/12/31:23:59:59
+	 *        s/2000/2100
+	 *
+	 */
+	yr += 2000;
+#endif
+
+	p += sprintf(p,"%4.4u-", yr);
+	p += (mo > 12)  ? sprintf(p, "**-")  : sprintf(p, "%2.2u-", mo);
+	p += (day > 31) ? sprintf(p, "** ")  : sprintf(p, "%2.2u ", day);
+	p += (hr > 23)  ? sprintf(p, "**:")  : sprintf(p, "%2.2u:", hr);
+	p += (min > 59) ? sprintf(p, "**:")  : sprintf(p, "%2.2u:", min);
+	p += (sec > 59) ? sprintf(p, "**\n") : sprintf(p, "%2.2u\n", sec);
+
+ end:
+	size = p - page;
+	if (size < count) *eof = 1;
+	else if (size > count) size = count;
+	if (size < 0) size = 0;
+	*start = page;
+
+	return_VALUE(size);
+}
+
+
+static int
+get_date_field (
+	char			**p,
+	u32			*value)
+{
+	char			*next = NULL;
+	char			*string_end = NULL;
+	int			result = -EINVAL;
+
+	/*
+	 * Try to find delimeter, only to insert null.  The end of the
+	 * string won't have one, but is still valid.
+	 */
+	next = strpbrk(*p, "- :");
+	if (next)
+		*next++ = '\0';
+
+	*value = simple_strtoul(*p, &string_end, 10);
+
+	/* Signal success if we got a good digit */
+	if (string_end != *p)
+		result = 0;
+
+	if (next)
+		*p = next;
+
+	return result;
+}
+
+
+static int
+acpi_system_write_alarm (
+	struct file		*file,
+	const char		*buffer,
+	unsigned long		count,
+	void			*data)
+{
+	int			result = 0;
+	char			alarm_string[30] = {'\0'};
+	char			*p = alarm_string;
+	u32			sec, min, hr, day, mo, yr;
+	int			adjust = 0;
+	unsigned char		rtc_control = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_system_write_alarm");
+
+	if (count > sizeof(alarm_string) - 1)
+		return_VALUE(-EINVAL);
+	
+	if (copy_from_user(alarm_string, buffer, count))
+		return_VALUE(-EFAULT);
+
+	alarm_string[count] = '\0';
+
+	/* check for time adjustment */
+	if (alarm_string[0] == '+') {
+		p++;
+		adjust = 1;
+	}
+
+	if ((result = get_date_field(&p, &yr)))
+		goto end;
+	if ((result = get_date_field(&p, &mo)))
+		goto end;
+	if ((result = get_date_field(&p, &day)))
+		goto end;
+	if ((result = get_date_field(&p, &hr)))
+		goto end;
+	if ((result = get_date_field(&p, &min)))
+		goto end;
+	if ((result = get_date_field(&p, &sec)))
+		goto end;
+
+	if (sec > 59) {
+		min += 1;
+		sec -= 60;
+	}
+	if (min > 59) {
+		hr += 1;
+		min -= 60;
+	}
+	if (hr > 23) {
+		day += 1;
+		hr -= 24;
+	}
+	if (day > 31) {
+		mo += 1;
+		day -= 31;
+	}
+	if (mo > 12) {
+		yr += 1;
+		mo -= 12;
+	}
+
+	spin_lock_irq(&rtc_lock);
+
+	rtc_control = CMOS_READ(RTC_CONTROL);
+	if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
+		BIN_TO_BCD(yr);
+		BIN_TO_BCD(mo);
+		BIN_TO_BCD(day);
+		BIN_TO_BCD(hr);
+		BIN_TO_BCD(min);
+		BIN_TO_BCD(sec);
+	}
+
+	if (adjust) {
+		yr  += CMOS_READ(RTC_YEAR);
+		mo  += CMOS_READ(RTC_MONTH);
+		day += CMOS_READ(RTC_DAY_OF_MONTH);
+		hr  += CMOS_READ(RTC_HOURS);
+		min += CMOS_READ(RTC_MINUTES);
+		sec += CMOS_READ(RTC_SECONDS);
+	}
+
+	spin_unlock_irq(&rtc_lock);
+
+	if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
+		BCD_TO_BIN(yr);
+		BCD_TO_BIN(mo);
+		BCD_TO_BIN(day);
+		BCD_TO_BIN(hr);
+		BCD_TO_BIN(min);
+		BCD_TO_BIN(sec);
+	}
+
+	if (sec > 59) {
+		min++;
+		sec -= 60;
+	}
+	if (min > 59) {
+		hr++;
+		min -= 60;
+	}
+	if (hr > 23) {
+		day++;
+		hr -= 24;
+	}
+	if (day > 31) {
+		mo++;
+		day -= 31;
+	}
+	if (mo > 12) {
+		yr++;
+		mo -= 12;
+	}
+	if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
+		BIN_TO_BCD(yr);
+		BIN_TO_BCD(mo);
+		BIN_TO_BCD(day);
+		BIN_TO_BCD(hr);
+		BIN_TO_BCD(min);
+		BIN_TO_BCD(sec);
+	}
+
+	spin_lock_irq(&rtc_lock);
+
+	/* write the fields the rtc knows about */
+	CMOS_WRITE(hr, RTC_HOURS_ALARM);
+	CMOS_WRITE(min, RTC_MINUTES_ALARM);
+	CMOS_WRITE(sec, RTC_SECONDS_ALARM);
+
+	/*
+	 * If the system supports an enhanced alarm it will have non-zero
+	 * offsets into the CMOS RAM here -- which for some reason are pointing
+	 * to the RTC area of memory.
+	 */
+#if 0
+	if (acpi_gbl_FADT->day_alrm)
+		CMOS_WRITE(day, acpi_gbl_FADT->day_alrm);
+	if (acpi_gbl_FADT->mon_alrm)
+		CMOS_WRITE(mo, acpi_gbl_FADT->mon_alrm);
+	if (acpi_gbl_FADT->century)
+		CMOS_WRITE(yr/100, acpi_gbl_FADT->century);
+#endif
+	/* enable the rtc alarm interrupt */
+	if (!(rtc_control & RTC_AIE)) {
+		rtc_control |= RTC_AIE;
+		CMOS_WRITE(rtc_control,RTC_CONTROL);
+		CMOS_READ(RTC_INTR_FLAGS);
+	}
+
+	spin_unlock_irq(&rtc_lock);
+
+	acpi_set_register(ACPI_BITREG_RT_CLOCK_ENABLE, 1, ACPI_MTX_LOCK);
+
+	file->f_pos += count;
+
+	result = 0;
+end:
+	return_VALUE(result ? result : count);
+}
+
+#endif /*CONFIG_ACPI_SLEEP*/
+
+
+static int
+acpi_system_add_fs (
+	struct acpi_device	*device)
+{
+	struct proc_dir_entry	*entry = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_system_add_fs");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	/* 'info' [R] */
+	entry = create_proc_entry(ACPI_SYSTEM_FILE_INFO,
+		S_IRUGO, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_SYSTEM_FILE_INFO));
+	else {
+		entry->read_proc = acpi_system_read_info;
+		entry->data = acpi_driver_data(device);
+	}
+
+	/* 'dsdt' [R] */
+	entry = create_proc_entry(ACPI_SYSTEM_FILE_DSDT,
+		S_IRUSR, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_SYSTEM_FILE_DSDT));
+	else
+		entry->proc_fops = &acpi_system_dsdt_ops;
+
+	/* 'fadt' [R] */
+	entry = create_proc_entry(ACPI_SYSTEM_FILE_FADT,
+		S_IRUSR, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_SYSTEM_FILE_FADT));
+	else
+		entry->proc_fops = &acpi_system_fadt_ops;
+
+	/* 'event' [R] */
+	entry = create_proc_entry(ACPI_SYSTEM_FILE_EVENT,
+		S_IRUSR, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_SYSTEM_FILE_EVENT));
+	else
+		entry->proc_fops = &acpi_system_event_ops;
+
+#ifdef CONFIG_ACPI_SLEEP
+
+	/* 'sleep' [R/W]*/
+	entry = create_proc_entry(ACPI_SYSTEM_FILE_SLEEP,
+		S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_SYSTEM_FILE_SLEEP));
+	else {
+		entry->read_proc = acpi_system_read_sleep;
+		entry->write_proc = acpi_system_write_sleep;
+		entry->data = acpi_driver_data(device);
+	}
+
+	/* 'alarm' [R/W] */
+	entry = create_proc_entry(ACPI_SYSTEM_FILE_ALARM,
+		S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_SYSTEM_FILE_ALARM));
+	else {
+		entry->read_proc = acpi_system_read_alarm;
+		entry->write_proc = acpi_system_write_alarm;
+		entry->data = acpi_driver_data(device);
+	}
+
+#endif /*CONFIG_ACPI_SLEEP*/
+
+#ifdef ACPI_DEBUG_OUTPUT
+
+	/* 'debug_layer' [R/W] */
+	entry = create_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER,
+		S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_SYSTEM_FILE_DEBUG_LAYER));
+	else {
+		entry->read_proc  = acpi_system_read_debug;
+		entry->write_proc = acpi_system_write_debug;
+		entry->data = (void *) 0;
+	}
+
+	/* 'debug_level' [R/W] */
+	entry = create_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LEVEL,
+		S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_SYSTEM_FILE_DEBUG_LEVEL));
+	else {
+		entry->read_proc  = acpi_system_read_debug;
+		entry->write_proc = acpi_system_write_debug;
+		entry->data = (void *) 1;
+	}
+
+#endif /*ACPI_DEBUG_OUTPUT */
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_system_remove_fs (
+	struct acpi_device	*device)
+{
+	ACPI_FUNCTION_TRACE("acpi_system_remove_fs");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	remove_proc_entry(ACPI_SYSTEM_FILE_INFO, acpi_device_dir(device));
+	remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_device_dir(device));
+	remove_proc_entry(ACPI_SYSTEM_FILE_EVENT, acpi_device_dir(device));
+#ifdef CONFIG_ACPI_SLEEP
+	remove_proc_entry(ACPI_SYSTEM_FILE_SLEEP, acpi_device_dir(device));
+	remove_proc_entry(ACPI_SYSTEM_FILE_ALARM, acpi_device_dir(device));
+#endif
+#ifdef ACPI_DEBUG_OUTPUT
+	remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER,
+		acpi_device_dir(device));
+	remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LEVEL,
+		acpi_device_dir(device));
+#endif
+
+	return_VALUE(0);
+}
+
+
+/* --------------------------------------------------------------------------
+                                 Driver Interface
+   -------------------------------------------------------------------------- */
+
+#if defined(CONFIG_MAGIC_SYSRQ) && defined(CONFIG_PM)
+
+/* Simple wrapper calling power down function. */
+static void acpi_sysrq_power_off(int key, struct pt_regs *pt_regs,
+	struct kbd_struct *kbd, struct tty_struct *tty)
+{
+	acpi_power_off();
+}
+
+struct sysrq_key_op sysrq_acpi_poweroff_op = {
+	.handler =	&acpi_sysrq_power_off,
+	.help_msg =	"Off",
+	.action_msg =	"Power Off\n"
+};
+
+#endif  /* CONFIG_MAGIC_SYSRQ */
+
+static int
+acpi_system_add (
+	struct acpi_device	*device)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	struct acpi_system	*system = NULL;
+	u8			i = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_system_add");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	system = kmalloc(sizeof(struct acpi_system), GFP_KERNEL);
+	if (!system)
+		return_VALUE(-ENOMEM);
+	memset(system, 0, sizeof(struct acpi_system));
+
+	system->handle = device->handle;
+	sprintf(acpi_device_name(device), "%s", ACPI_SYSTEM_DEVICE_NAME);
+	sprintf(acpi_device_class(device), "%s", ACPI_SYSTEM_CLASS);
+	acpi_driver_data(device) = system;
+
+	result = acpi_system_add_fs(device);
+	if (result)
+		goto end;
+
+	printk(KERN_INFO PREFIX "%s [%s] (supports", 
+		acpi_device_name(device), acpi_device_bid(device));
+	for (i=0; i<ACPI_S_STATE_COUNT; i++) {
+		u8 type_a, type_b;
+		status = acpi_get_sleep_type_data(i, &type_a, &type_b);
+		switch (i) {
+		case ACPI_STATE_S4:
+			if (acpi_gbl_FACS->S4bios_f &&
+			    0 != acpi_gbl_FADT->smi_cmd) {
+				printk(" S4bios");
+				system->states[i] = 1;
+			}
+			/* no break */
+		default: 
+			if (ACPI_SUCCESS(status)) {
+				system->states[i] = 1;
+				printk(" S%d", i);
+			}
+		}
+	}
+	printk(")\n");
+
+#ifdef CONFIG_PM
+	/* Install the soft-off (S5) handler. */
+	if (system->states[ACPI_STATE_S5]) {
+		pm_power_off = acpi_power_off;
+		register_sysrq_key('o', &sysrq_acpi_poweroff_op);
+	}
+#endif
+
+end:
+	if (result)
+		kfree(system);
+
+	return_VALUE(result);
+}
+
+
+static int
+acpi_system_remove (
+	struct acpi_device	*device,
+	int			type)
+{
+	struct acpi_system	*system = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_system_remove");
+
+	if (!device || !acpi_driver_data(device))
+		return_VALUE(-EINVAL);
+
+	system = (struct acpi_system *) acpi_driver_data(device);
+
+#ifdef CONFIG_PM
+	/* Remove the soft-off (S5) handler. */
+	if (system->states[ACPI_STATE_S5]) {
+		unregister_sysrq_key('o', &sysrq_acpi_poweroff_op);
+		pm_power_off = NULL;
+	}
+#endif
+
+	acpi_system_remove_fs(device);
+
+	kfree(system);
+
+	return 0;
+}
+
+
+int __init
+acpi_system_init (void)
+{
+	int			result = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_system_init");
+
+	result = acpi_bus_register_driver(&acpi_system_driver);
+	if (result < 0)
+		return_VALUE(-ENODEV);
+
+	return_VALUE(0);
+}
+
+
+void __exit
+acpi_system_exit (void)
+{
+	ACPI_FUNCTION_TRACE("acpi_system_exit");
+	acpi_bus_unregister_driver(&acpi_system_driver);
+	return_VOID;
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/tables/Makefile linux-2.4.22-pre2/drivers/acpi/tables/Makefile
--- linux-2.4.21/drivers/acpi/tables/Makefile	2001-06-21 00:47:40.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/tables/Makefile	2003-06-26 21:43:11.000000000 +0000
@@ -1,11 +1,10 @@
 #
 # Makefile for all Linux ACPI interpreter subdirectories
-# EXCEPT for the ospm directory
 #
 
 O_TARGET := $(notdir $(CURDIR)).o
 
-obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/tables/tbconvrt.c linux-2.4.22-pre2/drivers/acpi/tables/tbconvrt.c
--- linux-2.4.21/drivers/acpi/tables/tbconvrt.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/tables/tbconvrt.c	2003-06-26 21:43:18.000000000 +0000
@@ -1,68 +1,85 @@
 /******************************************************************************
  *
  * Module Name: tbconvrt - ACPI Table conversion utilities
- *              $Revision: 28 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "achware.h"
-#include "actables.h"
-#include "actbl.h"
+#include <acpi/acpi.h>
+#include <acpi/actables.h>
 
 
 #define _COMPONENT          ACPI_TABLES
-	 MODULE_NAME         ("tbconvrt")
+	 ACPI_MODULE_NAME    ("tbconvrt")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_get_table_count
+ * FUNCTION:    acpi_tb_get_table_count
  *
- * PARAMETERS:
+ * PARAMETERS:  RSDP            - Pointer to the RSDP
+ *              RSDT            - Pointer to the RSDT/XSDT
  *
- * RETURN:
+ * RETURN:      The number of tables pointed to by the RSDT or XSDT.
  *
- * DESCRIPTION: Calculate the number of tables
+ * DESCRIPTION: Calculate the number of tables.  Automatically handles either
+ *              an RSDT or XSDT.
  *
  ******************************************************************************/
 
 u32
 acpi_tb_get_table_count (
-	RSDP_DESCRIPTOR         *RSDP,
-	acpi_table_header       *RSDT)
+	struct rsdp_descriptor          *RSDP,
+	struct acpi_table_header        *RSDT)
 {
-	u32                     pointer_size;
+	u32                             pointer_size;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
-#ifndef _IA64
+#if ACPI_MACHINE_WIDTH != 64
 
 	if (RSDP->revision < 2) {
 		pointer_size = sizeof (u32);
 	}
-
 	else
 #endif
 	{
@@ -75,17 +92,17 @@
 	 * pointers contained within the RSDT/XSDT.  The size of the pointers
 	 * is architecture-dependent.
 	 */
-	return ((RSDT->length - sizeof (acpi_table_header)) / pointer_size);
+	return ((RSDT->length - sizeof (struct acpi_table_header)) / pointer_size);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_convert_to_xsdt
+ * FUNCTION:    acpi_tb_convert_to_xsdt
  *
- * PARAMETERS:
+ * PARAMETERS:  table_info      - Info about the RSDT
  *
- * RETURN:
+ * RETURN:      Status
  *
  * DESCRIPTION: Convert an RSDT to an XSDT (internal common format)
  *
@@ -93,24 +110,20 @@
 
 acpi_status
 acpi_tb_convert_to_xsdt (
-	acpi_table_desc         *table_info,
-	u32                     *number_of_tables)
+	struct acpi_table_desc          *table_info)
 {
-	u32                     table_size;
-	u32                     i;
-	xsdt_descriptor         *new_table;
-
-
-	FUNCTION_ENTRY ();
+	acpi_size                       table_size;
+	u32                             i;
+	XSDT_DESCRIPTOR         *new_table;
 
 
-	*number_of_tables = acpi_tb_get_table_count (acpi_gbl_RSDP, table_info->pointer);
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/* Compute size of the converted XSDT */
 
-	table_size = (*number_of_tables * sizeof (u64)) + sizeof (acpi_table_header);
-
+	table_size = ((acpi_size) acpi_gbl_rsdt_table_count * sizeof (u64)) +
+			  sizeof (struct acpi_table_header);
 
 	/* Allocate an XSDT */
 
@@ -121,37 +134,29 @@
 
 	/* Copy the header and set the length */
 
-	MEMCPY (new_table, table_info->pointer, sizeof (acpi_table_header));
-	new_table->header.length = table_size;
+	ACPI_MEMCPY (new_table, table_info->pointer, sizeof (struct acpi_table_header));
+	new_table->header.length = (u32) table_size;
 
 	/* Copy the table pointers */
 
-	for (i = 0; i < *number_of_tables; i++) {
+	for (i = 0; i < acpi_gbl_rsdt_table_count; i++) {
 		if (acpi_gbl_RSDP->revision < 2) {
-#ifdef _IA64
-			new_table->table_offset_entry[i] =
-				((RSDT_DESCRIPTOR_REV071 *) table_info->pointer)->table_offset_entry[i];
-#else
 			ACPI_STORE_ADDRESS (new_table->table_offset_entry[i],
-				((RSDT_DESCRIPTOR_REV1 *) table_info->pointer)->table_offset_entry[i]);
-#endif
+				((struct rsdt_descriptor_rev1 *) table_info->pointer)->table_offset_entry[i]);
 		}
 		else {
 			new_table->table_offset_entry[i] =
-				((xsdt_descriptor *) table_info->pointer)->table_offset_entry[i];
+				((XSDT_DESCRIPTOR *) table_info->pointer)->table_offset_entry[i];
 		}
 	}
 
-
 	/* Delete the original table (either mapped or in a buffer) */
 
 	acpi_tb_delete_single_table (table_info);
 
-
 	/* Point the table descriptor to the new table */
 
-	table_info->pointer     = (acpi_table_header *) new_table;
-	table_info->base_pointer = (acpi_table_header *) new_table;
+	table_info->pointer     = (struct acpi_table_header *) new_table;
 	table_info->length      = table_size;
 	table_info->allocation  = ACPI_MEM_ALLOCATED;
 
@@ -159,327 +164,325 @@
 }
 
 
-/*******************************************************************************
+/******************************************************************************
  *
- * FUNCTION:    Acpi_tb_convert_table_fadt
+ * FUNCTION:    acpi_tb_init_generic_address
  *
- * PARAMETERS:
+ * PARAMETERS:  new_gas_struct      - GAS struct to be initialized
+ *              register_bit_width  - Width of this register
+ *              Address             - Address of the register
  *
- * RETURN:
+ * RETURN:      None
  *
- * DESCRIPTION:
- *    Converts BIOS supplied 1.0 and 0.71 ACPI FADT to an intermediate
- *    ACPI 2.0 FADT. If the BIOS supplied a 2.0 FADT then it is simply
- *    copied to the intermediate FADT.  The ACPI CA software uses this
- *    intermediate FADT. Thus a significant amount of special #ifdef
- *    type codeing is saved. This intermediate FADT will need to be
- *    freed at some point.
+ * DESCRIPTION: Initialize a GAS structure.
  *
  ******************************************************************************/
 
-acpi_status
-acpi_tb_convert_table_fadt (void)
+static void
+acpi_tb_init_generic_address (
+	struct acpi_generic_address     *new_gas_struct,
+	u8                              register_bit_width,
+	acpi_physical_address           address)
 {
 
-#ifdef _IA64
-	fadt_descriptor_rev071 *FADT71;
-	u8                      pm1_address_space;
-	u8                      pm2_address_space;
-	u8                      pm_timer_address_space;
-	u8                      gpe0address_space;
-	u8                      gpe1_address_space;
-#else
-	fadt_descriptor_rev1   *FADT1;
-#endif
-
-	fadt_descriptor_rev2   *FADT2;
-	acpi_table_desc        *table_desc;
-
-
-	FUNCTION_TRACE ("Tb_convert_table_fadt");
-
-
-	/* Acpi_gbl_FADT is valid */
-	/* Allocate and zero the 2.0 buffer */
-
-	FADT2 = ACPI_MEM_CALLOCATE (sizeof (fadt_descriptor_rev2));
-	if (FADT2 == NULL) {
-		return_ACPI_STATUS (AE_NO_MEMORY);
-	}
-
-
-	/* The ACPI FADT revision number is FADT2_REVISION_ID=3 */
-	/* So, if the current table revision is less than 3 it is type 1.0 or 0.71 */
-
-	if (acpi_gbl_FADT->header.revision >= FADT2_REVISION_ID) {
-		/* We have an ACPI 2.0 FADT but we must copy it to our local buffer */
-
-		*FADT2 = *((fadt_descriptor_rev2*) acpi_gbl_FADT);
-
-	}
-
-	else {
-
-#ifdef _IA64
-		/*
-		 * For the 64-bit case only, a revision ID less than V2.0 means the
-		 * tables are the 0.71 extensions
-		 */
-
-		/* The BIOS stored FADT should agree with Revision 0.71 */
-
-		FADT71 = (fadt_descriptor_rev071 *) acpi_gbl_FADT;
-
-		/* Copy the table header*/
+	ACPI_STORE_ADDRESS (new_gas_struct->address, address);
 
-		FADT2->header       = FADT71->header;
-
-		/* Copy the common fields */
-
-		FADT2->sci_int      = FADT71->sci_int;
-		FADT2->acpi_enable  = FADT71->acpi_enable;
-		FADT2->acpi_disable = FADT71->acpi_disable;
-		FADT2->S4bios_req   = FADT71->S4bios_req;
-		FADT2->plvl2_lat    = FADT71->plvl2_lat;
-		FADT2->plvl3_lat    = FADT71->plvl3_lat;
-		FADT2->day_alrm     = FADT71->day_alrm;
-		FADT2->mon_alrm     = FADT71->mon_alrm;
-		FADT2->century      = FADT71->century;
-		FADT2->gpe1_base    = FADT71->gpe1_base;
-
-		/*
-		 * We still use the block length registers even though
-		 * the GAS structure should obsolete them.  This is because
-		 * these registers are byte lengths versus the GAS which
-		 * contains a bit width
-		 */
-		FADT2->pm1_evt_len  = FADT71->pm1_evt_len;
-		FADT2->pm1_cnt_len  = FADT71->pm1_cnt_len;
-		FADT2->pm2_cnt_len  = FADT71->pm2_cnt_len;
-		FADT2->pm_tm_len    = FADT71->pm_tm_len;
-		FADT2->gpe0blk_len  = FADT71->gpe0blk_len;
-		FADT2->gpe1_blk_len = FADT71->gpe1_blk_len;
-		FADT2->gpe1_base    = FADT71->gpe1_base;
-
-		/* Copy the existing 0.71 flags to 2.0. The other bits are zero.*/
-
-		FADT2->wb_invd      = FADT71->flush_cash;
-		FADT2->proc_c1      = FADT71->proc_c1;
-		FADT2->plvl2_up     = FADT71->plvl2_up;
-		FADT2->pwr_button   = FADT71->pwr_button;
-		FADT2->sleep_button = FADT71->sleep_button;
-		FADT2->fixed_rTC    = FADT71->fixed_rTC;
-		FADT2->rtcs4        = FADT71->rtcs4;
-		FADT2->tmr_val_ext  = FADT71->tmr_val_ext;
-		FADT2->dock_cap     = FADT71->dock_cap;
-
-
-		/* We should not use these next two addresses */
-		/* Since our buffer is pre-zeroed nothing to do for */
-		/* the next three data items in the structure */
-		/* FADT2->Firmware_ctrl = 0; */
-		/* FADT2->Dsdt = 0; */
-
-		/* System Interrupt Model isn't used in ACPI 2.0*/
-		/* FADT2->Reserved1 = 0; */
-
-		/* This field is set by the OEM to convey the preferred */
-		/* power management profile to OSPM. It doesn't have any*/
-		/* 0.71 equivalence.  Since we don't know what kind of  */
-		/* 64-bit system this is, we will pick unspecified.     */
-
-		FADT2->prefer_PM_profile = PM_UNSPECIFIED;
-
-
-		/* Port address of SMI command port */
-		/* We shouldn't use this port because IA64 doesn't */
-		/* have or use SMI.  It has PMI. */
+	new_gas_struct->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO;
+	new_gas_struct->register_bit_width = register_bit_width;
+	new_gas_struct->register_bit_offset = 0;
+	new_gas_struct->reserved        = 0;
+}
 
-		FADT2->smi_cmd      = (u32)(FADT71->smi_cmd & 0xFFFFFFFF);
 
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_tb_convert_fadt1
+ *
+ * PARAMETERS:  local_fadt      - Pointer to new FADT
+ *              original_fadt   - Pointer to old FADT
+ *
+ * RETURN:      Populates local_fadt
+ *
+ * DESCRIPTION: Convert an ACPI 1.0 FADT to common internal format
+ *
+ ******************************************************************************/
 
-		/* processor performance state control*/
-		/* The value OSPM writes to the SMI_CMD register to assume */
-		/* processor performance state control responsibility. */
-		/* There isn't any equivalence in 0.71 */
-		/* Again this should be meaningless for IA64 */
-		/* FADT2->Pstate_cnt = 0; */
+static void
+acpi_tb_convert_fadt1 (
+	struct fadt_descriptor_rev2    *local_fadt,
+	struct fadt_descriptor_rev1    *original_fadt)
+{
 
-		/* The 32-bit Power management and GPE registers are */
-		/* not valid in IA-64 and we are not going to use them */
-		/* so leaving them pre-zeroed. */
 
-		/* Support for the _CST object and C States change notification.*/
-		/* This data item hasn't any 0.71 equivalence so leaving it zero.*/
-		/* FADT2->Cst_cnt = 0; */
+	/* ACPI 1.0 FACS */
+	/* The BIOS stored FADT should agree with Revision 1.0 */
 
-		/* number of flush strides that need to be read */
-		/* No 0.71 equivalence. Leave pre-zeroed. */
-		/* FADT2->Flush_size = 0; */
+	/*
+	 * Copy the table header and the common part of the tables.
+	 *
+	 * The 2.0 table is an extension of the 1.0 table, so the entire 1.0
+	 * table can be copied first, then expand some fields to 64 bits.
+	 */
+	ACPI_MEMCPY (local_fadt, original_fadt, sizeof (struct fadt_descriptor_rev1));
 
-		/* Processor's memory cache line width, in bytes */
-		/* No 0.71 equivalence. Leave pre-zeroed. */
-		/* FADT2->Flush_stride = 0; */
+	/* Convert table pointers to 64-bit fields */
 
-		/* Processor's duty cycle index in processor's P_CNT reg*/
-		/* No 0.71 equivalence. Leave pre-zeroed. */
-		/* FADT2->Duty_offset = 0; */
+	ACPI_STORE_ADDRESS (local_fadt->xfirmware_ctrl, local_fadt->V1_firmware_ctrl);
+	ACPI_STORE_ADDRESS (local_fadt->Xdsdt, local_fadt->V1_dsdt);
 
-		/* Processor's duty cycle value bit width in P_CNT register.*/
-		/* No 0.71 equivalence. Leave pre-zeroed. */
-		/* FADT2->Duty_width = 0; */
+	/*
+	 * System Interrupt Model isn't used in ACPI 2.0 (local_fadt->Reserved1 = 0;)
+	 */
 
+	/*
+	 * This field is set by the OEM to convey the preferred power management
+	 * profile to OSPM. It doesn't have any 1.0 equivalence.  Since we don't
+	 * know what kind of 32-bit system this is, we will use "unspecified".
+	 */
+	local_fadt->prefer_PM_profile = PM_UNSPECIFIED;
 
-		/* Since there isn't any equivalence in 0.71 */
-		/* and since Big_sur had to support legacy */
+	/*
+	 * 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.
+	 */
+	local_fadt->pstate_cnt = 0;
 
-		FADT2->iapc_boot_arch = BAF_LEGACY_DEVICES;
+	/*
+	 * Support for the _CST object and C States change notification.
+	 * This data item hasn't any 1.0 equivalence so leave it zero.
+	 */
+	local_fadt->cst_cnt = 0;
 
-		/* Copy to ACPI 2.0 64-BIT Extended Addresses */
+	/*
+	 * Since there isn't any equivalence in 1.0 and since it highly likely
+	 * that a 1.0 system has legacy support.
+	 */
+	local_fadt->iapc_boot_arch = BAF_LEGACY_DEVICES;
 
-		FADT2->Xfirmware_ctrl = FADT71->firmware_ctrl;
-		FADT2->Xdsdt         = FADT71->dsdt;
+	/*
+	 * Convert the V1.0 block addresses to V2.0 GAS structures
+	 */
+	acpi_tb_init_generic_address (&local_fadt->xpm1a_evt_blk, local_fadt->pm1_evt_len,
+			  (acpi_physical_address)   local_fadt->V1_pm1a_evt_blk);
+	acpi_tb_init_generic_address (&local_fadt->xpm1b_evt_blk, local_fadt->pm1_evt_len,
+			  (acpi_physical_address)   local_fadt->V1_pm1b_evt_blk);
+	acpi_tb_init_generic_address (&local_fadt->xpm1a_cnt_blk, local_fadt->pm1_cnt_len,
+			  (acpi_physical_address)   local_fadt->V1_pm1a_cnt_blk);
+	acpi_tb_init_generic_address (&local_fadt->xpm1b_cnt_blk, local_fadt->pm1_cnt_len,
+			  (acpi_physical_address)   local_fadt->V1_pm1b_cnt_blk);
+	acpi_tb_init_generic_address (&local_fadt->xpm2_cnt_blk, local_fadt->pm2_cnt_len,
+			  (acpi_physical_address)   local_fadt->V1_pm2_cnt_blk);
+	acpi_tb_init_generic_address (&local_fadt->xpm_tmr_blk, local_fadt->pm_tm_len,
+			  (acpi_physical_address)   local_fadt->V1_pm_tmr_blk);
+	acpi_tb_init_generic_address (&local_fadt->xgpe0_blk, 0,
+			  (acpi_physical_address)   local_fadt->V1_gpe0_blk);
+	acpi_tb_init_generic_address (&local_fadt->xgpe1_blk, 0,
+			  (acpi_physical_address)   local_fadt->V1_gpe1_blk);
+
+	/* Create separate GAS structs for the PM1 Enable registers */
+
+	acpi_tb_init_generic_address (&acpi_gbl_xpm1a_enable,
+		 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len),
+		 (acpi_physical_address) (local_fadt->xpm1a_evt_blk.address +
+			ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len)));
+
+	/* PM1B is optional; leave null if not present */
+
+	if (local_fadt->xpm1b_evt_blk.address) {
+		acpi_tb_init_generic_address (&acpi_gbl_xpm1b_enable,
+			 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len),
+			 (acpi_physical_address) (local_fadt->xpm1b_evt_blk.address +
+				ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len)));
+	}
+}
 
 
-		/* Extract the address space IDs */
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_tb_convert_fadt2
+ *
+ * PARAMETERS:  local_fadt      - Pointer to new FADT
+ *              original_fadt   - Pointer to old FADT
+ *
+ * RETURN:      Populates local_fadt
+ *
+ * DESCRIPTION: Convert an ACPI 2.0 FADT to common internal format.
+ *              Handles optional "X" fields.
+ *
+ ******************************************************************************/
 
-		pm1_address_space   = (u8)((FADT71->address_space & PM1_BLK_ADDRESS_SPACE)    >> 1);
-		pm2_address_space   = (u8)((FADT71->address_space & PM2_CNT_BLK_ADDRESS_SPACE) >> 2);
-		pm_timer_address_space = (u8)((FADT71->address_space & PM_TMR_BLK_ADDRESS_SPACE) >> 3);
-		gpe0address_space   = (u8)((FADT71->address_space & GPE0_BLK_ADDRESS_SPACE)   >> 4);
-		gpe1_address_space  = (u8)((FADT71->address_space & GPE1_BLK_ADDRESS_SPACE)   >> 5);
+static void
+acpi_tb_convert_fadt2 (
+	struct fadt_descriptor_rev2    *local_fadt,
+	struct fadt_descriptor_rev2    *original_fadt)
+{
 
-		/*
-		 * Convert the 0.71 (non-GAS style) Block addresses to V2.0 GAS structures,
-		 * in this order:
-		 *
-		 * PM 1_a Events
-		 * PM 1_b Events
-		 * PM 1_a Control
-		 * PM 1_b Control
-		 * PM 2 Control
-		 * PM Timer Control
-		 * GPE Block 0
-		 * GPE Block 1
-		 */
+	/* We have an ACPI 2.0 FADT but we must copy it to our local buffer */
 
-		ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1a_evt_blk, FADT71->pm1_evt_len, FADT71->pm1a_evt_blk, pm1_address_space);
-		ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1b_evt_blk, FADT71->pm1_evt_len, FADT71->pm1b_evt_blk, pm1_address_space);
-		ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1a_cnt_blk, FADT71->pm1_cnt_len, FADT71->pm1a_cnt_blk, pm1_address_space);
-		ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1b_cnt_blk, FADT71->pm1_cnt_len, FADT71->pm1b_cnt_blk, pm1_address_space);
-		ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm2_cnt_blk, FADT71->pm2_cnt_len, FADT71->pm2_cnt_blk, pm2_address_space);
-		ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm_tmr_blk, FADT71->pm_tm_len,  FADT71->pm_tmr_blk, pm_timer_address_space);
-		ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xgpe0blk,    FADT71->gpe0blk_len, FADT71->gpe0blk,   gpe0address_space);
-		ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xgpe1_blk,   FADT71->gpe1_blk_len, FADT71->gpe1_blk, gpe1_address_space);
+	ACPI_MEMCPY (local_fadt, original_fadt, sizeof (struct fadt_descriptor_rev2));
 
-#else
+	/*
+	 * "X" fields are optional extensions to the original V1.0 fields, so
+	 * we must selectively expand V1.0 fields if the corresponding X field
+	 * is zero.
+	 */
+	if (!(local_fadt->xfirmware_ctrl)) {
+		ACPI_STORE_ADDRESS (local_fadt->xfirmware_ctrl, local_fadt->V1_firmware_ctrl);
+	}
 
-		/* ACPI 1.0 FACS */
+	if (!(local_fadt->Xdsdt)) {
+		ACPI_STORE_ADDRESS (local_fadt->Xdsdt, local_fadt->V1_dsdt);
+	}
 
+	if (!(local_fadt->xpm1a_evt_blk.address)) {
+		acpi_tb_init_generic_address (&local_fadt->xpm1a_evt_blk,
+			local_fadt->pm1_evt_len, (acpi_physical_address) local_fadt->V1_pm1a_evt_blk);
+	}
 
-		/* The BIOS stored FADT should agree with Revision 1.0 */
+	if (!(local_fadt->xpm1b_evt_blk.address)) {
+		acpi_tb_init_generic_address (&local_fadt->xpm1b_evt_blk,
+			local_fadt->pm1_evt_len, (acpi_physical_address) local_fadt->V1_pm1b_evt_blk);
+	}
 
-		FADT1 = (fadt_descriptor_rev1*) acpi_gbl_FADT;
+	if (!(local_fadt->xpm1a_cnt_blk.address)) {
+		acpi_tb_init_generic_address (&local_fadt->xpm1a_cnt_blk,
+			local_fadt->pm1_cnt_len, (acpi_physical_address) local_fadt->V1_pm1a_cnt_blk);
+	}
 
-		/*
-		 * Copy the table header and the common part of the tables
-		 * The 2.0 table is an extension of the 1.0 table, so the
-		 * entire 1.0 table can be copied first, then expand some
-		 * fields to 64 bits.
-		 */
-		MEMCPY (FADT2, FADT1, sizeof (fadt_descriptor_rev1));
+	if (!(local_fadt->xpm1b_cnt_blk.address)) {
+		acpi_tb_init_generic_address (&local_fadt->xpm1b_cnt_blk,
+			local_fadt->pm1_cnt_len, (acpi_physical_address) local_fadt->V1_pm1b_cnt_blk);
+	}
 
+	if (!(local_fadt->xpm2_cnt_blk.address)) {
+		acpi_tb_init_generic_address (&local_fadt->xpm2_cnt_blk,
+			local_fadt->pm2_cnt_len, (acpi_physical_address) local_fadt->V1_pm2_cnt_blk);
+	}
 
-		/* Convert table pointers to 64-bit fields */
+	if (!(local_fadt->xpm_tmr_blk.address)) {
+		acpi_tb_init_generic_address (&local_fadt->xpm_tmr_blk,
+			local_fadt->pm_tm_len, (acpi_physical_address) local_fadt->V1_pm_tmr_blk);
+	}
 
-		ACPI_STORE_ADDRESS (FADT2->Xfirmware_ctrl, FADT1->firmware_ctrl);
-		ACPI_STORE_ADDRESS (FADT2->Xdsdt, FADT1->dsdt);
+	if (!(local_fadt->xgpe0_blk.address)) {
+		acpi_tb_init_generic_address (&local_fadt->xgpe0_blk,
+			0, (acpi_physical_address) local_fadt->V1_gpe0_blk);
+	}
 
-		/* System Interrupt Model isn't used in ACPI 2.0*/
-		/* FADT2->Reserved1 = 0; */
+	if (!(local_fadt->xgpe1_blk.address)) {
+		acpi_tb_init_generic_address (&local_fadt->xgpe1_blk,
+			0, (acpi_physical_address) local_fadt->V1_gpe1_blk);
+	}
 
-		/* This field is set by the OEM to convey the preferred */
-		/* power management profile to OSPM. It doesn't have any*/
-		/* 1.0 equivalence.  Since we don't know what kind of   */
-		/* 32-bit system this is, we will pick unspecified.     */
+	/* Create separate GAS structs for the PM1 Enable registers */
 
-		FADT2->prefer_PM_profile = PM_UNSPECIFIED;
+	acpi_tb_init_generic_address (&acpi_gbl_xpm1a_enable,
+		(u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len),
+		(acpi_physical_address) (local_fadt->xpm1a_evt_blk.address +
+			ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len)));
+	acpi_gbl_xpm1a_enable.address_space_id = local_fadt->xpm1a_evt_blk.address_space_id;
+
+	/* PM1B is optional; leave null if not present */
+
+	if (local_fadt->xpm1b_evt_blk.address) {
+		acpi_tb_init_generic_address (&acpi_gbl_xpm1b_enable,
+			(u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len),
+			(acpi_physical_address) (local_fadt->xpm1b_evt_blk.address +
+				ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len)));
+		acpi_gbl_xpm1b_enable.address_space_id = local_fadt->xpm1b_evt_blk.address_space_id;
+	}
+}
 
 
-		/* 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.  So leave it zeroed.            */
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_tb_convert_table_fadt
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Converts a BIOS supplied ACPI 1.0 FADT to a local
+ *              ACPI 2.0 FADT. If the BIOS supplied a 2.0 FADT then it is simply
+ *              copied to the local FADT.  The ACPI CA software uses this
+ *              local FADT. Thus a significant amount of special #ifdef
+ *              type codeing is saved.
+ *
+ ******************************************************************************/
 
-		FADT2->pstate_cnt = 0;
+acpi_status
+acpi_tb_convert_table_fadt (void)
+{
+	struct fadt_descriptor_rev2    *local_fadt;
+	struct acpi_table_desc         *table_desc;
 
 
-		/* Support for the _CST object and C States change notification.*/
-		/* This data item hasn't any 1.0 equivalence so leaving it zero.*/
+	ACPI_FUNCTION_TRACE ("tb_convert_table_fadt");
 
-		FADT2->cst_cnt = 0;
 
+	/*
+	 * 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);
+	}
 
-		/* Since there isn't any equivalence in 1.0 and since it   */
-		/* is highly likely that a 1.0 system has legacy  support. */
+	/*
+	 * FADT length and version validation.  The table must be at least as
+	 * long as the version 1.0 FADT
+	 */
+	if (acpi_gbl_FADT->header.length < sizeof (struct fadt_descriptor_rev1)) {
+		ACPI_REPORT_ERROR (("Invalid FADT table length: 0x%X\n", acpi_gbl_FADT->header.length));
+		return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
+	}
 
-		FADT2->iapc_boot_arch = BAF_LEGACY_DEVICES;
+	if (acpi_gbl_FADT->header.revision >= FADT2_REVISION_ID) {
+		if (acpi_gbl_FADT->header.length < sizeof (struct fadt_descriptor_rev2)) {
+			/* Length is too short to be a V2.0 table */
 
+			ACPI_REPORT_WARNING (("Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n",
+					 acpi_gbl_FADT->header.length, acpi_gbl_FADT->header.revision));
 
-		/*
-		 * Convert the V1.0 Block addresses to V2.0 GAS structures
-		 * in this order:
-		 *
-		 * PM 1_a Events
-		 * PM 1_b Events
-		 * PM 1_a Control
-		 * PM 1_b Control
-		 * PM 2 Control
-		 * PM Timer Control
-		 * GPE Block 0
-		 * GPE Block 1
-		 */
+			acpi_tb_convert_fadt1 (local_fadt, (void *) acpi_gbl_FADT);
+		}
+		else {
+			/* Valid V2.0 table */
 
-		ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1a_evt_blk, FADT1->pm1_evt_len, FADT1->pm1a_evt_blk);
-		ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1b_evt_blk, FADT1->pm1_evt_len, FADT1->pm1b_evt_blk);
-		ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1a_cnt_blk, FADT1->pm1_cnt_len, FADT1->pm1a_cnt_blk);
-		ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1b_cnt_blk, FADT1->pm1_cnt_len, FADT1->pm1b_cnt_blk);
-		ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm2_cnt_blk, FADT1->pm2_cnt_len, FADT1->pm2_cnt_blk);
-		ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm_tmr_blk, FADT1->pm_tm_len,  FADT1->pm_tmr_blk);
-		ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xgpe0blk,    FADT1->gpe0blk_len, FADT1->gpe0blk);
-		ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xgpe1_blk,   FADT1->gpe1_blk_len, FADT1->gpe1_blk);
-#endif
+			acpi_tb_convert_fadt2 (local_fadt, acpi_gbl_FADT);
+		}
 	}
+	else {
+		/* Valid V1.0 table */
 
+		acpi_tb_convert_fadt1 (local_fadt, (void *) acpi_gbl_FADT);
+	}
 
 	/*
-	 * Global FADT pointer will point to the common V2.0 FADT
+	 * Global FADT pointer will point to the new common V2.0 FADT
 	 */
-	acpi_gbl_FADT = FADT2;
+	acpi_gbl_FADT = local_fadt;
 	acpi_gbl_FADT->header.length = sizeof (FADT_DESCRIPTOR);
 
-
 	/* Free the original table */
 
-	table_desc = &acpi_gbl_acpi_tables[ACPI_TABLE_FADT];
+	table_desc = acpi_gbl_table_lists[ACPI_TABLE_FADT].next;
 	acpi_tb_delete_single_table (table_desc);
 
-
 	/* Install the new table */
 
-	table_desc->pointer = (acpi_table_header *) acpi_gbl_FADT;
-	table_desc->base_pointer = acpi_gbl_FADT;
-	table_desc->allocation = ACPI_MEM_ALLOCATED;
-	table_desc->length = sizeof (fadt_descriptor_rev2);
-
+	table_desc->pointer     = (struct acpi_table_header *) acpi_gbl_FADT;
+	table_desc->allocation  = ACPI_MEM_ALLOCATED;
+	table_desc->length      = sizeof (struct fadt_descriptor_rev2);
 
 	/* Dump the entire FADT */
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_TABLES,
 		"Hex dump of common internal FADT, size %d (%X)\n",
 		acpi_gbl_FADT->header.length, acpi_gbl_FADT->header.length));
-	DUMP_BUFFER ((u8 *) (acpi_gbl_FADT), acpi_gbl_FADT->header.length);
-
+	ACPI_DUMP_BUFFER ((u8 *) (acpi_gbl_FADT), acpi_gbl_FADT->header.length);
 
 	return_ACPI_STATUS (AE_OK);
 }
@@ -487,82 +490,57 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_convert_table_facs
+ * FUNCTION:    acpi_tb_convert_table_facs
  *
- * PARAMETERS:
+ * PARAMETERS:  table_info      - Info for currently installad FACS
  *
- * RETURN:
+ * RETURN:      Status
  *
- * DESCRIPTION:
+ * DESCRIPTION: Convert ACPI 1.0 and ACPI 2.0 FACS to a common internal
+ *              table format.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_tb_build_common_facs (
-	acpi_table_desc         *table_info)
+	struct acpi_table_desc          *table_info)
 {
-	acpi_common_facs        *common_facs;
-
-#ifdef _IA64
-	facs_descriptor_rev071  *FACS71;
-#else
-	facs_descriptor_rev1    *FACS1;
-#endif
-
-	facs_descriptor_rev2    *FACS2;
 
+	ACPI_FUNCTION_TRACE ("tb_build_common_facs");
 
-	FUNCTION_TRACE ("Tb_build_common_facs");
 
+	/* Absolute minimum length is 24, but the ACPI spec says 64 */
 
-	/* Allocate a common FACS */
-
-	common_facs = ACPI_MEM_CALLOCATE (sizeof (acpi_common_facs));
-	if (!common_facs) {
-		return_ACPI_STATUS (AE_NO_MEMORY);
+	if (acpi_gbl_FACS->length < 24) {
+		ACPI_REPORT_ERROR (("Invalid FACS table length: 0x%X\n", acpi_gbl_FACS->length));
+		return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
 	}
 
+	if (acpi_gbl_FACS->length < 64) {
+		ACPI_REPORT_WARNING (("FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n",
+			acpi_gbl_FACS->length));
+	}
 
 	/* Copy fields to the new FACS */
 
-	if (acpi_gbl_RSDP->revision < 2) {
-#ifdef _IA64
-		/* 0.71 FACS */
-
-		FACS71 = (facs_descriptor_rev071 *) acpi_gbl_FACS;
-
-		common_facs->global_lock = (u32 *) &(FACS71->global_lock);
-		common_facs->firmware_waking_vector = &FACS71->firmware_waking_vector;
-		common_facs->vector_width = 64;
-#else
-		/* ACPI 1.0 FACS */
-
-		FACS1 = (facs_descriptor_rev1 *) acpi_gbl_FACS;
-
-		common_facs->global_lock = &(FACS1->global_lock);
-		common_facs->firmware_waking_vector = (u64 *) &FACS1->firmware_waking_vector;
-		common_facs->vector_width = 32;
+	acpi_gbl_common_fACS.global_lock = &(acpi_gbl_FACS->global_lock);
 
-#endif
-	}
+	if ((acpi_gbl_RSDP->revision < 2) ||
+		(acpi_gbl_FACS->length < 32) ||
+		(!(acpi_gbl_FACS->xfirmware_waking_vector))) {
+		/* ACPI 1.0 FACS or short table or optional X_ field is zero */
 
+		acpi_gbl_common_fACS.firmware_waking_vector = ACPI_CAST_PTR (u64, &(acpi_gbl_FACS->firmware_waking_vector));
+		acpi_gbl_common_fACS.vector_width = 32;
+	}
 	else {
-		/* ACPI 2.0 FACS */
+		/* ACPI 2.0 FACS with valid X_ field */
 
-		FACS2 = (facs_descriptor_rev2 *) acpi_gbl_FACS;
-
-		common_facs->global_lock = &(FACS2->global_lock);
-		common_facs->firmware_waking_vector = &FACS2->Xfirmware_waking_vector;
-		common_facs->vector_width = 64;
+		acpi_gbl_common_fACS.firmware_waking_vector = &acpi_gbl_FACS->xfirmware_waking_vector;
+		acpi_gbl_common_fACS.vector_width = 64;
 	}
 
-
-	/* Set the global FACS pointer to point to the common FACS */
-
-
-	acpi_gbl_FACS = common_facs;
-
-	return_ACPI_STATUS  (AE_OK);
+	return_ACPI_STATUS (AE_OK);
 }
 
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/tables/tbget.c linux-2.4.22-pre2/drivers/acpi/tables/tbget.c
--- linux-2.4.21/drivers/acpi/tables/tbget.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/tables/tbget.c	2003-06-26 21:43:29.000000000 +0000
@@ -1,754 +1,492 @@
 /******************************************************************************
  *
  * Module Name: tbget - ACPI Table get* routines
- *              $Revision: 56 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "achware.h"
-#include "actables.h"
+#include <acpi/acpi.h>
+#include <acpi/actables.h>
 
 
 #define _COMPONENT          ACPI_TABLES
-	 MODULE_NAME         ("tbget")
-
-#define RSDP_CHECKSUM_LENGTH 20
+	 ACPI_MODULE_NAME    ("tbget")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_get_table_ptr
+ * FUNCTION:    acpi_tb_get_table
  *
- * PARAMETERS:  Table_type      - one of the defined table types
- *              Instance        - Which table of this type
- *              Table_ptr_loc   - pointer to location to place the pointer for
- *                                return
+ * PARAMETERS:  Address             - Address of table to retrieve.  Can be
+ *                                    Logical or Physical
+ *              table_info          - Where table info is returned
  *
- * RETURN:      Status
+ * RETURN:      None
  *
- * DESCRIPTION: This function is called to get the pointer to an ACPI table.
+ * DESCRIPTION: Get entire table of unknown size.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_tb_get_table_ptr (
-	acpi_table_type         table_type,
-	u32                     instance,
-	acpi_table_header       **table_ptr_loc)
+acpi_tb_get_table (
+	struct acpi_pointer             *address,
+	struct acpi_table_desc          *table_info)
 {
-	acpi_table_desc         *table_desc;
-	u32                     i;
-
-
-	FUNCTION_TRACE ("Tb_get_table_ptr");
-
+	acpi_status                     status;
+	struct acpi_table_header        header;
 
-	if (!acpi_gbl_DSDT) {
-		return_ACPI_STATUS (AE_NO_ACPI_TABLES);
-	}
 
-	if (table_type > ACPI_TABLE_MAX) {
-		return_ACPI_STATUS (AE_BAD_PARAMETER);
-	}
+	ACPI_FUNCTION_TRACE ("tb_get_table");
 
 
 	/*
-	 * For all table types (Single/Multiple), the first
-	 * instance is always in the list head.
+	 * Get the header in order to get signature and table size
 	 */
-	if (instance == 1) {
-		/*
-		 * Just pluck the pointer out of the global table!
-		 * Will be null if no table is present
-		 */
-		*table_ptr_loc = acpi_gbl_acpi_tables[table_type].pointer;
-		return_ACPI_STATUS (AE_OK);
+	status = acpi_tb_get_table_header (address, &header);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
 	}
 
+	/* Get the entire table */
 
-	/*
-	 * Check for instance out of range
-	 */
-	if (instance > acpi_gbl_acpi_tables[table_type].count) {
-		return_ACPI_STATUS (AE_NOT_EXIST);
-	}
-
-	/* Walk the list to get the desired table
-	 * Since the if (Instance == 1) check above checked for the
-	 * first table, setting Table_desc equal to the .Next member
-	 * is actually pointing to the second table.  Therefore, we
-	 * need to walk from the 2nd table until we reach the Instance
-	 * that the user is looking for and return its table pointer.
-	 */
-	table_desc = acpi_gbl_acpi_tables[table_type].next;
-	for (i = 2; i < instance; i++) {
-		table_desc = table_desc->next;
+	status = acpi_tb_get_table_body (address, &header, table_info);
+	if (ACPI_FAILURE (status)) {
+		ACPI_REPORT_ERROR (("Could not get ACPI table (size %X), %s\n",
+			header.length, acpi_format_exception (status)));
+		return_ACPI_STATUS (status);
 	}
 
-	/* We are now pointing to the requested table's descriptor */
-
-	*table_ptr_loc = table_desc->pointer;
-
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_get_table
+ * FUNCTION:    acpi_tb_get_table_header
  *
- * PARAMETERS:  Physical_address        - Physical address of table to retrieve
- *              *Buffer_ptr             - If Buffer_ptr is valid, read data from
- *                                         buffer rather than searching memory
- *              *Table_info             - Where the table info is returned
+ * PARAMETERS:  Address             - Address of table to retrieve.  Can be
+ *                                    Logical or Physical
+ *              return_header       - Where the table header is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Maps the physical address of table into a logical address
+ * DESCRIPTION: Get an ACPI table header.  Works in both physical or virtual
+ *              addressing mode.  Works with both physical or logical pointers.
+ *              Table is either copied or mapped, depending on the pointer
+ *              type and mode of the processor.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_tb_get_table (
-	ACPI_PHYSICAL_ADDRESS   physical_address,
-	acpi_table_header       *buffer_ptr,
-	acpi_table_desc         *table_info)
+acpi_tb_get_table_header (
+	struct acpi_pointer             *address,
+	struct acpi_table_header        *return_header)
 {
-	acpi_table_header       *table_header = NULL;
-	acpi_table_header       *full_table = NULL;
-	u32                     size;
-	u8                      allocation;
-	acpi_status             status = AE_OK;
-
-
-	FUNCTION_TRACE ("Tb_get_table");
-
-
-	if (!table_info) {
-		return_ACPI_STATUS (AE_BAD_PARAMETER);
-	}
-
-
-	if (buffer_ptr) {
-		/*
-		 * Getting data from a buffer, not BIOS tables
-		 */
-		table_header = buffer_ptr;
-		status = acpi_tb_validate_table_header (table_header);
-		if (ACPI_FAILURE (status)) {
-			/* Table failed verification, map all errors to BAD_DATA */
+	acpi_status                     status = AE_OK;
+	struct acpi_table_header        *header = NULL;
 
-			return_ACPI_STATUS (AE_BAD_DATA);
-		}
 
-		/* Allocate buffer for the entire table */
+	ACPI_FUNCTION_TRACE ("tb_get_table_header");
 
-		full_table = ACPI_MEM_ALLOCATE (table_header->length);
-		if (!full_table) {
-			return_ACPI_STATUS (AE_NO_MEMORY);
-		}
 
-		/* Copy the entire table (including header) to the local buffer */
+	/*
+	 * Flags contains the current processor mode (Virtual or Physical addressing)
+	 * The pointer_type is either Logical or Physical
+	 */
+	switch (address->pointer_type) {
+	case ACPI_PHYSMODE_PHYSPTR:
+	case ACPI_LOGMODE_LOGPTR:
 
-		size = table_header->length;
-		MEMCPY (full_table, buffer_ptr, size);
+		/* Pointer matches processor mode, copy the header */
 
-		/* Save allocation type */
+		ACPI_MEMCPY (return_header, address->pointer.logical, sizeof (struct acpi_table_header));
+		break;
 
-		allocation = ACPI_MEM_ALLOCATED;
-	}
 
+	case ACPI_LOGMODE_PHYSPTR:
 
-	/*
-	 * Not reading from a buffer, just map the table's physical memory
-	 * into our address space.
-	 */
-	else {
-		size = SIZE_IN_HEADER;
+		/* Create a logical address for the physical pointer*/
 
-		status = acpi_tb_map_acpi_table (physical_address, &size, &full_table);
+		status = acpi_os_map_memory (address->pointer.physical, sizeof (struct acpi_table_header),
+				  (void **) &header);
 		if (ACPI_FAILURE (status)) {
+			ACPI_REPORT_ERROR (("Could not map memory at %8.8X%8.8X for length %X\n",
+				ACPI_HIDWORD (address->pointer.physical),
+				ACPI_LODWORD (address->pointer.physical),
+				sizeof (struct acpi_table_header)));
 			return_ACPI_STATUS (status);
 		}
 
-		/* Save allocation type */
+		/* Copy header and delete mapping */
 
-		allocation = ACPI_MEM_MAPPED;
-	}
+		ACPI_MEMCPY (return_header, header, sizeof (struct acpi_table_header));
+		acpi_os_unmap_memory (header, sizeof (struct acpi_table_header));
+		break;
 
 
-	/* Return values */
+	default:
 
-	table_info->pointer     = full_table;
-	table_info->length      = size;
-	table_info->allocation  = allocation;
-	table_info->base_pointer = full_table;
+		ACPI_REPORT_ERROR (("Invalid address flags %X\n",
+			address->pointer_type));
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	}
 
-	return_ACPI_STATUS (status);
+	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_get_all_tables
+ * FUNCTION:    acpi_tb_get_table_body
  *
- * PARAMETERS:  Number_of_tables    - Number of tables to get
- *              Table_ptr           - Input buffer pointer, optional
+ * PARAMETERS:  Address             - Address of table to retrieve.  Can be
+ *                                    Logical or Physical
+ *              Header              - Header of the table to retrieve
+ *              table_info          - Where the table info is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Load and validate all tables other than the RSDT.  The RSDT must
- *              already be loaded and validated.
+ * DESCRIPTION: Get an entire ACPI table with support to allow the host OS to
+ *              replace the table with a newer version (table override.)
+ *              Works in both physical or virtual
+ *              addressing mode.  Works with both physical or logical pointers.
+ *              Table is either copied or mapped, depending on the pointer
+ *              type and mode of the processor.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_tb_get_all_tables (
-	u32                     number_of_tables,
-	acpi_table_header       *table_ptr)
+acpi_tb_get_table_body (
+	struct acpi_pointer             *address,
+	struct acpi_table_header        *header,
+	struct acpi_table_desc          *table_info)
 {
-	acpi_status             status = AE_OK;
-	u32                     index;
-	acpi_table_desc         table_info;
-
-
-	FUNCTION_TRACE ("Tb_get_all_tables");
+	acpi_status                     status;
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Number of tables: %d\n", number_of_tables));
 
+	ACPI_FUNCTION_TRACE ("tb_get_table_body");
 
-	/*
-	 * Loop through all table pointers found in RSDT.
-	 * This will NOT include the FACS and DSDT - we must get
-	 * them after the loop
-	 */
-	for (index = 0; index < number_of_tables; index++) {
-		/* Clear the Table_info each time */
-
-		MEMSET (&table_info, 0, sizeof (acpi_table_desc));
-
-		/* Get the table via the XSDT */
-
-		status = acpi_tb_get_table ((ACPI_PHYSICAL_ADDRESS)
-				 ACPI_GET_ADDRESS (acpi_gbl_XSDT->table_offset_entry[index]),
-				 table_ptr, &table_info);
-
-		/* Ignore a table that failed verification */
-
-		if (status == AE_BAD_DATA) {
-			continue;
-		}
-
-		/* However, abort on serious errors */
-
-		if (ACPI_FAILURE (status)) {
-			return_ACPI_STATUS (status);
-		}
-
-		/* Recognize and install the table */
-
-		status = acpi_tb_install_table (table_ptr, &table_info);
-		if (ACPI_FAILURE (status)) {
-			/*
-			 * Unrecognized or unsupported table, delete it and ignore the
-			 * error.  Just get as many tables as we can, later we will
-			 * determine if there are enough tables to continue.
-			 */
-			acpi_tb_uninstall_table (&table_info);
-		}
-	}
-
-
-	/*
-	 * Convert the FADT to a common format.  This allows earlier revisions of the
-	 * table to coexist with newer versions, using common access code.
-	 */
-	status = acpi_tb_convert_table_fadt ();
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
-
-
-	/*
-	 * Get the minimum set of ACPI tables, namely:
-	 *
-	 * 1) FADT (via RSDT in loop above)
-	 * 2) FACS
-	 * 3) DSDT
-	 *
-	 */
-
-	/*
-	 * Get the FACS (must have the FADT first, from loop above)
-	 * Acpi_tb_get_table_facs will fail if FADT pointer is not valid
-	 */
-	status = acpi_tb_get_table_facs (table_ptr, &table_info);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
-
-	/* Install the FACS */
-
-	status = acpi_tb_install_table (table_ptr, &table_info);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
 
-	/*
-	 * Create the common FACS pointer table
-	 * (Contains pointers to the original table)
-	 */
-	status = acpi_tb_build_common_facs (&table_info);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
+	if (!table_info || !address) {
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-
 	/*
-	 * Get the DSDT (We know that the FADT is valid now)
+	 * Attempt table override.
 	 */
-	status = acpi_tb_get_table ((ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (acpi_gbl_FADT->Xdsdt),
-			  table_ptr, &table_info);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
-
-	/* Install the DSDT */
+	status = acpi_tb_table_override (header, table_info);
+	if (ACPI_SUCCESS (status)) {
+		/* Table was overridden by the host OS */
 
-	status = acpi_tb_install_table (table_ptr, &table_info);
-	if (ACPI_FAILURE (status)) {
 		return_ACPI_STATUS (status);
 	}
 
-	/* Dump the DSDT Header */
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Hex dump of DSDT Header:\n"));
-	DUMP_BUFFER ((u8 *) acpi_gbl_DSDT, sizeof (acpi_table_header));
-
-	/* Dump the entire DSDT */
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_TABLES,
-		"Hex dump of DSDT (After header), size %d (%x)\n",
-		acpi_gbl_DSDT->length, acpi_gbl_DSDT->length));
-	DUMP_BUFFER ((u8 *) (acpi_gbl_DSDT + 1), acpi_gbl_DSDT->length);
-
-	/*
-	 * Initialize the capabilities flags.
-	 * Assumes that platform supports ACPI_MODE since we have tables!
-	 */
-	acpi_gbl_system_flags |= acpi_hw_get_mode_capabilities ();
-
-
-	/* Always delete the RSDP mapping, we are done with it */
-
-	acpi_tb_delete_acpi_table (ACPI_TABLE_RSDP);
+	/* No override, get the original table */
 
+	status = acpi_tb_get_this_table (address, header, table_info);
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_verify_rsdp
+ * FUNCTION:    acpi_tb_table_override
  *
- * PARAMETERS:  Number_of_tables    - Where the table count is placed
+ * PARAMETERS:  Header              - Pointer to table header
+ *              table_info          - Return info if table is overridden
  *
- * RETURN:      Status
+ * RETURN:      None
  *
- * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table)
+ * DESCRIPTION: Attempts override of current table with a new one if provided
+ *              by the host OS.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_tb_verify_rsdp (
-	ACPI_PHYSICAL_ADDRESS   rsdp_physical_address)
+acpi_tb_table_override (
+	struct acpi_table_header        *header,
+	struct acpi_table_desc          *table_info)
 {
-	acpi_table_desc         table_info;
-	acpi_status             status;
-	u8                      *table_ptr;
+	struct acpi_table_header        *new_table;
+	acpi_status                     status;
+	struct acpi_pointer             address;
 
 
-	FUNCTION_TRACE ("Tb_verify_rsdp");
+	ACPI_FUNCTION_TRACE ("tb_table_override");
 
 
 	/*
-	 * Obtain access to the RSDP structure
+	 * The OSL will examine the header and decide whether to override this
+	 * table.  If it decides to override, a table will be returned in new_table,
+	 * which we will then copy.
 	 */
-	status = acpi_os_map_memory (rsdp_physical_address, sizeof (RSDP_DESCRIPTOR),
-			  (void **) &table_ptr);
+	status = acpi_os_table_override (header, &new_table);
 	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
-
-	/*
-	 *  The signature and checksum must both be correct
-	 */
-	if (STRNCMP ((NATIVE_CHAR *) table_ptr, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) {
-		/* Nope, BAD Signature */
+		/* Some severe error from the OSL, but we basically ignore it */
 
-		status = AE_BAD_SIGNATURE;
-		goto cleanup;
+		ACPI_REPORT_ERROR (("Could not override ACPI table, %s\n",
+			acpi_format_exception (status)));
+		return_ACPI_STATUS (status);
 	}
 
-	if (acpi_tb_checksum (table_ptr, RSDP_CHECKSUM_LENGTH) != 0) {
-		/* Nope, BAD Checksum */
+	if (!new_table) {
+		/* No table override */
 
-		status = AE_BAD_CHECKSUM;
-		goto cleanup;
+		return_ACPI_STATUS (AE_NO_ACPI_TABLES);
 	}
 
-	/* TBD: Check extended checksum if table version >= 2 */
-
-	/* The RSDP supplied is OK */
-
-	table_info.pointer     = (acpi_table_header *) table_ptr;
-	table_info.length      = sizeof (RSDP_DESCRIPTOR);
-	table_info.allocation  = ACPI_MEM_MAPPED;
-	table_info.base_pointer = table_ptr;
-
-	/* Save the table pointers and allocation info */
+	/*
+	 * We have a new table to override the old one.  Get a copy of
+	 * the new one.  We know that the new table has a logical pointer.
+	 */
+	address.pointer_type    = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING;
+	address.pointer.logical = new_table;
 
-	status = acpi_tb_init_table_descriptor (ACPI_TABLE_RSDP, &table_info);
+	status = acpi_tb_get_this_table (&address, new_table, table_info);
 	if (ACPI_FAILURE (status)) {
-		goto cleanup;
+		ACPI_REPORT_ERROR (("Could not copy override ACPI table, %s\n",
+			acpi_format_exception (status)));
+		return_ACPI_STATUS (status);
 	}
 
+	/* Copy the table info */
 
-	/* Save the RSDP in a global for easy access */
-
-	acpi_gbl_RSDP = (RSDP_DESCRIPTOR *) table_info.pointer;
-	return_ACPI_STATUS (status);
-
-
-	/* Error exit */
-cleanup:
+	ACPI_REPORT_INFO (("Table [%4.4s] replaced by host OS\n",
+		table_info->pointer->signature));
 
-	acpi_os_unmap_memory (table_ptr, sizeof (RSDP_DESCRIPTOR));
-	return_ACPI_STATUS (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_tb_get_rsdt_address
- *
- * PARAMETERS:  None
- *
- * RETURN:      RSDT physical address
- *
- * DESCRIPTION: Extract the address of the RSDT or XSDT, depending on the
- *              version of the RSDP
- *
- ******************************************************************************/
-
-ACPI_PHYSICAL_ADDRESS
-acpi_tb_get_rsdt_address (void)
-{
-	ACPI_PHYSICAL_ADDRESS   physical_address;
-
-
-	FUNCTION_ENTRY ();
-
-
-	/*
-	 * For RSDP revision 0 or 1, we use the RSDT.
-	 * For RSDP revision 2 (and above), we use the XSDT
-	 */
-	if (acpi_gbl_RSDP->revision < 2) {
-#ifdef _IA64
-		/* 0.71 RSDP has 64bit Rsdt address field */
-		physical_address = ((RSDP_DESCRIPTOR_REV071 *)acpi_gbl_RSDP)->rsdt_physical_address;
-#else
-		physical_address = (ACPI_PHYSICAL_ADDRESS) acpi_gbl_RSDP->rsdt_physical_address;
-#endif
-	}
-
-	else {
-		physical_address = (ACPI_PHYSICAL_ADDRESS)
-				   ACPI_GET_ADDRESS (acpi_gbl_RSDP->xsdt_physical_address);
-	}
-
-	return (physical_address);
+	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_validate_rsdt
+ * FUNCTION:    acpi_tb_get_this_table
  *
- * PARAMETERS:  Table_ptr       - Addressable pointer to the RSDT.
+ * PARAMETERS:  Address             - Address of table to retrieve.  Can be
+ *                                    Logical or Physical
+ *              Header              - Header of the table to retrieve
+ *              table_info          - Where the table info is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Validate signature for the RSDT or XSDT
+ * DESCRIPTION: Get an entire ACPI table.  Works in both physical or virtual
+ *              addressing mode.  Works with both physical or logical pointers.
+ *              Table is either copied or mapped, depending on the pointer
+ *              type and mode of the processor.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_tb_validate_rsdt (
-	acpi_table_header       *table_ptr)
+acpi_tb_get_this_table (
+	struct acpi_pointer             *address,
+	struct acpi_table_header        *header,
+	struct acpi_table_desc          *table_info)
 {
-	u32                     no_match;
+	struct acpi_table_header        *full_table = NULL;
+	u8                              allocation;
+	acpi_status                     status = AE_OK;
 
 
-	PROC_NAME ("Tb_validate_rsdt");
+	ACPI_FUNCTION_TRACE ("tb_get_this_table");
 
 
 	/*
-	 * For RSDP revision 0 or 1, we use the RSDT.
-	 * For RSDP revision 2 (and above), we use the XSDT
+	 * Flags contains the current processor mode (Virtual or Physical addressing)
+	 * The pointer_type is either Logical or Physical
 	 */
-	if (acpi_gbl_RSDP->revision < 2) {
-		no_match = STRNCMP ((char *) table_ptr, RSDT_SIG,
-				  sizeof (RSDT_SIG) -1);
-	}
-	else {
-		no_match = STRNCMP ((char *) table_ptr, XSDT_SIG,
-				  sizeof (XSDT_SIG) -1);
-	}
-
-
-	if (no_match) {
-		/* Invalid RSDT or XSDT signature */
-
-		REPORT_ERROR (("Invalid signature where RSDP indicates RSDT/XSDT should be located\n"));
-
-		DUMP_BUFFER (acpi_gbl_RSDP, 20);
-
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR,
-			"RSDT/XSDT signature at %X is invalid\n",
-			acpi_gbl_RSDP->rsdt_physical_address));
-
-		return (AE_BAD_SIGNATURE);
-	}
-
-	return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_tb_get_table_pointer
- *
- * PARAMETERS:  Physical_address    - Address from RSDT
- *              Flags               - virtual or physical addressing
- *              Table_ptr           - Addressable address (output)
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Create an addressable pointer to an ACPI table
- *
- ******************************************************************************/
-
-acpi_status
-acpi_tb_get_table_pointer (
-	ACPI_PHYSICAL_ADDRESS   physical_address,
-	u32                     flags,
-	u32                     *size,
-	acpi_table_header       **table_ptr)
-{
-	acpi_status             status;
-
-
-	FUNCTION_ENTRY ();
-
-
-	if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) {
-		*size = SIZE_IN_HEADER;
-		status = acpi_tb_map_acpi_table (physical_address, size, table_ptr);
-	}
-
-	else {
-		*size = 0;
-		*table_ptr = (acpi_table_header *) (ACPI_TBLPTR) physical_address;
-
-		status = AE_OK;
-	}
-
-	return (status);
-}
-
+	switch (address->pointer_type) {
+	case ACPI_PHYSMODE_PHYSPTR:
+	case ACPI_LOGMODE_LOGPTR:
 
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_tb_get_table_rsdt
- *
- * PARAMETERS:  Number_of_tables    - Where the table count is placed
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table)
- *
- ******************************************************************************/
+		/* Pointer matches processor mode, copy the table to a new buffer */
 
-acpi_status
-acpi_tb_get_table_rsdt (
-	u32                     *number_of_tables)
-{
-	acpi_table_desc         table_info;
-	acpi_status             status;
-	ACPI_PHYSICAL_ADDRESS   physical_address;
+		full_table = ACPI_MEM_ALLOCATE (header->length);
+		if (!full_table) {
+			ACPI_REPORT_ERROR (("Could not allocate table memory for [%4.4s] length %X\n",
+				header->signature, header->length));
+			return_ACPI_STATUS (AE_NO_MEMORY);
+		}
 
+		/* Copy the entire table (including header) to the local buffer */
 
-	FUNCTION_TRACE ("Tb_get_table_rsdt");
+		ACPI_MEMCPY (full_table, address->pointer.logical, header->length);
 
+		/* Save allocation type */
 
-	/*
-	 * Get the RSDT from the RSDP
-	 */
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-		"RSDP located at %p, RSDT physical=%8.8X%8.8X \n",
-		acpi_gbl_RSDP, HIDWORD(acpi_gbl_RSDP->rsdt_physical_address),
-		LODWORD(acpi_gbl_RSDP->rsdt_physical_address)));
+		allocation = ACPI_MEM_ALLOCATED;
+		break;
 
 
-	physical_address = acpi_tb_get_rsdt_address ();
+	case ACPI_LOGMODE_PHYSPTR:
 
+		/*
+		 * Just map the table's physical memory
+		 * into our address space.
+		 */
+		status = acpi_os_map_memory (address->pointer.physical, (acpi_size) header->length,
+				  (void **) &full_table);
+		if (ACPI_FAILURE (status)) {
+			ACPI_REPORT_ERROR (("Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X\n",
+				header->signature,
+				ACPI_HIDWORD (address->pointer.physical),
+				ACPI_LODWORD (address->pointer.physical), header->length));
+			return (status);
+		}
 
-	/* Get the RSDT/XSDT */
+		/* Save allocation type */
 
-	status = acpi_tb_get_table (physical_address, NULL, &table_info);
-	if (ACPI_FAILURE (status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not get the RSDT, %s\n",
-			acpi_format_exception (status)));
-		return_ACPI_STATUS (status);
-	}
+		allocation = ACPI_MEM_MAPPED;
+		break;
 
 
-	/* Check the RSDT or XSDT signature */
+	default:
 
-	status = acpi_tb_validate_rsdt (table_info.pointer);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid address flags %X\n",
+			address->pointer_type));
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-
 	/*
-	 * Valid RSDT signature, verify the checksum.  If it fails, just
-	 * print a warning and ignore it.
+	 * Validate checksum for _most_ tables,
+	 * even the ones whose signature we don't recognize
 	 */
-	status = acpi_tb_verify_table_checksum (table_info.pointer);
+	if (table_info->type != ACPI_TABLE_FACS) {
+		status = acpi_tb_verify_table_checksum (full_table);
 
+#if (!ACPI_CHECKSUM_ABORT)
+		if (ACPI_FAILURE (status)) {
+			/* Ignore the error if configuration says so */
 
-	/* Convert and/or copy to an XSDT structure */
-
-	status = acpi_tb_convert_to_xsdt (&table_info, number_of_tables);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
+			status = AE_OK;
+		}
+#endif
 	}
 
-	/* Save the table pointers and allocation info */
-
-	status = acpi_tb_init_table_descriptor (ACPI_TABLE_XSDT, &table_info);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
+	/* Return values */
 
-	acpi_gbl_XSDT = (xsdt_descriptor *) table_info.pointer;
+	table_info->pointer     = full_table;
+	table_info->length      = (acpi_size) header->length;
+	table_info->allocation  = allocation;
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "XSDT located at %p\n", acpi_gbl_XSDT));
+	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+		"Found table [%4.4s] at %8.8X%8.8X, mapped/copied to %p\n",
+		full_table->signature,
+		ACPI_HIDWORD (address->pointer.physical),
+		ACPI_LODWORD (address->pointer.physical), full_table));
 
 	return_ACPI_STATUS (status);
 }
 
 
-/******************************************************************************
+/*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_get_table_facs
+ * FUNCTION:    acpi_tb_get_table_ptr
  *
- * PARAMETERS:  *Buffer_ptr             - If Buffer_ptr is valid, read data from
- *                                        buffer rather than searching memory
- *              *Table_info             - Where the table info is returned
+ * PARAMETERS:  table_type      - one of the defined table types
+ *              Instance        - Which table of this type
+ *              table_ptr_loc   - pointer to location to place the pointer for
+ *                                return
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Returns a pointer to the FACS as defined in FADT.  This
- *              function assumes the global variable FADT has been
- *              correctly initialized.  The value of FADT->Firmware_ctrl
- *              into a far pointer which is returned.
+ * DESCRIPTION: This function is called to get the pointer to an ACPI table.
  *
- *****************************************************************************/
+ ******************************************************************************/
 
 acpi_status
-acpi_tb_get_table_facs (
-	acpi_table_header       *buffer_ptr,
-	acpi_table_desc         *table_info)
+acpi_tb_get_table_ptr (
+	acpi_table_type                 table_type,
+	u32                             instance,
+	struct acpi_table_header        **table_ptr_loc)
 {
-	acpi_table_header       *table_ptr = NULL;
-	u32                     size;
-	u8                      allocation;
-	acpi_status             status = AE_OK;
+	struct acpi_table_desc          *table_desc;
+	u32                             i;
 
 
-	FUNCTION_TRACE ("Tb_get_table_facs");
+	ACPI_FUNCTION_TRACE ("tb_get_table_ptr");
 
 
-	/* Must have a valid FADT pointer */
-
-	if (!acpi_gbl_FADT) {
+	if (!acpi_gbl_DSDT) {
 		return_ACPI_STATUS (AE_NO_ACPI_TABLES);
 	}
 
-	size = sizeof (FACS_DESCRIPTOR);
-	if (buffer_ptr) {
-		/*
-		 * Getting table from a file -- allocate a buffer and
-		 * read the table.
-		 */
-		table_ptr = ACPI_MEM_ALLOCATE (size);
-		if(!table_ptr) {
-			return_ACPI_STATUS (AE_NO_MEMORY);
-		}
-
-		MEMCPY (table_ptr, buffer_ptr, size);
-
-		/* Save allocation type */
-
-		allocation = ACPI_MEM_ALLOCATED;
+	if (table_type > ACPI_TABLE_MAX) {
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-	else {
-		/* Just map the physical memory to our address space */
+	/*
+	 * For all table types (Single/Multiple), the first
+	 * instance is always in the list head.
+	 */
+	if (instance == 1) {
+		/* Get the first */
 
-		status = acpi_tb_map_acpi_table ((ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (acpi_gbl_FADT->Xfirmware_ctrl),
-				   &size, &table_ptr);
-		if (ACPI_FAILURE (status)) {
-			return_ACPI_STATUS (status);
+		if (acpi_gbl_table_lists[table_type].next) {
+			*table_ptr_loc = acpi_gbl_table_lists[table_type].next->pointer;
 		}
+		return_ACPI_STATUS (AE_OK);
+	}
 
-		/* Save allocation type */
-
-		allocation = ACPI_MEM_MAPPED;
+	/*
+	 * Check for instance out of range
+	 */
+	if (instance > acpi_gbl_table_lists[table_type].count) {
+		return_ACPI_STATUS (AE_NOT_EXIST);
 	}
 
+	/* Walk the list to get the desired table
+	 * Since the if (Instance == 1) check above checked for the
+	 * first table, setting table_desc equal to the .Next member
+	 * is actually pointing to the second table.  Therefore, we
+	 * need to walk from the 2nd table until we reach the Instance
+	 * that the user is looking for and return its table pointer.
+	 */
+	table_desc = acpi_gbl_table_lists[table_type].next;
+	for (i = 2; i < instance; i++) {
+		table_desc = table_desc->next;
+	}
 
-	/* Return values */
+	/* We are now pointing to the requested table's descriptor */
 
-	table_info->pointer     = table_ptr;
-	table_info->length      = size;
-	table_info->allocation  = allocation;
-	table_info->base_pointer = table_ptr;
+	*table_ptr_loc = table_desc->pointer;
 
-	return_ACPI_STATUS (status);
+	return_ACPI_STATUS (AE_OK);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/tables/tbgetall.c linux-2.4.22-pre2/drivers/acpi/tables/tbgetall.c
--- linux-2.4.21/drivers/acpi/tables/tbgetall.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/tables/tbgetall.c	2003-06-26 21:43:10.000000000 +0000
@@ -0,0 +1,314 @@
+/******************************************************************************
+ *
+ * Module Name: tbgetall - Get all required ACPI tables
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+
+#include <acpi/acpi.h>
+#include <acpi/actables.h>
+
+
+#define _COMPONENT          ACPI_TABLES
+	 ACPI_MODULE_NAME    ("tbgetall")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_tb_get_primary_table
+ *
+ * PARAMETERS:  Address             - Physical address of table to retrieve
+ *              *table_info         - Where the table info is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Maps the physical address of table into a logical address
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_tb_get_primary_table (
+	struct acpi_pointer             *address,
+	struct acpi_table_desc          *table_info)
+{
+	acpi_status                     status;
+	struct acpi_table_header        header;
+
+
+	ACPI_FUNCTION_TRACE ("tb_get_primary_table");
+
+
+	/* Ignore a NULL address in the RSDT */
+
+	if (!address->pointer.value) {
+		return_ACPI_STATUS (AE_OK);
+	}
+
+	/*
+	 * Get the header in order to get signature and table size
+	 */
+	status = acpi_tb_get_table_header (address, &header);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/* Clear the table_info */
+
+	ACPI_MEMSET (table_info, 0, sizeof (struct acpi_table_desc));
+
+	/*
+	 * Check the table signature and make sure it is recognized.
+	 * Also checks the header checksum
+	 */
+	table_info->pointer = &header;
+	status = acpi_tb_recognize_table (table_info, ACPI_TABLE_PRIMARY);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/* Get the entire table */
+
+	status = acpi_tb_get_table_body (address, &header, table_info);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/* Install the table */
+
+	status = acpi_tb_install_table (table_info);
+	return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_tb_get_secondary_table
+ *
+ * PARAMETERS:  Address             - Physical address of table to retrieve
+ *              *table_info         - Where the table info is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Maps the physical address of table into a logical address
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_tb_get_secondary_table (
+	struct acpi_pointer             *address,
+	acpi_string                     signature,
+	struct acpi_table_desc          *table_info)
+{
+	acpi_status                     status;
+	struct acpi_table_header        header;
+
+
+	ACPI_FUNCTION_TRACE_STR ("tb_get_secondary_table", signature);
+
+
+	/* Get the header in order to match the signature */
+
+	status = acpi_tb_get_table_header (address, &header);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/* Signature must match request */
+
+	if (ACPI_STRNCMP (header.signature, signature, ACPI_NAME_SIZE)) {
+		ACPI_REPORT_ERROR (("Incorrect table signature - wanted [%s] found [%4.4s]\n",
+			signature, header.signature));
+		return_ACPI_STATUS (AE_BAD_SIGNATURE);
+	}
+
+	/*
+	 * Check the table signature and make sure it is recognized.
+	 * Also checks the header checksum
+	 */
+	table_info->pointer = &header;
+	status = acpi_tb_recognize_table (table_info, ACPI_TABLE_SECONDARY);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/* Get the entire table */
+
+	status = acpi_tb_get_table_body (address, &header, table_info);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/* Install the table */
+
+	status = acpi_tb_install_table (table_info);
+	return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_tb_get_required_tables
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Load and validate tables other than the RSDT.  The RSDT must
+ *              already be loaded and validated.
+ *
+ *              Get the minimum set of ACPI tables, namely:
+ *
+ *              1) FADT (via RSDT in loop below)
+ *              2) FACS (via FADT)
+ *              3) DSDT (via FADT)
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_tb_get_required_tables (
+	void)
+{
+	acpi_status                     status = AE_OK;
+	u32                             i;
+	struct acpi_table_desc          table_info;
+	struct acpi_pointer             address;
+
+
+	ACPI_FUNCTION_TRACE ("tb_get_required_tables");
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%d ACPI tables in RSDT\n",
+		acpi_gbl_rsdt_table_count));
+
+
+	address.pointer_type  = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING;
+
+	/*
+	 * Loop through all table pointers found in RSDT.
+	 * This will NOT include the FACS and DSDT - we must get
+	 * them after the loop.
+	 *
+	 * The only tables we are interested in getting here is the FADT and
+	 * any SSDTs.
+	 */
+	for (i = 0; i < acpi_gbl_rsdt_table_count; i++) {
+		/* Get the table address from the common internal XSDT */
+
+		address.pointer.value = acpi_gbl_XSDT->table_offset_entry[i];
+
+		/*
+		 * Get the tables needed by this subsystem (FADT and any SSDTs).
+		 * NOTE: All other tables are completely ignored at this time.
+		 */
+		status = acpi_tb_get_primary_table (&address, &table_info);
+		if ((status != AE_OK) && (status != AE_TABLE_NOT_SUPPORTED)) {
+			ACPI_REPORT_WARNING (("%s, while getting table at %8.8X%8.8X\n",
+				acpi_format_exception (status),
+				ACPI_HIDWORD (address.pointer.value),
+				ACPI_LODWORD (address.pointer.value)));
+		}
+	}
+
+	/* We must have a FADT to continue */
+
+	if (!acpi_gbl_FADT) {
+		ACPI_REPORT_ERROR (("No FADT present in RSDT/XSDT\n"));
+		return_ACPI_STATUS (AE_NO_ACPI_TABLES);
+	}
+
+	/*
+	 * Convert the FADT to a common format.  This allows earlier revisions of the
+	 * table to coexist with newer versions, using common access code.
+	 */
+	status = acpi_tb_convert_table_fadt ();
+	if (ACPI_FAILURE (status)) {
+		ACPI_REPORT_ERROR (("Could not convert FADT to internal common format\n"));
+		return_ACPI_STATUS (status);
+	}
+
+	/*
+	 * Get the FACS (Pointed to by the FADT)
+	 */
+	address.pointer.value = acpi_gbl_FADT->xfirmware_ctrl;
+
+	status = acpi_tb_get_secondary_table (&address, FACS_SIG, &table_info);
+	if (ACPI_FAILURE (status)) {
+		ACPI_REPORT_ERROR (("Could not get/install the FACS, %s\n",
+			acpi_format_exception (status)));
+		return_ACPI_STATUS (status);
+	}
+
+	/*
+	 * Create the common FACS pointer table
+	 * (Contains pointers to the original table)
+	 */
+	status = acpi_tb_build_common_facs (&table_info);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/*
+	 * Get/install the DSDT (Pointed to by the FADT)
+	 */
+	address.pointer.value = acpi_gbl_FADT->Xdsdt;
+
+	status = acpi_tb_get_secondary_table (&address, DSDT_SIG, &table_info);
+	if (ACPI_FAILURE (status)) {
+		ACPI_REPORT_ERROR (("Could not get/install the DSDT\n"));
+		return_ACPI_STATUS (status);
+	}
+
+	/* Set Integer Width (32/64) based upon DSDT revision */
+
+	acpi_ut_set_integer_width (acpi_gbl_DSDT->revision);
+
+	/* Dump the entire DSDT */
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_TABLES,
+		"Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n",
+		acpi_gbl_DSDT->length, acpi_gbl_DSDT->length, acpi_gbl_integer_bit_width));
+	ACPI_DUMP_BUFFER ((u8 *) acpi_gbl_DSDT, acpi_gbl_DSDT->length);
+
+	/* Always delete the RSDP mapping, we are done with it */
+
+	acpi_tb_delete_tables_by_type (ACPI_TABLE_RSDP);
+	return_ACPI_STATUS (status);
+}
+
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/tables/tbinstal.c linux-2.4.22-pre2/drivers/acpi/tables/tbinstal.c
--- linux-2.4.21/drivers/acpi/tables/tbinstal.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/tables/tbinstal.c	2003-06-26 21:43:14.000000000 +0000
@@ -1,44 +1,118 @@
 /******************************************************************************
  *
  * Module Name: tbinstal - ACPI table installation and removal
- *              $Revision: 45 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "achware.h"
-#include "actables.h"
+#include <acpi/acpi.h>
+#include <acpi/actables.h>
 
 
 #define _COMPONENT          ACPI_TABLES
-	 MODULE_NAME         ("tbinstal")
+	 ACPI_MODULE_NAME    ("tbinstal")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_install_table
+ * FUNCTION:    acpi_tb_match_signature
  *
- * PARAMETERS:  Table_ptr           - Input buffer pointer, optional
- *              Table_info          - Return value from Acpi_tb_get_table
+ * PARAMETERS:  Signature           - Table signature to match
+ *              table_info          - Return data
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Compare signature against the list of "ACPI-subsystem-owned"
+ *              tables (DSDT/FADT/SSDT, etc.) Returns the table_type_iD on match.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_tb_match_signature (
+	char                            *signature,
+	struct acpi_table_desc          *table_info,
+	u8                              search_type)
+{
+	acpi_native_uint                i;
+
+
+	ACPI_FUNCTION_TRACE ("tb_match_signature");
+
+
+	/*
+	 * Search for a signature match among the known table types
+	 */
+	for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) {
+		if (!(acpi_gbl_table_data[i].flags & search_type)) {
+			continue;
+		}
+
+		if (!ACPI_STRNCMP (signature, acpi_gbl_table_data[i].signature,
+				   acpi_gbl_table_data[i].sig_length)) {
+			/* Found a signature match, return index if requested */
+
+			if (table_info) {
+				table_info->type = (u8) i;
+			}
+
+			ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+				"Table [%4.4s] is an ACPI table consumed by the core subsystem\n",
+				(char *) acpi_gbl_table_data[i].signature));
+
+			return_ACPI_STATUS (AE_OK);
+		}
+	}
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+		"Table [%4.4s] is not an ACPI table consumed by the core subsystem - ignored\n",
+		(char *) signature));
+
+	return_ACPI_STATUS (AE_TABLE_NOT_SUPPORTED);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_tb_install_table
+ *
+ * PARAMETERS:  table_info          - Return value from acpi_tb_get_table_body
  *
  * RETURN:      Status
  *
@@ -50,45 +124,43 @@
 
 acpi_status
 acpi_tb_install_table (
-	acpi_table_header       *table_ptr,
-	acpi_table_desc         *table_info)
+	struct acpi_table_desc          *table_info)
 {
-	acpi_status             status;
+	acpi_status                     status;
 
-	FUNCTION_TRACE ("Tb_install_table");
+	ACPI_FUNCTION_TRACE ("tb_install_table");
 
 
-	/*
-	 * Check the table signature and make sure it is recognized
-	 * Also checks the header checksum
-	 */
-	status = acpi_tb_recognize_table (table_ptr, table_info);
+	/* Lock tables while installing */
+
+	status = acpi_ut_acquire_mutex (ACPI_MTX_TABLES);
 	if (ACPI_FAILURE (status)) {
+		ACPI_REPORT_ERROR (("Could not acquire table mutex for [%4.4s], %s\n",
+			table_info->pointer->signature, acpi_format_exception (status)));
 		return_ACPI_STATUS (status);
 	}
 
-	/* Lock tables while installing */
-
-	acpi_ut_acquire_mutex (ACPI_MTX_TABLES);
-
 	/* Install the table into the global data structure */
 
 	status = acpi_tb_init_table_descriptor (table_info->type, table_info);
+	if (ACPI_FAILURE (status)) {
+		ACPI_REPORT_ERROR (("Could not install ACPI table [%4.4s], %s\n",
+			table_info->pointer->signature, acpi_format_exception (status)));
+	}
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s located at %p\n",
-		acpi_gbl_acpi_table_data[table_info->type].name, table_info->pointer));
+		acpi_gbl_table_data[table_info->type].name, table_info->pointer));
 
-	acpi_ut_release_mutex (ACPI_MTX_TABLES);
+	(void) acpi_ut_release_mutex (ACPI_MTX_TABLES);
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_recognize_table
+ * FUNCTION:    acpi_tb_recognize_table
  *
- * PARAMETERS:  Table_ptr           - Input buffer pointer, optional
- *              Table_info          - Return value from Acpi_tb_get_table
+ * PARAMETERS:  table_info          - Return value from acpi_tb_get_table_body
  *
  * RETURN:      Status
  *
@@ -106,73 +178,44 @@
 
 acpi_status
 acpi_tb_recognize_table (
-	acpi_table_header       *table_ptr,
-	acpi_table_desc         *table_info)
+	struct acpi_table_desc          *table_info,
+	u8                              search_type)
 {
-	acpi_table_header       *table_header;
-	acpi_status             status;
-	acpi_table_type         table_type = 0;
-	u32                     i;
+	struct acpi_table_header        *table_header;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Tb_recognize_table");
+	ACPI_FUNCTION_TRACE ("tb_recognize_table");
 
 
 	/* Ensure that we have a valid table pointer */
 
-	table_header = (acpi_table_header *) table_info->pointer;
+	table_header = (struct acpi_table_header *) table_info->pointer;
 	if (!table_header) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
 	/*
-	 * Search for a signature match among the known table types
-	 * Start at index one -> Skip the RSDP
+	 * We only "recognize" a limited number of ACPI tables -- namely, the
+	 * ones that are used by the subsystem (DSDT, FADT, etc.)
+	 *
+	 * An AE_TABLE_NOT_SUPPORTED means that the table was not recognized.
+	 * This can be any one of many valid ACPI tables, it just isn't one of
+	 * the tables that is consumed by the core subsystem
 	 */
-	status = AE_SUPPORT;
-	for (i = 1; i < NUM_ACPI_TABLES; i++) {
-		if (!STRNCMP (table_header->signature,
-				  acpi_gbl_acpi_table_data[i].signature,
-				  acpi_gbl_acpi_table_data[i].sig_length)) {
-			/*
-			 * Found a signature match, get the pertinent info from the
-			 * Table_data structure
-			 */
-			table_type      = i;
-			status          = acpi_gbl_acpi_table_data[i].status;
-
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Found %4.4s\n",
-				(char*)acpi_gbl_acpi_table_data[i].signature));
-			break;
-		}
+	status = acpi_tb_match_signature (table_header->signature, table_info, search_type);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
 	}
 
-	/* Return the table type and length via the info struct */
-
-	table_info->type    = (u8) table_type;
-	table_info->length  = table_header->length;
-
-
-	/*
-	 * Validate checksum for _most_ tables,
-	 * even the ones whose signature we don't recognize
-	 */
-	if (table_type != ACPI_TABLE_FACS) {
-		/* But don't abort if the checksum is wrong */
-		/* TBD: [Future] make this a configuration option? */
-
-		acpi_tb_verify_table_checksum (table_header);
+	status = acpi_tb_validate_table_header (table_header);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
 	}
 
-	/*
-	 * An AE_SUPPORT means that the table was not recognized.
-	 * We basically ignore this;  just print a debug message
-	 */
-	if (status == AE_SUPPORT) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-			"Unsupported table %s (Type %X) was found and discarded\n",
-			acpi_gbl_acpi_table_data[table_type].name, table_type));
-	}
+	/* Return the table type and length via the info struct */
+
+	table_info->length = (acpi_size) table_header->length;
 
 	return_ACPI_STATUS (status);
 }
@@ -180,10 +223,10 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_init_table_descriptor
+ * FUNCTION:    acpi_tb_init_table_descriptor
  *
- * PARAMETERS:  Table_type          - The type of the table
- *              Table_info          - A table info struct
+ * PARAMETERS:  table_type          - The type of the table
+ *              table_info          - A table info struct
  *
  * RETURN:      None.
  *
@@ -193,94 +236,78 @@
 
 acpi_status
 acpi_tb_init_table_descriptor (
-	acpi_table_type         table_type,
-	acpi_table_desc         *table_info)
+	acpi_table_type                 table_type,
+	struct acpi_table_desc          *table_info)
 {
-	acpi_table_desc         *list_head;
-	acpi_table_desc         *table_desc;
+	struct acpi_table_list          *list_head;
+	struct acpi_table_desc          *table_desc;
+
 
+	ACPI_FUNCTION_TRACE_U32 ("tb_init_table_descriptor", table_type);
 
-	FUNCTION_TRACE_U32 ("Tb_init_table_descriptor", table_type);
+
+	/* Allocate a descriptor for this table */
+
+	table_desc = ACPI_MEM_CALLOCATE (sizeof (struct acpi_table_desc));
+	if (!table_desc) {
+		return_ACPI_STATUS (AE_NO_MEMORY);
+	}
 
 	/*
 	 * Install the table into the global data structure
 	 */
-	list_head   = &acpi_gbl_acpi_tables[table_type];
-	table_desc  = list_head;
-
+	list_head = &acpi_gbl_table_lists[table_type];
 
 	/*
 	 * Two major types of tables:  1) Only one instance is allowed.  This
 	 * includes most ACPI tables such as the DSDT.  2) Multiple instances of
 	 * the table are allowed.  This includes SSDT and PSDTs.
 	 */
-	if (IS_SINGLE_TABLE (acpi_gbl_acpi_table_data[table_type].flags)) {
+	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.
 		 */
-		if (list_head->pointer) {
-			return_ACPI_STATUS (AE_EXIST);
+		if (list_head->next) {
+			return_ACPI_STATUS (AE_ALREADY_EXISTS);
 		}
-
-		table_desc->count = 1;
 	}
 
+	/*
+	 * Link the new table in to the list of tables of this type.
+	 * Just insert at the start of the list, order unimportant.
+	 *
+	 * table_desc->Prev is already NULL from calloc()
+	 */
+	table_desc->next = list_head->next;
+	list_head->next = table_desc;
 
-	else {
-		/*
-		 * Multiple tables allowed for this table type, we must link
-		 * the new table in to the list of tables of this type.
-		 */
-		if (list_head->pointer) {
-			table_desc = ACPI_MEM_CALLOCATE (sizeof (acpi_table_desc));
-			if (!table_desc) {
-				return_ACPI_STATUS (AE_NO_MEMORY);
-			}
-
-			list_head->count++;
-
-			/* Update the original previous */
-
-			list_head->prev->next = table_desc;
-
-			/* Update new entry */
-
-			table_desc->prev = list_head->prev;
-			table_desc->next = list_head;
-
-			/* Update list head */
-
-			list_head->prev = table_desc;
-		}
-
-		else {
-			table_desc->count = 1;
-		}
+	if (table_desc->next) {
+		table_desc->next->prev = table_desc;
 	}
 
+	list_head->count++;
 
-	/* Common initialization of the table descriptor */
+	/* Finish initialization of the table descriptor */
 
+	table_desc->type                = (u8) table_type;
 	table_desc->pointer             = table_info->pointer;
-	table_desc->base_pointer        = table_info->base_pointer;
 	table_desc->length              = table_info->length;
 	table_desc->allocation          = table_info->allocation;
 	table_desc->aml_start           = (u8 *) (table_desc->pointer + 1),
 	table_desc->aml_length          = (u32) (table_desc->length -
-			 (u32) sizeof (acpi_table_header));
-	table_desc->table_id            = acpi_ut_allocate_owner_id (OWNER_TYPE_TABLE);
+			 (u32) sizeof (struct acpi_table_header));
+	table_desc->table_id            = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_TABLE);
 	table_desc->loaded_into_namespace = FALSE;
 
 	/*
 	 * Set the appropriate global pointer (if there is one) to point to the
 	 * newly installed table
 	 */
-	if (acpi_gbl_acpi_table_data[table_type].global_ptr) {
-		*(acpi_gbl_acpi_table_data[table_type].global_ptr) = table_info->pointer;
+	if (acpi_gbl_table_data[table_type].global_ptr) {
+		*(acpi_gbl_table_data[table_type].global_ptr) = table_info->pointer;
 	}
 
-
 	/* Return Data */
 
 	table_info->table_id        = table_desc->table_id;
@@ -292,7 +319,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_delete_acpi_tables
+ * FUNCTION:    acpi_tb_delete_all_tables
  *
  * PARAMETERS:  None.
  *
@@ -303,25 +330,24 @@
  ******************************************************************************/
 
 void
-acpi_tb_delete_acpi_tables (void)
+acpi_tb_delete_all_tables (void)
 {
-	acpi_table_type             type;
+	acpi_table_type                     type;
 
 
 	/*
 	 * Free memory allocated for ACPI tables
 	 * Memory can either be mapped or allocated
 	 */
-	for (type = 0; type < NUM_ACPI_TABLES; type++) {
-		acpi_tb_delete_acpi_table (type);
+	for (type = 0; type < NUM_ACPI_TABLE_TYPES; type++) {
+		acpi_tb_delete_tables_by_type (type);
 	}
-
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_delete_acpi_table
+ * FUNCTION:    acpi_tb_delete_tables_by_type
  *
  * PARAMETERS:  Type                - The table type to be deleted
  *
@@ -333,23 +359,24 @@
  ******************************************************************************/
 
 void
-acpi_tb_delete_acpi_table (
-	acpi_table_type             type)
+acpi_tb_delete_tables_by_type (
+	acpi_table_type                     type)
 {
-	FUNCTION_TRACE_U32 ("Tb_delete_acpi_table", type);
+	struct acpi_table_desc          *table_desc;
+	u32                             count;
+	u32                             i;
+
+
+	ACPI_FUNCTION_TRACE_U32 ("tb_delete_tables_by_type", type);
 
 
 	if (type > ACPI_TABLE_MAX) {
 		return_VOID;
 	}
 
-
-	acpi_ut_acquire_mutex (ACPI_MTX_TABLES);
-
-	/* Free the table */
-
-	acpi_tb_free_acpi_tables_of_type (&acpi_gbl_acpi_tables[type]);
-
+	if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_TABLES))) {
+		return;
+	}
 
 	/* Clear the appropriate "typed" global table pointer */
 
@@ -380,41 +407,11 @@
 		break;
 	}
 
-	acpi_ut_release_mutex (ACPI_MTX_TABLES);
-
-	return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_tb_free_acpi_tables_of_type
- *
- * PARAMETERS:  Table_info          - A table info struct
- *
- * RETURN:      None.
- *
- * DESCRIPTION: Free the memory associated with an internal ACPI table
- *              Table mutex should be locked.
- *
- ******************************************************************************/
-
-void
-acpi_tb_free_acpi_tables_of_type (
-	acpi_table_desc         *list_head)
-{
-	acpi_table_desc         *table_desc;
-	u32                     count;
-	u32                     i;
-
-
-	FUNCTION_TRACE_PTR ("Tb_free_acpi_tables_of_type", list_head);
-
-
+	/* Free the table */
 	/* Get the head of the list */
 
-	table_desc  = list_head;
-	count       = list_head->count;
+	table_desc = acpi_gbl_table_lists[type].next;
+	count     = acpi_gbl_table_lists[type].count;
 
 	/*
 	 * Walk the entire list, deleting both the allocated tables
@@ -424,15 +421,16 @@
 		table_desc = acpi_tb_uninstall_table (table_desc);
 	}
 
+	(void) acpi_ut_release_mutex (ACPI_MTX_TABLES);
 	return_VOID;
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_delete_single_table
+ * FUNCTION:    acpi_tb_delete_single_table
  *
- * PARAMETERS:  Table_info          - A table info struct
+ * PARAMETERS:  table_info          - A table info struct
  *
  * RETURN:      None.
  *
@@ -443,44 +441,45 @@
 
 void
 acpi_tb_delete_single_table (
-	acpi_table_desc         *table_desc)
+	struct acpi_table_desc          *table_desc)
 {
 
-	if (!table_desc) {
+	/* Must have a valid table descriptor and pointer */
+
+	if ((!table_desc) ||
+		 (!table_desc->pointer)) {
 		return;
 	}
 
-	if (table_desc->pointer) {
-		/* Valid table, determine type of memory allocation */
-
-		switch (table_desc->allocation) {
-
-		case ACPI_MEM_NOT_ALLOCATED:
-			break;
+	/* Valid table, determine type of memory allocation */
 
+	switch (table_desc->allocation) {
+	case ACPI_MEM_NOT_ALLOCATED:
+		break;
 
-		case ACPI_MEM_ALLOCATED:
+	case ACPI_MEM_ALLOCATED:
 
-			ACPI_MEM_FREE (table_desc->base_pointer);
-			break;
+		ACPI_MEM_FREE (table_desc->pointer);
+		break;
 
+	case ACPI_MEM_MAPPED:
 
-		case ACPI_MEM_MAPPED:
+		acpi_os_unmap_memory (table_desc->pointer, table_desc->length);
+		break;
 
-			acpi_os_unmap_memory (table_desc->base_pointer, table_desc->length);
-			break;
-		}
+	default:
+		break;
 	}
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_uninstall_table
+ * FUNCTION:    acpi_tb_uninstall_table
  *
- * PARAMETERS:  Table_info          - A table info struct
+ * PARAMETERS:  table_info          - A table info struct
  *
- * RETURN:      None.
+ * RETURN:      Pointer to the next table in the list (of same type)
  *
  * DESCRIPTION: Free the memory associated with an internal ACPI table that
  *              is either installed or has never been installed.
@@ -488,58 +487,45 @@
  *
  ******************************************************************************/
 
-acpi_table_desc *
+struct acpi_table_desc *
 acpi_tb_uninstall_table (
-	acpi_table_desc         *table_desc)
+	struct acpi_table_desc          *table_desc)
 {
-	acpi_table_desc         *next_desc;
+	struct acpi_table_desc          *next_desc;
 
 
-	FUNCTION_TRACE_PTR ("Tb_delete_single_table", table_desc);
+	ACPI_FUNCTION_TRACE_PTR ("tb_uninstall_table", table_desc);
 
 
 	if (!table_desc) {
 		return_PTR (NULL);
 	}
 
-
-	/* Unlink the descriptor */
+	/* Unlink the descriptor from the doubly linked list */
 
 	if (table_desc->prev) {
 		table_desc->prev->next = table_desc->next;
 	}
+	else {
+		/* Is first on list, update list head */
+
+		acpi_gbl_table_lists[table_desc->type].next = table_desc->next;
+	}
 
 	if (table_desc->next) {
 		table_desc->next->prev = table_desc->prev;
 	}
 
-
 	/* Free the memory allocated for the table itself */
 
 	acpi_tb_delete_single_table (table_desc);
 
+	/* Free the table descriptor */
 
-	/* Free the table descriptor (Don't delete the list head, tho) */
-
-	if ((table_desc->prev) == (table_desc->next)) {
-
-		next_desc = NULL;
-
-		/* Clear the list head */
-
-		table_desc->pointer  = NULL;
-		table_desc->length   = 0;
-		table_desc->count    = 0;
-
-	}
-
-	else {
-		/* Free the table descriptor */
-
-		next_desc = table_desc->next;
-		ACPI_MEM_FREE (table_desc);
-	}
+	next_desc = table_desc->next;
+	ACPI_MEM_FREE (table_desc);
 
+	/* Return pointer to the next descriptor */
 
 	return_PTR (next_desc);
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/tables/tbrsdt.c linux-2.4.22-pre2/drivers/acpi/tables/tbrsdt.c
--- linux-2.4.21/drivers/acpi/tables/tbrsdt.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/tables/tbrsdt.c	2003-06-26 21:43:22.000000000 +0000
@@ -0,0 +1,315 @@
+/******************************************************************************
+ *
+ * Module Name: tbrsdt - ACPI RSDT table utilities
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+
+#include <acpi/acpi.h>
+#include <acpi/actables.h>
+
+
+#define _COMPONENT          ACPI_TABLES
+	 ACPI_MODULE_NAME    ("tbrsdt")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_tb_verify_rsdp
+ *
+ * PARAMETERS:  Address         - RSDP (Pointer to RSDT)
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table)
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_tb_verify_rsdp (
+	struct acpi_pointer             *address)
+{
+	struct acpi_table_desc          table_info;
+	acpi_status                     status;
+	struct rsdp_descriptor          *rsdp;
+
+
+	ACPI_FUNCTION_TRACE ("tb_verify_rsdp");
+
+
+	switch (address->pointer_type) {
+	case ACPI_LOGICAL_POINTER:
+
+		rsdp = address->pointer.logical;
+		break;
+
+	case ACPI_PHYSICAL_POINTER:
+		/*
+		 * Obtain access to the RSDP structure
+		 */
+		status = acpi_os_map_memory (address->pointer.physical, sizeof (struct rsdp_descriptor),
+				  (void **) &rsdp);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
+		}
+		break;
+
+	default:
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	}
+
+	/*
+	 *  The signature and checksum must both be correct
+	 */
+	if (ACPI_STRNCMP ((char *) rsdp, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) {
+		/* Nope, BAD Signature */
+
+		status = AE_BAD_SIGNATURE;
+		goto cleanup;
+	}
+
+	/* Check the standard checksum */
+
+	if (acpi_tb_checksum (rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) {
+		status = AE_BAD_CHECKSUM;
+		goto cleanup;
+	}
+
+	/* Check extended checksum if table version >= 2 */
+
+	if (rsdp->revision >= 2) {
+		if (acpi_tb_checksum (rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0) {
+			status = AE_BAD_CHECKSUM;
+			goto cleanup;
+		}
+	}
+
+	/* The RSDP supplied is OK */
+
+	table_info.pointer     = ACPI_CAST_PTR (struct acpi_table_header, rsdp);
+	table_info.length      = sizeof (struct rsdp_descriptor);
+	table_info.allocation  = ACPI_MEM_MAPPED;
+
+	/* Save the table pointers and allocation info */
+
+	status = acpi_tb_init_table_descriptor (ACPI_TABLE_RSDP, &table_info);
+	if (ACPI_FAILURE (status)) {
+		goto cleanup;
+	}
+
+	/* Save the RSDP in a global for easy access */
+
+	acpi_gbl_RSDP = ACPI_CAST_PTR (struct rsdp_descriptor, table_info.pointer);
+	return_ACPI_STATUS (status);
+
+
+	/* Error exit */
+cleanup:
+
+	if (acpi_gbl_table_flags & ACPI_PHYSICAL_POINTER) {
+		acpi_os_unmap_memory (rsdp, sizeof (struct rsdp_descriptor));
+	}
+	return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_tb_get_rsdt_address
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      RSDT physical address
+ *
+ * DESCRIPTION: Extract the address of the RSDT or XSDT, depending on the
+ *              version of the RSDP
+ *
+ ******************************************************************************/
+
+void
+acpi_tb_get_rsdt_address (
+	struct acpi_pointer             *out_address)
+{
+
+	ACPI_FUNCTION_ENTRY ();
+
+
+	out_address->pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING;
+
+	/*
+	 * For RSDP revision 0 or 1, we use the RSDT.
+	 * For RSDP revision 2 (and above), we use the XSDT
+	 */
+	if (acpi_gbl_RSDP->revision < 2) {
+		out_address->pointer.value = acpi_gbl_RSDP->rsdt_physical_address;
+	}
+	else {
+		out_address->pointer.value = acpi_gbl_RSDP->xsdt_physical_address;
+	}
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_tb_validate_rsdt
+ *
+ * PARAMETERS:  table_ptr       - Addressable pointer to the RSDT.
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Validate signature for the RSDT or XSDT
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_tb_validate_rsdt (
+	struct acpi_table_header        *table_ptr)
+{
+	int                             no_match;
+
+
+	ACPI_FUNCTION_NAME ("tb_validate_rsdt");
+
+
+	/*
+	 * For RSDP revision 0 or 1, we use the RSDT.
+	 * For RSDP revision 2 and above, we use the XSDT
+	 */
+	if (acpi_gbl_RSDP->revision < 2) {
+		no_match = ACPI_STRNCMP ((char *) table_ptr, RSDT_SIG,
+				  sizeof (RSDT_SIG) -1);
+	}
+	else {
+		no_match = ACPI_STRNCMP ((char *) table_ptr, XSDT_SIG,
+				  sizeof (XSDT_SIG) -1);
+	}
+
+	if (no_match) {
+		/* Invalid RSDT or XSDT signature */
+
+		ACPI_REPORT_ERROR (("Invalid signature where RSDP indicates RSDT/XSDT should be located\n"));
+
+		ACPI_DUMP_BUFFER (acpi_gbl_RSDP, 20);
+
+		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR,
+			"RSDT/XSDT signature at %X (%p) is invalid\n",
+			acpi_gbl_RSDP->rsdt_physical_address,
+			(void *) (acpi_native_uint) acpi_gbl_RSDP->rsdt_physical_address));
+
+		return (AE_BAD_SIGNATURE);
+	}
+
+	return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_tb_get_table_rsdt
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table)
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_tb_get_table_rsdt (
+	void)
+{
+	struct acpi_table_desc          table_info;
+	acpi_status                     status;
+	struct acpi_pointer             address;
+
+
+	ACPI_FUNCTION_TRACE ("tb_get_table_rsdt");
+
+
+	/* Get the RSDT/XSDT via the RSDP */
+
+	acpi_tb_get_rsdt_address (&address);
+
+	status = acpi_tb_get_table (&address, &table_info);
+	if (ACPI_FAILURE (status)) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not get the RSDT/XSDT, %s\n",
+			acpi_format_exception (status)));
+		return_ACPI_STATUS (status);
+	}
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+		"RSDP located at %p, points to RSDT physical=%8.8X%8.8X \n",
+		acpi_gbl_RSDP,
+		ACPI_HIDWORD (address.pointer.value),
+		ACPI_LODWORD (address.pointer.value)));
+
+	/* Check the RSDT or XSDT signature */
+
+	status = acpi_tb_validate_rsdt (table_info.pointer);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/* Get the number of tables defined in the RSDT or XSDT */
+
+	acpi_gbl_rsdt_table_count = acpi_tb_get_table_count (acpi_gbl_RSDP, table_info.pointer);
+
+	/* Convert and/or copy to an XSDT structure */
+
+	status = acpi_tb_convert_to_xsdt (&table_info);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/* Save the table pointers and allocation info */
+
+	status = acpi_tb_init_table_descriptor (ACPI_TABLE_XSDT, &table_info);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	acpi_gbl_XSDT = (XSDT_DESCRIPTOR *) table_info.pointer;
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "XSDT located at %p\n", acpi_gbl_XSDT));
+	return_ACPI_STATUS (status);
+}
+
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/tables/tbutils.c linux-2.4.22-pre2/drivers/acpi/tables/tbutils.c
--- linux-2.4.21/drivers/acpi/tables/tbutils.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/tables/tbutils.c	2003-06-26 21:43:14.000000000 +0000
@@ -1,162 +1,102 @@
 /******************************************************************************
  *
  * Module Name: tbutils - Table manipulation utilities
- *              $Revision: 42 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "actables.h"
-#include "acinterp.h"
+#include <acpi/acpi.h>
+#include <acpi/actables.h>
 
 
 #define _COMPONENT          ACPI_TABLES
-	 MODULE_NAME         ("tbutils")
+	 ACPI_MODULE_NAME    ("tbutils")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_handle_to_object
+ * FUNCTION:    acpi_tb_handle_to_object
  *
- * PARAMETERS:  Table_id            - Id for which the function is searching
- *              Table_desc          - Pointer to return the matching table
+ * PARAMETERS:  table_id            - Id for which the function is searching
+ *              table_desc          - Pointer to return the matching table
  *                                      descriptor.
  *
- * RETURN:      Search the tables to find one with a matching Table_id and
+ * RETURN:      Search the tables to find one with a matching table_id and
  *              return a pointer to that table descriptor.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_tb_handle_to_object (
-	u16                     table_id,
-	acpi_table_desc         **table_desc)
+	u16                             table_id,
+	struct acpi_table_desc          **return_table_desc)
 {
-	u32                     i;
-	acpi_table_desc         *list_head;
+	u32                             i;
+	struct acpi_table_desc          *table_desc;
 
 
-	PROC_NAME ("Tb_handle_to_object");
+	ACPI_FUNCTION_NAME ("tb_handle_to_object");
 
 
 	for (i = 0; i < ACPI_TABLE_MAX; i++) {
-		list_head = &acpi_gbl_acpi_tables[i];
-		do {
-			if (list_head->table_id == table_id) {
-				*table_desc = list_head;
+		table_desc = acpi_gbl_table_lists[i].next;
+		while (table_desc) {
+			if (table_desc->table_id == table_id) {
+				*return_table_desc = table_desc;
 				return (AE_OK);
 			}
 
-			list_head = list_head->next;
-
-		} while (list_head != &acpi_gbl_acpi_tables[i]);
-	}
-
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Table_id=%X does not exist\n", table_id));
-	return (AE_BAD_PARAMETER);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_tb_system_table_pointer
- *
- * PARAMETERS:  *Where              - Pointer to be examined
- *
- * RETURN:      TRUE if Where is within the AML stream (in one of the ACPI
- *              system tables such as the DSDT or an SSDT.)
- *              FALSE otherwise
- *
- ******************************************************************************/
-
-u8
-acpi_tb_system_table_pointer (
-	void                    *where)
-{
-	u32                     i;
-	acpi_table_desc         *table_desc;
-	acpi_table_header       *table;
-
-
-	/* No function trace, called too often! */
-
-
-	/* Ignore null pointer */
-
-	if (!where) {
-		return (FALSE);
-	}
-
-
-	/* Check for a pointer within the DSDT */
-
-	if ((acpi_gbl_DSDT) &&
-		(IS_IN_ACPI_TABLE (where, acpi_gbl_DSDT))) {
-		return (TRUE);
-	}
-
-
-	/* Check each of the loaded SSDTs (if any)*/
-
-	table_desc = &acpi_gbl_acpi_tables[ACPI_TABLE_SSDT];
-
-	for (i = 0; i < acpi_gbl_acpi_tables[ACPI_TABLE_SSDT].count; i++) {
-		table = table_desc->pointer;
-
-		if (IS_IN_ACPI_TABLE (where, table)) {
-			return (TRUE);
+			table_desc = table_desc->next;
 		}
-
-		table_desc = table_desc->next;
 	}
 
-
-	/* Check each of the loaded PSDTs (if any)*/
-
-	table_desc = &acpi_gbl_acpi_tables[ACPI_TABLE_PSDT];
-
-	for (i = 0; i < acpi_gbl_acpi_tables[ACPI_TABLE_PSDT].count; i++) {
-		table = table_desc->pointer;
-
-		if (IS_IN_ACPI_TABLE (where, table)) {
-			return (TRUE);
-		}
-
-		table_desc = table_desc->next;
-	}
-
-
-	/* Pointer does not point into any system table */
-
-	return (FALSE);
+	ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "table_id=%X does not exist\n", table_id));
+	return (AE_BAD_PARAMETER);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_validate_table_header
+ * FUNCTION:    acpi_tb_validate_table_header
  *
- * PARAMETERS:  Table_header        - Logical pointer to the table
+ * PARAMETERS:  table_header        - Logical pointer to the table
  *
  * RETURN:      Status
  *
@@ -168,52 +108,52 @@
  *             name
  *          3) Table must be readable for length specified in the header
  *          4) Table checksum must be valid (with the exception of the FACS
- *              which has no checksum for some odd reason)
+ *              which has no checksum because it contains variable fields)
  *
  ******************************************************************************/
 
 acpi_status
 acpi_tb_validate_table_header (
-	acpi_table_header       *table_header)
+	struct acpi_table_header        *table_header)
 {
-	acpi_name               signature;
+	acpi_name                       signature;
 
 
-	PROC_NAME ("Tb_validate_table_header");
+	ACPI_FUNCTION_NAME ("tb_validate_table_header");
 
 
 	/* Verify that this is a valid address */
 
-	if (!acpi_os_readable (table_header, sizeof (acpi_table_header))) {
+	if (!acpi_os_readable (table_header, sizeof (struct acpi_table_header))) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 			"Cannot read table header at %p\n", table_header));
 		return (AE_BAD_ADDRESS);
 	}
 
-
 	/* Ensure that the signature is 4 ASCII characters */
 
-	MOVE_UNALIGNED32_TO_32 (&signature, &table_header->signature);
+	ACPI_MOVE_32_TO_32 (&signature, table_header->signature);
 	if (!acpi_ut_valid_acpi_name (signature)) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 			"Table signature at %p [%p] has invalid characters\n",
 			table_header, &signature));
 
-		REPORT_WARNING (("Invalid table signature %4.4s found\n", (char*)&signature));
-		DUMP_BUFFER (table_header, sizeof (acpi_table_header));
+		ACPI_REPORT_WARNING (("Invalid table signature found: [%4.4s]\n",
+			(char *) &signature));
+		ACPI_DUMP_BUFFER (table_header, sizeof (struct acpi_table_header));
 		return (AE_BAD_SIGNATURE);
 	}
 
-
 	/* Validate the table length */
 
-	if (table_header->length < sizeof (acpi_table_header)) {
+	if (table_header->length < sizeof (struct acpi_table_header)) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 			"Invalid length in table header %p name %4.4s\n",
-			table_header, (char*)&signature));
+			table_header, (char *) &signature));
 
-		REPORT_WARNING (("Invalid table header length found\n"));
-		DUMP_BUFFER (table_header, sizeof (acpi_table_header));
+		ACPI_REPORT_WARNING (("Invalid table header length (0x%X) found\n",
+			(u32) table_header->length));
+		ACPI_DUMP_BUFFER (table_header, sizeof (struct acpi_table_header));
 		return (AE_BAD_HEADER);
 	}
 
@@ -223,90 +163,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_map_acpi_table
- *
- * PARAMETERS:  Physical_address        - Physical address of table to map
- *              *Size                   - Size of the table.  If zero, the size
- *                                        from the table header is used.
- *                                        Actual size is returned here.
- *              **Logical_address       - Logical address of mapped table
- *
- * RETURN:      Logical address of the mapped table.
- *
- * DESCRIPTION: Maps the physical address of table into a logical address
- *
- ******************************************************************************/
-
-acpi_status
-acpi_tb_map_acpi_table (
-	ACPI_PHYSICAL_ADDRESS   physical_address,
-	u32                     *size,
-	acpi_table_header       **logical_address)
-{
-	acpi_table_header       *table;
-	u32                     table_size = *size;
-	acpi_status             status = AE_OK;
-
-
-	PROC_NAME ("Tb_map_acpi_table");
-
-
-	/* If size is zero, look at the table header to get the actual size */
-
-	if ((*size) == 0) {
-		/* Get the table header so we can extract the table length */
-
-		status = acpi_os_map_memory (physical_address, sizeof (acpi_table_header),
-				  (void **) &table);
-		if (ACPI_FAILURE (status)) {
-			return (status);
-		}
-
-		/* Extract the full table length before we delete the mapping */
-
-		table_size = table->length;
-
-		/*
-		 * Validate the header and delete the mapping.
-		 * We will create a mapping for the full table below.
-		 */
-		status = acpi_tb_validate_table_header (table);
-
-		/* Always unmap the memory for the header */
-
-		acpi_os_unmap_memory (table, sizeof (acpi_table_header));
-
-		/* Exit if header invalid */
-
-		if (ACPI_FAILURE (status)) {
-			return (status);
-		}
-	}
-
-
-	/* Map the physical memory for the correct length */
-
-	status = acpi_os_map_memory (physical_address, table_size, (void **) &table);
-	if (ACPI_FAILURE (status)) {
-		return (status);
-	}
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-		"Mapped memory for ACPI table, length=%d(%X) at %p\n",
-		table_size, table_size, table));
-
-	*size = table_size;
-	*logical_address = table;
-
-	return (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_tb_verify_table_checksum
+ * FUNCTION:    acpi_tb_verify_table_checksum
  *
- * PARAMETERS:  *Table_header           - ACPI table to verify
+ * PARAMETERS:  *table_header           - ACPI table to verify
  *
  * RETURN:      8 bit checksum of table
  *
@@ -317,13 +176,13 @@
 
 acpi_status
 acpi_tb_verify_table_checksum (
-	acpi_table_header       *table_header)
+	struct acpi_table_header        *table_header)
 {
-	u8                      checksum;
-	acpi_status             status = AE_OK;
+	u8                              checksum;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE ("Tb_verify_table_checksum");
+	ACPI_FUNCTION_TRACE ("tb_verify_table_checksum");
 
 
 	/* Compute the checksum on the table */
@@ -333,20 +192,18 @@
 	/* Return the appropriate exception */
 
 	if (checksum) {
-		REPORT_WARNING (("Invalid checksum (%X) in table %4.4s\n",
-			checksum, (char*)&table_header->signature));
+		ACPI_REPORT_WARNING (("Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n",
+			table_header->signature, (u32) table_header->checksum, (u32) checksum));
 
 		status = AE_BAD_CHECKSUM;
 	}
-
-
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_checksum
+ * FUNCTION:    acpi_tb_checksum
  *
  * PARAMETERS:  Buffer              - Buffer to checksum
  *              Length              - Size of the buffer
@@ -359,12 +216,12 @@
 
 u8
 acpi_tb_checksum (
-	void                    *buffer,
-	u32                     length)
+	void                            *buffer,
+	u32                             length)
 {
-	u8                      *limit;
-	u8                      *rover;
-	u8                      sum = 0;
+	const u8                        *limit;
+	const u8                        *rover;
+	u8                              sum = 0;
 
 
 	if (buffer && length) {
@@ -376,7 +233,6 @@
 			sum = (u8) (sum + *rover);
 		}
 	}
-
 	return (sum);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/tables/tbxface.c linux-2.4.22-pre2/drivers/acpi/tables/tbxface.c
--- linux-2.4.21/drivers/acpi/tables/tbxface.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/tables/tbxface.c	2003-06-26 21:43:32.000000000 +0000
@@ -2,42 +2,59 @@
  *
  * Module Name: tbxface - Public interfaces to the ACPI subsystem
  *                         ACPI table oriented interfaces
- *              $Revision: 45 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acnamesp.h"
-#include "acinterp.h"
-#include "actables.h"
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
+#include <acpi/actables.h>
 
 
 #define _COMPONENT          ACPI_TABLES
-	 MODULE_NAME         ("tbxface")
+	 ACPI_MODULE_NAME    ("tbxface")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_load_tables
+ * FUNCTION:    acpi_load_tables
  *
  * PARAMETERS:  None
  *
@@ -51,59 +68,60 @@
 acpi_status
 acpi_load_tables (void)
 {
-	ACPI_PHYSICAL_ADDRESS   rsdp_physical_address;
-	acpi_status             status;
-	u32                     number_of_tables = 0;
+	struct acpi_pointer             rsdp_address;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Acpi_load_tables");
+	ACPI_FUNCTION_TRACE ("acpi_load_tables");
 
 
 	/* Get the RSDP */
 
 	status = acpi_os_get_root_pointer (ACPI_LOGICAL_ADDRESSING,
-			  &rsdp_physical_address);
+			  &rsdp_address);
 	if (ACPI_FAILURE (status)) {
-		REPORT_ERROR (("Acpi_load_tables: Could not get RSDP, %s\n",
+		ACPI_REPORT_ERROR (("acpi_load_tables: Could not get RSDP, %s\n",
 				  acpi_format_exception (status)));
 		goto error_exit;
 	}
 
 	/* Map and validate the RSDP */
 
-	status = acpi_tb_verify_rsdp (rsdp_physical_address);
+	acpi_gbl_table_flags = rsdp_address.pointer_type;
+
+	status = acpi_tb_verify_rsdp (&rsdp_address);
 	if (ACPI_FAILURE (status)) {
-		REPORT_ERROR (("Acpi_load_tables: RSDP Failed validation: %s\n",
+		ACPI_REPORT_ERROR (("acpi_load_tables: RSDP Failed validation: %s\n",
 				  acpi_format_exception (status)));
 		goto error_exit;
 	}
 
 	/* Get the RSDT via the RSDP */
 
-	status = acpi_tb_get_table_rsdt (&number_of_tables);
+	status = acpi_tb_get_table_rsdt ();
 	if (ACPI_FAILURE (status)) {
-		REPORT_ERROR (("Acpi_load_tables: Could not load RSDT: %s\n",
+		ACPI_REPORT_ERROR (("acpi_load_tables: Could not load RSDT: %s\n",
 				  acpi_format_exception (status)));
 		goto error_exit;
 	}
 
-	/* Now get the rest of the tables */
+	/* Now get the tables needed by this subsystem (FADT, DSDT, etc.) */
 
-	status = acpi_tb_get_all_tables (number_of_tables, NULL);
+	status = acpi_tb_get_required_tables ();
 	if (ACPI_FAILURE (status)) {
-		REPORT_ERROR (("Acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n",
+		ACPI_REPORT_ERROR (("acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n",
 				  acpi_format_exception (status)));
 		goto error_exit;
 	}
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_OK, "ACPI Tables successfully loaded\n"));
+	ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
 
 
 	/* Load the namespace from the tables */
 
 	status = acpi_ns_load_namespace ();
 	if (ACPI_FAILURE (status)) {
-		REPORT_ERROR (("Acpi_load_tables: Could not load namespace: %s\n",
+		ACPI_REPORT_ERROR (("acpi_load_tables: Could not load namespace: %s\n",
 				  acpi_format_exception (status)));
 		goto error_exit;
 	}
@@ -112,7 +130,7 @@
 
 
 error_exit:
-	REPORT_ERROR (("Acpi_load_tables: Could not load tables: %s\n",
+	ACPI_REPORT_ERROR (("acpi_load_tables: Could not load tables: %s\n",
 			  acpi_format_exception (status)));
 
 	return_ACPI_STATUS (status);
@@ -121,9 +139,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_load_table
+ * FUNCTION:    acpi_load_table
  *
- * PARAMETERS:  Table_ptr       - pointer to a buffer containing the entire
+ * PARAMETERS:  table_ptr       - pointer to a buffer containing the entire
  *                                table to be loaded
  *
  * RETURN:      Status
@@ -137,13 +155,14 @@
 
 acpi_status
 acpi_load_table (
-	acpi_table_header       *table_ptr)
+	struct acpi_table_header        *table_ptr)
 {
-	acpi_status             status;
-	acpi_table_desc         table_info;
+	acpi_status                     status;
+	struct acpi_table_desc          table_info;
+	struct acpi_pointer             address;
 
 
-	FUNCTION_TRACE ("Acpi_load_table");
+	ACPI_FUNCTION_TRACE ("acpi_load_table");
 
 
 	if (!table_ptr) {
@@ -152,40 +171,59 @@
 
 	/* Copy the table to a local buffer */
 
-	status = acpi_tb_get_table (0, table_ptr, &table_info);
+	address.pointer_type    = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING;
+	address.pointer.logical = table_ptr;
+
+	status = acpi_tb_get_table_body (&address, table_ptr, &table_info);
 	if (ACPI_FAILURE (status)) {
 		return_ACPI_STATUS (status);
 	}
 
 	/* Install the new table into the local data structures */
 
-	status = acpi_tb_install_table (NULL, &table_info);
+	status = acpi_tb_install_table (&table_info);
 	if (ACPI_FAILURE (status)) {
-		/* Free table allocated by Acpi_tb_get_table */
+		/* Free table allocated by acpi_tb_get_table_body */
 
 		acpi_tb_delete_single_table (&table_info);
 		return_ACPI_STATUS (status);
 	}
 
+	/* Convert the table to common format if necessary */
+
+	switch (table_info.type) {
+	case ACPI_TABLE_FADT:
+
+		status = acpi_tb_convert_table_fadt ();
+		break;
+
+	case ACPI_TABLE_FACS:
+
+		status = acpi_tb_build_common_facs (&table_info);
+		break;
+
+	default:
+		/* Load table into namespace if it contains executable AML */
+
+		status = acpi_ns_load_table (table_info.installed_desc, acpi_gbl_root_node);
+		break;
+	}
 
-	status = acpi_ns_load_table (table_info.installed_desc, acpi_gbl_root_node);
 	if (ACPI_FAILURE (status)) {
 		/* Uninstall table and free the buffer */
 
-		acpi_tb_uninstall_table (table_info.installed_desc);
-		return_ACPI_STATUS (status);
+		(void) acpi_tb_uninstall_table (table_info.installed_desc);
 	}
 
-
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_unload_table
+ * FUNCTION:    acpi_unload_table
  *
- * PARAMETERS:  Table_type    - Type of table to be unloaded
+ * PARAMETERS:  table_type    - Type of table to be unloaded
  *
  * RETURN:      Status
  *
@@ -195,12 +233,12 @@
 
 acpi_status
 acpi_unload_table (
-	acpi_table_type         table_type)
+	acpi_table_type                 table_type)
 {
-	acpi_table_desc         *list_head;
+	struct acpi_table_desc          *table_desc;
 
 
-	FUNCTION_TRACE ("Acpi_unload_table");
+	ACPI_FUNCTION_TRACE ("acpi_unload_table");
 
 
 	/* Parameter validation */
@@ -212,39 +250,39 @@
 
 	/* Find all tables of the requested type */
 
-	list_head = &acpi_gbl_acpi_tables[table_type];
-	do {
+	table_desc = acpi_gbl_table_lists[table_type].next;
+	while (table_desc); {
 		/*
 		 * Delete all namespace entries owned by this table.  Note that these
 		 * entries can appear anywhere in the namespace by virtue of the AML
 		 * "Scope" operator.  Thus, we need to track ownership by an ID, not
 		 * simply a position within the hierarchy
 		 */
-		acpi_ns_delete_namespace_by_owner (list_head->table_id);
-
-		/* Delete (or unmap) the actual table */
+		acpi_ns_delete_namespace_by_owner (table_desc->table_id);
 
-		acpi_tb_delete_acpi_table (table_type);
+		table_desc = table_desc->next;
+	}
 
-	} while (list_head != &acpi_gbl_acpi_tables[table_type]);
+	/* Delete (or unmap) all tables of this type */
 
+	acpi_tb_delete_tables_by_type (table_type);
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_get_table_header
+ * FUNCTION:    acpi_get_table_header
  *
- * PARAMETERS:  Table_type      - one of the defined table types
+ * PARAMETERS:  table_type      - one of the defined table types
  *              Instance        - the non zero instance of the table, allows
  *                                support for multiple tables of the same type
- *                                see Acpi_gbl_Acpi_table_flag
- *              Out_table_header - pointer to the acpi_table_header if successful
+ *                                see acpi_gbl_acpi_table_flag
+ *              out_table_header - pointer to the struct acpi_table_header if successful
  *
  * DESCRIPTION: This function is called to get an ACPI table header.  The caller
  *              supplies an pointer to a data area sufficient to contain an ACPI
- *              acpi_table_header structure.
+ *              struct acpi_table_header structure.
  *
  *              The header contains a length field that can be used to determine
  *              the size of the buffer needed to contain the entire table.  This
@@ -255,15 +293,15 @@
 
 acpi_status
 acpi_get_table_header (
-	acpi_table_type         table_type,
-	u32                     instance,
-	acpi_table_header       *out_table_header)
+	acpi_table_type                 table_type,
+	u32                             instance,
+	struct acpi_table_header        *out_table_header)
 {
-	acpi_table_header       *tbl_ptr;
-	acpi_status             status;
+	struct acpi_table_header        *tbl_ptr;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Acpi_get_table_header");
+	ACPI_FUNCTION_TRACE ("acpi_get_table_header");
 
 
 	if ((instance == 0)                 ||
@@ -275,7 +313,7 @@
 	/* Check the table type and instance */
 
 	if ((table_type > ACPI_TABLE_MAX)   ||
-		(IS_SINGLE_TABLE (acpi_gbl_acpi_table_data[table_type].flags) &&
+		(ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags) &&
 		 instance > 1)) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
@@ -298,8 +336,8 @@
 	/*
 	 * Copy the header to the caller's buffer
 	 */
-	MEMCPY ((void *) out_table_header, (void *) tbl_ptr,
-			 sizeof (acpi_table_header));
+	ACPI_MEMCPY ((void *) out_table_header, (void *) tbl_ptr,
+			 sizeof (struct acpi_table_header));
 
 	return_ACPI_STATUS (status);
 }
@@ -307,54 +345,56 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_get_table
+ * FUNCTION:    acpi_get_table
  *
- * PARAMETERS:  Table_type      - one of the defined table types
+ * PARAMETERS:  table_type      - one of the defined table types
  *              Instance        - the non zero instance of the table, allows
  *                                support for multiple tables of the same type
- *                                see Acpi_gbl_Acpi_table_flag
- *              Ret_buffer      - pointer to a structure containing a buffer to
+ *                                see acpi_gbl_acpi_table_flag
+ *              ret_buffer      - pointer to a structure containing a buffer to
  *                                receive the table
  *
  * RETURN:      Status
  *
  * DESCRIPTION: This function is called to get an ACPI table.  The caller
- *              supplies an Out_buffer large enough to contain the entire ACPI
- *              table.  The caller should call the Acpi_get_table_header function
+ *              supplies an out_buffer large enough to contain the entire ACPI
+ *              table.  The caller should call the acpi_get_table_header function
  *              first to determine the buffer size needed.  Upon completion
- *              the Out_buffer->Length field will indicate the number of bytes
- *              copied into the Out_buffer->Buf_ptr buffer. This table will be
+ *              the out_buffer->Length field will indicate the number of bytes
+ *              copied into the out_buffer->buf_ptr buffer. This table will be
  *              a complete table including the header.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_get_table (
-	acpi_table_type         table_type,
-	u32                     instance,
-	acpi_buffer             *ret_buffer)
+	acpi_table_type                 table_type,
+	u32                             instance,
+	struct acpi_buffer              *ret_buffer)
 {
-	acpi_table_header       *tbl_ptr;
-	acpi_status             status;
-	u32                     ret_buf_len;
+	struct acpi_table_header        *tbl_ptr;
+	acpi_status                     status;
+	acpi_size                       table_length;
 
 
-	FUNCTION_TRACE ("Acpi_get_table");
+	ACPI_FUNCTION_TRACE ("acpi_get_table");
 
 
-	/*
-	 *  If we have a buffer, we must have a length too
-	 */
-	if ((instance == 0)                 ||
-		(!ret_buffer)                   ||
-		((!ret_buffer->pointer) && (ret_buffer->length))) {
+	/* Parameter validation */
+
+	if (instance == 0) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
+	status = acpi_ut_validate_buffer (ret_buffer);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
 	/* Check the table type and instance */
 
 	if ((table_type > ACPI_TABLE_MAX)   ||
-		(IS_SINGLE_TABLE (acpi_gbl_acpi_table_data[table_type].flags) &&
+		(ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags) &&
 		 instance > 1)) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
@@ -368,38 +408,35 @@
 	}
 
 	/*
-	 * Acpi_tb_get_table_ptr will return a NULL pointer if the
+	 * acpi_tb_get_table_ptr will return a NULL pointer if the
 	 * table is not loaded.
 	 */
 	if (tbl_ptr == NULL) {
 		return_ACPI_STATUS (AE_NOT_EXIST);
 	}
 
-	/*
-	 * Got a table ptr, assume it's ok and copy it to the user's buffer
-	 */
+	/* Get the table length */
+
 	if (table_type == ACPI_TABLE_RSDP) {
 		/*
 		 *  RSD PTR is the only "table" without a header
 		 */
-		ret_buf_len = sizeof (RSDP_DESCRIPTOR);
+		table_length = sizeof (struct rsdp_descriptor);
 	}
 	else {
-		ret_buf_len = tbl_ptr->length;
+		table_length = (acpi_size) tbl_ptr->length;
 	}
 
-	/*
-	 * Verify we have space in the caller's buffer for the table
-	 */
-	if (ret_buffer->length < ret_buf_len) {
-		ret_buffer->length = ret_buf_len;
-		return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
-	}
+	/* Validate/Allocate/Clear caller buffer */
 
-	ret_buffer->length = ret_buf_len;
+	status = acpi_ut_initialize_buffer (ret_buffer, table_length);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
-	MEMCPY ((void *) ret_buffer->pointer, (void *) tbl_ptr, ret_buf_len);
+	/* Copy the table to the buffer */
 
+	ACPI_MEMCPY ((void *) ret_buffer->pointer, (void *) tbl_ptr, table_length);
 	return_ACPI_STATUS (AE_OK);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/tables/tbxfroot.c linux-2.4.22-pre2/drivers/acpi/tables/tbxfroot.c
--- linux-2.4.21/drivers/acpi/tables/tbxfroot.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/tables/tbxfroot.c	2003-06-26 21:43:30.000000000 +0000
@@ -1,46 +1,302 @@
 /******************************************************************************
  *
  * Module Name: tbxfroot - Find the root ACPI table (RSDT)
- *              $Revision: 52 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "achware.h"
-#include "actables.h"
+#include <acpi/acpi.h>
+#include <acpi/actables.h>
 
 
 #define _COMPONENT          ACPI_TABLES
-	 MODULE_NAME         ("tbxfroot")
+	 ACPI_MODULE_NAME    ("tbxfroot")
 
-#define RSDP_CHECKSUM_LENGTH 20
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_tb_find_table
+ *
+ * PARAMETERS:  Signature           - String with ACPI table signature
+ *              oem_id              - String with the table OEM ID
+ *              oem_table_id        - String with the OEM Table ID.
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Find an ACPI table (in the RSDT/XSDT) that matches the
+ *              Signature, OEM ID and OEM Table ID.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_tb_find_table (
+	char                            *signature,
+	char                            *oem_id,
+	char                            *oem_table_id,
+	struct acpi_table_header        **table_ptr)
+{
+	acpi_status                     status;
+	struct acpi_table_header        *table;
+
+
+	ACPI_FUNCTION_TRACE ("tb_find_table");
+
+
+	/* Validate string lengths */
+
+	if ((ACPI_STRLEN (signature)  > ACPI_NAME_SIZE) ||
+		(ACPI_STRLEN (oem_id)     > sizeof (table->oem_id)) ||
+		(ACPI_STRLEN (oem_table_id) > sizeof (table->oem_table_id))) {
+		return_ACPI_STATUS (AE_AML_STRING_LIMIT);
+	}
+
+	/* 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 */
+
+	if ((oem_id[0]     && ACPI_STRCMP (oem_id, table->oem_id)) ||
+		(oem_table_id[0] && ACPI_STRCMP (oem_table_id, table->oem_table_id))) {
+		return_ACPI_STATUS (AE_AML_NAME_NOT_FOUND);
+	}
+
+	*table_ptr = table;
+	return_ACPI_STATUS (AE_OK);
+}
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_find_root_pointer
+ * FUNCTION:    acpi_get_firmware_table
  *
- * PARAMETERS:  **Rsdp_physical_address     - Where to place the RSDP address
- *              Flags                       - Logical/Physical addressing
+ * PARAMETERS:  Signature       - Any ACPI table signature
+ *              Instance        - the non zero instance of the table, allows
+ *                                support for multiple tables of the same type
+ *              Flags           - Physical/Virtual support
+ *              ret_buffer      - pointer to a structure containing a buffer to
+ *                                receive the table
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: This function is called to get an ACPI table.  The caller
+ *              supplies an out_buffer large enough to contain the entire ACPI
+ *              table.  Upon completion
+ *              the out_buffer->Length field will indicate the number of bytes
+ *              copied into the out_buffer->buf_ptr buffer. This table will be
+ *              a complete table including the header.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_get_firmware_table (
+	acpi_string                     signature,
+	u32                             instance,
+	u32                             flags,
+	struct acpi_table_header        **table_pointer)
+{
+	struct acpi_pointer             rsdp_address;
+	struct acpi_pointer             address;
+	acpi_status                     status;
+	struct acpi_table_header        header;
+	struct acpi_table_desc          table_info;
+	struct acpi_table_desc          rsdt_info;
+	u32                             table_count;
+	u32                             i;
+	u32                             j;
+
+
+	ACPI_FUNCTION_TRACE ("acpi_get_firmware_table");
+
+
+	/*
+	 * Ensure that at least the table manager is initialized.  We don't
+	 * require that the entire ACPI subsystem is up for this interface
+	 */
+
+	/*
+	 *  If we have a buffer, we must have a length too
+	 */
+	if ((instance == 0)                 ||
+		(!signature)                    ||
+		(!table_pointer)) {
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	}
+
+	rsdt_info.pointer = NULL;
+
+	if (!acpi_gbl_RSDP) {
+		/* Get the RSDP */
+
+		status = acpi_os_get_root_pointer (flags, &rsdp_address);
+		if (ACPI_FAILURE (status)) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP  not found\n"));
+			return_ACPI_STATUS (AE_NO_ACPI_TABLES);
+		}
+
+		/* Map and validate the RSDP */
+
+		if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) {
+			status = acpi_os_map_memory (rsdp_address.pointer.physical, sizeof (struct rsdp_descriptor),
+					  (void **) &acpi_gbl_RSDP);
+			if (ACPI_FAILURE (status)) {
+				return_ACPI_STATUS (status);
+			}
+		}
+		else {
+			acpi_gbl_RSDP = rsdp_address.pointer.logical;
+		}
+
+		/*
+		 *  The signature and checksum must both be correct
+		 */
+		if (ACPI_STRNCMP ((char *) acpi_gbl_RSDP, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) {
+			/* Nope, BAD Signature */
+
+			return_ACPI_STATUS (AE_BAD_SIGNATURE);
+		}
+
+		if (acpi_tb_checksum (acpi_gbl_RSDP, ACPI_RSDP_CHECKSUM_LENGTH) != 0) {
+			/* Nope, BAD Checksum */
+
+			return_ACPI_STATUS (AE_BAD_CHECKSUM);
+		}
+	}
+
+	/* Get the RSDT and validate it */
+
+	acpi_tb_get_rsdt_address (&address);
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+		"RSDP located at %p, RSDT physical=%8.8X%8.8X \n",
+		acpi_gbl_RSDP,
+		ACPI_HIDWORD (address.pointer.value),
+		ACPI_LODWORD (address.pointer.value)));
+
+	/* Insert processor_mode flags */
+
+	address.pointer_type |= flags;
+
+	status = acpi_tb_get_table (&address, &rsdt_info);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	status = acpi_tb_validate_rsdt (rsdt_info.pointer);
+	if (ACPI_FAILURE (status)) {
+		goto cleanup;
+	}
+
+	/* Get the number of table pointers within the RSDT */
+
+	table_count = acpi_tb_get_table_count (acpi_gbl_RSDP, rsdt_info.pointer);
+
+	address.pointer_type = acpi_gbl_table_flags | flags;
+
+	/*
+	 * Search the RSDT/XSDT for the correct instance of the
+	 * requested table
+	 */
+	for (i = 0, j = 0; i < table_count; i++) {
+		/* Get the next table pointer, handle RSDT vs. XSDT */
+
+		if (acpi_gbl_RSDP->revision < 2) {
+			address.pointer.value = ((RSDT_DESCRIPTOR *) rsdt_info.pointer)->table_offset_entry[i];
+		}
+		else {
+			address.pointer.value =
+				((XSDT_DESCRIPTOR *) rsdt_info.pointer)->table_offset_entry[i];
+		}
+
+		/* Get the table header */
+
+		status = acpi_tb_get_table_header (&address, &header);
+		if (ACPI_FAILURE (status)) {
+			goto cleanup;
+		}
+
+		/* Compare table signatures and table instance */
+
+		if (!ACPI_STRNCMP (header.signature, signature, ACPI_NAME_SIZE)) {
+			/* An instance of the table was found */
+
+			j++;
+			if (j >= instance) {
+				/* Found the correct instance, get the entire table */
+
+				status = acpi_tb_get_table_body (&address, &header, &table_info);
+				if (ACPI_FAILURE (status)) {
+					goto cleanup;
+				}
+
+				*table_pointer = table_info.pointer;
+				goto cleanup;
+			}
+		}
+	}
+
+	/* Did not find the table */
+
+	status = AE_NOT_EXIST;
+
+
+cleanup:
+	acpi_os_unmap_memory (rsdt_info.pointer, (acpi_size) rsdt_info.pointer->length);
+	return_ACPI_STATUS (status);
+}
+
+
+/* TBD: Move to a new file */
+
+#if ACPI_MACHINE_WIDTH != 16
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_find_root_pointer
+ *
+ * PARAMETERS:  **rsdp_address          - Where to place the RSDP address
+ *              Flags                   - Logical/Physical addressing
  *
  * RETURN:      Status, Physical address of the RSDP
  *
@@ -50,35 +306,36 @@
 
 acpi_status
 acpi_find_root_pointer (
-	u32                     flags,
-	ACPI_PHYSICAL_ADDRESS   *rsdp_physical_address)
+	u32                             flags,
+	struct acpi_pointer             *rsdp_address)
 {
-	acpi_table_desc         table_info;
-	acpi_status             status;
+	struct acpi_table_desc          table_info;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Acpi_find_root_pointer");
+	ACPI_FUNCTION_TRACE ("acpi_find_root_pointer");
 
 
 	/* Get the RSDP */
 
 	status = acpi_tb_find_rsdp (&table_info, flags);
 	if (ACPI_FAILURE (status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "RSDP structure not found\n"));
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "RSDP structure not found, %s Flags=%X\n",
+			acpi_format_exception (status), flags));
 		return_ACPI_STATUS (AE_NO_ACPI_TABLES);
 	}
 
-	*rsdp_physical_address = table_info.physical_address;
-
+	rsdp_address->pointer_type = ACPI_PHYSICAL_POINTER;
+	rsdp_address->pointer.physical = table_info.physical_address;
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_scan_memory_for_rsdp
+ * FUNCTION:    acpi_tb_scan_memory_for_rsdp
  *
- * PARAMETERS:  Start_address       - Starting pointer for search
+ * PARAMETERS:  start_address       - Starting pointer for search
  *              Length              - Maximum length to search
  *
  * RETURN:      Pointer to the RSDP if found, otherwise NULL.
@@ -89,27 +346,27 @@
 
 u8 *
 acpi_tb_scan_memory_for_rsdp (
-	u8                      *start_address,
-	u32                     length)
+	u8                              *start_address,
+	u32                             length)
 {
-	u32                     offset;
-	u8                      *mem_rover;
+	u32                             offset;
+	u8                              *mem_rover;
 
 
-	FUNCTION_TRACE ("Tb_scan_memory_for_rsdp");
+	ACPI_FUNCTION_TRACE ("tb_scan_memory_for_rsdp");
 
 
 	/* Search from given start addr for the requested length  */
 
 	for (offset = 0, mem_rover = start_address;
 		 offset < length;
-		 offset += RSDP_SCAN_STEP, mem_rover += RSDP_SCAN_STEP) {
+		 offset += ACPI_RSDP_SCAN_STEP, mem_rover += ACPI_RSDP_SCAN_STEP) {
 
 		/* The signature and checksum must both be correct */
 
-		if (STRNCMP ((NATIVE_CHAR *) mem_rover,
+		if (ACPI_STRNCMP ((char *) mem_rover,
 				RSDP_SIG, sizeof (RSDP_SIG)-1) == 0 &&
-			acpi_tb_checksum (mem_rover, RSDP_CHECKSUM_LENGTH) == 0) {
+			acpi_tb_checksum (mem_rover, ACPI_RSDP_CHECKSUM_LENGTH) == 0) {
 			/* If so, we have found the RSDP */
 
 			ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
@@ -121,25 +378,24 @@
 	/* Searched entire block, no RSDP was found */
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,"Searched entire block, no RSDP was found.\n"));
-
 	return_PTR (NULL);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_tb_find_rsdp
+ * FUNCTION:    acpi_tb_find_rsdp
  *
- * PARAMETERS:  *Table_info             - Where the table info is returned
+ * PARAMETERS:  *table_info             - Where the table info is returned
  *              Flags                   - Current memory mode (logical vs.
  *                                        physical addressing)
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Search lower 1_mbyte of memory for the root system descriptor
+ * DESCRIPTION: search lower 1_mbyte of memory for the root system descriptor
  *              pointer structure.  If it is found, set *RSDP to point to it.
  *
- *              NOTE: The RSDP must be either in the first 1_k of the Extended
+ *              NOTE: The RSDp must be either in the first 1_k of the Extended
  *              BIOS Data Area or between E0000 and FFFFF (ACPI 1.0 section
  *              5.2.2; assertion #421).
  *
@@ -147,16 +403,16 @@
 
 acpi_status
 acpi_tb_find_rsdp (
-	acpi_table_desc         *table_info,
-	u32                     flags)
+	struct acpi_table_desc          *table_info,
+	u32                             flags)
 {
-	u8                      *table_ptr;
-	u8                      *mem_rover;
-	u64                     phys_addr;
-	acpi_status             status = AE_OK;
+	u8                              *table_ptr;
+	u8                              *mem_rover;
+	u64                             phys_addr;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE ("Tb_find_rsdp");
+	ACPI_FUNCTION_TRACE ("tb_find_rsdp");
 
 
 	/*
@@ -166,51 +422,52 @@
 		/*
 		 * 1) Search EBDA (low memory) paragraphs
 		 */
-		status = acpi_os_map_memory (LO_RSDP_WINDOW_BASE, LO_RSDP_WINDOW_SIZE,
+		status = acpi_os_map_memory ((u64) ACPI_LO_RSDP_WINDOW_BASE, ACPI_LO_RSDP_WINDOW_SIZE,
 				  (void **) &table_ptr);
 		if (ACPI_FAILURE (status)) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %X for length %X\n",
+				ACPI_LO_RSDP_WINDOW_BASE, ACPI_LO_RSDP_WINDOW_SIZE));
 			return_ACPI_STATUS (status);
 		}
 
-		mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, LO_RSDP_WINDOW_SIZE);
-		acpi_os_unmap_memory (table_ptr, LO_RSDP_WINDOW_SIZE);
+		mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, ACPI_LO_RSDP_WINDOW_SIZE);
+		acpi_os_unmap_memory (table_ptr, ACPI_LO_RSDP_WINDOW_SIZE);
 
 		if (mem_rover) {
 			/* Found it, return the physical address */
 
-			phys_addr = LO_RSDP_WINDOW_BASE;
-			phys_addr += (mem_rover - table_ptr);
+			phys_addr = ACPI_LO_RSDP_WINDOW_BASE;
+			phys_addr += ACPI_PTR_DIFF (mem_rover,table_ptr);
 
 			table_info->physical_address = phys_addr;
-
 			return_ACPI_STATUS (AE_OK);
 		}
 
 		/*
 		 * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h
 		 */
-		status = acpi_os_map_memory (HI_RSDP_WINDOW_BASE, HI_RSDP_WINDOW_SIZE,
+		status = acpi_os_map_memory ((u64) ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE,
 				  (void **) &table_ptr);
 		if (ACPI_FAILURE (status)) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %X for length %X\n",
+				ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE));
 			return_ACPI_STATUS (status);
 		}
 
-		mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, HI_RSDP_WINDOW_SIZE);
-		acpi_os_unmap_memory (table_ptr, HI_RSDP_WINDOW_SIZE);
+		mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, ACPI_HI_RSDP_WINDOW_SIZE);
+		acpi_os_unmap_memory (table_ptr, ACPI_HI_RSDP_WINDOW_SIZE);
 
 		if (mem_rover) {
 			/* Found it, return the physical address */
 
-			phys_addr = HI_RSDP_WINDOW_BASE;
-			phys_addr += (mem_rover - table_ptr);
+			phys_addr = ACPI_HI_RSDP_WINDOW_BASE;
+			phys_addr += ACPI_PTR_DIFF (mem_rover, table_ptr);
 
 			table_info->physical_address = phys_addr;
-
 			return_ACPI_STATUS (AE_OK);
 		}
 	}
 
-
 	/*
 	 * Physical addressing
 	 */
@@ -218,212 +475,32 @@
 		/*
 		 * 1) Search EBDA (low memory) paragraphs
 		 */
-		mem_rover = acpi_tb_scan_memory_for_rsdp ((u8 *) LO_RSDP_WINDOW_BASE,
-				  LO_RSDP_WINDOW_SIZE);
+		mem_rover = acpi_tb_scan_memory_for_rsdp (ACPI_PHYSADDR_TO_PTR (ACPI_LO_RSDP_WINDOW_BASE),
+				  ACPI_LO_RSDP_WINDOW_SIZE);
 		if (mem_rover) {
 			/* Found it, return the physical address */
 
-			table_info->physical_address = (ACPI_TBLPTR) mem_rover;
+			table_info->physical_address = ACPI_TO_INTEGER (mem_rover);
 			return_ACPI_STATUS (AE_OK);
 		}
 
 		/*
 		 * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h
 		 */
-		mem_rover = acpi_tb_scan_memory_for_rsdp ((u8 *) HI_RSDP_WINDOW_BASE,
-				  HI_RSDP_WINDOW_SIZE);
+		mem_rover = acpi_tb_scan_memory_for_rsdp (ACPI_PHYSADDR_TO_PTR (ACPI_HI_RSDP_WINDOW_BASE),
+				  ACPI_HI_RSDP_WINDOW_SIZE);
 		if (mem_rover) {
 			/* Found it, return the physical address */
 
-			table_info->physical_address = (ACPI_TBLPTR) mem_rover;
+			table_info->physical_address = ACPI_TO_INTEGER (mem_rover);
 			return_ACPI_STATUS (AE_OK);
 		}
 	}
 
-
 	/* RSDP signature was not found */
 
 	return_ACPI_STATUS (AE_NOT_FOUND);
 }
 
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_get_firmware_table
- *
- * PARAMETERS:  Signature       - Any ACPI table signature
- *              Instance        - the non zero instance of the table, allows
- *                                support for multiple tables of the same type
- *              Flags           - 0: Physical/Virtual support
- *              Ret_buffer      - pointer to a structure containing a buffer to
- *                                receive the table
- *
- * RETURN:      Status
- *
- * DESCRIPTION: This function is called to get an ACPI table.  The caller
- *              supplies an Out_buffer large enough to contain the entire ACPI
- *              table.  Upon completion
- *              the Out_buffer->Length field will indicate the number of bytes
- *              copied into the Out_buffer->Buf_ptr buffer. This table will be
- *              a complete table including the header.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_get_firmware_table (
-	acpi_string             signature,
-	u32                     instance,
-	u32                     flags,
-	acpi_table_header       **table_pointer)
-{
-	ACPI_PHYSICAL_ADDRESS   physical_address;
-	acpi_table_header       *rsdt_ptr = NULL;
-	acpi_table_header       *table_ptr;
-	acpi_status             status;
-	u32                     rsdt_size = 0;
-	u32                     table_size;
-	u32                     table_count;
-	u32                     i;
-	u32                     j;
-
-
-	FUNCTION_TRACE ("Acpi_get_firmware_table");
-
-
-	/*
-	 * Ensure that at least the table manager is initialized.  We don't
-	 * require that the entire ACPI subsystem is up for this interface
-	 */
-
-	/*
-	 *  If we have a buffer, we must have a length too
-	 */
-	if ((instance == 0)                 ||
-		(!signature)                    ||
-		(!table_pointer)) {
-		return_ACPI_STATUS (AE_BAD_PARAMETER);
-	}
-
-	if (!acpi_gbl_RSDP) {
-		/* Get the RSDP */
-
-		status = acpi_os_get_root_pointer (flags, &physical_address);
-		if (ACPI_FAILURE (status)) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP  not found\n"));
-			return_ACPI_STATUS (AE_NO_ACPI_TABLES);
-		}
-
-		/* Map and validate the RSDP */
-
-		if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) {
-			status = acpi_os_map_memory (physical_address, sizeof (RSDP_DESCRIPTOR),
-					  (void **) &acpi_gbl_RSDP);
-			if (ACPI_FAILURE (status)) {
-				return_ACPI_STATUS (status);
-			}
-		}
-		else {
-			acpi_gbl_RSDP = (void *) (NATIVE_UINT) physical_address;
-		}
-
-		/*
-		 *  The signature and checksum must both be correct
-		 */
-		if (STRNCMP ((NATIVE_CHAR *) acpi_gbl_RSDP, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) {
-			/* Nope, BAD Signature */
-
-			status = AE_BAD_SIGNATURE;
-			goto cleanup;
-		}
-
-		if (acpi_tb_checksum (acpi_gbl_RSDP, RSDP_CHECKSUM_LENGTH) != 0) {
-			/* Nope, BAD Checksum */
-
-			status = AE_BAD_CHECKSUM;
-			goto cleanup;
-		}
-	}
-
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-		"RSDP located at %p, RSDT physical=%8.8X%8.8X \n",
-		acpi_gbl_RSDP, HIDWORD(acpi_gbl_RSDP->rsdt_physical_address),
-		LODWORD(acpi_gbl_RSDP->rsdt_physical_address)));
-
-
-	/* Get the RSDT and validate it */
-
-	physical_address = acpi_tb_get_rsdt_address ();
-	status = acpi_tb_get_table_pointer (physical_address, flags, &rsdt_size, &rsdt_ptr);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
-
-	status = acpi_tb_validate_rsdt (rsdt_ptr);
-	if (ACPI_FAILURE (status)) {
-		goto cleanup;
-	}
-
-
-	/* Get the number of table pointers within the RSDT */
-
-	table_count = acpi_tb_get_table_count (acpi_gbl_RSDP, rsdt_ptr);
-
-
-	/*
-	 * Search the RSDT/XSDT for the correct instance of the
-	 * requested table
-	 */
-	for (i = 0, j = 0; i < table_count; i++) {
-		/* Get the next table pointer */
-
-		if (acpi_gbl_RSDP->revision < 2) {
-			physical_address = ((RSDT_DESCRIPTOR *) rsdt_ptr)->table_offset_entry[i];
-		}
-		else {
-			physical_address = (ACPI_PHYSICAL_ADDRESS)
-				ACPI_GET_ADDRESS (((xsdt_descriptor *) rsdt_ptr)->table_offset_entry[i]);
-		}
-
-		/* Get addressibility if necessary */
-
-		status = acpi_tb_get_table_pointer (physical_address, flags, &table_size, &table_ptr);
-		if (ACPI_FAILURE (status)) {
-			goto cleanup;
-		}
-
-		/* Compare table signatures and table instance */
-
-		if (!STRNCMP ((char *) table_ptr, signature, STRLEN (signature))) {
-			/* An instance of the table was found */
-
-			j++;
-			if (j >= instance) {
-				/* Found the correct instance */
-
-				*table_pointer = table_ptr;
-				goto cleanup;
-			}
-		}
-
-		/* Delete table mapping if using virtual addressing */
-
-		if ((table_size) &&
-			((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING)) {
-			acpi_os_unmap_memory (table_ptr, table_size);
-		}
-	}
-
-	/* Did not find the table */
-
-	status = AE_NOT_EXIST;
-
-
-cleanup:
-	if (rsdt_size) {
-		acpi_os_unmap_memory (rsdt_ptr, rsdt_size);
-	}
-	return_ACPI_STATUS (status);
-}
-
+#endif
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/tables.c linux-2.4.22-pre2/drivers/acpi/tables.c
--- linux-2.4.21/drivers/acpi/tables.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/tables.c	2003-06-26 21:43:12.000000000 +0000
@@ -0,0 +1,564 @@
+/*
+ *  acpi_tables.c - ACPI Boot-Time Table Parsing
+ *
+ *  Copyright (C) 2001 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/config.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/smp.h>
+#include <linux/string.h>
+#include <linux/types.h>
+#include <linux/irq.h>
+#include <linux/errno.h>
+#include <linux/acpi.h>
+
+#define PREFIX			"ACPI: "
+
+#define ACPI_MAX_TABLES		256
+
+static char *acpi_table_signatures[ACPI_TABLE_COUNT] = {
+	[ACPI_TABLE_UNKNOWN]	= "????",
+	[ACPI_APIC]		= "APIC",
+	[ACPI_BOOT]		= "BOOT",
+	[ACPI_DBGP]		= "DBGP",
+	[ACPI_DSDT]		= "DSDT",
+	[ACPI_ECDT]		= "ECDT",
+	[ACPI_ETDT]		= "ETDT",
+	[ACPI_FADT]		= "FACP",
+	[ACPI_FACS]		= "FACS",
+	[ACPI_OEMX]		= "OEM",
+	[ACPI_PSDT]		= "PSDT",
+	[ACPI_SBST]		= "SBST",
+	[ACPI_SLIT]		= "SLIT",
+	[ACPI_SPCR]		= "SPCR",
+	[ACPI_SRAT]		= "SRAT",
+	[ACPI_SSDT]		= "SSDT",
+	[ACPI_SPMI]		= "SPMI",
+	[ACPI_HPET]		= "HPET",
+};
+
+/* System Description Table (RSDT/XSDT) */
+struct acpi_table_sdt {
+	unsigned long		pa;		/* Physical Address */
+	unsigned long		count;		/* Table count */
+	struct {
+		unsigned long		pa;
+		enum acpi_table_id	id;
+		unsigned long		size;
+	}			entry[ACPI_MAX_TABLES];
+} __attribute__ ((packed));
+
+static struct acpi_table_sdt	sdt;
+
+void
+acpi_table_print (
+	struct acpi_table_header *header,
+	unsigned long		phys_addr)
+{
+	char			*name = NULL;
+
+	if (!header)
+		return;
+
+	/* Some table signatures aren't good table names */
+
+	if (!strncmp((char *) &header->signature,
+		acpi_table_signatures[ACPI_APIC],
+		sizeof(header->signature))) {
+		name = "MADT";
+	}
+	else if (!strncmp((char *) &header->signature,
+		acpi_table_signatures[ACPI_FADT],
+		sizeof(header->signature))) {
+		name = "FADT";
+	}
+	else
+		name = header->signature;
+
+	printk(KERN_INFO PREFIX "%.4s (v%3.3d %6.6s %8.8s %5.5d.%5.5d) @ 0x%p\n",
+		name, header->revision, header->oem_id,
+		header->oem_table_id, header->oem_revision >> 16,
+		header->oem_revision & 0xffff, (void *) phys_addr);
+}
+
+
+void
+acpi_table_print_madt_entry (
+	acpi_table_entry_header	*header)
+{
+	if (!header)
+		return;
+
+	switch (header->type) {
+
+	case ACPI_MADT_LAPIC:
+	{
+		struct acpi_table_lapic *p =
+			(struct acpi_table_lapic*) header;
+		printk(KERN_INFO PREFIX "LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n",
+			p->acpi_id, p->id, p->flags.enabled?"enabled":"disabled");
+	}
+		break;
+
+	case ACPI_MADT_IOAPIC:
+	{
+		struct acpi_table_ioapic *p =
+			(struct acpi_table_ioapic*) header;
+		printk(KERN_INFO PREFIX "IOAPIC (id[0x%02x] address[0x%08x] global_irq_base[0x%x])\n",
+			p->id, p->address, p->global_irq_base);
+	}
+		break;
+
+	case ACPI_MADT_INT_SRC_OVR:
+	{
+		struct acpi_table_int_src_ovr *p =
+			(struct acpi_table_int_src_ovr*) header;
+		printk(KERN_INFO PREFIX "INT_SRC_OVR (bus[%d] irq[0x%x] global_irq[0x%x] polarity[0x%x] trigger[0x%x])\n",
+			p->bus, p->bus_irq, p->global_irq, p->flags.polarity, p->flags.trigger);
+	}
+		break;
+
+	case ACPI_MADT_NMI_SRC:
+	{
+		struct acpi_table_nmi_src *p =
+			(struct acpi_table_nmi_src*) header;
+		printk(KERN_INFO PREFIX "NMI_SRC (polarity[0x%x] trigger[0x%x] global_irq[0x%x])\n",
+			p->flags.polarity, p->flags.trigger, p->global_irq);
+	}
+		break;
+
+	case ACPI_MADT_LAPIC_NMI:
+	{
+		struct acpi_table_lapic_nmi *p =
+			(struct acpi_table_lapic_nmi*) header;
+		printk(KERN_INFO PREFIX "LAPIC_NMI (acpi_id[0x%02x] polarity[0x%x] trigger[0x%x] lint[0x%x])\n",
+			p->acpi_id, p->flags.polarity, p->flags.trigger, p->lint);
+	}
+		break;
+
+	case ACPI_MADT_LAPIC_ADDR_OVR:
+	{
+		struct acpi_table_lapic_addr_ovr *p =
+			(struct acpi_table_lapic_addr_ovr*) header;
+		printk(KERN_INFO PREFIX "LAPIC_ADDR_OVR (address[%p])\n",
+			(void *) (unsigned long) p->address);
+	}
+		break;
+
+	case ACPI_MADT_IOSAPIC:
+	{
+		struct acpi_table_iosapic *p =
+			(struct acpi_table_iosapic*) header;
+		printk(KERN_INFO PREFIX "IOSAPIC (id[0x%x] global_irq_base[0x%x] address[%p])\n",
+			p->id, p->global_irq_base, (void *) (unsigned long) p->address);
+	}
+		break;
+
+	case ACPI_MADT_LSAPIC:
+	{
+		struct acpi_table_lsapic *p =
+			(struct acpi_table_lsapic*) header;
+		printk(KERN_INFO PREFIX "LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n",
+			p->acpi_id, p->id, p->eid, p->flags.enabled?"enabled":"disabled");
+	}
+		break;
+
+	case ACPI_MADT_PLAT_INT_SRC:
+	{
+		struct acpi_table_plat_int_src *p =
+			(struct acpi_table_plat_int_src*) header;
+		printk(KERN_INFO PREFIX "PLAT_INT_SRC (polarity[0x%x] trigger[0x%x] type[0x%x] id[0x%04x] eid[0x%x] iosapic_vector[0x%x] global_irq[0x%x]\n",
+			p->flags.polarity, p->flags.trigger, p->type, p->id, p->eid, p->iosapic_vector, p->global_irq);
+	}
+		break;
+
+	default:
+		printk(KERN_WARNING PREFIX "Found unsupported MADT entry (type = 0x%x)\n",
+			header->type);
+		break;
+	}
+}
+
+
+static int
+acpi_table_compute_checksum (
+	void			*table_pointer,
+	unsigned long		length)
+{
+	u8			*p = (u8 *) table_pointer;
+	unsigned long		remains = length;
+	unsigned long		sum = 0;
+
+	if (!p || !length)
+		return -EINVAL;
+
+	while (remains--)
+		sum += *p++;
+
+	return (sum & 0xFF);
+}
+
+int __init
+acpi_get_table_header_early (
+	enum acpi_table_id	id,
+	struct acpi_table_header **header)
+{
+	int i;
+	enum acpi_table_id temp_id;
+
+	/* DSDT is different from the rest */
+	if (id == ACPI_DSDT)
+		temp_id = ACPI_FADT;
+	else
+		temp_id = id;
+
+	/* Locate the table. */
+
+	for (i = 0; i < sdt.count; i++) {
+		if (sdt.entry[i].id != temp_id)
+			continue;
+		*header = (void *)
+			__acpi_map_table(sdt.entry[i].pa, sdt.entry[i].size);
+		if (!*header) {
+			printk(KERN_WARNING PREFIX "Unable to map %s\n",
+			       acpi_table_signatures[temp_id]);
+			return -ENODEV;
+		}
+		break;
+	}
+
+	if (!*header) {
+		printk(KERN_WARNING PREFIX "%s not present\n",
+		       acpi_table_signatures[id]);
+		return -ENODEV;
+	}
+
+	/* Map the DSDT header via the pointer in the FADT */
+	if (id == ACPI_DSDT) {
+		struct acpi_table_fadt *fadt = (struct acpi_table_fadt *) *header;
+
+		*header = (void *) __acpi_map_table(fadt->dsdt_addr,
+				sizeof(struct acpi_table_header));
+		if (!*header) {
+			printk(KERN_WARNING PREFIX "Unable to map DSDT\n");
+			return -ENODEV;
+		}
+	}
+
+	return 0;
+}
+	 
+
+int __init
+acpi_table_parse_madt_family (
+	enum acpi_table_id	id,
+	unsigned long		madt_size,
+	int			entry_id,
+	acpi_madt_entry_handler	handler)
+{
+	void			*madt = NULL;
+	acpi_table_entry_header	*entry = NULL;
+	unsigned long		count = 0;
+	unsigned long		madt_end = 0;
+	int			i = 0;
+
+	if (!handler)
+		return -EINVAL;
+
+	/* Locate the MADT (if exists). There should only be one. */
+
+	for (i = 0; i < sdt.count; i++) {
+		if (sdt.entry[i].id != id)
+			continue;
+		madt = (void *)
+			__acpi_map_table(sdt.entry[i].pa, sdt.entry[i].size);
+		if (!madt) {
+			printk(KERN_WARNING PREFIX "Unable to map %s\n",
+			       acpi_table_signatures[id]);
+			return -ENODEV;
+		}
+		break;
+	}
+
+	if (!madt) {
+		printk(KERN_WARNING PREFIX "%s not present\n",
+		       acpi_table_signatures[id]);
+		return -ENODEV;
+	}
+
+	madt_end = (unsigned long) madt + sdt.entry[i].size;
+
+	/* Parse all entries looking for a match. */
+
+	entry = (acpi_table_entry_header *)
+		((unsigned long) madt + madt_size);
+
+	while (((unsigned long) entry) < madt_end) {
+		if (entry->type == entry_id) {
+			count++;
+			handler(entry);
+		}
+		entry = (acpi_table_entry_header *)
+			((unsigned long) entry + entry->length);
+	}
+
+	return count;
+}
+
+
+int __init
+acpi_table_parse_madt (
+	enum acpi_madt_entry_id	id,
+	acpi_madt_entry_handler	handler)
+{
+	return acpi_table_parse_madt_family(ACPI_APIC, sizeof(struct acpi_table_madt),
+					    id, handler);
+}
+
+
+int __init
+acpi_table_parse (
+	enum acpi_table_id	id,
+	acpi_table_handler	handler)
+{
+	int			count = 0;
+	int			i = 0;
+
+	if (!handler)
+		return -EINVAL;
+
+	for (i = 0; i < sdt.count; i++) {
+		if (sdt.entry[i].id != id)
+			continue;
+		handler(sdt.entry[i].pa, sdt.entry[i].size);
+		count++;
+	}
+
+	return count;
+}
+
+
+static int __init
+acpi_table_get_sdt (
+	struct acpi_table_rsdp	*rsdp)
+{
+	struct acpi_table_header *header = NULL;
+	int			i, id = 0;
+
+	if (!rsdp)
+		return -EINVAL;
+
+	/* First check XSDT (but only on ACPI 2.0-compatible systems) */
+
+	if ((rsdp->revision >= 2) &&
+		(((struct acpi20_table_rsdp*)rsdp)->xsdt_address)) {
+			
+		struct acpi_table_xsdt	*mapped_xsdt = NULL;
+
+		sdt.pa = ((struct acpi20_table_rsdp*)rsdp)->xsdt_address;
+
+		/* map in just the header */
+		header = (struct acpi_table_header *)
+			__acpi_map_table(sdt.pa, sizeof(struct acpi_table_header));
+
+		if (!header) {
+			printk(KERN_WARNING PREFIX "Unable to map XSDT header\n");
+			return -ENODEV;
+		}
+
+		/* remap in the entire table before processing */
+		mapped_xsdt = (struct acpi_table_xsdt *)
+			__acpi_map_table(sdt.pa, header->length);
+		if (!mapped_xsdt) {
+			printk(KERN_WARNING PREFIX "Unable to map XSDT\n");
+			return -ENODEV;
+		}
+		header = &mapped_xsdt->header;
+
+		if (strncmp(header->signature, "XSDT", 4)) {
+			printk(KERN_WARNING PREFIX "XSDT signature incorrect\n");
+			return -ENODEV;
+		}
+
+		if (acpi_table_compute_checksum(header, header->length)) {
+			printk(KERN_WARNING PREFIX "Invalid XSDT checksum\n");
+			return -ENODEV;
+		}
+
+		sdt.count = (header->length - sizeof(struct acpi_table_header)) >> 3;
+		if (sdt.count > ACPI_MAX_TABLES) {
+			printk(KERN_WARNING PREFIX "Truncated %lu XSDT entries\n",
+				(sdt.count - ACPI_MAX_TABLES));
+			sdt.count = ACPI_MAX_TABLES;
+		}
+
+		for (i = 0; i < sdt.count; i++)
+			sdt.entry[i].pa = (unsigned long) mapped_xsdt->entry[i];
+	}
+
+	/* Then check RSDT */
+
+	else if (rsdp->rsdt_address) {
+
+		struct acpi_table_rsdt	*mapped_rsdt = NULL;
+
+		sdt.pa = rsdp->rsdt_address;
+
+		/* map in just the header */
+		header = (struct acpi_table_header *)
+			__acpi_map_table(sdt.pa, sizeof(struct acpi_table_header));
+		if (!header) {
+			printk(KERN_WARNING PREFIX "Unable to map RSDT header\n");
+			return -ENODEV;
+		}
+
+		/* remap in the entire table before processing */
+		mapped_rsdt = (struct acpi_table_rsdt *)
+			__acpi_map_table(sdt.pa, header->length);
+		if (!mapped_rsdt) {
+			printk(KERN_WARNING PREFIX "Unable to map RSDT\n");
+			return -ENODEV;
+		}
+		header = &mapped_rsdt->header;
+
+		if (strncmp(header->signature, "RSDT", 4)) {
+			printk(KERN_WARNING PREFIX "RSDT signature incorrect\n");
+			return -ENODEV;
+		}
+
+		if (acpi_table_compute_checksum(header, header->length)) {
+			printk(KERN_WARNING PREFIX "Invalid RSDT checksum\n");
+			return -ENODEV;
+		}
+
+		sdt.count = (header->length - sizeof(struct acpi_table_header)) >> 2;
+		if (sdt.count > ACPI_MAX_TABLES) {
+			printk(KERN_WARNING PREFIX "Truncated %lu RSDT entries\n",
+				(sdt.count - ACPI_TABLE_COUNT));
+			sdt.count = ACPI_MAX_TABLES;
+		}
+
+		for (i = 0; i < sdt.count; i++)
+			sdt.entry[i].pa = (unsigned long) mapped_rsdt->entry[i];
+	}
+
+	else {
+		printk(KERN_WARNING PREFIX "No System Description Table (RSDT/XSDT) specified in RSDP\n");
+		return -ENODEV;
+	}
+
+	acpi_table_print(header, sdt.pa);
+
+	for (i = 0; i < sdt.count; i++) {
+
+		/* map in just the header */
+		header = (struct acpi_table_header *)
+			__acpi_map_table(sdt.entry[i].pa,
+				sizeof(struct acpi_table_header));
+		if (!header)
+			continue;
+
+		/* remap in the entire table before processing */
+		header = (struct acpi_table_header *)
+			__acpi_map_table(sdt.entry[i].pa,
+				header->length);
+		if (!header)
+			continue;
+	               
+		acpi_table_print(header, sdt.entry[i].pa);
+
+		if (acpi_table_compute_checksum(header, header->length)) {
+			printk(KERN_WARNING "  >>> ERROR: Invalid checksum\n");
+			continue;
+		}
+
+		sdt.entry[i].size = header->length;
+
+		for (id = 0; id < ACPI_TABLE_COUNT; id++) {
+			if (!strncmp((char *) &header->signature,
+				acpi_table_signatures[id],
+				sizeof(header->signature))) {
+				sdt.entry[i].id = id;
+			}
+		}
+	}
+
+	/* 
+	 * The DSDT is *not* in the RSDT (why not? no idea.) but we want
+	 * to print its info, because this is what people usually blacklist
+	 * against. Unfortunately, we don't know the phys_addr, so just
+	 * print 0. Maybe no one will notice.
+	 */
+	if(!acpi_get_table_header_early(ACPI_DSDT, &header))
+		acpi_table_print(header, 0);
+
+	return 0;
+}
+
+
+int __init
+acpi_table_init (void)
+{
+	struct acpi_table_rsdp	*rsdp = NULL;
+	unsigned long		rsdp_phys = 0;
+	int			result = 0;
+
+	memset(&sdt, 0, sizeof(struct acpi_table_sdt));
+
+	/* Locate and map the Root System Description Table (RSDP) */
+
+	rsdp_phys = acpi_find_rsdp();
+	if (!rsdp_phys) {
+		printk(KERN_ERR PREFIX "Unable to locate RSDP\n");
+		return -ENODEV;
+	}
+
+	rsdp = (struct acpi_table_rsdp *) __va(rsdp_phys);
+	if (!rsdp) {
+		printk(KERN_WARNING PREFIX "Unable to map RSDP\n");
+		return -ENODEV;
+	}
+
+	printk(KERN_INFO PREFIX "RSDP (v%3.3d %6.6s                     ) @ 0x%p\n",
+		rsdp->revision, rsdp->oem_id, (void *) rsdp_phys);
+
+	if (rsdp->revision < 2)
+		result = acpi_table_compute_checksum(rsdp, sizeof(struct acpi_table_rsdp));
+	else
+		result = acpi_table_compute_checksum(rsdp, ((struct acpi20_table_rsdp *)rsdp)->length);
+
+	if (result) {
+		printk(KERN_WARNING "  >>> ERROR: Invalid checksum\n");
+		return -ENODEV;
+	}
+
+	/* Locate and map the System Description table (RSDT/XSDT) */
+
+	if (acpi_table_get_sdt(rsdp))
+		return -ENODEV;
+
+	return 0;
+}
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/thermal.c linux-2.4.22-pre2/drivers/acpi/thermal.c
--- linux-2.4.21/drivers/acpi/thermal.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/thermal.c	2003-06-26 21:43:28.000000000 +0000
@@ -0,0 +1,1359 @@
+/*
+ *  acpi_thermal.c - ACPI Thermal Zone Driver ($Revision: 40 $)
+ *
+ *  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.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This driver fully implements the ACPI thermal policy as described in the
+ *  ACPI 2.0 Specification.
+ *
+ *  TBD: 1. Implement passive cooling hysteresis.
+ *       2. Enhance passive cooling (CPU) states/limit interface to support
+ *          concepts of 'multiple limiters', upper/lower limits, etc.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/compatmac.h>
+#include <linux/proc_fs.h>
+#include <linux/sched.h>
+#include <linux/kmod.h>
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+
+
+#define _COMPONENT		ACPI_THERMAL_COMPONENT
+ACPI_MODULE_NAME		("acpi_thermal")
+
+MODULE_AUTHOR("Paul Diefenbaugh");
+MODULE_DESCRIPTION(ACPI_THERMAL_DRIVER_NAME);
+MODULE_LICENSE("GPL");
+
+static int tzp = 0;
+MODULE_PARM(tzp, "i");
+MODULE_PARM_DESC(tzp, "Thermal zone polling frequency, in 1/10 seconds.\n");
+
+#define PREFIX			"ACPI: "
+
+
+#define ACPI_THERMAL_MAX_ACTIVE	10
+
+#define KELVIN_TO_CELSIUS(t)    (long)(((long)t-2732>=0) ? ((long)t-2732+5)/10 : ((long)t-2732-5)/10)
+#define CELSIUS_TO_KELVIN(t)	((t+273)*10)
+
+static int acpi_thermal_add (struct acpi_device *device);
+static int acpi_thermal_remove (struct acpi_device *device, int type);
+
+static struct acpi_driver acpi_thermal_driver = {
+	.name =		ACPI_THERMAL_DRIVER_NAME,
+	.class =	ACPI_THERMAL_CLASS,
+	.ids =		ACPI_THERMAL_HID,
+	.ops =		{
+				.add =		acpi_thermal_add,
+				.remove =	acpi_thermal_remove,
+			},
+};
+
+struct acpi_thermal_state {
+	u8			critical:1;
+	u8			hot:1;
+	u8			passive:1;
+	u8			active:1;
+	u8			reserved:4;
+	int			active_index;
+};
+
+struct acpi_thermal_state_flags {
+	u8			valid:1;
+	u8			enabled:1;
+	u8			reserved:6;
+};
+
+struct acpi_thermal_critical {
+	struct acpi_thermal_state_flags flags;
+	unsigned long		temperature;
+};
+
+struct acpi_thermal_hot {
+	struct acpi_thermal_state_flags flags;
+	unsigned long		temperature;
+};
+
+struct acpi_thermal_passive {
+	struct acpi_thermal_state_flags flags;
+	unsigned long		temperature;
+	unsigned long		tc1;
+	unsigned long		tc2;
+	unsigned long		tsp;
+	struct acpi_handle_list	devices;
+};
+
+struct acpi_thermal_active {
+	struct acpi_thermal_state_flags flags;
+	unsigned long		temperature;
+	struct acpi_handle_list	devices;
+};
+
+struct acpi_thermal_trips {
+	struct acpi_thermal_critical critical;
+	struct acpi_thermal_hot	hot;
+	struct acpi_thermal_passive passive;
+	struct acpi_thermal_active active[ACPI_THERMAL_MAX_ACTIVE];
+};
+
+struct acpi_thermal_flags {
+	u8			cooling_mode:1;		/* _SCP */
+	u8			devices:1;		/* _TZD */
+	u8			reserved:6;
+};
+
+struct acpi_thermal {
+	acpi_handle		handle;
+	acpi_bus_id		name;
+	unsigned long		temperature;
+	unsigned long		last_temperature;
+	unsigned long		polling_frequency;
+	u8			cooling_mode;
+	struct acpi_thermal_flags flags;
+	struct acpi_thermal_state state;
+	struct acpi_thermal_trips trips;
+	struct acpi_handle_list	devices;
+	struct timer_list	timer;
+};
+
+
+/* --------------------------------------------------------------------------
+                             Thermal Zone Management
+   -------------------------------------------------------------------------- */
+
+static int
+acpi_thermal_get_temperature (
+	struct acpi_thermal *tz)
+{
+	acpi_status		status = AE_OK;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_get_temperature");
+
+	if (!tz)
+		return_VALUE(-EINVAL);
+
+	tz->last_temperature = tz->temperature;
+
+	status = acpi_evaluate_integer(tz->handle, "_TMP", NULL, &tz->temperature);
+	if (ACPI_FAILURE(status))
+		return -ENODEV;
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n", tz->temperature));
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_thermal_get_polling_frequency (
+	struct acpi_thermal	*tz)
+{
+	acpi_status		status = AE_OK;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_get_polling_frequency");
+
+	if (!tz)
+		return_VALUE(-EINVAL);
+
+	status = acpi_evaluate_integer(tz->handle, "_TZP", NULL, &tz->polling_frequency);
+	if (ACPI_FAILURE(status))
+		return_VALUE(-ENODEV);
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n", tz->polling_frequency));
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_thermal_set_polling (
+	struct acpi_thermal	*tz,
+	int			seconds)
+{
+	ACPI_FUNCTION_TRACE("acpi_thermal_set_polling");
+
+	if (!tz)
+		return_VALUE(-EINVAL);
+
+	tz->polling_frequency = seconds * 10;	/* Convert value to deci-seconds */
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency set to %lu seconds\n", tz->polling_frequency));
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_thermal_set_cooling_mode (
+	struct acpi_thermal	*tz,
+	int			mode)
+{
+	acpi_status		status = AE_OK;
+	union acpi_object	arg0 = {ACPI_TYPE_INTEGER};
+	struct acpi_object_list	arg_list = {1, &arg0};
+	acpi_handle		handle = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_set_cooling_mode");
+
+	if (!tz)
+		return_VALUE(-EINVAL);
+
+	status = acpi_get_handle(tz->handle, "_SCP", &handle);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n"));
+		return_VALUE(-ENODEV);
+	}
+
+	arg0.integer.value = mode;
+
+	status = acpi_evaluate_object(handle, NULL, &arg_list, NULL);
+	if (ACPI_FAILURE(status))
+		return_VALUE(-ENODEV);
+
+	tz->cooling_mode = mode;
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling mode [%s]\n", 
+		mode?"passive":"active"));
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_thermal_get_trip_points (
+	struct acpi_thermal *tz)
+{
+	acpi_status		status = AE_OK;
+	int			i = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_get_trip_points");
+
+	if (!tz)
+		return_VALUE(-EINVAL);
+
+	/* Critical Shutdown (required) */
+
+	status = acpi_evaluate_integer(tz->handle, "_CRT", NULL, 
+		&tz->trips.critical.temperature);
+	if (ACPI_FAILURE(status)) {
+		tz->trips.critical.flags.valid = 0;
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No critical threshold\n"));
+		return -ENODEV;
+	}
+	else {
+		tz->trips.critical.flags.valid = 1;
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found critical threshold [%lu]\n", tz->trips.critical.temperature));
+	}
+
+	/* Critical Sleep (optional) */
+
+	status = acpi_evaluate_integer(tz->handle, "_HOT", NULL, &tz->trips.hot.temperature);
+	if (ACPI_FAILURE(status)) {
+		tz->trips.hot.flags.valid = 0;
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No hot threshold\n"));
+	}
+	else {
+		tz->trips.hot.flags.valid = 1;
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found hot threshold [%lu]\n", tz->trips.hot.temperature));
+	}
+
+	/* Passive: Processors (optional) */
+
+	status = acpi_evaluate_integer(tz->handle, "_PSV", NULL, &tz->trips.passive.temperature);
+	if (ACPI_FAILURE(status)) {
+		tz->trips.passive.flags.valid = 0;
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No passive threshold\n"));
+	}
+	else {
+		tz->trips.passive.flags.valid = 1;
+
+		status = acpi_evaluate_integer(tz->handle, "_TC1", NULL, &tz->trips.passive.tc1);
+		if (ACPI_FAILURE(status))
+			tz->trips.passive.flags.valid = 0;
+
+		status = acpi_evaluate_integer(tz->handle, "_TC2", NULL, &tz->trips.passive.tc2);
+		if (ACPI_FAILURE(status))
+			tz->trips.passive.flags.valid = 0;
+
+		status = acpi_evaluate_integer(tz->handle, "_TSP", NULL, &tz->trips.passive.tsp);
+		if (ACPI_FAILURE(status))
+			tz->trips.passive.flags.valid = 0;
+
+		status = acpi_evaluate_reference(tz->handle, "_PSL", NULL, &tz->trips.passive.devices);
+		if (ACPI_FAILURE(status))
+			tz->trips.passive.flags.valid = 0;
+
+		if (!tz->trips.passive.flags.valid)
+			ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid passive threshold\n"));
+		else
+			ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found passive threshold [%lu]\n", tz->trips.passive.temperature));
+	}
+
+	/* Active: Fans, etc. (optional) */
+
+	for (i=0; i<ACPI_THERMAL_MAX_ACTIVE; i++) {
+
+		char name[5] = {'_','A','C',('0'+i),'\0'};
+
+		status = acpi_evaluate_integer(tz->handle, name, NULL, &tz->trips.active[i].temperature);
+		if (ACPI_FAILURE(status))
+			break;
+
+		name[2] = 'L';
+		status = acpi_evaluate_reference(tz->handle, name, NULL, &tz->trips.active[i].devices);
+		if (ACPI_SUCCESS(status)) {
+			tz->trips.active[i].flags.valid = 1;
+			ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found active threshold [%d]:[%lu]\n", i, tz->trips.active[i].temperature));
+		}
+		else
+			ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid active threshold [%d]\n", i));
+	}
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_thermal_get_devices (
+	struct acpi_thermal	*tz)
+{
+	acpi_status		status = AE_OK;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_get_devices");
+
+	if (!tz)
+		return_VALUE(-EINVAL);
+
+	status = acpi_evaluate_reference(tz->handle, "_TZD", NULL, &tz->devices);
+	if (ACPI_FAILURE(status))
+		return_VALUE(-ENODEV);
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_thermal_call_usermode (
+	char			*path)
+{
+	char			*argv[2] = {NULL, NULL};
+	char			*envp[3] = {NULL, NULL, NULL};
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_call_usermode");
+
+	if (!path)
+		return_VALUE(-EINVAL);
+
+	argv[0] = path;
+
+	/* minimal command environment */
+	envp[0] = "HOME=/";
+	envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
+	
+	call_usermodehelper(argv[0], argv, envp);
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_thermal_critical (
+	struct acpi_thermal	*tz)
+{
+	int			result = 0;
+	struct acpi_device	*device = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_critical");
+
+	if (!tz || !tz->trips.critical.flags.valid)
+		return_VALUE(-EINVAL);
+
+	if (tz->temperature >= tz->trips.critical.temperature) {
+		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Critical trip point\n"));
+		tz->trips.critical.flags.enabled = 1;
+	}
+	else if (tz->trips.critical.flags.enabled)
+		tz->trips.critical.flags.enabled = 0;
+
+	result = acpi_bus_get_device(tz->handle, &device);
+	if (result)
+		return_VALUE(result);
+
+	acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_CRITICAL, tz->trips.critical.flags.enabled);
+
+	acpi_thermal_call_usermode(ACPI_THERMAL_PATH_POWEROFF);
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_thermal_hot (
+	struct acpi_thermal	*tz)
+{
+	int			result = 0;
+	struct acpi_device	*device = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_hot");
+
+	if (!tz || !tz->trips.hot.flags.valid)
+		return_VALUE(-EINVAL);
+
+	if (tz->temperature >= tz->trips.hot.temperature) {
+		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Hot trip point\n"));
+		tz->trips.hot.flags.enabled = 1;
+	}
+	else if (tz->trips.hot.flags.enabled)
+		tz->trips.hot.flags.enabled = 0;
+
+	result = acpi_bus_get_device(tz->handle, &device);
+	if (result)
+		return_VALUE(result);
+
+	acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_HOT, tz->trips.hot.flags.enabled);
+
+	/* TBD: Call user-mode "sleep(S4)" function */
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_thermal_passive (
+	struct acpi_thermal	*tz)
+{
+	int			result = 0;
+	struct acpi_thermal_passive *passive = NULL;
+	int			trend = 0;
+	int			i = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_passive");
+
+	if (!tz || !tz->trips.passive.flags.valid)
+		return_VALUE(-EINVAL);
+
+	passive = &(tz->trips.passive);
+
+	/*
+	 * Above Trip?
+	 * -----------
+	 * Calculate the thermal trend (using the passive cooling equation)
+	 * and modify the performance limit for all passive cooling devices
+	 * accordingly.  Note that we assume symmetry.
+	 */
+	if (tz->temperature >= passive->temperature) {
+		trend = (passive->tc1 * (tz->temperature - tz->last_temperature)) + (passive->tc2 * (tz->temperature - passive->temperature));
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+			"trend[%d]=(tc1[%lu]*(tmp[%lu]-last[%lu]))+(tc2[%lu]*(tmp[%lu]-psv[%lu]))\n", 
+			trend, passive->tc1, tz->temperature, 
+			tz->last_temperature, passive->tc2, 
+			tz->temperature, passive->temperature));
+		tz->trips.passive.flags.enabled = 1;
+		/* Heating up? */
+		if (trend > 0)
+			for (i=0; i<passive->devices.count; i++)
+				acpi_processor_set_thermal_limit(
+					passive->devices.handles[i], 
+					ACPI_PROCESSOR_LIMIT_INCREMENT);
+		/* Cooling off? */
+		else if (trend < 0)
+			for (i=0; i<passive->devices.count; i++)
+				acpi_processor_set_thermal_limit(
+					passive->devices.handles[i], 
+					ACPI_PROCESSOR_LIMIT_DECREMENT);
+	}
+
+	/*
+	 * Below Trip?
+	 * -----------
+	 * Implement passive cooling hysteresis to slowly increase performance
+	 * and avoid thrashing around the passive trip point.  Note that we
+	 * assume symmetry.
+	 */
+	else if (tz->trips.passive.flags.enabled) {
+		for (i=0; i<passive->devices.count; i++)
+			result = acpi_processor_set_thermal_limit(
+				passive->devices.handles[i], 
+				ACPI_PROCESSOR_LIMIT_DECREMENT);
+		if (result == 1) {
+			tz->trips.passive.flags.enabled = 0;
+			ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
+				"Disabling passive cooling (zone is cool)\n"));
+		}
+	}
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_thermal_active (
+	struct acpi_thermal	*tz)
+{
+	int			result = 0;
+	struct acpi_thermal_active *active = NULL;
+	int                     i = 0;
+	int			j = 0;
+	unsigned long		maxtemp = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_active");
+
+	if (!tz)
+		return_VALUE(-EINVAL);
+
+	for (i=0; i<ACPI_THERMAL_MAX_ACTIVE; i++) {
+
+		active = &(tz->trips.active[i]);
+		if (!active || !active->flags.valid)
+			break;
+
+		/*
+		 * Above Threshold?
+		 * ----------------
+		 * If not already enabled, turn ON all cooling devices
+		 * associated with this active threshold.
+		 */
+		if (tz->temperature >= active->temperature) {
+			if (active->temperature > maxtemp)
+				tz->state.active_index = i, maxtemp = active->temperature;
+			if (!active->flags.enabled) {
+				for (j = 0; j < active->devices.count; j++) {
+					result = acpi_bus_set_power(active->devices.handles[j], ACPI_STATE_D0);
+					if (result) {
+						ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Unable to turn cooling device [%p] 'on'\n", active->devices.handles[j]));
+						continue;
+					}
+					active->flags.enabled = 1;
+					ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling device [%p] now 'on'\n", active->devices.handles[j]));
+				}
+			}
+		}
+		/*
+		 * Below Threshold?
+		 * ----------------
+		 * Turn OFF all cooling devices associated with this
+		 * threshold.
+		 */
+		else if (active->flags.enabled) {
+			for (j = 0; j < active->devices.count; j++) {
+				result = acpi_bus_set_power(active->devices.handles[j], ACPI_STATE_D3);
+				if (result) {
+					ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Unable to turn cooling device [%p] 'off'\n", active->devices.handles[j]));
+					continue;
+				}
+				active->flags.enabled = 0;
+				ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling device [%p] now 'off'\n", active->devices.handles[j]));
+			}
+		}
+	}
+
+	return_VALUE(0);
+}
+
+
+static void acpi_thermal_check (void *context);
+
+static void
+acpi_thermal_run (
+	unsigned long		data)
+{
+	acpi_os_queue_for_execution(OSD_PRIORITY_GPE,  acpi_thermal_check, (void *) data);
+}
+
+
+static void
+acpi_thermal_check (
+	void                    *data)
+{
+	int			result = 0;
+	struct acpi_thermal	*tz = (struct acpi_thermal *) data;
+	unsigned long		sleep_time = 0;
+	int			i = 0;
+	struct acpi_thermal_state state = tz->state;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_check");
+
+	if (!tz) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) context.\n"));
+		return_VOID;
+	}
+
+	result = acpi_thermal_get_temperature(tz);
+	if (result)
+		return_VOID;
+	
+	memset(&tz->state, 0, sizeof(tz->state));
+	
+	/*
+	 * Check Trip Points
+	 * -----------------
+	 * Compare the current temperature to the trip point values to see
+	 * if we've entered one of the thermal policy states.  Note that
+	 * this function determines when a state is entered, but the 
+	 * individual policy decides when it is exited (e.g. hysteresis).
+	 */
+	if (tz->trips.critical.flags.valid)
+		state.critical |= (tz->temperature >= tz->trips.critical.temperature);
+	if (tz->trips.hot.flags.valid)
+		state.hot |= (tz->temperature >= tz->trips.hot.temperature);
+	if (tz->trips.passive.flags.valid)
+		state.passive |= (tz->temperature >= tz->trips.passive.temperature);
+	for (i=0; i<ACPI_THERMAL_MAX_ACTIVE; i++)
+		if (tz->trips.active[i].flags.valid)
+			state.active |= (tz->temperature >= tz->trips.active[i].temperature);
+
+	/*
+	 * Invoke Policy
+	 * -------------
+	 * Separated from the above check to allow individual policy to 
+	 * determine when to exit a given state.
+	 */
+	if (state.critical)
+		acpi_thermal_critical(tz);
+	if (state.hot)
+		acpi_thermal_hot(tz);
+	if (state.passive)
+		acpi_thermal_passive(tz);
+	if (state.active)
+		acpi_thermal_active(tz);
+
+	/*
+	 * Calculate State
+	 * ---------------
+	 * Again, separated from the above two to allow independent policy
+	 * decisions.
+	 */
+	if (tz->trips.critical.flags.enabled)
+		tz->state.critical = 1;
+	if (tz->trips.hot.flags.enabled)
+		tz->state.hot = 1;
+	if (tz->trips.passive.flags.enabled)
+		tz->state.passive = 1;
+	for (i=0; i<ACPI_THERMAL_MAX_ACTIVE; i++)
+		if (tz->trips.active[i].flags.enabled)
+			tz->state.active = 1;
+
+	/*
+	 * Calculate Sleep Time
+	 * --------------------
+	 * If we're in the passive state, use _TSP's value.  Otherwise
+	 * use the default polling frequency (e.g. _TZP).  If no polling
+	 * frequency is specified then we'll wait forever (at least until
+	 * a thermal event occurs).  Note that _TSP and _TZD values are
+	 * given in 1/10th seconds (we must covert to milliseconds).
+	 */
+	if (tz->state.passive)
+		sleep_time = tz->trips.passive.tsp * 100;
+	else if (tz->polling_frequency > 0)
+		sleep_time = tz->polling_frequency * 100;
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s: temperature[%lu] sleep[%lu]\n", 
+		tz->name, tz->temperature, sleep_time));
+
+	/*
+	 * Schedule Next Poll
+	 * ------------------
+	 */
+	if (!sleep_time) {
+		if (timer_pending(&(tz->timer)))
+			del_timer(&(tz->timer));
+	}
+	else {
+		if (timer_pending(&(tz->timer)))
+			mod_timer(&(tz->timer), (HZ * sleep_time) / 1000);
+		else {
+			tz->timer.data = (unsigned long) tz;
+			tz->timer.function = acpi_thermal_run;
+			tz->timer.expires = jiffies + (HZ * sleep_time) / 1000;
+			add_timer(&(tz->timer));
+		}
+	}
+
+	return_VOID;
+}
+
+
+/* --------------------------------------------------------------------------
+                              FS Interface (/proc)
+   -------------------------------------------------------------------------- */
+
+struct proc_dir_entry		*acpi_thermal_dir = NULL;
+
+
+static int
+acpi_thermal_read_state (
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	struct acpi_thermal	*tz = (struct acpi_thermal *) data;
+	char			*p = page;
+	int			len = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_read_state");
+
+	if (!tz || (off != 0))
+		goto end;
+
+	p += sprintf(p, "state:                   ");
+
+	if (!tz->state.critical && !tz->state.hot && !tz->state.passive && !tz->state.active)
+		p += sprintf(p, "ok\n");
+	else {
+		if (tz->state.critical)
+			p += sprintf(p, "critical ");
+		if (tz->state.hot)
+			p += sprintf(p, "hot ");
+		if (tz->state.passive)
+			p += sprintf(p, "passive ");
+		if (tz->state.active)
+			p += sprintf(p, "active[%d]", tz->state.active_index);
+		p += sprintf(p, "\n");
+	}
+
+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);
+}
+
+
+static int
+acpi_thermal_read_temperature (
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	int			result = 0;
+	struct acpi_thermal	*tz = (struct acpi_thermal *) data;
+	char			*p = page;
+	int			len = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_read_temperature");
+
+	if (!tz || (off != 0))
+		goto end;
+
+	result = acpi_thermal_get_temperature(tz);
+	if (result)
+		goto end;
+
+	p += sprintf(p, "temperature:             %ld C\n", 
+		KELVIN_TO_CELSIUS(tz->temperature));
+	
+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);
+}
+
+
+static int
+acpi_thermal_read_trip_points (
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	struct acpi_thermal	*tz = (struct acpi_thermal *) data;
+	char			*p = page;
+	int			len = 0;
+	int			i = 0;
+	int			j = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_read_trip_points");
+
+	if (!tz || (off != 0))
+		goto end;
+
+	if (tz->trips.critical.flags.valid)
+		p += sprintf(p, "critical (S5):           %ld C\n",
+			KELVIN_TO_CELSIUS(tz->trips.critical.temperature));
+
+	if (tz->trips.hot.flags.valid)
+		p += sprintf(p, "hot (S4):                %ld C\n",
+			KELVIN_TO_CELSIUS(tz->trips.hot.temperature));
+
+	if (tz->trips.passive.flags.valid) {
+		p += sprintf(p, "passive:                 %ld C: tc1=%lu tc2=%lu tsp=%lu devices=",
+			KELVIN_TO_CELSIUS(tz->trips.passive.temperature),
+			tz->trips.passive.tc1,
+			tz->trips.passive.tc2, 
+			tz->trips.passive.tsp);
+		for (j=0; j<tz->trips.passive.devices.count; j++) {
+
+			p += sprintf(p, "0x%p ", tz->trips.passive.devices.handles[j]);
+		}
+		p += sprintf(p, "\n");
+	}
+
+	for (i=0; i<ACPI_THERMAL_MAX_ACTIVE; i++) {
+		if (!(tz->trips.active[i].flags.valid))
+			break;
+		p += sprintf(p, "active[%d]:               %ld C: devices=",
+			i, KELVIN_TO_CELSIUS(tz->trips.active[i].temperature));
+		for (j=0; j<tz->trips.active[i].devices.count; j++) 
+			p += sprintf(p, "0x%p ",
+				tz->trips.active[i].devices.handles[j]);
+		p += sprintf(p, "\n");
+	}
+
+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);
+}
+
+
+static int
+acpi_thermal_write_trip_points (
+        struct file		*file,
+        const char		*buffer,
+        unsigned long		count,
+        void			*data)
+{
+	struct acpi_thermal	*tz = (struct acpi_thermal *) data;
+	char			limit_string[25] = {'\0'};
+	int			critical, hot, passive, active0, active1;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_write_trip_points");
+
+	if (!tz || (count > sizeof(limit_string) - 1)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument\n"));
+		return_VALUE(-EINVAL);
+	}
+	
+	if (copy_from_user(limit_string, buffer, count)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n"));
+		return_VALUE(-EFAULT);
+	}
+	
+	limit_string[count] = '\0';
+
+	if (sscanf(limit_string, "%d:%d:%d:%d:%d", &critical, &hot, &passive, &active0, &active1) != 5) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n"));
+		return_VALUE(-EINVAL);
+	}
+
+	tz->trips.critical.temperature = CELSIUS_TO_KELVIN(critical);
+	tz->trips.hot.temperature = CELSIUS_TO_KELVIN(hot);
+	tz->trips.passive.temperature = CELSIUS_TO_KELVIN(passive);
+	tz->trips.active[0].temperature = CELSIUS_TO_KELVIN(active0);
+	tz->trips.active[1].temperature = CELSIUS_TO_KELVIN(active1);
+	
+	return_VALUE(count);
+}
+
+
+static int
+acpi_thermal_read_cooling_mode (
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	struct acpi_thermal	*tz = (struct acpi_thermal *) data;
+	char			*p = page;
+	int			len = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_read_cooling_mode");
+
+	if (!tz || (off != 0))
+		goto end;
+
+	if (!tz->flags.cooling_mode) {
+		p += sprintf(p, "<not supported>\n");
+		goto end;
+	}
+
+	p += sprintf(p, "cooling mode:            %s\n",
+		tz->cooling_mode?"passive":"active");
+
+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);
+}
+
+
+static int
+acpi_thermal_write_cooling_mode (
+	struct file		*file,
+	const char		*buffer,
+	unsigned long		count,
+	void			*data)
+{
+	int			result = 0;
+	struct acpi_thermal	*tz = (struct acpi_thermal *) data;
+	char			mode_string[12] = {'\0'};
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_write_cooling_mode");
+
+	if (!tz || (count > sizeof(mode_string) - 1))
+		return_VALUE(-EINVAL);
+
+	if (!tz->flags.cooling_mode)
+		return_VALUE(-ENODEV);
+
+	if (copy_from_user(mode_string, buffer, count))
+		return_VALUE(-EFAULT);
+	
+	mode_string[count] = '\0';
+	
+	result = acpi_thermal_set_cooling_mode(tz, 
+		simple_strtoul(mode_string, NULL, 0));
+	if (result)
+		return_VALUE(result);
+
+	return_VALUE(count);
+}
+
+
+static int
+acpi_thermal_read_polling (
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
+	void			*data)
+{
+	struct acpi_thermal	*tz = (struct acpi_thermal *) data;
+	char			*p = page;
+	int			len = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_read_polling");
+
+	if (!tz || (off != 0))
+		goto end;
+
+	if (!tz->polling_frequency) {
+		p += sprintf(p, "<polling disabled>\n");
+		goto end;
+	}
+
+	p += sprintf(p, "polling frequency:       %lu seconds\n",
+		(tz->polling_frequency / 10));
+
+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);
+}
+
+
+static int
+acpi_thermal_write_polling (
+	struct file		*file,
+	const char		*buffer,
+	unsigned long		count,
+	void			*data)
+{
+	int			result = 0;
+	struct acpi_thermal	*tz = (struct acpi_thermal *) data;
+	char			polling_string[12] = {'\0'};
+	int			seconds = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_write_polling");
+
+	if (!tz || (count > sizeof(polling_string) - 1))
+		return_VALUE(-EINVAL);
+	
+	if (copy_from_user(polling_string, buffer, count))
+		return_VALUE(-EFAULT);
+	
+	polling_string[count] = '\0';
+
+	seconds = simple_strtoul(polling_string, NULL, 0);
+	
+	result = acpi_thermal_set_polling(tz, seconds);
+	if (result)
+		return_VALUE(result);
+
+	acpi_thermal_check(tz);
+
+	return_VALUE(count);
+}
+
+
+static int
+acpi_thermal_add_fs (
+	struct acpi_device	*device)
+{
+	struct proc_dir_entry	*entry = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_add_fs");
+
+	if (!acpi_device_dir(device)) {
+		acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
+			acpi_thermal_dir);
+		if (!acpi_device_dir(device))
+			return_VALUE(-ENODEV);
+	}
+
+	/* 'state' [R] */
+	entry = create_proc_entry(ACPI_THERMAL_FILE_STATE,
+		S_IRUGO, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_THERMAL_FILE_STATE));
+	else {
+		entry->read_proc = acpi_thermal_read_state;
+		entry->data = acpi_driver_data(device);
+	}
+
+	/* 'temperature' [R] */
+	entry = create_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE,
+		S_IRUGO, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_THERMAL_FILE_TEMPERATURE));
+	else {
+		entry->read_proc = acpi_thermal_read_temperature;
+		entry->data = acpi_driver_data(device);
+	}
+
+	/* 'trip_points' [R/W] */
+	entry = create_proc_entry(ACPI_THERMAL_FILE_TRIP_POINTS,
+		S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_THERMAL_FILE_POLLING_FREQ));
+	else {
+		entry->read_proc = acpi_thermal_read_trip_points;
+		entry->write_proc = acpi_thermal_write_trip_points;
+		entry->data = acpi_driver_data(device);
+	}
+
+	/* 'cooling_mode' [R/W] */
+	entry = create_proc_entry(ACPI_THERMAL_FILE_COOLING_MODE,
+		S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_THERMAL_FILE_COOLING_MODE));
+	else {
+		entry->read_proc = acpi_thermal_read_cooling_mode;
+		entry->write_proc = acpi_thermal_write_cooling_mode;
+		entry->data = acpi_driver_data(device);
+	}
+
+	/* 'polling_frequency' [R/W] */
+	entry = create_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ,
+		S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create '%s' fs entry\n",
+			ACPI_THERMAL_FILE_POLLING_FREQ));
+	else {
+		entry->read_proc = acpi_thermal_read_polling;
+		entry->write_proc = acpi_thermal_write_polling;
+		entry->data = acpi_driver_data(device);
+	}
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_thermal_remove_fs (
+	struct acpi_device	*device)
+{
+	ACPI_FUNCTION_TRACE("acpi_thermal_remove_fs");
+
+	if (acpi_device_dir(device)) {
+		remove_proc_entry(acpi_device_bid(device), acpi_thermal_dir);
+		acpi_device_dir(device) = NULL;
+	}
+
+	return_VALUE(0);
+}
+
+
+/* --------------------------------------------------------------------------
+                                 Driver Interface
+   -------------------------------------------------------------------------- */
+
+static void
+acpi_thermal_notify (
+	acpi_handle 		handle,
+	u32 			event,
+	void 			*data)
+{
+	struct acpi_thermal	*tz = (struct acpi_thermal *) data;
+	struct acpi_device	*device = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_notify");
+
+	if (!tz)
+		return_VOID;
+
+	if (acpi_bus_get_device(tz->handle, &device))
+		return_VOID;
+
+	switch (event) {
+	case ACPI_THERMAL_NOTIFY_TEMPERATURE:
+		acpi_thermal_check(tz);
+		break;
+	case ACPI_THERMAL_NOTIFY_THRESHOLDS:
+		acpi_thermal_get_trip_points(tz);
+		acpi_thermal_check(tz);
+		acpi_bus_generate_event(device, event, 0);
+		break;
+	case ACPI_THERMAL_NOTIFY_DEVICES:
+		if (tz->flags.devices)
+			acpi_thermal_get_devices(tz);
+		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_thermal_get_info (
+	struct acpi_thermal	*tz)
+{
+	int			result = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_get_info");
+
+	if (!tz)
+		return_VALUE(-EINVAL);
+
+	/* Get temperature [_TMP] (required) */
+	result = acpi_thermal_get_temperature(tz);
+	if (result)
+		return_VALUE(result);
+
+	/* Set the cooling mode [_SCP] to active cooling (default) */
+	result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE);
+	if (!result)
+		tz->flags.cooling_mode = 1;
+
+	/* Get trip points [_CRT, _PSV, etc.] (required) */
+	result = acpi_thermal_get_trip_points(tz);
+	if (result)
+		return_VALUE(result);
+
+	/* Get default polling frequency [_TZP] (optional) */
+	if (tzp)
+		tz->polling_frequency = tzp;
+	else
+		acpi_thermal_get_polling_frequency(tz);
+
+	/* Get devices in this thermal zone [_TZD] (optional) */
+	result = acpi_thermal_get_devices(tz);
+	if (!result)
+		tz->flags.devices = 1;
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_thermal_add (
+	struct acpi_device 		*device)
+{
+	int			result = 0;
+	acpi_status		status = AE_OK;
+	struct acpi_thermal	*tz = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_add");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	tz = kmalloc(sizeof(struct acpi_thermal), GFP_KERNEL);
+	if (!tz)
+		return_VALUE(-ENOMEM);
+	memset(tz, 0, sizeof(struct acpi_thermal));
+
+	tz->handle = device->handle;
+	sprintf(tz->name, "%s", device->pnp.bus_id);
+	sprintf(acpi_device_name(device), "%s", ACPI_THERMAL_DEVICE_NAME);
+	sprintf(acpi_device_class(device), "%s", ACPI_THERMAL_CLASS);
+	acpi_driver_data(device) = tz;
+
+	result = acpi_thermal_get_info(tz);
+	if (result)
+		goto end;
+
+	result = acpi_thermal_add_fs(device);
+	if (result)
+		return_VALUE(result);
+
+	init_timer(&tz->timer);
+
+	acpi_thermal_check(tz);
+
+	status = acpi_install_notify_handler(tz->handle,
+		ACPI_DEVICE_NOTIFY, acpi_thermal_notify, tz);
+	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] (%ld C)\n",
+		acpi_device_name(device), acpi_device_bid(device),
+		KELVIN_TO_CELSIUS(tz->temperature));
+
+end:
+	if (result) {
+		acpi_thermal_remove_fs(device);
+		kfree(tz);
+	}
+
+	return_VALUE(result);
+}
+
+
+static int
+acpi_thermal_remove (
+	struct acpi_device	*device,
+	int			type)
+{
+	acpi_status		status = AE_OK;
+	struct acpi_thermal	*tz = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_remove");
+
+	if (!device || !acpi_driver_data(device))
+		return_VALUE(-EINVAL);
+
+	tz = (struct acpi_thermal *) acpi_driver_data(device);
+
+	if (timer_pending(&(tz->timer)))
+		del_timer(&(tz->timer));
+
+	status = acpi_remove_notify_handler(tz->handle,
+		ACPI_DEVICE_NOTIFY, acpi_thermal_notify);
+	if (ACPI_FAILURE(status))
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Error removing notify handler\n"));
+
+	/* Terminate policy */
+	if (tz->trips.passive.flags.valid
+		&& tz->trips.passive.flags.enabled) {
+		tz->trips.passive.flags.enabled = 0;
+		acpi_thermal_passive(tz);
+	}
+	if (tz->trips.active[0].flags.valid
+		&& tz->trips.active[0].flags.enabled) {
+		tz->trips.active[0].flags.enabled = 0;
+		acpi_thermal_active(tz);
+	}
+
+	acpi_thermal_remove_fs(device);
+
+	return_VALUE(0);
+}
+
+
+static int __init
+acpi_thermal_init (void)
+{
+	int			result = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_thermal_init");
+
+	acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir);
+	if (!acpi_thermal_dir)
+		return_VALUE(-ENODEV);
+
+	result = acpi_bus_register_driver(&acpi_thermal_driver);
+	if (result < 0) {
+		remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
+		return_VALUE(-ENODEV);
+	}
+
+	return_VALUE(0);
+}
+
+
+static void __exit
+acpi_thermal_exit (void)
+{
+	ACPI_FUNCTION_TRACE("acpi_thermal_exit");
+
+	acpi_bus_unregister_driver(&acpi_thermal_driver);
+
+	remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
+
+	return_VOID;
+}
+
+
+module_init(acpi_thermal_init);
+module_exit(acpi_thermal_exit);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/toshiba_acpi.c linux-2.4.22-pre2/drivers/acpi/toshiba_acpi.c
--- linux-2.4.21/drivers/acpi/toshiba_acpi.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/toshiba_acpi.c	2003-06-26 21:43:12.000000000 +0000
@@ -0,0 +1,540 @@
+/*
+ *  toshiba_acpi.c - Toshiba Laptop ACPI Extras
+ *
+ *
+ *  Copyright (C) 2002-2003 John Belmonte
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the 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
+ *
+ *
+ *  The devolpment page for this driver is located at
+ *  http://memebeam.org/toys/ToshibaAcpiDriver.
+ *
+ *  Credits:
+ *	Jonathan A. Buzzard - Toshiba HCI info, and critical tips on reverse
+ *		engineering the Windows drivers
+ *	Yasushi Nagato - changes for linux kernel 2.4 -> 2.5
+ *	Rob Miller - TV out and hotkeys help
+ *
+ *
+ *  TODO
+ *
+ */
+
+#define TOSHIBA_ACPI_VERSION	"0.15"
+#define PROC_INTERFACE_VERSION	1
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/proc_fs.h>
+#include <linux/version.h>
+
+#include <acpi/acpi_drivers.h>
+
+MODULE_AUTHOR("John Belmonte");
+MODULE_DESCRIPTION("Toshiba Laptop ACPI Extras Driver");
+MODULE_LICENSE("GPL");
+
+/* Toshiba ACPI method paths */
+#define METHOD_LCD_BRIGHTNESS	"\\_SB_.PCI0.VGA_.LCD_._BCM"
+#define METHOD_HCI		"\\_SB_.VALD.GHCI"
+#define METHOD_VIDEO_OUT	"\\_SB_.VALX.DSSX"
+
+/* Toshiba HCI interface definitions
+ *
+ * HCI is Toshiba's "Hardware Control Interface" which is supposed to
+ * be uniform across all their models.  Ideally we would just call
+ * dedicated ACPI methods instead of using this primitive interface.
+ * However the ACPI methods seem to be incomplete in some areas (for
+ * example they allow setting, but not reading, the LCD brightness value),
+ * so this is still useful.
+ */
+
+#define HCI_WORDS			6
+
+/* operations */
+#define HCI_SET				0xff00
+#define HCI_GET				0xfe00
+
+/* return codes */
+#define HCI_SUCCESS			0x0000
+#define HCI_FAILURE			0x1000
+#define HCI_NOT_SUPPORTED		0x8000
+#define HCI_EMPTY			0x8c00
+
+/* registers */
+#define HCI_FAN				0x0004
+#define HCI_SYSTEM_EVENT		0x0016
+#define HCI_VIDEO_OUT			0x001c
+#define HCI_HOTKEY_EVENT		0x001e
+#define HCI_LCD_BRIGHTNESS		0x002a
+
+/* field definitions */
+#define HCI_LCD_BRIGHTNESS_BITS		3
+#define HCI_LCD_BRIGHTNESS_SHIFT	(16-HCI_LCD_BRIGHTNESS_BITS)
+#define HCI_LCD_BRIGHTNESS_LEVELS	(1 << HCI_LCD_BRIGHTNESS_BITS)
+#define HCI_VIDEO_OUT_LCD		0x1
+#define HCI_VIDEO_OUT_CRT		0x2
+#define HCI_VIDEO_OUT_TV		0x4
+
+/* utility
+ */
+
+static __inline__ void
+_set_bit(u32* word, u32 mask, int value)
+{
+	*word = (*word & ~mask) | (mask * value);
+}
+
+/* an sscanf that takes explicit string length */
+static int
+snscanf(const char* str, int n, const char* format, ...)
+{
+	va_list args;
+	int result;
+	char* str2 = kmalloc(n + 1, GFP_KERNEL);
+	if (str2 == 0) return 0;
+	strncpy(str2, str, n);
+	str2[n] = 0;
+	va_start(args, format);
+	result = vsscanf(str2, format, args);
+	va_end(args);
+	kfree(str2);
+	return result;
+}
+
+/* acpi interface wrappers
+ */
+
+static int
+write_acpi_int(const char* methodName, int val)
+{
+	struct acpi_object_list params;
+	union acpi_object in_objs[1];
+	acpi_status status;
+
+	params.count = sizeof(in_objs)/sizeof(in_objs[0]);
+	params.pointer = in_objs;
+	in_objs[0].type = ACPI_TYPE_INTEGER;
+	in_objs[0].integer.value = val;
+
+	status = acpi_evaluate_object(0, (char*)methodName, &params, 0);
+	return (status == AE_OK);
+}
+
+#if 0
+static int
+read_acpi_int(const char* methodName, int* pVal)
+{
+	struct acpi_buffer results;
+	union acpi_object out_objs[1];
+	acpi_status status;
+
+	results.length = sizeof(out_objs);
+	results.pointer = out_objs;
+
+	status = acpi_evaluate_object(0, (char*)methodName, 0, &results);
+	*pVal = out_objs[0].integer.value;
+
+	return (status == AE_OK) && (out_objs[0].type == ACPI_TYPE_INTEGER);
+}
+#endif
+
+/* Perform a raw HCI call.  Here we don't care about input or output buffer
+ * format.
+ */
+static acpi_status
+hci_raw(const u32 in[HCI_WORDS], u32 out[HCI_WORDS])
+{
+	struct acpi_object_list params;
+	union acpi_object in_objs[HCI_WORDS];
+	struct acpi_buffer results;
+	union acpi_object out_objs[HCI_WORDS+1];
+	acpi_status status;
+	int i;
+
+	params.count = HCI_WORDS;
+	params.pointer = in_objs;
+	for (i = 0; i < HCI_WORDS; ++i) {
+		in_objs[i].type = ACPI_TYPE_INTEGER;
+		in_objs[i].integer.value = in[i];
+	}
+
+	results.length = sizeof(out_objs);
+	results.pointer = out_objs;
+
+	status = acpi_evaluate_object(0, METHOD_HCI, &params,
+		&results);
+	if ((status == AE_OK) && (out_objs->package.count <= HCI_WORDS)) {
+		for (i = 0; i < out_objs->package.count; ++i) {
+			out[i] = out_objs->package.elements[i].integer.value;
+		}
+	}
+
+	return status;
+}
+
+/* common hci tasks (get or set one value)
+ *
+ * In addition to the ACPI status, the HCI system returns a result which
+ * may be useful (such as "not supported").
+ */
+
+static acpi_status
+hci_write1(u32 reg, u32 in1, u32* result)
+{
+	u32 in[HCI_WORDS] = { HCI_SET, reg, in1, 0, 0, 0 };
+	u32 out[HCI_WORDS];
+	acpi_status status = hci_raw(in, out);
+	*result = (status == AE_OK) ? out[0] : HCI_FAILURE;
+	return status;
+}
+
+static acpi_status
+hci_read1(u32 reg, u32* out1, u32* result)
+{
+	u32 in[HCI_WORDS] = { HCI_GET, reg, 0, 0, 0, 0 };
+	u32 out[HCI_WORDS];
+	acpi_status status = hci_raw(in, out);
+	*out1 = out[2];
+	*result = (status == AE_OK) ? out[0] : HCI_FAILURE;
+	return status;
+}
+
+static struct proc_dir_entry*	toshiba_proc_dir = NULL;
+static int			force_fan;
+static int			last_key_event;
+static int			key_event_valid;
+
+typedef struct _ProcItem
+{
+	const char* name;
+	char* (*read_func)(char*);
+	unsigned long (*write_func)(const char*, unsigned long);
+} ProcItem;
+
+/* proc file handlers
+ */
+
+static int
+dispatch_read(char* page, char** start, off_t off, int count, int* eof,
+	ProcItem* item)
+{
+	char* p = page;
+	int len;
+
+	if (off == 0)
+		p = item->read_func(p);
+
+	/* ISSUE: I don't understand this code */
+	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 len;
+}
+
+static int
+dispatch_write(struct file* file, const char* buffer, unsigned long count,
+	ProcItem* item)
+{
+	return item->write_func(buffer, count);
+}
+
+static char*
+read_lcd(char* p)
+{
+	u32 hci_result;
+	u32 value;
+
+	hci_read1(HCI_LCD_BRIGHTNESS, &value, &hci_result);
+	if (hci_result == HCI_SUCCESS) {
+		value = value >> HCI_LCD_BRIGHTNESS_SHIFT;
+		p += sprintf(p, "brightness:              %d\n", value);
+		p += sprintf(p, "brightness_levels:       %d\n",
+			HCI_LCD_BRIGHTNESS_LEVELS);
+	} else {
+		p += sprintf(p, "ERROR\n");
+	}
+
+	return p;
+}
+
+static unsigned long
+write_lcd(const char* buffer, unsigned long count)
+{
+	int value;
+	u32 hci_result;
+
+	if (snscanf(buffer, count, " brightness : %i", &value) == 1 &&
+			value >= 0 && value < HCI_LCD_BRIGHTNESS_LEVELS) {
+		value = value << HCI_LCD_BRIGHTNESS_SHIFT;
+		hci_write1(HCI_LCD_BRIGHTNESS, value, &hci_result);
+		if (hci_result != HCI_SUCCESS)
+			return -EFAULT;
+	} else {
+		return -EINVAL;
+	}
+
+	return count;
+}
+
+static char*
+read_video(char* p)
+{
+	u32 hci_result;
+	u32 value;
+
+	hci_read1(HCI_VIDEO_OUT, &value, &hci_result);
+	if (hci_result == HCI_SUCCESS) {
+		int is_lcd = (value & HCI_VIDEO_OUT_LCD) ? 1 : 0;
+		int is_crt = (value & HCI_VIDEO_OUT_CRT) ? 1 : 0;
+		int is_tv  = (value & HCI_VIDEO_OUT_TV ) ? 1 : 0;
+		p += sprintf(p, "lcd_out:                 %d\n", is_lcd);
+		p += sprintf(p, "crt_out:                 %d\n", is_crt);
+		p += sprintf(p, "tv_out:                  %d\n", is_tv);
+	} else {
+		p += sprintf(p, "ERROR\n");
+	}
+
+	return p;
+}
+
+static unsigned long
+write_video(const char* buffer, unsigned long count)
+{
+	int value;
+	const char* buffer_end = buffer + count;
+	int lcd_out = -1;
+	int crt_out = -1;
+	int tv_out = -1;
+	u32 hci_result;
+	int video_out;
+
+	/* scan expression.  Multiple expressions may be delimited with ; */
+	do {
+		if (snscanf(buffer, count, " lcd_out : %i", &value) == 1)
+			lcd_out = value & 1;
+		else if (snscanf(buffer, count, " crt_out : %i", &value) == 1)
+			crt_out = value & 1;
+		else if (snscanf(buffer, count, " tv_out : %i", &value) == 1)
+			tv_out = value & 1;
+		/* advance to one character past the next ; */
+		do ++buffer;
+		while ((buffer < buffer_end) && (*(buffer-1) != ';'));
+	} while (buffer < buffer_end);
+
+	hci_read1(HCI_VIDEO_OUT, &video_out, &hci_result);
+	if (hci_result == HCI_SUCCESS) {
+		int new_video_out = video_out;
+		if (lcd_out != -1)
+			_set_bit(&new_video_out, HCI_VIDEO_OUT_LCD, lcd_out);
+		if (crt_out != -1)
+			_set_bit(&new_video_out, HCI_VIDEO_OUT_CRT, crt_out);
+		if (tv_out != -1)
+			_set_bit(&new_video_out, HCI_VIDEO_OUT_TV, tv_out);
+		/* To avoid unnecessary video disruption, only write the new
+		 * video setting if something changed. */
+		if (new_video_out != video_out)
+			write_acpi_int(METHOD_VIDEO_OUT, new_video_out);
+	}
+
+	return count;
+}
+
+static char*
+read_fan(char* p)
+{
+	u32 hci_result;
+	u32 value;
+
+	hci_read1(HCI_FAN, &value, &hci_result);
+	if (hci_result == HCI_SUCCESS) {
+		p += sprintf(p, "running:                 %d\n", (value > 0));
+		p += sprintf(p, "force_on:                %d\n", force_fan);
+	} else {
+		p += sprintf(p, "ERROR\n");
+	}
+
+	return p;
+}
+
+static unsigned long
+write_fan(const char* buffer, unsigned long count)
+{
+	int value;
+	u32 hci_result;
+
+	if (snscanf(buffer, count, " force_on : %i", &value) == 1 &&
+			value >= 0 && value <= 1) {
+		hci_write1(HCI_FAN, value, &hci_result);
+		if (hci_result != HCI_SUCCESS)
+			return -EFAULT;
+		else
+			force_fan = value;
+	} else {
+		return -EINVAL;
+	}
+
+	return count;
+}
+
+static char*
+read_keys(char* p)
+{
+	u32 hci_result;
+	u32 value;
+
+	if (!key_event_valid) {
+		hci_read1(HCI_SYSTEM_EVENT, &value, &hci_result);
+		if (hci_result == HCI_SUCCESS) {
+			key_event_valid = 1;
+			last_key_event = value;
+		} else if (hci_result == HCI_EMPTY) {
+			/* better luck next time */
+		} else if (hci_result == HCI_NOT_SUPPORTED) {
+			/* This is a workaround for an unresolved issue on
+			 * some machines where system events sporadically
+			 * become disabled. */
+			hci_write1(HCI_SYSTEM_EVENT, 1, &hci_result);
+		} else {
+			p += sprintf(p, "ERROR\n");
+			goto end;
+		}
+	}
+
+	p += sprintf(p, "hotkey_ready:            %d\n", key_event_valid);
+	p += sprintf(p, "hotkey:                  0x%04x\n", last_key_event);
+
+end:
+	return p;
+}
+
+static unsigned long
+write_keys(const char* buffer, unsigned long count)
+{
+	int value;
+
+	if (snscanf(buffer, count, " hotkey_ready : %i", &value) == 1 &&
+			value == 0) {
+		key_event_valid = 0;
+	} else {
+		return -EINVAL;
+	}
+
+	return count;
+}
+
+static char*
+read_version(char* p)
+{
+	p += sprintf(p, "driver:                  %s\n", TOSHIBA_ACPI_VERSION);
+	p += sprintf(p, "proc_interface:          %d\n",
+		PROC_INTERFACE_VERSION);
+	return p;
+}
+
+/* proc and module init
+ */
+
+#define PROC_TOSHIBA		"toshiba"
+
+ProcItem proc_items[] =
+{
+	{ "lcd"		, read_lcd	, write_lcd	},
+	{ "video"	, read_video	, write_video	},
+	{ "fan"		, read_fan	, write_fan	},
+	{ "keys"	, read_keys	, write_keys	},
+	{ "version"	, read_version	, 0		},
+	{ 0		, 0		, 0		},
+};
+
+static acpi_status
+add_device(void)
+{
+	struct proc_dir_entry* proc;
+	ProcItem* item;
+
+	for (item = proc_items; item->name; ++item)
+	{
+		proc = create_proc_read_entry(item->name,
+			S_IFREG | S_IRUGO | S_IWUSR,
+			toshiba_proc_dir, (read_proc_t*)dispatch_read, item);
+		if (proc && item->write_func)
+			proc->write_proc = (write_proc_t*)dispatch_write;
+	}
+
+	return(AE_OK);
+}
+
+static acpi_status
+remove_device(void)
+{
+	ProcItem* item;
+
+	for (item = proc_items; item->name; ++item)
+		remove_proc_entry(item->name, toshiba_proc_dir);
+	return(AE_OK);
+}
+
+static int __init
+toshiba_acpi_init(void)
+{
+	acpi_status status = AE_OK;
+	int value;
+	u32 hci_result;
+
+	/* simple device detection: try reading an HCI register */
+	hci_read1(HCI_LCD_BRIGHTNESS, &value, &hci_result);
+	if (hci_result != HCI_SUCCESS)
+		return -ENODEV;
+
+	printk("Toshiba Laptop ACPI Extras version %s\n", TOSHIBA_ACPI_VERSION);
+
+	force_fan = 0;
+	key_event_valid = 0;
+
+	/* enable event fifo */
+	hci_write1(HCI_SYSTEM_EVENT, 1, &hci_result);
+
+	toshiba_proc_dir = proc_mkdir(PROC_TOSHIBA, acpi_root_dir);
+	if (!toshiba_proc_dir) {
+		status = AE_ERROR;
+	} else {
+		status = add_device();
+		if (ACPI_FAILURE(status))
+			remove_proc_entry(PROC_TOSHIBA, acpi_root_dir);
+	}
+
+	return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
+}
+
+static void __exit
+toshiba_acpi_exit(void)
+{
+	remove_device();
+
+	if (toshiba_proc_dir)
+		remove_proc_entry(PROC_TOSHIBA, acpi_root_dir);
+
+	return;
+}
+
+module_init(toshiba_acpi_init);
+module_exit(toshiba_acpi_exit);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/utilities/Makefile linux-2.4.22-pre2/drivers/acpi/utilities/Makefile
--- linux-2.4.21/drivers/acpi/utilities/Makefile	2001-06-21 00:47:40.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/utilities/Makefile	2003-06-26 21:43:17.000000000 +0000
@@ -1,11 +1,10 @@
 #
 # Makefile for all Linux ACPI interpreter subdirectories
-# EXCEPT for the ospm directory
 #
 
 O_TARGET := $(notdir $(CURDIR)).o
 
-obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/utilities/utalloc.c linux-2.4.22-pre2/drivers/acpi/utilities/utalloc.c
--- linux-2.4.21/drivers/acpi/utilities/utalloc.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/utilities/utalloc.c	2003-06-26 21:43:12.000000000 +0000
@@ -1,44 +1,58 @@
 /******************************************************************************
  *
  * Module Name: utalloc - local cache and memory allocation routines
- *              $Revision: 106 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "acglobal.h"
+#include <acpi/acpi.h>
 
 #define _COMPONENT          ACPI_UTILITIES
-	 MODULE_NAME         ("utalloc")
+	 ACPI_MODULE_NAME    ("utalloc")
 
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_ut_release_to_cache
+ * FUNCTION:    acpi_ut_release_to_cache
  *
- * PARAMETERS:  List_id             - Memory list/cache ID
+ * PARAMETERS:  list_id             - Memory list/cache ID
  *              Object              - The object to be released
  *
  * RETURN:      None
@@ -50,13 +64,13 @@
 
 void
 acpi_ut_release_to_cache (
-	u32                     list_id,
-	void                    *object)
+	u32                             list_id,
+	void                            *object)
 {
-	ACPI_MEMORY_LIST        *cache_info;
+	struct acpi_memory_list         *cache_info;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/* If walk cache is full, just free this wallkstate object */
@@ -70,29 +84,31 @@
 	/* Otherwise put this object back into the cache */
 
 	else {
-		acpi_ut_acquire_mutex (ACPI_MTX_CACHES);
+		if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES))) {
+			return;
+		}
 
 		/* Mark the object as cached */
 
-		MEMSET (object, 0xCA, cache_info->object_size);
-		((acpi_operand_object *) object)->common.data_type = ACPI_CACHED_OBJECT;
+		ACPI_MEMSET (object, 0xCA, cache_info->object_size);
+		ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_CACHED);
 
 		/* Put the object at the head of the cache list */
 
-		* (char **) (((char *) object) + cache_info->link_offset) = cache_info->list_head;
+		* (ACPI_CAST_INDIRECT_PTR (char, &(((char *) object)[cache_info->link_offset]))) = cache_info->list_head;
 		cache_info->list_head = object;
 		cache_info->cache_depth++;
 
-		acpi_ut_release_mutex (ACPI_MTX_CACHES);
+		(void) acpi_ut_release_mutex (ACPI_MTX_CACHES);
 	}
 }
 
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_ut_acquire_from_cache
+ * FUNCTION:    acpi_ut_acquire_from_cache
  *
- * PARAMETERS:  List_id             - Memory list ID
+ * PARAMETERS:  list_id             - Memory list ID
  *
  * RETURN:      A requested object.  NULL if the object could not be
  *              allocated.
@@ -104,17 +120,20 @@
 
 void *
 acpi_ut_acquire_from_cache (
-	u32                     list_id)
+	u32                             list_id)
 {
-	ACPI_MEMORY_LIST        *cache_info;
-	void                    *object;
+	struct acpi_memory_list         *cache_info;
+	void                            *object;
 
 
-	PROC_NAME ("Ut_acquire_from_cache");
+	ACPI_FUNCTION_NAME ("ut_acquire_from_cache");
 
 
 	cache_info = &acpi_gbl_memory_lists[list_id];
-	acpi_ut_acquire_mutex (ACPI_MTX_CACHES);
+	if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES))) {
+		return (NULL);
+	}
+
 	ACPI_MEM_TRACKING (cache_info->cache_requests++);
 
 	/* Check the cache first */
@@ -123,7 +142,7 @@
 		/* There is an object available, use it */
 
 		object = cache_info->list_head;
-		cache_info->list_head = * (char **) (((char *) object) + cache_info->link_offset);
+		cache_info->list_head = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) object)[cache_info->link_offset])));
 
 		ACPI_MEM_TRACKING (cache_info->cache_hits++);
 		cache_info->cache_depth--;
@@ -133,11 +152,13 @@
 			object, acpi_gbl_memory_lists[list_id].list_name));
 #endif
 
-		acpi_ut_release_mutex (ACPI_MTX_CACHES);
+		if (ACPI_FAILURE (acpi_ut_release_mutex (ACPI_MTX_CACHES))) {
+			return (NULL);
+		}
 
 		/* Clear (zero) the previously used Object */
 
-		MEMSET (object, 0, cache_info->object_size);
+		ACPI_MEMSET (object, 0, cache_info->object_size);
 	}
 
 	else {
@@ -145,7 +166,9 @@
 
 		/* Avoid deadlock with ACPI_MEM_CALLOCATE */
 
-		acpi_ut_release_mutex (ACPI_MTX_CACHES);
+		if (ACPI_FAILURE (acpi_ut_release_mutex (ACPI_MTX_CACHES))) {
+			return (NULL);
+		}
 
 		object = ACPI_MEM_CALLOCATE (cache_info->object_size);
 		ACPI_MEM_TRACKING (cache_info->total_allocated++);
@@ -157,9 +180,9 @@
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_ut_delete_generic_cache
+ * FUNCTION:    acpi_ut_delete_generic_cache
  *
- * PARAMETERS:  List_id         - Memory list ID
+ * PARAMETERS:  list_id         - Memory list ID
  *
  * RETURN:      None
  *
@@ -169,20 +192,20 @@
 
 void
 acpi_ut_delete_generic_cache (
-	u32                     list_id)
+	u32                             list_id)
 {
-	ACPI_MEMORY_LIST        *cache_info;
-	char                    *next;
+	struct acpi_memory_list         *cache_info;
+	char                            *next;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	cache_info = &acpi_gbl_memory_lists[list_id];
 	while (cache_info->list_head) {
 		/* Delete one cached state object */
 
-		next = * (char **) (((char *) cache_info->list_head) + cache_info->link_offset);
+		next = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) cache_info->list_head)[cache_info->link_offset])));
 		ACPI_MEM_FREE (cache_info->list_head);
 
 		cache_info->list_head = next;
@@ -191,26 +214,396 @@
 }
 
 
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_validate_buffer
+ *
+ * PARAMETERS:  Buffer              - Buffer descriptor to be validated
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Perform parameter validation checks on an struct acpi_buffer
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ut_validate_buffer (
+	struct acpi_buffer              *buffer)
+{
+
+	/* Obviously, the structure pointer must be valid */
+
+	if (!buffer) {
+		return (AE_BAD_PARAMETER);
+	}
+
+	/* Special semantics for the length */
+
+	if ((buffer->length == ACPI_NO_BUFFER)              ||
+		(buffer->length == ACPI_ALLOCATE_BUFFER)        ||
+		(buffer->length == ACPI_ALLOCATE_LOCAL_BUFFER)) {
+		return (AE_OK);
+	}
+
+	/* Length is valid, the buffer pointer must be also */
 
+	if (!buffer->pointer) {
+		return (AE_BAD_PARAMETER);
+	}
+
+	return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_initialize_buffer
+ *
+ * PARAMETERS:  required_length     - Length needed
+ *              Buffer              - Buffer to be validated
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Validate that the buffer is of the required length or
+ *              allocate a new buffer.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ut_initialize_buffer (
+	struct acpi_buffer              *buffer,
+	acpi_size                       required_length)
+{
+	acpi_status                     status = AE_OK;
+
+
+	switch (buffer->length) {
+	case ACPI_NO_BUFFER:
+
+		/* Set the exception and returned the required length */
+
+		status = AE_BUFFER_OVERFLOW;
+		break;
+
+
+	case ACPI_ALLOCATE_BUFFER:
+
+		/* Allocate a new buffer */
+
+		buffer->pointer = acpi_os_allocate (required_length);
+		if (!buffer->pointer) {
+			return (AE_NO_MEMORY);
+		}
+
+		/* Clear the buffer */
+
+		ACPI_MEMSET (buffer->pointer, 0, required_length);
+		break;
+
+
+	case ACPI_ALLOCATE_LOCAL_BUFFER:
+
+		/* Allocate a new buffer with local interface to allow tracking */
+
+		buffer->pointer = ACPI_MEM_ALLOCATE (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 */
+
+		if (buffer->length < required_length) {
+			status = AE_BUFFER_OVERFLOW;
+		}
+		break;
+	}
+
+	buffer->length = required_length;
+	return (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_allocate
+ *
+ * PARAMETERS:  Size                - Size of the allocation
+ *              Component           - Component type of caller
+ *              Module              - Source file name of caller
+ *              Line                - Line number of caller
+ *
+ * RETURN:      Address of the allocated memory on success, NULL on failure.
+ *
+ * DESCRIPTION: The subsystem's equivalent of malloc.
+ *
+ ******************************************************************************/
+
+void *
+acpi_ut_allocate (
+	acpi_size                       size,
+	u32                             component,
+	char                            *module,
+	u32                             line)
+{
+	void                            *allocation;
+
+
+	ACPI_FUNCTION_TRACE_U32 ("ut_allocate", size);
+
+
+	/* Check for an inadvertent size of zero bytes */
+
+	if (!size) {
+		_ACPI_REPORT_ERROR (module, line, component,
+				("ut_allocate: Attempt to allocate zero bytes\n"));
+		size = 1;
+	}
+
+	allocation = acpi_os_allocate (size);
+	if (!allocation) {
+		/* Report allocation error */
 
+		_ACPI_REPORT_ERROR (module, line, component,
+				("ut_allocate: Could not allocate size %X\n", (u32) size));
+
+		return_PTR (NULL);
+	}
+
+	return_PTR (allocation);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_callocate
+ *
+ * PARAMETERS:  Size                - Size of the allocation
+ *              Component           - Component type of caller
+ *              Module              - Source file name of caller
+ *              Line                - Line number of caller
+ *
+ * RETURN:      Address of the allocated memory on success, NULL on failure.
+ *
+ * DESCRIPTION: Subsystem equivalent of calloc.
+ *
+ ******************************************************************************/
+
+void *
+acpi_ut_callocate (
+	acpi_size                       size,
+	u32                             component,
+	char                            *module,
+	u32                             line)
+{
+	void                            *allocation;
+
+
+	ACPI_FUNCTION_TRACE_U32 ("ut_callocate", size);
+
+
+	/* Check for an inadvertent size of zero bytes */
+
+	if (!size) {
+		_ACPI_REPORT_ERROR (module, line, component,
+				("ut_callocate: Attempt to allocate zero bytes\n"));
+		return_PTR (NULL);
+	}
+
+	allocation = acpi_os_allocate (size);
+	if (!allocation) {
+		/* Report allocation error */
+
+		_ACPI_REPORT_ERROR (module, line, component,
+				("ut_callocate: Could not allocate size %X\n", (u32) size));
+		return_PTR (NULL);
+	}
+
+	/* Clear the memory block */
+
+	ACPI_MEMSET (allocation, 0, size);
+	return_PTR (allocation);
+}
+
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
 /*
  * These procedures are used for tracking memory leaks in the subsystem, and
  * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set.
  *
  * Each memory allocation is tracked via a doubly linked list.  Each
  * element contains the caller's component, module name, function name, and
- * line number.  Acpi_ut_allocate and Acpi_ut_callocate call
- * Acpi_ut_track_allocation to add an element to the list; deletion
- * occurs in the body of Acpi_ut_free.
+ * line number.  acpi_ut_allocate and acpi_ut_callocate call
+ * acpi_ut_track_allocation to add an element to the list; deletion
+ * occurs in the body of acpi_ut_free.
  */
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_find_allocation
+ * FUNCTION:    acpi_ut_allocate_and_track
+ *
+ * PARAMETERS:  Size                - Size of the allocation
+ *              Component           - Component type of caller
+ *              Module              - Source file name of caller
+ *              Line                - Line number of caller
+ *
+ * RETURN:      Address of the allocated memory on success, NULL on failure.
+ *
+ * DESCRIPTION: The subsystem's equivalent of malloc.
+ *
+ ******************************************************************************/
+
+void *
+acpi_ut_allocate_and_track (
+	acpi_size                       size,
+	u32                             component,
+	char                            *module,
+	u32                             line)
+{
+	struct acpi_debug_mem_block     *allocation;
+	acpi_status                     status;
+
+
+	allocation = acpi_ut_allocate (size + sizeof (struct acpi_debug_mem_block), component,
+			  module, line);
+	if (!allocation) {
+		return (NULL);
+	}
+
+	status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, allocation, size,
+			  ACPI_MEM_MALLOC, component, module, line);
+	if (ACPI_FAILURE (status)) {
+		acpi_os_free (allocation);
+		return (NULL);
+	}
+
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++;
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += (u32) size;
+
+	return ((void *) &allocation->user_space);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_callocate_and_track
+ *
+ * PARAMETERS:  Size                - Size of the allocation
+ *              Component           - Component type of caller
+ *              Module              - Source file name of caller
+ *              Line                - Line number of caller
+ *
+ * RETURN:      Address of the allocated memory on success, NULL on failure.
+ *
+ * DESCRIPTION: Subsystem equivalent of calloc.
+ *
+ ******************************************************************************/
+
+void *
+acpi_ut_callocate_and_track (
+	acpi_size                       size,
+	u32                             component,
+	char                            *module,
+	u32                             line)
+{
+	struct acpi_debug_mem_block     *allocation;
+	acpi_status                     status;
+
+
+	allocation = acpi_ut_callocate (size + sizeof (struct acpi_debug_mem_block), component,
+			  module, line);
+	if (!allocation) {
+		/* Report allocation error */
+
+		_ACPI_REPORT_ERROR (module, line, component,
+				("ut_callocate: Could not allocate size %X\n", (u32) size));
+		return (NULL);
+	}
+
+	status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, allocation, size,
+			   ACPI_MEM_CALLOC, component, module, line);
+	if (ACPI_FAILURE (status)) {
+		acpi_os_free (allocation);
+		return (NULL);
+	}
+
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++;
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += (u32) size;
+
+	return ((void *) &allocation->user_space);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_free_and_track
+ *
+ * PARAMETERS:  Allocation          - Address of the memory to deallocate
+ *              Component           - Component type of caller
+ *              Module              - Source file name of caller
+ *              Line                - Line number of caller
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Frees the memory at Allocation
+ *
+ ******************************************************************************/
+
+void
+acpi_ut_free_and_track (
+	void                            *allocation,
+	u32                             component,
+	char                            *module,
+	u32                             line)
+{
+	struct acpi_debug_mem_block     *debug_block;
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_TRACE_PTR ("ut_free", allocation);
+
+
+	if (NULL == allocation) {
+		_ACPI_REPORT_ERROR (module, line, component,
+			("acpi_ut_free: Attempt to delete a NULL address\n"));
+
+		return_VOID;
+	}
+
+	debug_block = ACPI_CAST_PTR (struct acpi_debug_mem_block,
+			  (((char *) allocation) - sizeof (struct acpi_debug_mem_header)));
+
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_freed++;
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size -= debug_block->size;
+
+	status = acpi_ut_remove_allocation (ACPI_MEM_LIST_GLOBAL, debug_block,
+			  component, module, line);
+	if (ACPI_FAILURE (status)) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not free memory, %s\n",
+			acpi_format_exception (status)));
+	}
+
+	acpi_os_free (debug_block);
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation));
+
+	return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_find_allocation
  *
- * PARAMETERS:  Address             - Address of allocated memory
+ * PARAMETERS:  Allocation             - Address of allocated memory
  *
  * RETURN:      A list element if found; NULL otherwise.
  *
@@ -218,15 +611,15 @@
  *
  ******************************************************************************/
 
-acpi_debug_mem_block *
+struct acpi_debug_mem_block *
 acpi_ut_find_allocation (
-	u32                     list_id,
-	void                    *address)
+	u32                             list_id,
+	void                            *allocation)
 {
-	acpi_debug_mem_block    *element;
+	struct acpi_debug_mem_block     *element;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	if (list_id > ACPI_MEM_LIST_MAX) {
@@ -238,7 +631,7 @@
 	/* Search for the address. */
 
 	while (element) {
-		if (element == address) {
+		if (element == allocation) {
 			return (element);
 		}
 
@@ -251,11 +644,11 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_track_allocation
+ * FUNCTION:    acpi_ut_track_allocation
  *
- * PARAMETERS:  Address             - Address of allocated memory
+ * PARAMETERS:  Allocation          - Address of allocated memory
  *              Size                - Size of the allocation
- *              Alloc_type          - MEM_MALLOC or MEM_CALLOC
+ *              alloc_type          - MEM_MALLOC or MEM_CALLOC
  *              Component           - Component type of caller
  *              Module              - Source file name of caller
  *              Line                - Line number of caller
@@ -268,20 +661,20 @@
 
 acpi_status
 acpi_ut_track_allocation (
-	u32                     list_id,
-	acpi_debug_mem_block    *address,
-	u32                     size,
-	u8                      alloc_type,
-	u32                     component,
-	NATIVE_CHAR             *module,
-	u32                     line)
-{
-	ACPI_MEMORY_LIST        *mem_list;
-	acpi_debug_mem_block    *element;
-	acpi_status             status = AE_OK;
+	u32                             list_id,
+	struct acpi_debug_mem_block     *allocation,
+	acpi_size                       size,
+	u8                              alloc_type,
+	u32                             component,
+	char                            *module,
+	u32                             line)
+{
+	struct acpi_memory_list         *mem_list;
+	struct acpi_debug_mem_block     *element;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE_PTR ("Ut_track_allocation", address);
+	ACPI_FUNCTION_TRACE_PTR ("ut_track_allocation", allocation);
 
 
 	if (list_id > ACPI_MEM_LIST_MAX) {
@@ -289,55 +682,58 @@
 	}
 
 	mem_list = &acpi_gbl_memory_lists[list_id];
-	acpi_ut_acquire_mutex (ACPI_MTX_MEMORY);
+	status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	/*
 	 * Search list for this address to make sure it is not already on the list.
 	 * This will catch several kinds of problems.
 	 */
 
-	element = acpi_ut_find_allocation (list_id, address);
+	element = acpi_ut_find_allocation (list_id, allocation);
 	if (element) {
-		REPORT_ERROR (("Ut_track_allocation: Address already present in list! (%p)\n",
-			address));
+		ACPI_REPORT_ERROR (("ut_track_allocation: Allocation already present in list! (%p)\n",
+			allocation));
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", element, address));
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", element, allocation));
 
 		goto unlock_and_exit;
 	}
 
 	/* Fill in the instance data. */
 
-	address->size      = size;
-	address->alloc_type = alloc_type;
-	address->component = component;
-	address->line      = line;
+	allocation->size      = (u32) size;
+	allocation->alloc_type = alloc_type;
+	allocation->component = component;
+	allocation->line      = line;
 
-	STRNCPY (address->module, module, MAX_MODULE_NAME);
+	ACPI_STRNCPY (allocation->module, module, ACPI_MAX_MODULE_NAME);
 
 	/* Insert at list head */
 
 	if (mem_list->list_head) {
-		((acpi_debug_mem_block *)(mem_list->list_head))->previous = address;
+		((struct acpi_debug_mem_block *)(mem_list->list_head))->previous = allocation;
 	}
 
-	address->next = mem_list->list_head;
-	address->previous = NULL;
+	allocation->next = mem_list->list_head;
+	allocation->previous = NULL;
 
-	mem_list->list_head = address;
+	mem_list->list_head = allocation;
 
 
 unlock_and_exit:
-	acpi_ut_release_mutex (ACPI_MTX_MEMORY);
+	status = acpi_ut_release_mutex (ACPI_MTX_MEMORY);
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_remove_allocation
+ * FUNCTION:    acpi_ut_remove_allocation
  *
- * PARAMETERS:  Address             - Address of allocated memory
+ * PARAMETERS:  Allocation          - Address of allocated memory
  *              Component           - Component type of caller
  *              Module              - Source file name of caller
  *              Line                - Line number of caller
@@ -350,16 +746,17 @@
 
 acpi_status
 acpi_ut_remove_allocation (
-	u32                     list_id,
-	acpi_debug_mem_block    *address,
-	u32                     component,
-	NATIVE_CHAR             *module,
-	u32                     line)
+	u32                             list_id,
+	struct acpi_debug_mem_block     *allocation,
+	u32                             component,
+	char                            *module,
+	u32                             line)
 {
-	ACPI_MEMORY_LIST        *mem_list;
+	struct acpi_memory_list         *mem_list;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Ut_remove_allocation");
+	ACPI_FUNCTION_TRACE ("ut_remove_allocation");
 
 
 	if (list_id > ACPI_MEM_LIST_MAX) {
@@ -370,43 +767,44 @@
 	if (NULL == mem_list->list_head) {
 		/* No allocations! */
 
-		_REPORT_ERROR (module, line, component,
-				("Ut_remove_allocation: Empty allocation list, nothing to free!\n"));
+		_ACPI_REPORT_ERROR (module, line, component,
+				("ut_remove_allocation: Empty allocation list, nothing to free!\n"));
 
 		return_ACPI_STATUS (AE_OK);
 	}
 
-
-	acpi_ut_acquire_mutex (ACPI_MTX_MEMORY);
+	status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	/* Unlink */
 
-	if (address->previous) {
-		(address->previous)->next = address->next;
+	if (allocation->previous) {
+		(allocation->previous)->next = allocation->next;
 	}
 	else {
-		mem_list->list_head = address->next;
+		mem_list->list_head = allocation->next;
 	}
 
-	if (address->next) {
-		(address->next)->previous = address->previous;
+	if (allocation->next) {
+		(allocation->next)->previous = allocation->previous;
 	}
 
-
 	/* Mark the segment as deleted */
 
-	MEMSET (&address->user_space, 0xEA, address->size);
+	ACPI_MEMSET (&allocation->user_space, 0xEA, allocation->size);
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size %X\n", address->size));
+	ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size %X\n", allocation->size));
 
-	acpi_ut_release_mutex (ACPI_MTX_MEMORY);
-	return_ACPI_STATUS (AE_OK);
+	status = acpi_ut_release_mutex (ACPI_MTX_MEMORY);
+	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_dump_allocation_info
+ * FUNCTION:    acpi_ut_dump_allocation_info
  *
  * PARAMETERS:
  *
@@ -421,43 +819,43 @@
 	void)
 {
 /*
-	ACPI_MEMORY_LIST        *Mem_list;
+	struct acpi_memory_list         *mem_list;
 */
 
-	FUNCTION_TRACE ("Ut_dump_allocation_info");
+	ACPI_FUNCTION_TRACE ("ut_dump_allocation_info");
 
 /*
 	ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
 			  ("%30s: %4d (%3d Kb)\n", "Current allocations",
-			  Mem_list->Current_count,
-			  ROUND_UP_TO_1K (Mem_list->Current_size)));
+			  mem_list->current_count,
+			  ROUND_UP_TO_1K (mem_list->current_size)));
 
 	ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
 			  ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations",
-			  Mem_list->Max_concurrent_count,
-			  ROUND_UP_TO_1K (Mem_list->Max_concurrent_size)));
+			  mem_list->max_concurrent_count,
+			  ROUND_UP_TO_1K (mem_list->max_concurrent_size)));
 
 
 	ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
 			  ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",
-			  Running_object_count,
-			  ROUND_UP_TO_1K (Running_object_size)));
+			  running_object_count,
+			  ROUND_UP_TO_1K (running_object_size)));
 
 	ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
 			  ("%30s: %4d (%3d Kb)\n", "Total (all) allocations",
-			  Running_alloc_count,
-			  ROUND_UP_TO_1K (Running_alloc_size)));
+			  running_alloc_count,
+			  ROUND_UP_TO_1K (running_alloc_size)));
 
 
 	ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
 			  ("%30s: %4d (%3d Kb)\n", "Current Nodes",
-			  Acpi_gbl_Current_node_count,
-			  ROUND_UP_TO_1K (Acpi_gbl_Current_node_size)));
+			  acpi_gbl_current_node_count,
+			  ROUND_UP_TO_1K (acpi_gbl_current_node_size)));
 
 	ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
 			  ("%30s: %4d (%3d Kb)\n", "Max Nodes",
-			  Acpi_gbl_Max_concurrent_node_count,
-			  ROUND_UP_TO_1K ((Acpi_gbl_Max_concurrent_node_count * sizeof (acpi_namespace_node)))));
+			  acpi_gbl_max_concurrent_node_count,
+			  ROUND_UP_TO_1K ((acpi_gbl_max_concurrent_node_count * sizeof (struct acpi_namespace_node)))));
 */
 	return_VOID;
 }
@@ -465,7 +863,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_dump_allocations
+ * FUNCTION:    acpi_ut_dump_allocations
  *
  * PARAMETERS:  Component           - Component(s) to dump info for.
  *              Module              - Module to dump info for.  NULL means all.
@@ -478,306 +876,124 @@
 
 void
 acpi_ut_dump_allocations (
-	u32                     component,
-	NATIVE_CHAR             *module)
+	u32                             component,
+	char                            *module)
 {
-	acpi_debug_mem_block    *element;
-	u32                     i;
-
+	struct acpi_debug_mem_block     *element;
+	union acpi_descriptor           *descriptor;
+	u32                             num_outstanding = 0;
 
-	FUNCTION_TRACE ("Ut_dump_allocations");
 
-
-	element = acpi_gbl_memory_lists[0].list_head;
-	if (element == NULL) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_OK,
-				"No outstanding allocations.\n"));
-		return_VOID;
-	}
+	ACPI_FUNCTION_TRACE ("ut_dump_allocations");
 
 
 	/*
 	 * Walk the allocation list.
 	 */
-	acpi_ut_acquire_mutex (ACPI_MTX_MEMORY);
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_OK,
-		"Outstanding allocations:\n"));
+	if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_MEMORY))) {
+		return;
+	}
 
-	for (i = 1; ; i++)  /* Just a counter */ {
+	element = acpi_gbl_memory_lists[0].list_head;
+	while (element) {
 		if ((element->component & component) &&
-			((module == NULL) || (0 == STRCMP (module, element->module)))) {
-			if (((acpi_operand_object  *)(&element->user_space))->common.type != ACPI_CACHED_OBJECT) {
-				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-						 "%p Len %04X %9.9s-%d",
-						 &element->user_space, element->size, element->module,
-						 element->line));
+			((module == NULL) || (0 == ACPI_STRCMP (module, element->module)))) {
+			/* Ignore allocated objects that are in a cache */
+
+			descriptor = ACPI_CAST_PTR (union acpi_descriptor, &element->user_space);
+			if (descriptor->descriptor_id != ACPI_DESC_TYPE_CACHED) {
+				acpi_os_printf ("%p Len %04X %9.9s-%d ",
+						 descriptor, element->size, element->module,
+						 element->line);
 
 				/* Most of the elements will be internal objects. */
 
-				switch (((acpi_operand_object  *)
-					(&element->user_space))->common.data_type) {
-				case ACPI_DESC_TYPE_INTERNAL:
-					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-							" Obj_type %12.12s R%d",
-							acpi_ut_get_type_name (((acpi_operand_object *)(&element->user_space))->common.type),
-							((acpi_operand_object *)(&element->user_space))->common.reference_count));
+				switch (ACPI_GET_DESCRIPTOR_TYPE (descriptor)) {
+				case ACPI_DESC_TYPE_OPERAND:
+					acpi_os_printf ("obj_type %12.12s R%hd",
+							acpi_ut_get_type_name (descriptor->object.common.type),
+							descriptor->object.common.reference_count);
 					break;
 
 				case ACPI_DESC_TYPE_PARSER:
-					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-							" Parse_obj Opcode %04X",
-							((acpi_parse_object *)(&element->user_space))->opcode));
+					acpi_os_printf ("parse_obj aml_opcode %04hX",
+							descriptor->op.asl.aml_opcode);
 					break;
 
 				case ACPI_DESC_TYPE_NAMED:
-					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-							" Node %4.4s",
-							(char*)&((acpi_namespace_node *)(&element->user_space))->name));
+					acpi_os_printf ("Node %4.4s",
+							descriptor->node.name.ascii);
 					break;
 
 				case ACPI_DESC_TYPE_STATE:
-					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-							" Untyped State_obj"));
+					acpi_os_printf ("Untyped state_obj");
 					break;
 
 				case ACPI_DESC_TYPE_STATE_UPDATE:
-					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-							" UPDATE State_obj"));
+					acpi_os_printf ("UPDATE state_obj");
 					break;
 
 				case ACPI_DESC_TYPE_STATE_PACKAGE:
-					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-							" PACKAGE State_obj"));
+					acpi_os_printf ("PACKAGE state_obj");
 					break;
 
 				case ACPI_DESC_TYPE_STATE_CONTROL:
-					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-							" CONTROL State_obj"));
+					acpi_os_printf ("CONTROL state_obj");
 					break;
 
 				case ACPI_DESC_TYPE_STATE_RPSCOPE:
-					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-							" ROOT-PARSE-SCOPE State_obj"));
+					acpi_os_printf ("ROOT-PARSE-SCOPE state_obj");
 					break;
 
 				case ACPI_DESC_TYPE_STATE_PSCOPE:
-					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-							" PARSE-SCOPE State_obj"));
+					acpi_os_printf ("PARSE-SCOPE state_obj");
 					break;
 
 				case ACPI_DESC_TYPE_STATE_WSCOPE:
-					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-							" WALK-SCOPE State_obj"));
+					acpi_os_printf ("WALK-SCOPE state_obj");
 					break;
 
 				case ACPI_DESC_TYPE_STATE_RESULT:
-					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-							" RESULT State_obj"));
+					acpi_os_printf ("RESULT state_obj");
 					break;
 
 				case ACPI_DESC_TYPE_STATE_NOTIFY:
-					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-							" NOTIFY State_obj"));
+					acpi_os_printf ("NOTIFY state_obj");
+					break;
+
+				case ACPI_DESC_TYPE_STATE_THREAD:
+					acpi_os_printf ("THREAD state_obj");
+					break;
+
+				default:
+					/* All types should appear above */
 					break;
 				}
 
-				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "\n"));
+				acpi_os_printf ( "\n");
+				num_outstanding++;
 			}
 		}
-
-		if (element->next == NULL) {
-			break;
-		}
-
 		element = element->next;
 	}
 
-	acpi_ut_release_mutex (ACPI_MTX_MEMORY);
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_OK,
-		"Total number of unfreed allocations = %d(%X)\n", i,i));
-
-
-	return_VOID;
-
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ut_allocate
- *
- * PARAMETERS:  Size                - Size of the allocation
- *              Component           - Component type of caller
- *              Module              - Source file name of caller
- *              Line                - Line number of caller
- *
- * RETURN:      Address of the allocated memory on success, NULL on failure.
- *
- * DESCRIPTION: The subsystem's equivalent of malloc.
- *
- ******************************************************************************/
-
-void *
-acpi_ut_allocate (
-	u32                     size,
-	u32                     component,
-	NATIVE_CHAR             *module,
-	u32                     line)
-{
-	acpi_debug_mem_block    *address;
-	acpi_status             status;
+	(void) acpi_ut_release_mutex (ACPI_MTX_MEMORY);
 
+	/* Print summary */
 
-	FUNCTION_TRACE_U32 ("Ut_allocate", size);
-
-
-	/* Check for an inadvertent size of zero bytes */
-
-	if (!size) {
-		_REPORT_ERROR (module, line, component,
-				("Ut_allocate: Attempt to allocate zero bytes\n"));
-		size = 1;
-	}
-
-	address = acpi_os_allocate (size + sizeof (acpi_debug_mem_block));
-	if (!address) {
-		/* Report allocation error */
-
-		_REPORT_ERROR (module, line, component,
-				("Ut_allocate: Could not allocate size %X\n", size));
-
-		return_PTR (NULL);
-	}
-
-	status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, address, size,
-			  MEM_MALLOC, component, module, line);
-	if (ACPI_FAILURE (status)) {
-		acpi_os_free (address);
-		return_PTR (NULL);
-	}
-
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++;
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += size;
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", address, size));
-
-	return_PTR ((void *) &address->user_space);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ut_callocate
- *
- * PARAMETERS:  Size                - Size of the allocation
- *              Component           - Component type of caller
- *              Module              - Source file name of caller
- *              Line                - Line number of caller
- *
- * RETURN:      Address of the allocated memory on success, NULL on failure.
- *
- * DESCRIPTION: Subsystem equivalent of calloc.
- *
- ******************************************************************************/
-
-void *
-acpi_ut_callocate (
-	u32                     size,
-	u32                     component,
-	NATIVE_CHAR             *module,
-	u32                     line)
-{
-	acpi_debug_mem_block    *address;
-	acpi_status             status;
-
-
-	FUNCTION_TRACE_U32 ("Ut_callocate", size);
-
-
-	/* Check for an inadvertent size of zero bytes */
-
-	if (!size) {
-		_REPORT_ERROR (module, line, component,
-				("Ut_callocate: Attempt to allocate zero bytes\n"));
-		return_PTR (NULL);
-	}
-
-
-	address = acpi_os_callocate (size + sizeof (acpi_debug_mem_block));
-	if (!address) {
-		/* Report allocation error */
-
-		_REPORT_ERROR (module, line, component,
-				("Ut_callocate: Could not allocate size %X\n", size));
-		return_PTR (NULL);
-	}
-
-	status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, address, size,
-			   MEM_CALLOC, component, module, line);
-	if (ACPI_FAILURE (status)) {
-		acpi_os_free (address);
-		return_PTR (NULL);
+	if (!num_outstanding) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"No outstanding allocations.\n"));
 	}
-
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++;
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += size;
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", address, size));
-	return_PTR ((void *) &address->user_space);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ut_free
- *
- * PARAMETERS:  Address             - Address of the memory to deallocate
- *              Component           - Component type of caller
- *              Module              - Source file name of caller
- *              Line                - Line number of caller
- *
- * RETURN:      None
- *
- * DESCRIPTION: Frees the memory at Address
- *
- ******************************************************************************/
-
-void
-acpi_ut_free (
-	void                    *address,
-	u32                     component,
-	NATIVE_CHAR             *module,
-	u32                     line)
-{
-	acpi_debug_mem_block    *debug_block;
-
-
-	FUNCTION_TRACE_PTR ("Ut_free", address);
-
-
-	if (NULL == address) {
-		_REPORT_ERROR (module, line, component,
-			("Acpi_ut_free: Trying to delete a NULL address\n"));
-
-		return_VOID;
+	else {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"%d(%X) Outstanding allocations\n",
+			num_outstanding, num_outstanding));
 	}
 
-	debug_block = (acpi_debug_mem_block *)
-			  (((char *) address) - sizeof (acpi_debug_mem_header));
-
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_freed++;
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size -= debug_block->size;
-
-	acpi_ut_remove_allocation (ACPI_MEM_LIST_GLOBAL, debug_block,
-			component, module, line);
-	acpi_os_free (debug_block);
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", address));
-
 	return_VOID;
 }
 
+
 #endif  /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/utilities/utcopy.c linux-2.4.22-pre2/drivers/acpi/utilities/utcopy.c
--- linux-2.4.21/drivers/acpi/utilities/utcopy.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/utilities/utcopy.c	2003-06-26 21:43:19.000000000 +0000
@@ -1,46 +1,62 @@
 /******************************************************************************
  *
  * Module Name: utcopy - Internal to external object translation utilities
- *              $Revision: 83 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "amlcode.h"
+#include <acpi/acpi.h>
+#include <acpi/amlcode.h>
 
 
 #define _COMPONENT          ACPI_UTILITIES
-	 MODULE_NAME         ("utcopy")
+	 ACPI_MODULE_NAME    ("utcopy")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_copy_isimple_to_esimple
+ * FUNCTION:    acpi_ut_copy_isimple_to_esimple
  *
- * PARAMETERS:  *Internal_object    - Pointer to the object we are examining
+ * PARAMETERS:  *internal_object    - Pointer to the object we are examining
  *              *Buffer             - Where the object is returned
- *              *Space_used         - Where the data length is returned
+ *              *space_used         - Where the data length is returned
  *
  * RETURN:      Status
  *
@@ -53,106 +69,77 @@
 
 static acpi_status
 acpi_ut_copy_isimple_to_esimple (
-	acpi_operand_object     *internal_object,
-	acpi_object             *external_object,
-	u8                      *data_space,
-	u32                     *buffer_space_used)
+	union acpi_operand_object       *internal_object,
+	union acpi_object               *external_object,
+	u8                              *data_space,
+	acpi_size                       *buffer_space_used)
 {
-	u32                     length = 0;
-	acpi_status             status = AE_OK;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE ("Ut_copy_isimple_to_esimple");
+	ACPI_FUNCTION_TRACE ("ut_copy_isimple_to_esimple");
 
 
+	*buffer_space_used = 0;
+
 	/*
 	 * Check for NULL object case (could be an uninitialized
-	 * package element
+	 * package element)
 	 */
 	if (!internal_object) {
-		*buffer_space_used = 0;
 		return_ACPI_STATUS (AE_OK);
 	}
 
 	/* Always clear the external object */
 
-	MEMSET (external_object, 0, sizeof (acpi_object));
+	ACPI_MEMSET (external_object, 0, sizeof (union acpi_object));
 
 	/*
 	 * In general, the external object will be the same type as
 	 * the internal object
 	 */
-	external_object->type = internal_object->common.type;
+	external_object->type = ACPI_GET_OBJECT_TYPE (internal_object);
 
 	/* However, only a limited number of external types are supported */
 
-	switch (internal_object->common.type) {
-
+	switch (ACPI_GET_OBJECT_TYPE (internal_object)) {
 	case ACPI_TYPE_STRING:
 
-		length = internal_object->string.length + 1;
+		external_object->string.pointer = (char *) data_space;
 		external_object->string.length = internal_object->string.length;
-		external_object->string.pointer = (NATIVE_CHAR *) data_space;
-		MEMCPY ((void *) data_space, (void *) internal_object->string.pointer, length);
+		*buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD ((acpi_size) internal_object->string.length + 1);
+
+		ACPI_MEMCPY ((void *) data_space, (void *) internal_object->string.pointer,
+				 (acpi_size) internal_object->string.length + 1);
 		break;
 
 
 	case ACPI_TYPE_BUFFER:
 
-		length = internal_object->buffer.length;
-		external_object->buffer.length = internal_object->buffer.length;
 		external_object->buffer.pointer = data_space;
-		MEMCPY ((void *) data_space, (void *) internal_object->buffer.pointer, length);
+		external_object->buffer.length = internal_object->buffer.length;
+		*buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD (internal_object->string.length);
+
+		ACPI_MEMCPY ((void *) data_space, (void *) internal_object->buffer.pointer,
+				 internal_object->buffer.length);
 		break;
 
 
 	case ACPI_TYPE_INTEGER:
 
-		external_object->integer.value= internal_object->integer.value;
+		external_object->integer.value = internal_object->integer.value;
 		break;
 
 
-	case INTERNAL_TYPE_REFERENCE:
+	case ACPI_TYPE_LOCAL_REFERENCE:
 
 		/*
 		 * This is an object reference.  Attempt to dereference it.
 		 */
 		switch (internal_object->reference.opcode) {
-		case AML_ZERO_OP:
-			external_object->type = ACPI_TYPE_INTEGER;
-			external_object->integer.value = 0;
-			break;
-
-		case AML_ONE_OP:
-			external_object->type = ACPI_TYPE_INTEGER;
-			external_object->integer.value = 1;
-			break;
-
-		case AML_ONES_OP:
-			external_object->type = ACPI_TYPE_INTEGER;
-			external_object->integer.value = ACPI_INTEGER_MAX;
-			break;
-
-		case AML_REVISION_OP:
-			external_object->type = ACPI_TYPE_INTEGER;
-			external_object->integer.value = ACPI_CA_SUPPORT_LEVEL;
-			break;
-
 		case AML_INT_NAMEPATH_OP:
-			/*
-			 * This is a named reference, get the string.  We already know that
-			 * we have room for it, use max length
-			 */
-			length = MAX_STRING_LENGTH;
-			external_object->type = ACPI_TYPE_STRING;
-			external_object->string.pointer = (NATIVE_CHAR *) data_space;
-			status = acpi_ns_handle_to_pathname ((acpi_handle *) internal_object->reference.node,
-					 &length, (char *) data_space);
-
-			/* Converted (external) string length is returned from above */
 
-			external_object->string.length = length;
-			break;
+			/* For namepath, return the object handle ("reference") */
 
 		default:
 			/*
@@ -168,7 +155,7 @@
 
 	case ACPI_TYPE_PROCESSOR:
 
-		external_object->processor.proc_id = internal_object->processor.proc_id;
+		external_object->processor.proc_id    = internal_object->processor.proc_id;
 		external_object->processor.pblk_address = internal_object->processor.address;
 		external_object->processor.pblk_length = internal_object->processor.length;
 		break;
@@ -189,21 +176,17 @@
 		 * There is no corresponding external object type
 		 */
 		return_ACPI_STATUS (AE_SUPPORT);
-		break;
 	}
 
-
-	*buffer_space_used = (u32) ROUND_UP_TO_NATIVE_WORD (length);
-
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_copy_ielement_to_eelement
+ * FUNCTION:    acpi_ut_copy_ielement_to_eelement
  *
- * PARAMETERS:  ACPI_PKG_CALLBACK
+ * PARAMETERS:  acpi_pkg_callback
  *
  * RETURN:      Status
  *
@@ -213,39 +196,39 @@
 
 acpi_status
 acpi_ut_copy_ielement_to_eelement (
-	u8                      object_type,
-	acpi_operand_object     *source_object,
-	acpi_generic_state      *state,
-	void                    *context)
-{
-	acpi_status             status = AE_OK;
-	acpi_pkg_info           *info = (acpi_pkg_info *) context;
-	u32                     object_space;
-	u32                     this_index;
-	acpi_object             *target_object;
+	u8                              object_type,
+	union acpi_operand_object       *source_object,
+	union acpi_generic_state        *state,
+	void                            *context)
+{
+	acpi_status                     status = AE_OK;
+	struct acpi_pkg_info            *info = (struct acpi_pkg_info *) context;
+	acpi_size                       object_space;
+	u32                             this_index;
+	union acpi_object               *target_object;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	this_index   = state->pkg.index;
-	target_object = (acpi_object *)
-			  &((acpi_object *)(state->pkg.dest_object))->package.elements[this_index];
+	target_object = (union acpi_object *)
+			  &((union acpi_object *)(state->pkg.dest_object))->package.elements[this_index];
 
 	switch (object_type) {
 	case ACPI_COPY_TYPE_SIMPLE:
 
 		/*
-		 * This is a simple or null object -- get the size
+		 * This is a simple or null object
 		 */
 		status = acpi_ut_copy_isimple_to_esimple (source_object,
 				  target_object, info->free_space, &object_space);
 		if (ACPI_FAILURE (status)) {
 			return (status);
 		}
-
 		break;
 
+
 	case ACPI_COPY_TYPE_PACKAGE:
 
 		/*
@@ -253,7 +236,7 @@
 		 */
 		target_object->type             = ACPI_TYPE_PACKAGE;
 		target_object->package.count    = source_object->package.count;
-		target_object->package.elements = (acpi_object *) info->free_space;
+		target_object->package.elements = ACPI_CAST_PTR (union acpi_object, info->free_space);
 
 		/*
 		 * Pass the new package object back to the package walk routine
@@ -264,29 +247,28 @@
 		 * Save space for the array of objects (Package elements)
 		 * update the buffer length counter
 		 */
-		object_space = (u32) ROUND_UP_TO_NATIVE_WORD (
-				   target_object->package.count * sizeof (acpi_object));
+		object_space = ACPI_ROUND_UP_TO_NATIVE_WORD (
+				   (acpi_size) target_object->package.count * sizeof (union acpi_object));
 		break;
 
+
 	default:
 		return (AE_BAD_PARAMETER);
 	}
 
-
 	info->free_space  += object_space;
 	info->length      += object_space;
-
 	return (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_copy_ipackage_to_epackage
+ * FUNCTION:    acpi_ut_copy_ipackage_to_epackage
  *
- * PARAMETERS:  *Internal_object    - Pointer to the object we are returning
+ * PARAMETERS:  *internal_object    - Pointer to the object we are returning
  *              *Buffer             - Where the object is returned
- *              *Space_used         - Where the object length is returned
+ *              *space_used         - Where the object length is returned
  *
  * RETURN:      Status
  *
@@ -295,66 +277,64 @@
  *
  *              The buffer is assumed to have sufficient space for the object.
  *              The caller must have verified the buffer length needed using the
- *              Acpi_ut_get_object_size function before calling this function.
+ *              acpi_ut_get_object_size function before calling this function.
  *
  ******************************************************************************/
 
 static acpi_status
 acpi_ut_copy_ipackage_to_epackage (
-	acpi_operand_object     *internal_object,
-	u8                      *buffer,
-	u32                     *space_used)
+	union acpi_operand_object       *internal_object,
+	u8                              *buffer,
+	acpi_size                       *space_used)
 {
-	acpi_object             *external_object;
-	acpi_status             status;
-	acpi_pkg_info           info;
+	union acpi_object               *external_object;
+	acpi_status                     status;
+	struct acpi_pkg_info            info;
 
 
-	FUNCTION_TRACE ("Ut_copy_ipackage_to_epackage");
+	ACPI_FUNCTION_TRACE ("ut_copy_ipackage_to_epackage");
 
 
 	/*
 	 * First package at head of the buffer
 	 */
-	external_object = (acpi_object *) buffer;
+	external_object = ACPI_CAST_PTR (union acpi_object, buffer);
 
 	/*
 	 * Free space begins right after the first package
 	 */
-	info.length      = 0;
+	info.length      = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object));
+	info.free_space  = buffer + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object));
 	info.object_space = 0;
 	info.num_packages = 1;
-	info.free_space  = buffer + ROUND_UP_TO_NATIVE_WORD (sizeof (acpi_object));
-
-
-	external_object->type              = internal_object->common.type;
-	external_object->package.count     = internal_object->package.count;
-	external_object->package.elements  = (acpi_object *) info.free_space;
 
+	external_object->type            = ACPI_GET_OBJECT_TYPE (internal_object);
+	external_object->package.count   = internal_object->package.count;
+	external_object->package.elements = ACPI_CAST_PTR (union acpi_object, info.free_space);
 
 	/*
-	 * Build an array of ACPI_OBJECTS in the buffer
+	 * Leave room for an array of ACPI_OBJECTS in the buffer
 	 * and move the free space past it
 	 */
+	info.length    += (acpi_size) external_object->package.count *
+			 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object));
 	info.free_space += external_object->package.count *
-			  ROUND_UP_TO_NATIVE_WORD (sizeof (acpi_object));
-
+			 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object));
 
 	status = acpi_ut_walk_package_tree (internal_object, external_object,
 			 acpi_ut_copy_ielement_to_eelement, &info);
 
 	*space_used = info.length;
-
 	return_ACPI_STATUS (status);
-
 }
 
+
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_copy_iobject_to_eobject
+ * FUNCTION:    acpi_ut_copy_iobject_to_eobject
  *
- * PARAMETERS:  *Internal_object    - The internal object to be converted
- *              *Buffer_ptr         - Where the object is returned
+ * PARAMETERS:  *internal_object    - The internal object to be converted
+ *              *buffer_ptr         - Where the object is returned
  *
  * RETURN:      Status
  *
@@ -365,16 +345,16 @@
 
 acpi_status
 acpi_ut_copy_iobject_to_eobject (
-	acpi_operand_object     *internal_object,
-	acpi_buffer             *ret_buffer)
+	union acpi_operand_object       *internal_object,
+	struct acpi_buffer              *ret_buffer)
 {
-	acpi_status             status;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Ut_copy_iobject_to_eobject");
+	ACPI_FUNCTION_TRACE ("ut_copy_iobject_to_eobject");
 
 
-	if (IS_THIS_OBJECT_TYPE (internal_object, ACPI_TYPE_PACKAGE)) {
+	if (ACPI_GET_OBJECT_TYPE (internal_object) == ACPI_TYPE_PACKAGE) {
 		/*
 		 * Package object:  Copy all subobjects (including
 		 * nested packages)
@@ -382,21 +362,20 @@
 		status = acpi_ut_copy_ipackage_to_epackage (internal_object,
 				  ret_buffer->pointer, &ret_buffer->length);
 	}
-
 	else {
 		/*
 		 * Build a simple object (no nested objects)
 		 */
 		status = acpi_ut_copy_isimple_to_esimple (internal_object,
-				  (acpi_object *) ret_buffer->pointer,
+				  (union acpi_object *) ret_buffer->pointer,
 				  ((u8 *) ret_buffer->pointer +
-				  ROUND_UP_TO_NATIVE_WORD (sizeof (acpi_object))),
+				  ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object))),
 				  &ret_buffer->length);
 		/*
 		 * build simple does not include the object size in the length
 		 * so we add it in here
 		 */
-		ret_buffer->length += sizeof (acpi_object);
+		ret_buffer->length += sizeof (union acpi_object);
 	}
 
 	return_ACPI_STATUS (status);
@@ -405,10 +384,10 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_copy_esimple_to_isimple
+ * FUNCTION:    acpi_ut_copy_esimple_to_isimple
  *
- * PARAMETERS:  *External_object   - The external object to be converted
- *              *Internal_object   - Where the internal object is returned
+ * PARAMETERS:  *external_object   - The external object to be converted
+ *              *internal_object   - Where the internal object is returned
  *
  * RETURN:      Status
  *
@@ -421,13 +400,13 @@
 
 acpi_status
 acpi_ut_copy_esimple_to_isimple (
-	acpi_object             *external_object,
-	acpi_operand_object     **ret_internal_object)
+	union acpi_object               *external_object,
+	union acpi_operand_object       **ret_internal_object)
 {
-	acpi_operand_object     *internal_object;
+	union acpi_operand_object       *internal_object;
 
 
-	FUNCTION_TRACE ("Ut_copy_esimple_to_isimple");
+	ACPI_FUNCTION_TRACE ("ut_copy_esimple_to_isimple");
 
 
 	/*
@@ -449,7 +428,6 @@
 		 * Whatever other type -- it is not supported
 		 */
 		return_ACPI_STATUS (AE_SUPPORT);
-		break;
 	}
 
 
@@ -459,14 +437,15 @@
 
 	case ACPI_TYPE_STRING:
 
-		internal_object->string.pointer = ACPI_MEM_CALLOCATE (external_object->string.length + 1);
+		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);
 		}
 
-		MEMCPY (internal_object->string.pointer,
-				external_object->string.pointer,
-				external_object->string.length);
+		ACPI_MEMCPY (internal_object->string.pointer,
+				  external_object->string.pointer,
+				  external_object->string.length);
 
 		internal_object->string.length = external_object->string.length;
 		break;
@@ -474,14 +453,15 @@
 
 	case ACPI_TYPE_BUFFER:
 
-		internal_object->buffer.pointer = ACPI_MEM_CALLOCATE (external_object->buffer.length);
+		internal_object->buffer.pointer =
+			ACPI_MEM_CALLOCATE (external_object->buffer.length);
 		if (!internal_object->buffer.pointer) {
 			return_ACPI_STATUS (AE_NO_MEMORY);
 		}
 
-		MEMCPY (internal_object->buffer.pointer,
-				external_object->buffer.pointer,
-				external_object->buffer.length);
+		ACPI_MEMCPY (internal_object->buffer.pointer,
+				  external_object->buffer.pointer,
+				  external_object->buffer.length);
 
 		internal_object->buffer.length = external_object->buffer.length;
 		break;
@@ -491,8 +471,11 @@
 
 		internal_object->integer.value  = external_object->integer.value;
 		break;
-	}
 
+	default:
+		/* Other types can't get here */
+		break;
+	}
 
 	*ret_internal_object = internal_object;
 	return_ACPI_STATUS (AE_OK);
@@ -505,65 +488,64 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_copy_epackage_to_ipackage
+ * FUNCTION:    acpi_ut_copy_epackage_to_ipackage
  *
- * PARAMETERS:  *Internal_object   - Pointer to the object we are returning
- *              *Buffer         - Where the object is returned
- *              *Space_used     - Where the length of the object is returned
+ * PARAMETERS:  *internal_object   - Pointer to the object we are returning
+ *              *Buffer            - Where the object is returned
+ *              *space_used        - Where the length of the object is returned
  *
- * RETURN:      Status          - the status of the call
+ * RETURN:      Status
  *
  * DESCRIPTION: This function is called to place a package object in a user
  *              buffer.  A package object by definition contains other objects.
  *
  *              The buffer is assumed to have sufficient space for the object.
  *              The caller must have verified the buffer length needed using the
- *              Acpi_ut_get_object_size function before calling this function.
+ *              acpi_ut_get_object_size function before calling this function.
  *
  ******************************************************************************/
 
 static acpi_status
 acpi_ut_copy_epackage_to_ipackage (
-	acpi_operand_object     *internal_object,
-	u8                      *buffer,
-	u32                     *space_used)
-{
-	u8                      *free_space;
-	acpi_object             *external_object;
-	u32                     length = 0;
-	u32                     this_index;
-	u32                     object_space = 0;
-	acpi_operand_object     *this_internal_obj;
-	acpi_object             *this_external_obj;
+	union acpi_operand_object       *internal_object,
+	u8                              *buffer,
+	u32                             *space_used)
+{
+	u8                              *free_space;
+	union acpi_object               *external_object;
+	u32                             length = 0;
+	u32                             this_index;
+	u32                             object_space = 0;
+	union acpi_operand_object       *this_internal_obj;
+	union acpi_object               *this_external_obj;
 
 
-	FUNCTION_TRACE ("Ut_copy_epackage_to_ipackage");
+	ACPI_FUNCTION_TRACE ("ut_copy_epackage_to_ipackage");
 
 
 	/*
 	 * First package at head of the buffer
 	 */
-	external_object = (acpi_object *)buffer;
+	external_object = (union acpi_object *)buffer;
 
 	/*
 	 * Free space begins right after the first package
 	 */
-	free_space = buffer + sizeof(acpi_object);
+	free_space = buffer + sizeof(union acpi_object);
 
 
-	external_object->type              = internal_object->common.type;
+	external_object->type              = ACPI_GET_OBJECT_TYPE (internal_object);
 	external_object->package.count     = internal_object->package.count;
-	external_object->package.elements  = (acpi_object *)free_space;
-
+	external_object->package.elements  = (union acpi_object *)free_space;
 
 	/*
 	 * Build an array of ACPI_OBJECTS in the buffer
 	 * and move the free space past it
 	 */
-	free_space += external_object->package.count * sizeof(acpi_object);
+	free_space += external_object->package.count * sizeof(union acpi_object);
 
 
-	/* Call Walk_package */
+	/* Call walk_package */
 
 }
 
@@ -572,10 +554,10 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_copy_eobject_to_iobject
+ * FUNCTION:    acpi_ut_copy_eobject_to_iobject
  *
- * PARAMETERS:  *Internal_object   - The external object to be converted
- *              *Buffer_ptr     - Where the internal object is returned
+ * PARAMETERS:  *internal_object   - The external object to be converted
+ *              *buffer_ptr     - Where the internal object is returned
  *
  * RETURN:      Status          - the status of the call
  *
@@ -585,29 +567,19 @@
 
 acpi_status
 acpi_ut_copy_eobject_to_iobject (
-	acpi_object             *external_object,
-	acpi_operand_object     **internal_object)
+	union acpi_object               *external_object,
+	union acpi_operand_object       **internal_object)
 {
-	acpi_status             status;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Ut_copy_eobject_to_iobject");
+	ACPI_FUNCTION_TRACE ("ut_copy_eobject_to_iobject");
 
 
 	if (external_object->type == ACPI_TYPE_PACKAGE) {
 		/*
-		 * Package objects contain other objects (which can be objects)
-		 * buildpackage does it all
-		 *
-		 * TBD: Package conversion must be completed and tested
-		 * NOTE: this code converts packages as input parameters to
-		 * control methods only.  This is a very, very rare case.
+		 * Packages as external input to control methods are not supported,
 		 */
-/*
-		Status = Acpi_ut_copy_epackage_to_ipackage(Internal_object,
-				 Ret_buffer->Pointer,
-				 &Ret_buffer->Length);
-*/
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 			"Packages as parameters not implemented!\n"));
 
@@ -627,11 +599,112 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_copy_ielement_to_ielement
+ * FUNCTION:    acpi_ut_copy_simple_object
  *
- * PARAMETERS:  ACPI_PKG_CALLBACK
+ * PARAMETERS:  source_desc         - The internal object to be copied
+ *              dest_desc           - New target object
  *
- * RETURN:      Status          - the status of the call
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Simple copy of one internal object to another.  Reference count
+ *              of the destination object is preserved.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ut_copy_simple_object (
+	union acpi_operand_object       *source_desc,
+	union acpi_operand_object       *dest_desc)
+{
+	u16                             reference_count;
+	union acpi_operand_object       *next_object;
+
+
+	/* Save fields from destination that we don't want to overwrite */
+
+	reference_count = dest_desc->common.reference_count;
+	next_object = dest_desc->common.next_object;
+
+	/* Copy the entire source object over the destination object*/
+
+	ACPI_MEMCPY ((char *) dest_desc, (char *) source_desc,
+			  sizeof (union acpi_operand_object));
+
+	/* Restore the saved fields */
+
+	dest_desc->common.reference_count = reference_count;
+	dest_desc->common.next_object = next_object;
+
+	/* Handle the objects with extra data */
+
+	switch (ACPI_GET_OBJECT_TYPE (dest_desc)) {
+	case ACPI_TYPE_BUFFER:
+
+		dest_desc->buffer.node = NULL;
+		dest_desc->common.flags = source_desc->common.flags;
+
+		/*
+		 * Allocate and copy the actual buffer if and only if:
+		 * 1) There is a valid buffer pointer
+		 * 2) The buffer is not static (not in an ACPI table) (in this case,
+		 *    the actual pointer was already copied above)
+		 */
+		if ((source_desc->buffer.pointer) &&
+			(!(source_desc->common.flags & AOPOBJ_STATIC_POINTER))) {
+			dest_desc->buffer.pointer = NULL;
+
+			/* Create an actual buffer only if length > 0 */
+
+			if (source_desc->buffer.length) {
+				dest_desc->buffer.pointer = ACPI_MEM_ALLOCATE (source_desc->buffer.length);
+				if (!dest_desc->buffer.pointer) {
+					return (AE_NO_MEMORY);
+				}
+
+				/* Copy the actual buffer data */
+
+				ACPI_MEMCPY (dest_desc->buffer.pointer, source_desc->buffer.pointer,
+						  source_desc->buffer.length);
+			}
+		}
+		break;
+
+	case ACPI_TYPE_STRING:
+
+		/*
+		 * Allocate and copy the actual string if and only if:
+		 * 1) There is a valid string pointer
+		 * 2) The string is not static (not in an ACPI table) (in this case,
+		 *    the actual pointer was already copied above)
+		 */
+		if ((source_desc->string.pointer) &&
+			(!(source_desc->common.flags & AOPOBJ_STATIC_POINTER))) {
+			dest_desc->string.pointer = ACPI_MEM_ALLOCATE ((acpi_size) source_desc->string.length + 1);
+			if (!dest_desc->string.pointer) {
+				return (AE_NO_MEMORY);
+			}
+
+			ACPI_MEMCPY (dest_desc->string.pointer, source_desc->string.pointer,
+					  (acpi_size) source_desc->string.length + 1);
+		}
+		break;
+
+	default:
+		/* Nothing to do for other simple objects */
+		break;
+	}
+
+	return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_copy_ielement_to_ielement
+ *
+ * PARAMETERS:  acpi_pkg_callback
+ *
+ * RETURN:      Status
  *
  * DESCRIPTION: Copy one package element to another package element
  *
@@ -639,58 +712,78 @@
 
 acpi_status
 acpi_ut_copy_ielement_to_ielement (
-	u8                      object_type,
-	acpi_operand_object     *source_object,
-	acpi_generic_state      *state,
-	void                    *context)
-{
-	acpi_status             status = AE_OK;
-	u32                     this_index;
-	acpi_operand_object     **this_target_ptr;
-	acpi_operand_object     *target_object;
+	u8                              object_type,
+	union acpi_operand_object       *source_object,
+	union acpi_generic_state        *state,
+	void                            *context)
+{
+	acpi_status                     status = AE_OK;
+	u32                             this_index;
+	union acpi_operand_object       **this_target_ptr;
+	union acpi_operand_object       *target_object;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	this_index    = state->pkg.index;
-	this_target_ptr = (acpi_operand_object **)
+	this_target_ptr = (union acpi_operand_object **)
 			   &state->pkg.dest_object->package.elements[this_index];
 
 	switch (object_type) {
-	case 0:
+	case ACPI_COPY_TYPE_SIMPLE:
 
-		/*
-		 * This is a simple object, just copy it
-		 */
-		target_object = acpi_ut_create_internal_object (source_object->common.type);
-		if (!target_object) {
-			return (AE_NO_MEMORY);
-		}
+		/* A null source object indicates a (legal) null package element */
 
-		status = acpi_ex_store_object_to_object (source_object, target_object,
-				  (acpi_walk_state *) context);
-		if (ACPI_FAILURE (status)) {
-			return (status);
+		if (source_object) {
+			/*
+			 * This is a simple object, just copy it
+			 */
+			target_object = acpi_ut_create_internal_object (
+					   ACPI_GET_OBJECT_TYPE (source_object));
+			if (!target_object) {
+				return (AE_NO_MEMORY);
+			}
+
+			status = acpi_ut_copy_simple_object (source_object, target_object);
+			if (ACPI_FAILURE (status)) {
+				return (status);
+			}
+
+			*this_target_ptr = target_object;
 		}
+		else {
+			/* Pass through a null element */
 
-		*this_target_ptr = target_object;
+			*this_target_ptr = NULL;
+		}
 		break;
 
 
-	case 1:
+	case ACPI_COPY_TYPE_PACKAGE:
+
 		/*
 		 * This object is a package - go down another nesting level
 		 * Create and build the package object
 		 */
 		target_object = acpi_ut_create_internal_object (ACPI_TYPE_PACKAGE);
 		if (!target_object) {
-			/* TBD: must delete package created up to this point */
-
 			return (AE_NO_MEMORY);
 		}
 
 		target_object->package.count = source_object->package.count;
+		target_object->common.flags = source_object->common.flags;
+
+		/*
+		 * Create the object array
+		 */
+		target_object->package.elements =
+			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);
+		}
 
 		/*
 		 * Pass the new package object back to the package walk routine
@@ -703,21 +796,21 @@
 		*this_target_ptr = target_object;
 		break;
 
+
 	default:
 		return (AE_BAD_PARAMETER);
 	}
 
-
 	return (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_copy_ipackage_to_ipackage
+ * FUNCTION:    acpi_ut_copy_ipackage_to_ipackage
  *
- * PARAMETERS:  *Source_obj     - Pointer to the source package object
- *              *Dest_obj       - Where the internal object is returned
+ * PARAMETERS:  *source_obj     - Pointer to the source package object
+ *              *dest_obj       - Where the internal object is returned
  *
  * RETURN:      Status          - the status of the call
  *
@@ -728,37 +821,92 @@
 
 acpi_status
 acpi_ut_copy_ipackage_to_ipackage (
-	acpi_operand_object     *source_obj,
-	acpi_operand_object     *dest_obj,
-	acpi_walk_state         *walk_state)
+	union acpi_operand_object       *source_obj,
+	union acpi_operand_object       *dest_obj,
+	struct acpi_walk_state          *walk_state)
 {
-	acpi_status             status = AE_OK;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE ("Ut_copy_ipackage_to_ipackage");
+	ACPI_FUNCTION_TRACE ("ut_copy_ipackage_to_ipackage");
 
 
-	dest_obj->common.type   = source_obj->common.type;
+	dest_obj->common.type   = ACPI_GET_OBJECT_TYPE (source_obj);
+	dest_obj->common.flags  = source_obj->common.flags;
 	dest_obj->package.count = source_obj->package.count;
 
-
 	/*
 	 * Create the object array and walk the source package tree
 	 */
-	dest_obj->package.elements = ACPI_MEM_CALLOCATE ((source_obj->package.count + 1) *
-			 sizeof (void *));
-	dest_obj->package.next_element = dest_obj->package.elements;
-
+	dest_obj->package.elements = ACPI_MEM_CALLOCATE (
+			   ((acpi_size) source_obj->package.count + 1) *
+			   sizeof (void *));
 	if (!dest_obj->package.elements) {
-		REPORT_ERROR (
-			("Aml_build_copy_internal_package_object: Package allocation failure\n"));
+		ACPI_REPORT_ERROR (
+			("aml_build_copy_internal_package_object: Package allocation failure\n"));
 		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
 
-
+	/*
+	 * Copy the package element-by-element by walking the package "tree".
+	 * This handles nested packages of arbitrary depth.
+	 */
 	status = acpi_ut_walk_package_tree (source_obj, dest_obj,
 			 acpi_ut_copy_ielement_to_ielement, walk_state);
+	if (ACPI_FAILURE (status)) {
+		/* On failure, delete the destination package object */
+
+		acpi_ut_remove_reference (dest_obj);
+	}
+
+	return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_copy_iobject_to_iobject
+ *
+ * PARAMETERS:  walk_state          - Current walk state
+ *              source_desc         - The internal object to be copied
+ *              dest_desc           - Where the copied object is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Copy an internal object to a new internal object
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ut_copy_iobject_to_iobject (
+	union acpi_operand_object       *source_desc,
+	union acpi_operand_object       **dest_desc,
+	struct acpi_walk_state          *walk_state)
+{
+	acpi_status                     status = AE_OK;
+
+
+	ACPI_FUNCTION_TRACE ("ut_copy_iobject_to_iobject");
+
+
+	/* Create the top level object */
+
+	*dest_desc = acpi_ut_create_internal_object (ACPI_GET_OBJECT_TYPE (source_desc));
+	if (!*dest_desc) {
+		return_ACPI_STATUS (AE_NO_MEMORY);
+	}
+
+	/* Copy the object and possible subobjects */
+
+	if (ACPI_GET_OBJECT_TYPE (source_desc) == ACPI_TYPE_PACKAGE) {
+		status = acpi_ut_copy_ipackage_to_ipackage (source_desc, *dest_desc,
+				  walk_state);
+	}
+	else {
+		status = acpi_ut_copy_simple_object (source_desc, *dest_desc);
+	}
 
 	return_ACPI_STATUS (status);
 }
 
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/utilities/utdebug.c linux-2.4.22-pre2/drivers/acpi/utilities/utdebug.c
--- linux-2.4.21/drivers/acpi/utilities/utdebug.c	2002-11-28 23:53:12.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/utilities/utdebug.c	2003-06-26 21:43:28.000000000 +0000
@@ -1,46 +1,63 @@
 /******************************************************************************
  *
  * Module Name: utdebug - Debug print routines
- *              $Revision: 90 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
+#include <acpi/acpi.h>
 
 #define _COMPONENT          ACPI_UTILITIES
-	 MODULE_NAME         ("utdebug")
+	 ACPI_MODULE_NAME    ("utdebug")
 
 
-u32             acpi_gbl_prev_thread_id = 0xFFFFFFFF;
-char            *acpi_gbl_fn_entry_str = "----Entry";
-char            *acpi_gbl_fn_exit_str = "----Exit-";
+#ifdef ACPI_DEBUG_OUTPUT
 
-
-#ifdef ACPI_DEBUG
+static u32   acpi_gbl_prev_thread_id = 0xFFFFFFFF;
+static char     *acpi_gbl_fn_entry_str = "----Entry";
+static char     *acpi_gbl_fn_exit_str = "----Exit-";
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ut_init_stack_ptr_trace
+ * FUNCTION:    acpi_ut_init_stack_ptr_trace
  *
  * PARAMETERS:  None
  *
@@ -54,16 +71,16 @@
 acpi_ut_init_stack_ptr_trace (
 	void)
 {
-	u32                 current_sp;
+	u32                         current_sp;
 
 
-	acpi_gbl_entry_stack_pointer = (unsigned long) &current_sp;
+	acpi_gbl_entry_stack_pointer = ACPI_PTR_DIFF (&current_sp, NULL);
 }
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ut_track_stack_ptr
+ * FUNCTION:    acpi_ut_track_stack_ptr
  *
  * PARAMETERS:  None
  *
@@ -77,9 +94,10 @@
 acpi_ut_track_stack_ptr (
 	void)
 {
-	u32                 current_sp;
+	acpi_size                   current_sp;
+
 
-	current_sp = (u32) &current_sp;
+	current_sp = ACPI_PTR_DIFF (&current_sp, NULL);
 
 	if (current_sp < acpi_gbl_lowest_stack_pointer) {
 		acpi_gbl_lowest_stack_pointer = current_sp;
@@ -93,13 +111,13 @@
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ut_debug_print
+ * FUNCTION:    acpi_ut_debug_print
  *
- * PARAMETERS:  Debug_level         - Requested debug print level
- *              Proc_name           - Caller's procedure name
- *              Module_name         - Caller's module name (for error output)
- *              Line_number         - Caller's line number (for error output)
- *              Component_id        - Caller's component ID (for error output)
+ * PARAMETERS:  debug_level         - Requested debug print level
+ *              proc_name           - Caller's procedure name
+ *              module_name         - Caller's module name (for error output)
+ *              line_number         - Caller's line number (for error output)
+ *              component_id        - Caller's component ID (for error output)
  *
  *              Format              - Printf format field
  *              ...                 - Optional printf arguments
@@ -111,15 +129,15 @@
  *
  ****************************************************************************/
 
-void
+void  ACPI_INTERNAL_VAR_XFACE
 acpi_ut_debug_print (
-	u32                     requested_debug_level,
-	u32                     line_number,
-	acpi_debug_print_info   *dbg_info,
-	char                    *format,
+	u32                             requested_debug_level,
+	u32                             line_number,
+	struct acpi_debug_print_info    *dbg_info,
+	char                            *format,
 	...)
 {
-	u32                     thread_id;
+	u32                             thread_id;
 	va_list                 args;
 
 
@@ -131,7 +149,6 @@
 		return;
 	}
 
-
 	/*
 	 * Thread tracking and context switch notification
 	 */
@@ -150,14 +167,13 @@
 	 * Display the module name, current line number, thread ID (if requested),
 	 * current procedure nesting level, and the current procedure name
 	 */
-	acpi_os_printf ("%8s-%04d ", dbg_info->module_name, line_number);
+	acpi_os_printf ("%8s-%04ld ", dbg_info->module_name, line_number);
 
 	if (ACPI_LV_THREADS & acpi_dbg_level) {
-		acpi_os_printf ("[%04X] ", thread_id, acpi_gbl_nesting_level, dbg_info->proc_name);
+		acpi_os_printf ("[%04lX] ", thread_id);
 	}
 
-	acpi_os_printf ("[%02d] %-22.22s: ", acpi_gbl_nesting_level, dbg_info->proc_name);
-
+	acpi_os_printf ("[%02ld] %-22.22s: ", acpi_gbl_nesting_level, dbg_info->proc_name);
 
 	va_start (args, format);
 	acpi_os_vprintf (format, args);
@@ -166,30 +182,30 @@
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ut_debug_print_raw
+ * FUNCTION:    acpi_ut_debug_print_raw
  *
- * PARAMETERS:  Requested_debug_level - Requested debug print level
- *              Line_number         - Caller's line number
- *              Dbg_info            - Contains:
- *                  Proc_name           - Caller's procedure name
- *                  Module_name         - Caller's module name
- *                  Component_id        - Caller's component ID
+ * PARAMETERS:  requested_debug_level - Requested debug print level
+ *              line_number         - Caller's line number
+ *              dbg_info            - Contains:
+ *                  proc_name           - Caller's procedure name
+ *                  module_name         - Caller's module name
+ *                  component_id        - Caller's component ID
  *              Format              - Printf format field
  *              ...                 - Optional printf arguments
  *
  * RETURN:      None
  *
  * DESCRIPTION: Print message with no headers.  Has same interface as
- *              Debug_print so that the same macros can be used.
+ *              debug_print so that the same macros can be used.
  *
  ****************************************************************************/
 
-void
+void  ACPI_INTERNAL_VAR_XFACE
 acpi_ut_debug_print_raw (
-	u32                     requested_debug_level,
-	u32                     line_number,
-	acpi_debug_print_info   *dbg_info,
-	char                    *format,
+	u32                             requested_debug_level,
+	u32                             line_number,
+	struct acpi_debug_print_info    *dbg_info,
+	char                            *format,
 	...)
 {
 	va_list                 args;
@@ -201,32 +217,31 @@
 	}
 
 	va_start (args, format);
-
 	acpi_os_vprintf (format, args);
 }
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ut_trace
+ * FUNCTION:    acpi_ut_trace
  *
- * PARAMETERS:  Line_number         - Caller's line number
- *              Dbg_info            - Contains:
- *                  Proc_name           - Caller's procedure name
- *                  Module_name         - Caller's module name
- *                  Component_id        - Caller's component ID
+ * PARAMETERS:  line_number         - Caller's line number
+ *              dbg_info            - Contains:
+ *                  proc_name           - Caller's procedure name
+ *                  module_name         - Caller's module name
+ *                  component_id        - Caller's component ID
  *
  * RETURN:      None
  *
  * DESCRIPTION: Function entry trace.  Prints only if TRACE_FUNCTIONS bit is
- *              set in Debug_level
+ *              set in debug_level
  *
  ****************************************************************************/
 
 void
 acpi_ut_trace (
-	u32                     line_number,
-	acpi_debug_print_info   *dbg_info)
+	u32                             line_number,
+	struct acpi_debug_print_info    *dbg_info)
 {
 
 	acpi_gbl_nesting_level++;
@@ -239,27 +254,27 @@
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ut_trace_ptr
+ * FUNCTION:    acpi_ut_trace_ptr
  *
- * PARAMETERS:  Line_number         - Caller's line number
- *              Dbg_info            - Contains:
- *                  Proc_name           - Caller's procedure name
- *                  Module_name         - Caller's module name
- *                  Component_id        - Caller's component ID
+ * PARAMETERS:  line_number         - Caller's line number
+ *              dbg_info            - Contains:
+ *                  proc_name           - Caller's procedure name
+ *                  module_name         - Caller's module name
+ *                  component_id        - Caller's component ID
  *              Pointer             - Pointer to display
  *
  * RETURN:      None
  *
  * DESCRIPTION: Function entry trace.  Prints only if TRACE_FUNCTIONS bit is
- *              set in Debug_level
+ *              set in debug_level
  *
  ****************************************************************************/
 
 void
 acpi_ut_trace_ptr (
-	u32                     line_number,
-	acpi_debug_print_info   *dbg_info,
-	void                    *pointer)
+	u32                             line_number,
+	struct acpi_debug_print_info    *dbg_info,
+	void                            *pointer)
 {
 	acpi_gbl_nesting_level++;
 	acpi_ut_track_stack_ptr ();
@@ -271,27 +286,27 @@
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ut_trace_str
+ * FUNCTION:    acpi_ut_trace_str
  *
- * PARAMETERS:  Line_number         - Caller's line number
- *              Dbg_info            - Contains:
- *                  Proc_name           - Caller's procedure name
- *                  Module_name         - Caller's module name
- *                  Component_id        - Caller's component ID
+ * PARAMETERS:  line_number         - Caller's line number
+ *              dbg_info            - Contains:
+ *                  proc_name           - Caller's procedure name
+ *                  module_name         - Caller's module name
+ *                  component_id        - Caller's component ID
  *              String              - Additional string to display
  *
  * RETURN:      None
  *
  * DESCRIPTION: Function entry trace.  Prints only if TRACE_FUNCTIONS bit is
- *              set in Debug_level
+ *              set in debug_level
  *
  ****************************************************************************/
 
 void
 acpi_ut_trace_str (
-	u32                     line_number,
-	acpi_debug_print_info   *dbg_info,
-	NATIVE_CHAR             *string)
+	u32                             line_number,
+	struct acpi_debug_print_info    *dbg_info,
+	char                            *string)
 {
 
 	acpi_gbl_nesting_level++;
@@ -304,27 +319,27 @@
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ut_trace_u32
+ * FUNCTION:    acpi_ut_trace_u32
  *
- * PARAMETERS:  Line_number         - Caller's line number
- *              Dbg_info            - Contains:
- *                  Proc_name           - Caller's procedure name
- *                  Module_name         - Caller's module name
- *                  Component_id        - Caller's component ID
+ * PARAMETERS:  line_number         - Caller's line number
+ *              dbg_info            - Contains:
+ *                  proc_name           - Caller's procedure name
+ *                  module_name         - Caller's module name
+ *                  component_id        - Caller's component ID
  *              Integer             - Integer to display
  *
  * RETURN:      None
  *
  * DESCRIPTION: Function entry trace.  Prints only if TRACE_FUNCTIONS bit is
- *              set in Debug_level
+ *              set in debug_level
  *
  ****************************************************************************/
 
 void
 acpi_ut_trace_u32 (
-	u32                     line_number,
-	acpi_debug_print_info   *dbg_info,
-	u32                     integer)
+	u32                             line_number,
+	struct acpi_debug_print_info    *dbg_info,
+	u32                             integer)
 {
 
 	acpi_gbl_nesting_level++;
@@ -337,25 +352,25 @@
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ut_exit
+ * FUNCTION:    acpi_ut_exit
  *
- * PARAMETERS:  Line_number         - Caller's line number
- *              Dbg_info            - Contains:
- *                  Proc_name           - Caller's procedure name
- *                  Module_name         - Caller's module name
- *                  Component_id        - Caller's component ID
+ * PARAMETERS:  line_number         - Caller's line number
+ *              dbg_info            - Contains:
+ *                  proc_name           - Caller's procedure name
+ *                  module_name         - Caller's module name
+ *                  component_id        - Caller's component ID
  *
  * RETURN:      None
  *
  * DESCRIPTION: Function exit trace.  Prints only if TRACE_FUNCTIONS bit is
- *              set in Debug_level
+ *              set in debug_level
  *
  ****************************************************************************/
 
 void
 acpi_ut_exit (
-	u32                     line_number,
-	acpi_debug_print_info   *dbg_info)
+	u32                             line_number,
+	struct acpi_debug_print_info    *dbg_info)
 {
 
 	acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info,
@@ -367,27 +382,27 @@
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ut_status_exit
+ * FUNCTION:    acpi_ut_status_exit
  *
- * PARAMETERS:  Line_number         - Caller's line number
- *              Dbg_info            - Contains:
- *                  Proc_name           - Caller's procedure name
- *                  Module_name         - Caller's module name
- *                  Component_id        - Caller's component ID
+ * PARAMETERS:  line_number         - Caller's line number
+ *              dbg_info            - Contains:
+ *                  proc_name           - Caller's procedure name
+ *                  module_name         - Caller's module name
+ *                  component_id        - Caller's component ID
  *              Status              - Exit status code
  *
  * RETURN:      None
  *
  * DESCRIPTION: Function exit trace.  Prints only if TRACE_FUNCTIONS bit is
- *              set in Debug_level. Prints exit status also.
+ *              set in debug_level. Prints exit status also.
  *
  ****************************************************************************/
 
 void
 acpi_ut_status_exit (
-	u32                     line_number,
-	acpi_debug_print_info   *dbg_info,
-	acpi_status             status)
+	u32                             line_number,
+	struct acpi_debug_print_info    *dbg_info,
+	acpi_status                     status)
 {
 
 	if (ACPI_SUCCESS (status)) {
@@ -407,31 +422,32 @@
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ut_value_exit
+ * FUNCTION:    acpi_ut_value_exit
  *
- * PARAMETERS:  Line_number         - Caller's line number
- *              Dbg_info            - Contains:
- *                  Proc_name           - Caller's procedure name
- *                  Module_name         - Caller's module name
- *                  Component_id        - Caller's component ID
+ * PARAMETERS:  line_number         - Caller's line number
+ *              dbg_info            - Contains:
+ *                  proc_name           - Caller's procedure name
+ *                  module_name         - Caller's module name
+ *                  component_id        - Caller's component ID
  *              Value               - Value to be printed with exit msg
  *
  * RETURN:      None
  *
  * DESCRIPTION: Function exit trace.  Prints only if TRACE_FUNCTIONS bit is
- *              set in Debug_level. Prints exit value also.
+ *              set in debug_level. Prints exit value also.
  *
  ****************************************************************************/
 
 void
 acpi_ut_value_exit (
-	u32                     line_number,
-	acpi_debug_print_info   *dbg_info,
-	acpi_integer            value)
+	u32                             line_number,
+	struct acpi_debug_print_info    *dbg_info,
+	acpi_integer                    value)
 {
 
 	acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info,
-			"%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str, HIDWORD(value), LODWORD(value));
+			"%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str,
+			ACPI_HIDWORD (value), ACPI_LODWORD (value));
 
 	acpi_gbl_nesting_level--;
 }
@@ -439,27 +455,27 @@
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ut_ptr_exit
+ * FUNCTION:    acpi_ut_ptr_exit
  *
- * PARAMETERS:  Line_number         - Caller's line number
- *              Dbg_info            - Contains:
- *                  Proc_name           - Caller's procedure name
- *                  Module_name         - Caller's module name
- *                  Component_id        - Caller's component ID
+ * PARAMETERS:  line_number         - Caller's line number
+ *              dbg_info            - Contains:
+ *                  proc_name           - Caller's procedure name
+ *                  module_name         - Caller's module name
+ *                  component_id        - Caller's component ID
  *              Value               - Value to be printed with exit msg
  *
  * RETURN:      None
  *
  * DESCRIPTION: Function exit trace.  Prints only if TRACE_FUNCTIONS bit is
- *              set in Debug_level. Prints exit value also.
+ *              set in debug_level. Prints exit value also.
  *
  ****************************************************************************/
 
 void
 acpi_ut_ptr_exit (
-	u32                     line_number,
-	acpi_debug_print_info   *dbg_info,
-	u8                      *ptr)
+	u32                             line_number,
+	struct acpi_debug_print_info    *dbg_info,
+	u8                              *ptr)
 {
 
 	acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info,
@@ -473,12 +489,12 @@
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ut_dump_buffer
+ * FUNCTION:    acpi_ut_dump_buffer
  *
  * PARAMETERS:  Buffer              - Buffer to dump
  *              Count               - Amount to dump, in bytes
  *              Display             - BYTE, WORD, DWORD, or QWORD display
- *              Component_iD        - Caller's component ID
+ *              component_iD        - Caller's component ID
  *
  * RETURN:      None
  *
@@ -488,15 +504,15 @@
 
 void
 acpi_ut_dump_buffer (
-	u8                      *buffer,
-	u32                     count,
-	u32                     display,
-	u32                     component_id)
-{
-	u32                     i = 0;
-	u32                     j;
-	u32                     temp32;
-	u8                      buf_char;
+	u8                              *buffer,
+	u32                             count,
+	u32                             display,
+	u32                             component_id)
+{
+	acpi_native_uint                i = 0;
+	acpi_native_uint                j;
+	u32                             temp32;
+	u8                              buf_char;
 
 
 	/* Only dump the buffer if tracing is enabled */
@@ -506,6 +522,11 @@
 		return;
 	}
 
+	if ((count < 4) || (count & 0x01)) {
+		display = DB_BYTE_DISPLAY;
+	}
+
+	acpi_os_printf ("\nOffset Value\n");
 
 	/*
 	 * Nasty little dump buffer routine!
@@ -513,8 +534,7 @@
 	while (i < count) {
 		/* Print current offset */
 
-		acpi_os_printf ("%05X  ", i);
-
+		acpi_os_printf ("%05X  ", (u32) i);
 
 		/* Print 16 hex chars */
 
@@ -539,8 +559,7 @@
 
 			case DB_WORD_DISPLAY:
 
-				MOVE_UNALIGNED16_TO_32 (&temp32,
-						 &buffer[i + j]);
+				ACPI_MOVE_16_TO_32 (&temp32, &buffer[i + j]);
 				acpi_os_printf ("%04X ", temp32);
 				j += 2;
 				break;
@@ -548,8 +567,7 @@
 
 			case DB_DWORD_DISPLAY:
 
-				MOVE_UNALIGNED32_TO_32 (&temp32,
-						 &buffer[i + j]);
+				ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j]);
 				acpi_os_printf ("%08X ", temp32);
 				j += 4;
 				break;
@@ -557,24 +575,20 @@
 
 			case DB_QWORD_DISPLAY:
 
-				MOVE_UNALIGNED32_TO_32 (&temp32,
-						 &buffer[i + j]);
+				ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j]);
 				acpi_os_printf ("%08X", temp32);
 
-				MOVE_UNALIGNED32_TO_32 (&temp32,
-						 &buffer[i + j + 4]);
+				ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j + 4]);
 				acpi_os_printf ("%08X ", temp32);
 				j += 8;
 				break;
 			}
 		}
 
-
 		/*
 		 * Print the ASCII equivalent characters
 		 * But watch out for the bad unprintable ones...
 		 */
-
 		for (j = 0; j < 16; j++) {
 			if (i + j >= count) {
 				acpi_os_printf ("\n");
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/utilities/utdelete.c linux-2.4.22-pre2/drivers/acpi/utilities/utdelete.c
--- linux-2.4.21/drivers/acpi/utilities/utdelete.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/utilities/utdelete.c	2003-06-26 21:43:21.000000000 +0000
@@ -1,42 +1,59 @@
 /*******************************************************************************
  *
  * Module Name: utdelete - object deletion and reference count utilities
- *              $Revision: 81 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "actables.h"
-#include "acparser.h"
+#include <acpi/acpi.h>
+#include <acpi/acinterp.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acevents.h>
 
 #define _COMPONENT          ACPI_UTILITIES
-	 MODULE_NAME         ("utdelete")
+	 ACPI_MODULE_NAME    ("utdelete")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_delete_internal_obj
+ * FUNCTION:    acpi_ut_delete_internal_obj
  *
  * PARAMETERS:  *Object        - Pointer to the list to be deleted
  *
@@ -49,13 +66,15 @@
 
 void
 acpi_ut_delete_internal_obj (
-	acpi_operand_object     *object)
+	union acpi_operand_object       *object)
 {
-	void                    *obj_pointer = NULL;
-	acpi_operand_object     *handler_desc;
+	void                            *obj_pointer = NULL;
+	union acpi_operand_object       *handler_desc;
+	union acpi_operand_object       *second_desc;
+	union acpi_operand_object       *next_desc;
 
 
-	FUNCTION_TRACE_PTR ("Ut_delete_internal_obj", object);
+	ACPI_FUNCTION_TRACE_PTR ("ut_delete_internal_obj", object);
 
 
 	if (!object) {
@@ -66,16 +85,17 @@
 	 * Must delete or free any pointers within the object that are not
 	 * actual ACPI objects (for example, a raw buffer pointer).
 	 */
-	switch (object->common.type) {
-
+	switch (ACPI_GET_OBJECT_TYPE (object)) {
 	case ACPI_TYPE_STRING:
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** String %p, ptr %p\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** String %p, ptr %p\n",
 			object, object->string.pointer));
 
 		/* Free the actual string buffer */
 
 		if (!(object->common.flags & AOPOBJ_STATIC_POINTER)) {
+			/* But only if it is NOT a pointer into an ACPI table */
+
 			obj_pointer = object->string.pointer;
 		}
 		break;
@@ -83,18 +103,22 @@
 
 	case ACPI_TYPE_BUFFER:
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Buffer %p, ptr %p\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** Buffer %p, ptr %p\n",
 			object, object->buffer.pointer));
 
 		/* Free the actual buffer */
 
-		obj_pointer = object->buffer.pointer;
+		if (!(object->common.flags & AOPOBJ_STATIC_POINTER)) {
+			/* But only if it is NOT a pointer into an ACPI table */
+
+			obj_pointer = object->buffer.pointer;
+		}
 		break;
 
 
 	case ACPI_TYPE_PACKAGE:
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, " **** Package of count %X\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, " **** Package of count %X\n",
 			object->package.count));
 
 		/*
@@ -108,124 +132,137 @@
 		break;
 
 
+	case ACPI_TYPE_DEVICE:
+
+		if (object->device.gpe_block) {
+			(void) acpi_ev_delete_gpe_block (object->device.gpe_block);
+		}
+
+		/* Walk the handler list for this device */
+
+		handler_desc = object->device.address_space;
+		while (handler_desc) {
+			next_desc = handler_desc->address_space.next;
+			acpi_ut_remove_reference (handler_desc);
+			handler_desc = next_desc;
+		}
+		break;
+
+
 	case ACPI_TYPE_MUTEX:
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "***** Mutex %p, Semaphore %p\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Mutex %p, Semaphore %p\n",
 			object, object->mutex.semaphore));
 
 		acpi_ex_unlink_mutex (object);
-		acpi_os_delete_semaphore (object->mutex.semaphore);
+		(void) acpi_os_delete_semaphore (object->mutex.semaphore);
 		break;
 
 
 	case ACPI_TYPE_EVENT:
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "***** Event %p, Semaphore %p\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Event %p, Semaphore %p\n",
 			object, object->event.semaphore));
 
-		acpi_os_delete_semaphore (object->event.semaphore);
+		(void) acpi_os_delete_semaphore (object->event.semaphore);
 		object->event.semaphore = NULL;
 		break;
 
 
 	case ACPI_TYPE_METHOD:
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "***** Method %p\n", object));
+		ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Method %p\n", object));
 
 		/* Delete the method semaphore if it exists */
 
 		if (object->method.semaphore) {
-			acpi_os_delete_semaphore (object->method.semaphore);
+			(void) acpi_os_delete_semaphore (object->method.semaphore);
 			object->method.semaphore = NULL;
 		}
-
 		break;
 
 
 	case ACPI_TYPE_REGION:
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "***** Region %p\n", object));
+		ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Region %p\n", object));
 
-		if (object->region.extra) {
+		second_desc = acpi_ns_get_secondary_object (object);
+		if (second_desc) {
 			/*
-			 * Free the Region_context if and only if the handler is one of the
+			 * Free the region_context if and only if the handler is one of the
 			 * default handlers -- and therefore, we created the context object
 			 * locally, it was not created by an external caller.
 			 */
-			handler_desc = object->region.addr_handler;
-			if ((handler_desc) &&
-				(handler_desc->addr_handler.hflags == ADDR_HANDLER_DEFAULT_INSTALLED)) {
-				obj_pointer = object->region.extra->extra.region_context;
+			handler_desc = object->region.address_space;
+			if (handler_desc) {
+				if (handler_desc->address_space.hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) {
+					obj_pointer = second_desc->extra.region_context;
+				}
+
+				acpi_ut_remove_reference (handler_desc);
 			}
 
 			/* Now we can free the Extra object */
 
-			acpi_ut_delete_object_desc (object->region.extra);
+			acpi_ut_delete_object_desc (second_desc);
 		}
 		break;
 
 
 	case ACPI_TYPE_BUFFER_FIELD:
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "***** Buffer Field %p\n", object));
+		ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Buffer Field %p\n", object));
 
-		if (object->buffer_field.extra) {
-			acpi_ut_delete_object_desc (object->buffer_field.extra);
+		second_desc = acpi_ns_get_secondary_object (object);
+		if (second_desc) {
+			acpi_ut_delete_object_desc (second_desc);
 		}
 		break;
 
+
 	default:
 		break;
 	}
 
+	/* Free any allocated memory (pointer within the object) found above */
 
-	/*
-	 * Delete any allocated memory found above
-	 */
 	if (obj_pointer) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Deleting Obj Ptr %p \n", obj_pointer));
+		ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object Subptr %p\n",
+				obj_pointer));
 		ACPI_MEM_FREE (obj_pointer);
 	}
 
-	/* Only delete the object if it was dynamically allocated */
-
-	if (object->common.flags & AOPOBJ_STATIC_ALLOCATION) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Object %p [%s] static allocation, no delete\n",
-			object, acpi_ut_get_type_name (object->common.type)));
-	}
-
-	if (!(object->common.flags & AOPOBJ_STATIC_ALLOCATION)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Deleting object %p [%s]\n",
-			object, acpi_ut_get_type_name (object->common.type)));
+	/* Now the object can be safely deleted */
 
-		acpi_ut_delete_object_desc (object);
-	}
+	ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n",
+			object, acpi_ut_get_object_type_name (object)));
 
+	acpi_ut_delete_object_desc (object);
 	return_VOID;
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_delete_internal_object_list
+ * FUNCTION:    acpi_ut_delete_internal_object_list
  *
- * PARAMETERS:  *Obj_list       - Pointer to the list to be deleted
+ * PARAMETERS:  *obj_list       - Pointer to the list to be deleted
  *
- * RETURN:      Status          - the status of the call
+ * RETURN:      None
  *
  * DESCRIPTION: This function deletes an internal object list, including both
  *              simple objects and package objects
  *
  ******************************************************************************/
 
-acpi_status
+void
 acpi_ut_delete_internal_object_list (
-	acpi_operand_object     **obj_list)
+	union acpi_operand_object       **obj_list)
 {
-	acpi_operand_object     **internal_obj;
+	union acpi_operand_object       **internal_obj;
 
 
-	FUNCTION_TRACE ("Ut_delete_internal_object_list");
+	ACPI_FUNCTION_TRACE ("ut_delete_internal_object_list");
 
 
 	/* Walk the null-terminated internal list */
@@ -237,14 +274,13 @@
 	/* Free the combined parameter pointer list and object array */
 
 	ACPI_MEM_FREE (obj_list);
-
-	return_ACPI_STATUS (AE_OK);
+	return_VOID;
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_update_ref_count
+ * FUNCTION:    acpi_ut_update_ref_count
  *
  * PARAMETERS:  *Object         - Object whose ref count is to be updated
  *              Action          - What to do
@@ -257,25 +293,25 @@
 
 static void
 acpi_ut_update_ref_count (
-	acpi_operand_object     *object,
-	u32                     action)
+	union acpi_operand_object       *object,
+	u32                             action)
 {
-	u16                     count;
-	u16                     new_count;
+	u16                             count;
+	u16                             new_count;
+
 
+	ACPI_FUNCTION_NAME ("ut_update_ref_count");
 
-	PROC_NAME ("Ut_update_ref_count");
 
 	if (!object) {
 		return;
 	}
 
-
 	count = object->common.reference_count;
 	new_count = count;
 
 	/*
-	 * Reference count action (increment, decrement, or force delete)
+	 * Perform the reference count action (increment, decrement, or force delete)
 	 */
 	switch (action) {
 
@@ -284,7 +320,7 @@
 		new_count++;
 		object->common.reference_count = new_count;
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Obj %p Refs=%X, [Incremented]\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, [Incremented]\n",
 			object, new_count));
 		break;
 
@@ -292,21 +328,20 @@
 	case REF_DECREMENT:
 
 		if (count < 1) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Obj %p Refs=%X, can't decrement! (Set to 0)\n",
+			ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, can't decrement! (Set to 0)\n",
 				object, new_count));
 
 			new_count = 0;
 		}
-
 		else {
 			new_count--;
 
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Obj %p Refs=%X, [Decremented]\n",
+			ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, [Decremented]\n",
 				object, new_count));
 		}
 
-		if (object->common.type == ACPI_TYPE_METHOD) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Method Obj %p Refs=%X, [Decremented]\n",
+		if (ACPI_GET_OBJECT_TYPE (object) == ACPI_TYPE_METHOD) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Method Obj %p Refs=%X, [Decremented]\n",
 				object, new_count));
 		}
 
@@ -320,7 +355,7 @@
 
 	case REF_FORCE_DELETE:
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Obj %p Refs=%X, Force delete! (Set to 0)\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, Force delete! (Set to 0)\n",
 			object, count));
 
 		new_count = 0;
@@ -335,12 +370,11 @@
 		break;
 	}
 
-
 	/*
 	 * Sanity check the reference count, for debug purposes only.
 	 * (A deleted object will have a huge reference count)
 	 */
-	if (count > MAX_REFERENCE_COUNT) {
+	if (count > ACPI_MAX_REFERENCE_COUNT) {
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_WARN,
 			"**** Warning **** Large Reference Count (%X) in object %p\n\n",
@@ -353,7 +387,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_update_object_reference
+ * FUNCTION:    acpi_ut_update_object_reference
  *
  * PARAMETERS:  *Object             - Increment ref count for this object
  *                                    and all sub-objects
@@ -375,18 +409,16 @@
 
 acpi_status
 acpi_ut_update_object_reference (
-	acpi_operand_object     *object,
-	u16                     action)
+	union acpi_operand_object       *object,
+	u16                             action)
 {
-	acpi_status             status;
-	u32                     i;
-	acpi_operand_object     *next;
-	acpi_operand_object     *new;
-	acpi_generic_state       *state_list = NULL;
-	acpi_generic_state       *state;
+	acpi_status                     status;
+	u32                             i;
+	union acpi_generic_state         *state_list = NULL;
+	union acpi_generic_state         *state;
 
 
-	FUNCTION_TRACE_PTR ("Ut_update_object_reference", object);
+	ACPI_FUNCTION_TRACE_PTR ("ut_update_object_reference", object);
 
 
 	/* Ignore a null object ptr */
@@ -395,16 +427,13 @@
 		return_ACPI_STATUS (AE_OK);
 	}
 
+	/* Make sure that this isn't a namespace handle */
 
-	/*
-	 * Make sure that this isn't a namespace handle or an AML pointer
-	 */
-	if (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_NAMED)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Object %p is NS handle\n", object));
+	if (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p is NS handle\n", object));
 		return_ACPI_STATUS (AE_OK);
 	}
 
-
 	state = acpi_ut_create_update_state (object, action);
 
 	while (state) {
@@ -416,32 +445,11 @@
 		 * All sub-objects must have their reference count incremented also.
 		 * Different object types have different subobjects.
 		 */
-		switch (object->common.type) {
-
+		switch (ACPI_GET_OBJECT_TYPE (object)) {
 		case ACPI_TYPE_DEVICE:
 
-			status = acpi_ut_create_update_state_and_push (object->device.addr_handler,
-					   action, &state_list);
-			if (ACPI_FAILURE (status)) {
-				return_ACPI_STATUS (status);
-			}
-
-			acpi_ut_update_ref_count (object->device.sys_handler, action);
-			acpi_ut_update_ref_count (object->device.drv_handler, action);
-			break;
-
-
-		case INTERNAL_TYPE_ADDRESS_HANDLER:
-
-			/* Must walk list of address handlers */
-
-			next = object->addr_handler.next;
-			while (next) {
-				new = next->addr_handler.next;
-				acpi_ut_update_ref_count (next, action);
-
-				next = new;
-			}
+			acpi_ut_update_ref_count (object->device.system_notify, action);
+			acpi_ut_update_ref_count (object->device.device_notify, action);
 			break;
 
 
@@ -460,7 +468,7 @@
 				status = acpi_ut_create_update_state_and_push (
 						 object->package.elements[i], action, &state_list);
 				if (ACPI_FAILURE (status)) {
-					return_ACPI_STATUS (status);
+					goto error_exit;
 				}
 			}
 			break;
@@ -470,63 +478,62 @@
 
 			status = acpi_ut_create_update_state_and_push (
 					 object->buffer_field.buffer_obj, action, &state_list);
-
 			if (ACPI_FAILURE (status)) {
-				return_ACPI_STATUS (status);
+				goto error_exit;
 			}
 			break;
 
 
-		case INTERNAL_TYPE_REGION_FIELD:
+		case ACPI_TYPE_LOCAL_REGION_FIELD:
 
 			status = acpi_ut_create_update_state_and_push (
 					 object->field.region_obj, action, &state_list);
 			if (ACPI_FAILURE (status)) {
-				return_ACPI_STATUS (status);
+				goto error_exit;
 			}
 		   break;
 
 
-		case INTERNAL_TYPE_BANK_FIELD:
+		case ACPI_TYPE_LOCAL_BANK_FIELD:
 
 			status = acpi_ut_create_update_state_and_push (
-					 object->bank_field.bank_register_obj, action, &state_list);
+					 object->bank_field.bank_obj, action, &state_list);
 			if (ACPI_FAILURE (status)) {
-				return_ACPI_STATUS (status);
+				goto error_exit;
 			}
 
 			status = acpi_ut_create_update_state_and_push (
 					 object->bank_field.region_obj, action, &state_list);
 			if (ACPI_FAILURE (status)) {
-				return_ACPI_STATUS (status);
+				goto error_exit;
 			}
 			break;
 
 
-		case INTERNAL_TYPE_INDEX_FIELD:
+		case ACPI_TYPE_LOCAL_INDEX_FIELD:
 
 			status = acpi_ut_create_update_state_and_push (
 					 object->index_field.index_obj, action, &state_list);
 			if (ACPI_FAILURE (status)) {
-				return_ACPI_STATUS (status);
+				goto error_exit;
 			}
 
 			status = acpi_ut_create_update_state_and_push (
 					 object->index_field.data_obj, action, &state_list);
 			if (ACPI_FAILURE (status)) {
-				return_ACPI_STATUS (status);
+				goto error_exit;
 			}
 			break;
 
 
 		case ACPI_TYPE_REGION:
-		case INTERNAL_TYPE_REFERENCE:
+		case ACPI_TYPE_LOCAL_REFERENCE:
+		default:
 
 			/* No subobjects */
 			break;
 		}
 
-
 		/*
 		 * Now we can update the count in the main object.  This can only
 		 * happen after we update the sub-objects in case this causes the
@@ -534,20 +541,26 @@
 		 */
 		acpi_ut_update_ref_count (object, action);
 
-
 		/* Move on to the next object to be updated */
 
 		state = acpi_ut_pop_generic_state (&state_list);
 	}
 
-
 	return_ACPI_STATUS (AE_OK);
+
+
+error_exit:
+
+	ACPI_REPORT_ERROR (("Could not update object reference count, %s\n",
+		acpi_format_exception (status)));
+
+	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_add_reference
+ * FUNCTION:    acpi_ut_add_reference
  *
  * PARAMETERS:  *Object        - Object whose reference count is to be
  *                                  incremented
@@ -560,31 +573,28 @@
 
 void
 acpi_ut_add_reference (
-	acpi_operand_object     *object)
+	union acpi_operand_object       *object)
 {
 
-	FUNCTION_TRACE_PTR ("Ut_add_reference", object);
+	ACPI_FUNCTION_TRACE_PTR ("ut_add_reference", object);
 
 
-	/*
-	 * Ensure that we have a valid object
-	 */
+	/* Ensure that we have a valid object */
+
 	if (!acpi_ut_valid_internal_object (object)) {
 		return_VOID;
 	}
 
-	/*
-	 * We have a valid ACPI internal object, now increment the reference count
-	 */
-	acpi_ut_update_object_reference (object, REF_INCREMENT);
+	/* Increment the reference count */
 
+	(void) acpi_ut_update_object_reference (object, REF_INCREMENT);
 	return_VOID;
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_remove_reference
+ * FUNCTION:    acpi_ut_remove_reference
  *
  * PARAMETERS:  *Object        - Object whose ref count will be decremented
  *
@@ -596,10 +606,11 @@
 
 void
 acpi_ut_remove_reference (
-	acpi_operand_object     *object)
+	union acpi_operand_object       *object)
 {
 
-	FUNCTION_TRACE_PTR ("Ut_remove_reference", object);
+	ACPI_FUNCTION_TRACE_PTR ("ut_remove_reference", object);
+
 
 	/*
 	 * Allow a NULL pointer to be passed in, just ignore it.  This saves
@@ -607,18 +618,17 @@
 	 *
 	 */
 	if (!object ||
-		(VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_NAMED))) {
+		(ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED)) {
 		return_VOID;
 	}
 
-	/*
-	 * Ensure that we have a valid object
-	 */
+	/* Ensure that we have a valid object */
+
 	if (!acpi_ut_valid_internal_object (object)) {
 		return_VOID;
 	}
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Obj %p Refs=%X\n",
+	ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X\n",
 			object, object->common.reference_count));
 
 	/*
@@ -626,7 +636,7 @@
 	 * if the reference count becomes 0.  (Must also decrement the ref count
 	 * of all subobjects!)
 	 */
-	acpi_ut_update_object_reference (object, REF_DECREMENT);
+	(void) acpi_ut_update_object_reference (object, REF_DECREMENT);
 	return_VOID;
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/utilities/uteval.c linux-2.4.22-pre2/drivers/acpi/utilities/uteval.c
--- linux-2.4.21/drivers/acpi/utilities/uteval.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/utilities/uteval.c	2003-06-26 21:43:11.000000000 +0000
@@ -1,123 +1,258 @@
 /******************************************************************************
  *
  * Module Name: uteval - Object evaluation
- *              $Revision: 31 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acnamesp.h"
-#include "acinterp.h"
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acinterp.h>
 
 
 #define _COMPONENT          ACPI_UTILITIES
-	 MODULE_NAME         ("uteval")
+	 ACPI_MODULE_NAME    ("uteval")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_evaluate_numeric_object
+ * FUNCTION:    acpi_ut_evaluate_object
  *
- * PARAMETERS:  *Object_name        - Object name to be evaluated
- *              Device_node         - Node for the device
- *              *Address            - Where the value is returned
+ * PARAMETERS:  prefix_node         - Starting node
+ *              Path                - Path to object from starting node
+ *              expected_return_types - Bitmap of allowed return types
+ *              return_desc         - Where a return value is stored
  *
  * RETURN:      Status
  *
- * DESCRIPTION: evaluates a numeric namespace object for a selected device
- *              and stores results in *Address.
+ * DESCRIPTION: Evaluates a namespace object and verifies the type of the
+ *              return object.  Common code that simplifies accessing objects
+ *              that have required return objects of fixed types.
  *
  *              NOTE: Internal function, no parameter validation
  *
  ******************************************************************************/
 
 acpi_status
-acpi_ut_evaluate_numeric_object (
-	NATIVE_CHAR             *object_name,
-	acpi_namespace_node     *device_node,
-	acpi_integer            *address)
+acpi_ut_evaluate_object (
+	struct acpi_namespace_node      *prefix_node,
+	char                            *path,
+	u32                             expected_return_btypes,
+	union acpi_operand_object       **return_desc)
 {
-	acpi_operand_object     *obj_desc;
-	acpi_status             status;
+	union acpi_operand_object       *obj_desc;
+	acpi_status                     status;
+	u32                             return_btype;
 
 
-	FUNCTION_TRACE ("Ut_evaluate_numeric_object");
+	ACPI_FUNCTION_TRACE ("ut_evaluate_object");
 
 
-	/* Execute the method */
+	/* Evaluate the object/method */
 
-	status = acpi_ns_evaluate_relative (device_node, object_name, NULL, &obj_desc);
+	status = acpi_ns_evaluate_relative (prefix_node, path, NULL, &obj_desc);
 	if (ACPI_FAILURE (status)) {
 		if (status == AE_NOT_FOUND) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s on %4.4s was not found\n",
-				object_name, (char*)&device_node->name));
+			ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n",
+				prefix_node->name.ascii, path));
 		}
 		else {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s on %4.4s failed with status %s\n",
-				object_name, (char*)&device_node->name,
-				acpi_format_exception (status)));
+			ACPI_REPORT_METHOD_ERROR ("Method execution failed",
+				prefix_node, path, status);
 		}
 
 		return_ACPI_STATUS (status);
 	}
 
-
 	/* Did we get a return object? */
 
 	if (!obj_desc) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from %s\n",
-			object_name));
-		return_ACPI_STATUS (AE_TYPE);
+		if (expected_return_btypes) {
+			ACPI_REPORT_METHOD_ERROR ("No object was returned from",
+				prefix_node, path, AE_NOT_EXIST);
+
+			return_ACPI_STATUS (AE_NOT_EXIST);
+		}
+
+		return_ACPI_STATUS (AE_OK);
 	}
 
-	/* Is the return object of the correct type? */
+	/* Map the return object type to the bitmapped type */
+
+	switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
+	case ACPI_TYPE_INTEGER:
+		return_btype = ACPI_BTYPE_INTEGER;
+		break;
+
+	case ACPI_TYPE_BUFFER:
+		return_btype = ACPI_BTYPE_BUFFER;
+		break;
+
+	case ACPI_TYPE_STRING:
+		return_btype = ACPI_BTYPE_STRING;
+		break;
+
+	case ACPI_TYPE_PACKAGE:
+		return_btype = ACPI_BTYPE_PACKAGE;
+		break;
+
+	default:
+		return_btype = 0;
+		break;
+	}
+
+	/* Is the return object one of the expected types? */
+
+	if (!(expected_return_btypes & return_btype)) {
+		ACPI_REPORT_METHOD_ERROR ("Return object type is incorrect",
+			prefix_node, path, AE_TYPE);
 
-	if (obj_desc->common.type != ACPI_TYPE_INTEGER) {
-		status = AE_TYPE;
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-			"Type returned from %s was not a number: %X \n",
-			object_name, obj_desc->common.type));
+			"Type returned from %s was incorrect: %X\n",
+			path, ACPI_GET_OBJECT_TYPE (obj_desc)));
+
+		/* On error exit, we must delete the return object */
+
+		acpi_ut_remove_reference (obj_desc);
+		return_ACPI_STATUS (AE_TYPE);
 	}
-	else {
-		/*
-		 * Since the structure is a union, setting any field will set all
-		 * of the variables in the union
-		 */
-		*address = obj_desc->integer.value;
+
+	/* Object type is OK, return it */
+
+	*return_desc = obj_desc;
+	return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_evaluate_numeric_object
+ *
+ * PARAMETERS:  *object_name        - Object name to be evaluated
+ *              device_node         - Node for the device
+ *              *Address            - Where the value is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Evaluates a numeric namespace object for a selected device
+ *              and stores result in *Address.
+ *
+ *              NOTE: Internal function, no parameter validation
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ut_evaluate_numeric_object (
+	char                            *object_name,
+	struct acpi_namespace_node      *device_node,
+	acpi_integer                    *address)
+{
+	union acpi_operand_object       *obj_desc;
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_TRACE ("ut_evaluate_numeric_object");
+
+
+	status = acpi_ut_evaluate_object (device_node, object_name,
+			 ACPI_BTYPE_INTEGER, &obj_desc);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
 	}
 
+	/* Get the returned Integer */
+
+	*address = obj_desc->integer.value;
+
 	/* On exit, we must delete the return object */
 
 	acpi_ut_remove_reference (obj_desc);
-
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_execute_HID
+ * FUNCTION:    acpi_ut_copy_id_string
  *
- * PARAMETERS:  Device_node         - Node for the device
+ * PARAMETERS:  Destination         - Where to copy the string
+ *              Source              - Source string
+ *              max_length          - Length of the destination buffer
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Copies an ID string for the _HID, _CID, and _UID methods.
+ *              Performs removal of a leading asterisk if present -- workaround
+ *              for a known issue on a bunch of machines.
+ *
+ ******************************************************************************/
+
+static void
+acpi_ut_copy_id_string (
+	char                            *destination,
+	char                            *source,
+	acpi_size                       max_length)
+{
+
+
+	/*
+	 * Workaround for ID strings that have a leading asterisk. This construct
+	 * is not allowed by the ACPI specification  (ID strings must be
+	 * alphanumeric), but enough existing machines have this embedded in their
+	 * ID strings that the following code is useful.
+	 */
+	if (*source == '*') {
+		source++;
+	}
+
+	/* Do the actual copy */
+
+	ACPI_STRNCPY (destination, source, max_length);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_execute_HID
+ *
+ * PARAMETERS:  device_node         - Node for the device
  *              *Hid                - Where the HID is returned
  *
  * RETURN:      Status
@@ -131,239 +266,299 @@
 
 acpi_status
 acpi_ut_execute_HID (
-	acpi_namespace_node     *device_node,
-	acpi_device_id          *hid)
+	struct acpi_namespace_node      *device_node,
+	struct acpi_device_id           *hid)
 {
-	acpi_operand_object     *obj_desc;
-	acpi_status             status;
-
+	union acpi_operand_object       *obj_desc;
+	acpi_status                     status;
 
-	FUNCTION_TRACE ("Ut_execute_HID");
 
+	ACPI_FUNCTION_TRACE ("ut_execute_HID");
 
-	/* Execute the method */
 
-	status = acpi_ns_evaluate_relative (device_node,
-			 METHOD_NAME__HID, NULL, &obj_desc);
+	status = acpi_ut_evaluate_object (device_node, METHOD_NAME__HID,
+			 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &obj_desc);
 	if (ACPI_FAILURE (status)) {
-		if (status == AE_NOT_FOUND) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "_HID on %4.4s was not found\n",
-				(char*)&device_node->name));
-		}
-
-		else {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "_HID on %4.4s failed %s\n",
-				(char*)&device_node->name, acpi_format_exception (status)));
-		}
-
 		return_ACPI_STATUS (status);
 	}
 
-	/* Did we get a return object? */
+	if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) {
+		/* Convert the Numeric HID to string */
 
-	if (!obj_desc) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from _HID\n"));
-		return_ACPI_STATUS (AE_TYPE);
+		acpi_ex_eisa_id_to_string ((u32) obj_desc->integer.value, hid->value);
 	}
+	else {
+		/* Copy the String HID from the returned object */
 
-	/*
-	 *  A _HID can return either a Number (32 bit compressed EISA ID) or
-	 *  a string
-	 */
-	if ((obj_desc->common.type != ACPI_TYPE_INTEGER) &&
-		(obj_desc->common.type != ACPI_TYPE_STRING)) {
-		status = AE_TYPE;
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-			"Type returned from _HID not a number or string: %s(%X) \n",
-			acpi_ut_get_type_name (obj_desc->common.type), obj_desc->common.type));
+		acpi_ut_copy_id_string (hid->value, obj_desc->string.pointer,
+				sizeof (hid->value));
 	}
 
-	else {
-		if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
-			/* Convert the Numeric HID to string */
+	/* On exit, we must delete the return object */
 
-			acpi_ex_eisa_id_to_string ((u32) obj_desc->integer.value, hid->buffer);
-		}
+	acpi_ut_remove_reference (obj_desc);
+	return_ACPI_STATUS (status);
+}
 
-		else {
-			/* Copy the String HID from the returned object */
 
-			STRNCPY(hid->buffer, obj_desc->string.pointer, sizeof(hid->buffer));
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_translate_one_cid
+ *
+ * PARAMETERS:  obj_desc            - _CID object, must be integer or string
+ *              one_cid             - Where the CID string is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Return a numeric or string _CID value as a string.
+ *              (Compatible ID)
+ *
+ *              NOTE:  Assumes a maximum _CID string length of
+ *                     ACPI_MAX_CID_LENGTH.
+ *
+ ******************************************************************************/
+
+static acpi_status
+acpi_ut_translate_one_cid (
+	union acpi_operand_object       *obj_desc,
+	struct acpi_compatible_id       *one_cid)
+{
+
+
+	switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
+	case ACPI_TYPE_INTEGER:
+
+		/* Convert the Numeric CID to string */
+
+		acpi_ex_eisa_id_to_string ((u32) obj_desc->integer.value, one_cid->value);
+		return (AE_OK);
+
+	case ACPI_TYPE_STRING:
+
+		if (obj_desc->string.length > ACPI_MAX_CID_LENGTH) {
+			return (AE_AML_STRING_LIMIT);
 		}
-	}
 
+		/* Copy the String CID from the returned object */
 
-	/* On exit, we must delete the return object */
+		acpi_ut_copy_id_string (one_cid->value, obj_desc->string.pointer,
+				ACPI_MAX_CID_LENGTH);
+		return (AE_OK);
 
-	acpi_ut_remove_reference (obj_desc);
+	default:
 
-	return_ACPI_STATUS (status);
+		return (AE_TYPE);
+	}
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_execute_UID
+ * FUNCTION:    acpi_ut_execute_CID
  *
- * PARAMETERS:  Device_node         - Node for the device
- *              *Uid                - Where the UID is returned
+ * PARAMETERS:  device_node         - Node for the device
+ *              *Cid                - Where the CID is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Executes the _UID control method that returns the hardware
- *              ID of the device.
+ * DESCRIPTION: Executes the _CID control method that returns one or more
+ *              compatible hardware IDs for the device.
  *
  *              NOTE: Internal function, no parameter validation
  *
  ******************************************************************************/
 
 acpi_status
-acpi_ut_execute_UID (
-	acpi_namespace_node     *device_node,
-	acpi_device_id          *uid)
+acpi_ut_execute_CID (
+	struct acpi_namespace_node      *device_node,
+	struct acpi_compatible_id_list **return_cid_list)
 {
-	acpi_operand_object     *obj_desc;
-	acpi_status             status;
+	union acpi_operand_object       *obj_desc;
+	acpi_status                     status;
+	u32                             count;
+	u32                             size;
+	struct acpi_compatible_id_list *cid_list;
+	acpi_native_uint                i;
 
 
-	PROC_NAME ("Ut_execute_UID");
+	ACPI_FUNCTION_TRACE ("ut_execute_CID");
 
 
-	/* Execute the method */
+	/* Evaluate the _CID method for this device */
 
-	status = acpi_ns_evaluate_relative (device_node,
-			 METHOD_NAME__UID, NULL, &obj_desc);
+	status = acpi_ut_evaluate_object (device_node, METHOD_NAME__CID,
+			 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE,
+			 &obj_desc);
 	if (ACPI_FAILURE (status)) {
-		if (status == AE_NOT_FOUND) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "_UID on %4.4s was not found\n",
-				(char*)&device_node->name));
-		}
+		return_ACPI_STATUS (status);
+	}
 
-		else {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-				"_UID on %4.4s failed %s\n",
-				(char*)&device_node->name, acpi_format_exception (status)));
-		}
+	/* Get the number of _CIDs returned */
 
-		return (status);
+	count = 1;
+	if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_PACKAGE) {
+		count = obj_desc->package.count;
 	}
 
-	/* Did we get a return object? */
+	/* Allocate a worst-case buffer for the _CIDs */
 
-	if (!obj_desc) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from _UID\n"));
-		return (AE_TYPE);
+	size = (((count - 1) * sizeof (struct acpi_compatible_id)) +
+			   sizeof (struct acpi_compatible_id_list));
+
+	cid_list = ACPI_MEM_CALLOCATE ((acpi_size) size);
+	if (!cid_list) {
+		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
 
+	/* Init CID list */
+
+	cid_list->count = count;
+	cid_list->size = size;
+
 	/*
-	 *  A _UID can return either a Number (32 bit compressed EISA ID) or
-	 *  a string
+	 *  A _CID can return either a single compatible ID or a package of compatible
+	 *  IDs.  Each compatible ID can be one of the following:
+	 *  -- Number (32 bit compressed EISA ID) or
+	 *  -- String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss").
 	 */
-	if ((obj_desc->common.type != ACPI_TYPE_INTEGER) &&
-		(obj_desc->common.type != ACPI_TYPE_STRING)) {
-		status = AE_TYPE;
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-			"Type returned from _UID was not a number or string: %X \n",
-			obj_desc->common.type));
-	}
 
-	else {
-		if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
-			/* Convert the Numeric UID to string */
-
-			acpi_ex_unsigned_integer_to_string (obj_desc->integer.value, uid->buffer);
-		}
+	/* The _CID object can be either a single CID or a package (list) of CIDs */
 
-		else {
-			/* Copy the String UID from the returned object */
+	if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_PACKAGE) {
+		/* Translate each package element */
 
-			STRNCPY(uid->buffer, obj_desc->string.pointer, sizeof(uid->buffer));
+		for (i = 0; i < count; i++) {
+			status = acpi_ut_translate_one_cid (obj_desc->package.elements[i],
+					  &cid_list->id[i]);
+			if (ACPI_FAILURE (status)) {
+				break;
+			}
 		}
 	}
+	else {
+		/* Only one CID, translate to a string */
 
+		status = acpi_ut_translate_one_cid (obj_desc, cid_list->id);
+	}
 
-	/* On exit, we must delete the return object */
+	/* Cleanup on error */
 
-	acpi_ut_remove_reference (obj_desc);
+	if (ACPI_FAILURE (status)) {
+		ACPI_MEM_FREE (cid_list);
+	}
+	else {
+		*return_cid_list = cid_list;
+	}
 
-	return (status);
+	/* On exit, we must delete the _CID return object */
+
+	acpi_ut_remove_reference (obj_desc);
+	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_execute_STA
+ * FUNCTION:    acpi_ut_execute_UID
  *
- * PARAMETERS:  Device_node         - Node for the device
- *              *Flags              - Where the status flags are returned
+ * PARAMETERS:  device_node         - Node for the device
+ *              *Uid                - Where the UID is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Executes _STA for selected device and stores results in
- *              *Flags.
+ * DESCRIPTION: Executes the _UID control method that returns the hardware
+ *              ID of the device.
  *
  *              NOTE: Internal function, no parameter validation
  *
  ******************************************************************************/
 
 acpi_status
-acpi_ut_execute_STA (
-	acpi_namespace_node     *device_node,
-	u32                     *flags)
+acpi_ut_execute_UID (
+	struct acpi_namespace_node      *device_node,
+	struct acpi_device_id           *uid)
 {
-	acpi_operand_object     *obj_desc;
-	acpi_status             status;
+	union acpi_operand_object       *obj_desc;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Ut_execute_STA");
+	ACPI_FUNCTION_TRACE ("ut_execute_UID");
 
 
-	/* Execute the method */
+	status = acpi_ut_evaluate_object (device_node, METHOD_NAME__UID,
+			 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &obj_desc);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
-	status = acpi_ns_evaluate_relative (device_node,
-			 METHOD_NAME__STA, NULL, &obj_desc);
-	if (AE_NOT_FOUND == status) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-			"_STA on %4.4s was not found, assuming present.\n",
-			(char*)&device_node->name));
+	if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) {
+		/* Convert the Numeric UID to string */
 
-		*flags = 0x0F;
-		status = AE_OK;
+		acpi_ex_unsigned_integer_to_string (obj_desc->integer.value, uid->value);
 	}
+	else {
+		/* Copy the String UID from the returned object */
 
-	else if (ACPI_FAILURE (status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "_STA on %4.4s failed %s\n",
-			(char*)&device_node->name,
-			acpi_format_exception (status)));
+		acpi_ut_copy_id_string (uid->value, obj_desc->string.pointer,
+				sizeof (uid->value));
 	}
 
-	else /* success */ {
-		/* Did we get a return object? */
+	/* On exit, we must delete the return object */
 
-		if (!obj_desc) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from _STA\n"));
-			return_ACPI_STATUS (AE_TYPE);
-		}
+	acpi_ut_remove_reference (obj_desc);
+	return_ACPI_STATUS (status);
+}
 
-		/* Is the return object of the correct type? */
 
-		if (obj_desc->common.type != ACPI_TYPE_INTEGER) {
-			status = AE_TYPE;
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-				"Type returned from _STA was not a number: %X \n",
-				obj_desc->common.type));
-		}
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_execute_STA
+ *
+ * PARAMETERS:  device_node         - Node for the device
+ *              *Flags              - Where the status flags are returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Executes _STA for selected device and stores results in
+ *              *Flags.
+ *
+ *              NOTE: Internal function, no parameter validation
+ *
+ ******************************************************************************/
 
-		else {
-			/* Extract the status flags */
+acpi_status
+acpi_ut_execute_STA (
+	struct acpi_namespace_node      *device_node,
+	u32                             *flags)
+{
+	union acpi_operand_object       *obj_desc;
+	acpi_status                     status;
 
-			*flags = (u32) obj_desc->integer.value;
-		}
 
-		/* On exit, we must delete the return object */
+	ACPI_FUNCTION_TRACE ("ut_execute_STA");
 
-		acpi_ut_remove_reference (obj_desc);
+
+	status = acpi_ut_evaluate_object (device_node, METHOD_NAME__STA,
+			 ACPI_BTYPE_INTEGER, &obj_desc);
+	if (ACPI_FAILURE (status)) {
+		if (AE_NOT_FOUND == status) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+				"_STA on %4.4s was not found, assuming device is present\n",
+				device_node->name.ascii));
+
+			*flags = 0x0F;
+			status = AE_OK;
+		}
+
+		return_ACPI_STATUS (status);
 	}
 
+	/* Extract the status flags */
+
+	*flags = (u32) obj_desc->integer.value;
+
+	/* On exit, we must delete the return object */
+
+	acpi_ut_remove_reference (obj_desc);
 	return_ACPI_STATUS (status);
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/utilities/utglobal.c linux-2.4.22-pre2/drivers/acpi/utilities/utglobal.c
--- linux-2.4.21/drivers/acpi/utilities/utglobal.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/utilities/utglobal.c	2003-06-26 21:43:12.000000000 +0000
@@ -1,44 +1,58 @@
 /******************************************************************************
  *
  * Module Name: utglobal - Global variables for the ACPI subsystem
- *              $Revision: 133 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 #define DEFINE_ACPI_GLOBALS
 
-#include "acpi.h"
-#include "acevents.h"
-#include "acnamesp.h"
-#include "acinterp.h"
-#include "amlcode.h"
-
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
 
 #define _COMPONENT          ACPI_UTILITIES
-	 MODULE_NAME         ("utglobal")
+	 ACPI_MODULE_NAME    ("utglobal")
 
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_format_exception
+ * FUNCTION:    acpi_format_exception
  *
  * PARAMETERS:  Status       - The acpi_status code to be formatted
  *
@@ -50,57 +64,69 @@
 
 const char *
 acpi_format_exception (
-	acpi_status             status)
+	acpi_status                     status)
 {
-	const char              *exception = "UNKNOWN_STATUS_CODE";
-	acpi_status             sub_status;
+	const char                      *exception = "UNKNOWN_STATUS_CODE";
+	acpi_status                     sub_status;
 
 
-	sub_status = (status & ~AE_CODE_MASK);
+	ACPI_FUNCTION_NAME ("format_exception");
 
 
+	sub_status = (status & ~AE_CODE_MASK);
+
 	switch (status & AE_CODE_MASK) {
 	case AE_CODE_ENVIRONMENTAL:
 
 		if (sub_status <= AE_CODE_ENV_MAX) {
 			exception = acpi_gbl_exception_names_env [sub_status];
+			break;
 		}
-		break;
+		goto unknown;
 
 	case AE_CODE_PROGRAMMER:
 
 		if (sub_status <= AE_CODE_PGM_MAX) {
 			exception = acpi_gbl_exception_names_pgm [sub_status -1];
+			break;
 		}
-		break;
+		goto unknown;
 
 	case AE_CODE_ACPI_TABLES:
 
 		if (sub_status <= AE_CODE_TBL_MAX) {
 			exception = acpi_gbl_exception_names_tbl [sub_status -1];
+			break;
 		}
-		break;
+		goto unknown;
 
 	case AE_CODE_AML:
 
 		if (sub_status <= AE_CODE_AML_MAX) {
 			exception = acpi_gbl_exception_names_aml [sub_status -1];
+			break;
 		}
-		break;
+		goto unknown;
 
 	case AE_CODE_CONTROL:
 
 		if (sub_status <= AE_CODE_CTRL_MAX) {
 			exception = acpi_gbl_exception_names_ctrl [sub_status -1];
+			break;
 		}
-		break;
+		goto unknown;
 
 	default:
-		break;
+		goto unknown;
 	}
 
 
 	return ((const char *) exception);
+
+unknown:
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown exception code: 0x%8.8X\n", status));
+	return ((const char *) exception);
 }
 
 
@@ -117,37 +143,41 @@
 
 /* Debug switch - level and trace mask */
 
-#ifdef ACPI_DEBUG
-u32                         acpi_dbg_level = DEBUG_DEFAULT;
+#ifdef ACPI_DEBUG_OUTPUT
+u32                                 acpi_dbg_level = ACPI_DEBUG_DEFAULT;
 #else
-u32                         acpi_dbg_level = NORMAL_DEFAULT;
+u32                                 acpi_dbg_level = ACPI_NORMAL_DEFAULT;
 #endif
 
 /* Debug switch - layer (component) mask */
 
-u32                         acpi_dbg_layer = ACPI_COMPONENT_DEFAULT;
-u32                         acpi_gbl_nesting_level = 0;
+u32                                 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT;
+u32                                 acpi_gbl_nesting_level = 0;
 
 
 /* Debugger globals */
 
-u8                          acpi_gbl_db_terminate_threads = FALSE;
-u8                          acpi_gbl_method_executing = FALSE;
+u8                                  acpi_gbl_db_terminate_threads = FALSE;
+u8                                  acpi_gbl_abort_method = FALSE;
+u8                                  acpi_gbl_method_executing = FALSE;
 
 /* System flags */
 
-u32                         acpi_gbl_system_flags = 0;
-u32                         acpi_gbl_startup_flags = 0;
+u32                                 acpi_gbl_startup_flags = 0;
 
-/* System starts unitialized! */
+/* System starts uninitialized */
 
-u8                          acpi_gbl_shutdown = TRUE;
+u8                                  acpi_gbl_shutdown = TRUE;
 
-const u8                    acpi_gbl_decode_to8bit [8] = {1,2,4,8,16,32,64,128};
+const u8                            acpi_gbl_decode_to8bit [8] = {1,2,4,8,16,32,64,128};
 
-const NATIVE_CHAR           *acpi_gbl_db_sleep_states[ACPI_NUM_SLEEP_STATES] = {
-			  "\\_S0_","\\_S1_","\\_S2_","\\_S3_",
-			  "\\_S4_","\\_S5_","\\_S4B"};
+const char                          *acpi_gbl_db_sleep_states[ACPI_S_STATE_COUNT] = {
+			  "\\_S0_",
+			  "\\_S1_",
+			  "\\_S2_",
+			  "\\_S3_",
+			  "\\_S4_",
+			  "\\_S5_"};
 
 
 /******************************************************************************
@@ -158,86 +188,82 @@
 
 
 /*
- * Names built-in to the interpreter
+ * Predefined ACPI Names (Built-in to the Interpreter)
  *
  * Initial values are currently supported only for types String and Number.
- * To avoid type punning, both are specified as strings in this table.
+ * Both are specified as strings in this table.
  *
  * NOTES:
  * 1) _SB_ is defined to be a device to allow _SB_/_INI to be run
  *    during the initialization sequence.
  */
 
-const predefined_names      acpi_gbl_pre_defined_names[] =
-{ {"_GPE",    INTERNAL_TYPE_DEF_ANY},
-	{"_PR_",    INTERNAL_TYPE_DEF_ANY},
-	{"_SB_",    ACPI_TYPE_DEVICE},
-	{"_SI_",    INTERNAL_TYPE_DEF_ANY},
-	{"_TZ_",    INTERNAL_TYPE_DEF_ANY},
-	{"_REV",    ACPI_TYPE_INTEGER, "2"},
-	{"_OS_",    ACPI_TYPE_STRING, ACPI_OS_NAME},
-	{"_GL_",    ACPI_TYPE_MUTEX, "0"},
-	{NULL,      ACPI_TYPE_ANY}           /* Table terminator */
+const struct acpi_predefined_names      acpi_gbl_pre_defined_names[] =
+{ {"_GPE",    ACPI_TYPE_LOCAL_SCOPE,      NULL},
+	{"_PR_",    ACPI_TYPE_LOCAL_SCOPE,      NULL},
+	{"_SB_",    ACPI_TYPE_DEVICE,           NULL},
+	{"_SI_",    ACPI_TYPE_LOCAL_SCOPE,      NULL},
+	{"_TZ_",    ACPI_TYPE_LOCAL_SCOPE,      NULL},
+	{"_REV",    ACPI_TYPE_INTEGER,          "2"},
+	{"_OS_",    ACPI_TYPE_STRING,           ACPI_OS_NAME},
+	{"_GL_",    ACPI_TYPE_MUTEX,            "0"},
+
+#if defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
+	{"_OSI",    ACPI_TYPE_METHOD,           "1"},
+#endif
+	{NULL,      ACPI_TYPE_ANY,              NULL}              /* Table terminator */
 };
 
 
 /*
  * Properties of the ACPI Object Types, both internal and external.
- *
- * Elements of Acpi_ns_properties are bit significant
- * and the table is indexed by values of acpi_object_type
+ * The table is indexed by values of acpi_object_type
  */
 
-const u8                    acpi_gbl_ns_properties[] =
+const u8                                acpi_gbl_ns_properties[] =
 {
-	NSP_NORMAL,                 /* 00 Any              */
-	NSP_NORMAL,                 /* 01 Number           */
-	NSP_NORMAL,                 /* 02 String           */
-	NSP_NORMAL,                 /* 03 Buffer           */
-	NSP_LOCAL,                  /* 04 Package          */
-	NSP_NORMAL,                 /* 05 Field_unit       */
-	NSP_NEWSCOPE | NSP_LOCAL,   /* 06 Device           */
-	NSP_LOCAL,                  /* 07 Acpi_event       */
-	NSP_NEWSCOPE | NSP_LOCAL,   /* 08 Method           */
-	NSP_LOCAL,                  /* 09 Mutex            */
-	NSP_LOCAL,                  /* 10 Region           */
-	NSP_NEWSCOPE | NSP_LOCAL,   /* 11 Power            */
-	NSP_NEWSCOPE | NSP_LOCAL,   /* 12 Processor        */
-	NSP_NEWSCOPE | NSP_LOCAL,   /* 13 Thermal          */
-	NSP_NORMAL,                 /* 14 Buffer_field     */
-	NSP_NORMAL,                 /* 15 Ddb_handle       */
-	NSP_NORMAL,                 /* 16 Debug Object     */
-	NSP_NORMAL,                 /* 17 Def_field        */
-	NSP_NORMAL,                 /* 18 Bank_field       */
-	NSP_NORMAL,                 /* 19 Index_field      */
-	NSP_NORMAL,                 /* 20 Reference        */
-	NSP_NORMAL,                 /* 21 Alias            */
-	NSP_NORMAL,                 /* 22 Notify           */
-	NSP_NORMAL,                 /* 23 Address Handler  */
-	NSP_NEWSCOPE | NSP_LOCAL,   /* 24 Resource Desc    */
-	NSP_NEWSCOPE | NSP_LOCAL,   /* 25 Resource Field   */
-	NSP_NORMAL,                 /* 26 Def_field_defn   */
-	NSP_NORMAL,                 /* 27 Bank_field_defn  */
-	NSP_NORMAL,                 /* 28 Index_field_defn */
-	NSP_NORMAL,                 /* 29 If               */
-	NSP_NORMAL,                 /* 30 Else             */
-	NSP_NORMAL,                 /* 31 While            */
-	NSP_NEWSCOPE,               /* 32 Scope            */
-	NSP_LOCAL,                  /* 33 Def_any          */
-	NSP_NORMAL,                 /* 34 Extra            */
-	NSP_NORMAL                  /* 35 Invalid          */
+	ACPI_NS_NORMAL,                     /* 00 Any              */
+	ACPI_NS_NORMAL,                     /* 01 Number           */
+	ACPI_NS_NORMAL,                     /* 02 String           */
+	ACPI_NS_NORMAL,                     /* 03 Buffer           */
+	ACPI_NS_NORMAL,                     /* 04 Package          */
+	ACPI_NS_NORMAL,                     /* 05 field_unit       */
+	ACPI_NS_NEWSCOPE,                   /* 06 Device           */
+	ACPI_NS_NORMAL,                     /* 07 Event            */
+	ACPI_NS_NEWSCOPE,                   /* 08 Method           */
+	ACPI_NS_NORMAL,                     /* 09 Mutex            */
+	ACPI_NS_NORMAL,                     /* 10 Region           */
+	ACPI_NS_NEWSCOPE,                   /* 11 Power            */
+	ACPI_NS_NEWSCOPE,                   /* 12 Processor        */
+	ACPI_NS_NEWSCOPE,                   /* 13 Thermal          */
+	ACPI_NS_NORMAL,                     /* 14 buffer_field     */
+	ACPI_NS_NORMAL,                     /* 15 ddb_handle       */
+	ACPI_NS_NORMAL,                     /* 16 Debug Object     */
+	ACPI_NS_NORMAL,                     /* 17 def_field        */
+	ACPI_NS_NORMAL,                     /* 18 bank_field       */
+	ACPI_NS_NORMAL,                     /* 19 index_field      */
+	ACPI_NS_NORMAL,                     /* 20 Reference        */
+	ACPI_NS_NORMAL,                     /* 21 Alias            */
+	ACPI_NS_NORMAL,                     /* 22 Notify           */
+	ACPI_NS_NORMAL,                     /* 23 Address Handler  */
+	ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,   /* 24 Resource Desc    */
+	ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,   /* 25 Resource Field   */
+	ACPI_NS_NEWSCOPE,                   /* 26 Scope            */
+	ACPI_NS_NORMAL,                     /* 27 Extra            */
+	ACPI_NS_NORMAL,                     /* 28 Data             */
+	ACPI_NS_NORMAL                      /* 29 Invalid          */
 };
 
 
 /* Hex to ASCII conversion table */
 
-const NATIVE_CHAR           acpi_gbl_hex_to_ascii[] =
+static const char                   acpi_gbl_hex_to_ascii[] =
 			  {'0','1','2','3','4','5','6','7',
-			  '8','9','A','B','C','D','E','F'};
+					 '8','9','A','B','C','D','E','F'};
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ut_hex_to_ascii_char
+ * FUNCTION:    acpi_ut_hex_to_ascii_char
  *
  * PARAMETERS:  Integer             - Contains the hex digit
  *              Position            - bit position of the digit within the
@@ -249,10 +275,10 @@
  *
  ****************************************************************************/
 
-u8
+char
 acpi_ut_hex_to_ascii_char (
-	acpi_integer            integer,
-	u32                     position)
+	acpi_integer                    integer,
+	u32                             position)
 {
 
 	return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
@@ -261,68 +287,180 @@
 
 /******************************************************************************
  *
- * Table globals
+ * Table name globals
  *
  * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes.
  * it is NOT an exhaustive list of all possible ACPI tables.  All ACPI tables
  * that are not used by the subsystem are simply ignored.
  *
+ * Do NOT add any table to this list that is not consumed directly by this
+ * subsystem.
+ *
  ******************************************************************************/
 
 
-acpi_table_desc             acpi_gbl_acpi_tables[NUM_ACPI_TABLES];
+struct acpi_table_list              acpi_gbl_table_lists[NUM_ACPI_TABLE_TYPES];
+
 
+struct acpi_table_support           acpi_gbl_table_data[NUM_ACPI_TABLE_TYPES] =
+{
+	/***********    Name,   Signature, Global typed pointer     Signature size,      Type                  How many allowed?,    Contains valid AML? */
+
+	/* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL,                    sizeof (RSDP_SIG)-1, ACPI_TABLE_ROOT     | ACPI_TABLE_SINGLE},
+	/* DSDT 1 */ {DSDT_SIG,  DSDT_SIG, (void **) &acpi_gbl_DSDT, sizeof (DSDT_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE  | ACPI_TABLE_EXECUTABLE},
+	/* FADT 2 */ {FADT_SIG,  FADT_SIG, (void **) &acpi_gbl_FADT, sizeof (FADT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE},
+	/* FACS 3 */ {FACS_SIG,  FACS_SIG, (void **) &acpi_gbl_FACS, sizeof (FACS_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE},
+	/* PSDT 4 */ {PSDT_SIG,  PSDT_SIG, NULL,                    sizeof (PSDT_SIG)-1, ACPI_TABLE_PRIMARY  | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE},
+	/* SSDT 5 */ {SSDT_SIG,  SSDT_SIG, NULL,                    sizeof (SSDT_SIG)-1, ACPI_TABLE_PRIMARY  | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE},
+	/* XSDT 6 */ {XSDT_SIG,  XSDT_SIG, NULL,                    sizeof (RSDT_SIG)-1, ACPI_TABLE_ROOT     | ACPI_TABLE_SINGLE},
+};
+
+
+/******************************************************************************
+ *
+ * Event and Hardware globals
+ *
+ ******************************************************************************/
 
-ACPI_TABLE_SUPPORT          acpi_gbl_acpi_table_data[NUM_ACPI_TABLES] =
+struct acpi_bit_register_info       acpi_gbl_bit_register_info[ACPI_NUM_BITREG] =
 {
-	/***********    Name,    Signature,  Signature size,    How many allowed?,   Supported?  Global typed pointer */
+	/* Name                                     Parent Register             Register Bit Position                   Register Bit Mask       */
+
+	/* ACPI_BITREG_TIMER_STATUS         */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_TIMER_STATUS,          ACPI_BITMASK_TIMER_STATUS},
+	/* ACPI_BITREG_BUS_MASTER_STATUS    */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_BUS_MASTER_STATUS,     ACPI_BITMASK_BUS_MASTER_STATUS},
+	/* ACPI_BITREG_GLOBAL_LOCK_STATUS   */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_GLOBAL_LOCK_STATUS,    ACPI_BITMASK_GLOBAL_LOCK_STATUS},
+	/* ACPI_BITREG_POWER_BUTTON_STATUS  */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_POWER_BUTTON_STATUS,   ACPI_BITMASK_POWER_BUTTON_STATUS},
+	/* ACPI_BITREG_SLEEP_BUTTON_STATUS  */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_SLEEP_BUTTON_STATUS,   ACPI_BITMASK_SLEEP_BUTTON_STATUS},
+	/* ACPI_BITREG_RT_CLOCK_STATUS      */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_RT_CLOCK_STATUS,       ACPI_BITMASK_RT_CLOCK_STATUS},
+	/* ACPI_BITREG_WAKE_STATUS          */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_WAKE_STATUS,           ACPI_BITMASK_WAKE_STATUS},
+
+	/* ACPI_BITREG_TIMER_ENABLE         */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_TIMER_ENABLE,          ACPI_BITMASK_TIMER_ENABLE},
+	/* ACPI_BITREG_GLOBAL_LOCK_ENABLE   */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE,    ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
+	/* ACPI_BITREG_POWER_BUTTON_ENABLE  */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_POWER_BUTTON_ENABLE,   ACPI_BITMASK_POWER_BUTTON_ENABLE},
+	/* ACPI_BITREG_SLEEP_BUTTON_ENABLE  */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE,   ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
+	/* ACPI_BITREG_RT_CLOCK_ENABLE      */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_RT_CLOCK_ENABLE,       ACPI_BITMASK_RT_CLOCK_ENABLE},
+	/* ACPI_BITREG_WAKE_ENABLE          */   {ACPI_REGISTER_PM1_ENABLE,   0,                                      0},
+
+	/* ACPI_BITREG_SCI_ENABLE           */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_SCI_ENABLE,            ACPI_BITMASK_SCI_ENABLE},
+	/* ACPI_BITREG_BUS_MASTER_RLD       */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_BUS_MASTER_RLD,        ACPI_BITMASK_BUS_MASTER_RLD},
+	/* ACPI_BITREG_GLOBAL_LOCK_RELEASE  */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE,   ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
+	/* ACPI_BITREG_SLEEP_TYPE_A         */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_SLEEP_TYPE_X,          ACPI_BITMASK_SLEEP_TYPE_X},
+	/* ACPI_BITREG_SLEEP_TYPE_B         */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_SLEEP_TYPE_X,          ACPI_BITMASK_SLEEP_TYPE_X},
+	/* ACPI_BITREG_SLEEP_ENABLE         */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_SLEEP_ENABLE,          ACPI_BITMASK_SLEEP_ENABLE},
 
-	/* RSDP 0 */ {RSDP_NAME, RSDP_SIG, sizeof (RSDP_SIG)-1, ACPI_TABLE_SINGLE,   AE_OK,      NULL},
-	/* DSDT 1 */ {DSDT_SIG,  DSDT_SIG, sizeof (DSDT_SIG)-1, ACPI_TABLE_SINGLE,   AE_OK,      (void **) &acpi_gbl_DSDT},
-	/* FADT 2 */ {FADT_SIG,  FADT_SIG, sizeof (FADT_SIG)-1, ACPI_TABLE_SINGLE,   AE_OK,      (void **) &acpi_gbl_FADT},
-	/* FACS 3 */ {FACS_SIG,  FACS_SIG, sizeof (FACS_SIG)-1, ACPI_TABLE_SINGLE,   AE_OK,      (void **) &acpi_gbl_FACS},
-	/* PSDT 4 */ {PSDT_SIG,  PSDT_SIG, sizeof (PSDT_SIG)-1, ACPI_TABLE_MULTIPLE, AE_OK,      NULL},
-	/* SSDT 5 */ {SSDT_SIG,  SSDT_SIG, sizeof (SSDT_SIG)-1, ACPI_TABLE_MULTIPLE, AE_OK,      NULL},
-	/* XSDT 6 */ {XSDT_SIG,  XSDT_SIG, sizeof (RSDT_SIG)-1, ACPI_TABLE_SINGLE,   AE_OK,      NULL},
+	/* ACPI_BITREG_ARB_DIS              */   {ACPI_REGISTER_PM2_CONTROL,  ACPI_BITPOSITION_ARB_DISABLE,           ACPI_BITMASK_ARB_DISABLE}
 };
 
 
-#ifdef ACPI_DEBUG
+struct acpi_fixed_event_info        acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] =
+{
+	/* ACPI_EVENT_PMTIMER       */  {ACPI_BITREG_TIMER_STATUS,          ACPI_BITREG_TIMER_ENABLE,        ACPI_BITMASK_TIMER_STATUS,          ACPI_BITMASK_TIMER_ENABLE},
+	/* ACPI_EVENT_GLOBAL        */  {ACPI_BITREG_GLOBAL_LOCK_STATUS,    ACPI_BITREG_GLOBAL_LOCK_ENABLE,  ACPI_BITMASK_GLOBAL_LOCK_STATUS,    ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
+	/* ACPI_EVENT_POWER_BUTTON  */  {ACPI_BITREG_POWER_BUTTON_STATUS,   ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS,   ACPI_BITMASK_POWER_BUTTON_ENABLE},
+	/* ACPI_EVENT_SLEEP_BUTTON  */  {ACPI_BITREG_SLEEP_BUTTON_STATUS,   ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS,   ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
+	/* ACPI_EVENT_RTC           */  {ACPI_BITREG_RT_CLOCK_STATUS,       ACPI_BITREG_RT_CLOCK_ENABLE,     0,                                  0},
+};
 
-/*
- * Strings and procedures used for debug only
+/*****************************************************************************
  *
- */
+ * FUNCTION:    acpi_ut_get_region_name
+ *
+ * PARAMETERS:  None.
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Translate a Space ID into a name string (Debug only)
+ *
+ ****************************************************************************/
+
+/* Region type decoding */
+
+const char                *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] =
+{
+/*! [Begin] no source code translation (keep these ASL Keywords as-is) */
+	"SystemMemory",
+	"SystemIO",
+	"PCI_Config",
+	"EmbeddedControl",
+	"SMBus",
+	"CMOS",
+	"PCIBARTarget",
+	"DataTable"
+/*! [End] no source code translation !*/
+};
+
+
+char *
+acpi_ut_get_region_name (
+	u8                              space_id)
+{
+
+	if (space_id >= ACPI_USER_REGION_BEGIN)
+	{
+		return ("user_defined_region");
+	}
+
+	else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS)
+	{
+		return ("invalid_space_id");
+	}
+
+	return ((char *) acpi_gbl_region_types[space_id]);
+}
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ut_get_mutex_name
+ * FUNCTION:    acpi_ut_get_event_name
  *
  * PARAMETERS:  None.
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
+ * DESCRIPTION: Translate a Event ID into a name string (Debug only)
  *
  ****************************************************************************/
 
-NATIVE_CHAR *
-acpi_ut_get_mutex_name (
-	u32                     mutex_id)
+/* Event type decoding */
+
+static const char                *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] =
 {
+	"PM_Timer",
+	"global_lock",
+	"power_button",
+	"sleep_button",
+	"real_time_clock",
+};
+
 
-	if (mutex_id > MAX_MTX)
+char *
+acpi_ut_get_event_name (
+	u32                             event_id)
+{
+
+	if (event_id > ACPI_EVENT_MAX)
 	{
-		return ("Invalid Mutex ID");
+		return ("invalid_event_iD");
 	}
 
-	return (acpi_gbl_mutex_names[mutex_id]);
+	return ((char *) acpi_gbl_event_types[event_id]);
 }
 
 
+/*****************************************************************************
+ *
+ * FUNCTION:    acpi_ut_get_type_name
+ *
+ * PARAMETERS:  None.
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Translate a Type ID into a name string (Debug only)
+ *
+ ****************************************************************************/
+
 /*
- * Elements of Acpi_gbl_Ns_type_names below must match
+ * Elements of acpi_gbl_ns_type_names below must match
  * one-to-one with values of acpi_object_type
  *
  * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; when
@@ -330,17 +468,17 @@
  * indicatewhat type is actually going to be stored for this entry.
  */
 
-static const NATIVE_CHAR    acpi_gbl_bad_type[] = "UNDEFINED";
+static const char                   acpi_gbl_bad_type[] = "UNDEFINED";
 #define TYPE_NAME_LENGTH    12                           /* Maximum length of each string */
 
-static const NATIVE_CHAR    *acpi_gbl_ns_type_names[] = /* printable names of ACPI types */
+static const char                   *acpi_gbl_ns_type_names[] = /* printable names of ACPI types */
 {
 	/* 00 */ "Untyped",
 	/* 01 */ "Integer",
 	/* 02 */ "String",
 	/* 03 */ "Buffer",
 	/* 04 */ "Package",
-	/* 05 */ "Field_unit",
+	/* 05 */ "field_unit",
 	/* 06 */ "Device",
 	/* 07 */ "Event",
 	/* 08 */ "Method",
@@ -349,154 +487,91 @@
 	/* 11 */ "Power",
 	/* 12 */ "Processor",
 	/* 13 */ "Thermal",
-	/* 14 */ "Buffer_field",
-	/* 15 */ "Ddb_handle",
-	/* 16 */ "Debug_object",
-	/* 17 */ "Region_field",
-	/* 18 */ "Bank_field",
-	/* 19 */ "Index_field",
+	/* 14 */ "buffer_field",
+	/* 15 */ "ddb_handle",
+	/* 16 */ "debug_object",
+	/* 17 */ "region_field",
+	/* 18 */ "bank_field",
+	/* 19 */ "index_field",
 	/* 20 */ "Reference",
 	/* 21 */ "Alias",
 	/* 22 */ "Notify",
-	/* 23 */ "Addr_handler",
-	/* 24 */ "Resource_desc",
-	/* 25 */ "Resource_fld",
-	/* 26 */ "Region_fld_dfn",
-	/* 27 */ "Bank_fld_dfn",
-	/* 28 */ "Index_fld_dfn",
-	/* 29 */ "If",
-	/* 30 */ "Else",
-	/* 31 */ "While",
-	/* 32 */ "Scope",
-	/* 33 */ "Def_any",
-	/* 34 */ "Extra",
-	/* 35 */ "Invalid"
+	/* 23 */ "addr_handler",
+	/* 24 */ "resource_desc",
+	/* 25 */ "resource_fld",
+	/* 26 */ "Scope",
+	/* 27 */ "Extra",
+	/* 28 */ "Data",
+	/* 39 */ "Invalid"
 };
 
 
-/*****************************************************************************
- *
- * FUNCTION:    Acpi_ut_get_type_name
- *
- * PARAMETERS:  None.
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Translate a Type ID into a name string (Debug only)
- *
- ****************************************************************************/
-
-NATIVE_CHAR *
+char *
 acpi_ut_get_type_name (
-	u32                     type)
+	acpi_object_type                type)
 {
 
-	if (type > INTERNAL_TYPE_INVALID)
+	if (type > ACPI_TYPE_INVALID)
 	{
-		return ((NATIVE_CHAR *) acpi_gbl_bad_type);
+		return ((char *) acpi_gbl_bad_type);
 	}
 
-	return ((NATIVE_CHAR *) acpi_gbl_ns_type_names[type]);
+	return ((char *) acpi_gbl_ns_type_names[type]);
 }
 
 
-/* Region type decoding */
-
-const NATIVE_CHAR *acpi_gbl_region_types[NUM_REGION_TYPES] =
+char *
+acpi_ut_get_object_type_name (
+	union acpi_operand_object       *obj_desc)
 {
-	"System_memory",
-	"System_iO",
-	"PCIConfig",
-	"Embedded_control",
-	"SMBus",
-	"CMOS",
-	"PCIBar_target",
-};
+
+	if (!obj_desc)
+	{
+		return ("[NULL Object Descriptor]");
+	}
+
+	return (acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (obj_desc)));
+}
 
 
+#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
+/*
+ * Strings and procedures used for debug only
+ */
+
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ut_get_region_name
+ * FUNCTION:    acpi_ut_get_mutex_name
  *
  * PARAMETERS:  None.
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Translate a Space ID into a name string (Debug only)
+ * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
  *
  ****************************************************************************/
 
-NATIVE_CHAR *
-acpi_ut_get_region_name (
-	u8                      space_id)
+char *
+acpi_ut_get_mutex_name (
+	u32                             mutex_id)
 {
 
-	if (space_id >= USER_REGION_BEGIN)
-	{
-		return ("User_defined_region");
-	}
-
-	else if (space_id >= NUM_REGION_TYPES)
+	if (mutex_id > MAX_MUTEX)
 	{
-		return ("Invalid_space_iD");
+		return ("Invalid Mutex ID");
 	}
 
-	return ((NATIVE_CHAR *) acpi_gbl_region_types[space_id]);
+	return (acpi_gbl_mutex_names[mutex_id]);
 }
 
-
-/* Data used in keeping track of fields */
-
-const NATIVE_CHAR *acpi_gbl_FEnames[NUM_FIELD_NAMES] =
-{
-	"skip",
-	"?access?"
-};              /* FE = Field Element */
-
-
-const NATIVE_CHAR *acpi_gbl_match_ops[NUM_MATCH_OPS] =
-{
-	"Error",
-	"MTR",
-	"MEQ",
-	"MLE",
-	"MLT",
-	"MGE",
-	"MGT"
-};
-
-
-/* Access type decoding */
-
-const NATIVE_CHAR *acpi_gbl_access_types[NUM_ACCESS_TYPES] =
-{
-	"Any_acc",
-	"Byte_acc",
-	"Word_acc",
-	"DWord_acc",
-	"Block_acc",
-	"SMBSend_recv_acc",
-	"SMBQuick_acc"
-};
-
-
-/* Update rule decoding */
-
-const NATIVE_CHAR *acpi_gbl_update_rules[NUM_UPDATE_RULES] =
-{
-	"Preserve",
-	"Write_as_ones",
-	"Write_as_zeros"
-};
-
 #endif
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ut_valid_object_type
+ * FUNCTION:    acpi_ut_valid_object_type
  *
- * PARAMETERS:  None.
+ * PARAMETERS:  Type            - Object type to be validated
  *
  * RETURN:      TRUE if valid object type
  *
@@ -506,16 +581,14 @@
 
 u8
 acpi_ut_valid_object_type (
-	u32                     type)
+	acpi_object_type                type)
 {
 
-	if (type > ACPI_TYPE_MAX)
+	if (type > ACPI_TYPE_LOCAL_MAX)
 	{
-		if ((type < INTERNAL_TYPE_BEGIN) ||
-			(type > INTERNAL_TYPE_MAX))
-		{
-			return (FALSE);
-		}
+		/* Note: Assumes all TYPEs are contiguous (external/local) */
+
+		return (FALSE);
 	}
 
 	return (TRUE);
@@ -524,9 +597,9 @@
 
 /****************************************************************************
  *
- * FUNCTION:    Acpi_ut_allocate_owner_id
+ * FUNCTION:    acpi_ut_allocate_owner_id
  *
- * PARAMETERS:  Id_type         - Type of ID (method or table)
+ * PARAMETERS:  id_type         - Type of ID (method or table)
  *
  * DESCRIPTION: Allocate a table or method owner id
  *
@@ -534,52 +607,61 @@
 
 acpi_owner_id
 acpi_ut_allocate_owner_id (
-	u32                     id_type)
+	u32                             id_type)
 {
-	acpi_owner_id           owner_id = 0xFFFF;
+	acpi_owner_id                   owner_id = 0xFFFF;
 
 
-	FUNCTION_TRACE ("Ut_allocate_owner_id");
+	ACPI_FUNCTION_TRACE ("ut_allocate_owner_id");
 
 
-	acpi_ut_acquire_mutex (ACPI_MTX_CACHES);
+	if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES)))
+	{
+		return (0);
+	}
 
 	switch (id_type)
 	{
-	case OWNER_TYPE_TABLE:
+	case ACPI_OWNER_TYPE_TABLE:
 
 		owner_id = acpi_gbl_next_table_owner_id;
 		acpi_gbl_next_table_owner_id++;
 
-		if (acpi_gbl_next_table_owner_id == FIRST_METHOD_ID)
+		/* Check for wraparound */
+
+		if (acpi_gbl_next_table_owner_id == ACPI_FIRST_METHOD_ID)
 		{
-			acpi_gbl_next_table_owner_id = FIRST_TABLE_ID;
+			acpi_gbl_next_table_owner_id = ACPI_FIRST_TABLE_ID;
+			ACPI_REPORT_WARNING (("Table owner ID wraparound\n"));
 		}
 		break;
 
 
-	case OWNER_TYPE_METHOD:
+	case ACPI_OWNER_TYPE_METHOD:
 
 		owner_id = acpi_gbl_next_method_owner_id;
 		acpi_gbl_next_method_owner_id++;
 
-		if (acpi_gbl_next_method_owner_id == FIRST_TABLE_ID)
+		if (acpi_gbl_next_method_owner_id == ACPI_FIRST_TABLE_ID)
 		{
-			acpi_gbl_next_method_owner_id = FIRST_METHOD_ID;
+			/* Check for wraparound */
+
+			acpi_gbl_next_method_owner_id = ACPI_FIRST_METHOD_ID;
 		}
 		break;
-	}
 
+	default:
+		break;
+	}
 
-	acpi_ut_release_mutex (ACPI_MTX_CACHES);
-
+	(void) acpi_ut_release_mutex (ACPI_MTX_CACHES);
 	return_VALUE (owner_id);
 }
 
 
 /****************************************************************************
  *
- * FUNCTION:    Acpi_ut_init_globals
+ * FUNCTION:    acpi_ut_init_globals
  *
  * PARAMETERS:  none
  *
@@ -592,33 +674,33 @@
 acpi_ut_init_globals (
 	void)
 {
-	u32                     i;
+	u32                             i;
 
 
-	FUNCTION_TRACE ("Ut_init_globals");
+	ACPI_FUNCTION_TRACE ("ut_init_globals");
 
 	/* Memory allocation and cache lists */
 
-	MEMSET (acpi_gbl_memory_lists, 0, sizeof (ACPI_MEMORY_LIST) * ACPI_NUM_MEM_LISTS);
+	ACPI_MEMSET (acpi_gbl_memory_lists, 0, sizeof (struct acpi_memory_list) * ACPI_NUM_MEM_LISTS);
 
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].link_offset      = (u16) (NATIVE_UINT) &(((acpi_generic_state *) NULL)->common.next);
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].link_offset     = (u16) (NATIVE_UINT) &(((acpi_parse_object *) NULL)->next);
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].link_offset = (u16) (NATIVE_UINT) &(((acpi_parse2_object *) NULL)->next);
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].link_offset    = (u16) (NATIVE_UINT) &(((acpi_operand_object *) NULL)->cache.next);
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].link_offset       = (u16) (NATIVE_UINT) &(((acpi_walk_state *) NULL)->next);
-
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].object_size     = sizeof (acpi_namespace_node);
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].object_size      = sizeof (acpi_generic_state);
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].object_size     = sizeof (acpi_parse_object);
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].object_size = sizeof (acpi_parse2_object);
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].object_size    = sizeof (acpi_operand_object);
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].object_size       = sizeof (acpi_walk_state);
-
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].max_cache_depth  = MAX_STATE_CACHE_DEPTH;
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].max_cache_depth = MAX_PARSE_CACHE_DEPTH;
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].max_cache_depth = MAX_EXTPARSE_CACHE_DEPTH;
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].max_cache_depth = MAX_OBJECT_CACHE_DEPTH;
-	acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].max_cache_depth   = MAX_WALK_CACHE_DEPTH;
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].link_offset      = (u16) ACPI_PTR_DIFF (&(((union acpi_generic_state *) NULL)->common.next), NULL);
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].link_offset     = (u16) ACPI_PTR_DIFF (&(((union acpi_parse_object *) NULL)->common.next), NULL);
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_parse_object *) NULL)->common.next), NULL);
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].link_offset    = (u16) ACPI_PTR_DIFF (&(((union acpi_operand_object *) NULL)->cache.next), NULL);
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].link_offset       = (u16) ACPI_PTR_DIFF (&(((struct acpi_walk_state *) NULL)->next), NULL);
+
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].object_size     = sizeof (struct acpi_namespace_node);
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].object_size      = sizeof (union acpi_generic_state);
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].object_size     = sizeof (struct acpi_parse_obj_common);
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].object_size = sizeof (struct acpi_parse_obj_named);
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].object_size    = sizeof (union acpi_operand_object);
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].object_size       = sizeof (struct acpi_walk_state);
+
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].max_cache_depth  = ACPI_MAX_STATE_CACHE_DEPTH;
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].max_cache_depth = ACPI_MAX_PARSE_CACHE_DEPTH;
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].max_cache_depth = ACPI_MAX_EXTPARSE_CACHE_DEPTH;
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].max_cache_depth = ACPI_MAX_OBJECT_CACHE_DEPTH;
+	acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].max_cache_depth   = ACPI_MAX_WALK_CACHE_DEPTH;
 
 	ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].list_name    = "Global Memory Allocation");
 	ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].list_name    = "Namespace Nodes");
@@ -630,38 +712,32 @@
 
 	/* ACPI table structure */
 
-	for (i = 0; i < NUM_ACPI_TABLES; i++)
+	for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++)
 	{
-		acpi_gbl_acpi_tables[i].prev        = &acpi_gbl_acpi_tables[i];
-		acpi_gbl_acpi_tables[i].next        = &acpi_gbl_acpi_tables[i];
-		acpi_gbl_acpi_tables[i].pointer     = NULL;
-		acpi_gbl_acpi_tables[i].length      = 0;
-		acpi_gbl_acpi_tables[i].allocation  = ACPI_MEM_NOT_ALLOCATED;
-		acpi_gbl_acpi_tables[i].count       = 0;
+		acpi_gbl_table_lists[i].next        = NULL;
+		acpi_gbl_table_lists[i].count       = 0;
 	}
 
+	/* Mutex locked flags */
 
-	/* Address Space handler array */
-
-	for (i = 0; i < ACPI_NUM_ADDRESS_SPACES; i++)
+	for (i = 0; i < NUM_MUTEX; i++)
 	{
-		acpi_gbl_address_spaces[i].handler  = NULL;
-		acpi_gbl_address_spaces[i].context  = NULL;
+		acpi_gbl_mutex_info[i].mutex        = NULL;
+		acpi_gbl_mutex_info[i].owner_id     = ACPI_MUTEX_NOT_ACQUIRED;
+		acpi_gbl_mutex_info[i].use_count    = 0;
 	}
 
-	/* Mutex locked flags */
+	/* GPE support */
 
-	for (i = 0; i < NUM_MTX; i++)
-	{
-		acpi_gbl_acpi_mutex_info[i].mutex   = NULL;
-		acpi_gbl_acpi_mutex_info[i].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
-		acpi_gbl_acpi_mutex_info[i].use_count = 0;
-	}
+	acpi_gbl_gpe_xrupt_list_head        = NULL;
+	acpi_gbl_gpe_fadt_blocks[0]         = NULL;
+	acpi_gbl_gpe_fadt_blocks[1]         = NULL;
 
 	/* Global notify handlers */
 
-	acpi_gbl_sys_notify.handler         = NULL;
-	acpi_gbl_drv_notify.handler         = NULL;
+	acpi_gbl_system_notify.handler      = NULL;
+	acpi_gbl_device_notify.handler      = NULL;
+	acpi_gbl_init_handler               = NULL;
 
 	/* Global "typed" ACPI table pointers */
 
@@ -675,11 +751,11 @@
 
 	acpi_gbl_global_lock_acquired       = FALSE;
 	acpi_gbl_global_lock_thread_count   = 0;
+	acpi_gbl_global_lock_handle         = 0;
 
 	/* Miscellaneous variables */
 
-	acpi_gbl_system_flags               = 0;
-	acpi_gbl_startup_flags              = 0;
+	acpi_gbl_table_flags                = ACPI_PHYSICAL_POINTER;
 	acpi_gbl_rsdp_original_location     = 0;
 	acpi_gbl_cm_single_step             = FALSE;
 	acpi_gbl_db_terminate_threads       = FALSE;
@@ -687,33 +763,30 @@
 	acpi_gbl_ns_lookup_count            = 0;
 	acpi_gbl_ps_find_count              = 0;
 	acpi_gbl_acpi_hardware_present      = TRUE;
-	acpi_gbl_next_table_owner_id        = FIRST_TABLE_ID;
-	acpi_gbl_next_method_owner_id       = FIRST_METHOD_ID;
+	acpi_gbl_next_table_owner_id        = ACPI_FIRST_TABLE_ID;
+	acpi_gbl_next_method_owner_id       = ACPI_FIRST_METHOD_ID;
 	acpi_gbl_debugger_configuration     = DEBUGGER_THREADING;
+	acpi_gbl_db_output_flags            = ACPI_DB_CONSOLE_OUTPUT;
 
 	/* Hardware oriented */
 
-	acpi_gbl_gpe0enable_register_save   = NULL;
-	acpi_gbl_gpe1_enable_register_save  = NULL;
-	acpi_gbl_original_mode              = SYS_MODE_UNKNOWN;   /*  original ACPI/legacy mode   */
-	acpi_gbl_gpe_registers              = NULL;
-	acpi_gbl_gpe_info                   = NULL;
+	acpi_gbl_events_initialized         = FALSE;
 
 	/* Namespace */
 
 	acpi_gbl_root_node                  = NULL;
 
-	acpi_gbl_root_node_struct.name      = ACPI_ROOT_NAME;
-	acpi_gbl_root_node_struct.data_type = ACPI_DESC_TYPE_NAMED;
-	acpi_gbl_root_node_struct.type      = ACPI_TYPE_ANY;
+	acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
+	acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED;
+	acpi_gbl_root_node_struct.type      = ACPI_TYPE_DEVICE;
 	acpi_gbl_root_node_struct.child     = NULL;
 	acpi_gbl_root_node_struct.peer      = NULL;
 	acpi_gbl_root_node_struct.object    = NULL;
 	acpi_gbl_root_node_struct.flags     = ANOBJ_END_OF_PEER_LIST;
 
 
-#ifdef ACPI_DEBUG
-	acpi_gbl_lowest_stack_pointer       = ACPI_UINT32_MAX;
+#ifdef ACPI_DEBUG_OUTPUT
+	acpi_gbl_lowest_stack_pointer       = ACPI_SIZE_MAX;
 #endif
 
 	return_VOID;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/utilities/utinit.c linux-2.4.22-pre2/drivers/acpi/utilities/utinit.c
--- linux-2.4.21/drivers/acpi/utilities/utinit.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/utilities/utinit.c	2003-06-26 21:43:28.000000000 +0000
@@ -1,52 +1,63 @@
 /******************************************************************************
  *
  * Module Name: utinit - Common ACPI subsystem initialization
- *              $Revision: 102 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "achware.h"
-#include "acnamesp.h"
-#include "acevents.h"
-#include "acparser.h"
-#include "acdispat.h"
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acevents.h>
 
 #define _COMPONENT          ACPI_UTILITIES
-	 MODULE_NAME         ("utinit")
-
-
-#define ACPI_OFFSET(d,o)    ((u32) &(((d *)0)->o))
-#define ACPI_FADT_OFFSET(o) ACPI_OFFSET (FADT_DESCRIPTOR, o)
+	 ACPI_MODULE_NAME    ("utinit")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_fadt_register_error
+ * FUNCTION:    acpi_ut_fadt_register_error
  *
- * PARAMETERS:  *Register_name          - Pointer to string identifying register
+ * PARAMETERS:  *register_name          - Pointer to string identifying register
  *              Value                   - Actual register contents value
- *              Acpi_test_spec_section  - TDS section containing assertion
- *              Acpi_assertion          - Assertion number being tested
+ *              acpi_test_spec_section  - TDS section containing assertion
+ *              acpi_assertion          - Assertion number being tested
  *
  * RETURN:      AE_BAD_VALUE
  *
@@ -54,25 +65,22 @@
  *
  ******************************************************************************/
 
-static acpi_status
+static void
 acpi_ut_fadt_register_error (
-	NATIVE_CHAR             *register_name,
-	u32                     value,
-	u32                     offset)
+	char                            *register_name,
+	u32                             value,
+	acpi_size                       offset)
 {
 
-	REPORT_ERROR (
-		("Invalid FADT value %s=%lX at offset %lX FADT=%p\n",
-		register_name, value, offset, acpi_gbl_FADT));
-
-
-	return (AE_BAD_VALUE);
+	ACPI_REPORT_WARNING (
+		("Invalid FADT value %s=%X at offset %X FADT=%p\n",
+		register_name, value, (u32) offset, acpi_gbl_FADT));
 }
 
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_ut_validate_fadt
+ * FUNCTION:    acpi_ut_validate_fadt
  *
  * PARAMETERS:  None
  *
@@ -86,101 +94,114 @@
 acpi_ut_validate_fadt (
 	void)
 {
-	acpi_status                 status = AE_OK;
-
 
 	/*
 	 * Verify Fixed ACPI Description Table fields,
 	 * but don't abort on any problems, just display error
 	 */
 	if (acpi_gbl_FADT->pm1_evt_len < 4) {
-		status = acpi_ut_fadt_register_error ("PM1_EVT_LEN",
+		acpi_ut_fadt_register_error ("PM1_EVT_LEN",
 				  (u32) acpi_gbl_FADT->pm1_evt_len,
 				  ACPI_FADT_OFFSET (pm1_evt_len));
 	}
 
 	if (!acpi_gbl_FADT->pm1_cnt_len) {
-		status = acpi_ut_fadt_register_error ("PM1_CNT_LEN", 0,
+		acpi_ut_fadt_register_error ("PM1_CNT_LEN", 0,
 				  ACPI_FADT_OFFSET (pm1_cnt_len));
 	}
 
-	if (!ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xpm1a_evt_blk.address)) {
-		status = acpi_ut_fadt_register_error ("X_PM1a_EVT_BLK", 0,
-				  ACPI_FADT_OFFSET (Xpm1a_evt_blk.address));
+	if (!acpi_gbl_FADT->xpm1a_evt_blk.address) {
+		acpi_ut_fadt_register_error ("X_PM1a_EVT_BLK", 0,
+				  ACPI_FADT_OFFSET (xpm1a_evt_blk.address));
 	}
 
-	if (!ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xpm1a_cnt_blk.address)) {
-		status = acpi_ut_fadt_register_error ("X_PM1a_CNT_BLK", 0,
-				  ACPI_FADT_OFFSET (Xpm1a_cnt_blk.address));
+	if (!acpi_gbl_FADT->xpm1a_cnt_blk.address) {
+		acpi_ut_fadt_register_error ("X_PM1a_CNT_BLK", 0,
+				  ACPI_FADT_OFFSET (xpm1a_cnt_blk.address));
 	}
 
-	if (!ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xpm_tmr_blk.address)) {
-		status = acpi_ut_fadt_register_error ("X_PM_TMR_BLK", 0,
-				  ACPI_FADT_OFFSET (Xpm_tmr_blk.address));
+	if (!acpi_gbl_FADT->xpm_tmr_blk.address) {
+		acpi_ut_fadt_register_error ("X_PM_TMR_BLK", 0,
+				  ACPI_FADT_OFFSET (xpm_tmr_blk.address));
 	}
 
-	if ((ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xpm2_cnt_blk.address) &&
+	if ((acpi_gbl_FADT->xpm2_cnt_blk.address &&
 		!acpi_gbl_FADT->pm2_cnt_len)) {
-		status = acpi_ut_fadt_register_error ("PM2_CNT_LEN",
+		acpi_ut_fadt_register_error ("PM2_CNT_LEN",
 				  (u32) acpi_gbl_FADT->pm2_cnt_len,
 				  ACPI_FADT_OFFSET (pm2_cnt_len));
 	}
 
 	if (acpi_gbl_FADT->pm_tm_len < 4) {
-		status = acpi_ut_fadt_register_error ("PM_TM_LEN",
+		acpi_ut_fadt_register_error ("PM_TM_LEN",
 				  (u32) acpi_gbl_FADT->pm_tm_len,
 				  ACPI_FADT_OFFSET (pm_tm_len));
 	}
 
-	/* length of GPE blocks must be a multiple of 2 */
+	/* Length of GPE blocks must be a multiple of 2 */
 
-	if (ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xgpe0blk.address) &&
-		(acpi_gbl_FADT->gpe0blk_len & 1)) {
-		status = acpi_ut_fadt_register_error ("(x)GPE0_BLK_LEN",
-				  (u32) acpi_gbl_FADT->gpe0blk_len,
-				  ACPI_FADT_OFFSET (gpe0blk_len));
+	if (acpi_gbl_FADT->xgpe0_blk.address &&
+		(acpi_gbl_FADT->gpe0_blk_len & 1)) {
+		acpi_ut_fadt_register_error ("(x)GPE0_BLK_LEN",
+				  (u32) acpi_gbl_FADT->gpe0_blk_len,
+				  ACPI_FADT_OFFSET (gpe0_blk_len));
 	}
 
-	if (ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xgpe1_blk.address) &&
+	if (acpi_gbl_FADT->xgpe1_blk.address &&
 		(acpi_gbl_FADT->gpe1_blk_len & 1)) {
-		status = acpi_ut_fadt_register_error ("(x)GPE1_BLK_LEN",
+		acpi_ut_fadt_register_error ("(x)GPE1_BLK_LEN",
 				  (u32) acpi_gbl_FADT->gpe1_blk_len,
 				  ACPI_FADT_OFFSET (gpe1_blk_len));
 	}
 
-	return (status);
+	return (AE_OK);
 }
 
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_ut_terminate
+ * FUNCTION:    acpi_ut_terminate
  *
  * PARAMETERS:  none
  *
  * RETURN:      none
  *
- * DESCRIPTION: free memory allocated for table storage.
+ * DESCRIPTION: free global memory
  *
  ******************************************************************************/
 
 void
 acpi_ut_terminate (void)
 {
+	struct acpi_gpe_block_info      *gpe_block;
+	struct acpi_gpe_block_info      *next_gpe_block;
+	struct acpi_gpe_xrupt_info      *gpe_xrupt_info;
+	struct acpi_gpe_xrupt_info      *next_gpe_xrupt_info;
 
-	FUNCTION_TRACE ("Ut_terminate");
+
+	ACPI_FUNCTION_TRACE ("ut_terminate");
 
 
 	/* Free global tables, etc. */
 
-	if (acpi_gbl_gpe0enable_register_save) {
-		ACPI_MEM_FREE (acpi_gbl_gpe0enable_register_save);
-	}
 
-	if (acpi_gbl_gpe1_enable_register_save) {
-		ACPI_MEM_FREE (acpi_gbl_gpe1_enable_register_save);
-	}
+	/* Free global GPE blocks and related info structures */
 
+	gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
+	while (gpe_xrupt_info) {
+		gpe_block = gpe_xrupt_info->gpe_block_list_head;
+		while (gpe_block) {
+			next_gpe_block = gpe_block->next;
+			ACPI_MEM_FREE (gpe_block->event_info);
+			ACPI_MEM_FREE (gpe_block->register_info);
+			ACPI_MEM_FREE (gpe_block);
+
+			gpe_block = next_gpe_block;
+		}
+		next_gpe_xrupt_info = gpe_xrupt_info->next;
+		ACPI_MEM_FREE (gpe_xrupt_info);
+		gpe_xrupt_info = next_gpe_xrupt_info;
+	}
 
 	return_VOID;
 }
@@ -188,7 +209,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_subsystem_shutdown
+ * FUNCTION:    acpi_ut_subsystem_shutdown
  *
  * PARAMETERS:  none
  *
@@ -199,17 +220,17 @@
  *
  ******************************************************************************/
 
-acpi_status
+void
 acpi_ut_subsystem_shutdown (void)
 {
 
-	FUNCTION_TRACE ("Ut_subsystem_shutdown");
+	ACPI_FUNCTION_TRACE ("ut_subsystem_shutdown");
 
 	/* Just exit if subsystem is already shutdown */
 
 	if (acpi_gbl_shutdown) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "ACPI Subsystem is already terminated\n"));
-		return_ACPI_STATUS (AE_OK);
+		return_VOID;
 	}
 
 	/* Subsystem appears active, go ahead and shut it down */
@@ -217,30 +238,21 @@
 	acpi_gbl_shutdown = TRUE;
 	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem...\n"));
 
+	/* Close the acpi_event Handling */
+
+	acpi_ev_terminate ();
 
 	/* Close the Namespace */
 
 	acpi_ns_terminate ();
 
-	/* Close the Acpi_event Handling */
-
-	acpi_ev_terminate ();
-
 	/* Close the globals */
 
 	acpi_ut_terminate ();
 
-	/* Flush the local cache(s) */
-
-	acpi_ut_delete_generic_state_cache ();
-	acpi_ut_delete_object_cache ();
-	acpi_ds_delete_walk_state_cache ();
-
-	/* Close the Parser */
+	/* Purge the local caches */
 
-	/* TBD: [Restructure] Acpi_ps_terminate () */
-
-	acpi_ps_delete_parse_cache ();
+	(void) acpi_purge_cached_objects ();
 
 	/* Debug only - display leftover memory allocation, if any */
 
@@ -248,7 +260,7 @@
 	acpi_ut_dump_allocations (ACPI_UINT32_MAX, NULL);
 #endif
 
-	return_ACPI_STATUS (AE_OK);
+	return_VOID;
 }
 
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/utilities/utmath.c linux-2.4.22-pre2/drivers/acpi/utilities/utmath.c
--- linux-2.4.21/drivers/acpi/utilities/utmath.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/utilities/utmath.c	2003-06-26 21:43:32.000000000 +0000
@@ -1,34 +1,52 @@
 /*******************************************************************************
  *
  * Module Name: utmath - Integer math support routines
- *              $Revision: 7 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
+#include <acpi/acpi.h>
 
 
 #define _COMPONENT          ACPI_UTILITIES
-	 MODULE_NAME         ("utmath")
+	 ACPI_MODULE_NAME    ("utmath")
 
 /*
  * Support for double-precision integer divide.  This code is included here
@@ -39,12 +57,12 @@
 #ifndef ACPI_USE_NATIVE_DIVIDE
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_short_divide
+ * FUNCTION:    acpi_ut_short_divide
  *
- * PARAMETERS:  In_dividend         - Pointer to the dividend
+ * PARAMETERS:  in_dividend         - Pointer to the dividend
  *              Divisor             - 32-bit divisor
- *              Out_quotient        - Pointer to where the quotient is returned
- *              Out_remainder       - Pointer to where the remainder is returned
+ *              out_quotient        - Pointer to where the quotient is returned
+ *              out_remainder       - Pointer to where the remainder is returned
  *
  * RETURN:      Status (Checks for divide-by-zero)
  *
@@ -56,24 +74,24 @@
 
 acpi_status
 acpi_ut_short_divide (
-	acpi_integer            *in_dividend,
-	u32                     divisor,
-	acpi_integer            *out_quotient,
-	u32                     *out_remainder)
+	acpi_integer                    *in_dividend,
+	u32                             divisor,
+	acpi_integer                    *out_quotient,
+	u32                             *out_remainder)
 {
-	uint64_overlay          dividend;
-	uint64_overlay          quotient;
-	u32                     remainder32;
+	union uint64_overlay            dividend;
+	union uint64_overlay            quotient;
+	u32                             remainder32;
 
 
-	FUNCTION_TRACE ("Ut_short_divide");
+	ACPI_FUNCTION_TRACE ("ut_short_divide");
 
 	dividend.full = *in_dividend;
 
 	/* Always check for a zero divisor */
 
 	if (divisor == 0) {
-		REPORT_ERROR (("Acpi_ut_short_divide: Divide by zero\n"));
+		ACPI_REPORT_ERROR (("acpi_ut_short_divide: Divide by zero\n"));
 		return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
 	}
 
@@ -101,12 +119,12 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_divide
+ * FUNCTION:    acpi_ut_divide
  *
- * PARAMETERS:  In_dividend         - Pointer to the dividend
- *              In_divisor          - Pointer to the divisor
- *              Out_quotient        - Pointer to where the quotient is returned
- *              Out_remainder       - Pointer to where the remainder is returned
+ * PARAMETERS:  in_dividend         - Pointer to the dividend
+ *              in_divisor          - Pointer to the divisor
+ *              out_quotient        - Pointer to where the quotient is returned
+ *              out_remainder       - Pointer to where the remainder is returned
  *
  * RETURN:      Status (Checks for divide-by-zero)
  *
@@ -116,29 +134,29 @@
 
 acpi_status
 acpi_ut_divide (
-	acpi_integer            *in_dividend,
-	acpi_integer            *in_divisor,
-	acpi_integer            *out_quotient,
-	acpi_integer            *out_remainder)
+	acpi_integer                    *in_dividend,
+	acpi_integer                    *in_divisor,
+	acpi_integer                    *out_quotient,
+	acpi_integer                    *out_remainder)
 {
-	uint64_overlay          dividend;
-	uint64_overlay          divisor;
-	uint64_overlay          quotient;
-	uint64_overlay          remainder;
-	uint64_overlay          normalized_dividend;
-	uint64_overlay          normalized_divisor;
-	u32                     partial1;
-	uint64_overlay          partial2;
-	uint64_overlay          partial3;
+	union uint64_overlay            dividend;
+	union uint64_overlay            divisor;
+	union uint64_overlay            quotient;
+	union uint64_overlay            remainder;
+	union uint64_overlay            normalized_dividend;
+	union uint64_overlay            normalized_divisor;
+	u32                             partial1;
+	union uint64_overlay            partial2;
+	union uint64_overlay            partial3;
 
 
-	FUNCTION_TRACE ("Ut_divide");
+	ACPI_FUNCTION_TRACE ("ut_divide");
 
 
 	/* Always check for a zero divisor */
 
 	if (*in_divisor == 0) {
-		REPORT_ERROR (("Acpi_ut_divide: Divide by zero\n"));
+		ACPI_REPORT_ERROR (("acpi_ut_divide: Divide by zero\n"));
 		return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
 	}
 
@@ -193,7 +211,7 @@
 		 */
 		partial1      = quotient.part.lo * divisor.part.hi;
 		partial2.full = (acpi_integer) quotient.part.lo * divisor.part.lo;
-		partial3.full = partial2.part.hi + partial1;
+		partial3.full = (acpi_integer) partial2.part.hi + partial1;
 
 		remainder.part.hi = partial3.part.lo;
 		remainder.part.lo = partial2.part.lo;
@@ -213,8 +231,8 @@
 			}
 
 			remainder.full    = remainder.full - dividend.full;
-			remainder.part.hi = -((s32) remainder.part.hi);
-			remainder.part.lo = -((s32) remainder.part.lo);
+			remainder.part.hi = (u32) -((s32) remainder.part.hi);
+			remainder.part.lo = (u32) -((s32) remainder.part.lo);
 
 			if (remainder.part.lo) {
 				remainder.part.hi--;
@@ -238,9 +256,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_short_divide, Acpi_ut_divide
+ * FUNCTION:    acpi_ut_short_divide, acpi_ut_divide
  *
- * DESCRIPTION: Native versions of the Ut_divide functions. Use these if either
+ * DESCRIPTION: Native versions of the ut_divide functions. Use these if either
  *              1) The target is a 64-bit platform and therefore 64-bit
  *                 integer math is supported directly by the machine.
  *              2) The target is a 32-bit or 16-bit platform, and the
@@ -251,19 +269,19 @@
 
 acpi_status
 acpi_ut_short_divide (
-	acpi_integer            *in_dividend,
-	u32                     divisor,
-	acpi_integer            *out_quotient,
-	u32                     *out_remainder)
+	acpi_integer                    *in_dividend,
+	u32                             divisor,
+	acpi_integer                    *out_quotient,
+	u32                             *out_remainder)
 {
 
-	FUNCTION_TRACE ("Ut_short_divide");
+	ACPI_FUNCTION_TRACE ("ut_short_divide");
 
 
 	/* Always check for a zero divisor */
 
 	if (divisor == 0) {
-		REPORT_ERROR (("Acpi_ut_short_divide: Divide by zero\n"));
+		ACPI_REPORT_ERROR (("acpi_ut_short_divide: Divide by zero\n"));
 		return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
 	}
 
@@ -281,18 +299,18 @@
 
 acpi_status
 acpi_ut_divide (
-	acpi_integer            *in_dividend,
-	acpi_integer            *in_divisor,
-	acpi_integer            *out_quotient,
-	acpi_integer            *out_remainder)
+	acpi_integer                    *in_dividend,
+	acpi_integer                    *in_divisor,
+	acpi_integer                    *out_quotient,
+	acpi_integer                    *out_remainder)
 {
-	FUNCTION_TRACE ("Ut_divide");
+	ACPI_FUNCTION_TRACE ("ut_divide");
 
 
 	/* Always check for a zero divisor */
 
 	if (*in_divisor == 0) {
-		REPORT_ERROR (("Acpi_ut_divide: Divide by zero\n"));
+		ACPI_REPORT_ERROR (("acpi_ut_divide: Divide by zero\n"));
 		return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
 	}
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/utilities/utmisc.c linux-2.4.22-pre2/drivers/acpi/utilities/utmisc.c
--- linux-2.4.21/drivers/acpi/utilities/utmisc.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/utilities/utmisc.c	2003-06-26 21:43:11.000000000 +0000
@@ -1,45 +1,292 @@
 /*******************************************************************************
  *
  * Module Name: utmisc - common utility procedures
- *              $Revision: 52 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acevents.h"
-#include "achware.h"
-#include "acnamesp.h"
-#include "acinterp.h"
-#include "amlcode.h"
-#include "acdebug.h"
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
 
 
 #define _COMPONENT          ACPI_UTILITIES
-	 MODULE_NAME         ("utmisc")
+	 ACPI_MODULE_NAME    ("utmisc")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_valid_acpi_name
+ * FUNCTION:    acpi_ut_print_string
+ *
+ * PARAMETERS:  String          - Null terminated ASCII string
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape
+ *              sequences.
+ *
+ ******************************************************************************/
+
+void
+acpi_ut_print_string (
+	char                            *string,
+	u8                              max_length)
+{
+	u32                             i;
+
+
+	if (!string) {
+		acpi_os_printf ("<\"NULL STRING PTR\">");
+		return;
+	}
+
+	acpi_os_printf ("\"");
+	for (i = 0; string[i] && (i < max_length); i++) {
+		/* Escape sequences */
+
+		switch (string[i]) {
+		case 0x07:
+			acpi_os_printf ("\\a");      /* BELL */
+			break;
+
+		case 0x08:
+			acpi_os_printf ("\\b");     /* BACKSPACE */
+			break;
+
+		case 0x0C:
+			acpi_os_printf ("\\f");     /* FORMFEED */
+			break;
+
+		case 0x0A:
+			acpi_os_printf ("\\n");     /* LINEFEED */
+			break;
+
+		case 0x0D:
+			acpi_os_printf ("\\r");     /* CARRIAGE RETURN*/
+			break;
+
+		case 0x09:
+			acpi_os_printf ("\\t");     /* HORIZONTAL TAB */
+			break;
+
+		case 0x0B:
+			acpi_os_printf ("\\v");     /* VERTICAL TAB */
+			break;
+
+		case '\'':                      /* Single Quote */
+		case '\"':                      /* Double Quote */
+		case '\\':                      /* Backslash */
+			acpi_os_printf ("\\%c", (int) string[i]);
+			break;
+
+		default:
+
+			/* Check for printable character or hex escape */
+
+			if (ACPI_IS_PRINT (string[i]))
+			{
+				/* This is a normal character */
+
+				acpi_os_printf ("%c", (int) string[i]);
+			}
+			else
+			{
+				/* All others will be Hex escapes */
+
+				acpi_os_printf ("\\x%2.2X", (s32) string[i]);
+			}
+			break;
+		}
+	}
+	acpi_os_printf ("\"");
+
+	if (i == max_length && string[i]) {
+		acpi_os_printf ("...");
+	}
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_dword_byte_swap
+ *
+ * PARAMETERS:  Value           - Value to be converted
+ *
+ * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
+ *
+ ******************************************************************************/
+
+u32
+acpi_ut_dword_byte_swap (
+	u32                             value)
+{
+	union {
+		u32                         value;
+		u8                          bytes[4];
+	} out;
+
+	union {
+		u32                         value;
+		u8                          bytes[4];
+	} in;
+
+
+	ACPI_FUNCTION_ENTRY ();
+
+
+	in.value = value;
+
+	out.bytes[0] = in.bytes[3];
+	out.bytes[1] = in.bytes[2];
+	out.bytes[2] = in.bytes[1];
+	out.bytes[3] = in.bytes[0];
+
+	return (out.value);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_set_integer_width
+ *
+ * PARAMETERS:  Revision            From DSDT header
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Set the global integer bit width based upon the revision
+ *              of the DSDT.  For Revision 1 and 0, Integers are 32 bits.
+ *              For Revision 2 and above, Integers are 64 bits.  Yes, this
+ *              makes a difference.
+ *
+ ******************************************************************************/
+
+void
+acpi_ut_set_integer_width (
+	u8                              revision)
+{
+
+	if (revision <= 1) {
+		acpi_gbl_integer_bit_width = 32;
+		acpi_gbl_integer_nybble_width = 8;
+		acpi_gbl_integer_byte_width = 4;
+	}
+	else {
+		acpi_gbl_integer_bit_width = 64;
+		acpi_gbl_integer_nybble_width = 16;
+		acpi_gbl_integer_byte_width = 8;
+	}
+}
+
+
+#ifdef ACPI_DEBUG_OUTPUT
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_display_init_pathname
+ *
+ * PARAMETERS:  obj_handle          - Handle whose pathname will be displayed
+ *              Path                - Additional path string to be appended.
+ *                                      (NULL if no extra path)
+ *
+ * RETURN:      acpi_status
+ *
+ * DESCRIPTION: Display full pathname of an object, DEBUG ONLY
+ *
+ ******************************************************************************/
+
+void
+acpi_ut_display_init_pathname (
+	u8                              type,
+	struct acpi_namespace_node      *obj_handle,
+	char                            *path)
+{
+	acpi_status                     status;
+	struct acpi_buffer              buffer;
+
+
+	ACPI_FUNCTION_ENTRY ();
+
+
+	/* Only print the path if the appropriate debug level is enabled */
+
+	if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
+		return;
+	}
+
+	/* Get the full pathname to the node */
+
+	buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
+	status = acpi_ns_handle_to_pathname (obj_handle, &buffer);
+	if (ACPI_FAILURE (status)) {
+		return;
+	}
+
+	/* Print what we're doing */
+
+	switch (type) {
+	case ACPI_TYPE_METHOD:
+		acpi_os_printf ("Executing  ");
+		break;
+
+	default:
+		acpi_os_printf ("Initializing ");
+		break;
+	}
+
+	/* Print the object type and pathname */
+
+	acpi_os_printf ("%-12s %s", acpi_ut_get_type_name (type), (char *) buffer.pointer);
+
+	/* Extra path is used to append names like _STA, _INI, etc. */
+
+	if (path) {
+		acpi_os_printf (".%s", path);
+	}
+	acpi_os_printf ("\n");
+
+	ACPI_MEM_FREE (buffer.pointer);
+}
+#endif
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_valid_acpi_name
  *
  * PARAMETERS:  Character           - The character to be examined
  *
@@ -54,13 +301,13 @@
 
 u8
 acpi_ut_valid_acpi_name (
-	u32                     name)
+	u32                             name)
 {
-	NATIVE_CHAR             *name_ptr = (NATIVE_CHAR *) &name;
-	u32                     i;
+	char                            *name_ptr = (char *) &name;
+	u32                             i;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	for (i = 0; i < ACPI_NAME_SIZE; i++) {
@@ -77,7 +324,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_valid_acpi_character
+ * FUNCTION:    acpi_ut_valid_acpi_character
  *
  * PARAMETERS:  Character           - The character to be examined
  *
@@ -89,10 +336,10 @@
 
 u8
 acpi_ut_valid_acpi_character (
-	NATIVE_CHAR             character)
+	char                            character)
 {
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 	return ((u8)   ((character == '_') ||
 			   (character >= 'A' && character <= 'Z') ||
@@ -102,40 +349,185 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_strupr
+ * FUNCTION:    acpi_ut_strtoul64
+ *
+ * PARAMETERS:  String          - Null terminated string
+ *              Terminater      - Where a pointer to the terminating byte is returned
+ *              Base            - Radix of the string
+ *
+ * RETURN:      Converted value
+ *
+ * DESCRIPTION: Convert a string into an unsigned value.
+ *
+ ******************************************************************************/
+#define NEGATIVE    1
+#define POSITIVE    0
+
+acpi_status
+acpi_ut_strtoul64 (
+	char                            *string,
+	u32                             base,
+	acpi_integer                    *ret_integer)
+{
+	u32                             index;
+	acpi_integer                    return_value = 0;
+	acpi_status                     status = AE_OK;
+	acpi_integer                    dividend;
+	acpi_integer                    quotient;
+
+
+	*ret_integer = 0;
+
+	switch (base) {
+	case 0:
+	case 8:
+	case 10:
+	case 16:
+		break;
+
+	default:
+		/*
+		 * The specified Base parameter is not in the domain of
+		 * this function:
+		 */
+		return (AE_BAD_PARAMETER);
+	}
+
+	/*
+	 * 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:
+	 */
+	if (base == 0) {
+		if (*string == '0') {
+			if (ACPI_TOLOWER (*(++string)) == 'x') {
+				base = 16;
+				++string;
+			}
+			else {
+				base = 8;
+			}
+		}
+		else {
+			base = 10;
+		}
+	}
+
+	/*
+	 * For octal and hexadecimal bases, skip over the leading
+	 * 0 or 0x, if they are present.
+	 */
+	if (base == 8 && *string == '0') {
+		string++;
+	}
+
+	if (base == 16 &&
+		*string == '0' &&
+		ACPI_TOLOWER (*(++string)) == 'x') {
+		string++;
+	}
+
+	/* Main loop: convert the string to an unsigned long */
+
+	while (*string) {
+		if (ACPI_IS_DIGIT (*string)) {
+			index = ((u8) *string) - '0';
+		}
+		else {
+			index = (u8) ACPI_TOUPPER (*string);
+			if (ACPI_IS_UPPER ((char) index)) {
+				index = index - 'A' + 10;
+			}
+			else {
+				goto error_exit;
+			}
+		}
+
+		if (index >= base) {
+			goto error_exit;
+		}
+
+		/* Check to see if value is out of range: */
+
+		dividend = ACPI_INTEGER_MAX - (acpi_integer) index;
+		(void) acpi_ut_short_divide (&dividend, base, &quotient, NULL);
+		if (return_value > quotient) {
+			goto error_exit;
+		}
+
+		return_value *= base;
+		return_value += index;
+		++string;
+	}
+
+	*ret_integer = return_value;
+	return (status);
+
+
+error_exit:
+	switch (base) {
+	case 8:
+		status = AE_BAD_OCTAL_CONSTANT;
+		break;
+
+	case 10:
+		status = AE_BAD_DECIMAL_CONSTANT;
+		break;
+
+	case 16:
+		status = AE_BAD_HEX_CONSTANT;
+		break;
+
+	default:
+		/* Base validated above */
+		break;
+	}
+
+	return (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_strupr
  *
- * PARAMETERS:  Src_string      - The source string to convert to
+ * PARAMETERS:  src_string      - The source string to convert to
  *
- * RETURN:      Src_string
+ * RETURN:      src_string
  *
  * DESCRIPTION: Convert string to uppercase
  *
  ******************************************************************************/
 
-NATIVE_CHAR *
+char *
 acpi_ut_strupr (
-	NATIVE_CHAR             *src_string)
+	char                            *src_string)
 {
-	NATIVE_CHAR             *string;
+	char                            *string;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/* Walk entire string, uppercasing the letters */
 
 	for (string = src_string; *string; ) {
-		*string = (char) TOUPPER (*string);
+		*string = (char) ACPI_TOUPPER (*string);
 		string++;
 	}
 
-
 	return (src_string);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_mutex_initialize
+ * FUNCTION:    acpi_ut_mutex_initialize
  *
  * PARAMETERS:  None.
  *
@@ -149,30 +541,33 @@
 acpi_ut_mutex_initialize (
 	void)
 {
-	u32                     i;
-	acpi_status             status;
+	u32                             i;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Ut_mutex_initialize");
+	ACPI_FUNCTION_TRACE ("ut_mutex_initialize");
 
 
 	/*
 	 * Create each of the predefined mutex objects
 	 */
-	for (i = 0; i < NUM_MTX; i++) {
+	for (i = 0; i < NUM_MUTEX; i++) {
 		status = acpi_ut_create_mutex (i);
 		if (ACPI_FAILURE (status)) {
 			return_ACPI_STATUS (status);
 		}
 	}
 
+
+	status = acpi_os_create_lock (&acpi_gbl_gpe_lock);
+
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_mutex_terminate
+ * FUNCTION:    acpi_ut_mutex_terminate
  *
  * PARAMETERS:  None.
  *
@@ -186,28 +581,29 @@
 acpi_ut_mutex_terminate (
 	void)
 {
-	u32                     i;
+	u32                             i;
 
 
-	FUNCTION_TRACE ("Ut_mutex_terminate");
+	ACPI_FUNCTION_TRACE ("ut_mutex_terminate");
 
 
 	/*
 	 * Delete each predefined mutex object
 	 */
-	for (i = 0; i < NUM_MTX; i++) {
-		acpi_ut_delete_mutex (i);
+	for (i = 0; i < NUM_MUTEX; i++) {
+		(void) acpi_ut_delete_mutex (i);
 	}
 
+	acpi_os_delete_lock (acpi_gbl_gpe_lock);
 	return_VOID;
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_create_mutex
+ * FUNCTION:    acpi_ut_create_mutex
  *
- * PARAMETERS:  Mutex_iD        - ID of the mutex to be created
+ * PARAMETERS:  mutex_iD        - ID of the mutex to be created
  *
  * RETURN:      Status
  *
@@ -217,24 +613,23 @@
 
 acpi_status
 acpi_ut_create_mutex (
-	ACPI_MUTEX_HANDLE       mutex_id)
+	acpi_mutex_handle               mutex_id)
 {
-	acpi_status             status = AE_OK;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE_U32 ("Ut_create_mutex", mutex_id);
+	ACPI_FUNCTION_TRACE_U32 ("ut_create_mutex", mutex_id);
 
 
-	if (mutex_id > MAX_MTX) {
+	if (mutex_id > MAX_MUTEX) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-
-	if (!acpi_gbl_acpi_mutex_info[mutex_id].mutex) {
+	if (!acpi_gbl_mutex_info[mutex_id].mutex) {
 		status = acpi_os_create_semaphore (1, 1,
-				  &acpi_gbl_acpi_mutex_info[mutex_id].mutex);
-		acpi_gbl_acpi_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
-		acpi_gbl_acpi_mutex_info[mutex_id].use_count = 0;
+				  &acpi_gbl_mutex_info[mutex_id].mutex);
+		acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
+		acpi_gbl_mutex_info[mutex_id].use_count = 0;
 	}
 
 	return_ACPI_STATUS (status);
@@ -243,9 +638,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_delete_mutex
+ * FUNCTION:    acpi_ut_delete_mutex
  *
- * PARAMETERS:  Mutex_iD        - ID of the mutex to be deleted
+ * PARAMETERS:  mutex_iD        - ID of the mutex to be deleted
  *
  * RETURN:      Status
  *
@@ -255,23 +650,22 @@
 
 acpi_status
 acpi_ut_delete_mutex (
-	ACPI_MUTEX_HANDLE       mutex_id)
+	acpi_mutex_handle               mutex_id)
 {
-	acpi_status             status;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE_U32 ("Ut_delete_mutex", mutex_id);
+	ACPI_FUNCTION_TRACE_U32 ("ut_delete_mutex", mutex_id);
 
 
-	if (mutex_id > MAX_MTX) {
+	if (mutex_id > MAX_MUTEX) {
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
+	status = acpi_os_delete_semaphore (acpi_gbl_mutex_info[mutex_id].mutex);
 
-	status = acpi_os_delete_semaphore (acpi_gbl_acpi_mutex_info[mutex_id].mutex);
-
-	acpi_gbl_acpi_mutex_info[mutex_id].mutex = NULL;
-	acpi_gbl_acpi_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
+	acpi_gbl_mutex_info[mutex_id].mutex = NULL;
+	acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
 
 	return_ACPI_STATUS (status);
 }
@@ -279,9 +673,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_acquire_mutex
+ * FUNCTION:    acpi_ut_acquire_mutex
  *
- * PARAMETERS:  Mutex_iD        - ID of the mutex to be acquired
+ * PARAMETERS:  mutex_iD        - ID of the mutex to be acquired
  *
  * RETURN:      Status
  *
@@ -291,21 +685,20 @@
 
 acpi_status
 acpi_ut_acquire_mutex (
-	ACPI_MUTEX_HANDLE       mutex_id)
+	acpi_mutex_handle               mutex_id)
 {
-	acpi_status             status;
-	u32                     i;
-	u32                     this_thread_id;
+	acpi_status                     status;
+	u32                             i;
+	u32                             this_thread_id;
 
 
-	PROC_NAME ("Ut_acquire_mutex");
+	ACPI_FUNCTION_NAME ("ut_acquire_mutex");
 
 
-	if (mutex_id > MAX_MTX) {
+	if (mutex_id > MAX_MUTEX) {
 		return (AE_BAD_PARAMETER);
 	}
 
-
 	this_thread_id = acpi_os_get_thread_id ();
 
 	/*
@@ -314,8 +707,8 @@
 	 * the mutex ordering rule.  This indicates a coding error somewhere in
 	 * the ACPI subsystem code.
 	 */
-	for (i = mutex_id; i < MAX_MTX; i++) {
-		if (acpi_gbl_acpi_mutex_info[i].owner_id == this_thread_id) {
+	for (i = mutex_id; i < MAX_MUTEX; i++) {
+		if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
 			if (i == mutex_id) {
 				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 						"Mutex [%s] already acquired by this thread [%X]\n",
@@ -333,22 +726,19 @@
 		}
 	}
 
-
 	ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
 			 "Thread %X attempting to acquire Mutex [%s]\n",
 			 this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
 
-	status = acpi_os_wait_semaphore (acpi_gbl_acpi_mutex_info[mutex_id].mutex,
-			   1, WAIT_FOREVER);
-
+	status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex,
+			   1, ACPI_WAIT_FOREVER);
 	if (ACPI_SUCCESS (status)) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n",
 				 this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
 
-		acpi_gbl_acpi_mutex_info[mutex_id].use_count++;
-		acpi_gbl_acpi_mutex_info[mutex_id].owner_id = this_thread_id;
+		acpi_gbl_mutex_info[mutex_id].use_count++;
+		acpi_gbl_mutex_info[mutex_id].owner_id = this_thread_id;
 	}
-
 	else {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Thread %X could not acquire Mutex [%s] %s\n",
 				 this_thread_id, acpi_ut_get_mutex_name (mutex_id),
@@ -361,9 +751,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_release_mutex
+ * FUNCTION:    acpi_ut_release_mutex
  *
- * PARAMETERS:  Mutex_iD        - ID of the mutex to be released
+ * PARAMETERS:  mutex_iD        - ID of the mutex to be released
  *
  * RETURN:      Status
  *
@@ -373,14 +763,14 @@
 
 acpi_status
 acpi_ut_release_mutex (
-	ACPI_MUTEX_HANDLE       mutex_id)
+	acpi_mutex_handle               mutex_id)
 {
-	acpi_status             status;
-	u32                     i;
-	u32                     this_thread_id;
+	acpi_status                     status;
+	u32                             i;
+	u32                             this_thread_id;
 
 
-	PROC_NAME ("Ut_release_mutex");
+	ACPI_FUNCTION_NAME ("ut_release_mutex");
 
 
 	this_thread_id = acpi_os_get_thread_id ();
@@ -388,15 +778,14 @@
 		"Thread %X releasing Mutex [%s]\n", this_thread_id,
 		acpi_ut_get_mutex_name (mutex_id)));
 
-	if (mutex_id > MAX_MTX) {
+	if (mutex_id > MAX_MUTEX) {
 		return (AE_BAD_PARAMETER);
 	}
 
-
 	/*
 	 * Mutex must be acquired in order to release it!
 	 */
-	if (acpi_gbl_acpi_mutex_info[mutex_id].owner_id == ACPI_MUTEX_NOT_ACQUIRED) {
+	if (acpi_gbl_mutex_info[mutex_id].owner_id == ACPI_MUTEX_NOT_ACQUIRED) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 				"Mutex [%s] is not acquired, cannot release\n",
 				acpi_ut_get_mutex_name (mutex_id)));
@@ -404,15 +793,14 @@
 		return (AE_NOT_ACQUIRED);
 	}
 
-
 	/*
 	 * Deadlock prevention.  Check if this thread owns any mutexes of value
 	 * greater than this one.  If so, the thread has violated the mutex
 	 * ordering rule.  This indicates a coding error somewhere in
 	 * the ACPI subsystem code.
 	 */
-	for (i = mutex_id; i < MAX_MTX; i++) {
-		if (acpi_gbl_acpi_mutex_info[i].owner_id == this_thread_id) {
+	for (i = mutex_id; i < MAX_MUTEX; i++) {
+		if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
 			if (i == mutex_id) {
 				continue;
 			}
@@ -425,12 +813,11 @@
 		}
 	}
 
-
 	/* Mark unlocked FIRST */
 
-	acpi_gbl_acpi_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
+	acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
 
-	status = acpi_os_signal_semaphore (acpi_gbl_acpi_mutex_info[mutex_id].mutex, 1);
+	status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1);
 
 	if (ACPI_FAILURE (status)) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Thread %X could not release Mutex [%s] %s\n",
@@ -448,11 +835,11 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_create_update_state_and_push
+ * FUNCTION:    acpi_ut_create_update_state_and_push
  *
  * PARAMETERS:  *Object         - Object to be added to the new state
  *              Action          - Increment/Decrement
- *              State_list      - List the state will be added to
+ *              state_list      - List the state will be added to
  *
  * RETURN:      None
  *
@@ -462,14 +849,14 @@
 
 acpi_status
 acpi_ut_create_update_state_and_push (
-	acpi_operand_object     *object,
-	u16                     action,
-	acpi_generic_state      **state_list)
+	union acpi_operand_object       *object,
+	u16                             action,
+	union acpi_generic_state        **state_list)
 {
-	acpi_generic_state       *state;
+	union acpi_generic_state         *state;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/* Ignore null objects; these are expected */
@@ -483,7 +870,6 @@
 		return (AE_NO_MEMORY);
 	}
 
-
 	acpi_ut_push_generic_state (state_list, state);
 	return (AE_OK);
 }
@@ -491,11 +877,11 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_create_pkg_state_and_push
+ * FUNCTION:    acpi_ut_create_pkg_state_and_push
  *
  * PARAMETERS:  *Object         - Object to be added to the new state
  *              Action          - Increment/Decrement
- *              State_list      - List the state will be added to
+ *              state_list      - List the state will be added to
  *
  * RETURN:      None
  *
@@ -505,15 +891,15 @@
 
 acpi_status
 acpi_ut_create_pkg_state_and_push (
-	void                    *internal_object,
-	void                    *external_object,
-	u16                     index,
-	acpi_generic_state      **state_list)
+	void                            *internal_object,
+	void                            *external_object,
+	u16                             index,
+	union acpi_generic_state        **state_list)
 {
-	acpi_generic_state       *state;
+	union acpi_generic_state         *state;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	state = acpi_ut_create_pkg_state (internal_object, external_object, index);
@@ -521,7 +907,6 @@
 		return (AE_NO_MEMORY);
 	}
 
-
 	acpi_ut_push_generic_state (state_list, state);
 	return (AE_OK);
 }
@@ -529,9 +914,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_push_generic_state
+ * FUNCTION:    acpi_ut_push_generic_state
  *
- * PARAMETERS:  List_head           - Head of the state stack
+ * PARAMETERS:  list_head           - Head of the state stack
  *              State               - State object to push
  *
  * RETURN:      Status
@@ -542,10 +927,10 @@
 
 void
 acpi_ut_push_generic_state (
-	acpi_generic_state      **list_head,
-	acpi_generic_state      *state)
+	union acpi_generic_state        **list_head,
+	union acpi_generic_state        *state)
 {
-	FUNCTION_TRACE ("Ut_push_generic_state");
+	ACPI_FUNCTION_TRACE ("ut_push_generic_state");
 
 
 	/* Push the state object onto the front of the list (stack) */
@@ -559,9 +944,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_pop_generic_state
+ * FUNCTION:    acpi_ut_pop_generic_state
  *
- * PARAMETERS:  List_head           - Head of the state stack
+ * PARAMETERS:  list_head           - Head of the state stack
  *
  * RETURN:      Status
  *
@@ -569,14 +954,14 @@
  *
  ******************************************************************************/
 
-acpi_generic_state *
+union acpi_generic_state *
 acpi_ut_pop_generic_state (
-	acpi_generic_state      **list_head)
+	union acpi_generic_state        **list_head)
 {
-	acpi_generic_state      *state;
+	union acpi_generic_state        *state;
 
 
-	FUNCTION_TRACE ("Ut_pop_generic_state");
+	ACPI_FUNCTION_TRACE ("ut_pop_generic_state");
 
 
 	/* Remove the state object at the head of the list (stack) */
@@ -594,7 +979,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_create_generic_state
+ * FUNCTION:    acpi_ut_create_generic_state
  *
  * PARAMETERS:  None
  *
@@ -605,13 +990,13 @@
  *
  ******************************************************************************/
 
-acpi_generic_state *
+union acpi_generic_state *
 acpi_ut_create_generic_state (void)
 {
-	acpi_generic_state      *state;
+	union acpi_generic_state        *state;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	state = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_STATE);
@@ -628,7 +1013,46 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_create_update_state
+ * FUNCTION:    acpi_ut_create_thread_state
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Thread State
+ *
+ * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used
+ *              to track per-thread info during method execution
+ *
+ ******************************************************************************/
+
+struct acpi_thread_state *
+acpi_ut_create_thread_state (
+	void)
+{
+	union acpi_generic_state        *state;
+
+
+	ACPI_FUNCTION_TRACE ("ut_create_thread_state");
+
+
+	/* Create the generic state object */
+
+	state = acpi_ut_create_generic_state ();
+	if (!state) {
+		return_PTR (NULL);
+	}
+
+	/* Init fields specific to the update struct */
+
+	state->common.data_type = ACPI_DESC_TYPE_STATE_THREAD;
+	state->thread.thread_id = acpi_os_get_thread_id ();
+
+	return_PTR ((struct acpi_thread_state *) state);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_create_update_state
  *
  * PARAMETERS:  Object              - Initial Object to be installed in the
  *                                    state
@@ -642,22 +1066,22 @@
  *
  ******************************************************************************/
 
-acpi_generic_state *
+union acpi_generic_state *
 acpi_ut_create_update_state (
-	acpi_operand_object     *object,
-	u16                     action)
+	union acpi_operand_object       *object,
+	u16                             action)
 {
-	acpi_generic_state      *state;
+	union acpi_generic_state        *state;
 
 
-	FUNCTION_TRACE_PTR ("Ut_create_update_state", object);
+	ACPI_FUNCTION_TRACE_PTR ("ut_create_update_state", object);
 
 
 	/* Create the generic state object */
 
 	state = acpi_ut_create_generic_state ();
 	if (!state) {
-		return (NULL);
+		return_PTR (NULL);
 	}
 
 	/* Init fields specific to the update struct */
@@ -672,7 +1096,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_create_pkg_state
+ * FUNCTION:    acpi_ut_create_pkg_state
  *
  * PARAMETERS:  Object              - Initial Object to be installed in the
  *                                    state
@@ -684,29 +1108,29 @@
  *
  ******************************************************************************/
 
-acpi_generic_state *
+union acpi_generic_state *
 acpi_ut_create_pkg_state (
-	void                    *internal_object,
-	void                    *external_object,
-	u16                     index)
+	void                            *internal_object,
+	void                            *external_object,
+	u16                             index)
 {
-	acpi_generic_state      *state;
+	union acpi_generic_state        *state;
 
 
-	FUNCTION_TRACE_PTR ("Ut_create_pkg_state", internal_object);
+	ACPI_FUNCTION_TRACE_PTR ("ut_create_pkg_state", internal_object);
 
 
 	/* Create the generic state object */
 
 	state = acpi_ut_create_generic_state ();
 	if (!state) {
-		return (NULL);
+		return_PTR (NULL);
 	}
 
 	/* Init fields specific to the update struct */
 
 	state->common.data_type = ACPI_DESC_TYPE_STATE_PACKAGE;
-	state->pkg.source_object = (acpi_operand_object *) internal_object;
+	state->pkg.source_object = (union acpi_operand_object *) internal_object;
 	state->pkg.dest_object  = external_object;
 	state->pkg.index        = index;
 	state->pkg.num_packages = 1;
@@ -717,7 +1141,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_create_control_state
+ * FUNCTION:    acpi_ut_create_control_state
  *
  * PARAMETERS:  None
  *
@@ -728,28 +1152,27 @@
  *
  ******************************************************************************/
 
-acpi_generic_state *
+union acpi_generic_state *
 acpi_ut_create_control_state (
 	void)
 {
-	acpi_generic_state      *state;
+	union acpi_generic_state        *state;
 
 
-	FUNCTION_TRACE ("Ut_create_control_state");
+	ACPI_FUNCTION_TRACE ("ut_create_control_state");
 
 
 	/* Create the generic state object */
 
 	state = acpi_ut_create_generic_state ();
 	if (!state) {
-		return (NULL);
+		return_PTR (NULL);
 	}
 
-
 	/* Init fields specific to the control struct */
 
 	state->common.data_type = ACPI_DESC_TYPE_STATE_CONTROL;
-	state->common.state     = CONTROL_CONDITIONAL_EXECUTING;
+	state->common.state     = ACPI_CONTROL_CONDITIONAL_EXECUTING;
 
 	return_PTR (state);
 }
@@ -757,7 +1180,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_delete_generic_state
+ * FUNCTION:    acpi_ut_delete_generic_state
  *
  * PARAMETERS:  State               - The state object to be deleted
  *
@@ -770,9 +1193,9 @@
 
 void
 acpi_ut_delete_generic_state (
-	acpi_generic_state      *state)
+	union acpi_generic_state        *state)
 {
-	FUNCTION_TRACE ("Ut_delete_generic_state");
+	ACPI_FUNCTION_TRACE ("ut_delete_generic_state");
 
 
 	acpi_ut_release_to_cache (ACPI_MEM_LIST_STATE, state);
@@ -782,7 +1205,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_delete_generic_state_cache
+ * FUNCTION:    acpi_ut_delete_generic_state_cache
  *
  * PARAMETERS:  None
  *
@@ -797,7 +1220,7 @@
 acpi_ut_delete_generic_state_cache (
 	void)
 {
-	FUNCTION_TRACE ("Ut_delete_generic_state_cache");
+	ACPI_FUNCTION_TRACE ("ut_delete_generic_state_cache");
 
 
 	acpi_ut_delete_generic_cache (ACPI_MEM_LIST_STATE);
@@ -807,106 +1230,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_resolve_package_references
- *
- * PARAMETERS:  Obj_desc        - The Package object on which to resolve refs
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Walk through a package and turn internal references into values
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ut_resolve_package_references (
-	acpi_operand_object     *obj_desc)
-{
-	u32                     count;
-	acpi_operand_object     *sub_object;
-
-
-	FUNCTION_TRACE ("Ut_resolve_package_references");
-
-
-	if (obj_desc->common.type != ACPI_TYPE_PACKAGE) {
-		/* The object must be a package */
-
-		REPORT_ERROR (("Must resolve Package Refs on a Package\n"));
-		return_ACPI_STATUS(AE_ERROR);
-	}
-
-	/*
-	 * TBD: what about nested packages? */
-
-	for (count = 0; count < obj_desc->package.count; count++) {
-		sub_object = obj_desc->package.elements[count];
-
-		if (sub_object->common.type == INTERNAL_TYPE_REFERENCE) {
-			if (sub_object->reference.opcode == AML_ZERO_OP) {
-				sub_object->common.type = ACPI_TYPE_INTEGER;
-				sub_object->integer.value = 0;
-			}
-
-			else if (sub_object->reference.opcode == AML_ONE_OP) {
-				sub_object->common.type = ACPI_TYPE_INTEGER;
-				sub_object->integer.value = 1;
-			}
-
-			else if (sub_object->reference.opcode == AML_ONES_OP) {
-				sub_object->common.type = ACPI_TYPE_INTEGER;
-				sub_object->integer.value = ACPI_INTEGER_MAX;
-			}
-		}
-	}
-
-	return_ACPI_STATUS(AE_OK);
-}
-
-#ifdef ACPI_DEBUG
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ut_display_init_pathname
- *
- * PARAMETERS:  Obj_handle          - Handle whose pathname will be displayed
- *              Path                - Additional path string to be appended
- *
- * RETURN:      acpi_status
- *
- * DESCRIPTION: Display full pathnbame of an object, DEBUG ONLY
- *
- ******************************************************************************/
-
-void
-acpi_ut_display_init_pathname (
-	acpi_handle             obj_handle,
-	char                    *path)
-{
-	acpi_status             status;
-	u32                     length = 128;
-	char                    buffer[128];
-
-
-	PROC_NAME ("Ut_display_init_pathname");
-
-
-	status = acpi_ns_handle_to_pathname (obj_handle, &length, buffer);
-	if (ACPI_SUCCESS (status)) {
-		if (path) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "%s.%s\n", buffer, path));
-		}
-		else {
-			ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "%s\n", buffer));
-		}
-	}
-}
-#endif
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ut_walk_package_tree
+ * FUNCTION:    acpi_ut_walk_package_tree
  *
- * PARAMETERS:  Obj_desc        - The Package object on which to resolve refs
+ * PARAMETERS:  obj_desc        - The Package object on which to resolve refs
  *
  * RETURN:      Status
  *
@@ -916,19 +1242,19 @@
 
 acpi_status
 acpi_ut_walk_package_tree (
-	acpi_operand_object     *source_object,
-	void                    *target_object,
-	ACPI_PKG_CALLBACK       walk_callback,
-	void                    *context)
-{
-	acpi_status             status = AE_OK;
-	acpi_generic_state      *state_list = NULL;
-	acpi_generic_state      *state;
-	u32                     this_index;
-	acpi_operand_object     *this_source_obj;
+	union acpi_operand_object       *source_object,
+	void                            *target_object,
+	acpi_pkg_callback               walk_callback,
+	void                            *context)
+{
+	acpi_status                     status = AE_OK;
+	union acpi_generic_state        *state_list = NULL;
+	union acpi_generic_state        *state;
+	u32                             this_index;
+	union acpi_operand_object       *this_source_obj;
 
 
-	FUNCTION_TRACE ("Ut_walk_package_tree");
+	ACPI_FUNCTION_TRACE ("ut_walk_package_tree");
 
 
 	state = acpi_ut_create_pkg_state (source_object, target_object, 0);
@@ -937,29 +1263,26 @@
 	}
 
 	while (state) {
+		/* Get one element of the package */
+
 		this_index    = state->pkg.index;
-		this_source_obj = (acpi_operand_object *)
+		this_source_obj = (union acpi_operand_object *)
 				  state->pkg.source_object->package.elements[this_index];
 
 		/*
-		 * Check for
+		 * Check for:
 		 * 1) An uninitialized package element.  It is completely
-		 *      legal to declare a package and leave it uninitialized
+		 *    legal to declare a package and leave it uninitialized
 		 * 2) Not an internal object - can be a namespace node instead
 		 * 3) Any type other than a package.  Packages are handled in else
-		 *      case below.
+		 *    case below.
 		 */
 		if ((!this_source_obj) ||
-			(!VALID_DESCRIPTOR_TYPE (
-					this_source_obj, ACPI_DESC_TYPE_INTERNAL)) ||
-			(!IS_THIS_OBJECT_TYPE (
-					this_source_obj, ACPI_TYPE_PACKAGE))) {
-
+			(ACPI_GET_DESCRIPTOR_TYPE (this_source_obj) != ACPI_DESC_TYPE_OPERAND) ||
+			(ACPI_GET_OBJECT_TYPE (this_source_obj) != ACPI_TYPE_PACKAGE)) {
 			status = walk_callback (ACPI_COPY_TYPE_SIMPLE, this_source_obj,
 					 state, context);
 			if (ACPI_FAILURE (status)) {
-				/* TBD: must delete package created up to this point */
-
 				return_ACPI_STATUS (status);
 			}
 
@@ -975,7 +1298,6 @@
 				acpi_ut_delete_generic_state (state);
 				state = acpi_ut_pop_generic_state (&state_list);
 
-
 				/* Finished when there are no more states */
 
 				if (!state) {
@@ -994,32 +1316,23 @@
 				state->pkg.index++;
 			}
 		}
-
 		else {
-			/* This is a sub-object of type package */
+			/* This is a subobject of type package */
 
 			status = walk_callback (ACPI_COPY_TYPE_PACKAGE, this_source_obj,
 					  state, context);
 			if (ACPI_FAILURE (status)) {
-				/* TBD: must delete package created up to this point */
-
 				return_ACPI_STATUS (status);
 			}
 
-
-			/*
-			 * The callback above returned a new target package object.
-			 */
-
 			/*
 			 * Push the current state and create a new one
+			 * The callback above returned a new target package object.
 			 */
 			acpi_ut_push_generic_state (&state_list, state);
 			state = acpi_ut_create_pkg_state (this_source_obj,
 					   state->pkg.this_target_obj, 0);
 			if (!state) {
-				/* TBD: must delete package created up to this point */
-
 				return_ACPI_STATUS (AE_NO_MEMORY);
 			}
 		}
@@ -1027,17 +1340,100 @@
 
 	/* We should never get here */
 
-	return (AE_AML_INTERNAL);
+	return_ACPI_STATUS (AE_AML_INTERNAL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_generate_checksum
+ *
+ * PARAMETERS:  Buffer          - Buffer to be scanned
+ *              Length          - number of bytes to examine
+ *
+ * RETURN:      checksum
+ *
+ * DESCRIPTION: Generate a checksum on a raw buffer
+ *
+ ******************************************************************************/
+
+u8
+acpi_ut_generate_checksum (
+	u8                              *buffer,
+	u32                             length)
+{
+	u32                             i;
+	signed char                     sum = 0;
+
+
+	for (i = 0; i < length; i++) {
+		sum = (signed char) (sum + buffer[i]);
+	}
+
+	return ((u8) (0 - sum));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_get_resource_end_tag
+ *
+ * PARAMETERS:  obj_desc        - The resource template buffer object
+ *
+ * RETURN:      Pointer to the end tag
+ *
+ * DESCRIPTION: Find the END_TAG resource descriptor in a resource template
+ *
+ ******************************************************************************/
+
+
+u8 *
+acpi_ut_get_resource_end_tag (
+	union acpi_operand_object       *obj_desc)
+{
+	u8                              buffer_byte;
+	u8                              *buffer;
+	u8                              *end_buffer;
+
+
+	buffer    = obj_desc->buffer.pointer;
+	end_buffer = buffer + obj_desc->buffer.length;
+
+	while (buffer < end_buffer) {
+		buffer_byte = *buffer;
+		if (buffer_byte & ACPI_RDESC_TYPE_MASK) {
+			/* Large Descriptor - Length is next 2 bytes */
+
+			buffer += ((*(buffer+1) | (*(buffer+2) << 8)) + 3);
+		}
+		else {
+			/* Small Descriptor.  End Tag will be found here */
+
+			if ((buffer_byte & ACPI_RDESC_SMALL_MASK) == ACPI_RDESC_TYPE_END_TAG) {
+				/* Found the end tag descriptor, all done. */
+
+				return (buffer);
+			}
+
+			/* Length is in the header */
+
+			buffer += ((buffer_byte & 0x07) + 1);
+		}
+	}
+
+	/* End tag not found */
+
+	return (NULL);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_report_error
+ * FUNCTION:    acpi_ut_report_error
  *
- * PARAMETERS:  Module_name         - Caller's module name (for error output)
- *              Line_number         - Caller's line number (for error output)
- *              Component_id        - Caller's component ID (for error output)
+ * PARAMETERS:  module_name         - Caller's module name (for error output)
+ *              line_number         - Caller's line number (for error output)
+ *              component_id        - Caller's component ID (for error output)
  *              Message             - Error message to use on failure
  *
  * RETURN:      None
@@ -1048,9 +1444,9 @@
 
 void
 acpi_ut_report_error (
-	NATIVE_CHAR             *module_name,
-	u32                     line_number,
-	u32                     component_id)
+	char                            *module_name,
+	u32                             line_number,
+	u32                             component_id)
 {
 
 
@@ -1060,11 +1456,11 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_report_warning
+ * FUNCTION:    acpi_ut_report_warning
  *
- * PARAMETERS:  Module_name         - Caller's module name (for error output)
- *              Line_number         - Caller's line number (for error output)
- *              Component_id        - Caller's component ID (for error output)
+ * PARAMETERS:  module_name         - Caller's module name (for error output)
+ *              line_number         - Caller's line number (for error output)
+ *              component_id        - Caller's component ID (for error output)
  *              Message             - Error message to use on failure
  *
  * RETURN:      None
@@ -1075,9 +1471,9 @@
 
 void
 acpi_ut_report_warning (
-	NATIVE_CHAR             *module_name,
-	u32                     line_number,
-	u32                     component_id)
+	char                            *module_name,
+	u32                             line_number,
+	u32                             component_id)
 {
 
 	acpi_os_printf ("%8s-%04d: *** Warning: ", module_name, line_number);
@@ -1086,11 +1482,11 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_report_info
+ * FUNCTION:    acpi_ut_report_info
  *
- * PARAMETERS:  Module_name         - Caller's module name (for error output)
- *              Line_number         - Caller's line number (for error output)
- *              Component_id        - Caller's component ID (for error output)
+ * PARAMETERS:  module_name         - Caller's module name (for error output)
+ *              line_number         - Caller's line number (for error output)
+ *              component_id        - Caller's component ID (for error output)
  *              Message             - Error message to use on failure
  *
  * RETURN:      None
@@ -1101,9 +1497,9 @@
 
 void
 acpi_ut_report_info (
-	NATIVE_CHAR             *module_name,
-	u32                     line_number,
-	u32                     component_id)
+	char                            *module_name,
+	u32                             line_number,
+	u32                             component_id)
 {
 
 	acpi_os_printf ("%8s-%04d: *** Info: ", module_name, line_number);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/utilities/utobject.c linux-2.4.22-pre2/drivers/acpi/utilities/utobject.c
--- linux-2.4.21/drivers/acpi/utilities/utobject.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/utilities/utobject.c	2003-06-26 21:43:29.000000000 +0000
@@ -1,48 +1,63 @@
 /******************************************************************************
  *
  * Module Name: utobject - ACPI object create/delete/size/cache routines
- *              $Revision: 57 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "actables.h"
-#include "amlcode.h"
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
+#include <acpi/amlcode.h>
 
 
 #define _COMPONENT          ACPI_UTILITIES
-	 MODULE_NAME         ("utobject")
+	 ACPI_MODULE_NAME    ("utobject")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_create_internal_object_dbg
+ * FUNCTION:    acpi_ut_create_internal_object_dbg
  *
- * PARAMETERS:  Address             - Address of the memory to deallocate
- *              Component           - Component type of caller
- *              Module              - Source file name of caller
- *              Line                - Line number of caller
+ * PARAMETERS:  module_name         - Source file name of caller
+ *              line_number         - Line number of caller
+ *              component_id        - Component type of caller
  *              Type                - ACPI Type of the new object
  *
  * RETURN:      Object              - The new object.  Null on failure
@@ -57,31 +72,55 @@
  *
  ******************************************************************************/
 
-acpi_operand_object  *
+union acpi_operand_object    *
 acpi_ut_create_internal_object_dbg (
-	NATIVE_CHAR             *module_name,
-	u32                     line_number,
-	u32                     component_id,
-	acpi_object_type8       type)
+	char                            *module_name,
+	u32                             line_number,
+	u32                             component_id,
+	acpi_object_type                type)
 {
-	acpi_operand_object     *object;
+	union acpi_operand_object       *object;
+	union acpi_operand_object       *second_object;
 
 
-	FUNCTION_TRACE_STR ("Ut_create_internal_object_dbg", acpi_ut_get_type_name (type));
+	ACPI_FUNCTION_TRACE_STR ("ut_create_internal_object_dbg", acpi_ut_get_type_name (type));
 
 
 	/* Allocate the raw object descriptor */
 
 	object = acpi_ut_allocate_object_desc_dbg (module_name, line_number, component_id);
 	if (!object) {
-		/* Allocation failure */
-
 		return_PTR (NULL);
 	}
 
+	switch (type) {
+	case ACPI_TYPE_REGION:
+	case ACPI_TYPE_BUFFER_FIELD:
+
+		/* These types require a secondary object */
+
+		second_object = acpi_ut_allocate_object_desc_dbg (module_name, line_number, component_id);
+		if (!second_object) {
+			acpi_ut_delete_object_desc (object);
+			return_PTR (NULL);
+		}
+
+		second_object->common.type = ACPI_TYPE_LOCAL_EXTRA;
+		second_object->common.reference_count = 1;
+
+		/* Link the second object to the first */
+
+		object->common.next_object = second_object;
+		break;
+
+	default:
+		/* All others have no secondary object */
+		break;
+	}
+
 	/* Save the object type in the object descriptor */
 
-	object->common.type = type;
+	object->common.type = (u8) type;
 
 	/* Init the reference count */
 
@@ -95,68 +134,132 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_valid_internal_object
+ * FUNCTION:    acpi_ut_create_buffer_object
+ *
+ * PARAMETERS:  buffer_size            - Size of buffer to be created
+ *
+ * RETURN:      Pointer to a new Buffer object
+ *
+ * DESCRIPTION: Create a fully initialized buffer object
+ *
+ ******************************************************************************/
+
+union acpi_operand_object *
+acpi_ut_create_buffer_object (
+	acpi_size                       buffer_size)
+{
+	union acpi_operand_object       *buffer_desc;
+	u8                              *buffer = NULL;
+
+
+	ACPI_FUNCTION_TRACE_U32 ("ut_create_buffer_object", buffer_size);
+
+
+	/*
+	 * Create a new Buffer object
+	 */
+	buffer_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER);
+	if (!buffer_desc) {
+		return_PTR (NULL);
+	}
+
+	/* Create an actual buffer only if size > 0 */
+
+	if (buffer_size > 0) {
+		/* Allocate the actual buffer */
+
+		buffer = ACPI_MEM_CALLOCATE (buffer_size);
+		if (!buffer) {
+			ACPI_REPORT_ERROR (("create_buffer: could not allocate size %X\n",
+				(u32) buffer_size));
+			acpi_ut_remove_reference (buffer_desc);
+			return_PTR (NULL);
+		}
+	}
+
+	/* Complete buffer object initialization */
+
+	buffer_desc->buffer.flags |= AOPOBJ_DATA_VALID;
+	buffer_desc->buffer.pointer = buffer;
+	buffer_desc->buffer.length = (u32) buffer_size;
+
+	/* Return the new buffer descriptor */
+
+	return_PTR (buffer_desc);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_valid_internal_object
  *
- * PARAMETERS:  Operand             - Object to be validated
+ * PARAMETERS:  Object              - Object to be validated
  *
- * RETURN:      Validate a pointer to be an acpi_operand_object
+ * RETURN:      Validate a pointer to be an union acpi_operand_object
  *
  ******************************************************************************/
 
 u8
 acpi_ut_valid_internal_object (
-	void                    *object)
+	void                            *object)
 {
 
-	PROC_NAME ("Ut_valid_internal_object");
+	ACPI_FUNCTION_NAME ("ut_valid_internal_object");
 
 
 	/* Check for a null pointer */
 
 	if (!object) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-			"**** Null Object Ptr\n"));
+		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Null Object Ptr\n"));
 		return (FALSE);
 	}
 
 	/* Check the descriptor type field */
 
-	if (!VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_INTERNAL)) {
-		/* Not an ACPI internal object, do some further checking */
+	switch (ACPI_GET_DESCRIPTOR_TYPE (object)) {
+	case ACPI_DESC_TYPE_OPERAND:
 
-		if (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_NAMED)) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-				"**** Obj %p is a named obj, not ACPI obj\n", object));
-		}
+		/* The object appears to be a valid union acpi_operand_object    */
 
-		else if (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_PARSER)) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-				"**** Obj %p is a parser obj, not ACPI obj\n", object));
-		}
+		return (TRUE);
 
-		else {
-			ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-				"**** Obj %p is of unknown type\n", object));
-		}
+	case ACPI_DESC_TYPE_NAMED:
 
-		return (FALSE);
-	}
+		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+			"**** Obj %p is a named obj, not ACPI obj\n", object));
+		break;
+
+	case ACPI_DESC_TYPE_PARSER:
+
+		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+			"**** Obj %p is a parser obj, not ACPI obj\n", object));
+		break;
 
+	case ACPI_DESC_TYPE_CACHED:
 
-	/* The object appears to be a valid acpi_operand_object  */
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"**** Obj %p has already been released to internal cache\n", object));
+		break;
+
+	default:
 
-	return (TRUE);
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"**** Obj %p has unknown descriptor type %X\n", object,
+			ACPI_GET_DESCRIPTOR_TYPE (object)));
+		break;
+	}
+
+	return (FALSE);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_allocate_object_desc_dbg
+ * FUNCTION:    acpi_ut_allocate_object_desc_dbg
  *
- * PARAMETERS:  Module_name         - Caller's module name (for error output)
- *              Line_number         - Caller's line number (for error output)
- *              Component_id        - Caller's component ID (for error output)
- *              Message             - Error message to use on failure
+ * PARAMETERS:  module_name         - Caller's module name (for error output)
+ *              line_number         - Caller's line number (for error output)
+ *              component_id        - Caller's component ID (for error output)
  *
  * RETURN:      Pointer to newly allocated object descriptor.  Null on error
  *
@@ -167,31 +270,30 @@
 
 void *
 acpi_ut_allocate_object_desc_dbg (
-	NATIVE_CHAR             *module_name,
-	u32                     line_number,
-	u32                     component_id)
+	char                            *module_name,
+	u32                             line_number,
+	u32                             component_id)
 {
-	acpi_operand_object     *object;
+	union acpi_operand_object       *object;
 
 
-	FUNCTION_TRACE ("Ut_allocate_object_desc_dbg");
+	ACPI_FUNCTION_TRACE ("ut_allocate_object_desc_dbg");
 
 
 	object = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_OPERAND);
 	if (!object) {
-		_REPORT_ERROR (module_name, line_number, component_id,
+		_ACPI_REPORT_ERROR (module_name, line_number, component_id,
 				  ("Could not allocate an object descriptor\n"));
 
 		return_PTR (NULL);
 	}
 
-
 	/* Mark the descriptor type */
 
-	object->common.data_type = ACPI_DESC_TYPE_INTERNAL;
+	ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_OPERAND);
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n",
-			object, sizeof (acpi_operand_object)));
+			object, (u32) sizeof (union acpi_operand_object)));
 
 	return_PTR (object);
 }
@@ -199,9 +301,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_delete_object_desc
+ * FUNCTION:    acpi_ut_delete_object_desc
  *
- * PARAMETERS:  Object          - Acpi internal object to be deleted
+ * PARAMETERS:  Object          - An Acpi internal object to be deleted
  *
  * RETURN:      None.
  *
@@ -211,14 +313,14 @@
 
 void
 acpi_ut_delete_object_desc (
-	acpi_operand_object     *object)
+	union acpi_operand_object       *object)
 {
-	FUNCTION_TRACE_PTR ("Ut_delete_object_desc", object);
+	ACPI_FUNCTION_TRACE_PTR ("ut_delete_object_desc", object);
 
 
-	/* Object must be an acpi_operand_object  */
+	/* Object must be an union acpi_operand_object    */
 
-	if (object->common.data_type != ACPI_DESC_TYPE_INTERNAL) {
+	if (ACPI_GET_DESCRIPTOR_TYPE (object) != ACPI_DESC_TYPE_OPERAND) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 			"Obj %p is not an ACPI object\n", object));
 		return_VOID;
@@ -232,11 +334,11 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_delete_object_cache
+ * FUNCTION:    acpi_ut_delete_object_cache
  *
  * PARAMETERS:  None
  *
- * RETURN:      Status
+ * RETURN:      None
  *
  * DESCRIPTION: Purge the global state object cache.  Used during subsystem
  *              termination.
@@ -247,7 +349,7 @@
 acpi_ut_delete_object_cache (
 	void)
 {
-	FUNCTION_TRACE ("Ut_delete_object_cache");
+	ACPI_FUNCTION_TRACE ("ut_delete_object_cache");
 
 
 	acpi_ut_delete_generic_cache (ACPI_MEM_LIST_OPERAND);
@@ -257,15 +359,15 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_get_simple_object_size
+ * FUNCTION:    acpi_ut_get_simple_object_size
  *
- * PARAMETERS:  *Internal_object    - Pointer to the object we are examining
- *              *Ret_length         - Where the length is returned
+ * PARAMETERS:  *internal_object    - Pointer to the object we are examining
+ *              *obj_length         - Where the length is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: This function is called to determine the space required to
- *              contain a simple object for return to an API user.
+ *              contain a simple object for return to an external user.
  *
  *              The length includes the object structure plus any additional
  *              needed space.
@@ -274,14 +376,14 @@
 
 acpi_status
 acpi_ut_get_simple_object_size (
-	acpi_operand_object     *internal_object,
-	u32                     *obj_length)
+	union acpi_operand_object       *internal_object,
+	acpi_size                       *obj_length)
 {
-	u32                     length;
-	acpi_status             status = AE_OK;
+	acpi_size                       length;
+	acpi_status                     status = AE_OK;
 
 
-	FUNCTION_TRACE_PTR ("Ut_get_simple_object_size", internal_object);
+	ACPI_FUNCTION_TRACE_PTR ("ut_get_simple_object_size", internal_object);
 
 
 	/* Handle a null object (Could be a uninitialized package element -- which is legal) */
@@ -291,37 +393,33 @@
 		return_ACPI_STATUS (AE_OK);
 	}
 
-
 	/* Start with the length of the Acpi object */
 
-	length = sizeof (acpi_object);
+	length = sizeof (union acpi_object);
 
-	if (VALID_DESCRIPTOR_TYPE (internal_object, ACPI_DESC_TYPE_NAMED)) {
+	if (ACPI_GET_DESCRIPTOR_TYPE (internal_object) == ACPI_DESC_TYPE_NAMED) {
 		/* Object is a named object (reference), just return the length */
 
-		*obj_length = (u32) ROUND_UP_TO_NATIVE_WORD (length);
+		*obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD (length);
 		return_ACPI_STATUS (status);
 	}
 
-
 	/*
 	 * The final length depends on the object type
 	 * Strings and Buffers are packed right up against the parent object and
 	 * must be accessed bytewise or there may be alignment problems on
 	 * certain processors
 	 */
-
-	switch (internal_object->common.type) {
-
+	switch (ACPI_GET_OBJECT_TYPE (internal_object)) {
 	case ACPI_TYPE_STRING:
 
-		length += internal_object->string.length + 1;
+		length += (acpi_size) internal_object->string.length + 1;
 		break;
 
 
 	case ACPI_TYPE_BUFFER:
 
-		length += internal_object->buffer.length;
+		length += (acpi_size) internal_object->buffer.length;
 		break;
 
 
@@ -335,25 +433,30 @@
 		break;
 
 
-	case INTERNAL_TYPE_REFERENCE:
+	case ACPI_TYPE_LOCAL_REFERENCE:
 
-		/*
-		 * The only type that should be here is internal opcode NAMEPATH_OP -- since
-		 * this means an object reference
-		 */
-		if (internal_object->reference.opcode != AML_INT_NAMEPATH_OP) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-				"Unsupported Reference opcode=%X in object %p\n",
-				internal_object->reference.opcode, internal_object));
-			status = AE_TYPE;
-		}
+		switch (internal_object->reference.opcode) {
+		case AML_INT_NAMEPATH_OP:
 
-		else {
 			/*
 			 * Get the actual length of the full pathname to this object.
 			 * The reference will be converted to the pathname to the object
 			 */
-			length += ROUND_UP_TO_NATIVE_WORD (acpi_ns_get_pathname_length (internal_object->reference.node));
+			length += ACPI_ROUND_UP_TO_NATIVE_WORD (acpi_ns_get_pathname_length (internal_object->reference.node));
+			break;
+
+		default:
+
+			/*
+			 * No other reference opcodes are supported.
+			 * Notably, Locals and Args are not supported, but this may be
+			 * required eventually.
+			 */
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"Unsupported Reference opcode=%X in object %p\n",
+				internal_object->reference.opcode, internal_object));
+			status = AE_TYPE;
+			break;
 		}
 		break;
 
@@ -361,31 +464,29 @@
 	default:
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported type=%X in object %p\n",
-			internal_object->common.type, internal_object));
+			ACPI_GET_OBJECT_TYPE (internal_object), internal_object));
 		status = AE_TYPE;
 		break;
 	}
 
-
 	/*
 	 * Account for the space required by the object rounded up to the next
 	 * multiple of the machine word size.  This keeps each object aligned
 	 * on a machine word boundary. (preventing alignment faults on some
 	 * machines.)
 	 */
-	*obj_length = (u32) ROUND_UP_TO_NATIVE_WORD (length);
-
+	*obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD (length);
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_get_element_length
+ * FUNCTION:    acpi_ut_get_element_length
  *
- * PARAMETERS:  ACPI_PKG_CALLBACK
+ * PARAMETERS:  acpi_pkg_callback
  *
- * RETURN:      Status          - the status of the call
+ * RETURN:      Status
  *
  * DESCRIPTION: Get the length of one package element.
  *
@@ -393,18 +494,18 @@
 
 acpi_status
 acpi_ut_get_element_length (
-	u8                      object_type,
-	acpi_operand_object     *source_object,
-	acpi_generic_state      *state,
-	void                    *context)
+	u8                              object_type,
+	union acpi_operand_object       *source_object,
+	union acpi_generic_state        *state,
+	void                            *context)
 {
-	acpi_status             status = AE_OK;
-	acpi_pkg_info           *info = (acpi_pkg_info *) context;
-	u32                     object_space;
+	acpi_status                     status = AE_OK;
+	struct acpi_pkg_info            *info = (struct acpi_pkg_info *) context;
+	acpi_size                       object_space;
 
 
 	switch (object_type) {
-	case 0:
+	case ACPI_COPY_TYPE_SIMPLE:
 
 		/*
 		 * Simple object - just get the size (Null object/entry is handled
@@ -419,33 +520,37 @@
 		break;
 
 
-	case 1:
-		/* Package - nothing much to do here, let the walk handle it */
+	case ACPI_COPY_TYPE_PACKAGE:
+
+		/* Package object - nothing much to do here, let the walk handle it */
 
 		info->num_packages++;
 		state->pkg.this_target_obj = NULL;
 		break;
 
+
 	default:
+
+		/* No other types allowed */
+
 		return (AE_BAD_PARAMETER);
 	}
 
-
 	return (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_get_package_object_size
+ * FUNCTION:    acpi_ut_get_package_object_size
  *
- * PARAMETERS:  *Internal_object    - Pointer to the object we are examining
- *              *Ret_length         - Where the length is returned
+ * PARAMETERS:  *internal_object    - Pointer to the object we are examining
+ *              *obj_length         - Where the length is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: This function is called to determine the space required to
- *              contain a package object for return to an API user.
+ *              contain a package object for return to an external user.
  *
  *              This is moderately complex since a package contains other
  *              objects including packages.
@@ -454,14 +559,14 @@
 
 acpi_status
 acpi_ut_get_package_object_size (
-	acpi_operand_object     *internal_object,
-	u32                     *obj_length)
+	union acpi_operand_object       *internal_object,
+	acpi_size                       *obj_length)
 {
-	acpi_status             status;
-	acpi_pkg_info           info;
+	acpi_status                     status;
+	struct acpi_pkg_info            info;
 
 
-	FUNCTION_TRACE_PTR ("Ut_get_package_object_size", internal_object);
+	ACPI_FUNCTION_TRACE_PTR ("ut_get_package_object_size", internal_object);
 
 
 	info.length      = 0;
@@ -470,14 +575,17 @@
 
 	status = acpi_ut_walk_package_tree (internal_object, NULL,
 			 acpi_ut_get_element_length, &info);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
 	/*
 	 * We have handled all of the objects in all levels of the package.
 	 * just add the length of the package objects themselves.
 	 * Round up to the next machine word.
 	 */
-	info.length += ROUND_UP_TO_NATIVE_WORD (sizeof (acpi_object)) *
-			  info.num_packages;
+	info.length += ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)) *
+			  (acpi_size) info.num_packages;
 
 	/* Return the total package length */
 
@@ -488,10 +596,10 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_get_object_size
+ * FUNCTION:    acpi_ut_get_object_size
  *
- * PARAMETERS:  *Internal_object    - Pointer to the object we are examining
- *              *Ret_length         - Where the length will be returned
+ * PARAMETERS:  *internal_object    - Pointer to the object we are examining
+ *              *obj_length         - Where the length will be returned
  *
  * RETURN:      Status
  *
@@ -502,20 +610,19 @@
 
 acpi_status
 acpi_ut_get_object_size(
-	acpi_operand_object     *internal_object,
-	u32                     *obj_length)
+	union acpi_operand_object       *internal_object,
+	acpi_size                       *obj_length)
 {
-	acpi_status             status;
+	acpi_status                     status;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
-	if ((VALID_DESCRIPTOR_TYPE (internal_object, ACPI_DESC_TYPE_INTERNAL)) &&
-		(IS_THIS_OBJECT_TYPE (internal_object, ACPI_TYPE_PACKAGE))) {
+	if ((ACPI_GET_DESCRIPTOR_TYPE (internal_object) == ACPI_DESC_TYPE_OPERAND) &&
+		(ACPI_GET_OBJECT_TYPE (internal_object) == ACPI_TYPE_PACKAGE)) {
 		status = acpi_ut_get_package_object_size (internal_object, obj_length);
 	}
-
 	else {
 		status = acpi_ut_get_simple_object_size (internal_object, obj_length);
 	}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/utilities/utxface.c linux-2.4.22-pre2/drivers/acpi/utilities/utxface.c
--- linux-2.4.21/drivers/acpi/utilities/utxface.c	2001-10-24 21:06:22.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/utilities/utxface.c	2003-06-26 21:43:12.000000000 +0000
@@ -1,46 +1,61 @@
 /******************************************************************************
  *
  * Module Name: utxface - External interfaces for "global" ACPI functions
- *              $Revision: 82 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.  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
+ * 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.
  */
 
 
-#include "acpi.h"
-#include "acevents.h"
-#include "achware.h"
-#include "acnamesp.h"
-#include "acinterp.h"
-#include "amlcode.h"
-#include "acdebug.h"
-#include "acexcep.h"
-
+#include <acpi/acpi.h>
+#include <acpi/acevents.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acparser.h>
+#include <acpi/acdispat.h>
+#include <acpi/acdebug.h>
 
 #define _COMPONENT          ACPI_UTILITIES
-	 MODULE_NAME         ("utxface")
+	 ACPI_MODULE_NAME    ("utxface")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_initialize_subsystem
+ * FUNCTION:    acpi_initialize_subsystem
  *
  * PARAMETERS:  None
  *
@@ -55,12 +70,12 @@
 acpi_initialize_subsystem (
 	void)
 {
-	acpi_status             status;
+	acpi_status                     status;
 
-	FUNCTION_TRACE ("Acpi_initialize_subsystem");
+	ACPI_FUNCTION_TRACE ("acpi_initialize_subsystem");
 
 
-	DEBUG_EXEC(acpi_ut_init_stack_ptr_trace ());
+	ACPI_DEBUG_EXEC (acpi_ut_init_stack_ptr_trace ());
 
 
 	/* Initialize all globals used by the subsystem */
@@ -71,7 +86,7 @@
 
 	status = acpi_os_initialize ();
 	if (ACPI_FAILURE (status)) {
-		REPORT_ERROR (("OSD failed to initialize, %s\n",
+		ACPI_REPORT_ERROR (("OSD failed to initialize, %s\n",
 			acpi_format_exception (status)));
 		return_ACPI_STATUS (status);
 	}
@@ -80,7 +95,7 @@
 
 	status = acpi_ut_mutex_initialize ();
 	if (ACPI_FAILURE (status)) {
-		REPORT_ERROR (("Global mutex creation failure, %s\n",
+		ACPI_REPORT_ERROR (("Global mutex creation failure, %s\n",
 			acpi_format_exception (status)));
 		return_ACPI_STATUS (status);
 	}
@@ -92,7 +107,7 @@
 
 	status = acpi_ns_root_initialize ();
 	if (ACPI_FAILURE (status)) {
-		REPORT_ERROR (("Namespace initialization failure, %s\n",
+		ACPI_REPORT_ERROR (("Namespace initialization failure, %s\n",
 			acpi_format_exception (status)));
 		return_ACPI_STATUS (status);
 	}
@@ -100,7 +115,7 @@
 
 	/* If configured, initialize the AML debugger */
 
-	DEBUGGER_EXEC (acpi_db_initialize ());
+	ACPI_DEBUGGER_EXEC (status = acpi_db_initialize ());
 
 	return_ACPI_STATUS (status);
 }
@@ -108,7 +123,7 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_enable_subsystem
+ * FUNCTION:    acpi_enable_subsystem
  *
  * PARAMETERS:  Flags           - Init/enable Options
  *
@@ -121,37 +136,17 @@
 
 acpi_status
 acpi_enable_subsystem (
-	u32                     flags)
+	u32                             flags)
 {
-	acpi_status             status = AE_OK;
-
-
-	FUNCTION_TRACE ("Acpi_enable_subsystem");
-
+	acpi_status                     status = AE_OK;
 
-	/* Sanity check the FADT for valid values */
 
-	status = acpi_ut_validate_fadt ();
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
+	ACPI_FUNCTION_TRACE ("acpi_enable_subsystem");
 
-	/*
-	 * Install the default Op_region handlers. These are
-	 * installed unless other handlers have already been
-	 * installed via the Install_address_space_handler interface
-	 */
-	if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing default address space handlers\n"));
-
-		status = acpi_ev_install_default_address_space_handlers ();
-		if (ACPI_FAILURE (status)) {
-			return_ACPI_STATUS (status);
-		}
-	}
 
 	/*
 	 * We must initialize the hardware before we can enable ACPI.
+	 * The values from the FADT are validated here.
 	 */
 	if (!(flags & ACPI_NO_HARDWARE_INIT)) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI hardware\n"));
@@ -163,21 +158,24 @@
 	}
 
 	/*
-	 * Enable ACPI on this platform
+	 * Enable ACPI mode
 	 */
 	if (!(flags & ACPI_NO_ACPI_ENABLE)) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n"));
 
+		acpi_gbl_original_mode = acpi_hw_get_mode();
+
 		status = acpi_enable ();
 		if (ACPI_FAILURE (status)) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Acpi_enable failed.\n"));
+			ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "acpi_enable failed.\n"));
 			return_ACPI_STATUS (status);
 		}
 	}
 
 	/*
-	 * Note:
-	 * We must have the hardware AND events initialized before we can execute
+	 * Initialize ACPI Event handling
+	 *
+	 * NOTE: We must have the hardware AND events initialized before we can execute
 	 * ANY control methods SAFELY.  Any control method can require ACPI hardware
 	 * support, so the hardware MUST be initialized before execution!
 	 */
@@ -190,25 +188,65 @@
 		}
 	}
 
+	/* Install the SCI handler, Global Lock handler, and GPE handlers */
+
+	if (!(flags & ACPI_NO_HANDLER_INIT)) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing SCI/GL/GPE handlers\n"));
+
+		status = acpi_ev_handler_initialize ();
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
+		}
+	}
+
+	return_ACPI_STATUS (status);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_initialize_objects
+ *
+ * PARAMETERS:  Flags           - Init/enable Options
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Completes namespace initialization by initializing device
+ *              objects and executing AML code for Regions, buffers, etc.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_initialize_objects (
+	u32                             flags)
+{
+	acpi_status                     status = AE_OK;
+
+
+	ACPI_FUNCTION_TRACE ("acpi_initialize_objects");
+
 
 	/*
-	 * Initialize all device objects in the namespace
-	 * This runs the _STA and _INI methods.
+	 * Install the default op_region handlers. These are installed unless
+	 * other handlers have already been installed via the
+	 * install_address_space_handler interface.
+	 *
+	 * NOTE: This will cause _REG methods to be run.  Any objects accessed
+	 * by the _REG methods will be automatically initialized, even if they
+	 * contain executable AML (see call to acpi_ns_initialize_objects below).
 	 */
-	if (!(flags & ACPI_NO_DEVICE_INIT)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI Devices\n"));
+	if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing default address space handlers\n"));
 
-		status = acpi_ns_initialize_devices ();
+		status = acpi_ev_init_address_spaces ();
 		if (ACPI_FAILURE (status)) {
 			return_ACPI_STATUS (status);
 		}
 	}
 
-
 	/*
 	 * Initialize the objects that remain uninitialized.  This
-	 * runs the executable AML that is part of the declaration of Op_regions
-	 * and Fields.
+	 * runs the executable AML that may be part of the declaration of these
+	 * objects: operation_regions, buffer_fields, Buffers, and Packages.
 	 */
 	if (!(flags & ACPI_NO_OBJECT_INIT)) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI Objects\n"));
@@ -219,15 +257,34 @@
 		}
 	}
 
-	acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
+	/*
+	 * Initialize all device objects in the namespace
+	 * This runs the _STA and _INI methods.
+	 */
+	if (!(flags & ACPI_NO_DEVICE_INIT)) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI Devices\n"));
 
+		status = acpi_ns_initialize_devices ();
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
+		}
+	}
+
+	/*
+	 * Empty the caches (delete the cached objects) on the assumption that
+	 * the table load filled them up more than they will be at runtime --
+	 * thus wasting non-paged memory.
+	 */
+	status = acpi_purge_cached_objects ();
+
+	acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
 	return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_terminate
+ * FUNCTION:    acpi_terminate
  *
  * PARAMETERS:  None
  *
@@ -240,16 +297,15 @@
 acpi_status
 acpi_terminate (void)
 {
-	FUNCTION_TRACE ("Acpi_terminate");
+	acpi_status                 status;
 
 
-	/* Terminate the AML Debugger if present */
+	ACPI_FUNCTION_TRACE ("acpi_terminate");
 
-	DEBUGGER_EXEC(acpi_gbl_db_terminate_threads = TRUE);
 
-	/* TBD: [Investigate] This is no longer needed?*/
-/*    Acpi_ut_release_mutex (ACPI_MTX_DEBUG_CMD_READY); */
+	/* Terminate the AML Debugger if present */
 
+	ACPI_DEBUGGER_EXEC(acpi_gbl_db_terminate_threads = TRUE);
 
 	/* Shutdown and free all resources */
 
@@ -261,7 +317,7 @@
 	acpi_ut_mutex_terminate ();
 
 
-#ifdef ENABLE_DEBUGGER
+#ifdef ACPI_DEBUGGER
 
 	/* Shut down the debugger */
 
@@ -270,16 +326,14 @@
 
 	/* Now we can shutdown the OS-dependent layer */
 
-	acpi_os_terminate ();
-
-
-	return_ACPI_STATUS (AE_OK);
+	status = acpi_os_terminate ();
+	return_ACPI_STATUS (status);
 }
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_subsystem_status
+ * FUNCTION:    acpi_subsystem_status
  *
  * PARAMETERS:  None
  *
@@ -305,65 +359,62 @@
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_get_system_info
+ * FUNCTION:    acpi_get_system_info
  *
- * PARAMETERS:  Out_buffer      - a pointer to a buffer to receive the
+ * PARAMETERS:  out_buffer      - a pointer to a buffer to receive the
  *                                resources for the device
- *              Buffer_length   - the number of bytes available in the buffer
+ *              buffer_length   - the number of bytes available in the buffer
  *
  * RETURN:      Status          - the status of the call
  *
  * DESCRIPTION: This function is called to get information about the current
  *              state of the ACPI subsystem.  It will return system information
- *              in the Out_buffer.
+ *              in the out_buffer.
  *
  *              If the function fails an appropriate status will be returned
- *              and the value of Out_buffer is undefined.
+ *              and the value of out_buffer is undefined.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_get_system_info (
-	acpi_buffer             *out_buffer)
+	struct acpi_buffer              *out_buffer)
 {
-	acpi_system_info        *info_ptr;
-	u32                     i;
+	struct acpi_system_info         *info_ptr;
+	u32                             i;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE ("Acpi_get_system_info");
+	ACPI_FUNCTION_TRACE ("acpi_get_system_info");
 
 
-	/*
-	 *  Must have a valid buffer
-	 */
-	if ((!out_buffer)         ||
-		(!out_buffer->pointer)) {
-		return_ACPI_STATUS (AE_BAD_PARAMETER);
+	/* Parameter validation */
+
+	status = acpi_ut_validate_buffer (out_buffer);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
 	}
 
-	if (out_buffer->length < sizeof (acpi_system_info)) {
-		/*
-		 *  Caller's buffer is too small
-		 */
-		out_buffer->length = sizeof (acpi_system_info);
+	/* Validate/Allocate/Clear caller buffer */
 
-		return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
+	status = acpi_ut_initialize_buffer (out_buffer, sizeof (struct acpi_system_info));
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
 	}
 
-
 	/*
-	 *  Set return length and get data
+	 * Populate the return buffer
 	 */
-	out_buffer->length = sizeof (acpi_system_info);
-	info_ptr = (acpi_system_info *) out_buffer->pointer;
+	info_ptr = (struct acpi_system_info *) out_buffer->pointer;
 
 	info_ptr->acpi_ca_version   = ACPI_CA_VERSION;
 
 	/* System flags (ACPI capabilities) */
 
-	info_ptr->flags             = acpi_gbl_system_flags;
+	info_ptr->flags             = ACPI_SYS_MODE_ACPI;
 
 	/* Timer resolution - 24 or 32 bits  */
+
 	if (!acpi_gbl_FADT) {
 		info_ptr->timer_resolution = 0;
 	}
@@ -386,12 +437,70 @@
 
 	/* Current status of the ACPI tables, per table type */
 
-	info_ptr->num_table_types = NUM_ACPI_TABLES;
-	for (i = 0; i < NUM_ACPI_TABLES; i++) {
-		info_ptr->table_info[i].count = acpi_gbl_acpi_tables[i].count;
+	info_ptr->num_table_types = NUM_ACPI_TABLE_TYPES;
+	for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) {
+		info_ptr->table_info[i].count = acpi_gbl_table_lists[i].count;
 	}
 
 	return_ACPI_STATUS (AE_OK);
 }
 
 
+/*****************************************************************************
+ *
+ * FUNCTION:    acpi_install_initialization_handler
+ *
+ * PARAMETERS:  Handler             - Callback procedure
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Install an initialization handler
+ *
+ * TBD: When a second function is added, must save the Function also.
+ *
+ ****************************************************************************/
+
+acpi_status
+acpi_install_initialization_handler (
+	acpi_init_handler               handler,
+	u32                             function)
+{
+
+	if (!handler) {
+		return (AE_BAD_PARAMETER);
+	}
+
+	if (acpi_gbl_init_handler) {
+		return (AE_ALREADY_EXISTS);
+	}
+
+	acpi_gbl_init_handler = handler;
+	return AE_OK;
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION:    acpi_purge_cached_objects
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Empty all caches (delete the cached objects)
+ *
+ ****************************************************************************/
+
+acpi_status
+acpi_purge_cached_objects (void)
+{
+	ACPI_FUNCTION_TRACE ("acpi_purge_cached_objects");
+
+
+	acpi_ut_delete_generic_state_cache ();
+	acpi_ut_delete_object_cache ();
+	acpi_ds_delete_walk_state_cache ();
+	acpi_ps_delete_parse_cache ();
+
+	return_ACPI_STATUS (AE_OK);
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/acpi/utils.c linux-2.4.22-pre2/drivers/acpi/utils.c
--- linux-2.4.21/drivers/acpi/utils.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/acpi/utils.c	2003-06-26 21:43:15.000000000 +0000
@@ -0,0 +1,413 @@
+/*
+ *  acpi_utils.c - ACPI Utility Functions ($Revision: 8 $)
+ *
+ *  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/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+
+
+#define _COMPONENT		ACPI_BUS_COMPONENT
+ACPI_MODULE_NAME		("acpi_utils")
+
+
+/* --------------------------------------------------------------------------
+                            Object Evaluation Helpers
+   -------------------------------------------------------------------------- */
+
+#ifdef ACPI_DEBUG_OUTPUT
+#define acpi_util_eval_error(h,p,s) {\
+	char prefix[80] = {'\0'};\
+	struct acpi_buffer buffer = {sizeof(prefix), prefix};\
+	acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer);\
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluate [%s.%s]: %s\n",\
+		(char *) prefix, p, acpi_format_exception(s))); }
+#else
+#define acpi_util_eval_error(h,p,s)
+#endif
+
+
+acpi_status
+acpi_extract_package (
+	union acpi_object	*package,
+	struct acpi_buffer	*format,
+	struct acpi_buffer	*buffer)
+{
+	u32			size_required = 0;
+	u32			tail_offset = 0;
+	char			*format_string = NULL;
+	u32			format_count = 0;
+	u32			i = 0;
+	u8			*head = NULL;
+	u8			*tail = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_extract_package");
+
+	if (!package || (package->type != ACPI_TYPE_PACKAGE) || (package->package.count < 1)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'package' argument\n"));
+		return_ACPI_STATUS(AE_BAD_PARAMETER);
+	}
+
+	if (!format || !format->pointer || (format->length < 1)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'format' argument\n"));
+		return_ACPI_STATUS(AE_BAD_PARAMETER);
+	}
+
+	if (!buffer) {
+		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'buffer' argument\n"));
+		return_ACPI_STATUS(AE_BAD_PARAMETER);
+	}
+
+	format_count = (format->length/sizeof(char)) - 1;
+	if (format_count > package->package.count) {
+		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Format specifies more objects [%d] than exist in package [%d].", format_count, package->package.count));
+		return_ACPI_STATUS(AE_BAD_DATA);
+	}
+
+	format_string = (char*)format->pointer;
+
+	/*
+	 * Calculate size_required.
+	 */
+	for (i=0; i<format_count; i++) {
+
+		union acpi_object *element = &(package->package.elements[i]);
+
+		if (!element) {
+			return_ACPI_STATUS(AE_BAD_DATA);
+		}
+
+		switch (element->type) {
+
+		case ACPI_TYPE_INTEGER:
+			switch (format_string[i]) {
+			case 'N':
+				size_required += sizeof(acpi_integer);
+				tail_offset += sizeof(acpi_integer);
+				break;
+			case 'S':
+				size_required += sizeof(char*) + sizeof(acpi_integer) + sizeof(char);
+				tail_offset += sizeof(char*);
+				break;
+			default:
+				ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid package element [%d]: got number, expecing [%c].\n", i, format_string[i]));
+				return_ACPI_STATUS(AE_BAD_DATA);
+				break;
+			}
+			break;
+
+		case ACPI_TYPE_STRING:
+		case ACPI_TYPE_BUFFER:
+			switch (format_string[i]) {
+			case 'S':
+				size_required += sizeof(char*) + (element->string.length * sizeof(char)) + sizeof(char);
+				tail_offset += sizeof(char*);
+				break;
+			case 'B':
+				size_required += sizeof(u8*) + (element->buffer.length * sizeof(u8));
+				tail_offset += sizeof(u8*);
+				break;
+			default:
+				ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid package element [%d] got string/buffer, expecing [%c].\n", i, format_string[i]));
+				return_ACPI_STATUS(AE_BAD_DATA);
+				break;
+			}
+			break;
+
+		case ACPI_TYPE_PACKAGE:
+		default:
+			ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unsupported element at index=%d\n", i));
+			/* TBD: handle nested packages... */
+			return_ACPI_STATUS(AE_SUPPORT);
+			break;
+		}
+	}
+
+	/*
+	 * Validate output buffer.
+	 */
+	if (buffer->length < size_required) {
+		buffer->length = size_required;
+		return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
+	}
+	else if (buffer->length != size_required || !buffer->pointer) {
+		return_ACPI_STATUS(AE_BAD_PARAMETER);
+	}
+
+	head = buffer->pointer;
+	tail = buffer->pointer + tail_offset;
+
+	/*
+	 * Extract package data.
+	 */
+	for (i=0; i<format_count; i++) {
+
+		u8 **pointer = NULL;
+		union acpi_object *element = &(package->package.elements[i]);
+
+		if (!element) {
+			return_ACPI_STATUS(AE_BAD_DATA);
+		}
+
+		switch (element->type) {
+
+		case ACPI_TYPE_INTEGER:
+			switch (format_string[i]) {
+			case 'N':
+				*((acpi_integer*)head) = element->integer.value;
+				head += sizeof(acpi_integer);
+				break;
+			case 'S':
+				pointer = (u8**)head;
+				*pointer = tail;
+				*((acpi_integer*)tail) = element->integer.value;
+				head += sizeof(acpi_integer*);
+				tail += sizeof(acpi_integer);
+				/* NULL terminate string */
+				*tail = (char)0;
+				tail += sizeof(char);
+				break;
+			default:
+				/* Should never get here */
+				break;
+			}
+			break;
+
+		case ACPI_TYPE_STRING:
+		case ACPI_TYPE_BUFFER:
+			switch (format_string[i]) {
+			case 'S':
+				pointer = (u8**)head;
+				*pointer = tail;
+				memcpy(tail, element->string.pointer, element->string.length);
+				head += sizeof(char*);
+				tail += element->string.length * sizeof(char);
+				/* NULL terminate string */
+				*tail = (char)0;
+				tail += sizeof(char);
+				break;
+			case 'B':
+				pointer = (u8**)head;
+				*pointer = tail;
+				memcpy(tail, element->buffer.pointer, element->buffer.length);
+				head += sizeof(u8*);
+				tail += element->buffer.length * sizeof(u8);
+				break;
+			default:
+				/* Should never get here */
+				break;
+			}
+			break;
+
+		case ACPI_TYPE_PACKAGE:
+			/* TBD: handle nested packages... */
+		default:
+			/* Should never get here */
+			break;
+		}
+	}
+
+	return_ACPI_STATUS(AE_OK);
+}
+
+
+acpi_status
+acpi_evaluate_integer (
+	acpi_handle		handle,
+	acpi_string		pathname,
+	struct acpi_object_list	*arguments,
+	unsigned long		*data)
+{
+	acpi_status             status = AE_OK;
+	union acpi_object	element;
+	struct acpi_buffer	buffer = {sizeof(union acpi_object), &element};
+
+	ACPI_FUNCTION_TRACE("acpi_evaluate_integer");
+
+	if (!data)
+		return_ACPI_STATUS(AE_BAD_PARAMETER);
+
+	status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
+	if (ACPI_FAILURE(status)) {
+		acpi_util_eval_error(handle, pathname, status);
+		return_ACPI_STATUS(status);
+	}
+
+	if (element.type != ACPI_TYPE_INTEGER) {
+		acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
+		return_ACPI_STATUS(AE_BAD_DATA);
+	}
+
+	*data = element.integer.value;
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%lu]\n", *data));
+
+	return_ACPI_STATUS(AE_OK);
+}
+
+
+#if 0
+acpi_status
+acpi_evaluate_string (
+	acpi_handle		handle,
+	acpi_string		pathname,
+	acpi_object_list	*arguments,
+	acpi_string		*data)
+{
+	acpi_status             status = AE_OK;
+	acpi_object             *element = NULL;
+	acpi_buffer		buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+
+	ACPI_FUNCTION_TRACE("acpi_evaluate_string");
+
+	if (!data)
+		return_ACPI_STATUS(AE_BAD_PARAMETER);
+
+	status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
+	if (ACPI_FAILURE(status)) {
+		acpi_util_eval_error(handle, pathname, status);
+		return_ACPI_STATUS(status);
+	}
+
+	element = (acpi_object *) buffer.pointer;
+
+	if ((element->type != ACPI_TYPE_STRING) 
+		|| (element->type != ACPI_TYPE_BUFFER)
+		|| !element->string.length) {
+		acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
+		return_ACPI_STATUS(AE_BAD_DATA);
+	}
+
+	*data = kmalloc(element->string.length + 1, GFP_KERNEL);
+	if (!data) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n"));
+		return_VALUE(-ENOMEM);
+	}
+	memset(*data, 0, element->string.length + 1);
+
+	memcpy(*data, element->string.pointer, element->string.length);
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%s]\n", *data));
+
+	acpi_os_free(buffer.pointer);
+
+	return_ACPI_STATUS(AE_OK);
+}
+#endif
+
+
+acpi_status
+acpi_evaluate_reference (
+	acpi_handle		handle,
+	acpi_string		pathname,
+	struct acpi_object_list	*arguments,
+	struct acpi_handle_list	*list)
+{
+	acpi_status		status = AE_OK;
+	union acpi_object	*package = NULL;
+	union acpi_object	*element = NULL;
+	struct acpi_buffer	buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+	u32			i = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_evaluate_reference");
+
+	if (!list) {
+		return_ACPI_STATUS(AE_BAD_PARAMETER);
+	}
+
+	/* Evaluate object. */
+
+	status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
+	if (ACPI_FAILURE(status))
+		goto end;
+
+	package = (union acpi_object *) buffer.pointer;
+
+	if ((buffer.length == 0) || !package) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 
+			"No return object (len %X ptr %p)\n", 
+			buffer.length, package));
+		status = AE_BAD_DATA;
+		acpi_util_eval_error(handle, pathname, status);
+		goto end;
+	}
+	if (package->type != ACPI_TYPE_PACKAGE) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 
+			"Expecting a [Package], found type %X\n", 
+			package->type));
+		status = AE_BAD_DATA;
+		acpi_util_eval_error(handle, pathname, status);
+		goto end;
+	}
+	if (!package->package.count) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 
+			"[Package] has zero elements (%p)\n", 
+			package));
+		status = AE_BAD_DATA;
+		acpi_util_eval_error(handle, pathname, status);
+		goto end;
+	}
+
+	if (package->package.count > ACPI_MAX_HANDLES) {
+		return AE_NO_MEMORY;
+	}
+	list->count = package->package.count;
+
+	/* Extract package data. */
+
+	for (i = 0; i < list->count; i++) {
+
+		element = &(package->package.elements[i]);
+
+		if (element->type != ACPI_TYPE_ANY) {
+			status = AE_BAD_DATA;
+			ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 
+				"Expecting a [Reference] package element, found type %X\n",
+				element->type));
+			acpi_util_eval_error(handle, pathname, status);
+			break;
+		}
+
+		/* Get the  acpi_handle. */
+
+		list->handles[i] = element->reference.handle;
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found reference [%p]\n",
+			list->handles[i]));
+	}
+
+end:
+	if (ACPI_FAILURE(status)) {
+		list->count = 0;
+		//kfree(list->handles);
+	}
+
+	acpi_os_free(buffer.pointer);
+
+	return_ACPI_STATUS(status);
+}
+
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/atm/Config.in linux-2.4.22-pre2/drivers/atm/Config.in
--- linux-2.4.21/drivers/atm/Config.in	2001-11-13 17:19:41.000000000 +0000
+++ linux-2.4.22-pre2/drivers/atm/Config.in	2003-06-26 21:43:31.000000000 +0000
@@ -92,4 +92,10 @@
     fi
   fi
 fi
+if [ "$CONFIG_PCI" = "y" ]; then
+  tristate 'ForeRunner HE Series' CONFIG_ATM_HE
+  if [ "$CONFIG_ATM_HE" = "y" ]; then
+    bool 'Use S/UNI PHY driver' CONFIG_ATM_HE_USE_SUNI
+  fi
+fi
 endmenu
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/atm/Makefile linux-2.4.22-pre2/drivers/atm/Makefile
--- linux-2.4.21/drivers/atm/Makefile	2001-11-07 22:39:36.000000000 +0000
+++ linux-2.4.22-pre2/drivers/atm/Makefile	2003-06-26 21:43:11.000000000 +0000
@@ -52,9 +52,13 @@
     CONFIG_ATM_FORE200E_SBA_FW := sba200e_ecd.bin2
   endif
 endif
-
 obj-$(CONFIG_ATM_FORE200E) += fore_200e.o
 
+obj-$(CONFIG_ATM_HE)		+= he.o
+ifeq ($(CONFIG_ATM_HE_USE_SUNI),y)
+  obj-$(CONFIG_ATM_HE)		+= suni.o
+endif
+
 EXTRA_CFLAGS=-g
 
 list-multi	:= fore_200e.o
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/atm/ambassador.c linux-2.4.22-pre2/drivers/atm/ambassador.c
--- linux-2.4.21/drivers/atm/ambassador.c	2001-09-13 22:21:32.000000000 +0000
+++ linux-2.4.22-pre2/drivers/atm/ambassador.c	2003-06-26 21:43:12.000000000 +0000
@@ -290,12 +290,11 @@
 /********** microcode **********/
 
 #ifdef AMB_NEW_MICROCODE
-#define UCODE(x) UCODE1(atmsar12.,x)
+#define UCODE(x) UCODE2(atmsar12.x)
 #else
-#define UCODE(x) UCODE1(atmsar11.,x)
+#define UCODE(x) UCODE2(atmsar11.x)
 #endif
 #define UCODE2(x) #x
-#define UCODE1(x,y) UCODE2(x ## y)
 
 static u32 __initdata ucode_start = 
 #include UCODE(start)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/atm/he.c linux-2.4.22-pre2/drivers/atm/he.c
--- linux-2.4.21/drivers/atm/he.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/atm/he.c	2003-06-26 21:43:13.000000000 +0000
@@ -0,0 +1,3419 @@
+/* $Id: he.c,v 1.18 2003/05/06 22:57:15 chas Exp $ */
+
+/*
+
+  he.c
+
+  ForeRunnerHE ATM Adapter driver for ATM on Linux
+  Copyright (C) 1999-2001  Naval Research Laboratory
+
+  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
+
+*/
+
+/*
+
+  he.c
+
+  ForeRunnerHE ATM Adapter driver for ATM on Linux
+  Copyright (C) 1999-2001  Naval Research Laboratory
+
+  Permission to use, copy, modify and distribute this software and its
+  documentation is hereby granted, provided that both the copyright
+  notice and this permission notice appear in all copies of the software,
+  derivative works or modified versions, and any portions thereof, and
+  that both notices appear in supporting documentation.
+
+  NRL ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND
+  DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
+  RESULTING FROM THE USE OF THIS SOFTWARE.
+
+  This driver was written using the "Programmer's Reference Manual for
+  ForeRunnerHE(tm)", MANU0361-01 - Rev. A, 08/21/98.
+
+  AUTHORS:
+	chas williams <chas@cmf.nrl.navy.mil>
+	eric kinzie <ekinzie@cmf.nrl.navy.mil>
+
+  NOTES:
+	4096 supported 'connections'
+	group 0 is used for all traffic
+	interrupt queue 0 is used for all interrupts
+	aal0 support for receive only
+
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/skbuff.h>
+#include <linux/pci.h>
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/string.h>
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/sched.h>
+#include <linux/timer.h>
+#include <linux/interrupt.h>
+#include <asm/io.h>
+#include <asm/byteorder.h>
+#include <asm/uaccess.h>
+
+#include <linux/atmdev.h>
+#include <linux/atm.h>
+#include <linux/sonet.h>
+#ifndef ATM_OC12_PCR
+#define ATM_OC12_PCR (622080000/1080*1040/8/53)
+#endif
+
+#ifdef BUS_INT_WAR
+void sn_add_polled_interrupt(int irq, int interval);
+void sn_delete_polled_interrupt(int irq);
+#endif
+
+#define USE_TASKLET
+#define USE_HE_FIND_VCC
+#undef USE_SCATTERGATHER
+#undef USE_CHECKSUM_HW			/* still confused about this */
+#define USE_RBPS
+#undef USE_RBPS_POOL			/* if memory is tight try this */
+#undef USE_RBPL_POOL			/* if memory is tight try this */
+#define USE_TPD_POOL
+/* #undef CONFIG_ATM_HE_USE_SUNI */
+
+/* 2.2 kernel support */
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,43)
+#define dev_kfree_skb_irq(skb)		dev_kfree_skb(skb)
+#define dev_kfree_skb_any(skb)		dev_kfree_skb(skb)
+#undef USE_TASKLET
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18)
+#define set_current_state(x)		current->state = (x);
+#endif
+
+#include "he.h"
+
+#include "suni.h"
+
+#include <linux/atm_he.h>
+
+#define hprintk(fmt,args...)	printk(DEV_LABEL "%d: " fmt, he_dev->number, args)
+#define hprintk1(fmt)		printk(DEV_LABEL "%d: " fmt, he_dev->number)
+
+#undef DEBUG
+#ifdef DEBUG
+#define HPRINTK(fmt,args...)	hprintk(fmt,args)
+#define HPRINTK1(fmt)		hprintk1(fmt)
+#else
+#define HPRINTK(fmt,args...)
+#define HPRINTK1(fmt,args...)
+#endif /* DEBUG */
+
+
+/* version definition */
+
+static char *version = "$Id: he.c,v 1.18 2003/05/06 22:57:15 chas Exp $";
+
+/* defines */
+#define ALIGN_ADDRESS(addr, alignment) \
+	((((unsigned long) (addr)) + (((unsigned long) (alignment)) - 1)) & ~(((unsigned long) (alignment)) - 1))
+
+/* declarations */
+
+static int he_open(struct atm_vcc *vcc, short vpi, int vci);
+static void he_close(struct atm_vcc *vcc);
+static int he_send(struct atm_vcc *vcc, struct sk_buff *skb);
+static int he_sg_send(struct atm_vcc *vcc, unsigned long start, unsigned long size);
+static int he_ioctl(struct atm_dev *dev, unsigned int cmd, void *arg);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,69)
+static irqreturn_t he_irq_handler(int irq, void *dev_id, struct pt_regs *regs);
+#else
+static void he_irq_handler(int irq, void *dev_id, struct pt_regs *regs);
+#endif
+static void he_tasklet(unsigned long data);
+static int he_proc_read(struct atm_dev *dev,loff_t *pos,char *page);
+static int he_start(struct atm_dev *dev);
+static void he_stop(struct he_dev *dev);
+static void he_phy_put(struct atm_dev *, unsigned char, unsigned long);
+static unsigned char he_phy_get(struct atm_dev *, unsigned long);
+
+static u8 read_prom_byte(struct he_dev *he_dev, int addr);
+
+/* globals */
+
+struct he_dev *he_devs = NULL;
+static short disable64 = -1;
+static short nvpibits = -1;
+static short nvcibits = -1;
+static short rx_skb_reserve = 16;
+static short irq_coalesce = 1;
+static short sdh = 1;
+
+static struct atmdev_ops he_ops =
+{
+   open:	he_open,
+   close:	he_close,	
+   ioctl:	he_ioctl,	
+   send:	he_send,
+   sg_send:	he_sg_send,	
+   phy_put:	he_phy_put,
+   phy_get:	he_phy_get,
+   proc_read:	he_proc_read,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,1)
+   owner:	THIS_MODULE
+#endif
+};
+
+/* see the comments in he.h about global_lock */
+
+#define HE_SPIN_LOCK(dev, flags)	spin_lock_irqsave(&(dev)->global_lock, flags)
+#define HE_SPIN_UNLOCK(dev, flags)	spin_unlock_irqrestore(&(dev)->global_lock, flags)
+
+#define he_writel(dev, val, reg)	do { writel(val, (dev)->membase + (reg)); wmb(); } while(0)
+#define he_readl(dev, reg)		readl((dev)->membase + (reg))
+
+/* section 2.12 connection memory access */
+
+static __inline__ void
+he_writel_internal(struct he_dev *he_dev, unsigned val, unsigned addr,
+								unsigned flags)
+{
+	he_writel(he_dev, val, CON_DAT);
+#ifdef CONFIG_IA64_SGI_SN2
+	(void) he_readl(he_dev, CON_DAT);
+#endif
+	he_writel(he_dev, flags | CON_CTL_WRITE | CON_CTL_ADDR(addr), CON_CTL);
+	while(he_readl(he_dev, CON_CTL) & CON_CTL_BUSY);
+}
+
+#define he_writel_rcm(dev, val, reg) 				\
+			he_writel_internal(dev, val, reg, CON_CTL_RCM)
+
+#define he_writel_tcm(dev, val, reg) 				\
+			he_writel_internal(dev, val, reg, CON_CTL_TCM)
+
+#define he_writel_mbox(dev, val, reg) 				\
+			he_writel_internal(dev, val, reg, CON_CTL_MBOX)
+
+static unsigned
+he_readl_internal(struct he_dev *he_dev, unsigned addr, unsigned flags)
+{
+	he_writel(he_dev, flags | CON_CTL_READ | CON_CTL_ADDR(addr), CON_CTL);
+	while(he_readl(he_dev, CON_CTL) & CON_CTL_BUSY);
+	return he_readl(he_dev, CON_DAT);
+}
+
+#define he_readl_rcm(dev, reg) \
+			he_readl_internal(dev, reg, CON_CTL_RCM)
+
+#define he_readl_tcm(dev, reg) \
+			he_readl_internal(dev, reg, CON_CTL_TCM)
+
+#define he_readl_mbox(dev, reg) \
+			he_readl_internal(dev, reg, CON_CTL_MBOX)
+
+
+/* figure 2.2 connection id */
+
+#define he_mkcid(dev, vpi, vci)		(((vpi<<(dev)->vcibits) | vci) & 0x1fff)
+
+/* 2.5.1 per connection transmit state registers */
+
+#define he_writel_tsr0(dev, val, cid) \
+		he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 0)
+#define he_readl_tsr0(dev, cid) \
+		he_readl_tcm(dev, CONFIG_TSRA | (cid<<3) | 0)
+
+#define he_writel_tsr1(dev, val, cid) \
+		he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 1)
+
+#define he_writel_tsr2(dev, val, cid) \
+		he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 2)
+
+#define he_writel_tsr3(dev, val, cid) \
+		he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 3)
+
+#define he_writel_tsr4(dev, val, cid) \
+		he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 4)
+
+	/* from page 2-20
+	 *
+	 * NOTE While the transmit connection is active, bits 23 through 0
+	 *      of this register must not be written by the host.  Byte
+	 *      enables should be used during normal operation when writing
+	 *      the most significant byte.
+	 */
+
+#define he_writel_tsr4_upper(dev, val, cid) \
+		he_writel_internal(dev, val, CONFIG_TSRA | (cid<<3) | 4, \
+							CON_CTL_TCM \
+							| CON_BYTE_DISABLE_2 \
+							| CON_BYTE_DISABLE_1 \
+							| CON_BYTE_DISABLE_0)
+
+#define he_readl_tsr4(dev, cid) \
+		he_readl_tcm(dev, CONFIG_TSRA | (cid<<3) | 4)
+
+#define he_writel_tsr5(dev, val, cid) \
+		he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 5)
+
+#define he_writel_tsr6(dev, val, cid) \
+		he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 6)
+
+#define he_writel_tsr7(dev, val, cid) \
+		he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 7)
+
+
+#define he_writel_tsr8(dev, val, cid) \
+		he_writel_tcm(dev, val, CONFIG_TSRB | (cid<<2) | 0)
+
+#define he_writel_tsr9(dev, val, cid) \
+		he_writel_tcm(dev, val, CONFIG_TSRB | (cid<<2) | 1)
+
+#define he_writel_tsr10(dev, val, cid) \
+		he_writel_tcm(dev, val, CONFIG_TSRB | (cid<<2) | 2)
+
+#define he_writel_tsr11(dev, val, cid) \
+		he_writel_tcm(dev, val, CONFIG_TSRB | (cid<<2) | 3)
+
+
+#define he_writel_tsr12(dev, val, cid) \
+		he_writel_tcm(dev, val, CONFIG_TSRC | (cid<<1) | 0)
+
+#define he_writel_tsr13(dev, val, cid) \
+		he_writel_tcm(dev, val, CONFIG_TSRC | (cid<<1) | 1)
+
+
+#define he_writel_tsr14(dev, val, cid) \
+		he_writel_tcm(dev, val, CONFIG_TSRD | cid)
+
+#define he_writel_tsr14_upper(dev, val, cid) \
+		he_writel_internal(dev, val, CONFIG_TSRD | cid, \
+							CON_CTL_TCM \
+							| CON_BYTE_DISABLE_2 \
+							| CON_BYTE_DISABLE_1 \
+							| CON_BYTE_DISABLE_0)
+
+/* 2.7.1 per connection receive state registers */
+
+#define he_writel_rsr0(dev, val, cid) \
+		he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 0)
+#define he_readl_rsr0(dev, cid) \
+		he_readl_rcm(dev, 0x00000 | (cid<<3) | 0)
+
+#define he_writel_rsr1(dev, val, cid) \
+		he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 1)
+
+#define he_writel_rsr2(dev, val, cid) \
+		he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 2)
+
+#define he_writel_rsr3(dev, val, cid) \
+		he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 3)
+
+#define he_writel_rsr4(dev, val, cid) \
+		he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 4)
+
+#define he_writel_rsr5(dev, val, cid) \
+		he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 5)
+
+#define he_writel_rsr6(dev, val, cid) \
+		he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 6)
+
+#define he_writel_rsr7(dev, val, cid) \
+		he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 7)
+
+static __inline__ struct atm_vcc*
+he_find_vcc(struct he_dev *he_dev, unsigned cid)
+{
+	struct atm_vcc *vcc;
+	short vpi;
+	int vci;
+
+	vpi = cid >> he_dev->vcibits;
+	vci = cid & ((1<<he_dev->vcibits)-1);
+
+	for (vcc = he_dev->atm_dev->vccs; vcc; vcc = vcc->next)
+		if (vcc->vci == vci && vcc->vpi == vpi
+			&& vcc->qos.rxtp.traffic_class != ATM_NONE) return vcc;
+
+	return NULL;
+}
+
+static int __devinit
+he_init_one(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent)
+{
+	struct atm_dev *atm_dev;
+	struct he_dev *he_dev;
+
+	printk(KERN_INFO "he: %s\n", version);
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,43)
+	if (pci_enable_device(pci_dev)) return -EIO;
+#endif
+	if (pci_set_dma_mask(pci_dev, HE_DMA_MASK) != 0)
+	{
+		printk(KERN_WARNING "he: no suitable dma available\n");
+		return -EIO;
+	}
+
+	atm_dev = atm_dev_register(DEV_LABEL, &he_ops, -1, 0);
+	if (!atm_dev) return -ENODEV;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,3)
+	pci_set_drvdata(pci_dev, atm_dev);
+#else
+	pci_dev->driver_data = atm_dev;
+#endif
+
+	he_dev = (struct he_dev *) kmalloc(sizeof(struct he_dev),
+							GFP_KERNEL);
+	if (!he_dev) return -ENOMEM;
+	memset(he_dev, 0, sizeof(struct he_dev));
+
+	he_dev->pci_dev = pci_dev;
+	he_dev->atm_dev = atm_dev;
+	he_dev->atm_dev->dev_data = he_dev;
+	HE_DEV(atm_dev) = he_dev;
+	he_dev->number = atm_dev->number;	/* was devs */
+	if (he_start(atm_dev)) {
+		atm_dev_deregister(atm_dev);
+		he_stop(he_dev);
+		kfree(he_dev);
+		return -ENODEV;
+	}
+	he_dev->next = NULL;
+	if (he_devs) he_dev->next = he_devs;
+	he_devs = he_dev;
+
+	return 0;
+}
+
+static void __devexit
+he_remove_one (struct pci_dev *pci_dev)
+{
+	struct atm_dev *atm_dev;
+	struct he_dev *he_dev;
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,3)
+	atm_dev = pci_get_drvdata(pci_dev);
+#else
+	atm_dev = pci_dev->driver_data;
+#endif
+	he_dev = HE_DEV(atm_dev);
+
+	/* need to remove from he_devs */
+
+	he_stop(he_dev);
+	atm_dev_deregister(atm_dev);
+	kfree(he_dev);
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,3)
+	pci_set_drvdata(pci_dev, NULL);
+#else
+	pci_dev->driver_data = NULL;
+#endif
+}
+
+
+static unsigned
+rate_to_atmf(unsigned rate)		/* cps to atm forum format */
+{
+#define NONZERO (1<<14)
+
+        unsigned exp = 0;
+
+        if (rate == 0) return(0);
+
+        rate <<= 9;
+        while (rate > 0x3ff)
+        {
+                ++exp;
+                rate >>= 1;
+        }
+
+        return (NONZERO | (exp << 9) | (rate & 0x1ff));
+}
+
+static void __init
+he_init_rx_lbfp0(struct he_dev *he_dev)
+{
+        unsigned i, lbm_offset, lbufd_index, lbuf_addr, lbuf_count;
+        unsigned lbufs_per_row = he_dev->cells_per_row / he_dev->cells_per_lbuf;
+        unsigned lbuf_bufsize = he_dev->cells_per_lbuf * ATM_CELL_PAYLOAD;
+        unsigned row_offset = he_dev->r0_startrow * he_dev->bytes_per_row;
+        
+	lbufd_index = 0;
+        lbm_offset = he_readl(he_dev, RCMLBM_BA);
+
+	he_writel(he_dev, lbufd_index, RLBF0_H);
+
+        for (i = 0, lbuf_count = 0; i < he_dev->r0_numbuffs; ++i)
+        {
+		lbufd_index += 2;
+                lbuf_addr = (row_offset + (lbuf_count * lbuf_bufsize)) / 32;
+
+		he_writel_rcm(he_dev, lbuf_addr, lbm_offset);
+		he_writel_rcm(he_dev, lbufd_index, lbm_offset + 1);
+
+                if (++lbuf_count == lbufs_per_row)
+                {
+                        lbuf_count = 0;
+                        row_offset += he_dev->bytes_per_row;
+                }
+		lbm_offset += 4;
+        }
+                
+        he_writel(he_dev, lbufd_index - 2, RLBF0_T);
+	he_writel(he_dev, he_dev->r0_numbuffs, RLBF0_C);
+}
+
+static void __init
+he_init_rx_lbfp1(struct he_dev *he_dev)
+{
+        unsigned i, lbm_offset, lbufd_index, lbuf_addr, lbuf_count;
+        unsigned lbufs_per_row = he_dev->cells_per_row / he_dev->cells_per_lbuf;
+        unsigned lbuf_bufsize = he_dev->cells_per_lbuf * ATM_CELL_PAYLOAD;
+        unsigned row_offset = he_dev->r1_startrow * he_dev->bytes_per_row;
+        
+	lbufd_index = 1;
+        lbm_offset = he_readl(he_dev, RCMLBM_BA) + (2 * lbufd_index);
+
+	he_writel(he_dev, lbufd_index, RLBF1_H);
+
+        for (i = 0, lbuf_count = 0; i < he_dev->r1_numbuffs; ++i)
+        {
+		lbufd_index += 2;
+                lbuf_addr = (row_offset + (lbuf_count * lbuf_bufsize)) / 32;
+
+		he_writel_rcm(he_dev, lbuf_addr, lbm_offset);
+		he_writel_rcm(he_dev, lbufd_index, lbm_offset + 1);
+
+                if (++lbuf_count == lbufs_per_row)
+                {
+                        lbuf_count = 0;
+                        row_offset += he_dev->bytes_per_row;
+                }
+		lbm_offset += 4;
+        }
+                
+        he_writel(he_dev, lbufd_index - 2, RLBF1_T);
+	he_writel(he_dev, he_dev->r1_numbuffs, RLBF1_C);
+}
+
+static void __init
+he_init_tx_lbfp(struct he_dev *he_dev)
+{
+        unsigned i, lbm_offset, lbufd_index, lbuf_addr, lbuf_count;
+        unsigned lbufs_per_row = he_dev->cells_per_row / he_dev->cells_per_lbuf;
+        unsigned lbuf_bufsize = he_dev->cells_per_lbuf * ATM_CELL_PAYLOAD;
+        unsigned row_offset = he_dev->tx_startrow * he_dev->bytes_per_row;
+        
+	lbufd_index = he_dev->r0_numbuffs + he_dev->r1_numbuffs;
+        lbm_offset = he_readl(he_dev, RCMLBM_BA) + (2 * lbufd_index);
+
+	he_writel(he_dev, lbufd_index, TLBF_H);
+
+        for (i = 0, lbuf_count = 0; i < he_dev->tx_numbuffs; ++i)
+        {
+		lbufd_index += 1;
+                lbuf_addr = (row_offset + (lbuf_count * lbuf_bufsize)) / 32;
+
+		he_writel_rcm(he_dev, lbuf_addr, lbm_offset);
+		he_writel_rcm(he_dev, lbufd_index, lbm_offset + 1);
+
+                if (++lbuf_count == lbufs_per_row)
+                {
+                        lbuf_count = 0;
+                        row_offset += he_dev->bytes_per_row;
+                }
+		lbm_offset += 2;
+        }
+                
+        he_writel(he_dev, lbufd_index - 1, TLBF_T);
+}
+
+static int __init
+he_init_tpdrq(struct he_dev *he_dev)
+{
+	he_dev->tpdrq_base = pci_alloc_consistent(he_dev->pci_dev,
+		CONFIG_TPDRQ_SIZE * sizeof(struct he_tpdrq), &he_dev->tpdrq_phys);
+	if (he_dev->tpdrq_base == NULL) 
+	{
+		hprintk1("failed to alloc tpdrq\n");
+		return -ENOMEM;
+	}
+	memset(he_dev->tpdrq_base, 0,
+				CONFIG_TPDRQ_SIZE * sizeof(struct he_tpdrq));
+
+	he_dev->tpdrq_tail = he_dev->tpdrq_base;
+	he_dev->tpdrq_head = he_dev->tpdrq_base;
+
+	he_writel(he_dev, he_dev->tpdrq_phys, TPDRQ_B_H);
+	he_writel(he_dev, 0, TPDRQ_T);	
+	he_writel(he_dev, CONFIG_TPDRQ_SIZE - 1, TPDRQ_S);
+
+	return 0;
+}
+
+static void __init
+he_init_cs_block(struct he_dev *he_dev)
+{
+	unsigned clock, rate, delta;
+	int reg;
+
+	/* 5.1.7 cs block initialization */
+
+	for(reg = 0; reg < 0x20; ++reg)
+		he_writel_mbox(he_dev, 0x0, CS_STTIM0 + reg);
+
+	/* rate grid timer reload values */
+
+	clock = he_is622(he_dev) ? 66667000 : 50000000;
+	rate = he_dev->atm_dev->link_rate;
+	delta = rate / 16 / 2;
+
+	for(reg = 0; reg < 0x10; ++reg)
+	{
+		/* 2.4 internal transmit function
+		 *
+	 	 * we initialize the first row in the rate grid.
+		 * values are period (in clock cycles) of timer
+		 */
+		unsigned period = clock / rate;
+
+		he_writel_mbox(he_dev, period, CS_TGRLD0 + reg);
+		rate -= delta;
+	}
+
+	if (he_is622(he_dev))
+	{
+		/* table 5.2 (4 cells per lbuf) */
+		he_writel_mbox(he_dev, 0x000800fa, CS_ERTHR0);
+		he_writel_mbox(he_dev, 0x000c33cb, CS_ERTHR1);
+		he_writel_mbox(he_dev, 0x0010101b, CS_ERTHR2);
+		he_writel_mbox(he_dev, 0x00181dac, CS_ERTHR3);
+		he_writel_mbox(he_dev, 0x00280600, CS_ERTHR4);
+
+		/* table 5.3, 5.4, 5.5, 5.6, 5.7 */
+		he_writel_mbox(he_dev, 0x023de8b3, CS_ERCTL0);
+		he_writel_mbox(he_dev, 0x1801, CS_ERCTL1);
+		he_writel_mbox(he_dev, 0x68b3, CS_ERCTL2);
+		he_writel_mbox(he_dev, 0x1280, CS_ERSTAT0);
+		he_writel_mbox(he_dev, 0x68b3, CS_ERSTAT1);
+		he_writel_mbox(he_dev, 0x14585, CS_RTFWR);
+
+		he_writel_mbox(he_dev, 0x4680, CS_RTATR);
+
+		/* table 5.8 */
+		he_writel_mbox(he_dev, 0x00159ece, CS_TFBSET);
+		he_writel_mbox(he_dev, 0x68b3, CS_WCRMAX);
+		he_writel_mbox(he_dev, 0x5eb3, CS_WCRMIN);
+		he_writel_mbox(he_dev, 0xe8b3, CS_WCRINC);
+		he_writel_mbox(he_dev, 0xdeb3, CS_WCRDEC);
+		he_writel_mbox(he_dev, 0x68b3, CS_WCRCEIL);
+
+		/* table 5.9 */
+		he_writel_mbox(he_dev, 0x5, CS_OTPPER);
+		he_writel_mbox(he_dev, 0x14, CS_OTWPER);
+	}
+	else
+	{
+		/* table 5.1 (4 cells per lbuf) */
+		he_writel_mbox(he_dev, 0x000400ea, CS_ERTHR0);
+		he_writel_mbox(he_dev, 0x00063388, CS_ERTHR1);
+		he_writel_mbox(he_dev, 0x00081018, CS_ERTHR2);
+		he_writel_mbox(he_dev, 0x000c1dac, CS_ERTHR3);
+		he_writel_mbox(he_dev, 0x0014051a, CS_ERTHR4);
+
+		/* table 5.3, 5.4, 5.5, 5.6, 5.7 */
+		he_writel_mbox(he_dev, 0x0235e4b1, CS_ERCTL0);
+		he_writel_mbox(he_dev, 0x4701, CS_ERCTL1);
+		he_writel_mbox(he_dev, 0x64b1, CS_ERCTL2);
+		he_writel_mbox(he_dev, 0x1280, CS_ERSTAT0);
+		he_writel_mbox(he_dev, 0x64b1, CS_ERSTAT1);
+		he_writel_mbox(he_dev, 0xf424, CS_RTFWR);
+
+		he_writel_mbox(he_dev, 0x4680, CS_RTATR);
+
+		/* table 5.8 */
+		he_writel_mbox(he_dev, 0x000563b7, CS_TFBSET);
+		he_writel_mbox(he_dev, 0x64b1, CS_WCRMAX);
+		he_writel_mbox(he_dev, 0x5ab1, CS_WCRMIN);
+		he_writel_mbox(he_dev, 0xe4b1, CS_WCRINC);
+		he_writel_mbox(he_dev, 0xdab1, CS_WCRDEC);
+		he_writel_mbox(he_dev, 0x64b1, CS_WCRCEIL);
+
+		/* table 5.9 */
+		he_writel_mbox(he_dev, 0x6, CS_OTPPER);
+		he_writel_mbox(he_dev, 0x1e, CS_OTWPER);
+
+	}
+
+	he_writel_mbox(he_dev, 0x8, CS_OTTLIM);
+
+	for(reg = 0; reg < 0x8; ++reg)
+		he_writel_mbox(he_dev, 0x0, CS_HGRRT0 + reg);
+
+}
+
+static void __init
+he_init_cs_block_rcm(struct he_dev *he_dev)
+{
+	unsigned rategrid[16][16];
+	unsigned rate, delta;
+	int i, j, reg;
+
+	unsigned rate_atmf, exp, man;
+	unsigned long long rate_cps;
+        int mult, buf, buf_limit = 4;
+
+	/* initialize rate grid group table */
+
+	for (reg = 0x0; reg < 0xff; ++reg)
+		he_writel_rcm(he_dev, 0x0, CONFIG_RCMABR + reg);
+
+	/* initialize rate controller groups */
+
+	for (reg = 0x100; reg < 0x1ff; ++reg)
+		he_writel_rcm(he_dev, 0x0, CONFIG_RCMABR + reg);
+	
+	/* initialize tNrm lookup table */
+
+	/* the manual makes reference to a routine in a sample driver
+	   for proper configuration; fortunately, we only need this
+	   in order to support abr connection */
+	
+	/* initialize rate to group table */
+
+	rate = he_dev->atm_dev->link_rate;
+	delta = rate / 32;
+
+	/*
+	 * 2.4 transmit internal functions
+	 * 
+	 * we construct a copy of the rate grid used by the scheduler
+	 * in order to construct the rate to group table below
+	 */
+
+	for (j = 0; j < 16; j++)
+	{
+		rategrid[0][j] = rate;
+		rate -= delta;
+	}
+
+	for (i = 1; i < 16; i++)
+		for (j = 0; j < 16; j++)
+			if (i > 14)
+				rategrid[i][j] = rategrid[i - 1][j] / 4;
+			else
+				rategrid[i][j] = rategrid[i - 1][j] / 2;
+
+	/*
+	 * 2.4 transmit internal function
+	 *
+	 * this table maps the upper 5 bits of exponent and mantissa
+	 * of the atm forum representation of the rate into an index
+	 * on rate grid  
+	 */
+
+	rate_atmf = 0;
+	while (rate_atmf < 0x400)
+	{
+		man = (rate_atmf & 0x1f) << 4;
+		exp = rate_atmf >> 5;
+
+		/* 
+			instead of '/ 512', use '>> 9' to prevent a call
+			to divdu3 on x86 platforms
+		*/
+		rate_cps = (unsigned long long) (1 << exp) * (man + 512) >> 9;
+
+		if (rate_cps < 10) rate_cps = 10;
+				/* 2.2.1 minimum payload rate is 10 cps */
+
+		for (i = 255; i > 0; i--)
+			if (rategrid[i/16][i%16] >= rate_cps) break;
+				/* pick nearest rate instead? */
+
+		/*
+		 * each table entry is 16 bits: (rate grid index (8 bits)
+		 * and a buffer limit (8 bits)
+		 * there are two table entries in each 32-bit register
+		 */
+
+#ifdef notdef
+                buf = rate_cps * he_dev->tx_numbuffs /
+				(he_dev->atm_dev->link_rate * 2);
+#else
+		/* this is pretty, but avoids _divdu3 and is mostly correct */
+                buf = 0;
+                mult = he_dev->atm_dev->link_rate / ATM_OC3_PCR;
+                if (rate_cps > (68 * mult)) buf = 1;
+                if (rate_cps > (136 * mult)) buf = 2;
+                if (rate_cps > (204 * mult)) buf = 3;
+                if (rate_cps > (272 * mult)) buf = 4;
+#endif
+                if (buf > buf_limit) buf = buf_limit;
+		reg = (reg<<16) | ((i<<8) | buf);
+
+#define RTGTBL_OFFSET 0x400
+	  
+		if (rate_atmf & 0x1)
+			he_writel_rcm(he_dev, reg,
+				CONFIG_RCMABR + RTGTBL_OFFSET + (rate_atmf>>1));
+
+		++rate_atmf;
+	}
+}
+
+static int __init
+he_init_group(struct he_dev *he_dev, int group)
+{
+	int i;
+
+#ifdef USE_RBPS
+	/* small buffer pool */
+#ifdef USE_RBPS_POOL
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,44)
+	he_dev->rbps_pool = pci_pool_create("rbps", he_dev->pci_dev,
+			CONFIG_RBPS_BUFSIZE, 8, 0, SLAB_KERNEL);
+#else
+	he_dev->rbps_pool = pci_pool_create("rbps", he_dev->pci_dev,
+			CONFIG_RBPS_BUFSIZE, 8, 0);
+#endif
+	if (he_dev->rbps_pool == NULL)
+	{
+		hprintk1("unable to create rbps pages\n");
+		return -ENOMEM;
+	}
+#else /* !USE_RBPS_POOL */
+	he_dev->rbps_pages = pci_alloc_consistent(he_dev->pci_dev,
+		CONFIG_RBPS_SIZE * CONFIG_RBPS_BUFSIZE, &he_dev->rbps_pages_phys);
+	if (he_dev->rbps_pages == NULL) {
+		hprintk1("unable to create rbps page pool\n");
+		return -ENOMEM;
+	}
+#endif /* USE_RBPS_POOL */
+
+	he_dev->rbps_base = pci_alloc_consistent(he_dev->pci_dev,
+		CONFIG_RBPS_SIZE * sizeof(struct he_rbp), &he_dev->rbps_phys);
+	if (he_dev->rbps_base == NULL)
+	{
+		hprintk1("failed to alloc rbps\n");
+		return -ENOMEM;
+	}
+	memset(he_dev->rbps_base, 0, CONFIG_RBPS_SIZE * sizeof(struct he_rbp));
+	he_dev->rbps_virt = kmalloc(CONFIG_RBPS_SIZE * sizeof(struct he_virt), GFP_KERNEL);
+
+	for (i = 0; i < CONFIG_RBPS_SIZE; ++i)
+	{
+		dma_addr_t dma_handle;
+		void *cpuaddr;
+
+#ifdef USE_RBPS_POOL 
+		cpuaddr = pci_pool_alloc(he_dev->rbps_pool, SLAB_KERNEL|SLAB_DMA, &dma_handle);
+		if (cpuaddr == NULL)
+			return -ENOMEM;
+#else
+		cpuaddr = he_dev->rbps_pages + (i * CONFIG_RBPS_BUFSIZE);
+		dma_handle = he_dev->rbps_pages_phys + (i * CONFIG_RBPS_BUFSIZE);
+#endif
+
+		he_dev->rbps_virt[i].virt = cpuaddr;
+		he_dev->rbps_base[i].status = RBP_LOANED | RBP_SMALLBUF | (i << RBP_INDEX_OFF);
+		he_dev->rbps_base[i].phys = dma_handle;
+
+	}
+	he_dev->rbps_tail = &he_dev->rbps_base[CONFIG_RBPS_SIZE-1];
+
+	he_writel(he_dev, he_dev->rbps_phys, G0_RBPS_S + (group * 32));
+	he_writel(he_dev, RBPS_MASK(he_dev->rbps_tail),
+						G0_RBPS_T + (group * 32));
+	he_writel(he_dev, CONFIG_RBPS_BUFSIZE/4,
+						G0_RBPS_BS + (group * 32));
+	he_writel(he_dev,
+			RBP_THRESH(CONFIG_RBPS_THRESH) |
+			RBP_QSIZE(CONFIG_RBPS_SIZE-1) |
+			RBP_INT_ENB,
+						G0_RBPS_QI + (group * 32));
+#else /* !USE_RBPS */
+	he_writel(he_dev, 0x0, G0_RBPS_S + (group * 32));
+	he_writel(he_dev, 0x0, G0_RBPS_T + (group * 32));
+	he_writel(he_dev, 0x0, G0_RBPS_QI + (group * 32));
+	he_writel(he_dev, RBP_THRESH(0x1) | RBP_QSIZE(0x0),
+						G0_RBPS_BS + (group * 32));
+#endif /* USE_RBPS */
+
+	/* large buffer pool */
+#ifdef USE_RBPL_POOL
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,44)
+	he_dev->rbpl_pool = pci_pool_create("rbpl", he_dev->pci_dev,
+			CONFIG_RBPL_BUFSIZE, 8, 0, SLAB_KERNEL);
+#else
+	he_dev->rbpl_pool = pci_pool_create("rbpl", he_dev->pci_dev,
+			CONFIG_RBPL_BUFSIZE, 8, 0);
+#endif
+	if (he_dev->rbpl_pool == NULL)
+	{
+		hprintk1("unable to create rbpl pool\n");
+		return -ENOMEM;
+	}
+#else /* !USE_RBPL_POOL */
+	he_dev->rbpl_pages = (void *) pci_alloc_consistent(he_dev->pci_dev,
+		CONFIG_RBPL_SIZE * CONFIG_RBPL_BUFSIZE, &he_dev->rbpl_pages_phys);
+	if (he_dev->rbpl_pages == NULL)
+	{
+		hprintk1("unable to create rbpl pages\n");
+		return -ENOMEM;
+	}
+#endif /* USE_RBPL_POOL */
+
+	he_dev->rbpl_base = pci_alloc_consistent(he_dev->pci_dev,
+		CONFIG_RBPL_SIZE * sizeof(struct he_rbp), &he_dev->rbpl_phys);
+	if (he_dev->rbpl_base == NULL)
+	{
+		hprintk1("failed to alloc rbpl\n");
+		return -ENOMEM;
+	}
+	memset(he_dev->rbpl_base, 0, CONFIG_RBPL_SIZE * sizeof(struct he_rbp));
+	he_dev->rbpl_virt = kmalloc(CONFIG_RBPL_SIZE * sizeof(struct he_virt), GFP_KERNEL);
+
+	for (i = 0; i < CONFIG_RBPL_SIZE; ++i)
+	{
+		dma_addr_t dma_handle;
+		void *cpuaddr;
+
+#ifdef USE_RBPL_POOL
+		cpuaddr = pci_pool_alloc(he_dev->rbpl_pool, SLAB_KERNEL|SLAB_DMA, &dma_handle);
+		if (cpuaddr == NULL)
+			return -ENOMEM;
+#else
+		cpuaddr = he_dev->rbpl_pages + (i * CONFIG_RBPL_BUFSIZE);
+		dma_handle = he_dev->rbpl_pages_phys + (i * CONFIG_RBPL_BUFSIZE);
+#endif
+
+		he_dev->rbpl_virt[i].virt = cpuaddr;
+		he_dev->rbpl_base[i].status = RBP_LOANED | (i << RBP_INDEX_OFF);
+		he_dev->rbpl_base[i].phys = dma_handle;
+
+	}
+	he_dev->rbpl_tail = &he_dev->rbpl_base[CONFIG_RBPL_SIZE-1];
+
+	he_writel(he_dev, he_dev->rbpl_phys, G0_RBPL_S + (group * 32));
+	he_writel(he_dev, RBPL_MASK(he_dev->rbpl_tail),
+						G0_RBPL_T + (group * 32));
+	he_writel(he_dev, CONFIG_RBPL_BUFSIZE/4,
+						G0_RBPL_BS + (group * 32));
+	he_writel(he_dev,
+			RBP_THRESH(CONFIG_RBPL_THRESH) |
+			RBP_QSIZE(CONFIG_RBPL_SIZE-1) |
+			RBP_INT_ENB,
+						G0_RBPL_QI + (group * 32));
+
+	/* rx buffer ready queue */
+
+	he_dev->rbrq_base = pci_alloc_consistent(he_dev->pci_dev,
+		CONFIG_RBRQ_SIZE * sizeof(struct he_rbrq), &he_dev->rbrq_phys);
+	if (he_dev->rbrq_base == NULL)
+	{
+		hprintk1("failed to allocate rbrq\n");
+		return -ENOMEM;
+	}
+	memset(he_dev->rbrq_base, 0, CONFIG_RBRQ_SIZE * sizeof(struct he_rbrq));
+
+	he_dev->rbrq_head = he_dev->rbrq_base;
+	he_writel(he_dev, he_dev->rbrq_phys, G0_RBRQ_ST + (group * 16));
+	he_writel(he_dev, 0, G0_RBRQ_H + (group * 16));
+	he_writel(he_dev,
+		RBRQ_THRESH(CONFIG_RBRQ_THRESH) | RBRQ_SIZE(CONFIG_RBRQ_SIZE-1),
+						G0_RBRQ_Q + (group * 16));
+	if (irq_coalesce)
+	{
+		hprintk1("coalescing interrupts\n");
+		he_writel(he_dev, RBRQ_TIME(768) | RBRQ_COUNT(7),
+						G0_RBRQ_I + (group * 16));
+	}
+	else
+		he_writel(he_dev, RBRQ_TIME(0) | RBRQ_COUNT(1),
+						G0_RBRQ_I + (group * 16));
+
+	/* tx buffer ready queue */
+
+	he_dev->tbrq_base = pci_alloc_consistent(he_dev->pci_dev,
+		CONFIG_TBRQ_SIZE * sizeof(struct he_tbrq), &he_dev->tbrq_phys);
+	if (he_dev->tbrq_base == NULL)
+	{
+		hprintk1("failed to allocate tbrq\n");
+		return -ENOMEM;
+	}
+	memset(he_dev->tbrq_base, 0, CONFIG_TBRQ_SIZE * sizeof(struct he_tbrq));
+
+	he_dev->tbrq_head = he_dev->tbrq_base;
+
+	he_writel(he_dev, he_dev->tbrq_phys, G0_TBRQ_B_T + (group * 16));
+	he_writel(he_dev, 0, G0_TBRQ_H + (group * 16));
+	he_writel(he_dev, CONFIG_TBRQ_SIZE - 1, G0_TBRQ_S + (group * 16));
+	he_writel(he_dev, CONFIG_TBRQ_THRESH, G0_TBRQ_THRESH + (group * 16));
+
+	return 0;
+}
+
+static int __init
+he_init_irq(struct he_dev *he_dev)
+{
+	int i;
+
+	/* 2.9.3.5  tail offset for each interrupt queue is located after the
+		    end of the interrupt queue */
+
+        he_dev->irq_base = pci_alloc_consistent(he_dev->pci_dev,
+			(CONFIG_IRQ_SIZE+1) * sizeof(struct he_irq), &he_dev->irq_phys);
+	if (he_dev->irq_base == NULL)
+	{
+		hprintk1("failed to allocate irq\n");
+		return -ENOMEM;
+	}
+	he_dev->irq_tailoffset = (unsigned *)
+					&he_dev->irq_base[CONFIG_IRQ_SIZE];
+	*he_dev->irq_tailoffset = 0;
+	he_dev->irq_head = he_dev->irq_base;
+	he_dev->irq_tail = he_dev->irq_base;
+
+	for(i=0; i < CONFIG_IRQ_SIZE; ++i)
+		he_dev->irq_base[i].isw = ITYPE_INVALID;
+
+	he_writel(he_dev, he_dev->irq_phys, IRQ0_BASE);
+	he_writel(he_dev,
+		IRQ_SIZE(CONFIG_IRQ_SIZE) | IRQ_THRESH(CONFIG_IRQ_THRESH),
+								IRQ0_HEAD);
+	he_writel(he_dev, IRQ_INT_A | IRQ_TYPE_LINE, IRQ0_CNTL);
+	he_writel(he_dev, 0x0, IRQ0_DATA);
+
+	he_writel(he_dev, 0x0, IRQ1_BASE);
+	he_writel(he_dev, 0x0, IRQ1_HEAD);
+	he_writel(he_dev, 0x0, IRQ1_CNTL);
+	he_writel(he_dev, 0x0, IRQ1_DATA);
+
+	he_writel(he_dev, 0x0, IRQ2_BASE);
+	he_writel(he_dev, 0x0, IRQ2_HEAD);
+	he_writel(he_dev, 0x0, IRQ2_CNTL);
+	he_writel(he_dev, 0x0, IRQ2_DATA);
+
+	he_writel(he_dev, 0x0, IRQ3_BASE);
+	he_writel(he_dev, 0x0, IRQ3_HEAD);
+	he_writel(he_dev, 0x0, IRQ3_CNTL);
+	he_writel(he_dev, 0x0, IRQ3_DATA);
+
+	/* 2.9.3.2 interrupt queue mapping registers */
+
+	he_writel(he_dev, 0x0, GRP_10_MAP);
+	he_writel(he_dev, 0x0, GRP_32_MAP);
+	he_writel(he_dev, 0x0, GRP_54_MAP);
+	he_writel(he_dev, 0x0, GRP_76_MAP);
+
+	if (request_irq(he_dev->pci_dev->irq, he_irq_handler, SA_INTERRUPT|SA_SHIRQ, DEV_LABEL, he_dev))
+	{
+		hprintk("irq %d already in use\n", he_dev->pci_dev->irq);
+		return -EINVAL;
+        }   
+
+	he_dev->irq = he_dev->pci_dev->irq;
+
+#ifdef BUS_INT_WAR
+        HPRINTK("sn_add_polled_interrupt(irq %d, 1)\n", he_dev->irq);
+        sn_add_polled_interrupt(he_dev->irq, 1);
+#endif
+
+	return 0;
+}
+
+static int __init
+he_start(struct atm_dev *dev)
+{
+        struct he_dev *he_dev;
+        struct pci_dev *pci_dev;
+
+	u16 command;
+	u32 gen_cntl_0, host_cntl, lb_swap;
+	u8 cache_size, timer;
+	
+	unsigned err;
+	unsigned int status, reg;
+	int i, group;
+
+        he_dev = HE_DEV(dev);
+        pci_dev = he_dev->pci_dev;
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,3)
+	he_dev->membase = pci_dev->resource[0].start;
+#else
+	he_dev->membase = pci_dev->base_address[0] & PCI_BASE_ADDRESS_MEM_MASK;
+#endif
+	HPRINTK("membase = 0x%lx  irq = %d.\n", he_dev->membase, pci_dev->irq);
+
+	/*
+	 * pci bus controller initialization 
+	 */
+
+	/* 4.3 pci bus controller-specific initialization */
+	if (pci_read_config_dword(pci_dev, GEN_CNTL_0, &gen_cntl_0) != 0)
+	{
+		hprintk1("can't read GEN_CNTL_0\n");
+		return -EINVAL;
+	}
+	gen_cntl_0 |= (MRL_ENB | MRM_ENB | IGNORE_TIMEOUT);
+	if (pci_write_config_dword(pci_dev, GEN_CNTL_0, gen_cntl_0) != 0)
+	{
+		hprintk1("can't write GEN_CNTL_0.\n");
+		return -EINVAL;
+	}
+
+	if (pci_read_config_word(pci_dev, PCI_COMMAND, &command) != 0)
+	{
+		hprintk1("can't read PCI_COMMAND.\n");
+		return -EINVAL;
+	}
+
+	command |= (PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE);
+	if (pci_write_config_word(pci_dev, PCI_COMMAND, command) != 0)
+	{
+		hprintk1("can't enable memory.\n");
+		return -EINVAL;
+	}
+
+	if (pci_read_config_byte(pci_dev, PCI_CACHE_LINE_SIZE, &cache_size))
+	{
+		hprintk1("can't read cache line size?\n");
+		return -EINVAL;
+	}
+
+	if (cache_size < 16)
+	{
+		cache_size = 16;
+		if (pci_write_config_byte(pci_dev, PCI_CACHE_LINE_SIZE, cache_size))
+			hprintk("can't set cache line size to %d\n", cache_size);
+	}
+
+	if (pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &timer))
+	{
+		hprintk1("can't read latency timer?\n");
+		return -EINVAL;
+	}
+
+	/* from table 3.9
+	 *
+	 * LAT_TIMER = 1 + AVG_LAT + BURST_SIZE/BUS_SIZE
+	 * 
+	 * AVG_LAT: The average first data read/write latency [maximum 16 clock cycles]
+	 * BURST_SIZE: 1536 bytes (read) for 622, 768 bytes (read) for 155 [192 clock cycles]
+	 *
+	 */ 
+#define LAT_TIMER 209
+	if (timer < LAT_TIMER)
+	{
+		HPRINTK("latency timer was %d, setting to %d\n", timer, LAT_TIMER);
+		timer = LAT_TIMER;
+		if (pci_write_config_byte(pci_dev, PCI_LATENCY_TIMER, timer))
+			hprintk("can't set latency timer to %d\n", timer);
+	}
+
+	if (!(he_dev->membase = (unsigned long) ioremap(he_dev->membase, HE_REGMAP_SIZE))) {
+		hprintk1("can't set up page mapping\n");
+		return -EINVAL;
+	}
+	      
+	/* 4.4 card reset */
+	he_writel(he_dev, 0x0, RESET_CNTL);
+	he_writel(he_dev, 0xff, RESET_CNTL);
+
+	udelay(16*1000);	/* 16 ms */
+	status = he_readl(he_dev, RESET_CNTL);
+	if ((status & BOARD_RST_STATUS) == 0)
+	{
+		hprintk1("reset failed\n");
+		return -EINVAL;
+	}
+
+	/* 4.5 set bus width */
+	host_cntl = he_readl(he_dev, HOST_CNTL);
+	if (host_cntl & PCI_BUS_SIZE64)
+		gen_cntl_0 |= ENBL_64;
+	else
+		gen_cntl_0 &= ~ENBL_64;
+
+	if (disable64 == 1)
+	{
+		hprintk1("disabling 64-bit pci bus transfers\n");
+		gen_cntl_0 &= ~ENBL_64;
+	}
+
+	if (gen_cntl_0 & ENBL_64) hprintk1("64-bit transfers enabled\n");
+
+	pci_write_config_dword(pci_dev, GEN_CNTL_0, gen_cntl_0);
+
+	/* 4.7 read prom contents */
+	for(i=0; i<PROD_ID_LEN; ++i)
+		he_dev->prod_id[i] = read_prom_byte(he_dev, PROD_ID + i);
+
+	he_dev->media = read_prom_byte(he_dev, MEDIA);
+
+	for(i=0; i<6; ++i)
+		dev->esi[i] = read_prom_byte(he_dev, MAC_ADDR + i);
+
+	hprintk("%s%s, %x:%x:%x:%x:%x:%x\n",
+				he_dev->prod_id,
+					he_dev->media & 0x40 ? "SM" : "MM",
+						dev->esi[0],
+						dev->esi[1],
+						dev->esi[2],
+						dev->esi[3],
+						dev->esi[4],
+						dev->esi[5]);
+	he_dev->atm_dev->link_rate = he_is622(he_dev) ?
+						ATM_OC12_PCR : ATM_OC3_PCR;
+
+	/* 4.6 set host endianess */
+	lb_swap = he_readl(he_dev, LB_SWAP);
+	if (he_is622(he_dev))
+		lb_swap &= ~XFER_SIZE;		/* 4 cells */
+	else
+		lb_swap |= XFER_SIZE;		/* 8 cells */
+#ifdef __BIG_ENDIAN
+	lb_swap |= DESC_WR_SWAP | INTR_SWAP | BIG_ENDIAN_HOST;
+#else
+	lb_swap &= ~(DESC_WR_SWAP | INTR_SWAP | BIG_ENDIAN_HOST |
+			DATA_WR_SWAP | DATA_RD_SWAP | DESC_RD_SWAP);
+#endif /* __BIG_ENDIAN */
+	he_writel(he_dev, lb_swap, LB_SWAP);
+
+	/* 4.8 sdram controller initialization */
+	he_writel(he_dev, he_is622(he_dev) ? LB_64_ENB : 0x0, SDRAM_CTL);
+
+	/* 4.9 initialize rnum value */
+	lb_swap |= SWAP_RNUM_MAX(0xf);
+	he_writel(he_dev, lb_swap, LB_SWAP);
+
+	/* 4.10 initialize the interrupt queues */
+	if ((err = he_init_irq(he_dev)) != 0) return err;
+
+#ifdef USE_TASKLET
+	tasklet_init(&he_dev->tasklet, he_tasklet, (unsigned long) he_dev);
+#endif
+	spin_lock_init(&he_dev->global_lock);
+
+	/* 4.11 enable pci bus controller state machines */
+	host_cntl |= (OUTFF_ENB | CMDFF_ENB |
+				QUICK_RD_RETRY | QUICK_WR_RETRY | PERR_INT_ENB);
+	he_writel(he_dev, host_cntl, HOST_CNTL);
+
+	gen_cntl_0 |= INT_PROC_ENBL|INIT_ENB;
+	pci_write_config_dword(pci_dev, GEN_CNTL_0, gen_cntl_0);
+
+	/*
+	 * atm network controller initialization
+	 */
+
+	/* 5.1.1 generic configuration state */
+
+	/*
+	 *		local (cell) buffer memory map
+	 *                    
+	 *             HE155                          HE622
+	 *                                                      
+	 *        0 ____________1023 bytes  0 _______________________2047 bytes
+	 *         |            |            |                   |   |
+	 *         |  utility   |            |        rx0        |   |
+	 *        5|____________|         255|___________________| u |
+	 *        6|            |         256|                   | t |
+	 *         |            |            |                   | i |
+	 *         |    rx0     |     row    |        tx         | l |
+	 *         |            |            |                   | i |
+	 *         |            |         767|___________________| t |
+	 *      517|____________|         768|                   | y |
+	 * row  518|            |            |        rx1        |   |
+	 *         |            |        1023|___________________|___|
+	 *         |            |
+	 *         |    tx      |
+	 *         |            |
+	 *         |            |
+	 *     1535|____________|
+	 *     1536|            |
+	 *         |    rx1     |
+	 *     2047|____________|
+	 *
+	 */
+
+	/* total 4096 connections */
+	he_dev->vcibits = CONFIG_DEFAULT_VCIBITS;
+	he_dev->vpibits = CONFIG_DEFAULT_VPIBITS;
+
+	if (nvpibits != -1 && nvcibits != -1 && nvpibits+nvcibits != HE_MAXCIDBITS)
+	{
+		hprintk("nvpibits + nvcibits != %d\n", HE_MAXCIDBITS);
+		return -ENODEV;
+	}
+
+	if (nvpibits != -1)
+	{
+		he_dev->vpibits = nvpibits;
+		he_dev->vcibits = HE_MAXCIDBITS - nvpibits;
+	}
+
+	if (nvcibits != -1)
+	{
+		he_dev->vcibits = nvcibits;
+		he_dev->vpibits = HE_MAXCIDBITS - nvcibits;
+	}
+
+
+	if (he_is622(he_dev))
+	{
+		he_dev->cells_per_row = 40;
+		he_dev->bytes_per_row = 2048;
+		he_dev->r0_numrows = 256;
+		he_dev->tx_numrows = 512;
+		he_dev->r1_numrows = 256;
+		he_dev->r0_startrow = 0;
+		he_dev->tx_startrow = 256;
+		he_dev->r1_startrow = 768;
+	}
+	else
+	{
+		he_dev->cells_per_row = 20;
+		he_dev->bytes_per_row = 1024;
+		he_dev->r0_numrows = 512;
+		he_dev->tx_numrows = 1018;
+		he_dev->r1_numrows = 512;
+		he_dev->r0_startrow = 6;
+		he_dev->tx_startrow = 518;
+		he_dev->r1_startrow = 1536;
+	}
+
+	he_dev->cells_per_lbuf = 4;
+	he_dev->buffer_limit = 4;
+	he_dev->r0_numbuffs = he_dev->r0_numrows *
+				he_dev->cells_per_row / he_dev->cells_per_lbuf;
+	if (he_dev->r0_numbuffs > 2560) he_dev->r0_numbuffs = 2560;
+
+	he_dev->r1_numbuffs = he_dev->r1_numrows *
+				he_dev->cells_per_row / he_dev->cells_per_lbuf;
+	if (he_dev->r1_numbuffs > 2560) he_dev->r1_numbuffs = 2560;
+
+	he_dev->tx_numbuffs = he_dev->tx_numrows *
+				he_dev->cells_per_row / he_dev->cells_per_lbuf;
+	if (he_dev->tx_numbuffs > 5120) he_dev->tx_numbuffs = 5120;
+
+	/* 5.1.2 configure hardware dependent registers */
+
+	he_writel(he_dev, 
+		SLICE_X(0x2) | ARB_RNUM_MAX(0xf) | TH_PRTY(0x3) |
+		RH_PRTY(0x3) | TL_PRTY(0x2) | RL_PRTY(0x1) |
+		(he_is622(he_dev) ? BUS_MULTI(0x28) : BUS_MULTI(0x46)) |
+		(he_is622(he_dev) ? NET_PREF(0x50) : NET_PREF(0x8c)),
+								LBARB);
+
+	he_writel(he_dev, BANK_ON |
+		(he_is622(he_dev) ? (REF_RATE(0x384) | WIDE_DATA) : REF_RATE(0x150)),
+								SDRAMCON);
+
+	he_writel(he_dev,
+		(he_is622(he_dev) ? RM_BANK_WAIT(1) : RM_BANK_WAIT(0)) |
+						RM_RW_WAIT(1), RCMCONFIG);
+	he_writel(he_dev,
+		(he_is622(he_dev) ? TM_BANK_WAIT(2) : TM_BANK_WAIT(1)) |
+						TM_RW_WAIT(1), TCMCONFIG);
+
+	he_writel(he_dev, he_dev->cells_per_lbuf * ATM_CELL_PAYLOAD, LB_CONFIG);
+
+	he_writel(he_dev, 
+		(he_is622(he_dev) ? UT_RD_DELAY(8) : UT_RD_DELAY(0)) |
+		(he_is622(he_dev) ? RC_UT_MODE(0) : RC_UT_MODE(1)) |
+		RX_VALVP(he_dev->vpibits) |
+		RX_VALVC(he_dev->vcibits),			 RC_CONFIG);
+
+	he_writel(he_dev, DRF_THRESH(0x20) |
+		(he_is622(he_dev) ? TX_UT_MODE(0) : TX_UT_MODE(1)) |
+		TX_VCI_MASK(he_dev->vcibits) |
+		LBFREE_CNT(he_dev->tx_numbuffs), 		TX_CONFIG);
+
+	he_writel(he_dev, 0x0, TXAAL5_PROTO);
+
+	he_writel(he_dev, PHY_INT_ENB |
+		(he_is622(he_dev) ? PTMR_PRE(67-1) : PTMR_PRE(50-1)),
+								RH_CONFIG);
+
+	/* 5.1.3 initialize connection memory */
+
+	for(i=0; i < TCM_MEM_SIZE; ++i)
+		he_writel_tcm(he_dev, 0, i);
+
+	for(i=0; i < RCM_MEM_SIZE; ++i)
+		he_writel_rcm(he_dev, 0, i);
+
+	/*
+	 *	transmit connection memory map
+	 *
+	 *                  tx memory
+	 *          0x0 ___________________
+	 *             |                   |
+	 *             |                   |
+	 *             |       TSRa        |
+	 *             |                   |
+	 *             |                   |
+	 *       0x8000|___________________|
+	 *             |                   |
+	 *             |       TSRb        |
+	 *       0xc000|___________________|
+	 *             |                   |
+	 *             |       TSRc        |
+	 *       0xe000|___________________|
+	 *             |       TSRd        |
+	 *       0xf000|___________________|
+	 *             |       tmABR       |
+	 *      0x10000|___________________|
+	 *             |                   |
+	 *             |       tmTPD       |
+	 *             |___________________|
+	 *             |                   |
+	 *                      ....
+	 *      0x1ffff|___________________|
+	 *
+	 *
+	 */
+
+	he_writel(he_dev, CONFIG_TSRB, TSRB_BA);
+	he_writel(he_dev, CONFIG_TSRC, TSRC_BA);
+	he_writel(he_dev, CONFIG_TSRD, TSRD_BA);
+	he_writel(he_dev, CONFIG_TMABR, TMABR_BA);
+	he_writel(he_dev, CONFIG_TPDBA, TPD_BA);
+
+
+	/*
+	 *	receive connection memory map
+	 *
+	 *          0x0 ___________________
+	 *             |                   |
+	 *             |                   |
+	 *             |       RSRa        |
+	 *             |                   |
+	 *             |                   |
+	 *       0x8000|___________________|
+	 *             |                   |
+	 *             |             rx0/1 |
+	 *             |       LBM         |   link lists of local
+	 *             |             tx    |   buffer memory 
+	 *             |                   |
+	 *       0xd000|___________________|
+	 *             |                   |
+	 *             |      rmABR        |
+	 *       0xe000|___________________|
+	 *             |                   |
+	 *             |       RSRb        |
+	 *             |___________________|
+	 *             |                   |
+	 *                      ....
+	 *       0xffff|___________________|
+	 */
+
+	he_writel(he_dev, 0x08000, RCMLBM_BA);
+	he_writel(he_dev, 0x0e000, RCMRSRB_BA);
+	he_writel(he_dev, 0x0d800, RCMABR_BA);
+
+	/* 5.1.4 initialize local buffer free pools linked lists */
+
+	he_init_rx_lbfp0(he_dev);
+	he_init_rx_lbfp1(he_dev);
+
+	he_writel(he_dev, 0x0, RLBC_H);
+	he_writel(he_dev, 0x0, RLBC_T);
+	he_writel(he_dev, 0x0, RLBC_H2);
+
+	he_writel(he_dev, 512, RXTHRSH);	/* 10% of r0+r1 buffers */
+	he_writel(he_dev, 256, LITHRSH); 	/* 5% of r0+r1 buffers */
+
+	he_init_tx_lbfp(he_dev);
+
+	he_writel(he_dev, he_is622(he_dev) ? 0x104780 : 0x800, UBUFF_BA);
+
+	/* 5.1.5 initialize intermediate receive queues */
+
+	if (he_is622(he_dev))
+	{
+		he_writel(he_dev, 0x000f, G0_INMQ_S);
+		he_writel(he_dev, 0x200f, G0_INMQ_L);
+
+		he_writel(he_dev, 0x001f, G1_INMQ_S);
+		he_writel(he_dev, 0x201f, G1_INMQ_L);
+
+		he_writel(he_dev, 0x002f, G2_INMQ_S);
+		he_writel(he_dev, 0x202f, G2_INMQ_L);
+
+		he_writel(he_dev, 0x003f, G3_INMQ_S);
+		he_writel(he_dev, 0x203f, G3_INMQ_L);
+
+		he_writel(he_dev, 0x004f, G4_INMQ_S);
+		he_writel(he_dev, 0x204f, G4_INMQ_L);
+
+		he_writel(he_dev, 0x005f, G5_INMQ_S);
+		he_writel(he_dev, 0x205f, G5_INMQ_L);
+
+		he_writel(he_dev, 0x006f, G6_INMQ_S);
+		he_writel(he_dev, 0x206f, G6_INMQ_L);
+
+		he_writel(he_dev, 0x007f, G7_INMQ_S);
+		he_writel(he_dev, 0x207f, G7_INMQ_L);
+	}
+	else
+	{
+		he_writel(he_dev, 0x0000, G0_INMQ_S);
+		he_writel(he_dev, 0x0008, G0_INMQ_L);
+
+		he_writel(he_dev, 0x0001, G1_INMQ_S);
+		he_writel(he_dev, 0x0009, G1_INMQ_L);
+
+		he_writel(he_dev, 0x0002, G2_INMQ_S);
+		he_writel(he_dev, 0x000a, G2_INMQ_L);
+
+		he_writel(he_dev, 0x0003, G3_INMQ_S);
+		he_writel(he_dev, 0x000b, G3_INMQ_L);
+
+		he_writel(he_dev, 0x0004, G4_INMQ_S);
+		he_writel(he_dev, 0x000c, G4_INMQ_L);
+
+		he_writel(he_dev, 0x0005, G5_INMQ_S);
+		he_writel(he_dev, 0x000d, G5_INMQ_L);
+
+		he_writel(he_dev, 0x0006, G6_INMQ_S);
+		he_writel(he_dev, 0x000e, G6_INMQ_L);
+
+		he_writel(he_dev, 0x0007, G7_INMQ_S);
+		he_writel(he_dev, 0x000f, G7_INMQ_L);
+	}
+
+	/* 5.1.6 application tunable parameters */
+
+	he_writel(he_dev, 0x0, MCC);
+	he_writel(he_dev, 0x0, OEC);
+	he_writel(he_dev, 0x0, DCC);
+	he_writel(he_dev, 0x0, CEC);
+	
+	/* 5.1.7 cs block initialization */
+
+	he_init_cs_block(he_dev);
+
+	/* 5.1.8 cs block connection memory initialization */
+	
+	he_init_cs_block_rcm(he_dev);
+
+	/* 5.1.10 initialize host structures */
+
+	he_init_tpdrq(he_dev);
+
+#ifdef USE_TPD_POOL
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,44)
+	he_dev->tpd_pool = pci_pool_create("tpd", he_dev->pci_dev,
+		sizeof(struct he_tpd), TPD_ALIGNMENT, 0, SLAB_KERNEL);
+#else
+	he_dev->tpd_pool = pci_pool_create("tpd", he_dev->pci_dev,
+		sizeof(struct he_tpd), TPD_ALIGNMENT, 0);
+#endif
+	if (he_dev->tpd_pool == NULL)
+	{
+		hprintk1("unable to create tpd pci_pool\n");
+		return -ENOMEM;         
+	}
+
+	INIT_LIST_HEAD(&he_dev->outstanding_tpds);
+#else
+	he_dev->tpd_base = (void *) pci_alloc_consistent(he_dev->pci_dev,
+			CONFIG_NUMTPDS * sizeof(struct he_tpd), &he_dev->tpd_base_phys);
+	if (!he_dev->tpd_base)
+		return -ENOMEM;
+
+	for(i = 0; i < CONFIG_NUMTPDS; ++i)
+	{
+		he_dev->tpd_base[i].status = (i << TPD_ADDR_SHIFT);
+		he_dev->tpd_base[i].inuse = 0;
+	}
+		
+	he_dev->tpd_head = he_dev->tpd_base;
+	he_dev->tpd_end = &he_dev->tpd_base[CONFIG_NUMTPDS-1];
+#endif
+
+	if (he_init_group(he_dev, 0) != 0)
+		return -ENOMEM;
+
+	for (group = 1; group < HE_NUM_GROUPS; ++group)
+	{
+		he_writel(he_dev, 0x0, G0_RBPS_S + (group * 32));
+		he_writel(he_dev, 0x0, G0_RBPS_T + (group * 32));
+		he_writel(he_dev, 0x0, G0_RBPS_QI + (group * 32));
+		he_writel(he_dev, RBP_THRESH(0x1) | RBP_QSIZE(0x0),
+						G0_RBPS_BS + (group * 32));
+
+		he_writel(he_dev, 0x0, G0_RBPL_S + (group * 32));
+		he_writel(he_dev, 0x0, G0_RBPL_T + (group * 32));
+		he_writel(he_dev, RBP_THRESH(0x1) | RBP_QSIZE(0x0),
+						G0_RBPL_QI + (group * 32));
+		he_writel(he_dev, 0x0, G0_RBPL_BS + (group * 32));
+
+		he_writel(he_dev, 0x0, G0_RBRQ_ST + (group * 16));
+		he_writel(he_dev, 0x0, G0_RBRQ_H + (group * 16));
+		he_writel(he_dev, RBRQ_THRESH(0x1) | RBRQ_SIZE(0x0),
+						G0_RBRQ_Q + (group * 16));
+		he_writel(he_dev, 0x0, G0_RBRQ_I + (group * 16));
+
+		he_writel(he_dev, 0x0, G0_TBRQ_B_T + (group * 16));
+		he_writel(he_dev, 0x0, G0_TBRQ_H + (group * 16));
+		he_writel(he_dev, TBRQ_THRESH(0x1),
+						G0_TBRQ_THRESH + (group * 16));
+		he_writel(he_dev, 0x0, G0_TBRQ_S + (group * 16));
+	}
+
+	/* host status page */
+
+	he_dev->hsp = pci_alloc_consistent(he_dev->pci_dev,
+				sizeof(struct he_hsp), &he_dev->hsp_phys);
+	if (he_dev->hsp == NULL)
+	{
+		hprintk1("failed to allocate host status page\n");
+		return -ENOMEM;
+	}
+	memset(he_dev->hsp, 0, sizeof(struct he_hsp));
+	he_writel(he_dev, he_dev->hsp_phys, HSP_BA);
+
+	/* initialize framer */
+
+#ifdef CONFIG_ATM_HE_USE_SUNI
+	suni_init(he_dev->atm_dev);
+	if (he_dev->atm_dev->phy && he_dev->atm_dev->phy->start)
+		he_dev->atm_dev->phy->start(he_dev->atm_dev);
+#endif /* CONFIG_ATM_HE_USE_SUNI */
+
+	if (sdh)
+	{
+		/* this really should be in suni.c but for now... */
+
+		int val;
+
+		val = he_phy_get(he_dev->atm_dev, SUNI_TPOP_APM);
+		val = (val & ~SUNI_TPOP_APM_S) | ( 0x2 << SUNI_TPOP_APM_S_SHIFT);
+		he_phy_put(he_dev->atm_dev, val, SUNI_TPOP_APM);
+	}
+
+	/* 5.1.12 enable transmit and receive */
+
+	reg = he_readl_mbox(he_dev, CS_ERCTL0);
+	reg |= TX_ENABLE|ER_ENABLE;
+	he_writel_mbox(he_dev, reg, CS_ERCTL0);
+
+	reg = he_readl(he_dev, RC_CONFIG);
+	reg |= RX_ENABLE;
+	he_writel(he_dev, reg, RC_CONFIG);
+
+#ifndef USE_HE_FIND_VCC
+	he_dev->he_vcc_table = kmalloc(sizeof(struct he_vcc_table) * 
+			(1 << (he_dev->vcibits + he_dev->vpibits)), GFP_KERNEL);
+	if (he_dev->he_vcc_table == NULL)
+	{
+		hprintk1("failed to alloc he_vcc_table\n");
+		return -ENOMEM;
+	}
+	memset(he_dev->he_vcc_table, 0, sizeof(struct he_vcc_table) *
+				(1 << (he_dev->vcibits + he_dev->vpibits)));
+#endif
+
+	for (i = 0; i < HE_NUM_CS_STPER; ++i)
+	{
+		he_dev->cs_stper[i].inuse = 0;
+		he_dev->cs_stper[i].pcr = -1;
+	}
+	he_dev->total_bw = 0;
+
+
+	/* atm linux initialization */
+
+	he_dev->atm_dev->ci_range.vpi_bits = he_dev->vpibits;
+	he_dev->atm_dev->ci_range.vci_bits = he_dev->vcibits;
+
+	he_dev->irq_peak = 0;
+	he_dev->rbrq_peak = 0;
+        he_dev->rbpl_peak = 0;
+        he_dev->tbrq_peak = 0;
+
+	HPRINTK("hell bent for leather!\n");
+
+	return 0;
+}
+
+static void
+he_stop(struct he_dev *he_dev)
+{
+	u16 command;
+	u32 gen_cntl_0, reg;
+	struct pci_dev *pci_dev;
+
+	pci_dev = he_dev->pci_dev;
+
+	/* disable interrupts */
+
+	if (he_dev->membase)
+	{
+		pci_read_config_dword(pci_dev, GEN_CNTL_0, &gen_cntl_0);
+		gen_cntl_0 &= ~(INT_PROC_ENBL | INIT_ENB);
+		pci_write_config_dword(pci_dev, GEN_CNTL_0, gen_cntl_0);
+
+#ifdef USE_TASKLET
+		tasklet_disable(&he_dev->tasklet);
+#endif
+
+		/* disable recv and transmit */
+
+		reg = he_readl_mbox(he_dev, CS_ERCTL0);
+		reg &= ~(TX_ENABLE|ER_ENABLE);
+		he_writel_mbox(he_dev, reg, CS_ERCTL0);
+
+		reg = he_readl(he_dev, RC_CONFIG);
+		reg &= ~(RX_ENABLE);
+		he_writel(he_dev, reg, RC_CONFIG);
+	}
+
+#ifdef CONFIG_ATM_HE_USE_SUNI
+	if (he_dev->atm_dev->phy && he_dev->atm_dev->phy->stop)
+		he_dev->atm_dev->phy->stop(he_dev->atm_dev);
+#endif /* CONFIG_ATM_HE_USE_SUNI */
+
+	if (he_dev->irq)
+	{
+#ifdef BUS_INT_WAR
+		sn_delete_polled_interrupt(he_dev->irq);
+#endif
+		free_irq(he_dev->irq, he_dev);
+	}
+
+	if (he_dev->irq_base)
+		pci_free_consistent(he_dev->pci_dev, (CONFIG_IRQ_SIZE+1)
+			* sizeof(struct he_irq), he_dev->irq_base, he_dev->irq_phys);
+
+	if (he_dev->hsp)
+		pci_free_consistent(he_dev->pci_dev, sizeof(struct he_hsp),
+						he_dev->hsp, he_dev->hsp_phys);
+
+	if (he_dev->rbpl_base)
+	{
+#ifdef USE_RBPL_POOL
+		for (i=0; i<CONFIG_RBPL_SIZE; ++i)
+		{
+			void *cpuaddr = he_dev->rbpl_virt[i].virt;
+			dma_addr_t dma_handle = he_dev->rbpl_base[i].phys;
+
+			pci_pool_free(he_dev->rbpl_pool, cpuaddr, dma_handle);
+		}
+#else
+		pci_free_consistent(he_dev->pci_dev, CONFIG_RBPL_SIZE
+			* CONFIG_RBPL_BUFSIZE, he_dev->rbpl_pages, he_dev->rbpl_pages_phys);
+#endif
+		pci_free_consistent(he_dev->pci_dev, CONFIG_RBPL_SIZE
+			* sizeof(struct he_rbp), he_dev->rbpl_base, he_dev->rbpl_phys);
+	}
+
+#ifdef USE_RBPL_POOL
+	if (he_dev->rbpl_pool)
+		pci_pool_destroy(he_dev->rbpl_pool);
+#endif
+
+#ifdef USE_RBPS
+	if (he_dev->rbps_base)
+	{
+#ifdef USE_RBPS_POOL
+		for (i=0; i<CONFIG_RBPS_SIZE; ++i)
+		{
+			void *cpuaddr = he_dev->rbps_virt[i].virt;
+			dma_addr_t dma_handle = he_dev->rbps_base[i].phys;
+
+			pci_pool_free(he_dev->rbps_pool, cpuaddr, dma_handle);
+		}
+#else
+		pci_free_consistent(he_dev->pci_dev, CONFIG_RBPS_SIZE
+			* CONFIG_RBPS_BUFSIZE, he_dev->rbps_pages, he_dev->rbps_pages_phys);
+#endif
+		pci_free_consistent(he_dev->pci_dev, CONFIG_RBPS_SIZE
+			* sizeof(struct he_rbp), he_dev->rbps_base, he_dev->rbps_phys);
+	}
+
+#ifdef USE_RBPS_POOL
+	if (he_dev->rbps_pool)
+		pci_pool_destroy(he_dev->rbps_pool);
+#endif
+
+#endif /* USE_RBPS */
+
+	if (he_dev->rbrq_base)
+		pci_free_consistent(he_dev->pci_dev, CONFIG_RBRQ_SIZE * sizeof(struct he_rbrq),
+							he_dev->rbrq_base, he_dev->rbrq_phys);
+
+	if (he_dev->tbrq_base)
+		pci_free_consistent(he_dev->pci_dev, CONFIG_TBRQ_SIZE * sizeof(struct he_tbrq),
+							he_dev->tbrq_base, he_dev->tbrq_phys);
+
+	if (he_dev->tpdrq_base)
+		pci_free_consistent(he_dev->pci_dev, CONFIG_TBRQ_SIZE * sizeof(struct he_tbrq),
+							he_dev->tpdrq_base, he_dev->tpdrq_phys);
+
+#ifdef USE_TPD_POOL
+	if (he_dev->tpd_pool)
+		pci_pool_destroy(he_dev->tpd_pool);
+#else
+	if (he_dev->tpd_base)
+		pci_free_consistent(he_dev->pci_dev, CONFIG_NUMTPDS * sizeof(struct he_tpd),
+							he_dev->tpd_base, he_dev->tpd_base_phys);
+#endif
+
+#ifndef USE_HE_FIND_VCC
+	if (he_dev->he_vcc_table)
+		kfree(he_dev->he_vcc_table);
+#endif
+
+	if (he_dev->pci_dev)
+	{
+		pci_read_config_word(he_dev->pci_dev, PCI_COMMAND, &command);
+		command &= ~(PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
+		pci_write_config_word(he_dev->pci_dev, PCI_COMMAND, command);
+	}
+	
+	if (he_dev->membase) iounmap((void *) he_dev->membase);
+}
+
+static struct he_tpd *
+__alloc_tpd(struct he_dev *he_dev)
+{
+#ifdef USE_TPD_POOL
+	struct he_tpd *tpd;
+	dma_addr_t dma_handle; 
+
+	tpd = pci_pool_alloc(he_dev->tpd_pool, SLAB_ATOMIC|SLAB_DMA, &dma_handle);              
+	if (tpd == NULL)
+		return NULL;
+			
+	tpd->status = TPD_ADDR(dma_handle);
+	tpd->reserved = 0; 
+	tpd->iovec[0].addr = 0; tpd->iovec[0].len = 0;
+	tpd->iovec[1].addr = 0; tpd->iovec[1].len = 0;
+	tpd->iovec[2].addr = 0; tpd->iovec[2].len = 0;
+
+	return tpd;
+#else
+	int i;
+
+	for(i = 0; i < CONFIG_NUMTPDS; ++i)
+	{
+		++he_dev->tpd_head;
+		if (he_dev->tpd_head > he_dev->tpd_end) {
+			he_dev->tpd_head = he_dev->tpd_base;
+		}
+
+		if (!he_dev->tpd_head->inuse) {
+			he_dev->tpd_head->inuse = 1;
+			he_dev->tpd_head->status &= TPD_MASK;
+			he_dev->tpd_head->iovec[0].addr = 0; he_dev->tpd_head->iovec[0].len = 0;
+			he_dev->tpd_head->iovec[1].addr = 0; he_dev->tpd_head->iovec[1].len = 0;
+			he_dev->tpd_head->iovec[2].addr = 0; he_dev->tpd_head->iovec[2].len = 0;
+			return he_dev->tpd_head;
+		}
+	}
+	hprintk("out of tpds -- increase CONFIG_NUMTPDS (%d)\n", CONFIG_NUMTPDS);
+	return NULL;
+#endif
+}
+
+#define AAL5_LEN(buf,len) 						\
+			((((unsigned char *)(buf))[(len)-6]<<8) |	\
+				(((unsigned char *)(buf))[(len)-5]))
+
+/* 2.10.1.2 receive
+ *
+ * aal5 packets can optionally return the tcp checksum in the lower
+ * 16 bits of the crc (RSR0_TCP_CKSUM)
+ */
+
+#define TCP_CKSUM(buf,len) 						\
+			((((unsigned char *)(buf))[(len)-2]<<8) |	\
+				(((unsigned char *)(buf))[(len-1)]))
+
+static int
+he_service_rbrq(struct he_dev *he_dev, int group)
+{
+	struct he_rbrq *rbrq_tail = (struct he_rbrq *)
+				((unsigned long)he_dev->rbrq_base |
+					he_dev->hsp->group[group].rbrq_tail);
+	struct he_rbp *rbp = NULL;
+	unsigned cid, lastcid = -1;
+	unsigned buf_len = 0;
+	struct sk_buff *skb;
+	struct atm_vcc *vcc = NULL;
+	struct he_vcc *he_vcc;
+	struct iovec *iov;
+	int pdus_assembled = 0;
+	int updated = 0;
+
+	while (he_dev->rbrq_head != rbrq_tail)
+	{
+		++updated;
+
+		HPRINTK("%p rbrq%d 0x%x len=%d cid=0x%x %s%s%s%s%s%s\n",
+			he_dev->rbrq_head, group,
+			RBRQ_ADDR(he_dev->rbrq_head),
+			RBRQ_BUFLEN(he_dev->rbrq_head),
+			RBRQ_CID(he_dev->rbrq_head),
+			RBRQ_CRC_ERR(he_dev->rbrq_head) ? " CRC_ERR" : "",
+			RBRQ_LEN_ERR(he_dev->rbrq_head) ? " LEN_ERR" : "",
+			RBRQ_END_PDU(he_dev->rbrq_head) ? " END_PDU" : "",
+			RBRQ_AAL5_PROT(he_dev->rbrq_head) ? " AAL5_PROT" : "",
+			RBRQ_CON_CLOSED(he_dev->rbrq_head) ? " CON_CLOSED" : "",
+			RBRQ_HBUF_ERR(he_dev->rbrq_head) ? " HBUF_ERR" : "");
+
+#ifdef USE_RBPS
+		if (RBRQ_ADDR(he_dev->rbrq_head) & RBP_SMALLBUF)
+			rbp = &he_dev->rbps_base[RBP_INDEX(RBRQ_ADDR(he_dev->rbrq_head))];
+		else
+#endif
+			rbp = &he_dev->rbpl_base[RBP_INDEX(RBRQ_ADDR(he_dev->rbrq_head))];
+		
+		buf_len = RBRQ_BUFLEN(he_dev->rbrq_head) * 4;
+		cid = RBRQ_CID(he_dev->rbrq_head);
+
+#ifdef USE_HE_FIND_VCC
+		if (cid != lastcid)
+			vcc = he_find_vcc(he_dev, cid);
+		lastcid = cid;
+#else
+		vcc = HE_LOOKUP_VCC(he_dev, cid);
+#endif
+		if (vcc == NULL)
+		{
+			hprintk("vcc == NULL  (cid 0x%x)\n", cid);
+			if (!RBRQ_HBUF_ERR(he_dev->rbrq_head))
+					rbp->status &= ~RBP_LOANED;
+					
+			goto next_rbrq_entry;
+		}
+
+		he_vcc = HE_VCC(vcc);
+		if (he_vcc == NULL)
+		{
+			hprintk("he_vcc == NULL  (cid 0x%x)\n", cid);
+			if (!RBRQ_HBUF_ERR(he_dev->rbrq_head))
+					rbp->status &= ~RBP_LOANED;
+			goto next_rbrq_entry;
+		}
+
+		if (RBRQ_HBUF_ERR(he_dev->rbrq_head))
+		{
+			hprintk("HBUF_ERR!  (cid 0x%x)\n", cid);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,99)
+				++vcc->stats->rx_drop;
+#else
+				atomic_inc(&vcc->stats->rx_drop);
+#endif
+			goto return_host_buffers;
+		}
+
+		he_vcc->iov_tail->iov_base = (void *) RBRQ_ADDR(he_dev->rbrq_head);
+		he_vcc->iov_tail->iov_len = buf_len;
+		he_vcc->pdu_len += buf_len;
+		++he_vcc->iov_tail;
+
+		if (RBRQ_CON_CLOSED(he_dev->rbrq_head))
+		{
+			lastcid = -1;
+			HPRINTK("wake_up rx_waitq  (cid 0x%x)\n", cid);
+			wake_up(&he_vcc->rx_waitq);
+			goto return_host_buffers;
+		}
+
+#ifdef notdef
+		if (he_vcc->iov_tail - he_vcc->iov_head > 32)
+		{
+			hprintk("iovec full!  cid 0x%x\n", cid);
+			goto return_host_buffers;
+		}
+#endif
+		if (!RBRQ_END_PDU(he_dev->rbrq_head)) goto next_rbrq_entry;
+
+		if (RBRQ_LEN_ERR(he_dev->rbrq_head)
+				|| RBRQ_CRC_ERR(he_dev->rbrq_head))
+		{
+			HPRINTK("%s%s (%d.%d)\n",
+				RBRQ_CRC_ERR(he_dev->rbrq_head)
+							? "CRC_ERR " : "",
+				RBRQ_LEN_ERR(he_dev->rbrq_head)
+							? "LEN_ERR" : "",
+							vcc->vpi, vcc->vci);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,99)
+			++vcc->stats->rx_err;
+#else
+			atomic_inc(&vcc->stats->rx_err);
+#endif
+			goto return_host_buffers;
+		}
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,15)
+		skb = atm_alloc_charge(vcc, he_vcc->pdu_len + rx_skb_reserve,
+							GFP_ATOMIC);
+#else
+		if (!atm_charge(vcc, atm_pdu2truesize(he_vcc->pdu_len + rx_skb_reserve)))
+			skb = NULL;
+		else
+		{
+			skb = alloc_skb(he_vcc->pdu_len + rx_skb_reserve, GFP_ATOMIC);
+			if (!skb) atm_return(vcc,
+				atm_pdu2truesize(he_vcc->pdu_len + rx_skb_reserve));
+		}
+#endif
+		if (!skb)
+		{
+			HPRINTK("charge failed (%d.%d)\n", vcc->vpi, vcc->vci);
+			goto return_host_buffers;
+		}
+
+		if (rx_skb_reserve > 0) skb_reserve(skb, rx_skb_reserve);
+
+		do_gettimeofday(&skb->stamp);
+
+		for(iov = he_vcc->iov_head;
+				iov < he_vcc->iov_tail; ++iov)
+		{
+#ifdef USE_RBPS
+			if ((u32)iov->iov_base & RBP_SMALLBUF)
+				memcpy(skb_put(skb, iov->iov_len),
+					he_dev->rbps_virt[RBP_INDEX(iov->iov_base)].virt, iov->iov_len);
+			else
+#endif
+				memcpy(skb_put(skb, iov->iov_len),
+					he_dev->rbpl_virt[RBP_INDEX(iov->iov_base)].virt, iov->iov_len);
+		}
+
+		switch(vcc->qos.aal)
+		{
+			case ATM_AAL0:
+				/* 2.10.1.5 raw cell receive */
+				skb->len = ATM_AAL0_SDU;
+				skb->tail = skb->data + skb->len;
+				break;
+			case ATM_AAL5:
+				/* 2.10.1.2 aal5 receive */
+
+				skb->len = AAL5_LEN(skb->data, he_vcc->pdu_len);
+				skb->tail = skb->data + skb->len;
+#ifdef USE_CHECKSUM_HW
+				if (vcc->vpi == 0 && vcc->vci >= ATM_NOT_RSV_VCI) 
+				{
+					skb->ip_summed = CHECKSUM_HW;
+					skb->csum = TCP_CKSUM(skb->data,
+							he_vcc->pdu_len);
+				}
+#endif
+				break;
+		}
+
+#ifdef should_never_happen
+		if (skb->len > vcc->qos.rxtp.max_sdu)
+			hprintk("pdu_len (%d) > vcc->qos.rxtp.max_sdu (%d)!  cid 0x%x\n", skb->len, vcc->qos.rxtp.max_sdu, cid);
+#endif
+
+#ifdef notdef
+		ATM_SKB(skb)->vcc = vcc;
+#endif
+		vcc->push(vcc, skb);
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,99)
+		++vcc->stats->rx;
+#else
+		atomic_inc(&vcc->stats->rx);
+#endif
+
+return_host_buffers:
+		++pdus_assembled;
+
+		for(iov = he_vcc->iov_head;
+				iov < he_vcc->iov_tail; ++iov)
+		{
+#ifdef USE_RBPS
+			if ((u32)iov->iov_base & RBP_SMALLBUF)
+				rbp = &he_dev->rbps_base[RBP_INDEX(iov->iov_base)];
+			else
+#endif
+				rbp = &he_dev->rbpl_base[RBP_INDEX(iov->iov_base)];
+
+			rbp->status &= ~RBP_LOANED;
+		}
+
+		he_vcc->iov_tail = he_vcc->iov_head;
+		he_vcc->pdu_len = 0;
+
+next_rbrq_entry:
+		he_dev->rbrq_head = (struct he_rbrq *)
+				((unsigned long) he_dev->rbrq_base |
+					RBRQ_MASK(++he_dev->rbrq_head));
+
+	}
+
+	if (updated)
+	{
+		if (updated > he_dev->rbrq_peak) he_dev->rbrq_peak = updated;
+
+		he_writel(he_dev, RBRQ_MASK(he_dev->rbrq_head),
+						G0_RBRQ_H + (group * 16));
+#ifdef CONFIG_IA64_SGI_SN2
+		(void) he_readl(he_dev, G0_RBRQ_H + (group * 16));
+#endif
+	}
+
+	return pdus_assembled;
+}
+
+static void
+he_service_tbrq(struct he_dev *he_dev, int group)
+{
+	struct he_tbrq *tbrq_tail = (struct he_tbrq *)
+				((unsigned long)he_dev->tbrq_base |
+					he_dev->hsp->group[group].tbrq_tail);
+	struct he_tpd *tpd;
+	int slot, updated = 0;
+#ifdef USE_TPD_POOL
+	struct list_head *p;
+#endif
+
+	/* 2.1.6 transmit buffer return queue */
+
+	while (he_dev->tbrq_head != tbrq_tail)
+	{
+		++updated;
+
+		HPRINTK("tbrq%d 0x%x%s%s\n",
+			group,
+			TBRQ_TPD(he_dev->tbrq_head), 
+			TBRQ_EOS(he_dev->tbrq_head) ? " EOS" : "",
+			TBRQ_MULTIPLE(he_dev->tbrq_head) ? " MULTIPLE" : "");
+#ifdef USE_TPD_POOL
+		tpd = NULL;
+		p = &he_dev->outstanding_tpds;
+		while ((p = p->next) != &he_dev->outstanding_tpds)
+		{
+			struct he_tpd *__tpd = list_entry(p, struct he_tpd, entry);
+			if (TPD_ADDR(__tpd->status) == TBRQ_TPD(he_dev->tbrq_head))
+			{
+				tpd = __tpd;
+				list_del(&__tpd->entry);
+				break;
+			}
+		}
+
+		if (tpd == NULL)
+		{
+			hprintk("unable to locate tpd for dma buffer %x\n",
+						TBRQ_TPD(he_dev->tbrq_head));
+			goto next_tbrq_entry;
+		}
+#else
+		tpd = &he_dev->tpd_base[ TPD_INDEX(TBRQ_TPD(he_dev->tbrq_head)) ];
+#endif
+
+		if (TBRQ_EOS(he_dev->tbrq_head))
+		{
+			HPRINTK("wake_up(tx_waitq) cid 0x%x\n",
+				he_mkcid(he_dev, tpd->vcc->vpi, tpd->vcc->vci));
+			if (tpd->vcc)
+				wake_up(&HE_VCC(tpd->vcc)->tx_waitq);
+
+			goto next_tbrq_entry;
+		}
+
+		for(slot = 0; slot < TPD_MAXIOV; ++slot)
+		{
+			if (tpd->iovec[slot].addr)
+				pci_unmap_single(he_dev->pci_dev,
+					tpd->iovec[slot].addr,
+					tpd->iovec[slot].len & TPD_LEN_MASK,
+							PCI_DMA_TODEVICE);
+			if (tpd->iovec[slot].len & TPD_LST) break;
+				
+		}
+
+		if (tpd->skb)	/* && !TBRQ_MULTIPLE(he_dev->tbrq_head) */
+		{
+			if (tpd->vcc && tpd->vcc->pop)
+				tpd->vcc->pop(tpd->vcc, tpd->skb);
+			else
+				dev_kfree_skb_any(tpd->skb);
+		}
+
+next_tbrq_entry:
+#ifdef USE_TPD_POOL
+		if (tpd) pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
+#else
+		tpd->inuse = 0;
+#endif
+		he_dev->tbrq_head = (struct he_tbrq *)
+				((unsigned long) he_dev->tbrq_base |
+					TBRQ_MASK(++he_dev->tbrq_head));
+	}
+
+	if (updated)
+	{
+		if (updated > he_dev->tbrq_peak) he_dev->tbrq_peak = updated;
+
+		he_writel(he_dev, TBRQ_MASK(he_dev->tbrq_head),
+						G0_TBRQ_H + (group * 16));
+#ifdef CONFIG_IA64_SGI_SN2
+		(void) he_readl(he_dev, G0_TBRQ_H + (group * 16));
+#endif
+	}
+}
+
+
+static void
+he_service_rbpl(struct he_dev *he_dev, int group)
+{
+	struct he_rbp *newtail;
+	struct he_rbp *rbpl_head;
+	int moved = 0;
+
+	rbpl_head = (struct he_rbp *) ((unsigned long)he_dev->rbpl_base |
+					RBPL_MASK(he_readl(he_dev, G0_RBPL_S)));
+
+	for(;;)
+	{
+		newtail = (struct he_rbp *) ((unsigned long)he_dev->rbpl_base |
+						RBPL_MASK(he_dev->rbpl_tail+1));
+
+		/* table 3.42 -- rbpl_tail should never be set to rbpl_head */
+		if ((newtail == rbpl_head) || (newtail->status & RBP_LOANED))
+			break;
+
+		newtail->status |= RBP_LOANED;
+		he_dev->rbpl_tail = newtail;
+		++moved;
+
+	} 
+
+	if (moved) {
+		he_writel(he_dev, RBPL_MASK(he_dev->rbpl_tail), G0_RBPL_T);
+#ifdef CONFIG_IA64_SGI_SN2
+                (void) he_readl(he_dev, G0_RBPL_T);
+#endif
+	}
+}
+
+#ifdef USE_RBPS
+static void
+he_service_rbps(struct he_dev *he_dev, int group)
+{
+	struct he_rbp *newtail;
+	struct he_rbp *rbps_head;
+	int moved = 0;
+
+	rbps_head = (struct he_rbp *) ((unsigned long)he_dev->rbps_base |
+					RBPS_MASK(he_readl(he_dev, G0_RBPS_S)));
+
+	for(;;)
+	{
+		newtail = (struct he_rbp *) ((unsigned long)he_dev->rbps_base |
+						RBPS_MASK(he_dev->rbps_tail+1));
+
+		/* table 3.42 -- rbps_tail should never be set to rbps_head */
+		if ((newtail == rbps_head) || (newtail->status & RBP_LOANED))
+			break;
+
+		newtail->status |= RBP_LOANED;
+		he_dev->rbps_tail = newtail;
+		++moved;
+
+	} 
+
+	if (moved) {
+		he_writel(he_dev, RBPS_MASK(he_dev->rbps_tail), G0_RBPS_T);
+#ifdef CONFIG_IA64_SGI_SN2
+                (void) he_readl(he_dev, G0_RBPS_T);
+#endif
+	}
+}
+#endif /* USE_RBPS */
+
+static void
+he_tasklet(unsigned long data)
+{
+	unsigned long flags;
+	struct he_dev *he_dev = (struct he_dev *) data;
+	int group, type;
+	int updated = 0;
+
+	HPRINTK("tasklet (0x%lx)\n", data);
+#ifdef USE_TASKLET
+	HE_SPIN_LOCK(he_dev, flags);
+#endif
+
+	while(he_dev->irq_head != he_dev->irq_tail)
+	{
+		++updated;
+
+		type = ITYPE_TYPE(he_dev->irq_head->isw);
+		group = ITYPE_GROUP(he_dev->irq_head->isw);
+
+		switch (type)
+		{
+			case ITYPE_RBRQ_THRESH:
+				hprintk("rbrq%d threshold\n", group);
+			case ITYPE_RBRQ_TIMER:
+				if (he_service_rbrq(he_dev, group))
+				{
+					he_service_rbpl(he_dev, group);
+#ifdef USE_RBPS
+					he_service_rbps(he_dev, group);
+#endif /* USE_RBPS */
+				}
+				break;
+			case ITYPE_TBRQ_THRESH:
+				hprintk("tbrq%d threshold\n", group);
+			case ITYPE_TPD_COMPLETE:
+				he_service_tbrq(he_dev, group);
+				break;
+			case ITYPE_RBPL_THRESH:
+				he_service_rbpl(he_dev, group);
+				break;
+			case ITYPE_RBPS_THRESH:
+#ifdef USE_RBPS
+				he_service_rbps(he_dev, group);
+#endif /* USE_RBPS */
+				break;
+			case ITYPE_PHY:
+#ifdef CONFIG_ATM_HE_USE_SUNI
+				HE_SPIN_UNLOCK(he_dev, flags);
+				if (he_dev->atm_dev->phy && he_dev->atm_dev->phy->interrupt)
+					he_dev->atm_dev->phy->interrupt(he_dev->atm_dev);
+				HE_SPIN_LOCK(he_dev, flags);
+#endif
+				HPRINTK1("phy interrupt\n");
+				break;
+			case ITYPE_OTHER:
+				switch (type|group)
+				{
+					case ITYPE_PARITY:
+						hprintk1("parity error\n");
+						break;
+					case ITYPE_ABORT:
+						hprintk("abort 0x%x\n", he_readl(he_dev, ABORT_ADDR));
+						break;
+				}
+				break;
+			default:
+				if (he_dev->irq_head->isw == ITYPE_INVALID)
+				{
+					/* see 8.1.1 -- check all queues */
+
+					HPRINTK("isw not updated 0x%x\n",
+						he_dev->irq_head->isw);
+
+					he_service_rbrq(he_dev, 0);
+					he_service_rbpl(he_dev, 0);
+#ifdef USE_RBPS
+					he_service_rbps(he_dev, 0);
+#endif /* USE_RBPS */
+					he_service_tbrq(he_dev, 0);
+				}
+				else
+					hprintk("bad isw = 0x%x?\n",
+						he_dev->irq_head->isw);
+		}
+
+		he_dev->irq_head->isw = ITYPE_INVALID;
+
+		he_dev->irq_head = (struct he_irq *) NEXT_ENTRY(he_dev->irq_base, he_dev->irq_head, IRQ_MASK);
+	}
+
+	if (updated)
+	{
+		if (updated > he_dev->irq_peak) he_dev->irq_peak = updated;
+
+		he_writel(he_dev,
+			IRQ_SIZE(CONFIG_IRQ_SIZE) |
+			IRQ_THRESH(CONFIG_IRQ_THRESH) |
+			IRQ_TAIL(he_dev->irq_tail), IRQ0_HEAD);
+		(void) he_readl(he_dev, INT_FIFO); /* 8.1.2 controller errata */
+	}
+#ifdef USE_TASKLET
+	HE_SPIN_UNLOCK(he_dev, flags);
+#endif
+}
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,69)
+static irq_return_t
+#else
+static void
+#endif
+he_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
+{
+	unsigned long flags;
+	struct he_dev *he_dev = (struct he_dev * )dev_id;
+	int handled = 0;
+
+	if (he_dev == NULL)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,69)
+		return IRQ_NONE;
+#else
+		return;
+#endif
+
+	HE_SPIN_LOCK(he_dev, flags);
+
+	he_dev->irq_tail = (struct he_irq *) (((unsigned long)he_dev->irq_base) |
+						(*he_dev->irq_tailoffset << 2));
+
+	if (he_dev->irq_tail == he_dev->irq_head)
+	{
+		HPRINTK1("tailoffset not updated?\n");
+		he_dev->irq_tail = (struct he_irq *) ((unsigned long)he_dev->irq_base |
+			((he_readl(he_dev, IRQ0_BASE) & IRQ_MASK) << 2));
+		(void) he_readl(he_dev, INT_FIFO);	/* 8.1.2 controller errata */
+	}
+
+#ifdef DEBUG
+	if (he_dev->irq_head == he_dev->irq_tail /* && !IRQ_PENDING */)
+		hprintk1("spurious (or shared) interrupt?\n");
+#endif
+
+	if (he_dev->irq_head != he_dev->irq_tail)
+	{
+		handled = 1;
+#ifdef USE_TASKLET
+		tasklet_schedule(&he_dev->tasklet);
+#else
+		he_tasklet((unsigned long) he_dev);
+#endif
+		he_writel(he_dev, INT_CLEAR_A, INT_FIFO);
+							/* clear interrupt */
+#ifdef CONFIG_IA64_SGI_SN2
+		(void) he_readl(he_dev, INT_FIFO);
+#endif
+	}
+	HE_SPIN_UNLOCK(he_dev, flags);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,69)
+	return IRQ_RETVAL(handled);
+#else
+	return;
+#endif
+
+}
+
+static __inline__ void
+__enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
+{
+	struct he_tpdrq *new_tail;
+
+	HPRINTK("tpdrq %p cid 0x%x -> tpdrq_tail %p\n",
+					tpd, cid, he_dev->tpdrq_tail);
+
+	/* new_tail = he_dev->tpdrq_tail; */
+	new_tail = (struct he_tpdrq *) ((unsigned long) he_dev->tpdrq_base |
+					TPDRQ_MASK(he_dev->tpdrq_tail+1));
+
+	/*
+	 * check to see if we are about to set the tail == head
+	 * if true, update the head pointer from the adapter
+	 * to see if this is really the case (reading the queue
+	 * head for every enqueue would be unnecessarily slow)
+	 */
+
+	if (new_tail == he_dev->tpdrq_head)
+	{
+		he_dev->tpdrq_head = (struct he_tpdrq *)
+			(((unsigned long)he_dev->tpdrq_base) |
+				TPDRQ_MASK(he_readl(he_dev, TPDRQ_B_H)));
+
+		if (new_tail == he_dev->tpdrq_head)
+		{
+			hprintk("tpdrq full (cid 0x%x)\n", cid);
+			/*
+			 * FIXME
+			 * push tpd onto a transmit backlog queue
+			 * after service_tbrq, service the backlog
+			 * for now, we just drop the pdu
+			 */
+			if (tpd->skb)
+			{
+				if (tpd->vcc->pop)
+					tpd->vcc->pop(tpd->vcc, tpd->skb);
+				else
+					dev_kfree_skb_any(tpd->skb);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,99)
+				++tpd->vcc->stats->tx_err;
+#else
+				atomic_inc(&tpd->vcc->stats->tx_err);
+#endif
+			}
+#ifdef USE_TPD_POOL
+			pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
+#else
+			tpd->inuse = 0;
+#endif
+			return;
+		}
+	}
+
+	/* 2.1.5 transmit packet descriptor ready queue */
+#ifdef USE_TPD_POOL
+	list_add_tail(&tpd->entry, &he_dev->outstanding_tpds);
+	he_dev->tpdrq_tail->tpd = TPD_ADDR(tpd->status);
+#else
+	he_dev->tpdrq_tail->tpd = he_dev->tpd_base_phys +
+				(TPD_INDEX(tpd->status) * sizeof(struct he_tpd));
+#endif
+	he_dev->tpdrq_tail->cid = cid;
+	wmb();
+
+	he_dev->tpdrq_tail = new_tail;
+
+	he_writel(he_dev, TPDRQ_MASK(he_dev->tpdrq_tail), TPDRQ_T);
+#ifdef CONFIG_IA64_SGI_SN2
+	(void) he_readl(he_dev, TPDRQ_T);
+#endif
+}
+
+static int
+he_open(struct atm_vcc *vcc, short vpi, int vci)
+{
+	unsigned long flags;
+	struct he_dev *he_dev = HE_DEV(vcc->dev);
+	struct he_vcc *he_vcc;
+	int err = 0;
+	unsigned cid, rsr0, rsr1, rsr4, tsr0, tsr0_aal, tsr4, period, reg, clock;
+
+	
+	if ((err = atm_find_ci(vcc, &vpi, &vci)))
+	{
+		HPRINTK("atm_find_ci err = %d\n", err);
+		return err;
+	}
+	if (vci == ATM_VCI_UNSPEC || vpi == ATM_VPI_UNSPEC) return 0;
+	vcc->vpi = vpi;
+	vcc->vci = vci;
+
+	HPRINTK("open vcc %p %d.%d\n", vcc, vpi, vci);
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,1)
+	vcc->flags |= ATM_VF_ADDR;
+#else
+	set_bit(ATM_VF_ADDR, &vcc->flags);
+#endif
+
+	cid = he_mkcid(he_dev, vpi, vci);
+
+	he_vcc = (struct he_vcc *) kmalloc(sizeof(struct he_vcc), GFP_ATOMIC);
+	if (he_vcc == NULL)
+	{
+		hprintk1("unable to allocate he_vcc during open\n");
+		return -ENOMEM;
+	}
+
+	he_vcc->iov_tail = he_vcc->iov_head;
+	he_vcc->pdu_len = 0;
+	he_vcc->rc_index = -1;
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,1)
+	init_waitqueue(&he_vcc->rx_waitq);
+	init_waitqueue(&he_vcc->tx_waitq);
+#else
+	init_waitqueue_head(&he_vcc->rx_waitq);
+	init_waitqueue_head(&he_vcc->tx_waitq);
+#endif
+
+	HE_VCC(vcc) = he_vcc;
+
+	if (vcc->qos.txtp.traffic_class != ATM_NONE)
+	{
+		int pcr_goal;
+
+                pcr_goal = atm_pcr_goal(&vcc->qos.txtp);
+                if (pcr_goal == 0)
+                        pcr_goal = he_dev->atm_dev->link_rate;
+                if (pcr_goal < 0)	/* means round down, technically */
+                        pcr_goal = -pcr_goal;
+
+		HPRINTK("open tx cid 0x%x pcr_goal %d\n", cid, pcr_goal);
+
+		switch (vcc->qos.aal)
+		{
+			case ATM_AAL5:
+				tsr0_aal = TSR0_AAL5;
+				tsr4 = TSR4_AAL5;
+				break;
+			case ATM_AAL0:
+				tsr0_aal = TSR0_AAL0_SDU;
+				tsr4 = TSR4_AAL0_SDU;
+				break;
+			default:
+				err = -EINVAL;
+				goto open_failed;
+		}
+
+		HE_SPIN_LOCK(he_dev, flags);
+		tsr0 = he_readl_tsr0(he_dev, cid);
+		HE_SPIN_UNLOCK(he_dev, flags);
+
+		if (TSR0_CONN_STATE(tsr0) != 0)
+		{
+			hprintk("cid 0x%x not idle (tsr0 = 0x%x)\n", cid, tsr0);
+			err = -EBUSY;
+			goto open_failed;
+		}
+
+		switch(vcc->qos.txtp.traffic_class)
+		{
+			case ATM_UBR:
+				/* 2.3.3.1 open connection ubr */
+
+				tsr0 = TSR0_UBR | TSR0_GROUP(0) | tsr0_aal |
+					TSR0_USE_WMIN | TSR0_UPDATE_GER;
+				break;
+
+			case ATM_CBR:
+				/* 2.3.3.2 open connection cbr */
+
+				/* 8.2.3 cbr scheduler wrap problem -- limit to 90% total link rate */
+				if ((he_dev->total_bw + pcr_goal)
+					> (he_dev->atm_dev->link_rate * 9 / 10))
+				{
+					err = -EBUSY;
+					goto open_failed;
+				}
+
+				HE_SPIN_LOCK(he_dev, flags);			/* also protects he_dev->cs_stper[] */
+
+				/* find an unused cs_stper register */
+				for(reg = 0; reg < HE_NUM_CS_STPER; ++reg)
+					if (he_dev->cs_stper[reg].inuse == 0 || 
+						he_dev->cs_stper[reg].pcr == pcr_goal)
+					break;
+
+				if (reg == HE_NUM_CS_STPER)
+				{
+					err = -EBUSY;
+					HE_SPIN_UNLOCK(he_dev, flags);
+					goto open_failed;
+				}
+
+				he_dev->total_bw += pcr_goal;
+
+				he_vcc->rc_index = reg;
+				++he_dev->cs_stper[reg].inuse;
+				he_dev->cs_stper[reg].pcr = pcr_goal;
+
+				clock = he_is622(he_dev) ? 66667000 : 50000000;
+				period = clock / pcr_goal;
+				
+				HPRINTK("rc_index = %d period = %d\n",
+								reg, period);
+
+				he_writel_mbox(he_dev, rate_to_atmf(period/2),
+							CS_STPER0 + reg);
+				HE_SPIN_UNLOCK(he_dev, flags);
+
+				tsr0 = TSR0_CBR | TSR0_GROUP(0) | tsr0_aal |
+							TSR0_RC_INDEX(reg);
+
+				break;
+			default:
+				err = -EINVAL;
+				goto open_failed;
+		}
+
+		HE_SPIN_LOCK(he_dev, flags);
+
+		he_writel_tsr0(he_dev, tsr0, cid);
+		he_writel_tsr4(he_dev, tsr4 | 1, cid);
+		he_writel_tsr1(he_dev, TSR1_MCR(rate_to_atmf(0)) |
+					TSR1_PCR(rate_to_atmf(pcr_goal)), cid);
+		he_writel_tsr2(he_dev, TSR2_ACR(rate_to_atmf(pcr_goal)), cid);
+		he_writel_tsr9(he_dev, TSR9_OPEN_CONN, cid);
+
+		he_writel_tsr3(he_dev, 0x0, cid);
+		he_writel_tsr5(he_dev, 0x0, cid);
+		he_writel_tsr6(he_dev, 0x0, cid);
+		he_writel_tsr7(he_dev, 0x0, cid);
+		he_writel_tsr8(he_dev, 0x0, cid);
+		he_writel_tsr10(he_dev, 0x0, cid);
+		he_writel_tsr11(he_dev, 0x0, cid);
+		he_writel_tsr12(he_dev, 0x0, cid);
+		he_writel_tsr13(he_dev, 0x0, cid);
+		he_writel_tsr14(he_dev, 0x0, cid);
+#ifdef CONFIG_IA64_SGI_SN2
+		(void) he_readl_tsr0(he_dev, cid);
+#endif
+		HE_SPIN_UNLOCK(he_dev, flags);
+	}
+
+	if (vcc->qos.rxtp.traffic_class != ATM_NONE)
+	{
+		unsigned aal;
+
+		HPRINTK("open rx cid 0x%x (rx_waitq %p)\n", cid,
+		 				&HE_VCC(vcc)->rx_waitq);
+
+		switch (vcc->qos.aal)
+		{
+			case ATM_AAL5:
+				aal = RSR0_AAL5;
+				break;
+			case ATM_AAL0:
+				aal = RSR0_RAWCELL;
+				break;
+			default:
+				err = -EINVAL;
+				goto open_failed;
+		}
+
+		HE_SPIN_LOCK(he_dev, flags);
+
+		rsr0 = he_readl_rsr0(he_dev, cid);
+		if (rsr0 & RSR0_OPEN_CONN)
+		{
+			HE_SPIN_UNLOCK(he_dev, flags);
+
+			hprintk("cid 0x%x not idle (rsr0 = 0x%x)\n", cid, rsr0);
+			err = -EBUSY;
+			goto open_failed;
+		}
+
+#ifdef USE_RBPS
+		rsr1 = RSR1_GROUP(0);
+		rsr4 = RSR4_GROUP(0);
+#else /* !USE_RBPS */
+		rsr1 = RSR1_GROUP(0)|RSR1_RBPL_ONLY;
+		rsr4 = RSR4_GROUP(0)|RSR4_RBPL_ONLY;
+#endif /* USE_RBPS */
+		rsr0 = vcc->qos.rxtp.traffic_class == ATM_UBR ? 
+				(RSR0_EPD_ENABLE|RSR0_PPD_ENABLE) : 0;
+
+#ifdef USE_CHECKSUM_HW
+		if (vpi == 0 && vci >= ATM_NOT_RSV_VCI) rsr0 |= RSR0_TCP_CKSUM;
+#endif
+
+		he_writel_rsr4(he_dev, rsr4, cid);
+		he_writel_rsr1(he_dev, rsr1, cid);
+		/* 5.1.11 last parameter initialized should be
+		          the open/closed indication in rsr0 */
+		he_writel_rsr0(he_dev,
+			rsr0 | RSR0_START_PDU | RSR0_OPEN_CONN | aal, cid);
+#ifdef CONFIG_IA64_SGI_SN2
+		(void) he_readl_rsr0(he_dev, cid);
+#endif
+
+		HE_SPIN_UNLOCK(he_dev, flags);
+
+#ifndef USE_HE_FIND_VCC
+		HE_LOOKUP_VCC(he_dev, cid) = vcc;
+#endif
+	}
+
+open_failed:
+
+	if (err)
+	{
+		if (he_vcc) kfree(he_vcc);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,1)
+		vcc->flags &= ~ATM_VF_ADDR;
+#else
+		clear_bit(ATM_VF_ADDR, &vcc->flags);
+#endif
+	}
+	else
+	{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,1)
+		vcc->flags |= ATM_VF_READY;
+#else
+		set_bit(ATM_VF_READY, &vcc->flags);
+#endif
+	}
+
+	return err;
+}
+
+static void
+he_close(struct atm_vcc *vcc)
+{
+	unsigned long flags;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,1)
+	DECLARE_WAITQUEUE(wait, current);
+#else
+	struct wait_queue wait = { current, NULL };
+#endif
+	struct he_dev *he_dev = HE_DEV(vcc->dev);
+	struct he_tpd *tpd;
+	unsigned cid;
+	struct he_vcc *he_vcc = HE_VCC(vcc);
+#define MAX_RETRY 30
+	int retry = 0, sleep = 1, tx_inuse;
+
+	HPRINTK("close vcc %p %d.%d\n", vcc, vcc->vpi, vcc->vci);
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,1)
+	vcc->flags &= ~ATM_VF_READY;
+#else
+	clear_bit(ATM_VF_READY, &vcc->flags);
+#endif
+	cid = he_mkcid(he_dev, vcc->vpi, vcc->vci);
+
+	if (vcc->qos.rxtp.traffic_class != ATM_NONE)
+	{
+		int timeout;
+
+		HPRINTK("close rx cid 0x%x\n", cid);
+
+		/* 2.7.2.2 close receive operation */
+
+		/* wait for previous close (if any) to finish */
+
+		HE_SPIN_LOCK(he_dev, flags);
+		while(he_readl(he_dev, RCC_STAT) & RCC_BUSY)
+		{
+			HPRINTK("close cid 0x%x RCC_BUSY\n", cid);
+			udelay(250);
+		}
+
+		add_wait_queue(&he_vcc->rx_waitq, &wait);
+		set_current_state(TASK_UNINTERRUPTIBLE);
+
+		he_writel_rsr0(he_dev, RSR0_CLOSE_CONN, cid);
+#ifdef CONFIG_IA64_SGI_SN2
+		(void) he_readl_rsr0(he_dev, cid);
+#endif
+		he_writel_mbox(he_dev, cid, RXCON_CLOSE);
+		HE_SPIN_UNLOCK(he_dev, flags);
+
+		timeout = schedule_timeout(30*HZ);
+
+		remove_wait_queue(&he_vcc->rx_waitq, &wait);
+		set_current_state(TASK_RUNNING);
+
+		if (timeout == 0)
+			hprintk("close rx timeout cid 0x%x\n", cid);
+
+#ifndef USE_HE_FIND_VCC
+		HE_LOOKUP_VCC(he_dev, cid) = NULL;
+#endif
+		HPRINTK("close rx cid 0x%x complete\n", cid);
+
+	}
+
+	if (vcc->qos.txtp.traffic_class != ATM_NONE)
+	{
+		volatile unsigned tsr4, tsr0;
+		int timeout;
+
+		HPRINTK("close tx cid 0x%x\n", cid);
+		
+		/* 2.1.2
+		 *
+		 * ... the host must first stop queueing packets to the TPDRQ
+		 * on the connection to be closed, then wait for all outstanding
+		 * packets to be transmitted and their buffers returned to the
+		 * TBRQ. When the last packet on the connection arrives in the
+		 * TBRQ, the host issues the close command to the adapter.
+		 */
+
+		while (((tx_inuse = atomic_read(&vcc->sk->wmem_alloc)) > 0)
+							&& (retry < MAX_RETRY))
+		{
+			set_current_state(TASK_UNINTERRUPTIBLE);
+			(void) schedule_timeout(sleep);
+			set_current_state(TASK_RUNNING);
+			if (sleep < HZ) sleep = sleep * 2;
+
+			++retry;
+		}
+
+		if (tx_inuse) hprintk("close tx cid 0x%x tx_inuse = %d\n",
+								cid, tx_inuse);
+
+		/* 2.3.1.1 generic close operations with flush */
+
+		HE_SPIN_LOCK(he_dev, flags);
+		he_writel_tsr4_upper(he_dev, TSR4_FLUSH_CONN, cid);
+					/* also clears TSR4_SESSION_ENDED */
+#ifdef CONFIG_IA64_SGI_SN2
+		(void) he_readl_tsr4(he_dev, cid);
+#endif
+
+		switch(vcc->qos.txtp.traffic_class)
+		{
+			case ATM_UBR:
+				he_writel_tsr1(he_dev, 
+					TSR1_MCR(rate_to_atmf(200000))
+					| TSR1_PCR(0), cid);
+				break;
+			case ATM_CBR:
+				he_writel_tsr14_upper(he_dev, TSR14_DELETE, cid);
+				break;
+		}
+
+
+		tpd = __alloc_tpd(he_dev);
+		if (tpd == NULL)
+		{
+			hprintk("close tx he_alloc_tpd failed cid 0x%x\n", cid);
+			goto close_tx_incomplete;
+		}
+		tpd->status |= TPD_EOS | TPD_INT;
+		tpd->skb = NULL;
+		tpd->vcc = vcc;
+		wmb();
+
+		add_wait_queue(&he_vcc->tx_waitq, &wait);
+		set_current_state(TASK_UNINTERRUPTIBLE);
+		__enqueue_tpd(he_dev, tpd, cid);
+		HE_SPIN_UNLOCK(he_dev, flags);
+
+		timeout = schedule_timeout(30*HZ);
+
+		remove_wait_queue(&he_vcc->tx_waitq, &wait);
+		set_current_state(TASK_RUNNING);
+
+		if (timeout == 0)
+		{
+			hprintk("close tx timeout cid 0x%x\n", cid);
+			goto close_tx_incomplete;
+		}
+
+		HE_SPIN_LOCK(he_dev, flags);
+		while (!((tsr4 = he_readl_tsr4(he_dev, cid))
+							& TSR4_SESSION_ENDED))
+		{
+			HPRINTK("close tx cid 0x%x !TSR4_SESSION_ENDED (tsr4 = 0x%x)\n", cid, tsr4);
+			udelay(250);
+		}
+
+		while (TSR0_CONN_STATE(tsr0 = he_readl_tsr0(he_dev, cid)) != 0)
+		{
+			HPRINTK("close tx cid 0x%x TSR0_CONN_STATE != 0 (tsr0 = 0x%x)\n", cid, tsr0);
+			udelay(250);
+		}
+
+close_tx_incomplete:
+
+		if (vcc->qos.txtp.traffic_class == ATM_CBR)
+		{
+			int reg = he_vcc->rc_index;
+
+			HPRINTK("cs_stper reg = %d\n", reg);
+
+			if (he_dev->cs_stper[reg].inuse == 0)
+				hprintk("cs_stper[%d].inuse = 0!\n", reg);
+			else
+				--he_dev->cs_stper[reg].inuse;
+
+			he_dev->total_bw -= he_dev->cs_stper[reg].pcr;
+		}
+		HE_SPIN_UNLOCK(he_dev, flags);
+
+		HPRINTK("close tx cid 0x%x complete\n", cid);
+	}
+
+	kfree(he_vcc);
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,1)
+	vcc->flags &= ~ATM_VF_ADDR;
+#else
+	clear_bit(ATM_VF_ADDR, &vcc->flags);
+#endif
+}
+
+static int
+he_sg_send(struct atm_vcc *vcc, unsigned long start, unsigned long size)
+{
+#ifdef USE_SCATTERGATHER
+	return 1;
+#else
+	return 0;
+#endif
+}
+
+static int
+he_send(struct atm_vcc *vcc, struct sk_buff *skb)
+{
+	unsigned long flags;
+	struct he_dev *he_dev = HE_DEV(vcc->dev);
+	unsigned cid = he_mkcid(he_dev, vcc->vpi, vcc->vci);
+	struct he_tpd *tpd;
+#ifdef USE_SCATTERGATHER
+	int i, slot = 0;
+#endif
+
+#define HE_TPD_BUFSIZE 0xffff
+
+	HPRINTK("send %d.%d\n", vcc->vpi, vcc->vci);
+
+	if ((skb->len > HE_TPD_BUFSIZE) ||
+		((vcc->qos.aal == ATM_AAL0) && (skb->len != ATM_AAL0_SDU)))
+	{
+		hprintk("buffer too large (or small) -- %d bytes\n", skb->len );
+		if (vcc->pop)
+			vcc->pop(vcc, skb);
+		else
+			dev_kfree_skb_any(skb);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,99)
+		++vcc->stats->tx_err;
+#else
+		atomic_inc(&vcc->stats->tx_err);
+#endif
+		return -EINVAL;
+	}
+
+#ifndef USE_SCATTERGATHER
+	if (skb_shinfo(skb)->nr_frags)
+	{
+		hprintk1("no scatter/gather support\n");
+		if (vcc->pop)
+			vcc->pop(vcc, skb);
+		else
+			dev_kfree_skb_any(skb);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,99)
+		++vcc->stats->tx_err;
+#else
+		atomic_inc(&vcc->stats->tx_err);
+#endif
+		return -EINVAL;
+	}
+#endif
+	HE_SPIN_LOCK(he_dev, flags);
+
+	tpd = __alloc_tpd(he_dev);
+	if (tpd == NULL)
+	{
+		if (vcc->pop)
+			vcc->pop(vcc, skb);
+		else
+			dev_kfree_skb_any(skb);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,99)
+		++vcc->stats->tx_err;
+#else
+		atomic_inc(&vcc->stats->tx_err);
+#endif
+		HE_SPIN_UNLOCK(he_dev, flags);
+		return -ENOMEM;
+	}
+
+	if (vcc->qos.aal == ATM_AAL5)
+		tpd->status |= TPD_CELLTYPE(TPD_USERCELL);
+	else
+	{
+		char *pti_clp = (void *) (skb->data + 3);
+		int clp, pti;
+
+		pti = (*pti_clp & ATM_HDR_PTI_MASK) >> ATM_HDR_PTI_SHIFT; 
+		clp = (*pti_clp & ATM_HDR_CLP);
+		tpd->status |= TPD_CELLTYPE(pti);
+		if (clp) tpd->status |= TPD_CLP;
+
+		skb_pull(skb, ATM_AAL0_SDU - ATM_CELL_PAYLOAD);
+	}
+
+#ifdef USE_SCATTERGATHER
+	tpd->iovec[slot].addr = pci_map_single(he_dev->pci_dev, skb->data,
+				skb->len - skb->data_len, PCI_DMA_TODEVICE);
+	tpd->iovec[slot].len = skb->len - skb->data_len;
+	++slot;
+
+	for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
+	{
+		skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
+
+		if (slot == TPD_MAXIOV)		/* send tpd; start new tpd */
+		{
+			tpd->vcc = vcc;
+			tpd->skb = NULL;	/* not the last fragment
+						   so dont ->push() yet */
+			wmb();
+
+			__enqueue_tpd(he_dev, tpd, cid);
+			tpd = __alloc_tpd(he_dev);
+			if (tpd == NULL)
+			{
+				if (vcc->pop)
+					vcc->pop(vcc, skb);
+				else
+					dev_kfree_skb_any(skb);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,99)
+				++vcc->stats->tx_err;
+#else
+				atomic_inc(&vcc->stats->tx_err);
+				HE_SPIN_UNLOCK(he_dev, flags);
+#endif
+				return -ENOMEM;
+			}
+			tpd->status |= TPD_USERCELL;
+			slot = 0;
+		}
+
+		tpd->iovec[slot].addr = pci_map_single(he_dev->pci_dev,
+			(void *) page_address(frag->page) + frag->page_offset,
+				frag->size, PCI_DMA_TODEVICE);
+		tpd->iovec[slot].len = frag->size;
+		++slot;
+
+	}
+
+	tpd->iovec[slot-1].len |= TPD_LST;
+#else
+	tpd->address0 = pci_map_single(he_dev->pci_dev, skb->data, skb->len, PCI_DMA_TODEVICE);
+	tpd->length0 = skb->len | TPD_LST;
+#endif
+	tpd->status |= TPD_INT;
+
+	tpd->vcc = vcc;
+	tpd->skb = skb;
+	wmb();
+	ATM_SKB(skb)->vcc = vcc;
+
+	__enqueue_tpd(he_dev, tpd, cid);
+	HE_SPIN_UNLOCK(he_dev, flags);
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,99)
+	++vcc->stats->tx;
+#else
+	atomic_inc(&vcc->stats->tx);
+#endif
+
+	return 0;
+}
+
+static int
+he_ioctl(struct atm_dev *atm_dev, unsigned int cmd, void *arg)
+{
+	unsigned long flags;
+	struct he_dev *he_dev = HE_DEV(atm_dev);
+	struct he_ioctl_reg reg;
+	int err = 0;
+
+	switch (cmd)
+	{
+		case HE_GET_REG:
+			if (!capable(CAP_NET_ADMIN)) return -EPERM;
+
+			copy_from_user(&reg, (struct he_ioctl_reg *) arg,
+						sizeof(struct he_ioctl_reg));
+			HE_SPIN_LOCK(he_dev, flags);
+			switch (reg.type)
+			{
+				case HE_REGTYPE_PCI:
+					reg.val = he_readl(he_dev, reg.addr);
+					break;
+				case HE_REGTYPE_RCM:
+					reg.val =
+						he_readl_rcm(he_dev, reg.addr);
+					break;
+				case HE_REGTYPE_TCM:
+					reg.val =
+						he_readl_tcm(he_dev, reg.addr);
+					break;
+				case HE_REGTYPE_MBOX:
+					reg.val =
+						he_readl_mbox(he_dev, reg.addr);
+					break;
+				default:
+					err = -EINVAL;
+					break;
+			}
+			HE_SPIN_UNLOCK(he_dev, flags);
+			if (err == 0) copy_to_user((struct he_ioctl_reg *) arg, &reg,
+							sizeof(struct he_ioctl_reg));
+			break;
+		default:
+#ifdef CONFIG_ATM_HE_USE_SUNI
+			if (atm_dev->phy && atm_dev->phy->ioctl)
+				err = atm_dev->phy->ioctl(atm_dev, cmd, arg);
+#else /* CONFIG_ATM_HE_USE_SUNI */
+			return -EINVAL;
+#endif /* CONFIG_ATM_HE_USE_SUNI */
+			break;
+	}
+
+	return err;
+}
+
+static void
+he_phy_put(struct atm_dev *atm_dev, unsigned char val, unsigned long addr)
+{
+	unsigned long flags;
+	struct he_dev *he_dev = HE_DEV(atm_dev);
+
+	HPRINTK("phy_put(val 0x%x, addr 0x%lx)\n", val, addr);
+
+	HE_SPIN_LOCK(he_dev, flags);
+        he_writel(he_dev, val, FRAMER + (addr*4));
+#ifdef CONFIG_IA64_SGI_SN2
+	(void) he_readl(he_dev, FRAMER + (addr*4));
+#endif
+	HE_SPIN_UNLOCK(he_dev, flags);
+}
+ 
+        
+static unsigned char
+he_phy_get(struct atm_dev *atm_dev, unsigned long addr)
+{ 
+	unsigned long flags;
+	struct he_dev *he_dev = HE_DEV(atm_dev);
+	unsigned reg;
+
+	HE_SPIN_LOCK(he_dev, flags);
+        reg = he_readl(he_dev, FRAMER + (addr*4));
+	HE_SPIN_UNLOCK(he_dev, flags);
+
+	HPRINTK("phy_get(addr 0x%lx) =0x%x\n", addr, reg);
+	return reg;
+}
+
+static int
+he_proc_read(struct atm_dev *dev, loff_t *pos, char *page)
+{
+	unsigned long flags;
+	struct he_dev *he_dev = HE_DEV(dev);
+	int left, i;
+#ifdef notdef
+	struct he_rbrq *rbrq_tail;
+	struct he_tpdrq *tpdrq_head;
+        int rbpl_head, rbpl_tail;
+#endif
+	static long mcc = 0, oec = 0, dcc = 0, cec = 0;
+
+
+	left = *pos;
+	if (!left--)
+		return sprintf(page, "%s\n", version);
+
+	if (!left--)
+		return sprintf(page, "%s%s\n\n",
+			he_dev->prod_id, he_dev->media & 0x40 ? "SM" : "MM");
+
+	if (!left--)
+		return sprintf(page, "Mismatched Cells  VPI/VCI Not Open  Dropped Cells  RCM Dropped Cells\n");
+
+	HE_SPIN_LOCK(he_dev, flags);
+	mcc += he_readl(he_dev, MCC);
+	oec += he_readl(he_dev, OEC);
+	dcc += he_readl(he_dev, DCC);
+	cec += he_readl(he_dev, CEC);
+	HE_SPIN_UNLOCK(he_dev, flags);
+
+	if (!left--)
+		return sprintf(page, "%16ld  %16ld  %13ld  %17ld\n\n", 
+							mcc, oec, dcc, cec);
+
+	if (!left--)
+		return sprintf(page, "irq_size = %d  inuse = ?  peak = %d\n",
+				CONFIG_IRQ_SIZE, he_dev->irq_peak);
+
+	if (!left--)
+		return sprintf(page, "tpdrq_size = %d  inuse = ?\n",
+						CONFIG_TPDRQ_SIZE);
+
+	if (!left--)
+		return sprintf(page, "rbrq_size = %d  inuse = ?  peak = %d\n",
+				CONFIG_RBRQ_SIZE, he_dev->rbrq_peak);
+
+	if (!left--)
+		return sprintf(page, "tbrq_size = %d  peak = %d\n",
+					CONFIG_TBRQ_SIZE, he_dev->tbrq_peak);
+
+
+#ifdef notdef
+        rbpl_head = RBPL_MASK(he_readl(he_dev, G0_RBPL_S));
+        rbpl_tail = RBPL_MASK(he_readl(he_dev, G0_RBPL_T));
+
+	inuse = rbpl_head - rbpl_tail;
+	if (inuse < 0) inuse += CONFIG_RBPL_SIZE * sizeof(struct he_rbp);
+	inuse /= sizeof(struct he_rbp);
+
+	if (!left--)
+		return sprintf(page, "rbpl_size = %d  inuse = %d\n\n",
+						CONFIG_RBPL_SIZE, inuse);
+#endif
+
+	if (!left--)
+		return sprintf(page, "rate controller periods (cbr)\n                 pcr  #vc\n");
+
+	for (i = 0; i < HE_NUM_CS_STPER; ++i)
+		if (!left--)
+			return sprintf(page, "cs_stper%-2d  %8ld  %3d\n", i,
+						he_dev->cs_stper[i].pcr,
+						he_dev->cs_stper[i].inuse);
+
+	if (!left--)
+		return sprintf(page, "total bw (cbr): %d  (limit %d)\n",
+			he_dev->total_bw, he_dev->atm_dev->link_rate * 10 / 9);
+
+	return 0;
+}
+
+/* eeprom routines  -- see 4.7 */
+
+u8
+read_prom_byte(struct he_dev *he_dev, int addr)
+{
+	u32 val = 0, tmp_read = 0;
+	int i, j = 0;
+	u8 byte_read = 0;
+
+	val = readl(he_dev->membase + HOST_CNTL);
+	val &= 0xFFFFE0FF;
+       
+	/* Turn on write enable */
+	val |= 0x800;
+	he_writel(he_dev, val, HOST_CNTL);
+       
+	/* Send READ instruction */
+	for (i=0; i<sizeof(readtab)/sizeof(readtab[0]); i++) {
+		he_writel(he_dev, val | readtab[i], HOST_CNTL);
+		udelay(EEPROM_DELAY);
+	}
+       
+        /* Next, we need to send the byte address to read from */
+	for (i=7; i>=0; i--) {
+		he_writel(he_dev, val | clocktab[j++] | (((addr >> i) & 1) << 9), HOST_CNTL);
+		udelay(EEPROM_DELAY);
+		he_writel(he_dev, val | clocktab[j++] | (((addr >> i) & 1) << 9), HOST_CNTL);
+		udelay(EEPROM_DELAY);
+	}
+       
+	j=0;
+
+	val &= 0xFFFFF7FF;      /* Turn off write enable */
+	he_writel(he_dev, val, HOST_CNTL);
+       
+	/* Now, we can read data from the EEPROM by clocking it in */
+	for (i=7; i>=0; i--) {
+		he_writel(he_dev, val | clocktab[j++], HOST_CNTL);
+	        udelay(EEPROM_DELAY);
+	        tmp_read = he_readl(he_dev, HOST_CNTL);
+	        byte_read |= (unsigned char)
+	                        ((tmp_read & ID_DOUT)
+	                         >> ID_DOFFSET << i);
+		he_writel(he_dev, val | clocktab[j++], HOST_CNTL);
+		udelay(EEPROM_DELAY);
+	}
+       
+	he_writel(he_dev, val | ID_CS, HOST_CNTL);
+	udelay(EEPROM_DELAY);
+
+        return (byte_read);
+}
+
+MODULE_AUTHOR("chas williams <chas@cmf.nrl.navy.mil>");
+MODULE_DESCRIPTION("ForeRunnerHE ATM Adapter driver");
+MODULE_PARM(disable64, "h");
+MODULE_PARM_DESC(disable64, "disable 64-bit pci bus transfers");
+MODULE_PARM(nvpibits, "i");
+MODULE_PARM_DESC(nvpibits, "numbers of bits for vpi (default 0)");
+MODULE_PARM(nvcibits, "i");
+MODULE_PARM_DESC(nvcibits, "numbers of bits for vci (default 12)");
+MODULE_PARM(rx_skb_reserve, "i");
+MODULE_PARM_DESC(rx_skb_reserve, "padding for receive skb (default 16)");
+MODULE_PARM(irq_coalesce, "i");
+MODULE_PARM_DESC(irq_coalesce, "use interrupt coalescing (default 1)");
+MODULE_PARM(sdh, "i");
+MODULE_PARM_DESC(sdh, "use SDH framing (default 0)");
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,1)
+static struct pci_device_id he_pci_tbl[] __devinitdata = {
+	{ PCI_VENDOR_ID_FORE, PCI_DEVICE_ID_FORE_HE, PCI_ANY_ID, PCI_ANY_ID,
+	  0, 0, 0 },
+        { 0, }
+};
+
+static struct pci_driver he_driver = {
+	.name =		"he",
+	.probe =	he_init_one,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,9)
+	.remove =	__devexit_p(he_remove_one),
+#else
+	.remove =	he_remove_one,
+#endif
+	.id_table =	he_pci_tbl,
+};
+
+static int __init he_init(void)
+{
+        return pci_module_init(&he_driver);
+}
+
+static void __exit he_cleanup(void)
+{
+        pci_unregister_driver(&he_driver);
+}
+
+module_init(he_init);
+module_exit(he_cleanup);
+#else
+static int __init
+he_init()
+{
+	if (!pci_present())
+		return -EIO;
+
+#ifdef CONFIG_ATM_HE_USE_SUNI_MODULE
+	/* request_module("suni"); */
+#endif
+
+	pci_dev = NULL;
+	while ((pci_dev = pci_find_device(PCI_VENDOR_ID_FORE,
+					PCI_DEVICE_ID_FORE_HE, pci_dev)) != NULL)
+		if (he_init_one(pci_dev, NULL) == 0)
+			++ndevs;
+
+	return (ndevs ? 0 : -ENODEV);
+}
+
+static void __devexit
+he_cleanup(void)
+{
+	while (he_devs)
+	{
+		struct he_dev *next = he_devs->next;
+		he_stop(he_devs);
+		atm_dev_deregister(he_devs->atm_dev);
+		kfree(he_devs);
+
+		he_devs = next;
+	}
+
+}
+
+int init_module(void)
+{
+	return he_init();
+}
+
+void cleanup_module(void)
+{
+	he_cleanup();
+}
+#endif
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,7)
+MODULE_LICENSE("GPL");
+#endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/atm/he.h linux-2.4.22-pre2/drivers/atm/he.h
--- linux-2.4.21/drivers/atm/he.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/atm/he.h	2003-06-26 21:43:33.000000000 +0000
@@ -0,0 +1,935 @@
+/* $Id: he.h,v 1.4 2003/05/06 22:48:00 chas Exp $ */
+
+/*
+
+  he.h
+
+  ForeRunnerHE ATM Adapter driver for ATM on Linux
+  Copyright (C) 1999-2001  Naval Research Laboratory
+
+  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
+
+*/
+
+/*
+
+  he.h
+
+  ForeRunnerHE ATM Adapter driver for ATM on Linux
+  Copyright (C) 1999-2000  Naval Research Laboratory
+
+  Permission to use, copy, modify and distribute this software and its
+  documentation is hereby granted, provided that both the copyright
+  notice and this permission notice appear in all copies of the software,
+  derivative works or modified versions, and any portions thereof, and
+  that both notices appear in supporting documentation.
+
+  NRL ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND
+  DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
+  RESULTING FROM THE USE OF THIS SOFTWARE.
+
+ */
+
+#ifndef _HE_H_
+#define _HE_H_
+
+#define DEV_LABEL       "he"
+
+#define CONFIG_DEFAULT_VCIBITS	12
+#define CONFIG_DEFAULT_VPIBITS	0
+
+#define CONFIG_IRQ_SIZE		128
+#define CONFIG_IRQ_THRESH	(CONFIG_IRQ_SIZE/2)
+
+#define CONFIG_NUMTPDS		256
+
+#define CONFIG_TPDRQ_SIZE	512
+#define TPDRQ_MASK(x)		(((unsigned long)(x))&((CONFIG_TPDRQ_SIZE<<3)-1))
+
+#define CONFIG_RBRQ_SIZE	512
+#define CONFIG_RBRQ_THRESH	400
+#define RBRQ_MASK(x)		(((unsigned long)(x))&((CONFIG_RBRQ_SIZE<<3)-1))
+
+#define CONFIG_TBRQ_SIZE	512
+#define CONFIG_TBRQ_THRESH	400
+#define TBRQ_MASK(x)		(((unsigned long)(x))&((CONFIG_TBRQ_SIZE<<2)-1))
+
+#define CONFIG_RBPL_SIZE	512
+#define CONFIG_RBPL_THRESH	64
+#define CONFIG_RBPL_BUFSIZE	4096
+#define RBPL_MASK(x)		(((unsigned long)(x))&((CONFIG_RBPL_SIZE<<3)-1))
+
+#define CONFIG_RBPS_SIZE	1024
+#define CONFIG_RBPS_THRESH	64
+#define CONFIG_RBPS_BUFSIZE	128
+#define RBPS_MASK(x)		(((unsigned long)(x))&((CONFIG_RBPS_SIZE<<3)-1))
+
+/* 5.1.3 initialize connection memory */
+
+#define CONFIG_RSRA		0x00000
+#define CONFIG_RCMLBM		0x08000
+#define CONFIG_RCMABR		0x0d800
+#define CONFIG_RSRB		0x0e000
+
+#define CONFIG_TSRA		0x00000
+#define CONFIG_TSRB		0x08000
+#define CONFIG_TSRC		0x0c000
+#define CONFIG_TSRD		0x0e000
+#define CONFIG_TMABR		0x0f000
+#define CONFIG_TPDBA		0x10000
+
+#define HE_MAXCIDBITS		12
+
+/* 2.9.3.3 interrupt encodings */
+
+struct he_irq {
+	volatile u32 isw;
+};
+
+#define IRQ_ALIGNMENT		0x1000
+
+#define NEXT_ENTRY(base, tail, mask) \
+				(((unsigned long)base)|(((unsigned long)(tail+1))&mask))
+
+#define ITYPE_INVALID		0xffffffff
+#define ITYPE_TBRQ_THRESH	(0<<3)
+#define ITYPE_TPD_COMPLETE	(1<<3)
+#define ITYPE_RBPS_THRESH	(2<<3)
+#define ITYPE_RBPL_THRESH	(3<<3)
+#define ITYPE_RBRQ_THRESH	(4<<3)
+#define ITYPE_RBRQ_TIMER	(5<<3)
+#define ITYPE_PHY		(6<<3)
+#define ITYPE_OTHER		0x80
+#define ITYPE_PARITY		0x81
+#define ITYPE_ABORT		0x82
+
+#define ITYPE_GROUP(x)		(x & 0x7)
+#define ITYPE_TYPE(x)		(x & 0xf8)
+
+#define HE_NUM_GROUPS 8
+
+/* 2.1.4 transmit packet descriptor */
+
+struct he_tpd {
+
+	/* read by the adapter */
+
+	volatile u32 status;
+	volatile u32 reserved;
+
+#define TPD_MAXIOV	3
+	struct {
+		u32 addr, len;
+	} iovec[TPD_MAXIOV];
+
+#define address0 iovec[0].addr
+#define length0 iovec[0].len
+
+	/* linux-atm extensions */
+
+	struct sk_buff *skb;
+	struct atm_vcc *vcc;
+
+#ifdef USE_TPD_POOL
+	struct list_head entry;
+#else
+	u32 inuse;
+	char padding[32 - sizeof(u32) - (2*sizeof(void*))];
+#endif
+};
+
+#define TPD_ALIGNMENT	64
+#define TPD_LEN_MASK	0xffff
+
+#define TPD_ADDR_SHIFT  6
+#define TPD_MASK	0xffffffc0
+#define TPD_ADDR(x)	((x) & TPD_MASK)
+#define TPD_INDEX(x)	(TPD_ADDR(x) >> TPD_ADDR_SHIFT)
+
+
+/* table 2.3 transmit buffer return elements */
+
+struct he_tbrq {
+	volatile u32 tbre;
+};
+
+#define TBRQ_ALIGNMENT	CONFIG_TBRQ_SIZE
+
+#define TBRQ_TPD(tbrq)		((tbrq)->tbre & 0xffffffc0)
+#define TBRQ_EOS(tbrq)		((tbrq)->tbre & (1<<3))
+#define TBRQ_MULTIPLE(tbrq)	((tbrq)->tbre & (1))
+
+/* table 2.21 receive buffer return queue element field organization */
+
+struct he_rbrq {
+	volatile u32 addr;
+	volatile u32 cidlen;
+};
+
+#define RBRQ_ALIGNMENT	CONFIG_RBRQ_SIZE
+
+#define RBRQ_ADDR(rbrq)		((rbrq)->addr & 0xffffffc0)
+#define RBRQ_CRC_ERR(rbrq)	((rbrq)->addr & (1<<5))
+#define RBRQ_LEN_ERR(rbrq)	((rbrq)->addr & (1<<4))
+#define RBRQ_END_PDU(rbrq)	((rbrq)->addr & (1<<3))
+#define RBRQ_AAL5_PROT(rbrq)	((rbrq)->addr & (1<<2))
+#define RBRQ_CON_CLOSED(rbrq)	((rbrq)->addr & (1<<1))
+#define RBRQ_HBUF_ERR(rbrq)	((rbrq)->addr & 1)
+#define RBRQ_CID(rbrq)		(((rbrq)->cidlen >> 16) & 0x1fff)
+#define RBRQ_BUFLEN(rbrq)	((rbrq)->cidlen & 0xffff)
+
+/* figure 2.3 transmit packet descriptor ready queue */
+
+struct he_tpdrq {
+	volatile u32 tpd;
+	volatile u32 cid;
+};
+
+#define TPDRQ_ALIGNMENT CONFIG_TPDRQ_SIZE
+
+/* table 2.30 host status page detail */
+
+#define HSP_ALIGNMENT	0x400		/* must align on 1k boundary */
+
+struct he_hsp {
+	struct he_hsp_entry {
+		volatile u32 tbrq_tail; 
+		volatile u32 reserved1[15];
+		volatile u32 rbrq_tail; 
+		volatile u32 reserved2[15];
+	} group[HE_NUM_GROUPS];
+};
+
+/* figure 2.9 receive buffer pools */
+
+struct he_rbp {
+	volatile u32 phys;
+	volatile u32 status;
+};
+
+/* NOTE: it is suggested that virt be the virtual address of the host
+   buffer.  on a 64-bit machine, this would not work.  Instead, we
+   store the real virtual address in another list, and store an index
+   (and buffer status) in the virt member.
+*/
+
+#define RBP_INDEX_OFF	6
+#define RBP_INDEX(x)	(((long)(x) >> RBP_INDEX_OFF) & 0xffff)
+#define RBP_LOANED	0x80000000
+#define RBP_SMALLBUF	0x40000000
+
+struct he_virt {
+	void *virt;
+};
+
+#define RBPL_ALIGNMENT CONFIG_RBPL_SIZE
+#define RBPS_ALIGNMENT CONFIG_RBPS_SIZE
+
+#ifdef notyet
+struct he_group {
+	u32 rpbs_size, rpbs_qsize;
+	struct he_rbp rbps_ba;
+
+	u32 rpbl_size, rpbl_qsize;
+	struct he_rpb_entry *rbpl_ba;
+};
+#endif
+
+#define HE_LOOKUP_VCC(dev, cid) ((dev)->he_vcc_table[(cid)].vcc)
+
+struct he_vcc_table 
+{
+	struct atm_vcc *vcc;
+};
+
+struct he_cs_stper
+{
+	long pcr;
+	int inuse;
+};
+
+#define HE_NUM_CS_STPER		16
+
+struct he_dev {
+	unsigned int number;
+	unsigned int irq;
+	unsigned long membase;
+
+	char prod_id[30];
+	char mac_addr[6];
+	int media;			/*  
+					 *  0x26 = HE155 MM 
+					 *  0x27 = HE622 MM 
+					 *  0x46 = HE155 SM 
+					 *  0x47 = HE622 SM 
+					 */
+
+
+	unsigned int vcibits, vpibits;
+	unsigned int cells_per_row;
+	unsigned int bytes_per_row;
+	unsigned int cells_per_lbuf;
+	unsigned int r0_numrows, r0_startrow, r0_numbuffs;
+	unsigned int r1_numrows, r1_startrow, r1_numbuffs;
+	unsigned int tx_numrows, tx_startrow, tx_numbuffs;
+	unsigned int buffer_limit;
+
+	struct he_vcc_table *he_vcc_table;
+
+#ifdef notyet
+	struct he_group group[HE_NUM_GROUPS];
+#endif
+	struct he_cs_stper cs_stper[HE_NUM_CS_STPER];
+	unsigned total_bw;
+
+	dma_addr_t irq_phys;
+	struct he_irq *irq_base, *irq_head, *irq_tail;
+	volatile unsigned *irq_tailoffset;
+	int irq_peak;
+
+#ifdef USE_TASKLET
+	struct tasklet_struct tasklet;
+#endif
+#ifdef USE_TPD_POOL
+	struct pci_pool *tpd_pool;
+	struct list_head outstanding_tpds;
+#else
+	struct he_tpd *tpd_head, *tpd_base, *tpd_end;
+	dma_addr_t tpd_base_phys;
+#endif
+
+	dma_addr_t tpdrq_phys;
+	struct he_tpdrq *tpdrq_base, *tpdrq_tail, *tpdrq_head;
+
+	spinlock_t global_lock;		/* 8.1.5 pci transaction ordering
+					  error problem */
+	dma_addr_t rbrq_phys;
+	struct he_rbrq *rbrq_base, *rbrq_head;
+	int rbrq_peak;
+
+#ifdef USE_RBPL_POOL
+	struct pci_pool *rbpl_pool;
+#else
+	void *rbpl_pages;
+	dma_addr_t rbpl_pages_phys;
+#endif
+	dma_addr_t rbpl_phys;
+	struct he_rbp *rbpl_base, *rbpl_tail;
+	struct he_virt *rbpl_virt;
+	int rbpl_peak;
+
+#ifdef USE_RBPS
+#ifdef USE_RBPS_POOL
+	struct pci_pool *rbps_pool;
+#else
+	void *rbps_pages;
+	dma_addr_t rbps_pages_phys;
+#endif
+#endif
+	dma_addr_t rbps_phys;
+	struct he_rbp *rbps_base, *rbps_tail;
+	struct he_virt *rbps_virt;
+	int rbps_peak;
+
+	dma_addr_t tbrq_phys;
+	struct he_tbrq *tbrq_base, *tbrq_head;
+	int tbrq_peak;
+
+	dma_addr_t hsp_phys;
+	struct he_hsp *hsp;
+
+	struct pci_dev *pci_dev;
+	struct atm_dev *atm_dev;
+	struct he_dev *next;
+};
+
+struct he_vcc
+{
+	struct iovec iov_head[32];
+	struct iovec *iov_tail;
+	int pdu_len;
+
+	int rc_index;
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,1)
+	struct wait_queue *rx_waitq;
+	atruct wait_queue *tx_waitq;
+#else
+	wait_queue_head_t rx_waitq;
+	wait_queue_head_t tx_waitq;
+#endif
+};
+
+#define HE_VCC(vcc)	((struct he_vcc *)(vcc->dev_data))
+
+#define PCI_VENDOR_ID_FORE	0x1127
+#define PCI_DEVICE_ID_FORE_HE	0x400
+
+#define HE_DMA_MASK		0xffffffff
+
+#define GEN_CNTL_0				0x40
+#define  INT_PROC_ENBL		(1<<25)
+#define  SLAVE_ENDIAN_MODE	(1<<16)
+#define  MRL_ENB		(1<<5)
+#define  MRM_ENB		(1<<4)
+#define  INIT_ENB		(1<<2)
+#define  IGNORE_TIMEOUT		(1<<1)
+#define  ENBL_64		(1<<0)
+
+#define MIN_PCI_LATENCY		32	/* errata 8.1.3 */
+
+#define HE_DEV(dev) ((struct he_dev *) (dev)->dev_data)
+
+#define he_is622(dev)	((dev)->media & 0x1)
+
+#define HE_REGMAP_SIZE	0x100000
+
+#define RESET_CNTL	0x80000
+#define  BOARD_RST_STATUS	(1<<6)
+
+#define HOST_CNTL	0x80004
+#define  PCI_BUS_SIZE64			(1<<27)
+#define  DESC_RD_STATIC_64		(1<<26)
+#define  DATA_RD_STATIC_64		(1<<25)
+#define  DATA_WR_STATIC_64		(1<<24)
+#define  ID_CS				(1<<12)
+#define  ID_WREN			(1<<11)
+#define  ID_DOUT			(1<<10)
+#define   ID_DOFFSET			10
+#define  ID_DIN				(1<<9)
+#define  ID_CLOCK			(1<<8)
+#define  QUICK_RD_RETRY			(1<<7)
+#define  QUICK_WR_RETRY			(1<<6)
+#define  OUTFF_ENB			(1<<5)
+#define  CMDFF_ENB			(1<<4)
+#define  PERR_INT_ENB			(1<<2)
+#define  IGNORE_INTR			(1<<0)
+
+#define LB_SWAP		0x80008
+#define  SWAP_RNUM_MAX(x)	(x<<27)
+#define  DATA_WR_SWAP		(1<<20)
+#define  DESC_RD_SWAP		(1<<19)
+#define  DATA_RD_SWAP		(1<<18)
+#define  INTR_SWAP		(1<<17)
+#define  DESC_WR_SWAP		(1<<16)
+#define  SDRAM_INIT		(1<<15)
+#define  BIG_ENDIAN_HOST	(1<<14)
+#define  XFER_SIZE		(1<<7)
+
+#define LB_MEM_ADDR	0x8000c
+#define LB_MEM_DATA	0x80010
+
+#define LB_MEM_ACCESS	0x80014
+#define  LB_MEM_HNDSHK		(1<<30)
+#define  LM_MEM_WRITE		(0x7)
+#define  LM_MEM_READ		(0x3)
+
+#define SDRAM_CTL	0x80018
+#define  LB_64_ENB		(1<<3)
+#define  LB_TWR			(1<<2)
+#define  LB_TRP			(1<<1)
+#define  LB_TRAS		(1<<0)
+
+#define INT_FIFO	0x8001c
+#define  INT_MASK_D		(1<<15)
+#define  INT_MASK_C		(1<<14)
+#define  INT_MASK_B		(1<<13)
+#define  INT_MASK_A		(1<<12)
+#define  INT_CLEAR_D		(1<<11)
+#define  INT_CLEAR_C		(1<<10)
+#define  INT_CLEAR_B		(1<<9)
+#define  INT_CLEAR_A		(1<<8)
+
+#define ABORT_ADDR	0x80020
+
+#define IRQ0_BASE	0x80080
+#define  IRQ_BASE(x)		(x<<12)
+#define  IRQ_MASK		((CONFIG_IRQ_SIZE<<2)-1)	/* was 0x3ff */
+#define  IRQ_TAIL(x)		(((unsigned long)(x)) & IRQ_MASK)
+#define IRQ0_HEAD	0x80084
+#define  IRQ_SIZE(x)		(x<<22)
+#define  IRQ_THRESH(x)		(x<<12)
+#define  IRQ_HEAD(x)		(x<<2)
+/* #define  IRQ_PENDING		(1) 		conflict with linux/irq.h */
+#define IRQ0_CNTL	0x80088
+#define  IRQ_ADDRSEL(x)		(x<<2)
+#define  IRQ_INT_A		(0<<2)
+#define  IRQ_INT_B		(1<<2)
+#define  IRQ_INT_C		(2<<2)
+#define  IRQ_INT_D		(3<<2)
+#define  IRQ_TYPE_ADDR		0x1
+#define  IRQ_TYPE_LINE		0x0
+#define IRQ0_DATA	0x8008c
+
+#define IRQ1_BASE	0x80090
+#define IRQ1_HEAD	0x80094
+#define IRQ1_CNTL	0x80098
+#define IRQ1_DATA	0x8009c
+
+#define IRQ2_BASE	0x800a0
+#define IRQ2_HEAD	0x800a4
+#define IRQ2_CNTL	0x800a8
+#define IRQ2_DATA	0x800ac
+
+#define IRQ3_BASE	0x800b0
+#define IRQ3_HEAD	0x800b4
+#define IRQ3_CNTL	0x800b8
+#define IRQ3_DATA	0x800bc
+
+#define GRP_10_MAP	0x800c0
+#define GRP_32_MAP	0x800c4
+#define GRP_54_MAP	0x800c8
+#define GRP_76_MAP	0x800cc
+
+#define	G0_RBPS_S	0x80400
+#define G0_RBPS_T	0x80404
+#define  RBP_TAIL(x)		((x)<<3)
+#define  RBP_MASK(x)		((x)|0x1fff)
+#define G0_RBPS_QI	0x80408
+#define  RBP_QSIZE(x)		((x)<<14)
+#define  RBP_INT_ENB		(1<<13)
+#define  RBP_THRESH(x)		(x)
+#define G0_RBPS_BS	0x8040c
+#define G0_RBPL_S	0x80410
+#define G0_RBPL_T	0x80414
+#define G0_RBPL_QI	0x80418 
+#define G0_RBPL_BS	0x8041c
+
+#define	G1_RBPS_S	0x80420
+#define G1_RBPS_T	0x80424
+#define G1_RBPS_QI	0x80428
+#define G1_RBPS_BS	0x8042c
+#define G1_RBPL_S	0x80430
+#define G1_RBPL_T	0x80434
+#define G1_RBPL_QI	0x80438
+#define G1_RBPL_BS	0x8043c
+
+#define	G2_RBPS_S	0x80440
+#define G2_RBPS_T	0x80444
+#define G2_RBPS_QI	0x80448
+#define G2_RBPS_BS	0x8044c
+#define G2_RBPL_S	0x80450
+#define G2_RBPL_T	0x80454
+#define G2_RBPL_QI	0x80458
+#define G2_RBPL_BS	0x8045c
+
+#define	G3_RBPS_S	0x80460
+#define G3_RBPS_T	0x80464
+#define G3_RBPS_QI	0x80468
+#define G3_RBPS_BS	0x8046c
+#define G3_RBPL_S	0x80470
+#define G3_RBPL_T	0x80474
+#define G3_RBPL_QI	0x80478
+#define G3_RBPL_BS	0x8047c
+
+#define	G4_RBPS_S	0x80480
+#define G4_RBPS_T	0x80484
+#define G4_RBPS_QI	0x80488
+#define G4_RBPS_BS	0x8048c
+#define G4_RBPL_S	0x80490
+#define G4_RBPL_T	0x80494
+#define G4_RBPL_QI	0x80498
+#define G4_RBPL_BS	0x8049c
+
+#define	G5_RBPS_S	0x804a0
+#define G5_RBPS_T	0x804a4
+#define G5_RBPS_QI	0x804a8
+#define G5_RBPS_BS	0x804ac
+#define G5_RBPL_S	0x804b0
+#define G5_RBPL_T	0x804b4
+#define G5_RBPL_QI	0x804b8
+#define G5_RBPL_BS	0x804bc
+
+#define	G6_RBPS_S	0x804c0
+#define G6_RBPS_T	0x804c4
+#define G6_RBPS_QI	0x804c8
+#define G6_RBPS_BS	0x804cc
+#define G6_RBPL_S	0x804d0
+#define G6_RBPL_T	0x804d4
+#define G6_RBPL_QI	0x804d8
+#define G6_RBPL_BS	0x804dc
+
+#define	G7_RBPS_S	0x804e0
+#define G7_RBPS_T	0x804e4
+#define G7_RBPS_QI	0x804e8
+#define G7_RBPS_BS	0x804ec
+
+#define G7_RBPL_S	0x804f0
+#define G7_RBPL_T	0x804f4
+#define G7_RBPL_QI	0x804f8
+#define G7_RBPL_BS	0x804fc
+
+#define G0_RBRQ_ST	0x80500
+#define G0_RBRQ_H	0x80504
+#define G0_RBRQ_Q	0x80508
+#define  RBRQ_THRESH(x)		((x)<<13)
+#define  RBRQ_SIZE(x)		(x)
+#define G0_RBRQ_I	0x8050c
+#define  RBRQ_TIME(x)		((x)<<8)
+#define  RBRQ_COUNT(x)		(x)
+
+/* fill in 1 ... 7 later */
+
+#define G0_TBRQ_B_T	0x80600
+#define G0_TBRQ_H	0x80604
+#define G0_TBRQ_S	0x80608
+#define G0_TBRQ_THRESH	0x8060c
+#define  TBRQ_THRESH(x)		(x)
+
+/* fill in 1 ... 7 later */
+
+#define RH_CONFIG	0x805c0
+#define  PHY_INT_ENB	(1<<10)
+#define  OAM_GID(x)	(x<<7)
+#define  PTMR_PRE(x)	(x)
+
+#define G0_INMQ_S	0x80580
+#define G0_INMQ_L	0x80584
+#define G1_INMQ_S	0x80588
+#define G1_INMQ_L	0x8058c
+#define G2_INMQ_S	0x80590
+#define G2_INMQ_L	0x80594
+#define G3_INMQ_S	0x80598
+#define G3_INMQ_L	0x8059c
+#define G4_INMQ_S	0x805a0
+#define G4_INMQ_L	0x805a4
+#define G5_INMQ_S	0x805a8
+#define G5_INMQ_L	0x805ac
+#define G6_INMQ_S	0x805b0
+#define G6_INMQ_L	0x805b4
+#define G7_INMQ_S	0x805b8
+#define G7_INMQ_L	0x805bc
+
+#define TPDRQ_B_H	0x80680
+#define TPDRQ_T		0x80684
+#define TPDRQ_S		0x80688
+
+#define UBUFF_BA	0x8068c
+
+#define RLBF0_H		0x806c0
+#define RLBF0_T		0x806c4
+#define RLBF1_H		0x806c8
+#define RLBF1_T		0x806cc
+#define RLBC_H		0x806d0
+#define RLBC_T		0x806d4
+#define RLBC_H2		0x806d8
+#define TLBF_H		0x806e0
+#define TLBF_T		0x806e4
+#define RLBF0_C		0x806e8
+#define RLBF1_C		0x806ec
+#define RXTHRSH		0x806f0
+#define LITHRSH		0x806f4
+
+#define LBARB		0x80700
+#define  SLICE_X(x)		 (x<<28)
+#define  ARB_RNUM_MAX(x)	 (x<<23)
+#define  TH_PRTY(x)		 (x<<21)
+#define  RH_PRTY(x)		 (x<<19)
+#define  TL_PRTY(x)		 (x<<17)
+#define  RL_PRTY(x)		 (x<<15)
+#define  BUS_MULTI(x)		 (x<<8)
+#define  NET_PREF(x)		 (x)
+
+#define SDRAMCON	0x80704
+#define	 BANK_ON		(1<<14)
+#define	 WIDE_DATA		(1<<13)
+#define	 TWR_WAIT		(1<<12)
+#define	 TRP_WAIT		(1<<11)
+#define	 TRAS_WAIT		(1<<10)
+#define	 REF_RATE(x)		(x)
+
+#define LBSTAT		0x80708
+
+#define RCC_STAT	0x8070c
+#define  RCC_BUSY		(1)
+
+#define TCMCONFIG	0x80740
+#define  TM_DESL2		(1<<10)
+#define	 TM_BANK_WAIT(x)	(x<<6)
+#define	 TM_ADD_BANK4(x)	(x<<4)
+#define  TM_PAR_CHECK(x)	(x<<3)
+#define  TM_RW_WAIT(x)		(x<<2)
+#define  TM_SRAM_TYPE(x)	(x)
+
+#define TSRB_BA		0x80744	
+#define TSRC_BA		0x80748	
+#define TMABR_BA	0x8074c	
+#define TPD_BA		0x80750	
+#define TSRD_BA		0x80758	
+
+#define TX_CONFIG	0x80760
+#define  DRF_THRESH(x)		(x<<22)
+#define  TX_UT_MODE(x)		(x<<21)
+#define  TX_VCI_MASK(x)		(x<<17)
+#define  LBFREE_CNT(x)		(x)
+
+#define TXAAL5_PROTO	0x80764
+#define  CPCS_UU(x)		(x<<8)
+#define  CPI(x)			(x)
+
+#define RCMCONFIG	0x80780
+#define  RM_DESL2(x)		(x<<10)
+#define  RM_BANK_WAIT(x)	(x<<6)
+#define  RM_ADD_BANK(x)		(x<<4)
+#define  RM_PAR_CHECK(x)	(x<<3)
+#define  RM_RW_WAIT(x)		(x<<2)
+#define  RM_SRAM_TYPE(x)	(x)
+
+#define RCMRSRB_BA	0x80784
+#define RCMLBM_BA	0x80788
+#define RCMABR_BA	0x8078c
+
+#define RC_CONFIG	0x807c0
+#define  UT_RD_DELAY(x)		(x<<11)
+#define  WRAP_MODE(x)		(x<<10)
+#define  RC_UT_MODE(x)		(x<<9)
+#define  RX_ENABLE		(1<<8)
+#define  RX_VALVP(x)		(x<<4)
+#define  RX_VALVC(x)		(x)
+
+#define MCC		0x807c4
+#define OEC		0x807c8
+#define DCC		0x807cc
+#define CEC		0x807d0
+
+#define HSP_BA		0x807f0
+
+#define LB_CONFIG	0x807f4
+#define  LB_SIZE(x)		(x)
+
+#define CON_DAT		0x807f8
+#define CON_CTL		0x807fc
+#define  CON_CTL_MBOX		(2<<30)
+#define  CON_CTL_TCM		(1<<30)
+#define  CON_CTL_RCM		(0<<30)
+#define  CON_CTL_WRITE		(1<<29)
+#define  CON_CTL_READ		(0<<29)
+#define  CON_CTL_BUSY		(1<<28)
+#define  CON_BYTE_DISABLE_3	(1<<22)		/* 24..31 */
+#define  CON_BYTE_DISABLE_2	(1<<21)		/* 16..23 */
+#define  CON_BYTE_DISABLE_1	(1<<20)		/* 8..15 */
+#define  CON_BYTE_DISABLE_0	(1<<19)		/* 0..7 */
+#define  CON_CTL_ADDR(x)	(x)
+
+#define FRAMER		0x80800		/* to 0x80bfc */
+
+/* 3.3 network controller (internal) mailbox registers */
+
+#define CS_STPER0	0x0
+	/* ... */
+#define CS_STPER31	0x01f
+
+#define CS_STTIM0	0x020
+	/* ... */
+#define CS_STTIM31	0x03f
+
+#define CS_TGRLD0	0x040
+	/* ... */
+#define CS_TGRLD15	0x04f
+
+#define CS_ERTHR0	0x050
+#define CS_ERTHR1	0x051
+#define CS_ERTHR2	0x052
+#define CS_ERTHR3	0x053
+#define CS_ERTHR4	0x054
+#define CS_ERCTL0	0x055
+#define  TX_ENABLE		(1<<28)
+#define  ER_ENABLE		(1<<27)
+#define CS_ERCTL1	0x056
+#define CS_ERCTL2	0x057
+#define CS_ERSTAT0	0x058
+#define CS_ERSTAT1	0x059
+
+#define CS_RTCCT	0x060
+#define CS_RTFWC	0x061
+#define CS_RTFWR	0x062
+#define CS_RTFTC	0x063
+#define CS_RTATR	0x064
+
+#define CS_TFBSET	0x070
+#define CS_TFBADD	0x071
+#define CS_TFBSUB	0x072
+#define CS_WCRMAX	0x073
+#define CS_WCRMIN	0x074
+#define CS_WCRINC	0x075
+#define CS_WCRDEC	0x076
+#define CS_WCRCEIL	0x077
+#define CS_BWDCNT	0x078
+
+#define CS_OTPPER	0x080
+#define CS_OTWPER	0x081
+#define CS_OTTLIM	0x082
+#define CS_OTTCNT	0x083
+
+#define CS_HGRRT0	0x090
+	/* ... */
+#define CS_HGRRT7	0x097
+
+#define CS_ORPTRS	0x0a0
+
+#define RXCON_CLOSE	0x100
+
+
+#define RCM_MEM_SIZE	0x10000		/* 1M of 32-bit registers */
+#define TCM_MEM_SIZE	0x20000		/* 2M of 32-bit registers */
+
+/* 2.5 transmit connection memory registers */
+
+#define TSR0_CONN_STATE(x)	((x>>28) & 0x7)
+#define TSR0_USE_WMIN		(1<<23)
+#define TSR0_GROUP(x)		((x & 0x7)<<18)
+#define TSR0_ABR		(2<<16)
+#define TSR0_UBR		(1<<16)
+#define TSR0_CBR		(0<<16)
+#define TSR0_PROT		(1<<15)
+#define TSR0_AAL0_SDU		(2<<12)
+#define TSR0_AAL0		(1<<12)
+#define TSR0_AAL5		(0<<12)
+#define TSR0_HALT_ER		(1<<11)
+#define TSR0_MARK_CI		(1<<10)
+#define TSR0_MARK_ER		(1<<9)
+#define TSR0_UPDATE_GER		(1<<8)
+#define TSR0_RC_INDEX(x)	(x & 0x1F)
+
+#define TSR1_PCR(x)		((x & 0x7FFF)<<16)
+#define TSR1_MCR(x)		(x & 0x7FFF)
+
+#define TSR2_ACR(x)		((x & 0x7FFF)<<16)
+
+#define TSR3_NRM_CNT(x)		((x & 0xFF)<<24)
+#define TSR3_CRM_CNT(x)		(x & 0xFFFF)
+
+#define TSR4_FLUSH_CONN		(1<<31)
+#define TSR4_SESSION_ENDED	(1<<30)
+#define TSR4_CRC10		(1<<28)
+#define TSR4_NULL_CRC10		(1<<27)
+#define TSR4_PROT		(1<<26)
+#define TSR4_AAL0_SDU		(2<<23)
+#define TSR4_AAL0		(1<<23)
+#define TSR4_AAL5		(0<<23)
+
+#define TSR9_OPEN_CONN		(1<<20)
+
+#define TSR11_ICR(x)		((x & 0x7FFF)<<16)
+#define TSR11_TRM(x)		((x & 0x7)<<13)
+#define TSR11_NRM(x)		((x & 0x7)<<10)
+#define TSR11_ADTF(x)		(x & 0x3FF)
+
+#define TSR13_RDF(x)		((x & 0xF)<<23)
+#define TSR13_RIF(x)		((x & 0xF)<<19)
+#define TSR13_CDF(x)		((x & 0x7)<<16)
+#define TSR13_CRM(x)		(x & 0xFFFF)
+
+#define TSR14_DELETE		(1<<31)
+#define TSR14_ABR_CLOSE		(1<<16)
+
+/* 2.7.1 per connection receieve state registers */
+
+#define RSR0_START_PDU	(1<<10)
+#define RSR0_OPEN_CONN	(1<<6)
+#define RSR0_CLOSE_CONN	(0<<6)
+#define RSR0_PPD_ENABLE	(1<<5)
+#define RSR0_EPD_ENABLE	(1<<4)
+#define RSR0_TCP_CKSUM	(1<<3)
+#define RSR0_AAL5		(0)
+#define RSR0_AAL0		(1)
+#define RSR0_AAL0_SDU		(2)
+#define RSR0_RAWCELL		(3)
+#define RSR0_RAWCELL_CRC10	(4)
+
+#define RSR1_AQI_ENABLE	(1<<20)
+#define RSR1_RBPL_ONLY	(1<<19)
+#define RSR1_GROUP(x)	((x)<<16)
+
+#define RSR4_AQI_ENABLE (1<<30)
+#define RSR4_GROUP(x)	((x)<<27)
+#define RSR4_RBPL_ONLY	(1<<26)
+
+/* 2.1.4 transmit packet descriptor */
+
+#define	TPD_USERCELL		0x0
+#define	TPD_SEGMENT_OAMF5	0x4
+#define	TPD_END2END_OAMF5	0x5
+#define	TPD_RMCELL		0x6
+#define TPD_CELLTYPE(x)		(x<<3)
+#define TPD_EOS			(1<<2)
+#define TPD_CLP			(1<<1)
+#define TPD_INT			(1<<0)
+#define TPD_LST		(1<<31)
+
+/* table 4.3 serial eeprom information */
+
+#define PROD_ID		0x08	/* char[] */
+#define  PROD_ID_LEN	30
+#define HW_REV		0x26	/* char[] */
+#define M_SN		0x3a	/* integer */
+#define MEDIA		0x3e	/* integer */
+#define  HE155MM	0x26
+#define  HE155SM	0x27
+#define  HE622MM	0x46
+#define  HE622SM	0x47
+#define MAC_ADDR	0x42	/* char[] */
+
+#define CS_LOW		0x0
+#define CS_HIGH		ID_CS /* HOST_CNTL_ID_PROM_SEL */
+#define CLK_LOW		0x0
+#define CLK_HIGH	ID_CLOCK /* HOST_CNTL_ID_PROM_CLOCK */
+#define SI_HIGH		ID_DIN /* HOST_CNTL_ID_PROM_DATA_IN */
+#define EEPROM_DELAY	400 /* microseconds */
+
+/* Read from EEPROM = 0000 0011b */
+unsigned int readtab[] = {
+	CS_HIGH | CLK_HIGH,
+	CS_LOW | CLK_LOW,
+	CLK_HIGH,               /* 0 */
+	CLK_LOW,
+	CLK_HIGH,               /* 0 */
+	CLK_LOW,
+	CLK_HIGH,               /* 0 */
+	CLK_LOW,
+	CLK_HIGH,               /* 0 */
+	CLK_LOW,
+	CLK_HIGH,               /* 0 */
+	CLK_LOW,
+	CLK_HIGH,               /* 0 */
+	CLK_LOW | SI_HIGH,
+	CLK_HIGH | SI_HIGH,     /* 1 */
+	CLK_LOW | SI_HIGH,
+	CLK_HIGH | SI_HIGH      /* 1 */
+};     
+ 
+/* Clock to read from/write to the EEPROM */
+unsigned int clocktab[] = {
+	CLK_LOW,
+	CLK_HIGH,
+	CLK_LOW,
+	CLK_HIGH,
+	CLK_LOW,
+	CLK_HIGH,
+	CLK_LOW,
+	CLK_HIGH,
+	CLK_LOW,
+	CLK_HIGH,
+	CLK_LOW,
+	CLK_HIGH,
+	CLK_LOW,
+	CLK_HIGH,
+	CLK_LOW,
+	CLK_HIGH,
+	CLK_LOW
+};     
+
+
+#endif /* _HE_H_ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/atm/iphase.c linux-2.4.22-pre2/drivers/atm/iphase.c
--- linux-2.4.21/drivers/atm/iphase.c	2003-06-26 21:45:06.000000000 +0000
+++ linux-2.4.22-pre2/drivers/atm/iphase.c	2003-06-26 21:43:32.000000000 +0000
@@ -2827,11 +2827,15 @@
              break;
           case MEMDUMP_FFL:
           {  
-             ia_regs_t       regs_local;
-             ffredn_t        *ffL = &regs_local.ffredn;
-             rfredn_t        *rfL = &regs_local.rfredn;
+             ia_regs_t       *regs_local;
+             ffredn_t        *ffL;
+             rfredn_t        *rfL;
                      
 	     if (!capable(CAP_NET_ADMIN)) return -EPERM;
+	     regs_local = kmalloc(sizeof(*regs_local), GFP_KERNEL);
+	     if (!regs_local) return -ENOMEM;
+	     ffL = &regs_local->ffredn;
+	     rfL = &regs_local->rfredn;
              /* Copy real rfred registers into the local copy */
  	     for (i=0; i<(sizeof (rfredn_t))/4; i++)
                 ((u_int *)rfL)[i] = ((u_int *)iadev->reass_reg)[i] & 0xffff;
@@ -2839,8 +2843,11 @@
 	     for (i=0; i<(sizeof (ffredn_t))/4; i++)
                 ((u_int *)ffL)[i] = ((u_int *)iadev->seg_reg)[i] & 0xffff;
 
-             if (copy_to_user(ia_cmds.buf, &regs_local,sizeof(ia_regs_t)))
+             if (copy_to_user(ia_cmds.buf, regs_local,sizeof(ia_regs_t))) {
+                kfree(regs_local);
                 return -EFAULT;
+             }
+             kfree(regs_local);
              printk("Board %d registers dumped\n", board);
              ia_cmds.status = 0;                  
 	 }	
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/block/paride/bpck6.c linux-2.4.22-pre2/drivers/block/paride/bpck6.c
--- linux-2.4.21/drivers/block/paride/bpck6.c	2002-08-03 00:39:43.000000000 +0000
+++ linux-2.4.22-pre2/drivers/block/paride/bpck6.c	2003-06-26 21:43:27.000000000 +0000
@@ -194,11 +194,11 @@
   	if(out)
  	{
 		ppc6_close(PPCSTRUCT(pi));
-		return(1);	
 		if(verbose)
 		{
 			printk(KERN_DEBUG "leaving probe\n");
 		}
+               return(1);
 	}
   	else
   	{
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/bluetooth/hci_usb.c linux-2.4.22-pre2/drivers/bluetooth/hci_usb.c
--- linux-2.4.21/drivers/bluetooth/hci_usb.c	2003-06-26 21:45:06.000000000 +0000
+++ linux-2.4.22-pre2/drivers/bluetooth/hci_usb.c	2003-06-26 21:43:18.000000000 +0000
@@ -301,7 +301,8 @@
 			hci_usb_bulk_rx_submit(husb);
 
 #ifdef CONFIG_BLUEZ_USB_SCO
-		hci_usb_isoc_rx_submit(husb);
+		if (husb->isoc_iface)
+			hci_usb_isoc_rx_submit(husb);
 #endif
 	} else {
 		clear_bit(HCI_RUNNING, &hdev->flags);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/char/amd76x_pm.c linux-2.4.22-pre2/drivers/char/amd76x_pm.c
--- linux-2.4.21/drivers/char/amd76x_pm.c	2002-11-28 23:53:12.000000000 +0000
+++ linux-2.4.22-pre2/drivers/char/amd76x_pm.c	2003-06-26 21:43:17.000000000 +0000
@@ -78,6 +78,7 @@
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/pm.h>
+#include <linux/init.h>
 
 #include "amd76x_pm.h"
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/char/ipmi/ipmi_kcs_intf.c linux-2.4.22-pre2/drivers/char/ipmi/ipmi_kcs_intf.c
--- linux-2.4.21/drivers/char/ipmi/ipmi_kcs_intf.c	2003-06-26 21:45:06.000000000 +0000
+++ linux-2.4.22-pre2/drivers/char/ipmi/ipmi_kcs_intf.c	2003-06-26 21:43:14.000000000 +0000
@@ -1032,9 +1032,9 @@
 
 #include <linux/acpi.h>
 /* A real hack, but everything's not there yet in 2.4. */
-#define COMPILER_DEPENDENT_UINT64 unsigned long
-#include <../drivers/acpi/include/acpi.h>
-#include <../drivers/acpi/include/actypes.h>
+#include <acpi/acpi.h>
+#include <acpi/actypes.h>
+#include <acpi/actbl.h>
 
 struct SPMITable {
 	s8	Signature[4];
@@ -1059,7 +1059,7 @@
 static unsigned long acpi_find_bmc(void)
 {
 	acpi_status       status;
-	acpi_table_header *spmi;
+	struct acpi_table_header *spmi;
 	static unsigned long io_base = 0;
 
 	if (io_base != 0)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/char/wdt_pci.c linux-2.4.22-pre2/drivers/char/wdt_pci.c
--- linux-2.4.21/drivers/char/wdt_pci.c	2002-11-28 23:53:12.000000000 +0000
+++ linux-2.4.22-pre2/drivers/char/wdt_pci.c	2003-06-26 21:43:28.000000000 +0000
@@ -557,7 +557,7 @@
 
 	ret = register_reboot_notifier (&wdtpci_notifier);
 	if (ret) {
-		printk (KERN_ERR PFX "can't misc_register on minor=%d\n", WATCHDOG_MINOR);
+		printk (KERN_ERR PFX "can't register_reboot_notifier on minor=%d\n", WATCHDOG_MINOR);
 		goto out_misc;
 	}
 #ifdef CONFIG_WDT_501
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/hotplug/Makefile linux-2.4.22-pre2/drivers/hotplug/Makefile
--- linux-2.4.21/drivers/hotplug/Makefile	2003-06-26 21:45:06.000000000 +0000
+++ linux-2.4.22-pre2/drivers/hotplug/Makefile	2003-06-26 21:43:12.000000000 +0000
@@ -27,10 +27,6 @@
 				ibmphp_res.o	\
 				ibmphp_hpc.o
 
-ifdef CONFIG_HOTPLUG_PCI_ACPI
-  EXTRA_CFLAGS	+= -D_LINUX -I$(CURDIR)/../acpi
-endif
-
 acpiphp_objs		:=	acpiphp_core.o	\
 				acpiphp_glue.o	\
 				acpiphp_pci.o	\
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/hotplug/acpiphp.h linux-2.4.22-pre2/drivers/hotplug/acpiphp.h
--- linux-2.4.21/drivers/hotplug/acpiphp.h	2003-06-26 21:45:06.000000000 +0000
+++ linux-2.4.22-pre2/drivers/hotplug/acpiphp.h	2003-06-26 21:43:10.000000000 +0000
@@ -5,8 +5,8 @@
  * Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
  * Copyright (c) 2001 IBM Corp.
  * Copyright (c) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com)
- * Copyright (c) 2002 Takayoshi Kochi (t-kouchi@cq.jp.nec.com)
- * Copyright (c) 2002 NEC Corporation
+ * Copyright (c) 2002,2003 Takayoshi Kochi (t-kochi@bq.jp.nec.com)
+ * Copyright (c) 2002,2003 NEC Corporation
  *
  * All rights reserved.
  *
@@ -26,15 +26,14 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  * Send feedback to <gregkh@us.ibm.com>,
- *		    <h-aono@ap.jp.nec.com>,
- *		    <t-kouchi@cq.jp.nec.com>
+ *		    <t-kochi@bq.jp.nec.com>
  *
  */
 
 #ifndef _ACPIPHP_H
 #define _ACPIPHP_H
 
-#include "include/acpi.h"
+#include <linux/acpi.h>
 #include "pci_hotplug.h"
 
 #if ACPI_CA_VERSION < 0x20020201
@@ -71,7 +70,7 @@
 	return AE_OK;
 }
 #else  /* ACPI_CA_VERSION < 0x20020201 */
-#include "acpi_bus.h"
+#include <acpi/acpi_bus.h>
 #endif
 
 /* compatibility stuff for ACPI CA */
@@ -107,7 +106,7 @@
 
 #define SLOT_MAGIC	0x67267322
 /* name size which is used for entries in pcihpfs */
-#define SLOT_NAME_SIZE	32		/* ACPI{_SUN}-{BUS}:{DEV} */
+#define SLOT_NAME_SIZE	16		/* {_SUN} */
 
 struct acpiphp_bridge;
 struct acpiphp_slot;
@@ -270,11 +269,7 @@
 #define FUNC_HAS_PS2		(0x00000040)
 #define FUNC_HAS_PS3		(0x00000080)
 
-/* not yet */
-#define SLOT_SUPPORT_66MHZ	(0x00010000)
-#define SLOT_SUPPORT_100MHZ	(0x00020000)
-#define SLOT_SUPPORT_133MHZ	(0x00040000)
-#define SLOT_SUPPORT_PCIX	(0x00080000)
+#define FUNC_EXISTS		(0x10000000) /* to make sure we call _EJ0 only for existing funcs */
 
 /* function prototypes */
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/hotplug/acpiphp_core.c linux-2.4.22-pre2/drivers/hotplug/acpiphp_core.c
--- linux-2.4.21/drivers/hotplug/acpiphp_core.c	2003-06-26 21:45:06.000000000 +0000
+++ linux-2.4.22-pre2/drivers/hotplug/acpiphp_core.c	2003-06-26 21:43:31.000000000 +0000
@@ -5,8 +5,8 @@
  * Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
  * Copyright (c) 2001 IBM Corp.
  * Copyright (c) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com)
- * Copyright (c) 2002 Takayoshi Kochi (t-kouchi@cq.jp.nec.com)
- * Copyright (c) 2002 NEC Corporation
+ * Copyright (c) 2002,2003 Takayoshi Kochi (t-kochi@bq.jp.nec.com)
+ * Copyright (c) 2002,2003 NEC Corporation
  *
  * All rights reserved.
  *
@@ -26,8 +26,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  * Send feedback to <gregkh@us.ibm.com>,
- *                  <h-aono@ap.jp.nec.com>,
- *		    <t-kouchi@cq.jp.nec.com>
+ *		    <t-kochi@bq.jp.nec.com>
  *
  */
 
@@ -57,7 +56,7 @@
 static int num_slots;
 
 #define DRIVER_VERSION	"0.4"
-#define DRIVER_AUTHOR	"Greg Kroah-Hartman <gregkh@us.ibm.com>, Takayoshi Kochi <t-kouchi@cq.jp.nec.com>"
+#define DRIVER_AUTHOR	"Greg Kroah-Hartman <gregkh@us.ibm.com>, Takayoshi Kochi <t-kochi@bq.jp.nec.com>"
 #define DRIVER_DESC	"ACPI Hot Plug PCI Controller Driver"
 
 MODULE_AUTHOR(DRIVER_AUTHOR);
@@ -376,10 +375,8 @@
  */
 static void make_slot_name (struct slot *slot)
 {
-	snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "ACPI%d-%02x:%02x",
-		 slot->acpi_slot->sun,
-		 slot->acpi_slot->bridge->bus,
-		 slot->acpi_slot->device);
+	snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%u",
+		 slot->acpi_slot->sun);
 }
 
 /**
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/hotplug/acpiphp_glue.c linux-2.4.22-pre2/drivers/hotplug/acpiphp_glue.c
--- linux-2.4.21/drivers/hotplug/acpiphp_glue.c	2003-06-26 21:45:06.000000000 +0000
+++ linux-2.4.22-pre2/drivers/hotplug/acpiphp_glue.c	2003-06-26 21:43:16.000000000 +0000
@@ -1,9 +1,9 @@
 /*
  * ACPI PCI HotPlug glue functions to ACPI CA subsystem
  *
- * Copyright (c) 2002 Takayoshi Kochi (t-kouchi@cq.jp.nec.com)
+ * Copyright (c) 2002,2003 Takayoshi Kochi (t-kochi@bq.jp.nec.com)
  * Copyright (c) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com)
- * Copyright (c) 2002 NEC Corporation
+ * Copyright (c) 2002,2003 NEC Corporation
  *
  * All rights reserved.
  *
@@ -22,7 +22,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * Send feedback to <t-kouchi@cq.jp.nec.com>
+ * Send feedback to <t-kochi@bq.jp.nec.com>
  *
  */
 
@@ -230,11 +230,11 @@
  * TBD: _TRA, etc.
  */
 static void
-decode_acpi_resource (acpi_resource *resource, struct acpiphp_bridge *bridge)
+decode_acpi_resource (struct acpi_resource *resource, struct acpiphp_bridge *bridge)
 {
-	acpi_resource_address16 *address16_data;
-	acpi_resource_address32 *address32_data;
-	acpi_resource_address64 *address64_data;
+	struct acpi_resource_address16 *address16_data;
+	struct acpi_resource_address32 *address32_data;
+	struct acpi_resource_address64 *address64_data;
 	struct pci_resource *res;
 
 	u32 resource_type, producer_consumer, address_length;
@@ -252,7 +252,7 @@
 
 		switch (resource->id) {
 		case ACPI_RSTYPE_ADDRESS16:
-			address16_data = (acpi_resource_address16 *)&resource->data;
+			address16_data = (struct acpi_resource_address16 *)&resource->data;
 			resource_type = address16_data->resource_type;
 			producer_consumer = address16_data->producer_consumer;
 			min_address_range = address16_data->min_address_range;
@@ -264,7 +264,7 @@
 			break;
 
 		case ACPI_RSTYPE_ADDRESS32:
-			address32_data = (acpi_resource_address32 *)&resource->data;
+			address32_data = (struct acpi_resource_address32 *)&resource->data;
 			resource_type = address32_data->resource_type;
 			producer_consumer = address32_data->producer_consumer;
 			min_address_range = address32_data->min_address_range;
@@ -276,7 +276,7 @@
 			break;
 
 		case ACPI_RSTYPE_ADDRESS64:
-			address64_data = (acpi_resource_address64 *)&resource->data;
+			address64_data = (struct acpi_resource_address64 *)&resource->data;
 			resource_type = address64_data->resource_type;
 			producer_consumer = address64_data->producer_consumer;
 			min_address_range = address64_data->min_address_range;
@@ -296,7 +296,7 @@
 			break;
 		}
 
-		resource = (acpi_resource *)((char*)resource + resource->length);
+		resource = (struct acpi_resource *)((char*)resource + resource->length);
 
 		if (found && producer_consumer == ACPI_PRODUCER && address_length > 0) {
 			switch (resource_type) {
@@ -392,10 +392,10 @@
 #if ACPI_CA_VERSION < 0x20020201
 	acpi_buffer buffer;
 #else
-	acpi_buffer buffer = { .length = ACPI_ALLOCATE_BUFFER,
-			       .pointer = NULL};
+	struct acpi_buffer buffer = { .length = ACPI_ALLOCATE_BUFFER,
+				      .pointer = NULL};
 #endif
-	acpi_object *package;
+	union acpi_object *package;
 	int i;
 
 	/* default numbers */
@@ -425,7 +425,7 @@
 		return;
 	}
 
-	package = (acpi_object *) buffer.pointer;
+	package = (union acpi_object *) buffer.pointer;
 
 	if (!package || package->type != ACPI_TYPE_PACKAGE ||
 	    package->package.count != 4 || !package->package.elements) {
@@ -497,8 +497,8 @@
 #if ACPI_CA_VERSION < 0x20020201
 	acpi_buffer buffer;
 #else
-	acpi_buffer buffer = { .length = ACPI_ALLOCATE_BUFFER,
-			       .pointer = NULL};
+	struct acpi_buffer buffer = { .length = ACPI_ALLOCATE_BUFFER,
+				      .pointer = NULL};
 #endif
 	struct acpiphp_bridge *bridge;
 
@@ -613,6 +613,7 @@
 		bridge->io_head = acpiphp_make_resource((u64)base, limit - base + 1);
 		if (!bridge->io_head) {
 			err("out of memory\n");
+			kfree(bridge);
 			return;
 		}
 		dbg("16bit I/O range: %04x-%04x\n",
@@ -627,6 +628,7 @@
 		bridge->io_head = acpiphp_make_resource((u64)base, limit - base + 1);
 		if (!bridge->io_head) {
 			err("out of memory\n");
+			kfree(bridge);
 			return;
 		}
 		dbg("32bit I/O range: %08x-%08x\n",
@@ -648,6 +650,7 @@
 	bridge->mem_head = acpiphp_make_resource((u64)base, limit - base + 1);
 	if (!bridge->mem_head) {
 		err("out of memory\n");
+		kfree(bridge);
 		return;
 	}
 	dbg("32bit Memory range: %08x-%08x\n",
@@ -667,6 +670,7 @@
 		bridge->p_mem_head = acpiphp_make_resource((u64)base, limit - base + 1);
 		if (!bridge->p_mem_head) {
 			err("out of memory\n");
+			kfree(bridge);
 			return;
 		}
 		dbg("32bit Prefetchable memory range: %08x-%08x\n",
@@ -682,6 +686,7 @@
 		bridge->p_mem_head = acpiphp_make_resource(base64, limit64 - base64 + 1);
 		if (!bridge->p_mem_head) {
 			err("out of memory\n");
+			kfree(bridge);
 			return;
 		}
 		dbg("64bit Prefetchable memory range: %08x%08x-%08x%08x\n",
@@ -747,7 +752,7 @@
 
 
 /* find hot-pluggable slots, and then find P2P bridge */
-static int add_bridges (acpi_handle *handle)
+static int add_bridge (acpi_handle handle)
 {
 	acpi_status status;
 	unsigned long tmp;
@@ -802,36 +807,11 @@
 }
 
 
-/* callback routine to enumerate all the bridges in ACPI namespace */
-static acpi_status
-find_host_bridge (acpi_handle handle, u32 lvl, void *context, void **rv)
+static void remove_bridge (acpi_handle handle)
 {
-	acpi_status status;
-	acpi_device_info info;
-	char objname[5];
-	acpi_buffer buffer = { .length = sizeof(objname),
-			       .pointer = objname };
-
-	status = acpi_get_object_info(handle, &info);
-	if (ACPI_FAILURE(status)) {
-		dbg("%s: failed to get bridge information\n", __FUNCTION__);
-		return AE_OK;		/* continue */
-	}
-
-	info.hardware_id[sizeof(info.hardware_id)-1] = '\0';
-
-	/* TBD use acpi_get_devices() API */
-	if (info.current_status &&
-	    (info.valid & ACPI_VALID_HID) &&
-	    strcmp(info.hardware_id, ACPI_PCI_HOST_HID) == 0) {
-		acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer);
-		dbg("checking PCI-hotplug capable bridges under [%s]\n", objname);
-		add_bridges(handle);
-	}
-	return AE_OK;
+	/* No-op for now .. */
 }
 
-
 static int power_on_slot (struct acpiphp_slot *slot)
 {
 	acpi_status status;
@@ -872,8 +852,8 @@
 	acpi_status status;
 	struct acpiphp_func *func;
 	struct list_head *l;
-	acpi_object_list arg_list;
-	acpi_object arg;
+	struct acpi_object_list arg_list;
+	union acpi_object arg;
 
 	int retval = 0;
 
@@ -884,9 +864,7 @@
 	list_for_each (l, &slot->funcs) {
 		func = list_entry(l, struct acpiphp_func, sibling);
 
-		if (func->flags & FUNC_HAS_PS3) {
-			dbg("%s: executing _PS3 on %s\n", __FUNCTION__,
-			    func->pci_dev->slot_name);
+		if (func->flags & (FUNC_HAS_PS3 | FUNC_EXISTS)) {
 			status = acpi_evaluate_object(func->handle, "_PS3", NULL, NULL);
 			if (ACPI_FAILURE(status)) {
 				warn("%s: _PS3 failed\n", __FUNCTION__);
@@ -899,10 +877,8 @@
 	list_for_each (l, &slot->funcs) {
 		func = list_entry(l, struct acpiphp_func, sibling);
 
-		if (func->flags & FUNC_HAS_EJ0) {
-			dbg("%s: executing _EJ0 on %s\n", __FUNCTION__,
-			    func->pci_dev->slot_name);
-
+		/* We don't want to call _EJ0 on non-existing functions. */
+		if (func->flags & (FUNC_HAS_EJ0 | FUNC_EXISTS)) {
 			/* _EJ0 method take one argument */
 			arg_list.count = 1;
 			arg_list.pointer = &arg;
@@ -915,6 +891,7 @@
 				retval = -1;
 				goto err_exit;
 			}
+			func->flags &= (~FUNC_EXISTS);
 		}
 	}
 
@@ -996,6 +973,8 @@
 		retval = acpiphp_configure_function(func);
 		if (retval)
 			goto err_exit;
+
+		func->flags |= FUNC_EXISTS;
 	}
 
 	slot->flags |= SLOT_ENABLED;
@@ -1101,8 +1080,8 @@
 {
 	struct acpiphp_bridge *bridge;
 	char objname[64];
-	acpi_buffer buffer = { .length = sizeof(objname),
-			       .pointer = objname };
+	struct acpi_buffer buffer = { .length = sizeof(objname),
+				      .pointer = objname };
 
 	bridge = (struct acpiphp_bridge *)context;
 
@@ -1152,8 +1131,8 @@
 {
 	struct acpiphp_func *func;
 	char objname[64];
-	acpi_buffer buffer = { .length = sizeof(objname),
-			       .pointer = objname };
+	struct acpi_buffer buffer = { .length = sizeof(objname),
+				      .pointer = objname };
 
 	acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
 
@@ -1190,25 +1169,26 @@
 }
 
 
+static struct acpi_pci_driver acpi_pci_hp_driver = {
+	.add =		add_bridge,
+	.remove =	remove_bridge,
+};
+
 /**
  * acpiphp_glue_init - initializes all PCI hotplug - ACPI glue data structures
  *
  */
 int acpiphp_glue_init (void)
 {
-	acpi_status status;
+	int num;
 
 	if (list_empty(&pci_root_buses))
 		return -1;
 
-	status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
-				     ACPI_UINT32_MAX, find_host_bridge,
-				     NULL, NULL);
+	num = acpi_pci_register_driver(&acpi_pci_hp_driver);
 
-	if (ACPI_FAILURE(status)) {
-		err("%s: acpi_walk_namespace() failed\n", __FUNCTION__);
+	if (num <= 0)
 		return -1;
-	}
 
 	return 0;
 }
@@ -1407,7 +1387,7 @@
 			if (sta != ACPI_STA_ALL) {
 				retval = acpiphp_disable_slot(slot);
 				if (retval) {
-					err("Error occured in enabling\n");
+					err("Error occurred in enabling\n");
 					up(&slot->crit_sect);
 					goto err_exit;
 				}
@@ -1418,7 +1398,7 @@
 			if (sta == ACPI_STA_ALL) {
 				retval = acpiphp_enable_slot(slot);
 				if (retval) {
-					err("Error occured in enabling\n");
+					err("Error occurred in enabling\n");
 					up(&slot->crit_sect);
 					goto err_exit;
 				}
@@ -1450,7 +1430,7 @@
 
 /*
  * attention LED ON: 1
- *              OFF: 0
+ *		OFF: 0
  *
  * TBD
  * no direct attention led status information via ACPI
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/hotplug/acpiphp_pci.c linux-2.4.22-pre2/drivers/hotplug/acpiphp_pci.c
--- linux-2.4.21/drivers/hotplug/acpiphp_pci.c	2003-06-26 21:45:06.000000000 +0000
+++ linux-2.4.22-pre2/drivers/hotplug/acpiphp_pci.c	2003-06-26 21:43:19.000000000 +0000
@@ -4,7 +4,7 @@
  * Copyright (c) 1995,2001 Compaq Computer Corporation
  * Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
  * Copyright (c) 2001,2002 IBM Corp.
- * Copyright (c) 2002 Takayoshi Kochi (t-kouchi@cq.jp.nec.com)
+ * Copyright (c) 2002 Takayoshi Kochi (t-kochi@bq.jp.nec.com)
  * Copyright (c) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com)
  * Copyright (c) 2002 NEC Corporation
  *
@@ -25,7 +25,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * Send feedback to <t-kouchi@cq.jp.nec.com>
+ * Send feedback to <t-kochi@bq.jp.nec.com>
  *
  */
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/hotplug/acpiphp_res.c linux-2.4.22-pre2/drivers/hotplug/acpiphp_res.c
--- linux-2.4.21/drivers/hotplug/acpiphp_res.c	2003-06-26 21:45:06.000000000 +0000
+++ linux-2.4.22-pre2/drivers/hotplug/acpiphp_res.c	2003-06-26 21:43:20.000000000 +0000
@@ -5,7 +5,7 @@
  * Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
  * Copyright (c) 2001 IBM Corp.
  * Copyright (c) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com)
- * Copyright (c) 2002 Takayoshi Kochi (t-kouchi@cq.jp.nec.com)
+ * Copyright (c) 2002 Takayoshi Kochi (t-kochi@bq.jp.nec.com)
  * Copyright (c) 2002 NEC Corporation
  *
  * All rights reserved.
@@ -25,7 +25,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * Send feedback to <gregkh@us.ibm.com>,<h-aono@ap.jp.nec.com>
+ * Send feedback to <gregkh@us.ibm.com>, <t-kochi@bq.jp.nec.com>
  *
  */
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/isdn/Config.in linux-2.4.22-pre2/drivers/isdn/Config.in
--- linux-2.4.21/drivers/isdn/Config.in	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/isdn/Config.in	2003-06-26 21:43:27.000000000 +0000
@@ -8,6 +8,7 @@
 if [ "$CONFIG_INET" != "n" ]; then
    bool '  Support synchronous PPP' CONFIG_ISDN_PPP
    if [ "$CONFIG_ISDN_PPP" != "n" ]; then
+      bool         '    PPP filtering for ISDN' CONFIG_IPPP_FILTER $CONFIG_FILTER
       bool         '    Use VJ-compression with synchronous PPP' CONFIG_ISDN_PPP_VJ
       bool         '    Support generic MP (RFC 1717)' CONFIG_ISDN_MPP
       dep_tristate '    Support BSD compression' CONFIG_ISDN_PPP_BSDCOMP $CONFIG_ISDN
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/isdn/hisax/avma1_cs.c linux-2.4.22-pre2/drivers/isdn/hisax/avma1_cs.c
--- linux-2.4.21/drivers/isdn/hisax/avma1_cs.c	2002-08-03 00:39:44.000000000 +0000
+++ linux-2.4.22-pre2/drivers/isdn/hisax/avma1_cs.c	2003-06-26 21:43:22.000000000 +0000
@@ -18,6 +18,7 @@
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/timer.h>
+#include <linux/init.h>
 #include <asm/io.h>
 #include <asm/system.h>
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/isdn/hisax/config.c linux-2.4.22-pre2/drivers/isdn/hisax/config.c
--- linux-2.4.21/drivers/isdn/hisax/config.c	2002-11-28 23:53:13.000000000 +0000
+++ linux-2.4.22-pre2/drivers/isdn/hisax/config.c	2003-06-26 21:43:31.000000000 +0000
@@ -1925,6 +1925,8 @@
 		break;
 	case PH_DEACTIVATE | INDICATION:
 		st->l1.l1l2(st, pr, NULL);
+		clear_bit(BC_FLG_BUSY, &bcs->Flag);
+		skb_queue_purge(&bcs->squeue);
 		bcs->hw.b_if = NULL;
 		break;
 	case PH_DATA | INDICATION:
@@ -2012,6 +2014,9 @@
 		else
 			set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
 		break;
+	case PH_DEACTIVATE | REQUEST:
+		test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
+		skb_queue_purge(&bcs->squeue);
 	default:
 		B_L2L1(b_if, pr, arg);
 		break;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/isdn/hisax/hisax_fcpcipnp.c linux-2.4.22-pre2/drivers/isdn/hisax/hisax_fcpcipnp.c
--- linux-2.4.21/drivers/isdn/hisax/hisax_fcpcipnp.c	2002-08-03 00:39:44.000000000 +0000
+++ linux-2.4.22-pre2/drivers/isdn/hisax/hisax_fcpcipnp.c	2003-06-26 21:43:15.000000000 +0000
@@ -515,6 +515,7 @@
 	}
 	skb_push(bcs->tx_skb, bcs->tx_cnt);
 	bcs->tx_cnt = 0;
+	hdlc_fill_fifo(bcs);
 }
 
 static inline void hdlc_xpr_irq(struct fritz_bcs *bcs)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/isdn/hisax/st5481_d.c linux-2.4.22-pre2/drivers/isdn/hisax/st5481_d.c
--- linux-2.4.21/drivers/isdn/hisax/st5481_d.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/isdn/hisax/st5481_d.c	2003-06-26 21:43:20.000000000 +0000
@@ -162,8 +162,8 @@
 	{ST_L1_F8, EV_TIMER3,            l1_timer3},
 	{ST_L1_F8, EV_IND_DP,            l1_go_f3},
 	{ST_L1_F8, EV_IND_AP,            l1_go_f6},
-	{ST_L1_F8, EV_IND_AI8,           l1_go_f8},
-	{ST_L1_F8, EV_IND_AI10,          l1_go_f8},
+	{ST_L1_F8, EV_IND_AI8,           l1_go_f7},
+	{ST_L1_F8, EV_IND_AI10,          l1_go_f7},
 	{ST_L1_F8, EV_IND_RSY,           l1_ignore},
 };
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/isdn/isdn_net.c linux-2.4.22-pre2/drivers/isdn/isdn_net.c
--- linux-2.4.21/drivers/isdn/isdn_net.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/isdn/isdn_net.c	2003-06-26 21:43:33.000000000 +0000
@@ -1296,6 +1296,16 @@
 						restore_flags(flags);
 						return 0;	/* STN (skb to nirvana) ;) */
 					}
+#ifdef CONFIG_IPPP_FILTER
+					if (isdn_ppp_autodial_filter(skb, lp)) {
+						isdn_ppp_free(lp);
+						isdn_net_unbind_channel(lp);
+						restore_flags(flags);
+						isdn_net_unreachable(ndev, skb, "dial rejected: packet filtered");
+						dev_kfree_skb(skb);
+						return 0;
+					}
+#endif
 					restore_flags(flags);
 					isdn_net_dial();	/* Initiate dialing */
 					netif_stop_queue(ndev);
@@ -1793,9 +1803,6 @@
 {
 	isdn_net_local *lp = (isdn_net_local *) ndev->priv;
 	isdn_net_local *olp = lp;	/* original 'lp' */
-#ifdef CONFIG_ISDN_PPP
-	int proto = PPP_PROTOCOL(skb->data);
-#endif
 #ifdef CONFIG_ISDN_X25
 	struct concap_proto *cprot = lp -> netdev -> cprot;
 #endif
@@ -1855,14 +1862,7 @@
 			break;
 #ifdef CONFIG_ISDN_PPP
 		case ISDN_NET_ENCAP_SYNCPPP:
-			/*
-			 * If encapsulation is syncppp, don't reset
-			 * huptimer on LCP packets.
-			 */
-			if (proto != PPP_LCP) {
-				olp->huptimer = 0;
-				lp->huptimer = 0;
-			}
+			/* huptimer is done in isdn_ppp_push_higher */
 			isdn_ppp_receive(lp->netdev, olp, skb);
 			return;
 #endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/isdn/isdn_ppp.c linux-2.4.22-pre2/drivers/isdn/isdn_ppp.c
--- linux-2.4.21/drivers/isdn/isdn_ppp.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/isdn/isdn_ppp.c	2003-06-26 21:43:29.000000000 +0000
@@ -13,6 +13,9 @@
 #include <linux/isdn.h>
 #include <linux/poll.h>
 #include <linux/ppp-comp.h>
+#ifdef CONFIG_IPPP_FILTER
+#include <linux/filter.h>
+#endif
 
 #include "isdn_common.h"
 #include "isdn_ppp.h"
@@ -324,7 +327,10 @@
 	 */
 	is->slcomp = slhc_init(16, 16);	/* not necessary for 2. link in bundle */
 #endif
-
+#ifdef CONFIG_IPPP_FILTER
+	is->pass_filter.filter = NULL;
+	is->active_filter.filter = NULL;
+#endif
 	is->state = IPPP_OPEN;
 
 	return 0;
@@ -379,6 +385,16 @@
 	slhc_free(is->slcomp);
 	is->slcomp = NULL;
 #endif
+#ifdef CONFIG_IPPP_FILTER
+	if (is->pass_filter.filter) {
+		kfree(is->pass_filter.filter);
+		is->pass_filter.filter = NULL;
+	}
+	if (is->active_filter.filter) {
+		kfree(is->active_filter.filter);
+		is->active_filter.filter = NULL;
+	}
+#endif
 
 /* TODO: if this was the previous master: link the stuff to the new master */
 	if(is->comp_stat)
@@ -588,6 +604,39 @@
 				}
 				return set_arg((void *)arg,&pci,sizeof(struct pppcallinfo));
 			}
+#ifdef CONFIG_IPPP_FILTER
+		case PPPIOCSPASS:
+		case PPPIOCSACTIVE:
+			{
+				struct sock_fprog uprog, *filtp;
+				struct sock_filter *code = NULL;
+				int len, err;
+
+				if (copy_from_user(&uprog, (void *) arg, sizeof(uprog)))
+					return -EFAULT;
+				if (uprog.len > 0 && uprog.len < 65536) {
+					len = uprog.len * sizeof(struct sock_filter);
+					code = kmalloc(len, GFP_KERNEL);
+					if (code == NULL)
+						return -ENOMEM;
+					if (copy_from_user(code, uprog.filter, len)) {
+						kfree(code);
+						return -EFAULT;
+					}
+					err = sk_chk_filter(code, uprog.len);
+					if (err) {
+						kfree(code);
+						return err;
+					}
+				}
+				filtp = (cmd == PPPIOCSPASS) ? &is->pass_filter : &is->active_filter;
+				if (filtp->filter)
+					kfree(filtp->filter);
+				filtp->filter = code;
+				filtp->len = uprog.len;
+				break;
+			}
+#endif /* CONFIG_IPPP_FILTER */
 		default:
 			break;
 	}
@@ -977,6 +1026,7 @@
 {
 	struct net_device *dev = &net_dev->dev;
  	struct ippp_struct *is, *mis;
+	isdn_net_local *mlp = NULL;
 	int slot;
 
 	slot = lp->ppp_slot;
@@ -988,7 +1038,8 @@
 	is = ippp_table[slot];
  	
  	if (lp->master) { // FIXME?
- 		slot = ((isdn_net_local *) (lp->master->priv))->ppp_slot;
+		mlp = (isdn_net_local *) lp->master->priv;
+ 		slot = mlp->ppp_slot;
  		if (slot < 0 || slot > ISDN_MAX_CHANNELS) {
  			printk(KERN_ERR "isdn_ppp_push_higher: master->ppp_slot(%d)\n",
  				lp->ppp_slot);
@@ -1082,9 +1133,36 @@
 			return;
 	}
 
- 	/* Reset hangup-timer */
- 	lp->huptimer = 0;
-
+#ifdef CONFIG_IPPP_FILTER
+	/* check if the packet passes the pass and active filters
+	 * the filter instructions are constructed assuming
+	 * a four-byte PPP header on each packet (which is still present) */
+	skb_push(skb, 4);
+	skb->data[0] = 0;	/* indicate inbound */
+
+	if (is->pass_filter.filter
+	    && sk_run_filter(skb, is->pass_filter.filter,
+	                    is->pass_filter.len) == 0) {
+		if (is->debug & 0x2)
+			printk(KERN_DEBUG "IPPP: inbound frame filtered.\n");
+		kfree_skb(skb);
+		return;
+	}
+	if (!(is->active_filter.filter
+	      && sk_run_filter(skb, is->active_filter.filter,
+	                       is->active_filter.len) == 0)) {
+		if (is->debug & 0x2)
+			printk(KERN_DEBUG "IPPP: link-active filter: reseting huptimer.\n");
+		lp->huptimer = 0;
+		if (mlp)
+			mlp->huptimer = 0;
+	}
+	skb_pull(skb, 4);
+#else /* CONFIG_IPPP_FILTER */
+	lp->huptimer = 0;
+	if (mlp)
+		mlp->huptimer = 0;
+#endif /* CONFIG_IPPP_FILTER */
 	skb->dev = dev;
 	skb->mac.raw = skb->data;
 	netif_rx(skb);
@@ -1121,7 +1199,6 @@
 	return skb_push(skb,len);
 }
 
-
 /*
  * send ppp frame .. we expect a PIDCOMPressable proto --
  *  (here: currently always PPP_IP,PPP_VJC_COMP,PPP_VJC_UNCOMP)
@@ -1188,7 +1265,6 @@
 		goto unlock;
 	}
 	ipt = ippp_table[slot];
-	lp->huptimer = 0;
 
 	/*
 	 * after this line .. requeueing in the device queue is no longer allowed!!!
@@ -1199,6 +1275,34 @@
 	 */
 	skb_pull(skb,IPPP_MAX_HEADER);
 
+#ifdef CONFIG_IPPP_FILTER
+	/* check if we should pass this packet
+	 * the filter instructions are constructed assuming
+	 * a four-byte PPP header on each packet */
+	skb_push(skb, 4);
+	skb->data[0] = 1;	/* indicate outbound */
+	*(u_int16_t *)(skb->data + 2) = htons(proto);
+
+	if (ipt->pass_filter.filter 
+	    && sk_run_filter(skb, ipt->pass_filter.filter,
+		             ipt->pass_filter.len) == 0) {
+		if (ipt->debug & 0x4)
+			printk(KERN_DEBUG "IPPP: outbound frame filtered.\n");
+		kfree_skb(skb);
+		goto unlock;
+	}
+	if (!(ipt->active_filter.filter
+	      && sk_run_filter(skb, ipt->active_filter.filter,
+		               ipt->active_filter.len) == 0)) {
+		if (ipt->debug & 0x4)
+			printk(KERN_DEBUG "IPPP: link-active filter: reseting huptimer.\n");
+		lp->huptimer = 0;
+	}
+	skb_pull(skb, 4);
+#else /* CONFIG_IPPP_FILTER */
+	lp->huptimer = 0;
+#endif /* CONFIG_IPPP_FILTER */
+
 	if (ipt->debug & 0x4)
 		printk(KERN_DEBUG "xmit skb, len %d\n", (int) skb->len);
         if (ipts->debug & 0x40)
@@ -1340,6 +1444,50 @@
 	return retval;
 }
 
+#ifdef CONFIG_IPPP_FILTER
+/*
+ * check if this packet may trigger auto-dial.
+ */
+
+int isdn_ppp_autodial_filter(struct sk_buff *skb, isdn_net_local *lp)
+{
+	struct ippp_struct *is = ippp_table[lp->ppp_slot];
+	u_int16_t proto;
+	int drop = 0;
+
+	switch (ntohs(skb->protocol)) {
+	case ETH_P_IP:
+		proto = PPP_IP;
+		break;
+	case ETH_P_IPX:
+		proto = PPP_IPX;
+		break;
+	default:
+		printk(KERN_ERR "isdn_ppp_autodial_filter: unsupported protocol 0x%x.\n",
+		       skb->protocol);
+		return 1;
+	}
+
+	/* the filter instructions are constructed assuming
+	 * a four-byte PPP header on each packet. we have to
+	 * temporarily remove part of the fake header stuck on
+	 * earlier.
+	 */
+	skb_pull(skb, IPPP_MAX_HEADER - 4);
+	skb->data[0] = 1;	/* indicate outbound */
+	*(u_int16_t *)(skb->data + 2) = htons(proto);
+	
+	drop |= is->pass_filter.filter
+	        && sk_run_filter(skb, is->pass_filter.filter,
+	                         is->pass_filter.len) == 0;
+	drop |= is->active_filter.filter
+	        && sk_run_filter(skb, is->active_filter.filter,
+	                         is->active_filter.len) == 0;
+	
+	skb_push(skb, IPPP_MAX_HEADER - 4);
+	return drop;
+}
+#endif
 #ifdef CONFIG_ISDN_MPP
 
 /* this is _not_ rfc1990 header, but something we convert both short and long
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/isdn/isdn_ppp.h linux-2.4.22-pre2/drivers/isdn/isdn_ppp.h
--- linux-2.4.21/drivers/isdn/isdn_ppp.h	2001-12-21 17:41:54.000000000 +0000
+++ linux-2.4.22-pre2/drivers/isdn/isdn_ppp.h	2003-06-26 21:43:16.000000000 +0000
@@ -19,6 +19,7 @@
 extern void isdn_ppp_cleanup(void);
 extern int isdn_ppp_free(isdn_net_local *);
 extern int isdn_ppp_bind(isdn_net_local *);
+extern int isdn_ppp_autodial_filter(struct sk_buff *, isdn_net_local *);
 extern int isdn_ppp_xmit(struct sk_buff *, struct net_device *);
 extern void isdn_ppp_receive(isdn_net_dev *, isdn_net_local *, struct sk_buff *);
 extern int isdn_ppp_dev_ioctl(struct net_device *, struct ifreq *, int);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/isdn/tpam/tpam_queues.c linux-2.4.22-pre2/drivers/isdn/tpam/tpam_queues.c
--- linux-2.4.21/drivers/isdn/tpam/tpam_queues.c	2001-12-21 17:41:54.000000000 +0000
+++ linux-2.4.22-pre2/drivers/isdn/tpam/tpam_queues.c	2003-06-26 21:43:11.000000000 +0000
@@ -146,6 +146,7 @@
 		do {
 			hpic = readl(card->bar0 + TPAM_HPIC_REGISTER);
 			if (waiting_too_long++ > 0xfffffff) {
+				kfree_skb(skb); 
 				spin_unlock(&card->lock);
 				printk(KERN_ERR "TurboPAM(tpam_irq): "
 						"waiting too long...\n");
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/md/md.c linux-2.4.22-pre2/drivers/md/md.c
--- linux-2.4.21/drivers/md/md.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/md/md.c	2003-06-26 21:43:15.000000000 +0000
@@ -2623,6 +2623,7 @@
 		case BLKRAGET:
 		case BLKRASET:
 		case BLKFLSBUF:
+		case BLKSSZGET:
 		case BLKBSZGET:
 		case BLKBSZSET:
 			err = blk_ioctl (dev, cmd, arg);
@@ -3155,7 +3156,7 @@
 	loff_t l = *pos;
 	mddev_t *mddev;
 
-	if (l > 0x10000)
+	if (l >= 0x10000)
 		return NULL;
 	if (!l--)
 		/* header */
@@ -3166,7 +3167,9 @@
 			mddev = list_entry(tmp, mddev_t, all_mddevs);
 			return mddev;
 		}
-	return (void*)2;/* tail */
+	if (!l--)	
+		return (void*)2;/* tail */
+	return NULL;
 }
 
 static void *md_seq_next(struct seq_file *seq, void *v, loff_t *pos)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/md/raid5.c linux-2.4.22-pre2/drivers/md/raid5.c
--- linux-2.4.21/drivers/md/raid5.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/md/raid5.c	2003-06-26 21:43:13.000000000 +0000
@@ -882,7 +882,7 @@
 	/* check if the array has lost two devices and, if so, some requests might
 	 * need to be failed
 	 */
-	if (failed > 1 && to_read+to_write) {
+	if (failed > 1 && to_read+to_write+written) {
 		for (i=disks; i--; ) {
 			/* fail all writes first */
 			if (sh->bh_write[i]) to_write--;
@@ -891,6 +891,14 @@
 				bh->b_reqnext = return_fail;
 				return_fail = bh;
 			}
+			/* and fail all 'written' */
+			if (sh->bh_written[i]) written--;
+			while ((bh = sh->bh_written[i])) {
+				sh->bh_written[i] = bh->b_reqnext;
+				bh->b_reqnext = return_fail;
+				return_fail = bh;
+			}
+
 			/* fail any reads if this device is non-operational */
 			if (!conf->disks[i].operational) {
 				spin_lock_irq(&conf->device_lock);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/message/fusion/isense.c linux-2.4.22-pre2/drivers/message/fusion/isense.c
--- linux-2.4.21/drivers/message/fusion/isense.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/message/fusion/isense.c	2003-06-26 21:43:21.000000000 +0000
@@ -9,7 +9,7 @@
  *  Written By: Steven J. Ralston
  *  (yes I wrote some of the orig. code back in 1991!)
  *  (mailto:sjralston1@netscape.net)
- *  (mailto:Pam.Delaney@lsil.com)
+ *  (mailto:lstephen@lsil.com)
  *
  *  $Id: isense.c,v 1.33 2002/02/27 18:44:19 sralston Exp $
  */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/message/fusion/linux_compat.h linux-2.4.22-pre2/drivers/message/fusion/linux_compat.h
--- linux-2.4.21/drivers/message/fusion/linux_compat.h	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/message/fusion/linux_compat.h	2003-06-26 21:43:16.000000000 +0000
@@ -248,7 +248,7 @@
 /*
  *  We use our new error handling code if the kernel version is 2.4.18 or newer.
  */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,18)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,1)
         #define MPT_SCSI_USE_NEW_EH
 #endif
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/message/fusion/mptbase.c linux-2.4.22-pre2/drivers/message/fusion/mptbase.c
--- linux-2.4.21/drivers/message/fusion/mptbase.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/message/fusion/mptbase.c	2003-06-26 21:43:13.000000000 +0000
@@ -47,7 +47,7 @@
  *  Copyright (c) 1999-2002 LSI Logic Corporation
  *  Originally By: Steven J. Ralston
  *  (mailto:sjralston1@netscape.net)
- *  (mailto:Pam.Delaney@lsil.com)
+ *  (mailto:lstephen@lsil.com)
  *
  *  $Id: mptbase.c,v 1.126 2002/12/16 15:28:45 pdelaney Exp $
  */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/message/fusion/mptbase.h linux-2.4.22-pre2/drivers/message/fusion/mptbase.h
--- linux-2.4.21/drivers/message/fusion/mptbase.h	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/message/fusion/mptbase.h	2003-06-26 21:43:12.000000000 +0000
@@ -11,7 +11,7 @@
  *  Copyright (c) 1999-2002 LSI Logic Corporation
  *  Originally By: Steven J. Ralston
  *  (mailto:sjralston1@netscape.net)
- *  (mailto:Pam.Delaney@lsil.com)
+ *  (mailto:lstephen@lsil.com)
  *
  *  $Id: mptbase.h,v 1.144 2003/01/28 21:31:56 pdelaney Exp $
  */
@@ -80,8 +80,8 @@
 #define COPYRIGHT	"Copyright (c) 1999-2002 " MODULEAUTHOR
 #endif
 
-#define MPT_LINUX_VERSION_COMMON	"2.05.00+"
-#define MPT_LINUX_PACKAGE_NAME		"@(#)mptlinux-2.05.00+"
+#define MPT_LINUX_VERSION_COMMON	"2.05.00fix"
+#define MPT_LINUX_PACKAGE_NAME		"@(#)mptlinux-2.05.00fix"
 #define WHAT_MAGIC_STRING		"@" "(" "#" ")"
 
 #define show_mptmod_ver(s,ver)  \
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/message/fusion/mptctl.c linux-2.4.22-pre2/drivers/message/fusion/mptctl.c
--- linux-2.4.21/drivers/message/fusion/mptctl.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/message/fusion/mptctl.c	2003-06-26 21:43:11.000000000 +0000
@@ -32,7 +32,7 @@
  *  Copyright (c) 1999-2002 LSI Logic Corporation
  *  Originally By: Steven J. Ralston, Noah Romer
  *  (mailto:sjralston1@netscape.net)
- *  (mailto:Pam.Delaney@lsil.com)
+ *  (mailto:lstephen@lsil.com)
  *
  *  $Id: mptctl.c,v 1.63 2002/12/03 21:26:33 pdelaney Exp $
  */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/message/fusion/mptctl.h linux-2.4.22-pre2/drivers/message/fusion/mptctl.h
--- linux-2.4.21/drivers/message/fusion/mptctl.h	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/message/fusion/mptctl.h	2003-06-26 21:43:11.000000000 +0000
@@ -18,7 +18,7 @@
  *  Copyright (c) 1999-2002 LSI Logic Corporation
  *  Originally By: Steven J. Ralston
  *  (mailto:sjralston1@netscape.net)
- *  (mailto:Pam.Delaney@lsil.com)
+ *  (mailto:lstephen@lsil.com)
  *
  *  $Id: mptctl.h,v 1.13 2002/12/03 21:26:33 pdelaney Exp $
  */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/message/fusion/mptscsih.c linux-2.4.22-pre2/drivers/message/fusion/mptscsih.c
--- linux-2.4.21/drivers/message/fusion/mptscsih.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/message/fusion/mptscsih.c	2003-06-26 21:43:18.000000000 +0000
@@ -24,7 +24,7 @@
  *  Copyright (c) 1999-2002 LSI Logic Corporation
  *  Original author: Steven J. Ralston
  *  (mailto:sjralston1@netscape.net)
- *  (mailto:Pam.Delaney@lsil.com)
+ *  (mailto:lstephen@lsil.com)
  *
  *  $Id: mptscsih.c,v 1.106 2003/01/28 21:31:57 pdelaney Exp $
  */
@@ -2526,6 +2526,9 @@
 	for (ii=0; ii < cmd_len; ii++)
 		pScsiReq->CDB[ii] = SCpnt->cmnd[ii];
 
+	for (ii=cmd_len; ii < 16; ii++)
+		pScsiReq->CDB[ii] = 0;
+
 	/* DataLength */
 	pScsiReq->DataLength = cpu_to_le32(datalen);
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/message/fusion/mptscsih.h linux-2.4.22-pre2/drivers/message/fusion/mptscsih.h
--- linux-2.4.21/drivers/message/fusion/mptscsih.h	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/message/fusion/mptscsih.h	2003-06-26 21:43:33.000000000 +0000
@@ -17,8 +17,8 @@
  *
  *  Copyright (c) 1999-2002 LSI Logic Corporation
  *  Originally By: Steven J. Ralston
- *  (mailto:netscape.net)
- *  (mailto:Pam.Delaney@lsil.com)
+ *  (mailto:sjralston1@netscape.net)
+ *  (mailto:lstephen@lsil.com)
  *
  *  $Id: mptscsih.h,v 1.22 2002/12/16 15:28:48 pdelaney Exp $
  */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/message/fusion/scsi3.h linux-2.4.22-pre2/drivers/message/fusion/scsi3.h
--- linux-2.4.21/drivers/message/fusion/scsi3.h	2002-08-03 00:39:44.000000000 +0000
+++ linux-2.4.22-pre2/drivers/message/fusion/scsi3.h	2003-06-26 21:43:19.000000000 +0000
@@ -7,7 +7,7 @@
  *  Copyright (c) 1996-2002 Steven J. Ralston
  *  Written By: Steven J. Ralston (19960517)
  *  (mailto:sjralston1@netscape.net)
- *  (mailto:Pam.Delaney@lsil.com)
+ *  (mailto:lstephen@lsil.com)
  *
  *  $Id: scsi3.h,v 1.9 2002/02/27 18:45:02 sralston Exp $
  */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/3c59x.c linux-2.4.22-pre2/drivers/net/3c59x.c
--- linux-2.4.21/drivers/net/3c59x.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/3c59x.c	2003-06-26 21:43:10.000000000 +0000
@@ -442,6 +442,8 @@
 	CH_3CCFEM656_1,
 	CH_3C450,
 	CH_3C920,
+	CH_3C982A,
+	CH_3C982B,
 };
 
 
@@ -497,8 +499,8 @@
 	 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_HWCKSM, 128, },
 	{"3c980 Cyclone",
 	 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, },
-	{"3c982 Dual Port Server Cyclone",
-	 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, },
+	{"3c980C Python-T",
+	 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM, 128, },
 
 	{"3cSOHO100-TX Hurricane",
 	 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM, 128, },
@@ -535,6 +537,11 @@
 	 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_HWCKSM, 128, },
 	{"3c920 Tornado",
 	 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_HWCKSM, 128, },
+	{"3c982 Hydra Dual Port A",
+	 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_HWCKSM|HAS_NWAY, 128, },
+	{"3c982 Hydra Dual Port B",
+	 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_HWCKSM|HAS_NWAY, 128, },
+
 	{0,}, /* 0 terminated list. */
 };
 
@@ -579,6 +586,8 @@
 	{ 0x10B7, 0x6564, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3CCFEM656_1 },
 	{ 0x10B7, 0x4500, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C450 },
 	{ 0x10B7, 0x9201, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C920 },
+	{ 0x10B7, 0x1201, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C982A },
+	{ 0x10B7, 0x1202, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C982B },
 	{0,}						/* 0 terminated list. */
 };
 MODULE_DEVICE_TABLE(pci, vortex_pci_tbl);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/8139cp.c linux-2.4.22-pre2/drivers/net/8139cp.c
--- linux-2.4.21/drivers/net/8139cp.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/8139cp.c	2003-06-26 21:43:20.000000000 +0000
@@ -1771,7 +1771,6 @@
 	long pciaddr;
 	unsigned int addr_len, i;
 	u8 pci_rev, cache_size;
-	u16 pci_command;
 	unsigned int board_type = (unsigned int) ent->driver_data;
 
 #ifndef MODULE
@@ -1837,7 +1836,7 @@
 	}
 
 	/* Configure DMA attributes. */
-	if (!pci_set_dma_mask(pdev, (u64) 0xffffffffffffffff)) {
+	if (!pci_set_dma_mask(pdev, (u64) 0xffffffffffffffffULL)) {
 		cp->pci_using_dac = 1;
 	} else {
 		rc = pci_set_dma_mask(pdev, (u64) 0xffffffff);
@@ -1929,12 +1928,8 @@
 	}
 
 	/* enable busmastering and memory-write-invalidate */
-	pci_read_config_word(pdev, PCI_COMMAND, &pci_command);
-	if (!(pci_command & PCI_COMMAND_INVALIDATE)) {
-		pci_command |= PCI_COMMAND_INVALIDATE;
-		pci_write_config_word(pdev, PCI_COMMAND, pci_command);
-	}
 	pci_set_master(pdev);
+	pci_set_mwi(pdev);
 
 	if (cp->wol_enabled) cp_set_d3_state (cp);
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/8139too.c linux-2.4.22-pre2/drivers/net/8139too.c
--- linux-2.4.21/drivers/net/8139too.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/8139too.c	2003-06-26 21:43:09.000000000 +0000
@@ -978,7 +978,7 @@
 
 	dev->irq = pdev->irq;
 
-	/* dev->priv/tp zeroed and aligned in init_etherdev */
+	/* dev->priv/tp zeroed and aligned in alloc_etherdev */
 	tp = dev->priv;
 
 	/* note: tp->chipset set in rtl8139_init_board */
@@ -1687,7 +1687,7 @@
 	entry = tp->cur_tx % NUM_TX_DESC;
 
 	if (likely(len < TX_BUF_SIZE)) {
-		if(len < ETH_ZLEN)
+		if (len < ETH_ZLEN)
 			memset(tp->tx_buf[entry], 0, ETH_ZLEN);
 		skb_copy_and_csum_dev(skb, tp->tx_buf[entry]);
 		dev_kfree_skb(skb);
@@ -2146,7 +2146,7 @@
 
 	spin_unlock_irqrestore (&tp->lock, flags);
 
-	synchronize_irq ();
+	synchronize_irq ();		/* racy, but that's ok here */
 	free_irq (dev->irq, dev);
 
 	rtl8139_tx_clear (tp);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/Config.in linux-2.4.22-pre2/drivers/net/Config.in
--- linux-2.4.21/drivers/net/Config.in	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/Config.in	2003-06-26 21:43:11.000000000 +0000
@@ -257,6 +257,9 @@
 fi
 dep_tristate 'D-Link DL2000-based Gigabit Ethernet support' CONFIG_DL2K $CONFIG_PCI
 dep_tristate 'Intel(R) PRO/1000 Gigabit Ethernet support' CONFIG_E1000 $CONFIG_PCI
+if [ "$CONFIG_E1000" != "n" ]; then
+   bool '  Use Rx Polling (NAPI)' CONFIG_E1000_NAPI
+fi
 dep_tristate 'MyriCOM Gigabit Ethernet support' CONFIG_MYRI_SBUS $CONFIG_SBUS
 dep_tristate 'National Semiconductor DP83820 support' CONFIG_NS83820 $CONFIG_PCI
 dep_tristate 'Packet Engines Hamachi GNIC-II support' CONFIG_HAMACHI $CONFIG_PCI
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/Makefile linux-2.4.22-pre2/drivers/net/Makefile
--- linux-2.4.21/drivers/net/Makefile	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/Makefile	2003-06-26 21:43:15.000000000 +0000
@@ -29,6 +29,10 @@
   obj-y += e1000/e1000.o
 endif
 
+ifeq ($(CONFIG_BONDING),y)
+  obj-y += bonding/bonding.o
+endif
+
 ifeq ($(CONFIG_ISDN_PPP),y)
   obj-$(CONFIG_ISDN) += slhc.o
 endif
@@ -46,6 +50,7 @@
 subdir-$(CONFIG_SKFP) += skfp
 subdir-$(CONFIG_E100) += e100
 subdir-$(CONFIG_E1000) += e1000
+subdir-$(CONFIG_BONDING) += bonding
 
 #
 # link order important here
@@ -158,7 +163,6 @@
 
 obj-$(CONFIG_STRIP) += strip.o
 obj-$(CONFIG_DUMMY) += dummy.o
-obj-$(CONFIG_BONDING) += bonding.o
 obj-$(CONFIG_DE600) += de600.o
 obj-$(CONFIG_DE620) += de620.o
 obj-$(CONFIG_AT1500) += lance.o
@@ -229,7 +233,7 @@
 obj-$(CONFIG_ETHER00) +=ether00.o
 obj-$(CONFIG_DL2K) += dl2k.o
 obj-$(CONFIG_R8169) += r8169.o
-obj-$(CONFIG_AMD8111_ETH) += amd8111e.o
+obj-$(CONFIG_AMD8111_ETH) += amd8111e.o mii.o
 
 # non-drivers/net drivers who want mii lib
 obj-$(CONFIG_PCMCIA_SMC91C92) += mii.o
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/Makefile.lib linux-2.4.22-pre2/drivers/net/Makefile.lib
--- linux-2.4.21/drivers/net/Makefile.lib	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/Makefile.lib	2003-06-26 21:43:21.000000000 +0000
@@ -0,0 +1,74 @@
+# These drivers all require crc32.o
+obj-$(CONFIG_8139CP)		+= crc32.o
+obj-$(CONFIG_8139TOO)		+= crc32.o
+obj-$(CONFIG_A2065)		+= crc32.o
+obj-$(CONFIG_ADAPTEC_STARFIRE)	+= crc32.o
+obj-$(CONFIG_AMD8111_ETH)	+= crc32.o
+obj-$(CONFIG_ARM_AM79C961A)	+= crc32.o
+obj-$(CONFIG_AT1700)		+= crc32.o
+obj-$(CONFIG_ATP)		+= crc32.o
+obj-$(CONFIG_BMAC)		+= crc32.o
+obj-$(CONFIG_DE4X5)		+= crc32.o
+obj-$(CONFIG_DECLANCE)		+= crc32.o
+obj-$(CONFIG_DEPCA)		+= crc32.o
+obj-$(CONFIG_DL2K)		+= crc32.o
+obj-$(CONFIG_DM9102)		+= crc32.o
+obj-$(CONFIG_EPIC100)		+= crc32.o
+obj-$(CONFIG_EWRK3)		+= crc32.o
+obj-$(CONFIG_FEALNX)		+= crc32.o
+obj-$(CONFIG_GMAC)		+= crc32.o
+obj-$(CONFIG_HAPPYMEAL)		+= crc32.o
+obj-$(CONFIG_MACE)		+= crc32.o
+obj-$(CONFIG_MACMACE)		+= crc32.o
+obj-$(CONFIG_PCNET32)		+= crc32.o
+obj-$(CONFIG_R8169)		+= crc32.o
+obj-$(CONFIG_SGI_IOC3_ETH)	+= crc32.o
+obj-$(CONFIG_SIS900)		+= crc32.o
+obj-$(CONFIG_SMC9194)		+= crc32.o
+obj-$(CONFIG_SUNBMAC)		+= crc32.o
+obj-$(CONFIG_SUNDANCE)		+= crc32.o
+obj-$(CONFIG_SUNGEM)		+= crc32.o
+obj-$(CONFIG_SUNLANCE)		+= crc32.o
+obj-$(CONFIG_SUNQE)		+= crc32.o
+obj-$(CONFIG_TYPHOON)		+= crc32.o
+obj-$(CONFIG_VIA_RHINE)		+= crc32.o
+obj-$(CONFIG_WINBOND_840)	+= crc32.o
+obj-$(CONFIG_YELLOWFIN)		+= crc32.o
+
+# These rely on drivers/net/7990.o which requires crc32.o
+obj-$(CONFIG_HPLANCE)		+= crc32.o	
+obj-$(CONFIG_MVME147_NET)	+= crc32.o	
+
+# These rely on drivers/net/8390.o which requires crc32.o
+obj-$(CONFIG_OAKNET)		+= crc32.o
+obj-$(CONFIG_NE2K_PCI)		+= crc32.o
+obj-$(CONFIG_STNIC)		+= crc32.o
+obj-$(CONFIG_MAC8390)		+= crc32.o
+obj-$(CONFIG_APNE)		+= crc32.o
+obj-$(CONFIG_PCMCIA_PCNET)	+= crc32.o
+obj-$(CONFIG_ARM_ETHERH)	+= crc32.o
+obj-$(CONFIG_WD80x3)		+= crc32.o
+obj-$(CONFIG_EL2)		+= crc32.o
+obj-$(CONFIG_NE2000)		+= crc32.o
+obj-$(CONFIG_NE2_MCA)		+= crc32.o
+obj-$(CONFIG_HPLAN)		+= crc32.o
+obj-$(CONFIG_HPLAN_PLUS)	+= crc32.o
+obj-$(CONFIG_ULTRA)		+= crc32.o
+obj-$(CONFIG_ULTRAMCA)		+= crc32.o
+obj-$(CONFIG_ULTRA32)		+= crc32.o
+obj-$(CONFIG_E2100)		+= crc32.o
+obj-$(CONFIG_ES3210)		+= crc32.o
+obj-$(CONFIG_LNE390)		+= crc32.o
+obj-$(CONFIG_NE3210)		+= crc32.o
+obj-$(CONFIG_AC3200)		+= crc32.o
+obj-$(CONFIG_ARIADNE2)		+= crc32.o
+obj-$(CONFIG_HYDRA)		+= crc32.o
+
+# drivers/net/pcmcia
+obj-$(CONFIG_PCMCIA_FMVJ18X)	+= crc32.o
+obj-$(CONFIG_PCMCIA_SMC91C92)	+= crc32.o
+obj-$(CONFIG_PCMCIA_XIRTULIP)	+= crc32.o
+
+# drivers/net/tulip
+obj-$(CONFIG_TULIP)		+= crc32.o
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/acenic.c linux-2.4.22-pre2/drivers/net/acenic.c
--- linux-2.4.21/drivers/net/acenic.c	2002-11-28 23:53:13.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/acenic.c	2003-06-26 21:43:20.000000000 +0000
@@ -1865,7 +1865,9 @@
 	} else {
 		printk(KERN_DEBUG "%s: BUG... transmitter died. Kicking it.\n",
 		       dev->name);
+#if 0
 		netif_wake_queue(dev);
+#endif
 	}
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/amd8111e.c linux-2.4.22-pre2/drivers/net/amd8111e.c
--- linux-2.4.21/drivers/net/amd8111e.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/amd8111e.c	2003-06-26 21:43:11.000000000 +0000
@@ -1,6 +1,6 @@
 
 /* Advanced  Micro Devices Inc. AMD8111E Linux Network Driver 
- * Copyright (C) 2002 Advanced Micro Devices 
+ * Copyright (C) 2003 Advanced Micro Devices 
  *
  * 
  * Copyright 2001,2002 Jeff Garzik <jgarzik@mandrakesoft.com> [ 8139cp.c,tg3.c ]
@@ -41,6 +41,20 @@
 	Kernel Mode
 
 Revision History:
+ 	3.0.0
+	   Initial Revision.
+	3.0.1
+	 1. Dynamic interrupt coalescing.
+	 2. Removed prev_stats.
+	 3. MII support.
+	 4. Dynamic IPG support
+	3.0.2  05/29/2003
+	 1. Bug fix: Fixed failure to send jumbo packets larger than 4k.
+	 2. Bug fix: Fixed VLAN support failure.
+	 3. Bug fix: Fixed receive interrupt coalescing bug.
+	 4. Dynamic IPG support is disabled by default.
+	3.0.3 06/05/2003
+	 1. Bug fix: Fixed failure to close the interface if SMP is enabled.
 
 */
 
@@ -77,13 +91,16 @@
 
 #include "amd8111e.h"
 #define MODULE_NAME	"amd8111e"
-#define MODULE_VERSION	"3.0.0"
+#define MODULE_VERSION	"3.0.3"
 MODULE_AUTHOR("Advanced Micro Devices, Inc.");
-MODULE_DESCRIPTION ("AMD8111 based 10/100 Ethernet Controller. Driver Version 3.0.0"); 
+MODULE_DESCRIPTION ("AMD8111 based 10/100 Ethernet Controller. Driver Version 3.0.3");
 MODULE_LICENSE("GPL");
-
 MODULE_PARM(speed_duplex, "1-" __MODULE_STRING (MAX_UNITS) "i");
 MODULE_PARM_DESC(speed_duplex, "Set device speed and duplex modes, 0: Auto Negotitate, 1: 10Mbps Half Duplex, 2: 10Mbps Full Duplex, 3: 100Mbps Half Duplex, 4: 100Mbps Full Duplex");
+MODULE_PARM(coalesce, "1-" __MODULE_STRING(MAX_UNITS) "i");
+MODULE_PARM_DESC(coalesce, "Enable or Disable interrupt coalescing, 1: Enable, 0: Disable");
+MODULE_PARM(dynamic_ipg, "1-" __MODULE_STRING(MAX_UNITS) "i");
+MODULE_PARM_DESC(dynamic_ipg, "Enable or Disable dynamic IPG, 1: Enable, 0: Disable");
 
 static struct pci_device_id amd8111e_pci_tbl[] __devinitdata = {
 		
@@ -92,6 +109,88 @@
 	{ 0, }
 
 };
+/* 
+This function will read the PHY registers.
+*/
+static int amd8111e_read_phy(struct amd8111e_priv* lp, int phy_id, int reg, u32* val)
+{
+	void * mmio = lp->mmio;
+	unsigned int reg_val;
+	unsigned int repeat= REPEAT_CNT;
+
+	reg_val = readl(mmio + PHY_ACCESS);
+	while (reg_val & PHY_CMD_ACTIVE)
+		reg_val = readl( mmio + PHY_ACCESS );
+
+	writel( PHY_RD_CMD | ((phy_id & 0x1f) << 21) |
+			   ((reg & 0x1f) << 16),  mmio +PHY_ACCESS);
+	do{
+		reg_val = readl(mmio + PHY_ACCESS);
+		udelay(30);  /* It takes 30 us to read/write data */
+	} while (--repeat && (reg_val & PHY_CMD_ACTIVE));
+	if(reg_val & PHY_RD_ERR)
+		goto err_phy_read;
+	
+	*val = reg_val & 0xffff;
+	return 0;
+err_phy_read:	
+	*val = 0;
+	return -EINVAL;
+	
+}
+
+/* 
+This function will write into PHY registers. 
+*/
+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;
+	unsigned int reg_val;
+
+	reg_val = readl(mmio + PHY_ACCESS);
+	while (reg_val & PHY_CMD_ACTIVE)
+		reg_val = readl( mmio + PHY_ACCESS );
+
+	writel( PHY_WR_CMD | ((phy_id & 0x1f) << 21) |
+			   ((reg & 0x1f) << 16)|val, mmio + PHY_ACCESS);
+
+	do{
+		reg_val = readl(mmio + PHY_ACCESS);
+		udelay(30);  /* It takes 30 us to read/write the data */
+	} while (--repeat && (reg_val & PHY_CMD_ACTIVE));
+	
+	if(reg_val & PHY_RD_ERR)
+		goto err_phy_write;
+	
+	return 0;
+
+err_phy_write:	
+	return -EINVAL;
+	
+}
+/* 
+This is the mii register read function provided to the mii interface.
+*/ 
+static int amd8111e_mdio_read(struct net_device * dev, int phy_id, int reg_num)
+{
+	struct amd8111e_priv* lp = dev->priv;
+	unsigned int reg_val;
+
+	amd8111e_read_phy(lp,phy_id,reg_num,&reg_val);
+	return reg_val;
+	
+}
+
+/* 
+This is the mii register write function provided to the mii interface.
+*/ 
+static void amd8111e_mdio_write(struct net_device * dev, int phy_id, int reg_num, int val)
+{
+	struct amd8111e_priv* lp = dev->priv;
+
+	amd8111e_write_phy(lp, phy_id, reg_num, val);
+}
 
 /*
 This function will set PHY speed. During initialization sets the original speed to 100 full.
@@ -99,26 +198,39 @@
 static void amd8111e_set_ext_phy(struct net_device *dev)
 {
 	struct amd8111e_priv *lp = (struct amd8111e_priv *)dev->priv;
-	unsigned long  reg_val = 0;
-	void * mmio = lp->mmio;
-	struct amd8111e_link_config *link_config = &lp->link_config;
+	u32 bmcr,advert,tmp;
 	
-	if(!lp->opened){
-		/* Initializing SPEED_100 and DUPLEX_FULL as original values */
-		link_config->orig_speed = SPEED_100;
-		link_config->orig_duplex = DUPLEX_FULL;
-		link_config->orig_phy_option = XPHYSP |XPHYFD;
-	}
-	reg_val = lp->ext_phy_option;
-
-	/* Disable port manager */
-	writel((u32) EN_PMGR, mmio + CMD3 );
+	/* Determine mii register values to set the speed */
+	advert = amd8111e_mdio_read(dev, PHY_ID, MII_ADVERTISE);
+	tmp = advert & ~(ADVERTISE_ALL | ADVERTISE_100BASE4);
+	switch (lp->ext_phy_option){
+
+		default:
+		case SPEED_AUTONEG: /* advertise all values */
+			tmp |= ( ADVERTISE_10HALF|ADVERTISE_10FULL|
+				ADVERTISE_100HALF|ADVERTISE_100FULL) ;
+			break;
+		case SPEED10_HALF:
+			tmp |= ADVERTISE_10HALF;
+			break;
+		case SPEED10_FULL:
+			tmp |= ADVERTISE_10FULL;
+			break;
+		case SPEED100_HALF: 
+			tmp |= ADVERTISE_100HALF;
+			break;
+		case SPEED100_FULL:
+			tmp |= ADVERTISE_100FULL;
+			break;
+	}
+
+	if(advert != tmp)
+		amd8111e_mdio_write(dev, PHY_ID, MII_ADVERTISE, tmp);
+	/* Restart auto negotiation */
+	bmcr = amd8111e_mdio_read(dev, PHY_ID, MII_BMCR);
+	bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);
+	amd8111e_mdio_write(dev, PHY_ID, MII_BMCR, bmcr);
 
-	/* Reset PHY */
-	writel((u32)XPHYRST | lp->ext_phy_option, mmio + CTRL2);
-
-	/* Enable port manager */
-	writel((u32)VAL1 | EN_PMGR, mmio + CMD3 );
 }
 
 /* 
@@ -156,7 +268,7 @@
 }
 
 /*
- This will set the receive buffer length corresponding to the mtu size of network interface.
+This will set the receive buffer length corresponding to the mtu size of networkinterface.
 */
 static inline void amd8111e_set_rx_buff_len(struct net_device* dev)
 {
@@ -226,13 +338,13 @@
 
 		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);
-		lp->rx_ring[i].rx_dr_offset10 = cpu_to_le16(OWN_BIT);
+		lp->rx_ring[i].rx_flags = cpu_to_le16(OWN_BIT);
 	}
 
 	/* Initializing transmit descriptors */
 	for (i = 0; i < NUM_TX_RING_DR; i++) {
 		lp->tx_ring[i].buff_phy_addr = 0;
-		lp->tx_ring[i].tx_dr_offset2 = 0;
+		lp->tx_ring[i].tx_flags = 0;
 		lp->tx_ring[i].buff_count = 0;
 	}
 
@@ -253,6 +365,65 @@
 err_no_mem:
 	return -ENOMEM;
 }
+/* This function will set the interrupt coalescing according to the input arguments */
+static int amd8111e_set_coalesce(struct net_device * dev, enum coal_mode cmod)
+{
+	unsigned int timeout;
+	unsigned int event_count;
+
+	struct amd8111e_priv *lp = dev->priv;
+	void* mmio = lp->mmio;
+	struct amd8111e_coalesce_conf * coal_conf = &lp->coal_conf;
+
+
+	switch(cmod)
+	{
+		case RX_INTR_COAL :
+			timeout = coal_conf->rx_timeout;
+			event_count = coal_conf->rx_event_count;
+			if( timeout > MAX_TIMEOUT || 
+					event_count > MAX_EVENT_COUNT ) 
+			return -EINVAL;
+
+			timeout = timeout * DELAY_TIMER_CONV; 
+			writel(VAL0|STINTEN, mmio+INTEN0);
+			writel((u32)DLY_INT_A_R0|( event_count<< 16 )|timeout,
+							mmio+DLY_INT_A);
+			break;
+
+		case TX_INTR_COAL :
+			timeout = coal_conf->tx_timeout;
+			event_count = coal_conf->tx_event_count;
+			if( timeout > MAX_TIMEOUT || 
+					event_count > MAX_EVENT_COUNT ) 
+			return -EINVAL;
+
+		   
+			timeout = timeout * DELAY_TIMER_CONV; 
+			writel(VAL0|STINTEN,mmio+INTEN0);
+			writel((u32)DLY_INT_B_T0|( event_count<< 16 )|timeout,
+							 mmio+DLY_INT_B);
+			break;
+
+		case DISABLE_COAL:
+			writel(0,mmio+STVAL);
+			writel(STINTEN, mmio+INTEN0);
+			writel(0, mmio +DLY_INT_B);
+			writel(0, mmio+DLY_INT_A);
+			break;
+		 case ENABLE_COAL: 
+		       /* Start the timer */
+			writel((u32)SOFT_TIMER_FREQ, mmio+STVAL); /*  0.5 sec */
+			writel(VAL0|STINTEN, mmio+INTEN0);
+			break;
+		default:
+			break;
+
+   }
+	return 0;
+
+}
+
 /* 
 This function initializes the device registers  and starts the device.  
 */
@@ -267,13 +438,17 @@
 
 	if(amd8111e_init_ring(dev))
 		return -ENOMEM;
+
+	/* enable the port manager and set auto negotiation always */
+	writel((u32) VAL1|EN_PMGR, mmio + CMD3 );
+	writel((u32)XPHYANE|XPHYRST , mmio + CTRL2); 
 	
 	amd8111e_set_ext_phy(dev);
 
 	/* set control registers */
 	reg_val = readl(mmio + CTRL1);
-	
-	writel( reg_val| XMTSP_128 | CACHE_ALIGN | B1_MASK, mmio + CTRL1 );
+	reg_val &= ~XMTSP_MASK;
+	writel( reg_val| XMTSP_128 | CACHE_ALIGN, mmio + CTRL1 );
 
 	/* enable interrupt */
 	writel( APINT5EN | APINT4EN | APINT3EN | APINT2EN | APINT1EN | 
@@ -288,15 +463,21 @@
 
 	writew((u32)NUM_TX_RING_DR, mmio + XMT_RING_LEN0);
 	writew((u16)NUM_RX_RING_DR, mmio + RCV_RING_LEN0);
+	
+	/* set default IPG to 96 */
+	writew((u32)DEFAULT_IPG,mmio+IPG);
+	writew((u32)(DEFAULT_IPG-IFS1_DELTA), mmio + IFS1); 
 
 	if(lp->options & OPTION_JUMBO_ENABLE){
 		writel((u32)VAL2|JUMBO, mmio + CMD3);
 		/* Reset REX_UFLO */
 		writel( REX_UFLO, mmio + CMD2);
 		/* Should not set REX_UFLO for jumbo frames */
-		writel( VAL0 | APAD_XMT | REX_RTRY, mmio + CMD2);
-	}else
+		writel( VAL0 | APAD_XMT|REX_RTRY , mmio + CMD2);
+	}else{
 		writel( VAL0 | APAD_XMT | REX_RTRY|REX_UFLO, mmio + CMD2);
+		writel((u32)JUMBO, mmio + CMD3);
+	}
 
 #if AMD8111E_VLAN_TAG_USED
 	writel((u32) VAL2|VSIZE|VL_TAG_DEL, mmio + CMD3);
@@ -306,11 +487,20 @@
 	/* Setting the MAC address to the device */
 	for(i = 0; i < ETH_ADDR_LEN; i++)
 		writeb( dev->dev_addr[i], mmio + PADR + i ); 
+
+	/* Enable interrupt coalesce */
+	if(lp->options & OPTION_INTR_COAL_ENABLE){
+		printk(KERN_INFO "%s: Interrupt Coalescing Enabled.\n",
+								dev->name);
+		amd8111e_set_coalesce(dev,ENABLE_COAL);
+	}
 	
 	/* set RUN bit to start the chip */
 	writel(VAL2 | RDMD0, mmio + CMD0);
 	writel(VAL0 | INTREN | RUN, mmio + CMD0);
 	
+	/* To avoid PCI posting bug */
+	readl(mmio+CMD0);
 	return 0;
 }
 /* 
@@ -383,7 +573,7 @@
 	writew(MIB_CLEAR, mmio + MIB_ADDR);
 
 	/* Clear LARF */
-	AMD8111E_WRITE_REG64(mmio, LADRF,logic_filter);
+	amd8111e_writeq(*(u64*)logic_filter,mmio+LADRF);
 
 	/* SRAM_SIZE register */
 	reg_val = readl(mmio + SRAM_SIZE);
@@ -393,8 +583,11 @@
 #if AMD8111E_VLAN_TAG_USED
 	writel(VAL2|VSIZE|VL_TAG_DEL, mmio + CMD3 );
 #endif
-	/* CMD2 register */
-	reg_val = readl(mmio + CMD2);
+	/* Set default value to CTRL1 Register */
+	writel(CTRL1_DEFAULT, mmio + CTRL1);
+
+	/* To avoid PCI posting bug */
+	readl(mmio + CMD2);
 
 }
 
@@ -412,6 +605,9 @@
 	/* Clear INT0 */
 	intr0 = readl(lp->mmio + INT0);
 	writel(intr0, lp->mmio + INT0);
+	
+	/* To avoid PCI posting bug */
+	readl(lp->mmio + INT0);
 
 }
 
@@ -421,6 +617,9 @@
 static void amd8111e_stop_chip(struct amd8111e_priv* lp)
 {
 	writel(RUN, lp->mmio + CMD0);
+	
+	/* To avoid PCI posting bug */
+	readl(lp->mmio + CMD0);
 }
 
 /* 
@@ -467,11 +666,10 @@
 	struct amd8111e_priv* lp = dev->priv;
 	int tx_index = lp->tx_complete_idx & TX_RING_DR_MOD_MASK;
 	int status;
-	
 	/* Complete all the transmit packet */
 	while (lp->tx_complete_idx != lp->tx_idx){
 		tx_index =  lp->tx_complete_idx & TX_RING_DR_MOD_MASK;
-		status = le16_to_cpu(lp->tx_ring[tx_index].tx_dr_offset2);
+		status = le16_to_cpu(lp->tx_ring[tx_index].tx_flags);
 
 		if(status & OWN_BIT)
 			break;	/* It still hasn't been Txed */
@@ -487,11 +685,15 @@
 			lp->tx_skbuff[tx_index] = 0;
 			lp->tx_dma_addr[tx_index] = 0;
 		}
-		lp->tx_complete_idx++;	
+		lp->tx_complete_idx++;
+		/*COAL update tx coalescing parameters */
+		lp->coal_conf.tx_packets++;
+		lp->coal_conf.tx_bytes += lp->tx_ring[tx_index].buff_count;	
 
 		if (netif_queue_stopped(dev) &&
 			lp->tx_complete_idx > lp->tx_idx - NUM_TX_BUFFERS +2){
 			/* The ring is no longer full, clear tbusy. */
+			/* lp->tx_full = 0; */
 			netif_wake_queue (dev);
 		}
 	}
@@ -516,33 +718,31 @@
 	
 	/* 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_dr_offset10 & OWN_BIT)
+		if(lp->rx_ring[rx_index].rx_flags & OWN_BIT)
 			return 0;
 	       
 		/* check if err summary bit is set */ 
-		if(le16_to_cpu(lp->rx_ring[rx_index].rx_dr_offset10) & ERR_BIT){
+		if(le16_to_cpu(lp->rx_ring[rx_index].rx_flags) & ERR_BIT){
 			/* 
 			 * There is a tricky error noted by John Murphy,
 			 * <murf@perftech.com> to Russ Nelson: Even with full-sized
 			 * buffers it's possible for a jabber packet to use two
 			 * buffers, with only the last correctly noting the error.			 */
 			/* reseting flags */
-			lp->rx_ring[rx_index].rx_dr_offset10 &= 
-						cpu_to_le16(RESET_RX_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_dr_offset10);
+		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_dr_offset10 &= 
-						cpu_to_le16(RESET_RX_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_dr_offset10) & TT_MASK;
+		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;
@@ -551,16 +751,14 @@
 			min_pkt_len =MIN_PKT_LEN;
 
 		if (pkt_len < min_pkt_len) {
-			lp->rx_ring[rx_index].rx_dr_offset10 &= 
-				cpu_to_le16(RESET_RX_FLAGS);
+			lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS;
 			lp->stats.rx_errors++;
 			goto err_next_pkt;
 		}
 		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_dr_offset10 &= 
-				cpu_to_le16(RESET_RX_FLAGS);
+			lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS;
 			lp->stats.rx_errors++;
 			goto err_next_pkt;
 		}
@@ -580,22 +778,26 @@
 
 #if AMD8111E_VLAN_TAG_USED		
 		
-		vtag = lp->rx_ring[rx_index].rx_dr_offset10 & TT_MASK;
+		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
 #endif
 			
-			dev->last_rx = jiffies;
 			netif_rx (skb);
+			/*COAL update rx coalescing parameters*/
+			lp->coal_conf.rx_packets++;
+			lp->coal_conf.rx_bytes += pkt_len;	
+
+			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 = 
 				cpu_to_le16(lp->rx_buff_len-2);
-		lp->rx_ring[rx_index].rx_dr_offset10 |= cpu_to_le16(OWN_BIT);
+		lp->rx_ring[rx_index].rx_flags |= cpu_to_le16(OWN_BIT);
 		rx_index = (++lp->rx_idx) & RX_RING_DR_MOD_MASK;
 	}
 
@@ -603,8 +805,8 @@
 }
 
 /* 
-This function will store the original speed to restore later, if autoneg is turned on. This speed will be set later when the autoneg is turned off. If the link status indicates that link is down, that will be indicated to the kernel */
-
+This function will indicate the link status to the kernel.
+*/
 static int amd8111e_link_change(struct net_device* dev)
 {	
 	struct amd8111e_priv *lp = dev->priv;
@@ -614,21 +816,11 @@
      	status0 = readl(lp->mmio + STAT0);
 	
 	if(status0 & LINK_STATS){
-		if(status0 & AUTONEG_COMPLETE){
-			/* keeping the original speeds */
-			if((lp->link_config.speed != SPEED_INVALID)&&
-				(lp->link_config.duplex != DUPLEX_INVALID)){
-			lp->link_config.orig_speed = lp->link_config.speed;
-			lp->link_config.orig_duplex = lp->link_config.duplex;
-			lp->link_config.orig_phy_option = lp->ext_phy_option;
-			}
-	
-			lp->link_config.speed = SPEED_INVALID;
-			lp->link_config.duplex = DUPLEX_INVALID;
+		if(status0 & AUTONEG_COMPLETE)
 			lp->link_config.autoneg = AUTONEG_ENABLE;
-			netif_carrier_on(dev);
-			return 0;
-		}
+		else 
+			lp->link_config.autoneg = AUTONEG_DISABLE;
+
 		if(status0 & FULL_DPLX)
 			lp->link_config.duplex = DUPLEX_FULL;
 		else 
@@ -638,13 +830,17 @@
 			lp->link_config.speed = SPEED_10;
 		else if(speed == PHY_SPEED_100)
 			lp->link_config.speed = SPEED_100;
-		lp->link_config.autoneg = AUTONEG_DISABLE;
+
+		printk(KERN_INFO "%s: Link is Up. Speed is %s Mbps %s Duplex\n",			dev->name,
+		       (lp->link_config.speed == SPEED_100) ? "100": "10", 
+		       (lp->link_config.duplex == DUPLEX_FULL)? "Full": "Half"); 
 		netif_carrier_on(dev);
 	}
 	else{	
 		lp->link_config.speed = SPEED_INVALID;
 		lp->link_config.duplex = DUPLEX_INVALID;
 		lp->link_config.autoneg = AUTONEG_INVALID;
+		printk(KERN_INFO "%s: Link is Down.\n",dev->name);
 		netif_carrier_off(dev);
 	}
 		
@@ -671,114 +867,236 @@
 }
 
 /*
-This function retuurns the reads the mib registers and returns the hardware statistics. It adds the previous statistics with new values.*/ 
+This function reads the mib registers and returns the hardware statistics. It  updates previous internal driver statistics with new values.
+*/ 
 static struct net_device_stats *amd8111e_get_stats(struct net_device * dev)
 {
 	struct amd8111e_priv *lp = dev->priv;
 	void * mmio = lp->mmio;
 	unsigned long flags;
-	struct net_device_stats *prev_stats = &lp->prev_stats;
+	/* struct net_device_stats *prev_stats = &lp->prev_stats; */
 	struct net_device_stats* new_stats = &lp->stats;
 	
 	if(!lp->opened)
-		return prev_stats;	
+		return &lp->stats;	
 	spin_lock_irqsave (&lp->lock, flags);
 
 	/* stats.rx_packets */
-	new_stats->rx_packets = prev_stats->rx_packets+
-		amd8111e_read_mib(mmio, rcv_broadcast_pkts)+
-		amd8111e_read_mib(mmio, rcv_multicast_pkts)+
-		amd8111e_read_mib(mmio, rcv_unicast_pkts);
+	new_stats->rx_packets = amd8111e_read_mib(mmio, rcv_broadcast_pkts)+
+				amd8111e_read_mib(mmio, rcv_multicast_pkts)+
+				amd8111e_read_mib(mmio, rcv_unicast_pkts);
 
 	/* stats.tx_packets */
-	new_stats->tx_packets = prev_stats->tx_packets+
-		amd8111e_read_mib(mmio, xmt_packets);
+	new_stats->tx_packets = amd8111e_read_mib(mmio, xmt_packets);
 
 	/*stats.rx_bytes */
-	new_stats->rx_bytes = prev_stats->rx_bytes+
-		amd8111e_read_mib(mmio, rcv_octets);
+	new_stats->rx_bytes = amd8111e_read_mib(mmio, rcv_octets);
 
 	/* stats.tx_bytes */
-	new_stats->tx_bytes = prev_stats->tx_bytes+
-		amd8111e_read_mib(mmio, xmt_octets);
+	new_stats->tx_bytes = amd8111e_read_mib(mmio, xmt_octets);
 
 	/* stats.rx_errors */
-	new_stats->rx_errors = prev_stats->rx_errors+
-		amd8111e_read_mib(mmio, rcv_undersize_pkts)+
-		amd8111e_read_mib(mmio, rcv_fragments)+
-		amd8111e_read_mib(mmio, rcv_jabbers)+
-		amd8111e_read_mib(mmio, rcv_alignment_errors)+
-		amd8111e_read_mib(mmio, rcv_fcs_errors)+
-		amd8111e_read_mib(mmio, rcv_miss_pkts);
+	new_stats->rx_errors = amd8111e_read_mib(mmio, rcv_undersize_pkts)+
+				amd8111e_read_mib(mmio, rcv_fragments)+
+				amd8111e_read_mib(mmio, rcv_jabbers)+
+				amd8111e_read_mib(mmio, rcv_alignment_errors)+
+				amd8111e_read_mib(mmio, rcv_fcs_errors)+
+				amd8111e_read_mib(mmio, rcv_miss_pkts);
 
 	/* stats.tx_errors */
-	new_stats->tx_errors = prev_stats->tx_errors+
-		amd8111e_read_mib(mmio, xmt_underrun_pkts);
+	new_stats->tx_errors = amd8111e_read_mib(mmio, xmt_underrun_pkts);
 
 	/* stats.rx_dropped*/
-	new_stats->rx_dropped = prev_stats->rx_dropped+
-		amd8111e_read_mib(mmio, rcv_miss_pkts);
+	new_stats->rx_dropped = amd8111e_read_mib(mmio, rcv_miss_pkts);
 
 	/* stats.tx_dropped*/
-	new_stats->tx_dropped = prev_stats->tx_dropped+
-		amd8111e_read_mib(mmio,  xmt_underrun_pkts);
+	new_stats->tx_dropped = amd8111e_read_mib(mmio,  xmt_underrun_pkts);
 
 	/* stats.multicast*/
-	new_stats->multicast = prev_stats->multicast+
-		amd8111e_read_mib(mmio, rcv_multicast_pkts);
+	new_stats->multicast = amd8111e_read_mib(mmio, rcv_multicast_pkts);
 
 	/* stats.collisions*/
-	new_stats->collisions = prev_stats->collisions+
-		amd8111e_read_mib(mmio, xmt_collisions);
+	new_stats->collisions = amd8111e_read_mib(mmio, xmt_collisions);
 
 	/* stats.rx_length_errors*/
-	new_stats->rx_length_errors = prev_stats->rx_length_errors+
+	new_stats->rx_length_errors = 
 		amd8111e_read_mib(mmio, rcv_undersize_pkts)+
 		amd8111e_read_mib(mmio, rcv_oversize_pkts);
 
 	/* stats.rx_over_errors*/
-	new_stats->rx_over_errors = prev_stats->rx_over_errors+
-		amd8111e_read_mib(mmio, rcv_miss_pkts);
+	new_stats->rx_over_errors = amd8111e_read_mib(mmio, rcv_miss_pkts);
 
 	/* stats.rx_crc_errors*/
-	new_stats->rx_crc_errors = prev_stats->rx_crc_errors+
-		amd8111e_read_mib(mmio, rcv_fcs_errors);
+	new_stats->rx_crc_errors = amd8111e_read_mib(mmio, rcv_fcs_errors);
 
 	/* stats.rx_frame_errors*/
-	new_stats->rx_frame_errors = prev_stats->rx_frame_errors+
+	new_stats->rx_frame_errors =
 		amd8111e_read_mib(mmio, rcv_alignment_errors);
 
 	/* stats.rx_fifo_errors */
-	new_stats->rx_fifo_errors = prev_stats->rx_fifo_errors+
-		amd8111e_read_mib(mmio, rcv_miss_pkts);
+	new_stats->rx_fifo_errors = amd8111e_read_mib(mmio, rcv_miss_pkts);
 
 	/* stats.rx_missed_errors */
-	new_stats->rx_missed_errors = prev_stats->rx_missed_errors+
-		amd8111e_read_mib(mmio, rcv_miss_pkts);
+	new_stats->rx_missed_errors = amd8111e_read_mib(mmio, rcv_miss_pkts);
 
 	/* stats.tx_aborted_errors*/
-	new_stats->tx_aborted_errors = prev_stats->tx_aborted_errors+
+	new_stats->tx_aborted_errors = 
 		amd8111e_read_mib(mmio, xmt_excessive_collision);
 
 	/* stats.tx_carrier_errors*/
-	new_stats->tx_carrier_errors = prev_stats->tx_carrier_errors+
+	new_stats->tx_carrier_errors = 
 		amd8111e_read_mib(mmio, xmt_loss_carrier);
 
 	/* stats.tx_fifo_errors*/
-	new_stats->tx_fifo_errors = prev_stats->tx_fifo_errors+
-		amd8111e_read_mib(mmio, xmt_underrun_pkts);
+	new_stats->tx_fifo_errors = amd8111e_read_mib(mmio, xmt_underrun_pkts);
 
 	/* stats.tx_window_errors*/
-	new_stats->tx_window_errors = prev_stats->tx_window_errors+
+	new_stats->tx_window_errors =
 		amd8111e_read_mib(mmio, xmt_late_collision);
 
+	/* Reset the mibs for collecting new statistics */
+	/* writew(MIB_CLEAR, mmio + MIB_ADDR);*/
+		
 	spin_unlock_irqrestore (&lp->lock, flags);
 
 	return new_stats;
 }
+/* This function recalculate the interupt coalescing  mode on every interrupt 
+according to the datarate and the packet rate.
+*/
+static int amd8111e_calc_coalesce(struct net_device *dev)
+{
+	struct amd8111e_priv *lp = dev->priv;
+	struct amd8111e_coalesce_conf * coal_conf = &lp->coal_conf;
+	int tx_pkt_rate;
+	int rx_pkt_rate;
+	int tx_data_rate;
+	int rx_data_rate;
+	int rx_pkt_size;
+	int tx_pkt_size;
+
+	tx_pkt_rate = coal_conf->tx_packets - coal_conf->tx_prev_packets;
+	coal_conf->tx_prev_packets =  coal_conf->tx_packets;
+	
+	tx_data_rate = coal_conf->tx_bytes - coal_conf->tx_prev_bytes;
+	coal_conf->tx_prev_bytes =  coal_conf->tx_bytes;
+	
+	rx_pkt_rate = coal_conf->rx_packets - coal_conf->rx_prev_packets;
+	coal_conf->rx_prev_packets =  coal_conf->rx_packets;
+	
+	rx_data_rate = coal_conf->rx_bytes - coal_conf->rx_prev_bytes;
+	coal_conf->rx_prev_bytes =  coal_conf->rx_bytes;
+	
+	if(rx_pkt_rate < 800){
+		if(coal_conf->rx_coal_type != NO_COALESCE){
+			
+			coal_conf->rx_timeout = 0x0;
+			coal_conf->rx_event_count = 0;
+			amd8111e_set_coalesce(dev,RX_INTR_COAL);
+			coal_conf->rx_coal_type = NO_COALESCE;
+		}
+	}
+	else{
+	
+		rx_pkt_size = rx_data_rate/rx_pkt_rate;
+		if (rx_pkt_size < 128){
+			if(coal_conf->rx_coal_type != NO_COALESCE){
+			
+				coal_conf->rx_timeout = 0;
+				coal_conf->rx_event_count = 0;
+				amd8111e_set_coalesce(dev,RX_INTR_COAL);
+				coal_conf->rx_coal_type = NO_COALESCE;
+			}
 
+		}
+		else if ( (rx_pkt_size >= 128) && (rx_pkt_size < 512) ){
+	
+			if(coal_conf->rx_coal_type !=  LOW_COALESCE){
+				coal_conf->rx_timeout = 1;
+				coal_conf->rx_event_count = 4;
+				amd8111e_set_coalesce(dev,RX_INTR_COAL);
+				coal_conf->rx_coal_type = LOW_COALESCE;
+			}
+		}
+		else if ((rx_pkt_size >= 512) && (rx_pkt_size < 1024)){
+			
+			if(coal_conf->rx_coal_type !=  MEDIUM_COALESCE){
+				coal_conf->rx_timeout = 1;
+				coal_conf->rx_event_count = 4;
+				amd8111e_set_coalesce(dev,RX_INTR_COAL);
+				coal_conf->rx_coal_type = MEDIUM_COALESCE;
+			}		
+				
+		}
+		else if(rx_pkt_size >= 1024){
+			if(coal_conf->rx_coal_type !=  HIGH_COALESCE){
+				coal_conf->rx_timeout = 2;
+				coal_conf->rx_event_count = 3;
+				amd8111e_set_coalesce(dev,RX_INTR_COAL);
+				coal_conf->rx_coal_type = HIGH_COALESCE;
+			}		
+		}
+	}
+    	/* NOW FOR TX INTR COALESC */
+	if(tx_pkt_rate < 800){
+		if(coal_conf->tx_coal_type != NO_COALESCE){
+			
+			coal_conf->tx_timeout = 0x0;
+			coal_conf->tx_event_count = 0;
+			amd8111e_set_coalesce(dev,TX_INTR_COAL);
+			coal_conf->tx_coal_type = NO_COALESCE;
+		}
+	}
+	else{
+	
+		tx_pkt_size = tx_data_rate/tx_pkt_rate;
+		if (tx_pkt_size < 128){
+		
+			if(coal_conf->tx_coal_type != NO_COALESCE){
+			
+				coal_conf->tx_timeout = 0;
+				coal_conf->tx_event_count = 0;
+				amd8111e_set_coalesce(dev,TX_INTR_COAL);
+				coal_conf->tx_coal_type = NO_COALESCE;
+			}
+
+		}
+		else if ( (tx_pkt_size >= 128) && (tx_pkt_size < 512) ){
+	
+			if(coal_conf->tx_coal_type !=  LOW_COALESCE){
+				coal_conf->tx_timeout = 1;
+				coal_conf->tx_event_count = 2;
+				amd8111e_set_coalesce(dev,TX_INTR_COAL);
+				coal_conf->tx_coal_type = LOW_COALESCE;
+
+			}
+		}
+		else if ((tx_pkt_size >= 512) && (tx_pkt_size < 1024)){
+			
+			if(coal_conf->tx_coal_type !=  MEDIUM_COALESCE){
+				coal_conf->tx_timeout = 2;
+				coal_conf->tx_event_count = 5;
+				amd8111e_set_coalesce(dev,TX_INTR_COAL);
+				coal_conf->tx_coal_type = MEDIUM_COALESCE;
+			}		
+				
+		}
+		else if(tx_pkt_size >= 1024){
+			if (tx_pkt_size >= 1024){
+				if(coal_conf->tx_coal_type !=  HIGH_COALESCE){
+					coal_conf->tx_timeout = 4;
+					coal_conf->tx_event_count = 8;
+					amd8111e_set_coalesce(dev,TX_INTR_COAL);
+					coal_conf->tx_coal_type = HIGH_COALESCE;
+				}		
+			}
+		}
+	}
+	return 0;
+
+}
 /*
-This is device interrupt function. It handles transmit, receive and link change interrupts.
+This is device interrupt function. It handles transmit, receive,link change and hardware timer interrupts.
 */
 static void amd8111e_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
@@ -791,7 +1109,7 @@
 	if(dev == NULL)
 		return;
 
-	spin_lock (&lp->lock);
+	if (regs) spin_lock (&lp->lock);
 	/* disabling interrupt */
 	writel(INTREN, mmio + CMD0);
 
@@ -819,15 +1137,20 @@
 	/* Check if  Link Change Interrupt has occurred. */
 	if (intr0 & LCINT)
 		amd8111e_link_change(dev);
-	
+
+	/* Check if Hardware Timer Interrupt has occurred. */
+	if (intr0 & STINT)
+		amd8111e_calc_coalesce(dev);
+
 err_no_interrupt:
 	writel( VAL0 | INTREN,mmio + CMD0);
-	spin_unlock(&lp->lock);
-	return;
-
+	
+	if (regs) spin_unlock(&lp->lock);
+	
 }
+
 /*
-This function closes the network interface and copies the new set of statistics into the previous statistics structure so that most recent statistics will be available after the interface is down.
+This function closes the network interface and updates the statistics so that most recent statistics will be available after the interface is down.
 */
 static int amd8111e_close(struct net_device * dev)
 {
@@ -842,10 +1165,15 @@
 	
 	netif_carrier_off(lp->amd8111e_net_dev);
 
-	spin_unlock_irq(&lp->lock);
+	/* Delete ipg timer */
+	if(lp->options & OPTION_DYN_IPG_ENABLE)	        
+		del_timer_sync(&lp->ipg_data.ipg_timer);
 
+	spin_unlock_irq(&lp->lock);
 	free_irq(dev->irq, dev);
-	memcpy(&lp->prev_stats,amd8111e_get_stats(dev), sizeof(lp->prev_stats));
+
+	/* Update the statistics before closing */
+	amd8111e_get_stats(dev);
 	lp->opened = 0;
 	return 0;
 }
@@ -867,7 +1195,12 @@
 		spin_unlock_irq(&lp->lock);
 		return -ENOMEM;
 	}
-	
+	/* Start ipg timer */
+	if(lp->options & OPTION_DYN_IPG_ENABLE){	        
+		add_timer(&lp->ipg_data.ipg_timer);
+		printk(KERN_INFO "%s: Dynamic IPG Enabled.\n",dev->name);
+	}
+
 	lp->opened = 1;
 
 	spin_unlock_irq(&lp->lock);
@@ -905,11 +1238,10 @@
 	lp->tx_ring[tx_index].buff_count = cpu_to_le16(skb->len);
 
 	lp->tx_skbuff[tx_index] = skb;
-	lp->tx_ring[tx_index].tx_dr_offset2 = 0;
+	lp->tx_ring[tx_index].tx_flags = 0;
 
 #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);	
 		lp->tx_ring[tx_index].tag_ctrl_info = 
@@ -923,7 +1255,7 @@
 	    (u32) cpu_to_le32(lp->tx_dma_addr[tx_index]);
 
 	/*  Set FCS and LTINT bits */
-	lp->tx_ring[tx_index].tx_dr_offset2 |=
+	lp->tx_ring[tx_index].tx_flags |=
 	    cpu_to_le16(OWN_BIT | STP_BIT | ENP_BIT|ADD_FCS_BIT|LTINT_BIT);
 
 	lp->tx_idx++;
@@ -946,16 +1278,54 @@
 static char* amd8111e_read_regs(struct amd8111e_priv* lp)
 {    	
 	void * mmio = lp->mmio;
-        unsigned char * reg_buff;
+        u32 * reg_buff;
 
-     	int i;
-     
      	reg_buff = kmalloc( AMD8111E_REG_DUMP_LEN,GFP_KERNEL);
 	if(NULL == reg_buff)
 		return NULL;
-    	for (i=0; i < AMD8111E_REG_DUMP_LEN; i+=4)
-		reg_buff[i]= readl(mmio + i);	
-	return reg_buff;
+
+	/* 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;
+}
+/*
+amd8111e crc generator implementation is different from the kernel
+ether_crc() function.
+*/
+int amd8111e_ether_crc(int len, char* mac_addr)
+{
+	int i,byte;
+	unsigned char octet;
+	u32 crc= INITCRC;
+
+	for(byte=0; byte < len; byte++){
+		octet = mac_addr[byte];
+		for( i=0;i < 8; i++){
+			/*If the next bit form the input stream is 1,subtract				 the divisor (CRC32) from the dividend(crc).*/
+			if( (octet & 0x1) ^ (crc & 0x1) ){
+				crc >>= 1;
+				crc ^= CRC32;
+			}
+			else
+				crc >>= 1;
+			
+			octet >>= 1;
+		}
+	}	
+	return crc; 
 }
 /*
 This function sets promiscuos mode, all-multi mode or the multicast address 
@@ -967,9 +1337,8 @@
 	struct amd8111e_priv *lp = dev->priv;
 	u32 mc_filter[2] ;
 	int i,bit_num;
-
 	if(dev->flags & IFF_PROMISC){
-		printk("%s: Setting  promiscuous mode.\n",dev->name);
+		printk(KERN_INFO "%s: Setting  promiscuous mode.\n",dev->name);
 		writel( VAL2 | PROM, lp->mmio + CMD2);
 		return;
 	}
@@ -980,7 +1349,7 @@
 		mc_filter[1] = mc_filter[0] = 0xffffffff;
 		lp->mc_list = dev->mc_list;
 		lp->options |= OPTION_MULTICAST_ENABLE;
-		AMD8111E_WRITE_REG64(lp->mmio, LADRF,mc_filter);
+		amd8111e_writeq(*(u64*)mc_filter,lp->mmio + LADRF);
 		return;
 	}
 	if( dev->mc_count == 0 ){
@@ -988,7 +1357,7 @@
 		mc_filter[1] = mc_filter[0] = 0;
 		lp->mc_list = 0;
 		lp->options &= ~OPTION_MULTICAST_ENABLE;
-		AMD8111E_WRITE_REG64(lp->mmio, LADRF,mc_filter);
+		amd8111e_writeq(*(u64*)mc_filter,lp->mmio + LADRF);
 		/* disable promiscous mode */
 		writel(PROM, lp->mmio + CMD2);
 		return;
@@ -999,14 +1368,16 @@
 	mc_filter[1] = mc_filter[0] = 0;
 	for (i = 0, mc_ptr = dev->mc_list; mc_ptr && i < dev->mc_count;
 		     i++, mc_ptr = mc_ptr->next) {
-		bit_num = ether_crc(ETH_ALEN, mc_ptr->dmi_addr) >> 26;
-			
+		bit_num = ( amd8111e_ether_crc(ETH_ALEN,mc_ptr->dmi_addr)							 >> 26 ) & 0x3f;
 		mc_filter[bit_num >> 5] |= 1 << (bit_num & 31);
 	}	
+	amd8111e_writeq(*(u64*)mc_filter,lp->mmio+ LADRF);
+
+	/* To eliminate PCI posting bug */
+	readl(lp->mmio + CMD2);
 
-	AMD8111E_WRITE_REG64(lp->mmio, LADRF, mc_filter);
-	return;
 }
+
 /*
 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. 
 */
@@ -1029,6 +1400,7 @@
 		strcpy (info.driver, MODULE_NAME);
 		strcpy (info.version, MODULE_VERSION);
 		memset(&info.fw_version, 0, sizeof(info.fw_version));
+		sprintf(info.fw_version,"%u",chip_version);
 		strcpy (info.bus_info, pci_dev->slot_name);
 		info.eedump_len = 0;
 		info.regdump_len = AMD8111E_REG_DUMP_LEN;
@@ -1036,85 +1408,27 @@
 			return -EFAULT;
 		return 0;
 	}
-	case ETHTOOL_GSET:{
-		struct ethtool_cmd cmd = { ETHTOOL_GSET };
-
-		if (!lp->opened) 
-			return -EAGAIN;
-
-		cmd.supported = SUPPORTED_Autoneg |
-				SUPPORTED_100baseT_Half |
-				SUPPORTED_100baseT_Full |
-			  	SUPPORTED_10baseT_Half |
-			        SUPPORTED_10baseT_Full |
-			        SUPPORTED_MII;
-
-		cmd.advertising = ADVERTISED_Autoneg |
-				ADVERTISED_100baseT_Half |
-				ADVERTISED_100baseT_Full |
-			  	ADVERTISED_10baseT_Half |
-			        ADVERTISED_10baseT_Full |
-			        ADVERTISED_MII;
-		cmd.speed = lp->link_config.speed;
-		cmd.duplex = lp->link_config.duplex;
-		cmd.port = 0;
-		cmd.phy_address = PHY_ID;
-		cmd.transceiver = XCVR_EXTERNAL;
-		cmd.autoneg = lp->link_config.autoneg;
-		cmd.maxtxpkt = 0; /* not implemented interrupt coalasing */
-		cmd.maxrxpkt = 0; /* not implemented interrupt coalasing */
-		if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
+	/* 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: {
-	
-		struct ethtool_cmd cmd;
-
-		if (!lp->opened)
-			return -EAGAIN;
-		if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
+		int r;
+		struct ethtool_cmd ecmd;
+		if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
 			return -EFAULT;
 
 		spin_lock_irq(&lp->lock);
-
-		if(cmd.autoneg == AUTONEG_ENABLE){
-			/* keeping the original speeds */
-			if((lp->link_config.speed != SPEED_INVALID)&&
-				(lp->link_config.duplex != DUPLEX_INVALID)){
-			lp->link_config.orig_speed = lp->link_config.speed;
-			lp->link_config.orig_duplex = lp->link_config.duplex;
-			lp->link_config.orig_phy_option = lp->ext_phy_option;
-			}
-
-			lp->ext_phy_option = XPHYANE;
-		}
-		else if(cmd.speed == SPEED_100 && cmd.duplex ==  DUPLEX_HALF)
-			lp->ext_phy_option = XPHYSP;
-		else if(cmd.speed == SPEED_100 && cmd.duplex ==  DUPLEX_FULL)
-			lp->ext_phy_option = XPHYSP |XPHYFD;
-		else if(cmd.speed == SPEED_10 && cmd.duplex ==  DUPLEX_HALF)
-			lp->ext_phy_option = 0;
-		else if(cmd.speed == SPEED_10 && cmd.duplex ==  DUPLEX_FULL)
-			lp->ext_phy_option = XPHYFD;
-		else {	
-			/* setting the original speed */
-			cmd.speed = lp->link_config.orig_speed;
-			cmd.duplex = lp->link_config.orig_duplex;
-			lp->ext_phy_option = lp->link_config.orig_phy_option;
-		}
-		lp->link_config.autoneg = cmd.autoneg;
-		if (cmd.autoneg == AUTONEG_ENABLE) {
-			
-			lp->link_config.speed = SPEED_INVALID;
-			lp->link_config.duplex = DUPLEX_INVALID;
-		} else {
-			lp->link_config.speed = cmd.speed;
-			lp->link_config.duplex = cmd.duplex;
-		}
-		amd8111e_set_ext_phy(dev);
+		r = mii_ethtool_sset(&lp->mii_if, &ecmd);
 		spin_unlock_irq(&lp->lock);
-		return 0;
+		return r;
 	}
 	case ETHTOOL_GREGS: {
 		struct ethtool_regs regs;
@@ -1140,24 +1454,17 @@
 		kfree(regbuf);
 		return ret;
 	}
+	/* restart autonegotiation */
 	case ETHTOOL_NWAY_RST: {
-		int ret;
-		spin_lock_irq(&lp->lock);
-		if(lp->link_config.autoneg == AUTONEG_ENABLE){
-			lp->ext_phy_option = XPHYANE;
-			amd8111e_set_ext_phy(dev);
-			ret = 0;
-		}else
-			ret =  -EINVAL;
-		spin_unlock_irq(&lp->lock);
-		return ret;
+		return mii_nway_restart(&lp->mii_if);
 	}
+	/* get link status */
 	case ETHTOOL_GLINK: {
-		struct ethtool_value val = { ETHTOOL_GLINK };
-
-		val.data = netif_carrier_ok(dev) ? 1 : 0;
+		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 };
@@ -1196,60 +1503,6 @@
 	}
 		return -EOPNOTSUPP;
 }
-static int amd8111e_read_phy(struct amd8111e_priv* lp, int phy_id, int reg, u32* val)
-{
-	void * mmio = lp->mmio;
-	unsigned int reg_val;
-	unsigned int repeat= REPEAT_CNT;
-
-	reg_val = readl(mmio + PHY_ACCESS);
-	while (reg_val & PHY_CMD_ACTIVE)
-		reg_val = readl( mmio + PHY_ACCESS );
-
-	writel( PHY_RD_CMD | ((phy_id & 0x1f) << 21) |
-			   ((reg & 0x1f) << 16),  mmio +PHY_ACCESS);
-	do{
-		reg_val = readl(mmio + PHY_ACCESS);
-		udelay(30);  /* It takes 30 us to read/write data */
-	} while (--repeat && (reg_val & PHY_CMD_ACTIVE));
-	if(reg_val & PHY_RD_ERR)
-		goto err_phy_read;
-	
-	*val = reg_val & 0xffff;
-	return 0;
-err_phy_read:	
-	*val = 0;
-	return -EINVAL;
-	
-}
-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;
-	unsigned int reg_val;
-	
-
-	reg_val = readl(mmio + PHY_ACCESS);
-	while (reg_val & PHY_CMD_ACTIVE)
-		reg_val = readl( mmio + PHY_ACCESS );
-
-	writel( PHY_WR_CMD | ((phy_id & 0x1f) << 21) |
-			   ((reg & 0x1f) << 16)|val, mmio + PHY_ACCESS);
-
-	do{
-		reg_val = readl(mmio + PHY_ACCESS);
-		udelay(30);  /* It takes 30 us to read/write the data */
-	} while (--repeat && (reg_val & PHY_CMD_ACTIVE));
-	
-	if(reg_val & PHY_RD_ERR)
-		goto err_phy_write;
-	
-	return 0;
-
-err_phy_write:	
-	return -EINVAL;
-	
-}
 static int amd8111e_ioctl(struct net_device * dev , struct ifreq *ifr, int cmd)
 {
 	struct mii_ioctl_data *data = (struct mii_ioctl_data *)&ifr->ifr_data;
@@ -1317,15 +1570,10 @@
 
 	dev->mtu = new_mtu;
 
-	/* if (new_mtu > ETH_DATA_LEN)
-		lp->options |= OPTION_JUMBO_ENABLE;
-	else
-		lp->options &= ~OPTION_JUMBO_ENABLE;
-	*/
 	err = amd8111e_restart(dev);
 	spin_unlock_irq(&lp->lock);
-
-	netif_start_queue(dev);
+	if(!err)
+		netif_start_queue(dev);
 	return err;
 }
 
@@ -1351,73 +1599,41 @@
 {
 	writel( VAL1|MPPLBA, lp->mmio + CMD3);
 	writel( VAL0|MPEN_SW, lp->mmio + CMD7);
+
+	/* To eliminate PCI posting bug */
+	readl(lp->mmio + CMD7);
 	return 0;
 }
 
 static int amd8111e_enable_link_change(struct amd8111e_priv* lp)
 {
+
 	/* Adapter is already stoped/suspended/interrupt-disabled */
 	writel(VAL0|LCMODE_SW,lp->mmio + CMD7);
-	return 0;
-}	
-
-/* 
-This function sets the power state of the device. When the device go to lower power states 1,2, and 3 it enables the wake on lan 
-*/  	
-static int amd8111e_set_power_state(struct amd8111e_priv* lp, u32 state)
-{
-	u16 power_control;
-	int pm = lp->pm_cap;
-
-	pci_read_config_word(lp->pci_dev,
-			     pm + PCI_PM_CTRL,
-			     &power_control);
-
-	power_control |= PCI_PM_CTRL_PME_STATUS;
-	power_control &= ~(PCI_PM_CTRL_STATE_MASK);
-	switch (state) {
-	case 0:
-		power_control |= 0;
-		pci_write_config_word(lp->pci_dev,
-				      pm + PCI_PM_CTRL,
-				      power_control);
-		return 0;
-
-	case 1:
-		power_control |= 1;
-		break;
-
-	case 2:
-		power_control |= 2;
-		break;
-
-	case 3:
-		power_control |= 3;
-		break;
-	default:
-
-		printk(KERN_WARNING "%s: Invalid power state (%d) requested.\n",
-		       lp->amd8111e_net_dev->name, state);
-		return -EINVAL;
-	}
 	
-	if(lp->options & OPTION_WAKE_MAGIC_ENABLE)
-		amd8111e_enable_magicpkt(lp);	
-	if(lp->options & OPTION_WAKE_PHY_ENABLE)
-		amd8111e_enable_link_change(lp);	
-
-	/*  Setting new power state. */
-	pci_write_config_word(lp->pci_dev, pm + PCI_PM_CTRL, power_control);
-
+	/* To eliminate PCI posting bug */
+	readl(lp->mmio + CMD7);
 	return 0;
+}	
+/* This function is called when a packet transmission fails to complete within a  resonable period, on the assumption that an interrupts have been failed or the  interface is locked up. This function will reinitialize the hardware */
 
+static void amd8111e_tx_timeout(struct net_device *dev)
+{
+	struct amd8111e_priv* lp = dev->priv;
+	int err;
 
+	printk(KERN_ERR "%s: transmit timed out, resetting\n",
+	 					      dev->name);
+	spin_lock_irq(&lp->lock);
+	err = amd8111e_restart(dev);
+	spin_unlock_irq(&lp->lock);
+	if(!err)
+		netif_wake_queue(dev);
 }
 static int amd8111e_suspend(struct pci_dev *pci_dev, u32 state)
 {	
 	struct net_device *dev = pci_get_drvdata(pci_dev);
 	struct amd8111e_priv *lp = dev->priv;
-	int err;
 	
 	if (!netif_running(dev))
 		return 0;
@@ -1431,37 +1647,54 @@
 	
 	/* stop chip */
 	spin_lock_irq(&lp->lock);
+	if(lp->options & OPTION_DYN_IPG_ENABLE)	        
+		del_timer_sync(&lp->ipg_data.ipg_timer);
 	amd8111e_stop_chip(lp);
 	spin_unlock_irq(&lp->lock);
 
-	err = amd8111e_set_power_state(lp, state);
-	if (err) {
+	if(lp->options & OPTION_WOL_ENABLE){
+		 /* enable wol */
+		if(lp->options & OPTION_WAKE_MAGIC_ENABLE)
+			amd8111e_enable_magicpkt(lp);	
+		if(lp->options & OPTION_WAKE_PHY_ENABLE)
+			amd8111e_enable_link_change(lp);	
 		
-		spin_lock_irq(&lp->lock);
-		amd8111e_restart(dev);
-		spin_unlock_irq(&lp->lock);
+		pci_enable_wake(pci_dev, 3, 1);
+		pci_enable_wake(pci_dev, 4, 1); /* D3 cold */
 
-		netif_device_attach(dev);
 	}
-	return err;
+	else{		
+		pci_enable_wake(pci_dev, 3, 0);
+		pci_enable_wake(pci_dev, 4, 0); /* 4 == D3 cold */
+	}
+	
+	pci_save_state(pci_dev, lp->pm_state);
+	pci_set_power_state(pci_dev, 3);
+
+	return 0;
 }
 static int amd8111e_resume(struct pci_dev *pci_dev)
 {
 	struct net_device *dev = pci_get_drvdata(pci_dev);
 	struct amd8111e_priv *lp = dev->priv;
-	int err;
 	
 	if (!netif_running(dev))
 		return 0;
 
-	err = amd8111e_set_power_state(lp, 0);
-	if (err)
-		return err;
+	pci_set_power_state(pci_dev, 0);
+	pci_restore_state(pci_dev, lp->pm_state);
+
+	pci_enable_wake(pci_dev, 3, 0);
+	pci_enable_wake(pci_dev, 4, 0); /* D3 cold */
 
 	netif_device_attach(dev);
 
 	spin_lock_irq(&lp->lock);
 	amd8111e_restart(dev);
+	/* Restart ipg timer */
+	if(lp->options & OPTION_DYN_IPG_ENABLE)	        
+		mod_timer(&lp->ipg_data.ipg_timer, 
+				jiffies + (IPG_CONVERGE_TIME * HZ));
 	spin_unlock_irq(&lp->lock);
 
 	return 0;
@@ -1480,6 +1713,65 @@
 		pci_set_drvdata(pdev, NULL);
 	}
 }
+static void amd8111e_config_ipg(struct net_device* dev)
+{
+	struct amd8111e_priv *lp = dev->priv;
+	struct ipg_info* ipg_data = &lp->ipg_data;
+	void * mmio = lp->mmio;
+	unsigned int prev_col_cnt = ipg_data->col_cnt;
+	unsigned int total_col_cnt;
+	unsigned int tmp_ipg;
+	
+	if(lp->link_config.duplex == DUPLEX_FULL){
+		ipg_data->ipg = DEFAULT_IPG;
+		return;
+	}
+
+	if(ipg_data->ipg_state == SSTATE){
+		
+		if(ipg_data->timer_tick == IPG_STABLE_TIME){
+			
+			ipg_data->timer_tick = 0;
+			ipg_data->ipg = MIN_IPG - IPG_STEP;
+			ipg_data->current_ipg = MIN_IPG;
+			ipg_data->diff_col_cnt = 0xFFFFFFFF;
+			ipg_data->ipg_state = CSTATE;
+		}
+		else
+			ipg_data->timer_tick++;
+	}
+
+	if(ipg_data->ipg_state == CSTATE){
+		
+		/* Get the current collision count */
+
+		total_col_cnt = ipg_data->col_cnt = 
+				amd8111e_read_mib(mmio, xmt_collisions);
+
+		if ((total_col_cnt - prev_col_cnt) < 
+				(ipg_data->diff_col_cnt)){
+			
+			ipg_data->diff_col_cnt =
+				total_col_cnt - prev_col_cnt ;
+
+			ipg_data->ipg = ipg_data->current_ipg;
+		}
+
+		ipg_data->current_ipg += IPG_STEP;
+
+		if (ipg_data->current_ipg <= MAX_IPG)
+			tmp_ipg = ipg_data->current_ipg;
+		else{
+			tmp_ipg = ipg_data->ipg;
+			ipg_data->ipg_state = SSTATE;
+		}
+		writew((u32)tmp_ipg, mmio + IPG); 
+		writew((u32)(tmp_ipg - IFS1_DELTA), mmio + IFS1); 
+	}
+	 mod_timer(&lp->ipg_data.ipg_timer, jiffies + (IPG_CONVERGE_TIME * HZ));
+	return;
+
+}
 
 static int __devinit amd8111e_probe_one(struct pci_dev *pdev,
 				  const struct pci_device_id *ent)
@@ -1488,7 +1780,6 @@
 	unsigned long reg_addr,reg_len;
 	struct amd8111e_priv* lp;
 	struct net_device* dev;
-	unsigned int chip_version;
 
 	err = pci_enable_device(pdev);
 	if(err){
@@ -1547,11 +1838,16 @@
 #endif	
 	
 	lp = dev->priv;
-	memset (lp, 0, sizeof (*lp));
 	lp->pci_dev = pdev;
 	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);
@@ -1565,12 +1861,14 @@
 	/* Initializing MAC address */
 	for(i = 0; i < ETH_ADDR_LEN; i++)
 			dev->dev_addr[i] =readb(lp->mmio + PADR + i);
-	/* Setting user defined speed */
-	if (speed_duplex[card_idx] > sizeof(speed_duplex_mapping))
-		lp->ext_phy_option = XPHYANE;
-	else
-		lp->ext_phy_option = 
-				speed_duplex_mapping[speed_duplex[card_idx]];
+	
+	/* Setting user defined parametrs */
+	lp->ext_phy_option = speed_duplex[card_idx];
+	if(coalesce[card_idx])
+		lp->options |= OPTION_INTR_COAL_ENABLE;		
+	if(dynamic_ipg[card_idx++])
+		lp->options |= OPTION_DYN_IPG_ENABLE;	        	
+
 	/* Initialize driver entry points */
 	dev->open = amd8111e_open;
 	dev->hard_start_xmit = amd8111e_start_xmit;
@@ -1580,6 +1878,8 @@
 	dev->do_ioctl = amd8111e_ioctl;
 	dev->change_mtu = amd8111e_change_mtu;
 	dev->irq =pdev->irq;
+	dev->tx_timeout = amd8111e_tx_timeout; 
+	dev->watchdog_timeo = AMD8111E_TX_TIMEOUT; 
 
 #if AMD8111E_VLAN_TAG_USED
 	dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
@@ -1589,10 +1889,6 @@
 	
 	/* Set receive buffer length and set jumbo option*/
 	amd8111e_set_rx_buff_len(dev);
-	
-
-	/* dev->tx_timeout = tg3_tx_timeout; */
-	/* dev->watchdog_timeo = TG3_TX_TIMEOUT; */
 
 	err = register_netdev(dev);
 	if (err) {
@@ -1603,15 +1899,26 @@
 
 	pci_set_drvdata(pdev, dev);
 	
+	/* Initialize software ipg timer */
+	if(lp->options & OPTION_DYN_IPG_ENABLE){	        
+		init_timer(&lp->ipg_data.ipg_timer);
+		lp->ipg_data.ipg_timer.data = (unsigned long) dev;
+		lp->ipg_data.ipg_timer.function = (void *)&amd8111e_config_ipg;
+		lp->ipg_data.ipg_timer.expires = jiffies + 
+						 IPG_CONVERGE_TIME * HZ;
+		lp->ipg_data.ipg = DEFAULT_IPG;
+		lp->ipg_data.ipg_state = CSTATE;
+	};
+
 	/*  display driver and device information */
 
-    chip_version = (readl(lp->mmio + CHIPID) & 0xf0000000)>>28;
-    printk("%s: AMD-8111e Driver Version: %s\n",dev->name,MODULE_VERSION);
-    printk("%s: [ Rev %x ] PCI 10/100BaseT Ethernet ", dev->name, chip_version);
-    for (i = 0; i < 6; i++)
-	printk("%2.2x%c", dev->dev_addr[i],i == 5 ? ' ' : ':');
-     printk("\n");	
-	return 0;
+    	chip_version = (readl(lp->mmio + CHIPID) & 0xf0000000)>>28;
+    	printk(KERN_INFO "%s: AMD-8111e Driver Version: %s\n",								 dev->name,MODULE_VERSION);
+    	printk(KERN_INFO "%s: [ Rev %x ] PCI 10/100BaseT Ethernet ",							dev->name, chip_version);
+    	for (i = 0; i < 6; i++)
+		printk("%2.2x%c",dev->dev_addr[i],i == 5 ? ' ' : ':');
+    	printk( "\n");	
+    	return 0;
 err_iounmap:
 	iounmap((void *) lp->mmio);
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/amd8111e.h linux-2.4.22-pre2/drivers/net/amd8111e.h
--- linux-2.4.21/drivers/net/amd8111e.h	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/amd8111e.h	2003-06-26 21:43:13.000000000 +0000
@@ -1,4 +1,7 @@
 /*
+ * Advanced  Micro Devices Inc. AMD8111E Linux Network Driver 
+ * Copyright (C) 2003 Advanced Micro Devices 
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
@@ -27,73 +30,14 @@
 	Kernel Mode
 
 Revision History:
-
+ 	3.0.0
+	   Initial Revision.
+	3.0.1
 */
 
 #ifndef _AMD811E_H
 #define _AMD811E_H
 
-/* Hardware definitions */
-
-#define B31_MASK	0x80000000
-#define B30_MASK	0X40000000
-#define B29_MASK	0x20000000
-#define B28_MASK	0x10000000
-#define B27_MASK	0x08000000
-#define B26_MASK	0x04000000
-#define B25_MASK	0x02000000
-#define B24_MASK	0x01000000
-#define B23_MASK	0x00800000
-#define B22_MASK	0x00400000
-#define B21_MASK	0x00200000
-#define B20_MASK	0x00100000
-#define B19_MASK	0x00080000
-#define B18_MASK	0x00040000
-#define B17_MASK	0x00020000
-#define B16_MASK	0x00010000
-
-#define B15_MASK	0x8000
-#define B14_MASK	0x4000
-#define B13_MASK	0x2000
-#define B12_MASK	0x1000
-#define B11_MASK	0x0800
-#define B10_MASK	0x0400
-#define B9_MASK		0x0200
-#define B8_MASK		0x0100
-#define B7_MASK		0x0080
-#define B6_MASK		0x0040
-#define B5_MASK		0x0020
-#define B4_MASK		0x0010
-#define B3_MASK		0x0008
-#define B2_MASK		0x0004
-#define B1_MASK		0x0002
-#define B0_MASK		0x0001
-
-/* PCI register offset */
-#define PCI_ID_REG		0x00
-#define PCI_COMMAND_REG		0x04
-/* #define MEMEN_BIT		B1_MASK */
-/* #define IOEN_BIT		B0_MASK */
-#define PCI_REV_ID_REG		0x08
-#define PCI_MEM_BASE_REG	0x10
-/* #define MEMBASE_MASK		0xFFFFF000 */
-/* #define MEMBASE_SIZE		4096 */
-#define PCI_INTR_REG		0x3C
-#define PCI_STATUS_REG		0x06
-#define PCI_CAP_ID_REG_OFFSET	0x34
-#define PCI_PMC_REG_OFFSET	0x36
-#define PCI_PMCSR_REG_OFFSET	0x38
-
-/* #define NEW_CAP		0x0010  */
-#define PME_EN			0x0100
-
-#define PARTID_MASK		0xFFFFF000
-#define PARTID_START_BIT	12
-
-/* #define LANCE_DWIO_RESET_PORT	0x18
-#define LANCE_WIO_RESET_PORT	0x14 */
-#define MIB_OFFSET		0x28
-
 /* Command style register access
 
 Registers CMD0, CMD2, CMD3,CMD7 and INTEN0 uses a write access technique called command style access. It allows the write to selected bits of this register without altering the bits that are not selected. Command style registers are divided into 4 bytes that can be written independently. Higher order bit of each byte is the  value bit that specifies the value that will be written into the selected bits of register. 
@@ -155,7 +99,7 @@
 #define XMT_RING_LEN2		0x148 	/* Transmit Ring2 length register */
 #define XMT_RING_LEN3		0x14C	/* Transmit Ring3 length register */
 
-#define RCV_RING_LEN0		0x150	/* Transmit Ring0 length register */
+#define RCV_RING_LEN0		0x150	/* Receive Ring0 length register */
 
 #define SRAM_SIZE		0x178	/* SRAM size register */
 #define SRAM_BOUNDARY		0x17A	/* SRAM boundary register */
@@ -164,391 +108,398 @@
 
 #define PADR			0x160	/* Physical address register */
 
+#define IFS1			0x18C	/* Inter-frame spacing Part1 register */
+#define IFS			0x18D	/* Inter-frame spacing register */
+#define IPG			0x18E	/* Inter-frame gap register */
 /* 64bit register */
 
 #define LADRF			0x168	/* Logical address filter register */
 
-/* 8bit regsisters */
-
-#define IFS1			0x18C	/* Inter-frame spacing Part1 register */
-#define IFS			0x18D	/* Inter-frame spacing register */
 
 /* Register Bit Definitions */
+typedef enum {
+
+	ASF_INIT_DONE		= (1 << 1),
+	ASF_INIT_PRESENT	= (1 << 0),
+
+}STAT_ASF_BITS; 
+   
+typedef enum {
+
+	MIB_CMD_ACTIVE		= (1 << 15 ),
+	MIB_RD_CMD		= (1 << 13 ),
+	MIB_CLEAR		= (1 << 12 ),
+	MIB_ADDRESS		= (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)|
+					(1 << 4) | (1 << 5),
+}MIB_ADDR_BITS;
+
+
+typedef enum {
+	
+	PMAT_DET		= (1 << 12),
+	MP_DET		        = (1 << 11),
+	LC_DET			= (1 << 10),
+	SPEED_MASK		= (1 << 9)|(1 << 8)|(1 << 7),
+	FULL_DPLX		= (1 << 6),
+	LINK_STATS		= (1 << 5),
+	AUTONEG_COMPLETE	= (1 << 4),
+	MIIPD			= (1 << 3),
+	RX_SUSPENDED		= (1 << 2),
+	TX_SUSPENDED		= (1 << 1),
+	RUNNING			= (1 << 0),
+
+}STAT0_BITS;
 
-/* STAT_ASF			0x00, 32bit register */
-#define ASF_INIT_DONE		B1_MASK
-#define ASF_INIT_PRESENT	B0_MASK
-
-/* MIB_ADDR			0x14, 16bit register */
-#define	MIB_CMD_ACTIVE		B15_MASK
-#define	MIB_RD_CMD		B13_MASK
-#define	MIB_CLEAR		B12_MASK
-#define	MIB_ADDRESS		0x0000003F	/* 5:0 */
-
-/* QOS_ADDR			0x1C, 16bit register */
-#define QOS_CMD_ACTIVE		B15_MASK
-#define QOS_WR_CMD		B14_MASK
-#define QOS_RD_CMD		B13_MASK
-#define QOS_ADDRESS		0x0000001F	/* 4:0 */
-
-/* STAT0			0x30, 32bit register */
-#define PAUSE_PEND		B14_MASK
-#define PAUSING			B13_MASK
-#define PMAT_DET		B12_MASK
-#define MP_DET			B11_MASK
-#define LC_DET			B10_MASK
-#define SPEED_MASK		0x0380	/* 9:7 */
-#define FULL_DPLX		B6_MASK
-#define LINK_STATS		B5_MASK
-#define AUTONEG_COMPLETE	B4_MASK
-#define MIIPD			B3_MASK
-#define RX_SUSPENDED		B2_MASK
-#define TX_SUSPENDED		B1_MASK
-#define RUNNING			B0_MASK
 #define PHY_SPEED_10		0x2
 #define PHY_SPEED_100		0x3
 
 /* INT0				0x38, 32bit register */
-#define INTR			B31_MASK
-#define PCSINT			B28_MASK
-#define LCINT			B27_MASK
-#define APINT5			B26_MASK
-#define APINT4			B25_MASK
-#define APINT3			B24_MASK
-#define TINT_SUM		B23_MASK
-#define APINT2			B22_MASK
-#define APINT1			B21_MASK
-#define APINT0			B20_MASK
-#define MIIPDTINT		B19_MASK
-#define MCCIINT			B18_MASK
-#define MCCINT			B17_MASK
-#define MREINT			B16_MASK
-#define RINT_SUM		B15_MASK
-#define SPNDINT			B14_MASK
-#define MPINT			B13_MASK
-#define SINT			B12_MASK
-#define TINT3			B11_MASK
-#define TINT2			B10_MASK
-#define TINT1			B9_MASK
-#define TINT0			B8_MASK
-#define UINT			B7_MASK
-#define STINT			B4_MASK
-#define RINT3			B3_MASK
-#define RINT2			B2_MASK
-#define RINT1			B1_MASK
-#define RINT0			B0_MASK
-
-/* INTEN0			0x40, 32bit register */
-#define VAL3			B31_MASK   /* VAL bit for byte 3 */
-#define VAL2			B23_MASK   /* VAL bit for byte 2 */
-#define VAL1			B15_MASK   /* VAL bit for byte 1 */
-#define VAL0			B7_MASK    /* VAL bit for byte 0 */
-/* VAL3 */
-#define PSCINTEN		B28_MASK
-#define LCINTEN			B27_MASK
-#define APINT5EN		B26_MASK
-#define APINT4EN		B25_MASK
-#define APINT3EN		B24_MASK
-/* VAL2 */
-#define APINT2EN		B22_MASK
-#define APINT1EN		B21_MASK
-#define APINT0EN		B20_MASK
-#define MIIPDTINTEN		B19_MASK
-#define MCCIINTEN		B18_MASK
-#define MCCINTEN		B17_MASK
-#define MREINTEN		B16_MASK
-/* VAL1 */
-#define SPNDINTEN		B14_MASK
-#define MPINTEN			B13_MASK
-#define SINTEN			B12_MASK
-#define TINTEN3			B11_MASK
-#define TINTEN2			B10_MASK
-#define TINTEN1			B9_MASK
-#define TINTEN0			B8_MASK
-/* VAL0 */
-#define STINTEN			B4_MASK
-#define RINTEN3			B3_MASK
-#define RINTEN2			B2_MASK
-#define RINTEN1			B1_MASK
-#define RINTEN0			B0_MASK
-
-#define INTEN0_CLEAR 		0x1F7F7F1F /* Command style register */		
-
-/* CMD0				0x48, 32bit register */
-/* VAL2 */
-#define RDMD3			B19_MASK
-#define RDMD2			B18_MASK
-#define RDMD1			B17_MASK
-#define RDMD0			B16_MASK
-/* VAL1 */
-#define TDMD3			B11_MASK
-#define TDMD2			B10_MASK
-#define TDMD1			B9_MASK
-#define TDMD0			B8_MASK
-/* VAL0 */
-#define UINTCMD			B6_MASK
-#define RX_FAST_SPND		B5_MASK
-#define TX_FAST_SPND		B4_MASK
-#define RX_SPND			B3_MASK
-#define TX_SPND			B2_MASK
-#define INTREN			B1_MASK
-#define RUN			B0_MASK
-
-#define CMD0_CLEAR 		0x000F0F7F   /* Command style register */	
-
-/* CMD2 			0x50, 32bit register */
-/* VAL3 */
-#define CONDUIT_MODE		B29_MASK
-/* VAL2 */
-#define RPA			B19_MASK
-#define DRCVPA			B18_MASK
-#define DRCVBC			B17_MASK
-#define PROM			B16_MASK
-/* VAL1 */
-#define ASTRP_RCV		B13_MASK
-#define FCOLL			B12_MASK
-#define EMBA			B11_MASK
-#define DXMT2PD			B10_MASK
-#define LTINTEN			B9_MASK
-#define DXMTFCS			B8_MASK
-/* VAL0 */
-#define APAD_XMT		B6_MASK
-#define DRTY			B5_MASK
-#define INLOOP			B4_MASK
-#define EXLOOP			B3_MASK
-#define REX_RTRY		B2_MASK
-#define REX_UFLO		B1_MASK
-#define REX_LCOL		B0_MASK
-
-#define CMD2_CLEAR 		0x3F7F3F7F   /* Command style register */
-
-/* CMD3				0x54, 32bit register */
-/* VAL3 */
-#define ASF_INIT_DONE_ALIAS	B29_MASK
-/* VAL2 */
-#define JUMBO			B21_MASK
-#define VSIZE			B20_MASK
-#define VLONLY			B19_MASK
-#define VL_TAG_DEL		B18_MASK
-/* VAL1 */
-#define EN_PMGR			B14_MASK
-#define INTLEVEL		B13_MASK
-#define FORCE_FULL_DUPLEX	B12_MASK
-#define FORCE_LINK_STATUS	B11_MASK
-#define APEP			B10_MASK
-#define MPPLBA			B9_MASK
-/* VAL0 */
-#define RESET_PHY_PULSE		B2_MASK
-#define RESET_PHY		B1_MASK
-#define PHY_RST_POL		B0_MASK
-/* CMD7				0x64, 32bit register */
-/* VAL0 */
-#define PMAT_SAVE_MATCH		B4_MASK
-#define PMAT_MODE		B3_MASK
-#define MPEN_SW			B1_MASK
-#define LCMODE_SW		B0_MASK
-
-#define CMD7_CLEAR  		0x0000001B		/* Command style register */
-/* CTRL0			0x68, 32bit register */
-#define PHY_SEL			0x03000000	/* 25:24 */
-#define RESET_PHY_WIDTH		0x00FF0000	/* 23:16 */
-#define BSWP_REGS		B10_MASK
-#define BSWP_DESC		B9_MASK
-#define BSWP_DATA		B8_MASK
-#define CACHE_ALIGN		B4_MASK
-#define BURST_LIMIT		0x0000000F	/* 3:0 */
-
-/* CTRL1			0x6C, 32bit register */
-#define SLOTMOD_MASK		0x03000000	/* 25:24 */
-#define XMTSP_MASK		0x300	/* 17:16 */
-#define XMTSP_128		0x200
-#define XMTSP_64		0x100
-#define CRTL1_DEFAULT		0x00000017
-
-/* CTRL2			0x70, 32bit register */
-#define FS_MASK			0x00070000	/* 18:16 */
-#define FMDC_MASK		0x00000300	/* 9:8 */
-#define XPHYRST			B7_MASK
-#define XPHYANE			B6_MASK
-#define XPHYFD			B5_MASK
-#define XPHYSP			B3_MASK	/* 4:3 */
-#define APDW_MASK		0x00000007	/* 2:0 */
-
-/* RCV_RING_CFG			0x78, 16bit register */
-#define RCV_DROP3		B11_MASK
-#define RCV_DROP2		B10_MASK
-#define RCV_DROP1		B9_MASK
-#define RCV_DROP0		B8_MASK
-#define RCV_RING_DEFAULT	0x0030	/* 5:4 */
-#define RCV_RING3_EN		B3_MASK
-#define RCV_RING2_EN		B2_MASK
-#define RCV_RING1_EN		B1_MASK
-#define RCV_RING0_EN		B0_MASK
+typedef enum {
+
+	INTR			= (1 << 31),
+	PCSINT			= (1 << 28), 
+	LCINT			= (1 << 27),
+	APINT5			= (1 << 26),
+	APINT4			= (1 << 25),
+	APINT3			= (1 << 24),
+	TINT_SUM		= (1 << 23),
+	APINT2			= (1 << 22),
+	APINT1			= (1 << 21),
+	APINT0			= (1 << 20),
+	MIIPDTINT		= (1 << 19),
+	MCCINT			= (1 << 17),
+	MREINT			= (1 << 16),
+	RINT_SUM		= (1 << 15),
+	SPNDINT			= (1 << 14),
+	MPINT			= (1 << 13),
+	SINT			= (1 << 12),
+	TINT3			= (1 << 11),
+	TINT2			= (1 << 10),
+	TINT1			= (1 << 9),
+	TINT0			= (1 << 8),
+	UINT			= (1 << 7),
+	STINT			= (1 << 4),
+	RINT0			= (1 << 0),
+
+}INT0_BITS;
+
+typedef enum {
+
+	VAL3			= (1 << 31),   /* VAL bit for byte 3 */
+	VAL2			= (1 << 23),   /* VAL bit for byte 2 */
+	VAL1			= (1 << 15),   /* VAL bit for byte 1 */
+	VAL0			= (1 << 7),    /* VAL bit for byte 0 */
+
+}VAL_BITS;
+
+typedef enum {
+
+	/* VAL3 */
+	LCINTEN			= (1 << 27),
+	APINT5EN		= (1 << 26),
+	APINT4EN		= (1 << 25),
+	APINT3EN		= (1 << 24),
+	/* VAL2 */
+	APINT2EN		= (1 << 22),
+	APINT1EN		= (1 << 21),
+	APINT0EN		= (1 << 20),
+	MIIPDTINTEN		= (1 << 19),
+	MCCIINTEN		= (1 << 18),
+	MCCINTEN		= (1 << 17),
+	MREINTEN		= (1 << 16),
+	/* VAL1 */
+	SPNDINTEN		= (1 << 14),
+	MPINTEN			= (1 << 13),
+	TINTEN3			= (1 << 11),
+	SINTEN			= (1 << 12),
+	TINTEN2			= (1 << 10),
+	TINTEN1			= (1 << 9),
+	TINTEN0			= (1 << 8),
+	/* VAL0 */
+	STINTEN			= (1 << 4),
+	RINTEN0			= (1 << 0),
+
+	INTEN0_CLEAR 		= 0x1F7F7F1F, /* Command style register */
+
+}INTEN0_BITS;		
+
+typedef enum {
+	/* VAL2 */
+	RDMD0			= (1 << 16),
+	/* VAL1 */
+	TDMD3			= (1 << 11),
+	TDMD2			= (1 << 10),
+	TDMD1			= (1 << 9),
+	TDMD0			= (1 << 8),
+	/* VAL0 */
+	UINTCMD			= (1 << 6),
+	RX_FAST_SPND		= (1 << 5),
+	TX_FAST_SPND		= (1 << 4),
+	RX_SPND			= (1 << 3),
+	TX_SPND			= (1 << 2),
+	INTREN			= (1 << 1),
+	RUN			= (1 << 0),
+
+	CMD0_CLEAR 		= 0x000F0F7F,   /* Command style register */	
+
+}CMD0_BITS;
+
+typedef enum {
+
+	/* VAL3 */
+	CONDUIT_MODE		= (1 << 29),
+	/* VAL2 */
+	RPA			= (1 << 19),
+	DRCVPA			= (1 << 18),
+	DRCVBC			= (1 << 17),
+	PROM			= (1 << 16),
+	/* VAL1 */
+	ASTRP_RCV		= (1 << 13),
+	RCV_DROP0	  	= (1 << 12),
+	EMBA			= (1 << 11),
+	DXMT2PD			= (1 << 10),
+	LTINTEN			= (1 << 9),
+	DXMTFCS			= (1 << 8),
+	/* VAL0 */
+	APAD_XMT		= (1 << 6),
+	DRTY			= (1 << 5),
+	INLOOP			= (1 << 4),
+	EXLOOP			= (1 << 3),
+	REX_RTRY		= (1 << 2),
+	REX_UFLO		= (1 << 1),
+	REX_LCOL		= (1 << 0),
+
+	CMD2_CLEAR 		= 0x3F7F3F7F,   /* Command style register */
+
+}CMD2_BITS;
+
+typedef enum {
+
+	/* VAL3 */
+	ASF_INIT_DONE_ALIAS	= (1 << 29),
+	/* VAL2 */
+	JUMBO			= (1 << 21),
+	VSIZE			= (1 << 20),	
+	VLONLY			= (1 << 19),
+	VL_TAG_DEL		= (1 << 18),	
+	/* VAL1 */
+	EN_PMGR			= (1 << 14),			
+	INTLEVEL		= (1 << 13),
+	FORCE_FULL_DUPLEX	= (1 << 12),	
+	FORCE_LINK_STATUS	= (1 << 11),	
+	APEP			= (1 << 10),	
+	MPPLBA			= (1 << 9),	
+	/* VAL0 */
+	RESET_PHY_PULSE		= (1 << 2),	
+	RESET_PHY		= (1 << 1),	
+	PHY_RST_POL		= (1 << 0),	
+
+}CMD3_BITS;
+
+
+typedef enum {
+
+	/* VAL0 */
+	PMAT_SAVE_MATCH		= (1 << 4),
+	PMAT_MODE		= (1 << 3),
+	MPEN_SW			= (1 << 1),
+	LCMODE_SW		= (1 << 0),
+
+	CMD7_CLEAR  		= 0x0000001B	/* Command style register */
+
+}CMD7_BITS;
+
+
+typedef enum {
+
+	RESET_PHY_WIDTH		= (0xF << 16) | (0xF<< 20), /* 0x00FF0000 */
+	XMTSP_MASK		= (1 << 9) | (1 << 8),	/* 9:8 */
+	XMTSP_128		= (1 << 9),	/* 9 */	
+	XMTSP_64		= (1 << 8),
+	CACHE_ALIGN		= (1 << 4),
+	BURST_LIMIT_MASK	= (0xF << 0 ),
+	CTRL1_DEFAULT		= 0x00010111,
+
+}CTRL1_BITS;
+
+typedef enum {
+
+	FMDC_MASK		= (1 << 9)|(1 << 8),	/* 9:8 */
+	XPHYRST			= (1 << 7),
+	XPHYANE			= (1 << 6),
+	XPHYFD			= (1 << 5),
+	XPHYSP			= (1 << 4) | (1 << 3),	/* 4:3 */
+	APDW_MASK		= (1 <<	2) | (1 << 1) | (1 << 0), /* 2:0 */
+
+}CTRL2_BITS;
 
 /* XMT_RING_LIMIT		0x7C, 32bit register */
-#define XMT_RING2_LIMIT		0x00FF0000	/* 23:16 */
-#define XMT_RING1_LIMIT		0x0000FF00	/* 15:8 */
-#define XMT_RING0_LIMIT		0x000000FF	/* 7:0 */
-
-/* AUTOPOLL0			0x88, 16bit register */
-#define AP_REG0_EN		B15_MASK
-#define AP_REG0_ADDR_MASK	0x1F00	/* 12:8 */
-#define AP_PHY0_ADDR_MASK	0x001F	/* 4:0 */
+typedef enum {
+
+	XMT_RING2_LIMIT		= (0xFF << 16),	/* 23:16 */
+	XMT_RING1_LIMIT		= (0xFF << 8),	/* 15:8 */
+	XMT_RING0_LIMIT		= (0xFF << 0), 	/* 7:0 */
+
+}XMT_RING_LIMIT_BITS;
+
+typedef enum {
+
+	AP_REG0_EN		= (1 << 15),
+	AP_REG0_ADDR_MASK	= (0xF << 8) |(1 << 12),/* 12:8 */
+	AP_PHY0_ADDR_MASK	= (0xF << 0) |(1 << 4),/* 4:0 */
+
+}AUTOPOLL0_BITS;
 
 /* AUTOPOLL1			0x8A, 16bit register */
-#define AP_REG1_EN		B15_MASK
-#define AP_REG1_ADDR_MASK	0x1F00	/* 12:8 */
-#define AP_PRE_SUP1		B6_MASK
-#define AP_PHY1_DFLT		B5_MASK
-#define AP_PHY1_ADDR_MASK	0x001F	/* 4:0 */
-
-/* AUTOPOLL2			0x8C, 16bit register */
-#define AP_REG2_EN		B15_MASK
-#define AP_REG2_ADDR_MASK	0x1F00	/* 12:8 */
-#define AP_PRE_SUP2		B6_MASK
-#define AP_PHY2_DFLT		B5_MASK
-#define AP_PHY2_ADDR_MASK	0x001F	/* 4:0 */
-
-/* AUTOPOLL3			0x8E, 16bit register */
-#define AP_REG3_EN		B15_MASK
-#define AP_REG3_ADDR_MASK	0x1F00	/* 12:8 */
-#define AP_PRE_SUP3		B6_MASK
-#define AP_PHY3_DFLT		B5_MASK
-#define AP_PHY3_ADDR_MASK	0x001F	/* 4:0 */
-
-/* AUTOPOLL4			0x90, 16bit register */
-#define AP_REG4_EN		B15_MASK
-#define AP_REG4_ADDR_MASK	0x1F00	/* 12:8 */
-#define AP_PRE_SUP4		B6_MASK
-#define AP_PHY4_DFLT		B5_MASK
-#define AP_PHY4_ADDR_MASK	0x001F	/* 4:0 */
-
-/* AUTOPOLL5			0x92, 16bit register */
-#define AP_REG5_EN		B15_MASK
-#define AP_REG5_ADDR_MASK	0x1F00	/* 12:8 */
-#define AP_PRE_SUP5		B6_MASK
-#define AP_PHY5_DFLT		B5_MASK
-#define AP_PHY5_ADDR_MASK	0x001F	/* 4:0 */
+typedef enum {
+
+	AP_REG1_EN		= (1 << 15),
+	AP_REG1_ADDR_MASK	= (0xF << 8) |(1 << 12),/* 12:8 */
+	AP_PRE_SUP1		= (1 << 6),
+	AP_PHY1_DFLT		= (1 << 5),
+	AP_PHY1_ADDR_MASK	= (0xF << 0) |(1 << 4),/* 4:0 */
+
+}AUTOPOLL1_BITS;
+
+
+typedef enum {
+
+	AP_REG2_EN		= (1 << 15),
+	AP_REG2_ADDR_MASK	= (0xF << 8) |(1 << 12),/* 12:8 */
+	AP_PRE_SUP2		= (1 << 6),
+	AP_PHY2_DFLT		= (1 << 5),
+	AP_PHY2_ADDR_MASK	= (0xF << 0) |(1 << 4),/* 4:0 */
+
+}AUTOPOLL2_BITS;
+
+typedef enum {
+
+	AP_REG3_EN		= (1 << 15),
+	AP_REG3_ADDR_MASK	= (0xF << 8) |(1 << 12),/* 12:8 */
+	AP_PRE_SUP3		= (1 << 6),
+	AP_PHY3_DFLT		= (1 << 5),
+	AP_PHY3_ADDR_MASK	= (0xF << 0) |(1 << 4),/* 4:0 */
+
+}AUTOPOLL3_BITS;
+
+
+typedef enum {
+
+	AP_REG4_EN		= (1 << 15),
+	AP_REG4_ADDR_MASK	= (0xF << 8) |(1 << 12),/* 12:8 */
+	AP_PRE_SUP4		= (1 << 6),
+	AP_PHY4_DFLT		= (1 << 5),
+	AP_PHY4_ADDR_MASK	= (0xF << 0) |(1 << 4),/* 4:0 */
+
+}AUTOPOLL4_BITS;
+
+
+typedef enum {
+
+	AP_REG5_EN		= (1 << 15),
+	AP_REG5_ADDR_MASK	= (0xF << 8) |(1 << 12),/* 12:8 */
+	AP_PRE_SUP5		= (1 << 6),
+	AP_PHY5_DFLT		= (1 << 5),
+	AP_PHY5_ADDR_MASK	= (0xF << 0) |(1 << 4),/* 4:0 */
+
+}AUTOPOLL5_BITS;
+
+
+
 
 /* AP_VALUE 			0x98, 32bit ragister */
-#define AP_VAL_ACTIVE		B31_MASK
-#define AP_VAL_RD_CMD		B29_MASK
-#define AP_ADDR			0x00070000	/* 18:16 */
-#define AP_VAL			0x0000FFFF	/* 15:0 */
-
-/* PCS_ANEG			0x9C, 32bit register */
-#define SYNC_LOST		B10_MASK
-#define IMATCH			B9_MASK
-#define CMATCH			B8_MASK
-#define PCS_AN_IDLE		B1_MASK
-#define PCS_AN_CFG		B0_MASK
-
-/* DLY_INT_A			0xA8, 32bit register */
-#define DLY_INT_A_R3		B31_MASK
-#define DLY_INT_A_R2		B30_MASK
-#define DLY_INT_A_R1		B29_MASK
-#define DLY_INT_A_R0		B28_MASK
-#define DLY_INT_A_T3		B27_MASK
-#define DLY_INT_A_T2		B26_MASK
-#define DLY_INT_A_T1		B25_MASK
-#define DLY_INT_A_T0		B24_MASK
-#define EVENT_COUNT_A		0x00FF0000	/* 20:16 */
-#define MAX_DELAY_TIME_A	0x000007FF	/* 10:0 */
-
-/* DLY_INT_B			0xAC, 32bit register */
-#define DLY_INT_B_R3		B31_MASK
-#define DLY_INT_B_R2		B30_MASK
-#define DLY_INT_B_R1		B29_MASK
-#define DLY_INT_B_R0		B28_MASK
-#define DLY_INT_B_T3		B27_MASK
-#define DLY_INT_B_T2		B26_MASK
-#define DLY_INT_B_T1		B25_MASK
-#define DLY_INT_B_T0		B24_MASK
-#define EVENT_COUNT_B		0x00FF0000	/* 20:16 */
-#define MAX_DELAY_TIME_B	0x000007FF	/* 10:0 */
-
-/* DFC_THRESH2			0xC0, 16bit register */
-#define DFC_THRESH2_HIGH	0xFF00	/* 15:8 */
-#define DFC_THRESH2_LOW		0x00FF	/* 7:0 */
-
-/* DFC_THRESH3			0xC2, 16bit register */
-#define DFC_THRESH3_HIGH	0xFF00	/* 15:8 */
-#define DFC_THRESH3_LOW		0x00FF	/* 7:0 */
-
-/* DFC_THRESH0			0xC4, 16bit register */
-#define DFC_THRESH0_HIGH	0xFF00	/* 15:8 */
-#define DFC_THRESH0_LOW		0x00FF	/* 7:0 */
-
-/* DFC_THRESH1			0xC6, 16bit register */
-#define DFC_THRESH1_HIGH	0xFF00	/* 15:8 */
-#define DFC_THRESH1_LOW		0x00FF	/* 7:0 */
+typedef enum {
+
+	AP_VAL_ACTIVE		= (1 << 31),
+	AP_VAL_RD_CMD		= ( 1 << 29),
+	AP_ADDR			= (1 << 18)|(1 << 17)|(1 << 16), /* 18:16 */
+	AP_VAL			= (0xF << 0) | (0xF << 4) |( 0xF << 8) |
+				  (0xF << 12),	/* 15:0 */
+
+}AP_VALUE_BITS;
+
+typedef enum {
+
+	DLY_INT_A_R3		= (1 << 31),
+	DLY_INT_A_R2		= (1 << 30),
+	DLY_INT_A_R1		= (1 << 29),
+	DLY_INT_A_R0		= (1 << 28),
+	DLY_INT_A_T3		= (1 << 27),
+	DLY_INT_A_T2		= (1 << 26),
+	DLY_INT_A_T1		= (1 << 25),
+	DLY_INT_A_T0		= ( 1 << 24),
+	EVENT_COUNT_A		= (0xF << 16) | (0x1 << 20),/* 20:16 */
+	MAX_DELAY_TIME_A	= (0xF << 0) | (0xF << 4) | (1 << 8)|
+				  (1 << 9) | (1 << 10),	/* 10:0 */
+
+}DLY_INT_A_BITS;
+
+typedef enum {
+
+	DLY_INT_B_R3		= (1 << 31),
+	DLY_INT_B_R2		= (1 << 30),
+	DLY_INT_B_R1		= (1 << 29),
+	DLY_INT_B_R0		= (1 << 28),
+	DLY_INT_B_T3		= (1 << 27),
+	DLY_INT_B_T2		= (1 << 26),
+	DLY_INT_B_T1		= (1 << 25),
+	DLY_INT_B_T0		= ( 1 << 24),
+	EVENT_COUNT_B		= (0xF << 16) | (0x1 << 20),/* 20:16 */
+	MAX_DELAY_TIME_B	= (0xF << 0) | (0xF << 4) | (1 << 8)| 
+				  (1 << 9) | (1 << 10),	/* 10:0 */
+}DLY_INT_B_BITS;
+
 
 /* FLOW_CONTROL 		0xC8, 32bit register */
-#define PAUSE_LEN_CHG		B30_MASK
-#define	FFC_EN			B28_MASK
-#define DFC_RING3_EN		B27_MASK
-#define DFC_RING2_EN		B26_MASK
-#define DFC_RING1_EN		B25_MASK
-#define DFC_RING0_EN		B24_MASK
-#define FIXP_CONGEST		B21_MASK
-#define FPA			B20_MASK
-#define NPA			B19_MASK
-#define FIXP			B18_MASK
-#define FCPEN			B17_MASK
-#define FCCMD			B16_MASK
-#define PAUSE_LEN		0x0000FFFF	/* 15:0 */
-
-/* FFC THRESH			0xCC, 32bit register */
-#define FFC_HIGH		0xFFFF0000	/* 31:16 */
-#define FFC_LOW			0x0000FFFF	/* 15:0 */
+typedef enum {
+
+	PAUSE_LEN_CHG		= (1 << 30),
+	FTPE			= (1 << 22),
+	FRPE			= (1 << 21),
+	NAPA			= (1 << 20),
+	NPA			= (1 << 19),
+	FIXP			= ( 1 << 18),
+	FCCMD			= ( 1 << 16),
+	PAUSE_LEN		= (0xF << 0) | (0xF << 4) |( 0xF << 8) |	 				  (0xF << 12),	/* 15:0 */
+
+}FLOW_CONTROL_BITS;
 
 /* PHY_ ACCESS			0xD0, 32bit register */
-#define	PHY_CMD_ACTIVE		B31_MASK
-#define PHY_WR_CMD		B30_MASK
-#define PHY_RD_CMD		B29_MASK
-#define PHY_RD_ERR		B28_MASK
-#define PHY_PRE_SUP		B27_MASK
-#define PHY_ADDR		0x03E00000	/* 25:21 */
-#define PHY_REG_ADDR		0x001F0000	/* 20:16 */
-#define PHY_DATA		0x0000FFFF	/* 15:0 */
-
-/* LED0..3			0xE0..0xE6, 16bit register */
-#define LEDOUT			B15_MASK
-#define LEDPOL			B14_MASK
-#define LEDDIS			B13_MASK
-#define LEDSTRETCH		B12_MASK
-#define LED1000			B8_MASK
-#define LED100			B7_MASK
-#define LEDMP			B6_MASK
-#define LEDFD			B5_MASK
-#define LEDLINK			B4_MASK
-#define LEDRCVMAT		B3_MASK
-#define LEDXMT			B2_MASK
-#define LEDRCV			B1_MASK
-#define LEDCOLOUT		B0_MASK
-
-/* EEPROM_ACC			0x17C, 16bit register */
-#define PVALID			B15_MASK
-#define PREAD			B14_MASK
-#define EEDET			B13_MASK
-#define	EEN			B4_MASK
-#define ECS			B2_MASK
-#define EESK			B1_MASK
-#define edi_edo			b0_MASK
+typedef enum {
+
+	PHY_CMD_ACTIVE		= (1 << 31),
+	PHY_WR_CMD		= (1 << 30),
+	PHY_RD_CMD		= (1 << 29),
+	PHY_RD_ERR		= (1 << 28),
+	PHY_PRE_SUP		= (1 << 27),
+	PHY_ADDR		= (1 << 21) | (1 << 22) | (1 << 23)|
+				  	(1 << 24) |(1 << 25),/* 25:21 */
+	PHY_REG_ADDR		= (1 << 16) | (1 << 17) | (1 << 18)|	 			  	   	  	(1 << 19) | (1 << 20),/* 20:16 */
+	PHY_DATA		= (0xF << 0)|(0xF << 4) |(0xF << 8)|
+					(0xF << 12),/* 15:0 */
+
+}PHY_ACCESS_BITS;
+
 
 /* PMAT0			0x190,	 32bit register */
-#define PMR_ACTIVE		B31_MASK
-#define PMR_WR_CMD		B30_MASK
-#define PMR_RD_CMD		B29_MASK
-#define PMR_BANK		B28_MASK
-#define PMR_ADDR		0x007F0000	/* 22:16 */
-#define PMR_B4			0x000000FF	/* 15:0 */
+typedef enum {
+	PMR_ACTIVE		= (1 << 31),
+	PMR_WR_CMD		= (1 << 30),
+	PMR_RD_CMD		= (1 << 29),
+	PMR_BANK		= (1 <<28),
+	PMR_ADDR		= (0xF << 16)|(1 << 20)|(1 << 21)|
+				  	(1 << 22),/* 22:16 */
+	PMR_B4			= (0xF << 0) | (0xF << 4),/* 15:0 */
+}PMAT0_BITS;
+
 
 /* PMAT1			0x194,	 32bit register */
-#define PMR_B3			0xFF000000	/* 31:24 */
-#define PMR_B2			0x00FF0000	/* 23:16 */
-#define PMR_B1			0x0000FF00	/* 15:8 */
-#define PMR_B0			0x000000FF	/* 7:0 */
+typedef enum {
+	PMR_B3			= (0xF << 24) | (0xF <<28),/* 31:24 */
+	PMR_B2			= (0xF << 16) |(0xF << 20),/* 23:16 */
+	PMR_B1			= (0xF << 8) | (0xF <<12), /* 15:8 */
+	PMR_B0			= (0xF << 0)|(0xF << 4),/* 7:0 */
+}PMAT1_BITS;
 
 /************************************************************************/
 /*                                                                      */
@@ -615,7 +566,7 @@
 #define	 PCI_VENDOR_ID_AMD		0x1022
 #define  PCI_DEVICE_ID_AMD8111E_7462	0x7462
 
-#define MAX_UNITS			16 /* Maximum number of devices possible */
+#define MAX_UNITS			8 /* Maximum number of devices possible */
 
 #define NUM_TX_BUFFERS			32 /* Number of transmit buffers */
 #define NUM_RX_BUFFERS			32 /* Number of receive buffers */	
@@ -637,45 +588,73 @@
 #define MIN_PKT_LEN			60
 #define ETH_ADDR_LEN			6
 
+#define  AMD8111E_TX_TIMEOUT		(3 * HZ)/* 3 sec */
+#define SOFT_TIMER_FREQ 		0xBEBC  /* 0.5 sec */
+#define DELAY_TIMER_CONV		50    /* msec to 10 usec conversion.
+						 Only 500 usec resolution */ 						 
 #define OPTION_VLAN_ENABLE		0x0001
 #define OPTION_JUMBO_ENABLE		0x0002
 #define OPTION_MULTICAST_ENABLE		0x0004
 #define OPTION_WOL_ENABLE		0x0008
 #define OPTION_WAKE_MAGIC_ENABLE	0x0010
 #define OPTION_WAKE_PHY_ENABLE		0x0020
+#define OPTION_INTR_COAL_ENABLE		0x0040
+#define OPTION_DYN_IPG_ENABLE	        0x0080
 
 #define PHY_REG_ADDR_MASK		0x1f
 
+/* ipg parameters */
+#define DEFAULT_IPG			0x60
+#define IFS1_DELTA			36
+#define	IPG_CONVERGE_TIME 0.5
+#define	IPG_STABLE_TIME	5
+#define	MIN_IPG	96
+#define	MAX_IPG	255
+#define IPG_STEP	16
+#define CSTATE  1 
+#define SSTATE  2 
+
 /* Assume contoller gets data 10 times the maximum processing time */
 #define  REPEAT_CNT			10; 
      
 /* amd8111e decriptor flag definitions */
+typedef enum {
 
-#define OWN_BIT			B15_MASK
-#define ADD_FCS_BIT		B13_MASK
-#define LTINT_BIT		B12_MASK
-#define STP_BIT			B9_MASK
-#define ENP_BIT			B8_MASK
-#define KILL_BIT		B6_MASK
-#define TCC_MASK		0x0003
-#define TCC_VLAN_INSERT		B1_MASK
-#define TCC_VLAN_REPLACE	0x0003
-#define RESET_RX_FLAGS		0x0000
+	OWN_BIT		=	(1 << 15),
+	ADD_FCS_BIT	=	(1 << 13),
+	LTINT_BIT	=	(1 << 12),
+	STP_BIT		=	(1 << 9),
+	ENP_BIT		=	(1 << 8),
+	KILL_BIT	= 	(1 << 6),
+	TCC_VLAN_INSERT	=	(1 << 1),
+	TCC_VLAN_REPLACE =	(1 << 1) |( 1<< 0),
+
+}TX_FLAG_BITS;
+
+typedef enum {
+	ERR_BIT 	=	(1 << 14),
+	FRAM_BIT	=  	(1 << 13),
+	OFLO_BIT	=       (1 << 12),
+	CRC_BIT		=	(1 << 11),
+	PAM_BIT		=	(1 << 6),
+	LAFM_BIT	= 	(1 << 5),
+	BAM_BIT		=	(1 << 4),
+	TT_VLAN_TAGGED	= 	(1 << 3) |(1 << 2),/* 0x000 */
+	TT_PRTY_TAGGED	=	(1 << 3),/* 0x0008 */
+
+}RX_FLAG_BITS;
 
-#define ERR_BIT 		B14_MASK
-#define FRAM_BIT		B13_MASK
-#define OFLO_BIT		B12_MASK
-#define CRC_BIT			B11_MASK
-#define PAM_BIT			B6_MASK
-#define LAFM_BIT		B5_MASK
-#define BAM_BIT			B4_MASK
+#define RESET_RX_FLAGS		0x0000
 #define TT_MASK			0x000c
-#define TT_VLAN_TAGGED		0x000c
-#define TT_PRTY_TAGGED		0x0008
+#define TCC_MASK		0x0003
 
 /* driver ioctl parameters */
 #define PHY_ID 			0x01	/* currently it is fixed */
-#define AMD8111E_REG_DUMP_LEN	4096	/* Memory mapped register length */
+#define AMD8111E_REG_DUMP_LEN	 13*sizeof(u32) 
+
+/* crc generator constants */
+#define CRC32 0xedb88320
+#define INITCRC 0xFFFFFFFF
 
 /* amd8111e desriptor format */
 
@@ -683,7 +662,7 @@
 
 	u16 buff_count; /* Size of the buffer pointed by this descriptor */
 
-	u16 tx_dr_offset2;
+	u16 tx_flags;
 
 	u16 tag_ctrl_info;
 
@@ -704,7 +683,7 @@
 
 	u16 buff_count;  /* Len of the buffer pointed by descriptor. */
 
-	u16 rx_dr_offset10;
+	u16 rx_flags;
 
 	u32 buff_phy_addr;
 
@@ -719,10 +698,58 @@
 	u16				speed;
 	u8				duplex;
 	u8				autoneg;
-	u16 				orig_speed;
-	u8				orig_duplex;
 	u8				reserved;  /* 32bit alignment */
 };
+
+enum coal_type{
+
+	NO_COALESCE,
+	LOW_COALESCE,
+	MEDIUM_COALESCE,
+	HIGH_COALESCE,
+
+};
+
+enum coal_mode{ 
+       	RX_INTR_COAL,
+	TX_INTR_COAL,
+	DISABLE_COAL,
+	ENABLE_COAL,
+
+};
+#define MAX_TIMEOUT	40
+#define MAX_EVENT_COUNT 31
+struct amd8111e_coalesce_conf{
+
+	unsigned int rx_timeout;
+	unsigned int rx_event_count;
+	unsigned long rx_packets;
+	unsigned long rx_prev_packets;
+	unsigned long rx_bytes;
+	unsigned long rx_prev_bytes;
+	unsigned int rx_coal_type;
+	
+	unsigned int tx_timeout;
+	unsigned int tx_event_count;
+	unsigned long tx_packets;
+	unsigned long tx_prev_packets;
+	unsigned long tx_bytes;
+	unsigned long tx_prev_bytes;
+	unsigned int tx_coal_type;
+
+};
+struct ipg_info{
+	
+	unsigned int ipg_state;
+	unsigned int ipg;
+	unsigned int current_ipg;
+	unsigned int col_cnt;
+	unsigned int diff_col_cnt;
+	unsigned int timer_tick;
+	unsigned int prev_ipg;
+	struct timer_list ipg_timer;
+};
+
 struct amd8111e_priv{
 	
 	struct amd8111e_tx_dr*  tx_ring;
@@ -742,45 +769,54 @@
 	void *  mmio;
 	
 	spinlock_t lock;	/* Guard lock */
-	unsigned long  rx_idx, tx_idx;	/* The next free ring entry */
-	unsigned long  tx_complete_idx;
+	unsigned long rx_idx, tx_idx;	/* The next free ring entry */
+	unsigned long tx_complete_idx;
 	unsigned long tx_ring_complete_idx;
 	unsigned long tx_ring_idx;
-	int rx_buff_len;	/* Buffer length of rx buffers */
+	unsigned int rx_buff_len;	/* Buffer length of rx buffers */
 	int options;		/* Options enabled/disabled for the device */
+
 	unsigned long ext_phy_option;
+	
 	struct amd8111e_link_config link_config;
 	int pm_cap;
+	u32 pm_state[12];
 
 	struct net_device *next;
+	int mii;
+	struct mii_if_info mii_if;
 #if AMD8111E_VLAN_TAG_USED
 	struct vlan_group		*vlgrp;
 #endif	
 	char opened;
 	struct net_device_stats stats;
-	struct net_device_stats prev_stats;
 	struct dev_mc_list* mc_list;
+	struct amd8111e_coalesce_conf coal_conf;
+
+	struct ipg_info  ipg_data;	
 	
 };
-#define AMD8111E_READ_REG64(_memMapBase, _offset, _pUlData)	\
-			*(u32*)(_pUlData) = readl(_memMapBase + (_offset));	\
-			*((u32*)(_pUlData))+1) = readl(_memMapBase + ((_offset)+4))
-
-#define AMD8111E_WRITE_REG64(_memMapBase, _offset, _pUlData)	\
-			writel(*(u32*)(_pUlData), _memMapBase + (_offset));	\
-			writel(*(u32*)((u8*)(_pUlData)+4), _memMapBase + ((_offset)+4))	\
+
+/* kernel provided writeq does not write 64 bits into the amd8111e device register instead writes only higher 32bits data into lower 32bits of the register.
+BUG? */
+#define  amd8111e_writeq(_UlData,_memMap)   \
+		writel(*(u32*)(&_UlData), _memMap);	\
+		writel(*(u32*)((u8*)(&_UlData)+4), _memMap+4)	
 
 /* maps the external speed options to internal value */
-static unsigned char speed_duplex_mapping[] = {
+typedef enum {
+	SPEED_AUTONEG,
+	SPEED10_HALF,
+	SPEED10_FULL,
+	SPEED100_HALF,
+	SPEED100_FULL,
+}EXT_PHY_OPTION;
 
-	XPHYANE,		/* Auto-negotiation, speed_duplex option 0 */
-	0,			/* 10M Half,  speed_duplex option 1 */
-	XPHYFD,			/* 10M Full,  speed_duplex option 2 */
-	XPHYSP,			/* 100M Half, speed_duplex option 3 */
-	XPHYFD | XPHYSP		/* 100M Full, speed_duplex option 4 */
-};
 static int card_idx;
 static int speed_duplex[MAX_UNITS] = { 0, };
+static int coalesce[MAX_UNITS] = {1,1,1,1,1,1,1,1};
+static int dynamic_ipg[MAX_UNITS] = {0,0,0,0,0,0,0,0};
+static unsigned int chip_version;
 
 #endif /* _AMD8111E_H */
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/apne.c linux-2.4.22-pre2/drivers/net/apne.c
--- linux-2.4.21/drivers/net/apne.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/apne.c	2003-06-26 21:43:33.000000000 +0000
@@ -285,6 +285,7 @@
     /* Allocate dev->priv and fill in 8390 specific dev fields. */
     if (ethdev_init(dev)) {
 	printk (" unable to get memory for dev->priv.\n");
+	free_irq(IRQ_AMIGA_PORTS, dev);
 	return -ENOMEM;
     }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/arcnet/arcnet.c linux-2.4.22-pre2/drivers/net/arcnet/arcnet.c
--- linux-2.4.21/drivers/net/arcnet/arcnet.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/arcnet/arcnet.c	2003-06-26 21:43:29.000000000 +0000
@@ -343,7 +343,7 @@
 	dev->hard_header_len = sizeof(struct archdr);
 	dev->mtu = choose_mtu();
 
-	dev->addr_len = 1;
+	dev->addr_len = ARCNET_ALEN;
 	dev->tx_queue_len = 30;
 	dev->broadcast[0] = 0x00;	/* for us, broadcasts are address 0 */
 	dev->watchdog_timeo = TX_TIMEOUT;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/arcnet/rfc1201.c linux-2.4.22-pre2/drivers/net/arcnet/rfc1201.c
--- linux-2.4.21/drivers/net/arcnet/rfc1201.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/arcnet/rfc1201.c	2003-06-26 21:43:20.000000000 +0000
@@ -56,6 +56,7 @@
 void __init arcnet_rfc1201_init(void)
 {
 	arc_proto_map[ARC_P_IP]
+	    = arc_proto_map[ARC_P_IPV6]
 	    = arc_proto_map[ARC_P_ARP]
 	    = arc_proto_map[ARC_P_RARP]
 	    = arc_proto_map[ARC_P_IPX]
@@ -114,6 +115,8 @@
 	switch (soft->proto) {
 	case ARC_P_IP:
 		return htons(ETH_P_IP);
+	case ARC_P_IPV6:
+		return htons(ETH_P_IPV6);
 	case ARC_P_ARP:
 		return htons(ETH_P_ARP);
 	case ARC_P_RARP:
@@ -388,6 +391,9 @@
 	case ETH_P_IP:
 		soft->proto = ARC_P_IP;
 		break;
+	case ETH_P_IPV6:
+		soft->proto = ARC_P_IPV6;
+		break;
 	case ETH_P_ARP:
 		soft->proto = ARC_P_ARP;
 		break;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/bonding/Makefile linux-2.4.22-pre2/drivers/net/bonding/Makefile
--- linux-2.4.21/drivers/net/bonding/Makefile	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/bonding/Makefile	2003-06-26 21:43:13.000000000 +0000
@@ -0,0 +1,14 @@
+#
+# Makefile for the Ethernet Bonding driver
+#
+
+O_TARGET := bonding.o
+
+obj-y	 := bond_main.o \
+            bond_3ad.o  \
+	    bond_alb.o
+
+obj-m	 := $(O_TARGET)
+
+include $(TOPDIR)/Rules.make
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/bonding/bond_3ad.c linux-2.4.22-pre2/drivers/net/bonding/bond_3ad.c
--- linux-2.4.21/drivers/net/bonding/bond_3ad.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/bonding/bond_3ad.c	2003-06-26 21:43:31.000000000 +0000
@@ -0,0 +1,2493 @@
+/*
+ * Copyright(c) 1999 - 2003 Intel 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 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.
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called LICENSE.
+ *
+ *
+ * Changes:
+ *
+ * 2003/05/01 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
+ *		Amir Noam <amir.noam at intel dot com>
+ *	- Added support for lacp_rate module param.
+ *
+ * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
+ *	- Based on discussion on mailing list, changed locking scheme
+ *	  to use lock/unlock or lock_bh/unlock_bh appropriately instead
+ *	  of lock_irqsave/unlock_irqrestore. The new scheme helps exposing
+ *	  hidden bugs and solves system hangs that occurred due to the fact
+ *	  that holding lock_irqsave doesn't prevent softirqs from running.
+ *	  This also increases total throughput since interrupts are not
+ *	  blocked on each transmitted packets or monitor timeout.
+ *
+ * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
+ *	- Renamed bond_3ad_link_status_changed() to
+ *	  bond_3ad_handle_link_change() for compatibility with TLB.
+ */
+
+#include <linux/skbuff.h>
+#include <linux/if_ether.h>
+#include <linux/netdevice.h>
+#include <linux/spinlock.h>
+#include <linux/ethtool.h>
+#include <linux/if_bonding.h>
+#include "bonding.h"
+#include "bond_3ad.h"
+
+// General definitions
+#define AD_SHORT_TIMEOUT           1
+#define AD_LONG_TIMEOUT            0
+#define AD_STANDBY                 0x2
+#define AD_MAX_TX_IN_SECOND        3
+#define AD_COLLECTOR_MAX_DELAY     0
+
+// Timer definitions(43.4.4 in the 802.3ad standard)
+#define AD_FAST_PERIODIC_TIME      1
+#define AD_SLOW_PERIODIC_TIME      30
+#define AD_SHORT_TIMEOUT_TIME      (3*AD_FAST_PERIODIC_TIME)
+#define AD_LONG_TIMEOUT_TIME       (3*AD_SLOW_PERIODIC_TIME)
+#define AD_CHURN_DETECTION_TIME    60
+#define AD_AGGREGATE_WAIT_TIME     2
+
+// Port state definitions(43.4.2.2 in the 802.3ad standard)
+#define AD_STATE_LACP_ACTIVITY   0x1
+#define AD_STATE_LACP_TIMEOUT    0x2
+#define AD_STATE_AGGREGATION     0x4
+#define AD_STATE_SYNCHRONIZATION 0x8
+#define AD_STATE_COLLECTING      0x10
+#define AD_STATE_DISTRIBUTING    0x20
+#define AD_STATE_DEFAULTED       0x40
+#define AD_STATE_EXPIRED         0x80
+
+// Port Variables definitions used by the State Machines(43.4.7 in the 802.3ad standard)
+#define AD_PORT_BEGIN           0x1
+#define AD_PORT_LACP_ENABLED    0x2
+#define AD_PORT_ACTOR_CHURN     0x4
+#define AD_PORT_PARTNER_CHURN   0x8
+#define AD_PORT_READY           0x10
+#define AD_PORT_READY_N         0x20
+#define AD_PORT_MATCHED         0x40
+#define AD_PORT_STANDBY         0x80
+#define AD_PORT_SELECTED        0x100
+#define AD_PORT_MOVED           0x200
+
+// Port Key definitions
+// key is determined according to the link speed, duplex and
+// user key(which is yet not supported)
+//              ------------------------------------------------------------
+// Port key :   | User key                       |      Speed       |Duplex|
+//              ------------------------------------------------------------
+//              16                               6               1 0
+#define  AD_DUPLEX_KEY_BITS    0x1
+#define  AD_SPEED_KEY_BITS     0x3E
+#define  AD_USER_KEY_BITS      0xFFC0
+
+//dalloun
+#define     AD_LINK_SPEED_BITMASK_1MBPS       0x1
+#define     AD_LINK_SPEED_BITMASK_10MBPS      0x2
+#define     AD_LINK_SPEED_BITMASK_100MBPS     0x4
+#define     AD_LINK_SPEED_BITMASK_1000MBPS    0x8
+//endalloun
+
+// compare MAC addresses
+#define MAC_ADDRESS_COMPARE(A, B) memcmp(A, B, ETH_ALEN)
+
+static struct mac_addr null_mac_addr = {{0, 0, 0, 0, 0, 0}};
+static u16 ad_ticks_per_sec;
+
+// ================= 3AD api to bonding and kernel code ==================
+static u16 __get_link_speed(struct port *port);
+static u8 __get_duplex(struct port *port);
+static inline void __initialize_port_locks(struct port *port);
+static inline void __deinitialize_port_locks(struct port *port);
+//conversions
+static void __ntohs_lacpdu(struct lacpdu *lacpdu);
+static u16 __ad_timer_to_ticks(u16 timer_type, u16 Par);
+
+
+// ================= ad code helper functions ==================
+//needed by ad_rx_machine(...)
+static void __record_pdu(struct lacpdu *lacpdu, struct port *port);
+static void __record_default(struct port *port);
+static void __update_selected(struct lacpdu *lacpdu, struct port *port);
+static void __update_default_selected(struct port *port);
+static void __choose_matched(struct lacpdu *lacpdu, struct port *port);
+static void __update_ntt(struct lacpdu *lacpdu, struct port *port);
+
+//needed for ad_mux_machine(..)
+static void __attach_bond_to_agg(struct port *port);
+static void __detach_bond_from_agg(struct port *port);
+static int __agg_ports_are_ready(struct aggregator *aggregator);
+static void __set_agg_ports_ready(struct aggregator *aggregator, int val);
+
+//needed for ad_agg_selection_logic(...)
+static u32 __get_agg_bandwidth(struct aggregator *aggregator);
+static struct aggregator *__get_active_agg(struct aggregator *aggregator);
+
+
+// ================= main 802.3ad protocol functions ==================
+static int ad_lacpdu_send(struct port *port);
+static int ad_marker_send(struct port *port, struct marker *marker);
+static void ad_mux_machine(struct port *port);
+static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port);
+static void ad_tx_machine(struct port *port);
+static void ad_periodic_machine(struct port *port);
+static void ad_port_selection_logic(struct port *port);
+static void ad_agg_selection_logic(struct aggregator *aggregator);
+static void ad_clear_agg(struct aggregator *aggregator);
+static void ad_initialize_agg(struct aggregator *aggregator);
+static void ad_initialize_port(struct port *port, int lacp_fast);
+static void ad_initialize_lacpdu(struct lacpdu *Lacpdu);
+static void ad_enable_collecting_distributing(struct port *port);
+static void ad_disable_collecting_distributing(struct port *port);
+static void ad_marker_info_received(struct marker *marker_info, struct port *port);
+static void ad_marker_response_received(struct marker *marker, struct port *port);
+
+
+/////////////////////////////////////////////////////////////////////////////////
+// ================= api to bonding and kernel code ==================
+/////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * __get_bond_by_port - get the port's bonding struct
+ * @port: the port we're looking at
+ *
+ * Return @port's bonding struct, or %NULL if it can't be found.
+ */
+static inline struct bonding *__get_bond_by_port(struct port *port)
+{
+	if (port->slave == NULL) {
+		return NULL;
+	}
+
+	return bond_get_bond_by_slave(port->slave);
+}
+
+/**
+ * __get_first_port - get the first port in the bond
+ * @bond: the bond we're looking at
+ *
+ * Return the port of the first slave in @bond, or %NULL if it can't be found.
+ */
+static inline struct port *__get_first_port(struct bonding *bond)
+{
+	struct slave *slave = bond->next;
+
+	if (slave == (struct slave *)bond) {
+		return NULL;
+	}
+
+	return &(SLAVE_AD_INFO(slave).port);
+}
+
+/**
+ * __get_next_port - get the next port in the bond
+ * @port: the port we're looking at
+ *
+ * Return the port of the slave that is next in line of @port's slave in the
+ * bond, or %NULL if it can't be found.
+ */
+static inline struct port *__get_next_port(struct port *port)
+{
+	struct bonding *bond = __get_bond_by_port(port);
+	struct slave *slave = port->slave;
+
+	// If there's no bond for this port, or this is the last slave
+	if ((bond == NULL) || (slave->next == bond->next)) {
+		return NULL;
+	}
+
+	return &(SLAVE_AD_INFO(slave->next).port);
+}
+
+/**
+ * __get_first_agg - get the first aggregator in the bond
+ * @bond: the bond we're looking at
+ *
+ * Return the aggregator of the first slave in @bond, or %NULL if it can't be
+ * found.
+ */
+static inline struct aggregator *__get_first_agg(struct port *port)
+{
+	struct bonding *bond = __get_bond_by_port(port);
+
+	// If there's no bond for this port, or this is the last slave
+	if ((bond == NULL) || (bond->next == (struct slave *)bond)) {
+		return NULL;
+	}
+
+	return &(SLAVE_AD_INFO(bond->next).aggregator);
+}
+
+/**
+ * __get_next_agg - get the next aggregator in the bond
+ * @aggregator: the aggregator we're looking at
+ *
+ * Return the aggregator of the slave that is next in line of @aggregator's
+ * slave in the bond, or %NULL if it can't be found.
+ */
+static inline struct aggregator *__get_next_agg(struct aggregator *aggregator)
+{
+	struct slave *slave = aggregator->slave;
+	struct bonding *bond = bond_get_bond_by_slave(slave);
+
+	// If there's no bond for this aggregator, or this is the last slave
+	if ((bond == NULL) || (slave->next == bond->next)) {
+		return NULL;
+	}
+
+	return &(SLAVE_AD_INFO(slave->next).aggregator);
+}
+
+/**
+ * __disable_port - disable the port's slave
+ * @port: the port we're looking at
+ *
+ */
+static inline void __disable_port(struct port *port)
+{
+	bond_set_slave_inactive_flags(port->slave);
+}
+
+/**
+ * __enable_port - enable the port's slave, if it's up
+ * @port: the port we're looking at
+ *
+ */
+static inline void __enable_port(struct port *port)
+{
+	struct slave *slave = port->slave;
+
+	if ((slave->link == BOND_LINK_UP) && IS_UP(slave->dev)) {
+		bond_set_slave_active_flags(slave);
+	}
+}
+
+/**
+ * __port_is_enabled - check if the port's slave is in active state
+ * @port: the port we're looking at
+ *
+ */
+static inline int __port_is_enabled(struct port *port)
+{
+	return(port->slave->state == BOND_STATE_ACTIVE);
+}
+
+/**
+ * __get_agg_selection_mode - get the aggregator selection mode
+ * @port: the port we're looking at
+ *
+ * Get the aggregator selection mode. Can be %BANDWIDTH or %COUNT.
+ */
+static inline u32 __get_agg_selection_mode(struct port *port)
+{
+	struct bonding *bond = __get_bond_by_port(port);
+
+	if (bond == NULL) {
+		return AD_BANDWIDTH;
+	}
+
+	return BOND_AD_INFO(bond).agg_select_mode;
+}
+
+/**
+ * __check_agg_selection_timer - check if the selection timer has expired
+ * @port: the port we're looking at
+ *
+ */
+static inline int __check_agg_selection_timer(struct port *port)
+{
+	struct bonding *bond = __get_bond_by_port(port);
+
+	if (bond == NULL) {
+		return 0;
+	}
+
+	return BOND_AD_INFO(bond).agg_select_timer ? 1 : 0;
+}
+
+/**
+ * __get_rx_machine_lock - lock the port's RX machine
+ * @port: the port we're looking at
+ *
+ */
+static inline void __get_rx_machine_lock(struct port *port)
+{
+	spin_lock(&(SLAVE_AD_INFO(port->slave).rx_machine_lock));
+}
+
+/**
+ * __release_rx_machine_lock - unlock the port's RX machine
+ * @port: the port we're looking at
+ *
+ */
+static inline void __release_rx_machine_lock(struct port *port)
+{
+	spin_unlock(&(SLAVE_AD_INFO(port->slave).rx_machine_lock));
+}
+
+/**
+ * __get_link_speed - get a port's speed
+ * @port: the port we're looking at
+ *
+ * Return @port's speed in 802.3ad bitmask format. i.e. one of:
+ *     0,
+ *     %AD_LINK_SPEED_BITMASK_10MBPS,
+ *     %AD_LINK_SPEED_BITMASK_100MBPS,
+ *     %AD_LINK_SPEED_BITMASK_1000MBPS
+ */
+static u16 __get_link_speed(struct port *port)
+{
+	struct slave *slave = port->slave;
+	u16 speed;
+
+	/* this if covers only a special case: when the configuration starts with
+	 * link down, it sets the speed to 0.
+	 * This is done in spite of the fact that the e100 driver reports 0 to be
+	 * compatible with MVT in the future.*/
+	if (slave->link != BOND_LINK_UP) {
+		speed=0;
+	} else {
+		switch (slave->speed) {
+		case SPEED_10:
+			speed = AD_LINK_SPEED_BITMASK_10MBPS;
+			break;
+
+		case SPEED_100:
+			speed = AD_LINK_SPEED_BITMASK_100MBPS;
+			break;
+
+		case SPEED_1000:
+			speed = AD_LINK_SPEED_BITMASK_1000MBPS;
+			break;
+
+		default:
+			speed = 0; // unknown speed value from ethtool. shouldn't happen
+			break;
+		}
+	}
+
+	BOND_PRINT_DBG(("Port %d Received link speed %d update from adapter", port->actor_port_number, speed));
+	return speed;
+}
+
+/**
+ * __get_duplex - get a port's duplex
+ * @port: the port we're looking at
+ *
+ * Return @port's duplex in 802.3ad bitmask format. i.e.:
+ *     0x01 if in full duplex
+ *     0x00 otherwise
+ */
+static u8 __get_duplex(struct port *port)
+{
+	struct slave *slave = port->slave;
+
+	u8 retval;
+
+	//  handling a special case: when the configuration starts with
+	// link down, it sets the duplex to 0.
+	if (slave->link != BOND_LINK_UP) {
+		retval=0x0;
+	} else {
+		switch (slave->duplex) {
+		case DUPLEX_FULL:
+			retval=0x1;
+			BOND_PRINT_DBG(("Port %d Received status full duplex update from adapter", port->actor_port_number));
+			break;
+		case DUPLEX_HALF:
+		default:
+			retval=0x0;
+			BOND_PRINT_DBG(("Port %d Received status NOT full duplex update from adapter", port->actor_port_number));
+			break;
+		}
+	}
+	return retval;
+}
+
+/**
+ * __initialize_port_locks - initialize a port's RX machine spinlock
+ * @port: the port we're looking at
+ *
+ */
+static inline void __initialize_port_locks(struct port *port)
+{
+	// make sure it isn't called twice
+	spin_lock_init(&(SLAVE_AD_INFO(port->slave).rx_machine_lock));
+}
+
+/**
+ * __deinitialize_port_locks - deinitialize a port's RX machine spinlock
+ * @port: the port we're looking at
+ *
+ */
+static inline void __deinitialize_port_locks(struct port *port)
+{
+}
+
+//conversions
+/**
+ * __ntohs_lacpdu - convert the contents of a LACPDU to host byte order
+ * @lacpdu: the speicifed lacpdu
+ *
+ * For each multi-byte field in the lacpdu, convert its content
+ */
+static void __ntohs_lacpdu(struct lacpdu *lacpdu)
+{
+	if (lacpdu) {
+		lacpdu->actor_system_priority =   ntohs(lacpdu->actor_system_priority);
+		lacpdu->actor_key =               ntohs(lacpdu->actor_key);
+		lacpdu->actor_port_priority =     ntohs(lacpdu->actor_port_priority);
+		lacpdu->actor_port =              ntohs(lacpdu->actor_port);
+		lacpdu->partner_system_priority = ntohs(lacpdu->partner_system_priority);
+		lacpdu->partner_key =             ntohs(lacpdu->partner_key);
+		lacpdu->partner_port_priority =   ntohs(lacpdu->partner_port_priority);
+		lacpdu->partner_port =            ntohs(lacpdu->partner_port);
+		lacpdu->collector_max_delay =     ntohs(lacpdu->collector_max_delay);
+	}
+}
+
+/**
+ * __ad_timer_to_ticks - convert a given timer type to AD module ticks
+ * @timer_type:	which timer to operate
+ * @par: timer parameter. see below
+ *
+ * If @timer_type is %current_while_timer, @par indicates long/short timer.
+ * If @timer_type is %periodic_timer, @par is one of %FAST_PERIODIC_TIME,
+ *						    %SLOW_PERIODIC_TIME.
+ */
+static u16 __ad_timer_to_ticks(u16 timer_type, u16 par)
+{
+	u16 retval=0;	 //to silence the compiler
+
+	switch (timer_type) {
+	case AD_CURRENT_WHILE_TIMER:   // for rx machine usage
+		if (par) {	      // for short or long timeout
+			retval = (AD_SHORT_TIMEOUT_TIME*ad_ticks_per_sec); // short timeout
+		} else {
+			retval = (AD_LONG_TIMEOUT_TIME*ad_ticks_per_sec); // long timeout
+		}
+		break;
+	case AD_ACTOR_CHURN_TIMER:	    // for local churn machine
+		retval = (AD_CHURN_DETECTION_TIME*ad_ticks_per_sec);
+		break;
+	case AD_PERIODIC_TIMER:	    // for periodic machine
+		retval = (par*ad_ticks_per_sec); // long timeout
+		break;
+	case AD_PARTNER_CHURN_TIMER:   // for remote churn machine
+		retval = (AD_CHURN_DETECTION_TIME*ad_ticks_per_sec);
+		break;
+	case AD_WAIT_WHILE_TIMER:	    // for selection machine
+		retval = (AD_AGGREGATE_WAIT_TIME*ad_ticks_per_sec);
+		break;
+	}
+	return retval;
+}
+
+
+/////////////////////////////////////////////////////////////////////////////////
+// ================= ad_rx_machine helper functions ==================
+/////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * __record_pdu - record parameters from a received lacpdu
+ * @lacpdu: the lacpdu we've received
+ * @port: the port we're looking at
+ *
+ * Record the parameter values for the Actor carried in a received lacpdu as
+ * the current partner operational parameter values and sets
+ * actor_oper_port_state.defaulted to FALSE.
+ */
+static void __record_pdu(struct lacpdu *lacpdu, struct port *port)
+{
+	// validate lacpdu and port
+	if (lacpdu && port) {
+		// record the new parameter values for the partner operational
+		port->partner_oper_port_number = lacpdu->actor_port;
+		port->partner_oper_port_priority = lacpdu->actor_port_priority;
+		port->partner_oper_system = lacpdu->actor_system;
+		port->partner_oper_system_priority = lacpdu->actor_system_priority;
+		port->partner_oper_key = lacpdu->actor_key;
+		// zero partener's lase states
+		port->partner_oper_port_state = 0;
+		port->partner_oper_port_state |= (lacpdu->actor_state & AD_STATE_LACP_ACTIVITY);
+		port->partner_oper_port_state |= (lacpdu->actor_state & AD_STATE_LACP_TIMEOUT);
+		port->partner_oper_port_state |= (lacpdu->actor_state & AD_STATE_AGGREGATION);
+		port->partner_oper_port_state |= (lacpdu->actor_state & AD_STATE_SYNCHRONIZATION);
+		port->partner_oper_port_state |= (lacpdu->actor_state & AD_STATE_COLLECTING);
+		port->partner_oper_port_state |= (lacpdu->actor_state & AD_STATE_DISTRIBUTING);
+		port->partner_oper_port_state |= (lacpdu->actor_state & AD_STATE_DEFAULTED);
+		port->partner_oper_port_state |= (lacpdu->actor_state & AD_STATE_EXPIRED);
+
+		// set actor_oper_port_state.defaulted to FALSE
+		port->actor_oper_port_state &= ~AD_STATE_DEFAULTED;
+
+		// set the partner sync. to on if the partner is sync. and the port is matched
+		if ((port->sm_vars & AD_PORT_MATCHED) && (lacpdu->actor_state & AD_STATE_SYNCHRONIZATION)) {
+			port->partner_oper_port_state |= AD_STATE_SYNCHRONIZATION;
+		} else {
+			port->partner_oper_port_state &= ~AD_STATE_SYNCHRONIZATION;
+		}
+	}
+}
+
+/**
+ * __record_default - record default parameters
+ * @port: the port we're looking at
+ *
+ * This function records the default parameter values for the partner carried
+ * in the Partner Admin parameters as the current partner operational parameter
+ * values and sets actor_oper_port_state.defaulted to TRUE.
+ */
+static void __record_default(struct port *port)
+{
+	// validate the port
+	if (port) {
+		// record the partner admin parameters
+		port->partner_oper_port_number = port->partner_admin_port_number;
+		port->partner_oper_port_priority = port->partner_admin_port_priority;
+		port->partner_oper_system = port->partner_admin_system;
+		port->partner_oper_system_priority = port->partner_admin_system_priority;
+		port->partner_oper_key = port->partner_admin_key;
+		port->partner_oper_port_state = port->partner_admin_port_state;
+
+		// set actor_oper_port_state.defaulted to true
+		port->actor_oper_port_state |= AD_STATE_DEFAULTED;
+	}
+}
+
+/**
+ * __update_selected - update a port's Selected variable from a received lacpdu
+ * @lacpdu: the lacpdu we've received
+ * @port: the port we're looking at
+ *
+ * Update the value of the selected variable, using parameter values from a
+ * newly received lacpdu. The parameter values for the Actor carried in the
+ * received PDU are compared with the corresponding operational parameter
+ * values for the ports partner. If one or more of the comparisons shows that
+ * the value(s) received in the PDU differ from the current operational values,
+ * then selected is set to FALSE and actor_oper_port_state.synchronization is
+ * set to out_of_sync. Otherwise, selected remains unchanged.
+ */
+static void __update_selected(struct lacpdu *lacpdu, struct port *port)
+{
+	// validate lacpdu and port
+	if (lacpdu && port) {
+		// check if any parameter is different
+		if ((lacpdu->actor_port != port->partner_oper_port_number) ||
+		    (lacpdu->actor_port_priority != port->partner_oper_port_priority) ||
+		    MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->partner_oper_system)) ||
+		    (lacpdu->actor_system_priority != port->partner_oper_system_priority) ||
+		    (lacpdu->actor_key != port->partner_oper_key) ||
+		    ((lacpdu->actor_state & AD_STATE_AGGREGATION) != (port->partner_oper_port_state & AD_STATE_AGGREGATION))
+		   ) {
+			// update the state machine Selected variable
+			port->sm_vars &= ~AD_PORT_SELECTED;
+		}
+	}
+}
+
+/**
+ * __update_default_selected - update a port's Selected variable from Partner
+ * @port: the port we're looking at
+ *
+ * This function updates the value of the selected variable, using the partner
+ * administrative parameter values. The administrative values are compared with
+ * the corresponding operational parameter values for the partner. If one or
+ * more of the comparisons shows that the administrative value(s) differ from
+ * the current operational values, then Selected is set to FALSE and
+ * actor_oper_port_state.synchronization is set to OUT_OF_SYNC. Otherwise,
+ * Selected remains unchanged.
+ */
+static void __update_default_selected(struct port *port)
+{
+	// validate the port
+	if (port) {
+		// check if any parameter is different
+		if ((port->partner_admin_port_number != port->partner_oper_port_number) ||
+		    (port->partner_admin_port_priority != port->partner_oper_port_priority) ||
+		    MAC_ADDRESS_COMPARE(&(port->partner_admin_system), &(port->partner_oper_system)) ||
+		    (port->partner_admin_system_priority != port->partner_oper_system_priority) ||
+		    (port->partner_admin_key != port->partner_oper_key) ||
+		    ((port->partner_admin_port_state & AD_STATE_AGGREGATION) != (port->partner_oper_port_state & AD_STATE_AGGREGATION))
+		   ) {
+			// update the state machine Selected variable
+			port->sm_vars &= ~AD_PORT_SELECTED;
+		}
+	}
+}
+
+/**
+ * __choose_matched - update a port's matched variable from a received lacpdu
+ * @lacpdu: the lacpdu we've received
+ * @port: the port we're looking at
+ *
+ * Update the value of the matched variable, using parameter values from a
+ * newly received lacpdu. Parameter values for the partner carried in the
+ * received PDU are compared with the corresponding operational parameter
+ * values for the actor. Matched is set to TRUE if all of these parameters
+ * match and the PDU parameter partner_state.aggregation has the same value as
+ * actor_oper_port_state.aggregation and lacp will actively maintain the link
+ * in the aggregation. Matched is also set to TRUE if the value of
+ * actor_state.aggregation in the received PDU is set to FALSE, i.e., indicates
+ * an individual link and lacp will actively maintain the link. Otherwise,
+ * matched is set to FALSE. LACP is considered to be actively maintaining the
+ * link if either the PDU's actor_state.lacp_activity variable is TRUE or both
+ * the actor's actor_oper_port_state.lacp_activity and the PDU's
+ * partner_state.lacp_activity variables are TRUE.
+ */
+static void __choose_matched(struct lacpdu *lacpdu, struct port *port)
+{
+	// validate lacpdu and port
+	if (lacpdu && port) {
+		// check if all parameters are alike
+		if (((lacpdu->partner_port == port->actor_port_number) &&
+		     (lacpdu->partner_port_priority == port->actor_port_priority) &&
+		     !MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) &&
+		     (lacpdu->partner_system_priority == port->actor_system_priority) &&
+		     (lacpdu->partner_key == port->actor_oper_port_key) &&
+		     ((lacpdu->partner_state & AD_STATE_AGGREGATION) == (port->actor_oper_port_state & AD_STATE_AGGREGATION))) ||
+		    // or this is individual link(aggregation == FALSE)
+		    ((lacpdu->actor_state & AD_STATE_AGGREGATION) == 0)
+		   ) {
+			// update the state machine Matched variable
+			port->sm_vars |= AD_PORT_MATCHED;
+		} else {
+			port->sm_vars &= ~AD_PORT_MATCHED;
+		}
+	}
+}
+
+/**
+ * __update_ntt - update a port's ntt variable from a received lacpdu
+ * @lacpdu: the lacpdu we've received
+ * @port: the port we're looking at
+ *
+ * Updates the value of the ntt variable, using parameter values from a newly
+ * received lacpdu. The parameter values for the partner carried in the
+ * received PDU are compared with the corresponding operational parameter
+ * values for the Actor. If one or more of the comparisons shows that the
+ * value(s) received in the PDU differ from the current operational values,
+ * then ntt is set to TRUE. Otherwise, ntt remains unchanged.
+ */
+static void __update_ntt(struct lacpdu *lacpdu, struct port *port)
+{
+	// validate lacpdu and port
+	if (lacpdu && port) {
+		// check if any parameter is different
+		if ((lacpdu->partner_port != port->actor_port_number) ||
+		    (lacpdu->partner_port_priority != port->actor_port_priority) ||
+		    MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) ||
+		    (lacpdu->partner_system_priority != port->actor_system_priority) ||
+		    (lacpdu->partner_key != port->actor_oper_port_key) ||
+		    ((lacpdu->partner_state & AD_STATE_LACP_ACTIVITY) != (port->actor_oper_port_state & AD_STATE_LACP_ACTIVITY)) ||
+		    ((lacpdu->partner_state & AD_STATE_LACP_TIMEOUT) != (port->actor_oper_port_state & AD_STATE_LACP_TIMEOUT)) ||
+		    ((lacpdu->partner_state & AD_STATE_SYNCHRONIZATION) != (port->actor_oper_port_state & AD_STATE_SYNCHRONIZATION)) ||
+		    ((lacpdu->partner_state & AD_STATE_AGGREGATION) != (port->actor_oper_port_state & AD_STATE_AGGREGATION))
+		   ) {
+			// set ntt to be TRUE
+			port->ntt = 1;
+		}
+	}
+}
+
+/**
+ * __attach_bond_to_agg
+ * @port: the port we're looking at
+ *
+ * Handle the attaching of the port's control parser/multiplexer and the
+ * aggregator. This function does nothing since the parser/multiplexer of the
+ * receive and the parser/multiplexer of the aggregator are already combined.
+ */
+static void __attach_bond_to_agg(struct port *port)
+{
+	port=NULL; // just to satisfy the compiler
+	// This function does nothing since the parser/multiplexer of the receive
+	// and the parser/multiplexer of the aggregator are already combined
+}
+
+/**
+ * __detach_bond_from_agg
+ * @port: the port we're looking at
+ *
+ * Handle the detaching of the port's control parser/multiplexer from the
+ * aggregator. This function does nothing since the parser/multiplexer of the
+ * receive and the parser/multiplexer of the aggregator are already combined.
+ */
+static void __detach_bond_from_agg(struct port *port)
+{
+	port=NULL; // just to satisfy the compiler
+	// This function does nothing sience the parser/multiplexer of the receive
+	// and the parser/multiplexer of the aggregator are already combined
+}
+
+/**
+ * __agg_ports_are_ready - check if all ports in an aggregator are ready
+ * @aggregator: the aggregator we're looking at
+ *
+ */
+static int __agg_ports_are_ready(struct aggregator *aggregator)
+{
+	struct port *port;
+	int retval = 1;
+
+	if (aggregator) {
+		// scan all ports in this aggregator to verfy if they are all ready
+		for (port=aggregator->lag_ports; port; port=port->next_port_in_aggregator) {
+			if (!(port->sm_vars & AD_PORT_READY_N)) {
+				retval = 0;
+				break;
+			}
+		}
+	}
+
+	return retval;
+}
+
+/**
+ * __set_agg_ports_ready - set value of Ready bit in all ports of an aggregator
+ * @aggregator: the aggregator we're looking at
+ * @val: Should the ports' ready bit be set on or off
+ *
+ */
+static void __set_agg_ports_ready(struct aggregator *aggregator, int val)
+{
+	struct port *port;
+
+	for (port=aggregator->lag_ports; port; port=port->next_port_in_aggregator) {
+		if (val) {
+			port->sm_vars |= AD_PORT_READY;
+		} else {
+			port->sm_vars &= ~AD_PORT_READY;
+		}
+	}
+}
+
+/**
+ * __get_agg_bandwidth - get the total bandwidth of an aggregator
+ * @aggregator: the aggregator we're looking at
+ *
+ */
+static u32 __get_agg_bandwidth(struct aggregator *aggregator)
+{
+	u32 bandwidth=0;
+	u32 basic_speed;
+
+	if (aggregator->num_of_ports) {
+		basic_speed = __get_link_speed(aggregator->lag_ports);
+		switch (basic_speed) {
+		case AD_LINK_SPEED_BITMASK_1MBPS:
+			bandwidth = aggregator->num_of_ports;
+			break;
+		case AD_LINK_SPEED_BITMASK_10MBPS:
+			bandwidth = aggregator->num_of_ports * 10;
+			break;
+		case AD_LINK_SPEED_BITMASK_100MBPS:
+			bandwidth = aggregator->num_of_ports * 100;
+			break;
+		case AD_LINK_SPEED_BITMASK_1000MBPS:
+			bandwidth = aggregator->num_of_ports * 1000;
+			break;
+		default:
+			bandwidth=0; // to silent the compilor ....
+		}
+	}
+	return bandwidth;
+}
+
+/**
+ * __get_active_agg - get the current active aggregator
+ * @aggregator: the aggregator we're looking at
+ *
+ */
+static struct aggregator *__get_active_agg(struct aggregator *aggregator)
+{
+	struct aggregator *retval = NULL;
+
+	for (; aggregator; aggregator = __get_next_agg(aggregator)) {
+		if (aggregator->is_active) {
+			retval = aggregator;
+			break;
+		}
+	}
+
+	return retval;
+}
+
+/**
+ * __update_lacpdu_from_port - update a port's lacpdu fields
+ * @port: the port we're looking at
+ *
+ */
+static inline void __update_lacpdu_from_port(struct port *port)
+{
+	struct lacpdu *lacpdu = &port->lacpdu;
+
+	/* update current actual Actor parameters */
+	/* lacpdu->subtype                   initialized
+	 * lacpdu->version_number            initialized
+	 * lacpdu->tlv_type_actor_info       initialized
+	 * lacpdu->actor_information_length  initialized
+	 */
+
+	lacpdu->actor_system_priority = port->actor_system_priority;
+	lacpdu->actor_system = port->actor_system;
+	lacpdu->actor_key = port->actor_oper_port_key;
+	lacpdu->actor_port_priority = port->actor_port_priority;
+	lacpdu->actor_port = port->actor_port_number;
+	lacpdu->actor_state = port->actor_oper_port_state;
+
+	/* lacpdu->reserved_3_1              initialized
+	 * lacpdu->tlv_type_partner_info     initialized
+	 * lacpdu->partner_information_length initialized
+	 */
+
+	lacpdu->partner_system_priority = port->partner_oper_system_priority;
+	lacpdu->partner_system = port->partner_oper_system;
+	lacpdu->partner_key = port->partner_oper_key;
+	lacpdu->partner_port_priority = port->partner_oper_port_priority;
+	lacpdu->partner_port = port->partner_oper_port_number;
+	lacpdu->partner_state = port->partner_oper_port_state;
+
+	/* lacpdu->reserved_3_2              initialized
+	 * lacpdu->tlv_type_collector_info   initialized
+	 * lacpdu->collector_information_length initialized
+	 * collector_max_delay                initialized
+	 * reserved_12[12]                   initialized
+	 * tlv_type_terminator               initialized
+	 * terminator_length                 initialized
+	 * reserved_50[50]                   initialized
+	 */
+
+	/* Convert all non u8 parameters to Big Endian for transmit */
+	__ntohs_lacpdu(lacpdu);
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+// ================= main 802.3ad protocol code ======================================
+//////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * ad_lacpdu_send - send out a lacpdu packet on a given port
+ * @port: the port we're looking at
+ *
+ * Returns:   0 on success
+ *          < 0 on error
+ */
+static int ad_lacpdu_send(struct port *port)
+{
+	struct slave *slave = port->slave;
+	struct sk_buff *skb;
+	struct lacpdu_header *lacpdu_header;
+	int length = sizeof(struct lacpdu_header);
+	struct mac_addr lacpdu_multicast_address = AD_MULTICAST_LACPDU_ADDR;
+
+	skb = dev_alloc_skb(length);
+	if (!skb) {
+		return -ENOMEM;
+	}
+
+	skb->dev = slave->dev;
+	skb->mac.raw = skb->data;
+	skb->nh.raw = skb->data + ETH_HLEN;
+	skb->protocol = PKT_TYPE_LACPDU;
+
+	lacpdu_header = (struct lacpdu_header *)skb_put(skb, length);
+
+	lacpdu_header->ad_header.destination_address = lacpdu_multicast_address;
+	/* Note: source addres is set to be the member's PERMANENT address, because we use it
+	   to identify loopback lacpdus in receive. */
+	lacpdu_header->ad_header.source_address = *((struct mac_addr *)(slave->perm_hwaddr));
+	lacpdu_header->ad_header.length_type = PKT_TYPE_LACPDU;
+
+	lacpdu_header->lacpdu = port->lacpdu; // struct copy
+
+	dev_queue_xmit(skb);
+
+	return 0;
+}
+
+/**
+ * ad_marker_send - send marker information/response on a given port
+ * @port: the port we're looking at
+ * @marker: marker data to send
+ *
+ * Returns:   0 on success
+ *          < 0 on error
+ */
+static int ad_marker_send(struct port *port, struct marker *marker)
+{
+	struct slave *slave = port->slave;
+	struct sk_buff *skb;
+	struct marker_header *marker_header;
+	int length = sizeof(struct marker_header);
+	struct mac_addr lacpdu_multicast_address = AD_MULTICAST_LACPDU_ADDR;
+
+	skb = dev_alloc_skb(length + 16);
+	if (!skb) {
+		return -ENOMEM;
+	}
+
+	skb_reserve(skb, 16);
+
+	skb->dev = slave->dev;
+	skb->mac.raw = skb->data;
+	skb->nh.raw = skb->data + ETH_HLEN;
+	skb->protocol = PKT_TYPE_LACPDU;
+
+	marker_header = (struct marker_header *)skb_put(skb, length);
+
+	marker_header->ad_header.destination_address = lacpdu_multicast_address;
+	/* Note: source addres is set to be the member's PERMANENT address, because we use it
+	   to identify loopback MARKERs in receive. */
+	marker_header->ad_header.source_address = *((struct mac_addr *)(slave->perm_hwaddr));
+	marker_header->ad_header.length_type = PKT_TYPE_LACPDU;
+
+	marker_header->marker = *marker; // struct copy
+
+	dev_queue_xmit(skb);
+
+	return 0;
+}
+
+/**
+ * ad_mux_machine - handle a port's mux state machine
+ * @port: the port we're looking at
+ *
+ */
+static void ad_mux_machine(struct port *port)
+{
+	mux_states_t last_state;
+
+	// keep current State Machine state to compare later if it was changed
+	last_state = port->sm_mux_state;
+
+	if (port->sm_vars & AD_PORT_BEGIN) {
+		port->sm_mux_state = AD_MUX_DETACHED;		 // next state
+	} else {
+		switch (port->sm_mux_state) {
+		case AD_MUX_DETACHED:
+			if ((port->sm_vars & AD_PORT_SELECTED) || (port->sm_vars & AD_PORT_STANDBY)) { // if SELECTED or STANDBY
+				port->sm_mux_state = AD_MUX_WAITING; // next state
+			}
+			break;
+		case AD_MUX_WAITING:
+			// if SELECTED == FALSE return to DETACH state
+			if (!(port->sm_vars & AD_PORT_SELECTED)) { // if UNSELECTED
+				port->sm_vars &= ~AD_PORT_READY_N;
+				// in order to withhold the Selection Logic to check all ports READY_N value
+				// every callback cycle to update ready variable, we check READY_N and update READY here
+				__set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator));
+				port->sm_mux_state = AD_MUX_DETACHED;	 // next state
+				break;
+			}
+
+			// check if the wait_while_timer expired
+			if (port->sm_mux_timer_counter && !(--port->sm_mux_timer_counter)) {
+				port->sm_vars |= AD_PORT_READY_N;
+			}
+
+			// in order to withhold the selection logic to check all ports READY_N value
+			// every callback cycle to update ready variable, we check READY_N and update READY here
+			__set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator));
+
+			// if the wait_while_timer expired, and the port is in READY state, move to ATTACHED state
+			if ((port->sm_vars & AD_PORT_READY) && !port->sm_mux_timer_counter) {
+				port->sm_mux_state = AD_MUX_ATTACHED;	 // next state
+			}
+			break;
+		case AD_MUX_ATTACHED:
+			// check also if agg_select_timer expired(so the edable port will take place only after this timer)
+			if ((port->sm_vars & AD_PORT_SELECTED) && (port->partner_oper_port_state & AD_STATE_SYNCHRONIZATION) && !__check_agg_selection_timer(port)) {
+				port->sm_mux_state = AD_MUX_COLLECTING_DISTRIBUTING;// next state
+			} else if (!(port->sm_vars & AD_PORT_SELECTED) || (port->sm_vars & AD_PORT_STANDBY)) {	  // if UNSELECTED or STANDBY
+				port->sm_vars &= ~AD_PORT_READY_N;
+				// in order to withhold the selection logic to check all ports READY_N value
+				// every callback cycle to update ready variable, we check READY_N and update READY here
+				__set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator));
+				port->sm_mux_state = AD_MUX_DETACHED;// next state
+			}
+			break;
+		case AD_MUX_COLLECTING_DISTRIBUTING:
+			if (!(port->sm_vars & AD_PORT_SELECTED) || (port->sm_vars & AD_PORT_STANDBY) ||
+			    !(port->partner_oper_port_state & AD_STATE_SYNCHRONIZATION)
+			   ) {
+				port->sm_mux_state = AD_MUX_ATTACHED;// next state
+
+			} else {
+				// if port state hasn't changed make
+				// sure that a collecting distributing
+				// port in an active aggregator is enabled
+				if (port->aggregator &&
+				    port->aggregator->is_active &&
+				    !__port_is_enabled(port)) {
+
+					__enable_port(port);
+				}
+			}
+			break;
+		default:    //to silence the compiler
+			break;
+		}
+	}
+
+	// check if the state machine was changed
+	if (port->sm_mux_state != last_state) {
+		BOND_PRINT_DBG(("Mux Machine: Port=%d, Last State=%d, Curr State=%d", port->actor_port_number, last_state, port->sm_mux_state));
+		switch (port->sm_mux_state) {
+		case AD_MUX_DETACHED:
+			__detach_bond_from_agg(port);
+			port->actor_oper_port_state &= ~AD_STATE_SYNCHRONIZATION;
+			ad_disable_collecting_distributing(port);
+			port->actor_oper_port_state &= ~AD_STATE_COLLECTING;
+			port->actor_oper_port_state &= ~AD_STATE_DISTRIBUTING;
+			port->ntt = 1;
+			break;
+		case AD_MUX_WAITING:
+			port->sm_mux_timer_counter = __ad_timer_to_ticks(AD_WAIT_WHILE_TIMER, 0);
+			break;
+		case AD_MUX_ATTACHED:
+			__attach_bond_to_agg(port);
+			port->actor_oper_port_state |= AD_STATE_SYNCHRONIZATION;
+			port->actor_oper_port_state &= ~AD_STATE_COLLECTING;
+			port->actor_oper_port_state &= ~AD_STATE_DISTRIBUTING;
+			ad_disable_collecting_distributing(port);
+			port->ntt = 1;
+			break;
+		case AD_MUX_COLLECTING_DISTRIBUTING:
+			port->actor_oper_port_state |= AD_STATE_COLLECTING;
+			port->actor_oper_port_state |= AD_STATE_DISTRIBUTING;
+			ad_enable_collecting_distributing(port);
+			port->ntt = 1;
+			break;
+		default:    //to silence the compiler
+			break;
+		}
+	}
+}
+
+/**
+ * ad_rx_machine - handle a port's rx State Machine
+ * @lacpdu: the lacpdu we've received
+ * @port: the port we're looking at
+ *
+ * If lacpdu arrived, stop previous timer (if exists) and set the next state as
+ * CURRENT. If timer expired set the state machine in the proper state.
+ * In other cases, this function checks if we need to switch to other state.
+ */
+static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
+{
+	rx_states_t last_state;
+
+	// Lock to prevent 2 instances of this function to run simultaneously(rx interrupt and periodic machine callback)
+	__get_rx_machine_lock(port);
+
+	// keep current State Machine state to compare later if it was changed
+	last_state = port->sm_rx_state;
+
+	// check if state machine should change state
+	// first, check if port was reinitialized
+	if (port->sm_vars & AD_PORT_BEGIN) {
+		port->sm_rx_state = AD_RX_INITIALIZE;		    // next state
+	}
+	// check if port is not enabled
+	else if (!(port->sm_vars & AD_PORT_BEGIN) && !port->is_enabled && !(port->sm_vars & AD_PORT_MOVED)) {
+		port->sm_rx_state = AD_RX_PORT_DISABLED;	    // next state
+	}
+	// check if new lacpdu arrived
+	else if (lacpdu && ((port->sm_rx_state == AD_RX_EXPIRED) || (port->sm_rx_state == AD_RX_DEFAULTED) || (port->sm_rx_state == AD_RX_CURRENT))) {
+		port->sm_rx_timer_counter = 0; // zero timer
+		port->sm_rx_state = AD_RX_CURRENT;
+	} else {
+		// if timer is on, and if it is expired
+		if (port->sm_rx_timer_counter && !(--port->sm_rx_timer_counter)) {
+			switch (port->sm_rx_state) {
+			case AD_RX_EXPIRED:
+				port->sm_rx_state = AD_RX_DEFAULTED;		// next state
+				break;
+			case AD_RX_CURRENT:
+				port->sm_rx_state = AD_RX_EXPIRED;	    // next state
+				break;
+			default:    //to silence the compiler
+				break;
+			}
+		} else {
+			// if no lacpdu arrived and no timer is on
+			switch (port->sm_rx_state) {
+			case AD_RX_PORT_DISABLED:
+				if (port->sm_vars & AD_PORT_MOVED) {
+					port->sm_rx_state = AD_RX_INITIALIZE;	    // next state
+				} else if (port->is_enabled && (port->sm_vars & AD_PORT_LACP_ENABLED)) {
+					port->sm_rx_state = AD_RX_EXPIRED;	// next state
+				} else if (port->is_enabled && ((port->sm_vars & AD_PORT_LACP_ENABLED) == 0)) {
+					port->sm_rx_state = AD_RX_LACP_DISABLED;    // next state
+				}
+				break;
+			default:    //to silence the compiler
+				break;
+
+			}
+		}
+	}
+
+	// check if the State machine was changed or new lacpdu arrived
+	if ((port->sm_rx_state != last_state) || (lacpdu)) {
+		BOND_PRINT_DBG(("Rx Machine: Port=%d, Last State=%d, Curr State=%d", port->actor_port_number, last_state, port->sm_rx_state));
+		switch (port->sm_rx_state) {
+		case AD_RX_INITIALIZE:
+			if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS)) {
+				port->sm_vars &= ~AD_PORT_LACP_ENABLED;
+			} else {
+				port->sm_vars |= AD_PORT_LACP_ENABLED;
+			}
+			port->sm_vars &= ~AD_PORT_SELECTED;
+			__record_default(port);
+			port->actor_oper_port_state &= ~AD_STATE_EXPIRED;
+			port->sm_vars &= ~AD_PORT_MOVED;
+			port->sm_rx_state = AD_RX_PORT_DISABLED;	// next state
+
+			/*- Fall Through -*/
+
+		case AD_RX_PORT_DISABLED:
+			port->sm_vars &= ~AD_PORT_MATCHED;
+			break;
+		case AD_RX_LACP_DISABLED:
+			port->sm_vars &= ~AD_PORT_SELECTED;
+			__record_default(port);
+			port->partner_oper_port_state &= ~AD_STATE_AGGREGATION;
+			port->sm_vars |= AD_PORT_MATCHED;
+			port->actor_oper_port_state &= ~AD_STATE_EXPIRED;
+			break;
+		case AD_RX_EXPIRED:
+			//Reset of the Synchronization flag. (Standard 43.4.12)
+			//This reset cause to disable this port in the COLLECTING_DISTRIBUTING state of the
+			//mux machine in case of EXPIRED even if LINK_DOWN didn't arrive for the port.
+			port->partner_oper_port_state &= ~AD_STATE_SYNCHRONIZATION;
+			port->sm_vars &= ~AD_PORT_MATCHED;
+			port->partner_oper_port_state |= AD_SHORT_TIMEOUT;
+			port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(AD_SHORT_TIMEOUT));
+			port->actor_oper_port_state |= AD_STATE_EXPIRED;
+			break;
+		case AD_RX_DEFAULTED:
+			__update_default_selected(port);
+			__record_default(port);
+			port->sm_vars |= AD_PORT_MATCHED;
+			port->actor_oper_port_state &= ~AD_STATE_EXPIRED;
+			break;
+		case AD_RX_CURRENT:
+			// detect loopback situation
+			if (!MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->actor_system))) {
+				// INFO_RECEIVED_LOOPBACK_FRAMES
+				printk(KERN_ERR "bonding: An illegal loopback occurred on adapter (%s)\n",
+						port->slave->dev->name);
+				printk(KERN_ERR "Check the configuration to verify that all Adapters "
+						"are connected to 802.3ad compliant switch ports\n");
+				__release_rx_machine_lock(port);
+				return;
+			}
+			__update_selected(lacpdu, port);
+			__update_ntt(lacpdu, port);
+			__record_pdu(lacpdu, port);
+			__choose_matched(lacpdu, port);
+			port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(port->actor_oper_port_state & AD_STATE_LACP_TIMEOUT));
+			port->actor_oper_port_state &= ~AD_STATE_EXPIRED;
+			// verify that if the aggregator is enabled, the port is enabled too.
+			//(because if the link goes down for a short time, the 802.3ad will not
+			// catch it, and the port will continue to be disabled)
+			if (port->aggregator && port->aggregator->is_active && !__port_is_enabled(port)) {
+				__enable_port(port);
+			}
+			break;
+		default:    //to silence the compiler
+			break;
+		}
+	}
+	__release_rx_machine_lock(port);
+}
+
+/**
+ * ad_tx_machine - handle a port's tx state machine
+ * @port: the port we're looking at
+ *
+ */
+static void ad_tx_machine(struct port *port)
+{
+	// check if tx timer expired, to verify that we do not send more than 3 packets per second
+	if (port->sm_tx_timer_counter && !(--port->sm_tx_timer_counter)) {
+		// check if there is something to send
+		if (port->ntt && (port->sm_vars & AD_PORT_LACP_ENABLED)) {
+			__update_lacpdu_from_port(port);
+			// send the lacpdu
+			if (ad_lacpdu_send(port) >= 0) {
+				BOND_PRINT_DBG(("Sent LACPDU on port %d", port->actor_port_number));
+				// mark ntt as false, so it will not be sent again until demanded
+				port->ntt = 0;
+			}
+		}
+		// restart tx timer(to verify that we will not exceed AD_MAX_TX_IN_SECOND
+		port->sm_tx_timer_counter=ad_ticks_per_sec/AD_MAX_TX_IN_SECOND;
+	}
+}
+
+/**
+ * ad_periodic_machine - handle a port's periodic state machine
+ * @port: the port we're looking at
+ *
+ * Turn ntt flag on priodically to perform periodic transmission of lacpdu's.
+ */
+static void ad_periodic_machine(struct port *port)
+{
+	periodic_states_t last_state;
+
+	// keep current state machine state to compare later if it was changed
+	last_state = port->sm_periodic_state;
+
+	// check if port was reinitialized
+	if (((port->sm_vars & AD_PORT_BEGIN) || !(port->sm_vars & AD_PORT_LACP_ENABLED) || !port->is_enabled) ||
+	    (!(port->actor_oper_port_state & AD_STATE_LACP_ACTIVITY) && !(port->partner_oper_port_state & AD_STATE_LACP_ACTIVITY))
+	   ) {
+		port->sm_periodic_state = AD_NO_PERIODIC;	     // next state
+	}
+	// check if state machine should change state
+	else if (port->sm_periodic_timer_counter) {
+		// check if periodic state machine expired
+		if (!(--port->sm_periodic_timer_counter)) {
+			// if expired then do tx
+			port->sm_periodic_state = AD_PERIODIC_TX;    // next state
+		} else {
+			// If not expired, check if there is some new timeout parameter from the partner state
+			switch (port->sm_periodic_state) {
+			case AD_FAST_PERIODIC:
+				if (!(port->partner_oper_port_state & AD_STATE_LACP_TIMEOUT)) {
+					port->sm_periodic_state = AD_SLOW_PERIODIC;  // next state
+				}
+				break;
+			case AD_SLOW_PERIODIC:
+				if ((port->partner_oper_port_state & AD_STATE_LACP_TIMEOUT)) {
+					// stop current timer
+					port->sm_periodic_timer_counter = 0;
+					port->sm_periodic_state = AD_PERIODIC_TX;	 // next state
+				}
+				break;
+			default:    //to silence the compiler
+				break;
+			}
+		}
+	} else {
+		switch (port->sm_periodic_state) {
+		case AD_NO_PERIODIC:
+			port->sm_periodic_state = AD_FAST_PERIODIC;	 // next state
+			break;
+		case AD_PERIODIC_TX:
+			if (!(port->partner_oper_port_state & AD_STATE_LACP_TIMEOUT)) {
+				port->sm_periodic_state = AD_SLOW_PERIODIC;  // next state
+			} else {
+				port->sm_periodic_state = AD_FAST_PERIODIC;  // next state
+			}
+			break;
+		default:    //to silence the compiler
+			break;
+		}
+	}
+
+	// check if the state machine was changed
+	if (port->sm_periodic_state != last_state) {
+		BOND_PRINT_DBG(("Periodic Machine: Port=%d, Last State=%d, Curr State=%d", port->actor_port_number, last_state, port->sm_periodic_state));
+		switch (port->sm_periodic_state) {
+		case AD_NO_PERIODIC:
+			port->sm_periodic_timer_counter = 0;	   // zero timer
+			break;
+		case AD_FAST_PERIODIC:
+			port->sm_periodic_timer_counter = __ad_timer_to_ticks(AD_PERIODIC_TIMER, (u16)(AD_FAST_PERIODIC_TIME))-1; // decrement 1 tick we lost in the PERIODIC_TX cycle
+			break;
+		case AD_SLOW_PERIODIC:
+			port->sm_periodic_timer_counter = __ad_timer_to_ticks(AD_PERIODIC_TIMER, (u16)(AD_SLOW_PERIODIC_TIME))-1; // decrement 1 tick we lost in the PERIODIC_TX cycle
+			break;
+		case AD_PERIODIC_TX:
+			port->ntt = 1;
+			break;
+		default:    //to silence the compiler
+			break;
+		}
+	}
+}
+
+/**
+ * ad_port_selection_logic - select aggregation groups
+ * @port: the port we're looking at
+ *
+ * Select aggregation groups, and assign each port for it's aggregetor. The
+ * selection logic is called in the inititalization (after all the handshkes),
+ * and after every lacpdu receive (if selected is off).
+ */
+static void ad_port_selection_logic(struct port *port)
+{
+	struct aggregator *aggregator, *free_aggregator = NULL, *temp_aggregator;
+	struct port *last_port = NULL, *curr_port;
+	int found = 0;
+
+	// if the port is already Selected, do nothing
+	if (port->sm_vars & AD_PORT_SELECTED) {
+		return;
+	}
+
+	// if the port is connected to other aggregator, detach it
+	if (port->aggregator) {
+		// detach the port from its former aggregator
+		temp_aggregator=port->aggregator;
+		for (curr_port=temp_aggregator->lag_ports; curr_port; last_port=curr_port, curr_port=curr_port->next_port_in_aggregator) {
+			if (curr_port == port) {
+				temp_aggregator->num_of_ports--;
+				if (!last_port) {// if it is the first port attached to the aggregator
+					temp_aggregator->lag_ports=port->next_port_in_aggregator;
+				} else {// not the first port attached to the aggregator
+					last_port->next_port_in_aggregator=port->next_port_in_aggregator;
+				}
+
+				// clear the port's relations to this aggregator
+				port->aggregator = NULL;
+				port->next_port_in_aggregator=NULL;
+				port->actor_port_aggregator_identifier=0;
+
+				BOND_PRINT_DBG(("Port %d left LAG %d", port->actor_port_number, temp_aggregator->aggregator_identifier));
+				// if the aggregator is empty, clear its parameters, and set it ready to be attached
+				if (!temp_aggregator->lag_ports) {
+					ad_clear_agg(temp_aggregator);
+				}
+				break;
+			}
+		}
+		if (!curr_port) { // meaning: the port was related to an aggregator but was not on the aggregator port list
+			printk(KERN_WARNING "bonding: Warning: Port %d (on %s) was "
+			       "related to aggregator %d but was not on its port list\n",
+			       port->actor_port_number, port->slave->dev->name,
+			       port->aggregator->aggregator_identifier);
+		}
+	}
+	// search on all aggregators for a suitable aggregator for this port
+	for (aggregator = __get_first_agg(port); aggregator;
+	     aggregator = __get_next_agg(aggregator)) {
+
+		// keep a free aggregator for later use(if needed)
+		if (!aggregator->lag_ports) {
+			if (!free_aggregator) {
+				free_aggregator=aggregator;
+			}
+			continue;
+		}
+		// check if current aggregator suits us
+		if (((aggregator->actor_oper_aggregator_key == port->actor_oper_port_key) && // if all parameters match AND
+		     !MAC_ADDRESS_COMPARE(&(aggregator->partner_system), &(port->partner_oper_system)) &&
+		     (aggregator->partner_system_priority == port->partner_oper_system_priority) &&
+		     (aggregator->partner_oper_aggregator_key == port->partner_oper_key)
+		    ) &&
+		    ((MAC_ADDRESS_COMPARE(&(port->partner_oper_system), &(null_mac_addr)) && // partner answers
+		      !aggregator->is_individual)  // but is not individual OR
+		    )
+		   ) {
+			// attach to the founded aggregator
+			port->aggregator = aggregator;
+			port->actor_port_aggregator_identifier=port->aggregator->aggregator_identifier;
+			port->next_port_in_aggregator=aggregator->lag_ports;
+			port->aggregator->num_of_ports++;
+			aggregator->lag_ports=port;
+			BOND_PRINT_DBG(("Port %d joined LAG %d(existing LAG)", port->actor_port_number, port->aggregator->aggregator_identifier));
+
+			// mark this port as selected
+			port->sm_vars |= AD_PORT_SELECTED;
+			found = 1;
+			break;
+		}
+	}
+
+	// the port couldn't find an aggregator - attach it to a new aggregator
+	if (!found) {
+		if (free_aggregator) {
+			// assign port a new aggregator
+			port->aggregator = free_aggregator;
+			port->actor_port_aggregator_identifier=port->aggregator->aggregator_identifier;
+
+			// update the new aggregator's parameters
+			// if port was responsed from the end-user
+			if (port->actor_oper_port_key & AD_DUPLEX_KEY_BITS) {// if port is full duplex
+				port->aggregator->is_individual = 0;
+			} else {
+				port->aggregator->is_individual = 1;
+			}
+
+			port->aggregator->actor_admin_aggregator_key = port->actor_admin_port_key;
+			port->aggregator->actor_oper_aggregator_key = port->actor_oper_port_key;
+			port->aggregator->partner_system=port->partner_oper_system;
+			port->aggregator->partner_system_priority = port->partner_oper_system_priority;
+			port->aggregator->partner_oper_aggregator_key = port->partner_oper_key;
+			port->aggregator->receive_state = 1;
+			port->aggregator->transmit_state = 1;
+			port->aggregator->lag_ports = port;
+			port->aggregator->num_of_ports++;
+
+			// mark this port as selected
+			port->sm_vars |= AD_PORT_SELECTED;
+
+			BOND_PRINT_DBG(("Port %d joined LAG %d(new LAG)", port->actor_port_number, port->aggregator->aggregator_identifier));
+		} else {
+			printk(KERN_ERR "bonding: Port %d (on %s) did not find a suitable aggregator\n",
+			       port->actor_port_number, port->slave->dev->name);
+		}
+	}
+	// if all aggregator's ports are READY_N == TRUE, set ready=TRUE in all aggregator's ports
+	// else set ready=FALSE in all aggregator's ports
+	__set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator));
+
+	if (!__check_agg_selection_timer(port) && (aggregator = __get_first_agg(port))) {
+		ad_agg_selection_logic(aggregator);
+	}
+}
+
+/**
+ * ad_agg_selection_logic - select an aggregation group for a team
+ * @aggregator: the aggregator we're looking at
+ *
+ * It is assumed that only one aggregator may be selected for a team.
+ * The logic of this function is to select (at first time) the aggregator with
+ * the most ports attached to it, and to reselect the active aggregator only if
+ * the previous aggregator has no more ports related to it.
+ *
+ * FIXME: this function MUST be called with the first agg in the bond, or
+ * __get_active_agg() won't work correctly. This function should be better
+ * called with the bond itself, and retrieve the first agg from it.
+ */
+static void ad_agg_selection_logic(struct aggregator *aggregator)
+{
+	struct aggregator *best_aggregator = NULL, *active_aggregator = NULL;
+	struct aggregator *last_active_aggregator = NULL, *origin_aggregator;
+	struct port *port;
+	u16 num_of_aggs=0;
+
+	origin_aggregator = aggregator;
+
+	//get current active aggregator
+	last_active_aggregator = __get_active_agg(aggregator);
+
+	// search for the aggregator with the most ports attached to it.
+	do {
+		// count how many candidate lag's we have
+		if (aggregator->lag_ports) {
+			num_of_aggs++;
+		}
+		if (aggregator->is_active && !aggregator->is_individual &&   // if current aggregator is the active aggregator
+		    MAC_ADDRESS_COMPARE(&(aggregator->partner_system), &(null_mac_addr))) {   // and partner answers to 802.3ad PDUs
+			if (aggregator->num_of_ports) {	// if any ports attached to the current aggregator
+				best_aggregator=NULL;	 // disregard the best aggregator that was chosen by now
+				break;		 // stop the selection of other aggregator if there are any ports attached to this active aggregator
+			} else { // no ports attached to this active aggregator
+				aggregator->is_active = 0; // mark this aggregator as not active anymore
+			}
+		}
+		if (aggregator->num_of_ports) {	// if any ports attached
+			if (best_aggregator) {	// if there is a candidte aggregator
+				//The reasons for choosing new best aggregator:
+				// 1. if current agg is NOT individual and the best agg chosen so far is individual OR
+				// current and best aggs are both individual or both not individual, AND
+				// 2a.  current agg partner reply but best agg partner do not reply OR
+				// 2b.  current agg partner reply OR current agg partner do not reply AND best agg partner also do not reply AND
+				//      current has more ports/bandwidth, or same amount of ports but current has faster ports, THEN
+				//      current agg become best agg so far
+
+				//if current agg is NOT individual and the best agg chosen so far is individual change best_aggregator
+				if (!aggregator->is_individual && best_aggregator->is_individual) {
+					best_aggregator=aggregator;
+				}
+				// current and best aggs are both individual or both not individual
+				else if ((aggregator->is_individual && best_aggregator->is_individual) ||
+					 (!aggregator->is_individual && !best_aggregator->is_individual)) {
+					//  current and best aggs are both individual or both not individual AND
+					//  current agg partner reply but best agg partner do not reply
+					if ((MAC_ADDRESS_COMPARE(&(aggregator->partner_system), &(null_mac_addr)) &&
+					     !MAC_ADDRESS_COMPARE(&(best_aggregator->partner_system), &(null_mac_addr)))) {
+						best_aggregator=aggregator;
+					}
+					//  current agg partner reply OR current agg partner do not reply AND best agg partner also do not reply
+					else if (! (!MAC_ADDRESS_COMPARE(&(aggregator->partner_system), &(null_mac_addr)) &&
+						    MAC_ADDRESS_COMPARE(&(best_aggregator->partner_system), &(null_mac_addr)))) {
+						if ((__get_agg_selection_mode(aggregator->lag_ports) == AD_BANDWIDTH)&&
+						    (__get_agg_bandwidth(aggregator) > __get_agg_bandwidth(best_aggregator))) {
+							best_aggregator=aggregator;
+						} else if (__get_agg_selection_mode(aggregator->lag_ports) == AD_COUNT) {
+							if (((aggregator->num_of_ports > best_aggregator->num_of_ports) &&
+							     (aggregator->actor_oper_aggregator_key & AD_SPEED_KEY_BITS))||
+							    ((aggregator->num_of_ports == best_aggregator->num_of_ports) &&
+							     ((u16)(aggregator->actor_oper_aggregator_key & AD_SPEED_KEY_BITS) >
+							      (u16)(best_aggregator->actor_oper_aggregator_key & AD_SPEED_KEY_BITS)))) {
+								best_aggregator=aggregator;
+							}
+						}
+					}
+				}
+			} else {
+				best_aggregator=aggregator;
+			}
+		}
+		aggregator->is_active = 0; // mark all aggregators as not active anymore
+	} while ((aggregator = __get_next_agg(aggregator)));
+
+	// if we have new aggregator selected, don't replace the old aggregator if it has an answering partner,
+	// or if both old aggregator and new aggregator don't have answering partner
+	if (best_aggregator) {
+		if (last_active_aggregator && last_active_aggregator->lag_ports && last_active_aggregator->lag_ports->is_enabled &&
+		    (MAC_ADDRESS_COMPARE(&(last_active_aggregator->partner_system), &(null_mac_addr)) ||   // partner answers OR
+		     (!MAC_ADDRESS_COMPARE(&(last_active_aggregator->partner_system), &(null_mac_addr)) &&	// both old and new
+		      !MAC_ADDRESS_COMPARE(&(best_aggregator->partner_system), &(null_mac_addr))))     // partner do not answer
+		   ) {
+			// if new aggregator has link, and old aggregator does not, replace old aggregator.(do nothing)
+			// -> don't replace otherwise.
+			if (!(!last_active_aggregator->actor_oper_aggregator_key && best_aggregator->actor_oper_aggregator_key)) {
+				best_aggregator=NULL;
+				last_active_aggregator->is_active = 1; // don't replace good old aggregator
+
+			}
+		}
+	}
+
+	// if there is new best aggregator, activate it
+	if (best_aggregator) {
+		for (aggregator = __get_first_agg(best_aggregator->lag_ports);
+		    aggregator;
+		    aggregator = __get_next_agg(aggregator)) {
+
+			BOND_PRINT_DBG(("Agg=%d; Ports=%d; a key=%d; p key=%d; Indiv=%d; Active=%d",
+					aggregator->aggregator_identifier, aggregator->num_of_ports,
+					aggregator->actor_oper_aggregator_key, aggregator->partner_oper_aggregator_key,
+					aggregator->is_individual, aggregator->is_active));
+		}
+
+		// check if any partner replys
+		if (best_aggregator->is_individual) {
+			printk(KERN_WARNING "bonding: Warning: No 802.3ad response from the link partner "
+					"for any adapters in the bond\n");
+		}
+
+		// check if there are more than one aggregator
+		if (num_of_aggs > 1) {
+			BOND_PRINT_DBG(("Warning: More than one Link Aggregation Group was "
+					"found in the bond. Only one group will function in the bond"));
+		}
+
+		best_aggregator->is_active = 1;
+		BOND_PRINT_DBG(("LAG %d choosed as the active LAG", best_aggregator->aggregator_identifier));
+		BOND_PRINT_DBG(("Agg=%d; Ports=%d; a key=%d; p key=%d; Indiv=%d; Active=%d",
+				best_aggregator->aggregator_identifier, best_aggregator->num_of_ports,
+				best_aggregator->actor_oper_aggregator_key, best_aggregator->partner_oper_aggregator_key,
+				best_aggregator->is_individual, best_aggregator->is_active));
+
+		// disable the ports that were related to the former active_aggregator
+		if (last_active_aggregator) {
+			for (port=last_active_aggregator->lag_ports; port; port=port->next_port_in_aggregator) {
+				__disable_port(port);
+			}
+		}
+	}
+
+	// if the selected aggregator is of join individuals(partner_system is NULL), enable their ports
+	active_aggregator = __get_active_agg(origin_aggregator);
+
+	if (active_aggregator) {
+		if (!MAC_ADDRESS_COMPARE(&(active_aggregator->partner_system), &(null_mac_addr))) {
+			for (port=active_aggregator->lag_ports; port; port=port->next_port_in_aggregator) {
+				__enable_port(port);
+			}
+		}
+	}
+}
+
+/**
+ * ad_clear_agg - clear a given aggregator's parameters
+ * @aggregator: the aggregator we're looking at
+ *
+ */
+static void ad_clear_agg(struct aggregator *aggregator)
+{
+	if (aggregator) {
+		aggregator->is_individual = 0;
+		aggregator->actor_admin_aggregator_key = 0;
+		aggregator->actor_oper_aggregator_key = 0;
+		aggregator->partner_system = null_mac_addr;
+		aggregator->partner_system_priority = 0;
+		aggregator->partner_oper_aggregator_key = 0;
+		aggregator->receive_state = 0;
+		aggregator->transmit_state = 0;
+		aggregator->lag_ports = NULL;
+		aggregator->is_active = 0;
+		aggregator->num_of_ports = 0;
+		BOND_PRINT_DBG(("LAG %d was cleared", aggregator->aggregator_identifier));
+	}
+}
+
+/**
+ * ad_initialize_agg - initialize a given aggregator's parameters
+ * @aggregator: the aggregator we're looking at
+ *
+ */
+static void ad_initialize_agg(struct aggregator *aggregator)
+{
+	if (aggregator) {
+		ad_clear_agg(aggregator);
+
+		aggregator->aggregator_mac_address = null_mac_addr;
+		aggregator->aggregator_identifier = 0;
+		aggregator->slave = NULL;
+	}
+}
+
+/**
+ * ad_initialize_port - initialize a given port's parameters
+ * @aggregator: the aggregator we're looking at
+ * @lacp_fast: boolean. whether fast periodic should be used
+ *
+ */
+static void ad_initialize_port(struct port *port, int lacp_fast)
+{
+	if (port) {
+		port->actor_port_number = 1;
+		port->actor_port_priority = 0xff;
+		port->actor_system = null_mac_addr;
+		port->actor_system_priority = 0xffff;
+		port->actor_port_aggregator_identifier = 0;
+		port->ntt = 0;
+		port->actor_admin_port_key = 1;
+		port->actor_oper_port_key  = 1;
+		port->actor_admin_port_state = AD_STATE_AGGREGATION | AD_STATE_LACP_ACTIVITY;
+		port->actor_oper_port_state  = AD_STATE_AGGREGATION | AD_STATE_LACP_ACTIVITY;
+
+		if (lacp_fast) {
+			port->actor_oper_port_state |= AD_STATE_LACP_TIMEOUT;
+		}
+
+		port->partner_admin_system = null_mac_addr;
+		port->partner_oper_system  = null_mac_addr;
+		port->partner_admin_system_priority = 0xffff;
+		port->partner_oper_system_priority  = 0xffff;
+		port->partner_admin_key = 1;
+		port->partner_oper_key  = 1;
+		port->partner_admin_port_number = 1;
+		port->partner_oper_port_number  = 1;
+		port->partner_admin_port_priority = 0xff;
+		port->partner_oper_port_priority  = 0xff;
+		port->partner_admin_port_state = 1;
+		port->partner_oper_port_state  = 1;
+		port->is_enabled = 1;
+		// ****** private parameters ******
+		port->sm_vars = 0x3;
+		port->sm_rx_state = 0;
+		port->sm_rx_timer_counter = 0;
+		port->sm_periodic_state = 0;
+		port->sm_periodic_timer_counter = 0;
+		port->sm_mux_state = 0;
+		port->sm_mux_timer_counter = 0;
+		port->sm_tx_state = 0;
+		port->sm_tx_timer_counter = 0;
+		port->slave = NULL;
+		port->aggregator = NULL;
+		port->next_port_in_aggregator = NULL;
+		port->transaction_id = 0;
+
+		ad_initialize_lacpdu(&(port->lacpdu));
+	}
+}
+
+/**
+ * ad_enable_collecting_distributing - enable a port's transmit/receive
+ * @port: the port we're looking at
+ *
+ * Enable @port if it's in an active aggregator
+ */
+static void ad_enable_collecting_distributing(struct port *port)
+{
+	if (port->aggregator->is_active) {
+		BOND_PRINT_DBG(("Enabling port %d(LAG %d)", port->actor_port_number, port->aggregator->aggregator_identifier));
+		__enable_port(port);
+	}
+}
+
+/**
+ * ad_disable_collecting_distributing - disable a port's transmit/receive
+ * @port: the port we're looking at
+ *
+ */
+static void ad_disable_collecting_distributing(struct port *port)
+{
+	if (port->aggregator && MAC_ADDRESS_COMPARE(&(port->aggregator->partner_system), &(null_mac_addr))) {
+		BOND_PRINT_DBG(("Disabling port %d(LAG %d)", port->actor_port_number, port->aggregator->aggregator_identifier));
+		__disable_port(port);
+	}
+}
+
+#if 0
+/**
+ * ad_marker_info_send - send a marker information frame
+ * @port: the port we're looking at
+ *
+ * This function does nothing since we decided not to implement send and handle
+ * response for marker PDU's, in this stage, but only to respond to marker
+ * information.
+ */
+static void ad_marker_info_send(struct port *port)
+{
+	struct marker marker;
+	u16 index;
+
+	// fill the marker PDU with the appropriate values
+	marker.subtype = 0x02;
+	marker.version_number = 0x01;
+	marker.tlv_type = AD_MARKER_INFORMATION_SUBTYPE;
+	marker.marker_length = 0x16;
+	// convert requester_port to Big Endian
+	marker.requester_port = (((port->actor_port_number & 0xFF) << 8) |((u16)(port->actor_port_number & 0xFF00) >> 8));
+	marker.requester_system = port->actor_system;
+	// convert requester_port(u32) to Big Endian
+	marker.requester_transaction_id = (((++port->transaction_id & 0xFF) << 24) |((port->transaction_id & 0xFF00) << 8) |((port->transaction_id & 0xFF0000) >> 8) |((port->transaction_id & 0xFF000000) >> 24));
+	marker.pad = 0;
+	marker.tlv_type_terminator = 0x00;
+	marker.terminator_length = 0x00;
+	for (index=0; index<90; index++) {
+		marker.reserved_90[index]=0;
+	}
+
+	// send the marker information
+	if (ad_marker_send(port, &marker) >= 0) {
+		BOND_PRINT_DBG(("Sent Marker Information on port %d", port->actor_port_number));
+	}
+}
+#endif
+
+/**
+ * ad_marker_info_received - handle receive of a Marker information frame
+ * @marker_info: Marker info received
+ * @port: the port we're looking at
+ *
+ */
+static void ad_marker_info_received(struct marker *marker_info,struct port *port)
+{
+	struct marker marker;
+
+	// copy the received marker data to the response marker
+	//marker = *marker_info;
+	memcpy(&marker, marker_info, sizeof(struct marker));
+	// change the marker subtype to marker response
+	marker.tlv_type=AD_MARKER_RESPONSE_SUBTYPE;
+	// send the marker response
+
+	if (ad_marker_send(port, &marker) >= 0) {
+		BOND_PRINT_DBG(("Sent Marker Response on port %d", port->actor_port_number));
+	}
+}
+
+/**
+ * ad_marker_response_received - handle receive of a marker response frame
+ * @marker: marker PDU received
+ * @port: the port we're looking at
+ *
+ * This function does nothing since we decided not to implement send and handle
+ * response for marker PDU's, in this stage, but only to respond to marker
+ * information.
+ */
+static void ad_marker_response_received(struct marker *marker, struct port *port)
+{
+	marker=NULL; // just to satisfy the compiler
+	port=NULL;  // just to satisfy the compiler
+	// DO NOTHING, SINCE WE DECIDED NOT TO IMPLEMENT THIS FEATURE FOR NOW
+}
+
+/**
+ * ad_initialize_lacpdu - initialize a given lacpdu structure
+ * @lacpdu: lacpdu structure to initialize
+ *
+ */
+static void ad_initialize_lacpdu(struct lacpdu *lacpdu)
+{
+	u16 index;
+
+	// initialize lacpdu data
+	lacpdu->subtype = 0x01;
+	lacpdu->version_number = 0x01;
+	lacpdu->tlv_type_actor_info = 0x01;
+	lacpdu->actor_information_length = 0x14;
+	// lacpdu->actor_system_priority    updated on send
+	// lacpdu->actor_system             updated on send
+	// lacpdu->actor_key                updated on send
+	// lacpdu->actor_port_priority      updated on send
+	// lacpdu->actor_port               updated on send
+	// lacpdu->actor_state              updated on send
+	lacpdu->tlv_type_partner_info = 0x02;
+	lacpdu->partner_information_length = 0x14;
+	for (index=0; index<=2; index++) {
+		lacpdu->reserved_3_1[index]=0;
+	}
+	// lacpdu->partner_system_priority  updated on send
+	// lacpdu->partner_system           updated on send
+	// lacpdu->partner_key              updated on send
+	// lacpdu->partner_port_priority    updated on send
+	// lacpdu->partner_port             updated on send
+	// lacpdu->partner_state            updated on send
+	for (index=0; index<=2; index++) {
+		lacpdu->reserved_3_2[index]=0;
+	}
+	lacpdu->tlv_type_collector_info = 0x03;
+	lacpdu->collector_information_length= 0x10;
+	lacpdu->collector_max_delay = AD_COLLECTOR_MAX_DELAY;
+	for (index=0; index<=11; index++) {
+		lacpdu->reserved_12[index]=0;
+	}
+	lacpdu->tlv_type_terminator = 0x00;
+	lacpdu->terminator_length = 0;
+	for (index=0; index<=49; index++) {
+		lacpdu->reserved_50[index]=0;
+	}
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+// ================= AD exported functions to the main bonding code ==================
+//////////////////////////////////////////////////////////////////////////////////////
+
+// Check aggregators status in team every T seconds
+#define AD_AGGREGATOR_SELECTION_TIMER  8
+
+static u16 aggregator_identifier;
+
+/**
+ * bond_3ad_initialize - initialize a bond's 802.3ad parameters and structures
+ * @bond: bonding struct to work on
+ * @tick_resolution: tick duration (millisecond resolution)
+ * @lacp_fast: boolean. whether fast periodic should be used
+ *
+ * Can be called only after the mac address of the bond is set.
+ */
+void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution, int lacp_fast)
+{                         
+	// check that the bond is not initialized yet
+	if (MAC_ADDRESS_COMPARE(&(BOND_AD_INFO(bond).system.sys_mac_addr), &(bond->device->dev_addr))) {
+
+		aggregator_identifier = 0;
+
+		BOND_AD_INFO(bond).lacp_fast = lacp_fast;
+		BOND_AD_INFO(bond).system.sys_priority = 0xFFFF;
+		BOND_AD_INFO(bond).system.sys_mac_addr = *((struct mac_addr *)bond->device->dev_addr);
+
+		// initialize how many times this module is called in one second(should be about every 100ms)
+		ad_ticks_per_sec = tick_resolution;
+
+		// initialize the aggregator selection timer(to activate an aggregation selection after initialize)
+		BOND_AD_INFO(bond).agg_select_timer = (AD_AGGREGATOR_SELECTION_TIMER * ad_ticks_per_sec);
+		BOND_AD_INFO(bond).agg_select_mode = AD_BANDWIDTH;
+	}
+}
+
+/**
+ * bond_3ad_bind_slave - initialize a slave's port
+ * @slave: slave struct to work on
+ *
+ * Returns:   0 on success
+ *          < 0 on error
+ */
+int bond_3ad_bind_slave(struct slave *slave)
+{
+	struct bonding *bond = bond_get_bond_by_slave(slave);
+	struct port *port;
+	struct aggregator *aggregator;
+
+	if (bond == NULL) {
+		printk(KERN_CRIT "The slave %s is not attached to its bond\n", slave->dev->name);
+		return -1;
+	}
+
+	//check that the slave has not been intialized yet.
+	if (SLAVE_AD_INFO(slave).port.slave != slave) {
+
+		// port initialization
+		port = &(SLAVE_AD_INFO(slave).port);
+
+		ad_initialize_port(port, BOND_AD_INFO(bond).lacp_fast);
+
+		port->slave = slave;
+		port->actor_port_number = SLAVE_AD_INFO(slave).id;
+		// key is determined according to the link speed, duplex and user key(which is yet not supported)
+		//              ------------------------------------------------------------
+		// Port key :   | User key                       |      Speed       |Duplex|
+		//              ------------------------------------------------------------
+		//              16                               6               1 0
+		port->actor_admin_port_key = 0;	// initialize this parameter
+		port->actor_admin_port_key |= __get_duplex(port);
+		port->actor_admin_port_key |= (__get_link_speed(port) << 1);
+		port->actor_oper_port_key = port->actor_admin_port_key;
+		// if the port is not full duplex, then the port should be not lacp Enabled
+		if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS)) {
+			port->sm_vars &= ~AD_PORT_LACP_ENABLED;
+		}
+		// actor system is the bond's system
+		port->actor_system = BOND_AD_INFO(bond).system.sys_mac_addr;
+		// tx timer(to verify that no more than MAX_TX_IN_SECOND lacpdu's are sent in one second)
+		port->sm_tx_timer_counter = ad_ticks_per_sec/AD_MAX_TX_IN_SECOND;
+		port->aggregator = NULL;
+		port->next_port_in_aggregator = NULL;
+
+		__disable_port(port);
+		__initialize_port_locks(port);
+
+
+		// aggregator initialization
+		aggregator = &(SLAVE_AD_INFO(slave).aggregator);
+
+		ad_initialize_agg(aggregator);
+
+		aggregator->aggregator_mac_address = *((struct mac_addr *)bond->device->dev_addr);
+		aggregator->aggregator_identifier = (++aggregator_identifier);
+		aggregator->slave = slave;
+		aggregator->is_active = 0;
+		aggregator->num_of_ports = 0;
+	}
+
+	return 0;
+}
+
+/**
+ * bond_3ad_unbind_slave - deinitialize a slave's port
+ * @slave: slave struct to work on
+ *
+ * Search for the aggregator that is related to this port, remove the
+ * aggregator and assign another aggregator for other port related to it
+ * (if any), and remove the port.
+ */
+void bond_3ad_unbind_slave(struct slave *slave)
+{
+	struct port *port, *prev_port, *temp_port;
+	struct aggregator *aggregator, *new_aggregator, *temp_aggregator;
+	int select_new_active_agg = 0;
+	
+	// find the aggregator related to this slave
+	aggregator = &(SLAVE_AD_INFO(slave).aggregator);
+
+	// find the port related to this slave
+	port = &(SLAVE_AD_INFO(slave).port);
+
+	// if slave is null, the whole port is not initialized
+	if (!port->slave) {
+		printk(KERN_WARNING "bonding: Trying to unbind an uninitialized port on %s\n", slave->dev->name);
+		return;
+	}
+
+	BOND_PRINT_DBG(("Unbinding Link Aggregation Group %d", aggregator->aggregator_identifier));
+
+	/* Tell the partner that this port is not suitable for aggregation */
+	port->actor_oper_port_state &= ~AD_STATE_AGGREGATION;
+	__update_lacpdu_from_port(port);
+	ad_lacpdu_send(port);
+
+	// check if this aggregator is occupied
+	if (aggregator->lag_ports) {
+		// check if there are other ports related to this aggregator except
+		// the port related to this slave(thats ensure us that there is a
+		// reason to search for new aggregator, and that we will find one
+		if ((aggregator->lag_ports != port) || (aggregator->lag_ports->next_port_in_aggregator)) {
+			// find new aggregator for the related port(s)
+			new_aggregator = __get_first_agg(port);
+			for (; new_aggregator; new_aggregator = __get_next_agg(new_aggregator)) {
+				// if the new aggregator is empty, or it connected to to our port only
+				if (!new_aggregator->lag_ports || ((new_aggregator->lag_ports == port) && !new_aggregator->lag_ports->next_port_in_aggregator)) {
+					break;
+				}
+			}
+			// if new aggregator found, copy the aggregator's parameters
+			// and connect the related lag_ports to the new aggregator
+			if ((new_aggregator) && ((!new_aggregator->lag_ports) || ((new_aggregator->lag_ports == port) && !new_aggregator->lag_ports->next_port_in_aggregator))) {
+				BOND_PRINT_DBG(("Some port(s) related to LAG %d - replaceing with LAG %d", aggregator->aggregator_identifier, new_aggregator->aggregator_identifier));
+
+				if ((new_aggregator->lag_ports == port) && new_aggregator->is_active) {
+					printk(KERN_INFO "bonding: Removing an active aggregator\n");
+					// select new active aggregator
+					 select_new_active_agg = 1;
+				}
+
+				new_aggregator->is_individual = aggregator->is_individual;
+				new_aggregator->actor_admin_aggregator_key = aggregator->actor_admin_aggregator_key;
+				new_aggregator->actor_oper_aggregator_key = aggregator->actor_oper_aggregator_key;
+				new_aggregator->partner_system = aggregator->partner_system;
+				new_aggregator->partner_system_priority = aggregator->partner_system_priority;
+				new_aggregator->partner_oper_aggregator_key = aggregator->partner_oper_aggregator_key;
+				new_aggregator->receive_state = aggregator->receive_state;
+				new_aggregator->transmit_state = aggregator->transmit_state;
+				new_aggregator->lag_ports = aggregator->lag_ports;
+				new_aggregator->is_active = aggregator->is_active;
+				new_aggregator->num_of_ports = aggregator->num_of_ports;
+
+				// update the information that is written on the ports about the aggregator
+				for (temp_port=aggregator->lag_ports; temp_port; temp_port=temp_port->next_port_in_aggregator) {
+					temp_port->aggregator=new_aggregator;
+					temp_port->actor_port_aggregator_identifier = new_aggregator->aggregator_identifier;
+				}
+
+				// clear the aggregator
+				ad_clear_agg(aggregator);
+				
+				if (select_new_active_agg) {
+					ad_agg_selection_logic(__get_first_agg(port));
+				}
+			} else {
+				printk(KERN_WARNING "bonding: Warning: unbinding aggregator, "
+				       "and could not find a new aggregator for its ports\n");
+			}
+		} else { // in case that the only port related to this aggregator is the one we want to remove
+			select_new_active_agg = aggregator->is_active;
+			// clear the aggregator
+			ad_clear_agg(aggregator);
+			if (select_new_active_agg) {
+				printk(KERN_INFO "Removing an active aggregator\n");
+				// select new active aggregator
+				ad_agg_selection_logic(__get_first_agg(port));
+			}
+		}
+	}
+
+	BOND_PRINT_DBG(("Unbinding port %d", port->actor_port_number));
+	// find the aggregator that this port is connected to
+	temp_aggregator = __get_first_agg(port);
+	for (; temp_aggregator; temp_aggregator = __get_next_agg(temp_aggregator)) {
+		prev_port = NULL;
+		// search the port in the aggregator's related ports
+		for (temp_port=temp_aggregator->lag_ports; temp_port; prev_port=temp_port, temp_port=temp_port->next_port_in_aggregator) {
+			if (temp_port == port) { // the aggregator found - detach the port from this aggregator
+				if (prev_port) {
+					prev_port->next_port_in_aggregator = temp_port->next_port_in_aggregator;
+				} else {
+					temp_aggregator->lag_ports = temp_port->next_port_in_aggregator;
+				}
+				temp_aggregator->num_of_ports--;
+				if (temp_aggregator->num_of_ports==0) {
+					select_new_active_agg = temp_aggregator->is_active;
+					// clear the aggregator
+					ad_clear_agg(temp_aggregator);
+					if (select_new_active_agg) {
+						printk(KERN_INFO "Removing an active aggregator\n");
+						// select new active aggregator
+						ad_agg_selection_logic(__get_first_agg(port));
+					}
+				}
+				break;
+			}
+		}
+	}
+	port->slave=NULL;	
+}
+
+/**
+ * bond_3ad_state_machine_handler - handle state machines timeout
+ * @bond: bonding struct to work on
+ *
+ * The state machine handling concept in this module is to check every tick
+ * which state machine should operate any function. The execution order is
+ * round robin, so when we have an interaction between state machines, the
+ * reply of one to each other might be delayed until next tick.
+ *
+ * This function also complete the initialization when the agg_select_timer
+ * times out, and it selects an aggregator for the ports that are yet not
+ * related to any aggregator, and selects the active aggregator for a bond.
+ */
+void bond_3ad_state_machine_handler(struct bonding *bond)
+{
+	struct port *port;
+	struct aggregator *aggregator;
+
+	read_lock(&bond->lock);
+
+	//check if there are any slaves
+	if (bond->next == (struct slave *)bond) {
+		goto end;
+	}
+
+	if ((bond->device->flags & IFF_UP) != IFF_UP) {
+		goto end;
+	}
+
+	// check if agg_select_timer timer after initialize is timed out
+	if (BOND_AD_INFO(bond).agg_select_timer && !(--BOND_AD_INFO(bond).agg_select_timer)) {
+		// select the active aggregator for the bond
+		if ((port = __get_first_port(bond))) {
+			if (!port->slave) {
+				printk(KERN_WARNING "bonding: Warning: bond's first port is uninitialized\n");
+				goto end;
+			}
+
+			aggregator = __get_first_agg(port);
+			ad_agg_selection_logic(aggregator);
+		}
+	}
+
+	// for each port run the state machines
+	for (port = __get_first_port(bond); port; port = __get_next_port(port)) {
+		if (!port->slave) {
+			printk(KERN_WARNING "bonding: Warning: Found an uninitialized port\n");
+			goto end;
+		}
+
+		ad_rx_machine(NULL, port);
+		ad_periodic_machine(port);
+		ad_port_selection_logic(port);
+		ad_mux_machine(port);
+		ad_tx_machine(port);
+
+		// turn off the BEGIN bit, since we already handled it
+		if (port->sm_vars & AD_PORT_BEGIN) {
+			port->sm_vars &= ~AD_PORT_BEGIN;
+		}
+	}
+
+end:
+	read_unlock(&bond->lock);
+
+
+	if ((bond->device->flags & IFF_UP) == IFF_UP) {
+		/* re-arm the timer */
+		mod_timer(&(BOND_AD_INFO(bond).ad_timer), jiffies + (AD_TIMER_INTERVAL * HZ / 1000));
+	}
+}
+
+/**
+ * bond_3ad_rx_indication - handle a received frame
+ * @lacpdu: received lacpdu
+ * @slave: slave struct to work on
+ * @length: length of the data received
+ *
+ * It is assumed that frames that were sent on this NIC don't returned as new
+ * received frames (loopback). Since only the payload is given to this
+ * function, it check for loopback.
+ */
+void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u16 length)
+{
+	struct port *port;
+
+	if (length >= sizeof(struct lacpdu)) {
+
+		port = &(SLAVE_AD_INFO(slave).port);
+
+		if (!port->slave) {
+			printk(KERN_WARNING "bonding: Warning: port of slave %s is uninitialized\n", slave->dev->name);
+			return;
+		}
+
+		switch (lacpdu->subtype) {
+		case AD_TYPE_LACPDU:
+			__ntohs_lacpdu(lacpdu);
+			BOND_PRINT_DBG(("Received LACPDU on port %d", port->actor_port_number));
+			ad_rx_machine(lacpdu, port);
+			break;
+
+		case AD_TYPE_MARKER:
+			// No need to convert fields to Little Endian since we don't use the marker's fields.
+
+			switch (((struct marker *)lacpdu)->tlv_type) {
+			case AD_MARKER_INFORMATION_SUBTYPE:
+				BOND_PRINT_DBG(("Received Marker Information on port %d", port->actor_port_number));
+				ad_marker_info_received((struct marker *)lacpdu, port);
+				break;
+
+			case AD_MARKER_RESPONSE_SUBTYPE:
+				BOND_PRINT_DBG(("Received Marker Response on port %d", port->actor_port_number));
+				ad_marker_response_received((struct marker *)lacpdu, port);
+				break;
+
+			default:
+				BOND_PRINT_DBG(("Received an unknown Marker subtype on slot %d", port->actor_port_number));
+			}
+		}
+	}
+}
+
+/**
+ * bond_3ad_adapter_speed_changed - handle a slave's speed change indication
+ * @slave: slave struct to work on
+ *
+ * Handle reselection of aggregator (if needed) for this port.
+ */
+void bond_3ad_adapter_speed_changed(struct slave *slave)
+{
+	struct port *port;
+
+	port = &(SLAVE_AD_INFO(slave).port);
+
+	// if slave is null, the whole port is not initialized
+	if (!port->slave) {
+		printk(KERN_WARNING "bonding: Warning: speed changed for uninitialized port on %s\n",
+		       slave->dev->name);
+		return;
+	}
+
+	port->actor_admin_port_key &= ~AD_SPEED_KEY_BITS;
+	port->actor_oper_port_key=port->actor_admin_port_key |= (__get_link_speed(port) << 1);
+	BOND_PRINT_DBG(("Port %d changed speed", port->actor_port_number));
+	// there is no need to reselect a new aggregator, just signal the
+	// state machines to reinitialize
+	port->sm_vars |= AD_PORT_BEGIN;
+}
+
+/**
+ * bond_3ad_adapter_duplex_changed - handle a slave's duplex change indication
+ * @slave: slave struct to work on
+ *
+ * Handle reselection of aggregator (if needed) for this port.
+ */
+void bond_3ad_adapter_duplex_changed(struct slave *slave)
+{
+	struct port *port;
+
+	port=&(SLAVE_AD_INFO(slave).port);
+
+	// if slave is null, the whole port is not initialized
+	if (!port->slave) {
+		printk(KERN_WARNING "bonding: Warning: duplex changed for uninitialized port on %s\n",
+		       slave->dev->name);
+		return;
+	}
+
+	port->actor_admin_port_key &= ~AD_DUPLEX_KEY_BITS;
+	port->actor_oper_port_key=port->actor_admin_port_key |= __get_duplex(port);
+	BOND_PRINT_DBG(("Port %d changed duplex", port->actor_port_number));
+	// there is no need to reselect a new aggregator, just signal the
+	// state machines to reinitialize
+	port->sm_vars |= AD_PORT_BEGIN;
+}
+
+/**
+ * bond_3ad_handle_link_change - handle a slave's link status change indication
+ * @slave: slave struct to work on
+ * @status: whether the link is now up or down
+ *
+ * Handle reselection of aggregator (if needed) for this port.
+ */
+void bond_3ad_handle_link_change(struct slave *slave, char link)
+{
+	struct port *port;
+
+	port = &(SLAVE_AD_INFO(slave).port);
+
+	// if slave is null, the whole port is not initialized
+	if (!port->slave) {
+#ifdef BONDING_DEBUG
+		printk(KERN_WARNING "bonding: Warning: link status changed for uninitialized port on %s\n",
+		       slave->dev->name);
+#endif
+		return;
+	}
+
+	// on link down we are zeroing duplex and speed since some of the adaptors(ce1000.lan) report full duplex/speed instead of N/A(duplex) / 0(speed)
+	// on link up we are forcing recheck on the duplex and speed since some of he adaptors(ce1000.lan) report
+	if (link == BOND_LINK_UP) {
+		port->is_enabled = 1;
+		port->actor_admin_port_key &= ~AD_DUPLEX_KEY_BITS;
+		port->actor_oper_port_key=port->actor_admin_port_key |= __get_duplex(port);
+		port->actor_admin_port_key &= ~AD_SPEED_KEY_BITS;
+		port->actor_oper_port_key=port->actor_admin_port_key |= (__get_link_speed(port) << 1);
+	} else {
+		/* link has failed */
+		port->is_enabled = 0;
+		port->actor_admin_port_key &= ~AD_DUPLEX_KEY_BITS;
+		port->actor_oper_port_key= (port->actor_admin_port_key &= ~AD_SPEED_KEY_BITS);
+	}
+	//BOND_PRINT_DBG(("Port %d changed link status to %s", port->actor_port_number, ((link == BOND_LINK_UP)?"UP":"DOWN")));
+	// there is no need to reselect a new aggregator, just signal the
+	// state machines to reinitialize
+	port->sm_vars |= AD_PORT_BEGIN;
+}
+
+/**
+ * bond_3ad_get_active_agg_info - get information of the active aggregator
+ * @bond: bonding struct to work on
+ * @ad_info: ad_info struct to fill with the bond's info
+ *
+ * Returns:   0 on success
+ *          < 0 on error
+ */
+int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info)
+{
+	struct aggregator *aggregator = NULL;
+	struct port *port;
+
+	for (port = __get_first_port(bond); port; port = __get_next_port(port)) {
+		if (port->aggregator && port->aggregator->is_active) {
+			aggregator = port->aggregator;
+			break;
+		}
+	}
+
+	if (aggregator) {
+		ad_info->aggregator_id = aggregator->aggregator_identifier;
+		ad_info->ports = aggregator->num_of_ports;
+		ad_info->actor_key = aggregator->actor_oper_aggregator_key;
+		ad_info->partner_key = aggregator->partner_oper_aggregator_key;
+		memcpy(ad_info->partner_system, aggregator->partner_system.mac_addr_value, ETH_ALEN);
+		return 0;
+	}
+
+	return -1;
+}
+
+int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
+{
+	slave_t *slave, *start_at;
+	struct bonding *bond = (struct bonding *) dev->priv;
+	struct ethhdr *data = (struct ethhdr *)skb->data;
+	int slave_agg_no;
+	int slaves_in_agg;
+	int agg_id;
+	struct ad_info ad_info;
+
+	if (!IS_UP(dev)) { /* bond down */
+		dev_kfree_skb(skb);
+		return 0;
+	}
+
+	if (bond == NULL) {
+		printk(KERN_CRIT "bonding: Error: bond is NULL on device %s\n", dev->name);
+		dev_kfree_skb(skb);
+		return 0;
+	}
+
+	read_lock(&bond->lock);
+	slave = bond->prev;
+
+	/* check if bond is empty */
+	if ((slave == (struct slave *) bond) || (bond->slave_cnt == 0)) {
+		printk(KERN_DEBUG "ERROR: bond is empty\n");
+		dev_kfree_skb(skb);
+		read_unlock(&bond->lock);
+		return 0;
+	}
+
+	if (bond_3ad_get_active_agg_info(bond, &ad_info)) {
+		printk(KERN_DEBUG "ERROR: bond_3ad_get_active_agg_info failed\n");
+		dev_kfree_skb(skb);
+		read_unlock(&bond->lock);
+		return 0;
+	}
+
+	slaves_in_agg = ad_info.ports;
+	agg_id = ad_info.aggregator_id;
+
+	if (slaves_in_agg == 0) {
+		/*the aggregator is empty*/
+		printk(KERN_DEBUG "ERROR: active aggregator is empty\n");
+		dev_kfree_skb(skb);
+		read_unlock(&bond->lock);
+		return 0;
+	}
+
+	/* we're at the root, get the first slave */
+	if ((slave == NULL) || (slave->dev == NULL)) {
+		/* no suitable interface, frame not sent */
+		dev_kfree_skb(skb);
+		read_unlock(&bond->lock);
+		return 0;
+	}
+
+	slave_agg_no = (data->h_dest[5]^slave->dev->dev_addr[5]) % slaves_in_agg;
+	while (slave != (slave_t *)bond) {
+		struct aggregator *agg = SLAVE_AD_INFO(slave).port.aggregator;
+
+		if (agg && (agg->aggregator_identifier == agg_id)) {
+			slave_agg_no--;
+			if (slave_agg_no < 0) {
+				break;
+			}
+		}
+
+		slave = slave->prev;
+		if (slave == NULL) {
+			printk(KERN_ERR "bonding: Error: slave is NULL\n");
+			dev_kfree_skb(skb);
+			read_unlock(&bond->lock);
+			return 0;
+		}
+	}
+
+	if (slave == (slave_t *)bond) {
+		printk(KERN_ERR "bonding: Error: Couldn't find a slave to tx on for aggregator ID %d\n", agg_id);
+		dev_kfree_skb(skb);
+		read_unlock(&bond->lock);
+		return 0;
+	}
+
+	start_at = slave;
+
+	do {
+		int slave_agg_id = 0;
+		struct aggregator *agg;
+
+		if (slave == NULL) {
+			printk(KERN_ERR "bonding: Error: slave is NULL\n");
+			dev_kfree_skb(skb);
+			read_unlock(&bond->lock);
+			return 0;
+		}
+
+		agg = SLAVE_AD_INFO(slave).port.aggregator;
+
+		if (agg) {
+			slave_agg_id = agg->aggregator_identifier;
+		}
+
+		if (SLAVE_IS_OK(slave) && 
+		    agg && (slave_agg_id == agg_id)) {
+			skb->dev = slave->dev;			
+			skb->priority = 1;
+			dev_queue_xmit(skb);
+			read_unlock(&bond->lock);
+			return 0;
+		}
+	} while ((slave = slave->next) != start_at);
+
+	/* no suitable interface, frame not sent */
+	dev_kfree_skb(skb);
+	read_unlock(&bond->lock);
+	return 0;
+}
+
+int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type* ptype)
+{
+	struct bonding *bond = (struct bonding *)dev->priv;
+	struct slave *slave = NULL;
+	int ret = NET_RX_DROP;
+
+	if (!(dev->flags & IFF_MASTER)) {
+		goto out;
+	}
+
+	read_lock(&bond->lock);
+	slave = bond_get_slave_by_dev((struct bonding *)dev->priv,
+				      skb->real_dev);
+	if (slave == NULL) {
+		goto out_unlock;
+	}
+
+	bond_3ad_rx_indication((struct lacpdu *) skb->data, slave, skb->len);
+
+	ret = NET_RX_SUCCESS;
+
+out_unlock:
+	read_unlock(&bond->lock);
+out:
+	dev_kfree_skb(skb);
+
+	return ret;
+}
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/bonding/bond_3ad.h linux-2.4.22-pre2/drivers/net/bonding/bond_3ad.h
--- linux-2.4.21/drivers/net/bonding/bond_3ad.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/bonding/bond_3ad.h	2003-06-26 21:43:19.000000000 +0000
@@ -0,0 +1,298 @@
+/*
+ * Copyright(c) 1999 - 2003 Intel 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 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.
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called LICENSE.
+ *
+ *
+ * Changes:
+ *
+ * 2003/05/01 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
+ *		Amir Noam <amir.noam at intel dot com>
+ *	- Added support for lacp_rate module param.
+ *
+ * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
+ *	- Renamed bond_3ad_link_status_changed() to
+ *	  bond_3ad_handle_link_change() for compatibility with TLB.
+ */
+
+#ifndef __BOND_3AD_H__
+#define __BOND_3AD_H__
+
+#include <asm/byteorder.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+
+// General definitions
+#define BOND_ETH_P_LACPDU       0x8809
+#define PKT_TYPE_LACPDU         __constant_htons(BOND_ETH_P_LACPDU)
+#define AD_TIMER_INTERVAL       100 /*msec*/
+
+#define MULTICAST_LACPDU_ADDR    {0x01, 0x80, 0xC2, 0x00, 0x00, 0x02}
+#define AD_MULTICAST_LACPDU_ADDR    {MULTICAST_LACPDU_ADDR}
+
+#define AD_LACP_SLOW 0
+#define AD_LACP_FAST 1
+
+typedef struct mac_addr {
+	u8 mac_addr_value[ETH_ALEN];
+} mac_addr_t;
+
+typedef enum {
+	AD_BANDWIDTH = 0,
+	AD_COUNT
+} agg_selection_t;
+
+// rx machine states(43.4.11 in the 802.3ad standard)
+typedef enum {
+	AD_RX_DUMMY,
+	AD_RX_INITIALIZE,     // rx Machine
+	AD_RX_PORT_DISABLED,  // rx Machine
+	AD_RX_LACP_DISABLED,  // rx Machine
+	AD_RX_EXPIRED,	      // rx Machine
+	AD_RX_DEFAULTED,      // rx Machine
+	AD_RX_CURRENT	      // rx Machine
+} rx_states_t;
+
+// periodic machine states(43.4.12 in the 802.3ad standard)
+typedef enum {
+	AD_PERIODIC_DUMMY,
+	AD_NO_PERIODIC,	       // periodic machine
+	AD_FAST_PERIODIC,      // periodic machine
+	AD_SLOW_PERIODIC,      // periodic machine
+	AD_PERIODIC_TX	   // periodic machine
+} periodic_states_t;
+
+// mux machine states(43.4.13 in the 802.3ad standard)
+typedef enum {
+	AD_MUX_DUMMY,
+	AD_MUX_DETACHED,       // mux machine
+	AD_MUX_WAITING,	       // mux machine
+	AD_MUX_ATTACHED,       // mux machine
+	AD_MUX_COLLECTING_DISTRIBUTING // mux machine
+} mux_states_t;
+
+// tx machine states(43.4.15 in the 802.3ad standard)
+typedef enum {
+	AD_TX_DUMMY,
+	AD_TRANSMIT	   // tx Machine
+} tx_states_t;
+
+// rx indication types
+typedef enum {
+	AD_TYPE_LACPDU = 1,    // type lacpdu
+	AD_TYPE_MARKER	   // type marker
+} pdu_type_t;
+
+// rx marker indication types
+typedef enum {
+	AD_MARKER_INFORMATION_SUBTYPE = 1, // marker imformation subtype
+	AD_MARKER_RESPONSE_SUBTYPE     // marker response subtype
+} marker_subtype_t;
+
+// timers types(43.4.9 in the 802.3ad standard)
+typedef enum {
+	AD_CURRENT_WHILE_TIMER,
+	AD_ACTOR_CHURN_TIMER,
+	AD_PERIODIC_TIMER,
+	AD_PARTNER_CHURN_TIMER,
+	AD_WAIT_WHILE_TIMER
+} ad_timers_t;
+
+#pragma pack(1)
+
+typedef struct ad_header {
+	struct mac_addr destination_address;
+	struct mac_addr source_address;
+	u16 length_type;
+} ad_header_t;
+
+// Link Aggregation Control Protocol(LACP) data unit structure(43.4.2.2 in the 802.3ad standard)
+typedef struct lacpdu {
+	u8 subtype;		     // = LACP(= 0x01)
+	u8 version_number;
+	u8 tlv_type_actor_info;	      // = actor information(type/length/value)
+	u8 actor_information_length; // = 20
+	u16 actor_system_priority;
+	struct mac_addr actor_system;
+	u16 actor_key;
+	u16 actor_port_priority;
+	u16 actor_port;
+	u8 actor_state;
+	u8 reserved_3_1[3];	     // = 0
+	u8 tlv_type_partner_info;     // = partner information
+	u8 partner_information_length;	 // = 20
+	u16 partner_system_priority;
+	struct mac_addr partner_system;
+	u16 partner_key;
+	u16 partner_port_priority;
+	u16 partner_port;
+	u8 partner_state;
+	u8 reserved_3_2[3];	     // = 0
+	u8 tlv_type_collector_info;	  // = collector information
+	u8 collector_information_length; // = 16
+	u16 collector_max_delay;
+	u8 reserved_12[12];
+	u8 tlv_type_terminator;	     // = terminator
+	u8 terminator_length;	     // = 0
+	u8 reserved_50[50];	     // = 0
+} lacpdu_t;
+
+typedef struct lacpdu_header {
+	struct ad_header ad_header;
+	struct lacpdu lacpdu;
+} lacpdu_header_t;
+
+// Marker Protocol Data Unit(PDU) structure(43.5.3.2 in the 802.3ad standard)
+typedef struct marker {
+	u8 subtype;		 //  = 0x02  (marker PDU)
+	u8 version_number;	 //  = 0x01
+	u8 tlv_type;		 //  = 0x01  (marker information)
+	//  = 0x02  (marker response information)
+	u8 marker_length;	 //  = 0x16
+	u16 requester_port;	 //   The number assigned to the port by the requester
+	struct mac_addr requester_system;      //   The requester’s system id
+	u32 requester_transaction_id;	//   The transaction id allocated by the requester,
+	u16 pad;		 //  = 0
+	u8 tlv_type_terminator;	     //  = 0x00
+	u8 terminator_length;	     //  = 0x00
+	u8 reserved_90[90];	     //  = 0
+} marker_t;
+
+typedef struct marker_header {
+	struct ad_header ad_header;
+	struct marker marker;
+} marker_header_t;
+
+#pragma pack()
+
+struct slave;
+struct bonding;
+struct ad_info;
+struct port;
+
+#ifdef __ia64__
+#pragma pack(8)
+#endif
+
+// aggregator structure(43.4.5 in the 802.3ad standard)
+typedef struct aggregator {
+	struct mac_addr aggregator_mac_address;
+	u16 aggregator_identifier;
+	u16 is_individual;		 // BOOLEAN
+	u16 actor_admin_aggregator_key;
+	u16 actor_oper_aggregator_key;
+	struct mac_addr partner_system;
+	u16 partner_system_priority;
+	u16 partner_oper_aggregator_key;
+	u16 receive_state;		// BOOLEAN
+	u16 transmit_state;		// BOOLEAN
+	struct port *lag_ports;
+	// ****** PRIVATE PARAMETERS ******
+	struct slave *slave;	    // pointer to the bond slave that this aggregator belongs to
+	u16 is_active;	    // BOOLEAN. Indicates if this aggregator is active
+	u16 num_of_ports;
+} aggregator_t;
+
+// port structure(43.4.6 in the 802.3ad standard)
+typedef struct port {
+	u16 actor_port_number;
+	u16 actor_port_priority;
+	struct mac_addr actor_system;	       // This parameter is added here although it is not specified in the standard, just for simplification
+	u16 actor_system_priority;	 // This parameter is added here although it is not specified in the standard, just for simplification
+	u16 actor_port_aggregator_identifier;
+	u16 ntt;			 // BOOLEAN
+	u16 actor_admin_port_key;
+	u16 actor_oper_port_key;
+	u8 actor_admin_port_state;
+	u8 actor_oper_port_state;
+	struct mac_addr partner_admin_system;
+	struct mac_addr partner_oper_system;
+	u16 partner_admin_system_priority;
+	u16 partner_oper_system_priority;
+	u16 partner_admin_key;
+	u16 partner_oper_key;
+	u16 partner_admin_port_number;
+	u16 partner_oper_port_number;
+	u16 partner_admin_port_priority;
+	u16 partner_oper_port_priority;
+	u8 partner_admin_port_state;
+	u8 partner_oper_port_state;
+	u16 is_enabled;	      // BOOLEAN
+	// ****** PRIVATE PARAMETERS ******
+	u16 sm_vars;	      // all state machines variables for this port
+	rx_states_t sm_rx_state;	// state machine rx state
+	u16 sm_rx_timer_counter;    // state machine rx timer counter
+	periodic_states_t sm_periodic_state;// state machine periodic state
+	u16 sm_periodic_timer_counter;	// state machine periodic timer counter
+	mux_states_t sm_mux_state;	// state machine mux state
+	u16 sm_mux_timer_counter;   // state machine mux timer counter
+	tx_states_t sm_tx_state;	// state machine tx state
+	u16 sm_tx_timer_counter;    // state machine tx timer counter(allways on - enter to transmit state 3 time per second)
+	struct slave *slave;	    // pointer to the bond slave that this port belongs to
+	struct aggregator *aggregator;	   // pointer to an aggregator that this port related to
+	struct port *next_port_in_aggregator; // Next port on the linked list of the parent aggregator
+	u32 transaction_id;	    // continuous number for identification of Marker PDU's;
+	struct lacpdu lacpdu;	       // the lacpdu that will be sent for this port
+} port_t;
+
+// system structure
+typedef struct ad_system {
+	u16 sys_priority;
+	struct mac_addr sys_mac_addr;
+} ad_system_t;
+
+#ifdef __ia64__
+#pragma pack()
+#endif
+
+// ================= AD Exported structures to the main bonding code ==================
+#define BOND_AD_INFO(bond)   ((bond)->ad_info)
+#define SLAVE_AD_INFO(slave) ((slave)->ad_info)
+
+struct ad_bond_info {
+	ad_system_t system;	    // 802.3ad system structure
+	u32 agg_select_timer;	    // Timer to select aggregator after all adapter's hand shakes
+	u32 agg_select_mode;	    // Mode of selection of active aggregator(bandwidth/count)
+	int lacp_fast;		/* whether fast periodic tx should be
+				 * requested
+				 */
+	struct timer_list ad_timer;
+	struct packet_type ad_pkt_type;
+};
+
+struct ad_slave_info {
+	struct aggregator aggregator;	    // 802.3ad aggregator structure
+	struct port port;		    // 802.3ad port structure
+	spinlock_t rx_machine_lock; // To avoid race condition between callback and receive interrupt
+	u16 id;
+};
+
+// ================= AD Exported functions to the main bonding code ==================
+void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution, int lacp_fast);
+int  bond_3ad_bind_slave(struct slave *slave);
+void bond_3ad_unbind_slave(struct slave *slave);
+void bond_3ad_state_machine_handler(struct bonding *bond);
+void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u16 length);
+void bond_3ad_adapter_speed_changed(struct slave *slave);
+void bond_3ad_adapter_duplex_changed(struct slave *slave);
+void bond_3ad_handle_link_change(struct slave *slave, char link);
+int  bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info);
+int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev);
+int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type* ptype);
+#endif //__BOND_3AD_H__
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/bonding/bond_alb.c linux-2.4.22-pre2/drivers/net/bonding/bond_alb.c
--- linux-2.4.21/drivers/net/bonding/bond_alb.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/bonding/bond_alb.c	2003-06-26 21:43:16.000000000 +0000
@@ -0,0 +1,1569 @@
+/*
+ * Copyright(c) 1999 - 2003 Intel 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 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.
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called LICENSE.
+ */
+
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/pkt_sched.h>
+#include <linux/spinlock.h>
+#include <linux/slab.h>
+#include <linux/timer.h>
+#include <linux/ip.h>
+#include <linux/ipv6.h>
+#include <linux/if_arp.h>
+#include <linux/if_ether.h>
+#include <linux/if_bonding.h>
+#include <net/ipx.h>
+#include <net/arp.h>
+#include <asm/byteorder.h>
+#include "bonding.h"
+#include "bond_alb.h"
+
+
+#define ALB_TIMER_TICKS_PER_SEC	    10	/* should be a divisor of HZ */
+#define BOND_TLB_REBALANCE_INTERVAL 10	/* in seconds, periodic re-balancing
+					 * used for division - never set
+					 * to zero !!!
+					 */
+#define BOND_ALB_LP_INTERVAL	    1	/* in seconds periodic send of
+					 * learning packets to the switch
+					 */
+
+#define BOND_TLB_REBALANCE_TICKS (BOND_TLB_REBALANCE_INTERVAL \
+				  * ALB_TIMER_TICKS_PER_SEC)
+
+#define BOND_ALB_LP_TICKS (BOND_ALB_LP_INTERVAL \
+			   * ALB_TIMER_TICKS_PER_SEC)
+
+#define TLB_HASH_TABLE_SIZE 256	/* The size of the clients hash table.
+				 * Note that this value MUST NOT be smaller
+				 * because the key hash table BYTE wide !
+				 */
+
+
+#define TLB_NULL_INDEX		0xffffffff
+#define MAX_LP_RETRY		3
+
+/* rlb defs */
+#define RLB_HASH_TABLE_SIZE	256
+#define RLB_NULL_INDEX		0xffffffff
+#define RLB_UPDATE_DELAY	2*ALB_TIMER_TICKS_PER_SEC /* 2 seconds */
+#define RLB_ARP_BURST_SIZE	2
+#define RLB_UPDATE_RETRY	3	/* 3-ticks - must be smaller than the rlb
+					 * rebalance interval (5 min).
+					 */
+/* RLB_PROMISC_TIMEOUT = 10 sec equals the time that the current slave is
+ * promiscuous after failover
+ */
+#define RLB_PROMISC_TIMEOUT	10*ALB_TIMER_TICKS_PER_SEC
+
+#pragma pack(1)
+struct learning_pkt {
+	u8 mac_dst[ETH_ALEN];
+	u8 mac_src[ETH_ALEN];
+	u16 type;
+	u8 padding[ETH_ZLEN - (2*ETH_ALEN + 2)];
+};
+
+struct arp_pkt {
+	u16     hw_addr_space;
+	u16     prot_addr_space;
+	u8      hw_addr_len;
+	u8      prot_addr_len;
+	u16     op_code;
+	u8      mac_src[ETH_ALEN];	/* sender hardware address */
+	u32     ip_src;			/* sender IP address */
+	u8      mac_dst[ETH_ALEN];	/* target hardware address */
+	u32     ip_dst;			/* target IP address */
+};
+#pragma pack()
+
+/* Forward declaration */
+static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[]);
+
+static inline u8
+_simple_hash(u8 *hash_start, int hash_size)
+{
+	int i;
+	u8 hash = 0;
+
+	for (i=0; i<hash_size; i++) {
+		hash ^= hash_start[i];
+	}
+
+	return hash;
+}
+
+/*********************** tlb specific functions ***************************/
+
+static inline void
+_lock_tx_hashtbl(struct bonding *bond)
+{
+	spin_lock(&(BOND_ALB_INFO(bond).tx_hashtbl_lock));
+}
+
+static inline void
+_unlock_tx_hashtbl(struct bonding *bond)
+{
+	spin_unlock(&(BOND_ALB_INFO(bond).tx_hashtbl_lock));
+}
+
+/* Caller must hold tx_hashtbl lock */
+static inline void
+tlb_init_table_entry(struct bonding *bond, u8 index, u8 save_load)
+{
+	struct tlb_client_info *entry;
+
+	if (BOND_ALB_INFO(bond).tx_hashtbl == NULL) {
+		return;
+	}
+
+	entry = &(BOND_ALB_INFO(bond).tx_hashtbl[index]);
+	/* at end of cycle, save the load that was transmitted to the client
+	 * during the cycle, and set the tx_bytes counter to 0 for counting
+	 * the load during the next cycle
+	 */
+	if (save_load) {
+		entry->load_history = 1 + entry->tx_bytes /
+			BOND_TLB_REBALANCE_INTERVAL;
+		entry->tx_bytes = 0;
+	}
+	entry->tx_slave = NULL;
+	entry->next = TLB_NULL_INDEX;
+	entry->prev = TLB_NULL_INDEX;
+}
+
+static inline void
+tlb_init_slave(struct slave *slave)
+{
+	struct tlb_slave_info *slave_info = &(SLAVE_TLB_INFO(slave));
+
+	slave_info->load = 0;
+	slave_info->head = TLB_NULL_INDEX;
+}
+
+/* Caller must hold bond lock for read */
+static inline void
+tlb_clear_slave(struct bonding *bond, struct slave *slave, u8 save_load)
+{
+	struct tlb_client_info *tx_hash_table = NULL;
+	u32 index, next_index;
+
+	/* clear slave from tx_hashtbl */
+	_lock_tx_hashtbl(bond);
+	tx_hash_table = BOND_ALB_INFO(bond).tx_hashtbl;
+
+	if (tx_hash_table) {
+		index = SLAVE_TLB_INFO(slave).head;
+		while (index != TLB_NULL_INDEX) {
+			next_index = tx_hash_table[index].next;
+			tlb_init_table_entry(bond, index, save_load);
+			index = next_index;
+		}
+	}
+	_unlock_tx_hashtbl(bond);
+
+	tlb_init_slave(slave);
+}
+
+/* Must be called before starting the monitor timer */
+static int
+tlb_initialize(struct bonding *bond)
+{
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+	int i;
+	size_t size;
+
+#if(TLB_HASH_TABLE_SIZE != 256)
+	/* Key to the hash table is byte wide. Check the size! */
+	#error Hash Table size is wrong.
+#endif
+
+	spin_lock_init(&(bond_info->tx_hashtbl_lock));
+
+	_lock_tx_hashtbl(bond);
+	if (bond_info->tx_hashtbl != NULL) {
+		printk (KERN_ERR "%s: TLB hash table is not NULL\n",
+			bond->device->name);
+		_unlock_tx_hashtbl(bond);
+		return -1;
+	}
+
+	size = TLB_HASH_TABLE_SIZE * sizeof(struct tlb_client_info);
+	bond_info->tx_hashtbl = kmalloc(size, GFP_KERNEL);
+	if (bond_info->tx_hashtbl == NULL) {
+		printk (KERN_ERR "%s: Failed to allocate TLB hash table\n",
+			bond->device->name);
+		_unlock_tx_hashtbl(bond);
+		return -1;
+	}
+
+	memset(bond_info->tx_hashtbl, 0, size);
+	for (i=0; i<TLB_HASH_TABLE_SIZE; i++) {
+		tlb_init_table_entry(bond, i, 1);
+	}
+	_unlock_tx_hashtbl(bond);
+
+	return 0;
+}
+
+/* Must be called only after all slaves have been released */
+static void
+tlb_deinitialize(struct bonding *bond)
+{
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+
+	_lock_tx_hashtbl(bond);
+	if (bond_info->tx_hashtbl == NULL) {
+		_unlock_tx_hashtbl(bond);
+		return;
+	}
+	kfree(bond_info->tx_hashtbl);
+	bond_info->tx_hashtbl = NULL;
+	_unlock_tx_hashtbl(bond);
+}
+
+/* Caller must hold bond lock for read */
+static struct slave*
+tlb_get_least_loaded_slave(struct bonding *bond)
+{
+	struct slave *slave;
+	struct slave *least_loaded;
+	u32 curr_gap, max_gap;
+
+	/* Find the first enabled slave */
+	slave = bond_get_first_slave(bond);
+	while (slave) {
+		if (SLAVE_IS_OK(slave)) {
+			break;
+		}
+		slave = bond_get_next_slave(bond, slave);
+	}
+
+	if (!slave) {
+		return NULL;
+	}
+
+	least_loaded = slave;
+	max_gap = (slave->speed * 1000000) -
+		  (SLAVE_TLB_INFO(slave).load * 8);
+
+	/* Find the slave with the largest gap */
+	slave = bond_get_next_slave(bond, slave);
+	while (slave) {
+		if (SLAVE_IS_OK(slave)) {
+			curr_gap = (slave->speed * 1000000) -
+				   (SLAVE_TLB_INFO(slave).load * 8);
+			if (max_gap < curr_gap) {
+				least_loaded = slave;
+				max_gap = curr_gap;
+			}
+		}
+		slave = bond_get_next_slave(bond, slave);
+	}
+
+	return least_loaded;
+}
+
+/* Caller must hold bond lock for read */
+struct slave*
+tlb_choose_channel(struct bonding *bond, u32 hash_index, u32 skb_len)
+{
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+	struct tlb_client_info *hash_table = NULL;
+	struct slave *assigned_slave = NULL;
+
+	_lock_tx_hashtbl(bond);
+
+	hash_table = bond_info->tx_hashtbl;
+	if (hash_table == NULL) {
+		printk (KERN_ERR "%s: TLB hash table is NULL\n",
+			bond->device->name);
+		_unlock_tx_hashtbl(bond);
+		return NULL;
+	}
+
+	assigned_slave = hash_table[hash_index].tx_slave;
+	if (!assigned_slave) {
+		assigned_slave = tlb_get_least_loaded_slave(bond);
+
+		if (assigned_slave) {
+			struct tlb_slave_info *slave_info =
+				&(SLAVE_TLB_INFO(assigned_slave));
+			u32 next_index = slave_info->head;
+
+			hash_table[hash_index].tx_slave = assigned_slave;
+			hash_table[hash_index].next = next_index;
+			hash_table[hash_index].prev = TLB_NULL_INDEX;
+
+			if (next_index != TLB_NULL_INDEX) {
+				hash_table[next_index].prev = hash_index;
+			}
+
+			slave_info->head = hash_index;
+			slave_info->load +=
+				hash_table[hash_index].load_history;
+		}
+	}
+
+	if (assigned_slave) {
+		hash_table[hash_index].tx_bytes += skb_len;
+	}
+
+	_unlock_tx_hashtbl(bond);
+
+	return assigned_slave;
+}
+
+/*********************** rlb specific functions ***************************/
+static inline void
+_lock_rx_hashtbl(struct bonding *bond)
+{
+	spin_lock(&(BOND_ALB_INFO(bond).rx_hashtbl_lock));
+}
+
+static inline void
+_unlock_rx_hashtbl(struct bonding *bond)
+{
+	spin_unlock(&(BOND_ALB_INFO(bond).rx_hashtbl_lock));
+}
+
+/* when an ARP REPLY is received from a client update its info
+ * in the rx_hashtbl
+ */
+static void
+rlb_update_entry_from_arp(struct bonding *bond, struct arp_pkt *arp)
+{
+	u32 hash_index;
+	struct rlb_client_info *client_info = NULL;
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+
+	_lock_rx_hashtbl(bond);
+
+	if (bond_info->rx_hashtbl == NULL) {
+		_unlock_rx_hashtbl(bond);
+		return;
+	}
+	hash_index = _simple_hash((u8*)&(arp->ip_src), 4);
+	client_info = &(bond_info->rx_hashtbl[hash_index]);
+
+	if ((client_info->assigned) &&
+	    (client_info->ip_src == arp->ip_dst) &&
+	    (client_info->ip_dst == arp->ip_src)) {
+
+		/* update the clients MAC address */
+		memcpy(client_info->mac_dst, arp->mac_src, ETH_ALEN);
+		client_info->ntt = 1;
+		bond_info->rx_ntt = 1;
+	}
+
+	_unlock_rx_hashtbl(bond);
+}
+
+static int
+rlb_arp_recv(struct sk_buff *skb,
+	     struct net_device *dev,
+	     struct packet_type* ptype)
+{
+	struct bonding *bond = (struct bonding *)dev->priv;
+	int ret = NET_RX_DROP;
+	struct arp_pkt *arp = (struct arp_pkt *)skb->data;
+
+	if (!(dev->flags & IFF_MASTER)) {
+		goto out;
+	}
+
+	if (!arp) {
+		printk(KERN_ERR "Packet has no ARP data\n");
+		goto out;
+	}
+
+	if (skb->len < sizeof(struct arp_pkt)) {
+		printk(KERN_ERR "Packet is too small to be an ARP\n");
+		goto out;
+	}
+
+	if (arp->op_code == htons(ARPOP_REPLY)) {
+		/* update rx hash table for this ARP */
+		rlb_update_entry_from_arp(bond, arp);
+		BOND_PRINT_DBG(("Server received an ARP Reply from client"));
+	}
+
+	ret = NET_RX_SUCCESS;
+
+out:
+	dev_kfree_skb(skb);
+
+	return ret;
+}
+
+/* Caller must hold bond lock for read */
+static struct slave*
+rlb_next_rx_slave(struct bonding *bond)
+{
+	struct slave *rx_slave = NULL, *slave = NULL;
+	unsigned int i = 0;
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+
+	slave = bond_info->next_rx_slave;
+	if (slave == NULL) {
+		slave = bond->next;
+	}
+
+	/* this loop uses the circular linked list property of the
+	 * slave's list to go through all slaves
+	 */
+	for (i = 0; i < bond->slave_cnt; i++, slave = slave->next) {
+
+		if (SLAVE_IS_OK(slave)) {
+			if (!rx_slave) {
+				rx_slave = slave;
+			}
+			else if (slave->speed > rx_slave->speed) {
+				rx_slave = slave;
+			}
+		}
+	}
+
+	if (rx_slave) {
+		bond_info->next_rx_slave = rx_slave->next;
+	}
+
+	return rx_slave;
+}
+
+/* teach the switch the mac of a disabled slave
+ * on the primary for fault tolerance
+ *
+ * Caller must hold bond->ptrlock for write or bond lock for write
+ */
+static void
+rlb_teach_disabled_mac_on_primary(struct bonding *bond, u8 addr[])
+{
+	if (!bond->current_slave) {
+		return;
+	}
+	if (!bond->alb_info.primary_is_promisc) {
+		bond->alb_info.primary_is_promisc = 1;
+		dev_set_promiscuity(bond->current_slave->dev, 1);
+	}
+	bond->alb_info.rlb_promisc_timeout_counter = 0;
+
+	alb_send_learning_packets(bond->current_slave, addr);
+}
+
+/* slave being removed should not be active at this point
+ *
+ * Caller must hold bond lock for read
+ */
+static void
+rlb_clear_slave(struct bonding *bond, struct slave *slave)
+{
+	struct rlb_client_info *rx_hash_table = NULL;
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+	u8 mac_bcast[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff};
+	u32 index, next_index;
+
+	/* clear slave from rx_hashtbl */
+	_lock_rx_hashtbl(bond);
+	rx_hash_table = bond_info->rx_hashtbl;
+
+	if (rx_hash_table == NULL) {
+		_unlock_rx_hashtbl(bond);
+		return;
+	}
+
+	index = bond_info->rx_hashtbl_head;
+	for (; index != RLB_NULL_INDEX; index = next_index) {
+		next_index = rx_hash_table[index].next;
+
+		if (rx_hash_table[index].slave == slave) {
+			struct slave *assigned_slave = rlb_next_rx_slave(bond);
+
+			if (assigned_slave) {
+				rx_hash_table[index].slave = assigned_slave;
+				if (memcmp(rx_hash_table[index].mac_dst,
+					   mac_bcast, ETH_ALEN)) {
+					bond_info->rx_hashtbl[index].ntt = 1;
+					bond_info->rx_ntt = 1;
+					/* A slave has been removed from the
+					 * table because it is either disabled
+					 * or being released. We must retry the
+					 * update to avoid clients from not
+					 * being updated & disconnecting when
+					 * there is stress
+					 */
+					bond_info->rlb_update_retry_counter =
+						RLB_UPDATE_RETRY;
+				}
+			} else {  /* there is no active slave */
+				rx_hash_table[index].slave = NULL;
+			}
+		}
+	}
+
+	_unlock_rx_hashtbl(bond);
+
+	write_lock(&bond->ptrlock);
+	if (slave != bond->current_slave) {
+		rlb_teach_disabled_mac_on_primary(bond, slave->dev->dev_addr);
+	}
+	write_unlock(&bond->ptrlock);
+}
+
+static void
+rlb_update_client(struct rlb_client_info *client_info)
+{
+	int i = 0;
+
+	if (client_info->slave == NULL) {
+		return;
+	}
+
+	for (i=0; i<RLB_ARP_BURST_SIZE; i++) {
+		arp_send(ARPOP_REPLY, ETH_P_ARP,
+			 client_info->ip_dst,
+			 client_info->slave->dev,
+			 client_info->ip_src,
+			 client_info->mac_dst,
+			 client_info->slave->dev->dev_addr,
+			 client_info->mac_dst);
+	}
+}
+
+/* sends ARP REPLIES that update the clients that need updating */
+static void
+rlb_update_rx_clients(struct bonding *bond)
+{
+	u32 hash_index;
+	struct rlb_client_info *client_info = NULL;
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+
+	_lock_rx_hashtbl(bond);
+
+	if (bond_info->rx_hashtbl == NULL) {
+		_unlock_rx_hashtbl(bond);
+		return;
+	}
+
+	hash_index = bond_info->rx_hashtbl_head;
+	for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
+		client_info = &(bond_info->rx_hashtbl[hash_index]);
+		if (client_info->ntt) {
+			rlb_update_client(client_info);
+			if (bond_info->rlb_update_retry_counter == 0) {
+				client_info->ntt = 0;
+			}
+		}
+	}
+
+	/* do not update the entries again untill this counter is zero so that
+	 * not to confuse the clients.
+	 */
+	bond_info->rlb_update_delay_counter = RLB_UPDATE_DELAY;
+
+	_unlock_rx_hashtbl(bond);
+}
+
+/* The slave was assigned a new mac address - update the clients */
+static void
+rlb_req_update_slave_clients(struct bonding *bond, struct slave *slave)
+{
+	u32 hash_index;
+	u8 ntt = 0;
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+	u8 mac_bcast[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff};
+	struct rlb_client_info* client_info = NULL;
+
+	_lock_rx_hashtbl(bond);
+
+	if (bond_info->rx_hashtbl == NULL) {
+		_unlock_rx_hashtbl(bond);
+		return;
+	}
+
+	hash_index = bond_info->rx_hashtbl_head;
+	for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
+		client_info = &(bond_info->rx_hashtbl[hash_index]);
+
+		if ((client_info->slave == slave) &&
+		    memcmp(client_info->mac_dst, mac_bcast, ETH_ALEN)) {
+			client_info->ntt = 1;
+			ntt = 1;
+		}
+	}
+
+	// update the team's flag only after the whole iteration
+	if (ntt) {
+		bond_info->rx_ntt = 1;
+		//fasten the change
+		bond_info->rlb_update_retry_counter = RLB_UPDATE_RETRY;
+	}
+
+	_unlock_rx_hashtbl(bond);
+}
+
+/* mark all clients using src_ip to be updated */
+static void
+rlb_req_update_subnet_clients(struct bonding *bond, u32 src_ip)
+{
+	u32 hash_index;
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+	u8 mac_bcast[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff};
+	struct rlb_client_info *client_info = NULL;
+
+	_lock_rx_hashtbl(bond);
+
+	if (bond_info->rx_hashtbl == NULL) {
+		_unlock_rx_hashtbl(bond);
+		return;
+	}
+
+	hash_index = bond_info->rx_hashtbl_head;
+	for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
+		client_info = &(bond_info->rx_hashtbl[hash_index]);
+
+		if (!client_info->slave) {
+			printk(KERN_ERR "Bonding: Error: found a client with no"
+			       " channel in the client's hash table\n");
+			continue;
+		}
+		/*update all clients using this src_ip, that are not assigned
+		 * to the team's address (current_slave) and have a known
+		 * unicast mac address.
+		 */
+		if ((client_info->ip_src == src_ip) &&
+		    memcmp(client_info->slave->dev->dev_addr,
+			   bond->device->dev_addr, ETH_ALEN) &&
+		    memcmp(client_info->mac_dst, mac_bcast, ETH_ALEN)) {
+			client_info->ntt = 1;
+			bond_info->rx_ntt = 1;
+		}
+	}
+
+	_unlock_rx_hashtbl(bond);
+}
+
+/* Caller must hold both bond and ptr locks for read */
+struct slave*
+rlb_choose_channel(struct bonding *bond, struct arp_pkt *arp)
+{
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+	struct rlb_client_info *client_info = NULL;
+	u32 hash_index = 0;
+	struct slave *assigned_slave = NULL;
+	u8 mac_bcast[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff};
+
+	_lock_rx_hashtbl(bond);
+
+	if (bond_info->rx_hashtbl == NULL) {
+		_unlock_rx_hashtbl(bond);
+		return NULL;
+	}
+
+	hash_index = _simple_hash((u8 *)&arp->ip_dst, 4);
+	client_info = &(bond_info->rx_hashtbl[hash_index]);
+
+	if (client_info->assigned == 1) {
+		if ((client_info->ip_src == arp->ip_src) &&
+		    (client_info->ip_dst == arp->ip_dst)) {
+			/* the entry is already assigned to this client */
+
+			if (memcmp(arp->mac_dst, mac_bcast, ETH_ALEN)) {
+				/* update mac address from arp */
+				memcpy(client_info->mac_dst, arp->mac_dst, ETH_ALEN);
+			}
+
+			assigned_slave = client_info->slave;
+			if (assigned_slave) {
+				_unlock_rx_hashtbl(bond);
+				return assigned_slave;
+			}
+		} else {
+			/* the entry is already assigned to some other client,
+			 * move the old client to primary (current_slave) so
+			 * that the new client can be assigned to this entry.
+			 */
+			if (bond->current_slave &&
+			    client_info->slave != bond->current_slave) {
+				client_info->slave = bond->current_slave;
+				rlb_update_client(client_info);
+			}
+		}
+	}
+	/* assign a new slave */
+	assigned_slave = rlb_next_rx_slave(bond);
+
+	if (assigned_slave) {
+		client_info->ip_src = arp->ip_src;
+		client_info->ip_dst = arp->ip_dst;
+		/* arp->mac_dst is broadcast for arp reqeusts.
+		 * will be updated with clients actual unicast mac address
+		 * upon receiving an arp reply.
+		 */
+		memcpy(client_info->mac_dst, arp->mac_dst, ETH_ALEN);
+		client_info->slave = assigned_slave;
+
+		if (memcmp(client_info->mac_dst, mac_bcast, ETH_ALEN)) {
+			client_info->ntt = 1;
+			bond->alb_info.rx_ntt = 1;
+		}
+		else {
+			client_info->ntt = 0;
+		}
+
+		if (!client_info->assigned) {
+			u32 prev_tbl_head = bond_info->rx_hashtbl_head;
+			bond_info->rx_hashtbl_head = hash_index;
+			client_info->next = prev_tbl_head;
+			if (prev_tbl_head != RLB_NULL_INDEX) {
+				bond_info->rx_hashtbl[prev_tbl_head].prev =
+					hash_index;
+			}
+			client_info->assigned = 1;
+		}
+	}
+
+	_unlock_rx_hashtbl(bond);
+
+	return assigned_slave;
+}
+
+/* chooses (and returns) transmit channel for arp reply
+ * does not choose channel for other arp types since they are
+ * sent on the current_slave
+ */
+static struct slave*
+rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond)
+{
+	struct arp_pkt *arp = (struct arp_pkt *)skb->nh.raw;
+	struct slave *tx_slave = NULL;
+
+	if (arp->op_code == __constant_htons(ARPOP_REPLY)) {
+		/* the arp must be sent on the selected
+		* rx channel
+		*/
+		tx_slave = rlb_choose_channel(bond, arp);
+		if (tx_slave) {
+			memcpy(arp->mac_src,tx_slave->dev->dev_addr, ETH_ALEN);
+		}
+		BOND_PRINT_DBG(("Server sent ARP Reply packet"));
+	} else if (arp->op_code == __constant_htons(ARPOP_REQUEST)) {
+
+		/* Create an entry in the rx_hashtbl for this client as a
+		 * place holder.
+		 * When the arp reply is received the entry will be updated
+		 * with the correct unicast address of the client.
+		 */
+		rlb_choose_channel(bond, arp);
+
+		/* The ARP relpy packets must be delayed so that
+		 * they can cancel out the influence of the ARP request.
+		 */
+		bond->alb_info.rlb_update_delay_counter = RLB_UPDATE_DELAY;
+
+		/* arp requests are broadcast and are sent on the primary
+		 * the arp request will collapse all clients on the subnet to
+		 * the primary slave. We must register these clients to be
+		 * updated with their assigned mac.
+		 */
+		rlb_req_update_subnet_clients(bond, arp->ip_src);
+		BOND_PRINT_DBG(("Server sent ARP Request packet"));
+	}
+
+	return tx_slave;
+}
+
+/* Caller must hold bond lock for read */
+static void
+rlb_rebalance(struct bonding *bond)
+{
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+	struct slave *assigned_slave = NULL;
+	u32 hash_index;
+	struct rlb_client_info *client_info = NULL;
+	u8 ntt = 0;
+
+	_lock_rx_hashtbl(bond);
+
+	if (bond_info->rx_hashtbl == NULL) {
+		_unlock_rx_hashtbl(bond);
+		return;
+	}
+
+	hash_index = bond_info->rx_hashtbl_head;
+	for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
+		client_info = &(bond_info->rx_hashtbl[hash_index]);
+		assigned_slave = rlb_next_rx_slave(bond);
+		if (assigned_slave && (client_info->slave != assigned_slave)){
+			client_info->slave = assigned_slave;
+			client_info->ntt = 1;
+			ntt = 1;
+		}
+	}
+
+	/* update the team's flag only after the whole iteration */
+	if (ntt) {
+		bond_info->rx_ntt = 1;
+	}
+	_unlock_rx_hashtbl(bond);
+}
+
+/* Caller must hold rx_hashtbl lock */
+static inline void
+rlb_init_table_entry(struct rlb_client_info *entry)
+{
+	entry->next = RLB_NULL_INDEX;
+	entry->prev = RLB_NULL_INDEX;
+	entry->assigned = 0;
+	entry->ntt = 0;
+}
+
+static int
+rlb_initialize(struct bonding *bond)
+{
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+	struct packet_type *pk_type = &(BOND_ALB_INFO(bond).rlb_pkt_type);
+	int i;
+	size_t size;
+
+	spin_lock_init(&(bond_info->rx_hashtbl_lock));
+
+	_lock_rx_hashtbl(bond);
+	if (bond_info->rx_hashtbl != NULL) {
+		printk (KERN_ERR "%s: RLB hash table is not NULL\n",
+			bond->device->name);
+		_unlock_rx_hashtbl(bond);
+		return -1;
+	}
+
+	size = RLB_HASH_TABLE_SIZE * sizeof(struct rlb_client_info);
+	bond_info->rx_hashtbl = kmalloc(size, GFP_KERNEL);
+	if (bond_info->rx_hashtbl == NULL) {
+		printk (KERN_ERR "%s: Failed to allocate"
+			" RLB hash table\n", bond->device->name);
+		_unlock_rx_hashtbl(bond);
+		return -1;
+	}
+
+	bond_info->rx_hashtbl_head = RLB_NULL_INDEX;
+
+	for (i=0; i<RLB_HASH_TABLE_SIZE; i++) {
+		rlb_init_table_entry(bond_info->rx_hashtbl + i);
+	}
+	_unlock_rx_hashtbl(bond);
+
+	/* register to receive ARPs */
+
+	/*initialize packet type*/
+	pk_type->type = __constant_htons(ETH_P_ARP);
+	pk_type->dev = bond->device;
+	pk_type->func = rlb_arp_recv;
+	pk_type->data = (void*)1;  /* understand shared skbs */
+
+	dev_add_pack(pk_type);
+
+	return 0;
+}
+
+static void
+rlb_deinitialize(struct bonding *bond)
+{
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+
+	dev_remove_pack(&(bond_info->rlb_pkt_type));
+
+	_lock_rx_hashtbl(bond);
+	if (bond_info->rx_hashtbl == NULL) {
+		_unlock_rx_hashtbl(bond);
+		return;
+	}
+	kfree(bond_info->rx_hashtbl);
+	bond_info->rx_hashtbl = NULL;
+	_unlock_rx_hashtbl(bond);
+}
+
+/*********************** tlb/rlb shared functions *********************/
+
+static void
+alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
+{
+	struct sk_buff *skb = NULL;
+	struct learning_pkt pkt;
+	char *data = NULL;
+	int i;
+	unsigned int size = sizeof(struct learning_pkt);
+
+	memset(&pkt, 0, size);
+	memcpy(pkt.mac_dst, mac_addr, ETH_ALEN);
+	memcpy(pkt.mac_src, mac_addr, ETH_ALEN);
+	pkt.type = __constant_htons(ETH_P_LOOP);
+
+	for (i=0; i < MAX_LP_RETRY; i++) {
+		skb = NULL;
+		skb = dev_alloc_skb(size);
+		if (!skb) {
+			return;
+		}
+
+		data = skb_put(skb, size);
+		memcpy(data, &pkt, size);
+		skb->mac.raw = data;
+		skb->nh.raw = data + ETH_HLEN;
+		skb->protocol = pkt.type;
+		skb->priority = TC_PRIO_CONTROL;
+		skb->dev = slave->dev;
+		dev_queue_xmit(skb);
+	}
+
+}
+
+/* hw is a boolean parameter that determines whether we should try and
+ * set the hw address of the hw as well as the hw address of the net_device
+ */
+static int
+alb_set_mac_addr(struct slave *slave, u8 addr[], int hw)
+{
+	struct net_device *dev = NULL;
+	struct sockaddr s_addr;
+
+	dev = slave->dev;
+
+	if (!hw) {
+		memcpy(dev->dev_addr, addr, ETH_ALEN);
+		return 0;
+	}
+
+	/* for rlb each slave must have a unique hw mac addresses so that */
+	/* each slave will receive packets destined to a different mac */
+	memcpy(s_addr.sa_data, addr, ETH_ALEN);
+	s_addr.sa_family = dev->type;
+	if (dev->set_mac_address(dev, &s_addr)) {
+		printk(KERN_DEBUG "bonding: Error: alb_set_mac_addr:"
+				  " dev->set_mac_address of dev %s failed!"
+				  " ALB mode requires that the base driver"
+				  " support setting the hw address also when"
+				  " the network device's interface is open\n",
+				  dev->name);
+		return -EOPNOTSUPP;
+	}
+	return 0;
+}
+
+/* Caller must hold bond lock for write or ptrlock for write*/
+static void
+alb_swap_mac_addr(struct bonding *bond,
+		  struct slave *slave1,
+		  struct slave *slave2)
+{
+	u8 tmp_mac_addr[ETH_ALEN];
+	struct slave *disabled_slave = NULL;
+	u8 slaves_state_differ;
+
+	slaves_state_differ = (SLAVE_IS_OK(slave1) != SLAVE_IS_OK(slave2));
+
+	memcpy(tmp_mac_addr, slave1->dev->dev_addr, ETH_ALEN);
+	alb_set_mac_addr(slave1, slave2->dev->dev_addr, bond->alb_info.rlb_enabled);
+	alb_set_mac_addr(slave2, tmp_mac_addr, bond->alb_info.rlb_enabled);
+
+	/* fasten the change in the switch */
+	if (SLAVE_IS_OK(slave1)) {
+		alb_send_learning_packets(slave1, slave1->dev->dev_addr);
+		if (bond->alb_info.rlb_enabled) {
+			/* inform the clients that the mac address
+			 * has changed
+			 */
+			rlb_req_update_slave_clients(bond, slave1);
+		}
+	}
+	else {
+		disabled_slave = slave1;
+	}
+
+	if (SLAVE_IS_OK(slave2)) {
+		alb_send_learning_packets(slave2, slave2->dev->dev_addr);
+		if (bond->alb_info.rlb_enabled) {
+			/* inform the clients that the mac address
+			 * has changed
+			 */
+			rlb_req_update_slave_clients(bond, slave2);
+		}
+	}
+	else {
+		disabled_slave = slave2;
+	}
+
+	if (bond->alb_info.rlb_enabled && slaves_state_differ) {
+			/* A disabled slave was assigned an active mac addr */
+			rlb_teach_disabled_mac_on_primary(bond,
+				disabled_slave->dev->dev_addr);
+	}
+}
+
+/**
+ * alb_change_hw_addr_on_detach
+ * @bond: bonding we're working on
+ * @slave: the slave that was just detached
+ *
+ * We assume that @slave was already detached from the slave list.
+ *
+ * If @slave's permanent hw address is different both from its current
+ * address and from @bond's address, then somewhere in the bond there's
+ * a slave that has @slave's permanet address as its current address.
+ * We'll make sure that that slave no longer uses @slave's permanent address.
+ *
+ * Caller must hold bond lock
+ */
+static void
+alb_change_hw_addr_on_detach(struct bonding *bond, struct slave *slave)
+{
+	struct slave *tmp_slave;
+	int perm_curr_diff;
+	int perm_bond_diff;
+
+	perm_curr_diff = memcmp(slave->perm_hwaddr,
+				slave->dev->dev_addr,
+				ETH_ALEN);
+	perm_bond_diff = memcmp(slave->perm_hwaddr,
+				bond->device->dev_addr,
+				ETH_ALEN);
+	if (perm_curr_diff && perm_bond_diff) {
+		tmp_slave = bond_get_first_slave(bond);
+		while (tmp_slave) {
+			if (!memcmp(slave->perm_hwaddr,
+				   tmp_slave->dev->dev_addr,
+				   ETH_ALEN)) {
+				break;
+			}
+			tmp_slave = bond_get_next_slave(bond, tmp_slave);
+		}
+
+		if (tmp_slave) {
+			alb_swap_mac_addr(bond, slave, tmp_slave);
+		}
+	}
+}
+
+/**
+ * alb_handle_addr_collision_on_attach
+ * @bond: bonding we're working on
+ * @slave: the slave that was just attached
+ *
+ * checks uniqueness of slave's mac address and handles the case the
+ * new slave uses the bonds mac address.
+ *
+ * If the permanent hw address of @slave is @bond's hw address, we need to
+ * find a different hw address to give @slave, that isn't in use by any other
+ * slave in the bond. This address must be, of course, one of the premanent
+ * addresses of the other slaves.
+ *
+ * We go over the slave list, and for each slave there we compare its
+ * permanent hw address with the current address of all the other slaves.
+ * If no match was found, then we've found a slave with a permanent address
+ * that isn't used by any other slave in the bond, so we can assign it to
+ * @slave.
+ *
+ * assumption: this function is called before @slave is attached to the
+ * 	       bond slave list.
+ *
+ * caller must hold the bond lock for write since the mac addresses are compared
+ * and may be swapped.
+ */
+static int
+alb_handle_addr_collision_on_attach(struct bonding *bond, struct slave *slave)
+{
+	struct slave *tmp_slave1, *tmp_slave2;
+
+	if (bond->slave_cnt == 0) {
+		/* this is the first slave */
+		return 0;
+	}
+
+	/* if slave's mac address differs from bond's mac address
+	 * check uniqueness of slave's mac address against the other
+	 * slaves in the bond.
+	 */
+	if (memcmp(slave->perm_hwaddr, bond->device->dev_addr, ETH_ALEN)) {
+		tmp_slave1 = bond_get_first_slave(bond);
+		for (; tmp_slave1; tmp_slave1 = bond_get_next_slave(bond, tmp_slave1)) {
+			if (!memcmp(tmp_slave1->dev->dev_addr, slave->dev->dev_addr,
+				    ETH_ALEN)) {
+				break;
+			}
+		}
+		if (tmp_slave1) {
+			/* a slave was found that is using the mac address
+			 * of the new slave
+			 */
+			printk(KERN_ERR "bonding: Warning: the hw address "
+			       "of slave %s is not unique - cannot enslave it!"
+			       , slave->dev->name);
+			return -EINVAL;
+		}
+		return 0;
+	}
+
+	/* the slave's address is equal to the address of the bond
+	 * search for a spare address in the bond for this slave.
+	 */
+	tmp_slave1 = bond_get_first_slave(bond);
+	for (; tmp_slave1; tmp_slave1 = bond_get_next_slave(bond, tmp_slave1)) {
+
+		tmp_slave2 = bond_get_first_slave(bond);
+		for (; tmp_slave2; tmp_slave2 = bond_get_next_slave(bond, tmp_slave2)) {
+
+			if (!memcmp(tmp_slave1->perm_hwaddr,
+				    tmp_slave2->dev->dev_addr,
+				    ETH_ALEN)) {
+
+				break;
+			}
+		}
+
+		if (!tmp_slave2) {
+			/* no slave has tmp_slave1's perm addr
+			 * as its curr addr
+			 */
+			break;
+		}
+	}
+
+	if (tmp_slave1) {
+		alb_set_mac_addr(slave, tmp_slave1->perm_hwaddr,
+				 bond->alb_info.rlb_enabled);
+
+		printk(KERN_WARNING "bonding: Warning: the hw address "
+		       "of slave %s is in use by the bond; "
+		       "giving it the hw address of %s\n",
+		       slave->dev->name, tmp_slave1->dev->name);
+	} else {
+		printk(KERN_CRIT "bonding: Error: the hw address "
+		       "of slave %s is in use by the bond; "
+		       "couldn't find a slave with a free hw "
+		       "address to give it (this should not have "
+		       "happened)\n", slave->dev->name);
+		return -EFAULT;
+	}
+
+	return 0;
+}
+
+/************************ exported alb funcions ************************/
+
+int
+bond_alb_initialize(struct bonding *bond, int rlb_enabled)
+{
+	int res;
+
+	res = tlb_initialize(bond);
+	if (res) {
+		return res;
+	}
+
+	if (rlb_enabled) {
+		bond->alb_info.rlb_enabled = 1;
+		/* initialize rlb */
+		res = rlb_initialize(bond);
+		if (res) {
+			tlb_deinitialize(bond);
+			return res;
+		}
+	}
+
+	return 0;
+}
+
+void
+bond_alb_deinitialize(struct bonding *bond)
+{
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+
+	tlb_deinitialize(bond);
+
+	if (bond_info->rlb_enabled) {
+		rlb_deinitialize(bond);
+	}
+}
+
+int
+bond_alb_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+	struct bonding *bond = (struct bonding *) dev->priv;
+	struct ethhdr *eth_data = (struct ethhdr *)skb->data;
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+	struct slave *tx_slave = NULL;
+	char do_tx_balance = 1;
+	int hash_size = 0;
+	u32 hash_index = 0;
+	u8 *hash_start = NULL;
+	u8 mac_bcast[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff};
+
+	if (!IS_UP(dev)) { /* bond down */
+		dev_kfree_skb(skb);
+		return 0;
+	}
+
+	/* make sure that the current_slave and the slaves list do
+	 * not change during tx
+	 */
+	read_lock(&bond->lock);
+
+	if (bond->slave_cnt == 0) {
+		/* no suitable interface, frame not sent */
+		dev_kfree_skb(skb);
+		read_unlock(&bond->lock);
+		return 0;
+	}
+
+	read_lock(&bond->ptrlock);
+
+	switch (ntohs(skb->protocol)) {
+	case ETH_P_IP:
+		if ((memcmp(eth_data->h_dest, mac_bcast, ETH_ALEN) == 0) ||
+		    (skb->nh.iph->daddr == 0xffffffff)) {
+			do_tx_balance = 0;
+			break;
+		}
+		hash_start = (char*)&(skb->nh.iph->daddr);
+		hash_size = 4;
+		break;
+
+	case ETH_P_IPV6:
+		if (memcmp(eth_data->h_dest, mac_bcast, ETH_ALEN) == 0) {
+			do_tx_balance = 0;
+			break;
+		}
+
+		hash_start = (char*)&(skb->nh.ipv6h->daddr);
+		hash_size = 16;
+		break;
+
+	case ETH_P_IPX:
+		if (skb->nh.ipxh->ipx_checksum !=
+		    __constant_htons(IPX_NO_CHECKSUM)) {
+			/* something is wrong with this packet */
+			do_tx_balance = 0;
+			break;
+		}
+
+		if (skb->nh.ipxh->ipx_type !=
+		    __constant_htons(IPX_TYPE_NCP)) {
+			/* The only protocol worth balancing in
+			 * this family since it has an "ARP" like
+			 * mechanism
+			 */
+			do_tx_balance = 0;
+			break;
+		}
+
+		hash_start = (char*)eth_data->h_dest;
+		hash_size = ETH_ALEN;
+		break;
+
+	case ETH_P_ARP:
+		do_tx_balance = 0;
+		if (bond_info->rlb_enabled) {
+			tx_slave = rlb_arp_xmit(skb, bond);
+		}
+		break;
+
+	default:
+		do_tx_balance = 0;
+		break;
+	}
+
+	if (do_tx_balance) {
+		hash_index = _simple_hash(hash_start, hash_size);
+		tx_slave = tlb_choose_channel(bond, hash_index, skb->len);
+	}
+
+	if (!tx_slave) {
+		/* unbalanced or unassigned, send through primary */
+		tx_slave = bond->current_slave;
+		bond_info->unbalanced_load += skb->len;
+	}
+
+	if (tx_slave && SLAVE_IS_OK(tx_slave)) {
+		skb->dev = tx_slave->dev;
+		if (tx_slave != bond->current_slave) {
+			memcpy(eth_data->h_source,
+				tx_slave->dev->dev_addr,
+				ETH_ALEN);
+		}
+		dev_queue_xmit(skb);
+	} else {
+		/* no suitable interface, frame not sent */
+		if (tx_slave) {
+			tlb_clear_slave(bond, tx_slave, 0);
+		}
+		dev_kfree_skb(skb);
+	}
+
+	read_unlock(&bond->ptrlock);
+	read_unlock(&bond->lock);
+	return 0;
+}
+
+void
+bond_alb_monitor(struct bonding *bond)
+{
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+	struct slave *slave = NULL;
+
+	read_lock(&bond->lock);
+
+	if ((bond->slave_cnt == 0) || !(bond->device->flags & IFF_UP)) {
+		bond_info->tx_rebalance_counter = 0;
+		bond_info->lp_counter = 0;
+		goto out;
+	}
+
+	bond_info->tx_rebalance_counter++;
+	bond_info->lp_counter++;
+
+	/* send learning packets */
+	if (bond_info->lp_counter >= BOND_ALB_LP_TICKS) {
+		/* change of current_slave involves swapping of mac addresses.
+		 * in order to avoid this swapping from happening while
+		 * sending the learning packets, the ptrlock must be held for
+		 * read.
+		 */
+		read_lock(&bond->ptrlock);
+		slave = bond_get_first_slave(bond);
+		while (slave) {
+			alb_send_learning_packets(slave,slave->dev->dev_addr);
+			slave = bond_get_next_slave(bond, slave);
+		}
+		read_unlock(&bond->ptrlock);
+
+		bond_info->lp_counter = 0;
+	}
+
+	/* rebalance tx traffic */
+	if (bond_info->tx_rebalance_counter >= BOND_TLB_REBALANCE_TICKS) {
+		read_lock(&bond->ptrlock);
+		slave = bond_get_first_slave(bond);
+		while (slave) {
+			tlb_clear_slave(bond, slave, 1);
+			if (slave == bond->current_slave) {
+				SLAVE_TLB_INFO(slave).load =
+					bond_info->unbalanced_load /
+						BOND_TLB_REBALANCE_INTERVAL;
+				bond_info->unbalanced_load = 0;
+			}
+			slave = bond_get_next_slave(bond, slave);
+		}
+		read_unlock(&bond->ptrlock);
+		bond_info->tx_rebalance_counter = 0;
+	}
+
+	/* handle rlb stuff */
+	if (bond_info->rlb_enabled) {
+		/* the following code changes the promiscuity of the
+		 * the current_slave. It needs to be locked with a
+		 * write lock to protect from other code that also
+		 * sets the promiscuity.
+		 */
+		write_lock(&bond->ptrlock);
+		if (bond_info->primary_is_promisc &&
+		    (++bond_info->rlb_promisc_timeout_counter >=
+			RLB_PROMISC_TIMEOUT)) {
+
+			bond_info->rlb_promisc_timeout_counter = 0;
+
+			/* If the primary was set to promiscuous mode
+			 * because a slave was disabled then
+			 * it can now leave promiscuous mode.
+			 */
+			dev_set_promiscuity(bond->current_slave->dev, -1);
+			bond_info->primary_is_promisc = 0;
+		}
+		write_unlock(&bond->ptrlock);
+
+		if (bond_info->rlb_rebalance == 1) {
+			bond_info->rlb_rebalance = 0;
+			rlb_rebalance(bond);
+		}
+
+		/* check if clients need updating */
+		if (bond_info->rx_ntt) {
+			if (bond_info->rlb_update_delay_counter) {
+				--bond_info->rlb_update_delay_counter;
+			} else {
+				rlb_update_rx_clients(bond);
+				if (bond_info->rlb_update_retry_counter) {
+					--bond_info->rlb_update_retry_counter;
+				} else {
+					bond_info->rx_ntt = 0;
+				}
+			}
+		}
+	}
+
+out:
+	read_unlock(&bond->lock);
+
+	if (bond->device->flags & IFF_UP) {
+		/* re-arm the timer */
+		mod_timer(&(bond_info->alb_timer),
+			jiffies + (HZ/ALB_TIMER_TICKS_PER_SEC));
+	}
+}
+
+/* assumption: called before the slave is attched to the bond
+ * and not locked by the bond lock
+ */
+int
+bond_alb_init_slave(struct bonding *bond, struct slave *slave)
+{
+	int err = 0;
+
+	err = alb_set_mac_addr(slave, slave->perm_hwaddr,
+				bond->alb_info.rlb_enabled);
+	if (err) {
+		return err;
+	}
+
+	/* caller must hold the bond lock for write since the mac addresses
+	 * are compared and may be swapped.
+	 */
+	write_lock_bh(&bond->lock);
+
+	err = alb_handle_addr_collision_on_attach(bond, slave);
+
+	write_unlock_bh(&bond->lock);
+
+	if (err) {
+		return err;
+	}
+
+	tlb_init_slave(slave);
+
+	/* order a rebalance ASAP */
+	bond->alb_info.tx_rebalance_counter = BOND_TLB_REBALANCE_TICKS;
+
+	if (bond->alb_info.rlb_enabled) {
+		bond->alb_info.rlb_rebalance = 1;
+	}
+
+	return 0;
+}
+
+/* Caller must hold bond lock for write */
+void
+bond_alb_deinit_slave(struct bonding *bond, struct slave *slave)
+{
+	if (bond->slave_cnt > 1) {
+		alb_change_hw_addr_on_detach(bond, slave);
+	}
+
+	tlb_clear_slave(bond, slave, 0);
+
+	if (bond->alb_info.rlb_enabled) {
+		bond->alb_info.next_rx_slave = NULL;
+		rlb_clear_slave(bond, slave);
+	}
+}
+
+/* Caller must hold bond lock for read */
+void
+bond_alb_handle_link_change(struct bonding *bond, struct slave *slave,
+			    char link)
+{
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+
+	if (link == BOND_LINK_DOWN) {
+		tlb_clear_slave(bond, slave, 0);
+		if (bond->alb_info.rlb_enabled) {
+			rlb_clear_slave(bond, slave);
+		}
+	} else if (link == BOND_LINK_UP) {
+		/* order a rebalance ASAP */
+		bond_info->tx_rebalance_counter = BOND_TLB_REBALANCE_TICKS;
+		if (bond->alb_info.rlb_enabled) {
+			bond->alb_info.rlb_rebalance = 1;
+			/* If the updelay module parameter is smaller than the
+			 * forwarding delay of the switch the rebalance will
+			 * not work because the rebalance arp replies will
+			 * not be forwarded to the clients..
+			 */
+		}
+	}
+}
+
+/**
+ * bond_alb_assign_current_slave - assign new current_slave
+ * @bond: our bonding struct
+ * @new_slave: new slave to assign
+ *
+ * Set the bond->current_slave to @new_slave and handle
+ * mac address swapping and promiscuity changes as needed.
+ *
+ * Caller must hold bond ptrlock for write (or bond lock for write)
+ */
+void
+bond_alb_assign_current_slave(struct bonding *bond, struct slave *new_slave)
+{
+	struct slave *swap_slave = bond->current_slave;
+
+	if (bond->current_slave == new_slave) {
+		return;
+	}
+
+	if (bond->current_slave && bond->alb_info.primary_is_promisc) {
+		dev_set_promiscuity(bond->current_slave->dev, -1);
+		bond->alb_info.primary_is_promisc = 0;
+		bond->alb_info.rlb_promisc_timeout_counter = 0;
+	}
+
+	bond->current_slave = new_slave;
+
+	if (!new_slave || (bond->slave_cnt == 0)) {
+		return;
+	}
+
+	/* set the new current_slave to the bonds mac address
+	 * i.e. swap mac addresses of old current_slave and new current_slave
+	 */
+	if (!swap_slave) {
+		/* find slave that is holding the bond's mac address */
+		swap_slave = bond_get_first_slave(bond);
+		while (swap_slave) {
+			if (!memcmp(swap_slave->dev->dev_addr,
+				bond->device->dev_addr, ETH_ALEN)) {
+				break;
+			}
+			swap_slave = bond_get_next_slave(bond, swap_slave);
+		}
+	}
+
+	/* current_slave must be set before calling alb_swap_mac_addr */
+	if (swap_slave) {
+		/* swap mac address */
+		alb_swap_mac_addr(bond, swap_slave, new_slave);
+	} else {
+		/* set the new_slave to the bond mac address */
+		alb_set_mac_addr(new_slave, bond->device->dev_addr,
+				 bond->alb_info.rlb_enabled);
+		/* fasten bond mac on new current slave */
+		alb_send_learning_packets(new_slave, bond->device->dev_addr);
+	}
+}
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/bonding/bond_alb.h linux-2.4.22-pre2/drivers/net/bonding/bond_alb.h
--- linux-2.4.21/drivers/net/bonding/bond_alb.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/bonding/bond_alb.h	2003-06-26 21:43:28.000000000 +0000
@@ -0,0 +1,127 @@
+/*
+ * Copyright(c) 1999 - 2003 Intel 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 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.
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called LICENSE.
+ */
+
+#ifndef __BOND_ALB_H__
+#define __BOND_ALB_H__
+
+#include <linux/if_ether.h>
+
+struct bonding;
+struct slave;
+
+#define BOND_ALB_INFO(bond)   ((bond)->alb_info)
+#define SLAVE_TLB_INFO(slave) ((slave)->tlb_info)
+
+struct tlb_client_info {
+	struct slave *tx_slave;	/* A pointer to slave used for transmiting
+				 * packets to a Client that the Hash function
+				 * gave this entry index.
+				 */
+	u32 tx_bytes;		/* Each Client acumulates the BytesTx that
+				 * were tranmitted to it, and after each
+				 * CallBack the LoadHistory is devided
+				 * by the balance interval
+				 */
+	u32 load_history;	/* This field contains the amount of Bytes
+				 * that were transmitted to this client by
+				 * the server on the previous balance
+				 * interval in Bps.
+				 */
+	u32 next;		/* The next Hash table entry index, assigned
+				 * to use the same adapter for transmit.
+				 */
+	u32 prev;		/* The previous Hash table entry index,
+				 * assigned to use the same
+				 */
+};
+
+/* -------------------------------------------------------------------------
+ * struct rlb_client_info contains all info related to a specific rx client
+ * connection. This is the Clients Hash Table entry struct
+ * -------------------------------------------------------------------------
+ */
+struct rlb_client_info {
+	u32 ip_src;		/* the server IP address */
+	u32 ip_dst;		/* the client IP address */
+	u8  mac_dst[ETH_ALEN];	/* the client MAC address */
+	u32 next;		/* The next Hash table entry index */
+	u32 prev;		/* The previous Hash table entry index */
+	u8  assigned;		/* checking whether this entry is assigned */
+	u8  ntt;		/* flag - need to transmit client info */
+	struct slave *slave;	/* the slave assigned to this client */
+};
+
+struct tlb_slave_info {
+	u32 head;	/* Index to the head of the bi-directional clients
+			 * hash table entries list. The entries in the list
+			 * are the entries that were assigned to use this
+			 * slave for transmit.
+			 */
+	u32 load;	/* Each slave sums the loadHistory of all clients
+			 * assigned to it
+			 */
+};
+
+struct alb_bond_info {
+	struct timer_list	alb_timer;
+	struct tlb_client_info	*tx_hashtbl; /* Dynamically allocated */
+	spinlock_t		tx_hashtbl_lock;
+	u32			unbalanced_load;
+	int			tx_rebalance_counter;
+	int			lp_counter;
+	/* -------- rlb parameters -------- */
+	int rlb_enabled;
+	struct packet_type	rlb_pkt_type;
+	struct rlb_client_info	*rx_hashtbl;	/* Receive hash table */
+	spinlock_t		rx_hashtbl_lock;
+	u32			rx_hashtbl_head;
+	u8			rx_ntt;	/* flag - need to transmit
+					 * to all rx clients
+					 */
+	struct slave		*next_rx_slave;/* next slave to be assigned
+						* to a new rx client for
+						*/
+	u32			rlb_interval_counter;
+	u8			primary_is_promisc;	   /* boolean */
+	u32			rlb_promisc_timeout_counter;/* counts primary
+							     * promiscuity time
+							     */
+	u32			rlb_update_delay_counter;
+	u32			rlb_update_retry_counter;/* counter of retries
+							  * of client update
+							  */
+	u8			rlb_rebalance;	/* flag - indicates that the
+						 * rx traffic should be
+						 * rebalanced
+						 */
+};
+
+int bond_alb_initialize(struct bonding *bond, int rlb_enabled);
+void bond_alb_deinitialize(struct bonding *bond);
+int bond_alb_init_slave(struct bonding *bond, struct slave *slave);
+void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave);
+void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link);
+void bond_alb_assign_current_slave(struct bonding *bond, struct slave *new_slave);
+int bond_alb_xmit(struct sk_buff *skb, struct net_device *dev);
+void bond_alb_monitor(struct bonding *bond);
+
+#endif /* __BOND_ALB_H__ */
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/bonding/bond_main.c linux-2.4.22-pre2/drivers/net/bonding/bond_main.c
--- linux-2.4.21/drivers/net/bonding/bond_main.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/bonding/bond_main.c	2003-06-26 21:43:18.000000000 +0000
@@ -0,0 +1,4021 @@
+/*
+ * originally based on the dummy device.
+ *
+ * Copyright 1999, Thomas Davis, tadavis@lbl.gov.  
+ * Licensed under the GPL. Based on dummy.c, and eql.c devices.
+ *
+ * bonding.c: an Ethernet Bonding driver
+ *
+ * This is useful to talk to a Cisco EtherChannel compatible equipment:
+ *	Cisco 5500
+ *	Sun Trunking (Solaris)
+ *	Alteon AceDirector Trunks
+ *	Linux Bonding
+ *	and probably many L2 switches ...
+ *
+ * How it works:
+ *    ifconfig bond0 ipaddress netmask up
+ *      will setup a network device, with an ip address.  No mac address 
+ *	will be assigned at this time.  The hw mac address will come from 
+ *	the first slave bonded to the channel.  All slaves will then use 
+ *	this hw mac address.
+ *
+ *    ifconfig bond0 down
+ *         will release all slaves, marking them as down.
+ *
+ *    ifenslave bond0 eth0
+ *	will attach eth0 to bond0 as a slave.  eth0 hw mac address will either
+ *	a: be used as initial mac address
+ *	b: if a hw mac address already is there, eth0's hw mac address 
+ *	   will then be set from bond0.
+ *
+ * v0.1 - first working version.
+ * v0.2 - changed stats to be calculated by summing slaves stats.
+ *
+ * Changes:
+ * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ * - fix leaks on failure at bond_init
+ *
+ * 2000/09/30 - Willy Tarreau <willy at meta-x.org>
+ *     - added trivial code to release a slave device.
+ *     - fixed security bug (CAP_NET_ADMIN not checked)
+ *     - implemented MII link monitoring to disable dead links :
+ *       All MII capable slaves are checked every <miimon> milliseconds
+ *       (100 ms seems good). This value can be changed by passing it to
+ *       insmod. A value of zero disables the monitoring (default).
+ *     - fixed an infinite loop in bond_xmit_roundrobin() when there's no
+ *       good slave.
+ *     - made the code hopefully SMP safe
+ *
+ * 2000/10/03 - Willy Tarreau <willy at meta-x.org>
+ *     - optimized slave lists based on relevant suggestions from Thomas Davis
+ *     - implemented active-backup method to obtain HA with two switches:
+ *       stay as long as possible on the same active interface, while we
+ *       also monitor the backup one (MII link status) because we want to know
+ *       if we are able to switch at any time. ( pass "mode=1" to insmod )
+ *     - lots of stress testings because we need it to be more robust than the
+ *       wires ! :->
+ *
+ * 2000/10/09 - Willy Tarreau <willy at meta-x.org>
+ *     - added up and down delays after link state change.
+ *     - optimized the slaves chaining so that when we run forward, we never
+ *       repass through the bond itself, but we can find it by searching
+ *       backwards. Renders the deletion more difficult, but accelerates the
+ *       scan.
+ *     - smarter enslaving and releasing.
+ *     - finer and more robust SMP locking
+ *
+ * 2000/10/17 - Willy Tarreau <willy at meta-x.org>
+ *     - fixed two potential SMP race conditions
+ *
+ * 2000/10/18 - Willy Tarreau <willy at meta-x.org>
+ *     - small fixes to the monitoring FSM in case of zero delays
+ * 2000/11/01 - Willy Tarreau <willy at meta-x.org>
+ *     - fixed first slave not automatically used in trunk mode.
+ * 2000/11/10 : spelling of "EtherChannel" corrected.
+ * 2000/11/13 : fixed a race condition in case of concurrent accesses to ioctl().
+ * 2000/12/16 : fixed improper usage of rtnl_exlock_nowait().
+ *
+ * 2001/1/3 - Chad N. Tindel <ctindel at ieee dot org>
+ *     - The bonding driver now simulates MII status monitoring, just like
+ *       a normal network device.  It will show that the link is down iff
+ *       every slave in the bond shows that their links are down.  If at least
+ *       one slave is up, the bond's MII status will appear as up.
+ *
+ * 2001/2/7 - Chad N. Tindel <ctindel at ieee dot org>
+ *     - Applications can now query the bond from user space to get
+ *       information which may be useful.  They do this by calling
+ *       the BOND_INFO_QUERY ioctl.  Once the app knows how many slaves
+ *       are in the bond, it can call the BOND_SLAVE_INFO_QUERY ioctl to
+ *       get slave specific information (# link failures, etc).  See
+ *       <linux/if_bonding.h> for more details.  The structs of interest
+ *       are ifbond and ifslave.
+ *
+ * 2001/4/5 - Chad N. Tindel <ctindel at ieee dot org>
+ *     - Ported to 2.4 Kernel
+ * 
+ * 2001/5/2 - Jeffrey E. Mast <jeff at mastfamily dot com>
+ *     - When a device is detached from a bond, the slave device is no longer
+ *       left thinking that is has a master.
+ *
+ * 2001/5/16 - Jeffrey E. Mast <jeff at mastfamily dot com>
+ *     - memset did not appropriately initialized the bond rw_locks. Used 
+ *       rwlock_init to initialize to unlocked state to prevent deadlock when 
+ *       first attempting a lock
+ *     - Called SET_MODULE_OWNER for bond device
+ *
+ * 2001/5/17 - Tim Anderson <tsa at mvista.com>
+ *     - 2 paths for releasing for slave release; 1 through ioctl
+ *       and 2) through close. Both paths need to release the same way.
+ *     - the free slave in bond release is changing slave status before
+ *       the free. The netdev_set_master() is intended to change slave state
+ *       so it should not be done as part of the release process.
+ *     - Simple rule for slave state at release: only the active in A/B and
+ *       only one in the trunked case.
+ *
+ * 2001/6/01 - Tim Anderson <tsa at mvista.com>
+ *     - Now call dev_close when releasing a slave so it doesn't screw up
+ *       out routing table.
+ *
+ * 2001/6/01 - Chad N. Tindel <ctindel at ieee dot org>
+ *     - Added /proc support for getting bond and slave information.
+ *       Information is in /proc/net/<bond device>/info. 
+ *     - Changed the locking when calling bond_close to prevent deadlock.
+ *
+ * 2001/8/05 - Janice Girouard <girouard at us.ibm.com>
+ *     - correct problem where refcnt of slave is not incremented in bond_ioctl
+ *       so the system hangs when halting.
+ *     - correct locking problem when unable to malloc in bond_enslave.
+ *     - adding bond_xmit_xor logic.
+ *     - adding multiple bond device support.
+ *
+ * 2001/8/13 - Erik Habbinga <erik_habbinga at hp dot com>
+ *     - correct locking problem with rtnl_exlock_nowait
+ *
+ * 2001/8/23 - Janice Girouard <girouard at us.ibm.com>
+ *     - bzero initial dev_bonds, to correct oops
+ *     - convert SIOCDEVPRIVATE to new MII ioctl calls
+ *
+ * 2001/9/13 - Takao Indoh <indou dot takao at jp dot fujitsu dot com>
+ *     - Add the BOND_CHANGE_ACTIVE ioctl implementation
+ *
+ * 2001/9/14 - Mark Huth <mhuth at mvista dot com>
+ *     - Change MII_LINK_READY to not check for end of auto-negotiation,
+ *       but only for an up link.
+ *
+ * 2001/9/20 - Chad N. Tindel <ctindel at ieee dot org>
+ *     - Add the device field to bonding_t.  Previously the net_device 
+ *       corresponding to a bond wasn't available from the bonding_t 
+ *       structure.
+ *
+ * 2001/9/25 - Janice Girouard <girouard at us.ibm.com>
+ *     - add arp_monitor for active backup mode
+ *
+ * 2001/10/23 - Takao Indoh <indou dot takao at jp dot fujitsu dot com>
+ *     - Various memory leak fixes
+ *
+ * 2001/11/5 - Mark Huth <mark dot huth at mvista dot com>
+ *     - Don't take rtnl lock in bond_mii_monitor as it deadlocks under 
+ *       certain hotswap conditions.  
+ *       Note:  this same change may be required in bond_arp_monitor ???
+ *     - Remove possibility of calling bond_sethwaddr with NULL slave_dev ptr 
+ *     - Handle hot swap ethernet interface deregistration events to remove
+ *       kernel oops following hot swap of enslaved interface
+ *
+ * 2002/1/2 - Chad N. Tindel <ctindel at ieee dot org>
+ *     - Restore original slave flags at release time.
+ *
+ * 2002/02/18 - Erik Habbinga <erik_habbinga at hp dot com>
+ *     - bond_release(): calling kfree on our_slave after call to
+ *       bond_restore_slave_flags, not before
+ *     - bond_enslave(): saving slave flags into original_flags before
+ *       call to netdev_set_master, so the IFF_SLAVE flag doesn't end
+ *       up in original_flags
+ *
+ * 2002/04/05 - Mark Smith <mark.smith at comdev dot cc> and
+ *              Steve Mead <steve.mead at comdev dot cc>
+ *     - Port Gleb Natapov's multicast support patchs from 2.4.12
+ *       to 2.4.18 adding support for multicast.
+ *
+ * 2002/06/10 - Tony Cureington <tony.cureington * hp_com>
+ *     - corrected uninitialized pointer (ifr.ifr_data) in bond_check_dev_link;
+ *       actually changed function to use MIIPHY, then MIIREG, and finally
+ *       ETHTOOL to determine the link status
+ *     - fixed bad ifr_data pointer assignments in bond_ioctl
+ *     - corrected mode 1 being reported as active-backup in bond_get_info;
+ *       also added text to distinguish type of load balancing (rr or xor)
+ *     - change arp_ip_target module param from "1-12s" (array of 12 ptrs)
+ *       to "s" (a single ptr)
+ *
+ * 2002/08/30 - Jay Vosburgh <fubar at us dot ibm dot com>
+ *     - Removed acquisition of xmit_lock in set_multicast_list; caused
+ *       deadlock on SMP (lock is held by caller).
+ *     - Revamped SIOCGMIIPHY, SIOCGMIIREG portion of bond_check_dev_link().
+ *
+ * 2002/09/18 - Jay Vosburgh <fubar at us dot ibm dot com>
+ *     - Fixed up bond_check_dev_link() (and callers): removed some magic
+ *	 numbers, banished local MII_ defines, wrapped ioctl calls to
+ *	 prevent EFAULT errors
+ *
+ * 2002/9/30 - Jay Vosburgh <fubar at us dot ibm dot com>
+ *     - make sure the ip target matches the arp_target before saving the
+ *	 hw address.
+ *
+ * 2002/9/30 - Dan Eisner <eisner at 2robots dot com>
+ *     - make sure my_ip is set before taking down the link, since
+ *	 not all switches respond if the source ip is not set.
+ *
+ * 2002/10/8 - Janice Girouard <girouard at us dot ibm dot com>
+ *     - read in the local ip address when enslaving a device
+ *     - add primary support
+ *     - make sure 2*arp_interval has passed when a new device
+ *       is brought on-line before taking it down.
+ *
+ * 2002/09/11 - Philippe De Muyter <phdm at macqel dot be>
+ *     - Added bond_xmit_broadcast logic.
+ *     - Added bond_mode() support function.
+ *
+ * 2002/10/26 - Laurent Deniel <laurent.deniel at free.fr>
+ *     - allow to register multicast addresses only on active slave
+ *       (useful in active-backup mode)
+ *     - add multicast module parameter
+ *     - fix deletion of multicast groups after unloading module
+ *
+ * 2002/11/06 - Kameshwara Rayaprolu <kameshwara.rao * wipro_com>
+ *     - Changes to prevent panic from closing the device twice; if we close 
+ *       the device in bond_release, we must set the original_flags to down 
+ *       so it won't be closed again by the network layer.
+ *
+ * 2002/11/07 - Tony Cureington <tony.cureington * hp_com>
+ *     - Fix arp_target_hw_addr memory leak
+ *     - Created activebackup_arp_monitor function to handle arp monitoring 
+ *       in active backup mode - the bond_arp_monitor had several problems... 
+ *       such as allowing slaves to tx arps sequentially without any delay 
+ *       for a response
+ *     - Renamed bond_arp_monitor to loadbalance_arp_monitor and re-wrote
+ *       this function to just handle arp monitoring in load-balancing mode;
+ *       it is a lot more compact now
+ *     - Changes to ensure one and only one slave transmits in active-backup 
+ *       mode
+ *     - Robustesize parameters; warn users about bad combinations of 
+ *       parameters; also if miimon is specified and a network driver does 
+ *       not support MII or ETHTOOL, inform the user of this
+ *     - Changes to support link_failure_count when in arp monitoring mode
+ *     - Fix up/down delay reported in /proc
+ *     - Added version; log version; make version available from "modinfo -d"
+ *     - Fixed problem in bond_check_dev_link - if the first IOCTL (SIOCGMIIPH)
+ *	 failed, the ETHTOOL ioctl never got a chance
+ *
+ * 2002/11/16 - Laurent Deniel <laurent.deniel at free.fr>
+ *     - fix multicast handling in activebackup_arp_monitor
+ *     - remove one unnecessary and confusing current_slave == slave test 
+ *	 in activebackup_arp_monitor
+ *
+ *  2002/11/17 - Laurent Deniel <laurent.deniel at free.fr>
+ *     - fix bond_slave_info_query when slave_id = num_slaves
+ *
+ *  2002/11/19 - Janice Girouard <girouard at us dot ibm dot com>
+ *     - correct ifr_data reference.  Update ifr_data reference
+ *       to mii_ioctl_data struct values to avoid confusion.
+ *
+ *  2002/11/22 - Bert Barbe <bert.barbe at oracle dot com>
+ *      - Add support for multiple arp_ip_target
+ *
+ *  2002/12/13 - Jay Vosburgh <fubar at us dot ibm dot com>
+ *	- Changed to allow text strings for mode and multicast, e.g.,
+ *	  insmod bonding mode=active-backup.  The numbers still work.
+ *	  One change: an invalid choice will cause module load failure,
+ *	  rather than the previous behavior of just picking one.
+ *	- Minor cleanups; got rid of dup ctype stuff, atoi function
+ * 
+ * 2003/02/07 - Jay Vosburgh <fubar at us dot ibm dot com>
+ *	- Added use_carrier module parameter that causes miimon to
+ *	  use netif_carrier_ok() test instead of MII/ETHTOOL ioctls.
+ *	- Minor cleanups; consolidated ioctl calls to one function.
+ *
+ * 2003/02/07 - Tony Cureington <tony.cureington * hp_com>
+ *	- Fix bond_mii_monitor() logic error that could result in
+ *	  bonding round-robin mode ignoring links after failover/recovery
+ *
+ * 2003/03/17 - Jay Vosburgh <fubar at us dot ibm dot com>
+ *	- kmalloc fix (GPF_KERNEL to GPF_ATOMIC) reported by
+ *	  Shmulik dot Hen at intel.com.
+ *	- Based on discussion on mailing list, changed use of
+ *	  update_slave_cnt(), created wrapper functions for adding/removing
+ *	  slaves, changed bond_xmit_xor() to check slave_cnt instead of
+ *	  checking slave and slave->dev (which only worked by accident).
+ *	- Misc code cleanup: get arp_send() prototype from header file,
+ *	  add max_bonds to bonding.txt.
+ *
+ * 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
+ *		Shmulik Hen <shmulik.hen at intel dot com>
+ *	- Make sure only bond_attach_slave() and bond_detach_slave() can
+ *	  manipulate the slave list, including slave_cnt, even when in
+ *	  bond_release_all().
+ *	- Fixed hang in bond_release() with traffic running:
+ *	  netdev_set_master() must not be called from within the bond lock.
+ *
+ * 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
+ *		Shmulik Hen <shmulik.hen at intel dot com>
+ *	- Fixed hang in bond_enslave() with traffic running:
+ *	  netdev_set_master() must not be called from within the bond lock.
+ *
+ * 2003/03/18 - Amir Noam <amir.noam at intel dot com>
+ *	- Added support for getting slave's speed and duplex via ethtool.
+ *	  Needed for 802.3ad and other future modes.
+ *
+ * 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
+ *		Shmulik Hen <shmulik.hen at intel dot com>
+ *	- Enable support of modes that need to use the unique mac address of
+ *	  each slave.
+ *	  * bond_enslave(): Moved setting the slave's mac address, and
+ *	    openning it, from the application to the driver. This breaks
+ *	    backward comaptibility with old versions of ifenslave that open
+ *	     the slave before enalsving it !!!.
+ *	  * bond_release(): The driver also takes care of closing the slave
+ *	    and restoring its original mac address.
+ *	- Removed the code that restores all base driver's flags.
+ *	  Flags are automatically restored once all undo stages are done
+ *	  properly.
+ *	- Block possibility of enslaving before the master is up. This
+ *	  prevents putting the system in an unstable state.
+ *
+ * 2003/03/18 - Amir Noam <amir.noam at intel dot com>,
+ *		Tsippy Mendelson <tsippy.mendelson at intel dot com> and
+ *		Shmulik Hen <shmulik.hen at intel dot com>
+ *    - Added support for IEEE 802.3ad Dynamic link aggregation mode.
+ *
+ * 2003/05/01 - Amir Noam <amir.noam at intel dot com>
+ *    - Added ABI version control to restore compatibility between
+ *      new/old ifenslave and new/old bonding.
+ *
+ * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
+ *    - Fixed bug in bond_release_all(): save old value of current_slave
+ *      before setting it to NULL.
+ *    - Changed driver versioning scheme to include version number instead
+ *      of release date (that is already in another field). There are 3
+ *      fields X.Y.Z where:
+ *            X - Major version - big behavior changes
+ *            Y - Minor version - addition of features
+ *            Z - Extra version - minor changes and bug fixes
+ *      The current version is 1.0.0 as a base line.
+ *
+ * 2003/05/01 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
+ *		Amir Noam <amir.noam at intel dot com>
+ *	- Added support for lacp_rate module param.
+ *	- Code beautification and style changes (mainly in comments).
+ *	  new version - 1.0.1
+ *
+ * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
+ *	- Based on discussion on mailing list, changed locking scheme
+ *	  to use lock/unlock or lock_bh/unlock_bh appropriately instead
+ *	  of lock_irqsave/unlock_irqrestore. The new scheme helps exposing
+ *	  hidden bugs and solves system hangs that occurred due to the fact
+ *	  that holding lock_irqsave doesn't prevent softirqs from running.
+ *	  This also increases total throughput since interrupts are not
+ *	  blocked on each transmitted packets or monitor timeout.
+ *	  new version - 2.0.0
+ *
+ * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
+ *	- Added support for Transmit load balancing mode.
+ *	- Concentrate all assignments of current_slave to a single point
+ *	  so specific modes can take actions when the primary adapter is
+ *	  changed.
+ *	- Take the updelay parameter into consideration during bond_enslave
+ *	  since some adapters loose their link during setting the device.
+ *	- Renamed bond_3ad_link_status_changed() to
+ *	  bond_3ad_handle_link_change() for compatibility with TLB.
+ *	  new version - 2.1.0
+ *
+ * 2003/05/01 - Tsippy Mendelson <tsippy.mendelson at intel dot com>
+ *	- Added support for Adaptive load balancing mode which is
+ *	  equivalent to Transmit load balancing + Receive load balancing.
+ *	  new version - 2.2.0
+ *
+ * 2003/05/15 - Jay Vosburgh <fubar at us dot ibm dot com>
+ *	- Applied fix to activebackup_arp_monitor posted to bonding-devel
+ *	  by Tony Cureington <tony.cureington * hp_com>.  Fixes ARP
+ *	  monitor endless failover bug.  Version to 2.2.10
+ *
+ * 2003/05/20 - Amir Noam <amir.noam at intel dot com>
+ *	- Fixed bug in ABI version control - Don't commit to a specific
+ *	  ABI version if receiving unsupported ioctl commands.
+ *
+ * 2003/05/22 - Jay Vosburgh <fubar at us dot ibm dot com>
+ *	- In conjunction with fix for ifenslave -c, in
+ *	  bond_change_active(), changing to the already active slave
+ *	  is no longer an error (it successfully does nothing).
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/sched.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/ip.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/init.h>
+#include <linux/timer.h>
+#include <linux/socket.h>
+#include <linux/ctype.h>
+#include <linux/inet.h>
+#include <asm/system.h>
+#include <asm/bitops.h>
+#include <asm/io.h>
+#include <asm/dma.h>
+#include <asm/uaccess.h>
+#include <linux/errno.h>
+
+#include <linux/netdevice.h>
+#include <linux/inetdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+#include <net/sock.h>
+#include <linux/rtnetlink.h>
+
+#include <linux/if_bonding.h>
+#include <linux/smp.h>
+#include <linux/if_ether.h>
+#include <net/arp.h>
+#include <linux/mii.h>
+#include <linux/ethtool.h>
+#include "bonding.h"
+#include "bond_3ad.h"
+#include "bond_alb.h"
+
+#define DRV_VERSION		"2.2.11"
+#define DRV_RELDATE		"May 29, 2003"
+#define DRV_NAME		"bonding"
+#define DRV_DESCRIPTION		"Ethernet Channel Bonding Driver"
+
+static const char *version =
+DRV_NAME ".c:v" DRV_VERSION " (" DRV_RELDATE ")\n";
+
+/* monitor all links that often (in milliseconds). <=0 disables monitoring */
+#ifndef BOND_LINK_MON_INTERV
+#define BOND_LINK_MON_INTERV	0
+#endif
+
+#ifndef BOND_LINK_ARP_INTERV
+#define BOND_LINK_ARP_INTERV	0
+#endif
+
+#ifndef MAX_ARP_IP_TARGETS
+#define MAX_ARP_IP_TARGETS 16
+#endif
+
+struct bond_parm_tbl {
+	char *modename;
+	int mode;
+};
+
+static int arp_interval = BOND_LINK_ARP_INTERV;
+static char *arp_ip_target[MAX_ARP_IP_TARGETS] = { NULL, };
+static unsigned long arp_target[MAX_ARP_IP_TARGETS] = { 0, } ;
+static int arp_ip_count = 0;
+static u32 my_ip = 0;
+char *arp_target_hw_addr = NULL;
+
+static char *primary= NULL;
+
+static int app_abi_ver = 0;
+static int orig_app_abi_ver = -1; /* This is used to save the first ABI version
+				   * we receive from the application. Once set,
+				   * it won't be changed, and the module will
+				   * refuse to enslave/release interfaces if the
+				   * command comes from an application using
+				   * another ABI version.
+				   */
+
+static int max_bonds	= BOND_DEFAULT_MAX_BONDS;
+static int miimon	= BOND_LINK_MON_INTERV;
+static int use_carrier	= 1;
+static int bond_mode	= BOND_MODE_ROUNDROBIN;
+static int updelay	= 0;
+static int downdelay	= 0;
+
+static char *mode	= NULL;
+
+static struct bond_parm_tbl bond_mode_tbl[] = {
+{	"balance-rr",		BOND_MODE_ROUNDROBIN},
+{	"active-backup",	BOND_MODE_ACTIVEBACKUP},
+{	"balance-xor",		BOND_MODE_XOR},
+{	"broadcast",		BOND_MODE_BROADCAST},
+{	"802.3ad",		BOND_MODE_8023AD},
+{	"balance-tlb",		BOND_MODE_TLB},
+{	"balance-alb",		BOND_MODE_ALB},
+{	NULL,			-1},
+};
+
+static int multicast_mode	= BOND_MULTICAST_ALL;
+static char *multicast		= NULL;
+
+static struct bond_parm_tbl bond_mc_tbl[] = {
+{	"disabled",		BOND_MULTICAST_DISABLED},
+{	"active",		BOND_MULTICAST_ACTIVE},
+{	"all",			BOND_MULTICAST_ALL},
+{	NULL,			-1},
+};
+
+static int lacp_fast		= 0;
+static char *lacp_rate		= NULL;
+
+static struct bond_parm_tbl bond_lacp_tbl[] = {
+{	"slow",		AD_LACP_SLOW},
+{	"fast",		AD_LACP_FAST},
+{	NULL,		-1},
+};
+
+static int first_pass	= 1;
+static struct bonding *these_bonds =  NULL;
+static struct net_device *dev_bonds = NULL;
+
+MODULE_PARM(max_bonds, "i");
+MODULE_PARM_DESC(max_bonds, "Max number of bonded devices");
+MODULE_PARM(miimon, "i");
+MODULE_PARM_DESC(miimon, "Link check interval in milliseconds");
+MODULE_PARM(use_carrier, "i");
+MODULE_PARM_DESC(use_carrier, "Use netif_carrier_ok (vs MII ioctls) in miimon; 09 for off, 1 for on (default)");
+MODULE_PARM(mode, "s");
+MODULE_PARM_DESC(mode, "Mode of operation : 0 for round robin, 1 for active-backup, 2 for xor");
+MODULE_PARM(arp_interval, "i");
+MODULE_PARM_DESC(arp_interval, "arp interval in milliseconds");
+MODULE_PARM(arp_ip_target, "1-" __MODULE_STRING(MAX_ARP_IP_TARGETS) "s");
+MODULE_PARM_DESC(arp_ip_target, "arp targets in n.n.n.n form");
+MODULE_PARM(updelay, "i");
+MODULE_PARM_DESC(updelay, "Delay before considering link up, in milliseconds");
+MODULE_PARM(downdelay, "i");
+MODULE_PARM_DESC(downdelay, "Delay before considering link down, in milliseconds");
+MODULE_PARM(primary, "s");
+MODULE_PARM_DESC(primary, "Primary network device to use");
+MODULE_PARM(multicast, "s");
+MODULE_PARM_DESC(multicast, "Mode for multicast support : 0 for none, 1 for active slave, 2 for all slaves (default)");
+MODULE_PARM(lacp_rate, "s");
+MODULE_PARM_DESC(lacp_rate, "LACPDU tx rate to request from 802.3ad partner (slow/fast)");
+
+static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *dev);
+static int bond_xmit_xor(struct sk_buff *skb, struct net_device *dev);
+static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *dev);
+static struct net_device_stats *bond_get_stats(struct net_device *dev);
+static void bond_mii_monitor(struct net_device *dev);
+static void loadbalance_arp_monitor(struct net_device *dev);
+static void activebackup_arp_monitor(struct net_device *dev);
+static int bond_event(struct notifier_block *this, unsigned long event, void *ptr);
+static void bond_mc_list_destroy(struct bonding *bond);
+static void bond_mc_add(bonding_t *bond, void *addr, int alen);
+static void bond_mc_delete(bonding_t *bond, void *addr, int alen);
+static int bond_mc_list_copy (struct dev_mc_list *src, struct bonding *dst, int gpf_flag);
+static inline int dmi_same(struct dev_mc_list *dmi1, struct dev_mc_list *dmi2);
+static void bond_set_promiscuity(bonding_t *bond, int inc);
+static void bond_set_allmulti(bonding_t *bond, int inc);
+static struct dev_mc_list* bond_mc_list_find_dmi(struct dev_mc_list *dmi, struct dev_mc_list *mc_list);
+static void bond_mc_update(bonding_t *bond, slave_t *new, slave_t *old);
+static int bond_enslave(struct net_device *master, struct net_device *slave);
+static int bond_release(struct net_device *master, struct net_device *slave);
+static int bond_release_all(struct net_device *master);
+static int bond_sethwaddr(struct net_device *master, struct net_device *slave);
+
+/*
+ * bond_get_info is the interface into the /proc filesystem.  This is
+ * a different interface than the BOND_INFO_QUERY ioctl.  That is done
+ * through the generic networking ioctl interface, and bond_info_query
+ * is the internal function which provides that information.
+ */
+static int bond_get_info(char *buf, char **start, off_t offset, int length);
+
+/* Caller must hold bond->ptrlock for write */
+static inline struct slave*
+bond_assign_current_slave(struct bonding *bond,struct slave *newslave)
+{
+	if ((bond_mode == BOND_MODE_TLB) ||
+	    (bond_mode == BOND_MODE_ALB)) {
+		bond_alb_assign_current_slave(bond, newslave);
+	} else {
+		bond->current_slave = newslave;
+	}
+
+	return bond->current_slave;
+}
+
+/* #define BONDING_DEBUG 1 */
+
+/* several macros */
+
+static void arp_send_all(slave_t *slave)
+{	
+	int i; 
+
+	for (i = 0; (i<MAX_ARP_IP_TARGETS) && arp_target[i]; i++) { 
+		arp_send(ARPOP_REQUEST, ETH_P_ARP, arp_target[i], slave->dev, 
+			 my_ip, arp_target_hw_addr, slave->dev->dev_addr,
+			 arp_target_hw_addr); 
+	} 
+}
+ 
+
+static const char *
+bond_mode_name(void)
+{
+	switch (bond_mode) {
+	case BOND_MODE_ROUNDROBIN :
+		return "load balancing (round-robin)";
+	case BOND_MODE_ACTIVEBACKUP :
+		return "fault-tolerance (active-backup)";
+	case BOND_MODE_XOR :
+		return "load balancing (xor)";
+	case BOND_MODE_BROADCAST :
+		return "fault-tolerance (broadcast)";
+	case BOND_MODE_8023AD:
+		return "IEEE 802.3ad Dynamic link aggregation";
+	case BOND_MODE_TLB:
+		return "transmit load balancing";
+	case BOND_MODE_ALB:
+		return "adaptive load balancing";
+	default:
+		return "unknown";
+	}
+}
+
+static const char *
+multicast_mode_name(void)
+{
+	switch(multicast_mode) {
+	case BOND_MULTICAST_DISABLED :
+		return "disabled";
+	case BOND_MULTICAST_ACTIVE :
+		return "active slave only";
+	case BOND_MULTICAST_ALL :
+		return "all slaves";
+	default :
+		return "unknown";
+	}
+}
+
+void bond_set_slave_inactive_flags(slave_t *slave)
+{
+	slave->state = BOND_STATE_BACKUP;
+	slave->dev->flags |= IFF_NOARP;
+}
+
+void bond_set_slave_active_flags(slave_t *slave)
+{
+	slave->state = BOND_STATE_ACTIVE;
+	slave->dev->flags &= ~IFF_NOARP;
+}
+
+/*
+ * This function counts and verifies the the number of attached
+ * slaves, checking the count against the expected value (given that incr
+ * is either 1 or -1, for add or removal of a slave).  Only
+ * bond_xmit_xor() uses the slave_cnt value, but this is still a good
+ * consistency check.
+ */
+static inline void
+update_slave_cnt(bonding_t *bond, int incr)
+{
+	slave_t *slave = NULL;
+	int expect = bond->slave_cnt + incr;
+
+	bond->slave_cnt = 0;
+	for (slave = bond->prev; slave != (slave_t*)bond;
+	     slave = slave->prev) {
+		bond->slave_cnt++;
+	}
+
+	if (expect != bond->slave_cnt)
+		BUG();
+}
+
+/*
+ * Set MAC.  Differs from eth_mac_addr in that we allow changes while
+ * netif_running().
+ */
+static int
+bond_set_mac_address(struct net_device *dev, void *p)
+{
+	struct sockaddr *addr = p;
+
+	memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+	return 0;
+}
+
+/* 
+ * This function detaches the slave <slave> from the list <bond>.
+ * WARNING: no check is made to verify if the slave effectively
+ * belongs to <bond>. It returns <slave> in case it's needed.
+ * Nothing is freed on return, structures are just unchained.
+ * If the bond->current_slave pointer was pointing to <slave>,
+ * it's replaced with bond->next, or NULL if not applicable.
+ *
+ * bond->lock held for writing by caller.
+ */
+static slave_t *
+bond_detach_slave(bonding_t *bond, slave_t *slave)
+{
+	if ((bond == NULL) || (slave == NULL) ||
+	   ((void *)bond == (void *)slave)) {
+		printk(KERN_ERR
+			"bond_detach_slave(): trying to detach "
+			"slave %p from bond %p\n", bond, slave);
+		return slave;
+	}
+
+	if (bond->next == slave) {  /* is the slave at the head ? */
+		if (bond->prev == slave) {  /* is the slave alone ? */
+			bond->prev = bond->next = (slave_t *)bond;
+		} else { /* not alone */
+			bond->next        = slave->next;
+			slave->next->prev = (slave_t *)bond;
+			bond->prev->next  = slave->next;
+		}
+	} else {
+		slave->prev->next = slave->next;
+		if (bond->prev == slave) {  /* is this slave the last one ? */
+			bond->prev = slave->prev;
+		} else {
+			slave->next->prev = slave->prev;
+		}
+	}
+
+	update_slave_cnt(bond, -1);
+
+	/* no need to hold ptrlock since bond lock is
+	 * already held for writing
+	 */
+	if (slave == bond->current_slave) {
+		if ( bond->next != (slave_t *)bond) {  /* found one slave */
+			bond_assign_current_slave(bond, bond->next);
+		} else {
+			bond_assign_current_slave(bond, NULL);
+		}
+	}
+
+	return slave;
+}
+
+/*
+ * This function attaches the slave <slave> to the list <bond>.
+ *
+ * bond->lock held for writing by caller.
+ */
+static void
+bond_attach_slave(struct bonding *bond, struct slave *new_slave)
+{
+	/* 
+	 * queue to the end of the slaves list, make the first element its
+	 * successor, the last one its predecessor, and make it the bond's
+	 * predecessor. 
+	 *
+	 * Just to clarify, so future bonding driver hackers don't go through
+	 * the same confusion stage I did trying to figure this out, the
+	 * slaves are stored in a double linked circular list, sortof.
+	 * In the ->next direction, the last slave points to the first slave,
+	 * bypassing bond; only the slaves are in the ->next direction.
+	 * In the ->prev direction, however, the first slave points to bond
+	 * and bond points to the last slave.
+	 *
+	 * It looks like a circle with a little bubble hanging off one side
+	 * in the ->prev direction only.
+	 *
+	 * When going through the list once, its best to start at bond->prev
+	 * and go in the ->prev direction, testing for bond.  Doing this
+	 * in the ->next direction doesn't work.  Trust me, I know this now.
+	 * :)  -mts 2002.03.14
+	 */
+	new_slave->prev       = bond->prev;
+	new_slave->prev->next = new_slave;
+	bond->prev            = new_slave;
+	new_slave->next       = bond->next;
+
+	update_slave_cnt(bond, 1);
+}
+
+
+/*
+ * Less bad way to call ioctl from within the kernel; this needs to be
+ * done some other way to get the call out of interrupt context.
+ * Needs "ioctl" variable to be supplied by calling context.
+ */
+#define IOCTL(dev, arg, cmd) ({		\
+	int ret;			\
+	mm_segment_t fs = get_fs();	\
+	set_fs(get_ds());		\
+	ret = ioctl(dev, arg, cmd);	\
+	set_fs(fs);			\
+	ret; })
+
+/*
+ * Get link speed and duplex from the slave's base driver
+ * using ethtool. If for some reason the call fails or the
+ * values are invalid, fake speed and duplex to 100/Full
+ * and return error.
+ */
+static int bond_update_speed_duplex(struct slave *slave)
+{
+	struct net_device *dev = slave->dev;
+	static int (* ioctl)(struct net_device *, struct ifreq *, int);
+	struct ifreq ifr;
+	struct ethtool_cmd etool;
+
+	ioctl = dev->do_ioctl;
+	if (ioctl) {
+		etool.cmd = ETHTOOL_GSET;
+		ifr.ifr_data = (char*)&etool;
+		if (IOCTL(dev, &ifr, SIOCETHTOOL) == 0) {
+			slave->speed = etool.speed;
+			slave->duplex = etool.duplex;
+		} else {
+			goto err_out;
+		}
+	} else {
+		goto err_out;
+	}
+
+	switch (slave->speed) {
+		case SPEED_10:
+		case SPEED_100:
+		case SPEED_1000:
+			break;
+		default:
+			goto err_out;
+	}
+
+	switch (slave->duplex) {
+		case DUPLEX_FULL:
+		case DUPLEX_HALF:
+			break;
+		default:
+			goto err_out;
+	}
+
+	return 0;
+
+err_out:
+	/* Fake speed and duplex */
+	slave->speed = SPEED_100;
+	slave->duplex = DUPLEX_FULL;
+	return -1;
+}
+
+/* 
+ * if <dev> supports MII link status reporting, check its link status.
+ *
+ * We either do MII/ETHTOOL ioctls, or check netif_carrier_ok(),
+ * depening upon the setting of the use_carrier parameter.
+ *
+ * Return either BMSR_LSTATUS, meaning that the link is up (or we
+ * can't tell and just pretend it is), or 0, meaning that the link is
+ * down.
+ *
+ * If reporting is non-zero, instead of faking link up, return -1 if
+ * both ETHTOOL and MII ioctls fail (meaning the device does not
+ * support them).  If use_carrier is set, return whatever it says.
+ * It'd be nice if there was a good way to tell if a driver supports
+ * netif_carrier, but there really isn't.
+ */
+static int
+bond_check_dev_link(struct net_device *dev, int reporting)
+{
+	static int (* ioctl)(struct net_device *, struct ifreq *, int);
+	struct ifreq ifr;
+	struct mii_ioctl_data *mii;
+	struct ethtool_value etool;
+
+	if (use_carrier) {
+		return netif_carrier_ok(dev) ? BMSR_LSTATUS : 0;
+	}
+
+	ioctl = dev->do_ioctl;
+	if (ioctl) {
+		/* TODO: set pointer to correct ioctl on a per team member */
+		/*       bases to make this more efficient. that is, once  */
+		/*       we determine the correct ioctl, we will always    */
+		/*       call it and not the others for that team          */
+		/*       member.                                           */
+
+		/*
+		 * We cannot assume that SIOCGMIIPHY will also read a
+		 * register; not all network drivers (e.g., e100)
+		 * support that.
+		 */
+
+		/* Yes, the mii is overlaid on the ifreq.ifr_ifru */
+		mii = (struct mii_ioctl_data *)&ifr.ifr_data;
+		if (IOCTL(dev, &ifr, SIOCGMIIPHY) == 0) {
+			mii->reg_num = MII_BMSR;
+			if (IOCTL(dev, &ifr, SIOCGMIIREG) == 0) {
+				return mii->val_out & BMSR_LSTATUS;
+			}
+		}
+
+		/* try SIOCETHTOOL ioctl, some drivers cache ETHTOOL_GLINK */
+		/* for a period of time so we attempt to get link status   */
+		/* from it last if the above MII ioctls fail...            */
+	        etool.cmd = ETHTOOL_GLINK;
+	        ifr.ifr_data = (char*)&etool;
+		if (IOCTL(dev, &ifr, SIOCETHTOOL) == 0) {
+			if (etool.data == 1) {
+				return BMSR_LSTATUS;
+			} else { 
+#ifdef BONDING_DEBUG
+				printk(KERN_INFO 
+					":: SIOCETHTOOL shows link down \n");
+#endif
+				return 0;
+			} 
+		}
+
+	}
+ 
+	/*
+	 * If reporting, report that either there's no dev->do_ioctl,
+	 * or both SIOCGMIIREG and SIOCETHTOOL failed (meaning that we
+	 * cannot report link status).  If not reporting, pretend
+	 * we're ok.
+	 */
+	return reporting ? -1 : BMSR_LSTATUS;
+}
+
+static u16 bond_check_mii_link(bonding_t *bond)
+{
+	int has_active_interface = 0;
+
+	read_lock_bh(&bond->lock);
+	read_lock(&bond->ptrlock);
+	has_active_interface = (bond->current_slave != NULL);
+	read_unlock(&bond->ptrlock);
+	read_unlock_bh(&bond->lock);
+
+	return (has_active_interface ? BMSR_LSTATUS : 0);
+}
+
+/* register to receive lacpdus on a bond */
+static void bond_register_lacpdu(struct bonding *bond)
+{
+	struct packet_type* pk_type = &(BOND_AD_INFO(bond).ad_pkt_type);
+
+	/* initialize packet type */
+	pk_type->type = PKT_TYPE_LACPDU;
+	pk_type->dev = bond->device;
+	pk_type->func = bond_3ad_lacpdu_recv;
+	pk_type->data = (void*)1;  /* understand shared skbs */
+
+	dev_add_pack(pk_type);
+}
+
+/* unregister to receive lacpdus on a bond */
+static void bond_unregister_lacpdu(struct bonding *bond)
+{
+	dev_remove_pack(&(BOND_AD_INFO(bond).ad_pkt_type));
+}
+
+static int bond_open(struct net_device *dev)
+{
+	struct bonding *bond = (struct bonding *)(dev->priv);
+	struct timer_list *timer = &((struct bonding *)(dev->priv))->mii_timer;
+	struct timer_list *arp_timer = &((struct bonding *)(dev->priv))->arp_timer;
+
+	if ((bond_mode == BOND_MODE_TLB) ||
+	    (bond_mode == BOND_MODE_ALB)) {
+		struct timer_list *alb_timer = &(BOND_ALB_INFO(bond).alb_timer);
+
+		/* bond_alb_initialize must be called before the timer
+		 * is started.
+		 */
+		if (bond_alb_initialize(bond, (bond_mode == BOND_MODE_ALB))) {
+			/* something went wrong - fail the open operation */
+			return -1;
+		}
+
+		init_timer(alb_timer);
+		alb_timer->expires  = jiffies + 1;
+		alb_timer->data     = (unsigned long)bond;
+		alb_timer->function = (void *)&bond_alb_monitor;
+		add_timer(alb_timer);
+	}
+
+	MOD_INC_USE_COUNT;
+
+	if (miimon > 0) {  /* link check interval, in milliseconds. */
+		init_timer(timer);
+		timer->expires  = jiffies + (miimon * HZ / 1000);
+		timer->data     = (unsigned long)dev;
+		timer->function = (void *)&bond_mii_monitor;
+		add_timer(timer);
+	}
+
+	if (arp_interval> 0) {  /* arp interval, in milliseconds. */
+		init_timer(arp_timer);
+		arp_timer->expires  = jiffies + (arp_interval * HZ / 1000);
+		arp_timer->data     = (unsigned long)dev;
+		if (bond_mode == BOND_MODE_ACTIVEBACKUP) {
+			arp_timer->function = (void *)&activebackup_arp_monitor;
+		} else {
+			arp_timer->function = (void *)&loadbalance_arp_monitor;
+		}
+		add_timer(arp_timer);
+	}
+
+	if (bond_mode == BOND_MODE_8023AD) {
+		struct timer_list *ad_timer = &(BOND_AD_INFO(bond).ad_timer);
+		init_timer(ad_timer);
+		ad_timer->expires  = jiffies + (AD_TIMER_INTERVAL * HZ / 1000);
+		ad_timer->data     = (unsigned long)bond;
+		ad_timer->function = (void *)&bond_3ad_state_machine_handler;
+		add_timer(ad_timer);
+
+		/* register to receive LACPDUs */
+		bond_register_lacpdu(bond);
+	}
+
+	return 0;
+}
+
+static int bond_close(struct net_device *master)
+{
+	bonding_t *bond = (struct bonding *) master->priv;
+
+	write_lock_bh(&bond->lock);
+
+	if (miimon > 0) {  /* link check interval, in milliseconds. */
+		del_timer(&bond->mii_timer);
+	}
+	if (arp_interval> 0) {  /* arp interval, in milliseconds. */
+		del_timer(&bond->arp_timer);
+                if (arp_target_hw_addr != NULL) {
+			kfree(arp_target_hw_addr); 
+			arp_target_hw_addr = NULL;
+		}
+	}
+
+	if (bond_mode == BOND_MODE_8023AD) {
+		del_timer_sync(&(BOND_AD_INFO(bond).ad_timer));
+
+		/* Unregister the receive of LACPDUs */
+		bond_unregister_lacpdu(bond);
+	}
+
+	bond_mc_list_destroy (bond);
+
+	write_unlock_bh(&bond->lock);
+
+	/* Release the bonded slaves */
+	bond_release_all(master);
+
+	if ((bond_mode == BOND_MODE_TLB) ||
+	    (bond_mode == BOND_MODE_ALB)) {
+		del_timer_sync(&(BOND_ALB_INFO(bond).alb_timer));
+
+		bond_alb_deinitialize(bond);
+	}
+
+	MOD_DEC_USE_COUNT;
+	return 0;
+}
+
+/* 
+ * flush all members of flush->mc_list from device dev->mc_list
+ */
+static void bond_mc_list_flush(struct net_device *dev, struct net_device *flush)
+{ 
+	struct dev_mc_list *dmi; 
+ 
+	for (dmi = flush->mc_list; dmi != NULL; dmi = dmi->next) 
+		dev_mc_delete(dev, dmi->dmi_addr, dmi->dmi_addrlen, 0);
+
+	if (bond_mode == BOND_MODE_8023AD) {
+		/* del lacpdu mc addr from mc list */
+		u8 lacpdu_multicast[ETH_ALEN] = MULTICAST_LACPDU_ADDR;
+
+		dev_mc_delete(dev, lacpdu_multicast, ETH_ALEN, 0);
+	}
+}
+
+/*
+ * Totally destroys the mc_list in bond
+ */
+static void bond_mc_list_destroy(struct bonding *bond)
+{
+	struct dev_mc_list *dmi;
+
+	dmi = bond->mc_list; 
+	while (dmi) { 
+		bond->mc_list = dmi->next; 
+		kfree(dmi); 
+		dmi = bond->mc_list; 
+	}
+}
+
+/*
+ * Add a Multicast address to every slave in the bonding group
+ */
+static void bond_mc_add(bonding_t *bond, void *addr, int alen)
+{ 
+	slave_t *slave;
+	switch (multicast_mode) {
+	case BOND_MULTICAST_ACTIVE :
+		/* write lock already acquired */
+		if (bond->current_slave != NULL)
+			dev_mc_add(bond->current_slave->dev, addr, alen, 0);
+		break;
+	case BOND_MULTICAST_ALL :
+		for (slave = bond->prev; slave != (slave_t*)bond; slave = slave->prev)
+			dev_mc_add(slave->dev, addr, alen, 0);
+		break;
+	case BOND_MULTICAST_DISABLED :
+		break;
+	}
+} 
+
+/*
+ * Remove a multicast address from every slave in the bonding group
+ */
+static void bond_mc_delete(bonding_t *bond, void *addr, int alen)
+{ 
+	slave_t *slave; 
+	switch (multicast_mode) {
+	case BOND_MULTICAST_ACTIVE :
+		/* write lock already acquired */
+		if (bond->current_slave != NULL)
+			dev_mc_delete(bond->current_slave->dev, addr, alen, 0);
+		break;
+	case BOND_MULTICAST_ALL :
+		for (slave = bond->prev; slave != (slave_t*)bond; slave = slave->prev)
+			dev_mc_delete(slave->dev, addr, alen, 0);
+		break;
+	case BOND_MULTICAST_DISABLED :
+		break;
+	}
+} 
+
+/*
+ * Copy all the Multicast addresses from src to the bonding device dst
+ */
+static int bond_mc_list_copy (struct dev_mc_list *src, struct bonding *dst,
+ int gpf_flag)
+{
+	struct dev_mc_list *dmi, *new_dmi;
+
+   	for (dmi = src; dmi != NULL; dmi = dmi->next) { 
+		new_dmi = kmalloc(sizeof(struct dev_mc_list), gpf_flag);
+
+		if (new_dmi == NULL) {
+			return -ENOMEM; 
+		}
+
+		new_dmi->next = dst->mc_list; 
+		dst->mc_list = new_dmi;
+
+		new_dmi->dmi_addrlen = dmi->dmi_addrlen; 
+		memcpy(new_dmi->dmi_addr, dmi->dmi_addr, dmi->dmi_addrlen); 
+		new_dmi->dmi_users = dmi->dmi_users;
+		new_dmi->dmi_gusers = dmi->dmi_gusers; 
+	} 
+	return 0;
+}
+
+/*
+ * Returns 0 if dmi1 and dmi2 are the same, non-0 otherwise
+ */
+static inline int dmi_same(struct dev_mc_list *dmi1, struct dev_mc_list *dmi2)
+{ 
+	return memcmp(dmi1->dmi_addr, dmi2->dmi_addr, dmi1->dmi_addrlen) == 0 &&
+	 dmi1->dmi_addrlen == dmi2->dmi_addrlen;
+} 
+
+/*
+ * Push the promiscuity flag down to all slaves
+ */
+static void bond_set_promiscuity(bonding_t *bond, int inc)
+{ 
+	slave_t *slave; 
+	switch (multicast_mode) {
+	case BOND_MULTICAST_ACTIVE :
+		/* write lock already acquired */
+		if (bond->current_slave != NULL)
+			dev_set_promiscuity(bond->current_slave->dev, inc);
+		break;
+	case BOND_MULTICAST_ALL :
+		for (slave = bond->prev; slave != (slave_t*)bond; slave = slave->prev)
+			dev_set_promiscuity(slave->dev, inc);
+		break;
+	case BOND_MULTICAST_DISABLED :
+		break;
+	}
+} 
+
+/*
+ * Push the allmulti flag down to all slaves
+ */
+static void bond_set_allmulti(bonding_t *bond, int inc)
+{ 
+	slave_t *slave; 
+	switch (multicast_mode) {
+	case BOND_MULTICAST_ACTIVE : 
+		/* write lock already acquired */
+		if (bond->current_slave != NULL)
+			dev_set_allmulti(bond->current_slave->dev, inc);
+		break;
+	case BOND_MULTICAST_ALL :
+		for (slave = bond->prev; slave != (slave_t*)bond; slave = slave->prev)
+			dev_set_allmulti(slave->dev, inc);
+		break;
+	case BOND_MULTICAST_DISABLED :
+		break;
+	}
+} 
+
+/* 
+ * returns dmi entry if found, NULL otherwise 
+ */
+static struct dev_mc_list* bond_mc_list_find_dmi(struct dev_mc_list *dmi,
+ struct dev_mc_list *mc_list)
+{ 
+	struct dev_mc_list *idmi;
+
+	for (idmi = mc_list; idmi != NULL; idmi = idmi->next) {
+		if (dmi_same(dmi, idmi)) {
+			return idmi; 
+		}
+	}
+	return NULL;
+} 
+
+static void set_multicast_list(struct net_device *master)
+{
+	bonding_t *bond = master->priv;
+	struct dev_mc_list *dmi;
+
+	if (multicast_mode == BOND_MULTICAST_DISABLED)
+		return;
+	/*
+	 * Lock the private data for the master
+	 */
+	write_lock_bh(&bond->lock);
+
+	/* set promiscuity flag to slaves */
+	if ( (master->flags & IFF_PROMISC) && !(bond->flags & IFF_PROMISC) )
+		bond_set_promiscuity(bond, 1); 
+
+	if ( !(master->flags & IFF_PROMISC) && (bond->flags & IFF_PROMISC) ) 
+		bond_set_promiscuity(bond, -1); 
+
+	/* set allmulti flag to slaves */ 
+	if ( (master->flags & IFF_ALLMULTI) && !(bond->flags & IFF_ALLMULTI) ) 
+		bond_set_allmulti(bond, 1); 
+
+	if ( !(master->flags & IFF_ALLMULTI) && (bond->flags & IFF_ALLMULTI) )
+		bond_set_allmulti(bond, -1); 
+
+	bond->flags = master->flags; 
+
+	/* looking for addresses to add to slaves' mc list */ 
+	for (dmi = master->mc_list; dmi != NULL; dmi = dmi->next) { 
+		if (bond_mc_list_find_dmi(dmi, bond->mc_list) == NULL) 
+		 bond_mc_add(bond, dmi->dmi_addr, dmi->dmi_addrlen); 
+	} 
+
+	/* looking for addresses to delete from slaves' list */ 
+	for (dmi = bond->mc_list; dmi != NULL; dmi = dmi->next) { 
+		if (bond_mc_list_find_dmi(dmi, master->mc_list) == NULL) 
+		 bond_mc_delete(bond, dmi->dmi_addr, dmi->dmi_addrlen); 
+	}
+
+
+	/* save master's multicast list */ 
+	bond_mc_list_destroy (bond);
+	bond_mc_list_copy (master->mc_list, bond, GFP_ATOMIC);
+
+	write_unlock_bh(&bond->lock);
+}
+
+/*
+ * Update the mc list and multicast-related flags for the new and 
+ * old active slaves (if any) according to the multicast mode
+ */
+static void bond_mc_update(bonding_t *bond, slave_t *new, slave_t *old)
+{
+	struct dev_mc_list *dmi;
+
+	switch(multicast_mode) {
+	case BOND_MULTICAST_ACTIVE :		
+		if (bond->device->flags & IFF_PROMISC) {
+			if (old != NULL && new != old)
+				dev_set_promiscuity(old->dev, -1);
+			dev_set_promiscuity(new->dev, 1);
+		}
+		if (bond->device->flags & IFF_ALLMULTI) {
+			if (old != NULL && new != old)
+				dev_set_allmulti(old->dev, -1);
+			dev_set_allmulti(new->dev, 1);
+		}
+		/* first remove all mc addresses from old slave if any,
+		   and _then_ add them to new active slave */
+		if (old != NULL && new != old) {
+			for (dmi = bond->device->mc_list; dmi != NULL; dmi = dmi->next)
+				dev_mc_delete(old->dev, dmi->dmi_addr, dmi->dmi_addrlen, 0);
+		}
+		for (dmi = bond->device->mc_list; dmi != NULL; dmi = dmi->next)
+			dev_mc_add(new->dev, dmi->dmi_addr, dmi->dmi_addrlen, 0);
+		break;
+	case BOND_MULTICAST_ALL :
+		/* nothing to do: mc list is already up-to-date on all slaves */
+		break;
+	case BOND_MULTICAST_DISABLED :
+		break;
+	}
+}
+
+/* enslave device <slave> to bond device <master> */
+static int bond_enslave(struct net_device *master_dev, 
+                        struct net_device *slave_dev)
+{
+	bonding_t *bond = NULL;
+	slave_t *new_slave = NULL;
+	unsigned long rflags = 0;
+	int err = 0;
+	struct dev_mc_list *dmi;
+	struct in_ifaddr **ifap;
+	struct in_ifaddr *ifa;
+	int link_reporting;
+	struct sockaddr addr;
+
+	if (master_dev == NULL || slave_dev == NULL) {
+		return -ENODEV;
+	}
+	bond = (struct bonding *) master_dev->priv;
+
+	if (slave_dev->do_ioctl == NULL) {
+		printk(KERN_DEBUG
+			"Warning : no link monitoring support for %s\n",
+			slave_dev->name);
+	}
+
+
+	/* bond must be initialized by bond_open() before enslaving */
+	if (!(master_dev->flags & IFF_UP)) {
+#ifdef BONDING_DEBUG
+		printk(KERN_CRIT "Error, master_dev is not up\n");
+#endif
+		return -EPERM;
+	}
+
+	/* already enslaved */
+	if (master_dev->flags & IFF_SLAVE || slave_dev->flags & IFF_SLAVE) {
+#ifdef BONDING_DEBUG
+		printk(KERN_CRIT "Error, Device was already enslaved\n");
+#endif
+		return -EBUSY;
+	}
+
+	if (app_abi_ver >= 1) {
+		/* The application is using an ABI, which requires the
+		 * slave interface to be closed.
+		 */
+		if ((slave_dev->flags & IFF_UP)) {
+#ifdef BONDING_DEBUG
+			printk(KERN_CRIT "Error, slave_dev is up\n");
+#endif
+			return -EPERM;
+		}
+
+		if (slave_dev->set_mac_address == NULL) {
+			printk(KERN_CRIT
+			       "The slave device you specified does not support"
+			       " setting the MAC address.\n");
+			printk(KERN_CRIT
+			       "Your kernel likely does not support slave"
+			       " devices.\n");
+
+			return -EOPNOTSUPP;
+		}
+	} else {
+		/* The application is not using an ABI, which requires the
+		 * slave interface to be open.
+		 */
+		if (!(slave_dev->flags & IFF_UP)) {
+#ifdef BONDING_DEBUG
+			printk(KERN_CRIT "Error, slave_dev is not running\n");
+#endif
+			return -EINVAL;
+		}
+
+		if ((bond_mode == BOND_MODE_8023AD) ||
+		    (bond_mode == BOND_MODE_TLB) ||
+		    (bond_mode == BOND_MODE_ALB)) {
+			printk(KERN_ERR
+			       "bonding: Error: to use %s mode, you must "
+			       "upgrade ifenslave.\n", bond_mode_name());
+			return -EOPNOTSUPP;
+		}
+	}
+
+	if ((new_slave = kmalloc(sizeof(slave_t), GFP_KERNEL)) == NULL) {
+		return -ENOMEM;
+	}
+	memset(new_slave, 0, sizeof(slave_t));
+
+	/* save slave's original flags before calling
+	 * netdev_set_master and dev_open
+	 */
+	new_slave->original_flags = slave_dev->flags;
+
+	if (app_abi_ver >= 1) {
+		/* save slave's original ("permanent") mac address for
+		 * modes that needs it, and for restoring it upon release,
+		 * and then set it to the master's address
+		 */
+		memcpy(new_slave->perm_hwaddr, slave_dev->dev_addr, ETH_ALEN);
+
+		if (bond->slave_cnt > 0) {
+			/* set slave to master's mac address
+			 * The application already set the master's
+			 * mac address to that of the first slave
+			 */
+			memcpy(addr.sa_data, master_dev->dev_addr, ETH_ALEN);
+			addr.sa_family = slave_dev->type;
+			err = slave_dev->set_mac_address(slave_dev, &addr);
+			if (err) {
+#ifdef BONDING_DEBUG
+				printk(KERN_CRIT "Error %d calling set_mac_address\n", err);
+#endif
+				goto err_free;
+			}
+		}
+
+		/* open the slave since the application closed it */
+		err = dev_open(slave_dev);
+		if (err) {
+#ifdef BONDING_DEBUG
+			printk(KERN_CRIT "Openning slave %s failed\n", slave_dev->name);
+#endif
+			goto err_restore_mac;
+		}
+	}
+
+	err = netdev_set_master(slave_dev, master_dev);
+	if (err) {
+#ifdef BONDING_DEBUG
+		printk(KERN_CRIT "Error %d calling netdev_set_master\n", err);
+#endif
+		if (app_abi_ver < 1) {
+			goto err_free;
+		} else {
+			goto err_close;
+		}
+	}
+
+	new_slave->dev = slave_dev;
+
+	if ((bond_mode == BOND_MODE_TLB) ||
+	    (bond_mode == BOND_MODE_ALB)) {
+		/* bond_alb_init_slave() must be called before all other stages since
+		 * it might fail and we do not want to have to undo everything
+		 */
+		err = bond_alb_init_slave(bond, new_slave);
+		if (err) {
+			goto err_unset_master;
+		}
+	}
+
+	if (multicast_mode == BOND_MULTICAST_ALL) {
+		/* set promiscuity level to new slave */ 
+		if (master_dev->flags & IFF_PROMISC)
+			dev_set_promiscuity(slave_dev, 1); 
+ 
+		/* set allmulti level to new slave */
+		if (master_dev->flags & IFF_ALLMULTI) 
+			dev_set_allmulti(slave_dev, 1); 
+		
+		/* upload master's mc_list to new slave */ 
+		for (dmi = master_dev->mc_list; dmi != NULL; dmi = dmi->next) 
+			dev_mc_add (slave_dev, dmi->dmi_addr, dmi->dmi_addrlen, 0);
+	}
+
+	if (bond_mode == BOND_MODE_8023AD) {
+		/* add lacpdu mc addr to mc list */
+		u8 lacpdu_multicast[ETH_ALEN] = MULTICAST_LACPDU_ADDR;
+
+		dev_mc_add(slave_dev, lacpdu_multicast, ETH_ALEN, 0);
+	}
+
+	write_lock_bh(&bond->lock);
+	
+	bond_attach_slave(bond, new_slave);
+	new_slave->delay = 0;
+	new_slave->link_failure_count = 0;
+
+	if (miimon > 0 && !use_carrier) {
+		link_reporting = bond_check_dev_link(slave_dev, 1);
+
+		if ((link_reporting == -1) && (arp_interval == 0)) {
+			/*
+			 * miimon is set but a bonded network driver
+			 * does not support ETHTOOL/MII and
+			 * arp_interval is not set.  Note: if
+			 * use_carrier is enabled, we will never go
+			 * here (because netif_carrier is always
+			 * supported); thus, we don't need to change
+			 * the messages for netif_carrier.
+			 */ 
+			printk(KERN_ERR
+				"bond_enslave(): MII and ETHTOOL support not "
+				"available for interface %s, and "
+				"arp_interval/arp_ip_target module parameters "
+		       		"not specified, thus bonding will not detect "
+				"link failures! see bonding.txt for details.\n",
+		       		slave_dev->name);
+		} else if (link_reporting == -1) {
+			/* unable  get link status using mii/ethtool */
+			printk(KERN_WARNING 
+			       "bond_enslave: can't get link status from "
+			       "interface %s; the network driver associated "
+			       "with this interface does not support "
+			       "MII or ETHTOOL link status reporting, thus "
+			       "miimon has no effect on this interface.\n", 
+			       slave_dev->name);
+		}
+	}
+
+	/* check for initial state */
+	if ((miimon <= 0) ||
+	    (bond_check_dev_link(slave_dev, 0) == BMSR_LSTATUS)) {
+		if (updelay) {
+#ifdef BONDING_DEBUG
+			printk(KERN_CRIT "Initial state of slave_dev is "
+			       "BOND_LINK_BACK\n");
+#endif
+			new_slave->link  = BOND_LINK_BACK;
+			new_slave->delay = updelay;
+		}
+		else {
+#ifdef BONDING_DEBUG
+			printk(KERN_DEBUG "Initial state of slave_dev is "
+				"BOND_LINK_UP\n");
+#endif
+			new_slave->link  = BOND_LINK_UP;
+		}
+		new_slave->jiffies = jiffies;
+	}
+	else {
+#ifdef BONDING_DEBUG
+		printk(KERN_CRIT "Initial state of slave_dev is "
+			"BOND_LINK_DOWN\n");
+#endif
+		new_slave->link  = BOND_LINK_DOWN;
+	}
+
+	if (bond_update_speed_duplex(new_slave) &&
+	    (new_slave->link != BOND_LINK_DOWN)) {
+
+		printk(KERN_WARNING
+		       "bond_enslave(): failed to get speed/duplex from %s, "
+		       "speed forced to 100Mbps, duplex forced to Full.\n",
+		       new_slave->dev->name);
+		if (bond_mode == BOND_MODE_8023AD) {
+			printk(KERN_WARNING
+			       "Operation of 802.3ad mode requires ETHTOOL support "
+			       "in base driver for proper aggregator selection.\n");
+		}
+	}
+
+	/* if we're in active-backup mode, we need one and only one active
+	 * interface. The backup interfaces will have their NOARP flag set
+	 * because we need them to be completely deaf and not to respond to
+	 * any ARP request on the network to avoid fooling a switch. Thus,
+	 * since we guarantee that current_slave always point to the last
+	 * usable interface, we just have to verify this interface's flag.
+	 */
+	if (bond_mode == BOND_MODE_ACTIVEBACKUP) {
+		if (((bond->current_slave == NULL)
+			|| (bond->current_slave->dev->flags & IFF_NOARP))
+			&& (new_slave->link != BOND_LINK_DOWN)) {
+#ifdef BONDING_DEBUG
+			printk(KERN_CRIT "This is the first active slave\n");
+#endif
+			/* first slave or no active slave yet, and this link
+			   is OK, so make this interface the active one */
+			bond_assign_current_slave(bond, new_slave);
+			bond_set_slave_active_flags(new_slave);
+			bond_mc_update(bond, new_slave, NULL);
+		}
+		else {
+#ifdef BONDING_DEBUG
+			printk(KERN_CRIT "This is just a backup slave\n");
+#endif
+			bond_set_slave_inactive_flags(new_slave);
+		}
+		read_lock_irqsave(&(((struct in_device *)slave_dev->ip_ptr)->lock), rflags);
+		ifap= &(((struct in_device *)slave_dev->ip_ptr)->ifa_list);
+		ifa = *ifap;
+		my_ip = ifa->ifa_address;
+		read_unlock_irqrestore(&(((struct in_device *)slave_dev->ip_ptr)->lock), rflags);
+
+		/* if there is a primary slave, remember it */
+		if (primary != NULL) {
+			if (strcmp(primary, new_slave->dev->name) == 0) {
+				bond->primary_slave = new_slave;
+			}
+		}
+	} else if (bond_mode == BOND_MODE_8023AD) {
+		/* in 802.3ad mode, the internal mechanism
+		 * will activate the slaves in the selected
+		 * aggregator
+		 */
+		bond_set_slave_inactive_flags(new_slave);
+		/* if this is the first slave */
+		if (new_slave == bond->next) {
+			SLAVE_AD_INFO(new_slave).id = 1;
+			/* Initialize AD with the number of times that the AD timer is called in 1 second
+			 * can be called only after the mac address of the bond is set
+			 */
+			bond_3ad_initialize(bond, 1000/AD_TIMER_INTERVAL,
+					    lacp_fast);
+		} else {
+			SLAVE_AD_INFO(new_slave).id =
+			SLAVE_AD_INFO(new_slave->prev).id + 1;
+		}
+
+		bond_3ad_bind_slave(new_slave);
+	} else if ((bond_mode == BOND_MODE_TLB) ||
+		   (bond_mode == BOND_MODE_ALB)) {
+		new_slave->state = BOND_STATE_ACTIVE;
+		if ((bond->current_slave == NULL) && (new_slave->link != BOND_LINK_DOWN)) {
+			/* first slave or no active slave yet, and this link
+			 * is OK, so make this interface the active one
+			 */
+			bond_assign_current_slave(bond, new_slave);
+		}
+
+		/* if there is a primary slave, remember it */
+		if (primary != NULL) {
+			if (strcmp(primary, new_slave->dev->name) == 0) {
+				bond->primary_slave = new_slave;
+			}
+		}
+	} else {
+#ifdef BONDING_DEBUG
+		printk(KERN_CRIT "This slave is always active in trunk mode\n");
+#endif
+		/* always active in trunk mode */
+		new_slave->state = BOND_STATE_ACTIVE;
+		if (bond->current_slave == NULL) 
+			bond_assign_current_slave(bond, new_slave);
+	}
+
+	write_unlock_bh(&bond->lock);
+
+	if (app_abi_ver < 1) {
+		/*
+		 * !!! This is to support old versions of ifenslave.
+		 * We can remove this in 2.5 because our ifenslave takes
+		 * care of this for us.
+		 * We check to see if the master has a mac address yet.
+		 * If not, we'll give it the mac address of our slave device.
+		 */
+		int ndx = 0;
+
+		for (ndx = 0; ndx < slave_dev->addr_len; ndx++) {
+#ifdef BONDING_DEBUG
+			printk(KERN_DEBUG
+			       "Checking ndx=%d of master_dev->dev_addr\n", ndx);
+#endif
+			if (master_dev->dev_addr[ndx] != 0) {
+#ifdef BONDING_DEBUG
+				printk(KERN_DEBUG
+				       "Found non-zero byte at ndx=%d\n", ndx);
+#endif
+				break;
+			}
+		}
+		if (ndx == slave_dev->addr_len) {
+			/*
+			 * We got all the way through the address and it was
+			 * all 0's.
+			 */
+#ifdef BONDING_DEBUG
+			printk(KERN_DEBUG "%s doesn't have a MAC address yet.  ",
+			       master_dev->name);
+			printk(KERN_DEBUG "Going to give assign it from %s.\n",
+			       slave_dev->name);
+#endif
+			bond_sethwaddr(master_dev, slave_dev);
+		}
+	}
+
+	printk (KERN_INFO "%s: enslaving %s as a%s interface with a%s link.\n",
+		master_dev->name, slave_dev->name,
+		new_slave->state == BOND_STATE_ACTIVE ? "n active" : " backup",
+		new_slave->link != BOND_LINK_DOWN ? "n up" : " down");
+
+	/* enslave is successful */
+	return 0;
+
+/* Undo stages on error */
+err_unset_master:
+	netdev_set_master(slave_dev, NULL);
+
+err_close:
+	dev_close(slave_dev);
+
+err_restore_mac:
+	memcpy(addr.sa_data, new_slave->perm_hwaddr, ETH_ALEN);
+	addr.sa_family = slave_dev->type;
+	slave_dev->set_mac_address(slave_dev, &addr);
+
+err_free:
+	kfree(new_slave);
+	return err;
+}
+
+/* 
+ * This function changes the active slave to slave <slave_dev>.
+ * It returns -EINVAL in the following cases.
+ *  - <slave_dev> is not found in the list.
+ *  - There is not active slave now.
+ *  - <slave_dev> is already active.
+ *  - The link state of <slave_dev> is not BOND_LINK_UP.
+ *  - <slave_dev> is not running.
+ * In these cases, this fuction does nothing.
+ * In the other cases, currnt_slave pointer is changed and 0 is returned.
+ */
+static int bond_change_active(struct net_device *master_dev, struct net_device *slave_dev)
+{
+	bonding_t *bond;
+	slave_t *slave;
+	slave_t *oldactive = NULL;
+	slave_t *newactive = NULL;
+	int ret = 0;
+
+	if (master_dev == NULL || slave_dev == NULL) {
+		return -ENODEV;
+	}
+
+	bond = (struct bonding *) master_dev->priv;
+	write_lock_bh(&bond->lock);
+	slave = (slave_t *)bond;
+	oldactive = bond->current_slave;
+
+	while ((slave = slave->prev) != (slave_t *)bond) {
+		if(slave_dev == slave->dev) {
+			newactive = slave;
+			break;
+		}
+	}
+
+	/*
+	 * Changing to the current active: do nothing; return success.
+	 */
+	if (newactive && (newactive == oldactive)) {
+		write_unlock_bh(&bond->lock);
+		return 0;
+	}
+
+	if ((newactive != NULL)&&
+	    (oldactive != NULL)&&
+	    (newactive->link == BOND_LINK_UP)&&
+	    IS_UP(newactive->dev)) {
+		bond_set_slave_inactive_flags(oldactive);
+		bond_set_slave_active_flags(newactive);
+		bond_mc_update(bond, newactive, oldactive);
+		bond_assign_current_slave(bond, newactive);
+		printk("%s : activate %s(old : %s)\n",
+			master_dev->name, newactive->dev->name, 
+			oldactive->dev->name);
+	} else {
+		ret = -EINVAL;
+	}
+	write_unlock_bh(&bond->lock);
+	return ret;
+}
+
+/* Choose a new valid interface from the pool, set it active
+ * and make it the current slave. If no valid interface is
+ * found, the oldest slave in BACK state is choosen and
+ * activated. If none is found, it's considered as no
+ * interfaces left so the current slave is set to NULL.
+ * The result is a pointer to the current slave.
+ *
+ * Since this function sends messages tails through printk, the caller
+ * must have started something like `printk(KERN_INFO "xxxx ");'.
+ *
+ * Warning: Caller must hold ptrlock for writing.
+ */
+slave_t *change_active_interface(bonding_t *bond)
+{
+	slave_t *newslave, *oldslave;
+	slave_t *bestslave = NULL;
+	int mintime;
+
+	newslave = oldslave = bond->current_slave;
+
+	if (newslave == NULL) { /* there were no active slaves left */
+		if (bond->next != (slave_t *)bond) {  /* found one slave */
+			newslave = bond_assign_current_slave(bond, bond->next);
+		} else {
+
+			printk (" but could not find any %s interface.\n",
+				(bond_mode == BOND_MODE_ACTIVEBACKUP) ? "backup":"other");
+			bond_assign_current_slave(bond, NULL);
+			return NULL; /* still no slave, return NULL */
+		}
+	} else if (bond_mode == BOND_MODE_ACTIVEBACKUP) {
+		/* make sure oldslave doesn't send arps - this could
+		 * cause a ping-pong effect between interfaces since they
+		 * would be able to tx arps - in active backup only one
+		 * slave should be able to tx arps, and that should be
+		 * the current_slave; the only exception is when all
+		 * slaves have gone down, then only one non-current slave can
+		 * send arps at a time; clearing oldslaves' mc list is handled
+		 * later in this function.
+		 */
+		bond_set_slave_inactive_flags(oldslave);
+	}
+
+	mintime = updelay;
+
+	/* first try the primary link; if arping, a link must tx/rx traffic 
+	 * before it can be considered the current_slave - also, we would skip 
+	 * slaves between the current_slave and primary_slave that may be up 
+	 * and able to arp
+	 */
+	if ((bond->primary_slave != NULL) && (arp_interval == 0)) {
+		if (IS_UP(bond->primary_slave->dev)) 
+			newslave = bond->primary_slave;
+	}
+
+	do {
+		if (IS_UP(newslave->dev)) {
+			if (newslave->link == BOND_LINK_UP) {
+				/* this one is immediately usable */
+				if (bond_mode == BOND_MODE_ACTIVEBACKUP) {
+					bond_set_slave_active_flags(newslave);
+					bond_mc_update(bond, newslave, oldslave);
+					printk (" and making interface %s the active one.\n",
+						newslave->dev->name);
+				}
+				else {
+					printk (" and setting pointer to interface %s.\n",
+						newslave->dev->name);
+				}
+
+				bond_assign_current_slave(bond, newslave);
+				return newslave;
+			}
+			else if (newslave->link == BOND_LINK_BACK) {
+				/* link up, but waiting for stabilization */
+				if (newslave->delay < mintime) {
+					mintime = newslave->delay;
+					bestslave = newslave;
+				}
+			}
+		}
+	} while ((newslave = newslave->next) != oldslave);
+
+	/* no usable backup found, we'll see if we at least got a link that was
+	   coming back for a long time, and could possibly already be usable.
+	*/
+
+	if (bestslave != NULL) {
+		/* early take-over. */
+		printk (" and making interface %s the active one %d ms earlier.\n",
+			bestslave->dev->name,
+			(updelay - bestslave->delay)*miimon);
+
+		bestslave->delay = 0;
+		bestslave->link = BOND_LINK_UP;
+		bestslave->jiffies = jiffies;
+		bond_set_slave_active_flags(bestslave);
+		bond_mc_update(bond, bestslave, oldslave);
+		bond_assign_current_slave(bond, bestslave);
+		return bestslave;
+	}
+
+	if ((bond_mode == BOND_MODE_ACTIVEBACKUP) &&
+	    (multicast_mode == BOND_MULTICAST_ACTIVE) &&
+	    (oldslave != NULL)) {
+		/* flush bonds (master's) mc_list from oldslave since it wasn't
+		 * updated (and deleted) above
+		 */ 
+		bond_mc_list_flush(oldslave->dev, bond->device); 
+		if (bond->device->flags & IFF_PROMISC) {
+			dev_set_promiscuity(oldslave->dev, -1);
+		}
+		if (bond->device->flags & IFF_ALLMULTI) {
+			dev_set_allmulti(oldslave->dev, -1);
+		}
+	}
+
+	printk (" but could not find any %s interface.\n",
+		(bond_mode == BOND_MODE_ACTIVEBACKUP) ? "backup":"other");
+	
+	/* absolutely nothing found. let's return NULL */
+	bond_assign_current_slave(bond, NULL);
+	return NULL;
+}
+
+/*
+ * Try to release the slave device <slave> from the bond device <master>
+ * It is legal to access current_slave without a lock because all the function
+ * is write-locked.
+ *
+ * The rules for slave state should be:
+ *   for Active/Backup:
+ *     Active stays on all backups go down
+ *   for Bonded connections:
+ *     The first up interface should be left on and all others downed.
+ */
+static int bond_release(struct net_device *master, struct net_device *slave)
+{
+	bonding_t *bond;
+	slave_t *our_slave, *old_current;
+	struct sockaddr addr;
+	
+	if (master == NULL || slave == NULL)  {
+		return -ENODEV;
+	}
+
+	bond = (struct bonding *) master->priv;
+
+	/* master already enslaved, or slave not enslaved,
+	   or no slave for this master */
+	if ((master->flags & IFF_SLAVE) || !(slave->flags & IFF_SLAVE)) {
+		printk (KERN_DEBUG "%s: cannot release %s.\n", master->name, slave->name);
+		return -EINVAL;
+	}
+
+	write_lock_bh(&bond->lock);
+	bond->current_arp_slave = NULL;
+	our_slave = (slave_t *)bond;
+	old_current = bond->current_slave;
+	while ((our_slave = our_slave->prev) != (slave_t *)bond) {
+		if (our_slave->dev == slave) {
+			int mac_addr_differ = memcmp(bond->device->dev_addr,
+						 our_slave->perm_hwaddr,
+						 ETH_ALEN);
+			if (!mac_addr_differ && (bond->slave_cnt > 1)) {
+				printk(KERN_WARNING "WARNING: the permanent HWaddr of %s "
+				"- %02X:%02X:%02X:%02X:%02X:%02X - "
+				"is still in use by %s. Set the HWaddr "
+				"of %s to a different address "
+				"to avoid conflicts.\n",
+				       slave->name,
+				       slave->dev_addr[0],
+				       slave->dev_addr[1],
+				       slave->dev_addr[2],
+				       slave->dev_addr[3],
+				       slave->dev_addr[4],
+				       slave->dev_addr[5],
+				       bond->device->name,
+				       slave->name);
+			}
+
+			/* Inform AD package of unbinding of slave. */
+			if (bond_mode == BOND_MODE_8023AD) {
+				/* must be called before the slave is
+				 * detached from the list
+				 */
+				bond_3ad_unbind_slave(our_slave);
+			}
+
+			/* release the slave from its bond */
+			bond_detach_slave(bond, our_slave);
+
+			printk (KERN_INFO "%s: releasing %s interface %s",
+				master->name,
+				(our_slave->state == BOND_STATE_ACTIVE) ? "active" : "backup",
+				slave->name);
+
+			if (our_slave == old_current) {
+				/* find a new interface and be verbose */
+				change_active_interface(bond); 
+			} else {
+				printk(".\n");
+			}
+			
+			if (bond->current_slave == NULL) {
+				printk(KERN_INFO
+					"%s: now running without any active interface !\n",
+					master->name);
+			}
+
+			if (bond->primary_slave == our_slave) {
+				bond->primary_slave = NULL;
+			}
+
+			if ((bond_mode == BOND_MODE_TLB) ||
+			    (bond_mode == BOND_MODE_ALB)) {
+				/* must be called only after the slave has been
+				 * detached from the list and the current_slave
+				 * has been replaced (if our_slave == old_current)
+				 */
+				bond_alb_deinit_slave(bond, our_slave);
+			}
+
+			break;
+		}
+
+	}
+	write_unlock_bh(&bond->lock);
+	
+	if (our_slave == (slave_t *)bond) {
+		/* if we get here, it's because the device was not found */
+		printk (KERN_INFO "%s: %s not enslaved\n", master->name, slave->name);
+		return -EINVAL;
+	}
+
+	/* undo settings and restore original values */
+	
+	if (multicast_mode == BOND_MULTICAST_ALL) {
+		/* flush master's mc_list from slave */ 
+		bond_mc_list_flush (slave, master); 
+
+		/* unset promiscuity level from slave */
+		if (master->flags & IFF_PROMISC) 
+			dev_set_promiscuity(slave, -1); 
+
+		/* unset allmulti level from slave */ 
+		if (master->flags & IFF_ALLMULTI)
+			dev_set_allmulti(slave, -1); 
+	}
+
+	netdev_set_master(slave, NULL);
+
+	/* close slave before restoring its mac address */
+	dev_close(slave);
+
+	if (app_abi_ver >= 1) {
+		/* restore original ("permanent") mac address */
+		memcpy(addr.sa_data, our_slave->perm_hwaddr, ETH_ALEN);
+		addr.sa_family = slave->type;
+		slave->set_mac_address(slave, &addr);
+	}
+
+	/* restore the original state of the
+	 * IFF_NOARP flag that might have been
+	 * set by bond_set_slave_inactive_flags()
+	 */
+	if ((our_slave->original_flags & IFF_NOARP) == 0) {
+		slave->flags &= ~IFF_NOARP;
+	}
+
+	kfree(our_slave);
+
+	/* if the last slave was removed, zero the mac address
+	 * of the master so it will be set by the application
+	 * to the mac address of the first slave
+	 */
+	if (bond->next == (slave_t*)bond) {
+		memset(master->dev_addr, 0, master->addr_len);
+	}
+
+	return 0;  /* deletion OK */
+}
+
+/* 
+ * This function releases all slaves.
+ */
+static int bond_release_all(struct net_device *master)
+{
+	bonding_t *bond;
+	slave_t *our_slave, *old_current;
+	struct net_device *slave_dev;
+	struct sockaddr addr;
+	int err = 0;
+
+	if (master == NULL)  {
+		return -ENODEV;
+	}
+
+	if (master->flags & IFF_SLAVE) {
+		return -EINVAL;
+	}
+
+	bond = (struct bonding *) master->priv;
+
+	write_lock_bh(&bond->lock);
+	if (bond->next == (struct slave *) bond) {
+		err = -EINVAL;
+		goto out;
+	}
+
+	old_current = bond->current_slave;
+	bond_assign_current_slave(bond, NULL);
+	bond->current_arp_slave = NULL;
+	bond->primary_slave = NULL;
+
+	while ((our_slave = bond->prev) != (slave_t *)bond) {
+		/* Inform AD package of unbinding of slave
+		 * before slave is detached from the list.
+		 */
+		if (bond_mode == BOND_MODE_8023AD) {
+			bond_3ad_unbind_slave(our_slave);
+		}
+
+		slave_dev = our_slave->dev;
+		bond_detach_slave(bond, our_slave);
+
+		if ((bond_mode == BOND_MODE_TLB) ||
+		    (bond_mode == BOND_MODE_ALB)) {
+			/* must be called only after the slave
+			 * has been detached from the list
+			 */
+			bond_alb_deinit_slave(bond, our_slave);
+		}
+
+		/* now that the slave is detached, unlock and perform
+		 * all the undo steps that should not be called from
+		 * within a lock.
+		 */
+		write_unlock_bh(&bond->lock);
+
+		if (multicast_mode == BOND_MULTICAST_ALL 
+		    || (multicast_mode == BOND_MULTICAST_ACTIVE 
+			&& old_current == our_slave)) {
+
+			/* flush master's mc_list from slave */ 
+			bond_mc_list_flush (slave_dev, master); 
+
+			/* unset promiscuity level from slave */
+			if (master->flags & IFF_PROMISC) 
+				dev_set_promiscuity(slave_dev, -1); 
+
+			/* unset allmulti level from slave */ 
+			if (master->flags & IFF_ALLMULTI)
+				dev_set_allmulti(slave_dev, -1); 
+		}
+
+		netdev_set_master(slave_dev, NULL);
+
+		/* close slave before restoring its mac address */
+		dev_close(slave_dev);
+
+		if (app_abi_ver >= 1) {
+			/* restore original ("permanent") mac address*/
+			memcpy(addr.sa_data, our_slave->perm_hwaddr, ETH_ALEN);
+			addr.sa_family = slave_dev->type;
+			slave_dev->set_mac_address(slave_dev, &addr);
+		}
+
+		/* restore the original state of the IFF_NOARP flag that might have
+		 * been set by bond_set_slave_inactive_flags()
+		 */
+		if ((our_slave->original_flags & IFF_NOARP) == 0) {
+			slave_dev->flags &= ~IFF_NOARP;
+		}
+
+		kfree(our_slave);
+
+		/* re-acquire the lock before getting the next slave */
+		write_lock_bh(&bond->lock);
+	}
+
+	/* zero the mac address of the master so it will be
+	 * set by the application to the mac address of the
+	 * first slave
+	 */
+	memset(master->dev_addr, 0, master->addr_len);
+
+	printk (KERN_INFO "%s: released all slaves\n", master->name);
+
+out:
+	write_unlock_bh(&bond->lock);
+
+	return err;
+}
+
+/* this function is called regularly to monitor each slave's link. */
+static void bond_mii_monitor(struct net_device *master)
+{
+	bonding_t *bond = (struct bonding *) master->priv;
+	slave_t *slave, *bestslave, *oldcurrent;
+	int slave_died = 0;
+
+	read_lock(&bond->lock);
+
+	/* we will try to read the link status of each of our slaves, and
+	 * set their IFF_RUNNING flag appropriately. For each slave not
+	 * supporting MII status, we won't do anything so that a user-space
+	 * program could monitor the link itself if needed.
+	 */
+
+	bestslave = NULL;
+	slave = (slave_t *)bond;
+
+	read_lock(&bond->ptrlock);
+	oldcurrent = bond->current_slave;
+	read_unlock(&bond->ptrlock);
+
+	while ((slave = slave->prev) != (slave_t *)bond) {
+		/* use updelay+1 to match an UP slave even when updelay is 0 */
+		int mindelay = updelay + 1;
+		struct net_device *dev = slave->dev;
+		int link_state;
+		u16 old_speed = slave->speed;
+		u8 old_duplex = slave->duplex;
+		
+		link_state = bond_check_dev_link(dev, 0);
+
+		switch (slave->link) {
+		case BOND_LINK_UP:	/* the link was up */
+			if (link_state == BMSR_LSTATUS) {
+				/* link stays up, tell that this one
+				   is immediately available */
+				if (IS_UP(dev) && (mindelay > -2)) {
+					/* -2 is the best case :
+					   this slave was already up */
+					mindelay = -2;
+					bestslave = slave;
+				}
+				break;
+			}
+			else { /* link going down */
+				slave->link  = BOND_LINK_FAIL;
+				slave->delay = downdelay;
+				if (slave->link_failure_count < UINT_MAX) {
+					slave->link_failure_count++;
+				}
+				if (downdelay > 0) {
+					printk (KERN_INFO
+						"%s: link status down for %sinterface "
+						"%s, disabling it in %d ms.\n",
+						master->name,
+						IS_UP(dev)
+						? ((bond_mode == BOND_MODE_ACTIVEBACKUP)
+						   ? ((slave == oldcurrent)
+						      ? "active " : "backup ")
+						   : "")
+						: "idle ",
+						dev->name,
+						downdelay * miimon);
+					}
+			}
+			/* no break ! fall through the BOND_LINK_FAIL test to
+			   ensure proper action to be taken
+			*/
+		case BOND_LINK_FAIL:	/* the link has just gone down */
+			if (link_state != BMSR_LSTATUS) {
+				/* link stays down */
+				if (slave->delay <= 0) {
+					/* link down for too long time */
+					slave->link = BOND_LINK_DOWN;
+					/* in active/backup mode, we must
+					 * completely disable this interface
+					 */
+					if ((bond_mode == BOND_MODE_ACTIVEBACKUP) ||
+					    (bond_mode == BOND_MODE_8023AD)) {
+						bond_set_slave_inactive_flags(slave);
+					}
+					printk(KERN_INFO
+						"%s: link status definitely down "
+						"for interface %s, disabling it",
+						master->name,
+						dev->name);
+
+					/* notify ad that the link status has changed */
+					if (bond_mode == BOND_MODE_8023AD) {
+						bond_3ad_handle_link_change(slave, BOND_LINK_DOWN);
+					}
+
+					if ((bond_mode == BOND_MODE_TLB) ||
+					    (bond_mode == BOND_MODE_ALB)) {
+						bond_alb_handle_link_change(bond, slave, BOND_LINK_DOWN);
+					}
+
+					write_lock(&bond->ptrlock);
+					if (slave == bond->current_slave) {
+						/* find a new interface and be verbose */
+						change_active_interface(bond);
+					} else {
+						printk(".\n");
+					}
+					write_unlock(&bond->ptrlock);
+					slave_died = 1;
+				} else {
+					slave->delay--;
+				}
+			} else {
+				/* link up again */
+				slave->link  = BOND_LINK_UP;
+				slave->jiffies = jiffies;
+				printk(KERN_INFO
+					"%s: link status up again after %d ms "
+					"for interface %s.\n",
+					master->name,
+					(downdelay - slave->delay) * miimon,
+					dev->name);
+
+				if (IS_UP(dev) && (mindelay > -1)) {
+					/* -1 is a good case : this slave went
+					   down only for a short time */
+					mindelay = -1;
+					bestslave = slave;
+				}
+			}
+			break;
+		case BOND_LINK_DOWN:	/* the link was down */
+			if (link_state != BMSR_LSTATUS) {
+				/* the link stays down, nothing more to do */
+				break;
+			} else {	/* link going up */
+				slave->link  = BOND_LINK_BACK;
+				slave->delay = updelay;
+				
+				if (updelay > 0) {
+					/* if updelay == 0, no need to
+					   advertise about a 0 ms delay */
+					printk (KERN_INFO
+						"%s: link status up for interface"
+						" %s, enabling it in %d ms.\n",
+						master->name,
+						dev->name,
+						updelay * miimon);
+				}
+			}
+			/* no break ! fall through the BOND_LINK_BACK state in
+			   case there's something to do.
+			*/
+		case BOND_LINK_BACK:	/* the link has just come back */
+			if (link_state != BMSR_LSTATUS) {
+				/* link down again */
+				slave->link  = BOND_LINK_DOWN;
+				printk(KERN_INFO
+					"%s: link status down again after %d ms "
+					"for interface %s.\n",
+					master->name,
+					(updelay - slave->delay) * miimon,
+					dev->name);
+			} else {
+				/* link stays up */
+				if (slave->delay == 0) {
+					/* now the link has been up for long time enough */
+					slave->link = BOND_LINK_UP;
+					slave->jiffies = jiffies;
+
+					if (bond_mode == BOND_MODE_8023AD) {
+						/* prevent it from being the active one */
+						slave->state = BOND_STATE_BACKUP;
+					}
+					else if (bond_mode != BOND_MODE_ACTIVEBACKUP) {
+						/* make it immediately active */
+						slave->state = BOND_STATE_ACTIVE;
+					} else if (slave != bond->primary_slave) {
+						/* prevent it from being the active one */
+						slave->state = BOND_STATE_BACKUP;
+					}
+
+					printk(KERN_INFO
+						"%s: link status definitely up "
+						"for interface %s.\n",
+						master->name,
+						dev->name);
+	
+					/* notify ad that the link status has changed */
+					if (bond_mode == BOND_MODE_8023AD) {
+						bond_3ad_handle_link_change(slave, BOND_LINK_UP);
+					}
+
+					if ((bond_mode == BOND_MODE_TLB) ||
+					    (bond_mode == BOND_MODE_ALB)) {
+						bond_alb_handle_link_change(bond, slave, BOND_LINK_UP);
+					}
+
+					write_lock(&bond->ptrlock);
+					if ( (bond->primary_slave != NULL)
+					  && (slave == bond->primary_slave) )
+						change_active_interface(bond); 
+					write_unlock(&bond->ptrlock);
+				}
+				else
+					slave->delay--;
+
+				/* we'll also look for the mostly eligible slave */
+				if (bond->primary_slave == NULL)  {
+				    if (IS_UP(dev) && (slave->delay < mindelay)) {
+					mindelay = slave->delay;
+					bestslave = slave;
+				    } 
+				} else if ( (IS_UP(bond->primary_slave->dev))  || 
+				          ( (!IS_UP(bond->primary_slave->dev))  && 
+				          (IS_UP(dev) && (slave->delay < mindelay)) ) ) {
+					mindelay = slave->delay;
+					bestslave = slave;
+				}
+			}
+			break;
+		} /* end of switch */
+
+		bond_update_speed_duplex(slave);
+
+		if (bond_mode == BOND_MODE_8023AD) {
+			if (old_speed != slave->speed) {
+				bond_3ad_adapter_speed_changed(slave);
+			}
+			if (old_duplex != slave->duplex) {
+				bond_3ad_adapter_duplex_changed(slave);
+			}
+		}
+
+	} /* end of while */
+
+	/* 
+	 * if there's no active interface and we discovered that one
+	 * of the slaves could be activated earlier, so we do it.
+	 */
+	read_lock(&bond->ptrlock);
+	oldcurrent = bond->current_slave;
+	read_unlock(&bond->ptrlock);
+
+	/* no active interface at the moment or need to bring up the primary */
+	if (oldcurrent == NULL)  { /* no active interface at the moment */
+		if (bestslave != NULL) { /* last chance to find one ? */
+			if (bestslave->link == BOND_LINK_UP) {
+				printk (KERN_INFO
+					"%s: making interface %s the new active one.\n",
+					master->name, bestslave->dev->name);
+			} else {
+				printk (KERN_INFO
+					"%s: making interface %s the new "
+					"active one %d ms earlier.\n",
+					master->name, bestslave->dev->name,
+					(updelay - bestslave->delay) * miimon);
+
+				bestslave->delay = 0;
+				bestslave->link  = BOND_LINK_UP;
+				bestslave->jiffies = jiffies;
+
+				/* notify ad that the link status has changed */
+				if (bond_mode == BOND_MODE_8023AD) {
+					bond_3ad_handle_link_change(bestslave, BOND_LINK_UP);
+				}
+
+				if ((bond_mode == BOND_MODE_TLB) ||
+				    (bond_mode == BOND_MODE_ALB)) {
+					bond_alb_handle_link_change(bond, bestslave, BOND_LINK_UP);
+				}
+			}
+
+			if (bond_mode == BOND_MODE_ACTIVEBACKUP) {
+				bond_set_slave_active_flags(bestslave);
+				bond_mc_update(bond, bestslave, NULL);
+			} else if (bond_mode != BOND_MODE_8023AD) {
+				bestslave->state = BOND_STATE_ACTIVE;
+			}
+			write_lock(&bond->ptrlock);
+			bond_assign_current_slave(bond, bestslave);
+			write_unlock(&bond->ptrlock);
+		} else if (slave_died) {
+			/* print this message only once a slave has just died */
+			printk(KERN_INFO
+				"%s: now running without any active interface !\n",
+				master->name);
+		}
+	}
+
+	read_unlock(&bond->lock);
+	/* re-arm the timer */
+	mod_timer(&bond->mii_timer, jiffies + (miimon * HZ / 1000));
+}
+
+/* 
+ * this function is called regularly to monitor each slave's link 
+ * ensuring that traffic is being sent and received when arp monitoring
+ * is used in load-balancing mode. if the adapter has been dormant, then an 
+ * arp is transmitted to generate traffic. see activebackup_arp_monitor for 
+ * arp monitoring in active backup mode. 
+ */
+static void loadbalance_arp_monitor(struct net_device *master)
+{
+	bonding_t *bond;
+	slave_t *slave;
+	int the_delta_in_ticks =  arp_interval * HZ / 1000;
+	int next_timer = jiffies + (arp_interval * HZ / 1000);
+
+	bond = (struct bonding *) master->priv; 
+	if (master->priv == NULL) {
+		mod_timer(&bond->arp_timer, next_timer);
+		return;
+	}
+
+	/* TODO: investigate why rtnl_shlock_nowait and rtnl_exlock_nowait
+	 * are called below and add comment why they are required... 
+	 */
+	if ((!IS_UP(master)) || rtnl_shlock_nowait()) {
+		mod_timer(&bond->arp_timer, next_timer);
+		return;
+	}
+
+	if (rtnl_exlock_nowait()) {
+		rtnl_shunlock();
+		mod_timer(&bond->arp_timer, next_timer);
+		return;
+	}
+
+	read_lock(&bond->lock);
+
+	/* see if any of the previous devices are up now (i.e. they have
+	 * xmt and rcv traffic). the current_slave does not come into
+	 * the picture unless it is null. also, slave->jiffies is not needed
+	 * here because we send an arp on each slave and give a slave as
+	 * long as it needs to get the tx/rx within the delta.
+	 * TODO: what about up/down delay in arp mode? it wasn't here before
+	 *       so it can wait 
+	 */
+	slave = (slave_t *)bond;
+	while ((slave = slave->prev) != (slave_t *)bond)  {
+
+	  	if (slave->link != BOND_LINK_UP) {
+
+	  		if (((jiffies - slave->dev->trans_start) <= 
+						the_delta_in_ticks) &&  
+			     ((jiffies - slave->dev->last_rx) <= 
+						the_delta_in_ticks)) {
+
+				slave->link  = BOND_LINK_UP;
+				slave->state = BOND_STATE_ACTIVE;
+
+				/* primary_slave has no meaning in round-robin
+				 * mode. the window of a slave being up and 
+				 * current_slave being null after enslaving
+				 * is closed.
+				 */
+				write_lock(&bond->ptrlock);
+				if (bond->current_slave == NULL) {
+					printk(KERN_INFO
+						"%s: link status definitely up "
+						"for interface %s, ",
+						master->name,
+						slave->dev->name);
+					change_active_interface(bond); 
+				} else {
+					printk(KERN_INFO
+						"%s: interface %s is now up\n",
+						master->name,
+						slave->dev->name);
+				}
+				write_unlock(&bond->ptrlock);
+			} 
+		} else {
+			/* slave->link == BOND_LINK_UP */
+
+			/* not all switches will respond to an arp request
+			 * when the source ip is 0, so don't take the link down
+			 * if we don't know our ip yet
+			 */
+			if (((jiffies - slave->dev->trans_start) >= 
+		              (2*the_delta_in_ticks)) ||
+		             (((jiffies - slave->dev->last_rx) >= 
+		               (2*the_delta_in_ticks)) && my_ip !=0)) {
+				slave->link  = BOND_LINK_DOWN;
+				slave->state = BOND_STATE_BACKUP;
+				if (slave->link_failure_count < UINT_MAX) {
+					slave->link_failure_count++;
+				}
+				printk(KERN_INFO
+				       "%s: interface %s is now down.\n",
+				       master->name,
+				       slave->dev->name);
+
+				write_lock(&bond->ptrlock);
+				if (slave == bond->current_slave) {
+					change_active_interface(bond);
+				}
+				write_unlock(&bond->ptrlock);
+			}
+		} 
+
+		/* note: if switch is in round-robin mode, all links 
+		 * must tx arp to ensure all links rx an arp - otherwise
+		 * links may oscillate or not come up at all; if switch is 
+		 * in something like xor mode, there is nothing we can 
+		 * do - all replies will be rx'ed on same link causing slaves 
+		 * to be unstable during low/no traffic periods
+		 */
+		if (IS_UP(slave->dev)) {
+			arp_send_all(slave);
+		}
+	}
+
+	read_unlock(&bond->lock);
+	rtnl_exunlock();
+	rtnl_shunlock();
+
+	/* re-arm the timer */
+	mod_timer(&bond->arp_timer, next_timer);
+}
+
+/* 
+ * When using arp monitoring in active-backup mode, this function is
+ * called to determine if any backup slaves have went down or a new
+ * current slave needs to be found.
+ * The backup slaves never generate traffic, they are considered up by merely 
+ * receiving traffic. If the current slave goes down, each backup slave will 
+ * be given the opportunity to tx/rx an arp before being taken down - this 
+ * prevents all slaves from being taken down due to the current slave not 
+ * sending any traffic for the backups to receive. The arps are not necessarily
+ * necessary, any tx and rx traffic will keep the current slave up. While any 
+ * rx traffic will keep the backup slaves up, the current slave is responsible 
+ * for generating traffic to keep them up regardless of any other traffic they 
+ * may have received.
+ * see loadbalance_arp_monitor for arp monitoring in load balancing mode
+ */
+static void activebackup_arp_monitor(struct net_device *master)
+{
+	bonding_t *bond;
+	slave_t *slave;
+	int the_delta_in_ticks =  arp_interval * HZ / 1000;
+	int next_timer = jiffies + (arp_interval * HZ / 1000);
+
+	bond = (struct bonding *) master->priv; 
+	if (master->priv == NULL) {
+		mod_timer(&bond->arp_timer, next_timer);
+		return;
+	}
+
+	if (!IS_UP(master)) {
+		mod_timer(&bond->arp_timer, next_timer);
+		return;
+	}
+
+	read_lock(&bond->lock);
+
+	/* determine if any slave has come up or any backup slave has 
+	 * gone down 
+	 * TODO: what about up/down delay in arp mode? it wasn't here before
+	 *       so it can wait 
+	 */
+	slave = (slave_t *)bond;
+	while ((slave = slave->prev) != (slave_t *)bond)  {
+
+	  	if (slave->link != BOND_LINK_UP) {
+			if ((jiffies - slave->dev->last_rx) <=
+			    the_delta_in_ticks) {
+
+				slave->link = BOND_LINK_UP;
+				write_lock(&bond->ptrlock);
+				if ((bond->current_slave == NULL) &&
+				    ((jiffies - slave->dev->trans_start) <=
+				     the_delta_in_ticks)) {
+					bond_assign_current_slave(bond, slave);
+					bond_set_slave_active_flags(slave);
+			                bond_mc_update(bond, slave, NULL);
+					bond->current_arp_slave = NULL;
+				} else if (bond->current_slave != slave) {
+					/* this slave has just come up but we 
+					 * already have a current slave; this
+					 * can also happen if bond_enslave adds
+					 * a new slave that is up while we are 
+					 * searching for a new slave
+					 */
+					bond_set_slave_inactive_flags(slave);
+					bond->current_arp_slave = NULL;
+				}
+
+				if (slave == bond->current_slave) {
+					printk(KERN_INFO
+						"%s: %s is up and now the "
+						"active interface\n",
+						master->name,
+						slave->dev->name);
+				} else {
+					printk(KERN_INFO
+						"%s: backup interface %s is "
+						"now up\n",
+						master->name,
+						slave->dev->name);
+				}
+
+				write_unlock(&bond->ptrlock);
+			}
+		} else {
+			read_lock(&bond->ptrlock);
+			if ((slave != bond->current_slave) &&
+			    (bond->current_arp_slave == NULL) &&
+			    (((jiffies - slave->dev->last_rx) >=
+			     3*the_delta_in_ticks) && (my_ip != 0))) {
+				/* a backup slave has gone down; three times 
+				 * the delta allows the current slave to be 
+				 * taken out before the backup slave.
+				 * note: a non-null current_arp_slave indicates
+				 * the current_slave went down and we are 
+				 * searching for a new one; under this 
+				 * condition we only take the current_slave 
+				 * down - this gives each slave a chance to 
+				 * tx/rx traffic before being taken out
+				 */
+				read_unlock(&bond->ptrlock);
+				slave->link  = BOND_LINK_DOWN;
+				if (slave->link_failure_count < UINT_MAX) {
+					slave->link_failure_count++;
+				}
+				bond_set_slave_inactive_flags(slave);
+				printk(KERN_INFO
+					"%s: backup interface %s is now down\n",
+					master->name,
+					slave->dev->name);
+			} else {
+				read_unlock(&bond->ptrlock);
+			}
+		}
+	}
+
+	read_lock(&bond->ptrlock);
+	slave = bond->current_slave;
+	read_unlock(&bond->ptrlock);
+
+	if (slave != NULL) {
+
+		/* if we have sent traffic in the past 2*arp_intervals but
+		 * haven't xmit and rx traffic in that time interval, select 
+		 * a different slave. slave->jiffies is only updated when
+		 * a slave first becomes the current_slave - not necessarily
+		 * after every arp; this ensures the slave has a full 2*delta 
+		 * before being taken out. if a primary is being used, check 
+		 * if it is up and needs to take over as the current_slave
+		 */
+		if ((((jiffies - slave->dev->trans_start) >= 
+		       (2*the_delta_in_ticks)) ||
+		     (((jiffies - slave->dev->last_rx) >= 
+		       (2*the_delta_in_ticks)) && (my_ip != 0))) &&
+		    ((jiffies - slave->jiffies) >= 2*the_delta_in_ticks)) {
+
+			slave->link  = BOND_LINK_DOWN;
+			if (slave->link_failure_count < UINT_MAX) {
+				slave->link_failure_count++;
+			}
+			printk(KERN_INFO "%s: link status down for "
+					 "active interface %s, disabling it",
+			       master->name,
+			       slave->dev->name);
+			write_lock(&bond->ptrlock);
+			slave = change_active_interface(bond);
+			write_unlock(&bond->ptrlock);
+			bond->current_arp_slave = slave;
+			if (slave != NULL) {
+				slave->jiffies = jiffies;
+			}
+
+		} else if ((bond->primary_slave != NULL) && 
+			   (bond->primary_slave != slave) && 
+			   (bond->primary_slave->link == BOND_LINK_UP)) {
+			/* at this point, slave is the current_slave */
+			printk(KERN_INFO 
+			       "%s: changing from interface %s to primary "
+			       "interface %s\n",
+			       master->name, 
+			       slave->dev->name, 
+			       bond->primary_slave->dev->name);
+			       
+			/* primary is up so switch to it */
+			bond_set_slave_inactive_flags(slave);
+			bond_mc_update(bond, bond->primary_slave, slave);
+			write_lock(&bond->ptrlock);
+			bond_assign_current_slave(bond, bond->primary_slave);
+			write_unlock(&bond->ptrlock);
+			slave = bond->primary_slave;
+			bond_set_slave_active_flags(slave);
+			slave->jiffies = jiffies;
+		} else {
+			bond->current_arp_slave = NULL;
+		}
+
+		/* the current slave must tx an arp to ensure backup slaves
+		 * rx traffic
+		 */
+		if ((slave != NULL) && (my_ip != 0)) {
+			arp_send_all(slave);
+		}
+	}
+
+	/* if we don't have a current_slave, search for the next available 
+	 * backup slave from the current_arp_slave and make it the candidate 
+	 * for becoming the current_slave
+	 */
+	if (slave == NULL) { 
+
+		if ((bond->current_arp_slave == NULL) ||
+		    (bond->current_arp_slave == (slave_t *)bond)) {
+			bond->current_arp_slave = bond->prev;
+		} 
+
+		if (bond->current_arp_slave != (slave_t *)bond) {
+			bond_set_slave_inactive_flags(bond->current_arp_slave);
+			slave = bond->current_arp_slave->next;
+
+			/* search for next candidate */
+			do {
+				if (IS_UP(slave->dev)) {
+					slave->link = BOND_LINK_BACK;
+					bond_set_slave_active_flags(slave);
+					arp_send_all(slave);
+					slave->jiffies = jiffies;
+					bond->current_arp_slave = slave;
+					break;
+				}
+
+				/* if the link state is up at this point, we 
+				 * mark it down - this can happen if we have 
+				 * simultaneous link failures and 
+				 * change_active_interface doesn't make this 
+				 * one the current slave so it is still marked 
+				 * up when it is actually down
+				 */
+				if (slave->link == BOND_LINK_UP) {
+					slave->link  = BOND_LINK_DOWN;
+					if (slave->link_failure_count < 
+							UINT_MAX) {
+						slave->link_failure_count++;
+					}
+
+					bond_set_slave_inactive_flags(slave);
+					printk(KERN_INFO
+						"%s: backup interface "
+						"%s is now down.\n",
+						master->name,
+						slave->dev->name);
+				}
+			} while ((slave = slave->next) != 
+					bond->current_arp_slave->next);
+		}
+	}
+
+	read_unlock(&bond->lock);
+	mod_timer(&bond->arp_timer, next_timer);
+}
+
+static int bond_sethwaddr(struct net_device *master, struct net_device *slave)
+{
+#ifdef BONDING_DEBUG
+	printk(KERN_CRIT "bond_sethwaddr: master=%x\n", (unsigned int)master);
+	printk(KERN_CRIT "bond_sethwaddr: slave=%x\n", (unsigned int)slave);
+	printk(KERN_CRIT "bond_sethwaddr: slave->addr_len=%d\n", slave->addr_len);
+#endif
+	memcpy(master->dev_addr, slave->dev_addr, slave->addr_len);
+	return 0;
+}
+
+static int bond_info_query(struct net_device *master, struct ifbond *info)
+{
+	bonding_t *bond = (struct bonding *) master->priv;
+	slave_t *slave;
+
+	info->bond_mode = bond_mode;
+	info->num_slaves = 0;
+	info->miimon = miimon;
+
+	read_lock_bh(&bond->lock);
+	for (slave = bond->prev; slave != (slave_t *)bond; slave = slave->prev) {
+		info->num_slaves++;
+	}
+	read_unlock_bh(&bond->lock);
+
+	return 0;
+}
+
+static int bond_slave_info_query(struct net_device *master, 
+					struct ifslave *info)
+{
+	bonding_t *bond = (struct bonding *) master->priv;
+	slave_t *slave;
+	int cur_ndx = 0;
+
+	if (info->slave_id < 0) {
+		return -ENODEV;
+	}
+
+	read_lock_bh(&bond->lock);
+	for (slave = bond->prev; 
+		 slave != (slave_t *)bond && cur_ndx < info->slave_id; 
+		 slave = slave->prev) {
+		cur_ndx++;
+	}
+	read_unlock_bh(&bond->lock);
+
+	if (slave != (slave_t *)bond) {
+		strcpy(info->slave_name, slave->dev->name);
+		info->link = slave->link;
+		info->state = slave->state;
+		info->link_failure_count = slave->link_failure_count;
+	} else {
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
+static int bond_ethtool_ioctl(struct net_device *master_dev, struct ifreq *ifr)
+{
+	void *addr = ifr->ifr_data;
+	uint32_t cmd;
+
+	if (get_user(cmd, (uint32_t *) addr))
+		return -EFAULT;
+
+	switch (cmd) {
+
+	case ETHTOOL_GDRVINFO:
+		{
+			struct ethtool_drvinfo info;
+			char *endptr;
+
+			if (copy_from_user(&info, addr, sizeof(info)))
+				return -EFAULT;
+
+			if (strcmp(info.driver, "ifenslave") == 0) {
+				int new_abi_ver;
+
+				new_abi_ver = simple_strtoul(info.fw_version,
+						             &endptr, 0);
+				if (*endptr) {
+					printk(KERN_ERR
+					       "bonding: Error: got invalid ABI"
+					       " version from application\n");
+
+					return -EINVAL;
+				}
+
+				if (orig_app_abi_ver == -1) {
+					orig_app_abi_ver  = new_abi_ver;
+				}
+
+				app_abi_ver = new_abi_ver;
+			}
+
+			strncpy(info.driver,  DRV_NAME, 32);
+			strncpy(info.version, DRV_VERSION, 32);
+			snprintf(info.fw_version, 32, "%d", BOND_ABI_VERSION);
+
+			if (copy_to_user(addr, &info, sizeof(info)))
+				return -EFAULT;
+
+			return 0;
+		}
+		break;
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
+static int bond_ioctl(struct net_device *master_dev, struct ifreq *ifr, int cmd)
+{
+	struct net_device *slave_dev = NULL;
+	struct ifbond *u_binfo = NULL, k_binfo;
+	struct ifslave *u_sinfo = NULL, k_sinfo;
+	struct mii_ioctl_data *mii = NULL;
+	int prev_abi_ver = orig_app_abi_ver;
+	int ret = 0;
+
+#ifdef BONDING_DEBUG
+	printk(KERN_INFO "bond_ioctl: master=%s, cmd=%d\n", 
+		master_dev->name, cmd);
+#endif
+
+	switch (cmd) {
+	case SIOCETHTOOL:
+		return bond_ethtool_ioctl(master_dev, ifr);
+
+	case SIOCGMIIPHY:
+		mii = (struct mii_ioctl_data *)&ifr->ifr_data;
+		if (mii == NULL) {
+			return -EINVAL;
+		}
+		mii->phy_id = 0;
+		/* Fall Through */
+	case SIOCGMIIREG:
+		/* 
+		 * We do this again just in case we were called by SIOCGMIIREG
+		 * instead of SIOCGMIIPHY.
+		 */
+		mii = (struct mii_ioctl_data *)&ifr->ifr_data;
+		if (mii == NULL) {
+			return -EINVAL;
+		}
+		if (mii->reg_num == 1) {
+			mii->val_out = bond_check_mii_link(
+				(struct bonding *)master_dev->priv);
+		}
+		return 0;
+	case BOND_INFO_QUERY_OLD:
+	case SIOCBONDINFOQUERY:
+		u_binfo = (struct ifbond *)ifr->ifr_data;
+		if (copy_from_user(&k_binfo, u_binfo, sizeof(ifbond))) {
+			return -EFAULT;
+		}
+		ret = bond_info_query(master_dev, &k_binfo);
+		if (ret == 0) {
+			if (copy_to_user(u_binfo, &k_binfo, sizeof(ifbond))) {
+				return -EFAULT;
+			}
+		}
+		return ret;
+	case BOND_SLAVE_INFO_QUERY_OLD:
+	case SIOCBONDSLAVEINFOQUERY:
+		u_sinfo = (struct ifslave *)ifr->ifr_data;
+		if (copy_from_user(&k_sinfo, u_sinfo, sizeof(ifslave))) {
+			return -EFAULT;
+		}
+		ret = bond_slave_info_query(master_dev, &k_sinfo);
+		if (ret == 0) {
+			if (copy_to_user(u_sinfo, &k_sinfo, sizeof(ifslave))) {
+				return -EFAULT;
+			}
+		}
+		return ret;
+	}
+
+	if (!capable(CAP_NET_ADMIN)) {
+		return -EPERM;
+	}
+
+	if (orig_app_abi_ver == -1) {
+		/* no orig_app_abi_ver was provided yet, so we'll use the
+		 * current one from now on, even if it's 0
+		 */
+		orig_app_abi_ver = app_abi_ver;
+
+	} else if (orig_app_abi_ver != app_abi_ver) {
+		printk(KERN_ERR
+		       "bonding: Error: already using ifenslave ABI "
+		       "version %d; to upgrade ifenslave to version %d, "
+		       "you must first reload bonding.\n",
+		       orig_app_abi_ver, app_abi_ver);
+		return -EINVAL;
+	}
+
+	slave_dev = dev_get_by_name(ifr->ifr_slave);
+
+#ifdef BONDING_DEBUG
+	printk(KERN_INFO "slave_dev=%x: \n", (unsigned int)slave_dev);
+	printk(KERN_INFO "slave_dev->name=%s: \n", slave_dev->name);
+#endif
+
+	if (slave_dev == NULL) {
+		ret = -ENODEV;
+	} else {
+		switch (cmd) {
+		case BOND_ENSLAVE_OLD:
+		case SIOCBONDENSLAVE:		
+			ret = bond_enslave(master_dev, slave_dev);
+			break;
+		case BOND_RELEASE_OLD:			
+		case SIOCBONDRELEASE:	
+			ret = bond_release(master_dev, slave_dev); 
+			break;
+		case BOND_SETHWADDR_OLD:
+		case SIOCBONDSETHWADDR:	
+			ret = bond_sethwaddr(master_dev, slave_dev);
+			break;
+		case BOND_CHANGE_ACTIVE_OLD:
+		case SIOCBONDCHANGEACTIVE:
+			if ((bond_mode == BOND_MODE_ACTIVEBACKUP) ||
+			    (bond_mode == BOND_MODE_TLB) ||
+			    (bond_mode == BOND_MODE_ALB)) {
+				ret = bond_change_active(master_dev, slave_dev);
+			}
+			else {
+				ret = -EINVAL;
+			}
+			break;
+		default:
+			ret = -EOPNOTSUPP;
+		}
+		dev_put(slave_dev);
+	}
+
+	if (ret < 0) {
+		/* The ioctl failed, so there's no point in changing the
+		 * orig_app_abi_ver. We'll restore it's value just in case
+		 * we've changed it earlier in this function.
+		 */
+		orig_app_abi_ver = prev_abi_ver;
+	}
+
+	return ret;
+}
+
+#ifdef CONFIG_NET_FASTROUTE
+static int bond_accept_fastpath(struct net_device *dev, struct dst_entry *dst)
+{
+	return -1;
+}
+#endif
+
+/* 
+ * in broadcast mode, we send everything to all usable interfaces.
+ */
+static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *dev)
+{
+	slave_t *slave, *start_at;
+	struct bonding *bond = (struct bonding *) dev->priv;
+	struct net_device *device_we_should_send_to = 0;
+
+	if (!IS_UP(dev)) { /* bond down */
+		dev_kfree_skb(skb);
+		return 0;
+	}
+
+	read_lock(&bond->lock);
+
+	read_lock(&bond->ptrlock);
+	slave = start_at = bond->current_slave;
+	read_unlock(&bond->ptrlock);
+
+	if (slave == NULL) { /* we're at the root, get the first slave */
+		/* no suitable interface, frame not sent */
+		read_unlock(&bond->lock);
+		dev_kfree_skb(skb);
+		return 0;
+	}
+
+	do {
+		if (IS_UP(slave->dev)
+		    && (slave->link == BOND_LINK_UP)
+		    && (slave->state == BOND_STATE_ACTIVE)) {
+			if (device_we_should_send_to) {
+				struct sk_buff *skb2;
+				if ((skb2 = skb_clone(skb, GFP_ATOMIC)) == NULL) {
+					printk(KERN_ERR "bond_xmit_broadcast: skb_clone() failed\n");
+					continue;
+				}
+
+				skb2->dev = device_we_should_send_to;
+				skb2->priority = 1;
+				dev_queue_xmit(skb2);
+			}
+			device_we_should_send_to = slave->dev;
+		}
+	} while ((slave = slave->next) != start_at);
+
+	if (device_we_should_send_to) {
+		skb->dev = device_we_should_send_to;
+		skb->priority = 1;
+		dev_queue_xmit(skb);
+	} else
+		dev_kfree_skb(skb);
+
+	/* frame sent to all suitable interfaces */
+	read_unlock(&bond->lock);
+	return 0;
+}
+
+static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *dev)
+{
+	slave_t *slave, *start_at;
+	struct bonding *bond = (struct bonding *) dev->priv;
+
+	if (!IS_UP(dev)) { /* bond down */
+		dev_kfree_skb(skb);
+		return 0;
+	}
+
+	read_lock(&bond->lock);
+
+	read_lock(&bond->ptrlock);
+	slave = start_at = bond->current_slave;
+	read_unlock(&bond->ptrlock);
+
+	if (slave == NULL) { /* we're at the root, get the first slave */
+		/* no suitable interface, frame not sent */
+		dev_kfree_skb(skb);
+		read_unlock(&bond->lock);
+		return 0;
+	}
+
+	do {
+		if (IS_UP(slave->dev)
+		    && (slave->link == BOND_LINK_UP)
+		    && (slave->state == BOND_STATE_ACTIVE)) {
+
+			skb->dev = slave->dev;
+			skb->priority = 1;
+			dev_queue_xmit(skb);
+
+			write_lock(&bond->ptrlock);
+			bond_assign_current_slave(bond, slave->next);
+			write_unlock(&bond->ptrlock);
+
+			read_unlock(&bond->lock);
+			return 0;
+		}
+	} while ((slave = slave->next) != start_at);
+
+	/* no suitable interface, frame not sent */
+	dev_kfree_skb(skb);
+	read_unlock(&bond->lock);
+	return 0;
+}
+
+/* 
+ * in XOR mode, we determine the output device by performing xor on
+ * the source and destination hw adresses.  If this device is not 
+ * enabled, find the next slave following this xor slave. 
+ */
+static int bond_xmit_xor(struct sk_buff *skb, struct net_device *dev)
+{
+	slave_t *slave, *start_at;
+	struct bonding *bond = (struct bonding *) dev->priv;
+	struct ethhdr *data = (struct ethhdr *)skb->data;
+	int slave_no;
+
+	if (!IS_UP(dev)) { /* bond down */
+		dev_kfree_skb(skb);
+		return 0;
+	}
+
+	read_lock(&bond->lock);
+	slave = bond->prev;
+
+	/* we're at the root, get the first slave */
+	if (bond->slave_cnt == 0) {
+		/* no suitable interface, frame not sent */
+		dev_kfree_skb(skb);
+		read_unlock(&bond->lock);
+		return 0;
+	}
+
+	slave_no = (data->h_dest[5]^slave->dev->dev_addr[5]) % bond->slave_cnt;
+
+	while ( (slave_no > 0) && (slave != (slave_t *)bond) ) {
+		slave = slave->prev;
+		slave_no--;
+	} 
+	start_at = slave;
+
+	do {
+		if (IS_UP(slave->dev)
+		    && (slave->link == BOND_LINK_UP)
+		    && (slave->state == BOND_STATE_ACTIVE)) {
+
+			skb->dev = slave->dev;
+			skb->priority = 1;
+			dev_queue_xmit(skb);
+
+			read_unlock(&bond->lock);
+			return 0;
+		}
+	} while ((slave = slave->next) != start_at);
+
+	/* no suitable interface, frame not sent */
+	dev_kfree_skb(skb);
+	read_unlock(&bond->lock);
+	return 0;
+}
+
+/* 
+ * in active-backup mode, we know that bond->current_slave is always valid if
+ * the bond has a usable interface.
+ */
+static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *dev)
+{
+	struct bonding *bond = (struct bonding *) dev->priv;
+	int ret;
+
+	if (!IS_UP(dev)) { /* bond down */
+		dev_kfree_skb(skb);
+		return 0;
+	}
+
+	/* if we are sending arp packets, try to at least 
+	   identify our own ip address */
+	if ( (arp_interval > 0) && (my_ip == 0) &&
+		(skb->protocol == __constant_htons(ETH_P_ARP) ) ) {
+		char *the_ip = (((char *)skb->data)) 
+				+ sizeof(struct ethhdr)  
+				+ sizeof(struct arphdr) + 
+				ETH_ALEN;
+		memcpy(&my_ip, the_ip, 4);
+	}
+
+	/* if we are sending arp packets and don't know 
+	 * the target hw address, save it so we don't need 
+	 * to use a broadcast address.
+	 * don't do this if in active backup mode because the slaves must 
+	 * receive packets to stay up, and the only ones they receive are 
+	 * broadcasts. 
+	 */
+	if ( (bond_mode != BOND_MODE_ACTIVEBACKUP) && 
+             (arp_ip_count == 1) &&
+	     (arp_interval > 0) && (arp_target_hw_addr == NULL) &&
+	     (skb->protocol == __constant_htons(ETH_P_IP) ) ) {
+		struct ethhdr *eth_hdr = 
+			(struct ethhdr *) (((char *)skb->data));
+		struct iphdr *ip_hdr = (struct iphdr *)(eth_hdr + 1);
+
+		if (arp_target[0] == ip_hdr->daddr) {
+			arp_target_hw_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
+			if (arp_target_hw_addr != NULL)
+				memcpy(arp_target_hw_addr, eth_hdr->h_dest, ETH_ALEN);
+		}
+	}
+
+	read_lock(&bond->lock);
+
+	read_lock(&bond->ptrlock);
+	if (bond->current_slave != NULL) { /* one usable interface */
+		skb->dev = bond->current_slave->dev;
+		read_unlock(&bond->ptrlock);
+		skb->priority = 1;
+		ret = dev_queue_xmit(skb);
+		read_unlock(&bond->lock);
+		return 0;
+	}
+	else {
+		read_unlock(&bond->ptrlock);
+	}
+
+	/* no suitable interface, frame not sent */
+#ifdef BONDING_DEBUG
+	printk(KERN_INFO "There was no suitable interface, so we don't transmit\n");
+#endif
+	dev_kfree_skb(skb);
+	read_unlock(&bond->lock);
+	return 0;
+}
+
+static struct net_device_stats *bond_get_stats(struct net_device *dev)
+{
+	bonding_t *bond = dev->priv;
+	struct net_device_stats *stats = bond->stats, *sstats;
+	slave_t *slave;
+
+	memset(bond->stats, 0, sizeof(struct net_device_stats));
+
+	read_lock_bh(&bond->lock);
+
+	for (slave = bond->prev; slave != (slave_t *)bond; slave = slave->prev) {
+		sstats = slave->dev->get_stats(slave->dev);
+ 
+		stats->rx_packets += sstats->rx_packets;
+		stats->rx_bytes += sstats->rx_bytes;
+		stats->rx_errors += sstats->rx_errors;
+		stats->rx_dropped += sstats->rx_dropped;
+
+		stats->tx_packets += sstats->tx_packets;
+		stats->tx_bytes += sstats->tx_bytes;
+		stats->tx_errors += sstats->tx_errors;
+		stats->tx_dropped += sstats->tx_dropped;
+
+		stats->multicast += sstats->multicast;
+		stats->collisions += sstats->collisions;
+
+		stats->rx_length_errors += sstats->rx_length_errors;
+		stats->rx_over_errors += sstats->rx_over_errors;
+		stats->rx_crc_errors += sstats->rx_crc_errors;
+		stats->rx_frame_errors += sstats->rx_frame_errors;
+		stats->rx_fifo_errors += sstats->rx_fifo_errors;	
+		stats->rx_missed_errors += sstats->rx_missed_errors;
+	
+		stats->tx_aborted_errors += sstats->tx_aborted_errors;
+		stats->tx_carrier_errors += sstats->tx_carrier_errors;
+		stats->tx_fifo_errors += sstats->tx_fifo_errors;
+		stats->tx_heartbeat_errors += sstats->tx_heartbeat_errors;
+		stats->tx_window_errors += sstats->tx_window_errors;
+
+	}
+
+	read_unlock_bh(&bond->lock);
+	return stats;
+}
+
+static int bond_get_info(char *buf, char **start, off_t offset, int length)
+{
+	bonding_t *bond = these_bonds;
+	int len = 0;
+	off_t begin = 0;
+	u16 link;
+	slave_t *slave = NULL;
+
+	len += sprintf(buf + len, "%s\n", version);
+
+	while (bond != NULL) {
+		/*
+		 * This function locks the mutex, so we can't lock it until 
+		 * afterwards
+		 */
+		link = bond_check_mii_link(bond);
+
+		len += sprintf(buf + len, "Bonding Mode: %s\n",
+			       bond_mode_name());
+
+		if ((bond_mode == BOND_MODE_ACTIVEBACKUP) ||
+		    (bond_mode == BOND_MODE_TLB) ||
+		    (bond_mode == BOND_MODE_ALB)) {
+			read_lock_bh(&bond->lock);
+			read_lock(&bond->ptrlock);
+			if (bond->current_slave != NULL) {
+				len += sprintf(buf + len, 
+					"Currently Active Slave: %s\n", 
+					bond->current_slave->dev->name);
+			}
+			read_unlock(&bond->ptrlock);
+			read_unlock_bh(&bond->lock);
+		}
+
+		len += sprintf(buf + len, "MII Status: ");
+		len += sprintf(buf + len, 
+				link == BMSR_LSTATUS ? "up\n" : "down\n");
+		len += sprintf(buf + len, "MII Polling Interval (ms): %d\n", 
+				miimon);
+		len += sprintf(buf + len, "Up Delay (ms): %d\n", 
+				updelay * miimon);
+		len += sprintf(buf + len, "Down Delay (ms): %d\n", 
+				downdelay * miimon);
+		len += sprintf(buf + len, "Multicast Mode: %s\n",
+			       multicast_mode_name());
+
+		read_lock_bh(&bond->lock);
+
+		if (bond_mode == BOND_MODE_8023AD) {
+			struct ad_info ad_info;
+
+			len += sprintf(buf + len, "\n802.3ad info\n");
+
+			if (bond_3ad_get_active_agg_info(bond, &ad_info)) {
+				len += sprintf(buf + len, "bond %s has no active aggregator\n", bond->device->name);
+			} else {
+				len += sprintf(buf + len, "Active Aggregator Info:\n");
+
+				len += sprintf(buf + len, "\tAggregator ID: %d\n", ad_info.aggregator_id);
+				len += sprintf(buf + len, "\tNumber of ports: %d\n", ad_info.ports);
+				len += sprintf(buf + len, "\tActor Key: %d\n", ad_info.actor_key);
+				len += sprintf(buf + len, "\tPartner Key: %d\n", ad_info.partner_key);
+				len += sprintf(buf + len, "\tPartner Mac Address: %02x:%02x:%02x:%02x:%02x:%02x\n",
+					       ad_info.partner_system[0],
+					       ad_info.partner_system[1],
+					       ad_info.partner_system[2],
+					       ad_info.partner_system[3],
+					       ad_info.partner_system[4],
+					       ad_info.partner_system[5]);
+			}
+		}
+
+		for (slave = bond->prev; slave != (slave_t *)bond; 
+		     slave = slave->prev) {
+			len += sprintf(buf + len, "\nSlave Interface: %s\n", slave->dev->name);
+
+			len += sprintf(buf + len, "MII Status: ");
+
+			len += sprintf(buf + len, 
+				slave->link == BOND_LINK_UP ? 
+				"up\n" : "down\n");
+			len += sprintf(buf + len, "Link Failure Count: %d\n", 
+				slave->link_failure_count);
+
+			if (app_abi_ver >= 1) {
+				len += sprintf(buf + len,
+					       "Permanent HW addr: %02x:%02x:%02x:%02x:%02x:%02x\n",
+					       slave->perm_hwaddr[0],
+					       slave->perm_hwaddr[1],
+					       slave->perm_hwaddr[2],
+					       slave->perm_hwaddr[3],
+					       slave->perm_hwaddr[4],
+					       slave->perm_hwaddr[5]);
+			}
+
+			if (bond_mode == BOND_MODE_8023AD) {
+				struct aggregator *agg = SLAVE_AD_INFO(slave).port.aggregator;
+
+				if (agg) {
+					len += sprintf(buf + len, "Aggregator ID: %d\n",
+						       agg->aggregator_identifier);
+				} else {
+					len += sprintf(buf + len, "Aggregator ID: N/A\n");
+				}
+			}
+		}
+		read_unlock_bh(&bond->lock);
+
+		/*
+		 * Figure out the calcs for the /proc/net interface
+		 */
+		*start = buf + (offset - begin);
+		len -= (offset - begin);
+		if (len > length) {
+			len = length;
+		}
+		if (len < 0) {
+			len = 0;
+		}
+
+
+		bond = bond->next_bond;
+	}
+	return len;
+}
+
+static int bond_event(struct notifier_block *this, unsigned long event, 
+			void *ptr)
+{
+	struct bonding *this_bond = (struct bonding *)these_bonds;
+	struct bonding *last_bond;
+	struct net_device *event_dev = (struct net_device *)ptr;
+
+	/* while there are bonds configured */
+	while (this_bond != NULL) {
+		if (this_bond == event_dev->priv ) {
+			switch (event) {
+			case NETDEV_UNREGISTER:
+				/* 
+				 * remove this bond from a linked list of 
+				 * bonds 
+				 */
+				if (this_bond == these_bonds) {
+					these_bonds = this_bond->next_bond;
+				} else {
+					for (last_bond = these_bonds; 
+					     last_bond != NULL; 
+					     last_bond = last_bond->next_bond) {
+						if (last_bond->next_bond == 
+						    this_bond) {
+							last_bond->next_bond = 
+							this_bond->next_bond;
+						}
+					}
+				}
+				return NOTIFY_DONE;
+
+			default:
+				return NOTIFY_DONE;
+			}
+		} else if (this_bond->device == event_dev->master) {
+			switch (event) {
+			case NETDEV_UNREGISTER:
+				bond_release(this_bond->device, event_dev);
+				break;
+			}
+			return NOTIFY_DONE;
+		}
+		this_bond = this_bond->next_bond;
+	}
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block bond_netdev_notifier = {
+	notifier_call: bond_event,
+};
+
+static int __init bond_init(struct net_device *dev)
+{
+	bonding_t *bond, *this_bond, *last_bond;
+	int count;
+
+#ifdef BONDING_DEBUG
+	printk (KERN_INFO "Begin bond_init for %s\n", dev->name);
+#endif
+	bond = kmalloc(sizeof(struct bonding), GFP_KERNEL);
+	if (bond == NULL) {
+		return -ENOMEM;
+	}
+	memset(bond, 0, sizeof(struct bonding));
+
+	/* initialize rwlocks */
+	rwlock_init(&bond->lock);
+	rwlock_init(&bond->ptrlock);
+	
+	bond->stats = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL);
+	if (bond->stats == NULL) {
+		kfree(bond);
+		return -ENOMEM;
+	}
+	memset(bond->stats, 0, sizeof(struct net_device_stats));
+
+	bond->next = bond->prev = (slave_t *)bond;
+	bond->current_slave = NULL;
+	bond->current_arp_slave = NULL;
+	bond->device = dev;
+	dev->priv = bond;
+
+	/* Initialize the device structure. */
+	switch (bond_mode) {
+	case BOND_MODE_ACTIVEBACKUP:
+		dev->hard_start_xmit = bond_xmit_activebackup;
+		break;
+	case BOND_MODE_ROUNDROBIN:
+		dev->hard_start_xmit = bond_xmit_roundrobin;
+		break;
+	case BOND_MODE_XOR:
+		dev->hard_start_xmit = bond_xmit_xor;
+		break;
+	case BOND_MODE_BROADCAST:
+		dev->hard_start_xmit = bond_xmit_broadcast;
+		break;
+	case BOND_MODE_8023AD:
+		dev->hard_start_xmit = bond_3ad_xmit_xor;
+		break;
+	case BOND_MODE_TLB:
+	case BOND_MODE_ALB:
+		dev->hard_start_xmit = bond_alb_xmit;
+		break;
+	default:
+		printk(KERN_ERR "Unknown bonding mode %d\n", bond_mode);
+		kfree(bond->stats);
+		kfree(bond);
+		return -EINVAL;
+	}
+
+	dev->get_stats = bond_get_stats;
+	dev->open = bond_open;
+	dev->stop = bond_close;
+	dev->set_multicast_list = set_multicast_list;
+	dev->do_ioctl = bond_ioctl;
+
+	/* 
+	 * Fill in the fields of the device structure with ethernet-generic 
+	 * values. 
+	 */
+
+	ether_setup(dev);
+
+	dev->set_mac_address = bond_set_mac_address;
+	dev->tx_queue_len = 0;
+	dev->flags |= IFF_MASTER|IFF_MULTICAST;
+#ifdef CONFIG_NET_FASTROUTE
+	dev->accept_fastpath = bond_accept_fastpath;
+#endif
+
+	printk(KERN_INFO "%s registered with", dev->name);
+	if (miimon > 0) {
+		printk(" MII link monitoring set to %d ms", miimon);
+		updelay /= miimon;
+		downdelay /= miimon;
+	} else {
+		printk("out MII link monitoring");
+	}
+	printk(", in %s mode.\n", bond_mode_name());
+
+	printk(KERN_INFO "%s registered with", dev->name);
+	if (arp_interval > 0) {
+		printk(" ARP monitoring set to %d ms with %d target(s):", 
+			arp_interval, arp_ip_count);
+		for (count=0 ; count<arp_ip_count ; count++)
+                        printk (" %s", arp_ip_target[count]);
+		printk("\n");
+	} else {
+		printk("out ARP monitoring\n");
+	}
+
+#ifdef CONFIG_PROC_FS
+	bond->bond_proc_dir = proc_mkdir(dev->name, proc_net);
+	if (bond->bond_proc_dir == NULL) {
+		printk(KERN_ERR "%s: Cannot init /proc/net/%s/\n", 
+			dev->name, dev->name);
+		kfree(bond->stats);
+		kfree(bond);
+		return -ENOMEM;
+	}
+	bond->bond_proc_info_file = 
+		create_proc_info_entry("info", 0, bond->bond_proc_dir, 
+					bond_get_info);
+	if (bond->bond_proc_info_file == NULL) {
+		printk(KERN_ERR "%s: Cannot init /proc/net/%s/info\n", 
+			dev->name, dev->name);
+		remove_proc_entry(dev->name, proc_net);
+		kfree(bond->stats);
+		kfree(bond);
+		return -ENOMEM;
+	}
+#endif /* CONFIG_PROC_FS */
+
+	if (first_pass == 1) {
+		these_bonds = bond;
+		register_netdevice_notifier(&bond_netdev_notifier);
+		first_pass = 0;
+	} else {
+		last_bond = these_bonds;
+		this_bond = these_bonds->next_bond;
+		while (this_bond != NULL) {
+			last_bond = this_bond;
+			this_bond = this_bond->next_bond;
+		}
+		last_bond->next_bond = bond;
+	} 
+
+	return 0;
+}
+
+/*
+static int __init bond_probe(struct net_device *dev)
+{
+	bond_init(dev);
+	return 0;
+}
+ */
+
+/*
+ * Convert string input module parms.  Accept either the
+ * number of the mode or its string name.
+ */
+static inline int
+bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl)
+{
+	int i;
+
+	for (i = 0; tbl[i].modename != NULL; i++) {
+		if ((isdigit(*mode_arg) &&
+		    tbl[i].mode == simple_strtol(mode_arg, NULL, 0)) ||
+		    (0 == strncmp(mode_arg, tbl[i].modename,
+				  strlen(tbl[i].modename)))) {
+			return tbl[i].mode;
+		}
+	}
+
+	return -1;
+}
+
+
+static int __init bonding_init(void)
+{
+	int no;
+	int err;
+
+	/* Find a name for this unit */
+	static struct net_device *dev_bond = NULL;
+
+	printk(KERN_INFO "%s", version);
+
+	/*
+	 * Convert string parameters.
+	 */
+	if (mode) {
+		bond_mode = bond_parse_parm(mode, bond_mode_tbl);
+		if (bond_mode == -1) {
+			printk(KERN_WARNING
+			       "bonding_init(): Invalid bonding mode \"%s\"\n",
+			       mode == NULL ? "NULL" : mode);
+			return -EINVAL;
+		}
+	}
+
+	if (multicast) {
+		multicast_mode = bond_parse_parm(multicast, bond_mc_tbl);
+		if (multicast_mode == -1) {
+			printk(KERN_WARNING 
+		       "bonding_init(): Invalid multicast mode \"%s\"\n",
+			       multicast == NULL ? "NULL" : multicast);
+			return -EINVAL;
+		}
+	}
+
+	if (lacp_rate) {
+		if (bond_mode != BOND_MODE_8023AD) {
+			printk(KERN_WARNING
+			       "lacp_rate param is irrelevant in mode %s\n",
+			       bond_mode_name());
+		} else {
+			lacp_fast = bond_parse_parm(lacp_rate, bond_lacp_tbl);
+			if (lacp_fast == -1) {
+				printk(KERN_WARNING
+			       	       "bonding_init(): Invalid lacp rate "
+				       "\"%s\"\n",
+				       lacp_rate == NULL ? "NULL" : lacp_rate);
+
+				return -EINVAL;
+			}
+		}
+	}
+
+	if (max_bonds < 1 || max_bonds > INT_MAX) {
+		printk(KERN_WARNING 
+		       "bonding_init(): max_bonds (%d) not in range %d-%d, "
+		       "so it was reset to BOND_DEFAULT_MAX_BONDS (%d)",
+		       max_bonds, 1, INT_MAX, BOND_DEFAULT_MAX_BONDS);
+		max_bonds = BOND_DEFAULT_MAX_BONDS;
+	}
+	dev_bond = dev_bonds = kmalloc(max_bonds*sizeof(struct net_device), 
+					GFP_KERNEL);
+	if (dev_bond == NULL) {
+		return -ENOMEM;
+	}
+	memset(dev_bonds, 0, max_bonds*sizeof(struct net_device));
+
+	if (miimon < 0) {
+		printk(KERN_WARNING 
+		       "bonding_init(): miimon module parameter (%d), "
+		       "not in range 0-%d, so it was reset to %d\n",
+		       miimon, INT_MAX, BOND_LINK_MON_INTERV);
+		miimon = BOND_LINK_MON_INTERV;
+	}
+
+	if (updelay < 0) {
+		printk(KERN_WARNING 
+		       "bonding_init(): updelay module parameter (%d), "
+		       "not in range 0-%d, so it was reset to 0\n",
+		       updelay, INT_MAX);
+		updelay = 0;
+	}
+
+	if (downdelay < 0) {
+		printk(KERN_WARNING 
+		       "bonding_init(): downdelay module parameter (%d), "
+		       "not in range 0-%d, so it was reset to 0\n",
+		       downdelay, INT_MAX);
+		downdelay = 0;
+	}
+
+	/* reset values for 802.3ad */
+	if (bond_mode == BOND_MODE_8023AD) {
+		if (arp_interval != 0) {
+			printk(KERN_WARNING "bonding_init(): ARP monitoring"
+			       "can't be used simultaneously with 802.3ad, "
+			       "disabling ARP monitoring\n");
+			arp_interval = 0;
+		}
+
+		if (miimon == 0) {
+			printk(KERN_ERR
+			       "bonding_init(): miimon must be specified, "
+			       "otherwise bonding will not detect link failure, "
+			       "speed and duplex which are essential "
+			       "for 802.3ad operation\n");
+			printk(KERN_ERR "Forcing miimon to 100msec\n");
+			miimon = 100;
+		}
+
+		if (multicast_mode != BOND_MULTICAST_ALL) {
+			printk(KERN_ERR
+			       "bonding_init(): Multicast mode must "
+			       "be set to ALL for 802.3ad\n");
+			printk(KERN_ERR "Forcing Multicast mode to ALL\n");
+			multicast_mode = BOND_MULTICAST_ALL;
+		}
+	}
+
+	/* reset values for TLB/ALB */
+	if ((bond_mode == BOND_MODE_TLB) ||
+	    (bond_mode == BOND_MODE_ALB)) {
+		if (miimon == 0) {
+			printk(KERN_ERR
+			       "bonding_init(): miimon must be specified, "
+			       "otherwise bonding will not detect link failure "
+			       "and link speed which are essential "
+			       "for TLB/ALB load balancing\n");
+			printk(KERN_ERR "Forcing miimon to 100msec\n");
+			miimon = 100;
+		}
+
+		if (multicast_mode != BOND_MULTICAST_ACTIVE) {
+			printk(KERN_ERR
+			       "bonding_init(): Multicast mode must "
+			       "be set to ACTIVE for TLB/ALB\n");
+			printk(KERN_ERR "Forcing Multicast mode to ACTIVE\n");
+			multicast_mode = BOND_MULTICAST_ACTIVE;
+		}
+	}
+
+	if (bond_mode == BOND_MODE_ALB) {
+		printk(KERN_INFO
+		       "In ALB mode you might experience client disconnections"
+		       " upon reconnection of a link if the bonding module"
+		       " updelay parameter (%d msec) is incompatible with the"
+		       " forwarding delay time of the switch\n", updelay);
+	}
+
+	if (miimon == 0) {
+		if ((updelay != 0) || (downdelay != 0)) {
+			/* just warn the user the up/down delay will have
+			 * no effect since miimon is zero...
+			 */
+			printk(KERN_WARNING 
+		               "bonding_init(): miimon module parameter not "
+			       "set and updelay (%d) or downdelay (%d) module "
+			       "parameter is set; updelay and downdelay have "
+			       "no effect unless miimon is set\n",
+		               updelay, downdelay);
+		}
+	} else {
+		/* don't allow arp monitoring */
+		if (arp_interval != 0) {
+			printk(KERN_WARNING 
+		               "bonding_init(): miimon (%d) and arp_interval "
+			       "(%d) can't be used simultaneously, "
+			       "disabling ARP monitoring\n",
+		               miimon, arp_interval);
+			arp_interval = 0;
+		}
+
+		if ((updelay % miimon) != 0) {
+			/* updelay will be rounded in bond_init() when it
+			 * is divided by miimon, we just inform user here
+			 */
+			printk(KERN_WARNING 
+		               "bonding_init(): updelay (%d) is not a multiple "
+			       "of miimon (%d), updelay rounded to %d ms\n",
+		               updelay, miimon, (updelay / miimon) * miimon);
+		}
+
+		if ((downdelay % miimon) != 0) {
+			/* downdelay will be rounded in bond_init() when it
+			 * is divided by miimon, we just inform user here
+			 */
+			printk(KERN_WARNING 
+		               "bonding_init(): downdelay (%d) is not a "
+			       "multiple of miimon (%d), downdelay rounded "
+			       "to %d ms\n",
+		               downdelay, miimon, 
+			       (downdelay / miimon) * miimon);
+		}
+	}
+
+	if (arp_interval < 0) {
+		printk(KERN_WARNING 
+		       "bonding_init(): arp_interval module parameter (%d), "
+		       "not in range 0-%d, so it was reset to %d\n",
+		       arp_interval, INT_MAX, BOND_LINK_ARP_INTERV);
+		arp_interval = BOND_LINK_ARP_INTERV;
+	}
+
+        for (arp_ip_count=0 ;
+             (arp_ip_count < MAX_ARP_IP_TARGETS) && arp_ip_target[arp_ip_count];
+              arp_ip_count++ ) {
+		/* not complete check, but should be good enough to
+		   catch mistakes */
+		if (!isdigit(arp_ip_target[arp_ip_count][0])) { 
+                        printk(KERN_WARNING
+                               "bonding_init(): bad arp_ip_target module "
+                               "parameter (%s), ARP monitoring will not be "
+                               "performed\n",
+                               arp_ip_target[arp_ip_count]);
+                        arp_interval = 0;
+		} else { 
+			u32 ip = in_aton(arp_ip_target[arp_ip_count]); 
+			*(u32 *)(arp_ip_target[arp_ip_count]) = ip;
+		}
+        }
+
+
+	if ( (arp_interval > 0) && (arp_ip_count==0)) {
+		/* don't allow arping if no arp_ip_target given... */
+		printk(KERN_WARNING 
+		       "bonding_init(): arp_interval module parameter "
+		       "(%d) specified without providing an arp_ip_target "
+		       "parameter, arp_interval was reset to 0\n",
+		       arp_interval);
+		arp_interval = 0;
+	}
+
+	if ((miimon == 0) && (arp_interval == 0)) {
+		/* miimon and arp_interval not set, we need one so things
+		 * work as expected, see bonding.txt for details
+		 */
+		printk(KERN_ERR 
+		       "bonding_init(): either miimon or "
+		       "arp_interval and arp_ip_target module parameters "
+		       "must be specified, otherwise bonding will not detect "
+		       "link failures! see bonding.txt for details.\n");
+	}
+
+	if ((primary != NULL) && (bond_mode != BOND_MODE_ACTIVEBACKUP) &&
+	    (bond_mode != BOND_MODE_TLB) &&
+	    (bond_mode != BOND_MODE_ALB)){
+		/* currently, using a primary only makes sense
+		 * in active backup, TLB or ALB modes
+		 */
+		printk(KERN_WARNING 
+		       "bonding_init(): %s primary device specified but has "
+		       "no effect in %s mode\n",
+		       primary, bond_mode_name());
+		primary = NULL;
+	}
+
+
+	for (no = 0; no < max_bonds; no++) {
+		dev_bond->init = bond_init;
+	
+		err = dev_alloc_name(dev_bond,"bond%d");
+		if (err < 0) {
+			kfree(dev_bonds);
+			return err;
+		}
+		SET_MODULE_OWNER(dev_bond);
+		if (register_netdev(dev_bond) != 0) {
+			kfree(dev_bonds);
+			return -EIO;
+		}	
+		dev_bond++;
+	}
+	return 0;
+}
+
+static void __exit bonding_exit(void)
+{
+	struct net_device *dev_bond = dev_bonds;
+	struct bonding *bond;
+	int no;
+
+	unregister_netdevice_notifier(&bond_netdev_notifier);
+		 
+	for (no = 0; no < max_bonds; no++) {
+
+#ifdef CONFIG_PROC_FS
+		bond = (struct bonding *) dev_bond->priv;
+		remove_proc_entry("info", bond->bond_proc_dir);
+		remove_proc_entry(dev_bond->name, proc_net);
+#endif
+		unregister_netdev(dev_bond);
+		kfree(bond->stats);
+		kfree(dev_bond->priv);
+		
+		dev_bond->priv = NULL;
+		dev_bond++;
+	}
+	kfree(dev_bonds);
+}
+
+module_init(bonding_init);
+module_exit(bonding_exit);
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION(DRV_DESCRIPTION ", v" DRV_VERSION);
+
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ *  tab-width: 8
+ * End:
+ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/bonding/bonding.h linux-2.4.22-pre2/drivers/net/bonding/bonding.h
--- linux-2.4.21/drivers/net/bonding/bonding.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/bonding/bonding.h	2003-06-26 21:43:18.000000000 +0000
@@ -0,0 +1,181 @@
+/*
+ * Bond several ethernet interfaces into a Cisco, running 'Etherchannel'.
+ *
+ * Portions are (c) Copyright 1995 Simon "Guru Aleph-Null" Janes
+ * NCM: Network and Communications Management, Inc.
+ *
+ * BUT, I'm the one who modified it for ethernet, so:
+ * (c) Copyright 1999, Thomas Davis, tadavis@lbl.gov
+ *
+ *	This software may be used and distributed according to the terms
+ *	of the GNU Public License, incorporated herein by reference.
+ * 
+ *
+ * 2003/03/18 - Amir Noam <amir.noam at intel dot com>,
+ *		Tsippy Mendelson <tsippy.mendelson at intel dot com> and
+ *		Shmulik Hen <shmulik.hen at intel dot com>
+ *	- Added support for IEEE 802.3ad Dynamic link aggregation mode.
+ *
+ * 2003/05/01 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
+ *		Amir Noam <amir.noam at intel dot com>
+ *	- Code beautification and style changes (mainly in comments).
+ *
+ * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
+ *	- Added support for Transmit load balancing mode.
+ */
+ 
+#ifndef _LINUX_BONDING_H
+#define _LINUX_BONDING_H
+
+#include <linux/timer.h>
+#include <linux/proc_fs.h>
+#include "bond_3ad.h"
+#include "bond_alb.h"
+
+#ifdef BONDING_DEBUG
+
+// use this like so: BOND_PRINT_DBG(("foo = %d, bar = %d", foo, bar));
+#define BOND_PRINT_DBG(X)                                     \
+do {                                                          \
+	printk(KERN_DEBUG "%s (%d)", __FUNCTION__, __LINE__); \
+	printk X;                                             \
+	printk("\n");                                         \
+} while(0)
+
+#else
+#define BOND_PRINT_DBG(X)
+#endif /* BONDING_DEBUG */
+
+#define IS_UP(dev)  ((((dev)->flags & (IFF_UP)) == (IFF_UP)) && \
+		     (netif_running(dev) && netif_carrier_ok(dev)))
+
+/* Checks whether the dev is ready for transmit. We do not check netif_running
+ * since a device can be stopped by the driver for short periods of time for
+ * maintainance. dev_queue_xmit() handles this by queing the packet until the
+ * the dev is running again. Keeping packets ordering requires sticking the
+ * same dev as much as possible
+ */
+#define SLAVE_IS_OK(slave) \
+		     ((((slave)->dev->flags & (IFF_UP)) == (IFF_UP)) && \
+		     netif_carrier_ok((slave)->dev) && \
+		     ((slave)->link == BOND_LINK_UP) && \
+		     ((slave)->state == BOND_STATE_ACTIVE))
+
+
+typedef struct slave {
+	struct slave *next;
+	struct slave *prev;
+	struct net_device *dev;
+	short  delay;
+	unsigned long jiffies;
+	char   link;    /* one of BOND_LINK_XXXX */
+	char   state;   /* one of BOND_STATE_XXXX */
+	unsigned short original_flags;
+	u32 link_failure_count;
+	u16    speed;
+	u8     duplex;
+	u8     perm_hwaddr[ETH_ALEN];
+	struct ad_slave_info ad_info; /* HUGE - better to dynamically alloc */
+	struct tlb_slave_info tlb_info;
+} slave_t;
+
+/*
+ * Here are the locking policies for the two bonding locks:
+ *
+ * 1) Get bond->lock when reading/writing slave list.
+ * 2) Get bond->ptrlock when reading/writing bond->current_slave.
+ *    (It is unnecessary when the write-lock is put with bond->lock.)
+ * 3) When we lock with bond->ptrlock, we must lock with bond->lock
+ *    beforehand.
+ */
+typedef struct bonding {
+	slave_t *next;
+	slave_t *prev;
+	slave_t *current_slave;
+	slave_t *primary_slave;
+	slave_t *current_arp_slave;
+	__s32 slave_cnt;
+	rwlock_t lock;
+	rwlock_t ptrlock;
+	struct timer_list mii_timer;
+	struct timer_list arp_timer;
+	struct net_device_stats *stats;
+#ifdef CONFIG_PROC_FS
+	struct proc_dir_entry *bond_proc_dir;
+	struct proc_dir_entry *bond_proc_info_file;
+#endif /* CONFIG_PROC_FS */
+	struct bonding *next_bond;
+	struct net_device *device;
+	struct dev_mc_list *mc_list;
+	unsigned short flags;
+	struct ad_bond_info ad_info;
+	struct alb_bond_info alb_info;
+} bonding_t;
+
+/* Forward declarations */
+void bond_set_slave_active_flags(slave_t *slave);
+void bond_set_slave_inactive_flags(slave_t *slave);
+
+/**
+ * These functions can be used for iterating the slave list
+ * (which is circular)
+ * Caller must hold bond lock for read
+ */
+extern inline struct slave*
+bond_get_first_slave(struct bonding *bond)
+{
+	/* if there are no slaves return NULL */
+	if (bond->next == (slave_t *)bond) {
+		return NULL;
+	}
+	return bond->next;
+}
+
+/**
+ * Caller must hold bond lock for read
+ */
+extern inline struct slave*
+bond_get_next_slave(struct bonding *bond, struct slave *slave)
+{
+	/* If we have reached the last slave return NULL */
+	if (slave->next == bond->next) {
+		return NULL;
+	}
+	return slave->next;
+}
+
+/**
+ * Returns NULL if the net_device does not belong to any of the bond's slaves
+ *
+ * Caller must hold bond lock for read
+ */
+extern inline struct slave*
+bond_get_slave_by_dev(struct bonding *bond, struct net_device *slave_dev)
+{
+	struct slave *our_slave = bond->next;
+
+	/* check if the list of slaves is empty */
+	if (our_slave == (slave_t *)bond) {
+		return NULL;
+	}
+
+	for (; our_slave; our_slave = bond_get_next_slave(bond, our_slave)) {
+		if (our_slave->dev == slave_dev) {
+			break;
+		}
+	}
+	return our_slave;
+}
+
+extern inline struct bonding*
+bond_get_bond_by_slave(struct slave *slave)
+{
+	if (!slave || !slave->dev->master) {
+		return NULL;
+	}
+
+	return (struct bonding *)(slave->dev->master->priv);
+}
+
+#endif /* _LINUX_BONDING_H */
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/bonding.c linux-2.4.22-pre2/drivers/net/bonding.c
--- linux-2.4.21/drivers/net/bonding.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/bonding.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,3302 +0,0 @@
-/*
- * originally based on the dummy device.
- *
- * Copyright 1999, Thomas Davis, tadavis@lbl.gov.  
- * Licensed under the GPL. Based on dummy.c, and eql.c devices.
- *
- * bonding.c: an Ethernet Bonding driver
- *
- * This is useful to talk to a Cisco EtherChannel compatible equipment:
- *	Cisco 5500
- *	Sun Trunking (Solaris)
- *	Alteon AceDirector Trunks
- *	Linux Bonding
- *	and probably many L2 switches ...
- *
- * How it works:
- *    ifconfig bond0 ipaddress netmask up
- *      will setup a network device, with an ip address.  No mac address 
- *	will be assigned at this time.  The hw mac address will come from 
- *	the first slave bonded to the channel.  All slaves will then use 
- *	this hw mac address.
- *
- *    ifconfig bond0 down
- *         will release all slaves, marking them as down.
- *
- *    ifenslave bond0 eth0
- *	will attach eth0 to bond0 as a slave.  eth0 hw mac address will either
- *	a: be used as initial mac address
- *	b: if a hw mac address already is there, eth0's hw mac address 
- *	   will then be set from bond0.
- *
- * v0.1 - first working version.
- * v0.2 - changed stats to be calculated by summing slaves stats.
- *
- * Changes:
- * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
- * - fix leaks on failure at bond_init
- *
- * 2000/09/30 - Willy Tarreau <willy at meta-x.org>
- *     - added trivial code to release a slave device.
- *     - fixed security bug (CAP_NET_ADMIN not checked)
- *     - implemented MII link monitoring to disable dead links :
- *       All MII capable slaves are checked every <miimon> milliseconds
- *       (100 ms seems good). This value can be changed by passing it to
- *       insmod. A value of zero disables the monitoring (default).
- *     - fixed an infinite loop in bond_xmit_roundrobin() when there's no
- *       good slave.
- *     - made the code hopefully SMP safe
- *
- * 2000/10/03 - Willy Tarreau <willy at meta-x.org>
- *     - optimized slave lists based on relevant suggestions from Thomas Davis
- *     - implemented active-backup method to obtain HA with two switches:
- *       stay as long as possible on the same active interface, while we
- *       also monitor the backup one (MII link status) because we want to know
- *       if we are able to switch at any time. ( pass "mode=1" to insmod )
- *     - lots of stress testings because we need it to be more robust than the
- *       wires ! :->
- *
- * 2000/10/09 - Willy Tarreau <willy at meta-x.org>
- *     - added up and down delays after link state change.
- *     - optimized the slaves chaining so that when we run forward, we never
- *       repass through the bond itself, but we can find it by searching
- *       backwards. Renders the deletion more difficult, but accelerates the
- *       scan.
- *     - smarter enslaving and releasing.
- *     - finer and more robust SMP locking
- *
- * 2000/10/17 - Willy Tarreau <willy at meta-x.org>
- *     - fixed two potential SMP race conditions
- *
- * 2000/10/18 - Willy Tarreau <willy at meta-x.org>
- *     - small fixes to the monitoring FSM in case of zero delays
- * 2000/11/01 - Willy Tarreau <willy at meta-x.org>
- *     - fixed first slave not automatically used in trunk mode.
- * 2000/11/10 : spelling of "EtherChannel" corrected.
- * 2000/11/13 : fixed a race condition in case of concurrent accesses to ioctl().
- * 2000/12/16 : fixed improper usage of rtnl_exlock_nowait().
- *
- * 2001/1/3 - Chad N. Tindel <ctindel at ieee dot org>
- *     - The bonding driver now simulates MII status monitoring, just like
- *       a normal network device.  It will show that the link is down iff
- *       every slave in the bond shows that their links are down.  If at least
- *       one slave is up, the bond's MII status will appear as up.
- *
- * 2001/2/7 - Chad N. Tindel <ctindel at ieee dot org>
- *     - Applications can now query the bond from user space to get
- *       information which may be useful.  They do this by calling
- *       the BOND_INFO_QUERY ioctl.  Once the app knows how many slaves
- *       are in the bond, it can call the BOND_SLAVE_INFO_QUERY ioctl to
- *       get slave specific information (# link failures, etc).  See
- *       <linux/if_bonding.h> for more details.  The structs of interest
- *       are ifbond and ifslave.
- *
- * 2001/4/5 - Chad N. Tindel <ctindel at ieee dot org>
- *     - Ported to 2.4 Kernel
- * 
- * 2001/5/2 - Jeffrey E. Mast <jeff at mastfamily dot com>
- *     - When a device is detached from a bond, the slave device is no longer
- *       left thinking that is has a master.
- *
- * 2001/5/16 - Jeffrey E. Mast <jeff at mastfamily dot com>
- *     - memset did not appropriately initialized the bond rw_locks. Used 
- *       rwlock_init to initialize to unlocked state to prevent deadlock when 
- *       first attempting a lock
- *     - Called SET_MODULE_OWNER for bond device
- *
- * 2001/5/17 - Tim Anderson <tsa at mvista.com>
- *     - 2 paths for releasing for slave release; 1 through ioctl
- *       and 2) through close. Both paths need to release the same way.
- *     - the free slave in bond release is changing slave status before
- *       the free. The netdev_set_master() is intended to change slave state
- *       so it should not be done as part of the release process.
- *     - Simple rule for slave state at release: only the active in A/B and
- *       only one in the trunked case.
- *
- * 2001/6/01 - Tim Anderson <tsa at mvista.com>
- *     - Now call dev_close when releasing a slave so it doesn't screw up
- *       out routing table.
- *
- * 2001/6/01 - Chad N. Tindel <ctindel at ieee dot org>
- *     - Added /proc support for getting bond and slave information.
- *       Information is in /proc/net/<bond device>/info. 
- *     - Changed the locking when calling bond_close to prevent deadlock.
- *
- * 2001/8/05 - Janice Girouard <girouard at us.ibm.com>
- *     - correct problem where refcnt of slave is not incremented in bond_ioctl
- *       so the system hangs when halting.
- *     - correct locking problem when unable to malloc in bond_enslave.
- *     - adding bond_xmit_xor logic.
- *     - adding multiple bond device support.
- *
- * 2001/8/13 - Erik Habbinga <erik_habbinga at hp dot com>
- *     - correct locking problem with rtnl_exlock_nowait
- *
- * 2001/8/23 - Janice Girouard <girouard at us.ibm.com>
- *     - bzero initial dev_bonds, to correct oops
- *     - convert SIOCDEVPRIVATE to new MII ioctl calls
- *
- * 2001/9/13 - Takao Indoh <indou dot takao at jp dot fujitsu dot com>
- *     - Add the BOND_CHANGE_ACTIVE ioctl implementation
- *
- * 2001/9/14 - Mark Huth <mhuth at mvista dot com>
- *     - Change MII_LINK_READY to not check for end of auto-negotiation,
- *       but only for an up link.
- *
- * 2001/9/20 - Chad N. Tindel <ctindel at ieee dot org>
- *     - Add the device field to bonding_t.  Previously the net_device 
- *       corresponding to a bond wasn't available from the bonding_t 
- *       structure.
- *
- * 2001/9/25 - Janice Girouard <girouard at us.ibm.com>
- *     - add arp_monitor for active backup mode
- *
- * 2001/10/23 - Takao Indoh <indou dot takao at jp dot fujitsu dot com>
- *     - Various memory leak fixes
- *
- * 2001/11/5 - Mark Huth <mark dot huth at mvista dot com>
- *     - Don't take rtnl lock in bond_mii_monitor as it deadlocks under 
- *       certain hotswap conditions.  
- *       Note:  this same change may be required in bond_arp_monitor ???
- *     - Remove possibility of calling bond_sethwaddr with NULL slave_dev ptr 
- *     - Handle hot swap ethernet interface deregistration events to remove
- *       kernel oops following hot swap of enslaved interface
- *
- * 2002/1/2 - Chad N. Tindel <ctindel at ieee dot org>
- *     - Restore original slave flags at release time.
- *
- * 2002/02/18 - Erik Habbinga <erik_habbinga at hp dot com>
- *     - bond_release(): calling kfree on our_slave after call to
- *       bond_restore_slave_flags, not before
- *     - bond_enslave(): saving slave flags into original_flags before
- *       call to netdev_set_master, so the IFF_SLAVE flag doesn't end
- *       up in original_flags
- *
- * 2002/04/05 - Mark Smith <mark.smith at comdev dot cc> and
- *              Steve Mead <steve.mead at comdev dot cc>
- *     - Port Gleb Natapov's multicast support patchs from 2.4.12
- *       to 2.4.18 adding support for multicast.
- *
- * 2002/06/10 - Tony Cureington <tony.cureington * hp_com>
- *     - corrected uninitialized pointer (ifr.ifr_data) in bond_check_dev_link;
- *       actually changed function to use MIIPHY, then MIIREG, and finally
- *       ETHTOOL to determine the link status
- *     - fixed bad ifr_data pointer assignments in bond_ioctl
- *     - corrected mode 1 being reported as active-backup in bond_get_info;
- *       also added text to distinguish type of load balancing (rr or xor)
- *     - change arp_ip_target module param from "1-12s" (array of 12 ptrs)
- *       to "s" (a single ptr)
- *
- * 2002/08/30 - Jay Vosburgh <fubar at us dot ibm dot com>
- *     - Removed acquisition of xmit_lock in set_multicast_list; caused
- *       deadlock on SMP (lock is held by caller).
- *     - Revamped SIOCGMIIPHY, SIOCGMIIREG portion of bond_check_dev_link().
- *
- * 2002/09/18 - Jay Vosburgh <fubar at us dot ibm dot com>
- *     - Fixed up bond_check_dev_link() (and callers): removed some magic
- *	 numbers, banished local MII_ defines, wrapped ioctl calls to
- *	 prevent EFAULT errors
- *
- * 2002/9/30 - Jay Vosburgh <fubar at us dot ibm dot com>
- *     - make sure the ip target matches the arp_target before saving the
- *	 hw address.
- *
- * 2002/9/30 - Dan Eisner <eisner at 2robots dot com>
- *     - make sure my_ip is set before taking down the link, since
- *	 not all switches respond if the source ip is not set.
- *
- * 2002/10/8 - Janice Girouard <girouard at us dot ibm dot com>
- *     - read in the local ip address when enslaving a device
- *     - add primary support
- *     - make sure 2*arp_interval has passed when a new device
- *       is brought on-line before taking it down.
- *
- * 2002/09/11 - Philippe De Muyter <phdm at macqel dot be>
- *     - Added bond_xmit_broadcast logic.
- *     - Added bond_mode() support function.
- *
- * 2002/10/26 - Laurent Deniel <laurent.deniel at free.fr>
- *     - allow to register multicast addresses only on active slave
- *       (useful in active-backup mode)
- *     - add multicast module parameter
- *     - fix deletion of multicast groups after unloading module
- *
- * 2002/11/06 - Kameshwara Rayaprolu <kameshwara.rao * wipro_com>
- *     - Changes to prevent panic from closing the device twice; if we close 
- *       the device in bond_release, we must set the original_flags to down 
- *       so it won't be closed again by the network layer.
- *
- * 2002/11/07 - Tony Cureington <tony.cureington * hp_com>
- *     - Fix arp_target_hw_addr memory leak
- *     - Created activebackup_arp_monitor function to handle arp monitoring 
- *       in active backup mode - the bond_arp_monitor had several problems... 
- *       such as allowing slaves to tx arps sequentially without any delay 
- *       for a response
- *     - Renamed bond_arp_monitor to loadbalance_arp_monitor and re-wrote
- *       this function to just handle arp monitoring in load-balancing mode;
- *       it is a lot more compact now
- *     - Changes to ensure one and only one slave transmits in active-backup 
- *       mode
- *     - Robustesize parameters; warn users about bad combinations of 
- *       parameters; also if miimon is specified and a network driver does 
- *       not support MII or ETHTOOL, inform the user of this
- *     - Changes to support link_failure_count when in arp monitoring mode
- *     - Fix up/down delay reported in /proc
- *     - Added version; log version; make version available from "modinfo -d"
- *     - Fixed problem in bond_check_dev_link - if the first IOCTL (SIOCGMIIPH)
- *	 failed, the ETHTOOL ioctl never got a chance
- *
- * 2002/11/16 - Laurent Deniel <laurent.deniel at free.fr>
- *     - fix multicast handling in activebackup_arp_monitor
- *     - remove one unnecessary and confusing current_slave == slave test 
- *	 in activebackup_arp_monitor
- *
- *  2002/11/17 - Laurent Deniel <laurent.deniel at free.fr>
- *     - fix bond_slave_info_query when slave_id = num_slaves
- *
- *  2002/11/19 - Janice Girouard <girouard at us dot ibm dot com>
- *     - correct ifr_data reference.  Update ifr_data reference
- *       to mii_ioctl_data struct values to avoid confusion.
- *
- *  2002/11/22 - Bert Barbe <bert.barbe at oracle dot com>
- *      - Add support for multiple arp_ip_target
- *
- *  2002/12/13 - Jay Vosburgh <fubar at us dot ibm dot com>
- *	- Changed to allow text strings for mode and multicast, e.g.,
- *	  insmod bonding mode=active-backup.  The numbers still work.
- *	  One change: an invalid choice will cause module load failure,
- *	  rather than the previous behavior of just picking one.
- *	- Minor cleanups; got rid of dup ctype stuff, atoi function
- * 
- * 2003/02/07 - Jay Vosburgh <fubar at us dot ibm dot com>
- *	- Added use_carrier module parameter that causes miimon to
- *	  use netif_carrier_ok() test instead of MII/ETHTOOL ioctls.
- *	- Minor cleanups; consolidated ioctl calls to one function.
- *
- * 2003/02/07 - Tony Cureington <tony.cureington * hp_com>
- *	- Fix bond_mii_monitor() logic error that could result in
- *	  bonding round-robin mode ignoring links after failover/recovery
- *
- * 2003/03/17 - Jay Vosburgh <fubar at us dot ibm dot com>
- *	- kmalloc fix (GPF_KERNEL to GPF_ATOMIC) reported by
- *	  Shmulik dot Hen at intel.com.
- *	- Based on discussion on mailing list, changed use of
- *	  update_slave_cnt(), created wrapper functions for adding/removing
- *	  slaves, changed bond_xmit_xor() to check slave_cnt instead of
- *	  checking slave and slave->dev (which only worked by accident).
- *	- Misc code cleanup: get arp_send() prototype from header file,
- *	  add max_bonds to bonding.txt.
- *
- * 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
- *		Shmulik Hen <shmulik.hen at intel dot com>
- *	- Make sure only bond_attach_slave() and bond_detach_slave() can
- *	  manipulate the slave list, including slave_cnt, even when in
- *	  bond_release_all().
- *	- Fixed hang in bond_release() while traffic is running.
- *	  netdev_set_master() must not be called from within the bond lock.
- *
- * 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
- *		Shmulik Hen <shmulik.hen at intel dot com>
- *	- Fixed hang in bond_enslave(): netdev_set_master() must not be
- *	  called from within the bond lock while traffic is running.
- */
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/sched.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/ip.h>
-#include <linux/slab.h>
-#include <linux/string.h>
-#include <linux/init.h>
-#include <linux/timer.h>
-#include <linux/socket.h>
-#include <linux/ctype.h>
-#include <asm/system.h>
-#include <asm/bitops.h>
-#include <asm/io.h>
-#include <asm/dma.h>
-#include <asm/uaccess.h>
-#include <linux/errno.h>
-
-#include <linux/netdevice.h>
-#include <linux/inetdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/skbuff.h>
-#include <net/sock.h>
-#include <linux/rtnetlink.h>
-
-#include <linux/if_bonding.h>
-#include <linux/smp.h>
-#include <linux/if_ether.h>
-#include <net/arp.h>
-#include <linux/mii.h>
-#include <linux/ethtool.h>
-
-#define DRV_VERSION		"2.4.20-20030320"
-#define DRV_RELDATE		"March 20, 2003"
-#define DRV_NAME		"bonding"
-#define DRV_DESCRIPTION		"Ethernet Channel Bonding Driver"
-
-static const char *version =
-DRV_NAME ".c:v" DRV_VERSION " (" DRV_RELDATE ")\n";
-
-/* monitor all links that often (in milliseconds). <=0 disables monitoring */
-#ifndef BOND_LINK_MON_INTERV
-#define BOND_LINK_MON_INTERV	0
-#endif
-
-#ifndef BOND_LINK_ARP_INTERV
-#define BOND_LINK_ARP_INTERV	0
-#endif
-
-#ifndef MAX_ARP_IP_TARGETS
-#define MAX_ARP_IP_TARGETS 16
-#endif
-
-static int arp_interval = BOND_LINK_ARP_INTERV;
-static char *arp_ip_target[MAX_ARP_IP_TARGETS] = { NULL, };
-static unsigned long arp_target[MAX_ARP_IP_TARGETS] = { 0, } ;
-static int arp_ip_count = 0;
-static u32 my_ip = 0;
-char *arp_target_hw_addr = NULL;
-
-static char *primary= NULL;
-
-static int max_bonds	= BOND_DEFAULT_MAX_BONDS;
-static int miimon	= BOND_LINK_MON_INTERV;
-static int use_carrier	= 1;
-static int bond_mode	= BOND_MODE_ROUNDROBIN;
-static int updelay	= 0;
-static int downdelay	= 0;
-
-static char *mode	= NULL;
-
-static struct bond_parm_tbl bond_mode_tbl[] = {
-{	"balance-rr",		BOND_MODE_ROUNDROBIN},
-{	"active-backup",	BOND_MODE_ACTIVEBACKUP},
-{	"balance-xor",		BOND_MODE_XOR},
-{	"broadcast",		BOND_MODE_BROADCAST},
-{	NULL,			-1},
-};
-
-static int multicast_mode	= BOND_MULTICAST_ALL;
-static char *multicast		= NULL;
-
-static struct bond_parm_tbl bond_mc_tbl[] = {
-{	"disabled",		BOND_MULTICAST_DISABLED},
-{	"active",		BOND_MULTICAST_ACTIVE},
-{	"all",			BOND_MULTICAST_ALL},
-{	NULL,			-1},
-};
-
-static int first_pass	= 1;
-static struct bonding *these_bonds =  NULL;
-static struct net_device *dev_bonds = NULL;
-
-MODULE_PARM(max_bonds, "i");
-MODULE_PARM_DESC(max_bonds, "Max number of bonded devices");
-MODULE_PARM(miimon, "i");
-MODULE_PARM_DESC(miimon, "Link check interval in milliseconds");
-MODULE_PARM(use_carrier, "i");
-MODULE_PARM_DESC(use_carrier, "Use netif_carrier_ok (vs MII ioctls) in miimon; 09 for off, 1 for on (default)");
-MODULE_PARM(mode, "s");
-MODULE_PARM_DESC(mode, "Mode of operation : 0 for round robin, 1 for active-backup, 2 for xor");
-MODULE_PARM(arp_interval, "i");
-MODULE_PARM_DESC(arp_interval, "arp interval in milliseconds");
-MODULE_PARM(arp_ip_target, "1-" __MODULE_STRING(MAX_ARP_IP_TARGETS) "s");
-MODULE_PARM_DESC(arp_ip_target, "arp targets in n.n.n.n form");
-MODULE_PARM(updelay, "i");
-MODULE_PARM_DESC(updelay, "Delay before considering link up, in milliseconds");
-MODULE_PARM(downdelay, "i");
-MODULE_PARM_DESC(downdelay, "Delay before considering link down, in milliseconds");
-MODULE_PARM(primary, "s");
-MODULE_PARM_DESC(primary, "Primary network device to use");
-MODULE_PARM(multicast, "s");
-MODULE_PARM_DESC(multicast, "Mode for multicast support : 0 for none, 1 for active slave, 2 for all slaves (default)");
-
-static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *dev);
-static int bond_xmit_xor(struct sk_buff *skb, struct net_device *dev);
-static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *dev);
-static struct net_device_stats *bond_get_stats(struct net_device *dev);
-static void bond_mii_monitor(struct net_device *dev);
-static void loadbalance_arp_monitor(struct net_device *dev);
-static void activebackup_arp_monitor(struct net_device *dev);
-static int bond_event(struct notifier_block *this, unsigned long event, void *ptr);
-static void bond_restore_slave_flags(slave_t *slave);
-static void bond_mc_list_destroy(struct bonding *bond);
-static void bond_mc_add(bonding_t *bond, void *addr, int alen);
-static void bond_mc_delete(bonding_t *bond, void *addr, int alen);
-static int bond_mc_list_copy (struct dev_mc_list *src, struct bonding *dst, int gpf_flag);
-static inline int dmi_same(struct dev_mc_list *dmi1, struct dev_mc_list *dmi2);
-static void bond_set_promiscuity(bonding_t *bond, int inc);
-static void bond_set_allmulti(bonding_t *bond, int inc);
-static struct dev_mc_list* bond_mc_list_find_dmi(struct dev_mc_list *dmi, struct dev_mc_list *mc_list);
-static void bond_mc_update(bonding_t *bond, slave_t *new, slave_t *old);
-static void bond_set_slave_inactive_flags(slave_t *slave);
-static void bond_set_slave_active_flags(slave_t *slave);
-static int bond_enslave(struct net_device *master, struct net_device *slave);
-static int bond_release(struct net_device *master, struct net_device *slave);
-static int bond_release_all(struct net_device *master);
-static int bond_sethwaddr(struct net_device *master, struct net_device *slave);
-
-/*
- * bond_get_info is the interface into the /proc filesystem.  This is
- * a different interface than the BOND_INFO_QUERY ioctl.  That is done
- * through the generic networking ioctl interface, and bond_info_query
- * is the internal function which provides that information.
- */
-static int bond_get_info(char *buf, char **start, off_t offset, int length);
-
-/* #define BONDING_DEBUG 1 */
-
-/* several macros */
-
-#define IS_UP(dev)	((((dev)->flags & (IFF_UP)) == (IFF_UP)) && \
-			(netif_running(dev) && netif_carrier_ok(dev)))
-  
-static void arp_send_all(slave_t *slave)
-{	
-	int i; 
-
-	for (i = 0; (i<MAX_ARP_IP_TARGETS) && arp_target[i]; i++) { 
-		arp_send(ARPOP_REQUEST, ETH_P_ARP, arp_target[i], slave->dev, 
-			 my_ip, arp_target_hw_addr, slave->dev->dev_addr,
-			 arp_target_hw_addr); 
-	} 
-}
- 
-
-static const char *
-bond_mode_name(void)
-{
-	switch (bond_mode) {
-	case BOND_MODE_ROUNDROBIN :
-		return "load balancing (round-robin)";
-	case BOND_MODE_ACTIVEBACKUP :
-		return "fault-tolerance (active-backup)";
-	case BOND_MODE_XOR :
-		return "load balancing (xor)";
-	case BOND_MODE_BROADCAST :
-		return "fault-tolerance (broadcast)";
-	default :
-		return "unknown";
-	}
-}
-
-static const char *
-multicast_mode_name(void)
-{
-	switch(multicast_mode) {
-	case BOND_MULTICAST_DISABLED :
-		return "disabled";
-	case BOND_MULTICAST_ACTIVE :
-		return "active slave only";
-	case BOND_MULTICAST_ALL :
-		return "all slaves";
-	default :
-		return "unknown";
-	}
-}
-
-static void bond_restore_slave_flags(slave_t *slave)
-{
-	slave->dev->flags = slave->original_flags;
-}
-
-static void bond_set_slave_inactive_flags(slave_t *slave)
-{
-	slave->state = BOND_STATE_BACKUP;
-	slave->dev->flags |= IFF_NOARP;
-}
-
-static void bond_set_slave_active_flags(slave_t *slave)
-{
-	slave->state = BOND_STATE_ACTIVE;
-	slave->dev->flags &= ~IFF_NOARP;
-}
-
-/*
- * This function counts and verifies the the number of attached
- * slaves, checking the count against the expected value (given that incr
- * is either 1 or -1, for add or removal of a slave).  Only
- * bond_xmit_xor() uses the slave_cnt value, but this is still a good
- * consistency check.
- */
-static inline void
-update_slave_cnt(bonding_t *bond, int incr)
-{
-	slave_t *slave = NULL;
-	int expect = bond->slave_cnt + incr;
-
-	bond->slave_cnt = 0;
-	for (slave = bond->prev; slave != (slave_t*)bond;
-	     slave = slave->prev) {
-		bond->slave_cnt++;
-	}
-
-	if (expect != bond->slave_cnt)
-		BUG();
-}
-
-/* 
- * This function detaches the slave <slave> from the list <bond>.
- * WARNING: no check is made to verify if the slave effectively
- * belongs to <bond>. It returns <slave> in case it's needed.
- * Nothing is freed on return, structures are just unchained.
- * If the bond->current_slave pointer was pointing to <slave>,
- * it's replaced with slave->next, or <bond> if not applicable.
- *
- * bond->lock held by caller.
- */
-static slave_t *
-bond_detach_slave(bonding_t *bond, slave_t *slave)
-{
-	if ((bond == NULL) || (slave == NULL) ||
-	   ((void *)bond == (void *)slave)) {
-		printk(KERN_ERR
-			"bond_detach_slave(): trying to detach "
-			"slave %p from bond %p\n", bond, slave);
-		return slave;
-	}
-
-	if (bond->next == slave) {  /* is the slave at the head ? */
-		if (bond->prev == slave) {  /* is the slave alone ? */
-			write_lock(&bond->ptrlock);
-			bond->current_slave = NULL; /* no slave anymore */
-			write_unlock(&bond->ptrlock);
-			bond->prev = bond->next = (slave_t *)bond;
-		} else { /* not alone */
-			bond->next        = slave->next;
-			slave->next->prev = (slave_t *)bond;
-			bond->prev->next  = slave->next;
-
-			write_lock(&bond->ptrlock);
-			if (bond->current_slave == slave) {
-				bond->current_slave = slave->next;
-			}
-			write_unlock(&bond->ptrlock);
-		}
-	} else {
-		slave->prev->next = slave->next;
-		if (bond->prev == slave) {  /* is this slave the last one ? */
-			bond->prev = slave->prev;
-		} else {
-			slave->next->prev = slave->prev;
-		}
-
-		write_lock(&bond->ptrlock);
-		if (bond->current_slave == slave) {
-			bond->current_slave = slave->next;
-		}
-		write_unlock(&bond->ptrlock);
-	}
-
-	update_slave_cnt(bond, -1);
-
-	return slave;
-}
-
-static void
-bond_attach_slave(struct bonding *bond, struct slave *new_slave)
-{
-	/* 
-	 * queue to the end of the slaves list, make the first element its
-	 * successor, the last one its predecessor, and make it the bond's
-	 * predecessor. 
-	 *
-	 * Just to clarify, so future bonding driver hackers don't go through
-	 * the same confusion stage I did trying to figure this out, the
-	 * slaves are stored in a double linked circular list, sortof.
-	 * In the ->next direction, the last slave points to the first slave,
-	 * bypassing bond; only the slaves are in the ->next direction.
-	 * In the ->prev direction, however, the first slave points to bond
-	 * and bond points to the last slave.
-	 *
-	 * It looks like a circle with a little bubble hanging off one side
-	 * in the ->prev direction only.
-	 *
-	 * When going through the list once, its best to start at bond->prev
-	 * and go in the ->prev direction, testing for bond.  Doing this
-	 * in the ->next direction doesn't work.  Trust me, I know this now.
-	 * :)  -mts 2002.03.14
-	 */
-	new_slave->prev       = bond->prev;
-	new_slave->prev->next = new_slave;
-	bond->prev            = new_slave;
-	new_slave->next       = bond->next;
-
-	update_slave_cnt(bond, 1);
-}
-
-
-/*
- * Less bad way to call ioctl from within the kernel; this needs to be
- * done some other way to get the call out of interrupt context.
- * Needs "ioctl" variable to be supplied by calling context.
- */
-#define IOCTL(dev, arg, cmd) ({		\
-	int ret;			\
-	mm_segment_t fs = get_fs();	\
-	set_fs(get_ds());		\
-	ret = ioctl(dev, arg, cmd);	\
-	set_fs(fs);			\
-	ret; })
-
-/* 
- * if <dev> supports MII link status reporting, check its link status.
- *
- * We either do MII/ETHTOOL ioctls, or check netif_carrier_ok(),
- * depening upon the setting of the use_carrier parameter.
- *
- * Return either BMSR_LSTATUS, meaning that the link is up (or we
- * can't tell and just pretend it is), or 0, meaning that the link is
- * down.
- *
- * If reporting is non-zero, instead of faking link up, return -1 if
- * both ETHTOOL and MII ioctls fail (meaning the device does not
- * support them).  If use_carrier is set, return whatever it says.
- * It'd be nice if there was a good way to tell if a driver supports
- * netif_carrier, but there really isn't.
- */
-static int
-bond_check_dev_link(struct net_device *dev, int reporting)
-{
-	static int (* ioctl)(struct net_device *, struct ifreq *, int);
-	struct ifreq ifr;
-	struct mii_ioctl_data *mii;
-	struct ethtool_value etool;
-
-	if (use_carrier) {
-		return netif_carrier_ok(dev) ? BMSR_LSTATUS : 0;
-	}
-
-	ioctl = dev->do_ioctl;
-	if (ioctl) {
-		/* TODO: set pointer to correct ioctl on a per team member */
-		/*       bases to make this more efficient. that is, once  */
-		/*       we determine the correct ioctl, we will always    */
-		/*       call it and not the others for that team          */
-		/*       member.                                           */
-
-		/*
-		 * We cannot assume that SIOCGMIIPHY will also read a
-		 * register; not all network drivers (e.g., e100)
-		 * support that.
-		 */
-
-		/* Yes, the mii is overlaid on the ifreq.ifr_ifru */
-		mii = (struct mii_ioctl_data *)&ifr.ifr_data;
-		if (IOCTL(dev, &ifr, SIOCGMIIPHY) == 0) {
-			mii->reg_num = MII_BMSR;
-			if (IOCTL(dev, &ifr, SIOCGMIIREG) == 0) {
-				return mii->val_out & BMSR_LSTATUS;
-			}
-		}
-
-		/* try SIOCETHTOOL ioctl, some drivers cache ETHTOOL_GLINK */
-		/* for a period of time so we attempt to get link status   */
-		/* from it last if the above MII ioctls fail...            */
-	        etool.cmd = ETHTOOL_GLINK;
-	        ifr.ifr_data = (char*)&etool;
-		if (IOCTL(dev, &ifr, SIOCETHTOOL) == 0) {
-			if (etool.data == 1) {
-				return BMSR_LSTATUS;
-			} else { 
-#ifdef BONDING_DEBUG
-				printk(KERN_INFO 
-					":: SIOCETHTOOL shows link down \n");
-#endif
-				return 0;
-			} 
-		}
-
-	}
- 
-	/*
-	 * If reporting, report that either there's no dev->do_ioctl,
-	 * or both SIOCGMIIREG and SIOCETHTOOL failed (meaning that we
-	 * cannot report link status).  If not reporting, pretend
-	 * we're ok.
-	 */
-	return reporting ? -1 : BMSR_LSTATUS;
-}
-
-static u16 bond_check_mii_link(bonding_t *bond)
-{
-	int has_active_interface = 0;
-	unsigned long flags;
-
-	read_lock_irqsave(&bond->lock, flags);
-	read_lock(&bond->ptrlock);
-	has_active_interface = (bond->current_slave != NULL);
-	read_unlock(&bond->ptrlock);
-	read_unlock_irqrestore(&bond->lock, flags);
-
-	return (has_active_interface ? BMSR_LSTATUS : 0);
-}
-
-static int bond_open(struct net_device *dev)
-{
-	struct timer_list *timer = &((struct bonding *)(dev->priv))->mii_timer;
-	struct timer_list *arp_timer = &((struct bonding *)(dev->priv))->arp_timer;
-	MOD_INC_USE_COUNT;
-
-	if (miimon > 0) {  /* link check interval, in milliseconds. */
-		init_timer(timer);
-		timer->expires  = jiffies + (miimon * HZ / 1000);
-		timer->data     = (unsigned long)dev;
-		timer->function = (void *)&bond_mii_monitor;
-		add_timer(timer);
-	}
-
-	if (arp_interval> 0) {  /* arp interval, in milliseconds. */
-		init_timer(arp_timer);
-		arp_timer->expires  = jiffies + (arp_interval * HZ / 1000);
-		arp_timer->data     = (unsigned long)dev;
-		if (bond_mode == BOND_MODE_ACTIVEBACKUP) {
-			arp_timer->function = (void *)&activebackup_arp_monitor;
-		} else {
-			arp_timer->function = (void *)&loadbalance_arp_monitor;
-		}
-		add_timer(arp_timer);
-	}
-	return 0;
-}
-
-static int bond_close(struct net_device *master)
-{
-	bonding_t *bond = (struct bonding *) master->priv;
-	unsigned long flags;
-
-	write_lock_irqsave(&bond->lock, flags);
-
-	if (miimon > 0) {  /* link check interval, in milliseconds. */
-		del_timer(&bond->mii_timer);
-	}
-	if (arp_interval> 0) {  /* arp interval, in milliseconds. */
-		del_timer(&bond->arp_timer);
-                if (arp_target_hw_addr != NULL) {
-			kfree(arp_target_hw_addr); 
-			arp_target_hw_addr = NULL;
-		}
-	}
-
-	/* Release the bonded slaves */
-	bond_release_all(master);
-	bond_mc_list_destroy (bond);
-
-	write_unlock_irqrestore(&bond->lock, flags);
-
-	MOD_DEC_USE_COUNT;
-	return 0;
-}
-
-/* 
- * flush all members of flush->mc_list from device dev->mc_list
- */
-static void bond_mc_list_flush(struct net_device *dev, struct net_device *flush)
-{ 
-	struct dev_mc_list *dmi; 
- 
-	for (dmi = flush->mc_list; dmi != NULL; dmi = dmi->next) 
-		dev_mc_delete(dev, dmi->dmi_addr, dmi->dmi_addrlen, 0);
-}
-
-/*
- * Totally destroys the mc_list in bond
- */
-static void bond_mc_list_destroy(struct bonding *bond)
-{
-	struct dev_mc_list *dmi;
-
-	dmi = bond->mc_list; 
-	while (dmi) { 
-		bond->mc_list = dmi->next; 
-		kfree(dmi); 
-		dmi = bond->mc_list; 
-	}
-}
-
-/*
- * Add a Multicast address to every slave in the bonding group
- */
-static void bond_mc_add(bonding_t *bond, void *addr, int alen)
-{ 
-	slave_t *slave;
-	switch (multicast_mode) {
-	case BOND_MULTICAST_ACTIVE :
-		/* write lock already acquired */
-		if (bond->current_slave != NULL)
-			dev_mc_add(bond->current_slave->dev, addr, alen, 0);
-		break;
-	case BOND_MULTICAST_ALL :
-		for (slave = bond->prev; slave != (slave_t*)bond; slave = slave->prev)
-			dev_mc_add(slave->dev, addr, alen, 0);
-		break;
-	case BOND_MULTICAST_DISABLED :
-		break;
-	}
-} 
-
-/*
- * Remove a multicast address from every slave in the bonding group
- */
-static void bond_mc_delete(bonding_t *bond, void *addr, int alen)
-{ 
-	slave_t *slave; 
-	switch (multicast_mode) {
-	case BOND_MULTICAST_ACTIVE :
-		/* write lock already acquired */
-		if (bond->current_slave != NULL)
-			dev_mc_delete(bond->current_slave->dev, addr, alen, 0);
-		break;
-	case BOND_MULTICAST_ALL :
-		for (slave = bond->prev; slave != (slave_t*)bond; slave = slave->prev)
-			dev_mc_delete(slave->dev, addr, alen, 0);
-		break;
-	case BOND_MULTICAST_DISABLED :
-		break;
-	}
-} 
-
-/*
- * Copy all the Multicast addresses from src to the bonding device dst
- */
-static int bond_mc_list_copy (struct dev_mc_list *src, struct bonding *dst,
- int gpf_flag)
-{
-	struct dev_mc_list *dmi, *new_dmi;
-
-   	for (dmi = src; dmi != NULL; dmi = dmi->next) { 
-		new_dmi = kmalloc(sizeof(struct dev_mc_list), gpf_flag);
-
-		if (new_dmi == NULL) {
-			return -ENOMEM; 
-		}
-
-		new_dmi->next = dst->mc_list; 
-		dst->mc_list = new_dmi;
-
-		new_dmi->dmi_addrlen = dmi->dmi_addrlen; 
-		memcpy(new_dmi->dmi_addr, dmi->dmi_addr, dmi->dmi_addrlen); 
-		new_dmi->dmi_users = dmi->dmi_users;
-		new_dmi->dmi_gusers = dmi->dmi_gusers; 
-	} 
-	return 0;
-}
-
-/*
- * Returns 0 if dmi1 and dmi2 are the same, non-0 otherwise
- */
-static inline int dmi_same(struct dev_mc_list *dmi1, struct dev_mc_list *dmi2)
-{ 
-	return memcmp(dmi1->dmi_addr, dmi2->dmi_addr, dmi1->dmi_addrlen) == 0 &&
-	 dmi1->dmi_addrlen == dmi2->dmi_addrlen;
-} 
-
-/*
- * Push the promiscuity flag down to all slaves
- */
-static void bond_set_promiscuity(bonding_t *bond, int inc)
-{ 
-	slave_t *slave; 
-	switch (multicast_mode) {
-	case BOND_MULTICAST_ACTIVE :
-		/* write lock already acquired */
-		if (bond->current_slave != NULL)
-			dev_set_promiscuity(bond->current_slave->dev, inc);
-		break;
-	case BOND_MULTICAST_ALL :
-		for (slave = bond->prev; slave != (slave_t*)bond; slave = slave->prev)
-			dev_set_promiscuity(slave->dev, inc);
-		break;
-	case BOND_MULTICAST_DISABLED :
-		break;
-	}
-} 
-
-/*
- * Push the allmulti flag down to all slaves
- */
-static void bond_set_allmulti(bonding_t *bond, int inc)
-{ 
-	slave_t *slave; 
-	switch (multicast_mode) {
-	case BOND_MULTICAST_ACTIVE : 
-		/* write lock already acquired */
-		if (bond->current_slave != NULL)
-			dev_set_allmulti(bond->current_slave->dev, inc);
-		break;
-	case BOND_MULTICAST_ALL :
-		for (slave = bond->prev; slave != (slave_t*)bond; slave = slave->prev)
-			dev_set_allmulti(slave->dev, inc);
-		break;
-	case BOND_MULTICAST_DISABLED :
-		break;
-	}
-} 
-
-/* 
- * returns dmi entry if found, NULL otherwise 
- */
-static struct dev_mc_list* bond_mc_list_find_dmi(struct dev_mc_list *dmi,
- struct dev_mc_list *mc_list)
-{ 
-	struct dev_mc_list *idmi;
-
-	for (idmi = mc_list; idmi != NULL; idmi = idmi->next) {
-		if (dmi_same(dmi, idmi)) {
-			return idmi; 
-		}
-	}
-	return NULL;
-} 
-
-static void set_multicast_list(struct net_device *master)
-{
-	bonding_t *bond = master->priv;
-	struct dev_mc_list *dmi;
-	unsigned long flags = 0;
-
-	if (multicast_mode == BOND_MULTICAST_DISABLED)
-		return;
-	/*
-	 * Lock the private data for the master
-	 */
-	write_lock_irqsave(&bond->lock, flags);
-
-	/* set promiscuity flag to slaves */
-	if ( (master->flags & IFF_PROMISC) && !(bond->flags & IFF_PROMISC) )
-		bond_set_promiscuity(bond, 1); 
-
-	if ( !(master->flags & IFF_PROMISC) && (bond->flags & IFF_PROMISC) ) 
-		bond_set_promiscuity(bond, -1); 
-
-	/* set allmulti flag to slaves */ 
-	if ( (master->flags & IFF_ALLMULTI) && !(bond->flags & IFF_ALLMULTI) ) 
-		bond_set_allmulti(bond, 1); 
-
-	if ( !(master->flags & IFF_ALLMULTI) && (bond->flags & IFF_ALLMULTI) )
-		bond_set_allmulti(bond, -1); 
-
-	bond->flags = master->flags; 
-
-	/* looking for addresses to add to slaves' mc list */ 
-	for (dmi = master->mc_list; dmi != NULL; dmi = dmi->next) { 
-		if (bond_mc_list_find_dmi(dmi, bond->mc_list) == NULL) 
-		 bond_mc_add(bond, dmi->dmi_addr, dmi->dmi_addrlen); 
-	} 
-
-	/* looking for addresses to delete from slaves' list */ 
-	for (dmi = bond->mc_list; dmi != NULL; dmi = dmi->next) { 
-		if (bond_mc_list_find_dmi(dmi, master->mc_list) == NULL) 
-		 bond_mc_delete(bond, dmi->dmi_addr, dmi->dmi_addrlen); 
-	}
-
-
-	/* save master's multicast list */ 
-	bond_mc_list_destroy (bond);
-	bond_mc_list_copy (master->mc_list, bond, GFP_ATOMIC);
-
-	write_unlock_irqrestore(&bond->lock, flags);
-}
-
-/*
- * Update the mc list and multicast-related flags for the new and 
- * old active slaves (if any) according to the multicast mode
- */
-static void bond_mc_update(bonding_t *bond, slave_t *new, slave_t *old)
-{
-	struct dev_mc_list *dmi;
-
-	switch(multicast_mode) {
-	case BOND_MULTICAST_ACTIVE :		
-		if (bond->device->flags & IFF_PROMISC) {
-			if (old != NULL && new != old)
-				dev_set_promiscuity(old->dev, -1);
-			dev_set_promiscuity(new->dev, 1);
-		}
-		if (bond->device->flags & IFF_ALLMULTI) {
-			if (old != NULL && new != old)
-				dev_set_allmulti(old->dev, -1);
-			dev_set_allmulti(new->dev, 1);
-		}
-		/* first remove all mc addresses from old slave if any,
-		   and _then_ add them to new active slave */
-		if (old != NULL && new != old) {
-			for (dmi = bond->device->mc_list; dmi != NULL; dmi = dmi->next)
-				dev_mc_delete(old->dev, dmi->dmi_addr, dmi->dmi_addrlen, 0);
-		}
-		for (dmi = bond->device->mc_list; dmi != NULL; dmi = dmi->next)
-			dev_mc_add(new->dev, dmi->dmi_addr, dmi->dmi_addrlen, 0);
-		break;
-	case BOND_MULTICAST_ALL :
-		/* nothing to do: mc list is already up-to-date on all slaves */
-		break;
-	case BOND_MULTICAST_DISABLED :
-		break;
-	}
-}
-
-/* enslave device <slave> to bond device <master> */
-static int bond_enslave(struct net_device *master_dev, 
-                        struct net_device *slave_dev)
-{
-	bonding_t *bond = NULL;
-	slave_t *new_slave = NULL;
-	unsigned long flags = 0;
-	unsigned long rflags = 0;
-	int ndx = 0;
-	int err = 0;
-	struct dev_mc_list *dmi;
-	struct in_ifaddr **ifap;
-	struct in_ifaddr *ifa;
-	int link_reporting;
-
-	if (master_dev == NULL || slave_dev == NULL) {
-		return -ENODEV;
-	}
-	bond = (struct bonding *) master_dev->priv;
-
-	if (slave_dev->do_ioctl == NULL) {
-		printk(KERN_DEBUG
-			"Warning : no link monitoring support for %s\n",
-			slave_dev->name);
-	}
-
-	/* not running. */
-	if ((slave_dev->flags & IFF_UP) != IFF_UP) {
-#ifdef BONDING_DEBUG
-		printk(KERN_CRIT "Error, slave_dev is not running\n");
-#endif
-		return -EINVAL;
-	}
-
-	/* already enslaved */
-	if (master_dev->flags & IFF_SLAVE || slave_dev->flags & IFF_SLAVE) {
-#ifdef BONDING_DEBUG
-		printk(KERN_CRIT "Error, Device was already enslaved\n");
-#endif
-		return -EBUSY;
-	}
-		   
-	if ((new_slave = kmalloc(sizeof(slave_t), GFP_ATOMIC)) == NULL) {
-		return -ENOMEM;
-	}
-	memset(new_slave, 0, sizeof(slave_t));
-
-	/* save flags before call to netdev_set_master */
-	new_slave->original_flags = slave_dev->flags;
-	err = netdev_set_master(slave_dev, master_dev);
-
-	if (err) {
-#ifdef BONDING_DEBUG
-		printk(KERN_CRIT "Error %d calling netdev_set_master\n", err);
-#endif
-		goto err_free;
-	}
-
-	new_slave->dev = slave_dev;
-
-	if (multicast_mode == BOND_MULTICAST_ALL) {
-		/* set promiscuity level to new slave */ 
-		if (master_dev->flags & IFF_PROMISC)
-			dev_set_promiscuity(slave_dev, 1); 
- 
-		/* set allmulti level to new slave */
-		if (master_dev->flags & IFF_ALLMULTI) 
-			dev_set_allmulti(slave_dev, 1); 
-		
-		/* upload master's mc_list to new slave */ 
-		for (dmi = master_dev->mc_list; dmi != NULL; dmi = dmi->next) 
-			dev_mc_add (slave_dev, dmi->dmi_addr, dmi->dmi_addrlen, 0);
-	}
-
-	write_lock_irqsave(&bond->lock, flags);
-	
-	bond_attach_slave(bond, new_slave);
-	new_slave->delay = 0;
-	new_slave->link_failure_count = 0;
-
-	if (miimon > 0 && !use_carrier) {
-		link_reporting = bond_check_dev_link(slave_dev, 1);
-
-		if ((link_reporting == -1) && (arp_interval == 0)) {
-			/*
-			 * miimon is set but a bonded network driver
-			 * does not support ETHTOOL/MII and
-			 * arp_interval is not set.  Note: if
-			 * use_carrier is enabled, we will never go
-			 * here (because netif_carrier is always
-			 * supported); thus, we don't need to change
-			 * the messages for netif_carrier.
-			 */ 
-			printk(KERN_ERR
-				"bond_enslave(): MII and ETHTOOL support not "
-				"available for interface %s, and "
-				"arp_interval/arp_ip_target module parameters "
-		       		"not specified, thus bonding will not detect "
-				"link failures! see bonding.txt for details.\n",
-		       		slave_dev->name);
-		} else if (link_reporting == -1) {
-			/* unable  get link status using mii/ethtool */
-			printk(KERN_WARNING 
-			       "bond_enslave: can't get link status from "
-			       "interface %s; the network driver associated "
-			       "with this interface does not support "
-			       "MII or ETHTOOL link status reporting, thus "
-			       "miimon has no effect on this interface.\n", 
-			       slave_dev->name);
-		}
-	}
-
-	/* check for initial state */
-	if ((miimon <= 0) ||
-	    (bond_check_dev_link(slave_dev, 0) == BMSR_LSTATUS)) {
-#ifdef BONDING_DEBUG
-		printk(KERN_CRIT "Initial state of slave_dev is BOND_LINK_UP\n");
-#endif
-		new_slave->link  = BOND_LINK_UP;
-		new_slave->jiffies = jiffies;
-	}
-	else {
-#ifdef BONDING_DEBUG
-		printk(KERN_CRIT "Initial state of slave_dev is BOND_LINK_DOWN\n");
-#endif
-		new_slave->link  = BOND_LINK_DOWN;
-	}
-
-	/* if we're in active-backup mode, we need one and only one active
-	 * interface. The backup interfaces will have their NOARP flag set
-	 * because we need them to be completely deaf and not to respond to
-	 * any ARP request on the network to avoid fooling a switch. Thus,
-	 * since we guarantee that current_slave always point to the last
-	 * usable interface, we just have to verify this interface's flag.
-	 */
-	if (bond_mode == BOND_MODE_ACTIVEBACKUP) {
-		if (((bond->current_slave == NULL)
-			|| (bond->current_slave->dev->flags & IFF_NOARP))
-			&& (new_slave->link == BOND_LINK_UP)) {
-#ifdef BONDING_DEBUG
-			printk(KERN_CRIT "This is the first active slave\n");
-#endif
-			/* first slave or no active slave yet, and this link
-			   is OK, so make this interface the active one */
-			bond->current_slave = new_slave;
-			bond_set_slave_active_flags(new_slave);
-			bond_mc_update(bond, new_slave, NULL);
-		}
-		else {
-#ifdef BONDING_DEBUG
-			printk(KERN_CRIT "This is just a backup slave\n");
-#endif
-			bond_set_slave_inactive_flags(new_slave);
-		}
-		read_lock_irqsave(&(((struct in_device *)slave_dev->ip_ptr)->lock), rflags);
-		ifap= &(((struct in_device *)slave_dev->ip_ptr)->ifa_list);
-		ifa = *ifap;
-		my_ip = ifa->ifa_address;
-		read_unlock_irqrestore(&(((struct in_device *)slave_dev->ip_ptr)->lock), rflags);
-
-		/* if there is a primary slave, remember it */
-		if (primary != NULL)
-		  if( strcmp(primary, new_slave->dev->name) == 0) 
-			bond->primary_slave = new_slave;
-	} else {
-#ifdef BONDING_DEBUG
-		printk(KERN_CRIT "This slave is always active in trunk mode\n");
-#endif
-		/* always active in trunk mode */
-		new_slave->state = BOND_STATE_ACTIVE;
-		if (bond->current_slave == NULL) 
-			bond->current_slave = new_slave;
-	}
-
-	write_unlock_irqrestore(&bond->lock, flags);
-
-	/*
-	 * !!! This is to support old versions of ifenslave.  We can remove
-	 * this in 2.5 because our ifenslave takes care of this for us.
-	 * We check to see if the master has a mac address yet.  If not,
-	 * we'll give it the mac address of our slave device.
-	 */
-	for (ndx = 0; ndx < slave_dev->addr_len; ndx++) {
-#ifdef BONDING_DEBUG
-		printk(KERN_CRIT "Checking ndx=%d of master_dev->dev_addr\n",
-		       ndx);
-#endif
-		if (master_dev->dev_addr[ndx] != 0) {
-#ifdef BONDING_DEBUG
-		printk(KERN_CRIT "Found non-zero byte at ndx=%d\n",
-		       ndx);
-#endif
-			break;
-		}
-	}
-	if (ndx == slave_dev->addr_len) {
-		/*
-		 * We got all the way through the address and it was
-		 * all 0's.
-		 */
-#ifdef BONDING_DEBUG
-		printk(KERN_CRIT "%s doesn't have a MAC address yet.  ",
-		       master_dev->name);
-		printk(KERN_CRIT "Going to give assign it from %s.\n",
-		       slave_dev->name);
-#endif
-		bond_sethwaddr(master_dev, slave_dev);
-	}
-
-	printk (KERN_INFO "%s: enslaving %s as a%s interface with a%s link.\n",
-		master_dev->name, slave_dev->name,
-		new_slave->state == BOND_STATE_ACTIVE ? "n active" : " backup",
-		new_slave->link == BOND_LINK_UP ? "n up" : " down");
-
-	/* enslave is successful */
-	return 0;
-err_free:
-	kfree(new_slave);
-	return err;
-}
-
-/* 
- * This function changes the active slave to slave <slave_dev>.
- * It returns -EINVAL in the following cases.
- *  - <slave_dev> is not found in the list.
- *  - There is not active slave now.
- *  - <slave_dev> is already active.
- *  - The link state of <slave_dev> is not BOND_LINK_UP.
- *  - <slave_dev> is not running.
- * In these cases, this fuction does nothing.
- * In the other cases, currnt_slave pointer is changed and 0 is returned.
- */
-static int bond_change_active(struct net_device *master_dev, struct net_device *slave_dev)
-{
-	bonding_t *bond;
-	slave_t *slave;
-	slave_t *oldactive = NULL;
-	slave_t *newactive = NULL;
-	unsigned long flags;
-	int ret = 0;
-
-	if (master_dev == NULL || slave_dev == NULL) {
-		return -ENODEV;
-	}
-
-	bond = (struct bonding *) master_dev->priv;
-	write_lock_irqsave(&bond->lock, flags);
-	slave = (slave_t *)bond;
-	oldactive = bond->current_slave;
-
-	while ((slave = slave->prev) != (slave_t *)bond) {
-		if(slave_dev == slave->dev) {
-			newactive = slave;
-			break;
-		}
-	}
-
-	if ((newactive != NULL)&&
-	    (oldactive != NULL)&&
-	    (newactive != oldactive)&&
-	    (newactive->link == BOND_LINK_UP)&&
-	    IS_UP(newactive->dev)) {
-		bond_set_slave_inactive_flags(oldactive);
-		bond_set_slave_active_flags(newactive);
-		bond_mc_update(bond, newactive, oldactive);
-		bond->current_slave = newactive;
-		printk("%s : activate %s(old : %s)\n",
-			master_dev->name, newactive->dev->name, 
-			oldactive->dev->name);
-	}
-	else {
-		ret = -EINVAL;
-	}
-	write_unlock_irqrestore(&bond->lock, flags);
-	return ret;
-}
-
-/* Choose a new valid interface from the pool, set it active
- * and make it the current slave. If no valid interface is
- * found, the oldest slave in BACK state is choosen and
- * activated. If none is found, it's considered as no
- * interfaces left so the current slave is set to NULL.
- * The result is a pointer to the current slave.
- *
- * Since this function sends messages tails through printk, the caller
- * must have started something like `printk(KERN_INFO "xxxx ");'.
- *
- * Warning: must put locks around the call to this function if needed.
- */
-slave_t *change_active_interface(bonding_t *bond)
-{
-	slave_t *newslave, *oldslave;
-	slave_t *bestslave = NULL;
-	int mintime;
-
-	read_lock(&bond->ptrlock);
-	newslave = oldslave = bond->current_slave;
-	read_unlock(&bond->ptrlock);
-
-	if (newslave == NULL) { /* there were no active slaves left */
-		if (bond->next != (slave_t *)bond) {  /* found one slave */
-			write_lock(&bond->ptrlock);
-			newslave = bond->current_slave = bond->next;
-			write_unlock(&bond->ptrlock);
-		} else {
-
-			printk (" but could not find any %s interface.\n",
-				(bond_mode == BOND_MODE_ACTIVEBACKUP) ? "backup":"other");
-			write_lock(&bond->ptrlock);
-			bond->current_slave = (slave_t *)NULL;
-			write_unlock(&bond->ptrlock);
-			return NULL; /* still no slave, return NULL */
-		}
-	} else if (bond_mode == BOND_MODE_ACTIVEBACKUP) {
-		/* make sure oldslave doesn't send arps - this could
-		 * cause a ping-pong effect between interfaces since they
-		 * would be able to tx arps - in active backup only one
-		 * slave should be able to tx arps, and that should be
-		 * the current_slave; the only exception is when all
-		 * slaves have gone down, then only one non-current slave can
-		 * send arps at a time; clearing oldslaves' mc list is handled
-		 * later in this function.
-		 */
-		bond_set_slave_inactive_flags(oldslave);
-	}
-
-	mintime = updelay;
-
-	/* first try the primary link; if arping, a link must tx/rx traffic 
-	 * before it can be considered the current_slave - also, we would skip 
-	 * slaves between the current_slave and primary_slave that may be up 
-	 * and able to arp
-	 */
-	if ((bond->primary_slave != NULL) && (arp_interval == 0)) {
-		if (IS_UP(bond->primary_slave->dev)) 
-			newslave = bond->primary_slave;
-	}
-
-	do {
-		if (IS_UP(newslave->dev)) {
-			if (newslave->link == BOND_LINK_UP) {
-				/* this one is immediately usable */
-				if (bond_mode == BOND_MODE_ACTIVEBACKUP) {
-					bond_set_slave_active_flags(newslave);
-					bond_mc_update(bond, newslave, oldslave);
-					printk (" and making interface %s the active one.\n",
-						newslave->dev->name);
-				}
-				else {
-					printk (" and setting pointer to interface %s.\n",
-						newslave->dev->name);
-				}
-
-				write_lock(&bond->ptrlock);
-				bond->current_slave = newslave;
-				write_unlock(&bond->ptrlock);
-				return newslave;
-			}
-			else if (newslave->link == BOND_LINK_BACK) {
-				/* link up, but waiting for stabilization */
-				if (newslave->delay < mintime) {
-					mintime = newslave->delay;
-					bestslave = newslave;
-				}
-			}
-		}
-	} while ((newslave = newslave->next) != oldslave);
-
-	/* no usable backup found, we'll see if we at least got a link that was
-	   coming back for a long time, and could possibly already be usable.
-	*/
-
-	if (bestslave != NULL) {
-		/* early take-over. */
-		printk (" and making interface %s the active one %d ms earlier.\n",
-			bestslave->dev->name,
-			(updelay - bestslave->delay)*miimon);
-
-		bestslave->delay = 0;
-		bestslave->link = BOND_LINK_UP;
-		bestslave->jiffies = jiffies;
-		bond_set_slave_active_flags(bestslave);
-		bond_mc_update(bond, bestslave, oldslave);
-		write_lock(&bond->ptrlock);
-		bond->current_slave = bestslave;
-		write_unlock(&bond->ptrlock);
-		return bestslave;
-	}
-
-	if ((bond_mode == BOND_MODE_ACTIVEBACKUP) &&
-	    (multicast_mode == BOND_MULTICAST_ACTIVE) &&
-	    (oldslave != NULL)) {
-		/* flush bonds (master's) mc_list from oldslave since it wasn't
-		 * updated (and deleted) above
-		 */ 
-		bond_mc_list_flush(oldslave->dev, bond->device); 
-		if (bond->device->flags & IFF_PROMISC) {
-			dev_set_promiscuity(oldslave->dev, -1);
-		}
-		if (bond->device->flags & IFF_ALLMULTI) {
-			dev_set_allmulti(oldslave->dev, -1);
-		}
-	}
-
-	printk (" but could not find any %s interface.\n",
-		(bond_mode == BOND_MODE_ACTIVEBACKUP) ? "backup":"other");
-	
-	/* absolutely nothing found. let's return NULL */
-	write_lock(&bond->ptrlock);
-	bond->current_slave = (slave_t *)NULL;
-	write_unlock(&bond->ptrlock);
-	return NULL;
-}
-
-/*
- * Try to release the slave device <slave> from the bond device <master>
- * It is legal to access current_slave without a lock because all the function
- * is write-locked.
- *
- * The rules for slave state should be:
- *   for Active/Backup:
- *     Active stays on all backups go down
- *   for Bonded connections:
- *     The first up interface should be left on and all others downed.
- */
-static int bond_release(struct net_device *master, struct net_device *slave)
-{
-	bonding_t *bond;
-	slave_t *our_slave, *old_current;
-	unsigned long flags;
-	
-	if (master == NULL || slave == NULL)  {
-		return -ENODEV;
-	}
-
-	bond = (struct bonding *) master->priv;
-
-	/* master already enslaved, or slave not enslaved,
-	   or no slave for this master */
-	if ((master->flags & IFF_SLAVE) || !(slave->flags & IFF_SLAVE)) {
-		printk (KERN_DEBUG "%s: cannot release %s.\n", master->name, slave->name);
-		return -EINVAL;
-	}
-
-	write_lock_irqsave(&bond->lock, flags);
-	bond->current_arp_slave = NULL;
-	our_slave = (slave_t *)bond;
-	old_current = bond->current_slave;
-	while ((our_slave = our_slave->prev) != (slave_t *)bond) {
-		if (our_slave->dev == slave) {
-			bond_detach_slave(bond, our_slave);
-
-			printk (KERN_INFO "%s: releasing %s interface %s",
-				master->name,
-				(our_slave->state == BOND_STATE_ACTIVE) ? "active" : "backup",
-				slave->name);
-
-			if (our_slave == old_current) {
-				/* find a new interface and be verbose */
-				change_active_interface(bond); 
-			} else {
-				printk(".\n");
-			}
-			
-			if (bond->current_slave == NULL) {
-				printk(KERN_INFO
-					"%s: now running without any active interface !\n",
-					master->name);
-			}
-
-			if (bond->primary_slave == our_slave) {
-				bond->primary_slave = NULL;
-			}
-
-			break;
-		}
-
-	}
-	write_unlock_irqrestore(&bond->lock, flags);
-	
-	if (our_slave == (slave_t *)bond) {
-		/* if we get here, it's because the device was not found */
-		printk (KERN_INFO "%s: %s not enslaved\n", master->name, slave->name);
-		return -EINVAL;
-	}
-
-	/* undo settings and restore original values */
-	
-	if (multicast_mode == BOND_MULTICAST_ALL) {
-		/* flush master's mc_list from slave */ 
-		bond_mc_list_flush (slave, master); 
-
-		/* unset promiscuity level from slave */
-		if (master->flags & IFF_PROMISC) 
-			dev_set_promiscuity(slave, -1); 
-
-		/* unset allmulti level from slave */ 
-		if (master->flags & IFF_ALLMULTI)
-			dev_set_allmulti(slave, -1); 
-	}
-
-	netdev_set_master(slave, NULL);
-
-	/* only restore its RUNNING flag if monitoring set it down */
-	if (slave->flags & IFF_UP) {
-		slave->flags |= IFF_RUNNING;
-	}
-
-	if (slave->flags & IFF_NOARP || 
-		bond->current_slave != NULL) {
-			dev_close(slave);
-			our_slave->original_flags &= ~IFF_UP;
-	}
-
-	bond_restore_slave_flags(our_slave);
-	
-	kfree(our_slave);
-
-	return 0;  /* deletion OK */
-}
-
-/* 
- * This function releases all slaves.
- * Warning: must put write-locks around the call to this function.
- */
-static int bond_release_all(struct net_device *master)
-{
-	bonding_t *bond;
-	slave_t *our_slave;
-	struct net_device *slave_dev;
-
-	if (master == NULL)  {
-		return -ENODEV;
-	}
-
-	if (master->flags & IFF_SLAVE) {
-		return -EINVAL;
-	}
-
-	bond = (struct bonding *) master->priv;
-	bond->current_arp_slave = NULL;
-	bond->current_slave = NULL;
-	bond->primary_slave = NULL;
-
-	while ((our_slave = bond->prev) != (slave_t *)bond) {
-		slave_dev = our_slave->dev;
-		bond_detach_slave(bond, our_slave);
-
-		if (multicast_mode == BOND_MULTICAST_ALL 
-		    || (multicast_mode == BOND_MULTICAST_ACTIVE 
-			&& bond->current_slave == our_slave)) {
-
-			/* flush master's mc_list from slave */ 
-			bond_mc_list_flush (slave_dev, master); 
-			
-			/* unset promiscuity level from slave */
-			if (master->flags & IFF_PROMISC) 
-				dev_set_promiscuity(slave_dev, -1); 
-			
-			/* unset allmulti level from slave */ 
-			if (master->flags & IFF_ALLMULTI)
-				dev_set_allmulti(slave_dev, -1); 
-		}
-
-		kfree(our_slave);
-
-		/*
-		 * Can be safely called from inside the bond lock
-		 * since traffic and timers have already stopped
-		 */
-		netdev_set_master(slave_dev, NULL);
-
-		/* only restore its RUNNING flag if monitoring set it down */
-		if (slave_dev->flags & IFF_UP)
-			slave_dev->flags |= IFF_RUNNING;
-
-		if (slave_dev->flags & IFF_NOARP)
-			dev_close(slave_dev);
-	}
-
-	printk (KERN_INFO "%s: released all slaves\n", master->name);
-
-	return 0;
-}
-
-/* this function is called regularly to monitor each slave's link. */
-static void bond_mii_monitor(struct net_device *master)
-{
-	bonding_t *bond = (struct bonding *) master->priv;
-	slave_t *slave, *bestslave, *oldcurrent;
-	unsigned long flags;
-	int slave_died = 0;
-
-	read_lock_irqsave(&bond->lock, flags);
-
-	/* we will try to read the link status of each of our slaves, and
-	 * set their IFF_RUNNING flag appropriately. For each slave not
-	 * supporting MII status, we won't do anything so that a user-space
-	 * program could monitor the link itself if needed.
-	 */
-
-	bestslave = NULL;
-	slave = (slave_t *)bond;
-
-	read_lock(&bond->ptrlock);
-	oldcurrent = bond->current_slave;
-	read_unlock(&bond->ptrlock);
-
-	while ((slave = slave->prev) != (slave_t *)bond) {
-		/* use updelay+1 to match an UP slave even when updelay is 0 */
-		int mindelay = updelay + 1;
-		struct net_device *dev = slave->dev;
-		int link_state;
-		
-		link_state = bond_check_dev_link(dev, 0);
-
-		switch (slave->link) {
-		case BOND_LINK_UP:	/* the link was up */
-			if (link_state == BMSR_LSTATUS) {
-				/* link stays up, tell that this one
-				   is immediately available */
-				if (IS_UP(dev) && (mindelay > -2)) {
-					/* -2 is the best case :
-					   this slave was already up */
-					mindelay = -2;
-					bestslave = slave;
-				}
-				break;
-			}
-			else { /* link going down */
-				slave->link  = BOND_LINK_FAIL;
-				slave->delay = downdelay;
-				if (slave->link_failure_count < UINT_MAX) {
-					slave->link_failure_count++;
-				}
-				if (downdelay > 0) {
-					printk (KERN_INFO
-						"%s: link status down for %sinterface "
-						"%s, disabling it in %d ms.\n",
-						master->name,
-						IS_UP(dev)
-						? ((bond_mode == BOND_MODE_ACTIVEBACKUP)
-						   ? ((slave == oldcurrent)
-						      ? "active " : "backup ")
-						   : "")
-						: "idle ",
-						dev->name,
-						downdelay * miimon);
-					}
-			}
-			/* no break ! fall through the BOND_LINK_FAIL test to
-			   ensure proper action to be taken
-			*/
-		case BOND_LINK_FAIL:	/* the link has just gone down */
-			if (link_state != BMSR_LSTATUS) {
-				/* link stays down */
-				if (slave->delay <= 0) {
-					/* link down for too long time */
-					slave->link = BOND_LINK_DOWN;
-					/* in active/backup mode, we must
-					   completely disable this interface */
-					if (bond_mode == BOND_MODE_ACTIVEBACKUP) {
-						bond_set_slave_inactive_flags(slave);
-					}
-					printk(KERN_INFO
-						"%s: link status definitely down "
-						"for interface %s, disabling it",
-						master->name,
-						dev->name);
-
-					read_lock(&bond->ptrlock);
-					if (slave == bond->current_slave) {
-						read_unlock(&bond->ptrlock);
-						/* find a new interface and be verbose */
-						change_active_interface(bond);
-					} else {
-						read_unlock(&bond->ptrlock);
-						printk(".\n");
-					}
-					slave_died = 1;
-				} else {
-					slave->delay--;
-				}
-			} else {
-				/* link up again */
-				slave->link  = BOND_LINK_UP;
-				slave->jiffies = jiffies;
-				printk(KERN_INFO
-					"%s: link status up again after %d ms "
-					"for interface %s.\n",
-					master->name,
-					(downdelay - slave->delay) * miimon,
-					dev->name);
-
-				if (IS_UP(dev) && (mindelay > -1)) {
-					/* -1 is a good case : this slave went
-					   down only for a short time */
-					mindelay = -1;
-					bestslave = slave;
-				}
-			}
-			break;
-		case BOND_LINK_DOWN:	/* the link was down */
-			if (link_state != BMSR_LSTATUS) {
-				/* the link stays down, nothing more to do */
-				break;
-			} else {	/* link going up */
-				slave->link  = BOND_LINK_BACK;
-				slave->delay = updelay;
-				
-				if (updelay > 0) {
-					/* if updelay == 0, no need to
-					   advertise about a 0 ms delay */
-					printk (KERN_INFO
-						"%s: link status up for interface"
-						" %s, enabling it in %d ms.\n",
-						master->name,
-						dev->name,
-						updelay * miimon);
-				}
-			}
-			/* no break ! fall through the BOND_LINK_BACK state in
-			   case there's something to do.
-			*/
-		case BOND_LINK_BACK:	/* the link has just come back */
-			if (link_state != BMSR_LSTATUS) {
-				/* link down again */
-				slave->link  = BOND_LINK_DOWN;
-				printk(KERN_INFO
-					"%s: link status down again after %d ms "
-					"for interface %s.\n",
-					master->name,
-					(updelay - slave->delay) * miimon,
-					dev->name);
-			} else {
-				/* link stays up */
-				if (slave->delay == 0) {
-					/* now the link has been up for long time enough */
-					slave->link = BOND_LINK_UP;
-					slave->jiffies = jiffies;
-
-					if (bond_mode != BOND_MODE_ACTIVEBACKUP) {
-						/* make it immediately active */
-						slave->state = BOND_STATE_ACTIVE;
-					} else if (slave != bond->primary_slave) {
-						/* prevent it from being the active one */
-						slave->state = BOND_STATE_BACKUP;
-					}
-
-					printk(KERN_INFO
-						"%s: link status definitely up "
-						"for interface %s.\n",
-						master->name,
-						dev->name);
-	
-					if ( (bond->primary_slave != NULL)	 
-					  && (slave == bond->primary_slave) )
-						change_active_interface(bond); 
-				}
-				else
-					slave->delay--;
-				
-				/* we'll also look for the mostly eligible slave */
-				if (bond->primary_slave == NULL)  {
-				    if (IS_UP(dev) && (slave->delay < mindelay)) {
-					mindelay = slave->delay;
-					bestslave = slave;
-				    } 
-				} else if ( (IS_UP(bond->primary_slave->dev))  || 
-				          ( (!IS_UP(bond->primary_slave->dev))  && 
-				          (IS_UP(dev) && (slave->delay < mindelay)) ) ) {
-					mindelay = slave->delay;
-					bestslave = slave;
-				}
-			}
-			break;
-		} /* end of switch */
-	} /* end of while */
-
-	/* 
-	 * if there's no active interface and we discovered that one
-	 * of the slaves could be activated earlier, so we do it.
-	 */
-	read_lock(&bond->ptrlock);
-	oldcurrent = bond->current_slave;
-	read_unlock(&bond->ptrlock);
-
-	/* no active interface at the moment or need to bring up the primary */
-	if (oldcurrent == NULL)  { /* no active interface at the moment */
-		if (bestslave != NULL) { /* last chance to find one ? */
-			if (bestslave->link == BOND_LINK_UP) {
-				printk (KERN_INFO
-					"%s: making interface %s the new active one.\n",
-					master->name, bestslave->dev->name);
-			} else {
-				printk (KERN_INFO
-					"%s: making interface %s the new "
-					"active one %d ms earlier.\n",
-					master->name, bestslave->dev->name,
-					(updelay - bestslave->delay) * miimon);
-
-				bestslave->delay = 0;
-				bestslave->link  = BOND_LINK_UP;
-				bestslave->jiffies = jiffies;
-			}
-
-			if (bond_mode == BOND_MODE_ACTIVEBACKUP) {
-				bond_set_slave_active_flags(bestslave);
-				bond_mc_update(bond, bestslave, NULL);
-			} else {
-				bestslave->state = BOND_STATE_ACTIVE;
-			}
-			write_lock(&bond->ptrlock);
-			bond->current_slave = bestslave;
-			write_unlock(&bond->ptrlock);
-		} else if (slave_died) {
-			/* print this message only once a slave has just died */
-			printk(KERN_INFO
-				"%s: now running without any active interface !\n",
-				master->name);
-		}
-	}
-
-	read_unlock_irqrestore(&bond->lock, flags);
-	/* re-arm the timer */
-	mod_timer(&bond->mii_timer, jiffies + (miimon * HZ / 1000));
-}
-
-/* 
- * this function is called regularly to monitor each slave's link 
- * ensuring that traffic is being sent and received when arp monitoring
- * is used in load-balancing mode. if the adapter has been dormant, then an 
- * arp is transmitted to generate traffic. see activebackup_arp_monitor for 
- * arp monitoring in active backup mode. 
- */
-static void loadbalance_arp_monitor(struct net_device *master)
-{
-	bonding_t *bond;
-	unsigned long flags;
-	slave_t *slave;
-	int the_delta_in_ticks =  arp_interval * HZ / 1000;
-	int next_timer = jiffies + (arp_interval * HZ / 1000);
-
-	bond = (struct bonding *) master->priv; 
-	if (master->priv == NULL) {
-		mod_timer(&bond->arp_timer, next_timer);
-		return;
-	}
-
-	read_lock_irqsave(&bond->lock, flags);
-
-	/* TODO: investigate why rtnl_shlock_nowait and rtnl_exlock_nowait
-	 * are called below and add comment why they are required... 
-	 */
-	if ((!IS_UP(master)) || rtnl_shlock_nowait()) {
-		mod_timer(&bond->arp_timer, next_timer);
-		read_unlock_irqrestore(&bond->lock, flags);
-		return;
-	}
-
-	if (rtnl_exlock_nowait()) {
-		rtnl_shunlock();
-		mod_timer(&bond->arp_timer, next_timer);
-		read_unlock_irqrestore(&bond->lock, flags);
-		return;
-	}
-
-	/* see if any of the previous devices are up now (i.e. they have
-	 * xmt and rcv traffic). the current_slave does not come into
-	 * the picture unless it is null. also, slave->jiffies is not needed
-	 * here because we send an arp on each slave and give a slave as
-	 * long as it needs to get the tx/rx within the delta.
-	 * TODO: what about up/down delay in arp mode? it wasn't here before
-	 *       so it can wait 
-	 */
-	slave = (slave_t *)bond;
-	while ((slave = slave->prev) != (slave_t *)bond)  {
-
-	  	if (slave->link != BOND_LINK_UP) {
-
-	  		if (((jiffies - slave->dev->trans_start) <= 
-						the_delta_in_ticks) &&  
-			     ((jiffies - slave->dev->last_rx) <= 
-						the_delta_in_ticks)) {
-
-				slave->link  = BOND_LINK_UP;
-				slave->state = BOND_STATE_ACTIVE;
-
-				/* primary_slave has no meaning in round-robin
-				 * mode. the window of a slave being up and 
-				 * current_slave being null after enslaving
-				 * is closed.
-				 */
-				read_lock(&bond->ptrlock);
-				if (bond->current_slave == NULL) {
-					read_unlock(&bond->ptrlock);
-					printk(KERN_INFO
-						"%s: link status definitely up "
-						"for interface %s, ",
-						master->name,
-						slave->dev->name);
-					change_active_interface(bond); 
-				} else {
-					read_unlock(&bond->ptrlock);
-					printk(KERN_INFO
-						"%s: interface %s is now up\n",
-						master->name,
-						slave->dev->name);
-				}
-			} 
-		} else {
-			/* slave->link == BOND_LINK_UP */
-
-			/* not all switches will respond to an arp request
-			 * when the source ip is 0, so don't take the link down
-			 * if we don't know our ip yet
-			 */
-			if (((jiffies - slave->dev->trans_start) >= 
-		              (2*the_delta_in_ticks)) ||
-		             (((jiffies - slave->dev->last_rx) >= 
-		               (2*the_delta_in_ticks)) && my_ip !=0)) {
-				slave->link  = BOND_LINK_DOWN;
-				slave->state = BOND_STATE_BACKUP;
-				if (slave->link_failure_count < UINT_MAX) {
-					slave->link_failure_count++;
-				}
-				printk(KERN_INFO
-				       "%s: interface %s is now down.\n",
-				       master->name,
-				       slave->dev->name);
-
-				read_lock(&bond->ptrlock);
-				if (slave == bond->current_slave) {
-					read_unlock(&bond->ptrlock);
-					change_active_interface(bond);
-				} else {
-					read_unlock(&bond->ptrlock);
-				}
-			}
-		} 
-
-		/* note: if switch is in round-robin mode, all links 
-		 * must tx arp to ensure all links rx an arp - otherwise
-		 * links may oscillate or not come up at all; if switch is 
-		 * in something like xor mode, there is nothing we can 
-		 * do - all replies will be rx'ed on same link causing slaves 
-		 * to be unstable during low/no traffic periods
-		 */
-		if (IS_UP(slave->dev)) {
-			arp_send_all(slave);
-		}
-	}
-
-	rtnl_exunlock();
-	rtnl_shunlock();
-	read_unlock_irqrestore(&bond->lock, flags);
-
-	/* re-arm the timer */
-	mod_timer(&bond->arp_timer, next_timer);
-}
-
-/* 
- * When using arp monitoring in active-backup mode, this function is
- * called to determine if any backup slaves have went down or a new
- * current slave needs to be found.
- * The backup slaves never generate traffic, they are considered up by merely 
- * receiving traffic. If the current slave goes down, each backup slave will 
- * be given the opportunity to tx/rx an arp before being taken down - this 
- * prevents all slaves from being taken down due to the current slave not 
- * sending any traffic for the backups to receive. The arps are not necessarily
- * necessary, any tx and rx traffic will keep the current slave up. While any 
- * rx traffic will keep the backup slaves up, the current slave is responsible 
- * for generating traffic to keep them up regardless of any other traffic they 
- * may have received.
- * see loadbalance_arp_monitor for arp monitoring in load balancing mode
- */
-static void activebackup_arp_monitor(struct net_device *master)
-{
-	bonding_t *bond;
-	unsigned long flags;
-	slave_t *slave;
-	int the_delta_in_ticks =  arp_interval * HZ / 1000;
-	int next_timer = jiffies + (arp_interval * HZ / 1000);
-
-	bond = (struct bonding *) master->priv; 
-	if (master->priv == NULL) {
-		mod_timer(&bond->arp_timer, next_timer);
-		return;
-	}
-
-	read_lock_irqsave(&bond->lock, flags);
-
-	if (!IS_UP(master)) {
-		mod_timer(&bond->arp_timer, next_timer);
-	        read_unlock_irqrestore(&bond->lock, flags);
-		return;
-	}
-
-	/* determine if any slave has come up or any backup slave has 
-	 * gone down 
-	 * TODO: what about up/down delay in arp mode? it wasn't here before
-	 *       so it can wait 
-	 */
-	slave = (slave_t *)bond;
-	while ((slave = slave->prev) != (slave_t *)bond)  {
-
-	  	if (slave->link != BOND_LINK_UP) {
-			if ((jiffies - slave->dev->last_rx) <=
-			    the_delta_in_ticks) {
-
-				slave->link = BOND_LINK_UP;
-				write_lock(&bond->ptrlock);
-				if ((bond->current_slave == NULL) &&
-				    ((jiffies - slave->dev->trans_start) <=
-				     the_delta_in_ticks)) {
-					bond->current_slave = slave;
-					bond_set_slave_active_flags(slave);
-			                bond_mc_update(bond, slave, NULL);
-					bond->current_arp_slave = NULL;
-				} else if (bond->current_slave != slave) {
-					/* this slave has just come up but we 
-					 * already have a current slave; this
-					 * can also happen if bond_enslave adds
-					 * a new slave that is up while we are 
-					 * searching for a new slave
-					 */
-					bond_set_slave_inactive_flags(slave);
-					bond->current_arp_slave = NULL;
-				}
-
-				if (slave == bond->current_slave) {
-					printk(KERN_INFO
-						"%s: %s is up and now the "
-						"active interface\n",
-						master->name,
-						slave->dev->name);
-				} else {
-					printk(KERN_INFO
-						"%s: backup interface %s is "
-						"now up\n",
-						master->name,
-						slave->dev->name);
-				}
-
-				write_unlock(&bond->ptrlock);
-			}
-		} else {
-			read_lock(&bond->ptrlock);
-			if ((slave != bond->current_slave) &&
-			    (bond->current_arp_slave == NULL) &&
-			    (((jiffies - slave->dev->last_rx) >=
-			     3*the_delta_in_ticks) && (my_ip != 0))) {
-				/* a backup slave has gone down; three times 
-				 * the delta allows the current slave to be 
-				 * taken out before the backup slave.
-				 * note: a non-null current_arp_slave indicates
-				 * the current_slave went down and we are 
-				 * searching for a new one; under this 
-				 * condition we only take the current_slave 
-				 * down - this gives each slave a chance to 
-				 * tx/rx traffic before being taken out
-				 */
-				read_unlock(&bond->ptrlock);
-				slave->link  = BOND_LINK_DOWN;
-				if (slave->link_failure_count < UINT_MAX) {
-					slave->link_failure_count++;
-				}
-				bond_set_slave_inactive_flags(slave);
-				printk(KERN_INFO
-					"%s: backup interface %s is now down\n",
-					master->name,
-					slave->dev->name);
-			} else {
-				read_unlock(&bond->ptrlock);
-			}
-		}
-	}
-
-	read_lock(&bond->ptrlock);
-	slave = bond->current_slave;
-	read_unlock(&bond->ptrlock);
-
-	if (slave != NULL) {
-
-		/* if we have sent traffic in the past 2*arp_intervals but
-		 * haven't xmit and rx traffic in that time interval, select 
-		 * a different slave. slave->jiffies is only updated when
-		 * a slave first becomes the current_slave - not necessarily
-		 * after every arp; this ensures the slave has a full 2*delta 
-		 * before being taken out. if a primary is being used, check 
-		 * if it is up and needs to take over as the current_slave
-		 */
-		if ((((jiffies - slave->dev->trans_start) >= 
-		       (2*the_delta_in_ticks)) ||
-		     (((jiffies - slave->dev->last_rx) >= 
-		       (2*the_delta_in_ticks)) && (my_ip != 0))) &&
-		    ((jiffies - slave->jiffies) >= 2*the_delta_in_ticks)) {
-
-			slave->link  = BOND_LINK_DOWN;
-			if (slave->link_failure_count < UINT_MAX) {
-				slave->link_failure_count++;
-			}
-			printk(KERN_INFO "%s: link status down for "
-					 "active interface %s, disabling it",
-			       master->name,
-			       slave->dev->name);
-			slave = change_active_interface(bond);
-			bond->current_arp_slave = slave;
-			if (slave != NULL) {
-				slave->jiffies = jiffies;
-			}
-
-		} else if ((bond->primary_slave != NULL) && 
-			   (bond->primary_slave != slave) && 
-			   (bond->primary_slave->link == BOND_LINK_UP)) {
-			/* at this point, slave is the current_slave */
-			printk(KERN_INFO 
-			       "%s: changing from interface %s to primary "
-			       "interface %s\n",
-			       master->name, 
-			       slave->dev->name, 
-			       bond->primary_slave->dev->name);
-			       
-			/* primary is up so switch to it */
-			bond_set_slave_inactive_flags(slave);
-			bond_mc_update(bond, bond->primary_slave, slave);
-			write_lock(&bond->ptrlock);
-			bond->current_slave = bond->primary_slave;
-			write_unlock(&bond->ptrlock);
-			slave = bond->primary_slave;
-			bond_set_slave_active_flags(slave);
-			slave->jiffies = jiffies;
-		} else {
-			bond->current_arp_slave = NULL;
-		}
-
-		/* the current slave must tx an arp to ensure backup slaves
-		 * rx traffic
-		 */
-		if ((slave != NULL) &&
-		    (((jiffies - slave->dev->last_rx) >= the_delta_in_ticks) &&
-		     (my_ip != 0))) {
-		  arp_send_all(slave);
-		}
-	}
-
-	/* if we don't have a current_slave, search for the next available 
-	 * backup slave from the current_arp_slave and make it the candidate 
-	 * for becoming the current_slave
-	 */
-	if (slave == NULL) { 
-
-		if ((bond->current_arp_slave == NULL) ||
-		    (bond->current_arp_slave == (slave_t *)bond)) {
-			bond->current_arp_slave = bond->prev;
-		} 
-
-		if (bond->current_arp_slave != (slave_t *)bond) {
-			bond_set_slave_inactive_flags(bond->current_arp_slave);
-			slave = bond->current_arp_slave->next;
-
-			/* search for next candidate */
-			do {
-				if (IS_UP(slave->dev)) {
-					slave->link = BOND_LINK_BACK;
-					bond_set_slave_active_flags(slave);
-					arp_send_all(slave);
-					slave->jiffies = jiffies;
-					bond->current_arp_slave = slave;
-					break;
-				}
-
-				/* if the link state is up at this point, we 
-				 * mark it down - this can happen if we have 
-				 * simultaneous link failures and 
-				 * change_active_interface doesn't make this 
-				 * one the current slave so it is still marked 
-				 * up when it is actually down
-				 */
-				if (slave->link == BOND_LINK_UP) {
-					slave->link  = BOND_LINK_DOWN;
-					if (slave->link_failure_count < 
-							UINT_MAX) {
-						slave->link_failure_count++;
-					}
-
-					bond_set_slave_inactive_flags(slave);
-					printk(KERN_INFO
-						"%s: backup interface "
-						"%s is now down.\n",
-						master->name,
-						slave->dev->name);
-				}
-			} while ((slave = slave->next) != 
-					bond->current_arp_slave->next);
-		}
-	}
-
-	mod_timer(&bond->arp_timer, next_timer);
-	read_unlock_irqrestore(&bond->lock, flags);
-}
-
-typedef uint32_t in_addr_t;
-
-int
-my_inet_aton(char *cp, unsigned long *the_addr) {
-	static const in_addr_t max[4] = { 0xffffffff, 0xffffff, 0xffff, 0xff };
-	in_addr_t val;
-	char c;
-	union iaddr {
-	  uint8_t bytes[4];
-	  uint32_t word;
-	} res;
-	uint8_t *pp = res.bytes;
-	int digit,base;
-
-	res.word = 0;
-
-	c = *cp;
-	for (;;) {
-		/*
-		 * Collect number up to ``.''.
-		 * Values are specified as for C:
-		 * 0x=hex, 0=octal, isdigit=decimal.
-		 */
-		if (!isdigit(c)) goto ret_0;
-		val = 0; base = 10; digit = 0;
-		for (;;) {
-			if (isdigit(c)) {
-				val = (val * base) + (c - '0');
-				c = *++cp;
-				digit = 1;
-			} else {
-				break;
-			}
-		}
-		if (c == '.') {
-			/*
-			 * Internet format:
-			 *	a.b.c.d
-			 *	a.b.c	(with c treated as 16 bits)
-			 *	a.b	(with b treated as 24 bits)
-			 */
-			if (pp > res.bytes + 2 || val > 0xff) {
-				goto ret_0;
-			}
-			*pp++ = val;
-			c = *++cp;
-		} else
-			break;
-	}
-	/*
-	 * Check for trailing characters.
-	 */
-	if (c != '\0' && (!isascii(c) || !isspace(c))) {
-		goto ret_0;
-	}
-	/*
-	 * Did we get a valid digit?
-	 */
-	if (!digit) {
-		goto ret_0;
-	}
-
-	/* Check whether the last part is in its limits depending on
-	   the number of parts in total.  */
-	if (val > max[pp - res.bytes]) {
-		goto ret_0;
-	}
-
-	if (the_addr != NULL) {
-		*the_addr = res.word | htonl (val);
-	}
-
-	return (1);
-
-ret_0:
-	return (0);
-}
-
-static int bond_sethwaddr(struct net_device *master, struct net_device *slave)
-{
-#ifdef BONDING_DEBUG
-	printk(KERN_CRIT "bond_sethwaddr: master=%x\n", (unsigned int)master);
-	printk(KERN_CRIT "bond_sethwaddr: slave=%x\n", (unsigned int)slave);
-	printk(KERN_CRIT "bond_sethwaddr: slave->addr_len=%d\n", slave->addr_len);
-#endif
-	memcpy(master->dev_addr, slave->dev_addr, slave->addr_len);
-	return 0;
-}
-
-static int bond_info_query(struct net_device *master, struct ifbond *info)
-{
-	bonding_t *bond = (struct bonding *) master->priv;
-	slave_t *slave;
-	unsigned long flags;
-
-	info->bond_mode = bond_mode;
-	info->num_slaves = 0;
-	info->miimon = miimon;
-
-	read_lock_irqsave(&bond->lock, flags);
-	for (slave = bond->prev; slave != (slave_t *)bond; slave = slave->prev) {
-		info->num_slaves++;
-	}
-	read_unlock_irqrestore(&bond->lock, flags);
-
-	return 0;
-}
-
-static int bond_slave_info_query(struct net_device *master, 
-					struct ifslave *info)
-{
-	bonding_t *bond = (struct bonding *) master->priv;
-	slave_t *slave;
-	int cur_ndx = 0;
-	unsigned long flags;
-
-	if (info->slave_id < 0) {
-		return -ENODEV;
-	}
-
-	read_lock_irqsave(&bond->lock, flags);
-	for (slave = bond->prev; 
-		 slave != (slave_t *)bond && cur_ndx < info->slave_id; 
-		 slave = slave->prev) {
-		cur_ndx++;
-	}
-	read_unlock_irqrestore(&bond->lock, flags);
-
-	if (slave != (slave_t *)bond) {
-		strcpy(info->slave_name, slave->dev->name);
-		info->link = slave->link;
-		info->state = slave->state;
-		info->link_failure_count = slave->link_failure_count;
-	} else {
-		return -ENODEV;
-	}
-
-	return 0;
-}
-
-static int bond_ioctl(struct net_device *master_dev, struct ifreq *ifr, int cmd)
-{
-	struct net_device *slave_dev = NULL;
-	struct ifbond *u_binfo = NULL, k_binfo;
-	struct ifslave *u_sinfo = NULL, k_sinfo;
-	struct mii_ioctl_data *mii = NULL;
-	int ret = 0;
-
-#ifdef BONDING_DEBUG
-	printk(KERN_INFO "bond_ioctl: master=%s, cmd=%d\n", 
-		master_dev->name, cmd);
-#endif
-
-	switch (cmd) {
-	case SIOCGMIIPHY:
-		mii = (struct mii_ioctl_data *)&ifr->ifr_data;
-		if (mii == NULL) {
-			return -EINVAL;
-		}
-		mii->phy_id = 0;
-		/* Fall Through */
-	case SIOCGMIIREG:
-		/* 
-		 * We do this again just in case we were called by SIOCGMIIREG
-		 * instead of SIOCGMIIPHY.
-		 */
-		mii = (struct mii_ioctl_data *)&ifr->ifr_data;
-		if (mii == NULL) {
-			return -EINVAL;
-		}
-		if (mii->reg_num == 1) {
-			mii->val_out = bond_check_mii_link(
-				(struct bonding *)master_dev->priv);
-		}
-		return 0;
-	case BOND_INFO_QUERY_OLD:
-	case SIOCBONDINFOQUERY:
-		u_binfo = (struct ifbond *)ifr->ifr_data;
-		if (copy_from_user(&k_binfo, u_binfo, sizeof(ifbond))) {
-			return -EFAULT;
-		}
-		ret = bond_info_query(master_dev, &k_binfo);
-		if (ret == 0) {
-			if (copy_to_user(u_binfo, &k_binfo, sizeof(ifbond))) {
-				return -EFAULT;
-			}
-		}
-		return ret;
-	case BOND_SLAVE_INFO_QUERY_OLD:
-	case SIOCBONDSLAVEINFOQUERY:
-		u_sinfo = (struct ifslave *)ifr->ifr_data;
-		if (copy_from_user(&k_sinfo, u_sinfo, sizeof(ifslave))) {
-			return -EFAULT;
-		}
-		ret = bond_slave_info_query(master_dev, &k_sinfo);
-		if (ret == 0) {
-			if (copy_to_user(u_sinfo, &k_sinfo, sizeof(ifslave))) {
-				return -EFAULT;
-			}
-		}
-		return ret;
-	}
-
-	if (!capable(CAP_NET_ADMIN)) {
-		return -EPERM;
-	}
-
-	slave_dev = dev_get_by_name(ifr->ifr_slave);
-
-#ifdef BONDING_DEBUG
-	printk(KERN_INFO "slave_dev=%x: \n", (unsigned int)slave_dev);
-	printk(KERN_INFO "slave_dev->name=%s: \n", slave_dev->name);
-#endif
-
-	if (slave_dev == NULL) {
-		ret = -ENODEV;
-	} else {
-		switch (cmd) {
-		case BOND_ENSLAVE_OLD:
-		case SIOCBONDENSLAVE:		
-			ret = bond_enslave(master_dev, slave_dev);
-			break;
-		case BOND_RELEASE_OLD:			
-		case SIOCBONDRELEASE:	
-			ret = bond_release(master_dev, slave_dev); 
-			break;
-		case BOND_SETHWADDR_OLD:
-		case SIOCBONDSETHWADDR:	
-			ret = bond_sethwaddr(master_dev, slave_dev);
-			break;
-		case BOND_CHANGE_ACTIVE_OLD:
-		case SIOCBONDCHANGEACTIVE:
-			if (bond_mode == BOND_MODE_ACTIVEBACKUP) {
-				ret = bond_change_active(master_dev, slave_dev);
-			}
-			else {
-				ret = -EINVAL;
-			}
-			break;
-		default:
-			ret = -EOPNOTSUPP;
-		}
-		dev_put(slave_dev);
-	}
-	return ret;
-}
-
-#ifdef CONFIG_NET_FASTROUTE
-static int bond_accept_fastpath(struct net_device *dev, struct dst_entry *dst)
-{
-	return -1;
-}
-#endif
-
-/* 
- * in broadcast mode, we send everything to all usable interfaces.
- */
-static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *dev)
-{
-	slave_t *slave, *start_at;
-	struct bonding *bond = (struct bonding *) dev->priv;
-	unsigned long flags;
-	struct net_device *device_we_should_send_to = 0;
-
-	if (!IS_UP(dev)) { /* bond down */
-		dev_kfree_skb(skb);
-		return 0;
-	}
-
-	read_lock_irqsave(&bond->lock, flags);
-
-	read_lock(&bond->ptrlock);
-	slave = start_at = bond->current_slave;
-	read_unlock(&bond->ptrlock);
-
-	if (slave == NULL) { /* we're at the root, get the first slave */
-		/* no suitable interface, frame not sent */
-		read_unlock_irqrestore(&bond->lock, flags);
-		dev_kfree_skb(skb);
-		return 0;
-	}
-
-	do {
-		if (IS_UP(slave->dev)
-		    && (slave->link == BOND_LINK_UP)
-		    && (slave->state == BOND_STATE_ACTIVE)) {
-			if (device_we_should_send_to) {
-				struct sk_buff *skb2;
-				if ((skb2 = skb_clone(skb, GFP_ATOMIC)) == NULL) {
-					printk(KERN_ERR "bond_xmit_broadcast: skb_clone() failed\n");
-					continue;
-				}
-
-				skb2->dev = device_we_should_send_to;
-				skb2->priority = 1;
-				dev_queue_xmit(skb2);
-			}
-			device_we_should_send_to = slave->dev;
-		}
-	} while ((slave = slave->next) != start_at);
-
-	if (device_we_should_send_to) {
-		skb->dev = device_we_should_send_to;
-		skb->priority = 1;
-		dev_queue_xmit(skb);
-	} else
-		dev_kfree_skb(skb);
-
-	/* frame sent to all suitable interfaces */
-	read_unlock_irqrestore(&bond->lock, flags);
-	return 0;
-}
-
-static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *dev)
-{
-	slave_t *slave, *start_at;
-	struct bonding *bond = (struct bonding *) dev->priv;
-	unsigned long flags;
-
-	if (!IS_UP(dev)) { /* bond down */
-		dev_kfree_skb(skb);
-		return 0;
-	}
-
-	read_lock_irqsave(&bond->lock, flags);
-
-	read_lock(&bond->ptrlock);
-	slave = start_at = bond->current_slave;
-	read_unlock(&bond->ptrlock);
-
-	if (slave == NULL) { /* we're at the root, get the first slave */
-		/* no suitable interface, frame not sent */
-		dev_kfree_skb(skb);
-		read_unlock_irqrestore(&bond->lock, flags);
-		return 0;
-	}
-
-	do {
-		if (IS_UP(slave->dev)
-		    && (slave->link == BOND_LINK_UP)
-		    && (slave->state == BOND_STATE_ACTIVE)) {
-
-			skb->dev = slave->dev;
-			skb->priority = 1;
-			dev_queue_xmit(skb);
-
-			write_lock(&bond->ptrlock);
-			bond->current_slave = slave->next;
-			write_unlock(&bond->ptrlock);
-
-			read_unlock_irqrestore(&bond->lock, flags);
-			return 0;
-		}
-	} while ((slave = slave->next) != start_at);
-
-	/* no suitable interface, frame not sent */
-	dev_kfree_skb(skb);
-	read_unlock_irqrestore(&bond->lock, flags);
-	return 0;
-}
-
-/* 
- * in XOR mode, we determine the output device by performing xor on
- * the source and destination hw adresses.  If this device is not 
- * enabled, find the next slave following this xor slave. 
- */
-static int bond_xmit_xor(struct sk_buff *skb, struct net_device *dev)
-{
-	slave_t *slave, *start_at;
-	struct bonding *bond = (struct bonding *) dev->priv;
-	unsigned long flags;
-	struct ethhdr *data = (struct ethhdr *)skb->data;
-	int slave_no;
-
-	if (!IS_UP(dev)) { /* bond down */
-		dev_kfree_skb(skb);
-		return 0;
-	}
-
-	read_lock_irqsave(&bond->lock, flags);
-	slave = bond->prev;
-
-	/* we're at the root, get the first slave */
-	if (bond->slave_cnt == 0) {
-		/* no suitable interface, frame not sent */
-		dev_kfree_skb(skb);
-		read_unlock_irqrestore(&bond->lock, flags);
-		return 0;
-	}
-
-	slave_no = (data->h_dest[5]^slave->dev->dev_addr[5]) % bond->slave_cnt;
-
-	while ( (slave_no > 0) && (slave != (slave_t *)bond) ) {
-		slave = slave->prev;
-		slave_no--;
-	} 
-	start_at = slave;
-
-	do {
-		if (IS_UP(slave->dev)
-		    && (slave->link == BOND_LINK_UP)
-		    && (slave->state == BOND_STATE_ACTIVE)) {
-
-			skb->dev = slave->dev;
-			skb->priority = 1;
-			dev_queue_xmit(skb);
-
-			read_unlock_irqrestore(&bond->lock, flags);
-			return 0;
-		}
-	} while ((slave = slave->next) != start_at);
-
-	/* no suitable interface, frame not sent */
-	dev_kfree_skb(skb);
-	read_unlock_irqrestore(&bond->lock, flags);
-	return 0;
-}
-
-/* 
- * in active-backup mode, we know that bond->current_slave is always valid if
- * the bond has a usable interface.
- */
-static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *dev)
-{
-	struct bonding *bond = (struct bonding *) dev->priv;
-	unsigned long flags;
-	int ret;
-
-	if (!IS_UP(dev)) { /* bond down */
-		dev_kfree_skb(skb);
-		return 0;
-	}
-
-	/* if we are sending arp packets, try to at least 
-	   identify our own ip address */
-	if ( (arp_interval > 0) && (my_ip == 0) &&
-		(skb->protocol == __constant_htons(ETH_P_ARP) ) ) {
-		char *the_ip = (((char *)skb->data)) 
-				+ sizeof(struct ethhdr)  
-				+ sizeof(struct arphdr) + 
-				ETH_ALEN;
-		memcpy(&my_ip, the_ip, 4);
-	}
-
-	/* if we are sending arp packets and don't know 
-	 * the target hw address, save it so we don't need 
-	 * to use a broadcast address.
-	 * don't do this if in active backup mode because the slaves must 
-	 * receive packets to stay up, and the only ones they receive are 
-	 * broadcasts. 
-	 */
-	if ( (bond_mode != BOND_MODE_ACTIVEBACKUP) && 
-             (arp_ip_count == 1) &&
-	     (arp_interval > 0) && (arp_target_hw_addr == NULL) &&
-	     (skb->protocol == __constant_htons(ETH_P_IP) ) ) {
-		struct ethhdr *eth_hdr = 
-			(struct ethhdr *) (((char *)skb->data));
-		struct iphdr *ip_hdr = (struct iphdr *)(eth_hdr + 1);
-
-		if (arp_target[0] == ip_hdr->daddr) {
-			arp_target_hw_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
-			if (arp_target_hw_addr != NULL)
-				memcpy(arp_target_hw_addr, eth_hdr->h_dest, ETH_ALEN);
-		}
-	}
-
-	read_lock_irqsave(&bond->lock, flags);
-
-	read_lock(&bond->ptrlock);
-	if (bond->current_slave != NULL) { /* one usable interface */
-		skb->dev = bond->current_slave->dev;
-		read_unlock(&bond->ptrlock);
-		skb->priority = 1;
-		ret = dev_queue_xmit(skb);
-		read_unlock_irqrestore(&bond->lock, flags);
-		return 0;
-	}
-	else {
-		read_unlock(&bond->ptrlock);
-	}
-
-	/* no suitable interface, frame not sent */
-#ifdef BONDING_DEBUG
-	printk(KERN_INFO "There was no suitable interface, so we don't transmit\n");
-#endif
-	dev_kfree_skb(skb);
-	read_unlock_irqrestore(&bond->lock, flags);
-	return 0;
-}
-
-static struct net_device_stats *bond_get_stats(struct net_device *dev)
-{
-	bonding_t *bond = dev->priv;
-	struct net_device_stats *stats = bond->stats, *sstats;
-	slave_t *slave;
-	unsigned long flags;
-
-	memset(bond->stats, 0, sizeof(struct net_device_stats));
-
-	read_lock_irqsave(&bond->lock, flags);
-
-	for (slave = bond->prev; slave != (slave_t *)bond; slave = slave->prev) {
-		sstats = slave->dev->get_stats(slave->dev);
- 
-		stats->rx_packets += sstats->rx_packets;
-		stats->rx_bytes += sstats->rx_bytes;
-		stats->rx_errors += sstats->rx_errors;
-		stats->rx_dropped += sstats->rx_dropped;
-
-		stats->tx_packets += sstats->tx_packets;
-		stats->tx_bytes += sstats->tx_bytes;
-		stats->tx_errors += sstats->tx_errors;
-		stats->tx_dropped += sstats->tx_dropped;
-
-		stats->multicast += sstats->multicast;
-		stats->collisions += sstats->collisions;
-
-		stats->rx_length_errors += sstats->rx_length_errors;
-		stats->rx_over_errors += sstats->rx_over_errors;
-		stats->rx_crc_errors += sstats->rx_crc_errors;
-		stats->rx_frame_errors += sstats->rx_frame_errors;
-		stats->rx_fifo_errors += sstats->rx_fifo_errors;	
-		stats->rx_missed_errors += sstats->rx_missed_errors;
-	
-		stats->tx_aborted_errors += sstats->tx_aborted_errors;
-		stats->tx_carrier_errors += sstats->tx_carrier_errors;
-		stats->tx_fifo_errors += sstats->tx_fifo_errors;
-		stats->tx_heartbeat_errors += sstats->tx_heartbeat_errors;
-		stats->tx_window_errors += sstats->tx_window_errors;
-
-	}
-
-	read_unlock_irqrestore(&bond->lock, flags);
-	return stats;
-}
-
-static int bond_get_info(char *buf, char **start, off_t offset, int length)
-{
-	bonding_t *bond = these_bonds;
-	int len = 0;
-	off_t begin = 0;
-	u16 link;
-	slave_t *slave = NULL;
-	unsigned long flags;
-
-	while (bond != NULL) {
-		/*
-		 * This function locks the mutex, so we can't lock it until 
-		 * afterwards
-		 */
-		link = bond_check_mii_link(bond);
-
-		len += sprintf(buf + len, "Bonding Mode: %s\n",
-			       bond_mode_name());
-
-		if (bond_mode == BOND_MODE_ACTIVEBACKUP) {
-			read_lock_irqsave(&bond->lock, flags);
-			read_lock(&bond->ptrlock);
-			if (bond->current_slave != NULL) {
-				len += sprintf(buf + len, 
-					"Currently Active Slave: %s\n", 
-					bond->current_slave->dev->name);
-			}
-			read_unlock(&bond->ptrlock);
-			read_unlock_irqrestore(&bond->lock, flags);
-		}
-
-		len += sprintf(buf + len, "MII Status: ");
-		len += sprintf(buf + len, 
-				link == BMSR_LSTATUS ? "up\n" : "down\n");
-		len += sprintf(buf + len, "MII Polling Interval (ms): %d\n", 
-				miimon);
-		len += sprintf(buf + len, "Up Delay (ms): %d\n", 
-				updelay * miimon);
-		len += sprintf(buf + len, "Down Delay (ms): %d\n", 
-				downdelay * miimon);
-		len += sprintf(buf + len, "Multicast Mode: %s\n",
-			       multicast_mode_name());
-
-		read_lock_irqsave(&bond->lock, flags);
-		for (slave = bond->prev; slave != (slave_t *)bond; 
-		     slave = slave->prev) {
-			len += sprintf(buf + len, "\nSlave Interface: %s\n", slave->dev->name);
-
-			len += sprintf(buf + len, "MII Status: ");
-
-			len += sprintf(buf + len, 
-				slave->link == BOND_LINK_UP ? 
-				"up\n" : "down\n");
-			len += sprintf(buf + len, "Link Failure Count: %d\n", 
-				slave->link_failure_count);
-		}
-		read_unlock_irqrestore(&bond->lock, flags);
-
-		/*
-		 * Figure out the calcs for the /proc/net interface
-		 */
-		*start = buf + (offset - begin);
-		len -= (offset - begin);
-		if (len > length) {
-			len = length;
-		}
-		if (len < 0) {
-			len = 0;
-		}
-
-
-		bond = bond->next_bond;
-	}
-	return len;
-}
-
-static int bond_event(struct notifier_block *this, unsigned long event, 
-			void *ptr)
-{
-	struct bonding *this_bond = (struct bonding *)these_bonds;
-	struct bonding *last_bond;
-	struct net_device *event_dev = (struct net_device *)ptr;
-
-	/* while there are bonds configured */
-	while (this_bond != NULL) {
-		if (this_bond == event_dev->priv ) {
-			switch (event) {
-			case NETDEV_UNREGISTER:
-				/* 
-				 * remove this bond from a linked list of 
-				 * bonds 
-				 */
-				if (this_bond == these_bonds) {
-					these_bonds = this_bond->next_bond;
-				} else {
-					for (last_bond = these_bonds; 
-					     last_bond != NULL; 
-					     last_bond = last_bond->next_bond) {
-						if (last_bond->next_bond == 
-						    this_bond) {
-							last_bond->next_bond = 
-							this_bond->next_bond;
-						}
-					}
-				}
-				return NOTIFY_DONE;
-
-			default:
-				return NOTIFY_DONE;
-			}
-		} else if (this_bond->device == event_dev->master) {
-			switch (event) {
-			case NETDEV_UNREGISTER:
-				bond_release(this_bond->device, event_dev);
-				break;
-			}
-			return NOTIFY_DONE;
-		}
-		this_bond = this_bond->next_bond;
-	}
-	return NOTIFY_DONE;
-}
-
-static struct notifier_block bond_netdev_notifier = {
-	notifier_call: bond_event,
-};
-
-static int __init bond_init(struct net_device *dev)
-{
-	bonding_t *bond, *this_bond, *last_bond;
-	int count;
-
-#ifdef BONDING_DEBUG
-	printk (KERN_INFO "Begin bond_init for %s\n", dev->name);
-#endif
-	bond = kmalloc(sizeof(struct bonding), GFP_KERNEL);
-	if (bond == NULL) {
-		return -ENOMEM;
-	}
-	memset(bond, 0, sizeof(struct bonding));
-
-	/* initialize rwlocks */
-	rwlock_init(&bond->lock);
-	rwlock_init(&bond->ptrlock);
-	
-	bond->stats = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL);
-	if (bond->stats == NULL) {
-		kfree(bond);
-		return -ENOMEM;
-	}
-	memset(bond->stats, 0, sizeof(struct net_device_stats));
-
-	bond->next = bond->prev = (slave_t *)bond;
-	bond->current_slave = NULL;
-	bond->current_arp_slave = NULL;
-	bond->device = dev;
-	dev->priv = bond;
-
-	/* Initialize the device structure. */
-	switch (bond_mode) {
-	case BOND_MODE_ACTIVEBACKUP:
-		dev->hard_start_xmit = bond_xmit_activebackup;
-		break;
-	case BOND_MODE_ROUNDROBIN:
-		dev->hard_start_xmit = bond_xmit_roundrobin;
-		break;
-	case BOND_MODE_XOR:
-		dev->hard_start_xmit = bond_xmit_xor;
-		break;
-	case BOND_MODE_BROADCAST:
-		dev->hard_start_xmit = bond_xmit_broadcast;
-		break;
-	default:
-		printk(KERN_ERR "Unknown bonding mode %d\n", bond_mode);
-		kfree(bond->stats);
-		kfree(bond);
-		return -EINVAL;
-	}
-
-	dev->get_stats = bond_get_stats;
-	dev->open = bond_open;
-	dev->stop = bond_close;
-	dev->set_multicast_list = set_multicast_list;
-	dev->do_ioctl = bond_ioctl;
-
-	/* 
-	 * Fill in the fields of the device structure with ethernet-generic 
-	 * values. 
-	 */
-
-	ether_setup(dev);
-
-	dev->tx_queue_len = 0;
-	dev->flags |= IFF_MASTER|IFF_MULTICAST;
-#ifdef CONFIG_NET_FASTROUTE
-	dev->accept_fastpath = bond_accept_fastpath;
-#endif
-
-	printk(KERN_INFO "%s registered with", dev->name);
-	if (miimon > 0) {
-		printk(" MII link monitoring set to %d ms", miimon);
-		updelay /= miimon;
-		downdelay /= miimon;
-	} else {
-		printk("out MII link monitoring");
-	}
-	printk(", in %s mode.\n", bond_mode_name());
-
-	printk(KERN_INFO "%s registered with", dev->name);
-	if (arp_interval > 0) {
-		printk(" ARP monitoring set to %d ms with %d target(s):", 
-			arp_interval, arp_ip_count);
-		for (count=0 ; count<arp_ip_count ; count++)
-                        printk (" %s", arp_ip_target[count]);
-		printk("\n");
-	} else {
-		printk("out ARP monitoring\n");
-	}
-
-#ifdef CONFIG_PROC_FS
-	bond->bond_proc_dir = proc_mkdir(dev->name, proc_net);
-	if (bond->bond_proc_dir == NULL) {
-		printk(KERN_ERR "%s: Cannot init /proc/net/%s/\n", 
-			dev->name, dev->name);
-		kfree(bond->stats);
-		kfree(bond);
-		return -ENOMEM;
-	}
-	bond->bond_proc_info_file = 
-		create_proc_info_entry("info", 0, bond->bond_proc_dir, 
-					bond_get_info);
-	if (bond->bond_proc_info_file == NULL) {
-		printk(KERN_ERR "%s: Cannot init /proc/net/%s/info\n", 
-			dev->name, dev->name);
-		remove_proc_entry(dev->name, proc_net);
-		kfree(bond->stats);
-		kfree(bond);
-		return -ENOMEM;
-	}
-#endif /* CONFIG_PROC_FS */
-
-	if (first_pass == 1) {
-		these_bonds = bond;
-		register_netdevice_notifier(&bond_netdev_notifier);
-		first_pass = 0;
-	} else {
-		last_bond = these_bonds;
-		this_bond = these_bonds->next_bond;
-		while (this_bond != NULL) {
-			last_bond = this_bond;
-			this_bond = this_bond->next_bond;
-		}
-		last_bond->next_bond = bond;
-	} 
-
-	return 0;
-}
-
-/*
-static int __init bond_probe(struct net_device *dev)
-{
-	bond_init(dev);
-	return 0;
-}
- */
-
-/*
- * Convert string input module parms.  Accept either the
- * number of the mode or its string name.
- */
-static inline int
-bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl)
-{
-	int i;
-
-	for (i = 0; tbl[i].modename != NULL; i++) {
-		if ((isdigit(*mode_arg) &&
-		    tbl[i].mode == simple_strtol(mode_arg, NULL, 0)) ||
-		    (0 == strncmp(mode_arg, tbl[i].modename,
-				  strlen(tbl[i].modename)))) {
-			return tbl[i].mode;
-		}
-	}
-
-	return -1;
-}
-
-
-static int __init bonding_init(void)
-{
-	int no;
-	int err;
-
-	/* Find a name for this unit */
-	static struct net_device *dev_bond = NULL;
-
-	printk(KERN_INFO "%s", version);
-
-	/*
-	 * Convert string parameters.
-	 */
-	if (mode) {
-		bond_mode = bond_parse_parm(mode, bond_mode_tbl);
-		if (bond_mode == -1) {
-			printk(KERN_WARNING
-			       "bonding_init(): Invalid bonding mode \"%s\"\n",
-			       mode == NULL ? "NULL" : mode);
-			return -EINVAL;
-		}
-	}
-
-	if (multicast) {
-		multicast_mode = bond_parse_parm(multicast, bond_mc_tbl);
-		if (multicast_mode == -1) {
-			printk(KERN_WARNING 
-		       "bonding_init(): Invalid multicast mode \"%s\"\n",
-			       multicast == NULL ? "NULL" : multicast);
-			return -EINVAL;
-		}
-	}
-
-	if (max_bonds < 1 || max_bonds > INT_MAX) {
-		printk(KERN_WARNING 
-		       "bonding_init(): max_bonds (%d) not in range %d-%d, "
-		       "so it was reset to BOND_DEFAULT_MAX_BONDS (%d)",
-		       max_bonds, 1, INT_MAX, BOND_DEFAULT_MAX_BONDS);
-		max_bonds = BOND_DEFAULT_MAX_BONDS;
-	}
-	dev_bond = dev_bonds = kmalloc(max_bonds*sizeof(struct net_device), 
-					GFP_KERNEL);
-	if (dev_bond == NULL) {
-		return -ENOMEM;
-	}
-	memset(dev_bonds, 0, max_bonds*sizeof(struct net_device));
-
-	if (miimon < 0) {
-		printk(KERN_WARNING 
-		       "bonding_init(): miimon module parameter (%d), "
-		       "not in range 0-%d, so it was reset to %d\n",
-		       miimon, INT_MAX, BOND_LINK_MON_INTERV);
-		miimon = BOND_LINK_MON_INTERV;
-	}
-
-	if (updelay < 0) {
-		printk(KERN_WARNING 
-		       "bonding_init(): updelay module parameter (%d), "
-		       "not in range 0-%d, so it was reset to 0\n",
-		       updelay, INT_MAX);
-		updelay = 0;
-	}
-
-	if (downdelay < 0) {
-		printk(KERN_WARNING 
-		       "bonding_init(): downdelay module parameter (%d), "
-		       "not in range 0-%d, so it was reset to 0\n",
-		       downdelay, INT_MAX);
-		downdelay = 0;
-	}
-
-	if (miimon == 0) {
-		if ((updelay != 0) || (downdelay != 0)) {
-			/* just warn the user the up/down delay will have
-			 * no effect since miimon is zero...
-			 */
-			printk(KERN_WARNING 
-		               "bonding_init(): miimon module parameter not "
-			       "set and updelay (%d) or downdelay (%d) module "
-			       "parameter is set; updelay and downdelay have "
-			       "no effect unless miimon is set\n",
-		               updelay, downdelay);
-		}
-	} else {
-		/* don't allow arp monitoring */
-		if (arp_interval != 0) {
-			printk(KERN_WARNING 
-		               "bonding_init(): miimon (%d) and arp_interval "
-			       "(%d) can't be used simultaneously, "
-			       "disabling ARP monitoring\n",
-		               miimon, arp_interval);
-			arp_interval = 0;
-		}
-
-		if ((updelay % miimon) != 0) {
-			/* updelay will be rounded in bond_init() when it
-			 * is divided by miimon, we just inform user here
-			 */
-			printk(KERN_WARNING 
-		               "bonding_init(): updelay (%d) is not a multiple "
-			       "of miimon (%d), updelay rounded to %d ms\n",
-		               updelay, miimon, (updelay / miimon) * miimon);
-		}
-
-		if ((downdelay % miimon) != 0) {
-			/* downdelay will be rounded in bond_init() when it
-			 * is divided by miimon, we just inform user here
-			 */
-			printk(KERN_WARNING 
-		               "bonding_init(): downdelay (%d) is not a "
-			       "multiple of miimon (%d), downdelay rounded "
-			       "to %d ms\n",
-		               downdelay, miimon, 
-			       (downdelay / miimon) * miimon);
-		}
-	}
-
-	if (arp_interval < 0) {
-		printk(KERN_WARNING 
-		       "bonding_init(): arp_interval module parameter (%d), "
-		       "not in range 0-%d, so it was reset to %d\n",
-		       arp_interval, INT_MAX, BOND_LINK_ARP_INTERV);
-		arp_interval = BOND_LINK_ARP_INTERV;
-	}
-
-        for (arp_ip_count=0 ;
-             (arp_ip_count < MAX_ARP_IP_TARGETS) && arp_ip_target[arp_ip_count];
-              arp_ip_count++ ) {
-                /* TODO: check and log bad ip address */
-                if (my_inet_aton(arp_ip_target[arp_ip_count],
-                                 &arp_target[arp_ip_count]) == 0) {
-                        printk(KERN_WARNING
-                               "bonding_init(): bad arp_ip_target module "
-                               "parameter (%s), ARP monitoring will not be "
-                               "performed\n",
-                               arp_ip_target[arp_ip_count]);
-                        arp_interval = 0;
-		}
-        }
-
-
-	if ( (arp_interval > 0) && (arp_ip_count==0)) {
-		/* don't allow arping if no arp_ip_target given... */
-		printk(KERN_WARNING 
-		       "bonding_init(): arp_interval module parameter "
-		       "(%d) specified without providing an arp_ip_target "
-		       "parameter, arp_interval was reset to 0\n",
-		       arp_interval);
-		arp_interval = 0;
-	}
-
-	if ((miimon == 0) && (arp_interval == 0)) {
-		/* miimon and arp_interval not set, we need one so things
-		 * work as expected, see bonding.txt for details
-		 */
-		printk(KERN_ERR 
-		       "bonding_init(): either miimon or "
-		       "arp_interval and arp_ip_target module parameters "
-		       "must be specified, otherwise bonding will not detect "
-		       "link failures! see bonding.txt for details.\n");
-	}
-
-	if ((primary != NULL) && (bond_mode != BOND_MODE_ACTIVEBACKUP)){
-		/* currently, using a primary only makes sence 
-		 * in active backup mode 
-		 */
-		printk(KERN_WARNING 
-		       "bonding_init(): %s primary device specified but has "
-		       " no effect in %s mode\n",
-		       primary, bond_mode_name());
-		primary = NULL;
-	}
-
-
-	for (no = 0; no < max_bonds; no++) {
-		dev_bond->init = bond_init;
-	
-		err = dev_alloc_name(dev_bond,"bond%d");
-		if (err < 0) {
-			kfree(dev_bonds);
-			return err;
-		}
-		SET_MODULE_OWNER(dev_bond);
-		if (register_netdev(dev_bond) != 0) {
-			kfree(dev_bonds);
-			return -EIO;
-		}	
-		dev_bond++;
-	}
-	return 0;
-}
-
-static void __exit bonding_exit(void)
-{
-	struct net_device *dev_bond = dev_bonds;
-	struct bonding *bond;
-	int no;
-
-	unregister_netdevice_notifier(&bond_netdev_notifier);
-		 
-	for (no = 0; no < max_bonds; no++) {
-
-#ifdef CONFIG_PROC_FS
-		bond = (struct bonding *) dev_bond->priv;
-		remove_proc_entry("info", bond->bond_proc_dir);
-		remove_proc_entry(dev_bond->name, proc_net);
-#endif
-		unregister_netdev(dev_bond);
-		kfree(bond->stats);
-		kfree(dev_bond->priv);
-		
-		dev_bond->priv = NULL;
-		dev_bond++;
-	}
-	kfree(dev_bonds);
-}
-
-module_init(bonding_init);
-module_exit(bonding_exit);
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION(DRV_DESCRIPTION ", v" DRV_VERSION);
-
-/*
- * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
- * End:
- */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/cs89x0.c linux-2.4.22-pre2/drivers/net/cs89x0.c
--- linux-2.4.21/drivers/net/cs89x0.c	2002-08-03 00:39:44.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/cs89x0.c	2003-06-26 21:43:31.000000000 +0000
@@ -1629,16 +1629,21 @@
 }
 
 
-static int set_mac_address(struct net_device *dev, void *addr)
+static int set_mac_address(struct net_device *dev, void *p)
 {
 	int i;
+	struct sockaddr *addr = p;
+
 
 	if (netif_running(dev))
 		return -EBUSY;
+
+	memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+
 	if (net_debug) {
 		printk("%s: Setting MAC address to ", dev->name);
-		for (i = 0; i < 6; i++)
-			printk(" %2.2x", dev->dev_addr[i] = ((unsigned char *)addr)[i]);
+		for (i = 0; i < dev->addr_len; i++)
+			printk(" %2.2x", dev->dev_addr[i]);
 		printk(".\n");
 	}
 	/* set the Ethernet address */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/dgrs.c linux-2.4.22-pre2/drivers/net/dgrs.c
--- linux-2.4.21/drivers/net/dgrs.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/dgrs.c	2003-06-26 21:43:11.000000000 +0000
@@ -1279,8 +1279,10 @@
 	dev->init = dgrs_probe1;
 	SET_MODULE_OWNER(dev);
 	ether_setup(dev);
-	if (register_netdev(dev) != 0)
+	if (register_netdev(dev) != 0) {
+		kfree(dev);
 		return -EIO;
+	}
 
 	priv->next_dev = dgrs_root_dev;
 	dgrs_root_dev = dev;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/dl2k.h linux-2.4.22-pre2/drivers/net/dl2k.h
--- linux-2.4.21/drivers/net/dl2k.h	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/dl2k.h	2003-06-26 21:43:17.000000000 +0000
@@ -243,7 +243,6 @@
 	VLANTagInsert = 0x0000000010000000,
 	TFDDone = 0x80000000,
 	VIDShift = 32,
-	CFI = 0x0000100000000000,
 	UsePriorityShift = 48,
 };
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/e100/e100.h linux-2.4.22-pre2/drivers/net/e100/e100.h
--- linux-2.4.21/drivers/net/e100/e100.h	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/e100/e100.h	2003-06-26 21:43:19.000000000 +0000
@@ -60,7 +60,14 @@
 #include <linux/if_vlan.h>
 #include <linux/mii.h>
 
-#define E100_REGS_LEN 1
+#define E100_CABLE_UNKNOWN	0
+#define E100_CABLE_OK		1		
+#define E100_CABLE_OPEN_NEAR	2	/* Open Circuit Near End  */
+#define E100_CABLE_OPEN_FAR	3	/* Open Circuit Far End   */
+#define E100_CABLE_SHORT_NEAR	4	/* Short Circuit Near End */
+#define E100_CABLE_SHORT_FAR	5	/* Short Circuit Far End  */
+
+#define E100_REGS_LEN 2
 /*
  *  Configure parameters for buffers per controller.
  *  If the machine this is being used on is a faster machine (i.e. > 150MHz)
@@ -105,8 +112,6 @@
 #define E100_MAX_CU_IDLE_WAIT	50	/* Max udelays in wait_cus_idle */
 
 /* HWI feature related constant */
-#define HWI_MAX_LOOP                    100
-#define MAX_SAME_RESULTS		3
 #define HWI_REGISTER_GRANULARITY        80	/* register granularity = 80 Cm */
 #define HWI_NEAR_END_BOUNDARY           1000	/* Near end is defined as < 10 meters */
 
@@ -942,7 +947,6 @@
 #ifdef CONFIG_PM
 	u32 pci_state[16];
 #endif
-	char ifname[IFNAMSIZ];
 #ifdef E100_CU_DEBUG	
 	u8 last_cmd;
 	u8 last_sub_cmd;
@@ -956,7 +960,10 @@
 #define E100_SPEED_100_FULL 4
 
 /********* function prototypes *************/
+extern int e100_open(struct net_device *);
+extern int e100_close(struct net_device *);
 extern void e100_isolate_driver(struct e100_private *bdp);
+extern unsigned char e100_hw_init(struct e100_private *);
 extern void e100_sw_reset(struct e100_private *bdp, u32 reset_cmd);
 extern u8 e100_start_cu(struct e100_private *bdp, tcb_t *tcb);
 extern void e100_free_non_tx_cmd(struct e100_private *bdp,
@@ -981,14 +988,13 @@
 #define TEST_TIMEOUT		0x08
 
 enum test_offsets {
-	E100_EEPROM_TEST_FAIL = 0,
-	E100_CHIP_TIMEOUT,
-	E100_ROM_TEST_FAIL,
-	E100_REG_TEST_FAIL,
-	E100_MAC_TEST_FAIL,
-	E100_LPBK_MAC_FAIL,
-	E100_LPBK_PHY_FAIL,
-	E100_MAX_TEST_RES
+	test_link,
+	test_eeprom,
+	test_self_test,
+	test_loopback_mac,
+	test_loopback_phy,
+	cable_diag,
+	max_test_res,  /* must be last */
 };
 
 #endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/e100/e100_main.c linux-2.4.22-pre2/drivers/net/e100/e100_main.c
--- linux-2.4.21/drivers/net/e100/e100_main.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/e100/e100_main.c	2003-06-26 21:43:11.000000000 +0000
@@ -46,6 +46,24 @@
 
 /* Change Log
  * 
+ * 2.3.13       05/08/03
+ * o Feature remove: /proc/net/PRO_LAN_Adapters support gone completely
+ * o Feature remove: IDIAG support (use ethtool -t instead)
+ * o Cleanup: fixed spelling mistakes found by community
+ * o Feature add: ethtool cable diag test
+ * o Feature add: ethtool parameter support (ring size, xsum, flow ctrl)
+ * o Cleanup: move e100_asf_enable under CONFIG_PM to avoid warning
+ *   [Stephen Rothwell (sfr@canb.auug.org.au)]
+ * o Bug fix: don't call any netif_carrier_* until netdev registered.
+ *   [Andrew Morton (akpm@digeo.com)]
+ * o Cleanup: replace (skb->len - skb->data_len) with skb_headlen(skb)
+ *   [jmorris@intercode.com.au]
+ * o Bug fix: cleanup of Tx skbs after running ethtool diags
+ * o Bug fix: incorrect reporting of ethtool diag overall results
+ * o Bug fix: must hold xmit_lock before stopping queue in ethtool
+ *   operations that require reset h/w and driver structures.
+ * o Bug fix: statistic command failure would stop statistic collection.
+ * 
  * 2.2.21	02/11/03
  * o Removed marketing brand strings. Instead, Using generic string 
  *   "Intel(R) PRO/100 Network Connection" for all adapters.
@@ -61,21 +79,6 @@
  * o New feature: added ICH5 support
  * 
  * 2.1.27	11/20/02
- *   o Bug fix: Device command timeout due to SMBus processing during init
- *   o Bug fix: Not setting/clearing I (Interrupt) bit in tcb correctly
- *   o Bug fix: Not using EEPROM WoL setting as default in ethtool
- *   o Bug fix: Not able to set autoneg on using ethtool when interface down
- *   o Bug fix: Not able to change speed/duplex using ethtool/mii
- *     when interface up
- *   o Bug fix: Ethtool shows autoneg on when forced to 100/Full
- *   o Bug fix: Compiler error when CONFIG_PROC_FS not defined
- *   o Bug fix: 2.5.44 e100 doesn't load with preemptive kernel enabled
- *     (sleep while holding spinlock)
- *   o Bug fix: 2.1.24-k1 doesn't display complete statistics
- *   o Bug fix: System panic due to NULL watchdog timer dereference during
- *     ifconfig down, rmmod and insmod
- *
- * 2.1.24       10/7/02
  */
  
 #include <linux/config.h>
@@ -121,14 +124,13 @@
 extern u32 e100_run_diag(struct net_device *dev, u64 *test_info, u32 flags);
 static int e100_ethtool_test(struct net_device *, struct ifreq *);
 static int e100_ethtool_gstrings(struct net_device *, struct ifreq *);
-static char *test_strings[] = {
-	"E100_EEPROM_TEST_FAIL",
-	"E100_CHIP_TIMEOUT",
-	"E100_ROM_TEST_FAIL",
-	"E100_REG_TEST_FAIL",
-	"E100_MAC_TEST_FAIL",
-	"E100_LPBK_MAC_FAIL",
-	"E100_LPBK_PHY_FAIL"
+static char test_strings[][ETH_GSTRING_LEN] = {
+	"Link test     (on/offline)",
+	"Eeprom test   (on/offline)",
+	"Self test        (offline)",
+	"Mac loopback     (offline)",
+	"Phy loopback     (offline)",
+	"Cable diagnostic (offline)"
 };
 
 static int e100_ethtool_led_blink(struct net_device *, struct ifreq *);
@@ -139,10 +141,10 @@
 						  nxmit_cb_entry_t *);
 static void e100_free_nontx_list(struct e100_private *);
 static void e100_non_tx_background(unsigned long);
-
+static inline void e100_tx_skb_free(struct e100_private *bdp, tcb_t *tcb);
 /* Global Data structures and variables */
 char e100_copyright[] __devinitdata = "Copyright (c) 2003 Intel Corporation";
-char e100_driver_version[]="2.2.21-k1";
+char e100_driver_version[]="2.3.13-k1";
 const char *e100_full_driver_name = "Intel(R) PRO/100 Network Driver";
 char e100_short_driver_name[] = "e100";
 static int e100nics = 0;
@@ -155,6 +157,7 @@
 static int e100_notify_reboot(struct notifier_block *, unsigned long event, void *ptr);
 static int e100_suspend(struct pci_dev *pcid, u32 state);
 static int e100_resume(struct pci_dev *pcid);
+static unsigned char e100_asf_enabled(struct e100_private *bdp);
 struct notifier_block e100_notifier_reboot = {
         .notifier_call  = e100_notify_reboot,
         .next           = NULL,
@@ -182,8 +185,6 @@
 static u8 e100_D101M_checksum(struct e100_private *, struct sk_buff *);
 static u8 e100_D102_check_checksum(rfd_t *);
 static int e100_ioctl(struct net_device *, struct ifreq *, int);
-static int e100_open(struct net_device *);
-static int e100_close(struct net_device *);
 static int e100_change_mtu(struct net_device *, int);
 static int e100_xmit_frame(struct sk_buff *, struct net_device *);
 static unsigned char e100_init(struct e100_private *);
@@ -193,7 +194,6 @@
 static void e100intr(int, void *, struct pt_regs *);
 static void e100_print_brd_conf(struct e100_private *);
 static void e100_set_multi(struct net_device *);
-void e100_set_speed_duplex(struct e100_private *);
 
 static u8 e100_pci_setup(struct pci_dev *, struct e100_private *);
 static u8 e100_sw_init(struct e100_private *);
@@ -215,7 +215,6 @@
 
 static unsigned char e100_clr_cntrs(struct e100_private *);
 static unsigned char e100_load_microcode(struct e100_private *);
-static unsigned char e100_hw_init(struct e100_private *);
 static unsigned char e100_setup_iaaddr(struct e100_private *, u8 *);
 static unsigned char e100_update_stats(struct e100_private *bdp);
 
@@ -228,7 +227,6 @@
 				 char *);
 unsigned char e100_wait_exec_cmplx(struct e100_private *, u32, u8, u8);
 void e100_exec_cmplx(struct e100_private *, u32, u8);
-static unsigned char e100_asf_enabled(struct e100_private *bdp);
 
 /**
  * e100_get_rx_struct - retrieve cell to hold skb buff from the pool
@@ -638,25 +636,7 @@
 	} else {
 		bdp->rfd_size = 16;
 	}
-	e100_check_options(e100nics, bdp);
 
-	if (!e100_init(bdp)) {
-		printk(KERN_ERR "e100: Failed to initialize, instance #%d\n",
-		       e100nics);
-		rc = -ENODEV;
-		goto err_pci;
-	}
-
-	/* Check if checksum is valid */
-	cal_checksum = e100_eeprom_calculate_chksum(bdp);
-	read_checksum = e100_eeprom_read(bdp, (bdp->eeprom_size - 1));
-	if (cal_checksum != read_checksum) {
-                printk(KERN_ERR "e100: Corrupted EEPROM on instance #%d\n",
-		       e100nics);
-                rc = -ENODEV;
-                goto err_pci;
-	}
-	
 	dev->vlan_rx_register = e100_vlan_rx_register;
 	dev->vlan_rx_add_vid = e100_vlan_rx_add_vid;
 	dev->vlan_rx_kill_vid = e100_vlan_rx_kill_vid;
@@ -674,15 +654,32 @@
 	dev->features = NETIF_F_SG | NETIF_F_HW_CSUM |
 			NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
 		
-	e100nics++;
-
-	e100_get_speed_duplex_caps(bdp);
-
 	if ((rc = register_netdev(dev)) != 0) {
 		goto err_pci;
 	}
-        memcpy(bdp->ifname, dev->name, IFNAMSIZ);
-        bdp->ifname[IFNAMSIZ-1] = 0;	
+
+	e100_check_options(e100nics, bdp);
+
+	if (!e100_init(bdp)) {
+		printk(KERN_ERR "e100: Failed to initialize, instance #%d\n",
+		       e100nics);
+		rc = -ENODEV;
+		goto err_unregister_netdev;
+	}
+
+	/* Check if checksum is valid */
+	cal_checksum = e100_eeprom_calculate_chksum(bdp);
+	read_checksum = e100_eeprom_read(bdp, (bdp->eeprom_size - 1));
+	if (cal_checksum != read_checksum) {
+                printk(KERN_ERR "e100: Corrupted EEPROM on instance #%d\n",
+		       e100nics);
+                rc = -ENODEV;
+                goto err_unregister_netdev;
+	}
+	
+	e100nics++;
+
+	e100_get_speed_duplex_caps(bdp);
 
 	printk(KERN_NOTICE
 	       "e100: %s: %s\n", 
@@ -708,6 +705,8 @@
 
 	goto out;
 
+err_unregister_netdev:
+	unregister_netdev(dev);
 err_pci:
 	iounmap(bdp->scb);
 	pci_release_regions(pcid);
@@ -973,7 +972,7 @@
 	}
 }
 
-static int
+int
 e100_open(struct net_device *dev)
 {
 	struct e100_private *bdp;
@@ -1011,7 +1010,11 @@
 
 	mod_timer(&(bdp->watchdog_timer), jiffies + (2 * HZ));
 
-	netif_start_queue(dev);
+	if (dev->flags & IFF_UP)
+		/* Otherwise process may sleep forever */
+		netif_wake_queue(dev);
+	else
+		netif_start_queue(dev);
 
 	e100_start_ru(bdp);
 	if ((rc = request_irq(dev->irq, &e100intr, SA_SHIRQ,
@@ -1032,7 +1035,7 @@
 	return rc;
 }
 
-static int
+int
 e100_close(struct net_device *dev)
 {
 	struct e100_private *bdp = dev->priv;
@@ -1073,7 +1076,8 @@
 		goto exit2;
 	}
 
-	if (!TCBS_AVAIL(bdp->tcb_pool) ||
+	/* tcb list may be empty temporarily during releasing resources */
+	if (!TCBS_AVAIL(bdp->tcb_pool) || (bdp->tcb_phys == 0) ||
 	    (bdp->non_tx_command_state != E100_NON_TX_IDLE)) {
 		notify_stop = true;
 		rc = 1;
@@ -1284,10 +1288,8 @@
 	/* read NIC's part number */
 	e100_rd_pwa_no(bdp);
 
-	if (!e100_hw_init(bdp)) {
-		printk(KERN_ERR "e100: hw init failed\n");
+	if (!e100_hw_init(bdp))
 		return false;
-	}
 	/* Interrupts are enabled after device reset */
 	e100_disable_clear_intr(bdp);
 
@@ -1329,6 +1331,8 @@
 	spin_lock_init(&(bdp->bd_non_tx_lock));
 	spin_lock_init(&(bdp->config_lock));
 	spin_lock_init(&(bdp->mdi_access_lock));
+	/* Initialize configuration data */
+	e100_config_init(bdp);
 
 	return 1;
 }
@@ -1383,11 +1387,11 @@
  *      true - If the adapter was initialized
  *      false - If the adapter failed initialization
  */
-unsigned char __devinit
+unsigned char
 e100_hw_init(struct e100_private *bdp)
 {
 	if (!e100_phy_init(bdp))
-		return false;
+		goto err;
 
 	e100_sw_reset(bdp, PORT_SELECTIVE_RESET);
 
@@ -1397,27 +1401,25 @@
 
 	/* Load the CU BASE (set to 0, because we use linear mode) */
 	if (!e100_wait_exec_cmplx(bdp, 0, SCB_CUC_LOAD_BASE, 0))
-		return false;
+		goto err;
 
 	if (!e100_wait_exec_cmplx(bdp, 0, SCB_RUC_LOAD_BASE, 0))
-		return false;
+		goto err;
 
 	/* Load interrupt microcode  */
 	if (e100_load_microcode(bdp)) {
 		bdp->flags |= DF_UCODE_LOADED;
 	}
 
-	e100_config_init(bdp);
-	if (!e100_config(bdp)) {
-		return false;
-	}
+	if (!e100_config(bdp))
+		goto err;
 
 	if (!e100_setup_iaaddr(bdp, bdp->device->dev_addr))
-		return false;
+		goto err;
 
 	/* Clear the internal counters */
 	if (!e100_clr_cntrs(bdp))
-		return false;
+		goto err;
 
 	/* Change for 82558 enhancement */
 	/* If 82558/9 and if the user has enabled flow control, set up the
@@ -1430,6 +1432,9 @@
 	}
 
 	return true;
+err:
+	printk(KERN_ERR "e100: hw init failed\n");
+	return false;
 }
 
 /**
@@ -1590,9 +1595,22 @@
 void
 e100_free_tcb_pool(struct e100_private *bdp)
 {
+	tcb_t *tcb;
+	int i;
+	/* Return tx skbs */ 
+	for (i = 0; i < bdp->params.TxDescriptors; i++) {
+	  	tcb = bdp->tcb_pool.data;
+		tcb += bdp->tcb_pool.head;
+  		e100_tx_skb_free(bdp, tcb);
+		if (NEXT_TCB_TOUSE(bdp->tcb_pool.head) == bdp->tcb_pool.tail)
+		  	break;
+		bdp->tcb_pool.head = NEXT_TCB_TOUSE(bdp->tcb_pool.head);
+	}
 	pci_free_consistent(bdp->pdev,
 			    sizeof (tcb_t) * bdp->params.TxDescriptors,
 			    bdp->tcb_pool.data, bdp->tcb_phys);
+	bdp->tcb_pool.head = 0;
+	bdp->tcb_pool.tail = 1;	
 	bdp->tcb_phys = 0;
 }
 
@@ -1746,12 +1764,10 @@
 				e100_set_multi(dev);
 			}
 		}
-
-		/* Update the statistics needed by the upper interface */
-		/* This should be the last statistic related command
-		 * as it's async. now */
-		e100_dump_stats_cntrs(bdp);
 	}
+	/* Issue command to dump statistics from device.        */
+	/* Check for command completion on next watchdog timer. */
+	e100_dump_stats_cntrs(bdp);
 
 	wmb();
 
@@ -2199,10 +2215,10 @@
 
 		(tcb->tbd_ptr)->tbd_buf_addr =
 			cpu_to_le32(pci_map_single(bdp->pdev, skb->data,
-						   (skb->len - skb->data_len),
+						   skb_headlen(skb),
 						   PCI_DMA_TODEVICE));
 		(tcb->tbd_ptr)->tbd_buf_cnt =
-			cpu_to_le16(skb->len - skb->data_len);
+			cpu_to_le16(skb_headlen(skb));
 
 		for (i = 0; i < skb_shinfo(skb)->nr_frags;
 		     i++, tbd_arr_ptr++, frag++) {
@@ -2542,6 +2558,7 @@
 	pcmd_complete = e100_cmd_complete_location(bdp);
 	if (*pcmd_complete != le32_to_cpu(DUMP_RST_STAT_COMPLETED) &&
 	    *pcmd_complete != le32_to_cpu(DUMP_STAT_COMPLETED)) {
+		*pcmd_complete = 0;
 		return false;
 	}
 
@@ -3039,23 +3056,6 @@
 	e100_sw_reset(bdp, PORT_SELECTIVE_RESET);
 }
 
-void
-e100_set_speed_duplex(struct e100_private *bdp)
-{
-	int carrier_ok;
-	/* Device may lose link with some siwtches when */
-	/* changing speed/duplex to non-autoneg. e100   */
-	/* needs to remember carrier state in order to  */
-	/* start watchdog timer for recovering link     */
-	if ((carrier_ok = netif_carrier_ok(bdp->device)))
-		e100_isolate_driver(bdp);
-	e100_phy_set_speed_duplex(bdp, true);
-	e100_config_fc(bdp);	/* re-config flow-control if necessary */
-	e100_config(bdp);	
-	if (carrier_ok)
-		e100_deisolate_driver(bdp, false);
-}
-
 static void
 e100_tcb_add_C_bit(struct e100_private *bdp)
 {
@@ -3211,6 +3211,144 @@
 	case ETHTOOL_PHYS_ID:
 		rc = e100_ethtool_led_blink(dev,ifr);
 		break;
+#ifdef	ETHTOOL_GRINGPARAM
+	case ETHTOOL_GRINGPARAM: {
+		struct ethtool_ringparam ering;
+		struct e100_private *bdp = dev->priv;
+		memset((void *) &ering, 0, sizeof(ering));
+		ering.rx_max_pending = E100_MAX_RFD;
+		ering.tx_max_pending = E100_MAX_TCB;
+		ering.rx_pending = bdp->params.RxDescriptors;
+		ering.tx_pending = bdp->params.TxDescriptors;
+		rc = copy_to_user(ifr->ifr_data, &ering, sizeof(ering))
+			? -EFAULT : 0;
+		return rc;
+	}
+#endif
+#ifdef	ETHTOOL_SRINGPARAM
+	case ETHTOOL_SRINGPARAM: {
+		struct ethtool_ringparam ering;
+		struct e100_private *bdp = dev->priv;
+		if (copy_from_user(&ering, ifr->ifr_data, sizeof(ering)))
+			return -EFAULT;
+		if (ering.rx_pending > E100_MAX_RFD 
+		    || ering.rx_pending < E100_MIN_RFD)
+			return -EINVAL;
+		if (ering.tx_pending > E100_MAX_TCB 
+		    || ering.tx_pending < E100_MIN_TCB)
+			return -EINVAL;
+		if (netif_running(dev)) {
+			spin_lock_bh(&dev->xmit_lock);
+			e100_close(dev);
+			spin_unlock_bh(&dev->xmit_lock);
+			/* Use new values to open interface */
+			bdp->params.RxDescriptors = ering.rx_pending;
+			bdp->params.TxDescriptors = ering.tx_pending;
+			e100_hw_init(bdp);
+			e100_open(dev);
+		}
+		else {
+			bdp->params.RxDescriptors = ering.rx_pending;
+			bdp->params.TxDescriptors = ering.tx_pending;
+		}
+		return 0;
+	}
+#endif
+#ifdef	ETHTOOL_GPAUSEPARAM
+	case ETHTOOL_GPAUSEPARAM: {
+		struct ethtool_pauseparam epause;
+		struct e100_private *bdp = dev->priv;
+		memset((void *) &epause, 0, sizeof(epause));
+		if ((bdp->flags & IS_BACHELOR)
+		    && (bdp->params.b_params & PRM_FC)) {
+			epause.autoneg = 1;
+			if (bdp->flags && DF_LINK_FC_CAP) {
+				epause.rx_pause = 1;
+				epause.tx_pause = 1;
+			}
+			if (bdp->flags && DF_LINK_FC_TX_ONLY)
+				epause.tx_pause = 1;
+		}
+		rc = copy_to_user(ifr->ifr_data, &epause, sizeof(epause))
+			? -EFAULT : 0;
+		return rc;
+	}
+#endif
+#ifdef	ETHTOOL_SPAUSEPARAM
+	case ETHTOOL_SPAUSEPARAM: {
+		struct ethtool_pauseparam epause;
+		struct e100_private *bdp = dev->priv;
+		if (!(bdp->flags & IS_BACHELOR))
+			return -EINVAL;
+		if (copy_from_user(&epause, ifr->ifr_data, sizeof(epause)))
+			return -EFAULT;
+		if (epause.autoneg == 1)
+			bdp->params.b_params |= PRM_FC;
+		else
+			bdp->params.b_params &= ~PRM_FC;
+		if (netif_running(dev)) {
+			spin_lock_bh(&dev->xmit_lock);
+			e100_close(dev);
+			spin_unlock_bh(&dev->xmit_lock);
+			e100_hw_init(bdp);
+			e100_open(dev);
+		}
+		return 0;
+	}
+#endif
+#ifdef	ETHTOOL_GRXCSUM
+	case ETHTOOL_GRXCSUM:
+	case ETHTOOL_GTXCSUM:
+	case ETHTOOL_GSG:
+	{	struct ethtool_value eval;
+		struct e100_private *bdp = dev->priv;
+		memset((void *) &eval, 0, sizeof(eval));
+		if ((ecmd.cmd == ETHTOOL_GRXCSUM) 
+		    && (bdp->params.b_params & PRM_XSUMRX))
+			eval.data = 1;
+		else
+			eval.data = 0;
+		rc = copy_to_user(ifr->ifr_data, &eval, sizeof(eval))
+			? -EFAULT : 0;
+		return rc;
+	}
+#endif
+#ifdef	ETHTOOL_SRXCSUM
+	case ETHTOOL_SRXCSUM:
+	case ETHTOOL_STXCSUM:
+	case ETHTOOL_SSG:
+	{	struct ethtool_value eval;
+		struct e100_private *bdp = dev->priv;
+		if (copy_from_user(&eval, ifr->ifr_data, sizeof(eval)))
+			return -EFAULT;
+		if (ecmd.cmd == ETHTOOL_SRXCSUM) {
+			if (eval.data == 1) { 
+				if (bdp->rev_id >= D101MA_REV_ID)
+					bdp->params.b_params |= PRM_XSUMRX;
+				else
+					return -EINVAL;
+			} else {
+				if (bdp->rev_id >= D101MA_REV_ID)
+					bdp->params.b_params &= ~PRM_XSUMRX;
+				else
+					return 0;
+			}
+		} else {
+			if (eval.data == 1)
+				return -EINVAL;
+			else
+				return 0;
+		}
+		if (netif_running(dev)) {
+			spin_lock_bh(&dev->xmit_lock);
+			e100_close(dev);
+			spin_unlock_bh(&dev->xmit_lock);
+			e100_hw_init(bdp);
+			e100_open(dev);
+		}
+		return 0;
+	}
+#endif
 	default:
 		break;
 	}			//switch
@@ -3296,7 +3434,13 @@
 	if ((ecmd.autoneg == AUTONEG_ENABLE)
 	    && (bdp->speed_duplex_caps & SUPPORTED_Autoneg)) {
 		bdp->params.e100_speed_duplex = E100_AUTONEG;
-		e100_set_speed_duplex(bdp);
+		if (netif_running(dev)) {
+			spin_lock_bh(&dev->xmit_lock);
+			e100_close(dev);
+			spin_unlock_bh(&dev->xmit_lock);
+			e100_hw_init(bdp);
+			e100_open(dev);
+		}
 	} else {
 		if (ecmd.speed == SPEED_10) {
 			if (ecmd.duplex == DUPLEX_HALF) {
@@ -3327,7 +3471,13 @@
 		if (bdp->speed_duplex_caps & ethtool_new_speed_duplex) {
 			bdp->params.e100_speed_duplex =
 				e100_new_speed_duplex;
-			e100_set_speed_duplex(bdp);
+			if (netif_running(dev)) {
+				spin_lock_bh(&dev->xmit_lock);
+				e100_close(dev);
+				spin_unlock_bh(&dev->xmit_lock);
+				e100_hw_init(bdp);
+				e100_open(dev);
+			}
 		} else {
 			return -EOPNOTSUPP;
 		} 
@@ -3362,14 +3512,14 @@
 	struct ethtool_test *info;
 	int rc = -EFAULT;
 
-	info = kmalloc(sizeof(*info) + E100_MAX_TEST_RES * sizeof(u64),
+	info = kmalloc(sizeof(*info) + max_test_res * sizeof(u64),
 		       GFP_ATOMIC);
 
 	if (!info)
 		return -ENOMEM;
 
 	memset((void *) info, 0, sizeof(*info) +
-				 E100_MAX_TEST_RES * sizeof(u64));
+				 max_test_res * sizeof(u64));
 
 	if (copy_from_user(info, ifr->ifr_data, sizeof(*info)))
 		goto exit;
@@ -3377,7 +3527,7 @@
 	info->flags = e100_run_diag(dev, info->data, info->flags);
 
 	if (!copy_to_user(ifr->ifr_data, info,
-			 sizeof(*info) + E100_MAX_TEST_RES * sizeof(u64)))
+			 sizeof(*info) + max_test_res * sizeof(u64)))
 		rc = 0;
 exit:
 	kfree(info);
@@ -3391,6 +3541,7 @@
 	u32 regs_buff[E100_REGS_LEN];
 	struct ethtool_regs regs = {ETHTOOL_GREGS};
 	void *addr = ifr->ifr_data;
+	u16 mdi_reg;
 
 	if (!capable(CAP_NET_ADMIN))
 		return -EPERM;
@@ -3403,6 +3554,8 @@
 	regs_buff[0] = readb(&(bdp->scb->scb_cmd_hi)) << 24 |
 		readb(&(bdp->scb->scb_cmd_low)) << 16 |
 		readw(&(bdp->scb->scb_status));
+	e100_mdi_read(bdp, MII_NCONFIG, bdp->phy_addr, &mdi_reg);
+	regs_buff[1] = mdi_reg;
 
 	if(copy_to_user(addr, &regs, sizeof(regs)))
 		return -EFAULT;
@@ -3426,7 +3579,13 @@
 
 	if ((bdp->speed_duplex_caps & SUPPORTED_Autoneg) &&
 	    (bdp->params.e100_speed_duplex == E100_AUTONEG)) {
-		e100_set_speed_duplex(bdp);
+		if (netif_running(dev)) {
+			spin_lock_bh(&dev->xmit_lock);
+			e100_close(dev);
+			spin_unlock_bh(&dev->xmit_lock);
+			e100_hw_init(bdp);
+			e100_open(dev);
+		}
 	} else {
 		return -EFAULT;
 	}
@@ -3452,7 +3611,7 @@
 	info.n_stats = E100_STATS_LEN;
 	info.regdump_len  = E100_REGS_LEN * sizeof(u32);
 	info.eedump_len = (bdp->eeprom_size << 1);	
-	info.testinfo_len = E100_MAX_TEST_RES;
+	info.testinfo_len = max_test_res;
 	if (copy_to_user(ifr->ifr_data, &info, sizeof (info)))
 		return -EFAULT;
 
@@ -3802,15 +3961,15 @@
 	switch (info.string_set) {
 	case ETH_SS_TEST: {
 		int ret = 0;
-		if (info.len > E100_MAX_TEST_RES)
-			info.len = E100_MAX_TEST_RES;
+		if (info.len > max_test_res)
+			info.len = max_test_res;
 		strings = kmalloc(info.len * ETH_GSTRING_LEN, GFP_ATOMIC);
 		if (!strings)
 			return -ENOMEM;
 		memset(strings, 0, info.len * ETH_GSTRING_LEN);
 
 		for (i = 0; i < info.len; i++) {
-			sprintf(strings + i * ETH_GSTRING_LEN, "%-31s",
+			sprintf(strings + i * ETH_GSTRING_LEN, "%s",
 				test_strings[i]);
 		}
 		if (copy_to_user(ifr->ifr_data, &info, sizeof (info)))
@@ -3879,7 +4038,13 @@
 					bdp->params.e100_speed_duplex = E100_SPEED_10_FULL;
 				else
 					bdp->params.e100_speed_duplex = E100_SPEED_10_HALF;
-				e100_set_speed_duplex(bdp);
+				if (netif_running(dev)) {
+					spin_lock_bh(&dev->xmit_lock);
+					e100_close(dev);
+					spin_unlock_bh(&dev->xmit_lock);
+					e100_hw_init(bdp);
+					e100_open(dev);
+				}
 		}
 		else 
 			/* Only allows changing speed/duplex */
@@ -4162,7 +4327,6 @@
 
 	return 0;
 }
-#endif /* CONFIG_PM */
 
 /**
  * e100_asf_enabled - checks if ASF is configured on the current adaper
@@ -4188,6 +4352,7 @@
 	}
 	return false;
 }
+#endif /* CONFIG_PM */
 
 #ifdef E100_CU_DEBUG
 unsigned char
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/e100/e100_phy.c linux-2.4.22-pre2/drivers/net/e100/e100_phy.c
--- linux-2.4.21/drivers/net/e100/e100_phy.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/e100/e100_phy.c	2003-06-26 21:43:14.000000000 +0000
@@ -628,8 +628,6 @@
 	u16 control;
 	unsigned long expires;
 
-	e100_phy_reset(bdp);
-
 	bdp->flags |= DF_SPEED_FORCED;
 
 	e100_mdi_read(bdp, MII_BMCR, bdp->phy_addr, &control);
@@ -912,6 +910,10 @@
 	u16 ctrl_reg;
 	ctrl_reg = BMCR_RESET;
 	e100_mdi_write(bdp, MII_BMCR, bdp->phy_addr, ctrl_reg);
+	/* ieee 802.3 : The reset process shall be completed       */
+	/* within 0.5 seconds from the settting of PHY reset bit.  */
+	set_current_state(TASK_UNINTERRUPTIBLE);
+	schedule_timeout(HZ / 2);
 }
 
 unsigned char __devinit
@@ -928,6 +930,7 @@
 	bdp->PhyDelay = 0;
 	bdp->zlock_state = ZLOCK_INITIAL;
 
+	e100_phy_reset(bdp);
 	e100_phy_set_speed_duplex(bdp, false);
 	e100_fix_polarity(bdp);
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/e100/e100_test.c linux-2.4.22-pre2/drivers/net/e100/e100_test.c
--- linux-2.4.21/drivers/net/e100/e100_test.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/e100/e100_test.c	2003-06-26 21:43:11.000000000 +0000
@@ -25,7 +25,7 @@
   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
 *******************************************************************************/
 
-#include "e100.h"
+#include "e100_phy.h"
 #include "e100_config.h"
 
 extern u16 e100_eeprom_read(struct e100_private *, u16);
@@ -46,6 +46,7 @@
 static void e100_diag_loopback_cu_ru_exec(struct e100_private *);
 static u8 e100_diag_check_pkt(u8 *);
 static void e100_diag_loopback_free(struct e100_private *);
+static int e100_cable_diag(struct e100_private *bdp);
 
 #define LB_PACKET_SIZE 1500
 
@@ -60,46 +61,52 @@
 e100_run_diag(struct net_device *dev, u64 *test_info, u32 flags)
 {
 	struct e100_private* bdp = dev->priv;
-	u8 test_result = true;
-
-	e100_isolate_driver(bdp);
+	u8 test_result = 0;
 
+	if (!e100_get_link_state(bdp)) {
+		test_result = ETH_TEST_FL_FAILED;
+		test_info[test_link] = true;
+	}
+	if (!e100_diag_eeprom(dev)) {
+		test_result = ETH_TEST_FL_FAILED;
+		test_info[test_eeprom] = true;
+	}
 	if (flags & ETH_TEST_FL_OFFLINE) {
 		u8 fail_mask;
-		
-		fail_mask = e100_diag_selftest(dev);
-		if (fail_mask) {
-			test_result = false;
-			if (fail_mask & REGISTER_TEST_FAIL)
-				test_info [E100_REG_TEST_FAIL] = true;
-			if (fail_mask & ROM_TEST_FAIL)
-				test_info [E100_ROM_TEST_FAIL] = true;
-			if (fail_mask & SELF_TEST_FAIL)
-				test_info [E100_MAC_TEST_FAIL] = true;
-			if (fail_mask & TEST_TIMEOUT)
-				test_info [E100_CHIP_TIMEOUT] = true;
+		if (netif_running(dev)) {
+			spin_lock_bh(&dev->xmit_lock);
+			e100_close(dev);
+			spin_unlock_bh(&dev->xmit_lock);
+		}
+		if (e100_diag_selftest(dev)) {
+			test_result = ETH_TEST_FL_FAILED;
+			test_info[test_self_test] = true;
 		}
 
 		fail_mask = e100_diag_loopback(dev);
 		if (fail_mask) {
-			test_result = false;
+			test_result = ETH_TEST_FL_FAILED;
 			if (fail_mask & PHY_LOOPBACK)
-				test_info [E100_LPBK_PHY_FAIL] = true;
+				test_info[test_loopback_phy] = true;
 			if (fail_mask & MAC_LOOPBACK)
-				test_info [E100_LPBK_MAC_FAIL] = true;
+				test_info[test_loopback_mac] = true;
 		}
-	}
 
-	if (!e100_diag_eeprom(dev)) {
-		test_result = false;
-		test_info [E100_EEPROM_TEST_FAIL] = true;
+		test_info[cable_diag] = e100_cable_diag(bdp);
+		/* Need hw init regardless of netif_running */
+		e100_hw_init(bdp);
+		if (netif_running(dev)) {
+			e100_open(dev);
+		}
+	}
+	else {
+		test_info[test_self_test] = false;
+		test_info[test_loopback_phy] = false;
+		test_info[test_loopback_mac] = false;
+		test_info[cable_diag] = false;
 	}
 
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(HZ * 2);
-    	e100_deisolate_driver(bdp, false);
-
-	return flags | (test_result ? 0 : ETH_TEST_FL_FAILED);
+	return flags | test_result;
 }
 
 /**
@@ -126,8 +133,6 @@
 		}
 	}
 
-	e100_configure_device(bdp);
-
 	return retval;
 }
 
@@ -165,14 +170,14 @@
 	u8 rc = 0;
 
 	printk(KERN_DEBUG "%s: PHY loopback test starts\n", dev->name);
-	e100_sw_reset(dev->priv, PORT_SELECTIVE_RESET);
+	e100_hw_init(dev->priv);
 	if (!e100_diag_one_loopback(dev, PHY_LOOPBACK)) {
 		rc |= PHY_LOOPBACK;
 	}
 	printk(KERN_DEBUG "%s: PHY loopback test ends\n", dev->name);
 
 	printk(KERN_DEBUG "%s: MAC loopback test starts\n", dev->name);
-	e100_sw_reset(dev->priv, PORT_SELECTIVE_RESET);
+	e100_hw_init(dev->priv);
 	if (!e100_diag_one_loopback(dev, MAC_LOOPBACK)) {
 		rc |= MAC_LOOPBACK;
 	}
@@ -257,15 +262,10 @@
 		if (set_loopback)
                         /* Set PHY loopback mode */
                         e100_phy_set_loopback(bdp);
-                else {	/* Back to normal speed and duplex */
-                	if (bdp->params.e100_speed_duplex == E100_AUTONEG)
-				/* Reset PHY and do autoneg */
-                        	e100_phy_autoneg(bdp);
-			else    
-				/* Reset PHY and force speed and duplex */
-				e100_force_speed_duplex(bdp);
-		}
-                /* Wait for PHY state change */
+		else
+			/* Reset PHY loopback mode */
+			e100_phy_reset(bdp);	
+		/* Wait for PHY state change */
 		set_current_state(TASK_UNINTERRUPTIBLE);
                 schedule_timeout(HZ);
 	} else { /* For MAC loopback wait 500 msec to take effect */
@@ -348,10 +348,6 @@
 e100_diag_loopback_cu_ru_exec(struct e100_private *bdp)
 {
 	/*load CU & RU base */ 
-	if (!e100_wait_exec_cmplx(bdp, 0, SCB_CUC_LOAD_BASE, 0))
-		printk(KERN_ERR "e100: SCB_CUC_LOAD_BASE failed\n");
-	if(!e100_wait_exec_cmplx(bdp, 0, SCB_RUC_LOAD_BASE, 0))
-		printk(KERN_ERR "e100: SCB_RUC_LOAD_BASE failed!\n");
 	if(!e100_wait_exec_cmplx(bdp, bdp->loopback.dma_handle, SCB_RUC_START, 0))
 		printk(KERN_ERR "e100: SCB_RUC_START failed!\n");
 
@@ -433,3 +429,72 @@
 			    bdp->loopback.dma_handle);
 }
 
+static int
+e100_cable_diag(struct e100_private *bdp)
+{	
+	int saved_open_circut = 0xffff;
+	int saved_short_circut = 0xffff;
+	int saved_distance = 0xffff;
+	int saved_same = 0;
+	int cable_status = E100_CABLE_UNKNOWN;
+	int i;
+	
+	/* If we have link, */	
+	if (e100_get_link_state(bdp))
+		return E100_CABLE_OK;
+	
+	if (bdp->rev_id < D102_REV_ID)
+		return E100_CABLE_UNKNOWN;
+
+	/* Disable MDI/MDI-X auto switching */
+        e100_mdi_write(bdp, MII_NCONFIG, bdp->phy_addr,
+		MDI_MDIX_RESET_ALL_MASK);
+	/* Set to 100 Full as required by cable test */
+	e100_mdi_write(bdp, MII_BMCR, bdp->phy_addr,
+		BMCR_SPEED100 | BMCR_FULLDPLX);
+
+	/* Test up to 100 times */
+	for (i = 0; i < 100; i++) {
+		u16 ctrl_reg;
+		int distance, open_circut, short_circut, near_end;
+
+		/* Enable and execute cable test */
+		e100_mdi_write(bdp, HWI_CONTROL_REG, bdp->phy_addr,
+			(HWI_TEST_ENABLE | HWI_TEST_EXECUTE));
+		/* Wait for cable test finished */
+		set_current_state(TASK_UNINTERRUPTIBLE);
+		schedule_timeout(HZ/100 + 1);
+		/* Read results */
+		e100_mdi_read(bdp, HWI_CONTROL_REG, bdp->phy_addr, &ctrl_reg);
+		distance = ctrl_reg & HWI_TEST_DISTANCE;
+		open_circut = ctrl_reg & HWI_TEST_HIGHZ_PROBLEM;
+		short_circut = ctrl_reg & HWI_TEST_LOWZ_PROBLEM;
+
+		if ((distance == saved_distance) &&
+	    	    (open_circut == saved_open_circut) &&
+	    	    (short_circut == saved_short_circut)) 
+			saved_same++;
+		else {
+			saved_same = 0;
+			saved_distance = distance;
+			saved_open_circut = open_circut;
+			saved_short_circut = short_circut;
+		}
+		/* If results are the same 3 times */
+		if (saved_same == 3) {
+			near_end = ((distance * HWI_REGISTER_GRANULARITY) <
+			       HWI_NEAR_END_BOUNDARY);
+			if (open_circut)
+				cable_status = (near_end) ? 
+					E100_CABLE_OPEN_NEAR : E100_CABLE_OPEN_FAR;
+			if (short_circut)
+				cable_status = (near_end) ?
+					E100_CABLE_SHORT_NEAR : E100_CABLE_SHORT_FAR;
+			break;
+		}
+	}
+	/* Reset cable test */
+        e100_mdi_write(bdp, HWI_CONTROL_REG, bdp->phy_addr,					       HWI_RESET_ALL_MASK);
+	return cable_status;
+}
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/e1000/Makefile linux-2.4.22-pre2/drivers/net/e1000/Makefile
--- linux-2.4.21/drivers/net/e1000/Makefile	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/e1000/Makefile	2003-06-26 21:43:33.000000000 +0000
@@ -1,7 +1,7 @@
 ################################################################################
 #
 # 
-# Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved.
+# Copyright(c) 1999 - 2003 Intel 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 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/e1000/e1000.h linux-2.4.22-pre2/drivers/net/e1000/e1000.h
--- linux-2.4.21/drivers/net/e1000/e1000.h	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/e1000/e1000.h	2003-06-26 21:43:17.000000000 +0000
@@ -63,6 +63,9 @@
 #include <net/pkt_sched.h>
 #include <linux/list.h>
 #include <linux/reboot.h>
+#ifdef NETIF_F_TSO
+#include <net/checksum.h>
+#endif
 #include <linux/tqueue.h>
 #include <linux/mii.h>
 #include <linux/ethtool.h>
@@ -131,6 +134,7 @@
 	uint64_t dma;
 	unsigned long length;
 	unsigned long time_stamp;
+	unsigned int next_to_watch;
 };
 
 struct e1000_desc_ring {
@@ -166,7 +170,6 @@
 	struct timer_list watchdog_timer;
 	struct timer_list phy_info_timer;
 	struct vlan_group *vlgrp;
-	char *id_string;
 	uint32_t bd_number;
 	uint32_t rx_buffer_len;
 	uint32_t part_num;
@@ -215,6 +218,9 @@
 	struct e1000_phy_info phy_info;
 	struct e1000_phy_stats phy_stats;
 
+	uint32_t test_icr;
+	struct e1000_desc_ring test_tx_ring;
+	struct e1000_desc_ring test_rx_ring;
 
 
 	uint32_t pci_state[16];
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/e1000/e1000_ethtool.c linux-2.4.22-pre2/drivers/net/e1000/e1000_ethtool.c
--- linux-2.4.21/drivers/net/e1000/e1000_ethtool.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/e1000/e1000_ethtool.c	2003-06-26 21:43:12.000000000 +0000
@@ -40,15 +40,60 @@
 extern void e1000_reset(struct e1000_adapter *adapter);
 extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx);
 
-static char e1000_gstrings_stats[][ETH_GSTRING_LEN] = {
-	"rx_packets", "tx_packets", "rx_bytes", "tx_bytes", "rx_errors",
-	"tx_errors", "rx_dropped", "tx_dropped", "multicast", "collisions",
-	"rx_length_errors", "rx_over_errors", "rx_crc_errors",
-	"rx_frame_errors", "rx_fifo_errors", "rx_missed_errors",
-	"tx_aborted_errors", "tx_carrier_errors", "tx_fifo_errors",
-	"tx_heartbeat_errors", "tx_window_errors",
+struct e1000_stats {
+	char stat_string[ETH_GSTRING_LEN];
+	int sizeof_stat;
+	int stat_offset;
 };
-#define E1000_STATS_LEN	sizeof(e1000_gstrings_stats) / ETH_GSTRING_LEN
+
+#define E1000_STAT(m) sizeof(((struct e1000_adapter *)0)->m), \
+		      offsetof(struct e1000_adapter, m)
+static struct e1000_stats e1000_gstrings_stats[] = {
+	{ "rx_packets", E1000_STAT(net_stats.rx_packets) },
+	{ "tx_packets", E1000_STAT(net_stats.tx_packets) },
+	{ "rx_bytes", E1000_STAT(net_stats.rx_bytes) },
+	{ "tx_bytes", E1000_STAT(net_stats.tx_bytes) },
+	{ "rx_errors", E1000_STAT(net_stats.rx_errors) },
+	{ "tx_errors", E1000_STAT(net_stats.tx_errors) },
+	{ "rx_dropped", E1000_STAT(net_stats.rx_dropped) },
+	{ "tx_dropped", E1000_STAT(net_stats.tx_dropped) },
+	{ "multicast", E1000_STAT(net_stats.multicast) },
+	{ "collisions", E1000_STAT(net_stats.collisions) },
+	{ "rx_length_errors", E1000_STAT(net_stats.rx_length_errors) },
+	{ "rx_over_errors", E1000_STAT(net_stats.rx_over_errors) },
+	{ "rx_crc_errors", E1000_STAT(net_stats.rx_crc_errors) },
+	{ "rx_frame_errors", E1000_STAT(net_stats.rx_frame_errors) },
+	{ "rx_fifo_errors", E1000_STAT(net_stats.rx_fifo_errors) },
+	{ "rx_missed_errors", E1000_STAT(net_stats.rx_missed_errors) },
+	{ "tx_aborted_errors", E1000_STAT(net_stats.tx_aborted_errors) },
+	{ "tx_carrier_errors", E1000_STAT(net_stats.tx_carrier_errors) },
+	{ "tx_fifo_errors", E1000_STAT(net_stats.tx_fifo_errors) },
+	{ "tx_heartbeat_errors", E1000_STAT(net_stats.tx_heartbeat_errors) },
+	{ "tx_window_errors", E1000_STAT(net_stats.tx_window_errors) },
+	{ "tx_abort_late_coll", E1000_STAT(stats.latecol) },
+	{ "tx_deferred_ok", E1000_STAT(stats.dc) },
+	{ "tx_single_coll_ok", E1000_STAT(stats.scc) },
+	{ "tx_multi_coll_ok", E1000_STAT(stats.mcc) },
+	{ "rx_long_length_errors", E1000_STAT(stats.roc) },
+	{ "rx_short_length_errors", E1000_STAT(stats.ruc) },
+	{ "rx_align_errors", E1000_STAT(stats.algnerrc) },
+	{ "tx_tcp_seg_good", E1000_STAT(stats.tsctc) },
+	{ "tx_tcp_seg_failed", E1000_STAT(stats.tsctfc) },
+	{ "rx_flow_control_xon", E1000_STAT(stats.xonrxc) },
+	{ "rx_flow_control_xoff", E1000_STAT(stats.xoffrxc) },
+	{ "tx_flow_control_xon", E1000_STAT(stats.xontxc) },
+	{ "tx_flow_control_xoff", E1000_STAT(stats.xofftxc) },
+	{ "rx_csum_offload_good", E1000_STAT(hw_csum_good) },
+	{ "rx_csum_offload_errors", E1000_STAT(hw_csum_err) }
+};
+#define E1000_STATS_LEN	\
+	sizeof(e1000_gstrings_stats) / sizeof(struct e1000_stats)
+static char e1000_gstrings_test[][ETH_GSTRING_LEN] = {
+	"Register test  (offline)", "Eeprom test    (offline)",
+	"Interrupt test (offline)", "Loopback test  (offline)",
+	"Link test   (on/offline)"
+};
+#define E1000_TEST_LEN sizeof(e1000_gstrings_test) / ETH_GSTRING_LEN
 
 static void
 e1000_ethtool_gset(struct e1000_adapter *adapter, struct ethtool_cmd *ecmd)
@@ -154,6 +199,7 @@
 	strncpy(drvinfo->fw_version, "N/A", 32);
 	strncpy(drvinfo->bus_info, adapter->pdev->slot_name, 32);
 	drvinfo->n_stats = E1000_STATS_LEN;
+	drvinfo->testinfo_len = E1000_TEST_LEN;
 #define E1000_REGS_LEN 32
 	drvinfo->regdump_len  = E1000_REGS_LEN * sizeof(uint32_t);
 	drvinfo->eedump_len = adapter->hw.eeprom.word_size * 2;
@@ -164,6 +210,7 @@
                     struct ethtool_regs *regs, uint32_t *regs_buff)
 {
 	struct e1000_hw *hw = &adapter->hw;
+	uint16_t phy_data;
 
 	regs->version = (1 << 24) | (hw->revision_id << 16) | hw->device_id;
 
@@ -182,6 +229,62 @@
 	regs_buff[10] = E1000_READ_REG(hw, TDT);
 	regs_buff[11] = E1000_READ_REG(hw, TIDV);
 
+	regs_buff[12] = adapter->hw.phy_type;  /* PHY type (IGP=1, M88=0) */
+	if(hw->phy_type == e1000_phy_igp) {
+		e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
+				    IGP01E1000_PHY_AGC_A);
+		e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_A &
+				   IGP01E1000_PHY_PAGE_SELECT, &phy_data);
+		regs_buff[13] = (uint32_t)phy_data; /* cable length */
+		e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
+				    IGP01E1000_PHY_AGC_B);
+		e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_B &
+				   IGP01E1000_PHY_PAGE_SELECT, &phy_data);
+		regs_buff[14] = (uint32_t)phy_data; /* cable length */
+		e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
+				    IGP01E1000_PHY_AGC_C);
+		e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_C &
+				   IGP01E1000_PHY_PAGE_SELECT, &phy_data);
+		regs_buff[15] = (uint32_t)phy_data; /* cable length */
+		e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
+				    IGP01E1000_PHY_AGC_D);
+		e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_D &
+				   IGP01E1000_PHY_PAGE_SELECT, &phy_data);
+		regs_buff[16] = (uint32_t)phy_data; /* cable length */
+		regs_buff[17] = 0; /* extended 10bt distance (not needed) */
+		e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, 0x0);
+		e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS &
+				   IGP01E1000_PHY_PAGE_SELECT, &phy_data);
+		regs_buff[18] = (uint32_t)phy_data; /* cable polarity */
+		e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
+				    IGP01E1000_PHY_PCS_INIT_REG);
+		e1000_read_phy_reg(hw, IGP01E1000_PHY_PCS_INIT_REG &
+				   IGP01E1000_PHY_PAGE_SELECT, &phy_data);
+		regs_buff[19] = (uint32_t)phy_data; /* cable polarity */
+		regs_buff[20] = 0; /* polarity correction enabled (always) */
+		regs_buff[22] = 0; /* phy receive errors (unavailable) */
+		regs_buff[23] = regs_buff[18]; /* mdix mode */
+		e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, 0x0);
+	} else {
+        	e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
+		regs_buff[13] = (uint32_t)phy_data; /* cable length */
+		regs_buff[14] = 0;  /* Dummy (to align w/ IGP phy reg dump) */
+		regs_buff[15] = 0;  /* Dummy (to align w/ IGP phy reg dump) */
+		regs_buff[16] = 0;  /* Dummy (to align w/ IGP phy reg dump) */
+        	e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
+		regs_buff[17] = (uint32_t)phy_data; /* extended 10bt distance */
+		regs_buff[18] = regs_buff[13]; /* cable polarity */
+		regs_buff[19] = 0;  /* Dummy (to align w/ IGP phy reg dump) */
+		regs_buff[20] = regs_buff[17]; /* polarity correction */
+		/* phy receive errors */
+		regs_buff[22] = adapter->phy_stats.receive_errors;
+		regs_buff[23] = regs_buff[13]; /* mdix mode */
+	}
+	regs_buff[21] = adapter->phy_stats.idle_errors;  /* phy idle errors */
+	e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_data);
+	regs_buff[24] = (uint32_t)phy_data;  /* phy local receiver status */
+	regs_buff[25] = regs_buff[24];  /* phy remote receiver status */
+
 	return;
 }
 
@@ -219,7 +322,7 @@
 		uint16_t i;
 		for (i = 0; i < last_word - first_word + 1; i++)
 			if((ret_val = e1000_read_eeprom(hw, first_word + i, 1,
-						       &eeprom_buff[i])))
+							&eeprom_buff[i])))
 				break;
 	}
 geeprom_error:
@@ -249,7 +352,7 @@
 	first_word = eeprom->offset >> 1;
 	last_word = (eeprom->offset + eeprom->len - 1) >> 1;
 	eeprom_buff = kmalloc(max_len, GFP_KERNEL);
-	if(eeprom_buff == NULL)
+	if(!eeprom_buff)
 		return -ENOMEM;
 
 	ptr = (void *)eeprom_buff;
@@ -284,6 +387,765 @@
 	return ret_val;
 }
 
+#define REG_PATTERN_TEST(R, M, W)                                              \
+{                                                                              \
+	uint32_t pat, value;                                                   \
+	uint32_t test[] =                                                      \
+		{0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};              \
+	for(pat = 0; pat < sizeof(test)/sizeof(test[0]); pat++) {              \
+		E1000_WRITE_REG(&adapter->hw, R, (test[pat] & W));             \
+		value = E1000_READ_REG(&adapter->hw, R);                       \
+		if(value != (test[pat] & W & M)) {                             \
+			*data = (adapter->hw.mac_type < e1000_82543) ?         \
+				E1000_82542_##R : E1000_##R;                   \
+			return 1;                                              \
+		}                                                              \
+	}                                                                      \
+}
+
+#define REG_SET_AND_CHECK(R, M, W)                                             \
+{                                                                              \
+	uint32_t value;                                                        \
+	E1000_WRITE_REG(&adapter->hw, R, W & M);                               \
+	value = E1000_READ_REG(&adapter->hw, R);                               \
+	if ((W & M) != (value & M)) {                                          \
+		*data = (adapter->hw.mac_type < e1000_82543) ?                 \
+			E1000_82542_##R : E1000_##R;                           \
+		return 1;                                                      \
+	}                                                                      \
+}
+
+static int
+e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data)
+{
+	uint32_t value;
+	uint32_t i;
+
+	/* The status register is Read Only, so a write should fail.
+	 * Some bits that get toggled are ignored.
+	 */
+	value = (E1000_READ_REG(&adapter->hw, STATUS) & (0xFFFFF833));
+	E1000_WRITE_REG(&adapter->hw, STATUS, (0xFFFFFFFF));
+	if(value != (E1000_READ_REG(&adapter->hw, STATUS) & (0xFFFFF833))) {
+		*data = 1;
+		return 1;
+	}
+
+	REG_PATTERN_TEST(FCAL, 0xFFFFFFFF, 0xFFFFFFFF);
+	REG_PATTERN_TEST(FCAH, 0x0000FFFF, 0xFFFFFFFF);
+	REG_PATTERN_TEST(FCT, 0x0000FFFF, 0xFFFFFFFF);
+	REG_PATTERN_TEST(VET, 0x0000FFFF, 0xFFFFFFFF);
+	REG_PATTERN_TEST(RDTR, 0x0000FFFF, 0xFFFFFFFF);
+	REG_PATTERN_TEST(RDBAH, 0xFFFFFFFF, 0xFFFFFFFF);
+	REG_PATTERN_TEST(RDLEN, 0x000FFF80, 0x000FFFFF);
+	REG_PATTERN_TEST(RDH, 0x0000FFFF, 0x0000FFFF);
+	REG_PATTERN_TEST(RDT, 0x0000FFFF, 0x0000FFFF);
+	REG_PATTERN_TEST(FCRTH, 0x0000FFF8, 0x0000FFF8);
+	REG_PATTERN_TEST(FCTTV, 0x0000FFFF, 0x0000FFFF);
+	REG_PATTERN_TEST(TIPG, 0x3FFFFFFF, 0x3FFFFFFF);
+	REG_PATTERN_TEST(TDBAH, 0xFFFFFFFF, 0xFFFFFFFF);
+	REG_PATTERN_TEST(TDLEN, 0x000FFF80, 0x000FFFFF);
+
+	REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x00000000);
+	REG_SET_AND_CHECK(RCTL, 0x06DFB3FE, 0x003FFFFB);
+	REG_SET_AND_CHECK(TCTL, 0xFFFFFFFF, 0x00000000);
+
+	if(adapter->hw.mac_type >= e1000_82543) {
+
+		REG_SET_AND_CHECK(RCTL, 0x06DFB3FE, 0xFFFFFFFF);
+		REG_PATTERN_TEST(RDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
+		REG_PATTERN_TEST(TXCW, 0xC000FFFF, 0x0000FFFF);
+		REG_PATTERN_TEST(TDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
+		REG_PATTERN_TEST(TIDV, 0x0000FFFF, 0x0000FFFF);
+
+		for(i = 0; i < E1000_RAR_ENTRIES; i++) {
+			REG_PATTERN_TEST(RA + ((i << 1) << 2), 0xFFFFFFFF,
+					 0xFFFFFFFF);
+			REG_PATTERN_TEST(RA + (((i << 1) + 1) << 2), 0x8003FFFF,
+					 0xFFFFFFFF);
+		}
+
+	} else {
+
+		REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x01FFFFFF);
+		REG_PATTERN_TEST(RDBAL, 0xFFFFF000, 0xFFFFFFFF);
+		REG_PATTERN_TEST(TXCW, 0x0000FFFF, 0x0000FFFF);
+		REG_PATTERN_TEST(TDBAL, 0xFFFFF000, 0xFFFFFFFF);
+
+	}
+
+	for(i = 0; i < E1000_MC_TBL_SIZE; i++)
+		REG_PATTERN_TEST(MTA + (i << 2), 0xFFFFFFFF, 0xFFFFFFFF);
+
+	return 0;
+}
+
+static int
+e1000_eeprom_test(struct e1000_adapter *adapter, uint64_t *data)
+{
+	uint16_t temp;
+	uint16_t checksum = 0;
+	uint16_t i;
+
+	*data = 0;
+	/* Read and add up the contents of the EEPROM */
+	for(i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) {
+		if((e1000_read_eeprom(&adapter->hw, i, 1, &temp)) < 0) {
+			*data = 1;
+			break;
+		}
+		checksum += temp;
+	}
+
+	/* If Checksum is not Correct return error else test passed */
+	if((checksum != (uint16_t) EEPROM_SUM) && !(*data))
+		*data = 2;
+
+	return *data;
+}
+
+static void
+e1000_test_intr(int irq,
+		void *data,
+		struct pt_regs *regs)
+{
+	struct net_device *netdev = (struct net_device *) data;
+	struct e1000_adapter *adapter = netdev->priv;
+
+	adapter->test_icr |= E1000_READ_REG(&adapter->hw, ICR);
+
+	return;
+}
+
+static int
+e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
+{
+	struct net_device *netdev = adapter->netdev;
+	uint32_t icr, mask, i=0;
+
+	*data = 0;
+
+	/* Hook up test interrupt handler just for this test */
+	if(request_irq
+	   (netdev->irq, &e1000_test_intr, SA_SHIRQ, netdev->name, netdev)) {
+		*data = 1;
+		return -1;
+	}
+
+	/* Disable all the interrupts */
+	E1000_WRITE_REG(&adapter->hw, IMC, 0xFFFFFFFF);
+	msec_delay(10);
+
+	/* Interrupts are disabled, so read interrupt cause
+	 * register (icr) twice to verify that there are no interrupts
+	 * pending.  icr is clear on read.
+	 */
+	icr = E1000_READ_REG(&adapter->hw, ICR);
+	icr = E1000_READ_REG(&adapter->hw, ICR);
+
+	if(icr != 0) {
+		/* if icr is non-zero, there is no point
+		 * running other interrupt tests.
+		 */
+		*data = 2;
+		i = 10;
+	}
+
+	/* Test each interrupt */
+	for(; i < 10; i++) {
+
+		/* Interrupt to test */
+		mask = 1 << i;
+
+		/* Disable the interrupt to be reported in
+		 * the cause register and then force the same
+		 * interrupt and see if one gets posted.  If
+		 * an interrupt was posted to the bus, the
+		 * test failed.
+		 */
+		adapter->test_icr = 0;
+		E1000_WRITE_REG(&adapter->hw, IMC, mask);
+		E1000_WRITE_REG(&adapter->hw, ICS, mask);
+		msec_delay(10);
+
+		if(adapter->test_icr & mask) {
+			*data = 3;
+			break;
+		}
+
+		/* Enable the interrupt to be reported in
+		 * the cause register and then force the same
+		 * interrupt and see if one gets posted.  If
+		 * an interrupt was not posted to the bus, the
+		 * test failed.
+		 */
+		adapter->test_icr = 0;
+		E1000_WRITE_REG(&adapter->hw, IMS, mask);
+		E1000_WRITE_REG(&adapter->hw, ICS, mask);
+		msec_delay(10);
+
+		if(!(adapter->test_icr & mask)) {
+			*data = 4;
+			break;
+		}
+
+		/* Disable the other interrupts to be reported in
+		 * the cause register and then force the other
+		 * interrupts and see if any get posted.  If
+		 * an interrupt was posted to the bus, the
+		 * test failed.
+		 */
+		adapter->test_icr = 0;
+		E1000_WRITE_REG(&adapter->hw, IMC, ~mask);
+		E1000_WRITE_REG(&adapter->hw, ICS, ~mask);
+		msec_delay(10);
+
+		if(adapter->test_icr) {
+			*data = 5;
+			break;
+		}
+	}
+
+	/* Disable all the interrupts */
+	E1000_WRITE_REG(&adapter->hw, IMC, 0xFFFFFFFF);
+	msec_delay(10);
+
+	/* Unhook test interrupt handler */
+	free_irq(netdev->irq, netdev);
+
+	return *data;
+}
+
+static void
+e1000_free_desc_rings(struct e1000_adapter *adapter)
+{
+	struct e1000_desc_ring *txdr = &adapter->test_tx_ring;
+	struct e1000_desc_ring *rxdr = &adapter->test_rx_ring;
+	struct pci_dev *pdev = adapter->pdev;
+	int i;
+
+	if(txdr->desc && txdr->buffer_info) {
+		for(i = 0; i < txdr->count; i++) {
+			if(txdr->buffer_info[i].dma)
+				pci_unmap_single(pdev, txdr->buffer_info[i].dma,
+						 txdr->buffer_info[i].length,
+						 PCI_DMA_TODEVICE);
+			if(txdr->buffer_info[i].skb)
+				dev_kfree_skb(txdr->buffer_info[i].skb);
+		}
+	}
+
+	if(rxdr->desc && rxdr->buffer_info) {
+		for(i = 0; i < rxdr->count; i++) {
+			if(rxdr->buffer_info[i].dma)
+				pci_unmap_single(pdev, rxdr->buffer_info[i].dma,
+						 rxdr->buffer_info[i].length,
+						 PCI_DMA_FROMDEVICE);
+			if(rxdr->buffer_info[i].skb)
+				dev_kfree_skb(rxdr->buffer_info[i].skb);
+		}
+	}
+
+	if(txdr->desc)
+		pci_free_consistent(pdev, txdr->size, txdr->desc, txdr->dma);
+	if(rxdr->desc)
+		pci_free_consistent(pdev, rxdr->size, rxdr->desc, rxdr->dma);
+
+	if(txdr->buffer_info)
+		kfree(txdr->buffer_info);
+	if(rxdr->buffer_info)
+		kfree(rxdr->buffer_info);
+
+	return;
+}
+
+static int
+e1000_setup_desc_rings(struct e1000_adapter *adapter)
+{
+	struct e1000_desc_ring *txdr = &adapter->test_tx_ring;
+	struct e1000_desc_ring *rxdr = &adapter->test_rx_ring;
+	struct pci_dev *pdev = adapter->pdev;
+	uint32_t rctl;
+	int size, i, ret_val;
+
+	/* Setup Tx descriptor ring and Tx buffers */
+
+	txdr->count = 80;
+
+	size = txdr->count * sizeof(struct e1000_buffer);
+	if(!(txdr->buffer_info = kmalloc(size, GFP_KERNEL))) {
+		ret_val = 1;
+		goto err_nomem;
+	}
+	memset(txdr->buffer_info, 0, size);
+
+	txdr->size = txdr->count * sizeof(struct e1000_tx_desc);
+	E1000_ROUNDUP(txdr->size, 4096);
+	if(!(txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma))) {
+		ret_val = 2;
+		goto err_nomem;
+	}
+	memset(txdr->desc, 0, txdr->size);
+	txdr->next_to_use = txdr->next_to_clean = 0;
+
+	E1000_WRITE_REG(&adapter->hw, TDBAL,
+			((uint64_t) txdr->dma & 0x00000000FFFFFFFF));
+	E1000_WRITE_REG(&adapter->hw, TDBAH, ((uint64_t) txdr->dma >> 32));
+	E1000_WRITE_REG(&adapter->hw, TDLEN,
+			txdr->count * sizeof(struct e1000_tx_desc));
+	E1000_WRITE_REG(&adapter->hw, TDH, 0);
+	E1000_WRITE_REG(&adapter->hw, TDT, 0);
+	E1000_WRITE_REG(&adapter->hw, TCTL,
+			E1000_TCTL_PSP | E1000_TCTL_EN |
+			E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT |
+			E1000_FDX_COLLISION_DISTANCE << E1000_COLD_SHIFT);
+
+	for(i = 0; i < txdr->count; i++) {
+		struct e1000_tx_desc *tx_desc = E1000_TX_DESC(*txdr, i);
+		struct sk_buff *skb;
+		unsigned int size = 1024;
+
+		if(!(skb = alloc_skb(size, GFP_KERNEL))) {
+			ret_val = 3;
+			goto err_nomem;
+		}
+		skb_put(skb, size);
+		txdr->buffer_info[i].skb = skb;
+		txdr->buffer_info[i].length = skb->len;
+		txdr->buffer_info[i].dma =
+			pci_map_single(pdev, skb->data, skb->len,
+				       PCI_DMA_TODEVICE);
+		tx_desc->buffer_addr = cpu_to_le64(txdr->buffer_info[i].dma);
+		tx_desc->lower.data = cpu_to_le32(skb->len);
+		tx_desc->lower.data |= E1000_TXD_CMD_EOP;
+		tx_desc->lower.data |= E1000_TXD_CMD_IFCS;
+		tx_desc->lower.data |= E1000_TXD_CMD_RPS;
+		tx_desc->upper.data = 0;
+	}
+
+	/* Setup Rx descriptor ring and Rx buffers */
+
+	rxdr->count = 80;
+
+	size = rxdr->count * sizeof(struct e1000_buffer);
+	if(!(rxdr->buffer_info = kmalloc(size, GFP_KERNEL))) {
+		ret_val = 4;
+		goto err_nomem;
+	}
+	memset(rxdr->buffer_info, 0, size);
+
+	rxdr->size = rxdr->count * sizeof(struct e1000_rx_desc);
+	if(!(rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma))) {
+		ret_val = 5;
+		goto err_nomem;
+	}
+	memset(rxdr->desc, 0, rxdr->size);
+	rxdr->next_to_use = rxdr->next_to_clean = 0;
+
+	rctl = E1000_READ_REG(&adapter->hw, RCTL);
+	E1000_WRITE_REG(&adapter->hw, RCTL, rctl & ~E1000_RCTL_EN);
+	E1000_WRITE_REG(&adapter->hw, RDBAL,
+			((uint64_t) rxdr->dma & 0xFFFFFFFF));
+	E1000_WRITE_REG(&adapter->hw, RDBAH, ((uint64_t) rxdr->dma >> 32));
+	E1000_WRITE_REG(&adapter->hw, RDLEN, rxdr->size);
+	E1000_WRITE_REG(&adapter->hw, RDH, 0);
+	E1000_WRITE_REG(&adapter->hw, RDT, 0);
+	rctl = E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_SZ_2048 |
+		E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
+		(adapter->hw.mc_filter_type << E1000_RCTL_MO_SHIFT);
+	E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
+
+	for(i = 0; i < rxdr->count; i++) {
+		struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rxdr, i);
+		struct sk_buff *skb;
+
+		if(!(skb = alloc_skb(E1000_RXBUFFER_2048 + 2, GFP_KERNEL))) {
+			ret_val = 6;
+			goto err_nomem;
+		}
+		skb_reserve(skb, 2);
+		rxdr->buffer_info[i].skb = skb;
+		rxdr->buffer_info[i].length = E1000_RXBUFFER_2048;
+		rxdr->buffer_info[i].dma =
+			pci_map_single(pdev, skb->data, E1000_RXBUFFER_2048,
+				       PCI_DMA_FROMDEVICE);
+		rx_desc->buffer_addr = cpu_to_le64(rxdr->buffer_info[i].dma);
+		memset(skb->data, 0x00, skb->len);
+	}
+
+	return 0;
+
+      err_nomem:
+	e1000_free_desc_rings(adapter);
+	return ret_val;
+}
+
+static void
+e1000_phy_disable_receiver(struct e1000_adapter *adapter)
+{
+	/* Write out to PHY registers 29 and 30 to disable the Receiver. */
+	e1000_write_phy_reg(&adapter->hw, 29, 0x001F);
+	e1000_write_phy_reg(&adapter->hw, 30, 0x8FFC);
+	e1000_write_phy_reg(&adapter->hw, 29, 0x001A);
+	e1000_write_phy_reg(&adapter->hw, 30, 0x8FF0);
+
+	return;
+}
+
+static void
+e1000_phy_reset_clk_and_crs(struct e1000_adapter *adapter)
+{
+	uint16_t phy_reg;
+
+	/* Because we reset the PHY above, we need to re-force TX_CLK in the
+	 * Extended PHY Specific Control Register to 25MHz clock.  This
+	 * value defaults back to a 2.5MHz clock when the PHY is reset.
+	 */
+	e1000_read_phy_reg(&adapter->hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_reg);
+	phy_reg |= M88E1000_EPSCR_TX_CLK_25;
+	e1000_write_phy_reg(&adapter->hw,
+		M88E1000_EXT_PHY_SPEC_CTRL, phy_reg);
+
+	/* In addition, because of the s/w reset above, we need to enable
+	 * CRS on TX.  This must be set for both full and half duplex
+	 * operation.
+	 */
+	e1000_read_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, &phy_reg);
+	phy_reg |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
+	e1000_write_phy_reg(&adapter->hw,
+		M88E1000_PHY_SPEC_CTRL, phy_reg);
+}
+
+static int
+e1000_nonintegrated_phy_loopback(struct e1000_adapter *adapter)
+{
+	uint32_t ctrl_reg;
+	uint16_t phy_reg;
+
+	/* Setup the Device Control Register for PHY loopback test. */
+
+	ctrl_reg = E1000_READ_REG(&adapter->hw, CTRL);
+	ctrl_reg |= (E1000_CTRL_ILOS |		/* Invert Loss-Of-Signal */
+		     E1000_CTRL_FRCSPD |	/* Set the Force Speed Bit */
+		     E1000_CTRL_FRCDPX |	/* Set the Force Duplex Bit */
+		     E1000_CTRL_SPD_1000 |	/* Force Speed to 1000 */
+		     E1000_CTRL_FD);		/* Force Duplex to FULL */
+
+	E1000_WRITE_REG(&adapter->hw, CTRL, ctrl_reg);
+
+	/* Read the PHY Specific Control Register (0x10) */
+	e1000_read_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, &phy_reg);
+
+	/* Clear Auto-Crossover bits in PHY Specific Control Register
+	 * (bits 6:5).
+	 */
+	phy_reg &= ~M88E1000_PSCR_AUTO_X_MODE;
+	e1000_write_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, phy_reg);
+
+	/* Perform software reset on the PHY */
+	e1000_phy_reset(&adapter->hw);
+
+	/* Have to setup TX_CLK and TX_CRS after software reset */
+	e1000_phy_reset_clk_and_crs(adapter);
+
+	e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x8100);
+
+	/* Wait for reset to complete. */
+	udelay(500);
+
+	/* Have to setup TX_CLK and TX_CRS after software reset */
+	e1000_phy_reset_clk_and_crs(adapter);
+
+	/* Write out to PHY registers 29 and 30 to disable the Receiver. */
+	e1000_phy_disable_receiver(adapter);
+
+	/* Set the loopback bit in the PHY control register. */
+	e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg);
+	phy_reg |= MII_CR_LOOPBACK;
+	e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg);
+
+	/* Setup TX_CLK and TX_CRS one more time. */
+	e1000_phy_reset_clk_and_crs(adapter);
+
+	/* Check Phy Configuration */
+	e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg);
+	if(phy_reg != 0x4100)
+		 return 9;
+
+	e1000_read_phy_reg(&adapter->hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_reg);
+	if(phy_reg != 0x0070)
+		return 10;
+
+	e1000_read_phy_reg(&adapter->hw, 29, &phy_reg);
+	if(phy_reg != 0x001A)
+		return 11;
+
+	return 0;
+}
+
+static int
+e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
+{
+	uint32_t ctrl_reg = 0;
+	uint32_t stat_reg = 0;
+
+	adapter->hw.autoneg = FALSE;
+
+	if(adapter->hw.phy_type == e1000_phy_m88) {
+		/* Auto-MDI/MDIX Off */
+		e1000_write_phy_reg(&adapter->hw,
+				    M88E1000_PHY_SPEC_CTRL, 0x0808);
+		/* reset to update Auto-MDI/MDIX */
+		e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x9140);
+		/* autoneg off */
+		e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x8140);
+	}
+	/* force 1000, set loopback */
+	e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x4140);
+
+	/* Now set up the MAC to the same speed/duplex as the PHY. */
+	ctrl_reg = E1000_READ_REG(&adapter->hw, CTRL);
+	ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
+	ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
+		     E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
+		     E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */
+		     E1000_CTRL_FD);	 /* Force Duplex to FULL */
+
+	if(adapter->hw.media_type == e1000_media_type_copper &&
+	   adapter->hw.phy_type == e1000_phy_m88) {
+		ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */
+	} else {
+		/* Set the ILOS bit on the fiber Nic is half
+		 * duplex link is detected. */
+		stat_reg = E1000_READ_REG(&adapter->hw, STATUS);
+		if((stat_reg & E1000_STATUS_FD) == 0)
+			ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU);
+	}
+
+	E1000_WRITE_REG(&adapter->hw, CTRL, ctrl_reg);
+
+	/* Disable the receiver on the PHY so when a cable is plugged in, the
+	 * PHY does not begin to autoneg when a cable is reconnected to the NIC.
+	 */
+	if(adapter->hw.phy_type == e1000_phy_m88)
+		e1000_phy_disable_receiver(adapter);
+
+	udelay(500);
+
+	return 0;
+}
+
+static int
+e1000_set_phy_loopback(struct e1000_adapter *adapter)
+{
+	uint16_t phy_reg = 0;
+	uint16_t count = 0;
+
+	switch (adapter->hw.mac_type) {
+	case e1000_82543:
+		if(adapter->hw.media_type == e1000_media_type_copper) {
+			/* Attempt to setup Loopback mode on Non-integrated PHY.
+			 * Some PHY registers get corrupted at random, so
+			 * attempt this 10 times.
+			 */
+			while(e1000_nonintegrated_phy_loopback(adapter) &&
+			      count++ < 10);
+			if(count < 11)
+				return 0;
+		}
+		break;
+
+	case e1000_82544:
+	case e1000_82540:
+	case e1000_82545:
+	case e1000_82546:
+	case e1000_82541:
+	case e1000_82547:
+		return e1000_integrated_phy_loopback(adapter);
+		break;
+
+	default:
+		/* Default PHY loopback work is to read the MII
+		 * control register and assert bit 14 (loopback mode).
+		 */
+		e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg);
+		phy_reg |= MII_CR_LOOPBACK;
+		e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg);
+		return 0;
+		break;
+	}
+
+	return 8;
+}
+
+static int
+e1000_setup_loopback_test(struct e1000_adapter *adapter)
+{
+	uint32_t rctl;
+
+	if(adapter->hw.media_type == e1000_media_type_fiber) {
+		if(adapter->hw.mac_type == e1000_82545 ||
+		   adapter->hw.mac_type == e1000_82546)
+			return e1000_set_phy_loopback(adapter);
+		else {
+			rctl = E1000_READ_REG(&adapter->hw, RCTL);
+			rctl |= E1000_RCTL_LBM_TCVR;
+			E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
+			return 0;
+		}
+	} else if(adapter->hw.media_type == e1000_media_type_copper)
+		return e1000_set_phy_loopback(adapter);
+
+	return 7;
+}
+
+static void
+e1000_loopback_cleanup(struct e1000_adapter *adapter)
+{
+	uint32_t rctl;
+	uint16_t phy_reg;
+
+	rctl = E1000_READ_REG(&adapter->hw, RCTL);
+	rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC);
+	E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
+
+	if(adapter->hw.media_type == e1000_media_type_copper ||
+	   (adapter->hw.media_type == e1000_media_type_fiber &&
+	    (adapter->hw.mac_type == e1000_82545 ||
+	     adapter->hw.mac_type == e1000_82546))) {
+		adapter->hw.autoneg = TRUE;
+		e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg);
+		if(phy_reg & MII_CR_LOOPBACK) {
+			phy_reg &= ~MII_CR_LOOPBACK;
+			e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg);
+			e1000_phy_reset(&adapter->hw);
+		}
+	}
+}
+
+static void
+e1000_create_lbtest_frame(struct sk_buff *skb, unsigned int frame_size)
+{
+	memset(skb->data, 0xFF, frame_size);
+	frame_size = (frame_size % 2) ? (frame_size - 1) : frame_size;
+	memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1);
+	memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
+	memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
+}
+
+static int
+e1000_check_lbtest_frame(struct sk_buff *skb, unsigned int frame_size)
+{
+	frame_size = (frame_size % 2) ? (frame_size - 1) : frame_size;
+	if(*(skb->data + 3) == 0xFF) {
+		if((*(skb->data + frame_size / 2 + 10) == 0xBE) &&
+		   (*(skb->data + frame_size / 2 + 12) == 0xAF)) {
+			return 0;
+		}
+	}
+	return 13;
+}
+
+static int
+e1000_run_loopback_test(struct e1000_adapter *adapter)
+{
+	struct e1000_desc_ring *txdr = &adapter->test_tx_ring;
+	struct e1000_desc_ring *rxdr = &adapter->test_rx_ring;
+	struct pci_dev *pdev = adapter->pdev;
+	int i;
+
+	E1000_WRITE_REG(&adapter->hw, RDT, rxdr->count - 1);
+
+	for(i = 0; i < 64; i++) {
+		e1000_create_lbtest_frame(txdr->buffer_info[i].skb, 1024);
+		pci_dma_sync_single(pdev, txdr->buffer_info[i].dma,
+				    txdr->buffer_info[i].length,
+				    PCI_DMA_TODEVICE);
+	}
+	E1000_WRITE_REG(&adapter->hw, TDT, i);
+
+	msec_delay(200);
+
+	pci_dma_sync_single(pdev, rxdr->buffer_info[0].dma,
+			    rxdr->buffer_info[0].length, PCI_DMA_FROMDEVICE);
+
+	return e1000_check_lbtest_frame(rxdr->buffer_info[0].skb, 1024);
+}
+
+static int
+e1000_loopback_test(struct e1000_adapter *adapter, uint64_t *data)
+{
+	if((*data = e1000_setup_desc_rings(adapter))) goto err_loopback;
+	if((*data = e1000_setup_loopback_test(adapter))) goto err_loopback;
+	*data = e1000_run_loopback_test(adapter);
+	e1000_loopback_cleanup(adapter);
+	e1000_free_desc_rings(adapter);
+err_loopback:
+	return *data;
+}
+
+static int
+e1000_link_test(struct e1000_adapter *adapter, uint64_t *data)
+{
+	*data = 0;
+	e1000_check_for_link(&adapter->hw);
+
+	if(!(E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU)) {
+		*data = 1;
+	}
+	return *data;
+}
+
+static int
+e1000_ethtool_test(struct e1000_adapter *adapter,
+		   struct ethtool_test *eth_test, uint64_t *data)
+{
+	boolean_t if_running = netif_running(adapter->netdev);
+
+	if(eth_test->flags == ETH_TEST_FL_OFFLINE) {
+		/* Offline tests */
+
+		/* Link test performed before hardware reset so autoneg doesn't
+		 * interfere with test result */
+		if(e1000_link_test(adapter, &data[4]))
+			eth_test->flags |= ETH_TEST_FL_FAILED;
+
+		if(if_running)
+			e1000_down(adapter);
+
+		e1000_reset(adapter);
+		if(e1000_reg_test(adapter, &data[0]))
+			eth_test->flags |= ETH_TEST_FL_FAILED;
+
+		e1000_reset(adapter);
+		if(e1000_eeprom_test(adapter, &data[1]))
+			eth_test->flags |= ETH_TEST_FL_FAILED;
+
+		e1000_reset(adapter);
+		if(e1000_intr_test(adapter, &data[2]))
+			eth_test->flags |= ETH_TEST_FL_FAILED;
+
+		e1000_reset(adapter);
+		if(e1000_loopback_test(adapter, &data[3]))
+			eth_test->flags |= ETH_TEST_FL_FAILED;
+
+		e1000_reset(adapter);
+		if(if_running)
+			e1000_up(adapter);
+	} else {
+		/* Online tests */
+		if(e1000_link_test(adapter, &data[4]))
+			eth_test->flags |= ETH_TEST_FL_FAILED;
+
+		/* Offline tests aren't run; pass by default */
+		data[0] = 0;
+		data[1] = 0;
+		data[2] = 0;
+		data[3] = 0;
+	}
+	return 0;
+}
+
 static void
 e1000_ethtool_gwol(struct e1000_adapter *adapter, struct ethtool_wolinfo *wol)
 {
@@ -443,24 +1305,46 @@
 	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:
+		case ETH_SS_TEST:
+			gstrings.len = E1000_TEST_LEN;
+			strings = kmalloc(E1000_TEST_LEN * ETH_GSTRING_LEN,
+					  GFP_KERNEL);
+			if(!strings)
+				return -ENOMEM;
+			memcpy(strings, e1000_gstrings_test, E1000_TEST_LEN *
+			       ETH_GSTRING_LEN);
+			break;
+		case ETH_SS_STATS: {
+			int i;
 			gstrings.len = E1000_STATS_LEN;
-			strings = *e1000_gstrings_stats;
+			strings = kmalloc(E1000_STATS_LEN * ETH_GSTRING_LEN,
+					  GFP_KERNEL);
+			if(!strings)
+				return -ENOMEM;
+			for(i=0; i < E1000_STATS_LEN; i++) {
+				memcpy(&strings[i * ETH_GSTRING_LEN],
+				       e1000_gstrings_stats[i].stat_string,
+				       ETH_GSTRING_LEN);
+			}
 			break;
+		}
 		default:
 			return -EOPNOTSUPP;
 		}
 		if(copy_to_user(addr, &gstrings, sizeof(gstrings)))
-			return -EFAULT;
+			err = -EFAULT;
 		addr += offsetof(struct ethtool_gstrings, data);
-		if(copy_to_user(addr, strings,
+		if(!err && copy_to_user(addr, strings,
 		   gstrings.len * ETH_GSTRING_LEN))
-			return -EFAULT;
-		return 0;
+			err = -EFAULT;
+
+		kfree(strings);
+		return err;
 	}
 	case ETHTOOL_GREGS: {
 		struct ethtool_regs regs = {ETHTOOL_GREGS};
@@ -522,16 +1406,14 @@
 		void *ptr;
 		int err = 0;
 
+		if(copy_from_user(&eeprom, addr, sizeof(eeprom)))
+			return -EFAULT;
+
 		eeprom_buff = kmalloc(hw->eeprom.word_size * 2, GFP_KERNEL);
 
-		if(eeprom_buff == NULL)
+		if(!eeprom_buff)
 			return -ENOMEM;
 
-		if(copy_from_user(&eeprom, addr, sizeof(eeprom))) {
-			err = -EFAULT;
-			goto err_geeprom_ioctl;
-		}
-
 		if((err = e1000_ethtool_geeprom(adapter, &eeprom,
 						eeprom_buff)))
 			goto err_geeprom_ioctl;
@@ -565,18 +1447,45 @@
 	}
 	case ETHTOOL_GSTATS: {
 		struct {
-			struct ethtool_stats cmd;
+			struct ethtool_stats eth_stats;
 			uint64_t data[E1000_STATS_LEN];
 		} stats = { {ETHTOOL_GSTATS, E1000_STATS_LEN} };
 		int i;
 
 		for(i = 0; i < E1000_STATS_LEN; i++)
-			stats.data[i] =
-				((unsigned long *)&adapter->net_stats)[i];
+			stats.data[i] = (e1000_gstrings_stats[i].sizeof_stat ==
+					sizeof(uint64_t)) ?
+				*(uint64_t *)((char *)adapter +
+					e1000_gstrings_stats[i].stat_offset) :
+				*(uint32_t *)((char *)adapter +
+					e1000_gstrings_stats[i].stat_offset);
 		if(copy_to_user(addr, &stats, sizeof(stats)))
 			return -EFAULT;
 		return 0;
 	}
+	case ETHTOOL_TEST: {
+		struct {
+			struct ethtool_test eth_test;
+			uint64_t data[E1000_TEST_LEN];
+		} test = { {ETHTOOL_TEST} };
+		int err;
+
+		if(!capable(CAP_NET_ADMIN))
+			return -EPERM;
+
+		if(copy_from_user(&test.eth_test, addr, sizeof(test.eth_test)))
+			return -EFAULT;
+
+		test.eth_test.len = E1000_TEST_LEN;
+
+		if((err = e1000_ethtool_test(adapter, &test.eth_test,
+					     test.data)))
+			return err;
+
+		if(copy_to_user(addr, &test, sizeof(test)) != 0)
+			return -EFAULT;
+		return 0;
+	}
 	default:
 		return -EOPNOTSUPP;
 	}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/e1000/e1000_hw.c linux-2.4.22-pre2/drivers/net/e1000/e1000_hw.c
--- linux-2.4.21/drivers/net/e1000/e1000_hw.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/e1000/e1000_hw.c	2003-06-26 21:43:29.000000000 +0000
@@ -185,6 +185,7 @@
         break;
     case E1000_DEV_ID_82546EB_COPPER:
     case E1000_DEV_ID_82546EB_FIBER:
+    case E1000_DEV_ID_82546EB_QUAD_COPPER:
         hw->mac_type = e1000_82546;
         break;
     case E1000_DEV_ID_82541EI:
@@ -288,9 +289,7 @@
         /* Configure activity LED after PHY reset */
         led_ctrl = E1000_READ_REG(hw, LEDCTL);
         led_ctrl &= IGP_ACTIVITY_LED_MASK;
-        led_ctrl |= IGP_ACTIVITY_LED_ENABLE;
-        if(hw->mac_type == e1000_82547)
-            led_ctrl |= IGP_LED3_MODE;
+        led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
         E1000_WRITE_REG(hw, LEDCTL, led_ctrl);
     }
 
@@ -737,9 +736,7 @@
         /* Configure activity LED after PHY reset */
         led_ctrl = E1000_READ_REG(hw, LEDCTL);
         led_ctrl &= IGP_ACTIVITY_LED_MASK;
-        led_ctrl |= IGP_ACTIVITY_LED_ENABLE;
-        if(hw->mac_type == e1000_82547)
-            led_ctrl |= IGP_LED3_MODE;
+        led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
         E1000_WRITE_REG(hw, LEDCTL, led_ctrl);
 
         if(hw->autoneg_advertised == ADVERTISE_1000_FULL) {
@@ -2293,9 +2290,7 @@
         /* Configure activity LED after PHY reset */
         led_ctrl = E1000_READ_REG(hw, LEDCTL);
         led_ctrl &= IGP_ACTIVITY_LED_MASK;
-        led_ctrl |= IGP_ACTIVITY_LED_ENABLE;
-        if(hw->mac_type == e1000_82547)
-            led_ctrl |= IGP_LED3_MODE;
+        led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
         E1000_WRITE_REG(hw, LEDCTL, led_ctrl);
     }
 }
@@ -3801,6 +3796,7 @@
     case E1000_DEV_ID_82540EM_LOM:
     case E1000_DEV_ID_82545EM_COPPER:
     case E1000_DEV_ID_82546EB_COPPER:
+    case E1000_DEV_ID_82546EB_QUAD_COPPER:
     case E1000_DEV_ID_82541EI:
     case E1000_DEV_ID_82541EP:
     case E1000_DEV_ID_82547EI:
@@ -3842,6 +3838,7 @@
     case E1000_DEV_ID_82545EM_FIBER:
     case E1000_DEV_ID_82546EB_COPPER:
     case E1000_DEV_ID_82546EB_FIBER:
+    case E1000_DEV_ID_82546EB_QUAD_COPPER:
     case E1000_DEV_ID_82541EI:
     case E1000_DEV_ID_82541EP:
     case E1000_DEV_ID_82547EI:
@@ -3896,6 +3893,7 @@
     case E1000_DEV_ID_82540EM_LOM:
     case E1000_DEV_ID_82545EM_COPPER:
     case E1000_DEV_ID_82546EB_COPPER:
+    case E1000_DEV_ID_82546EB_QUAD_COPPER:
     case E1000_DEV_ID_82541EI:
     case E1000_DEV_ID_82541EP:
     case E1000_DEV_ID_82547EI:
@@ -3949,6 +3947,7 @@
     case E1000_DEV_ID_82540EM_LOM:
     case E1000_DEV_ID_82545EM_COPPER:
     case E1000_DEV_ID_82546EB_COPPER:
+    case E1000_DEV_ID_82546EB_QUAD_COPPER:
     case E1000_DEV_ID_82541EI:
     case E1000_DEV_ID_82541EP:
     case E1000_DEV_ID_82547EI:
@@ -4206,7 +4205,11 @@
     status = E1000_READ_REG(hw, STATUS);
     hw->bus_type = (status & E1000_STATUS_PCIX_MODE) ?
                    e1000_bus_type_pcix : e1000_bus_type_pci;
-    if(hw->bus_type == e1000_bus_type_pci) {
+
+    if(hw->device_id == E1000_DEV_ID_82546EB_QUAD_COPPER) {
+        hw->bus_speed = (hw->bus_type == e1000_bus_type_pci) ?
+                        e1000_bus_speed_66 : e1000_bus_speed_120;
+    } else if(hw->bus_type == e1000_bus_type_pci) {
         hw->bus_speed = (status & E1000_STATUS_PCI66) ?
                         e1000_bus_speed_66 : e1000_bus_speed_33;
     } else {
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/e1000/e1000_hw.h linux-2.4.22-pre2/drivers/net/e1000/e1000_hw.h
--- linux-2.4.21/drivers/net/e1000/e1000_hw.h	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/e1000/e1000_hw.h	2003-06-26 21:43:12.000000000 +0000
@@ -99,6 +99,7 @@
     e1000_bus_speed_33,
     e1000_bus_speed_66,
     e1000_bus_speed_100,
+    e1000_bus_speed_120,
     e1000_bus_speed_133,
     e1000_bus_speed_reserved
 } e1000_bus_speed;
@@ -314,10 +315,11 @@
 #define E1000_DEV_ID_82545EM_FIBER       0x1011
 #define E1000_DEV_ID_82546EB_COPPER      0x1010
 #define E1000_DEV_ID_82546EB_FIBER       0x1012
+#define E1000_DEV_ID_82546EB_QUAD_COPPER 0x101D
 #define E1000_DEV_ID_82541EI             0x1013
 #define E1000_DEV_ID_82541EP             0x1018
 #define E1000_DEV_ID_82547EI             0x1019
-#define NUM_DEV_IDS 19
+#define NUM_DEV_IDS 20
 
 #define NODE_ADDRESS_SIZE 6
 #define ETH_LENGTH_OF_ADDRESS 6
@@ -601,7 +603,7 @@
 #define E1000_EECD     0x00010  /* EEPROM/Flash Control - RW */
 #define E1000_EERD     0x00014  /* EEPROM Read - RW */
 #define E1000_CTRL_EXT 0x00018  /* Extended Device Control - RW */
-#define E1000_FLA      0x0001C  /* Flash Access Register - RW */
+#define E1000_FLA      0x0001C  /* Flash Access - RW */
 #define E1000_MDIC     0x00020  /* MDI Control - RW */
 #define E1000_FCAL     0x00028  /* Flow Control Address Low - RW */
 #define E1000_FCAH     0x0002C  /* Flow Control Address High -RW */
@@ -730,6 +732,7 @@
  * the registers function in the same manner.
  */
 #define E1000_82542_CTRL     E1000_CTRL
+#define E1000_82542_CTRL_DUP E1000_CTRL_DUP
 #define E1000_82542_STATUS   E1000_STATUS
 #define E1000_82542_EECD     E1000_EECD
 #define E1000_82542_EERD     E1000_EERD
@@ -1485,7 +1488,6 @@
 #define E1000_COLLISION_DISTANCE        64
 #define E1000_FDX_COLLISION_DISTANCE    E1000_COLLISION_DISTANCE
 #define E1000_HDX_COLLISION_DISTANCE    E1000_COLLISION_DISTANCE
-#define E1000_GB_HDX_COLLISION_DISTANCE 512
 #define E1000_COLD_SHIFT                12
 
 /* The number of Transmit and Receive Descriptors must be a multiple of 8 */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/e1000/e1000_main.c linux-2.4.22-pre2/drivers/net/e1000/e1000_main.c
--- linux-2.4.21/drivers/net/e1000/e1000_main.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/e1000/e1000_main.c	2003-06-26 21:43:19.000000000 +0000
@@ -30,7 +30,14 @@
 
 /* Change Log
  *
- * 5.0.43	3/5/03
+ * 5.1.11	5/6/03
+ *   o Feature: Added support for 82546EB (Quad-port) hardware.
+ *   o Feature: Added support for Diagnostics through Ethtool.
+ *   o Cleanup: Removed /proc support.
+ *   o Cleanup: Removed proprietary IDIAG interface.
+ *   o Bug fix: TSO bug fixes.
+ *
+ * 5.0.42	3/5/03
  *   o Feature: Added support for 82541 and 82547 hardware.
  *   o Feature: Added support for Intel Gigabit PHY (IGP) and a variety of
  *   eeproms.
@@ -46,51 +53,22 @@
  *   shared interrupt instances.
  *
  * 4.4.18       11/27/02
- *   o Feature: Added user-settable knob for interrupt throttle rate (ITR).
- *   o Cleanup: removed large static array allocations.
- *   o Cleanup: C99 struct initializer format.
- *   o Bug fix: restore VLAN settings when interface is brought up.
- *   o Bug fix: return cleanly in probe if error in detecting MAC type.
- *   o Bug fix: Wake up on magic packet by default only if enabled in eeprom.
- *   o Bug fix: Validate MAC address in set_mac.
- *   o Bug fix: Throw away zero-length Tx skbs.
- *   o Bug fix: Make ethtool EEPROM acceses work on older versions of ethtool.
- * 
- * 4.4.12       10/15/02
  */
 
 char e1000_driver_name[] = "e1000";
 char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
-char e1000_driver_version[] = "5.0.43-k1";
+char e1000_driver_version[] = "5.1.11-k1";
 char e1000_copyright[] = "Copyright (c) 1999-2003 Intel Corporation.";
 
 /* e1000_pci_tbl - PCI Device ID Table
  *
- * Private driver_data field (last one) stores an index into e1000_strings
  * Wildcard entries (PCI_ANY_ID) should come last
  * Last entry must be all 0s
  *
  * { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
- *   Class, Class Mask, String Index }
+ *   Class, Class Mask, private data (not used) }
  */
 static struct pci_device_id e1000_pci_tbl[] __devinitdata = {
-	/* Intel(R) PRO/1000 Network Connection */
-	{0x8086, 0x1000, 0x8086, 0x1000, 0, 0, 0},
-	{0x8086, 0x1001, 0x8086, 0x1003, 0, 0, 0},
-	{0x8086, 0x1004, 0x8086, 0x1004, 0, 0, 0},
-	{0x8086, 0x1008, 0x8086, 0x1107, 0, 0, 0},
-	{0x8086, 0x1009, 0x8086, 0x1109, 0, 0, 0},
-	{0x8086, 0x100C, 0x8086, 0x1112, 0, 0, 0},
-	{0x8086, 0x100E, 0x8086, 0x001E, 0, 0, 0},
-	/* Compaq Gigabit Ethernet Server Adapter */
-	{0x8086, 0x1000, 0x0E11, PCI_ANY_ID, 0, 0, 1},
-	{0x8086, 0x1001, 0x0E11, PCI_ANY_ID, 0, 0, 1},
-	{0x8086, 0x1004, 0x0E11, PCI_ANY_ID, 0, 0, 1},
-	/* IBM Mobile, Desktop & Server Adapters */
-	{0x8086, 0x1000, 0x1014, PCI_ANY_ID, 0, 0, 2},
-	{0x8086, 0x1001, 0x1014, PCI_ANY_ID, 0, 0, 2},
-	{0x8086, 0x1004, 0x1014, PCI_ANY_ID, 0, 0, 2},
-	/* Generic */
 	{0x8086, 0x1000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
 	{0x8086, 0x1001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
 	{0x8086, 0x1004, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
@@ -106,6 +84,7 @@
 	{0x8086, 0x1016, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
 	{0x8086, 0x1017, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
 	{0x8086, 0x101E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{0x8086, 0x101D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
 	{0x8086, 0x1013, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
 	{0x8086, 0x1019, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
 	/* required last entry */
@@ -114,12 +93,6 @@
 
 MODULE_DEVICE_TABLE(pci, e1000_pci_tbl);
 
-static char *e1000_strings[] = {
-	"Intel(R) PRO/1000 Network Connection",
-	"HP Gigabit Ethernet Server Adapter",
-	"IBM Mobile, Desktop & Server Adapters"
-};
-
 /* Local Function Prototypes */
 
 int e1000_up(struct e1000_adapter *adapter);
@@ -130,7 +103,7 @@
 static int e1000_init_module(void);
 static void e1000_exit_module(void);
 static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
-static void e1000_remove(struct pci_dev *pdev);
+static void __devexit e1000_remove(struct pci_dev *pdev);
 static int e1000_sw_init(struct e1000_adapter *adapter);
 static int e1000_open(struct net_device *netdev);
 static int e1000_close(struct net_device *netdev);
@@ -155,8 +128,14 @@
 static inline void e1000_irq_disable(struct e1000_adapter *adapter);
 static inline void e1000_irq_enable(struct e1000_adapter *adapter);
 static void e1000_intr(int irq, void *data, struct pt_regs *regs);
-static boolean_t e1000_clean_tx_irq(struct e1000_adapter *adapter);
+#ifdef CONFIG_E1000_NAPI
+static int e1000_clean(struct net_device *netdev, int *budget);
+static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter,
+                                    int *work_done, int work_to_do);
+#else
 static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter);
+#endif
+static boolean_t e1000_clean_tx_irq(struct e1000_adapter *adapter);
 static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter);
 static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
 static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
@@ -189,7 +168,6 @@
 	.priority	= 0
 };
 
-
 /* Exported from other modules */
 
 extern void e1000_check_options(struct e1000_adapter *adapter);
@@ -228,8 +206,9 @@
 	printk(KERN_INFO "%s\n", e1000_copyright);
 
 	ret = pci_module_init(&e1000_driver);
-	if(ret >= 0)
+	if(ret >= 0) {
 		register_reboot_notifier(&e1000_notifier_reboot);
+	}
 	return ret;
 }
 
@@ -418,6 +397,10 @@
 	netdev->do_ioctl = &e1000_ioctl;
 	netdev->tx_timeout = &e1000_tx_timeout;
 	netdev->watchdog_timeo = 5 * HZ;
+#ifdef CONFIG_E1000_NAPI
+	netdev->poll = &e1000_clean;
+	netdev->weight = 64;
+#endif
 	netdev->vlan_rx_register = e1000_vlan_rx_register;
 	netdev->vlan_rx_add_vid = e1000_vlan_rx_add_vid;
 	netdev->vlan_rx_kill_vid = e1000_vlan_rx_kill_vid;
@@ -428,7 +411,6 @@
 	netdev->base_addr = adapter->hw.io_base;
 
 	adapter->bd_number = cards_found;
-	adapter->id_string = e1000_strings[ent->driver_data];
 
 	/* setup the private structure */
 
@@ -445,6 +427,12 @@
 		netdev->features = NETIF_F_SG;
 	}
 
+#ifdef NETIF_F_TSO
+	if((adapter->hw.mac_type >= e1000_82544) &&
+	   (adapter->hw.mac_type != e1000_82547))
+		netdev->features |= NETIF_F_TSO;
+#endif
+
 	if(pci_using_dac)
 		netdev->features |= NETIF_F_HIGHDMA;
 
@@ -483,15 +471,14 @@
 		(void (*)(void *))e1000_tx_timeout_task, netdev);
 
 	register_netdev(netdev);
-	memcpy(adapter->ifname, netdev->name, IFNAMSIZ);
-	adapter->ifname[IFNAMSIZ-1] = 0;
 
 	/* we're going to reset, so assume we have no link for now */
 
 	netif_carrier_off(netdev);
 	netif_stop_queue(netdev);
 
-	printk(KERN_INFO "%s: %s\n", netdev->name, adapter->id_string);
+	printk(KERN_INFO "%s: Intel(R) PRO/1000 Network Connection\n",
+	       netdev->name);
 	e1000_check_options(adapter);
 
 	/* Initial Wake on LAN setting
@@ -551,7 +538,6 @@
 
 	e1000_phy_hw_reset(&adapter->hw);
 
-
 	iounmap(adapter->hw.hw_addr);
 	pci_release_regions(pdev);
 
@@ -814,8 +800,9 @@
 
 	e1000_config_collision_dist(&adapter->hw);
 
-	/* Setup Transmit Descriptor Settings for this adapter */
-	adapter->txd_cmd = E1000_TXD_CMD_IFCS | E1000_TXD_CMD_IDE;
+	/* Setup Transmit Descriptor Settings for eop descriptor */
+	adapter->txd_cmd = E1000_TXD_CMD_IDE | E1000_TXD_CMD_EOP |
+		E1000_TXD_CMD_IFCS;
 
 	if(adapter->hw.report_tx_early == 1)
 		adapter->txd_cmd |= E1000_TXD_CMD_RS;
@@ -1413,10 +1400,63 @@
 
 #define E1000_TX_FLAGS_CSUM		0x00000001
 #define E1000_TX_FLAGS_VLAN		0x00000002
+#define E1000_TX_FLAGS_TSO		0x00000004
 #define E1000_TX_FLAGS_VLAN_MASK	0xffff0000
 #define E1000_TX_FLAGS_VLAN_SHIFT	16
 
 static inline boolean_t
+e1000_tso(struct e1000_adapter *adapter, struct sk_buff *skb)
+{
+#ifdef NETIF_F_TSO
+	struct e1000_context_desc *context_desc;
+	int i;
+	uint8_t ipcss, ipcso, tucss, tucso, hdr_len;
+	uint16_t ipcse, tucse, mss;
+
+	if(skb_shinfo(skb)->tso_size) {
+		hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
+		mss = skb_shinfo(skb)->tso_size;
+		skb->nh.iph->tot_len = 0;
+		skb->nh.iph->check = 0;
+		skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr,
+		                                      skb->nh.iph->daddr,
+		                                      0,
+		                                      IPPROTO_TCP,
+		                                      0);
+		ipcss = skb->nh.raw - skb->data;
+		ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data;
+		ipcse = skb->h.raw - skb->data - 1;
+		tucss = skb->h.raw - skb->data;
+		tucso = (void *)&(skb->h.th->check) - (void *)skb->data;
+		tucse = 0;
+
+		i = adapter->tx_ring.next_to_use;
+		context_desc = E1000_CONTEXT_DESC(adapter->tx_ring, i);
+
+		context_desc->lower_setup.ip_fields.ipcss  = ipcss;
+		context_desc->lower_setup.ip_fields.ipcso  = ipcso;
+		context_desc->lower_setup.ip_fields.ipcse  = cpu_to_le16(ipcse);
+		context_desc->upper_setup.tcp_fields.tucss = tucss;
+		context_desc->upper_setup.tcp_fields.tucso = tucso;
+		context_desc->upper_setup.tcp_fields.tucse = cpu_to_le16(tucse);
+		context_desc->tcp_seg_setup.fields.mss     = cpu_to_le16(mss);
+		context_desc->tcp_seg_setup.fields.hdr_len = hdr_len;
+		context_desc->cmd_and_length = cpu_to_le32(
+			E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE |
+			E1000_TXD_CMD_IP | E1000_TXD_CMD_TCP |
+			(skb->len - (hdr_len)));
+
+		if(++i == adapter->tx_ring.count) i = 0;
+		adapter->tx_ring.next_to_use = i;
+
+		return TRUE;
+	}
+#endif
+
+	return FALSE;
+}
+
+static inline boolean_t
 e1000_tx_csum(struct e1000_adapter *adapter, struct sk_buff *skb)
 {
 	struct e1000_context_desc *context_desc;
@@ -1434,8 +1474,7 @@
 		context_desc->upper_setup.tcp_fields.tucso = cso;
 		context_desc->upper_setup.tcp_fields.tucse = 0;
 		context_desc->tcp_seg_setup.data = 0;
-		context_desc->cmd_and_length =
-			cpu_to_le32(adapter->txd_cmd | E1000_TXD_CMD_DEXT);
+		context_desc->cmd_and_length = cpu_to_le32(E1000_TXD_CMD_DEXT);
 
 		if(++i == adapter->tx_ring.count) i = 0;
 		adapter->tx_ring.next_to_use = i;
@@ -1450,11 +1489,16 @@
 #define E1000_MAX_DATA_PER_TXD	(1<<E1000_MAX_TXD_PWR)
 
 static inline int
-e1000_tx_map(struct e1000_adapter *adapter, struct sk_buff *skb)
+e1000_tx_map(struct e1000_adapter *adapter, struct sk_buff *skb,
+	unsigned int first)
 {
 	struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
 	int len = skb->len, offset = 0, size, count = 0, i;
 
+#ifdef NETIF_F_TSO
+	int tso = skb_shinfo(skb)->tso_size;
+#endif
+	int nr_frags = skb_shinfo(skb)->nr_frags;
 	int f;
 	len -= skb->data_len;
 
@@ -1462,6 +1506,12 @@
 
 	while(len) {
 		size = min(len, E1000_MAX_DATA_PER_TXD);
+#ifdef NETIF_F_TSO
+		/* Workaround for premature desc write-backs
+		 * in TSO mode.  Append 4-byte sentinel desc */
+		if(tso && !nr_frags && size == len && size > 4)
+			size -= 4;
+#endif
 		tx_ring->buffer_info[i].length = size;
 		tx_ring->buffer_info[i].dma =
 			pci_map_single(adapter->pdev,
@@ -1476,7 +1526,7 @@
 		if(++i == tx_ring->count) i = 0;
 	}
 
-	for(f = 0; f < skb_shinfo(skb)->nr_frags; f++) {
+	for(f = 0; f < nr_frags; f++) {
 		struct skb_frag_struct *frag;
 
 		frag = &skb_shinfo(skb)->frags[f];
@@ -1485,6 +1535,12 @@
 
 		while(len) {
 			size = min(len, E1000_MAX_DATA_PER_TXD);
+#ifdef NETIF_F_TSO
+			/* Workaround for premature desc write-backs
+			 * in TSO mode.  Append 4-byte sentinel desc */
+			if(tso && f == (nr_frags-1) && size == len && size > 4)
+				size -= 4;
+#endif
 			tx_ring->buffer_info[i].length = size;
 			tx_ring->buffer_info[i].dma =
 				pci_map_page(adapter->pdev,
@@ -1502,6 +1558,7 @@
 	}
 	if(--i < 0) i = tx_ring->count - 1;
 	tx_ring->buffer_info[i].skb = skb;
+	tx_ring->buffer_info[first].next_to_watch = i;
 
 	return count;
 }
@@ -1511,11 +1568,14 @@
 {
 	struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
 	struct e1000_tx_desc *tx_desc = NULL;
-	uint32_t txd_upper, txd_lower;
+	uint32_t txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS;
 	int i;
 
-	txd_upper = 0;
-	txd_lower = adapter->txd_cmd;
+	if(tx_flags & E1000_TX_FLAGS_TSO) {
+		txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D |
+		             E1000_TXD_CMD_TSE;
+		txd_upper |= (E1000_TXD_POPTS_IXSM | E1000_TXD_POPTS_TXSM) << 8;
+	}
 
 	if(tx_flags & E1000_TX_FLAGS_CSUM) {
 		txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D;
@@ -1538,7 +1598,7 @@
 		if(++i == tx_ring->count) i = 0;
 	}
 
-	tx_desc->lower.data |= cpu_to_le32(E1000_TXD_CMD_EOP);
+	tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
 
 	/* Force memory writes to complete before letting h/w
 	 * know there are new descriptors to fetch.  (Only
@@ -1598,6 +1658,7 @@
 e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 {
 	struct e1000_adapter *adapter = netdev->priv;
+	unsigned int first;
 	int tx_flags = 0;
 
 	if(skb->len <= 0) {
@@ -1623,10 +1684,14 @@
 		tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
 	}
 
-	if(e1000_tx_csum(adapter, skb))
+	first = adapter->tx_ring.next_to_use;
+	
+	if(e1000_tso(adapter, skb))
+		tx_flags |= E1000_TX_FLAGS_TSO;
+	else if(e1000_tx_csum(adapter, skb))
 		tx_flags |= E1000_TX_FLAGS_CSUM;
 
-	e1000_tx_queue(adapter, e1000_tx_map(adapter, skb), tx_flags);
+	e1000_tx_queue(adapter, e1000_tx_map(adapter, skb, first), tx_flags);
 
 	netdev->trans_start = jiffies;
 
@@ -1858,6 +1923,7 @@
 		}
 
 		if((hw->mac_type <= e1000_82546) &&
+		   (hw->phy_type == e1000_phy_m88) &&
 		   !e1000_read_phy_reg(hw, M88E1000_RX_ERR_CNTR, &phy_tmp))
 			adapter->phy_stats.receive_errors += phy_tmp;
 	}
@@ -1904,7 +1970,9 @@
 	struct net_device *netdev = data;
 	struct e1000_adapter *adapter = netdev->priv;
 	uint32_t icr = E1000_READ_REG(&adapter->hw, ICR);
+#ifndef CONFIG_E1000_NAPI
 	int i;
+#endif
 
 	if(!icr)
 		return;  /* Not our interrupt */
@@ -1914,12 +1982,52 @@
 		mod_timer(&adapter->watchdog_timer, jiffies);
 	}
 
+#ifdef CONFIG_E1000_NAPI
+	if(netif_rx_schedule_prep(netdev)) {
+
+		/* Disable interrupts and register for poll. The flush 
+		  of the posted write is intentionally left out.
+		*/
+
+		atomic_inc(&adapter->irq_sem);
+		E1000_WRITE_REG(&adapter->hw, IMC, ~0);
+		__netif_rx_schedule(netdev);
+	}
+#else
 	for(i = 0; i < E1000_MAX_INTR; i++)
 		if(!e1000_clean_rx_irq(adapter) &&
 		   !e1000_clean_tx_irq(adapter))
 			break;
+#endif
+}
 
+#ifdef CONFIG_E1000_NAPI
+/**
+ * e1000_clean - NAPI Rx polling callback
+ * @adapter: board private structure
+ **/
+
+static int
+e1000_clean(struct net_device *netdev, int *budget)
+{
+	struct e1000_adapter *adapter = netdev->priv;
+	int work_to_do = min(*budget, netdev->quota);
+	int work_done = 0;
+	
+	e1000_clean_tx_irq(adapter);
+	e1000_clean_rx_irq(adapter, &work_done, work_to_do);
+
+	*budget -= work_done;
+	netdev->quota -= work_done;
+	
+	if(work_done < work_to_do) {
+		netif_rx_complete(netdev);
+		e1000_irq_enable(adapter);
+	}
+
+	return (work_done >= work_to_do);
 }
+#endif
 
 /**
  * e1000_clean_tx_irq - Reclaim resources after transmit completes
@@ -1932,39 +2040,47 @@
 	struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
 	struct net_device *netdev = adapter->netdev;
 	struct pci_dev *pdev = adapter->pdev;
-	struct e1000_tx_desc *tx_desc;
-	int i, cleaned = FALSE;
+	struct e1000_tx_desc *tx_desc, *eop_desc;
+	struct e1000_buffer *buffer_info;
+	int i, eop, cleaned = FALSE;
 
 	i = tx_ring->next_to_clean;
-	tx_desc = E1000_TX_DESC(*tx_ring, i);
+	eop = tx_ring->buffer_info[i].next_to_watch;
+	eop_desc = E1000_TX_DESC(*tx_ring, eop);
 
-	while(tx_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) {
+	while(eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) {
 
-		cleaned = TRUE;
+		for(cleaned = FALSE; !cleaned; ) {
+			tx_desc = E1000_TX_DESC(*tx_ring, i);
+			buffer_info = &tx_ring->buffer_info[i];
 
-		if(tx_ring->buffer_info[i].dma) {
+			if(buffer_info->dma) {
 
-			pci_unmap_page(pdev,
-			               tx_ring->buffer_info[i].dma,
-			               tx_ring->buffer_info[i].length,
-			               PCI_DMA_TODEVICE);
+				pci_unmap_page(pdev,
+					       buffer_info->dma,
+					       buffer_info->length,
+					       PCI_DMA_TODEVICE);
 
-			tx_ring->buffer_info[i].dma = 0;
-		}
+				buffer_info->dma = 0;
+			}
 
-		if(tx_ring->buffer_info[i].skb) {
+			if(buffer_info->skb) {
 
-			dev_kfree_skb_any(tx_ring->buffer_info[i].skb);
+				dev_kfree_skb_any(buffer_info->skb);
 
-			tx_ring->buffer_info[i].skb = NULL;
-		}
+				buffer_info->skb = NULL;
+			}
 
-		tx_desc->buffer_addr = 0;
-		tx_desc->lower.data = 0;
-		tx_desc->upper.data = 0;
+			tx_desc->buffer_addr = 0;
+			tx_desc->lower.data = 0;
+			tx_desc->upper.data = 0;
 
-		if(++i == tx_ring->count) i = 0;
-		tx_desc = E1000_TX_DESC(*tx_ring, i);
+			cleaned = (i == eop);
+			if(++i == tx_ring->count) i = 0;
+		}
+		
+		eop = tx_ring->buffer_info[i].next_to_watch;
+		eop_desc = E1000_TX_DESC(*tx_ring, eop);
 	}
 
 	tx_ring->next_to_clean = i;
@@ -1981,7 +2097,12 @@
  **/
 
 static boolean_t
+#ifdef CONFIG_E1000_NAPI
+e1000_clean_rx_irq(struct e1000_adapter *adapter, int *work_done,
+                   int work_to_do)
+#else
 e1000_clean_rx_irq(struct e1000_adapter *adapter)
+#endif
 {
 	struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
 	struct net_device *netdev = adapter->netdev;
@@ -1998,6 +2119,13 @@
 
 	while(rx_desc->status & E1000_RXD_STAT_DD) {
 
+#ifdef CONFIG_E1000_NAPI
+		if(*work_done >= work_to_do)
+			break;
+
+		(*work_done)++;
+#endif
+
 		cleaned = TRUE;
 
 		pci_unmap_single(pdev,
@@ -2060,12 +2188,21 @@
 		e1000_rx_checksum(adapter, rx_desc, skb);
 
 		skb->protocol = eth_type_trans(skb, netdev);
+#ifdef CONFIG_E1000_NAPI
+		if(adapter->vlgrp && (rx_desc->status & E1000_RXD_STAT_VP)) {
+			vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
+				(rx_desc->special & E1000_RXD_SPC_VLAN_MASK));
+		} else {
+			netif_receive_skb(skb);
+		}
+#else /* CONFIG_E1000_NAPI */
 		if(adapter->vlgrp && (rx_desc->status & E1000_RXD_STAT_VP)) {
 			vlan_hwaccel_rx(skb, adapter->vlgrp,
 				(rx_desc->special & E1000_RXD_SPC_VLAN_MASK));
 		} else {
 			netif_rx(skb);
 		}
+#endif /* CONFIG_E1000_NAPI */
 		netdev->last_rx = jiffies;
 
 		rx_desc->status = 0;
@@ -2518,7 +2655,6 @@
 	return NOTIFY_DONE;
 }
 
-
 static int
 e1000_suspend(struct pci_dev *pdev, uint32_t state)
 {
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/e1000/e1000_osdep.h linux-2.4.22-pre2/drivers/net/e1000/e1000_osdep.h
--- linux-2.4.21/drivers/net/e1000/e1000_osdep.h	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/e1000/e1000_osdep.h	2003-06-26 21:43:15.000000000 +0000
@@ -27,7 +27,7 @@
 *******************************************************************************/
 
 
-/* glue for the OS independant part of e1000
+/* glue for the OS independent part of e1000
  * includes register access macros
  */
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/eepro.c linux-2.4.22-pre2/drivers/net/eepro.c
--- linux-2.4.21/drivers/net/eepro.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/eepro.c	2003-06-26 21:43:30.000000000 +0000
@@ -1716,7 +1716,7 @@
 static int n_eepro;
 /* For linux 2.1.xx */
 
-MODULE_AUTHOR("Pascal Dupuis <dupuis@lei.ucl.ac.be> for the 2.1 stuff (locking,...)");
+MODULE_AUTHOR("Pascal Dupuis, and aris@cathedrallabs.org");
 MODULE_DESCRIPTION("Intel i82595 ISA EtherExpressPro10/10+ driver");
 MODULE_LICENSE("GPL");
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/eepro100.c linux-2.4.22-pre2/drivers/net/eepro100.c
--- linux-2.4.21/drivers/net/eepro100.c	2003-06-26 21:45:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/eepro100.c	2003-06-26 21:43:29.000000000 +0000
@@ -2392,6 +2392,7 @@
 	{ PCI_VENDOR_ID_INTEL, 0x103C, PCI_ANY_ID, PCI_ANY_ID, },
 	{ PCI_VENDOR_ID_INTEL, 0x103D, PCI_ANY_ID, PCI_ANY_ID, },
 	{ PCI_VENDOR_ID_INTEL, 0x103E, PCI_ANY_ID, PCI_ANY_ID, },
+	{ PCI_VENDOR_ID_INTEL, 0x1050, PCI_ANY_ID, PCI_ANY_ID, },
 	{ PCI_VENDOR_ID_INTEL, 0x1059, PCI_ANY_ID, PCI_ANY_ID, },
 	{ PCI_VENDOR_ID_INTEL, 0x1227, PCI_ANY_ID, PCI_ANY_ID, },
 	{ PCI_VENDOR_ID_INTEL, 0x1228, PCI_ANY_ID, PCI_ANY_ID, },
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/hamradio/mkiss.c linux-2.4.22-pre2/drivers/net/hamradio/mkiss.c
--- linux-2.4.21/drivers/net/hamradio/mkiss.c	2002-08-03 00:39:44.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/hamradio/mkiss.c	2003-06-26 21:43:19.000000000 +0000
@@ -330,6 +330,12 @@
 				return;
 			}
 			ax->rcount -= 2;
+                        /* dl9sau bugfix: the trailling two bytes flexnet crc
+                         * will not be passed to the kernel. thus we have
+                         * to correct the kissparm signature, because it
+                         * indicates a crc but there's none
+			 */
+                        *ax->rbuff &= ~0x20;
 		}
  	}
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/irda/irda-usb.c linux-2.4.22-pre2/drivers/net/irda/irda-usb.c
--- linux-2.4.21/drivers/net/irda/irda-usb.c	2002-11-28 23:53:13.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/irda/irda-usb.c	2003-06-26 21:43:22.000000000 +0000
@@ -30,23 +30,21 @@
  *			    IMPORTANT NOTE
  *			    --------------
  *
- * As of kernel 2.4.10, this is the state of compliance and testing of
+ * As of kernel 2.4.21, this is the state of compliance and testing of
  * this driver (irda-usb) with regards to the USB low level drivers...
  *
  * This driver has been tested SUCCESSFULLY with the following drivers :
  *	o usb-uhci	(For Intel/Via USB controllers)
+ *	o uhci		(Alternate/JE driver for Intel/Via USB controllers)
  *	o usb-ohci	(For other USB controllers)
  *
  * This driver has NOT been tested with the following drivers :
- *	o usb-ehci	(USB 2.0 controllers)
+ *	o ehci-hcd	(USB 2.0 controllers)
  *
- * This driver WON'T WORK with the following drivers :
- *	o uhci		(Alternate/JE driver for Intel/Via USB controllers)
- * Amongst the reasons :
- *	o uhci doesn't implement USB_ZERO_PACKET
- *	o uhci non-compliant use of urb->timeout
- * The final fix for USB_ZERO_PACKET in uhci is likely to be in 2.4.19 and
- * 2.5.8. With this fix, the driver will work properly. More on that later.
+ * Note that all HCD drivers do USB_ZERO_PACKET and timeout properly,
+ * so we don't have to worry about that anymore.
+ * One common problem is the failure to set the address on the dongle,
+ * but this happens before the driver gets loaded...
  *
  * Jean II
  */
@@ -81,8 +79,10 @@
 
 /* These are the currently known IrDA USB dongles. Add new dongles here */
 static struct usb_device_id dongles[] = {
-	/* ACTiSYS Corp,  ACT-IR2000U FIR-USB Adapter */
+	/* ACTiSYS Corp.,  ACT-IR2000U FIR-USB Adapter */
 	{ USB_DEVICE(0x9c4, 0x011), driver_info: IUC_SPEED_BUG | IUC_NO_WINDOW },
+	/* Look like ACTiSYS, Report : IBM Corp., IBM UltraPort IrDA */
+	{ USB_DEVICE(0x4428, 0x012), driver_info: IUC_SPEED_BUG | IUC_NO_WINDOW },
 	/* KC Technology Inc.,  KC-180 USB IrDA Device */
 	{ USB_DEVICE(0x50f, 0x180), driver_info: IUC_SPEED_BUG | IUC_NO_WINDOW },
 	/* Extended Systems, Inc.,  XTNDAccess IrDA USB (ESI-9685) */
@@ -167,7 +167,8 @@
 
 		IRDA_DEBUG(2, "%s(), changing speed to %d\n", __FUNCTION__, self->new_speed);
 		self->speed = self->new_speed;
-		self->new_speed = -1;
+		/* We will do ` self->new_speed = -1; ' in the completion
+		 * handler just in case the current URB fail - Jean II */
 
 		switch (self->speed) {
 		case 2400:
@@ -208,7 +209,8 @@
 	if (self->new_xbofs != -1) {
 		IRDA_DEBUG(2, "%s(), changing xbofs to %d\n", __FUNCTION__, self->new_xbofs);
 		self->xbofs = self->new_xbofs;
-		self->new_xbofs = -1;
+		/* We will do ` self->new_xbofs = -1; ' in the completion
+		 * handler just in case the current URB fail - Jean II */
 
 		switch (self->xbofs) {
 		case 48:
@@ -285,7 +287,8 @@
 
 /*------------------------------------------------------------------*/
 /*
- * Note : this function will be called with both speed_urb and empty_urb...
+ * Speed URB callback
+ * Now, we can only get called for the speed URB.
  */
 static void speed_bulk_callback(struct urb *purb)
 {
@@ -294,10 +297,9 @@
 	IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
 
 	/* We should always have a context */
-	if (self == NULL) {
-		WARNING("%s(), Bug : self == NULL\n", __FUNCTION__);
-		return;
-	}
+	ASSERT(self != NULL, return;);
+	/* We should always be called for the speed URB */
+	ASSERT(purb == &self->speed_urb, return;);
 
 	/* Check for timeout and other USB nasties */
 	if(purb->status != USB_ST_NOERROR) {
@@ -313,12 +315,14 @@
 	}
 
 	/* urb is now available */
-	purb->status = USB_ST_NOERROR;
+	//purb->status = USB_ST_NOERROR; -> tested above
 
-	/* If it was the speed URB, allow the stack to send more packets */
-	if(purb == &self->speed_urb) {
-		netif_wake_queue(self->netdev);
-	}
+	/* New speed and xbof is now commited in hardware */
+	self->new_speed = -1;
+	self->new_xbofs = -1;
+
+	/* Allow the stack to send more packets */
+	netif_wake_queue(self->netdev);
 }
 
 /*------------------------------------------------------------------*/
@@ -333,6 +337,9 @@
 	s32 speed;
 	s16 xbofs;
 	int res, mtt;
+	int	err = 1;	/* Failed */
+
+	IRDA_DEBUG(4, __FUNCTION__ "() on %s\n", netdev->name);
 
 	netif_stop_queue(netdev);
 
@@ -342,10 +349,9 @@
 	/* Check if the device is still there.
 	 * We need to check self->present under the spinlock because
 	 * of irda_usb_disconnect() is synchronous - Jean II */
-	if ((!self) || (!self->present)) {
+	if (!self->present) {
 		IRDA_DEBUG(0, "%s(), Device is gone...\n", __FUNCTION__);
-		spin_unlock_irqrestore(&self->lock, flags);
-		return 1;	/* Failed */
+		goto drop;
 	}
 
 	/* Check if we need to change the number of xbofs */
@@ -372,6 +378,7 @@
 			irda_usb_change_speed_xbofs(self);
 			netdev->trans_start = jiffies;
 			/* Will netif_wake_queue() in callback */
+			err = 0;	/* No error */
 			goto drop;
 		}
 	}
@@ -386,7 +393,7 @@
 	 * Also, we don't use directly skb_cow(), because it require
 	 * headroom >= 16, which force unnecessary copies - Jean II */
 	if (skb_headroom(skb) < USB_IRDA_HEADER) {
-		IRDA_DEBUG(0, "%s(), Insuficient skb headroom.\n", __FUNCTION__);
+		IRDA_DEBUG(1, "%s(), Insuficient skb headroom.\n", __FUNCTION__);
 		if (skb_cow(skb, USB_IRDA_HEADER)) {
 			WARNING("%s(), failed skb_cow() !!!\n", __FUNCTION__);
 			goto drop;
@@ -478,7 +485,7 @@
 	/* Drop silently the skb and exit */
 	dev_kfree_skb(skb);
 	spin_unlock_irqrestore(&self->lock, flags);
-	return 0;
+	return err;		/* Usually 1 */
 }
 
 /*------------------------------------------------------------------*/
@@ -494,10 +501,9 @@
 	IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
 
 	/* We should always have a context */
-	if (self == NULL) {
-		WARNING("%s(), Bug : self == NULL\n", __FUNCTION__);
-		return;
-	}
+	ASSERT(self != NULL, return;);
+	/* We should always be called for the speed URB */
+	ASSERT(purb == &self->tx_urb, return;);
 
 	/* Free up the skb */
 	dev_kfree_skb_any(skb);
@@ -530,10 +536,21 @@
 		return;
 	}
 
-	/* If we need to change the speed or xbofs, do it now */
+	/* If changes to speed or xbofs is pending... */
 	if ((self->new_speed != -1) || (self->new_xbofs != -1)) {
-		IRDA_DEBUG(1, "%s(), Changing speed now...\n", __FUNCTION__);
-		irda_usb_change_speed_xbofs(self);
+		if ((self->new_speed != self->speed) ||
+		    (self->new_xbofs != self->xbofs)) {
+			/* We haven't changed speed yet (because of
+			 * IUC_SPEED_BUG), so do it now - Jean II */
+			IRDA_DEBUG(1, __FUNCTION__ "(), Changing speed now...\n");
+			irda_usb_change_speed_xbofs(self);
+		} else {
+			/* New speed and xbof is now commited in hardware */
+			self->new_speed = -1;
+			self->new_xbofs = -1;
+			/* Done, waiting for next packet */
+			netif_wake_queue(self->netdev);
+		}
 	} else {
 		/* Otherwise, allow the stack to send more packets */
 		netif_wake_queue(self->netdev);
@@ -558,11 +575,13 @@
 	int	done = 0;	/* If we have made any progress */
 
 	IRDA_DEBUG(0, "%s(), Network layer thinks we timed out!\n", __FUNCTION__);
+	ASSERT(self != NULL, return;);
 
 	/* Protect us from USB callbacks, net Tx and else. */
 	spin_lock_irqsave(&self->lock, flags);
 
-	if ((!self) || (!self->present)) {
+	/* self->present *MUST* be read under spinlock */
+	if (!self->present) {
 		WARNING("%s(), device not present!\n", __FUNCTION__);
 		netif_stop_queue(netdev);
 		spin_unlock_irqrestore(&self->lock, flags);
@@ -677,36 +696,7 @@
 /*------------------------------------------------------------------*/
 /*
  * Submit a Rx URB to the USB layer to handle reception of a frame
- *
- * Important note :
- * The function process_urb() in usb-uhci.c contains the following code :
- * >	urb->complete ((struct urb *) urb);
- * >	// Re-submit the URB if ring-linked
- * >	if (is_ring && (urb->status != -ENOENT) && !contains_killed) {
- * >		urb->dev=usb_dev;
- * >		uhci_submit_urb (urb);
- * >	}
- * The way I see it is that if we submit more than one Rx URB at a
- * time, the Rx URB can be automatically re-submitted after the
- * completion handler is called.
- * We make sure to disable this feature by setting urb->next to NULL
- *
- * My take is that it's a questionable feature, and quite difficult
- * to control and to make work effectively.
- * The outcome (re-submited or not) depend on various complex
- * test ('is_ring' and 'contains_killed'), and the completion handler
- * don't have this information, so basically the driver has no way
- * to know if URB are resubmitted or not. Yuck !
- * If everything is perfect, it's cool, but the problem is when
- * an URB is killed (timeout, call to unlink_urb(), ...), things get
- * messy...
- * The other problem is that this scheme deal only with the URB
- * and ignore everything about the associated buffer. So, it would
- * resubmit URB even if the buffer is still in use or non-existent.
- * On the other hand, submitting ourself in the completion callback
- * is quite trivial and work well (this function).
- * Moreover, this scheme doesn't allow to have an idle URB, which is
- * necessary to overcome some URB failures.
+ * Mostly called by the completion callback of the previous URB.
  *
  * Jean II
  */
@@ -1127,7 +1117,10 @@
 	/* Initialize QoS for this device */
 	irda_init_max_qos_capabilies(&self->qos);
 
-	self->qos.baud_rate.bits       = desc->wBaudRate;
+	/* See spec section 7.2 for meaning.
+	 * Values are little endian (as most USB stuff), the IrDA stack
+	 * use it in native order (see parameters.c). - Jean II */
+	self->qos.baud_rate.bits       = le16_to_cpu(desc->wBaudRate);
 	self->qos.min_turn_time.bits   = desc->bmMinTurnaroundTime;
 	self->qos.additional_bofs.bits = desc->bmAdditionalBOFs;
 	self->qos.window_size.bits     = desc->bmWindowSize;
@@ -1138,7 +1131,7 @@
 
 	/* Don't always trust what the dongle tell us */
 	if(self->capability & IUC_SIR_ONLY)
-		self->qos.baud_rate.bits	&= 0xff;
+		self->qos.baud_rate.bits	&= 0x00ff;
 	if(self->capability & IUC_SMALL_PKT)
 		self->qos.data_size.bits	 = 0x07;
 	if(self->capability & IUC_NO_WINDOW)
@@ -1338,13 +1331,14 @@
  */
 static inline void irda_usb_dump_class_desc(struct irda_class_desc *desc)
 {
+	/* Values are little endian */
 	printk("bLength=%x\n", desc->bLength);
 	printk("bDescriptorType=%x\n", desc->bDescriptorType);
-	printk("bcdSpecRevision=%x\n", desc->bcdSpecRevision); 
+	printk("bcdSpecRevision=%x\n", le16_to_cpu(desc->bcdSpecRevision)); 
 	printk("bmDataSize=%x\n", desc->bmDataSize);
 	printk("bmWindowSize=%x\n", desc->bmWindowSize);
 	printk("bmMinTurnaroundTime=%d\n", desc->bmMinTurnaroundTime);
-	printk("wBaudRate=%x\n", desc->wBaudRate);
+	printk("wBaudRate=%x\n", le16_to_cpu(desc->wBaudRate));
 	printk("bmAdditionalBOFs=%x\n", desc->bmAdditionalBOFs);
 	printk("bIrdaRateSniff=%x\n", desc->bIrdaRateSniff);
 	printk("bMaxUnicastList=%x\n", desc->bMaxUnicastList);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/macmace.c linux-2.4.22-pre2/drivers/net/macmace.c
--- linux-2.4.21/drivers/net/macmace.c	2003-06-26 21:45:08.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/macmace.c	2003-06-26 21:43:17.000000000 +0000
@@ -320,8 +320,8 @@
 
 	/* Allocate the DMA ring buffers */
 
-	mp->rx_ring = (void *) __get_free_pages(GFP_DMA, N_RX_PAGES);
-	mp->tx_ring = (void *) __get_free_pages(GFP_DMA, 0);
+	mp->rx_ring = (void *) __get_free_pages(GFP_KERNEL | GFP_DMA, N_RX_PAGES);
+	mp->tx_ring = (void *) __get_free_pages(GFP_KERNEL | GFP_DMA, 0);
 	
 	if (mp->tx_ring==NULL || mp->rx_ring==NULL) {
 		if (mp->rx_ring) free_pages((u32) mp->rx_ring, N_RX_PAGES);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/myri_sbus.c linux-2.4.22-pre2/drivers/net/myri_sbus.c
--- linux-2.4.21/drivers/net/myri_sbus.c	2002-08-03 00:39:44.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/myri_sbus.c	2003-06-26 21:43:11.000000000 +0000
@@ -764,10 +764,14 @@
 int myri_header_cache(struct neighbour *neigh, struct hh_cache *hh)
 {
 	unsigned short type = hh->hh_type;
-	unsigned char *pad = (unsigned char *) hh->hh_data;
-	struct ethhdr *eth = (struct ethhdr *) (pad + MYRI_PAD_LEN);
+	unsigned char *pad;
+	struct ethhdr *eth;
 	struct net_device *dev = neigh->dev;
 
+	pad = ((unsigned char *) hh->hh_data) +
+		HH_DATA_OFF(sizeof(*eth) + MYRI_PAD_LEN);
+	eth = (struct ethhdr *) (pad + MYRI_PAD_LEN);
+
 	if (type == __constant_htons(ETH_P_802_3))
 		return -1;
 
@@ -786,7 +790,8 @@
 /* Called by Address Resolution module to notify changes in address. */
 void myri_header_cache_update(struct hh_cache *hh, struct net_device *dev, unsigned char * haddr)
 {
-	memcpy(((u8*)hh->hh_data) + 2, haddr, dev->addr_len);
+	memcpy(((u8*)hh->hh_data) + HH_DATA_OFF(sizeof(struct ethhdr)),
+	       haddr, dev->addr_len);
 }
 
 static int myri_change_mtu(struct net_device *dev, int new_mtu)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/ns83820.c linux-2.4.22-pre2/drivers/net/ns83820.c
--- linux-2.4.21/drivers/net/ns83820.c	2003-06-26 21:45:08.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/ns83820.c	2003-06-26 21:43:33.000000000 +0000
@@ -1766,7 +1766,7 @@
 	int using_dac = 0;
 
 	/* See if we can set the dma mask early on; failure is fatal. */
-	if (TRY_DAC && !pci_set_dma_mask(pci_dev, 0xffffffffffffffff)) {
+	if (TRY_DAC && !pci_set_dma_mask(pci_dev, 0xffffffffffffffffULL)) {
 		using_dac = 1;
 	} else if (!pci_set_dma_mask(pci_dev, 0xffffffff)) {
 		using_dac = 0;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/pci-skeleton.c linux-2.4.22-pre2/drivers/net/pci-skeleton.c
--- linux-2.4.21/drivers/net/pci-skeleton.c	2003-06-26 21:45:08.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/pci-skeleton.c	2003-06-26 21:43:10.000000000 +0000
@@ -602,7 +602,7 @@
 	*ioaddr_out = NULL;
 	*dev_out = NULL;
 
-	/* dev zeroed in init_etherdev */
+	/* dev zeroed in alloc_etherdev */
 	dev = alloc_etherdev (sizeof (*tp));
 	if (dev == NULL) {
 		printk (KERN_ERR PFX "unable to alloc new ethernet\n");
@@ -789,7 +789,7 @@
 	dev->irq = pdev->irq;
 	dev->base_addr = (unsigned long) ioaddr;
 
-	/* dev->priv/tp zeroed and aligned in init_etherdev */
+	/* dev->priv/tp zeroed and aligned in alloc_etherdev */
 	tp = dev->priv;
 
 	/* note: tp->chipset set in netdrv_init_board */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/pcmcia/wavelan_cs.h linux-2.4.22-pre2/drivers/net/pcmcia/wavelan_cs.h
--- linux-2.4.21/drivers/net/pcmcia/wavelan_cs.h	2002-11-28 23:53:14.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/pcmcia/wavelan_cs.h	2003-06-26 21:43:30.000000000 +0000
@@ -489,7 +489,7 @@
 #undef DEBUG_RX_INFO		/* Header of the transmitted packet */
 #undef DEBUG_RX_FAIL		/* Normal failure conditions */
 #define DEBUG_RX_ERROR		/* Unexpected conditions */
-#undef DEBUG_PACKET_DUMP	32	/* Dump packet on the screen */
+#undef DEBUG_PACKET_DUMP	/* Dump packet on the screen */
 #undef DEBUG_IOCTL_TRACE	/* Misc call by Linux */
 #undef DEBUG_IOCTL_INFO		/* Various debug info */
 #define DEBUG_IOCTL_ERROR	/* What's going wrong */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/pcnet32.c linux-2.4.22-pre2/drivers/net/pcnet32.c
--- linux-2.4.21/drivers/net/pcnet32.c	2003-06-26 21:45:08.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/pcnet32.c	2003-06-26 21:43:15.000000000 +0000
@@ -974,7 +974,9 @@
 	    }
 	    skb_reserve (rx_skbuff, 2);
 	}
-        lp->rx_dma_addr[i] = pci_map_single(lp->pci_dev, rx_skbuff->tail, rx_skbuff->len, PCI_DMA_FROMDEVICE);
+
+	if (lp->rx_dma_addr[i] == 0) 
+		lp->rx_dma_addr[i] = pci_map_single(lp->pci_dev, rx_skbuff->tail, rx_skbuff->len, PCI_DMA_FROMDEVICE);
 	lp->rx_ring[i].base = (u32)le32_to_cpu(lp->rx_dma_addr[i]);
 	lp->rx_ring[i].buf_length = le16_to_cpu(-PKT_BUF_SZ);
 	lp->rx_ring[i].status = le16_to_cpu(0x8000);
@@ -1009,7 +1011,7 @@
     /* ReInit Ring */
     lp->a.write_csr (ioaddr, 0, 1);
     i = 0;
-    while (i++ < 100)
+    while (i++ < 1000)
 	if (lp->a.read_csr (ioaddr, 0) & 0x0100)
 	    break;
 
@@ -1100,6 +1102,7 @@
     lp->tx_skbuff[entry] = skb;
     lp->tx_dma_addr[entry] = pci_map_single(lp->pci_dev, skb->data, skb->len, PCI_DMA_TODEVICE);
     lp->tx_ring[entry].base = (u32)le32_to_cpu(lp->tx_dma_addr[entry]);
+    wmb(); /* Make sure owner changes after all others are visible */
     lp->tx_ring[entry].status = le16_to_cpu(status);
 
     lp->cur_tx++;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/plip.c linux-2.4.22-pre2/drivers/net/plip.c
--- linux-2.4.21/drivers/net/plip.c	2001-09-30 19:26:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/plip.c	2003-06-26 21:43:33.000000000 +0000
@@ -1097,7 +1097,10 @@
 	
 	if ((ret = nl->orig_hard_header_cache(neigh, hh)) == 0)
 	{
-		struct ethhdr *eth = (struct ethhdr*)(((u8*)hh->hh_data) + 2);
+		struct ethhdr *eth;
+
+		eth = (struct ethhdr*)(((u8*)hh->hh_data) +
+				       HH_DATA_OFF(sizeof(*eth)));
 		plip_rewrite_address (neigh->dev, eth);
 	}
 	
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/ppp_deflate.c linux-2.4.22-pre2/drivers/net/ppp_deflate.c
--- linux-2.4.21/drivers/net/ppp_deflate.c	2002-11-28 23:53:14.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/ppp_deflate.c	2003-06-26 21:43:32.000000000 +0000
@@ -394,10 +394,10 @@
 
 	/* Check the sequence number. */
 	seq = (ibuf[PPP_HDRLEN] << 8) + ibuf[PPP_HDRLEN+1];
-	if (seq != state->seqno) {
+	if (seq != (state->seqno & 0xffff)) {
 		if (state->debug)
 			printk(KERN_DEBUG "z_decompress%d: bad seq # %d, expected %d\n",
-			       state->unit, seq, state->seqno);
+			       state->unit, seq, state->seqno & 0xffff);
 		return DECOMP_ERROR;
 	}
 	++state->seqno;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/ppp_generic.c linux-2.4.22-pre2/drivers/net/ppp_generic.c
--- linux-2.4.21/drivers/net/ppp_generic.c	2003-06-26 21:45:08.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/ppp_generic.c	2003-06-26 21:43:18.000000000 +0000
@@ -666,8 +666,10 @@
 			if (code == 0)
 				break;
 			err = -EFAULT;
-			if (copy_from_user(code, uprog.filter, len))
+			if (copy_from_user(code, uprog.filter, len)) {
+				kfree(code);
 				break;
+			}
 			err = sk_chk_filter(code, uprog.len);
 			if (err) {
 				kfree(code);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/r8169.c linux-2.4.22-pre2/drivers/net/r8169.c
--- linux-2.4.21/drivers/net/r8169.c	2003-06-26 21:45:08.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/r8169.c	2003-06-26 21:43:13.000000000 +0000
@@ -42,6 +42,7 @@
 #include <linux/delay.h>
 #include <linux/crc32.h>
 #include <linux/init.h>
+
 #include <asm/io.h>
 
 #define RTL8169_VERSION "1.2"
@@ -364,8 +365,8 @@
 	*ioaddr_out = NULL;
 	*dev_out = NULL;
 
-	// dev zeroed in init_etherdev 
-	dev = init_etherdev(NULL, sizeof (*tp));
+	// dev zeroed in alloc_etherdev 
+	dev = alloc_etherdev(sizeof (*tp));
 	if (dev == NULL) {
 		printk(KERN_ERR PFX "unable to alloc new ethernet\n");
 		return -ENOMEM;
@@ -389,18 +390,18 @@
 		printk(KERN_ERR PFX
 		       "region #1 not an MMIO resource, aborting\n");
 		rc = -ENODEV;
-		goto err_out;
+		goto err_out_disable;
 	}
 	// check for weird/broken PCI region reporting
 	if (mmio_len < RTL_MIN_IO_SIZE) {
 		printk(KERN_ERR PFX "Invalid PCI region size(s), aborting\n");
 		rc = -ENODEV;
-		goto err_out;
+		goto err_out_disable;
 	}
 
 	rc = pci_request_regions(pdev, dev->name);
 	if (rc)
-		goto err_out;
+		goto err_out_disable;
 
 	// enable PCI bus-mastering
 	pci_set_master(pdev);
@@ -448,8 +449,10 @@
 err_out_free_res:
 	pci_release_regions(pdev);
 
+err_out_disable:
+	pci_disable_device(pdev);
+
 err_out:
-	unregister_netdev(dev);
 	kfree(dev);
 	return rc;
 }
@@ -462,7 +465,7 @@
 	void *ioaddr = NULL;
 	static int board_idx = -1;
 	static int printed_version = 0;
-	int i;
+	int i, rc;
 	int option = -1, Cap10_100 = 0, Cap1000 = 0;
 
 	assert(pdev != NULL);
@@ -475,20 +478,18 @@
 		printed_version = 1;
 	}
 
-	i = rtl8169_init_board(pdev, &dev, &ioaddr);
-	if (i < 0) {
-		return i;
-	}
+	rc = rtl8169_init_board(pdev, &dev, &ioaddr);
+	if (rc)
+		return rc;
 
 	tp = dev->priv;
 	assert(ioaddr != NULL);
 	assert(dev != NULL);
 	assert(tp != NULL);
 
-	// Get MAC address //
-	for (i = 0; i < MAC_ADDR_LEN; i++) {
+	// Get MAC address.  FIXME: read EEPROM
+	for (i = 0; i < MAC_ADDR_LEN; i++)
 		dev->dev_addr[i] = RTL_R8(MAC0 + i);
-	}
 
 	dev->open = rtl8169_open;
 	dev->hard_start_xmit = rtl8169_start_xmit;
@@ -505,11 +506,20 @@
 	tp->pci_dev = pdev;
 	tp->mmio_addr = ioaddr;
 
+	spin_lock_init(&tp->lock);
+
+	rc = register_netdev(dev);
+	if (rc) {
+		iounmap(ioaddr);
+		pci_release_regions(pdev);
+		pci_disable_device(pdev);
+		kfree(dev);
+		return rc;
+	}
+
 	printk(KERN_DEBUG "%s: Identified chip type is '%s'.\n", dev->name,
 	       rtl_chip_info[tp->chipset].name);
 
-	spin_lock_init(&tp->lock);
-
 	pci_set_drvdata(pdev, dev);
 
 	printk(KERN_INFO "%s: %s at 0x%lx, "
@@ -621,7 +631,7 @@
 rtl8169_remove_one(struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
-	struct rtl8169_private *tp = (struct rtl8169_private *) (dev->priv);
+	struct rtl8169_private *tp = dev->priv;
 
 	assert(dev != NULL);
 	assert(tp != NULL);
@@ -634,6 +644,7 @@
 	memset(dev, 0xBC,
 	       sizeof (struct net_device) + sizeof (struct rtl8169_private));
 
+	pci_disable_device(pdev);
 	kfree(dev);
 	pci_set_drvdata(pdev, NULL);
 }
@@ -821,10 +832,9 @@
 	void *ioaddr = tp->mmio_addr;
 	int entry = tp->cur_tx % NUM_TX_DESC;
 
-	if(skb->len < ETH_ZLEN)
-	{
+	if (skb->len < ETH_ZLEN) {
 		skb = skb_padto(skb, ETH_ZLEN);
-		if(skb == NULL)
+		if (skb == NULL)
 			return 0;
 	}
 	
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/rcpci45.c linux-2.4.22-pre2/drivers/net/rcpci45.c
--- linux-2.4.21/drivers/net/rcpci45.c	2002-11-28 23:53:14.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/rcpci45.c	2003-06-26 21:43:30.000000000 +0000
@@ -75,10 +75,6 @@
 
 #define NEW_MULTICAST
 
-/* PCI/45 Configuration space values */
-#define RC_PCI45_VENDOR_ID  0x4916
-#define RC_PCI45_DEVICE_ID  0x1960
-
 #define MAX_ETHER_SIZE        1520
 #define MAX_NMBR_RCV_BUFFERS    96
 #define RC_POSTED_BUFFERS_LOW_MARK MAX_NMBR_RCV_BUFFERS-16
@@ -116,7 +112,7 @@
 static int RC_allocate_and_post_buffers (struct net_device *, int);
 
 static struct pci_device_id rcpci45_pci_table[] __devinitdata = {
-	{RC_PCI45_VENDOR_ID, RC_PCI45_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
+	{ PCI_VENDOR_ID_REDCREEK, PCI_DEVICE_ID_RC45, PCI_ANY_ID, PCI_ANY_ID,},
 	{}
 };
 MODULE_DEVICE_TABLE (pci, rcpci45_pci_table);
@@ -206,7 +202,7 @@
 	 * messages. Thus, we need contiguous physical pages of
 	 * memory.
 	 */
-	pDpa->msgbuf = kmalloc (MSG_BUF_SIZE, GFP_DMA|GFP_ATOMIC|GFP_KERNEL);
+	pDpa->msgbuf = kmalloc (MSG_BUF_SIZE, GFP_DMA | GFP_KERNEL);
 	if (!pDpa->msgbuf) {
 		printk (KERN_ERR "(rcpci45 driver:) \
 			Could not allocate %d byte memory for the \
@@ -999,7 +995,7 @@
 	}
 
 	p = (PU32) kmalloc (sizeof (U32) + numBuffers * sizeof (singleB),
-			    GFP_DMA|GFP_ATOMIC|GFP_KERNEL);
+			    GFP_DMA | GFP_ATOMIC);
 
 	if (!p) {
 		printk (KERN_WARNING "%s unable to allocate TCB\n",
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/sis900.c linux-2.4.22-pre2/drivers/net/sis900.c
--- linux-2.4.21/drivers/net/sis900.c	2003-06-26 21:45:08.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/sis900.c	2003-06-26 21:43:19.000000000 +0000
@@ -201,7 +201,7 @@
 static int sis900_close(struct net_device *net_dev);
 static int mii_ioctl(struct net_device *net_dev, struct ifreq *rq, int cmd);
 static struct net_device_stats *sis900_get_stats(struct net_device *net_dev);
-static u16 sis900_compute_hashtable_index(u8 *addr, u8 revision);
+static u16 sis900_mcast_bitnr(u8 *addr, u8 revision);
 static void set_rx_mode(struct net_device *net_dev);
 static void sis900_reset(struct net_device *net_dev);
 static void sis630_set_eq(struct net_device *net_dev, u8 revision);
@@ -213,7 +213,7 @@
 static void sis900_set_mode (long ioaddr, int speed, int duplex);
 
 /**
- *	sis900_get_mac_addr: - Get MAC address for stand alone SiS900 model
+ *	sis900_get_mac_addr - Get MAC address for stand alone SiS900 model
  *	@pci_dev: the sis900 pci device
  *	@net_dev: the net device to get address for 
  *
@@ -243,7 +243,7 @@
 }
 
 /**
- *	sis630e_get_mac_addr: - Get MAC address for SiS630E model
+ *	sis630e_get_mac_addr - Get MAC address for SiS630E model
  *	@pci_dev: the sis900 pci device
  *	@net_dev: the net device to get address for 
  *
@@ -276,7 +276,7 @@
 
 
 /**
- *	sis635_get_mac_addr: - Get MAC address for SIS635 model
+ *	sis635_get_mac_addr - Get MAC address for SIS635 model
  *	@pci_dev: the sis900 pci device
  *	@net_dev: the net device to get address for 
  *
@@ -312,7 +312,7 @@
 }
 
 /**
- *	sis96x_get_mac_addr: - Get MAC address for SiS962 or SiS963 model
+ *	sis96x_get_mac_addr - Get MAC address for SiS962 or SiS963 model
  *	@pci_dev: the sis900 pci device
  *	@net_dev: the net device to get address for 
  *
@@ -354,7 +354,7 @@
 }
 
 /**
- *	sis900_probe: - Probe for sis900 device
+ *	sis900_probe - Probe for sis900 device
  *	@pci_dev: the sis900 pci device
  *	@pci_id: the pci device ID
  *
@@ -499,7 +499,7 @@
 }
 
 /**
- *	sis900_mii_probe: - Probe MII PHY for sis900
+ *	sis900_mii_probe - Probe MII PHY for sis900
  *	@net_dev: the net device to probe for
  *	
  *	Search for total of 32 possible mii phy addresses.
@@ -528,7 +528,7 @@
 			mii_status = mdio_read(net_dev, phy_addr, MII_STATUS);
 
 		if (mii_status == 0xffff || mii_status == 0x0000)
-			/* the mii is not accessable, try next one */
+			/* the mii is not accessible, try next one */
 			continue;
 		
 		if ((mii_phy = kmalloc(sizeof(struct mii_phy), GFP_KERNEL)) == NULL) {
@@ -593,7 +593,7 @@
 			current->state = TASK_INTERRUPTIBLE;
 			schedule_timeout(0);
 			poll_bit ^= (mdio_read(net_dev, sis_priv->cur_phy, MII_STATUS) & poll_bit);
-			if (jiffies >= timeout) {
+			if (time_after_eq(jiffies, timeout)) {
 				printk(KERN_WARNING "%s: reset phy and link down now\n", net_dev->name);
 				return -ETIME;
 			}
@@ -619,7 +619,7 @@
 }
 
 /**
- *	sis900_default_phy: - Select default PHY for sis900 mac.
+ *	sis900_default_phy - Select default PHY for sis900 mac.
  *	@net_dev: the net device to probe for
  *
  *	Select first detected PHY with link as default.
@@ -672,7 +672,7 @@
 
 
 /**
- * 	sis900_set_capability: - set the media capability of network adapter.
+ * 	sis900_set_capability - set the media capability of network adapter.
  *	@net_dev : the net device to probe for
  *	@phy : default PHY
  *
@@ -702,7 +702,7 @@
 #define eeprom_delay()  inl(ee_addr)
 
 /**
- *	read_eeprom: - Read Serial EEPROM
+ *	read_eeprom - Read Serial EEPROM
  *	@ioaddr: base i/o address
  *	@location: the EEPROM location to read
  *
@@ -752,7 +752,7 @@
 
 /* Read and write the MII management registers using software-generated
    serial MDIO protocol. Note that the command bits and data bits are
-   send out seperately */
+   send out separately */
 #define mdio_delay()    inl(mdio_addr)
 
 static void mdio_idle(long mdio_addr)
@@ -777,7 +777,7 @@
 }
 
 /**
- *	mdio_read: - read MII PHY register
+ *	mdio_read - read MII PHY register
  *	@net_dev: the net device to read
  *	@phy_id: the phy address to read
  *	@location: the phy regiester id to read
@@ -819,7 +819,7 @@
 }
 
 /**
- *	mdio_write: - write MII PHY register
+ *	mdio_write - write MII PHY register
  *	@net_dev: the net device to write
  *	@phy_id: the phy address to write
  *	@location: the phy regiester id to write
@@ -873,7 +873,7 @@
 
 
 /**
- *	sis900_reset_phy: - reset sis900 mii phy.
+ *	sis900_reset_phy - reset sis900 mii phy.
  *	@net_dev: the net device to write
  *	@phy_addr: default phy address
  *
@@ -896,7 +896,7 @@
 }
 
 /**
- *	sis900_open: - open sis900 device
+ *	sis900_open - open sis900 device
  *	@net_dev: the net device to open
  *
  *	Do some initialization and start net interface.
@@ -953,7 +953,7 @@
 }
 
 /**
- *	sis900_init_rxfilter: - Initialize the Rx filter
+ *	sis900_init_rxfilter - Initialize the Rx filter
  *	@net_dev: the net device to initialize for
  *
  *	Set receive filter address to our MAC address
@@ -991,7 +991,7 @@
 }
 
 /**
- *	sis900_init_tx_ring: - Initialize the Tx descriptor ring
+ *	sis900_init_tx_ring - Initialize the Tx descriptor ring
  *	@net_dev: the net device to initialize for
  *
  *	Initialize the Tx descriptor ring, 
@@ -1024,7 +1024,7 @@
 }
 
 /**
- *	sis900_init_rx_ring: - Initialize the Rx descriptor ring
+ *	sis900_init_rx_ring - Initialize the Rx descriptor ring
  *	@net_dev: the net device to initialize for
  *
  *	Initialize the Rx descriptor ring, 
@@ -1078,7 +1078,7 @@
 }
 
 /**
- *	sis630_set_eq: - set phy equalizer value for 630 LAN
+ *	sis630_set_eq - set phy equalizer value for 630 LAN
  *	@net_dev: the net device to set equalizer value
  *	@revision: 630 LAN revision number
  *
@@ -1166,7 +1166,7 @@
 }
 
 /**
- *	sis900_timer: - sis900 timer routine
+ *	sis900_timer - sis900 timer routine
  *	@data: pointer to sis900 net device
  *
  *	On each timer ticks we check two things, 
@@ -1236,7 +1236,7 @@
 }
 
 /**
- *	sis900_check_mode: - check the media mode for sis900
+ *	sis900_check_mode - check the media mode for sis900
  *	@net_dev: the net device to be checked
  *	@mii_phy: the mii phy
  *
@@ -1267,7 +1267,7 @@
 }
 
 /**
- *	sis900_set_mode: - Set the media mode of mac register.
+ *	sis900_set_mode - Set the media mode of mac register.
  *	@ioaddr: the address of the device
  *	@speed : the transmit speed to be determined
  *	@duplex: the duplex mode to be determined
@@ -1311,7 +1311,7 @@
 }
 
 /**
- *	sis900_auto_negotiate:  Set the Auto-Negotiation Enable/Reset bit.
+ *	sis900_auto_negotiate - Set the Auto-Negotiation Enable/Reset bit.
  *	@net_dev: the net device to read mode for
  *	@phy_addr: mii phy address
  *
@@ -1345,7 +1345,7 @@
 
 
 /**
- *	sis900_read_mode: - read media mode for sis900 internal phy
+ *	sis900_read_mode - read media mode for sis900 internal phy
  *	@net_dev: the net device to read mode for
  *	@speed  : the transmit speed to be determined
  *	@duplex : the duplex mode to be determined
@@ -1402,7 +1402,7 @@
 }
 
 /**
- *	sis900_tx_timeout: - sis900 transmit timeout routine
+ *	sis900_tx_timeout - sis900 transmit timeout routine
  *	@net_dev: the net device to transmit
  *
  *	print transmit timeout status
@@ -1457,7 +1457,7 @@
 }
 
 /**
- *	sis900_start_xmit: - sis900 start transmit routine
+ *	sis900_start_xmit - sis900 start transmit routine
  *	@skb: socket buffer pointer to put the data being transmitted
  *	@net_dev: the net device to transmit with
  *
@@ -1527,7 +1527,7 @@
 }
 
 /**
- *	sis900_interrupt: - sis900 interrupt handler
+ *	sis900_interrupt - sis900 interrupt handler
  *	@irq: the irq number
  *	@dev_instance: the client data object
  *	@regs: snapshot of processor context
@@ -1586,7 +1586,7 @@
 }
 
 /**
- *	sis900_rx: - sis900 receive routine
+ *	sis900_rx - sis900 receive routine
  *	@net_dev: the net device which receives data
  *
  *	Process receive interrupt events, 
@@ -1725,7 +1725,7 @@
 }
 
 /**
- *	sis900_finish_xmit: - finish up transmission of packets
+ *	sis900_finish_xmit - finish up transmission of packets
  *	@net_dev: the net device to be transmitted on
  *
  *	Check for error condition and free socket buffer etc 
@@ -1795,7 +1795,7 @@
 }
 
 /**
- *	sis900_close: - close sis900 device 
+ *	sis900_close - close sis900 device 
  *	@net_dev: the net device to be closed
  *
  *	Disable interrupts, stop the Tx and Rx Status Machine 
@@ -1851,7 +1851,7 @@
 }
 
 /**
- *	netdev_ethtool_ioctl: - For the basic support of ethtool
+ *	netdev_ethtool_ioctl - For the basic support of ethtool
  *	@net_dev: the net device to command for
  *	@useraddr: start address of interface request
  *
@@ -1885,7 +1885,7 @@
 }
 
 /**
- *	mii_ioctl: - process MII i/o control command 
+ *	mii_ioctl - process MII i/o control command 
  *	@net_dev: the net device to command for
  *	@rq: parameter for command
  *	@cmd: the i/o command
@@ -1924,7 +1924,7 @@
 }
 
 /**
- *	sis900_get_stats: - Get sis900 read/write statistics 
+ *	sis900_get_stats - Get sis900 read/write statistics 
  *	@net_dev: the net device to get statistics for
  *
  *	get tx/rx statistics for sis900
@@ -1939,7 +1939,7 @@
 }
 
 /**
- *	sis900_set_config: - Set media type by net_device.set_config 
+ *	sis900_set_config - Set media type by net_device.set_config 
  *	@dev: the net device for media type change
  *	@map: ifmap passed by ifconfig
  *
@@ -1976,7 +1976,7 @@
 			status = mdio_read(dev, mii_phy->phy_addr, MII_CONTROL);
                 
 			/* enable auto negotiation and reset the negotioation
-			   (I dont really know what the auto negatiotiation reset
+			   (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);
@@ -2036,7 +2036,7 @@
 }
 
 /**
- *	sis900_compute_hashtable_index: - compute hashtable index 
+ *	sis900_mcast_bitnr - compute hashtable index 
  *	@addr: multicast address
  *	@revision: revision id of chip
  *
@@ -2046,7 +2046,7 @@
  *   	multicast hash table. 
  */
 
-static u16 sis900_compute_hashtable_index(u8 *addr, u8 revision)
+static inline u16 sis900_mcast_bitnr(u8 *addr, u8 revision)
 {
 
 	u32 crc = ether_crc(6, addr);
@@ -2059,7 +2059,7 @@
 }
 
 /**
- *	set_rx_mode: - Set SiS900 receive mode 
+ *	set_rx_mode - Set SiS900 receive mode 
  *	@net_dev: the net device to be set
  *
  *	Set SiS900 receive mode for promiscuous, multicast, or broadcast mode.
@@ -2100,9 +2100,11 @@
 		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)
-			set_bit(sis900_compute_hashtable_index(mclist->dmi_addr, revision),
-				mc_filter);
+		     i++, mclist = mclist->next) {
+			unsigned int bit_nr =
+				sis900_mcast_bitnr(mclist->dmi_addr, revision);
+			mc_filter[bit_nr >> 4] |= (1 << bit_nr);
+		}
 	}
 
 	/* update Multicast Hash Table in Receive Filter */
@@ -2131,7 +2133,7 @@
 }
 
 /**
- *	sis900_reset: - Reset sis900 MAC 
+ *	sis900_reset - Reset sis900 MAC 
  *	@net_dev: the net device to reset
  *
  *	reset sis900 MAC and wait until finished
@@ -2166,7 +2168,7 @@
 }
 
 /**
- *	sis900_remove: - Remove sis900 device 
+ *	sis900_remove - Remove sis900 device 
  *	@pci_dev: the pci device to be removed
  *
  *	remove and release SiS900 net device
@@ -2195,10 +2197,10 @@
 }
 
 static struct pci_driver sis900_pci_driver = {
-	name:		SIS900_MODULE_NAME,
-	id_table:	sis900_pci_tbl,
-	probe:		sis900_probe,
-	remove:		__devexit_p(sis900_remove),
+	.name		= SIS900_MODULE_NAME,
+	.id_table	= sis900_pci_tbl,
+	.probe		= sis900_probe,
+	.remove		= __devexit_p(sis900_remove),
 };
 
 static int __init sis900_init_module(void)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/sk98lin/skge.c linux-2.4.22-pre2/drivers/net/sk98lin/skge.c
--- linux-2.4.21/drivers/net/sk98lin/skge.c	2003-06-26 21:45:09.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/sk98lin/skge.c	2003-06-26 21:43:12.000000000 +0000
@@ -498,7 +498,7 @@
 		}
 
 		/* Configure DMA attributes. */
-		if (pci_set_dma_mask(pdev, (u64) 0xffffffffffffffff) &&
+		if (pci_set_dma_mask(pdev, (u64) 0xffffffffffffffffULL) &&
 			pci_set_dma_mask(pdev, (u64) 0xffffffff))
 			continue;
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/skfp/fplustm.c linux-2.4.22-pre2/drivers/net/skfp/fplustm.c
--- linux-2.4.21/drivers/net/skfp/fplustm.c	2001-03-20 20:04:59.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/skfp/fplustm.c	2003-06-26 21:43:18.000000000 +0000
@@ -390,7 +390,7 @@
 	outpw(FM_A(FM_TREQ0),(unsigned)t_requ) ;
 }
 
-void set_int(p,l)
+static void set_int(p,l)
 char *p;
 int l;
 {
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/sundance.c linux-2.4.22-pre2/drivers/net/sundance.c
--- linux-2.4.21/drivers/net/sundance.c	2002-11-28 23:53:14.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/sundance.c	2003-06-26 21:43:28.000000000 +0000
@@ -71,19 +71,32 @@
 
 	Versin LK1.06b (D-Link):
 	- New tx scheme, adaptive tx_coalesce
-
+	
+	Version LK1.07 (D-Link):
+	- Fix tx bugs in big-endian machines
+	- Remove unused max_interrupt_work module parameter, the new 
+	  NAPI-like rx scheme doesn't need it.
+	- Remove redundancy get_stats() in intr_handler(), those 
+	  I/O access could affect performance in ARM-based system
+	- Add Linux software VLAN support
+	
+	Version LK1.08 (D-Link):
+	- Fix bug of custom mac address 
+	(StationAddr register only accept word write) 
+
+	Version LK1.09 (D-Link):
+	- Fix the flowctrl bug.	
+	- Set Pause bit in MII ANAR if flow control enabled.	
 */
 
 #define DRV_NAME	"sundance"
-#define DRV_VERSION	"1.01+LK1.06b"
-#define DRV_RELDATE	"6-Nov-2002"
+#define DRV_VERSION	"1.01+LK1.09a"
+#define DRV_RELDATE	"16-May-2003"
 
 
 /* The user-configurable values.
    These may be modified when a driver module is loaded.*/
 static int debug = 1;			/* 1 normal messages, 0 quiet .. 7 verbose. */
-/* Maximum events (Rx packets, etc.) to handle at each interrupt. */
-static int max_interrupt_work = 0;
 /* Maximum number of multicast addresses to filter (vs. rx-all-multicast).
    Typical is a 64 element hash table based on the Ethernet CRC.  */
 static int multicast_filter_limit = 32;
@@ -129,8 +142,7 @@
 /* Operational parameters that usually are not changed. */
 /* Time in jiffies before concluding the transmitter is hung. */
 #define TX_TIMEOUT  (4*HZ)
-
-#define PKT_BUF_SZ		1536			/* Size of each temporary Rx buffer.*/
+#define PKT_BUF_SZ		1536	/* Size of each temporary Rx buffer.*/
 
 #ifndef __KERNEL__
 #define __KERNEL__
@@ -181,12 +193,10 @@
 MODULE_DESCRIPTION("Sundance Alta Ethernet driver");
 MODULE_LICENSE("GPL");
 
-MODULE_PARM(max_interrupt_work, "i");
 MODULE_PARM(debug, "i");
 MODULE_PARM(rx_copybreak, "i");
 MODULE_PARM(media, "1-" __MODULE_STRING(MAX_UNITS) "s");
 MODULE_PARM(flowctrl, "i");
-MODULE_PARM_DESC(max_interrupt_work, "Sundance Alta maximum events handled per interrupt");
 MODULE_PARM_DESC(debug, "Sundance Alta debug level (0-5)");
 MODULE_PARM_DESC(rx_copybreak, "Sundance Alta copy breakpoint for copy-only-tiny-frames");
 MODULE_PARM_DESC(flowctrl, "Sundance Alta flow control [0|1]");
@@ -502,6 +512,7 @@
 static void netdev_error(struct net_device *dev, int intr_status);
 static void netdev_error(struct net_device *dev, int intr_status);
 static void set_rx_mode(struct net_device *dev);
+static int __set_mac_addr(struct net_device *dev);
 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);
@@ -662,8 +673,8 @@
 				np->an_enable = 1;
 			}
 		}
-		if (flowctrl == 0)
-			np->flowctrl = 0;
+		if (flowctrl == 1)
+			np->flowctrl = 1;
 	}
 
 	/* Fibre PHY? */
@@ -678,6 +689,9 @@
 	/* Reset PHY */
 	mdio_write (dev, np->phys[0], MII_BMCR, BMCR_RESET);
 	mdelay (300);
+	/* If flow control enabled, we need to advertise it.*/
+	if (np->flowctrl)
+		mdio_write (dev, np->phys[0], MII_ADVERTISE, np->mii_if.advertising | 0x0400);
 	mdio_write (dev, np->phys[0], MII_BMCR, BMCR_ANENABLE|BMCR_ANRESTART);
 	/* Force media type */
 	if (!np->an_enable) {
@@ -847,17 +861,18 @@
 	if (netif_msg_ifup(np))
 		printk(KERN_DEBUG "%s: netdev_open() irq %d.\n",
 			   dev->name, dev->irq);
-
 	init_ring(dev);
 
 	writel(np->rx_ring_dma, ioaddr + RxListPtr);
 	/* The Tx list pointer is written as packets are queued. */
 
-	for (i = 0; i < 6; i++)
-		writeb(dev->dev_addr[i], ioaddr + StationAddr + i);
-
 	/* Initialize other registers. */
+	__set_mac_addr(dev);
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
+	writew(dev->mtu + 18, ioaddr + MaxFrameSize);
+#else
 	writew(dev->mtu + 14, ioaddr + MaxFrameSize);
+#endif
 	if (dev->mtu > 2047)
 		writel(readl(ioaddr + ASICCtrl) | 0x0C, ioaddr + ASICCtrl);
 
@@ -879,7 +894,7 @@
 		writeb(0x01, ioaddr + DebugCtrl1);
 	netif_start_queue(dev);
 
-	writew(StatsEnable | RxEnable | TxEnable, ioaddr + MACCtrl1);
+	writew (StatsEnable | RxEnable | TxEnable, ioaddr + MACCtrl1);
 
 	if (netif_msg_ifup(np))
 		printk(KERN_DEBUG "%s: Done netdev_open(), status: Rx %x Tx %x "
@@ -925,7 +940,7 @@
 			printk(KERN_INFO "%s: Setting %s-duplex based on MII #%d "
 				   "negotiated capability %4.4x.\n", dev->name,
 				   duplex ? "full" : "half", np->phys[0], negotiated);
-		writew(duplex ? 0x20 : 0, ioaddr + MACCtrl0);
+		writew(readw(ioaddr + MACCtrl0) | duplex ? 0x20 : 0, ioaddr + MACCtrl0);
 	}
 }
 
@@ -951,7 +966,7 @@
 {
 	struct netdev_private *np = dev->priv;
 	long ioaddr = dev->base_addr;
-	long flag;
+	unsigned long flag;
 	
 	netif_stop_queue(dev);
 	tasklet_disable(&np->tx_tasklet);
@@ -966,11 +981,11 @@
 		for (i=0; i<TX_RING_SIZE; i++) {
 			printk(KERN_DEBUG "%02x %08x %08x %08x(%02x) %08x %08x\n", i,
 				np->tx_ring_dma + i*sizeof(*np->tx_ring),	
-				np->tx_ring[i].next_desc,
-				np->tx_ring[i].status,
-				(np->tx_ring[i].status >> 2) & 0xff,
-				np->tx_ring[i].frag[0].addr, 
-				np->tx_ring[i].frag[0].length);
+				le32_to_cpu(np->tx_ring[i].next_desc),
+				le32_to_cpu(np->tx_ring[i].status),
+				(le32_to_cpu(np->tx_ring[i].status) >> 2) & 0xff,
+				le32_to_cpu(np->tx_ring[i].frag[0].addr), 
+				le32_to_cpu(np->tx_ring[i].frag[0].length));
 		}
 		printk(KERN_DEBUG "TxListPtr=%08x netif_queue_stopped=%d\n", 
 			readl(dev->base_addr + TxListPtr), 
@@ -1157,7 +1172,6 @@
 	struct net_device *dev = (struct net_device *)dev_instance;
 	struct netdev_private *np;
 	long ioaddr;
-	int boguscnt = max_interrupt_work;
 	int hw_frame_id;
 	int tx_cnt;
 	int tx_status;
@@ -1226,11 +1240,14 @@
 				int entry = np->dirty_tx % TX_RING_SIZE;
 				struct sk_buff *skb;
 				int sw_frame_id;
-				sw_frame_id = (np->tx_ring[entry].status >> 2) & 0xff;
-					if (sw_frame_id == hw_frame_id &&
-						!(np->tx_ring[entry].status & 0x00010000))
+				sw_frame_id = (le32_to_cpu(
+					np->tx_ring[entry].status) >> 2) & 0xff;
+				if (sw_frame_id == hw_frame_id &&
+					!(le32_to_cpu(np->tx_ring[entry].status)
+					& 0x00010000))
 						break;
-					if (sw_frame_id == (hw_frame_id + 1) % TX_RING_SIZE)
+				if (sw_frame_id == (hw_frame_id + 1) % 
+					TX_RING_SIZE)
 						break;
 				skb = np->tx_skbuff[entry];
 				/* Free the original skb. */
@@ -1248,7 +1265,8 @@
 			for (; np->cur_tx - np->dirty_tx > 0; np->dirty_tx++) {
 				int entry = np->dirty_tx % TX_RING_SIZE;
 				struct sk_buff *skb;
-				if (!(np->tx_ring[entry].status & 0x00010000))
+				if (!(le32_to_cpu(np->tx_ring[entry].status) 
+							& 0x00010000))
 					break;
 				skb = np->tx_skbuff[entry];
 				/* Free the original skb. */
@@ -1271,15 +1289,7 @@
 		/* Abnormal error summary/uncommon events handlers. */
 		if (intr_status & (IntrPCIErr | LinkChange | StatsMax))
 			netdev_error(dev, intr_status);
-		if (--boguscnt < 0) {
-			get_stats(dev);
-			if (netif_msg_hw(np))
-				printk(KERN_WARNING "%s: Too much work at interrupt, "
-				   "status=0x%4.4x / 0x%4.4x.\n",
-				   dev->name, intr_status, readw(ioaddr + IntrClear));
-			break;
-		}
-	} while (1);
+	} while (0);
 	if (netif_msg_intr(np))
 		printk(KERN_DEBUG "%s: exiting interrupt, status=%#4.4x.\n",
 			   dev->name, readw(ioaddr + IntrStatus));
@@ -1447,9 +1457,12 @@
 				"full" : "half");
 		}
 		check_duplex (dev);
-		if (np->flowctrl == 0)
-			writew(readw(ioaddr + MACCtrl0) & ~EnbFlowCtrl,
+		if (np->flowctrl && np->mii_if.full_duplex) {
+			writew(readw(ioaddr + MulticastFilter1+2) | 0x0200,
+				ioaddr + MulticastFilter1+2);
+			writew(readw(ioaddr + MACCtrl0) | EnbFlowCtrl,
 				ioaddr + MACCtrl0);
+		}
 	}
 	if (intr_status & StatsMax) {
 		get_stats(dev);
@@ -1463,8 +1476,8 @@
 
 static struct net_device_stats *get_stats(struct net_device *dev)
 {
-	long ioaddr = dev->base_addr;
 	struct netdev_private *np = dev->priv;
+	long ioaddr = dev->base_addr;
 	int i;
 
 	/* We should lock this segment of code for SMP eventually, although
@@ -1477,7 +1490,7 @@
 	np->stats.collisions += readb(ioaddr + StatsLateColl);
 	np->stats.collisions += readb(ioaddr + StatsMultiColl);
 	np->stats.collisions += readb(ioaddr + StatsOneColl);
-	readb(ioaddr + StatsCarrierError);
+	np->stats.tx_carrier_errors += readb(ioaddr + StatsCarrierError);
 	readb(ioaddr + StatsTxDefer);
 	for (i = StatsTxDefer; i <= StatsMcastRx; i++)
 		readb(ioaddr + i);
@@ -1492,6 +1505,7 @@
 static void set_rx_mode(struct net_device *dev)
 {
 	long ioaddr = dev->base_addr;
+	struct netdev_private *np = dev->priv;
 	u16 mc_filter[4];			/* Multicast hash filter */
 	u32 rx_mode;
 	int i;
@@ -1524,11 +1538,28 @@
 		writeb(AcceptBroadcast | AcceptMyPhys, ioaddr + RxMode);
 		return;
 	}
+	if (np->mii_if.full_duplex && np->flowctrl)
+		mc_filter[3] |= 0x0200;
+
 	for (i = 0; i < 4; i++)
 		writew(mc_filter[i], ioaddr + MulticastFilter0 + i*2);
 	writeb(rx_mode, ioaddr + RxMode);
 }
 
+static int __set_mac_addr(struct net_device *dev)
+{
+	u16 addr16;
+
+	addr16 = (dev->dev_addr[0] | (dev->dev_addr[1] << 8));
+	writew(addr16, dev->base_addr + StationAddr);
+	addr16 = (dev->dev_addr[2] | (dev->dev_addr[3] << 8));
+	writew(addr16, dev->base_addr + StationAddr+2);
+	addr16 = (dev->dev_addr[4] | (dev->dev_addr[5] << 8));
+	writew(addr16, dev->base_addr + StationAddr+4);
+	return 0;
+}
+	
+
 static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
 {
 	struct netdev_private *np = dev->priv;
@@ -1615,6 +1646,7 @@
 	struct mii_ioctl_data *data = (struct mii_ioctl_data *) & rq->ifr_data;
 	int rc;
 	int i;
+	long ioaddr = dev->base_addr;
 
 	if (!netif_running(dev))
 		return -EINVAL;
@@ -1632,11 +1664,12 @@
 		for (i=0; i<TX_RING_SIZE; i++) {
 			printk(KERN_DEBUG "%02x %08x %08x %08x(%02x) %08x %08x\n", i,
 				np->tx_ring_dma + i*sizeof(*np->tx_ring),	
-				np->tx_ring[i].next_desc,
-				np->tx_ring[i].status,
-				(np->tx_ring[i].status >> 2) & 0xff,
-				np->tx_ring[i].frag[0].addr, 
-				np->tx_ring[i].frag[0].length);
+				le32_to_cpu(np->tx_ring[i].next_desc),
+				le32_to_cpu(np->tx_ring[i].status),
+				(le32_to_cpu(np->tx_ring[i].status) >> 2) 
+					& 0xff,
+				le32_to_cpu(np->tx_ring[i].frag[0].addr), 
+				le32_to_cpu(np->tx_ring[i].frag[0].length));
 		}
 		printk(KERN_DEBUG "TxListPtr=%08x netif_queue_stopped=%d\n", 
 			readl(dev->base_addr + TxListPtr), 
@@ -1646,6 +1679,7 @@
 			np->dirty_tx, np->dirty_tx % TX_RING_SIZE);
 		printk(KERN_DEBUG "cur_rx=%d dirty_rx=%d\n", np->cur_rx, np->dirty_rx);
 		printk(KERN_DEBUG "cur_task=%d\n", np->cur_task);
+		printk(KERN_DEBUG "TxStatus=%04x\n", readw(ioaddr + TxStatus));
 			return 0;
 	}
 				
@@ -1753,10 +1787,10 @@
 }
 
 static struct pci_driver sundance_driver = {
-	name:		DRV_NAME,
-	id_table:	sundance_pci_tbl,
-	probe:		sundance_probe1,
-	remove:		__devexit_p(sundance_remove1),
+	.name		= DRV_NAME,
+	.id_table	= sundance_pci_tbl,
+	.probe		= sundance_probe1,
+	.remove		= __devexit_p(sundance_remove1),
 };
 
 static int __init sundance_init(void)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/sunhme.c linux-2.4.22-pre2/drivers/net/sunhme.c
--- linux-2.4.21/drivers/net/sunhme.c	2003-06-26 21:45:09.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/sunhme.c	2003-06-26 21:43:16.000000000 +0000
@@ -3091,8 +3091,12 @@
 
 #ifdef __sparc__
 	hp->hm_revision = prom_getintdefault(node, "hm-rev", 0xff);
-	if (hp->hm_revision == 0xff)
-		hp->hm_revision = 0xa0;
+	if (hp->hm_revision == 0xff) {
+		unsigned char prev;
+
+		pci_read_config_byte(pdev, PCI_REVISION_ID, &prev);
+		hp->hm_revision = 0xc0 | (prev & 0x0f);
+	}
 #else
 	/* works with this on non-sparc hosts */
 	hp->hm_revision = 0x20;
@@ -3101,7 +3105,7 @@
 	/* Now enable the feature flags we can. */
 	if (hp->hm_revision == 0x20 || hp->hm_revision == 0x21)
 		hp->happy_flags = HFLAG_20_21;
-	else if (hp->hm_revision != 0xa0)
+	else if (hp->hm_revision != 0xa0 && hp->hm_revision != 0xc0)
 		hp->happy_flags = HFLAG_NOT_A0;
 
 	if (qp != NULL)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/tg3.c linux-2.4.22-pre2/drivers/net/tg3.c
--- linux-2.4.21/drivers/net/tg3.c	2003-06-26 21:45:09.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/tg3.c	2003-06-26 21:43:19.000000000 +0000
@@ -29,10 +29,6 @@
 #include <asm/byteorder.h>
 #include <asm/uaccess.h>
 
-#ifndef PCI_DMA_BUS_IS_PHYS
-#define PCI_DMA_BUS_IS_PHYS 1
-#endif
-
 #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
 #define TG3_VLAN_TAG_USED 1
 #else
@@ -50,8 +46,8 @@
 
 #define DRV_MODULE_NAME		"tg3"
 #define PFX DRV_MODULE_NAME	": "
-#define DRV_MODULE_VERSION	"1.5"
-#define DRV_MODULE_RELDATE	"March 21, 2003"
+#define DRV_MODULE_VERSION	"1.6"
+#define DRV_MODULE_RELDATE	"June 11, 2003"
 
 #define TG3_DEF_MAC_MODE	0
 #define TG3_DEF_RX_MODE		0
@@ -2224,73 +2220,17 @@
 	schedule_task(&tp->reset_task);
 }
 
-#if !PCI_DMA_BUS_IS_PHYS
-static void tg3_set_txd_addr(struct tg3 *tp, int entry, dma_addr_t mapping)
-{
-	if (tp->tg3_flags & TG3_FLAG_HOST_TXDS) {
-		struct tg3_tx_buffer_desc *txd = &tp->tx_ring[entry];
-
-		txd->addr_hi = ((u64) mapping >> 32);
-		txd->addr_lo = ((u64) mapping & 0xffffffff);
-	} else {
-		unsigned long txd;
-
-		txd = (tp->regs +
-		       NIC_SRAM_WIN_BASE +
-		       NIC_SRAM_TX_BUFFER_DESC);
-		txd += (entry * TXD_SIZE);
-
-		if (sizeof(dma_addr_t) != sizeof(u32))
-			writel(((u64) mapping >> 32),
-			       txd + TXD_ADDR + TG3_64BIT_REG_HIGH);
-
-		writel(((u64) mapping & 0xffffffff),
-		       txd + TXD_ADDR + TG3_64BIT_REG_LOW);
-	}
-}
-#endif
-
 static void tg3_set_txd(struct tg3 *, int, dma_addr_t, int, u32, u32);
 
 static int tigon3_4gb_hwbug_workaround(struct tg3 *tp, struct sk_buff *skb,
 				       u32 guilty_entry, int guilty_len,
 				       u32 last_plus_one, u32 *start, u32 mss)
 {
+	struct sk_buff *new_skb = skb_copy(skb, GFP_ATOMIC);
 	dma_addr_t new_addr;
 	u32 entry = *start;
 	int i;
 
-#if !PCI_DMA_BUS_IS_PHYS
-	/* IOMMU, just map the guilty area again which is guarenteed to
-	 * use different addresses.
-	 */
-
-	i = 0;
-	while (entry != guilty_entry) {
-		entry = NEXT_TX(entry);
-		i++;
-	}
-	if (i == 0) {
-		new_addr = pci_map_single(tp->pdev, skb->data, guilty_len,
-					  PCI_DMA_TODEVICE);
-	} else {
-		skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1];
-
-		new_addr = pci_map_page(tp->pdev,
-					frag->page, frag->page_offset,
-					guilty_len, PCI_DMA_TODEVICE);
-	}
-	pci_unmap_single(tp->pdev, pci_unmap_addr(&tp->tx_buffers[guilty_entry],
-						  mapping),
-			 guilty_len, PCI_DMA_TODEVICE);
-	tg3_set_txd_addr(tp, guilty_entry, new_addr);
-	pci_unmap_addr_set(&tp->tx_buffers[guilty_entry], mapping,
-			   new_addr);
-	*start = last_plus_one;
-#else
-	/* Oh well, no IOMMU, have to allocate a whole new SKB. */
-	struct sk_buff *new_skb = skb_copy(skb, GFP_ATOMIC);
-
 	if (!new_skb) {
 		dev_kfree_skb(skb);
 		return -1;
@@ -2327,7 +2267,6 @@
 	}
 
 	dev_kfree_skb(skb);
-#endif
 
 	return 0;
 }
@@ -6703,7 +6642,7 @@
 	}
 
 	/* Configure DMA attributes. */
-	if (!pci_set_dma_mask(pdev, (u64) 0xffffffffffffffff)) {
+	if (!pci_set_dma_mask(pdev, (u64) 0xffffffffffffffffULL)) {
 		pci_using_dac = 1;
 	} else {
 		err = pci_set_dma_mask(pdev, (u64) 0xffffffff);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/tlan.c linux-2.4.22-pre2/drivers/net/tlan.c
--- linux-2.4.21/drivers/net/tlan.c	2002-08-03 00:39:44.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/tlan.c	2003-06-26 21:43:12.000000000 +0000
@@ -166,19 +166,18 @@
  *	                       Thanks to Gunnar Eikman
  *******************************************************************************/
 
-                                                                                
 #include <linux/module.h>
-
-#include "tlan.h"
-
 #include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/pci.h>
+#include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/delay.h>
 #include <linux/spinlock.h>
+#include <linux/tqueue.h>
 #include <linux/mii.h>
 
+#include "tlan.h"
 
 typedef u32 (TLanIntVectorFunc)( struct net_device *, u16 );
 
@@ -208,7 +207,6 @@
 MODULE_PARM_DESC(speed, "ThunderLAN port speen setting(s) (0,10,100)");
 MODULE_PARM_DESC(debug, "ThunderLAN debug mask");
 MODULE_PARM_DESC(bbuf, "ThunderLAN use big buffer (0-1)");
-EXPORT_NO_SYMBOLS;
 
 /* Define this to enable Link beat monitoring */
 #undef MONITOR
@@ -218,10 +216,11 @@
 
 static	int		bbuf;
 static	u8		*TLanPadBuffer;
+static  dma_addr_t	TLanPadBufferDMA;
 static	char		TLanSignature[] = "TLAN";
-static const char tlan_banner[] = "ThunderLAN driver v1.15\n";
-static int tlan_have_pci;
-static int tlan_have_eisa;
+static  const char tlan_banner[] = "ThunderLAN driver v1.15\n";
+static  int tlan_have_pci;
+static  int tlan_have_eisa;
 
 const char *media[] = {
 	"10BaseT-HD ", "10BaseT-FD ","100baseTx-HD ", 
@@ -347,6 +346,27 @@
 static int	TLan_EeReadByte( struct net_device *, u8, u8 * );
 
 
+static void 
+TLan_StoreSKB( struct tlan_list_tag *tag, struct sk_buff *skb)
+{
+	unsigned long addr = (unsigned long)skb;
+	tag->buffer[9].address = (u32)addr;
+	addr >>= 31;	/* >>= 32 is undefined for 32bit arch, stupid C */
+	addr >>= 1;
+	tag->buffer[8].address = (u32)addr;
+}
+
+static struct sk_buff *
+TLan_GetSKB( struct tlan_list_tag *tag)
+{
+	unsigned long addr = tag->buffer[8].address;
+	addr <<= 31;
+	addr <<= 1;
+	addr |= tag->buffer[9].address;
+	return (struct sk_buff *) addr;
+}
+
+
 static TLanIntVectorFunc *TLanIntVector[TLAN_INT_NUMBER_OF_INTS] = {
 	TLan_HandleInvalid,
 	TLan_HandleTxEOF,
@@ -422,10 +442,10 @@
 	unregister_netdev( dev );
 
 	if ( priv->dmaStorage ) {
-		kfree( priv->dmaStorage );
+		pci_free_consistent(priv->pciDev, priv->dmaSize, priv->dmaStorage, priv->dmaStorageDMA );
 	}
 
-	release_region( dev->base_addr, 0x10 );
+	pci_release_regions(pdev);
 	
 	kfree( dev );
 		
@@ -433,10 +453,10 @@
 } 
 
 static struct pci_driver tlan_driver = {
-	name:		"tlan",
-	id_table:	tlan_pci_tbl,
-	probe:		tlan_init_one,
-	remove:		__devexit_p(tlan_remove_one),	
+	.name		= "tlan",
+	.id_table	= tlan_pci_tbl,
+	.probe		= tlan_init_one,
+	.remove		= __devexit_p(tlan_remove_one),	
 };
 
 static int __init tlan_probe(void)
@@ -445,8 +465,7 @@
 	
 	printk(KERN_INFO "%s", tlan_banner);
 	
-	TLanPadBuffer = (u8 *) kmalloc(TLAN_MIN_FRAME_SIZE, 
-					GFP_KERNEL);
+	TLanPadBuffer = (u8 *) pci_alloc_consistent(NULL, TLAN_MIN_FRAME_SIZE, &TLanPadBufferDMA);
 
 	if (TLanPadBuffer == NULL) {
 		printk(KERN_ERR "TLAN: Could not allocate memory for pad buffer.\n");
@@ -471,7 +490,7 @@
 
 	if (TLanDevicesInstalled == 0) {
 		pci_unregister_driver(&tlan_driver);
-		kfree(TLanPadBuffer);
+		pci_free_consistent(NULL, TLAN_MIN_FRAME_SIZE, TLanPadBuffer, TLanPadBufferDMA);
 		return -ENODEV;
 	}
 	return 0;
@@ -512,26 +531,44 @@
 	TLanPrivateInfo    *priv;
 	u8		   pci_rev;
 	u16		   device_id;
-	int		   reg;
+	int		   reg, rc = -ENODEV;
+
+	if (pdev) {
+		rc = pci_enable_device(pdev);
+		if (rc)
+			return rc;
 
-	if (pdev && pci_enable_device(pdev))
-		return -EIO;
+		rc = pci_request_regions(pdev, TLanSignature);
+		if (rc) {
+			printk(KERN_ERR "TLAN: Could not reserve IO regions\n");
+			goto err_out;
+		}
+	}
 
-	dev = init_etherdev(NULL, sizeof(TLanPrivateInfo));
+	dev = alloc_etherdev(sizeof(TLanPrivateInfo));
 	if (dev == NULL) {
 		printk(KERN_ERR "TLAN: Could not allocate memory for device.\n");
-		return -ENOMEM;
+		rc = -ENOMEM;
+		goto err_out_regions;
 	}
 	SET_MODULE_OWNER(dev);
 	
 	priv = dev->priv;
 
+	priv->pciDev = pdev;
+	
 	/* Is this a PCI device? */
 	if (pdev) {
 		u32 		   pci_io_base = 0;
 
 		priv->adapter = &board_info[ent->driver_data];
 
+		rc = pci_set_dma_mask(pdev, 0xFFFFFFFF);
+		if (rc) {
+			printk(KERN_ERR "TLAN: No suitable PCI mapping available.\n");
+			goto err_out_free_dev;
+		}
+
 		pci_read_config_byte ( pdev, PCI_REVISION_ID, &pci_rev);
 
 		for ( reg= 0; reg <= 5; reg ++ ) {
@@ -544,9 +581,8 @@
 		}
 		if (!pci_io_base) {
 			printk(KERN_ERR "TLAN: No IO mappings available\n");
-			unregister_netdev(dev);
-			kfree(dev);
-			return -ENODEV;
+			rc = -EIO;
+			goto err_out_free_dev;
 		}
 		
 		dev->base_addr = pci_io_base;
@@ -592,19 +628,22 @@
 	
 	/* This will be used when we get an adapter error from
 	 * within our irq handler */
-	INIT_LIST_HEAD(&priv->tlan_tqueue.list);
-	priv->tlan_tqueue.sync = 0;
-	priv->tlan_tqueue.routine = (void *)(void*)TLan_tx_timeout;
-	priv->tlan_tqueue.data = dev;
+	INIT_TQUEUE(&priv->tlan_tqueue, (void *)(void*)TLan_tx_timeout, dev);
 
 	spin_lock_init(&priv->lock);
 	
-	if (TLan_Init(dev)) {
+	rc = TLan_Init(dev);
+	if (rc) {
+		printk(KERN_ERR "TLAN: Could not set up device.\n");
+		goto err_out_free_dev;
+	}
+
+	rc = register_netdev(dev);
+	if (rc) {
 		printk(KERN_ERR "TLAN: Could not register device.\n");
-		unregister_netdev(dev);
-		kfree(dev);
-		return -EAGAIN;
-	} else {
+		goto err_out_uninit;
+	}
+
 	
 	TLanDevicesInstalled++;
 	boards_found++;
@@ -625,8 +664,19 @@
 			priv->adapter->deviceLabel,
 			priv->adapterRev);
 	return 0;
-	}
 
+err_out_uninit:
+	pci_free_consistent(priv->pciDev, priv->dmaSize, priv->dmaStorage,
+			    priv->dmaStorageDMA );
+err_out_free_dev:
+	kfree(dev);
+err_out_regions:
+	if (pdev)
+		pci_release_regions(pdev);
+err_out:
+	if (pdev)
+		pci_disable_device(pdev);
+	return rc;
 }
 
 
@@ -639,7 +689,7 @@
 		dev = TLan_Eisa_Devices;
 		priv = dev->priv;
 		if (priv->dmaStorage) {
-			kfree(priv->dmaStorage);
+			pci_free_consistent(priv->pciDev, priv->dmaSize, priv->dmaStorage, priv->dmaStorageDMA );
 		}
 		release_region( dev->base_addr, 0x10);
 		unregister_netdev( dev );
@@ -657,7 +707,7 @@
 	if (tlan_have_eisa)
 		TLan_Eisa_Cleanup();
 
-	kfree( TLanPadBuffer );
+	pci_free_consistent(NULL, TLAN_MIN_FRAME_SIZE, TLanPadBuffer, TLanPadBufferDMA);
 
 }
 
@@ -792,15 +842,6 @@
 
 	priv = dev->priv;
 	
-	if (!priv->is_eisa)	/* EISA devices have already requested IO */
-		if (!request_region( dev->base_addr, 0x10, TLanSignature )) {
-			printk(KERN_ERR "TLAN: %s: IO port region 0x%lx size 0x%x in use.\n",
-				dev->name,
-				dev->base_addr,
-				0x10 );
-			return -EIO;
-		}
-	
 	if ( bbuf ) {
 		dma_size = ( TLAN_NUM_RX_LISTS + TLAN_NUM_TX_LISTS )
 	           * ( sizeof(TLanList) + TLAN_MAX_FRAME_SIZE );
@@ -808,21 +849,25 @@
 		dma_size = ( TLAN_NUM_RX_LISTS + TLAN_NUM_TX_LISTS )
 	           * ( sizeof(TLanList) );
 	}
-	priv->dmaStorage = kmalloc(dma_size, GFP_KERNEL | GFP_DMA);
+	priv->dmaStorage = pci_alloc_consistent(priv->pciDev, dma_size, &priv->dmaStorageDMA);
+	priv->dmaSize = dma_size;
+	
 	if ( priv->dmaStorage == NULL ) {
 		printk(KERN_ERR "TLAN:  Could not allocate lists and buffers for %s.\n",
 			dev->name );
-		release_region( dev->base_addr, 0x10 );
 		return -ENOMEM;
 	}
 	memset( priv->dmaStorage, 0, dma_size );
 	priv->rxList = (TLanList *) 
 		       ( ( ( (u32) priv->dmaStorage ) + 7 ) & 0xFFFFFFF8 );
+	priv->rxListDMA = ( ( ( (u32) priv->dmaStorageDMA ) + 7 ) & 0xFFFFFFF8 );
 	priv->txList = priv->rxList + TLAN_NUM_RX_LISTS;
+	priv->txListDMA = priv->rxListDMA + sizeof(TLanList) * TLAN_NUM_RX_LISTS;
 	if ( bbuf ) {
 		priv->rxBuffer = (u8 *) ( priv->txList + TLAN_NUM_TX_LISTS );
-		priv->txBuffer = priv->rxBuffer
-				 + ( TLAN_NUM_RX_LISTS * TLAN_MAX_FRAME_SIZE );
+		priv->rxBufferDMA =priv->txListDMA + sizeof(TLanList) * TLAN_NUM_TX_LISTS;
+		priv->txBuffer = priv->rxBuffer + ( TLAN_NUM_RX_LISTS * TLAN_MAX_FRAME_SIZE );
+		priv->txBufferDMA = priv->rxBufferDMA + ( TLAN_NUM_RX_LISTS * TLAN_MAX_FRAME_SIZE );
 	}
 
 	err = 0;
@@ -1003,6 +1048,7 @@
 {
 	TLanPrivateInfo *priv = dev->priv;
 	TLanList	*tail_list;
+	dma_addr_t	tail_list_phys;
 	u8		*tail_buffer;
 	int		pad;
 	unsigned long	flags;
@@ -1014,6 +1060,7 @@
 	}
 
 	tail_list = priv->txList + priv->txTail;
+	tail_list_phys = priv->txListDMA + sizeof(TLanList) * priv->txTail;
 	
 	if ( tail_list->cStat != TLAN_CSTAT_UNUSED ) {
 		TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT:  %s is busy (Head=%d Tail=%d)\n", dev->name, priv->txHead, priv->txTail );
@@ -1028,8 +1075,8 @@
 		tail_buffer = priv->txBuffer + ( priv->txTail * TLAN_MAX_FRAME_SIZE );
 		memcpy( tail_buffer, skb->data, skb->len );
 	} else {
-		tail_list->buffer[0].address = virt_to_bus( skb->data );
-		tail_list->buffer[9].address = (u32) skb;
+		tail_list->buffer[0].address = pci_map_single(priv->pciDev, skb->data, skb->len, PCI_DMA_TODEVICE);
+		TLan_StoreSKB(tail_list, skb);
 	}
 
 	pad = TLAN_MIN_FRAME_SIZE - skb->len;
@@ -1038,7 +1085,7 @@
 		tail_list->frameSize = (u16) skb->len + pad;
 		tail_list->buffer[0].count = (u32) skb->len;
 		tail_list->buffer[1].count = TLAN_LAST_BUFFER | (u32) pad;
-		tail_list->buffer[1].address = virt_to_bus( TLanPadBuffer );
+		tail_list->buffer[1].address = TLanPadBufferDMA;
 	} else {
 		tail_list->frameSize = (u16) skb->len;
 		tail_list->buffer[0].count = TLAN_LAST_BUFFER | (u32) skb->len;
@@ -1051,14 +1098,14 @@
 	if ( ! priv->txInProgress ) {
 		priv->txInProgress = 1;
 		TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT:  Starting TX on buffer %d\n", priv->txTail );
-		outl( virt_to_bus( tail_list ), dev->base_addr + TLAN_CH_PARM );
+		outl( tail_list_phys, dev->base_addr + TLAN_CH_PARM );
 		outl( TLAN_HC_GO, dev->base_addr + TLAN_HOST_CMD );
 	} else {
 		TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT:  Adding buffer %d to TX channel\n", priv->txTail );
 		if ( priv->txTail == 0 ) {
-			( priv->txList + ( TLAN_NUM_TX_LISTS - 1 ) )->forward = virt_to_bus( tail_list );
+			( priv->txList + ( TLAN_NUM_TX_LISTS - 1 ) )->forward = tail_list_phys;
 		} else {
-			( priv->txList + ( priv->txTail - 1 ) )->forward = virt_to_bus( tail_list );
+			( priv->txList + ( priv->txTail - 1 ) )->forward = tail_list_phys;
 		}
 	}
 	spin_unlock_irqrestore(&priv->lock, flags);
@@ -1344,6 +1391,7 @@
 	TLanPrivateInfo	*priv = dev->priv;
 	int		eoc = 0;
 	TLanList	*head_list;
+	dma_addr_t	head_list_phys;
 	u32		ack = 0;
 	u16		tmpCStat;
 	
@@ -1353,7 +1401,10 @@
 	while (((tmpCStat = head_list->cStat ) & TLAN_CSTAT_FRM_CMP) && (ack < 255)) {
 		ack++;
 		if ( ! bbuf ) {
-			dev_kfree_skb_any( (struct sk_buff *) head_list->buffer[9].address );
+			struct sk_buff *skb = TLan_GetSKB(head_list);
+			pci_unmap_single(priv->pciDev, head_list->buffer[0].address, skb->len, PCI_DMA_TODEVICE);
+			dev_kfree_skb_any(skb);
+			head_list->buffer[8].address = 0;
 			head_list->buffer[9].address = 0;
 		}
 	
@@ -1374,8 +1425,9 @@
 	if ( eoc ) {
 		TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT:  Handling TX EOC (Head=%d Tail=%d)\n", priv->txHead, priv->txTail );
 		head_list = priv->txList + priv->txHead;
+		head_list_phys = priv->txListDMA + sizeof(TLanList) * priv->txHead;
 		if ( ( head_list->cStat & TLAN_CSTAT_READY ) == TLAN_CSTAT_READY ) {
-			outl( virt_to_bus( head_list ), dev->base_addr + TLAN_CH_PARM );
+			outl(head_list_phys, dev->base_addr + TLAN_CH_PARM );
 			ack |= TLAN_HC_GO;
 		} else {
 			priv->txInProgress = 0;
@@ -1468,9 +1520,11 @@
 	void		*t;
 	u32		frameSize;
 	u16		tmpCStat;
+	dma_addr_t	head_list_phys;
 
 	TLAN_DBG( TLAN_DEBUG_RX, "RECEIVE:  Handling RX EOF (Head=%d Tail=%d)\n", priv->rxHead, priv->rxTail );
 	head_list = priv->rxList + priv->rxHead;
+	head_list_phys = priv->rxListDMA + sizeof(TLanList) * priv->rxHead;
 	
 	while (((tmpCStat = head_list->cStat) & TLAN_CSTAT_FRM_CMP) && (ack < 255)) {
 		frameSize = head_list->frameSize;
@@ -1498,17 +1552,16 @@
 			struct sk_buff *new_skb;
 		
 			/*
-		 	*	I changed the algorithm here. What we now do
-		 	*	is allocate the new frame. If this fails we
-		 	*	simply recycle the frame.
-		 	*/
+		 	 *	I changed the algorithm here. What we now do
+		 	 *	is allocate the new frame. If this fails we
+		 	 *	simply recycle the frame.
+		 	 */
 		
 			new_skb = dev_alloc_skb( TLAN_MAX_FRAME_SIZE + 7 );
 			
 			if ( new_skb != NULL ) {
-				/* If this ever happened it would be a problem */
-				/* not any more - ac */
-				skb = (struct sk_buff *) head_list->buffer[9].address;
+				skb = TLan_GetSKB(head_list);
+				pci_unmap_single(priv->pciDev, head_list->buffer[0].address, TLAN_MAX_FRAME_SIZE, PCI_DMA_FROMDEVICE);
 				skb_trim( skb, frameSize );
 
 				priv->stats.rx_bytes += frameSize;
@@ -1519,9 +1572,9 @@
 				new_skb->dev = dev;
 				skb_reserve( new_skb, 2 );
 				t = (void *) skb_put( new_skb, TLAN_MAX_FRAME_SIZE );
-				head_list->buffer[0].address = virt_to_bus( t );
+				head_list->buffer[0].address = pci_map_single(priv->pciDev, new_skb->data, TLAN_MAX_FRAME_SIZE, PCI_DMA_FROMDEVICE);
 				head_list->buffer[8].address = (u32) t;
-				head_list->buffer[9].address = (u32) new_skb;
+				TLan_StoreSKB(head_list, new_skb);
 			} else 
 				printk(KERN_WARNING "TLAN:  Couldn't allocate memory for received data.\n" );
 		}
@@ -1529,11 +1582,12 @@
 		head_list->forward = 0;
 		head_list->cStat = 0;
 		tail_list = priv->rxList + priv->rxTail;
-		tail_list->forward = virt_to_bus( head_list );
+		tail_list->forward = head_list_phys;
 
 		CIRC_INC( priv->rxHead, TLAN_NUM_RX_LISTS );
 		CIRC_INC( priv->rxTail, TLAN_NUM_RX_LISTS );
 		head_list = priv->rxList + priv->rxHead;
+		head_list_phys = priv->rxListDMA + sizeof(TLanList) * priv->rxHead;
 	}
 
 	if (!ack)
@@ -1545,7 +1599,8 @@
 	if ( eoc ) { 
 		TLAN_DBG( TLAN_DEBUG_RX, "RECEIVE:  Handling RX EOC (Head=%d Tail=%d)\n", priv->rxHead, priv->rxTail );
 		head_list = priv->rxList + priv->rxHead;
-		outl( virt_to_bus( head_list ), dev->base_addr + TLAN_CH_PARM );
+		head_list_phys = priv->rxListDMA + sizeof(TLanList) * priv->rxHead;
+		outl(head_list_phys, dev->base_addr + TLAN_CH_PARM );
 		ack |= TLAN_HC_GO | TLAN_HC_RT;
 		priv->rxEocCount++;
 	}
@@ -1611,7 +1666,7 @@
 	 *		host_int	The contents of the HOST_INT
 	 *				port.
 	 *
-	 *	This driver is structured to determine EOC occurances by
+	 *	This driver is structured to determine EOC occurrences by
 	 *	reading the CSTAT member of the list structure.  Tx EOC
 	 *	interrupts are disabled via the DIO INTDIS register.
 	 *	However, TLAN chips before revision 3.0 didn't have this
@@ -1624,15 +1679,17 @@
 {
 	TLanPrivateInfo	*priv = dev->priv;
 	TLanList		*head_list;
+	dma_addr_t		head_list_phys;
 	u32			ack = 1;
 	
 	host_int = 0;
 	if ( priv->tlanRev < 0x30 ) {
 		TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT:  Handling TX EOC (Head=%d Tail=%d) -- IRQ\n", priv->txHead, priv->txTail );
 		head_list = priv->txList + priv->txHead;
+		head_list_phys = priv->txListDMA + sizeof(TLanList) * priv->txHead;
 		if ( ( head_list->cStat & TLAN_CSTAT_READY ) == TLAN_CSTAT_READY ) {
 			netif_stop_queue(dev);
-			outl( virt_to_bus( head_list ), dev->base_addr + TLAN_CH_PARM );
+			outl( head_list_phys, dev->base_addr + TLAN_CH_PARM );
 			ack |= TLAN_HC_GO;
 		} else {
 			priv->txInProgress = 0;
@@ -1683,10 +1740,9 @@
 		printk( "TLAN:  %s: Adaptor Error = 0x%x\n", dev->name, error );
 		TLan_ReadAndClearStats( dev, TLAN_RECORD );
 		outl( TLAN_HC_AD_RST, dev->base_addr + TLAN_HOST_CMD );
-		
-		queue_task(&priv->tlan_tqueue, &tq_immediate);
-		mark_bh(IMMEDIATE_BH);
-		
+
+		schedule_task(&priv->tlan_tqueue);
+
 		netif_wake_queue(dev);
 		ack = 0;
 	} else {
@@ -1733,7 +1789,7 @@
 	 *		host_int	The contents of the HOST_INT
 	 *				port.
 	 *
-	 *	This driver is structured to determine EOC occurances by
+	 *	This driver is structured to determine EOC occurrences by
 	 *	reading the CSTAT member of the list structure.  Rx EOC
 	 *	interrupts are disabled via the DIO INTDIS register.
 	 *	However, TLAN chips before revision 3.0 didn't have this
@@ -1745,13 +1801,13 @@
 u32 TLan_HandleRxEOC( struct net_device *dev, u16 host_int )
 {
 	TLanPrivateInfo	*priv = dev->priv;
-	TLanList	*head_list;
+	dma_addr_t	head_list_phys;
 	u32		ack = 1;
 
 	if (  priv->tlanRev < 0x30 ) {
 		TLAN_DBG( TLAN_DEBUG_RX, "RECEIVE:  Handling RX EOC (Head=%d Tail=%d) -- IRQ\n", priv->rxHead, priv->rxTail );
-		head_list = priv->rxList + priv->rxHead;
-		outl( virt_to_bus( head_list ), dev->base_addr + TLAN_CH_PARM );
+		head_list_phys = priv->rxListDMA + sizeof(TLanList) * priv->rxHead;
+		outl( head_list_phys, dev->base_addr + TLAN_CH_PARM );
 		ack |= TLAN_HC_GO | TLAN_HC_RT;
 		priv->rxEocCount++;
 	}
@@ -1888,6 +1944,7 @@
 	TLanPrivateInfo *priv = dev->priv;
 	int		i;
 	TLanList	*list;
+	dma_addr_t	list_phys;
 	struct sk_buff	*skb;
 	void		*t = NULL;
 
@@ -1897,12 +1954,13 @@
 		list = priv->txList + i;
 		list->cStat = TLAN_CSTAT_UNUSED;
 		if ( bbuf ) {
-			list->buffer[0].address = virt_to_bus( priv->txBuffer + ( i * TLAN_MAX_FRAME_SIZE ) );
+			list->buffer[0].address = priv->txBufferDMA + ( i * TLAN_MAX_FRAME_SIZE );
 		} else {
 			list->buffer[0].address = 0;
 		}
 		list->buffer[2].count = 0;
 		list->buffer[2].address = 0;
+		list->buffer[8].address = 0;
 		list->buffer[9].address = 0;
 	}
 
@@ -1910,11 +1968,12 @@
 	priv->rxTail = TLAN_NUM_RX_LISTS - 1;
 	for ( i = 0; i < TLAN_NUM_RX_LISTS; i++ ) {
 		list = priv->rxList + i;
+		list_phys = priv->rxListDMA + sizeof(TLanList) * i;
 		list->cStat = TLAN_CSTAT_READY;
 		list->frameSize = TLAN_MAX_FRAME_SIZE;
 		list->buffer[0].count = TLAN_MAX_FRAME_SIZE | TLAN_LAST_BUFFER;
 		if ( bbuf ) {
-			list->buffer[0].address = virt_to_bus( priv->rxBuffer + ( i * TLAN_MAX_FRAME_SIZE ) );
+			list->buffer[0].address = priv->rxBufferDMA + ( i * TLAN_MAX_FRAME_SIZE );
 		} else {
 			skb = dev_alloc_skb( TLAN_MAX_FRAME_SIZE + 7 );
 			if ( skb == NULL ) {
@@ -1925,14 +1984,14 @@
 				skb_reserve( skb, 2 );
 				t = (void *) skb_put( skb, TLAN_MAX_FRAME_SIZE );
 			}
-			list->buffer[0].address = virt_to_bus( t );
+			list->buffer[0].address = pci_map_single(priv->pciDev, t, TLAN_MAX_FRAME_SIZE, PCI_DMA_FROMDEVICE);
 			list->buffer[8].address = (u32) t;
-			list->buffer[9].address = (u32) skb;
+			TLan_StoreSKB(list, skb);
 		}
 		list->buffer[1].count = 0;
 		list->buffer[1].address = 0;
 		if ( i < TLAN_NUM_RX_LISTS - 1 )
-			list->forward = virt_to_bus( list + 1 );
+			list->forward = list_phys + sizeof(TLanList);
 		else
 			list->forward = 0;
 	}
@@ -1950,23 +2009,26 @@
 	if ( ! bbuf ) {
 		for ( i = 0; i < TLAN_NUM_TX_LISTS; i++ ) {
 			list = priv->txList + i;
-			skb = (struct sk_buff *) list->buffer[9].address;
+			skb = TLan_GetSKB(list);
 			if ( skb ) {
+				pci_unmap_single(priv->pciDev, list->buffer[0].address, skb->len, PCI_DMA_TODEVICE);
 				dev_kfree_skb_any( skb );
+				list->buffer[8].address = 0;
 				list->buffer[9].address = 0;
 			}
 		}
 
 		for ( i = 0; i < TLAN_NUM_RX_LISTS; i++ ) {
 			list = priv->rxList + i;
-			skb = (struct sk_buff *) list->buffer[9].address;
+			skb = TLan_GetSKB(list);
 			if ( skb ) {
+				pci_unmap_single(priv->pciDev, list->buffer[0].address, TLAN_MAX_FRAME_SIZE, PCI_DMA_FROMDEVICE);
 				dev_kfree_skb_any( skb );
+				list->buffer[8].address = 0;
 				list->buffer[9].address = 0;
 			}
 		}
 	}
-
 } /* TLan_FreeLists */
 
 
@@ -2271,8 +2333,8 @@
 				printk("TLAN: Partner capability: ");
 					for (i = 5; i <= 10; i++)
 						if (partner & (1<<i))
-							printk("%s", media[i-5]);
-							printk("\n");
+							printk("%s",media[i-5]);
+				printk("\n");
 			}
 
 			TLan_DioWrite8( dev->base_addr, TLAN_LED_REG, TLAN_LED_LINK );
@@ -2304,7 +2366,7 @@
 		if ( debug >= 1 && debug != TLAN_DEBUG_PROBE ) {
 			outb( ( TLAN_HC_REQ_INT >> 8 ), dev->base_addr + TLAN_HOST_CMD + 1 );
 		}
-		outl( virt_to_bus( priv->rxList ), dev->base_addr + TLAN_CH_PARM );
+		outl( priv->rxListDMA, dev->base_addr + TLAN_CH_PARM );
 		outl( TLAN_HC_GO | TLAN_HC_RT, dev->base_addr + TLAN_HOST_CMD );
 	} else {
 		printk( "TLAN: %s: Link inactive, will retry in 10 secs...\n", dev->name );
@@ -2376,7 +2438,7 @@
 	 *		dev	A pointer to the device structure of the
 	 *			TLAN device having the PHYs to be detailed.
 	 *				
-	 *	This function prints the registers a PHY (aka tranceiver).
+	 *	This function prints the registers a PHY (aka transceiver).
 	 *
 	 ********************************************************************/
 
@@ -2492,7 +2554,7 @@
 
 	/* Wait for 50 ms and powerup
 	 * This is abitrary.  It is intended to make sure the
-	 * tranceiver settles.
+	 * transceiver settles.
 	 */
 	TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_PUP );
 
@@ -2512,7 +2574,7 @@
 	TLan_MiiWriteReg( dev, priv->phy[priv->phyNum], MII_GEN_CTL, value );
 	TLan_MiiSync(dev->base_addr);
 	/* Wait for 500 ms and reset the
-	 * tranceiver.  The TLAN docs say both 50 ms and
+	 * transceiver.  The TLAN docs say both 50 ms and
 	 * 500 ms, so do the longer, just in case.
 	 */
 	TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_RESET );
@@ -2627,7 +2689,7 @@
         	TLan_MiiWriteReg( dev, phy, TLAN_TLPHY_CTL, tctl );
 	}
 
-	/* Wait for 2 sec to give the tranceiver time
+	/* Wait for 2 sec to give the transceiver time
 	 * to establish link.
 	 */
 	TLan_SetTimer( dev, (4*HZ), TLAN_TIMER_FINISH_RESET );
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/tlan.h linux-2.4.22-pre2/drivers/net/tlan.h
--- linux-2.4.21/drivers/net/tlan.h	2001-07-02 21:03:04.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/tlan.h	2003-06-26 21:43:16.000000000 +0000
@@ -169,15 +169,22 @@
 
 typedef struct tlan_private_tag {
 	struct net_device       *nextDevice;
+	struct pci_dev		*pciDev;
 	void			*dmaStorage;
+	dma_addr_t		dmaStorageDMA;
+	unsigned int		dmaSize;
 	u8			*padBuffer;
 	TLanList                *rxList;
+	dma_addr_t		rxListDMA;
 	u8			*rxBuffer;
+	dma_addr_t		rxBufferDMA;
 	u32                     rxHead;
 	u32                     rxTail;
 	u32			rxEocCount;
 	TLanList                *txList;
+	dma_addr_t		txListDMA;
 	u8			*txBuffer;
+	dma_addr_t		txBufferDMA;
 	u32                     txHead;
 	u32                     txInProgress;
 	u32                     txTail;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/tulip/tulip_core.c linux-2.4.22-pre2/drivers/net/tulip/tulip_core.c
--- linux-2.4.21/drivers/net/tulip/tulip_core.c	2003-06-26 21:45:09.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/tulip/tulip_core.c	2003-06-26 21:43:28.000000000 +0000
@@ -231,6 +231,7 @@
 	{ 0x1737, 0xAB09, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
 	{ 0x17B3, 0xAB08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
 	{ 0x14f1, 0x1803, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CONEXANT },
+	{ 0x10b9, 0x5261, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DM910X },	/* ALi 1563 integrated ethernet */
 	{ } /* terminate list */
 };
 MODULE_DEVICE_TABLE(pci, tulip_pci_tbl);
@@ -1403,12 +1404,14 @@
 		csr0 &= ~0xfff10000; /* zero reserved bits 31:20, 16 */
 
 	/* DM9102A has troubles with MRM & clear reserved bits 24:22, 20, 16, 7:1 */
-	if (pdev->vendor == 0x1282 && pdev->device == 0x9102)
+	if ((pdev->vendor == 0x1282 && pdev->device == 0x9102)
+		|| (pdev->vendor == 0x10b9 && pdev->device == 0x5261))
 		csr0 &= ~0x01f100ff;
 
 #if defined(__sparc__)
         /* DM9102A needs 32-dword alignment/burst length on sparc - chip bug? */
-        if (pdev->vendor == 0x1282 && pdev->device == 0x9102)
+	if ((pdev->vendor == 0x1282 && pdev->device == 0x9102)
+		|| (pdev->vendor == 0x10b9 && pdev->device == 0x5261))
                 csr0 = (csr0 & ~0xff00) | 0xe000;
 #endif
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/typhoon.c linux-2.4.22-pre2/drivers/net/typhoon.c
--- linux-2.4.21/drivers/net/typhoon.c	2003-06-26 21:45:09.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/typhoon.c	2003-06-26 21:43:14.000000000 +0000
@@ -2134,7 +2134,7 @@
 	return 0;
 }
 
-#if CONFIG_PM
+#ifdef CONFIG_PM
 static int
 typhoon_resume(struct pci_dev *pdev)
 {
@@ -2482,7 +2482,7 @@
 	.id_table	= typhoon_pci_tbl,
 	.probe		= typhoon_init_one,
 	.remove		= __devexit_p(typhoon_remove_one),
-#if CONFIG_PM
+#ifdef CONFIG_PM
 	.suspend	= typhoon_suspend,
 	.resume		= typhoon_resume,
 	.enable_wake	= typhoon_enable_wake,
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/via-rhine.c linux-2.4.22-pre2/drivers/net/via-rhine.c
--- linux-2.4.21/drivers/net/via-rhine.c	2003-06-26 21:45:09.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/via-rhine.c	2003-06-26 21:43:20.000000000 +0000
@@ -1690,6 +1690,8 @@
 		/* Unconditionally log net taps. */
 		printk(KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name);
 		rx_mode = 0x1C;
+		writel(0xffffffff, ioaddr + MulticastFilter0);
+		writel(0xffffffff, ioaddr + MulticastFilter1);
 	} else if ((dev->mc_count > multicast_filter_limit)
 			   ||  (dev->flags & IFF_ALLMULTI)) {
 		/* Too many to match, or accept all multicasts. */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/wan/cosa.c linux-2.4.22-pre2/drivers/net/wan/cosa.c
--- linux-2.4.21/drivers/net/wan/cosa.c	2003-06-26 21:45:09.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/wan/cosa.c	2003-06-26 21:43:10.000000000 +0000
@@ -228,8 +228,8 @@
 /* NOTE: DMA is not autoprobed!!! */
 static int dma[MAX_CARDS+1] = { 1, 7, 1, 7, 1, 7, 1, 7, 0, };
 #else
-int io[MAX_CARDS+1]  = { 0, };
-int dma[MAX_CARDS+1] = { 0, };
+static int io[MAX_CARDS+1];
+static int dma[MAX_CARDS+1];
 #endif
 /* IRQ can be safely autoprobed */
 static int irq[MAX_CARDS+1] = { -1, -1, -1, -1, -1, -1, 0, };
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/net/wireless/airo.c linux-2.4.22-pre2/drivers/net/wireless/airo.c
--- linux-2.4.21/drivers/net/wireless/airo.c	2003-06-26 21:45:09.000000000 +0000
+++ linux-2.4.22-pre2/drivers/net/wireless/airo.c	2003-06-26 21:43:12.000000000 +0000
@@ -3161,7 +3161,7 @@
 	readStatsRid(apriv, &stats, rid);
 
         j = 0;
-	for(i=0; (int)statsLabels[i]!=-1 &&
+	for(i=0; statsLabels[i]!=(char *)-1 &&
 		    i*4<stats.len; i++){
 		if (!statsLabels[i]) continue;
 		if (j+strlen(statsLabels[i])+16>4096) {
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/pcmcia/i82092.c linux-2.4.22-pre2/drivers/pcmcia/i82092.c
--- linux-2.4.21/drivers/pcmcia/i82092.c	2003-06-26 21:45:09.000000000 +0000
+++ linux-2.4.22-pre2/drivers/pcmcia/i82092.c	2003-06-26 21:43:34.000000000 +0000
@@ -14,6 +14,8 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/tqueue.h>
 
 #include <pcmcia/cs_types.h>
 #include <pcmcia/ss.h>
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/s390/net/iucv.h linux-2.4.22-pre2/drivers/s390/net/iucv.h
--- linux-2.4.21/drivers/s390/net/iucv.h	2001-09-30 19:26:07.000000000 +0000
+++ linux-2.4.22-pre2/drivers/s390/net/iucv.h	2003-06-26 21:43:21.000000000 +0000
@@ -446,7 +446,7 @@
  *        buflen - Length of reply buffer.                              
  * Output: residual_buffer - Address of buffer updated by the number 
  *                    of bytes you have moved.              
- *         residual_length - Contains on the the following values
+ *         residual_length - Contains one of the following values:
  *		If the answer buffer is the same length as the reply, this field
  *		 contains zero.
  *		If the answer buffer is longer than the reply, this field contains
@@ -480,7 +480,7 @@
  *        buffer - Address of array of reply buffers.                     
  *        buflen - Total length of reply buffers.                         
  * Output: residual_buffer - Address of buffer which IUCV is currently working on.
- *         residual_length - Contains on the the following values
+ *         residual_length - Contains one of the following values:
  *              If the answer buffer is the same length as the reply, this field
  *               contains zero.
  *              If the answer buffer is longer than the reply, this field contains
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/Config.in linux-2.4.22-pre2/drivers/scsi/Config.in
--- linux-2.4.21/drivers/scsi/Config.in	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/Config.in	2003-06-26 21:43:19.000000000 +0000
@@ -52,7 +52,6 @@
    dep_tristate 'Adaptec AACRAID support (EXPERIMENTAL)' CONFIG_SCSI_AACRAID $CONFIG_SCSI $CONFIG_PCI
 fi
 source drivers/scsi/aic7xxx/Config.in
-source drivers/scsi/aic79xx/Config.in
 if [ "$CONFIG_SCSI_AIC7XXX" != "y" ]; then
    dep_tristate 'Old Adaptec AIC7xxx support' CONFIG_SCSI_AIC7XXX_OLD $CONFIG_SCSI
    if [ "$CONFIG_SCSI_AIC7XXX_OLD" != "n" ]; then
@@ -61,7 +60,9 @@
       bool '  Collect statistics to report in /proc' CONFIG_AIC7XXX_OLD_PROC_STATS
    fi
 fi
-dep_tristate 'Adaptec I2O RAID support ' CONFIG_SCSI_DPT_I2O $CONFIG_SCSI
+if [ "$CONFIG_X86_64" != "y" ]; then
+  dep_tristate 'Adaptec I2O RAID support ' CONFIG_SCSI_DPT_I2O $CONFIG_SCSI
+fi
 dep_tristate 'AdvanSys SCSI support' CONFIG_SCSI_ADVANSYS $CONFIG_SCSI
 dep_tristate 'Always IN2000 SCSI support' CONFIG_SCSI_IN2000 $CONFIG_SCSI
 dep_tristate 'AM53/79C974 PCI SCSI support' CONFIG_SCSI_AM53C974 $CONFIG_SCSI $CONFIG_PCI
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/Makefile linux-2.4.22-pre2/drivers/scsi/Makefile
--- linux-2.4.21/drivers/scsi/Makefile	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/Makefile	2003-06-26 21:43:14.000000000 +0000
@@ -27,7 +27,7 @@
 
 subdir-$(CONFIG_SCSI_AACRAID)	+= aacraid
 subdir-$(CONFIG_SCSI_AIC7XXX)	+= aic7xxx
-subdir-$(CONFIG_SCSI_AIC79XX)	+= aic79xx
+subdir-$(CONFIG_SCSI_AIC79XX)	+= aic7xxx
 subdir-$(CONFIG_PCMCIA)		+= pcmcia
 
 
@@ -73,7 +73,7 @@
   obj-$(CONFIG_SCSI_AIC7XXX)	+= aic7xxx/aic7xxx.o
 endif
 ifeq ($(CONFIG_SCSI_AIC79XX),y)
-  obj-$(CONFIG_SCSI_AIC79XX)	+= aic79xx/aic79xx.o
+  obj-$(CONFIG_SCSI_AIC79XX)	+= aic7xxx/aic79xx.o
 endif
 obj-$(CONFIG_SCSI_AIC7XXX_OLD)	+= aic7xxx_old.o
 obj-$(CONFIG_SCSI_IPS)		+= ips.o
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/CHANGELOG linux-2.4.22-pre2/drivers/scsi/aic79xx/CHANGELOG
--- linux-2.4.21/drivers/scsi/aic79xx/CHANGELOG	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/CHANGELOG	2003-06-26 21:43:29.000000000 +0000
@@ -1,23260 +0,0 @@
-Change 1861 by scottl@scottl-template on 2003/01/21 18:26:00
-
-	       Update driver version to 1.3.0
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#108 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/aic79xx.spec#25 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/install.sh#28 edit
-
-Change 1859 by scottl@scottl-template on 2003/01/21 15:27:08
-
-	readme.txt:
-	README.aic7xxx:
-		Convert tabs to spaces.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/README.aic7xxx#4 edit
-... //depot/linux_mod_devel/scsi.aic7xxx/readme.txt#4 edit
-
-Change 1858 by scottl@scottl-template on 2003/01/21 14:43:42
-
-	readme.txt:
-	README.aic79xx:
-		Fix the wording of the 1.3.0 version history line
-		Replace tabs with spaces.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/README.aic79xx#6 edit
-... //depot/linux_mod_devel/scsi.aic79xx/readme.txt#18 edit
-
-Change 1856 by gibbs@bitkeeper-linux-2.5 on 2003/01/21 12:37:08
-
-	Update the embedded aic7xxx driver README.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/README.aic7xxx#3 edit
-
-Change 1854 by gibbs@bitkeeper-linux-2.5 on 2003/01/21 12:12:27
-
-	Update aic79xx README used for embedding.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/README.aic79xx#5 edit
-
-Change 1851 by gibbs@bitkeeper-linux-2.5 on 2003/01/20 16:45:59
-
-	Bump aic7xxx driver to version 6.2.28.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#123 edit
-
-Change 1850 by scottl@scottl-template on 2003/01/20 16:29:28
-
-	       Update driver version to 1.3.0.RC2
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#107 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/aic79xx.spec#24 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/install.sh#27 edit
-
-Change 1849 by gibbs@bitkeeper-linux-2.4 on 2003/01/20 16:23:35
-
-	aic79xx_osm.c:
-		Correct the BUILD_SCSIID macro to take into account the
-		future removal of target, lun and channel from the
-		scsi_cmnd structure.
-	
-		Clean up ahd_linux_initialize_scsi_bus().  The indirection
-		was left over from the port from aic7xxx where twin
-		channel adapters come into play.  The result in the aic79xx
-		driver just looked silly.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#115 edit
-
-Change 1848 by gibbs@bitkeeper-linux-2.4 on 2003/01/20 16:20:47
-
-	aic79xx.c:
-		Fix a missed goal.period -> goal.offset change.  In
-		this case, the bug resulted in comparing a period
-		against an offset.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#156 edit
-
-Change 1847 by gibbs@bitkeeper-linux-2.4 on 2003/01/20 10:14:37
-
-	aic79xx.c:
-	aic7xxx.c:
-		Indicate the features, bugs, and flags set in the softc
-		that are used to control firmware patch download when
-		booting verbose.
-	
-	aic7xxx.c:
-		Fix an ifdef bug that caused sequencer debugging to
-		be enabled always.
-	
-		Clear the ultraenb flag in our tstate during startup.
-		The ultraenbled'ness of a device is recorded in the user
-		transfer settings.  tstate->ultraenb bitmask indicates
-		which devices we have negotiated an ultra speed with.
-		Just after initialization, we are async.  Setting the
-		ultraenb flag while async seems to be harmless, but it
-		was confusing to see the ULTRAENB flag set in the SCB.
-	
-		Allow ahc_dump_card_state() to be called when the sequencer
-		is not paused.  Add dump card state markers as in the U320
-		driver.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#155 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#112 edit
-
-Change 1846 by gibbs@bitkeeper-linux-2.4 on 2003/01/20 09:53:07
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Dump card state on DV timeouts when SHOW_DV debug
-		option is set.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#114 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#179 edit
-
-Change 1845 by gibbs@bitkeeper-linux-2.4 on 2003/01/17 14:46:30
-
-	aic79xx.c:
-	aic7xxx.c:
-		Force an SDTR after a rejected WDTR if the
-		syncrate is unkonwn.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#154 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#111 edit
-
-Change 1844 by gibbs@bitkeeper-linux-2.5 on 2003/01/17 13:20:26
-
-	aic7xxx_osm.h:
-		Bump driver version to 6.2.27.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#122 edit
-
-Change 1843 by gibbs@overdrive on 2003/01/17 13:06:51
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#22 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg_print.c#9 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#23 edit
-
-Change 1842 by scottl@scottl-template on 2003/01/17 12:39:50
-
-	       Update driver version to 1.3.0.RC1
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#106 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/aic79xx.spec#23 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/install.sh#26 edit
-
-Change 1841 by gibbs@bitkeeper-linux-2.4 on 2003/01/17 12:39:21
-
-	aic7xxx.c:
-	aic7xxx.h:
-	aic7xxx_pci.c:
-		Take another stab at disabling PCI errors in the aic7xxx
-		driver.  We now just clear the PERRRESEN bit in the command
-		register.  This option is now enabled via a new flag in
-		ahc->flags: AHC_DISABLE_PCI_PERR.
-	
-	aic7xxx_osm.c:
-		Hook the already existing pci_parity option.  Parity
-		defaults to off since so many Linux users have clunky
-		VIA chipsets that cause spurious warnings.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#110 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#70 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#57 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#178 edit
-
-Change 1840 by scottl@scottl-template on 2003/01/16 18:53:11
-
-	aic7xxx_osm.c:
-		Fix missed AHD->AHC substitutions from last commit.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#177 edit
-
-Change 1839 by scottl@scottl-template on 2003/01/16 18:51:20
-
-	aic7xxx_osm.c:
-		Traverse the array of targets and devices in
-		ahc_platform_free() and remove each device.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#176 edit
-
-Change 1838 by scottl@scottl-template on 2003/01/16 18:46:46
-
-	aic79xx_osm.c:
-		Traverse the arrays of targets and devices to free each
-		device when ahd_platform_free() is called.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#113 edit
-
-Change 1837 by gibbs@bitkeeper-linux-2.4 on 2003/01/16 16:24:58
-
-	aic79xx_osm.c:
-	aic79xx_osm.h:
-	aic7xxx_osm.c:
-	aic7xxx_osm.h:
-		Adapt to upcoming 2.5.X change.  The host, target, channel,
-		and lun fields are disappearing from the scsi_cmnd structure.
-		We must instead get this data from the scsi_device structure
-		hung off the command.  The only trick in this is an update
-		to how we fake up DV commands.  We now need to fake up a
-		scsi_device too.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#112 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#105 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#175 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#121 edit
-
-Change 1836 by gibbs@bitkeeper-linux-2.4 on 2003/01/16 14:39:58
-
-	aic79xx.c:
-		Only send an async update to the luns affected by
-		the device reset now that ahd_handle_devreset is
-		called for lun resets too.
-	
-	aic79xx_osm.c:
-		Only bother dumping card state after we've determined
-		that the command to be aborted is still active on the
-		controller.
-	
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Have the AC_SENT_BDR handler manually set the was_reset
-		and expecting_cc_ua flags in all devices that are
-		affected by the target/lun reset.
-	
-		Never allow cmd->retries to go below zero.  cmd->retries
-		is not incremented when a command goes through recovery.
-		This could allow the retry count to suddenly become a
-		very large number.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#153 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#111 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#174 edit
-
-Change 1834 by gibbs@aslan on 2003/01/15 21:32:22
-
-	aic7xxx.seq:
-		Correct a target mode regression that prevented the
-		driver from properly handling unexpected
-		messages (negotiation, etc).
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#54 edit
-
-Change 1833 by gibbs@bitkeeper-linux-2.4 on 2003/01/15 21:27:13
-
-	aic79xx_osm.c:
-		Split out the abort handler from the dev reset handler.
-		The dev reset handler will now use a new SCB to issue
-		the dev reset.  This avoids a potential problem with
-		SCB race issues for dev resets.
-	
-		Manually set the task management function now that
-		ahd_queue_scb() doesn't do this for us.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#110 edit
-
-Change 1832 by gibbs@bitkeeper-linux-2.4 on 2003/01/15 21:20:59
-
-	aic79xx.c:
-		Update copyright for 2003.
-	
-		Modify ahd_handle_devreset so that it can handle
-		lun resets in addition to target resets.
-	
-		Correct a bug in the illegal phase handler that
-		caused us to drop down to narrow when handling the
-		unexpected command phase case after 3rd party
-		reset of a packetized device.
-	
-		Add some diagnostics to the task management function code.
-	
-		Use ahd_handle_devreset for lun and target reset task
-		management functions.
-	
-		Handle the abort task TMF race case better.  We now
-		wait until any current selections are over and then
-		set the TMF back to zero.  This should cause the sequencer
-		to ignore the abort TMF completion should it occur.
-	
-		Correct a regression in ahd_sent_msg that caused it to fail
-		to recognize any 1byte messages other than identify.
-	
-	aic79xx_inline.h:
-		Allow callers to ahd_send_scb() to set the task management
-		function.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#152 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#41 edit
-
-Change 1831 by scottl@scottl-template on 2003/01/15 17:37:56
-
-	Move aic_error_action and aic_calc_speed out of the osm's and
-	into aiclib.  Do slight header adjustment to make it work.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#69 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#109 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#104 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#173 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#120 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aiclib.c#6 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aiclib.h#6 edit
-
-Change 1830 by gibbs@bitkeeper-linux-2.4 on 2003/01/15 15:33:45
-
-	aic79xx_osm.c:
-	aic79xx_osm.h:
-	aic7xxx_osm.c:
-	aic7xxx_osm.h:
-		Correct use of AHD_EH_UP_SEMAPHORE.  This should
-		unbreak the recovery handler.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#108 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#103 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#172 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#119 edit
-
-Change 1829 by gibbs@overdrive on 2003/01/15 11:18:20
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#54 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#35 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#55 edit
-
-Change 1828 by gibbs@bitkeeper-linux-2.5 on 2003/01/15 10:19:07
-
-	aic79xx_osm.c:
-		Continue to dump the card state on timeouts for the
-		time being.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#107 edit
-
-Change 1827 by gibbs@bitkeeper-linux-2.5 on 2003/01/15 10:18:44
-
-	aic7xxx.h:
-		Reformat a few comments to follow driver style.
-	
-		Add a controller flag that indicates that a controller
-		has not been initialized by the BIOS.
-	
-	aic7xxx.c:
-		Disable PCI error interrupts on PCI adapters prior
-		to the Ultra2 controllers.  This brings us in line
-		with what the other Adaptec drivers do, but it is
-		still not clear exactly why this status reporting
-		might be broken.
-	
-		Don't set our width to unknown when forcing negotiation
-		on narrow controllers.  This will confuse the negotiation
-		code into negotiating with a wide message on narrow
-		controllers.
-	
-		In ahc_reset(), record whether or not we found the
-		controller in a reset state.  If the controller was
-		already reset, assume that no BIOS has initialized
-		the controller and ignore left over scratch ram
-		settings.
-	
-		In ahc_dump_card_state() fix a logic reversal.  The
-		SCSIPHASE register only exists on U160 controllers.
-		The SCSISIGI register exists on all controllers.  Not
-		the other way around.
-	
-	aic7xxx_osm.c:
-		Format sense diagnostic in 16 byte rows.
-	
-		Remove a superfluous diagnostic printf.
-	
-	aic7xxx_pci.c:
-		Ensure that the PCIERRGENDIS bit is set in the
-		PCIERRGEN config space register.  Perhaps this
-		is a reason for the spurios parity errors reported
-		on U160 controllers.
-	
-		Honor the AHC_NO_BIOS_INIT flag.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#109 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#68 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#56 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#171 edit
-
-Change 1826 by gibbs@bitkeeper-linux-2.5 on 2003/01/15 10:10:47
-
-	aic79xx.reg:
-		Add SEQINT codes for handling task management
-		completions.
-	
-	aic79xx.seq:
-		Add notifications to the host of task management
-		completions as well as the completions for commands
-		that have a task management function pending but
-		not yet sent.
-	
-		Hold a critical section during select-out processing
-		until we have a fully identified connection.  This
-		removes a race condition with the legacy abort handler.
-	
-		Correct a few spelling errors in some comments.
-	
-	aic79xx_core.c
-		Flush the good status FIFO in ahd_flush_qoutfifo.
-		This routine should now catch all completed commands
-		in their various locations and states.
-	
-		Add support for task management function completions.
-	
-		If we are a narrow controller, don't set the current
-		width to unknown when forcing a future negotiation.
-		This just confuses the code into attempting a wide
-		negotiation on a narrow bus.
-	
-	aic79xx_osm.c:
-		Enable recovery code.  Behavior should be similar to
-		that of the aic7xxx driver for legacy devices.  For
-		packetized devices, we will now queue the appropriate
-		task management function.
-	
-		When printing out sense information, format in 16
-		byte rows.
-	
-	scsi_iu.h:
-		Add definitions for the task management codes sent
-		in SPI4 command information units.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#151 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#60 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#78 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#106 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/scsi_iu.h#4 edit
-
-Change 1825 by gibbs@bitkeeper-linux-2.5 on 2003/01/10 16:42:54
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Short cicuit domain validation if the inquiry
-		data for the device shows that it does not support
-		sync or wide transfers.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#105 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#170 edit
-
-Change 1820 by gibbs@bitkeeper-linux-2.5 on 2003/01/07 19:47:06
-
-	aic79xx_osm_pci.c:
-		Always set the pci_dma_mask.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#20 edit
-
-Change 1819 by gibbs@bitkeeper-linux-2.5 on 2003/01/07 19:44:50
-
-	aic7xxx_osm_pci.c:
-		Always initialize the pci_dma_mask.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#43 edit
-
-Change 1818 by gibbs@overdrive on 2003/01/07 19:11:29
-
-	aic79xx_osm.h:
-	aic7xxx_osm.h:
-		Correct version numbers.  We are now at aic7xxx 6.2.26,
-		and aic79xx 1.3.0_BETA2.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#102 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#118 edit
-
-Change 1817 by scottl@scottl-template on 2003/01/07 19:03:54
-
-	       Update driver version to 6.2.24
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#117 edit
-... //depot/linux_mod_devel/scsi.aic7xxx/rpm/aic7xxx.spec#10 edit
-... //depot/linux_mod_devel/scsi.aic7xxx/rpm/install.sh#14 edit
-
-Change 1815 by scottl@scottl-belfalas-template on 2003/01/07 18:58:15
-
-	Forward declare and static-ize aic7xxx_setup().
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#169 edit
-
-Change 1814 by gibbs@bitkeeper-linux-2.5 on 2003/01/07 18:35:16
-
-	aic7xxx_osm.h:
-		Add PCIM_CMD_SERRESPEN definition.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#116 edit
-
-Change 1813 by gibbs@overdrive on 2003/01/07 18:32:44
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#21 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg_print.c#8 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#22 edit
-
-Change 1812 by gibbs@aslan on 2003/01/07 17:38:33
-
-	aic79xx_pci.c:
-	aic7xxx_pci.c:
-		Disable SERR and pause the controller prior to performing
-		our mmapped I/O test.  This should handle the case of
-		controllers that do not "auto-access pause".  For legacy
-		controllers, use SCB ram instead of scratch ram since
-		the latter may contain settings left over from the BIOS
-		that we will use if an seeprom is not found.
-	
-	aic7xxx.h:
-	aic7xxx.c:
-		Remove the probe_stack code.  The stack is always
-		4 deep on legacy controllers, so probing is pointless.
-		This also avoids an issue where probing the stack would
-		upset the aic7770.
-	
-	aic7xxx.c:
-		Print out the ERROR register in ahc_dump_card_state().
-	
-	aic7xxx.reg:
-		Add a constant for the controller's stack size.
-	
-	aic7xxx.seq:
-		Style nit.  The source is implied to be the destination
-		unless overridden in an "and" instruction.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#61 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#108 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#67 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#37 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#53 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#55 edit
-
-Change 1811 by gibbs@aslan on 2003/01/07 14:20:42
-
-	aicasm_gram.y:
-		Remove the numerical_value portion of the grammer
-		which is no longer referenced.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#29 edit
-
-Change 1810 by scottl@scottl-template on 2003/01/07 09:29:00
-
-	       Update driver version to 1.3.0.BETA1
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#101 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/aic79xx.spec#21 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/install.sh#24 edit
-
-Change 1808 by gibbs@bitkeeper-linux-2.5 on 2003/01/06 14:21:46
-
-	aic7xxx_osm.c:
-		Correctly account for twin channel adapters in
-		pre-allocating target devices for initial DV scan.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#168 edit
-
-Change 1807 by gibbs@bitkeeper-linux-2.5 on 2003/01/06 11:58:41
-
-	aic79xx.c:
-		Correct ahd_find_syncrate() so that the actual
-		syncrate and not the "maximum syncrate" is modified
-		by tests that limit syncrate based on PPR options.
-	
-	aic7xxx.c:
-	aic79xx.c:
-		Enhance residual diagnostic to indicate if the residual
-		if for sense information or normal data transfers.
-	
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		For the initial DV scan, only instantiate target objects
-		for IDs that can exist (i.e. only up to ID 7 on narrow
-	
-		Record the maximum bus width for fallback in the target
-		structure and use this to ensure we never fallback to
-		wide on a narrow target.
-		channels).
-	
-		Add DV diagnostic for failed inquiry verification.
-	
-	aic79xx_osm.h:
-	aic7xxx_osm.h:
-		Add dv_max_width to target structures and shrink several
-		fields to 8bits.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#150 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#107 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#104 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#100 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#167 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#115 edit
-... //depot/linux-aic79xx-2.5.0/drivers/scsi/aic7xxx/Makefile#5 edit
-
-Change 1805 by scottl@scottl-junior-freebsd on 2002/12/30 21:13:11
-
-	Convert the use of MAXBSIZE in the dma tag to more appropriate values.
-	Use BUS_SPACE_MAXSIZE_32BIT for the parent dma tags, and
-	(NSEGS - 1) * PAGE_SIZE for the data buffer tags.  FreeBSD/sparc64 is
-	more strick about checking these values that other arches.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#149 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#106 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/ahc_eisa.c#10 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/ahc_pci.c#12 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/ahd_pci.c#12 edit
-
-Change 1804 by gibbs@bitkeeper-linux-2.5 on 2002/12/30 18:59:49
-
-	aic79xx_osm.h:
-		Bump version number to 1.3.0_ALPHA6
-	
-	aic7xxx_osm.h:
-		Bump version number to 6.2.25.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#99 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#114 edit
-
-Change 1803 by gibbs@bitkeeper-linux-2.4 on 2002/12/30 16:54:09
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Reorganize DV state machine so that full inquiry data
-		is retrieved prior to testing to see if the unit is ready.
-		We now use this full inquiry data to assume defaults if
-		for some reason the DV state machine fails to configure
-		the device.  This failsafe mechanism should ensure that
-		these devices are at least configured in the same fashion
-		as they were before the addition of DV to these drivers.
-	
-	aic79xx_osm.h:
-	aic7xxx_osm.h:
-		Re-arrange DV state enum to reflect current state machine
-		transitions.
-	
-		Add additional target flags used to implement the DV
-		failsafe mechanism.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#103 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#98 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#166 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#113 edit
-
-Change 1802 by gibbs@bitkeeper-linux-2.5 on 2002/12/30 14:59:22
-
-	aic7770_osm.c:
-	aic79xx_osm_pci.c:
-	aic7xxx_osm_pci.c:
-		Clean up check_region() usage.  It is deprecated in 2.5.X
-		and 2.4.X, but is still required in earlier kernels.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7770_osm.c#12 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#19 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#42 edit
-
-Change 1801 by gibbs@bitkeeper-linux-2.5 on 2002/12/30 13:50:25
-
-	aiclib.c:
-		Ignore media not-present errors during DV.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aiclib.c#5 edit
-
-Change 1800 by gibbs@bitkeeper-linux-2.5 on 2002/12/30 13:50:10
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Use down_interruptable() rather than down() to avoid
-		having our thread counted toward the load average.
-		We disable all signal sources to that the down_interruptable()
-		is not really interruptable().  Singals are not required for
-		the drivers to terminate the DV threads on unload.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#102 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#165 edit
-
-Change 1799 by gibbs@bitkeeper-linux-2.5 on 2002/12/30 12:19:23
-
-	aicasm_symbol.c:
-		Fix the last reference to the reg_print.c file handle
-		in symtable_dump.  This allows the assembler to operate
-		without generating this file.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#24 edit
-
-Change 1798 by gibbs@bitkeeper-linux-2.5 on 2002/12/30 12:18:05
-
-	aiclib.h:
-		Restore driver style.  All functions are declared prior
-		to being defined.  The original bug was that the 2.4.X
-		declaration was used unconditionally.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aiclib.h#5 edit
-
-Change 1797 by gibbs@bitkeeper-linux-2.5 on 2002/12/30 12:17:23
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Enable highmem_io on 2.5.X kernels.  It turns out that
-		the CONFIG_HIGHIO option does not exist there.
-	
-		Call daemonize() on and provide a name for our dv threads.
-	
-	aic79xx_osm.h:
-	aic7xxx_osm.h:
-		Include smp_lock.h for (un)lock_kernel().
-	
-	aic7xxx_osm.c:
-		Add a diagnostic, similar to that in the aic79xx driver,
-		for printing out sense information.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#101 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#97 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#164 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#112 edit
-
-Change 1796 by gibbs@bitkeeper-linux-2.5 on 2002/12/30 12:14:42
-
-	aic7xxx.c:
-		Preface the "asserting atn" diagnostic with controller/target
-		information.
-	
-		Restore a call to ahc_assert_atn() that was inadvertantly
-		lost when the asserting atn diagnostic was added.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#105 edit
-
-Change 1795 by gibbs@bitkeeper-linux-2.5 on 2002/12/30 12:13:06
-
-	aic79xx_core.c:
-		Print out target information to preface the asserting
-		attention diagnostic.
-	
-		Correct a compilation warning.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#148 edit
-
-Change 1792 by gibbs@bitkeeper-linux-2.5 on 2002/12/20 17:52:04
-
-	Bump to version 6.2.24.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#111 edit
-
-Change 1788 by gibbs@aslan on 2002/12/20 16:39:14
-
-	aic79xx.c:
-		Remove stray debugging code.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#147 edit
-
-Change 1787 by scottl@scottl-template on 2002/12/20 16:04:59
-
-	       Update driver version to 1.3.0.ALPHA5
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#96 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/aic79xx.spec#20 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/install.sh#23 edit
-
-Change 1786 by gibbs@overdrive on 2002/12/19 16:10:05
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#53 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#34 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#54 edit
-
-Change 1785 by gibbs@aslan on 2002/12/19 16:08:47
-
-	aic79xx.c:
-		Add a statistics timer that decides when to enable
-		or disable interrupt coalessing based on load.
-	
-		Add ahd_flush_qoutfifo() which will run the qoutfifo
-		as well as complete any commands sitting on the 
-		sequencer's COMPLETE_SCB lists.  Use this routine in
-		several places that did similar things in an add-hoc,
-		but incomplete, fashion.  A call to this routine was
-		also added to ahd_abort_scbs() to close a race.
-	
-		Add a routine, ahd_reset_cmds_pending() which is used
-		to update the CMDS_PENDING sequencer variable whenever
-		error recovery compeltes SCBs without notifying the
-		sequencer.  Since ahd_reset_cmds_pending is called
-		during ahd_unpause() only if we've aborted SCBs, its
-		call to ahd_flush_qoutfifo should not cause recursion
-		through ahd_run_qoutfifo().  A panic has been added to
-		ensure that this recursion does not occur.
-	
-		In ahd_search_qinfifo, update the CMDS_PENDING sequencer
-		variable directly.  ahd_search_qinififo can be called
-		in situations where using ahd_reset_cmds_pending() might
-		cause recursion.  Since we can safely determine the
-		exact number to reduce CMDS_PENDING by in this scenario
-		without running the qoutfifo, the manual update is more
-		than adequate.
-	
-		Clean up diagnostics.
-	
-	aic79xx.h:
-		Update per-softc variables for the stats "daemon".
-		The defaults for interrupt coalessing have been updated
-		slightly, but these need additional tuning.  A new
-		tunable paramter "minimum commands still outstanding
-		required to attempt coalessing" has been added.
-	
-		Add a debug option for interrupt coalessing activities.
-	
-		Add two new softc flags:
-		o AHD_UPDATE_PEND_CMDS
-			Run ahd_reset_cmds_pending() on the next unpause.
-	
-		o AHD_RUNNING_QOUTFIFO
-			Used to catch recursion through ahd_run_qoutfifo().
-	
-	aic79xx.reg:
-		Break INTMASK in SEQITNCTL out into INTMASK1 and INTMASK2.
-		In at least the REV A, these are writable bits.  We make
-		use of that for a swtimer workaround in the sequencer.
-	
-		Add sequencer variables to recovery the min-commands
-		still outstanding for coalessing and the current number
-		of commands outstanding.
-	
-		Since HS_MAILBOX autoclears, provide a sequencer variable
-		to store its contents.
-	
-	aic79xx.seq:
-		In idle_loop_cchan, update LOCAL_HS_MAILBOX everytime
-		we are notified of an HS_MAILBOX update via the
-		HS_MAILBOX_ACT bit in QOFF_CTLSTA.
-	
-		Enhance our coalessing algorithm.  If we have more
-		SCBs to complete to the host (sitting in COMPLETE_SCB
-		lists), always try to coaless them up to our coalessing
-		limit.  If coalessing is enabled, but we have fewer
-		commands oustantind than the hosts limit, complete the
-		command immediately.
-	
-		Since we cannot disable the swtimer's countdown, simply
-		mask its interrupt once we no longer care about it firing.
-	
-		Add code to track the number of commands outstanding.
-		Commands are outstanding from the time they are placed
-		into the execution queue until the DMA to post completion
-		is setup.
-	
-		Add a workaround for intvec_2 interrupts on the H2A4.
-		In H2A4, the mode pointer is not saved for intvec2, but
-		is restored on iret.  This can lead to the restoration
-		of a bogus mode ptr.  Manually clear the intmask bits and
-		do a normal return to compensate.
-	
-	aic79xx_inline.h:
-		Call ahd_reset_cmds_pending() in ahd_unpause if required.
-	
-		Update cmdcmplt interrupt statistics in our interrupt
-		handler.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#146 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#78 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#59 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#77 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#40 edit
-
-Change 1784 by gibbs@bitkeeper-linux-2.5 on 2002/12/18 10:33:25
-
-	aic79xx_osm.c:
-		Remove a stray ';' that was short cicuiting an if statement.
-	
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-	aic79xx_osm.h:
-	aic7xxx_osm.h:
-		Only allow slave_destroy() to destroy a real device
-		if that device has had slave_configure() called on it.
-		This prevents "silly deletions" caused by bogons in
-		the scsi_scan code from deleting DV state for devices
-		that are still attached and will have a slave_alloc()
-		called for them as soon as the slave_destroy() returns.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#100 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#95 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#163 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#110 edit
-
-Change 1783 by gibbs@bitkeeper-linux-2.5 on 2002/12/18 10:29:46
-
-	aic7xxx.c:
-		Don't clobber ppr_options when forcing a renegotiation.
-		The current ppr_options may be referenced while queuing
-		new commands.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#104 edit
-
-Change 1782 by gibbs@bitkeeper-linux-2.5 on 2002/12/17 19:27:05
-
-	aic79xx_osm.c:
-		Add a prototype for ahd_linux_dv_fallback().
-	
-	aic7xxx_osm.c:
-		Complete the merge of the new biosparam API from
-		Christoph Hellwig.
-	
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Move the setting of max_sectors to the host template
-		to quiet a warning in 2.5.X.
-	
-		Add slave_alloc calls and "bootverbose" diagnostics
-		for help in sorting out exactly how this slave_*
-		API functions.
-	
-		Move call to ahd_linux_device_queue_depth to within
-		the test to see if dev is NULL.
-	
-		Add code to actually destroy our data structures to
-		the slave_destroy routine instead of waiting for a
-		command that may not come to do so.
-	
-		Initialize the name field of the host structure.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#99 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#162 edit
-
-Change 1781 by gibbs@bitkeeper-linux-2.5 on 2002/12/17 19:20:16
-
-	aic79xx.c:
-		Remove "Now packetized" diagnostic now that this
-		information is incorperated into the actual negotiation
-		messages that are displayed.
-	
-		When forcing renegotiation, don't clober the current
-		ppr_options.  Much of the driver uses this information
-		to determine if we are currently packetized or not.
-	
-		Remove some stray spaces at column 1 and ahd_set_tags.
-	
-		When complaining about getting a host message loop
-		request with no pending messages, print out the 
-		SCB_CONTROL register down on the card.
-	
-		Modify the ahd_sent_msg() routine to handle a search
-		for an outgoing identify message.  Use this to detect
-		a msg reject on an identify message which typically
-		indicates that the target thought we were packetized.
-		Force a renegotiation in this case.
-	
-		In ahd_search_qinfifo(), wait more effectively for SCB
-		DMA activities to cease.  We also clear out the state
-		that tells the sequencer that a DMA was in progress for
-		SCB fetch operations since we are about to change the
-		qinfifo.
-	
-		In ahd_pause_and_flush_work(), actually itterate through
-		the two Complete SCB lists.  Ooops.
-	
-		In ahd_qinfifo_count(), fix the qinfifo empty case.
-	
-		In ahd_dump_card_state(), print out CCSCBCTL in the
-		correct mode.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#145 edit
-
-Change 1780 by gibbs@bitkeeper-linux-2.5 on 2002/12/17 19:11:25
-
-	aic79xx.seq:
-		Add a missing ret to the last instruction in
-		load_overrun_buf.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#76 edit
-
-Change 1779 by gibbs@bitkeeper-linux-2.5 on 2002/12/17 19:10:42
-
-	aic79xx.reg:
-		Correct address for the DFDBCTL register.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#58 edit
-
-Change 1774 by scottl@scottl-template on 2002/12/16 03:08:08
-
-	       Update driver version to 1.3.0.ALPHA4
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#94 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/aic79xx.spec#19 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/install.sh#22 edit
-
-Change 1772 by scottl@scottl-belfalas-template on 2002/12/16 02:43:36
-
-	ahd_linux_fallback can't aquire the ahd lock since it might be
-	called from the completion handler.  Create a wrapper called
-	ahd_linux_dv_fallback that aquires and releases the ahd lock so
-	that is can be called from the DV code and still satisfy it's locking
-	needs.
-	Move the error stat code into ahd_linux_queue_cmd_complete so it
-	can catch more error conditions.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#98 edit
-
-Change 1771 by scottl@scottl-belfalas-template on 2002/12/16 02:39:22
-
-	aic79xx_proc.c:
-		Add a newline when printing the renegotiation pending message.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_proc.c#11 edit
-
-Change 1770 by scottl@scottl-belfalas-template on 2002/12/15 23:38:06
-
-	aic79xx_osm.c:
-		Don't grab the ahd lock when updating error stats since
-		it's already held.
-		When deciding to do a fallback because of an error, don't
-		alias the existing devinfo struct with a new one.  Why
-		the compiler didn't catch this is beyond me.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#97 edit
-
-Change 1769 by scottl@scottl-hobbiton-0b47 on 2002/12/15 22:24:16
-
-	Regen firmware
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#52 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#33 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#53 edit
-
-Change 1768 by scottl@scottl-hobbiton-0b47 on 2002/12/15 22:24:02
-
-	aic79xx_osm.c:
-	aic79xx_osm.h:
-		Switch to a bucket-based method of counting the number off
-		good commands in between bad ones.  Use only a single bucket
-		right now for simplicity, though this can grow in the future.
-		This also removes the stats timer.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#96 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#93 edit
-
-Change 1767 by scottl@scottl-hobbiton-0b47 on 2002/12/15 21:23:38
-
-	aic79xx_osm.h:
-		Move the errors_detected field to the target structure, and
-		add new_errors_detected field for doing stats decay.
-	
-	aic79xx_osm.c:
-		If a transmission error is detected, increment the
-		new_errors_detected counter.  If it's passed the threshold,
-		call for a speed fallback.
-		Update the errors_detected field with new_errors_detected and
-		reset new_errors_detected on every stats timeout call.
-	
-	aic79xx_proc.c:
-		Display the per-target errors detected field.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#95 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#92 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_proc.c#10 edit
-
-Change 1766 by gibbs@aslan on 2002/12/15 19:32:13
-
-	Add interrupt coalessing hooks.
-	
-	aic79xx.c:
-		Keep a copy of the hs_mailbox in our softc so that
-		we can perform read/modify/write operations on the
-		hs_mailbox without having to pause the sequencer to
-		read the last written value.  Use the ENINT_COALESS
-		flag in the hs_mailbox to toggle interrupt coalessing.
-	
-		Add entrypoints for enabling interrupt coalessing and
-		setting both a timeout (how long to wait for commands
-		to be coalessed) and a maximum commands to coaless value. 
-	
-		In ahd_pause_and_flushwork() only return one selections
-		are safely disabled.  We now also flush the two sequencer
-		lists of completed commands.
-	
-	aic79xx.h:
-		Add coalessing and HS_MAILBOX fields.
-	
-	aic79xx.reg:
-		Correct register addresses related to the software timer.
-	
-		Add constants paramaterizing the software timer.
-	
-		Add scratch ram locations for storing interrupt coalessing
-		tunables.
-	
-	aic79xx.seq:
-		Use the software timer and a commands completed count to
-		implement interrupt coalessing.  The command complete is
-		deferred until either the maximum command threshold or a
-		timer since the first command completed since the last
-		completion expires.
-	
-		Move the test for the cfg4istat interrupt up an instruction
-		to hopefully close a race between the next outgoing selection
-		and our disabling of selections.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#144 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#77 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#57 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#75 edit
-
-Change 1765 by gibbs@aslan on 2002/12/15 17:48:29
-
-	aicasm_gram.y:
-		Allow constants to be complex expressions so long
-		as those expressions can be fully evaluated during
-		assembly.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#28 edit
-
-Change 1764 by scottl@scottl-hobbiton-0b47 on 2002/12/13 18:09:34
-
-	aic79xx_osm.c:
-	aic79xx_osm.h:
-		Start of runtime fallback and interrupt caolescing stat
-		gathering.  Run ahd_linux_stats_update() every
-		AHD_LINUX_STATS_INTERVAL period.  Consense the packetized
-		and non-packetized autosense code and start some logic to
-		figure out what to do with the sense information.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#94 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#91 edit
-
-Change 1762 by gibbs@bitkeeper-linux-2.5 on 2002/12/13 13:08:43
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Remove *slave_alloc declarations as we don't need or
-		export this entry point.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#93 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#161 edit
-
-Change 1761 by gibbs@bitkeeper-linux-2.4 on 2002/12/12 14:31:11
-
-	aiclib.h:
-		Add aic_sector_div macro.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aiclib.h#4 edit
-
-Change 1760 by gibbs@bitkeeper-linux-2.4 on 2002/12/12 14:30:40
-
-	aic79xx_osm.h:
-	aic7xxx_osm.h:
-		Complete adjustment for host template changes.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#90 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#109 edit
-
-Change 1759 by gibbs@bitkeeper-linux-2.5 on 2002/12/12 14:25:19
-
-	aic79xx_osm.h:
-		Remove a stray reference to aic79xx_host.h.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#89 edit
-
-Change 1754 by gibbs@bitkeeper-linux-2.4 on 2002/12/12 11:45:59
-
-	aic79xx_host.h:
-	aic7xxx_host.h:
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Eliminate separate Linux host template files and move
-		all host template entry ponts to one section of the Linux
-		osm.c file.
-	
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Add support for larger disks under 2.5.X.
-	
-	Changes prodded by: Christoph Hellwig <hch@sgi.com>
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_host.h#14 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#92 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#18 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_host.h#16 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#160 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#41 edit
-
-Change 1751 by scottl@scottl-template on 2002/12/10 21:41:30
-
-	       Update driver version to 6.2.23
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#108 edit
-... //depot/linux_mod_devel/scsi.aic7xxx/rpm/aic7xxx.spec#9 edit
-... //depot/linux_mod_devel/scsi.aic7xxx/rpm/install.sh#12 edit
-
-Change 1750 by gibbs@bitkeeper-linux-2.4 on 2002/12/10 20:51:23
-
-	aic79xx_host.h:
-	aic7xxx_host.h:
-		Set single_sg_okay for RH AS 2.1 too.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_host.h#13 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_host.h#15 edit
-
-Change 1749 by gibbs@bitkeeper-linux-2.4 on 2002/12/10 20:45:35
-
-	aic79xx_host.h:
-	aic7xxx_host.h:
-		Use CONFIG_HIGHIO as the gating define for whether
-		the highmem_io host template field is present.  Also
-		assume that if the kernel version is less than 2.4.18,
-		then we must be under RedHat and need to call this field
-		can_dma_32.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_host.h#12 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_host.h#14 edit
-
-Change 1748 by scottl@scottl-template on 2002/12/10 19:54:55
-
-	       Update driver version to 1.3.0.ALPHA3
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#88 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/aic79xx.spec#18 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/install.sh#20 edit
-
-Change 1747 by gibbs@bitkeeper-linux-2.4 on 2002/12/10 18:49:21
-
-	aic79xx_host.h:
-	aic7xxx_host.h:
-		Enable the highmem_io option on kernels with the
-		new highmem bouncing code.
-	
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Fix compilation error in the non-debug enabled case.
-	
-	aic7xxx_osm.c:
-		Remove leftover #if 0'd code from DV merge.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_host.h#11 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#91 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_host.h#13 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#159 edit
-
-Change 1746 by gibbs@bitkeeper-linux-2.5 on 2002/12/10 12:05:15
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Disable the shutdown hook for 2.5.X since it is called
-		to early to be useful.  Some other strategy will need to
-		be found.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#90 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#158 edit
-
-Change 1745 by gibbs@bitkeeper-linux-2.5 on 2002/12/09 16:29:02
-
-	aic79xx_host.h:
-	aic79xx_osm.c:
-	aic79xx_osm_pci.c
-	aic7xxx_host.h:
-	aic7xxx_osm.c:
-	aic7xxx_osm_pci.c:
-		Conform to latest 2.5.X API changes.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_host.h#10 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#89 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#17 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_host.h#12 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#157 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#40 edit
-
-Change 1743 by gibbs@bitkeeper-linux-2.4 on 2002/12/09 15:16:31
-
-	aic79xx.c:
-		Limit the syncrate after all option conformance
-		changes have taken place in ahd_devlimited_syncrate.
-		Changes in options may change the final syncrate we
-		accept.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#143 edit
-
-Change 1741 by gibbs@bitkeeper-linux-2.4 on 2002/12/09 14:11:44
-
-	Makefile:
-		Turn off -g.
-
-Affected files ...
-
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/Makefile#10 edit
-
-Change 1740 by scottl@scottl-template on 2002/12/09 10:15:50
-
-	       Update driver version to 6.2.22
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#107 edit
-... //depot/linux_mod_devel/scsi.aic7xxx/rpm/aic7xxx.spec#8 edit
-... //depot/linux_mod_devel/scsi.aic7xxx/rpm/install.sh#11 edit
-
-Change 1737 by scottl@scottl-template on 2002/12/06 16:14:24
-
-	       Update driver version to 1.3.0.ALPHA2
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#87 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/aic79xx.spec#17 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/install.sh#19 edit
-
-Change 1736 by gibbs@overdrive on 2002/12/06 16:04:51
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#51 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#32 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#52 edit
-
-Change 1735 by gibbs@bitkeeper-linux-2.4 on 2002/12/06 16:03:54
-
-	aic79xx.h:
-		Use consistent names for AH?_ASYNC_XFER_PERIOD.
-	
-	aic79xx.c:
-	aic79xx_proc.c:
-		Print out IU, QAS, and RTI features when showing
-		transfer options.
-	
-	aic79xx.c:
-		Save and restore the NEGOADDR address when setting
-		new transfer settings.  The sequencer performs lookups
-		in the negotiation table too and it expects NEGOADDR
-		to remain consistent across pause/unpause sessions.
-	
-		Consistently use "offset" instead of "period" to determine
-		if we are running sync or not.
-	
-		Add a SHOW_MESSAGES diagnostic for when we assert ATN
-		during message processing.
-	
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		In ah?_devlimited_syncrate enforce that we can never
-		attempt DT transfers if we are narrow. 
-	
-		Remove the ALLOW_MEMIO config option.
-	
-		Modify ah?_linux_filter_inquiry to assume that the
-		inquiry buffer is large enough and has been setup
-		correctly (i.e. memset to 0 prior to command issue)
-		so that range checks are unecessary.
-	
-		Remove comments about the need to perform short inquiry
-		requests.  The code does this now.
-	
-		Split out the bottom half handling of DV inquiry results
-		to make the code clearer.
-	
-		Re-arrange the DV state machine so that:
-	
-		o REB descriptor fetching is performed ASYNC so we
-		  don't confuse a failure with the need to fallback.
-		o Devices using Level 2 DV don't bother with Level 1
-		  DV.
-		o REB collisions are retried after a delay randomized
-		  by our ID on the bus.
-		o Level 2 DV is only attempted on devices that support
-		  DT transfers.
-	
-		Fix ah?_linux_fallback to always favor the fastest
-		speed during fallback and to favor sync over async speeds.
-	
-		Don't let a target reponding to a PPR message with 0
-		options set fool us into falling back to far.  We still
-		must try to negotiate without using PPR to get by some
-		expanders.		
-	
-		Use the SCB_SILENT flag on DV commands.
-		with 0 PPR options set
-	
-		Fix large inquiry size calculation.  It was off by one.
-		We need to add 5 and not 4.
-	
-	aic79xx_osm_pci.c:
-		Tell the user that our failure of the MMAP test is non
-		fatal.  We're just dropping back to PIO.
-	
-	aiclib.c:
-	aiclib.h:
-		Add flags for a randomized delay in response to an error.
-	
-		Include table entries for REB collisions.
-	
-		Add the proper response codes for sense codes indicating
-		inquiry data has changed.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#142 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#76 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#103 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#66 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#88 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#86 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#16 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_proc.c#9 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#156 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#106 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#39 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aiclib.c#4 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aiclib.h#3 edit
-
-Change 1734 by gibbs@bitkeeper-linux-2.4 on 2002/12/06 15:49:37
-
-	Config.in:
-		With the advent of our command line option and the
-		new memory mapped register test, there is no need
-		for a kernel compile time option to allow memory
-		mapped I/O.  Remove it.
-
-Affected files ...
-
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/Config.in#10 edit
-
-Change 1733 by gibbs@bitkeeper-linux-2.4 on 2002/12/06 15:31:31
-
-	aic79xx.seq:
-		Correct ignore wide residue processing check for
-		a wide negotiation being in effect.  We must be
-		in the SCSI register window in order to access the
-		negotiation table.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#74 edit
-
-Change 1732 by gibbs@aslan on 2002/12/06 15:14:01
-
-	aicasm_gram.y:
-		Add two missing ';'s that for some reason yacc/bison
-		never complained about as a syntax error.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#27 edit
-
-Change 1730 by cde@haywire on 2002/12/05 17:55:31
-
-	Add AHD_DV_STATE_INQ_SHORT_ASYNC to probe inquiry buff len
-	<enter description here>
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#87 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#85 edit
-
-Change 1729 by gibbs@aslan on 2002/12/05 17:23:45
-
-	aic7xxx.h:
-		AHD -> AHC.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#65 edit
-
-Change 1728 by gibbs@aslan on 2002/12/05 17:21:45
-
-	aic79xx.c:
-	aic79xx.h:
-	aic7xxx.c:
-	aic7xxx.h:
-		Cleanup usage of the SCB_SILENT flag by using
-		a new macro SCB_IS_SILENT(scb).
-	
-		Apply the silent treatment to outgoing LQ CRC
-		errors.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#141 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#75 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#102 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#64 edit
-
-Change 1727 by gibbs@aslan on 2002/12/05 17:01:15
-
-	aic79xx.c
-	aic7xxx.c:
-	aic79xx.h:
-	aic7xxx.h:
-		Implement the SCB_SILENT flag.  This is useful for
-		hushing up the driver during DV or other operations
-		that we expect to cause transmission errors.  The
-		messages will still print if the SHOW_MASKED_ERRORS
-		debug option is enabled.
-	
-	aic7xxx_inline.h:
-	aic7xxx_pci.c:
-		Implement ahc_[in|out][w|l|q].  This removes the need
-		for manual 'or and shift" type operations through out
-		the driver.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#140 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#74 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#101 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#63 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#39 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#54 edit
-
-Change 1726 by gibbs@overdrive on 2002/12/04 17:33:18
-
-	Regenerate Linux firmware
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#20 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg_print.c#7 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#21 edit
-
-Change 1725 by gibbs@aslan on 2002/12/04 17:32:26
-
-	aic7xxx.reg:
-		Add a definition for MAX_OFFSET.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#36 edit
-
-Change 1724 by gibbs@overdrive on 2002/12/04 16:35:11
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#50 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#31 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#51 edit
-
-Change 1723 by gibbs@aslan on 2002/12/04 16:34:34
-
-	aic79xx.seq:
-		The sequencer downloading code assumes that all jump
-		labels are acurate in relation to a fully compiled
-		sequencer program (all patches downloaded).  Correct
-		a few occurances of a relative jump across a macro
-		that ended up jumping us into the last instruction
-		of the macro.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#73 edit
-
-Change 1722 by scottl@scottl-via-freebsd on 2002/12/04 15:40:08
-
-	ahd_pci.c:
-		Add a newline to the MEMIO printf.
-	
-	aic79xx_pci.c:
-		Set the mode correctly for writing to SRAM_BASE in the MEMIO
-		test.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#60 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/ahd_pci.c#11 edit
-
-Change 1721 by scottl@scottl-junior-freebsd on 2002/12/04 14:49:34
-
-	aic79xx_pci.c:
-		Use SRAM and the 0xaa55 pattern for the MEMIO test.
-	
-	ahd_pci.c:
-		Go along with ahc_pci.c and retrieve the allow_memio hint
-		from the resource manager and act on it.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#59 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/ahd_pci.c#10 edit
-
-Change 1719 by gibbs@bitkeeper-linux-2.4 on 2002/12/03 17:04:22
-
-	aic79xx_pci.c:
-		Don't attempt to set reserved bits in memio test.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#58 edit
-
-Change 1718 by gibbs@overdrive on 2002/12/03 16:16:46
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#49 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#30 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#50 edit
-
-Change 1717 by gibbs@scottl-via-freebsd on 2002/12/03 15:29:57
-
-	aic79xx_pci.c:
-		Use the TYPEPTR register as a base for our
-		memory mapped I/O test.  The Rev B. will allow
-		multi-byte access to Scratch Ram, so it is not
-		a good test of write-combining or other bad
-		behavior.
-	
-		User CLRPCIINT and CLRSPLTINT in their respective
-		handlers.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#57 edit
-
-Change 1716 by gibbs@scottl-via-freebsd on 2002/12/03 15:27:24
-
-	aic79xx.reg:
-		Correct the location of the TARGPCISTAT register.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#56 edit
-
-Change 1715 by gibbs@aslan on 2002/12/03 10:34:23
-
-	aic79xx_pci.c:
-		Revamp memory mapped I/O test to match the algorithm
-		used in the aic7xxx driver.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#56 edit
-
-Change 1714 by scottl@scottl-via-freebsd on 2002/12/02 19:12:42
-
-	aic7xxx_pci.c:
-		In the memio test, clear the FAILDIS bit of the SEQCTL
-		before running the tests so that PCI errors will be
-		flagged.
-	
-		Write only 4 bytes to the SRAM to prevent VIA chipsets
-		from generating a burst transaction on the bus.
-	
-		Clear the PCIR_STATUS register and restore the SEQCTL
-		register before exiting.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#53 edit
-
-Change 1713 by gibbs@aslan on 2002/12/02 13:04:29
-
-	aic79xx_pci.c:
-		Properly report the aic7901A as an aic7901A.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#55 edit
-
-Change 1710 by scottl@scottl-junior-freebsd on 2002/11/27 02:05:18
-
-	Fix a spelling mistake and a whitespace goof.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#52 edit
-
-Change 1709 by scottl@scottl-junior-freebsd on 2002/11/26 22:12:00
-
-	Strip down the $FreeBSD$
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_insformat.h#11 edit
-
-Change 1708 by scottl@scottl-junior-freebsd on 2002/11/26 21:56:03
-
-	Revert whitespace changes in ahc_syncrates[] to reduce diffs.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#100 edit
-
-Change 1699 by gibbs@bitkeeper-linux-2.4 on 2002/11/20 14:14:13
-
-	aic79xx_osm_pci.c:
-	aic7xxx_osm_pci.c:
-		Make use of the new Core PCI routine for testing memory
-		mapped register access.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#15 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#38 edit
-
-Change 1698 by gibbs@bitkeeper-linux-2.4 on 2002/11/20 14:13:40
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Make the "ALLOW_MEMIO" config option actually work for
-		the "disabled" case.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#86 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#155 edit
-
-Change 1697 by gibbs@bitkeeper-linux-2.4 on 2002/11/20 14:12:43
-
-	aic79xx.h:
-	aic79xx_pci.c:
-	aic7xxx.h:
-	aic7xxx_pci.c:
-		Add a routine for testing memory mapped register access.
-		This will hopefully detect things like buggy via chipsets
-		so that the OSM can fallback to using I/O mapped access
-		when memory mapped I/O simply will not work.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.h#73 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#54 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#62 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#51 edit
-
-Change 1696 by gibbs@bitkeeper-linux-2.5 on 2002/11/19 11:43:33
-
-	aiclib.h:
-		Don't include the definition for REPORT_LUNS.  It conflicts
-		with the native Linux definition.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aiclib.h#2 edit
-
-Change 1695 by scottl@scottl-template on 2002/11/18 16:45:04
-
-	       Update driver version to 1.3.0.ALPHA1
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#84 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/aic79xx.spec#16 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/install.sh#18 edit
-
-Change 1690 by scottl@scottl-template on 2002/11/14 18:31:41
-
-	Fix type from previous commit
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#154 edit
-
-Change 1689 by scottl@scottl-template on 2002/11/14 18:26:58
-
-	       Update driver version to 6.2.21
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#105 edit
-... //depot/linux_mod_devel/scsi.aic7xxx/rpm/aic7xxx.spec#7 edit
-... //depot/linux_mod_devel/scsi.aic7xxx/rpm/install.sh#10 edit
-
-Change 1688 by scottl@scottl-template on 2002/11/14 17:38:10
-
-	       Update driver version to 1.2.0
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#83 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/aic79xx.spec#14 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/install.sh#17 edit
-
-Change 1687 by scottl@scottl-template on 2002/11/14 17:36:51
-
-	Remove the previous change for falling back in narrow.  It doesn't
-	seem to work.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#85 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#153 edit
-
-Change 1686 by scottl@scottl-template on 2002/11/14 12:40:42
-
-	       Update driver version to 1.1.14
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#82 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/aic79xx.spec#13 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/install.sh#16 edit
-
-Change 1685 by scottl@scottl-template on 2002/11/14 12:40:17
-
-	aic79xx_osm.c
-	aic7xxx_osm.c
-		Add a minimum bus settle delay after doing a bus reset from
-		the DV timeout handler.
-	
-		Limit the max period allowed for narrow when figuring out
-		the narrow fallback speed.
-	
-	aic7xxx.h
-		Add AHD_ULTRA2_XFER_PERIOD for narrow fallback calculations
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#61 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#84 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#152 edit
-
-Change 1683 by scottl@scottl-template on 2002/11/13 20:49:54
-
-	       Update driver version to 1.1.13
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#81 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/aic79xx.spec#12 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/install.sh#15 edit
-
-Change 1680 by gibbs@vas2209a on 2002/11/13 19:08:38
-
-	aic7xxx_osm.c:
-		Use ahc_set_tags rather than ahc_platform_set_tags so
-		that the core can be appraised of any tag type or depth
-		changes.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#151 edit
-
-Change 1679 by gibbs@vas2209a on 2002/11/13 19:03:23
-
-	aic7xxx_osm.c:
-		Add a back in a missing ahc_done_unlock() that was
-		lost in the last change.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#150 edit
-
-Change 1678 by gibbs@bitkeeper-linux-2.5 on 2002/11/13 18:26:28
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Requeue deferred command completions so that when the
-		timer does expire the entries are actually sent. <sigh>
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#83 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#149 edit
-
-Change 1676 by gibbs@bitkeeper-linux-2.5 on 2002/11/13 16:26:07
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Move a FALLTHROUGH label to the correct
-		location in the code.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#82 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#148 edit
-
-Change 1675 by gibbs@vas2209a on 2002/11/13 15:43:19
-
-	aic79xx.c:
-		Set WIDERESEN for Rev B which ensures that an
-		expected wide residue does not prevent the
-		FIFO from reporting FIFOEMP.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#139 edit
-
-Change 1674 by gibbs@vas2209a on 2002/11/13 14:27:15
-
-	aic79xx_host.h:
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Correct a few minor compile issues that fell out of
-		the port to 2.5.X.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_host.h#9 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#81 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#147 edit
-
-Change 1673 by gibbs@bitkeeper-linux-2.5 on 2002/11/13 13:43:15
-
-	aic79xx_host.h:
-	aic79xx_osm.c:
-	aic79xx_osm.h:
-	aic7xxx_host.h:
-	aic7xxx_osm.c:
-	aic7xxx_osm.h:
-		Complete the port to Linux 2.5.X.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_host.h#8 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#80 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#80 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_host.h#11 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#146 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#104 edit
-
-Change 1672 by gibbs@bitkeeper-linux-2.4 on 2002/11/13 13:02:15
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Remove fallback from the Read Echo Buffer Descriptor
-		DV state.  This avoids issues with tape drives that
-		just hang if you issue the command.  We should really
-		be issuing the command async, but that is too complicated
-		a fix for PH1.2.  Defer that fix to PH1.3.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#79 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#145 edit
-
-Change 1671 by gibbs@aslan on 2002/11/13 12:10:23
-
-	aic79xx.c:
-		Correct code that restore the STACK.  It was
-		always placing a 0 in the high byte of the stack
-		address.
-	
-	aic7xxx.c:
-		Remove unecessary restoration of the STACK for older
-		chips.
-	
-	aic7xxx.h:
-	aic79xx.h:
-		Collapse SCB flag entries so they are bit contiguous.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#138 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#72 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#99 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#60 edit
-
-Change 1670 by gibbs@bitkeeper-linux-2.4 on 2002/11/13 11:46:51
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		To avoid stack explosion in the mid-layer, only complete
-		AH?_LINUX_MAX_RETURNED_ERRORS commands that have errors
-		at a time.  Any deferred entries will be returned via
-		a timer that runs the queue.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#78 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#144 edit
-
-Change 1669 by gibbs@vas2209a on 2002/11/13 00:14:42
-
-	aic79xx_osm.c:
-	aic79xx_osm.h:
-	aic7xxx_osm.c:
-	aic7xxx_osm.h:
-		Don't allow the eh_sem to be up'ed twice in the
-		case of the eh timer expiring and the command completing
-		due to a future recovery action such as a bus reset.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#77 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#79 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#143 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#103 edit
-
-Change 1668 by gibbs@vas2209a on 2002/11/13 00:01:03
-
-	aic79xx.c:
-		Add DFFSTAT in mode 3 to ahd_dump_card_state().
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#137 edit
-
-Change 1667 by gibbs@overdrive on 2002/11/12 23:57:48
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#48 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#29 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#49 edit
-
-Change 1666 by gibbs@aslan on 2002/11/12 23:55:24
-
-	aic79xx.reg:
-	aic79xx.seq:
-		Workaround Rev B issue with CURRFIFO_0 having the
-		same value in "enhanced mode" as "standard mode"
-		for "writes".  Reads of the register behave as
-		expected. <sigh>
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#55 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#72 edit
-
-Change 1662 by gibbs@overdrive on 2002/11/12 14:59:39
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#47 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#28 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#48 edit
-
-Change 1661 by gibbs@vas2209a on 2002/11/12 14:58:23
-
-	aicasm_gram.y:
-		Use a direct move from allzeros to emulate a
-		mvi of 0.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#26 edit
-
-Change 1660 by gibbs@vas2209a on 2002/11/12 10:33:25
-
-	aic7xxx.h:
-		Add a missing typedef.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#59 edit
-
-Change 1659 by gibbs@overdrive on 2002/11/11 23:37:31
-
-	Regenerate Linux Firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#46 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#27 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#47 edit
-
-Change 1658 by gibbs@overdrive on 2002/11/11 23:35:30
-
-	aic79xx_pci.c:
-		Set the PREQDIS bit in DEVCONFIG1 for the B.  The
-		bit is misnamed, but seems to disable a work-around 
-		that breaks on the B on PCI busses.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#53 edit
-
-Change 1657 by gibbs@overdrive on 2002/11/11 23:34:43
-
-	aic79xx.seq:
-		Return to the SCSI mode prior to re-allocating a FIFO.
-		The alloc-FIFO routine assume we are in the SCSI mode.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#71 edit
-
-Change 1656 by gibbs@bitkeeper-linux-2.4 on 2002/11/11 15:37:54
-
-	aic79xx.c:
-		Printout the SAVED_MODE scratch ram location in ahd_dump_card_state.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#136 edit
-
-Change 1655 by gibbs@bitkeeper-linux-2.4 on 2002/11/11 14:22:01
-
-	aic79xx_osm.c:
-	aic79xx_osm.h
-	aic7xxx_osm.c:
-	aic7xxx_osm.h
-		Add a timer for deferred running of the completion
-		queue.  We use this to return commands back to the OS
-		when our queue is frozen that happen to arrive before
-		Linux sees that our host queue is blocked.  This avoids
-		a deadlock issue that occurs should we attempt to simply
-		scsi_done the command immediately.  This strategy also
-		guarantees that the commands are returned almost imediately
-		instead of having to wait for either a DV command or simq
-		release to occur.
-	
-		Add the ability to reset a command's timeout from within
-		the core.  We use this to give RequestSense operations
-		a new timer.
-	
-		Always perform DV thread operations while our ah?_lock
-		is held.
-	
-	aic79xx.c:
-	aic7xxx.c:
-		Make use of the new ah?_scb_timer_reset() api.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#135 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#98 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#76 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#78 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#142 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#102 edit
-
-Change 1654 by scottl@scottl-belfalas-rh72as on 2002/11/08 19:15:45
-
-	aic79xx_osm.c:
-		Remove unused variable.
-	
-		Move ahd_linux_thread_run_complete_queue() to its
-		proper location in the file.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#75 edit
-
-Change 1653 by scottl@scottl-belfalas-rh72as on 2002/11/08 19:10:04
-
-	aic79xx_osm.c:
-		Fix deadlock in ahd_linux_queue() when we want to
-		return a command immediately to the system because
-		our queue is blocked.  We now defer the return of
-		the command until either the simq is released or
-		the dv thread has an oportunity to flush the queue.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#74 edit
-
-Change 1652 by scottl@scottl-template on 2002/11/07 23:34:47
-
-	       Update driver version to 6.2.20
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#101 edit
-... //depot/linux_mod_devel/scsi.aic7xxx/rpm/aic7xxx.spec#6 edit
-... //depot/linux_mod_devel/scsi.aic7xxx/rpm/install.sh#8 edit
-
-Change 1650 by gibbs@aslan on 2002/11/07 13:55:31
-
-	aic79xx.c:
-		Avoid infinite loop in restoration of STACK contents
-		in ahd_dump_card_state().  Our interrator must be
-		signed.
-	
-	aic79xx.c:
-	aic7xxx.c:
-		Remove a diagnostic printf.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#134 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#97 edit
-
-Change 1649 by gibbs@bitkeeper-linux-2.4 on 2002/11/07 13:33:07
-
-	aic79xx.c:
-		Workaround printf format and integer sizing issues.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#133 edit
-
-Change 1648 by gibbs@bitkeeper-linux-2.4 on 2002/11/07 13:23:23
-
-	aic79xx.c:
-		Remove extraineous include of stdint.h.  The OSM
-		header file should be doing this.
-	
-		Remove unused variable warnings for debuging code.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#132 edit
-
-Change 1647 by gibbs@bitkeeper-linux-2.4 on 2002/11/07 13:19:35
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Mark devices as "configured" once the OS calls
-		select queue_depths.  This is required now that we
-		are no longer sniffing all inquiry cmds that the
-		OS performs.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#73 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#141 edit
-
-Change 1646 by scottl@scottl-template on 2002/11/06 23:07:03
-
-	       Update driver version to 1.1.12
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#131 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#77 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/aic79xx.spec#11 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/install.sh#12 edit
-
-Change 1645 by scottl@scottl-template on 2002/11/06 23:05:33
-
-	Follow the aic79xx driver and extend the timeout amount when
-	debug printing is enabled.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#140 edit
-
-Change 1644 by gibbs@bitkeeper-linux-2.4 on 2002/11/06 11:03:48
-
-	aic79xx_osm.c:
-		Be even more pessimistic about how long negotiation
-		messages take by bumping up the DV timeout a whole
-		1 second should negotiation debugging be enabled.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#72 edit
-
-Change 1643 by scottl@scottl-template on 2002/11/05 23:40:18
-
-	       Update driver version to 6.2.19
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#100 edit
-... //depot/linux_mod_devel/scsi.aic7xxx/rpm/aic7xxx.spec#5 edit
-... //depot/linux_mod_devel/scsi.aic7xxx/rpm/install.sh#7 edit
-
-Change 1642 by scottl@scottl-template on 2002/11/05 17:58:47
-
-	       Update driver version to 1.1.11
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#76 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/aic79xx.spec#10 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/install.sh#11 edit
-
-Change 1641 by gibbs@bitkeeper-linux-2.4 on 2002/11/05 16:33:24
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Not all Linux kernel versions honor the return value
-		from the queue_command driver entry point.  To deal with
-		these older kernels, always return "rejected" commands
-		via the scsi_done handler.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#71 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#139 edit
-
-Change 1640 by gibbs@bitkeeper-linux-2.4 on 2002/11/05 15:33:08
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Avoid taking the io_request lock twice.  This is a
-		regression from our port to 2.5.X.
-	
-	aic79xx_osm.c:
-		Put some more diagnostics under AHD_SHOW_RECOVERY.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#70 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#138 edit
-
-Change 1639 by gibbs@aslan on 2002/11/05 13:13:20
-
-	aic79xx.c:
-	aic79xx.h:
-	aic7xxx.c:
-	aic7xxx.h:
-		Save and restore stack contents during diagnostics.
-		Some chip variants overwrite stale entries on a 
-		stack "pop".
-	
-		Don't use 0 to probe the stack depth.  0 is the typical
-		value used to backfill the stack if entries are overwritten
-		on a "pop".
-	
-	aic79xx.c:
-	aic79xx.h:
-		Add the AHD_SHOW_RECOVERY debug option and use it to
-		control some diagnostic messages related to error recovery.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#130 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#71 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#96 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#58 edit
-
-Change 1638 by scottl@scottl-template on 2002/11/01 18:16:08
-
-	       Update driver version to 1.1.10
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#75 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/aic79xx.spec#9 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/install.sh#10 edit
-
-Change 1637 by gibbs@overdrive on 2002/11/01 17:17:04
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#45 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#26 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#46 edit
-
-Change 1636 by gibbs@bitkeeper-linux-2.4 on 2002/11/01 17:14:53
-
-	cam.h:
-		Add CAM_DEVQ_FROZEN to the cam_status enum.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/cam.h#15 edit
-
-Change 1635 by gibbs@bitkeeper-linux-2.4 on 2002/11/01 17:14:34
-
-	Make "empty_string" static so it can be included in both the
-	aic7xxx and the aic79xx drivers.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aiclib.c#3 edit
-
-Change 1634 by gibbs@bitkeeper-linux-2.4 on 2002/11/01 17:14:08
-
-	aic7xxx.c:
-	aic7xxx.h:
-		Just for safety, have the aic7xxx driver probe
-		the stack depth too.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#95 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#57 edit
-
-Change 1633 by gibbs@bitkeeper-linux-2.4 on 2002/11/01 17:13:33
-
-	aic79xx_osm.c:
-		Correct a compile error.  The updated handling of
-		CAM_CMD_TIMEOUT was placed in the wrong routine.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#69 edit
-
-Change 1632 by gibbs@bitkeeper-linux-2.4 on 2002/11/01 17:12:22
-
-	aic79xx.seq:
-		Revert de-optimization in the fifo polling loop.
-		Our problem was caused by the larger stack size on
-		Rev B.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#70 edit
-
-Change 1631 by gibbs@bitkeeper-linux-2.4 on 2002/11/01 17:11:33
-
-	aic79xx.c:
-		Move ahd_probe_stack_size() so it matches the location
-		of its declaration.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#129 edit
-
-Change 1630 by gibbs@bitkeeper-linux-2.4 on 2002/11/01 16:19:58
-
-	aic79xx_osm.c:
-	aic79xx_osm.h:
-	aic7xxx_osm.c:
-	aic7xxx_osm.h:
-		Actually freeze the device queue in response to a request
-		to do so from the Core.  This closes a race in the case
-		of things like QUEUE FULL or BUSY handling where the
-		OSM may be able to queue additional commands prior to
-		seeing the SCB that should have frozen or otherwise altered
-		the execution queue.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#68 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#74 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#137 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#99 edit
-
-Change 1629 by gibbs@overdrive on 2002/11/01 16:17:55
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#44 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#25 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#45 edit
-
-Change 1628 by gibbs@aslan on 2002/11/01 16:11:16
-
-	aic79xx.c:
-	aic79xx.h:
-	aic79xx.reg:
-		Add a routine to dynamically determine the size
-		of the sequencer stack.  It turns out that RevB
-		has a 9 entry stack rather than the 8 entry stack
-		of the A4.  Determining the stack depth programatically
-		should protect us from any future changes in this area.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#128 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#70 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#54 edit
-
-Change 1626 by scottl@scottl-template on 2002/10/31 16:38:49
-
-	       Update driver version to 1.1.9
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#73 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/aic79xx.spec#8 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/install.sh#9 edit
-
-Change 1625 by scottl@scottl-template on 2002/10/31 15:47:57
-
-	       Update driver version to 6.2.18
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#98 edit
-... //depot/linux_mod_devel/scsi.aic7xxx/rpm/aic7xxx.spec#4 edit
-... //depot/linux_mod_devel/scsi.aic7xxx/rpm/install.sh#6 edit
-
-Change 1623 by scottl@scottl-template on 2002/10/31 14:47:46
-
-	Define SCSI_NOSENSE_STRINGS to elimiate the asc/ascq description
-	strings.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aiclib.c#2 edit
-
-Change 1622 by scottl@scottl-template on 2002/10/31 14:44:19
-
-	Don't lock the io_request_lock until after calling
-	ahd_linux_register_host().
-	Release the ahd lock when calling kernel_thread()
-	
-	This fixes a deadlock when launching the DV thread in
-	older 2.4 SMP kernels.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#136 edit
-
-Change 1621 by scottl@scottl-template on 2002/10/31 14:17:54
-
-	Don't lock the io_request_lock until after calling
-	ahd_linux_register_host().
-	Release the ahd lock when calling kernel_thread()
-	
-	This fixes a deadlock when launching the DV thread in
-	older 2.4 kernels.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#67 edit
-
-Change 1618 by scottl@scottl-template on 2002/10/30 19:48:52
-
-	       Update driver version to 1.1.8
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#72 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/aic79xx.spec#7 edit
-... //depot/linux_mod_devel/scsi.aic79xx/rpm/install.sh#8 edit
-
-Change 1616 by scottl@scottl-template on 2002/10/30 19:05:51
-
-	       Update driver version to 6.2.17
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#97 edit
-... //depot/linux_mod_devel/scsi.aic7xxx/rpm/aic7xxx.spec#3 edit
-... //depot/linux_mod_devel/scsi.aic7xxx/rpm/install.sh#3 edit
-
-Change 1615 by gibbs@overdrive on 2002/10/30 18:35:23
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#43 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#24 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#44 edit
-
-Change 1614 by gibbs@aslan on 2002/10/30 18:34:26
-
-	aic79xx.seq:
-		Rearrange idle_loop_service_fifo:  I have a hunch
-		that the sequencer does not like the optimized version
-		of this routine should we be paused at the start of
-		a longjmp handler.  We now change this to look just
-		as it did in PH 1.1.
-	
-		Clear the longjmp address of the p_data handler just
-		after we call disable_ccsgen.  Otherwise the longjmp
-		handler may not be deregistered until an extra call
-		into the handler or a new handler is installed.  The
-		first behavior might be dangerous if the FIFO is not
-		active.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#69 edit
-
-Change 1613 by gibbs@overdrive on 2002/10/30 16:52:10
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#42 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#23 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#43 edit
-
-Change 1612 by gibbs@aslan on 2002/10/30 16:50:11
-
-	aic79xx.seq:
-		Test for SCSIPERR instead of relying on SCSIPHASE
-		not setting on a SCSI parity error.  It seems that
-		this is not the case and that we occassionally coast
-		out of routines like phase_lock when a parity error
-		is pending.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#68 edit
-
-Change 1611 by gibbs@aslan on 2002/10/30 12:55:46
-
-	aic7770.c:
-		Add IDs for some Olivetti OEM aic7770 based cards.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#27 edit
-
-Change 1610 by gibbs@bitkeeper-linux-2.4 on 2002/10/30 12:27:14
-
-	aic7xxx.c:
-		Don't disable ENBUSFREE when single stepping on
-		a DT capable controller.  We cannot re-enable unexpected
-		busfree detection, so we must clear BUSFREE on each
-		step instead.
-	
-		Correct the lookup of the SCB ID in ahc_handle_proto_error.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#94 edit
-
-Change 1609 by gibbs@aslan on 2002/10/30 12:25:51
-
-	aic79xx.h:
-		Remove redundant declaration of ahd_print_devinfo().
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.h#69 edit
-
-Change 1608 by gibbs@bitkeeper-linux-2.4 on 2002/10/30 11:38:28
-
-	aic7xxx_osm.c:
-		Bring in DV state machine enhancements from the U320
-		driver.
-	
-	aic79xx_osm.c:
-		Remove a left over diagnostic.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#66 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#135 edit
-
-Change 1607 by gibbs@bitkeeper-linux-2.4 on 2002/10/30 10:13:52
-
-	Pull DV branch into the mainline.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#127 integrate
-... //depot/aic7xxx/aic7xxx/aic79xx.h#68 integrate
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#39 integrate
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#93 integrate
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#56 integrate
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#65 integrate
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#71 integrate
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_proc.c#8 integrate
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#134 integrate
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#96 integrate
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#23 integrate
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aiclib.c#1 branch
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aiclib.h#1 branch
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/cam.h#14 integrate
-
-Change 1604 by gibbs@overdrive on 2002/10/29 18:59:13
-
-	aic79xx_osm.c:
-		Correct module description to properly identify the
-		driver as AIC79XX.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#64 edit
-
-Change 1597 by gibbs@overdrive on 2002/10/29 14:09:41
-
-	aic79xx_osm_pci.c:
-		Remove redundant check for PCI-X controller.  The bug
-		flag should be enough.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#14 edit
-
-Change 1596 by gibbs@overdrive on 2002/10/29 14:09:13
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#41 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#22 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#42 edit
-
-Change 1592 by gibbs@aslan on 2002/10/29 11:05:58
-
-	Implement work around for the Interrupt collission problem
-	on the 7902B.
-	
-	aic79xx.c:
-		When a sequencer interrupt occurs on the B, unpause
-		the sequencer and allow it to clear SEQINTCODE with
-		a second SEQINT prior to processing the "real" seqint.
-		This clears SEQINTCODE without requiring an extra
-		interrupt.
-	
-		Convert the SAW_HWERR sequencer interrupt into a
-		call to ahd_handle_hwerrint().
-	
-	aic79xx.h:
-		Add AHD_INTCOLLISION_BUG.
-	
-		Add NO_SEQINT, which is the special value that we
-		use to initialize SEQINTCODE so that the host can
-		tell if there is a real SEQINT pending.
-	
-	aic79xx.reg:
-		Add SET_SEQINTCODE() macro to special case sequencer
-		interrupt processing based on AHD_INTCOLLISION_BUG.
-	
-	aic79xx.seq
-		Whenever the sequencer is restarted, insure that
-		SEQINTCODE is properly initialized.
-	
-		Convert a non-zero ERROR status to a SAW_HWERR
-		sequencer interrupt.
-	
-		Add set_seqint_work_around which will clear SEQINTCODE
-		after every SEQINT.
-	
-		Use SET_SEQINTCODE throughout the firmware.
-	
-	aic79xx_inline.h:
-		Use a read of HCNTRL to flush our write to CLRCMDCMPLT
-		on the RevB.  This allows us to check to see if the sequencer
-		is paused and to initiate the interrupt collision workaround
-		without incuring an extra read.
-	
-	aic79xx_pci_c:
-		Set AHD_INTCOLLISIONT_BUG for the Rev B.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#126 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#67 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#53 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#67 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#38 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#52 edit
-
-Change 1590 by gibbs@overdrive on 2002/10/28 18:12:32
-
-	Regernerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#40 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#21 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#41 edit
-
-Change 1588 by gibbs@aslan on 2002/10/28 14:39:15
-
-	aic79xx_inline.h:
-		Add our controller name to the front of our
-		diagnostic "Setting Mode" messages.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#37 edit
-
-Change 1587 by gibbs@aslan on 2002/10/28 14:38:45
-
-	aic79xx.c:
-	aic79xx.reg:
-		Some 160 devices incorrectly accept 0xfe as a
-		sync offset, but will overrun this value.  Limit
-		to 0x7f for speeds lower than U320 which will
-		avoid the persistent sync offset overruns.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#125 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#52 edit
-
-Change 1574 by gibbs@overdrive on 2002/10/26 20:42:36
-
-	aic7xxx_osm.c:
-		Add "paused = TRUE" in ahc_queue_recovery_cmd which
-		was lost in the conversion to use ahc_pause_and_flush_work().
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#133 edit
-
-Change 1572 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/10/26 01:10:28
-
-	       Update driver version
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#70 edit
-
-Change 1570 by gibbs@aslan on 2002/10/25 23:53:19
-
-	aic79xx_pci.c:
-		Remove stray/random extra 7901A generic PCI
-		table entry.  Also switch the correct 7901A
-		generic entry to use ID_ALL_MASK since we
-		can only differentiate the 7901A from the
-		7902 by checking for a "type field" of 0xE.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#51 edit
-
-Change 1565 by gibbs@overdrive on 2002/10/25 20:45:29
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#39 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#20 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#40 edit
-
-Change 1564 by gibbs@aslan on 2002/10/25 20:44:25
-
-	aic79xx.h:
-		Add "feature" AHD_NEW_DFCNTRL_OPTS for SCSIENWRDIS.
-	
-	aic79xx.reg:
-		Add the SCSNENWRDIS field and the PLLDELAY register
-		definitions.
-	
-	aic79xx.seq:
-		Use SCSIENWRDIS when setting PRELOADEN on all
-		SG element writes save the first one on chips
-		that support this feature so that SCSIEN does
-		not get corrupted.
-	
-		Correct a bug in the legacy bitbucket handler.
-		We must save and restore our mode pointer now
-		that we can be using both FIFOs.
-	
-	aic79xx_pci.c:
-		PREQDIS in DEVCONFIG1 went away after the A2.
-		Remove all code that references this bit.  This
-		is especially important since this bit was reused
-		in the B for a different HW fix workaround.
-	
-		Properly set the AHD_NEW_IOCELL_OPTS and
-		AHD_NEW_DFCNTRL_OPTS features for the B.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.h#66 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#51 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#66 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#50 edit
-
-Change 1540 by gibbs@bitkeeper-linux-2.4 on 2002/10/23 12:53:14
-
-	Make it possible for both the aic7xxx and the aic79xx driver
-	to rely on scsi_all.c yet still be built into the same kernel.
-	Since we can't use a module dependency to have a "library module",
-	symbols are renamed and the code included in each driver.
-
-Affected files ...
-
-... //depot/aic7xxx-dv/aic7xxx/aic79xx.c#8 edit
-... //depot/aic7xxx-dv/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#9 edit
-... //depot/aic7xxx-dv/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#8 edit
-... //depot/aic7xxx-dv/linux/drivers/scsi/aic7xxx/aic79xx_proc.c#3 edit
-... //depot/aic7xxx-dv/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#30 edit
-... //depot/aic7xxx-dv/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#13 edit
-... //depot/aic7xxx-dv/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#3 edit
-... //depot/aic7xxx-dv/linux/drivers/scsi/aic7xxx/cam.c#2 delete
-... //depot/aic7xxx-dv/linux/drivers/scsi/aic7xxx/cam.h#4 edit
-... //depot/aic7xxx-dv/linux/drivers/scsi/aic7xxx/scsi_all.c#2 edit
-... //depot/aic7xxx-dv/linux/drivers/scsi/aic7xxx/scsi_all.h#2 edit
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/Makefile#9 edit
-
-Change 1538 by gibbs@aslan on 2002/10/22 21:45:34
-
-	aic79xx.c:
-		Modify use_ppr handling in ahd_build_transfer_message
-		to match the aic7xxx driver.
-	
-	aic7xxx.c:
-		Move a comment and remove a useless clearing of use_ppr.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#124 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#92 edit
-
-Change 1537 by gibbs@aslan on 2002/10/22 21:38:02
-
-	aic7xxx.c:
-		Bring back "use_ppr".  We need to use_ppr anytime
-		doppr is true or we have non-zero protocol options.
-		The later case was not handled in the recent removal
-		of use_ppr.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#91 edit
-
-Change 1528 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/10/22 12:00:33
-
-	       Update driver version
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#69 edit
-
-Change 1526 by gibbs@bitkeeper-linux-2.4 on 2002/10/22 11:54:03
-
-	Integrate from Head into aic7xxx-dv.
-
-Affected files ...
-
-... //depot/aic7xxx-dv/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#6 integrate
-... //depot/aic7xxx-dv/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#6 integrate
-... //depot/aic7xxx-dv/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#6 integrate
-... //depot/aic7xxx-dv/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#3 integrate
-... //depot/aic7xxx-dv/linux/drivers/scsi/aic7xxx/aic7xxx_reg_print.c#3 integrate
-... //depot/aic7xxx-dv/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#3 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/Makefile#8 edit
-
-Change 1525 by gibbs@overdrive on 2002/10/22 11:53:24
-
-	Regerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#38 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#19 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#39 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#19 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg_print.c#6 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#20 edit
-
-Change 1520 by gibbs@aslan on 2002/10/21 20:40:11
-
-	aic7xxx.c:
-		Add a newline to ahc_dump_card_state() output.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#90 edit
-
-Change 1519 by gibbs@aslan on 2002/10/21 20:39:23
-
-	aic7xxx.c:
-		Update ahc_reg_print() to handle a NULL cur_col.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#89 edit
-
-Change 1518 by gibbs@aslan on 2002/10/21 20:37:24
-
-	aic7xxx.c:
-		Add additional diagnostic output to ahc_dump_card_state(),
-		and have it use the register pretty printing functions.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#88 edit
-
-Change 1517 by gibbs@aslan on 2002/10/21 16:30:21
-
-	aic7xxx.seq:
-		Move data fifo CLRCHN to mesgin_rdptrs which is a safer
-		location for doing this operation.  This also saves a
-		sequencer instruction.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#52 edit
-
-Change 1516 by gibbs@aslan on 2002/10/21 16:18:49
-
-	aic79xx.seq:
-		Clarify a comment in the mesgin_rdptrs handler.
-		We need to clear the data fifo for CMD retries too.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#65 edit
-
-Change 1515 by gibbs@overdrive on 2002/10/21 16:06:12
-
-	aic7xxx_osm.c:
-		Adapt to conversion from IDENTIFY_SEEN to NO_IDENTIFIED.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#132 edit
-
-Change 1514 by gibbs@aslan on 2002/10/21 15:58:42
-
-	aic79xx.c:
-		Move "false parity error due to REQ release glitch"
-		workaround to the packetized busfree handler.  We
-		now only look to see if this is the potential cause
-		of the error if we have ruled out all other causes.
-		Before, it might be possible for this workaround
-		to trigger on "real" busfrees.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#123 edit
-
-Change 1513 by gibbs@overdrive on 2002/10/21 15:53:19
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#37 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#18 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#38 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#18 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg_print.c#5 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#19 edit
-
-Change 1512 by gibbs@aslan on 2002/10/21 15:51:41
-
-	aic79xx.c:
-	aic79xx.seq:
-		Handle unexpected command phases in the protocol violation
-		handler.  Right now we treat these just like data phase
-		protocol violations.
-	
-	aic79xx.seq:
-		Optimize out a few instructions by using a common label
-		for protocol violations in mesgin and status phases.  One
-		more instruction was removed by factoring out the status
-		received check in the mesgin_complete handler.
-	
-	aic7xxx.c:
-	aic7xxx.h:
-	aic7xxx.reg:
-	aic7xxx.seq:
-		Bring in the protocol violation handler from the U320
-		driver and replace the NO_IDENT sequencer interrupt code
-		with the PROTO_VIOLATION code.  Support for this code
-		required the following changes:
-	
-		SEQ_FLAGS:
-			IDENTIFY_SEEN -> NOT_IDENTIFIED
-			Added NO_CDB_SENT
-	
-		SCB_CONTROL:
-			TARGET_SCB == STATUS_RCVD for initiator mode
-	
-		scb->flags:
-			Added SCB_TARGET_SCB since we cannot rely on
-			TARGET_SCB as a target/initiator differentiator
-			due to it being overloaded in initiator mode to
-			indicate that status has been received.
-	
-	aic7xxx.seq:
-		Reset the FIFO whenever a short CDB transfer occurs
-		so that the FIFO contents do not corrupt a future CDB
-		transfer retry.
-	
-		Add support for catching the various protocol violations
-		handled by ahc_handle_protocol_violation.
-	
-		Reformat some comments.
-	
-	aic7xxx_osm.c:
-		Handle changes to SCB_CONTROL, scb->flags and SEQ_FLAGS.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#122 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#64 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#87 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#55 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#35 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#51 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.c#12 edit
-
-Change 1511 by gibbs@overdrive on 2002/10/18 17:37:10
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#36 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#17 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#37 edit
-
-Change 1509 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/10/18 17:33:40
-
-	Remove the DV framework from aic79xx.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#63 edit
-
-Change 1508 by scottl@scottl-template on 2002/10/18 15:27:23
-
-	Update to 6.2.13
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#95 edit
-
-Change 1505 by scottl@scottl-template on 2002/10/17 18:48:26
-
-	Integrate from aic7xxx-dv branch.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#86 integrate
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#54 integrate
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#62 integrate
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#131 integrate
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#94 integrate
-
-Change 1491 by gibbs@bitkeeper-linux-2.5 on 2002/10/15 18:51:15
-
-	aic79xx.reg:
-		Remove duplicate field.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#50 edit
-
-Change 1490 by gibbs@bitkeeper-linux-2.5 on 2002/10/15 18:44:45
-
-	aic79xx.reg:
-		Bring in Rev B SNAPSHOT and SLOWCRC bit fields from
-		the DV branch.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#49 integrate
-
-Change 1488 by gibbs@bitkeeper-linux-2.5 on 2002/10/15 18:38:54
-
-	README.aic79xx:
-		Correct rd_strm section to match correct syntax.
-	
-		Add amplitude, precomp, and slewrate options.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/README.aic79xx#4 edit
-
-Change 1487 by gibbs@bitkeeper-linux-2.5 on 2002/10/15 18:30:42
-
-	aic79xx_osm.c:
-	aic79xx_osm.h:
-		Add code to set precomp, slewrate, and amplitude on
-		a per-controller basis.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#61 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#68 edit
-
-Change 1486 by gibbs@bitkeeper-linux-2.5 on 2002/10/15 18:30:16
-
-	aic79xx.h:
-	aic79xx_pci.c:
-		SLEW -> SLEWRATE
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.h#65 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#49 edit
-
-Change 1484 by gibbs@overdrive on 2002/10/15 17:00:52
-
-	Regenerate Linux firmware and register definitions.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#35 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#16 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#36 edit
-
-Change 1483 by gibbs@aslan on 2002/10/15 14:53:35
-
-	Move IOCell paramters into softc and add a hook for the
-	OSM to modify these as well as other settings prior to
-	committing them to the chip.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#121 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#64 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#48 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#48 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.h#15 edit
-
-Change 1482 by gibbs@bitkeeper-linux-2.5 on 2002/10/15 10:05:36
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Promote si.memsize to 64 bits pefore shifting by
-		PAGE_SIZE so that the returned value is not truncated
-		to 64GB.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#60 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#130 edit
-
-Change 1481 by scottl@scottl-template on 2002/10/15 00:59:37
-
-	Integrate debugging info nit from aic7xxx-dv
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#129 integrate
-
-Change 1480 by scottl@scottl-template on 2002/10/15 00:57:33
-
-	Update to version 6.2.12
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#93 edit
-
-Change 1478 by scottl@scottl-template on 2002/10/15 00:22:14
-
-	Integrate from the aic7xxx-dv branch
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#53 integrate
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#128 integrate
-
-Change 1474 by scottl@scottl-template on 2002/10/14 10:57:29
-
-	Integrate the aic7xxx dv work into head
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#85 integrate
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#127 integrate
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#92 edit
-
-Change 1465 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/10/10 16:11:43
-
-	Add three new insmod tunables for the IO Cell.  They let you control
-	the slewrate, precomp, and amplitude.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#120 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#59 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#67 edit
-
-Change 1462 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/10/09 21:49:56
-
-	Add updated H2B identifiers
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#47 edit
-... //depot/linux_mod_devel/scsi.aic79xx/dud/redhat/pcitable#2 edit
-
-Change 1457 by gibbs@bitkeeper-linux-2.4 on 2002/10/09 15:56:51
-
-	Integrate from aic7xxx -> aic7xxx_dv.
-
-Affected files ...
-
-... //depot/aic7xxx-dv/aic7xxx/aic79xx.c#3 integrate
-... //depot/aic7xxx-dv/aic7xxx/aic79xx.reg#3 integrate
-... //depot/aic7xxx-dv/aic7xxx/aic79xx.seq#3 integrate
-... //depot/aic7xxx-dv/aic7xxx/aic79xx_pci.c#3 integrate
-... //depot/aic7xxx-dv/aic7xxx/aic7xxx.c#2 integrate
-... //depot/aic7xxx-dv/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#2 integrate
-... //depot/aic7xxx-dv/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#3 integrate
-... //depot/aic7xxx-dv/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#3 integrate
-... //depot/aic7xxx-dv/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#3 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/Makefile#7 edit
-
-Change 1455 by gibbs@bitkeeper-linux-2.4 on 2002/10/09 15:08:23
-
-	aic7xxx.c:
-		Only force a renegotiation on a selection timeout
-		if the SCB was valid.  Doing otherwise may be dangerous
-		as the connection was not valid for an unknown reason.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#84 edit
-
-Change 1454 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/10/09 14:45:23
-
-	       Update driver version
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#66 edit
-
-Change 1453 by gibbs@overdrive on 2002/10/09 14:44:21
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#34 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#15 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#35 edit
-
-Change 1452 by gibbs@aslan on 2002/10/09 14:43:31
-
-	The double write workaround for CURRSCB is only required if
-	abort pending is set.  Remove this work around and set the
-	abort pending bug bit on the B at least until we have better
-	confirmation that the double write is always safe.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#63 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#46 edit
-
-Change 1450 by gibbs@overdrive on 2002/10/09 00:32:41
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#33 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#14 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#34 edit
-
-Change 1449 by gibbs@aslan on 2002/10/09 00:31:44
-
-	aic79xx.c:
-		Enhance the packetized overrun handler to cover the
-		case of a data phase for an SCB that is not active.
-	
-		Update the comment on how CRC errors should be handled
-		in Harpoon2A and B.  The comment is still not fully
-		accurate.  We'll need more input from the hardware developers
-		before we can make the CRC handling really robust.
-	
-		Add diagnostics for unexpected busfrees that we take to
-		mean a negotiation message has been rejected.
-	
-		Fix several bugs in the iocell option setting code.  For
-		starters, the amplitude setting is in ANNEXCOL 6.  The
-		amplitude should also be set regardless of connection
-		speed.  The negotiation table is now updated in the
-		chip reset code which occurs after the profile information
-		is stored in our softc.  This avoids the problem of having
-		the chip reset code clear the neg table after the profile
-		code has written to it.  Lastly, only clear the negtable
-		manually on chip reset if we are on rev A.
-	
-		Remove the redundant setting of the ABORTPENDING bit.
-		I have yet to verify that aborts actually work on the B.
-	
-		Have ahd_qinfifo_requeue_tail() save and restore the
-		current mode and operate in the command channel mode.
-		ahd_qinfifo_count requires this mode and some of the
-		latest callers to ahd_qinfifo_requeue_tail() are not
-		already in the command channel mode.
-	
-		Allow register pretty printing with a NULL cur_column.
-	
-		Add a space in a register diagnostic and print out SIMODE0
-		in ahd_dump_card_state().
-	
-	aic79xx.reg:
-		Add a macro RESTORE_MODE that sets the current mode to
-		the value stored in the register passed to it.
-	
-		Add the DFFBITBUCKET bit for packetized bitbucket.
-	
-		Correct the definition of AHD_ANNEXCOL_IOCELL_OPT1.
-	
-	aic79xx.seq:
-		Clean up the structure of our idle loop.  This adds
-		a few instructions since the idle loop has been broken
-		into the following sub-routines that can be assembled
-		into customized idle loops:
-	
-			idle_loop_gsfifo	- Service the Good Status FIFO
-			idle_loop_service_fifos - Run any LONGJMP handlers
-			idle_loop_cchan		- Run command channel operations
-	
-		One or more of these routines are now called from the
-		main idle loop, the legacy idle loop, and the allocate_fifo
-		routine.  This removes a bunch of duplicated code and hopefully
-		clarifies the code flow.
-	
-		Optimize out a few instructions.
-	
-		Write to CURRSCB twice in a row since it seems that these
-		writes are sometimes flakey.
-	
-		Use the MK_MESSAGE bit in SCB_CONTROL as our abort bit.
-		We now set MK_MESSAGE on every SCB completion so that
-		reselections to idle SCBs trigger an automatic abort.
-	
-		Now that the other FIFO may be active doing packetized
-		things during a legacy connection, have the legacy
-		idle loop use a LONGJMP handler and process LONGJMP
-		handlers for both FIFOs.
-	
-		Have the CFG4OVERRUN handler use packetized bitbucket
-		if it is available.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#119 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#47 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#62 edit
-
-Change 1445 by gibbs@overdrive on 2002/10/05 00:10:28
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#32 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#13 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#33 edit
-
-Change 1444 by gibbs@aslan on 2002/10/05 00:07:22
-
-	aic79xx.c:
-		Add 4 TRACEPOINT sequencer interrupts useful for debugging.
-	
-		Record busfree time prior to clearing any critical sections
-		since we now clear any busfree interrupts while stepping.
-	
-		Add support for supressing unexpected busfree warnings
-		when we reject a QAS request after delivering a CRC
-		related message.
-	
-		Rev B hardware will not step with pending, pausing,
-		sequencer interrupts.  Turn off the interrupt enables
-		for all pausing interrupts save ENBUSFREE.  ENBUSFREE
-		must not be disabled or we will lose the ability to
-		detect unexpected busfree events until the start of
-		the next connection.  Diagnostics have also been added
-		to track the stepping process under the MISC debug category.
-	
-		Add CLROVERRUN to the list of interrupts cleared by
-		ahd_clear_intstat().
-	
-		Update PPR message conformance rules.  RTI must be
-		disabled for non-paced transfers.
-	
-		Don't apply RevA negtable corrections to the B.
-	
-		First pass at supporting RevB IOCELL settings.  Currently
-		the settings for precomp are the same for Rev A and B,
-		so they share code.  This will have to change if these
-		numbers are adjusted further.  It may be possible to remove
-		the RevA HP_BOARD options, but I still need to verify that
-		with Brandon Aubrey.
-	
-		If a device rejects a PPR message after the full PPR
-		message has been sent, assume it does not understand
-		SPI-4 PPR options and negotiate without them.  This
-		allows us to negotiate U160 with certain Fujitsu
-		U160 drives.
-	
-		Use enhanced DFFSTAT CURRFIFO status and adjust code
-		appropriately.
-	
-		CPQ->HP
-	
-		Set LQONOCHKOVER in LQOSCSCTL to avoid spurious LQO
-		overrun conditions.
-	
-		Negotiate RTI if it is available.
-	
-	aic79xx.h:
-		Add RTI and NEW_IOCELL_OPTS as AHD options enabled on
-		the B.
-	
-		Document each ahd_bug entry in the enumeration for quick
-		reference and add the AHD_LQOOVERRUN_BUG and
-		AHD_PACED_NEGTABLE_BUG entries.
-	
-		CPQ-HP
-	
-		Add the expect QAS reject busfree flag in ahd_msg_flags.
-	
-	aic79xx.reg:
-		Add four tracepoint sequencer interrupts.
-	
-		Modify CURRFIFO definition for Rev A backwards compatibility	
-		while using Rev B enhanced mode.
-	
-		Add the LQOSCSCTL register.
-	
-		Correct spelling of CURRFIFODEF in SCSCHKN.
-	
-		Add new IOCELL option ANNEX column definitions.
-	
-		Update CCSGCTL to move of CCSGEN in Rev B.  This
-		definition allows backwards compatibility, but may
-		change should we decide to optimize code due to this
-		change.
-	
-		Align QOUTFIFO_NEXT_ADDR on a 4 byte boundary since on
-		the B, this is required of any location that will be used
-		as the source for a block move to SCB/SGHADDR.
-	
-	aic79xx.seq:
-		Hit CCSCBRESET after setting the target address in
-		SCBHADDR to mirror what the CHIM sequencer does.  I
-		don't believe this has any real effect but was a holdover
-		from debugging command channel DMA operations up to
-		the host on the B.
-	
-		Simplify the run down of the qoutfifo loop by rearranging
-		it a bit.  We no longer special case loading first element.
-	
-		Allow non-pack transactions to use either FIFO without
-		waiting for the other FIFO to clear on Rev B.
-	
-		Remove an unecessary clear of SHCNT[1] and SHCNT[2] in
-		the embedded cdb transmission case.
-	
-		Do not rely on SCSIENACK being visible until at least one
-		sequencer instruction after it is written.  While this
-		is safe on RevA, the wait is required on RevB.
-	
-		Adapt to changes in the definition of CCSGCTL.
-	
-		Always perform aligned, 4byte block moves to SCB/SGHADDR.
-		Single RMW operations are still okay too.
-	
-	aic79xx_pci.c:
-		HP -> CPQ
-	
-		Rearrange IDs to better match which chips they use.
-	
-		Convert to uniform product description strings.
-	
-		Simplify 7901A setup function.
-	
-		Add the NONPACKFIFO_BUG and PACED_NEGTABLE_BUG entries
-		for the A.
-	
-		Add rev B bugs and features.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#118 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#63 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#46 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#61 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#45 edit
-
-Change 1441 by gibbs@overdrive on 2002/10/04 16:29:18
-
-	Add missing "{}"s around diagnostic code so that status packet
-	information is not printed unless the SHOW_SENSE debug flag is
-	set.  The message is only printed if the driver is compiled with
-	debug code enabled.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#117 edit
-
-Change 1432 by gibbs@overdrive on 2002/10/02 15:12:35
-
-	oder -> order.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/README.aic79xx#3 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/README.aic7xxx#2 edit
-
-Change 1427 by gibbs@bitkeeper-linux-2.4 on 2002/10/01 18:56:39
-
-	Have the Makefile do all the relative path including instead of
-	putting this in all of the include directives in the Linux OSMs.
-	This will make the module building framework happy on 8.0.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#58 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#65 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#126 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#91 edit
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/Makefile#6 edit
-
-Change 1425 by gibbs@aslan on 2002/10/01 14:45:04
-
-	Add a space to the end of the ahc/ahd_print_devinfo routines
-	so that it behaves as expected by the code that uses it.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#116 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#83 edit
-
-Change 1424 by gibbs@bitkeeper-linux-2.4 on 2002/10/01 13:20:47
-
-	If the initial bus reset is diabled, attempt to negotiate async
-	rather than the fastest non-ppr rate below the user setting.  We
-	will negotiate up to the user setting once inquiry information is
-	available.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#57 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#125 edit
-
-Change 1423 by gibbs@aslan on 2002/10/01 13:13:22
-
-	aic79xx.c:
-		Fix a style nit.
-	
-		Attempt to recover from a selection timeout that
-		occurs with an invalid SCB.  This should never
-		happen, but its best to try and keep the machine
-		going.
-	
-		Force a renegotiation to a particular target after
-		a selection timeout.  This handles the case of a
-		temporary interruption in the cable that the target
-		might notice and switch back to async without creating
-		a unit attention condition.
-	
-		Add code to ignore busfree interrupts which are in
-		fact parity errors resulting from a glitchy REQ
-		release of the free running clock by a target transitioning
-		to the bus free phase.  This code needs to be tested by
-		FTL.  A diagnostic will be printed if the debugging code
-		is enabled with the AHD_SHOW_MASKED_ERRORS bit set in
-		the debugging bitmask.
-	
-		Remove a redundant setting of the mode in the busfree
-		handler.
-	
-	aic79xx.c:
-	aic79xx.h:
-	aic7xxx.c:
-	aic7xxx.h:
-		Change ahc/ahd_upate_neg_request() to take a "negotiation
-		type" enum that allows us to negotiate:
-			o only if the goal and current parameters differ.
-			o only if the goal is non-async
-			o always - even if the negotiation will be for async.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#115 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#62 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#82 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#52 edit
-
-Change 1422 by gibbs@aslan on 2002/09/30 17:09:13
-
-	Don't panic (as a diagnostic to catch bugs) if we decided to
-	force the renegotiation of async even if we believe we are
-	already async.  This should allow us to negotiate async instead
-	of the full user goal rate during startup if bus resets are disabled.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#114 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#81 edit
-
-Change 1420 by gibbs@aslan on 2002/09/30 13:49:47
-
-	Remove a left over '&' from the conversion to using our
-	softc referenced seeprom store.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#26 edit
-
-Change 1419 by gibbs@bitkeeper-linux-2.5 on 2002/09/27 16:44:04
-
-	Add a missing pair of curly braces to a conditional debug
-	statement.  This ensures that debug code doesn't trigger if
-	it isn't enabled. <blush>
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#80 edit
-
-Change 1418 by gibbs@bitkeeper-linux-2.5 on 2002/09/27 14:46:02
-
-	Reset commands_since_idle_or_otag in the mid-layer induced otag
-	case.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#56 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#124 edit
-
-Change 1417 by gibbs@bitkeeper-linux-2.5 on 2002/09/27 14:36:27
-
-	Honor ordered tagged requests from the mid-layer.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#55 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#123 edit
-
-Change 1416 by gibbs@aslan on 2002/09/26 21:19:05
-
-	Remove redundant inclusion of inttypes.h in aicasm_gram.y
-	and properly sort inttypes.h into list of includes.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#25 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_macro_scan.l#7 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#18 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#23 edit
-
-Change 1415 by gibbs@aslan on 2002/09/26 16:02:22
-
-	Correct another BE issue in a printf.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#113 edit
-
-Change 1404 by gibbs@overdrive on 2002/09/24 17:27:07
-
-	Correct a spelling error.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#54 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#122 edit
-
-Change 1403 by gibbs@aslan on 2002/09/24 17:06:41
-
-	Correct a spelling mistake.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#79 edit
-
-Change 1400 by gibbs@overdrive on 2002/09/24 14:29:16
-
-	Make version numbers match what the driver prints on startup.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/README.aic79xx#2 edit
-
-Change 1399 by gibbs@overdrive on 2002/09/24 13:54:33
-
-	Add README files for embedded Linux drivers.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/README.aic79xx#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/README.aic7xxx#1 add
-
-Change 1398 by gibbs@bitkeeper-linux-2.5 on 2002/09/24 12:50:32
-
-	Bump Linux driver versions:
-		aic7xxx = 6.2.10
-		aic79xx = 1.1.1
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#64 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#90 edit
-
-Change 1397 by gibbs@bitkeeper-linux-2.4 on 2002/09/23 12:02:16
-
-	Add memory mapped I/O compile time option.
-
-Affected files ...
-
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/Config.in#9 edit
-
-Change 1396 by gibbs@bitkeeper-linux-2.4 on 2002/09/23 12:01:01
-
-	Add memory mapped I/O option to both the aic7xxx and aic79xx drivers.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#53 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#63 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#13 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#121 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#89 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#37 edit
-
-Change 1395 by gibbs@overdrive on 2002/09/23 11:19:47
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Remove two spurious but benign if statements that
-		probably appeared due to an editing botch.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#52 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#120 edit
-
-Change 1393 by gibbs@bitkeeper-linux-2.5 on 2002/09/20 14:58:43
-
-	aic7xxx_host.h:
-		Port to 2.5.X.
-		 - Adapt to "biosparam" driver method specification
-	
-	aic7xxx_osm.c:
-		Port to 2.5.X.
-		 - Include scsicam.h for disk partition functions.
-		 - Switch from strtok to strsep.  Strtok is no longer
-		   available in 2.5.X.	
-		 - Adapt to the removal of the io_request lock and the
-		   mid-layer acquiring our own lock prior to calling us.
-		   This comes in the form of a new inline,
-		   ahc_midlayer_entrypoint_lock().  For 2.5.X, this is
-		   no-op since our lock is already held prior to entry
-		   into the driver.
-		 - Make use of scsi_assign_lock so that we can have our
-		   lock held before we have our host structure.  If we
-		   used the host lock in the host structure, we would
-		   not be able to acquire our lock in our interrupt handler
-		   should a shared interrupt occur before we allocated
-		   our host structure.
-		 - Added comments indicating why it is that we don't do
-		   the same ahc_unlock()/ahd_done_lock() dance in 2.5.X.
-		   Since the done lock and the ahc_lock are one and the
-		   same, it doesn't make sense to release and reacquire
-		   the same lock.  For older kernels, this dance is required
-		   to avoid lock order reversals.
-		 - In our error recovery entry points, move unlock_irq()
-		   calls down to where we sleep so it is more obvious why
-		   they are required.  Add some comments about this too.
-		 - Adapt to changes in the biosparam method specification.
-	
-		Turn runq scheduling into an inline to remove lots of
-		#ifdef clutter.
-	
-	aic7xxx_osm.h:
-		Make register pretty printing and option.
-	
-		Add ahc_midlayer_entrypoint_lock() inlines to help
-		manage the latest Linux mid-layer locking fiasco.
-	
-		ahc_done_lock/unlock are no-ops for 2.5.X.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_host.h#10 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#119 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#88 edit
-
-Change 1392 by gibbs@bitkeeper-linux-2.5 on 2002/09/20 14:47:28
-
-	Config.in:	
-		Bring both the aic7xxx and aic79xx sections of this
-		file up to date in regards to the latest options.
-	aic79xx_host.h:
-		Port to 2.5.X.
-		 - Adapt to "biosparam" driver method specification
-		 - Modify driver template to be 2.5.X compatible
-	
-	aic79xx_osm.c:
-		Port to 2.5.X.
-		 - Include scsicam.h for disk partition functions.
-		 - Switch from strtok to strsep.  Strtok is no longer
-		   available in 2.5.X.	
-		 - Adapt to the removal of the io_request lock and the
-		   mid-layer acquiring our own lock prior to calling us.
-		   This comes in the form of a new inline,
-		   ahd_midlayer_entrypoint_lock().  For 2.5.X, this is
-		   no-op since our lock is already held prior to entry
-		   into the driver.
-		 - Make use of scsi_assign_lock so that we can have our
-		   lock held before we have our host structure.  If we
-		   used the host lock in the host structure, we would
-		   not be able to acquire our lock in our interrupt handler
-		   should a shared interrupt occur before we allocated
-		   our host structure.
-		 - Added comments indicating why it is that we don't do
-		   the same ahd_unlock()/ahd_done_lock() dance in 2.5.X.
-		   Since the done lock and the ahd_lock are one and the
-		   same, it doesn't make sense to release and reacquire
-		   the same lock.  For older kernels, this dance is required
-		   to avoid lock order reversals.
-		 - In our error recovery entry points, move unlock_irq()
-		   calls down to where we sleep so it is more obvious why
-		   they are required.  Add some comments about this too.
-		 - Adapt to changes in the biosparam method specification.
-	
-		Turn runq scheduling into an inline to remove lots of
-		#ifdef clutter.
-	
-	aic79xx_osm.h:
-		Make register pretty printing and option.
-	
-		Add ahd_midlayer_entrypoint_lock() inlines to help
-		manage the latest Linux mid-layer locking fiasco.
-	
-		ahd_done_lock/unlock are no-ops for 2.5.X.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_host.h#7 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#51 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#62 edit
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/Config.in#8 edit
-
-Change 1386 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/09/17 19:10:33
-
-	       Update driver version
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#61 edit
-
-Change 1385 by gibbs@overdrive on 2002/09/17 18:48:09
-
-	aic79xx_osm.c:
-		Correct a case in the aic79xx_rd_strm_info code where
-		it was referencing the tag_info array by mistake.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#50 edit
-
-Change 1380 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/09/16 14:46:03
-
-	Include <inttypes.h> to get uint8_t definitions
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#24 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_macro_scan.l#6 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#17 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#22 edit
-
-Change 1378 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/09/16 12:49:34
-
-	       Update driver version
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#60 edit
-
-Change 1377 by gibbs@aslan on 2002/09/16 12:47:19
-
-	Print out LQOSTAT* registers in ahd_dump_card_state.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#112 edit
-
-Change 1373 by gibbs@aslan on 2002/09/12 12:33:53
-
-	aic79xx.c:
-		Cover the ENBUSFREE case for bus resets too.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#111 edit
-
-Change 1372 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/09/12 11:26:37
-
-	       Update driver version
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#59 edit
-
-Change 1371 by gibbs@aslan on 2002/09/12 11:24:42
-
-	aic79xx.c:
-		With the BUSFREEREV bug in effect, we must
-		muck with the ENBUSFREE toggle if the busfree
-		occurred in a non-pack connection.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#110 edit
-
-Change 1370 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/09/11 18:39:38
-
-	       Update driver version
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#58 edit
-
-Change 1369 by gibbs@overdrive on 2002/09/11 18:38:24
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#31 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#12 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#32 edit
-
-Change 1368 by gibbs@aslan on 2002/09/11 18:37:30
-
-	Implement workaround for broken busfree-rev in the A4.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#109 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#61 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#60 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#44 edit
-
-Change 1364 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/09/11 10:02:19
-
-	       Update driver version
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#57 edit
-
-Change 1363 by gibbs@overdrive on 2002/09/11 10:01:38
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#30 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#11 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#31 edit
-
-Change 1362 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/09/10 19:43:30
-
-	       Update driver version
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#56 edit
-
-Change 1361 by gibbs@aslan on 2002/09/10 18:57:05
-
-	aic79xx.c:
-		Aesthetic changes to the dump_sglist routine.
-		We now indicate that the LAST flag was set in
-		the last SG element.
-	
-	aic79xx_inline.h:
-		Don't use ahd_htole64 on a variable that may not
-		be 64bits wide.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#108 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#36 edit
-
-Change 1360 by gibbs@aslan on 2002/09/10 18:52:55
-
-	aicasm_gram.y:
-		Adjust support for mvi with immediate of 0 to
-		handle the downloaded constant case.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#23 edit
-
-Change 1354 by gibbs@aslan on 2002/09/10 15:09:50
-
-	aic79xx.h:
-		Add two new bug defines that only apply to the A:
-	
-		o AHD_REG_SLOW_SETTLE_BUG
-		  - Some Host registers take a few clocks to settle.
-	
-		o AHD_SET_MODE_BUG
-		  - Interrupts must be disabled when changing the mode
-	
-	aic79xx.reg:
-		Modify SET_MODE and add a new TOGGLE_DFF_MODE macro
-		to optimize out the AHD_SET_MODE_BUG workaround.
-	
-		Make P_BUSFREE a field instead of a member of an
-		enum with a mask that doesn't apply to its bit location.
-	
-	aic79xx.seq:
-		Optimize code based on the two new bug defines.  We
-		also iimplement, for the first time, the SLOW_REG
-		bug workaround.
-	
-		SET_MODE and TOGGLE_DFF_MODE can't have ';'s after
-		them now due to if/else clauses.
-	
-		Correct a ';' -> ':' syntax error.
-	
-	aic79xx_pci.c:
-		Add the two new bug defines to the list of bugs
-		that apply to the A4.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.h#60 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#45 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#59 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#43 edit
-
-Change 1352 by gibbs@aslan on 2002/09/10 14:44:31
-
-	aicasm_gram.y:
-		Allow mvi immediates of zero and have the assembler
-		convert these to the equivalent of a clr instruction.
-		This allows macros that do not know the value of the
-		immediate they are given DTRT.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#22 edit
-
-Change 1349 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/09/09 15:09:57
-
-	       Update driver version
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#55 edit
-
-Change 1347 by gibbs@aslan on 2002/09/09 15:08:20
-
-	aic79xx.seq:
-		In pkt_saveptrs, wait for FIFOEMP before issuing
-		the clearchn.  This seems to be the easiest way
-		to ensure that we don't complete the command to
-		the host prior to all data draining.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#58 edit
-
-Change 1346 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/09/08 17:46:07
-
-	       Update driver version
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#54 edit
-
-Change 1345 by gibbs@overdrive on 2002/09/08 17:41:10
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#29 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#10 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#30 edit
-
-Change 1344 by gibbs@aslan on 2002/09/08 17:40:23
-
-	aic79xx.seq:
-		Correct a comment.
-	
-		In pkt_saveptrs, only clear the saveptrs interrupt
-		status once the pointers are saved.  Otherwise we
-		may allow a cfg4data in the other FIFO to proceed
-		with incorrect data pointers.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#57 edit
-
-Change 1343 by gibbs@aslan on 2002/09/08 17:13:36
-
-	aic79xx.c:
-		Add diagnostic messages for DSPDATACTL workarounds.
-	
-		Negotiate HOLD_MCS for U320 transfers.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#107 edit
-
-Change 1342 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/09/06 17:46:11
-
-	       Update driver version
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#53 edit
-
-Change 1341 by gibbs@overdrive on 2002/09/06 17:45:16
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#28 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#9 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#29 edit
-
-Change 1340 by gibbs@aslan on 2002/09/06 17:44:20
-
-	aic79xx.seq:
-		Fix syntax error.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#56 edit
-
-Change 1339 by gibbs@aslan on 2002/09/06 17:42:26
-
-	aic79xx.seq:
-	aic79xx.reg:
-		Fix SCBPTR corruption during mixed pack/non-pack
-		processing.  When allocating a FIFO, an SCB can
-		complete using MODE3's SCBPTR.  Save the SCBID
-		requesting the allocation into a new scratch ram
-		location that is unused by any other code prior
-		to running any FIFO threads and restore it once
-		allocation is complete.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#44 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#55 edit
-
-Change 1338 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/09/05 22:06:27
-
-	       Update driver version
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#52 edit
-
-Change 1337 by gibbs@overdrive on 2002/09/05 21:48:01
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#27 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#8 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#28 edit
-
-Change 1336 by gibbs@overdrive on 2002/09/05 20:58:55
-
-	aic79xx.c:
-		Restart the sequencer prior to scheduling our
-		reset polling timer.  We want to be sure the
-		sequencer is reset prior to the timer firing.
-	
-		In ahd_reset_poll(), put us in the SCSI mode
-		prior to tweaking registers.
-	
-	aic79xx.reg:
-		Use consistent case in defining register addresses.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#106 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#43 edit
-
-Change 1335 by gibbs@overdrive on 2002/09/05 20:19:00
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#26 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#7 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#27 edit
-
-Change 1334 by gibbs@aslan on 2002/09/05 18:26:26
-
-	aic79xx.h:
-		Give AHD_SHOW_SG it's own value.	
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.h#59 edit
-
-Change 1333 by gibbs@aslan on 2002/09/05 18:25:32
-
-	aic79xx.c:
-		Remove a redundant ahd_update_modes();
-	
-		Only print scb path information in our SELTO handler
-		once we've verified that the SCB is not NULL.
-	
-		Fix formatting nits.
-	
-		Convert transmission error diagnostic code to ahd_reg_print().
-	
-		Correct the comment for ahd_handle_pkt_busfree().  We
-		can enter this routine in any of modes 0, 1 and 3.
-	
-		In ahd_handle_pkt_busfree(), ensure we are in mode 3
-		for dealing with LQOBUSFREE events, save and restore
-		the current SCBPTR in that mode, and use CURRSCB to
-		determine the SCB affected by the busfree rather than
-		the quite bogus SCBPTR.
-	
-		In ahd_abort_scbs(), operate in the SCSI mode so that
-		busy and clear TCL functions use that mode.  It is
-		the only safe mode to use for temporary changes to
-		the SCBPTR register unless you have guaranteed that
-		no SCB fetches are inprogress in which case the command
-		channel mode is safe.
-	
-		Add assertions in the busy_tcl code to ensure we are
-		in the SCSI mode.
-	
-		Save and restore the SCBPTR in ahd_dump_card_state().
-		We were always leaving SCBPTR pointing to the last
-		SCB traversed in our debug output.
-	
-		Use ahd_get_scbptr() in all cases.
-	
-		Cleanup some nits in ahd_dump_cardstate() output.
-	
-		Save and restore the scbptr in ahd_dump_scbs().
-	
-	aic79xx.reg:
-		Remove the SCB_DMA field in SEQ_FLAGS2.  It is not
-		needed for Harpoon's SCB dma fetch abort algorithm.
-	
-	aic79xx.seq:
-		Add a critical section around the SCB dma complete
-		code.  It was possible for the host driver to "abort"
-		this SCB fetch while the sequencer was in the process
-		of handling the completion.  The critical section
-		ensures that the SCB fetch is either aborted, or on
-		the waiting queue once we are outside of the critical
-		section.
-	
-		Complete the removal of the SCB_DMA flag.
-	
-		Fix the PDATA_REINIT case.  We neglected to jump
-		to the dma_loop once the kernel had completed the
-		reinitialization.
-	
-		Fix the non-packetized bitbucket handler.  We were not
-		properly waiting until the data phase was over.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#105 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#42 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#54 edit
-
-Change 1332 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/09/04 23:44:52
-
-	Version 1.0.12
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#51 edit
-
-Change 1331 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/09/04 23:43:46
-
-	Regen aic79xx firmware
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#25 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#6 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#26 edit
-
-Change 1330 by gibbs@aslan on 2002/09/04 18:04:26
-
-	aic79xx.c:
-		Don't call ahd_clear_intstat from our busfree handler.
-		The bus may well have moved on and we don't want to
-		clear state that pertains to the current connection.
-		If we get stray PERR status, it will now be handled
-		by the "catch-all" case in the SCSIINT handler.
-	
-		In ahd_clear_intstat(), deal with the AHD_CLRLQO_AUTOCLR_BUG.
-		This may have been the cause for the really strange
-		problems with mixed pack/non-pack configuratons.
-	
-		When clearing ENSELO in SCSISEQ0, make sure we are
-		in a known and safe mode.
-	
-		Remove "nonpkt_tag" from the "task_attribute_nonpkt_tag"
-		HSCB field.  We no longer need nonpkt_tag information
-		in the SCB.
-	
-		Another update from Gordon for the bus reset quiet
-		the controller algorithm.
-	
-		Print the current byte on the bus in ahd_dump_card_state().
-	
-		Remove spurious ','s from the printing of the pending list.
-	
-		Include SCB_TAG in pending list dumps.
-	
-	aic79xx.h:
-		Put SCB_TAG on a 4 byte boundary just to be paranoid.
-	
-		task_attribute_nonpkt_tag -> task_attribute
-	
-	aic79xx.reg:
-		Put SCB_TAG on a 4 byte boundary just to be paranoid.
-	
-	aic79xx.seq:
-		Remove extra AHD_MDFF_WSCBPTR_BUG code.  The failure
-		can never occur since, in the A, only the non-pack
-		FIFO can ever be active during non-pack processing.
-	
-		Clear the busfree status when entering non-pack processing
-		so we can rely on it in await_busfree.
-	
-	aic79xx_inline.h:
-		Remove what is hopefully the last chunk of untagged queue
-		code from the driver.
-	
-		Don't bother setting the nonpack_tag since it is always
-		the same as the low byte of SCBPTR.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#104 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#58 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#41 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#53 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#35 edit
-
-Change 1328 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/09/03 17:30:10
-
-	Version 1.0.11
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#50 edit
-
-Change 1327 by gibbs@overdrive on 2002/09/03 17:21:56
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#24 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#5 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#25 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#17 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg_print.c#4 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#18 edit
-
-Change 1326 by gibbs@aslan on 2002/09/03 17:20:25
-
-	Remove a spuriously expanded $FreeBSD$.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_macro_scan.l#5 edit
-
-Change 1325 by gibbs@aslan on 2002/09/03 17:14:43
-
-	aic79xx.c:
-		Add a missing space in the pending list
-		debug output code.
-	
-	aic79xx.h:
-		Add AHD_MDFF_WSCBPTR_BUG.
-	
-	aic79xx.reg:
-		Reserve mode specific scratch location
-		REG2 for interrupt handler use only.
-		This avoids any potential races between
-		normal and interrupt contexts.
-	
-		Put target mode bits after initiator bits
-		so that the initiator mode ones are printed
-		during diagnostics.  We don't currently
-		support target mode.
-	
-	aic79xx.seq:
-		Add duplicate writes to SCBPTR when in modes
-		0 and 1.
-	
-		Switch one section of ISR code over to using
-		REG_ISR.
-	
-		Perform clear target state after releasing the
-		FIFO so the FIFO is free as soon as possible.
-	
-	aic79xx_pci.c:
-		Turn on AHD_MDFF_WSCBPTR_BUG.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#103 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#57 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#40 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#52 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#42 edit
-
-Change 1323 by gibbs@aslan on 2002/08/30 23:06:40
-
-	Strip back down to $FreeBSD$.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#25 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#78 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#51 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#34 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#17 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#12 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#38 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#50 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/ahc_eisa.c#8 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/ahc_pci.c#8 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#22 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.c#10 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.h#10 edit
-
-Change 1322 by gibbs@aslan on 2002/08/30 23:06:24
-
-	aic7xxx.seq:
-		Correct a bug in target mode handling of non-disconnected
-		transactions.  The host would indicate the correct SCB to
-		DMA by setting the SCB id in the currently selected hardware 
-		SCB.  Unfortunately, we would then immediated allocate a
-		hardware SCB which, depending on the access patern might not
-		be the same hardware SCB that the host setup for us.  Avoid
-		this by having the host put the SCBID into scratch ram.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#50 edit
-
-Change 1321 by gibbs@aslan on 2002/08/30 23:00:30
-
-	Strip back down to $FreeBSD$
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#22 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.h#14 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#21 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_macro_gram.y#5 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#16 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#21 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#17 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aicasm/Makefile#1 add
-
-Change 1320 by gibbs@aslan on 2002/08/30 20:47:28
-
-	Expands revision tags.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#21 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.h#13 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#20 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_insformat.h#10 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_macro_gram.y#4 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_macro_scan.l#4 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#15 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#20 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#16 edit
-
-Change 1317 by gibbs@aslan on 2002/08/30 20:18:37
-
-	aic7xxx.c:
-		Make use of ahc_print_devinfo in the non-AHC_DEBUG case
-		to quiet GCC.  We'll be adding more non-debug uses later
-		anyway.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#77 edit
-
-Change 1316 by gibbs@aslan on 2002/08/30 17:37:39
-
-	Expand Ids.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#24 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.c#102 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#56 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#39 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#51 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#34 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#41 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#76 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#50 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#33 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#49 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#16 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#11 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#37 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#49 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/ahc_eisa.c#6 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/ahc_pci.c#6 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/ahd_pci.c#6 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#21 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.h#13 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.c#9 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.h#8 edit
-
-Change 1313 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/08/29 16:44:35
-
-	Version 1.0.10
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#49 edit
-
-Change 1312 by gibbs@overdrive on 2002/08/29 16:17:01
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#23 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#4 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#24 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#16 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg_print.c#3 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#17 edit
-
-Change 1311 by gibbs@aslan on 2002/08/29 16:08:39
-
-	aic79xx.c:
-		Correct negotiation regression in 1.0.9.  We need to
-		cancel the negotiations for any unstarted SCBs to avoid
-		the "AWAITING MSG with no waiting message" assertion.
-		In the packetized world, it is safe to cancel negotiations
-		so long as we are active on the bus preventing the execution
-		queue from being run.  Restore ahd_update_pending_scbs() to
-		update SCBs on the controller and have all callers only call
-		it for negotiation changes when the transaction is active.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#101 edit
-
-Change 1310 by gibbs@aslan on 2002/08/29 14:34:09
-
-	aic79xx.c:
-	aic7xxx.c:
-		Print pathing information with some diagnostics.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#100 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#75 edit
-
-Change 1309 by gibbs@aslan on 2002/08/29 14:01:21
-
-	aic7xxx.c:
-	aic7xxx.h:
-		Add support for AHC_SHOW_MESSAGES.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#74 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#49 edit
-
-Change 1308 by gibbs@aslan on 2002/08/29 14:00:48
-
-	aicasm.c:
-	aicasm.h:
-	aicasm_gram.y:
-	aicasm_scan.l:
-	aicasm_symbol.h:
-		Update copyrights.
-	
-	aicasm_symbol.c:
-		Update cpyright.
-	
-		Allow print reg functions for registers with
-		no fields.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#20 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.h#12 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#19 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#14 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#19 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#15 edit
-
-Change 1307 by gibbs@aslan on 2002/08/29 13:57:31
-
-	Update copyrights.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#50 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#33 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#40 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#20 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.h#11 edit
-
-Change 1306 by gibbs@aslan on 2002/08/29 13:56:41
-
-	aic79xx.c:
-		Use ahd_print_path() for selection timeout messages.
-	
-		Clear all interrupt sources, via ahd_clear_intstat(),
-		if we get an expected or unexpected busfree.  It turns
-		out that the hardware clears some of them, but not all
-		of them when a busfree occurs which can confuse our SCSIINT
-		handler down the road.
-	
-		Update ahd_clear_intstat() to clear LQO/LQI type interrupts.
-	
-		Remove duplicate phase printing in the AHD_SHOW_MESSAGES
-		code.
-	
-		Update ahd_dump_card_state to use more of the "reg print"
-		functions.
-	
-		Conditionalize SG list printing under AHD_SHOW_SG.
-	
-	aic79xx.h:
-		Add AHD_SHOW_SG.
-	
-	aic79xx.reg:
-		Add several changes for Rev. B.  These still need
-		to be verified.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#99 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#55 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#38 edit
-
-Change 1305 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/08/29 10:27:03
-
-	limit per-drive tags to 32
-
-Affected files ...
-
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/Config.in#7 edit
-
-Change 1304 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/08/29 10:26:10
-
-	Sync up with the linux-aic79xx-2.4.18_rc4 version of this in order to 
-	get the new aic79xx_reg_print.o dependency.
-
-Affected files ...
-
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/Makefile#5 integrate
-
-Change 1302 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/08/28 10:55:57
-
-	Version 1.0.9
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#48 edit
-
-Change 1301 by gibbs@overdrive on 2002/08/27 16:50:51
-
-	Regen Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#22 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#3 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#23 edit
-
-Change 1300 by gibbs@aslan on 2002/08/27 16:49:33
-
-	aic79xx.c:
-		Print out both bytes of SINDEX in a diagnostic.
-	
-		Remove redundant pausing of the sequencer prior
-		to calls to ahd_update_pending_scbs().  It performs
-		its own pause management.
-	
-		In ahd_update_pending_scbs(), don't mess with SCBs
-		already DMA'ed down to the card.  Fields in the
-		SCB control byte are referenced by the select out
-		code to determine queue state, so it is best to
-		leave them alone.  The U320 cards don't embed
-		negotiation information in the SCBs anyway, so
-		the update was of little use.
-	
-		Protect against freezing the SIM Q multiple times
-		should a second bus reset be initiate prior to the
-		completed processing of a previous bus reset event.
-	
-		Print out some additional registers in ahd_dump_card_state().
-	
-		Don't rely on the flexport seeprom type detection to
-		determine if an seeprom is present.  The logic is not
-		present on all board types (e.g. mule boards).
-	
-	aic79xx.h:
-		Add bit for AHD_RESET_POLL_ACTIVE.
-	
-	aic79xx.seq:
-		Correct a few comments about how the sequencer operates.
-	
-		Always clear SG_STATE in disable_ccsgen.  Leaving stale
-		info in there was confusing the non-packetized path.
-	
-		Inline the effect of a call to disable_ccsgen in the
-		S/G fetch code path.
-	
-	aic79xx_pci.c:
-		If bootverbose, indicate STPWLEVEL.
-	
-	aic79xx_osm.c:
-		Properly drop to a sync rate that does not require
-		information unit transfers if tagged queuing or the
-		disconnect privledge are not available.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#98 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#54 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#49 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#39 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#19 edit
-
-Change 1296 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/08/22 17:40:40
-
-	1.0.8
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#47 edit
-
-Change 1295 by gibbs@overdrive on 2002/08/22 17:35:03
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#21 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#2 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#22 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#15 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg_print.c#2 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#16 edit
-
-Change 1293 by gibbs@aslan on 2002/08/22 15:14:44
-
-	aic79xx.c
-		Style nits.
-	
-		Print out REG0 in the NO_MATCH case.  It is more
-		interesting than ARG_1.
-	
-		Use AHD_NUM_LUNS_NONPKT for loops over the busy
-		target table.  Packetized luns don't use the table.
-	
-		Use BUILD_TCL_RAW rather than rolling our own in
-		combination with BUILD_TCL in a few places.
-	
-	aic79xx.h:
-		Allow TCLs to store all lun bits.
-	
-		Lower bus reset hold time to 25us.
-	
-	aic79xx.seq:
-		Correct grammer in a comment.
-	
-		Simplify busy table operatins in mesgin_identify.
-	
-		Remove a commented-out diagnostic.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#97 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#53 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#48 edit
-
-Change 1292 by gibbs@aslan on 2002/08/22 15:10:03
-
-	aic7xxx.h:
-		Drop reset hold duration to 25us.
-	
-	aic7xxx.seq:
-		Correct the grammer in a comment.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#48 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#48 edit
-
-Change 1291 by gibbs@aslan on 2002/08/22 14:04:12
-
-	aicasm_symbol.c:
-	aicasm_symbol.h:
-		Fix symbol sorting logic.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#18 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#14 edit
-
-Change 1289 by gibbs@aslan on 2002/08/21 18:45:16
-
-	aic79xx.c:
-	aic7xxx.c:
-		Handle field values that can be 0 in ahd_print_register().
-		The code would get into an infinite loop before.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#96 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#73 edit
-
-Change 1288 by gibbs@aslan on 2002/08/21 16:30:00
-
-	aic79xx.reg:
-		Remove unused SEQINTCODEs.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#37 edit
-
-Change 1287 by gibbs@aslan on 2002/08/21 16:29:36
-
-	aic79xx.c:
-		It turns out that we can single step even if a
-		SCSIINT is pending.  Remove clearing/restoring of
-		SCSIINT interrupt enables.  This fixes an issue
-		with busfree detection getting turned off without
-		the possibility of re-enabling it.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#95 edit
-
-Change 1286 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/08/20 18:32:08
-
-	Update to 1.0.7, add required makefile changes
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#46 edit
-... //depot/linux_mod_devel/scsi.aic79xx/Makefile#2 edit
-
-Change 1285 by gibbs@aslan on 2002/08/20 18:30:47
-
-	aic79xx.c:
-		Implement the latest bus reset card shutdown procedure.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#94 edit
-
-Change 1282 by gibbs@overdrive on 2002/08/20 17:18:57
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#45 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#20 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg_print.c#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#21 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#87 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#14 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg_print.c#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#15 edit
-
-Change 1280 by gibbs@aslan on 2002/08/20 14:15:29
-
-	aic79xx.seq:
-		Add a PREFIX for ahd generated definitions.
-	
-		Clean up more code related to the now defunct
-		disconnected lists.
-	
-		Use *stable* references to the current scsiid
-		and lun (SAVED_SCSIID/SAVED_LUN) for indexing
-		into the busy targets table.  We were referring
-		to the possibly uninitialzied SCB_LUN of the
-		SCB we had indexed into.  Bad.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#47 edit
-
-Change 1279 by gibbs@aslan on 2002/08/20 14:13:20
-
-	aic7xxx.c:
-	aic7xxx.h:
-		Fix a few typos.
-	
-		Implement ahc_print_register.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#72 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#47 edit
-
-Change 1278 by gibbs@aslan on 2002/08/20 14:12:23
-
-	aic79xx.c:
-	aic79xx.h:
-		More work on the ahd_print_register routine.
-	
-		Use the pretty print register routines in a few places.
-	
-		Fix a few typos.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#93 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#52 edit
-
-Change 1277 by gibbs@aslan on 2002/08/20 14:10:38
-
-	aic7xxx.seq:
-		Add a PREFIX designator for use in making assembler
-		generated definitions, unique.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#47 edit
-
-Change 1276 by gibbs@aslan on 2002/08/20 14:09:03
-
-	aic79xx.reg:
-	aic7xxx.reg:
-		Adapt to new assembler syntax.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#36 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#32 edit
-
-Change 1275 by gibbs@aslan on 2002/08/20 14:06:35
-
-	aicasm.c:
-	aicasm_gram.y:
-	aicasm_scan.l:
-	aicasm_symbol.c:
-	aicasm_symbol.h:
-		Add support for generating register field tables for
-		use in pretty-printing register values.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#19 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#18 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#13 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#17 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#13 edit
-
-Change 1272 by gibbs@overdrive on 2002/08/14 14:16:46
-
-	aic79xx_osm_pci.c:
-		Move warning about failures to memory map our controller
-		under bootverbose.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#12 edit
-
-Change 1271 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/08/14 08:02:15
-
-	Version 1.0.6
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#44 edit
-
-Change 1270 by gibbs@overdrive on 2002/08/13 16:02:05
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Use MSG_EXT_PPR_QAS_REQ rather than SID_SPI_QAS
-		when dealing with PPR options.  The latter is used
-		when looking at inquiry information.  Ooops.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#49 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#118 edit
-
-Change 1269 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/08/09 13:09:26
-
-	veriosn 1.0.5
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#43 edit
-
-Change 1264 by gibbs@aslan on 2002/08/08 15:19:58
-
-	aic79xx.c:
-		Use CAM_SEQUENCE_FAIL for protocol violations.
-	
-		Add first cut at a register printing function.
-	
-		Use better markers for the beginning and end
-		of ahd_dump_card_state.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#92 edit
-
-Change 1263 by gibbs@aslan on 2002/08/08 15:18:52
-
-	aicasm.c:
-	aicasm.h:
-	aicasm_gram.y:
-	aicasm_scan.l:
-	aicasm_symbol.c:
-	aicasm_symbol.h:
-		First cut at outputing register printing tables.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#18 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.h#11 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#17 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#12 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#16 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#12 edit
-
-Change 1262 by gibbs@overdrive on 2002/08/08 14:21:43
-
-	cam.h:
-		Add a mapping for CAM_SEQUENCE_FAIL.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/cam.h#13 edit
-
-Change 1261 by gibbs@overdrive on 2002/08/08 10:56:31
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		If QAS is not supported by a target, be sure to clear
-		the QAS flag in the ppr_options.  Otherwise we may
-		attempt a PPR on a device that does not support it.
-	
-		Use prot_version rather than the protocol version in
-		the tstate as the latter is not initialized until later
-		in the routine and will be 0 the first time an inquiry
-		is sent to a device.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#48 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#117 edit
-
-Change 1259 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/08/07 09:36:00
-
-	Version 1.0.4
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#42 edit
-
-Change 1258 by gibbs@aslan on 2002/08/06 16:58:52
-
-	aic79xx.c:
-		Move expected bus free handling code to ahd_set_syncrate()
-		so that it will work for message types other than PPR.
-	
-		Test for expected bus frees if the last phase was either
-		MESGIN or MESGOUT.  SPI4 dictates that the bus free will
-		occur once message phases are over, so we must handle the
-		case of other messages occuring prior to the bus going free.
-		We filter out other causes for the bus free (abort tag, etc.)
-		prior to treating this as an expected busfree.
-	
-		Wait a bus reset delay prior to performing the chip reset
-		for outgoing bus resets *just in case* this helps with the
-		stray arb issue.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#91 edit
-
-Change 1250 by gibbs@overdrive on 2002/08/05 14:23:13
-
-	aic7xxx_osm.c:
-	aic79xx_osm.c:
-		Fix off-by-one errors in calculations using the inquiry
-		data's additional_length field.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#47 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#116 edit
-
-Change 1248 by gibbs@overdrive on 2002/08/03 12:26:50
-
-	aic7xxx_proc.c:
-		Explicitly test for VLB and PCI cards in seeprom_write()
-		so we don't try this on EISA cards.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#22 edit
-
-Change 1246 by gibbs@overdrive on 2002/08/03 12:06:45
-
-	aic7xxx_proc.c:
-		AHC_PCI_CONFIG is always defined.  Test for > 0 instead.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#21 edit
-
-Change 1244 by gibbs@overdrive on 2002/08/03 12:01:55
-
-	aic7xxx_osm.c:
-		ahc_pause_and_flush_work() -> ahc_pause_and_flushwork().
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#115 edit
-
-Change 1243 by gibbs@overdrive on 2002/08/03 11:57:55
-
-	aic7xxx_proc.c:
-		Allow this to compile if PCI support is not
-		configured into the system.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#20 edit
-
-Change 1242 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/08/02 19:43:45
-
-	Version 1.0.3
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#41 edit
-
-Change 1240 by gibbs@aslan on 2002/08/02 17:47:26
-
-	aic79xx.c:
-		Force scb to be NULL if we have not been fully identified
-		in ahd_handle_protocol_violation().
-	
-		Use MSG_ABORT_TASK for invalid reselections as per the
-		SPI4 spec.
-	
-		Push the waiting for the bus transceivers to setting into
-		ahc_chip_init().  This makes the wait occur for bus reset
-		operations too.  Perform this wait prior to setting up
-		any of our iocell workarounds just in case the chip clobbers
-		them when the bus settles.
-	
-		Don't rely on the chip remaining paused while we wait for
-		the bus reset line to fall.  We simply perform most of
-		the reconfiguration of the chip prior to starting to poll
-		for the reset line to fall.
-	
-		Fix a bug in ahd_reset_poll() in the case of the reset
-		line not falling.  We would not exit the function to wait
-		again for the reset line to fall.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#90 edit
-
-Change 1228 by gibbs@overdrive on 2002/07/31 16:33:59
-
-	aic79xx_osm.c:
-	aic79xx_osm.h:
-	aic7xxx_osm.c:
-	aic7xxx_osm.h:
-	cam.h:
-		Emulate CAM_REQUEUE_REQ by returning check condition
-		status with the ABORTED COMMAND sense key.  This works
-		even if we happen to be requesting an error recovery
-		command to be unconditionally requeued.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#46 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#40 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#114 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#86 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/cam.h#12 edit
-
-Change 1227 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/07/31 12:12:00
-
-	version 1.0.2
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#39 edit
-
-Change 1226 by gibbs@overdrive on 2002/07/30 17:12:07
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#19 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#20 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#13 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#14 edit
-
-Change 1225 by gibbs@aslan on 2002/07/30 17:10:40
-
-	aic79xx.c:
-		When a selection timout occurs, we need not play with
-		ENBUSFREE.  The busfree interrupt is a pulse so simply
-		clearing that interrupt source is sufficient.
-	
-		Fixup some curly braces.
-	
-		LASTPHASE -> PREVPHASE.  LASTPHASE is a register
-		in scratch ram and not the bit in the PERRDIAG register
-		that indicates if the error has occurred before the
-		current phase.
-	
-		When setting the SCSI reset line, clear ENSELO and
-		ENARBO just in case they are set.  We don't want the
-		chip to decide it need to perform a select out as
-		soon as the reset is over.
-	
-		Add a line of '='s prior to dumping card state.  It
-		makes traces easier to follow.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#89 edit
-
-Change 1224 by gibbs@aslan on 2002/07/29 17:06:54
-
-	aic79xx.c:
-		When auto-sense fails due to non-0 scsi status,
-		we still need to release the selection queue.
-		Rearrange the code so that we do this step prior
-		to checking to see if this was an auto-sense
-		command.
-	
-	aic79xx.seq:
-		Be more careful about detection of protocol violations
-		flagged on command complete messages.  The command complete
-		is valid even if the CDB was never fully sent if the
-		target has given us non-zero status.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#88 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#46 edit
-
-Change 1223 by gibbs@aslan on 2002/07/29 12:00:22
-
-	aic79xx.c:
-		Move handler for protocol violations to its own funciton.
-		Make another attempt to handle protocol violations that
-		occur before we have a fully identified connection.
-	
-		Add ahd_print_devinfo() to simplify diagnostics for
-		scenarios without a fully identified connection.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#87 edit
-
-Change 1221 by gibbs@overdrive on 2002/07/26 13:54:57
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		When we get a QUEUE_FULL with only the transaction
-		returning QUEUE FULL outstanding, tell Linux that
-		the transaction received BUSY status.  Linux doesn't
-		understand how to deal with QUEUE FULL correctly in
-		this situation and will leave the device frozen forever.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#45 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#113 edit
-
-Change 1217 by gibbs@overdrive on 2002/07/25 13:35:10
-
-	aic7xxx_osm.c:
-		Rely on ahc_pause_and_flushwork() instead of rolling our own.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#112 edit
-
-Change 1216 by gibbs@aslan on 2002/07/25 13:34:21
-
-	aic7770.c:
-		Remove an unused variable.
-	
-	aic7xxx.c:
-		Mask qoutfifonext in printf to avoid promotion
-		issues when printing its value.
-	
-		When we experience a dual edge error, send an
-		initiator detected error message regardless of
-		data direction.  This is an error we can detect
-		either way.
-	
-		Cast the return from malloc.
-	
-		Use the SCSI offset as an indication that we have
-		a sync negotiation setup, not the period.
-	
-		In ahc_fetch_devinfo(), test for a few more bits
-		in SEQ_FLAGS to determine if we are acting as a
-		target that has been selected.  Depending on how
-		far we are along in the transaction one or all
-		of them may be set.
-	
-		Align our S/G data structures on an 8byte boundary.
-		This already was occuring by luck, but using the
-		correct parameter to bus_dma_tag_create formalizes
-		this requirement.
-	
-		Guard against pending (re)selections in
-		ahc_pause_and_flushwork().
-	
-		If SEARCH_REMOVE removes an SCB from an untagged queue,
-		clear its SCB_UNTAGGEDQ flag.
-	
-		When enabling a lun for target mode on a controller without
-		MULTARGID support, complain when an attempt is made to
-		enable another ID.
-	
-	aic7xxx.h:
-		Remove external declaration of the syncrate table.  It
-		is no longer accessed directly by the OSM.
-	
-	aic7xxx.reg:
-		Add a definition for SXFRCTL2.  This is just to serve
-		as documentation since we don't currently use this
-		register.
-	
-		Alias MWI_RESIDUAL with TARG_IMMEDIATE_SCB.  This new
-		field is used for a more robust immediate target mode
-		SCB delivery scheme.
-	
-	aic7xxx.seq:
-		Adapt to TARG_IMMEDIATE_SCB scheme.
-	
-		Correct a problem with immediate target mode SCBs on
-		controllers without a command channel.  We neglected
-		to CLRCHN before continuing the connection.
-	
-		Grammer nits.
-	
-	aic7xxx_pci.c:
-		Remove an unused variables.
-	
-		Simplify the code to read the SCB2 data.
-	
-		When checking termination on 785X cards, force
-		the wide termination to be off since these chips
-		do not support wide SCSI.
-	
-	aic7xxx_osm.c:
-		Use offset not period for sync rate negotiation decissions.
-	
-		Adapt to TARG_IMMDEDIATE_SCB scheme.
-	
-		Properly cast our softc in ahc_poll().
-	
-		Remove test for P_BUSFREE when trying to determine if
-		an active SCB is valid.  The SCB may be valid long
-		before we see the first phase.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#23 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#71 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#46 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#31 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#46 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#48 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.c#8 edit
-
-Change 1209 by gibbs@overdrive on 2002/07/24 16:53:31
-
-	aic79xx_osm.c:
-		Remove one last multi-line string constant.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#44 edit
-
-Change 1208 by scottl@scottl-hobbiton-mod_devel_aic7xxx on 2002/07/24 16:00:02
-
-	Fix compiliation errors
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#111 edit
-
-Change 1207 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/07/24 15:57:30
-
-	remove hard printf's
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#38 edit
-
-Change 1206 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/07/24 14:17:12
-
-	Driver is now at version 1.0.1
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#38 edit
-
-Change 1205 by gibbs@overdrive on 2002/07/24 14:09:02
-
-	aic79xx_osm.c:
-		Allow MODULE_LICENSE to work on 7.2AS.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#43 edit
-
-Change 1203 by scottl@scottl-linux-ia64 on 2002/07/23 11:18:20
-
-	Clear any bogus bus reset flags while the transceivers are settling
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#86 edit
-
-Change 1202 by scottl@scottl-linux-ia64 on 2002/07/22 19:10:49
-
-	Move the debugging printf in ahd_alloc to the end, avoiding a junk
-	pointer reference.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#85 edit
-
-Change 1201 by gibbs@aslan on 2002/07/22 17:53:37
-
-	aic7xxx_inline.h:
-		If chip interrupts are disabled, just return from our
-		interupt handler.  In these cases, the interrupts are
-		likely disabled because we don't want any entry into
-		our interrupt handler, even those caused by a shared
-		interrupt handler.
-	
-	aic7770.c:
-	aic7xxx_pci.c:
-	aic7xxx_osm.c:
-		Allow the OSM to decide when to initially enable interrups.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#22 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#36 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#47 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.c#7 edit
-
-Change 1200 by gibbs@overdrive on 2002/07/22 17:51:33
-
-	aic7xxx_osm.c:
-		Allow the OSM to decide when to initially enable
-		interrupts.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#110 edit
-
-Change 1199 by gibbs@overdrive on 2002/07/22 17:46:04
-
-	aic79xx_osm.c:
-		Add a missing \n"
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#42 edit
-
-Change 1198 by gibbs@aslan on 2002/07/22 17:40:37
-
-	aic79xx_inline.h
-		If interrupts are not enabled, just return
-		from the interrupt handler.  Interrupts are
-		usually disabled on the chip when we *don't*
-		want our interrupt handler entered which can
-		happen if the interrupt is shared.
-	
-	aic79xx_pci.c:
-	aic79xx_osm.c:
-		Let the OSM decide when to initially enable interrupts.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#32 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#37 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#18 edit
-
-Change 1197 by gibbs@overdrive on 2002/07/22 17:38:44
-
-	aic79xx_osm.c:
-		Use explicit newlines in multi-line string constants to
-		quiet GCC.
-	
-		Let the OSM enable interrupts once it is ready to
-		receive them.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#41 edit
-
-Change 1196 by gibbs@aslan on 2002/07/22 16:39:46
-
-	aic79xx.c:
-		Don't mask off the OVERRUN bit in sstat0 since
-		we do enable it.
-	
-		Assert that we are in a know mode other than MODE_CFG
-		when calling clear_intstat.
-	
-		To simplify logic, set the collision index in all
-		SCBs of a collision chain.
-	
-		AHD_BUILD_SCB_COL_IDX -> AHD_GET_SCB_COL_IDX
-	
-		CLRSCSIINT immediately after clearing any NTRAMPERRs
-		that occur during ahd_chip_init().
-	
-	aic79xx.h:
-	aic79xx_inline.h:
-		Move COL_IDX macros to aic79xx.h.
-	
-		Optimize collision chain head table for multiple
-		targets, not multiple luns.  The chain heads should
-		fit in 1 or 2 cache lines instead of an almost guaranteed
-		1 per target.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#84 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#51 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#31 edit
-
-Change 1195 by gibbs@overdrive on 2002/07/22 11:00:46
-
-	aicasm_gram.y:
-		Remove an extranious break;
-	
-		The syntax for a C label is: identifier ':' statement
-		label: } is not valid syntax even though GCC has allowed
-		it for years.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#16 edit
-
-Change 1194 by gibbs@overdrive on 2002/07/22 10:57:44
-
-	aic7xxx_osm.c:
-		Quiet GCC 3.X warnings by using explicit newlines in
-		long string constants.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#109 edit
-
-Change 1192 by gibbs@overdrive on 2002/07/19 19:51:02
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#18 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#19 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#12 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#13 edit
-
-Change 1191 by gibbs@overdrive on 2002/07/19 19:50:13
-
-	aic79xx_osm.c:
-		Remove references to the untagged queues.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#40 edit
-
-Change 1190 by gibbs@aslan on 2002/07/19 19:48:44
-
-	aic79xx.c:
-		Remove untagged queue support code.
-	
-		Set SCB_ACTIVE when it is allocated rather than
-		let the OSM set it some time later.  This closes
-		a race condition with collision list code that looks
-		for the active flag.
-	
-	aic79xx.h:
-		Move untagged queue cleanup.
-	
-	aic79xx.seq:
-		Remove the last reference to the SCB_NONPACKET_TAG
-		field.  This field will be removed shortly.
-	
-	aic79xx_osm.c:
-		Remove untagged queue support code.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#83 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#50 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#45 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#17 edit
-
-Change 1189 by gibbs@aslan on 2002/07/19 19:18:20
-
-	aic79xx.c:
-		Pause the sequencer prior to updating the negotiation
-		tables if "paused" is false.
-	
-		Add the collision scb to the collision list, not
-		the just allocated scb, in ahd_get_scb().
-	
-		Use the correct collision index when adding a just freed
-		scb back into a collision list.
-	
-	aic79xx.seq:
-		Simplify the mesgin_identify path now that we will
-		never have full disconnection lists.  This also removes
-		a bug where we could select the wrong SCB as the
-		valid SCB for the connection.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#82 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#44 edit
-
-Change 1187 by gibbs@overdrive on 2002/07/19 17:27:05
-
-	aic79xx_osm.c:
-		Correct typo: simple_strltoul -> simple_strtoul.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#39 edit
-
-Change 1186 by gibbs@overdrive on 2002/07/19 17:19:45
-
-	Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#17 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#18 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#11 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#12 edit
-
-Change 1185 by gibbs@overdrive on 2002/07/19 17:19:24
-
-	aic7xxx.seq:
-		Revert attempt to improve stuck PCI retry workaround
-		code.  This was only generated as a test and should
-		never have been committed in the first place.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#45 edit
-
-Change 1184 by gibbs@overdrive on 2002/07/19 17:14:13
-
-	aic79xx_osm.c:
-		Get a collision index prior to getting an SCB to use.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#38 edit
-
-Change 1183 by gibbs@aslan on 2002/07/19 17:04:52
-
-	aic79xx.c:
-		Add string for the aic7901A.
-	
-		Implement new SCB free list management so that
-		all 512 scbs can be used in non-packetized
-		environments.
-	
-		Implement new command completion mechanism that
-		uses a toggling bit 15 to indicate that a new
-		entry has arrived.  This avoids the kludgy writes
-		to the qoutfifo that may not work on processors
-		with certain types of cache retirement policies.
-	
-		Print out data structure sizes if AHD_DEBUG and
-		AHD_SHOW_MEMORY.
-	
-		Allocate the "sentinal" hardware SCB used for
-		queuing commands to the card separately so
-		that one of the 512 valid SCBs is not consumed
-		for this function.
-	
-		Add a space so we report "Wide Channel" instead of
-		"WideChannel".
-	
-		Cleanup allocation of the shared data area so that
-		the qoutfifo is always first.
-	
-		Add a fix for the RevA packetized Lun bug.  The driver
-		will now setup a full 8byte lun in the previously
-		"spare" portion of the SCB and the SCB transfer size
-		is incremented if the bug is present.  This required a
-		change in the layout of the disconnected SCB table to
-		make room for the larger lun field.
-	
-	aic79xx.h:
-		Add constants for the new qoutfifo scheme.
-	
-		Bump AHD_MAX_QUEUE up to 512 now that we have removed
-		all of the issues that previously restricted it to
-		a much lower value.
-	
-		Add a chip entry for the 7901A.
-	
-		Add the pkt_long_lun field to the hardware scb.
-	
-		SCB and ahc_softc updates for our new free scb
-		management algorithm.
-	
-		Stop inlining ahd_get_scb() and ahd_free_scb().
-		The get routine also take a collision index so
-		as t make an optimum choice in which free SCB to
-		pick.
-	
-	aic79xx.reg:
-		Add QOUTFIFO_ENTRY_VALID_TAG which is or'd into the
-		top byte of each completed SCB's tag id to effect
-		the new completion scheme.
-	
-		Define the SCB_PKT_LUN field and new SCB transfer
-		sizes required to use this field..
-	
-	aic79xx.seq:
-		Implement the new command completion scheme.
-	
-		Effect disconnected SCB table format change.
-	
-	aic79xx_inline.h:
-		When queuing a packetized SCB, update pkt_long_lun
-		in case we need it for the PKT_LUN workaround.
-	
-		Uninline ahd_get_scb() && ahd_free_scb().
-	
-		Adjust for the change from storing an SCB to an HSCB
-		as the next "SCB" in the softc.
-	
-		Update for changes in the command completion scheme.
-	
-	aic79xx_pci.c:
-		Fix a few issues with detecting the 7901A.
-	
-	aic79xx_osm.c:
-		Determine the type of transaction prior and the
-		necessary collision index prior to allocating
-		an SCB.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#81 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#49 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#35 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#43 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#30 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#36 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#16 edit
-
-Change 1182 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/07/19 16:34:50
-
-	Add the global_tag_depth variable to the aic79xx driver
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#37 edit
-
-Change 1181 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/07/19 13:45:22
-
-	Update PCI tables for the 29320 and 7901 variants.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.h#48 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#35 edit
-
-Change 1180 by gibbs@aslan on 2002/07/18 17:08:50
-
-	aic79xx_pci.c:
-		Remove A3 support.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#34 edit
-
-Change 1179 by scottl@scottl-hobbiton-mod_devel_aic7xxx on 2002/07/18 15:46:45
-
-	Version 6.2.9:
-		Add new command-line argument global_tag_depth:<int>, which
-		allows you to set the tag depth for every target on every
-		channel.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#108 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#85 edit
-
-Change 1172 by gibbs@overdrive on 2002/06/12 12:32:49
-
-	aic7xxx_osm.c:
-		Define use MODULE_LICENSE should it be defined instead
-		of testing against a specific kernel version.  This
-		should allow 7.2AS driver diskettes to work.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#107 edit
-
-Change 1171 by gibbs@overdrive on 2002/06/06 17:40:00
-
-	aic79xx_osm.h:
-		Try two.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#37 edit
-
-Change 1170 by gibbs@overdrive on 2002/06/06 17:38:12
-
-	aic79xx_osm.h:
-		Convert to using AHD_DEBUG_OPTS.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#36 edit
-
-Change 1166 by gibbs@aslan on 2002/06/06 10:18:11
-
-	Cleanup AHD_DEBUG.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#80 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#47 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#29 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#33 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#14 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.h#8 edit
-
-Change 1164 by gibbs@aslan on 2002/06/06 10:05:23
-
-	aicasm_symbol.c:
-		Remove another multi-line string literal.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#15 edit
-
-Change 1163 by gibbs@aslan on 2002/06/05 16:49:30
-
-	aicasm.c:
-		Remove wrapping strings.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#17 edit
-
-Change 1159 by gibbs@bitkeeper-linux-2.4 on 2002/05/30 23:23:01
-
-	Config.in:
-	Makefile:
-		Cleanup our config data and makefiles.
-
-Affected files ...
-
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/Config.in#6 edit
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/Makefile#4 edit
-
-Change 1157 by gibbs@overdrive on 2002/05/30 22:15:02
-
-	aic79xx_osm.h:
-		Bump to version 1.0.0.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#35 edit
-
-Change 1156 by gibbs@overdrive on 2002/05/30 22:14:09
-
-	aic79xx_inline.h:
-		Rearrange code to setup hscb->dataptr so our operations
-		are not truncated to 32bits.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#28 edit
-
-Change 1154 by gibbs@aslan on 2002/05/30 21:53:39
-
-	aic79xx_inline.h:
-		Include the top 7 bits of address when setting up
-		hscb->dataptr for the 39BIT addressing mode.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#27 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#44 edit
-
-Change 1153 by gibbs@aslan on 2002/05/30 20:09:22
-
-	aic79xx.h:
-		union -> struct for the cdb_plus_sense structure.
-		This was missed in the re-arrangement of the hscb
-		declaration.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.h#46 edit
-
-Change 1151 by gibbs@overdrive on 2002/05/30 18:24:34
-
-	aic79xx_reg.h:
-	aic79xx_seq.h:
-		Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#16 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#17 edit
-
-Change 1150 by gibbs@aslan on 2002/05/30 14:26:20
-
-	aic79xx_inline.h:
-		aic79xx_inline.h:
-			Break dataptr into u_int sized chucks for
-			printing to avoid compiler errors.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#26 edit
-
-Change 1149 by gibbs@aslan on 2002/05/30 14:25:13
-
-	aic79xx.c:
-		Panic if our hardware scb definition is not 64 bytes.
-		Hopefully this will catch agressive compiler padding
-		in the future.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#79 edit
-
-Change 1145 by gibbs@overdrive on 2002/05/30 13:51:24
-
-	aic79xx_osm.c:
-		Upate for change in hardware SCB definition.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#36 edit
-
-Change 1144 by gibbs@aslan on 2002/05/30 13:50:02
-
-	aic79xx.c:
-	aic79xx.h:
-	aic79xx_inline.h:
-	aic79xx_osm.c:
-		Rearrange hardware SCB definition to avoid
-		64bit alignment/packing problems on native
-		64bit platforms.  Everything was aligned
-		correctly, but the compiler was not smart
-		enough to see this with how the structures
-		were previously defined.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#78 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#45 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#25 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#12 edit
-
-Change 1143 by gibbs@aslan on 2002/05/29 20:55:06
-
-	aic79xx.c:
-	aic79xx.h:
-	aic79xx_pci.c:
-	aic7xxx.c:
-		Convert a few straglers to inttypes.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#77 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#44 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#32 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#70 edit
-
-Change 1141 by gibbs@overdrive on 2002/05/29 20:27:14
-
-	aic79xx_osm.c:
-		Bring back an "int i;" that was removed to fix a
-		compile warning.  It is used in debug code, so move
-		it to where it is used.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#35 edit
-
-Change 1139 by gibbs@overdrive on 2002/05/29 20:23:18
-
-	aic79xx_osm.c:
-	aic79xx_osm.h:
-	aic79xx_osm_pci.c:
-	aic7xxx_osm.c:
-	aic7xxx_osm.h:
-	aic7xxx_osm_pci.c:
-		Bring back the hack to force consistent memory to
-		be below 4GB.  The IA64 platform only enforces this
-		if your PCI device's dma mask is set to 4GB.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#34 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#34 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#11 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#106 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#84 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#36 edit
-
-Change 1138 by gibbs@overdrive on 2002/05/28 14:19:38
-
-	aic79xx_osm.c:
-		And another.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#33 edit
-
-Change 1137 by gibbs@overdrive on 2002/05/28 14:17:46
-
-	aic79xx_osm.c:
-		Kill a few compile warnings.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#32 edit
-
-Change 1135 by gibbs@aslan on 2002/05/28 13:35:41
-
-	aic79xx.c:
-	aic79xx.h:
-		Enable ahd_fini_scbdata().
-	
-		Change some #if 0's to AHD_DEBUG logs.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#76 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#43 edit
-
-Change 1133 by gibbs@overdrive on 2002/05/28 12:58:11
-
-	aic79xx_osm.c:
-		Clean up some 'XXX' and #if 0 stuff.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#31 edit
-
-Change 1132 by gibbs@overdrive on 2002/05/28 12:51:44
-
-	aic79xx_osm_pci.c:
-		More typos.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#10 edit
-
-Change 1130 by gibbs@overdrive on 2002/05/28 12:45:53
-
-	aic7xxx_osm_pci.c:
-		Remove stray '{'
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#35 edit
-
-Change 1129 by gibbs@overdrive on 2002/05/28 12:43:47
-
-	aic79xx_osm_pci.c:
-	aic7xxx_osm_pci.c:
-		Restore inadvertantly removed #endif.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#9 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#34 edit
-
-Change 1128 by gibbs@overdrive on 2002/05/28 12:39:12
-
-	aic7xxx_osm.c:
-		Remove one more stray use of hw_dma_mask.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#105 edit
-
-Change 1127 by gibbs@overdrive on 2002/05/28 12:37:22
-
-	aic7xxx_osm.c:
-	aic7xxx_osm.h:
-	aic7xxx_osm_pci.c:
-		Don't bother messing with the dma mask during
-		alloc consistent calls.  Linux guarantees that
-		the mappings will be below 4GB.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#104 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#83 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#33 edit
-
-Change 1126 by gibbs@overdrive on 2002/05/28 12:32:23
-
-	aic79xx_osm.c:
-	aic79xx_osm.h:
-	aic79xx_osm_pci.c:
-		Hook up 64BIT S/G support for Linux.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#30 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#33 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#8 edit
-
-Change 1125 by gibbs@aslan on 2002/05/24 17:11:19
-
-	aic79xx.h:
-		Pad ahd_dma64_seg to 16 bytes so we can still use
-		the ODD_SEG bit in the SG_CACHE.  Otherwise we'd
-		be able to shrink the SG element down to 12 bytes.
-	
-	aic79xx.seq:
-		Complete 64bit S/G data address support and inline
-		sg advance.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.h#42 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#42 edit
-
-Change 1121 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/05/24 14:01:42
-
-	Beta 6
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#32 edit
-
-Change 1120 by gibbs@aslan on 2002/05/24 13:58:41
-
-	aic79xx.c:
-		Fix some big endian bugs.
-	
-		Set SPLTSTADIS in PCIXCTL so we don't issue a target
-		abort when we abort an SG element fetch.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#75 edit
-
-Change 1117 by gibbs@overdrive on 2002/05/23 16:44:08
-
-	aic79xx_osm.h:
-		Bump version number to 0.5.0.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#31 edit
-
-Change 1115 by gibbs@overdrive on 2002/05/23 16:41:47
-
-	aic79xx_osm.h:
-		Add PCIX configuration space definitions.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#30 edit
-
-Change 1114 by gibbs@aslan on 2002/05/23 16:39:32
-
-	aic79xx_pci.c:
-		First shot at PCI-X error reporting.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#31 edit
-
-Change 1113 by gibbs@aslan on 2002/05/23 16:36:13
-
-	aic79xx_inline.h:
-		We always need to run the qoutfifo even if only
-		doing target mode.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#24 edit
-
-Change 1112 by gibbs@aslan on 2002/05/22 13:38:33
-
-	aic7xxx_pci.c:
-		Allow autoterm if we have SCB based config data.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#46 edit
-
-Change 1110 by gibbs@overdrive on 2002/05/22 11:41:08
-
-	aic7xxx_reg.h:
-	aic7xxx_seq.h:
-		Regenerate firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#10 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#11 edit
-
-Change 1109 by gibbs@aslan on 2002/05/22 11:40:28
-
-	aic7xxx.c:
-		Remove some unecessary ahc_flush_device_writes().
-	
-	aic7xxx.reg:
-		Remove redundant definition for SOFTCMDEN.
-	
-	aic7xxx_pci.c:
-		Only attempt auto-term if we have seeprom (or like)
-		data.
-	
-		For SPIOCAP based controllers, be sure that external
-		board control logic is enabled for termination control.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#69 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#30 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#45 edit
-
-Change 1108 by gibbs@aslan on 2002/05/21 16:51:16
-
-	aic79xx_pci.c:
-		SRAM_BASE -> SCB_BASE for reading SCB configuration
-		options.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#30 edit
-
-Change 1106 by gibbs@overdrive on 2002/05/21 15:03:07
-
-	Regenerate Linux aic79xx firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#15 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#16 edit
-
-Change 1105 by gibbs@overdrive on 2002/05/21 15:01:39
-
-	aic79xx_osm.c:
-		AHC -> AHD.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#29 edit
-
-Change 1103 by gibbs@overdrive on 2002/05/21 14:57:59
-
-	aic79xx_osm.c:
-	aic79xx_osm.h:
-		Add queue full and busy status timer to the aic79xx driver.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#28 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#29 edit
-
-Change 1102 by gibbs@overdrive on 2002/05/21 14:48:16
-
-	aic7xxx_osm.c:
-		Fix a few more compile errors.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#103 edit
-
-Change 1101 by gibbs@overdrive on 2002/05/21 14:45:36
-
-	aic7xxx_osm.c:
-		Really get the right timer.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#102 edit
-
-Change 1100 by gibbs@overdrive on 2002/05/21 14:39:27
-
-	aic7xxx_osm.c:
-		Use the correct timer for busy and queue full handling.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#101 edit
-
-Change 1099 by gibbs@overdrive on 2002/05/21 14:36:05
-
-	aic7xxx_osm.h:
-	aic7xxx_osm.c:
-		Perform a 500ms delay for single command queue full status
-		and busy status since Linux does not delay in this case.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#100 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#82 edit
-
-Change 1098 by gibbs@aslan on 2002/05/21 13:37:36
-
-	aic79xx.c:
-	aic79xx.reg:
-	aic79xx.seq:
-		Switch over to a more generic "protocol violation"
-		handler.  Use this to now catch cases where a
-		disconnect or command complete message is not
-		valid.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#74 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#34 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#41 edit
-
-Change 1091 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/05/17 14:35:15
-
-	Put a blank line before the Serial EEPROM text
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_proc.c#7 edit
-
-Change 1090 by gibbs@overdrive on 2002/05/17 14:19:14
-
-	aic79xx_osm.h:
-		Bump to Beta 4.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#28 edit
-
-Change 1089 by gibbs@overdrive on 2002/05/17 14:18:47
-
-	aic79xx_seq.h:
-	aic79xx_reg.h:
-		Regenerate firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#14 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#15 edit
-
-Change 1088 by gibbs@aslan on 2002/05/17 14:16:58
-
-	aic79xx.c:
-	aic79xx.reg:
-	aic79xx.seq:
-	aic79xx_osm.c:
-		IDENTIFY_SEEN -> NOT_IDENTIFIED.
-	
-		Add NO_CDB_SENT flag to SEQ_FLAGS.  Use this
-		to protect against DATA phases prior to having
-		a completed cdb transfer.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#73 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#33 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#40 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#11 edit
-
-Change 1087 by gibbs@aslan on 2002/05/17 13:32:27
-
-	aic79xx.c:
-	aic79xx.h:
-	aic79xx.reg:
-	aic79xx_pci.c:
-		Add Compaq special write bias and slewrate.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#72 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#41 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#32 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#29 edit
-
-Change 1086 by gibbs@overdrive on 2002/05/17 12:30:27
-
-	aic79xx_proc.c:
-		Adapt to ahd interface changes for seeprom routines.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_proc.c#6 edit
-
-Change 1085 by gibbs@overdrive on 2002/05/17 12:28:21
-
-	aic79xx_reg.h:
-	aic79xx_seq.h:
-		Regenerate Linux firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#13 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#14 edit
-
-Change 1083 by gibbs@overdrive on 2002/05/17 12:25:01
-
-	aic7xxx_proc.c:
-		Add a prototype.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#19 edit
-
-Change 1082 by gibbs@overdrive on 2002/05/17 12:24:49
-
-	aic79xx_proc.c:
-		Add write seeprom support.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_proc.c#5 edit
-
-Change 1081 by gibbs@aslan on 2002/05/17 12:22:15
-
-	aic79xx.c:
-	aic79xx.h:
-	aic79xx.reg:
-	aic79xx_pci.c:
-		Add logic for writing to serial eeproms.
-	
-		Move all flexport logic into the core.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#71 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#40 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#31 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#28 edit
-
-Change 1080 by gibbs@aslan on 2002/05/17 11:43:50
-
-	aic79xx.c:
-	aic79xx.h:
-	aic79xx_pci.c:
-		Switch over to using a buffer to store seeprom contents.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#70 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#39 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#27 edit
-
-Change 1078 by gibbs@overdrive on 2002/05/17 11:31:05
-
-	aic79xx_proc.c:
-		Protect the aic79xx proc code with the ahd_list_lock.
-	
-	aic7xxx_proc.c:
-		Release the ahc_list_lock when errors are encountered.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_proc.c#4 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#18 edit
-
-Change 1077 by gibbs@overdrive on 2002/05/17 11:16:59
-
-	aic79xx_osm.c:
-		':' -> ';'
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#27 edit
-
-Change 1076 by gibbs@overdrive on 2002/05/17 11:14:48
-
-	aic79xx_osm.c:
-	aic79xx_osm.h:
-		Kill a few stray ahcs.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#26 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#27 edit
-
-Change 1074 by gibbs@overdrive on 2002/05/17 11:08:38
-
-	aic79xx_osm.c:
-	aic79xx_osm.h:
-	aic79xx_osm_pci.c:
-		Linux implementation of the ahd_list_lock.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#25 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#26 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#7 edit
-
-Change 1073 by gibbs@aslan on 2002/05/17 10:57:35
-
-	Implement and use the ahd_list_lock.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#69 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#26 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#10 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.h#6 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.c#6 edit
-
-Change 1071 by gibbs@overdrive on 2002/05/17 10:23:20
-
-	aic7xxx_reg.h:
-	aic7xxx_seq.h:
-		Regenerate firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#9 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#10 edit
-
-Change 1070 by gibbs@overdrive on 2002/05/17 10:22:28
-
-	aic7xxx.seq:
-		Defer clearing SELDO until we have set IDENTIFY_SEEN.
-		This closes another race in the abort code.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#43 edit
-
-Change 1069 by gibbs@overdrive on 2002/05/17 10:21:50
-
-	aic7xxx_osm.c:
-		Treat IDENTIFY_SEEN flag as an indication that we
-		are still on the bus but still waiting for the first
-		REQ.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#99 edit
-
-Change 1068 by gibbs@overdrive on 2002/05/17 09:42:25
-
-	aic7xxx_osm.c:
-	aic7xxx_osm_pci.c:
-		Guard the two avenues for detach with the ahc_list_lock.
-	
-		Disable card interrupts prior to attempting detach.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#98 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#32 edit
-
-Change 1067 by gibbs@aslan on 2002/05/17 09:36:18
-
-	aic7770.c:
-	aic7xxx_pci.c:
-		Guarantee that the ahc_list_lock is not required
-		across the calls to the different config calls by
-		only putting the softc into the list if the config
-		is successful.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#21 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#44 edit
-
-Change 1066 by gibbs@aslan on 2002/05/17 09:30:44
-
-	aic7770.c:
-	aic7xxx.c:
-	aic7xxx_pci.c:
-	aic7xxx_osm.c:
-		Make sure that the ahc_list_lock is always aquired
-		ahead of the ahc_lock to prevent lock order reversals.
-	
-		Protect insertions of the ahc_softc into the ahc_list
-		with the ahc_list_lock.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#20 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#68 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#43 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.c#5 edit
-
-Change 1064 by gibbs@overdrive on 2002/05/16 22:36:00
-
-	aic7xxx_osm.c:
-		Don't register our reboot notifier twice.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#97 edit
-
-Change 1062 by gibbs@aslan on 2002/05/16 17:36:58
-
-	aic79xx.c:
-		Set HOST_MSG in the command complete with no status
-		case so that when we go to message out, the sequencer
-		will notify the host.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#68 edit
-
-Change 1061 by gibbs@overdrive on 2002/05/16 14:55:36
-
-	aic7xxx.c:
-		Freeze the untagged queues from within
-		ahc_search_untaggd_queues() in addition to
-		ahc_search_qinfifo().  There are other callers
-		to ahc_search_untagged_queues().
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#67 edit
-
-Change 1059 by gibbs@overdrive on 2002/05/16 14:18:12
-
-	aic7xxx_osm.h:
-		Bump version number to 6.2.8.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#81 edit
-
-Change 1058 by gibbs@overdrive on 2002/05/16 14:17:45
-
-	aic7xxx_reg.h:
-	aic7xxx_seq.h:
-		Regenerate firmware for Linux.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#8 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#9 edit
-
-Change 1057 by gibbs@overdrive on 2002/05/16 14:16:41
-
-	aic7xxx_proc.c:
-		Perform a read after the write to the serial eeprom
-		to refresh our eeprom buffer.  This allows the user
-		to verify that the write was good.
-	
-		Only acquire and release the seeprom if we are not
-		a VLB card.
-	
-		Be less strick in allowing writes.  We want the user to
-		be able to overwrite an EEPROM that was previously corrupted.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#17 edit
-
-Change 1056 by gibbs@overdrive on 2002/05/16 14:13:32
-
-	aic7xxx_pci.c:
-		Set seep_config to NULL after freeing the seep buffer.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#42 edit
-
-Change 1055 by gibbs@aslan on 2002/05/16 13:59:01
-
-	aic7770.c:
-	aic7xxx.reg:
-		Add support for configuration extended translation
-		on the 274X.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#19 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#29 edit
-
-Change 1054 by gibbs@aslan on 2002/05/16 12:57:59
-
-	aic7xxx.h:
-	aic7xxx_pci.c:
-		Record if the BIOS config left over in SCB2 is used.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#45 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#41 edit
-
-Change 1053 by gibbs@aslan on 2002/05/16 12:57:24
-
-	aic79xx.h:
-		Reduce AHD_MAX_QUEUE to 255 until support for using
-		all SCBs is added.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.h#38 edit
-
-Change 1052 by gibbs@overdrive on 2002/05/16 11:23:12
-
-	aic79xx_reg.h:
-	aic79xx_seq.h:
-		Regenerate firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#12 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#13 edit
-
-Change 1051 by gibbs@aslan on 2002/05/16 11:06:00
-
-	aic79xx.c:
-		Correct some #if AHD_TARGET_MODE code.
-	
-	aic79xx.seq:
-		If we do not find a matching SCB when snooping
-		the bus, don't "double ack" the last byte.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#67 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#39 edit
-
-Change 1050 by gibbs@aslan on 2002/05/16 10:55:25
-
-	aic7xxx.c:
-	aic7xxx.h:
-	aic7xxx_pci.c:
-		Record if we are in large SCB mode and use this
-		to fully initialize all SCBs so that reads in
-		our debuging routines don't cause inadvertent
-		parity errors.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#66 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#44 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#40 edit
-
-Change 1049 by gibbs@aslan on 2002/05/16 10:41:35
-
-	aic7xxx.c:
-		Flush device writes after doing any CLRREQINITs.
-	
-		Protect ahc frees via the list lock.
-	
-	aic7xxx_osm.h:
-		FreeBSD implementation of the list lock.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#65 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.h#5 edit
-
-Change 1048 by gibbs@overdrive on 2002/05/16 10:29:21
-
-	aic7xxx_osm.c:
-		Set "paused" from within the "get the controller in
-		a consistent state" loop in ahc_queue_recovery_cmd().
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#96 edit
-
-Change 1046 by gibbs@overdrive on 2002/05/15 17:53:13
-
-	aic7xxx_reg.h:
-	aic7xxx_seq.h:
-		Regenerate firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#7 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#8 edit
-
-Change 1045 by gibbs@aslan on 2002/05/15 17:51:20
-
-	aic7xxx.seq:
-		Only clear SELDO after we have removed the
-		active SCB from the waiting list.  This allows
-		the host to use this as a confirmation that
-		the WAITING_SCB list is free of a just selected
-		SCB.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#42 edit
-
-Change 1044 by gibbs@overdrive on 2002/05/15 17:48:42
-
-	aic7xxx_osm.c:
-	aic7xxx_osm.h:
-		Add ahd_list_lock implementation for Linux.
-	
-		Protect against a pending selection in our recovery
-		queuing routine.
-	
-	aic7xxx_proc.c:
-		Use the buffer in the softc for seeprom access.  Add
-		preliminary write support for VLB cards.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#95 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#80 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#16 edit
-
-Change 1043 by gibbs@overdrive on 2002/05/15 17:07:06
-
-	aic7xxx.c:
-		Clear out SCB_SCSIID and SCB_LUN when setting up
-		the SCB free list.  We don't want a parity error
-		if we dump these out in ahc_dump_card_state().
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#64 edit
-
-Change 1042 by gibbs@aslan on 2002/05/15 15:39:00
-
-	aic7770.c:
-		Seeprom config is now a pointer.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#18 edit
-
-Change 1040 by gibbs@aslan on 2002/05/15 14:47:38
-
-	aic7770.c:
-	aic7xxx.c:
-	aic7xxx.h:
-	aic7xxx_pci.c:
-		Store seeprom information in a buffer hung
-		off the softc.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#17 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#63 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#43 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#39 edit
-
-Change 1039 by gibbs@overdrive on 2002/05/15 13:05:07
-
-	Merge latest aic79xx driver into linux-aic79xx-2.4.0.
-
-Affected files ...
-
-... //depot/linux-aic79xx-2.4.0/Makefile#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/ide/cmd640.c#3 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/Makefile#2 edit
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/Config.in#5 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/Makefile#3 edit
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx.h#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx.reg#3 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx.seq#3 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx_core.c#3 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx_host.h#3 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx_inline.h#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx_osm.c#3 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx_osm.h#4 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#3 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx_pci.c#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx_proc.c#3 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx_reg.h#4 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx_seq.h#4 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx.h#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx.reg#4 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx.seq#4 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_93cx6.c#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_93cx6.h#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_core.c#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_host.h#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_osm.c#4 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_osm.h#3 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_pci.c#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_proc.c#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_reg.h#4 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_seq.h#4 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/Makefile#3 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/aicasm.c#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/aicasm.h#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/aicasm_gram.y#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/aicasm_macro_gram.y#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/aicasm_macro_scan.l#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/aicasm_scan.l#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.c#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.h#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/scsi_iu.h#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sd.c#3 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sr.c#3 integrate
-
-Change 1038 by gibbs@overdrive on 2002/05/15 12:50:49
-
-	aic79xx_osm.c:
-	aic79xx_osm.h:
-		Next pass at timer support in the Linux OSM.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#24 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#25 edit
-
-Change 1037 by gibbs@overdrive on 2002/05/15 12:48:28
-
-	aic79xx.c:
-		Move two variables into #ifdef AHD_TARGET_ROLE.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#66 edit
-
-Change 1036 by gibbs@overdrive on 2002/05/14 17:16:57
-
-	Regenerate firmware.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#11 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#12 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#6 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#7 edit
-
-Change 1035 by gibbs@overdrive on 2002/05/14 17:15:44
-
-	aic79xx_osm.c:
-		Register our reboot notifier on the first allocation
-		of a platform softc rather than in our module parameter
-		parsing routine.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#23 edit
-
-Change 1034 by gibbs@overdrive on 2002/05/14 17:08:01
-
-	aic79xx_osm.h:
-		First cut at ahd timer facility for linux.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#24 edit
-
-Change 1033 by gibbs@aslan on 2002/05/14 15:54:32
-
-	aic79xx.c:
-	aic79xx.h:
-	aic79xx.seq:
-	aic79xx_osm.h:
-		Poll for SCSI bus reset going away from a timer
-		context rather than deferring the re-enabling
-		of the SCSIRSTI interrupt to the sequencer.  We
-		have to catch *every* bus reset due to the reset
-		behavior of the negotiation table.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#65 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#37 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#38 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.h#5 edit
-
-Change 1032 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/05/13 17:21:47
-
-	Regenerate firmware
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#10 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#11 edit
-
-Change 1031 by gibbs@overdrive on 2002/05/13 17:14:19
-
-	aic79xx_osm.h
-		Bump version to 0.3.0.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#23 edit
-
-Change 1030 by gibbs@aslan on 2002/05/13 17:11:08
-
-	aic79xx.c:
-	aic79xx.seq:
-		Have the sequencer re-enable incoming scsi reset
-		interrupts if, prior to starting an outgoing selection,
-		this interrupt is disabled.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#64 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#37 edit
-
-Change 1029 by gibbs@aslan on 2002/05/13 16:47:29
-
-	aic79xx.c:
-		Handle non-packetized phase unexpected busfree
-		events via the non-packetized handler regardless
-		of the packetized negotiation agreement in effect.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#63 edit
-
-Change 1028 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/05/11 22:55:03
-
-	Bump the version to 0.2.1.  We missed 0.2.0, and the driver is
-	about to be re-released to address yet another script bug.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#22 edit
-
-Change 1026 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/05/10 22:38:10
-
-	Regenerate firmware
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#9 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#10 edit
-
-Change 1024 by gibbs@aslan on 2002/05/10 20:19:25
-
-	aic79xx.c:
-		Add an error handler for receiving a command complete
-		message without having received status.  We will attempt
-		to abort the command.
-	
-		Enable the OVERRUN interrup and add a handler for it.
-	
-		Include lun information when compiling devinfo for the
-		unexpected bus free handler.
-	
-		Mask off the correct number of length bits when printing
-		S/G elements.
-	
-		Always update the neg table when setting bus width.
-	
-		Don't bother clearing the last three bytes of the annex
-		table on every update of the neg table.  These are cleared
-		explicitly on chip reset and will, in the B, contain training
-		info.
-	
-		Reset the chip on third party resets.  It is hoped that this
-		is the cause of some of the host basher issues related to
-		transferring into and out of emulation mode.
-	
-		Factor out more S/G printing code.
-	
-	aic79xx.reg:
-		Add a new sequencer interrupt code for a command complete
-		message with no status phase.
-	
-	aic79xx.seq:
-		Add checking for whether status has been delivered or not
-		in the command complete handler.
-	
-		Correct a test for a necessary bitbucket prior to having
-		the host reinitialize our data pointers.
-	
-	aic79xx_osm.h:
-		Change the AHD_DEBUG value for FreeBSD to 0x3FF.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#62 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#30 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#36 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.h#4 edit
-
-Change 1018 by gibbs@bitkeeper-linux-2.4 on 2002/05/08 17:21:24
-
-	aic7xxx_osm.c:
-		Replace SEARCH_REMOVE with SEARCH_COMPLETE in the search
-		of the untagged queue.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#94 edit
-
-Change 1017 by gibbs@overdrive on 2002/05/07 17:45:57
-
-	aic7xxx_osm.c:
-		Remove entries from the untagged queue prior to
-		doing a more general abort in ahd_linux_queue_recovery_cmd().
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#93 edit
-
-Change 1016 by gibbs@aslan on 2002/05/07 17:34:02
-
-	aic7xxx.c:
-	aic7xxx.h:
-		Break out the search for entries in the untagged
-		queue into its own routine.  Allow the user to
-		search based on io_ctxt too.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#62 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#42 edit
-
-Change 1015 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/05/07 14:54:52
-
-	Beta 1
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#21 edit
-
-Change 1014 by gibbs@aslan on 2002/05/07 14:53:39
-
-	aic79xx.h:
-		Limit max queue to 256 until nonpacketized tag
-		management is added to the driver.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.h#36 edit
-
-Change 1013 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/05/07 14:26:20
-
-	Add semicolon, initialize a variable before use.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#22 edit
-
-Change 1012 by gibbs@overdrive on 2002/05/07 14:25:46
-
-	aic79xx.h:
-		Change ahd_debug to be a uint32_t.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.h#35 edit
-
-Change 1011 by gibbs@overdrive on 2002/05/07 14:01:41
-
-	aic79xx.c:
-		Make ahd_debug a uint32_t.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#61 edit
-
-Change 1010 by gibbs@overdrive on 2002/05/07 13:59:31
-
-	aic79xx_osm.c:
-		Ignore short inquiry information for devices that
-		are already configured and seem to allow spi3/4
-		ppr options.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#21 edit
-
-Change 1009 by gibbs@aslan on 2002/05/07 13:07:06
-
-	aic79xx.c:
-		Expand on our unexpected busfree handling.
-		We now have a better chance of getting the
-		packetized vs. non-packetized status correct.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#60 edit
-
-Change 1008 by gibbs@aslan on 2002/05/07 11:22:51
-
-	aic79xx.h:
-		Add a debug option for QFull messages.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.h#34 edit
-
-Change 1007 by gibbs@overdrive on 2002/05/07 11:22:04
-
-	aic79xx_osm.c:
-		Add a loging option for displaying Queue Full info.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#20 edit
-
-Change 1005 by gibbs@aslan on 2002/05/06 17:20:00
-
-	aic79xx.c:
-		Complete port of the ignore wide residue and
-		data pointers reinitialization routines.
-	
-		Create ahd_dump_sglist() and use it to factor out
-		some code.
-	
-		Use SCB_GET_TAG to access hscb->tag.  This fixes
-		the first of many big endian issues in the driver.
-	
-		In the busfree handler, busfree time is valid even
-		for non-packetized phases.  We now assume that a
-		packetized phase is active if lastphase is P_BUSFREE.
-	
-		If a parity error occurred in the current phase,
-		ack the current byte so long as it is not currently
-		a data phase.
-	
-		Print out the number of SCBs aborted during
-		non-packetized busfree handling.
-	
-	aic79xx.h:
-		Add definition for SCB_GET_TAG.
-	
-		Add a new debug entry for AHD_SHOW_QUEUE.
-	
-		Add prototype for ahd_dump_sglist.
-	
-	aic79xx.seq:
-		In our restore data pointers handler, release
-		and reacquire our FIFO to flush out any state
-		info before a possible return to data phase.
-	
-		When coming back to the data phase handler after
-		having already handled at least one data phase,
-		only bother with the PDATA_REINIT sequencer
-		interrupt if we think more data needs to be sent.
-	
-	aic79xx_inline.h:
-		More SCB_GET_TAG() cleanup.
-	
-		Add SHOW queue code.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#59 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#33 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#35 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#23 edit
-
-Change 1004 by gibbs@aslan on 2002/05/06 17:07:11
-
-	Sync FreeBSD Ids.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#61 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#41 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#28 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#41 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#15 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#10 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#35 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#38 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#16 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.h#10 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#15 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_insformat.h#9 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_macro_gram.y#3 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_macro_scan.l#3 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#11 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#14 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#11 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/ahc_eisa.c#5 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/ahc_pci.c#5 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#9 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.c#4 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.h#4 edit
-
-Change 1002 by gibbs@overdrive on 2002/05/02 19:05:23
-
-	aic79xx_osm.c:
-	aic7xxx_osm.c:
-		Release the io_request lock in our detect routines
-		to avoid deadlock with other portions of the system
-		(possibly PCI) that may try to acquire a spin lock.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#19 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#92 edit
-
-Change 1001 by gibbs@overdrive on 2002/05/02 17:24:12
-
-	aic79xx_osm.c:
-		Put sense printing behind AHD_DEBUG.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#18 edit
-
-Change 1000 by gibbs@aslan on 2002/05/02 17:22:05
-
-	aic79xx.c:
-		Put even more messages behind AHD_DEBUG type stuff.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#58 edit
-
-Change 999 by gibbs@overdrive on 2002/05/02 16:59:43
-
-	aic79xx_osm.h:
-		Bump version to Alpha 8.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#20 edit
-
-Change 998 by gibbs@overdrive on 2002/05/02 16:59:16
-
-	aic79xx_osm.c:
-	aic79xx_osm.h:
-		Add options for enabling debugging code.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#17 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#19 edit
-
-Change 997 by gibbs@overdrive on 2002/05/02 16:58:22
-
-	Config.in:
-		Add compile time options to control AHD_DEBUG.
-
-Affected files ...
-
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/Config.in#4 edit
-
-Change 996 by gibbs@aslan on 2002/05/02 16:42:23
-
-	aic79xx.c:
-		Put sense and S/G mapping printfs under AHD_DEBUG.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#57 edit
-
-Change 995 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/05/02 15:37:38
-
-	Remove HD_DEBUG block that doesn't compile on Linux and doesn't
-	make much sense anyways.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#56 edit
-
-Change 994 by gibbs@overdrive on 2002/05/02 15:34:00
-
-	scsi_iu.h:
-		Pull in the latest from FreeBSD.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/scsi_iu.h#3 edit
-
-Change 993 by gibbs@overdrive on 2002/05/02 15:19:13
-
-	aic79xx_reg.h:
-	aic79xx_seq.h:
-	aic7xxx_reg.h:
-	aic7xxx_seq.h:
-		Regenerate firmware for Linux.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#8 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#9 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#5 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#6 edit
-
-Change 992 by gibbs@aslan on 2002/05/02 15:03:26
-
-	aic79xx.c:
-		Save and restore modes in ahd_clear_fifo.
-		Also reset our long jump address.
-	
-		At the beginning of every message loop,
-		reset LQIPHASE_OUTPKT via LQIRETRY if
-		this condition is set.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#55 edit
-
-Change 991 by scottl@scottl-hobbiton-mod_devel_aic79xx on 2002/05/02 12:55:04
-
-	Document the read streaming config switch
-
-Affected files ...
-
-... //depot/linux-aic79xx-2.4.0/Documentation/Configure.help#4 edit
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/Config.in#3 edit
-
-Change 990 by gibbs@overdrive on 2002/05/01 22:03:06
-
-	aic79xx_osm.c:
-		First pass at read stream user tunables.  Still
-		needs an update to the config file.
-	
-		Bump limited tag count to 64.  Maxtor drives
-		still have issues with higher tag counts.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#16 edit
-
-Change 989 by gibbs@aslan on 2002/05/01 21:29:56
-
-	aic79xx.seq:
-		Restore an END_CRITICAL that was lost in the last
-		revision.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#34 edit
-
-Change 988 by gibbs@overdrive on 2002/05/01 21:23:18
-
-	aic79xx.seq:
-		Remove workarounds that only apply to chips <= A3.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#33 edit
-
-Change 987 by gibbs@aslan on 2002/05/01 21:19:06
-
-	aic79xx.c:
-		Split DFF reseting out of ahd_restart() and into
-		the routine ahd_clear_fifo().  This allows us to
-		safely restart the sequencer even if a FIFO has
-		been allocated to a new transaction.
-	
-		Add ahd_clear_fifo() calls as appropriate.
-	
-		Don't set PERRORDIS in SEQCTL0.
-	
-		Clean out sequencer interrupt codes that
-		are no longer in use.
-	
-		Add a handler for the ENTERING_NONPACK sequencer
-		interrupt.  This is used to handle the message
-		phases usually related to CRC errors in packetized
-		connections.
-	
-		Clean up saved mode handling.  The driver now
-		keeps the mode state as of when the interrupt
-		handler was entered in the softc as a separate
-		variable.  ahd_unpause() will now restore these
-		values whenever it is called.  This allows us to
-		remove several layers of saves and restores of
-		the mode register.
-	
-		Ensure we are in the SCSI mode when cleaning SCSI
-		interrupts.  Some of these clear bits are only
-		available in that mode.
-	
-		Port a few more non-pack sequencer interrupt code
-		handlers.
-	
-		Remove a few non-pack sequencer interrupt code
-		handlers that don't apply in a non-SCB paging
-		world.
-	
-		Complete framework for handling CRC errors.
-	
-		In our busfree handler, clear whichever fifo
-		was active at the time of the busfree.
-	
-		Only force a renegotiation for busfrees in a
-		non-packetized connection.
-	
-		In ahd_clear_critical_sections(), turn off all
-		of the interrupt enables that might prevent stepping.
-		Make sure that we unpause the sequencer in its
-		original mode during the stepping process.
-	
-		Rely on ATNO instead of ATNI.
-	
-		Handle "expected" busfrees after delivering an
-		INITIATOR_DET_ERROR message.
-	
-		Remove pausing code in the ahd_alloc_scbs() since
-		we no longer touch the hardware in this routine.
-	
-		Add additional AHD_DEBUG logging.
-	
-		Correct ahd_index_busy_tcl.  The target mask used
-		to set the SCBPTR was not correct.  This broke
-		non-packetized operations.
-	
-		Add code to print out the value of the packetized
-		failures field in status packets should it be set.
-	
-		Have ahd_dump_card_state() report the sequencer's
-		saved mode, not the current mode.
-	
-	aic79xx.h:
-		Add message handler flags for packetized CRC error
-		handling.
-	
-		Add fields for storing the sequencer's mode pointer
-		as found before setting any modes in host code.
-	
-		Add additional AHD_DEBUG values.
-	
-	aic79xx.reg:
-		Clean up SEQINTCODEs.
-	
-		Fix typo in BUSFREE_DFF0: O -> 0
-	
-	aic79xx.seq:
-		Remove a redundant test for SELDO.
-	
-		Workaround missing NONPACKREQ cases by looking
-		for ATNO and a message phase.
-	
-		Move the clearing of SELDO to outside of our
-		select_out handler's critical section.  This
-		ensures that we don't clear this status while
-		stepping through a critical section.
-	
-		Remove a jmp to await_busfree by moving the
-		await busfree handler.
-	
-		Clear the LONGJMP_ADDR prior to entering the
-		NONPACK handler.
-	
-	aic79xx_inline.h:
-		Revamp mode pointer routines to allow automatic
-		restoration of the sequencer's mode pointer when
-		the sequencer is unpaused.
-	
-		Add debug logging for all mode pointer accesses.
-	aic79xx_pci.c:
-		Correct the logging of PCI target errors.
-	
-	aic79xx_osm.c:
-		Add DDB hooks for looking at AHD registers.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#54 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#32 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#29 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#32 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#22 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#25 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#8 edit
-
-Change 986 by gibbs@aslan on 2002/05/01 20:51:55
-
-	aic7xxx.c:
-		Force renegotiation if we have an unexpected
-		busfree with a target just in case the busfree
-		is due to a negotiation mismatch.
-	
-		If the target goes on to a message that should
-		be handled by the sequencer during a host message
-		loop, terminate our message loop.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#60 edit
-
-Change 980 by gibbs@overdrive on 2002/04/25 12:54:54
-
-	aic79xx_osm.c:
-		If a device does not support information units as
-		per its inquiry data, don't attempt to set IUs or
-		IU related bits in our PPR requests.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#15 edit
-
-Change 979 by gibbs@aslan on 2002/04/25 11:32:11
-
-	aic79xx.c:
-		Force renegotiation on a non-packetized busfree.
-	
-		Commonize some devinfo setup in the non-packetized
-		busfree handler.
-	
-		Modify ahd_fetch_devinfo to pull IOWNID and TOWNID
-		from mode 3.  These registers are not valid in
-		modes 0 and 1.
-	
-		Add support for terminating an initiator message
-		loop early.  This is used to return to sequencer
-		based processing for those messages that the
-		sequencer usually handles.
-	
-		When parsing configuration parameters, manually
-		disable IU negotiation if the disconnect privledge
-		is disabled.
-	
-		Print out IOWNID, TOWNID and SCSISEQ1 in
-		ahd_dump_card_state.
-	
-	aic79xx_osm.c:
-		Disable IU_REQs if disconnects are disabled.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#53 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#7 edit
-
-Change 977 by gibbs@aslan on 2002/04/24 14:54:33
-
-	aicasm/aicasm.c:
-		Style nit.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#15 edit
-
-Change 976 by gibbs@aslan on 2002/04/24 12:43:24
-
-	aic79xx_inline.h:
-		Don't attempt to run the TQINFIFO if we are
-		out of ATIOs with which to service it.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#21 edit
-
-Change 975 by gibbs@aslan on 2002/04/24 12:42:39
-
-	ahc_eisa.c:
-	ahc_pci.c:
-		Remove DEVINTERFACE stuff that crept in from
-		my private trees.
-	
-	aic7xxx_inline.h:
-		Correct a big endian issue with large (> 12 byte)
-		cdb support.
-	
-	aic7xxx_osm.c:
-		Correct another big endian bug having to do with
-		sense data copying.
-	
-		And another big endian bug in the initialization
-		of SCBs that do not transfer data.
-	
-	aic7xxx_osm.h:
-		Enable byte swapping macros for FreeBSD.	
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#34 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/ahc_eisa.c#4 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/ahc_pci.c#3 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.c#3 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.h#3 edit
-
-Change 974 by gibbs@aslan on 2002/04/23 11:14:43
-
-	aic7xxx.c:
-		When clearing interrupts, perform a few
-		ahc_flush_device_writes() calls to ensure
-		status bits are cleared before any dependent
-		interrupt status bits.
-	
-		Add a comment about proper cleanup of the tqinfifo
-		under target mode.  Special care has to be taken
-		if we are a twin channel controller.
-	
-		Clean up the bus reset logic as it pertains to
-		target mode.  We still need a timer to wait for
-		the bus reset to fall so as to be completely immune
-		from "bus reset storms".
-	
-		Add a printf indicating that all ATIO resources
-		have been exhausted if this condition occurs and
-		we are running in bootverbose mode.
-	
-	aic7xxx.seq:
-		Properly set the synchronous transfer settings upon
-		resumption of a transaction with the disconnect privledge
-		disabled in target mode.  These connections were always
-		run in async mode irrespective of the negotiated transfer
-		rate.
-	
-	aic7xxx_inline.h:
-		Only attempt to run the TQINFIFO if we have ATIOs available
-		to service any entries that are found.
-	
-	aic7xxx_osm.c:
-		Put target mode diagnostics for transactions without the
-		disconnect privledge under bootverbose.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#59 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#40 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#33 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.c#2 edit
-
-Change 969 by gibbs@overdrive on 2002/04/22 16:46:42
-
-	aic7xxx_osm.h:
-		Bump Linux driver to 6.2.7 for chip reset delay.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#79 edit
-
-Change 967 by scottl@scottl-hobbiton-mod_devel1 on 2002/04/22 11:50:17
-
-	Note Alpha 7
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#18 edit
-
-Change 966 by gibbs@overdrive on 2002/04/22 11:46:47
-
-	aic79xx_reg.h:
-	aic79xx_seq.h:
-		Regenerate firmware for Linux.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#8 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#5 edit
-
-Change 965 by gibbs@aslan on 2002/04/22 11:45:24
-
-	aic79xx.c:
-		Simplify LQO busfree handling.  We now rely on
-		critical sections in the sequencer to make sure
-		that the sequencer is outside of the SELDO handler.
-		This allows us to clean up after the busfree with
-		one interrupt instead of two.
-	
-		Don't muck with the ENBUSFREE bit.  The set of the
-		BUSFREE interrupt is a pulse, so simply clearing
-		the BUSFREE status is enough to kill the interrupt.
-		This allows busfree protection for any packetized
-		connections that might be in progress during the
-		BUSFREE handler.
-	
-	aic79xx.h:
-		Fix duplicate entries in AHD_BUG definitions.
-	
-	aic79xx.reg:
-		Kill the LQOBUSFREE_TRAP sequencer interrupt.
-		It is no longer needed.
-	
-	aic79xx.seq:
-		Add critical sections to protect against jumping
-		to the SELDO handler at the same time the kernel
-		clears SELDO.
-	
-		If an LQOBUSFREE is detected in our SELDO handler,
-		jmp back to the idle loop so that we exit the
-		critical section and the kernel can handle the
-		error.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#52 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#31 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#28 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#31 edit
-
-Change 964 by gibbs@overdrive on 2002/04/22 00:00:09
-
-	aic79xx_reg.h:
-	aic79xx_seq.h:
-		Regenerate firmware for Linux.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#7 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#7 edit
-
-Change 963 by gibbs@aslan on 2002/04/21 23:58:57
-
-	aic79xx.seq:
-		Or in HDMAEN along with PRELOADEN just in
-		case HDMAENACK is not true at the time we
-		load a segment.  This avoids accidentally
-		shutting off host transfers.  This seems
-		to avoid the IBM drive issue and doesn't
-		require extra instructions or busy loops.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#30 edit
-
-Change 962 by gibbs@overdrive on 2002/04/21 23:24:21
-
-	aic79xx.c:
-		occured -> occurred.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#51 edit
-
-Change 961 by gibbs@overdrive on 2002/04/21 22:19:31
-
-	aic79xx_reg.h:
-	aic79xx_seq.h:
-		Regenerate to latest.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#6 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#6 edit
-
-Change 960 by gibbs@aslan on 2002/04/21 19:49:06
-
-	aic79xx_pci.c:
-		Update PCI bus modes to better reflect reality.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#24 edit
-
-Change 959 by gibbs@overdrive on 2002/04/21 18:44:49
-
-	aic79xx.seq:
-		Do not clear ENSELO if there is a pending SELDO
-		already.  We have not yet seen the SELDO, and
-		we rely on ENSELO set/clear sematics to distinguish
-		between packetized and non-packetized selections.
-	
-		or in IRET rather then use mvi in case some of
-		the bits in SEQINTCTL matter during interrupt
-		return.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#29 edit
-
-Change 958 by gibbs@overdrive on 2002/04/21 17:26:16
-
-	scsi_iu.h:
-		Correct off by 1 error.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/scsi_iu.h#2 edit
-
-Change 957 by scottl@scottl-hobbiton-mod_devel1 on 2002/04/21 00:23:33
-
-	Indicate Alpha 6
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#17 edit
-
-Change 956 by gibbs@overdrive on 2002/04/20 23:36:53
-
-	aic79xx_inline.h:
-		In ahd_lookup_scb(), guard against tag values
-		larger than AHD_SCB_MAX.  Our array of indexes
-		in only that large.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#20 edit
-
-Change 955 by gibbs@overdrive on 2002/04/20 23:28:30
-
-	aic79xx.c:
-		Fix logic bug in ahd_abort_scbs().
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#50 edit
-
-Change 954 by gibbs@overdrive on 2002/04/20 23:27:01
-
-	aic79xx.c:
-		Add missing '}'.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#49 edit
-
-Change 953 by gibbs@overdrive on 2002/04/20 23:25:00
-
-	aic79xx.c:
-		Limit abort processing of the busy targets table
-		to LUNS that are addressable when not packetized.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#48 edit
-
-Change 951 by scottl@scottl-hobbiton-mod_devel1 on 2002/04/20 21:16:27
-
-	Add definition for PCIM_SERRESPEN
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#16 edit
-
-Change 950 by gibbs@overdrive on 2002/04/20 21:06:07
-
-	aic79xx_osm.c:
-		Remove call to ahd_search_disc_list() which is no
-		longer required.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#14 edit
-
-Change 949 by gibbs@overdrive on 2002/04/20 21:04:55
-
-	aic79xx_reg.h:
-	aic79xx_seq.h:
-		Regenerate firmware for Linux releases.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#5 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#5 edit
-
-Change 948 by gibbs@aslan on 2002/04/20 21:03:26
-
-	aic79xx.c:
-		Remove disconnected list handling code as this
-		product does not use this algorithm.
-	
-		Add a routine to determine if we are currently
-		in a connection that has a packetized agreement.
-	
-		Add a routine to switch to the currently active
-		FIFO's mode.
-	
-		Modify unexpected busfree handling for outgoing
-		packets.  LQOBUSFREE is now a pollable status
-		rather than an interrupt.  When the unexpected
-		busfree interrupt occurs, we simply clear it
-		if LQOBUSFREE is set.  The sequencer will
-		eventually handle the SELDO and issue a sequencer
-		interrupt to the host.  The host then cleans up
-		the execution queue and restarts the sequencer.
-		This avoids the problem of determining just where
-		the sequencer is executing at the time of the
-		BUSFREE since the sequencer can drift into the
-		SELDO handler while the BUSFREE interrupt is working
-		to pause it.
-	
-		Finish the port of the busy target table routines.
-		This are used during error recovery.
-	
-		Start documenting our strategies for handling
-		CRC errors.  The code for this is only partially
-		completed.
-	
-		Tighten up the host message loop.  We now have
-		the sequencer perform the actual reads and writes
-		to drive our ACK, to reduce the possibility of the
-		sequencer missing a short lived phase.
-	
-		Print out the HADDR and HCNT for both FIFOs
-		in ahd_dump_card_state().
-	
-	aic79xx.h:
-		Add better documentation for the TCL format.
-	
-		Add a macro for building a TCL from target,
-		channel and lun, rather than SCSIID and lun.
-	
-		Add a bug entry for the issue on the A about
-		the packetized status bit being flakey.
-	
-		Add an SCB flag for recording transmission
-		errors.  This flag should save us if the
-		target does not properly return status
-		in response to our initiator detected
-		error message.
-	
-	aic79xx.reg:
-		Add a new sequencer interrupt for the busfree trap.
-	
-		Add bit definition for LQIPHASE_OUTPKT.
-	
-		Target message loop definitions.
-	
-	aic79xx.seq:
-		Use ENSELO auto-clearing as the key to determining
-		if the connection is packetized or not.
-	
-		Add support for handling unexpected busfree
-		events in outgoing command packets.
-	
-		If we have already allocated a FIFO when entering
-		the command phase, this must be a retry.  Free
-		the FIFO and reallocate it to make sure no
-		state from the previous transfer prevents the
-		retry from occurring properly.
-	
-		Host message loop changes.
-	
-		Add a possible workaround for hardware failing
-		to record the write to HDMAEN.  We simply loop
-		setting this bit until the hardware finally
-		acknowledges that it is set.  The seems to
-		only be required on SCSI writes to IBM Daytona
-		drives.  More investigation is needed.
-	
-	aic79xx_osm.c:
-		Update for changes in host message loop
-		handling.
-	
-		Remove call to ahd_search_disc_list() that
-		is nolonger required.
-	
-	aic79xx_pci.c:
-		Add in new bug definitions.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#47 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#30 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#27 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#28 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#23 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#6 edit
-
-Change 935 by gibbs@aslan on 2002/04/17 10:28:58
-
-	aic79xx.c:
-		Perform a 1000us delay after asserting CHIPRST
-		and prior to touching an card registers.  The
-		delay is not exact due to PCI write buffering
-		semantics, but it should still be sufficient to
-		avoid touching chip registers prior to the chip
-		becoming ready for such accesses.
-	
-		Modify ahd_chip_init() to leave the chip in a
-		paused state in AHD_MODE_SCSI.
-	
-		Modify ahd_loadseq() to leave the sequencer paused.
-		Code that follows such a call must call ahd_restart().
-	
-		Perform a chip reset on every outgoing bus reset
-		on rev A hardware.
-	
-	aic79xx.h:
-		Add AHD_SCSIRST_BUG.
-	
-	aic79xx_inline.h:
-		Don't reset the channel just prior to panicing due
-		to a mode assertion.  This could cause an infinite
-		recursion loop if the mode assertion is in
-		ahd_reset_channel or something it calls.
-	
-	aic79xx_pci.c:
-		Add in scsi bus reset requires chiprst bug to ahd->bugs.
-	
-	aic7xxx.c:
-		Perform a 1000us delay after asserting CHIPRST
-		and prior to touching an card registers.  The
-		delay is not exact due to PCI write buffering
-		semantics, but it should still be sufficient to
-		avoid touching chip registers prior to the chip
-		becoming ready for such accesses.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#46 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#29 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#19 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#22 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#58 edit
-
-Change 931 by gibbs@aslan on 2002/04/16 19:19:23
-
-	aic79xx.c:
-		Break out post CHIPRST initialization from ahc_init()
-		so that we can reset the chip for workarounds.
-	
-	aic79xx.h:
-		AHD_PCIX_RST_BUG -> AHD_PCIX_CHIPRST_BUG.
-	
-	aic79xx.reg:
-		Move CMDSIZE_TABLE to the end of our current scratch
-		ram definitions and initialize it in ahd_chip_init().
-	
-	aic79xx_pci.c:
-		Pull some PCI initialization code that needs to be
-		performed after every CHIPRST into aic79xx.c:ahd_chip_init().
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#45 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#28 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#26 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#21 edit
-
-Change 930 by gibbs@overdrive on 2002/04/15 19:22:04
-
-	aic79xx_osm.h:
-		Turn on all debugging code.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#15 edit
-
-Change 929 by scottl@scottl-hobbiton-linux on 2002/04/15 15:45:29
-
-	Bump the driver version to ALPHA 5
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#14 edit
-
-Change 912 by gibbs@aslan on 2002/04/15 13:30:23
-
-	aic79xx.c:
-		Style fix.
-	
-		Move chip bug bitmap setup into the "chip personality"
-		handlers.
-	
-		Include a bus description in ahd_controller_info().
-	
-	aic79xx.h:
-		Add a mask for bug workarounds that can be disabled
-		if we are not in PCI-X mode.
-	
-		Add bus_description to our softc.
-	
-	aic79xx_pci.c:
-		Initialize ahd->bus_description.
-	
-		Disable PCI-X specitific workarounds when operating
-		in PCI mode.
-	
-		Remove a few workarounds if we are an A4 chip.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#44 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#27 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#20 edit
-
-Change 905 by gibbs@overdrive on 2002/04/11 22:00:57
-
-	aic7xxx_osm.h:
-		Bump to version 6.2.6.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#78 edit
-
-Change 902 by scottl@scottl-hobbiton-mod_devel1 on 2002/04/10 23:30:00
-
-	aic79xx.c:
-		Dump our card state should we encounter an unhandled
-		SCSIINT.  Make the panic message for this case more
-		explicit too.
-	
-		Add a diagnostic for a new PPR Negotiation that should
-		end in a Busfree.  This is the case of a pre-existing
-		IU_REQ agreement at the time of a Negotiation.
-	
-		Dump the card state when we encounter an unexpected busfree.
-	
-		Always refresh the neg-table when calling ahd_set_syncrate()
-		to handle the case of the sequencer setting the ENATNO bit
-		for a MK_MESSAGE request.  We will always renegotiate in that
-		case if this is a packetized request.
-	
-		Correct the logic for setting MSG_FLAG_EXPECT_PPR_BUSFREE.
-		This should be set in the case of a pre-existing IU_REQ
-		agreement as well as if the IU_REQ agreement has changed.
-	
-		Kill a redundant call to ahd_update_neg_table.
-	
-		When dumping card state, also dump platform card state.
-	
-	aic79xx_osm.c:
-		user uint16_t rather than uint8_t for the array of user
-		settable tag limits.  We will eventually allow 512 as
-		the max.
-	
-		Properly propogate sense data in status packets back
-		to the user.
-	
-		Dump card state in the abort and target reset handlers.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#43 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#13 edit
-
-Change 899 by scottl@scottl-hobbiton-linux on 2002/04/09 16:25:34
-
-	Remove seeprom_erase
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#14 integrate
-
-Change 895 by gibbs@overdrive on 2002/04/09 15:17:06
-
-	aic79xx_host.h:
-	aic79xx_osm.c:
-	aic7xxx_host.h:
-	aic7xxx_osm.c:
-		Move max_sectors initialization back into osm.c so
-		that it can be conditionalized on Linux kernel verison.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_host.h#6 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#12 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_host.h#9 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#91 edit
-
-Change 894 by scottl@scottl-hobbiton-linux on 2002/04/09 15:16:00
-
-	Add support for reading and writing the SEEPROM through the
-	/proc interface.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#40 integrate
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#13 integrate
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#9 integrate
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#37 integrate
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#15 integrate
-
-Change 891 by gibbs@overdrive on 2002/04/09 13:35:39
-
-	aic79xx_seq.h:
-	aic79xx_reg.h:
-	aic7xxx_seq.h:
-	aic7xxx_reg.h:
-		Start generating firmware at the toplevel only.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#4 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#4 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#4 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#4 edit
-
-Change 886 by gibbs@overdrive on 2002/04/07 23:42:22
-
-	aic79xx.c:
-		Kill debugger calls that are unsupported by Linux.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#42 edit
-
-Change 884 by gibbs@overdrive on 2002/04/07 21:46:23
-
-	aicasm/Makefile:
-		Reverse integration.
-		Kill .NOTPARALLEL.  Use flex's -o.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/Makefile#12 integrate
-
-Change 883 by gibbs@aslan on 2002/04/07 21:40:53
-
-	aic79xx.c:
-		When handling the "expected" unexpected busfree
-		after a negotiation, freeze the scb and the device
-		queue so that ordering is preserved.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#41 edit
-
-Change 882 by gibbs@aslan on 2002/04/07 21:21:53
-
-	aic79xx.c:
-	aic79xx.h:
-	aic79xx.seq:
-		Add a workaround for the outstanding split bug.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#40 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#26 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#27 edit
-
-Change 881 by gibbs@overdrive on 2002/04/07 21:10:53
-
-	aic79xx.c:
-	aic7xxx.c:
-		Kill return argument.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#39 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#57 edit
-
-Change 880 by gibbs@overdrive on 2002/04/07 21:09:54
-
-	aic79xx.h:
-	aic7xxx.h:
-		Kill return argument.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.h#25 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#39 edit
-
-Change 879 by gibbs@overdrive on 2002/04/07 21:06:29
-
-	aic79xx.c:
-	aic79xx.h:
-	aic7xxx.c:
-	aic7xxx.h:
-		Add a routine to verify that a softc is still
-		on our list and configured.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#38 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#24 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#56 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#38 edit
-
-Change 878 by gibbs@overdrive on 2002/04/07 21:04:35
-
-	aic79xx_host.h:
-	aic7xxx_host.h:
-		Add a missing comma.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_host.h#5 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_host.h#8 edit
-
-Change 875 by gibbs@overdrive on 2002/04/07 18:16:42
-
-	aic79xx_host.h:
-	aic7xxx_host.h:
-	aic79xx_osm.c
-	aic7xxx_osm.c
-		Set "max_sectors" in our host template so that the Linux
-		SCSI layer doesn't foolishly limit our I/O size.
-	
-		Set a few additional static fields into the template
-		initialization macro.
-	
-	aic7xxx_osm_pci.c:
-	aic79xx_osm_pci.c:
-		Use ah[dc]_find_softc rather than do a brute force lookup
-		in multiple places.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_host.h#4 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#11 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#6 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_host.h#7 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#90 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#31 edit
-
-Change 873 by gibbs@aslan on 2002/04/05 12:29:11
-
-	aic79xx.c:
-		Handle a few more sequencer interrupts.
-	
-		Monitor sstat3 during SCSIINT handling.
-	
-		Remove a duplicate comment.
-	
-		Enable checking of negotiation table and output
-		sync FIFO parity errors.
-	
-		When traversing the execution queue, only complain
-		of list corruption after itterating over max SCB
-		entries.  Since elements can be queued outside of
-		the per-target lists, the num target limit coult
-		unintentionally fire.
-	
-		Correct a bug in the stitching of the TID lists in
-		the execution queue.  We could lose a whole TID
-		list in certain scenarios.
-	
-		When handling status errors, save and restore the
-		current mode as well as clear any critical sections
-		in the firmware.  We might otherwise corrupt sequencer
-		state.
-	
-		Add some more information to the ahd_dump_card_state()
-		output.
-	
-		Add a routine to dump out the state of all SCBs.  This
-		might be useful from the debugger.
-	
-	aic79xx.h:
-		Prototype ahd_dump_scbs().
-	
-	aic79xx.seq:
-		Stop using MK_MESSAGE as a flag for "dead" SCBs.
-		We should come up with another mechanism, but this
-		might confuse the cleanup of the execution queue
-		for SCBs that selected out with atn asserted.
-	
-		Use HDMAEN as a definitive test to see if a
-		saveptr interrupt is for a snapshot or not.
-	
-	aic79xx_pci.c:
-		Add a comma to the table of pci_status_strigs, so we
-		don't attempt to printf garbage.  Oops.
-	
-		Clear latched pci status at the end of our PCI error
-		handler so that the pci error interrupt is de-asserted.
-		More logic is needed here to handle PCI-X errors.
-	
-	aic7xxx.c:
-		If we have an overrun on an auto-request sense, report
-		autosense fail, not data-run-error.
-	
-		Use AHC_NUM_TARGETS rather than a hard coded 16.
-	
-		Fix a typo.
-	
-	aic7xxx.reg:
-		Add a comment to the DIRECTION bit so I can stop
-		looking it up its polarity in the data book all the time.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#37 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#23 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#25 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#26 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#19 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#55 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#27 edit
-
-Change 840 by gibbs@overdrive on 2002/03/26 23:33:12
-
-	p4 integrate -r -b redhat-aic7xxx-2.4.7_10_i386.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#26 integrate
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#39 integrate
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#36 integrate
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#14 integrate
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.h#9 integrate
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#14 integrate
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_insformat.h#8 integrate
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_macro_gram.y#2 integrate
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_macro_scan.l#2 integrate
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#10 integrate
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#13 integrate
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#10 integrate
-
-Change 839 by gibbs@overdrive on 2002/03/26 23:32:40
-
-	Integrate -r -b redhat-aic7xxx-2.4.7_10_i386
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#89 integrate
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#14 integrate
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#3 branch
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#3 branch
-
-Change 813 by gibbs@overdrive on 2002/03/13 20:18:34
-
-	aic79xx_osm.h:
-		Bump version number to 0.0.4 for Alpha 4 release.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#13 edit
-
-Change 800 by gibbs@overdrive on 2002/03/13 14:56:13
-
-	aic79xx.c:
-		Remove TRACEPOINT6 code which is no longer used.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#36 edit
-
-Change 795 by gibbs@overdrive on 2002/03/13 14:39:50
-
-	aic79xx_osm.h:
-		Add an implementation for scsi_4btoul().
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#12 edit
-
-Change 791 by gibbs@aslan on 2002/03/13 14:02:50
-
-	aic79xx.c:
-		Reset the bus if we encounter an overrun on a
-		status packet.
-	
-		Implement the AHD_CLRLQO_ATUTOCLR_BUG workaround.
-		We just need to manually clear the CLRLQO registers
-		when we use them.
-	
-		Roll LQISTAT1 handling into the
-		ahd_handle_transmission_errror(), handler.
-	
-		Don't qualify the BUSFREE status with ENBUSFREE.  The
-		chip may well have moved on to an handled another
-		transaction on the bus, so we simply cannot rely on
-		ENBUSFREE giving us an acuate sense of whether this
-		is a true BUSFREE interrupt.  Right now we defer
-		looking at BUSFREE interrupts until last in the hope
-		that we'll ignore spurious values of this bit by handling
-		the conditions we are sure of first.
-	
-		In handling busfree conditions allow the handler for that
-		condition to either unpause the sequencer or to force a
-		sequencer reset.
-	
-		Don't rely on the PACKETIZED status bit.  It corresponds
-		to the *last* connection on the bus, not the current one.
-		Instead rely on LQISTAT1 giving us acurate information
-		about transmission errors that correspond to packetized
-		transfers.
-	
-		Handle unexpected busfrees that indicate the target
-		saw a bad CRC in one of our outgoing LQs.
-	
-		Add optional debugging information for kernel handled
-		message phases.
-	
-		Fix a spelling error.
-	
-		Add loging for QAS messages that occur when they shouldn't.
-		We will reject the message which should force a busfree.
-	
-		Add more bug entries.
-	
-		When cleaning up entries from the waiting for selection
-		queue, handle MK_MESSAGE SCBs specially as they are not
-		now placed into the per-target-id queues.
-	
-		Add more logging for sense packets.
-	
-		Link completed SCBs using a different set of link
-		pointers.  This allows us to put the SCBs on the
-		complete queue without fear of corrupting the waiting
-		for selection queue if we have yet to see a pending
-		SELDO.
-	
-		Log the contents of the SCSIPHASE register in
-		ahd_dump_card_state().
-	
-	aic79xx.h:
-		Add more bug entries.
-	
-		Add a debugging flag for printing information during
-		kernel handled message phases.
-	
-	aic79xx.reg:
-		LQOBUSFREE1 -> LQOBUSFREE
-		LQOPHACHG1  -> LQOPHACHGINPKT
-	
-		CLRLQOBUSFREE1 -> CLRLQOBUSFREE
-		CLRLQOPHACH1   -> CLRLQOPHCHGINPKT
-	
-		ENLQOBUSFREE1 -> ENLQOBUSFREE
-		ENLQOPHACHG1 -> ENLQOPHACHGINPKT
-	
-		LQOPHACHG0 -> LQOPHACHGOUTPKT
-	
-		Add SCB_NEXT_COMPLETE link in the CDB pad
-		area.
-	
-	aic79xx.seq:
-		Queue incoming MK_MESSAGE SCBs separately so as
-		to ensure we see the MK_MESSAGE bit on the outgoing
-		selection that will send this SCB.
-	
-		Convert all complete queue operations to use the
-		SCB_NEXT_COMPLETE link.
-	
-		Start adding more critical section wrappers.  This
-		work still needs to be augmented and reviewed.
-	
-		When selecting out with a SCB that has MK_MESSAGE
-		set, don't bother clearing NEGPPROPTS.  We now
-		look for the MK_MESSAGE flag in our SELDO handler
-		and can thus determine that this is actually a
-		"nonpackreq" selection.
-	
-		Add in the workaround for AHD_AUTOFLUSH_BUG.
-	
-		Correctly set the transfer size for status packets
-		so we don't think we've had an overrun.
-	
-		Enhance, I hope, the workaround for the PCIX arbiter
-		hang.  We also now install the hang detection for
-		legacy.
-	
-	aic79xx_pci.c:
-		Take a first shot at handling PCI/PCI-X errors.  More
-		work is required here.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#35 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#22 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#24 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#25 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#18 edit
-
-Change 779 by gibbs@overdrive on 2002/03/11 17:55:24
-
-	aic79xx_osm.c:
-		Disable ABORT and BDR attempts until error recovery
-		is better fleshed out.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#10 edit
-
-Change 778 by gibbs@overdrive on 2002/03/11 17:55:02
-
-	aic79xx_osm.h:
-		Remove EISA/VL defines that don't apply to the
-		hardware supported by this driver.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#11 edit
-
-Change 767 by gibbs@aslan on 2002/03/06 15:10:06
-
-	aic79xx_pci.c:
-		Add a #define for the A4 revision number.
-	
-		Add a placeholder for the B0 revision number.
-	
-		Disable pending PCI REQ assertion on anything
-		younger than the B0.  It doesn't work if both
-		channels are active.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#17 edit
-
-Change 765 by gibbs@overdrive on 2002/03/04 21:59:30
-
-	aic79xx_osm.h:
-		Bump version number to 0.0.3.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#10 edit
-
-Change 764 by gibbs@overdrive on 2002/03/04 21:59:14
-
-	Handle integrate -r from redhat-aic79xx-2.4.7_10_i386
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_host.h#3 integrate
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#5 integrate
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_proc.c#3 integrate
-
-Change 761 by gibbs@overdrive on 2002/03/04 21:49:07
-
-	aic79xx.c:
-		Remove critical section clearing printfs.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#34 edit
-
-Change 759 by gibbs@moria on 2002/03/04 21:36:11
-
-	aic79xx.c:
-		In ahd_devlimited_syncrate(), treat the precomp enable
-		bit specially.  This is bit should be acted on regardless
-		of our goal for having the target precomp for us.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#33 edit
-
-Change 755 by gibbs@aslan on 2002/03/04 12:59:48
-
-	aic79xx_pci.c:
-		Only attach to A3 or newer H2A2 parts.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#16 edit
-
-Change 754 by gibbs@aslan on 2002/03/04 10:43:45
-
-	aic79xx.c:
-		Convert ahd_assert_atn to an inline.
-	
-		Add a comment indicating that blindly clearing out the
-		DMA channels in ahd_restart() is probably a bad thing.
-		Perhaps the best place to do this is in ahd_abort_scbs()
-		which should be able to match the SCB owning the FIFO
-		with the SCB pattern to kill off, but that is not completely
-		clear yet.
-	
-		Add the beginnings of an "illegal non-packetized phase"
-		handler.  This interrupt will be invoked should a target,
-		with whom we've negotiated packetized, take us to a non-pkt
-		and non-message phase.  The only situation we currently
-		handle is the case of a target taking us to the command
-		phase on the first REQ of what should be a packetized
-		connection.  Our response to that condition is:
-			o Downgrade our current negotiation to async/narrow.
-			o Embed a TUR into the SCB to replace whatever,
-			  possibly media altering, command was originally
-			  in the SCB.
-			o Clear any tag information in the SCB and set
-			  MK_MESSAGE.
-			o Set MSG_OUT to HOST_MSG, SAVED_SCSIID to the
-			  scb's SCSIID, and SAVED_LUN to 0 (no identify
-			  message, so target believes lun is 0).
-			o Clear the packetized flag in the SCB and set
-			  SCB_ABORT and SCB_CMDPHASE_ABORT.
-			o assert ATN.
-			o Prepare the transaction to complete with
-			  CAM_REQUEUE_REQ.
-			o When the Abort completes, we only abort the
-			  SCB that encountered the error.  This behavior
-			  and the actual error code we return should be
-			  reviewed.
-	
-		Convert some manual traversals of the phase table to calls
-		to ahd_lookup_phase_entry().
-	
-		Port the MKMSG_FAILED sequencer interrupt handler.
-	
-		If busfreetime is non-zero, but we were performing nonpackreq
-		recovery, use the ahd_handle-nonpkt_busfree() handler.
-	
-		Handle the case of a new PPR negotiation to a target that
-		we have already negotiated packetized to.  We should get
-		a busfree in this case.  The remainder of the handling of
-		this situation is in the sequencer.
-	
-		Correct a bug in the critical section stepping code.  We
-		were in the wrong register window when trying to clear
-		SIMODE0.
-	
-		If we are currently packetized with a target, the only
-		valid messages we can send at the beginning of the connection
-		are PPR or TUR.  Therefore, supress the identify messages.
-	
-		Create a msg_flags field in ahd_softc.  This replaces
-		msg_expect_ppr_busfree since we need to also record
-		whether the state of IU_REQ changed.
-	
-		Fix a grammer bug.
-	
-		Clear all message flags in the SCB during a request sense
-		that only intends to renegotiate with the device.
-	
-		Kill a debugging printf.
-	
-		Display the contents of SIMODE1, OPTIONMODE and MAXCMDCNT
-		during ahd_dump_card_state().
-	
-	aic79xx.h:
-		Make AHD_SENSE_BUFSIZE a sequencer visible value.
-	
-		Redefine our Hardware SCB format so we can embed a
-		sense address in the case of cdbs <= 12 bytes or using
-		a pointer.
-	
-		Add the SCB_CMDPHASE_ABORT flag.
-	
-		Add ahd_msg_flags.
-	
-	aic79xx.reg:
-		Document the DIRECTION bit in DFCNTRL.
-	
-		Redefine our Hardware SCB format so we can embed a
-		sense address in the case of cdbs <= 12 bytes or using
-		a pointer.
-	
-		Make AHD_SENSE_BUFSIZE a sequencer visible value.
-	aic79xx.seq:
-		When we are about to select a device and the first SCB
-		has MK_MESSAGE set, make sure to enable ENAUTOATNO.
-	
-		Treat LQOPHACHG1 as an unexpected_nonpkt_phase.
-	
-		Make the PCI-X workaround for the hung arbiter even
-		more selective in the legacy case.  We only need to
-		check for the hang condition if we are disconnecting
-		in the middle of a transfer.
-	
-		Enhance a comment about BITBUCKET handling in the
-		non-pack case.
-	
-		Correct a lable jump that should have been changed in
-		the last commit to this file.  The previous lable has
-		been removed.
-	
-		Add support for handling a status packet without host
-		intervention if the sense address is embedded in the
-		SCB.
-	
-	aic79xx_inline.h:
-		Embed the sense address in the SCB if there is room. 
-	
-	aic79xx_pci.c:
-		Be more careful about endianess when printing out
-		serial eeprom contents.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#32 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#21 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#23 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#24 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#18 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#15 edit
-
-Change 697 by gibbs@overdrive on 2002/02/26 17:49:44
-
-	aic79xx.c:
-	aic79xx.h:
-	aic79xx.reg:
-	aic79xx.seq:
-	aic79xx_pci.c:
-		Integrate changes from redhat-aic7xxx-2.4.7_10_i386
-		back into the core files.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#31 integrate
-... //depot/aic7xxx/aic7xxx/aic79xx.h#20 integrate
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#22 integrate
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#23 integrate
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#14 integrate
-
-Change 673 by gibbs@overdrive on 2002/02/11 16:36:16
-
-	aic79xx_osm.h:
-		Bump driver version to 0.0.2.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#9 edit
-
-Change 671 by gibbs@overdrive on 2002/02/11 16:28:09
-
-	aic7xxx_pci.c:
-		Pretend that there are no cables if we have
-		an illegal cable configuration.  This may fix
-		problems on certain HP Kayak systems.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#35 edit
-
-Change 668 by gibbs@overdrive on 2002/02/11 15:13:10
-
-	aic79xx.reg:
-	aic79xx.seq:
-		Convert to text+ko
-	
-	aic79xx_pci.c:
-		Avoid endian issues when dumping the seeprom.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#21 integrate
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#22 integrate
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#13 edit
-
-Change 667 by gibbs@aslan on 2002/02/11 15:09:27
-
-	aic79xx.c:
-		Add additional bug entries for Rev A errata.
-	
-		Don't attempt to perform current sensing on a
-		board unless we know that it is supported.  Doing
-		current sensing when it is not support messes up
-		our external termination.
-	
-		Leave the force U160 stuff in place, but allow
-		U320 transfers now.
-	
-		Don't attempt QAS or read streaming on A2 hardware.
-	
-	aic79xx.h:
-		Add more bug entries.
-	
-	aic79xx.seq:
-		Add comment about why we have to check SEDO when
-		ENSELO is clear but prior to starting a new selection.
-	
-		Add critical sections around some of the places they
-		are needed.
-	
-		Add a first cut workaround for one of the PCI-X bugs.
-		This particular bug is fixed in A3.
-	
-		Conditionalize the last bit of the CURRSCB workaround.
-	
-		Set the SCB_DMA flag when we initiate an SCB dma.  This
-		is the beginning of work to handle cancled DMAs from
-		the qinfifo.
-	
-	aic79xx_pci.c:
-		Only do current sensing if the card supports it.
-	
-		Truely initialize termctl if auto-term sensing fails.
-	
-		Set the low primary termination prior to setting any
-		external termination.  This mirrors what CHIM does.
-	
-		Add a mode assert to ahd_write_flexport.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#30 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#19 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#21 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#12 edit
-
-Change 663 by gibbs@overdrive on 2002/02/11 13:13:52
-
-	aic7xxx_osm.h:
-		Bump Linux aic7xxx driver version number to 6.2.5.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#77 edit
-
-Change 661 by gibbs@overdrive on 2002/02/11 13:11:36
-
-	aicasm/Makfile:
-		Bring .NOTPARALLEL change into the top level.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/Makefile#11 integrate
-
-Change 657 by scottl@scottl-linux on 2002/02/06 19:17:16
-
-	Serialize Makefiles.  Use CONFIG_AIC79XX_BUILD_FIRMWARE flag.
-
-Affected files ...
-
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/Makefile#2 edit
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/Makefile#2 edit
-
-Change 650 by gibbs@overdrive on 2002/01/28 17:35:10
-
-	aic79xx_osm.c:
-		Limit tag depth to 16 under Linux to avoid QUEUE_FULL
-		issues with Maxtor drives.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#9 edit
-
-Change 648 by gibbs@overdrive on 2002/01/28 17:29:46
-
-	aic79xx.c:
-		Correct typo.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#29 edit
-
-Change 647 by gibbs@overdrive on 2002/01/28 17:22:18
-
-	aic79xx.c:
-		Move more diagnostic printfs under AHD_DEBUG.
-	
-		Force 160 as the maximum sync speed until 320
-		issues are ironed out.
-	
-	aic79xx_pci.c:
-		Kill some diagnostic printfs.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#28 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#11 edit
-
-Change 646 by gibbs@overdrive on 2002/01/28 17:18:52
-
-	aic79xx_osm.h:
-		Bump Linux version number to for 0.0.1 release.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#8 edit
-
-Change 644 by gibbs@overdrive on 2002/01/28 16:43:03
-
-	aic79xx_osm.c:
-		Remove reference to ahc->seltime_b.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#8 edit
-
-Change 643 by gibbs@aslan on 2002/01/28 15:18:56
-
-	aic79xx.c:
-	aic79xx.h:
-	aic79xx.reg:
-	aic79xx.seq:
-	aic79xx_inline.h:
-	aic79xx_pci.c:
-		First pass at NONPACKREQ and CRC error handling.
-	
-		Turn on digital filtering and some additional IOCELL
-		workarounds.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#27 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#18 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#20 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#20 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#17 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#10 edit
-
-Change 640 by gibbs@aslan on 2002/01/27 14:15:43
-
-	aic79xx.c:
-	aic79xx.h:
-	aic79xx.reg:
-		Correct the selection timeout period on Rev A
-		parts where it is twice as long as the set value.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#26 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#17 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#19 edit
-
-Change 639 by gibbs@aslan on 2002/01/26 19:39:29
-
-	aic79xx.c:
-		Remove debugging printfs and place others inside
-		AHD_DEBUG statements.
-	aic79xx.h:
-	aic79xx_pci.c:
-		Complete support for termination current sensing.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#25 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#16 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#9 edit
-
-Change 637 by gibbs@overdrive on 2002/01/25 14:07:51
-
-	Firmware is generated in the leaf branch nodes.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#3 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#3 delete
-
-Change 626 by gibbs@overdrive on 2002/01/25 12:55:44
-
-	Remove extra blank line.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#76 edit
-
-Change 623 by gibbs@overdrive on 2002/01/25 12:48:59
-
-	Add text+ko and finish cleanup of no_probe.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_host.h#2 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#7 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#7 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#4 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_proc.c#2 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#2 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#2 edit
-
-Change 621 by gibbs@overdrive on 2002/01/25 12:39:17
-
-	aic79xx_osm.h:
-	aic7xxx_osm.h:
-		linux/malloc.h has been deprecated in 2.4.15.  Use
-		linux/slab.h instead which has been available since 2.4.0.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#6 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#75 edit
-
-Change 615 by gibbs@overdrive on 2002/01/24 17:27:58
-
-	aic79xx_osm.c:
-		Lose references to EISA and VLB inherited from
-		aic7xxx driver.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#6 edit
-
-Change 608 by gibbs@overdrive on 2002/01/24 13:32:31
-
-	To keep IDs coherent, we'll generate these in each branch we
-	ship to customers.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#2 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#2 delete
-
-Change 603 by gibbs@overdrive on 2002/01/24 13:00:46
-
-	Add assembled aic79xx firmware to revision control.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_reg.h#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_seq.h#1 add
-
-Change 601 by gibbs@overdrive on 2002/01/24 12:57:18
-
-	Add assembled firmware to revision control.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_reg.h#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_seq.h#1 add
-
-Change 587 by gibbs@overdrive on 2002/01/23 14:36:02
-
-	aic7xxx_osm.c:
-		Integrate PROBE_VL config changes back into Linux
-		driver mainline.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#88 integrate
-
-Change 580 by gibbs@overdrive on 2002/01/22 22:13:15
-
-	Integrate from linux-aic7xxx-2.4.0 -> linux-aic79xx-2.4.0
-
-Affected files ...
-
-... //depot/linux-aic79xx-2.4.0/drivers/ide/cmd640.c#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/Config.in#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7770_osm.c#2 integrate
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_osm.c#2 integrate
-
-Change 578 by gibbs@overdrive on 2002/01/22 21:48:24
-
-	aic7xxx_osm.c:
-		Protect against config not defining CONFIG_AIC7XXX_PROBE_EISA_VL
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#87 edit
-
-Change 576 by gibbs@overdrive on 2002/01/22 21:42:02
-
-	aic7770_osm.c:
-		Don't refer to aic7xxx_no_probe.  The check for
-		whether to perform EISA/VL probes was made prior
-		to the call to the EISA/VL probe.
-	
-	aic7xxx_osm.c:
-		Add a configuration option for EISA/VL probing.
-		It will default to off to avoid clobbering PCI
-		devices that frequest those I/O ranges.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7770_osm.c#11 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#86 edit
-
-Change 575 by gibbs@overdrive on 2002/01/22 21:34:25
-
-	aic7xxx_osm.c:
-		Default to not scanning for EISA/VL adapters.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#85 edit
-
-Change 569 by gibbs@aslan on 2002/01/22 13:56:22
-
-	aic79xx.c:
-		Clean up warnings related to currently disabled code.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#24 edit
-
-Change 568 by gibbs@overdrive on 2002/01/22 13:49:27
-
-	aic79xx_osm.h:
-		Include scsi_iu.h.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#5 edit
-
-Change 567 by gibbs@aslan on 2002/01/22 13:46:00
-
-	aic79xx.c:
-		Remove call to Debugger() which is not supported
-		under Linux.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#23 edit
-
-Change 566 by gibbs@overdrive on 2002/01/22 13:43:07
-
-	Initial aic79xx port to 2.4.0.
-
-Affected files ...
-
-... //depot/linux-aic79xx-2.4.0/COPYING#1 branch
-... //depot/linux-aic79xx-2.4.0/CREDITS#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/00-INDEX#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/BUG-HUNTING#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/Changes#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/CodingStyle#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/Configure.help#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/DMA-mapping.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/DocBook/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/DocBook/kernel-api.tmpl#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/DocBook/kernel-hacking.tmpl#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/DocBook/kernel-locking.tmpl#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/DocBook/mcabook.tmpl#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/DocBook/mousedrivers.tmpl#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/DocBook/parport-multi.fig#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/DocBook/parport-share.fig#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/DocBook/parport-structure.fig#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/DocBook/parportbook.tmpl#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/DocBook/sis900.tmpl#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/DocBook/via-audio.tmpl#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/DocBook/videobook.tmpl#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/DocBook/wanbook.tmpl#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/DocBook/z8530book.tmpl#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/IO-mapping.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/IRQ-affinity.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/LVM-HOWTO#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/README.DAC960#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/README.moxa#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/SubmittingDrivers#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/SubmittingPatches#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/VGA-softcursor.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/Netwinder#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/README#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/SA1100/Assabet#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/SA1100/Brutus#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/SA1100/CERF#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/SA1100/GraphicsClient#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/SA1100/Itsy#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/SA1100/LART#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/SA1100/PLEB#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/SA1100/Pangolin#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/SA1100/Tifon#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/SA1100/Victor#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/SA1100/empeg#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/SA1100/nanoEngine#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/SA1100/serial_UART#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/Setup#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/empeg/README#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/empeg/ir.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/empeg/mkdevs#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/nwfpe/NOTES#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/nwfpe/README#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/nwfpe/README.FPE#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/arm/nwfpe/TODO#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/binfmt_misc.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/cachetlb.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/cciss.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/cdrom/00-INDEX#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/cdrom/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/cdrom/aztcd#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/cdrom/cdrom-standard.tex#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/cdrom/cdu31a#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/cdrom/cm206#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/cdrom/gscd#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/cdrom/ide-cd#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/cdrom/isp16#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/cdrom/mcd#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/cdrom/mcdx#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/cdrom/optcd#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/cdrom/sbpcd#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/cdrom/sjcd#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/cdrom/sonycd535#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/computone.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/cpqarray.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/devices.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/digiboard.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/digiepca.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/dnotify.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/exception.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/fb/00-INDEX#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/fb/aty128fb.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/fb/clgenfb.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/fb/framebuffer.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/fb/internals.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/fb/matroxfb.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/fb/modedb.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/fb/sa1100fb.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/fb/tgafb.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/fb/vesafb.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/00-INDEX#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/Locking#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/adfs.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/affs.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/bfs.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/coda.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/cramfs.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/devfs/ChangeLog#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/devfs/README#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/devfs/ToDo#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/devfs/boot-options#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/devfs/rc.devfs#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/ext2.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/fat_cvf.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/hpfs.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/isofs.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/ncpfs.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/ntfs.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/proc.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/romfs.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/smbfs.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/sysv-fs.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/udf.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/ufs.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/umsdos.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/vfat.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/filesystems/vfs.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/floppy.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/ftape.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/hayes-esp.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/highuid.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/i2c/dev-interface#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/i2c/functionality#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/i2c/i2c-protocol#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/i2c/proc-interface#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/i2c/smbus-protocol#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/i2c/summary#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/i2c/ten-bit-addresses#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/i2c/writing-clients#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/i386/IO-APIC.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/i386/boot.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/i386/zero-page.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/ia64/README#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/ia64/efirtc.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/ide.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/initrd.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/ioctl-number.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isapnp.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/00-INDEX#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/CREDITS#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/HiSax.cert#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/INTERFACE#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/INTERFACE.fax#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/README#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/README.FAQ#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/README.HiSax#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/README.act2000#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/README.audio#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/README.avmb1#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/README.concap#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/README.diversion#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/README.eicon#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/README.fax#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/README.hfc-pci#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/README.hysdn#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/README.icn#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/README.pcbit#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/README.sc#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/README.syncppp#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/README.x25#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/isdn/syncPPP.FAQ#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/java.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/joystick-api.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/joystick-parport.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/joystick.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/kbuild/00-INDEX#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/kbuild/bug-list.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/kbuild/commands.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/kbuild/config-language.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/kbuild/makefiles.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/kernel-doc-nano-HOWTO.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/kernel-docs.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/kernel-parameters.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/kmod.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/locks.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/logo.gif#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/logo.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/m68k/00-INDEX#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/m68k/README.buddha#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/m68k/kernel-options.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/magic-number.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/mandatory.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/mca.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/md.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/memory.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/mkdev.cciss#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/mkdev.ida#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/modules.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/moxa-smartio#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/mtrr.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/nbd.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/00-INDEX#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/3c505.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/6pack.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/8139too.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/Configurable#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/DLINK.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/PLIP.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/README.sb1000#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/alias.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/arcnet-hardware.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/arcnet.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/atm.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/ax25.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/baycom.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/bridge.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/comx.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/cops.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/cs89x0.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/de4x5.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/decnet.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/depca.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/dgrs.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/dmfe.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/eql.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/ethertap.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/ewrk3.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/filter.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/fore200e.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/framerelay.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/ip-sysctl.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/ip_dynaddr.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/ipddp.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/iphase.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/irda.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/lapb-module.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/ltpc.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/multicast.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/ncsa-telnet#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/net-modules.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/netdevices.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/olympic.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/policy-routing.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/pt.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/ray_cs.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/routing.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/shaper.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/sis900.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/sk98lin.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/skfp.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/smc9.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/smctr.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/soundmodem.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/tcp.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/tlan.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/tms380tr.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/tulip.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/tuntap.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/vortex.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/wan-router.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/wanpipe.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/wavelan.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/x25-iface.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/x25.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/networking/z8530drv.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/nfsroot.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/nmi_watchdog.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/oops-tracing.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/paride.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/parisc/00-INDEX#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/parisc/IODC.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/parisc/debugging#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/parisc/mm#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/parisc/registers#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/parport-lowlevel.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/parport.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/pci.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/pcwd-watchdog.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/pm.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/powerpc/00-INDEX#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/powerpc/SBC8260_memory_mapping.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/powerpc/ppc_htab.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/powerpc/smp.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/powerpc/sound.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/powerpc/zImage_layout.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/ramdisk.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/riscom8.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/rtc.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/s390/DASD#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/s390/cds.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/scsi-generic.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/scsi.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/serial-console.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sgi-visws.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/smart-config.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/smp.tex#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/smp.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/AD1816#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/ALS#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/AWE32#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/AudioExcelDSP16#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/CMI8330#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/CMI8338#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/CS4232#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/ChangeLog.awe#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/ChangeLog.multisound#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/ESS#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/ESS1868#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/INSTALL.awe#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/Introduction#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/MAD16#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/Maestro#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/MultiSound#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/NEWS#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/NM256#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/OPL3#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/OPL3-SA#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/OPL3-SA2#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/Opti#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/PAS16#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/PCM1-pro#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/PSS#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/PSS-updates#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/README.OSS#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/README.awe#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/README.modules#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/README.ymfsb#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/SoundPro#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/Soundblaster#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/Tropez+#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/VIA-chipset#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/VIBRA16#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/Wavefront#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/es1370#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/es1371#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/mwave#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/solo1#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/sonicvibes#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/ultrasound#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/via82cxxx.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sound/vwsnd#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sparc/sbus_drivers.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/specialix.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/spinlocks.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/stallion.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/svga.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sx.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sysctl/README#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sysctl/fs.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sysctl/kernel.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sysctl/sunrpc.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sysctl/vm.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/sysrq.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/telephony/ixj.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/unicode.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/usb/CREDITS#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/usb/URB.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/usb/acm.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/usb/bluetooth.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/usb/dc2xx.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/usb/error-codes.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/usb/hotplug.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/usb/ibmcam.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/usb/input.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/usb/ohci.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/usb/ov511.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/usb/proc_usb_info.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/usb/rio.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/usb/scanner-hp-sane.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/usb/scanner.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/usb/uhci.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/usb/usb-help.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/usb/usb-serial.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/video4linux/API.html#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/video4linux/CQcam.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/video4linux/README.buz#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/video4linux/README.cpia#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/video4linux/bttv/CARDLIST#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/video4linux/bttv/CONTRIBUTORS#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/video4linux/bttv/ICs#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/video4linux/bttv/Insmod-options#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/video4linux/bttv/MAKEDEV#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/video4linux/bttv/Modules.conf#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/video4linux/bttv/PROBLEMS#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/video4linux/bttv/README#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/video4linux/bttv/README.WINVIEW#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/video4linux/bttv/Sound-FAQ#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/video4linux/bttv/Specs#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/video4linux/bttv/THANKS#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/video4linux/radiotrack.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/video4linux/zr36120.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/vm/balance#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/vm/locking#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/vm/numa#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/watchdog.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/xterm-linux.xpm#1 branch
-... //depot/linux-aic79xx-2.4.0/Documentation/zorro.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/MAINTAINERS#1 branch
-... //depot/linux-aic79xx-2.4.0/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/README#1 branch
-... //depot/linux-aic79xx-2.4.0/REPORTING-BUGS#1 branch
-... //depot/linux-aic79xx-2.4.0/Rules.make#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/boot/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/boot/bootloader.lds#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/boot/bootp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/boot/head.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/boot/main.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/boot/tools/mkbb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/boot/tools/objstrip.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/alpha_ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/check_asm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/console.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/core_apecs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/core_cia.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/core_irongate.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/core_lca.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/core_mcpcia.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/core_polaris.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/core_t2.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/core_titan.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/core_tsunami.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/core_wildfire.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/entry.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/es1888.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/head.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/irq_alpha.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/irq_i8259.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/irq_impl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/irq_pyxis.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/irq_smp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/irq_srm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/machvec_impl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/ns87312.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/osf_sys.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/pci_impl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/pci_iommu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/process.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/proto.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/ptrace.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/semaphore.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/signal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/smc37c669.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/smc37c93x.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/smp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/sys_alcor.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/sys_cabriolet.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/sys_dp264.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/sys_eb64p.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/sys_eiger.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/sys_jensen.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/sys_miata.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/sys_mikasa.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/sys_nautilus.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/sys_noritake.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/sys_rawhide.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/sys_ruffian.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/sys_rx164.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/sys_sable.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/sys_sio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/sys_sx164.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/sys_takara.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/sys_titan.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/sys_wildfire.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/kernel/traps.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/callback_srm.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/checksum.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/clear_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/copy_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/csum_ipv6_magic.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/csum_partial_copy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/divide.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/ev6-clear_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/ev6-copy_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/ev6-csum_ipv6_magic.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/ev6-divide.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/ev6-memchr.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/ev6-memcpy.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/ev6-memset.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/ev6-strncpy_from_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/ev6-stxcpy.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/ev6-stxncpy.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/ev67-strcat.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/ev67-strchr.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/ev67-strlen.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/ev67-strlen_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/ev67-strncat.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/ev67-strrchr.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/fpreg.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/io.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/memchr.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/memcpy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/memmove.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/memset.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/srm_printk.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/srm_puts.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/stackcheck.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/stackkill.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/stacktrace.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/strcasecmp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/strcat.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/strchr.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/strcpy.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/strlen.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/strlen_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/strncat.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/strncpy.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/strncpy_from_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/strrchr.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/stxcpy.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/lib/stxncpy.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/math-emu/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/math-emu/math.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/math-emu/qrnnd.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/math-emu/sfp-util.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/mm/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/mm/extable.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/mm/fault.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/mm/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/alpha/vmlinux.lds.in#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/boot/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/boot/bootp/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/boot/bootp/bootp.lds#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/boot/bootp/init.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/boot/compressed/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/boot/compressed/Makefile.debug#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/boot/compressed/head-ftvpci.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/boot/compressed/head-l7200.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/boot/compressed/head-netwinder.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/boot/compressed/head-sa1100.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/boot/compressed/head.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/boot/compressed/hw-bse.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/boot/compressed/ll_char_wr.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/boot/compressed/misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/boot/compressed/setup-sa1100.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/boot/compressed/vmlinux.lds.in#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/boot/install.sh#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/def-configs/a5k#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/def-configs/assabet#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/def-configs/brutus#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/def-configs/cerf#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/def-configs/clps7500#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/def-configs/ebsa110#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/def-configs/empeg#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/def-configs/footbridge#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/def-configs/graphicsclient#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/def-configs/integrator#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/def-configs/lart#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/def-configs/lusl7200#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/def-configs/neponset#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/def-configs/pangolin#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/def-configs/rpc#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/def-configs/shark#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/def-configs/sherman#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/def-configs/victor#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/arch.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/armksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/arthur.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/bios32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/calls.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/debug-armo.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/debug-armv.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/dec21285.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/dma-arc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/dma-footbridge.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/dma-isa.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/dma-rpc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/ecard.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/entry-armo.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/entry-armv.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/entry-common.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/fiq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/ftv-pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/head-armo.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/head-armv.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/init_task.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/isa.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/leds-ebsa110.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/leds-ftvpci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/oldlatches.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/plx90x0.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/process.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/ptrace.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/ptrace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/semaphore.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/signal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/sys_arm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/time-acorn.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/traps.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/kernel/via82c505.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/backtrace.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/changebit.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/clearbit.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/copy_page.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/csumipv6.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/csumpartial.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/csumpartialcopy.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/csumpartialcopyuser.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/delay.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/ecard.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/extractconstants.pl#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/findbit.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/floppydma.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/getconsdata.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/io-acorn.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/io-pcio.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/io-readsb.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/io-readsl.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/io-readsw-armv3.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/io-readsw-armv4.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/io-shark.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/io-writesb.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/io-writesl.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/io-writesw-armv3.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/io-writesw-armv4.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/io.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/memchr.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/memcpy.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/memset.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/memzero.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/setbit.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/strchr.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/strncpy_from_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/strnlen_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/strrchr.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/testchangebit.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/testclearbit.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/testsetbit.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/uaccess-armo.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/lib/uaccess.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mach-footbridge/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mach-footbridge/arch.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mach-footbridge/cats-hw.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mach-footbridge/cats-pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mach-footbridge/ebsa285-leds.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mach-footbridge/ebsa285-pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mach-footbridge/netwinder-hw.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mach-footbridge/netwinder-leds.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mach-footbridge/netwinder-pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mach-footbridge/personal-pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mach-sa1100/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mach-sa1100/arch.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mach-sa1100/hw.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mach-sa1100/leds.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mach-shark/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mach-shark/arch.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mach-shark/dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mach-shark/mm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mach-shark/pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/consistent.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/extable.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/fault-armo.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/fault-armv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/fault-common.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/ioremap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/mm-armo.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/mm-armv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/mm-clps7500.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/mm-ebsa110.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/mm-footbridge.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/mm-l7200.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/mm-nexuspci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/mm-rpc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/mm-sa1100.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/mm-tbox.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/proc-arm2,3.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/proc-arm6,7.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/proc-arm720.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/proc-arm920.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/proc-sa110.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/proc-syms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/mm/small_page.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/ARM-gcc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/ChangeLog#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/config.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/double_cpdo.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/entry.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/entry26.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/extended_cpdo.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/fpa11.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/fpa11.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/fpa11.inl#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/fpa11_cpdo.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/fpa11_cpdt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/fpa11_cprt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/fpmodule.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/fpmodule.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/fpmodule.inl#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/fpopcode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/fpopcode.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/fpsr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/milieu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/single_cpdo.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/softfloat-macros#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/softfloat-specialize#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/softfloat.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/nwfpe/softfloat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/tools/gen-mach-types#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/tools/mach-types#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/vmlinux-armo.lds.in#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/arm/vmlinux-armv.lds.in#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/boot/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/boot/bootsect.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/boot/compressed/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/boot/compressed/head.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/boot/compressed/misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/boot/install.sh#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/boot/setup.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/boot/tools/build.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/boot/video.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/apic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/apm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/bluesmoke.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/cpuid.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/dmi_scan.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/entry.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/head.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/i386_ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/i387.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/i8259.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/init_task.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/io_apic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/ioport.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/ldt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/mca.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/microcode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/mpparse.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/msr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/mtrr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/pci-dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/pci-i386.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/pci-i386.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/pci-irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/pci-pc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/pci-visws.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/process.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/ptrace.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/semaphore.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/signal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/smp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/smpboot.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/sys_i386.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/trampoline.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/traps.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/visws_apic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/kernel/vm86.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/lib/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/lib/checksum.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/lib/dec_and_lock.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/lib/delay.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/lib/getuser.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/lib/iodebug.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/lib/memcpy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/lib/mmx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/lib/old-checksum.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/lib/putuser.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/lib/usercopy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/README#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/control_w.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/div_Xsig.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/div_small.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/errors.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/exception.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/fpu_arith.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/fpu_asm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/fpu_aux.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/fpu_emu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/fpu_entry.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/fpu_etc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/fpu_proto.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/fpu_system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/fpu_tags.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/fpu_trig.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/get_address.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/load_store.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/mul_Xsig.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/poly.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/poly_2xm1.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/poly_atan.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/poly_l2.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/poly_sin.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/poly_tan.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/polynom_Xsig.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/reg_add_sub.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/reg_compare.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/reg_constant.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/reg_constant.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/reg_convert.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/reg_divide.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/reg_ld_str.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/reg_mul.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/reg_norm.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/reg_round.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/reg_u_add.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/reg_u_div.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/reg_u_mul.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/reg_u_sub.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/round_Xsig.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/shr_Xsig.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/status_w.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/version.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/wm_shrx.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/math-emu/wm_sqrt.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/mm/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/mm/extable.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/mm/fault.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/mm/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/mm/ioremap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/i386/vmlinux.lds#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/boot/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/boot/bootloader.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/boot/bootloader.lds#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/dig/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/dig/machvec.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/dig/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/hp/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/hp/hpsim_console.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/hp/hpsim_irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/hp/hpsim_machvec.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/hp/hpsim_setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/hp/hpsim_ssc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/ia32/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/ia32/binfmt_elf32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/ia32/ia32_entry.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/ia32/ia32_ioctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/ia32/ia32_signal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/ia32/ia32_support.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/ia32/ia32_traps.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/ia32/sys_ia32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/acpi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/brl_emu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/efi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/efi_stub.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/entry.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/entry.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/fw-emu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/gate.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/head.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/ia64_ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/init_task.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/iosapic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/irq_ia64.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/irq_sapic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/ivt.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/machvec.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/mca.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/mca_asm.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/minstate.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/pal.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/palinfo.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/perfmon.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/process.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/ptrace.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/sal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/semaphore.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/signal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/smp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/smpboot.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/sys_ia64.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/traps.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/unaligned.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/unwind.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/unwind_decoder.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/kernel/unwind_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/lib/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/lib/checksum.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/lib/clear_page.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/lib/clear_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/lib/copy_page.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/lib/copy_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/lib/csum_partial_copy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/lib/do_csum.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/lib/flush.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/lib/idiv32.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/lib/idiv64.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/lib/io.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/lib/memcpy.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/lib/memset.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/lib/strlen.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/lib/strlen_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/lib/strncpy_from_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/lib/strnlen_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/lib/swiotlb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/mm/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/mm/extable.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/mm/fault.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/mm/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/mm/tlb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/fprom/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/fprom/README#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/fprom/fpmem.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/fprom/fpmem.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/fprom/fprom.lds#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/fprom/fpromasm.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/fprom/fw-emu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/fprom/main.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/fprom/runsim#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/alenlist.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/cdl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/devsupport.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/eeprom.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/hcl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/hcl_util.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/hubdev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/hubspc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/invent.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/io.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/ip37.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/klconflib.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/klgraph.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/klgraph_hack.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/l1.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/l1_command.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/labelcl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/mem_refcnt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/ml_SN_init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/ml_SN_intr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/ml_iograph.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/module.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/pci_bus_cvlink.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/pci_dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/pcibr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/pciio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/sgi_if.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/sgi_io_init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/sgi_io_sim.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/stubs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/xbow.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/xswitch.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/io/xtalk.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/sn1/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/sn1/discontig.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/sn1/iomv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/sn1/irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/sn1/llsc4.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/sn1/llsc4.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/sn1/machvec.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/sn1/mm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/sn1/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/sn1/smp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/sn1/sn1_asm.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/sn1/synergy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/sn/tools/make_textsym#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/tools/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/tools/print_offsets.awk#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/tools/print_offsets.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ia64/vmlinux.lds.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/amiga/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/amiga/amiga_ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/amiga/amiints.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/amiga/amisound.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/amiga/chipram.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/amiga/cia.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/amiga/config.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/amiga/pcmcia.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/apollo/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/apollo/config.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/apollo/dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/apollo/dn_debug.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/apollo/dn_ints.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/atari/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/atari/ataints.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/atari/atakeyb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/atari/atari_ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/atari/atasound.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/atari/atasound.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/atari/config.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/atari/debug.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/atari/hades-pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/atari/joystick.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/atari/stdma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/atari/stram.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/atari/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/bvme6000/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/bvme6000/bvmeints.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/bvme6000/config.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/bvme6000/rtc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/README#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/bindec.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/binstr.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/bugfix.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/decbin.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/do_func.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/fpsp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/gen_except.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/get_op.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/kernel_ex.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/res_func.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/round.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/sacos.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/sasin.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/satan.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/satanh.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/scale.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/scosh.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/setox.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/sgetem.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/sint.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/skeleton.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/slog2.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/slogn.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/smovecr.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/srem_mod.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/ssin.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/ssinh.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/stan.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/stanh.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/sto_res.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/stwotox.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/tbldo.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/util.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/x_bsun.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/x_fline.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/x_operr.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/x_ovfl.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/x_snan.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/x_store.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/x_unfl.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/x_unimp.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/fpsp040/x_unsupp.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/hp300/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/hp300/README.hp300#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/hp300/config.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/hp300/hil.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/hp300/hp300map.map#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/hp300/ints.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/hp300/ints.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/hp300/ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/hp300/reboot.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/hp300/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/hp300/time.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/CHANGES#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/MISC#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/README#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/TEST.DOC#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/fplsp.doc#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/fplsp.sa#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/fpsp.doc#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/fpsp.sa#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/fskeleton.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/ftest.sa#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/ilsp.doc#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/ilsp.sa#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/iskeleton.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/isp.doc#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/isp.sa#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/itest.sa#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/os.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/pfpsp.sa#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/src/README-SRC#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/src/fplsp.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/src/fpsp.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/src/ftest.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/src/ilsp.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/src/isp.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/src/itest.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/ifpsp060/src/pfpsp.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/kernel/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/kernel/bios32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/kernel/entry.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/kernel/head.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/kernel/ints.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/kernel/m68k_defs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/kernel/m68k_defs.head#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/kernel/m68k_ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/kernel/process.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/kernel/ptrace.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/kernel/semaphore.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/kernel/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/kernel/signal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/kernel/sun3-head.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/kernel/sys_m68k.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/kernel/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/kernel/traps.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/lib/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/lib/ashldi3.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/lib/ashrdi3.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/lib/checksum.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/lib/lshrdi3.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/lib/memcmp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/lib/memcpy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/lib/memset.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/lib/muldi3.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/lib/semaphore.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mac/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mac/baboon.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mac/bootparse.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mac/config.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mac/debug.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mac/iop.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mac/mac_ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mac/mac_penguin.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mac/macboing.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mac/macints.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mac/misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mac/oss.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mac/psc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mac/via.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/math-emu/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/math-emu/fp_arith.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/math-emu/fp_arith.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/math-emu/fp_cond.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/math-emu/fp_decode.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/math-emu/fp_emu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/math-emu/fp_entry.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/math-emu/fp_log.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/math-emu/fp_move.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/math-emu/fp_movem.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/math-emu/fp_scan.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/math-emu/fp_trig.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/math-emu/fp_trig.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/math-emu/fp_util.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/math-emu/multi_arith.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mm/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mm/extable.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mm/fault.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mm/hwtest.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mm/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mm/kmap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mm/memory.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mm/motorola.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mm/sun3mmu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mvme147/147ints.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mvme147/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mvme147/config.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mvme16x/16xints.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mvme16x/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mvme16x/config.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mvme16x/mvme16x_ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/mvme16x/rtc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/q40/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/q40/README#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/q40/config.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/q40/q40ints.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3/config.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3/dvma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3/idprom.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3/intersil.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3/leds.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3/mmu_emu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3/prom/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3/prom/console.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3/prom/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3/prom/misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3/prom/printf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3/sbus.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3/sun3_ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3/sun3ints.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3x/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3x/config.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3x/dvma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3x/sbus.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3x/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/sun3x/time.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/tools/amiga/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/tools/amiga/dmesg.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/vmlinux-sun3.lds#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/m68k/vmlinux.lds#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/.gdbinit#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/algor/README#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/arc/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/arc/cmdline.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/arc/console.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/arc/env.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/arc/file.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/arc/identify.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/arc/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/arc/memory.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/arc/misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/arc/printf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/arc/salone.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/arc/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/arc/tree.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/baget/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/baget/baget.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/baget/bagetIRQ.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/baget/balo.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/baget/balo_supp.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/baget/irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/baget/ld.script.balo#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/baget/print.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/baget/prom/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/baget/prom/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/baget/reset.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/baget/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/baget/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/baget/vacserial.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/baget/wbflush.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/boot/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/boot/addinitrd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/boot/ecoff.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/boot/elf2ecoff.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/boot/mkboot.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/cobalt/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/cobalt/cobaltscc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/cobalt/diagdefs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/cobalt/hw-access.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/cobalt/int-handler.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/cobalt/pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/cobalt/reset.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/cobalt/serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/cobalt/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/cobalt/via.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/cobalt/z8530.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/ddb5074/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/ddb5074/int-handler.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/ddb5074/irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/ddb5074/nile4.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/ddb5074/pci-dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/ddb5074/pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/ddb5074/prom.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/ddb5074/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/ddb5074/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/boot/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/boot/decstation.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/boot/ld.ecoff#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/int-handler.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/prom/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/prom/cmdline.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/prom/dectypes.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/prom/identify.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/prom/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/prom/locore.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/prom/memory.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/prom/prom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/promcon.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/reset.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/rtc-dec.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/serial.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/dec/wbflush.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/defconfig-cobalt#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/defconfig-decstation#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/defconfig-ip22#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/defconfig-orion#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/defconfig-rm200#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/jazz/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/jazz/floppy-jazz.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/jazz/int-handler.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/jazz/io.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/jazz/jazzdma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/jazz/kbd-jazz.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/jazz/reset.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/jazz/rtc-jazz.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/jazz/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/branch.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/entry.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/fpe.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/gdb-low.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/gdb-stub.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/head.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/init_task.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/ioport.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/ipc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/irix5sys.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/irixelf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/irixinv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/irixioctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/irixsig.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/mips_ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/process.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/ptrace.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/r2300_fpu.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/r2300_misc.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/r2300_switch.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/r4k_fpu.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/r4k_misc.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/r4k_switch.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/r6000_fpu.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/reset.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/scall_o32.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/semaphore.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/signal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/softfp.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/syscall.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/syscalls.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/sysirix.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/sysmips.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/traps.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/unaligned.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/kernel/vm86.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/ld.script.big#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/ld.script.little#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/lib/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/lib/csum_partial.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/lib/csum_partial_copy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/lib/dump_tlb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/lib/floppy-no.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/lib/floppy-std.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/lib/ide-no.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/lib/ide-std.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/lib/kbd-no.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/lib/kbd-std.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/lib/memcpy.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/lib/memset.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/lib/r3k_dump_tlb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/lib/rtc-no.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/lib/rtc-std.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/lib/strlen_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/lib/strncpy_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/lib/strnlen_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/lib/tinycon.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/lib/watch.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/mm/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/mm/andes.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/mm/extable.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/mm/fault.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/mm/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/mm/loadmmu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/mm/r2300.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/mm/r4xx0.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/mm/umap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/orion/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/orion/int-handler.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/orion/irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/orion/ld.script.orion#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/orion/misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/orion/no_initrd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/orion/piggyback.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/orion/promcon.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/orion/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sgi/kernel/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sgi/kernel/indyIRQ.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sgi/kernel/indy_hpc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sgi/kernel/indy_int.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sgi/kernel/indy_mc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sgi/kernel/indy_rtc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sgi/kernel/indy_sc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sgi/kernel/indy_timer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sgi/kernel/promcon.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sgi/kernel/reset.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sgi/kernel/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sgi/kernel/system.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sgi/kernel/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sni/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sni/dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sni/int-handler.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sni/io.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sni/pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sni/pcimt_scache.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sni/reset.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/sni/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/tools/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips/tools/offset.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/arc/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/arc/cmdline.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/arc/console.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/arc/env.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/arc/file.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/arc/identify.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/arc/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/arc/memory.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/arc/misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/arc/printf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/arc/salone.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/arc/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/arc/tree.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/boot/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/defconfig-ip22#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/defconfig-ip27#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/binfmt_elf32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/branch.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/entry.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/head.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/init_task.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/ioctl32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/linux32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/mips64_ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/process.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/ptrace.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/r4k_cache.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/r4k_fpu.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/r4k_genex.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/r4k_switch.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/r4k_tlb.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/r4k_tlb_debug.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/r4k_tlb_glue.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/scall_64.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/scall_o32.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/semaphore.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/signal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/signal32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/smp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/softfp.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/syscall.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/traps.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/kernel/unaligned.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/ld.script.elf32.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/ld.script.elf64#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/lib/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/lib/csum_partial.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/lib/csum_partial_copy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/lib/dump_tlb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/lib/floppy-no.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/lib/floppy-std.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/lib/ide-no.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/lib/ide-std.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/lib/kbd-no.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/lib/kbd-std.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/lib/memcpy.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/lib/memset.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/lib/rtc-no.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/lib/rtc-std.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/lib/strlen_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/lib/strncpy_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/lib/strnlen_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/lib/watch.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/mm/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/mm/andes.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/mm/extable.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/mm/fault.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/mm/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/mm/loadmmu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/mm/r4xx0.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/mm/umap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip22/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip22/ip22-berr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip22/ip22-hpc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip22/ip22-int.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip22/ip22-irq.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip22/ip22-mc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip22/ip22-reset.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip22/ip22-rtc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip22/ip22-sc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip22/ip22-setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip22/ip22-timer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip22/system.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip22/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip27/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip27/TODO#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip27/ip27-berr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip27/ip27-console.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip27/ip27-init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip27/ip27-irq-glue.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip27/ip27-irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip27/ip27-klconfig.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip27/ip27-klnuma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip27/ip27-memory.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip27/ip27-nmi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip27/ip27-pci-dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip27/ip27-pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip27/ip27-reset.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip27/ip27-rtc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip27/ip27-setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/sgi-ip27/ip27-timer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/tools/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/mips64/tools/offset.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/hpux/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/hpux/entry_hpux.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/hpux/fs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/hpux/gate.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/hpux/ioctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/hpux/sys_hpux.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/hpux/wrappers.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/cache.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/ccio-dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/ccio-rm-dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/drivers.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/entry.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/hardware.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/head.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/hpmc.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/init_task.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/inventory.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/iosapic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/iosapic_private.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/keyboard.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/lasimap.map#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/lba_pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/led.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/pa7300lc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/parisc_ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/pci-dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/pdc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/pdc_cons.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/process.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/ptrace.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/real1.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/real2.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/sba_iommu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/semaphore.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/signal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/sys_parisc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/syscall.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/kernel/traps.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/lib/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/lib/bitops.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/lib/checksum.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/lib/lusercopy.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/mm/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/mm/extable.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/mm/fault.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/mm/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/mm/kmap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/mm/pa11.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/mm/pa20.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/tools/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/tools/offset.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/parisc/vmlinux.lds#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/8260_io/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/8260_io/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/8260_io/commproc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/8260_io/enet.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/8260_io/fcc_enet.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/8260_io/uart.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/8xx_io/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/8xx_io/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/8xx_io/commproc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/8xx_io/commproc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/8xx_io/enet.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/8xx_io/fec.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/8xx_io/uart.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/amiga/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/amiga/amiga_ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/amiga/amiints.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/amiga/amisound.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/amiga/bootinfo.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/amiga/chipram.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/amiga/cia.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/amiga/config.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/amiga/ints.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/amiga/pcmcia.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/amiga/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/boot/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/boot/head.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/boot/iso_font.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/boot/kbd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/boot/misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/boot/mkprep.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/boot/ns16550.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/boot/ns16550.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/boot/of1275.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/boot/of1275.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/boot/offset#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/boot/size#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/boot/vreset.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/chrpboot/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/chrpboot/addnote.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/chrpboot/crt0.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/chrpboot/main.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/chrpboot/misc.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/chrpboot/mknote.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/chrpboot/no_initrd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/chrpboot/piggyback.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/chrpboot/start.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/coffboot/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/coffboot/chrpmain.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/coffboot/coffcrt0.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/coffboot/coffmain.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/coffboot/crt0.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/coffboot/dummy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/coffboot/hack-coff.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/coffboot/ld.script#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/coffboot/main.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/coffboot/misc.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/coffboot/mknote.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/coffboot/no_initrd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/coffboot/nonstdio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/coffboot/piggyback.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/coffboot/rs6000.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/coffboot/start.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/coffboot/string.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/coffboot/zlib.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/coffboot/zlib.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/configs/apus_defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/configs/bseip_defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/configs/common_defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/configs/est8260_defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/configs/gemini_defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/configs/mbx_defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/configs/oak_defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/configs/rpxcllf_defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/configs/rpxlite_defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/configs/walnut_defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/align.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/apus_setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/bitops.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/checks.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/chrp_pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/chrp_setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/chrp_time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/entry.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/feature.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/find_name.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/galaxy_pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/gemini_pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/gemini_prom.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/gemini_setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/hashtable.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/head.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/head_4xx.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/head_8xx.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/i8259.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/i8259.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/idle.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/indirect_pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/local_irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/m8260_setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/m8xx_setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/misc.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/mk_defs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/mol.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/oak_setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/oak_setup.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/open_pic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/open_pic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/pci-dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/pci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/pmac_backlight.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/pmac_nvram.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/pmac_pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/pmac_pic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/pmac_pic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/pmac_setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/pmac_time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/ppc-stub.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/ppc4xx_pic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/ppc4xx_pic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/ppc8260_pic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/ppc8260_pic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/ppc8xx_pic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/ppc8xx_pic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/ppc_asm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/ppc_asm.tmpl#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/ppc_defs.head#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/ppc_htab.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/ppc_ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/prep_nvram.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/prep_pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/prep_setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/prep_time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/process.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/prom.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/ptrace.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/qspan_pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/residual.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/semaphore.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/signal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/sleep.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/smp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/softemu8xx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/syscalls.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/traps.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/walnut_setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/walnut_setup.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/xics.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/kernel/xics.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/lib/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/lib/checksum.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/lib/locks.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/lib/strcase.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/lib/string.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/double.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fabs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fadd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fadds.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fcmpo.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fcmpu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fctiw.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fctiwz.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fdiv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fdivs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fmadd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fmadds.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fmr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fmsub.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fmsubs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fmul.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fmuls.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fnabs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fneg.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fnmadd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fnmadds.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fnmsub.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fnmsubs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fres.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/frsp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/frsqrte.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fsel.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fsqrt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fsqrts.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fsub.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/fsubs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/lfd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/lfs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/math.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/mcrfs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/mffs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/mtfsb0.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/mtfsb1.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/mtfsf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/mtfsfi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/op-1.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/op-2.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/op-4.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/op-common.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/sfp-machine.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/single.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/soft-fp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/stfd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/stfiwx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/stfs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/types.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/math-emu/udivmodti4.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mbxboot/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mbxboot/embed_config.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mbxboot/gzimage.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mbxboot/head.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mbxboot/head_8260.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mbxboot/iic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mbxboot/m8260_tty.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mbxboot/m8xx_tty.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mbxboot/misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mbxboot/offset#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mbxboot/pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mbxboot/qspan_pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mbxboot/rdimage.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mbxboot/size#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mbxboot/vmlinux.lds#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mm/4xx_tlb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mm/4xx_tlb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mm/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mm/extable.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mm/fault.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mm/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mm/mem_pieces.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/mm/mem_pieces.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/treeboot/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/treeboot/crt0.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/treeboot/elf.pl#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/treeboot/irSect.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/treeboot/irSect.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/treeboot/ld.script#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/treeboot/main.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/treeboot/misc.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/treeboot/mkevimg#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/treeboot/mkirimg#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/vmlinux.lds#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/xmon/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/xmon/adb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/xmon/ansidecl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/xmon/nonstdio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/xmon/ppc-dis.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/xmon/ppc-opc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/xmon/ppc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/xmon/privinst.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/xmon/setjmp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/xmon/start.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/xmon/start_8xx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/xmon/subr_prf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/ppc/xmon/xmon.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/boot/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/boot/ipldump.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/boot/ipleckd.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/boot/iplfba.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/bitmap.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/cpcmd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/cpcmd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/ebcdic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/entry.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/floatlib.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/gdb-stub.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/head.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/ieee.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/init_task.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/irqextras390.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/lowcore.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/mathemu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/process.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/ptrace.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/reipl.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/s390_ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/s390dyn.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/s390fpu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/s390io.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/s390mach.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/semaphore.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/signal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/smp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/sys_s390.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/kernel/traps.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/lib/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/lib/checksum.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/lib/delay.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/lib/memset.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/lib/strcmp.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/lib/strncpy.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/mm/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/mm/extable.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/mm/fault.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/mm/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/mm/ioremap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/tools/dasdfmt/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/tools/dasdfmt/dasdfmt.8#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/tools/dasdfmt/dasdfmt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/tools/silo/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/tools/silo/cfg.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/tools/silo/cfg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/tools/silo/silo.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/tools/silo/silo.conf#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/s390/vmlinux.lds#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/boot/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/boot/compressed/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/boot/compressed/head.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/boot/compressed/install.sh#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/boot/compressed/misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/cf-enabler.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/entry.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/fpu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/head.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/init_task.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/io.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/io_generic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/io_hd64461.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/io_se.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/io_unknown.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/irq_imask.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/irq_ipr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/led_se.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/mach_hp600.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/mach_se.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/mach_unknown.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/pci-sh.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/process.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/ptrace.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/rtc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/semaphore.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/setup_cqreek.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/setup_hd64461.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/setup_od.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/setup_se.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/sh_bios.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/sh_ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/signal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/sys_sh.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/kernel/traps.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/lib/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/lib/checksum.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/lib/delay.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/lib/memchr.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/lib/memcpy.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/lib/memmove.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/lib/memset.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/lib/old-checksum.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/lib/strcasecmp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/mm/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/mm/cache.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/mm/extable.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/mm/fault.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/mm/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/mm/ioremap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sh/vmlinux.lds.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/boot/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/boot/btfixupprep.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/boot/piggyback.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/auxio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/check_asm.sh#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/cpu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/devices.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/ebus.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/entry.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/errtbls.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/etrap.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/head.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/idprom.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/init_task.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/ioport.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/muldiv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/pcic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/process.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/ptrace.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/rtrap.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/sclow.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/semaphore.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/signal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/smp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/sparc-stub.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/sparc_ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/sun4c_irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/sun4d_irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/sun4d_smp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/sun4m_irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/sun4m_smp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/sun4setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/sunos_asm.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/sunos_ioctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/sys_solaris.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/sys_sparc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/sys_sunos.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/systbls.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/tadpole.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/tick14.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/trampoline.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/traps.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/unaligned.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/windows.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/wof.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/kernel/wuf.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/COPYING.LIB#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/ashldi3.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/ashrdi3.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/atomic.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/bitops.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/blockops.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/checksum.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/copy_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/debuglocks.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/divdi3.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/locks.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/lshrdi3.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/memcmp.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/memcpy.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/memscan.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/memset.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/mul.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/muldi3.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/rem.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/rwsem.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/sdiv.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/strlen.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/strlen_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/strncmp.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/strncpy_from_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/udiv.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/udivdi3.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/umul.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/lib/urem.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/math-emu/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/math-emu/ashldi3.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/math-emu/math.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/math-emu/sfp-util.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/mm/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/mm/btfixup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/mm/extable.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/mm/fault.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/mm/generic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/mm/hypersparc.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/mm/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/mm/io-unit.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/mm/iommu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/mm/loadmmu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/mm/nosrmmu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/mm/nosun4c.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/mm/srmmu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/mm/sun4c.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/mm/swift.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/mm/tsunami.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/mm/viking.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/prom/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/prom/bootstr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/prom/console.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/prom/devmap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/prom/devops.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/prom/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/prom/memory.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/prom/misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/prom/mp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/prom/palloc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/prom/printf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/prom/ranges.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/prom/segment.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/prom/sun4prom.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/prom/tree.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc/vmlinux.lds#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/boot/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/boot/piggyback.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/defconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/auxio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/binfmt_aout32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/binfmt_elf32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/central.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/check_asm.sh#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/cpu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/devices.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/dtlb_backend.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/dtlb_base.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/dtlb_prot.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/ebus.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/entry.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/etrap.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/head.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/idprom.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/init_task.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/ioctl32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/iommu_common.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/iommu_common.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/itlb_base.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/pci_common.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/pci_impl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/pci_iommu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/pci_psycho.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/pci_sabre.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/power.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/process.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/ptrace.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/rtrap.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/sbus.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/semaphore.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/signal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/signal32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/smp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/sparc64_ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/starfire.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/sunos_ioctl32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/sys32.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/sys_sparc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/sys_sparc32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/sys_sunos32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/systbls.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/trampoline.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/traps.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/ttable.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/unaligned.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/kernel/winfixup.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/PeeCeeI.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/U3copy_from_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/U3copy_in_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/U3copy_to_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/U3memcpy.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/VIS.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/VISbzero.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/VIScopy.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/VIScsum.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/VIScsumcopy.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/VIScsumcopyusr.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/VISmemset.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/VISsave.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/atomic.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/bitops.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/blockops.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/checksum.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/debuglocks.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/dec_and_lock.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/memcmp.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/memscan.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/rwlock.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/strlen.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/strlen_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/strncmp.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/lib/strncpy_from_user.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/math-emu/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/math-emu/math.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/math-emu/sfp-util.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/mm/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/mm/extable.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/mm/fault.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/mm/generic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/mm/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/mm/modutil.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/mm/ultra.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/prom/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/prom/bootstr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/prom/console.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/prom/devops.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/prom/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/prom/map.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/prom/memory.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/prom/misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/prom/p1275.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/prom/printf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/prom/tree.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/solaris/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/solaris/conv.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/solaris/entry64.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/solaris/fs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/solaris/ioctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/solaris/ipc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/solaris/misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/solaris/signal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/solaris/signal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/solaris/socket.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/solaris/socksys.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/solaris/socksys.h#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/solaris/systbl.S#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/solaris/timod.c#1 branch
-... //depot/linux-aic79xx-2.4.0/arch/sparc64/vmlinux.lds#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/README#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/block/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/block/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/block/fd1772.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/block/fd1772dma.S#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/block/mfm.S#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/block/mfmhd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/char/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/char/defkeymap-acorn.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/char/i2c.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/char/keyb_arc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/char/keyb_ps2.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/char/mouse_rpc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/char/pcf8583.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/char/pcf8583.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/char/serial-atomwide.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/char/serial-card.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/char/serial-dualsp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/net/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/net/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/net/ether1.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/net/ether1.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/net/ether3.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/net/ether3.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/net/etherh.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/acornscsi-io.S#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/acornscsi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/acornscsi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/arxescsi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/arxescsi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/cumana_1.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/cumana_1.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/cumana_2.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/cumana_2.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/ecoscsi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/ecoscsi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/eesox.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/eesox.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/fas216.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/fas216.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/msgqueue.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/msgqueue.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/oak.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/oak.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/powertec.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/powertec.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/queue.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acorn/scsi/queue.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/cmbatt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/common/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/common/cmalloc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/common/cmclib.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/common/cmcopy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/common/cmdebug.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/common/cmdelete.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/common/cmeval.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/common/cmglobal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/common/cminit.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/common/cmobject.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/common/cmutils.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/common/cmxface.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/cpu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/dispatcher/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/dispatcher/dsfield.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/dispatcher/dsmethod.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/dispatcher/dsmthdat.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/dispatcher/dsobject.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/dispatcher/dsopcode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/dispatcher/dsutils.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/dispatcher/dswexec.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/dispatcher/dswload.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/dispatcher/dswscope.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/dispatcher/dswstate.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/driver.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/driver.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/ec.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/ec.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/events/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/events/evevent.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/events/evmisc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/events/evregion.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/events/evrgnini.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/events/evsci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/events/evxface.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/events/evxfevnt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/events/evxfregn.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/hardware/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/hardware/hwacpi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/hardware/hwcpu32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/hardware/hwgpe.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/hardware/hwregs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/hardware/hwxface.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/accommon.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/acconfig.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/acdebug.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/acdispat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/acenv.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/acevents.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/acexcep.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/acgcc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/acglobal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/achware.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/acinterp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/aclinux.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/aclocal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/acmacros.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/acnamesp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/acobject.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/acoutput.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/acparser.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/acpi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/acpiosxf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/acpixf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/acresrc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/actables.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/actbl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/actbl1.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/actbl2.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/actbl71.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/actypes.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/include/amlcode.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/interpreter/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/interpreter/amconfig.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/interpreter/amcreate.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/interpreter/amdyadic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/interpreter/amfield.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/interpreter/amfldio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/interpreter/ammisc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/interpreter/ammonad.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/interpreter/amnames.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/interpreter/amprep.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/interpreter/amregion.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/interpreter/amresnte.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/interpreter/amresolv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/interpreter/amresop.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/interpreter/amstore.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/interpreter/amstoren.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/interpreter/amstorob.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/interpreter/amsystem.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/interpreter/amutils.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/interpreter/amxface.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/namespace/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/namespace/nsaccess.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/namespace/nsalloc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/namespace/nseval.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/namespace/nsinit.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/namespace/nsload.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/namespace/nsnames.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/namespace/nsobject.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/namespace/nssearch.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/namespace/nsutils.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/namespace/nswalk.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/namespace/nsxfname.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/namespace/nsxfobj.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/os.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/parser/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/parser/psargs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/parser/psopcode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/parser/psparse.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/parser/psscope.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/parser/pstree.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/parser/psutils.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/parser/pswalk.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/parser/psxface.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/power.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/resources/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/resources/rsaddr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/resources/rscalc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/resources/rscreate.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/resources/rsdump.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/resources/rsio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/resources/rsirq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/resources/rslist.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/resources/rsmemory.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/resources/rsmisc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/resources/rsutils.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/resources/rsxface.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/sys.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/table.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/tables/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/tables/tbconvrt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/tables/tbget.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/tables/tbinstal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/tables/tbutils.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/tables/tbxface.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/acpi/tables/tbxfroot.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/ambassador.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/ambassador.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/atmdev_init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/atmsar11.data#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/atmsar11.regions#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/atmsar11.start#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/atmtcp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/eni.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/eni.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/firestream.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/firestream.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/fore200e.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/fore200e.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/fore200e_firmware_copyright#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/fore200e_mkfirm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/horizon.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/horizon.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/idt77105.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/idt77105.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/iphase.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/iphase.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/midway.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/nicstar.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/nicstar.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/nicstarmac.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/nicstarmac.copyright#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/nicstarmac.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/pca200e.data#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/pca200e_ecd.data#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/sba200e_ecd.data#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/suni.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/suni.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/tonga.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/uPD98401.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/uPD98402.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/uPD98402.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/zatm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/zatm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/atm/zeprom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/DAC960.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/DAC960.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/acsi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/acsi_slm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/amiflop.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/ataflop.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/blkpg.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/cciss.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/cciss.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/cciss_cmd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/cpqarray.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/cpqarray.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/elevator.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/floppy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/genhd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/ida_cmd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/ida_ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/ll_rw_blk.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/loop.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/nbd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/aten.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/bpck.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/comm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/dstr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/epat.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/epia.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/fit2.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/fit3.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/friq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/frpw.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/jumbo#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/kbic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/ktti.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/mkd#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/on20.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/on26.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/paride.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/paride.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/pcd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/pd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/pf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/pg.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/pseudo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/pt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/paride/setup.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/ps2esdi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/rd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/smart1,2.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/swim3.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/swim_iop.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/xd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/xd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/block/z2ram.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/aztcd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/aztcd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/cdrom.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/cdu31a.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/cdu31a.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/cm206.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/cm206.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/gscd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/gscd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/isp16.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/isp16.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/mcd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/mcd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/mcdx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/mcdx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/optcd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/optcd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/sbpcd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/sbpcd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/sbpcd2.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/sbpcd3.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/sbpcd4.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/sjcd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/sjcd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/sonycd535.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/cdrom/sonycd535.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ChangeLog#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/README.computone#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/README.cycladesZ#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/README.cyclomY#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/README.epca#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/README.scc#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/acquirewdt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/adbmouse.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/agp/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/agp/agp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/agp/agpgart_be.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/agp/agpgart_fe.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/amigamouse.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/amikeyb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/amiserial.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/applicom.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/applicom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/atarimouse.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/atixlmouse.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/busmouse.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/busmouse.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/cd1865.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/conmakehash.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/console.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/console_macros.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/consolemap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/cp437.uni#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/cyclades.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/defkeymap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/defkeymap.map#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/digi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/digi1.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/digiFep1.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/digiPCI.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/digi_bios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/digi_fep.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/dn_keyb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/README.drm#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/agpsupport.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/auth.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/bufs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/context.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/ctxbitmap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/drawable.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/drm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/drmP.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/ffb_context.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/ffb_drv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/ffb_drv.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/fops.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/gamma_dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/gamma_drv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/gamma_drv.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/i810_bufs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/i810_context.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/i810_dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/i810_drm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/i810_drv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/i810_drv.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/ioctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/lists.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/lock.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/memory.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/mga_bufs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/mga_context.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/mga_dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/mga_drm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/mga_drv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/mga_drv.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/mga_state.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/r128_bufs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/r128_cce.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/r128_context.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/r128_drm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/r128_drv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/r128_drv.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/r128_state.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/tdfx_context.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/tdfx_drv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/tdfx_drv.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/drm/vm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ds1620.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/dsp56k.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/dtlk.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/dz.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/dz.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/efirtc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/epca.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/epca.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/epcaconfig.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/esp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/fep.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/README.PCI#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/RELEASE-NOTES#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/compressor/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/compressor/lzrw3.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/compressor/lzrw3.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/compressor/zftape-compress.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/compressor/zftape-compress.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/fc-10.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/fc-10.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/fdc-io.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/fdc-io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/fdc-isr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/fdc-isr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-bsm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-bsm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-buffer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-buffer.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-calibr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-calibr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-ctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-ctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-ecc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-ecc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-format.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-format.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-init.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-io.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-proc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-read.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-read.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-rw.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-rw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-tracing.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-tracing.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-write.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape-write.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape_syms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/lowlevel/ftape_syms.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/zftape/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/zftape/zftape-buffers.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/zftape/zftape-buffers.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/zftape/zftape-ctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/zftape/zftape-ctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/zftape/zftape-eof.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/zftape/zftape-eof.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/zftape/zftape-init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/zftape/zftape-init.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/zftape/zftape-read.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/zftape/zftape-read.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/zftape/zftape-rw.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/zftape/zftape-rw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/zftape/zftape-vtbl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/zftape/zftape-vtbl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/zftape/zftape-write.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/zftape/zftape-write.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/zftape/zftape_syms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ftape/zftape/zftape_syms.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/generic_serial.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/h8.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/h8.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/hp600_keyb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/i810-tco.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/i810-tco.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/i810_rng.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ip2.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ip2/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ip2/fip_firm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ip2/i2cmd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ip2/i2cmd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ip2/i2ellis.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ip2/i2ellis.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ip2/i2hw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ip2/i2lib.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ip2/i2lib.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ip2/i2os.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ip2/i2pack.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ip2/ip2.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ip2/ip2ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ip2/ip2mkdev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ip2/ip2stat.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ip2/ip2trace.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ip2/ip2trace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ip2/ip2types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ip2main.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/isicom.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/istallion.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/a3d.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/adi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/amijoy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/analog.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/cobra.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/db9.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/gamecon.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/gameport.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/gf2k.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/grip.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/iforce.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/interact.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/lightning.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/magellan.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/ns558.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/pcigame.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/serio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/serport.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/sidewinder.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/spaceball.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/spaceorb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/tmdc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/turbografx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/joystick/warrior.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/keyboard.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/logibusmouse.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/lp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/mem.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/mixcomwd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/moxa.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/msbusmouse.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/mxser.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/n_hdlc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/n_r3964.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/n_tty.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/nvram.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/nwbutton.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/nwbutton.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/nwflash.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/pc110pad.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/pc110pad.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/pc_keyb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/pcmcia/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/pcmcia/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/pcmcia/serial_cb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/pcmcia/serial_cs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/pcwd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/pcxx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/pcxx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/ppdev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/pty.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/q40_keyb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/qpmouse.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/random.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/raw.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/board.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/bootpkt.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/brates.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/cdproto.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/chan.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/cirrus.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/cmd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/cmdblk.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/cmdpkt.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/control.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/daemon.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/data.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/debug.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/defaults.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/eisa.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/enable.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/error.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/errors.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/formpkt.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/func.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/host.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/hosthw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/link.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/linux_compat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/list.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/lrt.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/ltt.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/lttwake.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/map.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/mca.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/mesg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/parmmap.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/pci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/phb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/pkt.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/poll.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/port.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/proto.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/protsts.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/qbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/rio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/rio_linux.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/rio_linux.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/rioboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/rioboot.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/riocmd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/rioctrl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/riodrvr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/rioinfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/rioinit.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/riointr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/rioioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/riolocks.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/rioparam.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/riopcicopy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/rioroute.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/riospace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/riotable.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/riotime.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/riotty.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/riotypes.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/riowinif.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/riscos.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/rom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/route.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/rtahw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/rup.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/rupstat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/sam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/selftest.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/space.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/sysmap.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/timeouts.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/top.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/typdef.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rio/unixrup.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/riscom8.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/riscom8.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/riscom8_reg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rocket.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rocket_int.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rsf16fmi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/rtc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/sbc60xxwdt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/scan_keyb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/scan_keyb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/scc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/selection.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/serial.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/serial167.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/serial_21285.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/serial_amba.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/sh-sci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/sh-sci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/softdog.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/specialix.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/specialix_io8.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/stallion.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/sx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/sx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/sxboards.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/sxwindow.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/synclink.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/sysrq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/toshiba.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/tpqic02.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/tty_io.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/tty_ioctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/vc_screen.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/vino.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/vme_scc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/vt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/wd501p.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/wdt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/wdt285.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/wdt977.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/char/wdt_pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/dio/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/dio/dio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/fc4/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/fc4/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/fc4/fc-al.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/fc4/fc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/fc4/fc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/fc4/fc_syms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/fc4/fcp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/fc4/fcp_impl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/fc4/soc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/fc4/soc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/fc4/socal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/fc4/socal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2c/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2c/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2c/i2c-algo-bit.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2c/i2c-algo-pcf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2c/i2c-core.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2c/i2c-dev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2c/i2c-elektor.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2c/i2c-elv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2c/i2c-pcf8584.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2c/i2c-philips-par.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2c/i2c-velleman.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2o/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2o/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2o/README#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2o/README.ioctl#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2o/i2o_block.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2o/i2o_config.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2o/i2o_core.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2o/i2o_lan.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2o/i2o_lan.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2o/i2o_pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2o/i2o_proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2o/i2o_scsi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/i2o/i2o_scsi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/aec62xx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/ali14xx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/alim15x3.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/amd7409.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/buddha.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/cmd640.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/cmd64x.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/cs5530.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/cy82c693.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/dtc2278.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/falconide.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/gayle.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/hd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/hpt34x.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/hpt366.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/ht6560b.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/icside.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/ide-cd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/ide-cd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/ide-cs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/ide-disk.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/ide-dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/ide-features.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/ide-floppy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/ide-geometry.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/ide-pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/ide-pmac.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/ide-pnp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/ide-probe.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/ide-proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/ide-tape.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/ide.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/ide_modes.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/macide.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/ns87415.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/opti621.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/osb4.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/pdc202xx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/pdc4030.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/pdc4030.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/piix.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/q40ide.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/qd6580.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/rapide.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/rz1000.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/sis5513.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/sl82c105.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/slc90e66.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/trm290.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/umc8672.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ide/via82cxxx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/aic5800.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/aic5800.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/csr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/csr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/guid.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/guid.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/highlevel.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/highlevel.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/hosts.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/hosts.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/ieee1394.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/ieee1394_core.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/ieee1394_core.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/ieee1394_syms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/ieee1394_transactions.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/ieee1394_transactions.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/ieee1394_types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/ohci1394.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/ohci1394.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/pcilynx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/pcilynx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/raw1394.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/raw1394.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/video1394.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/ieee1394/video1394.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/input/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/input/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/input/evdev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/input/input.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/input/joydev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/input/keybdev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/input/mousedev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/act2000/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/act2000/act2000.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/act2000/act2000_isa.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/act2000/act2000_isa.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/act2000/capi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/act2000/capi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/act2000/module.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/avm_cs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/avmcard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/b1.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/b1dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/b1isa.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/b1pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/b1pcmcia.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/c4.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/capi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/capicmd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/capidev.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/capidrv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/capidrv.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/capifs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/capifs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/capilli.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/capiutil.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/capiutil.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/kcapi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/t1isa.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/avmb1/t1pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/divert/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/divert/divert_init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/divert/divert_procfs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/divert/isdn_divert.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/divert/isdn_divert.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/Divas_mod.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/adapter.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/bri.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/common.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/constant.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/divalog.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/divas.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/dsp_defs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/dspdids.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/eicon.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/eicon_dsp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/eicon_idi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/eicon_idi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/eicon_io.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/eicon_isa.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/eicon_isa.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/eicon_mod.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/eicon_pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/eicon_pci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/fcheck.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/fourbri.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/fpga.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/idi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/idi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/kprintf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/lincfg.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/linchr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/linio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/linsys.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/log.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/md5sums.asc#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/pc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/pc_maint.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/pr_pc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/pri.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/sys.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/uxio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/eicon/xlog.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/amd7930.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/arcofi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/arcofi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/asuscom.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/avm_a1.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/avm_a1p.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/avm_pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/bkm_a4t.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/bkm_a8.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/bkm_ax.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/callc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/cert.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/config.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/diva.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/elsa.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/elsa_ser.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/fsm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/gazel.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/hfc_2bds0.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/hfc_2bds0.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/hfc_2bs0.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/hfc_2bs0.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/hfc_pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/hfc_pci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/hfc_sx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/hfc_sx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/hfcscard.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/hisax.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/hscx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/hscx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/hscx_irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/icc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/icc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/ipac.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/isac.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/isac.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/isar.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/isar.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/isdnl1.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/isdnl1.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/isdnl2.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/isdnl2.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/isdnl3.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/isdnl3.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/isurf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/ix1_micro.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/jade.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/jade.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/jade_irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/l3_1tr6.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/l3_1tr6.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/l3dss1.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/l3dss1.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/l3ni1.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/l3ni1.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/lmgr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/md5sums.asc#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/mic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/netjet.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/netjet.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/niccy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/nj_s.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/nj_u.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/q931.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/rawhdlc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/rawhdlc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/s0box.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/saphir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/sedlbauer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/sportster.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/tei.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/teleint.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/teles0.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/teles3.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/telespci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/w6692.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hisax/w6692.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hysdn/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hysdn/boardergo.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hysdn/boardergo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hysdn/hycapi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hysdn/hysdn_boot.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hysdn/hysdn_defs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hysdn/hysdn_init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hysdn/hysdn_net.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hysdn/hysdn_pof.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hysdn/hysdn_procconf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hysdn/hysdn_procfs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hysdn/hysdn_proclog.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hysdn/hysdn_sched.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/hysdn/ince1pc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/icn/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/icn/icn.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/icn/icn.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_audio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_audio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_bsdcomp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_cards.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_cards.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_common.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_common.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_concap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_concap.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_net.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_net.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_ppp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_ppp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_tty.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_tty.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_ttyfax.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_ttyfax.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_v110.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_v110.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_x25iface.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdn_x25iface.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdnloop/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdnloop/isdnloop.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/isdnloop/isdnloop.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/pcbit/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/pcbit/callbacks.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/pcbit/callbacks.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/pcbit/capi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/pcbit/capi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/pcbit/drv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/pcbit/edss1.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/pcbit/edss1.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/pcbit/layer2.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/pcbit/layer2.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/pcbit/module.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/pcbit/pcbit.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/sc/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/sc/card.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/sc/command.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/sc/debug.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/sc/debug.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/sc/event.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/sc/hardware.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/sc/includes.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/sc/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/sc/interrupt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/sc/ioctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/sc/message.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/sc/message.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/sc/packet.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/sc/scioc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/sc/shmem.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/isdn/sc/timer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/macintosh/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/macintosh/adb-iop.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/macintosh/adb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/macintosh/adbhid.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/macintosh/mac_hid.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/macintosh/mac_keyb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/macintosh/macio-adb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/macintosh/mackeymap.map#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/macintosh/macserial.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/macintosh/macserial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/macintosh/mediabay.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/macintosh/nvram.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/macintosh/rtc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/macintosh/via-cuda.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/macintosh/via-macii.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/macintosh/via-maciisi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/macintosh/via-pmu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/macintosh/via-pmu68k.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/md/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/md/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/md/linear.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/md/lvm-snap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/md/lvm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/md/md.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/md/raid0.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/md/raid1.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/md/raid5.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/md/xor.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/radio/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/radio/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/radio/radio-aimslab.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/radio/radio-aztech.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/radio/radio-cadet.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/radio/radio-gemtek.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/radio/radio-maestro.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/radio/radio-miropcm20.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/radio/radio-rtrack2.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/radio/radio-sf16fmi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/radio/radio-terratec.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/radio/radio-trust.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/radio/radio-typhoon.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/radio/radio-zoltrix.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/audiochip.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/bt848.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/bttv-cards.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/bttv-driver.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/bttv-if.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/bttv.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/bttvp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/buz.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/buz.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/bw-qcam.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/bw-qcam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/c-qcam.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/cpia.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/cpia.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/cpia_pp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/cpia_usb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/cs8420.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/i2c-old.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/i2c-parport.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/ibmmpeg2.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/id.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/msp3400.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/planb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/planb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/pms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/saa5249.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/saa7110.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/saa7111.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/saa7121.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/saa7146.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/saa7146reg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/saa7185.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/saa7196.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/stradis.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/tda7432.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/tda9875.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/tuner-3036.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/tuner.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/tuner.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/tvaudio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/tvaudio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/tvmixer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/videodev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/vino.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/zr36057.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/zr36060.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/zr36120.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/zr36120.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/zr36120_i2c.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/zr36120_mem.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/media/video/zr36120_mem.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/misc/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/misc/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/cfi_cmdset_0001.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/cfi_cmdset_0002.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/cfi_probe.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/doc1000.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/doc2000.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/doc2001.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/docecc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/docprobe.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/ftl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/jedec.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/map_ram.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/map_rom.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/mapped.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/mixmem.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/mtdblock.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/mtdchar.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/mtdcore.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/mtdpart.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/mtdram.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/nftl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/nftlmount.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/nora.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/octagon-5066.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/physmap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/pmc551.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/pnc2000.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/rpxlite.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/slram.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/mtd/vmax301.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/3c501.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/3c503.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/3c503.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/3c505.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/3c505.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/3c507.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/3c509.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/3c515.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/3c523.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/3c523.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/3c527.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/3c527.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/3c59x.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/7990.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/7990.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/8139too.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/82596.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/8390.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/8390.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/LICENSE.SRC#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/Space.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/a2065.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/a2065.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ac3200.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/acenic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/acenic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/acenic_firmware.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/aironet4500.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/aironet4500_card.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/aironet4500_core.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/aironet4500_proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/aironet4500_rid.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/am79c961a.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/am79c961a.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/apne.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/appletalk/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/appletalk/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/appletalk/cops.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/appletalk/cops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/appletalk/cops_ffdrv.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/appletalk/cops_ltdrv.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/appletalk/ipddp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/appletalk/ipddp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/appletalk/ltpc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/appletalk/ltpc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/arcnet/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/arcnet/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/arcnet/arc-rawmode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/arcnet/arc-rimi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/arcnet/arcnet.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/arcnet/com20020-isa.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/arcnet/com20020-pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/arcnet/com20020.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/arcnet/com90io.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/arcnet/com90xx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/arcnet/rfc1051.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/arcnet/rfc1201.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ariadne.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ariadne.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ariadne2.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/arlan-proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/arlan.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/arlan.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/at1700.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/atari_bionet.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/atari_pamsnet.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/atarilance.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/atp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/atp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/auto_irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/bagetlance.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/bmac.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/bmac.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/bonding.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/bsd_comp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/cs89x0.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/cs89x0.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/daynaport.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/de4x5.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/de4x5.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/de600.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/de620.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/de620.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/declance.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/defxx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/defxx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/depca.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/depca.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/dgrs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/dgrs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/dgrs_asstruct.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/dgrs_bcomm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/dgrs_es4h.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/dgrs_ether.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/dgrs_firmware.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/dgrs_i82596.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/dgrs_plx9060.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/dmfe.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/dummy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/e2100.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/eepro.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/eepro100.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/eexpress.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/eexpress.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/epic100.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/eql.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/es3210.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/eth16i.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ethertap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ewrk3.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ewrk3.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/fc/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/fc/iph5526.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/fc/iph5526_ip.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/fc/iph5526_novram.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/fc/iph5526_scsi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/fc/tach.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/fc/tach_structs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/fmv18x.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/gmac.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/gmac.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamachi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/6pack.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/baycom_epp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/baycom_par.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/baycom_ser_fdx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/baycom_ser_hdx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/bpqether.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/dmascc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/hdlcdrv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/mkiss.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/mkiss.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/scc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/soundmodem/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/soundmodem/gentbl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/soundmodem/sm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/soundmodem/sm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/soundmodem/sm_afsk1200.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/soundmodem/sm_afsk2400_7.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/soundmodem/sm_afsk2400_8.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/soundmodem/sm_afsk2666.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/soundmodem/sm_fsk9600.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/soundmodem/sm_hapn4800.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/soundmodem/sm_psk4800.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/soundmodem/sm_sbc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/soundmodem/sm_wss.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/soundmodem/smdma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/yam.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/yam1200.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/yam9600.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hamradio/z8530.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hp-plus.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hp100.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hp100.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hplance.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hplance.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hydra.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/hydra.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/i82586.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ibmlana.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ibmlana.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ioc3-eth.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/irda/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/irda/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/irda/actisys.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/irda/esi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/irda/girbil.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/irda/irport.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/irda/irtty.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/irda/litelink.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/irda/nsc-ircc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/irda/old_belkin.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/irda/smc-ircc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/irda/tekram.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/irda/toshoboe.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/irda/w83977af_ir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/isa-skeleton.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/jazzsonic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/lance.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/lasi_82596.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/lne390.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/loopback.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/mac89x0.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/mace.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/mace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/macmace.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/macsonic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/mvme147.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/myri_code.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/myri_sbus.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/myri_sbus.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/natsemi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ncr885_debug.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ncr885e.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ncr885e.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ne.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ne2.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ne2k-pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ne3210.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/net_init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ni5010.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ni5010.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ni52.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ni52.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ni65.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ni65.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/oaknet.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/3c574_cs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/3c589_cs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/aironet4500_cs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/com20020_cs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/fmvj18x_cs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/i82593.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/ibmtr_cs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/netwave_cs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/nmclan_cs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/ositech.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/pcnet_cs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/ray_cs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/ray_cs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/rayctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/smc91c92_cs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/wavelan.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/wavelan_cs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/wavelan_cs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/xirc2ps_cs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcmcia/xircom_tulip_cb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pcnet32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/plip.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ppp_async.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ppp_deflate.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ppp_generic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ppp_synctty.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pppoe.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/pppox.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ptifddi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ptifddi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/ptifddi_asm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/rcif.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/rclanmtl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/rclanmtl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/rcpci45.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/rrunner.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/rrunner.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/rtl8129.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sb1000.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/seeq8005.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/seeq8005.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/setup.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sgiseeq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sgiseeq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/shaper.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sis900.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sis900.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/lm80.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/skaddr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/skcsum.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/skdebug.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/skdrv1st.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/skdrv2nd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/skerror.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/skgedrv.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/skgehw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/skgehwt.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/skgei2c.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/skgeinit.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/skgepnm2.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/skgepnmi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/skgesirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/ski2c.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/skqueue.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/skrlmt.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/sktimer.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/sktypes.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/skvpd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/h/xmac_ii.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/skaddr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/skcsum.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/skge.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/skgehwt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/skgeinit.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/skgepnmi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/skgesirq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/ski2c.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/sklm80.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/skqueue.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/skrlmt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/sktimer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/skvpd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk98lin/skxmac2.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk_g16.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk_g16.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk_mca.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sk_mca.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/can.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/cfm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/drvfbi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/ecm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/ess.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/fplustm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/h/cmtdef.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/h/fddi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/h/fddimib.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/h/fplustm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/h/hwmtm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/h/lnkstat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/h/mbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/h/osdef1st.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/h/sba.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/h/sba_def.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/h/skfbi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/h/skfbiinc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/h/smc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/h/smt.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/h/smt_p.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/h/smtstate.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/h/supern_2.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/h/targethw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/h/targetos.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/h/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/hwmtm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/hwt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/lnkstat.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/pcmplc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/pmf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/queue.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/rmt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/skfddi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/smt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/smtdef.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/smtinit.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/smtparse.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/smttimer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/skfp/srf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/slhc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/slip.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/slip.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/smc-mca.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/smc-mca.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/smc-ultra.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/smc-ultra32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/smc9194.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/smc9194.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sonic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sonic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/starfire.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/stnic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/strip.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sun3lance.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sunbmac.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sunbmac.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sundance.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sunhme.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sunhme.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sunlance.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sunqe.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/sunqe.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tlan.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tlan.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tokenring/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tokenring/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tokenring/abyss.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tokenring/abyss.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tokenring/ibmtr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tokenring/ibmtr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tokenring/lanstreamer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tokenring/lanstreamer.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tokenring/madgemc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tokenring/madgemc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tokenring/olympic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tokenring/olympic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tokenring/smctr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tokenring/smctr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tokenring/smctr_firmware.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tokenring/tms380tr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tokenring/tms380tr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tokenring/tms380tr_microcode.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tokenring/tmspci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tulip/21142.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tulip/ChangeLog#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tulip/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tulip/eeprom.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tulip/interrupt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tulip/media.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tulip/pnic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tulip/timer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tulip/tulip.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tulip/tulip_core.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/tun.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/via-rhine.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/comx-hw-comx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/comx-hw-locomx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/comx-hw-mixcom.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/comx-proto-fr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/comx-proto-lapb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/comx-proto-ppp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/comx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/comx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/comxhw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/cosa.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/cosa.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/cycx_drv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/cycx_main.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/cycx_x25.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/dlci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/hostess_sv11.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/hscx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/lapbether.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/lmc/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/lmc/lmc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/lmc/lmc_debug.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/lmc/lmc_debug.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/lmc/lmc_ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/lmc/lmc_main.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/lmc/lmc_media.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/lmc/lmc_media.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/lmc/lmc_prot.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/lmc/lmc_proto.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/lmc/lmc_proto.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/lmc/lmc_proto_raw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/lmc/lmc_var.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/lmc/lmc_ver.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/mixcom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/sbni.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/sbni.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/sdla.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/sdla_chdlc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/sdla_fr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/sdla_ppp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/sdla_x25.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/sdladrv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/sdlamain.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/sealevel.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/syncppp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/syncppp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/x25_asy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/x25_asy.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/z85230.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wan/z85230.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wavelan.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wavelan.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wavelan.p.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/wd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/winbond-840.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/yellowfin.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/zlib.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/zlib.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/net/znet.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/nubus/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/nubus/nubus.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/nubus/nubus_syms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/nubus/proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/parport/BUGS-parport#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/parport/ChangeLog#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/parport/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/parport/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/parport/TODO-parport#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/parport/daisy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/parport/ieee1284.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/parport/ieee1284_ops.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/parport/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/parport/multiface.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/parport/parport_amiga.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/parport/parport_arc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/parport/parport_atari.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/parport/parport_gsc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/parport/parport_mfc3.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/parport/parport_pc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/parport/parport_sunbpp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/parport/probe.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/parport/procfs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/parport/share.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pci/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pci/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pci/compat.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pci/gen-devlist.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pci/names.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pci/pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pci/pci.ids#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pci/proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pci/quirks.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pci/setup-bus.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pci/setup-irq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pci/setup-res.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pci/syscall.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/bulkmem.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/cardbus.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/cb_enabler.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/cirrus.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/cistpl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/cs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/cs_internal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/ds.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/i82365.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/i82365.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/o2micro.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/old-yenta.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/pci_socket.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/pci_socket.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/ricoh.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/rsrc_mgr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/rsrc_mgr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/smc34c90.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/tcic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/tcic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/ti113x.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/topic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/vg468.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/yenta.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pcmcia/yenta.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pnp/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pnp/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pnp/isapnp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pnp/isapnp_proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/pnp/quirks.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/block/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/block/dasd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/block/dasd_ccwstuff.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/block/dasd_ccwstuff.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/block/dasd_eckd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/block/dasd_erp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/block/dasd_erp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/block/dasd_mdsk.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/block/dasd_proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/block/dasd_profile.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/block/dasd_types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/block/mdisk.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/block/mdisk.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/char/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/char/con3215.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/char/hwc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/char/hwc_con.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/char/hwc_rw.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/char/hwc_rw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/char/hwc_tty.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/misc/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/misc/chandev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/net/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/net/ctc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/net/iucv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/s390/net/iucv.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/audio/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/audio/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/audio/amd7930.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/audio/amd7930.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/audio/audio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/audio/cs4215.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/audio/cs4231.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/audio/cs4231.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/audio/dbri.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/audio/dbri.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/audio/dmy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/audio/dummy.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/aurora.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/aurora.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/bpp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/cd180.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/display7seg.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/envctrl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/flash.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/jsflash.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/openprom.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/pcikbd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/pcikbd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/rtc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/sab82532.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/su.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/sunkbd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/sunkbd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/sunkbdmap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/sunkeymap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/sunkeymap.map#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/sunmouse.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/sunmouse.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/sunserial.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/sunserial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/uctrl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/vfc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/vfc_dev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/vfc_i2c.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/vfc_i2c.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/zs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/char/zs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/dvma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sbus/sbus.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/3w-xxxx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/3w-xxxx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/53c7,8xx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/53c7,8xx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/53c7,8xx.scr#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/53c7xx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/53c7xx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/53c7xx.scr#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/53c8xx_d.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/53c8xx_u.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/AM53C974.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/AM53C974.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/BusLogic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/BusLogic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ChangeLog#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ChangeLog.ips#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ChangeLog.ncr53c8xx#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ChangeLog.serverraid#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ChangeLog.sym53c8xx#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/FlashPoint.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/LICENSE.FlashPoint#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/NCR5380.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/NCR5380.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/NCR53C9x.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/NCR53C9x.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/NCR53c406a.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/NCR53c406a.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/README.AM53C974#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/README.BusLogic#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/README.FlashPoint#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/README.Mylex#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/README.aha152x#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/README.dtc3x80#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/README.g_NCR5380#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/README.ibmmca#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/README.in2000#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/README.ncr53c7xx#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/README.ncr53c8xx#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/README.osst#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/README.ppa#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/README.qlogicfas#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/README.qlogicisp#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/README.st#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/README.tmscsim#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/a2091.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/a2091.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/a3000.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/a3000.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/advansys.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/advansys.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aha152x.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aha152x.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aha1542.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aha1542.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aha1740.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aha1740.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7770.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7770_osm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx.reg#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx.seq#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx_core.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx_host.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx_inline.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx_osm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx_osm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx_pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic79xx_proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx.reg#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx.seq#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_93cx6.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_93cx6.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_core.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_host.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_inline.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_osm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_osm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_pci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aic7xxx_proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/aicasm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/aicasm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/aicasm_gram.y#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/aicasm_macro_gram.y#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/aicasm_macro_scan.l#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/aicasm_scan.l#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/cam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/queue.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/scsi_iu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx/scsi_message.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx_old.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx_old/README.aic7xxx#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx_old/aic7xxx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx_old/aic7xxx.reg#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx_old/aic7xxx.seq#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx_old/aic7xxx_proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx_old/aic7xxx_reg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx_old/aic7xxx_seq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx_old/scsi_message.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/aic7xxx_old/sequencer.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/amiga7xx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/amiga7xx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/atari_NCR5380.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/atari_dma_emul.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/atari_scsi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/atari_scsi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/atp870u.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/atp870u.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/blz1230.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/blz1230.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/blz2060.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/blz2060.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/bvme6000.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/bvme6000.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/constants.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/constants.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/cpqfc.Readme#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/cpqfcTS.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/cpqfcTSchip.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/cpqfcTScontrol.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/cpqfcTSi2c.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/cpqfcTSinit.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/cpqfcTSioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/cpqfcTSstructs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/cpqfcTStrigger.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/cpqfcTSworker.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/cpqioctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/cyberstorm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/cyberstorm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/cyberstormII.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/cyberstormII.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/dc390.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/dec_esp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/dec_esp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/dmx3191d.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/dmx3191d.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/dtc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/dtc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/eata.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/eata.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/eata_dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/eata_dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/eata_dma_proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/eata_dma_proc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/eata_generic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/eata_pio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/eata_pio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/eata_pio_proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/esp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/esp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/fastlane.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/fastlane.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/fcal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/fcal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/fd_mcs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/fd_mcs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/fdomain.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/fdomain.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/g_NCR5380.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/g_NCR5380.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/gdth.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/gdth.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/gdth_ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/gdth_proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/gdth_proc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/gvp11.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/gvp11.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/hosts.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/hosts.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/i60uscsi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/i60uscsi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/i91uscsi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/i91uscsi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ibmmca.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ibmmca.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ide-scsi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ide-scsi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/imm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/imm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/in2000.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/in2000.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ini9100u.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ini9100u.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/inia100.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/inia100.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ips.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ips.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/jazz_esp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/jazz_esp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/mac53c94.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/mac53c94.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/mac_NCR5380.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/mac_esp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/mac_esp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/mac_scsi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/mac_scsi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/mca_53c9x.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/mca_53c9x.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/megaraid.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/megaraid.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/mesh.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/mesh.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/mvme147.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/mvme147.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/mvme16x.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/mvme16x.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ncr53c8xx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ncr53c8xx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/oktagon_esp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/oktagon_esp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/oktagon_io.S#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/osst.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/osst.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/osst_detect.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/osst_options.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/pas16.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/pas16.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/pci2000.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/pci2000.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/pci2220i.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/pci2220i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/pcmcia/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/pcmcia/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/pcmcia/aha152x_stub.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/pcmcia/fdomain_stub.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/pcmcia/qlogic_stub.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/pluto.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/pluto.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ppa.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ppa.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/psi240i.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/psi240i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/psi_chip.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/psi_dale.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/psi_roy.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ql12160_fw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ql1280_fw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/qla1280.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/qla1280.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/qlogicfas.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/qlogicfas.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/qlogicfc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/qlogicfc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/qlogicfc_asm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/qlogicisp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/qlogicisp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/qlogicisp_asm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/qlogicpti.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/qlogicpti.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/qlogicpti_asm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/script_asm.pl#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/scsi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/scsi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/scsi_debug.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/scsi_debug.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/scsi_dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/scsi_error.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/scsi_ioctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/scsi_lib.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/scsi_merge.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/scsi_module.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/scsi_obsolete.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/scsi_obsolete.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/scsi_proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/scsi_queue.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/scsi_scan.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/scsi_syms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/scsicam.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/scsiiom.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/seagate.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/seagate.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sg.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sgiwd93.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sgiwd93.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sim710.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sim710.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sim710.scr#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sim710_d.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sim710_u.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sr_ioctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sr_vendor.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/st.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/st.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/st_options.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sun3_NCR5380.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sun3_scsi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sun3_scsi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sun3x_esp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sun3x_esp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sym53c416.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sym53c416.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sym53c8xx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sym53c8xx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sym53c8xx_comm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/sym53c8xx_defs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/t128.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/t128.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/tmscsim.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/tmscsim.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/u14-34f.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/u14-34f.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ultrastor.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/ultrastor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/wd33c93.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/wd33c93.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/wd7000.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/scsi/wd7000.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sgi/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sgi/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sgi/char/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sgi/char/ds1286.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sgi/char/gconsole.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sgi/char/graphics.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sgi/char/graphics.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sgi/char/graphics_syms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sgi/char/linux_logo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sgi/char/newport.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sgi/char/rrm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sgi/char/sgicons.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sgi/char/sgiserial.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sgi/char/sgiserial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sgi/char/shmiq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sgi/char/streamable.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sgi/char/usema.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sgi/char/usema.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/.indent.pro#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/.version#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/724hwmcode.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/CHANGELOG#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/COPYING#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/Hwmcode.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/README.FIRST#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/ac97.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/ac97.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/ac97_codec.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/aci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/ad1816.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/ad1848.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/ad1848.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/ad1848_mixer.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/adlib_card.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/aedsp16.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/audio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/audio_syms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/awe_hw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/awe_wave.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/awe_wave.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/bin2hex.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/cmpci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/coproc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/cs4232.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/cs4232.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/cs4281.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/cs4281_hwdefs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/cs461x.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/cs461x_image.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/cs46xx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/dev_table.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/dev_table.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/dm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/dmabuf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/dmasound/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/dmasound/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/dmasound/awacs_defs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/dmasound/dmasound.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/dmasound/dmasound_atari.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/dmasound/dmasound_awacs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/dmasound/dmasound_core.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/dmasound/dmasound_paula.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/dmasound/dmasound_q40.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/8010.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/audio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/audio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/cardmi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/cardmi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/cardmo.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/cardmo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/cardwi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/cardwi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/cardwo.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/cardwo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/ecard.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/ecard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/efxmgr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/emu_wrapper.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/emuadxmg.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/hwaccess.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/hwaccess.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/icardmid.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/icardwav.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/irqmgr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/irqmgr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/main.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/midi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/midi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/mixer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/recmgr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/recmgr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/timer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/timer.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/voicemgr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/emu10k1/voicemgr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/es1370.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/es1371.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/esssolo1.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/gus.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/gus_card.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/gus_hw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/gus_linearvol.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/gus_midi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/gus_vol.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/gus_wave.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/hex2hex.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/i810_audio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/ics2101.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/iwmem.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/mad16.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/maestro.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/maestro.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/maestro_tables.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/maui.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/midi_ctrl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/midi_syms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/midi_synth.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/midi_synth.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/midibuf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/miroaci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/mpu401.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/mpu401.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/msnd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/msnd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/msnd_classic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/msnd_classic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/msnd_pinnacle.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/msnd_pinnacle.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/nm256.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/nm256_audio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/nm256_coeff.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/opl3.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/opl3.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/opl3_hw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/opl3sa.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/opl3sa2.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/os.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/pas2.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/pas2_card.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/pas2_midi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/pas2_mixer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/pas2_pcm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/pss.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sb_audio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sb_card.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sb_common.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sb_ess.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sb_ess.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sb_midi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sb_mixer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sb_mixer.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sequencer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sequencer_syms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sgalaxy.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/skeleton.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sonicvibes.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sound_calls.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sound_config.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sound_core.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sound_firmware.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sound_firmware.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sound_syms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sound_timer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/soundcard.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/soundvers.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sscape.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/sys_timer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/trident.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/trident.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/trix.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/tuning.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/uart401.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/uart6850.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/ulaw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/v_midi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/v_midi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/via82cxxx_audio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/vidc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/vidc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/vidc_fill.S#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/vwsnd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/waveartist.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/waveartist.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/wavfront.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/wf_midi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/ymf_sb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/ymfpci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/ymfpci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/ymfpci_image.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/yss225.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/sound/yss225.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/tc/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/tc/tc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/tc/tcsyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/tc/zs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/tc/zs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/telephony/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/telephony/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/telephony/ixj.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/telephony/ixj.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/telephony/phonedev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/acm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/audio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/audio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/bluetooth.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/dabfirmware.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/dabusb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/dabusb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/dc2xx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/devices.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/devio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/drivers.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/dsbr100.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/hid-debug.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/hid.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/hid.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/hub.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/hub.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/ibmcam.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/ibmcam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/mdc800.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/microtek.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/microtek.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/net1080.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/ov511.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/ov511.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/pegasus.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/pegasus.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/plusb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/printer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/rio500.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/rio500_usb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/scanner.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/scanner.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/Makefile-keyspan_pda_fw#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/belkin_sa.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/belkin_sa.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/digi_acceleport.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/empeg.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/ezusb_convert.pl#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/ftdi_sio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/ftdi_sio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/keyspan.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/keyspan.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/keyspan_pda.S#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/keyspan_pda.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/keyspan_pda_fw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/keyspan_usa18x_fw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/keyspan_usa19_fw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/keyspan_usa19w_fw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/keyspan_usa26msg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/keyspan_usa28_fw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/keyspan_usa28msg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/keyspan_usa28x_fw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/keyspan_usa49msg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/keyspan_usa49w_fw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/mct_u232.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/mct_u232.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/omninet.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/usb-serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/usbserial.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/visor.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/visor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/whiteheat.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/whiteheat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/serial/whiteheat_fw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/debug.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/debug.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/dpcm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/dpcm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/freecom.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/freecom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/initializers.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/initializers.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/protocol.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/protocol.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/scsiglue.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/scsiglue.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/sddr09.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/sddr09.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/shuttle_usbat.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/shuttle_usbat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/transport.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/transport.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/usb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/storage/usb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/uhci-debug.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/uhci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/uhci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/usb-debug.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/usb-ohci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/usb-ohci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/usb-uhci-debug.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/usb-uhci.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/usb-uhci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/usb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/usbkbd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/usbmouse.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/uss720.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/usb/wacom.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/S3triofb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/acornfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/acornfb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/amifb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/atafb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/aty.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/aty128.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/aty128fb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/atyfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/bwtwofb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/cgfourteenfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/cgsixfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/cgthreefb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/chipsfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/clgenfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/clgenfb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/controlfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/controlfb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/creatorfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/cvisionppc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/cyber2000fb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/cyber2000fb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/cyberfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/cyberfb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/dn_accel.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/dn_cfb4.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/dn_cfb8.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/dnfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/dummycon.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbcmap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbcon-afb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbcon-cfb16.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbcon-cfb2.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbcon-cfb24.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbcon-cfb32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbcon-cfb4.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbcon-cfb8.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbcon-hga.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbcon-ilbm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbcon-iplan2p2.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbcon-iplan2p4.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbcon-iplan2p8.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbcon-mac.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbcon-mfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbcon-sti.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbcon-vga-planes.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbcon-vga.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbcon.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbgen.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbmem.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fbmon.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fm2fb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/font_6x11.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/font_8x16.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/font_8x8.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/font_acorn_8x8.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/font_pearl_8x8.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/font_sun12x22.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/font_sun8x16.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/fonts.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/g364fb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/hgafb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/hitfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/hpfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/iga.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/igafb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/imsttfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/leofb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/macfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/macmodes.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/matrox/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/matrox/i2c-matroxfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/matrox/matroxfb_DAC1064.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/matrox/matroxfb_DAC1064.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/matrox/matroxfb_Ti3026.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/matrox/matroxfb_Ti3026.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/matrox/matroxfb_accel.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/matrox/matroxfb_accel.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/matrox/matroxfb_base.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/matrox/matroxfb_base.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/matrox/matroxfb_crtc2.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/matrox/matroxfb_crtc2.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/matrox/matroxfb_g450.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/matrox/matroxfb_g450.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/matrox/matroxfb_maven.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/matrox/matroxfb_maven.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/matrox/matroxfb_misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/matrox/matroxfb_misc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/mdacon.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/modedb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/newport_con.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/offb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/p9100.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/p9100fb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/platinumfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/platinumfb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/pm2fb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/pm2fb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/prom.uni#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/promcon.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/q40fb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/retz3fb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/retz3fb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/riva/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/riva/fbdev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/riva/nv4ref.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/riva/nvreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/riva/riva_hw.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/riva/riva_hw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/riva/riva_tbl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/sa1100fb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/sbusfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/sgivwfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/sgivwfb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/sis/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/sis/initdef.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/sis/sis.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/sis/sis_300.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/sis/sis_300.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/sis/sis_301.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/sis/sis_301.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/sis/sis_main.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/skeletonfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/sti-bmode.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/sti.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/sticon-bmode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/sticon.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/sticore.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/stifb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/sun3fb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/tcxfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/tdfxfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/tgafb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/tgafb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/valkyriefb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/valkyriefb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/vesafb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/vfb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/vga.h#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/vga16fb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/vgacon.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/video/virgefb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/zorro/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/zorro/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/zorro/gen-devlist.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/zorro/names.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/zorro/proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/zorro/zorro.c#1 branch
-... //depot/linux-aic79xx-2.4.0/drivers/zorro/zorro.ids#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ChangeLog#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/adfs/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/adfs/adfs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/adfs/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/adfs/dir_f.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/adfs/dir_f.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/adfs/dir_fplus.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/adfs/dir_fplus.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/adfs/file.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/adfs/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/adfs/map.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/adfs/super.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/affs/Changes#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/affs/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/affs/amigaffs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/affs/bitmap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/affs/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/affs/file.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/affs/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/affs/namei.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/affs/super.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/affs/symlink.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/attr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/autofs/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/autofs/autofs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/autofs/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/autofs/dirhash.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/autofs/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/autofs/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/autofs/root.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/autofs/symlink.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/autofs/waitq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/autofs4/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/autofs4/autofs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/autofs4/expire.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/autofs4/init.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/autofs4/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/autofs4/root.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/autofs4/symlink.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/autofs4/waitq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/bad_inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/bfs/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/bfs/bfs_defs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/bfs/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/bfs/file.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/bfs/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/binfmt_aout.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/binfmt_elf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/binfmt_em86.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/binfmt_misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/binfmt_script.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/block_dev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/buffer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/coda/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/coda/cache.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/coda/cnode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/coda/coda_linux.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/coda/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/coda/file.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/coda/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/coda/pioctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/coda/psdev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/coda/symlink.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/coda/sysctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/coda/upcall.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/README#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/cramfs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/inflate/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/inflate/adler32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/inflate/infblock.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/inflate/infblock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/inflate/infcodes.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/inflate/infcodes.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/inflate/inffast.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/inflate/inffast.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/inflate/inffixed.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/inflate/inflate.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/inflate/inftrees.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/inflate/inftrees.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/inflate/infutil.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/inflate/infutil.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/inflate/uncompr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/inflate/zconf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/inflate/zlib.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/inflate/zutil.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/cramfs/uncompress.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/dcache.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/devfs/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/devfs/base.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/devfs/util.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/devices.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/devpts/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/devpts/devpts_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/devpts/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/devpts/root.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/dnotify.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/dquot.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/efs/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/efs/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/efs/file.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/efs/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/efs/namei.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/efs/super.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/efs/symlink.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/exec.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ext2/CHANGES#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ext2/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ext2/acl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ext2/balloc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ext2/bitmap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ext2/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ext2/file.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ext2/fsync.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ext2/ialloc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ext2/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ext2/ioctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ext2/namei.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ext2/super.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ext2/symlink.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/fat/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/fat/buffer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/fat/cache.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/fat/cvf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/fat/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/fat/fatfs_syms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/fat/file.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/fat/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/fat/misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/fat/msbuffer.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/fat/tables.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/fat/tables.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/fcntl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/fifo.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/file.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/file_table.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/filesystems.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/COPYING#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/ChangeLog#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/FAQ.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/HFS.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/INSTALL.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/TODO#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/balloc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/bdelete.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/bfind.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/bins_del.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/binsert.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/bitmap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/bitops.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/bnode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/brec.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/btree.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/catalog.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/dir_cap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/dir_dbl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/dir_nat.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/extent.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/file.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/file_cap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/file_hdr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/hfs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/hfs_btree.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/mdb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/part_tbl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/string.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/super.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/sysdep.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/trans.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hfs/version.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hpfs/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hpfs/alloc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hpfs/anode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hpfs/buffer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hpfs/dentry.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hpfs/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hpfs/dnode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hpfs/ea.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hpfs/file.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hpfs/hpfs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hpfs/hpfs_fn.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hpfs/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hpfs/map.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hpfs/name.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hpfs/namei.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/hpfs/super.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/iobuf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ioctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/isofs/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/isofs/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/isofs/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/isofs/joliet.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/isofs/namei.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/isofs/rock.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/isofs/rock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/isofs/util.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/jffs/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/jffs/inode-v23.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/jffs/intrep.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/jffs/intrep.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/jffs/jffs_fm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/jffs/jffs_fm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/lockd/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/lockd/clntlock.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/lockd/clntproc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/lockd/host.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/lockd/lockd_syms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/lockd/mon.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/lockd/svc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/lockd/svc4proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/lockd/svclock.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/lockd/svcproc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/lockd/svcshare.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/lockd/svcsubs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/lockd/xdr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/lockd/xdr4.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/locks.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/minix/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/minix/bitmap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/minix/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/minix/file.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/minix/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/minix/itree_common.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/minix/itree_v1.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/minix/itree_v2.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/minix/namei.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/msdos/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/msdos/msdosfs_syms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/msdos/namei.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/namei.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ncpfs/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ncpfs/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ncpfs/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ncpfs/file.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ncpfs/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ncpfs/ioctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ncpfs/mmap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ncpfs/ncplib_kernel.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ncpfs/ncplib_kernel.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ncpfs/ncpsign_kernel.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ncpfs/ncpsign_kernel.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ncpfs/sock.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ncpfs/symlink.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfs/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfs/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfs/file.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfs/flushd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfs/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfs/mount_clnt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfs/nfs2xdr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfs/nfs3proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfs/nfs3xdr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfs/nfsroot.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfs/proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfs/read.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfs/symlink.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfs/unlink.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfs/write.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfsd/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfsd/auth.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfsd/export.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfsd/lockd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfsd/nfs3proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfsd/nfs3xdr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfsd/nfscache.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfsd/nfsctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfsd/nfsfh.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfsd/nfsproc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfsd/nfssvc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfsd/nfsxdr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfsd/stats.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nfsd/vfs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_base.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_big5.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_cp437.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_cp737.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_cp775.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_cp850.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_cp852.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_cp855.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_cp857.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_cp860.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_cp861.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_cp862.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_cp863.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_cp864.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_cp865.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_cp866.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_cp869.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_cp874.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_cp932.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_cp936.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_cp949.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_cp950.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_euc-jp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_euc-kr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_gb2312.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_iso8859-1.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_iso8859-14.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_iso8859-15.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_iso8859-2.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_iso8859-3.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_iso8859-4.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_iso8859-5.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_iso8859-6.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_iso8859-7.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_iso8859-8.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_iso8859-9.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_koi8-r.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_sjis.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/nls/nls_utf8.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/noquot.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ntfs/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ntfs/attr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ntfs/attr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ntfs/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ntfs/dir.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ntfs/fs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ntfs/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ntfs/inode.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ntfs/macros.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ntfs/ntfsendian.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ntfs/ntfstypes.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ntfs/struct.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ntfs/super.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ntfs/super.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ntfs/support.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ntfs/support.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ntfs/sysctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ntfs/sysctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ntfs/util.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ntfs/util.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/open.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/openpromfs/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/openpromfs/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/acorn.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/acorn.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/amiga.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/amiga.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/atari.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/atari.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/check.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/check.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/ibm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/ibm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/mac.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/mac.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/msdos.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/msdos.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/osf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/osf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/sgi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/sgi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/sun.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/sun.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/ultrix.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/partitions/ultrix.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/pipe.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/proc/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/proc/array.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/proc/base.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/proc/generic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/proc/inode-alloc.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/proc/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/proc/kcore.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/proc/kmsg.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/proc/proc_devtree.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/proc/proc_misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/proc/proc_tty.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/proc/procfs_syms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/proc/root.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/qnx4/BUGS#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/qnx4/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/qnx4/README#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/qnx4/TODO#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/qnx4/bitmap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/qnx4/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/qnx4/file.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/qnx4/fsync.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/qnx4/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/qnx4/namei.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/qnx4/truncate.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ramfs/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ramfs/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/read_write.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/readdir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/romfs/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/romfs/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/select.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/smbfs/ChangeLog#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/smbfs/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/smbfs/cache.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/smbfs/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/smbfs/file.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/smbfs/getopt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/smbfs/getopt.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/smbfs/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/smbfs/ioctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/smbfs/proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/smbfs/smb_debug.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/smbfs/sock.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/stat.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/super.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/sysv/CHANGES#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/sysv/INTRO#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/sysv/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/sysv/balloc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/sysv/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/sysv/file.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/sysv/fsync.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/sysv/ialloc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/sysv/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/sysv/namei.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/sysv/truncate.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/balloc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/crc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/directory.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/file.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/fsync.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/ialloc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/lowlevel.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/namei.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/partition.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/super.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/symlink.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/truncate.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/udf_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/udf_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/udfdecl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/udfend.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/udftime.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/udf/unicode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ufs/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ufs/balloc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ufs/cylinder.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ufs/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ufs/file.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ufs/ialloc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ufs/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ufs/namei.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ufs/super.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ufs/swab.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ufs/symlink.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ufs/truncate.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ufs/util.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/ufs/util.h#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/umsdos/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/umsdos/README-WIP.txt#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/umsdos/dir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/umsdos/emd.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/umsdos/inode.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/umsdos/ioctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/umsdos/mangle.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/umsdos/namei.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/umsdos/notes#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/umsdos/rdir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/umsdos/specs#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/vfat/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/vfat/namei.c#1 branch
-... //depot/linux-aic79xx-2.4.0/fs/vfat/vfatfs_syms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/a.out.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/asm_offsets.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/atomic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/bitops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/bugs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/byteorder.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/cache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/checksum.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/compiler.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/console.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/core_apecs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/core_cia.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/core_irongate.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/core_lca.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/core_mcpcia.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/core_polaris.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/core_t2.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/core_titan.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/core_tsunami.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/core_wildfire.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/current.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/delay.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/div64.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/elf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/errno.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/fcntl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/floppy.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/fpu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/gentrap.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/hardirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/hdreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/hw_irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/hwrpb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/init.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/ioctls.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/ipcbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/jensen.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/linux_logo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/machvec.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/mc146818rtc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/md.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/mman.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/mmu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/mmu_context.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/module.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/msgbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/namei.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/page.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/pal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/parport.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/pci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/pgalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/pgtable.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/poll.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/posix_types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/processor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/ptrace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/reg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/resource.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/scatterlist.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/segment.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/semaphore.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/sembuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/sfp-machine.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/shmbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/shmparam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/sigcontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/siginfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/signal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/smp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/smplock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/socket.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/sockios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/softirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/spinlock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/stat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/statfs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/string.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/sysinfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/termbits.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/termios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/uaccess.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/ucontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/unaligned.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/unistd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/user.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/vga.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-alpha/xor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/a.out.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-arc/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-arc/hardware.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-arc/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-arc/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-arc/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-arc/irqs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-arc/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-arc/memory.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-arc/oldlatches.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-arc/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-arc/serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-arc/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-arc/time.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-arc/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-arc/uncompress.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-cl7500/acornfb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-cl7500/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-cl7500/hardware.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-cl7500/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-cl7500/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-cl7500/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-cl7500/irqs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-cl7500/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-cl7500/memory.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-cl7500/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-cl7500/serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-cl7500/shmparam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-cl7500/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-cl7500/time.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-cl7500/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-cl7500/uncompress.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-cl7500/vmalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa110/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa110/hardware.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa110/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa110/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa110/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa110/irqs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa110/memory.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa110/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa110/processor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa110/serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa110/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa110/time.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa110/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa110/uncompress.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa110/vmalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa285/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa285/hardware.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa285/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa285/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa285/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa285/irqs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa285/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa285/memory.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa285/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa285/serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa285/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa285/time.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa285/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa285/uncompress.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-ebsa285/vmalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-l7200/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-l7200/hardware.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-l7200/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-l7200/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-l7200/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-l7200/irqs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-l7200/memory.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-l7200/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-l7200/serial_l7200.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-l7200/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-l7200/time.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-l7200/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-l7200/uncompress.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-l7200/vmalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-nexuspci/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-nexuspci/hardware.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-nexuspci/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-nexuspci/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-nexuspci/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-nexuspci/irqs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-nexuspci/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-nexuspci/memory.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-nexuspci/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-nexuspci/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-nexuspci/time.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-nexuspci/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-nexuspci/uncompress.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-nexuspci/vmalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-rpc/acornfb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-rpc/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-rpc/hardware.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-rpc/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-rpc/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-rpc/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-rpc/irqs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-rpc/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-rpc/memory.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-rpc/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-rpc/serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-rpc/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-rpc/time.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-rpc/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-rpc/uncompress.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-rpc/vmalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/SA-1100.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/SA-1101.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/SA-1111.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/assabet.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/bitfield.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/bitsy.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/cerf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/hardware.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/irqs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/memory.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/mmzone.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/processor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/serial_reg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/thinclient.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/time.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/uncompress.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-sa1100/vmalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-shark/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-shark/hardware.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-shark/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-shark/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-shark/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-shark/irqs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-shark/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-shark/memory.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-shark/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-shark/serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-shark/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-shark/time.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-shark/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-shark/uncompress.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-shark/vmalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-tbox/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-tbox/hardware.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-tbox/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-tbox/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-tbox/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-tbox/irqs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-tbox/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-tbox/memory.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-tbox/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-tbox/serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-tbox/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-tbox/time.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-tbox/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-tbox/uncompress.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/arch-tbox/vmalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/assembler.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/atomic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/bitops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/bugs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/byteorder.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/cache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/checksum.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/cpu-multi26.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/cpu-multi32.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/cpu-single.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/current.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/delay.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/div64.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/ecard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/elf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/errno.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/fcntl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/fiq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/floppy.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/hardirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/hardware.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/hardware/dec21285.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/hardware/ioc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/hardware/iomd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/hardware/memc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/hardware/pci_v3.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/hardware/serial_amba.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/hdreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/ioctls.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/ipc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/ipcbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/leds.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/limits.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/linux_logo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/mach/arch.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/mach/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/mach/map.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/mach/pci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/mc146818rtc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/memory.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/mman.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/mmu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/mmu_context.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/mmzone.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/module.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/msgbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/namei.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/nwflash.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/page.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/parport.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/pci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/pgalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/pgtable.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/poll.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/posix_types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armo/assembler.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armo/cache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armo/elf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armo/locks.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armo/page.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armo/pgtable.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armo/processor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armo/ptrace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armo/shmparam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armo/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armo/uaccess.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armo/uncompress.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armv/assembler.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armv/cache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armv/domain.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armv/elf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armv/locks.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armv/page.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armv/pgtable.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armv/processor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armv/ptrace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armv/shmparam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armv/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armv/uaccess.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-armv/uncompress.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/proc-fns.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/processor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/procinfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/ptrace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/resource.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/scatterlist.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/segment.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/semaphore-helper.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/semaphore.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/sembuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/setup.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/shmbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/shmparam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/sigcontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/siginfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/signal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/smp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/smplock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/socket.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/sockios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/softirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/spinlock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/stat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/statfs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/string.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/termbits.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/termios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/therm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/uaccess.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/ucontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/unaligned.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/unistd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/user.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/vga.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/vt.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-arm/xor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-generic/bitops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-generic/pgtable.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-generic/smplock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-generic/unaligned.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-generic/xor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/a.out.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/apic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/apicdef.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/atomic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/bitops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/boot.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/bugs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/byteorder.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/cache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/checksum.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/cobalt.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/cpufeature.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/current.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/debugreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/delay.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/desc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/div64.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/e820.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/elf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/errno.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/fcntl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/fixmap.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/floppy.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/hardirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/hdreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/highmem.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/hw_irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/i387.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/init.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/io_apic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/ioctls.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/ipc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/ipcbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/kmap_types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/ldt.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/linux_logo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/lithium.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/locks.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/math_emu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/mc146818rtc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/mca_dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/mman.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/mmu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/mmu_context.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/mmx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/module.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/mpspec.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/msgbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/msr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/mtrr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/namei.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/page.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/parport.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/pci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/pgalloc-2level.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/pgalloc-3level.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/pgalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/pgtable-2level.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/pgtable-3level.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/pgtable.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/poll.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/posix_types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/processor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/ptrace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/resource.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/rwlock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/scatterlist.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/segment.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/semaphore.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/sembuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/setup.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/shmbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/shmparam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/sigcontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/siginfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/signal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/smp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/smplock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/socket.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/sockios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/softirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/spinlock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/stat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/statfs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/string-486.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/string.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/termbits.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/termios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/uaccess.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/ucontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/unaligned.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/unistd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/user.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/vga.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/vm86.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-i386/xor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/a.out.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/acpi-ext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/acpikcfg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/asmmacro.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/atomic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/bitops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/break.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/bugs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/byteorder.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/cache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/checksum.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/current.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/delay.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/div64.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/efi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/elf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/errno.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/fcntl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/fpswa.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/fpu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/hardirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/hdreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/hw_irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/ia32.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/ioctls.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/iosapic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/ipc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/ipcbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/linux_logo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/machvec.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/machvec_dig.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/machvec_hpsim.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/machvec_init.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/machvec_sn1.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/mca.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/mca_asm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/mman.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/mmu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/mmu_context.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/module.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/msgbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/namei.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/offsets.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/page.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/pal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/parport.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/pci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/pgalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/pgtable.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/poll.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/posix_types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/processor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/ptrace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/ptrace_offsets.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/resource.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/rse.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/scatterlist.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/segment.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/semaphore.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sembuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/shmbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/shmparam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sigcontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/siginfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/signal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/smp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/smplock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/addrs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/agent.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/alenlist.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/arc/hinv.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/arc/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/arch.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/cdl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/clksupport.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/cmn_err.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/dmamap.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/driver.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/eeprom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/gda.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/hack.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/hcl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/hcl_util.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/hubspc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/hwcntrs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/intr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/intr_public.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/invent.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/iobus.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/ioc3.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/ioerror.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/ioerror_handling.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/iograph.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/klconfig.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/kldir.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/ksys/elsc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/ksys/i2c.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/ksys/l1.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/labelcl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/mem_refcnt.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/mmzone.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/mmzone_default.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/mmzone_sn1.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/module.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/nic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/nodemask.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/nodepda.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/pci/bridge.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/pci/pci_bus_cvlink.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/pci/pci_defs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/pci/pcibr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/pci/pcibr_private.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/pci/pciio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/pci/pciio_private.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/pio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/prio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/router.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sgi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/slotnum.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/addrs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/arch.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/bedrock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/hubdev.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/hubio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/hubio_next.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/hublb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/hublb_next.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/hubmd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/hubmd_next.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/hubni.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/hubni_next.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/hubpi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/hubpi_next.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/hubxb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/hubxb_next.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/ip27config.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/kldir.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/leds.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/promlog.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/router.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/slotnum.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/sn1.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/uart16550.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn1/war.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn_cpuid.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn_fru.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/sn_private.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/synergy.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/systeminfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/vector.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/war.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/xtalk/xbow.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/xtalk/xbow_info.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/xtalk/xswitch.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/xtalk/xtalk.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/xtalk/xtalk_private.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/xtalk/xtalkaddrs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sn/xtalk/xwidget.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/socket.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/sockios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/softirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/spinlock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/stat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/statfs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/string.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/termbits.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/termios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/uaccess.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/unaligned.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/unistd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/unwind.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/user.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/vga.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ia64/xor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/a.out.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/adb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/adb_iop.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/adb_mouse.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/amigahw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/amigaints.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/amigayle.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/amipcmcia.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/apollodma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/apollohw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/atafd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/atafdreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/atari_SCCserial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/atari_SLM.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/atari_acsi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/atari_joystick.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/atari_stdma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/atari_stram.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/atarihw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/atariints.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/atarikb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/atomic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/bitops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/blinken.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/bootinfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/bugs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/bvme6000hw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/byteorder.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/cache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/cachectl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/checksum.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/contregs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/current.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/delay.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/div64.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/dsp56k.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/dvma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/elf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/entry.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/errno.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/fbio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/fcntl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/floppy.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/fpu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/hardirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/hdreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/hwtest.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/idprom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/init.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/intersil.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/ioctls.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/ipc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/ipcbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/kbio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/linux_logo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/mac_asc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/mac_baboon.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/mac_iop.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/mac_mouse.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/mac_oss.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/mac_psc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/mac_via.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/machdep.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/machines.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/machw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/macintosh.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/macints.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/math-emu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/md.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/mman.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/mmu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/mmu_context.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/module.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/motorola_pgalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/motorola_pgtable.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/movs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/msgbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/mvme147hw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/mvme16xhw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/namei.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/openprom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/oplib.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/page.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/page_offset.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/parport.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/pci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/pgalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/pgtable.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/poll.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/posix_types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/processor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/ptrace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/q40_keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/q40_master.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/q40ints.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/resource.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/sbus.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/scatterlist.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/segment.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/semaphore-helper.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/semaphore.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/sembuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/setup.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/shm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/shmbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/shmparam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/sigcontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/siginfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/signal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/smplock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/socket.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/sockios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/softirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/spinlock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/stat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/statfs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/string.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/sun3-head.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/sun3_pgalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/sun3_pgtable.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/sun3ints.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/sun3mmu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/sun3x.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/swim_iop.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/termbits.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/termios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/traps.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/uaccess.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/ucontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/unaligned.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/unistd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/user.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/virtconvert.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/vuid_event.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-m68k/xor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/a.out.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/addrspace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/arc/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/asm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/asmmacro.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/atomic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/baget/baget.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/baget/vac.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/baget/vic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/bcache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/bitops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/bootinfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/branch.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/bugs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/byteorder.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/cache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/cachectl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/cacheops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/checksum.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/cpu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/current.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/ddb5074.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/dec/interrupts.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/dec/ioasic_addrs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/dec/ioasic_ints.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/dec/kn01.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/dec/kn02.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/dec/kn02xa.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/dec/kn03.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/dec/machtype.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/dec/tc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/dec/tcinfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/dec/tcmodule.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/delay.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/div64.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/ds1286.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/elf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/errno.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/fcntl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/floppy.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/fp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/fpregdef.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/gdb-stub.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/gfx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/hardirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/hdreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/hw_irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/init.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/inst.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/inventory.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/ioctls.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/ipc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/ipcbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/isadep.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/jazz.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/jazzdma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/linux_logo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/mc146818rtc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/mipsprom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/mipsregs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/mman.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/mmu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/mmu_context.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/module.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/msgbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/namei.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/ng1.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/ng1hw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/nile4.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/orion.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/paccess.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/page.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/parport.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/pci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/pgalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/pgtable.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/poll.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/posix_types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/prctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/processor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/ptrace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/r4kcache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/reboot.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/reg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/regdef.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/resource.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/rrm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/scatterlist.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/segment.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/semaphore-helper.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/semaphore.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/sembuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/sfp-machine.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/sgi/sgi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/sgi/sgihpc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/sgi/sgimc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/sgi/sgint23.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/sgialib.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/sgiarcs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/sgidefs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/shmbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/shmiq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/shmparam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/sigcontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/siginfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/signal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/smp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/smplock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/sni.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/socket.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/sockios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/softirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/spinlock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/stackframe.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/stat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/statfs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/string.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/sysmips.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/termbits.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/termios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/uaccess.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/ucontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/umap.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/unaligned.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/unistd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/user.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/usioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/vga.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/watch.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/wbflush.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips/xor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/a.out.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/addrspace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/arc/hinv.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/arc/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/asm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/asmmacro.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/atomic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/bcache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/bitops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/bootinfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/branch.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/bugs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/byteorder.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/cache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/cachectl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/checksum.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/cpu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/current.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/delay.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/div64.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/ds1286.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/elf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/errno.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/fcntl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/floppy.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/fpregdef.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/gfx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/hardirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/hdreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/hw_irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/init.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/inst.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/ioctls.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/ipc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/ipcbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/linux_logo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/m48t35.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/mc146818rtc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/mipsregs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/mman.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/mmu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/mmu_context.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/mmzone.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/module.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/msgbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/namei.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/ng1.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/paccess.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/page.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/parport.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/pci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/pci/bridge.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/pgalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/pgtable.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/poll.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/posix_types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/processor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/ptrace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/r10kcache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/r10kcacheops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/r4kcache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/r4kcacheops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/reg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/regdef.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/resource.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/riscos-syscall.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/scatterlist.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/segment.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/semaphore-helper.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/semaphore.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sembuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sfp-machine.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sgi/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sgi/sgi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sgi/sgihpc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sgi/sgimc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sgi/sgint23.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sgialib.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sgiarcs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sgidefs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/shmbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/shmiq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/shmparam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sigcontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/siginfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/signal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/smp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/smplock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/addrs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/agent.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/arch.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/gda.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/intr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/intr_public.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/ioc3.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/klconfig.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/kldir.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/klkernvars.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/launch.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/mapped_kernel.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/nmi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/sn0/addrs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/sn0/arch.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/sn0/hub.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/sn0/hubio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/sn0/hubmd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/sn0/hubni.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/sn0/hubpi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/sn0/ip27.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/sn0/sn0_fru.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/sn_private.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sn/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/socket.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sockios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/softirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/spinlock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/stackframe.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/stat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/statfs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/string.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/sysmips.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/termbits.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/termios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/uaccess.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/ucontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/unaligned.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/unistd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/user.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/usioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/watch.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/xor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/xtalk/xtalk.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-mips64/xtalk/xwidget.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/a.out.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/asmregs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/assembly.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/atomic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/bitops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/bootdata.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/bugs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/byteorder.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/cache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/checksum.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/current.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/delay.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/div64.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/elf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/errno.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/fcntl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/fixmap.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/gsc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/hardirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/hardware.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/hdreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/hil.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/hw_irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/ioctls.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/iosapic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/ipcbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/led.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/linux_logo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/machdep.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/mc146818rtc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/md.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/mman.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/mmu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/mmu_context.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/msgbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/namei.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/page.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/parport.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/parport_gsc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/pci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/pdc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/pdcpat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/pgalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/pgtable.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/poll.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/posix_types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/processor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/psw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/ptrace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/real.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/resource.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/runway.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/scatterlist.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/segment.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/semaphore-helper.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/semaphore.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/sembuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/setup.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/shmbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/shmparam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/sigcontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/siginfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/signal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/smp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/smplock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/socket.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/sockios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/softirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/som.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/spinlock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/stat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/statfs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/string.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/termbits.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/termios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/traps.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/uaccess.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/ucontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/unaligned.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/unistd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-parisc/user.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/8xx_immap.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/a.out.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/amigahw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/amigaints.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/amigappc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/amigayle.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/amipcmcia.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/atomic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/backlight.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/bitops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/board.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/bootinfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/bootx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/bseip.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/bugs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/byteorder.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/cache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/checksum.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/cpm_8260.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/current.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/dbdma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/delay.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/div64.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/elf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/errno.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/est8260.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/fads.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/fcntl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/feature.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/floppy.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/gemini.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/gemini_serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/gg2.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/hardirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/hdreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/heathrow.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/highmem.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/hw_irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/hydra.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/immap_8260.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/init.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/ioctls.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/ipc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/ipcbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/keylargo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/kgdb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/kmap_types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/linux_logo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/m48t35.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/machdep.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/mbx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/mc146818rtc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/md.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/mediabay.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/mk48t59.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/mman.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/mmu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/mmu_context.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/module.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/mpc8260.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/mpc8xx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/msgbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/namei.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/nvram.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/oak.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/ohare.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/page.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/pci-bridge.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/pci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/pgalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/pgtable.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/pnp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/poll.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/posix_types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/prep_nvram.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/processor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/prom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/ptrace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/raven.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/residual.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/resource.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/rpxclassic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/rpxlite.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/scatterlist.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/segment.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/semaphore-helper.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/semaphore.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/sembuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/setup.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/shmbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/shmparam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/sigcontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/siginfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/signal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/smp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/smplock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/socket.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/sockios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/softirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/spinlock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/stat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/statfs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/string.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/termbits.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/termios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/time.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/tqm860.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/tqm8xxL.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/traps.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/uaccess.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/ucontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/unaligned.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/uninorth.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/unistd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/user.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/vc_ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/vga.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/walnut.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-ppc/xor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/a.out.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/atomic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/bitops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/bugs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/byteorder.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/cache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/chandev.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/checksum.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/current.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/delay.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/div64.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/ebcdic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/elf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/errno.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/fcntl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/gdb-stub.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/hardirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/hdreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/init.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/ioctls.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/ipc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/ipcbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/irqextras390.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/lowcore.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/major.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/mathemu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/misc390.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/mman.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/mmu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/mmu_context.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/module.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/msgbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/namei.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/page.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/pgalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/pgtable.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/poll.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/posix_types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/processor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/ptrace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/queue.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/resource.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/s390-gdbregs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/s390-regs-common.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/s390dyn.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/s390io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/s390mach.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/segment.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/semaphore-helper.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/semaphore.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/sembuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/setup.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/shmbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/shmparam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/sigcontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/siginfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/signal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/sigp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/smp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/smplock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/socket.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/sockios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/softirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/spinlock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/stat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/statfs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/string.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/termbits.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/termios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/uaccess.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/ucontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/unaligned.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/unistd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/user.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-s390/xor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/a.out.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/addrspace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/atomic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/bitops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/bugs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/byteorder.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/cache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/checksum.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/current.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/delay.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/div64.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/elf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/errno.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/fcntl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/hardirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/hd64461.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/hdreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/hitachi_se.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/hw_irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/init.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/io_generic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/io_hd64461.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/io_od.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/io_se.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/io_unknown.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/ioctls.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/ipc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/ipcbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/linux_logo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/machvec.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/machvec_init.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/mman.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/mmu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/mmu_context.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/module.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/msgbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/namei.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/page.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/pci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/pgalloc-2level.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/pgalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/pgtable-2level.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/pgtable.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/poll.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/posix_types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/processor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/ptrace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/resource.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/rtc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/scatterlist.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/semaphore-helper.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/semaphore.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/sembuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/sh_bios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/shmbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/shmparam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/sigcontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/siginfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/signal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/smc37c93x.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/smp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/smplock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/socket.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/sockios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/softirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/spinlock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/stat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/statfs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/string.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/termbits.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/termios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/uaccess.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/ucontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/unaligned.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/unistd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/user.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sh/xor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/a.out.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/asi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/asmmacro.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/atomic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/audioio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/auxio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/bitops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/bpp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/bsderrno.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/btfixup.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/bugs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/byteorder.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/cache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/checksum.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/clock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/contregs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/cprefix.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/current.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/cypress.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/delay.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/div64.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/ebus.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/ecc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/eeprom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/elf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/errno.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/fbio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/fcntl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/floppy.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/hardirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/hdreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/head.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/highmem.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/idprom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/init.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/io-unit.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/ioctls.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/iommu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/ipc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/ipcbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/jsflash.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/kbio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/kdebug.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/kgdb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/kmap_types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/linux_logo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/machines.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/mbus.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/mc146818rtc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/memreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/mman.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/mmu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/mmu_context.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/module.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/mostek.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/mpmbox.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/msgbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/msi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/mxcc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/namei.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/obio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/openprom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/openpromio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/oplib.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/page.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/pbm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/pci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/pcic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/pconf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/perfctr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/pgalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/pgtable.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/pgtsrmmu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/pgtsun4.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/pgtsun4c.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/poll.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/posix_types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/processor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/psr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/ptrace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/reg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/resource.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/ross.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/rtc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/sbi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/sbus.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/scatterlist.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/segment.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/semaphore.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/sembuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/sfp-machine.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/shmbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/shmparam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/sigcontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/siginfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/signal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/smp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/smplock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/smpprim.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/socket.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/sockios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/softirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/solerrno.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/spinlock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/stat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/statfs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/string.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/sun4paddr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/sun4prom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/sunbpp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/svr4.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/swift.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/sysen.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/termbits.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/termios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/timer.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/traps.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/tsunami.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/turbosparc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/uaccess.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/ultra.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/unaligned.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/unistd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/user.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/vac-ops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/vaddrs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/vfc_ioctls.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/viking.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/vuid_event.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/winmacro.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc/xor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/a.out.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/apb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/asi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/atomic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/audioio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/auxio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/bitops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/bpp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/bsderrno.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/bugs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/byteorder.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/cache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/checksum.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/current.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/delay.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/display7seg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/div64.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/dma.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/ebus.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/elf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/envctrl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/errno.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/fbio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/fcntl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/fhc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/floppy.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/fpumacro.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/hardirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/hdreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/head.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/idprom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/init.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/io.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/ioctls.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/iommu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/ipc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/ipcbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/kbio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/kdebug.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/linux_logo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/lsu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/mc146818rtc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/mman.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/mmu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/mmu_context.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/module.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/mostek.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/msgbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/namei.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/ns87303.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/openprom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/openpromio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/oplib.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/page.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/parport.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/pbm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/pci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/pconf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/perfctr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/pgalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/pgtable.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/poll.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/posix_types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/processor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/psrcompat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/pstate.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/ptrace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/reg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/resource.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/rtc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/sab82532.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/sbus.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/scatterlist.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/segment.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/semaphore-helper.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/semaphore.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/sembuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/sfp-machine.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/shmbuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/shmparam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/sigcontext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/siginfo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/signal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/smp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/smplock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/socket.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/sockios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/softirq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/solerrno.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/spinlock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/spitfire.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/starfire.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/stat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/statfs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/string.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/sunbpp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/svr4.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/system.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/termbits.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/termios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/timer.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/ttable.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/uaccess.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/uctx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/unaligned.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/unistd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/upa.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/user.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/utrap.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/vaddrs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/vga.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/visasm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/vuid_event.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/asm-sparc64/xor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/802_11.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/a.out.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ac97_codec.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/acct.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/acpi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/adb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/adb_mouse.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/adfs_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/adfs_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/adfs_fs_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/affs_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/affs_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/affs_fs_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/affs_hardblocks.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/agp_backend.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/agpgart.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/amifd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/amifdreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/amigaffs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/apm_bios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/arcdevice.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/atalk.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/atari_rootsec.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/atm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/atm_eni.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/atm_idt77105.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/atm_nicstar.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/atm_suni.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/atm_tcp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/atm_zatm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/atmapi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/atmarp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/atmclip.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/atmdev.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/atmioc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/atmlec.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/atmmpc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/atmsap.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/atmsvc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/auto_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/auto_fs4.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/awe_voice.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ax25.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/b1lli.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/b1pcmcia.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/baycom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/bfs_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/bfs_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/bfs_fs_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/binfmts.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/bitops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/blk.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/blkdev.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/blkpg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/bootmem.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/bpqether.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/brlock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/byteorder/big_endian.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/byteorder/generic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/byteorder/little_endian.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/byteorder/pdp_endian.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/byteorder/swab.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/byteorder/swabb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/cache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/capability.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/capi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/cciss_ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/cd1400.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/cdk.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/cdrom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/circ_buf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/coda.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/coda_cache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/coda_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/coda_linux.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/coda_proc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/coda_psdev.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/coff.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/com20020.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/compatmac.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/comstats.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/concap.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/config.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/console.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/console_struct.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/consolemap.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ctype.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/cuda.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/cyclades.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/cyclomx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/cycx_cfm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/cycx_drv.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/cycx_x25.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/dasd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/dcache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/delay.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/devfs_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/devfs_fs_kernel.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/devpts_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/dio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/dirent.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/divert.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/dn.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/dnotify.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/dtlk.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/efs_dir.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/efs_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/efs_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/efs_fs_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/efs_vh.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/elevator.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/elf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/elfcore.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/errno.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/errqueue.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/etherdevice.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ethtool.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ext2_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ext2_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ext2_fs_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/fat_cvf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/fb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/fcdevice.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/fcntl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/fd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/fd1772.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/fddidevice.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/fdreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/file.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/filter.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/fs_struct.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ftape-header-segment.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ftape-vendors.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ftape.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/gameport.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/generic_serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/genhd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ghash.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/hayesesp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/hdlcdrv.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/hdreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/hdsmart.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/hfs_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/hfs_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/hfs_fs_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/hfs_sysdep.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/highmem.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/highuid.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/hippidevice.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/hpfs_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/hpfs_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/hpfs_fs_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/hysdn_if.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/i2c-algo-bit.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/i2c-algo-pcf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/i2c-dev.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/i2c-elektor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/i2c-id.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/i2c-old.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/i2c.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/i2o-dev.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/i2o.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ibmtr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/icmp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/icmpv6.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ide.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_arcnet.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_arp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_bonding.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_bridge.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_cablemodem.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_ec.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_eql.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_ether.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_fc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_fddi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_frad.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_hippi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_ltalk.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_packet.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_plip.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_ppp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_pppox.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_pppvar.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_shaper.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_slip.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_strip.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_tr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_tun.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/if_tunnel.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/igmp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/in.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/in6.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/in_route.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/in_systm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/inet.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/inetdevice.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/init.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/input.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/interrupt.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/iobuf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ioport.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ip.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ipc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ipsec.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ipv6.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ipv6_route.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ipx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/irda.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/irq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/irq_cpustat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/isapnp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/isdn.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/isdn_divertif.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/isdn_lzscomp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/isdn_ppp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/isdnif.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/isicom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/iso_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/iso_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/iso_fs_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/istallion.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ixjuser.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/jffs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/joystick.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/kbd_diacr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/kbd_kern.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/kbd_ll.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/kd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/kdev_t.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/kernel.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/kernel_stat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/kernelcapi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/keyboard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/kmod.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/lapb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/limits.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/linkage.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/linux_logo.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/list.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/lockd/bind.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/lockd/debug.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/lockd/lockd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/lockd/nlm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/lockd/share.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/lockd/sm_inter.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/lockd/xdr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/lockd/xdr4.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/locks.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/logibusmouse.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/loop.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/lp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/lvm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/major.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/malloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/matroxfb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mc146818rtc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mc6821.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mca.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/minix_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/minix_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/minix_fs_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/miscdevice.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mman.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mmzone.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/modsetver.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/module.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mount.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mpp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mroute.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/msdos_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/msdos_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/msdos_fs_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/msg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mtd/cfi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mtd/compatmac.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mtd/doc2000.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mtd/flashchip.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mtd/ftl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mtd/iflash.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mtd/jedec.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mtd/map.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mtd/mapped.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mtd/mtd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mtd/nand.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mtd/nand_ids.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mtd/nftl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mtd/partitions.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mtd/pmc551.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/mtio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/n_r3964.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nbd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ncp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ncp_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ncp_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ncp_fs_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ncp_mount.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ncp_no.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/net.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netbeui.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netdevice.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ddp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_decnet.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/compat_firewall.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ip_conntrack.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ip_conntrack_core.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ip_conntrack_ftp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ip_conntrack_helper.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ip_conntrack_protocol.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ip_conntrack_tcp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ip_conntrack_tuple.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ip_nat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ip_nat_core.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ip_nat_ftp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ip_nat_helper.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ip_nat_protocol.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ip_nat_rule.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ip_queue.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ip_tables.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ipchains_core.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ipfwadm_core.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ipt_LOG.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ipt_MARK.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ipt_REJECT.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ipt_TOS.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ipt_limit.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ipt_mac.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ipt_mark.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ipt_multiport.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ipt_owner.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ipt_state.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/ipt_tos.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/listhelp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv4/lockhelp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv6.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv6/ip6_tables.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv6/ip6t_LOG.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv6/ip6t_MARK.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv6/ip6t_REJECT.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv6/ip6t_limit.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv6/ip6t_mac.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv6/ip6t_mark.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv6/ip6t_multiport.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipv6/ip6t_owner.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_ipx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netfilter_x25.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netlink.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/netrom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfs2.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfs3.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfs_flushd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfs_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfs_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfs_fs_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfs_mount.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfs_page.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfs_xdr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfsd/auth.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfsd/cache.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfsd/const.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfsd/debug.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfsd/export.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfsd/interface.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfsd/nfsd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfsd/nfsfh.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfsd/stats.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfsd/syscall.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfsd/xdr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfsd/xdr3.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nfsiod.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nls.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/notifier.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ntfs_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ntfs_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ntfs_fs_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nubus.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/nvram.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/openpic.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/openprom_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/pagemap.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/parport.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/parport_pc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/pc_keyb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/pci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/pci_ids.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/personality.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/pg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/phonedev.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/pipe_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/pkt_cls.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/pkt_sched.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/pm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/pmu.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/poll.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/posix_types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ppdev.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ppp-comp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ppp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ppp_channel.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ppp_defs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/prctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/proc_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/proc_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ps2esdi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ptrace.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/qic117.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/qnx4_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/qnx4_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/qnx4_fs_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/qnxtypes.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/quota.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/quotaops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/raid/linear.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/raid/md.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/raid/md_compatible.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/raid/md_k.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/raid/md_p.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/raid/md_u.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/raid/raid0.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/raid/raid1.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/raid/raid5.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/raid/xor.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/random.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/raw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/reboot.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/resource.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/rocket.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/romfs_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/romfs_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/romfs_fs_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/rose.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/route.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/rpcsock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/rtc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/rtnetlink.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sc26198.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/scc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sched.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sdla.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sdla_chdlc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sdla_fr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sdla_ppp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sdla_x25.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sdladrv.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sdlapci.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sdlasfm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/securebits.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/selection.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sem.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/serial.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/serial167.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/serialP.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/serial_reg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/serio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/shm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/shmem_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/signal.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sisfb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/skbuff.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/slab.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/smb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/smb_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/smb_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/smb_fs_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/smb_mount.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/smbno.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/smp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/smp_lock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/socket.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sockios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sonet.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sound.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/soundcard.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/soundmodem.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/spinlock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/stallion.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/stat.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/stddef.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/string.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sunrpc/auth.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sunrpc/clnt.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sunrpc/debug.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sunrpc/msg_prot.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sunrpc/sched.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sunrpc/stats.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sunrpc/svc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sunrpc/svcauth.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sunrpc/svcsock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sunrpc/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sunrpc/xdr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sunrpc/xprt.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/swap.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/swapctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/synclink.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sys.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sysctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sysrq.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sysv_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sysv_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/sysv_fs_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/tcp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/telephony.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/termios.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/threads.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/time.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/timer.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/times.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/timex.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/toshiba.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/tpqic02.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/tqueue.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/trdevice.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/tty.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/tty_driver.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/tty_flip.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/tty_ldisc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/udf_167.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/udf_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/udf_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/udf_fs_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/udf_udf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/udp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ufs_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ufs_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ufs_fs_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/uio.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/ultrasound.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/umsdos_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/umsdos_fs.p#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/umsdos_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/un.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/unistd.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/usb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/usbdev_fs_i.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/usbdev_fs_sb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/usbdevice_fs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/user.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/utime.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/uts.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/utsname.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/vfs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/video_decoder.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/video_encoder.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/videodev.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/videotext.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/vmalloc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/vt.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/vt_buffer.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/vt_kern.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/wait.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/wanpipe.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/wanrouter.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/watchdog.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/wavefront.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/wireless.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/wrapper.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/x25.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/yam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/zftape.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/zorro.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/linux/zorro_ids.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/math-emu/double.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/math-emu/extended.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/math-emu/op-1.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/math-emu/op-2.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/math-emu/op-4.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/math-emu/op-8.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/math-emu/op-common.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/math-emu/quad.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/math-emu/single.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/math-emu/soft-fp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/addrconf.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/af_unix.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/arp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/atmclip.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/ax25.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/checksum.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/datalink.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/dn.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/dn_dev.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/dn_fib.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/dn_neigh.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/dn_nsp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/dn_route.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/dsfield.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/dst.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/flow.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/icmp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/if_inet6.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/inet_common.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/inet_ecn.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/inetpeer.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/ip.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/ip6_fib.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/ip6_fw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/ip6_route.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/ip_fib.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/ipconfig.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/ipip.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/ipv6.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/ipx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/crc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/discovery.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/ircomm_core.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/ircomm_event.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/ircomm_lmp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/ircomm_param.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/ircomm_ttp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/ircomm_tty.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/ircomm_tty_attach.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irda.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irda_device.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irdacall.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/iriap.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/iriap_event.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irias_object.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irlan_client.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irlan_common.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irlan_eth.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irlan_event.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irlan_filter.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irlan_provider.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irlap.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irlap_comp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irlap_event.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irlap_frame.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irlmp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irlmp_event.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irlmp_frame.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irmod.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irport.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irqueue.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irttp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/irtty.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/nsc-ircc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/parameters.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/qos.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/smc-ircc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/timer.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/toshoboe.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/w83977af.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/w83977af_ir.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/irda/wrapper.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/lapb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/llc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/llc_frame.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/llc_name.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/llc_state.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/ndisc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/neighbour.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/netrom.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/p8022.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/pkt_cls.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/pkt_sched.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/profile.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/protocol.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/psnap.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/raw.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/rawv6.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/rose.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/route.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/scm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/slhc_vj.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/snmp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/sock.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/spx.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/tcp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/tcp_ecn.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/transp_v6.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/udp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/net/x25.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/pcmcia/bulkmem.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/pcmcia/bus_ops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/pcmcia/ciscode.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/pcmcia/cisreg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/pcmcia/cistpl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/pcmcia/cs.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/pcmcia/cs_types.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/pcmcia/driver_ops.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/pcmcia/ds.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/pcmcia/ftl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/pcmcia/mem_op.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/pcmcia/memory.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/pcmcia/ss.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/pcmcia/version.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/scsi/scsi.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/scsi/scsi_ioctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/scsi/scsicam.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/scsi/sg.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/fbcon-afb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/fbcon-cfb16.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/fbcon-cfb2.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/fbcon-cfb24.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/fbcon-cfb32.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/fbcon-cfb4.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/fbcon-cfb8.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/fbcon-hga.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/fbcon-ilbm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/fbcon-iplan2p2.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/fbcon-iplan2p4.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/fbcon-iplan2p8.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/fbcon-mac.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/fbcon-mfb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/fbcon-vga-planes.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/fbcon-vga.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/fbcon.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/font.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/macmodes.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/newport.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/s3blit.h#1 branch
-... //depot/linux-aic79xx-2.4.0/include/video/sbusfb.h#1 branch
-... //depot/linux-aic79xx-2.4.0/init/main.c#1 branch
-... //depot/linux-aic79xx-2.4.0/init/version.c#1 branch
-... //depot/linux-aic79xx-2.4.0/ipc/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/ipc/msg.c#1 branch
-... //depot/linux-aic79xx-2.4.0/ipc/sem.c#1 branch
-... //depot/linux-aic79xx-2.4.0/ipc/shm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/ipc/util.c#1 branch
-... //depot/linux-aic79xx-2.4.0/ipc/util.h#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/acct.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/capability.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/context.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/dma.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/exec_domain.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/exit.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/fork.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/info.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/itimer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/kmod.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/ksyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/module.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/panic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/pm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/printk.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/ptrace.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/resource.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/sched.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/signal.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/softirq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/sys.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/sysctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/timer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/uid16.c#1 branch
-... //depot/linux-aic79xx-2.4.0/kernel/user.c#1 branch
-... //depot/linux-aic79xx-2.4.0/lib/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/lib/brlock.c#1 branch
-... //depot/linux-aic79xx-2.4.0/lib/cmdline.c#1 branch
-... //depot/linux-aic79xx-2.4.0/lib/ctype.c#1 branch
-... //depot/linux-aic79xx-2.4.0/lib/dec_and_lock.c#1 branch
-... //depot/linux-aic79xx-2.4.0/lib/errno.c#1 branch
-... //depot/linux-aic79xx-2.4.0/lib/inflate.c#1 branch
-... //depot/linux-aic79xx-2.4.0/lib/string.c#1 branch
-... //depot/linux-aic79xx-2.4.0/lib/vsprintf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/bootmem.c#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/filemap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/highmem.c#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/memory.c#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/mlock.c#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/mmap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/mmap_avl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/mprotect.c#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/mremap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/numa.c#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/oom_kill.c#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/page_alloc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/page_io.c#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/shmem.c#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/slab.c#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/swap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/swap_state.c#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/swapfile.c#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/vmalloc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/mm/vmscan.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/TODO#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/cl2llc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/cl2llc.pre#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/fc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/fddi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/hippi.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/llc_macinit.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/llc_sendpdu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/llc_utility.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/p8022.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/p8023.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/pseudo/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/pseudo/actionnm.awk#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/pseudo/actionnm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/pseudo/compile.awk#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/pseudo/opcd2num.sed#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/pseudo/opcodes#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/pseudo/opcodesnm.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/pseudo/pseudocode#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/pseudo/pseudocode.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/psnap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/sysctl_net_802.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/tr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/transit/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/transit/compile.awk#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/transit/pdutr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/transit/pdutr.pre#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/transit/timertr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/802/transit/timertr.pre#1 branch
-... //depot/linux-aic79xx-2.4.0/net/Changes#1 branch
-... //depot/linux-aic79xx-2.4.0/net/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/net/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/README#1 branch
-... //depot/linux-aic79xx-2.4.0/net/TUNABLE#1 branch
-... //depot/linux-aic79xx-2.4.0/net/appletalk/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/appletalk/aarp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/appletalk/ddp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/appletalk/sysctl_net_atalk.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/addr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/addr.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/atm_misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/clip.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/common.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/common.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/ipcommon.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/ipcommon.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/lec.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/lec.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/lec_arpc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/mpc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/mpc.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/mpoa_caches.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/mpoa_caches.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/mpoa_proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/protocols.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/pvc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/raw.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/resources.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/resources.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/signaling.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/signaling.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/atm/svc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ax25/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ax25/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ax25/af_ax25.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ax25/ax25_addr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ax25/ax25_dev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ax25/ax25_ds_in.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ax25/ax25_ds_subr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ax25/ax25_ds_timer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ax25/ax25_iface.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ax25/ax25_in.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ax25/ax25_ip.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ax25/ax25_out.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ax25/ax25_route.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ax25/ax25_std_in.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ax25/ax25_std_subr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ax25/ax25_std_timer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ax25/ax25_subr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ax25/ax25_timer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ax25/ax25_uid.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ax25/sysctl_net_ax25.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/bridge/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/bridge/br.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/bridge/br_device.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/bridge/br_fdb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/bridge/br_forward.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/bridge/br_if.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/bridge/br_input.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/bridge/br_ioctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/bridge/br_notify.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/bridge/br_private.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/bridge/br_private_stp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/bridge/br_private_timer.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/bridge/br_stp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/bridge/br_stp_bpdu.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/bridge/br_stp_if.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/bridge/br_stp_timer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/core/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/core/datagram.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/core/dev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/core/dev_mcast.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/core/dst.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/core/dv.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/core/filter.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/core/iovec.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/core/neighbour.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/core/netfilter.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/core/profile.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/core/rtnetlink.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/core/scm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/core/skbuff.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/core/sock.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/core/sysctl_net_core.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/core/utils.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/decnet/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/net/decnet/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/decnet/README#1 branch
-... //depot/linux-aic79xx-2.4.0/net/decnet/TODO#1 branch
-... //depot/linux-aic79xx-2.4.0/net/decnet/af_decnet.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/decnet/dn_dev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/decnet/dn_fib.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/decnet/dn_neigh.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/decnet/dn_nsp_in.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/decnet/dn_nsp_out.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/decnet/dn_route.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/decnet/dn_rules.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/decnet/dn_table.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/decnet/dn_timer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/decnet/sysctl_net_decnet.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/econet/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/econet/af_econet.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/econet/sysctl_net_ec.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ethernet/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ethernet/eth.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ethernet/pe2.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ethernet/sysctl_net_ether.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/af_inet.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/arp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/devinet.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/fib_frontend.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/fib_hash.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/fib_rules.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/fib_semantics.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/icmp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/igmp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/inetpeer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/ip_forward.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/ip_fragment.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/ip_gre.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/ip_input.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/ip_nat_dumb.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/ip_options.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/ip_output.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/ip_sockglue.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/ipconfig.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/ipip.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/ipmr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ip_conntrack_core.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ip_conntrack_ftp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ip_conntrack_proto_generic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ip_conntrack_proto_icmp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ip_conntrack_proto_tcp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ip_conntrack_proto_udp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ip_conntrack_standalone.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ip_fw_compat.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ip_fw_compat_masq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ip_fw_compat_redir.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ip_nat_core.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ip_nat_ftp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ip_nat_proto_icmp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ip_nat_proto_tcp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ip_nat_proto_udp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ip_nat_proto_unknown.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ip_nat_rule.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ip_nat_standalone.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ip_queue.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ip_tables.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ipchains_core.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ipfwadm_core.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ipt_LOG.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ipt_MARK.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ipt_MASQUERADE.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ipt_MIRROR.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ipt_REDIRECT.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ipt_REJECT.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ipt_TOS.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ipt_limit.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ipt_mac.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ipt_mark.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ipt_multiport.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ipt_owner.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ipt_state.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ipt_tos.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/ipt_unclean.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/iptable_filter.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/netfilter/iptable_mangle.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/protocol.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/raw.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/route.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/syncookies.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/sysctl_net_ipv4.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/tcp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/tcp_input.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/tcp_ipv4.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/tcp_minisocks.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/tcp_output.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/tcp_timer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/udp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv4/utils.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/README#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/addrconf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/af_inet6.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/datagram.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/exthdrs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/icmp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/ip6_fib.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/ip6_flowlabel.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/ip6_fw.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/ip6_input.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/ip6_output.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/ipv6_sockglue.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/mcast.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/ndisc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/netfilter/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/netfilter/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/netfilter/ip6_tables.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/netfilter/ip6t_MARK.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/netfilter/ip6t_limit.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/netfilter/ip6t_mac.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/netfilter/ip6t_mark.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/netfilter/ip6t_multiport.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/netfilter/ip6table_filter.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/proc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/protocol.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/raw.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/reassembly.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/route.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/sit.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/sysctl_net_ipv6.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/tcp_ipv6.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipv6/udp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipx/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipx/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipx/af_ipx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipx/af_spx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/ipx/sysctl_net_ipx.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/af_irda.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/compressors/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/compressors/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/compressors/irda_deflate.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/crc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/discovery.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/ircomm/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/ircomm/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/ircomm/ircomm_core.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/ircomm/ircomm_event.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/ircomm/ircomm_lmp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/ircomm/ircomm_param.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/ircomm/ircomm_ttp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/ircomm/ircomm_tty.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/ircomm/ircomm_tty_attach.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/ircomm/ircomm_tty_ioctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irda_device.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/iriap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/iriap_event.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irias_object.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irlan/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irlan/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irlan/irlan_client.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irlan/irlan_client_event.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irlan/irlan_common.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irlan/irlan_eth.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irlan/irlan_event.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irlan/irlan_filter.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irlan/irlan_provider.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irlan/irlan_provider_event.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irlap.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irlap_comp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irlap_event.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irlap_frame.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irlmp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irlmp_event.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irlmp_frame.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irnet/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irnet/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irnet/irnet.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irnet/irnet_irda.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irnet/irnet_irda.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irnet/irnet_ppp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irnet/irnet_ppp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irproc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irqueue.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irsyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irsysctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/irttp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/parameters.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/qos.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/timer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/irda/wrapper.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/khttpd/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/net/khttpd/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/khttpd/README#1 branch
-... //depot/linux-aic79xx-2.4.0/net/khttpd/accept.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/khttpd/datasending.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/khttpd/logging.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/khttpd/main.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/khttpd/make_times_h.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/khttpd/misc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/khttpd/prototypes.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/khttpd/rfc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/khttpd/rfc_time.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/khttpd/security.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/khttpd/security.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/khttpd/sockets.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/khttpd/structure.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/khttpd/sysctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/khttpd/sysctl.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/khttpd/userspace.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/khttpd/waitheaders.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/lapb/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/lapb/lapb_iface.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/lapb/lapb_in.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/lapb/lapb_out.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/lapb/lapb_subr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/lapb/lapb_timer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/netlink/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/netlink/af_netlink.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/netlink/netlink_dev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/netrom/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/netrom/af_netrom.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/netrom/nr_dev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/netrom/nr_in.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/netrom/nr_loopback.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/netrom/nr_out.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/netrom/nr_route.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/netrom/nr_subr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/netrom/nr_timer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/netrom/sysctl_net_netrom.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/netsyms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/packet/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/packet/af_packet.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/rose/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/rose/af_rose.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/rose/rose_dev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/rose/rose_in.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/rose/rose_link.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/rose/rose_loopback.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/rose/rose_out.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/rose/rose_route.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/rose/rose_subr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/rose/rose_timer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/rose/sysctl_net_rose.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/Config.in#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/cls_api.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/cls_fw.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/cls_route.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/cls_rsvp.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/cls_rsvp.h#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/cls_rsvp6.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/cls_tcindex.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/cls_u32.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/estimator.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/police.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/sch_api.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/sch_atm.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/sch_cbq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/sch_csz.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/sch_dsmark.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/sch_fifo.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/sch_generic.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/sch_gred.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/sch_ingress.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/sch_prio.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/sch_red.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/sch_sfq.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/sch_tbf.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sched/sch_teql.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/socket.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sunrpc/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sunrpc/auth.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sunrpc/auth_null.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sunrpc/auth_unix.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sunrpc/clnt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sunrpc/pmap_clnt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sunrpc/sched.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sunrpc/stats.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sunrpc/sunrpc_syms.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sunrpc/svc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sunrpc/svcauth.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sunrpc/svcauth_des.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sunrpc/svcsock.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sunrpc/sysctl.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sunrpc/xdr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sunrpc/xprt.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/sysctl_net.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/unix/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/unix/af_unix.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/unix/garbage.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/unix/sysctl_net_unix.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/wanrouter/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/wanrouter/patchlevel#1 branch
-... //depot/linux-aic79xx-2.4.0/net/wanrouter/wanmain.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/wanrouter/wanproc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/x25/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/net/x25/af_x25.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/x25/sysctl_net_x25.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/x25/x25_dev.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/x25/x25_facilities.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/x25/x25_in.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/x25/x25_link.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/x25/x25_out.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/x25/x25_route.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/x25/x25_subr.c#1 branch
-... //depot/linux-aic79xx-2.4.0/net/x25/x25_timer.c#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/Configure#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/MAKEDEV.ide#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/Menuconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/README.Menuconfig#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/checkconfig.pl#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/checkhelp.pl#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/checkincludes.pl#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/cramfs/GNUmakefile#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/cramfs/mkcramfs.c#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/docgen#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/docproc.c#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/gen-all-syms#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/header.tk#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/kernel-doc#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/ksymoops/README#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/lxdialog/BIG.FAT.WARNING#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/lxdialog/Makefile#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/lxdialog/checklist.c#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/lxdialog/colors.h#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/lxdialog/dialog.h#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/lxdialog/inputbox.c#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/lxdialog/lxdialog.c#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/lxdialog/menubox.c#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/lxdialog/msgbox.c#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/lxdialog/textbox.c#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/lxdialog/util.c#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/lxdialog/yesno.c#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/makelst#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/mkdep.c#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/patch-kernel#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/pathdown.sh#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/split-include.c#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/tail.tk#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/tkcond.c#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/tkgen.c#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/tkparse.c#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/tkparse.h#1 branch
-... //depot/linux-aic79xx-2.4.0/scripts/ver_linux#1 branch
-
-Change 563 by gibbs@aslan on 2002/01/22 11:00:23
-
-	aic79xx.c:
-		Add initial AHD_PKT_BITBUCKET_BUG and overrun handling.
-		In the cases where the hardware will allow such a
-		situation, we will transfer data into on overrun
-		buffer in host memory to simulate a bitbucket.
-	
-	aic79xx.h:
-		AHD_PKT_BITBUCKET_BUG definition.
-	
-	aic79xx.reg:
-		Add per-mode location for saving the accumulator during
-		interrupt handlers.
-	
-		Add bits describing an overrun condition.
-	
-		Add a downloadable constant for defining the 
-		overrun buffer location.
-	
-	aic79xx.seq:
-		Turn freeze_queue into a subroutine and have it
-		save and restore the accumulator around using it.
-	
-		Add preliminary support for handling overruns.
-	
-	aicasm/aicasm.c:
-		Formatting nits.
-	
-	aicasm/aicasm_gram.y:
-	aicasm/aicasm_symbol.h:
-		Allow constants to be larger than 8bits.  The sequencer
-		will still complain if an expression doesn't manipulate
-		the constant into a form that fits in 8bits during an
-		assignment.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#22 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#15 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#18 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#19 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#13 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#13 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#9 edit
-
-Change 554 by gibbs@overdrive on 2002/01/22 00:14:54
-
-	scsi_iu.h:
-		Add a header file describing datastructures of
-		SCSI Information Units.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/scsi_iu.h#1 add
-
-Change 552 by gibbs@overdrive on 2002/01/21 23:50:24
-
-	aic7xxx_osm.c:
-		block_size() is only available in very recent
-		kernels.  Use 1024 for anything earlier than 2.4.17.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#84 edit
-
-Change 529 by gibbs@overdrive on 2002/01/21 14:19:18
-
-	aic7xxx_host.h:
-		Correct idempotency ifdefs.
-	
-	aic7xxx_osm.c:
-		Use "block_size" rather than a hard coded 1024 to
-		access the underlying device in search of an fdisk table.
-	
-	aic7xxx_osm.c:
-		Protect code unreferenced if MMAPIO is flase.
-	
-		Use pci_set_drvdata(), rather than touching the
-		PCI device structure manually.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_host.h#6 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#83 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#30 edit
-
-Change 504 by gibbs@aslan on 2002/01/15 13:23:22
-
-	aic79xx.c:
-		Set SAVED_SCSIID and SAVED_LUN to invalid values
-		everytime we restart the sequencer.
-	
-		Panic() after dumping card state should we complete
-		an SCB twice.  This will be removed prior to release.
-	
-		Add panics after most calls to ahd_dump_card_state().
-		This guarantees that we can capture any diagnostic
-		output.
-	
-		Implement status packet fetching.  In the future we
-		may embed the sense data location into the SCB so
-		a sequencer interrupt is not necessary, but for now
-		we let the kernel fill in the sense address.
-	
-		Add sequencer interrupt codes for failures of diagnostics
-		performed by the sequencer.
-	
-		Properly set the bug variable to include all bugs we
-		have workarounds for.
-	
-		Add support for using the abort feature (once it works)
-		to catch references by a target to tag identifiers that
-		are not allocated.
-	
-		Protect the routines parsing the execution list from
-		infinite transaction loops.
-	
-		Enahance ahd_dump_card_state to include more information.
-	
-	aic79xx.h:
-		Move derivative register access routines to aic79xx_inline.h.
-		Using inline functions allows type promotion which aids in
-		gracefully handling quads.
-	
-	aic79xx.reg:
-		Add additional sequencer interrupt codes.
-	
-		Fix a typo in the definition of LQIABORT.
-	
-		Define the sequencer stack size.
-	
-	aic79xx.seq:
-		Revert to non-inlined version of load_first_seg.  The
-		bug that this "worked around" has been addressed.
-	
-		Use calls to setjmp in our interrupt handler rather than
-		manually setting the longjmp address.
-	
-	aic79xx_inline.h:
-		Add routines for syncing sense buffers.
-	
-		Add inline versions of the derivative register
-		access methods (inw, inq, etc.).
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#21 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#14 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#17 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#18 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#16 edit
-
-Change 503 by gibbs@aslan on 2002/01/13 20:57:51
-
-	Packetized checkpoint.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#17 edit
-
-Change 495 by gibbs@aslan on 2002/01/09 09:29:03
-
-	aic7xxx.c:
-		Set both SAVED_LUN and SAVED_SCSIID to impossible values
-		in ahc_restart().  We can't trust these fields until the
-		sequencer trusts them again and since we didn't initialize
-		them explicitly during startup, a rogue interrupt could
-		have caused us to access them, generating a parity error.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#54 edit
-
-Change 493 by gibbs@aslan on 2002/01/08 12:39:10
-
-	Setup task attributes (tag type) for packetized transactions.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#15 edit
-
-Change 492 by gibbs@aslan on 2002/01/08 11:20:40
-
-	aic79xx.c:
-		Add additional trace sequencer interrupt codes.
-	
-		Make a fist pass at handling unexpected bus frees.  We
-		now expect a busfree at the end of any PPR negotiation
-		that results in a change in the IU_REQ agreement.
-	
-		Don't set PACED transfers for async speeds.  This bug
-		didn't seem to upset the chip, but who knows.
-	
-		Fix a bug in initialization of the per-device annex
-		data.  Start at the PRECOMP column and allow
-		auto-increment to do the rest.
-	
-		Enable IU/QAS/RD_STRM/WR_FLOW negotiation.
-	
-		Enable searching through the pending list for SCBs to
-		abort in ahd_abort_scbs().
-	
-		Print out FIFO status in ahd_dump_card_state().
-	
-	aic79xx.reg:
-		Add more debugging SEQINTCODEs.
-	
-		Add definitions for the BUSFREETIME status bits.
-	
-		Correct definition of the PRECOMP annex column.
-	
-		Add FETCH_INPROG to SG_STATE for workaround of
-		SG_CACHE_AVAIL coming true soon than expected.
-	
-		Change DRAINING_SCB to LONGJMP_SCB as the SCBID
-		is now set for many different longjmp routines.
-	
-	aic79xx.seq:
-		Add code to drain the good status fifo.
-	
-		Service longjmp routines in order to clear FIFOs
-		for a non-packetized transaction.
-	
-		Complete the workaround for Razor #494.
-	
-		SG_CACHE_AVAIL will come true in the other FIFO as
-		soon as the FIFO using the SG_CACHE has provided
-		enough segments to satify it's transfer or has seen
-		saveptrs status.  Use FETCH_INPROG state to guard against
-		this early switch confusing the other FIFO into believing
-		it has valid SG data.
-	
-		Clear SG_FULL_RESID from both the SCB_SGPTR and the
-		RESIDUAL_SGPTR by clearing the flag in SCB_SGPTR prior
-		to the copy to the residual field.
-	
-		Update the calc_resid subroutine to include the setting
-		of the residual datacnt.
-	
-		Remove the monitor_drain handler.  We rely on the data
-		FIFO's high priority to handle this case.
-	
-		Only defer completions if a longjmp routine for the
-		SCB of interrest is still active.  This simplifies
-		the check_fifo routine.
-	
-		Inline the good_status_IU handler to lose a stack level.
-	
-	aic79xx_inline.h:
-		Clear the task_management field if we are packetized.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#20 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#13 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#16 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#16 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#14 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#53 edit
-
-Change 485 by gibbs@overdrive on 2001/12/17 23:07:26
-
-	aic79xx_osm.c:
-		Correct typos and style nits.
-	
-		Properly track the transfer length in
-		scb->platform_data->xfer_len.  We failed to
-		update this variable during the conversion to
-		use the Core ahd_sg_setup() routine.
-	
-		Increment cur_seg instead of using the first
-		segment for every segment in the transfer.
-	
-		Remove target_offset.  Since single function
-		twin chips don't exist in the 79XX class, target_offset
-		and target are synonymous.
-	
-		If we don't have a "linux target" structure for for
-		a device pertaining to an async event, don't service
-		the event.
-	
-	aic79xx_osm_pci.c:
-		Linux counts every 4 bytes of config space as a bar
-		regardless of whether the BAR is 64bit or not.  Update
-		use of pci_resource_start() to reflect this strange
-		method of indexing.
-	
-		Correct check of retrieved ioport bases.  base and
-		base2 are pointers.
-	
-		Correct think-o in mapping regsiters.  We only want to
-		attempt IO space if maddr is NULL indicating that
-		memory mapped space is not available.
-	
-	aic7xxx_osm.c:
-		Style nit.
-	
-		If we don't have a "linux target" structure for for
-		a device pertaining to an async event, don't service
-		the event.
-	
-	aic7xxx_osm_pci.c:
-		Correct check of retrieved ioport base.
-		base is a pointer.
-	
-		Correct think-o in mapping regsiters.  We only want to
-		attempt IO space if maddr is NULL indicating that
-		memory mapped space is not available.
-	
-	aicasm/Makefile:
-		yacc in some distributions does not support the -o
-		output option.  Modify the Makefile to avoid using
-		this feature.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#5 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#3 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#82 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#29 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/Makefile#10 edit
-
-Change 484 by gibbs@overdrive on 2001/12/17 21:32:02
-
-	Disable information unit transfers for now.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#19 edit
-
-Change 483 by gibbs@overdrive on 2001/12/17 15:23:19
-
-	aic79xx_osm.c:
-		Remove vestigial call to aic7770_linux_probe().  This driver
-		does not support that chip.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#4 edit
-
-Change 482 by gibbs@overdrive on 2001/12/17 13:43:35
-
-	Include SPI4 PPR options.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/scsi_message.h#4 edit
-
-Change 481 by gibbs@overdrive on 2001/12/17 13:43:25
-
-	Set SCB_PACKETIZED on all packetized SCBs.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#3 edit
-
-Change 480 by gibbs@overdrive on 2001/12/17 13:43:06
-
-	Prepare for release 0.0.0 of the aic79xx driver.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#4 edit
-
-Change 479 by gibbs@aslan on 2001/12/17 13:27:15
-
-	aic79xx.c:
-	aic79xx.seq:
-		Initialize SG_STATE to 0 for sanity on card initialization
-		and anytime a new transfer is started where additional
-		segments are not needed.
-	
-	aic79xx.reg:
-		SG_SENSE is no longer needed.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#18 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#15 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#15 edit
-
-Change 478 by gibbs@overdrive on 2001/12/17 11:44:16
-
-	aic7xxx.h:
-		Remove alternate bus space tag handles.  We don't bother
-		holding the unused regions any more.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#37 edit
-
-Change 477 by gibbs@aslan on 2001/12/17 11:43:03
-
-	aic79xx.c:
-		Break out the computation of "post patch" sequencer
-		addresses so we can use it to compute the location
-		of the sequencer's interrupt handler.
-	
-		Start the process of marking Rev A bugs with the
-		AHD_SENT_SCB_UPDATE_BUG.
-	
-		Expand PPR option rules to include all supported
-		options.
-	
-		Correct the setting of precompensation values to
-		reflect fixes in the A2.
-	
-		Begin the process of handling PPR negotiations that
-		end in a bus free due to a change in IU_REQ.
-	
-		Enhance DFF mode specific initialization to include
-		the LongJmp address and the interrupts we want enabled.
-	
-		We must be in the SCSI mode to initialize the
-		negotiation table.
-	
-		Enable write flow control, read streaming and
-		information units if the SEEPROM tells us to enable
-		packetized.
-	
-	aic79xx.h:
-		Add AHD_SENT_SCB_UPDATE_BUG definition.
-	
-		Add SCB flags indicating packetized transaction and
-		a PPR that should result in a busfree.
-	
-	aic79xx.reg:
-		Add additional sequencer interrupt codes for packetized
-		failure modes.
-	
-		Allow the STACK and LASTSCB to be written two.  The
-		STACK needs to be written for longjump operations.
-		LASTSCB needs to be written for the AHD_SENT_SCB_UPDATE_BUG.
-	
-		Add PRECOMP constants.
-	
-		Move DATA_COUNT_ODD to per-mode scratch.
-	
-		Add STATUS_RCVD field to SCB_CONTROL.
-	
-		A status code of STATUS_PKT_SENSE indicates sense
-		data was recieved for this packetized transaction.
-	
-		Set the high bit of LONGJMP_ADDR to indicate that
-		it is no longer valid.
-	
-	aic79xx.seq:
-		Add setjmp/longjmp support.
-	
-		Implement AHD_SENT_SCB_UPDATE_BUG workaround.
-	
-		Break out first segment load, SCB completion,
-		residual calculation and save pointers so they
-		can be used for packetized operations.
-	
-		Make a first cut at sequencer interrupt services
-		for packetized operations.
-	
-	aic79xx_inline.h:
-	aic79xx_osm.c:
-		Use an SCB flag to indicate that a transaction is
-		packetized freeing up a bit in SCB_CONTROL for
-		STATUS_RCVD.
-	
-	aic79xx_pci.c:
-		Add compaq IDs.
-	
-	aicasm/aicasm_gram.y:
-	aicasm/aicasm_scan.l:
-	aicasm/aicasm_symbol.c:
-	aicasm/aicasm_symbol.h:
-		Add the ability to export a sequencer label to
-		the host driver.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#17 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#12 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#14 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#14 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#13 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#8 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#12 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#9 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#12 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#8 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#3 edit
-
-Change 475 by gibbs@overdrive on 2001/12/13 14:45:21
-
-	aic79xx_osm.h:
-		Put definition of KERNEL_VERSION into a more
-		appropriate place.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#3 edit
-
-Change 474 by gibbs@overdrive on 2001/12/13 14:43:24
-
-	Makefile:
-		Delete common makefile.  Each version of Linux is
-		so different that having one Makefile isn't practical.
-		Our build process has not referenced this version for
-		some time.
-	
-	aic7770_osm.c:
-		Pass port information into aic7770_config rather than
-		using a back door through the bus tag and handle to
-		get it.  This allows us to properly clean up mappings
-		should our attach fail.
-	
-		Port is now passed into aic7770_map_registers.
-	
-		Don't set platform data irq field until allocation is
-		successful.  This avoids freeing attempting to free
-		an IRQ we don't own during teardown of a failed attach.
-	
-	aic79xx_osm.c:
-		Clean up unmapping of SCB data.  In the single buffer case,
-		we now store the bus address for the buffer in the SCB
-		platform data so we don't need to recreate it from the
-		S/G list.  The S/G list may be changed by and auto request
-		sense operation, so it cannot be trusted.
-	
-		Formatting nits.
-	
-		Allow DT transfers to devices that only claim SCSI_2 if they
-		have the DT_REQ bit set in thier inquiry data.  This fixes
-		slow transfers on certain IBM drivers.
-	
-	aic79xx_osm.h:
-		Add powerof2 #define.
-	
-		Add buf_busaddr into the SCB platform data.
-	
-	aic79xx_osm_pci.c:
-		Correct comments to reflect reality.
-	
-	aic7xxx_osm.c:
-		Only define modversion info in this file.  This should fix
-		builds on 2.2.X kernels.
-	
-		Clean up unmapping of SCB data.  In the single buffer case,
-		we now store the bus address for the buffer in the SCB
-		platform data so we don't need to recreate it from the
-		S/G list.  The S/G list may be changed by and auto request
-		sense operation, so it cannot be trusted.
-	
-		Initialize platform IRQ field to unallocated value so we
-		don't inadvertantly free an IRQ we don't own in ahc_free().
-	
-		Use AHC_NUM_LUNS rather than hard coded value.
-	
-		Properly initialize sg_count prior to mapping any segments.
-	
-		Allow DT transfers to devices that only claim SCSI_2 if they
-		have the DT_REQ bit set in thier inquiry data.  This fixes
-		slow transfers on certain IBM drivers.
-	
-	aic7xxx_osm.h:
-		Add tasklet include and adjust for movement of files.	
-	
-		Add buf_busaddr to scb_platform_data.
-	
-		Add define for AHC_LINUX_NOIRQ.
-	
-		Adjust for new prototype for aic7770_map_registers.
-	
-	aic7xxx_osm_pci.c:
-		Properly release memory regions if we fail to ioremap them.
-		In general clean up how we allocate memory regions.
-	
-		Don't set platform data irq field until allocation is
-		successful.  This avoids freeing attempting to free
-		an IRQ we don't own during teardown of a failed attach.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/Makefile#9 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7770_osm.c#10 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#2 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#2 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#2 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#81 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#74 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#28 edit
-
-Change 473 by gibbs@aslan on 2001/12/07 17:48:46
-
-	aic79xx.c:
-		Initialize new SG_STATE, per DFF, scratch ram variable.
-	
-		Display SG_STATE information when dumping card state
-		while in a DFF mode.
-	
-	aic79xx.reg:
-		Add SG_STATE and SAVED_MODE scratch ram variables.
-	
-	aic79xx.seq:
-		Move the return label to a location where there is
-		already a solicatry return instruction.
-	
-		Add code to service FIFOS for packetized transactions
-		to the main idle loop.
-	
-		We can't rely on ARRDONE after ARREN is disabled.  The
-		chip clears that bit at the same time ARREN is cleared.
-		Remove a comment about an optimization we could perform
-		if ARRDONE stayed set.
-	
-		Add a comment explaining why we must disable interrupts
-		when setting the mode pointer register.
-	
-		Have allocate FIFO service FIFOs so it can free them
-		up.  We still require both FIFOs to be free for a
-		non-packetized request.
-	
-		Optimize the delivery of an unpacketized cdb.  If we
-		are using SCB internal storage, we can bypass the
-		SG FIFO and set SHCNT directly.  This shaves ~12 clocks
-		of the start of the cdb transfer.
-	
-		Start using CLRCHN instead of RSTCHN.  There is still
-		more optimization that can occur in the non-packetized
-		path in terms of deferring DFIFO teardown.
-	
-		Modify data_group_idle_loop to service the other FIFO
-		as well as perform SCB prefetch/completion type
-		activities.
-	
-		Use SG_STATE to track S/G prefetch and FIFO servicing
-		requirements.
-	
-		Clear SG_STATE when the last segment is loaded or we
-		have completed this data group transfer (last segment
-		done or phasechange).
-	
-		If we go into an overrun condition, release the FIFO
-		by performing a reset channel if a FIFO is still
-		allocated.
-	
-		Change ultra2 -> data_group in all labels.
-	
-		Rely exclusively on SCSIEN going away to signal end
-		of a data transfer.  SCSIEN transitions on last segment
-		done, so testing for it in the loop too is superfluous.
-	
-	aic79xx_inline.h:
-		Add a better comment for why we read from the MODE_PTR
-		register after every SCB ram read.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#16 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#13 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#13 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#12 edit
-
-Change 470 by gibbs@aslan on 2001/12/04 17:09:19
-
-	aic79xx.seq:
-		Convert ccsg idle loop into a proceedure so it can
-		be used in places other than the main idle loop.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#12 edit
-
-Change 469 by gibbs@aslan on 2001/12/02 14:30:08
-
-	aic79xx.c:
-		Add a trace point for printing out saved pointer and residual
-		data from an SCB.
-	
-		Remove a hardware workaround that is no longer needed for
-		H2A2 and beyond.
-	
-		Quite some diagnostic code.
-	
-		Trim our downloaded constants down to only those needed.
-	
-		Add a #error if the number of downloaded constants grows
-		or shrinks from the number we currently initialize.
-	
-		Perform more robust calculations to determine the constants
-		used for S/G element prefetch.
-	
-	aic79xx.reg:
-		Add the saved/residual tracepoint to SEQINTCODE.
-	
-		Trim unused downloaded constants.
-	
-	aic79xx.seq:
-		Make use of SG_PREFETCH_CNT_LIMIT constant in handling
-		S/G fetch.  This ensures that a complete segment is
-		still left in the buffer prior to attempting to use it.
-	
-		Assume the kernel will start the DMA after a PDATA_REINIT
-		call.
-	
-		Correct some comments.
-	
-		Don't clear the data channel after a data group phase.
-		Defer this to await busfree.  This guarantees that SHADDR
-		is still valid should a saved data pointers occur.
-	
-	aic79xx_inline.h:
-		Add "ahd_inl_scbram()".
-	
-	aic79xx_osm.c:
-		Correct another case where we were still using an
-		ahd_syncrate.
-	
-	aicasm/aicasm_gram.y:
-		Don't complain about an immediate aliasing the accumulator
-		if the immediate is a downloaded constant.
-	
-	aicasm/aicasm_symbol.c:
-		Output a #define for the number of downloaded constants
-		the sequencer program is expecting.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#15 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#12 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#11 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#11 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#11 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#11 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#2 edit
-
-Change 468 by gibbs@overdrive on 2001/11/28 15:47:30
-
-	aic79xx_host.h:
-	aic79xx_osm.c:
-	aic79xx_osm.h:
-	aic79xx_osm_pci.c:
-	aic79xx_proc.c:
-		First cut at Linux U320 OSM layer.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_host.h#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_proc.c#1 add
-
-Change 467 by gibbs@aslan on 2001/11/28 15:45:19
-
-	aic79xx_pci.c:
-		Correct include location under Linux.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#7 edit
-
-Change 466 by gibbs@aslan on 2001/11/28 15:43:12
-
-	aic79xx.c:
-	aic79xx.reg:
-		Linux's kernel ffs() implementation doesn't handle
-		constants properly on x86.  Compensate by using
-		a constant for the bit offset as well.  Grrrr!
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#14 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#11 edit
-
-Change 465 by gibbs@aslan on 2001/11/28 14:55:16
-
-	aic79xx.c:
-		Remove debugging printfs.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#13 edit
-
-Change 464 by gibbs@aslan on 2001/11/28 14:46:07
-
-	aic79xx.c:
-		Remove Debugger() statements that Linux doesn't understand.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#12 edit
-
-Change 463 by gibbs@overdrive on 2001/11/28 14:43:42
-
-	aic79xx_inline.h:
-		Avoid code bloat by only including 64bit S/G format
-		code if sizeof(bus_addr_t) > 4.  The compiler should
-		optimize out this code if this check against a constant
-		fails.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#10 edit
-
-Change 462 by gibbs@aslan on 2001/11/28 14:41:51
-
-	aic79xx.h:
-	aic79xx_pci.c:
-		Put PCI BAR offsets into a header where
-		all OSMs can see them.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.h#11 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#6 edit
-
-Change 461 by gibbs@aslan on 2001/11/27 17:52:25
-
-	aic79xx.h:
-		Pull ahd_inw/l/q and ahd_outw/l/q into Core header file.
-	
-	aic79xx_osm.h:
-		Mask off top port bit when doing I/O.
-	
-	ahd_pci.c:
-		Map a subregion for bshs[1], offset by 256 bytes, when we are
-		doing memory mapped I/O.  This compensates for the masking
-		of the port performed above.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.h#10 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/ahd_pci.c#2 edit
-... //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.h#2 edit
-
-Change 459 by gibbs@overdrive on 2001/11/27 13:32:05
-
-	Enable ID expansion.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#11 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#9 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#10 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#10 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#9 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#5 edit
-
-Change 458 by gibbs@overdrive on 2001/11/27 13:29:05
-
-	Allow FreeBSD and Linux to fully share core files.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#16 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.c#10 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#52 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#36 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#12 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#34 edit
-
-Change 454 by gibbs@overdrive on 2001/11/25 17:22:22
-
-	Complete the update of the assembler.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_macro_gram.y#1 add
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_macro_scan.l#1 add
-
-Change 453 by gibbs@overdrive on 2001/11/25 15:46:40
-
-	aic7xxx_osm.c:
-		Add a function to pull out user tag depth information.
-		Use it to limit the per-device tag depth.  The kernel
-		will never send us more commands than this limit anyway
-		since we honor this limit in select queue depths, but
-		this will make the information in /proc jibe with the
-		users settings and prevent some confusion.
-	
-		On kernels that support them (>= 2.4.0), use a tasklet
-		to flush any queued commands pent up in our per-device
-		queues
-	
-		Use an inline function, ahc_linux_next_device_to_run(),
-		to factor out some common code.
-	
-	aic7xxx_osm.h:
-		Add structures for our tasklet to the linux platform
-		softc.
-	
-	aicasm/Makefile:
-		Update for second parser/scanner in the assembler.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#80 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#73 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/Makefile#9 edit
-
-Change 452 by gibbs@overdrive on 2001/11/25 15:32:58
-
-	aic7770.c:
-		Disable chip interrupts early in chip attach.
-		We poke a few registers on the chip prior to
-		resetting it so this narrows the window where
-		an unexpected interrupt could hang us.
-	
-	               Convert all exported symbols to use an "ahc"
-		prefix to avoid conflicts with other drivers.
-	
-		Use a common SEEPROM checksum.
-	
-	aic7xxx.c:
-		Clear any pending message state in ahc_restart();
-	
-		Pass the ahc softc to ahc_update_residual.
-		ahc_update_residual calls ahc_calc_residual which
-		requires the softc to print path information if
-		debugging is enabled.
-	
-		Don't bother clearing message state just prior
-		to calling ahc_restart();
-	
-		Always perform a bus read prior to waiting in
-		a delay loop waiting for a bus write to take
-		effect.  This ensures that the first time
-		through the loop the delay occurs after the
-		write has taken effect.
-	
-		Style cleanup.
-	
-		Remove some initialization code left over from
-		a previous way of probing SCBs.
-	
-		Always clear parity error status after reading
-		any SCB or scratch locations that might be
-		uninitialized.  The debugging code that dumps
-		scratch ram contents could trigger such an
-		event.
-	
-		Initialize any scratch ram locations that might
-		be read (by our interrupt handler most likely)
-		prior to being initialized by our first transaction.
-		SAVED_SCSIID falls into this category, but there
-		may be others.
-	
-		Remove some unecessary code.  In this case, the
-		varaible "next" was initialized unecessarily which
-		could hide "use before initialization" bugs.
-	
-		Add some more information to ahc_dump_card_state();
-	
-	aic7xxx.h:
-		Update ahc_update_residual() declaration.
-	
-		Move AHC_DEBUG definitions to this header.
-	
-	aic7xxx.reg:
-	aic7xxx.seq:
-		Update for changes in the assembler.
-	
-	aic7xxx_93cx6.c:
-	aic7xxx_93cx6.h:
-		Prefix exported symbols with "ahc".
-	
-	aic7xxx_inline.h:
-		Update ahc_update_residual() definition.
-	
-		Target mode command completions come in through
-		the qinfifo, so we must read it even if we are
-		only executing the target role.
-	
-		Change to power state D0 prior to mapping our
-		registers.  BARs are usually cleared by a power
-		state change.
-	
-		Disable chip interrupts early in chip attach.
-		We poke a few registers on the chip prior to
-		resetting it so this narrows the window where
-		an unexpected interrupt could hang us.
-	
-		Use symbols prefixed by "ahc".
-	
-		Clear any parity errors that might occur while
-		trying to pull uninitialized SCB2 information.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#15 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#51 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#35 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#25 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#38 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#11 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#8 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#32 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#33 edit
-
-Change 451 by gibbs@overdrive on 2001/11/25 15:05:14
-
-	Teach the assembler about simple 'C' macros.
-	
-	Add a second parser/scanner to handle macro expansions.
-	
-	The arguments to patch functions are now specified in the
-	source file rather than be hard coded.
-	
-	Use the "driver neutral" "aic_patch_#_func() to denote the
-	static functions used to patch sequencer code.
-	
-	staticize all generated code to avoid conflicts when mutliple
-	drivers are compiled together.
-	
-	Teach the driver about register window modes.  Have the assembler
-	complain if a register is accessed in a window that is not supported
-	by the register.
-	
-	Allow '<<' and '>>' expressions.  They are evaluated during assembly.
-	
-	Complain if an expression used as an "immediate or the accumulator"
-	argument evaluates to 0.  0 is an alias for the accumulator in these
-	instruction formats and referencing the accumulator in these
-	situations is likely not the desired effect.
-	
-	BUGS: Line numbers get screwed up on program listing when macros are
-	      used.  The assembler should output the expanded code into the
-	      listing file so line numbers and instruction lines make sense.
-	      Line numbers in error messages may also be wrong for macros,
-	      but I haven't verified this.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#12 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.h#8 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#10 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#8 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#10 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#7 edit
-
-Change 448 by gibbs@aslan on 2001/11/19 21:22:51
-
-	Checkpoint.  Tagged queuing now works.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#9 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#8 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#9 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#9 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#8 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#4 edit
-
-Change 447 by gibbs@aslan on 2001/11/17 21:06:51
-
-	Checkpoint: U160 now operational.
-	
-	Deal with the NEG table.  And NEG table bugs.
-	
-	Implement IOCELL workarounds.
-	
-	Deal with missing DIS_MSGIN_DUAL in OPTIONMODE register.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#8 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#7 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#8 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#8 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#7 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#3 edit
-
-Change 445 by gibbs@aslan on 2001/11/14 16:49:32
-
-	Checkpoint.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#7 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#6 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#7 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#7 edit
-
-Change 444 by gibbs@aslan on 2001/11/13 21:49:20
-
-	Checkpoint.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#6 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#5 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#6 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#6 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#6 edit
-
-Change 442 by gibbs@aslan on 2001/11/13 14:07:10
-
-	Checkpoint.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#5 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#4 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#5 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#5 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#5 edit
-
-Change 440 by gibbs@aslan on 2001/11/08 21:14:12
-
-	Checkpoint.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#4 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.h#3 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#4 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#4 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#4 edit
-
-Change 439 by gibbs@aslan on 2001/11/07 18:54:07
-
-	Checkpoint.  Selection Timeout path now operates.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#3 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#3 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#3 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#3 edit
-
-Change 438 by gibbs@aslan on 2001/11/07 17:28:10
-
-	Checkpoint.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#2 edit
-
-Change 437 by gibbs@aslan on 2001/11/07 15:41:15
-
-	Checkpoint.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.h#2 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#2 edit
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#2 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#2 edit
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#2 edit
-
-Change 435 by gibbs@aslan on 2001/10/25 13:28:33
-
-	Initial 790X Core driver import.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic79xx.c#1 add
-... //depot/aic7xxx/aic7xxx/aic79xx.h#1 add
-... //depot/aic7xxx/aic7xxx/aic79xx.reg#1 add
-... //depot/aic7xxx/aic7xxx/aic79xx.seq#1 add
-... //depot/aic7xxx/aic7xxx/aic79xx_inline.h#1 add
-... //depot/aic7xxx/aic7xxx/aic79xx_pci.c#1 add
-
-Change 421 by gibbs@overdrive on 2001/10/11 15:33:59
-
-	Bump version to 6.2.4.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#72 edit
-
-Change 420 by gibbs@overdrive on 2001/10/11 15:33:30
-
-	aic7xxx_osm.c:
-		Move the include of linux/module.h to our osm header file.
-	
-		Add a MODULE_LICENSE entry.
-	
-		Don't forget to include the high address bits in
-		calls to pci_unmap_single().
-	
-		Fix a typo in a comment.
-	
-		Use hex instead of decimal when reporting return codes
-		to our exception handling routines.
-	
-	aic7xxx_osm.h:
-		Include, unconditionally, linux/module.h.
-	
-	aic7xxx_osm_pci.c:
-		Add a MODULE_DEVICE_TABLE entry for our PCI ids.
-	
-		Formatting cleanup.
-	
-		Use a simpler way of expressing "all bits set in something
-		the size of a bus_addr_t" without getting compiler warnings
-		on some platforms.
-	
-		Kill an unused variable.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#79 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#71 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#27 edit
-
-Change 419 by gibbs@overdrive on 2001/10/11 15:21:15
-
-	aic7xxx.c:
-		Force renegotatiation of transfer parameters on the
-		next command to a device after a selection timeout or
-		a parity error.
-	
-		Fix a typo in a comment.
-	
-		Put SCBs that aren't in the scbindex table and not already
-		in the free list, back into the free list.  This can happen
-		in certain "SCB queued twice for abort processing" cases.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#50 edit
-
-Change 408 by gibbs@overdrive on 2001/09/13 17:49:29
-
-	Still part of the 6.2.3 release...
-	
-	aic7xxx.c:
-		Export ahc_abort_scbs() for use by OSMs.
-	
-		In ahc_abort_scbs(), only remove entries from
-		the busy target table that match the abort
-		criteria.  In the past, we might take out any
-		entry for a particular target.
-	
-		In ahc_abort_scbs() only search the disconnected
-		list and busy target table if the role is not
-		ROLE_TARGET.
-	
-	aic7xxx.h:
-		Export ahc_abort_scbs() for use by OSMs.
-	
-	aic7xxx.reg:
-		Add a definition for the SCSI offset count in
-		SSTAT3 for U2+ adapters.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#49 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#34 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#24 edit
-
-Change 391 by gibbs@overdrive on 2001/09/12 13:14:51
-
-	Update version for 6.2.3 driver release.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#70 edit
-
-Change 390 by gibbs@overdrive on 2001/09/12 13:14:00
-
-	Update copyright to reflect new binary distribution disclaimer
-	       clause (if you choose BSD license terms) and Adaptec copyright.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7770_osm.c#9 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_host.h#5 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#78 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#69 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#26 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#13 edit
-
-Change 389 by gibbs@overdrive on 2001/09/12 13:07:18
-
-	Update copyright to reflect new binary distribution disclaimer
-	clause and Adaptec copyright.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#14 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#48 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#33 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#23 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#37 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#10 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#7 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#31 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#32 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#11 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.h#7 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#9 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_insformat.h#7 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#7 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#9 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#6 edit
-
-Change 387 by gibbs@overdrive on 2001/09/11 15:31:45
-
-	aic7xxx_inline.h:
-		Remove spurious '{' that only came into effect if
-		target mode was compiled in.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#30 edit
-
-Change 386 by gibbs@overdrive on 2001/09/11 14:19:51
-
-	aic7xxx_osm.c:
-		Only run our shutdown hook for the SYS_DOWN and
-		SYS_HALT events.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#77 edit
-
-Change 385 by gibbs@overdrive on 2001/09/11 14:18:38
-
-	aic7xxx.h:
-		Add residual information to struct target_data to
-		allow residual information to be handled in the
-		same way as for the initiator role.  Prior to this
-		fix, the status byte field was overwritten when the
-		residual count was saved to the SCB assuming the
-		residual was non-zero.
-	
-	aic7xxx.reg:
-		Adjust for change in SCB layout for target mode.
-	
-	aic7xxx.seq:
-		Adjust for change in SCB layout for target mode.
-	
-		Send an ignore wide residue message if we are acting
-		as a target in wide mode and complete a data-in phase
-		with an odd data count.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#32 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#22 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#36 edit
-
-Change 382 by gibbs@overdrive on 2001/09/10 17:31:46
-
-	aic7xxx_osm.c:
-		Initialize our host template's "max_lun" field.  This may
-		correct an issue with probing big, multi-lun, devices in
-		Linux post 2.4.3.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#76 edit
-
-Change 381 by gibbs@overdrive on 2001/09/10 16:29:53
-
-	aic7xxx.c:
-	aic7xxx.h:
-		Add a new constant, AHC_SCB_MAX_ALLOC, which indicates
-		how many of the AHC_SCB_MAX scbs available on the card
-		we can actually allocate.  This can be at most
-		AHC_MAX_QUEUE+1.  The FreeBSD OSM, by virtue of CAM, already
-		enforced this limit.  This change ensures that all OSMs
-		are restricted to this limit.
-	
-	aic7xxx_inline.h:
-		If CMDCMPLT is active in intstat, check all completion queues.
-		This corrects a race condition when target mode is enabled
-		that could allow us to miss running a queue that just received
-		a new command.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#47 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#31 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#29 edit
-
-Change 357 by gibbs@overdrive on 2001/09/06 13:25:10
-
-	aic7xxx_osm.h:
-		Add constants related to the "periodic_otag" feature.
-	
-		Increase the ordered tag threshold to 500 commands.
-	
-		Issue an mb() even when using PIO to talk to the card.
-		This may be necessary on platforms other than intel.
-	
-		Bump driver version to 6.2.2.
-	
-	aic7xxx_osm.c:
-		Remove comments/globals referencing unused driver options.
-	
-		Hook up the following driver options:
-			no_probe	Disable EISA/VLB controller probing
-			no_reset	Supress initial bus resets
-			extended	Enable extended geometry on
-					all controllers
-			periodic_otag	Send an ordered tagged transaction
-					periodically to prevent tag starvation.
-					This may be required by some older disk
-					drives/RAID arrays. 
-			reverse_scan	Sort PCI devices highest Bus/Slot to
-					lowest 
-	
-		Don't attempt to set the PCI dma mask if we're an EISA/VLB
-		controller.
-	
-		Dump controller state on any abort/bdr instead of only when
-		the user has turned on the "verbose" option.  This should
-		facilitate the generation of user bug reports.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#75 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#68 edit
-
-Change 356 by gibbs@overdrive on 2001/09/06 13:16:05
-
-	Only trust sub-device information on Adaptec cards.  It seems
-	that many motherboard implementations do not follow the Adaptec
-	sub-device id spec.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#31 edit
-
-Change 340 by gibbs@overdrive on 2001/08/24 11:24:25
-
-	aic7xxx_osm.c:
-		Remove a no-longer relevant comment.
-	
-		Add information about our module parameters that
-		can be displayed by modinfo.
-	
-		Use the channel letter, rather than the number, as
-		we do in all other displays of this information.
-	
-		Never attempt PPR messages on a device that claims
-		to be SCSI2.  Jaz drives hang, rather than reject
-		the message, and sending these messages to SCSI2
-		devices is just too dangerous.
-	
-		Whitespace cleanup.
-	
-	aic7xxx_osm.h:
-		Include endian information for use by aicasm_insformat.h.
-	
-	aic7xxx_osm_pci.c:
-		Always reserve both our memory and I/O port range to guard
-		against other devices attaching to these same addresses.
-		We still only use one of the two regions for accessing the
-		card.
-	
-	aicasm/Makefile:
-		Add explicit dependencies on y.tab.h so it is rebuilt
-		prior to any files, even generated ones, that need it.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#74 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#67 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#25 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/Makefile#8 edit
-
-Change 339 by gibbs@overdrive on 2001/08/24 11:17:35
-
-	aic7xxx.c:
-		Re-intialize LASTPHASE everytime we restart the sequencer.
-		This should make the value of LASTPHASE fully deterministic.
-	
-		Correct target mode handling of Abort and Abort Tag messages.
-		The sequencer now sets TARGET_MSG_PENDING whenever it runs
-		into an unexpected message while parsing "ident" messages
-		during a selection.  We have to clear this flag whenever we
-		stop processing messages.  We also need to restart the sequencer
-		for any abort message so that we return to busfree.
-	
-		Send the tag number along with the abort tag message immediate
-		notification message.
-	
-		The construct "foo(i++, i++, i++);" is not guaranteed to
-		give "expected" results by the C standard.  Change some
-		diagnostic code to avoid this.
-	
-		Correctly set ahc->unpause to include the IRQMS bit on
-		non-PCI platforms.
-	
-	aic7xxx.reg:
-		Add TARGET_MSG_PENDING bit to the SEQ_FLAGS2 register.
-	
-	aic7xxx.seq:
-		During identify message processing, setup SAVED_LUN.  We
-		may need it to handle certain types of messages.
-	
-		Handle unexpected messages that have already been REQ'ed
-		as well as those that have not been REQ'ed but should be
-		handled due to ATNI being active.
-	
-		Postpone the "queue full" determination until we are about
-		to transition to command phase.  This should give the
-		initiator the ability to abort transactions even if our
-		queue would otherwise be full.
-	
-	aic7xxx_pci.c:
-		Take another stab at validating the 9005 subdevice information
-		prior to using it.  We now ensure that the device type stated
-		in the device field is compatible with the one expressed in
-		the subdevice field.  This should allow the latest report
-		of a "missing channel" to be probed again.
-	
-	aicasm/aicasm.c
-		Pull the platform endian file for userland operations from
-		here, so that the insformat header, which is shared with the
-		kernel, never gets the wrong file.  The kernel driver will
-		deal with getting the correct endian values in its platform
-		specific file.
-	
-	aicasm/aicasm_insformat.h:
-		String #include of endian header files.  This is now handled
-		by the client of this file.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#46 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#21 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#35 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#30 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#10 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_insformat.h#6 edit
-
-Change 330 by gibbs@overdrive on 2001/08/16 15:16:36
-
-	"GNU Public License" -> "GNU General Public License"
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7770_osm.c#8 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_host.h#4 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#73 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#66 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#24 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#12 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/cam.h#11 edit
-
-Change 329 by gibbs@overdrive on 2001/08/16 15:12:51
-
-	"Gnu Public License" -> "Gnu General Public License"
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#13 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#45 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#30 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#20 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#34 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#9 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#6 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#28 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#29 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#9 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.h#6 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#8 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_insformat.h#5 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#6 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#8 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#5 edit
-
-Change 323 by gibbs@overdrive on 2001/08/05 15:00:59
-
-	aic7xxx_linxu.c:
-	aic7xxx_osm_pci.c:
-		pci_set_dma_mask() became available in 2.4.3, not 2.4.0.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#72 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#23 edit
-
-Change 322 by gibbs@overdrive on 2001/08/05 14:58:46
-
-	aic7xxx.c:
-		Correct an off by one in our critical section handling.
-		SEQADDR always reads the next instruction to execute,
-		so we must subtract one from its value before making
-		comparisons with entries in the critical section table.
-	
-		Kill a "too verbose" bootverbose printf.
-	
-		Print a few additional registers whenever we dump
-		card state.
-	
-		Show the SCB_CONTROL and SCB_TAG values for all pending
-		SCBs in card SCB ram when dumping card state.
-	
-	aic7xxx.seq:
-		Fix a bug introduced while optimizing the SDPTR path.
-		We would ack the SDPTR message twice on Ultra2 or better
-		chips if it occurred after all data had been transferred
-		for a transaction.
-	
-		Change our workaround for the PCI2.1 retry bug on some
-		chips.  Although the previous workaround was logically
-		correct, its faster method of draining the FIFO seemed
-		to occassionally confuse the FIFO state.  We now drain
-		the FIFO at half the speed which avoids the problem.
-	
-	aic7xxx_pci.c:
-		Chips with the PCI 2.1 retry bug can't handle a 16byte
-		cachesize.  If the cachesize is set to 16bytes, drop
-		it to 0.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#44 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#33 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#28 edit
-
-Change 317 by gibbs@overdrive on 2001/07/18 16:19:54
-
-	Bump version to 6.2.0 Release.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#65 edit
-
-Change 314 by gibbs@overdrive on 2001/07/18 14:17:17
-
-	Remove a stray '{' after a #endif.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#27 edit
-
-Change 311 by gibbs@overdrive on 2001/07/18 14:14:39
-
-	Only set AHC_RUN_TQINFIFO if we are performing the target role.
-	Otherwise there is no guarantee that the tqinfifo is even allocated.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#26 edit
-
-Change 309 by gibbs@overdrive on 2001/07/17 18:10:35
-
-	aic7xxx_osm.h:
-		Add definition for BUS_SPACE_MAXADDR_32BIT.  This
-		is now used in our bus_dma_tag_create() operations.
-	
-		Remove a spurious return(0) I mistakenly added when
-		"fixing" compiler warnings for NOTREACHED code.
-	
-	aic7xxx_osm_pci.c:
-		Quite a compiler warning for code that cannot be reached
-		unless sizeof(dma_addr_t) > 4.  We now mask our 39bit
-		mask with a mask based on the size of dma_addr_t so
-		we cannot have an overflowing assignment the compiler
-		will complain about.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#64 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#22 edit
-
-Change 308 by gibbs@overdrive on 2001/07/17 18:06:31
-
-	aic7xxx.c:
-		Enforce a 4GB boundary on all DMA transactions.  Due
-		to 32bit DAC restrictions, 64bit addressed operations
-		cannot cross a 4GB boundary.  This is enforced manually
-		in the Linux driver as bus tag boundaries are not honored,
-		but for FreeBSD, the tags are used by the OS dma map
-		routines to enforce the limits.
-	
-		Bus resets (initiated or incoming) clear the ENSELI bit
-		in the SCSISEQ register.  For this reason, we cannot
-		defer the re-enabling of bus reset interrupts in target
-		mode - select-ins might get disabled and we'd never
-		know.
-	
-	aic7xxx.seq:
-		Remove sequencer code to re-enable bus reset interrupts
-		when we are selected as a target.
-	
-	aic7xxx_inline.h:
-		Correct calls to ahc_dmamap_sync.  In Linux these are
-		no-ops, so the fact that we didn't reference our maps
-		correctly didn't show up.
-	
-	aicasm/aicasm.c:
-	aicasm/aicasm_symbol.c:
-		Use queue macros instead of groveling through queue
-		data structures manually.
-	
-		Fix a few style bugs.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#43 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#32 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#25 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#8 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#7 edit
-
-Change 307 by gibbs@overdrive on 2001/07/16 17:31:46
-
-	aic7xxx.c:
-		style(9) fix.
-	
-	aic7xxx.seq:
-		Correct high address support for non-Ultra2 chips.
-	
-		Bring back a fix for flaky external SRAM support
-		on the aic7895.
-	
-	aic7xxx_inline.h:
-		In ahc_update_residual(), don't bother setting
-		a 0 length residual.  The residual is cleared
-		prior to starting the command.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#42 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#31 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#24 edit
-
-Change 306 by gibbs@overdrive on 2001/07/16 17:26:24
-
-	aic7xxx_osm.c:
-		Clean out PCMCIA defines.  This driver does not
-		require any special compile environment to serve
-		cardbus cards.
-	
-		Clear residual data prior to starting a new SCB.
-		The calculate residual code now only sets residual
-		information should a residual exist.
-	
-		Remove a redundant assignment to platform_data->xfer_len.
-		Our map_seg routine already updates this field.
-	
-		Manually set the DRIVER_SENSE bit in the result word
-		of commands that have had auto-sense.
-	
-	aic7xxx_osm.h:
-		Kill silly compiler warnings for no return with value
-		from functions that panic.
-	
-	aic7xxx_osm_pci.c:
-		Use more formal "ULL" designation on some constants.
-	
-	cam.h:
-		Remove unused, at least in Linux, definition of
-		CAM_SIM_QUEUED.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#71 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#63 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#21 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/cam.h#10 edit
-
-Change 303 by gibbs@overdrive on 2001/07/11 17:51:28
-
-	Bump version to 6.2.0-BETA1.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#62 edit
-
-Change 302 by gibbs@overdrive on 2001/07/11 17:47:06
-
-	Remove another diagnostic printf.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#20 edit
-
-Change 301 by gibbs@overdrive on 2001/07/11 17:35:55
-
-	Place a diagnostic behind bootverbose.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#27 edit
-
-Change 300 by gibbs@overdrive on 2001/07/11 17:35:34
-
-	Add VERSION statements.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#19 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#30 edit
-
-Change 299 by gibbs@overdrive on 2001/07/11 17:34:54
-
-	Remove debugging printfs.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#70 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#19 edit
-
-Change 297 by gibbs@overdrive on 2001/07/10 18:23:07
-
-	Add support for the "VERSION" keyword.
-	
-	Print out all version information in generated files.
-	
-	Fix a bug in the handling of "include" statements.
-	For some reason this didn't show up until the version
-	changes were added.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#7 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.h#5 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#7 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#5 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#6 edit
-
-Change 295 by gibbs@overdrive on 2001/07/10 15:27:47
-
-	aic7xxx_osm.c:
-		Don't panic if the system decides to have us select
-		the queue depth for a non-existant device.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#69 edit
-
-Change 293 by gibbs@overdrive on 2001/07/10 14:23:44
-
-	aic7xxx_osm.c:
-		Properly ignore inquiry responses for VPD data or where
-		the amount of data that is actually transferred is not
-		enough for us to pull transfer negotiation information.
-	
-		Add synchronization of datastructures we share with
-		the hardware.
-	
-		Add a per-segment mapping helper function that deals
-		with 39bit addressing issues and complete 39bit
-		support.
-	
-		Fool the OS into always allocating our shared device/kernel
-		memory below the 4GB mark by changing our dma mask on
-		the fly.
-	
-		Add a method for determining the amount of memory in
-		the system.
-	
-		Run devices in a Round Robin fashion to ensure fairness.
-	
-		Correct code that handles temporary SCB resource shortages.
-	
-		Don't report bus resets until we have successfully registered
-		our host structure.
-	
-	aic7xxx_osm.h:
-		Add synchronization primatives.
-	
-		Add definition for the inquiry command for use in
-		our filtering function.
-	
-		Use system defined mb() macro rather than rolling our
-		own.  Allow memory mapped I/O on the ia64.
-	
-	aic7xxx_osm_pci.c:
-		Enable 39Bit addressing if the system supports large
-		addresses on the platform and we have more than 2GB
-		of memory installed.  Some systems move memory to
-		after the 4GB mark, reserving the 2-4GB range for
-		device memory mapping.
-	
-		Clean up a compile error when memory mapped I/O is
-		not enabled.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#68 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#61 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#18 edit
-
-Change 291 by gibbs@overdrive on 2001/07/10 13:43:58
-
-	aic7770.c:
-		Set fields directly in the softc rather than indirect
-		through the probe config structure.
-	
-	aic7xxx.c:
-		Add synchronization calls for data structures in 
-		system memory that are shared between the kernel
-		driver and the controller.
-	
-		Several corrections to 39bit address support:
-			o 39bit support is a flag not a feature
-			  in the ahc softc.
-	
-			o Perform endian conversions for high
-			  address bits.
-	
-		Prevent PPR messages from being issued when acting
-		as a target.
-	
-		Add diagnostics in ahc_search_qinfifo() for tracking
-		down qinfifo corruption issues.
-	
-	aic7xxx.h:
-		Store a pointer to the sg_map_node in the scb to
-		allow scatter gather lists to be synced.
-	
-	aic7xxx.seq:
-		39bit support is a flag not a feature in the ahc softc.
-	
-	aic7xxx_inline.h:
-		Add inlines to facilitate synchronization operations.
-	
-		Synchronize SCBs anytime we perform a lookup from
-		SCB ID to pending SCB and prior to queuing SCBs to
-		the adapter.
-	
-		Synchronize the first qoutfifo and tqinfifo when
-		checking for newly completed transactions.
-	
-		Fix several bugs in the spurious interrupt handling
-		in our interrupt handler.  Hopefully this will stop
-		the reports of spurious PCI errors.
-	
-	aic7xxx_pci.c:
-		Add pci 64bit bus status bit definition for the
-		DEVCONFIG register.
-	
-		Be even more careful in checking that a 9005 subdevice
-		ID is valid prior to processing it.  This should prevent
-		us from dropping the second channel on some MB controllers.
-	
-		Set fields directly in the softc rather than indirect
-		through the probe config structure.
-	
-		Set the DAC enable bit when in 39bit addressing mode.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#12 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#41 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#29 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#29 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#23 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#26 edit
-
-Change 277 by gibbs@overdrive on 2001/06/18 14:52:58
-
-	Switch to round-robin scheduling of devices to ensure fairness
-	during resource contention.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#67 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#60 edit
-
-Change 276 by gibbs@overdrive on 2001/06/18 14:47:51
-
-	aic7xxx.c:
-		Spelling fixes.
-	
-		Handling data pointers reinitialization requests
-		from the sequencer.  This only occurs should the
-		target take us into the data phase twice with
-		an interviening non-data phase.
-	
-		On a data overrun, clear the channel of all preloaded
-		S/G segments if we are an Ultra2 controller.  This
-		error path does not go through the normal dma shutdown
-		path, so we have to clear the S/G fifo while the kernel
-		is recording the overrun event.
-	
-		Clear AHC_ULTRA rather than deal with the AHC_ULTRA_DISABLED
-		flag.
-	
-		Fixup a few cases where we were not properly byte swapping
-		S/G element data in the ignore wide residue handler.   Update
-		this routine for 39bit addressing support.  Remove the
-		reload of the explicit HADDR registers.  We now do this at
-		the time we re-enter the dataphase, which, in 90% of the
-		cases, will never happen.
-	
-		Add the ahc_reinitialize_dataptrs() routine.  This is called
-		to fixup the dma engine's data pointers should we re-enter
-		a data phase with some interveining phase.  This used to
-		be handled in the sequencer, but is so rare (i.e. almost
-		never happens), that there is little reason to waste
-		sequencer space on it.
-	
-	aic7xxx.h:
-		Remove AHC_ULTRA_DISABLED ahc_flag.
-	
-		Add AHC_39BIT_ADRESSING ahc_flag.
-	
-	aic7xxx.reg:
-		Add the DSCOMMAND1 register which holds the high
-		address load select bits.
-	
-		Add the PDATA_REINIT sequencer interrupt code.
-		This is hit should we re-enter a data phase and
-		need help from the kernel to restore the data ptrs.
-	
-		Remove the RESIDUAL sequencer interrupt code.
-		It has not been used for some time.
-	
-	aic7xxx.seq:
-		Spelling fixes.
-	
-		Streamline the ULTRA2 idle loop.  The HADDR register
-		is not directly shaddowed, so we can read the contents
-		placed there by the bmov out of CCSGRAM.
-	
-		Remove data_phase_reinit.  This is now handled by a
-		sequencer interrupt request to the kernel.
-	
-		Remove the assert method.  We now do the test inline
-		which saves two instructions per call.
-	
-		Add 39bit addressing support.
-	
-		Add shortcuts for updating our residual pointers and
-		handling SDPTR messages when we are at the end of
-		a transfer.
-	
-	aic7xxx_inline.h:
-		Change the way that unsolicited interrupts are counted.
-		We now only increment and/or test the unsolicited interrupt
-		count if we see that we don't have any conventional
-		interrupts pending.  More importantly, everytime we do
-		unsolicited interrupt processing, we clear the count.
-		This prevents us from constantly performing unsolicited
-		interrupt handling.
-	
-	aic7xxx_pci.c:
-		Set CLRPARERR in CLRINT for all PCI error status.  The
-		manuals are not sufficiently clear on which status code
-		cause parity errors to be set, so we play it safe.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#40 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#28 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#18 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#28 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#8 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#22 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#25 edit
-
-Change 207 by gibbs@overdrive on 2001/05/01 16:18:08
-
-	Bump driver version to 6.1.13.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#59 edit
-
-Change 206 by gibbs@overdrive on 2001/05/01 16:16:11
-
-	aic7xxx.seq:
-		For chips without S/G pipelining, we can only ack the
-		SDPTR message after SHADDR has been saved.  On these
-		chips, SHADDR increments with every bus transaction,
-		even PIO.  This corrects a data corruption bug in the
-		last version of the sequencer for non-ULTRA2 chips.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#27 edit
-
-Change 205 by gibbs@overdrive on 2001/05/01 15:04:36
-
-	aic7xxx_osm.c:
-		Add support for the 2.4.4 scsi_set_pci_device API.
-	
-	aic7xxx_osm.h:
-		Move the conditional declaration of KERNEL_VERSION to
-		the top of aic7xxx_osm.h so it is defined before
-		its first usage.
-	
-		Remove late conditional include of linux/version.h.  We
-		already include it unconditionally at the top of this file.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#66 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#58 edit
-
-Change 203 by gibbs@overdrive on 2001/05/01 13:07:13
-
-	Makefile:
-		Add the current directory to the include path.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/Makefile#7 edit
-
-Change 202 by gibbs@overdrive on 2001/05/01 13:02:15
-
-	aic7xxx_osm.c:
-		Don't unregister from the reboot notification chain
-		from within our handler.  The routine that calls down
-		the chain does not guard against removals.
-	
-		Create a simq_freeze method as a compliment to the
-		simq_release method.  This method assumes that the
-		ahc lock is held prior to call.  The release method
-		requires a lock as it is only called from a timeout
-		handler.  The release method now guards (other than
-		for a small race that cannot be avoided without a
-		mid-layer change) unblocking and blocking multiple times.
-		Blocking is either on or off; the mid-layer does not
-		have semaphore type semantics for this feature.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#65 edit
-
-Change 196 by gibbs@overdrive on 2001/04/27 14:24:13
-
-	Bump version number to 6.1.12 for next release.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#57 edit
-
-Change 195 by gibbs@overdrive on 2001/04/27 14:23:37
-
-	aic7xxx_osm.c:
-		current -> curr
-	
-		Implement a kludge to deal with inquiry requests that
-		are not large enough for us to pull the spi3 bits.
-		In this case, we assume that a device that tells us
-		they can provide inquiry data that spans the SPI3
-		bits can handle a PPR request.  If the inquiry
-		request has sufficient buffer space to cover these
-		bits, we check them to see if any ppr options are
-		available.  This corrects the drop to async narrow
-		for U160 devices during a cdrecord bus scan.
-	
-	aic7xxx_osm.h:
-		Remove the kludge to undefine "current".  We've renamed
-		any effected fields in the driver to avoid a conflict.
-	
-		dma_addr_t appeared in 2.2.18, not 2.2.17.
-	
-	aic7xxx_proc.c:
-		current -> curr
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#64 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#56 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#11 edit
-
-Change 194 by gibbs@overdrive on 2001/04/27 14:19:04
-
-	aic7xxx.c:
-		current->curr to avoid Linux's use of current as a
-		#define for the current task on some architectures.
-	
-		Add a helper function, ahc_assert_atn(), for use in
-		message phases we handle manually.  This hides the fact
-		that U160 chips with the expected phase matching disabled
-		need to have SCSISIGO updated differently.
-	
-		if (ahc_check_residual(scb) != 0)
-			ahc_calc_residual(scb);
-		else
-			ahc_set_residual(scb, 0);
-	
-		becomes:
-	
-		ahc_update_residual(scb);
-	
-		Modify scsi parity error (or CRC error) handling to
-		reflect expected phase being disabled on U160 chips.
-	
-		Move SELTO handling above BUSFREE handling so we can
-		use the new busfree interrupt behavior on U160 chips.
-	
-		Correct a long standing but latent bug in
-		ahc_find_syncrate().  We could choose a DT only
-		rate even though DT transfers were disabled.
-	
-		When displaing controller characteristics, include the
-		speed of the chip.  This way we can modify the transfer
-		speed based on optional features that are enabled/disabled
-		in a particular application.
-	
-	aic7xxx.h:
-		The real 7850 does not support Ultra modes, but there are
-		several cards that use the generic 7850 PCI ID even though
-		they are using an Ultra capable chip (7859/7860).  We start
-		out with the AHC_ULTRA feature set and then check the
-		DEVSTATUS register to determine if the capability is really
-		present.
-	
-		current -> curr
-	
-		ahc_calc_residual() is no longer static allowing it to
-		be called from ahc_update_residual() in aic7xxx_inline.h.
-	
-	aic7xxx.reg:
-		Add a combined DATA_PHASE mask to the SCSIPHASE register
-		definition to simplify some sequencer code.
-	
-	aic7xxx.seq:
-		Take advantage of some performance features available only
-		on the U160 chips.  The auto-ack feature allows us to ack
-		data-in phases up to the data-fifo size while the sequencer
-		is still setting up the DMA engine.  This greatly reduces
-		read transfer latency and simplifies testing for transfer
-		complete (check SCSIEN only).  We also disable the expected
-		phase feature, and enable the new bus free interrupt behavior,
-		to avoid a few instructions.
-	
-		Re-arrange the Ultra2+ data phase handling to allow us to
-		do more work in parallel with the data fifo flushing on a
-		read.
-	
-		On an SDTR, ack the message immediately so the target can
-		prepare the next phase or message byte in parallel with 
-		our work to honor the message.
-	
-	aic7xxx_inline.h:
-		ahc_update_residual() now looks at the residual valid
-		flag in an endian safe way.  This fixes a residual bug
-		on the PPC.
-	
-	aic7xxx_pci.c:
-		Correct a few product strings.
-	
-		Enable several U160 performance enhancing features.
-	
-		Modify Ultra capability determination so we will enable
-		Ultra speeds on devices with a 7850 PCI id that happen
-		to really be 7859 or 7860s.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#39 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#27 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#17 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#26 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#21 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#24 edit
-
-Change 189 by gibbs@overdrive on 2001/04/09 14:52:16
-
-	Bump version number to 6.1.11 for latest release.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#55 edit
-
-Change 188 by gibbs@overdrive on 2001/04/06 16:38:18
-
-	aic7xxx.c:
-		In ahc_build_transfer_msg() filter the period and
-		ppr_options prior to deciding whether a PPR message
-		is required.  ppr_options may be forced to zero
-		which will affect our decision.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#38 edit
-
-Change 187 by gibbs@overdrive on 2001/04/06 15:54:25
-
-	aic7xxx_osm.c:
-		Don't try negotiations that require PPR messages
-		if bus reset is enabled.  We'll wait until we
-		successfully retrieve Inquiry data so we can make
-		an informed decision.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#63 edit
-
-Change 186 by gibbs@overdrive on 2001/04/05 16:29:33
-
-	aic7xxx_osm.h:
-		Bump version number to 6.1.10.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#54 edit
-
-Change 185 by gibbs@overdrive on 2001/04/05 16:29:00
-
-	aic7xxx_osm.c
-		Use scsi_(un)block_requests() to effect a freeze of the
-		entire controller queue.  Scsi_unblock_requests() has been
-		modified to actually run any stalled queues in the 2.4.X
-		kernel sources.  For 2.2.X, scsi_(un)block_requests() was
-		implemented.  Since we now rely on this functionality,
-		only patch updates to the driver will be provided from
-		here on out.
-	
-		With this change, our bus settle delay can be of any
-		length and still avoid triggering command timeouts from
-		the midlayer.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#62 edit
-
-Change 182 by gibbs@overdrive on 2001/04/04 16:32:27
-
-	Bump version number to 6.1.9 for latest release.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#53 edit
-
-Change 181 by gibbs@overdrive on 2001/04/04 16:31:50
-
-	aic7xxx_osm.c:
-		Correct a bug in ahc_done() that prevented us from running
-		the in-core device queue anytime the physical device was
-		idle.  This caused problems anytime the driver received
-		more than one transaction for a device that does not
-		support tagged transactions.  Unless another transaction
-		was queued to us to kick the queue, the transaction would
-		never get run.  Zip drives are the most commonly found
-		device that was affected by this bug.
-	
-		CONFIG_AIC7XXX_RESET_DELAY -> CONFIG_AIC7XXX_RESET_DELAY_MS
-		Too many people have stale settings under the old config
-		option name for us to use it with a different meaning.
-		The setting is now in milli-seconds to allow more granular
-		control so stale values resulted in an extremely short bus
-		settle delay.
-	
-		Add a shutdown hook that resets all of the controllers
-		to a safe state.
-	
-		Update for changes in the way negotiation prameters are
-		communicated with the Core.
-	
-		Correct a function name in a printf.
-	
-		tmode_tstate -> ahc_tmode_tstate.
-	
-	aic7xxx_proc.c:
-		tmode_tstate -> ahc_tmode_tstate.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#61 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#10 edit
-
-Change 180 by gibbs@overdrive on 2001/04/04 16:22:29
-
-	aic7770.c:
-		Register our interrupt driver prior to enabling our
-		Bus drivers.  This is just added paranoia.
-	
-	aic7xxx.c:
-		Namespace cleanup continues:
-			tmode_tstate -> ahc_tmode_tstate
-			tmode_lstate -> ahc_tmode_lstate
-	
-		Clean up the check condition path by branching early rather
-		than indenting a giant block of code.
-	
-		Add support for target mode initiated sync negotiation.
-		The code has been tested by forcing the feature on for
-		all devices, but for the moment is left inaccesible until
-		a decent mechanism for controlling the behavior is complete.
-		Implementing this feature required the removal of the
-		old "target message request" mechanism.  The old method
-		required setting one of the 16 bit fields to initiate
-		negotiation with a particular target.  This had the nice
-		feature of being easy to change the request and have it
-		effect the next command.  We now set the MK_MESSAGE bit
-		on any new command when negotiation is required.  When
-		the negotiation is successful, we walk through and clean
-		up the bit on any pending commands.  We have to walk
-		the commands to reset the SCSI syncrate values already,
-		so no additional work is required.  The only drawback of
-		this approach is that the negotiation is deferred until
-		the next command is queued to the controller.  On the plus
-		side, we regain two bytes of sequencer scratch ram and 6
-		sequencer instructions.
-	
-		When cleaning up a target mode instance, never remove the
-		"master" target mode state object.  The master contains
-		all of the saved SEEPROM settings that control things like
-		transfer negotiations.  This data will be cloned as the
-		defaults if a target mode instance is re-instantiated.
-	
-		Correct a bug in ahc_set_width().  We neglected to update
-		the pending scbs to reflect the new parameters.  Since
-		wide negotiation is almost always followed by sync
-		negotiation it is doubtful that this had any real
-		effect.
-	
-		When in the target role, don't complain about
-		"Target Initiated" negotiation requests when an initiator
-		negotiates with us.
-	
-		Pull all info that used to be in ahc_timeout for the FreeBSD
-		OSM into ahc_dump_card_state().  This info should be printed
-		out on all platforms.
-	
-	aic7xxx.h:
-		Add the SCB_AUTO_NEGOITATE scb flag.  This allows us to
-		discern the reason the MK_MESSAGE flag is set in the hscb
-		control byte.  We only want to clear MK_MESSAGE in
-		ahc_update_pending_scbs() if the MK_MESSAGE was set due
-		to an auto transfer negotiation.
-	
-		Add the auto_negotiate bitfield for each tstate so that
-		behavior can be controlled for each of our enabled SCSI
-		IDs.
-	
-		Use a bus interrupt handler vector in our softc rather
-		than hard coding the PCI interrupt handler.  This makes
-		it easier to build the different bus attachments to
-		the aic7xxx driver as modules.
-	
-		Update seeprom definitions for the latest formats.
-	
-	aic7xxx.reg:
-		Remove the TARGET_MSG_REQUEST definition for sequencer ram.
-	
-	aic7xxx.seq:
-		Fix a few target mode bugs:
-	
-		o If MK_MESSAGE is set in an SCB, transition to
-		  message in phase and notify the kernel so that
-		  message delivery can occur.  This is currently
-		  only used for target mode initiated transfer
-		  negotiation.
-	
-		o Allow a continue target I/O to compile without
-		  executing a status phase or disconnecting.  If
-		  we have not been granted the disconnect privledge
-		  but this transfer is larger than MAXPHYS, it may
-		  take several CTIOs to get the job done.
-	
-		Remove the tests of the TARGET_MSG_REQUEST field
-		in scratch ram.
-	
-	aic7xxx_inline.h:
-		Use ahc->bus_intr rather than ahc_pci_intr.
-	
-	aic7xxx_pci.c:
-		Move a comment to the correct location.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#11 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#37 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#26 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#16 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#25 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#20 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#23 edit
-
-Change 172 by gibbs@overdrive on 2001/03/22 17:47:51
-
-	Bump version to 6.1.8.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#52 edit
-
-Change 169 by gibbs@overdrive on 2001/03/22 15:56:41
-
-	aic7xxx_osm.c:
-	aic7xxx_osm.h:
-		Add support for switching to from full to basic
-		command queuing.  Flags in the ahc_linux_device
-		structure indicate what kind of queuing to perform.
-	
-		In the past, we issued an ordered tag every 250
-		transactions.  We now issue an ordered tag every
-		250 transactions issued without the device queue
-		going empty.
-	
-	aic7xxx_proc.c:
-		Use an unsigned long for total number of commands
-		sent to a device.  %q and %lld don't seem to work
-		under Linux or I'd have used a quad.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#60 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#51 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#9 edit
-
-Change 167 by gibbs@overdrive on 2001/03/22 15:45:33
-
-	aic7770.c:
-	aic7xxx_pci.c:
-		Don't map our interrupt until after we are fully setup to
-		handle interrupts.  Our interrupt line may be shared so
-		an interrupt could occur at any time.
-	
-	aic7xxx.h:
-	aic7xxx.c:
-		Add support for switching from fully blown tagged queing
-		to just using simple queue tags should the device reject
-		an ordered tag.
-	
-		Remove per-target "current" disconnect and tag queuing
-		enable flags.  These should be per-device and are not
-		referenced internally be the driver, so we let the OSM
-		track this state if it needs to.
-	
-		Use SCSI-3 message terminology.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#10 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#36 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#25 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#22 edit
-
-Change 165 by gibbs@overdrive on 2001/03/19 17:58:07
-
-	aic7770.c:
-		ahc_reset() leaves the card in a paused state.
-		Re-arrange the code so we reset the chip earlier
-		so we can avoid a manual pause during setup.
-	
-		Setup the controller without enabling card interrupts.
-	
-	aic7xxx.c:
-		Fix a bug in ahc_lookup_phase_entry().  We never traversed
-		past the first entry.  This routine is only used in
-		diagnostics so this had only a limited effect.
-	
-		Start out life with card interrupts disabled.  The bus
-		code will enable the interrupts once setup is complete
-		and our handler is in place.
-	
-		Initialize our softc unit to -1 so that code such as
-		ahc_linux_next_unit() can traverse the list looking for
-		coliding unit numbers without tripping over entries that
-		have not yet had their unit number set.
-	
-		Enhance ahc_dump_card_state().  OSMs should be able to
-		rely on this to dump any controller specific data of
-		interest.  Most of the additional registers printed
-		used to be printed in the FreeBSD timeout handler.
-	
-		Add a function pointer in our softc for a bus specific
-		interrupt handler.  This removes some dependencies on
-		the PCI code so that bus attachments can be compiled
-		as modules separate from the core.
-	
-	aic7xxx.reg:
-		Use the naming for bit 5 of DFSTATUS in the data book,
-		FIFOQWDEMP.
-	
-	aic7xxx.seq:
-		In our idle loop, use an or instruction to set PRELOADEN
-		rather than rewriting the contents of DMAPARAMS to
-		DFCNTRL.  The later may re-enable the DMA engine if
-		the idle loop is called to complete the preload of at
-		least one segment when a target disconnects on an S/G
-		segment boundary but before we have completed fetching
-		the next segment.  This correts a hang, usually in
-		message out phase, when this situation occurs.  This
-		bug has been here for a long time, so the situation
-		is rare, but not impossible to reproduce.
-	
-		Wait for at least 8 bytes in the FIFO before testing to
-		see if the DMA fetch of an SCB has stalled.  The old
-		code used FIFOEMP, which goes false on a single byte.
-		Since we drain the FIFO 8 bytes at a time, using FIFOQWDEMP
-		is safer.
-	
-		If a device happens to be exceptionally slow in asserting
-		HDONE, our workaround for a stalled SCB dma can be triggered.
-		Make this situation non-fatal by terminating our FIFO
-		emptying should we complete the transfer.
-	
-	aic7xxx_inline.h:
-		ahc_pci_intr() -> ahc->bus_intr()
-	
-	aic7xxx_pci.c:
-		Setup ahc->bus_intr().
-	
-		Enable board interrupts at the appropriate time.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#9 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#35 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#24 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#15 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#24 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#19 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#21 edit
-
-Change 164 by gibbs@overdrive on 2001/03/19 17:44:04
-
-	aic7xxx_osm.c:
-		Format to 80 columns.
-	
-		Break after finding a matching entry in the token
-		table during aic7xxx_setup.
-	
-		print the correct name of a function in a diagnostic.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#59 edit
-
-Change 163 by gibbs@overdrive on 2001/03/10 23:51:53
-
-	Bump version to 6.1.7.  The too leanient interpretation
-	of the seeprom signature could result in improper
-	termination settings on some MBs, and this is a big
-	enough bug to warant a new release.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#50 edit
-
-Change 162 by gibbs@overdrive on 2001/03/10 23:50:09
-
-	Handle cross builds.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/Makefile#6 edit
-
-Change 161 by gibbs@overdrive on 2001/03/10 23:41:16
-
-	We now generate a header file for the db include
-	under linux to handle the build on more distribution
-	types.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#5 edit
-
-Change 160 by gibbs@overdrive on 2001/03/10 23:40:38
-
-	aic7xxx.h:
-		Add a definition for the 3.X BIOS signature.
-	
-	aic7xxx_inline.h:
-		We must setup queuestat before processing
-		command complete interrupts in case target
-		mode is enabled.
-	
-	aic7xxx_pci.c:
-		Be more selective in the BIOS signatures we
-		support.  Some seeproms have a signature of
-		0xFFFF, so testing greater than 0x250 resulted
-		in false positives.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#23 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#18 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#20 edit
-
-Change 159 by gibbs@overdrive on 2001/03/09 18:37:25
-
-	To be compatible with older kernels, our setup routine
-	must be called aic7xxx_setup().
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#58 edit
-
-Change 158 by gibbs@overdrive on 2001/03/09 18:00:41
-
-	Play some games so we have a better chance of actually
-	building on more systems.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/Makefile#5 edit
-
-Change 157 by gibbs@overdrive on 2001/03/09 17:04:49
-
-	aic7770_osm.c:
-	aic7xxx_osm.h:
-		Adjust aic7770_map_int() to not rely on a passed in "shared"
-		argument.  We can now look at ahc->flags to see whether the
-		interrupt source is edge or level.
-	
-	aic7xxx_osm.c:
-		Only adjust our goal negotiation settings if the device
-		is actually present.  This prevents a disconnected lun
-		that does not claim to support negotiations from messing
-		up the settings for a successfully probed lun whose inquiry
-		data properly reflects the abilities of the device.
-	
-		Set the device structure as releasable should the inquiry
-		come back with anything other than lun connected.  We
-		should also do this if the device goes away as evidenced
-		by a selection timeout, but as we can't know if this
-		condition is persistant and there is no guarantee that
-		the mid-layer will reissue the inquiry command we use
-		to validate the device, I've simply added a comment
-		this effect.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7770_osm.c#7 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#57 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#49 edit
-
-Change 156 by gibbs@overdrive on 2001/03/09 16:58:41
-
-	Adjust our interrupt handler so it will work in the edge
-	interrupt case.  We must process all interrupt sources
-	when the interrupt fires or risk not ever getting an
-	interrupt from them.  This involves marking the fact
-	that we are relying on an edge interrupt in ahc->flags
-	and checking for this condition in addition to the
-	AHC_ALL_INTERRUPTS flag.
-	
-	This will make it into the 6.1.6 Linux driver release.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#8 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#22 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#17 edit
-
-Change 155 by gibbs@overdrive on 2001/03/08 17:00:32
-
-	Bump version number for new release.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#48 edit
-
-Change 154 by gibbs@overdrive on 2001/03/08 16:59:57
-
-	Convert to ahc_* and ahc_linux_* function names.
-	
-	aic7770_osm.c:
-		Drop the SA_INTERRUPT flag.  According to Linus,
-		it should not be set.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7770_osm.c#6 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_host.h#3 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#56 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#47 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#17 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#8 edit
-
-Change 153 by gibbs@overdrive on 2001/03/08 16:58:20
-
-	Cleanup exported symbol names.  We now use ahc_* exclusively
-	to reduce the chance of conflicts with other modules.
-	
-	Staticize symbols that should have always been static.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#34 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#21 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#16 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#19 edit
-
-Change 152 by gibbs@overdrive on 2001/03/07 18:54:38
-
-	aic7xxx_osm.c:
-		Correct our softc comparison routine so that, regardless
-		of which function is seen first, the primary channel of
-		a multi-function chip is probed first.
-	
-		Note that the host structure only records a single scsi
-		ID.  This means that multi-channel controllers, such as
-		the 2742T, cannot inform the SCSI layer of the IDs used
-		by channels other than the first.
-	
-		There is also no way to communicate the probe order of
-		channels on a multi-channel adapter.  We could swap the
-		channels internally, but that would probably be more
-		confusing than just not supporting the option.
-	
-		Add a crude hack to make modunload/modload cycles work
-		now that we are using the new PCI methods.  We must
-		detach our driver from each PCI device referenced by
-		a call to our release method.  The PCI code doesn't have
-		a method to do this, so we muck with the pci_dev ourselves.
-	
-		Deregister our PCI driver when aic7xxx_release releases
-		the last host instance.
-	
-		Fix a bug in the inquiry sniffing code.  It was possible
-		to set our period to a non-zero value even though the
-		offset was zero.  This might have confused some async
-		devices.
-	
-	aic7xxx_osm.h:
-		ahc_power_state_change() is now an OSM routine.
-	
-	aic7xxx_osm_pci.c
-		Make our pci_driver non-static so that aic7xxx_osm.c
-		can reference it during module unload.
-	
-		Add an implementation to change the power state for
-		kernel versions that don't have a PCI method to do
-		this.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#55 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#46 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#16 edit
-
-Change 151 by gibbs@overdrive on 2001/03/07 18:45:53
-
-	aic7770.c:
-		Store a 2 bit channel number in ahc->flags.
-	
-	aic7xxx.c:
-		AHC_SUPPORT_PCI has never been defined.  Use
-		AHC_PCI_CONFIG instead.
-	
-		Modify multi-function option merging to work
-		regardless of the order the functions are presented
-		to the driver.
-	
-		Adjust for the primary channel being a 2 bit integer
-		rather than a flag for 'B' channel being the primary.
-	
-	aic7xxx.h:
-		Adjust for the primary channel being represented as
-		a 2 bit integer in the flags member of the ahc softc.
-	
-		Cleanup the flags definitions so that comment blocks are
-		not cramped.
-	
-		Update seeprom definitions to correctly reflect the fact
-		that the primary channel is represented as a 2 bit
-		integer.
-	
-	aic7xxx.reg:
-		Add DFCACHETH to the definition of DFSTATUS for
-		completness sake.
-	
-	aic7xxx.seq:
-		On some chips, at least the aic7856, the transition from
-		MREQPEND to HDONE can take a full 4 clock cycles.  Test
-		HDONE one more time to avoid this race.  We only want our
-		FIFO hung recovery code to execute when the engine is
-		really hung.
-	
-	aic7xxx_pci.c:
-		Move the powerstate manipulation code into the OSM.  Several
-		OSes now provide this functionality natively.
-	
-		Take another shot at using the data stored in scratch ram
-		if the SCB2 signature is correct and no SEEPROM data is
-		available.  In the past this failed if external SCB ram
-		was configured because the memory port was locked.  We
-		now release the memory port prior to testing the values
-		in SCB2 and re-acquire it prior to doing termination control.
-	
-		Adjust for new 2 bit primary channel setting.
-	
-		Trust the STPWLEVEL setting on any BIOS v 2.5X and above.
-		3.X bioses have started to ship.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#7 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#33 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#20 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#14 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#23 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#18 edit
-
-Change 150 by gibbs@overdrive on 2001/02/28 17:44:09
-
-	aic7xxx_osm.c:
-		Fix the setup for the selection timeout setting.
-	
-		During exception processing dump the card state if
-		we are in verbose mode.
-	
-		Keep "driver_template" static so as not to conflict
-		with other files in the system.  Instead, export a
-		pointer to the driver template with a more unique
-		symbol name.
-	
-	aic7xxx.h:
-		Export our pointer to the driver template.
-	
-		Bump driver version number to 6.1.5.
-	
-	aic7xxx_osm_pci.c:
-		Use the newly exported pointer to the driver template.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#54 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#45 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#15 edit
-
-Change 149 by gibbs@overdrive on 2001/02/28 17:36:26
-
-	aic7xxx.c:
-		Take advantage of a new flag managed by the sequencer
-		that indicates if an SCB fetch is in progress.  If so,
-		the currently selected SCB needs to be returned to the
-		free list to prevent an SCB leak.  This leak is a rarity
-		and would only occur if a bus reset or timeout resulting
-		in a bus reset occurred in the middle of an SCB fetch.
-	
-		Don't attempt to perform ULTRA transfers on ultra capable
-		adapters missing the external precision resistor required
-		for ultra speeds.  I've never encountered an adapter
-		configured this way, but better safe than sorry.
-	
-	aic7xxx.h:
-		Add AHC_ULTRA_DIASABLED softc flag to denote controllers
-		missing the external precision resistor.
-	
-	aic7xxx.reg:
-		Add SEQ_FLAGS2 which currently only contains the SCB_DMA
-		(SCB DMA in progress) flag.
-	
-	aic7xxx.seq:
-		Manage the SCB_DMA flag of SEQ_FLAGS2.
-	
-		More carefully shutdown the S/G dma engine in
-		all cases by using a subroutine.  Supposedly not
-		doing this can cause an arbiter hang on some ULTRA2
-		chips.
-	
-		Formatting cleanup.
-	
-	aic7xxx_pci.c:
-		Configure any 785X ID in the same fashion and assume
-		that any device with a rev id of 1 or higher has the
-		PCI 2.1 retry bug.  It seems that at least some revisions
-		of the 7856 have this bug.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#32 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#19 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#13 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#22 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#17 edit
-
-Change 148 by gibbs@overdrive on 2001/02/27 17:39:56
-
-	Correct a problem when one lun has a disconnected untagged
-	transaction and another lun has disconnected tagged transactions.
-	Just because an entry is found in the untagged table doesn't
-	mean that it will match.  If the match on the lun fails, cleanup
-	the SCB (return it to the disconnected list or free it), and snoop
-	for a tag message.  Before this change, we reported an unsolicited
-	reselection.  This bug was introduced about a month ago during an
-	overly aggressive optimization pass on the reselection code.
-	
-	When cleaning up an SCB, we can't just blindly free the SCB.  In
-	the paging case, if the SCB came off of the disconnected list, its
-	state may never have been updated in host memory.  So, check the
-	disconnected bit in SCB_CONTROL and return the SCB to the disconnected
-	list if appropriate.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#21 edit
-
-Change 147 by gibbs@overdrive on 2001/02/26 17:05:34
-
-	Handle the case of 5MHz user sync rate set as "0" instead of 0x1c
-	in scratch ram.
-	
-	If we lookup a period of 0 in our table (async), clear the scsi offset.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#31 edit
-
-Change 146 by gibbs@overdrive on 2001/02/21 20:48:22
-
-	Put our exception handling semaphore into the softc rather
-	than as a global.  I don't know what I was thinking when
-	I wrote this code, but having two different controllers sleeping
-	on the same mutex for error recovery is a recipe for disaster.
-	
-	Implement a controller global queue freeze function.  We use this
-	feature to handle the initial reset bus settle delay.  The queue
-	is unfrozen by a timer so all bus settle delays occur in parallel
-	and without stopping other kernel tasks from running.  My only
-	remaining concern is that the specification of too long of a
-	reset delay might trigger a mid-layer timeout.  The default
-	under linux is 5 seconds which is substantially less than the
-	timeouts used during probe.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#53 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#44 edit
-
-Change 145 by gibbs@overdrive on 2001/02/21 13:26:52
-
-	Bump version for 6.1.3 release.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#43 edit
-
-Change 144 by gibbs@overdrive on 2001/02/21 13:26:21
-
-	Properly use the target offset rather than the target id
-	for choosing the correct untagged Q to manipulate.  This
-	should correct problems with the 2742T.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#52 edit
-
-Change 143 by gibbs@overdrive on 2001/02/21 13:25:10
-
-	Identify adapters in ARO mode as such.
-	
-	Ensure that not only the subvendor ID is correct (9005)
-	but also that the controller type field is valid before
-	looking at other information in the subdevice id.  Intel
-	seems to have decided that their subdevice id of 8086
-	is more appropriate than Adaptec's sanctioned scheme.
-	
-	Add an exclusion entry for SISL (AAC on MB based adapters).
-	Adapters in SISL mode are owned by the RAID controller, so
-	even if a driver for the RAID controller is not present,
-	it isn't safe for us to touch them.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#16 edit
-
-Change 142 by gibbs@overdrive on 2001/02/21 13:21:47
-
-	Use the target offset rather than the target Id to reference
-	the untagged SCB array.  The offset and id are identical save
-	in the twin channel case.  This should correct several issues
-	with the 2742T.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#30 edit
-
-Change 141 by gibbs@overdrive on 2001/02/21 13:21:00
-
-	Correct an issue with the aic7770 in twin channel mode.
-	We could continually attempt to start a selection even
-	though a selection was already occurring on one channel.
-	This might have the side effect of hanging our selection
-	or causing us to select the wrong device.
-	
-	While here, create a separate polling loop for when we
-	have already started a selection.  This should reduce
-	the latency of our response to a (re)selection.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#20 edit
-
-Change 140 by gibbs@overdrive on 2001/02/17 14:44:19
-
-	Bump version number to 6.1.2.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#42 edit
-
-Change 139 by gibbs@overdrive on 2001/02/16 16:15:57
-
-	Don't require iospace or mem space to be enabled in order to
-	attach to a PCI device.  We only require that one of the mapping
-	registers is properly setup.
-	
-	This fix allows us to run on a G3 PowerMac.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#14 edit
-
-Change 138 by gibbs@overdrive on 2001/02/15 10:43:52
-
-	Use dma_addr_t as the Linux equivalent to bus_addr_t.  uint32_t
-	works for only some platforms.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#41 edit
-
-Change 137 by gibbs@overdrive on 2001/02/15 10:42:44
-
-	Set the goal and user settings for sync and wide negotiation
-	prior to setting the current.  This makes it easier for some
-	code in the Linux OSM to know when is an oportune time to
-	display a user message about transfer negotiation status.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#29 edit
-
-Change 136 by gibbs@overdrive on 2001/02/09 20:09:59
-
-	On second thought, don't test for ATN just before a
-	command complete message is processed.  We probably
-	want to test for SCSIPERR, but this needs more thought.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#19 edit
-
-Change 135 by gibbs@overdrive on 2001/02/09 20:06:02
-
-	aic7xxx.c:
-		Style nits.
-	
-		Make sure that our selection hardware is disabled
-		as soon as possible after detecting a busfree and
-		even go so far as to disable the selection hardware
-		in advance of an event that will cause a busfree
-		(ABORT or BUS DEVICE RESET message).  The concern
-		is that the selection hardware will select a target
-		for which, after processing the bus free, there
-		will be no commands pending.  The sequencer idle
-		loop will re-enable the selection should still be
-		necessary.
-	
-		In ahc_handle_scsiint(), clear SSTAT0 events several
-		PCI transactions (most notably reads) prior to clearing
-		SCSIINT.  The newer chips seem to take a bit of time
-		see the change which can make the clearing of SCSIINT
-		ineffective.
-	
-		Don't bother panicing at the end of ahc_handle_scsiint().
-		Getting to the final else just means we lost the race
-		with clearing SCSIINT.
-	
-		In ahc_free(), handle case 0.  This can happen when we fail
-		the attach for RAID devices.  While I'm here, also kill
-		the parent dma tag.
-	
-		In ahc_match_scb(), consider initiator ccbs to be any
-		that are not from the target mode group.  This fixes
-		a bug where an external reset CCB was not getting cleaned
-		up by the reset code.
-	
-		Don't bother freezing a ccb in any of our "abort" routines
-		when the status is set to CAM_REQ_CMP.
-	
-	aic7xxx.reg:
-		Reserve space for a completion queue.  This will be used
-		to enhance performance in the near future.
-	
-		Remove an optimization for the 7890 autoflush bug that
-		turned out to allow, in rare cases, some data to get
-		lost.
-	
-		Even though we need a critical section to fully close
-		the command complete loophole, test for ATN anyway in
-		the command complete handler.  Its better than nothing.
-	
-		Implement a simpler, faster, fix for the PCI_2_1 retry
-		bug that hangs the sequencer on an SCB dma.
-	
-	aic7xxx_pci.c
-		Use the correct mask for checking the generic aic7892
-		entry.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#28 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#12 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#18 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#15 edit
-
-Change 134 by gibbs@overdrive on 2001/02/09 19:29:14
-
-	aic7xxx_osm.c:
-		Pull the host_no out of the host structure rather
-		than storing a copy of the field in our own platform
-		softc.
-	
-		Use the host_no rather than our unit nuber for any
-		"scsi%d" type printfs.  In this case, the result is
-		a corrected printf for tagged queue depth.
-	
-		Anytime we run the complete queue, we must clear it.
-		We missed the clearing part when running the device
-		queue after queuing a new command.
-	
-		Use the same format for reporting transfer rates as the
-		/proc code.  Only print transfer info if no further
-		negotiations are pending and the value is different from
-		the last one reported.
-	
-		Correctly format a printf used during error recovery.
-	
-		Don't forget to set the result before returning from
-		one case in ahc_queue_recovery_scb.
-	
-		Fix inverted test for the non-paging case.  The result of
-		this bug was that we would set the MK_MESSAGE bit in an
-		SCB unrelated to the SCB we were trying to abort.
-	
-		Add a missing add_timer() call.  It's hard to timeout
-		on a recovery action when no timer is running.  This
-		also explains why I had to invert the test of the status
-		returned by del_timer() in the past.  We always thought
-		the timer had expired because it was no longer active.
-	
-		Don't forget to run the device queue after error recovery
-		is complete.  We don't want to leave any stray commands
-		stuck in our queues.
-	
-	aic7xxx_osm.h
-		Bump version for next release.
-	
-		Add a "last_tinfo" field to the ahc_linux_target to track
-		what negotiation settings have been announced.
-	
-		Kill unneeded host_no field in the platform softc.
-	
-		Bring the info_str structure into this header file so
-		we can export ahc_format_transinfo() outside of the
-		/proc code.
-	
-	aic7xxx_proc.c:
-		Export ahc_format_transinfo().
-	
-		Use the host_no in the host structure rather than
-		removed field in the platform softc.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#51 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#40 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#7 edit
-
-Change 133 by gibbs@overdrive on 2001/01/28 15:49:09
-
-	aic7770_osm.c:
-		Convert to "aic7xxx_osm.h".
-	
-		On newer kernels, check the return of request_region.
-	
-	aic7xxx_osm.c:
-		Cleanup comment blocks for consistent style.
-	
-		Convert to "aic7xxx_osm.h".
-	
-		Add support for attachment of devices found after
-		the initial probe during "aic7xxx_detect".  We do
-		this by setting a global, aic7xxx_detect_complete,
-		which tells the pci probe code to do its own registration
-		call if initial detection has already occurred.  This way,
-		we maintain the "sane ordering" of devices that the
-		old driver had for statically configured devices.
-	
-		Split out the host registration code into its own function
-		so that hot-plug devices can call this code after
-		aic7xxx_detect has already completed.
-	
-		Use request/release_mem_region on 2.4.0 or higher kernels.
-	
-		Restore SCBPTR after setting up an abort for a
-		disconnected SCB.  The sequencer will become confused
-		if this is not done.
-	
-		Always look for the SCB that timedout first and result to
-		a more generic search only if that fails.  The timedout SCB
-		is more likely to be the one on the bus.
-	
-		Don't bother to drop and reaquire our mutex at the tail
-		of the recovery handler unless we are going to sleep.
-	
-	aic7xxx_osm.h:
-		Comment cleanup.
-	
-		Export our SCSI host template so the hot-plug PCI stuff
-		can use it.
-	
-		Bump revision to 6.1.0... our first release.
-	
-	aic7xxx_osm_pci.c:
-		Add support for new PCI probe mechanism in 2.4.0 while
-		maintaining compatibility with older kernels.
-	
-	aic7xxx_proc.c:
-		Fix several bugs in Gerard's proc code.  We would never
-		properly deal with reads at offsets other than 0.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7770_osm.c#5 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#50 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#39 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#13 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#6 edit
-
-Change 132 by gibbs@overdrive on 2001/01/28 15:32:59
-
-	aic7770.c:
-	aic7xxx.c:
-	aic7xxx_93cx6.c:
-		Convert to "aic7xxx_osm.h" setup rather than ifdef hell.
-	
-	aic7xxx_pci.c:
-		Document the layout of the DEVID for cards with the 9005
-		Adaptec vendor ID.  Use a more generic mask for the generic
-		9005 product tests.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#6 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#27 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#7 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#14 edit
-
-Change 131 by gibbs@overdrive on 2001/01/23 15:29:46
-
-	When flipping the first entry in the qinfifo with the
-	"next queued SCB", we must also inform the card of this
-	change.  Otherwise the sequencer will traverse a corrupt
-	list of SCBS.  The side effects of this problem were unknown
-	SCBs completing in the qoutfifo or worse yet, panics due
-	to sequencer interrupts that referenced what, to the kernel,
-	were invalid SCB ids.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#26 edit
-
-Change 130 by gibbs@overdrive on 2001/01/22 17:44:12
-
-	Update copyrights.
-	
-	aic7xxx.seq:
-		Handle busfree early in selection correctly.  We
-		must clear ENSELO so that we will make future attempts
-		at selection.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#5 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#25 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#18 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#11 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#17 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#6 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#15 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#13 edit
-
-Change 129 by gibbs@overdrive on 2001/01/22 17:03:07
-
-	Bump revision level.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#38 edit
-
-Change 128 by gibbs@overdrive on 2001/01/19 16:09:10
-
-	Bump version number.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#37 edit
-
-Change 127 by gibbs@overdrive on 2001/01/19 15:57:40
-
-	It's Adaptec Inc., not just Adaptec.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_host.h#2 edit
-
-Change 126 by gibbs@overdrive on 2001/01/19 15:57:16
-
-	Correct a typo.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7770_osm.c#4 edit
-
-Change 125 by gibbs@overdrive on 2001/01/19 10:35:11
-
-	aic7xxx.c:
-		Remove aic7895 stack corruption work-around.
-		This seems to only apply if you are mucking
-		with the stack register to effect a "long-jump".
-		We don't do this and don't plan to either.
-	
-		Add additional diagnostic output for when things
-		go wrong.
-	
-		AHC_SCB_BTT is set in the flags area of the softc,
-		not features.
-	
-		Don't loop forever if the INTSTAT register gets
-		locked up when flushing work.  This can happen if
-		we are a removable device (register goes away) or
-		the card dies.
-	
-	aic7xxx.h:
-		Add a removable feature designation to ahc_features.
-		This is currently only used for the apa1480 and the 29160C.
-	
-	aic7xxx.reg:
-		Don't use the sequencer intcode 0xF0.  It makes it possible
-		for the kernel to see INTSTAT as 0xFF and believe a hot-eject
-		has occurred.
-	
-		Align the busy target table on a 16byte boundary.  This
-		appears to correct a sequencer execution issue for the
-		7895.
-	
-	aic7xxx.seq:
-		Don't bother performing a "diagnostic" sequencer interupt
-		should an abort collision occur.
-	
-		Have the bus-free after selection code apply to
-		reselections too.
-	
-		Always follow the clearing of SELDI with a jmp instruction.
-		This corrects a sequencer execution issue on the 7895.
-	
-		In the target mode command loop, don't bother re-enabling
-		SPIOEN for each byte.  It only needs to be enabled once.
-	
-		Fix AHC_SCB_BTT tests to test the correct field in the softc.
-	
-		Correctly clean up resources should an incoming reselection
-		reference a transaction we don't believe is pending.  Add
-		some additional sequencer diagnostics for the SCB_BTT case
-		too.
-	
-	aic7xxx_inline.h:
-		Fix AHC_SCB_BTT tests to test the correct field in the softc.
-	
-		Only believe a hot eject to have occurred if the device
-		is removable.
-	
-	aic7xxx_pci.c:
-		Set the removable feature for the apa1480 and 29160C.
-	
-		Don't print information about high byte termination on
-		narrow adapters.
-	
-		Use a pci bus read instead of a questionable read for
-		safety when manipulating external termination logic.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#24 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#17 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#10 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#16 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#14 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#12 edit
-
-Change 124 by gibbs@overdrive on 2001/01/15 05:12:30
-
-	aic7770_osm.c:
-		Whitespace cleanup.
-	
-		Don't reference a NULL pointer.
-	
-	aic7xxx_osm.c:
-		Honor kernel configuration settings for bus
-		settle delay and max tagged commands.
-	
-		Correct accuracy of tagged command setup comments.
-	
-		Limit linux to 253 total commands due to command
-		complete FIFO cleanup restrictions.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7770_osm.c#3 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#49 edit
-
-Change 123 by gibbs@overdrive on 2001/01/12 09:08:27
-
-	aic7770.c:
-		Add softcs for new EISA instances into the global list
-		of aic7xxx controllers as they are found.  Leaving the
-		softcs out of the list prevented these controller instances
-		from being attached.
-	
-	aic7xxx.c:
-		Remove code that corrected for a state that cannot occur.
-		The sequencer now increments its position in the qinfifo
-		only once it has successfully DMAed the SCB from that queue
-		position down to the controller.  In the past the sequencer
-		incremented before attempting the DMA.
-	
-		To ensure that the sequencer always notices an abort
-		collision, swap the first entry in the qinfifo with
-		the held, next to dma, hscb only after we have completed
-		our pass through the array.  In the past, we did this
-		before clearing out the queue, and this did not provide
-		the same guarantee since the queue could be cleared leaving
-		the next pointer to be the same as it was originally.
-	
-		Print out the next queued SCB as seen by both the kernel
-		and the sequencer in ahc_dump_card_state().
-	
-	aic7xxx.h:
-		Introduce a new constant, AHC_MAX_QUEUE.  This is now set
-		to 253 to make sure that our 32bit writes to clear the
-		qoutfifo can never clobber a valid entry in the queue.
-		All OSMs should use this new define to throttle their
-		controller wide queue depth.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#4 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#23 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#16 edit
-
-Change 122 by gibbs@overdrive on 2001/01/08 11:32:55
-
-	Kill old insqueue interface.  It will not be used by the
-	aic7xxx driver.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/queue.h#4 edit
-
-Change 121 by gibbs@overdrive on 2001/01/08 11:30:36
-
-	Reduce the university's copyright per Kirk.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/queue.h#3 edit
-
-Change 120 by gibbs@overdrive on 2001/01/08 11:27:30
-
-	Bump version number for next release.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#36 edit
-
-Change 119 by gibbs@overdrive on 2001/01/08 11:20:17
-
-	Turn on ID expansion.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#3 edit
-
-Change 118 by gibbs@overdrive on 2001/01/08 08:10:19
-
-	aic7xxx_osm.c:
-		Honor selection timeout settings set by the user.
-	
-		Style cleanup of initial setup routine.
-	
-		Use sense buffer access inlines.
-	
-		Check for critical underflow only if there are no
-		other errors reported at the time the command is ahc_done()'d.
-		In the past, we might have marked the command as critically
-		failed before retrieving sense.  Sense data should take
-		priority.
-	
-	aic7xxx_osm.h:
-		Second part of underflow cleanup.  Just store the residual
-		in ahc_set_residual().  Leave policy decision to ahc_done().
-	
-	aic7xxx_proc.c:
-		Add per-device statistics to proc output.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#48 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#35 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#5 edit
-
-Change 117 by gibbs@overdrive on 2001/01/08 08:03:54
-
-	aic7xxx.c:
-		Use inline accessors to get to the sense buffer associated
-		with a particular auto-sense transaction.  This buffer is
-		now indexed by scb offset, not hscb offset, so any qinfifo
-		manipulations will not effect the buffer referenced.
-	
-		Honor the selection timeout setting in ahc_softc.  The
-		OSM is responsible for setting this to any non-default
-		value.
-	
-		Modify our suspend and resume routines to take into account
-		twin channel adapters.
-	
-	aic7xxx.h:
-		Add fields for twin channel suspend state storage and
-		selection timeout timer to ahc_softc.
-	
-	aic7xxx_inline.h:
-		Inline accessors for sense buffer bus address and buffer.
-	
-	aic7xxx_pci.c:
-		Correct subdevice id data extraction routines to work
-		correctly on motherboard devices.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#22 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#15 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#13 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#11 edit
-
-Change 116 by gibbs@overdrive on 2000/12/21 09:22:20
-
-	Makefile:
-		Generate module in SCSI directory so it can be
-		named just like its predecessor.
-	
-	aic7xxx_osm.c:
-		Fix semaphore declarations for newer kernels.
-	
-		Use new ahc_* byte order functions.
-	
-		Cleanup some unused code.
-	
-		Implement platform_flush_work.
-	
-	aic7xxx_osm.hosts.h:
-		Split out our host template definition so we don't
-		muck up the namespace when our template is included
-		in hosts.c
-	
-	aic7xxx_inline.h:
-		Define ahc_endian functions.
-	
-		Bump version number.
-	
-	aic7xxx_proc.c:
-		First stab at /proc support.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/Makefile#7 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_host.h#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#47 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#34 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#4 edit
-
-Change 115 by gibbs@overdrive on 2000/12/21 08:59:37
-
-	Add untested support for big endian machines.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#21 edit
-
-Change 114 by gibbs@overdrive on 2000/12/13 08:00:07
-
-	Bring in the optimized interrupts handler.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#12 edit
-
-Change 113 by gibbs@overdrive on 2000/12/13 07:57:15
-
-	aic7xxx_osm.c:
-		Use a semaphore and a timer to cause our exception
-		handler to sleep while recovery actions are in progress.
-	
-		Mark the correct recovery type in the SCB instead of
-		always marking DEVICE_RESET.
-	
-	aic7xxx_osm.h:
-		We are now at 6.0.6 BETA.
-	
-		Use a simple "do/while" construct to serve as a
-		memory barier on ia32.  lock instructions are
-		expensive and all we need is something to prevent
-		the compiler from reordering our store order.
-	
-	aic7xxx_pci.c:
-		Turn off either I/O or Mem access depending on which
-		mapping type is not in use.  This prevents our EISA
-		probe from kicking one of our cards.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#46 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#33 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#12 edit
-
-Change 112 by gibbs@overdrive on 2000/12/13 07:39:03
-
-	Complete preliminary resume support.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#20 edit
-
-Change 111 by gibbs@overdrive on 2000/12/12 12:09:54
-
-	aic7xxx.c:
-		During initialization, be sure to initialize all scratch
-		ram locations before they are read to avoid parity errors.
-		In this case, we use a new function, ahc_unbusy_tcl() to
-		initialize the scratch ram busy target table.
-	
-		Replace instances of ahc_index_busy_tcl() used to unbusy
-		a tcl without looking at the old value with ahc_unbusy_tcl().
-	
-		Modify ahc_sent_msg so that it can find single byte messages.
-		ahc_sent_msg is now used to determine if a transfer negotiation
-		attempt resulted in a bus free.
-	
-		Be more careful in filtering out only the SCSI interrupts
-		of interest in ahc_handle_scsiint.
-	
-		Rearrange interrupt clearing code to ensure that at least
-		one PCI transaction occurrs after hitting CLRSINT1 and
-		writting to CLRINT.  CLRSINT1 writes take a bit to
-		take effect, and the re-arrangement provides sufficient
-		delay to ensure the write to CLRINT is effective.
-	
-		export ahc-update_target_msg_request for use by OSM code.
-	
-		If a target does not respond to our ATN request, clear
-		it once we move to a non-message phase.  This avoids
-		sending a MSG_NOOP in some later message out phase.
-	
-		Use max lun and max target constants instead of
-		hard-coded values.
-	
-		Use softc storage built into our device_t under FreeBSD.
-	
-		Fix a bug in ahc_free() that caused us to delete
-		resources that were not allocated.
-	
-		Clean up any tstate/lstate info in ahc_free().
-	
-		Clear the powerdown state in ahc_reset() so that
-		registers can be accessed.
-	
-		Add a preliminary function for pausing the chip and
-		processing any posted work.
-	
-		Add a preliminary suspend and resume functions.
-	
-	aic7xxx.h:
-		Limit the number of supported luns to 64.  We don't
-		support information unit transfers, so this is the
-		maximum that makes sense for these chips.
-	
-		Add a new flag AHC_ALL_INTERRUPTS that forces the
-		processing of all interrupt state in a single invokation
-		of ahc_intr().  When the flag is not set, we use the
-		lazy interrupt handling scheme.
-	
-		Add data structures to store controller state while
-		we are suspended.
-	
-		Use constants instead of hard coded values where appropriate.
-	
-		Correct some harmless "unsigned/signed" conflicts.
-	
-	aic7xxx.seq:
-		Only perform the SCSIBUSL fix on ULTRA2 or newer controllers.
-		Older controllers seem to be confused by this.
-	
-		In target mode, ignore PHASEMIS during data phases.
-		This bit seems to be flakey on U160 controllers acting
-		in target mode.
-	
-	aic7xxx_pci.c:
-		Add support for the 29160C CPCI adapter.
-	
-		Add definitions for subvendor ID information
-		available for devices with the "9005" vendor id.
-		We currently use this information to determine
-		if a multi-function device doesn't have the second
-		channel hooked up on a board.
-	
-		Add rudimentary power mode code so we can put the
-		controller into the D0 state.
-	
-		Only capture "left over BIOS state" if the POWRDN
-		setting is not set in HCNTRL.
-	
-		In target mode, don't bother sending incremental
-		CRC data.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#19 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#14 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#15 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#10 edit
-
-Change 110 by gibbs@overdrive on 2000/12/01 09:43:59
-
-	When bus resets are disabled, call update_target_msgreq after
-	setting initial transfer settings so that negotiation takes place
-	on the first command to the target.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#45 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#32 edit
-
-Change 109 by gibbs@overdrive on 2000/11/10 09:37:15
-
-	Add IOMODE support.
-	
-	Remove recurring interrupts during scsi bus resets by
-	disabling scsi bus reset notifications until we start
-	sending or receiving transactions again.
-	
-	Issue a missed busfree sequencer interrupt instead of
-	overloading bad phase.  The code was getting confused
-	before because last phase was not set in all cases
-	to distinguish the two cases.
-	
-	Don't assume the SCB tag is valid unless SEEN_IDENTIFY
-	is set in SEQ_FLAGS during timeout handling.
-	
-	Add critical sections to protect the sequencer from list
-	corruption during timeout handling.
-	
-	Sync with FreeBSD IDs.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#18 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#13 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#9 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#14 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#5 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#5 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#11 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#9 edit
-
-Change 108 by gibbs@overdrive on 2000/11/10 09:33:33
-
-	Bump version for next release.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#31 edit
-
-Change 107 by gibbs@overdrive on 2000/11/06 09:36:35
-
-	The core driver takes care to clean up any doubly queued SCBs
-	now, so don't call ahc_search_qinfifo from ahc_done().
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#44 edit
-
-Change 106 by gibbs@overdrive on 2000/11/06 09:35:50
-
-	Fix 8bit math errors when tweaking the qinfifo.
-	
-	Don't allow ahc_search_qinfifo to be called recursively.
-	
-	Use a subroutine to make sure we don't coast into any
-	important sequencer instructions when issuing a pausing
-	interrupt.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#17 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#8 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#13 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#10 edit
-
-Change 105 by gibbs@overdrive on 2000/11/01 12:01:08
-
-	Linux EISA support, support for 2.4.X kernels, and updates to
-	match changes in the core aic7xxx code.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/Makefile#6 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7770_osm.c#2 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#43 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#30 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#11 edit
-
-Change 104 by gibbs@overdrive on 2000/11/01 11:59:42
-
-	Too many changes to mention.  Lots of bug fixes.  Filtering of
-	incoming transfer negotiation messages based on user settings,
-	bmov instruction for all moves, additional debugging code, etc.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#2 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#16 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#12 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#7 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#12 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#9 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#8 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#6 edit
-
-Change 103 by gibbs@overdrive on 2000/10/13 10:01:42
-
-	aic7xxx.c:
-		Limit our sync period correctly based on tinfo data.
-		We now send a period of 0 if we want async.
-	
-		Fix problem with DMA'ed CDBs.  The pointer to the
-		physical cdb was not being setup properly during
-		the HSCB swap.  We now compute this value in
-		ahc_setup_scb().
-	
-	aic7xxx.seq:
-		Make sure that DFON stays on in SXFRCTL0.
-	
-		Fix DMA'ed cdbs for adapters without a command channel.
-		The length in HCNT was not properly set.
-	
-		Clear STCNT on U2 controllers when we exit command
-		phase.  This is an attempt to clear the preload circuit.
-		It is not yet clear that this works.
-	
-	aic7xxx_inline.h:
-		Copy the whole 64 bytes of the hscb when queuing it.
-		If we need to recalculate the cdb physical pointer for
-		a large cdb, do so at this time as well.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#15 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#11 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#11 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#8 edit
-
-Change 102 by gibbs@overdrive on 2000/10/12 11:12:41
-
-	Make the no_reset option work and also honor the seeprom/nvram
-	reset options at boot time.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#42 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#29 edit
-
-Change 101 by gibbs@overdrive on 2000/10/12 10:00:34
-
-	Update for changes in aic7xxx core files: UNTAGGED_Q flag,
-	ahc_validate*() now take a tinfo.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#41 edit
-
-Change 100 by gibbs@overdrive on 2000/10/12 09:59:11
-
-	Limit transfer settings to that of our goal at all times.  This
-	ensures that a target initiated sync/wide negotiation never goes
-	above the limits specified by the user.
-	
-	When switching to non-tagged queuing, be sure to set the
-	SCB_UNTAGGEDQ flag when inserting the SCB onto the untagged q.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#14 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#10 edit
-
-Change 99 by gibbs@overdrive on 2000/10/09 11:21:46
-
-	Remove AIC7XXX_STRICT_PCI_SETUP.  We don't currently honor it
-	and don't have a reason to honor it in the future.
-	
-	Handle temporary resource shortages such as an attempt to allocate
-	additional SCBs failing.
-	
-	Complete the first pass at Linux error recovery code.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#40 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#28 edit
-
-Change 98 by gibbs@overdrive on 2000/10/09 11:17:46
-
-	Export ahc_match_scb() to OSMs.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#13 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#9 edit
-
-Change 97 by gibbs@overdrive on 2000/10/09 07:49:38
-
-	aic7xxx.c:
-		export ahc_qinfifo_requeue and a new routine
-		ahc_qinfifo_count for use by OSM error recovery
-		routines.
-	
-		Resync the tqinfifo position during every restart of
-		the sequencer.  In the past, we would do this only
-		for bus resets but there are other situations where
-		restarting the sequencer might cause a discrepency.
-	
-		Print the scb's path information before running an
-		abort command that will include that scb.  There is
-		no guarantee that the path information will be valid
-		after an SCB is freed.
-	
-		In ahc_clear_critical_sections(), disable all SCSIINT
-		interrupt sources and clear SCSIINT.  SCSIINT is a pausing
-		interrupt and the sequencer will not step if it is paused
-		by an interrupt condition.  Any SCSIINT sourc that is
-		active prior to or becomes active during the stepping 
-		process will cause SCSIINT to be re-asserted when we
-		re-enable these interrupt sources at the tail of
-		ahc_clear_critical_sections().
-	
-		Send the correct async notifications for BDR and bus reset.
-	
-		Fix an error in ahc_search_qinfifo() that would update
-		QINFIFO at the wrong time.
-	
-		In ahc_loadseq, properly calculate the critical section
-		regions for the current firmware load.  The old code was
-		confused if a critical sections boundary occurred on
-		an instruction not downloaded to the chip.
-	
-	aic7xxx.h:
-		Remove an unused SCB_FLAG.
-	
-		Export ahc_qinfifo_requeue() and ahc_qinfifo_count().
-	
-	aic7xxx.seq:
-		The MK_MESSAGE flag is cleared by the kernel.  Don't
-		bother duplicating that effort in the sequencer.
-	
-	aic7xxx_pci.c:
-		7880's prior to rev B have the MWI boundary bug.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#12 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#8 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#10 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#7 edit
-
-Change 96 by gibbs@overdrive on 2000/10/06 06:40:57
-
-	Convert to keeping a queue of Scsi_Cmnd structures instead of SCBs.
-	This will allow us to queue domain validation and other requests
-	internally to the driver without fear of an SCB shortage related
-	deadlock.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#39 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#27 edit
-
-Change 95 by gibbs@overdrive on 2000/10/06 06:39:42
-
-	Simplify ahc_update_pending_syncrates().
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#11 edit
-
-Change 94 by gibbs@overdrive on 2000/10/06 06:19:23
-
-	Update FreeBSD ids.
-	
-	Move verbose logging of negotiation into the *construct* methods
-	so that logging occurs in all cases.
-	
-	Correct ahc_search_qinfifo to properly deal with an SCB out of
-	the qinfifo but mid-dma in the SEARCH_REMOVE case.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#10 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#7 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#6 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#9 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#4 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#4 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#7 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#6 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#6 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.h#4 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#5 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_insformat.h#4 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#4 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#4 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#4 edit
-
-Change 93 by gibbs@overdrive on 2000/10/03 11:11:11
-
-	Fix non-module build on 2.2.14.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#38 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#26 edit
-
-Change 92 by gibbs@overdrive on 2000/10/03 11:10:45
-
-	aic7xxx.c:
-		panic with a reasonable message if we do not have a valid
-		SCB when handling a HOST_MSG_LOOP event.
-	
-		Clear any critical sections when a bus reset or any unexpected
-		SCSI event occurs.
-	
-		Fix an off by one in testing whether we are inside a
-		critical section.
-	
-		Set the step bit in the correct register.
-	
-		Also check whether the PPR options have changed when
-		deciding to update our syncrate.
-	
-		Add some bootverbose logging about transfer negotiations.
-	
-		If we are going to reject a PPR, explicitly set all options
-		to async/narrow.  It may be that only one of the many options
-		was filtered to an unacceptable value.
-	
-		Have the ahc_search_qinfifo routing properly handle the
-		case where an SCB has left the qinfifo but has not yet
-		been added to the waiting list.
-	
-	aic7xxx.seq:
-		Correct critical sections for input queue handling.
-	
-		Fix a bug in input queue handling that caused us to
-		smash the next scb to download value as we were putting
-		the new SCB onto the waiting list.
-	
-		If the qinfifo changes to not include the just DMAed
-		SCB, throw it away... it has been aborted by the kernel.
-	
-	aic7xxx_inline.h:
-		Simplify a statement.  No fucntional change.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#9 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#8 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#6 edit
-
-Change 91 by gibbs@overdrive on 2000/09/28 10:59:15
-
-	Limit prefetch to a PCI cacheline amount instead of pulling
-	a full (and expensive) 128 bytes.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#8 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#5 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#7 edit
-
-Change 90 by gibbs@overdrive on 2000/09/28 10:31:17
-
-	Make sure we tell the OS that we can only take 254 or
-	AHC_SCB_MAX - 1 requests at a time due to the new QINFIFO
-	scheme.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#37 edit
-
-Change 89 by gibbs@overdrive on 2000/09/28 10:30:48
-
-	Correct ahc_search_qinfifo by reading and resetting the
-	SNSCB_QOFF register.  A read of this register increments it,
-	requiring the reset.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#7 edit
-
-Change 88 by gibbs@overdrive on 2000/09/28 09:24:14
-
-	Use an array of scb pointers to map from HSCB tag to
-	SCB.
-	
-	Take a first shot at correcting ahc_search_qinfifo for the
-	new qinfifo mechanism.  We don't currently handle the case
-	of an SCB in transit to the card after it has been removed
-	from the QINFIFO.
-	
-	There still appears to be a problem with the QINFIFO handling
-	that I have yet to address.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#6 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#6 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#6 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#5 edit
-
-Change 87 by gibbs@overdrive on 2000/09/27 09:03:56
-
-	Put the Linux aic7770 support into its final location.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7770_osm.c#1 branch
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_eisa.c#3 delete
-
-Change 86 by gibbs@overdrive on 2000/09/27 09:03:16
-
-	Implement new, single DMA, strategy for getting commands to
-	the controller.
-	
-	Still need to implement qinfifo cleanup routine.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#5 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#5 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#4 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#5 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#4 edit
-
-Change 85 by gibbs@overdrive on 2000/09/27 09:02:01
-
-	Clean up code formating so extraineous commas are not
-	generated.
-	
-	Output a constant indicating the size of the critical
-	section table.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#5 edit
-
-Change 84 by gibbs@overdrive on 2000/09/27 08:58:38
-
-	Switch to only allowing 254 commands outstanding in preparation
-	for new input queue handling.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#36 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#25 edit
-
-Change 83 by gibbs@overdrive on 2000/09/25 08:40:23
-
-	aic7xxx_osm.c:
-		Correct a KERNEL_VERSION test.
-	
-		Reset the bus only after we've finished setting
-		up the controller fully.
-	
-		Update for new ahc_send_async() API.
-	
-		Only attempt to report bus resets if the kernel
-		we're building for supports it.
-	
-	aic7xxx_osm.h:
-		Bump driver version in preparation for next release.
-	
-		Fix compilation on older kernels.  The Scsi_Cmnd is now
-		available through the scb->io_ctx.
-	
-		Update for new ahc_send_async() API.
-	
-	aic7xxx_osm_pci.c:
-		Correctly handle the I/O mapped case.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#35 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#24 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#10 edit
-
-Change 82 by gibbs@overdrive on 2000/09/25 08:35:25
-
-	Rely on CACHETHEN bug entries to limit its use.  Otherwise,
-	default to turning it on.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#5 edit
-
-Change 81 by gibbs@overdrive on 2000/09/22 07:55:30
-
-	aic7xxx.c:
-		Clear scsi interrupts via the CLRINT register if we
-		see a spurios SCSI interrupt.
-	
-		Modify the ahc_send_async interface so that the client
-		can directly specify which devices (through the use of
-		wildcards) are affected.
-	
-		When sending a PPR message we need to filter the syncrate
-		we attempt to negotiate with the target just as when using
-		the older SDTR message.  Combine these two cases so we can
-		share the code that does this.
-	
-		Correct a panic message.
-	
-		Handle a MSG_MESSAGE_REJ for a PPR request.  Simplify the
-		ahc_handle_msg_reject routine by calling
-		ahc_build_transfer_msg in cases where further negotiation
-		is required rather than doing this manually.
-	
-		In ahc_controller_info(), don't bother updating len and
-		buf for the last sprintf since no-one will look at them
-		again.
-	
-	aic7xxx.h:
-		Increase the size of both msgout_buf and msgin_buf[].
-		The PPR message is 8 bytes in length and we might
-		(on some platforms) combine the PPR with inquiry and
-		tag data.  We now allocate 12 bytes in each.
-	
-	aic7xxx.seq:
-		Use quoted includes in the sequencer file and make up
-		for the lack of path information in some OS dependent
-		manner (sys/conf/files for FreeBSD, placement of files
-		in Linux).  The assembler doesn't understand #ifdef
-		directives and this allows the files to be completely
-		shared between platforms.
-	
-		Remove an unnecessary nop instruction.
-	
-	aic7xxx_pci.c:
-		In ahc_pci_intr(), look at the error register to
-		determine whether a PCI error has occurred before
-		rushing into a configuration cycle to read the error.
-		Configuration cycles are more expensive than a single
-		memory read transaction and we may end up thinking
-		we have a PCI interrupt waiting just because we share
-		an IRQ with other devices.
-	
-		unpause the sequencer after clearing any PCI status.
-		For some errors (such as received Master Abort), the
-		error had nothing to do with this controller, but the
-		chip was automatically paused.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#4 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#4 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#4 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#4 edit
-
-Change 80 by gibbs@overdrive on 2000/09/19 09:20:44
-
-	Add ahc_send_async() for Linux and have it report bus resets.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#34 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#23 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/cam.h#9 edit
-
-Change 79 by gibbs@overdrive on 2000/09/19 09:06:42
-
-	include inttypes.h.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#4 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#4 edit
-
-Change 78 by gibbs@overdrive on 2000/09/19 08:43:13
-
-	Bring back the Linux Makefile for the assembler.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/Makefile#4 add
-
-Change 77 by gibbs@overdrive on 2000/09/19 08:15:07
-
-	Bring in latest FreeBSD port changes.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7770.c#1 add
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#3 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#3 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#3 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#3 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#3 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#3 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#3 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#3 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#3 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.h#3 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#3 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_insformat.h#3 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#3 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#3 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#3 edit
-
-Change 76 by gibbs@overdrive on 2000/09/19 07:24:37
-
-	Make sure these all have RCS ID expansion enabled.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#2 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#2 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#2 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#2 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#2 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#2 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#2 edit
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#2 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#2 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.h#2 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#2 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_insformat.h#2 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#2 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#2 edit
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#2 edit
-
-Change 75 by gibbs@overdrive on 2000/09/19 07:21:44
-
-	Move core files to core location in the repository.
-
-Affected files ...
-
-... //depot/aic7xxx/aic7xxx/aic7xxx.c#1 branch
-... //depot/aic7xxx/aic7xxx/aic7xxx.h#1 branch
-... //depot/aic7xxx/aic7xxx/aic7xxx.reg#1 branch
-... //depot/aic7xxx/aic7xxx/aic7xxx.seq#1 branch
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#1 branch
-... //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#1 branch
-... //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#1 branch
-... //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#1 branch
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#1 branch
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm.h#1 branch
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#1 branch
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_insformat.h#1 branch
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#1 branch
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#1 branch
-... //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#1 branch
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.c#25 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.h#12 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.reg#5 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.seq#12 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_93cx6.c#4 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_93cx6.h#3 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_eisa.c#3 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_inline.h#10 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_pci.c#7 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/Makefile#3 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/aicasm.c#5 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/aicasm.h#4 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/aicasm_gram.y#7 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h#2 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/aicasm_scan.l#5 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.c#3 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.h#4 delete
-
-Change 74 by gibbs@overdrive on 2000/09/12 11:57:59
-
-	Cleanup and changes to support FreeBSD
-	
-	aic7xxx.c:
-		FreeBSD includes.  FreeBSD uses -nostdinc so
-		we must explicitly state the path to any referenced
-		files.
-	
-		staticize
-	
-		Inline ahc_intr().  It is only referenced once by
-		the OSM.
-	
-		Call ahc_notify_xfer_settings_change() in all locations
-		where settings change.
-	
-		Simplify ahc_platform_set_tags.  Don't bother calling
-		it if the tags setting has not changed.
-	
-		Don't leak ahc->name() in ahc_free().
-	
-		Add functions used only for target mode.
-	
-		pci_softc -> dev_softc.
-	
-		Move FreeBSD specific calls into aic7xxx_freebsd.c.
-	
-		Add marker to cleanup tstate info in ahc_free().
-	
-		Bring back SEARCH_REMOVE to ahc_search_qinfifo().
-		The FreeBSD error recovery code uses it.
-	
-	aic7xxx.h:
-		Add the io_ctx field into the scb.  This represents a
-		pointer to the ccb or Scsi_Cmnd or whatever a platform
-		uses to keep track of the OSes io context.  This is
-		faster and simpler than rooting around in the scb_platform
-		data object.
-	
-		Bring back in more target mode stuff.
-	
-		ahc_pci_softc_t -> ahc_dev_softc_t.
-	
-		inline ahc_intr.
-	
-		export functions referenced by FreeBSD's error recovery code.
-	
-	aic7xxx_93cx6.c:
-		FreeBSD inludes.
-	
-	aic7xxx_inline.h:
-		Inline ahc_intr.
-	
-	aic7xxx_osm.c:
-		Cleanup unused and #if 0'd code.
-	
-		platform_data->cmd -> io_ctx.
-	
-		ahc->pci_softc -> ahc->dev_softc.
-	
-		Cleanup unused (or should have been unused) fields
-		in ahc_platform_softc.
-	
-		ahc_platform_set_tags() simplification.  Changed argument
-		goes away and the function is only called when the
-		tags setting changes.
-	
-	aic7xxx_osm.h:
-		Cleanup unused and #if 0'd code.
-	
-		Add ahc_insb() for use by ahc_dump_seq().
-	
-		pci_softc -> dev_softc.
-	
-		platform_data->cmd -> io_ctx.
-	
-	aic7xxx_osm_pci.c:
-		pci_softc -> dev_softc.
-	
-	aic7xxx_pci.c:
-		FreeBSD includes
-	
-		pci_softc -> dev_softc.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.c#24 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.h#11 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_93cx6.c#3 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_inline.h#9 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#33 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#22 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#9 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_pci.c#6 edit
-
-Change 72 by gibbs@overdrive on 2000/09/07 10:47:56
-
-	aic7xxx.c:
-		TAILQ_FOREACH is not safe to use when the list you
-		are traversing is modified in the body of the loop.
-		Manually traverse the list instead.
-	
-	aic7xxx_osm.h:
-	aic7xxx_osm.c:
-		Avoid re-entry issues during abort processing by
-		deferring the run of any device queues until after
-		ahc_intr() has completed.  Just as in the case of
-		running the complete queue, the device queues will
-		need to be run from any abort processing performed
-		outside the interrupt handler as well.
-	
-		Bump our version number in preparation for another release.
-	
-	cam.h:
-		Make get and set transaction status work the same way as
-		in FreeBSD.  Notably, mask with CAM_STATUS_MASK.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.c#23 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#32 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#21 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/cam.h#8 edit
-
-Change 68 by gibbs@overdrive on 2000/09/06 10:25:15
-
-	aic7xxx.c:
-		Start the port back to FreeBSD....
-			o Include FreeBSD header on FreeBSD
-	
-			o ahc_freeze_ccb -> ahc_freeze_scb() and unifdef.
-	
-			o Change XXX to __FreeBSD__ on sections of code
-			  we still need additional special accessors for.
-	
-			o Bring in the rest of the target mode code.
-	
-		Move the pci_softc from platform_data into its own
-		field in ahc_softc.  This makes it less cumbersome
-		to perform PCI operations.		
-	
-		Add a routine, ahc_dump_card_state,  that dumps the
-		state of all of our queues.  This can be called when
-		something unexpected occurs to aid in debugging problems.
-		It is currently only called when we see an inactive
-		SCB come through ahc_done().
-	
-	aic7xxx.h:
-		struct ahc_pci_softc -> ahc_pci_softc_t.
-		On both Linux and FreeBSD, the pci_softc need only
-		be a pointer to the platform provided PCI instance
-		object, so we let the OSM define this type to be
-		whatever is convenient.
-	
-		Add bug definition for SCB corruption on upload
-		with aic7899s on 66MHz PCI.
-	
-		Use bus space tag/handle pair for accessing the
-		card on all platforms.  This removes an extra
-		pointer dereference and matches what FreeBSD
-		has been doing for some time.
-	
-		Move the platform_softc lower in the ahc_softc.
-		Since it no-longer includes the fields required
-		to access card registers, it is accessed less often
-		than the fields that now appear before it.
-	
-	aic7xxx.seq:
-		Implement a workaround for the 66MHz PCI SCB upload
-		corruption problem.  By transferring first from the
-		SCB into SCBRAM and then performing the DMA, we
-		avoid the corruption.
-	
-	aic7xxx_osm.c:
-		ahc_pci_softc_t fallout.
-	
-		bus space fallout.
-	
-		Implement the platform dependant portions of
-		ahc_dump_card_state().
-	
-		Fix a nasty bug in ahc_run_device_queue().  We
-		cannot send any SCB that does not have CAM_SIM_QUEUED
-		set to the card or it will get sent twice.  Once
-		by the queue run routine and again by aic7xxx_queue().
-	
-	aic7xxx_osm.h:
-		Implement bus space fields for PIO/MEMIO.
-	
-		struct ahc_pci_softc -> ahc_pci_softc_t
-	
-		Implement ahc_freeze_scb() which is a no-op on Linux.
-	
-	aic7xxx_osm_pci.c:
-		ahc_pci_softc_t fallout.
-	
-		bus space fallout.
-	
-	aic7xxx_pci.c:
-		ahc_pci_softc_t fallout.
-	
-	aicasm_symbol.c:
-		Pick up the correct db header on non-linux platforms.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.c#21 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.h#10 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.seq#11 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#31 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#20 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#8 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_pci.c#5 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.c#2 edit
-
-Change 64 by gibbs@overdrive on 2000/09/02 12:46:16
-
-	aic7xxx.c:
-		Add a chip name for the aic7895 Rev C.  We differentiate
-		between the C and all other revs, so it is best to report
-		explicitly to the user when we find this chip.
-	
-		Export ahc_print_scb();
-	
-		In restart_sequencer() do all of the things that the
-		sequencer used to do at startup.  This shaves quite
-		a few instructions and there is no reason to "optimize"
-		these steps as they happen very rarely.
-	
-		Add some useful TRACEPOINT code.
-	
-		Use SCB_BASE instead of SCB_CONTROL to reference the
-		start of SCB ram.  SCB_CONTROL is no longer the first
-		element in the SCB and this show why using a variable
-		location instead of a fixed constant is unwise.
-	
-		Explictily export controller information
-		(width, scsiid, number of SCBS, etc) via
-		ahc_controller_info() instead of spraying this
-		data out from all through ahc_init().  This
-		allows OSMs to display the data in any way
-		they see fit.
-	
-		Correct some SCB_BTT bugs.
-	
-		Size the downloaded constants table correctly.
-	
-	aic7xxx.h:
-		Give the aic7895C isn't own chip identifier.
-	
-		Note which controllers have the AUTOPAUSE feature.
-	
-		Add a bug entry for controllers that fail to handle
-		residual transfers after a PCI MWI transaction correctly.
-	
-		Move the status packet up to the top of the SCB in
-		preparation for shortening the number of bytes uploaded
-		during check condition and other errors.
-	
-		Store in our softc information about the pci cacheline size.
-	
-	aic7xxx.reg:
-		Move the SCB status packet up to the top of the SCB.
-	
-		Add a different download size for external SCB memory.
-		This appears to avoid a download corruption problem.
-	
-		Add the MWI_RESIDUAL field for the MWI sequencer workaround.
-	
-		Add a downloaded constants describing the PCI cachline size.
-	
-	aic7xxx.seq:
-		Move reset code into kernel space.
-	
-		Add MWI bug workaround.  Essentially we save off the
-		portion of the current S/G segment that goes beyond the
-		last cacheline and transfer this separately.
-	
-		Use SCB_BASE instead of SCB_CONTROL for referencing the
-		start of SCB space.
-	
-		Add a workaround for transferring an embedded CDB from
-		external scratch ram on the aic7895.  We must wait to
-		enable the DMA engine until after we have filled the
-		FIFO.
-	
-		Fix index_busy_target in the SCB_BTT case.
-	
-		Factor out some more code that is not needed when
-		we don't page SCBs.
-	
-		Replace explicit test against aic7895 in command channel
-		code with != ULTRA2.  This gives the same effect and
-		doesn't require us to also check to see if this is an aic7895C.
-	
-		If we have large external SCBs, download 48 bytes of
-		SCB instead of 32.  This appears to avoid an SCB
-		corruption problem.
-	
-		Solidify the PCI 2.1 retry problem on SCB dma operations
-		bug.  We now wait until we are sure the chip is hung
-		before touching the FIFO.  The old system seemed to
-		sometimes pull out data too soon or corrupt the
-		data.
-	
-	aic7xxx_inline.h:
-		Only explicitly pause the sequencer on command enqueue
-		operations if the chip does not have the auto-pause
-		feature or the queue registers feature.
-	
-	aic7xxx_osm.c:
-		Fix the number of trasactions we report as supporting
-		to the mid layer.  Also fix our max opening count.
-		It was possible to overrun the FIFOs if we were using
-		the SCB busy target table.
-	
-		Provide more controller information through aic7xxx_info()
-		via the ahc_controller_info() routine.
-	
-	aic7xxx_osm.h:
-		More "number of transactions" cleanups.
-	
-		Our per-device active and openings count must be
-		signed so we can properly reduce our opening count
-		when downgrading from tagged to untagged.
-	
-		Add a bit definition for the memory write and invalidate
-		enable PCI space bit.
-	
-		Provide more information to the user on underflow conditions.
-	
-	aic7xxx_pci.c:
-		Clean up the way that large SCBs are enabled.  This is
-		now only done in the ahc_probe_extscbs() routine.
-	
-		Fetch PCI cache line size information and put it in the
-		softc.
-	
-		Correct the seletion of large SCBs for Ultra2+ controllers
-		in the SCB config routine.
-	
-		If external SCBs are not present, run through the SCB
-		config routine with the default settings.  This avoids
-		having to put code to attain the defaults somewhere
-		else.
-	
-		Correct SCB_BTT feature enable logic.  We must have
-		external 64byte SCBs for this to work.
-	
-		If bootverbose, mention whether large SCBs are being
-		used.
-	
-		SCB_CONTROL->SCB_BASE.
-	
-		Output the Sequencer program address if we get a PCI
-		error.  Useful in debugging.
-	
-		Note which controllers require MWI workarounds.
-	
-		Differentiate even more between the aic7895 and aic7895C.
-		Add code to deal the the spurious DAC cycle problem,
-		but don't enable it just yet.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.c#20 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.h#9 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.reg#4 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.seq#7 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_inline.h#8 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#30 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#19 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_pci.c#4 edit
-
-Change 62 by gibbs@overdrive on 2000/08/29 05:51:37
-
-	Move to just a single driver version stored in aic7xxx_osm.h.
-	Cleanup information printed out at driver load time.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#29 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#18 edit
-
-Change 61 by gibbs@overdrive on 2000/08/29 05:46:33
-
-	aic7xxx.seq:
-		Be a little more careful in how we empty the FIFO
-		on PCI 2.1 compliant aic78XX chips.  After pulling
-		out 8 bytes, wait for the FIFO to get some data
-		before testing to see if we are hung.
-	
-	aic7xxx_osm.c:
-		Fix the abort collision case in the device queue by
-		setting CAM_SIM_QUEUED only once aic7xxx_queue() has
-		released ownership of the SCB.  The old code was somewhat
-		confused in how it flagged transactions as still being
-		owned by aic7xxx_queue().
-	
-		Revert ahc_queue_busy_scb() and instead implement a
-		roll_back function ahc_free_busy_scb().  This makes
-		it much clearer who is aborting which scbs and how.
-		This required implementing ahc_unmap_scb() for use
-		by both ahc_done() and ahc_free_busy_scb().
-	
-		Correct ahc_platform_abort_scbs to abort the correct
-		device.  It was not checking wide/twin controller
-		properties and also suffered from a cut 'n paste error
-		that corrupted how the luns to traverse were determined.
-	
-	aic7xxx_osm.h:
-		Only return the low byte of the transaction status to
-		the rest of the world, but allow the high byte to be
-		set.  This simplifies handling of the CAM_SIM_QUEUED
-		flag.
-	
-	cam.h:
-		Add the CAM_SIM_QUEUED flag.  This flag is only used
-		in the device busy queue and indicates that the transaction
-		in the queue is no longer being operated on by aic7xxx_queue().
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.seq#6 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#28 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#17 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/cam.h#7 edit
-
-Change 60 by gibbs@overdrive on 2000/08/24 12:12:57
-
-	Turn on ktext expansion for all files.
-	
-	Add $Id$ where appropriate.
-	
-	Add PCI 2.1 Retry bug workaround.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.c#19 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.h#8 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.seq#5 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_93cx6.c#2 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_93cx6.h#2 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_eisa.c#2 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_inline.h#7 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#27 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#16 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_eisa.c#2 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#7 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_pci.c#3 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#3 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/Makefile#2 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/aicasm_gram.y#4 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/aicasm_scan.l#2 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/cam.h#6 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/queue.h#2 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/scsi_message.h#3 edit
-
-Change 59 by gibbs@overdrive on 2000/08/22 08:26:27
-
-	Change the name of our controller to scsi%d once we know the host
-	number.  Until that time, use a bus specific name.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.c#18 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.h#7 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#26 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#6 edit
-
-Change 58 by gibbs@overdrive on 2000/08/22 07:29:04
-
-	Remove old, #ifdef'd out, abort/reset implementations.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#25 edit
-
-Change 57 by gibbs@overdrive on 2000/08/22 07:20:46
-
-	Remove debugging printfs.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#5 edit
-
-Change 56 by gibbs@overdrive on 2000/08/22 06:53:44
-
-	aic7xxx.c:
-		For no, leave all locking to OSM layer.
-	
-	aic7xxx_osm.c:
-		Correct Adaptec copyright.
-	
-		Conditionalize inclusion of linux/init.h
-	
-		Add proc_dir_entry for older kernels.
-	
-		Don't declare static, entry points that may be
-		called externally in a static kernel linkage
-		configuration.
-	
-		Fixup abort processing for entries in the dev
-		queue.  We first bring these transactions up
-		to a state where ahc_done() will work on them,
-		and then call ahc_done().  This ensures that
-		all mapped memory for the transaction, etc. is
-		released.
-	
-		Becareful not to overwrite the sense data buffer
-		in Scsi_Cmnd's.
-	
-		Guard against null host structures in aic7xxx_release.
-	
-	aic7xxx_osm.h:
-		Remove bogus status checking in ahc_set_transaction_status().
-	
-	aic7xxx_osm_pci.c:
-		Use pci_find_class() to enumerate PCI devices.  This should
-		work acceptably in all kernel versions we support.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.c#17 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#24 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#15 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#4 edit
-
-Change 54 by gibbs@overdrive on 2000/08/21 12:30:49
-
-	When aborting commands in our per-device queues, queue them
-	to the complete queue, thus avoiding the dead-lock of a direct
-	completion.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#23 edit
-
-Change 53 by gibbs@overdrive on 2000/08/21 09:50:38
-
-	Use DID_BUS_BUSY for CAM_REQUEUE_REQ.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#22 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/cam.h#5 edit
-
-Change 52 by gibbs@overdrive on 2000/08/21 09:37:53
-
-	Implement aic7xxx_biosparam, finish tagged queuing implementation,
-	and complete the port to 2.2.14.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#21 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#14 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#3 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/cam.h#4 edit
-
-Change 51 by gibbs@overdrive on 2000/08/12 10:40:14
-
-	aic7xxx.c:
-		Add a platform callback to notify the system when
-		tag settings change.  We use this to freeze the
-		device queue until all oustanding transaction complete
-		when the tag type changes.
-	
-	aic7xxx_osm.c:
-		Add support for releasing the queue when the active
-		count goes to 0 for a particular device.
-	
-		Implement ahc_platform_set_tags() which will freeze
-		the queue when tag types change.
-	
-		In ahc_filter_cmd(), enable tags if the device supports them.
-	
-	aic7xxx_osm.h:
-		Prototype for ahc_platform_set_tags().
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.c#16 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#20 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#13 edit
-
-Change 50 by gibbs@overdrive on 2000/08/12 10:10:26
-
-	Kill a diagnostic printf.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#19 edit
-
-Change 49 by gibbs@overdrive on 2000/08/12 10:06:51
-
-	Switch to queing SCBs not Linux scsi commands in our busy
-	queues.  This avoids a locking and latency issues when we
-	have to run the queues from interrupt context.
-	
-	Run the busyq at the end of ahc_done.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#18 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#12 edit
-
-Change 48 by gibbs@overdrive on 2000/08/12 09:25:34
-
-	aic7xxx.c:
-		Add a platform callbacks for aborting transactions
-		sitting in OSM queues.
-	
-	aic7xxx_inline.h:
-		Don't lock in ahc_get_scb.  Let the OSM do this
-		as it may need to lock other data structures (using
-		the same lock) around the time it aquires the SCB.
-	
-	aic7xxx_osm.c:
-		Implement Linux version of the transaction abort
-		callbacks.
-	
-		Modify ahc_get_device() to only allocate device
-		entries if asked.  This allows this routine to
-		be used to see if a device exists at that location.
-	
-		Modify aic7xxx_queue() so that incoming commands
-		are placed into the device busy queue and that
-		transactions are only run if the device has
-		openings available and is not frozen.
-	
-		Check to see if a command has been aborted after
-		re-acquiring the ahc lock at the tail end of
-		aic7xxx_queue().
-	
-		Modify ahc_alloc_device() to initialize the openings
-		and maxtags fields.
-	
-	aic7xxx_osm.h:
-		Add Adaptec Copyright.
-	
-		Add device fields required to handle tagged queuing.
-	
-		Add function prototypes for ahc_platform abort routines.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.c#15 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_inline.h#6 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#17 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#11 edit
-
-Change 47 by gibbs@overdrive on 2000/08/12 07:00:10
-
-	Swith to using a union in ahc_cmd so we can avoid excessive
-	casting.
-	
-	Sort entries as they are inserted onto the completeq so that
-	transaction ordering for retried transactions is maintained.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#16 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#10 edit
-
-Change 46 by gibbs@overdrive on 2000/08/12 06:25:07
-
-	aic7xxx.c:
-		Remove some debugging printfs.
-	
-		Correctly deal with TWIN channel adapters when
-		dealing with the busy target table or busy target
-		queues.
-	
-	aic7xxx_osm.c:
-		Correct memset call in ahc_alloc_device() to
-		zero the correct nuber of bytes.
-	
-	aic7xxx_osm_pci.c:
-		Remove some debugging printfs.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.c#14 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#15 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#2 edit
-
-Change 45 by gibbs@overdrive on 2000/08/11 09:20:01
-
-	Set scb->platform_data->dev in aic7xxx_queue().
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#14 edit
-
-Change 44 by gibbs@overdrive on 2000/08/11 08:47:10
-
-	Correct addressing for per-device data-structures for
-	twin channel devices.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#13 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#9 edit
-
-Change 43 by gibbs@overdrive on 2000/08/11 08:40:12
-
-	aic7xxx.c:
-		Remove the "SEARCH_REMOVE" case from ahc_search_action.
-		It is never used and it would be hard to create sane
-		semantics for its use.
-	
-		scbp->scb to match most of the rest of the driver.
-	
-		In ahc_search_qinfifo(), handle the untagged queues
-		as well.  To the rest of the system, these are just
-		another part of the input fifo.
-	
-	aic7xxx_osm.c:
-		Add Adaptec Inc. copyright.
-	
-		Add a mechanism for allocating and freeing a per-device
-		data-structure for queue and other management.  The
-		data structure is persistent so long as commands for
-		that device are outstanding and/or we've seen a proper
-		inquiry response from that device that makes us believe
-		there is a persistent device at that location (target/lun).
-	
-	aic7xxx_osm.h:
-		Per-device data structure definitions.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.c#13 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#12 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#8 edit
-
-Change 42 by gibbs@overdrive on 2000/08/11 04:43:03
-
-	Initialize the completeq with STAILQ_INIT now that it is an
-	STAILQ.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#11 edit
-
-Change 41 by gibbs@overdrive on 2000/08/11 04:37:07
-
-	Use a shaddow structure of scsi_cmnd so we can name fields
-	"reserved" for HBA use however we wish.  This lets us use
-	the queue macros for queuing these structures.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#10 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#7 edit
-
-Change 37 by gibbs@overdrive on 2000/08/10 08:07:55
-
-	aic7xxx.c:
-	aic7xxx.h:
-		Move more function declarations to global scope.
-	
-	aic7xxx_osm.c:
-		Implement a mechanism to sniff completed commands
-		that complete with good status.  We use this to
-		sniff completed inquiry responses for targets to
-		determine there transfer capabilities.
-	
-	aic7xxx_osm.h:
-		Add a definition for the inquiry response format
-		for use by our transaction sniffer.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.c#9 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.h#5 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#9 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#6 edit
-
-Change 36 by gibbs@overdrive on 2000/08/10 06:34:34
-
-	Spaces to tabs.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.c#8 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#8 edit
-
-Change 35 by gibbs@overdrive on 2000/08/10 05:33:22
-
-	aic7xxx.c:
-		Add ahc_busy_tcl().  This routine is used to add
-		an SCBID to the busy target's table.  Right now this
-		is only used when transitioning a transaction from
-		tagged to untagged when a tag message is rejected.
-	
-		Move some function prototypes to aic7xxx.h for use
-		by other modules.
-	
-		Re-enable code that sets transaction status now that
-		we have an OSM method for doing this.
-	
-		Kill some debugging printfs.
-	
-	aic7xxx.h:
-		Added function prototypes for methods in aic7xxx.c
-	
-	aic7xxx.seq:
-		For added safety, when handling a data overrun,
-		clear STCNT before going into bit-bucket mode.
-		clearing STCNT should ensure that the data channel
-		will not resume a previous transfer setup via
-		PRELOADEN.
-	
-	aic7xxx_inline.h:
-		The controller lock is always held when a transaction is
-		freed.  Don't bother re-acquiring it is ahc_free_scb().
-	
-		Kill more diagnostic printfs.
-	
-	aic7xxx_osm.c:
-		Inline completion queue routines.
-	
-		Reset the bus on startup for now.  Later we will honor
-		non-volatile card setting and if no reset is requested,
-		we will negotiate on the first transaction.
-	
-		Store a pointer to a scsi command's scb in the host_scribble
-		area while the command is outstanding.  This allows us
-		to get back to the SCB from within the abort/reset routines.
-	
-		Check cmd->use_sg consistently.  Even if only one SG is
-		provided, we must still treat the request_buffer pointer
-		as a pointer to a list of SG structures, not a contiguous
-		buffer.
-	
-		Fixup some bugs in how were were initializing SCBs in the
-		aic7xxx_queue routine.
-	
-		Keep track of pending SCBs in the pending_scb list.  The
-		core routines in aic7xxx.c expect to find pending SCBS
-		here.
-	
-		Properly remove untagged transactions from the untagged
-		queue when they complete.
-	
-		Set transaction status to DID_OK (CAM_REQ_CMP) if, at
-		ahc_done time, the status is still CAM_REQ_INPROG.
-	
-		Add some diagnostic code to the abort routine so we
-		can determine why the mid-layer decided an abort was
-		necessary.
-	
-	aic7xxx_osm.h:
-		Make the ahc_done_lock a no-op on systems that use
-		interrupt blocking for locks.  The softc lock is always
-		while the done lock is held, so no additional protection
-		is required.
-	
-		Add accessers for both the transaction and scsi status
-		fields.  These are used by core code.
-	
-	cam.h:
-		Switch CAM_SEL_TIMEOUT from "DID_TIME_OUT" to
-		"DID_NO_CONNECT".  This seems more correct based
-		on a quick look at scsi_error.c of the mid-layer.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.c#7 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.h#4 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.seq#4 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_inline.h#5 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#7 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#5 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/cam.h#3 edit
-
-Change 32 by gibbs@overdrive on 2000/08/09 07:31:45
-
-	aic7xxx.c:
-		Remove duplicate OSM function ahc_scb_set_residual().
-		We already had ahc_set_residual().
-	
-		Use platform independent method for storing retrieved
-		sense data.
-	
-	aic7xxx_osm.c:
-		Add a deferred completion queue.  The queue is filled
-		by ahc_done() and run from either our interrupt handler,
-		or error recovery routines after all commands are queued
-		for completion.
-	
-		Keep track of the size of our transfer.  This is later
-		used in residual handling.
-	
-		Implement basic ahc_done() routine.  This will need to
-		be enhanced to deal with things like queue full.
-	
-	aic7xxx_osm.h:
-		Implement the completeq.  Due to the nature of the
-		scsi_cmnd structure, we cannot use a <sys/queue.h>
-		style queue for this, so create a simple LIFO.
-	
-		Flesh out the inline accessors to OSM dependent
-		per transaction data fields.
-	
-	cam.h:
-		Map CAM status to Linux SCSI status codes.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.c#4 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#6 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#4 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/cam.h#2 edit
-
-Change 31 by gibbs@overdrive on 2000/08/08 13:11:38
-
-	Debug adapter queue command path.  We can now queue a command,
-	have the sequencer complete it, and route the compelted
-	command to ahc_done().
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.c#3 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_inline.h#4 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#5 edit
-
-Change 30 by gibbs@overdrive on 2000/08/08 10:01:08
-
-	First pass at the aic7xxx_queue routine.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#4 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#3 edit
-
-Change 29 by gibbs@overdrive on 2000/08/08 07:41:45
-
-	Missed in prior checkin.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_inline.h#3 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_pci.c#2 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#2 edit
-
-Change 27 by gibbs@overdrive on 2000/08/08 07:10:41
-
-	Add definitions to properly lock the system when returning
-	commands back to the OS.
-	
-	Hook up our interrupt handler.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.c#2 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#3 edit
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#2 edit
-
-Change 26 by gibbs@overdrive on 2000/08/08 05:59:33
-
-	Get us to the point where we can successfully register
-	PCI adapters.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#2 edit
-
-Change 25 by gibbs@overdrive on 2000/08/08 05:58:36
-
-	More infrastructure - mostly from FreeBSD.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_93cx6.h#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_eisa.c#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_eisa.c#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/cam.h#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/queue.h#1 add
-
-Change 19 by gibbs@overdrive on 2000/07/28 03:12:09
-
-	Move into our sub-directory.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#1 branch
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx_proc.c#4 delete
-
-Change 18 by gibbs@overdrive on 2000/07/27 12:00:48
-
-	Use the old Linux driver as the foundation for the Linux
-	specific core file.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#1 branch
-
-Change 7 by gibbs@overdrive on 2000/07/13 07:09:24
-
-	Latest SCSI message file from FreeBSD.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/scsi_message.h#2 edit
-
-Change 5 by gibbs@overdrive on 2000/07/13 07:07:29
-
-	Move the assembler to its own subdirectory.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/Makefile#3 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm.c#2 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm.h#2 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/Makefile#1 branch
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/aicasm.c#1 branch
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/aicasm.h#1 branch
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/aicasm_gram.y#1 branch
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h#1 branch
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/aicasm_scan.l#1 branch
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.c#1 branch
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.h#1 branch
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm_gram.y#2 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm_insformat.h#3 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm_scan.l#2 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm_symbol.c#3 delete
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aicasm_symbol.h#2 delete
-
-Change 1 by gibbs@overdrive on 2000/07/12 11:01:33
-
-	Initial import of Doug Ledford's aic7xxx driver v5.2.0.
-
-Affected files ...
-
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx.c#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx.h#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.reg#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx.seq#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/scsi_message.h#1 add
-... //depot/aic7xxx/linux/drivers/scsi/aic7xxx/sequencer.h#1 add
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/Config.in linux-2.4.22-pre2/drivers/scsi/aic79xx/Config.in
--- linux-2.4.21/drivers/scsi/aic79xx/Config.in	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/Config.in	2003-06-26 21:43:13.000000000 +0000
@@ -1,17 +0,0 @@
-dep_tristate 'Adaptec AIC79xx support' CONFIG_SCSI_AIC79XX $CONFIG_SCSI
-if [ "$CONFIG_SCSI_AIC79XX" != "n" ]; then
-   int  '  Maximum number of TCQ commands per device' \
-	CONFIG_AIC79XX_CMDS_PER_DEVICE 32
-   int  '  Initial bus reset delay in milli-seconds' \
-	CONFIG_AIC79XX_RESET_DELAY_MS 15000
-   bool  '  Build Adapter Firmware with Kernel Build' \
-	CONFIG_AIC79XX_BUILD_FIRMWARE
-   bool  '  Enable Read Streaming for All Targets' \
-	CONFIG_AIC79XX_ENABLE_RD_STRM
-   bool  '  Compile in Debugging Code' \
-	CONFIG_AIC79XX_DEBUG_ENABLE
-   int  '  Debug code enable mask (16384 for all debugging)' \
-	CONFIG_AIC79XX_DEBUG_MASK 0
-   bool  '  Decode registers during diagnostics' \
-	CONFIG_AIC79XX_REG_PRETTY_PRINT
-fi
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/Makefile linux-2.4.22-pre2/drivers/scsi/aic79xx/Makefile
--- linux-2.4.21/drivers/scsi/aic79xx/Makefile	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/Makefile	2003-06-26 21:43:11.000000000 +0000
@@ -1,50 +0,0 @@
-#
-# drivers/scsi/aic79xx/Makefile
-#
-# Makefile for the Linux aic79xx SCSI driver.
-#
-
-O_TARGET := aic79xx_drv.o
-
-list-multi	:= aic79xx.o
-
-obj-$(CONFIG_SCSI_AIC79XX)	+= aic79xx.o
-
-EXTRA_CFLAGS += -I..
-#EXTRA_CFLAGS += -g
-
-# Platform Specific U320 Files
-obj-aic79xx = aic79xx_osm.o aic79xx_proc.o aic79xx_osm_pci.o
-# Core Files
-obj-aic79xx += aic79xx_core.o aic79xx_pci.o
-ifeq ($(CONFIG_AIC79XX_REG_PRETTY_PRINT),y)
-obj-aic79xx += aic79xx_reg_print.o
-endif
-
-# Override our module desitnation
-MOD_DESTDIR = $(shell cd .. && $(CONFIG_SHELL) $(TOPDIR)/scripts/pathdown.sh)
-
-include $(TOPDIR)/Rules.make
-
-aic79xx_core.o: aic79xx_seq.h
-$(obj-aic79xx): aic79xx_reg.h
-aic79xx.o: aic79xx_seq.h aic79xx_reg.h $(obj-aic79xx)
-	$(LD) $(LD_RFLAG) -r -o $@ $(obj-aic79xx)
-
-ifeq ($(CONFIG_AIC79XX_BUILD_FIRMWARE),y)
-aic79xx_gen = aic79xx_seq.h aic79xx_reg.h
-ifeq ($(CONFIG_AIC79XX_REG_PRETTY_PRINT),y)
-aic79xx_gen += aic79xx_reg_print.c
-aic79xx_asm_cmd = aicasm/aicasm -I. -r aic79xx_reg.h		\
-		 -p aic79xx_reg_print.c -i aic79xx_osm.h	\
-		 -o aic79xx_seq.h aic79xx.seq
-else
-aic79xx_asm_cmd = aicasm/aicasm -I. -r aic79xx_reg.h \
-		 -o aic79xx_seq.h aic79xx.seq
-endif
-$(aic79xx_gen): aic79xx.seq aic79xx.reg aicasm/aicasm
-	$(aic79xx_asm_cmd)
-endif
-
-aicasm/aicasm: aicasm/*.[chyl]
-	$(MAKE) -C aicasm
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aic79xx.h linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx.h
--- linux-2.4.21/drivers/scsi/aic79xx/aic79xx.h	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx.h	2003-06-26 21:43:12.000000000 +0000
@@ -1,1480 +0,0 @@
-/*
- * Core definitions and data structures shareable across OS platforms.
- *
- * Copyright (c) 1994-2002 Justin T. Gibbs.
- * Copyright (c) 2000-2002 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: //depot/aic7xxx/aic7xxx/aic79xx.h#78 $
- *
- * $FreeBSD$
- */
-
-#ifndef _AIC79XX_H_
-#define _AIC79XX_H_
-
-/* Register Definitions */
-#include "aic79xx_reg.h"
-
-/************************* Forward Declarations *******************************/
-struct ahd_platform_data;
-struct scb_platform_data;
-
-/****************************** Useful Macros *********************************/
-#ifndef MAX
-#define MAX(a,b) (((a) > (b)) ? (a) : (b))
-#endif
-
-#ifndef MIN
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-#endif
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#define NUM_ELEMENTS(array) (sizeof(array) / sizeof(*array))
-
-#define ALL_CHANNELS '\0'
-#define ALL_TARGETS_MASK 0xFFFF
-#define INITIATOR_WILDCARD	(~0)
-#define	SCB_LIST_NULL		0xFF00
-#define	SCB_LIST_NULL_LE	(ahd_htole16(SCB_LIST_NULL))
-#define QOUTFIFO_ENTRY_VALID 0x8000
-#define QOUTFIFO_ENTRY_VALID_LE (ahd_htole16(0x8000))
-#define SCBID_IS_NULL(scbid) (((scbid) & 0xFF00 ) == SCB_LIST_NULL)
-
-#define SCSIID_TARGET(ahd, scsiid)	\
-	(((scsiid) & TID) >> TID_SHIFT)
-#define SCSIID_OUR_ID(scsiid)		\
-	((scsiid) & OID)
-#define SCSIID_CHANNEL(ahd, scsiid) ('A')
-#define	SCB_IS_SCSIBUS_B(ahd, scb) (0)
-#define	SCB_GET_OUR_ID(scb) \
-	SCSIID_OUR_ID((scb)->hscb->scsiid)
-#define	SCB_GET_TARGET(ahd, scb) \
-	SCSIID_TARGET((ahd), (scb)->hscb->scsiid)
-#define	SCB_GET_CHANNEL(ahd, scb) \
-	SCSIID_CHANNEL(ahd, (scb)->hscb->scsiid)
-#define	SCB_GET_LUN(scb) \
-	((scb)->hscb->lun)
-#define SCB_GET_TARGET_OFFSET(ahd, scb)	\
-	SCB_GET_TARGET(ahd, scb)
-#define SCB_GET_TARGET_MASK(ahd, scb) \
-	(0x01 << (SCB_GET_TARGET_OFFSET(ahd, scb)))
-#ifdef AHD_DEBUG
-#define SCB_IS_SILENT(scb)					\
-	((ahd_debug & AHD_SHOW_MASKED_ERRORS) == 0		\
-      && (((scb)->flags & SCB_SILENT) != 0))
-#else
-#define SCB_IS_SILENT(scb)					\
-	(((scb)->flags & SCB_SILENT) != 0)
-#endif
-/*
- * TCLs have the following format: TTTTLLLLLLLL
- */
-#define TCL_TARGET_OFFSET(tcl) \
-	((((tcl) >> 4) & TID) >> 4)
-#define TCL_LUN(tcl) \
-	(tcl & (AHD_NUM_LUNS - 1))
-#define BUILD_TCL(scsiid, lun) \
-	((lun) | (((scsiid) & TID) << 4))
-#define BUILD_TCL_RAW(target, channel, lun) \
-	((lun) | ((target) << 8))
-
-#define SCB_GET_TAG(scb) \
-	ahd_le16toh(scb->hscb->tag)
-
-#ifndef	AHD_TARGET_MODE
-#undef	AHD_TMODE_ENABLE
-#define	AHD_TMODE_ENABLE 0
-#endif
-
-#define AHD_BUILD_COL_IDX(target, lun)				\
-	(((lun) << 4) | target)
-
-#define AHD_GET_SCB_COL_IDX(ahd, scb)				\
-	((SCB_GET_LUN(scb) << 4) | SCB_GET_TARGET(ahd, scb))
-
-#define AHD_SET_SCB_COL_IDX(scb, col_idx)				\
-do {									\
-	(scb)->hscb->scsiid = ((col_idx) << TID_SHIFT) & TID;		\
-	(scb)->hscb->lun = ((col_idx) >> 4) & (AHD_NUM_LUNS_NONPKT-1);	\
-} while (0)
-
-#define AHD_COPY_SCB_COL_IDX(dst, src)				\
-do {								\
-	dst->hscb->scsiid = src->hscb->scsiid;			\
-	dst->hscb->lun = src->hscb->lun;			\
-} while (0)
-
-#define	AHD_NEVER_COL_IDX 0xFFFF
-
-/**************************** Driver Constants ********************************/
-/*
- * The maximum number of supported targets.
- */
-#define AHD_NUM_TARGETS 16
-
-/*
- * The maximum number of supported luns.
- * The identify message only supports 64 luns in non-packetized transfers.
- * You can have 2^64 luns when information unit transfers are enabled,
- * but until we see a need to support that many, we support 256.
- */
-#define AHD_NUM_LUNS_NONPKT 64
-#define AHD_NUM_LUNS 256
-
-/*
- * The maximum transfer per S/G segment.
- */
-#define AHD_MAXTRANSFER_SIZE	 0x00ffffff	/* limited by 24bit counter */
-
-/*
- * The maximum amount of SCB storage in hardware on a controller.
- * This value represents an upper bound.  Due to software design,
- * we may not be able to use this number.
- */
-#define AHD_SCB_MAX	512
-
-/*
- * The maximum number of concurrent transactions supported per driver instance.
- * Sequencer Control Blocks (SCBs) store per-transaction information.
- */
-#define AHD_MAX_QUEUE	AHD_SCB_MAX
-
-/*
- * Define the size of our QIN and QOUT FIFOs.  They must be a power of 2
- * in size and accomodate as many transactions as can be queued concurrently.
- */
-#define	AHD_QIN_SIZE	AHD_MAX_QUEUE
-#define	AHD_QOUT_SIZE	AHD_MAX_QUEUE
-
-#define AHD_QIN_WRAP(x) ((x) & (AHD_QIN_SIZE-1))
-/*
- * The maximum amount of SCB storage we allocate in host memory.
- */
-#define AHD_SCB_MAX_ALLOC AHD_MAX_QUEUE
-
-/*
- * Ring Buffer of incoming target commands.
- * We allocate 256 to simplify the logic in the sequencer
- * by using the natural wrap point of an 8bit counter.
- */
-#define AHD_TMODE_CMDS	256
-
-/* Reset line assertion time in us */
-#define AHD_BUSRESET_DELAY	25
-
-/******************* Chip Characteristics/Operating Settings  *****************/
-/*
- * Chip Type
- * The chip order is from least sophisticated to most sophisticated.
- */
-typedef enum {
-	AHD_NONE	= 0x0000,
-	AHD_CHIPID_MASK	= 0x00FF,
-	AHD_AIC7901	= 0x0001,
-	AHD_AIC7902	= 0x0002,
-	AHD_AIC7901A	= 0x0003,
-	AHD_PCI		= 0x0100,	/* Bus type PCI */
-	AHD_PCIX	= 0x0200,	/* Bus type PCIX */
-	AHD_BUS_MASK	= 0x0F00
-} ahd_chip;
-
-/*
- * Features available in each chip type.
- */
-typedef enum {
-	AHD_FENONE		= 0x00000,
-	AHD_WIDE  		= 0x00001,/* Wide Channel */
-	AHD_MULTI_FUNC		= 0x00100,/* Multi-Function/Channel Device */
-	AHD_TARGETMODE		= 0x01000,/* Has tested target mode support */
-	AHD_MULTIROLE		= 0x02000,/* Space for two roles at a time */
-	AHD_RTI			= 0x04000,/* Retained Training Support */
-	AHD_NEW_IOCELL_OPTS	= 0x08000,/* More Signal knobs in the IOCELL */
-	AHD_NEW_DFCNTRL_OPTS	= 0x10000,/* SCSIENWRDIS bit */
-	AHD_REMOVABLE		= 0x00000,/* Hot-Swap supported - None so far*/
-	AHD_AIC7901_FE		= AHD_FENONE,
-	AHD_AIC7902_FE		= AHD_MULTI_FUNC
-} ahd_feature;
-
-/*
- * Bugs in the silicon that we work around in software.
- */
-typedef enum {
-	AHD_BUGNONE		= 0x0000,
-	/*
-	 * Rev A hardware fails to update LAST/CURR/NEXTSCB
-	 * correctly in certain packetized selection cases.
-	 */
-	AHD_SENT_SCB_UPDATE_BUG	= 0x0001,
-	/* The wrong SCB is accessed to check the abort pending bit. */
-	AHD_ABORT_LQI_BUG	= 0x0002,
-	/* Packetized bitbucket crosses packet boundaries. */
-	AHD_PKT_BITBUCKET_BUG	= 0x0004,
-	/* The selection timer runs twice as long as its setting. */
-	AHD_LONG_SETIMO_BUG	= 0x0008,
-	/* The Non-LQ CRC error status is delayed until phase change. */
-	AHD_NLQICRC_DELAYED_BUG	= 0x0010,
-	/* The chip must be reset for all outgoing bus resets.  */
-	AHD_SCSIRST_BUG		= 0x0020,
-	/* Some PCIX fields must be saved and restored across chip reset. */
-	AHD_PCIX_CHIPRST_BUG	= 0x0040,
-	/* MMAPIO is not functional in PCI-X mode.  */
-	AHD_PCIX_MMAPIO_BUG	= 0x0080,
-	/* Bug workarounds that can be disabled on non-PCIX busses. */
-	AHD_PCIX_BUG_MASK	= AHD_PCIX_CHIPRST_BUG
-				| AHD_PCIX_MMAPIO_BUG,
-	/*
-	 * LQOSTOP0 status set even for forced selections with ATN
-	 * to perform non-packetized message delivery.
-	 */
-	AHD_LQO_ATNO_BUG	= 0x0100,
-	/* FIFO auto-flush does not always trigger.  */
-	AHD_AUTOFLUSH_BUG	= 0x0200,
-	/* The CLRLQO registers are not self-clearing. */
-	AHD_CLRLQO_AUTOCLR_BUG	= 0x0400,
-	/* The PACKETIZED status bit refers to the previous connection. */
-	AHD_PKTIZED_STATUS_BUG  = 0x0800,
-	/* "Short Luns" are not placed into outgoing LQ packets correctly. */
-	AHD_PKT_LUN_BUG		= 0x1000,
-	/*
-	 * Only the FIFO allocated to the non-packetized connection may
-	 * be in use during a non-packetzied connection.
-	 */
-	AHD_NONPACKFIFO_BUG	= 0x2000,
-	/*
-	 * Writing to a DFF SCBPTR register may fail if concurent with
-	 * a hardware write to the other DFF SCBPTR register.  This is
-	 * not currently a concern in our sequencer since all chips with
-	 * this bug have the AHD_NONPACKFIFO_BUG and all writes of concern
-	 * occur in non-packetized connections.
-	 */
-	AHD_MDFF_WSCBPTR_BUG	= 0x4000,
-	/* SGHADDR updates are slow. */
-	AHD_REG_SLOW_SETTLE_BUG	= 0x8000,
-	/*
-	 * Changing the MODE_PTR coincident with an interrupt that
-	 * switches to a different mode will cause the interrupt to
-	 * be in the mode written outside of interrupt context.
-	 */
-	AHD_SET_MODE_BUG	= 0x10000,
-	/* Non-packetized busfree revision does not work. */
-	AHD_BUSFREEREV_BUG	= 0x20000,
-	/*
-	 * Paced transfers are indicated with a non-standard PPR
-	 * option bit in the neg table, 160MHz is indicated by
-	 * sync factor 0x7, and the offset if off by a factor of 2.
-	 */
-	AHD_PACED_NEGTABLE_BUG	= 0x40000,
-	/* LQOOVERRUN false positives. */
-	AHD_LQOOVERRUN_BUG	= 0x80000,
-	/*
-	 * Controller write to INTSTAT will lose to a host
-	 * write to CLRINT.
-	 */
-	AHD_INTCOLLISION_BUG	= 0x100000
-} ahd_bug;
-
-/*
- * Configuration specific settings.
- * The driver determines these settings by probing the
- * chip/controller's configuration.
- */
-typedef enum {
-	AHD_FNONE	      = 0x00000,
-	AHD_PRIMARY_CHANNEL   = 0x00003,/*
-					 * The channel that should
-					 * be probed first.
-					 */
-	AHD_USEDEFAULTS	      = 0x00004,/*
-					 * For cards without an seeprom
-					 * or a BIOS to initialize the chip's
-					 * SRAM, we use the default target
-					 * settings.
-					 */
-	AHD_SEQUENCER_DEBUG   = 0x00008,
-	AHD_RESET_BUS_A	      = 0x00010,
-	AHD_EXTENDED_TRANS_A  = 0x00020,
-	AHD_TERM_ENB_A	      = 0x00040,
-	AHD_SPCHK_ENB_A	      = 0x00080,
-	AHD_STPWLEVEL_A	      = 0x00100,
-	AHD_INITIATORROLE     = 0x00200,/*
-					 * Allow initiator operations on
-					 * this controller.
-					 */
-	AHD_TARGETROLE	      = 0x00400,/*
-					 * Allow target operations on this
-					 * controller.
-					 */
-	AHD_RESOURCE_SHORTAGE = 0x00800,
-	AHD_TQINFIFO_BLOCKED  = 0x01000,/* Blocked waiting for ATIOs */
-	AHD_INT50_SPEEDFLEX   = 0x02000,/*
-					 * Internal 50pin connector
-					 * sits behind an aic3860
-					 */
-	AHD_BIOS_ENABLED      = 0x04000,
-	AHD_ALL_INTERRUPTS    = 0x08000,
-	AHD_39BIT_ADDRESSING  = 0x10000,/* Use 39 bit addressing scheme. */
-	AHD_64BIT_ADDRESSING  = 0x20000,/* Use 64 bit addressing scheme. */
-	AHD_CURRENT_SENSING   = 0x40000,
-	AHD_SCB_CONFIG_USED   = 0x80000,/* No SEEPROM but SCB had info. */
-	AHD_HP_BOARD	      = 0x100000,
-	AHD_RESET_POLL_ACTIVE = 0x200000,
-	AHD_UPDATE_PEND_CMDS  = 0x400000,
-	AHD_RUNNING_QOUTFIFO  = 0x800000
-} ahd_flag;
-
-/************************* Hardware  SCB Definition ***************************/
-
-/*
- * The driver keeps up to MAX_SCB scb structures per card in memory.  The SCB
- * consists of a "hardware SCB" mirroring the fields availible on the card
- * and additional information the kernel stores for each transaction.
- *
- * To minimize space utilization, a portion of the hardware scb stores
- * different data during different portions of a SCSI transaction.
- * As initialized by the host driver for the initiator role, this area
- * contains the SCSI cdb (or a pointer to the  cdb) to be executed.  After
- * the cdb has been presented to the target, this area serves to store
- * residual transfer information and the SCSI status byte.
- * For the target role, the contents of this area do not change, but
- * still serve a different purpose than for the initiator role.  See
- * struct target_data for details.
- */
-
-/*
- * Status information embedded in the shared poriton of
- * an SCB after passing the cdb to the target.  The kernel
- * driver will only read this data for transactions that
- * complete abnormally.
- */
-struct initiator_status {
-	uint32_t residual_datacnt;	/* Residual in the current S/G seg */
-	uint32_t residual_sgptr;	/* The next S/G for this transfer */
-	uint8_t	 scsi_status;		/* Standard SCSI status byte */
-};
-
-struct target_status {
-	uint32_t residual_datacnt;	/* Residual in the current S/G seg */
-	uint32_t residual_sgptr;	/* The next S/G for this transfer */
-	uint8_t  scsi_status;		/* SCSI status to give to initiator */
-	uint8_t  target_phases;		/* Bitmap of phases to execute */
-	uint8_t  data_phase;		/* Data-In or Data-Out */
-	uint8_t  initiator_tag;		/* Initiator's transaction tag */
-};
-
-/*
- * Initiator mode SCB shared data area.
- * If the embedded CDB is 12 bytes or less, we embed
- * the sense buffer address in the SCB.  This allows
- * us to retrieve sense information without interupting
- * the host in packetized mode.
- */
-typedef uint32_t sense_addr_t;
-#define MAX_CDB_LEN 16
-#define MAX_CDB_LEN_WITH_SENSE_ADDR (MAX_CDB_LEN - sizeof(sense_addr_t))
-union initiator_data {
-	uint64_t cdbptr;
-	uint8_t	 cdb[MAX_CDB_LEN];
-	struct {
-		uint8_t	 cdb[MAX_CDB_LEN_WITH_SENSE_ADDR];
-		sense_addr_t sense_addr;
-	} cdb_plus_saddr;
-};
-
-/*
- * Target mode version of the shared data SCB segment.
- */
-struct target_data {
-	uint32_t spare[2];	
-	uint8_t  scsi_status;		/* SCSI status to give to initiator */
-	uint8_t  target_phases;		/* Bitmap of phases to execute */
-	uint8_t  data_phase;		/* Data-In or Data-Out */
-	uint8_t  initiator_tag;		/* Initiator's transaction tag */
-};
-
-struct hardware_scb {
-/*0*/	union {
-		union	initiator_data idata;
-		struct	target_data tdata;
-		struct	initiator_status istatus;
-		struct	target_status tstatus;
-	} shared_data;
-/*
- * A word about residuals.
- * The scb is presented to the sequencer with the dataptr and datacnt
- * fields initialized to the contents of the first S/G element to
- * transfer.  The sgptr field is initialized to the bus address for
- * the S/G element that follows the first in the in core S/G array
- * or'ed with the SG_FULL_RESID flag.  Sgptr may point to an invalid
- * S/G entry for this transfer (single S/G element transfer with the
- * first elements address and length preloaded in the dataptr/datacnt
- * fields).  If no transfer is to occur, sgptr is set to SG_LIST_NULL.
- * The SG_FULL_RESID flag ensures that the residual will be correctly
- * noted even if no data transfers occur.  Once the data phase is entered,
- * the residual sgptr and datacnt are loaded from the sgptr and the
- * datacnt fields.  After each S/G element's dataptr and length are
- * loaded into the hardware, the residual sgptr is advanced.  After
- * each S/G element is expired, its datacnt field is checked to see
- * if the LAST_SEG flag is set.  If so, SG_LIST_NULL is set in the
- * residual sg ptr and the transfer is considered complete.  If the
- * sequencer determines that there is a residual in the tranfer, or
- * there is non-zero status, it will set the SG_STATUS_VALID flag in
- * sgptr and dma the scb back into host memory.  To sumarize:
- *
- * Sequencer:
- *	o A residual has occurred if SG_FULL_RESID is set in sgptr,
- *	  or residual_sgptr does not have SG_LIST_NULL set.
- *
- *	o We are transfering the last segment if residual_datacnt has
- *	  the SG_LAST_SEG flag set.
- *
- * Host:
- *	o A residual can only have occurred if a completed scb has the
- *	  SG_STATUS_VALID flag set.  Inspection of the SCSI status field,
- *	  the residual_datacnt, and the residual_sgptr field will tell
- *	  for sure.
- *
- *	o residual_sgptr and sgptr refer to the "next" sg entry
- *	  and so may point beyond the last valid sg entry for the
- *	  transfer.
- */ 
-#define SG_PTR_MASK	0xFFFFFFF8
-/*16*/	uint16_t tag;
-/*18*/	uint8_t  cdb_len;
-/*19*/	uint8_t  task_management;
-/*20*/	uint32_t next_hscb_busaddr;
-/*24*/	uint64_t dataptr;
-/*32*/	uint32_t datacnt;	/* Byte 3 is spare. */
-/*36*/	uint32_t sgptr;
-/*40*/	uint8_t  control;	/* See SCB_CONTROL in aic79xx.reg for details */
-/*41*/	uint8_t	 scsiid;	/*
-				 * Selection out Id
-				 * Our Id (bits 0-3) Their ID (bits 4-7)
-				 */
-/*42*/	uint8_t  lun;
-/*43*/	uint8_t  task_attribute;
-/*44*/	uint32_t hscb_busaddr;
-/******* Long lun field only downloaded for full 8 byte lun support *******/
-/*48*/  uint8_t	 pkt_long_lun[8];
-/******* Fields below are not Downloaded (Sequencer may use for scratch) ******/
-/*56*/  uint8_t	 spare[8];
-};
-
-/************************ Kernel SCB Definitions ******************************/
-/*
- * Some fields of the SCB are OS dependent.  Here we collect the
- * definitions for elements that all OS platforms need to include
- * in there SCB definition.
- */
-
-/*
- * Definition of a scatter/gather element as transfered to the controller.
- * The aic7xxx chips only support a 24bit length.  We use the top byte of
- * the length to store additional address bits and a flag to indicate
- * that a given segment terminates the transfer.  This gives us an
- * addressable range of 512GB on machines with 64bit PCI or with chips
- * that can support dual address cycles on 32bit PCI busses.
- */
-struct ahd_dma_seg {
-	uint32_t	addr;
-	uint32_t	len;
-#define	AHD_DMA_LAST_SEG	0x80000000
-#define	AHD_SG_HIGH_ADDR_MASK	0x7F000000
-#define	AHD_SG_LEN_MASK		0x00FFFFFF
-};
-
-struct ahd_dma64_seg {
-	uint64_t	addr;
-	uint32_t	len;
-	uint32_t	pad;
-};
-
-struct map_node {
-	bus_dmamap_t		 dmamap;
-	bus_addr_t		 physaddr;
-	uint8_t			*vaddr;
-	SLIST_ENTRY(map_node)	 links;
-};
-
-/*
- * The current state of this SCB.
- */
-typedef enum {
-	SCB_FLAG_NONE		= 0x00000,
-	SCB_TRANSMISSION_ERROR	= 0x00001,/*
-					   * We detected a parity or CRC
-					   * error that has effected the
-					   * payload of the command.  This
-					   * flag is checked when normal
-					   * status is returned to catch
-					   * the case of a target not
-					   * responding to our attempt
-					   * to report the error.
-					   */
-	SCB_OTHERTCL_TIMEOUT	= 0x00002,/*
-					   * Another device was active
-					   * during the first timeout for
-					   * this SCB so we gave ourselves
-					   * an additional timeout period
-					   * in case it was hogging the
-					   * bus.
-				           */
-	SCB_DEVICE_RESET	= 0x00004,
-	SCB_SENSE		= 0x00008,
-	SCB_CDB32_PTR		= 0x00010,
-	SCB_RECOVERY_SCB	= 0x00020,
-	SCB_AUTO_NEGOTIATE	= 0x00040,/* Negotiate to achieve goal. */
-	SCB_NEGOTIATE		= 0x00080,/* Negotiation forced for command. */
-	SCB_ABORT		= 0x00100,
-	SCB_ACTIVE		= 0x00200,
-	SCB_TARGET_IMMEDIATE	= 0x00400,
-	SCB_PACKETIZED		= 0x00800,
-	SCB_EXPECT_PPR_BUSFREE	= 0x01000,
-	SCB_PKT_SENSE		= 0x02000,
-	SCB_CMDPHASE_ABORT	= 0x04000,
-	SCB_ON_COL_LIST		= 0x08000,
-	SCB_SILENT		= 0x10000 /*
-					   * Be quiet about transmission type
-					   * errors.  They are expected and we
-					   * don't want to upset the user.  This
-					   * flag is typically used during DV.
-					   */
-} scb_flag;
-
-struct scb {
-	struct	hardware_scb	 *hscb;
-	union {
-		SLIST_ENTRY(scb)  sle;
-		LIST_ENTRY(scb)	  le;
-		TAILQ_ENTRY(scb)  tqe;
-	} links;
-	union {
-		SLIST_ENTRY(scb)  sle;
-		LIST_ENTRY(scb)	  le;
-		TAILQ_ENTRY(scb)  tqe;
-	} links2;
-#define pending_links links2.le
-#define collision_links links2.le
-	struct scb		 *col_scb;
-	ahd_io_ctx_t		  io_ctx;
-	struct ahd_softc	 *ahd_softc;
-	scb_flag		  flags;
-#ifndef __linux__
-	bus_dmamap_t		  dmamap;
-#endif
-	struct scb_platform_data *platform_data;
-	struct map_node	 	 *hscb_map;
-	struct map_node	 	 *sg_map;
-	struct map_node	 	 *sense_map;
-	void			 *sg_list;
-	uint8_t			 *sense_data;
-	bus_addr_t		  sg_list_busaddr;
-	bus_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;
-};
-
-TAILQ_HEAD(scb_tailq, scb);
-LIST_HEAD(scb_list, scb);
-
-struct scb_data {
-	/*
-	 * TAILQ of lists of free SCBs grouped by device
-	 * collision domains.
-	 */
-	struct scb_tailq free_scbs;
-
-	/*
-	 * Per-device lists of SCBs whose tag ID would collide
-	 * with an already active tag on the device.
-	 */
-	struct scb_list free_scb_lists[AHD_NUM_TARGETS * AHD_NUM_LUNS_NONPKT];
-
-	/*
-	 * SCBs that will not collide with any active device.
-	 */
-	struct scb_list any_dev_free_scb_list;
-
-	/*
-	 * Mapping from tag to SCB.
-	 */
-	struct	scb *scbindex[AHD_SCB_MAX];
-
-	/*
-	 * "Bus" addresses of our data structures.
-	 */
-	bus_dma_tag_t	 hscb_dmat;	/* dmat for our hardware SCB array */
-	bus_dma_tag_t	 sg_dmat;	/* dmat for our sg segments */
-	bus_dma_tag_t	 sense_dmat;	/* dmat for our sense buffers */
-	SLIST_HEAD(, map_node) hscb_maps;
-	SLIST_HEAD(, map_node) sg_maps;
-	SLIST_HEAD(, map_node) sense_maps;
-	int		 scbs_left;	/* unallocated scbs in head map_node */
-	int		 sgs_left;	/* unallocated sgs in head map_node */
-	int		 sense_left;	/* unallocated sense in head map_node */
-	uint16_t	 numscbs;
-	uint16_t	 maxhscbs;	/* Number of SCBs on the card */
-	uint8_t		 init_level;	/*
-					 * How far we've initialized
-					 * this structure.
-					 */
-};
-
-/************************ Target Mode Definitions *****************************/
-
-/*
- * Connection desciptor for select-in requests in target mode.
- */
-struct target_cmd {
-	uint8_t scsiid;		/* Our ID and the initiator's ID */
-	uint8_t identify;	/* Identify message */
-	uint8_t bytes[22];	/* 
-				 * Bytes contains any additional message
-				 * bytes terminated by 0xFF.  The remainder
-				 * is the cdb to execute.
-				 */
-	uint8_t cmd_valid;	/*
-				 * When a command is complete, the firmware
-				 * will set cmd_valid to all bits set.
-				 * After the host has seen the command,
-				 * the bits are cleared.  This allows us
-				 * to just peek at host memory to determine
-				 * if more work is complete. cmd_valid is on
-				 * an 8 byte boundary to simplify setting
-				 * it on aic7880 hardware which only has
-				 * limited direct access to the DMA FIFO.
-				 */
-	uint8_t pad[7];
-};
-
-/*
- * Number of events we can buffer up if we run out
- * of immediate notify ccbs.
- */
-#define AHD_TMODE_EVENT_BUFFER_SIZE 8
-struct ahd_tmode_event {
-	uint8_t initiator_id;
-	uint8_t event_type;	/* MSG type or EVENT_TYPE_BUS_RESET */
-#define	EVENT_TYPE_BUS_RESET 0xFF
-	uint8_t event_arg;
-};
-
-/*
- * Per enabled lun target mode state.
- * As this state is directly influenced by the host OS'es target mode
- * environment, we let the OS module define it.  Forward declare the
- * structure here so we can store arrays of them, etc. in OS neutral
- * data structures.
- */
-#ifdef AHD_TARGET_MODE 
-struct ahd_tmode_lstate {
-	struct cam_path *path;
-	struct ccb_hdr_slist accept_tios;
-	struct ccb_hdr_slist immed_notifies;
-	struct ahd_tmode_event event_buffer[AHD_TMODE_EVENT_BUFFER_SIZE];
-	uint8_t event_r_idx;
-	uint8_t event_w_idx;
-};
-#else
-struct ahd_tmode_lstate;
-#endif
-
-/******************** Transfer Negotiation Datastructures *********************/
-#define AHD_TRANS_CUR		0x01	/* Modify current neogtiation status */
-#define AHD_TRANS_ACTIVE	0x03	/* Assume this target is on the bus */
-#define AHD_TRANS_GOAL		0x04	/* Modify negotiation goal */
-#define AHD_TRANS_USER		0x08	/* Modify user negotiation settings */
-#define AHD_PERIOD_10MHz	0x19
-
-#define AHD_WIDTH_UNKNOWN	0xFF
-#define AHD_PERIOD_UNKNOWN	0xFF
-#define AHD_OFFSET_UNKNOWN	0x0
-#define AHD_PPR_OPTS_UNKNOWN	0xFF
-
-/*
- * Transfer Negotiation Information.
- */
-struct ahd_transinfo {
-	uint8_t protocol_version;	/* SCSI Revision level */
-	uint8_t transport_version;	/* SPI Revision level */
-	uint8_t width;			/* Bus width */
-	uint8_t period;			/* Sync rate factor */
-	uint8_t offset;			/* Sync offset */
-	uint8_t ppr_options;		/* Parallel Protocol Request options */
-};
-
-/*
- * Per-initiator current, goal and user transfer negotiation information. */
-struct ahd_initiator_tinfo {
-	struct ahd_transinfo curr;
-	struct ahd_transinfo goal;
-	struct ahd_transinfo user;
-};
-
-/*
- * Per enabled target ID state.
- * Pointers to lun target state as well as sync/wide negotiation information
- * for each initiator<->target mapping.  For the initiator role we pretend
- * that we are the target and the targets are the initiators since the
- * negotiation is the same regardless of role.
- */
-struct ahd_tmode_tstate {
-	struct ahd_tmode_lstate*	enabled_luns[AHD_NUM_LUNS];
-	struct ahd_initiator_tinfo	transinfo[AHD_NUM_TARGETS];
-
-	/*
-	 * Per initiator state bitmasks.
-	 */
-	uint16_t	 auto_negotiate;/* Auto Negotiation Required */
-	uint16_t	 discenable;	/* Disconnection allowed  */
-	uint16_t	 tagenable;	/* Tagged Queuing allowed */
-};
-
-/*
- * Points of interest along the negotiated transfer scale.
- */
-#define AHD_SYNCRATE_160	0x8
-#define AHD_SYNCRATE_PACED	0x8
-#define AHD_SYNCRATE_DT		0x9
-#define AHD_SYNCRATE_ULTRA2	0xa
-#define AHD_SYNCRATE_ULTRA	0xc
-#define AHD_SYNCRATE_FAST	0x19
-#define AHD_SYNCRATE_MIN_DT	AHD_SYNCRATE_FAST
-#define AHD_SYNCRATE_SYNC	0x32
-#define AHD_SYNCRATE_MIN	0x60
-#define	AHD_SYNCRATE_ASYNC	0xFF
-#define AHD_SYNCRATE_MAX	AHD_SYNCRATE_160
-
-/* Safe and valid period for async negotiations. */
-#define	AHD_ASYNC_XFER_PERIOD	0x44
-
-/*
- * In RevA, the synctable uses a 120MHz rate for the period
- * factor 8 and 160MHz for the period factor 7.  The 120MHz
- * rate never made it into the official SCSI spec, so we must
- * compensate when setting the negotiation table for Rev A
- * parts.
- */
-#define AHD_SYNCRATE_REVA_120	0x8
-#define AHD_SYNCRATE_REVA_160	0x7
-
-/***************************** Lookup Tables **********************************/
-/*
- * Phase -> name and message out response
- * to parity errors in each phase table. 
- */
-struct ahd_phase_table_entry {
-        uint8_t phase;
-        uint8_t mesg_out; /* Message response to parity errors */
-	char *phasemsg;
-};
-
-/************************** Serial EEPROM Format ******************************/
-
-struct seeprom_config {
-/*
- * Per SCSI ID Configuration Flags
- */
-	uint16_t device_flags[16];	/* words 0-15 */
-#define		CFXFER		0x003F	/* synchronous transfer rate */
-#define			CFXFER_ASYNC	0x3F
-#define		CFQAS		0x0040	/* Negotiate QAS */
-#define		CFPACKETIZED	0x0080	/* Negotiate Packetized Transfers */
-#define		CFSTART		0x0100	/* send start unit SCSI command */
-#define		CFINCBIOS	0x0200	/* include in BIOS scan */
-#define		CFDISC		0x0400	/* enable disconnection */
-#define		CFMULTILUNDEV	0x0800	/* Probe multiple luns in BIOS scan */
-#define		CFWIDEB		0x1000	/* wide bus device */
-#define		CFHOSTMANAGED	0x8000	/* Managed by a RAID controller */
-
-/*
- * BIOS Control Bits
- */
-	uint16_t bios_control;		/* word 16 */
-#define		CFSUPREM	0x0001	/* support all removeable drives */
-#define		CFSUPREMB	0x0002	/* support removeable boot drives */
-#define		CFBIOSSTATE	0x000C	/* BIOS Action State */
-#define		    CFBS_DISABLED	0x00
-#define		    CFBS_ENABLED	0x04
-#define		    CFBS_DISABLED_SCAN	0x08
-#define		CFENABLEDV	0x0010	/* Perform Domain Validation */
-#define		CFCTRL_A	0x0020	/* BIOS displays Ctrl-A message */	
-#define		CFSPARITY	0x0040	/* SCSI parity */
-#define		CFEXTEND	0x0080	/* extended translation enabled */
-#define		CFBOOTCD	0x0100  /* Support Bootable CD-ROM */
-#define		CFMSG_LEVEL	0x0600	/* BIOS Message Level */
-#define			CFMSG_VERBOSE	0x0000
-#define			CFMSG_SILENT	0x0200
-#define			CFMSG_DIAG	0x0400
-#define		CFRESETB	0x0800	/* reset SCSI bus at boot */
-/*		UNUSED		0xf000	*/
-
-/*
- * Host Adapter Control Bits
- */
-	uint16_t adapter_control;	/* word 17 */	
-#define		CFAUTOTERM	0x0001	/* Perform Auto termination */
-#define		CFSTERM		0x0002	/* SCSI low byte termination */
-#define		CFWSTERM	0x0004	/* SCSI high byte termination */
-#define		CFSEAUTOTERM	0x0008	/* Ultra2 Perform secondary Auto Term*/
-#define		CFSELOWTERM	0x0010	/* Ultra2 secondary low term */
-#define		CFSEHIGHTERM	0x0020	/* Ultra2 secondary high term */
-#define		CFSTPWLEVEL	0x0040	/* Termination level control */
-#define		CFBIOSAUTOTERM	0x0080	/* Perform Auto termination */
-#define		CFTERM_MENU	0x0100	/* BIOS displays termination menu */	
-#define		CFCLUSTERENB	0x8000	/* Cluster Enable */
-
-/*
- * Bus Release Time, Host Adapter ID
- */
-	uint16_t brtime_id;		/* word 18 */
-#define		CFSCSIID	0x000f	/* host adapter SCSI ID */
-/*		UNUSED		0x00f0	*/
-#define		CFBRTIME	0xff00	/* bus release time/PCI Latency Time */
-
-/*
- * Maximum targets
- */
-	uint16_t max_targets;		/* word 19 */	
-#define		CFMAXTARG	0x00ff	/* maximum targets */
-#define		CFBOOTLUN	0x0f00	/* Lun to boot from */
-#define		CFBOOTID	0xf000	/* Target to boot from */
-	uint16_t res_1[10];		/* words 20-29 */
-	uint16_t signature;		/* BIOS Signature */
-#define		CFSIGNATURE	0x400
-	uint16_t checksum;		/* word 31 */
-};
-
-/****************************** Flexport Logic ********************************/
-#define FLXADDR_TERMCTL			0x0
-#define		FLX_TERMCTL_ENSECHIGH	0x8
-#define		FLX_TERMCTL_ENSECLOW	0x4
-#define		FLX_TERMCTL_ENPRIHIGH	0x2
-#define		FLX_TERMCTL_ENPRILOW	0x1
-#define FLXADDR_ROMSTAT_CURSENSECTL	0x1
-#define		FLX_ROMSTAT_SEECFG	0xF0
-#define		FLX_ROMSTAT_EECFG	0x0F
-#define		FLX_ROMSTAT_SEE_93C66	0x00
-#define		FLX_ROMSTAT_SEE_NONE	0xF0
-#define		FLX_ROMSTAT_EE_512x8	0x0
-#define		FLX_ROMSTAT_EE_1MBx8	0x1
-#define		FLX_ROMSTAT_EE_2MBx8	0x2
-#define		FLX_ROMSTAT_EE_4MBx8	0x3
-#define		FLX_ROMSTAT_EE_16MBx8	0x4
-#define 		CURSENSE_ENB	0x1
-#define	FLXADDR_FLEXSTAT		0x2
-#define		FLX_FSTAT_BUSY		0x1
-#define FLXADDR_CURRENT_STAT		0x4
-#define		FLX_CSTAT_SEC_HIGH	0xC0
-#define		FLX_CSTAT_SEC_LOW	0x30
-#define		FLX_CSTAT_PRI_HIGH	0x0C
-#define		FLX_CSTAT_PRI_LOW	0x03
-#define		FLX_CSTAT_MASK		0x03
-#define		FLX_CSTAT_SHIFT		2
-#define		FLX_CSTAT_OKAY		0x0
-#define		FLX_CSTAT_OVER		0x1
-#define		FLX_CSTAT_UNDER		0x2
-#define		FLX_CSTAT_INVALID	0x3
-
-int		ahd_read_seeprom(struct ahd_softc *ahd, uint16_t *buf,
-				 u_int start_addr, u_int count);
-
-int		ahd_write_seeprom(struct ahd_softc *ahd, uint16_t *buf,
-				  u_int start_addr, u_int count);
-int		ahd_wait_seeprom(struct ahd_softc *ahd);
-int		ahd_verify_cksum(struct seeprom_config *sc);
-int		ahd_acquire_seeprom(struct ahd_softc *ahd);
-void		ahd_release_seeprom(struct ahd_softc *ahd);
-
-/****************************  Message Buffer *********************************/
-typedef enum {
-	MSG_FLAG_NONE			= 0x00,
-	MSG_FLAG_EXPECT_PPR_BUSFREE	= 0x01,
-	MSG_FLAG_IU_REQ_CHANGED		= 0x02,
-	MSG_FLAG_EXPECT_IDE_BUSFREE	= 0x04,
-	MSG_FLAG_EXPECT_QASREJ_BUSFREE	= 0x08,
-	MSG_FLAG_PACKETIZED		= 0x10
-} ahd_msg_flags;
-
-typedef enum {
-	MSG_TYPE_NONE			= 0x00,
-	MSG_TYPE_INITIATOR_MSGOUT	= 0x01,
-	MSG_TYPE_INITIATOR_MSGIN	= 0x02,
-	MSG_TYPE_TARGET_MSGOUT		= 0x03,
-	MSG_TYPE_TARGET_MSGIN		= 0x04
-} ahd_msg_type;
-
-typedef enum {
-	MSGLOOP_IN_PROG,
-	MSGLOOP_MSGCOMPLETE,
-	MSGLOOP_TERMINATED
-} msg_loop_stat;
-
-/*********************** Software Configuration Structure *********************/
-struct ahd_suspend_channel_state {
-	uint8_t	scsiseq;
-	uint8_t	sxfrctl0;
-	uint8_t	sxfrctl1;
-	uint8_t	simode0;
-	uint8_t	simode1;
-	uint8_t	seltimer;
-	uint8_t	seqctl;
-};
-
-struct ahd_suspend_state {
-	struct	ahd_suspend_channel_state channel[2];
-	uint8_t	optionmode;
-	uint8_t	dscommand0;
-	uint8_t	dspcistatus;
-	/* hsmailbox */
-	uint8_t	crccontrol1;
-	uint8_t	scbbaddr;
-	/* Host and sequencer SCB counts */
-	uint8_t	dff_thrsh;
-	uint8_t	*scratch_ram;
-	uint8_t	*btt;
-};
-
-typedef void (*ahd_bus_intr_t)(struct ahd_softc *);
-
-typedef enum {
-	AHD_MODE_DFF0,
-	AHD_MODE_DFF1,
-	AHD_MODE_CCHAN,
-	AHD_MODE_SCSI,
-	AHD_MODE_CFG,
-	AHD_MODE_UNKNOWN
-} ahd_mode;
-
-#define AHD_MK_MSK(x) (0x01 << (x))
-#define AHD_MODE_DFF0_MSK	AHD_MK_MSK(AHD_MODE_DFF0)
-#define AHD_MODE_DFF1_MSK	AHD_MK_MSK(AHD_MODE_DFF1)
-#define AHD_MODE_CCHAN_MSK	AHD_MK_MSK(AHD_MODE_CCHAN)
-#define AHD_MODE_SCSI_MSK	AHD_MK_MSK(AHD_MODE_SCSI)
-#define AHD_MODE_CFG_MSK	AHD_MK_MSK(AHD_MODE_CFG)
-#define AHD_MODE_UNKNOWN_MSK	AHD_MK_MSK(AHD_MODE_UNKNOWN)
-#define AHD_MODE_ANY_MSK (~0)
-
-typedef uint8_t ahd_mode_state;
-
-typedef void ahd_callback_t (void *);
-
-struct ahd_softc {
-	bus_space_tag_t           tags[2];
-	bus_space_handle_t        bshs[2];
-#ifndef __linux__
-	bus_dma_tag_t		  buffer_dmat;   /* dmat for buffer I/O */
-#endif
-	struct scb_data		  scb_data;
-
-	struct hardware_scb	 *next_queued_hscb;
-
-	/*
-	 * SCBs that have been sent to the controller
-	 */
-	LIST_HEAD(, scb)	  pending_scbs;
-
-	/*
-	 * Current register window mode information.
-	 */
-	ahd_mode		  dst_mode;
-	ahd_mode		  src_mode;
-
-	/*
-	 * Saved register window mode information
-	 * used for restore on next unpause.
-	 */
-	ahd_mode		  saved_dst_mode;
-	ahd_mode		  saved_src_mode;
-
-	/*
-	 * Platform specific data.
-	 */
-	struct ahd_platform_data *platform_data;
-
-	/*
-	 * Platform specific device information.
-	 */
-	ahd_dev_softc_t		  dev_softc;
-
-	/*
-	 * Bus specific device information.
-	 */
-	ahd_bus_intr_t		  bus_intr;
-
-	/*
-	 * Target mode related state kept on a per enabled lun basis.
-	 * Targets that are not enabled will have null entries.
-	 * As an initiator, we keep one target entry for our initiator
-	 * ID to store our sync/wide transfer settings.
-	 */
-	struct ahd_tmode_tstate  *enabled_targets[AHD_NUM_TARGETS];
-
-	/*
-	 * The black hole device responsible for handling requests for
-	 * disabled luns on enabled targets.
-	 */
-	struct ahd_tmode_lstate  *black_hole;
-
-	/*
-	 * Device instance currently on the bus awaiting a continue TIO
-	 * for a command that was not given the disconnect priveledge.
-	 */
-	struct ahd_tmode_lstate  *pending_device;
-
-	/*
-	 * Timer handles for timer driven callbacks.
-	 */
-	ahd_timer_t		  reset_timer;
-	ahd_timer_t		  stat_timer;
-
-	/*
-	 * Statistics.
-	 */
-#define	AHD_STAT_UPDATE_US	250000 /* 250ms */
-#define	AHD_STAT_BUCKETS	4
-	u_int			  cmdcmplt_bucket;
-	uint32_t		  cmdcmplt_counts[AHD_STAT_BUCKETS];
-	uint32_t		  cmdcmplt_total;
-
-	/*
-	 * Card characteristics
-	 */
-	ahd_chip		  chip;
-	ahd_feature		  features;
-	ahd_bug			  bugs;
-	ahd_flag		  flags;
-	struct seeprom_config	 *seep_config;
-
-	/* Values to store in the SEQCTL register for pause and unpause */
-	uint8_t			  unpause;
-	uint8_t			  pause;
-
-	/* Command Queues */
-	uint16_t		  qoutfifonext;
-	uint16_t		  qoutfifonext_valid_tag;
-	uint16_t		  qinfifonext;
-	uint16_t		  qinfifo[AHD_SCB_MAX];
-	uint16_t		 *qoutfifo;
-
-	/* Critical Section Data */
-	struct cs		 *critical_sections;
-	u_int			  num_critical_sections;
-
-	/* Buffer for handling packetized bitbucket. */
-	uint8_t			 *overrun_buf;
-
-	/* Links for chaining softcs */
-	TAILQ_ENTRY(ahd_softc)	  links;
-
-	/* Channel Names ('A', 'B', etc.) */
-	char			  channel;
-
-	/* Initiator Bus ID */
-	uint8_t			  our_id;
-
-	/*
-	 * Target incoming command FIFO.
-	 */
-	struct target_cmd	 *targetcmds;
-	uint8_t			  tqinfifonext;
-
-	/*
-	 * Cached verson of the hs_mailbox so we can avoid
-	 * pausing the sequencer during mailbox updates.
-	 */
-	uint8_t			  hs_mailbox;
-
-	/*
-	 * Incoming and outgoing message handling.
-	 */
-	uint8_t			  send_msg_perror;
-	ahd_msg_flags		  msg_flags;
-	ahd_msg_type		  msg_type;
-	uint8_t			  msgout_buf[12];/* Message we are sending */
-	uint8_t			  msgin_buf[12];/* Message we are receiving */
-	u_int			  msgout_len;	/* Length of message to send */
-	u_int			  msgout_index;	/* Current index in msgout */
-	u_int			  msgin_index;	/* Current index in msgin */
-
-	/*
-	 * Mapping information for data structures shared
-	 * between the sequencer and kernel.
-	 */
-	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;
-
-	/* Information saved through suspend/resume cycles */
-	struct ahd_suspend_state  suspend_state;
-
-	/* Number of enabled target mode device on this card */
-	u_int			  enabled_luns;
-
-	/* Initialization level of this data structure */
-	u_int			  init_level;
-
-	/* PCI cacheline size. */
-	u_int			  pci_cachesize;
-
-	/* IO Cell Parameters */
-	uint8_t			  iocell_opts[AHD_NUM_PER_DEV_ANNEXCOLS];
-
-	u_int			  stack_size;
-	uint16_t		 *saved_stack;
-
-	/* Per-Unit descriptive information */
-	const char		 *description;
-	const char		 *bus_description;
-	char			 *name;
-	int			  unit;
-
-	/* Selection Timer settings */
-	int			  seltime;
-
-	/*
-	 * Interrupt coalessing settings.
-	 */
-#define	AHD_INT_COALESSING_TIMER_DEFAULT		250 /*us*/
-#define	AHD_INT_COALESSING_MAXCMDS_DEFAULT		10
-#define	AHD_INT_COALESSING_MAXCMDS_MAX			127
-#define	AHD_INT_COALESSING_MINCMDS_DEFAULT		5
-#define	AHD_INT_COALESSING_MINCMDS_MAX			127
-#define	AHD_INT_COALESSING_THRESHOLD_DEFAULT		2000
-#define	AHD_INT_COALESSING_STOP_THRESHOLD_DEFAULT	1000
-	u_int			  int_coalessing_timer;
-	u_int			  int_coalessing_maxcmds;
-	u_int			  int_coalessing_mincmds;
-	u_int			  int_coalessing_threshold;
-	u_int			  int_coalessing_stop_threshold;
-
-	uint16_t	 	  user_discenable;/* Disconnection allowed  */
-	uint16_t		  user_tagenable;/* Tagged Queuing allowed */
-};
-
-TAILQ_HEAD(ahd_softc_tailq, ahd_softc);
-extern struct ahd_softc_tailq ahd_tailq;
-
-/*************************** IO Cell Configuration ****************************/
-#define	AHD_PRECOMP_SLEW_INDEX						\
-    (AHD_ANNEXCOL_PRECOMP_SLEW - AHD_ANNEXCOL_PER_DEV0)
-
-#define	AHD_AMPLITUDE_INDEX						\
-    (AHD_ANNEXCOL_AMPLITUDE - AHD_ANNEXCOL_PER_DEV0)
-
-#define AHD_SET_SLEWRATE(ahd, new_slew)					\
-do {									\
-    (ahd)->iocell_opts[AHD_PRECOMP_SLEW_INDEX] &= ~AHD_SLEWRATE_MASK;	\
-    (ahd)->iocell_opts[AHD_PRECOMP_SLEW_INDEX] |=			\
-	(((new_slew) << AHD_SLEWRATE_SHIFT) & AHD_SLEWRATE_MASK);	\
-} while (0)
-
-#define AHD_SET_PRECOMP(ahd, new_pcomp)					\
-do {									\
-    (ahd)->iocell_opts[AHD_PRECOMP_SLEW_INDEX] &= ~AHD_PRECOMP_MASK;	\
-    (ahd)->iocell_opts[AHD_PRECOMP_SLEW_INDEX] |=			\
-	(((new_pcomp) << AHD_PRECOMP_SHIFT) & AHD_PRECOMP_MASK);	\
-} while (0)
-
-#define AHD_SET_AMPLITUDE(ahd, new_amp)					\
-do {									\
-    (ahd)->iocell_opts[AHD_AMPLITUDE_INDEX] &= ~AHD_AMPLITUDE_MASK;	\
-    (ahd)->iocell_opts[AHD_AMPLITUDE_INDEX] |=				\
-	(((new_amp) << AHD_AMPLITUDE_SHIFT) & AHD_AMPLITUDE_MASK);	\
-} while (0)
-
-/************************ Active Device Information ***************************/
-typedef enum {
-	ROLE_UNKNOWN,
-	ROLE_INITIATOR,
-	ROLE_TARGET
-} role_t;
-
-struct ahd_devinfo {
-	int	 our_scsiid;
-	int	 target_offset;
-	uint16_t target_mask;
-	u_int	 target;
-	u_int	 lun;
-	char	 channel;
-	role_t	 role;		/*
-				 * Only guaranteed to be correct if not
-				 * in the busfree state.
-				 */
-};
-
-/****************************** PCI Structures ********************************/
-#define AHD_PCI_IOADDR0	PCIR_MAPS	/* I/O BAR*/
-#define AHD_PCI_MEMADDR	(PCIR_MAPS + 4)	/* Memory BAR */
-#define AHD_PCI_IOADDR1	(PCIR_MAPS + 12)/* Second I/O BAR */
-
-typedef int (ahd_device_setup_t)(struct ahd_softc *);
-
-struct ahd_pci_identity {
-	uint64_t		 full_id;
-	uint64_t		 id_mask;
-	char			*name;
-	ahd_device_setup_t	*setup;
-};
-extern struct ahd_pci_identity ahd_pci_ident_table [];
-extern const u_int ahd_num_pci_devs;
-
-/***************************** VL/EISA Declarations ***************************/
-struct aic7770_identity {
-	uint32_t		 full_id;
-	uint32_t		 id_mask;
-	char			*name;
-	ahd_device_setup_t	*setup;
-};
-extern struct aic7770_identity aic7770_ident_table [];
-extern const int ahd_num_aic7770_devs;
-
-#define AHD_EISA_SLOT_OFFSET	0xc00
-#define AHD_EISA_IOSIZE		0x100
-
-/*************************** Function Declarations ****************************/
-/******************************************************************************/
-void			ahd_reset_cmds_pending(struct ahd_softc *ahd);
-u_int			ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl);
-void			ahd_busy_tcl(struct ahd_softc *ahd,
-				     u_int tcl, u_int busyid);
-static __inline void	ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl);
-static __inline void
-ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl)
-{
-	ahd_busy_tcl(ahd, tcl, SCB_LIST_NULL);
-}
-
-/***************************** PCI Front End *********************************/
-struct	ahd_pci_identity *ahd_find_pci_device(ahd_dev_softc_t);
-int			  ahd_pci_config(struct ahd_softc *,
-					 struct ahd_pci_identity *);
-int	ahd_pci_test_register_access(struct ahd_softc *);
-
-/************************** SCB and SCB queue management **********************/
-int		ahd_probe_scbs(struct ahd_softc *);
-void		ahd_qinfifo_requeue_tail(struct ahd_softc *ahd,
-					 struct scb *scb);
-int		ahd_match_scb(struct ahd_softc *ahd, struct scb *scb,
-			      int target, char channel, int lun,
-			      u_int tag, role_t role);
-
-/****************************** Initialization ********************************/
-struct ahd_softc	*ahd_alloc(void *platform_arg, char *name);
-int			 ahd_softc_init(struct ahd_softc *);
-void			 ahd_controller_info(struct ahd_softc *ahd, char *buf);
-int			 ahd_init(struct ahd_softc *ahd);
-int			 ahd_default_config(struct ahd_softc *ahd);
-int			 ahd_parse_cfgdata(struct ahd_softc *ahd,
-					   struct seeprom_config *sc);
-void			 ahd_intr_enable(struct ahd_softc *ahd, int enable);
-void			 ahd_update_coalessing_values(struct ahd_softc *ahd,
-						      u_int timer,
-						      u_int maxcmds,
-						      u_int mincmds);
-void			 ahd_enable_coalessing(struct ahd_softc *ahd,
-					       int enable);
-void			 ahd_pause_and_flushwork(struct ahd_softc *ahd);
-int			 ahd_suspend(struct ahd_softc *ahd); 
-int			 ahd_resume(struct ahd_softc *ahd);
-void			 ahd_softc_insert(struct ahd_softc *);
-struct ahd_softc	*ahd_find_softc(struct ahd_softc *ahd);
-void			 ahd_set_unit(struct ahd_softc *, int);
-void			 ahd_set_name(struct ahd_softc *, char *);
-struct scb		*ahd_get_scb(struct ahd_softc *ahd, u_int col_idx);
-void			 ahd_free_scb(struct ahd_softc *ahd, struct scb *scb);
-void			 ahd_alloc_scbs(struct ahd_softc *ahd);
-void			 ahd_free(struct ahd_softc *ahd);
-int			 ahd_reset(struct ahd_softc *ahd);
-void			 ahd_shutdown(void *arg);
-int			ahd_write_flexport(struct ahd_softc *ahd,
-					   u_int addr, u_int value);
-int			ahd_read_flexport(struct ahd_softc *ahd, u_int addr,
-					  uint8_t *value);
-int			ahd_wait_flexport(struct ahd_softc *ahd);
-
-/*************************** Interrupt Services *******************************/
-void			ahd_pci_intr(struct ahd_softc *ahd);
-void			ahd_clear_intstat(struct ahd_softc *ahd);
-void			ahd_flush_qoutfifo(struct ahd_softc *ahd);
-void			ahd_run_qoutfifo(struct ahd_softc *ahd);
-#ifdef AHD_TARGET_MODE
-void			ahd_run_tqinfifo(struct ahd_softc *ahd, int paused);
-#endif
-void			ahd_handle_hwerrint(struct ahd_softc *ahd);
-void			ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat);
-void			ahd_handle_scsiint(struct ahd_softc *ahd,
-					   u_int intstat);
-void			ahd_clear_critical_section(struct ahd_softc *ahd);
-
-/***************************** Error Recovery *********************************/
-typedef enum {
-	SEARCH_COMPLETE,
-	SEARCH_COUNT,
-	SEARCH_REMOVE,
-	SEARCH_PRINT
-} ahd_search_action;
-int			ahd_search_qinfifo(struct ahd_softc *ahd, int target,
-					   char channel, int lun, u_int tag,
-					   role_t role, uint32_t status,
-					   ahd_search_action action);
-int			ahd_search_disc_list(struct ahd_softc *ahd, int target,
-					     char channel, int lun, u_int tag,
-					     int stop_on_first, int remove,
-					     int save_state);
-void			ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb);
-int			ahd_reset_channel(struct ahd_softc *ahd, char channel,
-					  int initiate_reset);
-int			ahd_abort_scbs(struct ahd_softc *ahd, int target,
-				       char channel, int lun, u_int tag,
-				       role_t role, uint32_t status);
-void			ahd_restart(struct ahd_softc *ahd);
-void			ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo);
-void			ahd_handle_scb_status(struct ahd_softc *ahd,
-					      struct scb *scb);
-void			ahd_handle_scsi_status(struct ahd_softc *ahd,
-					       struct scb *scb);
-void			ahd_calc_residual(struct ahd_softc *ahd,
-					  struct scb *scb);
-/*************************** Utility Functions ********************************/
-struct ahd_phase_table_entry*
-			ahd_lookup_phase_entry(int phase);
-void			ahd_compile_devinfo(struct ahd_devinfo *devinfo,
-					    u_int our_id, u_int target,
-					    u_int lun, char channel,
-					    role_t role);
-/************************** Transfer Negotiation ******************************/
-void			ahd_find_syncrate(struct ahd_softc *ahd, u_int *period,
-					  u_int *ppr_options, u_int maxsync);
-void			ahd_validate_offset(struct ahd_softc *ahd,
-					    struct ahd_initiator_tinfo *tinfo,
-					    u_int period, u_int *offset,
-					    int wide, role_t role);
-void			ahd_validate_width(struct ahd_softc *ahd,
-					   struct ahd_initiator_tinfo *tinfo,
-					   u_int *bus_width,
-					   role_t role);
-/*
- * Negotiation types.  These are used to qualify if we should renegotiate
- * even if our goal and current transport parameters are identical.
- */
-typedef enum {
-	AHD_NEG_TO_GOAL,	/* Renegotiate only if goal and curr differ. */
-	AHD_NEG_IF_NON_ASYNC,	/* Renegotiate so long as goal is non-async. */
-	AHD_NEG_ALWAYS		/* Renegotiat even if goal is async. */
-} ahd_neg_type;
-int			ahd_update_neg_request(struct ahd_softc*,
-					       struct ahd_devinfo*,
-					       struct ahd_tmode_tstate*,
-					       struct ahd_initiator_tinfo*,
-					       ahd_neg_type);
-void			ahd_set_width(struct ahd_softc *ahd,
-				      struct ahd_devinfo *devinfo,
-				      u_int width, u_int type, int paused);
-void			ahd_set_syncrate(struct ahd_softc *ahd,
-					 struct ahd_devinfo *devinfo,
-					 u_int period, u_int offset,
-					 u_int ppr_options,
-					 u_int type, int paused);
-typedef enum {
-	AHD_QUEUE_NONE,
-	AHD_QUEUE_BASIC,
-	AHD_QUEUE_TAGGED
-} ahd_queue_alg;
-
-void			ahd_set_tags(struct ahd_softc *ahd,
-				     struct ahd_devinfo *devinfo,
-				     ahd_queue_alg alg);
-
-/**************************** Target Mode *************************************/
-#ifdef AHD_TARGET_MODE
-void		ahd_send_lstate_events(struct ahd_softc *,
-				       struct ahd_tmode_lstate *);
-void		ahd_handle_en_lun(struct ahd_softc *ahd,
-				  struct cam_sim *sim, union ccb *ccb);
-cam_status	ahd_find_tmode_devs(struct ahd_softc *ahd,
-				    struct cam_sim *sim, union ccb *ccb,
-				    struct ahd_tmode_tstate **tstate,
-				    struct ahd_tmode_lstate **lstate,
-				    int notfound_failure);
-#ifndef AHD_TMODE_ENABLE
-#define AHD_TMODE_ENABLE 0
-#endif
-#endif
-/******************************* Debug ***************************************/
-#ifdef AHD_DEBUG
-extern uint32_t ahd_debug;
-#define AHD_SHOW_MISC		0x00001
-#define AHD_SHOW_SENSE		0x00002
-#define AHD_SHOW_RECOVERY	0x00004
-#define AHD_DUMP_SEEPROM	0x00008
-#define AHD_SHOW_TERMCTL	0x00010
-#define AHD_SHOW_MEMORY		0x00020
-#define AHD_SHOW_MESSAGES	0x00040
-#define AHD_SHOW_MODEPTR	0x00080
-#define AHD_SHOW_SELTO		0x00100
-#define AHD_SHOW_FIFOS		0x00200
-#define AHD_SHOW_QFULL		0x00400
-#define	AHD_SHOW_DV		0x00800
-#define AHD_SHOW_MASKED_ERRORS	0x01000
-#define AHD_SHOW_QUEUE		0x02000
-#define AHD_SHOW_TQIN		0x04000
-#define AHD_SHOW_SG		0x08000
-#define AHD_SHOW_INT_COALESSING	0x10000
-#define AHD_DEBUG_SEQUENCER	0x20000
-#endif
-void			ahd_print_scb(struct scb *scb);
-void			ahd_print_devinfo(struct ahd_softc *ahd,
-					  struct ahd_devinfo *devinfo);
-void			ahd_dump_sglist(struct scb *scb);
-void			ahd_dump_all_cards_state(void);
-void			ahd_dump_card_state(struct ahd_softc *ahd);
-int			ahd_print_register(ahd_reg_parse_entry_t *table,
-					   u_int num_entries,
-					   const char *name,
-					   u_int address,
-					   u_int value,
-					   u_int *cur_column,
-					   u_int wrap_point);
-void			ahd_dump_scbs(struct ahd_softc *ahd);
-#endif /* _AIC79XX_H_ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aic79xx.reg linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx.reg
--- linux-2.4.21/drivers/scsi/aic79xx/aic79xx.reg	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx.reg	2003-06-26 21:43:11.000000000 +0000
@@ -1,3950 +0,0 @@
-/*
- * Aic79xx register and scratch ram definitions.
- *
- * Copyright (c) 1994-2001 Justin T. Gibbs.
- * Copyright (c) 2000-2002 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.
- *
- * $FreeBSD$
- */
-VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#60 $"
-
-/*
- * This file is processed by the aic7xxx_asm utility for use in assembling
- * firmware for the aic79xx family of SCSI host adapters as well as to generate
- * a C header file for use in the kernel portion of the Aic79xx driver.
- */
-
-/* Register window Modes */
-#define M_DFF0		0
-#define M_DFF1		1
-#define M_CCHAN		2
-#define M_SCSI		3
-#define M_CFG		4
-#define M_DST_SHIFT	4
-
-#define MK_MODE(src, dst) ((src) | ((dst) << M_DST_SHIFT))
-#define SET_MODE(src, dst)						\
-	SET_SRC_MODE	src;						\
-	SET_DST_MODE	dst;						\
-	if ((ahd->bugs & AHD_SET_MODE_BUG) != 0) {			\
-		mvi	MK_MODE(src, dst) call set_mode_work_around;	\
-	} else {							\
-		mvi	MODE_PTR, MK_MODE(src, dst);			\
-	}
-
-#define TOGGLE_DFF_MODE							\
-	if ((ahd->bugs & AHD_SET_MODE_BUG) != 0) {			\
-		call	toggle_dff_mode_work_around;			\
-	} else {							\
-		xor	MODE_PTR, MK_MODE(M_DFF1, M_DFF1);		\
-	}
-	
-#define RESTORE_MODE(mode)						\
-	if ((ahd->bugs & AHD_SET_MODE_BUG) != 0) {			\
-		mov	mode call set_mode_work_around;			\
-	} else {							\
-		mov	MODE_PTR, mode;					\
-	}
-
-#define SET_SEQINTCODE(code)						\
-	if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) {			\
-		mvi	code call set_seqint_work_around;		\
-	} else {							\
-		mvi	SEQINTCODE, code;				\
-	}
-
-/*
- * Mode Pointer
- * Controls which of the 5, 512byte, address spaces should be used
- * as the source and destination of any register accesses in our
- * register window.
- */
-register MODE_PTR {
-	address			0x000
-	access_mode	RW
-	field	DST_MODE	0x70
-	field	SRC_MODE	0x07
-	mode_pointer
-}
-
-const SRC_MODE_SHIFT	0
-const DST_MODE_SHIFT	4
-
-/*
- * Host Interrupt Status
- */
-register INTSTAT {
-	address			0x001
-	access_mode	RW
-	field	HWERRINT	0x80
-	field	BRKADRINT	0x40
-	field	SWTMINT		0x20
-	field	PCIINT		0x10
-	field	SCSIINT		0x08
-	field	SEQINT		0x04
-	field	CMDCMPLT	0x02
-	field	SPLTINT		0x01
-	mask	INT_PEND 0xFF
-}
-
-/*
- * Sequencer Interrupt Code
- */
-register SEQINTCODE {
-	address			0x002
-	access_mode	RW
-	field {
-		NO_SEQINT,			/* No seqint pending. */
-		BAD_PHASE,			/* unknown scsi bus phase */
-		SEND_REJECT,			/* sending a message reject */
-		PROTO_VIOLATION, 		/* Protocol Violation */
-		NO_MATCH,			/* no cmd match for reconnect */
-		IGN_WIDE_RES,			/* Complex IGN Wide Res Msg */
-		PDATA_REINIT,			/*
-						 * Returned to data phase
-						 * that requires data
-						 * transfer pointers to be
-						 * recalculated from the
-						 * transfer residual.
-						 */
-		HOST_MSG_LOOP,			/*
-						 * The bus is ready for the
-						 * host to perform another
-						 * message transaction.  This
-						 * mechanism is used for things
-						 * like sync/wide negotiation
-						 * that require a kernel based
-						 * message state engine.
-						 */
-		BAD_STATUS,			/* Bad status from target */
-		DATA_OVERRUN,			/*
-						 * Target attempted to write
-						 * beyond the bounds of its
-						 * command.
-						 */
-		MKMSG_FAILED,			/*
-						 * Target completed command
-						 * without honoring our ATN
-						 * request to issue a message. 
-						 */
-		MISSED_BUSFREE,			/*
-						 * The sequencer never saw
-						 * the bus go free after
-						 * either a command complete
-						 * or disconnect message.
-						 */
-		DUMP_CARD_STATE,
-		ILLEGAL_PHASE,
-		INVALID_SEQINT,
-		CFG4ISTAT_INTR,
-		STATUS_OVERRUN,
-		CFG4OVERRUN,
-		ENTERING_NONPACK,
-		TASKMGMT_FUNC_COMPLETE,		/*
-						 * Task management function
-						 * request completed with
-						 * an expected busfree.
-						 */
-		TASKMGMT_CMD_CMPLT_OKAY,	/*
-						 * A command with a non-zero
-						 * task management function
-						 * has completed via the normal
-						 * command completion method
-						 * for commands with a zero
-						 * task management function.
-						 * This happens when an attempt
-						 * to abort a command loses
-						 * the race for the command to
-						 * complete normally.
-						 */
-		TRACEPOINT0,
-		TRACEPOINT1,
-		TRACEPOINT2,
-		TRACEPOINT3,
-		SAW_HWERR
-	}
-}
-
-/*
- * Clear Host Interrupt
- */
-register CLRINT {
-	address			0x003
-	access_mode	WO
-	field	CLRHWERRINT	0x80 /* Rev B or greater */
-	field	CLRBRKADRINT	0x40
-	field	CLRSWTMINT	0x20
-	field	CLRPCIINT	0x10
-	field	CLRSCSIINT	0x08
-	field	CLRSEQINT	0x04
-	field	CLRCMDINT	0x02
-	field	CLRSPLTINT	0x01
-}
-
-/*
- * Error Register
- */
-register ERROR {
-	address			0x004
-	access_mode	RO
-	field	CIOPARERR	0x80
-	field	CIOACCESFAIL	0x40 /* Rev B or greater */
-	field	MPARERR		0x20
-	field	DPARERR		0x10
-	field	SQPARERR	0x08
-	field	ILLOPCODE	0x04
-	field	DSCTMOUT	0x02
-}
-
-/*
- * Clear Error
- */
-register CLRERR {
-	address			0x004
-	access_mode 	WO
-	field	CLRCIOPARERR	0x80
-	field	CLRCIOACCESFAIL	0x40 /* Rev B or greater */
-	field	CLRMPARERR	0x20
-	field	CLRDPARERR	0x10
-	field	CLRSQPARERR	0x08
-	field	CLRILLOPCODE	0x04
-	field	CLRDSCTMOUT	0x02
-}
-
-/*
- * Host Control Register
- * Overall host control of the device.
- */
-register HCNTRL {
-	address			0x005
-	access_mode	RW
-	field	SEQ_RESET	0x80 /* Rev B or greater */
-	field	POWRDN		0x40
-	field	SWINT		0x10
-	field	SWTIMER_START_B	0x08 /* Rev B or greater */
-	field	PAUSE		0x04
-	field	INTEN		0x02
-	field	CHIPRST		0x01
-	field	CHIPRSTACK	0x01
-}
-
-/*
- * Host New SCB Queue Offset
- */
-register HNSCB_QOFF {
-	address			0x006
-	access_mode	RW
-	size		2
-}
-
-/*
- * Host Empty SCB Queue Offset
- */
-register HESCB_QOFF {
-	address			0x008
-	access_mode	RW
-}
-
-/*
- * Host Mailbox
- */
-register HS_MAILBOX {
-	address			0x00B
-	access_mode	RW
-	mask	HOST_TQINPOS	0x80	/* Boundary at either 0 or 128 */
-	mask	ENINT_COALESS	0x40	/* Perform interrupt coalessing */
-}
-
-/*
- * Sequencer Interupt Status
- */
-register SEQINTSTAT {
-	address			0x00C
-	access_mode	RO
-	field	SEQ_SWTMRTO	0x10
-	field	SEQ_SEQINT	0x08
-	field	SEQ_SCSIINT	0x04
-	field	SEQ_PCIINT	0x02
-	field	SEQ_SPLTINT	0x01
-}
-
-/*
- * Clear SEQ Interrupt
- */
-register CLRSEQINTSTAT {
-	address			0x00C
-	access_mode	WO
-	field	CLRSEQ_SWTMRTO	0x10
-	field	CLRSEQ_SEQINT	0x08
-	field	CLRSEQ_SCSIINT	0x04
-	field	CLRSEQ_PCIINT	0x02
-	field	CLRSEQ_SPLTINT	0x01
-}
-
-/*
- * Software Timer
- */
-register SWTIMER {
-	address			0x00E
-	access_mode	RW
-	size		2
-}
-
-/*
- * SEQ New SCB Queue Offset
- */
-register SNSCB_QOFF {
-	address			0x010
-	access_mode	RW
-	size		2
-	modes		M_CCHAN
-}
-
-/*
- * SEQ Empty SCB Queue Offset
- */
-register SESCB_QOFF {
-	address			0x012
-	access_mode	RW
-	modes		M_CCHAN
-}
-
-/*
- * SEQ Done SCB Queue Offset
- */
-register SDSCB_QOFF {
-	address			0x014
-	access_mode	RW
-	modes		M_CCHAN
-	size		2
-}
-
-/*
- * Queue Offset Control & Status
- */
-register QOFF_CTLSTA {
-	address			0x016
-	access_mode	RW
-	modes		M_CCHAN
-	field	EMPTY_SCB_AVAIL	0x80
-	field	NEW_SCB_AVAIL	0x40
-	field	SDSCB_ROLLOVR	0x20
-	field	HS_MAILBOX_ACT	0x10
-	field	SCB_QSIZE	0x0F {
-		SCB_QSIZE_4,
-		SCB_QSIZE_8,
-		SCB_QSIZE_16,
-		SCB_QSIZE_32,
-		SCB_QSIZE_64,
-		SCB_QSIZE_128,
-		SCB_QSIZE_256,
-		SCB_QSIZE_512,
-		SCB_QSIZE_1024,
-		SCB_QSIZE_2048,
-		SCB_QSIZE_4096,
-		SCB_QSIZE_8192,
-		SCB_QSIZE_16384
-	}
-}
-
-/*
- * Interrupt Control
- */
-register INTCTL {
-	address			0x018
-	access_mode	RW
-	field	SWTMINTMASK	0x80
-	field	SWTMINTEN	0x40
-	field	SWTIMER_START	0x20
-	field	AUTOCLRCMDINT	0x10
-	field	PCIINTEN	0x08
-	field	SCSIINTEN	0x04
-	field	SEQINTEN	0x02
-	field	SPLTINTEN	0x01
-}
-
-/*
- * Data FIFO Control
- */
-register DFCNTRL {
-	address			0x019
-	access_mode	RW
-	modes		M_DFF0, M_DFF1
-	field	PRELOADEN	0x80
-	field	SCSIENWRDIS	0x40	/* Rev B only. */
-	field	SCSIEN		0x20
-	field	SCSIENACK	0x20
-	field	HDMAEN		0x08
-	field	HDMAENACK	0x08
-	field	DIRECTION	0x04
-	field	DIRECTIONACK	0x04
-	field	FIFOFLUSH	0x02
-	field	FIFOFLUSHACK	0x02
-	field	DIRECTIONEN	0x01
-}
-
-/*
- * Device Space Command 0
- */
-register DSCOMMAND0 {
-	address			0x019
-	access_mode	RW
-	modes		M_CFG
-	field	CACHETHEN	0x80	/* Cache Threshold enable */
-	field	DPARCKEN	0x40	/* Data Parity Check Enable */
-	field	MPARCKEN	0x20	/* Memory Parity Check Enable */
-	field	EXTREQLCK	0x10	/* External Request Lock */
-	field	DISABLE_TWATE	0x02	/* Rev B or greater */
-	field	CIOPARCKEN	0x01	/* Internal bus parity error enable */
-}
-
-/*
- * Data FIFO Status
- */
-register DFSTATUS {
-	address			0x01A
-	access_mode	RO
-	modes		M_DFF0, M_DFF1
-	field	PRELOAD_AVAIL		0x80
-	field	PKT_PRELOAD_AVAIL	0x40
-	field	MREQPEND		0x10
-	field	HDONE			0x08
-	field	DFTHRESH		0x04
-	field	FIFOFULL		0x02
-	field	FIFOEMP			0x01
-}
-
-/*
- * S/G Cache Pointer
- */
-register SG_CACHE_PRE {
-	address			0x01B
-	access_mode	WO
-	modes		M_DFF0, M_DFF1
-	field	SG_ADDR_MASK	0xf8
-	field	ODD_SEG		0x04
-	field	LAST_SEG	0x02
-}
-
-register SG_CACHE_SHADOW {
-	address			0x01B
-	access_mode	RO
-	modes		M_DFF0, M_DFF1
-	field	SG_ADDR_MASK	0xf8
-	field	ODD_SEG		0x04
-	field	LAST_SEG	0x02
-	field	LAST_SEG_DONE	0x01
-}
-
-/*
- * Arbiter Control
- */
-register ARBCTL {
-	address			0x01B
-	access_mode	RW
-	modes		M_CFG
-	field	RESET_HARB	0x80
-	field	RETRY_SWEN	0x08
-	field	USE_TIME	0x07
-}
-
-/*
- * Data Channel Host Address
- */
-register HADDR {
-	address			0x070
-	access_mode	RW
-	size		8
-	modes		M_DFF0, M_DFF1
-}
-
-/*
- * Host Overlay DMA Address
- */
-register HODMAADR {
-	address			0x070
-	access_mode	RW
-	size		8
-	modes		M_SCSI
-}
-
-/*
- * PCI PLL Delay.
- */
-register PLLDELAY {
-	address			0x070
-	access_mode	RW
-	size		1
-	modes		M_CFG
-	field	SPLIT_DROP_REQ	0x80
-}
-
-/*
- * Data Channel Host Count
- */
-register HCNT {
-	address			0x078
-	access_mode	RW
-	size		3
-	modes		M_DFF0, M_DFF1
-}
-
-/*
- * Host Overlay DMA Count
- */
-register HODMACNT {
-	address			0x078
-	access_mode	RW
-	size		2
-	modes		M_SCSI
-}
-
-/*
- * Host Overlay DMA Enable
- */
-register HODMAEN {
-	address			0x07A
-	access_mode	RW
-	modes		M_SCSI
-}
-
-/*
- * Scatter/Gather Host Address
- */
-register SGHADDR {
-	address			0x07C
-	access_mode	RW
-	size		8
-	modes		M_DFF0, M_DFF1
-}
-
-/*
- * SCB Host Address
- */
-register SCBHADDR {
-	address			0x07C
-	access_mode	RW
-	size		8
-	modes		M_CCHAN
-}
-
-/*
- * Scatter/Gather Host Count
- */
-register SGHCNT {
-	address			0x084
-	access_mode	RW
-	modes		M_DFF0, M_DFF1
-}
-
-/*
- * SCB Host Count
- */
-register SCBHCNT {
-	address			0x084
-	access_mode	RW
-	modes		M_CCHAN
-}
-
-/*
- * Data FIFO Threshold
- */
-register DFF_THRSH {
-	address			0x088
-	access_mode	RW
-	modes		M_CFG
-	field	WR_DFTHRSH	0x70 {
-		WR_DFTHRSH_MIN,
-		WR_DFTHRSH_25,
-		WR_DFTHRSH_50,
-		WR_DFTHRSH_63,
-		WR_DFTHRSH_75,
-		WR_DFTHRSH_85,
-		WR_DFTHRSH_90,
-		WR_DFTHRSH_MAX
-	}
-	field	RD_DFTHRSH	0x07 {
-		RD_DFTHRSH_MIN,
-		RD_DFTHRSH_25,
-		RD_DFTHRSH_50,
-		RD_DFTHRSH_63,
-		RD_DFTHRSH_75,
-		RD_DFTHRSH_85,
-		RD_DFTHRSH_90,
-		RD_DFTHRSH_MAX
-	}
-}
-
-/*
- * ROM Address
- */
-register ROMADDR {
-	address			0x08A
-	access_mode	RW
-	size		3
-}
-
-/*
- * ROM Control
- */
-register ROMCNTRL {
-	address			0x08D
-	access_mode	RW
-	field	ROMOP		0xE0
-	field	ROMSPD		0x18
-	field	REPEAT		0x02
-	field	RDY		0x01
-}
-
-/*
- * ROM Data
- */
-register ROMDATA {
-	address			0x08E
-	access_mode	RW
-}
-
-/*
- * Data Channel Receive Message 0
- */
-register DCHRXMSG0 {
-	address			0x090
-	access_mode	RO
-	modes		M_DFF0, M_DFF1
-	field		CDNUM	0xF8
-	field		CFNUM	0x07
-}
-
-/*
- * CMC Recieve Message 0
- */
-register CMCRXMSG0 {
-	address			0x090
-	access_mode	RO
-	modes		M_CCHAN
-	field		CDNUM	0xF8
-	field		CFNUM	0x07
-}
-
-/*
- * Overlay Recieve Message 0
- */
-register OVLYRXMSG0 {
-	address			0x090
-	access_mode	RO
-	modes		M_SCSI
-	field		CDNUM	0xF8
-	field		CFNUM	0x07
-}
-
-/*
- * Relaxed Order Enable
- */
-register ROENABLE {
-	address			0x090
-	access_mode	RW
-	modes		M_CFG
-	field	MSIROEN		0x20
-	field	OVLYROEN	0x10
-	field	CMCROEN		0x08
-	field	SGROEN		0x04
-	field	DCH1ROEN	0x02
-	field	DCH0ROEN	0x01
-}
-
-/*
- * Data Channel Receive Message 1
- */
-register DCHRXMSG1 {
-	address			0x091
-	access_mode	RO
-	modes		M_DFF0, M_DFF1
-	field	CBNUM		0xFF
-}
-
-/*
- * CMC Recieve Message 1
- */
-register CMCRXMSG1 {
-	address			0x091
-	access_mode	RO
-	modes		M_CCHAN
-	field	CBNUM		0xFF
-}
-
-/*
- * Overlay Recieve Message 1
- */
-register OVLYRXMSG1 {
-	address			0x091
-	access_mode	RO
-	modes		M_SCSI
-	field	CBNUM		0xFF
-}
-
-/*
- * No Snoop Enable
- */
-register NSENABLE {
-	address			0x091
-	access_mode	RW
-	modes		M_CFG
-	field	MSINSEN		0x20
-	field	OVLYNSEN	0x10
-	field	CMCNSEN		0x08
-	field	SGNSEN		0x04
-	field	DCH1NSEN	0x02
-	field	DCH0NSEN	0x01
-}
-
-/*
- * Data Channel Receive Message 2
- */
-register DCHRXMSG2 {
-	address			0x092
-	access_mode	RO
-	modes		M_DFF0, M_DFF1
-	field	MINDEX		0xFF
-}
-
-/*
- * CMC Recieve Message 2
- */
-register CMCRXMSG2 {
-	address			0x092
-	access_mode	RO
-	modes		M_CCHAN
-	field	MINDEX		0xFF
-}
-
-/*
- * Overlay Recieve Message 2
- */
-register OVLYRXMSG2 {
-	address			0x092
-	access_mode	RO
-	modes		M_SCSI
-	field	MINDEX		0xFF
-}
-
-/*
- * Outstanding Split Transactions
- */
-register OST {
-	address			0x092
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * Data Channel Receive Message 3
- */
-register DCHRXMSG3 {
-	address			0x093
-	access_mode	RO
-	modes		M_DFF0, M_DFF1
-	field	MCLASS		0x0F
-}
-
-/*
- * CMC Recieve Message 3
- */
-register CMCRXMSG3 {
-	address			0x093
-	access_mode	RO
-	modes		M_CCHAN
-	field	MCLASS		0x0F
-}
-
-/*
- * Overlay Recieve Message 3
- */
-register OVLYRXMSG3 {
-	address			0x093
-	access_mode	RO
-	modes		M_SCSI
-	field	MCLASS		0x0F
-}
-
-/*
- * PCI-X Control
- */
-register PCIXCTL {
-	address			0x093
-	access_mode	RW
-	modes		M_CFG
-	field	SERRPULSE	0x80
-	field	UNEXPSCIEN	0x20
-	field	SPLTSMADIS	0x10
-	field	SPLTSTADIS	0x08
-	field	SRSPDPEEN	0x04
-	field	TSCSERREN	0x02
-	field	CMPABCDIS	0x01
-}
-
-/*
- * CMC Sequencer Byte Count
- */
-register CMCSEQBCNT {
-	address			0x094
-	access_mode	RO
-	modes		M_CCHAN
-}
-
-/*
- * Overlay Sequencer Byte Count
- */
-register OVLYSEQBCNT {
-	address			0x094
-	access_mode	RO
-	modes		M_SCSI
-}
-
-/*
- * Data Channel Sequencer Byte Count
- */
-register DCHSEQBCNT {
-	address			0x094
-	access_mode	RO
-	size		2
-	modes		M_DFF0, M_DFF1
-}
-
-/*
- * Data Channel Split Status 0
- */
-register DCHSPLTSTAT0 {
-	address			0x096
-	access_mode	RW
-	modes		M_DFF0, M_DFF1
-	field	STAETERM	0x80
-	field	SCBCERR		0x40
-	field	SCADERR		0x20
-	field	SCDATBUCKET	0x10
-	field	CNTNOTCMPLT	0x08
-	field	RXOVRUN		0x04
-	field	RXSCEMSG	0x02
-	field	RXSPLTRSP	0x01
-}
-
-/*
- * CMC Split Status 0
- */
-register CMCSPLTSTAT0 {
-	address			0x096
-	access_mode	RW
-	modes		M_CCHAN
-	field	STAETERM	0x80
-	field	SCBCERR		0x40
-	field	SCADERR		0x20
-	field	SCDATBUCKET	0x10
-	field	CNTNOTCMPLT	0x08
-	field	RXOVRUN		0x04
-	field	RXSCEMSG	0x02
-	field	RXSPLTRSP	0x01
-}
-
-/*
- * Overlay Split Status 0
- */
-register OVLYSPLTSTAT0 {
-	address			0x096
-	access_mode	RW
-	modes		M_SCSI
-	field	STAETERM	0x80
-	field	SCBCERR		0x40
-	field	SCADERR		0x20
-	field	SCDATBUCKET	0x10
-	field	CNTNOTCMPLT	0x08
-	field	RXOVRUN		0x04
-	field	RXSCEMSG	0x02
-	field	RXSPLTRSP	0x01
-}
-
-/*
- * Data Channel Split Status 1
- */
-register DCHSPLTSTAT1 {
-	address			0x097
-	access_mode	RW
-	modes		M_DFF0, M_DFF1
-	field	RXDATABUCKET	0x01
-}
-
-/*
- * CMC Split Status 1
- */
-register CMCSPLTSTAT1 {
-	address			0x097
-	access_mode	RW
-	modes		M_CCHAN
-	field	RXDATABUCKET	0x01
-}
-
-/*
- * Overlay Split Status 1
- */
-register OVLYSPLTSTAT1 {
-	address			0x097
-	access_mode	RW
-	modes		M_SCSI
-	field	RXDATABUCKET	0x01
-}
-
-/*
- * S/G Receive Message 0
- */
-register SGRXMSG0 {
-	address			0x098
-	access_mode	RO
-	modes		M_DFF0, M_DFF1
-	field		CDNUM	0xF8
-	field		CFNUM	0x07
-}
-
-/*
- * S/G Receive Message 1
- */
-register SGRXMSG1 {
-	address			0x099
-	access_mode	RO
-	modes		M_DFF0, M_DFF1
-	field	CBNUM		0xFF
-}
-
-/*
- * S/G Receive Message 2
- */
-register SGRXMSG2 {
-	address			0x09A
-	access_mode	RO
-	modes		M_DFF0, M_DFF1
-	field	MINDEX		0xFF
-}
-
-/*
- * S/G Receive Message 3
- */
-register SGRXMSG3 {
-	address			0x09B
-	access_mode	RO
-	modes		M_DFF0, M_DFF1
-	field	MCLASS		0x0F
-}
-
-/*
- * Slave Split Out Address 0
- */
-register SLVSPLTOUTADR0 {
-	address			0x098
-	access_mode	RO
-	modes		M_SCSI
-	field	LOWER_ADDR	0x7F
-}
-
-/*
- * Slave Split Out Address 1
- */
-register SLVSPLTOUTADR1 {
-	address			0x099
-	access_mode	RO
-	modes		M_SCSI
-	field	REQ_DNUM	0xF8
-	field	REQ_FNUM	0x07
-}
-
-/*
- * Slave Split Out Address 2
- */
-register SLVSPLTOUTADR2 {
-	address			0x09A
-	access_mode	RO
-	modes		M_SCSI
-	field	REQ_BNUM	0xFF
-}
-
-/*
- * Slave Split Out Address 3
- */
-register SLVSPLTOUTADR3 {
-	address			0x09B
-	access_mode	RO
-	modes		M_SCSI
-	field	RLXORD		020
-	field	TAG_NUM		0x1F
-}
-
-/*
- * SG Sequencer Byte Count
- */
-register SGSEQBCNT {
-	address			0x09C
-	access_mode	RO
-	modes		M_DFF0, M_DFF1
-}
-
-/*
- * Slave Split Out Attribute 0
- */
-register SLVSPLTOUTATTR0 {
-	address			0x09C
-	access_mode	RO
-	modes		M_SCSI
-	field	LOWER_BCNT	0xFF
-}
-
-/*
- * Slave Split Out Attribute 1
- */
-register SLVSPLTOUTATTR1 {
-	address			0x09D
-	access_mode	RO
-	modes		M_SCSI
-	field	CMPLT_DNUM	0xF8
-	field	CMPLT_FNUM	0x07
-}
-
-/*
- * Slave Split Out Attribute 2
- */
-register SLVSPLTOUTATTR2 {
-	address			0x09E
-	access_mode	RO
-	size		2
-	modes		M_SCSI
-	field	CMPLT_BNUM	0xFF
-}
-/*
- * S/G Split Status 0
- */
-register SGSPLTSTAT0 {
-	address			0x09E
-	access_mode	RW
-	modes		M_DFF0, M_DFF1
-	field	STAETERM	0x80
-	field	SCBCERR		0x40
-	field	SCADERR		0x20
-	field	SCDATBUCKET	0x10
-	field	CNTNOTCMPLT	0x08
-	field	RXOVRUN		0x04
-	field	RXSCEMSG	0x02
-	field	RXSPLTRSP	0x01
-}
-
-/*
- * S/G Split Status 1
- */
-register SGSPLTSTAT1 {
-	address			0x09F
-	access_mode	RW
-	modes		M_DFF0, M_DFF1
-	field	RXDATABUCKET	0x01
-}
-
-/*
- * Special Function
- */
-register SFUNCT {
-	address			0x09f
-	access_mode	RW
-	modes		M_CFG
-	field	TEST_GROUP	0xF0
-	field	TEST_NUM	0x0F
-}
-
-/*
- * Data FIFO 0 PCI Status 
- */
-register DF0PCISTAT {
-	address			0x0A0
-	access_mode	RW
-	modes		M_CFG
-	field	DPE		0x80
-	field	SSE		0x40
-	field	RMA		0x20
-	field	RTA		0x10
-	field	SCAAPERR	0x08
-	field	RDPERR		0x04
-	field	TWATERR		0x02
-	field	DPR		0x01
-}
-
-/*
- * Data FIFO 1 PCI Status 
- */
-register DF1PCISTAT {
-	address			0x0A1
-	access_mode	RW
-	modes		M_CFG
-	field	DPE		0x80
-	field	SSE		0x40
-	field	RMA		0x20
-	field	RTA		0x10
-	field	SCAAPERR	0x08
-	field	RDPERR		0x04
-	field	TWATERR		0x02
-	field	DPR		0x01
-}
-
-/*
- * S/G PCI Status 
- */
-register SGPCISTAT {
-	address			0x0A2
-	access_mode	RW
-	modes		M_CFG
-	field	DPE		0x80
-	field	SSE		0x40
-	field	RMA		0x20
-	field	RTA		0x10
-	field	SCAAPERR	0x08
-	field	RDPERR		0x04
-	field	DPR		0x01
-}
-
-/*
- * CMC PCI Status 
- */
-register CMCPCISTAT {
-	address			0x0A3
-	access_mode	RW
-	modes		M_CFG
-	field	DPE		0x80
-	field	SSE		0x40
-	field	RMA		0x20
-	field	RTA		0x10
-	field	SCAAPERR	0x08
-	field	RDPERR		0x04
-	field	TWATERR		0x02
-	field	DPR		0x01
-}
-
-/*
- * Overlay PCI Status 
- */
-register OVLYPCISTAT {
-	address			0x0A4
-	access_mode	RW
-	modes		M_CFG
-	field	DPE		0x80
-	field	SSE		0x40
-	field	RMA		0x20
-	field	RTA		0x10
-	field	SCAAPERR	0x08
-	field	RDPERR		0x04
-	field	DPR		0x01
-}
-
-/*
- * PCI Status for MSI Master DMA Transfer
- */
-register MSIPCISTAT {
-	address			0x0A6
-	access_mode	RW
-	modes		M_CFG
-	field	SSE		0x40
-	field	RMA		0x20
-	field	RTA		0x10
-	field	CLRPENDMSI	0x08
-	field	TWATERR		0x02
-	field	DPR		0x01
-}
-
-/*
- * PCI Status for Target
- */
-register TARGPCISTAT {
-	address			0x0A7
-	access_mode	RW
-	modes		M_CFG
-	field	DPE		0x80
-	field	SSE		0x40
-	field	STA		0x08
-	field	TWATERR		0x02
-}
-
-/*
- * LQ Packet In
- * The last LQ Packet recieved
- */
-register LQIN {
-	address			0x020
-	access_mode	RW
-	size		20
-	modes		M_DFF0, M_DFF1, M_SCSI
-}
-
-/*
- * SCB Type Pointer
- * SCB offset for Target Mode SCB type information
- */
-register TYPEPTR {
-	address			0x020
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * Queue Tag Pointer
- * SCB offset to the Two Byte tag identifier used for target mode.
- */
-register TAGPTR {
-	address			0x021
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * Logical Unit Number Pointer
- * SCB offset to the LSB (little endian) of the lun field.
- */
-register LUNPTR {
-	address			0x022
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * Data Length Pointer
- * SCB offset for the 4 byte data length field in target mode.
- */
-register DATALENPTR {
-	address			0x023
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * Status Length Pointer
- * SCB offset to the two byte status field in target SCBs.
- */
-register STATLENPTR {
-	address			0x024
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * Command Length Pointer
- * Scb offset for the CDB length field in initiator SCBs.
- */
-register CMDLENPTR {
-	address			0x025
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * Task Attribute Pointer
- * Scb offset for the byte field specifying the attribute byte
- * to be used in command packets.
- */ 
-register ATTRPTR {
-	address			0x026
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * Task Management Flags Pointer
- * Scb offset for the byte field specifying the attribute flags
- * byte to be used in command packets.
- */ 
-register FLAGPTR {
-	address			0x027
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * Command Pointer
- * Scb offset for the first byte in the CDB for initiator SCBs.
- */
-register CMDPTR {
-	address			0x028
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * Queue Next Pointer
- * Scb offset for the 2 byte "next scb link".
- */
-register QNEXTPTR {
-	address			0x029
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * SCSI ID Pointer
- * Scb offset to the value to place in the SCSIID register
- * during target mode connections.
- */
-register IDPTR {
-	address			0x02A
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * Command Aborted Byte Pointer
- * Offset to the SCB flags field that includes the
- * "SCB aborted" status bit.
- */
-register ABRTBYTEPTR {
-	address			0x02B
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * Command Aborted Bit Pointer
- * Bit offset in the SCB flags field for "SCB aborted" status.
- */
-register ABRTBITPTR {
-	address			0x02C
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * Rev B or greater.
- */
-register MAXCMDBYTES {
-	address			0x02D
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * Rev B or greater.
- */
-register MAXCMD2RCV {
-	address			0x02E
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * Rev B or greater.
- */
-register SHORTTHRESH {
-	address			0x02F
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * Logical Unit Number Length
- * The length, in bytes, of the SCB lun field.
- */
-register LUNLEN {
-	address			0x030
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * CDB Limit
- * The size, in bytes, of the embedded CDB field in initator SCBs.
- */
-register CDBLIMIT {
-	address			0x031
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * Maximum Commands
- * The maximum number of commands to issue during a
- * single packetized connection.
- */
-register MAXCMD {
-	address			0x032
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * Maximum Command Counter
- * The number of commands already sent during this connection
- */
-register MAXCMDCNT {
-	address			0x033
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * LQ Packet Reserved Bytes
- * The bytes to be sent in the currently reserved fileds
- * of all LQ packets.
- */
-register LQRSVD01 {
-	address			0x034
-	access_mode	RW
-	modes		M_SCSI
-}
-register LQRSVD16 {
-	address			0x035
-	access_mode	RW
-	modes		M_SCSI
-}
-register LQRSVD17 {
-	address			0x036
-	access_mode	RW
-	modes		M_SCSI
-}
-
-/*
- * Command Reserved 0
- * The byte to be sent for the reserved byte 0 of
- * outgoing command packets.
- */
-register CMDRSVD0 {
-	address			0x037
-	access_mode	RW
-	modes		M_CFG
-}
-
-/*
- * LQ Manager Control 0
- */
-register LQCTL0 {
-	address			0x038
-	access_mode	RW
-	modes		M_CFG
-	field	LQITARGCLT	0xC0
-	field	LQIINITGCLT	0x30
-	field	LQ0TARGCLT	0x0C
-	field	LQ0INITGCLT	0x03
-}
-
-/*
- * LQ Manager Control 1
- */
-register LQCTL1 {
-	address			0x038
-	access_mode	RW
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	PCI2PCI		0x04
-	field	SINGLECMD	0x02
-	field	ABORTPENDING	0x01
-}
-
-/*
- * LQ Manager Control 2
- */
-register LQCTL2 {
-	address			0x039
-	access_mode	RW
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	LQIRETRY	0x80
-	field	LQICONTINUE	0x40
-	field	LQITOIDLE	0x20
-	field	LQIPAUSE	0x10
-	field	LQORETRY	0x08
-	field	LQOCONTINUE	0x04
-	field	LQOTOIDLE	0x02
-	field	LQOPAUSE	0x01
-}
-
-/*
- * SCSI RAM BIST0
- */
-register SCSBIST0 {
-	address			0x039
-	access_mode	RW
-	modes		M_CFG
-	field	GSBISTERR	0x40
-	field	GSBISTDONE	0x20
-	field	GSBISTRUN	0x10
-	field	OSBISTERR	0x04
-	field	OSBISTDONE	0x02
-	field	OSBISTRUN	0x01
-}
-
-/*
- * SCSI Sequence Control0
- */
-register SCSISEQ0 {
-	address			0x03A
-	access_mode	RW
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	TEMODEO		0x80
-	field	ENSELO		0x40
-	field	ENARBO		0x20
-	field	FORCEBUSFREE	0x10
-	field	SCSIRSTO	0x01
-}
-
-/*
- * SCSI RAM BIST 1
- */
-register SCSBIST1 {
-	address			0x03A
-	access_mode	RW
-	modes		M_CFG
-	field	NTBISTERR	0x04
-	field	NTBISTDONE	0x02
-	field	NTBISTRUN	0x01
-}
-
-/*
- * SCSI Sequence Control 1
- */
-register SCSISEQ1 {
-	address			0x03B
-	access_mode	RW
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	MANUALCTL	0x40
-	field	ENSELI		0x20
-	field	ENRSELI		0x10
-	field	MANUALP		0x0C
-	field	ENAUTOATNP	0x02
-	field	ALTSTIM		0x01
-}
-
-/*
- * SCSI Transfer Control 0
- */
-register SXFRCTL0 {
-	address			0x03C
-	access_mode	RW
-	modes		M_SCSI
-	field	DFON		0x80
-	field	DFPEXP		0x40
-	field	BIOSCANCELEN	0x10
-	field	SPIOEN		0x08
-}
-
-/*
- * SCSI Transfer Control 1
- */
-register SXFRCTL1 {
-	address			0x03D
-	access_mode	RW
-	modes		M_SCSI
-	field	BITBUCKET	0x80
-	field	ENSACHK		0x40
-	field	ENSPCHK		0x20
-	field	STIMESEL	0x18
-	field	ENSTIMER	0x04
-	field	ACTNEGEN	0x02
-	field	STPWEN		0x01
-}
-
-/*
- * SCSI Transfer Control 2
- */
-register SXFRCTL2 {
-	address			0x03E
-	access_mode	RW
-	modes		M_SCSI
-	field	AUTORSTDIS	0x10
-	field	CMDDMAEN	0x08
-	field	ASU		0x07
-}
-
-/*
- * SCSI Bus Initiator IDs
- * Bitmask of observed initiators on the bus.
- */
-register BUSINITID {
-	address			0x03C
-	access_mode	RW
-	modes		M_CFG
-	size		2
-}
-
-/*
- * Data Length Counters
- * Packet byte counter.
- */
-register DLCOUNT {
-	address			0x03C
-	access_mode	RW
-	modes		M_DFF0, M_DFF1
-	size		3
-}
-
-/*
- * Data FIFO Status
- */
-register DFFSTAT {
-	address			0x03F
-	access_mode	RW
-	modes		M_SCSI
-	field	FIFO1FREE	0x20
-	field	FIFO0FREE	0x10
-	/*
-	 * On the B, this enum only works
-	 * in the read direction.  For writes,
-	 * you must use the B version of the
-	 * CURRFIFO_0 definition which is defined
-	 * as a constant outside of this register
-	 * definition to avoid confusing the
-	 * register pretty printing code.
-	 */
-	enum	CURRFIFO	0x03 {
-		CURRFIFO_0,
-		CURRFIFO_1,
-		CURRFIFO_NONE	0x3
-	}
-}
-
-const B_CURRFIFO_0 0x2
-
-/*
- * SCSI Bus Target IDs
- * Bitmask of observed targets on the bus.
- */
-register BUSTARGID {
-	address			0x03E
-	access_mode	RW
-	modes		M_CFG
-	size		2
-}
-
-/*
- * SCSI Control Signal Out
- */
-register SCSISIGO {
-	address			0x040
-	access_mode	RW
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	CDO		0x80
-	field	IOO		0x40
-	field	MSGO		0x20
-	field	ATNO		0x10
-	field	SELO		0x08
-	field	BSYO		0x04
-	field	REQO		0x02
-	field	ACKO		0x01
-/*
- * Possible phases to write into SCSISIG0
- */
-	enum	PHASE_MASK  CDO|IOO|MSGO {
-		P_DATAOUT	0x0,
-		P_DATAIN	IOO,
-		P_DATAOUT_DT	P_DATAOUT|MSGO,
-		P_DATAIN_DT	P_DATAIN|MSGO,
-		P_COMMAND	CDO,
-		P_MESGOUT	CDO|MSGO,
-		P_STATUS	CDO|IOO,
-		P_MESGIN	CDO|IOO|MSGO
-	}
-}
-
-register SCSISIGI {
-	address			0x041
-	access_mode	RO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	CDI		0x80
-	field	IOI		0x40
-	field	MSGI		0x20
-	field	ATNI		0x10
-	field	SELI		0x08
-	field	BSYI		0x04
-	field	REQI		0x02
-	field	ACKI		0x01
-/*
- * Possible phases in SCSISIGI
- */
-	enum	PHASE_MASK  CDO|IOO|MSGO {
-		P_DATAOUT	0x0,
-		P_DATAIN	IOO,
-		P_DATAOUT_DT	P_DATAOUT|MSGO,
-		P_DATAIN_DT	P_DATAIN|MSGO,
-		P_COMMAND	CDO,
-		P_MESGOUT	CDO|MSGO,
-		P_STATUS	CDO|IOO,
-		P_MESGIN	CDO|IOO|MSGO
-	}
-}
-
-/*
- * Multiple Target IDs
- * Bitmask of ids to respond as a target.
- */
-register MULTARGID {
-	address			0x040
-	access_mode	RW
-	modes		M_CFG
-	size		2
-}
-
-/*
- * SCSI Phase
- */
-register SCSIPHASE {
-	address			0x042
-	access_mode	RO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	STATUS_PHASE	0x20
-	field	COMMAND_PHASE	0x10
-	field	MSG_IN_PHASE	0x08
-	field	MSG_OUT_PHASE	0x04
-	field	DATA_PHASE_MASK	0x03 {
-		DATA_OUT_PHASE	0x01,
-		DATA_IN_PHASE	0x02
-	}
-}
-
-/*
- * SCSI Data 0 Image
- */
-register SCSIDAT0_IMG {
-	address			0x043
-	access_mode	RW
-	modes		M_DFF0, M_DFF1, M_SCSI
-}
-
-/*
- * SCSI Latched Data
- */
-register SCSIDAT {
-	address			0x044
-	access_mode	RW
-	modes		M_DFF0, M_DFF1, M_SCSI
-	size		2
-}
-
-/*
- * SCSI Data Bus
- */
-register SCSIBUS {
-	address			0x046
-	access_mode	RW
-	modes		M_DFF0, M_DFF1, M_SCSI
-	size		2
-}
-
-/*
- * Target ID In
- */
-register TARGIDIN {
-	address			0x048
-	access_mode	RO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	CLKOUT		0x80
-	field	TARGID		0x0F
-}
-
-/*
- * Selection/Reselection ID
- * Upper four bits are the device id.  The ONEBIT is set when the re/selecting
- * device did not set its own ID.
- */
-register SELID {
-	address			0x049
-	access_mode	RW
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	SELID_MASK	0xf0
-	field	ONEBIT		0x08
-}
-
-/*
- * SCSI Block Control
- * Controls Bus type and channel selection.  SELWIDE allows for the
- * coexistence of 8bit and 16bit devices on a wide bus.
- */
-register SBLKCTL {
-	address			0x04A
-	access_mode	RW
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	DIAGLEDEN	0x80
-	field	DIAGLEDON	0x40
-	field	ENAB40		0x08	/* LVD transceiver active */
-	field	ENAB20		0x04	/* SE/HVD transceiver active */
-	field	SELWIDE		0x02
-}
-
-/*
- * Option Mode
- */
-register OPTIONMODE {
-	address			0x04A
-	access_mode	RW
-	modes		M_CFG
-	field	BIOSCANCTL		0x80
-	field	AUTOACKEN		0x40
-	field	BIASCANCTL		0x20
-	field	BUSFREEREV		0x10
-	field	ENDGFORMCHK		0x04
-	field	AUTO_MSGOUT_DE		0x02
-	mask	OPTIONMODE_DEFAULTS	AUTO_MSGOUT_DE
-}
-
-/*
- * SCSI Status 0
- */
-register SSTAT0	{
-	address			0x04B
-	access_mode	RO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	TARGET		0x80	/* Board acting as target */
-	field	SELDO		0x40	/* Selection Done */
-	field	SELDI		0x20	/* Board has been selected */
-	field	SELINGO		0x10	/* Selection In Progress */
-	field	IOERR		0x08	/* LVD Tranceiver mode changed */
-	field	OVERRUN		0x04	/* SCSI Offset overrun detected */
-	field	SPIORDY		0x02	/* SCSI PIO Ready */
-	field	ARBDO		0x01	/* Arbitration Done Out */
-}
-
-/*
- * Clear SCSI Interrupt 0
- * Writing a 1 to a bit clears the associated SCSI Interrupt in SSTAT0.
- */
-register CLRSINT0 {
-	address			0x04B
-	access_mode	WO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	CLRSELDO	0x40
-	field	CLRSELDI	0x20
-	field	CLRSELINGO	0x10
-	field	CLRIOERR	0x08
-	field	CLROVERRUN	0x04
-	field	CLRSPIORDY	0x02
-	field	CLRARBDO	0x01
-}
-
-/*
- * SCSI Interrupt Mode 0
- * Setting any bit will enable the corresponding function
- * in SIMODE0 to interrupt via the IRQ pin.
- */
-register SIMODE0 {
-	address			0x04B
-	access_mode	RW
-	modes		M_CFG
-	field	ENSELDO		0x40
-	field	ENSELDI		0x20
-	field	ENSELINGO	0x10
-	field	ENIOERR		0x08
-	field	ENOVERRUN	0x04
-	field	ENSPIORDY	0x02
-	field	ENARBDO		0x01
-}
-
-/*
- * SCSI Status 1
- */
-register SSTAT1 {
-	address			0x04C
-	access_mode	RO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	SELTO		0x80
-	field	ATNTARG 	0x40
-	field	SCSIRSTI	0x20
-	field	PHASEMIS	0x10
-	field	BUSFREE		0x08
-	field	SCSIPERR	0x04
-	field	STRB2FAST	0x02
-	field	REQINIT		0x01
-}
-
-/*
- * Clear SCSI Interrupt 1
- * Writing a 1 to a bit clears the associated SCSI Interrupt in SSTAT1.
- */
-register CLRSINT1 {
-	address			0x04C
-	access_mode	WO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	CLRSELTIMEO	0x80
-	field	CLRATNO		0x40
-	field	CLRSCSIRSTI	0x20
-	field	CLRBUSFREE	0x08
-	field	CLRSCSIPERR	0x04
-	field	CLRSTRB2FAST	0x02
-	field	CLRREQINIT	0x01
-}
-
-/*
- * SCSI Status 2
- */
-register SSTAT2 {
-	address			0x04d
-	access_mode	RO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	BUSFREETIME	0xc0 {
-		BUSFREE_LQO	0x40,
-		BUSFREE_DFF0	0x80,
-		BUSFREE_DFF1	0xC0
-	}
-	field	NONPACKREQ	0x20
-	field	EXP_ACTIVE	0x10	/* SCSI Expander Active */
-	field	BSYX		0x08	/* Busy Expander */
-	field	WIDE_RES	0x04	/* Modes 0 and 1 only */
-	field	SDONE		0x02	/* Modes 0 and 1 only */
-	field	DMADONE		0x01	/* Modes 0 and 1 only */
-}
-
-/*
- * Clear SCSI Interrupt 2
- */
-register CLRSINT2 {
-	address			0x04D
-	access_mode	WO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	CLRNONPACKREQ	0x20
-	field	CLRWIDE_RES	0x04	/* Modes 0 and 1 only */
-	field	CLRSDONE	0x02	/* Modes 0 and 1 only */
-	field	CLRDMADONE	0x01	/* Modes 0 and 1 only */
-}
-
-/*
- * SCSI Interrupt Mode 2
- */
-register SIMODE2 {
-	address			0x04D
-	access_mode	RW
-	modes		M_CFG
-	field	ENWIDE_RES	0x04
-	field	ENSDONE		0x02
-	field	ENDMADONE	0x01
-}
-
-/*
- * Physical Error Diagnosis
- */
-register PERRDIAG {
-	address			0x04E
-	access_mode	RO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	HIZERO		0x80
-	field	HIPERR		0x40
-	field	PREVPHASE	0x20
-	field	PARITYERR	0x10
-	field	AIPERR		0x08
-	field	CRCERR		0x04
-	field	DGFORMERR	0x02
-	field	DTERR		0x01
-}
-
-/*
- * LQI Manager Current State
- */
-register LQISTATE {
-	address			0x04E
-	access_mode	RO
-	modes		M_CFG
-}
-
-/*
- * SCSI Offset Count
- */
-register SOFFCNT {
-	address			0x04F
-	access_mode	RO
-	modes		M_DFF0, M_DFF1, M_SCSI
-}
-
-/*
- * LQO Manager Current State
- */
-register LQOSTATE {
-	address			0x04F
-	access_mode	RO
-	modes		M_CFG
-}
-
-/*
- * LQI Manager Status
- */
-register LQISTAT0 {
-	address			0x050
-	access_mode	RO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	LQIATNQAS	0x20
-	field	LQICRCT1	0x10
-	field	LQICRCT2	0x08
-	field	LQIBADLQT	0x04
-	field	LQIATNLQ	0x02
-	field	LQIATNCMD	0x01
-}
-
-/*
- * Clear LQI Interrupts 0
- */
-register CLRLQIINT0 {
-	address			0x050
-	access_mode	WO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	CLRLQIATNQAS	0x20
-	field	CLRLQICRCT1	0x10
-	field	CLRLQICRCT2	0x08
-	field	CLRLQIBADLQT	0x04
-	field	CLRLQIATNLQ	0x02
-	field	CLRLQIATNCMD	0x01
-}
-
-/*
- * LQI Manager Interrupt Mode 0
- */
-register LQIMODE0 {
-	address			0x050
-	access_mode	RW
-	modes		M_CFG
-	field	ENLQIATNQASK	0x20
-	field	ENLQICRCT1	0x10
-	field	ENLQICRCT2	0x08
-	field	ENLQIBADLQT	0x04
-	field	ENLQIATNLQ	0x02
-	field	ENLQIATNCMD	0x01
-}
-
-/*
- * LQI Manager Status 1
- */
-register LQISTAT1 {
-	address			0x051
-	access_mode	RO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	LQIPHASE_LQ	0x80
-	field	LQIPHASE_NLQ	0x40
-	field	LQIABORT	0x20
-	field	LQICRCI_LQ	0x10
-	field	LQICRCI_NLQ	0x08
-	field	LQIBADLQI	0x04
-	field	LQIOVERI_LQ	0x02
-	field	LQIOVERI_NLQ	0x01
-}
-
-/*
- * Clear LQI Manager Interrupts1
- */
-register CLRLQIINT1 {
-	address			0x051
-	access_mode	WO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	CLRLQIPHASE_LQ	0x80
-	field	CLRLQIPHASE_NLQ	0x40
-	field	CLRLIQABORT	0x20
-	field	CLRLQICRCI_LQ	0x10
-	field	CLRLQICRCI_NLQ	0x08
-	field	CLRLQIBADLQI	0x04
-	field	CLRLQIOVERI_LQ	0x02
-	field	CLRLQIOVERI_NLQ	0x01
-}
-
-/*
- * LQI Manager Interrupt Mode 1
- */
-register LQIMODE1 {
-	address			0x051
-	access_mode	RW
-	modes		M_CFG
-	field	ENLQIPHASE_LQ	0x80
-	field	ENLQIPHASE_NLQ	0x40
-	field	ENLIQABORT	0x20
-	field	ENLQICRCI_LQ	0x10
-	field	ENLQICRCI_NLQ	0x08
-	field	ENLQIBADLQI	0x04
-	field	ENLQIOVERI_LQ	0x02
-	field	ENLQIOVERI_NLQ	0x01
-}
-
-/*
- * LQI Manager Status 2
- */
-register LQISTAT2 {
-	address			0x052
-	access_mode	RO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	PACKETIZED	0x80
-	field	LQIPHASE_OUTPKT	0x40
-	field	LQIWORKONLQ	0x20
-	field	LQIWAITFIFO	0x10
-	field	LQISTOPPKT	0x08
-	field	LQISTOPLQ	0x04
-	field	LQISTOPCMD	0x02
-	field	LQIGSAVAIL	0x01
-}
-
-/*
- * SCSI Status 3
- */
-register SSTAT3 {
-	address			0x053
-	access_mode	RO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	NTRAMPERR	0x02
-	field	OSRAMPERR	0x01
-}
-
-/*
- * Clear SCSI Status 3
- */
-register CLRSINT3 {
-	address			0x053
-	access_mode	WO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	CLRNTRAMPERR	0x02
-	field	CLROSRAMPERR	0x01
-}
-
-/*
- * SCSI Interrupt Mode 3
- */
-register SIMODE3 {
-	address			0x053
-	access_mode	RW
-	modes		M_CFG
-	field	ENNTRAMPERR	0x02
-	field	ENOSRAMPERR	0x01
-}
-
-/*
- * LQO Manager Status 0
- */
-register LQOSTAT0 {
-	address			0x054
-	access_mode	RO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	LQOTARGSCBPERR	0x10
-	field	LQOSTOPT2	0x08
-	field	LQOATNLQ	0x04
-	field	LQOATNPKT	0x02
-	field	LQOTCRC		0x01
-}
-
-/*
- * Clear LQO Manager interrupt 0
- */
-register CLRLQOINT0 {
-	address			0x054
-	access_mode	WO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	CLRLQOTARGSCBPERR	0x10
-	field	CLRLQOSTOPT2		0x08
-	field	CLRLQOATNLQ		0x04
-	field	CLRLQOATNPKT		0x02
-	field	CLRLQOTCRC		0x01
-}
-
-/*
- * LQO Manager Interrupt Mode 0
- */
-register LQOMODE0 {
-	address			0x054
-	access_mode	RW
-	modes		M_CFG
-	field	ENLQOTARGSCBPERR	0x10
-	field	ENLQOSTOPT2		0x08
-	field	ENLQOATNLQ		0x04
-	field	ENLQOATNPKT		0x02
-	field	ENLQOTCRC		0x01
-}
-
-/*
- * LQO Manager Status 1
- */
-register LQOSTAT1 {
-	address			0x055
-	access_mode	RO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	LQOINITSCBPERR	0x10
-	field	LQOSTOPI2	0x08
-	field	LQOBADQAS	0x04
-	field	LQOBUSFREE	0x02
-	field	LQOPHACHGINPKT	0x01
-}
-
-/*
- * Clear LOQ Interrupt 1
- */
-register CLRLQOINT1 {
-	address			0x055
-	access_mode	WO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	CLRLQOINITSCBPERR	0x10
-	field	CLRLQOSTOPI2		0x08
-	field	CLRLQOBADQAS		0x04
-	field	CLRLQOBUSFREE		0x02
-	field	CLRLQOPHACHGINPKT	0x01
-}
-
-/*
- * LQO Manager Interrupt Mode 1
- */
-register LQOMODE1 {
-	address			0x055
-	access_mode	RW
-	modes		M_CFG
-	field	ENLQOINITSCBPERR	0x10
-	field	ENLQOSTOPI2		0x08
-	field	ENLQOBADQAS		0x04
-	field	ENLQOBUSFREE		0x02
-	field	ENLQOPHACHGINPKT	0x01
-}
-
-/*
- * LQO Manager Status 2
- */
-register LQOSTAT2 {
-	address			0x056
-	access_mode	RO
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	LQOPKT		0xE0
-	field	LQOWAITFIFO	0x10
-	field	LQOPHACHGOUTPKT	0x02	/* outside of packet boundaries. */
-	field	LQOSTOP0	0x01	/* Stopped after sending all packets */
-}
-
-/*
- * Output Synchronizer Space Count
- */
-register OS_SPACE_CNT {
-	address			0x056
-	access_mode	RO
-	modes		M_CFG
-}
-
-/*
- * SCSI Interrupt Mode 1
- * Setting any bit will enable the corresponding function
- * in SIMODE1 to interrupt via the IRQ pin.
- */
-register SIMODE1 {
-	address			0x057
-	access_mode	RW
-	modes		M_DFF0, M_DFF1, M_SCSI
-	field	ENSELTIMO	0x80
-	field	ENATNTARG	0x40
-	field	ENSCSIRST	0x20
-	field	ENPHASEMIS	0x10
-	field	ENBUSFREE	0x08
-	field	ENSCSIPERR	0x04
-	field	ENSTRB2FAST	0x02
-	field	ENREQINIT	0x01
-}
-
-/*
- * Good Status FIFO
- */
-register GSFIFO {
-	address			0x058
-	access_mode	RO
-	size		2
-	modes		M_DFF0, M_DFF1, M_SCSI
-}
-
-/*
- * Data FIFO SCSI Transfer Control
- */
-register DFFSXFRCTL {
-	address			0x05A
-	access_mode	RW
-	modes		M_DFF0, M_DFF1
-	field	DFFBITBUCKET	0x08
-	field	CLRSHCNT	0x04
-	field	CLRCHN		0x02
-	field	RSTCHN		0x01
-}
-
-/*
- * Next SCSI Control Block
- */
-register NEXTSCB {
-	address			0x05A
-	access_mode	RW
-	size		2
-	modes		M_SCSI
-}
-
-/* Rev B only. */
-register LQOSCSCTL {
-	address			0x05A
-	access_mode	RW
-	size		1
-	modes		M_CFG
-	field		LQOH2A_VERSION	0x80
-	field		LQONOCHKOVER	0x01
-}
-
-/*
- * SEQ Interrupts
- */
-register SEQINTSRC {
-	address			0x05B
-	access_mode	RO
-	modes		M_DFF0, M_DFF1
-	field	CTXTDONE	0x40
-	field	SAVEPTRS	0x20
-	field	CFG4DATA	0x10
-	field	CFG4ISTAT	0x08
-	field	CFG4TSTAT	0x04
-	field	CFG4ICMD	0x02
-	field	CFG4TCMD	0x01
-}
-
-/*
- * Clear Arp Interrupts
- */
-register CLRSEQINTSRC {
-	address			0x05B
-	access_mode	WO
-	modes		M_DFF0, M_DFF1
-	field	CLRCTXTDONE	0x40
-	field	CLRSAVEPTRS	0x20
-	field	CLRCFG4DATA	0x10
-	field	CLRCFG4ISTAT	0x08
-	field	CLRCFG4TSTAT	0x04
-	field	CLRCFG4ICMD	0x02
-	field	CLRCFG4TCMD	0x01
-}
-
-/*
- * SEQ Interrupt Enabled (Shared)
- */
-register SEQIMODE {
-	address			0x05C
-	access_mode	RW
-	modes		M_DFF0, M_DFF1
-	field	ENCTXTDONE	0x40
-	field	ENSAVEPTRS	0x20
-	field	ENCFG4DATA	0x10
-	field	ENCFG4ISTAT	0x08
-	field	ENCFG4TSTAT	0x04
-	field	ENCFG4ICMD	0x02
-	field	ENCFG4TCMD	0x01
-}
-
-/*
- * Current SCSI Control Block
- */
-register CURRSCB {
-	address			0x05C
-	access_mode	RW
-	size		2
-	modes		M_SCSI
-}
-
-/*
- * Data FIFO Status
- */
-register MDFFSTAT {
-	address			0x05D
-	access_mode	RO
-	modes		M_DFF0, M_DFF1
-	field	SHCNTNEGATIVE	0x40 /* Rev B or higher */
-	field	SHCNTMINUS1	0x20 /* Rev B or higher */
-	field	LASTSDONE	0x10
-	field	SHVALID		0x08
-	field	DLZERO		0x04 /* FIFO data ends on packet boundary. */
-	field	DATAINFIFO	0x02
-	field	FIFOFREE	0x01
-}
-
-/*
- * CRC Control
- */
-register CRCCONTROL {
-	address			0x05d
-	access_mode	RW
-	modes		M_CFG
-	field	CRCVALCHKEN		0x40
-}
-
-/*
- * SCSI Test Control
- */
-register SCSITEST {
-	address			0x05E
-	access_mode	RW
-	modes		M_CFG
-	field	CNTRTEST	0x08
-	field	SEL_TXPLL_DEBUG	0x04
-}
-
-/*
- * Data FIFO Queue Tag
- */
-register DFFTAG {
-	address			0x05E
-	access_mode	RW
-	size		2
-	modes		M_DFF0, M_DFF1
-}
-
-/*
- * Last SCSI Control Block
- */
-register LASTSCB {
-	address			0x05E
-	access_mode	RW
-	size		2
-	modes		M_SCSI
-}
-
-/*
- * SCSI I/O Cell Power-down Control
- */
-register IOPDNCTL {
-	address			0x05F
-	access_mode	RW
-	modes		M_CFG
-	field	DISABLE_OE	0x80
-	field	PDN_IDIST	0x04
-	field	PDN_DIFFSENSE	0x01
-}
-
-/*
- * Shaddow Host Address.
- */
-register SHADDR {
-	address			0x060
-	access_mode	RO
-	size		8
-	modes		M_DFF0, M_DFF1
-}
-
-/*
- * Data Group CRC Interval.
- */
-register DGRPCRCI {
-	address			0x060
-	access_mode	RW
-	size		2
-	modes		M_CFG
-}
-
-/*
- * Data Transfer Negotiation Address
- */
-register NEGOADDR {
-	address			0x060
-	access_mode	RW
-	modes		M_SCSI
-}
-
-/*
- * Data Transfer Negotiation Data - Period Byte
- */
-register NEGPERIOD {
-	address			0x061
-	access_mode	RW
-	modes		M_SCSI
-}
-
-/*
- * Packetized CRC Interval
- */
-register PACKCRCI {
-	address			0x062
-	access_mode	RW
-	size		2
-	modes		M_CFG
-}
-
-/*
- * Data Transfer Negotiation Data - Offset Byte
- */
-register NEGOFFSET {
-	address			0x062
-	access_mode	RW
-	modes		M_SCSI
-}
-
-/*
- * Data Transfer Negotiation Data - PPR Options
- */
-register NEGPPROPTS {
-	address			0x063
-	access_mode	RW
-	modes		M_SCSI
-	field	PPROPT_PACE	0x08
-	field	PPROPT_QAS	0x04
-	field	PPROPT_DT	0x02
-	field	PPROPT_IUT	0x01
-}
-
-/*
- * Data Transfer Negotiation Data -  Connection Options
- */
-register NEGCONOPTS {
-	address			0x064
-	access_mode	RW
-	modes		M_SCSI
-	field	ENSNAPSHOT	0x40
-	field	RTI_WRTDIS	0x20
-	field	RTI_OVRDTRN	0x10
-	field	ENSLOWCRC	0x08
-	field	ENAUTOATNI	0x04
-	field	ENAUTOATNO	0x02
-	field	WIDEXFER	0x01
-}
-
-/*
- * Negotiation Table Annex Column Index.
- */
-register ANNEXCOL {
-	address			0x065
-	access_mode	RW
-	modes		M_SCSI
-}
-
-register SCSCHKN {
-	address			0x066
-	access_mode	RW
-	modes		M_CFG
-	field	STSELSKIDDIS	0x40
-	field	CURRFIFODEF	0x20
-	field	WIDERESEN	0x10
-	field	SDONEMSKDIS	0x08
-	field	DFFACTCLR	0x04
-	field	SHVALIDSTDIS	0x02
-	field	LSTSGCLRDIS	0x01
-}
-
-const AHD_ANNEXCOL_PER_DEV0	4
-const AHD_NUM_PER_DEV_ANNEXCOLS	4
-const AHD_ANNEXCOL_PRECOMP_SLEW	4
-const	AHD_PRECOMP_MASK	0x07
-const	AHD_PRECOMP_SHIFT	0
-const	AHD_PRECOMP_CUTBACK_17	0x04
-const	AHD_PRECOMP_CUTBACK_29	0x06
-const	AHD_PRECOMP_CUTBACK_37	0x07
-const	AHD_SLEWRATE_MASK	0x78
-const	AHD_SLEWRATE_SHIFT	3
-/*
- * Rev A has only a single bit of slew adjustment.
- * Rev B has 4 bits.
- */
-const	AHD_SLEWRATE_DEF_REVA	0x01
-const	AHD_SLEWRATE_DEF_REVB	0x08
-
-/* Rev A does not have any amplitude setting. */
-const AHD_ANNEXCOL_AMPLITUDE	6
-const	AHD_AMPLITUDE_MASK	0x7
-const	AHD_AMPLITUDE_SHIFT	0
-const	AHD_AMPLITUDE_DEF	0x7
-
-/*
- * Negotiation Table Annex Data Port.
- */
-register ANNEXDAT {
-	address			0x066
-	access_mode	RW
-	modes		M_SCSI
-}
-
-/*
- * Initiator's Own Id.
- * The SCSI ID to use for Selection Out and seen during a reselection..
- */
-register IOWNID {
-	address			0x067
-	access_mode	RW
-	modes		M_SCSI
-}
-
-/*
- * 960MHz Phase-Locked Loop Control 0
- */
-register PLL960CTL0 {
-	address			0x068
-	access_mode	RW
-	modes		M_CFG
-	field	PLL_VCOSEL	0x80
-	field	PLL_PWDN	0x40
-	field	PLL_NS		0x30
-	field	PLL_ENLUD	0x08
-	field	PLL_ENLPF	0x04
-	field	PLL_DLPF	0x02
-	field	PLL_ENFBM	0x01
-}
-
-/*
- * Target Own Id
- */
-register TOWNID {
-	address			0x069
-	access_mode	RW
-	modes		M_SCSI
-}
-
-/*
- * 960MHz Phase-Locked Loop Control 1
- */
-register PLL960CTL1 {
-	address			0x069
-	access_mode	RW
-	modes		M_CFG
-	field	PLL_CNTEN	0x80
-	field	PLL_CNTCLR	0x40
-	field	PLL_RST		0x01
-}
-
-/*
- * Expander Signature
- */
-register XSIG {
-	address			0x06A
-	access_mode	RW
-	modes		M_SCSI
-}
-
-/*
- * Shadow Byte Count
- */
-register SHCNT {
-	address			0x068
-	access_mode	RW
-	size		3
-	modes		M_DFF0, M_DFF1
-}
-
-/*
- * Selection Out ID
- */
-register SELOID {
-	address			0x06B
-	access_mode	RW
-	modes		M_SCSI
-}
-
-/*
- * 960-MHz Phase-Locked Loop Test Count
- */
-register PLL960CNT0 {
-	address			0x06A
-	access_mode	RO
-	size		2
-	modes		M_CFG
-}
-
-/*
- * 400-MHz Phase-Locked Loop Control 0
- */
-register PLL400CTL0 {
-	address			0x06C
-	access_mode	RW
-	modes		M_CFG
-	field	PLL_VCOSEL	0x80
-	field	PLL_PWDN	0x40
-	field	PLL_NS		0x30
-	field	PLL_ENLUD	0x08
-	field	PLL_ENLPF	0x04
-	field	PLL_DLPF	0x02
-	field	PLL_ENFBM	0x01
-}
-
-/*
- * Arbitration Fairness
- */
-register FAIRNESS {
-	address			0x06C
-	access_mode	RW
-	size		2
-	modes		M_SCSI
-}
-
-/*
- * 400-MHz Phase-Locked Loop Control 1
- */
-register PLL400CTL1 {
-	address			0x06D
-	access_mode	RW
-	modes		M_CFG
-	field	PLL_CNTEN	0x80
-	field	PLL_CNTCLR	0x40
-	field	PLL_RST		0x01
-}
-
-/*
- * Arbitration Unfairness
- */
-register UNFAIRNESS {
-	address			0x06E
-	access_mode	RW
-	size		2
-	modes		M_SCSI
-}
-
-/*
- * 400-MHz Phase-Locked Loop Test Count
- */
-register PLL400CNT0 {
-	address			0x06E
-	access_mode	RO
-	size		2
-	modes		M_CFG
-}
-
-/*
- * SCB Page Pointer
- */
-register SCBPTR {
-	address			0x0A8
-	access_mode	RW
-	size		2
-	modes		M_DFF0, M_DFF1, M_CCHAN, M_SCSI
-}
-
-/*
- * CMC SCB Array Count
- * Number of bytes to transfer between CMC SCB memory and SCBRAM.
- * Transfers must be 8byte aligned and sized.
- */
-register CCSCBACNT {
-	address			0x0AB
-	access_mode	RW
-	modes		M_CCHAN
-}
-
-/*
- * SCB Autopointer
- * SCB-Next Address Snooping logic.  When an SCB is transferred to
- * the card, the next SCB address to be used by the CMC array can
- * be autoloaded from that transfer.
- */
-register SCBAUTOPTR {
-	address			0x0AB
-	access_mode	RW
-	modes		M_CFG
-	field	AUSCBPTR_EN	0x80
-	field	SCBPTR_ADDR	0x38
-	field	SCBPTR_OFF	0x07
-}
-
-/*
- * CMC SG Ram Address Pointer
- */
-register CCSGADDR {
-	address			0x0AC
-	access_mode	RW
-	modes		M_DFF0, M_DFF1
-}
-
-/*
- * CMC SCB RAM Address Pointer
- */
-register CCSCBADDR {
-	address			0x0AC
-	access_mode	RW
-	modes		M_CCHAN
-}
-
-/*
- * CMC SCB Ram Back-up Address Pointer
- * Indicates the true stop location of transfers halted prior
- * to SCBHCNT going to 0.
- */
-register CCSCBADR_BK {
-	address			0x0AC
-	access_mode	RO
-	modes		M_CFG
-}
-
-/*
- * CMC SG Control
- */
-register CCSGCTL {
-	address			0x0AD
-	access_mode	RW
-	modes		M_DFF0, M_DFF1
-	field	CCSGDONE	0x80
-	field	SG_CACHE_AVAIL	0x10
-	field	CCSGENACK	0x08
-	mask	CCSGEN		0x0C
-	field	SG_FETCH_REQ	0x02
-	field	CCSGRESET	0x01
-}
-
-/*
- * CMD SCB Control
- */
-register CCSCBCTL {
-	address			0x0AD
-	access_mode	RW
-	modes		M_CCHAN
-	field	CCSCBDONE	0x80
-	field	ARRDONE		0x40
-	field	CCARREN		0x10
-	field	CCSCBEN		0x08
-	field	CCSCBDIR	0x04
-	field	CCSCBRESET	0x01
-}
-
-/*
- * CMC Ram BIST
- */
-register CMC_RAMBIST {
-	address			0x0AD
-	access_mode	RW
-	modes		M_CFG
-	field	SG_ELEMENT_SIZE		0x80
-	field	SCBRAMBIST_FAIL		0x40
-	field	SG_BIST_FAIL		0x20
-	field	SG_BIST_EN		0x10
-	field	CMC_BUFFER_BIST_FAIL	0x02
-	field	CMC_BUFFER_BIST_EN	0x01
-}
-
-/*
- * CMC SG RAM Data Port
- */
-register CCSGRAM {
-	address			0x0B0
-	access_mode	RW
-	modes		M_DFF0, M_DFF1
-}
-
-/*
- * CMC SCB RAM Data Port
- */
-register CCSCBRAM {
-	address			0x0B0
-	access_mode	RW
-	modes		M_CCHAN
-}
-
-/*
- * Flex DMA Address.
- */
-register FLEXADR {
-	address			0x0B0
-	access_mode	RW
-	size		3
-	modes		M_SCSI
-}
-
-/*
- * Flex DMA Byte Count
- */
-register FLEXCNT {
-	address			0x0B3
-	access_mode	RW
-	size		2
-	modes		M_SCSI
-}
-
-/*
- * Flex DMA Status
- */
-register FLEXDMASTAT {
-	address			0x0B5
-	access_mode	RW
-	modes		M_SCSI
-	field	FLEXDMAERR	0x02
-	field	FLEXDMADONE	0x01
-}
-
-/*
- * Flex DMA Data Port
- */
-register FLEXDATA {
-	address			0x0B6
-	access_mode	RW
-	modes		M_SCSI
-}
-
-/*
- * Board Data
- */
-register BRDDAT {
-	address			0x0B8
-	access_mode	RW
-	modes		M_SCSI
-}
-
-/*
- * Board Control
- */
-register BRDCTL {
-	address			0x0B9
-	access_mode	RW
-	modes		M_SCSI
-	field	FLXARBACK	0x80
-	field	FLXARBREQ	0x40
-	field	BRDADDR		0x38
-	field	BRDEN		0x04
-	field	BRDRW		0x02
-	field	BRDSTB		0x01
-}
-
-/*
- * Serial EEPROM Address
- */
-register SEEADR {
-	address			0x0BA
-	access_mode	RW
-	modes		M_SCSI
-}
-
-/*
- * Serial EEPROM Data
- */
-register SEEDAT {
-	address			0x0BC
-	access_mode	RW
-	size		2
-	modes		M_SCSI
-}
-
-/*
- * Serial EEPROM Status
- */
-register SEESTAT {
-	address			0x0BE
-	access_mode	RO
-	modes		M_SCSI
-	field	INIT_DONE	0x80
-	field	SEEOPCODE	0x70
-	field	LDALTID_L	0x08
-	field	SEEARBACK	0x04
-	field	SEEBUSY		0x02
-	field	SEESTART	0x01
-}
-
-/*
- * Serial EEPROM Control
- */
-register SEECTL {
-	address			0x0BE
-	access_mode	RW
-	modes		M_SCSI
-	field	SEEOPCODE	0x70 {
-		SEEOP_ERASE	0x70,
-		SEEOP_READ	0x60,
-		SEEOP_WRITE	0x50,
-	/*
-	 * The following four commands use special
-	 * addresses for differentiation.
-	 */
-		SEEOP_ERAL	0x40
-	}
-	mask	SEEOP_EWEN	0x40
-	mask	SEEOP_WALL	0x40
-	mask	SEEOP_EWDS	0x40
-	field	SEERST		0x02
-	field	SEESTART	0x01
-}
-
-const SEEOP_ERAL_ADDR	0x80
-const SEEOP_EWEN_ADDR	0xC0
-const SEEOP_WRAL_ADDR	0x40
-const SEEOP_EWDS_ADDR	0x00
-
-/*
- * SCB Counter
- */
-register SCBCNT {
-	address			0x0BF
-	access_mode	RW
-	modes		M_SCSI
-}
-
-/*
- * Data FIFO Write Address
- * Pointer to the next QWD location to be written to the data FIFO.
- */
-register DFWADDR {
-	address			0x0C0
-	access_mode	RW
-	size		2
-	modes		M_DFF0, M_DFF1
-}
-
-/*
- * DSP Filter Control
- */
-register DSPFLTRCTL {
-	address			0x0C0
-	access_mode	RW
-	modes		M_CFG
-	field	FLTRDISABLE	0x20
-	field	EDGESENSE	0x10
-	field	DSPFCNTSEL	0x0F
-}
-
-/*
- * DSP Data Channel Control
- */
-register DSPDATACTL {
-	address			0x0C1
-	access_mode	RW
-	modes		M_CFG
-	field	BYPASSENAB	0x80
-	field	DESQDIS		0x10
-	field	RCVROFFSTDIS	0x04
-	field	XMITOFFSTDIS	0x02
-}
-
-/*
- * Data FIFO Read Address
- * Pointer to the next QWD location to be read from the data FIFO.
- */
-register DFRADDR {
-	address			0x0C2
-	access_mode	RW
-	size		2
-	modes		M_DFF0, M_DFF1
-}
-
-/*
- * DSP REQ Control
- */
-register DSPREQCTL {
-	address			0x0C2
-	access_mode	RW
-	modes		M_CFG
-	field	MANREQCTL	0xC0
-	field	MANREQDLY	0x3F
-}
-
-/*
- * DSP ACK Control
- */
-register DSPACKCTL {
-	address			0x0C3
-	access_mode	RW
-	modes		M_CFG
-	field	MANACKCTL	0xC0
-	field	MANACKDLY	0x3F
-}
-
-/*
- * Data FIFO Data
- * Read/Write byte port into the data FIFO.  The read and write
- * FIFO pointers increment with each read and write respectively
- * to this port.
- */
-register DFDAT {
-	address			0x0C4
-	access_mode	RW
-	modes		M_DFF0, M_DFF1
-}
-
-/*
- * DSP Channel Select
- */
-register DSPSELECT {
-	address			0x0C4
-	access_mode	RW
-	modes		M_CFG
-	field	AUTOINCEN	0x80
-	field	DSPSEL		0x1F
-}
-
-const NUMDSPS 0x14
-
-/*
- * Write Bias Control
- */
-register WRTBIASCTL {
-	address			0x0C5
-	access_mode	WO
-	modes		M_CFG
-	field	AUTOXBCDIS	0x80
-	field	XMITMANVAL	0x3F
-}
-
-/*
- * Currently the WRTBIASCTL is the same as the default.
- */
-const WRTBIASCTL_HP_DEFAULT 0x0
-
-/*
- * Receiver Bias Control
- */
-register RCVRBIOSCTL {
-	address			0x0C6
-	access_mode	WO
-	modes		M_CFG
-	field	AUTORBCDIS	0x80
-	field	RCVRMANVAL	0x3F
-}
-
-/*
- * Write Bias Calculator
- */
-register WRTBIASCALC {
-	address			0x0C7
-	access_mode	RO
-	modes		M_CFG
-}
-
-/*
- * Data FIFO Pointers
- * Contains the byte offset from DFWADDR and DWRADDR to the current
- * FIFO write/read locations.
- */
-register DFPTRS {
-	address			0x0C8
-	access_mode	RW
-	modes		M_DFF0, M_DFF1
-}
-
-/*
- * Receiver Bias Calculator
- */
-register RCVRBIASCALC {
-	address			0x0C8
-	access_mode	RO
-	modes		M_CFG
-}
-
-/*
- * Data FIFO Backup Read Pointer
- * Contains the data FIFO address to be restored if the last
- * data accessed from the data FIFO was not transferred successfully.
- */
-register DFBKPTR {
-	address			0x0C9
-	access_mode	RW
-	size		2
-	modes		M_DFF0, M_DFF1
-}
-
-/*
- * Skew Calculator
- */
-register SKEWCALC {
-	address			0x0C9
-	access_mode	RO
-	modes		M_CFG
-}
-
-/*
- * Data FIFO Debug Control
- */
-register DFDBCTL {
-	address				0x0CB
-	access_mode	RW
-	modes		M_DFF0, M_DFF1
-	field	DFF_CIO_WR_RDY		0x20
-	field	DFF_CIO_RD_RDY		0x10
-	field	DFF_DIR_ERR		0x08
-	field	DFF_RAMBIST_FAIL	0x04
-	field	DFF_RAMBIST_DONE	0x02
-	field	DFF_RAMBIST_EN		0x01
-}
-
-/*
- * Data FIFO Space Count
- * Number of FIFO locations that are free.
- */
-register DFSCNT {
-	address			0x0CC
-	access_mode	RO
-	size		2
-	modes		M_DFF0, M_DFF1
-}
-
-/*
- * Data FIFO Byte Count
- * Number of filled FIFO locations.
- */
-register DFBCNT {
-	address			0x0CE
-	access_mode	RO
-	size		2
-	modes		M_DFF0, M_DFF1
-}
-
-/*
- * Sequencer Program Overlay Address.
- * Low address must be written prior to high address.
- */
-register OVLYADDR {
-	address			0x0D4
-	modes		M_SCSI
-	size		2
-	access_mode	RW
-}
-
-/*
- * Sequencer Control 0
- * Error detection mode, speed configuration,
- * single step, breakpoints and program load.
- */
-register SEQCTL0 {
-	address			0x0D6
-	access_mode RW
-	field	PERRORDIS	0x80
-	field	PAUSEDIS	0x40
-	field	FAILDIS		0x20
-	field	FASTMODE	0x10
-	field	BRKADRINTEN	0x08
-	field	STEP		0x04
-	field	SEQRESET	0x02
-	field	LOADRAM		0x01
-}
-
-/*
- * Sequencer Control 1
- * Instruction RAM Diagnostics
- */
-register SEQCTL1 {
-	address			0x0D7
-	access_mode RW
-	field	OVRLAY_DATA_CHK	0x08
-	field	RAMBIST_DONE	0x04
-	field	RAMBIST_FAIL	0x02
-	field	RAMBIST_EN	0x01
-}
-
-/*
- * Sequencer Flags
- * Zero and Carry state of the ALU.
- */
-register FLAGS {
-	address			0x0D8
-	access_mode RO
-	field	ZERO		0x02
-	field	CARRY		0x01
-}
-
-/*
- * Sequencer Interrupt Control
- */ 
-register SEQINTCTL {
-	address			0x0D9
-	access_mode RW
-	field	INTVEC1DSL	0x80
-	field	INT1_CONTEXT	0x20
-	field	SCS_SEQ_INT1M1	0x10
-	field	SCS_SEQ_INT1M0	0x08
-	field	INTMASK2	0x04
-	field	INTMASK1	0x02
-	field	IRET		0x01
-}
-
-/*
- * Sequencer RAM Data Port
- * Single byte window into the Sequencer Instruction Ram area starting
- * at the address specified by OVLYADDR.  To write a full instruction word,
- * simply write four bytes in succession.  OVLYADDR will increment after the
- * most significant instrution byte (the byte with the parity bit) is written.
- */
-register SEQRAM {
-	address			0x0DA
-	access_mode RW
-}
-
-/*
- * Sequencer Program Counter
- * Low byte must be written prior to high byte.
- */
-register PRGMCNT {
-	address			0x0DE
-	access_mode	RW
-	size		2
-}
-
-/*
- * Accumulator
- */
-register ACCUM {
-	address			0x0E0
-	access_mode RW
-	accumulator
-}
-
-/*
- * Source Index Register
- * Incrementing index for reads of SINDIR and the destination (low byte only)
- * for any immediate operands passed in jmp, jc, jnc, call instructions.
- * Example:
- *		mvi	0xFF	call some_routine;
- *
- *  Will set SINDEX[0] to 0xFF and call the routine "some_routine.
- */
-register SINDEX	{
-	address			0x0E2
-	access_mode	RW
-	size		2
-	sindex
-}
-
-/*
- * Destination Index Register
- * Incrementing index for writes to DINDIR.  Can be used as a scratch register.
- */
-register DINDEX {
-	address			0x0E4
-	access_mode	RW
-	size		2
-}
-
-/*
- * Break Address
- * Sequencer instruction breakpoint address address.
- */
-register BRKADDR0 {
-	address			0x0E6
-	access_mode	RW
-}
-
-register BRKADDR1 {
-	address			0x0E6
-	access_mode	RW
-	field	BRKDIS		0x80	/* Disable Breakpoint */
-}
-
-/*
- * All Ones
- * All reads to this register return the value 0xFF.
- */
-register ALLONES {
-	address			0x0E8
-	access_mode RO
-	allones
-}
-
-/*
- * All Zeros
- * All reads to this register return the value 0.
- */
-register ALLZEROS {
-	address			0x0EA
-	access_mode RO
-	allzeros
-}
-
-/*
- * No Destination
- * Writes to this register have no effect.
- */
-register NONE {
-	address			0x0EA
-	access_mode WO
-	none
-}
-
-/*
- * Source Index Indirect
- * Reading this register is equivalent to reading (register_base + SINDEX) and
- * incrementing SINDEX by 1.
- */
-register SINDIR	{
-	address			0x0EC
-	access_mode RO
-}
-
-/*
- * Destination Index Indirect
- * Writing this register is equivalent to writing to (register_base + DINDEX)
- * and incrementing DINDEX by 1.
- */
-register DINDIR	 {
-	address			0x0ED
-	access_mode WO
-}
-
-/*
- * Function One
- * 2's complement to bit value conversion.  Write the 2's complement value
- * (0-7 only) to the top nibble and retrieve the bit indexed by that value
- * on the next read of this register. 
- * Example:
- *	Write	0x60
- *	Read	0x40
- */
-register FUNCTION1 {
-	address			0x0F0
-	access_mode RW
-}
-
-/*
- * Stack
- * Window into the stack.  Each stack location is 10 bits wide reported
- * low byte followed by high byte.  There are 8 stack locations.
- */
-register STACK {
-	address			0x0F2
-	access_mode RW
-}
-
-/*
- * Interrupt Vector 1 Address
- * Interrupt branch address for SCS SEQ_INT1 mode 0 and 1 interrupts.
- */
-register INTVEC1_ADDR {
-	address			0x0F4
-	access_mode	RW
-	size		2
-	modes		M_CFG
-}
-
-/*
- * Current Address
- * Address of the SEQRAM instruction currently executing instruction.
- */
-register CURADDR {
-	address			0x0F4
-	access_mode	RW
-	size		2
-	modes		M_SCSI
-}
-
-/*
- * Interrupt Vector 2 Address
- * Interrupt branch address for HST_SEQ_INT2 interrupts.
- */
-register INTVEC2_ADDR {
-	address			0x0F6
-	access_mode	RW
-	size		2
-	modes		M_CFG
-}
-
-/*
- * Last Address
- * Address of the SEQRAM instruction executed prior to the current instruction.
- */
-register LASTADDR {
-	address			0x0F6
-	access_mode	RW
-	size		2
-	modes		M_SCSI
-}
-
-register AHD_PCI_CONFIG_BASE {
-	address			0x100
-	access_mode	RW
-	size		256
-	modes		M_CFG
-}
-
-/* ---------------------- Scratch RAM Offsets ------------------------- */
-scratch_ram {
-	/* Mode Specific */
-	address			0x0A0
-	size	8
-	modes	0, 1, 2, 3
-	REG0 {
-		size		2
-	}
-	REG1 {
-		size		2
-	}
-	REG_ISR {
-		size		2
-	}
-	SG_STATE {
-		size		1
-		field	SEGS_AVAIL	0x01
-		field	LOADING_NEEDED	0x02
-		field	FETCH_INPROG	0x04
-	}
-	/*
-	 * Track whether the transfer byte count for
-	 * the current data phase is odd.
-	 */
-	DATA_COUNT_ODD {
-		size		1
-	}
-}
-
-scratch_ram {
-	/* Mode Specific */
-	address			0x0F8
-	size	8
-	modes	0, 1, 2, 3
-	LONGJMP_ADDR {
-		size		2
-	}
-	LONGJMP_SCB {
-		size		2
-	}
-	ACCUM_SAVE {
-		size		1
-	}
-}
-
-
-scratch_ram {
-	address			0x100
-	size	128
-	modes	0, 1, 2, 3
-	/*
-	 * Per "other-id" execution queues.  We use an array of
-	 * tail pointers into lists of SCBs sorted by "other-id".
-	 * The execution head pointer threads the head SCBs for
-	 * each list.
-	 */
-	WAITING_SCB_TAILS {
-		size		32
-	}
-	WAITING_TID_HEAD {
-		size		2
-	}
-	WAITING_TID_TAIL {
-		size		2
-	}
-	/*
-	 * SCBID of the next SCB in the new SCB queue.
-	 */
-	NEXT_QUEUED_SCB_ADDR {
-		size		4
-	}
-	/*
-	 * head of list of SCBs that have
-	 * completed but have not been
-	 * put into the qoutfifo.
-	 */
-	COMPLETE_SCB_HEAD {
-		size		2
-	}
-	/*
-	 * The list of completed SCBs in
-	 * the active DMA.
-	 */
-	COMPLETE_SCB_DMAINPROG_HEAD {
-		size		2
-	}
-	/*
-	 * head of list of SCBs that have
-	 * completed but need to be uploaded
-	 * to the host prior to being completed.
-	 */
-	COMPLETE_DMA_SCB_HEAD {
-		size		2
-	}
-	/* Counting semaphore to prevent new select-outs */
-	QFREEZE_COUNT {
-		size		2
-	}
-	/*
-	 * Mode to restore on legacy idle loop exit.
-	 */
-	SAVED_MODE {
-		size		1
-	}
-	/*
-	 * Single byte buffer used to designate the type or message
-	 * to send to a target.
-	 */
-	MSG_OUT {
-		size		1
-	}
-	/* Parameters for DMA Logic */
-	DMAPARAMS {
-		size		1
-		field	PRELOADEN	0x80
-		field	WIDEODD		0x40
-		field	SCSIEN		0x20
-		field	SDMAEN		0x10
-		field	SDMAENACK	0x10
-		field	HDMAEN		0x08
-		field	HDMAENACK	0x08
-		field	DIRECTION	0x04	/* Set indicates PCI->SCSI */
-		field	FIFOFLUSH	0x02
-		field	FIFORESET	0x01
-	}
-	SEQ_FLAGS {
-		size		1
-		field	NOT_IDENTIFIED		0x80
-		field	NO_CDB_SENT		0x40
-		field	TARGET_CMD_IS_TAGGED	0x40
-		field	DPHASE			0x20
-		/* Target flags */
-		field	TARG_CMD_PENDING	0x10
-		field	CMDPHASE_PENDING	0x08
-		field	DPHASE_PENDING		0x04
-		field	SPHASE_PENDING		0x02
-		field	NO_DISCONNECT		0x01
-	}
-	/*
-	 * Temporary storage for the
-	 * target/channel/lun of a
-	 * reconnecting target
-	 */
-	SAVED_SCSIID {
-		size		1
-	}
-	SAVED_LUN {
-		size		1
-	}
-	/*
-	 * The last bus phase as seen by the sequencer. 
-	 */
-	LASTPHASE {
-		size		1
-		field	CDI		0x80
-		field	IOI		0x40
-		field	MSGI		0x20
-		field	P_BUSFREE	0x01
-		enum	PHASE_MASK  CDO|IOO|MSGO {
-			P_DATAOUT	0x0,
-			P_DATAIN	IOO,
-			P_DATAOUT_DT	P_DATAOUT|MSGO,
-			P_DATAIN_DT	P_DATAIN|MSGO,
-			P_COMMAND	CDO,
-			P_MESGOUT	CDO|MSGO,
-			P_STATUS	CDO|IOO,
-			P_MESGIN	CDO|IOO|MSGO
-		}
-	}
-	/*
-	 * Value to "or" into the SCBPTR[1] value to
-	 * indicate that an entry in the QINFIFO is valid.
-	 */
-	QOUTFIFO_ENTRY_VALID_TAG {
-		size		1
-	}
-	/*
-	 * Base address of our shared data with the kernel driver in host
-	 * memory.  This includes the qoutfifo and target mode
-	 * incoming command queue.
-	 */
-	SHARED_DATA_ADDR {
-		size		4
-	}
-	/*
-	 * Pointer to location in host memory for next
-	 * position in the qoutfifo.
-	 */
-	QOUTFIFO_NEXT_ADDR {
-		size		4
-	}
-	/*
-	 * Kernel and sequencer offsets into the queue of
-	 * incoming target mode command descriptors.  The
-	 * queue is full when the KERNEL_TQINPOS == TQINPOS.
-	 */
-	KERNEL_TQINPOS {
-		size		1
-	}
-	TQINPOS {                
-		size		1
-	}
-	ARG_1 {
-		size		1
-		mask	SEND_MSG		0x80
-		mask	SEND_SENSE		0x40
-		mask	SEND_REJ		0x20
-		mask	MSGOUT_PHASEMIS		0x10
-		mask	EXIT_MSG_LOOP		0x08
-		mask	CONT_MSG_LOOP_WRITE	0x04
-		mask	CONT_MSG_LOOP_READ	0x03
-		mask	CONT_MSG_LOOP_TARG	0x02
-		alias	RETURN_1
-	}
-	ARG_2 {
-		size		1
-		alias	RETURN_2
-	}
-
-	/*
-	 * Snapshot of MSG_OUT taken after each message is sent.
-	 */
-	LAST_MSG {
-		size		1
-	}
-
-	/*
-	 * Sequences the kernel driver has okayed for us.  This allows
-	 * the driver to do things like prevent initiator or target
-	 * operations.
-	 */
-	SCSISEQ_TEMPLATE {
-		size		1
-		field	MANUALCTL	0x40
-		field	ENSELI		0x20
-		field	ENRSELI		0x10
-		field	MANUALP		0x0C
-		field	ENAUTOATNP	0x02
-		field	ALTSTIM		0x01
-	}
-
-	/*
-	 * The initiator specified tag for this target mode transaction.
-	 */
-	INITIATOR_TAG {
-		size		1
-	}
-
-	SEQ_FLAGS2 {
-		size		1
-		field	TARGET_MSG_PENDING	  0x02
-		field	SELECTOUT_QFROZEN	  0x04
-	}
-
-	ALLOCFIFO_SCBPTR {
-		size		2
-	}
-
-	/*
-	 * The maximum amount of time to wait, when interrupt coalessing
-	 * is enabled, before issueing a CMDCMPLT interrupt for a completed
-	 * command.
-	 */
-	INT_COALESSING_TIMER {
-		size		2
-	}
-
-	/*
-	 * The maximum number of commands to coaless into a single interrupt.
-	 * Actually the 2's complement of that value to simplify sequencer
-	 * code.
-	 */
-	INT_COALESSING_MAXCMDS {
-		size		1
-	}
-
-	/*
-	 * The minimum number of commands still outstanding required
-	 * to continue coalessing (2's compliment of value).
-	 */
-	INT_COALESSING_MINCMDS {
-		size		1
-	}
-
-	/*
-	 * Number of commands "in-flight".
-	 */
-	CMDS_PENDING {
-		size		2
-	}
-
-	/*
-	 * The count of commands that have been coalessed.
-	 */
-	INT_COALESSING_CMDCOUNT {
-		size		1
-	}
-
-	/*
-	 * Since the HS_MAIBOX is self clearing, copy its contents to
-	 * this position in scratch ram every time it changes.
-	 */
-	LOCAL_HS_MAILBOX {
-		size		1
-	}
-	/*
-	 * Target-mode CDB type to CDB length table used
-	 * in non-packetized operation.
-	 */
-	CMDSIZE_TABLE {
-		size		8
-	}
-}
-
-/************************* Hardware SCB Definition ****************************/
-scb {
-	address			0x180
-	size	64
-	modes	0, 1, 2, 3
-	SCB_RESIDUAL_DATACNT {
-		size	4
-		alias	SCB_CDB_STORE
-	}
-	SCB_RESIDUAL_SGPTR {
-		size	4
-		alias	SCB_CDB_PTR
-		field	SG_ADDR_MASK		0xf8	/* In the last byte */
-		field	SG_OVERRUN_RESID	0x02	/* In the first byte */
-		field	SG_LIST_NULL		0x01	/* In the first byte */
-	}
-	SCB_SCSI_STATUS {
-		size	1
-	}
-	SCB_TARGET_PHASES {
-		size	1
-	}
-	SCB_TARGET_DATA_DIR {
-		size	1
-	}
-	SCB_TARGET_ITAG {
-		size	1
-	}
-	SCB_SENSE_BUSADDR {
-		/*
-		 * Only valid if CDB length is less than 13 bytes or
-		 * we are using a CDB pointer.  Otherwise contains
-		 * the last 4 bytes of embedded cdb information.
-		 */
-		size	4
-		alias	SCB_NEXT_COMPLETE
-	}
-	SCB_TAG {
-		size	2
-	}
-	SCB_CDB_LEN {
-		size	1
-		field	SCB_CDB_LEN_PTR	0x80	/* CDB in host memory */
-	}
-	SCB_TASK_MANAGEMENT {
-		size	1
-	}
-	SCB_NEXT {
-		alias	SCB_NEXT_SCB_BUSADDR
-		size	2
-	}
-	SCB_NEXT2 {
-		size	2
-	}
-	SCB_DATAPTR {
-		size	8
-	}
-	SCB_DATACNT {
-		/*
-		 * The last byte is really the high address bits for
-		 * the data address.
-		 */
-		size	4
-		field	SG_LAST_SEG		0x80	/* In the fourth byte */
-		field	SG_HIGH_ADDR_BITS	0x7F	/* In the fourth byte */
-	}
-	SCB_SGPTR {
-		size	4
-		field	SG_STATUS_VALID	0x04	/* In the first byte */
-		field	SG_FULL_RESID	0x02	/* In the first byte */
-		field	SG_LIST_NULL	0x01	/* In the first byte */
-	}
-	SCB_CONTROL {
-		size	1
-		field	TARGET_SCB	0x80
-		field	DISCENB		0x40
-		field	TAG_ENB		0x20
-		field	MK_MESSAGE	0x10
-		field	STATUS_RCVD	0x08
-		field	DISCONNECTED	0x04
-		field	SCB_TAG_TYPE	0x03
-	}
-	SCB_SCSIID {
-		size	1
-		field	TID	0xF0
-		field	OID	0x0F
-	}
-	SCB_LUN {
-		size	1
-		field	LID				0xff
-	}
-	SCB_TASK_ATTRIBUTE {
-		size	1
-	}
-	SCB_BUSADDR {
-		size	4
-	}
-	SCB_SPARE {
-		size	8
-		alias	SCB_PKT_LUN
-	}
-	SCB_DISCONNECTED_LISTS {
-		size	8
-	}
-}
-
-/*********************************** Constants ********************************/
-const MK_MESSAGE_BIT_OFFSET	4
-const TID_SHIFT		4
-const TARGET_CMD_CMPLT	0xfe
-const INVALID_ADDR	0x80
-#define SCB_LIST_NULL	0xff
-#define QOUTFIFO_ENTRY_VALID_TOGGLE	0x80
-
-const CCSGADDR_MAX	0x80
-const CCSCBADDR_MAX	0x80
-const CCSGRAM_MAXSEGS	16
-
-/* Selection Timeout Timer Constants */
-const STIMESEL_SHIFT	3
-const STIMESEL_MIN	0x18
-const STIMESEL_BUG_ADJ	0x8
-
-/* WDTR Message values */
-const BUS_8_BIT			0x00
-const BUS_16_BIT		0x01
-const BUS_32_BIT		0x02
-
-/* Offset maximums */
-const MAX_OFFSET		0xfe
-const MAX_OFFSET_PACED		0xfe
-const MAX_OFFSET_PACED_BUG	0x7f
-/*
- * Some 160 devices incorrectly accept 0xfe as a
- * sync offset, but will overrun this value.  Limit
- * to 0x7f for speed lower than U320 which will
- * avoid the persistent sync offset overruns.
- */
-const MAX_OFFSET_NON_PACED	0x7f
-const HOST_MSG			0xff
-
-/*
- * The size of our sense buffers.
- * Sense buffer mapping can be handled in either of two ways.
- * The first is to allocate a dmamap for each transaction.
- * Depending on the architecture, dmamaps can be costly. The
- * alternative is to statically map the buffers in much the same
- * way we handle our scatter gather lists.  The driver implements
- * the later.
- */
-const AHD_SENSE_BUFSIZE		256
-
-/* Target mode command processing constants */
-const CMD_GROUP_CODE_SHIFT	0x05
-
-const STATUS_BUSY		0x08
-const STATUS_QUEUE_FULL		0x28
-const STATUS_PKT_SENSE		0xFF
-const TARGET_DATA_IN		1
-
-const SCB_TRANSFER_SIZE_FULL_LUN	56
-const SCB_TRANSFER_SIZE_1BYTE_LUN	48
-/* PKT_OVERRUN_BUFSIZE must be a multiple of 256 less than 64K */
-const PKT_OVERRUN_BUFSIZE	512
-
-/*
- * Timer parameters.
- */
-const AHD_TIMER_US_PER_TICK	25
-const AHD_TIMER_MAX_TICKS	0xFFFF
-const AHD_TIMER_MAX_US		(AHD_TIMER_MAX_TICKS * AHD_TIMER_US_PER_TICK)
-
-/*
- * Downloaded (kernel inserted) constants
- */
-const SG_PREFETCH_CNT download
-const SG_PREFETCH_CNT_LIMIT download
-const SG_PREFETCH_ALIGN_MASK download
-const SG_PREFETCH_ADDR_MASK download
-const SG_SIZEOF download
-const PKT_OVERRUN_BUFOFFSET download
-const SCB_TRANSFER_SIZE	download
-
-/*
- * BIOS SCB offsets
- */
-const NVRAM_SCB_OFFSET	0x2C
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aic79xx.seq linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx.seq
--- linux-2.4.21/drivers/scsi/aic79xx/aic79xx.seq	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx.seq	2003-06-26 21:43:10.000000000 +0000
@@ -1,1889 +0,0 @@
-/*
- * Adaptec U320 device driver firmware for Linux and FreeBSD.
- *
- * Copyright (c) 1994-2001 Justin T. Gibbs.
- * Copyright (c) 2000-2002 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.
- *
- * $FreeBSD$
- */
-
-VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#78 $"
-PATCH_ARG_LIST = "struct ahd_softc *ahd"
-PREFIX = "ahd_"
-
-#include "aic79xx.reg"
-#include "scsi_message.h"
-
-restart:
-if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) {
-	test	SEQINTCODE, 0xFF jz idle_loop;
-	SET_SEQINTCODE(NO_SEQINT)
-}
-
-idle_loop:
-
-	if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) {
-		/*
-		 * Convert ERROR status into a sequencer
-		 * interrupt to handle the case of an
-		 * interrupt collision on the hardware
-		 * setting of HWERR.
-		 */
-		test	ERROR, 0xFF jz no_error_set;
-		SET_SEQINTCODE(SAW_HWERR)
-no_error_set:
-	}
-	SET_MODE(M_SCSI, M_SCSI)
-	test	SCSISEQ0, ENSELO|ENARBO jnz idle_loop_checkbus;
-	test	SEQ_FLAGS2, SELECTOUT_QFROZEN jnz idle_loop_checkbus;
-	cmp	WAITING_TID_HEAD[1], SCB_LIST_NULL je idle_loop_checkbus;
-	/*
-	 * ENSELO is cleared by a SELDO, so we must test for SELDO
-	 * one last time.
-	 */
-BEGIN_CRITICAL;
-	test	SSTAT0, SELDO jnz select_out;
-END_CRITICAL;
-	call	start_selection;
-idle_loop_checkbus:
-BEGIN_CRITICAL;
-	test	SSTAT0, SELDO jnz select_out;
-END_CRITICAL;
-	test	SSTAT0, SELDI jnz select_in;
-	test	SCSIPHASE, ~DATA_PHASE_MASK jz idle_loop_check_nonpackreq;
-	test	SCSISIGO, ATNO jz idle_loop_check_nonpackreq;
-	call	unexpected_nonpkt_phase_find_ctxt;
-idle_loop_check_nonpackreq:
-	test	SSTAT2, NONPACKREQ jz . + 2;
-	call	unexpected_nonpkt_phase_find_ctxt;
-	call	idle_loop_gsfifo_in_scsi_mode;
-	call	idle_loop_service_fifos;
-	call	idle_loop_cchan;
-	jmp	idle_loop;
-
-BEGIN_CRITICAL;
-idle_loop_gsfifo:
-	SET_MODE(M_SCSI, M_SCSI)
-idle_loop_gsfifo_in_scsi_mode:
-	test	LQISTAT2, LQIGSAVAIL jz return;
-	/*
-	 * We have received good status for this transaction.  There may
-	 * still be data in our FIFOs draining to the host.  Setup
-	 * monitoring of the draining process or complete the SCB.
-	 */
-good_status_IU_done:
-	bmov	SCBPTR, GSFIFO, 2;
-	clr	SCB_SCSI_STATUS;
-	/*
-	 * If a command completed before an attempted task management
-	 * function completed, notify the host after disabling any
-	 * pending select-outs.
-	 */
-	test	SCB_TASK_MANAGEMENT, 0xFF jz gsfifo_complete_normally;
-	test	SSTAT0, SELDO|SELINGO jnz . + 2;
-	and	SCSISEQ0, ~ENSELO;
-	SET_SEQINTCODE(TASKMGMT_CMD_CMPLT_OKAY)
-gsfifo_complete_normally:
-	or	SCB_CONTROL, STATUS_RCVD;
-
-	/*
-	 * Since this status did not consume a FIFO, we have to
-	 * be a bit more dilligent in how we check for FIFOs pertaining
-	 * to this transaction.  There are three states that a FIFO still
-	 * transferring data may be in.
-	 *
-	 * 1) Configured and draining to the host, with a pending CLRCHN.
-	 * 2) Configured and draining to the host, no pending CLRCHN.
-	 * 3) Pending cfg4data, fifo not empty.
-	 *
-	 * Cases 1 and 2 can be detected by noticing that a longjmp is
-	 * active for the FIFO and LONGJMP_SCB matches our SCB.  In this
-	 * case, we allow the routine servicing the FIFO to complete the SCB.
-	 * 
-	 * Case 3 implies either a pending or yet to occur save data
-	 * pointers for this same context in the other FIFO.  So, if
-	 * we detect case 2, we will properly defer the post of the SCB
-	 * and achieve the desired result.  The pending cfg4data will
-	 * notice that status has been received and complete the SCB.
-	 */
-	test	SCB_SGPTR, SG_LIST_NULL jz good_status_check_fifos;
-	/*
-	 * All segments have been loaded (or no data transfer), so
-	 * it is safe to complete the command.  Since this was a
-	 * cheap command to check for completion, loop to see if
-	 * more entries can be removed from the GSFIFO.
-	 */
-	call	complete;
-END_CRITICAL;
-	jmp	idle_loop_gsfifo_in_scsi_mode;
-BEGIN_CRITICAL;
-good_status_check_fifos:
-	clc;
-	bmov	ARG_1, SCBPTR, 2;
-	SET_MODE(M_DFF0, M_DFF0)
-	call	check_fifo;
-	jc	return;
-	SET_MODE(M_DFF1, M_DFF1)
-	call	check_fifo;
-	jc	return;
-	SET_MODE(M_SCSI, M_SCSI)
-	jmp	queue_scb_completion;
-END_CRITICAL;
-
-idle_loop_service_fifos:
-	SET_MODE(M_DFF0, M_DFF0)
-	test	LONGJMP_ADDR[1], INVALID_ADDR jnz idle_loop_next_fifo;
-	call	longjmp;
-idle_loop_next_fifo:
-	SET_MODE(M_DFF1, M_DFF1)
-	test	LONGJMP_ADDR[1], INVALID_ADDR jz longjmp;
-	ret;
-
-idle_loop_cchan:
-	SET_MODE(M_CCHAN, M_CCHAN)
-	test	QOFF_CTLSTA, HS_MAILBOX_ACT jz	hs_mailbox_empty;
-	mov	LOCAL_HS_MAILBOX, HS_MAILBOX;
-	or	QOFF_CTLSTA, HS_MAILBOX_ACT;
-hs_mailbox_empty:
-BEGIN_CRITICAL;
-	test	CCSCBCTL, CCARREN|CCSCBEN jz scbdma_idle;
-	test	CCSCBCTL, CCSCBDIR jnz fetch_new_scb_inprog;
-	test	CCSCBCTL, CCSCBDONE jz return;
-END_CRITICAL;
-	/* FALLTHROUGH */
-scbdma_tohost_done:
-	test	CCSCBCTL, CCARREN jz fill_qoutfifo_dmadone;
-	/*
-	 * A complete SCB upload requires no intervention.
-	 * The SCB is already on the COMPLETE_SCB list
-	 * and its completion notification will now be
-	 * handled just like any other SCB.
-	 */
-	and	CCSCBCTL, ~(CCARREN|CCSCBEN) ret;
-fill_qoutfifo_dmadone:
-	and	CCSCBCTL, ~(CCARREN|CCSCBEN);
-	call	qoutfifo_updated;
-	mvi	COMPLETE_SCB_DMAINPROG_HEAD[1], SCB_LIST_NULL;
-	bmov	QOUTFIFO_NEXT_ADDR, SCBHADDR, 4;
-	test	QOFF_CTLSTA, SDSCB_ROLLOVR jz return;
-	bmov	QOUTFIFO_NEXT_ADDR, SHARED_DATA_ADDR, 4;
-	xor	QOUTFIFO_ENTRY_VALID_TAG, QOUTFIFO_ENTRY_VALID_TOGGLE ret;
-
-qoutfifo_updated:
-	/*
-	 * If there are more commands waiting to be dma'ed
-	 * to the host, always coaless.  Otherwise honor the
-	 * host's wishes.
-	 */
-	cmp	COMPLETE_DMA_SCB_HEAD[1], SCB_LIST_NULL jne coaless_by_count;
-	cmp	COMPLETE_SCB_HEAD[1], SCB_LIST_NULL jne coaless_by_count;
-	test	LOCAL_HS_MAILBOX, ENINT_COALESS jz issue_cmdcmplt;
-
-	/*
-	 * If we have relatively few commands outstanding, don't
-	 * bother waiting for another command to complete.
-	 */
-	test	CMDS_PENDING[1], 0xFF jnz coaless_by_count;
-	/* Add -1 so that jnc means <= not just < */
-	add	A, -1, INT_COALESSING_MINCMDS;
-	add	NONE, A, CMDS_PENDING;
-	jnc	issue_cmdcmplt;
-	
-	/*
-	 * If coalessing, only coaless up to the limit
-	 * provided by the host driver.
-	 */
-coaless_by_count:
-	mov	A, INT_COALESSING_MAXCMDS;
-	add	NONE, A, INT_COALESSING_CMDCOUNT;
-	jc	issue_cmdcmplt;
-	/*
-	 * If the timer is not currently active,
-	 * fire it up.
-	 */
-	test	INTCTL, SWTMINTMASK jz return;
-	bmov	SWTIMER, INT_COALESSING_TIMER, 2;
-	mvi	CLRSEQINTSTAT, CLRSEQ_SWTMRTO;
-	or	INTCTL, SWTMINTEN|SWTIMER_START;
-	and	INTCTL, ~SWTMINTMASK ret;
-
-issue_cmdcmplt:
-	mvi	INTSTAT, CMDCMPLT;
-	clr	INT_COALESSING_CMDCOUNT;
-	or	INTCTL, SWTMINTMASK ret;
-
-BEGIN_CRITICAL;
-fetch_new_scb_inprog:
-	test	CCSCBCTL, ARRDONE jz return;
-fetch_new_scb_done:
-	and	CCSCBCTL, ~(CCARREN|CCSCBEN);
-	bmov	REG0, SCBPTR, 2;
-	clr	A;
-	add	CMDS_PENDING, 1;
-	adc	CMDS_PENDING[1], A;
-	/* Update the next SCB address to download. */
-	bmov	NEXT_QUEUED_SCB_ADDR, SCB_NEXT_SCB_BUSADDR, 4;
-	mvi	SCB_NEXT[1], SCB_LIST_NULL;
-	mvi	SCB_NEXT2[1], SCB_LIST_NULL;
-	/* Increment our position in the QINFIFO. */
-	mov	NONE, SNSCB_QOFF;
-	/*
-	 * SCBs that want to send messages are always
-	 * queued independently.  This ensures that they
-	 * are at the head of the SCB list to select out
-	 * to a target and we will see the MK_MESSAGE flag.
-	 */
-	test	SCB_CONTROL, MK_MESSAGE jnz first_new_target_scb;
-	shr	SINDEX, 3, SCB_SCSIID;
-	and	SINDEX, ~0x1;
-	mvi	SINDEX[1], (WAITING_SCB_TAILS >> 8);
-	bmov	DINDEX, SINDEX, 2;
-	bmov	SCBPTR, SINDIR, 2;
-	bmov	DINDIR, REG0, 2;
-	cmp	SCBPTR[1], SCB_LIST_NULL je first_new_target_scb;
-	bmov	SCB_NEXT, REG0, 2 ret;
-first_new_target_scb:
-	cmp	WAITING_TID_HEAD[1], SCB_LIST_NULL je first_new_scb;
-	bmov	SCBPTR, WAITING_TID_TAIL, 2;
-	bmov	SCB_NEXT2, REG0, 2;
-	bmov	WAITING_TID_TAIL, REG0, 2 ret;
-first_new_scb:
-	bmov	WAITING_TID_HEAD, REG0, 2;
-	bmov	WAITING_TID_TAIL, REG0, 2 ret;
-END_CRITICAL;
-
-scbdma_idle:
-	/*
-	 * Give precedence to downloading new SCBs to execute
-	 * unless select-outs are currently frozen.
-	 */
-	test	SEQ_FLAGS2, SELECTOUT_QFROZEN jnz . + 2;
-BEGIN_CRITICAL;
-	test	QOFF_CTLSTA, NEW_SCB_AVAIL jnz fetch_new_scb;
-	cmp	COMPLETE_DMA_SCB_HEAD[1], SCB_LIST_NULL jne dma_complete_scb;
-	cmp	COMPLETE_SCB_HEAD[1], SCB_LIST_NULL je return;
-	/* FALLTHROUGH */
-fill_qoutfifo:
-	/*
-	 * Keep track of the SCBs we are dmaing just
-	 * in case the DMA fails or is aborted.
-	 */
-	mov	A, QOUTFIFO_ENTRY_VALID_TAG;
-	bmov	COMPLETE_SCB_DMAINPROG_HEAD, COMPLETE_SCB_HEAD, 2;
-	mvi	CCSCBCTL, CCSCBRESET;
-	bmov	SCBHADDR, QOUTFIFO_NEXT_ADDR, 4;
-	bmov	SCBPTR, COMPLETE_SCB_HEAD, 2;
-fill_qoutfifo_loop:
-	mov	CCSCBRAM, SCBPTR;
-	or	CCSCBRAM, A, SCBPTR[1];
-	mov	NONE, SDSCB_QOFF;
-	inc	INT_COALESSING_CMDCOUNT;
-	add	CMDS_PENDING, -1;
-	adc	CMDS_PENDING[1], -1;
-	cmp	SCB_NEXT_COMPLETE[1], SCB_LIST_NULL je fill_qoutfifo_done;
-	cmp	CCSCBADDR, CCSCBADDR_MAX je fill_qoutfifo_done;
-	test	QOFF_CTLSTA, SDSCB_ROLLOVR jnz fill_qoutfifo_done;
-	bmov	SCBPTR, SCB_NEXT_COMPLETE, 2;
-	jmp	fill_qoutfifo_loop;
-fill_qoutfifo_done:
-	mov	SCBHCNT, CCSCBADDR;
-	mvi	CCSCBCTL, CCSCBEN|CCSCBRESET;
-	bmov	COMPLETE_SCB_HEAD, SCB_NEXT_COMPLETE, 2;
-	mvi	SCB_NEXT_COMPLETE[1], SCB_LIST_NULL ret;
-
-fetch_new_scb:
-	bmov	SCBHADDR, NEXT_QUEUED_SCB_ADDR, 4;
-	mvi	CCARREN|CCSCBEN|CCSCBDIR|CCSCBRESET jmp dma_scb;
-dma_complete_scb:
-	bmov	SCBPTR, COMPLETE_DMA_SCB_HEAD, 2;
-	bmov	SCBHADDR, SCB_BUSADDR, 4;
-	mvi	CCARREN|CCSCBEN|CCSCBRESET call dma_scb;
-	/*
-	 * Now that we've started the DMA, push us onto
-	 * the normal completion queue to have our SCBID
-	 * posted to the kernel.
-	 */
-	bmov	COMPLETE_DMA_SCB_HEAD, SCB_NEXT_COMPLETE, 2;
-	bmov	SCB_NEXT_COMPLETE, COMPLETE_SCB_HEAD, 2;
-	bmov	COMPLETE_SCB_HEAD, SCBPTR, 2 ret;
-END_CRITICAL;
-
-/*
- * Either post or fetch an SCB from host memory.  The caller
- * is responsible for polling for transfer completion.
- *
- * Prerequisits: Mode == M_CCHAN
- *		 SINDEX contains CCSCBCTL flags
- *		 SCBHADDR set to Host SCB address
- *		 SCBPTR set to SCB src location on "push" operations
- */
-SET_SRC_MODE	M_CCHAN;
-SET_DST_MODE	M_CCHAN;
-dma_scb:
-	mvi	SCBHCNT, SCB_TRANSFER_SIZE;
-	mov	CCSCBCTL, SINDEX ret;
-
-BEGIN_CRITICAL;
-setjmp_setscb:
-	bmov	LONGJMP_SCB, SCBPTR, 2;
-setjmp:
-	bmov	LONGJMP_ADDR, STACK, 2 ret;
-setjmp_inline:
-	bmov	LONGJMP_ADDR, STACK, 2;
-longjmp:
-	bmov	STACK, LONGJMP_ADDR, 2 ret;
-END_CRITICAL;
-
-/*************************** Chip Bug Work Arounds ****************************/
-/*
- * Must disable interrupts when setting the mode pointer
- * register as an interrupt occurring mid update will
- * fail to store the new mode value for restoration on
- * an iret.
- */
-if ((ahd->bugs & AHD_SET_MODE_BUG) != 0) {
-set_mode_work_around:
-	mvi	SEQINTCTL, INTVEC1DSL;
-	mov	MODE_PTR, SINDEX;
-	clr	SEQINTCTL ret;
-
-toggle_dff_mode_work_around:
-	mvi	SEQINTCTL, INTVEC1DSL;
-	xor	MODE_PTR, MK_MODE(M_DFF1, M_DFF1);
-	clr	SEQINTCTL ret;
-}
-
-
-if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) {
-set_seqint_work_around:
-	mov	SEQINTCODE, SINDEX;
-	mvi	SEQINTCODE, NO_SEQINT ret;
-}
-
-/************************ Packetized LongJmp Routines *************************/
-SET_SRC_MODE	M_SCSI;
-SET_DST_MODE	M_SCSI;
-start_selection:
-BEGIN_CRITICAL;
-	if ((ahd->bugs & AHD_SENT_SCB_UPDATE_BUG) != 0) {
-		/*
-		 * Razor #494
-		 * Rev A hardware fails to update LAST/CURR/NEXTSCB
-		 * correctly after a packetized selection in several
-		 * situations:
-		 *
-		 * 1) If only one command existed in the queue, the
-		 *    LAST/CURR/NEXTSCB are unchanged.
-		 *
-		 * 2) In a non QAS, protocol allowed phase change,
-		 *    the queue is shifted 1 too far.  LASTSCB is
-		 *    the last SCB that was correctly processed.
-		 * 
-		 * 3) In the QAS case, if the full list of commands
-		 *    was successfully sent, NEXTSCB is NULL and neither
-		 *    CURRSCB nor LASTSCB can be trusted.  We must
-		 *    manually walk the list counting MAXCMDCNT elements
-		 *    to find the last SCB that was sent correctly.
-		 *
-		 * To simplify the workaround for this bug in SELDO
-		 * handling, we initialize LASTSCB prior to enabling
-		 * selection so we can rely on it even for case #1 above.
-		 */
-		bmov	LASTSCB, WAITING_TID_HEAD, 2;
-	}
-	bmov	CURRSCB, WAITING_TID_HEAD, 2;
-	bmov	SCBPTR, WAITING_TID_HEAD, 2;
-	shr	SELOID, 4, SCB_SCSIID;
-	/*
-	 * If we want to send a message to the device, ensure
-	 * we are selecting with atn irregardless of our packetized
-	 * agreement.  Since SPI4 only allows target reset or PPR
-	 * messages if this is a packetized connection, the change
-	 * to our negotiation table entry for this selection will
-	 * be cleared when the message is acted on.
-	 */
-	test	SCB_CONTROL, MK_MESSAGE jz . + 3;
-	mov	NEGOADDR, SELOID;
-	or	NEGCONOPTS, ENAUTOATNO;
-	or	SCSISEQ0, ENSELO ret;
-END_CRITICAL;
-
-/*
- * Allocate a FIFO for a non-packetized transaction.
- * In RevA hardware, both FIFOs must be free before we
- * can allocate a FIFO for a non-packetized transaction.
- */
-allocate_fifo_loop:
-	/*
-	 * Do whatever work is required to free a FIFO.
-	 */
-	call	idle_loop_service_fifos;
-	SET_MODE(M_SCSI, M_SCSI)
-allocate_fifo:
-	if ((ahd->bugs & AHD_NONPACKFIFO_BUG) != 0) {
-		and	A, FIFO0FREE|FIFO1FREE, DFFSTAT;
-		cmp	A, FIFO0FREE|FIFO1FREE jne allocate_fifo_loop;
-	} else {
-		test	DFFSTAT, FIFO1FREE jnz allocate_fifo1;
-		test	DFFSTAT, FIFO0FREE jz allocate_fifo_loop;
-		mvi	DFFSTAT, B_CURRFIFO_0;
-		SET_MODE(M_DFF0, M_DFF0)
-		bmov	SCBPTR, ALLOCFIFO_SCBPTR, 2 ret;
-	}
-SET_SRC_MODE	M_SCSI;
-SET_DST_MODE	M_SCSI;
-allocate_fifo1:
-	mvi	DFFSTAT, CURRFIFO_1;
-	SET_MODE(M_DFF1, M_DFF1)
-	bmov	SCBPTR, ALLOCFIFO_SCBPTR, 2 ret;
-
-/*
- * We have been reselected as an initiator
- * or selected as a target.
- */
-SET_SRC_MODE	M_SCSI;
-SET_DST_MODE	M_SCSI;
-select_in:
-	if ((ahd->bugs & AHD_BUSFREEREV_BUG) != 0) {
-		/*
-		 * This exposes a window whereby a
-		 * busfree just after a selection will
-		 * be missed, but there is no other safe
-		 * way to enable busfree detection if
-		 * the busfreerev function is broken.
-		 */
-		mvi	CLRSINT1,CLRBUSFREE;
-		or	SIMODE1, ENBUSFREE;
-	}
-	or	SXFRCTL0, SPIOEN;
-	and	SAVED_SCSIID, SELID_MASK, SELID;
-	and	A, OID, IOWNID;
-	or	SAVED_SCSIID, A;
-	mvi	CLRSINT0, CLRSELDI;
-	jmp	ITloop;
-
-/*
- * We have successfully selected out.
- *
- * Clear SELDO.
- * Dequeue all SCBs sent from the waiting queue
- * Requeue all SCBs *not* sent to the tail of the waiting queue
- * Take Razor #494 into account for above.
- *
- * In Packetized Mode:
- *	Return to the idle loop.  Our interrupt handler will take
- *	care of any incoming L_Qs.
- *
- * In Non-Packetize Mode:
- *	Continue to our normal state machine.
- */
-SET_SRC_MODE	M_SCSI;
-SET_DST_MODE	M_SCSI;
-select_out:
-BEGIN_CRITICAL;
-	/* Clear out all SCBs that have been successfully sent. */
-	if ((ahd->bugs & AHD_SENT_SCB_UPDATE_BUG) != 0) {
-		/*
-		 * For packetized, the LQO manager clears ENSELO on
-		 * the assertion of SELDO.  If we are non-packetized,
-		 * LASTSCB and CURRSCB are acuate.
-		 */
-		test	SCSISEQ0, ENSELO jnz use_lastscb;
-
-		/*
-		 * The update is correct for LQOSTAT1 errors.  All
-		 * but LQOBUSFREE are handled by kernel interrupts.
-		 * If we see LQOBUSFREE, return to the idle loop.
-		 * Once we are out of the select_out critical section,
-		 * the kernel will cleanup the LQOBUSFREE and we will
-		 * eventually restart the selection if appropriate.
-		 */
-		test	LQOSTAT1, LQOBUSFREE jnz idle_loop;
-
-		/*
-		 * On a phase change oustside of packet boundaries,
-		 * LASTSCB points to the currently active SCB context
-		 * on the bus.
-		 */
-		test	LQOSTAT2, LQOPHACHGOUTPKT jnz use_lastscb;
-
-		/*
-		 * If the hardware has traversed the whole list, NEXTSCB
-		 * will be NULL, CURRSCB and LASTSCB cannot be trusted,
-		 * but MAXCMDCNT is accurate.  If we stop part way through
-		 * the list or only had one command to issue, NEXTSCB[1] is
-		 * not NULL and LASTSCB is the last command to go out.
-		 */
-		cmp	NEXTSCB[1], SCB_LIST_NULL jne use_lastscb;
-
-		/*
-		 * Brute force walk.
-		 */
-		bmov	SCBPTR, WAITING_TID_HEAD, 2;
-		mvi	SEQINTCTL, INTVEC1DSL;
-		mvi	MODE_PTR, MK_MODE(M_CFG, M_CFG);
-		mov	A, MAXCMDCNT;
-		mvi	MODE_PTR, MK_MODE(M_SCSI, M_SCSI);
-		clr	SEQINTCTL;
-find_lastscb_loop:
-		dec	A;
-		test	A, 0xFF jz found_last_sent_scb;
-		bmov	SCBPTR, SCB_NEXT, 2;
-		jmp	find_lastscb_loop;
-use_lastscb:
-		bmov	SCBPTR, LASTSCB, 2;
-found_last_sent_scb:
-		bmov	CURRSCB, SCBPTR, 2;
-curscb_ww_done:
-	} else {
-		/*
-		 * Untested - Verify with Rev B.
-		 */
-		bmov	SCBPTR, CURRSCB, 2;
-	}
-
-	/*
-	 * Requeue any SCBs not sent, to the tail of the waiting Q.
-	 */
-	cmp	SCB_NEXT[1], SCB_LIST_NULL je select_out_list_done;
-
-	/*
-	 * We know that neither the per-TID list nor the list of
-	 * TIDs is empty.  Use this knowledge to our advantage.
-	 */
-	bmov	REG0, SCB_NEXT, 2;
-	bmov	SCBPTR, WAITING_TID_TAIL, 2;
-	bmov	SCB_NEXT2, REG0, 2;
-	bmov	WAITING_TID_TAIL, REG0, 2;
-	jmp	select_out_inc_tid_q;
-
-select_out_list_done:
-	/*
-	 * The whole list made it.  Just clear our TID's tail pointer
-	 * unless we were queued independently due to our need to
-	 * send a message.
-	 */
-	test	SCB_CONTROL, MK_MESSAGE jnz select_out_inc_tid_q;
-	shr	DINDEX, 3, SCB_SCSIID;
-	or	DINDEX, 1;	/* Want only the second byte */
-	mvi	DINDEX[1], ((WAITING_SCB_TAILS) >> 8);
-	mvi	DINDIR, SCB_LIST_NULL;
-select_out_inc_tid_q:
-	bmov	SCBPTR, WAITING_TID_HEAD, 2;
-	bmov	WAITING_TID_HEAD, SCB_NEXT2, 2;
-	cmp	WAITING_TID_HEAD[1], SCB_LIST_NULL jne . + 2;
-	mvi	WAITING_TID_TAIL[1], SCB_LIST_NULL;
-	bmov	SCBPTR, CURRSCB, 2;
-	mvi	CLRSINT0, CLRSELDO;
-	test	LQOSTAT2, LQOPHACHGOUTPKT jnz unexpected_nonpkt_phase;
-	test	LQOSTAT1, LQOPHACHGINPKT jnz unexpected_nonpkt_phase;
-
-	/*
-	 * If this is a packetized connection, return to our
-	 * idle_loop and let our interrupt handler deal with
-	 * any connection setup/teardown issues.  The only
-	 * exceptions are the case of MK_MESSAGE and task management
-	 * SCBs.
-	 */
-	if ((ahd->bugs & AHD_LQO_ATNO_BUG) != 0) {
-		/*
-		 * In the A, the LQO manager transitions to LQOSTOP0 even if
-		 * we have selected out with ATN asserted and the target
-		 * REQs in a non-packet phase.
-		 */
-		test 	SCB_CONTROL, MK_MESSAGE jz select_out_no_message;
-		test	SCSISIGO, ATNO jnz select_out_non_packetized;
-select_out_no_message:
-	}
-	test	LQOSTAT2, LQOSTOP0 jz select_out_non_packetized;
-	test	SCB_TASK_MANAGEMENT, 0xFF jz idle_loop;
-	SET_SEQINTCODE(TASKMGMT_FUNC_COMPLETE)
-	jmp	idle_loop;
-
-select_out_non_packetized:
-	/* Non packetized request. */
-	and     SCSISEQ0, ~ENSELO;
-	if ((ahd->bugs & AHD_BUSFREEREV_BUG) != 0) {
-		/*
-		 * This exposes a window whereby a
-		 * busfree just after a selection will
-		 * be missed, but there is no other safe
-		 * way to enable busfree detection if
-		 * the busfreerev function is broken.
-		 */
-		mvi	CLRSINT1,CLRBUSFREE;
-		or	SIMODE1, ENBUSFREE;
-	}
-	mov	SAVED_SCSIID, SCB_SCSIID;
-	mov	SAVED_LUN, SCB_LUN;
-	mvi	SEQ_FLAGS, NO_CDB_SENT;
-END_CRITICAL;
-	or	SXFRCTL0, SPIOEN;
-
-	/*
-	 * As soon as we get a successful selection, the target
-	 * should go into the message out phase since we have ATN
-	 * asserted.
-	 */
-	mvi	MSG_OUT, MSG_IDENTIFYFLAG;
-
-	/*
-	 * Main loop for information transfer phases.  Wait for the
-	 * target to assert REQ before checking MSG, C/D and I/O for
-	 * the bus phase.
-	 */
-mesgin_phasemis:
-ITloop:
-	call	phase_lock;
-
-	mov	A, LASTPHASE;
-
-	test	A, ~P_DATAIN_DT	jz p_data;
-	cmp	A,P_COMMAND	je p_command;
-	cmp	A,P_MESGOUT	je p_mesgout;
-	cmp	A,P_STATUS	je p_status;
-	cmp	A,P_MESGIN	je p_mesgin;
-
-	SET_SEQINTCODE(BAD_PHASE)
-	jmp	ITloop;			/* Try reading the bus again. */
-
-/*
- * Command phase.  Set up the DMA registers and let 'er rip.
- */
-p_command:
-	test	SEQ_FLAGS, NOT_IDENTIFIED jz p_command_okay;
-	SET_SEQINTCODE(PROTO_VIOLATION)
-p_command_okay:
-	test	MODE_PTR, ~(MK_MODE(M_DFF1, M_DFF1))
-		jnz p_command_allocate_fifo;
-	/*
-	 * Command retry.  Free our current FIFO and
-	 * re-allocate a FIFO so transfer state is
-	 * reset.
-	 */
-SET_SRC_MODE	M_DFF1;
-SET_DST_MODE	M_DFF1;
-	mvi	DFFSXFRCTL, RSTCHN|CLRSHCNT;
-	SET_MODE(M_SCSI, M_SCSI)
-p_command_allocate_fifo:
-	bmov	ALLOCFIFO_SCBPTR, SCBPTR, 2;
-	call	allocate_fifo;
-SET_SRC_MODE	M_DFF1;
-SET_DST_MODE	M_DFF1;
-	add	NONE, -17, SCB_CDB_LEN;
-	jnc	p_command_embedded;
-p_command_from_host:
-	bmov	HADDR[0], SCB_CDB_PTR, 11;
-	mvi	SG_CACHE_PRE, LAST_SEG;
-	mvi	DFCNTRL, (PRELOADEN|SCSIEN|HDMAEN);
-	jmp	p_command_xfer;
-p_command_embedded:
-	bmov	SHCNT[0], SCB_CDB_LEN,  1;
-	bmov	DFDAT, SCB_CDB_STORE, 16; 
-	mvi	DFCNTRL, SCSIEN;
-p_command_xfer:
-	and	SEQ_FLAGS, ~NO_CDB_SENT;
-	test	DFCNTRL, SCSIEN jnz .;
-	/*
-	 * DMA Channel automatically disabled.
-	 * Don't allow a data phase if the command
-	 * was not fully transferred.
-	 */
-	test	SSTAT2, SDONE jnz ITloop;
-	or	SEQ_FLAGS, NO_CDB_SENT;
-	jmp	ITloop;
-
-
-/*
- * Status phase.  Wait for the data byte to appear, then read it
- * and store it into the SCB.
- */
-SET_SRC_MODE	M_SCSI;
-SET_DST_MODE	M_SCSI;
-p_status:
-	test	SEQ_FLAGS,NOT_IDENTIFIED jnz mesgin_proto_violation;
-p_status_okay:
-	mov	SCB_SCSI_STATUS, SCSIDAT;
-	or	SCB_CONTROL, STATUS_RCVD;
-	jmp	ITloop;
-
-/*
- * Message out phase.  If MSG_OUT is MSG_IDENTIFYFLAG, build a full
- * indentify message sequence and send it to the target.  The host may
- * override this behavior by setting the MK_MESSAGE bit in the SCB
- * control byte.  This will cause us to interrupt the host and allow
- * it to handle the message phase completely on its own.  If the bit
- * associated with this target is set, we will also interrupt the host,
- * thereby allowing it to send a message on the next selection regardless
- * of the transaction being sent.
- * 
- * If MSG_OUT is == HOST_MSG, also interrupt the host and take a message.
- * This is done to allow the host to send messages outside of an identify
- * sequence while protecting the seqencer from testing the MK_MESSAGE bit
- * on an SCB that might not be for the current nexus. (For example, a
- * BDR message in responce to a bad reselection would leave us pointed to
- * an SCB that doesn't have anything to do with the current target).
- *
- * Otherwise, treat MSG_OUT as a 1 byte message to send (abort, abort tag,
- * bus device reset).
- *
- * When there are no messages to send, MSG_OUT should be set to MSG_NOOP,
- * in case the target decides to put us in this phase for some strange
- * reason.
- */
-p_mesgout_retry:
-	/* Turn on ATN for the retry */
-	mvi	SCSISIGO, ATNO;
-p_mesgout:
-	mov	SINDEX, MSG_OUT;
-	cmp	SINDEX, MSG_IDENTIFYFLAG jne p_mesgout_from_host;
-	test	SCB_CONTROL,MK_MESSAGE	jnz host_message_loop;
-p_mesgout_identify:
-	or	SINDEX, MSG_IDENTIFYFLAG|DISCENB, SCB_LUN;
-	test	SCB_CONTROL, DISCENB jnz . + 2;
-	and	SINDEX, ~DISCENB;
-/*
- * Send a tag message if TAG_ENB is set in the SCB control block.
- * Use SCB_NONPACKET_TAG as the tag value.
- */
-p_mesgout_tag:
-	test	SCB_CONTROL,TAG_ENB jz  p_mesgout_onebyte;
-	mov	SCSIDAT, SINDEX;	/* Send the identify message */
-	call	phase_lock;
-	cmp	LASTPHASE, P_MESGOUT	jne p_mesgout_done;
-	and	SCSIDAT,TAG_ENB|SCB_TAG_TYPE,SCB_CONTROL;
-	call	phase_lock;
-	cmp	LASTPHASE, P_MESGOUT	jne p_mesgout_done;
-	mov	SCBPTR jmp p_mesgout_onebyte;
-/*
- * Interrupt the driver, and allow it to handle this message
- * phase and any required retries.
- */
-p_mesgout_from_host:
-	cmp	SINDEX, HOST_MSG	jne p_mesgout_onebyte;
-	jmp	host_message_loop;
-
-p_mesgout_onebyte:
-	mvi	CLRSINT1, CLRATNO;
-	mov	SCSIDAT, SINDEX;
-
-/*
- * If the next bus phase after ATN drops is message out, it means
- * that the target is requesting that the last message(s) be resent.
- */
-	call	phase_lock;
-	cmp	LASTPHASE, P_MESGOUT	je p_mesgout_retry;
-
-p_mesgout_done:
-	mvi	CLRSINT1,CLRATNO;	/* Be sure to turn ATNO off */
-	mov	LAST_MSG, MSG_OUT;
-	mvi	MSG_OUT, MSG_NOOP;	/* No message left */
-	jmp	ITloop;
-
-/*
- * Message in phase.  Bytes are read using Automatic PIO mode.
- */
-p_mesgin:
-	/* read the 1st message byte */
-	mvi	ACCUM		call inb_first;
-
-	test	A,MSG_IDENTIFYFLAG	jnz mesgin_identify;
-	cmp	A,MSG_DISCONNECT	je mesgin_disconnect;
-	cmp	A,MSG_SAVEDATAPOINTER	je mesgin_sdptrs;
-	cmp	ALLZEROS,A		je mesgin_complete;
-	cmp	A,MSG_RESTOREPOINTERS	je mesgin_rdptrs;
-	cmp	A,MSG_IGN_WIDE_RESIDUE	je mesgin_ign_wide_residue;
-	cmp	A,MSG_NOOP		je mesgin_done;
-
-/*
- * Pushed message loop to allow the kernel to
- * run it's own message state engine.  To avoid an
- * extra nop instruction after signaling the kernel,
- * we perform the phase_lock before checking to see
- * if we should exit the loop and skip the phase_lock
- * in the ITloop.  Performing back to back phase_locks
- * shouldn't hurt, but why do it twice...
- */
-host_message_loop:
-	call	phase_lock;	/* Benign the first time through. */
-	SET_SEQINTCODE(HOST_MSG_LOOP)
-	cmp	RETURN_1, EXIT_MSG_LOOP	je ITloop;
-	cmp	RETURN_1, CONT_MSG_LOOP_WRITE	jne . + 3;
-	mov	SCSIDAT, RETURN_2;
-	jmp	host_message_loop;
-	/* Must be CONT_MSG_LOOP_READ */
-	mov	NONE, SCSIDAT;	/* ACK Byte */
-	jmp	host_message_loop;
-
-mesgin_ign_wide_residue:
-	mov	SAVED_MODE, MODE_PTR;
-	SET_MODE(M_SCSI, M_SCSI)
-	shr	NEGOADDR, 4, SAVED_SCSIID;
-	mov	A, NEGCONOPTS;
-	RESTORE_MODE(SAVED_MODE)
-	test	A, WIDEXFER jz mesgin_reject;
-	/* Pull the residue byte */
-	mvi	REG0	call inb_next;
-	cmp	REG0, 0x01 jne mesgin_reject;
-	test	SCB_RESIDUAL_SGPTR[0], SG_LIST_NULL jz . + 2;
-	test	DATA_COUNT_ODD, 0x1	jz mesgin_done;
-	jmp	mesgin_done;
-
-mesgin_proto_violation:
-	SET_SEQINTCODE(PROTO_VIOLATION)
-	jmp	mesgin_done;
-mesgin_reject:
-	mvi	MSG_MESSAGE_REJECT	call mk_mesg;
-mesgin_done:
-	mov	NONE,SCSIDAT;		/*dummy read from latch to ACK*/
-	jmp	ITloop;
-
-#define INDEX_DISC_LIST(scsiid, lun)					\
-	and	A, 0xC0, scsiid;					\
-	or	SCBPTR, A, lun;						\
-	clr	SCBPTR[1];						\
-	and	SINDEX, 0x30, scsiid;					\
-	shr	SINDEX, 3;	/* Multiply by 2 */			\
-	add	SINDEX, (SCB_DISCONNECTED_LISTS & 0xFF);		\
-	mvi	SINDEX[1], ((SCB_DISCONNECTED_LISTS >> 8) & 0xFF)
-
-mesgin_identify:
-	/*
-	 * Determine whether a target is using tagged or non-tagged
-	 * transactions by first looking at the transaction stored in
-	 * the per-device, disconnected array.  If there is no untagged
-	 * transaction for this target, this must be a tagged transaction.
-	 */
-	and	SAVED_LUN, MSG_IDENTIFY_LUNMASK, A;
-	INDEX_DISC_LIST(SAVED_SCSIID, SAVED_LUN);
-	bmov	DINDEX, SINDEX, 2;
-	bmov	REG0, SINDIR, 2;
-	cmp	REG0[1], SCB_LIST_NULL je snoop_tag;
-	/* Untagged.  Clear the busy table entry and setup the SCB. */
-	bmov	DINDIR, ALLONES, 2;
-	bmov	SCBPTR, REG0, 2;
-	jmp	setup_SCB;
-
-/*
- * Here we "snoop" the bus looking for a SIMPLE QUEUE TAG message.
- * If we get one, we use the tag returned to find the proper
- * SCB.  After receiving the tag, look for the SCB at SCB locations tag and
- * tag + 256.
- */
-snoop_tag:
-	if ((ahd->flags & AHD_SEQUENCER_DEBUG) != 0) {
-		or	SEQ_FLAGS, 0x80;
-	}
-	mov	NONE, SCSIDAT;		/* ACK Identify MSG */
-	call	phase_lock;
-	if ((ahd->flags & AHD_SEQUENCER_DEBUG) != 0) {
-		or	SEQ_FLAGS, 0x1;
-	}
-	cmp	LASTPHASE, P_MESGIN	jne not_found_ITloop;
-	if ((ahd->flags & AHD_SEQUENCER_DEBUG) != 0) {
-		or	SEQ_FLAGS, 0x2;
-	}
-	cmp	SCSIBUS, MSG_SIMPLE_Q_TAG jne not_found;
-get_tag:
-	clr	SCBPTR[1];
-	mvi	SCBPTR	call inb_next;	/* tag value */
-verify_scb:
-	test	SCB_CONTROL,DISCONNECTED jz verify_other_scb;
-	mov	A, SAVED_SCSIID;
-	cmp	SCB_SCSIID, A jne verify_other_scb;
-	mov	A, SAVED_LUN;
-	cmp	SCB_LUN, A je setup_SCB_disconnected;
-verify_other_scb:
-	xor	SCBPTR[1], 1;
-	test	SCBPTR[1], 0xFF jnz verify_scb;
-	jmp	not_found;
-
-/*
- * Ensure that the SCB the tag points to is for
- * an SCB transaction to the reconnecting target.
- */
-setup_SCB:
-	if ((ahd->flags & AHD_SEQUENCER_DEBUG) != 0) {
-		or	SEQ_FLAGS, 0x10;
-	}
-	test	SCB_CONTROL,DISCONNECTED jz not_found;
-setup_SCB_disconnected:
-	and	SCB_CONTROL,~DISCONNECTED;
-	clr	SEQ_FLAGS;	/* make note of IDENTIFY */
-	test	SCB_SGPTR, SG_LIST_NULL jnz . + 3;
-	bmov	ALLOCFIFO_SCBPTR, SCBPTR, 2;
-	call	allocate_fifo;
-	/* See if the host wants to send a message upon reconnection */
-	test	SCB_CONTROL, MK_MESSAGE jz mesgin_done;
-	mvi	HOST_MSG	call mk_mesg;
-	jmp	mesgin_done;
-
-not_found:
-	SET_SEQINTCODE(NO_MATCH)
-	jmp	mesgin_done;
-
-not_found_ITloop:
-	SET_SEQINTCODE(NO_MATCH)
-	jmp	ITloop;
-
-/*
- * We received a "command complete" message.  Put the SCB on the complete
- * queue and trigger a completion interrupt via the idle loop.  Before doing
- * so, check to see if there
- * is a residual or the status byte is something other than STATUS_GOOD (0).
- * In either of these conditions, we upload the SCB back to the host so it can
- * process this information.  In the case of a non zero status byte, we 
- * additionally interrupt the kernel driver synchronously, allowing it to
- * decide if sense should be retrieved.  If the kernel driver wishes to request
- * sense, it will fill the kernel SCB with a request sense command, requeue
- * it to the QINFIFO and tell us not to post to the QOUTFIFO by setting 
- * RETURN_1 to SEND_SENSE.
- */
-mesgin_complete:
-
-	/*
-	 * If ATN is raised, we still want to give the target a message.
-	 * Perhaps there was a parity error on this last message byte.
-	 * Either way, the target should take us to message out phase
-	 * and then attempt to complete the command again.  We should use a
-	 * critical section here to guard against a timeout triggering
-	 * for this command and setting ATN while we are still processing
-	 * the completion.
-	test	SCSISIGI, ATNI jnz mesgin_done;
-	 */
-
-	/*
-	 * If we are identified and have successfully sent the CDB,
-	 * any status will do.  Optimize this fast path.
-	 */
-	test	SCB_CONTROL, STATUS_RCVD jz mesgin_proto_violation;
-	test	SEQ_FLAGS, NOT_IDENTIFIED|NO_CDB_SENT jz complete_accepted;
-
-	/*
-	 * If the target never sent an identify message but instead went
-	 * to mesgin to give an invalid message, let the host abort us.
-	 */
-	test	SEQ_FLAGS, NOT_IDENTIFIED jnz mesgin_proto_violation;
-
-	/*
-	 * If we recevied good status but never successfully sent the
-	 * cdb, abort the command.
-	 */
-	test	SCB_SCSI_STATUS,0xff	jnz complete_accepted;
-	test	SEQ_FLAGS, NO_CDB_SENT jnz mesgin_proto_violation;
-complete_accepted:
-
-	/*
-	 * See if we attempted to deliver a message but the target ingnored us.
-	 */
-	test	SCB_CONTROL, MK_MESSAGE jz complete_nomsg;
-	SET_SEQINTCODE(MKMSG_FAILED)
-complete_nomsg:
-	call	queue_scb_completion;
-	jmp	await_busfree;
-
-freeze_queue:
-	/* Cancel any pending select-out. */
-	test	SSTAT0, SELDO|SELINGO jnz . + 2;
-	and	SCSISEQ0, ~ENSELO;
-	mov	ACCUM_SAVE, A;
-	clr	A;
-	add	QFREEZE_COUNT, 1;
-	adc	QFREEZE_COUNT[1], A;
-	or	SEQ_FLAGS2, SELECTOUT_QFROZEN;
-	mov	A, ACCUM_SAVE ret;
-
-queue_arg1_scb_completion:
-	SET_MODE(M_SCSI, M_SCSI)
-	bmov	SCBPTR, ARG_1, 2;
-queue_scb_completion:
-	if ((ahd->bugs & AHD_ABORT_LQI_BUG) == 0) {
-		/*
-		 * Set MK_MESSAGE to trigger an abort should this SCB
-		 * be referenced by a target even though it is not currently
-		 * active.
-		 */
-		or	SCB_CONTROL, MK_MESSAGE;
-	}
-	test	SCB_SCSI_STATUS,0xff	jnz bad_status;
-	/*
-	 * Check for residuals
-	 */
-	test	SCB_SGPTR, SG_LIST_NULL jnz complete;	/* No xfer */
-	test	SCB_SGPTR, SG_FULL_RESID jnz upload_scb;/* Never xfered */
-	test	SCB_RESIDUAL_SGPTR, SG_LIST_NULL jz upload_scb;
-complete:
-	bmov	SCB_NEXT_COMPLETE, COMPLETE_SCB_HEAD, 2;
-	bmov	COMPLETE_SCB_HEAD, SCBPTR, 2 ret;
-bad_status:
-	cmp	SCB_SCSI_STATUS, STATUS_PKT_SENSE je upload_scb;
-	call	freeze_queue;
-upload_scb:
-	bmov	SCB_NEXT_COMPLETE, COMPLETE_DMA_SCB_HEAD, 2;
-	bmov	COMPLETE_DMA_SCB_HEAD, SCBPTR, 2;
-	or	SCB_SGPTR, SG_STATUS_VALID ret;
-
-/*
- * Is it a disconnect message?  Set a flag in the SCB to remind us
- * and await the bus going free.  If this is an untagged transaction
- * store the SCB id for it in our untagged target table for lookup on
- * a reselction.
- */
-mesgin_disconnect:
-	/*
-	 * If ATN is raised, we still want to give the target a message.
-	 * Perhaps there was a parity error on this last message byte
-	 * or we want to abort this command.  Either way, the target
-	 * should take us to message out phase and then attempt to
-	 * disconnect again.
-	 * XXX - Wait for more testing.
-	test	SCSISIGI, ATNI jnz mesgin_done;
-	 */
-	test	SEQ_FLAGS, NOT_IDENTIFIED|NO_CDB_SENT
-		jnz mesgin_proto_violation;
-	or	SCB_CONTROL,DISCONNECTED;
-	test	SCB_CONTROL, TAG_ENB jnz await_busfree;
-queue_disc_scb:
-	bmov	REG0, SCBPTR, 2;
-	INDEX_DISC_LIST(SAVED_SCSIID, SAVED_LUN);
-	bmov	DINDEX, SINDEX, 2;
-	bmov	DINDIR, REG0, 2;
-	bmov	SCBPTR, REG0, 2;
-	/* FALLTHROUGH */
-await_busfree:
-	and	SIMODE1, ~ENBUSFREE;
-	if ((ahd->bugs & AHD_BUSFREEREV_BUG) == 0) {
-		/*
-		 * In the BUSFREEREV_BUG case, the
-		 * busfree status was cleared at the
-		 * beginning of the connection.
-		 */
-		mvi	CLRSINT1,CLRBUSFREE;
-	}
-	mov	NONE, SCSIDAT;		/* Ack the last byte */
-	test	MODE_PTR, ~(MK_MODE(M_DFF1, M_DFF1))
-		jnz await_busfree_not_m_dff;
-SET_SRC_MODE	M_DFF1;
-SET_DST_MODE	M_DFF1;
-await_busfree_clrchn:
-	mvi	DFFSXFRCTL, CLRCHN;
-await_busfree_not_m_dff:
-	call	clear_target_state;
-	test	SSTAT1,REQINIT|BUSFREE	jz .;
-	test	SSTAT1, BUSFREE jnz idle_loop;
-	SET_SEQINTCODE(MISSED_BUSFREE)
-
-
-/*
- * Save data pointers message:
- * Copying RAM values back to SCB, for Save Data Pointers message, but
- * only if we've actually been into a data phase to change them.  This
- * protects against bogus data in scratch ram and the residual counts
- * since they are only initialized when we go into data_in or data_out.
- * Ack the message as soon as possible.
- */
-SET_SRC_MODE	M_DFF1;
-SET_DST_MODE	M_DFF1;
-mesgin_sdptrs:
-	mov	NONE,SCSIDAT;		/*dummy read from latch to ACK*/
-	test	SEQ_FLAGS, DPHASE	jz ITloop;
-	call	save_pointers;
-	jmp	ITloop;
-
-save_pointers:
-	/*
-	 * If we are asked to save our position at the end of the
-	 * transfer, just mark us at the end rather than perform a
-	 * full save.
-	 */
-	test	SCB_RESIDUAL_SGPTR[0], SG_LIST_NULL jz save_pointers_full;
-	or	SCB_SGPTR, SG_LIST_NULL ret;
-
-save_pointers_full:
-	/*
-	 * The SCB_DATAPTR becomes the current SHADDR.
-	 * All other information comes directly from our residual
-	 * state.
-	 */
-	bmov	SCB_DATAPTR, SHADDR, 8;
-	bmov	SCB_DATACNT, SCB_RESIDUAL_DATACNT, 8 ret;
-
-/*
- * Restore pointers message?  Data pointers are recopied from the
- * SCB anytime we enter a data phase for the first time, so all
- * we need to do is clear the DPHASE flag and let the data phase
- * code do the rest.  We also reset/reallocate the FIFO to make
- * sure we have a clean start for the next data or command phase.
- */
-mesgin_rdptrs:
-	and	SEQ_FLAGS, ~DPHASE;
-	test	MODE_PTR, ~(MK_MODE(M_DFF1, M_DFF1)) jnz msgin_rdptrs_get_fifo;
-	mvi	DFFSXFRCTL, RSTCHN|CLRSHCNT;
-	SET_MODE(M_SCSI, M_SCSI)
-msgin_rdptrs_get_fifo:
-	call	allocate_fifo;
-	jmp	mesgin_done;
-
-clear_target_state:
-	mvi	LASTPHASE, P_BUSFREE;
-	/* clear target specific flags */
-	mvi	SEQ_FLAGS, NOT_IDENTIFIED|NO_CDB_SENT ret;
-
-phase_lock:     
-	test	SCSIPHASE, 0xFF jz .;
-	test	SSTAT1, SCSIPERR jnz phase_lock;
-phase_lock_latch_phase:
-	and	LASTPHASE, PHASE_MASK, SCSISIGI ret;
-
-/*
- * Functions to read data in Automatic PIO mode.
- *
- * An ACK is not sent on input from the target until SCSIDATL is read from.
- * So we wait until SCSIDATL is latched (the usual way), then read the data
- * byte directly off the bus using SCSIBUSL.  When we have pulled the ATN
- * line, or we just want to acknowledge the byte, then we do a dummy read
- * from SCISDATL.  The SCSI spec guarantees that the target will hold the
- * data byte on the bus until we send our ACK.
- *
- * The assumption here is that these are called in a particular sequence,
- * and that REQ is already set when inb_first is called.  inb_{first,next}
- * use the same calling convention as inb.
- */
-inb_next:
-	mov	NONE,SCSIDAT;		/*dummy read from latch to ACK*/
-inb_next_wait:
-	/*
-	 * If there is a parity error, wait for the kernel to
-	 * see the interrupt and prepare our message response
-	 * before continuing.
-	 */
-	test	SCSIPHASE, 0xFF jz .;
-	test	SSTAT1, SCSIPERR jnz inb_next_wait;
-inb_next_check_phase:
-	and	LASTPHASE, PHASE_MASK, SCSISIGI;
-	cmp	LASTPHASE, P_MESGIN jne mesgin_phasemis;
-inb_first:
-	clr	DINDEX[1];
-	mov	DINDEX,SINDEX;
-	mov	DINDIR,SCSIBUS	ret;		/*read byte directly from bus*/
-inb_last:
-	mov	NONE,SCSIDAT ret;		/*dummy read from latch to ACK*/
-
-mk_mesg:
-	mvi	SCSISIGO, ATNO;
-	mov	MSG_OUT,SINDEX ret;
-
-SET_SRC_MODE	M_DFF1;
-SET_DST_MODE	M_DFF1;
-disable_ccsgen:
-	test	SG_STATE, FETCH_INPROG jz disable_ccsgen_fetch_done;
-	clr	CCSGCTL;
-disable_ccsgen_fetch_done:
-	clr	SG_STATE ret;
-
-service_fifo:
-	/*
-	 * Do we have any prefetch left???
-	 */
-	test	SG_STATE, SEGS_AVAIL jnz idle_sg_avail;
-
-	/*
-	 * Can this FIFO have access to the S/G cache yet?
-	 */
-	test	CCSGCTL, SG_CACHE_AVAIL jz return;
-
-	/* Did we just finish fetching segs? */
-	test	CCSGCTL, CCSGDONE jnz idle_sgfetch_complete;
-
-	/* Are we actively fetching segments? */
-	test	CCSGCTL, CCSGENACK jnz return;
-
-	/*
-	 * We fetch a "cacheline aligned" and sized amount of data
-	 * so we don't end up referencing a non-existant page.
-	 * Cacheline aligned is in quotes because the kernel will
-	 * set the prefetch amount to a reasonable level if the
-	 * cacheline size is unknown.
-	 */
-	bmov	SGHADDR, SCB_RESIDUAL_SGPTR, 4;
-	mvi	SGHCNT, SG_PREFETCH_CNT;
-	if ((ahd->bugs & AHD_REG_SLOW_SETTLE_BUG) != 0) {
-		/*
-		 * Need two instruction between "touches" of SGHADDR.
-		 */
-		nop;
-	}
-	and	SGHADDR[0], SG_PREFETCH_ALIGN_MASK, SCB_RESIDUAL_SGPTR;
-	mvi	CCSGCTL, CCSGEN|SG_CACHE_AVAIL|CCSGRESET;
-	or	SG_STATE, FETCH_INPROG ret;
-idle_sgfetch_complete:
-	/*
-	 * Guard against SG_CACHE_AVAIL activating during sg fetch
-	 * request in the other FIFO.
-	 */
-	test	SG_STATE, FETCH_INPROG jz return;
-	clr	CCSGCTL;
-	and	CCSGADDR, SG_PREFETCH_ADDR_MASK, SCB_RESIDUAL_SGPTR;
-	mvi	SG_STATE, SEGS_AVAIL|LOADING_NEEDED;
-idle_sg_avail:
-	/* Does the hardware have space for another SG entry? */
-	test	DFSTATUS, PRELOAD_AVAIL jz return;
-	if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
-		bmov	HADDR, CCSGRAM, 8;
-	} else {
-		bmov 	HADDR, CCSGRAM, 4;
-	}
-	bmov	HCNT, CCSGRAM, 3;
-	test	HCNT[0], 0x1 jz . + 2;
-	xor	DATA_COUNT_ODD, 0x1;
-	bmov	SCB_RESIDUAL_DATACNT[3], CCSGRAM, 1;
-	if ((ahd->flags & AHD_39BIT_ADDRESSING) != 0) {
-		and	HADDR[4], SG_HIGH_ADDR_BITS, SCB_RESIDUAL_DATACNT[3];
-	}
-	if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
-		/* Skip 4 bytes of pad. */
-		add	CCSGADDR, 4;
-	}
-sg_advance:
-	clr	A;			/* add sizeof(struct scatter) */
-	add	SCB_RESIDUAL_SGPTR[0],SG_SIZEOF;
-	adc	SCB_RESIDUAL_SGPTR[1],A;
-	adc	SCB_RESIDUAL_SGPTR[2],A;
-	adc	SCB_RESIDUAL_SGPTR[3],A;
-	mov	SINDEX, SCB_RESIDUAL_SGPTR[0];
-	test	DATA_COUNT_ODD, 0x1 jz . + 2;
-	or	SINDEX, ODD_SEG;
-	test	SCB_RESIDUAL_DATACNT[3], SG_LAST_SEG jz . + 3;
-	or	SINDEX, LAST_SEG;
-	clr	SG_STATE;
-	mov	SG_CACHE_PRE, SINDEX;
-	/*
-	 * Load the segment.  Or in HDMAEN here too
-	 * just in case HDMAENACK has not come true
-	 * by the time this segment is loaded.  If
-	 * HDMAENACK is not true, this or will disable
-	 * HDMAEN mid-transfer.  We do not want to simply
-	 * mvi our original settings as SCSIEN automatically
-	 * de-asserts and we don't want to accidentally
-	 * re-enable it.
-	 */
-	if ((ahd->features & AHD_NEW_DFCNTRL_OPTS) != 0) {
-		/*
-		 * Use SCSIENWRDIS so that SCSIEN is never
-		 * modified by this operation.
-		 */
-		or	DFCNTRL, PRELOADEN|SCSIENWRDIS|HDMAEN;
-	} else {
-		or	DFCNTRL, PRELOADEN|HDMAEN;
-	}
-	/*
-	 * Do we have another segment in the cache?
-	 */
-	add	NONE, SG_PREFETCH_CNT_LIMIT, CCSGADDR;
-	jnc	return;
-	and	SG_STATE, ~SEGS_AVAIL ret;
-
-/*
- * Initialize the DMA address and counter from the SCB.
- */
-load_first_seg:
-	bmov	HADDR, SCB_DATAPTR, 11;
-	and	DATA_COUNT_ODD, 0x1, SCB_DATACNT[0];
-	and	REG_ISR, ~SG_FULL_RESID, SCB_SGPTR[0];
-	test	SCB_DATACNT[3], SG_LAST_SEG jz . + 2;
-	or	REG_ISR, LAST_SEG;
-	test	DATA_COUNT_ODD, 0x1 jz . + 2;
-	or	REG_ISR, ODD_SEG;
-	mov	SG_CACHE_PRE, REG_ISR;
-	mvi	DFCNTRL, (PRELOADEN|SCSIEN|HDMAEN);
-	/*
-	 * Since we've are entering a data phase, we will
-	 * rely on the SCB_RESID* fields.  Initialize the
-	 * residual and clear the full residual flag.
-	 */
-	and	SCB_SGPTR[0], ~SG_FULL_RESID;
-	bmov	SCB_RESIDUAL_DATACNT[3], SCB_DATACNT[3], 5;
-	/* If we need more S/G elements, tell the idle loop */
-	test	SCB_RESIDUAL_DATACNT[3], SG_LAST_SEG jnz . + 2;
-	mvi	SG_STATE, LOADING_NEEDED ret;
-	clr	SG_STATE ret;
-
-p_data_handle_xfer:
-	call	setjmp_setscb;
-	test	SG_STATE, LOADING_NEEDED jnz service_fifo;
-p_data_clear_handler:
-	or	LONGJMP_ADDR[1], INVALID_ADDR ret;
-
-p_data:
-	test	SEQ_FLAGS, NOT_IDENTIFIED|NO_CDB_SENT	jz p_data_allowed;
-	SET_SEQINTCODE(PROTO_VIOLATION)
-p_data_allowed:
- 
-	test	SEQ_FLAGS, DPHASE	jz data_phase_initialize;
-
-	/*
-	 * If we re-enter the data phase after going through another
-	 * phase, our transfer location has almost certainly been
-	 * corrupted by the interveining, non-data, transfers.  Ask
-	 * the host driver to fix us up based on the transfer residual
-	 * unless we already know that we should be bitbucketing.
-	 */
-	test	SCB_RESIDUAL_SGPTR[0], SG_LIST_NULL jnz p_data_bitbucket;
-	SET_SEQINTCODE(PDATA_REINIT)
-	jmp	data_phase_inbounds;
-
-p_data_bitbucket:
-	/*
-	 * Turn on `Bit Bucket' mode, wait until the target takes
-	 * us to another phase, and then notify the host.
-	 */
-	mov	SAVED_MODE, MODE_PTR;
-	test	MODE_PTR, ~(MK_MODE(M_DFF1, M_DFF1))
-		jnz bitbucket_not_m_dff;
-	/*
-	 * Ensure that any FIFO contents are cleared out and the
-	 * FIFO free'd prior to starting the BITBUCKET.  BITBUCKET
-	 * doesn't discard data already in the FIFO.
-	 */
-	mvi	DFFSXFRCTL, RSTCHN|CLRSHCNT;
-	SET_MODE(M_SCSI, M_SCSI)
-bitbucket_not_m_dff:
-	or	SXFRCTL1,BITBUCKET;
-	/* Wait for non-data phase. */
-	test	SCSIPHASE, ~DATA_PHASE_MASK jz .;
-	and	SXFRCTL1, ~BITBUCKET;
-	RESTORE_MODE(SAVED_MODE)
-SET_SRC_MODE	M_DFF1;
-SET_DST_MODE	M_DFF1;
-	SET_SEQINTCODE(DATA_OVERRUN)
-	jmp	ITloop;
-
-data_phase_initialize:
-	test	SCB_SGPTR[0], SG_LIST_NULL jnz p_data_bitbucket;
-	call	load_first_seg;
-data_phase_inbounds:
-	/* We have seen a data phase at least once. */
-	or	SEQ_FLAGS, DPHASE;
-	mov	SAVED_MODE, MODE_PTR;
-	test	SG_STATE, LOADING_NEEDED jz data_group_dma_loop;
-	call	p_data_handle_xfer;
-data_group_dma_loop:
-	/*
-	 * The transfer is complete if either the last segment
-	 * completes or the target changes phase.  Both conditions
-	 * will clear SCSIEN.
-	 */
-	call	idle_loop_service_fifos;
-	call	idle_loop_cchan;
-	call	idle_loop_gsfifo;
-	RESTORE_MODE(SAVED_MODE)
-	test	DFCNTRL, SCSIEN jnz data_group_dma_loop;
-
-data_group_dmafinish:
-	/*
-	 * The transfer has terminated either due to a phase
-	 * change, and/or the completion of the last segment.
-	 * We have two goals here.  Do as much other work
-	 * as possible while the data fifo drains on a read
-	 * and respond as quickly as possible to the standard
-	 * messages (save data pointers/disconnect and command
-	 * complete) that usually follow a data phase.
-	 */
-	call	calc_residual;
-
-	/*
-	 * Go ahead and shut down the DMA engine now.
-	 */
-	test	DFCNTRL, DIRECTION jnz data_phase_finish;
-data_group_fifoflush:
-	if ((ahd->bugs & AHD_AUTOFLUSH_BUG) != 0) {
-		or	DFCNTRL, FIFOFLUSH;
-	}
-	/*
-	 * We have enabled the auto-ack feature.  This means
-	 * that the controller may have already transferred
-	 * some overrun bytes into the data FIFO and acked them
-	 * on the bus.  The only way to detect this situation is
-	 * to wait for LAST_SEG_DONE to come true on a completed
-	 * transfer and then test to see if the data FIFO is
-	 * non-empty.  We know there is more data yet to transfer
-	 * if SG_LIST_NULL is not yet set, thus there cannot be
-	 * an overrun.
-	 */
-	test	SCB_RESIDUAL_SGPTR[0], SG_LIST_NULL jz data_phase_finish;
-	test	SG_CACHE_SHADOW, LAST_SEG_DONE jz .;
-	test	DFSTATUS, FIFOEMP jnz data_phase_finish;
-	/* Overrun */
-	jmp	p_data;
-data_phase_finish:
-	/*
-	 * If the target has left us in data phase, loop through
-	 * the dma code again.  We will only loop if there is a
-	 * data overrun.  
-	 */
-	if ((ahd->flags & AHD_TARGETROLE) != 0) {
-		test	SSTAT0, TARGET jnz data_phase_done;
-	}
-	if ((ahd->flags & AHD_INITIATORROLE) != 0) {
-		test	SSTAT1, REQINIT jz .;
-		test	SCSIPHASE, DATA_PHASE_MASK jnz p_data;
-	}
-
-data_phase_done:
-	/* Kill off any pending prefetch */
-	call	disable_ccsgen;
-	or 	LONGJMP_ADDR[1], INVALID_ADDR;
-
-	if ((ahd->flags & AHD_TARGETROLE) != 0) {
-		test	SEQ_FLAGS, DPHASE_PENDING jz ITloop;
-		/*
-		and	SEQ_FLAGS, ~DPHASE_PENDING;
-		 * For data-in phases, wait for any pending acks from the
-		 * initiator before changing phase.  We only need to
-		 * send Ignore Wide Residue messages for data-in phases.
-		test	DFCNTRL, DIRECTION jz target_ITloop;
-		test	SSTAT1, REQINIT	jnz .;
-		test	DATA_COUNT_ODD, 0x1 jz target_ITloop;
-		SET_MODE(M_SCSI, M_SCSI)
-		test	NEGCONOPTS, WIDEXFER jz target_ITloop;
-		 */
-		/*
-		 * Issue an Ignore Wide Residue Message.
-		mvi	P_MESGIN|BSYO call change_phase;
-		mvi	MSG_IGN_WIDE_RESIDUE call target_outb;
-		mvi	1 call target_outb;
-		jmp	target_ITloop;
-		 */
-	} else {
-		jmp	ITloop;
-	}
-
-/*
- * We assume that, even though data may still be
- * transferring to the host, that the SCSI side of
- * the DMA engine is now in a static state.  This
- * allows us to update our notion of where we are
- * in this transfer.
- *
- * If, by chance, we stopped before being able
- * to fetch additional segments for this transfer,
- * yet the last S/G was completely exhausted,
- * call our idle loop until it is able to load
- * another segment.  This will allow us to immediately
- * pickup on the next segment on the next data phase.
- *
- * If we happened to stop on the last segment, then
- * our residual information is still correct from
- * the idle loop and there is no need to perform
- * any fixups.
- */
-calc_residual:
-	test	SG_CACHE_SHADOW, LAST_SEG jz residual_before_last_seg;
-	/* Record if we've consumed all S/G entries */
-	test	MDFFSTAT, SHVALID	jz . + 2;
-	bmov	SCB_RESIDUAL_DATACNT, SHCNT, 3 ret;
-	or	SCB_RESIDUAL_SGPTR[0], SG_LIST_NULL ret;
-residual_before_last_seg:
-	test    MDFFSTAT, SHVALID	jnz sgptr_fixup;
-	/*
-	 * Can never happen from an interrupt as the packetized
-	 * hardware will only interrupt us once SHVALID or
-	 * LAST_SEG_DONE.
-	 */
-	call	idle_loop_service_fifos;
-	RESTORE_MODE(SAVED_MODE)
-	jmp	calc_residual;
-
-sgptr_fixup:
-	/*
-	 * Fixup the residual next S/G pointer.  The S/G preload
-	 * feature of the chip allows us to load two elements
-	 * in addition to the currently active element.  We
-	 * store the bottom byte of the next S/G pointer in
-	 * the SG_CACHE_PTR register so we can restore the
-	 * correct value when the DMA completes.  If the next
-	 * sg ptr value has advanced to the point where higher
-	 * bytes in the address have been affected, fix them
-	 * too.
-	 */
-	test	SG_CACHE_SHADOW, 0x80 jz sgptr_fixup_done;
-	test	SCB_RESIDUAL_SGPTR[0], 0x80 jnz sgptr_fixup_done;
-	add	SCB_RESIDUAL_SGPTR[1], -1;
-	adc	SCB_RESIDUAL_SGPTR[2], -1; 
-	adc	SCB_RESIDUAL_SGPTR[3], -1;
-sgptr_fixup_done:
-	and	SCB_RESIDUAL_SGPTR[0], SG_ADDR_MASK, SG_CACHE_SHADOW;
-	clr	DATA_COUNT_ODD;
-	test	SG_CACHE_SHADOW, ODD_SEG jz . + 2;
-	or	DATA_COUNT_ODD, 0x1;
-	clr	SCB_RESIDUAL_DATACNT[3]; /* We are not the last seg */
-	bmov	SCB_RESIDUAL_DATACNT, SHCNT, 3 ret;
-
-export timer_isr:
-	call	issue_cmdcmplt;
-	mvi	CLRSEQINTSTAT, CLRSEQ_SWTMRTO;
-	if ((ahd->bugs & AHD_SET_MODE_BUG) != 0) {
-		/*
-		 * In H2A4, the mode pointer is not saved
-		 * for intvec2, but is restored on iret.
-		 * This can lead to the restoration of a
-		 * bogus mode ptr.  Manually clear the
-		 * intmask bits and do a normal return
-		 * to compensate.
-		 */
-		and	SEQINTCTL, ~(INTMASK2|INTMASK1) ret;
-	} else {
-		or	SEQINTCTL, IRET ret;
-	}
-
-export seq_isr:
-	nop;	/* Jumps in the first ISR instruction fail on Rev A. */
-	test	SEQINTSRC, CFG4DATA	jnz cfg4data_intr;
-	test	SEQINTSRC, CFG4ISTAT	jnz cfg4istat_intr;
-	test	SEQINTSRC, SAVEPTRS	jnz saveptr_intr;
-	test	SEQINTSRC, CFG4ICMD	jnz cfg4icmd_intr;
-	SET_SEQINTCODE(INVALID_SEQINT)
-
-/*
- * There are two types of save pointers interrupts:
- * The first is a snapshot save pointers where the current FIFO is not
- * active and contains a snapshot of the current poniter information.
- * This happens between packets in a stream for a single L_Q.  Since we
- * are not performing a pointer save, we can safely clear the channel
- * so it can be used for other transactions.
- *
- * The second case is a save pointers on an active FIFO which occurs
- * if the target changes to a new L_Q or busfrees/QAS' and the transfer
- * has a residual.  This should occur coincident with a ctxtdone.  We
- * disable the interrupt and allow our active routine to handle the
- * save.
- */
-saveptr_intr:
-	test	DFCNTRL, HDMAENACK jz snapshot_saveptr;
-	and	SEQIMODE, ~ENSAVEPTRS;
-	or	SEQINTCTL, IRET ret;
-snapshot_saveptr:
-	mvi	DFFSXFRCTL, CLRCHN;
-	or	SEQINTCTL, IRET ret;
-
-cfg4data_intr:
-	test	SCB_SGPTR[0], SG_LIST_NULL jnz pkt_handle_overrun;
-	call	load_first_seg;
-	call	pkt_handle_xfer;
-	or	SEQINTCTL, IRET ret;
-
-cfg4istat_intr:
-	call	freeze_queue;
-	add	NONE, -13, SCB_CDB_LEN;
-	jnc	cfg4istat_have_sense_addr;
-	test	SCB_CDB_LEN, SCB_CDB_LEN_PTR jnz cfg4istat_have_sense_addr;
-	/*
-	 * Host sets up address/count and enables transfer.
-	 */
-	SET_SEQINTCODE(CFG4ISTAT_INTR)
-	jmp	cfg4istat_setup_handler;
-cfg4istat_have_sense_addr:
-	bmov	HADDR, SCB_SENSE_BUSADDR, 4;
-	mvi	HCNT[1], (AHD_SENSE_BUFSIZE >> 8);
-	mvi	SG_CACHE_PRE, LAST_SEG;
-	mvi	DFCNTRL, PRELOADEN|SCSIEN|HDMAEN;
-cfg4istat_setup_handler:
-	/*
-	 * Status pkt is transferring to host.
-	 * Wait in idle loop for transfer to complete.
-	 * If a command completed before an attempted
-	 * task management function completed, notify the host.
-	 */
-	test	SCB_TASK_MANAGEMENT, 0xFF jz cfg4istat_no_taskmgmt_func;
-	SET_SEQINTCODE(TASKMGMT_CMD_CMPLT_OKAY)
-cfg4istat_no_taskmgmt_func:
-	call	pkt_handle_status;
-	or	SEQINTCTL, IRET ret;
-
-/*
- * See if the target has gone on in this context creating an
- * overrun condition.  For the write case, the hardware cannot
- * ack bytes until data are provided.  So, if the target begins
- * another  packet without changing contexts, implying we are
- * not sitting on a packet boundary, we are in an overrun
- * situation.  For the read case, the hardware will continue to
- * ack bytes into the FIFO, and may even ack the last overrun packet
- * into the FIFO.   If the FIFO should become non-empty, we are in
- * a read overrun case.
- */
-#define check_overrun							\
-	/* Not on a packet boundary. */					\
-	test 	MDFFSTAT, DLZERO jz pkt_handle_overrun;			\
-	test	DFSTATUS, FIFOEMP jz pkt_handle_overrun
-
-pkt_handle_xfer:
-	bmov	LONGJMP_SCB, SCBPTR, 2;
-	test	SG_STATE, LOADING_NEEDED jz pkt_last_seg;
-	call	setjmp;
-	test	SEQINTSRC, SAVEPTRS jnz pkt_saveptrs;
-	test	SCSIPHASE, ~DATA_PHASE_MASK jz . + 2;
-	test	SCSISIGO, ATNO jnz . + 2;
-	test	SSTAT2, NONPACKREQ jz pkt_service_fifo;
-	/*
-	 * Defer handling of this NONPACKREQ until we
-	 * can be sure it pertains to this FIFO.  SAVEPTRS
-	 * will not be asserted if the NONPACKREQ is for us,
-	 * so we must simulate it if shaddow is valid.  If
-	 * shaddow is not valid, keep running this FIFO until we
-	 * have satisfied the transfer by loading segments and
-	 * waiting for either shaddow valid or last_seg_done.
-	 */
-	test	MDFFSTAT, SHVALID jnz pkt_saveptrs;
-pkt_service_fifo:
-	test	SG_STATE, LOADING_NEEDED jnz service_fifo;
-pkt_last_seg:
-	call	setjmp;
-	test	SEQINTSRC, SAVEPTRS jnz pkt_saveptrs;
-	test	SG_CACHE_SHADOW, LAST_SEG_DONE jnz last_pkt_done;
-	test	SCSIPHASE, ~DATA_PHASE_MASK jz . + 2;
-	test	SCSISIGO, ATNO jnz . + 2;
-	test	SSTAT2, NONPACKREQ jz return;
-	test	MDFFSTAT, SHVALID jz return;
-	/* FALLTHROUGH */
-
-/*
- * Either a SAVEPTRS interrupt condition is pending for this FIFO
- * or we have a pending nonpackreq for this FIFO.  We differentiate
- * between the two by capturing the state of the SAVEPTRS interrupt
- * prior to clearing this status and executing the common code for
- * these two cases.
- */
-pkt_saveptrs:
-BEGIN_CRITICAL;
-	if ((ahd->bugs & AHD_AUTOFLUSH_BUG) != 0) {
-		or	DFCNTRL, FIFOFLUSH;
-	}
-	mov	REG0, SEQINTSRC;
-	call	calc_residual;
-	call	save_pointers;
-	mvi	CLRSEQINTSRC, CLRSAVEPTRS;
-	call	disable_ccsgen;
-	or	SEQIMODE, ENSAVEPTRS;
-	test	DFCNTRL, DIRECTION jnz pkt_saveptrs_check_status;
-	test	DFSTATUS, FIFOEMP jnz pkt_saveptrs_check_status;
-	/*
-	 * Keep a handler around for this FIFO until it drains
-	 * to the host to guarantee that we don't complete the
-	 * command to the host before the data arrives.
-	 */
-pkt_saveptrs_wait_fifoemp:
-	call	setjmp;
-	test	DFSTATUS, FIFOEMP jz return;
-pkt_saveptrs_check_status:
-	or	LONGJMP_ADDR[1], INVALID_ADDR;
-	test	REG0, SAVEPTRS jz unexpected_nonpkt_phase;
-	test	SCB_CONTROL, STATUS_RCVD jz pkt_saveptrs_clrchn;
-	jmp	last_pkt_complete;
-pkt_saveptrs_clrchn:
-	mvi	DFFSXFRCTL, CLRCHN ret;
-END_CRITICAL;
-
-last_pkt_done:
-BEGIN_CRITICAL;
-	if ((ahd->bugs & AHD_AUTOFLUSH_BUG) != 0) {
-		or	DFCNTRL, FIFOFLUSH;
-	}
-	test	SCB_CONTROL, STATUS_RCVD jz wait_pkt_end;
-	check_overrun;
-	or	SCB_SGPTR, SG_LIST_NULL;
-	/*
-	 * It is safe to skip the other FIFO check since
-	 * we defer CLRCHN on SAVEPTRS until all data in
-	 * the FIFO are seen by the host and a CFG4DATA
-	 * in this FIFO for the same context is held off
-	 * by hardware.
-	 */
-last_pkt_queue_scb:
-	or	LONGJMP_ADDR[1], INVALID_ADDR;
-	bmov	ARG_1, SCBPTR, 2;
-	mvi	DFFSXFRCTL, CLRCHN;
-	jmp	queue_arg1_scb_completion;
-
-last_pkt_complete:
-	bmov	ARG_1, SCBPTR, 2;
-	mvi	DFFSXFRCTL, CLRCHN;
-check_other_fifo:
-	clc;
-	TOGGLE_DFF_MODE
-	call	check_fifo;
-	jnc	queue_arg1_scb_completion;
-return:
-	ret;
-
-wait_pkt_end:
-	call	setjmp;
-END_CRITICAL;
-wait_pkt_end_loop:
-	test	SEQINTSRC, CTXTDONE jnz pkt_end;
-	check_overrun;
-	test	SSTAT2, NONPACKREQ jz return;
-	test	SEQINTSRC, CTXTDONE jz unexpected_nonpkt_phase;
-pkt_end:
-BEGIN_CRITICAL;
-	check_overrun;
-	or	LONGJMP_ADDR[1], INVALID_ADDR;
-	or	SCB_SGPTR, SG_LIST_NULL;
-	test	SCB_CONTROL, STATUS_RCVD jnz last_pkt_complete;
-	mvi	DFFSXFRCTL, CLRCHN ret;
-END_CRITICAL;
-
-check_status_overrun:
-	test	SHCNT[2], 0xFF jz status_IU_done;
-	SET_SEQINTCODE(STATUS_OVERRUN)
-	jmp	status_IU_done;
-pkt_handle_status:
-	call	setjmp_setscb;
-	test	MDFFSTAT, LASTSDONE jnz check_status_overrun;
-	test	SEQINTSRC, CTXTDONE jz return;
-status_IU_done:
-BEGIN_CRITICAL;
-	if ((ahd->bugs & AHD_AUTOFLUSH_BUG) != 0) {
-		or	DFCNTRL, FIFOFLUSH;
-	}
-	or	LONGJMP_ADDR[1], INVALID_ADDR;
-	mvi	SCB_SCSI_STATUS, STATUS_PKT_SENSE;
-	or	SCB_CONTROL, STATUS_RCVD;
-	jmp	last_pkt_complete;
-END_CRITICAL;
-
-SET_SRC_MODE	M_DFF0;
-SET_DST_MODE	M_DFF0;
-BEGIN_CRITICAL;
-check_fifo:
-	test	LONGJMP_ADDR[1], INVALID_ADDR jnz return;
-	mov	A, ARG_2;
-	cmp	LONGJMP_SCB[1], A	jne return;
-	mov	A, ARG_1;
-	cmp	LONGJMP_SCB[0], A	jne return;
-	stc	ret;
-END_CRITICAL;
-
-/*
- * Nonpackreq is a polled status.  It can come true in three situations:
- * we have received an L_Q, we have sent one or more L_Qs, or there is no
- * L_Q context associated with this REQ (REQ occurs immediately after a
- * (re)selection).  Routines that know that the context responsible for this
- * nonpackreq call directly into unexpected_nonpkt_phase.  In the case of the
- * top level idle loop, we exhaust all active contexts prior to determining that
- * we simply do not have the full I_T_L_Q for this phase.
- */
-unexpected_nonpkt_phase_find_ctxt:
-	/*
-	 * This nonpackreq is most likely associated with one of the tags
-	 * in a FIFO or an outgoing LQ.  Only treat it as an I_T only
-	 * nonpackreq if we've cleared out the FIFOs and handled any
-	 * pending SELDO.
-	 */
-SET_SRC_MODE	M_SCSI;
-SET_DST_MODE	M_SCSI;
-	and	A, FIFO1FREE|FIFO0FREE, DFFSTAT;
-	cmp	A, FIFO1FREE|FIFO0FREE jne return;
-	test	SSTAT0, SELDO jnz return;
-	mvi	SCBPTR[1], SCB_LIST_NULL;
-unexpected_nonpkt_phase:
-	test	MODE_PTR, ~(MK_MODE(M_DFF1, M_DFF1)) jnz . + 3;
-SET_SRC_MODE	M_DFF0;
-SET_DST_MODE	M_DFF0;
-	or	LONGJMP_ADDR[1], INVALID_ADDR;
-	mvi	DFFSXFRCTL, CLRCHN;
-	mvi	CLRSINT2, CLRNONPACKREQ;
-	test	SCSIPHASE, ~(MSG_IN_PHASE|MSG_OUT_PHASE) jnz illegal_phase;
-	SET_SEQINTCODE(ENTERING_NONPACK)
-	jmp	ITloop;
-
-illegal_phase:
-	SET_SEQINTCODE(ILLEGAL_PHASE)
-	jmp	ITloop;
-
-/*
- * We have entered an overrun situation.  If we have working
- * BITBUCKET, flip that on and let the hardware eat any overrun
- * data.  Otherwise use an overrun buffer in the host to simulate
- * BITBUCKET.
- */
-pkt_handle_overrun:
-	SET_SEQINTCODE(CFG4OVERRUN)
-	call	freeze_queue;
-	if ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) == 0) {
-		or	DFFSXFRCTL, DFFBITBUCKET;
-SET_SRC_MODE	M_DFF1;
-SET_DST_MODE	M_DFF1;
-	} else {
-		call	load_overrun_buf;
-		mvi	DFCNTRL, (HDMAEN|SCSIEN|PRELOADEN);
-	}
-	call	setjmp;
-	if ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0) {
-		test	DFSTATUS, PRELOAD_AVAIL jz overrun_load_done;
-		call	load_overrun_buf;
-		or	DFCNTRL, PRELOADEN;
-overrun_load_done:
-		test	SEQINTSRC, CTXTDONE jnz pkt_overrun_end;
-	} else {
-		test	DFFSXFRCTL, DFFBITBUCKET jz pkt_overrun_end;
-	}
-	test	SSTAT2, NONPACKREQ jz return;
-pkt_overrun_end:
-	or	SCB_RESIDUAL_SGPTR, SG_OVERRUN_RESID;
-	test	SEQINTSRC, CTXTDONE jz unexpected_nonpkt_phase;
-	test	SCB_CONTROL, STATUS_RCVD jnz last_pkt_queue_scb;
-	mvi	DFFSXFRCTL, CLRCHN ret;
-
-if ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0) {
-load_overrun_buf:
-	/*
-	 * Load a dummy segment if preload space is available.
-	 */
-	mov 	HADDR[0], SHARED_DATA_ADDR;
-	add	HADDR[1], PKT_OVERRUN_BUFOFFSET, SHARED_DATA_ADDR[1];
-	mov	ACCUM_SAVE, A;
-	clr	A;
-	adc	HADDR[2], A, SHARED_DATA_ADDR[2];
-	adc	HADDR[3], A, SHARED_DATA_ADDR[3];
-	mov	A, ACCUM_SAVE;
-	bmov	HADDR[4], ALLZEROS, 4;
-	/* PKT_OVERRUN_BUFSIZE is a multiple of 256 */
-	clr	HCNT[0];
-	mvi	HCNT[1], ((PKT_OVERRUN_BUFSIZE >> 8) & 0xFF);
-	clr	HCNT[2] ret;
-}
-
-cfg4icmd_intr:
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aic79xx_core.c linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx_core.c
--- linux-2.4.21/drivers/scsi/aic79xx/aic79xx_core.c	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx_core.c	2003-06-26 21:43:29.000000000 +0000
@@ -1,9505 +0,0 @@
-/*
- * Core routines and tables shareable across OS platforms.
- *
- * Copyright (c) 1994-2002 Justin T. Gibbs.
- * Copyright (c) 2000-2003 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: //depot/aic7xxx/aic7xxx/aic79xx.c#156 $
- *
- * $FreeBSD$
- */
-
-#ifdef __linux__
-#include "aic79xx_osm.h"
-#include "aic79xx_inline.h"
-#include "aicasm/aicasm_insformat.h"
-#else
-#include <dev/aic7xxx/aic79xx_osm.h>
-#include <dev/aic7xxx/aic79xx_inline.h>
-#include <dev/aic7xxx/aicasm/aicasm_insformat.h>
-#endif
-
-/******************************** Globals *************************************/
-struct ahd_softc_tailq ahd_tailq = TAILQ_HEAD_INITIALIZER(ahd_tailq);
-
-/***************************** Lookup Tables **********************************/
-char *ahd_chip_names[] =
-{
-	"NONE",
-	"aic7901",
-	"aic7902",
-	"aic7901A"
-};
-static const u_int num_chip_names = NUM_ELEMENTS(ahd_chip_names);
-
-/*
- * Hardware error codes.
- */
-struct ahd_hard_error_entry {
-        uint8_t errno;
-	char *errmesg;
-};
-
-static struct ahd_hard_error_entry ahd_hard_errors[] = {
-	{ DSCTMOUT,	"Discard Timer has timed out" },
-	{ ILLOPCODE,	"Illegal Opcode in sequencer program" },
-	{ SQPARERR,	"Sequencer Parity Error" },
-	{ DPARERR,	"Data-path Parity Error" },
-	{ MPARERR,	"Scratch or SCB Memory Parity Error" },
-	{ CIOPARERR,	"CIOBUS Parity Error" },
-};
-static const u_int num_errors = NUM_ELEMENTS(ahd_hard_errors);
-
-static struct ahd_phase_table_entry ahd_phase_table[] =
-{
-	{ P_DATAOUT,	MSG_NOOP,		"in Data-out phase"	},
-	{ P_DATAIN,	MSG_INITIATOR_DET_ERR,	"in Data-in phase"	},
-	{ P_DATAOUT_DT,	MSG_NOOP,		"in DT Data-out phase"	},
-	{ P_DATAIN_DT,	MSG_INITIATOR_DET_ERR,	"in DT Data-in phase"	},
-	{ P_COMMAND,	MSG_NOOP,		"in Command phase"	},
-	{ P_MESGOUT,	MSG_NOOP,		"in Message-out phase"	},
-	{ P_STATUS,	MSG_INITIATOR_DET_ERR,	"in Status phase"	},
-	{ P_MESGIN,	MSG_PARITY_ERROR,	"in Message-in phase"	},
-	{ P_BUSFREE,	MSG_NOOP,		"while idle"		},
-	{ 0,		MSG_NOOP,		"in unknown phase"	}
-};
-
-/*
- * In most cases we only wish to itterate over real phases, so
- * exclude the last element from the count.
- */
-static const u_int num_phases = NUM_ELEMENTS(ahd_phase_table) - 1;
-
-/* Our Sequencer Program */
-#include "aic79xx_seq.h"
-
-/**************************** Function Declarations ***************************/
-static void		ahd_handle_transmission_error(struct ahd_softc *ahd);
-static void		ahd_handle_lqiphase_error(struct ahd_softc *ahd,
-						  u_int lqistat1);
-static int		ahd_handle_pkt_busfree(struct ahd_softc *ahd,
-					       u_int busfreetime);
-static int		ahd_handle_nonpkt_busfree(struct ahd_softc *ahd);
-static void		ahd_handle_proto_violation(struct ahd_softc *ahd);
-static void		ahd_force_renegotiation(struct ahd_softc *ahd,
-						struct ahd_devinfo *devinfo);
-
-static struct ahd_tmode_tstate*
-			ahd_alloc_tstate(struct ahd_softc *ahd,
-					 u_int scsi_id, char channel);
-#ifdef AHD_TARGET_MODE
-static void		ahd_free_tstate(struct ahd_softc *ahd,
-					u_int scsi_id, char channel, int force);
-#endif
-static void		ahd_devlimited_syncrate(struct ahd_softc *ahd,
-					        struct ahd_initiator_tinfo *,
-						u_int *period,
-						u_int *ppr_options,
-						role_t role);
-static void		ahd_update_neg_table(struct ahd_softc *ahd,
-					     struct ahd_devinfo *devinfo,
-					     struct ahd_transinfo *tinfo);
-static void		ahd_update_pending_scbs(struct ahd_softc *ahd);
-static void		ahd_fetch_devinfo(struct ahd_softc *ahd,
-					  struct ahd_devinfo *devinfo);
-static void		ahd_scb_devinfo(struct ahd_softc *ahd,
-					struct ahd_devinfo *devinfo,
-					struct scb *scb);
-static void		ahd_setup_initiator_msgout(struct ahd_softc *ahd,
-						   struct ahd_devinfo *devinfo,
-						   struct scb *scb);
-static void		ahd_build_transfer_msg(struct ahd_softc *ahd,
-					       struct ahd_devinfo *devinfo);
-static void		ahd_construct_sdtr(struct ahd_softc *ahd,
-					   struct ahd_devinfo *devinfo,
-					   u_int period, u_int offset);
-static void		ahd_construct_wdtr(struct ahd_softc *ahd,
-					   struct ahd_devinfo *devinfo,
-					   u_int bus_width);
-static void		ahd_construct_ppr(struct ahd_softc *ahd,
-					  struct ahd_devinfo *devinfo,
-					  u_int period, u_int offset,
-					  u_int bus_width, u_int ppr_options);
-static void		ahd_clear_msg_state(struct ahd_softc *ahd);
-static void		ahd_handle_message_phase(struct ahd_softc *ahd);
-typedef enum {
-	AHDMSG_1B,
-	AHDMSG_2B,
-	AHDMSG_EXT
-} ahd_msgtype;
-static int		ahd_sent_msg(struct ahd_softc *ahd, ahd_msgtype type,
-				     u_int msgval, int full);
-static int		ahd_parse_msg(struct ahd_softc *ahd,
-				      struct ahd_devinfo *devinfo);
-static int		ahd_handle_msg_reject(struct ahd_softc *ahd,
-					      struct ahd_devinfo *devinfo);
-static void		ahd_handle_ign_wide_residue(struct ahd_softc *ahd,
-						struct ahd_devinfo *devinfo);
-static void		ahd_reinitialize_dataptrs(struct ahd_softc *ahd);
-static void		ahd_handle_devreset(struct ahd_softc *ahd,
-					    struct ahd_devinfo *devinfo,
-					    u_int lun, cam_status status,
-					    char *message, int verbose_level);
-#if AHD_TARGET_MODE
-static void		ahd_setup_target_msgin(struct ahd_softc *ahd,
-					       struct ahd_devinfo *devinfo,
-					       struct scb *scb);
-#endif
-
-static u_int		ahd_sglist_size(struct ahd_softc *ahd);
-static u_int		ahd_sglist_allocsize(struct ahd_softc *ahd);
-static bus_dmamap_callback_t
-			ahd_dmamap_cb; 
-static void		ahd_initialize_hscbs(struct ahd_softc *ahd);
-static int		ahd_init_scbdata(struct ahd_softc *ahd);
-static void		ahd_fini_scbdata(struct ahd_softc *ahd);
-static void		ahd_setup_iocell_workaround(struct ahd_softc *ahd);
-static void		ahd_iocell_first_selection(struct ahd_softc *ahd);
-static void		ahd_add_col_list(struct ahd_softc *ahd,
-					 struct scb *scb, u_int col_idx);
-static void		ahd_rem_col_list(struct ahd_softc *ahd,
-					 struct scb *scb);
-static void		ahd_chip_init(struct ahd_softc *ahd);
-static void		ahd_qinfifo_requeue(struct ahd_softc *ahd,
-					    struct scb *prev_scb,
-					    struct scb *scb);
-static int		ahd_qinfifo_count(struct ahd_softc *ahd);
-static int		ahd_search_scb_list(struct ahd_softc *ahd, int target,
-					    char channel, int lun, u_int tag,
-					    role_t role, uint32_t status,
-					    ahd_search_action action,
-					    u_int *list_head, u_int tid);
-static void		ahd_stitch_tid_list(struct ahd_softc *ahd,
-					    u_int tid_prev, u_int tid_cur,
-					    u_int tid_next);
-static void		ahd_add_scb_to_free_list(struct ahd_softc *ahd,
-						 u_int scbid);
-static u_int		ahd_rem_wscb(struct ahd_softc *ahd, u_int scbid,
-				     u_int prev, u_int next, u_int tid);
-static void		ahd_reset_current_bus(struct ahd_softc *ahd);
-static ahd_callback_t	ahd_reset_poll;
-static ahd_callback_t	ahd_stat_timer;
-#ifdef AHD_DUMP_SEQ
-static void		ahd_dumpseq(struct ahd_softc *ahd);
-#endif
-static void		ahd_loadseq(struct ahd_softc *ahd);
-static int		ahd_check_patch(struct ahd_softc *ahd,
-					struct patch **start_patch,
-					u_int start_instr, u_int *skip_addr);
-static u_int		ahd_resolve_seqaddr(struct ahd_softc *ahd,
-					    u_int address);
-static void		ahd_download_instr(struct ahd_softc *ahd,
-					   u_int instrptr, uint8_t *dconsts);
-static int		ahd_probe_stack_size(struct ahd_softc *ahd);
-#ifdef AHD_TARGET_MODE
-static void		ahd_queue_lstate_event(struct ahd_softc *ahd,
-					       struct ahd_tmode_lstate *lstate,
-					       u_int initiator_id,
-					       u_int event_type,
-					       u_int event_arg);
-static void		ahd_update_scsiid(struct ahd_softc *ahd,
-					  u_int targid_mask);
-static int		ahd_handle_target_cmd(struct ahd_softc *ahd,
-					      struct target_cmd *cmd);
-#endif
-
-/******************************** Private Inlines *****************************/
-static __inline void	ahd_assert_atn(struct ahd_softc *ahd);
-static __inline int	ahd_currently_packetized(struct ahd_softc *ahd);
-static __inline int	ahd_set_active_fifo(struct ahd_softc *ahd);
-
-static __inline void
-ahd_assert_atn(struct ahd_softc *ahd)
-{
-	ahd_outb(ahd, SCSISIGO, ATNO);
-}
-
-/*
- * Determine if the current connection has a packetized
- * agreement.  This does not necessarily mean that we
- * are currently in a packetized transfer.  We could
- * just as easily be sending or receiving a message.
- */
-static __inline int
-ahd_currently_packetized(struct ahd_softc *ahd)
-{
-	ahd_mode_state	 saved_modes;
-	int		 packetized;
-
-	saved_modes = ahd_save_modes(ahd);
-	if ((ahd->bugs & AHD_PKTIZED_STATUS_BUG) != 0) {
-		/*
-		 * The packetized bit refers to the last
-		 * connection, not the current one.  Check
-		 * for non-zero LQISTATE instead.
-		 */
-		ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
-		packetized = ahd_inb(ahd, LQISTATE) != 0;
-	} else {
-		ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-		packetized = ahd_inb(ahd, LQISTAT2) & PACKETIZED;
-	}
-	ahd_restore_modes(ahd, saved_modes);
-	return (packetized);
-}
-
-static __inline int
-ahd_set_active_fifo(struct ahd_softc *ahd)
-{
-	u_int active_fifo;
-
-	AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
-	active_fifo = ahd_inb(ahd, DFFSTAT) & CURRFIFO;
-	switch (active_fifo) {
-	case 0:
-	case 1:
-		ahd_set_modes(ahd, active_fifo, active_fifo);
-		return (1);
-	default:
-		return (0);
-	}
-}
-
-/************************* Sequencer Execution Control ************************/
-/*
- * Restart the sequencer program from address zero
- */
-void
-ahd_restart(struct ahd_softc *ahd)
-{
-
-	ahd_pause(ahd);
-
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-
-	/* No more pending messages */
-	ahd_clear_msg_state(ahd);
-	ahd_outb(ahd, SCSISIGO, 0);		/* De-assert BSY */
-	ahd_outb(ahd, MSG_OUT, MSG_NOOP);	/* No message to send */
-	ahd_outb(ahd, SXFRCTL1, ahd_inb(ahd, SXFRCTL1) & ~BITBUCKET);
-	ahd_outb(ahd, SEQINTCTL, 0);
-	ahd_outb(ahd, LASTPHASE, P_BUSFREE);
-	ahd_outb(ahd, SEQ_FLAGS, 0);
-	ahd_outb(ahd, SAVED_SCSIID, 0xFF);
-	ahd_outb(ahd, SAVED_LUN, 0xFF);
-
-	/*
-	 * Ensure that the sequencer's idea of TQINPOS
-	 * matches our own.  The sequencer increments TQINPOS
-	 * only after it sees a DMA complete and a reset could
-	 * occur before the increment leaving the kernel to believe
-	 * the command arrived but the sequencer to not.
-	 */
-	ahd_outb(ahd, TQINPOS, ahd->tqinfifonext);
-
-	/* Always allow reselection */
-	ahd_outb(ahd, SCSISEQ1,
-		 ahd_inb(ahd, SCSISEQ_TEMPLATE) & (ENSELI|ENRSELI|ENAUTOATNP));
-	/* Ensure that no DMA operations are in progress */
-	ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
-	ahd_outb(ahd, SCBHCNT, 0);
-	ahd_outb(ahd, CCSCBCTL, CCSCBRESET);
-	ahd_outb(ahd, SEQCTL0, FASTMODE|SEQRESET);
-	ahd_unpause(ahd);
-}
-
-void
-ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo)
-{
-	ahd_mode_state	 saved_modes;
-
-#ifdef AHD_DEBUG
-	if ((ahd_debug & AHD_SHOW_FIFOS) != 0)
-		printf("%s: Clearing FIFO %d\n", ahd_name(ahd), fifo);
-#endif
-	saved_modes = ahd_save_modes(ahd);
-	ahd_set_modes(ahd, fifo, fifo);
-	ahd_outb(ahd, DFFSXFRCTL, RSTCHN|CLRSHCNT);
-	if ((ahd_inb(ahd, SG_STATE) & FETCH_INPROG) != 0)
-		ahd_outb(ahd, CCSGCTL, CCSGRESET);
-	ahd_outb(ahd, LONGJMP_ADDR + 1, INVALID_ADDR);
-	ahd_outb(ahd, SG_STATE, 0);
-	ahd_restore_modes(ahd, saved_modes);
-}
-
-/************************* Input/Output Queues ********************************/
-/*
- * Flush and completed commands that are sitting in the command
- * complete queues down on the chip but have yet to be dma'ed back up.
- */
-void
-ahd_flush_qoutfifo(struct ahd_softc *ahd)
-{
-	struct		scb *scb;
-	ahd_mode_state	saved_modes;
-	u_int		saved_scbptr;
-	u_int		ccscbctl;
-	u_int		scbid;
-	u_int		next_scbid;
-
-	saved_modes = ahd_save_modes(ahd);
-	ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
-	saved_scbptr = ahd_get_scbptr(ahd);
-
-	/*
-	 * Wait for any inprogress DMA to complete and clear DMA state
-	 * if this if for an SCB in the qinfifo.
-	 */
-	while ((ccscbctl = ahd_inb(ahd, CCSCBCTL) & (CCARREN|CCSCBEN)) != 0) {
-
-		if ((ccscbctl & (CCSCBDIR|CCARREN)) == (CCSCBDIR|CCARREN)) {
-			if ((ccscbctl & ARRDONE) != 0)
-				break;
-		} else if ((ccscbctl & CCSCBDONE) != 0)
-			break;
-		ahd_delay(200);
-	}
-	if ((ccscbctl & CCSCBDIR) != 0)
-		ahd_outb(ahd, CCSCBCTL, ccscbctl & ~(CCARREN|CCSCBEN));
-
-	/*
-	 * Complete any SCBs that just finished being
-	 * DMA'ed into the qoutfifo.
-	 */
-	ahd_run_qoutfifo(ahd);
-
-	/*
-	 * Manually update/complete any completed SCBs that are waiting to be
-	 * DMA'ed back up to the host.
-	 */
-	scbid = ahd_inw(ahd, COMPLETE_DMA_SCB_HEAD);
-	while (!SCBID_IS_NULL(scbid)) {
-		uint8_t *hscb_ptr;
-		u_int	 i;
-		
-		ahd_set_scbptr(ahd, scbid);
-		next_scbid = ahd_inw(ahd, SCB_NEXT_COMPLETE);
-		scb = ahd_lookup_scb(ahd, scbid);
-		if (scb == NULL) {
-			printf("%s: Warning - DMA-up and complete "
-			       "SCB %d invalid\n", ahd_name(ahd), scbid);
-			continue;
-		}
-		hscb_ptr = (uint8_t *)scb->hscb;
-		for (i = 0; i < sizeof(struct hardware_scb); i++)
-			*hscb_ptr++ = ahd_inb(ahd, SCB_BASE + i);
-
-		ahd_complete_scb(ahd, scb);
-		scbid = next_scbid;
-	}
-	ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, SCB_LIST_NULL);
-
-	scbid = ahd_inw(ahd, COMPLETE_SCB_HEAD);
-	while (!SCBID_IS_NULL(scbid)) {
-
-		ahd_set_scbptr(ahd, scbid);
-		next_scbid = ahd_inw(ahd, SCB_NEXT_COMPLETE);
-		scb = ahd_lookup_scb(ahd, scbid);
-		if (scb == NULL) {
-			printf("%s: Warning - Complete SCB %d invalid\n",
-			       ahd_name(ahd), scbid);
-			continue;
-		}
-
-		ahd_complete_scb(ahd, scb);
-		scbid = next_scbid;
-	}
-	ahd_outw(ahd, COMPLETE_SCB_HEAD, SCB_LIST_NULL);
-	ahd_set_scbptr(ahd, saved_scbptr);
-
-	/*
-	 * Flush the good status FIFO for compelted packetized commands.
-	 */
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-	while ((ahd_inb(ahd, LQISTAT2) & LQIGSAVAIL) != 0) {
-		scbid = (ahd_inb(ahd, GSFIFO+1) << 8)
-		      | ahd_inb(ahd, GSFIFO);
-		scb = ahd_lookup_scb(ahd, scbid);
-		if (scb == NULL) {
-			printf("%s: Warning - GSFIFO SCB %d invalid\n",
-			       ahd_name(ahd), scbid);
-			continue;
-		}
-		ahd_complete_scb(ahd, scb);
-	}
-
-	/*
-	 * Restore state.
-	 */
-	ahd_restore_modes(ahd, saved_modes);
-	ahd->flags |= AHD_UPDATE_PEND_CMDS;
-}
-
-void
-ahd_run_qoutfifo(struct ahd_softc *ahd)
-{
-	struct scb *scb;
-	u_int  scb_index;
-
-	if ((ahd->flags & AHD_RUNNING_QOUTFIFO) != 0)
-		panic("ahd_run_qoutfifo recursion");
-	ahd->flags |= AHD_RUNNING_QOUTFIFO;
-	ahd_sync_qoutfifo(ahd, BUS_DMASYNC_POSTREAD);
-	while ((ahd->qoutfifo[ahd->qoutfifonext]
-	     & QOUTFIFO_ENTRY_VALID_LE) == ahd->qoutfifonext_valid_tag) {
-
-		scb_index = ahd_le16toh(ahd->qoutfifo[ahd->qoutfifonext]
-				      & ~QOUTFIFO_ENTRY_VALID_LE);
-		scb = ahd_lookup_scb(ahd, scb_index);
-		if (scb == NULL) {
-			printf("%s: WARNING no command for scb %d "
-			       "(cmdcmplt)\nQOUTPOS = %d\n",
-			       ahd_name(ahd), scb_index,
-			       ahd->qoutfifonext);
-			ahd_dump_card_state(ahd);
-		} else
-			ahd_complete_scb(ahd, scb);
-
-		ahd->qoutfifonext = (ahd->qoutfifonext+1) & (AHD_QOUT_SIZE-1);
-		if (ahd->qoutfifonext == 0)
-			ahd->qoutfifonext_valid_tag ^= QOUTFIFO_ENTRY_VALID_LE;
-	}
-	ahd->flags &= ~AHD_RUNNING_QOUTFIFO;
-}
-
-/************************* Interrupt Handling *********************************/
-void
-ahd_handle_hwerrint(struct ahd_softc *ahd)
-{
-	/*
-	 * Some catastrophic hardware error has occurred.
-	 * Print it for the user and disable the controller.
-	 */
-	int i;
-	int error;
-
-	error = ahd_inb(ahd, ERROR);
-	for (i = 0; i < num_errors; i++) {
-		if ((error & ahd_hard_errors[i].errno) != 0)
-			printf("%s: hwerrint, %s\n",
-			       ahd_name(ahd), ahd_hard_errors[i].errmesg);
-	}
-
-	ahd_dump_card_state(ahd);
-	panic("BRKADRINT");
-
-	/* Tell everyone that this HBA is no longer availible */
-	ahd_abort_scbs(ahd, CAM_TARGET_WILDCARD, ALL_CHANNELS,
-		       CAM_LUN_WILDCARD, SCB_LIST_NULL, ROLE_UNKNOWN,
-		       CAM_NO_HBA);
-
-	/* Tell the system that this controller has gone away. */
-	ahd_free(ahd);
-}
-
-void
-ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
-{
-	u_int seqintcode;
-
-	/*
-	 * Save the sequencer interrupt code and clear the SEQINT
-	 * bit. We will unpause the sequencer, if appropriate,
-	 * after servicing the request.
-	 */
-	seqintcode = ahd_inb(ahd, SEQINTCODE);
-	ahd_outb(ahd, CLRINT, CLRSEQINT);
-	if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) {
-		/*
-		 * Unpause the sequencer and let it clear
-		 * SEQINT by writing NO_SEQINT to it.  This
-		 * will cause the sequencer to be paused again,
-		 * which is the expected state of this routine.
-		 */
-		ahd_unpause(ahd);
-		while (!ahd_is_paused(ahd))
-			;
-		ahd_outb(ahd, CLRINT, CLRSEQINT);
-	}
-	ahd_update_modes(ahd);
-#ifdef AHD_DEBUG
-	if ((ahd_debug & AHD_SHOW_MISC) != 0)
-		printf("%s: Handle Seqint Called for code %d\n",
-		       ahd_name(ahd), seqintcode);
-#endif
-	switch (seqintcode) {
-	case ENTERING_NONPACK:
-	{
-		struct	scb *scb;
-		u_int	scbid;
-
-		AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
-				 ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
-		scbid = ahd_get_scbptr(ahd);
-		scb = ahd_lookup_scb(ahd, scbid);
-		if (scb == NULL) {
-			/*
-			 * Somehow need to know if this
-			 * is from a selection or reselection.
-			 * From that, we can termine target
-			 * ID so we at least have an I_T nexus.
-			 */
-		} else {
-			ahd_outb(ahd, SAVED_SCSIID, scb->hscb->scsiid);
-			ahd_outb(ahd, SAVED_LUN, scb->hscb->lun);
-			ahd_outb(ahd, SEQ_FLAGS, 0x0);
-		}
-		if ((ahd_inb(ahd, LQISTAT2) & LQIPHASE_OUTPKT) != 0
-		 && (ahd_inb(ahd, SCSISIGO) & ATNO) != 0) {
-			/*
-			 * Phase change after read stream with
-			 * CRC error with P0 asserted on last
-			 * packet.
-			 */
-#ifdef AHD_DEBUG
-			if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)
-				printf("%s: Assuming LQIPHASE_NLQ with "
-				       "P0 assertion\n", ahd_name(ahd));
-#endif
-		}
-#ifdef AHD_DEBUG
-		if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)
-			printf("%s: Entering NONPACK\n", ahd_name(ahd));
-#endif
-		break;
-	}
-	case INVALID_SEQINT:
-		printf("%s: Invalid Sequencer interrupt occurred.\n",
-		       ahd_name(ahd));
-		ahd_dump_card_state(ahd);
-		ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
-		break;
-	case STATUS_OVERRUN:
-	{
-		printf("%s: Status Overrun", ahd_name(ahd));
-		ahd_dump_card_state(ahd);
-		ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
-		break;
-	}
-	case CFG4ISTAT_INTR:
-	{
-		struct	scb *scb;
-		u_int	scbid;
-
-		scbid = ahd_get_scbptr(ahd);
-		scb = ahd_lookup_scb(ahd, scbid);
-		if (scb == NULL) {
-			ahd_dump_card_state(ahd);
-			printf("CFG4ISTAT: Free SCB %d referenced", scbid);
-			panic("For safety");
-		}
-		ahd_outq(ahd, HADDR, scb->sense_busaddr);
-		ahd_outw(ahd, HCNT, AHD_SENSE_BUFSIZE);
-		ahd_outb(ahd, HCNT + 2, 0);
-		ahd_outb(ahd, SG_CACHE_PRE, SG_LAST_SEG);
-		ahd_outb(ahd, DFCNTRL, PRELOADEN|SCSIEN|HDMAEN);
-		break;
-	}
-	case ILLEGAL_PHASE:
-	{
-		u_int bus_phase;
-
-		bus_phase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK;
-		printf("%s: ILLEGAL_PHASE 0x%x\n",
-		       ahd_name(ahd), bus_phase);
-
-		switch (bus_phase) {
-		case P_DATAOUT:
-		case P_DATAIN:
-		case P_DATAOUT_DT:
-		case P_DATAIN_DT:
-		case P_MESGOUT:
-		case P_STATUS:
-		case P_MESGIN:
-			ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
-			printf("%s: Issued Bus Reset.\n", ahd_name(ahd));
-			break;
-		case P_COMMAND:
-		{
-			struct	ahd_devinfo devinfo;
-			struct	scb *scb;
-			struct	ahd_initiator_tinfo *targ_info;
-			struct	ahd_tmode_tstate *tstate;
-			struct	ahd_transinfo *tinfo;
-			u_int	scbid;
-
-			/*
-			 * If a target takes us into the command phase
-			 * assume that it has been externally reset and
-			 * has thus lost our previous packetized negotiation
-			 * agreement.  Since we have not sent an identify
-			 * message and may not have fully qualified the
-			 * connection, we change our command to TUR, assert
-			 * ATN and ABORT the task when we go to message in
-			 * phase.  The OSM will see the REQUEUE_REQUEST
-			 * status and retry the command.
-			 */
-			scbid = ahd_get_scbptr(ahd);
-			scb = ahd_lookup_scb(ahd, scbid);
-			if (scb == NULL) {
-				printf("Invalid phase with no valid SCB.  "
-				       "Resetting bus.\n");
-				ahd_reset_channel(ahd, 'A',
-						  /*Initiate Reset*/TRUE);
-				break;
-			}
-			ahd_compile_devinfo(&devinfo, SCB_GET_OUR_ID(scb),
-					    SCB_GET_TARGET(ahd, scb),
-					    SCB_GET_LUN(scb),
-					    SCB_GET_CHANNEL(ahd, scb),
-					    ROLE_INITIATOR);
-			targ_info = ahd_fetch_transinfo(ahd,
-							devinfo.channel,
-							devinfo.our_scsiid,
-							devinfo.target,
-							&tstate);
-			tinfo = &targ_info->curr;
-			ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
-				      AHD_TRANS_ACTIVE, /*paused*/TRUE);
-			ahd_set_syncrate(ahd, &devinfo, /*period*/0,
-					 /*offset*/0, /*ppr_options*/0,
-					 AHD_TRANS_ACTIVE, /*paused*/TRUE);
-			ahd_outb(ahd, SCB_CDB_STORE, 0);
-			ahd_outb(ahd, SCB_CDB_STORE+1, 0);
-			ahd_outb(ahd, SCB_CDB_STORE+2, 0);
-			ahd_outb(ahd, SCB_CDB_STORE+3, 0);
-			ahd_outb(ahd, SCB_CDB_STORE+4, 0);
-			ahd_outb(ahd, SCB_CDB_STORE+5, 0);
-			ahd_outb(ahd, SCB_CDB_LEN, 6);
-			scb->hscb->control &= ~(TAG_ENB|SCB_TAG_TYPE);
-			scb->hscb->control |= MK_MESSAGE;
-			ahd_outb(ahd, SCB_CONTROL, scb->hscb->control);
-			ahd_outb(ahd, MSG_OUT, HOST_MSG);
-			ahd_outb(ahd, SAVED_SCSIID, scb->hscb->scsiid);
-			/*
-			 * The lun is 0, regardless of the SCB's lun
-			 * as we have not sent an identify message.
-			 */
-			ahd_outb(ahd, SAVED_LUN, 0);
-			ahd_outb(ahd, SEQ_FLAGS, 0);
-			ahd_assert_atn(ahd);
-			scb->flags &= ~(SCB_PACKETIZED);
-			scb->flags |= SCB_ABORT|SCB_CMDPHASE_ABORT;
-			ahd_freeze_devq(ahd, scb);
-			ahd_set_transaction_status(scb, CAM_REQUEUE_REQ);
-			ahd_freeze_scb(scb);
-
-			/*
-			 * Allow the sequencer to continue with
-			 * non-pack processing.
-			 */
-			ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-			ahd_outb(ahd, CLRLQOINT1, CLRLQOPHACHGINPKT);
-			if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0) {
-				ahd_outb(ahd, CLRLQOINT1, 0);
-			}
-#ifdef AHD_DEBUG
-			if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
-				ahd_print_path(ahd, scb);
-				printf("Unexpected command phase from "
-				       "packetized target\n");
-			}
-#endif
-			break;
-		}
-		}
-		break;
-	}
-	case CFG4OVERRUN:
-	{
-		struct	scb *scb;
-		u_int	scb_index;
-		
-#ifdef AHD_DEBUG
-		if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
-			printf("%s: CFG4OVERRUN mode = %x\n", ahd_name(ahd),
-			       ahd_inb(ahd, MODE_PTR));
-		}
-#endif
-		scb_index = ahd_get_scbptr(ahd);
-		scb = ahd_lookup_scb(ahd, scb_index);
-		if (scb == NULL) {
-			/*
-			 * Attempt to transfer to an SCB that is
-			 * not outstanding.
-			 */
-			ahd_assert_atn(ahd);
-			ahd_outb(ahd, MSG_OUT, HOST_MSG);
-			ahd->msgout_buf[0] = MSG_ABORT_TASK;
-			ahd->msgout_len = 1;
-			ahd->msgout_index = 0;
-			ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
-			/*
-			 * Clear status received flag to prevent any
-			 * attempt to complete this bogus SCB.
-			 */
-			ahd_outb(ahd, SCB_CONTROL,
-				 ahd_inb(ahd, SCB_CONTROL) & ~STATUS_RCVD);
-		}
-		break;
-	}
-	case DUMP_CARD_STATE:
-	{
-		ahd_dump_card_state(ahd);
-		break;
-	}
-	case PDATA_REINIT:
-	{
-#ifdef AHD_DEBUG
-		if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
-			printf("%s: PDATA_REINIT - DFCNTRL = 0x%x "
-			       "SG_CACHE_SHADOW = 0x%x\n",
-			       ahd_name(ahd), ahd_inb(ahd, DFCNTRL),
-			       ahd_inb(ahd, SG_CACHE_SHADOW));
-		}
-#endif
-		ahd_reinitialize_dataptrs(ahd);
-		break;
-	}
-	case HOST_MSG_LOOP:
-	{
-		struct ahd_devinfo devinfo;
-
-		/*
-		 * The sequencer has encountered a message phase
-		 * that requires host assistance for completion.
-		 * While handling the message phase(s), we will be
-		 * notified by the sequencer after each byte is
-		 * transfered so we can track bus phase changes.
-		 *
-		 * If this is the first time we've seen a HOST_MSG_LOOP
-		 * interrupt, initialize the state of the host message
-		 * loop.
-		 */
-		ahd_fetch_devinfo(ahd, &devinfo);
-		if (ahd->msg_type == MSG_TYPE_NONE) {
-			struct scb *scb;
-			u_int scb_index;
-			u_int bus_phase;
-
-			bus_phase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK;
-			if (bus_phase != P_MESGIN
-			 && bus_phase != P_MESGOUT) {
-				printf("ahd_intr: HOST_MSG_LOOP bad "
-				       "phase 0x%x\n", bus_phase);
-				/*
-				 * Probably transitioned to bus free before
-				 * we got here.  Just punt the message.
-				 */
-				ahd_dump_card_state(ahd);
-				ahd_clear_intstat(ahd);
-				ahd_restart(ahd);
-				return;
-			}
-
-			scb_index = ahd_get_scbptr(ahd);
-			scb = ahd_lookup_scb(ahd, scb_index);
-			if (devinfo.role == ROLE_INITIATOR) {
-				if (bus_phase == P_MESGOUT)
-					ahd_setup_initiator_msgout(ahd,
-								   &devinfo,
-								   scb);
-				else {
-					ahd->msg_type =
-					    MSG_TYPE_INITIATOR_MSGIN;
-					ahd->msgin_index = 0;
-				}
-			}
-#if AHD_TARGET_MODE
-			else {
-				if (bus_phase == P_MESGOUT) {
-					ahd->msg_type =
-					    MSG_TYPE_TARGET_MSGOUT;
-					ahd->msgin_index = 0;
-				}
-				else 
-					ahd_setup_target_msgin(ahd,
-							       &devinfo,
-							       scb);
-			}
-#endif
-		}
-
-		ahd_handle_message_phase(ahd);
-		break;
-	}
-	case NO_MATCH:
-	{
-		/* Ensure we don't leave the selection hardware on */
-		AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
-		ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
-
-		printf("%s:%c:%d: no active SCB for reconnecting "
-		       "target - issuing BUS DEVICE RESET\n",
-		       ahd_name(ahd), 'A', ahd_inb(ahd, SELID) >> 4);
-		printf("SAVED_SCSIID == 0x%x, SAVED_LUN == 0x%x, "
-		       "REG0 == 0x%x ACCUM = 0x%x\n",
-		       ahd_inb(ahd, SAVED_SCSIID), ahd_inb(ahd, SAVED_LUN),
-		       ahd_inw(ahd, REG0), ahd_inb(ahd, ACCUM));
-		printf("SEQ_FLAGS == 0x%x, SCBPTR == 0x%x, BTT == 0x%x, "
-		       "SINDEX == 0x%x\n",
-		       ahd_inb(ahd, SEQ_FLAGS), ahd_get_scbptr(ahd),
-		       ahd_find_busy_tcl(ahd,
-					 BUILD_TCL(ahd_inb(ahd, SAVED_SCSIID),
-						   ahd_inb(ahd, SAVED_LUN))),
-		       ahd_inw(ahd, SINDEX));
-		printf("SELID == 0x%x, SCB_SCSIID == 0x%x, SCB_LUN == 0x%x, "
-		       "SCB_CONTROL == 0x%x\n",
-		       ahd_inb(ahd, SELID), ahd_inb_scbram(ahd, SCB_SCSIID),
-		       ahd_inb_scbram(ahd, SCB_LUN),
-		       ahd_inb_scbram(ahd, SCB_CONTROL));
-		printf("SCSIBUS[0] == 0x%x, SCSISIGI == 0x%x\n",
-		       ahd_inb(ahd, SCSIBUS), ahd_inb(ahd, SCSISIGI));
-		printf("SXFRCTL0 == 0x%x\n", ahd_inb(ahd, SXFRCTL0));
-		printf("SEQCTL0 == 0x%x\n", ahd_inb(ahd, SEQCTL0));
-		ahd_dump_card_state(ahd);
-		ahd->msgout_buf[0] = MSG_BUS_DEV_RESET;
-		ahd->msgout_len = 1;
-		ahd->msgout_index = 0;
-		ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
-		ahd_outb(ahd, MSG_OUT, HOST_MSG);
-		ahd_assert_atn(ahd);
-		break;
-	}
-	case PROTO_VIOLATION:
-	{
-		ahd_handle_proto_violation(ahd);
-		break;
-	}
-	case IGN_WIDE_RES:
-	{
-		struct ahd_devinfo devinfo;
-
-		ahd_fetch_devinfo(ahd, &devinfo);
-		ahd_handle_ign_wide_residue(ahd, &devinfo);
-		break;
-	}
-	case BAD_PHASE:
-	{
-		u_int lastphase;
-
-		lastphase = ahd_inb(ahd, LASTPHASE);
-		printf("%s:%c:%d: unknown scsi bus phase %x, "
-		       "lastphase = 0x%x.  Attempting to continue\n",
-		       ahd_name(ahd), 'A',
-		       SCSIID_TARGET(ahd, ahd_inb(ahd, SAVED_SCSIID)),
-		       lastphase, ahd_inb(ahd, SCSISIGI));
-		break;
-	}
-	case MISSED_BUSFREE:
-	{
-		u_int lastphase;
-
-		lastphase = ahd_inb(ahd, LASTPHASE);
-		printf("%s:%c:%d: Missed busfree. "
-		       "Lastphase = 0x%x, Curphase = 0x%x\n",
-		       ahd_name(ahd), 'A',
-		       SCSIID_TARGET(ahd, ahd_inb(ahd, SAVED_SCSIID)),
-		       lastphase, ahd_inb(ahd, SCSISIGI));
-		ahd_restart(ahd);
-		return;
-	}
-	case DATA_OVERRUN:
-	{
-		/*
-		 * When the sequencer detects an overrun, it
-		 * places the controller in "BITBUCKET" mode
-		 * and allows the target to complete its transfer.
-		 * Unfortunately, none of the counters get updated
-		 * when the controller is in this mode, so we have
-		 * no way of knowing how large the overrun was.
-		 */
-		struct	scb *scb;
-		u_int	scbindex;
-#ifdef AHD_DEBUG
-		u_int	lastphase;
-#endif
-
-		scbindex = ahd_get_scbptr(ahd);
-		scb = ahd_lookup_scb(ahd, scbindex);
-#ifdef AHD_DEBUG
-		lastphase = ahd_inb(ahd, LASTPHASE);
-		if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
-			ahd_print_path(ahd, scb);
-			printf("data overrun detected %s.  Tag == 0x%x.\n",
-			       ahd_lookup_phase_entry(lastphase)->phasemsg,
-			       SCB_GET_TAG(scb));
-			ahd_print_path(ahd, scb);
-			printf("%s seen Data Phase.  Length = %ld.  "
-			       "NumSGs = %d.\n",
-			       ahd_inb(ahd, SEQ_FLAGS) & DPHASE
-			       ? "Have" : "Haven't",
-			       ahd_get_transfer_length(scb), scb->sg_count);
-			ahd_dump_sglist(scb);
-		}
-#endif
-
-		/*
-		 * Set this and it will take effect when the
-		 * target does a command complete.
-		 */
-		ahd_freeze_devq(ahd, scb);
-		ahd_set_transaction_status(scb, CAM_DATA_RUN_ERR);
-		ahd_freeze_scb(scb);
-		break;
-	}
-	case MKMSG_FAILED:
-	{
-		struct ahd_devinfo devinfo;
-		struct scb *scb;
-		u_int scbid;
-
-		ahd_fetch_devinfo(ahd, &devinfo);
-		printf("%s:%c:%d:%d: Attempt to issue message failed\n",
-		       ahd_name(ahd), devinfo.channel, devinfo.target,
-		       devinfo.lun);
-		scbid = ahd_get_scbptr(ahd);
-		scb = ahd_lookup_scb(ahd, scbid);
-		if (scb != NULL
-		 && (scb->flags & SCB_RECOVERY_SCB) != 0)
-			/*
-			 * Ensure that we didn't put a second instance of this
-			 * SCB into the QINFIFO.
-			 */
-			ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb),
-					   SCB_GET_CHANNEL(ahd, scb),
-					   SCB_GET_LUN(scb), SCB_GET_TAG(scb),
-					   ROLE_INITIATOR, /*status*/0,
-					   SEARCH_REMOVE);
-		ahd_outb(ahd, SCB_CONTROL,
-			 ahd_inb(ahd, SCB_CONTROL) & ~MK_MESSAGE);
-		break;
-	}
-	case TASKMGMT_FUNC_COMPLETE:
-	{
-		u_int	scbid;
-		struct	scb *scb;
-
-		scbid = ahd_get_scbptr(ahd);
-		scb = ahd_lookup_scb(ahd, scbid);
-		if (scb != NULL) {
-			u_int	   lun;
-			u_int	   tag;
-			cam_status error;
-
-			ahd_print_path(ahd, scb);
-			printf("Task Management Func 0x%x Complete\n",
-			       scb->hscb->task_management);
-			lun = CAM_LUN_WILDCARD;
-			tag = SCB_LIST_NULL;
-
-			switch (scb->hscb->task_management) {
-			case SIU_TASKMGMT_ABORT_TASK:
-				tag = scb->hscb->tag;
-			case SIU_TASKMGMT_ABORT_TASK_SET:
-			case SIU_TASKMGMT_CLEAR_TASK_SET:
-				lun = scb->hscb->lun;
-				error = CAM_REQ_ABORTED;
-				ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb),
-					       'A', lun, tag, ROLE_INITIATOR,
-					       error);
-				break;
-			case SIU_TASKMGMT_LUN_RESET:
-				lun = scb->hscb->lun;
-			case SIU_TASKMGMT_TARGET_RESET:
-			{
-				struct ahd_devinfo devinfo;
-
-				ahd_scb_devinfo(ahd, &devinfo, scb);
-				error = CAM_BDR_SENT;
-				ahd_handle_devreset(ahd, &devinfo, lun,
-						    CAM_BDR_SENT,
-						    lun != CAM_LUN_WILDCARD
-						    ? "Lun Reset"
-						    : "Target Reset",
-						    /*verbose_level*/0);
-				break;
-			}
-			default:
-				panic("Unexpected TaskMgmt Func\n");
-				break;
-			}
-		}
-		break;
-	}
-	case TASKMGMT_CMD_CMPLT_OKAY:
-	{
-		u_int	scbid;
-		struct	scb *scb;
-
-		/*
-		 * An ABORT TASK TMF failed to be delivered before
-		 * the targeted command completed normally.
-		 */
-		scbid = ahd_get_scbptr(ahd);
-		scb = ahd_lookup_scb(ahd, scbid);
-		if (scb != NULL) {
-			/*
-			 * Remove the second instance of this SCB from
-			 * the QINFIFO if it is still there.
-                         */
-			ahd_print_path(ahd, scb);
-			printf("SCB completes before TMF\n");
-			/*
-			 * Handle losing the race.  Wait until any
-			 * current selection completes.  We will then
-			 * set the TMF back to zero in this SCB so that
-			 * the sequencer doesn't bother to issue another
-			 * sequencer interrupt for its completion.
-			 */
-			while ((ahd_inb(ahd, SCSISEQ0) & ENSELO) != 0
-			    && (ahd_inb(ahd, SSTAT0) & SELDO) == 0
-			    && (ahd_inb(ahd, SSTAT1) & SELTO) == 0)
-				;
-			ahd_outb(ahd, SCB_TASK_MANAGEMENT, 0);
-			ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb),
-					   SCB_GET_CHANNEL(ahd, scb),  
-					   SCB_GET_LUN(scb), scb->hscb->tag, 
-					   ROLE_INITIATOR, /*status*/0,   
-					   SEARCH_REMOVE);
-		}
-		break;
-	}
-	case TRACEPOINT0:
-	case TRACEPOINT1:
-	case TRACEPOINT2:
-	case TRACEPOINT3:
-		printf("%s: Tracepoint %d\n", ahd_name(ahd),
-		       seqintcode - TRACEPOINT0);
-		break;
-	case NO_SEQINT:
-		break;
-	case SAW_HWERR:
-		ahd_handle_hwerrint(ahd);
-		break;
-	default:
-		printf("%s: Unexpected SEQINTCODE %d\n", ahd_name(ahd),
-		       seqintcode);
-		break;
-	}
-	/*
-	 *  The sequencer is paused immediately on
-	 *  a SEQINT, so we should restart it when
-	 *  we're done.
-	 */
-	ahd_unpause(ahd);
-}
-
-void
-ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat)
-{
-	struct scb	*scb;
-	u_int		 status0;
-	u_int		 status3;
-	u_int		 status;
-	u_int		 lqistat1;
-	u_int		 lqostat0;
-	u_int		 scbid;
-	u_int		 busfreetime;
-
-	ahd_update_modes(ahd);
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-
-	status3 = ahd_inb(ahd, SSTAT3) & (NTRAMPERR|OSRAMPERR);
-	status0 = ahd_inb(ahd, SSTAT0) & (IOERR|OVERRUN|SELDI|SELDO);
-	status = ahd_inb(ahd, SSTAT1) & (SELTO|SCSIRSTI|BUSFREE|SCSIPERR);
-	lqistat1 = ahd_inb(ahd, LQISTAT1);
-	lqostat0 = ahd_inb(ahd, LQOSTAT0);
-	busfreetime = ahd_inb(ahd, SSTAT2) & BUSFREETIME;
-	if ((status0 & (SELDI|SELDO)) != 0) {
-		u_int simode0;
-
-		ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
-		simode0 = ahd_inb(ahd, SIMODE0);
-		status0 &= simode0 & (IOERR|OVERRUN|SELDI|SELDO);
-		ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-	}
-	scbid = ahd_get_scbptr(ahd);
-	scb = ahd_lookup_scb(ahd, scbid);
-	if (scb != NULL
-	 && (ahd_inb(ahd, SEQ_FLAGS) & NOT_IDENTIFIED) != 0)
-		scb = NULL;
-
-	/* Make sure the sequencer is in a safe location. */
-	ahd_clear_critical_section(ahd);
-
-	if ((status0 & IOERR) != 0) {
-		u_int now_lvd;
-
-		now_lvd = ahd_inb(ahd, SBLKCTL) & ENAB40;
-		printf("%s: Transceiver State Has Changed to %s mode\n",
-		       ahd_name(ahd), now_lvd ? "LVD" : "SE");
-		ahd_outb(ahd, CLRSINT0, CLRIOERR);
-		/*
-		 * A change in I/O mode is equivalent to a bus reset.
-		 */
-		ahd_reset_channel(ahd, 'A', /*Initiate Reset*/FALSE);
-		ahd_pause(ahd);
-		ahd_setup_iocell_workaround(ahd);
-		ahd_unpause(ahd);
-	} else if ((status0 & OVERRUN) != 0) {
-		printf("%s: SCSI offset overrun detected.  Resetting bus.\n",
-		       ahd_name(ahd));
-		ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
-	} else if ((status & SCSIRSTI) != 0) {
-		printf("%s: Someone reset channel A\n", ahd_name(ahd));
-		ahd_reset_channel(ahd, 'A', /*Initiate Reset*/FALSE);
-	} else if ((status & SCSIPERR) != 0) {
-		ahd_handle_transmission_error(ahd);
-	} else if (lqostat0 != 0) {
-		printf("%s: lqostat0 == 0x%x!\n", ahd_name(ahd), lqostat0);
-		ahd_outb(ahd, CLRLQOINT0, lqostat0);
-		if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0) {
-			ahd_outb(ahd, CLRLQOINT1, 0);
-		}
-	} else if ((status & SELTO) != 0) {
-		u_int  scbid;
-
-		/* Stop the selection */
-		ahd_outb(ahd, SCSISEQ0, 0);
-
-		/* No more pending messages */
-		ahd_clear_msg_state(ahd);
-
-		/* Clear interrupt state */
-		ahd_outb(ahd, CLRSINT1, CLRSELTIMEO|CLRBUSFREE|CLRSCSIPERR);
-
-		/*
-		 * Although the driver does not care about the
-		 * 'Selection in Progress' status bit, the busy
-		 * LED does.  SELINGO is only cleared by a sucessfull
-		 * selection, so we must manually clear it to insure
-		 * the LED turns off just incase no future successful
-		 * selections occur (e.g. no devices on the bus).
-		 */
-		ahd_outb(ahd, CLRSINT0, CLRSELINGO);
-
-		scbid = ahd_inw(ahd, WAITING_TID_HEAD);
-		scb = ahd_lookup_scb(ahd, scbid);
-		if (scb == NULL) {
-			printf("%s: ahd_intr - referenced scb not "
-			       "valid during SELTO scb(0x%x)\n",
-			       ahd_name(ahd), scbid);
-			ahd_dump_card_state(ahd);
-		} else {
-			struct ahd_devinfo devinfo;
-#ifdef AHD_DEBUG
-			if ((ahd_debug & AHD_SHOW_SELTO) != 0) {
-				ahd_print_path(ahd, scb);
-				printf("Saw Selection Timeout for SCB 0x%x\n",
-				       scbid);
-			}
-#endif
-			/*
-			 * Force a renegotiation with this target just in
-			 * case the cable was pulled and will later be
-			 * re-attached.  The target may forget its negotiation
-			 * settings with us should it attempt to reselect
-			 * during the interruption.  The target will not issue
-			 * a unit attention in this case, so we must always
-			 * renegotiate.
-			 */
-			ahd_scb_devinfo(ahd, &devinfo, scb);
-			ahd_force_renegotiation(ahd, &devinfo);
-			ahd_set_transaction_status(scb, CAM_SEL_TIMEOUT);
-			ahd_freeze_devq(ahd, scb);
-		}
-		ahd_outb(ahd, CLRINT, CLRSCSIINT);
-		ahd_iocell_first_selection(ahd);
-		ahd_unpause(ahd);
-	} else if ((status0 & (SELDI|SELDO)) != 0) {
-		ahd_iocell_first_selection(ahd);
-		ahd_unpause(ahd);
-	} else if (status3 != 0) {
-		printf("%s: SCSI Cell parity error SSTAT3 == 0x%x\n",
-		       ahd_name(ahd), status3);
-		ahd_outb(ahd, CLRSINT3, status3);
-	} else if ((lqistat1 & (LQIPHASE_LQ|LQIPHASE_NLQ)) != 0) {
-		ahd_handle_lqiphase_error(ahd, lqistat1);
-	} else if ((status & BUSFREE) != 0) {
-		u_int lqostat1;
-		int   restart;
-		int   clear_fifo;
-		int   packetized;
-		u_int mode;
-
-		/*
-		 * Clear our selection hardware as soon as possible.
-		 * We may have an entry in the waiting Q for this target,
-		 * that is affected by this busfree and we don't want to
-		 * go about selecting the target while we handle the event.
-		 */
-		ahd_outb(ahd, SCSISEQ0, 0);
-
-		/*
-		 * Determine what we were up to at the time of
-		 * the busfree.
-		 */
-		mode = AHD_MODE_SCSI;
-		busfreetime = ahd_inb(ahd, SSTAT2) & BUSFREETIME;
-		lqostat1 = ahd_inb(ahd, LQOSTAT1);
-		switch (busfreetime) {
-		case BUSFREE_DFF0:
-		case BUSFREE_DFF1:
-		{
-			u_int	scbid;
-			struct	scb *scb;
-
-			mode = busfreetime == BUSFREE_DFF0
-			     ? AHD_MODE_DFF0 : AHD_MODE_DFF1;
-			ahd_set_modes(ahd, mode, mode);
-			scbid = ahd_get_scbptr(ahd);
-			scb = ahd_lookup_scb(ahd, scbid);
-			if (scb == NULL) {
-				printf("%s: Invalid SCB in DFF%d "
-				       "during unexpected busfree\n",
-				       ahd_name(ahd), mode);
-				packetized = 0;
-			} else
-				packetized = (scb->flags & SCB_PACKETIZED) != 0;
-			clear_fifo = 1;
-			break;
-		}
-		case BUSFREE_LQO:
-			clear_fifo = 0;
-			packetized = 1;
-			break;
-		default:
-			clear_fifo = 0;
-			packetized =  (lqostat1 & LQOBUSFREE) != 0;
-			if (!packetized
-			 && ahd_inb(ahd, LASTPHASE) == P_BUSFREE)
-				packetized = 1;
-			break;
-		}
-
-#ifdef AHD_DEBUG
-		if ((ahd_debug & AHD_SHOW_MISC) != 0)
-			printf("Saw Busfree.  Busfreetime = 0x%x.\n",
-			       busfreetime);
-#endif
-		/*
-		 * Busfrees that occur in non-packetized phases are
-		 * handled by the nonpkt_busfree handler.
-		 */
-		if (packetized && ahd_inb(ahd, LASTPHASE) == P_BUSFREE) {
-			restart = ahd_handle_pkt_busfree(ahd, busfreetime);
-		} else {
-			packetized = 0;
-			restart = ahd_handle_nonpkt_busfree(ahd);
-		}
-		/*
-		 * Clear the busfree interrupt status.  The setting of
-		 * the interrupt is a pulse, so in a perfect world, we
-		 * would not need to muck with the ENBUSFREE logic.  This
-		 * would ensure that if the bus moves on to another
-		 * connection, busfree protection is still in force.  If
-		 * BUSFREEREV is broken, however, we must manually clear
-		 * the ENBUSFREE if the busfree occurred during a non-pack
-		 * connection so that we don't get false positives during
-		 * future, packetized, connections.
-		 */
-		ahd_outb(ahd, CLRSINT1, CLRBUSFREE);
-		if (packetized == 0
-		 && (ahd->bugs & AHD_BUSFREEREV_BUG) != 0)
-			ahd_outb(ahd, SIMODE1,
-				 ahd_inb(ahd, SIMODE1) & ~ENBUSFREE);
-
-		if (clear_fifo)
-			ahd_clear_fifo(ahd, mode);
-
-		ahd_clear_msg_state(ahd);
-		ahd_outb(ahd, CLRINT, CLRSCSIINT);
-		if (restart) {
-			ahd_restart(ahd);
-		} else {
-			ahd_unpause(ahd);
-		}
-	} else {
-		printf("%s: Missing case in ahd_handle_scsiint. status = %x\n",
-		       ahd_name(ahd), status);
-		ahd_dump_card_state(ahd);
-		ahd_clear_intstat(ahd);
-		ahd_unpause(ahd);
-	}
-}
-
-static void
-ahd_handle_transmission_error(struct ahd_softc *ahd)
-{
-	struct	scb *scb;
-	u_int	scbid;
-	u_int	lqistat1;
-	u_int	lqistat2;
-	u_int	msg_out;
-	u_int	curphase;
-	u_int	lastphase;
-	u_int	perrdiag;
-	u_int	cur_col;
-	int	silent;
-
-	scb = NULL;
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-	lqistat1 = ahd_inb(ahd, LQISTAT1) & ~(LQIPHASE_LQ|LQIPHASE_NLQ);
-	lqistat2 = ahd_inb(ahd, LQISTAT2);
-	if ((lqistat1 & (LQICRCI_NLQ|LQICRCI_LQ)) == 0
-	 && (ahd->bugs & AHD_NLQICRC_DELAYED_BUG) != 0) {
-		u_int lqistate;
-
-		ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
-		lqistate = ahd_inb(ahd, LQISTATE);
-		if ((lqistate >= 0x1E && lqistate <= 0x24)
-		 || (lqistate == 0x29)) {
-#ifdef AHD_DEBUG
-			if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
-				printf("%s: NLQCRC found via LQISTATE\n",
-				       ahd_name(ahd));
-			}
-#endif
-			lqistat1 |= LQICRCI_NLQ;
-		}
-		ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-	}
-
-	ahd_outb(ahd, CLRLQIINT1, lqistat1);
-	lastphase = ahd_inb(ahd, LASTPHASE);
-	curphase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK;
-	perrdiag = ahd_inb(ahd, PERRDIAG);
-	msg_out = MSG_INITIATOR_DET_ERR;
-	ahd_outb(ahd, CLRSINT1, CLRSCSIPERR);
-	
-	/*
-	 * Try to find the SCB associated with this error.
-	 */
-	silent = FALSE;
-	if (lqistat1 == 0
-	 || (lqistat1 & LQICRCI_NLQ) != 0) {
-	 	if ((lqistat1 & (LQICRCI_NLQ|LQIOVERI_NLQ)) != 0)
-			ahd_set_active_fifo(ahd);
-		scbid = ahd_get_scbptr(ahd);
-		scb = ahd_lookup_scb(ahd, scbid);
-		if (scb != NULL && SCB_IS_SILENT(scb))
-			silent = TRUE;
-	}
-
-	cur_col = 0;
-	if (silent == FALSE) {
-		printf("%s: Transmission error detected\n", ahd_name(ahd));
-		ahd_lqistat1_print(lqistat1, &cur_col, 50);
-		ahd_lastphase_print(lastphase, &cur_col, 50);
-		ahd_scsisigi_print(curphase, &cur_col, 50);
-		ahd_perrdiag_print(perrdiag, &cur_col, 50);
-		printf("\n");
-		ahd_dump_card_state(ahd);
-	}
-
-	if ((lqistat1 & (LQIOVERI_LQ|LQIOVERI_NLQ)) != 0) {
-		if (silent == FALSE) {
-			printf("%s: Gross protocol error during incoming "
-			       "packet.  lqistat1 == 0x%x.  Resetting bus.\n",
-			       ahd_name(ahd), lqistat1);
-		}
-		ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
-		return;
-	} else if ((lqistat1 & LQICRCI_LQ) != 0) {
-		/*
-		 * A CRC error has been detected on an incoming LQ.
-		 * The bus is currently hung on the last ACK.
-		 * Hit LQIRETRY to release the last ack, and
-		 * wait for the sequencer to determine that ATNO
-		 * is asserted while in message out to take us
-		 * to our host message loop.  No NONPACKREQ or
-		 * LQIPHASE type errors will occur in this
-		 * scenario.  After this first LQIRETRY, the LQI
-		 * manager will be in ISELO where it will
-		 * happily sit until another packet phase begins.
-		 * Unexpected bus free detection is enabled
-		 * through any phases that occur after we release
-		 * this last ack until the LQI manager sees a
-		 * packet phase.  This implies we may have to
-		 * ignore a perfectly valid "unexected busfree"
-		 * after our "initiator detected error" message is
-		 * sent.  A busfree is the expected response after
-		 * we tell the target that it's L_Q was corrupted.
-		 * (SPI4R09 10.7.3.3.3)
-		 */
-		ahd_outb(ahd, LQCTL2, LQIRETRY);
-		printf("LQIRetry for LQICRCI_LQ to release ACK\n");
-	} else if ((lqistat1 & LQICRCI_NLQ) != 0) {
-		/*
-		 * We detected a CRC error in a NON-LQ packet.
-		 * The hardware has varying behavior in this situation
-		 * depending on whether this packet was part of a
-		 * stream or not.
-		 *
-		 * PKT by PKT mode:
-		 * The hardware has already acked the complete packet.
-		 * If the target honors our outstanding ATN condition,
-		 * we should be (or soon will be) in MSGOUT phase.
-		 * This will trigger the LQIPHASE_LQ status bit as the
-		 * hardware was expecting another LQ.  Unexpected
-		 * busfree detection is enabled.  Once LQIPHASE_LQ is
-		 * true (first entry into host message loop is much
-		 * the same), we must clear LQIPHASE_LQ and hit
-		 * LQIRETRY so the hardware is ready to handle
-		 * a future LQ.  NONPACKREQ will not be asserted again
-		 * once we hit LQIRETRY until another packet is
-		 * processed.  The target may either go busfree
-		 * or start another packet in response to our message.
-		 *
-		 * Read Streaming P0 asserted:
-		 * If we raise ATN and the target completes the entire
-		 * stream (P0 asserted during the last packet), the
-		 * hardware will ack all data and return to the ISTART
-		 * state.  When the target reponds to our ATN condition,
-		 * LQIPHASE_LQ will be asserted.  We should respond to
-		 * this with an LQIRETRY to prepare for any future
-		 * packets.  NONPACKREQ will not be asserted again
-		 * once we hit LQIRETRY until another packet is
-		 * processed.  The target may either go busfree or
-		 * start another packet in response to our message.
-		 * Busfree detection is enabled.
-		 *
-		 * Read Streaming P0 not asserted:
-		 * If we raise ATN and the target transitions to
-		 * MSGOUT in or after a packet where P0 is not
-		 * asserted, the hardware will assert LQIPHASE_NLQ.
-		 * We should respond to the LQIPHASE_NLQ with an
-		 * LQIRETRY.  Should the target stay in a non-pkt
-		 * phase after we send our message, the hardware
-		 * will assert LQIPHASE_LQ.  Recovery is then just as
-		 * listed above for the read streaming with P0 asserted.
-		 * Busfree detection is enabled.
-		 */
-		if (silent == FALSE)
-			printf("LQICRC_NLQ\n");
-		if (scb == NULL) {
-			printf("%s: No SCB valid for LQICRC_NLQ.  "
-			       "Resetting bus\n", ahd_name(ahd));
-			ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
-			return;
-		}
-	} else if ((lqistat1 & LQIBADLQI) != 0) {
-		printf("Need to handle BADLQI!\n");
-		ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
-		return;
-	} else if ((perrdiag & (PARITYERR|PREVPHASE)) == PARITYERR) {
-		if ((curphase & ~P_DATAIN_DT) != 0) {
-			/* Ack the byte.  So we can continue. */
-			if (silent == FALSE)
-				printf("Acking %s to clear perror\n",
-				    ahd_lookup_phase_entry(curphase)->phasemsg);
-			ahd_inb(ahd, SCSIDAT);
-		}
-	
-		if (curphase == P_MESGIN)
-			msg_out = MSG_PARITY_ERROR;
-	}
-
-	/*
-	 * We've set the hardware to assert ATN if we 
-	 * get a parity error on "in" phases, so all we
-	 * need to do is stuff the message buffer with
-	 * the appropriate message.  "In" phases have set
-	 * mesg_out to something other than MSG_NOP.
-	 */
-	ahd->send_msg_perror = msg_out;
-	if (scb != NULL && msg_out == MSG_INITIATOR_DET_ERR)
-		scb->flags |= SCB_TRANSMISSION_ERROR;
-	ahd_outb(ahd, MSG_OUT, HOST_MSG);
-	ahd_outb(ahd, CLRINT, CLRSCSIINT);
-	ahd_unpause(ahd);
-}
-
-static void
-ahd_handle_lqiphase_error(struct ahd_softc *ahd, u_int lqistat1)
-{
-	/*
-	 * Clear the sources of the interrupts.
-	 */
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-	ahd_outb(ahd, CLRLQIINT1, lqistat1);
-
-	/*
-	 * If the "illegal" phase changes were in response
-	 * to our ATN to flag a CRC error, AND we ended up
-	 * on packet boundaries, clear the error, restart the
-	 * LQI manager as appropriate, and go on our merry
-	 * way toward sending the message.  Otherwise, reset
-	 * the bus to clear the error.
-	 */
-	ahd_set_active_fifo(ahd);
-	if ((ahd_inb(ahd, SCSISIGO) & ATNO) != 0
-	 && (ahd_inb(ahd, MDFFSTAT) & DLZERO) != 0) {
-		if ((lqistat1 & LQIPHASE_LQ) != 0) {
-			printf("LQIRETRY for LQIPHASE_LQ\n");
-			ahd_outb(ahd, LQCTL2, LQIRETRY);
-		} else if ((lqistat1 & LQIPHASE_NLQ) != 0) {
-			printf("LQIRETRY for LQIPHASE_NLQ\n");
-			ahd_outb(ahd, LQCTL2, LQIRETRY);
-		} else
-			panic("ahd_handle_lqiphase_error: No phase errors\n");
-		ahd_dump_card_state(ahd);
-		ahd_outb(ahd, CLRINT, CLRSCSIINT);
-		ahd_unpause(ahd);
-	} else {
-		printf("Reseting Channel for LQI Phase error\n");
-		ahd_dump_card_state(ahd);
-		ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
-	}
-}
-
-/*
- * Packetized unexpected or expected busfree.
- * Entered in mode based on busfreetime.
- */
-static int
-ahd_handle_pkt_busfree(struct ahd_softc *ahd, u_int busfreetime)
-{
-	u_int lqostat1;
-
-	AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
-			 ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
-	lqostat1 = ahd_inb(ahd, LQOSTAT1);
-	if ((lqostat1 & LQOBUSFREE) != 0) {
-		struct scb *scb;
-		u_int scbid;
-		u_int saved_scbptr;
-		u_int waiting_h;
-		u_int waiting_t;
-		u_int next;
-
-		if ((busfreetime & BUSFREE_LQO) == 0)
-			printf("%s: Warning, BUSFREE time is 0x%x.  "
-			       "Expected BUSFREE_LQO.\n",
-			       ahd_name(ahd), busfreetime);
-		/*
-		 * The LQO manager detected an unexpected busfree
-		 * either:
-		 *
-		 * 1) During an outgoing LQ.
-		 * 2) After an outgoing LQ but before the first
-		 *    REQ of the command packet.
-		 * 3) During an outgoing command packet.
-		 *
-		 * In all cases, CURRSCB is pointing to the
-		 * SCB that encountered the failure.  Clean
-		 * up the queue, clear SELDO and LQOBUSFREE,
-		 * and allow the sequencer to restart the select
-		 * out at its lesure.
-		 */
-		ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-		scbid = ahd_inw(ahd, CURRSCB);
-		scb = ahd_lookup_scb(ahd, scbid);
-		if (scb == NULL)
-		       panic("SCB not valid during LQOBUSFREE");
-		/*
-		 * Return the LQO manager to its idle loop.  It will
-		 * not do this automatically if the busfree occurs
-		 * after the first REQ of either the LQ or command
-		 * packet or between the LQ and command packet.
-		 */
-		ahd_outb(ahd, LQCTL2, ahd_inb(ahd, LQCTL2) | LQOTOIDLE);
-
-		/*
-		 * Clear the status.
-		 */
-		ahd_outb(ahd, CLRLQOINT1, CLRLQOBUSFREE);
-		if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0)
-			ahd_outb(ahd, CLRLQOINT1, 0);
-		ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
-		ahd_outb(ahd, CLRSINT0, CLRSELDO);
-
-		/*
-		 * Update the waiting for selection queue so
-		 * we restart on the correct SCB.
-		 */
-		waiting_h = ahd_inw(ahd, WAITING_TID_HEAD);
-		saved_scbptr = ahd_get_scbptr(ahd);
-		if (waiting_h != scbid) {
-
-			ahd_outw(ahd, WAITING_TID_HEAD, scbid);
-			waiting_t = ahd_inw(ahd, WAITING_TID_TAIL);
-			next = SCB_LIST_NULL;
-			if (waiting_t == waiting_h) {
-				ahd_outw(ahd, WAITING_TID_TAIL, scbid);
-			} else {
-				ahd_set_scbptr(ahd, waiting_h);
-				next = ahd_inw(ahd, SCB_NEXT2);
-			}
-			ahd_set_scbptr(ahd, scbid);
-			ahd_outw(ahd, SCB_NEXT2, next);
-		}
-		ahd_set_scbptr(ahd, saved_scbptr);
-		if (scb->crc_retry_count < AHD_MAX_LQ_CRC_ERRORS) {
-			if (SCB_IS_SILENT(scb) == FALSE) {
-				ahd_print_path(ahd, scb);
-				printf("Probable outgoing LQ CRC error.  "
-				       "Retrying command\n");
-			}
-			scb->crc_retry_count++;
-		} else {
-			ahd_set_transaction_status(scb, CAM_UNCOR_PARITY);
-			ahd_freeze_scb(scb);
-			ahd_freeze_devq(ahd, scb);
-		}
-		/* Return unpausing the sequencer. */
-		return (0);
-	} else if ((ahd_inb(ahd, PERRDIAG) & PARITYERR) != 0) {
-		/*
-		 * Ignore what are really parity errors that
-		 * occur on the last REQ of a free running
-		 * clock prior to going busfree.  Some drives
-		 * do not properly active negate just before
-		 * going busfree resulting in a parity glitch.
-		 */
-		ahd_outb(ahd, CLRSINT1, CLRSCSIPERR|CLRBUSFREE);
-#ifdef AHD_DEBUG
-		if ((ahd_debug & AHD_SHOW_MASKED_ERRORS) != 0)
-			printf("%s: Parity on last REQ detected "
-			       "during busfree phase.\n",
-			       ahd_name(ahd));
-#endif
-		/* Return unpausing the sequencer. */
-		return (0);
-	}
-	if (ahd->src_mode != AHD_MODE_SCSI) {
-		u_int	scbid;
-		struct	scb *scb;
-
-		scbid = ahd_get_scbptr(ahd);
-		scb = ahd_lookup_scb(ahd, scbid);
-		ahd_print_path(ahd, scb);
-		printf("Unexpected PKT busfree condition\n");
-		ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb), 'A',
-			       SCB_GET_LUN(scb), SCB_GET_TAG(scb),
-			       ROLE_INITIATOR, CAM_UNEXP_BUSFREE);
-
-		/* Return restarting the sequencer. */
-		return (1);
-	}
-	printf("%s: Unexpected PKT busfree condition\n", ahd_name(ahd));
-	ahd_dump_card_state(ahd);
-	/* Restart the sequencer. */
-	return (1);
-}
-
-/*
- * Non-packetized unexpected or expected busfree.
- */
-static int
-ahd_handle_nonpkt_busfree(struct ahd_softc *ahd)
-{
-	struct	ahd_devinfo devinfo;
-	struct	scb *scb;
-	u_int	lastphase;
-	u_int	saved_scsiid;
-	u_int	saved_lun;
-	u_int	target;
-	u_int	initiator_role_id;
-	u_int	scbid;
-	u_int	ppr_busfree;
-	int	printerror;
-
-	/*
-	 * Look at what phase we were last in.  If its message out,
-	 * chances are pretty good that the busfree was in response
-	 * to one of our abort requests.
-	 */
-	lastphase = ahd_inb(ahd, LASTPHASE);
-	saved_scsiid = ahd_inb(ahd, SAVED_SCSIID);
-	saved_lun = ahd_inb(ahd, SAVED_LUN);
-	target = SCSIID_TARGET(ahd, saved_scsiid);
-	initiator_role_id = SCSIID_OUR_ID(saved_scsiid);
-	ahd_compile_devinfo(&devinfo, initiator_role_id,
-			    target, saved_lun, 'A', ROLE_INITIATOR);
-	printerror = 1;
-
-	scbid = ahd_get_scbptr(ahd);
-	scb = ahd_lookup_scb(ahd, scbid);
-	if (scb != NULL
-	 && (ahd_inb(ahd, SEQ_FLAGS) & NOT_IDENTIFIED) != 0)
-		scb = NULL;
-
-	ppr_busfree = (ahd->msg_flags & MSG_FLAG_EXPECT_PPR_BUSFREE) != 0;
-	if (lastphase == P_MESGOUT) {
-		u_int tag;
-
-		tag = SCB_LIST_NULL;
-		if (ahd_sent_msg(ahd, AHDMSG_1B, MSG_ABORT_TAG, TRUE)
-		 || ahd_sent_msg(ahd, AHDMSG_1B, MSG_ABORT, TRUE)) {
-			int found;
-			int sent_msg;
-
-			if (scb == NULL) {
-				ahd_print_devinfo(ahd, &devinfo);
-				printf("Abort for unidentified "
-				       "connection completed.\n");
-				/* restart the sequencer. */
-				return (1);
-			}
-			sent_msg = ahd->msgout_buf[ahd->msgout_index - 1];
-			ahd_print_path(ahd, scb);
-			printf("SCB %d - Abort%s Completed.\n",
-			       SCB_GET_TAG(scb),
-			       sent_msg == MSG_ABORT_TAG ? "" : " Tag");
-
-			if (sent_msg == MSG_ABORT_TAG)
-				tag = SCB_GET_TAG(scb);
-
-			if ((scb->flags & SCB_CMDPHASE_ABORT) != 0) {
-				/*
-				 * This abort is in response to an
-				 * unexpected switch to command phase
-				 * for a packetized connection.  Since
-				 * the identify message was never sent,
-				 * "saved lun" is 0.  We really want to
-				 * abort only the SCB that encountered
-				 * this error, which could have a different
-				 * lun.  The SCB will be retried so the OS
-				 * will see the UA after renegotiating to
-				 * packetized.
-				 */
-				tag = SCB_GET_TAG(scb);
-				saved_lun = scb->hscb->lun;
-			}
-			found = ahd_abort_scbs(ahd, target, 'A', saved_lun,
-					       tag, ROLE_INITIATOR,
-					       CAM_REQ_ABORTED);
-			printf("found == 0x%x\n", found);
-			printerror = 0;
-		} else if (ahd_sent_msg(ahd, AHDMSG_1B,
-					MSG_BUS_DEV_RESET, TRUE)) {
-#ifdef __FreeBSD__
-			/*
-			 * Don't mark the user's request for this BDR
-			 * as completing with CAM_BDR_SENT.  CAM3
-			 * specifies CAM_REQ_CMP.
-			 */
-			if (scb != NULL
-			 && scb->io_ctx->ccb_h.func_code== XPT_RESET_DEV
-			 && ahd_match_scb(ahd, scb, target, 'A',
-					  CAM_LUN_WILDCARD, SCB_LIST_NULL,
-					  ROLE_INITIATOR))
-				ahd_set_transaction_status(scb, CAM_REQ_CMP);
-#endif
-			ahd_handle_devreset(ahd, &devinfo, CAM_LUN_WILDCARD,
-					    CAM_BDR_SENT, "Bus Device Reset",
-					    /*verbose_level*/0);
-			printerror = 0;
-		} else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_PPR, FALSE)
-			&& ppr_busfree == 0) {
-			struct ahd_initiator_tinfo *tinfo;
-			struct ahd_tmode_tstate *tstate;
-
-			/*
-			 * PPR Rejected.  Try non-ppr negotiation
-			 * and retry command.
-			 */
-#ifdef AHD_DEBUG
-			if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
-				printf("PPR negotiation rejected busfree.\n");
-#endif
-			tinfo = ahd_fetch_transinfo(ahd, devinfo.channel,
-						    devinfo.our_scsiid,
-						    devinfo.target, &tstate);
-			tinfo->curr.transport_version = 2;
-			tinfo->goal.transport_version = 2;
-			tinfo->goal.ppr_options = 0;
-			ahd_qinfifo_requeue_tail(ahd, scb);
-			printerror = 0;
-		} else if ((ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_WDTR, FALSE)
-			 || ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_SDTR, FALSE))
-			&& ppr_busfree == 0) {
-			/*
-			 * Negotiation Rejected.  Go-async and
-			 * retry command.
-			 */
-#ifdef AHD_DEBUG
-			if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
-				printf("Negotiation rejected busfree.\n");
-#endif
-			ahd_set_width(ahd, &devinfo,
-				      MSG_EXT_WDTR_BUS_8_BIT,
-				      AHD_TRANS_CUR|AHD_TRANS_GOAL,
-				      /*paused*/TRUE);
-			ahd_set_syncrate(ahd, &devinfo,
-					/*period*/0, /*offset*/0,
-					/*ppr_options*/0,
-					AHD_TRANS_CUR|AHD_TRANS_GOAL,
-					/*paused*/TRUE);
-			ahd_qinfifo_requeue_tail(ahd, scb);
-			printerror = 0;
-		} else if ((ahd->msg_flags & MSG_FLAG_EXPECT_IDE_BUSFREE) != 0
-			&& ahd_sent_msg(ahd, AHDMSG_1B,
-					 MSG_INITIATOR_DET_ERR, TRUE)) {
-
-#ifdef AHD_DEBUG
-			if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
-				printf("Expected IDE Busfree\n");
-#endif
-			printerror = 0;
-		} else if ((ahd->msg_flags & MSG_FLAG_EXPECT_QASREJ_BUSFREE)
-			&& ahd_sent_msg(ahd, AHDMSG_1B,
-					MSG_MESSAGE_REJECT, TRUE)) {
-
-#ifdef AHD_DEBUG
-			if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
-				printf("Expected QAS Reject Busfree\n");
-#endif
-			printerror = 0;
-		}
-	}
-
-	/*
-	 * The busfree required flag is honored at the end of
-	 * the message phases.  We check it last in case we
-	 * had to send some other message that caused a busfree.
-	 */
-	if (printerror != 0
-	 && (lastphase == P_MESGIN || lastphase == P_MESGOUT)
-	 && ((ahd->msg_flags & MSG_FLAG_EXPECT_PPR_BUSFREE) != 0)) {
-
-		ahd_freeze_devq(ahd, scb);
-		ahd_set_transaction_status(scb, CAM_REQUEUE_REQ);
-		ahd_freeze_scb(scb);
-		if ((ahd->msg_flags & MSG_FLAG_IU_REQ_CHANGED) != 0) {
-			ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb),
-				       SCB_GET_CHANNEL(ahd, scb),
-				       SCB_GET_LUN(scb), SCB_LIST_NULL,
-				       ROLE_INITIATOR, CAM_REQ_ABORTED);
-		} else {
-#ifdef AHD_DEBUG
-			if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
-				printf("PPR Negotiation Busfree.\n");
-#endif
-			ahd_done(ahd, scb);
-		}
-		printerror = 0;
-	}
-	if (printerror != 0) {
-		int aborted;
-
-		aborted = 0;
-		if (scb != NULL) {
-			u_int tag;
-
-			if ((scb->hscb->control & TAG_ENB) != 0)
-				tag = SCB_GET_TAG(scb);
-			else
-				tag = SCB_LIST_NULL;
-			ahd_print_path(ahd, scb);
-			aborted = ahd_abort_scbs(ahd, target, 'A',
-				       SCB_GET_LUN(scb), tag,
-				       ROLE_INITIATOR,
-				       CAM_UNEXP_BUSFREE);
-		} else {
-			/*
-			 * We had not fully identified this connection,
-			 * so we cannot abort anything.
-			 */
-			printf("%s: ", ahd_name(ahd));
-		}
-		if (lastphase != P_BUSFREE)
-			ahd_force_renegotiation(ahd, &devinfo);
-		printf("Unexpected busfree %s, %d SCBs aborted, "
-		       "PRGMCNT == 0x%x\n",
-		       ahd_lookup_phase_entry(lastphase)->phasemsg,
-		       aborted,
-		       ahd_inb(ahd, PRGMCNT)
-			| (ahd_inb(ahd, PRGMCNT+1) << 8));
-		ahd_dump_card_state(ahd);
-	}
-	/* Always restart the sequencer. */
-	return (1);
-}
-
-static void
-ahd_handle_proto_violation(struct ahd_softc *ahd)
-{
-	struct	ahd_devinfo devinfo;
-	struct	scb *scb;
-	u_int	scbid;
-	u_int	seq_flags;
-	u_int	curphase;
-	u_int	lastphase;
-	int	found;
-
-	ahd_fetch_devinfo(ahd, &devinfo);
-	scbid = ahd_get_scbptr(ahd);
-	scb = ahd_lookup_scb(ahd, scbid);
-	seq_flags = ahd_inb(ahd, SEQ_FLAGS);
-	curphase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK;
-	lastphase = ahd_inb(ahd, LASTPHASE);
-	if ((seq_flags & NOT_IDENTIFIED) != 0) {
-
-		/*
-		 * The reconnecting target either did not send an
-		 * identify message, or did, but we didn't find an SCB
-		 * to match.
-		 */
-		ahd_print_devinfo(ahd, &devinfo);
-		printf("Target did not send an IDENTIFY message. "
-		       "LASTPHASE = 0x%x.\n", lastphase);
-		scb = NULL;
-	} else if (scb == NULL) {
-		/*
-		 * We don't seem to have an SCB active for this
-		 * transaction.  Print an error and reset the bus.
-		 */
-		ahd_print_devinfo(ahd, &devinfo);
-		printf("No SCB found during protocol violation\n");
-		goto proto_violation_reset;
-	} else {
-		ahd_set_transaction_status(scb, CAM_SEQUENCE_FAIL);
-		if ((seq_flags & NO_CDB_SENT) != 0) {
-			ahd_print_path(ahd, scb);
-			printf("No or incomplete CDB sent to device.\n");
-		} else if ((ahd_inb(ahd, SCB_CONTROL) & STATUS_RCVD) == 0) {
-			/*
-			 * The target never bothered to provide status to
-			 * us prior to completing the command.  Since we don't
-			 * know the disposition of this command, we must attempt
-			 * to abort it.  Assert ATN and prepare to send an abort
-			 * message.
-			 */
-			ahd_print_path(ahd, scb);
-			printf("Completed command without status.\n");
-		} else {
-			ahd_print_path(ahd, scb);
-			printf("Unknown protocol violation.\n");
-			ahd_dump_card_state(ahd);
-		}
-	}
-	if ((lastphase & ~P_DATAIN_DT) == 0
-	 || lastphase == P_COMMAND) {
-proto_violation_reset:
-		/*
-		 * Target either went directly to data
-		 * phase or didn't respond to our ATN.
-		 * The only safe thing to do is to blow
-		 * it away with a bus reset.
-		 */
-		found = ahd_reset_channel(ahd, 'A', TRUE);
-		printf("%s: Issued Channel %c Bus Reset. "
-		       "%d SCBs aborted\n", ahd_name(ahd), 'A', found);
-	} else {
-		/*
-		 * Leave the selection hardware off in case
-		 * this abort attempt will affect yet to
-		 * be sent commands.
-		 */
-		ahd_outb(ahd, SCSISEQ0,
-			 ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
-		ahd_assert_atn(ahd);
-		ahd_outb(ahd, MSG_OUT, HOST_MSG);
-		if (scb == NULL) {
-			ahd_print_devinfo(ahd, &devinfo);
-			ahd->msgout_buf[0] = MSG_ABORT_TASK;
-			ahd->msgout_len = 1;
-			ahd->msgout_index = 0;
-			ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
-		} else {
-			ahd_print_path(ahd, scb);
-			scb->flags |= SCB_ABORT;
-		}
-		printf("Protocol violation %s.  Attempting to abort.\n",
-		       ahd_lookup_phase_entry(curphase)->phasemsg);
-	}
-}
-
-/*
- * Force renegotiation to occur the next time we initiate
- * a command to the current device.
- */
-static void
-ahd_force_renegotiation(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
-{
-	struct	ahd_initiator_tinfo *targ_info;
-	struct	ahd_tmode_tstate *tstate;
-
-#ifdef AHD_DEBUG
-	if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
-		ahd_print_devinfo(ahd, devinfo);
-		printf("Forcing renegotiation\n");
-	}
-#endif
-	targ_info = ahd_fetch_transinfo(ahd,
-					devinfo->channel,
-					devinfo->our_scsiid,
-					devinfo->target,
-					&tstate);
-	ahd_update_neg_request(ahd, devinfo, tstate,
-			       targ_info, AHD_NEG_IF_NON_ASYNC);
-}
-
-#define AHD_MAX_STEPS 2000
-void
-ahd_clear_critical_section(struct ahd_softc *ahd)
-{
-	ahd_mode_state	saved_modes;
-	int		stepping;
-	int		steps;
-	int		first_instr;
-	u_int		simode0;
-	u_int		simode1;
-	u_int		simode3;
-	u_int		lqimode0;
-	u_int		lqimode1;
-	u_int		lqomode0;
-	u_int		lqomode1;
-
-	if (ahd->num_critical_sections == 0)
-		return;
-
-	stepping = FALSE;
-	steps = 0;
-	first_instr = 0;
-	simode0 = 0;
-	simode1 = 0;
-	simode3 = 0;
-	lqimode0 = 0;
-	lqimode1 = 0;
-	lqomode0 = 0;
-	lqomode1 = 0;
-	saved_modes = ahd_save_modes(ahd);
-	for (;;) {
-		struct	cs *cs;
-		u_int	seqaddr;
-		u_int	i;
-
-		ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-		seqaddr = ahd_inb(ahd, CURADDR)
-			| (ahd_inb(ahd, CURADDR+1) << 8);
-
-		cs = ahd->critical_sections;
-		for (i = 0; i < ahd->num_critical_sections; i++, cs++) {
-			
-			if (cs->begin < seqaddr && cs->end >= seqaddr)
-				break;
-		}
-
-		if (i == ahd->num_critical_sections)
-			break;
-
-		if (steps > AHD_MAX_STEPS) {
-			printf("%s: Infinite loop in critical section\n"
-			       "%s: First Instruction 0x%x now 0x%x\n",
-			       ahd_name(ahd), ahd_name(ahd), first_instr,
-			       seqaddr);
-			ahd_dump_card_state(ahd);
-			panic("critical section loop");
-		}
-
-		steps++;
-#ifdef AHD_DEBUG
-		if ((ahd_debug & AHD_SHOW_MISC) != 0)
-			printf("%s: Single stepping at 0x%x\n", ahd_name(ahd),
-			       seqaddr);
-#endif
-		if (stepping == FALSE) {
-
-			first_instr = seqaddr;
-  			ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
-  			simode0 = ahd_inb(ahd, SIMODE0);
-			simode3 = ahd_inb(ahd, SIMODE3);
-			lqimode0 = ahd_inb(ahd, LQIMODE0);
-			lqimode1 = ahd_inb(ahd, LQIMODE1);
-			lqomode0 = ahd_inb(ahd, LQOMODE0);
-			lqomode1 = ahd_inb(ahd, LQOMODE1);
-			ahd_outb(ahd, SIMODE0, 0);
-			ahd_outb(ahd, SIMODE3, 0);
-			ahd_outb(ahd, LQIMODE0, 0);
-			ahd_outb(ahd, LQIMODE1, 0);
-			ahd_outb(ahd, LQOMODE0, 0);
-			ahd_outb(ahd, LQOMODE1, 0);
-			ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-  			simode1 = ahd_inb(ahd, SIMODE1);
-  			ahd_outb(ahd, SIMODE1, ENBUSFREE);
-			ahd_outb(ahd, SEQCTL0, ahd_inb(ahd, SEQCTL0) | STEP);
-			stepping = TRUE;
-		}
-		ahd_outb(ahd, CLRSINT1, CLRBUSFREE);
-		ahd_outb(ahd, CLRINT, CLRSCSIINT);
-		ahd_set_modes(ahd, ahd->saved_src_mode, ahd->saved_dst_mode);
-		ahd_outb(ahd, HCNTRL, ahd->unpause);
-		do {
-			ahd_delay(200);
-		} while (!ahd_is_paused(ahd));
-		ahd_update_modes(ahd);
-	}
-	if (stepping) {
-		ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
-		ahd_outb(ahd, SIMODE0, simode0);
-		ahd_outb(ahd, SIMODE3, simode3);
-		ahd_outb(ahd, LQIMODE0, lqimode0);
-		ahd_outb(ahd, LQIMODE1, lqimode1);
-		ahd_outb(ahd, LQOMODE0, lqomode0);
-		ahd_outb(ahd, LQOMODE1, lqomode1);
-		ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-		ahd_outb(ahd, SEQCTL0, ahd_inb(ahd, SEQCTL0) & ~STEP);
-  		ahd_outb(ahd, SIMODE1, simode1);
-	}
-	ahd_restore_modes(ahd, saved_modes);
-}
-
-/*
- * Clear any pending interrupt status.
- */
-void
-ahd_clear_intstat(struct ahd_softc *ahd)
-{
-	AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
-			 ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
-	/* Clear any interrupt conditions this may have caused */
-	ahd_outb(ahd, CLRLQIINT0, CLRLQIATNQAS|CLRLQICRCT1|CLRLQICRCT2
-				 |CLRLQIBADLQT|CLRLQIATNLQ|CLRLQIATNCMD);
-	ahd_outb(ahd, CLRLQIINT1, CLRLQIPHASE_LQ|CLRLQIPHASE_NLQ|CLRLIQABORT
-				 |CLRLQICRCI_LQ|CLRLQICRCI_NLQ|CLRLQIBADLQI
-				 |CLRLQIOVERI_LQ|CLRLQIOVERI_NLQ|CLRNONPACKREQ);
-	ahd_outb(ahd, CLRLQOINT0, CLRLQOTARGSCBPERR|CLRLQOSTOPT2|CLRLQOATNLQ
-				 |CLRLQOATNPKT|CLRLQOTCRC);
-	ahd_outb(ahd, CLRLQOINT1, CLRLQOINITSCBPERR|CLRLQOSTOPI2|CLRLQOBADQAS
-				 |CLRLQOBUSFREE|CLRLQOPHACHGINPKT);
-	if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0) {
-		ahd_outb(ahd, CLRLQOINT0, 0);
-		ahd_outb(ahd, CLRLQOINT1, 0);
-	}
-	ahd_outb(ahd, CLRSINT3, CLRNTRAMPERR|CLROSRAMPERR);
-	ahd_outb(ahd, CLRSINT1, CLRSELTIMEO|CLRATNO|CLRSCSIRSTI
-				|CLRBUSFREE|CLRSCSIPERR|CLRREQINIT);
-	ahd_outb(ahd, CLRSINT0, CLRSELDO|CLRSELDI|CLRSELINGO
-			        |CLRIOERR|CLROVERRUN);
-	ahd_outb(ahd, CLRINT, CLRSCSIINT);
-}
-
-/**************************** Debugging Routines ******************************/
-#ifdef AHD_DEBUG
-uint32_t ahd_debug = AHD_DEBUG_OPTS;
-#endif
-void
-ahd_print_scb(struct scb *scb)
-{
-	struct hardware_scb *hscb;
-	int i;
-
-	hscb = scb->hscb;
-	printf("scb:%p control:0x%x scsiid:0x%x lun:%d cdb_len:%d\n",
-	       (void *)scb,
-	       hscb->control,
-	       hscb->scsiid,
-	       hscb->lun,
-	       hscb->cdb_len);
-	printf("Shared Data: ");
-	for (i = 0; i < sizeof(hscb->shared_data.idata.cdb); i++)
-		printf("%#02x", hscb->shared_data.idata.cdb[i]);
-	printf("        dataptr:%#x%x datacnt:%#x sgptr:%#x tag:%#x\n",
-	       (uint32_t)((ahd_le64toh(hscb->dataptr) >> 32) & 0xFFFFFFFF),
-	       (uint32_t)(ahd_le64toh(hscb->dataptr) & 0xFFFFFFFF),
-	       ahd_le32toh(hscb->datacnt),
-	       ahd_le32toh(hscb->sgptr),
-	       SCB_GET_TAG(scb));
-	ahd_dump_sglist(scb);
-}
-
-void
-ahd_dump_sglist(struct scb *scb)
-{
-	int i;
-
-	if (scb->sg_count > 0) {
-		if ((scb->ahd_softc->flags & AHD_64BIT_ADDRESSING) != 0) {
-			struct ahd_dma64_seg *sg_list;
-
-			sg_list = (struct ahd_dma64_seg*)scb->sg_list;
-			for (i = 0; i < scb->sg_count; i++) {
-				uint64_t addr;
-				uint32_t len;
-
-				addr = ahd_le64toh(sg_list[i].addr);
-				len = ahd_le32toh(sg_list[i].len);
-				printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
-				       i,
-				       (uint32_t)((addr >> 32) & 0xFFFFFFFF),
-				       (uint32_t)(addr & 0xFFFFFFFF),
-				       sg_list[i].len & AHD_SG_LEN_MASK,
-				       (sg_list[i].len & AHD_DMA_LAST_SEG)
-				     ? " Last" : "");
-			}
-		} else {
-			struct ahd_dma_seg *sg_list;
-
-			sg_list = (struct ahd_dma_seg*)scb->sg_list;
-			for (i = 0; i < scb->sg_count; i++) {
-				uint32_t len;
-
-				len = ahd_le32toh(sg_list[i].len);
-				printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
-				       i,
-				       (len >> 24) & SG_HIGH_ADDR_BITS,
-				       ahd_le32toh(sg_list[i].addr),
-				       len & AHD_SG_LEN_MASK,
-				       len & AHD_DMA_LAST_SEG ? " Last" : "");
-			}
-		}
-	}
-}
-
-/************************* Transfer Negotiation *******************************/
-/*
- * Allocate per target mode instance (ID we respond to as a target)
- * transfer negotiation data structures.
- */
-static struct ahd_tmode_tstate *
-ahd_alloc_tstate(struct ahd_softc *ahd, u_int scsi_id, char channel)
-{
-	struct ahd_tmode_tstate *master_tstate;
-	struct ahd_tmode_tstate *tstate;
-	int i;
-
-	master_tstate = ahd->enabled_targets[ahd->our_id];
-	if (ahd->enabled_targets[scsi_id] != NULL
-	 && ahd->enabled_targets[scsi_id] != master_tstate)
-		panic("%s: ahd_alloc_tstate - Target already allocated",
-		      ahd_name(ahd));
-	tstate = malloc(sizeof(*tstate), M_DEVBUF, M_NOWAIT);
-	if (tstate == NULL)
-		return (NULL);
-
-	/*
-	 * If we have allocated a master tstate, copy user settings from
-	 * the master tstate (taken from SRAM or the EEPROM) for this
-	 * channel, but reset our current and goal settings to async/narrow
-	 * until an initiator talks to us.
-	 */
-	if (master_tstate != NULL) {
-		memcpy(tstate, master_tstate, sizeof(*tstate));
-		memset(tstate->enabled_luns, 0, sizeof(tstate->enabled_luns));
-		for (i = 0; i < 16; i++) {
-			memset(&tstate->transinfo[i].curr, 0,
-			      sizeof(tstate->transinfo[i].curr));
-			memset(&tstate->transinfo[i].goal, 0,
-			      sizeof(tstate->transinfo[i].goal));
-		}
-	} else
-		memset(tstate, 0, sizeof(*tstate));
-	ahd->enabled_targets[scsi_id] = tstate;
-	return (tstate);
-}
-
-#ifdef AHD_TARGET_MODE
-/*
- * Free per target mode instance (ID we respond to as a target)
- * transfer negotiation data structures.
- */
-static void
-ahd_free_tstate(struct ahd_softc *ahd, u_int scsi_id, char channel, int force)
-{
-	struct ahd_tmode_tstate *tstate;
-
-	/*
-	 * Don't clean up our "master" tstate.
-	 * It has our default user settings.
-	 */
-	if (scsi_id == ahd->our_id
-	 && force == FALSE)
-		return;
-
-	tstate = ahd->enabled_targets[scsi_id];
-	if (tstate != NULL)
-		free(tstate, M_DEVBUF);
-	ahd->enabled_targets[scsi_id] = NULL;
-}
-#endif
-
-/*
- * Called when we have an active connection to a target on the bus,
- * this function finds the nearest period to the input period limited
- * by the capabilities of the bus connectivity of and sync settings for
- * the target.
- */
-void
-ahd_devlimited_syncrate(struct ahd_softc *ahd,
-			struct ahd_initiator_tinfo *tinfo,
-			u_int *period, u_int *ppr_options, role_t role)
-{
-	struct	ahd_transinfo *transinfo;
-	u_int	maxsync;
-
-	if ((ahd_inb(ahd, SBLKCTL) & ENAB40) != 0
-	 && (ahd_inb(ahd, SSTAT2) & EXP_ACTIVE) == 0) {
-		maxsync = AHD_SYNCRATE_PACED;
-	} else {
-		maxsync = AHD_SYNCRATE_ULTRA;
-		/* Can't do DT related options on an SE bus */
-		*ppr_options &= MSG_EXT_PPR_QAS_REQ;
-	}
-	/*
-	 * Never allow a value higher than our current goal
-	 * period otherwise we may allow a target initiated
-	 * negotiation to go above the limit as set by the
-	 * user.  In the case of an initiator initiated
-	 * sync negotiation, we limit based on the user
-	 * setting.  This allows the system to still accept
-	 * incoming negotiations even if target initiated
-	 * negotiation is not performed.
-	 */
-	if (role == ROLE_TARGET)
-		transinfo = &tinfo->user;
-	else 
-		transinfo = &tinfo->goal;
-	*ppr_options &= (transinfo->ppr_options|MSG_EXT_PPR_PCOMP_EN);
-	if (transinfo->width == MSG_EXT_WDTR_BUS_8_BIT) {
-		maxsync = MAX(maxsync, AHD_SYNCRATE_ULTRA2);
-		*ppr_options &= ~MSG_EXT_PPR_DT_REQ;
-	}
-	if (transinfo->period == 0) {
-		*period = 0;
-		*ppr_options = 0;
-	} else {
-		*period = MAX(*period, transinfo->period);
-		ahd_find_syncrate(ahd, period, ppr_options, maxsync);
-	}
-}
-
-/*
- * Look up the valid period to SCSIRATE conversion in our table.
- * Return the period and offset that should be sent to the target
- * if this was the beginning of an SDTR.
- */
-void
-ahd_find_syncrate(struct ahd_softc *ahd, u_int *period,
-		  u_int *ppr_options, u_int maxsync)
-{
-	if (*period < maxsync)
-		*period = maxsync;
-
-	if ((*ppr_options & MSG_EXT_PPR_DT_REQ) != 0
-	 && *period > AHD_SYNCRATE_MIN_DT)
-		*ppr_options &= ~MSG_EXT_PPR_DT_REQ;
-		
-	if (*period > AHD_SYNCRATE_MIN)
-		*period = 0;
-
-	/* Honor PPR option conformance rules. */
-	if (*period > AHD_SYNCRATE_PACED)
-		*ppr_options &= ~MSG_EXT_PPR_RTI;
-
-	if ((*ppr_options & MSG_EXT_PPR_IU_REQ) == 0)
-		*ppr_options &= (MSG_EXT_PPR_DT_REQ|MSG_EXT_PPR_QAS_REQ);
-
-	if ((*ppr_options & MSG_EXT_PPR_DT_REQ) == 0)
-		*ppr_options &= MSG_EXT_PPR_QAS_REQ;
-
-	/* Skip all PACED only entries if IU is not available */
-	if ((*ppr_options & MSG_EXT_PPR_IU_REQ) == 0
-	 && *period < AHD_SYNCRATE_DT)
-		*period = AHD_SYNCRATE_DT;
-
-	/* Skip all DT only entries if DT is not available */
-	if ((*ppr_options & MSG_EXT_PPR_DT_REQ) == 0
-	 && *period < AHD_SYNCRATE_ULTRA2)
-		*period = AHD_SYNCRATE_ULTRA2;
-}
-
-/*
- * Truncate the given synchronous offset to a value the
- * current adapter type and syncrate are capable of.
- */
-void
-ahd_validate_offset(struct ahd_softc *ahd,
-		    struct ahd_initiator_tinfo *tinfo,
-		    u_int period, u_int *offset, int wide,
-		    role_t role)
-{
-	u_int maxoffset;
-
-	/* Limit offset to what we can do */
-	if (period == 0)
-		maxoffset = 0;
-	else if (period <= AHD_SYNCRATE_PACED) {
-		if ((ahd->bugs & AHD_PACED_NEGTABLE_BUG) != 0)
-			maxoffset = MAX_OFFSET_PACED_BUG;
-		else
-			maxoffset = MAX_OFFSET_PACED;
-	} else
-		maxoffset = MAX_OFFSET_NON_PACED;
-	*offset = MIN(*offset, maxoffset);
-	if (tinfo != NULL) {
-		if (role == ROLE_TARGET)
-			*offset = MIN(*offset, tinfo->user.offset);
-		else
-			*offset = MIN(*offset, tinfo->goal.offset);
-	}
-}
-
-/*
- * Truncate the given transfer width parameter to a value the
- * current adapter type is capable of.
- */
-void
-ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo,
-		   u_int *bus_width, role_t role)
-{
-	switch (*bus_width) {
-	default:
-		if (ahd->features & AHD_WIDE) {
-			/* Respond Wide */
-			*bus_width = MSG_EXT_WDTR_BUS_16_BIT;
-			break;
-		}
-		/* FALLTHROUGH */
-	case MSG_EXT_WDTR_BUS_8_BIT:
-		*bus_width = MSG_EXT_WDTR_BUS_8_BIT;
-		break;
-	}
-	if (tinfo != NULL) {
-		if (role == ROLE_TARGET)
-			*bus_width = MIN(tinfo->user.width, *bus_width);
-		else
-			*bus_width = MIN(tinfo->goal.width, *bus_width);
-	}
-}
-
-/*
- * Update the bitmask of targets for which the controller should
- * negotiate with at the next convenient oportunity.  This currently
- * means the next time we send the initial identify messages for
- * a new transaction.
- */
-int
-ahd_update_neg_request(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
-		       struct ahd_tmode_tstate *tstate,
-		       struct ahd_initiator_tinfo *tinfo, ahd_neg_type neg_type)
-{
-	u_int auto_negotiate_orig;
-
-	auto_negotiate_orig = tstate->auto_negotiate;
-	if (neg_type == AHD_NEG_ALWAYS) {
-		/*
-		 * Force our "current" settings to be
-		 * unknown so that unless a bus reset
-		 * occurs the need to renegotiate is
-		 * recorded persistently.
-		 */
-		if ((ahd->features & AHD_WIDE) != 0)
-			tinfo->curr.width = AHD_WIDTH_UNKNOWN;
-		tinfo->curr.period = AHD_PERIOD_UNKNOWN;
-		tinfo->curr.offset = AHD_OFFSET_UNKNOWN;
-	}
-	if (tinfo->curr.period != tinfo->goal.period
-	 || tinfo->curr.width != tinfo->goal.width
-	 || tinfo->curr.offset != tinfo->goal.offset
-	 || tinfo->curr.ppr_options != tinfo->goal.ppr_options
-	 || (neg_type == AHD_NEG_IF_NON_ASYNC
-	  && (tinfo->goal.offset != 0
-	   || tinfo->goal.width != MSG_EXT_WDTR_BUS_8_BIT
-	   || tinfo->goal.ppr_options != 0)))
-		tstate->auto_negotiate |= devinfo->target_mask;
-	else
-		tstate->auto_negotiate &= ~devinfo->target_mask;
-
-	return (auto_negotiate_orig != tstate->auto_negotiate);
-}
-
-/*
- * Update the user/goal/curr tables of synchronous negotiation
- * parameters as well as, in the case of a current or active update,
- * any data structures on the host controller.  In the case of an
- * active update, the specified target is currently talking to us on
- * the bus, so the transfer parameter update must take effect
- * immediately.
- */
-void
-ahd_set_syncrate(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
-		 u_int period, u_int offset, u_int ppr_options,
-		 u_int type, int paused)
-{
-	struct	ahd_initiator_tinfo *tinfo;
-	struct	ahd_tmode_tstate *tstate;
-	u_int	old_period;
-	u_int	old_offset;
-	u_int	old_ppr;
-	int	active;
-	int	update_needed;
-
-	active = (type & AHD_TRANS_ACTIVE) == AHD_TRANS_ACTIVE;
-	update_needed = 0;
-
-	if (period == 0 || offset == 0) {
-		period = 0;
-		offset = 0;
-	}
-
-	tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid,
-				    devinfo->target, &tstate);
-
-	if ((type & AHD_TRANS_USER) != 0) {
-		tinfo->user.period = period;
-		tinfo->user.offset = offset;
-		tinfo->user.ppr_options = ppr_options;
-	}
-
-	if ((type & AHD_TRANS_GOAL) != 0) {
-		tinfo->goal.period = period;
-		tinfo->goal.offset = offset;
-		tinfo->goal.ppr_options = ppr_options;
-	}
-
-	old_period = tinfo->curr.period;
-	old_offset = tinfo->curr.offset;
-	old_ppr	   = tinfo->curr.ppr_options;
-
-	if ((type & AHD_TRANS_CUR) != 0
-	 && (old_period != period
-	  || old_offset != offset
-	  || old_ppr != ppr_options)) {
-
-		update_needed++;
-
-		tinfo->curr.period = period;
-		tinfo->curr.offset = offset;
-		tinfo->curr.ppr_options = ppr_options;
-
-		ahd_send_async(ahd, devinfo->channel, devinfo->target,
-			       CAM_LUN_WILDCARD, AC_TRANSFER_NEG, NULL);
-		if (bootverbose) {
-			if (offset != 0) {
-				int options;
-
-				printf("%s: target %d synchronous with "
-				       "period = 0x%x, offset = 0x%x",
-				       ahd_name(ahd), devinfo->target,
-				       period, offset);
-				options = 0;
-				if ((ppr_options & MSG_EXT_PPR_DT_REQ) != 0) {
-					printf("(DT");
-					options++;
-				}
-				if ((ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
-					printf("%s", options ? "|IU" : "(IU");
-					options++;
-				}
-				if ((ppr_options & MSG_EXT_PPR_RTI) != 0) {
-					printf("%s", options ? "|RTI" : "(RTI");
-					options++;
-				}
-				if ((ppr_options & MSG_EXT_PPR_QAS_REQ) != 0) {
-					printf("%s", options ? "|QAS" : "(QAS");
-					options++;
-				}
-				if (options != 0)
-					printf(")\n");
-				else
-					printf("\n");
-			} else {
-				printf("%s: target %d using "
-				       "asynchronous transfers%s\n",
-				       ahd_name(ahd), devinfo->target,
-				       (ppr_options & MSG_EXT_PPR_QAS_REQ) != 0
-				     ?  "(QAS)" : "");
-			}
-		}
-	}
-	/*
-	 * Always refresh the neg-table to handle the case of the
-	 * sequencer setting the ENATNO bit for a MK_MESSAGE request.
-	 * We will always renegotiate in that case if this is a
-	 * packetized request.  Also manage the busfree expected flag
-	 * from this common routine so that we catch changes due to
-	 * WDTR or SDTR messages.
-	 */
-	if ((type & AHD_TRANS_CUR) != 0) {
-		if (!paused)
-			ahd_pause(ahd);
-		ahd_update_neg_table(ahd, devinfo, &tinfo->curr);
-		if (!paused)
-			ahd_unpause(ahd);
-		if (ahd->msg_type != MSG_TYPE_NONE) {
-			if ((old_ppr & MSG_EXT_PPR_IU_REQ)
-			 != (ppr_options & MSG_EXT_PPR_IU_REQ)) {
-#ifdef AHD_DEBUG
-				if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
-					ahd_print_devinfo(ahd, devinfo);
-					printf("Expecting IU Change busfree\n");
-				}
-#endif
-				ahd->msg_flags |= MSG_FLAG_EXPECT_PPR_BUSFREE
-					       |  MSG_FLAG_IU_REQ_CHANGED;
-			}
-			if ((old_ppr & MSG_EXT_PPR_IU_REQ) != 0) {
-#ifdef AHD_DEBUG
-				if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
-					printf("PPR with IU_REQ outstanding\n");
-#endif
-				ahd->msg_flags |= MSG_FLAG_EXPECT_PPR_BUSFREE;
-			}
-		}
-	}
-
-	update_needed += ahd_update_neg_request(ahd, devinfo, tstate,
-						tinfo, AHD_NEG_TO_GOAL);
-
-	if (update_needed && active)
-		ahd_update_pending_scbs(ahd);
-}
-
-/*
- * Update the user/goal/curr tables of wide negotiation
- * parameters as well as, in the case of a current or active update,
- * any data structures on the host controller.  In the case of an
- * active update, the specified target is currently talking to us on
- * the bus, so the transfer parameter update must take effect
- * immediately.
- */
-void
-ahd_set_width(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
-	      u_int width, u_int type, int paused)
-{
-	struct	ahd_initiator_tinfo *tinfo;
-	struct	ahd_tmode_tstate *tstate;
-	u_int	oldwidth;
-	int	active;
-	int	update_needed;
-
-	active = (type & AHD_TRANS_ACTIVE) == AHD_TRANS_ACTIVE;
-	update_needed = 0;
-	tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid,
-				    devinfo->target, &tstate);
-
-	if ((type & AHD_TRANS_USER) != 0)
-		tinfo->user.width = width;
-
-	if ((type & AHD_TRANS_GOAL) != 0)
-		tinfo->goal.width = width;
-
-	oldwidth = tinfo->curr.width;
-	if ((type & AHD_TRANS_CUR) != 0 && oldwidth != width) {
-
-		update_needed++;
-
-		tinfo->curr.width = width;
-		ahd_send_async(ahd, devinfo->channel, devinfo->target,
-			       CAM_LUN_WILDCARD, AC_TRANSFER_NEG, NULL);
-		if (bootverbose) {
-			printf("%s: target %d using %dbit transfers\n",
-			       ahd_name(ahd), devinfo->target,
-			       8 * (0x01 << width));
-		}
-	}
-
-	if ((type & AHD_TRANS_CUR) != 0) {
-		if (!paused)
-			ahd_pause(ahd);
-		ahd_update_neg_table(ahd, devinfo, &tinfo->curr);
-		if (!paused)
-			ahd_unpause(ahd);
-	}
-
-	update_needed += ahd_update_neg_request(ahd, devinfo, tstate,
-						tinfo, AHD_NEG_TO_GOAL);
-	if (update_needed && active)
-		ahd_update_pending_scbs(ahd);
-
-}
-
-/*
- * Update the current state of tagged queuing for a given target.
- */
-void
-ahd_set_tags(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
-	     ahd_queue_alg alg)
-{
-	ahd_platform_set_tags(ahd, devinfo, alg);
-	ahd_send_async(ahd, devinfo->channel, devinfo->target,
-		       devinfo->lun, AC_TRANSFER_NEG, &alg);
-}
-
-static void
-ahd_update_neg_table(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
-		     struct ahd_transinfo *tinfo)
-{
-	ahd_mode_state	saved_modes;
-	u_int		period;
-	u_int		ppr_opts;
-	u_int		con_opts;
-	u_int		offset;
-	u_int		saved_negoaddr;
-	uint8_t		iocell_opts[sizeof(ahd->iocell_opts)];
-
-	saved_modes = ahd_save_modes(ahd);
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-
-	saved_negoaddr = ahd_inb(ahd, NEGOADDR);
-	ahd_outb(ahd, NEGOADDR, devinfo->target);
-	period = tinfo->period;
-	offset = tinfo->offset;
-	memcpy(iocell_opts, ahd->iocell_opts, sizeof(ahd->iocell_opts)); 
-	ppr_opts = tinfo->ppr_options & (MSG_EXT_PPR_QAS_REQ|MSG_EXT_PPR_DT_REQ
-					|MSG_EXT_PPR_IU_REQ|MSG_EXT_PPR_RTI);
-	con_opts = 0;
-	if (period == 0)
-		period = AHD_SYNCRATE_ASYNC;
-	if (period == AHD_SYNCRATE_160) {
-
-		if ((ahd->bugs & AHD_PACED_NEGTABLE_BUG) != 0) {
-			/*
-			 * When the SPI4 spec was finalized, PACE transfers
-			 * was not made a configurable option in the PPR
-			 * message.  Instead it is assumed to be enabled for
-			 * any syncrate faster than 80MHz.  Nevertheless,
-			 * Harpoon2A4 allows this to be configurable.
-			 *
-			 * Harpoon2A4 also assumes at most 2 data bytes per
-			 * negotiated REQ/ACK offset.  Paced transfers take
-			 * 4, so we must adjust our offset.
-			 */
-			ppr_opts |= PPROPT_PACE;
-			offset *= 2;
-
-			/*
-			 * Harpoon2A assumed that there would be a
-			 * fallback rate between 160MHz and 80Mhz,
-			 * so 7 is used as the period factor rather
-			 * than 8 for 160MHz.
-			 */
-			period = AHD_SYNCRATE_REVA_160;
-		}
-		if ((tinfo->ppr_options & MSG_EXT_PPR_PCOMP_EN) == 0)
-			iocell_opts[AHD_PRECOMP_SLEW_INDEX] &=
-			    ~AHD_PRECOMP_MASK;
-	} else {
-		/*
-		 * Precomp should be disabled for non-paced transfers.
-		 */
-		iocell_opts[AHD_PRECOMP_SLEW_INDEX] &= ~AHD_PRECOMP_MASK;
-
-		if ((ahd->features & AHD_NEW_IOCELL_OPTS) != 0
-		 && (ppr_opts & MSG_EXT_PPR_DT_REQ) != 0) {
-			/*
-			 * Slow down our CRC interval to be
-			 * compatible with devices that can't
-			 * handle a CRC at full speed.
-			 */
-			con_opts |= ENSLOWCRC;
-		}
-	}
-
-	ahd_outb(ahd, ANNEXCOL, AHD_ANNEXCOL_PRECOMP_SLEW);
-	ahd_outb(ahd, ANNEXDAT, iocell_opts[AHD_PRECOMP_SLEW_INDEX]);
-	ahd_outb(ahd, ANNEXCOL, AHD_ANNEXCOL_AMPLITUDE);
-	ahd_outb(ahd, ANNEXDAT, iocell_opts[AHD_AMPLITUDE_INDEX]);
-
-	ahd_outb(ahd, NEGPERIOD, period);
-	ahd_outb(ahd, NEGPPROPTS, ppr_opts);
-	ahd_outb(ahd, NEGOFFSET, offset);
-
-	if (tinfo->width == MSG_EXT_WDTR_BUS_16_BIT)
-		con_opts |= WIDEXFER;
-
-	/*
-	 * During packetized transfers, the target will
-	 * give us the oportunity to send command packets
-	 * without us asserting attention.
-	 */
-	if ((tinfo->ppr_options & MSG_EXT_PPR_IU_REQ) == 0)
-		con_opts |= ENAUTOATNO;
-	ahd_outb(ahd, NEGCONOPTS, con_opts);
-	ahd_outb(ahd, NEGOADDR, saved_negoaddr);
-	ahd_restore_modes(ahd, saved_modes);
-}
-
-/*
- * When the transfer settings for a connection change, setup for
- * negotiation in pending SCBs to effect the change as quickly as
- * possible.  We also cancel any negotiations that are scheduled
- * for inflight SCBs that have not been started yet.
- */
-static void
-ahd_update_pending_scbs(struct ahd_softc *ahd)
-{
-	struct		scb *pending_scb;
-	int		pending_scb_count;
-	int		i;
-	int		paused;
-	u_int		saved_scbptr;
-	ahd_mode_state	saved_modes;
-
-	/*
-	 * Traverse the pending SCB list and ensure that all of the
-	 * SCBs there have the proper settings.  We can only safely
-	 * clear the negotiation required flag (setting requires the
-	 * execution queue to be modified) and this is only possible
-	 * if we are not already attempting to select out for this
-	 * SCB.  For this reason, all callers only call this routine
-	 * if we are changing the negotiation settings for the currently
-	 * active transaction on the bus.
-	 */
-	pending_scb_count = 0;
-	LIST_FOREACH(pending_scb, &ahd->pending_scbs, pending_links) {
-		struct ahd_devinfo devinfo;
-		struct hardware_scb *pending_hscb;
-		struct ahd_initiator_tinfo *tinfo;
-		struct ahd_tmode_tstate *tstate;
-
-		ahd_scb_devinfo(ahd, &devinfo, pending_scb);
-		tinfo = ahd_fetch_transinfo(ahd, devinfo.channel,
-					    devinfo.our_scsiid,
-					    devinfo.target, &tstate);
-		pending_hscb = pending_scb->hscb;
-		if ((tstate->auto_negotiate & devinfo.target_mask) == 0
-		 && (pending_scb->flags & SCB_AUTO_NEGOTIATE) != 0) {
-			pending_scb->flags &= ~SCB_AUTO_NEGOTIATE;
-			pending_hscb->control &= ~MK_MESSAGE;
-		}
-		ahd_sync_scb(ahd, pending_scb,
-			     BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
-		pending_scb_count++;
-	}
-
-	if (pending_scb_count == 0)
-		return;
-
-	if (ahd_is_paused(ahd)) {
-		paused = 1;
-	} else {
-		paused = 0;
-		ahd_pause(ahd);
-	}
-
-	/*
-	 * Force the sequencer to reinitialize the selection for
-	 * the command at the head of the execution queue if it
-	 * has already been setup.  The negotiation changes may
-	 * effect whether we select-out with ATN.
-	 */
-	saved_modes = ahd_save_modes(ahd);
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-	ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
-	saved_scbptr = ahd_get_scbptr(ahd);
-	/* Ensure that the hscbs down on the card match the new information */
-	for (i = 0; i < ahd->scb_data.maxhscbs; i++) {
-		struct	hardware_scb *pending_hscb;
-		u_int	control;
-		u_int	scb_tag;
-
-		ahd_set_scbptr(ahd, i);
-		scb_tag = i;
-		pending_scb = ahd_lookup_scb(ahd, scb_tag);
-		if (pending_scb == NULL)
-			continue;
-
-		pending_hscb = pending_scb->hscb;
-		control = ahd_inb_scbram(ahd, SCB_CONTROL);
-		control &= ~MK_MESSAGE;
-		control |= pending_hscb->control & MK_MESSAGE;
-		ahd_outb(ahd, SCB_CONTROL, control);
-	}
-	ahd_set_scbptr(ahd, saved_scbptr);
-	ahd_restore_modes(ahd, saved_modes);
-
-	if (paused == 0)
-		ahd_unpause(ahd);
-}
-
-/**************************** Pathing Information *****************************/
-static void
-ahd_fetch_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
-{
-	ahd_mode_state	saved_modes;
-	u_int		saved_scsiid;
-	role_t		role;
-	int		our_id;
-
-	saved_modes = ahd_save_modes(ahd);
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-
-	if (ahd_inb(ahd, SSTAT0) & TARGET)
-		role = ROLE_TARGET;
-	else
-		role = ROLE_INITIATOR;
-
-	if (role == ROLE_TARGET
-	 && (ahd_inb(ahd, SEQ_FLAGS) & CMDPHASE_PENDING) != 0) {
-		/* We were selected, so pull our id from TARGIDIN */
-		our_id = ahd_inb(ahd, TARGIDIN) & OID;
-	} else if (role == ROLE_TARGET)
-		our_id = ahd_inb(ahd, TOWNID);
-	else
-		our_id = ahd_inb(ahd, IOWNID);
-
-	saved_scsiid = ahd_inb(ahd, SAVED_SCSIID);
-	ahd_compile_devinfo(devinfo,
-			    our_id,
-			    SCSIID_TARGET(ahd, saved_scsiid),
-			    ahd_inb(ahd, SAVED_LUN),
-			    SCSIID_CHANNEL(ahd, saved_scsiid),
-			    role);
-	ahd_restore_modes(ahd, saved_modes);
-}
-
-void
-ahd_print_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
-{
-	printf("%s:%c:%d:%d: ", ahd_name(ahd), 'A',
-	       devinfo->target, devinfo->lun);
-}
-
-struct ahd_phase_table_entry*
-ahd_lookup_phase_entry(int phase)
-{
-	struct ahd_phase_table_entry *entry;
-	struct ahd_phase_table_entry *last_entry;
-
-	/*
-	 * num_phases doesn't include the default entry which
-	 * will be returned if the phase doesn't match.
-	 */
-	last_entry = &ahd_phase_table[num_phases];
-	for (entry = ahd_phase_table; entry < last_entry; entry++) {
-		if (phase == entry->phase)
-			break;
-	}
-	return (entry);
-}
-
-void
-ahd_compile_devinfo(struct ahd_devinfo *devinfo, u_int our_id, u_int target,
-		    u_int lun, char channel, role_t role)
-{
-	devinfo->our_scsiid = our_id;
-	devinfo->target = target;
-	devinfo->lun = lun;
-	devinfo->target_offset = target;
-	devinfo->channel = channel;
-	devinfo->role = role;
-	if (channel == 'B')
-		devinfo->target_offset += 8;
-	devinfo->target_mask = (0x01 << devinfo->target_offset);
-}
-
-static void
-ahd_scb_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
-		struct scb *scb)
-{
-	role_t	role;
-	int	our_id;
-
-	our_id = SCSIID_OUR_ID(scb->hscb->scsiid);
-	role = ROLE_INITIATOR;
-	if ((scb->hscb->control & TARGET_SCB) != 0)
-		role = ROLE_TARGET;
-	ahd_compile_devinfo(devinfo, our_id, SCB_GET_TARGET(ahd, scb),
-			    SCB_GET_LUN(scb), SCB_GET_CHANNEL(ahd, scb), role);
-}
-
-
-/************************ Message Phase Processing ****************************/
-/*
- * When an initiator transaction with the MK_MESSAGE flag either reconnects
- * or enters the initial message out phase, we are interrupted.  Fill our
- * outgoing message buffer with the appropriate message and beging handing
- * the message phase(s) manually.
- */
-static void
-ahd_setup_initiator_msgout(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
-			   struct scb *scb)
-{
-	/*
-	 * To facilitate adding multiple messages together,
-	 * each routine should increment the index and len
-	 * variables instead of setting them explicitly.
-	 */
-	ahd->msgout_index = 0;
-	ahd->msgout_len = 0;
-
-	if (ahd_currently_packetized(ahd))
-		ahd->msg_flags |= MSG_FLAG_PACKETIZED;
-
-	if (ahd->send_msg_perror
-	 && ahd_inb(ahd, MSG_OUT) == HOST_MSG) {
-		ahd->msgout_buf[ahd->msgout_index++] = ahd->send_msg_perror;
-		ahd->msgout_len++;
-		ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
-#ifdef AHD_DEBUG
-		if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
-			printf("Setting up for Parity Error delivery\n");
-#endif
-		return;
-	} else if (scb == NULL) {
-		printf("%s: WARNING. No pending message for "
-		       "I_T msgin.  Issuing NO-OP\n", ahd_name(ahd));
-		ahd->msgout_buf[ahd->msgout_index++] = MSG_NOOP;
-		ahd->msgout_len++;
-		ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
-		return;
-	}
-
-	if ((scb->flags & SCB_DEVICE_RESET) == 0
-	 && (scb->flags & SCB_PACKETIZED) == 0
-	 && ahd_inb(ahd, MSG_OUT) == MSG_IDENTIFYFLAG) {
-		u_int identify_msg;
-
-		identify_msg = MSG_IDENTIFYFLAG | SCB_GET_LUN(scb);
-		if ((scb->hscb->control & DISCENB) != 0)
-			identify_msg |= MSG_IDENTIFY_DISCFLAG;
-		ahd->msgout_buf[ahd->msgout_index++] = identify_msg;
-		ahd->msgout_len++;
-
-		if ((scb->hscb->control & TAG_ENB) != 0) {
-			ahd->msgout_buf[ahd->msgout_index++] =
-			    scb->hscb->control & (TAG_ENB|SCB_TAG_TYPE);
-			ahd->msgout_buf[ahd->msgout_index++] = SCB_GET_TAG(scb);
-			ahd->msgout_len += 2;
-		}
-	}
-
-	if (scb->flags & SCB_DEVICE_RESET) {
-		ahd->msgout_buf[ahd->msgout_index++] = MSG_BUS_DEV_RESET;
-		ahd->msgout_len++;
-		ahd_print_path(ahd, scb);
-		printf("Bus Device Reset Message Sent\n");
-		/*
-		 * Clear our selection hardware in advance of
-		 * the busfree.  We may have an entry in the waiting
-		 * Q for this target, and we don't want to go about
-		 * selecting while we handle the busfree and blow it
-		 * away.
-		 */
-		ahd_outb(ahd, SCSISEQ0, 0);
-	} else if ((scb->flags & SCB_ABORT) != 0) {
-
-		if ((scb->hscb->control & TAG_ENB) != 0) {
-			ahd->msgout_buf[ahd->msgout_index++] = MSG_ABORT_TAG;
-		} else {
-			ahd->msgout_buf[ahd->msgout_index++] = MSG_ABORT;
-		}
-		ahd->msgout_len++;
-		ahd_print_path(ahd, scb);
-		printf("Abort%s Message Sent\n",
-		       (scb->hscb->control & TAG_ENB) != 0 ? " Tag" : "");
-		/*
-		 * Clear our selection hardware in advance of
-		 * the busfree.  We may have an entry in the waiting
-		 * Q for this target, and we don't want to go about
-		 * selecting while we handle the busfree and blow it
-		 * away.
-		 */
-		ahd_outb(ahd, SCSISEQ0, 0);
-	} else if ((scb->flags & (SCB_AUTO_NEGOTIATE|SCB_NEGOTIATE)) != 0) {
-		ahd_build_transfer_msg(ahd, devinfo);
-		/*
-		 * Clear our selection hardware in advance of potential
-		 * PPR IU status change busfree.  We may have an entry in
-		 * the waiting Q for this target, and we don't want to go
-		 * about selecting while we handle the busfree and blow
-		 * it away.
-		 */
-		ahd_outb(ahd, SCSISEQ0, 0);
-	} else {
-		printf("ahd_intr: AWAITING_MSG for an SCB that "
-		       "does not have a waiting message\n");
-		printf("SCSIID = %x, target_mask = %x\n", scb->hscb->scsiid,
-		       devinfo->target_mask);
-		panic("SCB = %d, SCB Control = %x:%x, MSG_OUT = %x "
-		      "SCB flags = %x", SCB_GET_TAG(scb), scb->hscb->control,
-		      ahd_inb(ahd, SCB_CONTROL), ahd_inb(ahd, MSG_OUT),
-		      scb->flags);
-	}
-
-	/*
-	 * Clear the MK_MESSAGE flag from the SCB so we aren't
-	 * asked to send this message again.
-	 */
-	ahd_outb(ahd, SCB_CONTROL,
-		 ahd_inb_scbram(ahd, SCB_CONTROL) & ~MK_MESSAGE);
-	scb->hscb->control &= ~MK_MESSAGE;
-	ahd->msgout_index = 0;
-	ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
-}
-
-/*
- * Build an appropriate transfer negotiation message for the
- * currently active target.
- */
-static void
-ahd_build_transfer_msg(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
-{
-	/*
-	 * We need to initiate transfer negotiations.
-	 * If our current and goal settings are identical,
-	 * we want to renegotiate due to a check condition.
-	 */
-	struct	ahd_initiator_tinfo *tinfo;
-	struct	ahd_tmode_tstate *tstate;
-	int	dowide;
-	int	dosync;
-	int	doppr;
-	u_int	period;
-	u_int	ppr_options;
-	u_int	offset;
-
-	tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid,
-				    devinfo->target, &tstate);
-	/*
-	 * Filter our period based on the current connection.
-	 * If we can't perform DT transfers on this segment (not in LVD
-	 * mode for instance), then our decision to issue a PPR message
-	 * may change.
-	 */
-	period = tinfo->goal.period;
-	ppr_options = tinfo->goal.ppr_options;
-	/* Target initiated PPR is not allowed in the SCSI spec */
-	if (devinfo->role == ROLE_TARGET)
-		ppr_options = 0;
-	ahd_devlimited_syncrate(ahd, tinfo, &period,
-				&ppr_options, devinfo->role);
-	dowide = tinfo->curr.width != tinfo->goal.width;
-	dosync = tinfo->curr.period != period;
-	/*
-	 * Only use PPR if we have options that need it, even if the device
-	 * claims to support it.  There might be an expander in the way
-	 * that doesn't.
-	 */
-	doppr = ppr_options != 0;
-
-	if (!dowide && !dosync && !doppr) {
-		dowide = tinfo->goal.width != MSG_EXT_WDTR_BUS_8_BIT;
-		dosync = tinfo->goal.period != 0;
-	}
-
-	if (!dowide && !dosync && !doppr) {
-		/*
-		 * Force async with a WDTR message if we have a wide bus,
-		 * or just issue an SDTR with a 0 offset.
-		 */
-		if ((ahd->features & AHD_WIDE) != 0)
-			dowide = 1;
-		else
-			dosync = 1;
-
-		if (bootverbose) {
-			ahd_print_devinfo(ahd, devinfo);
-			printf("Ensuring async\n");
-		}
-	}
-	/* Target initiated PPR is not allowed in the SCSI spec */
-	if (devinfo->role == ROLE_TARGET)
-		doppr = 0;
-
-	/*
-	 * Both the PPR message and SDTR message require the
-	 * goal syncrate to be limited to what the target device
-	 * is capable of handling (based on whether an LVD->SE
-	 * expander is on the bus), so combine these two cases.
-	 * Regardless, guarantee that if we are using WDTR and SDTR
-	 * messages that WDTR comes first.
-	 */
-	if (doppr || (dosync && !dowide)) {
-
-		offset = tinfo->goal.offset;
-		ahd_validate_offset(ahd, tinfo, period, &offset,
-				    doppr ? tinfo->goal.width
-					  : tinfo->curr.width,
-				    devinfo->role);
-		if (doppr) {
-			ahd_construct_ppr(ahd, devinfo, period, offset,
-					  tinfo->goal.width, ppr_options);
-		} else {
-			ahd_construct_sdtr(ahd, devinfo, period, offset);
-		}
-	} else {
-		ahd_construct_wdtr(ahd, devinfo, tinfo->goal.width);
-	}
-}
-
-/*
- * Build a synchronous negotiation message in our message
- * buffer based on the input parameters.
- */
-static void
-ahd_construct_sdtr(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
-		   u_int period, u_int offset)
-{
-	if (offset == 0)
-		period = AHD_ASYNC_XFER_PERIOD;
-	ahd->msgout_buf[ahd->msgout_index++] = MSG_EXTENDED;
-	ahd->msgout_buf[ahd->msgout_index++] = MSG_EXT_SDTR_LEN;
-	ahd->msgout_buf[ahd->msgout_index++] = MSG_EXT_SDTR;
-	ahd->msgout_buf[ahd->msgout_index++] = period;
-	ahd->msgout_buf[ahd->msgout_index++] = offset;
-	ahd->msgout_len += 5;
-	if (bootverbose) {
-		printf("(%s:%c:%d:%d): Sending SDTR period %x, offset %x\n",
-		       ahd_name(ahd), devinfo->channel, devinfo->target,
-		       devinfo->lun, period, offset);
-	}
-}
-
-/*
- * Build a wide negotiateion message in our message
- * buffer based on the input parameters.
- */
-static void
-ahd_construct_wdtr(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
-		   u_int bus_width)
-{
-	ahd->msgout_buf[ahd->msgout_index++] = MSG_EXTENDED;
-	ahd->msgout_buf[ahd->msgout_index++] = MSG_EXT_WDTR_LEN;
-	ahd->msgout_buf[ahd->msgout_index++] = MSG_EXT_WDTR;
-	ahd->msgout_buf[ahd->msgout_index++] = bus_width;
-	ahd->msgout_len += 4;
-	if (bootverbose) {
-		printf("(%s:%c:%d:%d): Sending WDTR %x\n",
-		       ahd_name(ahd), devinfo->channel, devinfo->target,
-		       devinfo->lun, bus_width);
-	}
-}
-
-/*
- * Build a parallel protocol request message in our message
- * buffer based on the input parameters.
- */
-static void
-ahd_construct_ppr(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
-		  u_int period, u_int offset, u_int bus_width,
-		  u_int ppr_options)
-{
-	/*
-	 * Always request precompensation from
-	 * the other target if we are running
-	 * at paced syncrates.
-	 */
-	if (period <= AHD_SYNCRATE_PACED)
-		ppr_options |= MSG_EXT_PPR_PCOMP_EN;
-	if (offset == 0)
-		period = AHD_ASYNC_XFER_PERIOD;
-	ahd->msgout_buf[ahd->msgout_index++] = MSG_EXTENDED;
-	ahd->msgout_buf[ahd->msgout_index++] = MSG_EXT_PPR_LEN;
-	ahd->msgout_buf[ahd->msgout_index++] = MSG_EXT_PPR;
-	ahd->msgout_buf[ahd->msgout_index++] = period;
-	ahd->msgout_buf[ahd->msgout_index++] = 0;
-	ahd->msgout_buf[ahd->msgout_index++] = offset;
-	ahd->msgout_buf[ahd->msgout_index++] = bus_width;
-	ahd->msgout_buf[ahd->msgout_index++] = ppr_options;
-	ahd->msgout_len += 8;
-	if (bootverbose) {
-		printf("(%s:%c:%d:%d): Sending PPR bus_width %x, period %x, "
-		       "offset %x, ppr_options %x\n", ahd_name(ahd),
-		       devinfo->channel, devinfo->target, devinfo->lun,
-		       bus_width, period, offset, ppr_options);
-	}
-}
-
-/*
- * Clear any active message state.
- */
-static void
-ahd_clear_msg_state(struct ahd_softc *ahd)
-{
-	ahd_mode_state saved_modes;
-
-	saved_modes = ahd_save_modes(ahd);
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-	ahd->send_msg_perror = 0;
-	ahd->msg_flags = MSG_FLAG_NONE;
-	ahd->msgout_len = 0;
-	ahd->msgin_index = 0;
-	ahd->msg_type = MSG_TYPE_NONE;
-	if ((ahd_inb(ahd, SCSISIGO) & ATNO) != 0) {
-		/*
-		 * The target didn't care to respond to our
-		 * message request, so clear ATN.
-		 */
-		ahd_outb(ahd, CLRSINT1, CLRATNO);
-	}
-	ahd_outb(ahd, MSG_OUT, MSG_NOOP);
-	ahd_outb(ahd, SEQ_FLAGS2,
-		 ahd_inb(ahd, SEQ_FLAGS2) & ~TARGET_MSG_PENDING);
-	ahd_restore_modes(ahd, saved_modes);
-}
-
-/*
- * Manual message loop handler.
- */
-static void
-ahd_handle_message_phase(struct ahd_softc *ahd)
-{ 
-	struct	ahd_devinfo devinfo;
-	u_int	bus_phase;
-	int	end_session;
-
-	ahd_fetch_devinfo(ahd, &devinfo);
-	end_session = FALSE;
-	bus_phase = ahd_inb(ahd, LASTPHASE);
-
-	if ((ahd_inb(ahd, LQISTAT2) & LQIPHASE_OUTPKT) != 0) {
-		printf("LQIRETRY for LQIPHASE_OUTPKT\n");
-		ahd_outb(ahd, LQCTL2, LQIRETRY);
-	}
-reswitch:
-	switch (ahd->msg_type) {
-	case MSG_TYPE_INITIATOR_MSGOUT:
-	{
-		int lastbyte;
-		int phasemis;
-		int msgdone;
-
-		if (ahd->msgout_len == 0 && ahd->send_msg_perror == 0)
-			panic("HOST_MSG_LOOP interrupt with no active message");
-
-#ifdef AHD_DEBUG
-		if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
-			ahd_print_devinfo(ahd, &devinfo);
-			printf("INITIATOR_MSG_OUT");
-		}
-#endif
-		phasemis = bus_phase != P_MESGOUT;
-		if (phasemis) {
-#ifdef AHD_DEBUG
-			if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
-				printf(" PHASEMIS %s\n",
-				       ahd_lookup_phase_entry(bus_phase)
-							     ->phasemsg);
-			}
-#endif
-			if (bus_phase == P_MESGIN) {
-				/*
-				 * Change gears and see if
-				 * this messages is of interest to
-				 * us or should be passed back to
-				 * the sequencer.
-				 */
-				ahd_outb(ahd, CLRSINT1, CLRATNO);
-				ahd->send_msg_perror = 0;
-				ahd->msg_type = MSG_TYPE_INITIATOR_MSGIN;
-				ahd->msgin_index = 0;
-				goto reswitch;
-			}
-			end_session = TRUE;
-			break;
-		}
-
-		if (ahd->send_msg_perror) {
-			ahd_outb(ahd, CLRSINT1, CLRATNO);
-			ahd_outb(ahd, CLRSINT1, CLRREQINIT);
-#ifdef AHD_DEBUG
-			if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
-				printf(" byte 0x%x\n", ahd->send_msg_perror);
-#endif
-			/*
-			 * If we are notifying the target of a CRC error
-			 * during packetized operations, the target is
-			 * within its rights to acknowledge our message
-			 * with a busfree.
-			 */
-			if ((ahd->msg_flags & MSG_FLAG_PACKETIZED) != 0
-			 && ahd->send_msg_perror == MSG_INITIATOR_DET_ERR)
-				ahd->msg_flags |= MSG_FLAG_EXPECT_IDE_BUSFREE;
-
-			ahd_outb(ahd, RETURN_2, ahd->send_msg_perror);
-			ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_WRITE);
-			break;
-		}
-
-		msgdone	= ahd->msgout_index == ahd->msgout_len;
-		if (msgdone) {
-			/*
-			 * The target has requested a retry.
-			 * Re-assert ATN, reset our message index to
-			 * 0, and try again.
-			 */
-			ahd->msgout_index = 0;
-			ahd_assert_atn(ahd);
-		}
-
-		lastbyte = ahd->msgout_index == (ahd->msgout_len - 1);
-		if (lastbyte) {
-			/* Last byte is signified by dropping ATN */
-			ahd_outb(ahd, CLRSINT1, CLRATNO);
-		}
-
-		/*
-		 * Clear our interrupt status and present
-		 * the next byte on the bus.
-		 */
-		ahd_outb(ahd, CLRSINT1, CLRREQINIT);
-#ifdef AHD_DEBUG
-		if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
-			printf(" byte 0x%x\n",
-			       ahd->msgout_buf[ahd->msgout_index]);
-#endif
-		ahd_outb(ahd, RETURN_2, ahd->msgout_buf[ahd->msgout_index++]);
-		ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_WRITE);
-		break;
-	}
-	case MSG_TYPE_INITIATOR_MSGIN:
-	{
-		int phasemis;
-		int message_done;
-
-#ifdef AHD_DEBUG
-		if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
-			ahd_print_devinfo(ahd, &devinfo);
-			printf("INITIATOR_MSG_IN");
-		}
-#endif
-		phasemis = bus_phase != P_MESGIN;
-		if (phasemis) {
-#ifdef AHD_DEBUG
-			if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
-				printf(" PHASEMIS %s\n",
-				       ahd_lookup_phase_entry(bus_phase)
-							     ->phasemsg);
-			}
-#endif
-			ahd->msgin_index = 0;
-			if (bus_phase == P_MESGOUT
-			 && (ahd->send_msg_perror != 0
-			  || (ahd->msgout_len != 0
-			   && ahd->msgout_index == 0))) {
-				ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
-				goto reswitch;
-			}
-			end_session = TRUE;
-			break;
-		}
-
-		/* Pull the byte in without acking it */
-		ahd->msgin_buf[ahd->msgin_index] = ahd_inb(ahd, SCSIBUS);
-#ifdef AHD_DEBUG
-		if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
-			printf(" byte 0x%x\n",
-			       ahd->msgin_buf[ahd->msgin_index]);
-#endif
-
-		message_done = ahd_parse_msg(ahd, &devinfo);
-
-		if (message_done) {
-			/*
-			 * Clear our incoming message buffer in case there
-			 * is another message following this one.
-			 */
-			ahd->msgin_index = 0;
-
-			/*
-			 * If this message illicited a response,
-			 * assert ATN so the target takes us to the
-			 * message out phase.
-			 */
-			if (ahd->msgout_len != 0) {
-#ifdef AHD_DEBUG
-				if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
-					ahd_print_devinfo(ahd, &devinfo);
-					printf("Asserting ATN for response\n");
-				}
-#endif
-				ahd_assert_atn(ahd);
-			}
-		} else 
-			ahd->msgin_index++;
-
-		if (message_done == MSGLOOP_TERMINATED) {
-			end_session = TRUE;
-		} else {
-			/* Ack the byte */
-			ahd_outb(ahd, CLRSINT1, CLRREQINIT);
-			ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_READ);
-		}
-		break;
-	}
-	case MSG_TYPE_TARGET_MSGIN:
-	{
-		int msgdone;
-		int msgout_request;
-
-		/*
-		 * By default, the message loop will continue.
-		 */
-		ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_TARG);
-
-		if (ahd->msgout_len == 0)
-			panic("Target MSGIN with no active message");
-
-		/*
-		 * If we interrupted a mesgout session, the initiator
-		 * will not know this until our first REQ.  So, we
-		 * only honor mesgout requests after we've sent our
-		 * first byte.
-		 */
-		if ((ahd_inb(ahd, SCSISIGI) & ATNI) != 0
-		 && ahd->msgout_index > 0)
-			msgout_request = TRUE;
-		else
-			msgout_request = FALSE;
-
-		if (msgout_request) {
-
-			/*
-			 * Change gears and see if
-			 * this messages is of interest to
-			 * us or should be passed back to
-			 * the sequencer.
-			 */
-			ahd->msg_type = MSG_TYPE_TARGET_MSGOUT;
-			ahd_outb(ahd, SCSISIGO, P_MESGOUT | BSYO);
-			ahd->msgin_index = 0;
-			/* Dummy read to REQ for first byte */
-			ahd_inb(ahd, SCSIDAT);
-			ahd_outb(ahd, SXFRCTL0,
-				 ahd_inb(ahd, SXFRCTL0) | SPIOEN);
-			break;
-		}
-
-		msgdone = ahd->msgout_index == ahd->msgout_len;
-		if (msgdone) {
-			ahd_outb(ahd, SXFRCTL0,
-				 ahd_inb(ahd, SXFRCTL0) & ~SPIOEN);
-			end_session = TRUE;
-			break;
-		}
-
-		/*
-		 * Present the next byte on the bus.
-		 */
-		ahd_outb(ahd, SXFRCTL0, ahd_inb(ahd, SXFRCTL0) | SPIOEN);
-		ahd_outb(ahd, SCSIDAT, ahd->msgout_buf[ahd->msgout_index++]);
-		break;
-	}
-	case MSG_TYPE_TARGET_MSGOUT:
-	{
-		int lastbyte;
-		int msgdone;
-
-		/*
-		 * By default, the message loop will continue.
-		 */
-		ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_TARG);
-
-		/*
-		 * The initiator signals that this is
-		 * the last byte by dropping ATN.
-		 */
-		lastbyte = (ahd_inb(ahd, SCSISIGI) & ATNI) == 0;
-
-		/*
-		 * Read the latched byte, but turn off SPIOEN first
-		 * so that we don't inadvertently cause a REQ for the
-		 * next byte.
-		 */
-		ahd_outb(ahd, SXFRCTL0, ahd_inb(ahd, SXFRCTL0) & ~SPIOEN);
-		ahd->msgin_buf[ahd->msgin_index] = ahd_inb(ahd, SCSIDAT);
-		msgdone = ahd_parse_msg(ahd, &devinfo);
-		if (msgdone == MSGLOOP_TERMINATED) {
-			/*
-			 * The message is *really* done in that it caused
-			 * us to go to bus free.  The sequencer has already
-			 * been reset at this point, so pull the ejection
-			 * handle.
-			 */
-			return;
-		}
-		
-		ahd->msgin_index++;
-
-		/*
-		 * XXX Read spec about initiator dropping ATN too soon
-		 *     and use msgdone to detect it.
-		 */
-		if (msgdone == MSGLOOP_MSGCOMPLETE) {
-			ahd->msgin_index = 0;
-
-			/*
-			 * If this message illicited a response, transition
-			 * to the Message in phase and send it.
-			 */
-			if (ahd->msgout_len != 0) {
-				ahd_outb(ahd, SCSISIGO, P_MESGIN | BSYO);
-				ahd_outb(ahd, SXFRCTL0,
-					 ahd_inb(ahd, SXFRCTL0) | SPIOEN);
-				ahd->msg_type = MSG_TYPE_TARGET_MSGIN;
-				ahd->msgin_index = 0;
-				break;
-			}
-		}
-
-		if (lastbyte)
-			end_session = TRUE;
-		else {
-			/* Ask for the next byte. */
-			ahd_outb(ahd, SXFRCTL0,
-				 ahd_inb(ahd, SXFRCTL0) | SPIOEN);
-		}
-
-		break;
-	}
-	default:
-		panic("Unknown REQINIT message type");
-	}
-
-	if (end_session) {
-		if ((ahd->msg_flags & MSG_FLAG_PACKETIZED) != 0) {
-			printf("%s: Returning to Idle Loop\n",
-			       ahd_name(ahd));
-			ahd_outb(ahd, LASTPHASE, P_BUSFREE);
-			ahd_clear_msg_state(ahd);
-			ahd_outb(ahd, SEQCTL0, FASTMODE|SEQRESET);
-		} else {
-			ahd_clear_msg_state(ahd);
-			ahd_outb(ahd, RETURN_1, EXIT_MSG_LOOP);
-		}
-	}
-}
-
-/*
- * See if we sent a particular extended message to the target.
- * If "full" is true, return true only if the target saw the full
- * message.  If "full" is false, return true if the target saw at
- * least the first byte of the message.
- */
-static int
-ahd_sent_msg(struct ahd_softc *ahd, ahd_msgtype type, u_int msgval, int full)
-{
-	int found;
-	u_int index;
-
-	found = FALSE;
-	index = 0;
-
-	while (index < ahd->msgout_len) {
-		if (ahd->msgout_buf[index] == MSG_EXTENDED) {
-			u_int end_index;
-
-			end_index = index + 1 + ahd->msgout_buf[index + 1];
-			if (ahd->msgout_buf[index+2] == msgval
-			 && type == AHDMSG_EXT) {
-
-				if (full) {
-					if (ahd->msgout_index > end_index)
-						found = TRUE;
-				} else if (ahd->msgout_index > index)
-					found = TRUE;
-			}
-			index = end_index;
-		} else if (ahd->msgout_buf[index] >= MSG_SIMPLE_TASK
-			&& ahd->msgout_buf[index] <= MSG_IGN_WIDE_RESIDUE) {
-
-			/* Skip tag type and tag id or residue param*/
-			index += 2;
-		} else {
-			/* Single byte message */
-			if (type == AHDMSG_1B
-			 && ahd->msgout_index > index
-			 && (ahd->msgout_buf[index] == msgval
-			  || ((ahd->msgout_buf[index] & MSG_IDENTIFYFLAG) != 0
-			   && msgval == MSG_IDENTIFYFLAG)))
-				found = TRUE;
-			index++;
-		}
-
-		if (found)
-			break;
-	}
-	return (found);
-}
-
-/*
- * Wait for a complete incoming message, parse it, and respond accordingly.
- */
-static int
-ahd_parse_msg(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
-{
-	struct	ahd_initiator_tinfo *tinfo;
-	struct	ahd_tmode_tstate *tstate;
-	int	reject;
-	int	done;
-	int	response;
-
-	done = MSGLOOP_IN_PROG;
-	response = FALSE;
-	reject = FALSE;
-	tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid,
-				    devinfo->target, &tstate);
-
-	/*
-	 * Parse as much of the message as is availible,
-	 * rejecting it if we don't support it.  When
-	 * the entire message is availible and has been
-	 * handled, return MSGLOOP_MSGCOMPLETE, indicating
-	 * that we have parsed an entire message.
-	 *
-	 * In the case of extended messages, we accept the length
-	 * byte outright and perform more checking once we know the
-	 * extended message type.
-	 */
-	switch (ahd->msgin_buf[0]) {
-	case MSG_DISCONNECT:
-	case MSG_SAVEDATAPOINTER:
-	case MSG_CMDCOMPLETE:
-	case MSG_RESTOREPOINTERS:
-	case MSG_IGN_WIDE_RESIDUE:
-		/*
-		 * End our message loop as these are messages
-		 * the sequencer handles on its own.
-		 */
-		done = MSGLOOP_TERMINATED;
-		break;
-	case MSG_MESSAGE_REJECT:
-		response = ahd_handle_msg_reject(ahd, devinfo);
-		/* FALLTHROUGH */
-	case MSG_NOOP:
-		done = MSGLOOP_MSGCOMPLETE;
-		break;
-	case MSG_EXTENDED:
-	{
-		/* Wait for enough of the message to begin validation */
-		if (ahd->msgin_index < 2)
-			break;
-		switch (ahd->msgin_buf[2]) {
-		case MSG_EXT_SDTR:
-		{
-			u_int	 period;
-			u_int	 ppr_options;
-			u_int	 offset;
-			u_int	 saved_offset;
-			
-			if (ahd->msgin_buf[1] != MSG_EXT_SDTR_LEN) {
-				reject = TRUE;
-				break;
-			}
-
-			/*
-			 * Wait until we have both args before validating
-			 * and acting on this message.
-			 *
-			 * Add one to MSG_EXT_SDTR_LEN to account for
-			 * the extended message preamble.
-			 */
-			if (ahd->msgin_index < (MSG_EXT_SDTR_LEN + 1))
-				break;
-
-			period = ahd->msgin_buf[3];
-			ppr_options = 0;
-			saved_offset = offset = ahd->msgin_buf[4];
-			ahd_devlimited_syncrate(ahd, tinfo, &period,
-						&ppr_options, devinfo->role);
-			ahd_validate_offset(ahd, tinfo, period, &offset,
-					    tinfo->curr.width, devinfo->role);
-			if (bootverbose) {
-				printf("(%s:%c:%d:%d): Received "
-				       "SDTR period %x, offset %x\n\t"
-				       "Filtered to period %x, offset %x\n",
-				       ahd_name(ahd), devinfo->channel,
-				       devinfo->target, devinfo->lun,
-				       ahd->msgin_buf[3], saved_offset,
-				       period, offset);
-			}
-			ahd_set_syncrate(ahd, devinfo, period,
-					 offset, ppr_options,
-					 AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
-					 /*paused*/TRUE);
-
-			/*
-			 * See if we initiated Sync Negotiation
-			 * and didn't have to fall down to async
-			 * transfers.
-			 */
-			if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_SDTR, TRUE)) {
-				/* We started it */
-				if (saved_offset != offset) {
-					/* Went too low - force async */
-					reject = TRUE;
-				}
-			} else {
-				/*
-				 * Send our own SDTR in reply
-				 */
-				if (bootverbose
-				 && devinfo->role == ROLE_INITIATOR) {
-					printf("(%s:%c:%d:%d): Target "
-					       "Initiated SDTR\n",
-					       ahd_name(ahd), devinfo->channel,
-					       devinfo->target, devinfo->lun);
-				}
-				ahd->msgout_index = 0;
-				ahd->msgout_len = 0;
-				ahd_construct_sdtr(ahd, devinfo,
-						   period, offset);
-				ahd->msgout_index = 0;
-				response = TRUE;
-			}
-			done = MSGLOOP_MSGCOMPLETE;
-			break;
-		}
-		case MSG_EXT_WDTR:
-		{
-			u_int bus_width;
-			u_int saved_width;
-			u_int sending_reply;
-
-			sending_reply = FALSE;
-			if (ahd->msgin_buf[1] != MSG_EXT_WDTR_LEN) {
-				reject = TRUE;
-				break;
-			}
-
-			/*
-			 * Wait until we have our arg before validating
-			 * and acting on this message.
-			 *
-			 * Add one to MSG_EXT_WDTR_LEN to account for
-			 * the extended message preamble.
-			 */
-			if (ahd->msgin_index < (MSG_EXT_WDTR_LEN + 1))
-				break;
-
-			bus_width = ahd->msgin_buf[3];
-			saved_width = bus_width;
-			ahd_validate_width(ahd, tinfo, &bus_width,
-					   devinfo->role);
-			if (bootverbose) {
-				printf("(%s:%c:%d:%d): Received WDTR "
-				       "%x filtered to %x\n",
-				       ahd_name(ahd), devinfo->channel,
-				       devinfo->target, devinfo->lun,
-				       saved_width, bus_width);
-			}
-
-			if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_WDTR, TRUE)) {
-				/*
-				 * Don't send a WDTR back to the
-				 * target, since we asked first.
-				 * If the width went higher than our
-				 * request, reject it.
-				 */
-				if (saved_width > bus_width) {
-					reject = TRUE;
-					printf("(%s:%c:%d:%d): requested %dBit "
-					       "transfers.  Rejecting...\n",
-					       ahd_name(ahd), devinfo->channel,
-					       devinfo->target, devinfo->lun,
-					       8 * (0x01 << bus_width));
-					bus_width = 0;
-				}
-			} else {
-				/*
-				 * Send our own WDTR in reply
-				 */
-				if (bootverbose
-				 && devinfo->role == ROLE_INITIATOR) {
-					printf("(%s:%c:%d:%d): Target "
-					       "Initiated WDTR\n",
-					       ahd_name(ahd), devinfo->channel,
-					       devinfo->target, devinfo->lun);
-				}
-				ahd->msgout_index = 0;
-				ahd->msgout_len = 0;
-				ahd_construct_wdtr(ahd, devinfo, bus_width);
-				ahd->msgout_index = 0;
-				response = TRUE;
-				sending_reply = TRUE;
-			}
-			ahd_set_width(ahd, devinfo, bus_width,
-				      AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
-				      /*paused*/TRUE);
-			/* After a wide message, we are async */
-			ahd_set_syncrate(ahd, devinfo, /*period*/0,
-					 /*offset*/0, /*ppr_options*/0,
-					 AHD_TRANS_ACTIVE, /*paused*/TRUE);
-			if (sending_reply == FALSE && reject == FALSE) {
-
-				if (tinfo->goal.offset) {
-					ahd->msgout_index = 0;
-					ahd->msgout_len = 0;
-					ahd_build_transfer_msg(ahd, devinfo);
-					ahd->msgout_index = 0;
-					response = TRUE;
-				}
-			}
-			done = MSGLOOP_MSGCOMPLETE;
-			break;
-		}
-		case MSG_EXT_PPR:
-		{
-			u_int	period;
-			u_int	offset;
-			u_int	bus_width;
-			u_int	ppr_options;
-			u_int	saved_width;
-			u_int	saved_offset;
-			u_int	saved_ppr_options;
-
-			if (ahd->msgin_buf[1] != MSG_EXT_PPR_LEN) {
-				reject = TRUE;
-				break;
-			}
-
-			/*
-			 * Wait until we have all args before validating
-			 * and acting on this message.
-			 *
-			 * Add one to MSG_EXT_PPR_LEN to account for
-			 * the extended message preamble.
-			 */
-			if (ahd->msgin_index < (MSG_EXT_PPR_LEN + 1))
-				break;
-
-			period = ahd->msgin_buf[3];
-			offset = ahd->msgin_buf[5];
-			bus_width = ahd->msgin_buf[6];
-			saved_width = bus_width;
-			ppr_options = ahd->msgin_buf[7];
-			/*
-			 * According to the spec, a DT only
-			 * period factor with no DT option
-			 * set implies async.
-			 */
-			if ((ppr_options & MSG_EXT_PPR_DT_REQ) == 0
-			 && period <= 9)
-				offset = 0;
-			saved_ppr_options = ppr_options;
-			saved_offset = offset;
-
-			/*
-			 * Transfer options are only available if we
-			 * are negotiating wide.
-			 */
-			if (bus_width == 0)
-				ppr_options &= MSG_EXT_PPR_QAS_REQ;
-
-			ahd_validate_width(ahd, tinfo, &bus_width,
-					   devinfo->role);
-			ahd_devlimited_syncrate(ahd, tinfo, &period,
-						&ppr_options, devinfo->role);
-			ahd_validate_offset(ahd, tinfo, period, &offset,
-					    bus_width, devinfo->role);
-
-			if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_PPR, TRUE)) {
-				/*
-				 * If we are unable to do any of the
-				 * requested options (we went too low),
-				 * then we'll have to reject the message.
-				 */
-				if (saved_width > bus_width
-				 || saved_offset != offset
-				 || saved_ppr_options != ppr_options) {
-					reject = TRUE;
-					period = 0;
-					offset = 0;
-					bus_width = 0;
-					ppr_options = 0;
-				}
-			} else {
-				if (devinfo->role != ROLE_TARGET)
-					printf("(%s:%c:%d:%d): Target "
-					       "Initiated PPR\n",
-					       ahd_name(ahd), devinfo->channel,
-					       devinfo->target, devinfo->lun);
-				else
-					printf("(%s:%c:%d:%d): Initiator "
-					       "Initiated PPR\n",
-					       ahd_name(ahd), devinfo->channel,
-					       devinfo->target, devinfo->lun);
-				ahd->msgout_index = 0;
-				ahd->msgout_len = 0;
-				ahd_construct_ppr(ahd, devinfo, period, offset,
-						  bus_width, ppr_options);
-				ahd->msgout_index = 0;
-				response = TRUE;
-			}
-			if (bootverbose) {
-				printf("(%s:%c:%d:%d): Received PPR width %x, "
-				       "period %x, offset %x,options %x\n"
-				       "\tFiltered to width %x, period %x, "
-				       "offset %x, options %x\n",
-				       ahd_name(ahd), devinfo->channel,
-				       devinfo->target, devinfo->lun,
-				       saved_width, ahd->msgin_buf[3],
-				       saved_offset, saved_ppr_options,
-				       bus_width, period, offset, ppr_options);
-			}
-			ahd_set_width(ahd, devinfo, bus_width,
-				      AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
-				      /*paused*/TRUE);
-			ahd_set_syncrate(ahd, devinfo, period,
-					 offset, ppr_options,
-					 AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
-					 /*paused*/TRUE);
-
-			done = MSGLOOP_MSGCOMPLETE;
-			break;
-		}
-		default:
-			/* Unknown extended message.  Reject it. */
-			reject = TRUE;
-			break;
-		}
-		break;
-	}
-#ifdef AHD_TARGET_MODE
-	case MSG_BUS_DEV_RESET:
-		ahd_handle_devreset(ahd, devinfo, CAM_LUN_WILDCARD,
-				    CAM_BDR_SENT,
-				    "Bus Device Reset Received",
-				    /*verbose_level*/0);
-		ahd_restart(ahd);
-		done = MSGLOOP_TERMINATED;
-		break;
-	case MSG_ABORT_TAG:
-	case MSG_ABORT:
-	case MSG_CLEAR_QUEUE:
-	{
-		int tag;
-
-		/* Target mode messages */
-		if (devinfo->role != ROLE_TARGET) {
-			reject = TRUE;
-			break;
-		}
-		tag = SCB_LIST_NULL;
-		if (ahd->msgin_buf[0] == MSG_ABORT_TAG)
-			tag = ahd_inb(ahd, INITIATOR_TAG);
-		ahd_abort_scbs(ahd, devinfo->target, devinfo->channel,
-			       devinfo->lun, tag, ROLE_TARGET,
-			       CAM_REQ_ABORTED);
-
-		tstate = ahd->enabled_targets[devinfo->our_scsiid];
-		if (tstate != NULL) {
-			struct ahd_tmode_lstate* lstate;
-
-			lstate = tstate->enabled_luns[devinfo->lun];
-			if (lstate != NULL) {
-				ahd_queue_lstate_event(ahd, lstate,
-						       devinfo->our_scsiid,
-						       ahd->msgin_buf[0],
-						       /*arg*/tag);
-				ahd_send_lstate_events(ahd, lstate);
-			}
-		}
-		ahd_restart(ahd);
-		done = MSGLOOP_TERMINATED;
-		break;
-	}
-#endif
-	case MSG_QAS_REQUEST:
-#ifdef AHD_DEBUG
-		if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
-			printf("%s: QAS request.  SCSISIGI == 0x%x\n",
-			       ahd_name(ahd), ahd_inb(ahd, SCSISIGI));
-#endif
-		ahd->msg_flags |= MSG_FLAG_EXPECT_QASREJ_BUSFREE;
-		/* FALLTHROUGH */
-	case MSG_TERM_IO_PROC:
-	default:
-		reject = TRUE;
-		break;
-	}
-
-	if (reject) {
-		/*
-		 * Setup to reject the message.
-		 */
-		ahd->msgout_index = 0;
-		ahd->msgout_len = 1;
-		ahd->msgout_buf[0] = MSG_MESSAGE_REJECT;
-		done = MSGLOOP_MSGCOMPLETE;
-		response = TRUE;
-	}
-
-	if (done != MSGLOOP_IN_PROG && !response)
-		/* Clear the outgoing message buffer */
-		ahd->msgout_len = 0;
-
-	return (done);
-}
-
-/*
- * Process a message reject message.
- */
-static int
-ahd_handle_msg_reject(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
-{
-	/*
-	 * What we care about here is if we had an
-	 * outstanding SDTR or WDTR message for this
-	 * target.  If we did, this is a signal that
-	 * the target is refusing negotiation.
-	 */
-	struct scb *scb;
-	struct ahd_initiator_tinfo *tinfo;
-	struct ahd_tmode_tstate *tstate;
-	u_int scb_index;
-	u_int last_msg;
-	int   response = 0;
-
-	scb_index = ahd_get_scbptr(ahd);
-	scb = ahd_lookup_scb(ahd, scb_index);
-	tinfo = ahd_fetch_transinfo(ahd, devinfo->channel,
-				    devinfo->our_scsiid,
-				    devinfo->target, &tstate);
-	/* Might be necessary */
-	last_msg = ahd_inb(ahd, LAST_MSG);
-
-	if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_PPR, /*full*/FALSE)) {
-		if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_PPR, /*full*/TRUE)
-		 && tinfo->goal.period <= AHD_SYNCRATE_PACED) {
-			/*
-			 * Target may not like our SPI-4 PPR Options.
-			 * Attempt to negotiate 80MHz which will turn
-			 * off these options.
-			 */
-			if (bootverbose) {
-				printf("(%s:%c:%d:%d): PPR Rejected. "
-				       "Trying simple U160 PPR\n",
-				       ahd_name(ahd), devinfo->channel,
-				       devinfo->target, devinfo->lun);
-			}
-			tinfo->goal.period = AHD_SYNCRATE_DT;
-			tinfo->goal.ppr_options &= MSG_EXT_PPR_IU_REQ
-						|  MSG_EXT_PPR_QAS_REQ
-						|  MSG_EXT_PPR_DT_REQ;
-		} else {
-			/*
-			 * Target does not support the PPR message.
-			 * Attempt to negotiate SPI-2 style.
-			 */
-			if (bootverbose) {
-				printf("(%s:%c:%d:%d): PPR Rejected. "
-				       "Trying WDTR/SDTR\n",
-				       ahd_name(ahd), devinfo->channel,
-				       devinfo->target, devinfo->lun);
-			}
-			tinfo->goal.ppr_options = 0;
-			tinfo->curr.transport_version = 2;
-			tinfo->goal.transport_version = 2;
-		}
-		ahd->msgout_index = 0;
-		ahd->msgout_len = 0;
-		ahd_build_transfer_msg(ahd, devinfo);
-		ahd->msgout_index = 0;
-		response = 1;
-	} else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_WDTR, /*full*/FALSE)) {
-
-		/* note 8bit xfers */
-		printf("(%s:%c:%d:%d): refuses WIDE negotiation.  Using "
-		       "8bit transfers\n", ahd_name(ahd),
-		       devinfo->channel, devinfo->target, devinfo->lun);
-		ahd_set_width(ahd, devinfo, MSG_EXT_WDTR_BUS_8_BIT,
-			      AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
-			      /*paused*/TRUE);
-		/*
-		 * No need to clear the sync rate.  If the target
-		 * did not accept the command, our syncrate is
-		 * unaffected.  If the target started the negotiation,
-		 * but rejected our response, we already cleared the
-		 * sync rate before sending our WDTR.
-		 */
-		if (tinfo->goal.offset != tinfo->curr.offset) {
-
-			/* Start the sync negotiation */
-			ahd->msgout_index = 0;
-			ahd->msgout_len = 0;
-			ahd_build_transfer_msg(ahd, devinfo);
-			ahd->msgout_index = 0;
-			response = 1;
-		}
-	} else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_SDTR, /*full*/FALSE)) {
-		/* note asynch xfers and clear flag */
-		ahd_set_syncrate(ahd, devinfo, /*period*/0,
-				 /*offset*/0, /*ppr_options*/0,
-				 AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
-				 /*paused*/TRUE);
-		printf("(%s:%c:%d:%d): refuses synchronous negotiation. "
-		       "Using asynchronous transfers\n",
-		       ahd_name(ahd), devinfo->channel,
-		       devinfo->target, devinfo->lun);
-	} else if ((scb->hscb->control & MSG_SIMPLE_TASK) != 0) {
-		int tag_type;
-		int mask;
-
-		tag_type = (scb->hscb->control & MSG_SIMPLE_TASK);
-
-		if (tag_type == MSG_SIMPLE_TASK) {
-			printf("(%s:%c:%d:%d): refuses tagged commands.  "
-			       "Performing non-tagged I/O\n", ahd_name(ahd),
-			       devinfo->channel, devinfo->target, devinfo->lun);
-			ahd_set_tags(ahd, devinfo, AHD_QUEUE_NONE);
-			mask = ~0x23;
-		} else {
-			printf("(%s:%c:%d:%d): refuses %s tagged commands.  "
-			       "Performing simple queue tagged I/O only\n",
-			       ahd_name(ahd), devinfo->channel, devinfo->target,
-			       devinfo->lun, tag_type == MSG_ORDERED_TASK
-			       ? "ordered" : "head of queue");
-			ahd_set_tags(ahd, devinfo, AHD_QUEUE_BASIC);
-			mask = ~0x03;
-		}
-
-		/*
-		 * Resend the identify for this CCB as the target
-		 * may believe that the selection is invalid otherwise.
-		 */
-		ahd_outb(ahd, SCB_CONTROL,
-			 ahd_inb_scbram(ahd, SCB_CONTROL) & mask);
-	 	scb->hscb->control &= mask;
-		ahd_set_transaction_tag(scb, /*enabled*/FALSE,
-					/*type*/MSG_SIMPLE_TASK);
-		ahd_outb(ahd, MSG_OUT, MSG_IDENTIFYFLAG);
-		ahd_assert_atn(ahd);
-		ahd_busy_tcl(ahd, BUILD_TCL(scb->hscb->scsiid, devinfo->lun),
-			     SCB_GET_TAG(scb));
-
-		/*
-		 * Requeue all tagged commands for this target
-		 * currently in our posession so they can be
-		 * converted to untagged commands.
-		 */
-		ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb),
-				   SCB_GET_CHANNEL(ahd, scb),
-				   SCB_GET_LUN(scb), /*tag*/SCB_LIST_NULL,
-				   ROLE_INITIATOR, CAM_REQUEUE_REQ,
-				   SEARCH_COMPLETE);
-	} else if (ahd_sent_msg(ahd, AHDMSG_1B, MSG_IDENTIFYFLAG, TRUE)) {
-		/*
-		 * Most likely the device believes that we had
-		 * previously negotiated packetized.
-		 */
-		ahd->msg_flags |= MSG_FLAG_EXPECT_PPR_BUSFREE
-			       |  MSG_FLAG_IU_REQ_CHANGED;
-
-		ahd_force_renegotiation(ahd, devinfo);
-		ahd->msgout_index = 0;
-		ahd->msgout_len = 0;
-		ahd_build_transfer_msg(ahd, devinfo);
-		ahd->msgout_index = 0;
-		response = 1;
-	} else {
-		/*
-		 * Otherwise, we ignore it.
-		 */
-		printf("%s:%c:%d: Message reject for %x -- ignored\n",
-		       ahd_name(ahd), devinfo->channel, devinfo->target,
-		       last_msg);
-	}
-	return (response);
-}
-
-/*
- * Process an ingnore wide residue message.
- */
-static void
-ahd_handle_ign_wide_residue(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
-{
-	u_int scb_index;
-	struct scb *scb;
-
-	scb_index = ahd_get_scbptr(ahd);
-	scb = ahd_lookup_scb(ahd, scb_index);
-	/*
-	 * XXX Actually check data direction in the sequencer?
-	 * Perhaps add datadir to some spare bits in the hscb?
-	 */
-	if ((ahd_inb(ahd, SEQ_FLAGS) & DPHASE) == 0
-	 || ahd_get_transfer_dir(scb) != CAM_DIR_IN) {
-		/*
-		 * Ignore the message if we haven't
-		 * seen an appropriate data phase yet.
-		 */
-	} else {
-		/*
-		 * If the residual occurred on the last
-		 * transfer and the transfer request was
-		 * expected to end on an odd count, do
-		 * nothing.  Otherwise, subtract a byte
-		 * and update the residual count accordingly.
-		 */
-		uint32_t sgptr;
-
-		sgptr = ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR);
-		if ((sgptr & SG_LIST_NULL) != 0
-		 && ahd_inb(ahd, DATA_COUNT_ODD) == 1) {
-			/*
-			 * If the residual occurred on the last
-			 * transfer and the transfer request was
-			 * expected to end on an odd count, do
-			 * nothing.
-			 */
-		} else {
-			uint32_t data_cnt;
-			uint64_t data_addr;
-			uint32_t sglen;
-
-			/* Pull in the rest of the sgptr */
-			sgptr |=
-			    (ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR + 3) << 24)
-			  | (ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR + 2) << 16)
-			  | (ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR + 1) << 8);
-			sgptr &= SG_PTR_MASK;
-			data_cnt =
-			    (ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT+3) << 24)
-			  | (ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT+2) << 16)
-			  | (ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT+1) << 8)
-			  | (ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT));
-
-			data_addr = (((uint64_t)ahd_inb(ahd, SHADDR + 7)) << 56)
-				  | (((uint64_t)ahd_inb(ahd, SHADDR + 6)) << 48)
-				  | (((uint64_t)ahd_inb(ahd, SHADDR + 5)) << 40)
-				  | (((uint64_t)ahd_inb(ahd, SHADDR + 4)) << 32)
-				  | (ahd_inb(ahd, SHADDR + 3) << 24)
-				  | (ahd_inb(ahd, SHADDR + 2) << 16)
-				  | (ahd_inb(ahd, SHADDR + 1) << 8)
-				  | (ahd_inb(ahd, SHADDR));
-
-			data_cnt += 1;
-			data_addr -= 1;
-
-			if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
-				struct ahd_dma64_seg *sg;
-
-				sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
-
-				/*
-				 * The residual sg ptr points to the next S/G
-				 * to load so we must go back one.
-				 */
-				sg--;
-				sglen = ahd_le32toh(sg->len) & AHD_SG_LEN_MASK;
-				if (sg != scb->sg_list
-				 && sglen < (data_cnt & AHD_SG_LEN_MASK)) {
-
-					sg--;
-					sglen = ahd_le32toh(sg->len);
-					/*
-					 * Preserve High Address and SG_LIST
-					 * bits while setting the count to 1.
-					 */
-					data_cnt = 1|(sglen&(~AHD_SG_LEN_MASK));
-					data_addr = ahd_le64toh(sg->addr)
-						  + (sglen & AHD_SG_LEN_MASK)
-						  - 1;
-
-					/*
-					 * Increment sg so it points to the
-					 * "next" sg.
-					 */
-					sg++;
-					sgptr = ahd_sg_virt_to_bus(ahd, scb,
-								   sg);
-				}
-			} else {
-				struct ahd_dma_seg *sg;
-
-				sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
-
-				/*
-				 * The residual sg ptr points to the next S/G
-				 * to load so we must go back one.
-				 */
-				sg--;
-				sglen = ahd_le32toh(sg->len) & AHD_SG_LEN_MASK;
-				if (sg != scb->sg_list
-				 && sglen < (data_cnt & AHD_SG_LEN_MASK)) {
-
-					sg--;
-					sglen = ahd_le32toh(sg->len);
-					/*
-					 * Preserve High Address and SG_LIST
-					 * bits while setting the count to 1.
-					 */
-					data_cnt = 1|(sglen&(~AHD_SG_LEN_MASK));
-					data_addr = ahd_le32toh(sg->addr)
-						  + (sglen & AHD_SG_LEN_MASK)
-						  - 1;
-
-					/*
-					 * Increment sg so it points to the
-					 * "next" sg.
-					 */
-					sg++;
-					sgptr = ahd_sg_virt_to_bus(ahd, scb,
-								  sg);
-				}
-			}
-			ahd_outb(ahd, SCB_RESIDUAL_SGPTR + 3, sgptr >> 24);
-			ahd_outb(ahd, SCB_RESIDUAL_SGPTR + 2, sgptr >> 16);
-			ahd_outb(ahd, SCB_RESIDUAL_SGPTR + 1, sgptr >> 8);
-			ahd_outb(ahd, SCB_RESIDUAL_SGPTR, sgptr);
-
-			ahd_outb(ahd, SCB_RESIDUAL_DATACNT + 3, data_cnt >> 24);
-			ahd_outb(ahd, SCB_RESIDUAL_DATACNT + 2, data_cnt >> 16);
-			ahd_outb(ahd, SCB_RESIDUAL_DATACNT + 1, data_cnt >> 8);
-			ahd_outb(ahd, SCB_RESIDUAL_DATACNT, data_cnt);
-
-			/*
-			 * The FIFO's pointers will be updated if/when the
-			 * sequencer re-enters a data phase.
-			 */
-		}
-	}
-}
-
-
-/*
- * Reinitialize the data pointers for the active transfer
- * based on its current residual.
- */
-static void
-ahd_reinitialize_dataptrs(struct ahd_softc *ahd)
-{
-	struct		 scb *scb;
-	ahd_mode_state	 saved_modes;
-	u_int		 scb_index;
-	u_int		 wait;
-	uint32_t	 sgptr;
-	uint32_t	 resid;
-	uint64_t	 dataptr;
-
-	AHD_ASSERT_MODES(ahd, AHD_MODE_DFF0_MSK|AHD_MODE_DFF1_MSK,
-			 AHD_MODE_DFF0_MSK|AHD_MODE_DFF1_MSK);
-			 
-	scb_index = ahd_get_scbptr(ahd);
-	scb = ahd_lookup_scb(ahd, scb_index);
-
-	/*
-	 * Release and reacquire the FIFO so we
-	 * have a clean slate.
-	 */
-	ahd_outb(ahd, DFFSXFRCTL, CLRCHN);
-	wait = 1000;
-	do {
-		ahd_delay(100);
-	} while (--wait && !(ahd_inb(ahd, MDFFSTAT) & FIFOFREE));
-	if (wait == 0) {
-		ahd_print_path(ahd, scb);
-		printf("ahd_reinitialize_dataptrs: Forcing FIFO free.\n");
-		ahd_outb(ahd, DFFSXFRCTL, RSTCHN|CLRSHCNT);
-	}
-	saved_modes = ahd_save_modes(ahd);
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-	ahd_outb(ahd, DFFSTAT,
-		 ahd_inb(ahd, DFFSTAT)
-		| (saved_modes == 0x11 ? CURRFIFO_1 : CURRFIFO_0));
-
-	/*
-	 * Determine initial values for data_addr and data_cnt
-	 * for resuming the data phase.
-	 */
-	sgptr = (ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR + 3) << 24)
-	      | (ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR + 2) << 16)
-	      | (ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR + 1) << 8)
-	      |	ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR);
-	sgptr &= SG_PTR_MASK;
-
-	resid = (ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT + 2) << 16)
-	      | (ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT + 1) << 8)
-	      | ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT);
-
-	if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
-		struct ahd_dma64_seg *sg;
-
-		sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
-
-		/* The residual sg_ptr always points to the next sg */
-		sg--;
-
-		dataptr = ahd_le64toh(sg->addr)
-			+ (ahd_le32toh(sg->len) & AHD_SG_LEN_MASK)
-			- resid;
-		ahd_outb(ahd, HADDR + 7, dataptr >> 56);
-		ahd_outb(ahd, HADDR + 6, dataptr >> 48);
-		ahd_outb(ahd, HADDR + 5, dataptr >> 40);
-		ahd_outb(ahd, HADDR + 4, dataptr >> 32);
-	} else {
-		struct	 ahd_dma_seg *sg;
-
-		sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
-
-		/* The residual sg_ptr always points to the next sg */
-		sg--;
-
-		dataptr = ahd_le32toh(sg->addr)
-			+ (ahd_le32toh(sg->len) & AHD_SG_LEN_MASK)
-			- resid;
-		ahd_outb(ahd, HADDR + 4,
-			 (ahd_le32toh(sg->len) & ~AHD_SG_LEN_MASK) >> 24);
-	}
-	ahd_outb(ahd, HADDR + 3, dataptr >> 24);
-	ahd_outb(ahd, HADDR + 2, dataptr >> 16);
-	ahd_outb(ahd, HADDR + 1, dataptr >> 8);
-	ahd_outb(ahd, HADDR, dataptr);
-	ahd_outb(ahd, HCNT + 2, resid >> 16);
-	ahd_outb(ahd, HCNT + 1, resid >> 8);
-	ahd_outb(ahd, HCNT, resid);
-}
-
-/*
- * Handle the effects of issuing a bus device reset message.
- */
-static void
-ahd_handle_devreset(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
-		    u_int lun, cam_status status, char *message,
-		    int verbose_level)
-{
-#ifdef AHD_TARGET_MODE
-	struct ahd_tmode_tstate* tstate;
-#endif
-	int found;
-
-	found = ahd_abort_scbs(ahd, devinfo->target, devinfo->channel,
-			       lun, SCB_LIST_NULL, devinfo->role,
-			       status);
-
-#ifdef AHD_TARGET_MODE
-	/*
-	 * Send an immediate notify ccb to all target mord peripheral
-	 * drivers affected by this action.
-	 */
-	tstate = ahd->enabled_targets[devinfo->our_scsiid];
-	if (tstate != NULL) {
-		u_int cur_lun;
-		u_int max_lun;
-
-		if (lun != CAM_LUN_WILDCARD) {
-			cur_lun = 0;
-			max_lun = AHD_NUM_LUNS - 1;
-		} else {
-			cur_lun = lun;
-			max_lun = lun;
-		}
-		for (cur_lun <= max_lun; cur_lun++) {
-			struct ahd_tmode_lstate* lstate;
-
-			lstate = tstate->enabled_luns[cur_lun];
-			if (lstate == NULL)
-				continue;
-
-			ahd_queue_lstate_event(ahd, lstate, devinfo->our_scsiid,
-					       MSG_BUS_DEV_RESET, /*arg*/0);
-			ahd_send_lstate_events(ahd, lstate);
-		}
-	}
-#endif
-
-	/*
-	 * Go back to async/narrow transfers and renegotiate.
-	 */
-	ahd_set_width(ahd, devinfo, MSG_EXT_WDTR_BUS_8_BIT,
-		      AHD_TRANS_CUR, /*paused*/TRUE);
-	ahd_set_syncrate(ahd, devinfo, /*period*/0, /*offset*/0,
-			 /*ppr_options*/0, AHD_TRANS_CUR, /*paused*/TRUE);
-	
-	ahd_send_async(ahd, devinfo->channel, devinfo->target,
-		       lun, AC_SENT_BDR, NULL);
-
-	if (message != NULL
-	 && (verbose_level <= bootverbose))
-		printf("%s: %s on %c:%d. %d SCBs aborted\n", ahd_name(ahd),
-		       message, devinfo->channel, devinfo->target, found);
-}
-
-#ifdef AHD_TARGET_MODE
-static void
-ahd_setup_target_msgin(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
-		       struct scb *scb)
-{
-
-	/*              
-	 * To facilitate adding multiple messages together,
-	 * each routine should increment the index and len
-	 * variables instead of setting them explicitly.
-	 */             
-	ahd->msgout_index = 0;
-	ahd->msgout_len = 0;
-
-	if (scb != NULL && (scb->flags & SCB_AUTO_NEGOTIATE) != 0)
-		ahd_build_transfer_msg(ahd, devinfo);
-	else
-		panic("ahd_intr: AWAITING target message with no message");
-
-	ahd->msgout_index = 0;
-	ahd->msg_type = MSG_TYPE_TARGET_MSGIN;
-}
-#endif
-/**************************** Initialization **********************************/
-static u_int
-ahd_sglist_size(struct ahd_softc *ahd)
-{
-	bus_size_t list_size;
-
-	list_size = sizeof(struct ahd_dma_seg) * AHD_NSEG;
-	if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0)
-		list_size = sizeof(struct ahd_dma64_seg) * AHD_NSEG;
-	return (list_size);
-}
-
-/*
- * Calculate the optimum S/G List allocation size.  S/G elements used
- * for a given transaction must be physically contiguous.  Assume the
- * OS will allocate full pages to us, so it doesn't make sense to request
- * less than a page.
- */
-static u_int
-ahd_sglist_allocsize(struct ahd_softc *ahd)
-{
-	bus_size_t sg_list_increment;
-	bus_size_t sg_list_size;
-	bus_size_t max_list_size;
-	bus_size_t best_list_size;
-
-	/* Start out with the minimum required for AHD_NSEG. */
-	sg_list_increment = ahd_sglist_size(ahd);
-	sg_list_size = sg_list_increment;
-
-	/* Get us as close as possible to a page in size. */
-	while ((sg_list_size + sg_list_increment) <= PAGE_SIZE)
-		sg_list_size += sg_list_increment;
-
-	/*
-	 * Try to reduce the amount of wastage by allocating
-	 * multiple pages.
-	 */
-	best_list_size = sg_list_size;
-	max_list_size = roundup(sg_list_increment, PAGE_SIZE);
-	if (max_list_size < 4 * PAGE_SIZE)
-		max_list_size = 4 * PAGE_SIZE;
-	if (max_list_size > (AHD_SCB_MAX_ALLOC * sg_list_increment))
-		max_list_size = (AHD_SCB_MAX_ALLOC * sg_list_increment);
-	while ((sg_list_size + sg_list_increment) <= max_list_size
-	   &&  (sg_list_size % PAGE_SIZE) != 0) {
-		bus_size_t new_mod;
-		bus_size_t best_mod;
-
-		sg_list_size += sg_list_increment;
-		new_mod = sg_list_size % PAGE_SIZE;
-		best_mod = best_list_size % PAGE_SIZE;
-		if (new_mod > best_mod || new_mod == 0) {
-			best_list_size = sg_list_size;
-		}
-	}
-	return (best_list_size);
-}
-
-/*
- * Allocate a controller structure for a new device
- * and perform initial initializion.
- */
-struct ahd_softc *
-ahd_alloc(void *platform_arg, char *name)
-{
-	struct  ahd_softc *ahd;
-
-#ifndef	__FreeBSD__
-	ahd = malloc(sizeof(*ahd), M_DEVBUF, M_NOWAIT);
-	if (!ahd) {
-		printf("aic7xxx: cannot malloc softc!\n");
-		free(name, M_DEVBUF);
-		return NULL;
-	}
-#else
-	ahd = device_get_softc((device_t)platform_arg);
-#endif
-	memset(ahd, 0, sizeof(*ahd));
-	ahd->seep_config = malloc(sizeof(*ahd->seep_config),
-				  M_DEVBUF, M_NOWAIT);
-	if (ahd->seep_config == NULL) {
-#ifndef	__FreeBSD__
-		free(ahd, M_DEVBUF);
-#endif
-		free(name, M_DEVBUF);
-		return (NULL);
-	}
-	LIST_INIT(&ahd->pending_scbs);
-	/* We don't know our unit number until the OSM sets it */
-	ahd->name = name;
-	ahd->unit = -1;
-	ahd->description = NULL;
-	ahd->bus_description = NULL;
-	ahd->channel = 'A';
-	ahd->chip = AHD_NONE;
-	ahd->features = AHD_FENONE;
-	ahd->bugs = AHD_BUGNONE;
-	ahd->flags = AHD_SPCHK_ENB_A|AHD_RESET_BUS_A|AHD_TERM_ENB_A
-		   | AHD_EXTENDED_TRANS_A|AHD_STPWLEVEL_A;
-	ahd_timer_init(&ahd->reset_timer);
-	ahd_timer_init(&ahd->stat_timer);
-	ahd->int_coalessing_timer = AHD_INT_COALESSING_TIMER_DEFAULT;
-	ahd->int_coalessing_maxcmds = AHD_INT_COALESSING_MAXCMDS_DEFAULT;
-	ahd->int_coalessing_mincmds = AHD_INT_COALESSING_MINCMDS_DEFAULT;
-	ahd->int_coalessing_threshold = AHD_INT_COALESSING_THRESHOLD_DEFAULT;
-	ahd->int_coalessing_stop_threshold =
-	    AHD_INT_COALESSING_STOP_THRESHOLD_DEFAULT;
-
-	if (ahd_platform_alloc(ahd, platform_arg) != 0) {
-		ahd_free(ahd);
-		ahd = NULL;
-	}
-#ifdef AHD_DEBUG
-	if ((ahd_debug & AHD_SHOW_MEMORY) != 0) {
-		printf("%s: scb size = 0x%x, hscb size = 0x%x\n",
-		       ahd_name(ahd), (u_int)sizeof(struct scb),
-		       (u_int)sizeof(struct hardware_scb));
-	}
-#endif
-	return (ahd);
-}
-
-int
-ahd_softc_init(struct ahd_softc *ahd)
-{
-
-	ahd->unpause = 0;
-	ahd->pause = PAUSE; 
-	return (0);
-}
-
-void
-ahd_softc_insert(struct ahd_softc *ahd)
-{
-	struct ahd_softc *list_ahd;
-
-#if AHD_PCI_CONFIG > 0
-	/*
-	 * Second Function PCI devices need to inherit some
-	 * settings from function 0.
-	 */
-	if ((ahd->features & AHD_MULTI_FUNC) != 0) {
-		TAILQ_FOREACH(list_ahd, &ahd_tailq, links) {
-			ahd_dev_softc_t list_pci;
-			ahd_dev_softc_t pci;
-
-			list_pci = list_ahd->dev_softc;
-			pci = ahd->dev_softc;
-			if (ahd_get_pci_slot(list_pci) == ahd_get_pci_slot(pci)
-			 && ahd_get_pci_bus(list_pci) == ahd_get_pci_bus(pci)) {
-				struct ahd_softc *master;
-				struct ahd_softc *slave;
-
-				if (ahd_get_pci_function(list_pci) == 0) {
-					master = list_ahd;
-					slave = ahd;
-				} else {
-					master = ahd;
-					slave = list_ahd;
-				}
-				slave->flags &= ~AHD_BIOS_ENABLED; 
-				slave->flags |=
-				    master->flags & AHD_BIOS_ENABLED;
-				slave->flags &= ~AHD_PRIMARY_CHANNEL; 
-				slave->flags |=
-				    master->flags & AHD_PRIMARY_CHANNEL;
-				break;
-			}
-		}
-	}
-#endif
-
-	/*
-	 * Insertion sort into our list of softcs.
-	 */
-	list_ahd = TAILQ_FIRST(&ahd_tailq);
-	while (list_ahd != NULL
-	    && ahd_softc_comp(list_ahd, ahd) <= 0)
-		list_ahd = TAILQ_NEXT(list_ahd, links);
-	if (list_ahd != NULL)
-		TAILQ_INSERT_BEFORE(list_ahd, ahd, links);
-	else
-		TAILQ_INSERT_TAIL(&ahd_tailq, ahd, links);
-	ahd->init_level++;
-}
-
-/*
- * Verify that the passed in softc pointer is for a
- * controller that is still configured.
- */
-struct ahd_softc *
-ahd_find_softc(struct ahd_softc *ahd)
-{
-	struct ahd_softc *list_ahd;
-
-	TAILQ_FOREACH(list_ahd, &ahd_tailq, links) {
-		if (list_ahd == ahd)
-			return (ahd);
-	}
-	return (NULL);
-}
-
-void
-ahd_set_unit(struct ahd_softc *ahd, int unit)
-{
-	ahd->unit = unit;
-}
-
-void
-ahd_set_name(struct ahd_softc *ahd, char *name)
-{
-	if (ahd->name != NULL)
-		free(ahd->name, M_DEVBUF);
-	ahd->name = name;
-}
-
-void
-ahd_free(struct ahd_softc *ahd)
-{
-	int i;
-
-	ahd_fini_scbdata(ahd);
-	switch (ahd->init_level) {
-	default:
-	case 5:
-		ahd_shutdown(ahd);
-		TAILQ_REMOVE(&ahd_tailq, ahd, links);
-		/* FALLTHROUGH */
-	case 4:
-		ahd_dmamap_unload(ahd, ahd->shared_data_dmat,
-				  ahd->shared_data_dmamap);
-		/* FALLTHROUGH */
-	case 3:
-		ahd_dmamem_free(ahd, ahd->shared_data_dmat, ahd->qoutfifo,
-				ahd->shared_data_dmamap);
-		ahd_dmamap_destroy(ahd, ahd->shared_data_dmat,
-				   ahd->shared_data_dmamap);
-		/* FALLTHROUGH */
-	case 2:
-		ahd_dma_tag_destroy(ahd, ahd->shared_data_dmat);
-	case 1:
-#ifndef __linux__
-		ahd_dma_tag_destroy(ahd, ahd->buffer_dmat);
-#endif
-		break;
-	case 0:
-		break;
-	}
-
-#ifndef __linux__
-	ahd_dma_tag_destroy(ahd, ahd->parent_dmat);
-#endif
-	ahd_platform_free(ahd);
-	for (i = 0; i < AHD_NUM_TARGETS; i++) {
-		struct ahd_tmode_tstate *tstate;
-
-		tstate = ahd->enabled_targets[i];
-		if (tstate != NULL) {
-#if AHD_TARGET_MODE
-			int j;
-
-			for (j = 0; j < AHD_NUM_LUNS; j++) {
-				struct ahd_tmode_lstate *lstate;
-
-				lstate = tstate->enabled_luns[j];
-				if (lstate != NULL) {
-					xpt_free_path(lstate->path);
-					free(lstate, M_DEVBUF);
-				}
-			}
-#endif
-			free(tstate, M_DEVBUF);
-		}
-	}
-#if AHD_TARGET_MODE
-	if (ahd->black_hole != NULL) {
-		xpt_free_path(ahd->black_hole->path);
-		free(ahd->black_hole, M_DEVBUF);
-	}
-#endif
-	if (ahd->name != NULL)
-		free(ahd->name, M_DEVBUF);
-	if (ahd->seep_config != NULL)
-		free(ahd->seep_config, M_DEVBUF);
-	if (ahd->saved_stack != NULL)
-		free(ahd->saved_stack, M_DEVBUF);
-#ifndef __FreeBSD__
-	free(ahd, M_DEVBUF);
-#endif
-	return;
-}
-
-void
-ahd_shutdown(void *arg)
-{
-	struct	ahd_softc *ahd;
-
-	ahd = (struct ahd_softc *)arg;
-
-	/*
-	 * Stop periodic timer callbacks.
-	 */
-	ahd_timer_stop(&ahd->reset_timer);
-	ahd_timer_stop(&ahd->stat_timer);
-
-	/* This will reset most registers to 0, but not all */
-	ahd_reset(ahd);
-}
-
-/*
- * Reset the controller and record some information about it
- * that is only available just after a reset.
- */
-int
-ahd_reset(struct ahd_softc *ahd)
-{
-	u_int	 sxfrctl1;
-	int	 wait;
-	uint32_t cmd;
-	
-	/*
-	 * Preserve the value of the SXFRCTL1 register for all channels.
-	 * It contains settings that affect termination and we don't want
-	 * to disturb the integrity of the bus.
-	 */
-	ahd_pause(ahd);
-	sxfrctl1 = ahd_inb(ahd, SXFRCTL1);
-
-	cmd = ahd_pci_read_config(ahd->dev_softc, PCIR_COMMAND, /*bytes*/2);
-	if ((ahd->bugs & AHD_PCIX_CHIPRST_BUG) != 0) {
-		uint32_t mod_cmd;
-
-		/*
-		 * A4 Razor #632
-		 * During the assertion of CHIPRST, the chip
-		 * does not disable its parity logic prior to
-		 * the start of the reset.  This may cause a
-		 * parity error to be detected and thus a
-		 * spurious SERR or PERR assertion.  Disble
-		 * PERR and SERR responses during the CHIPRST.
-		 */
-		mod_cmd = cmd & ~(PCIM_CMD_PERRESPEN|PCIM_CMD_SERRESPEN);
-		ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND,
-				     mod_cmd, /*bytes*/2);
-	}
-	ahd_outb(ahd, HCNTRL, CHIPRST | ahd->pause);
-
-	/*
-	 * Ensure that the reset has finished.  We delay 1000us
-	 * prior to reading the register to make sure the chip
-	 * has sufficiently completed its reset to handle register
-	 * accesses.
-	 */
-	wait = 1000;
-	do {
-		ahd_delay(1000);
-	} while (--wait && !(ahd_inb(ahd, HCNTRL) & CHIPRSTACK));
-
-	if (wait == 0) {
-		printf("%s: WARNING - Failed chip reset!  "
-		       "Trying to initialize anyway.\n", ahd_name(ahd));
-	}
-	ahd_outb(ahd, HCNTRL, ahd->pause);
-
-	if ((ahd->bugs & AHD_PCIX_CHIPRST_BUG) != 0) {
-		/*
-		 * Clear any latched PCI error status and restore
-		 * previous SERR and PERR response enables.
-		 */
-		ahd_pci_write_config(ahd->dev_softc, PCIR_STATUS + 1,
-				     0xFF, /*bytes*/1);
-		ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND,
-				     cmd, /*bytes*/2);
-	}
-	/* After a reset, we know the state of the mode register. */
-	ahd_known_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-
-	/* Determine chip configuration */
-	ahd->features &= ~AHD_WIDE;
-	if ((ahd_inb(ahd, SBLKCTL) & SELWIDE) != 0)
-		ahd->features |= AHD_WIDE;
-
-	/*
-	 * Restore SXFRCTL1.
-	 *
-	 * We must always initialize STPWEN to 1 before we
-	 * restore the saved values.  STPWEN is initialized
-	 * to a tri-state condition which can only be cleared
-	 * by turning it on.
-	 */
-	ahd_outb(ahd, SXFRCTL1, sxfrctl1|STPWEN);
-	ahd_outb(ahd, SXFRCTL1, sxfrctl1);
-
-	/*
-	 * If a recovery action has forced a chip reset,
-	 * re-initialize the chip to our likeing.
-	 */
-	if (ahd->init_level > 0)
-		ahd_chip_init(ahd);
-
-	return (0);
-}
-
-/*
- * Determine the number of SCBs available on the controller
- */
-int
-ahd_probe_scbs(struct ahd_softc *ahd) {
-	int i;
-
-	AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
-			 ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
-	for (i = 0; i < AHD_SCB_MAX; i++) {
-		int j;
-
-		ahd_set_scbptr(ahd, i);
-		ahd_outw(ahd, SCB_BASE, i);
-		for (j = 2; j < 64; j++)
-			ahd_outb(ahd, SCB_BASE+j, 0);
-		/* Start out life as unallocated (needing an abort) */
-		ahd_outb(ahd, SCB_CONTROL, MK_MESSAGE);
-		if (ahd_inw_scbram(ahd, SCB_BASE) != i)
-			break;
-		ahd_set_scbptr(ahd, 0);
-		if (ahd_inw_scbram(ahd, SCB_BASE) != 0)
-			break;
-	}
-	return (i);
-}
-
-static void
-ahd_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error) 
-{
-	bus_addr_t *baddr;
-
-	baddr = (bus_addr_t *)arg;
-	*baddr = segs->ds_addr;
-}
-
-static void
-ahd_initialize_hscbs(struct ahd_softc *ahd)
-{
-	int i;
-
-	for (i = 0; i < ahd->scb_data.maxhscbs; i++) {
-		ahd_set_scbptr(ahd, i);
-
-		/* Clear the control byte. */
-		ahd_outb(ahd, SCB_CONTROL, 0);
-
-		/* Set the next pointer */
-		ahd_outw(ahd, SCB_NEXT, SCB_LIST_NULL);
-	}
-}
-
-static int
-ahd_init_scbdata(struct ahd_softc *ahd)
-{
-	struct	scb_data *scb_data;
-	int	i;
-
-	scb_data = &ahd->scb_data;
-	TAILQ_INIT(&scb_data->free_scbs);
-	for (i = 0; i < AHD_NUM_TARGETS * AHD_NUM_LUNS_NONPKT; i++)
-		LIST_INIT(&scb_data->free_scb_lists[i]);
-	LIST_INIT(&scb_data->any_dev_free_scb_list);
-	SLIST_INIT(&scb_data->hscb_maps);
-	SLIST_INIT(&scb_data->sg_maps);
-	SLIST_INIT(&scb_data->sense_maps);
-
-	/* Determine the number of hardware SCBs and initialize them */
-	scb_data->maxhscbs = ahd_probe_scbs(ahd);
-	if (scb_data->maxhscbs == 0) {
-		printf("%s: No SCB space found\n", ahd_name(ahd));
-		return (ENXIO);
-	}
-
-	ahd_initialize_hscbs(ahd);
-
-	/*
-	 * Create our DMA tags.  These tags define the kinds of device
-	 * accessible memory allocations and memory mappings we will
-	 * need to perform during normal operation.
-	 *
-	 * Unless we need to further restrict the allocation, we rely
-	 * on the restrictions of the parent dmat, hence the common
-	 * use of MAXADDR and MAXSIZE.
-	 */
-
-	/* DMA tag for our hardware scb structures */
-	if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1,
-			       /*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
-			       /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
-			       /*highaddr*/BUS_SPACE_MAXADDR,
-			       /*filter*/NULL, /*filterarg*/NULL,
-			       PAGE_SIZE, /*nsegments*/1,
-			       /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
-			       /*flags*/0, &scb_data->hscb_dmat) != 0) {
-		goto error_exit;
-	}
-
-	scb_data->init_level++;
-
-	/* DMA tag for our S/G structures. */
-	if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1,
-			       /*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
-			       /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
-			       /*highaddr*/BUS_SPACE_MAXADDR,
-			       /*filter*/NULL, /*filterarg*/NULL,
-			       ahd_sglist_allocsize(ahd), /*nsegments*/1,
-			       /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
-			       /*flags*/0, &scb_data->sg_dmat) != 0) {
-		goto error_exit;
-	}
-#ifdef AHD_DEBUG
-	if ((ahd_debug & AHD_SHOW_MEMORY) != 0)
-		printf("%s: ahd_sglist_allocsize = 0x%x\n", ahd_name(ahd),
-		       ahd_sglist_allocsize(ahd));
-#endif
-
-	scb_data->init_level++;
-
-	/* DMA tag for our sense buffers.  We allocate in page sized chunks */
-	if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1,
-			       /*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
-			       /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
-			       /*highaddr*/BUS_SPACE_MAXADDR,
-			       /*filter*/NULL, /*filterarg*/NULL,
-			       PAGE_SIZE, /*nsegments*/1,
-			       /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
-			       /*flags*/0, &scb_data->sense_dmat) != 0) {
-		goto error_exit;
-	}
-
-	scb_data->init_level++;
-
-	/* Perform initial CCB allocation */
-	ahd_alloc_scbs(ahd);
-
-	if (scb_data->numscbs == 0) {
-		printf("%s: ahd_init_scbdata - "
-		       "Unable to allocate initial scbs\n",
-		       ahd_name(ahd));
-		goto error_exit;
-	}
-
-	/*
-	 * Note that we were successfull
-	 */
-	return (0); 
-
-error_exit:
-
-	return (ENOMEM);
-}
-
-static struct scb *
-ahd_find_scb_by_tag(struct ahd_softc *ahd, u_int tag)
-{
-	struct scb *scb;
-
-	/*
-	 * Look on the pending list.
-	 */
-	LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) {
-		if (SCB_GET_TAG(scb) == tag)
-			return (scb);
-	}
-
-	/*
-	 * Then on all of the collision free lists.
-	 */
-	TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) {
-		struct scb *list_scb;
-
-		list_scb = scb;
-		do {
-			if (SCB_GET_TAG(list_scb) == tag)
-				return (list_scb);
-			list_scb = LIST_NEXT(list_scb, collision_links);
-		} while (list_scb);
-	}
-
-	/*
-	 * And finally on the generic free list.
-	 */
-	LIST_FOREACH(scb, &ahd->scb_data.any_dev_free_scb_list, links.le) {
-		if (SCB_GET_TAG(scb) == tag)
-			return (scb);
-	}
-
-	return (NULL);
-}
-
-static void
-ahd_fini_scbdata(struct ahd_softc *ahd)
-{
-	struct scb_data *scb_data;
-
-	scb_data = &ahd->scb_data;
-	if (scb_data == NULL)
-		return;
-
-	switch (scb_data->init_level) {
-	default:
-	case 7:
-	{
-		struct map_node *sns_map;
-
-		while ((sns_map = SLIST_FIRST(&scb_data->sense_maps)) != NULL) {
-			SLIST_REMOVE_HEAD(&scb_data->sense_maps, links);
-			ahd_dmamap_unload(ahd, scb_data->sense_dmat,
-					  sns_map->dmamap);
-			ahd_dmamem_free(ahd, scb_data->sense_dmat,
-					sns_map->vaddr, sns_map->dmamap);
-			free(sns_map, M_DEVBUF);
-		}
-		ahd_dma_tag_destroy(ahd, scb_data->sense_dmat);
-		/* FALLTHROUGH */
-	}
-	case 6:
-	{
-		struct map_node *sg_map;
-
-		while ((sg_map = SLIST_FIRST(&scb_data->sg_maps)) != NULL) {
-			SLIST_REMOVE_HEAD(&scb_data->sg_maps, links);
-			ahd_dmamap_unload(ahd, scb_data->sg_dmat,
-					  sg_map->dmamap);
-			ahd_dmamem_free(ahd, scb_data->sg_dmat,
-					sg_map->vaddr, sg_map->dmamap);
-			free(sg_map, M_DEVBUF);
-		}
-		ahd_dma_tag_destroy(ahd, scb_data->sg_dmat);
-		/* FALLTHROUGH */
-	}
-	case 5:
-	{
-		struct map_node *hscb_map;
-
-		while ((hscb_map = SLIST_FIRST(&scb_data->hscb_maps)) != NULL) {
-			SLIST_REMOVE_HEAD(&scb_data->hscb_maps, links);
-			ahd_dmamap_unload(ahd, scb_data->hscb_dmat,
-					  hscb_map->dmamap);
-			ahd_dmamem_free(ahd, scb_data->hscb_dmat,
-					hscb_map->vaddr, hscb_map->dmamap);
-			free(hscb_map, M_DEVBUF);
-		}
-		ahd_dma_tag_destroy(ahd, scb_data->hscb_dmat);
-		/* FALLTHROUGH */
-	}
-	case 4:
-	case 3:
-	case 2:
-	case 1:
-	case 0:
-		break;
-	}
-}
-
-/*
- * DSP filter Bypass must be enabled until the first selection
- * after a change in bus mode (Razor #491 and #493).
- */
-static void
-ahd_setup_iocell_workaround(struct ahd_softc *ahd)
-{
-	ahd_mode_state saved_modes;
-
-	saved_modes = ahd_save_modes(ahd);
-	ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
-	ahd_outb(ahd, DSPDATACTL, ahd_inb(ahd, DSPDATACTL)
-	       | BYPASSENAB | RCVROFFSTDIS | XMITOFFSTDIS);
-	ahd_outb(ahd, SIMODE0, ahd_inb(ahd, SIMODE0) | (ENSELDO|ENSELDI));
-#ifdef AHD_DEBUG
-	if ((ahd_debug & AHD_SHOW_MISC) != 0)
-		printf("%s: Setting up iocell workaround\n", ahd_name(ahd));
-#endif
-	ahd_restore_modes(ahd, saved_modes);
-}
-
-static void
-ahd_iocell_first_selection(struct ahd_softc *ahd)
-{
-	ahd_mode_state	saved_modes;
-	u_int		sblkctl;
-
-	saved_modes = ahd_save_modes(ahd);
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-	sblkctl = ahd_inb(ahd, SBLKCTL);
-	ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
-#ifdef AHD_DEBUG
-	if ((ahd_debug & AHD_SHOW_MISC) != 0)
-		printf("%s: iocell first selection\n", ahd_name(ahd));
-#endif
-	if ((sblkctl & ENAB40) != 0) {
-		ahd_outb(ahd, DSPDATACTL,
-			 ahd_inb(ahd, DSPDATACTL) & ~BYPASSENAB);
-#ifdef AHD_DEBUG
-		if ((ahd_debug & AHD_SHOW_MISC) != 0)
-			printf("%s: BYPASS now disabled\n", ahd_name(ahd));
-#endif
-	}
-	ahd_outb(ahd, SIMODE0, ahd_inb(ahd, SIMODE0) & ~(ENSELDO|ENSELDI));
-	ahd_outb(ahd, CLRINT, CLRSCSIINT);
-	ahd_restore_modes(ahd, saved_modes);
-}
-
-/*************************** SCB Management ***********************************/
-static void
-ahd_add_col_list(struct ahd_softc *ahd, struct scb *scb, u_int col_idx)
-{
-	struct	scb_list *free_list;
-	struct	scb_tailq *free_tailq;
-	struct	scb *first_scb;
-
-	scb->flags |= SCB_ON_COL_LIST;
-	AHD_SET_SCB_COL_IDX(scb, col_idx);
-	free_list = &ahd->scb_data.free_scb_lists[col_idx];
-	free_tailq = &ahd->scb_data.free_scbs;
-	first_scb = LIST_FIRST(free_list);
-	if (first_scb != NULL) {
-		LIST_INSERT_AFTER(first_scb, scb, collision_links);
-	} else {
-		LIST_INSERT_HEAD(free_list, scb, collision_links);
-		TAILQ_INSERT_TAIL(free_tailq, scb, links.tqe);
-	}
-}
-
-static void
-ahd_rem_col_list(struct ahd_softc *ahd, struct scb *scb)
-{
-	struct	scb_list *free_list;
-	struct	scb_tailq *free_tailq;
-	struct	scb *first_scb;
-	u_int	col_idx;
-
-	scb->flags &= ~SCB_ON_COL_LIST;
-	col_idx = AHD_GET_SCB_COL_IDX(ahd, scb);
-	free_list = &ahd->scb_data.free_scb_lists[col_idx];
-	free_tailq = &ahd->scb_data.free_scbs;
-	first_scb = LIST_FIRST(free_list);
-	if (first_scb == scb) {
-		struct scb *next_scb;
-
-		/*
-		 * Maintain order in the collision free
-		 * lists for fairness if this device has
-		 * other colliding tags active.
-		 */
-		next_scb = LIST_NEXT(scb, collision_links);
-		if (next_scb != NULL) {
-			TAILQ_INSERT_AFTER(free_tailq, scb,
-					   next_scb, links.tqe);
-		}
-		TAILQ_REMOVE(free_tailq, scb, links.tqe);
-	}
-	LIST_REMOVE(scb, collision_links);
-}
-
-/*
- * Get a free scb. If there are none, see if we can allocate a new SCB.
- */
-struct scb *
-ahd_get_scb(struct ahd_softc *ahd, u_int col_idx)
-{
-	struct scb *scb;
-	int tries;
-
-	tries = 0;
-look_again:
-	TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) {
-		if (AHD_GET_SCB_COL_IDX(ahd, scb) != col_idx) {
-			ahd_rem_col_list(ahd, scb);
-			goto found;
-		}
-	}
-	if ((scb = LIST_FIRST(&ahd->scb_data.any_dev_free_scb_list)) == NULL) {
-
-		if (tries++ != 0)
-			return (NULL);
-		ahd_alloc_scbs(ahd);
-		goto look_again;
-	}
-	LIST_REMOVE(scb, links.le);
-	if (col_idx != AHD_NEVER_COL_IDX
-	 && (scb->col_scb != NULL)
-	 && (scb->col_scb->flags & SCB_ACTIVE) == 0) {
-		LIST_REMOVE(scb->col_scb, links.le);
-		ahd_add_col_list(ahd, scb->col_scb, col_idx);
-	}
-found:
-	scb->flags |= SCB_ACTIVE;
-	return (scb);
-}
-
-/*
- * Return an SCB resource to the free list.
- */
-void
-ahd_free_scb(struct ahd_softc *ahd, struct scb *scb)
-{       
-
-	/* Clean up for the next user */
-	scb->flags = SCB_FLAG_NONE;
-	scb->hscb->control = 0;
-	ahd->scb_data.scbindex[scb->hscb->tag] = NULL;
-
-	if (scb->col_scb == NULL) {
-
-		/*
-		 * No collision possible.  Just free normally.
-		 */
-		LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list,
-				 scb, links.le);
-	} else if ((scb->col_scb->flags & SCB_ON_COL_LIST) != 0) {
-
-		/*
-		 * The SCB we might have collided with is on
-		 * a free collision list.  Put both SCBs on
-		 * the generic list.
-		 */
-		ahd_rem_col_list(ahd, scb->col_scb);
-		LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list,
-				 scb, links.le);
-		LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list,
-				 scb->col_scb, links.le);
-	} else if ((scb->col_scb->flags
-		  & (SCB_PACKETIZED|SCB_ACTIVE)) == SCB_ACTIVE
-		&& (scb->col_scb->hscb->control & TAG_ENB) != 0) {
-
-		/*
-		 * The SCB we might collide with on the next allocation
-		 * is still active in a non-packetized, tagged, context.
-		 * Put us on the SCB collision list.
-		 */
-		ahd_add_col_list(ahd, scb,
-				 AHD_GET_SCB_COL_IDX(ahd, scb->col_scb));
-	} else {
-		/*
-		 * The SCB we might collide with on the next allocation
-		 * is either active in a packetized context, or free.
-		 * Since we can't collide, put this SCB on the generic
-		 * free list.
-		 */
-		LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list,
-				 scb, links.le);
-	}
-
-	ahd_platform_scb_free(ahd, scb);
-}
-
-void
-ahd_alloc_scbs(struct ahd_softc *ahd)
-{
-	struct scb_data *scb_data;
-	struct scb	*next_scb;
-	struct hardware_scb *hscb;
-	struct map_node *hscb_map;
-	struct map_node *sg_map;
-	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;
-	int		 newcount;
-	int		 i;
-
-	scb_data = &ahd->scb_data;
-	if (scb_data->numscbs >= AHD_SCB_MAX_ALLOC)
-		/* Can't allocate any more */
-		return;
-
-	if (scb_data->scbs_left != 0) {
-		int offset;
-
-		offset = (PAGE_SIZE / sizeof(*hscb)) - scb_data->scbs_left;
-		hscb_map = SLIST_FIRST(&scb_data->hscb_maps);
-		hscb = &((struct hardware_scb *)hscb_map->vaddr)[offset];
-		hscb_busaddr = hscb_map->physaddr + (offset * sizeof(*hscb));
-	} else {
-		hscb_map = malloc(sizeof(*hscb_map), M_DEVBUF, M_NOWAIT);
-
-		if (hscb_map == NULL)
-			return;
-
-		/* Allocate the next batch of hardware SCBs */
-		if (ahd_dmamem_alloc(ahd, scb_data->hscb_dmat,
-				     (void **)&hscb_map->vaddr,
-				     BUS_DMA_NOWAIT, &hscb_map->dmamap) != 0) {
-			free(hscb_map, M_DEVBUF);
-			return;
-		}
-
-		SLIST_INSERT_HEAD(&scb_data->hscb_maps, hscb_map, links);
-
-		ahd_dmamap_load(ahd, scb_data->hscb_dmat, hscb_map->dmamap,
-				hscb_map->vaddr, PAGE_SIZE, ahd_dmamap_cb,
-				&hscb_map->physaddr, /*flags*/0);
-
-		hscb = (struct hardware_scb *)hscb_map->vaddr;
-		hscb_busaddr = hscb_map->physaddr;
-		scb_data->scbs_left = PAGE_SIZE / sizeof(*hscb);
-	}
-
-	if (scb_data->sgs_left != 0) {
-		int offset;
-
-		offset = ahd_sglist_allocsize(ahd)
-		       - (scb_data->sgs_left * ahd_sglist_size(ahd));
-		sg_map = SLIST_FIRST(&scb_data->sg_maps);
-		segs = sg_map->vaddr + offset;
-		sg_busaddr = sg_map->physaddr + offset;
-	} else {
-		sg_map = malloc(sizeof(*sg_map), M_DEVBUF, M_NOWAIT);
-
-		if (sg_map == NULL)
-			return;
-
-		/* Allocate the next batch of S/G lists */
-		if (ahd_dmamem_alloc(ahd, scb_data->sg_dmat,
-				     (void **)&sg_map->vaddr,
-				     BUS_DMA_NOWAIT, &sg_map->dmamap) != 0) {
-			free(sg_map, M_DEVBUF);
-			return;
-		}
-
-		SLIST_INSERT_HEAD(&scb_data->sg_maps, sg_map, links);
-
-		ahd_dmamap_load(ahd, scb_data->sg_dmat, sg_map->dmamap,
-				sg_map->vaddr, ahd_sglist_allocsize(ahd),
-				ahd_dmamap_cb, &sg_map->physaddr, /*flags*/0);
-
-		segs = sg_map->vaddr;
-		sg_busaddr = sg_map->physaddr;
-		scb_data->sgs_left =
-		    ahd_sglist_allocsize(ahd) / ahd_sglist_size(ahd);
-#ifdef AHD_DEBUG
-		if (ahd_debug & AHD_SHOW_MEMORY)
-			printf("Mapped SG data\n");
-#endif
-	}
-
-	if (scb_data->sense_left != 0) {
-		int offset;
-
-		offset = PAGE_SIZE - (AHD_SENSE_BUFSIZE * scb_data->sense_left);
-		sense_map = SLIST_FIRST(&scb_data->sense_maps);
-		sense_data = sense_map->vaddr + offset;
-		sense_busaddr = sense_map->physaddr + offset;
-	} else {
-		sense_map = malloc(sizeof(*sense_map), M_DEVBUF, M_NOWAIT);
-
-		if (sense_map == NULL)
-			return;
-
-		/* Allocate the next batch of sense buffers */
-		if (ahd_dmamem_alloc(ahd, scb_data->sense_dmat,
-				     (void **)&sense_map->vaddr,
-				     BUS_DMA_NOWAIT, &sense_map->dmamap) != 0) {
-			free(sense_map, M_DEVBUF);
-			return;
-		}
-
-		SLIST_INSERT_HEAD(&scb_data->sense_maps, sense_map, links);
-
-		ahd_dmamap_load(ahd, scb_data->sense_dmat, sense_map->dmamap,
-				sense_map->vaddr, PAGE_SIZE, ahd_dmamap_cb,
-				&sense_map->physaddr, /*flags*/0);
-
-		sense_data = sense_map->vaddr;
-		sense_busaddr = sense_map->physaddr;
-		scb_data->sense_left = PAGE_SIZE / AHD_SENSE_BUFSIZE;
-#ifdef AHD_DEBUG
-		if (ahd_debug & AHD_SHOW_MEMORY)
-			printf("Mapped sense data\n");
-#endif
-	}
-
-	newcount = MIN(scb_data->sense_left, scb_data->scbs_left);
-	newcount = MIN(newcount, scb_data->sgs_left);
-	newcount = MIN(newcount, (AHD_SCB_MAX_ALLOC - scb_data->numscbs));
-	scb_data->sense_left -= newcount;
-	scb_data->scbs_left -= newcount;
-	scb_data->sgs_left -= newcount;
-	for (i = 0; i < newcount; i++) {
-		u_int col_tag;
-
-		struct scb_platform_data *pdata;
-#ifndef __linux__
-		int error;
-#endif
-		next_scb = (struct scb *)malloc(sizeof(*next_scb),
-						M_DEVBUF, M_NOWAIT);
-		if (next_scb == NULL)
-			break;
-
-		pdata = (struct scb_platform_data *)malloc(sizeof(*pdata),
-							   M_DEVBUF, M_NOWAIT);
-		if (pdata == NULL) {
-			free(next_scb, M_DEVBUF);
-			break;
-		}
-		next_scb->platform_data = pdata;
-		next_scb->hscb_map = hscb_map;
-		next_scb->sg_map = sg_map;
-		next_scb->sense_map = sense_map;
-		next_scb->sg_list = segs;
-		next_scb->sense_data = sense_data;
-		next_scb->sense_busaddr = sense_busaddr;
-		next_scb->hscb = hscb;
-		hscb->hscb_busaddr = ahd_htole32(hscb_busaddr);
-
-		/*
-		 * The sequencer always starts with the second entry.
-		 * The first entry is embedded in the scb.
-		 */
-		next_scb->sg_list_busaddr = sg_busaddr;
-		if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0)
-			next_scb->sg_list_busaddr
-			    += sizeof(struct ahd_dma64_seg);
-		else
-			next_scb->sg_list_busaddr += sizeof(struct ahd_dma_seg);
-		next_scb->ahd_softc = ahd;
-		next_scb->flags = SCB_FLAG_NONE;
-#ifndef __linux__
-		error = ahd_dmamap_create(ahd, ahd->buffer_dmat, /*flags*/0,
-					  &next_scb->dmamap);
-		if (error != 0) {
-			free(next_scb, M_DEVBUF);
-			free(pdata, M_DEVBUF);
-			break;
-		}
-#endif
-		next_scb->hscb->tag = ahd_htole16(scb_data->numscbs);
-		col_tag = scb_data->numscbs ^ 0x100;
-		next_scb->col_scb = ahd_find_scb_by_tag(ahd, col_tag);
-		if (next_scb->col_scb != NULL)
-			next_scb->col_scb->col_scb = next_scb;
-		ahd_free_scb(ahd, next_scb);
-		hscb++;
-		hscb_busaddr += sizeof(*hscb);
-		segs += ahd_sglist_size(ahd);
-		sg_busaddr += ahd_sglist_size(ahd);
-		sense_data += AHD_SENSE_BUFSIZE;
-		sense_busaddr += AHD_SENSE_BUFSIZE;
-		scb_data->numscbs++;
-	}
-}
-
-void
-ahd_controller_info(struct ahd_softc *ahd, char *buf)
-{
-	const char *speed;
-	const char *type;
-	int len;
-
-	len = sprintf(buf, "%s: ", ahd_chip_names[ahd->chip & AHD_CHIPID_MASK]);
-	buf += len;
-
-	speed = "Ultra320 ";
-	if ((ahd->features & AHD_WIDE) != 0) {
-		type = "Wide ";
-	} else {
-		type = "Single ";
-	}
-	len = sprintf(buf, "%s%sChannel %c, SCSI Id=%d, ",
-		      speed, type, ahd->channel, ahd->our_id);
-	buf += len;
-
-	sprintf(buf, "%s, %d SCBs", ahd->bus_description,
-		ahd->scb_data.maxhscbs);
-}
-
-static const char *channel_strings[] = {
-	"Primary Low",
-	"Primary High",
-	"Secondary Low", 
-	"Secondary High"
-};
-
-static const char *termstat_strings[] = {
-	"Terminated Correctly",
-	"Over Terminated",
-	"Under Terminated",
-	"Not Configured"
-};
-
-/*
- * Start the board, ready for normal operation
- */
-int
-ahd_init(struct ahd_softc *ahd)
-{
-	uint8_t		*base_vaddr;
-	uint8_t		*next_vaddr;
-	bus_addr_t	 next_baddr;
-	size_t		 driver_data_size;
-	int		 i;
-	int		 error;
-	u_int		 warn_user;
-	uint8_t		 current_sensing;
-	uint8_t		 fstat;
-
-	AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
-
-	ahd->stack_size = ahd_probe_stack_size(ahd);
-	ahd->saved_stack = malloc(ahd->stack_size * sizeof(uint16_t),
-				  M_DEVBUF, M_NOWAIT);
-	if (ahd->saved_stack == NULL)
-		return (ENOMEM);
-
-	/*
-	 * Verify that the compiler hasn't over-agressively
-	 * padded important structures.
-	 */
-	if (sizeof(struct hardware_scb) != 64)
-		panic("Hardware SCB size is incorrect");
-
-#ifdef AHD_DEBUG
-	if ((ahd_debug & AHD_DEBUG_SEQUENCER) != 0)
-		ahd->flags |= AHD_SEQUENCER_DEBUG;
-#endif
-
-	/*
-	 * Default to allowing initiator operations.
-	 */
-	ahd->flags |= AHD_INITIATORROLE;
-
-	/*
-	 * Only allow target mode features if this unit has them enabled.
-	 */
-	if ((AHD_TMODE_ENABLE & (0x1 << ahd->unit)) == 0)
-		ahd->features &= ~AHD_TARGETMODE;
-
-#ifndef __linux__
-	/* DMA tag for mapping buffers into device visible space. */
-	if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1,
-			       /*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
-			       /*lowaddr*/BUS_SPACE_MAXADDR,
-			       /*highaddr*/BUS_SPACE_MAXADDR,
-			       /*filter*/NULL, /*filterarg*/NULL,
-			       /*maxsize*/(AHD_NSEG - 1) * PAGE_SIZE,
-			       /*nsegments*/AHD_NSEG,
-			       /*maxsegsz*/AHD_MAXTRANSFER_SIZE,
-			       /*flags*/BUS_DMA_ALLOCNOW,
-			       &ahd->buffer_dmat) != 0) {
-		return (ENOMEM);
-	}
-#endif
-
-	ahd->init_level++;
-
-	/*
-	 * DMA tag for our command fifos and other data in system memory
-	 * the card's sequencer must be able to access.  For initiator
-	 * roles, we need to allocate space for the qoutfifo.  When providing
-	 * for the target mode role, we must additionally provide space for
-	 * the incoming target command fifo.
-	 */
-	driver_data_size = AHD_SCB_MAX * sizeof(uint16_t)
-			 + sizeof(struct hardware_scb);
-	if ((ahd->features & AHD_TARGETMODE) != 0)
-		driver_data_size += AHD_TMODE_CMDS * sizeof(struct target_cmd);
-	if ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0)
-		driver_data_size += PKT_OVERRUN_BUFSIZE;
-	if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1,
-			       /*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
-			       /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
-			       /*highaddr*/BUS_SPACE_MAXADDR,
-			       /*filter*/NULL, /*filterarg*/NULL,
-			       driver_data_size,
-			       /*nsegments*/1,
-			       /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
-			       /*flags*/0, &ahd->shared_data_dmat) != 0) {
-		return (ENOMEM);
-	}
-
-	ahd->init_level++;
-
-	/* Allocation of driver data */
-	if (ahd_dmamem_alloc(ahd, ahd->shared_data_dmat,
-			     (void **)&base_vaddr,
-			     BUS_DMA_NOWAIT, &ahd->shared_data_dmamap) != 0) {
-		return (ENOMEM);
-	}
-
-	ahd->init_level++;
-
-	/* And permanently map it in */
-	ahd_dmamap_load(ahd, ahd->shared_data_dmat, ahd->shared_data_dmamap,
-			base_vaddr, driver_data_size, ahd_dmamap_cb,
-			&ahd->shared_data_busaddr, /*flags*/0);
-	ahd->qoutfifo = (uint16_t *)base_vaddr;
-	next_vaddr = (uint8_t *)&ahd->qoutfifo[AHD_QOUT_SIZE];
-	next_baddr = ahd->shared_data_busaddr + AHD_QOUT_SIZE*sizeof(uint16_t);
-	if ((ahd->features & AHD_TARGETMODE) != 0) {
-		ahd->targetcmds = (struct target_cmd *)next_vaddr;
-		next_vaddr += AHD_TMODE_CMDS * sizeof(struct target_cmd);
-		next_baddr += AHD_TMODE_CMDS * sizeof(struct target_cmd);
-	}
-
-	if ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0) {
-		ahd->overrun_buf = next_vaddr;
-		next_vaddr += PKT_OVERRUN_BUFSIZE;
-		next_baddr += PKT_OVERRUN_BUFSIZE;
-	}
-
-	/*
-	 * We need one SCB to serve as the "next SCB".  Since the
-	 * tag identifier in this SCB will never be used, there is
-	 * no point in using a valid HSCB tag from an SCB pulled from
-	 * the standard free pool.  So, we allocate this "sentinel"
-	 * specially from the DMA safe memory chunk used for the QOUTFIFO.
-	 */
-	ahd->next_queued_hscb = (struct hardware_scb *)next_vaddr;
-	ahd->next_queued_hscb->hscb_busaddr = next_baddr;
-
-	ahd->init_level++;
-
-	/* Allocate SCB data now that buffer_dmat is initialized */
-	if (ahd_init_scbdata(ahd) != 0)
-		return (ENOMEM);
-
-	if ((ahd->flags & AHD_INITIATORROLE) == 0)
-		ahd->flags &= ~AHD_RESET_BUS_A;
-
-	/*
-	 * Before committing these settings to the chip, give
-	 * the OSM one last chance to modify our configuration.
-	 */
-	ahd_platform_init(ahd);
-
-	/* Bring up the chip. */
-	ahd_chip_init(ahd);
-
-	AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
-
-	if ((ahd->flags & AHD_CURRENT_SENSING) == 0)
-		goto init_done;
-
-	/*
-	 * Verify termination based on current draw and
-	 * warn user if the bus is over/under terminated.
-	 */
-	error = ahd_write_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL,
-				   CURSENSE_ENB);
-	if (error != 0) {
-		printf("%s: current sensing timeout 1\n", ahd_name(ahd));
-		goto init_done;
-	}
-	for (i = 20, fstat = FLX_FSTAT_BUSY;
-	     (fstat & FLX_FSTAT_BUSY) != 0 && i; i--) {
-		error = ahd_read_flexport(ahd, FLXADDR_FLEXSTAT, &fstat);
-		if (error != 0) {
-			printf("%s: current sensing timeout 2\n",
-			       ahd_name(ahd));
-			goto init_done;
-		}
-	}
-	if (i == 0) {
-		printf("%s: Timedout during current-sensing test\n",
-		       ahd_name(ahd));
-		goto init_done;
-	}
-
-	/* Latch Current Sensing status. */
-	error = ahd_read_flexport(ahd, FLXADDR_CURRENT_STAT, &current_sensing);
-	if (error != 0) {
-		printf("%s: current sensing timeout 3\n", ahd_name(ahd));
-		goto init_done;
-	}
-
-	/* Diable current sensing. */
-	ahd_write_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL, 0);
-
-#ifdef AHD_DEBUG
-	if ((ahd_debug & AHD_SHOW_TERMCTL) != 0) {
-		printf("%s: current_sensing == 0x%x\n",
-		       ahd_name(ahd), current_sensing);
-	}
-#endif
-	warn_user = 0;
-	for (i = 0; i < 4; i++, current_sensing >>= FLX_CSTAT_SHIFT) {
-		u_int term_stat;
-
-		term_stat = (current_sensing & FLX_CSTAT_MASK);
-		switch (term_stat) {
-		case FLX_CSTAT_OVER:
-		case FLX_CSTAT_UNDER:
-			warn_user++;
-		case FLX_CSTAT_INVALID:
-		case FLX_CSTAT_OKAY:
-			if (warn_user == 0 && bootverbose == 0)
-				break;
-			printf("%s: %s Channel %s\n", ahd_name(ahd),
-			       channel_strings[i], termstat_strings[term_stat]);
-			break;
-		}
-	}
-	if (warn_user) {
-		printf("%s: WARNING. Termination is not configured correctly.\n"
-		       "%s: WARNING. SCSI bus operations may FAIL.\n",
-		       ahd_name(ahd), ahd_name(ahd));
-	}
-init_done:
-	ahd_restart(ahd);
-	ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US,
-			ahd_stat_timer, ahd);
-	return (0);
-}
-
-/*
- * (Re)initialize chip state after a chip reset.
- */
-static void
-ahd_chip_init(struct ahd_softc *ahd)
-{
-	uint32_t busaddr;
-	u_int	 sxfrctl1;
-	u_int	 scsiseq_template;
-	u_int	 wait;
-	u_int	 i;
-	u_int	 target;
-
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-	/*
-	 * Take the LED out of diagnostic mode
-	 */
-	ahd_outb(ahd, SBLKCTL, ahd_inb(ahd, SBLKCTL) & ~(DIAGLEDEN|DIAGLEDON));
-
-	/*
-	 * Return HS_MAILBOX to its default value.
-	 */
-	ahd->hs_mailbox = 0;
-	ahd_outb(ahd, HS_MAILBOX, 0);
-
-	/* Set the SCSI Id, SXFRCTL0, SXFRCTL1, and SIMODE1. */
-	ahd_outb(ahd, IOWNID, ahd->our_id);
-	ahd_outb(ahd, TOWNID, ahd->our_id);
-	sxfrctl1 = (ahd->flags & AHD_TERM_ENB_A) != 0 ? STPWEN : 0;
-	sxfrctl1 |= (ahd->flags & AHD_SPCHK_ENB_A) != 0 ? ENSPCHK : 0;
-	if ((ahd->bugs & AHD_LONG_SETIMO_BUG)
-	 && (ahd->seltime != STIMESEL_MIN)) {
-		/*
-		 * The selection timer duration is twice as long
-		 * as it should be.  Halve it by adding "1" to
-		 * the user specified setting.
-		 */
-		sxfrctl1 |= ahd->seltime + STIMESEL_BUG_ADJ;
-	} else {
-		sxfrctl1 |= ahd->seltime;
-	}
-		
-	ahd_outb(ahd, SXFRCTL0, DFON);
-	ahd_outb(ahd, SXFRCTL1, sxfrctl1|ahd->seltime|ENSTIMER|ACTNEGEN);
-	ahd_outb(ahd, SIMODE1, ENSELTIMO|ENSCSIRST|ENSCSIPERR);
-
-	/*
-	 * Now that termination is set, wait for up
-	 * to 500ms for our transceivers to settle.  If
-	 * the adapter does not have a cable attached,
-	 * the tranceivers may never settle, so don't
-	 * complain if we fail here.
-	 */
-	for (wait = 10000;
-	     (ahd_inb(ahd, SBLKCTL) & (ENAB40|ENAB20)) == 0 && wait;
-	     wait--)
-		ahd_delay(100);
-
-	/* Clear any false bus resets due to the transceivers settling */
-	ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI);
-	ahd_outb(ahd, CLRINT, CLRSCSIINT);
-
-	/* Initialize mode specific S/G state. */
-	for (i = 0; i < 2; i++) {
-		ahd_set_modes(ahd, AHD_MODE_DFF0 + i, AHD_MODE_DFF0 + i);
-		ahd_outb(ahd, LONGJMP_ADDR + 1, INVALID_ADDR);
-		ahd_outw(ahd, LONGJMP_SCB, SCB_LIST_NULL);
-		ahd_outb(ahd, SG_STATE, 0);
-		ahd_outb(ahd, CLRSEQINTSRC, 0xFF);
-		ahd_outb(ahd, SEQIMODE,
-			 ENSAVEPTRS|ENCFG4DATA|ENCFG4ISTAT
-			|ENCFG4TSTAT|ENCFG4ICMD|ENCFG4TCMD);
-	}
-
-	ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
-	ahd_outb(ahd, DSCOMMAND0, ahd_inb(ahd, DSCOMMAND0)|MPARCKEN|CACHETHEN);
-	ahd_outb(ahd, DFF_THRSH, RD_DFTHRSH_75|WR_DFTHRSH_75);
-	ahd_outb(ahd, SIMODE0, ENIOERR|ENOVERRUN);
-	ahd_outb(ahd, SIMODE3, ENNTRAMPERR|ENOSRAMPERR);
-	if ((ahd->bugs & AHD_BUSFREEREV_BUG) != 0) {
-		ahd_outb(ahd, OPTIONMODE, AUTOACKEN|AUTO_MSGOUT_DE);
-	} else {
-		ahd_outb(ahd, OPTIONMODE, AUTOACKEN|BUSFREEREV|AUTO_MSGOUT_DE);
-	}
-	ahd_outb(ahd, SCSCHKN, CURRFIFODEF|WIDERESEN);
-	if ((ahd->chip & AHD_BUS_MASK) == AHD_PCIX)
-		/*
-		 * Do not issue a target abort when a split completion
-		 * error occurs.  Let our PCIX interrupt handler deal
-		 * with it instead. H2A4 Razor #625
-		 */
-		ahd_outb(ahd, PCIXCTL, ahd_inb(ahd, PCIXCTL) | SPLTSTADIS);
-
-	if ((ahd->bugs & AHD_LQOOVERRUN_BUG) != 0)
-		ahd_outb(ahd, LQOSCSCTL, LQONOCHKOVER);
-
-	/*
-	 * Tweak IOCELL settings.
-	 */
-	if ((ahd->flags & AHD_HP_BOARD) != 0) {
-		for (i = 0; i < NUMDSPS; i++) {
-			ahd_outb(ahd, DSPSELECT, i);
-			ahd_outb(ahd, WRTBIASCTL, WRTBIASCTL_HP_DEFAULT);
-		}
-#ifdef AHD_DEBUG
-		if ((ahd_debug & AHD_SHOW_MISC) != 0)
-			printf("%s: WRTBIASCTL now 0x%x\n", ahd_name(ahd),
-			       WRTBIASCTL_HP_DEFAULT);
-#endif
-	}
-	ahd_setup_iocell_workaround(ahd);
-
-	/*
-	 * Enable LQI Manager interrupts.
-	 */
-	ahd_outb(ahd, LQIMODE1, ENLQIPHASE_LQ|ENLQIPHASE_NLQ|ENLIQABORT
-			      | ENLQICRCI_LQ|ENLQICRCI_NLQ|ENLQIBADLQI
-			      | ENLQIOVERI_LQ|ENLQIOVERI_NLQ);
-	ahd_outb(ahd, LQOMODE0, ENLQOATNLQ|ENLQOATNPKT|ENLQOTCRC);
-	/*
-	 * An interrupt from LQOBUSFREE is made redundant by the
-	 * BUSFREE interrupt.  We choose to have the sequencer catch
-	 * LQOPHCHGINPKT errors manually for the command phase at the
-	 * start of a packetized selection case.
-	ahd_outb(ahd, LQOMODE1, ENLQOBUSFREE|ENLQOPHACHGINPKT);
-	 */
-	ahd_outb(ahd, LQOMODE1, 0);
-
-	/*
-	 * Setup sequencer interrupt handlers.
-	 */
-	ahd_outw(ahd, INTVEC1_ADDR, ahd_resolve_seqaddr(ahd, LABEL_seq_isr));
-	ahd_outw(ahd, INTVEC2_ADDR, ahd_resolve_seqaddr(ahd, LABEL_timer_isr));
-
-	/*
-	 * Setup SCB Offset registers.
-	 */
-	if ((ahd->bugs & AHD_PKT_LUN_BUG) != 0) {
-		ahd_outb(ahd, LUNPTR, offsetof(struct hardware_scb,
-			 pkt_long_lun));
-	} else {
-		ahd_outb(ahd, LUNPTR, offsetof(struct hardware_scb, lun));
-	}
-	ahd_outb(ahd, CMDLENPTR, offsetof(struct hardware_scb, cdb_len));
-	ahd_outb(ahd, ATTRPTR, offsetof(struct hardware_scb, task_attribute));
-	ahd_outb(ahd, FLAGPTR, offsetof(struct hardware_scb, task_management));
-	ahd_outb(ahd, CMDPTR, offsetof(struct hardware_scb,
-				       shared_data.idata.cdb));
-	ahd_outb(ahd, QNEXTPTR,
-		 offsetof(struct hardware_scb, next_hscb_busaddr));
-	ahd_outb(ahd, ABRTBITPTR, MK_MESSAGE_BIT_OFFSET);
-	ahd_outb(ahd, ABRTBYTEPTR, offsetof(struct hardware_scb, control));
-	if ((ahd->bugs & AHD_PKT_LUN_BUG) != 0) {
-		ahd_outb(ahd, LUNLEN,
-			 sizeof(ahd->next_queued_hscb->pkt_long_lun) - 1);
-	} else {
-		ahd_outb(ahd, LUNLEN, sizeof(ahd->next_queued_hscb->lun) - 1);
-	}
-	ahd_outb(ahd, CDBLIMIT, SCB_CDB_LEN_PTR - 1);
-	ahd_outb(ahd, MAXCMD, 0xFF);
-	ahd_outb(ahd, SCBAUTOPTR,
-		 AUSCBPTR_EN | offsetof(struct hardware_scb, tag));
-
-	/* We haven't been enabled for target mode yet. */
-	ahd_outb(ahd, MULTARGID, 0);
-	ahd_outb(ahd, MULTARGID + 1, 0);
-
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-	/* Initialize the negotiation table. */
-	if ((ahd->features & AHD_NEW_IOCELL_OPTS) == 0) {
-		/*
-		 * Clear the spare bytes in the neg table to avoid
-		 * spurious parity errors.
-		 */
-		for (target = 0; target < AHD_NUM_TARGETS; target++) {
-			ahd_outb(ahd, NEGOADDR, target);
-			ahd_outb(ahd, ANNEXCOL, AHD_ANNEXCOL_PER_DEV0);
-			for (i = 0; i < AHD_NUM_PER_DEV_ANNEXCOLS; i++)
-				ahd_outb(ahd, ANNEXDAT, 0);
-		}
-	}
-	for (target = 0; target < AHD_NUM_TARGETS; target++) {
-		struct	 ahd_devinfo devinfo;
-		struct	 ahd_initiator_tinfo *tinfo;
-		struct	 ahd_tmode_tstate *tstate;
-
-		tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
-					    target, &tstate);
-		ahd_compile_devinfo(&devinfo, ahd->our_id,
-				    target, CAM_LUN_WILDCARD,
-				    'A', ROLE_INITIATOR);
-		ahd_update_neg_table(ahd, &devinfo, &tinfo->curr);
-	}
-
-	ahd_outb(ahd, CLRSINT3, NTRAMPERR|OSRAMPERR);
-	ahd_outb(ahd, CLRINT, CLRSCSIINT);
-
-	/*
-	 * Always enable abort on incoming L_Qs if this feature is
-	 * supported.  We use this to catch invalid SCB references.
-	 */
-	if ((ahd->bugs & AHD_ABORT_LQI_BUG) == 0)
-		ahd_outb(ahd, LQCTL1, ABORTPENDING);
-	else
-		ahd_outb(ahd, LQCTL1, 0);
-
-	/* All of our queues are empty */
-	ahd->qoutfifonext = 0;
-	ahd->qoutfifonext_valid_tag = QOUTFIFO_ENTRY_VALID_LE;
-	ahd_outb(ahd, QOUTFIFO_ENTRY_VALID_TAG, QOUTFIFO_ENTRY_VALID >> 8);
-	for (i = 0; i < AHD_QOUT_SIZE; i++)
-		ahd->qoutfifo[i] = 0;
-	ahd_sync_qoutfifo(ahd, BUS_DMASYNC_PREREAD);
-
-	ahd->qinfifonext = 0;
-	for (i = 0; i < AHD_QIN_SIZE; i++)
-		ahd->qinfifo[i] = SCB_LIST_NULL;
-
-	if ((ahd->features & AHD_TARGETMODE) != 0) {
-		/* All target command blocks start out invalid. */
-		for (i = 0; i < AHD_TMODE_CMDS; i++)
-			ahd->targetcmds[i].cmd_valid = 0;
-		ahd_sync_tqinfifo(ahd, BUS_DMASYNC_PREREAD);
-		ahd->tqinfifonext = 1;
-		ahd_outb(ahd, KERNEL_TQINPOS, ahd->tqinfifonext - 1);
-		ahd_outb(ahd, TQINPOS, ahd->tqinfifonext);
-	}
-
-	/* Initialize Scratch Ram. */
-	ahd_outb(ahd, SEQ_FLAGS, 0);
-	ahd_outb(ahd, SEQ_FLAGS2, 0);
-
-	/* We don't have any waiting selections */
-	ahd_outw(ahd, WAITING_TID_HEAD, SCB_LIST_NULL);
-	ahd_outw(ahd, WAITING_TID_TAIL, SCB_LIST_NULL);
-	for (i = 0; i < AHD_NUM_TARGETS; i++)
-		ahd_outw(ahd, WAITING_SCB_TAILS + (2 * i), SCB_LIST_NULL);
-
-	/*
-	 * Nobody is waiting to be DMAed into the QOUTFIFO.
-	 */
-	ahd_outw(ahd, COMPLETE_SCB_HEAD, SCB_LIST_NULL);
-	ahd_outw(ahd, COMPLETE_SCB_DMAINPROG_HEAD, SCB_LIST_NULL);
-	ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, SCB_LIST_NULL);
-
-	/*
-	 * The Freeze Count is 0.
-	 */
-	ahd_outw(ahd, QFREEZE_COUNT, 0);
-
-	/*
-	 * Tell the sequencer where it can find our arrays in memory.
-	 */
-	busaddr = ahd->shared_data_busaddr;
-	ahd_outb(ahd, SHARED_DATA_ADDR, busaddr & 0xFF);
-	ahd_outb(ahd, SHARED_DATA_ADDR + 1, (busaddr >> 8) & 0xFF);
-	ahd_outb(ahd, SHARED_DATA_ADDR + 2, (busaddr >> 16) & 0xFF);
-	ahd_outb(ahd, SHARED_DATA_ADDR + 3, (busaddr >> 24) & 0xFF);
-	ahd_outb(ahd, QOUTFIFO_NEXT_ADDR, busaddr & 0xFF);
-	ahd_outb(ahd, QOUTFIFO_NEXT_ADDR + 1, (busaddr >> 8) & 0xFF);
-	ahd_outb(ahd, QOUTFIFO_NEXT_ADDR + 2, (busaddr >> 16) & 0xFF);
-	ahd_outb(ahd, QOUTFIFO_NEXT_ADDR + 3, (busaddr >> 24) & 0xFF);
-
-	/*
-	 * Setup the allowed SCSI Sequences based on operational mode.
-	 * If we are a target, we'll enable select in operations once
-	 * we've had a lun enabled.
-	 */
-	scsiseq_template = ENAUTOATNP;
-	if ((ahd->flags & AHD_INITIATORROLE) != 0)
-		scsiseq_template |= ENRSELI;
-	ahd_outb(ahd, SCSISEQ_TEMPLATE, scsiseq_template);
-
-	/* There are no busy SCBs yet. */
-	for (target = 0; target < AHD_NUM_TARGETS; target++) {
-		int lun;
-
-		for (lun = 0; lun < AHD_NUM_LUNS_NONPKT; lun++)
-			ahd_unbusy_tcl(ahd, BUILD_TCL_RAW(target, 'A', lun));
-	}
-
-	/*
-	 * Initialize the group code to command length table.
-	 * Vendor Unique codes are set to 0 so we only capture
-	 * the first byte of the cdb.  These can be overridden
-	 * when target mode is enabled.
-	 */
-	ahd_outb(ahd, CMDSIZE_TABLE, 5);
-	ahd_outb(ahd, CMDSIZE_TABLE + 1, 9);
-	ahd_outb(ahd, CMDSIZE_TABLE + 2, 9);
-	ahd_outb(ahd, CMDSIZE_TABLE + 3, 0);
-	ahd_outb(ahd, CMDSIZE_TABLE + 4, 15);
-	ahd_outb(ahd, CMDSIZE_TABLE + 5, 11);
-	ahd_outb(ahd, CMDSIZE_TABLE + 6, 0);
-	ahd_outb(ahd, CMDSIZE_TABLE + 7, 0);
-		
-	/* Tell the sequencer of our initial queue positions */
-	ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
-	ahd_outb(ahd, QOFF_CTLSTA, SCB_QSIZE_512);
-	ahd->qinfifonext = 0;
-	ahd_set_hnscb_qoff(ahd, ahd->qinfifonext);
-	ahd_set_hescb_qoff(ahd, 0);
-	ahd_set_snscb_qoff(ahd, 0);
-	ahd_set_sescb_qoff(ahd, 0);
-	ahd_set_sdscb_qoff(ahd, 0);
-
-	/*
-	 * Tell the sequencer which SCB will be the next one it receives.
-	 */
-	busaddr = ahd_le32toh(ahd->next_queued_hscb->hscb_busaddr);
-	ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 0, busaddr & 0xFF);
-	ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 1, (busaddr >> 8) & 0xFF);
-	ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 2, (busaddr >> 16) & 0xFF);
-	ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 3, (busaddr >> 24) & 0xFF);
-
-	/*
-	 * Default to coalessing disabled.
-	 */
-	ahd_outw(ahd, INT_COALESSING_CMDCOUNT, 0);
-	ahd_outw(ahd, CMDS_PENDING, 0);
-	ahd_update_coalessing_values(ahd, ahd->int_coalessing_timer,
-				     ahd->int_coalessing_maxcmds,
-				     ahd->int_coalessing_mincmds);
-	ahd_enable_coalessing(ahd, FALSE);
-
-	ahd_loadseq(ahd);
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-}
-
-/*
- * Setup default device and controller settings.
- * This should only be called if our probe has
- * determined that no configuration data is available.
- */
-int
-ahd_default_config(struct ahd_softc *ahd)
-{
-	int	targ;
-
-	ahd->our_id = 7;
-
-	/*
-	 * Allocate a tstate to house information for our
-	 * initiator presence on the bus as well as the user
-	 * data for any target mode initiator.
-	 */
-	if (ahd_alloc_tstate(ahd, ahd->our_id, 'A') == NULL) {
-		printf("%s: unable to allocate ahd_tmode_tstate.  "
-		       "Failing attach\n", ahd_name(ahd));
-		return (ENOMEM);
-	}
-
-	for (targ = 0; targ < AHD_NUM_TARGETS; targ++) {
-		struct	 ahd_devinfo devinfo;
-		struct	 ahd_initiator_tinfo *tinfo;
-		struct	 ahd_tmode_tstate *tstate;
-		uint16_t target_mask;
-
-		tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
-					    targ, &tstate);
-		/*
-		 * We support SPC2 and SPI4.
-		 */
-		tinfo->user.protocol_version = 4;
-		tinfo->user.transport_version = 4;
-
-		target_mask = 0x01 << targ;
-		ahd->user_discenable |= target_mask;
-		tstate->discenable |= target_mask;
-		ahd->user_tagenable |= target_mask;
-#ifdef AHD_FORCE_160
-		tinfo->user.period = AHD_SYNCRATE_DT;
-#else
-		tinfo->user.period = AHD_SYNCRATE_160;
-#endif
-		tinfo->user.offset= ~0;
-		tinfo->user.ppr_options = MSG_EXT_PPR_RD_STRM
-					| MSG_EXT_PPR_WR_FLOW
-					| MSG_EXT_PPR_HOLD_MCS
-					| MSG_EXT_PPR_IU_REQ
-					| MSG_EXT_PPR_QAS_REQ
-					| MSG_EXT_PPR_DT_REQ;
-		if ((ahd->features & AHD_RTI) != 0)
-			tinfo->user.ppr_options |= MSG_EXT_PPR_RTI;
-
-		tinfo->user.width = MSG_EXT_WDTR_BUS_16_BIT;
-
-		/*
-		 * Start out Async/Narrow/Untagged and with
-		 * conservative protocol support.
-		 */
-		tinfo->goal.protocol_version = 2;
-		tinfo->goal.transport_version = 2;
-		tinfo->curr.protocol_version = 2;
-		tinfo->curr.transport_version = 2;
-		ahd_compile_devinfo(&devinfo, ahd->our_id,
-				    targ, CAM_LUN_WILDCARD,
-				    'A', ROLE_INITIATOR);
-		tstate->tagenable &= ~target_mask;
-		ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
-			      AHD_TRANS_CUR|AHD_TRANS_GOAL, /*paused*/TRUE);
-		ahd_set_syncrate(ahd, &devinfo, /*period*/0, /*offset*/0,
-				 /*ppr_options*/0, AHD_TRANS_CUR|AHD_TRANS_GOAL,
-				 /*paused*/TRUE);
-	}
-	return (0);
-}
-
-/*
- * Parse device configuration information.
- */
-int
-ahd_parse_cfgdata(struct ahd_softc *ahd, struct seeprom_config *sc)
-{
-	int targ;
-	int max_targ;
-
-	max_targ = sc->max_targets & CFMAXTARG;
-	ahd->our_id = sc->brtime_id & CFSCSIID;
-
-	/*
-	 * Allocate a tstate to house information for our
-	 * initiator presence on the bus as well as the user
-	 * data for any target mode initiator.
-	 */
-	if (ahd_alloc_tstate(ahd, ahd->our_id, 'A') == NULL) {
-		printf("%s: unable to allocate ahd_tmode_tstate.  "
-		       "Failing attach\n", ahd_name(ahd));
-		return (ENOMEM);
-	}
-
-	for (targ = 0; targ < max_targ; targ++) {
-		struct	 ahd_devinfo devinfo;
-		struct	 ahd_initiator_tinfo *tinfo;
-		struct	 ahd_transinfo *user_tinfo;
-		struct	 ahd_tmode_tstate *tstate;
-		uint16_t target_mask;
-
-		tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
-					    targ, &tstate);
-		user_tinfo = &tinfo->user;
-
-		/*
-		 * We support SPC2 and SPI4.
-		 */
-		tinfo->user.protocol_version = 4;
-		tinfo->user.transport_version = 4;
-
-		target_mask = 0x01 << targ;
-		ahd->user_discenable &= ~target_mask;
-		tstate->discenable &= ~target_mask;
-		ahd->user_tagenable &= ~target_mask;
-		if (sc->device_flags[targ] & CFDISC) {
-			tstate->discenable |= target_mask;
-			ahd->user_discenable |= target_mask;
-			ahd->user_tagenable |= target_mask;
-		} else {
-			/*
-			 * Cannot be packetized without disconnection.
-			 */
-			sc->device_flags[targ] &= ~CFPACKETIZED;
-		}
-
-		user_tinfo->ppr_options = 0;
-		user_tinfo->period = (sc->device_flags[targ] & CFXFER);
-		if (user_tinfo->period < CFXFER_ASYNC) {
-			if (user_tinfo->period <= AHD_PERIOD_10MHz)
-				user_tinfo->ppr_options |= MSG_EXT_PPR_DT_REQ;
-			user_tinfo->offset = MAX_OFFSET;
-		} else  {
-			user_tinfo->offset = 0;
-			user_tinfo->period = AHD_ASYNC_XFER_PERIOD;
-		}
-#ifdef AHD_FORCE_160
-		if (user_tinfo->period <= AHD_SYNCRATE_160)
-			user_tinfo->period = AHD_SYNCRATE_DT;
-#endif
-
-		if ((sc->device_flags[targ] & CFPACKETIZED) != 0) {
-			user_tinfo->ppr_options |= MSG_EXT_PPR_RD_STRM
-						|  MSG_EXT_PPR_WR_FLOW
-						|  MSG_EXT_PPR_HOLD_MCS
-						|  MSG_EXT_PPR_IU_REQ;
-			if ((ahd->features & AHD_RTI) != 0)
-				user_tinfo->ppr_options |= MSG_EXT_PPR_RTI;
-		}
-
-		if ((sc->device_flags[targ] & CFQAS) != 0)
-			user_tinfo->ppr_options |= MSG_EXT_PPR_QAS_REQ;
-
-		if ((sc->device_flags[targ] & CFWIDEB) != 0)
-			user_tinfo->width = MSG_EXT_WDTR_BUS_16_BIT;
-		else
-			user_tinfo->width = MSG_EXT_WDTR_BUS_8_BIT;
-#ifdef AHD_DEBUG
-		if ((ahd_debug & AHD_SHOW_MISC) != 0)
-			printf("(%d): %x:%x:%x:%x\n", targ, user_tinfo->width,
-			       user_tinfo->period, user_tinfo->offset,
-			       user_tinfo->ppr_options);
-#endif
-		/*
-		 * Start out Async/Narrow/Untagged and with
-		 * conservative protocol support.
-		 */
-		tstate->tagenable &= ~target_mask;
-		tinfo->goal.protocol_version = 2;
-		tinfo->goal.transport_version = 2;
-		tinfo->curr.protocol_version = 2;
-		tinfo->curr.transport_version = 2;
-		ahd_compile_devinfo(&devinfo, ahd->our_id,
-				    targ, CAM_LUN_WILDCARD,
-				    'A', ROLE_INITIATOR);
-		ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
-			      AHD_TRANS_CUR|AHD_TRANS_GOAL, /*paused*/TRUE);
-		ahd_set_syncrate(ahd, &devinfo, /*period*/0, /*offset*/0,
-				 /*ppr_options*/0, AHD_TRANS_CUR|AHD_TRANS_GOAL,
-				 /*paused*/TRUE);
-	}
-
-	ahd->flags &= ~AHD_SPCHK_ENB_A;
-	if (sc->bios_control & CFSPARITY)
-		ahd->flags |= AHD_SPCHK_ENB_A;
-
-	ahd->flags &= ~AHD_RESET_BUS_A;
-	if (sc->bios_control & CFRESETB)
-		ahd->flags |= AHD_RESET_BUS_A;
-
-	ahd->flags &= ~AHD_EXTENDED_TRANS_A;
-	if (sc->bios_control & CFEXTEND)
-		ahd->flags |= AHD_EXTENDED_TRANS_A;
-
-	ahd->flags &= ~AHD_BIOS_ENABLED;
-	if ((sc->bios_control & CFBIOSSTATE) == CFBS_ENABLED)
-		ahd->flags |= AHD_BIOS_ENABLED;
-
-	ahd->flags &= ~AHD_STPWLEVEL_A;
-	if ((sc->adapter_control & CFSTPWLEVEL) != 0)
-		ahd->flags |= AHD_STPWLEVEL_A;
-
-	return (0);
-}
-
-void
-ahd_intr_enable(struct ahd_softc *ahd, int enable)
-{
-	u_int hcntrl;
-
-	hcntrl = ahd_inb(ahd, HCNTRL);
-	hcntrl &= ~INTEN;
-	ahd->pause &= ~INTEN;
-	ahd->unpause &= ~INTEN;
-	if (enable) {
-		hcntrl |= INTEN;
-		ahd->pause |= INTEN;
-		ahd->unpause |= INTEN;
-	}
-	ahd_outb(ahd, HCNTRL, hcntrl);
-}
-
-void
-ahd_update_coalessing_values(struct ahd_softc *ahd, u_int timer, u_int maxcmds,
-			     u_int mincmds)
-{
-	if (timer > AHD_TIMER_MAX_US)
-		timer = AHD_TIMER_MAX_US;
-	ahd->int_coalessing_timer = timer;
-
-	if (maxcmds > AHD_INT_COALESSING_MAXCMDS_MAX)
-		maxcmds = AHD_INT_COALESSING_MAXCMDS_MAX;
-	if (mincmds > AHD_INT_COALESSING_MINCMDS_MAX)
-		mincmds = AHD_INT_COALESSING_MINCMDS_MAX;
-	ahd->int_coalessing_maxcmds = maxcmds;
-	ahd_outw(ahd, INT_COALESSING_TIMER, timer / AHD_TIMER_US_PER_TICK);
-	ahd_outb(ahd, INT_COALESSING_MAXCMDS, -maxcmds);
-	ahd_outb(ahd, INT_COALESSING_MINCMDS, -mincmds);
-}
-
-void
-ahd_enable_coalessing(struct ahd_softc *ahd, int enable)
-{
-
-	ahd->hs_mailbox &= ~ENINT_COALESS;
-	if (enable)
-		ahd->hs_mailbox |= ENINT_COALESS;
-	ahd_outb(ahd, HS_MAILBOX, ahd->hs_mailbox);
-	ahd_flush_device_writes(ahd);
-	ahd_run_qoutfifo(ahd);
-}
-
-/*
- * Ensure that the card is paused in a location
- * outside of all critical sections and that all
- * pending work is completed prior to returning.
- * This routine should only be called from outside
- * an interrupt context.
- */
-void
-ahd_pause_and_flushwork(struct ahd_softc *ahd)
-{
-	u_int intstat;
-	u_int maxloops;
-	int   paused;
-
-	maxloops = 1000;
-	ahd->flags |= AHD_ALL_INTERRUPTS;
-	intstat = 0;
-	paused = FALSE;
-	do {
-		struct scb *waiting_scb;
-
-		if (paused)
-			ahd_unpause(ahd);
-		ahd_intr(ahd);
-		ahd_pause(ahd);
-		paused = TRUE;
-		ahd_clear_critical_section(ahd);
-		if ((ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO)) == 0)
-			ahd_outb(ahd, SCSISEQ0,
-				 ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
-		/*
-		 * In the non-packetized case, the sequencer (for Rev A),
-		 * relies on ENSELO remaining set after SELDO.  The hardware
-		 * auto-clears ENSELO in the packetized case.
-		 */
-		waiting_scb = ahd_lookup_scb(ahd,
-					     ahd_inw(ahd, WAITING_TID_HEAD));
-		if (waiting_scb != NULL
-		 && (waiting_scb->flags & SCB_PACKETIZED) == 0
-		 && (ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO)) != 0)
-			ahd_outb(ahd, SCSISEQ0,
-				 ahd_inb(ahd, SCSISEQ0) | ENSELO);
-
-		if (intstat == 0xFF && (ahd->features & AHD_REMOVABLE) != 0)
-			break;
-	} while (--maxloops
-	      && (((intstat = ahd_inb(ahd, INTSTAT)) & INT_PEND) != 0
-	       || (ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO))));
-	if (maxloops == 0) {
-		printf("Infinite interrupt loop, INTSTAT = %x",
-		      ahd_inb(ahd, INTSTAT));
-	}
-
-	ahd_flush_qoutfifo(ahd);
-
-	ahd_platform_flushwork(ahd);
-	ahd->flags &= ~AHD_ALL_INTERRUPTS;
-}
-
-int
-ahd_suspend(struct ahd_softc *ahd)
-{
-#if 0
-	uint8_t *ptr;
-	int	 i;
-
-	ahd_pause_and_flushwork(ahd);
-
-	if (LIST_FIRST(&ahd->pending_scbs) != NULL)
-		return (EBUSY);
-
-#if AHD_TARGET_MODE
-	/*
-	 * XXX What about ATIOs that have not yet been serviced?
-	 * Perhaps we should just refuse to be suspended if we
-	 * are acting in a target role.
-	 */
-	if (ahd->pending_device != NULL)
-		return (EBUSY);
-#endif
-
-	/* Save volatile registers */
-	ahd->suspend_state.channel[0].scsiseq = ahd_inb(ahd, SCSISEQ0);
-	ahd->suspend_state.channel[0].sxfrctl0 = ahd_inb(ahd, SXFRCTL0);
-	ahd->suspend_state.channel[0].sxfrctl1 = ahd_inb(ahd, SXFRCTL1);
-	ahd->suspend_state.channel[0].simode0 = ahd_inb(ahd, SIMODE0);
-	ahd->suspend_state.channel[0].simode1 = ahd_inb(ahd, SIMODE1);
-	ahd->suspend_state.channel[0].seltimer = ahd_inb(ahd, SELTIMER);
-	ahd->suspend_state.channel[0].seqctl = ahd_inb(ahd, SEQCTL0);
-	ahd->suspend_state.dscommand0 = ahd_inb(ahd, DSCOMMAND0);
-	ahd->suspend_state.dspcistatus = ahd_inb(ahd, DSPCISTATUS);
-
-	if ((ahd->features & AHD_DT) != 0) {
-		u_int sfunct;
-
-		sfunct = ahd_inb(ahd, SFUNCT) & ~ALT_MODE;
-		ahd_outb(ahd, SFUNCT, sfunct | ALT_MODE);
-		ahd->suspend_state.optionmode = ahd_inb(ahd, OPTIONMODE);
-		ahd_outb(ahd, SFUNCT, sfunct);
-		ahd->suspend_state.crccontrol1 = ahd_inb(ahd, CRCCONTROL1);
-	}
-
-	if ((ahd->features & AHD_MULTI_FUNC) != 0)
-		ahd->suspend_state.scbbaddr = ahd_inb(ahd, SCBBADDR);
-
-	if ((ahd->features & AHD_ULTRA2) != 0)
-		ahd->suspend_state.dff_thrsh = ahd_inb(ahd, DFF_THRSH);
-
-	ptr = ahd->suspend_state.scratch_ram;
-	for (i = 0; i < 64; i++)
-		*ptr++ = ahd_inb(ahd, SRAM_BASE + i);
-
-	if ((ahd->features & AHD_MORE_SRAM) != 0) {
-		for (i = 0; i < 16; i++)
-			*ptr++ = ahd_inb(ahd, TARG_OFFSET + i);
-	}
-
-	ptr = ahd->suspend_state.btt;
-	for (i = 0;i < AHD_NUM_TARGETS; i++) {
-		int j;
-
-		for (j = 0;j < AHD_NUM_LUNS_NONPKT; j++) {
-			u_int tcl;
-
-			tcl = BUILD_TCL_RAW(i, 'A', j);
-			*ptr = ahd_find_busy_tcl(ahd, tcl);
-		}
-	}
-	ahd_shutdown(ahd);
-#endif
-	return (0);
-}
-
-int
-ahd_resume(struct ahd_softc *ahd)
-{
-#if 0
-	uint8_t *ptr;
-	int	 i;
-
-	ahd_reset(ahd);
-
-	ahd_build_free_scb_list(ahd);
-
-	/* Restore volatile registers */
-	ahd_outb(ahd, SCSISEQ0, ahd->suspend_state.channel[0].scsiseq);
-	ahd_outb(ahd, SXFRCTL0, ahd->suspend_state.channel[0].sxfrctl0);
-	ahd_outb(ahd, SXFRCTL1, ahd->suspend_state.channel[0].sxfrctl1);
-	ahd_outb(ahd, SIMODE0, ahd->suspend_state.channel[0].simode0);
-	ahd_outb(ahd, SIMODE1, ahd->suspend_state.channel[0].simode1);
-	ahd_outb(ahd, SELTIMER, ahd->suspend_state.channel[0].seltimer);
-	ahd_outb(ahd, SEQCTL0, ahd->suspend_state.channel[0].seqctl);
-	if ((ahd->features & AHD_ULTRA2) != 0)
-		ahd_outb(ahd, SCSIID_ULTRA2, ahd->our_id);
-	else
-		ahd_outb(ahd, SCSIID, ahd->our_id);
-
-	ahd_outb(ahd, DSCOMMAND0, ahd->suspend_state.dscommand0);
-	ahd_outb(ahd, DSPCISTATUS, ahd->suspend_state.dspcistatus);
-
-	if ((ahd->features & AHD_DT) != 0) {
-		u_int sfunct;
-
-		sfunct = ahd_inb(ahd, SFUNCT) & ~ALT_MODE;
-		ahd_outb(ahd, SFUNCT, sfunct | ALT_MODE);
-		ahd_outb(ahd, OPTIONMODE, ahd->suspend_state.optionmode);
-		ahd_outb(ahd, SFUNCT, sfunct);
-		ahd_outb(ahd, CRCCONTROL1, ahd->suspend_state.crccontrol1);
-	}
-
-	if ((ahd->features & AHD_MULTI_FUNC) != 0)
-		ahd_outb(ahd, SCBBADDR, ahd->suspend_state.scbbaddr);
-
-	if ((ahd->features & AHD_ULTRA2) != 0)
-		ahd_outb(ahd, DFF_THRSH, ahd->suspend_state.dff_thrsh);
-
-	ptr = ahd->suspend_state.scratch_ram;
-	for (i = 0; i < 64; i++)
-		ahd_outb(ahd, SRAM_BASE + i, *ptr++);
-
-	if ((ahd->features & AHD_MORE_SRAM) != 0) {
-		for (i = 0; i < 16; i++)
-			ahd_outb(ahd, TARG_OFFSET + i, *ptr++);
-	}
-
-	ptr = ahd->suspend_state.btt;
-	for (i = 0;i < AHD_NUM_TARGETS; i++) {
-		int j;
-
-		for (j = 0;j < AHD_NUM_LUNS; j++) {
-			u_int tcl;
-
-			tcl = BUILD_TCL(i << 4, j);
-			ahd_busy_tcl(ahd, tcl, *ptr);
-		}
-	}
-#endif
-	return (0);
-}
-
-/************************** Busy Target Table *********************************/
-/*
- * Set SCBPTR to the SCB that contains the busy
- * table entry for TCL.  Return the offset into
- * the SCB that contains the entry for TCL.
- * saved_scbid is dereferenced and set to the
- * scbid that should be restored once manipualtion
- * of the TCL entry is complete.
- */
-static __inline u_int
-ahd_index_busy_tcl(struct ahd_softc *ahd, u_int *saved_scbid, u_int tcl)
-{
-	/*
-	 * Index to the SCB that contains the busy entry.
-	 */
-	AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
-	*saved_scbid = ahd_get_scbptr(ahd);
-	ahd_set_scbptr(ahd, TCL_LUN(tcl)
-		     | ((TCL_TARGET_OFFSET(tcl) & 0xC) << 4));
-
-	/*
-	 * And now calculate the SCB offset to the entry.
-	 * Each entry is 2 bytes wide, hence the
-	 * multiplication by 2.
-	 */
-	return (((TCL_TARGET_OFFSET(tcl) & 0x3) << 1) + SCB_DISCONNECTED_LISTS);
-}
-
-/*
- * Return the untagged transaction id for a given target/channel lun.
- * Optionally, clear the entry.
- */
-u_int
-ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl)
-{
-	u_int scbid;
-	u_int scb_offset;
-	u_int saved_scbptr;
-		
-	scb_offset = ahd_index_busy_tcl(ahd, &saved_scbptr, tcl);
-	scbid = ahd_inw_scbram(ahd, scb_offset);
-	ahd_set_scbptr(ahd, saved_scbptr);
-	return (scbid);
-}
-
-void
-ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl, u_int scbid)
-{
-	u_int scb_offset;
-	u_int saved_scbptr;
-		
-	scb_offset = ahd_index_busy_tcl(ahd, &saved_scbptr, tcl);
-	ahd_outw(ahd, scb_offset, scbid);
-	ahd_set_scbptr(ahd, saved_scbptr);
-}
-
-/************************** SCB and SCB queue management **********************/
-int
-ahd_match_scb(struct ahd_softc *ahd, struct scb *scb, int target,
-	      char channel, int lun, u_int tag, role_t role)
-{
-	int targ = SCB_GET_TARGET(ahd, scb);
-	char chan = SCB_GET_CHANNEL(ahd, scb);
-	int slun = SCB_GET_LUN(scb);
-	int match;
-
-	match = ((chan == channel) || (channel == ALL_CHANNELS));
-	if (match != 0)
-		match = ((targ == target) || (target == CAM_TARGET_WILDCARD));
-	if (match != 0)
-		match = ((lun == slun) || (lun == CAM_LUN_WILDCARD));
-	if (match != 0) {
-#if AHD_TARGET_MODE
-		int group;
-
-		group = XPT_FC_GROUP(scb->io_ctx->ccb_h.func_code);
-		if (role == ROLE_INITIATOR) {
-			match = (group != XPT_FC_GROUP_TMODE)
-			      && ((tag == SCB_GET_TAG(scb))
-			       || (tag == SCB_LIST_NULL));
-		} else if (role == ROLE_TARGET) {
-			match = (group == XPT_FC_GROUP_TMODE)
-			      && ((tag == scb->io_ctx->csio.tag_id)
-			       || (tag == SCB_LIST_NULL));
-		}
-#else /* !AHD_TARGET_MODE */
-		match = ((tag == SCB_GET_TAG(scb)) || (tag == SCB_LIST_NULL));
-#endif /* AHD_TARGET_MODE */
-	}
-
-	return match;
-}
-
-void
-ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb)
-{
-	int	target;
-	char	channel;
-	int	lun;
-
-	target = SCB_GET_TARGET(ahd, scb);
-	lun = SCB_GET_LUN(scb);
-	channel = SCB_GET_CHANNEL(ahd, scb);
-	
-	ahd_search_qinfifo(ahd, target, channel, lun,
-			   /*tag*/SCB_LIST_NULL, ROLE_UNKNOWN,
-			   CAM_REQUEUE_REQ, SEARCH_COMPLETE);
-
-	ahd_platform_freeze_devq(ahd, scb);
-}
-
-void
-ahd_qinfifo_requeue_tail(struct ahd_softc *ahd, struct scb *scb)
-{
-	struct scb	*prev_scb;
-	ahd_mode_state	 saved_modes;
-
-	saved_modes = ahd_save_modes(ahd);
-	ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
-	prev_scb = NULL;
-	if (ahd_qinfifo_count(ahd) != 0) {
-		u_int prev_tag;
-		u_int prev_pos;
-
-		prev_pos = AHD_QIN_WRAP(ahd->qinfifonext - 1);
-		prev_tag = ahd->qinfifo[prev_pos];
-		prev_scb = ahd_lookup_scb(ahd, prev_tag);
-	}
-	ahd_qinfifo_requeue(ahd, prev_scb, scb);
-	ahd_set_hnscb_qoff(ahd, ahd->qinfifonext);
-	ahd_restore_modes(ahd, saved_modes);
-}
-
-static void
-ahd_qinfifo_requeue(struct ahd_softc *ahd, struct scb *prev_scb,
-		    struct scb *scb)
-{
-	if (prev_scb == NULL) {
-		uint32_t busaddr;
-
-		busaddr = ahd_le32toh(scb->hscb->hscb_busaddr);
-		ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 0, busaddr & 0xFF);
-		ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 1, (busaddr >> 8) & 0xFF);
-		ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 2, (busaddr >> 16) & 0xFF);
-		ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 3, (busaddr >> 24) & 0xFF);
-	} else {
-		prev_scb->hscb->next_hscb_busaddr = scb->hscb->hscb_busaddr;
-		ahd_sync_scb(ahd, prev_scb, 
-			     BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
-	}
-	ahd->qinfifo[AHD_QIN_WRAP(ahd->qinfifonext)] = SCB_GET_TAG(scb);
-	ahd->qinfifonext++;
-	scb->hscb->next_hscb_busaddr = ahd->next_queued_hscb->hscb_busaddr;
-	ahd_sync_scb(ahd, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
-}
-
-static int
-ahd_qinfifo_count(struct ahd_softc *ahd)
-{
-	u_int qinpos;
-	u_int wrap_qinpos;
-	u_int wrap_qinfifonext;
-
-	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
-	qinpos = ahd_get_snscb_qoff(ahd);
-	wrap_qinpos = AHD_QIN_WRAP(qinpos);
-	wrap_qinfifonext = AHD_QIN_WRAP(ahd->qinfifonext);
-	if (wrap_qinfifonext >= wrap_qinpos)
-		return (wrap_qinfifonext - wrap_qinpos);
-	else
-		return (wrap_qinfifonext
-		      + NUM_ELEMENTS(ahd->qinfifo) - wrap_qinpos);
-}
-
-void
-ahd_reset_cmds_pending(struct ahd_softc *ahd)
-{
-	struct		scb *scb;
-	ahd_mode_state	saved_modes;
-	u_int		pending_cmds;
-
-	saved_modes = ahd_save_modes(ahd);
-	ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
-
-	/*
-	 * Don't count any commands as outstanding that the
-	 * sequencer has already marked for completion.
-	 */
-	ahd_flush_qoutfifo(ahd);
-
-	pending_cmds = 0;
-	LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) {
-		pending_cmds++;
-	}
-	ahd_outw(ahd, CMDS_PENDING, pending_cmds - ahd_qinfifo_count(ahd));
-	ahd_restore_modes(ahd, saved_modes);
-	ahd->flags &= ~AHD_UPDATE_PEND_CMDS;
-}
-
-int
-ahd_search_qinfifo(struct ahd_softc *ahd, int target, char channel,
-		   int lun, u_int tag, role_t role, uint32_t status,
-		   ahd_search_action action)
-{
-	struct scb	*scb;
-	struct scb	*prev_scb;
-	ahd_mode_state	 saved_modes;
-	u_int		 qinstart;
-	u_int		 qinpos;
-	u_int		 qintail;
-	u_int		 tid_next;
-	u_int		 tid_prev;
-	u_int		 scbid;
-	u_int		 savedscbptr;
-	uint32_t	 busaddr;
-	int		 found;
-	int		 targets;
-
-	/* Must be in CCHAN mode */
-	saved_modes = ahd_save_modes(ahd);
-	ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
-
-	/*
-	 * Halt any pending SCB DMA.  The sequencer will reinitiate
-	 * this dma if the qinfifo is not empty once we unpause.
-	 */
-	if ((ahd_inb(ahd, CCSCBCTL) & (CCARREN|CCSCBEN|CCSCBDIR))
-	 == (CCARREN|CCSCBEN|CCSCBDIR)) {
-		ahd_outb(ahd, CCSCBCTL,
-			 ahd_inb(ahd, CCSCBCTL) & ~(CCARREN|CCSCBEN));
-		while ((ahd_inb(ahd, CCSCBCTL) & (CCARREN|CCSCBEN)) != 0)
-			;
-	}
-	/* Determine sequencer's position in the qinfifo. */
-	qintail = AHD_QIN_WRAP(ahd->qinfifonext);
-	qinstart = ahd_get_snscb_qoff(ahd);
-	qinpos = AHD_QIN_WRAP(qinstart);
-	found = 0;
-	prev_scb = NULL;
-
-	if (action == SEARCH_PRINT) {
-		printf("qinstart = %d qinfifonext = %d\nQINFIFO:",
-		       qinstart, ahd->qinfifonext);
-	}
-
-	/*
-	 * Start with an empty queue.  Entries that are not chosen
-	 * for removal will be re-added to the queue as we go.
-	 */
-	ahd->qinfifonext = qinstart;
-	busaddr = ahd_le32toh(ahd->next_queued_hscb->hscb_busaddr);
-	ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 0, busaddr & 0xFF);
-	ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 1, (busaddr >> 8) & 0xFF);
-	ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 2, (busaddr >> 16) & 0xFF);
-	ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 3, (busaddr >> 24) & 0xFF);
-
-	while (qinpos != qintail) {
-		scb = ahd_lookup_scb(ahd, ahd->qinfifo[qinpos]);
-		if (scb == NULL) {
-			printf("qinpos = %d, SCB index = %d\n",
-				qinpos, ahd->qinfifo[qinpos]);
-			panic("Loop 1\n");
-		}
-
-		if (ahd_match_scb(ahd, scb, target, channel, lun, tag, role)) {
-			/*
-			 * We found an scb that needs to be acted on.
-			 */
-			found++;
-			switch (action) {
-			case SEARCH_COMPLETE:
-			{
-				cam_status ostat;
-				cam_status cstat;
-
-				ostat = ahd_get_transaction_status(scb);
-				if (ostat == CAM_REQ_INPROG)
-					ahd_set_transaction_status(scb,
-								   status);
-				cstat = ahd_get_transaction_status(scb);
-				if (cstat != CAM_REQ_CMP)
-					ahd_freeze_scb(scb);
-				if ((scb->flags & SCB_ACTIVE) == 0)
-					printf("Inactive SCB in qinfifo\n");
-				ahd_done(ahd, scb);
-
-				/* FALLTHROUGH */
-			}
-			case SEARCH_REMOVE:
-				break;
-			case SEARCH_PRINT:
-				printf(" 0x%x", ahd->qinfifo[qinpos]);
-				/* FALLTHROUGH */
-			case SEARCH_COUNT:
-				ahd_qinfifo_requeue(ahd, prev_scb, scb);
-				prev_scb = scb;
-				break;
-			}
-		} else {
-			ahd_qinfifo_requeue(ahd, prev_scb, scb);
-			prev_scb = scb;
-		}
-		qinpos = AHD_QIN_WRAP(qinpos+1);
-	}
-
-	ahd_set_hnscb_qoff(ahd, ahd->qinfifonext);
-
-	if (action == SEARCH_PRINT)
-		printf("\nWAITING_TID_QUEUES:\n");
-
-	/*
-	 * Search waiting for selection lists.  We traverse the
-	 * list of "their ids" waiting for selection and, if
-	 * appropriate, traverse the SCBs of each "their id"
-	 * looking for matches.
-	 */
-	savedscbptr = ahd_get_scbptr(ahd);
-	tid_next = ahd_inw(ahd, WAITING_TID_HEAD);
-	tid_prev = SCB_LIST_NULL;
-	targets = 0;
-	for (scbid = tid_next; !SCBID_IS_NULL(scbid); scbid = tid_next) {
-		u_int tid_head;
-
-		/*
-		 * We limit based on the number of SCBs since
-		 * MK_MESSAGE SCBs are not in the per-tid lists.
-		 */
-		targets++;
-		if (targets > AHD_SCB_MAX) {
-			panic("TID LIST LOOP");
-		}
-		if (scbid >= ahd->scb_data.numscbs) {
-			printf("%s: Waiting TID List inconsistency. "
-			       "SCB index == 0x%x, yet numscbs == 0x%x.",
-			       ahd_name(ahd), scbid, ahd->scb_data.numscbs);
-			ahd_dump_card_state(ahd);
-			panic("for safety");
-		}
-		scb = ahd_lookup_scb(ahd, scbid);
-		if (scb == NULL) {
-			printf("%s: SCB = 0x%x Not Active!\n",
-			       ahd_name(ahd), scbid);
-			panic("Waiting TID List traversal\n");
-		}
-		ahd_set_scbptr(ahd, scbid);
-		tid_next = ahd_inw_scbram(ahd, SCB_NEXT2);
-		if (ahd_match_scb(ahd, scb, target, channel, CAM_LUN_WILDCARD,
-				  SCB_LIST_NULL, ROLE_UNKNOWN) == 0) {
-			tid_prev = scbid;
-			continue;
-		}
-
-		/*
-		 * We found a list of scbs that needs to be searched.
-		 */
-		if (action == SEARCH_PRINT)
-			printf("       %d ( ", SCB_GET_TARGET(ahd, scb));
-		tid_head = scbid;
-		found += ahd_search_scb_list(ahd, target, channel,
-					     lun, tag, role, status,
-					     action, &tid_head,
-					     SCB_GET_TARGET(ahd, scb));
-		if (tid_head != scbid)
-			ahd_stitch_tid_list(ahd, tid_prev, tid_head, tid_next);
-		if (!SCBID_IS_NULL(tid_head))
-			tid_prev = tid_head;
-		if (action == SEARCH_PRINT)
-			printf(")\n");
-	}
-	ahd_set_scbptr(ahd, savedscbptr);
-	ahd_restore_modes(ahd, saved_modes);
-	return (found);
-}
-
-static int
-ahd_search_scb_list(struct ahd_softc *ahd, int target, char channel,
-		    int lun, u_int tag, role_t role, uint32_t status,
-		    ahd_search_action action, u_int *list_head, u_int tid)
-{
-	struct	scb *scb;
-	u_int	scbid;
-	u_int	next;
-	u_int	prev;
-	int	found;
-
-	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
-	found = 0;
-	prev = SCB_LIST_NULL;
-	next = *list_head;
-	for (scbid = next; !SCBID_IS_NULL(scbid); scbid = next) {
-		if (scbid >= ahd->scb_data.numscbs) {
-			printf("%s:SCB List inconsistency. "
-			       "SCB == 0x%x, yet numscbs == 0x%x.",
-			       ahd_name(ahd), scbid, ahd->scb_data.numscbs);
-			ahd_dump_card_state(ahd);
-			panic("for safety");
-		}
-		scb = ahd_lookup_scb(ahd, scbid);
-		if (scb == NULL) {
-			printf("%s: SCB = %d Not Active!\n",
-			       ahd_name(ahd), scbid);
-			panic("Waiting List traversal\n");
-		}
-		ahd_set_scbptr(ahd, scbid);
-		next = ahd_inw_scbram(ahd, SCB_NEXT);
-		if (ahd_match_scb(ahd, scb, target, channel,
-				  lun, SCB_LIST_NULL, role) == 0) {
-			prev = scbid;
-			continue;
-		}
-		found++;
-		switch (action) {
-		case SEARCH_COMPLETE:
-		{
-			cam_status ostat;
-			cam_status cstat;
-
-			ostat = ahd_get_transaction_status(scb);
-			if (ostat == CAM_REQ_INPROG)
-				ahd_set_transaction_status(scb, status);
-			cstat = ahd_get_transaction_status(scb);
-			if (cstat != CAM_REQ_CMP)
-				ahd_freeze_scb(scb);
-			if ((scb->flags & SCB_ACTIVE) == 0)
-				printf("Inactive SCB in Waiting List\n");
-			ahd_done(ahd, scb);
-			/* FALLTHROUGH */
-		}
-		case SEARCH_REMOVE:
-			ahd_rem_wscb(ahd, scbid, prev, next, tid);
-			if (prev == SCB_LIST_NULL)
-				*list_head = next;
-			break;
-		case SEARCH_PRINT:
-			printf("0x%x ", scbid);
-		case SEARCH_COUNT:
-			prev = scbid;
-			break;
-		}
-		if (found > AHD_SCB_MAX)
-			panic("SCB LIST LOOP");
-	}
-	if (action == SEARCH_COMPLETE
-	 || action == SEARCH_REMOVE)
-		ahd_outw(ahd, CMDS_PENDING, ahd_inw(ahd, CMDS_PENDING) - found);
-	return (found);
-}
-
-static void
-ahd_stitch_tid_list(struct ahd_softc *ahd, u_int tid_prev,
-		    u_int tid_cur, u_int tid_next)
-{
-	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
-
-	if (SCBID_IS_NULL(tid_cur)) {
-
-		/* Bypass current TID list */
-		if (SCBID_IS_NULL(tid_prev)) {
-			ahd_outw(ahd, WAITING_TID_HEAD, tid_next);
-		} else {
-			ahd_set_scbptr(ahd, tid_prev);
-			ahd_outw(ahd, SCB_NEXT2, tid_next);
-		}
-		if (SCBID_IS_NULL(tid_next))
-			ahd_outw(ahd, WAITING_TID_TAIL, tid_prev);
-	} else {
-
-		/* Stitch through tid_cur */
-		if (SCBID_IS_NULL(tid_prev)) {
-			ahd_outw(ahd, WAITING_TID_HEAD, tid_cur);
-		} else {
-			ahd_set_scbptr(ahd, tid_prev);
-			ahd_outw(ahd, SCB_NEXT2, tid_cur);
-		}
-		ahd_set_scbptr(ahd, tid_cur);
-		ahd_outw(ahd, SCB_NEXT2, tid_next);
-
-		if (SCBID_IS_NULL(tid_next))
-			ahd_outw(ahd, WAITING_TID_TAIL, tid_cur);
-	}
-}
-
-/*
- * Manipulate the waiting for selection list and return the
- * scb that follows the one that we remove.
- */
-static u_int
-ahd_rem_wscb(struct ahd_softc *ahd, u_int scbid,
-	     u_int prev, u_int next, u_int tid)
-{
-	u_int tail_offset;
-
-	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
-	if (!SCBID_IS_NULL(prev)) {
-		ahd_set_scbptr(ahd, prev);
-		ahd_outw(ahd, SCB_NEXT, next);
-	}
-
-	/*
-	 * SCBs that had MK_MESSAGE set in them will not
-	 * be queued to the per-target lists, so don't
-	 * blindly clear the tail pointer.
-	 */
-	tail_offset = WAITING_SCB_TAILS + (2 * tid);
-	if (SCBID_IS_NULL(next)
-	 && ahd_inw(ahd, tail_offset) == scbid)
-		ahd_outw(ahd, tail_offset, prev);
-	ahd_add_scb_to_free_list(ahd, scbid);
-	return (next);
-}
-
-/*
- * Add the SCB as selected by SCBPTR onto the on chip list of
- * free hardware SCBs.  This list is empty/unused if we are not
- * performing SCB paging.
- */
-static void
-ahd_add_scb_to_free_list(struct ahd_softc *ahd, u_int scbid)
-{
-/* XXX Need some other mechanism to designate "free". */
-	/*
-	 * Invalidate the tag so that our abort
-	 * routines don't think it's active.
-	ahd_outb(ahd, SCB_TAG, SCB_LIST_NULL);
-	 */
-}
-
-/******************************** Error Handling ******************************/
-/*
- * Abort all SCBs that match the given description (target/channel/lun/tag),
- * setting their status to the passed in status if the status has not already
- * been modified from CAM_REQ_INPROG.  This routine assumes that the sequencer
- * is paused before it is called.
- */
-int
-ahd_abort_scbs(struct ahd_softc *ahd, int target, char channel,
-	       int lun, u_int tag, role_t role, uint32_t status)
-{
-	struct		scb *scbp;
-	struct		scb *scbp_next;
-	u_int		active_scb;
-	u_int		i, j;
-	u_int		maxtarget;
-	u_int		minlun;
-	u_int		maxlun;
-	int		found;
-	ahd_mode_state	saved_modes;
-
-	/* restore these when we're done */
-	active_scb = ahd_get_scbptr(ahd);
-	saved_modes = ahd_save_modes(ahd);
-
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-	found = ahd_search_qinfifo(ahd, target, channel, lun, SCB_LIST_NULL,
-				   role, CAM_REQUEUE_REQ, SEARCH_COMPLETE);
-
-	/*
-	 * Clean out the busy target table for any untagged commands.
-	 */
-	i = 0;
-	maxtarget = 16;
-	if (target != CAM_TARGET_WILDCARD) {
-		i = target;
-		if (channel == 'B')
-			i += 8;
-		maxtarget = i + 1;
-	}
-
-	if (lun == CAM_LUN_WILDCARD) {
-		minlun = 0;
-		maxlun = AHD_NUM_LUNS_NONPKT;
-	} else if (lun >= AHD_NUM_LUNS_NONPKT) {
-		minlun = maxlun = 0;
-	} else {
-		minlun = lun;
-		maxlun = lun + 1;
-	}
-
-	if (role != ROLE_TARGET) {
-		for (;i < maxtarget; i++) {
-			for (j = minlun;j < maxlun; j++) {
-				u_int scbid;
-				u_int tcl;
-
-				tcl = BUILD_TCL_RAW(i, 'A', j);
-				scbid = ahd_find_busy_tcl(ahd, tcl);
-				scbp = ahd_lookup_scb(ahd, scbid);
-				if (scbp == NULL
-				 || ahd_match_scb(ahd, scbp, target, channel,
-						  lun, tag, role) == 0)
-					continue;
-				ahd_unbusy_tcl(ahd, BUILD_TCL_RAW(i, 'A', j));
-			}
-		}
-	}
-
-	/*
-	 * Don't abort commands that have already completed,
-	 * but haven't quite made it up to the host yet.
-	 */
-	ahd_flush_qoutfifo(ahd);
-
-	/*
-	 * Go through the pending CCB list and look for
-	 * commands for this target that are still active.
-	 * These are other tagged commands that were
-	 * disconnected when the reset occurred.
-	 */
-	scbp_next = LIST_FIRST(&ahd->pending_scbs);
-	while (scbp_next != NULL) {
-		scbp = scbp_next;
-		scbp_next = LIST_NEXT(scbp, pending_links);
-		if (ahd_match_scb(ahd, scbp, target, channel, lun, tag, role)) {
-			cam_status ostat;
-
-			ostat = ahd_get_transaction_status(scbp);
-			if (ostat == CAM_REQ_INPROG)
-				ahd_set_transaction_status(scbp, status);
-			if (ahd_get_transaction_status(scbp) != CAM_REQ_CMP)
-				ahd_freeze_scb(scbp);
-			if ((scbp->flags & SCB_ACTIVE) == 0)
-				printf("Inactive SCB on pending list\n");
-			ahd_done(ahd, scbp);
-			found++;
-		}
-	}
-	ahd_set_scbptr(ahd, active_scb);
-	ahd_restore_modes(ahd, saved_modes);
-	ahd_platform_abort_scbs(ahd, target, channel, lun, tag, role, status);
-	ahd->flags |= AHD_UPDATE_PEND_CMDS;
-	return found;
-}
-
-static void
-ahd_reset_current_bus(struct ahd_softc *ahd)
-{
-	uint8_t scsiseq;
-
-	AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
-	ahd_outb(ahd, SIMODE1, ahd_inb(ahd, SIMODE1) & ~ENSCSIRST);
-	scsiseq = ahd_inb(ahd, SCSISEQ0) & ~(ENSELO|ENARBO|SCSIRSTO);
-	ahd_outb(ahd, SCSISEQ0, scsiseq | SCSIRSTO);
-	ahd_delay(AHD_BUSRESET_DELAY);
-	/* Turn off the bus reset */
-	ahd_outb(ahd, SCSISEQ0, scsiseq);
-	if ((ahd->bugs & AHD_SCSIRST_BUG) != 0) {
-		/*
-		 * 2A Razor #474
-		 * Certain chip state is not cleared for
-		 * SCSI bus resets that we initiate, so
-		 * we must reset the chip.
-		 */
-		ahd_delay(AHD_BUSRESET_DELAY);
-		ahd_reset(ahd);
-		ahd_intr_enable(ahd, /*enable*/TRUE);
-		AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
-	}
-
-	ahd_clear_intstat(ahd);
-}
-
-int
-ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset)
-{
-	struct	ahd_devinfo devinfo;
-	u_int	initiator;
-	u_int	target;
-	u_int	max_scsiid;
-	int	found;
-	u_int	fifo;
-	u_int	next_fifo;
-
-	ahd->pending_device = NULL;
-
-	ahd_compile_devinfo(&devinfo,
-			    CAM_TARGET_WILDCARD,
-			    CAM_TARGET_WILDCARD,
-			    CAM_LUN_WILDCARD,
-			    channel, ROLE_UNKNOWN);
-	ahd_pause(ahd);
-
-	/* Make sure the sequencer is in a safe location. */
-	ahd_clear_critical_section(ahd);
-
-#if AHD_TARGET_MODE
-	if ((ahd->flags & AHD_TARGETROLE) != 0) {
-		ahd_run_tqinfifo(ahd, /*paused*/TRUE);
-	}
-#endif
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-
-	/*
-	 * Disable selections so no automatic hardware
-	 * functions will modify chip state.
-	 */
-	ahd_outb(ahd, SCSISEQ0, 0);
-	ahd_outb(ahd, SCSISEQ1, 0);
-
-	/*
-	 * Safely shut down our DMA engines.  Always start with
-	 * the FIFO that is not currently active (if any are
-	 * actively connected).
-	 */
-	next_fifo = fifo = ahd_inb(ahd, DFFSTAT) & CURRFIFO;
-	if (next_fifo > CURRFIFO_1)
-		/* If disconneced, arbitrarily start with FIFO1. */
-		next_fifo = fifo = 0;
-	do {
-		next_fifo ^= CURRFIFO_1;
-		ahd_set_modes(ahd, next_fifo, next_fifo);
-		ahd_outb(ahd, DFCNTRL,
-			 ahd_inb(ahd, DFCNTRL) & ~(SCSIEN|HDMAEN));
-		while ((ahd_inb(ahd, DFCNTRL) & HDMAENACK) != 0)
-			ahd_delay(10);
-		/*
-		 * Set CURRFIFO to the now inactive channel.
-		 */
-		ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-		ahd_outb(ahd, DFFSTAT, next_fifo);
-	} while (next_fifo != fifo);
-	/*
-	 * Reset the bus if we are initiating this reset
-	 */
-	ahd_clear_msg_state(ahd);
-	ahd_outb(ahd, SIMODE1,
-		 ahd_inb(ahd, SIMODE1) & ~(ENBUSFREE|ENSCSIRST|ENBUSFREE));
-	if (initiate_reset)
-		ahd_reset_current_bus(ahd);
-	ahd_clear_intstat(ahd);
-
-	/*
-	 * Clean up all the state information for the
-	 * pending transactions on this bus.
-	 */
-	found = ahd_abort_scbs(ahd, CAM_TARGET_WILDCARD, channel,
-			       CAM_LUN_WILDCARD, SCB_LIST_NULL,
-			       ROLE_UNKNOWN, CAM_SCSI_BUS_RESET);
-
-	/*
-	 * Cleanup anything left in the FIFOs.
-	 */
-	ahd_clear_fifo(ahd, 0);
-	ahd_clear_fifo(ahd, 1);
-
-	/*
-	 * Revert to async/narrow transfers until we renegotiate.
-	 */
-	max_scsiid = (ahd->features & AHD_WIDE) ? 15 : 7;
-	for (target = 0; target <= max_scsiid; target++) {
-
-		if (ahd->enabled_targets[target] == NULL)
-			continue;
-		for (initiator = 0; initiator <= max_scsiid; initiator++) {
-			struct ahd_devinfo devinfo;
-
-			ahd_compile_devinfo(&devinfo, target, initiator,
-					    CAM_LUN_WILDCARD,
-					    'A', ROLE_UNKNOWN);
-			ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
-				      AHD_TRANS_CUR, /*paused*/TRUE);
-			ahd_set_syncrate(ahd, &devinfo, /*period*/0,
-					 /*offset*/0, /*ppr_options*/0,
-					 AHD_TRANS_CUR, /*paused*/TRUE);
-		}
-	}
-
-#ifdef AHD_TARGET_MODE
-	max_scsiid = (ahd->features & AHD_WIDE) ? 15 : 7;
-
-	/*
-	 * Send an immediate notify ccb to all target more peripheral
-	 * drivers affected by this action.
-	 */
-	for (target = 0; target <= max_scsiid; target++) {
-		struct ahd_tmode_tstate* tstate;
-		u_int lun;
-
-		tstate = ahd->enabled_targets[target];
-		if (tstate == NULL)
-			continue;
-		for (lun = 0; lun < AHD_NUM_LUNS; lun++) {
-			struct ahd_tmode_lstate* lstate;
-
-			lstate = tstate->enabled_luns[lun];
-			if (lstate == NULL)
-				continue;
-
-			ahd_queue_lstate_event(ahd, lstate, CAM_TARGET_WILDCARD,
-					       EVENT_TYPE_BUS_RESET, /*arg*/0);
-			ahd_send_lstate_events(ahd, lstate);
-		}
-	}
-#endif
-	/* Notify the XPT that a bus reset occurred */
-	ahd_send_async(ahd, devinfo.channel, CAM_TARGET_WILDCARD,
-		       CAM_LUN_WILDCARD, AC_BUS_RESET, NULL);
-	ahd_restart(ahd);
-	/*
-	 * Freeze the SIMQ until our poller can determine that
-	 * the bus reset has really gone away.  We set the initial
-	 * timer to 0 to have the check performed as soon as possible
-	 * from the timer context.
-	 */
-	if ((ahd->flags & AHD_RESET_POLL_ACTIVE) == 0) {
-		ahd->flags |= AHD_RESET_POLL_ACTIVE;
-		ahd_freeze_simq(ahd);
-		ahd_timer_reset(&ahd->reset_timer, 0, ahd_reset_poll, ahd);
-	}
-	return (found);
-}
-
-
-#define AHD_RESET_POLL_US 1000
-static void
-ahd_reset_poll(void *arg)
-{
-	struct	ahd_softc *ahd;
-	u_int	scsiseq1;
-	u_long	l;
-	u_long	s;
-	
-	ahd_list_lock(&l);
-	ahd = ahd_find_softc((struct ahd_softc *)arg);
-	if (ahd == NULL) {
-		printf("ahd_reset_poll: Instance %p no longer exists\n", arg);
-		ahd_list_unlock(&l);
-		return;
-	}
-	ahd_lock(ahd, &s);
-	ahd_pause(ahd);
-	ahd_update_modes(ahd);
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-	ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI);
-	if ((ahd_inb(ahd, SSTAT1) & SCSIRSTI) != 0) {
-		ahd_timer_reset(&ahd->reset_timer, AHD_RESET_POLL_US,
-				ahd_reset_poll, ahd);
-		ahd_unpause(ahd);
-		ahd_unlock(ahd, &s);
-		ahd_list_unlock(&l);
-		return;
-	}
-
-	/* Reset is now low.  Complete chip reinitialization. */
-	ahd_outb(ahd, SIMODE1, ahd_inb(ahd, SIMODE1) | ENSCSIRST);
-	scsiseq1 = ahd_inb(ahd, SCSISEQ_TEMPLATE);
-	ahd_outb(ahd, SCSISEQ1, scsiseq1 & (ENSELI|ENRSELI|ENAUTOATNP));
-	ahd_unpause(ahd);
-	ahd->flags &= ~AHD_RESET_POLL_ACTIVE;
-	ahd_unlock(ahd, &s);
-	ahd_release_simq(ahd);
-	ahd_list_unlock(&l);
-}
-
-/**************************** Statistics Processing ***************************/
-static void
-ahd_stat_timer(void *arg)
-{
-	struct	ahd_softc *ahd;
-	u_long	l;
-	u_long	s;
-	int	enint_coal;
-	
-	ahd_list_lock(&l);
-	ahd = ahd_find_softc((struct ahd_softc *)arg);
-	if (ahd == NULL) {
-		printf("ahd_stat_timer: Instance %p no longer exists\n", arg);
-		ahd_list_unlock(&l);
-		return;
-	}
-	ahd_lock(ahd, &s);
-
-	enint_coal = ahd->hs_mailbox & ENINT_COALESS;
-	if (ahd->cmdcmplt_total > ahd->int_coalessing_threshold)
-		enint_coal |= ENINT_COALESS;
-	else if (ahd->cmdcmplt_total < ahd->int_coalessing_stop_threshold)
-		enint_coal &= ~ENINT_COALESS;
-
-	if (enint_coal != (ahd->hs_mailbox & ENINT_COALESS)) {
-		ahd_enable_coalessing(ahd, enint_coal);
-#ifdef AHD_DEBUG
-		if ((ahd_debug & AHD_SHOW_INT_COALESSING) != 0)
-			printf("%s: Interrupt coalessing "
-			       "now %sabled. Cmds %d\n",
-			       ahd_name(ahd),
-			       (enint_coal & ENINT_COALESS) ? "en" : "dis",
-			       ahd->cmdcmplt_total);
-#endif
-	}
-
-	ahd->cmdcmplt_bucket = (ahd->cmdcmplt_bucket+1) & (AHD_STAT_BUCKETS-1);
-	ahd->cmdcmplt_total -= ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket];
-	ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket] = 0;
-	ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US,
-			ahd_stat_timer, ahd);
-	ahd_unlock(ahd, &s);
-	ahd_list_unlock(&l);
-}
-
-/****************************** Status Processing *****************************/
-void
-ahd_handle_scb_status(struct ahd_softc *ahd, struct scb *scb)
-{
-	if (scb->hscb->shared_data.istatus.scsi_status != 0) {
-		ahd_handle_scsi_status(ahd, scb);
-	} else {
-		ahd_calc_residual(ahd, scb);
-		ahd_done(ahd, scb);
-	}
-}
-
-void
-ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)
-{
-	struct hardware_scb *hscb;
-	u_int  qfreeze_cnt;
-	ahd_mode_state saved_modes;
-
-	/*
-	 * The sequencer freezes its select-out queue
-	 * anytime a SCSI status error occurs.  We must
-	 * handle the error and decrement the QFREEZE count
-	 * to allow the sequencer to continue.
-	 */
-	hscb = scb->hscb; 
-
-	/* Freeze the queue until the client sees the error. */
-	ahd_pause(ahd);
-	saved_modes = ahd_save_modes(ahd);
-	ahd_clear_critical_section(ahd);
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-	ahd_freeze_devq(ahd, scb);
-	ahd_freeze_scb(scb);
-	qfreeze_cnt = ahd_inw(ahd, QFREEZE_COUNT);
-	if (qfreeze_cnt == 0) {
-		printf("%s: Bad status with 0 qfreeze count!\n", ahd_name(ahd));
-	} else {
-		qfreeze_cnt--;
-		ahd_outw(ahd, QFREEZE_COUNT, qfreeze_cnt);
-	}
-	if (qfreeze_cnt == 0)
-		ahd_outb(ahd, SEQ_FLAGS2,
-			 ahd_inb(ahd, SEQ_FLAGS2) & ~SELECTOUT_QFROZEN);
-	ahd_unpause(ahd);
-	/* Don't want to clobber the original sense code */
-	if ((scb->flags & SCB_SENSE) != 0) {
-		/*
-		 * Clear the SCB_SENSE Flag and perform
-		 * a normal command completion.
-		 */
-		scb->flags &= ~SCB_SENSE;
-		ahd_set_transaction_status(scb, CAM_AUTOSENSE_FAIL);
-		ahd_done(ahd, scb);
-		return;
-	}
-	ahd_set_transaction_status(scb, CAM_SCSI_STATUS_ERROR);
-	ahd_set_scsi_status(scb, hscb->shared_data.istatus.scsi_status);
-	switch (hscb->shared_data.istatus.scsi_status) {
-	case STATUS_PKT_SENSE:
-	{
-		struct scsi_status_iu_header *siu;
-
-		ahd_sync_sense(ahd, scb, BUS_DMASYNC_POSTREAD);
-		siu = (struct scsi_status_iu_header *)scb->sense_data;
-		ahd_set_scsi_status(scb, siu->status);
-#ifdef AHD_DEBUG
-		if ((ahd_debug & AHD_SHOW_SENSE) != 0) {
-			ahd_print_path(ahd, scb);
-			printf("SCB 0x%x Received PKT Status of 0x%x\n",
-			       SCB_GET_TAG(scb), siu->status);
-			printf("\tflags = 0x%x, sense len = 0x%x, "
-			       "pktfail = 0x%x\n",
-			       siu->flags, scsi_4btoul(siu->sense_length),
-			       scsi_4btoul(siu->pkt_failures_length));
-		}
-#endif
-		if ((siu->flags & SIU_RSPVALID) != 0) {
-			ahd_print_path(ahd, scb);
-			if (scsi_4btoul(siu->pkt_failures_length) < 4) {
-				printf("Unable to parse pkt_failures\n");
-			} else {
-
-				switch (SIU_PKTFAIL_CODE(siu)) {
-				case SIU_PFC_NONE:
-					printf("No packet failure found\n");
-					break;
-				case SIU_PFC_CIU_FIELDS_INVALID:
-					printf("Invalid Command IU Field\n");
-					break;
-				case SIU_PFC_TMF_NOT_SUPPORTED:
-					printf("TMF not supportd\n");
-					break;
-				case SIU_PFC_TMF_FAILED:
-					printf("TMF failed\n");
-					break;
-				case SIU_PFC_INVALID_TYPE_CODE:
-					printf("Invalid L_Q Type code\n");
-					break;
-				case SIU_PFC_ILLEGAL_REQUEST:
-					printf("Illegal request\n");
-				default:
-					break;
-				}
-			}
-			if (siu->status == SCSI_STATUS_OK)
-				ahd_set_transaction_status(scb,
-							   CAM_REQ_CMP_ERR);
-		}
-		if ((siu->flags & SIU_SNSVALID) != 0) {
-			scb->flags |= SCB_PKT_SENSE;
-#ifdef AHD_DEBUG
-			if ((ahd_debug & AHD_SHOW_SENSE) != 0)
-				printf("Sense data available\n");
-#endif
-		}
-		ahd_done(ahd, scb);
-		break;
-	}
-	case SCSI_STATUS_CMD_TERMINATED:
-	case SCSI_STATUS_CHECK_COND:
-	{
-		struct ahd_devinfo devinfo;
-		struct ahd_dma_seg *sg;
-		struct scsi_sense *sc;
-		struct ahd_initiator_tinfo *targ_info;
-		struct ahd_tmode_tstate *tstate;
-		struct ahd_transinfo *tinfo;
-#ifdef AHD_DEBUG
-		if (ahd_debug & AHD_SHOW_SENSE) {
-			ahd_print_path(ahd, scb);
-			printf("SCB %d: requests Check Status\n",
-			       SCB_GET_TAG(scb));
-		}
-#endif
-
-		if (ahd_perform_autosense(scb) == 0)
-			break;
-
-		ahd_compile_devinfo(&devinfo, SCB_GET_OUR_ID(scb),
-				    SCB_GET_TARGET(ahd, scb),
-				    SCB_GET_LUN(scb),
-				    SCB_GET_CHANNEL(ahd, scb),
-				    ROLE_INITIATOR);
-		targ_info = ahd_fetch_transinfo(ahd,
-						devinfo.channel,
-						devinfo.our_scsiid,
-						devinfo.target,
-						&tstate);
-		tinfo = &targ_info->curr;
-		sg = scb->sg_list;
-		sc = (struct scsi_sense *)hscb->shared_data.idata.cdb;
-		/*
-		 * Save off the residual if there is one.
-		 */
-		ahd_update_residual(ahd, scb);
-#ifdef AHD_DEBUG
-		if (ahd_debug & AHD_SHOW_SENSE) {
-			ahd_print_path(ahd, scb);
-			printf("Sending Sense\n");
-		}
-#endif
-		scb->sg_count = 0;
-		sg = ahd_sg_setup(ahd, scb, sg, ahd_get_sense_bufaddr(ahd, scb),
-				  ahd_get_sense_bufsize(ahd, scb),
-				  /*last*/TRUE);
-		sc->opcode = REQUEST_SENSE;
-		sc->byte2 = 0;
-		if (tinfo->protocol_version <= SCSI_REV_2
-		 && SCB_GET_LUN(scb) < 8)
-			sc->byte2 = SCB_GET_LUN(scb) << 5;
-		sc->unused[0] = 0;
-		sc->unused[1] = 0;
-		sc->length = ahd_get_sense_bufsize(ahd, scb);
-		sc->control = 0;
-
-		/*
-		 * We can't allow the target to disconnect.
-		 * This will be an untagged transaction and
-		 * having the target disconnect will make this
-		 * transaction indestinguishable from outstanding
-		 * tagged transactions.
-		 */
-		hscb->control = 0;
-
-		/*
-		 * This request sense could be because the
-		 * the device lost power or in some other
-		 * way has lost our transfer negotiations.
-		 * Renegotiate if appropriate.  Unit attention
-		 * errors will be reported before any data
-		 * phases occur.
-		 */
-		if (ahd_get_residual(scb) == ahd_get_transfer_length(scb)) {
-			ahd_update_neg_request(ahd, &devinfo,
-					       tstate, targ_info,
-					       AHD_NEG_IF_NON_ASYNC);
-		}
-		if (tstate->auto_negotiate & devinfo.target_mask) {
-			hscb->control |= MK_MESSAGE;
-			scb->flags &=
-			    ~(SCB_NEGOTIATE|SCB_ABORT|SCB_DEVICE_RESET);
-			scb->flags |= SCB_AUTO_NEGOTIATE;
-		}
-		hscb->cdb_len = sizeof(*sc);
-		ahd_setup_data_scb(ahd, scb);
-		scb->flags |= SCB_SENSE;
-		ahd_queue_scb(ahd, scb);
-		/*
-		 * Ensure we have enough time to actually
-		 * retrieve the sense.
-		 */
-		ahd_scb_timer_reset(scb, 5 * 1000000);
-		break;
-	}
-	case SCSI_STATUS_OK:
-		printf("%s: Interrupted for staus of 0???\n",
-		       ahd_name(ahd));
-		/* FALLTHROUGH */
-	default:
-		ahd_done(ahd, scb);
-		break;
-	}
-}
-
-/*
- * Calculate the residual for a just completed SCB.
- */
-void
-ahd_calc_residual(struct ahd_softc *ahd, struct scb *scb)
-{
-	struct hardware_scb *hscb;
-	struct initiator_status *spkt;
-	uint32_t sgptr;
-	uint32_t resid_sgptr;
-	uint32_t resid;
-
-	/*
-	 * 5 cases.
-	 * 1) No residual.
-	 *    SG_STATUS_VALID clear in sgptr.
-	 * 2) Transferless command
-	 * 3) Never performed any transfers.
-	 *    sgptr has SG_FULL_RESID set.
-	 * 4) No residual but target did not
-	 *    save data pointers after the
-	 *    last transfer, so sgptr was
-	 *    never updated.
-	 * 5) We have a partial residual.
-	 *    Use residual_sgptr to determine
-	 *    where we are.
-	 */
-
-	hscb = scb->hscb;
-	sgptr = ahd_le32toh(hscb->sgptr);
-	if ((sgptr & SG_STATUS_VALID) == 0)
-		/* Case 1 */
-		return;
-	sgptr &= ~SG_STATUS_VALID;
-
-	if ((sgptr & SG_LIST_NULL) != 0)
-		/* Case 2 */
-		return;
-
-	/*
-	 * Residual fields are the same in both
-	 * target and initiator status packets,
-	 * so we can always use the initiator fields
-	 * regardless of the role for this SCB.
-	 */
-	spkt = &hscb->shared_data.istatus;
-	resid_sgptr = ahd_le32toh(spkt->residual_sgptr);
-	if ((sgptr & SG_FULL_RESID) != 0) {
-		/* Case 3 */
-		resid = ahd_get_transfer_length(scb);
-	} else if ((resid_sgptr & SG_LIST_NULL) != 0) {
-		/* Case 4 */
-		return;
-	} else if ((resid_sgptr & SG_OVERRUN_RESID) != 0) {
-		ahd_print_path(ahd, scb);
-		printf("data overrun detected Tag == 0x%x.\n",
-		       SCB_GET_TAG(scb));
-		ahd_freeze_devq(ahd, scb);
-		ahd_set_transaction_status(scb, CAM_DATA_RUN_ERR);
-		ahd_freeze_scb(scb);
-		return;
-	} else if ((resid_sgptr & ~SG_PTR_MASK) != 0) {
-		panic("Bogus resid sgptr value 0x%x\n", resid_sgptr);
-		/* NOTREACHED */
-	} else {
-		struct ahd_dma_seg *sg;
-
-		/*
-		 * Remainder of the SG where the transfer
-		 * stopped.  
-		 */
-		resid = ahd_le32toh(spkt->residual_datacnt) & AHD_SG_LEN_MASK;
-		sg = ahd_sg_bus_to_virt(ahd, scb, resid_sgptr & SG_PTR_MASK);
-
-		/* The residual sg_ptr always points to the next sg */
-		sg--;
-
-		/*
-		 * Add up the contents of all residual
-		 * SG segments that are after the SG where
-		 * the transfer stopped.
-		 */
-		while ((ahd_le32toh(sg->len) & AHD_DMA_LAST_SEG) == 0) {
-			sg++;
-			resid += ahd_le32toh(sg->len) & AHD_SG_LEN_MASK;
-		}
-	}
-	if ((scb->flags & SCB_SENSE) == 0)
-		ahd_set_residual(scb, resid);
-	else
-		ahd_set_sense_residual(scb, resid);
-
-#ifdef AHD_DEBUG
-	if ((ahd_debug & AHD_SHOW_MISC) != 0) {
-		ahd_print_path(ahd, scb);
-		printf("Handled %sResidual of %d bytes\n",
-		       (scb->flags & SCB_SENSE) ? "Sense " : "", resid);
-	}
-#endif
-}
-
-/******************************* Target Mode **********************************/
-#ifdef AHD_TARGET_MODE
-/*
- * Add a target mode event to this lun's queue
- */
-static void
-ahd_queue_lstate_event(struct ahd_softc *ahd, struct ahd_tmode_lstate *lstate,
-		       u_int initiator_id, u_int event_type, u_int event_arg)
-{
-	struct ahd_tmode_event *event;
-	int pending;
-
-	xpt_freeze_devq(lstate->path, /*count*/1);
-	if (lstate->event_w_idx >= lstate->event_r_idx)
-		pending = lstate->event_w_idx - lstate->event_r_idx;
-	else
-		pending = AHD_TMODE_EVENT_BUFFER_SIZE + 1
-			- (lstate->event_r_idx - lstate->event_w_idx);
-
-	if (event_type == EVENT_TYPE_BUS_RESET
-	 || event_type == MSG_BUS_DEV_RESET) {
-		/*
-		 * Any earlier events are irrelevant, so reset our buffer.
-		 * This has the effect of allowing us to deal with reset
-		 * floods (an external device holding down the reset line)
-		 * without losing the event that is really interesting.
-		 */
-		lstate->event_r_idx = 0;
-		lstate->event_w_idx = 0;
-		xpt_release_devq(lstate->path, pending, /*runqueue*/FALSE);
-	}
-
-	if (pending == AHD_TMODE_EVENT_BUFFER_SIZE) {
-		xpt_print_path(lstate->path);
-		printf("immediate event %x:%x lost\n",
-		       lstate->event_buffer[lstate->event_r_idx].event_type,
-		       lstate->event_buffer[lstate->event_r_idx].event_arg);
-		lstate->event_r_idx++;
-		if (lstate->event_r_idx == AHD_TMODE_EVENT_BUFFER_SIZE)
-			lstate->event_r_idx = 0;
-		xpt_release_devq(lstate->path, /*count*/1, /*runqueue*/FALSE);
-	}
-
-	event = &lstate->event_buffer[lstate->event_w_idx];
-	event->initiator_id = initiator_id;
-	event->event_type = event_type;
-	event->event_arg = event_arg;
-	lstate->event_w_idx++;
-	if (lstate->event_w_idx == AHD_TMODE_EVENT_BUFFER_SIZE)
-		lstate->event_w_idx = 0;
-}
-
-/*
- * Send any target mode events queued up waiting
- * for immediate notify resources.
- */
-void
-ahd_send_lstate_events(struct ahd_softc *ahd, struct ahd_tmode_lstate *lstate)
-{
-	struct ccb_hdr *ccbh;
-	struct ccb_immed_notify *inot;
-
-	while (lstate->event_r_idx != lstate->event_w_idx
-	    && (ccbh = SLIST_FIRST(&lstate->immed_notifies)) != NULL) {
-		struct ahd_tmode_event *event;
-
-		event = &lstate->event_buffer[lstate->event_r_idx];
-		SLIST_REMOVE_HEAD(&lstate->immed_notifies, sim_links.sle);
-		inot = (struct ccb_immed_notify *)ccbh;
-		switch (event->event_type) {
-		case EVENT_TYPE_BUS_RESET:
-			ccbh->status = CAM_SCSI_BUS_RESET|CAM_DEV_QFRZN;
-			break;
-		default:
-			ccbh->status = CAM_MESSAGE_RECV|CAM_DEV_QFRZN;
-			inot->message_args[0] = event->event_type;
-			inot->message_args[1] = event->event_arg;
-			break;
-		}
-		inot->initiator_id = event->initiator_id;
-		inot->sense_len = 0;
-		xpt_done((union ccb *)inot);
-		lstate->event_r_idx++;
-		if (lstate->event_r_idx == AHD_TMODE_EVENT_BUFFER_SIZE)
-			lstate->event_r_idx = 0;
-	}
-}
-#endif
-
-/******************** Sequencer Program Patching/Download *********************/
-
-#ifdef AHD_DUMP_SEQ
-void
-ahd_dumpseq(struct ahd_softc* ahd)
-{
-	int i;
-	int max_prog;
-
-	max_prog = 2048;
-
-	ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE|LOADRAM);
-	ahd_outb(ahd, PRGMCNT, 0);
-	ahd_outb(ahd, PRGMCNT+1, 0);
-	for (i = 0; i < max_prog; i++) {
-		uint8_t ins_bytes[4];
-
-		ahd_insb(ahd, SEQRAM, ins_bytes, 4);
-		printf("0x%08x\n", ins_bytes[0] << 24
-				 | ins_bytes[1] << 16
-				 | ins_bytes[2] << 8
-				 | ins_bytes[3]);
-	}
-}
-#endif
-
-static void
-ahd_loadseq(struct ahd_softc *ahd)
-{
-	struct	cs cs_table[num_critical_sections];
-	u_int	begin_set[num_critical_sections];
-	u_int	end_set[num_critical_sections];
-	struct	patch *cur_patch;
-	u_int	cs_count;
-	u_int	cur_cs;
-	u_int	i;
-	int	downloaded;
-	u_int	skip_addr;
-	u_int	sg_prefetch_cnt;
-	u_int	sg_prefetch_cnt_limit;
-	u_int	sg_prefetch_align;
-	u_int	sg_size;
-	uint8_t	download_consts[DOWNLOAD_CONST_COUNT];
-
-	if (bootverbose)
-		printf("%s: Downloading Sequencer Program...",
-		       ahd_name(ahd));
-
-#if DOWNLOAD_CONST_COUNT != 7
-#error "Download Const Mismatch"
-#endif
-	/*
-	 * Start out with 0 critical sections
-	 * that apply to this firmware load.
-	 */
-	cs_count = 0;
-	cur_cs = 0;
-	memset(begin_set, 0, sizeof(begin_set));
-	memset(end_set, 0, sizeof(end_set));
-
-	/*
-	 * Setup downloadable constant table.
-	 * 
-	 * The computation for the S/G prefetch variables is
-	 * a bit complicated.  We would like to always fetch
-	 * in terms of cachelined sized increments.  However,
-	 * if the cacheline is not an even multiple of the
-	 * SG element size or is larger than our SG RAM, using
-	 * just the cache size might leave us with only a portion
-	 * of an SG element at the tail of a prefetch.  If the
-	 * cacheline is larger than our S/G prefetch buffer less
-	 * the size of an SG element, we may round down to a cacheline
-	 * that doesn't contain any or all of the S/G of interest
-	 * within the bounds of our S/G ram.  Provide variables to
-	 * the sequencer that will allow it to handle these edge
-	 * cases.
-	 */
-	/* Start by aligning to the nearest cacheline. */
-	sg_prefetch_align = ahd->pci_cachesize;
-	if (sg_prefetch_align == 0)
-		sg_prefetch_cnt = 8;
-	/* Round down to the nearest power of 2. */
-	while (powerof2(sg_prefetch_align) == 0)
-		sg_prefetch_align--;
-	/*
-	 * If the cacheline boundary is greater than half our prefetch RAM
-	 * we risk not being able to fetch even a single complete S/G
-	 * segment if we align to that boundary.
-	 */
-	if (sg_prefetch_align > CCSGADDR_MAX/2)
-		sg_prefetch_align = CCSGADDR_MAX/2;
-	/* Start by fetching a single cacheline. */
-	sg_prefetch_cnt = sg_prefetch_align;
-	/*
-	 * Increment the prefetch count by cachelines until
-	 * at least one S/G element will fit.
-	 */
-	sg_size = sizeof(struct ahd_dma_seg);
-	if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0)
-		sg_size = sizeof(struct ahd_dma64_seg);
-	while (sg_prefetch_cnt < sg_size)
-		sg_prefetch_cnt += sg_prefetch_align;
-	/*
-	 * If the cacheline is not an even multiple of
-	 * the S/G size, we may only get a partial S/G when
-	 * we align. Add a cacheline if this is the case.
-	 */
-	if ((sg_prefetch_align % sg_size) != 0
-	 && (sg_prefetch_cnt < CCSGADDR_MAX))
-		sg_prefetch_cnt += sg_prefetch_align;
-	/*
-	 * Lastly, compute a value that the sequencer can use
-	 * to determine if the remainder of the CCSGRAM buffer
-	 * has a full S/G element in it.
-	 */
-	sg_prefetch_cnt_limit = -(sg_prefetch_cnt - sg_size + 1);
-	download_consts[SG_PREFETCH_CNT] = sg_prefetch_cnt;
-	download_consts[SG_PREFETCH_CNT_LIMIT] = sg_prefetch_cnt_limit;
-	download_consts[SG_PREFETCH_ALIGN_MASK] = ~(sg_prefetch_align - 1);
-	download_consts[SG_PREFETCH_ADDR_MASK] = (sg_prefetch_align - 1);
-	download_consts[SG_SIZEOF] = sg_size;
-	download_consts[PKT_OVERRUN_BUFOFFSET] =
-		(ahd->overrun_buf - (uint8_t *)ahd->qoutfifo) / 256;
-	download_consts[SCB_TRANSFER_SIZE] = SCB_TRANSFER_SIZE_1BYTE_LUN;
-	if ((ahd->bugs & AHD_PKT_LUN_BUG) != 0)
-		download_consts[SCB_TRANSFER_SIZE] = SCB_TRANSFER_SIZE_FULL_LUN;
-	cur_patch = patches;
-	downloaded = 0;
-	skip_addr = 0;
-	ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE|LOADRAM);
-	ahd_outb(ahd, PRGMCNT, 0);
-	ahd_outb(ahd, PRGMCNT+1, 0);
-
-	for (i = 0; i < sizeof(seqprog)/4; i++) {
-		if (ahd_check_patch(ahd, &cur_patch, i, &skip_addr) == 0) {
-			/*
-			 * Don't download this instruction as it
-			 * is in a patch that was removed.
-			 */
-			continue;
-		}
-		/*
-		 * Move through the CS table until we find a CS
-		 * that might apply to this instruction.
-		 */
-		for (; cur_cs < num_critical_sections; cur_cs++) {
-			if (critical_sections[cur_cs].end <= i) {
-				if (begin_set[cs_count] == TRUE
-				 && end_set[cs_count] == FALSE) {
-					cs_table[cs_count].end = downloaded;
-				 	end_set[cs_count] = TRUE;
-					cs_count++;
-				}
-				continue;
-			}
-			if (critical_sections[cur_cs].begin <= i
-			 && begin_set[cs_count] == FALSE) {
-				cs_table[cs_count].begin = downloaded;
-				begin_set[cs_count] = TRUE;
-			}
-			break;
-		}
-		ahd_download_instr(ahd, i, download_consts);
-		downloaded++;
-	}
-
-	ahd->num_critical_sections = cs_count;
-	if (cs_count != 0) {
-
-		cs_count *= sizeof(struct cs);
-		ahd->critical_sections = malloc(cs_count, M_DEVBUF, M_NOWAIT);
-		if (ahd->critical_sections == NULL)
-			panic("ahd_loadseq: Could not malloc");
-		memcpy(ahd->critical_sections, cs_table, cs_count);
-	}
-	ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE);
-
-	if (bootverbose) {
-		printf(" %d instructions downloaded\n", downloaded);
-		printf("%s: Features 0x%x, Bugs 0x%x, Flags 0x%x\n",
-		       ahd_name(ahd), ahd->features, ahd->bugs, ahd->flags);
-	}
-}
-
-static int
-ahd_check_patch(struct ahd_softc *ahd, struct patch **start_patch,
-		u_int start_instr, u_int *skip_addr)
-{
-	struct	patch *cur_patch;
-	struct	patch *last_patch;
-	u_int	num_patches;
-
-	num_patches = sizeof(patches)/sizeof(struct patch);
-	last_patch = &patches[num_patches];
-	cur_patch = *start_patch;
-
-	while (cur_patch < last_patch && start_instr == cur_patch->begin) {
-
-		if (cur_patch->patch_func(ahd) == 0) {
-
-			/* Start rejecting code */
-			*skip_addr = start_instr + cur_patch->skip_instr;
-			cur_patch += cur_patch->skip_patch;
-		} else {
-			/* Accepted this patch.  Advance to the next
-			 * one and wait for our intruction pointer to
-			 * hit this point.
-			 */
-			cur_patch++;
-		}
-	}
-
-	*start_patch = cur_patch;
-	if (start_instr < *skip_addr)
-		/* Still skipping */
-		return (0);
-
-	return (1);
-}
-
-static u_int
-ahd_resolve_seqaddr(struct ahd_softc *ahd, u_int address)
-{
-	struct patch *cur_patch;
-	int address_offset;
-	u_int skip_addr;
-	u_int i;
-
-	address_offset = 0;
-	cur_patch = patches;
-	skip_addr = 0;
-
-	for (i = 0; i < address;) {
-
-		ahd_check_patch(ahd, &cur_patch, i, &skip_addr);
-
-		if (skip_addr > i) {
-			int end_addr;
-
-			end_addr = MIN(address, skip_addr);
-			address_offset += end_addr - i;
-			i = skip_addr;
-		} else {
-			i++;
-		}
-	}
-	return (address - address_offset);
-}
-
-static void
-ahd_download_instr(struct ahd_softc *ahd, u_int instrptr, uint8_t *dconsts)
-{
-	union	ins_formats instr;
-	struct	ins_format1 *fmt1_ins;
-	struct	ins_format3 *fmt3_ins;
-	u_int	opcode;
-
-	/*
-	 * The firmware is always compiled into a little endian format.
-	 */
-	instr.integer = ahd_le32toh(*(uint32_t*)&seqprog[instrptr * 4]);
-
-	fmt1_ins = &instr.format1;
-	fmt3_ins = NULL;
-
-	/* Pull the opcode */
-	opcode = instr.format1.opcode;
-	switch (opcode) {
-	case AIC_OP_JMP:
-	case AIC_OP_JC:
-	case AIC_OP_JNC:
-	case AIC_OP_CALL:
-	case AIC_OP_JNE:
-	case AIC_OP_JNZ:
-	case AIC_OP_JE:
-	case AIC_OP_JZ:
-	{
-		fmt3_ins = &instr.format3;
-		fmt3_ins->address = ahd_resolve_seqaddr(ahd, fmt3_ins->address);
-		/* FALLTHROUGH */
-	}
-	case AIC_OP_OR:
-	case AIC_OP_AND:
-	case AIC_OP_XOR:
-	case AIC_OP_ADD:
-	case AIC_OP_ADC:
-	case AIC_OP_BMOV:
-		if (fmt1_ins->parity != 0) {
-			fmt1_ins->immediate = dconsts[fmt1_ins->immediate];
-		}
-		fmt1_ins->parity = 0;
-		/* FALLTHROUGH */
-	case AIC_OP_ROL:
-	{
-		int i, count;
-
-		/* Calculate odd parity for the instruction */
-		for (i = 0, count = 0; i < 31; i++) {
-			uint32_t mask;
-
-			mask = 0x01 << i;
-			if ((instr.integer & mask) != 0)
-				count++;
-		}
-		if ((count & 0x01) == 0)
-			instr.format1.parity = 1;
-
-		/* The sequencer is a little endian cpu */
-		instr.integer = ahd_htole32(instr.integer);
-		ahd_outsb(ahd, SEQRAM, instr.bytes, 4);
-		break;
-	}
-	default:
-		panic("Unknown opcode encountered in seq program");
-		break;
-	}
-}
-
-static int
-ahd_probe_stack_size(struct ahd_softc *ahd)
-{
-	int last_probe;
-
-	last_probe = 0;
-	while (1) {
-		int i;
-
-		/*
-		 * We avoid using 0 as a pattern to avoid
-		 * confusion if the stack implementation
-		 * "back-fills" with zeros when "poping'
-		 * entries.
-		 */
-		for (i = 1; i <= last_probe+1; i++) {
-		       ahd_outb(ahd, STACK, i & 0xFF);
-		       ahd_outb(ahd, STACK, (i >> 8) & 0xFF);
-		}
-
-		/* Verify */
-		for (i = last_probe+1; i > 0; i--) {
-			u_int stack_entry;
-
-			stack_entry = ahd_inb(ahd, STACK)
-				    |(ahd_inb(ahd, STACK) << 8);
-			if (stack_entry != i)
-				goto sized;
-		}
-		last_probe++;
-	}
-sized:
-	return (last_probe);
-}
-
-void
-ahd_dump_all_cards_state()
-{
-	struct ahd_softc *list_ahd;
-
-	TAILQ_FOREACH(list_ahd, &ahd_tailq, links) {
-		ahd_dump_card_state(list_ahd);
-	}
-}
-
-int
-ahd_print_register(ahd_reg_parse_entry_t *table, u_int num_entries,
-		   const char *name, u_int address, u_int value,
-		   u_int *cur_column, u_int wrap_point)
-{
-	int	printed;
-	u_int	printed_mask;
-
-	if (cur_column != NULL && *cur_column >= wrap_point) {
-		printf("\n");
-		*cur_column = 0;
-	}
-	printed = printf("%s[0x%x]", name, value);
-	if (table == NULL) {
-		printed += printf(" ");
-		*cur_column += printed;
-		return (printed);
-	}
-	printed_mask = 0;
-	while (printed_mask != 0xFF) {
-		int entry;
-
-		for (entry = 0; entry < num_entries; entry++) {
-			if (((value & table[entry].mask)
-			  != table[entry].value)
-			 || ((printed_mask & table[entry].mask)
-			  == table[entry].mask))
-				continue;
-
-			printed += printf("%s%s",
-					  printed_mask == 0 ? ":(" : "|",
-					  table[entry].name);
-			printed_mask |= table[entry].mask;
-			
-			break;
-		}
-		if (entry >= num_entries)
-			break;
-	}
-	if (printed_mask != 0)
-		printed += printf(") ");
-	else
-		printed += printf(" ");
-	if (cur_column != NULL)
-		*cur_column += printed;
-	return (printed);
-}
-
-void
-ahd_dump_card_state(struct ahd_softc *ahd)
-{
-	struct scb	*scb;
-	ahd_mode_state	 saved_modes;
-	u_int		 dffstat;
-	int		 paused;
-	u_int		 scb_index;
-	u_int		 saved_scb_index;
-	u_int		 cur_col;
-	int		 i;
-
-	if (ahd_is_paused(ahd)) {
-		paused = 1;
-	} else {
-		paused = 0;
-		ahd_pause(ahd);
-	}
-	saved_modes = ahd_save_modes(ahd);
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-	printf(">>>>>>>>>>>>>>>>>> Dump Card State Begins <<<<<<<<<<<<<<<<<\n"
-	       "%s: Dumping Card State at program address 0x%x Mode 0x%x\n",
-	       ahd_name(ahd), 
-	       ahd_inb(ahd, CURADDR) | (ahd_inb(ahd, CURADDR+1) << 8),
-	       ahd_build_mode_state(ahd, ahd->saved_src_mode,
-				    ahd->saved_dst_mode));
-	if (paused)
-		printf("Card was paused\n");
-	/*
-	 * Mode independent registers.
-	 */
-	cur_col = 0;
-	ahd_hs_mailbox_print(ahd_inb(ahd, LOCAL_HS_MAILBOX), &cur_col, 50);
-	ahd_intctl_print(ahd_inb(ahd, INTCTL), &cur_col, 50);
-	ahd_seqintstat_print(ahd_inb(ahd, SEQINTSTAT), &cur_col, 50);
-	ahd_saved_mode_print(ahd_inb(ahd, SAVED_MODE), &cur_col, 50);
-	ahd_dffstat_print(ahd_inb(ahd, DFFSTAT), &cur_col, 50);
-	ahd_scsisigi_print(ahd_inb(ahd, SCSISIGI), &cur_col, 50);
-	ahd_scsiphase_print(ahd_inb(ahd, SCSIPHASE), &cur_col, 50);
-	ahd_scsibus_print(ahd_inb(ahd, SCSIBUS), &cur_col, 50);
-	ahd_lastphase_print(ahd_inb(ahd, LASTPHASE), &cur_col, 50);
-	ahd_scsiseq0_print(ahd_inb(ahd, SCSISEQ0), &cur_col, 50);
-	ahd_scsiseq1_print(ahd_inb(ahd, SCSISEQ1), &cur_col, 50);
-	ahd_seqctl0_print(ahd_inb(ahd, SEQCTL0), &cur_col, 50);
-	ahd_seqintctl_print(ahd_inb(ahd, SEQINTCTL), &cur_col, 50);
-	ahd_seq_flags_print(ahd_inb(ahd, SEQ_FLAGS), &cur_col, 50);
-	ahd_seq_flags2_print(ahd_inb(ahd, SEQ_FLAGS2), &cur_col, 50);
-	ahd_sstat0_print(ahd_inb(ahd, SSTAT0), &cur_col, 50);
-	ahd_sstat1_print(ahd_inb(ahd, SSTAT1), &cur_col, 50);
-	ahd_sstat2_print(ahd_inb(ahd, SSTAT2), &cur_col, 50);
-	ahd_sstat3_print(ahd_inb(ahd, SSTAT3), &cur_col, 50);
-	ahd_perrdiag_print(ahd_inb(ahd, PERRDIAG), &cur_col, 50);
-	ahd_simode1_print(ahd_inb(ahd, SIMODE1), &cur_col, 50);
-	ahd_lqistat0_print(ahd_inb(ahd, LQISTAT0), &cur_col, 50);
-	ahd_lqistat1_print(ahd_inb(ahd, LQISTAT1), &cur_col, 50);
-	ahd_lqistat2_print(ahd_inb(ahd, LQISTAT2), &cur_col, 50);
-	ahd_lqostat0_print(ahd_inb(ahd, LQOSTAT0), &cur_col, 50);
-	ahd_lqostat1_print(ahd_inb(ahd, LQOSTAT1), &cur_col, 50);
-	ahd_lqostat2_print(ahd_inb(ahd, LQOSTAT2), &cur_col, 50);
-	printf("\n");
-	printf("\nSCB Count = %d CMDS_PENDING = %d LASTSCB 0x%x "
-	       "CURRSCB 0x%x NEXTSCB 0x%x\n",
-	       ahd->scb_data.numscbs, ahd_inw(ahd, CMDS_PENDING),
-	       ahd_inw(ahd, LASTSCB), ahd_inw(ahd, CURRSCB),
-	       ahd_inw(ahd, NEXTSCB));
-	cur_col = 0;
-	/* QINFIFO */
-	ahd_search_qinfifo(ahd, CAM_TARGET_WILDCARD, ALL_CHANNELS,
-			   CAM_LUN_WILDCARD, SCB_LIST_NULL,
-			   ROLE_UNKNOWN, /*status*/0, SEARCH_PRINT);
-	saved_scb_index = ahd_get_scbptr(ahd);
-	printf("Pending list:");
-	i = 0;
-	LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) {
-		if (i++ > AHD_SCB_MAX)
-			break;
-		cur_col = printf("\n%3d ", SCB_GET_TAG(scb));
-		ahd_set_scbptr(ahd, SCB_GET_TAG(scb));
-		ahd_scb_control_print(ahd_inb(ahd, SCB_CONTROL), &cur_col, 60);
-		ahd_scb_scsiid_print(ahd_inb(ahd, SCB_SCSIID), &cur_col, 60);
-		ahd_scb_tag_print(ahd_inb(ahd, SCB_TAG), &cur_col, 60);
-	}
-	printf("\nTotal %d\n", i);
-
-	printf("Kernel Free SCB list: ");
-	i = 0;
-	TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) {
-		struct scb *list_scb;
-
-		list_scb = scb;
-		do {
-			printf("%d ", SCB_GET_TAG(list_scb));
-			list_scb = LIST_NEXT(list_scb, collision_links);
-		} while (list_scb && i++ < AHD_SCB_MAX);
-	}
-
-	LIST_FOREACH(scb, &ahd->scb_data.any_dev_free_scb_list, links.le) {
-		if (i++ > AHD_SCB_MAX)
-			break;
-		printf("%d ", SCB_GET_TAG(scb));
-	}
-	printf("\n");
-
-	printf("Sequencer Complete DMA-inprog list: ");
-	scb_index = ahd_inw(ahd, COMPLETE_SCB_DMAINPROG_HEAD);
-	i = 0;
-	while (!SCBID_IS_NULL(scb_index) && i++ < AHD_SCB_MAX) {
-		ahd_set_scbptr(ahd, scb_index);
-		printf("%d ", scb_index);
-		scb_index = ahd_inw(ahd, SCB_NEXT_COMPLETE);
-	}
-	printf("\n");
-
-	printf("Sequencer Complete list: ");
-	scb_index = ahd_inw(ahd, COMPLETE_SCB_HEAD);
-	i = 0;
-	while (!SCBID_IS_NULL(scb_index) && i++ < AHD_SCB_MAX) {
-		ahd_set_scbptr(ahd, scb_index);
-		printf("%d ", scb_index);
-		scb_index = ahd_inw(ahd, SCB_NEXT_COMPLETE);
-	}
-	printf("\n");
-
-	
-	printf("Sequencer DMA-Up and Complete list: ");
-	scb_index = ahd_inw(ahd, COMPLETE_DMA_SCB_HEAD);
-	i = 0;
-	while (!SCBID_IS_NULL(scb_index) && i++ < AHD_SCB_MAX) {
-		ahd_set_scbptr(ahd, scb_index);
-		printf("%d ", scb_index);
-		scb_index = ahd_inw(ahd, SCB_NEXT_COMPLETE);
-	}
-	printf("\n");
-	ahd_set_scbptr(ahd, saved_scb_index);
-	dffstat = ahd_inb(ahd, DFFSTAT);
-	for (i = 0; i < 2; i++) {
-#ifdef AHD_DEBUG
-		struct scb *fifo_scb;
-#endif
-		u_int	    fifo_scbptr;
-
-		ahd_set_modes(ahd, AHD_MODE_DFF0 + i, AHD_MODE_DFF0 + i);
-		fifo_scbptr = ahd_get_scbptr(ahd);
-		printf("\n%s: FIFO%d %s, LONGJMP == 0x%x, "
-		       "SCB 0x%x, LJSCB 0x%x\n",
-		       ahd_name(ahd), i,
-		       (dffstat & (FIFO0FREE << i)) ? "Free" : "Active",
-		       ahd_inw(ahd, LONGJMP_ADDR), fifo_scbptr,
-		       ahd_inw(ahd, LONGJMP_SCB));
-		cur_col = 0;
-		ahd_seqimode_print(ahd_inb(ahd, SEQIMODE), &cur_col, 50);
-		ahd_seqintsrc_print(ahd_inb(ahd, SEQINTSRC), &cur_col, 50);
-		ahd_dfcntrl_print(ahd_inb(ahd, DFCNTRL), &cur_col, 50);
-		ahd_dfstatus_print(ahd_inb(ahd, DFSTATUS), &cur_col, 50);
-		ahd_sg_cache_shadow_print(ahd_inb(ahd, SG_CACHE_SHADOW),
-					  &cur_col, 50);
-		ahd_sg_state_print(ahd_inb(ahd, SG_STATE), &cur_col, 50);
-		ahd_dffsxfrctl_print(ahd_inb(ahd, DFFSXFRCTL), &cur_col, 50);
-		ahd_soffcnt_print(ahd_inb(ahd, SOFFCNT), &cur_col, 50);
-		ahd_mdffstat_print(ahd_inb(ahd, MDFFSTAT), &cur_col, 50);
-		if (cur_col > 50) {
-			printf("\n");
-			cur_col = 0;
-		}
-		cur_col += printf("SHADDR = 0x%x%x, SHCNT = 0x%x ",
-				  ahd_inl(ahd, SHADDR+4),
-				  ahd_inl(ahd, SHADDR),
-				  (ahd_inb(ahd, SHCNT)
-				| (ahd_inb(ahd, SHCNT + 1) << 8)
-				| (ahd_inb(ahd, SHCNT + 2) << 16)));
-		if (cur_col > 50) {
-			printf("\n");
-			cur_col = 0;
-		}
-		cur_col += printf("HADDR = 0x%x%x, HCNT = 0x%x ",
-				  ahd_inl(ahd, HADDR+4),
-				  ahd_inl(ahd, HADDR),
-				  (ahd_inb(ahd, HCNT)
-				| (ahd_inb(ahd, HCNT + 1) << 8)
-				| (ahd_inb(ahd, HCNT + 2) << 16)));
-		ahd_ccsgctl_print(ahd_inb(ahd, CCSGCTL), &cur_col, 50);
-#ifdef AHD_DEBUG
-		if ((ahd_debug & AHD_SHOW_SG) != 0) {
-			fifo_scb = ahd_lookup_scb(ahd, fifo_scbptr);
-			if (fifo_scb != NULL)
-				ahd_dump_sglist(fifo_scb);
-		}
-#endif
-	}
-	printf("\nLQIN: ");
-	for (i = 0; i < 20; i++)
-		printf("0x%x ", ahd_inb(ahd, LQIN + i));
-	printf("\n");
-	ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
-	printf("%s: LQISTATE = 0x%x, LQOSTATE = 0x%x, OPTIONMODE = 0x%x\n",
-	       ahd_name(ahd), ahd_inb(ahd, LQISTATE), ahd_inb(ahd, LQOSTATE),
-	       ahd_inb(ahd, OPTIONMODE));
-	printf("%s: OS_SPACE_CNT = 0x%x MAXCMDCNT = 0x%x\n",
-	       ahd_name(ahd), ahd_inb(ahd, OS_SPACE_CNT),
-	       ahd_inb(ahd, MAXCMDCNT));
-	ahd_simode0_print(ahd_inb(ahd, SIMODE0), &cur_col, 50);
-	printf("\n");
-	ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
-	cur_col = 0;
-	ahd_ccscbctl_print(ahd_inb(ahd, CCSCBCTL), &cur_col, 50);
-	printf("\n");
-	ahd_set_modes(ahd, ahd->saved_src_mode, ahd->saved_dst_mode);
-	printf("%s: REG0 == 0x%x, SINDEX = 0x%x, DINDEX = 0x%x\n",
-	       ahd_name(ahd), ahd_inw(ahd, REG0), ahd_inw(ahd, SINDEX),
-	       ahd_inw(ahd, DINDEX));
-	printf("%s: SCBPTR == 0x%x, SCB_NEXT == 0x%x, SCB_NEXT2 == 0x%x\n",
-	       ahd_name(ahd), ahd_get_scbptr(ahd), ahd_inw(ahd, SCB_NEXT),
-	       ahd_inw(ahd, SCB_NEXT2));
-	printf("CDB %x %x %x %x %x %x\n",
-	       ahd_inb(ahd, SCB_CDB_STORE),
-	       ahd_inb(ahd, SCB_CDB_STORE+1),
-	       ahd_inb(ahd, SCB_CDB_STORE+2),
-	       ahd_inb(ahd, SCB_CDB_STORE+3),
-	       ahd_inb(ahd, SCB_CDB_STORE+4),
-	       ahd_inb(ahd, SCB_CDB_STORE+5));
-	printf("STACK:");
-	for (i = 0; i < ahd->stack_size; i++) {
-		ahd->saved_stack[i] =
-		    ahd_inb(ahd, STACK)|(ahd_inb(ahd, STACK) << 8);
-		printf(" 0x%x", ahd->saved_stack[i]);
-	}
-	for (i = ahd->stack_size-1; i >= 0; i--) {
-		ahd_outb(ahd, STACK, ahd->saved_stack[i] & 0xFF);
-		ahd_outb(ahd, STACK, (ahd->saved_stack[i] >> 8) & 0xFF);
-	}
-	printf("\n<<<<<<<<<<<<<<<<< Dump Card State Ends >>>>>>>>>>>>>>>>>>\n");
-	ahd_platform_dump_card_state(ahd);
-	ahd_restore_modes(ahd, saved_modes);
-	if (paused == 0)
-		ahd_unpause(ahd);
-}
-
-void
-ahd_dump_scbs(struct ahd_softc *ahd)
-{
-	ahd_mode_state saved_modes;
-	u_int	       saved_scb_index;
-	int	       i;
-
-	saved_modes = ahd_save_modes(ahd);
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-	saved_scb_index = ahd_get_scbptr(ahd);
-	for (i = 0; i < AHD_SCB_MAX; i++) {
-		ahd_set_scbptr(ahd, i);
-		printf("%3d", i);
-		printf("(CTRL 0x%x ID 0x%x N 0x%x N2 0x%x SG 0x%x, RSG 0x%x)\n",
-		       ahd_inb(ahd, SCB_CONTROL),
-		       ahd_inb(ahd, SCB_SCSIID), ahd_inw(ahd, SCB_NEXT),
-		       ahd_inw(ahd, SCB_NEXT2), ahd_inl(ahd, SCB_SGPTR),
-		       ahd_inl(ahd, SCB_RESIDUAL_SGPTR));
-	}
-	printf("\n");
-	ahd_set_scbptr(ahd, saved_scb_index);
-	ahd_restore_modes(ahd, saved_modes);
-}
-
-/**************************** Flexport Logic **********************************/
-/*
- * Read count 16bit words from 16bit word address start_addr from the
- * SEEPROM attached to the controller, into buf, using the controller's
- * SEEPROM reading state machine.
- */
-int
-ahd_read_seeprom(struct ahd_softc *ahd, uint16_t *buf,
-		 u_int start_addr, u_int count)
-{
-	u_int cur_addr;
-	u_int end_addr;
-	int   error;
-
-	/*
-	 * If we never make it through the loop even once,
-	 * we were passed invalid arguments.
-	 */
-	error = EINVAL;
-	AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
-	end_addr = start_addr + count;
-	for (cur_addr = start_addr; cur_addr < end_addr; cur_addr++) {
-		ahd_outb(ahd, SEEADR, cur_addr);
-		ahd_outb(ahd, SEECTL, SEEOP_READ | SEESTART);
-		
-		error = ahd_wait_seeprom(ahd);
-		if (error)
-			break;
-		*buf++ = ahd_inw(ahd, SEEDAT);
-	}
-	return (error);
-}
-
-/*
- * Write count 16bit words from buf, into SEEPROM attache to the
- * controller starting at 16bit word address start_addr, using the
- * controller's SEEPROM writing state machine.
- */
-int
-ahd_write_seeprom(struct ahd_softc *ahd, uint16_t *buf,
-		  u_int start_addr, u_int count)
-{
-	u_int cur_addr;
-	u_int end_addr;
-	int   error;
-	int   retval;
-
-	AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
-	error = ENOENT;
-
-	/* Place the chip into write-enable mode */
-	ahd_outb(ahd, SEEADR, SEEOP_EWEN_ADDR);
-	ahd_outb(ahd, SEECTL, SEEOP_EWEN | SEESTART);
-	error = ahd_wait_seeprom(ahd);
-	if (error)
-		return (error);
-
-	/*
-	 * Write the data.  If we don't get throught the loop at
-	 * least once, the arguments were invalid.
-	 */
-	retval = EINVAL;
-	end_addr = start_addr + count;
-	for (cur_addr = start_addr; cur_addr < end_addr; cur_addr++) {
-		ahd_outw(ahd, SEEDAT, *buf++);
-		ahd_outb(ahd, SEEADR, cur_addr);
-		ahd_outb(ahd, SEECTL, SEEOP_WRITE | SEESTART);
-		
-		retval = ahd_wait_seeprom(ahd);
-		if (retval)
-			break;
-	}
-
-	/*
-	 * Disable writes.
-	 */
-	ahd_outb(ahd, SEEADR, SEEOP_EWDS_ADDR);
-	ahd_outb(ahd, SEECTL, SEEOP_EWDS | SEESTART);
-	error = ahd_wait_seeprom(ahd);
-	if (error)
-		return (error);
-	return (retval);
-}
-
-/*
- * Wait ~100us for the serial eeprom to satisfy our request.
- */
-int
-ahd_wait_seeprom(struct ahd_softc *ahd)
-{
-	int cnt;
-
-	cnt = 20;
-	while ((ahd_inb(ahd, SEESTAT) & (SEEARBACK|SEEBUSY)) != 0 && --cnt)
-		ahd_delay(5);
-
-	if (cnt == 0)
-		return (ETIMEDOUT);
-	return (0);
-}
-
-int
-ahd_verify_cksum(struct seeprom_config *sc)
-{
-	int i;
-	int maxaddr;
-	uint32_t checksum;
-	uint16_t *scarray;
-
-	maxaddr = (sizeof(*sc)/2) - 1;
-	checksum = 0;
-	scarray = (uint16_t *)sc;
-
-	for (i = 0; i < maxaddr; i++)
-		checksum = checksum + scarray[i];
-	if (checksum == 0
-	 || (checksum & 0xFFFF) != sc->checksum) {
-		return (0);
-	} else {
-		return (1);
-	}
-}
-
-int
-ahd_acquire_seeprom(struct ahd_softc *ahd)
-{
-	/*
-	 * We should be able to determine the SEEPROM type
-	 * from the flexport logic, but unfortunately not
-	 * all implementations have this logic and there is
-	 * no programatic method for determining if the logic
-	 * is present.
-	 */
-	return (1);
-#if 0
-	uint8_t	seetype;
-	int	error;
-
-	error = ahd_read_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL, &seetype);
-	if (error != 0
-         || ((seetype & FLX_ROMSTAT_SEECFG) == FLX_ROMSTAT_SEE_NONE))
-		return (0);
-	return (1);
-#endif
-}
-
-void
-ahd_release_seeprom(struct ahd_softc *ahd)
-{
-	/* Currently a no-op */
-}
-
-int
-ahd_write_flexport(struct ahd_softc *ahd, u_int addr, u_int value)
-{
-	int error;
-
-	AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
-	if (addr > 7)
-		panic("ahd_write_flexport: address out of range");
-	ahd_outb(ahd, BRDCTL, BRDEN|(addr << 3));
-	error = ahd_wait_flexport(ahd);
-	if (error != 0)
-		return (error);
-	ahd_outb(ahd, BRDDAT, value);
-	ahd_flush_device_writes(ahd);
-	ahd_outb(ahd, BRDCTL, BRDSTB|BRDEN|(addr << 3));
-	ahd_flush_device_writes(ahd);
-	ahd_outb(ahd, BRDCTL, BRDEN|(addr << 3));
-	ahd_flush_device_writes(ahd);
-	ahd_outb(ahd, BRDCTL, 0);
-	ahd_flush_device_writes(ahd);
-	return (0);
-}
-
-int
-ahd_read_flexport(struct ahd_softc *ahd, u_int addr, uint8_t *value)
-{
-	int	error;
-
-	AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
-	if (addr > 7)
-		panic("ahd_read_flexport: address out of range");
-	ahd_outb(ahd, BRDCTL, BRDRW|BRDEN|(addr << 3));
-	error = ahd_wait_flexport(ahd);
-	if (error != 0)
-		return (error);
-	*value = ahd_inb(ahd, BRDDAT);
-	ahd_outb(ahd, BRDCTL, 0);
-	ahd_flush_device_writes(ahd);
-	return (0);
-}
-
-/*
- * Wait at most 2 seconds for flexport arbitration to succeed.
- */
-int
-ahd_wait_flexport(struct ahd_softc *ahd)
-{
-	int cnt;
-
-	AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
-	cnt = 1000000 * 2 / 5;
-	while ((ahd_inb(ahd, BRDCTL) & FLXARBACK) == 0 && --cnt)
-		ahd_delay(5);
-
-	if (cnt == 0)
-		return (ETIMEDOUT);
-	return (0);
-}
-
-/************************* Target Mode ****************************************/
-#ifdef AHD_TARGET_MODE
-cam_status
-ahd_find_tmode_devs(struct ahd_softc *ahd, struct cam_sim *sim, union ccb *ccb,
-		    struct ahd_tmode_tstate **tstate,
-		    struct ahd_tmode_lstate **lstate,
-		    int notfound_failure)
-{
-
-	if ((ahd->features & AHD_TARGETMODE) == 0)
-		return (CAM_REQ_INVALID);
-
-	/*
-	 * Handle the 'black hole' device that sucks up
-	 * requests to unattached luns on enabled targets.
-	 */
-	if (ccb->ccb_h.target_id == CAM_TARGET_WILDCARD
-	 && ccb->ccb_h.target_lun == CAM_LUN_WILDCARD) {
-		*tstate = NULL;
-		*lstate = ahd->black_hole;
-	} else {
-		u_int max_id;
-
-		max_id = (ahd->features & AHD_WIDE) ? 15 : 7;
-		if (ccb->ccb_h.target_id > max_id)
-			return (CAM_TID_INVALID);
-
-		if (ccb->ccb_h.target_lun >= AHD_NUM_LUNS)
-			return (CAM_LUN_INVALID);
-
-		*tstate = ahd->enabled_targets[ccb->ccb_h.target_id];
-		*lstate = NULL;
-		if (*tstate != NULL)
-			*lstate =
-			    (*tstate)->enabled_luns[ccb->ccb_h.target_lun];
-	}
-
-	if (notfound_failure != 0 && *lstate == NULL)
-		return (CAM_PATH_INVALID);
-
-	return (CAM_REQ_CMP);
-}
-
-void
-ahd_handle_en_lun(struct ahd_softc *ahd, struct cam_sim *sim, union ccb *ccb)
-{
-#if NOT_YET
-	struct	   ahd_tmode_tstate *tstate;
-	struct	   ahd_tmode_lstate *lstate;
-	struct	   ccb_en_lun *cel;
-	cam_status status;
-	u_int	   target;
-	u_int	   lun;
-	u_int	   target_mask;
-	u_long	   s;
-	char	   channel;
-
-	status = ahd_find_tmode_devs(ahd, sim, ccb, &tstate, &lstate,
-				     /*notfound_failure*/FALSE);
-
-	if (status != CAM_REQ_CMP) {
-		ccb->ccb_h.status = status;
-		return;
-	}
-
-	if ((ahd->features & AHD_MULTIROLE) != 0) {
-		u_int	   our_id;
-
-		our_id = ahd->our_id;
-		if (ccb->ccb_h.target_id != our_id) {
-			if ((ahd->features & AHD_MULTI_TID) != 0
-		   	 && (ahd->flags & AHD_INITIATORROLE) != 0) {
-				/*
-				 * Only allow additional targets if
-				 * the initiator role is disabled.
-				 * The hardware cannot handle a re-select-in
-				 * on the initiator id during a re-select-out
-				 * on a different target id.
-				 */
-				status = CAM_TID_INVALID;
-			} else if ((ahd->flags & AHD_INITIATORROLE) != 0
-				|| ahd->enabled_luns > 0) {
-				/*
-				 * Only allow our target id to change
-				 * if the initiator role is not configured
-				 * and there are no enabled luns which
-				 * are attached to the currently registered
-				 * scsi id.
-				 */
-				status = CAM_TID_INVALID;
-			}
-		}
-	}
-
-	if (status != CAM_REQ_CMP) {
-		ccb->ccb_h.status = status;
-		return;
-	}
-
-	/*
-	 * We now have an id that is valid.
-	 * If we aren't in target mode, switch modes.
-	 */
-	if ((ahd->flags & AHD_TARGETROLE) == 0
-	 && ccb->ccb_h.target_id != CAM_TARGET_WILDCARD) {
-		u_long	s;
-
-		printf("Configuring Target Mode\n");
-		ahd_lock(ahd, &s);
-		if (LIST_FIRST(&ahd->pending_scbs) != NULL) {
-			ccb->ccb_h.status = CAM_BUSY;
-			ahd_unlock(ahd, &s);
-			return;
-		}
-		ahd->flags |= AHD_TARGETROLE;
-		if ((ahd->features & AHD_MULTIROLE) == 0)
-			ahd->flags &= ~AHD_INITIATORROLE;
-		ahd_pause(ahd);
-		ahd_loadseq(ahd);
-		ahd_unlock(ahd, &s);
-	}
-	cel = &ccb->cel;
-	target = ccb->ccb_h.target_id;
-	lun = ccb->ccb_h.target_lun;
-	channel = SIM_CHANNEL(ahd, sim);
-	target_mask = 0x01 << target;
-	if (channel == 'B')
-		target_mask <<= 8;
-
-	if (cel->enable != 0) {
-		u_int scsiseq1;
-
-		/* Are we already enabled?? */
-		if (lstate != NULL) {
-			xpt_print_path(ccb->ccb_h.path);
-			printf("Lun already enabled\n");
-			ccb->ccb_h.status = CAM_LUN_ALRDY_ENA;
-			return;
-		}
-
-		if (cel->grp6_len != 0
-		 || cel->grp7_len != 0) {
-			/*
-			 * Don't (yet?) support vendor
-			 * specific commands.
-			 */
-			ccb->ccb_h.status = CAM_REQ_INVALID;
-			printf("Non-zero Group Codes\n");
-			return;
-		}
-
-		/*
-		 * Seems to be okay.
-		 * Setup our data structures.
-		 */
-		if (target != CAM_TARGET_WILDCARD && tstate == NULL) {
-			tstate = ahd_alloc_tstate(ahd, target, channel);
-			if (tstate == NULL) {
-				xpt_print_path(ccb->ccb_h.path);
-				printf("Couldn't allocate tstate\n");
-				ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
-				return;
-			}
-		}
-		lstate = malloc(sizeof(*lstate), M_DEVBUF, M_NOWAIT);
-		if (lstate == NULL) {
-			xpt_print_path(ccb->ccb_h.path);
-			printf("Couldn't allocate lstate\n");
-			ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
-			return;
-		}
-		memset(lstate, 0, sizeof(*lstate));
-		status = xpt_create_path(&lstate->path, /*periph*/NULL,
-					 xpt_path_path_id(ccb->ccb_h.path),
-					 xpt_path_target_id(ccb->ccb_h.path),
-					 xpt_path_lun_id(ccb->ccb_h.path));
-		if (status != CAM_REQ_CMP) {
-			free(lstate, M_DEVBUF);
-			xpt_print_path(ccb->ccb_h.path);
-			printf("Couldn't allocate path\n");
-			ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
-			return;
-		}
-		SLIST_INIT(&lstate->accept_tios);
-		SLIST_INIT(&lstate->immed_notifies);
-		ahd_lock(ahd, &s);
-		ahd_pause(ahd);
-		if (target != CAM_TARGET_WILDCARD) {
-			tstate->enabled_luns[lun] = lstate;
-			ahd->enabled_luns++;
-
-			if ((ahd->features & AHD_MULTI_TID) != 0) {
-				u_int targid_mask;
-
-				targid_mask = ahd_inb(ahd, TARGID)
-					    | (ahd_inb(ahd, TARGID + 1) << 8);
-
-				targid_mask |= target_mask;
-				ahd_outb(ahd, TARGID, targid_mask);
-				ahd_outb(ahd, TARGID+1, (targid_mask >> 8));
-				
-				ahd_update_scsiid(ahd, targid_mask);
-			} else {
-				u_int our_id;
-				char  channel;
-
-				channel = SIM_CHANNEL(ahd, sim);
-				our_id = SIM_SCSI_ID(ahd, sim);
-
-				/*
-				 * This can only happen if selections
-				 * are not enabled
-				 */
-				if (target != our_id) {
-					u_int sblkctl;
-					char  cur_channel;
-					int   swap;
-
-					sblkctl = ahd_inb(ahd, SBLKCTL);
-					cur_channel = (sblkctl & SELBUSB)
-						    ? 'B' : 'A';
-					if ((ahd->features & AHD_TWIN) == 0)
-						cur_channel = 'A';
-					swap = cur_channel != channel;
-					ahd->our_id = target;
-
-					if (swap)
-						ahd_outb(ahd, SBLKCTL,
-							 sblkctl ^ SELBUSB);
-
-					ahd_outb(ahd, SCSIID, target);
-
-					if (swap)
-						ahd_outb(ahd, SBLKCTL, sblkctl);
-				}
-			}
-		} else
-			ahd->black_hole = lstate;
-		/* Allow select-in operations */
-		if (ahd->black_hole != NULL && ahd->enabled_luns > 0) {
-			scsiseq1 = ahd_inb(ahd, SCSISEQ_TEMPLATE);
-			scsiseq1 |= ENSELI;
-			ahd_outb(ahd, SCSISEQ_TEMPLATE, scsiseq1);
-			scsiseq1 = ahd_inb(ahd, SCSISEQ1);
-			scsiseq1 |= ENSELI;
-			ahd_outb(ahd, SCSISEQ1, scsiseq1);
-		}
-		ahd_unpause(ahd);
-		ahd_unlock(ahd, &s);
-		ccb->ccb_h.status = CAM_REQ_CMP;
-		xpt_print_path(ccb->ccb_h.path);
-		printf("Lun now enabled for target mode\n");
-	} else {
-		struct scb *scb;
-		int i, empty;
-
-		if (lstate == NULL) {
-			ccb->ccb_h.status = CAM_LUN_INVALID;
-			return;
-		}
-
-		ahd_lock(ahd, &s);
-		
-		ccb->ccb_h.status = CAM_REQ_CMP;
-		LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) {
-			struct ccb_hdr *ccbh;
-
-			ccbh = &scb->io_ctx->ccb_h;
-			if (ccbh->func_code == XPT_CONT_TARGET_IO
-			 && !xpt_path_comp(ccbh->path, ccb->ccb_h.path)){
-				printf("CTIO pending\n");
-				ccb->ccb_h.status = CAM_REQ_INVALID;
-				ahd_unlock(ahd, &s);
-				return;
-			}
-		}
-
-		if (SLIST_FIRST(&lstate->accept_tios) != NULL) {
-			printf("ATIOs pending\n");
-			ccb->ccb_h.status = CAM_REQ_INVALID;
-		}
-
-		if (SLIST_FIRST(&lstate->immed_notifies) != NULL) {
-			printf("INOTs pending\n");
-			ccb->ccb_h.status = CAM_REQ_INVALID;
-		}
-
-		if (ccb->ccb_h.status != CAM_REQ_CMP) {
-			ahd_unlock(ahd, &s);
-			return;
-		}
-
-		xpt_print_path(ccb->ccb_h.path);
-		printf("Target mode disabled\n");
-		xpt_free_path(lstate->path);
-		free(lstate, M_DEVBUF);
-
-		ahd_pause(ahd);
-		/* Can we clean up the target too? */
-		if (target != CAM_TARGET_WILDCARD) {
-			tstate->enabled_luns[lun] = NULL;
-			ahd->enabled_luns--;
-			for (empty = 1, i = 0; i < 8; i++)
-				if (tstate->enabled_luns[i] != NULL) {
-					empty = 0;
-					break;
-				}
-
-			if (empty) {
-				ahd_free_tstate(ahd, target, channel,
-						/*force*/FALSE);
-				if (ahd->features & AHD_MULTI_TID) {
-					u_int targid_mask;
-
-					targid_mask = ahd_inb(ahd, TARGID)
-						    | (ahd_inb(ahd, TARGID + 1)
-						       << 8);
-
-					targid_mask &= ~target_mask;
-					ahd_outb(ahd, TARGID, targid_mask);
-					ahd_outb(ahd, TARGID+1,
-					 	 (targid_mask >> 8));
-					ahd_update_scsiid(ahd, targid_mask);
-				}
-			}
-		} else {
-
-			ahd->black_hole = NULL;
-
-			/*
-			 * We can't allow selections without
-			 * our black hole device.
-			 */
-			empty = TRUE;
-		}
-		if (ahd->enabled_luns == 0) {
-			/* Disallow select-in */
-			u_int scsiseq1;
-
-			scsiseq1 = ahd_inb(ahd, SCSISEQ_TEMPLATE);
-			scsiseq1 &= ~ENSELI;
-			ahd_outb(ahd, SCSISEQ_TEMPLATE, scsiseq1);
-			scsiseq1 = ahd_inb(ahd, SCSISEQ1);
-			scsiseq1 &= ~ENSELI;
-			ahd_outb(ahd, SCSISEQ1, scsiseq1);
-
-			if ((ahd->features & AHD_MULTIROLE) == 0) {
-				printf("Configuring Initiator Mode\n");
-				ahd->flags &= ~AHD_TARGETROLE;
-				ahd->flags |= AHD_INITIATORROLE;
-				ahd_pause(ahd);
-				ahd_loadseq(ahd);
-			}
-		}
-		ahd_unpause(ahd);
-		ahd_unlock(ahd, &s);
-	}
-#endif
-}
-
-static void
-ahd_update_scsiid(struct ahd_softc *ahd, u_int targid_mask)
-{
-#if NOT_YET
-	u_int scsiid_mask;
-	u_int scsiid;
-
-	if ((ahd->features & AHD_MULTI_TID) == 0)
-		panic("ahd_update_scsiid called on non-multitid unit\n");
-
-	/*
-	 * Since we will rely on the TARGID mask
-	 * for selection enables, ensure that OID
-	 * in SCSIID is not set to some other ID
-	 * that we don't want to allow selections on.
-	 */
-	if ((ahd->features & AHD_ULTRA2) != 0)
-		scsiid = ahd_inb(ahd, SCSIID_ULTRA2);
-	else
-		scsiid = ahd_inb(ahd, SCSIID);
-	scsiid_mask = 0x1 << (scsiid & OID);
-	if ((targid_mask & scsiid_mask) == 0) {
-		u_int our_id;
-
-		/* ffs counts from 1 */
-		our_id = ffs(targid_mask);
-		if (our_id == 0)
-			our_id = ahd->our_id;
-		else
-			our_id--;
-		scsiid &= TID;
-		scsiid |= our_id;
-	}
-	if ((ahd->features & AHD_ULTRA2) != 0)
-		ahd_outb(ahd, SCSIID_ULTRA2, scsiid);
-	else
-		ahd_outb(ahd, SCSIID, scsiid);
-#endif
-}
-
-void
-ahd_run_tqinfifo(struct ahd_softc *ahd, int paused)
-{
-	struct target_cmd *cmd;
-
-	ahd_sync_tqinfifo(ahd, BUS_DMASYNC_POSTREAD);
-	while ((cmd = &ahd->targetcmds[ahd->tqinfifonext])->cmd_valid != 0) {
-
-		/*
-		 * Only advance through the queue if we
-		 * have the resources to process the command.
-		 */
-		if (ahd_handle_target_cmd(ahd, cmd) != 0)
-			break;
-
-		cmd->cmd_valid = 0;
-		ahd_dmamap_sync(ahd, ahd->shared_data_dmat,
-				ahd->shared_data_dmamap,
-				ahd_targetcmd_offset(ahd, ahd->tqinfifonext),
-				sizeof(struct target_cmd),
-				BUS_DMASYNC_PREREAD);
-		ahd->tqinfifonext++;
-
-		/*
-		 * Lazily update our position in the target mode incoming
-		 * command queue as seen by the sequencer.
-		 */
-		if ((ahd->tqinfifonext & (HOST_TQINPOS - 1)) == 1) {
-			u_int hs_mailbox;
-
-			hs_mailbox = ahd_inb(ahd, HS_MAILBOX);
-			hs_mailbox &= ~HOST_TQINPOS;
-			hs_mailbox |= ahd->tqinfifonext & HOST_TQINPOS;
-			ahd_outb(ahd, HS_MAILBOX, hs_mailbox);
-		}
-	}
-}
-
-static int
-ahd_handle_target_cmd(struct ahd_softc *ahd, struct target_cmd *cmd)
-{
-	struct	  ahd_tmode_tstate *tstate;
-	struct	  ahd_tmode_lstate *lstate;
-	struct	  ccb_accept_tio *atio;
-	uint8_t *byte;
-	int	  initiator;
-	int	  target;
-	int	  lun;
-
-	initiator = SCSIID_TARGET(ahd, cmd->scsiid);
-	target = SCSIID_OUR_ID(cmd->scsiid);
-	lun    = (cmd->identify & MSG_IDENTIFY_LUNMASK);
-
-	byte = cmd->bytes;
-	tstate = ahd->enabled_targets[target];
-	lstate = NULL;
-	if (tstate != NULL)
-		lstate = tstate->enabled_luns[lun];
-
-	/*
-	 * Commands for disabled luns go to the black hole driver.
-	 */
-	if (lstate == NULL)
-		lstate = ahd->black_hole;
-
-	atio = (struct ccb_accept_tio*)SLIST_FIRST(&lstate->accept_tios);
-	if (atio == NULL) {
-		ahd->flags |= AHD_TQINFIFO_BLOCKED;
-		/*
-		 * Wait for more ATIOs from the peripheral driver for this lun.
-		 */
-		return (1);
-	} else
-		ahd->flags &= ~AHD_TQINFIFO_BLOCKED;
-#ifdef AHD_DEBUG
-	if ((ahd_debug & AHD_SHOW_TQIN) != 0)
-		printf("Incoming command from %d for %d:%d%s\n",
-		       initiator, target, lun,
-		       lstate == ahd->black_hole ? "(Black Holed)" : "");
-#endif
-	SLIST_REMOVE_HEAD(&lstate->accept_tios, sim_links.sle);
-
-	if (lstate == ahd->black_hole) {
-		/* Fill in the wildcards */
-		atio->ccb_h.target_id = target;
-		atio->ccb_h.target_lun = lun;
-	}
-
-	/*
-	 * Package it up and send it off to
-	 * whomever has this lun enabled.
-	 */
-	atio->sense_len = 0;
-	atio->init_id = initiator;
-	if (byte[0] != 0xFF) {
-		/* Tag was included */
-		atio->tag_action = *byte++;
-		atio->tag_id = *byte++;
-		atio->ccb_h.flags = CAM_TAG_ACTION_VALID;
-	} else {
-		atio->ccb_h.flags = 0;
-	}
-	byte++;
-
-	/* Okay.  Now determine the cdb size based on the command code */
-	switch (*byte >> CMD_GROUP_CODE_SHIFT) {
-	case 0:
-		atio->cdb_len = 6;
-		break;
-	case 1:
-	case 2:
-		atio->cdb_len = 10;
-		break;
-	case 4:
-		atio->cdb_len = 16;
-		break;
-	case 5:
-		atio->cdb_len = 12;
-		break;
-	case 3:
-	default:
-		/* Only copy the opcode. */
-		atio->cdb_len = 1;
-		printf("Reserved or VU command code type encountered\n");
-		break;
-	}
-	
-	memcpy(atio->cdb_io.cdb_bytes, byte, atio->cdb_len);
-
-	atio->ccb_h.status |= CAM_CDB_RECVD;
-
-	if ((cmd->identify & MSG_IDENTIFY_DISCFLAG) == 0) {
-		/*
-		 * We weren't allowed to disconnect.
-		 * We're hanging on the bus until a
-		 * continue target I/O comes in response
-		 * to this accept tio.
-		 */
-#ifdef AHD_DEBUG
-		if ((ahd_debug & AHD_SHOW_TQIN) != 0)
-			printf("Received Immediate Command %d:%d:%d - %p\n",
-			       initiator, target, lun, ahd->pending_device);
-#endif
-		ahd->pending_device = lstate;
-		ahd_freeze_ccb((union ccb *)atio);
-		atio->ccb_h.flags |= CAM_DIS_DISCONNECT;
-	}
-	xpt_done((union ccb*)atio);
-	return (0);
-}
-
-#endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aic79xx_inline.h linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx_inline.h
--- linux-2.4.21/drivers/scsi/aic79xx/aic79xx_inline.h	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx_inline.h	2003-06-26 21:43:11.000000000 +0000
@@ -1,950 +0,0 @@
-/*
- * Inline routines shareable across OS platforms.
- *
- * Copyright (c) 1994-2001 Justin T. Gibbs.
- * Copyright (c) 2000-2003 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: //depot/aic7xxx/aic7xxx/aic79xx_inline.h#41 $
- *
- * $FreeBSD$
- */
-
-#ifndef _AIC79XX_INLINE_H_
-#define _AIC79XX_INLINE_H_
-
-/******************************** Debugging ***********************************/
-static __inline char *ahd_name(struct ahd_softc *ahd);
-
-static __inline char *
-ahd_name(struct ahd_softc *ahd)
-{
-	return (ahd->name);
-}
-
-/************************ Sequencer Execution Control *************************/
-static __inline void ahd_known_modes(struct ahd_softc *ahd,
-				     ahd_mode src, ahd_mode dst);
-static __inline ahd_mode_state ahd_build_mode_state(struct ahd_softc *ahd,
-						    ahd_mode src,
-						    ahd_mode dst);
-static __inline void ahd_extract_mode_state(struct ahd_softc *ahd,
-					    ahd_mode_state state,
-					    ahd_mode *src, ahd_mode *dst);
-static __inline void ahd_set_modes(struct ahd_softc *ahd, ahd_mode src,
-				   ahd_mode dst);
-static __inline void ahd_update_modes(struct ahd_softc *ahd);
-static __inline void ahd_assert_modes(struct ahd_softc *ahd, ahd_mode srcmode,
-				      ahd_mode dstmode, const char *file,
-				      int line);
-static __inline ahd_mode_state ahd_save_modes(struct ahd_softc *ahd);
-static __inline void ahd_restore_modes(struct ahd_softc *ahd,
-				       ahd_mode_state state);
-static __inline int  ahd_is_paused(struct ahd_softc *ahd);
-static __inline void ahd_pause(struct ahd_softc *ahd);
-static __inline void ahd_unpause(struct ahd_softc *ahd);
-
-static __inline void
-ahd_known_modes(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
-{
-	ahd->src_mode = src;
-	ahd->dst_mode = dst;
-	ahd->saved_src_mode = src;
-	ahd->saved_dst_mode = dst;
-}
-
-static __inline ahd_mode_state
-ahd_build_mode_state(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
-{
-	return ((src << SRC_MODE_SHIFT) | (dst << DST_MODE_SHIFT));
-}
-
-static __inline void
-ahd_extract_mode_state(struct ahd_softc *ahd, ahd_mode_state state,
-		       ahd_mode *src, ahd_mode *dst)
-{
-	*src = (state & SRC_MODE) >> SRC_MODE_SHIFT;
-	*dst = (state & DST_MODE) >> DST_MODE_SHIFT;
-}
-
-static __inline void
-ahd_set_modes(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
-{
-	if (ahd->src_mode == src && ahd->dst_mode == dst)
-		return;
-#ifdef AHD_DEBUG
-	if (ahd->src_mode == AHD_MODE_UNKNOWN
-	 || ahd->dst_mode == AHD_MODE_UNKNOWN)
-		panic("Setting mode prior to saving it.\n");
-	if ((ahd_debug & AHD_SHOW_MODEPTR) != 0)
-		printf("%s: Setting mode 0x%x\n", ahd_name(ahd),
-		       ahd_build_mode_state(ahd, src, dst));
-#endif
-	ahd_outb(ahd, MODE_PTR, ahd_build_mode_state(ahd, src, dst));
-	ahd->src_mode = src;
-	ahd->dst_mode = dst;
-}
-
-static __inline void
-ahd_update_modes(struct ahd_softc *ahd)
-{
-	ahd_mode_state mode_ptr;
-	ahd_mode src;
-	ahd_mode dst;
-
-	mode_ptr = ahd_inb(ahd, MODE_PTR);
-#ifdef AHD_DEBUG
-	if ((ahd_debug & AHD_SHOW_MODEPTR) != 0)
-		printf("Reading mode 0x%x\n", mode_ptr);
-#endif
-	ahd_extract_mode_state(ahd, mode_ptr, &src, &dst);
-	ahd_known_modes(ahd, src, dst);
-}
-
-static __inline void
-ahd_assert_modes(struct ahd_softc *ahd, ahd_mode srcmode,
-		 ahd_mode dstmode, const char *file, int line)
-{
-#ifdef AHD_DEBUG
-	if ((srcmode & AHD_MK_MSK(ahd->src_mode)) == 0
-	 || (dstmode & AHD_MK_MSK(ahd->dst_mode)) == 0) {
-		panic("%s:%s:%d: Mode assertion failed.\n",
-		       ahd_name(ahd), file, line);
-	}
-#endif
-}
-
-static __inline ahd_mode_state
-ahd_save_modes(struct ahd_softc *ahd)
-{
-	if (ahd->src_mode == AHD_MODE_UNKNOWN
-	 || ahd->dst_mode == AHD_MODE_UNKNOWN)
-		ahd_update_modes(ahd);
-
-	return (ahd_build_mode_state(ahd, ahd->src_mode, ahd->dst_mode));
-}
-
-static __inline void
-ahd_restore_modes(struct ahd_softc *ahd, ahd_mode_state state)
-{
-	ahd_mode src;
-	ahd_mode dst;
-
-	ahd_extract_mode_state(ahd, state, &src, &dst);
-	ahd_set_modes(ahd, src, dst);
-}
-
-#define AHD_ASSERT_MODES(ahd, source, dest) \
-	ahd_assert_modes(ahd, source, dest, __FILE__, __LINE__);
-
-/*
- * Determine whether the sequencer has halted code execution.
- * Returns non-zero status if the sequencer is stopped.
- */
-static __inline int
-ahd_is_paused(struct ahd_softc *ahd)
-{
-	return ((ahd_inb(ahd, HCNTRL) & PAUSE) != 0);
-}
-
-/*
- * Request that the sequencer stop and wait, indefinitely, for it
- * to stop.  The sequencer will only acknowledge that it is paused
- * once it has reached an instruction boundary and PAUSEDIS is
- * cleared in the SEQCTL register.  The sequencer may use PAUSEDIS
- * for critical sections.
- */
-static __inline void
-ahd_pause(struct ahd_softc *ahd)
-{
-	ahd_outb(ahd, HCNTRL, ahd->pause);
-
-	/*
-	 * Since the sequencer can disable pausing in a critical section, we
-	 * must loop until it actually stops.
-	 */
-	while (ahd_is_paused(ahd) == 0)
-		;
-}
-
-/*
- * Allow the sequencer to continue program execution.
- * We check here to ensure that no additional interrupt
- * sources that would cause the sequencer to halt have been
- * asserted.  If, for example, a SCSI bus reset is detected
- * while we are fielding a different, pausing, interrupt type,
- * we don't want to release the sequencer before going back
- * into our interrupt handler and dealing with this new
- * condition.
- */
-static __inline void
-ahd_unpause(struct ahd_softc *ahd)
-{
-	/*
-	 * Automatically restore our modes to those saved
-	 * prior to the first change of the mode.
-	 */
-	if (ahd->saved_src_mode != AHD_MODE_UNKNOWN
-	 && ahd->saved_dst_mode != AHD_MODE_UNKNOWN) {
-		if ((ahd->flags & AHD_UPDATE_PEND_CMDS) != 0)
-			ahd_reset_cmds_pending(ahd);
-		ahd_set_modes(ahd, ahd->saved_src_mode, ahd->saved_dst_mode);
-	}
-
-	if ((ahd_inb(ahd, INTSTAT) & ~(SWTMINT | CMDCMPLT)) == 0)
-		ahd_outb(ahd, HCNTRL, ahd->unpause);
-
-	ahd_known_modes(ahd, AHD_MODE_UNKNOWN, AHD_MODE_UNKNOWN);
-}
-
-/*********************** Scatter Gather List Handling *************************/
-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);
-static __inline void	 ahd_setup_scb_common(struct ahd_softc *ahd,
-					      struct scb *scb);
-static __inline void	 ahd_setup_data_scb(struct ahd_softc *ahd,
-					    struct scb *scb);
-static __inline void	 ahd_setup_noxfer_scb(struct ahd_softc *ahd,
-					      struct scb *scb);
-
-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)
-{
-	scb->sg_count++;
-	if (sizeof(bus_addr_t) > 4
-	 && (ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
-		struct ahd_dma64_seg *sg;
-
-		sg = (struct ahd_dma64_seg *)sgptr;
-		sg->addr = ahd_htole64(addr);
-		sg->len = ahd_htole32(len | (last ? AHD_DMA_LAST_SEG : 0));
-		return (sg + 1);
-	} else {
-		struct ahd_dma_seg *sg;
-
-		sg = (struct ahd_dma_seg *)sgptr;
-		sg->addr = ahd_htole32(addr & 0xFFFFFFFF);
-		sg->len = ahd_htole32(len | ((addr >> 8) & 0x7F000000)
-				    | (last ? AHD_DMA_LAST_SEG : 0));
-		return (sg + 1);
-	}
-}
-
-static __inline void
-ahd_setup_scb_common(struct ahd_softc *ahd, struct scb *scb)
-{
-	/* XXX Handle target mode SCBs. */
-	scb->crc_retry_count = 0;
-	if ((scb->flags & SCB_PACKETIZED) != 0) {
-		/* XXX what about ACA??  It is type 4, but TAG_TYPE == 0x3. */
-		scb->hscb->task_attribute= scb->hscb->control & SCB_TAG_TYPE;
-		/*
-		 * For Rev A short lun workaround.
-		 */
-		scb->hscb->pkt_long_lun[6] = scb->hscb->lun;
-	}
-
-	if (scb->hscb->cdb_len <= MAX_CDB_LEN_WITH_SENSE_ADDR
-	 || (scb->hscb->cdb_len & SCB_CDB_LEN_PTR) != 0)
-		scb->hscb->shared_data.idata.cdb_plus_saddr.sense_addr =
-		    ahd_htole32(scb->sense_busaddr);
-}
-
-static __inline void
-ahd_setup_data_scb(struct ahd_softc *ahd, struct scb *scb)
-{
-	/*
-	 * Copy the first SG into the "current" data ponter area.
-	 */
-	if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
-		struct ahd_dma64_seg *sg;
-
-		sg = (struct ahd_dma64_seg *)scb->sg_list;
-		scb->hscb->dataptr = sg->addr;
-		scb->hscb->datacnt = sg->len;
-	} else {
-		struct ahd_dma_seg *sg;
-
-		sg = (struct ahd_dma_seg *)scb->sg_list;
-		scb->hscb->dataptr = sg->addr;
-		if ((ahd->flags & AHD_39BIT_ADDRESSING) != 0) {
-			uint64_t high_addr;
-
-			high_addr = ahd_le32toh(sg->len) & 0x7F000000;
-			scb->hscb->dataptr |= ahd_htole64(high_addr << 8);
-		}
-		scb->hscb->datacnt = sg->len;
-	}
-	/*
-	 * Note where to find the SG entries in bus space.
-	 * We also set the full residual flag which the 
-	 * sequencer will clear as soon as a data transfer
-	 * occurs.
-	 */
-	scb->hscb->sgptr = ahd_htole32(scb->sg_list_busaddr|SG_FULL_RESID);
-}
-
-static __inline void
-ahd_setup_noxfer_scb(struct ahd_softc *ahd, struct scb *scb)
-{
-	scb->hscb->sgptr = ahd_htole32(SG_LIST_NULL);
-	scb->hscb->dataptr = 0;
-	scb->hscb->datacnt = 0;
-}
-
-/************************** Memory mapping routines ***************************/
-static __inline size_t	ahd_sg_size(struct ahd_softc *ahd);
-static __inline void *
-			ahd_sg_bus_to_virt(struct ahd_softc *ahd,
-					   struct scb *scb,
-					   uint32_t sg_busaddr);
-static __inline uint32_t
-			ahd_sg_virt_to_bus(struct ahd_softc *ahd,
-					   struct scb *scb,
-					   void *sg);
-static __inline void	ahd_sync_scb(struct ahd_softc *ahd,
-				     struct scb *scb, int op);
-static __inline void	ahd_sync_sglist(struct ahd_softc *ahd,
-					struct scb *scb, int op);
-static __inline void	ahd_sync_sense(struct ahd_softc *ahd,
-				       struct scb *scb, int op);
-static __inline uint32_t
-			ahd_targetcmd_offset(struct ahd_softc *ahd,
-					     u_int index);
-
-static __inline size_t
-ahd_sg_size(struct ahd_softc *ahd)
-{
-	if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0)
-		return (sizeof(struct ahd_dma64_seg));
-	return (sizeof(struct ahd_dma_seg));
-}
-
-static __inline void *
-ahd_sg_bus_to_virt(struct ahd_softc *ahd, struct scb *scb, uint32_t sg_busaddr)
-{
-	bus_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));
-	return ((uint8_t *)scb->sg_list + sg_offset);
-}
-
-static __inline uint32_t
-ahd_sg_virt_to_bus(struct ahd_softc *ahd, struct scb *scb, void *sg)
-{
-	bus_addr_t sg_offset;
-
-	/* sg_list_phys points to entry 1, not 0 */
-	sg_offset = ((uint8_t *)sg - (uint8_t *)scb->sg_list)
-		  - ahd_sg_size(ahd);
-
-	return (scb->sg_list_busaddr + sg_offset);
-}
-
-static __inline void
-ahd_sync_scb(struct ahd_softc *ahd, struct scb *scb, int op)
-{
-	ahd_dmamap_sync(ahd, ahd->scb_data.hscb_dmat,
-			scb->hscb_map->dmamap,
-			/*offset*/(uint8_t*)scb->hscb - scb->hscb_map->vaddr,
-			/*len*/sizeof(*scb->hscb), op);
-}
-
-static __inline void
-ahd_sync_sglist(struct ahd_softc *ahd, struct scb *scb, int op)
-{
-	if (scb->sg_count == 0)
-		return;
-
-	ahd_dmamap_sync(ahd, ahd->scb_data.sg_dmat,
-			scb->sg_map->dmamap,
-			/*offset*/scb->sg_list_busaddr - ahd_sg_size(ahd),
-			/*len*/ahd_sg_size(ahd) * scb->sg_count, op);
-}
-
-static __inline void
-ahd_sync_sense(struct ahd_softc *ahd, struct scb *scb, int op)
-{
-	ahd_dmamap_sync(ahd, ahd->scb_data.sense_dmat,
-			scb->sense_map->dmamap,
-			/*offset*/scb->sense_busaddr,
-			/*len*/AHD_SENSE_BUFSIZE, op);
-}
-
-static __inline uint32_t
-ahd_targetcmd_offset(struct ahd_softc *ahd, u_int index)
-{
-	return (((uint8_t *)&ahd->targetcmds[index])
-	       - (uint8_t *)ahd->qoutfifo);
-}
-
-/*********************** Miscelaneous Support Functions ***********************/
-static __inline void	ahd_complete_scb(struct ahd_softc *ahd,
-					 struct scb *scb);
-static __inline void	ahd_update_residual(struct ahd_softc *ahd,
-					    struct scb *scb);
-static __inline struct ahd_initiator_tinfo *
-			ahd_fetch_transinfo(struct ahd_softc *ahd,
-					    char channel, u_int our_id,
-					    u_int remote_id,
-					    struct ahd_tmode_tstate **tstate);
-static __inline uint16_t
-			ahd_inw(struct ahd_softc *ahd, u_int port);
-static __inline void	ahd_outw(struct ahd_softc *ahd, u_int port,
-				 u_int value);
-static __inline uint32_t
-			ahd_inl(struct ahd_softc *ahd, u_int port);
-static __inline void	ahd_outl(struct ahd_softc *ahd, u_int port,
-				 uint32_t value);
-static __inline uint64_t
-			ahd_inq(struct ahd_softc *ahd, u_int port);
-static __inline void	ahd_outq(struct ahd_softc *ahd, u_int port,
-				 uint64_t value);
-static __inline u_int	ahd_get_scbptr(struct ahd_softc *ahd);
-static __inline void	ahd_set_scbptr(struct ahd_softc *ahd, u_int scbptr);
-static __inline u_int	ahd_get_hnscb_qoff(struct ahd_softc *ahd);
-static __inline void	ahd_set_hnscb_qoff(struct ahd_softc *ahd, u_int value);
-static __inline u_int	ahd_get_hescb_qoff(struct ahd_softc *ahd);
-static __inline void	ahd_set_hescb_qoff(struct ahd_softc *ahd, u_int value);
-static __inline u_int	ahd_get_snscb_qoff(struct ahd_softc *ahd);
-static __inline void	ahd_set_snscb_qoff(struct ahd_softc *ahd, u_int value);
-static __inline u_int	ahd_get_sescb_qoff(struct ahd_softc *ahd);
-static __inline void	ahd_set_sescb_qoff(struct ahd_softc *ahd, u_int value);
-static __inline u_int	ahd_get_sdscb_qoff(struct ahd_softc *ahd);
-static __inline void	ahd_set_sdscb_qoff(struct ahd_softc *ahd, u_int value);
-static __inline u_int	ahd_inb_scbram(struct ahd_softc *ahd, u_int offset);
-static __inline u_int	ahd_inw_scbram(struct ahd_softc *ahd, u_int offset);
-static __inline uint32_t
-			ahd_inl_scbram(struct ahd_softc *ahd, u_int offset);
-static __inline void	ahd_swap_with_next_hscb(struct ahd_softc *ahd,
-						struct scb *scb);
-static __inline void	ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb);
-static __inline uint8_t *
-			ahd_get_sense_buf(struct ahd_softc *ahd,
-					  struct scb *scb);
-static __inline uint32_t
-			ahd_get_sense_bufaddr(struct ahd_softc *ahd,
-					      struct scb *scb);
-
-static __inline void
-ahd_complete_scb(struct ahd_softc *ahd, struct scb *scb)
-{
-	uint32_t sgptr;
-
-	sgptr = ahd_le32toh(scb->hscb->sgptr);
-	if ((sgptr & SG_STATUS_VALID) != 0)
-		ahd_handle_scb_status(ahd, scb);
-	else
-		ahd_done(ahd, scb);
-}
-
-/*
- * Determine whether the sequencer reported a residual
- * for this SCB/transaction.
- */
-static __inline void
-ahd_update_residual(struct ahd_softc *ahd, struct scb *scb)
-{
-	uint32_t sgptr;
-
-	sgptr = ahd_le32toh(scb->hscb->sgptr);
-	if ((sgptr & SG_STATUS_VALID) != 0)
-		ahd_calc_residual(ahd, scb);
-}
-
-/*
- * Return pointers to the transfer negotiation information
- * for the specified our_id/remote_id pair.
- */
-static __inline struct ahd_initiator_tinfo *
-ahd_fetch_transinfo(struct ahd_softc *ahd, char channel, u_int our_id,
-		    u_int remote_id, struct ahd_tmode_tstate **tstate)
-{
-	/*
-	 * Transfer data structures are stored from the perspective
-	 * of the target role.  Since the parameters for a connection
-	 * in the initiator role to a given target are the same as
-	 * when the roles are reversed, we pretend we are the target.
-	 */
-	if (channel == 'B')
-		our_id += 8;
-	*tstate = ahd->enabled_targets[our_id];
-	return (&(*tstate)->transinfo[remote_id]);
-}
-
-#define AHD_COPY_COL_IDX(dst, src)				\
-do {								\
-	dst->hscb->scsiid = src->hscb->scsiid;			\
-	dst->hscb->lun = src->hscb->lun;			\
-} while (0)
-
-static __inline uint16_t
-ahd_inw(struct ahd_softc *ahd, u_int port)
-{
-	return ((ahd_inb(ahd, port+1) << 8) | ahd_inb(ahd, port));
-}
-
-static __inline void
-ahd_outw(struct ahd_softc *ahd, u_int port, u_int value)
-{
-	ahd_outb(ahd, port, value & 0xFF);
-	ahd_outb(ahd, port+1, (value >> 8) & 0xFF);
-}
-
-static __inline uint32_t
-ahd_inl(struct ahd_softc *ahd, u_int port)
-{
-	return ((ahd_inb(ahd, port))
-	      | (ahd_inb(ahd, port+1) << 8)
-	      | (ahd_inb(ahd, port+2) << 16)
-	      | (ahd_inb(ahd, port+3) << 24));
-}
-
-static __inline void
-ahd_outl(struct ahd_softc *ahd, u_int port, uint32_t value)
-{
-	ahd_outb(ahd, port, (value) & 0xFF);
-	ahd_outb(ahd, port+1, ((value) >> 8) & 0xFF);
-	ahd_outb(ahd, port+2, ((value) >> 16) & 0xFF);
-	ahd_outb(ahd, port+3, ((value) >> 24) & 0xFF);
-}
-
-static __inline uint64_t
-ahd_inq(struct ahd_softc *ahd, u_int port)
-{
-	return ((ahd_inb(ahd, port))
-	      | (ahd_inb(ahd, port+1) << 8)
-	      | (ahd_inb(ahd, port+2) << 16)
-	      | (ahd_inb(ahd, port+3) << 24)
-	      | (((uint64_t)ahd_inb(ahd, port+4)) << 32)
-	      | (((uint64_t)ahd_inb(ahd, port+5)) << 40)
-	      | (((uint64_t)ahd_inb(ahd, port+6)) << 48)
-	      | (((uint64_t)ahd_inb(ahd, port+7)) << 56));
-}
-
-static __inline void
-ahd_outq(struct ahd_softc *ahd, u_int port, uint64_t value)
-{
-	ahd_outb(ahd, port, value & 0xFF);
-	ahd_outb(ahd, port+1, (value >> 8) & 0xFF);
-	ahd_outb(ahd, port+2, (value >> 16) & 0xFF);
-	ahd_outb(ahd, port+3, (value >> 24) & 0xFF);
-	ahd_outb(ahd, port+4, (value >> 32) & 0xFF);
-	ahd_outb(ahd, port+5, (value >> 40) & 0xFF);
-	ahd_outb(ahd, port+6, (value >> 48) & 0xFF);
-	ahd_outb(ahd, port+7, (value >> 56) & 0xFF);
-}
-
-static __inline u_int
-ahd_get_scbptr(struct ahd_softc *ahd)
-{
-	AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
-			 ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
-	return (ahd_inb(ahd, SCBPTR) | (ahd_inb(ahd, SCBPTR + 1) << 8));
-}
-
-static __inline void
-ahd_set_scbptr(struct ahd_softc *ahd, u_int scbptr)
-{
-	AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
-			 ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
-	ahd_outb(ahd, SCBPTR, scbptr & 0xFF);
-	ahd_outb(ahd, SCBPTR+1, (scbptr >> 8) & 0xFF);
-}
-
-static __inline u_int
-ahd_get_hnscb_qoff(struct ahd_softc *ahd)
-{
-	return (ahd_inw_atomic(ahd, HNSCB_QOFF));
-}
-
-static __inline void
-ahd_set_hnscb_qoff(struct ahd_softc *ahd, u_int value)
-{
-	ahd_outw_atomic(ahd, HNSCB_QOFF, value);
-}
-
-static __inline u_int
-ahd_get_hescb_qoff(struct ahd_softc *ahd)
-{
-	return (ahd_inb(ahd, HESCB_QOFF));
-}
-
-static __inline void
-ahd_set_hescb_qoff(struct ahd_softc *ahd, u_int value)
-{
-	ahd_outb(ahd, HESCB_QOFF, value);
-}
-
-static __inline u_int
-ahd_get_snscb_qoff(struct ahd_softc *ahd)
-{
-	u_int oldvalue;
-
-	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
-	oldvalue = ahd_inw(ahd, SNSCB_QOFF);
-	ahd_outw(ahd, SNSCB_QOFF, oldvalue);
-	return (oldvalue);
-}
-
-static __inline void
-ahd_set_snscb_qoff(struct ahd_softc *ahd, u_int value)
-{
-	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
-	ahd_outw(ahd, SNSCB_QOFF, value);
-}
-
-static __inline u_int
-ahd_get_sescb_qoff(struct ahd_softc *ahd)
-{
-	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
-	return (ahd_inb(ahd, SESCB_QOFF));
-}
-
-static __inline void
-ahd_set_sescb_qoff(struct ahd_softc *ahd, u_int value)
-{
-	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
-	ahd_outb(ahd, SESCB_QOFF, value);
-}
-
-static __inline u_int
-ahd_get_sdscb_qoff(struct ahd_softc *ahd)
-{
-	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
-	return (ahd_inb(ahd, SDSCB_QOFF) | (ahd_inb(ahd, SDSCB_QOFF + 1) << 8));
-}
-
-static __inline void
-ahd_set_sdscb_qoff(struct ahd_softc *ahd, u_int value)
-{
-	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
-	ahd_outb(ahd, SDSCB_QOFF, value & 0xFF);
-	ahd_outb(ahd, SDSCB_QOFF+1, (value >> 8) & 0xFF);
-}
-
-static __inline u_int
-ahd_inb_scbram(struct ahd_softc *ahd, u_int offset)
-{
-	u_int value;
-
-	/*
-	 * Workaround PCI-X Rev A. hardware bug.
-	 * After a host read of SCB memory, the chip
-	 * may become confused into thinking prefetch
-	 * was required.  This starts the discard timer
-	 * running and can cause an unexpected discard
-	 * timer interrupt.  The work around is to read
-	 * a normal register prior to the exhaustion of
-	 * the discard timer.  The mode pointer register
-	 * has no side effects and so serves well for
-	 * this purpose.
-	 *
-	 * Razor #528
-	 */
-	value = ahd_inb(ahd, offset);
-	ahd_inb(ahd, MODE_PTR);
-	return (value);
-}
-
-static __inline u_int
-ahd_inw_scbram(struct ahd_softc *ahd, u_int offset)
-{
-	return (ahd_inb_scbram(ahd, offset)
-	      | (ahd_inb_scbram(ahd, offset+1) << 8));
-}
-
-static __inline uint32_t
-ahd_inl_scbram(struct ahd_softc *ahd, u_int offset)
-{
-	return (ahd_inb_scbram(ahd, offset)
-	      | (ahd_inb_scbram(ahd, offset+1) << 8)
-	      | (ahd_inb_scbram(ahd, offset+2) << 16)
-	      | (ahd_inb_scbram(ahd, offset+3) << 24));
-}
-
-static __inline struct scb *
-ahd_lookup_scb(struct ahd_softc *ahd, u_int tag)
-{
-	struct scb* scb;
-
-	if (tag >= AHD_SCB_MAX)
-		return (NULL);
-	scb = ahd->scb_data.scbindex[tag];
-	if (scb != NULL)
-		ahd_sync_scb(ahd, scb,
-			     BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);
-	return (scb);
-}
-
-static __inline void
-ahd_swap_with_next_hscb(struct ahd_softc *ahd, struct scb *scb)
-{
-	struct hardware_scb *q_hscb;
-	uint32_t saved_hscb_busaddr;
-
-	/*
-	 * Our queuing method is a bit tricky.  The card
-	 * knows in advance which HSCB (by address) to download,
-	 * and we can't disappoint it.  To achieve this, the next
-	 * HSCB to download is saved off in ahd->next_queued_hscb.
-	 * When we are called to queue "an arbitrary scb",
-	 * we copy the contents of the incoming HSCB to the one
-	 * the sequencer knows about, swap HSCB pointers and
-	 * finally assign the SCB to the tag indexed location
-	 * in the scb_array.  This makes sure that we can still
-	 * locate the correct SCB by SCB_TAG.
-	 */
-	q_hscb = ahd->next_queued_hscb;
-	saved_hscb_busaddr = q_hscb->hscb_busaddr;
-	memcpy(q_hscb, scb->hscb, sizeof(*scb->hscb));
-	q_hscb->hscb_busaddr = saved_hscb_busaddr;
-	q_hscb->next_hscb_busaddr = scb->hscb->hscb_busaddr;
-
-	/* Now swap HSCB pointers. */
-	ahd->next_queued_hscb = scb->hscb;
-	scb->hscb = q_hscb;
-
-	/* Now define the mapping from tag to SCB in the scbindex */
-	ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = scb;
-}
-
-/*
- * Tell the sequencer about a new transaction to execute.
- */
-static __inline void
-ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb)
-{
-	ahd_swap_with_next_hscb(ahd, scb);
-
-	if (SCBID_IS_NULL(SCB_GET_TAG(scb)))
-		panic("Attempt to queue invalid SCB tag %x\n",
-		      SCB_GET_TAG(scb));
-
-	/*
-	 * Keep a history of SCBs we've downloaded in the qinfifo.
-	 */
-	ahd->qinfifo[AHD_QIN_WRAP(ahd->qinfifonext)] = SCB_GET_TAG(scb);
-	ahd->qinfifonext++;
-
-	if (scb->sg_count != 0)
-		ahd_setup_data_scb(ahd, scb);
-	else
-		ahd_setup_noxfer_scb(ahd, scb);
-	ahd_setup_scb_common(ahd, scb);
-
-	/*
-	 * Make sure our data is consistant from the
-	 * perspective of the adapter.
-	 */
-	ahd_sync_scb(ahd, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
-
-#ifdef AHD_DEBUG
-	if ((ahd_debug & AHD_SHOW_QUEUE) != 0) {
-		printf("%s: Queueing SCB 0x%x bus addr 0x%x - 0x%x%x/0x%x\n",
-		       ahd_name(ahd),
-		       SCB_GET_TAG(scb), scb->hscb->hscb_busaddr,
-		       (u_int)((scb->hscb->dataptr >> 32) & 0xFFFFFFFF),
-		       (u_int)(scb->hscb->dataptr & 0xFFFFFFFF),
-		       scb->hscb->datacnt);
-	}
-#endif
-	/* Tell the adapter about the newly queued SCB */
-	ahd_set_hnscb_qoff(ahd, ahd->qinfifonext);
-}
-
-static __inline uint8_t *
-ahd_get_sense_buf(struct ahd_softc *ahd, struct scb *scb)
-{
-	return (scb->sense_data);
-}
-
-static __inline uint32_t
-ahd_get_sense_bufaddr(struct ahd_softc *ahd, struct scb *scb)
-{
-	return (scb->sense_busaddr);
-}
-
-/************************** Interrupt Processing ******************************/
-static __inline void	ahd_sync_qoutfifo(struct ahd_softc *ahd, int op);
-static __inline void	ahd_sync_tqinfifo(struct ahd_softc *ahd, int op);
-static __inline u_int	ahd_check_cmdcmpltqueues(struct ahd_softc *ahd);
-static __inline void	ahd_intr(struct ahd_softc *ahd);
-
-static __inline void
-ahd_sync_qoutfifo(struct ahd_softc *ahd, int op)
-{
-	ahd_dmamap_sync(ahd, ahd->shared_data_dmat, ahd->shared_data_dmamap,
-			/*offset*/0, /*len*/AHC_SCB_MAX * sizeof(uint16_t), op);
-}
-
-static __inline void
-ahd_sync_tqinfifo(struct ahd_softc *ahd, int op)
-{
-#ifdef AHD_TARGET_MODE
-	if ((ahd->flags & AHD_TARGETROLE) != 0) {
-		ahd_dmamap_sync(ahd, ahd->shared_data_dmat,
-				ahd->shared_data_dmamap,
-				ahd_targetcmd_offset(ahd, 0),
-				sizeof(struct target_cmd) * AHD_TMODE_CMDS,
-				op);
-	}
-#endif
-}
-
-/*
- * See if the firmware has posted any completed commands
- * into our in-core command complete fifos.
- */
-#define AHD_RUN_QOUTFIFO 0x1
-#define AHD_RUN_TQINFIFO 0x2
-static __inline u_int
-ahd_check_cmdcmpltqueues(struct ahd_softc *ahd)
-{
-	u_int retval;
-
-	retval = 0;
-	ahd_dmamap_sync(ahd, ahd->shared_data_dmat, ahd->shared_data_dmamap,
-			/*offset*/ahd->qoutfifonext, /*len*/2,
-			BUS_DMASYNC_POSTREAD);
-	if ((ahd->qoutfifo[ahd->qoutfifonext]
-	     & QOUTFIFO_ENTRY_VALID_LE) == ahd->qoutfifonext_valid_tag)
-		retval |= AHD_RUN_QOUTFIFO;
-#ifdef AHD_TARGET_MODE
-	if ((ahd->flags & AHD_TARGETROLE) != 0
-	 && (ahd->flags & AHD_TQINFIFO_BLOCKED) == 0) {
-		ahd_dmamap_sync(ahd, ahd->shared_data_dmat,
-				ahd->shared_data_dmamap,
-				ahd_targetcmd_offset(ahd, ahd->tqinfifofnext),
-				/*len*/sizeof(struct target_cmd),
-				BUS_DMASYNC_POSTREAD);
-		if (ahd->targetcmds[ahd->tqinfifonext].cmd_valid != 0)
-			retval |= AHD_RUN_TQINFIFO;
-	}
-#endif
-	return (retval);
-}
-
-/*
- * Catch an interrupt from the adapter
- */
-static __inline void
-ahd_intr(struct ahd_softc *ahd)
-{
-	u_int	intstat;
-
-	if ((ahd->pause & INTEN) == 0) {
-		/*
-		 * Our interrupt is not enabled on the chip
-		 * and may be disabled for re-entrancy reasons,
-		 * so just return.  This is likely just a shared
-		 * interrupt.
-		 */
-		return;
-	}
-
-	/*
-	 * Instead of directly reading the interrupt status register,
-	 * infer the cause of the interrupt by checking our in-core
-	 * completion queues.  This avoids a costly PCI bus read in
-	 * most cases.
-	 */
-	if ((ahd->flags & AHD_ALL_INTERRUPTS) == 0
-	 && (ahd_check_cmdcmpltqueues(ahd) != 0))
-		intstat = CMDCMPLT;
-	else
-		intstat = ahd_inb(ahd, INTSTAT);
-
-	if (intstat & CMDCMPLT) {
-		ahd_outb(ahd, CLRINT, CLRCMDINT);
-
-		/*
-		 * Ensure that the chip sees that we've cleared
-		 * this interrupt before we walk the output fifo.
-		 * Otherwise, we may, due to posted bus writes,
-		 * clear the interrupt after we finish the scan,
-		 * and after the sequencer has added new entries
-		 * and asserted the interrupt again.
-		 */
-		if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) {
-			if (ahd_is_paused(ahd)) {
-				/*
-				 * Potentially lost SEQINT.
-				 * If SEQINTCODE is non-zero,
-				 * simulate the SEQINT.
-				 */
-				if (ahd_inb(ahd, SEQINTCODE) != NO_SEQINT)
-					intstat |= SEQINT;
-			}
-		} else {
-			ahd_flush_device_writes(ahd);
-		}
-		ahd_run_qoutfifo(ahd);
-		ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket]++;
-		ahd->cmdcmplt_total++;
-#ifdef AHD_TARGET_MODE
-		if ((ahd->flags & AHD_TARGETROLE) != 0)
-			ahd_run_tqinfifo(ahd, /*paused*/FALSE);
-#endif
-	}
-
-	if (intstat == 0xFF && (ahd->features & AHD_REMOVABLE) != 0)
-		/* Hot eject */
-		return;
-
-	if ((intstat & INT_PEND) == 0)
-		return;
-
-	if (intstat & HWERRINT) {
-		ahd_handle_hwerrint(ahd);
-		return;
-	}
-
-	if ((intstat & (PCIINT|SPLTINT)) != 0) {
-		ahd->bus_intr(ahd);
-		return;
-	}
-
-	if ((intstat & SEQINT) != 0)
-		ahd_handle_seqint(ahd, intstat);
-
-	if ((intstat & SCSIINT) != 0)
-		ahd_handle_scsiint(ahd, intstat);
-}
-
-#endif  /* _AIC79XX_INLINE_H_ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aic79xx_osm.c linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx_osm.c
--- linux-2.4.21/drivers/scsi/aic79xx/aic79xx_osm.c	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx_osm.c	2003-06-26 21:43:30.000000000 +0000
@@ -1,5322 +0,0 @@
-/*
- * Adaptec AIC79xx device driver for Linux.
- *
- * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#115 $
- *
- * --------------------------------------------------------------------------
- * Copyright (c) 1994-2000 Justin T. Gibbs.
- * Copyright (c) 1997-1999 Doug Ledford
- * Copyright (c) 2000-2003 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.
- */
-
-/*
- * This is the only file where module.h should
- * embed module global version info.
- */
-#define AHD_MODVERSION_FILE
-
-#include "aic79xx_osm.h"
-#include "aic79xx_inline.h"
-#include <scsi/scsicam.h>
-
-/*
- * Include aiclib.c as part of our
- * "module dependencies are hard" work around.
- */
-#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 */
-#endif
-
-#include <linux/mm.h>		/* For fetching system memory size */
-
-#define __KERNEL_SYSCALLS__
-
-#include <linux/unistd.h>
-static int errno;
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
-/*
- * Lock protecting manipulation of the ahd softc list.
- */
-spinlock_t ahd_list_spinlock;
-#endif
-
-#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
-
-/*
- * Bucket size for counting good commands in between bad ones.
- */
-#define AHD_LINUX_ERR_THRESH	1000
-
-/*
- * Set this to the delay in seconds after SCSI bus reset.
- * Note, we honor this only for the initial bus reset.
- * The scsi error recovery code performs its own bus settle
- * delay handling for error recovery actions.
- */
-#ifdef CONFIG_AIC79XX_RESET_DELAY_MS
-#define AIC79XX_RESET_DELAY CONFIG_AIC79XX_RESET_DELAY_MS
-#else
-#define AIC79XX_RESET_DELAY 5000
-#endif
-
-/*
- * To change the default number of tagged transactions allowed per-device,
- * add a line to the lilo.conf file like:
- * append="aic79xx=verbose,tag_info:{{32,32,32,32},{32,32,32,32}}"
- * which will result in the first four devices on the first two
- * controllers being set to a tagged queue depth of 32.
- *
- * The tag_commands is an array of 16 to allow for wide and twin adapters.
- * Twin adapters will use indexes 0-7 for channel 0, and indexes 8-15
- * for channel 1.
- */
-typedef struct {
-	uint16_t tag_commands[16];	/* Allow for wide/twin adapters. */
-} adapter_tag_info_t;
-
-/*
- * Modify this as you see fit for your system.
- *
- * 0			tagged queuing disabled
- * 1 <= n <= 253	n == max tags ever dispatched.
- *
- * The driver will throttle the number of commands dispatched to a
- * device if it returns queue full.  For devices with a fixed maximum
- * queue depth, the driver will eventually determine this depth and
- * lock it in (a console message is printed to indicate that a lock
- * has occurred).  On some devices, queue full is returned for a temporary
- * resource shortage.  These devices will return queue full at varying
- * depths.  The driver will throttle back when the queue fulls occur and
- * attempt to slowly increase the depth over time as the device recovers
- * from the resource shortage.
- *
- * In this example, the first line will disable tagged queueing for all
- * the devices on the first probed aic79xx adapter.
- *
- * The second line enables tagged queueing with 4 commands/LUN for IDs
- * (0, 2-11, 13-15), disables tagged queueing for ID 12, and tells the
- * driver to attempt to use up to 64 tags for ID 1.
- *
- * The third line is the same as the first line.
- *
- * The fourth line disables tagged queueing for devices 0 and 3.  It
- * enables tagged queueing for the other IDs, with 16 commands/LUN
- * for IDs 1 and 4, 127 commands/LUN for ID 8, and 4 commands/LUN for
- * IDs 2, 5-7, and 9-15.
- */
-
-/*
- * NOTE: The below structure is for reference only, the actual structure
- *       to modify in order to change things is just below this comment block.
-adapter_tag_info_t aic79xx_tag_info[] =
-{
-	{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
-	{{4, 64, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 4, 4, 4}},
-	{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
-	{{0, 16, 4, 0, 16, 4, 4, 4, 127, 4, 4, 4, 4, 4, 4, 4}}
-};
-*/
-
-#ifdef CONFIG_AIC79XX_CMDS_PER_DEVICE
-#define AIC79XX_CMDS_PER_DEVICE CONFIG_AIC79XX_CMDS_PER_DEVICE
-#else
-#define AIC79XX_CMDS_PER_DEVICE AHD_MAX_QUEUE
-#endif
-
-#define AIC79XX_CONFIGED_TAG_COMMANDS {					\
-	AIC79XX_CMDS_PER_DEVICE, AIC79XX_CMDS_PER_DEVICE,		\
-	AIC79XX_CMDS_PER_DEVICE, AIC79XX_CMDS_PER_DEVICE,		\
-	AIC79XX_CMDS_PER_DEVICE, AIC79XX_CMDS_PER_DEVICE,		\
-	AIC79XX_CMDS_PER_DEVICE, AIC79XX_CMDS_PER_DEVICE,		\
-	AIC79XX_CMDS_PER_DEVICE, AIC79XX_CMDS_PER_DEVICE,		\
-	AIC79XX_CMDS_PER_DEVICE, AIC79XX_CMDS_PER_DEVICE,		\
-	AIC79XX_CMDS_PER_DEVICE, AIC79XX_CMDS_PER_DEVICE,		\
-	AIC79XX_CMDS_PER_DEVICE, AIC79XX_CMDS_PER_DEVICE		\
-}
-
-/*
- * By default, use the number of commands specified by
- * the users kernel configuration.
- */
-static adapter_tag_info_t aic79xx_tag_info[] =
-{
-	{AIC79XX_CONFIGED_TAG_COMMANDS},
-	{AIC79XX_CONFIGED_TAG_COMMANDS},
-	{AIC79XX_CONFIGED_TAG_COMMANDS},
-	{AIC79XX_CONFIGED_TAG_COMMANDS},
-	{AIC79XX_CONFIGED_TAG_COMMANDS},
-	{AIC79XX_CONFIGED_TAG_COMMANDS},
-	{AIC79XX_CONFIGED_TAG_COMMANDS},
-	{AIC79XX_CONFIGED_TAG_COMMANDS},
-	{AIC79XX_CONFIGED_TAG_COMMANDS},
-	{AIC79XX_CONFIGED_TAG_COMMANDS},
-	{AIC79XX_CONFIGED_TAG_COMMANDS},
-	{AIC79XX_CONFIGED_TAG_COMMANDS},
-	{AIC79XX_CONFIGED_TAG_COMMANDS},
-	{AIC79XX_CONFIGED_TAG_COMMANDS},
-	{AIC79XX_CONFIGED_TAG_COMMANDS},
-	{AIC79XX_CONFIGED_TAG_COMMANDS}
-};
-
-/*
- * By default, read streaming is disabled.  In theory,
- * read streaming should enhance performance, but early
- * U320 drive firmware actually performs slower with
- * read streaming enabled.
- */
-#ifdef CONFIG_AIC79XX_ENABLE_RD_STRM
-#define AIC79XX_CONFIGED_RD_STRM 0xFFFF
-#else
-#define AIC79XX_CONFIGED_RD_STRM 0
-#endif
-
-static uint16_t aic79xx_rd_strm_info[] =
-{
-	AIC79XX_CONFIGED_RD_STRM,
-	AIC79XX_CONFIGED_RD_STRM,
-	AIC79XX_CONFIGED_RD_STRM,
-	AIC79XX_CONFIGED_RD_STRM,
-	AIC79XX_CONFIGED_RD_STRM,
-	AIC79XX_CONFIGED_RD_STRM,
-	AIC79XX_CONFIGED_RD_STRM,
-	AIC79XX_CONFIGED_RD_STRM,
-	AIC79XX_CONFIGED_RD_STRM,
-	AIC79XX_CONFIGED_RD_STRM,
-	AIC79XX_CONFIGED_RD_STRM,
-	AIC79XX_CONFIGED_RD_STRM,
-	AIC79XX_CONFIGED_RD_STRM,
-	AIC79XX_CONFIGED_RD_STRM,
-	AIC79XX_CONFIGED_RD_STRM,
-	AIC79XX_CONFIGED_RD_STRM
-};
-
-/*
- * DV option:
- *
- * positive value = DV Enabled
- * zero		  = DV Disabled
- * negative value = DV Default for adapter type/seeprom
- */
-#ifdef CONFIG_AIC79XX_DV_SETTING
-#define AIC79XX_CONFIGED_DV CONFIG_AIC79XX_DV_SETTING
-#else
-#define AIC79XX_CONFIGED_DV -1
-#endif
-
-static int8_t aic79xx_dv_settings[] =
-{
-	AIC79XX_CONFIGED_DV,
-	AIC79XX_CONFIGED_DV,
-	AIC79XX_CONFIGED_DV,
-	AIC79XX_CONFIGED_DV,
-	AIC79XX_CONFIGED_DV,
-	AIC79XX_CONFIGED_DV,
-	AIC79XX_CONFIGED_DV,
-	AIC79XX_CONFIGED_DV,
-	AIC79XX_CONFIGED_DV,
-	AIC79XX_CONFIGED_DV,
-	AIC79XX_CONFIGED_DV,
-	AIC79XX_CONFIGED_DV,
-	AIC79XX_CONFIGED_DV,
-	AIC79XX_CONFIGED_DV,
-	AIC79XX_CONFIGED_DV,
-	AIC79XX_CONFIGED_DV
-};
-
-/*
- * The I/O cell on the chip is very configurable in respect to its analog
- * characteristics.  Set the defaults here; they can be overriden with
- * the proper insmod parameters.
- */
-struct ahd_linux_iocell_opts
-{
-	uint8_t	precomp;
-	uint8_t	slewrate;
-	uint8_t amplitude;
-};
-#define AIC79XX_DEFAULT_PRECOMP		0xFF
-#define AIC79XX_DEFAULT_SLEWRATE	0xFF
-#define AIC79XX_DEFAULT_AMPLITUDE	0xFF
-#define AIC79XX_DEFAULT_IOOPTS			\
-{						\
-	AIC79XX_DEFAULT_PRECOMP,		\
-	AIC79XX_DEFAULT_SLEWRATE,		\
-	AIC79XX_DEFAULT_AMPLITUDE		\
-}
-#define AIC79XX_PRECOMP_INDEX	0
-#define AIC79XX_SLEWRATE_INDEX	1
-#define AIC79XX_AMPLITUDE_INDEX	2
-static struct ahd_linux_iocell_opts aic79xx_iocell_info[] =
-{
-	AIC79XX_DEFAULT_IOOPTS,
-	AIC79XX_DEFAULT_IOOPTS,
-	AIC79XX_DEFAULT_IOOPTS,
-	AIC79XX_DEFAULT_IOOPTS,
-	AIC79XX_DEFAULT_IOOPTS,
-	AIC79XX_DEFAULT_IOOPTS,
-	AIC79XX_DEFAULT_IOOPTS,
-	AIC79XX_DEFAULT_IOOPTS,
-	AIC79XX_DEFAULT_IOOPTS,
-	AIC79XX_DEFAULT_IOOPTS,
-	AIC79XX_DEFAULT_IOOPTS,
-	AIC79XX_DEFAULT_IOOPTS,
-	AIC79XX_DEFAULT_IOOPTS,
-	AIC79XX_DEFAULT_IOOPTS,
-	AIC79XX_DEFAULT_IOOPTS,
-	AIC79XX_DEFAULT_IOOPTS
-};
-
-/*
- * There should be a specific return value for this in scsi.h, but
- * it seems that most drivers ignore it.
- */
-#define DID_UNDERFLOW   DID_ERROR
-
-void
-ahd_print_path(struct ahd_softc *ahd, struct scb *scb)
-{
-	printk("(scsi%d:%c:%d:%d): ",
-	       ahd->platform_data->host->host_no,
-	       scb != NULL ? SCB_GET_CHANNEL(ahd, scb) : 'X',
-	       scb != NULL ? SCB_GET_TARGET(ahd, scb) : -1,
-	       scb != NULL ? SCB_GET_LUN(scb) : -1);
-}
-
-/*
- * XXX - these options apply unilaterally to _all_ adapters
- *       cards in the system.  This should be fixed.  Exceptions to this
- *       rule are noted in the comments.
- */
-
-/*
- * Skip the scsi bus reset.  Non 0 make us skip the reset at startup.  This
- * has no effect on any later resets that might occur due to things like
- * SCSI bus timeouts.
- */
-static uint32_t aic79xx_no_reset;
-
-/*
- * Certain PCI motherboards will scan PCI devices from highest to lowest,
- * others scan from lowest to highest, and they tend to do all kinds of
- * strange things when they come into contact with PCI bridge chips.  The
- * net result of all this is that the PCI card that is actually used to boot
- * the machine is very hard to detect.  Most motherboards go from lowest
- * PCI slot number to highest, and the first SCSI controller found is the
- * one you boot from.  The only exceptions to this are when a controller
- * has its BIOS disabled.  So, we by default sort all of our SCSI controllers
- * from lowest PCI slot number to highest PCI slot number.  We also force
- * all controllers with their BIOS disabled to the end of the list.  This
- * works on *almost* all computers.  Where it doesn't work, we have this
- * option.  Setting this option to non-0 will reverse the order of the sort
- * to highest first, then lowest, but will still leave cards with their BIOS
- * disabled at the very end.  That should fix everyone up unless there are
- * really strange cirumstances.
- */
-static int aic79xx_reverse_scan = 0;
-
-/*
- * Should we force EXTENDED translation on a controller.
- *     0 == Use whatever is in the SEEPROM or default to off
- *     1 == Use whatever is in the SEEPROM or default to on
- */
-static uint32_t aic79xx_extended = 0;
-
-/*
- * PCI bus parity checking of the Adaptec controllers.  This is somewhat
- * dubious at best.  To my knowledge, this option has never actually
- * solved a PCI parity problem, but on certain machines with broken PCI
- * chipset configurations, it can generate tons of false error messages.
- * It's included in the driver for completeness.
- *   0 = Shut off PCI parity check
- *  -1 = Normal polarity pci parity checking
- *   1 = reverse polarity pci parity checking
- *
- * NOTE: you can't actually pass -1 on the lilo prompt.  So, to set this
- * variable to -1 you would actually want to simply pass the variable
- * name without a number.  That will invert the 0 which will result in
- * -1.
- */
-static int aic79xx_pci_parity = 0;
-
-/*
- * There are lots of broken chipsets in the world.  Some of them will
- * violate the PCI spec when we issue byte sized memory writes to our
- * controller.  I/O mapped register access, if allowed by the given
- * platform, will work in almost all cases.
- */
-int aic79xx_allow_memio = 1;
-
-/*
- * aic79xx_detect() has been run, so register all device arrivals
- * immediately with the system rather than deferring to the sorted
- * attachment performed by aic79xx_detect().
- */
-int aic79xx_detect_complete;
-
-/*
- * So that we can set how long each device is given as a selection timeout.
- * The table of values goes like this:
- *   0 - 256ms
- *   1 - 128ms
- *   2 - 64ms
- *   3 - 32ms
- * We default to 256ms because some older devices need a longer time
- * to respond to initial selection.
- */
-static int aic79xx_seltime = 0x00;
-
-/*
- * Certain devices do not perform any aging on commands.  Should the
- * device be saturated by commands in one portion of the disk, it is
- * possible for transactions on far away sectors to never be serviced.
- * To handle these devices, we can periodically send an ordered tag to
- * force all outstanding transactions to be serviced prior to a new
- * transaction.
- */
-int aic79xx_periodic_otag;
-
-/*
- * Module information and settable options.
- */
-#ifdef MODULE
-static char *aic79xx = NULL;
-/*
- * Just in case someone uses commas to separate items on the insmod
- * command line, we define a dummy buffer here to avoid having insmod
- * write wild stuff into our code segment
- */
-static char dummy_buffer[60] = "Please don't trounce on me insmod!!\n";
-
-MODULE_AUTHOR("Maintainer: Justin T. Gibbs <gibbs@scsiguy.com>");
-MODULE_DESCRIPTION("Adaptec Aic77XX/78XX SCSI Host Bus Adapter driver");
-#ifdef MODULE_LICENSE
-MODULE_LICENSE("Dual BSD/GPL");
-#endif
-MODULE_PARM(aic79xx, "s");
-MODULE_PARM_DESC(aic79xx,
-"period delimited, options string.\n"
-"	verbose			Enable verbose/diagnostic logging\n"
-"	allow_memio		Allow device registers to be memory mapped\n"
-"	debug			Bitmask of debug values to enable\n"
-"	no_reset		Supress initial bus resets\n"
-"	extended		Enable extended geometry on all controllers\n"
-"	periodic_otag		Send an ordered tagged transaction\n"
-"				periodically to prevent tag starvation.\n"
-"				This may be required by some older disk\n"
-"				or drives/RAID arrays.\n"
-"	reverse_scan		Sort PCI devices highest Bus/Slot to lowest\n"
-"	tag_info:<tag_str>	Set per-target tag depth\n"
-"	global_tag_depth:<int>	Global tag depth for all targets on all buses\n"
-"	rd_strm:<rd_strm_masks> Set per-target read streaming setting.\n"
-"	dv:<dv_settings>	Set per-controller Domain Validation Setting.\n"
-"	slewrate:<slewrate_list>Set the signal slew rate (0-15).\n"
-"	precomp:<pcomp_list>	Set the signal precompensation (0-7).\n"
-"	amplitude:<int>		Set the signal amplitude (0-7).\n"
-"	seltime:<int>		Selection Timeout:\n"
-"				(0/256ms,1/128ms,2/64ms,3/32ms)\n"
-"\n"
-"	Sample /etc/modules.conf line:\n"
-"		Enable verbose logging\n"
-"		Set tag depth on Controller 2/Target 2 to 10 tags\n"
-"		Shorten the selection timeout to 128ms\n"
-"\n"
-"	options aic79xx='\"verbose.tag_info:{{}.{}.{..10}}.seltime:1\"'\n"
-"\n"
-"	Sample /etc/modules.conf line:\n"
-"		Change Read Streaming for Controller's 2 and 3\n"
-"\n"
-"	options aic79xx='\"rd_strm:{..0xFFF0.0xC0F0}\"'");
-#endif
-
-static void ahd_linux_handle_scsi_status(struct ahd_softc *,
-					 struct ahd_linux_device *,
-					 struct scb *);
-static void ahd_linux_queue_cmd_complete(struct ahd_softc *ahd,
-					 Scsi_Cmnd *cmd);
-static void ahd_linux_filter_inquiry(struct ahd_softc *ahd,
-				     struct ahd_devinfo *devinfo);
-static void ahd_linux_dev_timed_unfreeze(u_long arg);
-static void ahd_linux_sem_timeout(u_long arg);
-static void ahd_linux_initialize_scsi_bus(struct ahd_softc *ahd);
-static void ahd_linux_thread_run_complete_queue(struct ahd_softc *ahd);
-static void ahd_linux_start_dv(struct ahd_softc *ahd);
-static void ahd_linux_dv_timeout(struct scsi_cmnd *cmd);
-static int  ahd_linux_dv_thread(void *data);
-static void ahd_linux_dv_target(struct ahd_softc *ahd, u_int target);
-static void ahd_linux_dv_transition(struct ahd_softc *ahd,
-				    struct scsi_cmnd *cmd,
-				    struct ahd_devinfo *devinfo,
-				    struct ahd_linux_target *targ);
-static void ahd_linux_dv_fill_cmd(struct ahd_softc *ahd,
-				  struct scsi_cmnd *cmd,
-				  struct ahd_devinfo *devinfo);
-static void ahd_linux_dv_inq(struct ahd_softc *ahd,
-			     struct scsi_cmnd *cmd,
-			     struct ahd_devinfo *devinfo,
-			     struct ahd_linux_target *targ,
-			     u_int request_length);
-static void ahd_linux_dv_tur(struct ahd_softc *ahd,
-			     struct scsi_cmnd *cmd,
-			     struct ahd_devinfo *devinfo);
-static void ahd_linux_dv_rebd(struct ahd_softc *ahd,
-			      struct scsi_cmnd *cmd,
-			      struct ahd_devinfo *devinfo,
-			      struct ahd_linux_target *targ);
-static void ahd_linux_dv_web(struct ahd_softc *ahd,
-			     struct scsi_cmnd *cmd,
-			     struct ahd_devinfo *devinfo,
-			     struct ahd_linux_target *targ);
-static void ahd_linux_dv_reb(struct ahd_softc *ahd,
-			     struct scsi_cmnd *cmd,
-			     struct ahd_devinfo *devinfo,
-			     struct ahd_linux_target *targ);
-static void ahd_linux_dv_su(struct ahd_softc *ahd,
-			    struct scsi_cmnd *cmd,
-			    struct ahd_devinfo *devinfo,
-			    struct ahd_linux_target *targ);
-static __inline int
-	   ahd_linux_dv_fallback(struct ahd_softc *ahd,
-				 struct ahd_devinfo *devinfo);
-static int ahd_linux_fallback(struct ahd_softc *ahd,
-			      struct ahd_devinfo *devinfo);
-static __inline int ahd_linux_dv_fallback(struct ahd_softc *ahd,
-					  struct ahd_devinfo *devinfo);
-static void ahd_linux_dv_complete(Scsi_Cmnd *cmd);
-static void ahd_linux_generate_dv_pattern(struct ahd_linux_target *targ);
-static u_int ahd_linux_user_tagdepth(struct ahd_softc *ahd,
-				     struct ahd_devinfo *devinfo);
-static u_int ahd_linux_user_dv_setting(struct ahd_softc *ahd);
-static void ahd_linux_device_queue_depth(struct ahd_softc *ahd,
-					 struct ahd_linux_device *dev);
-static struct ahd_linux_target*	ahd_linux_alloc_target(struct ahd_softc*,
-						       u_int, u_int);
-static void			ahd_linux_free_target(struct ahd_softc*,
-						      struct ahd_linux_target*);
-static struct ahd_linux_device*	ahd_linux_alloc_device(struct ahd_softc*,
-						       struct ahd_linux_target*,
-						       u_int);
-static void			ahd_linux_free_device(struct ahd_softc*,
-						      struct ahd_linux_device*);
-static void ahd_linux_run_device_queue(struct ahd_softc*,
-				       struct ahd_linux_device*);
-static void ahd_linux_setup_tag_info(char *p, char *end, char *s);
-static void ahd_linux_setup_tag_info_global(char *p);
-static void ahd_linux_setup_rd_strm_info(char *p, char *end, char *s);
-static void ahd_linux_setup_dv(char *p, char *end, char *s);
-static void ahd_linux_setup_iocell_info(char *p, char *end, char *s, int index);
-static int ahd_linux_next_unit(void);
-static void ahd_runq_tasklet(unsigned long data);
-static int ahd_linux_halt(struct notifier_block *nb, u_long event, void *buf);
-static int aic79xx_setup(char *c);
-
-/****************************** Inlines ***************************************/
-static __inline void ahd_schedule_completeq(struct ahd_softc *ahd,
-					    struct ahd_cmd *acmd);
-static __inline void ahd_schedule_runq(struct ahd_softc *ahd);
-static __inline void ahd_setup_runq_tasklet(struct ahd_softc *ahd);
-static __inline void ahd_teardown_runq_tasklet(struct ahd_softc *ahd);
-static __inline struct ahd_linux_device*
-		     ahd_linux_get_device(struct ahd_softc *ahd, u_int channel,
-					  u_int target, u_int lun, int alloc);
-static struct ahd_cmd *ahd_linux_run_complete_queue(struct ahd_softc *ahd,
-						    struct ahd_cmd *acmd);
-static __inline void ahd_linux_check_device_queue(struct ahd_softc *ahd,
-						  struct ahd_linux_device *dev);
-static __inline struct ahd_linux_device *
-		     ahd_linux_next_device_to_run(struct ahd_softc *ahd);
-static __inline void ahd_linux_run_device_queues(struct ahd_softc *ahd);
-static __inline void ahd_linux_unmap_scb(struct ahd_softc*, struct scb*);
-
-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);
-
-static __inline void
-ahd_schedule_completeq(struct ahd_softc *ahd, struct ahd_cmd *acmd)
-{
-	while (acmd != NULL) {
-		struct ahd_completeq *completeq;
-		struct ahd_cmd *list_cmd;
-		struct ahd_cmd *next_cmd;
-
-		next_cmd = TAILQ_NEXT(acmd, acmd_links.tqe);
-		completeq = &ahd->platform_data->completeq;
-		list_cmd = TAILQ_FIRST(completeq);
-		while (list_cmd != NULL
-		    && acmd_scsi_cmd(list_cmd).serial_number
-		     < acmd_scsi_cmd(acmd).serial_number)
-			list_cmd = TAILQ_NEXT(list_cmd, acmd_links.tqe);
-		if (list_cmd != NULL)
-			TAILQ_INSERT_BEFORE(list_cmd, acmd, acmd_links.tqe);
-		else
-			TAILQ_INSERT_TAIL(completeq, acmd, acmd_links.tqe);
-		acmd = next_cmd;
-	}
-	if ((ahd->platform_data->flags & AHD_RUN_CMPLT_Q_TIMER) == 0) {
-		ahd->platform_data->flags |= AHD_RUN_CMPLT_Q_TIMER;
-		ahd->platform_data->completeq_timer.expires = jiffies;
-		add_timer(&ahd->platform_data->completeq_timer);
-	}
-}
-
-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*
-ahd_linux_get_device(struct ahd_softc *ahd, u_int channel, u_int target,
-		     u_int lun, int alloc)
-{
-	struct ahd_linux_target *targ;
-	struct ahd_linux_device *dev;
-	u_int target_offset;
-
-	target_offset = target;
-	if (channel != 0)
-		target_offset += 8;
-	targ = ahd->platform_data->targets[target_offset];
-	if (targ == NULL) {
-		if (alloc != 0) {
-			targ = ahd_linux_alloc_target(ahd, channel, target);
-			if (targ == NULL)
-				return (NULL);
-		} else
-			return (NULL);
-	}
-	dev = targ->devices[lun];
-	if (dev == NULL && alloc != 0)
-		dev = ahd_linux_alloc_device(ahd, targ, lun);
-	return (dev);
-}
-
-#define AHD_LINUX_MAX_RETURNED_ERRORS 4
-static struct ahd_cmd *
-ahd_linux_run_complete_queue(struct ahd_softc *ahd, struct ahd_cmd *acmd)
-{	
-	u_long	done_flags;
-	int	with_errors;
-
-	ahd_done_lock(ahd, &done_flags);
-	with_errors = 0;
-	while (acmd != NULL) {
-		Scsi_Cmnd *cmd;
-
-		cmd = &acmd_scsi_cmd(acmd);
-		acmd = TAILQ_NEXT(acmd, acmd_links.tqe);
-		cmd->host_scribble = NULL;
-		if (ahd_cmd_get_transaction_status(cmd) != DID_OK
-		 || (cmd->result & 0xFF) != SCSI_STATUS_OK)
-			with_errors++;
-
-		cmd->scsi_done(cmd);
-
-		if (with_errors > AHD_LINUX_MAX_RETURNED_ERRORS) {
-			/*
-			 * Linux uses stack recursion to requeue
-			 * commands that need to be retried.  Avoid
-			 * blowing out the stack by "spoon feeding"
-			 * commands that completed with error back
-			 * the operating system in case they are going
-			 * to be retried. "ick"
-			 */
-			break;
-		}
-	}
-	ahd_done_unlock(ahd, &done_flags);
-	return (acmd);
-}
-
-static __inline void
-ahd_linux_check_device_queue(struct ahd_softc *ahd,
-			     struct ahd_linux_device *dev)
-{
-	if ((dev->flags & AHD_DEV_FREEZE_TIL_EMPTY) != 0
-	 && dev->active == 0) {
-		dev->flags &= ~AHD_DEV_FREEZE_TIL_EMPTY;
-		dev->qfrozen--;
-	}
-
-	if (TAILQ_FIRST(&dev->busyq) == NULL
-	 || dev->openings == 0 || dev->qfrozen != 0)
-		return;
-
-	ahd_linux_run_device_queue(ahd, dev);
-}
-
-static __inline struct ahd_linux_device *
-ahd_linux_next_device_to_run(struct ahd_softc *ahd)
-{
-	
-	if ((ahd->flags & AHD_RESOURCE_SHORTAGE) != 0
-	 || (ahd->platform_data->qfrozen != 0
-	  && AHD_DV_SIMQ_FROZEN(ahd) == 0))
-		return (NULL);
-	return (TAILQ_FIRST(&ahd->platform_data->device_runq));
-}
-
-static __inline void
-ahd_linux_run_device_queues(struct ahd_softc *ahd)
-{
-	struct ahd_linux_device *dev;
-
-	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);
-	}
-}
-
-static __inline void
-ahd_linux_unmap_scb(struct ahd_softc *ahd, struct scb *scb)
-{
-	Scsi_Cmnd *cmd;
-	int direction;
-
-	cmd = scb->io_ctx;
-	direction = scsi_to_pci_dma_dir(cmd->sc_data_direction);
-	ahd_sync_sglist(ahd, scb, BUS_DMASYNC_POSTWRITE);
-	if (cmd->use_sg != 0) {
-		struct scatterlist *sg;
-
-		sg = (struct scatterlist *)cmd->request_buffer;
-		pci_unmap_sg(ahd->dev_softc, sg, cmd->use_sg, direction);
-	} else if (cmd->request_bufflen != 0) {
-		pci_unmap_single(ahd->dev_softc,
-				 scb->platform_data->buf_busaddr,
-				 cmd->request_bufflen, direction);
-	}
-}
-
-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)
-{
-	int	 consumed;
-
-	if ((scb->sg_count + 1) > AHD_NSEG)
-		panic("Too few segs for dma mapping.  "
-		      "Increase AHD_NSEG\n");
-
-	consumed = 1;
-	sg->addr = ahd_htole32(addr & 0xFFFFFFFF);
-	scb->platform_data->xfer_len += len;
-	if (sizeof(bus_addr_t) > 4
-	 && (ahd->flags & AHD_39BIT_ADDRESSING) != 0) {
-		/*
-		 * Due to DAC restrictions, we can't
-		 * cross a 4GB boundary.
-		 */
-		if ((addr ^ (addr + len - 1)) & ~0xFFFFFFFF) {
-			struct	 ahd_dma_seg *next_sg;
-			uint32_t next_len;
-
-			printf("Crossed Seg\n");
-			if ((scb->sg_count + 2) > AHD_NSEG)
-				panic("Too few segs for dma mapping.  "
-				      "Increase AHD_NSEG\n");
-
-			consumed++;
-			next_sg = sg + 1;
-			next_sg->addr = 0;
-			next_len = 0x100000000 - (addr & 0xFFFFFFFF);
-			len -= next_len;
-			next_len |= ((addr >> 8) + 0x1000000) & 0x7F000000;
-			next_sg->len = ahd_htole32(next_len);
-		}
-		len |= (addr >> 8) & 0x7F000000;
-	}
-	sg->len = ahd_htole32(len);
-	return (consumed);
-}
-
-/******************************** Macros **************************************/
-#define BUILD_SCSIID(ahd, cmd)						\
-	((((cmd)->device->id << TID_SHIFT) & TID) | (ahd)->our_id)
-
-/************************  Host template entry points *************************/
-static int	   ahd_linux_detect(Scsi_Host_Template *);
-static int	   ahd_linux_release(struct Scsi_Host *);
-static const char *ahd_linux_info(struct Scsi_Host *);
-static int	   ahd_linux_queue(Scsi_Cmnd *, void (*)(Scsi_Cmnd *));
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-static int	   ahd_linux_slave_alloc(Scsi_Device *);
-static int	   ahd_linux_slave_configure(Scsi_Device *);
-static void	   ahd_linux_slave_destroy(Scsi_Device *);
-static int	   ahd_linux_biosparam(struct scsi_device*,
-				       struct block_device*, sector_t, int[]);
-#else
-static void	   ahd_linux_select_queue_depth(struct Scsi_Host *host,
-						Scsi_Device *scsi_devs);
-static int	   ahd_linux_biosparam(Disk *, kdev_t, int[]);
-#endif
-static int	   ahd_linux_bus_reset(Scsi_Cmnd *);
-static int	   ahd_linux_dev_reset(Scsi_Cmnd *);
-static int	   ahd_linux_abort(Scsi_Cmnd *);
-
-/*
- * Try to detect an Adaptec 79XX controller.
- */
-static int
-ahd_linux_detect(Scsi_Host_Template *template)
-{
-	struct	ahd_softc *ahd;
-	int     found;
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	/*
-	 * It is a bug that the upper layer takes
-	 * this lock just prior to calling us.
-	 */
-	spin_unlock_irq(&io_request_lock);
-#endif
-
-	/*
-	 * Sanity checking of Linux SCSI data structures so
-	 * that some of our hacks^H^H^H^H^Hassumptions aren't
-	 * violated.
-	 */
-	if (offsetof(struct ahd_cmd_internal, end)
-	  > offsetof(struct scsi_cmnd, host_scribble)) {
-		printf("ahd_linux_detect: SCSI data structures changed.\n");
-		printf("ahd_linux_detect: Unable to attach\n");
-		return (0);
-	}
-#ifdef MODULE
-	/*
-	 * If we've been passed any parameters, process them now.
-	 */
-	if (aic79xx)
-		aic79xx_setup(aic79xx);
-	if (dummy_buffer[0] != 'P')
-		printk(KERN_WARNING
-"aic79xx: Please read the file /usr/src/linux/drivers/scsi/README.aic79xx\n"
-"aic79xx: to see the proper way to specify options to the aic79xx module\n"
-"aic79xx: Specifically, don't use any commas when passing arguments to\n"
-"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
-	 * probing for any adapters.
-	 */
-	ahd_list_lockinit();
-
-#ifdef CONFIG_PCI
-	ahd_linux_pci_probe(template);
-#endif
-
-	/*
-	 * Register with the SCSI layer all
-	 * controllers we've found.
-	 */
-	found = 0;
-	TAILQ_FOREACH(ahd, &ahd_tailq, links) {
-
-		if (ahd_linux_register_host(ahd, template) == 0)
-			found++;
-	}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	spin_lock_irq(&io_request_lock);
-#endif
-	aic79xx_detect_complete++;
-	return (found);
-}
-
-/*
- * Free the passed in Scsi_Host memory structures prior to unloading the
- * module.
- */
-static int
-ahd_linux_release(struct Scsi_Host * host)
-{
-	struct ahd_softc *ahd;
-	u_long l;
-
-	ahd_list_lock(&l);
-	if (host != NULL) {
-
-		/*
-		 * We should be able to just perform
-		 * the free directly, but check our
-		 * list for extra sanity.
-		 */
-		ahd = ahd_find_softc(*(struct ahd_softc **)host->hostdata);
-		if (ahd != NULL) {
-			u_long s;
-
-			ahd_lock(ahd, &s);
-			ahd_intr_enable(ahd, FALSE);
-			ahd_unlock(ahd, &s);
-			ahd_free(ahd);
-		}
-	}
-	ahd_list_unlock(&l);
-	return (0);
-}
-
-/*
- * Return a string describing the driver.
- */
-static const char *
-ahd_linux_info(struct Scsi_Host *host)
-{
-	static char buffer[512];
-	char	ahd_info[256];
-	char   *bp;
-	struct ahd_softc *ahd;
-
-	bp = &buffer[0];
-	ahd = *(struct ahd_softc **)host->hostdata;
-	memset(bp, 0, sizeof(buffer));
-	strcpy(bp, "Adaptec AIC79XX PCI-X SCSI HBA DRIVER, Rev ");
-	strcat(bp, AIC79XX_DRIVER_VERSION);
-	strcat(bp, "\n");
-	strcat(bp, "        <");
-	strcat(bp, ahd->description);
-	strcat(bp, ">\n");
-	strcat(bp, "        ");
-	ahd_controller_info(ahd, ahd_info);
-	strcat(bp, ahd_info);
-	strcat(bp, "\n");
-
-	return (bp);
-}
-
-/*
- * Queue an SCB to the controller.
- */
-static int
-ahd_linux_queue(Scsi_Cmnd * cmd, void (*scsi_done) (Scsi_Cmnd *))
-{
-	struct	 ahd_softc *ahd;
-	struct	 ahd_linux_device *dev;
-	u_long	 flags;
-
-	ahd = *(struct ahd_softc **)cmd->device->host->hostdata;
-
-	/*
-	 * Save the callback on completion function.
-	 */
-	cmd->scsi_done = scsi_done;
-
-	ahd_midlayer_entrypoint_lock(ahd, &flags);
-
-	/*
-	 * Close the race of a command that was in the process of
-	 * being queued to us just as our simq was frozen.  Let
-	 * DV commands through so long as we are only frozen to
-	 * perform DV.
-	 */
-	if (ahd->platform_data->qfrozen != 0
-	 && AHD_DV_CMD(cmd) == 0) {
-
-		ahd_cmd_set_transaction_status(cmd, CAM_REQUEUE_REQ);
-		ahd_linux_queue_cmd_complete(ahd, cmd);
-		ahd_schedule_completeq(ahd, NULL);
-		ahd_midlayer_entrypoint_unlock(ahd, &flags);
-		return (0);
-	}
-	dev = ahd_linux_get_device(ahd, cmd->device->channel,
-				   cmd->device->id, cmd->device->lun,
-				   /*alloc*/TRUE);
-	if (dev == NULL) {
-		ahd_midlayer_entrypoint_unlock(ahd, &flags);
-		printf("aic79xx_linux_queue: Unable to allocate device!\n");
-		return (-ENOMEM);
-	}
-	if (cmd->cmd_len > MAX_CDB_LEN)
-		return (-EINVAL);
-	cmd->result = CAM_REQ_INPROG << 16;
-	TAILQ_INSERT_TAIL(&dev->busyq, (struct ahd_cmd *)cmd, acmd_links.tqe);
-	if ((dev->flags & AHD_DEV_ON_RUN_LIST) == 0) {
-		TAILQ_INSERT_TAIL(&ahd->platform_data->device_runq, dev, links);
-		dev->flags |= AHD_DEV_ON_RUN_LIST;
-		ahd_linux_run_device_queues(ahd);
-	}
-	ahd_midlayer_entrypoint_unlock(ahd, &flags);
-	return (0);
-}
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-static int
-ahd_linux_slave_alloc(Scsi_Device *device)
-{
-	struct	ahd_softc *ahd;
-
-	ahd = *((struct ahd_softc **)device->host->hostdata);
-	if (bootverbose)
-		printf("%s: Slave Alloc %d\n", ahd_name(ahd), device->id);
-	return (0);
-}
-
-static int
-ahd_linux_slave_configure(Scsi_Device *device)
-{
-	struct	ahd_softc *ahd;
-	struct	ahd_linux_device *dev;
-	u_long	flags;
-
-	ahd = *((struct ahd_softc **)device->host->hostdata);
-	if (bootverbose)
-		printf("%s: Slave Configure %d\n", ahd_name(ahd), device->id);
-	ahd_midlayer_entrypoint_lock(ahd, &flags);
-	/*
-	 * Since Linux has attached to the device, configure
-	 * it so we don't free and allocate the device
-	 * structure on every command.
-	 */
-	dev = ahd_linux_get_device(ahd, device->channel,
-				   device->id, device->lun,
-				   /*alloc*/TRUE);
-	if (dev != NULL) {
-		dev->flags &= ~AHD_DEV_UNCONFIGURED;
-		dev->flags |= AHD_DEV_SLAVE_CONFIGURED;
-		dev->scsi_device = device;
-		ahd_linux_device_queue_depth(ahd, dev);
-	}
-	ahd_midlayer_entrypoint_unlock(ahd, &flags);
-	return (0);
-}
-
-static void
-ahd_linux_slave_destroy(Scsi_Device *device)
-{
-	struct	ahd_softc *ahd;
-	struct	ahd_linux_device *dev;
-	u_long	flags;
-
-	ahd = *((struct ahd_softc **)device->host->hostdata);
-	if (bootverbose)
-		printf("%s: Slave Destroy %d\n", ahd_name(ahd), device->id);
-	ahd_midlayer_entrypoint_lock(ahd, &flags);
-	dev = ahd_linux_get_device(ahd, device->channel,
-				   device->id, device->lun,
-					   /*alloc*/FALSE);
-
-	/*
-	 * Filter out "silly" deletions of real devices by only
-	 * deleting devices that have had slave_configure()
-	 * called on them.  All other devices that have not
-	 * been configured will automatically be deleted by
-	 * the refcounting process.
-	 */
-	if (dev != NULL
-	 && (dev->flags & AHD_DEV_SLAVE_CONFIGURED) != 0) {
-		dev->flags |= AHD_DEV_UNCONFIGURED;
-		if (TAILQ_EMPTY(&dev->busyq)
-		 && dev->active == 0)
-			ahd_linux_free_device(ahd, dev);
-	}
-	ahd_midlayer_entrypoint_unlock(ahd, &flags);
-}
-#else
-/*
- * Sets the queue depth for each SCSI device hanging
- * off the input host adapter.
- */
-static void
-ahd_linux_select_queue_depth(struct Scsi_Host * host,
-			     Scsi_Device * scsi_devs)
-{
-	Scsi_Device *device;
-	struct	ahd_softc *ahd;
-	u_long	flags;
-	int	scbnum;
-
-	ahd = *((struct ahd_softc **)host->hostdata);
-	ahd_midlayer_entrypoint_lock(ahd, &flags);
-	scbnum = 0;
-	for (device = scsi_devs; device != NULL; device = device->next) {
-
-		if (device->host == host) {
-			struct	 ahd_linux_device *dev;
-
-			/*
-			 * Since Linux has attached to the device, configure
-			 * it so we don't free and allocate the device
-			 * structure on every command.
-			 */
-			dev = ahd_linux_get_device(ahd, device->channel,
-						   device->id, device->lun,
-						   /*alloc*/TRUE);
-			if (dev != NULL) {
-				dev->flags &= ~AHD_DEV_UNCONFIGURED;
-				dev->scsi_device = device;
-				ahd_linux_device_queue_depth(ahd, dev);
-				device->queue_depth = dev->openings
-						    + dev->active;
-				if ((dev->flags & (AHD_DEV_Q_BASIC
-						| AHD_DEV_Q_TAGGED)) == 0) {
-					/*
-					 * We allow the OS to queue 2 untagged
-					 * transactions to us at any time even
-					 * though we can only execute them
-					 * serially on the controller/device.
-					 * This should remove some latency.
-					 */
-					device->queue_depth = 2;
-				}
-			}
-		}
-	}
-	ahd_midlayer_entrypoint_unlock(ahd, &flags);
-}
-#endif
-
-/*
- * Return the disk geometry for the given SCSI device.
- */
-static int
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-ahd_linux_biosparam(struct scsi_device *sdev, struct block_device *bdev,
-		    sector_t capacity, int geom[])
-{
-	uint8_t *bh;
-#else
-ahd_linux_biosparam(Disk *disk, kdev_t dev, int geom[])
-{
-	struct	scsi_device *sdev = disk->device;
-	u_long	capacity = disk->capacity;
-	struct	buffer_head *bh;
-#endif
-	int	 heads;
-	int	 sectors;
-	int	 cylinders;
-	int	 ret;
-	int	 extended;
-	struct	 ahd_softc *ahd;
-
-	ahd = *((struct ahd_softc **)sdev->host->hostdata);
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-	bh = scsi_bios_ptable(bdev);
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,17)
-	bh = bread(MKDEV(MAJOR(dev), MINOR(dev) & ~0xf), 0, block_size(dev));
-#else
-	bh = bread(MKDEV(MAJOR(dev), MINOR(dev) & ~0xf), 0, 1024);
-#endif
-
-	if (bh) {
-		ret = scsi_partsize(bh, capacity,
-				    &geom[2], &geom[0], &geom[1]);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-		kfree(bh);
-#else
-		brelse(bh);
-#endif
-		if (ret != -1)
-			return (ret);
-	}
-	heads = 64;
-	sectors = 32;
-	cylinders = aic_sector_div(capacity, heads, sectors);
-
-	if (aic79xx_extended != 0)
-		extended = 1;
-	else
-		extended = (ahd->flags & AHD_EXTENDED_TRANS_A) != 0;
-	if (extended && cylinders >= 1024) {
-		heads = 255;
-		sectors = 63;
-		cylinders = aic_sector_div(capacity, heads, sectors);
-	}
-	geom[0] = heads;
-	geom[1] = sectors;
-	geom[2] = cylinders;
-	return (0);
-}
-
-/*
- * Abort the current SCSI command(s).
- */
-static int
-ahd_linux_abort(Scsi_Cmnd *cmd)
-{
-	struct ahd_softc *ahd;
-	struct ahd_cmd *acmd;
-	struct ahd_cmd *list_acmd;
-	struct ahd_linux_device *dev;
-	struct scb *pending_scb;
-	u_long s;
-	u_int  saved_scbptr;
-	u_int  active_scbptr;
-	u_int  last_phase;
-	int    retval;
-	int    paused;
-	int    wait;
-	int    disconnected;
-	ahd_mode_state saved_modes;
-
-	pending_scb = NULL;
-	paused = FALSE;
-	wait = FALSE;
-	ahd = *(struct ahd_softc **)cmd->device->host->hostdata;
-	acmd = (struct ahd_cmd *)cmd;
-
-	printf("%s:%d:%d:%d: Attempting to abort cmd %p\n",
-	       ahd_name(ahd), cmd->device->channel, cmd->device->id,
-	       cmd->device->lun, cmd);
-
-	/*
-	 * In all versions of Linux, we have to work around
-	 * a major flaw in how the mid-layer is locked down
-	 * if we are to sleep successfully in our error handler
-	 * while allowing our interrupt handler to run.  Since
-	 * the midlayer acquires either the io_request_lock or
-	 * our lock prior to calling us, we must use the
-	 * spin_unlock_irq() method for unlocking our lock.
-	 * This will force interrupts to be enabled on the
-	 * current CPU.  Since the EH thread should not have
-	 * been running with CPU interrupts disabled other than
-	 * by acquiring either the io_request_lock or our own
-	 * lock, this *should* be safe.
-	 */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	spin_unlock_irq(&io_request_lock);
-#endif
-	ahd_midlayer_entrypoint_lock(ahd, &s);
-
-	/*
-	 * First determine if we currently own this command.
-	 * Start by searching the device queue.  If not found
-	 * there, check the pending_scb list.  If not found
-	 * at all, and the system wanted us to just abort the
-	 * command return success.
-	 */
-	dev = ahd_linux_get_device(ahd, cmd->device->channel,
-				   cmd->device->id, cmd->device->lun,
-				   /*alloc*/FALSE);
-
-	if (dev == NULL) {
-		/*
-		 * No target device for this command exists,
-		 * so we must not still own the command.
-		 */
-		printf("%s:%d:%d:%d: Is not an active device\n",
-		       ahd_name(ahd), cmd->device->channel, cmd->device->id,
-		       cmd->device->lun);
-		retval = SUCCESS;
-		goto no_cmd;
-	}
-
-	TAILQ_FOREACH(list_acmd, &dev->busyq, acmd_links.tqe) {
-		if (list_acmd == acmd)
-			break;
-	}
-
-	if (list_acmd != NULL) {
-		printf("%s:%d:%d:%d: Command found on device queue\n",
-		       ahd_name(ahd), cmd->device->channel, cmd->device->id,
-		       cmd->device->lun);
-		TAILQ_REMOVE(&dev->busyq, list_acmd, acmd_links.tqe);
-		cmd->result = DID_ABORT << 16;
-		ahd_linux_queue_cmd_complete(ahd, cmd);
-		retval = SUCCESS;
-		goto done;
-	}
-
-	/*
-	 * See if we can find a matching cmd in the pending list.
-	 */
-	LIST_FOREACH(pending_scb, &ahd->pending_scbs, pending_links) {
-		if (pending_scb->io_ctx == cmd)
-			break;
-	}
-
-	if (pending_scb == NULL) {
-		printf("%s:%d:%d:%d: Command not found\n",
-		       ahd_name(ahd), cmd->device->channel, cmd->device->id,
-		       cmd->device->lun);
-		goto no_cmd;
-	}
-
-	if ((pending_scb->flags & SCB_RECOVERY_SCB) != 0) {
-		/*
-		 * We can't queue two recovery actions using the same SCB
-		 */
-		retval = FAILED;
-		goto  done;
-	}
-
-	/*
-	 * Ensure that the card doesn't do anything
-	 * behind our back.  Also make sure that we
-	 * didn't "just" miss an interrupt that would
-	 * affect this cmd.
-	 */
-	ahd_pause_and_flushwork(ahd);
-	paused = TRUE;
-
-	if ((pending_scb->flags & SCB_ACTIVE) == 0) {
-		printf("%s:%d:%d:%d: Command already completed\n",
-		       ahd_name(ahd), cmd->device->channel, cmd->device->id,
-		       cmd->device->lun);
-		goto no_cmd;
-	}
-
-	ahd_dump_card_state(ahd);
-
-	disconnected = TRUE;
-	if (ahd_search_qinfifo(ahd, cmd->device->id, cmd->device->channel + 'A',
-			       cmd->device->lun, pending_scb->hscb->tag,
-			       ROLE_INITIATOR, CAM_REQ_ABORTED,
-			       SEARCH_COMPLETE) > 0) {
-		printf("%s:%d:%d:%d: Cmd aborted from QINFIFO\n",
-		       ahd_name(ahd), cmd->device->channel, cmd->device->id,
-				cmd->device->lun);
-		retval = SUCCESS;
-		goto done;
-	}
-
-	saved_modes = ahd_save_modes(ahd);
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-	last_phase = ahd_inb(ahd, LASTPHASE);
-	saved_scbptr = ahd_get_scbptr(ahd);
-	active_scbptr = saved_scbptr;
-	if (disconnected && (ahd_inb(ahd, SEQ_FLAGS) & NOT_IDENTIFIED) == 0) {
-		struct scb *bus_scb;
-
-		bus_scb = ahd_lookup_scb(ahd, active_scbptr);
-		if (bus_scb == pending_scb)
-			disconnected = FALSE;
-	}
-
-	/*
-	 * At this point, pending_scb is the scb associated with the
-	 * passed in command.  That command is currently active on the
-	 * bus or is in the disconnected state.
-	 */
-	if (last_phase != P_BUSFREE
-	 && pending_scb->hscb->tag == active_scbptr) {
-
-		/*
-		 * We're active on the bus, so assert ATN
-		 * and hope that the target responds.
-		 */
-		pending_scb = ahd_lookup_scb(ahd, active_scbptr);
-		pending_scb->flags |= SCB_RECOVERY_SCB|SCB_ABORT;
-		ahd_outb(ahd, MSG_OUT, HOST_MSG);
-		ahd_outb(ahd, SCSISIGO, last_phase|ATNO);
-		printf("%s:%d:%d:%d: Device is active, asserting ATN\n",
-		       ahd_name(ahd), cmd->device->channel,
-		       cmd->device->id, cmd->device->lun);
-		wait = TRUE;
-	} else if (disconnected) {
-
-		/*
-		 * Actually re-queue this SCB in an attempt
-		 * to select the device before it reconnects.
-		 */
-		pending_scb->flags |= SCB_RECOVERY_SCB|SCB_ABORT;
-		ahd_set_scbptr(ahd, pending_scb->hscb->tag);
-		pending_scb->hscb->cdb_len = 0;
-		pending_scb->hscb->task_attribute = 0;
-		pending_scb->hscb->task_management = SIU_TASKMGMT_ABORT_TASK;
-
-		if ((pending_scb->flags & SCB_PACKETIZED) != 0) {
-			/*
-			 * Mark the SCB has having an outstanding
-			 * task management function.  Should the command
-			 * complete normally before the task management
-			 * function can be sent, the host will be notified
-			 * to abort our requeued SCB.
-			 */
-			ahd_outb(ahd, SCB_TASK_MANAGEMENT,
-				 pending_scb->hscb->task_management);
-		} else {
-			/*
-			 * If non-packetized, set the MK_MESSAGE control
-			 * bit indicating that we desire to send a message.
-			 * We also set the disconnected flag since there is
-			 * no guarantee that our SCB control byte matches
-			 * the version on the card.  We don't want the
-			 * sequencer to abort the command thinking an
-			 * unsolicited reselection occurred.
-			 */
-			pending_scb->hscb->control |= MK_MESSAGE|DISCONNECTED;
-
-			/*
-			 * The sequencer will never re-reference the
-			 * in-core SCB.  To make sure we are notified
-			 * during reslection, set the MK_MESSAGE flag in
-			 * the card's copy of the SCB.
-			 */
-			ahd_outb(ahd, SCB_CONTROL,
-				 ahd_inb(ahd, SCB_CONTROL)|MK_MESSAGE);
-		}
-
-		/*
-		 * Clear out any entries in the QINFIFO first
-		 * so we are the next SCB for this target
-		 * to run.
-		 */
-		ahd_search_qinfifo(ahd, cmd->device->id,
-				   cmd->device->channel + 'A', cmd->device->lun,
-				   SCB_LIST_NULL, ROLE_INITIATOR,
-				   CAM_REQUEUE_REQ, SEARCH_COMPLETE);
-		ahd_qinfifo_requeue_tail(ahd, pending_scb);
-		ahd_set_scbptr(ahd, saved_scbptr);
-		ahd_print_path(ahd, pending_scb);
-		printf("Device is disconnected, re-queuing SCB\n");
-		wait = TRUE;
-	} else {
-		printf("%s:%d:%d:%d: Unable to deliver message\n",
-		       ahd_name(ahd), cmd->device->channel,
-		       cmd->device->id, cmd->device->lun);
-		retval = FAILED;
-		goto done;
-	}
-
-no_cmd:
-	/*
-	 * Our assumption is that if we don't have the command, no
-	 * recovery action was required, so we return success.  Again,
-	 * the semantics of the mid-layer recovery engine are not
-	 * well defined, so this may change in time.
-	 */
-	retval = SUCCESS;
-done:
-	if (paused)
-		ahd_unpause(ahd);
-	if (wait) {
-		struct timer_list timer;
-		int ret;
-
-		ahd->platform_data->flags |= AHD_UP_EH_SEMAPHORE;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-		ahd_unlock(ahd, &s);
-#else
-		spin_unlock_irq(ahd->platform_data->host->host_lock);
-#endif
-		init_timer(&timer);
-		timer.data = (u_long)ahd;
-		timer.expires = jiffies + (5 * HZ);
-		timer.function = ahd_linux_sem_timeout;
-		add_timer(&timer);
-		printf("Recovery code sleeping\n");
-		down(&ahd->platform_data->eh_sem);
-		printf("Recovery code awake\n");
-        	ret = del_timer(&timer);
-		if (ret == 0) {
-			printf("Timer Expired\n");
-			retval = FAILED;
-		}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-		ahd_lock(ahd, &s);
-#else
-		spin_lock_irq(ahd->platform_data->host->host_lock);
-#endif
-	}
-	acmd = TAILQ_FIRST(&ahd->platform_data->completeq);
-	TAILQ_INIT(&ahd->platform_data->completeq);
-	ahd_midlayer_entrypoint_unlock(ahd, &s);
-	if (acmd != NULL) {
-		acmd = ahd_linux_run_complete_queue(ahd, acmd);
-		if (acmd != NULL) {
-			ahd_midlayer_entrypoint_lock(ahd, &s);
-			ahd_schedule_completeq(ahd, acmd);
-			ahd_midlayer_entrypoint_unlock(ahd, &s);
-		}
-	}
-	ahd_schedule_runq(ahd);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	spin_lock_irq(&io_request_lock);
-#endif
-	return (retval);
-}
-
-
-static void
-ahd_linux_dev_reset_complete(Scsi_Cmnd *cmd)
-{
-	free(cmd, M_DEVBUF);
-}
-
-/*
- * Attempt to send a target reset message to the device that timed out.
- */
-static int
-ahd_linux_dev_reset(Scsi_Cmnd *cmd)
-{
-	struct	ahd_softc *ahd;
-	struct	scsi_cmnd *recovery_cmd;
-	struct	ahd_linux_device *dev;
-	struct	ahd_initiator_tinfo *tinfo;
-	struct	ahd_tmode_tstate *tstate;
-	struct	scb *scb;
-	struct	hardware_scb *hscb;
-	struct	ahd_cmd *acmd;
-	u_long	s;
-	struct	timer_list timer;
-	int	retval;
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	spin_unlock_irq(&io_request_lock);
-#endif
-	ahd = *(struct ahd_softc **)cmd->device->host->hostdata;
-	recovery_cmd = malloc(sizeof(struct scsi_cmnd), M_DEVBUF, M_WAITOK);
-	memset(recovery_cmd, 0, sizeof(struct scsi_cmnd));
-	recovery_cmd->device = cmd->device;
-	recovery_cmd->scsi_done = ahd_linux_dev_reset_complete;
-#if AHD_DEBUG
-	if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)
-		printf("%s:%d:%d:%d: Device reset called for cmd %p\n",
-		       ahd_name(ahd), cmd->device->channel, cmd->device->id,
-		       cmd->device->lun, cmd);
-#endif
-	ahd_midlayer_entrypoint_lock(ahd, &s);
-
-	dev = ahd_linux_get_device(ahd, cmd->device->channel, cmd->device->id,
-				   cmd->device->lun, /*alloc*/FALSE);
-	if (dev == NULL) {
-		ahd_midlayer_entrypoint_unlock(ahd, &s);
-		return (FAILED);
-	}
-	if ((scb = ahd_get_scb(ahd, AHD_NEVER_COL_IDX)) == NULL) {
-		ahd_midlayer_entrypoint_unlock(ahd, &s);
-		return (FAILED);
-	}
-	tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
-				    cmd->device->id, &tstate);
-	recovery_cmd->result = CAM_REQ_INPROG << 16;
-	recovery_cmd->host_scribble = (char *)scb;
-	scb->io_ctx = recovery_cmd;
-	scb->platform_data->dev = dev;
-	scb->sg_count = 0;
-	ahd_set_residual(scb, 0);
-	ahd_set_sense_residual(scb, 0);
-	hscb = scb->hscb;
-	hscb->control = 0;
-	hscb->scsiid = BUILD_SCSIID(ahd, cmd);
-	hscb->lun = cmd->lun;
-	hscb->cdb_len = 0;
-	hscb->task_management = SIU_TASKMGMT_LUN_RESET;
-	scb->flags |= SCB_DEVICE_RESET|SCB_RECOVERY_SCB|SCB_ACTIVE;
-	if ((tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
-		scb->flags |= SCB_PACKETIZED;
-	} else {
-		hscb->control |= MK_MESSAGE;
-	}
-	dev->openings--;
-	dev->active++;
-	dev->commands_issued++;
-	LIST_INSERT_HEAD(&ahd->pending_scbs, scb, pending_links);
-	ahd_queue_scb(ahd, scb);
-
-	ahd->platform_data->flags |= AHD_UP_EH_SEMAPHORE;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	ahd_unlock(ahd, &s);
-#else
-	spin_unlock_irq(ahd->platform_data->host->host_lock);
-#endif
-	init_timer(&timer);
-	timer.data = (u_long)ahd;
-	timer.expires = jiffies + (5 * HZ);
-	timer.function = ahd_linux_sem_timeout;
-	add_timer(&timer);
-	printf("Recovery code sleeping\n");
-	down(&ahd->platform_data->eh_sem);
-	printf("Recovery code awake\n");
-	retval = SUCCESS;
-	if (del_timer(&timer) == 0) {
-		printf("Timer Expired\n");
-		retval = FAILED;
-	}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	ahd_lock(ahd, &s);
-#else
-	spin_lock_irq(ahd->platform_data->host->host_lock);
-#endif
-	acmd = TAILQ_FIRST(&ahd->platform_data->completeq);
-	TAILQ_INIT(&ahd->platform_data->completeq);
-	ahd_midlayer_entrypoint_unlock(ahd, &s);
-	if (acmd != NULL) {
-		acmd = ahd_linux_run_complete_queue(ahd, acmd);
-		if (acmd != NULL) {
-			ahd_midlayer_entrypoint_lock(ahd, &s);
-			ahd_schedule_completeq(ahd, acmd);
-			ahd_midlayer_entrypoint_unlock(ahd, &s);
-		}
-	}
-	ahd_schedule_runq(ahd);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	spin_lock_irq(&io_request_lock);
-#endif
-	printf("%s: Device reset returning 0x%x\n", ahd_name(ahd), retval);
-	return (retval);
-}
-
-/*
- * Reset the SCSI bus.
- */
-static int
-ahd_linux_bus_reset(Scsi_Cmnd *cmd)
-{
-	struct ahd_softc *ahd;
-	struct ahd_cmd *acmd;
-	u_long s;
-	int    found;
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	spin_unlock_irq(&io_request_lock);
-#endif
-	ahd = *(struct ahd_softc **)cmd->device->host->hostdata;
-#ifdef AHD_DEBUG
-	if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)
-		printf("%s: Bus reset called for cmd %p\n",
-		       ahd_name(ahd), cmd);
-#endif
-	ahd_midlayer_entrypoint_lock(ahd, &s);
-	found = ahd_reset_channel(ahd, cmd->channel + 'A',
-				  /*initiate reset*/TRUE);
-	acmd = TAILQ_FIRST(&ahd->platform_data->completeq);
-	TAILQ_INIT(&ahd->platform_data->completeq);
-	ahd_midlayer_entrypoint_unlock(ahd, &s);
-	if (bootverbose)
-		printf("%s: SCSI bus reset delivered. "
-		       "%d SCBs aborted.\n", ahd_name(ahd), found);
-
-	if (acmd != NULL) {
-		acmd = ahd_linux_run_complete_queue(ahd, acmd);
-		if (acmd != NULL) {
-			ahd_midlayer_entrypoint_lock(ahd, &s);
-			ahd_schedule_completeq(ahd, acmd);
-			ahd_midlayer_entrypoint_unlock(ahd, &s);
-		}
-	}
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	spin_lock_irq(&io_request_lock);
-#endif
-	return (SUCCESS);
-}
-
-Scsi_Host_Template aic79xx_driver_template = {
-	.proc_info		= ahd_linux_proc_info,
-	.detect			= ahd_linux_detect,
-	.release		= ahd_linux_release,
-	.info			= ahd_linux_info,
-	.queuecommand		= ahd_linux_queue,
-	.eh_abort_handler	= ahd_linux_abort,
-	.eh_device_reset_handler = ahd_linux_dev_reset,
-	.eh_bus_reset_handler	= ahd_linux_bus_reset,
-#if defined(__i386__)
-	.bios_param		= ahd_linux_biosparam,
-#endif
-	.can_queue		= AHD_MAX_QUEUE,
-	.this_id		= -1,
-	.sg_tablesize		= AHD_NSEG,
-	.cmd_per_lun		= 2,
-	.use_clustering		= ENABLE_CLUSTERING,
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,7)
-	/*
-	 * We can only map 16MB per-SG
-	 * so create a sector limit of
-	 * "16MB" in 2K sectors.
-	 */
-	.max_sectors		= 8192,
-#endif
-#if defined CONFIG_HIGHIO || LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
-/* Assume RedHat Distribution with its different HIGHIO conventions. */
-	.can_dma_32		= 1,
-	.single_sg_okay		= 1,
-#else
-	.highmem_io		= 1,
-#endif
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-	.name			= "aic79xx",
-	.slave_alloc		= ahd_linux_slave_alloc,
-	.slave_configure	= ahd_linux_slave_configure,
-	.slave_destroy		= ahd_linux_slave_destroy,
-#else
-	.select_queue_depths	= ahd_linux_select_queue_depth,
-	.use_new_eh_code	= 1,
-#endif
-};
-
-#define driver_template aic79xx_driver_template
-#include "scsi_module.c"
-/**************************** Tasklet Handler *********************************/
-
-static void
-ahd_runq_tasklet(unsigned long data)
-{
-	struct ahd_softc* ahd;
-	struct ahd_linux_device *dev;
-	u_long flags;
-
-	ahd = (struct ahd_softc *)data;
-	ahd_lock(ahd, &flags);
-	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);
-		/* Yeild to our interrupt handler */
-		ahd_unlock(ahd, &flags);
-		ahd_lock(ahd, &flags);
-	}
-	ahd_unlock(ahd, &flags);
-}
-
-/************************ Shutdown/halt/reboot hook ***************************/
-#include <linux/notifier.h>
-#include <linux/reboot.h>
-
-static struct notifier_block ahd_linux_notifier = {
-	ahd_linux_halt, NULL, 0
-};
-
-static int ahd_linux_halt(struct notifier_block *nb, u_long event, void *buf)
-{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	struct ahd_softc *ahd;
-
-	/*
-	 * In 2.5.X, this is called prior to the filesystems
-	 * being synced and the SCSI layer being properly
-	 * shutdown.  A different API is required there,
-	 * but the device hooks for this don't quite look
-	 * right.
-	 */
-	if (event == SYS_DOWN || event == SYS_HALT) {
-		TAILQ_FOREACH(ahd, &ahd_tailq, links) {
-			ahd_shutdown(ahd);
-		}
-	}
-#endif
-	return (NOTIFY_OK);
-}
-
-/******************************** 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,
-		   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)
-{
-	bus_dma_tag_t dmat;
-
-	dmat = malloc(sizeof(*dmat), M_DEVBUF, M_NOWAIT);
-	if (dmat == NULL)
-		return (ENOMEM);
-
-	/*
-	 * Linux is very simplistic about DMA memory.  For now don't
-	 * maintain all specification information.  Once Linux supplies
-	 * better facilities for doing these operations, or the
-	 * needs of this particular driver change, we might need to do
-	 * more here.
-	 */
-	dmat->alignment = alignment;
-	dmat->boundary = boundary;
-	dmat->maxsize = maxsize;
-	*ret_tag = dmat;
-	return (0);
-}
-
-void
-ahd_dma_tag_destroy(struct ahd_softc *ahd, bus_dma_tag_t dmat)
-{
-	free(dmat, M_DEVBUF);
-}
-
-int
-ahd_dmamem_alloc(struct ahd_softc *ahd, bus_dma_tag_t dmat, void** vaddr,
-		 int flags, bus_dmamap_t *mapp)
-{
-	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);
-	/*
-	 * Although we can dma data above 4GB, our
-	 * "consistent" memory is below 4GB for
-	 * space efficiency reasons (only need a 4byte
-	 * address).  For this reason, we have to reset
-	 * our dma mask when doing allocations.
-	 */
-	if (ahd->dev_softc != NULL)
-		ahd_pci_set_dma_mask(ahd->dev_softc, 0xFFFFFFFF);
-	*vaddr = pci_alloc_consistent(ahd->dev_softc,
-				      dmat->maxsize, &map->bus_addr);
-	if (ahd->dev_softc != NULL)
-		ahd_pci_set_dma_mask(ahd->dev_softc,
-				     ahd->platform_data->hw_dma_mask);
-#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 accessable 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;
-	return(0);
-}
-
-void
-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
-ahd_dmamap_load(struct ahd_softc *ahd, bus_dma_tag_t dmat, bus_dmamap_t map,
-		void *buf, bus_size_t buflen, bus_dmamap_callback_t *cb,
-		void *cb_arg, int flags)
-{
-	/*
-	 * Assume for now that this will only be used during
-	 * initialization and not for per-transaction buffer mapping.
-	 */
-	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);
-}
-
-void
-ahd_dmamap_destroy(struct ahd_softc *ahd, bus_dma_tag_t dmat, bus_dmamap_t map)
-{
-	/*
-	 * The map may is NULL in our < 2.3.X implementation.
-	 */
-	if (map != NULL)
-		free(map, M_DEVBUF);
-}
-
-int
-ahd_dmamap_unload(struct ahd_softc *ahd, bus_dma_tag_t dmat, bus_dmamap_t map)
-{
-	/* Nothing to do */
-	return (0);
-}
-
-/********************* Platform Dependent Functions ***************************/
-int
-ahd_softc_comp(struct ahd_softc *lahd, struct ahd_softc *rahd)
-{
-	int	value;
-	char	primary_channel;
-
-	/*
-	 * Under Linux, cards are ordered as follows:
-	 *	1) PCI devices with BIOS enabled sorted by bus/slot/func.
-	 *	2) All remaining PCI devices sorted by bus/slot/func.
-	 */
-	value = (lahd->flags & AHD_BIOS_ENABLED)
-	      - (rahd->flags & AHD_BIOS_ENABLED);
-	if (value != 0)
-		/* Controllers with BIOS enabled have a *higher* priority */
-		return (-value);
-
-	/* Still equal.  Sort by bus/slot/func. */
-	if (aic79xx_reverse_scan != 0)
-		value = ahd_get_pci_bus(rahd->dev_softc)
-		      - ahd_get_pci_bus(lahd->dev_softc);
-	else
-		value = ahd_get_pci_bus(lahd->dev_softc)
-		      - ahd_get_pci_bus(rahd->dev_softc);
-	if (value != 0)
-		return (value);
-	if (aic79xx_reverse_scan != 0)
-		value = ahd_get_pci_slot(rahd->dev_softc)
-		      - ahd_get_pci_slot(lahd->dev_softc);
-	else
-		value = ahd_get_pci_slot(lahd->dev_softc)
-		      - ahd_get_pci_slot(rahd->dev_softc);
-	if (value != 0)
-		return (value);
-
-	/*
-	 * On multi-function devices, the user can choose
-	 * to have function 1 probed before function 0.
-	 * Give whichever channel is the primary channel
-	 * the lowest priority.
-	 */
-	primary_channel = (lahd->flags & AHD_PRIMARY_CHANNEL) + 'A';
-	value = 1;
-	if (lahd->channel == primary_channel)
-		value = -1;
-	return (value);
-}
-
-static void
-ahd_linux_setup_tag_info(char *p, char *end, char *s)
-{
-	char	*base;
-	char	*tok;
-	char	*tok_end;
-	char	*tok_end2;
-	int      i;
-	int      instance;
-	int	 targ;
-	int	 done;
-	char	 tok_list[] = {'.', ',', '{', '}', '\0'};
-
-	if (*p != ':')
-		return;
-
-	instance = -1;
-	targ = -1;
-	done = FALSE;
-	base = p;
-	/* Forward us just past the ':' */
-	tok = base + 1;
-	tok_end = strchr(tok, '\0');
-	if (tok_end < end)
-		*tok_end = ',';
-	while (!done) {
-		switch (*tok) {
-		case '{':
-			if (instance == -1)
-				instance = 0;
-			else if (targ == -1)
-				targ = 0;
-			tok++;
-			break;
-		case '}':
-			if (targ != -1)
-				targ = -1;
-			else if (instance != -1)
-				instance = -1;
-			tok++;
-			break;
-		case ',':
-		case '.':
-			if (instance == -1)
-				done = TRUE;
-			else if (targ >= 0)
-				targ++;
-			else if (instance >= 0)
-				instance++;
-			if ((targ >= AHD_NUM_TARGETS) ||
-			    (instance >= NUM_ELEMENTS(aic79xx_tag_info)))
-				done = TRUE;
-			tok++;
-			if (!done) {
-				base = tok;
-			}
-			break;
-		case '\0':
-			done = TRUE;
-			break;
-		default:
-			done = TRUE;
-			tok_end = strchr(tok, '\0');
-			for (i = 0; tok_list[i]; i++) {
-				tok_end2 = strchr(tok, tok_list[i]);
-				if ((tok_end2) && (tok_end2 < tok_end)) {
-					tok_end = tok_end2;
-					done = FALSE;
-				}
-			}
-			if ((instance >= 0) && (targ >= 0)
-			 && (instance < NUM_ELEMENTS(aic79xx_tag_info))
-			 && (targ < AHD_NUM_TARGETS)) {
-				aic79xx_tag_info[instance].tag_commands[targ] =
-				    simple_strtoul(tok, NULL, 0) & 0xff;
-			}
-			tok = tok_end;
-			break;
-		}
-	}
-	while ((p != base) && (p != NULL))
-		p = strsep(&s, ",.");
-}
-
-static void
-ahd_linux_setup_rd_strm_info(char *p, char *end, char *s)
-{
-	char	*base;
-	char	*tok;
-	char	*tok_end;
-	char	*tok_end2;
-	int      i;
-	int      instance;
-	int	 done;
-	char	 tok_list[] = {'.', ',', '{', '}', '\0'};
-
-	if (*p != ':')
-		return;
-
-	instance = -1;
-	done = FALSE;
-	base = p;
-	/* Forward us just past the ':' */
-	tok = base + 1;
-	tok_end = strchr(tok, '\0');
-	if (tok_end < end)
-		*tok_end = ',';
-	while (!done) {
-		switch (*tok) {
-		case '{':
-			if (instance == -1)
-				instance = 0;
-			tok++;
-			break;
-		case '}':
-			if (instance != -1)
-				instance = -1;
-			tok++;
-			break;
-		case ',':
-		case '.':
-			if (instance == -1)
-				done = TRUE;
-			else if (instance >= 0)
-				instance++;
-			if (instance >= NUM_ELEMENTS(aic79xx_rd_strm_info))
-				done = TRUE;
-			tok++;
-			if (!done) {
-				base = tok;
-			}
-			break;
-		case '\0':
-			done = TRUE;
-			break;
-		default:
-			done = TRUE;
-			tok_end = strchr(tok, '\0');
-			for (i = 0; tok_list[i]; i++) {
-				tok_end2 = strchr(tok, tok_list[i]);
-				if ((tok_end2) && (tok_end2 < tok_end)) {
-					tok_end = tok_end2;
-					done = FALSE;
-				}
-			}
-			if ((instance >= 0)
-			 && (instance < NUM_ELEMENTS(aic79xx_rd_strm_info))) {
-				aic79xx_rd_strm_info[instance] =
-				    simple_strtoul(tok, NULL, 0) & 0xffff;
-			}
-			tok = tok_end;
-			break;
-		}
-	}
-	while ((p != base) && (p != NULL))
-		p = strsep(&s, ",.");
-}
-
-static void
-ahd_linux_setup_dv(char *p, char *end, char *s)
-{
-	char	*base;
-	char	*tok;
-	char	*tok_end;
-	char	*tok_end2;
-	int      i;
-	int      instance;
-	int	 done;
-	char	 tok_list[] = {'.', ',', '{', '}', '\0'};
-
-	if (*p != ':')
-		return;
-
-	instance = -1;
-	done = FALSE;
-	base = p;
-	/* Forward us just past the ':' */
-	tok = base + 1;
-	tok_end = strchr(tok, '\0');
-	if (tok_end < end)
-		*tok_end = ',';
-	while (!done) {
-		switch (*tok) {
-		case '{':
-			if (instance == -1)
-				instance = 0;
-			tok++;
-			break;
-		case '}':
-			if (instance != -1)
-				instance = -1;
-			tok++;
-			break;
-		case ',':
-		case '.':
-			if (instance == -1)
-				done = TRUE;
-			else if (instance >= 0)
-				instance++;
-			if (instance >= NUM_ELEMENTS(aic79xx_dv_settings))
-				done = TRUE;
-			tok++;
-			if (!done) {
-				base = tok;
-			}
-			break;
-		case '\0':
-			done = TRUE;
-			break;
-		default:
-			done = TRUE;
-			tok_end = strchr(tok, '\0');
-			for (i = 0; tok_list[i]; i++) {
-				tok_end2 = strchr(tok, tok_list[i]);
-				if ((tok_end2) && (tok_end2 < tok_end)) {
-					tok_end = tok_end2;
-					done = FALSE;
-				}
-			}
-			if ((instance >= 0)
-			 && (instance < NUM_ELEMENTS(aic79xx_dv_settings))) {
-				aic79xx_dv_settings[instance] =
-				    simple_strtol(tok, NULL, 0);
-			}
-			tok = tok_end;
-			break;
-		}
-	}
-	while ((p != base) && (p != NULL))
-		p = strsep(&s, ",.");
-}
-
-static void
-ahd_linux_setup_iocell_info(char *p, char *end, char *s, int index)
-{
-	char	*base;
-	char	*tok;
-	char	*tok_end;
-	char	*tok_end2;
-	uint8_t	*iocell_info;
-	int      i;
-	int      instance;
-	int	 done;
-	char	 tok_list[] = {'.', ',', '{', '}', '\0'};
-
-	if (*p != ':')
-		return;
-
-	instance = -1;
-	done = FALSE;
-	base = p;
-	/* Forward us just past the ':' */
-	tok = base + 1;
-	tok_end = strchr(tok, '\0');
-	if (tok_end < end)
-		*tok_end = ',';
-	while (!done) {
-		switch (*tok) {
-		case '{':
-			if (instance == -1)
-				instance = 0;
-			tok++;
-			break;
-		case '}':
-			if (instance != -1)
-				instance = -1;
-			tok++;
-			break;
-		case ',':
-		case '.':
-			if (instance == -1)
-				done = TRUE;
-			else if (instance >= 0)
-				instance++;
-			if (instance >= NUM_ELEMENTS(aic79xx_iocell_info))
-				done = TRUE;
-			tok++;
-			if (!done) {
-				base = tok;
-			}
-			break;
-		case '\0':
-			done = TRUE;
-			break;
-		default:
-			done = TRUE;
-			tok_end = strchr(tok, '\0');
-			for (i = 0; tok_list[i]; i++) {
-				tok_end2 = strchr(tok, tok_list[i]);
-				if ((tok_end2) && (tok_end2 < tok_end)) {
-					tok_end = tok_end2;
-					done = FALSE;
-				}
-			}
-			if ((instance >= 0)
-			 && (instance < NUM_ELEMENTS(aic79xx_iocell_info))) {
-				iocell_info =
-				    (uint8_t*)&aic79xx_iocell_info[instance];
-				iocell_info[index] = 
-				    simple_strtoul(tok, NULL, 0) & 0xffff;
-			}
-			tok = tok_end;
-			break;
-		}
-	}
-	while ((p != base) && (p != NULL))
-		p = strsep(&s, ",.");
-}
-
-static void
-ahd_linux_setup_tag_info_global(char *p)
-{
-	int tags, i, j;
-
-	tags = simple_strtoul(p + 1, NULL, 0) & 0xff;
-	printf("Setting Global Tags= %d\n", tags);
-
-	for (i = 0; i < NUM_ELEMENTS(aic79xx_tag_info); i++) {
-		for (j = 0; j < AHD_NUM_TARGETS; j++) {
-			aic79xx_tag_info[i].tag_commands[j] = tags;
-		}
-	}
-}
-
-/*
- * Handle Linux boot parameters. This routine allows for assigning a value
- * to a parameter with a ':' between the parameter and the value.
- * ie. aic79xx=stpwlev:1,extended
- */
-static int
-aic79xx_setup(char *s)
-{
-	int	i, n;
-	char   *p;
-	char   *end;
-
-	static struct {
-		const char *name;
-		uint32_t *flag;
-	} options[] = {
-		{ "extended", &aic79xx_extended },
-		{ "no_reset", &aic79xx_no_reset },
-		{ "verbose", &aic79xx_verbose },
-		{ "allow_memio", &aic79xx_allow_memio},
-#ifdef AHD_DEBUG
-		{ "debug", &ahd_debug },
-#endif
-		{ "reverse_scan", &aic79xx_reverse_scan },
-		{ "periodic_otag", &aic79xx_periodic_otag },
-		{ "pci_parity", &aic79xx_pci_parity },
-		{ "seltime", &aic79xx_seltime },
-		{ "tag_info", NULL },
-		{ "global_tag_depth", NULL},
-		{ "rd_strm", NULL },
-		{ "dv", NULL },
-		{ "slewrate", NULL },
-		{ "precomp", NULL },
-		{ "amplitude", NULL },
-	};
-
-	end = strchr(s, '\0');
-
-	while ((p = strsep(&s, ",.")) != NULL) {
-		if (*p == '\0')
-			continue;
-		for (i = 0; i < NUM_ELEMENTS(options); i++) {
-			n = strlen(options[i].name);
-
-			if (strncmp(options[i].name, p, n) != 0)
-				continue;
-
-			if (!strncmp(p, "global_tag_depth", n)) {
-				ahd_linux_setup_tag_info_global(p + n);
-			} else if (!strncmp(p, "tag_info", n)) {
-				ahd_linux_setup_tag_info(p + n, end, s);
-			} else if (strncmp(p, "rd_strm", n) == 0) {
-				ahd_linux_setup_rd_strm_info(p + n, end, s);
-			} else if (strncmp(p, "dv", n) == 0) {
-				ahd_linux_setup_dv(p + n, end, s);
-			} else if (strncmp(p, "slewrate", n) == 0) {
-				ahd_linux_setup_iocell_info(p + n, end, s,
-				    AIC79XX_SLEWRATE_INDEX);
-			} else if (strncmp(p, "precomp", n) == 0) {
-				ahd_linux_setup_iocell_info(p + n, end, s,
-				    AIC79XX_PRECOMP_INDEX);
-			} else if (strncmp(p, "amplitude", n) == 0) {
-				ahd_linux_setup_iocell_info(p + n, end, s,
-				    AIC79XX_AMPLITUDE_INDEX);
-			} else if (p[n] == ':') {
-				*(options[i].flag) =
-				    simple_strtoul(p + n + 1, NULL, 0);
-			} else if (!strncmp(p, "verbose", n)) {
-				*(options[i].flag) = 1;
-			} else {
-				*(options[i].flag) = ~(*(options[i].flag));
-			}
-			break;
-		}
-	}
-	return 1;
-}
-
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0)
-__setup("aic79xx=", aic79xx_setup);
-#endif
-
-int aic79xx_verbose;
-
-int
-ahd_linux_register_host(struct ahd_softc *ahd, Scsi_Host_Template *template)
-{
-	char	buf[80];
-	struct	Scsi_Host *host;
-	char	*new_name;
-	u_long	s;
-	u_long	target;
-
-	template->name = ahd->description;
-	host = scsi_register(template, sizeof(struct ahd_softc *));
-	if (host == NULL)
-		return (ENOMEM);
-
-	*((struct ahd_softc **)host->hostdata) = ahd;
-	ahd_lock(ahd, &s);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-	scsi_assign_lock(host, &ahd->platform_data->spin_lock);
-#endif
-	ahd->platform_data->host = host;
-	host->can_queue = AHD_MAX_QUEUE;
-	host->cmd_per_lun = 2;
-	host->sg_tablesize = AHD_NSEG;
-	host->this_id = ahd->our_id;
-	host->irq = ahd->platform_data->irq;
-	host->max_id = (ahd->features & AHD_WIDE) ? 16 : 8;
-	host->max_lun = AHD_NUM_LUNS;
-	host->max_channel = 0;
-	ahd_set_unit(ahd, ahd_linux_next_unit());
-	sprintf(buf, "scsi%d", host->host_no);
-	new_name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT);
-	if (new_name != NULL) {
-		strcpy(new_name, buf);
-		ahd_set_name(ahd, new_name);
-	}
-	host->unique_id = ahd->unit;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4)
-	scsi_set_pci_device(host, ahd->dev_softc);
-#endif
-	ahd_linux_initialize_scsi_bus(ahd);
-	ahd_unlock(ahd, &s);
-	ahd->platform_data->dv_pid = kernel_thread(ahd_linux_dv_thread, ahd, 0);
-	ahd_lock(ahd, &s);
-	if (ahd->platform_data->dv_pid < 0) {
-		printf("%s: Failed to create DV thread, error= %d\n",
-		       ahd_name(ahd), ahd->platform_data->dv_pid);
-		return (-ahd->platform_data->dv_pid);
-	}
-	/*
-	 * Initially allocate *all* of our linux target objects
-	 * so that the DV thread will scan them all in parallel
-	 * just after driver initialization.  Any device that
-	 * does not exist will have its target object destroyed
-	 * by the selection timeout handler.  In the case of a
-	 * device that appears after the initial DV scan, async
-	 * negotiation will occur for the first command, and DV
-	 * will comence should that first command be successful.
-	 */
-	for (target = 0; target < host->max_id; target++)
-		ahd_linux_alloc_target(ahd, 0, target);
-	ahd_intr_enable(ahd, TRUE);
-	ahd_linux_start_dv(ahd);
-	ahd_unlock(ahd, &s);
-	return (0);
-}
-
-uint64_t
-ahd_linux_get_memsize()
-{
-	struct sysinfo si;
-
-	si_meminfo(&si);
-	return ((uint64_t)si.totalram << PAGE_SHIFT);
-}
-
-/*
- * Find the smallest available unit number to use
- * for a new device.  We don't just use a static
- * count to handle the "repeated hot-(un)plug"
- * scenario.
- */
-static int
-ahd_linux_next_unit()
-{
-	struct ahd_softc *ahd;
-	int unit;
-
-	unit = 0;
-retry:
-	TAILQ_FOREACH(ahd, &ahd_tailq, links) {
-		if (ahd->unit == unit) {
-			unit++;
-			goto retry;
-		}
-	}
-	return (unit);
-}
-
-/*
- * Place the SCSI bus into a known state by either resetting it,
- * or forcing transfer negotiations on the next command to any
- * target.
- */
-static void
-ahd_linux_initialize_scsi_bus(struct ahd_softc *ahd)
-{
-	u_int target_id;
-	u_int numtarg;
-
-	target_id = 0;
-	numtarg = 0;
-
-	if (aic79xx_no_reset != 0)
-		ahd->flags &= ~AHD_RESET_BUS_A;
-
-	if ((ahd->flags & AHD_RESET_BUS_A) != 0)
-		ahd_reset_channel(ahd, 'A', /*initiate_reset*/TRUE);
-	else
-		numtarg = (ahd->features & AHD_WIDE) ? 16 : 8;
-
-	/*
-	 * Force negotiation to async for all targets that
-	 * will not see an initial bus reset.
-	 */
-	for (; target_id < numtarg; target_id++) {
-		struct ahd_devinfo devinfo;
-		struct ahd_initiator_tinfo *tinfo;
-		struct ahd_tmode_tstate *tstate;
-
-		tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
-					    target_id, &tstate);
-		ahd_compile_devinfo(&devinfo, ahd->our_id, target_id,
-				    CAM_LUN_WILDCARD, 'A', ROLE_INITIATOR);
-		ahd_update_neg_request(ahd, &devinfo, tstate,
-				       tinfo, AHD_NEG_ALWAYS);
-	}
-	/* Give the bus some time to recover */
-	if ((ahd->flags & AHD_RESET_BUS_A) != 0) {
-		ahd_freeze_simq(ahd);
-		init_timer(&ahd->platform_data->reset_timer);
-		ahd->platform_data->reset_timer.data = (u_long)ahd;
-		ahd->platform_data->reset_timer.expires =
-		    jiffies + (AIC79XX_RESET_DELAY * HZ)/1000;
-		ahd->platform_data->reset_timer.function =
-		    (ahd_linux_callback_t *)ahd_release_simq;
-		add_timer(&ahd->platform_data->reset_timer);
-	}
-}
-
-int
-ahd_platform_alloc(struct ahd_softc *ahd, void *platform_arg)
-{
-	ahd->platform_data =
-	    malloc(sizeof(struct ahd_platform_data), M_DEVBUF, M_NOWAIT);
-	if (ahd->platform_data == NULL)
-		return (ENOMEM);
-	memset(ahd->platform_data, 0, sizeof(struct ahd_platform_data));
-	TAILQ_INIT(&ahd->platform_data->completeq);
-	TAILQ_INIT(&ahd->platform_data->device_runq);
-	ahd->platform_data->irq = AHD_LINUX_NOIRQ;
-	ahd->platform_data->hw_dma_mask = 0xFFFFFFFF;
-	ahd_lockinit(ahd);
-	ahd_done_lockinit(ahd);
-	init_timer(&ahd->platform_data->completeq_timer);
-	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;
-	if (TAILQ_EMPTY(&ahd_tailq))
-		register_reboot_notifier(&ahd_linux_notifier);
-	return (0);
-}
-
-void
-ahd_platform_free(struct ahd_softc *ahd)
-{
-	struct ahd_linux_target *targ;
-	struct ahd_linux_device *dev;
-	u_long s;
-	int i, j;
-
-	if (ahd->platform_data != NULL) {
-		/* Kill the DV kthread */
-		if (ahd->platform_data->dv_pid != 0) {
-			ahd_lock(ahd, &s);
-			ahd->platform_data->flags |= AHD_DV_SHUTDOWN;
-			ahd_unlock(ahd, &s);
-			up(&ahd->platform_data->dv_sem);
-			do {
-#ifdef AHD_DEBUG
-				if (ahd_debug & AHD_SHOW_DV) {
-					printf("%s: Waiting for DV thread to "
-					       "exit\n", ahd_name(ahd));
-				}
-#endif
-			} while (waitpid(ahd->platform_data->dv_pid, NULL,
-					 __WCLONE) == -ERESTARTSYS);
-		}
-		ahd_teardown_runq_tasklet(ahd);
-		if (ahd->platform_data->host != NULL)
-			scsi_unregister(ahd->platform_data->host);
-
-		/* destroy all of the device and target objects */
-		for (i = 0; i < AHD_NUM_TARGETS; i++) {
-			targ = ahd->platform_data->targets[i];
-			if (targ != NULL) {
-				for (j = 0; j < AHD_NUM_LUNS; j++) {
-					if (targ->devices[j] != NULL) {
-						dev = targ->devices[j];
-						ahd_linux_free_device(ahd, dev);
-					}
-					if (ahd->platform_data->targets[i] ==
-					    NULL)
-						break;
-				}
-			}
-		}
-
-		if (ahd->platform_data->irq != AHD_LINUX_NOIRQ)
-			free_irq(ahd->platform_data->irq, ahd);
-		if (ahd->tags[0] == BUS_SPACE_PIO
-		 && ahd->bshs[0].ioport != 0)
-			release_region(ahd->bshs[0].ioport, 256);
-		if (ahd->tags[1] == BUS_SPACE_PIO
-		 && ahd->bshs[1].ioport != 0)
-			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)
-			release_mem_region(ahd->platform_data->mem_busaddr,
-					   0x1000);
-#endif
-		}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		/* XXX Need an instance detach in the PCI code */
-		if (ahd->dev_softc != NULL)
-			ahd->dev_softc->driver = NULL;
-#endif
-		free(ahd->platform_data, M_DEVBUF);
-	}
-	if (TAILQ_EMPTY(&ahd_tailq)) {
-		unregister_reboot_notifier(&ahd_linux_notifier);
-#ifdef CONFIG_PCI
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		pci_unregister_driver(&aic79xx_pci_driver);
-#endif
-#endif
-	}
-}
-
-void
-ahd_platform_init(struct ahd_softc *ahd)
-{
-	/*
-	 * Lookup and commit any modified IO Cell options.
-	 */
-	if (ahd->unit < NUM_ELEMENTS(aic79xx_iocell_info)) {
-		struct ahd_linux_iocell_opts *iocell_opts;
-
-		iocell_opts = &aic79xx_iocell_info[ahd->unit];
-		if (iocell_opts->precomp != AIC79XX_DEFAULT_PRECOMP)
-			AHD_SET_PRECOMP(ahd, iocell_opts->precomp);
-		if (iocell_opts->slewrate != AIC79XX_DEFAULT_SLEWRATE)
-			AHD_SET_SLEWRATE(ahd, iocell_opts->slewrate);
-		if (iocell_opts->amplitude != AIC79XX_DEFAULT_AMPLITUDE)
-			AHD_SET_AMPLITUDE(ahd, iocell_opts->amplitude);
-	}
-
-}
-
-void
-ahd_platform_freeze_devq(struct ahd_softc *ahd, struct scb *scb)
-{
-	ahd_platform_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb),
-				SCB_GET_CHANNEL(ahd, scb),
-				SCB_GET_LUN(scb), SCB_LIST_NULL,
-				ROLE_UNKNOWN, CAM_REQUEUE_REQ);
-}
-
-void
-ahd_platform_set_tags(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
-		      ahd_queue_alg alg)
-{
-	struct ahd_linux_device *dev;
-	int was_queuing;
-	int now_queuing;
-
-	dev = ahd_linux_get_device(ahd, devinfo->channel - 'A',
-				   devinfo->target,
-				   devinfo->lun, /*alloc*/FALSE);
-	if (dev == NULL)
-		return;
-	was_queuing = dev->flags & (AHD_DEV_Q_BASIC|AHD_DEV_Q_TAGGED);
-	now_queuing = alg != AHD_QUEUE_NONE;
-	if ((dev->flags & AHD_DEV_FREEZE_TIL_EMPTY) == 0
-	 && (was_queuing != now_queuing)
-	 && (dev->active != 0)) {
-		dev->flags |= AHD_DEV_FREEZE_TIL_EMPTY;
-		dev->qfrozen++;
-	}
-
-	dev->flags &= ~(AHD_DEV_Q_BASIC|AHD_DEV_Q_TAGGED|AHD_DEV_PERIODIC_OTAG);
-	if (now_queuing) {
-		u_int usertags;
-
-		usertags = ahd_linux_user_tagdepth(ahd, devinfo);
-		if (!was_queuing) {
-			/*
-			 * Start out agressively and allow our
-			 * dynamic queue depth algorithm to take
-			 * care of the rest.
-			 */
-			dev->maxtags = usertags;
-			dev->openings = dev->maxtags - dev->active;
-		}
-		if (dev->maxtags == 0) {
-			/*
-			 * Queueing is disabled by the user.
-			 */
-			dev->openings = 1;
-		} else if (alg == AHD_QUEUE_TAGGED) {
-			dev->flags |= AHD_DEV_Q_TAGGED;
-			if (aic79xx_periodic_otag != 0)
-				dev->flags |= AHD_DEV_PERIODIC_OTAG;
-		} else
-			dev->flags |= AHD_DEV_Q_BASIC;
-	} else {
-		/* We can only have one opening. */
-		dev->maxtags = 0;
-		dev->openings =  1 - dev->active;
-	}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-	if (dev->scsi_device != NULL) {
-		switch ((dev->flags & (AHD_DEV_Q_BASIC|AHD_DEV_Q_TAGGED))) {
-		case AHD_DEV_Q_BASIC:
-			scsi_adjust_queue_depth(dev->scsi_device,
-						MSG_SIMPLE_TASK,
-						dev->openings + dev->active);
-			break;
-		case AHD_DEV_Q_TAGGED:
-			scsi_adjust_queue_depth(dev->scsi_device,
-						MSG_ORDERED_TASK,
-						dev->openings + dev->active);
-			break;
-		default:
-			/*
-			 * We allow the OS to queue 2 untagged transactions to
-			 * us at any time even though we can only execute them
-			 * serially on the controller/device.  This should
-			 * remove some latency.
-			 */
-			scsi_adjust_queue_depth(dev->scsi_device,
-						/*NON-TAGGED*/0,
-						/*queue depth*/2);
-			break;
-		}
-	}
-#endif
-}
-
-int
-ahd_platform_abort_scbs(struct ahd_softc *ahd, int target, char channel,
-			int lun, u_int tag, role_t role, uint32_t status)
-{
-	int targ;
-	int maxtarg;
-	int maxlun;
-	int clun;
-	int count;
-
-	if (tag != SCB_LIST_NULL)
-		return (0);
-
-	targ = 0;
-	if (target != CAM_TARGET_WILDCARD) {
-		targ = target;
-		maxtarg = targ + 1;
-	} else {
-		maxtarg = (ahd->features & AHD_WIDE) ? 16 : 8;
-	}
-	clun = 0;
-	if (lun != CAM_LUN_WILDCARD) {
-		clun = lun;
-		maxlun = clun + 1;
-	} else {
-		maxlun = AHD_NUM_LUNS;
-	}
-
-	count = 0;
-	for (; targ < maxtarg; targ++) {
-
-		for (; clun < maxlun; clun++) {
-			struct ahd_linux_device *dev;
-			struct ahd_busyq *busyq;
-			struct ahd_cmd *acmd;
-
-			dev = ahd_linux_get_device(ahd, /*chan*/0, targ,
-						   clun, /*alloc*/FALSE);
-			if (dev == NULL)
-				continue;
-
-			busyq = &dev->busyq;
-			while ((acmd = TAILQ_FIRST(busyq)) != NULL) {
-				Scsi_Cmnd *cmd;
-
-				cmd = &acmd_scsi_cmd(acmd);
-				TAILQ_REMOVE(busyq, acmd,
-					     acmd_links.tqe);
-				count++;
-				cmd->result = status << 16;
-				ahd_linux_queue_cmd_complete(ahd, cmd);
-			}
-		}
-	}
-
-	return (count);
-}
-
-static void
-ahd_linux_thread_run_complete_queue(struct ahd_softc *ahd)
-{
-	struct ahd_cmd *acmd;
-	u_long flags;
-
-	ahd_lock(ahd, &flags);
-	del_timer(&ahd->platform_data->completeq_timer);
-	ahd->platform_data->flags &= ~AHD_RUN_CMPLT_Q_TIMER;
-	acmd = TAILQ_FIRST(&ahd->platform_data->completeq);
-	TAILQ_INIT(&ahd->platform_data->completeq);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	ahd_unlock(ahd, &flags);
-#endif
-	if (acmd != NULL) {
-		acmd = ahd_linux_run_complete_queue(ahd, acmd);
-		if (acmd != NULL) {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-			ahd_lock(ahd, &flags);
-#endif
-			ahd_schedule_completeq(ahd, acmd);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-			ahd_unlock(ahd, &flags);
-#endif
-		}
-	}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-	ahd_unlock(ahd, &flags);
-#endif
-}
-
-static void
-ahd_linux_start_dv(struct ahd_softc *ahd)
-{
-
-	/*
-	 * Freeze the simq and signal ahd_linux_queue to not let any
-	 * more commands through
-	 */
-	if ((ahd->platform_data->flags & AHD_DV_ACTIVE) == 0) {
-#ifdef AHD_DEBUG
-		if (ahd_debug & AHD_SHOW_DV)
-			printf("%s: Starting DV\n", ahd_name(ahd));
-#endif
-
-		ahd->platform_data->flags |= AHD_DV_ACTIVE;
-		ahd_freeze_simq(ahd);
-
-		/* Wake up the DV kthread */
-		up(&ahd->platform_data->dv_sem);
-	}
-}
-
-static int
-ahd_linux_dv_thread(void *data)
-{
-	struct	ahd_softc *ahd;
-	int	target;
-	u_long	s;
-
-	ahd = (struct ahd_softc *)data;
-
-#ifdef AHD_DEBUG
-	if (ahd_debug & AHD_SHOW_DV)
-		printf("In DV Thread\n");
-#endif
-
-	/*
-	 * Don't care about any signals.
-	 */
-	siginitsetinv(&current->blocked, 0);
-
-	/*
-	 * Complete thread creation.
-	 */
-	lock_kernel();
-	daemonize();
-	sprintf(current->comm, "ahd_dv_%d", ahd->unit);
-	unlock_kernel();
-
-	while (1) {
-		/*
-		 * Use down_interruptible() rather than down() to
-		 * avoid inclusion in the load average.
-		 */
-		down_interruptible(&ahd->platform_data->dv_sem);
-
-		/* Check to see if we've been signaled to exit */
-		ahd_lock(ahd, &s);
-		if ((ahd->platform_data->flags & AHD_DV_SHUTDOWN) != 0) {
-			ahd_unlock(ahd, &s);
-			return (0);
-		}
-		ahd_unlock(ahd, &s);
-
-#ifdef AHD_DEBUG
-		if (ahd_debug & AHD_SHOW_DV)
-			printf("%s: Beginning Domain Validation\n",
-			       ahd_name(ahd));
-#endif
-
-		/*
-		 * Wait for any pending commands to drain before proceeding.
-		 */
-		ahd_lock(ahd, &s);
-		while (LIST_FIRST(&ahd->pending_scbs) != NULL) {
-			ahd->platform_data->flags |= AHD_DV_WAIT_SIMQ_EMPTY;
-			ahd_unlock(ahd, &s);
-			down_interruptible(&ahd->platform_data->dv_sem);
-			ahd_lock(ahd, &s);
-		}
-
-		/*
-		 * Wait for the SIMQ to be released so that DV is the
-		 * only reason the queue is frozen.
-		 */
-		while (AHD_DV_SIMQ_FROZEN(ahd) == 0) {
-			ahd->platform_data->flags |= AHD_DV_WAIT_SIMQ_RELEASE;
-			ahd_unlock(ahd, &s);
-			down_interruptible(&ahd->platform_data->dv_sem);
-			ahd_lock(ahd, &s);
-		}
-		ahd_unlock(ahd, &s);
-
-		for (target = 0; target < AHD_NUM_TARGETS; target++)
-			ahd_linux_dv_target(ahd, target);
-
-		ahd_lock(ahd, &s);
-		ahd->platform_data->flags &= ~AHD_DV_ACTIVE;
-		ahd_unlock(ahd, &s);
-
-		/*
-		 * Release the SIMQ so that normal commands are
-		 * allowed to continue on the bus.
-		 */
-		ahd_release_simq(ahd);
-	}
-
-	return (0);
-}
-
-#define AHD_LINUX_DV_INQ_SHORT_LEN	36
-#define AHD_LINUX_DV_INQ_LEN		256
-#define AHD_LINUX_DV_TIMEOUT		(HZ / 4)
-
-#define AHD_SET_DV_STATE(ahd, targ, newstate) \
-	ahd_set_dv_state(ahd, targ, newstate, __LINE__)
-
-static __inline void
-ahd_set_dv_state(struct ahd_softc *ahd, struct ahd_linux_target *targ,
-		 ahd_dv_state newstate, u_int line)
-{
-	ahd_dv_state oldstate;
-
-	oldstate = targ->dv_state;
-#ifdef AHD_DEBUG
-	if (ahd_debug & AHD_SHOW_DV)
-		printf("%s:%d: Going from state %d to state %d\n",
-		       ahd_name(ahd), line, oldstate, newstate);
-#endif
-
-	if (oldstate == newstate)
-		targ->dv_state_retry++;
-	else
-		targ->dv_state_retry = 0;
-	targ->dv_state = newstate;
-}
-
-static void
-ahd_linux_dv_target(struct ahd_softc *ahd, u_int target_offset)
-{
-	struct	 ahd_devinfo devinfo;
-	struct	 ahd_linux_target *targ;
-	struct	 scsi_cmnd *cmd;
-	struct	 scsi_device *scsi_dev;
-	struct	 scsi_sense_data *sense;
-	uint8_t *buffer;
-	u_long	 s;
-	u_int	 timeout;
-	int	 echo_size;
-
-	sense = NULL;
-	buffer = NULL;
-	echo_size = 0;
-	ahd_lock(ahd, &s);
-	targ = ahd->platform_data->targets[target_offset];
-	if (targ == NULL || (targ->flags & AHD_DV_REQUIRED) == 0) {
-		ahd_unlock(ahd, &s);
-		return;
-	}
-	ahd_compile_devinfo(&devinfo, ahd->our_id, targ->target, /*lun*/0,
-			    targ->channel + 'A', ROLE_INITIATOR);
-#ifdef AHD_DEBUG
-	if (ahd_debug & AHD_SHOW_DV) {
-		ahd_print_devinfo(ahd, &devinfo);
-		printf("Performing DV\n");
-	}
-#endif
-
-	ahd_unlock(ahd, &s);
-
-	cmd = malloc(sizeof(struct scsi_cmnd), M_DEVBUF, M_WAITOK);
-	scsi_dev = malloc(sizeof(struct scsi_device), M_DEVBUF, M_WAITOK);
-	scsi_dev->host = ahd->platform_data->host;
-	scsi_dev->id = devinfo.target;
-	scsi_dev->lun = devinfo.lun;
-	scsi_dev->channel = devinfo.channel - 'A';
-	ahd->platform_data->dv_scsi_dev = scsi_dev;
-
-	AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_INQ_SHORT_ASYNC);
-
-	while (targ->dv_state != AHD_DV_STATE_EXIT) {
-		timeout = AHD_LINUX_DV_TIMEOUT;
-		switch (targ->dv_state) {
-		case AHD_DV_STATE_INQ_SHORT_ASYNC:
-		case AHD_DV_STATE_INQ_ASYNC:
-		case AHD_DV_STATE_INQ_ASYNC_VERIFY:
-			/*
-			 * Set things to async narrow to reduce the
-			 * chance that the INQ will fail.
-			 */
-			ahd_lock(ahd, &s);
-			ahd_set_syncrate(ahd, &devinfo, 0, 0, 0,
-					 AHD_TRANS_GOAL, /*paused*/FALSE);
-			ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
-				      AHD_TRANS_GOAL, /*paused*/FALSE);
-			ahd_unlock(ahd, &s);
-			timeout = 10 * HZ;
-			targ->flags &= ~AHD_INQ_VALID;
-			/* FALLTHROUGH */
-		case AHD_DV_STATE_INQ_VERIFY:
-		{
-			u_int inq_len;
-
-			if (targ->dv_state == AHD_DV_STATE_INQ_SHORT_ASYNC)
-				inq_len = AHD_LINUX_DV_INQ_SHORT_LEN;
-			else
-				inq_len = targ->inq_data->additional_length + 5;
-			ahd_linux_dv_inq(ahd, cmd, &devinfo, targ, inq_len);
-			break;
-		}
-		case AHD_DV_STATE_TUR:
-		case AHD_DV_STATE_BUSY:
-			ahd_linux_dv_tur(ahd, cmd, &devinfo);
-			break;
-		case AHD_DV_STATE_REBD:
-			ahd_linux_dv_rebd(ahd, cmd, &devinfo, targ);
-			break;
-		case AHD_DV_STATE_WEB:
-			ahd_linux_dv_web(ahd, cmd, &devinfo, targ);
-			break;
-
-		case AHD_DV_STATE_REB:
-			ahd_linux_dv_reb(ahd, cmd, &devinfo, targ);
-			break;
-
-		case AHD_DV_STATE_SU:
-			ahd_linux_dv_su(ahd, cmd, &devinfo, targ);
-			timeout = 50 * HZ;
-			break;
-
-		default:
-			ahd_print_devinfo(ahd, &devinfo);
-			printf("Unknown DV state %d\n", targ->dv_state);
-			goto out;
-		}
-
-		/* Queue the command and wait for it to complete */
-		/* Abuse eh_timeout in the scsi_cmnd struct for our purposes */
-		init_timer(&cmd->eh_timeout);
-#ifdef AHD_DEBUG
-		if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
-			/*
-			 * All of the printfs during negotiation
-			 * really slow down the negotiation.
-			 * Add a bit of time just to be safe.
-			 */
-			timeout += HZ;
-#endif
-		scsi_add_timer(cmd, timeout, ahd_linux_dv_timeout);
-		/*
-		 * In 2.5.X, it is assumed that all calls from the
-		 * "midlayer" (which we are emulating) will have the
-		 * ahd host lock held.
-		 */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-		ahd_lock(ahd, &s);
-#endif
-		ahd_linux_queue(cmd, ahd_linux_dv_complete);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-		ahd_unlock(ahd, &s);
-#endif
-		down_interruptible(&ahd->platform_data->dv_cmd_sem);
-		/*
-		 * Wait for the SIMQ to be released so that DV is the
-		 * only reason the queue is frozen.
-		 */
-		ahd_lock(ahd, &s);
-		while (AHD_DV_SIMQ_FROZEN(ahd) == 0) {
-			ahd->platform_data->flags |= AHD_DV_WAIT_SIMQ_RELEASE;
-			ahd_unlock(ahd, &s);
-			down_interruptible(&ahd->platform_data->dv_sem);
-			ahd_lock(ahd, &s);
-		}
-		ahd_unlock(ahd, &s);
-
-		ahd_linux_dv_transition(ahd, cmd, &devinfo, targ);
-	}
-
-out:
-	if ((targ->flags & AHD_INQ_VALID) != 0
-	 && ahd_linux_get_device(ahd, devinfo.channel - 'A',
-				 devinfo.target, devinfo.lun,
-				 /*alloc*/FALSE) == NULL) {
-		/*
-		 * The DV state machine failed to configure this device.  
-		 * This is normal if DV is disabled.  Since we have inquiry
-		 * data, filter it and use the "optimistic" negotiation
-		 * parameters found in the inquiry string.
-		 */
-		ahd_linux_filter_inquiry(ahd, &devinfo);
-		if ((targ->flags & (AHD_BASIC_DV|AHD_ENHANCED_DV)) != 0) {
-			ahd_print_devinfo(ahd, &devinfo);
-			printf("DV failed to configure device.  "
-			       "Please file a bug report against "
-			       "this driver.\n");
-		}
-	}
-
-	if (cmd != NULL)
-		free(cmd, M_DEVBUF);
-
-	if (ahd->platform_data->dv_scsi_dev != NULL) {
-		free(ahd->platform_data->dv_scsi_dev, M_DEVBUF);
-		ahd->platform_data->dv_scsi_dev = NULL;
-	}
-
-	ahd_lock(ahd, &s);
-	if (targ->dv_buffer != NULL)
-		free(targ->dv_buffer, M_DEVBUF);
-	if (targ->dv_buffer1 != NULL)
-		free(targ->dv_buffer1, M_DEVBUF);
-	targ->flags &= ~AHD_DV_REQUIRED;
-	if (targ->refcount == 0)
-		ahd_linux_free_target(ahd, targ);
-	ahd_unlock(ahd, &s);
-}
-
-static void
-ahd_linux_dv_transition(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
-			struct ahd_devinfo *devinfo,
-			struct ahd_linux_target *targ)
-{
-	cam_status cam_status;
-	u_int32_t status;
-	u_int scsi_status;
-
-	scsi_status = ahd_cmd_get_scsi_status(cmd);
-	cam_status = ahd_cmd_get_transaction_status(cmd);
-	status = aic_error_action(cmd, targ->inq_data, cam_status, scsi_status);
-
-	
-#ifdef AHD_DEBUG
-	if (ahd_debug & AHD_SHOW_DV) {
-		ahd_print_devinfo(ahd, devinfo);
-		printf("Entering ahd_linux_dv_transition, state= %d, "
-		       "status= 0x%x, cmd->result= 0x%x\n", targ->dv_state,
-		       status, cmd->result);
-	}
-#endif
-
-	switch (targ->dv_state) {
-	case AHD_DV_STATE_INQ_SHORT_ASYNC:
-	case AHD_DV_STATE_INQ_ASYNC:
-		switch (status & SS_MASK) {
-		case SS_NOP:
-		{
-			AHD_SET_DV_STATE(ahd, targ, targ->dv_state+1);
-			break;
-		}
-		case SS_INQ_REFRESH:
-			AHD_SET_DV_STATE(ahd, targ,
-					 AHD_DV_STATE_INQ_SHORT_ASYNC);
-			break;
-		case SS_TUR:
-		case SS_RETRY:
-			AHD_SET_DV_STATE(ahd, targ, targ->dv_state);
-			if (ahd_cmd_get_transaction_status(cmd)
-			 == CAM_REQUEUE_REQ)
-				targ->dv_state_retry--;
-			if ((status & SS_ERRMASK) == EBUSY)
-				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_BUSY);
-			if (targ->dv_state_retry < 10)
-				break;
-			/* FALLTHROUGH */
-		default:
-			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
-#ifdef AHD_DEBUG
-			if (ahd_debug & AHD_SHOW_DV) {
-				ahd_print_devinfo(ahd, devinfo);
-				printf("Failed DV inquiry, skipping\n");
-			}
-#endif
-			break;
-		}
-		break;
-	case AHD_DV_STATE_INQ_ASYNC_VERIFY:
-		switch (status & SS_MASK) {
-		case SS_NOP:
-		{
-			u_int xportflags;
-			u_int spi3data;
-
-			if (memcmp(targ->inq_data, targ->dv_buffer,
-				   AHD_LINUX_DV_INQ_LEN) != 0) {
-				/*
-				 * Inquiry data must have changed.
-				 * Try from the top again.
-				 */
-				AHD_SET_DV_STATE(ahd, targ,
-						 AHD_DV_STATE_INQ_SHORT_ASYNC);
-				break;
-			}
-
-			AHD_SET_DV_STATE(ahd, targ, targ->dv_state+1);
-			targ->flags |= AHD_INQ_VALID;
-			if (ahd_linux_user_dv_setting(ahd) == 0)
-				break;
-
-			xportflags = targ->inq_data->flags;
-			if ((xportflags & (SID_Sync|SID_WBus16)) == 0)
-				break;
-
-			spi3data = targ->inq_data->spi3data;
-			switch (spi3data & SID_SPI_CLOCK_DT_ST) {
-			default:
-			case SID_SPI_CLOCK_ST:
-				/* Assume only basic DV is supported. */
-				targ->flags |= AHD_BASIC_DV;
-				break;
-			case SID_SPI_CLOCK_DT:
-			case SID_SPI_CLOCK_DT_ST:
-				targ->flags |= AHD_ENHANCED_DV;
-				break;
-			}
-			break;
-		}
-		case SS_INQ_REFRESH:
-			AHD_SET_DV_STATE(ahd, targ,
-					 AHD_DV_STATE_INQ_SHORT_ASYNC);
-			break;
-		case SS_TUR:
-		case SS_RETRY:
-			AHD_SET_DV_STATE(ahd, targ, targ->dv_state);
-			if (ahd_cmd_get_transaction_status(cmd)
-			 == CAM_REQUEUE_REQ)
-				targ->dv_state_retry--;
-
-			if ((status & SS_ERRMASK) == EBUSY)
-				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_BUSY);
-			if (targ->dv_state_retry < 10)
-				break;
-			/* FALLTHROUGH */
-		default:
-			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
-#ifdef AHD_DEBUG
-			if (ahd_debug & AHD_SHOW_DV) {
-				ahd_print_devinfo(ahd, devinfo);
-				printf("Failed DV inquiry, skipping\n");
-			}
-#endif
-			break;
-		}
-		break;
-	case AHD_DV_STATE_INQ_VERIFY:
-		switch (status & SS_MASK) {
-		case SS_NOP:
-		{
-
-			if (memcmp(targ->inq_data, targ->dv_buffer,
-				   AHD_LINUX_DV_INQ_LEN) == 0) {
-				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
-				break;
-			}
-
-#ifdef AHD_DEBUG
-			if (ahd_debug & AHD_SHOW_DV) {
-				int i;
-
-				ahd_print_devinfo(ahd, devinfo);
-				printf("Inquiry buffer mismatch:");
-				for (i = 0; i < AHD_LINUX_DV_INQ_LEN; i++) {
-					if ((i & 0xF) == 0)
-						printf("\n        ");
-					printf("0x%x:0x0%x ",
-					       ((uint8_t *)targ->inq_data)[i], 
-					       targ->dv_buffer[i]);
-				}
-				printf("\n");
-			}
-#endif
-
-			if (ahd_linux_dv_fallback(ahd, devinfo) != 0) {
-				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
-				break;
-			}
-			/*
-			 * Do not count "falling back"
-			 * against our retries.
-			 */
-			targ->dv_state_retry = 0;
-			AHD_SET_DV_STATE(ahd, targ, targ->dv_state);
-			break;
-		}
-		case SS_INQ_REFRESH:
-			AHD_SET_DV_STATE(ahd, targ,
-					 AHD_DV_STATE_INQ_SHORT_ASYNC);
-			break;
-		case SS_TUR:
-		case SS_RETRY:
-			AHD_SET_DV_STATE(ahd, targ, targ->dv_state);
-			if (ahd_cmd_get_transaction_status(cmd)
-			 == CAM_REQUEUE_REQ) {
-				targ->dv_state_retry--;
-			} else if ((status & SSQ_FALLBACK) != 0) {
-				if (ahd_linux_dv_fallback(ahd, devinfo) != 0) {
-					AHD_SET_DV_STATE(ahd, targ,
-							 AHD_DV_STATE_EXIT);
-					break;
-				}
-				/*
-				 * Do not count "falling back"
-				 * against our retries.
-				 */
-				targ->dv_state_retry = 0;
-			} else if ((status & SS_ERRMASK) == EBUSY)
-				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_BUSY);
-			if (targ->dv_state_retry < 10)
-				break;
-			/* FALLTHROUGH */
-		default:
-			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
-#ifdef AHD_DEBUG
-			if (ahd_debug & AHD_SHOW_DV) {
-				ahd_print_devinfo(ahd, devinfo);
-				printf("Failed DV inquiry, skipping\n");
-			}
-#endif
-			break;
-		}
-		break;
-
-	case AHD_DV_STATE_TUR:
-		switch (status & SS_MASK) {
-		case SS_NOP:
-			if ((targ->flags & AHD_BASIC_DV) != 0) {
-				ahd_linux_filter_inquiry(ahd, devinfo);
-				AHD_SET_DV_STATE(ahd, targ,
-						 AHD_DV_STATE_INQ_VERIFY);
-			} else if ((targ->flags & AHD_ENHANCED_DV) != 0) {
-				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_REBD);
-			} else {
-				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
-			}
-			break;
-		case SS_RETRY:
-		case SS_TUR:
-			if ((status & SS_ERRMASK) == EBUSY) {
-				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_BUSY);
-				break;
-			}
-			AHD_SET_DV_STATE(ahd, targ, targ->dv_state);
-			if (ahd_cmd_get_transaction_status(cmd)
-			 == CAM_REQUEUE_REQ) {
-				targ->dv_state_retry--;
-			} else if ((status & SSQ_FALLBACK) != 0) {
-				if (ahd_linux_dv_fallback(ahd, devinfo) != 0) {
-					AHD_SET_DV_STATE(ahd, targ,
-							 AHD_DV_STATE_EXIT);
-					break;
-				}
-				/*
-				 * Do not count "falling back"
-				 * against our retries.
-				 */
-				targ->dv_state_retry = 0;
-			}
-			if (targ->dv_state_retry >= 10) {
-#ifdef AHD_DEBUG
-				if (ahd_debug & AHD_SHOW_DV) {
-					ahd_print_devinfo(ahd, devinfo);
-					printf("DV TUR reties exhausted\n");
-				}
-#endif
-				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
-				break;
-			}
-			if (status & SSQ_DELAY)
-				scsi_sleep(1 * HZ);
-
-			break;
-		case SS_START:
-			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_SU);
-			break;
-		case SS_INQ_REFRESH:
-			AHD_SET_DV_STATE(ahd, targ,
-					 AHD_DV_STATE_INQ_SHORT_ASYNC);
-			break;
-		default:
-			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
-			break;
-		}
-		break;
-
-	case AHD_DV_STATE_REBD:
-		switch (status & SS_MASK) {
-		case SS_NOP:
-		{
-			uint32_t echo_size;
-
-			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_WEB);
-			echo_size = scsi_3btoul(&targ->dv_buffer[1]);
-			echo_size &= 0x1FFF;
-#ifdef AHD_DEBUG
-			if (ahd_debug & AHD_SHOW_DV) {
-				ahd_print_devinfo(ahd, devinfo);
-				printf("Echo buffer size= %d\n", echo_size);
-			}
-#endif
-			if (echo_size == 0) {
-				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
-				break;
-			}
-
-			/* Generate the buffer pattern */
-			targ->dv_echo_size = echo_size;
-			ahd_linux_generate_dv_pattern(targ);
-			/*
-			 * Setup initial negotiation values.
-			 */
-			ahd_linux_filter_inquiry(ahd, devinfo);
-			break;
-		}
-		case SS_INQ_REFRESH:
-			AHD_SET_DV_STATE(ahd, targ,
-					 AHD_DV_STATE_INQ_SHORT_ASYNC);
-			break;
-		case SS_RETRY:
-			AHD_SET_DV_STATE(ahd, targ, targ->dv_state);
-			if (ahd_cmd_get_transaction_status(cmd)
-			 == CAM_REQUEUE_REQ)
-				targ->dv_state_retry--;
-			if (targ->dv_state_retry <= 10)
-				break;
-#ifdef AHD_DEBUG
-			if (ahd_debug & AHD_SHOW_DV) {
-				ahd_print_devinfo(ahd, devinfo);
-				printf("DV REBD reties exhausted\n");
-			}
-#endif
-			/* FALLTHROUGH */
-		case SS_FATAL:
-		default:
-			/*
-			 * Setup initial negotiation values
-			 * and try level 1 DV.
-			 */
-			ahd_linux_filter_inquiry(ahd, devinfo);
-			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_INQ_VERIFY);
-			targ->dv_echo_size = 0;
-			break;
-		}
-		break;
-
-	case AHD_DV_STATE_WEB:
-		switch (status & SS_MASK) {
-		case SS_NOP:
-			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_REB);
-			break;
-		case SS_INQ_REFRESH:
-			AHD_SET_DV_STATE(ahd, targ,
-					 AHD_DV_STATE_INQ_SHORT_ASYNC);
-			break;
-		case SS_RETRY:
-			AHD_SET_DV_STATE(ahd, targ, targ->dv_state);
-			if (ahd_cmd_get_transaction_status(cmd)
-			 == CAM_REQUEUE_REQ) {
-				targ->dv_state_retry--;
-			} else if ((status & SSQ_FALLBACK) != 0) {
-				if (ahd_linux_dv_fallback(ahd, devinfo) != 0) {
-					AHD_SET_DV_STATE(ahd, targ,
-							 AHD_DV_STATE_EXIT);
-					break;
-				}
-				/*
-				 * Do not count "falling back"
-				 * against our retries.
-				 */
-				targ->dv_state_retry = 0;
-			}
-			if (targ->dv_state_retry <= 10)
-				break;
-			/* FALLTHROUGH */
-#ifdef AHD_DEBUG
-			if (ahd_debug & AHD_SHOW_DV) {
-				ahd_print_devinfo(ahd, devinfo);
-				printf("DV WEB reties exhausted\n");
-			}
-#endif
-		default:
-			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
-			break;
-		}
-		break;
-
-	case AHD_DV_STATE_REB:
-		switch (status & SS_MASK) {
-		case SS_NOP:
-			if (memcmp(targ->dv_buffer, targ->dv_buffer1,
-				   targ->dv_echo_size) != 0) {
-				if (ahd_linux_dv_fallback(ahd, devinfo) != 0)
-					AHD_SET_DV_STATE(ahd, targ,
-							 AHD_DV_STATE_EXIT);
-				else
-					AHD_SET_DV_STATE(ahd, targ,
-							 AHD_DV_STATE_WEB);
-				break;
-			}
-			
-			if (targ->dv_buffer != NULL) {
-				free(targ->dv_buffer, M_DEVBUF);
-				targ->dv_buffer = NULL;
-			}
-			if (targ->dv_buffer1 != NULL) {
-				free(targ->dv_buffer1, M_DEVBUF);
-				targ->dv_buffer1 = NULL;
-			}
-			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
-			break;
-		case SS_INQ_REFRESH:
-			AHD_SET_DV_STATE(ahd, targ,
-					 AHD_DV_STATE_INQ_SHORT_ASYNC);
-			break;
-		case SS_RETRY:
-			AHD_SET_DV_STATE(ahd, targ, targ->dv_state);
-			if (ahd_cmd_get_transaction_status(cmd)
-			 == CAM_REQUEUE_REQ) {
-				targ->dv_state_retry--;
-			} else if ((status & SSQ_FALLBACK) != 0) {
-				if (ahd_linux_dv_fallback(ahd, devinfo) != 0) {
-					AHD_SET_DV_STATE(ahd, targ,
-							 AHD_DV_STATE_EXIT);
-					break;
-				}
-				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_WEB);
-			}
-			if (targ->dv_state_retry <= 10) {
-				if ((status & (SSQ_DELAY_RANDOM|SSQ_DELAY))!= 0)
-					scsi_sleep(ahd->our_id*HZ/10);
-				break;
-			}
-#ifdef AHD_DEBUG
-			if (ahd_debug & AHD_SHOW_DV) {
-				ahd_print_devinfo(ahd, devinfo);
-				printf("DV REB reties exhausted\n");
-			}
-#endif
-			/* FALLTHROUGH */
-		default:
-			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
-			break;
-		}
-		break;
-
-	case AHD_DV_STATE_SU:
-		switch (status & SS_MASK) {
-		case SS_NOP:
-		case SS_INQ_REFRESH:
-			AHD_SET_DV_STATE(ahd, targ,
-					 AHD_DV_STATE_INQ_SHORT_ASYNC);
-			break;
-		default:
-			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
-			break;
-		}
-		break;
-
-	case AHD_DV_STATE_BUSY:
-		switch (status & SS_MASK) {
-		case SS_NOP:
-		case SS_INQ_REFRESH:
-			AHD_SET_DV_STATE(ahd, targ,
-					 AHD_DV_STATE_INQ_SHORT_ASYNC);
-			break;
-		case SS_TUR:
-		case SS_RETRY:
-			AHD_SET_DV_STATE(ahd, targ, targ->dv_state);
-			if (ahd_cmd_get_transaction_status(cmd)
-			 == CAM_REQUEUE_REQ) {
-				targ->dv_state_retry--;
-			} else if (targ->dv_state_retry < 60) {
-				if ((status & SSQ_DELAY) != 0)
-					scsi_sleep(1 * HZ);
-			} else {
-#ifdef AHD_DEBUG
-				if (ahd_debug & AHD_SHOW_DV) {
-					ahd_print_devinfo(ahd, devinfo);
-					printf("DV BUSY reties exhausted\n");
-				}
-#endif
-				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
-			}
-			break;
-		default:
-			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
-			break;
-		}
-		break;
-
-	default:
-		printf("%s: Invalid DV completion state %d\n", ahd_name(ahd),
-		       targ->dv_state);
-		AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
-		break;
-	}
-}
-
-static void
-ahd_linux_dv_fill_cmd(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
-		      struct ahd_devinfo *devinfo)
-{
-	memset(cmd, 0, sizeof(struct scsi_cmnd));
-	cmd->device = ahd->platform_data->dv_scsi_dev;
-	cmd->scsi_done = ahd_linux_dv_complete;
-}
-
-/*
- * Synthesize an inquiry command.  On the return trip, it'll be
- * sniffed and the device transfer settings set for us.
- */
-static void
-ahd_linux_dv_inq(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
-		 struct ahd_devinfo *devinfo, struct ahd_linux_target *targ,
-		 u_int request_length)
-{
-
-#ifdef AHD_DEBUG
-	if (ahd_debug & AHD_SHOW_DV) {
-		ahd_print_devinfo(ahd, devinfo);
-		printf("Sending INQ\n");
-	}
-#endif
-	if (targ->inq_data == NULL)
-		targ->inq_data = malloc(AHD_LINUX_DV_INQ_LEN,
-					M_DEVBUF, M_WAITOK);
-	if (targ->dv_state > AHD_DV_STATE_INQ_ASYNC) {
-		if (targ->dv_buffer != NULL)
-			free(targ->dv_buffer, M_DEVBUF);
-		targ->dv_buffer = malloc(AHD_LINUX_DV_INQ_LEN,
-					 M_DEVBUF, M_WAITOK);
-	}
-
-	ahd_linux_dv_fill_cmd(ahd, cmd, devinfo);
-	cmd->sc_data_direction = SCSI_DATA_READ;
-	cmd->cmd_len = 6;
-	cmd->cmnd[0] = INQUIRY;
-	cmd->cmnd[4] = request_length;
-	cmd->request_bufflen = request_length;
-	if (targ->dv_state > AHD_DV_STATE_INQ_ASYNC)
-		cmd->request_buffer = targ->dv_buffer;
-	else
-		cmd->request_buffer = targ->inq_data;
-	memset(cmd->request_buffer, 0, AHD_LINUX_DV_INQ_LEN);
-}
-
-static void
-ahd_linux_dv_tur(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
-		 struct ahd_devinfo *devinfo)
-{
-
-#ifdef AHD_DEBUG
-	if (ahd_debug & AHD_SHOW_DV) {
-		ahd_print_devinfo(ahd, devinfo);
-		printf("Sending TUR\n");
-	}
-#endif
-	/* Do a TUR to clear out any non-fatal transitional state */
-	ahd_linux_dv_fill_cmd(ahd, cmd, devinfo);
-	cmd->sc_data_direction = SCSI_DATA_NONE;
-	cmd->cmd_len = 6;
-	cmd->cmnd[0] = TEST_UNIT_READY;
-}
-
-#define AHD_REBD_LEN 4
-
-static void
-ahd_linux_dv_rebd(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
-		 struct ahd_devinfo *devinfo, struct ahd_linux_target *targ)
-{
-
-#ifdef AHD_DEBUG
-	if (ahd_debug & AHD_SHOW_DV) {
-		ahd_print_devinfo(ahd, devinfo);
-		printf("Sending REBD\n");
-	}
-#endif
-	if (targ->dv_buffer != NULL)
-		free(targ->dv_buffer, M_DEVBUF);
-	targ->dv_buffer = malloc(AHD_REBD_LEN, M_DEVBUF, M_WAITOK);
-	ahd_linux_dv_fill_cmd(ahd, cmd, devinfo);
-	cmd->sc_data_direction = SCSI_DATA_READ;
-	cmd->cmd_len = 10;
-	cmd->cmnd[0] = READ_BUFFER;
-	cmd->cmnd[1] = 0x0b;
-	scsi_ulto3b(AHD_REBD_LEN, &cmd->cmnd[6]);
-	cmd->request_bufflen = AHD_REBD_LEN;
-	cmd->underflow = cmd->request_bufflen;
-	cmd->request_buffer = targ->dv_buffer;
-}
-
-static void
-ahd_linux_dv_web(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
-		 struct ahd_devinfo *devinfo, struct ahd_linux_target *targ)
-{
-
-#ifdef AHD_DEBUG
-	if (ahd_debug & AHD_SHOW_DV) {
-		ahd_print_devinfo(ahd, devinfo);
-		printf("Sending WEB\n");
-	}
-#endif
-	ahd_linux_dv_fill_cmd(ahd, cmd, devinfo);
-	cmd->sc_data_direction = SCSI_DATA_WRITE;
-	cmd->cmd_len = 10;
-	cmd->cmnd[0] = WRITE_BUFFER;
-	cmd->cmnd[1] = 0x0a;
-	scsi_ulto3b(targ->dv_echo_size, &cmd->cmnd[6]);
-	cmd->request_bufflen = targ->dv_echo_size;
-	cmd->underflow = cmd->request_bufflen;
-	cmd->request_buffer = targ->dv_buffer;
-}
-
-static void
-ahd_linux_dv_reb(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
-		 struct ahd_devinfo *devinfo, struct ahd_linux_target *targ)
-{
-
-#ifdef AHD_DEBUG
-	if (ahd_debug & AHD_SHOW_DV) {
-		ahd_print_devinfo(ahd, devinfo);
-		printf("Sending REB\n");
-	}
-#endif
-	ahd_linux_dv_fill_cmd(ahd, cmd, devinfo);
-	cmd->sc_data_direction = SCSI_DATA_READ;
-	cmd->cmd_len = 10;
-	cmd->cmnd[0] = READ_BUFFER;
-	cmd->cmnd[1] = 0x0a;
-	scsi_ulto3b(targ->dv_echo_size, &cmd->cmnd[6]);
-	cmd->request_bufflen = targ->dv_echo_size;
-	cmd->underflow = cmd->request_bufflen;
-	cmd->request_buffer = targ->dv_buffer1;
-}
-
-static void
-ahd_linux_dv_su(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
-		struct ahd_devinfo *devinfo,
-		struct ahd_linux_target *targ)
-{
-	u_int le;
-
-	le = SID_IS_REMOVABLE(targ->inq_data) ? SSS_LOEJ : 0;
-
-#ifdef AHD_DEBUG
-	if (ahd_debug & AHD_SHOW_DV) {
-		ahd_print_devinfo(ahd, devinfo);
-		printf("Sending SU\n");
-	}
-#endif
-	ahd_linux_dv_fill_cmd(ahd, cmd, devinfo);
-	cmd->sc_data_direction = SCSI_DATA_NONE;
-	cmd->cmd_len = 6;
-	cmd->cmnd[0] = START_STOP_UNIT;
-	cmd->cmnd[4] = le | SSS_START;
-}
-
-static __inline int
-ahd_linux_dv_fallback(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
-{
-	u_long s;
-	int retval;
-
-	ahd_lock(ahd, &s);
-	retval = ahd_linux_fallback(ahd, devinfo);
-	ahd_unlock(ahd, &s);
-
-	return (retval);
-}
-
-static int
-ahd_linux_fallback(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
-{
-	struct	ahd_linux_target *targ;
-	struct	ahd_initiator_tinfo *tinfo;
-	struct	ahd_transinfo *goal;
-	struct	ahd_tmode_tstate *tstate;
-	u_int	width;
-	u_int	period;
-	u_int	offset;
-	u_int	ppr_options;
-	u_int	cur_speed;
-	u_int	wide_speed;
-	u_int	narrow_speed;
-	u_int	fallback_speed;
-
-#ifdef AHD_DEBUG
-	if (ahd_debug & AHD_SHOW_DV) {
-		ahd_print_devinfo(ahd, devinfo);
-		printf("Trying to fallback\n");
-	}
-#endif
-	targ = ahd->platform_data->targets[devinfo->target_offset];
-	tinfo = ahd_fetch_transinfo(ahd, devinfo->channel,
-				    devinfo->our_scsiid,
-				    devinfo->target, &tstate);
-	goal = &tinfo->goal;
-	width = goal->width;
-	period = goal->period;
-	offset = goal->offset;
-	ppr_options = goal->ppr_options;
-	if (offset == 0)
-		period = AHD_ASYNC_XFER_PERIOD;
-	if (targ->dv_next_narrow_period == 0)
-		targ->dv_next_narrow_period = MAX(period, AHD_SYNCRATE_ULTRA2);
-	if (targ->dv_next_wide_period == 0)
-		targ->dv_next_wide_period = period;
-	if (targ->dv_max_width == 0)
-		targ->dv_max_width = width;
-	if (targ->dv_max_ppr_options == 0)
-		targ->dv_max_ppr_options = ppr_options;
-	if (targ->dv_last_ppr_options == 0)
-		targ->dv_last_ppr_options = ppr_options;
-
-	cur_speed = aic_calc_speed(width, period, offset, AHD_SYNCRATE_MIN);
-	wide_speed = aic_calc_speed(MSG_EXT_WDTR_BUS_16_BIT,
-					  targ->dv_next_wide_period,
-					  MAX_OFFSET, AHD_SYNCRATE_MIN);
-	narrow_speed = aic_calc_speed(MSG_EXT_WDTR_BUS_8_BIT,
-					    targ->dv_next_narrow_period,
-					    MAX_OFFSET, AHD_SYNCRATE_MIN);
-	fallback_speed = aic_calc_speed(width, period+1, offset,
-					      AHD_SYNCRATE_MIN);
-#ifdef AHD_DEBUG
-	if (ahd_debug & AHD_SHOW_DV) {
-		printf("cur_speed= %d, wide_speed= %d, narrow_speed= %d, "
-		       "fallback_speed= %d\n", cur_speed, wide_speed,
-		       narrow_speed, fallback_speed);
-	}
-#endif
-
-	if (cur_speed > 160000) {
-		/*
-		 * Paced/DT/IU_REQ only transfer speeds.  All we
-		 * can do is fallback in terms of syncrate.
-		 */
-		period++;
-	} else if (cur_speed > 80000) {
-		if ((ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
-			/*
-			 * Try without IU_REQ as it may be confusing
-			 * an expander.
-			 */
-			ppr_options &= ~MSG_EXT_PPR_IU_REQ;
-		} else {
-			/*
-			 * Paced/DT only transfer speeds.  All we
-			 * can do is fallback in terms of syncrate.
-			 */
-			period++;
-			ppr_options = targ->dv_max_ppr_options;
-		}
-	} else if (cur_speed > 3300) {
-
-		/*
-		 * In this range we the following
-		 * options ordered from highest to
-		 * lowest desireability:
-		 *
-		 * o Wide/DT
-		 * o Wide/non-DT
-		 * o Narrow at a potentally higher sync rate.
-		 *
-		 * All modes are tested with and without IU_REQ
-		 * set since using IUs may confuse an expander.
-		 */
-		if ((ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
-
-			ppr_options &= ~MSG_EXT_PPR_IU_REQ;
-		} else if ((ppr_options & MSG_EXT_PPR_DT_REQ) != 0) {
-			/*
-			 * Try going non-DT.
-			 */
-			ppr_options = targ->dv_max_ppr_options;
-			ppr_options &= ~MSG_EXT_PPR_DT_REQ;
-		} else if (targ->dv_last_ppr_options != 0) {
-			/*
-			 * Try without QAS or any other PPR options.
-			 * We may need a non-PPR message to work with
-			 * an expander.  We look at the "last PPR options"
-			 * so we will perform this fallback even if the
-			 * target responded to our PPR negotiation with
-			 * no option bits set.
-			 */
-			ppr_options = 0;
-		} else if (width == MSG_EXT_WDTR_BUS_16_BIT) {
-			/*
-			 * If the next narrow speed is greater than
-			 * the next wide speed, fallback to narrow.
-			 * Otherwise fallback to the next DT/Wide setting.
-			 * The narrow async speed will always be smaller
-			 * than the wide async speed, so handle this case
-			 * specifically.
-			 */
-			ppr_options = targ->dv_max_ppr_options;
-			if (narrow_speed > fallback_speed
-			 || period >= AHD_ASYNC_XFER_PERIOD) {
-				targ->dv_next_wide_period = period+1;
-				width = MSG_EXT_WDTR_BUS_8_BIT;
-				period = targ->dv_next_narrow_period;
-			} else {
-				period++;
-			}
-		} else if ((ahd->features & AHD_WIDE) != 0
-			&& targ->dv_max_width != 0
-			&& wide_speed >= fallback_speed
-			&& (targ->dv_next_wide_period <= AHD_ASYNC_XFER_PERIOD
-			 || period >= AHD_ASYNC_XFER_PERIOD)) {
-
-			/*
-			 * We are narrow.  Try falling back
-			 * to the next wide speed with 
-			 * all supported ppr options set.
-			 */
-			targ->dv_next_narrow_period = period+1;
-			width = MSG_EXT_WDTR_BUS_16_BIT;
-			period = targ->dv_next_wide_period;
-			ppr_options = targ->dv_max_ppr_options;
-		} else {
-			/* Only narrow fallback is allowed. */
-			period++;
-			ppr_options = targ->dv_max_ppr_options;
-		}
-	} else {
-		return (-1);
-	}
-	offset = MAX_OFFSET;
-	ahd_find_syncrate(ahd, &period, &ppr_options, AHD_SYNCRATE_PACED);
-	ahd_set_width(ahd, devinfo, width, AHD_TRANS_GOAL, FALSE);
-	if (period == 0) {
-		period = 0;
-		offset = 0;
-		ppr_options = 0;
-		if (width == MSG_EXT_WDTR_BUS_8_BIT)
-			targ->dv_next_narrow_period = AHD_ASYNC_XFER_PERIOD;
-		else
-			targ->dv_next_wide_period = AHD_ASYNC_XFER_PERIOD;
-	}
-	ahd_set_syncrate(ahd, devinfo, period, offset,
-			 ppr_options, AHD_TRANS_GOAL, FALSE);
-	targ->dv_last_ppr_options = ppr_options;
-	return (0);
-}
-
-static void
-ahd_linux_dv_timeout(struct scsi_cmnd *cmd)
-{
-	struct	ahd_softc *ahd;
-	struct	ahd_cmd *acmd;
-	struct	ahd_linux_device *next_dev;
-	struct	scb *scb;
-	u_long	flags;
-
-	ahd = *((struct ahd_softc **)cmd->device->host->hostdata);
-	ahd_lock(ahd, &flags);
-
-#ifdef AHD_DEBUG
-	if (ahd_debug & AHD_SHOW_DV) {
-		printf("%s: Timeout while doing DV command %x.\n",
-		       ahd_name(ahd), cmd->cmnd[0]);
-		ahd_dump_card_state(ahd);
-	}
-#endif
-	
-	/*
-	 * Guard against "done race".  No action is
-	 * required if we just completed.
-	 */
-	if ((scb = (struct scb *)cmd->host_scribble) == NULL) {
-		ahd_unlock(ahd, &flags);
-		return;
-	}
-
-	/*
-	 * Command has not completed.  Mark this
-	 * SCB as having failing status prior to
-	 * resetting the bus, so we get the correct
-	 * error code.
-	 */
-	if ((scb->flags & SCB_SENSE) != 0)
-		ahd_set_transaction_status(scb, CAM_AUTOSENSE_FAIL);
-	else
-		ahd_set_transaction_status(scb, CAM_CMD_TIMEOUT);
-	ahd_reset_channel(ahd, cmd->channel + 'A', /*initiate*/TRUE);
-
-	/*
-	 * Add a minimal bus settle delay for devices that are slow to
-	 * respond after bus resets.
-	 */
-	ahd_freeze_simq(ahd);
-	init_timer(&ahd->platform_data->reset_timer);
-	ahd->platform_data->reset_timer.data = (u_long)ahd;
-	ahd->platform_data->reset_timer.expires = jiffies + HZ / 2;
-	ahd->platform_data->reset_timer.function =
-	    (ahd_linux_callback_t *)ahd_release_simq;
-	add_timer(&ahd->platform_data->reset_timer);
-	/*
-	 * In 2.5.X, the "done lock" is the ahd_lock.
-	 * Instead of dropping and re-acquiring the same
-	 * lock in the 2.5.X case, just hold our ahd_lock
-	 * the whole time.  ahd_done_lock() has been
-	 * made a no-op for 2.5.X too.
-	 */
-	acmd = TAILQ_FIRST(&ahd->platform_data->completeq);
-	TAILQ_INIT(&ahd->platform_data->completeq);
-	next_dev = ahd_linux_next_device_to_run(ahd);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	ahd_unlock(ahd, &flags);
-#endif
-	if (next_dev)
-		ahd_schedule_runq(ahd);
-	if (acmd != NULL) {
-		acmd = ahd_linux_run_complete_queue(ahd, acmd);
-		if (acmd != NULL) {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-			ahd_lock(ahd, &flags);
-#endif
-			ahd_schedule_completeq(ahd, acmd);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-			ahd_unlock(ahd, &flags);
-#endif
-		}
-	}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-	ahd_unlock(ahd, &flags);
-#endif
-}
-
-static void
-ahd_linux_dv_complete(struct scsi_cmnd *cmd)
-{
-	struct ahd_softc *ahd;
-
-	ahd = *((struct ahd_softc **)cmd->device->host->hostdata);
-
-	/* Delete the DV timer before it goes off! */
-	scsi_delete_timer(cmd);
-
-#ifdef AHD_DEBUG
-	if (ahd_debug & AHD_SHOW_DV)
-		printf("%s:%c:%d: Command completed, status= 0x%x\n",
-		       ahd_name(ahd), cmd->device->channel, cmd->device->id,
-		       cmd->result);
-#endif
-
-	/* Wake up the state machine */
-	up(&ahd->platform_data->dv_cmd_sem);
-}
-
-static void
-ahd_linux_generate_dv_pattern(struct ahd_linux_target *targ)
-{
-	uint16_t b;
-	u_int	 i;
-	u_int	 j;
-
-	if (targ->dv_buffer != NULL)
-		free(targ->dv_buffer, M_DEVBUF);
-	targ->dv_buffer = malloc(targ->dv_echo_size, M_DEVBUF, M_WAITOK);
-	if (targ->dv_buffer1 != NULL)
-		free(targ->dv_buffer1, M_DEVBUF);
-	targ->dv_buffer1 = malloc(targ->dv_echo_size, M_DEVBUF, M_WAITOK);
-
-	i = 0;
-
-	b = 0x0001;
-	for (j = 0 ; i < targ->dv_echo_size; j++) {
-		if (j < 32) {
-			/*
-			 * 32bytes of sequential numbers.
-			 */
-			targ->dv_buffer[i++] = j & 0xff;
-		} else if (j < 48) {
-			/*
-			 * 32bytes of repeating 0x0000, 0xffff.
-			 */
-			targ->dv_buffer[i++] = (j & 0x02) ? 0xff : 0x00;
-		} else if (j < 64) {
-			/*
-			 * 32bytes of repeating 0x5555, 0xaaaa.
-			 */
-			targ->dv_buffer[i++] = (j & 0x02) ? 0xaa : 0x55;
-		} else {
-			/*
-			 * Remaining buffer is filled with a repeating
-			 * patter of:
-			 *
-			 *	 0xffff
-			 *	~0x0001 << shifted once in each loop.
-			 */
-			if (j & 0x02) {
-				if (j & 0x01) {
-					targ->dv_buffer[i++] = ~(b >> 8) & 0xff;
-					b <<= 1;
-					if (b == 0x0000)
-						b = 0x0001;
-				} else {
-					targ->dv_buffer[i++] = (~b & 0xff);
-				}
-			} else {
-				targ->dv_buffer[i++] = 0xff;
-			}
-		}
-	}
-}
-
-static u_int
-ahd_linux_user_tagdepth(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
-{
-	static int warned_user;
-	u_int tags;
-
-	tags = 0;
-	if ((ahd->user_discenable & devinfo->target_mask) != 0) {
-		if (warned_user == 0
-		 && ahd->unit >= NUM_ELEMENTS(aic79xx_tag_info)) {
-
-			printf("aic79xx: WARNING, insufficient "
-			       "tag_info instances for installed "
-			       "controllers. Using defaults\n");
-			printf("aic79xx: Please update the "
-			       "aic79xx_tag_info array in the "
-			       "aic79xx.c source file.\n");
-			tags = AHD_MAX_QUEUE;
-			warned_user++;
-		} else {
-			adapter_tag_info_t *tag_info;
-
-			tag_info = &aic79xx_tag_info[ahd->unit];
-			tags = tag_info->tag_commands[devinfo->target_offset];
-			if (tags > AHD_MAX_QUEUE)
-				tags = AHD_MAX_QUEUE;
-		}
-	}
-	return (tags);
-}
-
-static u_int
-ahd_linux_user_dv_setting(struct ahd_softc *ahd)
-{
-	static int warned_user;
-	int dv;
-
-	if (warned_user == 0
-	 && ahd->unit >= NUM_ELEMENTS(aic79xx_dv_settings)) {
-
-		printf("aic79xx: WARNING, insufficient "
-		       "dv settings instances for installed "
-		       "controllers. Using defaults\n");
-		printf("aic79xx: Please update the "
-		       "aic79xx_dv_settings array in the "
-		       "aic79xx.c source file.\n");
-		dv = -1;
-		warned_user++;
-	} else {
-
-		dv = aic79xx_dv_settings[ahd->unit];
-	}
-
-	if (dv < 0) {
-		/*
-		 * Apply the default.
-		 */
-		dv = 1;
-		if (ahd->seep_config != 0)
-			dv = (ahd->seep_config->bios_control & CFENABLEDV);
-	}
-	return (dv);
-}
-
-/*
- * Determines the queue depth for a given device.
- */
-static void
-ahd_linux_device_queue_depth(struct ahd_softc *ahd,
-			     struct ahd_linux_device *dev)
-{
-	struct	ahd_devinfo devinfo;
-	u_int	tags;
-
-	ahd_compile_devinfo(&devinfo,
-			    ahd->our_id,
-			    dev->target->target, dev->lun,
-			    dev->target->channel == 0 ? 'A' : 'B',
-			    ROLE_INITIATOR);
-	tags = ahd_linux_user_tagdepth(ahd, &devinfo);
-	if (tags != 0
-	 && dev->scsi_device != NULL
-	 && dev->scsi_device->tagged_supported != 0) {
-
-		ahd_set_tags(ahd, &devinfo, AHD_QUEUE_TAGGED);
-		printf("scsi%d:%c:%d:%d: Tagged Queuing enabled.  Depth %d\n",
-	       	       ahd->platform_data->host->host_no, devinfo.channel,
-		       devinfo.target, devinfo.lun, tags);
-	} else {
-		ahd_set_tags(ahd, &devinfo, AHD_QUEUE_NONE);
-	}
-}
-
-static void
-ahd_linux_run_device_queue(struct ahd_softc *ahd, struct ahd_linux_device *dev)
-{
-	struct	 ahd_cmd *acmd;
-	struct	 scsi_cmnd *cmd;
-	struct	 scb *scb;
-	struct	 hardware_scb *hscb;
-	struct	 ahd_initiator_tinfo *tinfo;
-	struct	 ahd_tmode_tstate *tstate;
-	u_int	 col_idx;
-	uint16_t mask;
-
-	if ((dev->flags & AHD_DEV_ON_RUN_LIST) != 0)
-		panic("running device on run list");
-
-	while ((acmd = TAILQ_FIRST(&dev->busyq)) != NULL
-	    && dev->openings > 0 && dev->qfrozen == 0) {
-
-		/*
-		 * Schedule us to run later.  The only reason we are not
-		 * running is because the whole controller Q is frozen.
-		 */
-		if (ahd->platform_data->qfrozen != 0
-		 && AHD_DV_SIMQ_FROZEN(ahd) == 0) {
-
-			TAILQ_INSERT_TAIL(&ahd->platform_data->device_runq,
-					  dev, links);
-			dev->flags |= AHD_DEV_ON_RUN_LIST;
-			return;
-		}
-
-		cmd = &acmd_scsi_cmd(acmd);
-
-		/*
-		 * Get an scb to use.
-		 */
-		tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
-					    cmd->device->id, &tstate);
-		if ((dev->flags & (AHD_DEV_Q_TAGGED|AHD_DEV_Q_BASIC)) == 0
-		 || (tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
-			col_idx = AHD_NEVER_COL_IDX;
-		} else {
-			col_idx = AHD_BUILD_COL_IDX(cmd->device->id,
-						    cmd->device->lun);
-		}
-		if ((scb = ahd_get_scb(ahd, col_idx)) == NULL) {
-			TAILQ_INSERT_TAIL(&ahd->platform_data->device_runq,
-					 dev, links);
-			dev->flags |= AHD_DEV_ON_RUN_LIST;
-			ahd->flags |= AHD_RESOURCE_SHORTAGE;
-			return;
-		}
-		TAILQ_REMOVE(&dev->busyq, acmd, acmd_links.tqe);
-		scb->io_ctx = cmd;
-		scb->platform_data->dev = dev;
-		hscb = scb->hscb;
-		cmd->host_scribble = (char *)scb;
-
-		/*
-		 * Fill out basics of the HSCB.
-		 */
-		hscb->control = 0;
-		hscb->scsiid = BUILD_SCSIID(ahd, cmd);
-		hscb->lun = cmd->lun;
-		scb->hscb->task_management = 0;
-		mask = SCB_GET_TARGET_MASK(ahd, scb);
-
-		if ((ahd->user_discenable & mask) != 0)
-			hscb->control |= DISCENB;
-
-	 	if (AHD_DV_CMD(cmd) != 0)
-			scb->flags |= SCB_SILENT;
-
-		if ((tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0)
-			scb->flags |= SCB_PACKETIZED;
-
-		if ((tstate->auto_negotiate & mask) != 0) {
-			scb->flags |= SCB_AUTO_NEGOTIATE;
-			scb->hscb->control |= MK_MESSAGE;
-		}
-
-		if ((dev->flags & (AHD_DEV_Q_TAGGED|AHD_DEV_Q_BASIC)) != 0) {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-			int	msg_bytes;
-			uint8_t tag_msgs[2];
-
-			msg_bytes = scsi_populate_tag_msg(cmd, tag_msgs);
-			if (msg_bytes && tag_msgs[0] != MSG_SIMPLE_TASK) {
-				hscb->control |= tag_msgs[0];
-				if (tag_msgs[0] == MSG_ORDERED_TASK)
-					dev->commands_since_idle_or_otag = 0;
-			} else
-#endif
-			if (dev->commands_since_idle_or_otag == AHD_OTAG_THRESH
-			 && (dev->flags & AHD_DEV_Q_TAGGED) != 0) {
-				hscb->control |= MSG_ORDERED_TASK;
-				dev->commands_since_idle_or_otag = 0;
-			} else {
-				hscb->control |= MSG_SIMPLE_TASK;
-			}
-		}
-
-		hscb->cdb_len = cmd->cmd_len;
-		memcpy(hscb->shared_data.idata.cdb, cmd->cmnd, hscb->cdb_len);
-
-		scb->sg_count = 0;
-		ahd_set_residual(scb, 0);
-		ahd_set_sense_residual(scb, 0);
-		if (cmd->use_sg != 0) {
-			void	*sg;
-			struct	 scatterlist *cur_seg;
-			u_int	 nseg;
-			int	 dir;
-
-			cur_seg = (struct scatterlist *)cmd->request_buffer;
-			dir = scsi_to_pci_dma_dir(cmd->sc_data_direction);
-			nseg = pci_map_sg(ahd->dev_softc, cur_seg,
-					  cmd->use_sg, dir);
-			scb->platform_data->xfer_len = 0;
-			for (sg = scb->sg_list; nseg > 0; nseg--, cur_seg++) {
-				bus_addr_t addr;
-				bus_size_t len;
-
-				addr = sg_dma_address(cur_seg);
-				len = sg_dma_len(cur_seg);
-				scb->platform_data->xfer_len += len;
-				sg = ahd_sg_setup(ahd, scb, sg, addr, len,
-						  /*last*/nseg == 1);
-			}
-		} else if (cmd->request_bufflen != 0) {
-			void *sg;
-			bus_addr_t addr;
-			int dir;
-
-			sg = scb->sg_list;
-			dir = scsi_to_pci_dma_dir(cmd->sc_data_direction);
-			addr = pci_map_single(ahd->dev_softc,
-					      cmd->request_buffer,
-					      cmd->request_bufflen, dir);
-			scb->platform_data->xfer_len = cmd->request_bufflen;
-			scb->platform_data->buf_busaddr = addr;
-			sg = ahd_sg_setup(ahd, scb, sg, addr,
-					  cmd->request_bufflen, /*last*/TRUE);
-		}
-
-		LIST_INSERT_HEAD(&ahd->pending_scbs, scb, pending_links);
-		dev->openings--;
-		dev->active++;
-		dev->commands_issued++;
-
-		/* Update the error counting bucket and dump if needed */
-		if (dev->target->cmds_since_error) {
-			dev->target->cmds_since_error++;
-			if (dev->target->cmds_since_error >
-			    AHD_LINUX_ERR_THRESH)
-				dev->target->cmds_since_error = 0;
-		}
-
-		if ((dev->flags & AHD_DEV_PERIODIC_OTAG) != 0)
-			dev->commands_since_idle_or_otag++;
-		scb->flags |= SCB_ACTIVE;
-		ahd_queue_scb(ahd, scb);
-	}
-}
-
-/*
- * SCSI controller interrupt handler.
- */
-void
-ahd_linux_isr(int irq, void *dev_id, struct pt_regs * regs)
-{
-	struct	ahd_softc *ahd;
-	struct	ahd_cmd *acmd;
-	u_long	flags;
-	struct	ahd_linux_device *next_dev;
-
-	ahd = (struct ahd_softc *) dev_id;
-	ahd_lock(ahd, &flags); 
-	ahd_intr(ahd);
-	acmd = TAILQ_FIRST(&ahd->platform_data->completeq);
-	TAILQ_INIT(&ahd->platform_data->completeq);
-	next_dev = ahd_linux_next_device_to_run(ahd);
-	/*
-	 * In 2.5.X, the "done lock" is the ahd_lock.
-	 * Instead of dropping and re-acquiring the same
-	 * lock in the 2.5.X case, just hold our ahd_lock
-	 * the whole time.  ahd_done_lock() has been
-	 * made a no-op for 2.5.X too.
-	 */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	ahd_unlock(ahd, &flags);
-#endif
-	if (next_dev)
-		ahd_schedule_runq(ahd);
-	if (acmd != NULL) {
-		acmd = ahd_linux_run_complete_queue(ahd, acmd);
-		if (acmd != NULL) {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-			ahd_lock(ahd, &flags);
-#endif
-			ahd_schedule_completeq(ahd, acmd);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-			ahd_unlock(ahd, &flags);
-#endif
-		}
-	}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-	ahd_unlock(ahd, &flags);
-#endif
-}
-
-void
-ahd_platform_flushwork(struct ahd_softc *ahd)
-{
-	struct ahd_cmd *acmd;
-
-	acmd = TAILQ_FIRST(&ahd->platform_data->completeq);
-	TAILQ_INIT(&ahd->platform_data->completeq);
-	while (acmd != NULL)
-		acmd = ahd_linux_run_complete_queue(ahd, acmd);
-}
-
-static struct ahd_linux_target*
-ahd_linux_alloc_target(struct ahd_softc *ahd, u_int channel, u_int target)
-{
-	struct ahd_linux_target *targ;
-	u_int target_offset;
-
-	target_offset = target;
-	/*
-	 * Never allow allocation of a target object for
-	 * our own SCSIID.
-	 */
-	if (target == ahd->our_id) {
-		ahd->platform_data->targets[target_offset] = NULL;
-		return (NULL);
-	}
-
-	targ = malloc(sizeof(*targ), M_DEVBUF, M_NOWAIT);
-	if (targ == NULL)
-		return (NULL);
-	memset(targ, 0, sizeof(*targ));
-	targ->channel = channel;
-	targ->target = target;
-	targ->ahd = ahd;
-	targ->flags = AHD_DV_REQUIRED;
-	ahd->platform_data->targets[target_offset] = targ;
-	return (targ);
-}
-
-static void
-ahd_linux_free_target(struct ahd_softc *ahd, struct ahd_linux_target *targ)
-{
-	struct ahd_devinfo devinfo;
-	struct ahd_initiator_tinfo *tinfo;
-	struct ahd_tmode_tstate *tstate;
-	u_int our_id;
-	u_int target_offset;
-	char channel;
-
-	/*
-	 * Force a negotiation to async/narrow on any
-	 * future command to this device unless a bus
-	 * reset occurs between now and that command.
-	 */
-	channel = 'A' + targ->channel;
-	our_id = ahd->our_id;
-	target_offset = targ->target;
-	tinfo = ahd_fetch_transinfo(ahd, channel, our_id,
-				    targ->target, &tstate);
-	ahd_compile_devinfo(&devinfo, our_id, targ->target, CAM_LUN_WILDCARD,
-			    channel, ROLE_INITIATOR);
-	ahd_set_syncrate(ahd, &devinfo, 0, 0, 0,
-			 AHD_TRANS_GOAL, /*paused*/FALSE);
-	ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
-		      AHD_TRANS_GOAL, /*paused*/FALSE);
-	ahd_update_neg_request(ahd, &devinfo, tstate, tinfo, AHD_NEG_ALWAYS);
- 	ahd->platform_data->targets[target_offset] = NULL;
-	if (targ->inq_data != NULL)
-		free(targ->inq_data, M_DEVBUF);
-	if (targ->dv_buffer != NULL)
-		free(targ->dv_buffer, M_DEVBUF);
-	if (targ->dv_buffer1 != NULL)
-		free(targ->dv_buffer1, M_DEVBUF);
-	free(targ, M_DEVBUF);
-}
-
-static struct ahd_linux_device*
-ahd_linux_alloc_device(struct ahd_softc *ahd,
-		 struct ahd_linux_target *targ, u_int lun)
-{
-	struct ahd_linux_device *dev;
-
-	dev = malloc(sizeof(*dev), M_DEVBUG, M_NOWAIT);
-	if (dev == NULL)
-		return (NULL);
-	memset(dev, 0, sizeof(*dev));
-	init_timer(&dev->timer);
-	TAILQ_INIT(&dev->busyq);
-	dev->flags = AHD_DEV_UNCONFIGURED;
-	dev->lun = lun;
-	dev->target = targ;
-
-	/*
-	 * We start out life using untagged
-	 * transactions of which we allow one.
-	 */
-	dev->openings = 1;
-
-	/*
-	 * Set maxtags to 0.  This will be changed if we
-	 * later determine that we are dealing with
-	 * a tagged queuing capable device.
-	 */
-	dev->maxtags = 0;
-	
-	targ->refcount++;
-	targ->devices[lun] = dev;
-	return (dev);
-}
-
-static void
-ahd_linux_free_device(struct ahd_softc *ahd, struct ahd_linux_device *dev)
-{
-	struct ahd_linux_target *targ;
-
-	del_timer(&dev->timer);
-	targ = dev->target;
-	targ->devices[dev->lun] = NULL;
-	free(dev, M_DEVBUF);
-	targ->refcount--;
-	if (targ->refcount == 0
-	 && (targ->flags & AHD_DV_REQUIRED) == 0)
-		ahd_linux_free_target(ahd, targ);
-}
-
-void
-ahd_send_async(struct ahd_softc *ahd, char channel,
-	       u_int target, u_int lun, ac_code code, void *arg)
-{
-	switch (code) {
-	case AC_TRANSFER_NEG:
-	{
-		char	buf[80];
-		struct	ahd_linux_target *targ;
-		struct	info_str info;
-		struct	ahd_initiator_tinfo *tinfo;
-		struct	ahd_tmode_tstate *tstate;
-
-		info.buffer = buf;
-		info.length = sizeof(buf);
-		info.offset = 0;
-		info.pos = 0;
-		tinfo = ahd_fetch_transinfo(ahd, channel, ahd->our_id,
-					    target, &tstate);
-
-		/*
-		 * Don't bother reporting results while
-		 * negotiations are still pending.
-		 */
-		if (tinfo->curr.period != tinfo->goal.period
-		 || tinfo->curr.width != tinfo->goal.width
-		 || tinfo->curr.offset != tinfo->goal.offset
-		 || tinfo->curr.ppr_options != tinfo->goal.ppr_options)
-			if (bootverbose == 0)
-				break;
-
-		/*
-		 * Don't bother reporting results that
-		 * are identical to those last reported.
-		 */
-		targ = ahd->platform_data->targets[target];
-		if (targ == NULL)
-			break;
-		if (tinfo->curr.period == targ->last_tinfo.period
-		 && tinfo->curr.width == targ->last_tinfo.width
-		 && tinfo->curr.offset == targ->last_tinfo.offset
-		 && tinfo->curr.ppr_options == targ->last_tinfo.ppr_options)
-			if (bootverbose == 0)
-				break;
-
-		targ->last_tinfo.period = tinfo->curr.period;
-		targ->last_tinfo.width = tinfo->curr.width;
-		targ->last_tinfo.offset = tinfo->curr.offset;
-		targ->last_tinfo.ppr_options = tinfo->curr.ppr_options;
-
-		printf("(%s:%c:", ahd_name(ahd), channel);
-		if (target == CAM_TARGET_WILDCARD)
-			printf("*): ");
-		else
-			printf("%d): ", target);
-		ahd_format_transinfo(&info, &tinfo->curr);
-		if (info.pos < info.length)
-			*info.buffer = '\0';
-		else
-			buf[info.length - 1] = '\0';
-		printf("%s", buf);
-		break;
-	}
-        case AC_SENT_BDR:
-	{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
-		Scsi_Device *scsi_dev;
-
-		/*
-		 * Find the SCSI device associated with this
-		 * request and indicate that a UA is expected.
-		 * XXX This should really be handled by the mid-layer.
-		 */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-		list_for_each_entry(scsi_dev,
-				    &ahd->platform_data->host->my_devices,
-				    siblings) {
-#else
-		for (scsi_dev = ahd->platform_data->host->host_queue;
-		     scsi_dev != NULL; scsi_dev = scsi_dev->next) {
-#endif
-			if (channel - 'A' == scsi_dev->channel
-			 && target == scsi_dev->id
-			 && (lun == CAM_LUN_WILDCARD
-			  || lun == scsi_dev->lun)) {
-				scsi_dev->was_reset = 1;
-				scsi_dev->expecting_cc_ua = 1;
-			}
-		}
-#endif
-		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");
-        }
-}
-
-/*
- * Calls the higher level scsi done function and frees the scb.
- */
-void
-ahd_done(struct ahd_softc *ahd, struct scb *scb)
-{
-	Scsi_Cmnd *cmd;
-	struct	  ahd_linux_device *dev;
-
-	LIST_REMOVE(scb, pending_links);
-
-	if ((scb->flags & SCB_ACTIVE) == 0) {
-		printf("SCB %d done'd twice\n", scb->hscb->tag);
-		ahd_dump_card_state(ahd);
-		panic("Stopping for safety");
-	}
-	cmd = scb->io_ctx;
-	dev = scb->platform_data->dev;
-	dev->active--;
-	dev->openings++;
-	if ((cmd->result & (CAM_DEV_QFRZN << 16)) != 0) {
-		cmd->result &= ~(CAM_DEV_QFRZN << 16);
-		dev->qfrozen--;
-	}
-	ahd_linux_unmap_scb(ahd, scb);
-
-	/*
-	 * Guard against stale sense data.
-	 * The Linux mid-layer assumes that sense
-	 * was retrieved anytime the first byte of
-	 * the sense buffer looks "sane".
-	 */
-	cmd->sense_buffer[0] = 0;
-	if (ahd_get_transaction_status(scb) == CAM_REQ_INPROG) {
-		uint32_t amount_xferred;
-
-		amount_xferred =
-		    ahd_get_transfer_length(scb) - ahd_get_residual(scb);
-		if ((scb->flags & SCB_TRANSMISSION_ERROR) != 0) {
-#ifdef AHD_DEBUG
-			if ((ahd_debug & AHD_SHOW_MISC) != 0) {
-				ahd_print_path(ahd, scb);
-				printf("Set CAM_UNCOR_PARITY\n");
-			}
-#endif
-			ahd_set_transaction_status(scb, CAM_UNCOR_PARITY);
-		} else if (amount_xferred < scb->io_ctx->underflow) {
-			printf("Saw underflow (%ld of %ld bytes). "
-			       "Treated as error\n",
-				ahd_get_residual(scb),
-				ahd_get_transfer_length(scb));
-			ahd_set_transaction_status(scb, CAM_DATA_RUN_ERR);
-		} else {
-			ahd_set_transaction_status(scb, CAM_REQ_CMP);
-		}
-	} else if (ahd_get_transaction_status(scb) == CAM_SCSI_STATUS_ERROR) {
-		ahd_linux_handle_scsi_status(ahd, dev, scb);
-	} else if (ahd_get_transaction_status(scb) == CAM_SEL_TIMEOUT) {
-		dev->flags |= AHD_DEV_UNCONFIGURED;
-		if (AHD_DV_CMD(cmd) == FALSE)
-			dev->target->flags &= ~AHD_DV_REQUIRED;
-	}
-	/*
-	 * Start DV for devices that require it assuming the first command
-	 * sent does not result in a selection timeout.
-	 */
-	if (ahd_get_transaction_status(scb) != CAM_SEL_TIMEOUT
-	 && (dev->target->flags & AHD_DV_REQUIRED) != 0)
-		ahd_linux_start_dv(ahd);
-
-	if (dev->openings == 1
-	 && ahd_get_transaction_status(scb) == CAM_REQ_CMP
-	 && ahd_get_scsi_status(scb) != SCSI_STATUS_QUEUE_FULL)
-		dev->tag_success_count++;
-	/*
-	 * Some devices deal with temporary internal resource
-	 * shortages by returning queue full.  When the queue
-	 * full occurrs, we throttle back.  Slowly try to get
-	 * back to our previous queue depth.
-	 */
-	if ((dev->openings + dev->active) < dev->maxtags
-	 && dev->tag_success_count > AHD_TAG_SUCCESS_INTERVAL) {
-		dev->tag_success_count = 0;
-		dev->openings++;
-	}
-
-	if (dev->active == 0)
-		dev->commands_since_idle_or_otag = 0;
-
-	if (TAILQ_EMPTY(&dev->busyq)) {
-		if ((dev->flags & AHD_DEV_UNCONFIGURED) != 0
-		 && dev->active == 0)
-			ahd_linux_free_device(ahd, dev);
-	} else if ((dev->flags & AHD_DEV_ON_RUN_LIST) == 0) {
-		TAILQ_INSERT_TAIL(&ahd->platform_data->device_runq, dev, links);
-		dev->flags |= AHD_DEV_ON_RUN_LIST;
-	}
-
-	if ((scb->flags & SCB_RECOVERY_SCB) != 0) {
-		printf("Recovery SCB completes\n");
-		if (ahd_get_transaction_status(scb) == CAM_BDR_SENT
-		 || ahd_get_transaction_status(scb) == CAM_REQ_ABORTED)
-			ahd_set_transaction_status(scb, CAM_CMD_TIMEOUT);
-		if ((ahd->platform_data->flags & AHD_UP_EH_SEMAPHORE) != 0) {
-			ahd->platform_data->flags &= ~AHD_UP_EH_SEMAPHORE;
-			up(&ahd->platform_data->eh_sem);
-		}
-	}
-
-	ahd_free_scb(ahd, scb);
-	ahd_linux_queue_cmd_complete(ahd, cmd);
-
-	if ((ahd->platform_data->flags & AHD_DV_WAIT_SIMQ_EMPTY) != 0
-	 && LIST_FIRST(&ahd->pending_scbs) == NULL) {
-		ahd->platform_data->flags &= ~AHD_DV_WAIT_SIMQ_EMPTY;
-		up(&ahd->platform_data->dv_sem);
-	}
-}
-
-static void
-ahd_linux_handle_scsi_status(struct ahd_softc *ahd,
-			     struct ahd_linux_device *dev, struct scb *scb)
-{
-	struct	ahd_devinfo devinfo;
-
-	ahd_compile_devinfo(&devinfo,
-			    ahd->our_id,
-			    dev->target->target, dev->lun,
-			    dev->target->channel == 0 ? 'A' : 'B',
-			    ROLE_INITIATOR);
-	
-	/*
-	 * We don't currently trust the mid-layer to
-	 * properly deal with queue full or busy.  So,
-	 * when one occurs, we tell the mid-layer to
-	 * unconditionally requeue the command to us
-	 * so that we can retry it ourselves.  We also
-	 * implement our own throttling mechanism so
-	 * we don't clobber the device with too many
-	 * commands.
-	 */
-	switch (ahd_get_scsi_status(scb)) {
-	default:
-		break;
-	case SCSI_STATUS_CHECK_COND:
-	case SCSI_STATUS_CMD_TERMINATED:
-	{
-		Scsi_Cmnd *cmd;
-
-		/*
-		 * Copy sense information to the OS's cmd
-		 * structure if it is available.
-		 */
-		cmd = scb->io_ctx;
-		if ((scb->flags & (SCB_SENSE|SCB_PKT_SENSE)) != 0) {
-			struct scsi_status_iu_header *siu;
-			u_int sense_size;
-			u_int sense_offset;
-
-			if (scb->flags & SCB_SENSE) {
-				sense_size = MIN(sizeof(struct scsi_sense_data)
-					       - ahd_get_sense_residual(scb),
-						 sizeof(cmd->sense_buffer));
-				sense_offset = 0;
-			} else {
-				/*
-				 * Copy only the sense data into the provided
-				 * buffer.
-				 */
-				siu = (struct scsi_status_iu_header *)
-				    scb->sense_data;
-				sense_size = MIN(scsi_4btoul(siu->sense_length),
-						sizeof(cmd->sense_buffer));
-				sense_offset = SIU_SENSE_OFFSET(siu);
-			}
-
-			memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
-			memcpy(cmd->sense_buffer,
-			       ahd_get_sense_buf(ahd, scb)
-			       + sense_offset, sense_size);
-			cmd->result |= (DRIVER_SENSE << 24);
-
-#ifdef AHD_DEBUG
-			if (ahd_debug & AHD_SHOW_SENSE) {
-				int i;
-
-				printf("Copied %d bytes of sense data at %d:",
-				       sense_size, sense_offset);
-				for (i = 0; i < sense_size; i++) {
-					if ((i & 0xF) == 0)
-						printf("\n");
-					printf("0x%x ", cmd->sense_buffer[i]);
-				}
-				printf("\n");
-			}
-#endif
-		}
-		break;
-	}
-	case SCSI_STATUS_QUEUE_FULL:
-	{
-		/*
-		 * By the time the core driver has returned this
-		 * command, all other commands that were queued
-		 * to us but not the device have been returned.
-		 * This ensures that dev->active is equal to
-		 * the number of commands actually queued to
-		 * the device.
-		 */
-		dev->tag_success_count = 0;
-		if (dev->active != 0) {
-			/*
-			 * Drop our opening count to the number
-			 * of commands currently outstanding.
-			 */
-			dev->openings = 0;
-#ifdef AHD_DEBUG
-			if (ahd_debug & AHD_SHOW_QFULL) {
-				ahd_print_path(ahd, scb);
-				printf("Dropping tag count to %d\n",
-				       dev->active);
-			}
-#endif
-			if (dev->active == dev->tags_on_last_queuefull) {
-
-				dev->last_queuefull_same_count++;
-				/*
-				 * If we repeatedly see a queue full
-				 * at the same queue depth, this
-				 * device has a fixed number of tag
-				 * slots.  Lock in this tag depth
-				 * so we stop seeing queue fulls from
-				 * this device.
-				 */
-				if (dev->last_queuefull_same_count
-				 == AHD_LOCK_TAGS_COUNT) {
-					dev->maxtags = dev->active;
-					ahd_print_path(ahd, scb);
-					printf("Locking max tag count at %d\n",
-					       dev->active);
-				}
-			} else {
-				dev->tags_on_last_queuefull = dev->active;
-				dev->last_queuefull_same_count = 0;
-			}
-			ahd_set_transaction_status(scb, CAM_REQUEUE_REQ);
-			ahd_set_scsi_status(scb, SCSI_STATUS_OK);
-			ahd_set_tags(ahd, &devinfo,
-				     (dev->flags & AHD_DEV_Q_BASIC)
-				   ? AHD_QUEUE_BASIC : AHD_QUEUE_TAGGED);
-			break;
-		}
-		/*
-		 * Drop down to a single opening, and treat this
-		 * as if the target returned BUSY SCSI status.
-		 */
-		dev->openings = 1;
-		ahd_set_tags(ahd, &devinfo,
-			     (dev->flags & AHD_DEV_Q_BASIC)
-			   ? AHD_QUEUE_BASIC : AHD_QUEUE_TAGGED);
-		ahd_set_scsi_status(scb, SCSI_STATUS_BUSY);
-		/* FALLTHROUGH */
-	}
-	case SCSI_STATUS_BUSY:
-		/*
-		 * Set a short timer to defer sending commands for
-		 * a bit since Linux will not delay in this case.
-		 */
-		if ((dev->flags & AHD_DEV_TIMER_ACTIVE) != 0) {
-			printf("%s:%c:%d: Device Timer still active during "
-			       "busy processing\n", ahd_name(ahd),
-				dev->target->channel, dev->target->target);
-			break;
-		}
-		dev->flags |= AHD_DEV_TIMER_ACTIVE;
-		dev->qfrozen++;
-		init_timer(&dev->timer);
-		dev->timer.data = (u_long)dev;
-		dev->timer.expires = jiffies + (HZ/2);
-		dev->timer.function = ahd_linux_dev_timed_unfreeze;
-		add_timer(&dev->timer);
-		break;
-	}
-}
-
-static void
-ahd_linux_queue_cmd_complete(struct ahd_softc *ahd, Scsi_Cmnd *cmd)
-{
-	/*
-	 * Typically, the complete queue has very few entries
-	 * queued to it before the queue is emptied by
-	 * ahd_linux_run_complete_queue, so sorting the entries
-	 * by generation number should be inexpensive.
-	 * We perform the sort so that commands that complete
-	 * with an error are retuned in the order origionally
-	 * queued to the controller so that any subsequent retries
-	 * are performed in order.  The underlying ahd routines do
-	 * not guarantee the order that aborted commands will be
-	 * returned to us.
-	 */
-	struct ahd_completeq *completeq;
-	struct ahd_cmd *list_cmd;
-	struct ahd_cmd *acmd;
-
-	/*
-	 * Map CAM error codes into Linux Error codes.  We
-	 * avoid the conversion so that the DV code has the
-	 * full error information available when making
-	 * state change decisions.
-	 */
-	if (AHD_DV_CMD(cmd) == FALSE) {
-		uint32_t status;
-		u_int new_status;
-
-		status = ahd_cmd_get_transaction_status(cmd);
-		if (status != CAM_REQ_CMP) {
-			struct ahd_linux_device *dev;
-			struct ahd_devinfo devinfo;
-			cam_status cam_status;
-			uint32_t action;
-			u_int scsi_status;
-
-			dev = ahd_linux_get_device(ahd, cmd->channel,
-						   cmd->device->id,
-						   cmd->device->lun,
-						   /*alloc*/FALSE);
-
-			if (dev == NULL)
-				goto no_fallback;
-
-			ahd_compile_devinfo(&devinfo,
-					    ahd->our_id,
-					    dev->target->target, dev->lun,
-					    dev->target->channel == 0 ? 'A':'B',
-					    ROLE_INITIATOR);
-
-			scsi_status = ahd_cmd_get_scsi_status(cmd);
-			cam_status = ahd_cmd_get_transaction_status(cmd);
-			action = aic_error_action(cmd, dev->target->inq_data,
-						  cam_status, scsi_status);
-			if ((action & SSQ_FALLBACK) != 0) {
-
-				/* Update stats */
-				dev->target->errors_detected++;
-				if (dev->target->cmds_since_error == 0)
-					dev->target->cmds_since_error++;
-				else {
-					dev->target->cmds_since_error = 0;
-					ahd_linux_fallback(ahd, &devinfo);
-				}
-			}
-		}
-no_fallback:
-		switch (status) {
-		case CAM_REQ_INPROG:
-		case CAM_REQ_CMP:
-		case CAM_SCSI_STATUS_ERROR:
-			new_status = DID_OK;
-			break;
-		case CAM_REQ_ABORTED:
-			new_status = DID_ABORT;
-			break;
-		case CAM_BUSY:
-			new_status = DID_BUS_BUSY;
-			break;
-		case CAM_REQ_INVALID:
-		case CAM_PATH_INVALID:
-			new_status = DID_BAD_TARGET;
-			break;
-		case CAM_SEL_TIMEOUT:
-			new_status = DID_NO_CONNECT;
-			break;
-		case CAM_SCSI_BUS_RESET:
-		case CAM_BDR_SENT:
-			new_status = DID_RESET;
-			break;
-		case CAM_UNCOR_PARITY:
-			new_status = DID_PARITY;
-			break;
-		case CAM_CMD_TIMEOUT:
-			new_status = DID_TIME_OUT;
-			break;
-		case CAM_UA_ABORT:
-		case CAM_REQ_CMP_ERR:
-		case CAM_AUTOSENSE_FAIL:
-		case CAM_NO_HBA:
-		case CAM_DATA_RUN_ERR:
-		case CAM_UNEXP_BUSFREE:
-		case CAM_SEQUENCE_FAIL:
-		case CAM_CCB_LEN_ERR:
-		case CAM_PROVIDE_FAIL:
-		case CAM_REQ_TERMIO:
-		case CAM_UNREC_HBA_ERROR:
-		case CAM_REQ_TOO_BIG:
-			new_status = DID_ERROR;
-			break;
-		case CAM_REQUEUE_REQ:
-			/*
-			 * If we want the request requeued, make sure there
-			 * are sufficent retries.  In the old scsi error code,
-			 * we used to be able to specify a result code that
-			 * bypassed the retry count.  Now we must use this
-			 * hack.  We also "fake" a check condition with
-			 * a sense code of ABORTED COMMAND.  This seems to
-			 * evoke a retry even if this command is being sent
-			 * via the eh thread.  Ick!  Ick!  Ick!
-			 */
-			if (cmd->retries > 0)
-				cmd->retries--;
-			new_status = DID_OK;
-			ahd_cmd_set_scsi_status(cmd, SCSI_STATUS_CHECK_COND);
-			cmd->result |= (DRIVER_SENSE << 24);
-			memset(cmd->sense_buffer, 0,
-			       sizeof(cmd->sense_buffer));
-			cmd->sense_buffer[0] = SSD_ERRCODE_VALID
-					     | SSD_CURRENT_ERROR;
-			cmd->sense_buffer[2] = SSD_KEY_ABORTED_COMMAND;
-			break;
-		default:
-			/* We should never get here */
-			new_status = DID_ERROR;
-			break;
-		}
-
-		ahd_cmd_set_transaction_status(cmd, new_status);
-	}
-
-	completeq = &ahd->platform_data->completeq;
-	list_cmd = TAILQ_FIRST(completeq);
-	acmd = (struct ahd_cmd *)cmd;
-	while (list_cmd != NULL
-	    && acmd_scsi_cmd(list_cmd).serial_number
-	     < acmd_scsi_cmd(acmd).serial_number)
-		list_cmd = TAILQ_NEXT(list_cmd, acmd_links.tqe);
-	if (list_cmd != NULL)
-		TAILQ_INSERT_BEFORE(list_cmd, acmd, acmd_links.tqe);
-	else
-		TAILQ_INSERT_TAIL(completeq, acmd, acmd_links.tqe);
-}
-
-static void
-ahd_linux_filter_inquiry(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
-{
-	struct	scsi_inquiry_data *sid;
-	struct	ahd_initiator_tinfo *tinfo;
-	struct	ahd_transinfo *user;
-	struct	ahd_transinfo *goal;
-	struct	ahd_transinfo *curr;
-	struct	ahd_tmode_tstate *tstate;
-	struct	ahd_linux_device *dev;
-	u_int	width;
-	u_int	period;
-	u_int	offset;
-	u_int	ppr_options;
-	u_int	trans_version;
-	u_int	prot_version;
-	static	int warned_user;
-
-	/*
-	 * Determine if this lun actually exists.  If so,
-	 * hold on to its corresponding device structure.
-	 * If not, make sure we release the device and
-	 * don't bother processing the rest of this inquiry
-	 * command.
-	 */
-	dev = ahd_linux_get_device(ahd, devinfo->channel - 'A',
-				   devinfo->target, devinfo->lun,
-				   /*alloc*/TRUE);
-
-	sid = (struct scsi_inquiry_data *)dev->target->inq_data;
-	if (SID_QUAL(sid) == SID_QUAL_LU_CONNECTED) {
-
-		dev->flags &= ~AHD_DEV_UNCONFIGURED;
-	} else {
-		dev->flags |= AHD_DEV_UNCONFIGURED;
-		return;
-	}
-
-	/*
-	 * Update our notion of this device's transfer
-	 * negotiation capabilities.
-	 */
-	tinfo = ahd_fetch_transinfo(ahd, devinfo->channel,
-				    devinfo->our_scsiid,
-				    devinfo->target, &tstate);
-	user = &tinfo->user;
-	goal = &tinfo->goal;
-	curr = &tinfo->curr;
-	width = user->width;
-	period = user->period;
-	offset = user->offset;
-	ppr_options = user->ppr_options;
-	trans_version = user->transport_version;
-	prot_version = MIN(user->protocol_version, SID_ANSI_REV(sid));
-
-	/*
-	 * If we have read streaming info for this controller,
-	 * apply it to this target.
-	 */
-	if (warned_user == 0
-	 && ahd->unit >= NUM_ELEMENTS(aic79xx_rd_strm_info)) {
-
-		printf("aic79xx: WARNING, insufficient rd_strm instances "
-		       "for installed controllers. Using defaults\n");
-		printf("aic79xx: Please update the aic79xx_rd_strm_info "
-		       "array in the aic79xx_osm.c source file.\n");
-		warned_user++;
-	} else {
-		uint16_t rd_strm_mask;
-
-		rd_strm_mask = aic79xx_rd_strm_info[ahd->unit];
-		if ((rd_strm_mask & devinfo->target_mask) == 0)
-			ppr_options &= ~MSG_EXT_PPR_RD_STRM;
-	}
-	
-	/*
-	 * Only attempt SPI3/4 once we've verified that
-	 * the device claims to support SPI3/4 features.
-	 */
-	if (prot_version < SCSI_REV_2)
-		trans_version = SID_ANSI_REV(sid);
-	else
-		trans_version = SCSI_REV_2;
-
-	if ((sid->flags & SID_WBus16) == 0)
-		width = MSG_EXT_WDTR_BUS_8_BIT;
-	if ((sid->flags & SID_Sync) == 0) {
-		period = 0;
-		offset = 0;
-		ppr_options = 0;
-	}
-	if ((sid->spi3data & SID_SPI_QAS) == 0)
-		ppr_options &= ~MSG_EXT_PPR_QAS_REQ;
-	if ((sid->spi3data & SID_SPI_CLOCK_DT) == 0)
-		ppr_options &= MSG_EXT_PPR_QAS_REQ;
-	if ((sid->spi3data & SID_SPI_IUS) == 0)
-		ppr_options &= (MSG_EXT_PPR_DT_REQ
-			      | MSG_EXT_PPR_QAS_REQ);
-
-	if (prot_version > SCSI_REV_2
-	 && ppr_options != 0)
-		trans_version = user->transport_version;
-
-	ahd_validate_width(ahd, /*tinfo limit*/NULL, &width, ROLE_UNKNOWN);
-	ahd_find_syncrate(ahd, &period, &ppr_options, AHD_SYNCRATE_MAX);
-	ahd_validate_offset(ahd, /*tinfo limit*/NULL, period,
-			    &offset, width, ROLE_UNKNOWN);
-	if (offset == 0 || period == 0) {
-		period = 0;
-		offset = 0;
-		ppr_options = 0;
-	}
-	/* Apply our filtered user settings. */
-	curr->transport_version = trans_version;
-	curr->protocol_version = prot_version;
-	ahd_set_width(ahd, devinfo, width, AHD_TRANS_GOAL, /*paused*/FALSE);
-	ahd_set_syncrate(ahd, devinfo, period, offset, ppr_options,
-			 AHD_TRANS_GOAL, /*paused*/FALSE);
-}
-
-void
-ahd_freeze_simq(struct ahd_softc *ahd)
-{
-	ahd->platform_data->qfrozen++;
-	if (ahd->platform_data->qfrozen == 1) {
-		scsi_block_requests(ahd->platform_data->host);
-		ahd_platform_abort_scbs(ahd, CAM_TARGET_WILDCARD, ALL_CHANNELS,
-					CAM_LUN_WILDCARD, SCB_LIST_NULL,
-					ROLE_INITIATOR, CAM_REQUEUE_REQ);
-	}
-}
-
-void
-ahd_release_simq(struct ahd_softc *ahd)
-{
-	u_long s;
-	int    unblock_reqs;
-
-	unblock_reqs = 0;
-	ahd_lock(ahd, &s);
-	if (ahd->platform_data->qfrozen > 0)
-		ahd->platform_data->qfrozen--;
-	if (ahd->platform_data->qfrozen == 0) {
-		unblock_reqs = 1;
-	}
-	if (AHD_DV_SIMQ_FROZEN(ahd)
-	 && ((ahd->platform_data->flags & AHD_DV_WAIT_SIMQ_RELEASE) != 0)) {
-		ahd->platform_data->flags &= ~AHD_DV_WAIT_SIMQ_RELEASE;
-		up(&ahd->platform_data->dv_sem);
-	}
-	ahd_unlock(ahd, &s);
-	/*
-	 * There is still a race here.  The mid-layer
-	 * should keep its own freeze count and use
-	 * a bottom half handler to run the queues
-	 * so we can unblock with our own lock held.
-	 */
-	if (unblock_reqs)
-		scsi_unblock_requests(ahd->platform_data->host);
-
-	ahd_schedule_runq(ahd);
-}
-
-static void
-ahd_linux_sem_timeout(u_long arg)
-{
-	struct	ahd_softc *ahd;
-	u_long	s;
-
-	ahd = (struct ahd_softc *)arg;
-	ahd_lock(ahd, &s);
-	if ((ahd->platform_data->flags & AHD_UP_EH_SEMAPHORE) != 0) {
-		ahd->platform_data->flags &= ~AHD_UP_EH_SEMAPHORE;
-		up(&ahd->platform_data->eh_sem);
-	}
-	ahd_unlock(ahd, &s);
-}
-
-static void
-ahd_linux_dev_timed_unfreeze(u_long arg)
-{
-	struct ahd_linux_device *dev;
-	struct ahd_softc *ahd;
-	u_long s;
-
-	dev = (struct ahd_linux_device *)arg;
-	ahd = dev->target->ahd;
-	ahd_lock(ahd, &s);
-	dev->flags &= ~AHD_DEV_TIMER_ACTIVE;
-	if (dev->qfrozen > 0)
-		dev->qfrozen--;
-	if (dev->qfrozen == 0
-	 && (dev->flags & AHD_DEV_ON_RUN_LIST) == 0)
-		ahd_linux_run_device_queue(ahd, dev);
-	ahd_unlock(ahd, &s);
-}
-
-void
-ahd_platform_dump_card_state(struct ahd_softc *ahd)
-{
-	struct ahd_linux_device *dev;
-	int target;
-	int maxtarget;
-	int lun;
-	int i;
-
-	maxtarget = (ahd->features & AHD_WIDE) ? 15 : 7;
-	for (target = 0; target <=maxtarget; target++) {
-
-		for (lun = 0; lun < AHD_NUM_LUNS; lun++) {
-			struct ahd_cmd *acmd;
-
-			dev = ahd_linux_get_device(ahd, 0, target,
-						   lun, /*alloc*/FALSE);
-			if (dev == NULL)
-				continue;
-
-			printf("DevQ(%d:%d:%d): ", 0, target, lun);
-			i = 0;
-			TAILQ_FOREACH(acmd, &dev->busyq, acmd_links.tqe) {
-				if (i++ > AHD_SCB_MAX)
-					break;
-			}
-			printf("%d waiting\n", i);
-		}
-	}
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aic79xx_osm.h linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx_osm.h
--- linux-2.4.21/drivers/scsi/aic79xx/aic79xx_osm.h	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx_osm.h	2003-06-26 21:43:10.000000000 +0000
@@ -1,1288 +0,0 @@
-/*
- * 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: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#108 $
- *
- */
-#ifndef _AIC79XX_LINUX_H_
-#define _AIC79XX_LINUX_H_
-
-#include <linux/types.h>
-#include <linux/blk.h>
-#include <linux/blkdev.h>
-#include <linux/delay.h>
-#include <linux/ioport.h>
-#include <linux/pci.h>
-#include <linux/smp_lock.h>
-#include <linux/version.h>
-#ifndef AHD_MODVERSION_FILE
-#define __NO_VERSION__
-#endif
-#include <linux/module.h>
-#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
-#include "scsi.h"
-#include "hosts.h"
-
-/* Name space conflict with BSD queue macros */
-#ifdef LIST_HEAD
-#undef LIST_HEAD
-#endif
-
-#include "cam.h"
-#include "queue.h"
-#include "scsi_message.h"
-#include "scsi_iu.h"
-#include "aiclib.h"
-
-/*********************************** Debugging ********************************/
-#ifdef CONFIG_AIC79XX_DEBUG_ENABLE
-#ifdef CONFIG_AIC79XX_DEBUG_MASK
-#define AHD_DEBUG 1
-#define AHD_DEBUG_OPTS CONFIG_AIC79XX_DEBUG_MASK
-#else
-/*
- * Compile in debugging code, but do not enable any printfs.
- */
-#define AHD_DEBUG 1
-#endif
-/* No debugging code. */
-#endif
-
-/********************************** Misc Macros *******************************/
-#define	roundup(x, y)   ((((x)+((y)-1))/(y))*(y))
-#define	powerof2(x)	((((x)-1)&(x))==0)
-
-/************************* Forward Declarations *******************************/
-struct ahd_softc;
-typedef struct pci_dev *ahd_dev_softc_t;
-typedef Scsi_Cmnd      *ahd_io_ctx_t;
-
-/******************************* Byte Order ***********************************/
-#define ahd_htobe16(x)	cpu_to_be16(x)
-#define ahd_htobe32(x)	cpu_to_be32(x)
-#define ahd_htobe64(x)	cpu_to_be64(x)
-#define ahd_htole16(x)	cpu_to_le16(x)
-#define ahd_htole32(x)	cpu_to_le32(x)
-#define ahd_htole64(x)	cpu_to_le64(x)
-
-#define ahd_be16toh(x)	be16_to_cpu(x)
-#define ahd_be32toh(x)	be32_to_cpu(x)
-#define ahd_be64toh(x)	be64_to_cpu(x)
-#define ahd_le16toh(x)	le16_to_cpu(x)
-#define ahd_le32toh(x)	le32_to_cpu(x)
-#define ahd_le64toh(x)	le64_to_cpu(x)
-
-#ifndef LITTLE_ENDIAN
-#define LITTLE_ENDIAN 1234
-#endif
-
-#ifndef BIG_ENDIAN
-#define BIG_ENDIAN 4321
-#endif
-
-#ifndef BYTE_ORDER
-#if defined(__BIG_ENDIAN)
-#define BYTE_ORDER BIG_ENDIAN
-#endif
-#if defined(__LITTLE_ENDIAN)
-#define BYTE_ORDER LITTLE_ENDIAN
-#endif
-#endif /* BYTE_ORDER */
-
-/************************* Configuration Data *********************************/
-extern int aic79xx_allow_memio;
-extern int aic79xx_detect_complete;
-extern Scsi_Host_Template aic79xx_driver_template;
-
-/***************************** 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 {
-	BUS_SPACE_MEMIO,
-	BUS_SPACE_PIO
-} bus_space_tag_t;
-
-typedef union {
-	u_long		  ioport;
-	volatile uint8_t *maddr;
-} bus_space_handle_t;
-
-typedef struct bus_dma_segment
-{
-	bus_addr_t	ds_addr;
-	bus_size_t	ds_len;
-} bus_dma_segment_t;
-
-struct ahd_linux_dma_tag
-{
-	bus_size_t	alignment;
-	bus_size_t	boundary;
-	bus_size_t	maxsize;
-};
-typedef struct ahd_linux_dma_tag* bus_dma_tag_t;
-
-struct ahd_linux_dmamap
-{
-	bus_addr_t	bus_addr;
-};
-typedef struct ahd_linux_dmamap* bus_dmamap_t;
-
-typedef int bus_dma_filter_t(void*, bus_addr_t);
-typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
-
-#define BUS_DMA_WAITOK		0x0
-#define BUS_DMA_NOWAIT		0x1
-#define BUS_DMA_ALLOCNOW	0x2
-#define BUS_DMA_LOAD_SEGS	0x4	/*
-					 * Argument is an S/G list not
-					 * a single buffer.
-					 */
-
-#define BUS_SPACE_MAXADDR	0xFFFFFFFF
-#define BUS_SPACE_MAXADDR_32BIT	0xFFFFFFFF
-#define BUS_SPACE_MAXSIZE_32BIT	0xFFFFFFFF
-
-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*/,
-			   bus_dma_filter_t*/*filter*/, void */*filterarg*/,
-			   bus_size_t /*maxsize*/, int /*nsegments*/,
-			   bus_size_t /*maxsegsz*/, int /*flags*/,
-			   bus_dma_tag_t */*dma_tagp*/);
-
-void	ahd_dma_tag_destroy(struct ahd_softc *, bus_dma_tag_t /*tag*/);
-
-int	ahd_dmamem_alloc(struct ahd_softc *, bus_dma_tag_t /*dmat*/,
-			 void** /*vaddr*/, int /*flags*/,
-			 bus_dmamap_t* /*mapp*/);
-
-void	ahd_dmamem_free(struct ahd_softc *, bus_dma_tag_t /*dmat*/,
-			void* /*vaddr*/, bus_dmamap_t /*map*/);
-
-void	ahd_dmamap_destroy(struct ahd_softc *, bus_dma_tag_t /*tag*/,
-			   bus_dmamap_t /*map*/);
-
-int	ahd_dmamap_load(struct ahd_softc *ahd, bus_dma_tag_t /*dmat*/,
-			bus_dmamap_t /*map*/, void * /*buf*/,
-			bus_size_t /*buflen*/, bus_dmamap_callback_t *,
-			void */*callback_arg*/, int /*flags*/);
-
-int	ahd_dmamap_unload(struct ahd_softc *, bus_dma_tag_t, bus_dmamap_t);
-
-/*
- * Operations performed by ahd_dmamap_sync().
- */
-#define BUS_DMASYNC_PREREAD	0x01	/* pre-read synchronization */
-#define BUS_DMASYNC_POSTREAD	0x02	/* post-read synchronization */
-#define BUS_DMASYNC_PREWRITE	0x04	/* pre-write synchronization */
-#define BUS_DMASYNC_POSTWRITE	0x08	/* post-write synchronization */
-
-/*
- * XXX
- * ahd_dmamap_sync is only used on buffers allocated with
- * the pci_alloc_consistent() API.  Although I'm not sure how
- * this works on architectures with a write buffer, Linux does
- * not have an API to sync "coherent" memory.  Perhaps we need
- * to do an mb()?
- */
-#define ahd_dmamap_sync(ahd, dma_tag, dmamap, offset, len, op)
-
-/************************** Timer DataStructures ******************************/
-typedef struct timer_list ahd_timer_t;
-
-/********************************** Includes **********************************/
-#if CONFIG_AIC79XX_REG_PRETTY_PRINT
-#define AIC_DEBUG_REGISTERS 1
-#else
-#define AIC_DEBUG_REGISTERS 0
-#endif
-#include "aic79xx.h"
-
-/***************************** Timer Facilities *******************************/
-#define ahd_timer_init init_timer
-#define ahd_timer_stop del_timer
-typedef void ahd_linux_callback_t (u_long);  
-static __inline void ahd_timer_reset(ahd_timer_t *timer, u_int usec,
-				     ahd_callback_t *func, void *arg);
-static __inline void ahd_scb_timer_reset(struct scb *scb, u_int usec);
-
-static __inline void
-ahd_timer_reset(ahd_timer_t *timer, u_int usec, ahd_callback_t *func, void *arg)
-{
-	struct ahd_softc *ahd;
-
-	ahd = (struct ahd_softc *)arg;
-	del_timer(timer);
-	timer->data = (u_long)arg;
-	timer->expires = jiffies + (usec * HZ)/1000000;
-	timer->function = (ahd_linux_callback_t*)func;
-	add_timer(timer);
-}
-
-static __inline void
-ahd_scb_timer_reset(struct scb *scb, u_int usec)
-{
-	mod_timer(&scb->io_ctx->eh_timeout, jiffies + (usec * HZ)/1000000);
-}
-
-/***************************** 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
-
-#define AIC79XX_DRIVER_VERSION "1.3.0"
-
-/**************************** Front End Queues ********************************/
-/*
- * Data structure used to cast the Linux struct scsi_cmnd to something
- * that allows us to use the queue macros.  The linux structure has
- * plenty of space to hold the links fields as required by the queue
- * macros, but the queue macors require them to have the correct type.
- */
-struct ahd_cmd_internal {
-	/* Area owned by the Linux scsi layer. */
-	uint8_t	private[offsetof(struct scsi_cmnd, SCp.Status)];
-	union {
-		STAILQ_ENTRY(ahd_cmd)	ste;
-		LIST_ENTRY(ahd_cmd)	le;
-		TAILQ_ENTRY(ahd_cmd)	tqe;
-	} links;
-	uint32_t			end;
-};
-
-struct ahd_cmd {
-	union {
-		struct ahd_cmd_internal	icmd;
-		struct scsi_cmnd	scsi_cmd;
-	} un;
-};
-
-#define acmd_icmd(cmd) ((cmd)->un.icmd)
-#define acmd_scsi_cmd(cmd) ((cmd)->un.scsi_cmd)
-#define acmd_links un.icmd.links
-
-/*************************** Device Data Structures ***************************/
-/*
- * A per probed device structure used to deal with some error recovery
- * scenarios that the Linux mid-layer code just doesn't know how to
- * handle.  The structure allocated for a device only becomes persistant
- * after a successfully completed inquiry command to the target when
- * that inquiry data indicates a lun is present.
- */
-TAILQ_HEAD(ahd_busyq, ahd_cmd);
-typedef enum {
-	AHD_DEV_UNCONFIGURED	 = 0x01,
-	AHD_DEV_FREEZE_TIL_EMPTY = 0x02, /* Freeze queue until active == 0 */
-	AHD_DEV_TIMER_ACTIVE	 = 0x04, /* Our timer is active */
-	AHD_DEV_ON_RUN_LIST	 = 0x08, /* Queued to be run later */
-	AHD_DEV_Q_BASIC		 = 0x10, /* Allow basic device queuing */
-	AHD_DEV_Q_TAGGED	 = 0x20, /* Allow full SCSI2 command queueing */
-	AHD_DEV_PERIODIC_OTAG	 = 0x40, /* Send OTAG to prevent starvation */
-	AHD_DEV_SLAVE_CONFIGURED = 0x80	 /* slave_configure() has been called */
-} ahd_linux_dev_flags;
-
-struct ahd_linux_target;
-struct ahd_linux_device {
-	TAILQ_ENTRY(ahd_linux_device) links;
-	struct			ahd_busyq busyq;
-
-	/*
-	 * The number of transactions currently
-	 * queued to the device.
-	 */
-	int			active;
-
-	/*
-	 * The currently allowed number of 
-	 * transactions that can be queued to
-	 * the device.  Must be signed for
-	 * conversion from tagged to untagged
-	 * mode where the device may have more
-	 * than one outstanding active transaction.
-	 */
-	int			openings;
-
-	/*
-	 * A positive count indicates that this
-	 * device's queue is halted.
-	 */
-	u_int			qfrozen;
-	
-	/*
-	 * Cumulative command counter.
-	 */
-	u_long			commands_issued;
-
-	/*
-	 * The number of tagged transactions when
-	 * running at our current opening level
-	 * that have been successfully received by
-	 * this device since the last QUEUE FULL.
-	 */
-	u_int			tag_success_count;
-#define AHD_TAG_SUCCESS_INTERVAL 50
-
-	ahd_linux_dev_flags	flags;
-
-	/*
-	 * Per device timer.
-	 */
-	struct timer_list	timer;
-
-	/*
-	 * The high limit for the tags variable.
-	 */
-	u_int			maxtags;
-
-	/*
-	 * The computed number of tags outstanding
-	 * at the time of the last QUEUE FULL event.
-	 */
-	u_int			tags_on_last_queuefull;
-
-	/*
-	 * How many times we have seen a queue full
-	 * with the same number of tags.  This is used
-	 * to stop our adaptive queue depth algorithm
-	 * on devices with a fixed number of tags.
-	 */
-	u_int			last_queuefull_same_count;
-#define AHD_LOCK_TAGS_COUNT 50
-
-	/*
-	 * How many transactions have been queued
-	 * without the device going idle.  We use
-	 * this statistic to determine when to issue
-	 * an ordered tag to prevent transaction
-	 * starvation.  This statistic is only updated
-	 * if the AHD_DEV_PERIODIC_OTAG flag is set
-	 * on this device.
-	 */
-	u_int			commands_since_idle_or_otag;
-#define AHD_OTAG_THRESH	500
-
-	int			lun;
-	Scsi_Device	       *scsi_device;
-	struct			ahd_linux_target *target;
-};
-
-typedef enum {
-	AHD_DV_REQUIRED		 = 0x01,
-	AHD_INQ_VALID		 = 0x02,
-	AHD_BASIC_DV		 = 0x04,
-	AHD_ENHANCED_DV		 = 0x08
-} ahd_linux_targ_flags;
-
-/* DV States */
-typedef enum {
-	AHD_DV_STATE_EXIT = 0,
-	AHD_DV_STATE_INQ_SHORT_ASYNC,
-	AHD_DV_STATE_INQ_ASYNC,
-	AHD_DV_STATE_INQ_ASYNC_VERIFY,
-	AHD_DV_STATE_TUR,
-	AHD_DV_STATE_REBD,
-	AHD_DV_STATE_INQ_VERIFY,
-	AHD_DV_STATE_WEB,
-	AHD_DV_STATE_REB,
-	AHD_DV_STATE_SU,
-	AHD_DV_STATE_BUSY
-} ahd_dv_state;
-
-struct ahd_linux_target {
-	struct ahd_linux_device	 *devices[AHD_NUM_LUNS];
-	int			  channel;
-	int			  target;
-	int			  refcount;
-	struct ahd_transinfo	  last_tinfo;
-	struct ahd_softc	 *ahd;
-	ahd_linux_targ_flags	  flags;
-	struct scsi_inquiry_data *inq_data;
-	/*
-	 * The next "fallback" period to use for narrow/wide transfers.
-	 */
-	uint8_t			  dv_next_narrow_period;
-	uint8_t			  dv_next_wide_period;
-	uint8_t			  dv_max_width;
-	uint8_t			  dv_max_ppr_options;
-	uint8_t			  dv_last_ppr_options;
-	u_int			  dv_echo_size;
-	ahd_dv_state		  dv_state;
-	u_int			  dv_state_retry;
-	uint8_t			 *dv_buffer;
-	uint8_t			 *dv_buffer1;
-
-	/*
-	 * Cumulative counter of errors.
-	 */
-	u_long			errors_detected;
-	u_long			cmds_since_error;
-};
-
-/********************* Definitions Required by the Core ***********************/
-/*
- * Number of SG segments we require.  So long as the S/G segments for
- * a particular transaction are allocated in a physically contiguous
- * manner and are allocated below 4GB, the number of S/G segments is
- * unrestricted.
- */
-#define        AHD_NSEG 128
-
-/*
- * Per-SCB OSM storage.
- */
-typedef enum {
-	AHD_UP_EH_SEMAPHORE = 0x1
-} ahd_linux_scb_flags;
-
-struct scb_platform_data {
-	struct ahd_linux_device	*dev;
-	bus_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;
-};
-
-/*
- * Define a structure used for each host adapter.  All members are
- * aligned on a boundary >= the size of the member to honor the
- * alignment restrictions of the various platforms supported by
- * this driver.
- */
-typedef enum {
-	AHD_DV_WAIT_SIMQ_EMPTY	 = 0x01,
-	AHD_DV_WAIT_SIMQ_RELEASE = 0x02,
-	AHD_DV_ACTIVE		 = 0x04,
-	AHD_DV_SHUTDOWN		 = 0x08,
-	AHD_RUN_CMPLT_Q_TIMER	 = 0x10
-} ahd_linux_softc_flags;
-
-TAILQ_HEAD(ahd_completeq, ahd_cmd);
-
-struct ahd_platform_data {
-	/*
-	 * Fields accessed from interrupt context.
-	 */
-	struct ahd_linux_target *targets[AHD_NUM_TARGETS]; 
-	TAILQ_HEAD(, ahd_linux_device) device_runq;
-	struct ahd_completeq	 completeq;
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
-	spinlock_t		 spin_lock;
-#endif
-#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;
-	struct timer_list	 reset_timer;
-	struct timer_list	 stats_timer;
-	struct semaphore	 eh_sem;
-	struct semaphore	 dv_sem;
-	struct semaphore	 dv_cmd_sem;	/* XXX This needs to be in
-						 * the target struct
-						 */
-	struct scsi_device	*dv_scsi_dev;
-	struct Scsi_Host        *host;		/* pointer to scsi host */
-#define AHD_LINUX_NOIRQ	((uint32_t)~0)
-	uint32_t		 irq;		/* IRQ for this adapter */
-	uint32_t		 bios_address;
-	uint32_t		 mem_busaddr;	/* Mem Base Addr */
-	bus_addr_t		 hw_dma_mask;
-	ahd_linux_softc_flags	 flags;
-};
-
-/************************** OS Utility Wrappers *******************************/
-#define printf printk
-#define M_NOWAIT GFP_ATOMIC
-#define M_WAITOK 0
-#define malloc(size, type, flags) kmalloc(size, flags)
-#define free(ptr, type) kfree(ptr)
-
-static __inline void ahd_delay(long);
-static __inline void
-ahd_delay(long usec)
-{
-	/*
-	 * udelay on Linux can have problems for
-	 * multi-millisecond waits.  Wait at most
-	 * 1024us per call.
-	 */
-	while (usec > 0) {
-		udelay(usec % 1024);
-		usec -= 1024;
-	}
-}
-
-
-/***************************** Low Level I/O **********************************/
-#if defined(__powerpc__) || defined(__i386__) || defined(__ia64__)
-#define MMAPIO
-#endif
-
-static __inline uint8_t ahd_inb(struct ahd_softc * ahd, long port);
-static __inline uint16_t ahd_inw_atomic(struct ahd_softc * ahd, long port);
-static __inline void ahd_outb(struct ahd_softc * ahd, long port, uint8_t val);
-static __inline void ahd_outw_atomic(struct ahd_softc * ahd,
-				     long port, uint16_t val);
-static __inline void ahd_outsb(struct ahd_softc * ahd, long port,
-			       uint8_t *, int count);
-static __inline void ahd_insb(struct ahd_softc * ahd, long port,
-			       uint8_t *, int count);
-
-static __inline uint8_t
-ahd_inb(struct ahd_softc * ahd, long port)
-{
-	uint8_t x;
-#ifdef MMAPIO
-
-	if (ahd->tags[0] == BUS_SPACE_MEMIO) {
-		x = readb(ahd->bshs[0].maddr + port);
-	} else {
-		x = inb(ahd->bshs[(port) >> 8].ioport + ((port) & 0xFF));
-	}
-#else
-	x = inb(ahd->bshs[(port) >> 8].ioport + ((port) & 0xFF));
-#endif
-	mb();
-	return (x);
-}
-
-static __inline uint16_t
-ahd_inw_atomic(struct ahd_softc * ahd, long port)
-{
-	uint8_t x;
-#ifdef MMAPIO
-
-	if (ahd->tags[0] == BUS_SPACE_MEMIO) {
-		x = readw(ahd->bshs[0].maddr + port);
-	} else {
-		x = inw(ahd->bshs[(port) >> 8].ioport + ((port) & 0xFF));
-	}
-#else
-	x = inw(ahd->bshs[(port) >> 8].ioport + ((port) & 0xFF));
-#endif
-	mb();
-	return (x);
-}
-
-static __inline void
-ahd_outb(struct ahd_softc * ahd, long port, uint8_t val)
-{
-#ifdef MMAPIO
-	if (ahd->tags[0] == BUS_SPACE_MEMIO) {
-		writeb(val, ahd->bshs[0].maddr + port);
-	} else {
-		outb(val, ahd->bshs[(port) >> 8].ioport + (port & 0xFF));
-	}
-#else
-	outb(val, ahd->bshs[(port) >> 8].ioport + (port & 0xFF));
-#endif
-	mb();
-}
-
-static __inline void
-ahd_outw_atomic(struct ahd_softc * ahd, long port, uint16_t val)
-{
-#ifdef MMAPIO
-	if (ahd->tags[0] == BUS_SPACE_MEMIO) {
-		writew(val, ahd->bshs[0].maddr + port);
-	} else {
-		outw(val, ahd->bshs[(port) >> 8].ioport + (port & 0xFF));
-	}
-#else
-	outw(val, ahd->bshs[(port) >> 8].ioport + (port & 0xFF));
-#endif
-	mb();
-}
-
-static __inline void
-ahd_outsb(struct ahd_softc * ahd, long port, uint8_t *array, int count)
-{
-	int i;
-
-	/*
-	 * There is probably a more efficient way to do this on Linux
-	 * but we don't use this for anything speed critical and this
-	 * should work.
-	 */
-	for (i = 0; i < count; i++)
-		ahd_outb(ahd, port, *array++);
-}
-
-static __inline void
-ahd_insb(struct ahd_softc * ahd, long port, uint8_t *array, int count)
-{
-	int i;
-
-	/*
-	 * There is probably a more efficient way to do this on Linux
-	 * but we don't use this for anything speed critical and this
-	 * should work.
-	 */
-	for (i = 0; i < count; i++)
-		*array++ = ahd_inb(ahd, port);
-}
-
-/**************************** Initialization **********************************/
-int		ahd_linux_register_host(struct ahd_softc *,
-					Scsi_Host_Template *);
-
-uint64_t	ahd_linux_get_memsize(void);
-
-/*************************** Pretty Printing **********************************/
-struct info_str {
-	char *buffer;
-	int length;
-	off_t offset;
-	int pos;
-};
-
-void	ahd_format_transinfo(struct info_str *info,
-			     struct ahd_transinfo *tinfo);
-
-/******************************** Locking *************************************/
-/* Lock protecting internal data structures */
-static __inline void ahd_lockinit(struct ahd_softc *);
-static __inline void ahd_lock(struct ahd_softc *, unsigned long *flags);
-static __inline void ahd_unlock(struct ahd_softc *, unsigned long *flags);
-
-/* Lock acquisition and release of the above lock in midlayer entry points. */
-static __inline void ahd_midlayer_entrypoint_lock(struct ahd_softc *,
-						  unsigned long *flags);
-static __inline void ahd_midlayer_entrypoint_unlock(struct ahd_softc *,
-						    unsigned long *flags);
-
-/* Lock held during command compeletion to the upper layer */
-static __inline void ahd_done_lockinit(struct ahd_softc *);
-static __inline void ahd_done_lock(struct ahd_softc *, unsigned long *flags);
-static __inline void ahd_done_unlock(struct ahd_softc *, unsigned long *flags);
-
-/* Lock held during ahd_list manipulation and ahd softc frees */
-extern spinlock_t ahd_list_spinlock;
-static __inline void ahd_list_lockinit(void);
-static __inline void ahd_list_lock(unsigned long *flags);
-static __inline void ahd_list_unlock(unsigned long *flags);
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
-static __inline void
-ahd_lockinit(struct ahd_softc *ahd)
-{
-	spin_lock_init(&ahd->platform_data->spin_lock);
-}
-
-static __inline void
-ahd_lock(struct ahd_softc *ahd, unsigned long *flags)
-{
-	*flags = 0;
-	spin_lock_irqsave(&ahd->platform_data->spin_lock, *flags);
-}
-
-static __inline void
-ahd_unlock(struct ahd_softc *ahd, unsigned long *flags)
-{
-	spin_unlock_irqrestore(&ahd->platform_data->spin_lock, *flags);
-}
-
-static __inline void
-ahd_midlayer_entrypoint_lock(struct ahd_softc *ahd, unsigned long *flags)
-{
-	/*
-	 * In 2.5.X, the midlayer takes our lock just before
-	 * calling us, so avoid locking again.
-	 */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	ahd_lock(ahd, flags);
-#endif
-}
-
-static __inline void
-ahd_midlayer_entrypoint_unlock(struct ahd_softc *ahd, unsigned long *flags)
-{
-	/*
-	 * In 2.5.X, the midlayer takes our lock just before
-	 * calling us and unlocks when we return, so let it do the unlock.
-	 */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	ahd_unlock(ahd, flags);
-#endif
-}
-
-static __inline void
-ahd_done_lockinit(struct ahd_softc *ahd)
-{
-	/*
-	 * In 2.5.X, our own lock is held during completions.
-	 * In previous versions, the io_request_lock is used.
-	 * In either case, we can't initialize this lock again.
-	 */
-}
-
-static __inline void
-ahd_done_lock(struct ahd_softc *ahd, unsigned long *flags)
-{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	*flags = 0;
-	spin_lock_irqsave(&io_request_lock, *flags);
-#endif
-}
-
-static __inline void
-ahd_done_unlock(struct ahd_softc *ahd, unsigned long *flags)
-{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	spin_unlock_irqrestore(&io_request_lock, *flags);
-#endif
-}
-
-static __inline void
-ahd_list_lockinit()
-{
-	spin_lock_init(&ahd_list_spinlock);
-}
-
-static __inline void
-ahd_list_lock(unsigned long *flags)
-{
-	*flags = 0;
-	spin_lock_irqsave(&ahd_list_spinlock, *flags);
-}
-
-static __inline void
-ahd_list_unlock(unsigned long *flags)
-{
-	spin_unlock_irqrestore(&ahd_list_spinlock, *flags);
-}
-
-#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0) */
-
-ahd_lockinit(struct ahd_softc *ahd)
-{
-}
-
-static __inline void
-ahd_lock(struct ahd_softc *ahd, unsigned long *flags)
-{
-	*flags = 0;
-	save_flags(*flags);
-	cli();
-}
-
-static __inline void
-ahd_unlock(struct ahd_softc *ahd, unsigned long *flags)
-{
-	restore_flags(*flags);
-}
-
-ahd_done_lockinit(struct ahd_softc *ahd)
-{
-}
-
-static __inline void
-ahd_done_lock(struct ahd_softc *ahd, unsigned long *flags)
-{
-	/*
-	 * The done lock is always held while
-	 * the ahd lock is held so blocking
-	 * interrupts again would have no effect.
-	 */
-}
-
-static __inline void
-ahd_done_unlock(struct ahd_softc *ahd, unsigned long *flags)
-{
-}
-
-static __inline void
-ahd_list_lockinit()
-{
-}
-
-static __inline void
-ahd_list_lock(unsigned long *flags)
-{
-	*flags = 0;
-	save_flags(*flags);
-	cli();
-}
-
-static __inline void
-ahd_list_unlock(unsigned long *flags)
-{
-	restore_flags(*flags);
-}
-#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0) */
-
-/******************************* PCI Definitions ******************************/
-/*
- * PCIM_xxx: mask to locate subfield in register
- * PCIR_xxx: config register offset
- * PCIC_xxx: device class
- * PCIS_xxx: device subclass
- * PCIP_xxx: device programming interface
- * PCIV_xxx: PCI vendor ID (only required to fixup ancient devices)
- * PCID_xxx: device ID
- */
-#define PCIR_DEVVENDOR		0x00
-#define PCIR_VENDOR		0x00
-#define PCIR_DEVICE		0x02
-#define PCIR_COMMAND		0x04
-#define PCIM_CMD_PORTEN		0x0001
-#define PCIM_CMD_MEMEN		0x0002
-#define PCIM_CMD_BUSMASTEREN	0x0004
-#define PCIM_CMD_MWRICEN	0x0010
-#define PCIM_CMD_PERRESPEN	0x0040
-#define	PCIM_CMD_SERRESPEN	0x0100
-#define PCIR_STATUS		0x06
-#define PCIR_REVID		0x08
-#define PCIR_PROGIF		0x09
-#define PCIR_SUBCLASS		0x0a
-#define PCIR_CLASS		0x0b
-#define PCIR_CACHELNSZ		0x0c
-#define PCIR_LATTIMER		0x0d
-#define PCIR_HEADERTYPE		0x0e
-#define PCIM_MFDEV		0x80
-#define PCIR_BIST		0x0f
-#define PCIR_CAP_PTR		0x34
-
-/* config registers for header type 0 devices */
-#define PCIR_MAPS	0x10
-#define PCIR_SUBVEND_0	0x2c
-#define PCIR_SUBDEV_0	0x2e
-
-/****************************** PCI-X definitions *****************************/
-#define PCIXR_COMMAND	0x96
-#define PCIXR_DEVADDR	0x98
-#define PCIXM_DEVADDR_FNUM	0x0003	/* Function Number */
-#define PCIXM_DEVADDR_DNUM	0x00F8	/* Device Number */
-#define PCIXM_DEVADDR_BNUM	0xFF00	/* Bus Number */
-#define PCIXR_STATUS	0x9A
-#define PCIXM_STATUS_64BIT	0x0001	/* Active 64bit connection to device. */
-#define PCIXM_STATUS_133CAP	0x0002	/* Device is 133MHz capable */
-#define PCIXM_STATUS_SCDISC	0x0004	/* Split Completion Discarded */
-#define PCIXM_STATUS_UNEXPSC	0x0008	/* Unexpected Split Completion */
-#define PCIXM_STATUS_CMPLEXDEV	0x0010	/* Device Complexity (set == bridge) */
-#define PCIXM_STATUS_MAXMRDBC	0x0060	/* Maximum Burst Read Count */
-#define PCIXM_STATUS_MAXSPLITS	0x0380	/* Maximum Split Transactions */
-#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
-{
-	AHD_POWER_STATE_D0,
-	AHD_POWER_STATE_D1,
-	AHD_POWER_STATE_D2,
-	AHD_POWER_STATE_D3
-} ahd_power_state;
-
-void ahd_power_state_change(struct ahd_softc *ahd,
-			    ahd_power_state new_state);
-
-/******************************* PCI Routines *********************************/
-/*
- * We need to use the bios32.h routines if we are kernel version 2.1.92 or less.
- */
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,1,92)
-#if defined(__sparc_v9__) || defined(__powerpc__)
-#error "PPC and Sparc platforms are only support under 2.1.92 and above"
-#endif
-#include <linux/bios32.h>
-#endif
-
-int			 ahd_linux_pci_probe(Scsi_Host_Template *);
-int			 ahd_pci_map_registers(struct ahd_softc *ahd);
-int			 ahd_pci_map_int(struct ahd_softc *ahd);
-
-static __inline uint32_t ahd_pci_read_config(ahd_dev_softc_t pci,
-					     int reg, int width);
-
-static __inline uint32_t
-ahd_pci_read_config(ahd_dev_softc_t pci, int reg, int width)
-{
-	switch (width) {
-	case 1:
-	{
-		uint8_t retval;
-
-		pci_read_config_byte(pci, reg, &retval);
-		return (retval);
-	}
-	case 2:
-	{
-		uint16_t retval;
-		pci_read_config_word(pci, reg, &retval);
-		return (retval);
-	}
-	case 4:
-	{
-		uint32_t retval;
-		pci_read_config_dword(pci, reg, &retval);
-		return (retval);
-	}
-	default:
-		panic("ahd_pci_read_config: Read size too big");
-		/* NOTREACHED */
-		return (0);
-	}
-}
-
-static __inline void ahd_pci_write_config(ahd_dev_softc_t pci,
-					  int reg, uint32_t value,
-					  int width);
-
-static __inline void
-ahd_pci_write_config(ahd_dev_softc_t pci, int reg, uint32_t value, int width)
-{
-	switch (width) {
-	case 1:
-		pci_write_config_byte(pci, reg, value);
-		break;
-	case 2:
-		pci_write_config_word(pci, reg, value);
-		break;
-	case 4:
-		pci_write_config_dword(pci, reg, value);
-		break;
-	default:
-		panic("ahd_pci_write_config: Write size too big");
-		/* NOTREACHED */
-	}
-}
-
-static __inline int ahd_get_pci_function(ahd_dev_softc_t);
-static __inline int
-ahd_get_pci_function(ahd_dev_softc_t pci)
-{
-	return (PCI_FUNC(pci->devfn));
-}
-
-static __inline int ahd_get_pci_slot(ahd_dev_softc_t);
-static __inline int
-ahd_get_pci_slot(ahd_dev_softc_t pci)
-{
-	return (PCI_SLOT(pci->devfn));
-}
-
-static __inline int ahd_get_pci_bus(ahd_dev_softc_t);
-static __inline int
-ahd_get_pci_bus(ahd_dev_softc_t pci)
-{
-	return (pci->bus->number);
-}
-
-static __inline void ahd_flush_device_writes(struct ahd_softc *);
-static __inline void
-ahd_flush_device_writes(struct ahd_softc *ahd)
-{
-	/* XXX Is this sufficient for all architectures??? */
-	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 *********************************/
-int	ahd_linux_proc_info(char *, char **, off_t, int, int, int);
-
-/*************************** Domain Validation ********************************/
-#define AHD_DV_CMD(cmd) ((cmd)->scsi_done == ahd_linux_dv_complete)
-#define AHD_DV_SIMQ_FROZEN(ahd)					\
-	((((ahd)->platform_data->flags & AHD_DV_ACTIVE) != 0)	\
-	 && (ahd)->platform_data->qfrozen == 1)
-
-/*********************** Transaction Access Wrappers **************************/
-static __inline void ahd_cmd_set_transaction_status(Scsi_Cmnd *, uint32_t);
-static __inline void ahd_set_transaction_status(struct scb *, uint32_t);
-static __inline void ahd_cmd_set_scsi_status(Scsi_Cmnd *, uint32_t);
-static __inline void ahd_set_scsi_status(struct scb *, uint32_t);
-static __inline uint32_t ahd_cmd_get_transaction_status(Scsi_Cmnd *cmd);
-static __inline uint32_t ahd_get_transaction_status(struct scb *);
-static __inline uint32_t ahd_cmd_get_scsi_status(Scsi_Cmnd *cmd);
-static __inline uint32_t ahd_get_scsi_status(struct scb *);
-static __inline void ahd_set_transaction_tag(struct scb *, int, u_int);
-static __inline u_long ahd_get_transfer_length(struct scb *);
-static __inline int ahd_get_transfer_dir(struct scb *);
-static __inline void ahd_set_residual(struct scb *, u_long);
-static __inline void ahd_set_sense_residual(struct scb *scb, u_long resid);
-static __inline u_long ahd_get_residual(struct scb *);
-static __inline u_long ahd_get_sense_residual(struct scb *);
-static __inline int ahd_perform_autosense(struct scb *);
-static __inline uint32_t ahd_get_sense_bufsize(struct ahd_softc *,
-					       struct scb *);
-static __inline void ahd_notify_xfer_settings_change(struct ahd_softc *,
-						     struct ahd_devinfo *);
-static __inline void ahd_platform_scb_free(struct ahd_softc *ahd,
-					   struct scb *scb);
-static __inline void ahd_freeze_scb(struct scb *scb);
-
-static __inline
-void ahd_cmd_set_transaction_status(Scsi_Cmnd *cmd, uint32_t status)
-{
-	cmd->result &= ~(CAM_STATUS_MASK << 16);
-	cmd->result |= status << 16;
-}
-
-static __inline
-void ahd_set_transaction_status(struct scb *scb, uint32_t status)
-{
-	ahd_cmd_set_transaction_status(scb->io_ctx,status);
-}
-
-static __inline
-void ahd_cmd_set_scsi_status(Scsi_Cmnd *cmd, uint32_t status)
-{
-	cmd->result &= ~0xFFFF;
-	cmd->result |= status;
-}
-
-static __inline
-void ahd_set_scsi_status(struct scb *scb, uint32_t status)
-{
-	ahd_cmd_set_scsi_status(scb->io_ctx, status);
-}
-
-static __inline
-uint32_t ahd_cmd_get_transaction_status(Scsi_Cmnd *cmd)
-{
-	return ((cmd->result >> 16) & CAM_STATUS_MASK);
-}
-
-static __inline
-uint32_t ahd_get_transaction_status(struct scb *scb)
-{
-	return (ahd_cmd_get_transaction_status(scb->io_ctx));
-}
-
-static __inline
-uint32_t ahd_cmd_get_scsi_status(Scsi_Cmnd *cmd)
-{
-	return (cmd->result & 0xFFFF);
-}
-
-static __inline
-uint32_t ahd_get_scsi_status(struct scb *scb)
-{
-	return (ahd_cmd_get_scsi_status(scb->io_ctx));
-}
-
-static __inline
-void ahd_set_transaction_tag(struct scb *scb, int enabled, u_int type)
-{
-	/*
-	 * Nothing to do for linux as the incoming transaction
-	 * has no concept of tag/non tagged, etc.
-	 */
-}
-
-static __inline
-u_long ahd_get_transfer_length(struct scb *scb)
-{
-	return (scb->platform_data->xfer_len);
-}
-
-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
-void ahd_set_sense_residual(struct scb *scb, u_long resid)
-{
-	scb->platform_data->sense_resid = resid;
-}
-
-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
-u_long ahd_get_sense_residual(struct scb *scb)
-{
-	return (scb->platform_data->sense_resid);
-}
-
-static __inline
-int ahd_perform_autosense(struct scb *scb)
-{
-	/*
-	 * We always perform autosense in Linux.
-	 * On other platforms this is set on a
-	 * per-transaction basis.
-	 */
-	return (1);
-}
-
-static __inline uint32_t
-ahd_get_sense_bufsize(struct ahd_softc *ahd, struct scb *scb)
-{
-	return (sizeof(struct scsi_sense_data));
-}
-
-static __inline void
-ahd_notify_xfer_settings_change(struct ahd_softc *ahd,
-				struct ahd_devinfo *devinfo)
-{
-	/* Nothing to do here for linux */
-}
-
-static __inline void
-ahd_platform_scb_free(struct ahd_softc *ahd, struct scb *scb)
-{
-	ahd->flags &= ~AHD_RESOURCE_SHORTAGE;
-}
-
-int	ahd_platform_alloc(struct ahd_softc *ahd, void *platform_arg);
-void	ahd_platform_free(struct ahd_softc *ahd);
-void	ahd_platform_init(struct ahd_softc *ahd);
-void	ahd_platform_freeze_devq(struct ahd_softc *ahd, struct scb *scb);
-void	ahd_freeze_simq(struct ahd_softc *ahd);
-void	ahd_release_simq(struct ahd_softc *ahd);
-
-static __inline void
-ahd_freeze_scb(struct scb *scb)
-{
-	if ((scb->io_ctx->result & (CAM_DEV_QFRZN << 16)) == 0) {
-                scb->io_ctx->result |= CAM_DEV_QFRZN << 16;
-                scb->platform_data->dev->qfrozen++;
-        }
-}
-
-void	ahd_platform_set_tags(struct ahd_softc *ahd,
-			      struct ahd_devinfo *devinfo, ahd_queue_alg);
-int	ahd_platform_abort_scbs(struct ahd_softc *ahd, int target,
-				char channel, int lun, u_int tag,
-				role_t role, uint32_t status);
-void	ahd_linux_isr(int irq, void *dev_id, struct pt_regs * regs);
-void	ahd_platform_flushwork(struct ahd_softc *ahd);
-int	ahd_softc_comp(struct ahd_softc *, struct ahd_softc *);
-void	ahd_done(struct ahd_softc*, struct scb*);
-void	ahd_send_async(struct ahd_softc *, char channel,
-		       u_int target, u_int lun, ac_code, void *);
-void	ahd_print_path(struct ahd_softc *, struct scb *);
-void	ahd_platform_dump_card_state(struct ahd_softc *ahd);
-
-#ifdef CONFIG_PCI
-#define AHD_PCI_CONFIG 1
-#else
-#define AHD_PCI_CONFIG 0
-#endif
-#define bootverbose aic79xx_verbose
-extern int aic79xx_verbose;
-#endif /* _AIC79XX_LINUX_H_ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aic79xx_osm_pci.c linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx_osm_pci.c
--- linux-2.4.21/drivers/scsi/aic79xx/aic79xx_osm_pci.c	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx_osm_pci.c	2003-06-26 21:43:32.000000000 +0000
@@ -1,432 +0,0 @@
-/*
- * Linux driver attachment glue for PCI based U320 controllers.
- *
- * 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: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#20 $
- */
-
-#include "aic79xx_osm.h"
-#include "aic79xx_inline.h"
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
-struct pci_device_id
-{
-};
-#endif
-
-static int	ahd_linux_pci_dev_probe(struct pci_dev *pdev,
-					const struct pci_device_id *ent);
-static int	ahd_linux_pci_reserve_io_regions(struct ahd_softc *ahd,
-						 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)
-static void	ahd_linux_pci_dev_remove(struct pci_dev *pdev);
-
-/* We do our own ID filtering.  So, grab all SCSI storage class devices. */
-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
-	},
-	{ 0 }
-};
-
-MODULE_DEVICE_TABLE(pci, ahd_linux_pci_id_table);
-
-struct pci_driver aic79xx_pci_driver = {
-	name:		"aic79xx",
-	probe:		ahd_linux_pci_dev_probe,
-	remove:		ahd_linux_pci_dev_remove,
-	id_table:	ahd_linux_pci_id_table
-};
-
-static void
-ahd_linux_pci_dev_remove(struct pci_dev *pdev)
-{
-	struct ahd_softc *ahd;
-	u_long l;
-
-	/*
-	 * We should be able to just perform
-	 * the free directly, but check our
-	 * list for extra sanity.
-	 */
-	ahd_list_lock(&l);
-	ahd = ahd_find_softc((struct ahd_softc *)pci_get_drvdata(pdev));
-	if (ahd != NULL) {
-		u_long s;
-
-		ahd_lock(ahd, &s);
-		ahd_intr_enable(ahd, FALSE);
-		ahd_unlock(ahd, &s);
-		ahd_free(ahd);
-	}
-	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)
-{
-	char		 buf[80];
-	struct		 ahd_softc *ahd;
-	ahd_dev_softc_t	 pci;
-	struct		 ahd_pci_identity *entry;
-	char		*name;
-	int		 error;
-
-	/*
-	 * Some BIOSen report the same device multiple times.
-	 */
-	TAILQ_FOREACH(ahd, &ahd_tailq, links) {
-		struct pci_dev *probed_pdev;
-
-		probed_pdev = ahd->dev_softc;
-		if (probed_pdev->bus->number == pdev->bus->number
-		 && probed_pdev->devfn == pdev->devfn)
-			break;
-	}
-	if (ahd != NULL) {
-		/* Skip duplicate. */
-		return (-ENODEV);
-	}
-
-	pci = pdev;
-	entry = ahd_find_pci_device(pci);
-	if (entry == NULL)
-		return (-ENODEV);
-
-	/*
-	 * Allocate a softc for this card and
-	 * set it up for attachment by our
-	 * common detect routine.
-	 */
-	sprintf(buf, "ahd_pci:%d:%d:%d",
-		ahd_get_pci_bus(pci),
-		ahd_get_pci_slot(pci),
-		ahd_get_pci_function(pci));
-	name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT);
-	if (name == NULL)
-		return (-ENOMEM);
-	strcpy(name, buf);
-	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) {
-		uint64_t memsize;
-
-		memsize = ahd_linux_get_memsize();
-		if (memsize >= 0x8000000000
-	 	 && ahd_pci_set_dma_mask(pdev, 0xFFFFFFFFFFFFFFFFULL) == 0) {
-			ahd->flags |= AHD_64BIT_ADDRESSING;
-			ahd->platform_data->hw_dma_mask =
-			    (bus_addr_t)(0xFFFFFFFFFFFFFFFFULL&(bus_addr_t)~0);
-		} else if (memsize > 0x80000000
-			&& ahd_pci_set_dma_mask(pdev, 0x7FFFFFFFFFULL) == 0) {
-			ahd->flags |= AHD_39BIT_ADDRESSING;
-			ahd->platform_data->hw_dma_mask =
-			    (bus_addr_t)(0x7FFFFFFFFFULL & (bus_addr_t)~0);
-		}
-	} else {
-		ahd_pci_set_dma_mask(pdev, 0xFFFFFFFF);
-		ahd->platform_data->hw_dma_mask = 0xFFFFFFFF;
-	}
-#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)
-		ahd_linux_register_host(ahd, &aic79xx_driver_template);
-#endif
-	return (0);
-}
-
-int
-ahd_linux_pci_probe(Scsi_Host_Template *template)
-{
-#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
-}
-
-static int
-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,
-	 * but the Linux PCI code doesn't know how to "count" 64bit
-	 * 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)
-{
-	u_long	start;
-	u_long	base_page;
-	u_long	base_offset;
-	int	error;
-
-	if (aic79xx_allow_memio == 0)
-		return (ENOMEM);
-
-	if ((ahd->bugs & AHD_PCIX_MMAPIO_BUG) != 0)
-		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;
-		}
-	} else
-		error = ENOMEM;
-	return (error);
-}
-
-int
-ahd_pci_map_registers(struct ahd_softc *ahd)
-{
-	uint32_t command;
-	u_long	 base;
-	uint8_t	*maddr;
-	int	 error;
-
-	/*
-	 * If its allowed, we prefer memory mapped access.
-	 */
-	command = ahd_pci_read_config(ahd->dev_softc, PCIR_COMMAND, 4);
-	command &= ~(PCIM_CMD_PORTEN|PCIM_CMD_MEMEN);
-	base = 0;
-	maddr = NULL;
-#ifdef MMAPIO
-	error = ahd_linux_pci_reserve_mem_region(ahd, &base, &maddr);
-	if (error == 0) {
-		ahd->platform_data->mem_busaddr = base;
-		ahd->tags[0] = BUS_SPACE_MEMIO;
-		ahd->bshs[0].maddr = maddr;
-		ahd->tags[1] = BUS_SPACE_MEMIO;
-		ahd->bshs[1].maddr = maddr + 0x100;
-		ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND,
-				     command | PCIM_CMD_MEMEN, 4);
-
-		if (ahd_pci_test_register_access(ahd) != 0) {
-
-			printf("aic79xx: PCI Device %d:%d:%d "
-			       "failed memory mapped test.  Using PIO.\n",
-			       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)
-			release_mem_region(ahd->platform_data->mem_busaddr,
-					   0x1000);
-#endif
-			ahd->bshs[0].maddr = NULL;
-			maddr = NULL;
-		} else
-			command |= PCIM_CMD_MEMEN;
-	} else if (bootverbose) {
-		printf("aic79xx: PCI%d:%d:%d MEM region 0x%lx "
-		       "unavailable. Cannot memory map device.\n",
-		       ahd_get_pci_bus(ahd->dev_softc),
-		       ahd_get_pci_slot(ahd->dev_softc),
-		       ahd_get_pci_function(ahd->dev_softc),
-		       base);
-	}
-#endif
-
-	if (maddr == NULL) {
-		u_long	 base2;
-
-		error = ahd_linux_pci_reserve_io_regions(ahd, &base, &base2);
-		if (error == 0) {
-			ahd->tags[0] = BUS_SPACE_PIO;
-			ahd->tags[1] = BUS_SPACE_PIO;
-			ahd->bshs[0].ioport = base;
-			ahd->bshs[1].ioport = base2;
-			command |= PCIM_CMD_PORTEN;
-		} else {
-			printf("aic79xx: PCI%d:%d:%d IO regions 0x%lx and 0x%lx"
-			       "unavailable. Cannot map device.\n",
-			       ahd_get_pci_bus(ahd->dev_softc),
-			       ahd_get_pci_slot(ahd->dev_softc),
-			       ahd_get_pci_function(ahd->dev_softc),
-			       base, base2);
-		}
-	}
-	ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND, command, 4);
-	return (error);
-}
-
-int
-ahd_pci_map_int(struct ahd_softc *ahd)
-{
-	int error;
-
-	error = request_irq(ahd->dev_softc->irq, ahd_linux_isr,
-			    SA_SHIRQ, "aic79xx", ahd);
-	if (error == 0)
-		ahd->platform_data->irq = ahd->dev_softc->irq;
-	
-	return (-error);
-}
-
-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 -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aic79xx_pci.c linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx_pci.c
--- linux-2.4.21/drivers/scsi/aic79xx/aic79xx_pci.c	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx_pci.c	2003-06-26 21:43:22.000000000 +0000
@@ -1,923 +0,0 @@
-/*
- * Product specific probe and attach routines for:
- *	aic7901 and aic7902 SCSI controllers
- *
- * Copyright (c) 1994-2001 Justin T. Gibbs.
- * Copyright (c) 2000-2002 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: //depot/aic7xxx/aic7xxx/aic79xx_pci.c#61 $
- *
- * $FreeBSD$
- */
-
-#ifdef __linux__
-#include "aic79xx_osm.h"
-#include "aic79xx_inline.h"
-#else
-#include <dev/aic7xxx/aic79xx_osm.h>
-#include <dev/aic7xxx/aic79xx_inline.h>
-#endif
-
-static __inline uint64_t
-ahd_compose_id(u_int device, u_int vendor, u_int subdevice, u_int subvendor)
-{
-	uint64_t id;
-
-	id = subvendor
-	   | (subdevice << 16)
-	   | ((uint64_t)vendor << 32)
-	   | ((uint64_t)device << 48);
-
-	return (id);
-}
-
-#define ID_ALL_MASK			0xFFFFFFFFFFFFFFFFull
-#define ID_DEV_VENDOR_MASK		0xFFFFFFFF00000000ull
-#define ID_9005_GENERIC_MASK		0xFFF0FFFF00000000ull
-
-#define ID_AIC7901			0x800F9005FFFF9005ull
-#define ID_AIC7901A			0x801E9005FFFF9005ull
-#define ID_AIC7901A_IROC		0x809E9005FFFF9005ull
-#define ID_AHA_29320A			0x8000900500609005ull
-#define ID_AHA_29320LP			0x8014900500449005ull
-#define ID_AHA_29320LP_IROC		0x8094900500449005ull
-
-#define ID_AIC7902			0x801F9005FFFF9005ull
-#define ID_AIC7902_IROC			0x809F9005FFFF9005ull
-#define ID_AIC7902_B			0x801D9005FFFF9005ull
-#define ID_AIC7902_B_IROC		0x809D9005FFFF9005ull
-#define ID_AHA_39320			0x8010900500409005ull
-#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_AHA_29320			0x8012900500429005ull
-#define ID_AHA_29320B			0x8013900500439005ull
-#define ID_AIC7902_PCI_REV_A4		0x3
-#define ID_AIC7902_PCI_REV_B0		0x10
-#define SUBID_HP			0x0E11
-
-#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 */
-#define		DEVID_9005_TYPE_IROC		0x8	/* Raid(0,1,10) Card */
-#define		DEVID_9005_TYPE_MB		0xF	/* On Motherboard */
-
-#define DEVID_9005_MFUNC(id) ((id) & 0x10)
-
-#define DEVID_9005_PACKETIZED(id) ((id) & 0x8000)
-
-#define SUBID_9005_TYPE(id) ((id) & 0xF)
-#define		SUBID_9005_TYPE_HBA		0x0	/* Standard Card */
-#define		SUBID_9005_TYPE_MB		0xF	/* On Motherboard */
-
-#define SUBID_9005_AUTOTERM(id)	(((id) & 0x10) == 0)
-
-#define SUBID_9005_LEGACYCONN_FUNC(id) ((id) & 0x20)
-
-#define SUBID_9005_SEEPTYPE(id) ((id) & 0x0C0) >> 6)
-#define		SUBID_9005_SEEPTYPE_NONE	0x0
-#define		SUBID_9005_SEEPTYPE_4K		0x1
-
-static ahd_device_setup_t ahd_aic7901A_setup;
-static ahd_device_setup_t ahd_aic7902_setup;
-
-struct ahd_pci_identity ahd_pci_ident_table [] =
-{
-	/* aic7901A based controllers */
-	{
-		ID_AHA_29320LP,
-		ID_ALL_MASK,
-		"Adaptec 29320LP Ultra320 SCSI adapter",
-		ahd_aic7901A_setup
-	},
-	{
-		ID_AHA_29320A,
-		ID_ALL_MASK,
-		"Adaptec 29320A Ultra320 SCSI adapter",
-		ahd_aic7901A_setup
-	},
-	/* aic7902 based controllers */	
-	{
-		ID_AHA_39320,
-		ID_ALL_MASK,
-		"Adaptec 39320 Ultra320 SCSI adapter",
-		ahd_aic7902_setup
-	},
-	{
-		ID_AHA_39320D,
-		ID_ALL_MASK,
-		"Adaptec 39320D Ultra320 SCSI adapter",
-		ahd_aic7902_setup
-	},
-	{
-		ID_AHA_39320D_HP,
-		ID_ALL_MASK,
-		"Adaptec (HP OEM) 39320D Ultra320 SCSI adapter",
-		ahd_aic7902_setup
-	},
-	{
-		ID_AHA_39320D_B,
-		ID_ALL_MASK,
-		"Adaptec 39320D Ultra320 SCSI adapter",
-		ahd_aic7902_setup
-	},
-	{
-		ID_AHA_39320D_B_HP,
-		ID_ALL_MASK,
-		"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_AIC7901A & ID_DEV_VENDOR_MASK,
-		ID_DEV_VENDOR_MASK,
-		"Adaptec AIC7901A Ultra320 SCSI adapter",
-		ahd_aic7901A_setup
-	},
-	{
-		ID_AIC7902 & ID_9005_GENERIC_MASK,
-		ID_9005_GENERIC_MASK,
-		"Adaptec AIC7902 Ultra320 SCSI adapter",
-		ahd_aic7902_setup
-	}
-};
-
-const u_int ahd_num_pci_devs = NUM_ELEMENTS(ahd_pci_ident_table);
-		
-#define	DEVCONFIG		0x40
-#define		PCIXINITPAT	0x0000E000ul
-#define			PCIXINIT_PCI33_66	0x0000E000ul
-#define			PCIXINIT_PCIX50_66	0x0000C000ul
-#define			PCIXINIT_PCIX66_100	0x0000A000ul
-#define			PCIXINIT_PCIX100_133	0x00008000ul
-#define	PCI_BUS_MODES_INDEX(devconfig)	\
-	(((devconfig) & PCIXINITPAT) >> 13)
-static const char *pci_bus_modes[] =
-{
-	"PCI bus mode unknown",
-	"PCI bus mode unknown",
-	"PCI bus mode unknown",
-	"PCI bus mode unknown",
-	"PCI-X 101-133Mhz",
-	"PCI-X 67-100Mhz",
-	"PCI-X 50-66Mhz",
-	"PCI 33 or 66Mhz"
-};
-
-#define		TESTMODE	0x00000800ul
-#define		IRDY_RST	0x00000200ul
-#define		FRAME_RST	0x00000100ul
-#define		PCI64BIT	0x00000080ul
-#define		MRDCEN		0x00000040ul
-#define		ENDIANSEL	0x00000020ul
-#define		MIXQWENDIANEN	0x00000008ul
-#define		DACEN		0x00000004ul
-#define		STPWLEVEL	0x00000002ul
-#define		QWENDIANSEL	0x00000001ul
-
-#define	DEVCONFIG1		0x44
-#define		PREQDIS		0x01
-
-#define	CSIZE_LATTIME		0x0c
-#define		CACHESIZE	0x000000fful
-#define		LATTIME		0x0000ff00ul
-
-static int	ahd_check_extport(struct ahd_softc *ahd);
-static void	ahd_configure_termination(struct ahd_softc *ahd,
-					  u_int adapter_control);
-static void	ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat);
-
-struct ahd_pci_identity *
-ahd_find_pci_device(ahd_dev_softc_t pci)
-{
-	uint64_t  full_id;
-	uint16_t  device;
-	uint16_t  vendor;
-	uint16_t  subdevice;
-	uint16_t  subvendor;
-	struct	  ahd_pci_identity *entry;
-	u_int	  i;
-
-	vendor = ahd_pci_read_config(pci, PCIR_DEVVENDOR, /*bytes*/2);
-	device = ahd_pci_read_config(pci, PCIR_DEVICE, /*bytes*/2);
-	subvendor = ahd_pci_read_config(pci, PCIR_SUBVEND_0, /*bytes*/2);
-	subdevice = ahd_pci_read_config(pci, PCIR_SUBDEV_0, /*bytes*/2);
-	full_id = ahd_compose_id(device,
-				 vendor,
-				 subdevice,
-				 subvendor);
-
-	for (i = 0; i < ahd_num_pci_devs; i++) {
-		entry = &ahd_pci_ident_table[i];
-		if (entry->full_id == (full_id & entry->id_mask)) {
-			/* Honor exclusion entries. */
-			if (entry->name == NULL)
-				return (NULL);
-			return (entry);
-		}
-	}
-	return (NULL);
-}
-
-int
-ahd_pci_config(struct ahd_softc *ahd, struct ahd_pci_identity *entry)
-{
-	struct scb_data *shared_scb_data;
-	u_long		 l;
-	u_int		 command;
-	uint32_t	 devconfig;
-	uint16_t	 subvendor; 
-	int		 error;
-
-	shared_scb_data = NULL;
-	ahd->description = entry->name;
-	/*
-	 * Record if this is an HP board.
-	 */
-	subvendor = ahd_pci_read_config(ahd->dev_softc,
-					PCIR_SUBVEND_0, /*bytes*/2);
-	if (subvendor == SUBID_HP)
-		ahd->flags |= AHD_HP_BOARD;
-
-	error = entry->setup(ahd);
-	if (error != 0)
-		return (error);
-	
-	devconfig = ahd_pci_read_config(ahd->dev_softc, DEVCONFIG, /*bytes*/4);
-	if ((devconfig & PCIXINITPAT) == PCIXINIT_PCI33_66) {
-		ahd->chip |= AHD_PCI;
-		/* Disable PCIX workarounds when running in PCI mode. */
-		ahd->bugs &= ~AHD_PCIX_BUG_MASK;
-	} else {
-		ahd->chip |= AHD_PCIX;
-	}
-	ahd->bus_description = pci_bus_modes[PCI_BUS_MODES_INDEX(devconfig)];
-
-	ahd_power_state_change(ahd, AHD_POWER_STATE_D0);
-
-	error = ahd_pci_map_registers(ahd);
-	if (error != 0)
-		return (error);
-
-	/*
-	 * If we need to support high memory, enable dual
-	 * address cycles.  This bit must be set to enable
-	 * high address bit generation even if we are on a
-	 * 64bit bus (PCI64BIT set in devconfig).
-	 */
-	if ((ahd->flags & (AHD_39BIT_ADDRESSING|AHD_64BIT_ADDRESSING)) != 0) {
-		uint32_t devconfig;
-
-		if (bootverbose)
-			printf("%s: Enabling 39Bit Addressing\n",
-			       ahd_name(ahd));
-		devconfig = ahd_pci_read_config(ahd->dev_softc,
-						DEVCONFIG, /*bytes*/4);
-		devconfig |= DACEN;
-		ahd_pci_write_config(ahd->dev_softc, DEVCONFIG,
-				     devconfig, /*bytes*/4);
-	}
-	
-	/* Ensure busmastering is enabled */
-	command = ahd_pci_read_config(ahd->dev_softc, PCIR_COMMAND, /*bytes*/1);
-	command |= PCIM_CMD_BUSMASTEREN;
-	ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND, command, /*bytes*/1);
-
-	error = ahd_softc_init(ahd);
-	if (error != 0)
-		return (error);
-
-	ahd->bus_intr = ahd_pci_intr;
-
-	error = ahd_reset(ahd);
-	if (error != 0)
-		return (ENXIO);
-
-	ahd->pci_cachesize =
-	    ahd_pci_read_config(ahd->dev_softc, CSIZE_LATTIME,
-				/*bytes*/1) & CACHESIZE;
-	ahd->pci_cachesize *= 4;
-
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-	/* See if we have a SEEPROM and perform auto-term */
-	error = ahd_check_extport(ahd);
-	if (error != 0)
-		return (error);
-
-	/* Core initialization */
-	error = ahd_init(ahd);
-	if (error != 0)
-		return (error);
-
-	/*
-	 * Allow interrupts now that we are completely setup.
-	 */
-	error = ahd_pci_map_int(ahd);
-	if (error != 0)
-		return (error);
-
-	ahd_list_lock(&l);
-	/*
-	 * Link this softc in with all other ahd instances.
-	 */
-	ahd_softc_insert(ahd);
-	ahd_list_unlock(&l);
-	return (0);
-}
-
-/*
- * Perform some simple tests that should catch situations where
- * our registers are invalidly mapped.
- */
-int
-ahd_pci_test_register_access(struct ahd_softc *ahd)
-{
-	ahd_mode_state	saved_modes;
-	uint32_t	cmd;
-	int		error;
-	uint8_t		hcntrl;
-
-	saved_modes = ahd_save_modes(ahd);
-	error = EIO;
-
-	/*
-	 * Enable PCI error interrupt status, but suppress NMIs
-	 * generated by SERR raised due to target aborts.
-	 */
-	cmd = ahd_pci_read_config(ahd->dev_softc, PCIR_COMMAND, /*bytes*/2);
-	ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND,
-			     cmd & ~PCIM_CMD_SERRESPEN, /*bytes*/2);
-
-	/*
-	 * First a simple test to see if any
-	 * registers can be read.  Reading
-	 * HCNTRL has no side effects and has
-	 * at least one bit that is guaranteed to
-	 * be zero so it is a good register to
-	 * use for this test.
-	 */
-	hcntrl = ahd_inb(ahd, HCNTRL);
-	if (hcntrl == 0xFF)
-		goto fail;
-
-	/*
-	 * Next create a situation where write combining
-	 * or read prefetching could be initiated by the
-	 * CPU or host bridge.  Our device does not support
-	 * either, so look for data corruption and/or flaged
-	 * PCI errors.
-	 */
-	ahd_outb(ahd, HCNTRL, hcntrl|PAUSE);
-	while (ahd_is_paused(ahd) == 0)
-		;
-	ahd_outb(ahd, SEQCTL0, PERRORDIS);
-	ahd_outl(ahd, SRAM_BASE, 0x5aa555aa);
-	if (ahd_inl(ahd, SRAM_BASE) != 0x5aa555aa)
-		goto fail;
-
-	if ((ahd_inb(ahd, INTSTAT) & PCIINT) != 0) {
-		u_int targpcistat;
-
-		ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
-		targpcistat = ahd_inb(ahd, TARGPCISTAT);
-		if ((targpcistat & STA) != 0)
-			goto fail;
-	}
-
-	error = 0;
-
-fail:
-	if ((ahd_inb(ahd, INTSTAT) & PCIINT) != 0) {
-		u_int targpcistat;
-		u_int pci_status1;
-
-		ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
-		targpcistat = ahd_inb(ahd, TARGPCISTAT);
-
-		/* Silently clear any latched errors. */
-		ahd_outb(ahd, TARGPCISTAT, targpcistat);
-		pci_status1 = ahd_pci_read_config(ahd->dev_softc,
-						  PCIR_STATUS + 1, /*bytes*/1);
-		ahd_pci_write_config(ahd->dev_softc, PCIR_STATUS + 1,
-				     pci_status1, /*bytes*/1);
-		ahd_outb(ahd, CLRINT, CLRPCIINT);
-	}
-
-	ahd_restore_modes(ahd, saved_modes);
-	ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS);
-	ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND, cmd, /*bytes*/2);
-	return (error);
-}
-
-/*
- * Check the external port logic for a serial eeprom
- * and termination/cable detection contrls.
- */
-static int
-ahd_check_extport(struct ahd_softc *ahd)
-{
-	struct	seeprom_config *sc;
-	u_int	adapter_control;
-	int	have_seeprom;
-	int	error;
-
-	sc = ahd->seep_config;
-	have_seeprom = ahd_acquire_seeprom(ahd);
-	if (have_seeprom) {
-		u_int start_addr;
-
-		if (bootverbose) 
-			printf("%s: Reading SEEPROM...", ahd_name(ahd));
-
-		/* Address is always in units of 16bit words */
-		start_addr = (sizeof(*sc) / 2) * (ahd->channel - 'A');
-
-		error = ahd_read_seeprom(ahd, (uint16_t *)sc,
-					 start_addr, sizeof(*sc)/2);
-
-		if (error != 0) {
-			printf("Unable to read SEEPROM\n");
-			have_seeprom = 0;
-		} else {
-			have_seeprom = ahd_verify_cksum(sc);
-
-			if (bootverbose) {
-				if (have_seeprom == 0)
-					printf ("checksum error\n");
-				else
-					printf ("done.\n");
-			}
-		}
-		ahd_release_seeprom(ahd);
-	}
-
-	if (!have_seeprom) {
-		u_int	  nvram_scb;
-
-		/*
-		 * Pull scratch ram settings and treat them as
-		 * if they are the contents of an seeprom if
-		 * the 'ADPT', 'BIOS', or 'ASPI' signature is found
-		 * in SCB 0xFF.  We manually compose the data as 16bit
-		 * values to avoid endian issues.
-		 */
-		ahd_set_scbptr(ahd, 0xFF);
-		nvram_scb = ahd_inb_scbram(ahd, SCB_BASE + NVRAM_SCB_OFFSET);
-		if (nvram_scb != 0xFF
-		 && ((ahd_inb_scbram(ahd, SCB_BASE + 0) == 'A'
-		   && ahd_inb_scbram(ahd, SCB_BASE + 1) == 'D'
-		   && ahd_inb_scbram(ahd, SCB_BASE + 2) == 'P'
-		   && ahd_inb_scbram(ahd, SCB_BASE + 3) == 'T')
-		  || (ahd_inb_scbram(ahd, SCB_BASE + 0) == 'B'
-		   && ahd_inb_scbram(ahd, SCB_BASE + 1) == 'I'
-		   && ahd_inb_scbram(ahd, SCB_BASE + 2) == 'O'
-		   && ahd_inb_scbram(ahd, SCB_BASE + 3) == 'S')
-		  || (ahd_inb_scbram(ahd, SCB_BASE + 0) == 'A'
-		   && ahd_inb_scbram(ahd, SCB_BASE + 1) == 'S'
-		   && ahd_inb_scbram(ahd, SCB_BASE + 2) == 'P'
-		   && ahd_inb_scbram(ahd, SCB_BASE + 3) == 'I'))) {
-			uint16_t *sc_data;
-			int	  i;
-
-			ahd_set_scbptr(ahd, nvram_scb);
-			sc_data = (uint16_t *)sc;
-			for (i = 0; i < 64; i += 2)
-				*sc_data++ = ahd_inw_scbram(ahd, SCB_BASE+i);
-			have_seeprom = ahd_verify_cksum(sc);
-			if (have_seeprom)
-				ahd->flags |= AHD_SCB_CONFIG_USED;
-		}
-	}
-
-#if AHD_DEBUG
-	if (have_seeprom != 0
-	 && (ahd_debug & AHD_DUMP_SEEPROM) != 0) {
-		uint8_t *sc_data;
-		int	 i;
-
-		printf("%s: Seeprom Contents:", ahd_name(ahd));
-		sc_data = (uint8_t *)sc;
-		for (i = 0; i < (sizeof(*sc)); i += 2)
-			printf("\n\t0x%.4x", 
-			       sc_data[i] | (sc_data[i+1] << 8));
-		printf("\n");
-	}
-#endif
-
-	if (!have_seeprom) {
-		if (bootverbose)
-			printf("%s: No SEEPROM available.\n", ahd_name(ahd));
-		ahd->flags |= AHD_USEDEFAULTS;
-		error = ahd_default_config(ahd);
-		adapter_control = CFAUTOTERM|CFSEAUTOTERM;
-		free(ahd->seep_config, M_DEVBUF);
-		ahd->seep_config = NULL;
-	} else {
-		error = ahd_parse_cfgdata(ahd, sc);
-		adapter_control = sc->adapter_control;
-	}
-	if (error != 0)
-		return (error);
-
-	ahd_configure_termination(ahd, adapter_control);
-
-	return (0);
-}
-
-static void
-ahd_configure_termination(struct ahd_softc *ahd, u_int adapter_control)
-{
-	int	 error;
-	u_int	 sxfrctl1;
-	uint8_t	 termctl;
-	uint32_t devconfig;
-
-	devconfig = ahd_pci_read_config(ahd->dev_softc, DEVCONFIG, /*bytes*/4);
-	devconfig &= ~STPWLEVEL;
-	if ((ahd->flags & AHD_STPWLEVEL_A) != 0)
-		devconfig |= STPWLEVEL;
-	if (bootverbose)
-		printf("%s: STPWLEVEL is %s\n",
-		       ahd_name(ahd), (devconfig & STPWLEVEL) ? "on" : "off");
-	ahd_pci_write_config(ahd->dev_softc, DEVCONFIG, devconfig, /*bytes*/4);
- 
-	/* Make sure current sensing is off. */
-	if ((ahd->flags & AHD_CURRENT_SENSING) != 0) {
-		(void)ahd_write_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL, 0);
-	}
-
-	/*
-	 * Read to sense.  Write to set.
-	 */
-	error = ahd_read_flexport(ahd, FLXADDR_TERMCTL, &termctl);
-	if ((adapter_control & CFAUTOTERM) == 0) {
-		if (bootverbose)
-			printf("%s: Manual Primary Termination\n",
-			       ahd_name(ahd));
-		termctl &= ~(FLX_TERMCTL_ENPRILOW|FLX_TERMCTL_ENPRIHIGH);
-		if ((adapter_control & CFSTERM) != 0)
-			termctl |= FLX_TERMCTL_ENPRILOW;
-		if ((adapter_control & CFWSTERM) != 0)
-			termctl |= FLX_TERMCTL_ENPRIHIGH;
-	} else if (error != 0) {
-		printf("%s: Primary Auto-Term Sensing failed! "
-		       "Using Defaults.\n", ahd_name(ahd));
-		termctl = FLX_TERMCTL_ENPRILOW|FLX_TERMCTL_ENPRIHIGH;
-	}
-
-	if ((adapter_control & CFSEAUTOTERM) == 0) {
-		if (bootverbose)
-			printf("%s: Manual Secondary Termination\n",
-			       ahd_name(ahd));
-		termctl &= ~(FLX_TERMCTL_ENSECLOW|FLX_TERMCTL_ENSECHIGH);
-		if ((adapter_control & CFSELOWTERM) != 0)
-			termctl |= FLX_TERMCTL_ENSECLOW;
-		if ((adapter_control & CFSEHIGHTERM) != 0)
-			termctl |= FLX_TERMCTL_ENSECHIGH;
-	} else if (error != 0) {
-		printf("%s: Secondary Auto-Term Sensing failed! "
-		       "Using Defaults.\n", ahd_name(ahd));
-		termctl |= FLX_TERMCTL_ENSECLOW|FLX_TERMCTL_ENSECHIGH;
-	}
-
-	/*
-	 * Now set the termination based on what we found.
-	 */
-	sxfrctl1 = ahd_inb(ahd, SXFRCTL1) & ~STPWEN;
-	if ((termctl & FLX_TERMCTL_ENPRILOW) != 0) {
-		ahd->flags |= AHD_TERM_ENB_A;
-		sxfrctl1 |= STPWEN;
-	}
-	/* Must set the latch once in order to be effective. */
-	ahd_outb(ahd, SXFRCTL1, sxfrctl1|STPWEN);
-	ahd_outb(ahd, SXFRCTL1, sxfrctl1);
-
-	error = ahd_write_flexport(ahd, FLXADDR_TERMCTL, termctl);
-	if (error != 0) {
-		printf("%s: Unable to set termination settings!\n",
-		       ahd_name(ahd));
-	} else if (bootverbose) {
-		printf("%s: Primary High byte termination %sabled\n",
-		       ahd_name(ahd),
-		       (termctl & FLX_TERMCTL_ENPRIHIGH) ? "En" : "Dis");
-
-		printf("%s: Primary Low byte termination %sabled\n",
-		       ahd_name(ahd),
-		       (termctl & FLX_TERMCTL_ENPRILOW) ? "En" : "Dis");
-
-		printf("%s: Secondary High byte termination %sabled\n",
-		       ahd_name(ahd),
-		       (termctl & FLX_TERMCTL_ENSECHIGH) ? "En" : "Dis");
-
-		printf("%s: Secondary Low byte termination %sabled\n",
-		       ahd_name(ahd),
-		       (termctl & FLX_TERMCTL_ENSECLOW) ? "En" : "Dis");
-	}
-	return;
-}
-
-#define	DPE	0x80
-#define SSE	0x40
-#define	RMA	0x20
-#define	RTA	0x10
-#define STA	0x08
-#define DPR	0x01
-
-static const char *split_status_source[] =
-{
-	"DFF0",
-	"DFF1",
-	"OVLY",
-	"CMC",
-};
-
-static const char *pci_status_source[] =
-{
-	"DFF0",
-	"DFF1",
-	"SG",
-	"CMC",
-	"OVLY",
-	"NONE",
-	"MSI",
-	"TARG"
-};
-
-static const char *split_status_strings[] =
-{
-	"%s: Received split response in %s.\n"
-	"%s: Received split completion error message in %s\n",
-	"%s: Receive overrun in %s\n",
-	"%s: Count not complete in %s\n",
-	"%s: Split completion data bucket in %s\n",
-	"%s: Split completion address error in %s\n",
-	"%s: Split completion byte count error in %s\n",
-	"%s: Signaled Target-abort to early terminate a split in %s\n",
-};
-
-static const char *pci_status_strings[] =
-{
-	"%s: Data Parity Error has been reported via PERR# in %s\n",
-	"%s: Target initial wait state error in %s\n",
-	"%s: Split completion read data parity error in %s\n",
-	"%s: Split completion address attribute parity error in %s\n",
-	"%s: Received a Target Abort in %s\n",
-	"%s: Received a Master Abort in %s\n",
-	"%s: Signal System Error Detected in %s\n",
-	"%s: Address or Write Phase Parity Error Detected in %s.\n"
-};
-
-void
-ahd_pci_intr(struct ahd_softc *ahd)
-{
-	uint8_t		pci_status[8];
-	ahd_mode_state	saved_modes;
-	u_int		pci_status1;
-	u_int		intstat;
-	u_int		i;
-	u_int		reg;
-	
-	intstat = ahd_inb(ahd, INTSTAT);
-
-	if ((intstat & SPLTINT) != 0)
-		ahd_pci_split_intr(ahd, intstat);
-
-	if ((intstat & PCIINT) == 0)
-		return;
-
-	printf("%s: PCI error Interrupt\n", ahd_name(ahd));
-	saved_modes = ahd_save_modes(ahd);
-	ahd_dump_card_state(ahd);
-	ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
-	for (i = 0, reg = DF0PCISTAT; i < 8; i++, reg++) {
-
-		if (i == 5)
-			continue;
-		pci_status[i] = ahd_inb(ahd, reg);
-		/* Clear latched errors.  So our interupt deasserts. */
-		ahd_outb(ahd, reg, pci_status[i]);
-	}
-
-	for (i = 0; i < 8; i++) {
-		u_int bit;
-	
-		if (i == 5)
-			continue;
-
-		for (bit = 0; bit < 8; bit++) {
-
-			if ((pci_status[i] & (0x1 << bit)) != 0) {
-				static const char *s;
-
-				s = pci_status_strings[bit];
-				if (i == 7/*TARG*/ && bit == 3)
-					s = "%s: Signaled Target Abort\n";
-				printf(s, ahd_name(ahd), pci_status_source[i]);
-			}
-		}	
-	}
-	pci_status1 = ahd_pci_read_config(ahd->dev_softc,
-					  PCIR_STATUS + 1, /*bytes*/1);
-	ahd_pci_write_config(ahd->dev_softc, PCIR_STATUS + 1,
-			     pci_status1, /*bytes*/1);
-	ahd_restore_modes(ahd, saved_modes);
-	ahd_outb(ahd, CLRINT, CLRPCIINT);
-	ahd_unpause(ahd);
-}
-
-static void
-ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat)
-{
-	uint8_t		split_status[4];
-	uint8_t		split_status1[4];
-	uint8_t		sg_split_status[2];
-	uint8_t		sg_split_status1[2];
-	ahd_mode_state	saved_modes;
-	u_int		i;
-	uint16_t	pcix_status;
-
-	/*
-	 * Check for splits in all modes.  Modes 0 and 1
-	 * additionally have SG engine splits to look at.
-	 */
-	pcix_status = ahd_pci_read_config(ahd->dev_softc, PCIXR_STATUS,
-					  /*bytes*/2);
-	printf("%s: PCI Split Interrupt - PCI-X status = 0x%x\n",
-	       ahd_name(ahd), pcix_status);
-	saved_modes = ahd_save_modes(ahd);
-	for (i = 0; i < 4; i++) {
-		ahd_set_modes(ahd, i, i);
-
-		split_status[i] = ahd_inb(ahd, DCHSPLTSTAT0);
-		split_status1[i] = ahd_inb(ahd, DCHSPLTSTAT1);
-		/* Clear latched errors.  So our interupt deasserts. */
-		ahd_outb(ahd, DCHSPLTSTAT0, split_status[i]);
-		ahd_outb(ahd, DCHSPLTSTAT1, split_status1[i]);
-		if (i != 0)
-			continue;
-		sg_split_status[i] = ahd_inb(ahd, SGSPLTSTAT0);
-		sg_split_status1[i] = ahd_inb(ahd, SGSPLTSTAT1);
-		/* Clear latched errors.  So our interupt deasserts. */
-		ahd_outb(ahd, SGSPLTSTAT0, sg_split_status[i]);
-		ahd_outb(ahd, SGSPLTSTAT1, sg_split_status1[i]);
-	}
-
-	for (i = 0; i < 4; i++) {
-		u_int bit;
-
-		for (bit = 0; bit < 8; bit++) {
-
-			if ((split_status[i] & (0x1 << bit)) != 0) {
-				static const char *s;
-
-				s = split_status_strings[bit];
-				printf(s, ahd_name(ahd),
-				       split_status_source[i]);
-			}
-
-			if (i != 0)
-				continue;
-
-			if ((sg_split_status[i] & (0x1 << bit)) != 0) {
-				static const char *s;
-
-				s = split_status_strings[bit];
-				printf(s, ahd_name(ahd), "SG");
-			}
-		}
-	}
-	/*
-	 * Clear PCI-X status bits.
-	 */
-	ahd_pci_write_config(ahd->dev_softc, PCIXR_STATUS,
-			     pcix_status, /*bytes*/2);
-	ahd_outb(ahd, CLRINT, CLRSPLTINT);
-	ahd_restore_modes(ahd, saved_modes);
-}
-
-static int
-ahd_aic7901A_setup(struct ahd_softc *ahd)
-{
-	int error;
-
-	error = ahd_aic7902_setup(ahd);
-	if (error != 0)
-		return (error);
-	ahd->chip = AHD_AIC7901A;
-	return (0);
-}
-
-static int
-ahd_aic7902_setup(struct ahd_softc *ahd)
-{
-	ahd_dev_softc_t pci;
-	u_int rev;
-
-	pci = ahd->dev_softc;
-	rev = ahd_pci_read_config(pci, PCIR_REVID, /*bytes*/1);
-	if (rev < ID_AIC7902_PCI_REV_A4) {
-		printf("%s: Unable to attach to unsupported chip revision %d\n",
-		       ahd_name(ahd), rev);
-		ahd_pci_write_config(pci, PCIR_COMMAND, 0, /*bytes*/1);
-		return (ENXIO);
-	}
-	ahd->channel = ahd_get_pci_function(pci) + 'A';
-	ahd->chip = AHD_AIC7902;
-	ahd->features = AHD_AIC7902_FE;
-	if (rev < ID_AIC7902_PCI_REV_B0) {
-		/*
-		 * Enable A series workarounds.
-		 */
-		ahd->bugs |= AHD_SENT_SCB_UPDATE_BUG|AHD_ABORT_LQI_BUG
-			  |  AHD_PKT_BITBUCKET_BUG|AHD_LONG_SETIMO_BUG
-			  |  AHD_NLQICRC_DELAYED_BUG|AHD_SCSIRST_BUG
-			  |  AHD_LQO_ATNO_BUG|AHD_AUTOFLUSH_BUG
-			  |  AHD_CLRLQO_AUTOCLR_BUG|AHD_PCIX_MMAPIO_BUG
-			  |  AHD_PCIX_CHIPRST_BUG|AHD_PKTIZED_STATUS_BUG
-			  |  AHD_PKT_LUN_BUG|AHD_MDFF_WSCBPTR_BUG
-			  |  AHD_REG_SLOW_SETTLE_BUG|AHD_SET_MODE_BUG
-			  |  AHD_BUSFREEREV_BUG|AHD_NONPACKFIFO_BUG
-			  |  AHD_PACED_NEGTABLE_BUG;
-
-		/*
-		 * IO Cell paramter setup.
-		 */
-		AHD_SET_PRECOMP(ahd, AHD_PRECOMP_CUTBACK_29);
-
-		if ((ahd->flags & AHD_HP_BOARD) == 0)
-			AHD_SET_SLEWRATE(ahd, AHD_SLEWRATE_DEF_REVA);
-	} else {
-		u_int devconfig1;
-
-		ahd->features |= AHD_RTI|AHD_NEW_IOCELL_OPTS
-			      |  AHD_NEW_DFCNTRL_OPTS;
-		ahd->bugs |= AHD_LQOOVERRUN_BUG|AHD_ABORT_LQI_BUG
-			  |  AHD_INTCOLLISION_BUG;
-
-		/*
-		 * IO Cell paramter setup.
-		 */
-		AHD_SET_PRECOMP(ahd, AHD_PRECOMP_CUTBACK_29);
-		AHD_SET_SLEWRATE(ahd, AHD_SLEWRATE_DEF_REVB);
-		AHD_SET_AMPLITUDE(ahd, AHD_AMPLITUDE_DEF);
-
-		/*
-		 * Set the PREQDIS bit for H2B which disables some workaround
-		 * that doesn't work on regular PCI busses.
-		 * XXX - Find out exactly what this does from the hardware
-		 * 	 folks!
-		 */
-		devconfig1 = ahd_pci_read_config(pci, DEVCONFIG1, /*bytes*/1);
-		ahd_pci_write_config(pci, DEVCONFIG1,
-				     devconfig1|PREQDIS, /*bytes*/1);
-		devconfig1 = ahd_pci_read_config(pci, DEVCONFIG1, /*bytes*/1);
-	}
-
-	return (0);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aic79xx_proc.c linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx_proc.c
--- linux-2.4.21/drivers/scsi/aic79xx/aic79xx_proc.c	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx_proc.c	2003-06-26 21:43:14.000000000 +0000
@@ -1,345 +0,0 @@
-/*
- * 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.
- *
- * String handling code courtesy of Gerard Roudier's <groudier@club-internet.fr>
- * sym driver.
- *
- * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_proc.c#11 $
- */
-#include "aic79xx_osm.h"
-#include "aic79xx_inline.h"
-
-static void	copy_mem_info(struct info_str *info, char *data, int len);
-static int	copy_info(struct info_str *info, char *fmt, ...);
-static void	ahd_dump_target_state(struct ahd_softc *ahd,
-				      struct info_str *info,
-				      u_int our_id, char channel,
-				      u_int target_id, u_int target_offset);
-static void	ahd_dump_device_state(struct info_str *info,
-				      struct ahd_linux_device *dev);
-static int	ahd_proc_write_seeprom(struct ahd_softc *ahd,
-				       char *buffer, int length);
-
-static void
-copy_mem_info(struct info_str *info, char *data, int len)
-{
-	if (info->pos + len > info->offset + info->length)
-		len = info->offset + info->length - info->pos;
-
-	if (info->pos + len < info->offset) {
-		info->pos += len;
-		return;
-	}
-
-	if (info->pos < info->offset) {
-		off_t partial;
-
-		partial = info->offset - info->pos;
-		data += partial;
-		info->pos += partial;
-		len  -= partial;
-	}
-
-	if (len > 0) {
-		memcpy(info->buffer, data, len);
-		info->pos += len;
-		info->buffer += len;
-	}
-}
-
-static int
-copy_info(struct info_str *info, char *fmt, ...)
-{
-	va_list args;
-	char buf[256];
-	int len;
-
-	va_start(args, fmt);
-	len = vsprintf(buf, fmt, args);
-	va_end(args);
-
-	copy_mem_info(info, buf, len);
-	return (len);
-}
-
-void
-ahd_format_transinfo(struct info_str *info, struct ahd_transinfo *tinfo)
-{
-	u_int speed;
-	u_int freq;
-	u_int mb;
-
-	if (tinfo->period == AHD_PERIOD_UNKNOWN) {
-		copy_info(info, "Renegotiation Pending\n");
-		return;
-	}
-        speed = 3300;
-        freq = 0;
-	if (tinfo->offset != 0) {
-		freq = aic_calc_syncsrate(tinfo->period);
-		speed = freq;
-	}
-	speed *= (0x01 << tinfo->width);
-        mb = speed / 1000;
-        if (mb > 0)
-		copy_info(info, "%d.%03dMB/s transfers", mb, speed % 1000);
-        else
-		copy_info(info, "%dKB/s transfers", speed);
-
-	if (freq != 0) {
-		int	printed_options;
-
-		printed_options = 0;
-		copy_info(info, " (%d.%03dMHz", freq / 1000, freq % 1000);
-		if ((tinfo->ppr_options & MSG_EXT_PPR_DT_REQ) != 0) {
-			copy_info(info, " DT");
-			printed_options++;
-		}
-		if ((tinfo->ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
-			copy_info(info, "%s", printed_options ? "|IU" : " IU");
-			printed_options++;
-		}
-		if ((tinfo->ppr_options & MSG_EXT_PPR_RTI) != 0) {
-			copy_info(info, "%s",
-				  printed_options ? "|RTI" : " RTI");
-			printed_options++;
-		}
-		if ((tinfo->ppr_options & MSG_EXT_PPR_QAS_REQ) != 0) {
-			copy_info(info, "%s",
-				  printed_options ? "|QAS" : " QAS");
-			printed_options++;
-		}
-	}
-
-	if (tinfo->width > 0) {
-		if (freq != 0) {
-			copy_info(info, ", ");
-		} else {
-			copy_info(info, " (");
-		}
-		copy_info(info, "%dbit)", 8 * (0x01 << tinfo->width));
-	} else if (freq != 0) {
-		copy_info(info, ")");
-	}
-	copy_info(info, "\n");
-}
-
-static void
-ahd_dump_target_state(struct ahd_softc *ahd, struct info_str *info,
-		      u_int our_id, char channel, u_int target_id,
-		      u_int target_offset)
-{
-	struct	ahd_linux_target *targ;
-	struct	ahd_initiator_tinfo *tinfo;
-	struct	ahd_tmode_tstate *tstate;
-	int	lun;
-
-	tinfo = ahd_fetch_transinfo(ahd, channel, our_id,
-				    target_id, &tstate);
-	copy_info(info, "Channel %c Target %d Negotiation Settings\n",
-		  channel, target_id);
-	copy_info(info, "\tUser: ");
-	ahd_format_transinfo(info, &tinfo->user);
-	targ = ahd->platform_data->targets[target_offset];
-	if (targ == NULL)
-		return;
-
-	copy_info(info, "\tGoal: ");
-	ahd_format_transinfo(info, &tinfo->goal);
-	copy_info(info, "\tCurr: ");
-	ahd_format_transinfo(info, &tinfo->curr);
-	copy_info(info, "\tTransmission Errors %ld\n", targ->errors_detected);
-
-	for (lun = 0; lun < AHD_NUM_LUNS; lun++) {
-		struct ahd_linux_device *dev;
-
-		dev = targ->devices[lun];
-
-		if (dev == NULL)
-			continue;
-
-		ahd_dump_device_state(info, dev);
-	}
-}
-
-static void
-ahd_dump_device_state(struct info_str *info, struct ahd_linux_device *dev)
-{
-	copy_info(info, "\tChannel %c Target %d Lun %d Settings\n",
-		  dev->target->channel + 'A', dev->target->target, dev->lun);
-
-	copy_info(info, "\t\tCommands Queued %ld\n", dev->commands_issued);
-	copy_info(info, "\t\tCommands Active %d\n", dev->active);
-	copy_info(info, "\t\tCommand Openings %d\n", dev->openings);
-	copy_info(info, "\t\tMax Tagged Openings %d\n", dev->maxtags);
-	copy_info(info, "\t\tDevice Queue Frozen Count %d\n", dev->qfrozen);
-}
-
-static int
-ahd_proc_write_seeprom(struct ahd_softc *ahd, char *buffer, int length)
-{
-	ahd_mode_state saved_modes;
-	int have_seeprom;
-	u_long s;
-	int paused;
-	int written;
-
-	/* Default to failure. */
-	written = -EINVAL;
-	ahd_lock(ahd, &s);
-	paused = ahd_is_paused(ahd);
-	if (!paused)
-		ahd_pause(ahd);
-
-	saved_modes = ahd_save_modes(ahd);
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
-	if (length != sizeof(struct seeprom_config)) {
-		printf("ahd_proc_write_seeprom: incorrect buffer size\n");
-		goto done;
-	}
-
-	have_seeprom = ahd_verify_cksum((struct seeprom_config*)buffer);
-	if (have_seeprom == 0) {
-		printf("ahd_proc_write_seeprom: cksum verification failed\n");
-		goto done;
-	}
-
-	have_seeprom = ahd_acquire_seeprom(ahd);
-	if (!have_seeprom) {
-		printf("ahd_proc_write_seeprom: No Serial EEPROM\n");
-		goto done;
-	} else {
-		u_int start_addr;
-
-		if (ahd->seep_config == NULL) {
-			ahd->seep_config = malloc(sizeof(*ahd->seep_config),
-						  M_DEVBUF, M_NOWAIT);
-			if (ahd->seep_config == NULL) {
-				printf("aic79xx: Unable to allocate serial "
-				       "eeprom buffer.  Write failing\n");
-				goto done;
-			}
-		}
-		printf("aic79xx: Writing Serial EEPROM\n");
-		start_addr = 32 * (ahd->channel - 'A');
-		ahd_write_seeprom(ahd, (u_int16_t *)buffer, start_addr,
-				  sizeof(struct seeprom_config)/2);
-		ahd_read_seeprom(ahd, (uint16_t *)ahd->seep_config,
-				 start_addr, sizeof(struct seeprom_config)/2);
-		ahd_release_seeprom(ahd);
-		written = length;
-	}
-
-done:
-	ahd_restore_modes(ahd, saved_modes);
-	if (!paused)
-		ahd_unpause(ahd);
-	ahd_unlock(ahd, &s);
-	return (written);
-}
-/*
- * Return information to handle /proc support for the driver.
- */
-int
-ahd_linux_proc_info(char *buffer, char **start, off_t offset,
-		  int length, int hostno, int inout)
-{
-	struct	ahd_softc *ahd;
-	struct	info_str info;
-	char	ahd_info[256];
-	u_long	l;
-	u_int	max_targ;
-	u_int	i;
-	int	retval;
-
-	retval = -EINVAL;
-	ahd_list_lock(&l);
-	TAILQ_FOREACH(ahd, &ahd_tailq, links) {
-		if (ahd->platform_data->host->host_no == hostno)
-			break;
-	}
-
-	if (ahd == NULL)
-		goto done;
-
-	 /* Has data been written to the file? */ 
-	if (inout == TRUE) {
-		retval = ahd_proc_write_seeprom(ahd, buffer, length);
-		goto done;
-	}
-
-	if (start)
-		*start = buffer;
-
-	info.buffer	= buffer;
-	info.length	= length;
-	info.offset	= offset;
-	info.pos	= 0;
-
-	copy_info(&info, "Adaptec AIC79xx driver version: %s\n",
-		  AIC79XX_DRIVER_VERSION);
-	ahd_controller_info(ahd, ahd_info);
-	copy_info(&info, "%s\n\n", ahd_info);
-
-	if (ahd->seep_config == NULL)
-		copy_info(&info, "No Serial EEPROM\n");
-	else {
-		copy_info(&info, "Serial EEPROM:\n");
-		for (i = 0; i < sizeof(*ahd->seep_config)/2; i++) {
-			if (((i % 8) == 0) && (i != 0)) {
-				copy_info(&info, "\n");
-			}
-			copy_info(&info, "0x%.4x ",
-				  ((uint16_t*)ahd->seep_config)[i]);
-		}
-		copy_info(&info, "\n");
-	}
-	copy_info(&info, "\n");
-
-	max_targ = 15;
-	if ((ahd->features & AHD_WIDE) == 0)
-		max_targ = 7;
-
-	for (i = 0; i <= max_targ; i++) {
-
-		ahd_dump_target_state(ahd, &info, ahd->our_id, 'A',
-				      /*target_id*/i, /*target_offset*/i);
-	}
-	retval = info.pos > info.offset ? info.pos - info.offset : 0;
-done:
-	ahd_list_unlock(&l);
-	return (retval);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aic79xx_reg.h linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx_reg.h
--- linux-2.4.21/drivers/scsi/aic79xx/aic79xx_reg.h	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx_reg.h	2003-06-26 21:43:28.000000000 +0000
@@ -1,3778 +0,0 @@
-/*
- * DO NOT EDIT - This file is automatically generated
- *		 from the following source files:
- *
- * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#78 $
- * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#60 $
- */
-typedef int (ahd_reg_print_t)(u_int, u_int *, u_int);
-typedef struct ahd_reg_parse_entry {
-	char	*name;
-	uint8_t	 value;
-	uint8_t	 mask;
-} ahd_reg_parse_entry_t;
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_mode_ptr_print;
-#else
-#define ahd_mode_ptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "MODE_PTR", 0x00, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_intstat_print;
-#else
-#define ahd_intstat_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "INTSTAT", 0x01, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_seqintcode_print;
-#else
-#define ahd_seqintcode_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SEQINTCODE", 0x02, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_clrint_print;
-#else
-#define ahd_clrint_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CLRINT", 0x03, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_error_print;
-#else
-#define ahd_error_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "ERROR", 0x04, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_clrerr_print;
-#else
-#define ahd_clrerr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CLRERR", 0x04, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_hcntrl_print;
-#else
-#define ahd_hcntrl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "HCNTRL", 0x05, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_hnscb_qoff_print;
-#else
-#define ahd_hnscb_qoff_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "HNSCB_QOFF", 0x06, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_hescb_qoff_print;
-#else
-#define ahd_hescb_qoff_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "HESCB_QOFF", 0x08, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_hs_mailbox_print;
-#else
-#define ahd_hs_mailbox_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "HS_MAILBOX", 0x0b, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_clrseqintstat_print;
-#else
-#define ahd_clrseqintstat_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CLRSEQINTSTAT", 0x0c, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_seqintstat_print;
-#else
-#define ahd_seqintstat_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SEQINTSTAT", 0x0c, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_swtimer_print;
-#else
-#define ahd_swtimer_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SWTIMER", 0x0e, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_snscb_qoff_print;
-#else
-#define ahd_snscb_qoff_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SNSCB_QOFF", 0x10, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sescb_qoff_print;
-#else
-#define ahd_sescb_qoff_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SESCB_QOFF", 0x12, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sdscb_qoff_print;
-#else
-#define ahd_sdscb_qoff_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SDSCB_QOFF", 0x14, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_qoff_ctlsta_print;
-#else
-#define ahd_qoff_ctlsta_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "QOFF_CTLSTA", 0x16, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_intctl_print;
-#else
-#define ahd_intctl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "INTCTL", 0x18, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dfcntrl_print;
-#else
-#define ahd_dfcntrl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DFCNTRL", 0x19, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dscommand0_print;
-#else
-#define ahd_dscommand0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DSCOMMAND0", 0x19, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dfstatus_print;
-#else
-#define ahd_dfstatus_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DFSTATUS", 0x1a, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sg_cache_shadow_print;
-#else
-#define ahd_sg_cache_shadow_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SG_CACHE_SHADOW", 0x1b, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_arbctl_print;
-#else
-#define ahd_arbctl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "ARBCTL", 0x1b, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sg_cache_pre_print;
-#else
-#define ahd_sg_cache_pre_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SG_CACHE_PRE", 0x1b, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lqin_print;
-#else
-#define ahd_lqin_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LQIN", 0x20, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_typeptr_print;
-#else
-#define ahd_typeptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "TYPEPTR", 0x20, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_tagptr_print;
-#else
-#define ahd_tagptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "TAGPTR", 0x21, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lunptr_print;
-#else
-#define ahd_lunptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LUNPTR", 0x22, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_datalenptr_print;
-#else
-#define ahd_datalenptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DATALENPTR", 0x23, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_statlenptr_print;
-#else
-#define ahd_statlenptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "STATLENPTR", 0x24, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_cmdlenptr_print;
-#else
-#define ahd_cmdlenptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CMDLENPTR", 0x25, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_attrptr_print;
-#else
-#define ahd_attrptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "ATTRPTR", 0x26, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_flagptr_print;
-#else
-#define ahd_flagptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "FLAGPTR", 0x27, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_cmdptr_print;
-#else
-#define ahd_cmdptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CMDPTR", 0x28, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_qnextptr_print;
-#else
-#define ahd_qnextptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "QNEXTPTR", 0x29, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_idptr_print;
-#else
-#define ahd_idptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "IDPTR", 0x2a, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_abrtbyteptr_print;
-#else
-#define ahd_abrtbyteptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "ABRTBYTEPTR", 0x2b, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_abrtbitptr_print;
-#else
-#define ahd_abrtbitptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "ABRTBITPTR", 0x2c, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_maxcmdbytes_print;
-#else
-#define ahd_maxcmdbytes_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "MAXCMDBYTES", 0x2d, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_maxcmd2rcv_print;
-#else
-#define ahd_maxcmd2rcv_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "MAXCMD2RCV", 0x2e, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_shortthresh_print;
-#else
-#define ahd_shortthresh_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SHORTTHRESH", 0x2f, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lunlen_print;
-#else
-#define ahd_lunlen_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LUNLEN", 0x30, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_cdblimit_print;
-#else
-#define ahd_cdblimit_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CDBLIMIT", 0x31, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_maxcmd_print;
-#else
-#define ahd_maxcmd_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "MAXCMD", 0x32, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_maxcmdcnt_print;
-#else
-#define ahd_maxcmdcnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "MAXCMDCNT", 0x33, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lqrsvd01_print;
-#else
-#define ahd_lqrsvd01_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LQRSVD01", 0x34, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lqrsvd16_print;
-#else
-#define ahd_lqrsvd16_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LQRSVD16", 0x35, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lqrsvd17_print;
-#else
-#define ahd_lqrsvd17_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LQRSVD17", 0x36, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_cmdrsvd0_print;
-#else
-#define ahd_cmdrsvd0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CMDRSVD0", 0x37, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lqctl0_print;
-#else
-#define ahd_lqctl0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LQCTL0", 0x38, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lqctl1_print;
-#else
-#define ahd_lqctl1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LQCTL1", 0x38, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scsbist0_print;
-#else
-#define ahd_scsbist0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCSBIST0", 0x39, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lqctl2_print;
-#else
-#define ahd_lqctl2_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LQCTL2", 0x39, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scsbist1_print;
-#else
-#define ahd_scsbist1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCSBIST1", 0x3a, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scsiseq0_print;
-#else
-#define ahd_scsiseq0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCSISEQ0", 0x3a, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scsiseq1_print;
-#else
-#define ahd_scsiseq1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCSISEQ1", 0x3b, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sxfrctl0_print;
-#else
-#define ahd_sxfrctl0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SXFRCTL0", 0x3c, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_businitid_print;
-#else
-#define ahd_businitid_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "BUSINITID", 0x3c, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dlcount_print;
-#else
-#define ahd_dlcount_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DLCOUNT", 0x3c, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sxfrctl1_print;
-#else
-#define ahd_sxfrctl1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SXFRCTL1", 0x3d, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_bustargid_print;
-#else
-#define ahd_bustargid_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "BUSTARGID", 0x3e, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sxfrctl2_print;
-#else
-#define ahd_sxfrctl2_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SXFRCTL2", 0x3e, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dffstat_print;
-#else
-#define ahd_dffstat_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DFFSTAT", 0x3f, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scsisigo_print;
-#else
-#define ahd_scsisigo_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCSISIGO", 0x40, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_multargid_print;
-#else
-#define ahd_multargid_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "MULTARGID", 0x40, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scsisigi_print;
-#else
-#define ahd_scsisigi_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCSISIGI", 0x41, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scsiphase_print;
-#else
-#define ahd_scsiphase_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCSIPHASE", 0x42, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scsidat0_img_print;
-#else
-#define ahd_scsidat0_img_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCSIDAT0_IMG", 0x43, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scsidat_print;
-#else
-#define ahd_scsidat_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCSIDAT", 0x44, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scsibus_print;
-#else
-#define ahd_scsibus_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCSIBUS", 0x46, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_targidin_print;
-#else
-#define ahd_targidin_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "TARGIDIN", 0x48, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_selid_print;
-#else
-#define ahd_selid_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SELID", 0x49, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sblkctl_print;
-#else
-#define ahd_sblkctl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SBLKCTL", 0x4a, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_optionmode_print;
-#else
-#define ahd_optionmode_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "OPTIONMODE", 0x4a, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sstat0_print;
-#else
-#define ahd_sstat0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SSTAT0", 0x4b, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_clrsint0_print;
-#else
-#define ahd_clrsint0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CLRSINT0", 0x4b, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_simode0_print;
-#else
-#define ahd_simode0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SIMODE0", 0x4b, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_clrsint1_print;
-#else
-#define ahd_clrsint1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CLRSINT1", 0x4c, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sstat1_print;
-#else
-#define ahd_sstat1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SSTAT1", 0x4c, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sstat2_print;
-#else
-#define ahd_sstat2_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SSTAT2", 0x4d, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_clrsint2_print;
-#else
-#define ahd_clrsint2_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CLRSINT2", 0x4d, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_simode2_print;
-#else
-#define ahd_simode2_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SIMODE2", 0x4d, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_perrdiag_print;
-#else
-#define ahd_perrdiag_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "PERRDIAG", 0x4e, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lqistate_print;
-#else
-#define ahd_lqistate_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LQISTATE", 0x4e, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_soffcnt_print;
-#else
-#define ahd_soffcnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SOFFCNT", 0x4f, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lqostate_print;
-#else
-#define ahd_lqostate_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LQOSTATE", 0x4f, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lqistat0_print;
-#else
-#define ahd_lqistat0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LQISTAT0", 0x50, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_clrlqiint0_print;
-#else
-#define ahd_clrlqiint0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CLRLQIINT0", 0x50, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lqimode0_print;
-#else
-#define ahd_lqimode0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LQIMODE0", 0x50, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lqimode1_print;
-#else
-#define ahd_lqimode1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LQIMODE1", 0x51, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lqistat1_print;
-#else
-#define ahd_lqistat1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LQISTAT1", 0x51, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_clrlqiint1_print;
-#else
-#define ahd_clrlqiint1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CLRLQIINT1", 0x51, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lqistat2_print;
-#else
-#define ahd_lqistat2_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LQISTAT2", 0x52, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sstat3_print;
-#else
-#define ahd_sstat3_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SSTAT3", 0x53, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_simode3_print;
-#else
-#define ahd_simode3_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SIMODE3", 0x53, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_clrsint3_print;
-#else
-#define ahd_clrsint3_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CLRSINT3", 0x53, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lqomode0_print;
-#else
-#define ahd_lqomode0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LQOMODE0", 0x54, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lqostat0_print;
-#else
-#define ahd_lqostat0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LQOSTAT0", 0x54, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_clrlqoint0_print;
-#else
-#define ahd_clrlqoint0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CLRLQOINT0", 0x54, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lqostat1_print;
-#else
-#define ahd_lqostat1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LQOSTAT1", 0x55, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_clrlqoint1_print;
-#else
-#define ahd_clrlqoint1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CLRLQOINT1", 0x55, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lqomode1_print;
-#else
-#define ahd_lqomode1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LQOMODE1", 0x55, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lqostat2_print;
-#else
-#define ahd_lqostat2_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LQOSTAT2", 0x56, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_os_space_cnt_print;
-#else
-#define ahd_os_space_cnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "OS_SPACE_CNT", 0x56, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_simode1_print;
-#else
-#define ahd_simode1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SIMODE1", 0x57, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_gsfifo_print;
-#else
-#define ahd_gsfifo_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "GSFIFO", 0x58, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dffsxfrctl_print;
-#else
-#define ahd_dffsxfrctl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DFFSXFRCTL", 0x5a, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lqoscsctl_print;
-#else
-#define ahd_lqoscsctl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LQOSCSCTL", 0x5a, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_nextscb_print;
-#else
-#define ahd_nextscb_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "NEXTSCB", 0x5a, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_clrseqintsrc_print;
-#else
-#define ahd_clrseqintsrc_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CLRSEQINTSRC", 0x5b, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_seqintsrc_print;
-#else
-#define ahd_seqintsrc_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SEQINTSRC", 0x5b, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_currscb_print;
-#else
-#define ahd_currscb_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CURRSCB", 0x5c, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_seqimode_print;
-#else
-#define ahd_seqimode_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SEQIMODE", 0x5c, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_mdffstat_print;
-#else
-#define ahd_mdffstat_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "MDFFSTAT", 0x5d, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_crccontrol_print;
-#else
-#define ahd_crccontrol_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CRCCONTROL", 0x5d, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dfftag_print;
-#else
-#define ahd_dfftag_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DFFTAG", 0x5e, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lastscb_print;
-#else
-#define ahd_lastscb_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LASTSCB", 0x5e, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scsitest_print;
-#else
-#define ahd_scsitest_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCSITEST", 0x5e, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_iopdnctl_print;
-#else
-#define ahd_iopdnctl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "IOPDNCTL", 0x5f, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_shaddr_print;
-#else
-#define ahd_shaddr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SHADDR", 0x60, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_negoaddr_print;
-#else
-#define ahd_negoaddr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "NEGOADDR", 0x60, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dgrpcrci_print;
-#else
-#define ahd_dgrpcrci_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DGRPCRCI", 0x60, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_negperiod_print;
-#else
-#define ahd_negperiod_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "NEGPERIOD", 0x61, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_packcrci_print;
-#else
-#define ahd_packcrci_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "PACKCRCI", 0x62, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_negoffset_print;
-#else
-#define ahd_negoffset_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "NEGOFFSET", 0x62, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_negppropts_print;
-#else
-#define ahd_negppropts_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "NEGPPROPTS", 0x63, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_negconopts_print;
-#else
-#define ahd_negconopts_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "NEGCONOPTS", 0x64, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_annexcol_print;
-#else
-#define ahd_annexcol_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "ANNEXCOL", 0x65, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scschkn_print;
-#else
-#define ahd_scschkn_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCSCHKN", 0x66, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_annexdat_print;
-#else
-#define ahd_annexdat_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "ANNEXDAT", 0x66, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_iownid_print;
-#else
-#define ahd_iownid_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "IOWNID", 0x67, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_pll960ctl0_print;
-#else
-#define ahd_pll960ctl0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "PLL960CTL0", 0x68, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_shcnt_print;
-#else
-#define ahd_shcnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SHCNT", 0x68, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_townid_print;
-#else
-#define ahd_townid_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "TOWNID", 0x69, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_pll960ctl1_print;
-#else
-#define ahd_pll960ctl1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "PLL960CTL1", 0x69, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_pll960cnt0_print;
-#else
-#define ahd_pll960cnt0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "PLL960CNT0", 0x6a, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_xsig_print;
-#else
-#define ahd_xsig_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "XSIG", 0x6a, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_seloid_print;
-#else
-#define ahd_seloid_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SELOID", 0x6b, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_pll400ctl0_print;
-#else
-#define ahd_pll400ctl0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "PLL400CTL0", 0x6c, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_fairness_print;
-#else
-#define ahd_fairness_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "FAIRNESS", 0x6c, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_pll400ctl1_print;
-#else
-#define ahd_pll400ctl1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "PLL400CTL1", 0x6d, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_pll400cnt0_print;
-#else
-#define ahd_pll400cnt0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "PLL400CNT0", 0x6e, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_unfairness_print;
-#else
-#define ahd_unfairness_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "UNFAIRNESS", 0x6e, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_haddr_print;
-#else
-#define ahd_haddr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "HADDR", 0x70, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_plldelay_print;
-#else
-#define ahd_plldelay_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "PLLDELAY", 0x70, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_hodmaadr_print;
-#else
-#define ahd_hodmaadr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "HODMAADR", 0x70, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_hodmacnt_print;
-#else
-#define ahd_hodmacnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "HODMACNT", 0x78, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_hcnt_print;
-#else
-#define ahd_hcnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "HCNT", 0x78, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_hodmaen_print;
-#else
-#define ahd_hodmaen_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "HODMAEN", 0x7a, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sghaddr_print;
-#else
-#define ahd_sghaddr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SGHADDR", 0x7c, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scbhaddr_print;
-#else
-#define ahd_scbhaddr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCBHADDR", 0x7c, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sghcnt_print;
-#else
-#define ahd_sghcnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SGHCNT", 0x84, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scbhcnt_print;
-#else
-#define ahd_scbhcnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCBHCNT", 0x84, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dff_thrsh_print;
-#else
-#define ahd_dff_thrsh_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DFF_THRSH", 0x88, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_romaddr_print;
-#else
-#define ahd_romaddr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "ROMADDR", 0x8a, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_romcntrl_print;
-#else
-#define ahd_romcntrl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "ROMCNTRL", 0x8d, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_romdata_print;
-#else
-#define ahd_romdata_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "ROMDATA", 0x8e, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_cmcrxmsg0_print;
-#else
-#define ahd_cmcrxmsg0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CMCRXMSG0", 0x90, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_roenable_print;
-#else
-#define ahd_roenable_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "ROENABLE", 0x90, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_ovlyrxmsg0_print;
-#else
-#define ahd_ovlyrxmsg0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "OVLYRXMSG0", 0x90, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dchrxmsg0_print;
-#else
-#define ahd_dchrxmsg0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DCHRXMSG0", 0x90, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_ovlyrxmsg1_print;
-#else
-#define ahd_ovlyrxmsg1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "OVLYRXMSG1", 0x91, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_nsenable_print;
-#else
-#define ahd_nsenable_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "NSENABLE", 0x91, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dchrxmsg1_print;
-#else
-#define ahd_dchrxmsg1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DCHRXMSG1", 0x91, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_cmcrxmsg1_print;
-#else
-#define ahd_cmcrxmsg1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CMCRXMSG1", 0x91, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dchrxmsg2_print;
-#else
-#define ahd_dchrxmsg2_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DCHRXMSG2", 0x92, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_ovlyrxmsg2_print;
-#else
-#define ahd_ovlyrxmsg2_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "OVLYRXMSG2", 0x92, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_cmcrxmsg2_print;
-#else
-#define ahd_cmcrxmsg2_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CMCRXMSG2", 0x92, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_ost_print;
-#else
-#define ahd_ost_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "OST", 0x92, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dchrxmsg3_print;
-#else
-#define ahd_dchrxmsg3_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DCHRXMSG3", 0x93, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_cmcrxmsg3_print;
-#else
-#define ahd_cmcrxmsg3_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CMCRXMSG3", 0x93, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_pcixctl_print;
-#else
-#define ahd_pcixctl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "PCIXCTL", 0x93, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_ovlyrxmsg3_print;
-#else
-#define ahd_ovlyrxmsg3_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "OVLYRXMSG3", 0x93, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_ovlyseqbcnt_print;
-#else
-#define ahd_ovlyseqbcnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "OVLYSEQBCNT", 0x94, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_cmcseqbcnt_print;
-#else
-#define ahd_cmcseqbcnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CMCSEQBCNT", 0x94, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dchseqbcnt_print;
-#else
-#define ahd_dchseqbcnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DCHSEQBCNT", 0x94, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_cmcspltstat0_print;
-#else
-#define ahd_cmcspltstat0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CMCSPLTSTAT0", 0x96, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_ovlyspltstat0_print;
-#else
-#define ahd_ovlyspltstat0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "OVLYSPLTSTAT0", 0x96, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dchspltstat0_print;
-#else
-#define ahd_dchspltstat0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DCHSPLTSTAT0", 0x96, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dchspltstat1_print;
-#else
-#define ahd_dchspltstat1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DCHSPLTSTAT1", 0x97, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_cmcspltstat1_print;
-#else
-#define ahd_cmcspltstat1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CMCSPLTSTAT1", 0x97, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_ovlyspltstat1_print;
-#else
-#define ahd_ovlyspltstat1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "OVLYSPLTSTAT1", 0x97, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sgrxmsg0_print;
-#else
-#define ahd_sgrxmsg0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SGRXMSG0", 0x98, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_slvspltoutadr0_print;
-#else
-#define ahd_slvspltoutadr0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SLVSPLTOUTADR0", 0x98, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sgrxmsg1_print;
-#else
-#define ahd_sgrxmsg1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SGRXMSG1", 0x99, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_slvspltoutadr1_print;
-#else
-#define ahd_slvspltoutadr1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SLVSPLTOUTADR1", 0x99, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sgrxmsg2_print;
-#else
-#define ahd_sgrxmsg2_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SGRXMSG2", 0x9a, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_slvspltoutadr2_print;
-#else
-#define ahd_slvspltoutadr2_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SLVSPLTOUTADR2", 0x9a, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sgrxmsg3_print;
-#else
-#define ahd_sgrxmsg3_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SGRXMSG3", 0x9b, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_slvspltoutadr3_print;
-#else
-#define ahd_slvspltoutadr3_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SLVSPLTOUTADR3", 0x9b, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sgseqbcnt_print;
-#else
-#define ahd_sgseqbcnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SGSEQBCNT", 0x9c, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_slvspltoutattr0_print;
-#else
-#define ahd_slvspltoutattr0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SLVSPLTOUTATTR0", 0x9c, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_slvspltoutattr1_print;
-#else
-#define ahd_slvspltoutattr1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SLVSPLTOUTATTR1", 0x9d, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_slvspltoutattr2_print;
-#else
-#define ahd_slvspltoutattr2_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SLVSPLTOUTATTR2", 0x9e, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sgspltstat0_print;
-#else
-#define ahd_sgspltstat0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SGSPLTSTAT0", 0x9e, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sfunct_print;
-#else
-#define ahd_sfunct_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SFUNCT", 0x9f, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sgspltstat1_print;
-#else
-#define ahd_sgspltstat1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SGSPLTSTAT1", 0x9f, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_df0pcistat_print;
-#else
-#define ahd_df0pcistat_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DF0PCISTAT", 0xa0, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_reg0_print;
-#else
-#define ahd_reg0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "REG0", 0xa0, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_df1pcistat_print;
-#else
-#define ahd_df1pcistat_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DF1PCISTAT", 0xa1, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sgpcistat_print;
-#else
-#define ahd_sgpcistat_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SGPCISTAT", 0xa2, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_reg1_print;
-#else
-#define ahd_reg1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "REG1", 0xa2, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_cmcpcistat_print;
-#else
-#define ahd_cmcpcistat_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CMCPCISTAT", 0xa3, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_ovlypcistat_print;
-#else
-#define ahd_ovlypcistat_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "OVLYPCISTAT", 0xa4, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_reg_isr_print;
-#else
-#define ahd_reg_isr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "REG_ISR", 0xa4, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sg_state_print;
-#else
-#define ahd_sg_state_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SG_STATE", 0xa6, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_msipcistat_print;
-#else
-#define ahd_msipcistat_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "MSIPCISTAT", 0xa6, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_targpcistat_print;
-#else
-#define ahd_targpcistat_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "TARGPCISTAT", 0xa7, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_data_count_odd_print;
-#else
-#define ahd_data_count_odd_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DATA_COUNT_ODD", 0xa7, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scbptr_print;
-#else
-#define ahd_scbptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCBPTR", 0xa8, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_ccscbacnt_print;
-#else
-#define ahd_ccscbacnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CCSCBACNT", 0xab, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scbautoptr_print;
-#else
-#define ahd_scbautoptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCBAUTOPTR", 0xab, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_ccsgaddr_print;
-#else
-#define ahd_ccsgaddr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CCSGADDR", 0xac, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_ccscbaddr_print;
-#else
-#define ahd_ccscbaddr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CCSCBADDR", 0xac, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_ccscbadr_bk_print;
-#else
-#define ahd_ccscbadr_bk_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CCSCBADR_BK", 0xac, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_cmc_rambist_print;
-#else
-#define ahd_cmc_rambist_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CMC_RAMBIST", 0xad, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_ccsgctl_print;
-#else
-#define ahd_ccsgctl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CCSGCTL", 0xad, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_ccscbctl_print;
-#else
-#define ahd_ccscbctl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CCSCBCTL", 0xad, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_ccsgram_print;
-#else
-#define ahd_ccsgram_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CCSGRAM", 0xb0, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_flexadr_print;
-#else
-#define ahd_flexadr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "FLEXADR", 0xb0, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_ccscbram_print;
-#else
-#define ahd_ccscbram_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CCSCBRAM", 0xb0, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_flexcnt_print;
-#else
-#define ahd_flexcnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "FLEXCNT", 0xb3, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_flexdmastat_print;
-#else
-#define ahd_flexdmastat_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "FLEXDMASTAT", 0xb5, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_flexdata_print;
-#else
-#define ahd_flexdata_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "FLEXDATA", 0xb6, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_brddat_print;
-#else
-#define ahd_brddat_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "BRDDAT", 0xb8, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_brdctl_print;
-#else
-#define ahd_brdctl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "BRDCTL", 0xb9, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_seeadr_print;
-#else
-#define ahd_seeadr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SEEADR", 0xba, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_seedat_print;
-#else
-#define ahd_seedat_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SEEDAT", 0xbc, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_seectl_print;
-#else
-#define ahd_seectl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SEECTL", 0xbe, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_seestat_print;
-#else
-#define ahd_seestat_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SEESTAT", 0xbe, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scbcnt_print;
-#else
-#define ahd_scbcnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCBCNT", 0xbf, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dfwaddr_print;
-#else
-#define ahd_dfwaddr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DFWADDR", 0xc0, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dspfltrctl_print;
-#else
-#define ahd_dspfltrctl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DSPFLTRCTL", 0xc0, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dspdatactl_print;
-#else
-#define ahd_dspdatactl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DSPDATACTL", 0xc1, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dfraddr_print;
-#else
-#define ahd_dfraddr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DFRADDR", 0xc2, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dspreqctl_print;
-#else
-#define ahd_dspreqctl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DSPREQCTL", 0xc2, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dspackctl_print;
-#else
-#define ahd_dspackctl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DSPACKCTL", 0xc3, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dfdat_print;
-#else
-#define ahd_dfdat_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DFDAT", 0xc4, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dspselect_print;
-#else
-#define ahd_dspselect_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DSPSELECT", 0xc4, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_wrtbiasctl_print;
-#else
-#define ahd_wrtbiasctl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "WRTBIASCTL", 0xc5, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_rcvrbiosctl_print;
-#else
-#define ahd_rcvrbiosctl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "RCVRBIOSCTL", 0xc6, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_wrtbiascalc_print;
-#else
-#define ahd_wrtbiascalc_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "WRTBIASCALC", 0xc7, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dfptrs_print;
-#else
-#define ahd_dfptrs_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DFPTRS", 0xc8, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_rcvrbiascalc_print;
-#else
-#define ahd_rcvrbiascalc_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "RCVRBIASCALC", 0xc8, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dfbkptr_print;
-#else
-#define ahd_dfbkptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DFBKPTR", 0xc9, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_skewcalc_print;
-#else
-#define ahd_skewcalc_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SKEWCALC", 0xc9, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dfdbctl_print;
-#else
-#define ahd_dfdbctl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DFDBCTL", 0xcb, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dfscnt_print;
-#else
-#define ahd_dfscnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DFSCNT", 0xcc, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dfbcnt_print;
-#else
-#define ahd_dfbcnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DFBCNT", 0xce, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_ovlyaddr_print;
-#else
-#define ahd_ovlyaddr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "OVLYADDR", 0xd4, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_seqctl0_print;
-#else
-#define ahd_seqctl0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SEQCTL0", 0xd6, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_seqctl1_print;
-#else
-#define ahd_seqctl1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SEQCTL1", 0xd7, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_flags_print;
-#else
-#define ahd_flags_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "FLAGS", 0xd8, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_seqintctl_print;
-#else
-#define ahd_seqintctl_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SEQINTCTL", 0xd9, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_seqram_print;
-#else
-#define ahd_seqram_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SEQRAM", 0xda, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_prgmcnt_print;
-#else
-#define ahd_prgmcnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "PRGMCNT", 0xde, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_accum_print;
-#else
-#define ahd_accum_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "ACCUM", 0xe0, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sindex_print;
-#else
-#define ahd_sindex_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SINDEX", 0xe2, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dindex_print;
-#else
-#define ahd_dindex_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DINDEX", 0xe4, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_brkaddr1_print;
-#else
-#define ahd_brkaddr1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "BRKADDR1", 0xe6, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_brkaddr0_print;
-#else
-#define ahd_brkaddr0_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "BRKADDR0", 0xe6, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_allones_print;
-#else
-#define ahd_allones_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "ALLONES", 0xe8, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_allzeros_print;
-#else
-#define ahd_allzeros_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "ALLZEROS", 0xea, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_none_print;
-#else
-#define ahd_none_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "NONE", 0xea, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sindir_print;
-#else
-#define ahd_sindir_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SINDIR", 0xec, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dindir_print;
-#else
-#define ahd_dindir_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DINDIR", 0xed, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_function1_print;
-#else
-#define ahd_function1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "FUNCTION1", 0xf0, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_stack_print;
-#else
-#define ahd_stack_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "STACK", 0xf2, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_curaddr_print;
-#else
-#define ahd_curaddr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CURADDR", 0xf4, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_intvec1_addr_print;
-#else
-#define ahd_intvec1_addr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "INTVEC1_ADDR", 0xf4, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_intvec2_addr_print;
-#else
-#define ahd_intvec2_addr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "INTVEC2_ADDR", 0xf6, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lastaddr_print;
-#else
-#define ahd_lastaddr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LASTADDR", 0xf6, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_longjmp_addr_print;
-#else
-#define ahd_longjmp_addr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LONGJMP_ADDR", 0xf8, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_longjmp_scb_print;
-#else
-#define ahd_longjmp_scb_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LONGJMP_SCB", 0xfa, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_accum_save_print;
-#else
-#define ahd_accum_save_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "ACCUM_SAVE", 0xfc, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_waiting_scb_tails_print;
-#else
-#define ahd_waiting_scb_tails_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "WAITING_SCB_TAILS", 0x100, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_ahd_pci_config_base_print;
-#else
-#define ahd_ahd_pci_config_base_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "AHD_PCI_CONFIG_BASE", 0x100, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_sram_base_print;
-#else
-#define ahd_sram_base_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SRAM_BASE", 0x100, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_waiting_tid_head_print;
-#else
-#define ahd_waiting_tid_head_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "WAITING_TID_HEAD", 0x120, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_waiting_tid_tail_print;
-#else
-#define ahd_waiting_tid_tail_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "WAITING_TID_TAIL", 0x122, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_next_queued_scb_addr_print;
-#else
-#define ahd_next_queued_scb_addr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "NEXT_QUEUED_SCB_ADDR", 0x124, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_complete_scb_head_print;
-#else
-#define ahd_complete_scb_head_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "COMPLETE_SCB_HEAD", 0x128, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_complete_scb_dmainprog_head_print;
-#else
-#define ahd_complete_scb_dmainprog_head_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "COMPLETE_SCB_DMAINPROG_HEAD", 0x12a, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_complete_dma_scb_head_print;
-#else
-#define ahd_complete_dma_scb_head_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "COMPLETE_DMA_SCB_HEAD", 0x12c, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_qfreeze_count_print;
-#else
-#define ahd_qfreeze_count_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "QFREEZE_COUNT", 0x12e, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_saved_mode_print;
-#else
-#define ahd_saved_mode_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SAVED_MODE", 0x130, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_msg_out_print;
-#else
-#define ahd_msg_out_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "MSG_OUT", 0x131, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_dmaparams_print;
-#else
-#define ahd_dmaparams_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "DMAPARAMS", 0x132, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_seq_flags_print;
-#else
-#define ahd_seq_flags_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SEQ_FLAGS", 0x133, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_saved_scsiid_print;
-#else
-#define ahd_saved_scsiid_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SAVED_SCSIID", 0x134, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_saved_lun_print;
-#else
-#define ahd_saved_lun_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SAVED_LUN", 0x135, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_lastphase_print;
-#else
-#define ahd_lastphase_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LASTPHASE", 0x136, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_qoutfifo_entry_valid_tag_print;
-#else
-#define ahd_qoutfifo_entry_valid_tag_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "QOUTFIFO_ENTRY_VALID_TAG", 0x137, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_shared_data_addr_print;
-#else
-#define ahd_shared_data_addr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SHARED_DATA_ADDR", 0x138, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_qoutfifo_next_addr_print;
-#else
-#define ahd_qoutfifo_next_addr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "QOUTFIFO_NEXT_ADDR", 0x13c, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_kernel_tqinpos_print;
-#else
-#define ahd_kernel_tqinpos_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "KERNEL_TQINPOS", 0x140, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_tqinpos_print;
-#else
-#define ahd_tqinpos_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "TQINPOS", 0x141, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_arg_1_print;
-#else
-#define ahd_arg_1_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "ARG_1", 0x142, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_arg_2_print;
-#else
-#define ahd_arg_2_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "ARG_2", 0x143, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_last_msg_print;
-#else
-#define ahd_last_msg_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LAST_MSG", 0x144, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scsiseq_template_print;
-#else
-#define ahd_scsiseq_template_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCSISEQ_TEMPLATE", 0x145, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_initiator_tag_print;
-#else
-#define ahd_initiator_tag_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "INITIATOR_TAG", 0x146, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_seq_flags2_print;
-#else
-#define ahd_seq_flags2_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SEQ_FLAGS2", 0x147, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_allocfifo_scbptr_print;
-#else
-#define ahd_allocfifo_scbptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "ALLOCFIFO_SCBPTR", 0x148, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_int_coalessing_timer_print;
-#else
-#define ahd_int_coalessing_timer_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "INT_COALESSING_TIMER", 0x14a, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_int_coalessing_maxcmds_print;
-#else
-#define ahd_int_coalessing_maxcmds_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "INT_COALESSING_MAXCMDS", 0x14c, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_int_coalessing_mincmds_print;
-#else
-#define ahd_int_coalessing_mincmds_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "INT_COALESSING_MINCMDS", 0x14d, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_cmds_pending_print;
-#else
-#define ahd_cmds_pending_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CMDS_PENDING", 0x14e, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_int_coalessing_cmdcount_print;
-#else
-#define ahd_int_coalessing_cmdcount_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "INT_COALESSING_CMDCOUNT", 0x150, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_local_hs_mailbox_print;
-#else
-#define ahd_local_hs_mailbox_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LOCAL_HS_MAILBOX", 0x151, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_cmdsize_table_print;
-#else
-#define ahd_cmdsize_table_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "CMDSIZE_TABLE", 0x152, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_base_print;
-#else
-#define ahd_scb_base_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_BASE", 0x180, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_residual_datacnt_print;
-#else
-#define ahd_scb_residual_datacnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_RESIDUAL_DATACNT", 0x180, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_residual_sgptr_print;
-#else
-#define ahd_scb_residual_sgptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_RESIDUAL_SGPTR", 0x184, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_scsi_status_print;
-#else
-#define ahd_scb_scsi_status_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_SCSI_STATUS", 0x188, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_target_phases_print;
-#else
-#define ahd_scb_target_phases_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_TARGET_PHASES", 0x189, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_target_data_dir_print;
-#else
-#define ahd_scb_target_data_dir_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_TARGET_DATA_DIR", 0x18a, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_target_itag_print;
-#else
-#define ahd_scb_target_itag_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_TARGET_ITAG", 0x18b, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_sense_busaddr_print;
-#else
-#define ahd_scb_sense_busaddr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_SENSE_BUSADDR", 0x18c, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_tag_print;
-#else
-#define ahd_scb_tag_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_TAG", 0x190, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_cdb_len_print;
-#else
-#define ahd_scb_cdb_len_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_CDB_LEN", 0x192, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_task_management_print;
-#else
-#define ahd_scb_task_management_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_TASK_MANAGEMENT", 0x193, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_next_print;
-#else
-#define ahd_scb_next_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_NEXT", 0x194, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_next2_print;
-#else
-#define ahd_scb_next2_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_NEXT2", 0x196, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_dataptr_print;
-#else
-#define ahd_scb_dataptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_DATAPTR", 0x198, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_datacnt_print;
-#else
-#define ahd_scb_datacnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_DATACNT", 0x1a0, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_sgptr_print;
-#else
-#define ahd_scb_sgptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_SGPTR", 0x1a4, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_control_print;
-#else
-#define ahd_scb_control_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_CONTROL", 0x1a8, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_scsiid_print;
-#else
-#define ahd_scb_scsiid_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_SCSIID", 0x1a9, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_lun_print;
-#else
-#define ahd_scb_lun_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_LUN", 0x1aa, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_task_attribute_print;
-#else
-#define ahd_scb_task_attribute_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_TASK_ATTRIBUTE", 0x1ab, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_busaddr_print;
-#else
-#define ahd_scb_busaddr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_BUSADDR", 0x1ac, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_spare_print;
-#else
-#define ahd_scb_spare_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_SPARE", 0x1b0, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_disconnected_lists_print;
-#else
-#define ahd_scb_disconnected_lists_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_DISCONNECTED_LISTS", 0x1b8, regvalue, cur_col, wrap)
-#endif
-
-
-#define	MODE_PTR        		0x00
-#define		DST_MODE        	0x70
-#define		SRC_MODE        	0x07
-
-#define	INTSTAT         		0x01
-#define		INT_PEND        	0xff
-#define		HWERRINT        	0x80
-#define		BRKADRINT       	0x40
-#define		SWTMINT         	0x20
-#define		PCIINT          	0x10
-#define		SCSIINT         	0x08
-#define		SEQINT          	0x04
-#define		CMDCMPLT        	0x02
-#define		SPLTINT         	0x01
-
-#define	SEQINTCODE      		0x02
-#define		SAW_HWERR       	0x19
-#define		TRACEPOINT3     	0x18
-#define		TRACEPOINT2     	0x17
-#define		TRACEPOINT1     	0x16
-#define		TRACEPOINT0     	0x15
-#define		TASKMGMT_CMD_CMPLT_OKAY	0x14
-#define		TASKMGMT_FUNC_COMPLETE	0x13
-#define		ENTERING_NONPACK	0x12
-#define		CFG4OVERRUN     	0x11
-#define		STATUS_OVERRUN  	0x10
-#define		CFG4ISTAT_INTR  	0x0f
-#define		INVALID_SEQINT  	0x0e
-#define		ILLEGAL_PHASE   	0x0d
-#define		DUMP_CARD_STATE 	0x0c
-#define		MISSED_BUSFREE  	0x0b
-#define		MKMSG_FAILED    	0x0a
-#define		DATA_OVERRUN    	0x09
-#define		BAD_STATUS      	0x08
-#define		HOST_MSG_LOOP   	0x07
-#define		PDATA_REINIT    	0x06
-#define		IGN_WIDE_RES    	0x05
-#define		NO_MATCH        	0x04
-#define		PROTO_VIOLATION 	0x03
-#define		SEND_REJECT     	0x02
-#define		BAD_PHASE       	0x01
-#define		NO_SEQINT       	0x00
-
-#define	CLRINT          		0x03
-#define		CLRHWERRINT     	0x80
-#define		CLRBRKADRINT    	0x40
-#define		CLRSWTMINT      	0x20
-#define		CLRPCIINT       	0x10
-#define		CLRSCSIINT      	0x08
-#define		CLRSEQINT       	0x04
-#define		CLRCMDINT       	0x02
-#define		CLRSPLTINT      	0x01
-
-#define	ERROR           		0x04
-#define		CIOPARERR       	0x80
-#define		CIOACCESFAIL    	0x40
-#define		MPARERR         	0x20
-#define		DPARERR         	0x10
-#define		SQPARERR        	0x08
-#define		ILLOPCODE       	0x04
-#define		DSCTMOUT        	0x02
-
-#define	CLRERR          		0x04
-#define		CLRCIOPARERR    	0x80
-#define		CLRCIOACCESFAIL 	0x40
-#define		CLRMPARERR      	0x20
-#define		CLRDPARERR      	0x10
-#define		CLRSQPARERR     	0x08
-#define		CLRILLOPCODE    	0x04
-#define		CLRDSCTMOUT     	0x02
-
-#define	HCNTRL          		0x05
-#define		SEQ_RESET       	0x80
-#define		POWRDN          	0x40
-#define		SWINT           	0x10
-#define		SWTIMER_START_B 	0x08
-#define		PAUSE           	0x04
-#define		INTEN           	0x02
-#define		CHIPRST         	0x01
-#define		CHIPRSTACK      	0x01
-
-#define	HNSCB_QOFF      		0x06
-
-#define	HESCB_QOFF      		0x08
-
-#define	HS_MAILBOX      		0x0b
-#define		HOST_TQINPOS    	0x80
-#define		ENINT_COALESS   	0x40
-
-#define	CLRSEQINTSTAT   		0x0c
-#define		CLRSEQ_SWTMRTO  	0x10
-#define		CLRSEQ_SEQINT   	0x08
-#define		CLRSEQ_SCSIINT  	0x04
-#define		CLRSEQ_PCIINT   	0x02
-#define		CLRSEQ_SPLTINT  	0x01
-
-#define	SEQINTSTAT      		0x0c
-#define		SEQ_SWTMRTO     	0x10
-#define		SEQ_SEQINT      	0x08
-#define		SEQ_SCSIINT     	0x04
-#define		SEQ_PCIINT      	0x02
-#define		SEQ_SPLTINT     	0x01
-
-#define	SWTIMER         		0x0e
-
-#define	SNSCB_QOFF      		0x10
-
-#define	SESCB_QOFF      		0x12
-
-#define	SDSCB_QOFF      		0x14
-
-#define	QOFF_CTLSTA     		0x16
-#define		EMPTY_SCB_AVAIL 	0x80
-#define		NEW_SCB_AVAIL   	0x40
-#define		SDSCB_ROLLOVR   	0x20
-#define		HS_MAILBOX_ACT  	0x10
-#define		SCB_QSIZE       	0x0f
-#define		SCB_QSIZE_16384 	0x0c
-#define		SCB_QSIZE_8192  	0x0b
-#define		SCB_QSIZE_4096  	0x0a
-#define		SCB_QSIZE_2048  	0x09
-#define		SCB_QSIZE_1024  	0x08
-#define		SCB_QSIZE_512   	0x07
-#define		SCB_QSIZE_256   	0x06
-#define		SCB_QSIZE_128   	0x05
-#define		SCB_QSIZE_64    	0x04
-#define		SCB_QSIZE_32    	0x03
-#define		SCB_QSIZE_16    	0x02
-#define		SCB_QSIZE_8     	0x01
-#define		SCB_QSIZE_4     	0x00
-
-#define	INTCTL          		0x18
-#define		SWTMINTMASK     	0x80
-#define		SWTMINTEN       	0x40
-#define		SWTIMER_START   	0x20
-#define		AUTOCLRCMDINT   	0x10
-#define		PCIINTEN        	0x08
-#define		SCSIINTEN       	0x04
-#define		SEQINTEN        	0x02
-#define		SPLTINTEN       	0x01
-
-#define	DFCNTRL         		0x19
-#define		SCSIENWRDIS     	0x40
-#define		SCSIENACK       	0x20
-#define		DIRECTIONACK    	0x04
-#define		FIFOFLUSHACK    	0x02
-#define		DIRECTIONEN     	0x01
-
-#define	DSCOMMAND0      		0x19
-#define		CACHETHEN       	0x80
-#define		DPARCKEN        	0x40
-#define		MPARCKEN        	0x20
-#define		EXTREQLCK       	0x10
-#define		DISABLE_TWATE   	0x02
-#define		CIOPARCKEN      	0x01
-
-#define	DFSTATUS        		0x1a
-#define		PRELOAD_AVAIL   	0x80
-#define		PKT_PRELOAD_AVAIL	0x40
-#define		MREQPEND        	0x10
-#define		HDONE           	0x08
-#define		DFTHRESH        	0x04
-#define		FIFOFULL        	0x02
-#define		FIFOEMP         	0x01
-
-#define	SG_CACHE_SHADOW 		0x1b
-#define		ODD_SEG         	0x04
-#define		LAST_SEG        	0x02
-#define		LAST_SEG_DONE   	0x01
-
-#define	ARBCTL          		0x1b
-#define		RESET_HARB      	0x80
-#define		RETRY_SWEN      	0x08
-#define		USE_TIME        	0x07
-
-#define	SG_CACHE_PRE    		0x1b
-
-#define	LQIN            		0x20
-
-#define	TYPEPTR         		0x20
-
-#define	TAGPTR          		0x21
-
-#define	LUNPTR          		0x22
-
-#define	DATALENPTR      		0x23
-
-#define	STATLENPTR      		0x24
-
-#define	CMDLENPTR       		0x25
-
-#define	ATTRPTR         		0x26
-
-#define	FLAGPTR         		0x27
-
-#define	CMDPTR          		0x28
-
-#define	QNEXTPTR        		0x29
-
-#define	IDPTR           		0x2a
-
-#define	ABRTBYTEPTR     		0x2b
-
-#define	ABRTBITPTR      		0x2c
-
-#define	MAXCMDBYTES     		0x2d
-
-#define	MAXCMD2RCV      		0x2e
-
-#define	SHORTTHRESH     		0x2f
-
-#define	LUNLEN          		0x30
-
-#define	CDBLIMIT        		0x31
-
-#define	MAXCMD          		0x32
-
-#define	MAXCMDCNT       		0x33
-
-#define	LQRSVD01        		0x34
-
-#define	LQRSVD16        		0x35
-
-#define	LQRSVD17        		0x36
-
-#define	CMDRSVD0        		0x37
-
-#define	LQCTL0          		0x38
-#define		LQITARGCLT      	0xc0
-#define		LQIINITGCLT     	0x30
-#define		LQ0TARGCLT      	0x0c
-#define		LQ0INITGCLT     	0x03
-
-#define	LQCTL1          		0x38
-#define		PCI2PCI         	0x04
-#define		SINGLECMD       	0x02
-#define		ABORTPENDING    	0x01
-
-#define	SCSBIST0        		0x39
-#define		GSBISTERR       	0x40
-#define		GSBISTDONE      	0x20
-#define		GSBISTRUN       	0x10
-#define		OSBISTERR       	0x04
-#define		OSBISTDONE      	0x02
-#define		OSBISTRUN       	0x01
-
-#define	LQCTL2          		0x39
-#define		LQIRETRY        	0x80
-#define		LQICONTINUE     	0x40
-#define		LQITOIDLE       	0x20
-#define		LQIPAUSE        	0x10
-#define		LQORETRY        	0x08
-#define		LQOCONTINUE     	0x04
-#define		LQOTOIDLE       	0x02
-#define		LQOPAUSE        	0x01
-
-#define	SCSBIST1        		0x3a
-#define		NTBISTERR       	0x04
-#define		NTBISTDONE      	0x02
-#define		NTBISTRUN       	0x01
-
-#define	SCSISEQ0        		0x3a
-#define		TEMODEO         	0x80
-#define		ENSELO          	0x40
-#define		ENARBO          	0x20
-#define		FORCEBUSFREE    	0x10
-#define		SCSIRSTO        	0x01
-
-#define	SCSISEQ1        		0x3b
-
-#define	SXFRCTL0        		0x3c
-#define		DFON            	0x80
-#define		DFPEXP          	0x40
-#define		BIOSCANCELEN    	0x10
-#define		SPIOEN          	0x08
-
-#define	BUSINITID       		0x3c
-
-#define	DLCOUNT         		0x3c
-
-#define	SXFRCTL1        		0x3d
-#define		BITBUCKET       	0x80
-#define		ENSACHK         	0x40
-#define		ENSPCHK         	0x20
-#define		STIMESEL        	0x18
-#define		ENSTIMER        	0x04
-#define		ACTNEGEN        	0x02
-#define		STPWEN          	0x01
-
-#define	BUSTARGID       		0x3e
-
-#define	SXFRCTL2        		0x3e
-#define		AUTORSTDIS      	0x10
-#define		CMDDMAEN        	0x08
-#define		ASU             	0x07
-
-#define	DFFSTAT         		0x3f
-#define		CURRFIFO        	0x03
-#define		FIFO1FREE       	0x20
-#define		FIFO0FREE       	0x10
-#define		CURRFIFO_NONE   	0x03
-#define		CURRFIFO_1      	0x01
-#define		CURRFIFO_0      	0x00
-
-#define	SCSISIGO        		0x40
-#define		CDO             	0x80
-#define		IOO             	0x40
-#define		MSGO            	0x20
-#define		ATNO            	0x10
-#define		SELO            	0x08
-#define		BSYO            	0x04
-#define		REQO            	0x02
-#define		ACKO            	0x01
-
-#define	MULTARGID       		0x40
-
-#define	SCSISIGI        		0x41
-#define		ATNI            	0x10
-#define		SELI            	0x08
-#define		BSYI            	0x04
-#define		REQI            	0x02
-#define		ACKI            	0x01
-
-#define	SCSIPHASE       		0x42
-#define		STATUS_PHASE    	0x20
-#define		COMMAND_PHASE   	0x10
-#define		MSG_IN_PHASE    	0x08
-#define		MSG_OUT_PHASE   	0x04
-#define		DATA_PHASE_MASK 	0x03
-#define		DATA_IN_PHASE   	0x02
-#define		DATA_OUT_PHASE  	0x01
-
-#define	SCSIDAT0_IMG    		0x43
-
-#define	SCSIDAT         		0x44
-
-#define	SCSIBUS         		0x46
-
-#define	TARGIDIN        		0x48
-#define		CLKOUT          	0x80
-#define		TARGID          	0x0f
-
-#define	SELID           		0x49
-#define		SELID_MASK      	0xf0
-#define		ONEBIT          	0x08
-
-#define	SBLKCTL         		0x4a
-#define		DIAGLEDEN       	0x80
-#define		DIAGLEDON       	0x40
-#define		ENAB40          	0x08
-#define		ENAB20          	0x04
-#define		SELWIDE         	0x02
-
-#define	OPTIONMODE      		0x4a
-#define		OPTIONMODE_DEFAULTS	0x02
-#define		BIOSCANCTL      	0x80
-#define		AUTOACKEN       	0x40
-#define		BIASCANCTL      	0x20
-#define		BUSFREEREV      	0x10
-#define		ENDGFORMCHK     	0x04
-#define		AUTO_MSGOUT_DE  	0x02
-
-#define	SSTAT0          		0x4b
-#define		TARGET          	0x80
-#define		SELDO           	0x40
-#define		SELDI           	0x20
-#define		SELINGO         	0x10
-#define		IOERR           	0x08
-#define		OVERRUN         	0x04
-#define		SPIORDY         	0x02
-#define		ARBDO           	0x01
-
-#define	CLRSINT0        		0x4b
-#define		CLRSELDO        	0x40
-#define		CLRSELDI        	0x20
-#define		CLRSELINGO      	0x10
-#define		CLRIOERR        	0x08
-#define		CLROVERRUN      	0x04
-#define		CLRSPIORDY      	0x02
-#define		CLRARBDO        	0x01
-
-#define	SIMODE0         		0x4b
-#define		ENSELDO         	0x40
-#define		ENSELDI         	0x20
-#define		ENSELINGO       	0x10
-#define		ENIOERR         	0x08
-#define		ENOVERRUN       	0x04
-#define		ENSPIORDY       	0x02
-#define		ENARBDO         	0x01
-
-#define	CLRSINT1        		0x4c
-#define		CLRSELTIMEO     	0x80
-#define		CLRATNO         	0x40
-#define		CLRSCSIRSTI     	0x20
-#define		CLRBUSFREE      	0x08
-#define		CLRSCSIPERR     	0x04
-#define		CLRSTRB2FAST    	0x02
-#define		CLRREQINIT      	0x01
-
-#define	SSTAT1          		0x4c
-#define		SELTO           	0x80
-#define		ATNTARG         	0x40
-#define		SCSIRSTI        	0x20
-#define		PHASEMIS        	0x10
-#define		BUSFREE         	0x08
-#define		SCSIPERR        	0x04
-#define		STRB2FAST       	0x02
-#define		REQINIT         	0x01
-
-#define	SSTAT2          		0x4d
-#define		BUSFREETIME     	0xc0
-#define		NONPACKREQ      	0x20
-#define		EXP_ACTIVE      	0x10
-#define		BSYX            	0x08
-#define		WIDE_RES        	0x04
-#define		SDONE           	0x02
-#define		DMADONE         	0x01
-#define		BUSFREE_DFF1    	0xc0
-#define		BUSFREE_DFF0    	0x80
-#define		BUSFREE_LQO     	0x40
-
-#define	CLRSINT2        		0x4d
-#define		CLRNONPACKREQ   	0x20
-#define		CLRWIDE_RES     	0x04
-#define		CLRSDONE        	0x02
-#define		CLRDMADONE      	0x01
-
-#define	SIMODE2         		0x4d
-#define		ENWIDE_RES      	0x04
-#define		ENSDONE         	0x02
-#define		ENDMADONE       	0x01
-
-#define	PERRDIAG        		0x4e
-#define		HIZERO          	0x80
-#define		HIPERR          	0x40
-#define		PREVPHASE       	0x20
-#define		PARITYERR       	0x10
-#define		AIPERR          	0x08
-#define		CRCERR          	0x04
-#define		DGFORMERR       	0x02
-#define		DTERR           	0x01
-
-#define	LQISTATE        		0x4e
-
-#define	SOFFCNT         		0x4f
-
-#define	LQOSTATE        		0x4f
-
-#define	LQISTAT0        		0x50
-#define		LQIATNQAS       	0x20
-#define		LQICRCT1        	0x10
-#define		LQICRCT2        	0x08
-#define		LQIBADLQT       	0x04
-#define		LQIATNLQ        	0x02
-#define		LQIATNCMD       	0x01
-
-#define	CLRLQIINT0      		0x50
-#define		CLRLQIATNQAS    	0x20
-#define		CLRLQICRCT1     	0x10
-#define		CLRLQICRCT2     	0x08
-#define		CLRLQIBADLQT    	0x04
-#define		CLRLQIATNLQ     	0x02
-#define		CLRLQIATNCMD    	0x01
-
-#define	LQIMODE0        		0x50
-#define		ENLQIATNQASK    	0x20
-#define		ENLQICRCT1      	0x10
-#define		ENLQICRCT2      	0x08
-#define		ENLQIBADLQT     	0x04
-#define		ENLQIATNLQ      	0x02
-#define		ENLQIATNCMD     	0x01
-
-#define	LQIMODE1        		0x51
-#define		ENLQIPHASE_LQ   	0x80
-#define		ENLQIPHASE_NLQ  	0x40
-#define		ENLIQABORT      	0x20
-#define		ENLQICRCI_LQ    	0x10
-#define		ENLQICRCI_NLQ   	0x08
-#define		ENLQIBADLQI     	0x04
-#define		ENLQIOVERI_LQ   	0x02
-#define		ENLQIOVERI_NLQ  	0x01
-
-#define	LQISTAT1        		0x51
-#define		LQIPHASE_LQ     	0x80
-#define		LQIPHASE_NLQ    	0x40
-#define		LQIABORT        	0x20
-#define		LQICRCI_LQ      	0x10
-#define		LQICRCI_NLQ     	0x08
-#define		LQIBADLQI       	0x04
-#define		LQIOVERI_LQ     	0x02
-#define		LQIOVERI_NLQ    	0x01
-
-#define	CLRLQIINT1      		0x51
-#define		CLRLQIPHASE_LQ  	0x80
-#define		CLRLQIPHASE_NLQ 	0x40
-#define		CLRLIQABORT     	0x20
-#define		CLRLQICRCI_LQ   	0x10
-#define		CLRLQICRCI_NLQ  	0x08
-#define		CLRLQIBADLQI    	0x04
-#define		CLRLQIOVERI_LQ  	0x02
-#define		CLRLQIOVERI_NLQ 	0x01
-
-#define	LQISTAT2        		0x52
-#define		PACKETIZED      	0x80
-#define		LQIPHASE_OUTPKT 	0x40
-#define		LQIWORKONLQ     	0x20
-#define		LQIWAITFIFO     	0x10
-#define		LQISTOPPKT      	0x08
-#define		LQISTOPLQ       	0x04
-#define		LQISTOPCMD      	0x02
-#define		LQIGSAVAIL      	0x01
-
-#define	SSTAT3          		0x53
-#define		NTRAMPERR       	0x02
-#define		OSRAMPERR       	0x01
-
-#define	SIMODE3         		0x53
-#define		ENNTRAMPERR     	0x02
-#define		ENOSRAMPERR     	0x01
-
-#define	CLRSINT3        		0x53
-#define		CLRNTRAMPERR    	0x02
-#define		CLROSRAMPERR    	0x01
-
-#define	LQOMODE0        		0x54
-#define		ENLQOTARGSCBPERR	0x10
-#define		ENLQOSTOPT2     	0x08
-#define		ENLQOATNLQ      	0x04
-#define		ENLQOATNPKT     	0x02
-#define		ENLQOTCRC       	0x01
-
-#define	LQOSTAT0        		0x54
-#define		LQOTARGSCBPERR  	0x10
-#define		LQOSTOPT2       	0x08
-#define		LQOATNLQ        	0x04
-#define		LQOATNPKT       	0x02
-#define		LQOTCRC         	0x01
-
-#define	CLRLQOINT0      		0x54
-#define		CLRLQOTARGSCBPERR	0x10
-#define		CLRLQOSTOPT2    	0x08
-#define		CLRLQOATNLQ     	0x04
-#define		CLRLQOATNPKT    	0x02
-#define		CLRLQOTCRC      	0x01
-
-#define	LQOSTAT1        		0x55
-#define		LQOINITSCBPERR  	0x10
-#define		LQOSTOPI2       	0x08
-#define		LQOBADQAS       	0x04
-#define		LQOBUSFREE      	0x02
-#define		LQOPHACHGINPKT  	0x01
-
-#define	CLRLQOINT1      		0x55
-#define		CLRLQOINITSCBPERR	0x10
-#define		CLRLQOSTOPI2    	0x08
-#define		CLRLQOBADQAS    	0x04
-#define		CLRLQOBUSFREE   	0x02
-#define		CLRLQOPHACHGINPKT	0x01
-
-#define	LQOMODE1        		0x55
-#define		ENLQOINITSCBPERR	0x10
-#define		ENLQOSTOPI2     	0x08
-#define		ENLQOBADQAS     	0x04
-#define		ENLQOBUSFREE    	0x02
-#define		ENLQOPHACHGINPKT	0x01
-
-#define	LQOSTAT2        		0x56
-#define		LQOPKT          	0xe0
-#define		LQOWAITFIFO     	0x10
-#define		LQOPHACHGOUTPKT 	0x02
-#define		LQOSTOP0        	0x01
-
-#define	OS_SPACE_CNT    		0x56
-
-#define	SIMODE1         		0x57
-#define		ENSELTIMO       	0x80
-#define		ENATNTARG       	0x40
-#define		ENSCSIRST       	0x20
-#define		ENPHASEMIS      	0x10
-#define		ENBUSFREE       	0x08
-#define		ENSCSIPERR      	0x04
-#define		ENSTRB2FAST     	0x02
-#define		ENREQINIT       	0x01
-
-#define	GSFIFO          		0x58
-
-#define	DFFSXFRCTL      		0x5a
-#define		DFFBITBUCKET    	0x08
-#define		CLRSHCNT        	0x04
-#define		CLRCHN          	0x02
-#define		RSTCHN          	0x01
-
-#define	LQOSCSCTL       		0x5a
-#define		LQOH2A_VERSION  	0x80
-#define		LQONOCHKOVER    	0x01
-
-#define	NEXTSCB         		0x5a
-
-#define	CLRSEQINTSRC    		0x5b
-#define		CLRCTXTDONE     	0x40
-#define		CLRSAVEPTRS     	0x20
-#define		CLRCFG4DATA     	0x10
-#define		CLRCFG4ISTAT    	0x08
-#define		CLRCFG4TSTAT    	0x04
-#define		CLRCFG4ICMD     	0x02
-#define		CLRCFG4TCMD     	0x01
-
-#define	SEQINTSRC       		0x5b
-#define		CTXTDONE        	0x40
-#define		SAVEPTRS        	0x20
-#define		CFG4DATA        	0x10
-#define		CFG4ISTAT       	0x08
-#define		CFG4TSTAT       	0x04
-#define		CFG4ICMD        	0x02
-#define		CFG4TCMD        	0x01
-
-#define	CURRSCB         		0x5c
-
-#define	SEQIMODE        		0x5c
-#define		ENCTXTDONE      	0x40
-#define		ENSAVEPTRS      	0x20
-#define		ENCFG4DATA      	0x10
-#define		ENCFG4ISTAT     	0x08
-#define		ENCFG4TSTAT     	0x04
-#define		ENCFG4ICMD      	0x02
-#define		ENCFG4TCMD      	0x01
-
-#define	MDFFSTAT        		0x5d
-#define		SHCNTNEGATIVE   	0x40
-#define		SHCNTMINUS1     	0x20
-#define		LASTSDONE       	0x10
-#define		SHVALID         	0x08
-#define		DLZERO          	0x04
-#define		DATAINFIFO      	0x02
-#define		FIFOFREE        	0x01
-
-#define	CRCCONTROL      		0x5d
-#define		CRCVALCHKEN     	0x40
-
-#define	DFFTAG          		0x5e
-
-#define	LASTSCB         		0x5e
-
-#define	SCSITEST        		0x5e
-#define		CNTRTEST        	0x08
-#define		SEL_TXPLL_DEBUG 	0x04
-
-#define	IOPDNCTL        		0x5f
-#define		DISABLE_OE      	0x80
-#define		PDN_IDIST       	0x04
-#define		PDN_DIFFSENSE   	0x01
-
-#define	SHADDR          		0x60
-
-#define	NEGOADDR        		0x60
-
-#define	DGRPCRCI        		0x60
-
-#define	NEGPERIOD       		0x61
-
-#define	PACKCRCI        		0x62
-
-#define	NEGOFFSET       		0x62
-
-#define	NEGPPROPTS      		0x63
-#define		PPROPT_PACE     	0x08
-#define		PPROPT_QAS      	0x04
-#define		PPROPT_DT       	0x02
-#define		PPROPT_IUT      	0x01
-
-#define	NEGCONOPTS      		0x64
-#define		ENSNAPSHOT      	0x40
-#define		RTI_WRTDIS      	0x20
-#define		RTI_OVRDTRN     	0x10
-#define		ENSLOWCRC       	0x08
-#define		ENAUTOATNI      	0x04
-#define		ENAUTOATNO      	0x02
-#define		WIDEXFER        	0x01
-
-#define	ANNEXCOL        		0x65
-
-#define	SCSCHKN         		0x66
-#define		STSELSKIDDIS    	0x40
-#define		CURRFIFODEF     	0x20
-#define		WIDERESEN       	0x10
-#define		SDONEMSKDIS     	0x08
-#define		DFFACTCLR       	0x04
-#define		SHVALIDSTDIS    	0x02
-#define		LSTSGCLRDIS     	0x01
-
-#define	ANNEXDAT        		0x66
-
-#define	IOWNID          		0x67
-
-#define	PLL960CTL0      		0x68
-
-#define	SHCNT           		0x68
-
-#define	TOWNID          		0x69
-
-#define	PLL960CTL1      		0x69
-
-#define	PLL960CNT0      		0x6a
-
-#define	XSIG            		0x6a
-
-#define	SELOID          		0x6b
-
-#define	PLL400CTL0      		0x6c
-#define		PLL_VCOSEL      	0x80
-#define		PLL_PWDN        	0x40
-#define		PLL_NS          	0x30
-#define		PLL_ENLUD       	0x08
-#define		PLL_ENLPF       	0x04
-#define		PLL_DLPF        	0x02
-#define		PLL_ENFBM       	0x01
-
-#define	FAIRNESS        		0x6c
-
-#define	PLL400CTL1      		0x6d
-#define		PLL_CNTEN       	0x80
-#define		PLL_CNTCLR      	0x40
-#define		PLL_RST         	0x01
-
-#define	PLL400CNT0      		0x6e
-
-#define	UNFAIRNESS      		0x6e
-
-#define	HADDR           		0x70
-
-#define	PLLDELAY        		0x70
-#define		SPLIT_DROP_REQ  	0x80
-
-#define	HODMAADR        		0x70
-
-#define	HODMACNT        		0x78
-
-#define	HCNT            		0x78
-
-#define	HODMAEN         		0x7a
-
-#define	SGHADDR         		0x7c
-
-#define	SCBHADDR        		0x7c
-
-#define	SGHCNT          		0x84
-
-#define	SCBHCNT         		0x84
-
-#define	DFF_THRSH       		0x88
-#define		WR_DFTHRSH      	0x70
-#define		RD_DFTHRSH      	0x07
-#define		WR_DFTHRSH_MAX  	0x70
-#define		WR_DFTHRSH_90   	0x60
-#define		WR_DFTHRSH_85   	0x50
-#define		WR_DFTHRSH_75   	0x40
-#define		WR_DFTHRSH_63   	0x30
-#define		WR_DFTHRSH_50   	0x20
-#define		WR_DFTHRSH_25   	0x10
-#define		RD_DFTHRSH_MAX  	0x07
-#define		RD_DFTHRSH_90   	0x06
-#define		RD_DFTHRSH_85   	0x05
-#define		RD_DFTHRSH_75   	0x04
-#define		RD_DFTHRSH_63   	0x03
-#define		RD_DFTHRSH_50   	0x02
-#define		RD_DFTHRSH_25   	0x01
-#define		WR_DFTHRSH_MIN  	0x00
-#define		RD_DFTHRSH_MIN  	0x00
-
-#define	ROMADDR         		0x8a
-
-#define	ROMCNTRL        		0x8d
-#define		ROMOP           	0xe0
-#define		ROMSPD          	0x18
-#define		REPEAT          	0x02
-#define		RDY             	0x01
-
-#define	ROMDATA         		0x8e
-
-#define	CMCRXMSG0       		0x90
-
-#define	ROENABLE        		0x90
-#define		MSIROEN         	0x20
-#define		OVLYROEN        	0x10
-#define		CMCROEN         	0x08
-#define		SGROEN          	0x04
-#define		DCH1ROEN        	0x02
-#define		DCH0ROEN        	0x01
-
-#define	OVLYRXMSG0      		0x90
-
-#define	DCHRXMSG0       		0x90
-
-#define	OVLYRXMSG1      		0x91
-
-#define	NSENABLE        		0x91
-#define		MSINSEN         	0x20
-#define		OVLYNSEN        	0x10
-#define		CMCNSEN         	0x08
-#define		SGNSEN          	0x04
-#define		DCH1NSEN        	0x02
-#define		DCH0NSEN        	0x01
-
-#define	DCHRXMSG1       		0x91
-
-#define	CMCRXMSG1       		0x91
-
-#define	DCHRXMSG2       		0x92
-
-#define	OVLYRXMSG2      		0x92
-
-#define	CMCRXMSG2       		0x92
-
-#define	OST             		0x92
-
-#define	DCHRXMSG3       		0x93
-
-#define	CMCRXMSG3       		0x93
-
-#define	PCIXCTL         		0x93
-#define		SERRPULSE       	0x80
-#define		UNEXPSCIEN      	0x20
-#define		SPLTSMADIS      	0x10
-#define		SPLTSTADIS      	0x08
-#define		SRSPDPEEN       	0x04
-#define		TSCSERREN       	0x02
-#define		CMPABCDIS       	0x01
-
-#define	OVLYRXMSG3      		0x93
-
-#define	OVLYSEQBCNT     		0x94
-
-#define	CMCSEQBCNT      		0x94
-
-#define	DCHSEQBCNT      		0x94
-
-#define	CMCSPLTSTAT0    		0x96
-
-#define	OVLYSPLTSTAT0   		0x96
-
-#define	DCHSPLTSTAT0    		0x96
-
-#define	DCHSPLTSTAT1    		0x97
-
-#define	CMCSPLTSTAT1    		0x97
-
-#define	OVLYSPLTSTAT1   		0x97
-
-#define	SGRXMSG0        		0x98
-#define		CDNUM           	0xf8
-#define		CFNUM           	0x07
-
-#define	SLVSPLTOUTADR0  		0x98
-#define		LOWER_ADDR      	0x7f
-
-#define	SGRXMSG1        		0x99
-#define		CBNUM           	0xff
-
-#define	SLVSPLTOUTADR1  		0x99
-#define		REQ_DNUM        	0xf8
-#define		REQ_FNUM        	0x07
-
-#define	SGRXMSG2        		0x9a
-#define		MINDEX          	0xff
-
-#define	SLVSPLTOUTADR2  		0x9a
-#define		REQ_BNUM        	0xff
-
-#define	SGRXMSG3        		0x9b
-#define		MCLASS          	0x0f
-
-#define	SLVSPLTOUTADR3  		0x9b
-#define		TAG_NUM         	0x1f
-#define		RLXORD          	0x10
-
-#define	SGSEQBCNT       		0x9c
-
-#define	SLVSPLTOUTATTR0 		0x9c
-#define		LOWER_BCNT      	0xff
-
-#define	SLVSPLTOUTATTR1 		0x9d
-#define		CMPLT_DNUM      	0xf8
-#define		CMPLT_FNUM      	0x07
-
-#define	SLVSPLTOUTATTR2 		0x9e
-#define		CMPLT_BNUM      	0xff
-
-#define	SGSPLTSTAT0     		0x9e
-#define		STAETERM        	0x80
-#define		SCBCERR         	0x40
-#define		SCADERR         	0x20
-#define		SCDATBUCKET     	0x10
-#define		CNTNOTCMPLT     	0x08
-#define		RXOVRUN         	0x04
-#define		RXSCEMSG        	0x02
-#define		RXSPLTRSP       	0x01
-
-#define	SFUNCT          		0x9f
-#define		TEST_GROUP      	0xf0
-#define		TEST_NUM        	0x0f
-
-#define	SGSPLTSTAT1     		0x9f
-#define		RXDATABUCKET    	0x01
-
-#define	DF0PCISTAT      		0xa0
-
-#define	REG0            		0xa0
-
-#define	DF1PCISTAT      		0xa1
-
-#define	SGPCISTAT       		0xa2
-
-#define	REG1            		0xa2
-
-#define	CMCPCISTAT      		0xa3
-
-#define	OVLYPCISTAT     		0xa4
-#define		SCAAPERR        	0x08
-#define		RDPERR          	0x04
-
-#define	REG_ISR         		0xa4
-
-#define	SG_STATE        		0xa6
-#define		FETCH_INPROG    	0x04
-#define		LOADING_NEEDED  	0x02
-#define		SEGS_AVAIL      	0x01
-
-#define	MSIPCISTAT      		0xa6
-#define		RMA             	0x20
-#define		RTA             	0x10
-#define		CLRPENDMSI      	0x08
-#define		DPR             	0x01
-
-#define	TARGPCISTAT     		0xa7
-#define		DPE             	0x80
-#define		SSE             	0x40
-#define		STA             	0x08
-#define		TWATERR         	0x02
-
-#define	DATA_COUNT_ODD  		0xa7
-
-#define	SCBPTR          		0xa8
-
-#define	CCSCBACNT       		0xab
-
-#define	SCBAUTOPTR      		0xab
-#define		AUSCBPTR_EN     	0x80
-#define		SCBPTR_ADDR     	0x38
-#define		SCBPTR_OFF      	0x07
-
-#define	CCSGADDR        		0xac
-
-#define	CCSCBADDR       		0xac
-
-#define	CCSCBADR_BK     		0xac
-
-#define	CMC_RAMBIST     		0xad
-#define		SG_ELEMENT_SIZE 	0x80
-#define		SCBRAMBIST_FAIL 	0x40
-#define		SG_BIST_FAIL    	0x20
-#define		SG_BIST_EN      	0x10
-#define		CMC_BUFFER_BIST_FAIL	0x02
-#define		CMC_BUFFER_BIST_EN	0x01
-
-#define	CCSGCTL         		0xad
-#define		CCSGEN          	0x0c
-#define		CCSGDONE        	0x80
-#define		SG_CACHE_AVAIL  	0x10
-#define		CCSGENACK       	0x08
-#define		SG_FETCH_REQ    	0x02
-#define		CCSGRESET       	0x01
-
-#define	CCSCBCTL        		0xad
-#define		CCSCBDONE       	0x80
-#define		ARRDONE         	0x40
-#define		CCARREN         	0x10
-#define		CCSCBEN         	0x08
-#define		CCSCBDIR        	0x04
-#define		CCSCBRESET      	0x01
-
-#define	CCSGRAM         		0xb0
-
-#define	FLEXADR         		0xb0
-
-#define	CCSCBRAM        		0xb0
-
-#define	FLEXCNT         		0xb3
-
-#define	FLEXDMASTAT     		0xb5
-#define		FLEXDMAERR      	0x02
-#define		FLEXDMADONE     	0x01
-
-#define	FLEXDATA        		0xb6
-
-#define	BRDDAT          		0xb8
-
-#define	BRDCTL          		0xb9
-#define		FLXARBACK       	0x80
-#define		FLXARBREQ       	0x40
-#define		BRDADDR         	0x38
-#define		BRDEN           	0x04
-#define		BRDRW           	0x02
-#define		BRDSTB          	0x01
-
-#define	SEEADR          		0xba
-
-#define	SEEDAT          		0xbc
-
-#define	SEECTL          		0xbe
-#define		SEEOP_EWEN      	0x40
-#define		SEEOP_WALL      	0x40
-#define		SEEOP_EWDS      	0x40
-#define		SEEOPCODE       	0x70
-#define		SEERST          	0x02
-#define		SEESTART        	0x01
-#define		SEEOP_ERASE     	0x70
-#define		SEEOP_READ      	0x60
-#define		SEEOP_WRITE     	0x50
-#define		SEEOP_ERAL      	0x40
-
-#define	SEESTAT         		0xbe
-#define		INIT_DONE       	0x80
-#define		LDALTID_L       	0x08
-#define		SEEARBACK       	0x04
-#define		SEEBUSY         	0x02
-
-#define	SCBCNT          		0xbf
-
-#define	DFWADDR         		0xc0
-
-#define	DSPFLTRCTL      		0xc0
-#define		FLTRDISABLE     	0x20
-#define		EDGESENSE       	0x10
-#define		DSPFCNTSEL      	0x0f
-
-#define	DSPDATACTL      		0xc1
-#define		BYPASSENAB      	0x80
-#define		DESQDIS         	0x10
-#define		RCVROFFSTDIS    	0x04
-#define		XMITOFFSTDIS    	0x02
-
-#define	DFRADDR         		0xc2
-
-#define	DSPREQCTL       		0xc2
-#define		MANREQCTL       	0xc0
-#define		MANREQDLY       	0x3f
-
-#define	DSPACKCTL       		0xc3
-#define		MANACKCTL       	0xc0
-#define		MANACKDLY       	0x3f
-
-#define	DFDAT           		0xc4
-
-#define	DSPSELECT       		0xc4
-#define		AUTOINCEN       	0x80
-#define		DSPSEL          	0x1f
-
-#define	WRTBIASCTL      		0xc5
-#define		AUTOXBCDIS      	0x80
-#define		XMITMANVAL      	0x3f
-
-#define	RCVRBIOSCTL     		0xc6
-#define		AUTORBCDIS      	0x80
-#define		RCVRMANVAL      	0x3f
-
-#define	WRTBIASCALC     		0xc7
-
-#define	DFPTRS          		0xc8
-
-#define	RCVRBIASCALC    		0xc8
-
-#define	DFBKPTR         		0xc9
-
-#define	SKEWCALC        		0xc9
-
-#define	DFDBCTL         		0xcb
-#define		DFF_CIO_WR_RDY  	0x20
-#define		DFF_CIO_RD_RDY  	0x10
-#define		DFF_DIR_ERR     	0x08
-#define		DFF_RAMBIST_FAIL	0x04
-#define		DFF_RAMBIST_DONE	0x02
-#define		DFF_RAMBIST_EN  	0x01
-
-#define	DFSCNT          		0xcc
-
-#define	DFBCNT          		0xce
-
-#define	OVLYADDR        		0xd4
-
-#define	SEQCTL0         		0xd6
-#define		PERRORDIS       	0x80
-#define		PAUSEDIS        	0x40
-#define		FAILDIS         	0x20
-#define		FASTMODE        	0x10
-#define		BRKADRINTEN     	0x08
-#define		STEP            	0x04
-#define		SEQRESET        	0x02
-#define		LOADRAM         	0x01
-
-#define	SEQCTL1         		0xd7
-#define		OVRLAY_DATA_CHK 	0x08
-#define		RAMBIST_DONE    	0x04
-#define		RAMBIST_FAIL    	0x02
-#define		RAMBIST_EN      	0x01
-
-#define	FLAGS           		0xd8
-#define		ZERO            	0x02
-#define		CARRY           	0x01
-
-#define	SEQINTCTL       		0xd9
-#define		INTVEC1DSL      	0x80
-#define		INT1_CONTEXT    	0x20
-#define		SCS_SEQ_INT1M1  	0x10
-#define		SCS_SEQ_INT1M0  	0x08
-#define		INTMASK2        	0x04
-#define		INTMASK1        	0x02
-#define		IRET            	0x01
-
-#define	SEQRAM          		0xda
-
-#define	PRGMCNT         		0xde
-
-#define	ACCUM           		0xe0
-
-#define	SINDEX          		0xe2
-
-#define	DINDEX          		0xe4
-
-#define	BRKADDR1        		0xe6
-#define		BRKDIS          	0x80
-
-#define	BRKADDR0        		0xe6
-
-#define	ALLONES         		0xe8
-
-#define	ALLZEROS        		0xea
-
-#define	NONE            		0xea
-
-#define	SINDIR          		0xec
-
-#define	DINDIR          		0xed
-
-#define	FUNCTION1       		0xf0
-
-#define	STACK           		0xf2
-
-#define	CURADDR         		0xf4
-
-#define	INTVEC1_ADDR    		0xf4
-
-#define	INTVEC2_ADDR    		0xf6
-
-#define	LASTADDR        		0xf6
-
-#define	LONGJMP_ADDR    		0xf8
-
-#define	LONGJMP_SCB     		0xfa
-
-#define	ACCUM_SAVE      		0xfc
-
-#define	WAITING_SCB_TAILS		0x100
-
-#define	AHD_PCI_CONFIG_BASE		0x100
-
-#define	SRAM_BASE       		0x100
-
-#define	WAITING_TID_HEAD		0x120
-
-#define	WAITING_TID_TAIL		0x122
-
-#define	NEXT_QUEUED_SCB_ADDR		0x124
-
-#define	COMPLETE_SCB_HEAD		0x128
-
-#define	COMPLETE_SCB_DMAINPROG_HEAD		0x12a
-
-#define	COMPLETE_DMA_SCB_HEAD		0x12c
-
-#define	QFREEZE_COUNT   		0x12e
-
-#define	SAVED_MODE      		0x130
-
-#define	MSG_OUT         		0x131
-
-#define	DMAPARAMS       		0x132
-#define		PRELOADEN       	0x80
-#define		WIDEODD         	0x40
-#define		SCSIEN          	0x20
-#define		SDMAEN          	0x10
-#define		SDMAENACK       	0x10
-#define		HDMAENACK       	0x08
-#define		HDMAEN          	0x08
-#define		DIRECTION       	0x04
-#define		FIFOFLUSH       	0x02
-#define		FIFORESET       	0x01
-
-#define	SEQ_FLAGS       		0x133
-#define		NOT_IDENTIFIED  	0x80
-#define		NO_CDB_SENT     	0x40
-#define		TARGET_CMD_IS_TAGGED	0x40
-#define		DPHASE          	0x20
-#define		TARG_CMD_PENDING	0x10
-#define		CMDPHASE_PENDING	0x08
-#define		DPHASE_PENDING  	0x04
-#define		SPHASE_PENDING  	0x02
-#define		NO_DISCONNECT   	0x01
-
-#define	SAVED_SCSIID    		0x134
-
-#define	SAVED_LUN       		0x135
-
-#define	LASTPHASE       		0x136
-#define		PHASE_MASK      	0xe0
-#define		CDI             	0x80
-#define		IOI             	0x40
-#define		MSGI            	0x20
-#define		P_BUSFREE       	0x01
-#define		P_MESGIN        	0xe0
-#define		P_STATUS        	0xc0
-#define		P_MESGOUT       	0xa0
-#define		P_COMMAND       	0x80
-#define		P_DATAIN_DT     	0x60
-#define		P_DATAIN        	0x40
-#define		P_DATAOUT_DT    	0x20
-#define		P_DATAOUT       	0x00
-
-#define	QOUTFIFO_ENTRY_VALID_TAG		0x137
-
-#define	SHARED_DATA_ADDR		0x138
-
-#define	QOUTFIFO_NEXT_ADDR		0x13c
-
-#define	KERNEL_TQINPOS  		0x140
-
-#define	TQINPOS         		0x141
-
-#define	ARG_1           		0x142
-#define	RETURN_1        		0x142
-#define		SEND_MSG        	0x80
-#define		SEND_SENSE      	0x40
-#define		SEND_REJ        	0x20
-#define		MSGOUT_PHASEMIS 	0x10
-#define		EXIT_MSG_LOOP   	0x08
-#define		CONT_MSG_LOOP_WRITE	0x04
-#define		CONT_MSG_LOOP_READ	0x03
-#define		CONT_MSG_LOOP_TARG	0x02
-
-#define	ARG_2           		0x143
-#define	RETURN_2        		0x143
-
-#define	LAST_MSG        		0x144
-
-#define	SCSISEQ_TEMPLATE		0x145
-#define		MANUALCTL       	0x40
-#define		ENSELI          	0x20
-#define		ENRSELI         	0x10
-#define		MANUALP         	0x0c
-#define		ENAUTOATNP      	0x02
-#define		ALTSTIM         	0x01
-
-#define	INITIATOR_TAG   		0x146
-
-#define	SEQ_FLAGS2      		0x147
-#define		SELECTOUT_QFROZEN	0x04
-#define		TARGET_MSG_PENDING	0x02
-
-#define	ALLOCFIFO_SCBPTR		0x148
-
-#define	INT_COALESSING_TIMER		0x14a
-
-#define	INT_COALESSING_MAXCMDS		0x14c
-
-#define	INT_COALESSING_MINCMDS		0x14d
-
-#define	CMDS_PENDING    		0x14e
-
-#define	INT_COALESSING_CMDCOUNT		0x150
-
-#define	LOCAL_HS_MAILBOX		0x151
-
-#define	CMDSIZE_TABLE   		0x152
-
-#define	SCB_BASE        		0x180
-
-#define	SCB_RESIDUAL_DATACNT		0x180
-#define	SCB_CDB_STORE   		0x180
-
-#define	SCB_RESIDUAL_SGPTR		0x184
-#define	SCB_CDB_PTR     		0x184
-#define		SG_ADDR_MASK    	0xf8
-#define		SG_OVERRUN_RESID	0x02
-
-#define	SCB_SCSI_STATUS 		0x188
-
-#define	SCB_TARGET_PHASES		0x189
-
-#define	SCB_TARGET_DATA_DIR		0x18a
-
-#define	SCB_TARGET_ITAG 		0x18b
-
-#define	SCB_SENSE_BUSADDR		0x18c
-#define	SCB_NEXT_COMPLETE		0x18c
-
-#define	SCB_TAG         		0x190
-
-#define	SCB_CDB_LEN     		0x192
-#define		SCB_CDB_LEN_PTR 	0x80
-
-#define	SCB_TASK_MANAGEMENT		0x193
-
-#define	SCB_NEXT        		0x194
-#define	SCB_NEXT_SCB_BUSADDR		0x194
-
-#define	SCB_NEXT2       		0x196
-
-#define	SCB_DATAPTR     		0x198
-
-#define	SCB_DATACNT     		0x1a0
-#define		SG_LAST_SEG     	0x80
-#define		SG_HIGH_ADDR_BITS	0x7f
-
-#define	SCB_SGPTR       		0x1a4
-#define		SG_STATUS_VALID 	0x04
-#define		SG_FULL_RESID   	0x02
-#define		SG_LIST_NULL    	0x01
-
-#define	SCB_CONTROL     		0x1a8
-#define		TARGET_SCB      	0x80
-#define		DISCENB         	0x40
-#define		TAG_ENB         	0x20
-#define		MK_MESSAGE      	0x10
-#define		STATUS_RCVD     	0x08
-#define		DISCONNECTED    	0x04
-#define		SCB_TAG_TYPE    	0x03
-
-#define	SCB_SCSIID      		0x1a9
-#define		TID             	0xf0
-#define		OID             	0x0f
-
-#define	SCB_LUN         		0x1aa
-#define		LID             	0xff
-
-#define	SCB_TASK_ATTRIBUTE		0x1ab
-
-#define	SCB_BUSADDR     		0x1ac
-
-#define	SCB_SPARE       		0x1b0
-#define	SCB_PKT_LUN     		0x1b0
-
-#define	SCB_DISCONNECTED_LISTS		0x1b8
-
-
-#define	AHD_TIMER_US_PER_TICK	0x19
-#define	SCB_TRANSFER_SIZE_FULL_LUN	0x38
-#define	STATUS_QUEUE_FULL	0x28
-#define	STATUS_BUSY	0x08
-#define	MAX_OFFSET_NON_PACED	0x7f
-#define	MAX_OFFSET_PACED	0xfe
-#define	BUS_32_BIT	0x02
-#define	CCSGADDR_MAX	0x80
-#define	TID_SHIFT	0x04
-#define	MK_MESSAGE_BIT_OFFSET	0x04
-#define	WRTBIASCTL_HP_DEFAULT	0x00
-#define	SEEOP_EWDS_ADDR	0x00
-#define	AHD_AMPLITUDE_SHIFT	0x00
-#define	AHD_AMPLITUDE_MASK	0x07
-#define	AHD_ANNEXCOL_AMPLITUDE	0x06
-#define	AHD_SLEWRATE_DEF_REVA	0x01
-#define	AHD_SLEWRATE_SHIFT	0x03
-#define	AHD_SLEWRATE_MASK	0x78
-#define	AHD_PRECOMP_CUTBACK_29	0x06
-#define	AHD_NUM_PER_DEV_ANNEXCOLS	0x04
-#define	B_CURRFIFO_0	0x02
-#define	NVRAM_SCB_OFFSET	0x2c
-#define	AHD_TIMER_MAX_US	0x18ffe7
-#define	AHD_TIMER_MAX_TICKS	0xffff
-#define	STATUS_PKT_SENSE	0xff
-#define	CMD_GROUP_CODE_SHIFT	0x05
-#define	AHD_SENSE_BUFSIZE	0x100
-#define	MAX_OFFSET_PACED_BUG	0x7f
-#define	BUS_8_BIT	0x00
-#define	STIMESEL_BUG_ADJ	0x08
-#define	STIMESEL_MIN	0x18
-#define	STIMESEL_SHIFT	0x03
-#define	CCSGRAM_MAXSEGS	0x10
-#define	INVALID_ADDR	0x80
-#define	TARGET_CMD_CMPLT	0xfe
-#define	SEEOP_WRAL_ADDR	0x40
-#define	SEEOP_ERAL_ADDR	0x80
-#define	AHD_AMPLITUDE_DEF	0x07
-#define	AHD_SLEWRATE_DEF_REVB	0x08
-#define	AHD_PRECOMP_CUTBACK_37	0x07
-#define	AHD_PRECOMP_CUTBACK_17	0x04
-#define	AHD_PRECOMP_SHIFT	0x00
-#define	AHD_PRECOMP_MASK	0x07
-#define	AHD_ANNEXCOL_PRECOMP_SLEW	0x04
-#define	SRC_MODE_SHIFT	0x00
-#define	PKT_OVERRUN_BUFSIZE	0x200
-#define	SCB_TRANSFER_SIZE_1BYTE_LUN	0x30
-#define	TARGET_DATA_IN	0x01
-#define	HOST_MSG	0xff
-#define	MAX_OFFSET	0xfe
-#define	BUS_16_BIT	0x01
-#define	CCSCBADDR_MAX	0x80
-#define	NUMDSPS 	0x14
-#define	SEEOP_EWEN_ADDR	0xc0
-#define	AHD_ANNEXCOL_PER_DEV0	0x04
-#define	DST_MODE_SHIFT	0x04
-
-
-/* Downloaded Constant Definitions */
-#define	SCB_TRANSFER_SIZE	0x06
-#define	PKT_OVERRUN_BUFOFFSET	0x05
-#define	SG_SIZEOF	0x04
-#define	SG_PREFETCH_ADDR_MASK	0x03
-#define	SG_PREFETCH_ALIGN_MASK	0x02
-#define	SG_PREFETCH_CNT_LIMIT	0x01
-#define	SG_PREFETCH_CNT	0x00
-#define	DOWNLOAD_CONST_COUNT	0x07
-
-
-/* Exported Labels */
-#define	LABEL_seq_isr 	0x263
-#define	LABEL_timer_isr	0x25f
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aic79xx_reg_print.c linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx_reg_print.c
--- linux-2.4.21/drivers/scsi/aic79xx/aic79xx_reg_print.c	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx_reg_print.c	2003-06-26 21:43:12.000000000 +0000
@@ -1,3632 +0,0 @@
-/*
- * DO NOT EDIT - This file is automatically generated
- *		 from the following source files:
- *
- * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#78 $
- * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#60 $
- */
-
-#include "aic79xx_osm.h"
-
-static ahd_reg_parse_entry_t MODE_PTR_parse_table[] = {
-	{ "SRC_MODE",		0x07, 0x07 },
-	{ "DST_MODE",		0x70, 0x70 }
-};
-
-int
-ahd_mode_ptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(MODE_PTR_parse_table, 2, "MODE_PTR",
-	    0x00, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t INTSTAT_parse_table[] = {
-	{ "SPLTINT",		0x01, 0x01 },
-	{ "CMDCMPLT",		0x02, 0x02 },
-	{ "SEQINT",		0x04, 0x04 },
-	{ "SCSIINT",		0x08, 0x08 },
-	{ "PCIINT",		0x10, 0x10 },
-	{ "SWTMINT",		0x20, 0x20 },
-	{ "BRKADRINT",		0x40, 0x40 },
-	{ "HWERRINT",		0x80, 0x80 },
-	{ "INT_PEND",		0xff, 0xff }
-};
-
-int
-ahd_intstat_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(INTSTAT_parse_table, 9, "INTSTAT",
-	    0x01, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SEQINTCODE_parse_table[] = {
-	{ "NO_SEQINT",		0x00, 0xff },
-	{ "BAD_PHASE",		0x01, 0xff },
-	{ "SEND_REJECT",	0x02, 0xff },
-	{ "PROTO_VIOLATION",	0x03, 0xff },
-	{ "NO_MATCH",		0x04, 0xff },
-	{ "IGN_WIDE_RES",	0x05, 0xff },
-	{ "PDATA_REINIT",	0x06, 0xff },
-	{ "HOST_MSG_LOOP",	0x07, 0xff },
-	{ "BAD_STATUS",		0x08, 0xff },
-	{ "DATA_OVERRUN",	0x09, 0xff },
-	{ "MKMSG_FAILED",	0x0a, 0xff },
-	{ "MISSED_BUSFREE",	0x0b, 0xff },
-	{ "DUMP_CARD_STATE",	0x0c, 0xff },
-	{ "ILLEGAL_PHASE",	0x0d, 0xff },
-	{ "INVALID_SEQINT",	0x0e, 0xff },
-	{ "CFG4ISTAT_INTR",	0x0f, 0xff },
-	{ "STATUS_OVERRUN",	0x10, 0xff },
-	{ "CFG4OVERRUN",	0x11, 0xff },
-	{ "ENTERING_NONPACK",	0x12, 0xff },
-	{ "TASKMGMT_FUNC_COMPLETE",0x13, 0xff },
-	{ "TASKMGMT_CMD_CMPLT_OKAY",0x14, 0xff },
-	{ "TRACEPOINT0",	0x15, 0xff },
-	{ "TRACEPOINT1",	0x16, 0xff },
-	{ "TRACEPOINT2",	0x17, 0xff },
-	{ "TRACEPOINT3",	0x18, 0xff },
-	{ "SAW_HWERR",		0x19, 0xff }
-};
-
-int
-ahd_seqintcode_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SEQINTCODE_parse_table, 26, "SEQINTCODE",
-	    0x02, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CLRINT_parse_table[] = {
-	{ "CLRSPLTINT",		0x01, 0x01 },
-	{ "CLRCMDINT",		0x02, 0x02 },
-	{ "CLRSEQINT",		0x04, 0x04 },
-	{ "CLRSCSIINT",		0x08, 0x08 },
-	{ "CLRPCIINT",		0x10, 0x10 },
-	{ "CLRSWTMINT",		0x20, 0x20 },
-	{ "CLRBRKADRINT",	0x40, 0x40 },
-	{ "CLRHWERRINT",	0x80, 0x80 }
-};
-
-int
-ahd_clrint_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CLRINT_parse_table, 8, "CLRINT",
-	    0x03, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t ERROR_parse_table[] = {
-	{ "DSCTMOUT",		0x02, 0x02 },
-	{ "ILLOPCODE",		0x04, 0x04 },
-	{ "SQPARERR",		0x08, 0x08 },
-	{ "DPARERR",		0x10, 0x10 },
-	{ "MPARERR",		0x20, 0x20 },
-	{ "CIOACCESFAIL",	0x40, 0x40 },
-	{ "CIOPARERR",		0x80, 0x80 }
-};
-
-int
-ahd_error_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(ERROR_parse_table, 7, "ERROR",
-	    0x04, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CLRERR_parse_table[] = {
-	{ "CLRDSCTMOUT",	0x02, 0x02 },
-	{ "CLRILLOPCODE",	0x04, 0x04 },
-	{ "CLRSQPARERR",	0x08, 0x08 },
-	{ "CLRDPARERR",		0x10, 0x10 },
-	{ "CLRMPARERR",		0x20, 0x20 },
-	{ "CLRCIOACCESFAIL",	0x40, 0x40 },
-	{ "CLRCIOPARERR",	0x80, 0x80 }
-};
-
-int
-ahd_clrerr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CLRERR_parse_table, 7, "CLRERR",
-	    0x04, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t HCNTRL_parse_table[] = {
-	{ "CHIPRST",		0x01, 0x01 },
-	{ "CHIPRSTACK",		0x01, 0x01 },
-	{ "INTEN",		0x02, 0x02 },
-	{ "PAUSE",		0x04, 0x04 },
-	{ "SWTIMER_START_B",	0x08, 0x08 },
-	{ "SWINT",		0x10, 0x10 },
-	{ "POWRDN",		0x40, 0x40 },
-	{ "SEQ_RESET",		0x80, 0x80 }
-};
-
-int
-ahd_hcntrl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(HCNTRL_parse_table, 8, "HCNTRL",
-	    0x05, regvalue, cur_col, wrap));
-}
-
-int
-ahd_hnscb_qoff_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "HNSCB_QOFF",
-	    0x06, regvalue, cur_col, wrap));
-}
-
-int
-ahd_hescb_qoff_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "HESCB_QOFF",
-	    0x08, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t HS_MAILBOX_parse_table[] = {
-	{ "ENINT_COALESS",	0x40, 0x40 },
-	{ "HOST_TQINPOS",	0x80, 0x80 }
-};
-
-int
-ahd_hs_mailbox_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(HS_MAILBOX_parse_table, 2, "HS_MAILBOX",
-	    0x0b, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CLRSEQINTSTAT_parse_table[] = {
-	{ "CLRSEQ_SPLTINT",	0x01, 0x01 },
-	{ "CLRSEQ_PCIINT",	0x02, 0x02 },
-	{ "CLRSEQ_SCSIINT",	0x04, 0x04 },
-	{ "CLRSEQ_SEQINT",	0x08, 0x08 },
-	{ "CLRSEQ_SWTMRTO",	0x10, 0x10 }
-};
-
-int
-ahd_clrseqintstat_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CLRSEQINTSTAT_parse_table, 5, "CLRSEQINTSTAT",
-	    0x0c, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SEQINTSTAT_parse_table[] = {
-	{ "SEQ_SPLTINT",	0x01, 0x01 },
-	{ "SEQ_PCIINT",		0x02, 0x02 },
-	{ "SEQ_SCSIINT",	0x04, 0x04 },
-	{ "SEQ_SEQINT",		0x08, 0x08 },
-	{ "SEQ_SWTMRTO",	0x10, 0x10 }
-};
-
-int
-ahd_seqintstat_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SEQINTSTAT_parse_table, 5, "SEQINTSTAT",
-	    0x0c, regvalue, cur_col, wrap));
-}
-
-int
-ahd_swtimer_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SWTIMER",
-	    0x0e, regvalue, cur_col, wrap));
-}
-
-int
-ahd_snscb_qoff_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SNSCB_QOFF",
-	    0x10, regvalue, cur_col, wrap));
-}
-
-int
-ahd_sescb_qoff_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SESCB_QOFF",
-	    0x12, regvalue, cur_col, wrap));
-}
-
-int
-ahd_sdscb_qoff_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SDSCB_QOFF",
-	    0x14, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t QOFF_CTLSTA_parse_table[] = {
-	{ "SCB_QSIZE_4",	0x00, 0x0f },
-	{ "SCB_QSIZE_8",	0x01, 0x0f },
-	{ "SCB_QSIZE_16",	0x02, 0x0f },
-	{ "SCB_QSIZE_32",	0x03, 0x0f },
-	{ "SCB_QSIZE_64",	0x04, 0x0f },
-	{ "SCB_QSIZE_128",	0x05, 0x0f },
-	{ "SCB_QSIZE_256",	0x06, 0x0f },
-	{ "SCB_QSIZE_512",	0x07, 0x0f },
-	{ "SCB_QSIZE_1024",	0x08, 0x0f },
-	{ "SCB_QSIZE_2048",	0x09, 0x0f },
-	{ "SCB_QSIZE_4096",	0x0a, 0x0f },
-	{ "SCB_QSIZE_8192",	0x0b, 0x0f },
-	{ "SCB_QSIZE_16384",	0x0c, 0x0f },
-	{ "SCB_QSIZE",		0x0f, 0x0f },
-	{ "HS_MAILBOX_ACT",	0x10, 0x10 },
-	{ "SDSCB_ROLLOVR",	0x20, 0x20 },
-	{ "NEW_SCB_AVAIL",	0x40, 0x40 },
-	{ "EMPTY_SCB_AVAIL",	0x80, 0x80 }
-};
-
-int
-ahd_qoff_ctlsta_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(QOFF_CTLSTA_parse_table, 18, "QOFF_CTLSTA",
-	    0x16, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t INTCTL_parse_table[] = {
-	{ "SPLTINTEN",		0x01, 0x01 },
-	{ "SEQINTEN",		0x02, 0x02 },
-	{ "SCSIINTEN",		0x04, 0x04 },
-	{ "PCIINTEN",		0x08, 0x08 },
-	{ "AUTOCLRCMDINT",	0x10, 0x10 },
-	{ "SWTIMER_START",	0x20, 0x20 },
-	{ "SWTMINTEN",		0x40, 0x40 },
-	{ "SWTMINTMASK",	0x80, 0x80 }
-};
-
-int
-ahd_intctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(INTCTL_parse_table, 8, "INTCTL",
-	    0x18, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DFCNTRL_parse_table[] = {
-	{ "DIRECTIONEN",	0x01, 0x01 },
-	{ "FIFOFLUSH",		0x02, 0x02 },
-	{ "FIFOFLUSHACK",	0x02, 0x02 },
-	{ "DIRECTION",		0x04, 0x04 },
-	{ "DIRECTIONACK",	0x04, 0x04 },
-	{ "HDMAEN",		0x08, 0x08 },
-	{ "HDMAENACK",		0x08, 0x08 },
-	{ "SCSIEN",		0x20, 0x20 },
-	{ "SCSIENACK",		0x20, 0x20 },
-	{ "SCSIENWRDIS",	0x40, 0x40 },
-	{ "PRELOADEN",		0x80, 0x80 }
-};
-
-int
-ahd_dfcntrl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DFCNTRL_parse_table, 11, "DFCNTRL",
-	    0x19, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DSCOMMAND0_parse_table[] = {
-	{ "CIOPARCKEN",		0x01, 0x01 },
-	{ "DISABLE_TWATE",	0x02, 0x02 },
-	{ "EXTREQLCK",		0x10, 0x10 },
-	{ "MPARCKEN",		0x20, 0x20 },
-	{ "DPARCKEN",		0x40, 0x40 },
-	{ "CACHETHEN",		0x80, 0x80 }
-};
-
-int
-ahd_dscommand0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DSCOMMAND0_parse_table, 6, "DSCOMMAND0",
-	    0x19, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DFSTATUS_parse_table[] = {
-	{ "FIFOEMP",		0x01, 0x01 },
-	{ "FIFOFULL",		0x02, 0x02 },
-	{ "DFTHRESH",		0x04, 0x04 },
-	{ "HDONE",		0x08, 0x08 },
-	{ "MREQPEND",		0x10, 0x10 },
-	{ "PKT_PRELOAD_AVAIL",	0x40, 0x40 },
-	{ "PRELOAD_AVAIL",	0x80, 0x80 }
-};
-
-int
-ahd_dfstatus_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DFSTATUS_parse_table, 7, "DFSTATUS",
-	    0x1a, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SG_CACHE_SHADOW_parse_table[] = {
-	{ "LAST_SEG_DONE",	0x01, 0x01 },
-	{ "LAST_SEG",		0x02, 0x02 },
-	{ "ODD_SEG",		0x04, 0x04 },
-	{ "SG_ADDR_MASK",	0xf8, 0xf8 }
-};
-
-int
-ahd_sg_cache_shadow_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SG_CACHE_SHADOW_parse_table, 4, "SG_CACHE_SHADOW",
-	    0x1b, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t ARBCTL_parse_table[] = {
-	{ "USE_TIME",		0x07, 0x07 },
-	{ "RETRY_SWEN",		0x08, 0x08 },
-	{ "RESET_HARB",		0x80, 0x80 }
-};
-
-int
-ahd_arbctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(ARBCTL_parse_table, 3, "ARBCTL",
-	    0x1b, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SG_CACHE_PRE_parse_table[] = {
-	{ "LAST_SEG",		0x02, 0x02 },
-	{ "ODD_SEG",		0x04, 0x04 },
-	{ "SG_ADDR_MASK",	0xf8, 0xf8 }
-};
-
-int
-ahd_sg_cache_pre_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SG_CACHE_PRE_parse_table, 3, "SG_CACHE_PRE",
-	    0x1b, regvalue, cur_col, wrap));
-}
-
-int
-ahd_lqin_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "LQIN",
-	    0x20, regvalue, cur_col, wrap));
-}
-
-int
-ahd_typeptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "TYPEPTR",
-	    0x20, regvalue, cur_col, wrap));
-}
-
-int
-ahd_tagptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "TAGPTR",
-	    0x21, regvalue, cur_col, wrap));
-}
-
-int
-ahd_lunptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "LUNPTR",
-	    0x22, regvalue, cur_col, wrap));
-}
-
-int
-ahd_datalenptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "DATALENPTR",
-	    0x23, regvalue, cur_col, wrap));
-}
-
-int
-ahd_statlenptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "STATLENPTR",
-	    0x24, regvalue, cur_col, wrap));
-}
-
-int
-ahd_cmdlenptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "CMDLENPTR",
-	    0x25, regvalue, cur_col, wrap));
-}
-
-int
-ahd_attrptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "ATTRPTR",
-	    0x26, regvalue, cur_col, wrap));
-}
-
-int
-ahd_flagptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "FLAGPTR",
-	    0x27, regvalue, cur_col, wrap));
-}
-
-int
-ahd_cmdptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "CMDPTR",
-	    0x28, regvalue, cur_col, wrap));
-}
-
-int
-ahd_qnextptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "QNEXTPTR",
-	    0x29, regvalue, cur_col, wrap));
-}
-
-int
-ahd_idptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "IDPTR",
-	    0x2a, regvalue, cur_col, wrap));
-}
-
-int
-ahd_abrtbyteptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "ABRTBYTEPTR",
-	    0x2b, regvalue, cur_col, wrap));
-}
-
-int
-ahd_abrtbitptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "ABRTBITPTR",
-	    0x2c, regvalue, cur_col, wrap));
-}
-
-int
-ahd_maxcmdbytes_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "MAXCMDBYTES",
-	    0x2d, regvalue, cur_col, wrap));
-}
-
-int
-ahd_maxcmd2rcv_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "MAXCMD2RCV",
-	    0x2e, regvalue, cur_col, wrap));
-}
-
-int
-ahd_shortthresh_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SHORTTHRESH",
-	    0x2f, regvalue, cur_col, wrap));
-}
-
-int
-ahd_lunlen_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "LUNLEN",
-	    0x30, regvalue, cur_col, wrap));
-}
-
-int
-ahd_cdblimit_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "CDBLIMIT",
-	    0x31, regvalue, cur_col, wrap));
-}
-
-int
-ahd_maxcmd_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "MAXCMD",
-	    0x32, regvalue, cur_col, wrap));
-}
-
-int
-ahd_maxcmdcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "MAXCMDCNT",
-	    0x33, regvalue, cur_col, wrap));
-}
-
-int
-ahd_lqrsvd01_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "LQRSVD01",
-	    0x34, regvalue, cur_col, wrap));
-}
-
-int
-ahd_lqrsvd16_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "LQRSVD16",
-	    0x35, regvalue, cur_col, wrap));
-}
-
-int
-ahd_lqrsvd17_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "LQRSVD17",
-	    0x36, regvalue, cur_col, wrap));
-}
-
-int
-ahd_cmdrsvd0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "CMDRSVD0",
-	    0x37, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t LQCTL0_parse_table[] = {
-	{ "LQ0INITGCLT",	0x03, 0x03 },
-	{ "LQ0TARGCLT",		0x0c, 0x0c },
-	{ "LQIINITGCLT",	0x30, 0x30 },
-	{ "LQITARGCLT",		0xc0, 0xc0 }
-};
-
-int
-ahd_lqctl0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(LQCTL0_parse_table, 4, "LQCTL0",
-	    0x38, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t LQCTL1_parse_table[] = {
-	{ "ABORTPENDING",	0x01, 0x01 },
-	{ "SINGLECMD",		0x02, 0x02 },
-	{ "PCI2PCI",		0x04, 0x04 }
-};
-
-int
-ahd_lqctl1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(LQCTL1_parse_table, 3, "LQCTL1",
-	    0x38, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SCSBIST0_parse_table[] = {
-	{ "OSBISTRUN",		0x01, 0x01 },
-	{ "OSBISTDONE",		0x02, 0x02 },
-	{ "OSBISTERR",		0x04, 0x04 },
-	{ "GSBISTRUN",		0x10, 0x10 },
-	{ "GSBISTDONE",		0x20, 0x20 },
-	{ "GSBISTERR",		0x40, 0x40 }
-};
-
-int
-ahd_scsbist0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SCSBIST0_parse_table, 6, "SCSBIST0",
-	    0x39, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t LQCTL2_parse_table[] = {
-	{ "LQOPAUSE",		0x01, 0x01 },
-	{ "LQOTOIDLE",		0x02, 0x02 },
-	{ "LQOCONTINUE",	0x04, 0x04 },
-	{ "LQORETRY",		0x08, 0x08 },
-	{ "LQIPAUSE",		0x10, 0x10 },
-	{ "LQITOIDLE",		0x20, 0x20 },
-	{ "LQICONTINUE",	0x40, 0x40 },
-	{ "LQIRETRY",		0x80, 0x80 }
-};
-
-int
-ahd_lqctl2_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(LQCTL2_parse_table, 8, "LQCTL2",
-	    0x39, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SCSBIST1_parse_table[] = {
-	{ "NTBISTRUN",		0x01, 0x01 },
-	{ "NTBISTDONE",		0x02, 0x02 },
-	{ "NTBISTERR",		0x04, 0x04 }
-};
-
-int
-ahd_scsbist1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SCSBIST1_parse_table, 3, "SCSBIST1",
-	    0x3a, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SCSISEQ0_parse_table[] = {
-	{ "SCSIRSTO",		0x01, 0x01 },
-	{ "FORCEBUSFREE",	0x10, 0x10 },
-	{ "ENARBO",		0x20, 0x20 },
-	{ "ENSELO",		0x40, 0x40 },
-	{ "TEMODEO",		0x80, 0x80 }
-};
-
-int
-ahd_scsiseq0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SCSISEQ0_parse_table, 5, "SCSISEQ0",
-	    0x3a, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SCSISEQ1_parse_table[] = {
-	{ "ALTSTIM",		0x01, 0x01 },
-	{ "ENAUTOATNP",		0x02, 0x02 },
-	{ "MANUALP",		0x0c, 0x0c },
-	{ "ENRSELI",		0x10, 0x10 },
-	{ "ENSELI",		0x20, 0x20 },
-	{ "MANUALCTL",		0x40, 0x40 }
-};
-
-int
-ahd_scsiseq1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SCSISEQ1_parse_table, 6, "SCSISEQ1",
-	    0x3b, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SXFRCTL0_parse_table[] = {
-	{ "SPIOEN",		0x08, 0x08 },
-	{ "BIOSCANCELEN",	0x10, 0x10 },
-	{ "DFPEXP",		0x40, 0x40 },
-	{ "DFON",		0x80, 0x80 }
-};
-
-int
-ahd_sxfrctl0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SXFRCTL0_parse_table, 4, "SXFRCTL0",
-	    0x3c, regvalue, cur_col, wrap));
-}
-
-int
-ahd_businitid_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "BUSINITID",
-	    0x3c, regvalue, cur_col, wrap));
-}
-
-int
-ahd_dlcount_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "DLCOUNT",
-	    0x3c, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SXFRCTL1_parse_table[] = {
-	{ "STPWEN",		0x01, 0x01 },
-	{ "ACTNEGEN",		0x02, 0x02 },
-	{ "ENSTIMER",		0x04, 0x04 },
-	{ "STIMESEL",		0x18, 0x18 },
-	{ "ENSPCHK",		0x20, 0x20 },
-	{ "ENSACHK",		0x40, 0x40 },
-	{ "BITBUCKET",		0x80, 0x80 }
-};
-
-int
-ahd_sxfrctl1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SXFRCTL1_parse_table, 7, "SXFRCTL1",
-	    0x3d, regvalue, cur_col, wrap));
-}
-
-int
-ahd_bustargid_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "BUSTARGID",
-	    0x3e, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SXFRCTL2_parse_table[] = {
-	{ "ASU",		0x07, 0x07 },
-	{ "CMDDMAEN",		0x08, 0x08 },
-	{ "AUTORSTDIS",		0x10, 0x10 }
-};
-
-int
-ahd_sxfrctl2_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SXFRCTL2_parse_table, 3, "SXFRCTL2",
-	    0x3e, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DFFSTAT_parse_table[] = {
-	{ "CURRFIFO_0",		0x00, 0x03 },
-	{ "CURRFIFO_1",		0x01, 0x03 },
-	{ "CURRFIFO_NONE",	0x03, 0x03 },
-	{ "FIFO0FREE",		0x10, 0x10 },
-	{ "FIFO1FREE",		0x20, 0x20 },
-	{ "CURRFIFO",		0x03, 0x03 }
-};
-
-int
-ahd_dffstat_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DFFSTAT_parse_table, 6, "DFFSTAT",
-	    0x3f, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SCSISIGO_parse_table[] = {
-	{ "P_DATAOUT",		0x00, 0xe0 },
-	{ "P_DATAOUT_DT",	0x20, 0xe0 },
-	{ "P_DATAIN",		0x40, 0xe0 },
-	{ "P_DATAIN_DT",	0x60, 0xe0 },
-	{ "P_COMMAND",		0x80, 0xe0 },
-	{ "P_MESGOUT",		0xa0, 0xe0 },
-	{ "P_STATUS",		0xc0, 0xe0 },
-	{ "P_MESGIN",		0xe0, 0xe0 },
-	{ "ACKO",		0x01, 0x01 },
-	{ "REQO",		0x02, 0x02 },
-	{ "BSYO",		0x04, 0x04 },
-	{ "SELO",		0x08, 0x08 },
-	{ "ATNO",		0x10, 0x10 },
-	{ "MSGO",		0x20, 0x20 },
-	{ "IOO",		0x40, 0x40 },
-	{ "CDO",		0x80, 0x80 },
-	{ "PHASE_MASK",		0xe0, 0xe0 }
-};
-
-int
-ahd_scsisigo_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SCSISIGO_parse_table, 17, "SCSISIGO",
-	    0x40, regvalue, cur_col, wrap));
-}
-
-int
-ahd_multargid_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "MULTARGID",
-	    0x40, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SCSISIGI_parse_table[] = {
-	{ "P_DATAOUT",		0x00, 0xe0 },
-	{ "P_DATAOUT_DT",	0x20, 0xe0 },
-	{ "P_DATAIN",		0x40, 0xe0 },
-	{ "P_DATAIN_DT",	0x60, 0xe0 },
-	{ "P_COMMAND",		0x80, 0xe0 },
-	{ "P_MESGOUT",		0xa0, 0xe0 },
-	{ "P_STATUS",		0xc0, 0xe0 },
-	{ "P_MESGIN",		0xe0, 0xe0 },
-	{ "ACKI",		0x01, 0x01 },
-	{ "REQI",		0x02, 0x02 },
-	{ "BSYI",		0x04, 0x04 },
-	{ "SELI",		0x08, 0x08 },
-	{ "ATNI",		0x10, 0x10 },
-	{ "MSGI",		0x20, 0x20 },
-	{ "IOI",		0x40, 0x40 },
-	{ "CDI",		0x80, 0x80 },
-	{ "PHASE_MASK",		0xe0, 0xe0 }
-};
-
-int
-ahd_scsisigi_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SCSISIGI_parse_table, 17, "SCSISIGI",
-	    0x41, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SCSIPHASE_parse_table[] = {
-	{ "DATA_OUT_PHASE",	0x01, 0x03 },
-	{ "DATA_IN_PHASE",	0x02, 0x03 },
-	{ "DATA_PHASE_MASK",	0x03, 0x03 },
-	{ "MSG_OUT_PHASE",	0x04, 0x04 },
-	{ "MSG_IN_PHASE",	0x08, 0x08 },
-	{ "COMMAND_PHASE",	0x10, 0x10 },
-	{ "STATUS_PHASE",	0x20, 0x20 }
-};
-
-int
-ahd_scsiphase_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SCSIPHASE_parse_table, 7, "SCSIPHASE",
-	    0x42, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scsidat0_img_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCSIDAT0_IMG",
-	    0x43, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scsidat_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCSIDAT",
-	    0x44, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scsibus_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCSIBUS",
-	    0x46, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t TARGIDIN_parse_table[] = {
-	{ "TARGID",		0x0f, 0x0f },
-	{ "CLKOUT",		0x80, 0x80 }
-};
-
-int
-ahd_targidin_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(TARGIDIN_parse_table, 2, "TARGIDIN",
-	    0x48, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SELID_parse_table[] = {
-	{ "ONEBIT",		0x08, 0x08 },
-	{ "SELID_MASK",		0xf0, 0xf0 }
-};
-
-int
-ahd_selid_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SELID_parse_table, 2, "SELID",
-	    0x49, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SBLKCTL_parse_table[] = {
-	{ "SELWIDE",		0x02, 0x02 },
-	{ "ENAB20",		0x04, 0x04 },
-	{ "ENAB40",		0x08, 0x08 },
-	{ "DIAGLEDON",		0x40, 0x40 },
-	{ "DIAGLEDEN",		0x80, 0x80 }
-};
-
-int
-ahd_sblkctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SBLKCTL_parse_table, 5, "SBLKCTL",
-	    0x4a, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t OPTIONMODE_parse_table[] = {
-	{ "AUTO_MSGOUT_DE",	0x02, 0x02 },
-	{ "ENDGFORMCHK",	0x04, 0x04 },
-	{ "BUSFREEREV",		0x10, 0x10 },
-	{ "BIASCANCTL",		0x20, 0x20 },
-	{ "AUTOACKEN",		0x40, 0x40 },
-	{ "BIOSCANCTL",		0x80, 0x80 },
-	{ "OPTIONMODE_DEFAULTS",0x02, 0x02 }
-};
-
-int
-ahd_optionmode_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(OPTIONMODE_parse_table, 7, "OPTIONMODE",
-	    0x4a, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SSTAT0_parse_table[] = {
-	{ "ARBDO",		0x01, 0x01 },
-	{ "SPIORDY",		0x02, 0x02 },
-	{ "OVERRUN",		0x04, 0x04 },
-	{ "IOERR",		0x08, 0x08 },
-	{ "SELINGO",		0x10, 0x10 },
-	{ "SELDI",		0x20, 0x20 },
-	{ "SELDO",		0x40, 0x40 },
-	{ "TARGET",		0x80, 0x80 }
-};
-
-int
-ahd_sstat0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SSTAT0_parse_table, 8, "SSTAT0",
-	    0x4b, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CLRSINT0_parse_table[] = {
-	{ "CLRARBDO",		0x01, 0x01 },
-	{ "CLRSPIORDY",		0x02, 0x02 },
-	{ "CLROVERRUN",		0x04, 0x04 },
-	{ "CLRIOERR",		0x08, 0x08 },
-	{ "CLRSELINGO",		0x10, 0x10 },
-	{ "CLRSELDI",		0x20, 0x20 },
-	{ "CLRSELDO",		0x40, 0x40 }
-};
-
-int
-ahd_clrsint0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CLRSINT0_parse_table, 7, "CLRSINT0",
-	    0x4b, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SIMODE0_parse_table[] = {
-	{ "ENARBDO",		0x01, 0x01 },
-	{ "ENSPIORDY",		0x02, 0x02 },
-	{ "ENOVERRUN",		0x04, 0x04 },
-	{ "ENIOERR",		0x08, 0x08 },
-	{ "ENSELINGO",		0x10, 0x10 },
-	{ "ENSELDI",		0x20, 0x20 },
-	{ "ENSELDO",		0x40, 0x40 }
-};
-
-int
-ahd_simode0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SIMODE0_parse_table, 7, "SIMODE0",
-	    0x4b, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CLRSINT1_parse_table[] = {
-	{ "CLRREQINIT",		0x01, 0x01 },
-	{ "CLRSTRB2FAST",	0x02, 0x02 },
-	{ "CLRSCSIPERR",	0x04, 0x04 },
-	{ "CLRBUSFREE",		0x08, 0x08 },
-	{ "CLRSCSIRSTI",	0x20, 0x20 },
-	{ "CLRATNO",		0x40, 0x40 },
-	{ "CLRSELTIMEO",	0x80, 0x80 }
-};
-
-int
-ahd_clrsint1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CLRSINT1_parse_table, 7, "CLRSINT1",
-	    0x4c, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SSTAT1_parse_table[] = {
-	{ "REQINIT",		0x01, 0x01 },
-	{ "STRB2FAST",		0x02, 0x02 },
-	{ "SCSIPERR",		0x04, 0x04 },
-	{ "BUSFREE",		0x08, 0x08 },
-	{ "PHASEMIS",		0x10, 0x10 },
-	{ "SCSIRSTI",		0x20, 0x20 },
-	{ "ATNTARG",		0x40, 0x40 },
-	{ "SELTO",		0x80, 0x80 }
-};
-
-int
-ahd_sstat1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SSTAT1_parse_table, 8, "SSTAT1",
-	    0x4c, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SSTAT2_parse_table[] = {
-	{ "BUSFREE_LQO",	0x40, 0xc0 },
-	{ "BUSFREE_DFF0",	0x80, 0xc0 },
-	{ "BUSFREE_DFF1",	0xc0, 0xc0 },
-	{ "DMADONE",		0x01, 0x01 },
-	{ "SDONE",		0x02, 0x02 },
-	{ "WIDE_RES",		0x04, 0x04 },
-	{ "BSYX",		0x08, 0x08 },
-	{ "EXP_ACTIVE",		0x10, 0x10 },
-	{ "NONPACKREQ",		0x20, 0x20 },
-	{ "BUSFREETIME",	0xc0, 0xc0 }
-};
-
-int
-ahd_sstat2_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SSTAT2_parse_table, 10, "SSTAT2",
-	    0x4d, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CLRSINT2_parse_table[] = {
-	{ "CLRDMADONE",		0x01, 0x01 },
-	{ "CLRSDONE",		0x02, 0x02 },
-	{ "CLRWIDE_RES",	0x04, 0x04 },
-	{ "CLRNONPACKREQ",	0x20, 0x20 }
-};
-
-int
-ahd_clrsint2_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CLRSINT2_parse_table, 4, "CLRSINT2",
-	    0x4d, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SIMODE2_parse_table[] = {
-	{ "ENDMADONE",		0x01, 0x01 },
-	{ "ENSDONE",		0x02, 0x02 },
-	{ "ENWIDE_RES",		0x04, 0x04 }
-};
-
-int
-ahd_simode2_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SIMODE2_parse_table, 3, "SIMODE2",
-	    0x4d, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t PERRDIAG_parse_table[] = {
-	{ "DTERR",		0x01, 0x01 },
-	{ "DGFORMERR",		0x02, 0x02 },
-	{ "CRCERR",		0x04, 0x04 },
-	{ "AIPERR",		0x08, 0x08 },
-	{ "PARITYERR",		0x10, 0x10 },
-	{ "PREVPHASE",		0x20, 0x20 },
-	{ "HIPERR",		0x40, 0x40 },
-	{ "HIZERO",		0x80, 0x80 }
-};
-
-int
-ahd_perrdiag_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(PERRDIAG_parse_table, 8, "PERRDIAG",
-	    0x4e, regvalue, cur_col, wrap));
-}
-
-int
-ahd_lqistate_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "LQISTATE",
-	    0x4e, regvalue, cur_col, wrap));
-}
-
-int
-ahd_soffcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SOFFCNT",
-	    0x4f, regvalue, cur_col, wrap));
-}
-
-int
-ahd_lqostate_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "LQOSTATE",
-	    0x4f, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t LQISTAT0_parse_table[] = {
-	{ "LQIATNCMD",		0x01, 0x01 },
-	{ "LQIATNLQ",		0x02, 0x02 },
-	{ "LQIBADLQT",		0x04, 0x04 },
-	{ "LQICRCT2",		0x08, 0x08 },
-	{ "LQICRCT1",		0x10, 0x10 },
-	{ "LQIATNQAS",		0x20, 0x20 }
-};
-
-int
-ahd_lqistat0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(LQISTAT0_parse_table, 6, "LQISTAT0",
-	    0x50, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CLRLQIINT0_parse_table[] = {
-	{ "CLRLQIATNCMD",	0x01, 0x01 },
-	{ "CLRLQIATNLQ",	0x02, 0x02 },
-	{ "CLRLQIBADLQT",	0x04, 0x04 },
-	{ "CLRLQICRCT2",	0x08, 0x08 },
-	{ "CLRLQICRCT1",	0x10, 0x10 },
-	{ "CLRLQIATNQAS",	0x20, 0x20 }
-};
-
-int
-ahd_clrlqiint0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CLRLQIINT0_parse_table, 6, "CLRLQIINT0",
-	    0x50, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t LQIMODE0_parse_table[] = {
-	{ "ENLQIATNCMD",	0x01, 0x01 },
-	{ "ENLQIATNLQ",		0x02, 0x02 },
-	{ "ENLQIBADLQT",	0x04, 0x04 },
-	{ "ENLQICRCT2",		0x08, 0x08 },
-	{ "ENLQICRCT1",		0x10, 0x10 },
-	{ "ENLQIATNQASK",	0x20, 0x20 }
-};
-
-int
-ahd_lqimode0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(LQIMODE0_parse_table, 6, "LQIMODE0",
-	    0x50, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t LQIMODE1_parse_table[] = {
-	{ "ENLQIOVERI_NLQ",	0x01, 0x01 },
-	{ "ENLQIOVERI_LQ",	0x02, 0x02 },
-	{ "ENLQIBADLQI",	0x04, 0x04 },
-	{ "ENLQICRCI_NLQ",	0x08, 0x08 },
-	{ "ENLQICRCI_LQ",	0x10, 0x10 },
-	{ "ENLIQABORT",		0x20, 0x20 },
-	{ "ENLQIPHASE_NLQ",	0x40, 0x40 },
-	{ "ENLQIPHASE_LQ",	0x80, 0x80 }
-};
-
-int
-ahd_lqimode1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(LQIMODE1_parse_table, 8, "LQIMODE1",
-	    0x51, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t LQISTAT1_parse_table[] = {
-	{ "LQIOVERI_NLQ",	0x01, 0x01 },
-	{ "LQIOVERI_LQ",	0x02, 0x02 },
-	{ "LQIBADLQI",		0x04, 0x04 },
-	{ "LQICRCI_NLQ",	0x08, 0x08 },
-	{ "LQICRCI_LQ",		0x10, 0x10 },
-	{ "LQIABORT",		0x20, 0x20 },
-	{ "LQIPHASE_NLQ",	0x40, 0x40 },
-	{ "LQIPHASE_LQ",	0x80, 0x80 }
-};
-
-int
-ahd_lqistat1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(LQISTAT1_parse_table, 8, "LQISTAT1",
-	    0x51, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CLRLQIINT1_parse_table[] = {
-	{ "CLRLQIOVERI_NLQ",	0x01, 0x01 },
-	{ "CLRLQIOVERI_LQ",	0x02, 0x02 },
-	{ "CLRLQIBADLQI",	0x04, 0x04 },
-	{ "CLRLQICRCI_NLQ",	0x08, 0x08 },
-	{ "CLRLQICRCI_LQ",	0x10, 0x10 },
-	{ "CLRLIQABORT",	0x20, 0x20 },
-	{ "CLRLQIPHASE_NLQ",	0x40, 0x40 },
-	{ "CLRLQIPHASE_LQ",	0x80, 0x80 }
-};
-
-int
-ahd_clrlqiint1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CLRLQIINT1_parse_table, 8, "CLRLQIINT1",
-	    0x51, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t LQISTAT2_parse_table[] = {
-	{ "LQIGSAVAIL",		0x01, 0x01 },
-	{ "LQISTOPCMD",		0x02, 0x02 },
-	{ "LQISTOPLQ",		0x04, 0x04 },
-	{ "LQISTOPPKT",		0x08, 0x08 },
-	{ "LQIWAITFIFO",	0x10, 0x10 },
-	{ "LQIWORKONLQ",	0x20, 0x20 },
-	{ "LQIPHASE_OUTPKT",	0x40, 0x40 },
-	{ "PACKETIZED",		0x80, 0x80 }
-};
-
-int
-ahd_lqistat2_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(LQISTAT2_parse_table, 8, "LQISTAT2",
-	    0x52, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SSTAT3_parse_table[] = {
-	{ "OSRAMPERR",		0x01, 0x01 },
-	{ "NTRAMPERR",		0x02, 0x02 }
-};
-
-int
-ahd_sstat3_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SSTAT3_parse_table, 2, "SSTAT3",
-	    0x53, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SIMODE3_parse_table[] = {
-	{ "ENOSRAMPERR",	0x01, 0x01 },
-	{ "ENNTRAMPERR",	0x02, 0x02 }
-};
-
-int
-ahd_simode3_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SIMODE3_parse_table, 2, "SIMODE3",
-	    0x53, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CLRSINT3_parse_table[] = {
-	{ "CLROSRAMPERR",	0x01, 0x01 },
-	{ "CLRNTRAMPERR",	0x02, 0x02 }
-};
-
-int
-ahd_clrsint3_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CLRSINT3_parse_table, 2, "CLRSINT3",
-	    0x53, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t LQOMODE0_parse_table[] = {
-	{ "ENLQOTCRC",		0x01, 0x01 },
-	{ "ENLQOATNPKT",	0x02, 0x02 },
-	{ "ENLQOATNLQ",		0x04, 0x04 },
-	{ "ENLQOSTOPT2",	0x08, 0x08 },
-	{ "ENLQOTARGSCBPERR",	0x10, 0x10 }
-};
-
-int
-ahd_lqomode0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(LQOMODE0_parse_table, 5, "LQOMODE0",
-	    0x54, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t LQOSTAT0_parse_table[] = {
-	{ "LQOTCRC",		0x01, 0x01 },
-	{ "LQOATNPKT",		0x02, 0x02 },
-	{ "LQOATNLQ",		0x04, 0x04 },
-	{ "LQOSTOPT2",		0x08, 0x08 },
-	{ "LQOTARGSCBPERR",	0x10, 0x10 }
-};
-
-int
-ahd_lqostat0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(LQOSTAT0_parse_table, 5, "LQOSTAT0",
-	    0x54, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CLRLQOINT0_parse_table[] = {
-	{ "CLRLQOTCRC",		0x01, 0x01 },
-	{ "CLRLQOATNPKT",	0x02, 0x02 },
-	{ "CLRLQOATNLQ",	0x04, 0x04 },
-	{ "CLRLQOSTOPT2",	0x08, 0x08 },
-	{ "CLRLQOTARGSCBPERR",	0x10, 0x10 }
-};
-
-int
-ahd_clrlqoint0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CLRLQOINT0_parse_table, 5, "CLRLQOINT0",
-	    0x54, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t LQOSTAT1_parse_table[] = {
-	{ "LQOPHACHGINPKT",	0x01, 0x01 },
-	{ "LQOBUSFREE",		0x02, 0x02 },
-	{ "LQOBADQAS",		0x04, 0x04 },
-	{ "LQOSTOPI2",		0x08, 0x08 },
-	{ "LQOINITSCBPERR",	0x10, 0x10 }
-};
-
-int
-ahd_lqostat1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(LQOSTAT1_parse_table, 5, "LQOSTAT1",
-	    0x55, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CLRLQOINT1_parse_table[] = {
-	{ "CLRLQOPHACHGINPKT",	0x01, 0x01 },
-	{ "CLRLQOBUSFREE",	0x02, 0x02 },
-	{ "CLRLQOBADQAS",	0x04, 0x04 },
-	{ "CLRLQOSTOPI2",	0x08, 0x08 },
-	{ "CLRLQOINITSCBPERR",	0x10, 0x10 }
-};
-
-int
-ahd_clrlqoint1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CLRLQOINT1_parse_table, 5, "CLRLQOINT1",
-	    0x55, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t LQOMODE1_parse_table[] = {
-	{ "ENLQOPHACHGINPKT",	0x01, 0x01 },
-	{ "ENLQOBUSFREE",	0x02, 0x02 },
-	{ "ENLQOBADQAS",	0x04, 0x04 },
-	{ "ENLQOSTOPI2",	0x08, 0x08 },
-	{ "ENLQOINITSCBPERR",	0x10, 0x10 }
-};
-
-int
-ahd_lqomode1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(LQOMODE1_parse_table, 5, "LQOMODE1",
-	    0x55, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t LQOSTAT2_parse_table[] = {
-	{ "LQOSTOP0",		0x01, 0x01 },
-	{ "LQOPHACHGOUTPKT",	0x02, 0x02 },
-	{ "LQOWAITFIFO",	0x10, 0x10 },
-	{ "LQOPKT",		0xe0, 0xe0 }
-};
-
-int
-ahd_lqostat2_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(LQOSTAT2_parse_table, 4, "LQOSTAT2",
-	    0x56, regvalue, cur_col, wrap));
-}
-
-int
-ahd_os_space_cnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "OS_SPACE_CNT",
-	    0x56, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SIMODE1_parse_table[] = {
-	{ "ENREQINIT",		0x01, 0x01 },
-	{ "ENSTRB2FAST",	0x02, 0x02 },
-	{ "ENSCSIPERR",		0x04, 0x04 },
-	{ "ENBUSFREE",		0x08, 0x08 },
-	{ "ENPHASEMIS",		0x10, 0x10 },
-	{ "ENSCSIRST",		0x20, 0x20 },
-	{ "ENATNTARG",		0x40, 0x40 },
-	{ "ENSELTIMO",		0x80, 0x80 }
-};
-
-int
-ahd_simode1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SIMODE1_parse_table, 8, "SIMODE1",
-	    0x57, regvalue, cur_col, wrap));
-}
-
-int
-ahd_gsfifo_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "GSFIFO",
-	    0x58, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DFFSXFRCTL_parse_table[] = {
-	{ "RSTCHN",		0x01, 0x01 },
-	{ "CLRCHN",		0x02, 0x02 },
-	{ "CLRSHCNT",		0x04, 0x04 },
-	{ "DFFBITBUCKET",	0x08, 0x08 }
-};
-
-int
-ahd_dffsxfrctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DFFSXFRCTL_parse_table, 4, "DFFSXFRCTL",
-	    0x5a, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t LQOSCSCTL_parse_table[] = {
-	{ "LQONOCHKOVER",	0x01, 0x01 },
-	{ "LQOH2A_VERSION",	0x80, 0x80 }
-};
-
-int
-ahd_lqoscsctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(LQOSCSCTL_parse_table, 2, "LQOSCSCTL",
-	    0x5a, regvalue, cur_col, wrap));
-}
-
-int
-ahd_nextscb_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "NEXTSCB",
-	    0x5a, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CLRSEQINTSRC_parse_table[] = {
-	{ "CLRCFG4TCMD",	0x01, 0x01 },
-	{ "CLRCFG4ICMD",	0x02, 0x02 },
-	{ "CLRCFG4TSTAT",	0x04, 0x04 },
-	{ "CLRCFG4ISTAT",	0x08, 0x08 },
-	{ "CLRCFG4DATA",	0x10, 0x10 },
-	{ "CLRSAVEPTRS",	0x20, 0x20 },
-	{ "CLRCTXTDONE",	0x40, 0x40 }
-};
-
-int
-ahd_clrseqintsrc_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CLRSEQINTSRC_parse_table, 7, "CLRSEQINTSRC",
-	    0x5b, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SEQINTSRC_parse_table[] = {
-	{ "CFG4TCMD",		0x01, 0x01 },
-	{ "CFG4ICMD",		0x02, 0x02 },
-	{ "CFG4TSTAT",		0x04, 0x04 },
-	{ "CFG4ISTAT",		0x08, 0x08 },
-	{ "CFG4DATA",		0x10, 0x10 },
-	{ "SAVEPTRS",		0x20, 0x20 },
-	{ "CTXTDONE",		0x40, 0x40 }
-};
-
-int
-ahd_seqintsrc_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SEQINTSRC_parse_table, 7, "SEQINTSRC",
-	    0x5b, regvalue, cur_col, wrap));
-}
-
-int
-ahd_currscb_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "CURRSCB",
-	    0x5c, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SEQIMODE_parse_table[] = {
-	{ "ENCFG4TCMD",		0x01, 0x01 },
-	{ "ENCFG4ICMD",		0x02, 0x02 },
-	{ "ENCFG4TSTAT",	0x04, 0x04 },
-	{ "ENCFG4ISTAT",	0x08, 0x08 },
-	{ "ENCFG4DATA",		0x10, 0x10 },
-	{ "ENSAVEPTRS",		0x20, 0x20 },
-	{ "ENCTXTDONE",		0x40, 0x40 }
-};
-
-int
-ahd_seqimode_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SEQIMODE_parse_table, 7, "SEQIMODE",
-	    0x5c, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t MDFFSTAT_parse_table[] = {
-	{ "FIFOFREE",		0x01, 0x01 },
-	{ "DATAINFIFO",		0x02, 0x02 },
-	{ "DLZERO",		0x04, 0x04 },
-	{ "SHVALID",		0x08, 0x08 },
-	{ "LASTSDONE",		0x10, 0x10 },
-	{ "SHCNTMINUS1",	0x20, 0x20 },
-	{ "SHCNTNEGATIVE",	0x40, 0x40 }
-};
-
-int
-ahd_mdffstat_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(MDFFSTAT_parse_table, 7, "MDFFSTAT",
-	    0x5d, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CRCCONTROL_parse_table[] = {
-	{ "CRCVALCHKEN",	0x40, 0x40 }
-};
-
-int
-ahd_crccontrol_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CRCCONTROL_parse_table, 1, "CRCCONTROL",
-	    0x5d, regvalue, cur_col, wrap));
-}
-
-int
-ahd_dfftag_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "DFFTAG",
-	    0x5e, regvalue, cur_col, wrap));
-}
-
-int
-ahd_lastscb_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "LASTSCB",
-	    0x5e, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SCSITEST_parse_table[] = {
-	{ "SEL_TXPLL_DEBUG",	0x04, 0x04 },
-	{ "CNTRTEST",		0x08, 0x08 }
-};
-
-int
-ahd_scsitest_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SCSITEST_parse_table, 2, "SCSITEST",
-	    0x5e, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t IOPDNCTL_parse_table[] = {
-	{ "PDN_DIFFSENSE",	0x01, 0x01 },
-	{ "PDN_IDIST",		0x04, 0x04 },
-	{ "DISABLE_OE",		0x80, 0x80 }
-};
-
-int
-ahd_iopdnctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(IOPDNCTL_parse_table, 3, "IOPDNCTL",
-	    0x5f, regvalue, cur_col, wrap));
-}
-
-int
-ahd_shaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SHADDR",
-	    0x60, regvalue, cur_col, wrap));
-}
-
-int
-ahd_negoaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "NEGOADDR",
-	    0x60, regvalue, cur_col, wrap));
-}
-
-int
-ahd_dgrpcrci_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "DGRPCRCI",
-	    0x60, regvalue, cur_col, wrap));
-}
-
-int
-ahd_negperiod_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "NEGPERIOD",
-	    0x61, regvalue, cur_col, wrap));
-}
-
-int
-ahd_packcrci_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "PACKCRCI",
-	    0x62, regvalue, cur_col, wrap));
-}
-
-int
-ahd_negoffset_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "NEGOFFSET",
-	    0x62, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t NEGPPROPTS_parse_table[] = {
-	{ "PPROPT_IUT",		0x01, 0x01 },
-	{ "PPROPT_DT",		0x02, 0x02 },
-	{ "PPROPT_QAS",		0x04, 0x04 },
-	{ "PPROPT_PACE",	0x08, 0x08 }
-};
-
-int
-ahd_negppropts_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NEGPPROPTS_parse_table, 4, "NEGPPROPTS",
-	    0x63, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t NEGCONOPTS_parse_table[] = {
-	{ "WIDEXFER",		0x01, 0x01 },
-	{ "ENAUTOATNO",		0x02, 0x02 },
-	{ "ENAUTOATNI",		0x04, 0x04 },
-	{ "ENSLOWCRC",		0x08, 0x08 },
-	{ "RTI_OVRDTRN",	0x10, 0x10 },
-	{ "RTI_WRTDIS",		0x20, 0x20 },
-	{ "ENSNAPSHOT",		0x40, 0x40 }
-};
-
-int
-ahd_negconopts_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NEGCONOPTS_parse_table, 7, "NEGCONOPTS",
-	    0x64, regvalue, cur_col, wrap));
-}
-
-int
-ahd_annexcol_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "ANNEXCOL",
-	    0x65, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SCSCHKN_parse_table[] = {
-	{ "LSTSGCLRDIS",	0x01, 0x01 },
-	{ "SHVALIDSTDIS",	0x02, 0x02 },
-	{ "DFFACTCLR",		0x04, 0x04 },
-	{ "SDONEMSKDIS",	0x08, 0x08 },
-	{ "WIDERESEN",		0x10, 0x10 },
-	{ "CURRFIFODEF",	0x20, 0x20 },
-	{ "STSELSKIDDIS",	0x40, 0x40 }
-};
-
-int
-ahd_scschkn_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SCSCHKN_parse_table, 7, "SCSCHKN",
-	    0x66, regvalue, cur_col, wrap));
-}
-
-int
-ahd_annexdat_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "ANNEXDAT",
-	    0x66, regvalue, cur_col, wrap));
-}
-
-int
-ahd_iownid_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "IOWNID",
-	    0x67, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t PLL960CTL0_parse_table[] = {
-	{ "PLL_ENFBM",		0x01, 0x01 },
-	{ "PLL_DLPF",		0x02, 0x02 },
-	{ "PLL_ENLPF",		0x04, 0x04 },
-	{ "PLL_ENLUD",		0x08, 0x08 },
-	{ "PLL_NS",		0x30, 0x30 },
-	{ "PLL_PWDN",		0x40, 0x40 },
-	{ "PLL_VCOSEL",		0x80, 0x80 }
-};
-
-int
-ahd_pll960ctl0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(PLL960CTL0_parse_table, 7, "PLL960CTL0",
-	    0x68, regvalue, cur_col, wrap));
-}
-
-int
-ahd_shcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SHCNT",
-	    0x68, regvalue, cur_col, wrap));
-}
-
-int
-ahd_townid_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "TOWNID",
-	    0x69, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t PLL960CTL1_parse_table[] = {
-	{ "PLL_RST",		0x01, 0x01 },
-	{ "PLL_CNTCLR",		0x40, 0x40 },
-	{ "PLL_CNTEN",		0x80, 0x80 }
-};
-
-int
-ahd_pll960ctl1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(PLL960CTL1_parse_table, 3, "PLL960CTL1",
-	    0x69, regvalue, cur_col, wrap));
-}
-
-int
-ahd_pll960cnt0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "PLL960CNT0",
-	    0x6a, regvalue, cur_col, wrap));
-}
-
-int
-ahd_xsig_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "XSIG",
-	    0x6a, regvalue, cur_col, wrap));
-}
-
-int
-ahd_seloid_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SELOID",
-	    0x6b, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t PLL400CTL0_parse_table[] = {
-	{ "PLL_ENFBM",		0x01, 0x01 },
-	{ "PLL_DLPF",		0x02, 0x02 },
-	{ "PLL_ENLPF",		0x04, 0x04 },
-	{ "PLL_ENLUD",		0x08, 0x08 },
-	{ "PLL_NS",		0x30, 0x30 },
-	{ "PLL_PWDN",		0x40, 0x40 },
-	{ "PLL_VCOSEL",		0x80, 0x80 }
-};
-
-int
-ahd_pll400ctl0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(PLL400CTL0_parse_table, 7, "PLL400CTL0",
-	    0x6c, regvalue, cur_col, wrap));
-}
-
-int
-ahd_fairness_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "FAIRNESS",
-	    0x6c, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t PLL400CTL1_parse_table[] = {
-	{ "PLL_RST",		0x01, 0x01 },
-	{ "PLL_CNTCLR",		0x40, 0x40 },
-	{ "PLL_CNTEN",		0x80, 0x80 }
-};
-
-int
-ahd_pll400ctl1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(PLL400CTL1_parse_table, 3, "PLL400CTL1",
-	    0x6d, regvalue, cur_col, wrap));
-}
-
-int
-ahd_pll400cnt0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "PLL400CNT0",
-	    0x6e, regvalue, cur_col, wrap));
-}
-
-int
-ahd_unfairness_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "UNFAIRNESS",
-	    0x6e, regvalue, cur_col, wrap));
-}
-
-int
-ahd_haddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "HADDR",
-	    0x70, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t PLLDELAY_parse_table[] = {
-	{ "SPLIT_DROP_REQ",	0x80, 0x80 }
-};
-
-int
-ahd_plldelay_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(PLLDELAY_parse_table, 1, "PLLDELAY",
-	    0x70, regvalue, cur_col, wrap));
-}
-
-int
-ahd_hodmaadr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "HODMAADR",
-	    0x70, regvalue, cur_col, wrap));
-}
-
-int
-ahd_hodmacnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "HODMACNT",
-	    0x78, regvalue, cur_col, wrap));
-}
-
-int
-ahd_hcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "HCNT",
-	    0x78, regvalue, cur_col, wrap));
-}
-
-int
-ahd_hodmaen_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "HODMAEN",
-	    0x7a, regvalue, cur_col, wrap));
-}
-
-int
-ahd_sghaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SGHADDR",
-	    0x7c, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scbhaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCBHADDR",
-	    0x7c, regvalue, cur_col, wrap));
-}
-
-int
-ahd_sghcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SGHCNT",
-	    0x84, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scbhcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCBHCNT",
-	    0x84, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DFF_THRSH_parse_table[] = {
-	{ "WR_DFTHRSH_MIN",	0x00, 0x70 },
-	{ "RD_DFTHRSH_MIN",	0x00, 0x07 },
-	{ "RD_DFTHRSH_25",	0x01, 0x07 },
-	{ "RD_DFTHRSH_50",	0x02, 0x07 },
-	{ "RD_DFTHRSH_63",	0x03, 0x07 },
-	{ "RD_DFTHRSH_75",	0x04, 0x07 },
-	{ "RD_DFTHRSH_85",	0x05, 0x07 },
-	{ "RD_DFTHRSH_90",	0x06, 0x07 },
-	{ "RD_DFTHRSH_MAX",	0x07, 0x07 },
-	{ "WR_DFTHRSH_25",	0x10, 0x70 },
-	{ "WR_DFTHRSH_50",	0x20, 0x70 },
-	{ "WR_DFTHRSH_63",	0x30, 0x70 },
-	{ "WR_DFTHRSH_75",	0x40, 0x70 },
-	{ "WR_DFTHRSH_85",	0x50, 0x70 },
-	{ "WR_DFTHRSH_90",	0x60, 0x70 },
-	{ "WR_DFTHRSH_MAX",	0x70, 0x70 },
-	{ "RD_DFTHRSH",		0x07, 0x07 },
-	{ "WR_DFTHRSH",		0x70, 0x70 }
-};
-
-int
-ahd_dff_thrsh_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DFF_THRSH_parse_table, 18, "DFF_THRSH",
-	    0x88, regvalue, cur_col, wrap));
-}
-
-int
-ahd_romaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "ROMADDR",
-	    0x8a, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t ROMCNTRL_parse_table[] = {
-	{ "RDY",		0x01, 0x01 },
-	{ "REPEAT",		0x02, 0x02 },
-	{ "ROMSPD",		0x18, 0x18 },
-	{ "ROMOP",		0xe0, 0xe0 }
-};
-
-int
-ahd_romcntrl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(ROMCNTRL_parse_table, 4, "ROMCNTRL",
-	    0x8d, regvalue, cur_col, wrap));
-}
-
-int
-ahd_romdata_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "ROMDATA",
-	    0x8e, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CMCRXMSG0_parse_table[] = {
-	{ "CFNUM",		0x07, 0x07 },
-	{ "CDNUM",		0xf8, 0xf8 }
-};
-
-int
-ahd_cmcrxmsg0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CMCRXMSG0_parse_table, 2, "CMCRXMSG0",
-	    0x90, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t ROENABLE_parse_table[] = {
-	{ "DCH0ROEN",		0x01, 0x01 },
-	{ "DCH1ROEN",		0x02, 0x02 },
-	{ "SGROEN",		0x04, 0x04 },
-	{ "CMCROEN",		0x08, 0x08 },
-	{ "OVLYROEN",		0x10, 0x10 },
-	{ "MSIROEN",		0x20, 0x20 }
-};
-
-int
-ahd_roenable_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(ROENABLE_parse_table, 6, "ROENABLE",
-	    0x90, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t OVLYRXMSG0_parse_table[] = {
-	{ "CFNUM",		0x07, 0x07 },
-	{ "CDNUM",		0xf8, 0xf8 }
-};
-
-int
-ahd_ovlyrxmsg0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(OVLYRXMSG0_parse_table, 2, "OVLYRXMSG0",
-	    0x90, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DCHRXMSG0_parse_table[] = {
-	{ "CFNUM",		0x07, 0x07 },
-	{ "CDNUM",		0xf8, 0xf8 }
-};
-
-int
-ahd_dchrxmsg0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DCHRXMSG0_parse_table, 2, "DCHRXMSG0",
-	    0x90, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t OVLYRXMSG1_parse_table[] = {
-	{ "CBNUM",		0xff, 0xff }
-};
-
-int
-ahd_ovlyrxmsg1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(OVLYRXMSG1_parse_table, 1, "OVLYRXMSG1",
-	    0x91, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t NSENABLE_parse_table[] = {
-	{ "DCH0NSEN",		0x01, 0x01 },
-	{ "DCH1NSEN",		0x02, 0x02 },
-	{ "SGNSEN",		0x04, 0x04 },
-	{ "CMCNSEN",		0x08, 0x08 },
-	{ "OVLYNSEN",		0x10, 0x10 },
-	{ "MSINSEN",		0x20, 0x20 }
-};
-
-int
-ahd_nsenable_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NSENABLE_parse_table, 6, "NSENABLE",
-	    0x91, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DCHRXMSG1_parse_table[] = {
-	{ "CBNUM",		0xff, 0xff }
-};
-
-int
-ahd_dchrxmsg1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DCHRXMSG1_parse_table, 1, "DCHRXMSG1",
-	    0x91, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CMCRXMSG1_parse_table[] = {
-	{ "CBNUM",		0xff, 0xff }
-};
-
-int
-ahd_cmcrxmsg1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CMCRXMSG1_parse_table, 1, "CMCRXMSG1",
-	    0x91, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DCHRXMSG2_parse_table[] = {
-	{ "MINDEX",		0xff, 0xff }
-};
-
-int
-ahd_dchrxmsg2_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DCHRXMSG2_parse_table, 1, "DCHRXMSG2",
-	    0x92, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t OVLYRXMSG2_parse_table[] = {
-	{ "MINDEX",		0xff, 0xff }
-};
-
-int
-ahd_ovlyrxmsg2_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(OVLYRXMSG2_parse_table, 1, "OVLYRXMSG2",
-	    0x92, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CMCRXMSG2_parse_table[] = {
-	{ "MINDEX",		0xff, 0xff }
-};
-
-int
-ahd_cmcrxmsg2_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CMCRXMSG2_parse_table, 1, "CMCRXMSG2",
-	    0x92, regvalue, cur_col, wrap));
-}
-
-int
-ahd_ost_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "OST",
-	    0x92, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DCHRXMSG3_parse_table[] = {
-	{ "MCLASS",		0x0f, 0x0f }
-};
-
-int
-ahd_dchrxmsg3_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DCHRXMSG3_parse_table, 1, "DCHRXMSG3",
-	    0x93, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CMCRXMSG3_parse_table[] = {
-	{ "MCLASS",		0x0f, 0x0f }
-};
-
-int
-ahd_cmcrxmsg3_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CMCRXMSG3_parse_table, 1, "CMCRXMSG3",
-	    0x93, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t PCIXCTL_parse_table[] = {
-	{ "CMPABCDIS",		0x01, 0x01 },
-	{ "TSCSERREN",		0x02, 0x02 },
-	{ "SRSPDPEEN",		0x04, 0x04 },
-	{ "SPLTSTADIS",		0x08, 0x08 },
-	{ "SPLTSMADIS",		0x10, 0x10 },
-	{ "UNEXPSCIEN",		0x20, 0x20 },
-	{ "SERRPULSE",		0x80, 0x80 }
-};
-
-int
-ahd_pcixctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(PCIXCTL_parse_table, 7, "PCIXCTL",
-	    0x93, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t OVLYRXMSG3_parse_table[] = {
-	{ "MCLASS",		0x0f, 0x0f }
-};
-
-int
-ahd_ovlyrxmsg3_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(OVLYRXMSG3_parse_table, 1, "OVLYRXMSG3",
-	    0x93, regvalue, cur_col, wrap));
-}
-
-int
-ahd_ovlyseqbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "OVLYSEQBCNT",
-	    0x94, regvalue, cur_col, wrap));
-}
-
-int
-ahd_cmcseqbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "CMCSEQBCNT",
-	    0x94, regvalue, cur_col, wrap));
-}
-
-int
-ahd_dchseqbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "DCHSEQBCNT",
-	    0x94, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CMCSPLTSTAT0_parse_table[] = {
-	{ "RXSPLTRSP",		0x01, 0x01 },
-	{ "RXSCEMSG",		0x02, 0x02 },
-	{ "RXOVRUN",		0x04, 0x04 },
-	{ "CNTNOTCMPLT",	0x08, 0x08 },
-	{ "SCDATBUCKET",	0x10, 0x10 },
-	{ "SCADERR",		0x20, 0x20 },
-	{ "SCBCERR",		0x40, 0x40 },
-	{ "STAETERM",		0x80, 0x80 }
-};
-
-int
-ahd_cmcspltstat0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CMCSPLTSTAT0_parse_table, 8, "CMCSPLTSTAT0",
-	    0x96, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t OVLYSPLTSTAT0_parse_table[] = {
-	{ "RXSPLTRSP",		0x01, 0x01 },
-	{ "RXSCEMSG",		0x02, 0x02 },
-	{ "RXOVRUN",		0x04, 0x04 },
-	{ "CNTNOTCMPLT",	0x08, 0x08 },
-	{ "SCDATBUCKET",	0x10, 0x10 },
-	{ "SCADERR",		0x20, 0x20 },
-	{ "SCBCERR",		0x40, 0x40 },
-	{ "STAETERM",		0x80, 0x80 }
-};
-
-int
-ahd_ovlyspltstat0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(OVLYSPLTSTAT0_parse_table, 8, "OVLYSPLTSTAT0",
-	    0x96, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DCHSPLTSTAT0_parse_table[] = {
-	{ "RXSPLTRSP",		0x01, 0x01 },
-	{ "RXSCEMSG",		0x02, 0x02 },
-	{ "RXOVRUN",		0x04, 0x04 },
-	{ "CNTNOTCMPLT",	0x08, 0x08 },
-	{ "SCDATBUCKET",	0x10, 0x10 },
-	{ "SCADERR",		0x20, 0x20 },
-	{ "SCBCERR",		0x40, 0x40 },
-	{ "STAETERM",		0x80, 0x80 }
-};
-
-int
-ahd_dchspltstat0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DCHSPLTSTAT0_parse_table, 8, "DCHSPLTSTAT0",
-	    0x96, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DCHSPLTSTAT1_parse_table[] = {
-	{ "RXDATABUCKET",	0x01, 0x01 }
-};
-
-int
-ahd_dchspltstat1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DCHSPLTSTAT1_parse_table, 1, "DCHSPLTSTAT1",
-	    0x97, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CMCSPLTSTAT1_parse_table[] = {
-	{ "RXDATABUCKET",	0x01, 0x01 }
-};
-
-int
-ahd_cmcspltstat1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CMCSPLTSTAT1_parse_table, 1, "CMCSPLTSTAT1",
-	    0x97, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t OVLYSPLTSTAT1_parse_table[] = {
-	{ "RXDATABUCKET",	0x01, 0x01 }
-};
-
-int
-ahd_ovlyspltstat1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(OVLYSPLTSTAT1_parse_table, 1, "OVLYSPLTSTAT1",
-	    0x97, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SGRXMSG0_parse_table[] = {
-	{ "CFNUM",		0x07, 0x07 },
-	{ "CDNUM",		0xf8, 0xf8 }
-};
-
-int
-ahd_sgrxmsg0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SGRXMSG0_parse_table, 2, "SGRXMSG0",
-	    0x98, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SLVSPLTOUTADR0_parse_table[] = {
-	{ "LOWER_ADDR",		0x7f, 0x7f }
-};
-
-int
-ahd_slvspltoutadr0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SLVSPLTOUTADR0_parse_table, 1, "SLVSPLTOUTADR0",
-	    0x98, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SGRXMSG1_parse_table[] = {
-	{ "CBNUM",		0xff, 0xff }
-};
-
-int
-ahd_sgrxmsg1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SGRXMSG1_parse_table, 1, "SGRXMSG1",
-	    0x99, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SLVSPLTOUTADR1_parse_table[] = {
-	{ "REQ_FNUM",		0x07, 0x07 },
-	{ "REQ_DNUM",		0xf8, 0xf8 }
-};
-
-int
-ahd_slvspltoutadr1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SLVSPLTOUTADR1_parse_table, 2, "SLVSPLTOUTADR1",
-	    0x99, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SGRXMSG2_parse_table[] = {
-	{ "MINDEX",		0xff, 0xff }
-};
-
-int
-ahd_sgrxmsg2_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SGRXMSG2_parse_table, 1, "SGRXMSG2",
-	    0x9a, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SLVSPLTOUTADR2_parse_table[] = {
-	{ "REQ_BNUM",		0xff, 0xff }
-};
-
-int
-ahd_slvspltoutadr2_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SLVSPLTOUTADR2_parse_table, 1, "SLVSPLTOUTADR2",
-	    0x9a, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SGRXMSG3_parse_table[] = {
-	{ "MCLASS",		0x0f, 0x0f }
-};
-
-int
-ahd_sgrxmsg3_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SGRXMSG3_parse_table, 1, "SGRXMSG3",
-	    0x9b, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SLVSPLTOUTADR3_parse_table[] = {
-	{ "RLXORD",		0x10, 0x10 },
-	{ "TAG_NUM",		0x1f, 0x1f }
-};
-
-int
-ahd_slvspltoutadr3_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SLVSPLTOUTADR3_parse_table, 2, "SLVSPLTOUTADR3",
-	    0x9b, regvalue, cur_col, wrap));
-}
-
-int
-ahd_sgseqbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SGSEQBCNT",
-	    0x9c, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SLVSPLTOUTATTR0_parse_table[] = {
-	{ "LOWER_BCNT",		0xff, 0xff }
-};
-
-int
-ahd_slvspltoutattr0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SLVSPLTOUTATTR0_parse_table, 1, "SLVSPLTOUTATTR0",
-	    0x9c, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SLVSPLTOUTATTR1_parse_table[] = {
-	{ "CMPLT_FNUM",		0x07, 0x07 },
-	{ "CMPLT_DNUM",		0xf8, 0xf8 }
-};
-
-int
-ahd_slvspltoutattr1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SLVSPLTOUTATTR1_parse_table, 2, "SLVSPLTOUTATTR1",
-	    0x9d, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SLVSPLTOUTATTR2_parse_table[] = {
-	{ "CMPLT_BNUM",		0xff, 0xff }
-};
-
-int
-ahd_slvspltoutattr2_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SLVSPLTOUTATTR2_parse_table, 1, "SLVSPLTOUTATTR2",
-	    0x9e, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SGSPLTSTAT0_parse_table[] = {
-	{ "RXSPLTRSP",		0x01, 0x01 },
-	{ "RXSCEMSG",		0x02, 0x02 },
-	{ "RXOVRUN",		0x04, 0x04 },
-	{ "CNTNOTCMPLT",	0x08, 0x08 },
-	{ "SCDATBUCKET",	0x10, 0x10 },
-	{ "SCADERR",		0x20, 0x20 },
-	{ "SCBCERR",		0x40, 0x40 },
-	{ "STAETERM",		0x80, 0x80 }
-};
-
-int
-ahd_sgspltstat0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SGSPLTSTAT0_parse_table, 8, "SGSPLTSTAT0",
-	    0x9e, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SFUNCT_parse_table[] = {
-	{ "TEST_NUM",		0x0f, 0x0f },
-	{ "TEST_GROUP",		0xf0, 0xf0 }
-};
-
-int
-ahd_sfunct_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SFUNCT_parse_table, 2, "SFUNCT",
-	    0x9f, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SGSPLTSTAT1_parse_table[] = {
-	{ "RXDATABUCKET",	0x01, 0x01 }
-};
-
-int
-ahd_sgspltstat1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SGSPLTSTAT1_parse_table, 1, "SGSPLTSTAT1",
-	    0x9f, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DF0PCISTAT_parse_table[] = {
-	{ "DPR",		0x01, 0x01 },
-	{ "TWATERR",		0x02, 0x02 },
-	{ "RDPERR",		0x04, 0x04 },
-	{ "SCAAPERR",		0x08, 0x08 },
-	{ "RTA",		0x10, 0x10 },
-	{ "RMA",		0x20, 0x20 },
-	{ "SSE",		0x40, 0x40 },
-	{ "DPE",		0x80, 0x80 }
-};
-
-int
-ahd_df0pcistat_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DF0PCISTAT_parse_table, 8, "DF0PCISTAT",
-	    0xa0, regvalue, cur_col, wrap));
-}
-
-int
-ahd_reg0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "REG0",
-	    0xa0, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DF1PCISTAT_parse_table[] = {
-	{ "DPR",		0x01, 0x01 },
-	{ "TWATERR",		0x02, 0x02 },
-	{ "RDPERR",		0x04, 0x04 },
-	{ "SCAAPERR",		0x08, 0x08 },
-	{ "RTA",		0x10, 0x10 },
-	{ "RMA",		0x20, 0x20 },
-	{ "SSE",		0x40, 0x40 },
-	{ "DPE",		0x80, 0x80 }
-};
-
-int
-ahd_df1pcistat_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DF1PCISTAT_parse_table, 8, "DF1PCISTAT",
-	    0xa1, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SGPCISTAT_parse_table[] = {
-	{ "DPR",		0x01, 0x01 },
-	{ "RDPERR",		0x04, 0x04 },
-	{ "SCAAPERR",		0x08, 0x08 },
-	{ "RTA",		0x10, 0x10 },
-	{ "RMA",		0x20, 0x20 },
-	{ "SSE",		0x40, 0x40 },
-	{ "DPE",		0x80, 0x80 }
-};
-
-int
-ahd_sgpcistat_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SGPCISTAT_parse_table, 7, "SGPCISTAT",
-	    0xa2, regvalue, cur_col, wrap));
-}
-
-int
-ahd_reg1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "REG1",
-	    0xa2, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CMCPCISTAT_parse_table[] = {
-	{ "DPR",		0x01, 0x01 },
-	{ "TWATERR",		0x02, 0x02 },
-	{ "RDPERR",		0x04, 0x04 },
-	{ "SCAAPERR",		0x08, 0x08 },
-	{ "RTA",		0x10, 0x10 },
-	{ "RMA",		0x20, 0x20 },
-	{ "SSE",		0x40, 0x40 },
-	{ "DPE",		0x80, 0x80 }
-};
-
-int
-ahd_cmcpcistat_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CMCPCISTAT_parse_table, 8, "CMCPCISTAT",
-	    0xa3, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t OVLYPCISTAT_parse_table[] = {
-	{ "DPR",		0x01, 0x01 },
-	{ "RDPERR",		0x04, 0x04 },
-	{ "SCAAPERR",		0x08, 0x08 },
-	{ "RTA",		0x10, 0x10 },
-	{ "RMA",		0x20, 0x20 },
-	{ "SSE",		0x40, 0x40 },
-	{ "DPE",		0x80, 0x80 }
-};
-
-int
-ahd_ovlypcistat_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(OVLYPCISTAT_parse_table, 7, "OVLYPCISTAT",
-	    0xa4, regvalue, cur_col, wrap));
-}
-
-int
-ahd_reg_isr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "REG_ISR",
-	    0xa4, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SG_STATE_parse_table[] = {
-	{ "SEGS_AVAIL",		0x01, 0x01 },
-	{ "LOADING_NEEDED",	0x02, 0x02 },
-	{ "FETCH_INPROG",	0x04, 0x04 }
-};
-
-int
-ahd_sg_state_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SG_STATE_parse_table, 3, "SG_STATE",
-	    0xa6, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t MSIPCISTAT_parse_table[] = {
-	{ "DPR",		0x01, 0x01 },
-	{ "TWATERR",		0x02, 0x02 },
-	{ "CLRPENDMSI",		0x08, 0x08 },
-	{ "RTA",		0x10, 0x10 },
-	{ "RMA",		0x20, 0x20 },
-	{ "SSE",		0x40, 0x40 }
-};
-
-int
-ahd_msipcistat_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(MSIPCISTAT_parse_table, 6, "MSIPCISTAT",
-	    0xa6, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t TARGPCISTAT_parse_table[] = {
-	{ "TWATERR",		0x02, 0x02 },
-	{ "STA",		0x08, 0x08 },
-	{ "SSE",		0x40, 0x40 },
-	{ "DPE",		0x80, 0x80 }
-};
-
-int
-ahd_targpcistat_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(TARGPCISTAT_parse_table, 4, "TARGPCISTAT",
-	    0xa7, regvalue, cur_col, wrap));
-}
-
-int
-ahd_data_count_odd_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "DATA_COUNT_ODD",
-	    0xa7, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scbptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCBPTR",
-	    0xa8, regvalue, cur_col, wrap));
-}
-
-int
-ahd_ccscbacnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "CCSCBACNT",
-	    0xab, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SCBAUTOPTR_parse_table[] = {
-	{ "SCBPTR_OFF",		0x07, 0x07 },
-	{ "SCBPTR_ADDR",	0x38, 0x38 },
-	{ "AUSCBPTR_EN",	0x80, 0x80 }
-};
-
-int
-ahd_scbautoptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SCBAUTOPTR_parse_table, 3, "SCBAUTOPTR",
-	    0xab, regvalue, cur_col, wrap));
-}
-
-int
-ahd_ccsgaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "CCSGADDR",
-	    0xac, regvalue, cur_col, wrap));
-}
-
-int
-ahd_ccscbaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "CCSCBADDR",
-	    0xac, regvalue, cur_col, wrap));
-}
-
-int
-ahd_ccscbadr_bk_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "CCSCBADR_BK",
-	    0xac, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CMC_RAMBIST_parse_table[] = {
-	{ "CMC_BUFFER_BIST_EN",	0x01, 0x01 },
-	{ "CMC_BUFFER_BIST_FAIL",0x02, 0x02 },
-	{ "SG_BIST_EN",		0x10, 0x10 },
-	{ "SG_BIST_FAIL",	0x20, 0x20 },
-	{ "SCBRAMBIST_FAIL",	0x40, 0x40 },
-	{ "SG_ELEMENT_SIZE",	0x80, 0x80 }
-};
-
-int
-ahd_cmc_rambist_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CMC_RAMBIST_parse_table, 6, "CMC_RAMBIST",
-	    0xad, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CCSGCTL_parse_table[] = {
-	{ "CCSGRESET",		0x01, 0x01 },
-	{ "SG_FETCH_REQ",	0x02, 0x02 },
-	{ "CCSGENACK",		0x08, 0x08 },
-	{ "SG_CACHE_AVAIL",	0x10, 0x10 },
-	{ "CCSGDONE",		0x80, 0x80 },
-	{ "CCSGEN",		0x0c, 0x0c }
-};
-
-int
-ahd_ccsgctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CCSGCTL_parse_table, 6, "CCSGCTL",
-	    0xad, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t CCSCBCTL_parse_table[] = {
-	{ "CCSCBRESET",		0x01, 0x01 },
-	{ "CCSCBDIR",		0x04, 0x04 },
-	{ "CCSCBEN",		0x08, 0x08 },
-	{ "CCARREN",		0x10, 0x10 },
-	{ "ARRDONE",		0x40, 0x40 },
-	{ "CCSCBDONE",		0x80, 0x80 }
-};
-
-int
-ahd_ccscbctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(CCSCBCTL_parse_table, 6, "CCSCBCTL",
-	    0xad, regvalue, cur_col, wrap));
-}
-
-int
-ahd_ccsgram_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "CCSGRAM",
-	    0xb0, regvalue, cur_col, wrap));
-}
-
-int
-ahd_flexadr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "FLEXADR",
-	    0xb0, regvalue, cur_col, wrap));
-}
-
-int
-ahd_ccscbram_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "CCSCBRAM",
-	    0xb0, regvalue, cur_col, wrap));
-}
-
-int
-ahd_flexcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "FLEXCNT",
-	    0xb3, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t FLEXDMASTAT_parse_table[] = {
-	{ "FLEXDMADONE",	0x01, 0x01 },
-	{ "FLEXDMAERR",		0x02, 0x02 }
-};
-
-int
-ahd_flexdmastat_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(FLEXDMASTAT_parse_table, 2, "FLEXDMASTAT",
-	    0xb5, regvalue, cur_col, wrap));
-}
-
-int
-ahd_flexdata_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "FLEXDATA",
-	    0xb6, regvalue, cur_col, wrap));
-}
-
-int
-ahd_brddat_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "BRDDAT",
-	    0xb8, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t BRDCTL_parse_table[] = {
-	{ "BRDSTB",		0x01, 0x01 },
-	{ "BRDRW",		0x02, 0x02 },
-	{ "BRDEN",		0x04, 0x04 },
-	{ "BRDADDR",		0x38, 0x38 },
-	{ "FLXARBREQ",		0x40, 0x40 },
-	{ "FLXARBACK",		0x80, 0x80 }
-};
-
-int
-ahd_brdctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(BRDCTL_parse_table, 6, "BRDCTL",
-	    0xb9, regvalue, cur_col, wrap));
-}
-
-int
-ahd_seeadr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SEEADR",
-	    0xba, regvalue, cur_col, wrap));
-}
-
-int
-ahd_seedat_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SEEDAT",
-	    0xbc, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SEECTL_parse_table[] = {
-	{ "SEEOP_ERAL",		0x40, 0x70 },
-	{ "SEEOP_WRITE",	0x50, 0x70 },
-	{ "SEEOP_READ",		0x60, 0x70 },
-	{ "SEEOP_ERASE",	0x70, 0x70 },
-	{ "SEESTART",		0x01, 0x01 },
-	{ "SEERST",		0x02, 0x02 },
-	{ "SEEOPCODE",		0x70, 0x70 },
-	{ "SEEOP_EWEN",		0x40, 0x40 },
-	{ "SEEOP_WALL",		0x40, 0x40 },
-	{ "SEEOP_EWDS",		0x40, 0x40 }
-};
-
-int
-ahd_seectl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SEECTL_parse_table, 10, "SEECTL",
-	    0xbe, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SEESTAT_parse_table[] = {
-	{ "SEESTART",		0x01, 0x01 },
-	{ "SEEBUSY",		0x02, 0x02 },
-	{ "SEEARBACK",		0x04, 0x04 },
-	{ "LDALTID_L",		0x08, 0x08 },
-	{ "SEEOPCODE",		0x70, 0x70 },
-	{ "INIT_DONE",		0x80, 0x80 }
-};
-
-int
-ahd_seestat_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SEESTAT_parse_table, 6, "SEESTAT",
-	    0xbe, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCBCNT",
-	    0xbf, regvalue, cur_col, wrap));
-}
-
-int
-ahd_dfwaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "DFWADDR",
-	    0xc0, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DSPFLTRCTL_parse_table[] = {
-	{ "DSPFCNTSEL",		0x0f, 0x0f },
-	{ "EDGESENSE",		0x10, 0x10 },
-	{ "FLTRDISABLE",	0x20, 0x20 }
-};
-
-int
-ahd_dspfltrctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DSPFLTRCTL_parse_table, 3, "DSPFLTRCTL",
-	    0xc0, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DSPDATACTL_parse_table[] = {
-	{ "XMITOFFSTDIS",	0x02, 0x02 },
-	{ "RCVROFFSTDIS",	0x04, 0x04 },
-	{ "DESQDIS",		0x10, 0x10 },
-	{ "BYPASSENAB",		0x80, 0x80 }
-};
-
-int
-ahd_dspdatactl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DSPDATACTL_parse_table, 4, "DSPDATACTL",
-	    0xc1, regvalue, cur_col, wrap));
-}
-
-int
-ahd_dfraddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "DFRADDR",
-	    0xc2, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DSPREQCTL_parse_table[] = {
-	{ "MANREQDLY",		0x3f, 0x3f },
-	{ "MANREQCTL",		0xc0, 0xc0 }
-};
-
-int
-ahd_dspreqctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DSPREQCTL_parse_table, 2, "DSPREQCTL",
-	    0xc2, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DSPACKCTL_parse_table[] = {
-	{ "MANACKDLY",		0x3f, 0x3f },
-	{ "MANACKCTL",		0xc0, 0xc0 }
-};
-
-int
-ahd_dspackctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DSPACKCTL_parse_table, 2, "DSPACKCTL",
-	    0xc3, regvalue, cur_col, wrap));
-}
-
-int
-ahd_dfdat_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "DFDAT",
-	    0xc4, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DSPSELECT_parse_table[] = {
-	{ "DSPSEL",		0x1f, 0x1f },
-	{ "AUTOINCEN",		0x80, 0x80 }
-};
-
-int
-ahd_dspselect_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DSPSELECT_parse_table, 2, "DSPSELECT",
-	    0xc4, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t WRTBIASCTL_parse_table[] = {
-	{ "XMITMANVAL",		0x3f, 0x3f },
-	{ "AUTOXBCDIS",		0x80, 0x80 }
-};
-
-int
-ahd_wrtbiasctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(WRTBIASCTL_parse_table, 2, "WRTBIASCTL",
-	    0xc5, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t RCVRBIOSCTL_parse_table[] = {
-	{ "RCVRMANVAL",		0x3f, 0x3f },
-	{ "AUTORBCDIS",		0x80, 0x80 }
-};
-
-int
-ahd_rcvrbiosctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(RCVRBIOSCTL_parse_table, 2, "RCVRBIOSCTL",
-	    0xc6, regvalue, cur_col, wrap));
-}
-
-int
-ahd_wrtbiascalc_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "WRTBIASCALC",
-	    0xc7, regvalue, cur_col, wrap));
-}
-
-int
-ahd_dfptrs_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "DFPTRS",
-	    0xc8, regvalue, cur_col, wrap));
-}
-
-int
-ahd_rcvrbiascalc_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "RCVRBIASCALC",
-	    0xc8, regvalue, cur_col, wrap));
-}
-
-int
-ahd_dfbkptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "DFBKPTR",
-	    0xc9, regvalue, cur_col, wrap));
-}
-
-int
-ahd_skewcalc_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SKEWCALC",
-	    0xc9, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DFDBCTL_parse_table[] = {
-	{ "DFF_RAMBIST_EN",	0x01, 0x01 },
-	{ "DFF_RAMBIST_DONE",	0x02, 0x02 },
-	{ "DFF_RAMBIST_FAIL",	0x04, 0x04 },
-	{ "DFF_DIR_ERR",	0x08, 0x08 },
-	{ "DFF_CIO_RD_RDY",	0x10, 0x10 },
-	{ "DFF_CIO_WR_RDY",	0x20, 0x20 }
-};
-
-int
-ahd_dfdbctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DFDBCTL_parse_table, 6, "DFDBCTL",
-	    0xcb, regvalue, cur_col, wrap));
-}
-
-int
-ahd_dfscnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "DFSCNT",
-	    0xcc, regvalue, cur_col, wrap));
-}
-
-int
-ahd_dfbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "DFBCNT",
-	    0xce, regvalue, cur_col, wrap));
-}
-
-int
-ahd_ovlyaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "OVLYADDR",
-	    0xd4, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SEQCTL0_parse_table[] = {
-	{ "LOADRAM",		0x01, 0x01 },
-	{ "SEQRESET",		0x02, 0x02 },
-	{ "STEP",		0x04, 0x04 },
-	{ "BRKADRINTEN",	0x08, 0x08 },
-	{ "FASTMODE",		0x10, 0x10 },
-	{ "FAILDIS",		0x20, 0x20 },
-	{ "PAUSEDIS",		0x40, 0x40 },
-	{ "PERRORDIS",		0x80, 0x80 }
-};
-
-int
-ahd_seqctl0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SEQCTL0_parse_table, 8, "SEQCTL0",
-	    0xd6, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SEQCTL1_parse_table[] = {
-	{ "RAMBIST_EN",		0x01, 0x01 },
-	{ "RAMBIST_FAIL",	0x02, 0x02 },
-	{ "RAMBIST_DONE",	0x04, 0x04 },
-	{ "OVRLAY_DATA_CHK",	0x08, 0x08 }
-};
-
-int
-ahd_seqctl1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SEQCTL1_parse_table, 4, "SEQCTL1",
-	    0xd7, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t FLAGS_parse_table[] = {
-	{ "CARRY",		0x01, 0x01 },
-	{ "ZERO",		0x02, 0x02 }
-};
-
-int
-ahd_flags_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(FLAGS_parse_table, 2, "FLAGS",
-	    0xd8, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SEQINTCTL_parse_table[] = {
-	{ "IRET",		0x01, 0x01 },
-	{ "INTMASK1",		0x02, 0x02 },
-	{ "INTMASK2",		0x04, 0x04 },
-	{ "SCS_SEQ_INT1M0",	0x08, 0x08 },
-	{ "SCS_SEQ_INT1M1",	0x10, 0x10 },
-	{ "INT1_CONTEXT",	0x20, 0x20 },
-	{ "INTVEC1DSL",		0x80, 0x80 }
-};
-
-int
-ahd_seqintctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SEQINTCTL_parse_table, 7, "SEQINTCTL",
-	    0xd9, regvalue, cur_col, wrap));
-}
-
-int
-ahd_seqram_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SEQRAM",
-	    0xda, regvalue, cur_col, wrap));
-}
-
-int
-ahd_prgmcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "PRGMCNT",
-	    0xde, regvalue, cur_col, wrap));
-}
-
-int
-ahd_accum_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "ACCUM",
-	    0xe0, regvalue, cur_col, wrap));
-}
-
-int
-ahd_sindex_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SINDEX",
-	    0xe2, regvalue, cur_col, wrap));
-}
-
-int
-ahd_dindex_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "DINDEX",
-	    0xe4, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t BRKADDR1_parse_table[] = {
-	{ "BRKDIS",		0x80, 0x80 }
-};
-
-int
-ahd_brkaddr1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(BRKADDR1_parse_table, 1, "BRKADDR1",
-	    0xe6, regvalue, cur_col, wrap));
-}
-
-int
-ahd_brkaddr0_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "BRKADDR0",
-	    0xe6, regvalue, cur_col, wrap));
-}
-
-int
-ahd_allones_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "ALLONES",
-	    0xe8, regvalue, cur_col, wrap));
-}
-
-int
-ahd_allzeros_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "ALLZEROS",
-	    0xea, regvalue, cur_col, wrap));
-}
-
-int
-ahd_none_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "NONE",
-	    0xea, regvalue, cur_col, wrap));
-}
-
-int
-ahd_sindir_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SINDIR",
-	    0xec, regvalue, cur_col, wrap));
-}
-
-int
-ahd_dindir_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "DINDIR",
-	    0xed, regvalue, cur_col, wrap));
-}
-
-int
-ahd_function1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "FUNCTION1",
-	    0xf0, regvalue, cur_col, wrap));
-}
-
-int
-ahd_stack_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "STACK",
-	    0xf2, regvalue, cur_col, wrap));
-}
-
-int
-ahd_curaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "CURADDR",
-	    0xf4, regvalue, cur_col, wrap));
-}
-
-int
-ahd_intvec1_addr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "INTVEC1_ADDR",
-	    0xf4, regvalue, cur_col, wrap));
-}
-
-int
-ahd_intvec2_addr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "INTVEC2_ADDR",
-	    0xf6, regvalue, cur_col, wrap));
-}
-
-int
-ahd_lastaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "LASTADDR",
-	    0xf6, regvalue, cur_col, wrap));
-}
-
-int
-ahd_longjmp_addr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "LONGJMP_ADDR",
-	    0xf8, regvalue, cur_col, wrap));
-}
-
-int
-ahd_longjmp_scb_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "LONGJMP_SCB",
-	    0xfa, regvalue, cur_col, wrap));
-}
-
-int
-ahd_accum_save_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "ACCUM_SAVE",
-	    0xfc, regvalue, cur_col, wrap));
-}
-
-int
-ahd_waiting_scb_tails_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "WAITING_SCB_TAILS",
-	    0x100, regvalue, cur_col, wrap));
-}
-
-int
-ahd_ahd_pci_config_base_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "AHD_PCI_CONFIG_BASE",
-	    0x100, regvalue, cur_col, wrap));
-}
-
-int
-ahd_sram_base_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SRAM_BASE",
-	    0x100, regvalue, cur_col, wrap));
-}
-
-int
-ahd_waiting_tid_head_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "WAITING_TID_HEAD",
-	    0x120, regvalue, cur_col, wrap));
-}
-
-int
-ahd_waiting_tid_tail_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "WAITING_TID_TAIL",
-	    0x122, regvalue, cur_col, wrap));
-}
-
-int
-ahd_next_queued_scb_addr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "NEXT_QUEUED_SCB_ADDR",
-	    0x124, regvalue, cur_col, wrap));
-}
-
-int
-ahd_complete_scb_head_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "COMPLETE_SCB_HEAD",
-	    0x128, regvalue, cur_col, wrap));
-}
-
-int
-ahd_complete_scb_dmainprog_head_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "COMPLETE_SCB_DMAINPROG_HEAD",
-	    0x12a, regvalue, cur_col, wrap));
-}
-
-int
-ahd_complete_dma_scb_head_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "COMPLETE_DMA_SCB_HEAD",
-	    0x12c, regvalue, cur_col, wrap));
-}
-
-int
-ahd_qfreeze_count_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "QFREEZE_COUNT",
-	    0x12e, regvalue, cur_col, wrap));
-}
-
-int
-ahd_saved_mode_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SAVED_MODE",
-	    0x130, regvalue, cur_col, wrap));
-}
-
-int
-ahd_msg_out_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "MSG_OUT",
-	    0x131, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t DMAPARAMS_parse_table[] = {
-	{ "FIFORESET",		0x01, 0x01 },
-	{ "FIFOFLUSH",		0x02, 0x02 },
-	{ "DIRECTION",		0x04, 0x04 },
-	{ "HDMAEN",		0x08, 0x08 },
-	{ "HDMAENACK",		0x08, 0x08 },
-	{ "SDMAEN",		0x10, 0x10 },
-	{ "SDMAENACK",		0x10, 0x10 },
-	{ "SCSIEN",		0x20, 0x20 },
-	{ "WIDEODD",		0x40, 0x40 },
-	{ "PRELOADEN",		0x80, 0x80 }
-};
-
-int
-ahd_dmaparams_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(DMAPARAMS_parse_table, 10, "DMAPARAMS",
-	    0x132, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SEQ_FLAGS_parse_table[] = {
-	{ "NO_DISCONNECT",	0x01, 0x01 },
-	{ "SPHASE_PENDING",	0x02, 0x02 },
-	{ "DPHASE_PENDING",	0x04, 0x04 },
-	{ "CMDPHASE_PENDING",	0x08, 0x08 },
-	{ "TARG_CMD_PENDING",	0x10, 0x10 },
-	{ "DPHASE",		0x20, 0x20 },
-	{ "NO_CDB_SENT",	0x40, 0x40 },
-	{ "TARGET_CMD_IS_TAGGED",0x40, 0x40 },
-	{ "NOT_IDENTIFIED",	0x80, 0x80 }
-};
-
-int
-ahd_seq_flags_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SEQ_FLAGS_parse_table, 9, "SEQ_FLAGS",
-	    0x133, regvalue, cur_col, wrap));
-}
-
-int
-ahd_saved_scsiid_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SAVED_SCSIID",
-	    0x134, regvalue, cur_col, wrap));
-}
-
-int
-ahd_saved_lun_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SAVED_LUN",
-	    0x135, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t LASTPHASE_parse_table[] = {
-	{ "P_DATAOUT",		0x00, 0xe0 },
-	{ "P_DATAOUT_DT",	0x20, 0xe0 },
-	{ "P_DATAIN",		0x40, 0xe0 },
-	{ "P_DATAIN_DT",	0x60, 0xe0 },
-	{ "P_COMMAND",		0x80, 0xe0 },
-	{ "P_MESGOUT",		0xa0, 0xe0 },
-	{ "P_STATUS",		0xc0, 0xe0 },
-	{ "P_MESGIN",		0xe0, 0xe0 },
-	{ "P_BUSFREE",		0x01, 0x01 },
-	{ "MSGI",		0x20, 0x20 },
-	{ "IOI",		0x40, 0x40 },
-	{ "CDI",		0x80, 0x80 },
-	{ "PHASE_MASK",		0xe0, 0xe0 }
-};
-
-int
-ahd_lastphase_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(LASTPHASE_parse_table, 13, "LASTPHASE",
-	    0x136, regvalue, cur_col, wrap));
-}
-
-int
-ahd_qoutfifo_entry_valid_tag_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "QOUTFIFO_ENTRY_VALID_TAG",
-	    0x137, regvalue, cur_col, wrap));
-}
-
-int
-ahd_shared_data_addr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SHARED_DATA_ADDR",
-	    0x138, regvalue, cur_col, wrap));
-}
-
-int
-ahd_qoutfifo_next_addr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "QOUTFIFO_NEXT_ADDR",
-	    0x13c, regvalue, cur_col, wrap));
-}
-
-int
-ahd_kernel_tqinpos_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "KERNEL_TQINPOS",
-	    0x140, regvalue, cur_col, wrap));
-}
-
-int
-ahd_tqinpos_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "TQINPOS",
-	    0x141, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t ARG_1_parse_table[] = {
-	{ "CONT_MSG_LOOP_TARG",	0x02, 0x02 },
-	{ "CONT_MSG_LOOP_READ",	0x03, 0x03 },
-	{ "CONT_MSG_LOOP_WRITE",0x04, 0x04 },
-	{ "EXIT_MSG_LOOP",	0x08, 0x08 },
-	{ "MSGOUT_PHASEMIS",	0x10, 0x10 },
-	{ "SEND_REJ",		0x20, 0x20 },
-	{ "SEND_SENSE",		0x40, 0x40 },
-	{ "SEND_MSG",		0x80, 0x80 }
-};
-
-int
-ahd_arg_1_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(ARG_1_parse_table, 8, "ARG_1",
-	    0x142, regvalue, cur_col, wrap));
-}
-
-int
-ahd_arg_2_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "ARG_2",
-	    0x143, regvalue, cur_col, wrap));
-}
-
-int
-ahd_last_msg_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "LAST_MSG",
-	    0x144, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SCSISEQ_TEMPLATE_parse_table[] = {
-	{ "ALTSTIM",		0x01, 0x01 },
-	{ "ENAUTOATNP",		0x02, 0x02 },
-	{ "MANUALP",		0x0c, 0x0c },
-	{ "ENRSELI",		0x10, 0x10 },
-	{ "ENSELI",		0x20, 0x20 },
-	{ "MANUALCTL",		0x40, 0x40 }
-};
-
-int
-ahd_scsiseq_template_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SCSISEQ_TEMPLATE_parse_table, 6, "SCSISEQ_TEMPLATE",
-	    0x145, regvalue, cur_col, wrap));
-}
-
-int
-ahd_initiator_tag_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "INITIATOR_TAG",
-	    0x146, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SEQ_FLAGS2_parse_table[] = {
-	{ "TARGET_MSG_PENDING",	0x02, 0x02 },
-	{ "SELECTOUT_QFROZEN",	0x04, 0x04 }
-};
-
-int
-ahd_seq_flags2_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SEQ_FLAGS2_parse_table, 2, "SEQ_FLAGS2",
-	    0x147, regvalue, cur_col, wrap));
-}
-
-int
-ahd_allocfifo_scbptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "ALLOCFIFO_SCBPTR",
-	    0x148, regvalue, cur_col, wrap));
-}
-
-int
-ahd_int_coalessing_timer_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "INT_COALESSING_TIMER",
-	    0x14a, regvalue, cur_col, wrap));
-}
-
-int
-ahd_int_coalessing_maxcmds_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "INT_COALESSING_MAXCMDS",
-	    0x14c, regvalue, cur_col, wrap));
-}
-
-int
-ahd_int_coalessing_mincmds_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "INT_COALESSING_MINCMDS",
-	    0x14d, regvalue, cur_col, wrap));
-}
-
-int
-ahd_cmds_pending_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "CMDS_PENDING",
-	    0x14e, regvalue, cur_col, wrap));
-}
-
-int
-ahd_int_coalessing_cmdcount_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "INT_COALESSING_CMDCOUNT",
-	    0x150, regvalue, cur_col, wrap));
-}
-
-int
-ahd_local_hs_mailbox_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "LOCAL_HS_MAILBOX",
-	    0x151, regvalue, cur_col, wrap));
-}
-
-int
-ahd_cmdsize_table_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "CMDSIZE_TABLE",
-	    0x152, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scb_base_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCB_BASE",
-	    0x180, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scb_residual_datacnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCB_RESIDUAL_DATACNT",
-	    0x180, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SCB_RESIDUAL_SGPTR_parse_table[] = {
-	{ "SG_LIST_NULL",	0x01, 0x01 },
-	{ "SG_OVERRUN_RESID",	0x02, 0x02 },
-	{ "SG_ADDR_MASK",	0xf8, 0xf8 }
-};
-
-int
-ahd_scb_residual_sgptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SCB_RESIDUAL_SGPTR_parse_table, 3, "SCB_RESIDUAL_SGPTR",
-	    0x184, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scb_scsi_status_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCB_SCSI_STATUS",
-	    0x188, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scb_target_phases_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCB_TARGET_PHASES",
-	    0x189, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scb_target_data_dir_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCB_TARGET_DATA_DIR",
-	    0x18a, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scb_target_itag_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCB_TARGET_ITAG",
-	    0x18b, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scb_sense_busaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCB_SENSE_BUSADDR",
-	    0x18c, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scb_tag_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCB_TAG",
-	    0x190, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SCB_CDB_LEN_parse_table[] = {
-	{ "SCB_CDB_LEN_PTR",	0x80, 0x80 }
-};
-
-int
-ahd_scb_cdb_len_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SCB_CDB_LEN_parse_table, 1, "SCB_CDB_LEN",
-	    0x192, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scb_task_management_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCB_TASK_MANAGEMENT",
-	    0x193, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scb_next_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCB_NEXT",
-	    0x194, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scb_next2_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCB_NEXT2",
-	    0x196, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scb_dataptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCB_DATAPTR",
-	    0x198, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SCB_DATACNT_parse_table[] = {
-	{ "SG_HIGH_ADDR_BITS",	0x7f, 0x7f },
-	{ "SG_LAST_SEG",	0x80, 0x80 }
-};
-
-int
-ahd_scb_datacnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SCB_DATACNT_parse_table, 2, "SCB_DATACNT",
-	    0x1a0, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SCB_SGPTR_parse_table[] = {
-	{ "SG_LIST_NULL",	0x01, 0x01 },
-	{ "SG_FULL_RESID",	0x02, 0x02 },
-	{ "SG_STATUS_VALID",	0x04, 0x04 }
-};
-
-int
-ahd_scb_sgptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SCB_SGPTR_parse_table, 3, "SCB_SGPTR",
-	    0x1a4, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SCB_CONTROL_parse_table[] = {
-	{ "SCB_TAG_TYPE",	0x03, 0x03 },
-	{ "DISCONNECTED",	0x04, 0x04 },
-	{ "STATUS_RCVD",	0x08, 0x08 },
-	{ "MK_MESSAGE",		0x10, 0x10 },
-	{ "TAG_ENB",		0x20, 0x20 },
-	{ "DISCENB",		0x40, 0x40 },
-	{ "TARGET_SCB",		0x80, 0x80 }
-};
-
-int
-ahd_scb_control_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SCB_CONTROL_parse_table, 7, "SCB_CONTROL",
-	    0x1a8, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SCB_SCSIID_parse_table[] = {
-	{ "OID",		0x0f, 0x0f },
-	{ "TID",		0xf0, 0xf0 }
-};
-
-int
-ahd_scb_scsiid_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SCB_SCSIID_parse_table, 2, "SCB_SCSIID",
-	    0x1a9, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SCB_LUN_parse_table[] = {
-	{ "LID",		0xff, 0xff }
-};
-
-int
-ahd_scb_lun_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SCB_LUN_parse_table, 1, "SCB_LUN",
-	    0x1aa, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scb_task_attribute_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCB_TASK_ATTRIBUTE",
-	    0x1ab, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scb_busaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCB_BUSADDR",
-	    0x1ac, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scb_spare_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCB_SPARE",
-	    0x1b0, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scb_disconnected_lists_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCB_DISCONNECTED_LISTS",
-	    0x1b8, regvalue, cur_col, wrap));
-}
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aic79xx_seq.h linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx_seq.h
--- linux-2.4.21/drivers/scsi/aic79xx/aic79xx_seq.h	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aic79xx_seq.h	2003-06-26 21:43:28.000000000 +0000
@@ -1,1085 +0,0 @@
-/*
- * DO NOT EDIT - This file is automatically generated
- *		 from the following source files:
- *
- * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#78 $
- * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#60 $
- */
-static uint8_t seqprog[] = {
-	0xff, 0x02, 0x06, 0x78,
-	0x00, 0xea, 0x46, 0x59,
-	0x01, 0xea, 0x04, 0x30,
-	0xff, 0x04, 0x0c, 0x78,
-	0x19, 0xea, 0x46, 0x59,
-	0x19, 0xea, 0x04, 0x00,
-	0x33, 0xea, 0x3a, 0x59,
-	0x33, 0xea, 0x00, 0x00,
-	0x60, 0x3a, 0x1a, 0x68,
-	0x04, 0x47, 0x1b, 0x68,
-	0xff, 0x21, 0x1b, 0x70,
-	0x40, 0x4b, 0x88, 0x69,
-	0x00, 0xe2, 0x4a, 0x59,
-	0x40, 0x4b, 0x88, 0x69,
-	0x20, 0x4b, 0x78, 0x69,
-	0xfc, 0x42, 0x24, 0x78,
-	0x10, 0x40, 0x24, 0x78,
-	0x00, 0xe2, 0xa4, 0x5d,
-	0x20, 0x4d, 0x28, 0x78,
-	0x00, 0xe2, 0xa4, 0x5d,
-	0x00, 0xe2, 0x34, 0x58,
-	0x00, 0xe2, 0x66, 0x58,
-	0x00, 0xe2, 0x76, 0x58,
-	0x00, 0xe2, 0x06, 0x40,
-	0x33, 0xea, 0x3a, 0x59,
-	0x33, 0xea, 0x00, 0x00,
-	0x01, 0x52, 0x66, 0x7d,
-	0x02, 0x58, 0x50, 0x31,
-	0xff, 0xea, 0x10, 0x0b,
-	0xff, 0x93, 0x45, 0x78,
-	0x50, 0x4b, 0x40, 0x68,
-	0xbf, 0x3a, 0x74, 0x08,
-	0x14, 0xea, 0x46, 0x59,
-	0x14, 0xea, 0x04, 0x00,
-	0x08, 0xa8, 0x51, 0x03,
-	0x01, 0xa4, 0x4d, 0x78,
-	0x00, 0xe2, 0x44, 0x5b,
-	0x00, 0xe2, 0x34, 0x40,
-	0xff, 0xea, 0xd4, 0x19,
-	0x02, 0xa8, 0x84, 0x32,
-	0x00, 0xea, 0x3a, 0x59,
-	0x01, 0xea, 0x00, 0x30,
-	0x00, 0xe2, 0x98, 0x5d,
-	0x00, 0xe2, 0x66, 0x4d,
-	0x11, 0xea, 0x3a, 0x59,
-	0x11, 0xea, 0x00, 0x00,
-	0x00, 0xe2, 0x98, 0x5d,
-	0x00, 0xe2, 0x66, 0x4d,
-	0x33, 0xea, 0x3a, 0x59,
-	0x33, 0xea, 0x00, 0x00,
-	0x00, 0xe2, 0x3a, 0x43,
-	0x00, 0xea, 0x3a, 0x59,
-	0x01, 0xea, 0x00, 0x30,
-	0x80, 0xf9, 0x6e, 0x68,
-	0x00, 0xe2, 0x38, 0x59,
-	0x11, 0xea, 0x3a, 0x59,
-	0x11, 0xea, 0x00, 0x00,
-	0x80, 0xf9, 0x38, 0x79,
-	0xff, 0xea, 0xd4, 0x0d,
-	0x22, 0xea, 0x3a, 0x59,
-	0x22, 0xea, 0x00, 0x00,
-	0x10, 0x16, 0x80, 0x78,
-	0x01, 0x0b, 0xa2, 0x32,
-	0x10, 0x16, 0x2c, 0x00,
-	0x18, 0xad, 0xee, 0x78,
-	0x04, 0xad, 0xbc, 0x68,
-	0x80, 0xad, 0x66, 0x7d,
-	0x10, 0xad, 0x8a, 0x78,
-	0xe7, 0xad, 0x5a, 0x0d,
-	0xe7, 0xad, 0x5a, 0x09,
-	0x00, 0xe2, 0x98, 0x58,
-	0xff, 0xea, 0x56, 0x02,
-	0x04, 0x7c, 0x78, 0x32,
-	0x20, 0x16, 0x66, 0x7d,
-	0x04, 0x38, 0x79, 0x32,
-	0x80, 0x37, 0x6f, 0x16,
-	0xff, 0x2d, 0xa7, 0x60,
-	0xff, 0x29, 0xa7, 0x60,
-	0x40, 0x51, 0xb7, 0x78,
-	0xff, 0x4f, 0xa7, 0x68,
-	0xff, 0x4d, 0xc1, 0x19,
-	0x00, 0x4e, 0xd5, 0x19,
-	0x00, 0xe2, 0xb6, 0x50,
-	0x01, 0x4c, 0xc1, 0x31,
-	0x00, 0x50, 0xd5, 0x19,
-	0x00, 0xe2, 0xb6, 0x48,
-	0x80, 0x18, 0x66, 0x7d,
-	0x02, 0x4a, 0x1d, 0x30,
-	0x10, 0xea, 0x18, 0x00,
-	0x60, 0x18, 0x30, 0x00,
-	0x7f, 0x18, 0x30, 0x0c,
-	0x02, 0xea, 0x02, 0x00,
-	0xff, 0xea, 0xa0, 0x0a,
-	0x80, 0x18, 0x30, 0x04,
-	0x40, 0xad, 0x66, 0x7d,
-	0xe7, 0xad, 0x5a, 0x09,
-	0x02, 0xa8, 0x40, 0x31,
-	0xff, 0xea, 0xc0, 0x09,
-	0x01, 0x4e, 0x9d, 0x1a,
-	0x00, 0x4f, 0x9f, 0x22,
-	0x04, 0x94, 0x49, 0x32,
-	0xff, 0xea, 0x2a, 0x03,
-	0xff, 0xea, 0x2e, 0x03,
-	0x01, 0x10, 0xd4, 0x31,
-	0x10, 0xa8, 0xe3, 0x68,
-	0x3d, 0xa9, 0xc5, 0x29,
-	0xfe, 0xe2, 0xc4, 0x09,
-	0x01, 0xea, 0xc6, 0x01,
-	0x02, 0xe2, 0xc8, 0x31,
-	0x02, 0xec, 0x50, 0x31,
-	0x02, 0xa0, 0xda, 0x31,
-	0xff, 0xa9, 0xe2, 0x70,
-	0x02, 0xa0, 0x28, 0x37,
-	0xff, 0x21, 0xeb, 0x70,
-	0x02, 0x22, 0x51, 0x31,
-	0x02, 0xa0, 0x2c, 0x33,
-	0x02, 0xa0, 0x44, 0x36,
-	0x02, 0xa0, 0x40, 0x32,
-	0x02, 0xa0, 0x44, 0x36,
-	0x04, 0x47, 0xf3, 0x68,
-	0x40, 0x16, 0x1e, 0x69,
-	0xff, 0x2d, 0x23, 0x61,
-	0xff, 0x29, 0x67, 0x75,
-	0x01, 0x37, 0xc1, 0x31,
-	0x02, 0x28, 0x55, 0x32,
-	0x01, 0xea, 0x5a, 0x01,
-	0x04, 0x3c, 0xf9, 0x30,
-	0x02, 0x28, 0x51, 0x31,
-	0x01, 0xa8, 0x60, 0x31,
-	0x00, 0xa9, 0x60, 0x01,
-	0x01, 0x14, 0xd4, 0x31,
-	0x01, 0x50, 0xa1, 0x1a,
-	0xff, 0x4e, 0x9d, 0x1a,
-	0xff, 0x4f, 0x9f, 0x22,
-	0xff, 0x8d, 0x17, 0x71,
-	0x80, 0xac, 0x16, 0x71,
-	0x20, 0x16, 0x16, 0x69,
-	0x02, 0x8c, 0x51, 0x31,
-	0x00, 0xe2, 0x00, 0x41,
-	0x01, 0xac, 0x08, 0x31,
-	0x09, 0xea, 0x5a, 0x01,
-	0x02, 0x8c, 0x51, 0x32,
-	0xff, 0xea, 0x1a, 0x07,
-	0x04, 0x24, 0xf9, 0x30,
-	0x1d, 0xea, 0x2e, 0x41,
-	0x02, 0x2c, 0x51, 0x31,
-	0x04, 0xac, 0xf9, 0x30,
-	0x19, 0xea, 0x2e, 0x59,
-	0x02, 0x8c, 0x59, 0x32,
-	0x02, 0x28, 0x19, 0x33,
-	0x02, 0xa8, 0x50, 0x36,
-	0x06, 0xea, 0x08, 0x81,
-	0x01, 0xe2, 0x5a, 0x35,
-	0x02, 0xa8, 0xf4, 0x31,
-	0x02, 0xf2, 0xf0, 0x35,
-	0x02, 0xf2, 0xf0, 0x31,
-	0x02, 0xf8, 0xe4, 0x35,
-	0x80, 0xea, 0xb2, 0x01,
-	0x01, 0xe2, 0x00, 0x30,
-	0xff, 0xea, 0xb2, 0x0d,
-	0x80, 0xea, 0xb2, 0x01,
-	0x11, 0x00, 0x00, 0x10,
-	0xff, 0xea, 0xb2, 0x0d,
-	0x01, 0xe2, 0x04, 0x30,
-	0x01, 0xea, 0x04, 0x34,
-	0x02, 0x20, 0xbd, 0x30,
-	0x02, 0x20, 0xb9, 0x30,
-	0x02, 0x20, 0x51, 0x31,
-	0x4c, 0xa9, 0xd7, 0x28,
-	0x10, 0xa8, 0x59, 0x79,
-	0x01, 0x6b, 0xc0, 0x30,
-	0x02, 0x64, 0xc8, 0x00,
-	0x40, 0x3a, 0x74, 0x04,
-	0x00, 0xe2, 0x66, 0x58,
-	0x33, 0xea, 0x3a, 0x59,
-	0x33, 0xea, 0x00, 0x00,
-	0x30, 0x3f, 0xc0, 0x09,
-	0x30, 0xe0, 0x5a, 0x61,
-	0x20, 0x3f, 0x70, 0x69,
-	0x10, 0x3f, 0x5a, 0x79,
-	0x02, 0xea, 0x7e, 0x00,
-	0x00, 0xea, 0x3a, 0x59,
-	0x01, 0xea, 0x00, 0x30,
-	0x02, 0x48, 0x51, 0x35,
-	0x01, 0xea, 0x7e, 0x00,
-	0x11, 0xea, 0x3a, 0x59,
-	0x11, 0xea, 0x00, 0x00,
-	0x02, 0x48, 0x51, 0x35,
-	0x08, 0xea, 0x98, 0x00,
-	0x08, 0x57, 0xae, 0x00,
-	0x08, 0x3c, 0x78, 0x00,
-	0xf0, 0x49, 0x68, 0x0a,
-	0x0f, 0x67, 0xc0, 0x09,
-	0x00, 0x34, 0x69, 0x02,
-	0x20, 0xea, 0x96, 0x00,
-	0x00, 0xe2, 0xee, 0x41,
-	0x40, 0x3a, 0xa4, 0x69,
-	0x02, 0x55, 0x06, 0x68,
-	0x02, 0x56, 0xa4, 0x69,
-	0xff, 0x5b, 0xa4, 0x61,
-	0x02, 0x20, 0x51, 0x31,
-	0x80, 0xea, 0xb2, 0x01,
-	0x44, 0xea, 0x00, 0x00,
-	0x01, 0x33, 0xc0, 0x31,
-	0x33, 0xea, 0x00, 0x00,
-	0xff, 0xea, 0xb2, 0x09,
-	0xff, 0xe0, 0xc0, 0x19,
-	0xff, 0xe0, 0xa6, 0x79,
-	0x02, 0x94, 0x51, 0x31,
-	0x00, 0xe2, 0x9c, 0x41,
-	0x02, 0x5e, 0x50, 0x31,
-	0x02, 0xa8, 0xb8, 0x30,
-	0x02, 0x5c, 0x50, 0x31,
-	0xff, 0x95, 0xb7, 0x71,
-	0x02, 0x94, 0x41, 0x31,
-	0x02, 0x22, 0x51, 0x31,
-	0x02, 0xa0, 0x2c, 0x33,
-	0x02, 0xa0, 0x44, 0x32,
-	0x00, 0xe2, 0xc0, 0x41,
-	0x10, 0xa8, 0xc1, 0x69,
-	0x3d, 0xa9, 0xc9, 0x29,
-	0x01, 0xe4, 0xc8, 0x01,
-	0x01, 0xea, 0xca, 0x01,
-	0xff, 0xea, 0xda, 0x01,
-	0x02, 0x20, 0x51, 0x31,
-	0x02, 0x96, 0x41, 0x32,
-	0xff, 0x21, 0xc9, 0x61,
-	0xff, 0xea, 0x46, 0x02,
-	0x02, 0x5c, 0x50, 0x31,
-	0x40, 0xea, 0x96, 0x00,
-	0x02, 0x56, 0xac, 0x6d,
-	0x01, 0x55, 0xac, 0x6d,
-	0x10, 0xa8, 0xd5, 0x79,
-	0x10, 0x40, 0xde, 0x69,
-	0x01, 0x56, 0xde, 0x79,
-	0xff, 0x93, 0x07, 0x78,
-	0x13, 0xea, 0x46, 0x59,
-	0x13, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0x06, 0x40,
-	0xbf, 0x3a, 0x74, 0x08,
-	0x08, 0xea, 0x98, 0x00,
-	0x08, 0x57, 0xae, 0x00,
-	0x01, 0xa9, 0x69, 0x32,
-	0x01, 0xaa, 0x6b, 0x32,
-	0x40, 0xea, 0x66, 0x02,
-	0x08, 0x3c, 0x78, 0x00,
-	0x80, 0xea, 0x62, 0x02,
-	0x00, 0xe2, 0xa4, 0x5b,
-	0x01, 0x36, 0xc1, 0x31,
-	0x9f, 0xe0, 0x38, 0x7c,
-	0x80, 0xe0, 0x02, 0x72,
-	0xa0, 0xe0, 0x3a, 0x72,
-	0xc0, 0xe0, 0x30, 0x72,
-	0xe0, 0xe0, 0x6a, 0x72,
-	0x01, 0xea, 0x46, 0x59,
-	0x01, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0xee, 0x41,
-	0x80, 0x33, 0x09, 0x7a,
-	0x03, 0xea, 0x46, 0x59,
-	0x03, 0xea, 0x04, 0x00,
-	0xee, 0x00, 0x10, 0x6a,
-	0x05, 0xea, 0xb4, 0x00,
-	0x33, 0xea, 0x3a, 0x59,
-	0x33, 0xea, 0x00, 0x00,
-	0x02, 0xa8, 0x90, 0x32,
-	0x00, 0xe2, 0x60, 0x59,
-	0xef, 0x92, 0xd5, 0x19,
-	0x00, 0xe2, 0x20, 0x52,
-	0x0b, 0x84, 0xe1, 0x30,
-	0x02, 0xea, 0x36, 0x00,
-	0xa8, 0xea, 0x32, 0x00,
-	0x00, 0xe2, 0x26, 0x42,
-	0x01, 0x92, 0xd1, 0x30,
-	0x10, 0x80, 0x89, 0x31,
-	0x20, 0xea, 0x32, 0x00,
-	0xbf, 0x33, 0x67, 0x0a,
-	0x20, 0x19, 0x28, 0x6a,
-	0x02, 0x4d, 0xee, 0x69,
-	0x40, 0x33, 0x67, 0x02,
-	0x00, 0xe2, 0xee, 0x41,
-	0x80, 0x33, 0xa7, 0x6a,
-	0x01, 0x44, 0x10, 0x33,
-	0x08, 0xa8, 0x51, 0x03,
-	0x00, 0xe2, 0xee, 0x41,
-	0x10, 0xea, 0x80, 0x00,
-	0x01, 0x31, 0xc5, 0x31,
-	0x80, 0xe2, 0x56, 0x62,
-	0x10, 0xa8, 0x7b, 0x6a,
-	0xc0, 0xaa, 0xc5, 0x01,
-	0x40, 0xa8, 0x47, 0x6a,
-	0xbf, 0xe2, 0xc4, 0x09,
-	0x20, 0xa8, 0x5b, 0x7a,
-	0x01, 0xe2, 0x88, 0x30,
-	0x00, 0xe2, 0xa4, 0x5b,
-	0xa0, 0x36, 0x63, 0x62,
-	0x23, 0xa8, 0x89, 0x08,
-	0x00, 0xe2, 0xa4, 0x5b,
-	0xa0, 0x36, 0x63, 0x62,
-	0x00, 0xa8, 0x5a, 0x42,
-	0xff, 0xe2, 0x5a, 0x62,
-	0x00, 0xe2, 0x7a, 0x42,
-	0x40, 0xea, 0x98, 0x00,
-	0x01, 0xe2, 0x88, 0x30,
-	0x00, 0xe2, 0xa4, 0x5b,
-	0xa0, 0x36, 0x39, 0x72,
-	0x40, 0xea, 0x98, 0x00,
-	0x01, 0x31, 0x89, 0x32,
-	0x08, 0xea, 0x62, 0x02,
-	0x00, 0xe2, 0xee, 0x41,
-	0xe0, 0xea, 0xb4, 0x5b,
-	0x80, 0xe0, 0xb2, 0x6a,
-	0x04, 0xe0, 0x52, 0x73,
-	0x02, 0xe0, 0x82, 0x73,
-	0x00, 0xea, 0x10, 0x73,
-	0x03, 0xe0, 0x92, 0x73,
-	0x23, 0xe0, 0x8c, 0x72,
-	0x08, 0xe0, 0xae, 0x72,
-	0x00, 0xe2, 0xa4, 0x5b,
-	0x07, 0xea, 0x46, 0x59,
-	0x07, 0xea, 0x04, 0x00,
-	0x08, 0x42, 0xef, 0x71,
-	0x04, 0x42, 0x89, 0x62,
-	0x01, 0x43, 0x89, 0x30,
-	0x00, 0xe2, 0x7a, 0x42,
-	0x01, 0x44, 0xd4, 0x31,
-	0x00, 0xe2, 0x7a, 0x42,
-	0x01, 0x00, 0x60, 0x32,
-	0x33, 0xea, 0x3a, 0x59,
-	0x33, 0xea, 0x00, 0x00,
-	0x4c, 0x34, 0xc1, 0x28,
-	0x01, 0x64, 0xc0, 0x31,
-	0x00, 0x30, 0x3b, 0x59,
-	0x01, 0x30, 0x01, 0x30,
-	0x01, 0xe0, 0xac, 0x7a,
-	0xa0, 0xea, 0xaa, 0x5b,
-	0x01, 0xa0, 0xac, 0x62,
-	0x01, 0x84, 0xa5, 0x7a,
-	0x01, 0xa7, 0xae, 0x7a,
-	0x00, 0xe2, 0xae, 0x42,
-	0x03, 0xea, 0x46, 0x59,
-	0x03, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0xae, 0x42,
-	0x07, 0xea, 0xbc, 0x5b,
-	0x01, 0x44, 0xd4, 0x31,
-	0x00, 0xe2, 0xee, 0x41,
-	0x3f, 0xe0, 0x6a, 0x0a,
-	0xc0, 0x34, 0xc1, 0x09,
-	0x00, 0x35, 0x51, 0x01,
-	0xff, 0xea, 0x52, 0x09,
-	0x30, 0x34, 0xc5, 0x09,
-	0x3d, 0xe2, 0xc4, 0x29,
-	0xb8, 0xe2, 0xc4, 0x19,
-	0x01, 0xea, 0xc6, 0x01,
-	0x02, 0xe2, 0xc8, 0x31,
-	0x02, 0xec, 0x40, 0x31,
-	0xff, 0xa1, 0xce, 0x72,
-	0x02, 0xe8, 0xda, 0x31,
-	0x02, 0xa0, 0x50, 0x31,
-	0x00, 0xe2, 0xf0, 0x42,
-	0x80, 0x33, 0x67, 0x02,
-	0x01, 0x44, 0xd4, 0x31,
-	0x00, 0xe2, 0xa4, 0x5b,
-	0x01, 0x33, 0x67, 0x02,
-	0xe0, 0x36, 0x0b, 0x63,
-	0x02, 0x33, 0x67, 0x02,
-	0x20, 0x46, 0x04, 0x63,
-	0xff, 0xea, 0x52, 0x09,
-	0xa8, 0xea, 0xaa, 0x5b,
-	0x04, 0xa8, 0xeb, 0x7a,
-	0x01, 0x34, 0xc1, 0x31,
-	0x00, 0xa9, 0xeb, 0x62,
-	0x01, 0x35, 0xc1, 0x31,
-	0x00, 0xaa, 0xf5, 0x72,
-	0x01, 0xa9, 0x52, 0x11,
-	0xff, 0xa9, 0xe0, 0x6a,
-	0x00, 0xe2, 0x04, 0x43,
-	0x10, 0x33, 0x67, 0x02,
-	0x04, 0xa8, 0x05, 0x7b,
-	0xfb, 0xa8, 0x51, 0x0b,
-	0xff, 0xea, 0x66, 0x0a,
-	0x01, 0xa4, 0xff, 0x6a,
-	0x02, 0xa8, 0x90, 0x32,
-	0x00, 0xe2, 0x60, 0x59,
-	0x10, 0xa8, 0xaf, 0x7a,
-	0xff, 0xea, 0xbc, 0x5b,
-	0x00, 0xe2, 0xae, 0x42,
-	0x04, 0xea, 0x46, 0x59,
-	0x04, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0xae, 0x42,
-	0x04, 0xea, 0x46, 0x59,
-	0x04, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0xee, 0x41,
-	0x08, 0xa8, 0xa7, 0x7a,
-	0xc0, 0x33, 0x1b, 0x7b,
-	0x80, 0x33, 0xa7, 0x6a,
-	0xff, 0x88, 0x1b, 0x6b,
-	0x40, 0x33, 0xa7, 0x6a,
-	0x10, 0xa8, 0x21, 0x7b,
-	0x0a, 0xea, 0x46, 0x59,
-	0x0a, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0x3a, 0x5b,
-	0x00, 0xe2, 0x6e, 0x43,
-	0x50, 0x4b, 0x28, 0x6b,
-	0xbf, 0x3a, 0x74, 0x08,
-	0x01, 0xe0, 0xf8, 0x31,
-	0xff, 0xea, 0xc0, 0x09,
-	0x01, 0x2e, 0x5d, 0x1a,
-	0x00, 0x2f, 0x5f, 0x22,
-	0x04, 0x47, 0x8f, 0x02,
-	0x01, 0xfc, 0xc0, 0x35,
-	0x33, 0xea, 0x3a, 0x59,
-	0x33, 0xea, 0x00, 0x00,
-	0x02, 0x42, 0x51, 0x31,
-	0x10, 0xa8, 0x51, 0x03,
-	0xff, 0x88, 0x49, 0x6b,
-	0x01, 0xa4, 0x45, 0x6b,
-	0x02, 0xa4, 0x4d, 0x6b,
-	0x01, 0x84, 0x4d, 0x7b,
-	0x02, 0x28, 0x19, 0x33,
-	0x02, 0xa8, 0x50, 0x36,
-	0xff, 0x88, 0x4d, 0x73,
-	0x00, 0xe2, 0x24, 0x5b,
-	0x02, 0x2c, 0x19, 0x33,
-	0x02, 0xa8, 0x58, 0x32,
-	0x04, 0xa4, 0x49, 0x07,
-	0xc0, 0x33, 0xa7, 0x6a,
-	0x04, 0xa8, 0x51, 0x03,
-	0x20, 0xa8, 0x6f, 0x6b,
-	0x02, 0xa8, 0x40, 0x31,
-	0xc0, 0x34, 0xc1, 0x09,
-	0x00, 0x35, 0x51, 0x01,
-	0xff, 0xea, 0x52, 0x09,
-	0x30, 0x34, 0xc5, 0x09,
-	0x3d, 0xe2, 0xc4, 0x29,
-	0xb8, 0xe2, 0xc4, 0x19,
-	0x01, 0xea, 0xc6, 0x01,
-	0x02, 0xe2, 0xc8, 0x31,
-	0x02, 0xa0, 0xda, 0x31,
-	0x02, 0xa0, 0x50, 0x31,
-	0xf7, 0x57, 0xae, 0x08,
-	0x08, 0xea, 0x98, 0x00,
-	0x01, 0x44, 0xd4, 0x31,
-	0xee, 0x00, 0x78, 0x6b,
-	0x02, 0xea, 0xb4, 0x00,
-	0x00, 0xe2, 0xa0, 0x5b,
-	0x09, 0x4c, 0x7a, 0x7b,
-	0x08, 0x4c, 0x06, 0x68,
-	0x0b, 0xea, 0x46, 0x59,
-	0x0b, 0xea, 0x04, 0x00,
-	0x01, 0x44, 0xd4, 0x31,
-	0x20, 0x33, 0xef, 0x79,
-	0x00, 0xe2, 0x8a, 0x5b,
-	0x00, 0xe2, 0xee, 0x41,
-	0x01, 0x84, 0x8f, 0x7b,
-	0x01, 0xa4, 0x49, 0x07,
-	0x08, 0x60, 0x30, 0x33,
-	0x08, 0x80, 0x41, 0x37,
-	0xdf, 0x33, 0x67, 0x0a,
-	0xee, 0x00, 0x9c, 0x6b,
-	0x05, 0xea, 0xb4, 0x00,
-	0x33, 0xea, 0x3a, 0x59,
-	0x33, 0xea, 0x00, 0x00,
-	0x00, 0xe2, 0x60, 0x59,
-	0x00, 0xe2, 0xae, 0x42,
-	0x01, 0xea, 0x6c, 0x02,
-	0xc0, 0xea, 0x66, 0x06,
-	0xff, 0x42, 0xa4, 0x7b,
-	0x04, 0x4c, 0xa4, 0x6b,
-	0xe0, 0x41, 0x6c, 0x0e,
-	0x01, 0x44, 0xd4, 0x31,
-	0xff, 0x42, 0xac, 0x7b,
-	0x04, 0x4c, 0xac, 0x6b,
-	0xe0, 0x41, 0x6c, 0x0a,
-	0xe0, 0x36, 0xef, 0x61,
-	0xff, 0xea, 0xca, 0x09,
-	0x01, 0xe2, 0xc8, 0x31,
-	0x01, 0x46, 0xda, 0x35,
-	0x01, 0x44, 0xd4, 0x35,
-	0x10, 0xea, 0x80, 0x00,
-	0x01, 0xe2, 0x62, 0x36,
-	0x04, 0xa6, 0xc4, 0x7b,
-	0xff, 0xea, 0x5a, 0x09,
-	0xff, 0xea, 0x4c, 0x0d,
-	0x01, 0xa6, 0xe2, 0x6b,
-	0x10, 0xad, 0x66, 0x7d,
-	0x80, 0xad, 0xda, 0x6b,
-	0x08, 0xad, 0x66, 0x6d,
-	0x04, 0x84, 0xf9, 0x30,
-	0x00, 0xea, 0x08, 0x81,
-	0xff, 0xea, 0xd4, 0x09,
-	0x02, 0x84, 0xf9, 0x88,
-	0x1d, 0xea, 0x5a, 0x01,
-	0x04, 0xa6, 0x4c, 0x05,
-	0x04, 0xa6, 0x66, 0x7d,
-	0xff, 0xea, 0x5a, 0x09,
-	0x03, 0x84, 0x59, 0x89,
-	0x03, 0xea, 0x4c, 0x01,
-	0x80, 0x1a, 0x66, 0x7d,
-	0x08, 0xb0, 0xe0, 0x30,
-	0x04, 0xb0, 0xe0, 0x30,
-	0x03, 0xb0, 0xf0, 0x30,
-	0x01, 0x78, 0xee, 0x7b,
-	0x01, 0xa7, 0x4e, 0x11,
-	0x01, 0xb0, 0x06, 0x33,
-	0x7f, 0x83, 0xe9, 0x08,
-	0x04, 0xac, 0x58, 0x19,
-	0xff, 0xea, 0xc0, 0x09,
-	0x04, 0x84, 0x09, 0x9b,
-	0x00, 0x85, 0x0b, 0x23,
-	0x00, 0x86, 0x0d, 0x23,
-	0x00, 0x87, 0x0f, 0x23,
-	0x01, 0x84, 0xc5, 0x31,
-	0x01, 0xa7, 0x04, 0x7c,
-	0x04, 0xe2, 0xc4, 0x01,
-	0x80, 0x83, 0x0b, 0x7c,
-	0x02, 0xe2, 0xc4, 0x01,
-	0xff, 0xea, 0x4c, 0x09,
-	0x01, 0xe2, 0x36, 0x30,
-	0xc8, 0x19, 0x32, 0x00,
-	0x88, 0x19, 0x32, 0x00,
-	0x01, 0xac, 0xd4, 0x99,
-	0x00, 0xe2, 0x66, 0x55,
-	0xfe, 0xa6, 0x4c, 0x0d,
-	0x0b, 0x98, 0xe1, 0x30,
-	0x01, 0xa0, 0x4f, 0x09,
-	0xfd, 0xa4, 0x49, 0x09,
-	0x80, 0xa3, 0x21, 0x7c,
-	0x02, 0xa4, 0x48, 0x01,
-	0x01, 0xa7, 0x24, 0x7c,
-	0x04, 0xa4, 0x48, 0x01,
-	0x01, 0xa4, 0x36, 0x30,
-	0xa8, 0xea, 0x32, 0x00,
-	0xfd, 0xa4, 0x49, 0x0b,
-	0x05, 0xa3, 0x07, 0x33,
-	0x80, 0x83, 0x31, 0x6c,
-	0x02, 0xea, 0x4c, 0x05,
-	0xff, 0xea, 0x4c, 0x0d,
-	0x00, 0xe2, 0x32, 0x59,
-	0x02, 0xa6, 0xc6, 0x6b,
-	0x80, 0xf9, 0xf2, 0x05,
-	0xc0, 0x33, 0x3f, 0x7c,
-	0x03, 0xea, 0x46, 0x59,
-	0x03, 0xea, 0x04, 0x00,
-	0x20, 0x33, 0x63, 0x7c,
-	0x01, 0x84, 0x49, 0x6c,
-	0x06, 0xea, 0x46, 0x59,
-	0x06, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0x66, 0x44,
-	0x01, 0x00, 0x60, 0x32,
-	0xee, 0x00, 0x52, 0x6c,
-	0x05, 0xea, 0xb4, 0x00,
-	0x33, 0xea, 0x3a, 0x59,
-	0x33, 0xea, 0x00, 0x00,
-	0x80, 0x3d, 0x7a, 0x00,
-	0xfc, 0x42, 0x54, 0x7c,
-	0x7f, 0x3d, 0x7a, 0x08,
-	0x00, 0x30, 0x3b, 0x59,
-	0x01, 0x30, 0x01, 0x30,
-	0x09, 0xea, 0x46, 0x59,
-	0x09, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0xee, 0x41,
-	0x01, 0xa4, 0x49, 0x6c,
-	0x00, 0xe2, 0x16, 0x5c,
-	0x20, 0x33, 0x67, 0x02,
-	0x01, 0x00, 0x60, 0x32,
-	0x02, 0xa6, 0x6e, 0x7c,
-	0x00, 0xe2, 0x32, 0x5c,
-	0x00, 0xe2, 0x66, 0x58,
-	0x00, 0xe2, 0x76, 0x58,
-	0x00, 0xe2, 0x30, 0x58,
-	0x00, 0x30, 0x3b, 0x59,
-	0x01, 0x30, 0x01, 0x30,
-	0x20, 0x19, 0x6e, 0x6c,
-	0x00, 0xe2, 0x96, 0x5c,
-	0x04, 0x19, 0x88, 0x6c,
-	0x02, 0x19, 0x32, 0x00,
-	0x01, 0x84, 0x89, 0x7c,
-	0x01, 0x1b, 0x82, 0x7c,
-	0x01, 0x1a, 0x88, 0x6c,
-	0x00, 0xe2, 0x38, 0x44,
-	0x80, 0x4b, 0x8e, 0x6c,
-	0x01, 0x4c, 0x8a, 0x7c,
-	0x03, 0x42, 0x38, 0x6c,
-	0x00, 0xe2, 0xc0, 0x5b,
-	0x80, 0xf9, 0xf2, 0x01,
-	0x04, 0x33, 0xef, 0x79,
-	0x00, 0xe2, 0xee, 0x41,
-	0x02, 0x1b, 0x9e, 0x7c,
-	0x08, 0x5d, 0x9c, 0x7c,
-	0x03, 0x68, 0x00, 0x37,
-	0x01, 0x84, 0x09, 0x07,
-	0x08, 0x5d, 0xa8, 0x6c,
-	0x00, 0xe2, 0x66, 0x58,
-	0x00, 0x30, 0x3b, 0x59,
-	0x01, 0x30, 0x01, 0x30,
-	0x00, 0xe2, 0x96, 0x44,
-	0x80, 0x1b, 0xb2, 0x7c,
-	0x80, 0x84, 0xb3, 0x6c,
-	0xff, 0x85, 0x0b, 0x1b,
-	0xff, 0x86, 0x0d, 0x23,
-	0xff, 0x87, 0x0f, 0x23,
-	0xf8, 0x1b, 0x08, 0x0b,
-	0xff, 0xea, 0x4e, 0x09,
-	0x04, 0x1b, 0xba, 0x7c,
-	0x01, 0xa7, 0x4e, 0x01,
-	0xff, 0xea, 0x06, 0x0b,
-	0x03, 0x68, 0x00, 0x37,
-	0x00, 0xe2, 0xb6, 0x58,
-	0x10, 0xea, 0x18, 0x00,
-	0xf9, 0xd9, 0xb2, 0x0d,
-	0x01, 0xd9, 0xb2, 0x05,
-	0xff, 0xea, 0xd4, 0x09,
-	0x10, 0x5b, 0xde, 0x6c,
-	0x08, 0x5b, 0xe6, 0x6c,
-	0x20, 0x5b, 0xd4, 0x6c,
-	0x02, 0x5b, 0xfa, 0x6d,
-	0x0e, 0xea, 0x46, 0x59,
-	0x0e, 0xea, 0x04, 0x00,
-	0x08, 0x19, 0xda, 0x7c,
-	0xdf, 0x5c, 0xb8, 0x08,
-	0x01, 0xd9, 0xb2, 0x05,
-	0x02, 0xea, 0xb4, 0x00,
-	0x01, 0xd9, 0xb2, 0x05,
-	0x01, 0xa4, 0xc3, 0x6d,
-	0x00, 0xe2, 0x16, 0x5c,
-	0x00, 0xe2, 0x06, 0x5d,
-	0x01, 0xd9, 0xb2, 0x05,
-	0x00, 0xe2, 0x24, 0x5b,
-	0xf3, 0x92, 0xd5, 0x19,
-	0x00, 0xe2, 0xf4, 0x54,
-	0x80, 0x92, 0xf5, 0x6c,
-	0x0f, 0xea, 0x46, 0x59,
-	0x0f, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0xfc, 0x44,
-	0x04, 0x8c, 0xe1, 0x30,
-	0x01, 0xea, 0xf2, 0x00,
-	0x02, 0xea, 0x36, 0x00,
-	0xa8, 0xea, 0x32, 0x00,
-	0xff, 0x93, 0x03, 0x7d,
-	0x14, 0xea, 0x46, 0x59,
-	0x14, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0x88, 0x5d,
-	0x01, 0xd9, 0xb2, 0x05,
-	0x02, 0xa8, 0xf4, 0x31,
-	0x02, 0xa6, 0x18, 0x7d,
-	0x00, 0xe2, 0x34, 0x59,
-	0x20, 0x5b, 0x26, 0x6d,
-	0xfc, 0x42, 0x12, 0x7d,
-	0x10, 0x40, 0x14, 0x6d,
-	0x20, 0x4d, 0x16, 0x7d,
-	0x08, 0x5d, 0x26, 0x6d,
-	0x02, 0xa6, 0xc6, 0x6b,
-	0x00, 0xe2, 0x34, 0x59,
-	0x20, 0x5b, 0x26, 0x6d,
-	0x01, 0x1b, 0x46, 0x6d,
-	0xfc, 0x42, 0x22, 0x7d,
-	0x10, 0x40, 0x24, 0x6d,
-	0x20, 0x4d, 0x66, 0x7d,
-	0x08, 0x5d, 0x66, 0x7d,
-	0x02, 0x19, 0x32, 0x00,
-	0x01, 0x5b, 0x40, 0x31,
-	0x00, 0xe2, 0x96, 0x5c,
-	0x00, 0xe2, 0x8a, 0x5b,
-	0x20, 0xea, 0xb6, 0x00,
-	0x00, 0xe2, 0xc0, 0x5b,
-	0x20, 0x5c, 0xb8, 0x00,
-	0x04, 0x19, 0x3c, 0x6d,
-	0x01, 0x1a, 0x3c, 0x6d,
-	0x00, 0xe2, 0x34, 0x59,
-	0x01, 0x1a, 0x66, 0x7d,
-	0x80, 0xf9, 0xf2, 0x01,
-	0x20, 0xa0, 0xac, 0x7d,
-	0x08, 0xa8, 0x45, 0x7d,
-	0x00, 0xe2, 0x58, 0x45,
-	0x02, 0xea, 0xb4, 0x04,
-	0x02, 0x19, 0x32, 0x00,
-	0x08, 0xa8, 0x69, 0x7d,
-	0x04, 0x5d, 0xc2, 0x7d,
-	0x01, 0x1a, 0xc2, 0x7d,
-	0x01, 0xa4, 0x49, 0x03,
-	0x80, 0xf9, 0xf2, 0x01,
-	0x02, 0xa8, 0x84, 0x32,
-	0x02, 0xea, 0xb4, 0x00,
-	0x00, 0xe2, 0x34, 0x43,
-	0x02, 0xa8, 0x84, 0x32,
-	0x02, 0xea, 0xb4, 0x00,
-	0xff, 0xea, 0xd4, 0x19,
-	0x00, 0xe2, 0x40, 0x59,
-	0x11, 0x00, 0x00, 0x10,
-	0x00, 0xe2, 0x98, 0x5d,
-	0x00, 0xe2, 0x34, 0x53,
-	0xff, 0xea, 0xd4, 0x0d,
-	0x00, 0xe2, 0x34, 0x59,
-	0x40, 0x5b, 0x74, 0x6d,
-	0x04, 0x5d, 0xc2, 0x7d,
-	0x01, 0x1a, 0xc2, 0x7d,
-	0x20, 0x4d, 0x66, 0x7d,
-	0x40, 0x5b, 0xac, 0x7d,
-	0x04, 0x5d, 0xc2, 0x7d,
-	0x01, 0x1a, 0xc2, 0x7d,
-	0x80, 0xf9, 0xf2, 0x01,
-	0x01, 0xa4, 0x49, 0x03,
-	0x08, 0xa8, 0x59, 0x6d,
-	0x02, 0xea, 0xb4, 0x04,
-	0xff, 0x6a, 0x8e, 0x7d,
-	0x10, 0xea, 0x46, 0x59,
-	0x10, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0x8e, 0x45,
-	0x00, 0xe2, 0x32, 0x59,
-	0x10, 0x5d, 0x80, 0x6d,
-	0x40, 0x5b, 0x66, 0x7d,
-	0x02, 0x19, 0x32, 0x00,
-	0x80, 0xf9, 0xf2, 0x01,
-	0xff, 0xea, 0x10, 0x03,
-	0x08, 0xa8, 0x51, 0x03,
-	0x00, 0xe2, 0x58, 0x45,
-	0x80, 0xf9, 0x66, 0x6d,
-	0x01, 0x43, 0xc1, 0x31,
-	0x00, 0xfb, 0x66, 0x65,
-	0x01, 0x42, 0xc1, 0x31,
-	0x00, 0xfa, 0x66, 0x65,
-	0x01, 0xe8, 0xd4, 0x1d,
-	0x30, 0x3f, 0xc0, 0x09,
-	0x30, 0xe0, 0x66, 0x65,
-	0x40, 0x4b, 0x66, 0x6d,
-	0xff, 0xea, 0x52, 0x01,
-	0xee, 0x00, 0xb2, 0x6d,
-	0x80, 0xf9, 0xf2, 0x01,
-	0x02, 0xea, 0xb4, 0x00,
-	0x20, 0xea, 0x9a, 0x00,
-	0xf3, 0x42, 0xbc, 0x6d,
-	0x12, 0xea, 0x46, 0x59,
-	0x12, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0xee, 0x41,
-	0x0d, 0xea, 0x46, 0x59,
-	0x0d, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0xee, 0x41,
-	0x11, 0xea, 0x46, 0x59,
-	0x11, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0x24, 0x5b,
-	0x08, 0x5a, 0xb4, 0x00,
-	0x00, 0xe2, 0xe4, 0x5d,
-	0xa8, 0xea, 0x32, 0x00,
-	0x00, 0xe2, 0x34, 0x59,
-	0x80, 0x1a, 0xd6, 0x7d,
-	0x00, 0xe2, 0xe4, 0x5d,
-	0x80, 0x19, 0x32, 0x00,
-	0x40, 0x5b, 0xdc, 0x6d,
-	0x08, 0x5a, 0xdc, 0x7d,
-	0x20, 0x4d, 0x66, 0x7d,
-	0x02, 0x84, 0x09, 0x03,
-	0x40, 0x5b, 0xac, 0x7d,
-	0x08, 0xa8, 0x51, 0x6d,
-	0x02, 0xea, 0xb4, 0x04,
-	0x01, 0x38, 0xe1, 0x30,
-	0x05, 0x39, 0xe3, 0x98,
-	0x01, 0xe0, 0xf8, 0x31,
-	0xff, 0xea, 0xc0, 0x09,
-	0x00, 0x3a, 0xe5, 0x20,
-	0x00, 0x3b, 0xe7, 0x20,
-	0x01, 0xfc, 0xc0, 0x31,
-	0x04, 0xea, 0xe8, 0x30,
-	0xff, 0xea, 0xf0, 0x08,
-	0x02, 0xea, 0xf2, 0x00,
-	0xff, 0xea, 0xf4, 0x0c
-};
-
-typedef int ahd_patch_func_t (struct ahd_softc *ahd);
-static ahd_patch_func_t ahd_patch18_func;
-
-static int
-ahd_patch18_func(struct ahd_softc *ahd)
-{
-	return ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0);
-}
-
-static ahd_patch_func_t ahd_patch17_func;
-
-static int
-ahd_patch17_func(struct ahd_softc *ahd)
-{
-	return ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) == 0);
-}
-
-static ahd_patch_func_t ahd_patch16_func;
-
-static int
-ahd_patch16_func(struct ahd_softc *ahd)
-{
-	return ((ahd->flags & AHD_INITIATORROLE) != 0);
-}
-
-static ahd_patch_func_t ahd_patch15_func;
-
-static int
-ahd_patch15_func(struct ahd_softc *ahd)
-{
-	return ((ahd->flags & AHD_TARGETROLE) != 0);
-}
-
-static ahd_patch_func_t ahd_patch14_func;
-
-static int
-ahd_patch14_func(struct ahd_softc *ahd)
-{
-	return ((ahd->bugs & AHD_AUTOFLUSH_BUG) != 0);
-}
-
-static ahd_patch_func_t ahd_patch13_func;
-
-static int
-ahd_patch13_func(struct ahd_softc *ahd)
-{
-	return ((ahd->features & AHD_NEW_DFCNTRL_OPTS) != 0);
-}
-
-static ahd_patch_func_t ahd_patch12_func;
-
-static int
-ahd_patch12_func(struct ahd_softc *ahd)
-{
-	return ((ahd->flags & AHD_39BIT_ADDRESSING) != 0);
-}
-
-static ahd_patch_func_t ahd_patch11_func;
-
-static int
-ahd_patch11_func(struct ahd_softc *ahd)
-{
-	return ((ahd->flags & AHD_64BIT_ADDRESSING) != 0);
-}
-
-static ahd_patch_func_t ahd_patch10_func;
-
-static int
-ahd_patch10_func(struct ahd_softc *ahd)
-{
-	return ((ahd->bugs & AHD_REG_SLOW_SETTLE_BUG) != 0);
-}
-
-static ahd_patch_func_t ahd_patch9_func;
-
-static int
-ahd_patch9_func(struct ahd_softc *ahd)
-{
-	return ((ahd->bugs & AHD_BUSFREEREV_BUG) == 0);
-}
-
-static ahd_patch_func_t ahd_patch8_func;
-
-static int
-ahd_patch8_func(struct ahd_softc *ahd)
-{
-	return ((ahd->bugs & AHD_ABORT_LQI_BUG) == 0);
-}
-
-static ahd_patch_func_t ahd_patch7_func;
-
-static int
-ahd_patch7_func(struct ahd_softc *ahd)
-{
-	return ((ahd->flags & AHD_SEQUENCER_DEBUG) != 0);
-}
-
-static ahd_patch_func_t ahd_patch6_func;
-
-static int
-ahd_patch6_func(struct ahd_softc *ahd)
-{
-	return ((ahd->bugs & AHD_LQO_ATNO_BUG) != 0);
-}
-
-static ahd_patch_func_t ahd_patch5_func;
-
-static int
-ahd_patch5_func(struct ahd_softc *ahd)
-{
-	return ((ahd->bugs & AHD_BUSFREEREV_BUG) != 0);
-}
-
-static ahd_patch_func_t ahd_patch4_func;
-
-static int
-ahd_patch4_func(struct ahd_softc *ahd)
-{
-	return ((ahd->bugs & AHD_NONPACKFIFO_BUG) != 0);
-}
-
-static ahd_patch_func_t ahd_patch3_func;
-
-static int
-ahd_patch3_func(struct ahd_softc *ahd)
-{
-	return ((ahd->bugs & AHD_SENT_SCB_UPDATE_BUG) != 0);
-}
-
-static ahd_patch_func_t ahd_patch2_func;
-
-static int
-ahd_patch2_func(struct ahd_softc *ahd)
-{
-	return ((ahd->bugs & AHD_SET_MODE_BUG) != 0);
-}
-
-static ahd_patch_func_t ahd_patch1_func;
-
-static int
-ahd_patch1_func(struct ahd_softc *ahd)
-{
-	return ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0);
-}
-
-static ahd_patch_func_t ahd_patch0_func;
-
-static int
-ahd_patch0_func(struct ahd_softc *ahd)
-{
-	return (0);
-}
-
-static struct patch {
-	ahd_patch_func_t		*patch_func;
-	uint32_t		 begin		:10,
-				 skip_instr	:10,
-				 skip_patch	:12;
-} patches[] = {
-	{ ahd_patch1_func, 0, 3, 3 },
-	{ ahd_patch1_func, 1, 1, 2 },
-	{ ahd_patch0_func, 2, 1, 1 },
-	{ ahd_patch1_func, 3, 3, 3 },
-	{ ahd_patch1_func, 4, 1, 2 },
-	{ ahd_patch0_func, 5, 1, 1 },
-	{ ahd_patch2_func, 6, 1, 2 },
-	{ ahd_patch0_func, 7, 1, 1 },
-	{ ahd_patch2_func, 24, 1, 2 },
-	{ ahd_patch0_func, 25, 1, 1 },
-	{ ahd_patch1_func, 32, 1, 2 },
-	{ ahd_patch0_func, 33, 1, 1 },
-	{ ahd_patch2_func, 40, 1, 2 },
-	{ ahd_patch0_func, 41, 1, 1 },
-	{ ahd_patch2_func, 44, 1, 2 },
-	{ ahd_patch0_func, 45, 1, 1 },
-	{ ahd_patch2_func, 48, 1, 2 },
-	{ ahd_patch0_func, 49, 1, 1 },
-	{ ahd_patch2_func, 51, 1, 2 },
-	{ ahd_patch0_func, 52, 1, 1 },
-	{ ahd_patch2_func, 55, 1, 2 },
-	{ ahd_patch0_func, 56, 1, 1 },
-	{ ahd_patch2_func, 59, 1, 2 },
-	{ ahd_patch0_func, 60, 1, 1 },
-	{ ahd_patch2_func, 157, 6, 1 },
-	{ ahd_patch1_func, 163, 2, 1 },
-	{ ahd_patch3_func, 165, 1, 1 },
-	{ ahd_patch2_func, 174, 1, 2 },
-	{ ahd_patch0_func, 175, 1, 1 },
-	{ ahd_patch4_func, 176, 2, 2 },
-	{ ahd_patch0_func, 178, 6, 3 },
-	{ ahd_patch2_func, 181, 1, 2 },
-	{ ahd_patch0_func, 182, 1, 1 },
-	{ ahd_patch2_func, 185, 1, 2 },
-	{ ahd_patch0_func, 186, 1, 1 },
-	{ ahd_patch5_func, 188, 2, 1 },
-	{ ahd_patch3_func, 196, 16, 2 },
-	{ ahd_patch0_func, 212, 1, 1 },
-	{ ahd_patch6_func, 232, 2, 1 },
-	{ ahd_patch1_func, 236, 1, 2 },
-	{ ahd_patch0_func, 237, 1, 1 },
-	{ ahd_patch5_func, 240, 2, 1 },
-	{ ahd_patch1_func, 254, 1, 2 },
-	{ ahd_patch0_func, 255, 1, 1 },
-	{ ahd_patch1_func, 258, 1, 2 },
-	{ ahd_patch0_func, 259, 1, 1 },
-	{ ahd_patch2_func, 262, 1, 2 },
-	{ ahd_patch0_func, 263, 1, 1 },
-	{ ahd_patch1_func, 318, 1, 2 },
-	{ ahd_patch0_func, 319, 1, 1 },
-	{ ahd_patch2_func, 327, 1, 2 },
-	{ ahd_patch0_func, 328, 1, 1 },
-	{ ahd_patch2_func, 331, 1, 2 },
-	{ ahd_patch0_func, 332, 1, 1 },
-	{ ahd_patch1_func, 339, 1, 2 },
-	{ ahd_patch0_func, 340, 1, 1 },
-	{ ahd_patch7_func, 359, 1, 1 },
-	{ ahd_patch7_func, 362, 1, 1 },
-	{ ahd_patch7_func, 364, 1, 1 },
-	{ ahd_patch7_func, 376, 1, 1 },
-	{ ahd_patch1_func, 386, 1, 2 },
-	{ ahd_patch0_func, 387, 1, 1 },
-	{ ahd_patch1_func, 389, 1, 2 },
-	{ ahd_patch0_func, 390, 1, 1 },
-	{ ahd_patch1_func, 398, 1, 2 },
-	{ ahd_patch0_func, 399, 1, 1 },
-	{ ahd_patch2_func, 410, 1, 2 },
-	{ ahd_patch0_func, 411, 1, 1 },
-	{ ahd_patch8_func, 413, 1, 1 },
-	{ ahd_patch9_func, 440, 1, 1 },
-	{ ahd_patch1_func, 447, 1, 2 },
-	{ ahd_patch0_func, 448, 1, 1 },
-	{ ahd_patch2_func, 460, 1, 2 },
-	{ ahd_patch0_func, 461, 1, 1 },
-	{ ahd_patch10_func, 489, 1, 1 },
-	{ ahd_patch11_func, 498, 1, 2 },
-	{ ahd_patch0_func, 499, 1, 1 },
-	{ ahd_patch12_func, 504, 1, 1 },
-	{ ahd_patch11_func, 505, 1, 1 },
-	{ ahd_patch13_func, 518, 1, 2 },
-	{ ahd_patch0_func, 519, 1, 1 },
-	{ ahd_patch1_func, 541, 1, 2 },
-	{ ahd_patch0_func, 542, 1, 1 },
-	{ ahd_patch1_func, 545, 1, 2 },
-	{ ahd_patch0_func, 546, 1, 1 },
-	{ ahd_patch2_func, 551, 1, 2 },
-	{ ahd_patch0_func, 552, 1, 1 },
-	{ ahd_patch2_func, 556, 1, 2 },
-	{ ahd_patch0_func, 557, 1, 1 },
-	{ ahd_patch1_func, 558, 1, 2 },
-	{ ahd_patch0_func, 559, 1, 1 },
-	{ ahd_patch2_func, 570, 1, 2 },
-	{ ahd_patch0_func, 571, 1, 1 },
-	{ ahd_patch14_func, 575, 1, 1 },
-	{ ahd_patch15_func, 580, 1, 1 },
-	{ ahd_patch16_func, 581, 2, 1 },
-	{ ahd_patch15_func, 585, 1, 2 },
-	{ ahd_patch0_func, 586, 1, 1 },
-	{ ahd_patch2_func, 593, 1, 2 },
-	{ ahd_patch0_func, 594, 1, 1 },
-	{ ahd_patch2_func, 609, 1, 2 },
-	{ ahd_patch0_func, 610, 1, 1 },
-	{ ahd_patch1_func, 616, 1, 2 },
-	{ ahd_patch0_func, 617, 1, 1 },
-	{ ahd_patch1_func, 631, 1, 2 },
-	{ ahd_patch0_func, 632, 1, 1 },
-	{ ahd_patch1_func, 639, 1, 2 },
-	{ ahd_patch0_func, 640, 1, 1 },
-	{ ahd_patch14_func, 659, 1, 1 },
-	{ ahd_patch14_func, 675, 1, 1 },
-	{ ahd_patch2_func, 687, 1, 2 },
-	{ ahd_patch0_func, 688, 1, 1 },
-	{ ahd_patch1_func, 705, 1, 2 },
-	{ ahd_patch0_func, 706, 1, 1 },
-	{ ahd_patch14_func, 711, 1, 1 },
-	{ ahd_patch1_func, 731, 1, 2 },
-	{ ahd_patch0_func, 732, 1, 1 },
-	{ ahd_patch1_func, 734, 1, 2 },
-	{ ahd_patch0_func, 735, 1, 1 },
-	{ ahd_patch1_func, 737, 1, 2 },
-	{ ahd_patch0_func, 738, 1, 1 },
-	{ ahd_patch17_func, 740, 1, 2 },
-	{ ahd_patch0_func, 741, 2, 1 },
-	{ ahd_patch18_func, 744, 4, 2 },
-	{ ahd_patch0_func, 748, 1, 1 },
-	{ ahd_patch18_func, 754, 11, 1 }
-};
-
-static struct cs {
-	uint16_t	begin;
-	uint16_t	end;
-} critical_sections[] = {
-	{ 11, 12 },
-	{ 13, 14 },
-	{ 24, 37 },
-	{ 38, 51 },
-	{ 64, 67 },
-	{ 94, 119 },
-	{ 120, 151 },
-	{ 153, 157 },
-	{ 165, 173 },
-	{ 196, 245 },
-	{ 659, 675 },
-	{ 675, 693 },
-	{ 698, 704 },
-	{ 711, 716 },
-	{ 716, 722 }
-};
-
-static const int num_critical_sections = sizeof(critical_sections)
-				       / sizeof(*critical_sections);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aicasm/Makefile linux-2.4.22-pre2/drivers/scsi/aic79xx/aicasm/Makefile
--- linux-2.4.21/drivers/scsi/aic79xx/aicasm/Makefile	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aicasm/Makefile	2003-06-26 21:43:10.000000000 +0000
@@ -1,65 +0,0 @@
-PROG=	aicasm
-
-.SUFFIXES= .l .y .c .h
-
-CSRCS=	aicasm.c aicasm_symbol.c
-YSRCS=	aicasm_gram.y aicasm_macro_gram.y
-LSRCS=	aicasm_scan.l aicasm_macro_scan.l
-
-GENHDRS=	aicdb.h $(YSRCS:.y=.h)
-GENSRCS=	$(YSRCS:.y=.c) $(LSRCS:.l=.c)
-
-SRCS=	${CSRCS} ${GENSRCS}
-CLEANFILES= ${GENSRCS} ${GENHDRS} $(YSRCS:.y=.output)
-# Override default kernel CFLAGS.  This is a userland app.
-AICASM_CFLAGS:= -I/usr/include -I. -ldb
-YFLAGS= -d
-
-NOMAN=	noman
-
-ifneq ($(HOSTCC),)
-AICASM_CC= $(HOSTCC)
-else
-AICASM_CC= $(CC)
-endif
-
-ifdef DEBUG
-CFLAGS+= -DDEBUG -g
-YFLAGS+= -t -v
-LFLAGS= -d
-endif
-
-$(PROG):  ${GENHDRS} $(SRCS)
-	$(AICASM_CC) $(AICASM_CFLAGS) $(SRCS) -o $(PROG)
-
-aicdb.h:
-	@if [ -e "/usr/include/db3/db_185.h" ]; then		\
-		echo "#include <db3/db_185.h>" > aicdb.h;	\
-	 elif [ -e "/usr/include/db2/db_185.h" ]; then		\
-		echo "#include <db2/db_185.h>" > aicdb.h;	\
-	 elif [ -e "/usr/include/db/db_185.h" ]; then		\
-		echo "#include <db/db_185.h>" > aicdb.h;	\
-	 elif [ -e "/usr/include/db_185.h" ]; then		\
-		echo "#include <db_185.h>" > aicdb.h;		\
-	 else							\
-		echo "*** Install db development libraries";	\
-	 fi
-
-clean:
-	rm -f $(CLEANFILES) $(PROG)
-
-aicasm_gram.c aicasm_gram.h: aicasm_gram.y
-	$(YACC) $(YFLAGS) -b $(<:.y=) $<
-	mv $(<:.y=).tab.c $(<:.y=.c)
-	mv $(<:.y=).tab.h $(<:.y=.h)
-
-aicasm_macro_gram.c aicasm_macro_gram.h: aicasm_macro_gram.y
-	$(YACC) $(YFLAGS) -b $(<:.y=) -p mm $<
-	mv $(<:.y=).tab.c $(<:.y=.c)
-	mv $(<:.y=).tab.h $(<:.y=.h)
-
-aicasm_scan.c: aicasm_scan.l
-	$(LEX) $(LFLAGS) -o$@ $<
-
-aicasm_macro_scan.c: aicasm_macro_scan.l
-	$(LEX) $(LFLAGS) -Pmm -o$@ $<
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aicasm/aicasm.c linux-2.4.22-pre2/drivers/scsi/aic79xx/aicasm/aicasm.c
--- linux-2.4.21/drivers/scsi/aic79xx/aicasm/aicasm.c	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aicasm/aicasm.c	2003-06-26 21:43:32.000000000 +0000
@@ -1,835 +0,0 @@
-/*
- * Aic7xxx SCSI host adapter firmware asssembler
- *
- * Copyright (c) 1997, 1998, 2000, 2001 Justin T. Gibbs.
- * Copyright (c) 2001, 2002 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: //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#22 $
- *
- * $FreeBSD$
- */
-#include <sys/types.h>
-#include <sys/mman.h>
-
-#include <ctype.h>
-#include <inttypes.h>
-#include <regex.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sysexits.h>
-#include <unistd.h>
-
-#if linux
-#include <endian.h>
-#else
-#include <machine/endian.h>
-#endif
-
-#include "aicasm.h"
-#include "aicasm_symbol.h"
-#include "aicasm_insformat.h"
-
-typedef struct patch {
-	STAILQ_ENTRY(patch) links;
-	int		patch_func;
-	u_int		begin;
-	u_int		skip_instr;
-	u_int		skip_patch;
-} patch_t;
-
-STAILQ_HEAD(patch_list, patch) patches;
-
-static void usage(void);
-static void back_patch(void);
-static void output_code(void);
-static void output_listing(char *ifilename);
-static void dump_scope(scope_t *scope);
-static void emit_patch(scope_t *scope, int patch);
-static int check_patch(patch_t **start_patch, int start_instr,
-		       int *skip_addr, int *func_vals);
-
-struct path_list search_path;
-int includes_search_curdir;
-char *appname;
-char *stock_include_file;
-FILE *ofile;
-char *ofilename;
-char *regfilename;
-FILE *regfile;
-char *listfilename;
-FILE *listfile;
-char *regdiagfilename;
-FILE *regdiagfile;
-int   src_mode;
-int   dst_mode;
-
-static STAILQ_HEAD(,instruction) seq_program;
-struct cs_tailq cs_tailq;
-struct scope_list scope_stack;
-symlist_t patch_functions;
-
-#if DEBUG
-extern int yy_flex_debug;
-extern int mm_flex_debug;
-extern int yydebug;
-extern int mmdebug;
-#endif
-extern FILE *yyin;
-extern int yyparse(void);
-
-int main(int argc, char *argv[]);
-
-int
-main(int argc, char *argv[])
-{
-	extern char *optarg;
-	extern int optind;
-	int  ch;
-	int  retval;
-	char *inputfilename;
-	scope_t *sentinal;
-
-	STAILQ_INIT(&patches);
-	SLIST_INIT(&search_path);
-	STAILQ_INIT(&seq_program);
-	TAILQ_INIT(&cs_tailq);
-	SLIST_INIT(&scope_stack);
-
-	/* Set Sentinal scope node */
-	sentinal = scope_alloc();
-	sentinal->type = SCOPE_ROOT;
-	
-	includes_search_curdir = 1;
-	appname = *argv;
-	regfile = NULL;
-	listfile = NULL;
-#if DEBUG
-	yy_flex_debug = 0;
-	mm_flex_debug = 0;
-	yydebug = 0;
-	mmdebug = 0;
-#endif
-	while ((ch = getopt(argc, argv, "d:i:l:n:o:p:r:I:")) != -1) {
-		switch(ch) {
-		case 'd':
-#if DEBUG
-			if (strcmp(optarg, "s") == 0) {
-				yy_flex_debug = 1;
-				mm_flex_debug = 1;
-			} else if (strcmp(optarg, "p") == 0) {
-				yydebug = 1;
-				mmdebug = 1;
-			} else {
-				fprintf(stderr, "%s: -d Requires either an "
-					"'s' or 'p' argument\n", appname);
-				usage();
-			}
-#else
-			stop("-d: Assembler not built with debugging "
-			     "information", EX_SOFTWARE);
-#endif
-			break;
-		case 'i':
-			stock_include_file = optarg;
-			break;
-		case 'l':
-			/* Create a program listing */
-			if ((listfile = fopen(optarg, "w")) == NULL) {
-				perror(optarg);
-				stop(NULL, EX_CANTCREAT);
-			}
-			listfilename = optarg;
-			break;
-		case 'n':
-			/* Don't complain about the -nostdinc directrive */
-			if (strcmp(optarg, "ostdinc")) {
-				fprintf(stderr, "%s: Unknown option -%c%s\n",
-					appname, ch, optarg);
-				usage();
-				/* NOTREACHED */
-			}
-			break;
-		case 'o':
-			if ((ofile = fopen(optarg, "w")) == NULL) {
-				perror(optarg);
-				stop(NULL, EX_CANTCREAT);
-			}
-			ofilename = optarg;
-			break;
-		case 'p':
-			/* Create Register Diagnostic "printing" Functions */
-			if ((regdiagfile = fopen(optarg, "w")) == NULL) {
-				perror(optarg);
-				stop(NULL, EX_CANTCREAT);
-			}
-			regdiagfilename = optarg;
-			break;
-		case 'r':
-			if ((regfile = fopen(optarg, "w")) == NULL) {
-				perror(optarg);
-				stop(NULL, EX_CANTCREAT);
-			}
-			regfilename = optarg;
-			break;
-		case 'I':
-		{
-			path_entry_t include_dir;
-
-			if (strcmp(optarg, "-") == 0) {
-				if (includes_search_curdir == 0) {
-					fprintf(stderr, "%s: Warning - '-I-' "
-							"specified multiple "
-							"times\n", appname);
-				}
-				includes_search_curdir = 0;
-				for (include_dir = SLIST_FIRST(&search_path);
-				     include_dir != NULL;
-				     include_dir = SLIST_NEXT(include_dir,
-							      links))
-					/*
-					 * All entries before a '-I-' only
-					 * apply to includes specified with
-					 * quotes instead of "<>".
-					 */
-					include_dir->quoted_includes_only = 1;
-			} else {
-				include_dir =
-				    (path_entry_t)malloc(sizeof(*include_dir));
-				if (include_dir == NULL) {
-					perror(optarg);
-					stop(NULL, EX_OSERR);
-				}
-				include_dir->directory = strdup(optarg);
-				if (include_dir->directory == NULL) {
-					perror(optarg);
-					stop(NULL, EX_OSERR);
-				}
-				include_dir->quoted_includes_only = 0;
-				SLIST_INSERT_HEAD(&search_path, include_dir,
-						  links);
-			}
-			break;
-		}
-		case '?':
-		default:
-			usage();
-			/* NOTREACHED */
-		}
-	}
-	argc -= optind;
-	argv += optind;
-
-	if (argc != 1) {
-		fprintf(stderr, "%s: No input file specifiled\n", appname);
-		usage();
-		/* NOTREACHED */
-	}
-
-	if (regdiagfile != NULL
-	 && (regfile == NULL || stock_include_file == NULL)) {
-		fprintf(stderr,
-			"%s: The -p option requires the -r and -i options.\n",
-			appname);
-		usage();
-		/* NOTREACHED */
-	}
-	symtable_open();
-	inputfilename = *argv;
-	include_file(*argv, SOURCE_FILE);
-	retval = yyparse();
-	if (retval == 0) {
-		if (SLIST_FIRST(&scope_stack) == NULL
-		 || SLIST_FIRST(&scope_stack)->type != SCOPE_ROOT) {
-			stop("Unterminated conditional expression", EX_DATAERR);
-			/* NOTREACHED */
-		}
-
-		/* Process outmost scope */
-		process_scope(SLIST_FIRST(&scope_stack));
-		/*
-		 * Decend the tree of scopes and insert/emit
-		 * patches as appropriate.  We perform a depth first
-		 * tranversal, recursively handling each scope.
-		 */
-		/* start at the root scope */
-		dump_scope(SLIST_FIRST(&scope_stack));
-
-		/* Patch up forward jump addresses */
-		back_patch();
-
-		if (ofile != NULL)
-			output_code();
-		if (regfile != NULL)
-			symtable_dump(regfile, regdiagfile);
-		if (listfile != NULL)
-			output_listing(inputfilename);
-	}
-
-	stop(NULL, 0);
-	/* NOTREACHED */
-	return (0);
-}
-
-static void
-usage()
-{
-
-	(void)fprintf(stderr,
-"usage: %-16s [-nostdinc] [-I-] [-I directory] [-o output_file]\n"
-"	[-r register_output_file [-p register_diag_file -i includefile]]\n"
-"	[-l program_list_file]\n"
-"	input_file\n", appname);
-	exit(EX_USAGE);
-}
-
-static void
-back_patch()
-{
-	struct instruction *cur_instr;
-
-	for (cur_instr = STAILQ_FIRST(&seq_program);
-	     cur_instr != NULL;
-	     cur_instr = STAILQ_NEXT(cur_instr, links)) {
-		if (cur_instr->patch_label != NULL) {
-			struct ins_format3 *f3_instr;
-			u_int address;
-
-			if (cur_instr->patch_label->type != LABEL) {
-				char buf[255];
-
-				snprintf(buf, sizeof(buf),
-					 "Undefined label %s",
-					 cur_instr->patch_label->name);
-				stop(buf, EX_DATAERR);
-				/* NOTREACHED */
-			}
-			f3_instr = &cur_instr->format.format3;
-			address = f3_instr->address;
-			address += cur_instr->patch_label->info.linfo->address;
-			f3_instr->address = address;
-		}
-	}
-}
-
-static void
-output_code()
-{
-	struct instruction *cur_instr;
-	patch_t *cur_patch;
-	critical_section_t *cs;
-	symbol_node_t *cur_node;
-	int instrcount;
-
-	instrcount = 0;
-	fprintf(ofile,
-"/*\n"
-" * DO NOT EDIT - This file is automatically generated\n"
-" *		 from the following source files:\n"
-" *\n"
-"%s */\n", versions);
-
-	fprintf(ofile, "static uint8_t seqprog[] = {\n");
-	for (cur_instr = STAILQ_FIRST(&seq_program);
-	     cur_instr != NULL;
-	     cur_instr = STAILQ_NEXT(cur_instr, links)) {
-
-		fprintf(ofile, "%s\t0x%02x, 0x%02x, 0x%02x, 0x%02x",
-			cur_instr == STAILQ_FIRST(&seq_program) ? "" : ",\n",
-#if BYTE_ORDER == LITTLE_ENDIAN
-			cur_instr->format.bytes[0],
-			cur_instr->format.bytes[1],
-			cur_instr->format.bytes[2],
-			cur_instr->format.bytes[3]);
-#else
-			cur_instr->format.bytes[3],
-			cur_instr->format.bytes[2],
-			cur_instr->format.bytes[1],
-			cur_instr->format.bytes[0]);
-#endif
-		instrcount++;
-	}
-	fprintf(ofile, "\n};\n\n");
-
-	if (patch_arg_list == NULL)
-		stop("Patch argument list not defined",
-		     EX_DATAERR);
-
-	/*
-	 *  Output patch information.  Patch functions first.
-	 */
-	fprintf(ofile,
-"typedef int %spatch_func_t (%s);\n", prefix, patch_arg_list);
-
-	for (cur_node = SLIST_FIRST(&patch_functions);
-	     cur_node != NULL;
-	     cur_node = SLIST_NEXT(cur_node,links)) {
-		fprintf(ofile,
-"static %spatch_func_t %spatch%d_func;\n"
-"\n"
-"static int\n"
-"%spatch%d_func(%s)\n"
-"{\n"
-"	return (%s);\n"
-"}\n\n",
-			prefix,
-			prefix,
-			cur_node->symbol->info.condinfo->func_num,
-			prefix,
-			cur_node->symbol->info.condinfo->func_num,
-			patch_arg_list,
-			cur_node->symbol->name);
-	}
-
-	fprintf(ofile,
-"static struct patch {\n"
-"	%spatch_func_t		*patch_func;\n"
-"	uint32_t		 begin		:10,\n"
-"				 skip_instr	:10,\n"
-"				 skip_patch	:12;\n"
-"} patches[] = {\n", prefix);
-
-	for (cur_patch = STAILQ_FIRST(&patches);
-	     cur_patch != NULL;
-	     cur_patch = STAILQ_NEXT(cur_patch,links)) {
-		fprintf(ofile, "%s\t{ %spatch%d_func, %d, %d, %d }",
-			cur_patch == STAILQ_FIRST(&patches) ? "" : ",\n",
-			prefix,
-			cur_patch->patch_func, cur_patch->begin,
-			cur_patch->skip_instr, cur_patch->skip_patch);
-	}
-
-	fprintf(ofile, "\n};\n\n");
-
-	fprintf(ofile,
-"static struct cs {\n"
-"	uint16_t	begin;\n"
-"	uint16_t	end;\n"
-"} critical_sections[] = {\n");
-
-	for (cs = TAILQ_FIRST(&cs_tailq);
-	     cs != NULL;
-	     cs = TAILQ_NEXT(cs, links)) {
-		fprintf(ofile, "%s\t{ %d, %d }",
-			cs == TAILQ_FIRST(&cs_tailq) ? "" : ",\n",
-			cs->begin_addr, cs->end_addr);
-	}
-
-	fprintf(ofile, "\n};\n\n");
-
-	fprintf(ofile,
-"static const int num_critical_sections = sizeof(critical_sections)\n"
-"				       / sizeof(*critical_sections);\n");
-
-	fprintf(stderr, "%s: %d instructions used\n", appname, instrcount);
-}
-
-static void
-dump_scope(scope_t *scope)
-{
-	scope_t *cur_scope;
-
-	/*
-	 * Emit the first patch for this scope
-	 */
-	emit_patch(scope, 0);
-
-	/*
-	 * Dump each scope within this one.
-	 */
-	cur_scope = TAILQ_FIRST(&scope->inner_scope);
-
-	while (cur_scope != NULL) {
-
-		dump_scope(cur_scope);
-
-		cur_scope = TAILQ_NEXT(cur_scope, scope_links);
-	}
-
-	/*
-	 * Emit the second, closing, patch for this scope
-	 */
-	emit_patch(scope, 1);
-}
-
-void
-emit_patch(scope_t *scope, int patch)
-{
-	patch_info_t *pinfo;
-	patch_t *new_patch;
-
-	pinfo = &scope->patches[patch];
-
-	if (pinfo->skip_instr == 0)
-		/* No-Op patch */
-		return;
-
-	new_patch = (patch_t *)malloc(sizeof(*new_patch));
-
-	if (new_patch == NULL)
-		stop("Could not malloc patch structure", EX_OSERR);
-
-	memset(new_patch, 0, sizeof(*new_patch));
-
-	if (patch == 0) {
-		new_patch->patch_func = scope->func_num;
-		new_patch->begin = scope->begin_addr;
-	} else {
-		new_patch->patch_func = 0;
-		new_patch->begin = scope->end_addr;
-	}
-	new_patch->skip_instr = pinfo->skip_instr;
-	new_patch->skip_patch = pinfo->skip_patch;
-	STAILQ_INSERT_TAIL(&patches, new_patch, links);
-}
-
-void
-output_listing(char *ifilename)
-{
-	char buf[1024];
-	FILE *ifile;
-	struct instruction *cur_instr;
-	patch_t *cur_patch;
-	symbol_node_t *cur_func;
-	int *func_values;
-	int instrcount;
-	int instrptr;
-	int line;
-	int func_count;
-	int skip_addr;
-
-	instrcount = 0;
-	instrptr = 0;
-	line = 1;
-	skip_addr = 0;
-	if ((ifile = fopen(ifilename, "r")) == NULL) {
-		perror(ifilename);
-		stop(NULL, EX_DATAERR);
-	}
-
-	/*
-	 * Determine which options to apply to this listing.
-	 */
-	for (func_count = 0, cur_func = SLIST_FIRST(&patch_functions);
-	    cur_func != NULL;
-	    cur_func = SLIST_NEXT(cur_func, links))
-		func_count++;
-
-	func_values = NULL;
-	if (func_count != 0) {
-		func_values = (int *)malloc(func_count * sizeof(int));
-
-		if (func_values == NULL)
-			stop("Could not malloc", EX_OSERR);
-		
-		func_values[0] = 0; /* FALSE func */
-		func_count--;
-
-		/*
-		 * Ask the user to fill in the return values for
-		 * the rest of the functions.
-		 */
-		
-		
-		for (cur_func = SLIST_FIRST(&patch_functions);
-		     cur_func != NULL && SLIST_NEXT(cur_func, links) != NULL;
-		     cur_func = SLIST_NEXT(cur_func, links), func_count--) {
-			int input;
-			
-			fprintf(stdout, "\n(%s)\n", cur_func->symbol->name);
-			fprintf(stdout,
-				"Enter the return value for "
-				"this expression[T/F]:");
-
-			while (1) {
-
-				input = getchar();
-				input = toupper(input);
-
-				if (input == 'T') {
-					func_values[func_count] = 1;
-					break;
-				} else if (input == 'F') {
-					func_values[func_count] = 0;
-					break;
-				}
-			}
-			if (isatty(fileno(stdin)) == 0)
-				putchar(input);
-		}
-		fprintf(stdout, "\nThanks!\n");
-	}
-
-	/* Now output the listing */
-	cur_patch = STAILQ_FIRST(&patches);
-	for (cur_instr = STAILQ_FIRST(&seq_program);
-	     cur_instr != NULL;
-	     cur_instr = STAILQ_NEXT(cur_instr, links), instrcount++) {
-
-		if (check_patch(&cur_patch, instrcount,
-				&skip_addr, func_values) == 0) {
-			/* Don't count this instruction as it is in a patch
-			 * that was removed.
-			 */
-                        continue;
-		}
-
-		while (line < cur_instr->srcline) {
-			fgets(buf, sizeof(buf), ifile);
-				fprintf(listfile, "\t\t%s", buf);
-				line++;
-		}
-		fprintf(listfile, "%03x %02x%02x%02x%02x", instrptr,
-#if BYTE_ORDER == LITTLE_ENDIAN
-			cur_instr->format.bytes[0],
-			cur_instr->format.bytes[1],
-			cur_instr->format.bytes[2],
-			cur_instr->format.bytes[3]);
-#else
-			cur_instr->format.bytes[3],
-			cur_instr->format.bytes[2],
-			cur_instr->format.bytes[1],
-			cur_instr->format.bytes[0]);
-#endif
-		fgets(buf, sizeof(buf), ifile);
-		fprintf(listfile, "\t%s", buf);
-		line++;
-		instrptr++;
-	}
-	/* Dump the remainder of the file */
-	while(fgets(buf, sizeof(buf), ifile) != NULL)
-		fprintf(listfile, "\t\t%s", buf);
-
-	fclose(ifile);
-}
-
-static int
-check_patch(patch_t **start_patch, int start_instr,
-	    int *skip_addr, int *func_vals)
-{
-	patch_t *cur_patch;
-
-	cur_patch = *start_patch;
-
-	while (cur_patch != NULL && start_instr == cur_patch->begin) {
-		if (func_vals[cur_patch->patch_func] == 0) {
-			int skip;
-
-			/* Start rejecting code */
-			*skip_addr = start_instr + cur_patch->skip_instr;
-			for (skip = cur_patch->skip_patch;
-			     skip > 0 && cur_patch != NULL;
-			     skip--)
-				cur_patch = STAILQ_NEXT(cur_patch, links);
-		} else {
-			/* Accepted this patch.  Advance to the next
-			 * one and wait for our intruction pointer to
-			 * hit this point.
-			 */
-			cur_patch = STAILQ_NEXT(cur_patch, links);
-		}
-	}
-
-	*start_patch = cur_patch;
-	if (start_instr < *skip_addr)
-		/* Still skipping */
-		return (0);
-
-	return (1);
-}
-
-/*
- * Print out error information if appropriate, and clean up before
- * terminating the program.
- */
-void
-stop(const char *string, int err_code)
-{
-	if (string != NULL) {
-		fprintf(stderr, "%s: ", appname);
-		if (yyfilename != NULL) {
-			fprintf(stderr, "Stopped at file %s, line %d - ",
-				yyfilename, yylineno);
-		}
-		fprintf(stderr, "%s\n", string);
-	}
-
-	if (ofile != NULL) {
-		fclose(ofile);
-		if (err_code != 0) {
-			fprintf(stderr, "%s: Removing %s due to error\n",
-				appname, ofilename);
-			unlink(ofilename);
-		}
-	}
-
-	if (regfile != NULL) {
-		fclose(regfile);
-		if (err_code != 0) {
-			fprintf(stderr, "%s: Removing %s due to error\n",
-				appname, regfilename);
-			unlink(regfilename);
-		}
-	}
-
-	if (listfile != NULL) {
-		fclose(listfile);
-		if (err_code != 0) {
-			fprintf(stderr, "%s: Removing %s due to error\n",
-				appname, listfilename);
-			unlink(listfilename);
-		}
-	}
-
-	symlist_free(&patch_functions);
-	symtable_close();
-
-	exit(err_code);
-}
-
-struct instruction *
-seq_alloc()
-{
-	struct instruction *new_instr;
-
-	new_instr = (struct instruction *)malloc(sizeof(struct instruction));
-	if (new_instr == NULL)
-		stop("Unable to malloc instruction object", EX_SOFTWARE);
-	memset(new_instr, 0, sizeof(*new_instr));
-	STAILQ_INSERT_TAIL(&seq_program, new_instr, links);
-	new_instr->srcline = yylineno;
-	return new_instr;
-}
-
-critical_section_t *
-cs_alloc()
-{
-	critical_section_t *new_cs;
-
-	new_cs= (critical_section_t *)malloc(sizeof(critical_section_t));
-	if (new_cs == NULL)
-		stop("Unable to malloc critical_section object", EX_SOFTWARE);
-	memset(new_cs, 0, sizeof(*new_cs));
-	
-	TAILQ_INSERT_TAIL(&cs_tailq, new_cs, links);
-	return new_cs;
-}
-
-scope_t *
-scope_alloc()
-{
-	scope_t *new_scope;
-
-	new_scope = (scope_t *)malloc(sizeof(scope_t));
-	if (new_scope == NULL)
-		stop("Unable to malloc scope object", EX_SOFTWARE);
-	memset(new_scope, 0, sizeof(*new_scope));
-	TAILQ_INIT(&new_scope->inner_scope);
-	
-	if (SLIST_FIRST(&scope_stack) != NULL) {
-		TAILQ_INSERT_TAIL(&SLIST_FIRST(&scope_stack)->inner_scope,
-				  new_scope, scope_links);
-	}
-	/* This patch is now the current scope */
-	SLIST_INSERT_HEAD(&scope_stack, new_scope, scope_stack_links);
-	return new_scope;
-}
-
-void
-process_scope(scope_t *scope)
-{
-	/*
-	 * We are "leaving" this scope.  We should now have
-	 * enough information to process the lists of scopes
-	 * we encapsulate.
-	 */
-	scope_t *cur_scope;
-	u_int skip_patch_count;
-	u_int skip_instr_count;
-
-	cur_scope = TAILQ_LAST(&scope->inner_scope, scope_tailq);
-	skip_patch_count = 0;
-	skip_instr_count = 0;
-	while (cur_scope != NULL) {
-		u_int patch0_patch_skip;
-
-		patch0_patch_skip = 0;
-		switch (cur_scope->type) {
-		case SCOPE_IF:
-		case SCOPE_ELSE_IF:
-			if (skip_instr_count != 0) {
-				/* Create a tail patch */
-				patch0_patch_skip++;
-				cur_scope->patches[1].skip_patch =
-				    skip_patch_count + 1;
-				cur_scope->patches[1].skip_instr =
-				    skip_instr_count;
-			}
-
-			/* Count Head patch */
-			patch0_patch_skip++;
-
-			/* Count any patches contained in our inner scope */
-			patch0_patch_skip += cur_scope->inner_scope_patches;
-
-			cur_scope->patches[0].skip_patch = patch0_patch_skip;
-			cur_scope->patches[0].skip_instr =
-			    cur_scope->end_addr - cur_scope->begin_addr;
-
-			skip_instr_count += cur_scope->patches[0].skip_instr;
-
-			skip_patch_count += patch0_patch_skip;
-			if (cur_scope->type == SCOPE_IF) {
-				scope->inner_scope_patches += skip_patch_count;
-				skip_patch_count = 0;
-			        skip_instr_count = 0;
-			}
-			break;
-		case SCOPE_ELSE:
-			/* Count any patches contained in our innter scope */
-			skip_patch_count += cur_scope->inner_scope_patches;
-
-			skip_instr_count += cur_scope->end_addr
-					  - cur_scope->begin_addr;
-			break;
-		case SCOPE_ROOT:
-			stop("Unexpected scope type encountered", EX_SOFTWARE);
-			/* NOTREACHED */
-		}
-
-		cur_scope = TAILQ_PREV(cur_scope, scope_tailq, scope_links);
-	}
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aicasm/aicasm.h linux-2.4.22-pre2/drivers/scsi/aic79xx/aicasm/aicasm.h
--- linux-2.4.21/drivers/scsi/aic79xx/aicasm/aicasm.h	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aicasm/aicasm.h	2003-06-26 21:43:18.000000000 +0000
@@ -1,95 +0,0 @@
-/*
- * Assembler for the sequencer program downloaded to Aic7xxx SCSI host adapters
- *
- * Copyright (c) 1997 Justin T. Gibbs.
- * Copyright (c) 2001, 2002 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: //depot/aic7xxx/aic7xxx/aicasm/aicasm.h#14 $
- *
- * $FreeBSD$
- */
-
-#ifdef __linux__
-#include "../queue.h"
-#else
-#include <sys/queue.h>
-#endif
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-typedef struct path_entry {
-	char	*directory;
-	int	quoted_includes_only;
-	SLIST_ENTRY(path_entry) links;
-} *path_entry_t;
-
-typedef enum {  
-	QUOTED_INCLUDE,
-	BRACKETED_INCLUDE,
-	SOURCE_FILE
-} include_type;
-
-SLIST_HEAD(path_list, path_entry);
-
-extern struct path_list search_path;
-extern struct cs_tailq cs_tailq;
-extern struct scope_list scope_stack;
-extern struct symlist patch_functions;
-extern int includes_search_curdir;		/* False if we've seen -I- */
-extern char *appname;
-extern char *stock_include_file;
-extern int yylineno;
-extern char *yyfilename;
-extern char *prefix;
-extern char *patch_arg_list;
-extern char *versions;
-extern int   src_mode;
-extern int   dst_mode;
-struct symbol;
-
-void stop(const char *errstring, int err_code);
-void include_file(char *file_name, include_type type);
-void expand_macro(struct symbol *macro_symbol);
-struct instruction *seq_alloc(void);
-struct critical_section *cs_alloc(void);
-struct scope *scope_alloc(void);
-void process_scope(struct scope *);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aicasm/aicasm_gram.y linux-2.4.22-pre2/drivers/scsi/aic79xx/aicasm/aicasm_gram.y
--- linux-2.4.21/drivers/scsi/aic79xx/aicasm/aicasm_gram.y	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aicasm/aicasm_gram.y	2003-06-26 21:43:12.000000000 +0000
@@ -1,1945 +0,0 @@
-%{
-/*
- * Parser for the Aic7xxx SCSI Host adapter sequencer assembler.
- *
- * Copyright (c) 1997, 1998, 2000 Justin T. Gibbs.
- * Copyright (c) 2001, 2002 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: //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#29 $
- *
- * $FreeBSD$
- */
-
-#include <sys/types.h>
-
-#include <inttypes.h>
-#include <regex.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sysexits.h>
-
-#ifdef __linux__
-#include "../queue.h"
-#else
-#include <sys/queue.h>
-#endif
-
-#include "aicasm.h"
-#include "aicasm_symbol.h"
-#include "aicasm_insformat.h"
-
-int yylineno;
-char *yyfilename;
-char stock_prefix[] = "aic_";
-char *prefix = stock_prefix;
-char *patch_arg_list;
-char *versions;
-static char errbuf[255];
-static char regex_pattern[255];
-static symbol_t *cur_symbol;
-static symbol_t *field_symbol;
-static symbol_t *scb_or_sram_symbol;
-static symtype cur_symtype;
-static symbol_ref_t accumulator;
-static symbol_ref_t mode_ptr;
-static symbol_ref_t allones;
-static symbol_ref_t allzeros;
-static symbol_ref_t none;
-static symbol_ref_t sindex;
-static int instruction_ptr;
-static int num_srams;
-static int sram_or_scb_offset;
-static int download_constant_count;
-static int in_critical_section;
-static u_int enum_increment;
-static u_int enum_next_value;
-
-static void process_field(int field_type, symbol_t *sym, int mask);
-static void initialize_symbol(symbol_t *symbol);
-static void add_macro_arg(const char *argtext, int position);
-static void add_macro_body(const char *bodytext);
-static void process_register(symbol_t **p_symbol);
-static void format_1_instr(int opcode, symbol_ref_t *dest,
-			   expression_t *immed, symbol_ref_t *src, int ret);
-static void format_2_instr(int opcode, symbol_ref_t *dest,
-			   expression_t *places, symbol_ref_t *src, int ret);
-static void format_3_instr(int opcode, symbol_ref_t *src,
-			   expression_t *immed, symbol_ref_t *address);
-static void test_readable_symbol(symbol_t *symbol);
-static void test_writable_symbol(symbol_t *symbol);
-static void type_check(symbol_t *symbol, expression_t *expression, int and_op);
-static void make_expression(expression_t *immed, int value);
-static void add_conditional(symbol_t *symbol);
-static void add_version(const char *verstring);
-static int  is_download_const(expression_t *immed);
-
-#define SRAM_SYMNAME "SRAM_BASE"
-#define SCB_SYMNAME "SCB_BASE"
-%}
-
-%union {
-	u_int		value;
-	char		*str;
-	symbol_t	*sym;
-	symbol_ref_t	sym_ref;
-	expression_t	expression;
-}
-
-%token T_REGISTER
-
-%token <value> T_CONST
-
-%token T_EXPORT
-
-%token T_DOWNLOAD
-
-%token T_SCB
-
-%token T_SRAM
-
-%token T_ALIAS
-
-%token T_SIZE
-
-%token T_EXPR_LSHIFT
-
-%token T_EXPR_RSHIFT
-
-%token <value> T_ADDRESS
-
-%token T_ACCESS_MODE
-
-%token T_MODES
-
-%token T_DEFINE
-
-%token T_SET_SRC_MODE
-
-%token T_SET_DST_MODE
-
-%token <value> T_MODE
-
-%token T_BEGIN_CS
-
-%token T_END_CS
-
-%token T_FIELD
-
-%token T_ENUM
-
-%token T_MASK
-
-%token <value> T_NUMBER
-
-%token <str> T_PATH T_STRING T_ARG T_MACROBODY
-
-%token <sym> T_CEXPR
-
-%token T_EOF T_INCLUDE T_VERSION T_PREFIX T_PATCH_ARG_LIST
-
-%token <value> T_SHR T_SHL T_ROR T_ROL
-
-%token <value> T_MVI T_MOV T_CLR T_BMOV
-
-%token <value> T_JMP T_JC T_JNC T_JE T_JNE T_JNZ T_JZ T_CALL
-
-%token <value> T_ADD T_ADC
-
-%token <value> T_INC T_DEC
-
-%token <value> T_STC T_CLC
-
-%token <value> T_CMP T_NOT T_XOR
-
-%token <value> T_TEST T_AND
-
-%token <value> T_OR
-
-%token T_RET
-
-%token T_NOP
-
-%token T_ACCUM T_ALLONES T_ALLZEROS T_NONE T_SINDEX T_MODE_PTR
-
-%token T_A
-
-%token <sym> T_SYMBOL
-
-%token T_NL
-
-%token T_IF T_ELSE T_ELSE_IF T_ENDIF
-
-%type <sym_ref> reg_symbol address destination source opt_source
-
-%type <expression> expression immediate immediate_or_a
-
-%type <value> export ret f1_opcode f2_opcode jmp_jc_jnc_call jz_jnz je_jne
-
-%type <value> mode_value mode_list macro_arglist
-
-%left '|'
-%left '&'
-%left T_EXPR_LSHIFT T_EXPR_RSHIFT
-%left '+' '-'
-%left '*' '/'
-%right '~'
-%nonassoc UMINUS
-%%
-
-program:
-	include
-|	program include
-|	prefix
-|	program prefix
-|	patch_arg_list
-|	program patch_arg_list
-|	version
-|	program version
-|	register
-|	program register
-|	constant
-|	program constant
-|	macrodefn
-|	program macrodefn
-|	scratch_ram
-|	program scratch_ram
-|	scb
-|	program scb
-|	label
-|	program label
-|	set_src_mode
-|	program set_src_mode
-|	set_dst_mode
-|	program set_dst_mode
-|	critical_section_start
-|	program critical_section_start
-|	critical_section_end
-|	program critical_section_end
-|	conditional
-|	program conditional
-|	code
-|	program code
-;
-
-include:
-	T_INCLUDE '<' T_PATH '>'
-	{
-		include_file($3, BRACKETED_INCLUDE);
-	}
-|	T_INCLUDE '"' T_PATH '"'
-	{
-		include_file($3, QUOTED_INCLUDE);
-	}
-;
-
-prefix:
-	T_PREFIX '=' T_STRING
-	{
-		if (prefix != stock_prefix)
-			stop("Prefix multiply defined",
-			     EX_DATAERR);
-		prefix = strdup($3);
-		if (prefix == NULL)
-			stop("Unable to record prefix", EX_SOFTWARE);
-	}
-;
-
-patch_arg_list:
-	T_PATCH_ARG_LIST '=' T_STRING
-	{
-		if (patch_arg_list != NULL)
-			stop("Patch argument list multiply defined",
-			     EX_DATAERR);
-		patch_arg_list = strdup($3);
-		if (patch_arg_list == NULL)
-			stop("Unable to record patch arg list", EX_SOFTWARE);
-	}
-;
-
-version:
-	T_VERSION '=' T_STRING
-	{ add_version($3); }
-;
-
-register:
-	T_REGISTER { cur_symtype = REGISTER; } reg_definition
-;
-
-reg_definition:
-	T_SYMBOL '{'
-		{
-			if ($1->type != UNINITIALIZED) {
-				stop("Register multiply defined", EX_DATAERR);
-				/* NOTREACHED */
-			}
-			cur_symbol = $1; 
-			cur_symbol->type = cur_symtype;
-			initialize_symbol(cur_symbol);
-		}
-		reg_attribute_list
-	'}'
-		{                    
-			/*
-			 * Default to allowing everything in for registers
-			 * with no bit or mask definitions.
-			 */
-			if (cur_symbol->info.rinfo->valid_bitmask == 0)
-				cur_symbol->info.rinfo->valid_bitmask = 0xFF;
-
-			if (cur_symbol->info.rinfo->size == 0)
-				cur_symbol->info.rinfo->size = 1;
-
-			/*
-			 * This might be useful for registers too.
-			 */
-			if (cur_symbol->type != REGISTER) {
-				if (cur_symbol->info.rinfo->address == 0)
-					cur_symbol->info.rinfo->address =
-					    sram_or_scb_offset;
-				sram_or_scb_offset +=
-				    cur_symbol->info.rinfo->size;
-			}
-			cur_symbol = NULL;
-		}
-;
-
-reg_attribute_list:
-	reg_attribute
-|	reg_attribute_list reg_attribute
-;
-
-reg_attribute:		
-	reg_address
-|	size
-|	access_mode
-|	modes
-|	field_defn
-|	enum_defn
-|	mask_defn
-|	alias
-|	accumulator
-|	mode_pointer
-|	allones
-|	allzeros
-|	none
-|	sindex
-;
-
-reg_address:
-	T_ADDRESS T_NUMBER
-	{
-		cur_symbol->info.rinfo->address = $2;
-	}
-;
-
-size:
-	T_SIZE T_NUMBER
-	{
-		cur_symbol->info.rinfo->size = $2;
-		if (scb_or_sram_symbol != NULL) {
-			u_int max_addr;
-			u_int sym_max_addr;
-
-			max_addr = scb_or_sram_symbol->info.rinfo->address
-				 + scb_or_sram_symbol->info.rinfo->size;
-			sym_max_addr = cur_symbol->info.rinfo->address
-				     + cur_symbol->info.rinfo->size;
-
-			if (sym_max_addr > max_addr)
-				stop("SCB or SRAM space exhausted", EX_DATAERR);
-		}
-	}
-;
-
-access_mode:
-	T_ACCESS_MODE T_MODE
-	{
-		cur_symbol->info.rinfo->mode = $2;
-	}
-;
-
-modes:
-	T_MODES mode_list
-	{
-		cur_symbol->info.rinfo->modes = $2;
-	}
-;
-
-mode_list:
-	mode_value
-	{
-		$$ = $1;
-	}
-|	mode_list ',' mode_value
-	{
-		$$ = $1 | $3;
-	}
-;
-
-mode_value:
-	T_NUMBER
-	{
-		if ($1 > 4) {
-			stop("Valid register modes range between 0 and 4.",
-			     EX_DATAERR);
-			/* NOTREACHED */
-		}
-
-		$$ = (0x1 << $1);
-	}
-|	T_SYMBOL
-	{
-		symbol_t *symbol;
-
-		symbol = $1;
-		if (symbol->type != CONST) {
-			stop("Only \"const\" symbols allowed in "
-			     "mode definitions.", EX_DATAERR);
-			/* NOTREACHED */
-		}
-		if (symbol->info.cinfo->value > 4) {
-			stop("Valid register modes range between 0 and 4.",
-			     EX_DATAERR);
-			/* NOTREACHED */
-		}
-		$$ = (0x1 << symbol->info.cinfo->value);
-	}
-;
-
-field_defn:
-	T_FIELD
-		{
-			field_symbol = NULL;
-			enum_next_value = 0;
-			enum_increment = 1;
-		}
-	'{' enum_entry_list '}'
-|	T_FIELD T_SYMBOL expression
-		{
-			process_field(FIELD, $2, $3.value);
-			field_symbol = $2;
-			enum_next_value = 0;
-			enum_increment = 0x01 << (ffs($3.value) - 1);
-		}
-	'{' enum_entry_list '}'
-|	T_FIELD T_SYMBOL expression
-	{
-		process_field(FIELD, $2, $3.value);
-	}
-;
-
-enum_defn:
-	T_ENUM
-		{
-			field_symbol = NULL;
-			enum_next_value = 0;
-			enum_increment = 1;
-		}
-	'{' enum_entry_list '}'
-|	T_ENUM T_SYMBOL expression
-		{
-			process_field(ENUM, $2, $3.value);
-			field_symbol = $2;
-			enum_next_value = 0;
-			enum_increment = 0x01 << (ffs($3.value) - 1);
-		}
-	'{' enum_entry_list '}'
-;
-
-enum_entry_list:
-	enum_entry
-|	enum_entry_list ',' enum_entry
-;
-
-enum_entry:
-	T_SYMBOL
-	{
-		process_field(ENUM_ENTRY, $1, enum_next_value);
-		enum_next_value += enum_increment;
-	}
-|	T_SYMBOL expression
-	{
-		process_field(ENUM_ENTRY, $1, $2.value);
-		enum_next_value = $2.value + enum_increment;
-	}
-;
-
-mask_defn:
-	T_MASK T_SYMBOL expression
-	{
-		process_field(MASK, $2, $3.value);
-	}
-;
-
-alias:
-	T_ALIAS	T_SYMBOL
-	{
-		if ($2->type != UNINITIALIZED) {
-			stop("Re-definition of register alias",
-			     EX_DATAERR);
-			/* NOTREACHED */
-		}
-		$2->type = ALIAS;
-		initialize_symbol($2);
-		$2->info.ainfo->parent = cur_symbol;
-	}
-;
-
-accumulator:
-	T_ACCUM
-	{
-		if (accumulator.symbol != NULL) {
-			stop("Only one accumulator definition allowed",
-			     EX_DATAERR);
-			/* NOTREACHED */
-		}
-		accumulator.symbol = cur_symbol;
-	}
-;
-
-mode_pointer:
-	T_MODE_PTR
-	{
-		if (mode_ptr.symbol != NULL) {
-			stop("Only one mode pointer definition allowed",
-			     EX_DATAERR);
-			/* NOTREACHED */
-		}
-		mode_ptr.symbol = cur_symbol;
-	}
-;
-
-allones:
-	T_ALLONES
-	{
-		if (allones.symbol != NULL) {
-			stop("Only one definition of allones allowed",
-			     EX_DATAERR);
-			/* NOTREACHED */
-		}
-		allones.symbol = cur_symbol;
-	}
-;
-
-allzeros:
-	T_ALLZEROS
-	{
-		if (allzeros.symbol != NULL) {
-			stop("Only one definition of allzeros allowed",
-			     EX_DATAERR);
-			/* NOTREACHED */
-		}
-		allzeros.symbol = cur_symbol;
-	}
-;
-
-none:
-	T_NONE
-	{
-		if (none.symbol != NULL) {
-			stop("Only one definition of none allowed",
-			     EX_DATAERR);
-			/* NOTREACHED */
-		}
-		none.symbol = cur_symbol;
-	}
-;
-
-sindex:
-	T_SINDEX
-	{
-		if (sindex.symbol != NULL) {
-			stop("Only one definition of sindex allowed",
-			     EX_DATAERR);
-			/* NOTREACHED */
-		}
-		sindex.symbol = cur_symbol;
-	}
-;
-
-expression:
-	expression '|' expression
-	{
-		 $$.value = $1.value | $3.value;
-		 symlist_merge(&$$.referenced_syms,
-			       &$1.referenced_syms,
-			       &$3.referenced_syms);
-	}
-|	expression '&' expression
-	{
-		$$.value = $1.value & $3.value;
-		symlist_merge(&$$.referenced_syms,
-			       &$1.referenced_syms,
-			       &$3.referenced_syms);
-	}
-|	expression '+' expression
-	{
-		$$.value = $1.value + $3.value;
-		symlist_merge(&$$.referenced_syms,
-			       &$1.referenced_syms,
-			       &$3.referenced_syms);
-	}
-|	expression '-' expression
-	{
-		$$.value = $1.value - $3.value;
-		symlist_merge(&($$.referenced_syms),
-			       &($1.referenced_syms),
-			       &($3.referenced_syms));
-	}
-|	expression '*' expression
-	{
-		$$.value = $1.value * $3.value;
-		symlist_merge(&($$.referenced_syms),
-			       &($1.referenced_syms),
-			       &($3.referenced_syms));
-	}
-|	expression '/' expression
-	{
-		$$.value = $1.value / $3.value;
-		symlist_merge(&($$.referenced_syms),
-			       &($1.referenced_syms),
-			       &($3.referenced_syms));
-	}
-| 	expression T_EXPR_LSHIFT expression
-	{
-		$$.value = $1.value << $3.value;
-		symlist_merge(&$$.referenced_syms,
-			       &$1.referenced_syms,
-			       &$3.referenced_syms);
-	}
-| 	expression T_EXPR_RSHIFT expression
-	{
-		$$.value = $1.value >> $3.value;
-		symlist_merge(&$$.referenced_syms,
-			       &$1.referenced_syms,
-			       &$3.referenced_syms);
-	}
-|	'(' expression ')'
-	{
-		$$ = $2;
-	}
-|	'~' expression
-	{
-		$$ = $2;
-		$$.value = (~$$.value) & 0xFF;
-	}
-|	'-' expression %prec UMINUS
-	{
-		$$ = $2;
-		$$.value = -$$.value;
-	}
-|	T_NUMBER
-	{
-		$$.value = $1;
-		SLIST_INIT(&$$.referenced_syms);
-	}
-|	T_SYMBOL
-	{
-		symbol_t *symbol;
-
-		symbol = $1;
-		switch (symbol->type) {
-		case ALIAS:
-			symbol = $1->info.ainfo->parent;
-		case REGISTER:
-		case SCBLOC:
-		case SRAMLOC:
-			$$.value = symbol->info.rinfo->address;
-			break;
-		case MASK:
-		case FIELD:
-		case ENUM:
-		case ENUM_ENTRY:
-			$$.value = symbol->info.finfo->value;
-			break;
-		case DOWNLOAD_CONST:
-		case CONST:
-			$$.value = symbol->info.cinfo->value;
-			break;
-		case UNINITIALIZED:
-		default:
-		{
-			snprintf(errbuf, sizeof(errbuf),
-				 "Undefined symbol %s referenced",
-				 symbol->name);
-			stop(errbuf, EX_DATAERR);
-			/* NOTREACHED */
-			break;
-		}
-		}
-		SLIST_INIT(&$$.referenced_syms);
-		symlist_add(&$$.referenced_syms, symbol, SYMLIST_INSERT_HEAD);
-	}
-;
-
-constant:
-	T_CONST T_SYMBOL expression 
-	{
-		if ($2->type != UNINITIALIZED) {
-			stop("Re-definition of symbol as a constant",
-			     EX_DATAERR);
-			/* NOTREACHED */
-		}
-		$2->type = CONST;
-		initialize_symbol($2);
-		$2->info.cinfo->value = $3.value;
-	}
-|	T_CONST T_SYMBOL T_DOWNLOAD
-	{
-		if ($1) {
-			stop("Invalid downloaded constant declaration",
-			     EX_DATAERR);
-			/* NOTREACHED */
-		}
-		if ($2->type != UNINITIALIZED) {
-			stop("Re-definition of symbol as a downloaded constant",
-			     EX_DATAERR);
-			/* NOTREACHED */
-		}
-		$2->type = DOWNLOAD_CONST;
-		initialize_symbol($2);
-		$2->info.cinfo->value = download_constant_count++;
-	}
-;
-
-macrodefn_prologue:
-	T_DEFINE T_SYMBOL
-	{
-		if ($2->type != UNINITIALIZED) {
-			stop("Re-definition of symbol as a macro",
-			     EX_DATAERR);
-			/* NOTREACHED */
-		}
-		cur_symbol = $2;
-		cur_symbol->type = MACRO;
-		initialize_symbol(cur_symbol);
-	}
-;
-
-macrodefn:
-	macrodefn_prologue T_MACROBODY
-	{
-		add_macro_body($2);
-	}
-|	macrodefn_prologue '(' macro_arglist ')' T_MACROBODY
-	{
-		add_macro_body($5);
-		cur_symbol->info.macroinfo->narg = $3;
-	}
-;
-
-macro_arglist:
-	{
-		/* Macros can take no arguments */
-		$$ = 0;
-	}
-|	T_ARG
-	{
-		$$ = 1;
-		add_macro_arg($1, 0);
-	}
-|	macro_arglist ',' T_ARG
-	{
-		if ($1 == 0) {
-			stop("Comma without preceeding argument in arg list",
-			     EX_DATAERR);
-			/* NOTREACHED */
-		}
-		$$ = $1 + 1;
-		add_macro_arg($3, $1);
-	}
-;
-
-scratch_ram:
-	T_SRAM '{'
-		{
-			snprintf(errbuf, sizeof(errbuf), "%s%d", SRAM_SYMNAME,
-				 num_srams);
-			cur_symbol = symtable_get(SRAM_SYMNAME);
-			cur_symtype = SRAMLOC;
-			cur_symbol->type = SRAMLOC;
-			initialize_symbol(cur_symbol);
-		}
-		reg_address
-		{
-			sram_or_scb_offset = cur_symbol->info.rinfo->address;
-		}
-		size
-		{
-			scb_or_sram_symbol = cur_symbol;
-		}
-		scb_or_sram_attributes
-	'}'
-		{
-			cur_symbol = NULL;
-			scb_or_sram_symbol = NULL;
-		}
-;
-
-scb:
-	T_SCB '{'
-		{
-			cur_symbol = symtable_get(SCB_SYMNAME);
-			cur_symtype = SCBLOC;
-			if (cur_symbol->type != UNINITIALIZED) {
-				stop("Only one SRAM definition allowed",
-				     EX_SOFTWARE);
-				/* NOTREACHED */
-			}
-			cur_symbol->type = SCBLOC;
-			initialize_symbol(cur_symbol);
-			/* 64 bytes of SCB space */
-			cur_symbol->info.rinfo->size = 64;
-		}
-		reg_address
-		{
-			sram_or_scb_offset = cur_symbol->info.rinfo->address;
-		}
-		size
-		{
-			scb_or_sram_symbol = cur_symbol;
-		}
-		scb_or_sram_attributes
-	'}'
-		{
-			cur_symbol = NULL;
-			scb_or_sram_symbol = NULL;
-		}
-;
-
-scb_or_sram_attributes:
-	/* NULL definition is okay */
-|	modes
-|	scb_or_sram_reg_list
-|	modes scb_or_sram_reg_list
-;
-
-scb_or_sram_reg_list:
-	reg_definition
-|	scb_or_sram_reg_list reg_definition
-;
-
-reg_symbol:
-	T_SYMBOL
-	{
-		process_register(&$1);
-		$$.symbol = $1;
-		$$.offset = 0;
-	}
-|	T_SYMBOL '[' T_SYMBOL ']'
-	{
-		process_register(&$1);
-		if ($3->type != CONST) {
-			stop("register offset must be a constant", EX_DATAERR);
-			/* NOTREACHED */
-		}
-		if (($3->info.cinfo->value + 1) > $1->info.rinfo->size) {
-			stop("Accessing offset beyond range of register",
-			     EX_DATAERR);
-			/* NOTREACHED */
-		}
-		$$.symbol = $1;
-		$$.offset = $3->info.cinfo->value;
-	}
-|	T_SYMBOL '[' T_NUMBER ']'
-	{
-		process_register(&$1);
-		if (($3 + 1) > $1->info.rinfo->size) {
-			stop("Accessing offset beyond range of register",
-			     EX_DATAERR);
-			/* NOTREACHED */
-		}
-		$$.symbol = $1;
-		$$.offset = $3;
-	}
-|	T_A
-	{
-		if (accumulator.symbol == NULL) {
-			stop("No accumulator has been defined", EX_DATAERR);
-			/* NOTREACHED */
-		}
-		$$.symbol = accumulator.symbol;
-		$$.offset = 0;
-	}
-;
-
-destination:
-	reg_symbol
-	{
-		test_writable_symbol($1.symbol);
-		$$ = $1;
-	}
-;
-
-immediate:
-	expression
-	{ $$ = $1; }
-;
-
-immediate_or_a:
-	expression
-	{
-		if ($1.value == 0 && is_download_const(&$1) == 0) {
-			snprintf(errbuf, sizeof(errbuf),
-				 "\nExpression evaluates to 0 and thus "
-				 "references the accumulator.\n "
-				 "If this is the desired effect, use 'A' "
-				 "instead.\n");
-			stop(errbuf, EX_DATAERR);
-		}
-		$$ = $1;
-	}
-|	T_A
-	{
-		SLIST_INIT(&$$.referenced_syms);
-		symlist_add(&$$.referenced_syms, accumulator.symbol,
-			    SYMLIST_INSERT_HEAD);
-		$$.value = 0;
-	}
-;
-
-source:
-	reg_symbol
-	{
-		test_readable_symbol($1.symbol);
-		$$ = $1;
-	}
-;
-
-opt_source:
-	{
-		$$.symbol = NULL;
-		$$.offset = 0;
-	}
-|	',' source
-	{ $$ = $2; }
-;
-
-ret:
-	{ $$ = 0; }
-|	T_RET
-	{ $$ = 1; }
-;
-
-set_src_mode:
-	T_SET_SRC_MODE T_NUMBER ';'
-	{
-		src_mode = $2;
-	}
-;
-
-set_dst_mode:
-	T_SET_DST_MODE T_NUMBER ';'
-	{
-		dst_mode = $2;
-	}
-;
-
-critical_section_start:
-	T_BEGIN_CS ';'
-	{
-		critical_section_t *cs;
-
-		if (in_critical_section != FALSE) {
-			stop("Critical Section within Critical Section",
-			     EX_DATAERR);
-			/* NOTREACHED */
-		}
-		cs = cs_alloc();
-		cs->begin_addr = instruction_ptr;
-		in_critical_section = TRUE;
-	}
-;
-
-critical_section_end:
-	T_END_CS ';'
-	{
-		critical_section_t *cs;
-
-		if (in_critical_section == FALSE) {
-			stop("Unballanced 'end_cs'", EX_DATAERR);
-			/* NOTREACHED */
-		}
-		cs = TAILQ_LAST(&cs_tailq, cs_tailq);
-		cs->end_addr = instruction_ptr;
-		in_critical_section = FALSE;
-	}
-;
-
-export:
-	{ $$ = 0; }
-|	T_EXPORT
-	{ $$ = 1; }
-;
-
-label:
-	export T_SYMBOL ':'
-	{
-		if ($2->type != UNINITIALIZED) {
-			stop("Program label multiply defined", EX_DATAERR);
-			/* NOTREACHED */
-		}
-		$2->type = LABEL;
-		initialize_symbol($2);
-		$2->info.linfo->address = instruction_ptr;
-		$2->info.linfo->exported = $1;
-	}
-;
-
-address:
-	T_SYMBOL
-	{
-		$$.symbol = $1;
-		$$.offset = 0;
-	}
-|	T_SYMBOL '+' T_NUMBER
-	{
-		$$.symbol = $1;
-		$$.offset = $3;
-	}
-|	T_SYMBOL '-' T_NUMBER
-	{
-		$$.symbol = $1;
-		$$.offset = -$3;
-	}
-|	'.'
-	{
-		$$.symbol = NULL;
-		$$.offset = 0;
-	}
-|	'.' '+' T_NUMBER
-	{
-		$$.symbol = NULL;
-		$$.offset = $3;
-	}
-|	'.' '-' T_NUMBER
-	{
-		$$.symbol = NULL;
-		$$.offset = -$3;
-	}
-;
-
-conditional:
-	T_IF T_CEXPR '{'
-	{
-		scope_t *new_scope;
-
-		add_conditional($2);
-		new_scope = scope_alloc();
-		new_scope->type = SCOPE_IF;
-		new_scope->begin_addr = instruction_ptr;
-		new_scope->func_num = $2->info.condinfo->func_num;
-	}
-|	T_ELSE T_IF T_CEXPR '{'
-	{
-		scope_t *new_scope;
-		scope_t *scope_context;
-		scope_t *last_scope;
-
-		/*
-		 * Ensure that the previous scope is either an
-		 * if or and else if.
-		 */
-		scope_context = SLIST_FIRST(&scope_stack);
-		last_scope = TAILQ_LAST(&scope_context->inner_scope,
-					scope_tailq);
-		if (last_scope == NULL
-		 || last_scope->type == T_ELSE) {
-
-			stop("'else if' without leading 'if'", EX_DATAERR);
-			/* NOTREACHED */
-		}
-		add_conditional($3);
-		new_scope = scope_alloc();
-		new_scope->type = SCOPE_ELSE_IF;
-		new_scope->begin_addr = instruction_ptr;
-		new_scope->func_num = $3->info.condinfo->func_num;
-	}
-|	T_ELSE '{'
-	{
-		scope_t *new_scope;
-		scope_t *scope_context;
-		scope_t *last_scope;
-
-		/*
-		 * Ensure that the previous scope is either an
-		 * if or and else if.
-		 */
-		scope_context = SLIST_FIRST(&scope_stack);
-		last_scope = TAILQ_LAST(&scope_context->inner_scope,
-					scope_tailq);
-		if (last_scope == NULL
-		 || last_scope->type == SCOPE_ELSE) {
-
-			stop("'else' without leading 'if'", EX_DATAERR);
-			/* NOTREACHED */
-		}
-		new_scope = scope_alloc();
-		new_scope->type = SCOPE_ELSE;
-		new_scope->begin_addr = instruction_ptr;
-	}
-;
-
-conditional:
-	'}'
-	{
-		scope_t *scope_context;
-
-		scope_context = SLIST_FIRST(&scope_stack);
-		if (scope_context->type == SCOPE_ROOT) {
-			stop("Unexpected '}' encountered", EX_DATAERR);
-			/* NOTREACHED */
-		}
-
-		scope_context->end_addr = instruction_ptr;
-
-		/* Pop the scope */
-		SLIST_REMOVE_HEAD(&scope_stack, scope_stack_links);
-
-		process_scope(scope_context);
-
-		if (SLIST_FIRST(&scope_stack) == NULL) {
-			stop("Unexpected '}' encountered", EX_DATAERR);
-			/* NOTREACHED */
-		}
-	}
-;
-
-f1_opcode:
-	T_AND { $$ = AIC_OP_AND; }
-|	T_XOR { $$ = AIC_OP_XOR; }
-|	T_ADD { $$ = AIC_OP_ADD; }
-|	T_ADC { $$ = AIC_OP_ADC; }
-;
-
-code:
-	f1_opcode destination ',' immediate_or_a opt_source ret ';'
-	{
-		format_1_instr($1, &$2, &$4, &$5, $6);
-	}
-;
-
-code:
-	T_OR reg_symbol ',' immediate_or_a opt_source ret ';'
-	{
-		format_1_instr(AIC_OP_OR, &$2, &$4, &$5, $6);
-	}
-;
-
-code:
-	T_INC destination opt_source ret ';'
-	{
-		expression_t immed;
-
-		make_expression(&immed, 1);
-		format_1_instr(AIC_OP_ADD, &$2, &immed, &$3, $4);
-	}
-;
-
-code:
-	T_DEC destination opt_source ret ';'
-	{
-		expression_t immed;
-
-		make_expression(&immed, -1);
-		format_1_instr(AIC_OP_ADD, &$2, &immed, &$3, $4);
-	}
-;
-
-code:
-	T_CLC ret ';'
-	{
-		expression_t immed;
-
-		make_expression(&immed, -1);
-		format_1_instr(AIC_OP_ADD, &none, &immed, &allzeros, $2);
-	}
-|	T_CLC T_MVI destination ',' immediate_or_a ret ';'
-	{
-		format_1_instr(AIC_OP_ADD, &$3, &$5, &allzeros, $6);
-	}
-;
-
-code:
-	T_STC ret ';'
-	{
-		expression_t immed;
-
-		make_expression(&immed, 1);
-		format_1_instr(AIC_OP_ADD, &none, &immed, &allones, $2);
-	}
-|	T_STC destination ret ';'
-	{
-		expression_t immed;
-
-		make_expression(&immed, 1);
-		format_1_instr(AIC_OP_ADD, &$2, &immed, &allones, $3);
-	}
-;
-
-code:
-	T_BMOV destination ',' source ',' immediate ret ';'
-	{
-		format_1_instr(AIC_OP_BMOV, &$2, &$6, &$4, $7);
-	}
-;
-
-code:
-	T_MOV destination ',' source ret ';'
-	{
-		expression_t immed;
-
-		make_expression(&immed, 1);
-		format_1_instr(AIC_OP_BMOV, &$2, &immed, &$4, $5);
-	}
-;
-
-code:
-	T_MVI destination ',' immediate ret ';'
-	{
-		if ($4.value == 0
-		 && is_download_const(&$4) == 0) {
-			expression_t immed;
-
-			/*
-			 * Allow move immediates of 0 so that macros,
-			 * that can't know the immediate's value and
-			 * otherwise compensate, still work.
-			 */
-			make_expression(&immed, 1);
-			format_1_instr(AIC_OP_BMOV, &$2, &immed, &allzeros, $5);
-		} else {
-			format_1_instr(AIC_OP_OR, &$2, &$4, &allzeros, $5);
-		}
-	}
-;
-
-code:
-	T_NOT destination opt_source ret ';'
-	{
-		expression_t immed;
-
-		make_expression(&immed, 0xff);
-		format_1_instr(AIC_OP_XOR, &$2, &immed, &$3, $4);
-	}
-;
-
-code:
-	T_CLR destination ret ';'
-	{
-		expression_t immed;
-
-		make_expression(&immed, 0xff);
-		format_1_instr(AIC_OP_AND, &$2, &immed, &allzeros, $3);
-	}
-;
-
-code:
-	T_NOP ret ';'
-	{
-		expression_t immed;
-
-		make_expression(&immed, 0xff);
-		format_1_instr(AIC_OP_AND, &none, &immed, &allzeros, $2);
-	}
-;
-
-code:
-	T_RET ';'
-	{
-		expression_t immed;
-
-		make_expression(&immed, 0xff);
-		format_1_instr(AIC_OP_AND, &none, &immed, &allzeros, TRUE);
-	}
-;
-
-	/*
-	 * This grammer differs from the one in the aic7xxx
-	 * reference manual since the grammer listed there is
-	 * ambiguous and causes a shift/reduce conflict.
-	 * It also seems more logical as the "immediate"
-	 * argument is listed as the second arg like the
-	 * other formats.
-	 */
-
-f2_opcode:
-	T_SHL { $$ = AIC_OP_SHL; }
-|	T_SHR { $$ = AIC_OP_SHR; }
-|	T_ROL { $$ = AIC_OP_ROL; }
-|	T_ROR { $$ = AIC_OP_ROR; }
-;
-
-code:
-	f2_opcode destination ',' expression opt_source ret ';'
-	{
-		format_2_instr($1, &$2, &$4, &$5, $6);
-	}
-;
-
-jmp_jc_jnc_call:
-	T_JMP	{ $$ = AIC_OP_JMP; }
-|	T_JC	{ $$ = AIC_OP_JC; }
-|	T_JNC	{ $$ = AIC_OP_JNC; }
-|	T_CALL	{ $$ = AIC_OP_CALL; }
-;
-
-jz_jnz:
-	T_JZ	{ $$ = AIC_OP_JZ; }
-|	T_JNZ	{ $$ = AIC_OP_JNZ; }
-;
-
-je_jne:
-	T_JE	{ $$ = AIC_OP_JE; }
-|	T_JNE	{ $$ = AIC_OP_JNE; }
-;
-
-code:
-	jmp_jc_jnc_call address ';'
-	{
-		expression_t immed;
-
-		make_expression(&immed, 0);
-		format_3_instr($1, &sindex, &immed, &$2);
-	}
-;
-
-code:
-	T_OR reg_symbol ',' immediate jmp_jc_jnc_call address ';'
-	{
-		format_3_instr($5, &$2, &$4, &$6);
-	}
-;
-
-code:
-	T_TEST source ',' immediate_or_a jz_jnz address ';'
-	{
-		format_3_instr($5, &$2, &$4, &$6);
-	}
-;
-
-code:
-	T_CMP source ',' immediate_or_a je_jne address ';'
-	{
-		format_3_instr($5, &$2, &$4, &$6);
-	}
-;
-
-code:
-	T_MOV source jmp_jc_jnc_call address ';'
-	{
-		expression_t immed;
-
-		make_expression(&immed, 0);
-		format_3_instr($3, &$2, &immed, &$4);
-	}
-;
-
-code:
-	T_MVI immediate jmp_jc_jnc_call address ';'
-	{
-		format_3_instr($3, &allzeros, &$2, &$4);
-	}
-;
-
-%%
-
-static void
-process_field(int field_type, symbol_t *sym, int value)
-{
-	/*
-	 * Add the current register to its
-	 * symbol list, if it already exists,
-	 * warn if we are setting it to a
-	 * different value, or in the bit to
-	 * the "allowed bits" of this register.
-	 */
-	if (sym->type == UNINITIALIZED) {
-		sym->type = field_type;
-		initialize_symbol(sym);
-		sym->info.finfo->value = value;
-		if (field_type != ENUM_ENTRY) {
-			if (field_type != MASK && value == 0) {
-				stop("Empty Field, or Enum", EX_DATAERR);
-				/* NOTREACHED */
-			}
-			sym->info.finfo->value = value;
-			sym->info.finfo->mask = value;
-		} else if (field_symbol != NULL) {
-			sym->info.finfo->mask = field_symbol->info.finfo->value;
-		} else {
-			sym->info.finfo->mask = 0xFF;
-		}
-	} else if (sym->type != field_type) {
-		stop("Field definition mirrors a definition of the same "
-		     " name, but a different type", EX_DATAERR);
-		/* NOTREACHED */
-	} else if (value != sym->info.finfo->value) {
-		stop("Field redefined with a conflicting value", EX_DATAERR);
-		/* NOTREACHED */
-	}
-	/* Fail if this symbol is already listed */
-	if (symlist_search(&(sym->info.finfo->symrefs),
-			   cur_symbol->name) != NULL) {
-		stop("Field defined multiple times for register", EX_DATAERR);
-		/* NOTREACHED */
-	}
-	symlist_add(&(sym->info.finfo->symrefs), cur_symbol,
-		    SYMLIST_INSERT_HEAD);
-	cur_symbol->info.rinfo->valid_bitmask |= sym->info.finfo->mask;
-	cur_symbol->info.rinfo->typecheck_masks = TRUE;
-	symlist_add(&(cur_symbol->info.rinfo->fields), sym, SYMLIST_SORT);
-}
-
-static void
-initialize_symbol(symbol_t *symbol)
-{
-	switch (symbol->type) {
-	case UNINITIALIZED:
-		stop("Call to initialize_symbol with type field unset",
-		     EX_SOFTWARE);
-		/* NOTREACHED */
-		break;
-	case REGISTER:
-	case SRAMLOC:
-	case SCBLOC:
-		symbol->info.rinfo =
-		    (struct reg_info *)malloc(sizeof(struct reg_info));
-		if (symbol->info.rinfo == NULL) {
-			stop("Can't create register info", EX_SOFTWARE);
-			/* NOTREACHED */
-		}
-		memset(symbol->info.rinfo, 0,
-		       sizeof(struct reg_info));
-		SLIST_INIT(&(symbol->info.rinfo->fields));
-		/*
-		 * Default to allowing access in all register modes
-		 * or to the mode specified by the SCB or SRAM space
-		 * we are in.
-		 */
-		if (scb_or_sram_symbol != NULL)
-			symbol->info.rinfo->modes =
-			    scb_or_sram_symbol->info.rinfo->modes;
-		else
-			symbol->info.rinfo->modes = ~0;
-		break;
-	case ALIAS:
-		symbol->info.ainfo =
-		    (struct alias_info *)malloc(sizeof(struct alias_info));
-		if (symbol->info.ainfo == NULL) {
-			stop("Can't create alias info", EX_SOFTWARE);
-			/* NOTREACHED */
-		}
-		memset(symbol->info.ainfo, 0,
-		       sizeof(struct alias_info));
-		break;
-	case MASK:
-	case FIELD:
-	case ENUM:
-	case ENUM_ENTRY:
-		symbol->info.finfo =
-		    (struct field_info *)malloc(sizeof(struct field_info));
-		if (symbol->info.finfo == NULL) {
-			stop("Can't create field info", EX_SOFTWARE);
-			/* NOTREACHED */
-		}
-		memset(symbol->info.finfo, 0, sizeof(struct field_info));
-		SLIST_INIT(&(symbol->info.finfo->symrefs));
-		break;
-	case CONST:
-	case DOWNLOAD_CONST:
-		symbol->info.cinfo =
-		    (struct const_info *)malloc(sizeof(struct const_info));
-		if (symbol->info.cinfo == NULL) {
-			stop("Can't create alias info", EX_SOFTWARE);
-			/* NOTREACHED */
-		}
-		memset(symbol->info.cinfo, 0,
-		       sizeof(struct const_info));
-		break;
-	case LABEL:
-		symbol->info.linfo =
-		    (struct label_info *)malloc(sizeof(struct label_info));
-		if (symbol->info.linfo == NULL) {
-			stop("Can't create label info", EX_SOFTWARE);
-			/* NOTREACHED */
-		}
-		memset(symbol->info.linfo, 0,
-		       sizeof(struct label_info));
-		break;
-	case CONDITIONAL:
-		symbol->info.condinfo =
-		    (struct cond_info *)malloc(sizeof(struct cond_info));
-		if (symbol->info.condinfo == NULL) {
-			stop("Can't create conditional info", EX_SOFTWARE);
-			/* NOTREACHED */
-		}
-		memset(symbol->info.condinfo, 0,
-		       sizeof(struct cond_info));
-		break;
-	case MACRO:
-		symbol->info.macroinfo = 
-		    (struct macro_info *)malloc(sizeof(struct macro_info));
-		if (symbol->info.macroinfo == NULL) {
-			stop("Can't create macro info", EX_SOFTWARE);
-			/* NOTREACHED */
-		}
-		memset(symbol->info.macroinfo, 0,
-		       sizeof(struct macro_info));
-		STAILQ_INIT(&symbol->info.macroinfo->args);
-		break;
-	default:
-		stop("Call to initialize_symbol with invalid symbol type",
-		     EX_SOFTWARE);
-		/* NOTREACHED */
-		break;
-	}
-}
-
-static void
-add_macro_arg(const char *argtext, int argnum)
-{
-	struct macro_arg *marg;
-	int i;
-	int retval;
-		
-
-	if (cur_symbol == NULL || cur_symbol->type != MACRO) {
-		stop("Invalid current symbol for adding macro arg",
-		     EX_SOFTWARE);
-		/* NOTREACHED */
-	}
-
-	marg = (struct macro_arg *)malloc(sizeof(*marg));
-	if (marg == NULL) {
-		stop("Can't create macro_arg structure", EX_SOFTWARE);
-		/* NOTREACHED */
-	}
-	marg->replacement_text = NULL;
-	retval = snprintf(regex_pattern, sizeof(regex_pattern),
-			  "[^-/A-Za-z0-9_](%s)([^-/A-Za-z0-9_]|$)",
-			  argtext);
-	if (retval >= sizeof(regex_pattern)) {
-		stop("Regex text buffer too small for arg",
-		     EX_SOFTWARE);
-		/* NOTREACHED */
-	}
-	retval = regcomp(&marg->arg_regex, regex_pattern, REG_EXTENDED);
-	if (retval != 0) {
-		stop("Regex compilation failed", EX_SOFTWARE);
-		/* NOTREACHED */
-	}
-	STAILQ_INSERT_TAIL(&cur_symbol->info.macroinfo->args, marg, links);
-}
-
-static void
-add_macro_body(const char *bodytext)
-{
-	if (cur_symbol == NULL || cur_symbol->type != MACRO) {
-		stop("Invalid current symbol for adding macro arg",
-		     EX_SOFTWARE);
-		/* NOTREACHED */
-	}
-	cur_symbol->info.macroinfo->body = strdup(bodytext);
-	if (cur_symbol->info.macroinfo->body == NULL) {
-		stop("Can't duplicate macro body text", EX_SOFTWARE);
-		/* NOTREACHED */
-	}
-}
-
-static void
-process_register(symbol_t **p_symbol)
-{
-	symbol_t *symbol = *p_symbol;
-
-	if (symbol->type == UNINITIALIZED) {
-		snprintf(errbuf, sizeof(errbuf), "Undefined register %s",
-			 symbol->name);
-		stop(errbuf, EX_DATAERR);
-		/* NOTREACHED */
-	} else if (symbol->type == ALIAS) {
-		*p_symbol = symbol->info.ainfo->parent;
-	} else if ((symbol->type != REGISTER)
-		&& (symbol->type != SCBLOC)
-		&& (symbol->type != SRAMLOC)) {
-		snprintf(errbuf, sizeof(errbuf),
-			 "Specified symbol %s is not a register",
-			 symbol->name);
-		stop(errbuf, EX_DATAERR);
-	}
-}
-
-static void
-format_1_instr(int opcode, symbol_ref_t *dest, expression_t *immed,
-	       symbol_ref_t *src, int ret)
-{
-	struct instruction *instr;
-	struct ins_format1 *f1_instr;
-
-	if (src->symbol == NULL)
-		src = dest;
-
-	/* Test register permissions */
-	test_writable_symbol(dest->symbol);
-	test_readable_symbol(src->symbol);
-
-	/* Ensure that immediate makes sense for this destination */
-	type_check(dest->symbol, immed, opcode);
-
-	/* Allocate sequencer space for the instruction and fill it out */
-	instr = seq_alloc();
-	f1_instr = &instr->format.format1;
-	f1_instr->ret = ret ? 1 : 0;
-	f1_instr->opcode = opcode;
-	f1_instr->destination = dest->symbol->info.rinfo->address
-			      + dest->offset;
-	f1_instr->source = src->symbol->info.rinfo->address
-			 + src->offset;
-	f1_instr->immediate = immed->value;
-
-	if (is_download_const(immed))
-		f1_instr->parity = 1;
-	else if (dest->symbol == mode_ptr.symbol) {
-		u_int src_value;
-		u_int dst_value;
-
-		/*
-		 * Attempt to update mode information if
-		 * we are operating on the mode register.
-		 */
-		if (src->symbol == allones.symbol)
-			src_value = 0xFF;
-		else if (src->symbol == allzeros.symbol)
-			src_value = 0;
-		else if (src->symbol == mode_ptr.symbol)
-			src_value = (dst_mode << 4) | src_mode;
-		else
-			goto cant_update;
-
-		switch (opcode) {
-		case AIC_OP_AND:
-			dst_value = src_value & immed->value;
-			break;
-		case AIC_OP_XOR:
-			dst_value = src_value ^ immed->value;
-			break;
-		case AIC_OP_ADD:
-			dst_value = (src_value + immed->value) & 0xFF;
-			break;
-		case AIC_OP_OR:
-			dst_value = src_value | immed->value;
-			break;
-		case AIC_OP_BMOV:
-			dst_value = src_value;
-			break;
-		default:
-			goto cant_update;
-		}
-		src_mode = dst_value & 0xF;
-		dst_mode = (dst_value >> 4) & 0xF;
-	}
-
-cant_update:
-	symlist_free(&immed->referenced_syms);
-	instruction_ptr++;
-}
-
-static void
-format_2_instr(int opcode, symbol_ref_t *dest, expression_t *places,
-	       symbol_ref_t *src, int ret)
-{
-	struct instruction *instr;
-	struct ins_format2 *f2_instr;
-	uint8_t shift_control;
-
-	if (src->symbol == NULL)
-		src = dest;
-
-	/* Test register permissions */
-	test_writable_symbol(dest->symbol);
-	test_readable_symbol(src->symbol);
-
-	/* Allocate sequencer space for the instruction and fill it out */
-	instr = seq_alloc();
-	f2_instr = &instr->format.format2;
-	f2_instr->ret = ret ? 1 : 0;
-	f2_instr->opcode = AIC_OP_ROL;
-	f2_instr->destination = dest->symbol->info.rinfo->address
-			      + dest->offset;
-	f2_instr->source = src->symbol->info.rinfo->address
-			 + src->offset;
-	if (places->value > 8 || places->value <= 0) {
-		stop("illegal shift value", EX_DATAERR);
-		/* NOTREACHED */
-	}
-	switch (opcode) {
-	case AIC_OP_SHL:
-		if (places->value == 8)
-			shift_control = 0xf0;
-		else
-			shift_control = (places->value << 4) | places->value;
-		break;
-	case AIC_OP_SHR:
-		if (places->value == 8) {
-			shift_control = 0xf8;
-		} else {
-			shift_control = (places->value << 4)
-				      | (8 - places->value)
-				      | 0x08;
-		}
-		break;
-	case AIC_OP_ROL:
-		shift_control = places->value & 0x7;
-		break;
-	case AIC_OP_ROR:
-		shift_control = (8 - places->value) | 0x08;
-		break;
-	default:
-		shift_control = 0; /* Quiet Compiler */
-		stop("Invalid shift operation specified", EX_SOFTWARE);
-		/* NOTREACHED */
-		break;
-	};
-	f2_instr->shift_control = shift_control;
-	symlist_free(&places->referenced_syms);
-	instruction_ptr++;
-}
-
-static void
-format_3_instr(int opcode, symbol_ref_t *src,
-	       expression_t *immed, symbol_ref_t *address)
-{
-	struct instruction *instr;
-	struct ins_format3 *f3_instr;
-	int addr;
-
-	/* Test register permissions */
-	test_readable_symbol(src->symbol);
-
-	/* Ensure that immediate makes sense for this source */
-	type_check(src->symbol, immed, opcode);
-
-	/* Allocate sequencer space for the instruction and fill it out */
-	instr = seq_alloc();
-	f3_instr = &instr->format.format3;
-	if (address->symbol == NULL) {
-		/* 'dot' referrence.  Use the current instruction pointer */
-		addr = instruction_ptr + address->offset;
-	} else if (address->symbol->type == UNINITIALIZED) {
-		/* forward reference */
-		addr = address->offset;
-		instr->patch_label = address->symbol;
-	} else
-		addr = address->symbol->info.linfo->address + address->offset;
-	f3_instr->opcode = opcode;
-	f3_instr->address = addr;
-	f3_instr->source = src->symbol->info.rinfo->address
-			 + src->offset;
-	f3_instr->immediate = immed->value;
-
-	if (is_download_const(immed))
-		f3_instr->parity = 1;
-
-	symlist_free(&immed->referenced_syms);
-	instruction_ptr++;
-}
-
-static void
-test_readable_symbol(symbol_t *symbol)
-{
-	
-	if ((symbol->info.rinfo->modes & (0x1 << src_mode)) == 0) {
-		snprintf(errbuf, sizeof(errbuf),
-			"Register %s unavailable in source reg mode %d",
-			symbol->name, src_mode);
-		stop(errbuf, EX_DATAERR);
-	}
-
-	if (symbol->info.rinfo->mode == WO) {
-		stop("Write Only register specified as source",
-		     EX_DATAERR);
-		/* NOTREACHED */
-	}
-}
-
-static void
-test_writable_symbol(symbol_t *symbol)
-{
-	
-	if ((symbol->info.rinfo->modes & (0x1 << dst_mode)) == 0) {
-		snprintf(errbuf, sizeof(errbuf),
-			"Register %s unavailable in destination reg mode %d",
-			symbol->name, dst_mode);
-		stop(errbuf, EX_DATAERR);
-	}
-
-	if (symbol->info.rinfo->mode == RO) {
-		stop("Read Only register specified as destination",
-		     EX_DATAERR);
-		/* NOTREACHED */
-	}
-}
-
-static void
-type_check(symbol_t *symbol, expression_t *expression, int opcode)
-{
-	symbol_node_t *node;
-	int and_op;
-
-	and_op = FALSE;
-	if (opcode == AIC_OP_AND || opcode == AIC_OP_JNZ || AIC_OP_JZ)
-		and_op = TRUE;
-
-	/*
-	 * Make sure that we aren't attempting to write something
-	 * that hasn't been defined.  If this is an and operation,
-	 * this is a mask, so "undefined" bits are okay.
-	 */
-	if (and_op == FALSE
-	 && (expression->value & ~symbol->info.rinfo->valid_bitmask) != 0) {
-		snprintf(errbuf, sizeof(errbuf),
-			 "Invalid bit(s) 0x%x in immediate written to %s",
-			 expression->value & ~symbol->info.rinfo->valid_bitmask,
-			 symbol->name);
-		stop(errbuf, EX_DATAERR);
-		/* NOTREACHED */
-	}
-
-	/*
-	 * Now make sure that all of the symbols referenced by the
-	 * expression are defined for this register.
-	 */
-	if (symbol->info.rinfo->typecheck_masks != FALSE) {
-		for(node = expression->referenced_syms.slh_first;
-		    node != NULL;
-		    node = node->links.sle_next) {
-			if ((node->symbol->type == MASK
-			  || node->symbol->type == FIELD
-			  || node->symbol->type == ENUM
-			  || node->symbol->type == ENUM_ENTRY)
-			 && symlist_search(&node->symbol->info.finfo->symrefs,
-					   symbol->name) == NULL) {
-				snprintf(errbuf, sizeof(errbuf),
-					 "Invalid field or mask %s "
-					 "for register %s",
-					 node->symbol->name, symbol->name);
-				stop(errbuf, EX_DATAERR);
-				/* NOTREACHED */
-			}
-		}
-	}
-}
-
-static void
-make_expression(expression_t *immed, int value)
-{
-	SLIST_INIT(&immed->referenced_syms);
-	immed->value = value & 0xff;
-}
-
-static void
-add_conditional(symbol_t *symbol)
-{
-	static int numfuncs;
-
-	if (numfuncs == 0) {
-		/* add a special conditional, "0" */
-		symbol_t *false_func;
-
-		false_func = symtable_get("0");
-		if (false_func->type != UNINITIALIZED) {
-			stop("Conditional expression '0' "
-			     "conflicts with a symbol", EX_DATAERR);
-			/* NOTREACHED */
-		}
-		false_func->type = CONDITIONAL;
-		initialize_symbol(false_func);
-		false_func->info.condinfo->func_num = numfuncs++;
-		symlist_add(&patch_functions, false_func, SYMLIST_INSERT_HEAD);
-	}
-
-	/* This condition has occurred before */
-	if (symbol->type == CONDITIONAL)
-		return;
-
-	if (symbol->type != UNINITIALIZED) {
-		stop("Conditional expression conflicts with a symbol",
-		     EX_DATAERR);
-		/* NOTREACHED */
-	}
-
-	symbol->type = CONDITIONAL;
-	initialize_symbol(symbol);
-	symbol->info.condinfo->func_num = numfuncs++;
-	symlist_add(&patch_functions, symbol, SYMLIST_INSERT_HEAD);
-}
-
-static void
-add_version(const char *verstring)
-{
-	const char prefix[] = " * ";
-	int newlen;
-	int oldlen;
-
-	newlen = strlen(verstring) + strlen(prefix);
-	oldlen = 0;
-	if (versions != NULL)
-		oldlen = strlen(versions);
-	versions = realloc(versions, newlen + oldlen + 2);
-	if (versions == NULL)
-		stop("Can't allocate version string", EX_SOFTWARE);
-	strcpy(&versions[oldlen], prefix);
-	strcpy(&versions[oldlen + strlen(prefix)], verstring);
-	versions[newlen + oldlen] = '\n';
-	versions[newlen + oldlen + 1] = '\0';
-}
-
-void
-yyerror(const char *string)
-{
-	stop(string, EX_DATAERR);
-}
-
-static int
-is_download_const(expression_t *immed)
-{
-	if ((immed->referenced_syms.slh_first != NULL)
-	 && (immed->referenced_syms.slh_first->symbol->type == DOWNLOAD_CONST))
-		return (TRUE);
-
-	return (FALSE);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aicasm/aicasm_insformat.h linux-2.4.22-pre2/drivers/scsi/aic79xx/aicasm/aicasm_insformat.h
--- linux-2.4.21/drivers/scsi/aic79xx/aicasm/aicasm_insformat.h	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aicasm/aicasm_insformat.h	2003-06-26 21:43:20.000000000 +0000
@@ -1,131 +0,0 @@
-/*
- * Instruction formats for the sequencer program downloaded to
- * Aic7xxx SCSI host adapters
- *
- * Copyright (c) 1997, 1998, 2000 Justin T. Gibbs.
- * 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: //depot/aic7xxx/aic7xxx/aicasm/aicasm_insformat.h#11 $
- *
- * $FreeBSD$
- */
-
-struct ins_format1 {
-#if BYTE_ORDER == LITTLE_ENDIAN
-	uint32_t	immediate	: 8,
-			source		: 9,
-			destination	: 9,
-			ret		: 1,
-			opcode		: 4,
-			parity		: 1;
-#else
-	uint32_t	parity		: 1,
-			opcode		: 4,
-			ret		: 1,
-			destination	: 9,
-			source		: 9,
-			immediate	: 8;
-#endif
-};
-
-struct ins_format2 {
-#if BYTE_ORDER == LITTLE_ENDIAN
-	uint32_t	shift_control	: 8,
-			source		: 9,
-			destination	: 9,
-			ret		: 1,
-			opcode		: 4,
-			parity		: 1;
-#else
-	uint32_t	parity		: 1,
-			opcode		: 4,
-			ret		: 1,
-			destination	: 9,
-			source		: 9,
-			shift_control	: 8;
-#endif
-};
-
-struct ins_format3 {
-#if BYTE_ORDER == LITTLE_ENDIAN
-	uint32_t	immediate	: 8,
-			source		: 9,
-			address		: 10,
-			opcode		: 4,
-			parity		: 1;
-#else
-	uint32_t	parity		: 1,
-			opcode		: 4,
-			address		: 10,
-			source		: 9,
-			immediate	: 8;
-#endif
-};
-
-union ins_formats {
-		struct ins_format1 format1;
-		struct ins_format2 format2;
-		struct ins_format3 format3;
-		uint8_t		   bytes[4];
-		uint32_t	   integer;
-};
-struct instruction {
-	union	ins_formats format;
-	u_int	srcline;
-	struct symbol *patch_label;
-	STAILQ_ENTRY(instruction) links;
-};
-
-#define	AIC_OP_OR	0x0
-#define	AIC_OP_AND	0x1
-#define AIC_OP_XOR	0x2
-#define	AIC_OP_ADD	0x3
-#define	AIC_OP_ADC	0x4
-#define	AIC_OP_ROL	0x5
-#define	AIC_OP_BMOV	0x6
-
-#define	AIC_OP_JMP	0x8
-#define AIC_OP_JC	0x9
-#define AIC_OP_JNC	0xa
-#define AIC_OP_CALL	0xb
-#define	AIC_OP_JNE	0xc
-#define	AIC_OP_JNZ	0xd
-#define	AIC_OP_JE	0xe
-#define	AIC_OP_JZ	0xf
-
-/* Pseudo Ops */
-#define	AIC_OP_SHL	0x10
-#define	AIC_OP_SHR	0x20
-#define	AIC_OP_ROR	0x30
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aicasm/aicasm_macro_gram.y linux-2.4.22-pre2/drivers/scsi/aic79xx/aicasm/aicasm_macro_gram.y
--- linux-2.4.21/drivers/scsi/aic79xx/aicasm/aicasm_macro_gram.y	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aicasm/aicasm_macro_gram.y	2003-06-26 21:43:31.000000000 +0000
@@ -1,164 +0,0 @@
-%{
-/*
- * Sub-parser for macro invocation in the Aic7xxx SCSI
- * Host adapter sequencer assembler.
- *
- * Copyright (c) 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: //depot/aic7xxx/aic7xxx/aicasm/aicasm_macro_gram.y#5 $
- *
- * $FreeBSD$
- */
-
-#include <sys/types.h>
-
-#include <inttypes.h>
-#include <regex.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sysexits.h>
-
-#ifdef __linux__
-#include "../queue.h"
-#else
-#include <sys/queue.h>
-#endif
-
-#include "aicasm.h"
-#include "aicasm_symbol.h"
-#include "aicasm_insformat.h"
-
-static symbol_t *macro_symbol;
-
-static void add_macro_arg(const char *argtext, int position);
-
-%}
-
-%union {
-	int		value;
-	char		*str;
-	symbol_t	*sym;
-}
-
-
-%token <str> T_ARG
-
-%token <sym> T_SYMBOL
-
-%type <value> macro_arglist
-
-%%
-
-macrocall:
-	T_SYMBOL '('
-	{
-		macro_symbol = $1;
-	}
-	macro_arglist ')'
-	{
-		if (macro_symbol->info.macroinfo->narg != $4) {
-			printf("Narg == %d", macro_symbol->info.macroinfo->narg);
-			stop("Too few arguments for macro invocation",
-			     EX_DATAERR);
-			/* NOTREACHED */
-		}
-		macro_symbol = NULL;
-		YYACCEPT;
-	}
-;
-
-macro_arglist:
-	{
-		/* Macros can take 0 arguments */
-		$$ = 0;
-	}
-|	T_ARG
-	{
-		$$ = 1;
-		add_macro_arg($1, 1);
-	}
-|	macro_arglist ',' T_ARG
-	{
-		if ($1 == 0) {
-			stop("Comma without preceeding argument in arg list",
-			     EX_DATAERR);
-			/* NOTREACHED */
-		}
-		$$ = $1 + 1;
-		add_macro_arg($3, $$);
-	}
-;
-
-%%
-
-static void
-add_macro_arg(const char *argtext, int argnum)
-{
-	struct macro_arg *marg;
-	int i;
-
-	if (macro_symbol == NULL || macro_symbol->type != MACRO) {
-		stop("Invalid current symbol for adding macro arg",
-		     EX_SOFTWARE);
-		/* NOTREACHED */
-	}
-	/*
-	 * Macro Invocation.  Find the appropriate argument and fill
-	 * in the replace ment text for this call.
-	 */
-	i = 0;
-	STAILQ_FOREACH(marg, &macro_symbol->info.macroinfo->args, links) {
-		i++;
-		if (i == argnum)
-			break;
-	}
-	if (marg == NULL) {
-		stop("Too many arguments for macro invocation", EX_DATAERR);
-		/* NOTREACHED */
-	}
-	marg->replacement_text = strdup(argtext);
-	if (marg->replacement_text == NULL) {
-		stop("Unable to replicate replacement text", EX_SOFTWARE);
-		/* NOTREACHED */
-	}
-}
-
-void
-mmerror(const char *string)
-{
-	stop(string, EX_DATAERR);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aicasm/aicasm_macro_scan.l linux-2.4.22-pre2/drivers/scsi/aic79xx/aicasm/aicasm_macro_scan.l
--- linux-2.4.21/drivers/scsi/aic79xx/aicasm/aicasm_macro_scan.l	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aicasm/aicasm_macro_scan.l	2003-06-26 21:43:31.000000000 +0000
@@ -1,155 +0,0 @@
-%{
-/*
- * Sub-Lexical Analyzer for macro invokation in 
- * the Aic7xxx SCSI Host adapter sequencer assembler.
- *
- * Copyright (c) 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: //depot/aic7xxx/aic7xxx/aicasm/aicasm_macro_scan.l#7 $
- *
- * $FreeBSD$
- */
-
-#include <sys/types.h>
-
-#include <inttypes.h>
-#include <limits.h>
-#include <regex.h>
-#include <stdio.h>
-#include <string.h>
-#include <sysexits.h>
-#ifdef __linux__
-#include "../queue.h"
-#else
-#include <sys/queue.h>
-#endif
-
-#include "aicasm.h"
-#include "aicasm_symbol.h"
-#include "aicasm_macro_gram.h"
-
-#define MAX_STR_CONST 4096
-static char string_buf[MAX_STR_CONST];
-static char *string_buf_ptr;
-static int  parren_count;
-static char buf[255];
-%}
-
-WORD		[A-Za-z_][-A-Za-z_0-9]*
-SPACE		[ \t]+
-MCARG		[^(), \t]+
-
-%x ARGLIST
-
-%%
-\n			{
-				++yylineno;
-			}
-<ARGLIST>{SPACE}	;
-<ARGLIST>\(		{
-				parren_count++;
-				if (parren_count == 1) {
-					string_buf_ptr = string_buf;
-					return ('(');
-				}
-				*string_buf_ptr++ = '(';
-			}
-<ARGLIST>\)		{
-				if (parren_count == 1) {
-					if (string_buf_ptr != string_buf) {
-						/*
-						 * Return an argument and
-						 * rescan this parren so we
-						 * can return it as well.
-						 */
-						*string_buf_ptr = '\0';
-						mmlval.str = string_buf;
-						string_buf_ptr = string_buf;
-						unput(')');
-						return T_ARG;
-					}
-					BEGIN INITIAL;
-					return (')');
-				}
-				parren_count--;
-				*string_buf_ptr++ = ')';
-			}
-<ARGLIST>{MCARG}	{
-				char *yptr;
-
-				yptr = mmtext;
-				while (*yptr)
-					*string_buf_ptr++ = *yptr++;
-			}
-<ARGLIST>\,		{
-				if (string_buf_ptr != string_buf) {
-					/*
-					 * Return an argument and
-					 * rescan this comma so we
-					 * can return it as well.
-					 */
-					*string_buf_ptr = '\0';
-					mmlval.str = string_buf;
-					string_buf_ptr = string_buf;
-					unput(',');
-					return T_ARG;
-				}
-				return ',';
-			}
-{WORD}[(]		{
-				/* May be a symbol or a macro invocation. */
-				mmlval.sym = symtable_get(mmtext);
-				if (mmlval.sym->type != MACRO) {
-					stop("Expecting Macro Name",
-					     EX_DATAERR);
-				}
-				unput('(');
-				parren_count = 0;
-				BEGIN ARGLIST;
-				return T_SYMBOL;
-			}
-.			{ 
-				snprintf(buf, sizeof(buf), "Invalid character "
-					 "'%c'", mmtext[0]);
-				stop(buf, EX_DATAERR);
-			}
-%%
-
-int
-mmwrap()
-{
-	stop("EOF encountered in macro call", EX_DATAERR);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aicasm/aicasm_scan.l linux-2.4.22-pre2/drivers/scsi/aic79xx/aicasm/aicasm_scan.l
--- linux-2.4.21/drivers/scsi/aic79xx/aicasm/aicasm_scan.l	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aicasm/aicasm_scan.l	2003-06-26 21:43:30.000000000 +0000
@@ -1,597 +0,0 @@
-%{
-/*
- * Lexical Analyzer for the Aic7xxx SCSI Host adapter sequencer assembler.
- *
- * Copyright (c) 1997, 1998, 2000 Justin T. Gibbs.
- * Copyright (c) 2001, 2002 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: //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#18 $
- *
- * $FreeBSD$
- */
-
-#include <sys/types.h>
-
-#include <inttypes.h>
-#include <limits.h>
-#include <regex.h>
-#include <stdio.h>
-#include <string.h>
-#include <sysexits.h>
-#ifdef __linux__
-#include "../queue.h"
-#else
-#include <sys/queue.h>
-#endif
-
-#include "aicasm.h"
-#include "aicasm_symbol.h"
-#include "aicasm_gram.h"
-
-/* This is used for macro body capture too, so err on the large size. */
-#define MAX_STR_CONST 4096
-static char string_buf[MAX_STR_CONST];
-static char *string_buf_ptr;
-static int  parren_count;
-static int  quote_count;
-static char buf[255];
-%}
-
-PATH		([/]*[-A-Za-z0-9_.])+
-WORD		[A-Za-z_][-A-Za-z_0-9]*
-SPACE		[ \t]+
-MCARG		[^(), \t]+
-MBODY		((\\[^\n])*[^\n\\]*)+
-
-%x COMMENT
-%x CEXPR
-%x INCLUDE
-%x STRING
-%x MACRODEF
-%x MACROARGLIST
-%x MACROCALLARGS
-%x MACROBODY
-
-%%
-\n			{ ++yylineno; }
-"/*"			{ BEGIN COMMENT;  /* Enter comment eating state */ }
-<COMMENT>"/*"		{ fprintf(stderr, "Warning! Comment within comment."); }
-<COMMENT>\n		{ ++yylineno; }
-<COMMENT>[^*/\n]*	;
-<COMMENT>"*"+[^*/\n]*	;
-<COMMENT>"/"+[^*/\n]*	;
-<COMMENT>"*"+"/"	{ BEGIN INITIAL; }
-if[ \t]*\(		{
-				string_buf_ptr = string_buf;
-				parren_count = 1;
-				BEGIN CEXPR;
-				return T_IF;
-			}
-<CEXPR>\(		{	*string_buf_ptr++ = '('; parren_count++; }
-<CEXPR>\)		{
-				parren_count--;
-				if (parren_count == 0) {
-					/* All done */
-					BEGIN INITIAL;
-					*string_buf_ptr = '\0';
-					yylval.sym = symtable_get(string_buf);
-					return T_CEXPR;
-				} else {
-					*string_buf_ptr++ = ')';
-				}
-			}
-<CEXPR>\n		{ ++yylineno; }
-<CEXPR>[^()\n]+	{
-				char *yptr;
-
-				yptr = yytext;
-				while (*yptr != '\0') {
-					/* Remove duplicate spaces */
-					if (*yptr == '\t')
-						*yptr = ' ';
-					if (*yptr == ' '
-					 && string_buf_ptr != string_buf
-					 && string_buf_ptr[-1] == ' ')
-						yptr++;
-					else 
-						*string_buf_ptr++ = *yptr++;
-				}
-			}
-
-VERSION			{ return T_VERSION; }
-PREFIX			{ return T_PREFIX; }
-PATCH_ARG_LIST		{ return T_PATCH_ARG_LIST; }
-\"			{
-				string_buf_ptr = string_buf;
-				BEGIN STRING;
-			}
-<STRING>[^"]+		{
-				char *yptr;
-
-				yptr = yytext;
-				while (*yptr)
-					*string_buf_ptr++ = *yptr++;
-			}
-<STRING>\"		{
-				/* All done */
-				BEGIN INITIAL;
-				*string_buf_ptr = '\0';
-				yylval.str = string_buf;
-				return T_STRING;
-			}
-{SPACE}			 ;
-
-	/* Register/SCB/SRAM definition keywords */
-export			{ return T_EXPORT; }
-register		{ return T_REGISTER; }
-const			{ yylval.value = FALSE; return T_CONST; }
-download		{ return T_DOWNLOAD; }
-address			{ return T_ADDRESS; }
-access_mode		{ return T_ACCESS_MODE; }
-modes			{ return T_MODES; }
-RW|RO|WO		{
-				 if (strcmp(yytext, "RW") == 0)
-					yylval.value = RW;
-				 else if (strcmp(yytext, "RO") == 0)
-					yylval.value = RO;
-				 else
-					yylval.value = WO;
-				 return T_MODE;
-			}
-BEGIN_CRITICAL		{ return T_BEGIN_CS; }
-END_CRITICAL		{ return T_END_CS; }
-SET_SRC_MODE		{ return T_SET_SRC_MODE; }
-SET_DST_MODE		{ return T_SET_DST_MODE; }
-field			{ return T_FIELD; }
-enum			{ return T_ENUM; }
-mask			{ return T_MASK; }
-alias			{ return T_ALIAS; }
-size			{ return T_SIZE; }
-scb			{ return T_SCB; }
-scratch_ram		{ return T_SRAM; }
-accumulator		{ return T_ACCUM; }
-mode_pointer		{ return T_MODE_PTR; }
-allones			{ return T_ALLONES; }
-allzeros		{ return T_ALLZEROS; }
-none			{ return T_NONE; }
-sindex			{ return T_SINDEX; }
-A			{ return T_A; }
-
-	/* Opcodes */
-shl			{ return T_SHL; }
-shr			{ return T_SHR; }
-ror			{ return T_ROR; }
-rol			{ return T_ROL; }
-mvi			{ return T_MVI; }
-mov			{ return T_MOV; }
-clr			{ return T_CLR; }
-jmp			{ return T_JMP; }
-jc			{ return T_JC;	}
-jnc			{ return T_JNC;	}
-je			{ return T_JE;	}
-jne			{ return T_JNE;	}
-jz			{ return T_JZ;	}
-jnz			{ return T_JNZ;	}
-call			{ return T_CALL; }
-add			{ return T_ADD; }
-adc			{ return T_ADC; }
-bmov			{ return T_BMOV; }
-inc			{ return T_INC; }
-dec			{ return T_DEC; }
-stc			{ return T_STC;	}
-clc			{ return T_CLC; }
-cmp			{ return T_CMP;	}
-not			{ return T_NOT;	}
-xor			{ return T_XOR;	}
-test			{ return T_TEST;}
-and			{ return T_AND;	}
-or			{ return T_OR;	}
-ret			{ return T_RET; }
-nop			{ return T_NOP; }
-else			{ return T_ELSE; }
-
-	/* Allowed Symbols */
-\<\<			{ return T_EXPR_LSHIFT; }
-\>\>			{ return T_EXPR_RSHIFT; }
-[-+,:()~|&."{};<>[\]/*!=] { return yytext[0]; }
-
-	/* Number processing */
-0[0-7]*			{
-				yylval.value = strtol(yytext, NULL, 8);
-				return T_NUMBER;
-			}
-
-0[xX][0-9a-fA-F]+	{
-				yylval.value = strtoul(yytext + 2, NULL, 16);
-				return T_NUMBER;
-			}
-
-[1-9][0-9]*		{
-				yylval.value = strtol(yytext, NULL, 10);
-				return T_NUMBER;
-			}
-	/* Include Files */
-#include{SPACE}		{
-				BEGIN INCLUDE;
-				quote_count = 0;
-				return T_INCLUDE;
-			}
-<INCLUDE>[<]		{ return yytext[0]; }
-<INCLUDE>[>]		{ BEGIN INITIAL; return yytext[0]; }
-<INCLUDE>[\"]		{
-				if (quote_count != 0)
-					BEGIN INITIAL;
-				quote_count++;
-				return yytext[0];
-			}
-<INCLUDE>{PATH}		{
-				char *yptr;
-
-				yptr = yytext;
-				string_buf_ptr = string_buf;
-				while (*yptr)
-					*string_buf_ptr++ = *yptr++;
-				yylval.str = string_buf;
-				*string_buf_ptr = '\0';
-				return T_PATH;
-			}
-<INCLUDE>.		{ stop("Invalid include line", EX_DATAERR); }
-#define{SPACE}		{
-				BEGIN MACRODEF;
-				return T_DEFINE;
-			}
-<MACRODEF>{WORD}{SPACE}	{ 
-				char *yptr;
-
-				/* Strip space and return as a normal symbol */
-				yptr = yytext;
-				while (*yptr != ' ' && *yptr != '\t')
-					yptr++;
-				*yptr = '\0';
-				yylval.sym = symtable_get(yytext);
-				string_buf_ptr = string_buf;
-				BEGIN MACROBODY;
-				return T_SYMBOL;
-			}
-<MACRODEF>{WORD}\(	{
-				/*
-				 * We store the symbol with its opening
-				 * parren so we can differentiate macros
-				 * that take args from macros with the
-				 * same name that do not take args as
-				 * is allowed in C.
-				 */
-				BEGIN MACROARGLIST;
-				yylval.sym = symtable_get(yytext);
-				unput('(');
-				return T_SYMBOL;
-			}
-<MACROARGLIST>{WORD}	{
-				yylval.str = yytext;
-				return T_ARG;
-			}
-<MACROARGLIST>{SPACE}   ;
-<MACROARGLIST>[(,]	{
-				return yytext[0];
-			}
-<MACROARGLIST>[)]	{
-				string_buf_ptr = string_buf;
-				BEGIN MACROBODY;
-				return ')';
-			}
-<MACROARGLIST>.		{
-				snprintf(buf, sizeof(buf), "Invalid character "
-					 "'%c' in macro argument list",
-					 yytext[0]);
-				stop(buf, EX_DATAERR);
-			}
-<MACROCALLARGS>{SPACE}  ;
-<MACROCALLARGS>\(	{
-				parren_count++;
-				if (parren_count == 1)
-					return ('(');
-				*string_buf_ptr++ = '(';
-			}
-<MACROCALLARGS>\)	{
-				parren_count--;
-				if (parren_count == 0) {
-					BEGIN INITIAL;
-					return (')');
-				}
-				*string_buf_ptr++ = ')';
-			}
-<MACROCALLARGS>{MCARG}	{
-				char *yptr;
-
-				yptr = yytext;
-				while (*yptr)
-					*string_buf_ptr++ = *yptr++;
-			}
-<MACROCALLARGS>\,	{
-				if (string_buf_ptr != string_buf) {
-					/*
-					 * Return an argument and
-					 * rescan this comma so we
-					 * can return it as well.
-					 */
-					*string_buf_ptr = '\0';
-					yylval.str = string_buf;
-					string_buf_ptr = string_buf;
-					unput(',');
-					return T_ARG;
-				}
-				return ',';
-			}
-<MACROBODY>\\\n		{
-				/* Eat escaped newlines. */
-				++yylineno;
-			}
-<MACROBODY>\n		{
-				/* Macros end on the first unescaped newline. */
-				BEGIN INITIAL;
-				*string_buf_ptr = '\0';
-				yylval.str = string_buf;
-				++yylineno;
-				return T_MACROBODY;
-			}
-<MACROBODY>{MBODY}	{
-				char *yptr;
-
-				yptr = yytext;
-				while (*yptr)
-					*string_buf_ptr++ = *yptr++;
-			}
-{WORD}\(		{
-				char *yptr;
-				char *ycopy;
-
-				/* May be a symbol or a macro invocation. */
-				yylval.sym = symtable_get(yytext);
-				if (yylval.sym->type == MACRO) {
-					YY_BUFFER_STATE old_state;
-					YY_BUFFER_STATE temp_state;
-
-					ycopy = strdup(yytext);
-					yptr = ycopy + yyleng;
-					while (yptr > ycopy)
-						unput(*--yptr);
-					old_state = YY_CURRENT_BUFFER;
-					temp_state =
-					    yy_create_buffer(stdin,
-							     YY_BUF_SIZE);
-					yy_switch_to_buffer(temp_state);
-					mm_switch_to_buffer(old_state);
-					mmparse();
-					mm_switch_to_buffer(temp_state);
-					yy_switch_to_buffer(old_state);
-					mm_delete_buffer(temp_state);
-					expand_macro(yylval.sym);
-				} else {
-					if (yylval.sym->type == UNINITIALIZED) {
-						/* Try without the '(' */
-						symbol_delete(yylval.sym);
-						yytext[yyleng-1] = '\0';
-						yylval.sym =
-						    symtable_get(yytext);
-					}
-					unput('(');
-					return T_SYMBOL;
-				}
-			}
-{WORD}			{
-				yylval.sym = symtable_get(yytext);
-				if (yylval.sym->type == MACRO) {
-					expand_macro(yylval.sym);
-				} else {
-					return T_SYMBOL;
-				}
-			}
-.			{ 
-				snprintf(buf, sizeof(buf), "Invalid character "
-					 "'%c'", yytext[0]);
-				stop(buf, EX_DATAERR);
-			}
-%%
-
-typedef struct include {
-        YY_BUFFER_STATE  buffer;
-        int              lineno;
-        char            *filename;
-	SLIST_ENTRY(include) links;
-}include_t;
-
-SLIST_HEAD(, include) include_stack;
-
-void
-include_file(char *file_name, include_type type)
-{
-	FILE *newfile;
-	include_t *include;
-
-	newfile = NULL;
-	/* Try the current directory first */
-	if (includes_search_curdir != 0 || type == SOURCE_FILE)
-		newfile = fopen(file_name, "r");
-
-	if (newfile == NULL && type != SOURCE_FILE) {
-                path_entry_t include_dir;
-                for (include_dir = search_path.slh_first;
-                     include_dir != NULL;                
-                     include_dir = include_dir->links.sle_next) {
-			char fullname[PATH_MAX];
-
-			if ((include_dir->quoted_includes_only == TRUE)
-			 && (type != QUOTED_INCLUDE))
-				continue;
-
-			snprintf(fullname, sizeof(fullname),
-				 "%s/%s", include_dir->directory, file_name);
-
-			if ((newfile = fopen(fullname, "r")) != NULL)
-				break;
-                }
-        }
-
-	if (newfile == NULL) {
-		perror(file_name);
-		stop("Unable to open input file", EX_SOFTWARE);
-		/* NOTREACHED */
-	}
-
-	if (type != SOURCE_FILE) {
-		include = (include_t *)malloc(sizeof(include_t));
-		if (include == NULL) {
-			stop("Unable to allocate include stack entry",
-			     EX_SOFTWARE);
-			/* NOTREACHED */
-		}
-		include->buffer = YY_CURRENT_BUFFER;
-		include->lineno = yylineno;
-		include->filename = yyfilename;
-		SLIST_INSERT_HEAD(&include_stack, include, links);
-	}
-	yy_switch_to_buffer(yy_create_buffer(newfile, YY_BUF_SIZE));
-	yylineno = 1;
-	yyfilename = strdup(file_name);
-}
-
-static void next_substitution(struct symbol *mac_symbol, const char *body_pos,
-			      const char **next_match,
-			      struct macro_arg **match_marg, regmatch_t *match);
-
-void
-expand_macro(struct symbol *macro_symbol)
-{
-	struct macro_arg *marg;
-	struct macro_arg *match_marg;
-	const char *body_head;
-	const char *body_pos;
-	const char *next_match;
-
-	/*
-	 * Due to the nature of unput, we must work
-	 * backwards through the macro body performing
-	 * any expansions.
-	 */
-	body_head = macro_symbol->info.macroinfo->body;
-	body_pos = body_head + strlen(body_head);
-	while (body_pos > body_head) {
-		regmatch_t match;
-
-		next_match = body_head;
-		match_marg = NULL;
-		next_substitution(macro_symbol, body_pos, &next_match,
-				  &match_marg, &match);
-
-		/* Put back everything up until the replacement. */
-		while (body_pos > next_match)
-			unput(*--body_pos);
-
-		/* Perform the replacement. */
-		if (match_marg != NULL) {
-			const char *strp;
-
-			next_match = match_marg->replacement_text;
-			strp = next_match + strlen(next_match);
-			while (strp > next_match)
-				unput(*--strp);
-
-			/* Skip past the unexpanded macro arg. */
-			body_pos -= match.rm_eo - match.rm_so;
-		}
-	}
-
-	/* Cleanup replacement text. */
-	STAILQ_FOREACH(marg, &macro_symbol->info.macroinfo->args, links) {
-		free(marg->replacement_text);
-	}
-}
-
-/*
- * Find the next substitution in the macro working backwards from
- * body_pos until the beginning of the macro buffer.  next_match
- * should be initialized to the beginning of the macro buffer prior
- * to calling this routine.
- */
-static void
-next_substitution(struct symbol *mac_symbol, const char *body_pos,
-		  const char **next_match, struct macro_arg **match_marg,
-		  regmatch_t *match)
-{
-	regmatch_t	  matches[2];
-	struct macro_arg *marg;
-	const char	 *search_pos;
-	int		  retval;
-
-	do {
-		search_pos = *next_match;
-
-		STAILQ_FOREACH(marg, &mac_symbol->info.macroinfo->args, links) {
-
-			retval = regexec(&marg->arg_regex, search_pos, 2,
-					 matches, 0);
-			if (retval == 0
-			 && (matches[1].rm_eo + search_pos) <= body_pos
-			 && (matches[1].rm_eo + search_pos) > *next_match) {
-				*match = matches[1];
-				*next_match = match->rm_eo + search_pos;
-				*match_marg = marg;
-			}
-		}
-	} while (search_pos != *next_match);
-}
-
-int
-yywrap()
-{
-	include_t *include;
-
-	yy_delete_buffer(YY_CURRENT_BUFFER);
-	(void)fclose(yyin);
-	if (yyfilename != NULL)
-		free(yyfilename);
-	yyfilename = NULL;
-	include = include_stack.slh_first;
-	if (include != NULL) {
-		yy_switch_to_buffer(include->buffer);
-		yylineno = include->lineno;
-		yyfilename = include->filename;
-		SLIST_REMOVE_HEAD(&include_stack, links);
-		free(include);
-		return (0);
-	}
-	return (1);
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aicasm/aicasm_symbol.c linux-2.4.22-pre2/drivers/scsi/aic79xx/aicasm/aicasm_symbol.c
--- linux-2.4.21/drivers/scsi/aic79xx/aicasm/aicasm_symbol.c	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aicasm/aicasm_symbol.c	2003-06-26 21:43:15.000000000 +0000
@@ -1,677 +0,0 @@
-/*
- * Aic7xxx SCSI host adapter firmware asssembler symbol table implementation
- *
- * Copyright (c) 1997 Justin T. Gibbs.
- * Copyright (c) 2002 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: //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#24 $
- *
- * $FreeBSD$
- */
-
-#include <sys/types.h>
-
-#ifdef __linux__
-#include "aicdb.h"
-#else
-#include <db.h>
-#endif
-#include <fcntl.h>
-#include <inttypes.h>
-#include <regex.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sysexits.h>
-
-#include "aicasm_symbol.h"
-#include "aicasm.h"
-
-static DB *symtable;
-
-symbol_t *
-symbol_create(char *name)
-{
-	symbol_t *new_symbol;
-
-	new_symbol = (symbol_t *)malloc(sizeof(symbol_t));
-	if (new_symbol == NULL) {
-		perror("Unable to create new symbol");
-		exit(EX_SOFTWARE);
-	}
-	memset(new_symbol, 0, sizeof(*new_symbol));
-	new_symbol->name = strdup(name);
-	if (new_symbol->name == NULL)
-		 stop("Unable to strdup symbol name", EX_SOFTWARE);
-	new_symbol->type = UNINITIALIZED;
-	return (new_symbol);
-}
-
-void
-symbol_delete(symbol_t *symbol)
-{
-	if (symtable != NULL) {
-		DBT	 key;
-
-		key.data = symbol->name;
-		key.size = strlen(symbol->name);
-		symtable->del(symtable, &key, /*flags*/0);
-	}
-	switch(symbol->type) {
-	case SCBLOC:
-	case SRAMLOC:
-	case REGISTER:
-		if (symbol->info.rinfo != NULL)
-			free(symbol->info.rinfo);
-		break;
-	case ALIAS:
-		if (symbol->info.ainfo != NULL)
-			free(symbol->info.ainfo);
-		break;
-	case MASK:
-	case FIELD:
-	case ENUM:
-	case ENUM_ENTRY:
-		if (symbol->info.finfo != NULL) {
-			symlist_free(&symbol->info.finfo->symrefs);
-			free(symbol->info.finfo);
-		}
-		break;
-	case DOWNLOAD_CONST:
-	case CONST:
-		if (symbol->info.cinfo != NULL)
-			free(symbol->info.cinfo);
-		break;
-	case LABEL:
-		if (symbol->info.linfo != NULL)
-			free(symbol->info.linfo);
-		break;
-	case UNINITIALIZED:
-	default:
-		break;
-	}
-	free(symbol->name);
-	free(symbol);
-}
-
-void
-symtable_open()
-{
-	symtable = dbopen(/*filename*/NULL,
-			  O_CREAT | O_NONBLOCK | O_RDWR, /*mode*/0, DB_HASH,
-			  /*openinfo*/NULL);
-
-	if (symtable == NULL) {
-		perror("Symbol table creation failed");
-		exit(EX_SOFTWARE);
-		/* NOTREACHED */
-	}
-}
-
-void
-symtable_close()
-{
-	if (symtable != NULL) {
-		DBT	 key;
-		DBT	 data;
-
-		while (symtable->seq(symtable, &key, &data, R_FIRST) == 0) {
-			symbol_t *stored_ptr;
-
-			memcpy(&stored_ptr, data.data, sizeof(stored_ptr));
-			symbol_delete(stored_ptr);
-		}
-		symtable->close(symtable);
-	}
-}
-
-/*
- * The semantics of get is to return an uninitialized symbol entry
- * if a lookup fails.
- */
-symbol_t *
-symtable_get(char *name)
-{
-	symbol_t *stored_ptr;
-	DBT	  key;
-	DBT	  data;
-	int	  retval;
-
-	key.data = (void *)name;
-	key.size = strlen(name);
-
-	if ((retval = symtable->get(symtable, &key, &data, /*flags*/0)) != 0) {
-		if (retval == -1) {
-			perror("Symbol table get operation failed");
-			exit(EX_SOFTWARE);
-			/* NOTREACHED */
-		} else if (retval == 1) {
-			/* Symbol wasn't found, so create a new one */
-			symbol_t *new_symbol;
-
-			new_symbol = symbol_create(name);
-			data.data = &new_symbol;
-			data.size = sizeof(new_symbol);
-			if (symtable->put(symtable, &key, &data,
-					  /*flags*/0) !=0) {
-				perror("Symtable put failed");
-				exit(EX_SOFTWARE);
-			}
-			return (new_symbol);
-		} else {
-			perror("Unexpected return value from db get routine");
-			exit(EX_SOFTWARE);
-			/* NOTREACHED */
-		}
-	}
-	memcpy(&stored_ptr, data.data, sizeof(stored_ptr));
-	return (stored_ptr);
-}
-
-symbol_node_t *
-symlist_search(symlist_t *symlist, char *symname)
-{
-	symbol_node_t *curnode;
-
-	curnode = SLIST_FIRST(symlist);
-	while(curnode != NULL) {
-		if (strcmp(symname, curnode->symbol->name) == 0)
-			break;
-		curnode = SLIST_NEXT(curnode, links);
-	}
-	return (curnode);
-}
-
-void
-symlist_add(symlist_t *symlist, symbol_t *symbol, int how)
-{
-	symbol_node_t *newnode;
-
-	newnode = (symbol_node_t *)malloc(sizeof(symbol_node_t));
-	if (newnode == NULL) {
-		stop("symlist_add: Unable to malloc symbol_node", EX_SOFTWARE);
-		/* NOTREACHED */
-	}
-	newnode->symbol = symbol;
-	if (how == SYMLIST_SORT) {
-		symbol_node_t *curnode;
-		int field;
-
-		field = FALSE;
-		switch(symbol->type) {
-		case REGISTER:
-		case SCBLOC:
-		case SRAMLOC:
-			break;
-		case FIELD:
-		case MASK:
-		case ENUM:
-		case ENUM_ENTRY:
-			field = TRUE;
-			break;
-		default:
-			stop("symlist_add: Invalid symbol type for sorting",
-			     EX_SOFTWARE);
-			/* NOTREACHED */
-		}
-
-		curnode = SLIST_FIRST(symlist);
-		if (curnode == NULL
-		 || (field
-		  && (curnode->symbol->type > newnode->symbol->type
-		   || (curnode->symbol->type == newnode->symbol->type
-		    && (curnode->symbol->info.finfo->value >
-			newnode->symbol->info.finfo->value))))
-		 || (!field && (curnode->symbol->info.rinfo->address >
-		               newnode->symbol->info.rinfo->address))) {
-			SLIST_INSERT_HEAD(symlist, newnode, links);
-			return;
-		}
-
-		while (1) {
-			if (SLIST_NEXT(curnode, links) == NULL) {
-				SLIST_INSERT_AFTER(curnode, newnode,
-						   links);
-				break;
-			} else {
-				symbol_t *cursymbol;
-
-				cursymbol = SLIST_NEXT(curnode, links)->symbol;
-				if ((field
-		  		  && (cursymbol->type > symbol->type
-				   || (cursymbol->type == symbol->type
-				    && (cursymbol->info.finfo->value >
-					symbol->info.finfo->value))))
-				 || (!field
-				   && (cursymbol->info.rinfo->address >
-				       symbol->info.rinfo->address))) {
-					SLIST_INSERT_AFTER(curnode, newnode,
-							   links);
-					break;
-				}
-			}
-			curnode = SLIST_NEXT(curnode, links);
-		}
-	} else {
-		SLIST_INSERT_HEAD(symlist, newnode, links);
-	}
-}
-
-void
-symlist_free(symlist_t *symlist)
-{
-	symbol_node_t *node1, *node2;
-
-	node1 = SLIST_FIRST(symlist);
-	while (node1 != NULL) {
-		node2 = SLIST_NEXT(node1, links);
-		free(node1);
-		node1 = node2;
-	}
-	SLIST_INIT(symlist);
-}
-
-void
-symlist_merge(symlist_t *symlist_dest, symlist_t *symlist_src1,
-	      symlist_t *symlist_src2)
-{
-	symbol_node_t *node;
-
-	*symlist_dest = *symlist_src1;
-	while((node = SLIST_FIRST(symlist_src2)) != NULL) {
-		SLIST_REMOVE_HEAD(symlist_src2, links);
-		SLIST_INSERT_HEAD(symlist_dest, node, links);
-	}
-
-	/* These are now empty */
-	SLIST_INIT(symlist_src1);
-	SLIST_INIT(symlist_src2);
-}
-
-void
-aic_print_file_prologue(FILE *ofile)
-{
-
-	if (ofile == NULL)
-		return;
-
-	fprintf(ofile,
-"/*\n"
-" * DO NOT EDIT - This file is automatically generated\n"
-" *		 from the following source files:\n"
-" *\n"
-"%s */\n",
-		versions);
-}
-
-void
-aic_print_include(FILE *dfile, char *include_file)
-{
-
-	if (dfile == NULL)
-		return;
-	fprintf(dfile, "\n#include \"%s\"\n\n", include_file);
-}
-
-void
-aic_print_reg_dump_types(FILE *ofile)
-{
-	if (ofile == NULL)
-		return;
-		
-	fprintf(ofile,
-"typedef int (%sreg_print_t)(u_int, u_int *, u_int);\n"
-"typedef struct %sreg_parse_entry {\n"
-"	char	*name;\n"
-"	uint8_t	 value;\n"
-"	uint8_t	 mask;\n"
-"} %sreg_parse_entry_t;\n"
-"\n",
-		prefix, prefix, prefix);
-}
-
-static void
-aic_print_reg_dump_start(FILE *dfile, symbol_node_t *regnode)
-{
-	if (dfile == NULL)
-		return;
-
-	fprintf(dfile,
-"static %sreg_parse_entry_t %s_parse_table[] = {\n",
-		prefix,
-		regnode->symbol->name);
-}
-
-static void
-aic_print_reg_dump_end(FILE *ofile, FILE *dfile,
-		       symbol_node_t *regnode, u_int num_entries)
-{
-	char *lower_name;
-	char *letter;
-
-	lower_name = strdup(regnode->symbol->name);
-	if (lower_name == NULL)
-		 stop("Unable to strdup symbol name", EX_SOFTWARE);
-	
-	for (letter = lower_name; *letter != '\0'; letter++)
-		*letter = tolower(*letter);
-
-	if (dfile != NULL) {
-		if (num_entries != 0)
-			fprintf(dfile,
-"\n"
-"};\n"
-"\n");
-
-		fprintf(dfile,
-"int\n"
-"%s%s_print(u_int regvalue, u_int *cur_col, u_int wrap)\n"
-"{\n"
-"	return (%sprint_register(%s%s, %d, \"%s\",\n"
-"	    0x%02x, regvalue, cur_col, wrap));\n"
-"}\n"
-"\n",
-			prefix,
-			lower_name,
-			prefix,
-			num_entries != 0 ? regnode->symbol->name : "NULL",
-			num_entries != 0 ? "_parse_table" : "",
-			num_entries,
-			regnode->symbol->name,
-			regnode->symbol->info.rinfo->address);
-	}
-
-	fprintf(ofile,
-"#if AIC_DEBUG_REGISTERS\n"
-"%sreg_print_t %s%s_print;\n"
-"#else\n"
-"#define %s%s_print(regvalue, cur_col, wrap) \\\n"
-"    %sprint_register(NULL, 0, \"%s\", 0x%02x, regvalue, cur_col, wrap)\n"
-"#endif\n"
-"\n",
-		prefix,
-		prefix,
-		lower_name,
-		prefix,
-		lower_name,
-		prefix,
-		regnode->symbol->name,
-		regnode->symbol->info.rinfo->address);
-}
-
-static void
-aic_print_reg_dump_entry(FILE *dfile, symbol_node_t *curnode)
-{
-	int num_tabs;
-
-	if (dfile == NULL)
-		return;
-
-	fprintf(dfile,
-"	{ \"%s\",",
-		curnode->symbol->name);
-
-	num_tabs = 3 - (strlen(curnode->symbol->name) + 5) / 8;
-
-	while (num_tabs-- > 0)
-		fputc('\t', dfile);
-	fprintf(dfile, "0x%02x, 0x%02x }",
-		curnode->symbol->info.finfo->value,
-		curnode->symbol->info.finfo->mask);
-}
-
-void
-symtable_dump(FILE *ofile, FILE *dfile)
-{
-	/*
-	 * Sort the registers by address with a simple insertion sort.
-	 * Put bitmasks next to the first register that defines them.
-	 * Put constants at the end.
-	 */
-	symlist_t	 registers;
-	symlist_t	 masks;
-	symlist_t	 constants;
-	symlist_t	 download_constants;
-	symlist_t	 aliases;
-	symlist_t	 exported_labels;
-	symbol_node_t	*curnode;
-	symbol_node_t	*regnode;
-	DBT		 key;
-	DBT		 data;
-	int		 flag;
-	u_int		 i;
-
-	if (symtable == NULL)
-		return;
-
-	SLIST_INIT(&registers);
-	SLIST_INIT(&masks);
-	SLIST_INIT(&constants);
-	SLIST_INIT(&download_constants);
-	SLIST_INIT(&aliases);
-	SLIST_INIT(&exported_labels);
-	flag = R_FIRST;
-	while (symtable->seq(symtable, &key, &data, flag) == 0) {
-		symbol_t *cursym;
-
-		memcpy(&cursym, data.data, sizeof(cursym));
-		switch(cursym->type) {
-		case REGISTER:
-		case SCBLOC:
-		case SRAMLOC:
-			symlist_add(&registers, cursym, SYMLIST_SORT);
-			break;
-		case MASK:
-		case FIELD:
-		case ENUM:
-		case ENUM_ENTRY:
-			symlist_add(&masks, cursym, SYMLIST_SORT);
-			break;
-		case CONST:
-			symlist_add(&constants, cursym,
-				    SYMLIST_INSERT_HEAD);
-			break;
-		case DOWNLOAD_CONST:
-			symlist_add(&download_constants, cursym,
-				    SYMLIST_INSERT_HEAD);
-			break;
-		case ALIAS:
-			symlist_add(&aliases, cursym,
-				    SYMLIST_INSERT_HEAD);
-			break;
-		case LABEL:
-			if (cursym->info.linfo->exported == 0)
-				break;
-			symlist_add(&exported_labels, cursym,
-				    SYMLIST_INSERT_HEAD);
-			break;
-		default:
-			break;
-		}
-		flag = R_NEXT;
-	}
-
-	/* Register dianostic functions/declarations first. */
-	aic_print_file_prologue(ofile);
-	aic_print_reg_dump_types(ofile);
-	aic_print_file_prologue(dfile);
-	aic_print_include(dfile, stock_include_file);
-	SLIST_FOREACH(curnode, &registers, links) {
-
-		switch(curnode->symbol->type) {
-		case REGISTER:
-		case SCBLOC:
-		case SRAMLOC:
-		{
-			symlist_t	*fields;
-			symbol_node_t	*fieldnode;
-			int		 num_entries;
-
-			num_entries = 0;
-			fields = &curnode->symbol->info.rinfo->fields;
-			SLIST_FOREACH(fieldnode, fields, links) {
-				if (num_entries == 0)
-					aic_print_reg_dump_start(dfile,
-								 curnode);
-				else if (dfile != NULL)
-					fputs(",\n", dfile);
-				num_entries++;
-				aic_print_reg_dump_entry(dfile, fieldnode);
-			}
-			aic_print_reg_dump_end(ofile, dfile,
-					       curnode, num_entries);
-		}
-		default:
-			break;
-		}
-	}
-
-	/* Fold in the masks and bits */
-	while (SLIST_FIRST(&masks) != NULL) {
-		char *regname;
-
-		curnode = SLIST_FIRST(&masks);
-		SLIST_REMOVE_HEAD(&masks, links);
-
-		regnode = SLIST_FIRST(&curnode->symbol->info.finfo->symrefs);
-		regname = regnode->symbol->name;
-		regnode = symlist_search(&registers, regname);
-		SLIST_INSERT_AFTER(regnode, curnode, links);
-	}
-
-	/* Add the aliases */
-	while (SLIST_FIRST(&aliases) != NULL) {
-		char *regname;
-
-		curnode = SLIST_FIRST(&aliases);
-		SLIST_REMOVE_HEAD(&aliases, links);
-
-		regname = curnode->symbol->info.ainfo->parent->name;
-		regnode = symlist_search(&registers, regname);
-		SLIST_INSERT_AFTER(regnode, curnode, links);
-	}
-
-	/* Output generated #defines. */
-	while (SLIST_FIRST(&registers) != NULL) {
-		symbol_node_t *curnode;
-		u_int value;
-		char *tab_str;
-		char *tab_str2;
-
-		curnode = SLIST_FIRST(&registers);
-		SLIST_REMOVE_HEAD(&registers, links);
-		switch(curnode->symbol->type) {
-		case REGISTER:
-		case SCBLOC:
-		case SRAMLOC:
-			fprintf(ofile, "\n");
-			value = curnode->symbol->info.rinfo->address;
-			tab_str = "\t";
-			tab_str2 = "\t\t";
-			break;
-		case ALIAS:
-		{
-			symbol_t *parent;
-
-			parent = curnode->symbol->info.ainfo->parent;
-			value = parent->info.rinfo->address;
-			tab_str = "\t";
-			tab_str2 = "\t\t";
-			break;
-		}
-		case MASK:
-		case FIELD:
-		case ENUM:
-		case ENUM_ENTRY:
-			value = curnode->symbol->info.finfo->value;
-			tab_str = "\t\t";
-			tab_str2 = "\t";
-			break;
-		default:
-			value = 0; /* Quiet compiler */
-			tab_str = NULL;
-			tab_str2 = NULL;
-			stop("symtable_dump: Invalid symbol type "
-			     "encountered", EX_SOFTWARE);
-			break;
-		}
-		fprintf(ofile, "#define%s%-16s%s0x%02x\n",
-			tab_str, curnode->symbol->name, tab_str2,
-			value);
-		free(curnode);
-	}
-	fprintf(ofile, "\n\n");
-
-	while (SLIST_FIRST(&constants) != NULL) {
-		symbol_node_t *curnode;
-
-		curnode = SLIST_FIRST(&constants);
-		SLIST_REMOVE_HEAD(&constants, links);
-		fprintf(ofile, "#define\t%-8s\t0x%02x\n",
-			curnode->symbol->name,
-			curnode->symbol->info.cinfo->value);
-		free(curnode);
-	}
-
-	
-	fprintf(ofile, "\n\n/* Downloaded Constant Definitions */\n");
-
-	for (i = 0; SLIST_FIRST(&download_constants) != NULL; i++) {
-		symbol_node_t *curnode;
-
-		curnode = SLIST_FIRST(&download_constants);
-		SLIST_REMOVE_HEAD(&download_constants, links);
-		fprintf(ofile, "#define\t%-8s\t0x%02x\n",
-			curnode->symbol->name,
-			curnode->symbol->info.cinfo->value);
-		free(curnode);
-	}
-	fprintf(ofile, "#define\tDOWNLOAD_CONST_COUNT\t0x%02x\n", i);
-
-	fprintf(ofile, "\n\n/* Exported Labels */\n");
-
-	while (SLIST_FIRST(&exported_labels) != NULL) {
-		symbol_node_t *curnode;
-
-		curnode = SLIST_FIRST(&exported_labels);
-		SLIST_REMOVE_HEAD(&exported_labels, links);
-		fprintf(ofile, "#define\tLABEL_%-8s\t0x%02x\n",
-			curnode->symbol->name,
-			curnode->symbol->info.linfo->address);
-		free(curnode);
-	}
-}
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aicasm/aicasm_symbol.h linux-2.4.22-pre2/drivers/scsi/aic79xx/aicasm/aicasm_symbol.h
--- linux-2.4.21/drivers/scsi/aic79xx/aicasm/aicasm_symbol.h	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aicasm/aicasm_symbol.h	2003-06-26 21:43:15.000000000 +0000
@@ -1,207 +0,0 @@
-/*
- * Aic7xxx SCSI host adapter firmware asssembler symbol table definitions
- *
- * Copyright (c) 1997 Justin T. Gibbs.
- * Copyright (c) 2002 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: //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#17 $
- *
- * $FreeBSD$
- */
-
-#ifdef __linux__
-#include "../queue.h"
-#else
-#include <sys/queue.h>
-#endif
-
-typedef enum {
-	UNINITIALIZED,
-	REGISTER,
-	ALIAS,
-	SCBLOC,
-	SRAMLOC,
-	ENUM_ENTRY,
-	FIELD,
-	MASK,
-	ENUM,
-	CONST,
-	DOWNLOAD_CONST,
-	LABEL,
-	CONDITIONAL,
-	MACRO
-} symtype;
-
-typedef enum {
-	RO = 0x01,
-	WO = 0x02,
-	RW = 0x03
-}amode_t;
-
-typedef SLIST_HEAD(symlist, symbol_node) symlist_t;
-
-struct reg_info {
-	u_int	  address;
-	int	  size;
-	amode_t	  mode;
-	symlist_t fields;
-	uint8_t	  valid_bitmask;
-	uint8_t	  modes;
-	int	  typecheck_masks;
-};
-
-struct field_info {
-	symlist_t symrefs;
-	uint8_t	  value;
-	uint8_t	  mask;
-};
-
-struct const_info {
-	u_int	value;
-	int	define;
-};
-
-struct alias_info {
-	struct symbol *parent;
-};
-
-struct label_info {
-	int	address;
-	int	exported;
-};
-
-struct cond_info {
-	int	func_num;
-};
-
-struct macro_arg {
-	STAILQ_ENTRY(macro_arg)	links;
-	regex_t	arg_regex;
-	char   *replacement_text;
-};
-STAILQ_HEAD(macro_arg_list, macro_arg) args;
-
-struct macro_info {
-	struct macro_arg_list args;
-	int   narg;
-	const char* body;
-};
-
-typedef struct expression_info {
-        symlist_t       referenced_syms;
-        int             value;
-} expression_t;
-
-typedef struct symbol {
-	char	*name;
-	symtype	type;
-	union	{
-		struct reg_info	  *rinfo;
-		struct field_info *finfo;
-		struct const_info *cinfo;
-		struct alias_info *ainfo;
-		struct label_info *linfo;
-		struct cond_info  *condinfo;
-		struct macro_info *macroinfo;
-	}info;
-} symbol_t;
-
-typedef struct symbol_ref {
-	symbol_t *symbol;
-	int	 offset;
-} symbol_ref_t;
-
-typedef struct symbol_node {
-	SLIST_ENTRY(symbol_node) links;
-	symbol_t *symbol;
-} symbol_node_t;
-
-typedef struct critical_section {
-	TAILQ_ENTRY(critical_section) links;
-	int begin_addr;
-	int end_addr;
-} critical_section_t;
-
-typedef enum {
-	SCOPE_ROOT,
-	SCOPE_IF,
-	SCOPE_ELSE_IF,
-	SCOPE_ELSE
-} scope_type;
-
-typedef struct patch_info {
-	int skip_patch;
-	int skip_instr;
-} patch_info_t;
-
-typedef struct scope {
-	SLIST_ENTRY(scope) scope_stack_links;
-	TAILQ_ENTRY(scope) scope_links;
-	TAILQ_HEAD(, scope) inner_scope;
-	scope_type type;
-	int inner_scope_patches;
-	int begin_addr;
-        int end_addr;
-	patch_info_t patches[2];
-	int func_num;
-} scope_t;
-
-TAILQ_HEAD(cs_tailq, critical_section);
-SLIST_HEAD(scope_list, scope);
-TAILQ_HEAD(scope_tailq, scope);
-
-void	symbol_delete(symbol_t *symbol);
-
-void	symtable_open(void);
-
-void	symtable_close(void);
-
-symbol_t *
-	symtable_get(char *name);
-
-symbol_node_t *
-	symlist_search(symlist_t *symlist, char *symname);
-
-void
-	symlist_add(symlist_t *symlist, symbol_t *symbol, int how);
-#define SYMLIST_INSERT_HEAD	0x00
-#define SYMLIST_SORT		0x01
-
-void	symlist_free(symlist_t *symlist);
-
-void	symlist_merge(symlist_t *symlist_dest, symlist_t *symlist_src1,
-		      symlist_t *symlist_src2);
-void	symtable_dump(FILE *ofile, FILE *dfile);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aiclib.c linux-2.4.22-pre2/drivers/scsi/aic79xx/aiclib.c
--- linux-2.4.21/drivers/scsi/aic79xx/aiclib.c	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aiclib.c	2003-06-26 21:43:31.000000000 +0000
@@ -1,1335 +0,0 @@
-/*
- * Implementation of Utility functions for all SCSI device types.
- *
- * Copyright (c) 1997, 1998, 1999 Justin T. Gibbs.
- * Copyright (c) 1997, 1998 Kenneth D. Merry.
- * 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, immediately at the beginning of the file.
- * 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 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.
- *
- * $FreeBSD: src/sys/cam/scsi/scsi_all.c,v 1.38 2002/09/23 04:56:35 mjacob Exp $
- * $Id$
- */
-
-#include <linux/blk.h>
-#include <linux/blkdev.h>
-#include <linux/delay.h>
-#include <linux/version.h>
-
-/* Core SCSI definitions */
-#include "scsi.h"
-#include "hosts.h"
-#include "aiclib.h"
-#include "cam.h"
-
-#ifndef FALSE
-#define FALSE   0
-#endif /* FALSE */
-#ifndef TRUE
-#define TRUE    1
-#endif /* TRUE */
-#ifndef ERESTART
-#define ERESTART        -1              /* restart syscall */
-#endif
-#ifndef EJUSTRETURN
-#define EJUSTRETURN     -2              /* don't modify regs, just return */
-#endif
-
-static int	ascentrycomp(const void *key, const void *member);
-static int	senseentrycomp(const void *key, const void *member);
-static void	fetchtableentries(int sense_key, int asc, int ascq,
-				  struct scsi_inquiry_data *,
-				  const struct sense_key_table_entry **,
-				  const struct asc_table_entry **);
-static void *	scsibsearch(const void *key, const void *base, size_t nmemb,
-			    size_t size,
-			    int (*compar)(const void *, const void *));
-typedef int (cam_quirkmatch_t)(caddr_t, caddr_t);
-static int	cam_strmatch(const u_int8_t *str, const u_int8_t *pattern,
-			     int str_len);
-static caddr_t	cam_quirkmatch(caddr_t target, caddr_t quirk_table,
-			       int num_entries, int entry_size,
-			       cam_quirkmatch_t *comp_func);
-
-#define SCSI_NO_SENSE_STRINGS 1
-#if !defined(SCSI_NO_SENSE_STRINGS)
-#define SST(asc, ascq, action, desc) \
-	asc, ascq, action, desc
-#else 
-static const char empty_string[] = "";
-
-#define SST(asc, ascq, action, desc) \
-	asc, ascq, action, empty_string
-#endif 
-
-static const struct sense_key_table_entry sense_key_table[] = 
-{
-	{ SSD_KEY_NO_SENSE, SS_NOP, "NO SENSE" },
-	{ SSD_KEY_RECOVERED_ERROR, SS_NOP|SSQ_PRINT_SENSE, "RECOVERED ERROR" },
-	{
-	  SSD_KEY_NOT_READY, SS_TUR|SSQ_MANY|SSQ_DECREMENT_COUNT|EBUSY,
-	  "NOT READY"
-	},
-	{ SSD_KEY_MEDIUM_ERROR, SS_RDEF, "MEDIUM ERROR" },
-	{ SSD_KEY_HARDWARE_ERROR, SS_RDEF, "HARDWARE FAILURE" },
-	{ SSD_KEY_ILLEGAL_REQUEST, SS_FATAL|EINVAL, "ILLEGAL REQUEST" },
-	{ SSD_KEY_UNIT_ATTENTION, SS_FATAL|ENXIO, "UNIT ATTENTION" },
-	{ SSD_KEY_DATA_PROTECT, SS_FATAL|EACCES, "DATA PROTECT" },
-	{ SSD_KEY_BLANK_CHECK, SS_FATAL|ENOSPC, "BLANK CHECK" },
-	{ SSD_KEY_Vendor_Specific, SS_FATAL|EIO, "Vendor Specific" },
-	{ SSD_KEY_COPY_ABORTED, SS_FATAL|EIO, "COPY ABORTED" },
-	{ SSD_KEY_ABORTED_COMMAND, SS_RDEF, "ABORTED COMMAND" },
-	{ SSD_KEY_EQUAL, SS_NOP, "EQUAL" },
-	{ SSD_KEY_VOLUME_OVERFLOW, SS_FATAL|EIO, "VOLUME OVERFLOW" },
-	{ SSD_KEY_MISCOMPARE, SS_NOP, "MISCOMPARE" },
-	{ SSD_KEY_RESERVED, SS_FATAL|EIO, "RESERVED" }
-};
-
-static const int sense_key_table_size =
-    sizeof(sense_key_table)/sizeof(sense_key_table[0]);
-
-static struct asc_table_entry quantum_fireball_entries[] = {
-	{SST(0x04, 0x0b, SS_START|SSQ_DECREMENT_COUNT|ENXIO, 
-	     "Logical unit not ready, initializing cmd. required")}
-};
-
-static struct asc_table_entry sony_mo_entries[] = {
-	{SST(0x04, 0x00, SS_START|SSQ_DECREMENT_COUNT|ENXIO,
-	     "Logical unit not ready, cause not reportable")}
-};
-
-static struct scsi_sense_quirk_entry sense_quirk_table[] = {
-	{
-		/*
-		 * The Quantum Fireball ST and SE like to return 0x04 0x0b when
-		 * they really should return 0x04 0x02.  0x04,0x0b isn't
-		 * defined in any SCSI spec, and it isn't mentioned in the
-		 * hardware manual for these drives.
-		 */
-		{T_DIRECT, SIP_MEDIA_FIXED, "QUANTUM", "FIREBALL S*", "*"},
-		/*num_sense_keys*/0,
-		sizeof(quantum_fireball_entries)/sizeof(struct asc_table_entry),
-		/*sense key entries*/NULL,
-		quantum_fireball_entries
-	},
-	{
-		/*
-		 * This Sony MO drive likes to return 0x04, 0x00 when it
-		 * isn't spun up.
-		 */
-		{T_DIRECT, SIP_MEDIA_REMOVABLE, "SONY", "SMO-*", "*"},
-		/*num_sense_keys*/0,
-		sizeof(sony_mo_entries)/sizeof(struct asc_table_entry),
-		/*sense key entries*/NULL,
-		sony_mo_entries
-	}
-};
-
-static const int sense_quirk_table_size =
-    sizeof(sense_quirk_table)/sizeof(sense_quirk_table[0]);
-
-static struct asc_table_entry asc_table[] = {
-/*
- * From File: ASC-NUM.TXT
- * SCSI ASC/ASCQ Assignments
- * Numeric Sorted Listing
- * as of  5/12/97
- *
- * D - DIRECT ACCESS DEVICE (SBC)                     device column key
- * .T - SEQUENTIAL ACCESS DEVICE (SSC)               -------------------
- * . L - PRINTER DEVICE (SSC)                           blank = reserved
- * .  P - PROCESSOR DEVICE (SPC)                     not blank = allowed
- * .  .W - WRITE ONCE READ MULTIPLE DEVICE (SBC)
- * .  . R - CD DEVICE (MMC)
- * .  .  S - SCANNER DEVICE (SGC)
- * .  .  .O - OPTICAL MEMORY DEVICE (SBC)
- * .  .  . M - MEDIA CHANGER DEVICE (SMC)
- * .  .  .  C - COMMUNICATION DEVICE (SSC)
- * .  .  .  .A - STORAGE ARRAY DEVICE (SCC)
- * .  .  .  . E - ENCLOSURE SERVICES DEVICE (SES)
- * DTLPWRSOMCAE        ASC   ASCQ  Action  Description
- * ------------        ----  ----  ------  -----------------------------------*/
-/* DTLPWRSOMCAE */{SST(0x00, 0x00, SS_NOP,
-			"No additional sense information") },
-/*  T    S      */{SST(0x00, 0x01, SS_RDEF,
-			"Filemark detected") },
-/*  T    S      */{SST(0x00, 0x02, SS_RDEF,
-			"End-of-partition/medium detected") },
-/*  T           */{SST(0x00, 0x03, SS_RDEF,
-			"Setmark detected") },
-/*  T    S      */{SST(0x00, 0x04, SS_RDEF,
-			"Beginning-of-partition/medium detected") },
-/*  T    S      */{SST(0x00, 0x05, SS_RDEF,
-			"End-of-data detected") },
-/* DTLPWRSOMCAE */{SST(0x00, 0x06, SS_RDEF,
-			"I/O process terminated") },
-/*      R       */{SST(0x00, 0x11, SS_FATAL|EBUSY,
-			"Audio play operation in progress") },
-/*      R       */{SST(0x00, 0x12, SS_NOP,
-			"Audio play operation paused") },
-/*      R       */{SST(0x00, 0x13, SS_NOP,
-			"Audio play operation successfully completed") },
-/*      R       */{SST(0x00, 0x14, SS_RDEF,
-			"Audio play operation stopped due to error") },
-/*      R       */{SST(0x00, 0x15, SS_NOP,
-			"No current audio status to return") },
-/* DTLPWRSOMCAE */{SST(0x00, 0x16, SS_FATAL|EBUSY,
-			"Operation in progress") },
-/* DTL WRSOM AE */{SST(0x00, 0x17, SS_RDEF,
-			"Cleaning requested") },
-/* D   W  O     */{SST(0x01, 0x00, SS_RDEF,
-			"No index/sector signal") },
-/* D   WR OM    */{SST(0x02, 0x00, SS_RDEF,
-			"No seek complete") },
-/* DTL W SO     */{SST(0x03, 0x00, SS_RDEF,
-			"Peripheral device write fault") },
-/*  T           */{SST(0x03, 0x01, SS_RDEF,
-			"No write current") },
-/*  T           */{SST(0x03, 0x02, SS_RDEF,
-			"Excessive write errors") },
-/* DTLPWRSOMCAE */{SST(0x04, 0x00,
-			SS_TUR|SSQ_DELAY|SSQ_MANY|SSQ_DECREMENT_COUNT|EIO,
-			"Logical unit not ready, cause not reportable") },
-/* DTLPWRSOMCAE */{SST(0x04, 0x01,
-			SS_TUR|SSQ_DELAY|SSQ_MANY|SSQ_DECREMENT_COUNT|EBUSY,
-			"Logical unit is in process of becoming ready") },
-/* DTLPWRSOMCAE */{SST(0x04, 0x02, SS_START|SSQ_DECREMENT_COUNT|ENXIO,
-			"Logical unit not ready, initializing cmd. required") },
-/* DTLPWRSOMCAE */{SST(0x04, 0x03, SS_FATAL|ENXIO,
-			"Logical unit not ready, manual intervention required")},
-/* DTL    O     */{SST(0x04, 0x04, SS_FATAL|EBUSY,
-			"Logical unit not ready, format in progress") },
-/* DT  W  OMCA  */{SST(0x04, 0x05, SS_FATAL|EBUSY,
-			"Logical unit not ready, rebuild in progress") },
-/* DT  W  OMCA  */{SST(0x04, 0x06, SS_FATAL|EBUSY,
-			"Logical unit not ready, recalculation in progress") },
-/* DTLPWRSOMCAE */{SST(0x04, 0x07, SS_FATAL|EBUSY,
-			"Logical unit not ready, operation in progress") },
-/*      R       */{SST(0x04, 0x08, SS_FATAL|EBUSY,
-			"Logical unit not ready, long write in progress") },
-/* DTL WRSOMCAE */{SST(0x05, 0x00, SS_RDEF,
-			"Logical unit does not respond to selection") },
-/* D   WR OM    */{SST(0x06, 0x00, SS_RDEF,
-			"No reference position found") },
-/* DTL WRSOM    */{SST(0x07, 0x00, SS_RDEF,
-			"Multiple peripheral devices selected") },
-/* DTL WRSOMCAE */{SST(0x08, 0x00, SS_RDEF,
-			"Logical unit communication failure") },
-/* DTL WRSOMCAE */{SST(0x08, 0x01, SS_RDEF,
-			"Logical unit communication time-out") },
-/* DTL WRSOMCAE */{SST(0x08, 0x02, SS_RDEF,
-			"Logical unit communication parity error") },
-/* DT   R OM    */{SST(0x08, 0x03, SS_RDEF,
-			"Logical unit communication crc error (ultra-dma/32)")},
-/* DT  WR O     */{SST(0x09, 0x00, SS_RDEF,
-			"Track following error") },
-/*     WR O     */{SST(0x09, 0x01, SS_RDEF,
-			"Tracking servo failure") },
-/*     WR O     */{SST(0x09, 0x02, SS_RDEF,
-			"Focus servo failure") },
-/*     WR O     */{SST(0x09, 0x03, SS_RDEF,
-			"Spindle servo failure") },
-/* DT  WR O     */{SST(0x09, 0x04, SS_RDEF,
-			"Head select fault") },
-/* DTLPWRSOMCAE */{SST(0x0A, 0x00, SS_FATAL|ENOSPC,
-			"Error log overflow") },
-/* DTLPWRSOMCAE */{SST(0x0B, 0x00, SS_RDEF,
-			"Warning") },
-/* DTLPWRSOMCAE */{SST(0x0B, 0x01, SS_RDEF,
-			"Specified temperature exceeded") },
-/* DTLPWRSOMCAE */{SST(0x0B, 0x02, SS_RDEF,
-			"Enclosure degraded") },
-/*  T   RS      */{SST(0x0C, 0x00, SS_RDEF,
-			"Write error") },
-/* D   W  O     */{SST(0x0C, 0x01, SS_NOP|SSQ_PRINT_SENSE,
-			"Write error - recovered with auto reallocation") },
-/* D   W  O     */{SST(0x0C, 0x02, SS_RDEF,
-			"Write error - auto reallocation failed") },
-/* D   W  O     */{SST(0x0C, 0x03, SS_RDEF,
-			"Write error - recommend reassignment") },
-/* DT  W  O     */{SST(0x0C, 0x04, SS_RDEF,
-			"Compression check miscompare error") },
-/* DT  W  O     */{SST(0x0C, 0x05, SS_RDEF,
-			"Data expansion occurred during compression") },
-/* DT  W  O     */{SST(0x0C, 0x06, SS_RDEF,
-			"Block not compressible") },
-/*      R       */{SST(0x0C, 0x07, SS_RDEF,
-			"Write error - recovery needed") },
-/*      R       */{SST(0x0C, 0x08, SS_RDEF,
-			"Write error - recovery failed") },
-/*      R       */{SST(0x0C, 0x09, SS_RDEF,
-			"Write error - loss of streaming") },
-/*      R       */{SST(0x0C, 0x0A, SS_RDEF,
-			"Write error - padding blocks added") },
-/* D   W  O     */{SST(0x10, 0x00, SS_RDEF,
-			"ID CRC or ECC error") },
-/* DT  WRSO     */{SST(0x11, 0x00, SS_RDEF,
-			"Unrecovered read error") },
-/* DT  W SO     */{SST(0x11, 0x01, SS_RDEF,
-			"Read retries exhausted") },
-/* DT  W SO     */{SST(0x11, 0x02, SS_RDEF,
-			"Error too long to correct") },
-/* DT  W SO     */{SST(0x11, 0x03, SS_RDEF,
-			"Multiple read errors") },
-/* D   W  O     */{SST(0x11, 0x04, SS_RDEF,
-			"Unrecovered read error - auto reallocate failed") },
-/*     WR O     */{SST(0x11, 0x05, SS_RDEF,
-			"L-EC uncorrectable error") },
-/*     WR O     */{SST(0x11, 0x06, SS_RDEF,
-			"CIRC unrecovered error") },
-/*     W  O     */{SST(0x11, 0x07, SS_RDEF,
-			"Data re-synchronization error") },
-/*  T           */{SST(0x11, 0x08, SS_RDEF,
-			"Incomplete block read") },
-/*  T           */{SST(0x11, 0x09, SS_RDEF,
-			"No gap found") },
-/* DT     O     */{SST(0x11, 0x0A, SS_RDEF,
-			"Miscorrected error") },
-/* D   W  O     */{SST(0x11, 0x0B, SS_RDEF,
-			"Unrecovered read error - recommend reassignment") },
-/* D   W  O     */{SST(0x11, 0x0C, SS_RDEF,
-			"Unrecovered read error - recommend rewrite the data")},
-/* DT  WR O     */{SST(0x11, 0x0D, SS_RDEF,
-			"De-compression CRC error") },
-/* DT  WR O     */{SST(0x11, 0x0E, SS_RDEF,
-			"Cannot decompress using declared algorithm") },
-/*      R       */{SST(0x11, 0x0F, SS_RDEF,
-			"Error reading UPC/EAN number") },
-/*      R       */{SST(0x11, 0x10, SS_RDEF,
-			"Error reading ISRC number") },
-/*      R       */{SST(0x11, 0x11, SS_RDEF,
-			"Read error - loss of streaming") },
-/* D   W  O     */{SST(0x12, 0x00, SS_RDEF,
-			"Address mark not found for id field") },
-/* D   W  O     */{SST(0x13, 0x00, SS_RDEF,
-			"Address mark not found for data field") },
-/* DTL WRSO     */{SST(0x14, 0x00, SS_RDEF,
-			"Recorded entity not found") },
-/* DT  WR O     */{SST(0x14, 0x01, SS_RDEF,
-			"Record not found") },
-/*  T           */{SST(0x14, 0x02, SS_RDEF,
-			"Filemark or setmark not found") },
-/*  T           */{SST(0x14, 0x03, SS_RDEF,
-			"End-of-data not found") },
-/*  T           */{SST(0x14, 0x04, SS_RDEF,
-			"Block sequence error") },
-/* DT  W  O     */{SST(0x14, 0x05, SS_RDEF,
-			"Record not found - recommend reassignment") },
-/* DT  W  O     */{SST(0x14, 0x06, SS_RDEF,
-			"Record not found - data auto-reallocated") },
-/* DTL WRSOM    */{SST(0x15, 0x00, SS_RDEF,
-			"Random positioning error") },
-/* DTL WRSOM    */{SST(0x15, 0x01, SS_RDEF,
-			"Mechanical positioning error") },
-/* DT  WR O     */{SST(0x15, 0x02, SS_RDEF,
-			"Positioning error detected by read of medium") },
-/* D   W  O     */{SST(0x16, 0x00, SS_RDEF,
-			"Data synchronization mark error") },
-/* D   W  O     */{SST(0x16, 0x01, SS_RDEF,
-			"Data sync error - data rewritten") },
-/* D   W  O     */{SST(0x16, 0x02, SS_RDEF,
-			"Data sync error - recommend rewrite") },
-/* D   W  O     */{SST(0x16, 0x03, SS_NOP|SSQ_PRINT_SENSE,
-			"Data sync error - data auto-reallocated") },
-/* D   W  O     */{SST(0x16, 0x04, SS_RDEF,
-			"Data sync error - recommend reassignment") },
-/* DT  WRSO     */{SST(0x17, 0x00, SS_NOP|SSQ_PRINT_SENSE,
-			"Recovered data with no error correction applied") },
-/* DT  WRSO     */{SST(0x17, 0x01, SS_NOP|SSQ_PRINT_SENSE,
-			"Recovered data with retries") },
-/* DT  WR O     */{SST(0x17, 0x02, SS_NOP|SSQ_PRINT_SENSE,
-			"Recovered data with positive head offset") },
-/* DT  WR O     */{SST(0x17, 0x03, SS_NOP|SSQ_PRINT_SENSE,
-			"Recovered data with negative head offset") },
-/*     WR O     */{SST(0x17, 0x04, SS_NOP|SSQ_PRINT_SENSE,
-			"Recovered data with retries and/or CIRC applied") },
-/* D   WR O     */{SST(0x17, 0x05, SS_NOP|SSQ_PRINT_SENSE,
-			"Recovered data using previous sector id") },
-/* D   W  O     */{SST(0x17, 0x06, SS_NOP|SSQ_PRINT_SENSE,
-			"Recovered data without ECC - data auto-reallocated") },
-/* D   W  O     */{SST(0x17, 0x07, SS_NOP|SSQ_PRINT_SENSE,
-			"Recovered data without ECC - recommend reassignment")},
-/* D   W  O     */{SST(0x17, 0x08, SS_NOP|SSQ_PRINT_SENSE,
-			"Recovered data without ECC - recommend rewrite") },
-/* D   W  O     */{SST(0x17, 0x09, SS_NOP|SSQ_PRINT_SENSE,
-			"Recovered data without ECC - data rewritten") },
-/* D   W  O     */{SST(0x18, 0x00, SS_NOP|SSQ_PRINT_SENSE,
-			"Recovered data with error correction applied") },
-/* D   WR O     */{SST(0x18, 0x01, SS_NOP|SSQ_PRINT_SENSE,
-			"Recovered data with error corr. & retries applied") },
-/* D   WR O     */{SST(0x18, 0x02, SS_NOP|SSQ_PRINT_SENSE,
-			"Recovered data - data auto-reallocated") },
-/*      R       */{SST(0x18, 0x03, SS_NOP|SSQ_PRINT_SENSE,
-			"Recovered data with CIRC") },
-/*      R       */{SST(0x18, 0x04, SS_NOP|SSQ_PRINT_SENSE,
-			"Recovered data with L-EC") },
-/* D   WR O     */{SST(0x18, 0x05, SS_NOP|SSQ_PRINT_SENSE,
-			"Recovered data - recommend reassignment") },
-/* D   WR O     */{SST(0x18, 0x06, SS_NOP|SSQ_PRINT_SENSE,
-			"Recovered data - recommend rewrite") },
-/* D   W  O     */{SST(0x18, 0x07, SS_NOP|SSQ_PRINT_SENSE,
-			"Recovered data with ECC - data rewritten") },
-/* D      O     */{SST(0x19, 0x00, SS_RDEF,
-			"Defect list error") },
-/* D      O     */{SST(0x19, 0x01, SS_RDEF,
-			"Defect list not available") },
-/* D      O     */{SST(0x19, 0x02, SS_RDEF,
-			"Defect list error in primary list") },
-/* D      O     */{SST(0x19, 0x03, SS_RDEF,
-			"Defect list error in grown list") },
-/* DTLPWRSOMCAE */{SST(0x1A, 0x00, SS_RDEF,
-			"Parameter list length error") },
-/* DTLPWRSOMCAE */{SST(0x1B, 0x00, SS_RDEF,
-			"Synchronous data transfer error") },
-/* D      O     */{SST(0x1C, 0x00, SS_RDEF,
-			"Defect list not found") },
-/* D      O     */{SST(0x1C, 0x01, SS_RDEF,
-			"Primary defect list not found") },
-/* D      O     */{SST(0x1C, 0x02, SS_RDEF,
-			"Grown defect list not found") },
-/* D   W  O     */{SST(0x1D, 0x00, SS_FATAL,
-			"Miscompare during verify operation" )},
-/* D   W  O     */{SST(0x1E, 0x00, SS_NOP|SSQ_PRINT_SENSE,
-			"Recovered id with ecc correction") },
-/* D      O     */{SST(0x1F, 0x00, SS_RDEF,
-			"Partial defect list transfer") },
-/* DTLPWRSOMCAE */{SST(0x20, 0x00, SS_FATAL|EINVAL,
-			"Invalid command operation code") },
-/* DT  WR OM    */{SST(0x21, 0x00, SS_FATAL|EINVAL,
-			"Logical block address out of range" )},
-/* DT  WR OM    */{SST(0x21, 0x01, SS_FATAL|EINVAL,
-			"Invalid element address") },
-/* D            */{SST(0x22, 0x00, SS_FATAL|EINVAL,
-			"Illegal function") }, /* Deprecated. Use 20 00, 24 00, or 26 00 instead */
-/* DTLPWRSOMCAE */{SST(0x24, 0x00, SS_FATAL|EINVAL,
-			"Invalid field in CDB") },
-/* DTLPWRSOMCAE */{SST(0x25, 0x00, SS_FATAL|ENXIO,
-			"Logical unit not supported") },
-/* DTLPWRSOMCAE */{SST(0x26, 0x00, SS_FATAL|EINVAL,
-			"Invalid field in parameter list") },
-/* DTLPWRSOMCAE */{SST(0x26, 0x01, SS_FATAL|EINVAL,
-			"Parameter not supported") },
-/* DTLPWRSOMCAE */{SST(0x26, 0x02, SS_FATAL|EINVAL,
-			"Parameter value invalid") },
-/* DTLPWRSOMCAE */{SST(0x26, 0x03, SS_FATAL|EINVAL,
-			"Threshold parameters not supported") },
-/* DTLPWRSOMCAE */{SST(0x26, 0x04, SS_FATAL|EINVAL,
-			"Invalid release of active persistent reservation") },
-/* DT  W  O     */{SST(0x27, 0x00, SS_FATAL|EACCES,
-			"Write protected") },
-/* DT  W  O     */{SST(0x27, 0x01, SS_FATAL|EACCES,
-			"Hardware write protected") },
-/* DT  W  O     */{SST(0x27, 0x02, SS_FATAL|EACCES,
-			"Logical unit software write protected") },
-/*  T           */{SST(0x27, 0x03, SS_FATAL|EACCES,
-			"Associated write protect") },
-/*  T           */{SST(0x27, 0x04, SS_FATAL|EACCES,
-			"Persistent write protect") },
-/*  T           */{SST(0x27, 0x05, SS_FATAL|EACCES,
-			"Permanent write protect") },
-/* DTLPWRSOMCAE */{SST(0x28, 0x00, SS_RDEF,
-			"Not ready to ready change, medium may have changed") },
-/* DTLPWRSOMCAE */{SST(0x28, 0x01, SS_FATAL|ENXIO,
-			"Import or export element accessed") },
-/*
- * XXX JGibbs - All of these should use the same errno, but I don't think
- * ENXIO is the correct choice.  Should we borrow from the networking
- * errnos?  ECONNRESET anyone?
- */
-/* DTLPWRSOMCAE */{SST(0x29, 0x00, SS_RDEF,
-			"Power on, reset, or bus device reset occurred") },
-/* DTLPWRSOMCAE */{SST(0x29, 0x01, SS_RDEF,
-			"Power on occurred") },
-/* DTLPWRSOMCAE */{SST(0x29, 0x02, SS_RDEF,
-			"Scsi bus reset occurred") },
-/* DTLPWRSOMCAE */{SST(0x29, 0x03, SS_RDEF,
-			"Bus device reset function occurred") },
-/* DTLPWRSOMCAE */{SST(0x29, 0x04, SS_RDEF,
-			"Device internal reset") },
-/* DTLPWRSOMCAE */{SST(0x29, 0x05, SS_RDEF,
-			"Transceiver mode changed to single-ended") },
-/* DTLPWRSOMCAE */{SST(0x29, 0x06, SS_RDEF,
-			"Transceiver mode changed to LVD") },
-/* DTL WRSOMCAE */{SST(0x2A, 0x00, SS_RDEF,
-			"Parameters changed") },
-/* DTL WRSOMCAE */{SST(0x2A, 0x01, SS_RDEF,
-			"Mode parameters changed") },
-/* DTL WRSOMCAE */{SST(0x2A, 0x02, SS_RDEF,
-			"Log parameters changed") },
-/* DTLPWRSOMCAE */{SST(0x2A, 0x03, SS_RDEF,
-			"Reservations preempted") },
-/* DTLPWRSO C   */{SST(0x2B, 0x00, SS_RDEF,
-			"Copy cannot execute since host cannot disconnect") },
-/* DTLPWRSOMCAE */{SST(0x2C, 0x00, SS_RDEF,
-			"Command sequence error") },
-/*       S      */{SST(0x2C, 0x01, SS_RDEF,
-			"Too many windows specified") },
-/*       S      */{SST(0x2C, 0x02, SS_RDEF,
-			"Invalid combination of windows specified") },
-/*      R       */{SST(0x2C, 0x03, SS_RDEF,
-			"Current program area is not empty") },
-/*      R       */{SST(0x2C, 0x04, SS_RDEF,
-			"Current program area is empty") },
-/*  T           */{SST(0x2D, 0x00, SS_RDEF,
-			"Overwrite error on update in place") },
-/* DTLPWRSOMCAE */{SST(0x2F, 0x00, SS_RDEF,
-			"Commands cleared by another initiator") },
-/* DT  WR OM    */{SST(0x30, 0x00, SS_RDEF,
-			"Incompatible medium installed") },
-/* DT  WR O     */{SST(0x30, 0x01, SS_RDEF,
-			"Cannot read medium - unknown format") },
-/* DT  WR O     */{SST(0x30, 0x02, SS_RDEF,
-			"Cannot read medium - incompatible format") },
-/* DT           */{SST(0x30, 0x03, SS_RDEF,
-			"Cleaning cartridge installed") },
-/* DT  WR O     */{SST(0x30, 0x04, SS_RDEF,
-			"Cannot write medium - unknown format") },
-/* DT  WR O     */{SST(0x30, 0x05, SS_RDEF,
-			"Cannot write medium - incompatible format") },
-/* DT  W  O     */{SST(0x30, 0x06, SS_RDEF,
-			"Cannot format medium - incompatible medium") },
-/* DTL WRSOM AE */{SST(0x30, 0x07, SS_RDEF,
-			"Cleaning failure") },
-/*      R       */{SST(0x30, 0x08, SS_RDEF,
-			"Cannot write - application code mismatch") },
-/*      R       */{SST(0x30, 0x09, SS_RDEF,
-			"Current session not fixated for append") },
-/* DT  WR O     */{SST(0x31, 0x00, SS_RDEF,
-			"Medium format corrupted") },
-/* D L  R O     */{SST(0x31, 0x01, SS_RDEF,
-			"Format command failed") },
-/* D   W  O     */{SST(0x32, 0x00, SS_RDEF,
-			"No defect spare location available") },
-/* D   W  O     */{SST(0x32, 0x01, SS_RDEF,
-			"Defect list update failure") },
-/*  T           */{SST(0x33, 0x00, SS_RDEF,
-			"Tape length error") },
-/* DTLPWRSOMCAE */{SST(0x34, 0x00, SS_RDEF,
-			"Enclosure failure") },
-/* DTLPWRSOMCAE */{SST(0x35, 0x00, SS_RDEF,
-			"Enclosure services failure") },
-/* DTLPWRSOMCAE */{SST(0x35, 0x01, SS_RDEF,
-			"Unsupported enclosure function") },
-/* DTLPWRSOMCAE */{SST(0x35, 0x02, SS_RDEF,
-			"Enclosure services unavailable") },
-/* DTLPWRSOMCAE */{SST(0x35, 0x03, SS_RDEF,
-			"Enclosure services transfer failure") },
-/* DTLPWRSOMCAE */{SST(0x35, 0x04, SS_RDEF,
-			"Enclosure services transfer refused") },
-/*   L          */{SST(0x36, 0x00, SS_RDEF,
-			"Ribbon, ink, or toner failure") },
-/* DTL WRSOMCAE */{SST(0x37, 0x00, SS_RDEF,
-			"Rounded parameter") },
-/* DTL WRSOMCAE */{SST(0x39, 0x00, SS_RDEF,
-			"Saving parameters not supported") },
-/* DTL WRSOM    */{SST(0x3A, 0x00, SS_NOP,
-			"Medium not present") },
-/* DT  WR OM    */{SST(0x3A, 0x01, SS_NOP,
-			"Medium not present - tray closed") },
-/* DT  WR OM    */{SST(0x3A, 0x01, SS_NOP,
-			"Medium not present - tray open") },
-/* DT  WR OM    */{SST(0x3A, 0x03, SS_NOP,
-			"Medium not present - Loadable") },
-/* DT  WR OM    */{SST(0x3A, 0x04, SS_NOP,
-			"Medium not present - medium auxiliary "
-			"memory accessible") },
-/* DT  WR OM    */{SST(0x3A, 0xFF, SS_NOP, NULL) },/* Range 0x05->0xFF */
-/*  TL          */{SST(0x3B, 0x00, SS_RDEF,
-			"Sequential positioning error") },
-/*  T           */{SST(0x3B, 0x01, SS_RDEF,
-			"Tape position error at beginning-of-medium") },
-/*  T           */{SST(0x3B, 0x02, SS_RDEF,
-			"Tape position error at end-of-medium") },
-/*   L          */{SST(0x3B, 0x03, SS_RDEF,
-			"Tape or electronic vertical forms unit not ready") },
-/*   L          */{SST(0x3B, 0x04, SS_RDEF,
-			"Slew failure") },
-/*   L          */{SST(0x3B, 0x05, SS_RDEF,
-			"Paper jam") },
-/*   L          */{SST(0x3B, 0x06, SS_RDEF,
-			"Failed to sense top-of-form") },
-/*   L          */{SST(0x3B, 0x07, SS_RDEF,
-			"Failed to sense bottom-of-form") },
-/*  T           */{SST(0x3B, 0x08, SS_RDEF,
-			"Reposition error") },
-/*       S      */{SST(0x3B, 0x09, SS_RDEF,
-			"Read past end of medium") },
-/*       S      */{SST(0x3B, 0x0A, SS_RDEF,
-			"Read past beginning of medium") },
-/*       S      */{SST(0x3B, 0x0B, SS_RDEF,
-			"Position past end of medium") },
-/*  T    S      */{SST(0x3B, 0x0C, SS_RDEF,
-			"Position past beginning of medium") },
-/* DT  WR OM    */{SST(0x3B, 0x0D, SS_FATAL|ENOSPC,
-			"Medium destination element full") },
-/* DT  WR OM    */{SST(0x3B, 0x0E, SS_RDEF,
-			"Medium source element empty") },
-/*      R       */{SST(0x3B, 0x0F, SS_RDEF,
-			"End of medium reached") },
-/* DT  WR OM    */{SST(0x3B, 0x11, SS_RDEF,
-			"Medium magazine not accessible") },
-/* DT  WR OM    */{SST(0x3B, 0x12, SS_RDEF,
-			"Medium magazine removed") },
-/* DT  WR OM    */{SST(0x3B, 0x13, SS_RDEF,
-			"Medium magazine inserted") },
-/* DT  WR OM    */{SST(0x3B, 0x14, SS_RDEF,
-			"Medium magazine locked") },
-/* DT  WR OM    */{SST(0x3B, 0x15, SS_RDEF,
-			"Medium magazine unlocked") },
-/* DTLPWRSOMCAE */{SST(0x3D, 0x00, SS_RDEF,
-			"Invalid bits in identify message") },
-/* DTLPWRSOMCAE */{SST(0x3E, 0x00, SS_RDEF,
-			"Logical unit has not self-configured yet") },
-/* DTLPWRSOMCAE */{SST(0x3E, 0x01, SS_RDEF,
-			"Logical unit failure") },
-/* DTLPWRSOMCAE */{SST(0x3E, 0x02, SS_RDEF,
-			"Timeout on logical unit") },
-/* DTLPWRSOMCAE */{SST(0x3F, 0x00, SS_RDEF,
-			"Target operating conditions have changed") },
-/* DTLPWRSOMCAE */{SST(0x3F, 0x01, SS_RDEF,
-			"Microcode has been changed") },
-/* DTLPWRSOMC   */{SST(0x3F, 0x02, SS_RDEF,
-			"Changed operating definition") },
-/* DTLPWRSOMCAE */{SST(0x3F, 0x03, SS_INQ_REFRESH|SSQ_DECREMENT_COUNT,
-			"Inquiry data has changed") },
-/* DT  WR OMCAE */{SST(0x3F, 0x04, SS_RDEF,
-			"Component device attached") },
-/* DT  WR OMCAE */{SST(0x3F, 0x05, SS_RDEF,
-			"Device identifier changed") },
-/* DT  WR OMCAE */{SST(0x3F, 0x06, SS_RDEF,
-			"Redundancy group created or modified") },
-/* DT  WR OMCAE */{SST(0x3F, 0x07, SS_RDEF,
-			"Redundancy group deleted") },
-/* DT  WR OMCAE */{SST(0x3F, 0x08, SS_RDEF,
-			"Spare created or modified") },
-/* DT  WR OMCAE */{SST(0x3F, 0x09, SS_RDEF,
-			"Spare deleted") },
-/* DT  WR OMCAE */{SST(0x3F, 0x0A, SS_RDEF,
-			"Volume set created or modified") },
-/* DT  WR OMCAE */{SST(0x3F, 0x0B, SS_RDEF,
-			"Volume set deleted") },
-/* DT  WR OMCAE */{SST(0x3F, 0x0C, SS_RDEF,
-			"Volume set deassigned") },
-/* DT  WR OMCAE */{SST(0x3F, 0x0D, SS_RDEF,
-			"Volume set reassigned") },
-/* DTLPWRSOMCAE */{SST(0x3F, 0x0E, SS_RDEF,
-			"Reported luns data has changed") },
-/* DTLPWRSOMCAE */{SST(0x3F, 0x0F, SS_RETRY|SSQ_DECREMENT_COUNT
-				 | SSQ_DELAY_RANDOM|EBUSY,
-			"Echo buffer overwritten") },
-/* DT  WR OM   B*/{SST(0x3F, 0x0F, SS_RDEF, "Medium Loadable") },
-/* DT  WR OM   B*/{SST(0x3F, 0x0F, SS_RDEF,
-			"Medium auxiliary memory accessible") },
-/* D            */{SST(0x40, 0x00, SS_RDEF,
-			"Ram failure") }, /* deprecated - use 40 NN instead */
-/* DTLPWRSOMCAE */{SST(0x40, 0x80, SS_RDEF,
-			"Diagnostic failure: ASCQ = Component ID") },
-/* DTLPWRSOMCAE */{SST(0x40, 0xFF, SS_RDEF|SSQ_RANGE,
-			NULL) },/* Range 0x80->0xFF */
-/* D            */{SST(0x41, 0x00, SS_RDEF,
-			"Data path failure") }, /* deprecated - use 40 NN instead */
-/* D            */{SST(0x42, 0x00, SS_RDEF,
-			"Power-on or self-test failure") }, /* deprecated - use 40 NN instead */
-/* DTLPWRSOMCAE */{SST(0x43, 0x00, SS_RDEF,
-			"Message error") },
-/* DTLPWRSOMCAE */{SST(0x44, 0x00, SS_RDEF,
-			"Internal target failure") },
-/* DTLPWRSOMCAE */{SST(0x45, 0x00, SS_RDEF,
-			"Select or reselect failure") },
-/* DTLPWRSOMC   */{SST(0x46, 0x00, SS_RDEF,
-			"Unsuccessful soft reset") },
-/* DTLPWRSOMCAE */{SST(0x47, 0x00, SS_RDEF|SSQ_FALLBACK,
-			"SCSI parity error") },
-/* DTLPWRSOMCAE */{SST(0x47, 0x01, SS_RDEF|SSQ_FALLBACK,
-			"Data Phase CRC error detected") },
-/* DTLPWRSOMCAE */{SST(0x47, 0x02, SS_RDEF|SSQ_FALLBACK,
-			"SCSI parity error detected during ST data phase") },
-/* DTLPWRSOMCAE */{SST(0x47, 0x03, SS_RDEF|SSQ_FALLBACK,
-			"Information Unit iuCRC error") },
-/* DTLPWRSOMCAE */{SST(0x47, 0x04, SS_RDEF|SSQ_FALLBACK,
-			"Asynchronous information protection error detected") },
-/* DTLPWRSOMCAE */{SST(0x47, 0x05, SS_RDEF|SSQ_FALLBACK,
-			"Protocol server CRC error") },
-/* DTLPWRSOMCAE */{SST(0x48, 0x00, SS_RDEF|SSQ_FALLBACK,
-			"Initiator detected error message received") },
-/* DTLPWRSOMCAE */{SST(0x49, 0x00, SS_RDEF,
-			"Invalid message error") },
-/* DTLPWRSOMCAE */{SST(0x4A, 0x00, SS_RDEF,
-			"Command phase error") },
-/* DTLPWRSOMCAE */{SST(0x4B, 0x00, SS_RDEF,
-			"Data phase error") },
-/* DTLPWRSOMCAE */{SST(0x4C, 0x00, SS_RDEF,
-			"Logical unit failed self-configuration") },
-/* DTLPWRSOMCAE */{SST(0x4D, 0x00, SS_RDEF,
-			"Tagged overlapped commands: ASCQ = Queue tag ID") },
-/* DTLPWRSOMCAE */{SST(0x4D, 0xFF, SS_RDEF|SSQ_RANGE,
-			NULL)}, /* Range 0x00->0xFF */
-/* DTLPWRSOMCAE */{SST(0x4E, 0x00, SS_RDEF,
-			"Overlapped commands attempted") },
-/*  T           */{SST(0x50, 0x00, SS_RDEF,
-			"Write append error") },
-/*  T           */{SST(0x50, 0x01, SS_RDEF,
-			"Write append position error") },
-/*  T           */{SST(0x50, 0x02, SS_RDEF,
-			"Position error related to timing") },
-/*  T     O     */{SST(0x51, 0x00, SS_RDEF,
-			"Erase failure") },
-/*  T           */{SST(0x52, 0x00, SS_RDEF,
-			"Cartridge fault") },
-/* DTL WRSOM    */{SST(0x53, 0x00, SS_RDEF,
-			"Media load or eject failed") },
-/*  T           */{SST(0x53, 0x01, SS_RDEF,
-			"Unload tape failure") },
-/* DT  WR OM    */{SST(0x53, 0x02, SS_RDEF,
-			"Medium removal prevented") },
-/*    P         */{SST(0x54, 0x00, SS_RDEF,
-			"Scsi to host system interface failure") },
-/*    P         */{SST(0x55, 0x00, SS_RDEF,
-			"System resource failure") },
-/* D      O     */{SST(0x55, 0x01, SS_FATAL|ENOSPC,
-			"System buffer full") },
-/*      R       */{SST(0x57, 0x00, SS_RDEF,
-			"Unable to recover table-of-contents") },
-/*        O     */{SST(0x58, 0x00, SS_RDEF,
-			"Generation does not exist") },
-/*        O     */{SST(0x59, 0x00, SS_RDEF,
-			"Updated block read") },
-/* DTLPWRSOM    */{SST(0x5A, 0x00, SS_RDEF,
-			"Operator request or state change input") },
-/* DT  WR OM    */{SST(0x5A, 0x01, SS_RDEF,
-			"Operator medium removal request") },
-/* DT  W  O     */{SST(0x5A, 0x02, SS_RDEF,
-			"Operator selected write protect") },
-/* DT  W  O     */{SST(0x5A, 0x03, SS_RDEF,
-			"Operator selected write permit") },
-/* DTLPWRSOM    */{SST(0x5B, 0x00, SS_RDEF,
-			"Log exception") },
-/* DTLPWRSOM    */{SST(0x5B, 0x01, SS_RDEF,
-			"Threshold condition met") },
-/* DTLPWRSOM    */{SST(0x5B, 0x02, SS_RDEF,
-			"Log counter at maximum") },
-/* DTLPWRSOM    */{SST(0x5B, 0x03, SS_RDEF,
-			"Log list codes exhausted") },
-/* D      O     */{SST(0x5C, 0x00, SS_RDEF,
-			"RPL status change") },
-/* D      O     */{SST(0x5C, 0x01, SS_NOP|SSQ_PRINT_SENSE,
-			"Spindles synchronized") },
-/* D      O     */{SST(0x5C, 0x02, SS_RDEF,
-			"Spindles not synchronized") },
-/* DTLPWRSOMCAE */{SST(0x5D, 0x00, SS_RDEF,
-			"Failure prediction threshold exceeded") },
-/* DTLPWRSOMCAE */{SST(0x5D, 0xFF, SS_RDEF,
-			"Failure prediction threshold exceeded (false)") },
-/* DTLPWRSO CA  */{SST(0x5E, 0x00, SS_RDEF,
-			"Low power condition on") },
-/* DTLPWRSO CA  */{SST(0x5E, 0x01, SS_RDEF,
-			"Idle condition activated by timer") },
-/* DTLPWRSO CA  */{SST(0x5E, 0x02, SS_RDEF,
-			"Standby condition activated by timer") },
-/* DTLPWRSO CA  */{SST(0x5E, 0x03, SS_RDEF,
-			"Idle condition activated by command") },
-/* DTLPWRSO CA  */{SST(0x5E, 0x04, SS_RDEF,
-			"Standby condition activated by command") },
-/*       S      */{SST(0x60, 0x00, SS_RDEF,
-			"Lamp failure") },
-/*       S      */{SST(0x61, 0x00, SS_RDEF,
-			"Video acquisition error") },
-/*       S      */{SST(0x61, 0x01, SS_RDEF,
-			"Unable to acquire video") },
-/*       S      */{SST(0x61, 0x02, SS_RDEF,
-			"Out of focus") },
-/*       S      */{SST(0x62, 0x00, SS_RDEF,
-			"Scan head positioning error") },
-/*      R       */{SST(0x63, 0x00, SS_RDEF,
-			"End of user area encountered on this track") },
-/*      R       */{SST(0x63, 0x01, SS_FATAL|ENOSPC,
-			"Packet does not fit in available space") },
-/*      R       */{SST(0x64, 0x00, SS_RDEF,
-			"Illegal mode for this track") },
-/*      R       */{SST(0x64, 0x01, SS_RDEF,
-			"Invalid packet size") },
-/* DTLPWRSOMCAE */{SST(0x65, 0x00, SS_RDEF,
-			"Voltage fault") },
-/*       S      */{SST(0x66, 0x00, SS_RDEF,
-			"Automatic document feeder cover up") },
-/*       S      */{SST(0x66, 0x01, SS_RDEF,
-			"Automatic document feeder lift up") },
-/*       S      */{SST(0x66, 0x02, SS_RDEF,
-			"Document jam in automatic document feeder") },
-/*       S      */{SST(0x66, 0x03, SS_RDEF,
-			"Document miss feed automatic in document feeder") },
-/*           A  */{SST(0x67, 0x00, SS_RDEF,
-			"Configuration failure") },
-/*           A  */{SST(0x67, 0x01, SS_RDEF,
-			"Configuration of incapable logical units failed") },
-/*           A  */{SST(0x67, 0x02, SS_RDEF,
-			"Add logical unit failed") },
-/*           A  */{SST(0x67, 0x03, SS_RDEF,
-			"Modification of logical unit failed") },
-/*           A  */{SST(0x67, 0x04, SS_RDEF,
-			"Exchange of logical unit failed") },
-/*           A  */{SST(0x67, 0x05, SS_RDEF,
-			"Remove of logical unit failed") },
-/*           A  */{SST(0x67, 0x06, SS_RDEF,
-			"Attachment of logical unit failed") },
-/*           A  */{SST(0x67, 0x07, SS_RDEF,
-			"Creation of logical unit failed") },
-/*           A  */{SST(0x68, 0x00, SS_RDEF,
-			"Logical unit not configured") },
-/*           A  */{SST(0x69, 0x00, SS_RDEF,
-			"Data loss on logical unit") },
-/*           A  */{SST(0x69, 0x01, SS_RDEF,
-			"Multiple logical unit failures") },
-/*           A  */{SST(0x69, 0x02, SS_RDEF,
-			"Parity/data mismatch") },
-/*           A  */{SST(0x6A, 0x00, SS_RDEF,
-			"Informational, refer to log") },
-/*           A  */{SST(0x6B, 0x00, SS_RDEF,
-			"State change has occurred") },
-/*           A  */{SST(0x6B, 0x01, SS_RDEF,
-			"Redundancy level got better") },
-/*           A  */{SST(0x6B, 0x02, SS_RDEF,
-			"Redundancy level got worse") },
-/*           A  */{SST(0x6C, 0x00, SS_RDEF,
-			"Rebuild failure occurred") },
-/*           A  */{SST(0x6D, 0x00, SS_RDEF,
-			"Recalculate failure occurred") },
-/*           A  */{SST(0x6E, 0x00, SS_RDEF,
-			"Command to logical unit failed") },
-/*  T           */{SST(0x70, 0x00, SS_RDEF,
-			"Decompression exception short: ASCQ = Algorithm ID") },
-/*  T           */{SST(0x70, 0xFF, SS_RDEF|SSQ_RANGE,
-			NULL) }, /* Range 0x00 -> 0xFF */
-/*  T           */{SST(0x71, 0x00, SS_RDEF,
-			"Decompression exception long: ASCQ = Algorithm ID") },
-/*  T           */{SST(0x71, 0xFF, SS_RDEF|SSQ_RANGE,
-			NULL) }, /* Range 0x00 -> 0xFF */	
-/*      R       */{SST(0x72, 0x00, SS_RDEF,
-			"Session fixation error") },
-/*      R       */{SST(0x72, 0x01, SS_RDEF,
-			"Session fixation error writing lead-in") },
-/*      R       */{SST(0x72, 0x02, SS_RDEF,
-			"Session fixation error writing lead-out") },
-/*      R       */{SST(0x72, 0x03, SS_RDEF,
-			"Session fixation error - incomplete track in session") },
-/*      R       */{SST(0x72, 0x04, SS_RDEF,
-			"Empty or partially written reserved track") },
-/*      R       */{SST(0x73, 0x00, SS_RDEF,
-			"CD control error") },
-/*      R       */{SST(0x73, 0x01, SS_RDEF,
-			"Power calibration area almost full") },
-/*      R       */{SST(0x73, 0x02, SS_FATAL|ENOSPC,
-			"Power calibration area is full") },
-/*      R       */{SST(0x73, 0x03, SS_RDEF,
-			"Power calibration area error") },
-/*      R       */{SST(0x73, 0x04, SS_RDEF,
-			"Program memory area update failure") },
-/*      R       */{SST(0x73, 0x05, SS_RDEF,
-			"program memory area is full") }
-};
-
-static const int asc_table_size = sizeof(asc_table)/sizeof(asc_table[0]);
-
-struct asc_key
-{
-	int asc;
-	int ascq;
-};
-
-static int
-ascentrycomp(const void *key, const void *member)
-{
-	int asc;
-	int ascq;
-	const struct asc_table_entry *table_entry;
-
-	asc = ((const struct asc_key *)key)->asc;
-	ascq = ((const struct asc_key *)key)->ascq;
-	table_entry = (const struct asc_table_entry *)member;
-
-	if (asc >= table_entry->asc) {
-
-		if (asc > table_entry->asc)
-			return (1);
-
-		if (ascq <= table_entry->ascq) {
-			/* Check for ranges */
-			if (ascq == table_entry->ascq
-		 	 || ((table_entry->action & SSQ_RANGE) != 0
-		  	   && ascq >= (table_entry - 1)->ascq))
-				return (0);
-			return (-1);
-		}
-		return (1);
-	}
-	return (-1);
-}
-
-static int
-senseentrycomp(const void *key, const void *member)
-{
-	int sense_key;
-	const struct sense_key_table_entry *table_entry;
-
-	sense_key = *((const int *)key);
-	table_entry = (const struct sense_key_table_entry *)member;
-
-	if (sense_key >= table_entry->sense_key) {
-		if (sense_key == table_entry->sense_key)
-			return (0);
-		return (1);
-	}
-	return (-1);
-}
-
-static void
-fetchtableentries(int sense_key, int asc, int ascq,
-		  struct scsi_inquiry_data *inq_data,
-		  const struct sense_key_table_entry **sense_entry,
-		  const struct asc_table_entry **asc_entry)
-{
-	void *match;
-	const struct asc_table_entry *asc_tables[2];
-	const struct sense_key_table_entry *sense_tables[2];
-	struct asc_key asc_ascq;
-	size_t asc_tables_size[2];
-	size_t sense_tables_size[2];
-	int num_asc_tables;
-	int num_sense_tables;
-	int i;
-
-	/* Default to failure */
-	*sense_entry = NULL;
-	*asc_entry = NULL;
-	match = NULL;
-	if (inq_data != NULL)
-		match = cam_quirkmatch((void *)inq_data,
-				       (void *)sense_quirk_table,
-				       sense_quirk_table_size,
-				       sizeof(*sense_quirk_table),
-				       aic_inquiry_match);
-
-	if (match != NULL) {
-		struct scsi_sense_quirk_entry *quirk;
-
-		quirk = (struct scsi_sense_quirk_entry *)match;
-		asc_tables[0] = quirk->asc_info;
-		asc_tables_size[0] = quirk->num_ascs;
-		asc_tables[1] = asc_table;
-		asc_tables_size[1] = asc_table_size;
-		num_asc_tables = 2;
-		sense_tables[0] = quirk->sense_key_info;
-		sense_tables_size[0] = quirk->num_sense_keys;
-		sense_tables[1] = sense_key_table;
-		sense_tables_size[1] = sense_key_table_size;
-		num_sense_tables = 2;
-	} else {
-		asc_tables[0] = asc_table;
-		asc_tables_size[0] = asc_table_size;
-		num_asc_tables = 1;
-		sense_tables[0] = sense_key_table;
-		sense_tables_size[0] = sense_key_table_size;
-		num_sense_tables = 1;
-	}
-
-	asc_ascq.asc = asc;
-	asc_ascq.ascq = ascq;
-	for (i = 0; i < num_asc_tables; i++) {
-		void *found_entry;
-
-		found_entry = scsibsearch(&asc_ascq, asc_tables[i],
-					  asc_tables_size[i],
-					  sizeof(**asc_tables),
-					  ascentrycomp);
-
-		if (found_entry) {
-			*asc_entry = (struct asc_table_entry *)found_entry;
-			break;
-		}
-	}
-
-	for (i = 0; i < num_sense_tables; i++) {
-		void *found_entry;
-
-		found_entry = scsibsearch(&sense_key, sense_tables[i],
-					  sense_tables_size[i],
-					  sizeof(**sense_tables),
-					  senseentrycomp);
-
-		if (found_entry) {
-			*sense_entry =
-			    (struct sense_key_table_entry *)found_entry;
-			break;
-		}
-	}
-}
-
-static void *
-scsibsearch(const void *key, const void *base, size_t nmemb, size_t size,
-		 int (*compar)(const void *, const void *))
-{
-	const void *entry;
-	u_int l;
-	u_int u;
-	u_int m;
-
-	l = -1;
-	u = nmemb;
-	while (l + 1 != u) {
-		m = (l + u) / 2;
-		entry = base + m * size;
-		if (compar(key, entry) > 0)
-			l = m;
-		else
-			u = m;
-	}
-
-	entry = base + u * size;
-	if (u == nmemb
-	 || compar(key, entry) != 0)
-		return (NULL);
-
-	return ((void *)entry);
-}
-
-/*
- * Compare string with pattern, returning 0 on match.
- * Short pattern matches trailing blanks in name,
- * wildcard '*' in pattern matches rest of name,
- * wildcard '?' matches a single non-space character.
- */
-static int
-cam_strmatch(const uint8_t *str, const uint8_t *pattern, int str_len)
-{
-
-	while (*pattern != '\0'&& str_len > 0) {  
-
-		if (*pattern == '*') {
-			return (0);
-		}
-		if ((*pattern != *str)
-		 && (*pattern != '?' || *str == ' ')) {
-			return (1);
-		}
-		pattern++;
-		str++;
-		str_len--;
-	}
-	while (str_len > 0 && *str++ == ' ')
-		str_len--;
-
-	return (str_len);
-}
-
-static caddr_t
-cam_quirkmatch(caddr_t target, caddr_t quirk_table, int num_entries,
-	       int entry_size, cam_quirkmatch_t *comp_func)
-{
-	for (; num_entries > 0; num_entries--, quirk_table += entry_size) {
-		if ((*comp_func)(target, quirk_table) == 0)
-			return (quirk_table);
-	}
-	return (NULL);
-}
-
-void
-aic_sense_desc(int sense_key, int asc, int ascq,
-	       struct scsi_inquiry_data *inq_data,
-	       const char **sense_key_desc, const char **asc_desc)
-{
-	const struct asc_table_entry *asc_entry;
-	const struct sense_key_table_entry *sense_entry;
-
-	fetchtableentries(sense_key, asc, ascq,
-			  inq_data,
-			  &sense_entry,
-			  &asc_entry);
-
-	*sense_key_desc = sense_entry->desc;
-
-	if (asc_entry != NULL)
-		*asc_desc = asc_entry->desc;
-	else if (asc >= 0x80 && asc <= 0xff)
-		*asc_desc = "Vendor Specific ASC";
-	else if (ascq >= 0x80 && ascq <= 0xff)
-		*asc_desc = "Vendor Specific ASCQ";
-	else
-		*asc_desc = "Reserved ASC/ASCQ pair";
-}
-
-/*
- * Given sense and device type information, return the appropriate action.
- * If we do not understand the specific error as identified by the ASC/ASCQ
- * pair, fall back on the more generic actions derived from the sense key.
- */
-aic_sense_action
-aic_sense_error_action(struct scsi_sense_data *sense_data,
-		       struct scsi_inquiry_data *inq_data, uint32_t sense_flags)
-{
-	const struct asc_table_entry *asc_entry;
-	const struct sense_key_table_entry *sense_entry;
-	int error_code, sense_key, asc, ascq;
-	aic_sense_action action;
-
-	scsi_extract_sense(sense_data, &error_code, &sense_key, &asc, &ascq);
-
-	if (error_code == SSD_DEFERRED_ERROR) {
-		/*
-		 * XXX dufault@FreeBSD.org
-		 * This error doesn't relate to the command associated
-		 * with this request sense.  A deferred error is an error
-		 * for a command that has already returned GOOD status
-		 * (see SCSI2 8.2.14.2).
-		 *
-		 * By my reading of that section, it looks like the current
-		 * command has been cancelled, we should now clean things up
-		 * (hopefully recovering any lost data) and then retry the
-		 * current command.  There are two easy choices, both wrong:
-		 *
-		 * 1. Drop through (like we had been doing), thus treating
-		 *    this as if the error were for the current command and
-		 *    return and stop the current command.
-		 * 
-		 * 2. Issue a retry (like I made it do) thus hopefully
-		 *    recovering the current transfer, and ignoring the
-		 *    fact that we've dropped a command.
-		 *
-		 * These should probably be handled in a device specific
-		 * sense handler or punted back up to a user mode daemon
-		 */
-		action = SS_RETRY|SSQ_DECREMENT_COUNT|SSQ_PRINT_SENSE;
-	} else {
-		fetchtableentries(sense_key, asc, ascq,
-				  inq_data,
-				  &sense_entry,
-				  &asc_entry);
-
-		/*
-		 * Override the 'No additional Sense' entry (0,0)
-		 * with the error action of the sense key.
-		 */
-		if (asc_entry != NULL
-		 && (asc != 0 || ascq != 0))
-			action = asc_entry->action;
-		else
-			action = sense_entry->action;
-
-		if (sense_key == SSD_KEY_RECOVERED_ERROR) {
-			/*
-			 * The action succeeded but the device wants
-			 * the user to know that some recovery action
-			 * was required.
-			 */
-			action &= ~(SS_MASK|SSQ_MASK|SS_ERRMASK);
-			action |= SS_NOP|SSQ_PRINT_SENSE;
-		} else if (sense_key == SSD_KEY_ILLEGAL_REQUEST) {
-			if ((sense_flags & SF_QUIET_IR) != 0)
-				action &= ~SSQ_PRINT_SENSE;
-		} else if (sense_key == SSD_KEY_UNIT_ATTENTION) {
-			if ((sense_flags & SF_RETRY_UA) != 0
-			 && (action & SS_MASK) == SS_FAIL) {
-				action &= ~(SS_MASK|SSQ_MASK);
-				action |= SS_RETRY|SSQ_DECREMENT_COUNT|
-					  SSQ_PRINT_SENSE;
-			}
-		}
-	}
-
-	if ((sense_flags & SF_PRINT_ALWAYS) != 0)
-		action |= SSQ_PRINT_SENSE;
-	else if ((sense_flags & SF_NO_PRINT) != 0)
-		action &= ~SSQ_PRINT_SENSE;
-
-	return (action);
-}
-
-/*      
- * Try make as good a match as possible with
- * available sub drivers
- */
-int
-aic_inquiry_match(caddr_t inqbuffer, caddr_t table_entry)
-{
-	struct scsi_inquiry_pattern *entry;
-	struct scsi_inquiry_data *inq;
- 
-	entry = (struct scsi_inquiry_pattern *)table_entry;
-	inq = (struct scsi_inquiry_data *)inqbuffer;
-
-	if (((SID_TYPE(inq) == entry->type)
-	  || (entry->type == T_ANY))
-	 && (SID_IS_REMOVABLE(inq) ? entry->media_type & SIP_MEDIA_REMOVABLE
-				   : entry->media_type & SIP_MEDIA_FIXED)
-	 && (cam_strmatch(inq->vendor, entry->vendor, sizeof(inq->vendor)) == 0)
-	 && (cam_strmatch(inq->product, entry->product,
-			  sizeof(inq->product)) == 0)
-	 && (cam_strmatch(inq->revision, entry->revision,
-			  sizeof(inq->revision)) == 0)) {
-		return (0);
-	}
-        return (-1);
-}
-
-/*
- * Table of syncrates that don't follow the "divisible by 4"
- * rule. This table will be expanded in future SCSI specs.
- */
-static struct {
-	u_int period_factor;
-	u_int period;	/* in 100ths of ns */
-} scsi_syncrates[] = {
-	{ 0x08, 625 },	/* FAST-160 */
-	{ 0x09, 1250 },	/* FAST-80 */
-	{ 0x0a, 2500 },	/* FAST-40 40MHz */
-	{ 0x0b, 3030 },	/* FAST-40 33MHz */
-	{ 0x0c, 5000 }	/* FAST-20 */
-};
-
-/*
- * Return the frequency in kHz corresponding to the given
- * sync period factor.
- */
-u_int
-aic_calc_syncsrate(u_int period_factor)
-{
-	int i;
-	int num_syncrates;
-
-	num_syncrates = sizeof(scsi_syncrates) / sizeof(scsi_syncrates[0]);
-	/* See if the period is in the "exception" table */
-	for (i = 0; i < num_syncrates; i++) {
-
-		if (period_factor == scsi_syncrates[i].period_factor) {
-			/* Period in kHz */
-			return (100000000 / scsi_syncrates[i].period);
-		}
-	}
-
-	/*
-	 * Wasn't in the table, so use the standard
-	 * 4 times conversion.
-	 */
-	return (10000000 / (period_factor * 4 * 10));
-}
-
-/*
- * Return speed in KB/s.
- */
-u_int
-aic_calc_speed(u_int width, u_int period, u_int offset, u_int min_rate)
-{
-	u_int freq;
-
-	if (offset != 0 && period < min_rate)
-		freq  = aic_calc_syncsrate(period);
-	else
-		/* Roughly 3.3MB/s for async */
-		freq  = 3300;
-	freq <<= width;
-	return (freq);
-}
-
-uint32_t
-aic_error_action(struct scsi_cmnd *cmd, struct scsi_inquiry_data *inq_data,
-		 cam_status status, u_int scsi_status)
-{
-	aic_sense_action  err_action;
-	int		  sense;
-
-	sense  = (cmd->result >> 24) == DRIVER_SENSE;
-
-	switch (status) {
-	case CAM_REQ_CMP:
-		err_action = SS_NOP;
-		break;
-	case CAM_AUTOSENSE_FAIL:
-	case CAM_SCSI_STATUS_ERROR:
-
-		switch (scsi_status) {
-		case SCSI_STATUS_OK:
-		case SCSI_STATUS_COND_MET:
-		case SCSI_STATUS_INTERMED:
-		case SCSI_STATUS_INTERMED_COND_MET:
-			err_action = SS_NOP;
-			break;
-		case SCSI_STATUS_CMD_TERMINATED:
-		case SCSI_STATUS_CHECK_COND:
-			if (sense != 0) {
-				struct scsi_sense_data *sense;
-
-				sense = (struct scsi_sense_data *)
-				    &cmd->sense_buffer;
-				err_action =
-				    aic_sense_error_action(sense, inq_data, 0);
-
-			} else {
-				err_action = SS_RETRY|SSQ_FALLBACK
-					   | SSQ_DECREMENT_COUNT|EIO;
-			}
-			break;
-		case SCSI_STATUS_QUEUE_FULL:
-		case SCSI_STATUS_BUSY:
-			err_action = SS_RETRY|SSQ_DELAY|SSQ_MANY
-				   | SSQ_DECREMENT_COUNT|EBUSY;
-			break;
-		case SCSI_STATUS_RESERV_CONFLICT:
-		default:
-			err_action = SS_FAIL|EBUSY;
-			break;
-		}
-		break;
-	case CAM_CMD_TIMEOUT:
-	case CAM_REQ_CMP_ERR:
-	case CAM_UNEXP_BUSFREE:
-	case CAM_UNCOR_PARITY:
-	case CAM_DATA_RUN_ERR:
-		err_action = SS_RETRY|SSQ_FALLBACK|EIO;
-		break;
-	case CAM_UA_ABORT:
-	case CAM_UA_TERMIO:
-	case CAM_MSG_REJECT_REC:
-	case CAM_SEL_TIMEOUT:
-		err_action = SS_FAIL|EIO;
-		break;
-	case CAM_REQ_INVALID:
-	case CAM_PATH_INVALID:
-	case CAM_DEV_NOT_THERE:
-	case CAM_NO_HBA:
-	case CAM_PROVIDE_FAIL:
-	case CAM_REQ_TOO_BIG:		
-	case CAM_RESRC_UNAVAIL:
-	case CAM_BUSY:
-	default:
-		/* panic??  These should never occur in our application. */
-		err_action = SS_FAIL|EIO;
-		break;
-	case CAM_SCSI_BUS_RESET:
-	case CAM_BDR_SENT:		
-	case CAM_REQUEUE_REQ:
-		/* Unconditional requeue */
-		err_action = SS_RETRY;
-		break;
-	}
-
-	return (err_action);
-}
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/aiclib.h linux-2.4.22-pre2/drivers/scsi/aic79xx/aiclib.h
--- linux-2.4.21/drivers/scsi/aic79xx/aiclib.h	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/aiclib.h	2003-06-26 21:43:14.000000000 +0000
@@ -1,1001 +0,0 @@
-/*
- * Largely written by Julian Elischer (julian@tfs.com)
- * for TRW Financial Systems.
- *
- * TRW Financial Systems, in accordance with their agreement with Carnegie
- * Mellon University, makes this software available to CMU to distribute
- * or use in any manner that they see fit as long as this message is kept with
- * the software. For this reason TFS also grants any other persons or
- * organisations permission to use or modify this software.
- *
- * TFS supplies this software to be publicly redistributed
- * on the understanding that TFS is not responsible for the correct
- * functioning of this software in any circumstances.
- *
- * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
- *
- * $FreeBSD: src/sys/cam/scsi/scsi_all.h,v 1.21 2002/10/08 17:12:44 ken Exp $
- * $Id$
- */
-
-/*
- * SCSI general  interface description
- */
-
-#ifndef	_SCSI_SCSI_ALL_H
-#define _SCSI_SCSI_ALL_H 1
-
-/*
- * SCSI command format
- */
-
-/*
- * Define dome bits that are in ALL (or a lot of) scsi commands
- */
-#define SCSI_CTL_LINK		0x01
-#define SCSI_CTL_FLAG		0x02
-#define SCSI_CTL_VENDOR		0xC0
-#define	SCSI_CMD_LUN		0xA0	/* these two should not be needed */
-#define	SCSI_CMD_LUN_SHIFT	5	/* LUN in the cmd is no longer SCSI */
-
-#define SCSI_MAX_CDBLEN		16	/* 
-					 * 16 byte commands are in the 
-					 * SCSI-3 spec 
-					 */
-/* 6byte CDBs special case 0 length to be 256 */
-#define SCSI_CDB6_LEN(len)	((len) == 0 ? 256 : len)
-
-/*
- * This type defines actions to be taken when a particular sense code is
- * received.  Right now, these flags are only defined to take up 16 bits,
- * but can be expanded in the future if necessary.
- */
-typedef enum {
-	SS_NOP		= 0x000000, /* Do nothing */
-	SS_RETRY	= 0x010000, /* Retry the command */
-	SS_FAIL		= 0x020000, /* Bail out */
-	SS_START	= 0x030000, /* Send a Start Unit command to the device,
-				     * then retry the original command.
-				     */
-	SS_TUR		= 0x040000, /* Send a Test Unit Ready command to the
-				     * device, then retry the original command.
-				     */
-	SS_REQSENSE	= 0x050000, /* Send a RequestSense command to the
-				     * device, then retry the original command.
-				     */
-	SS_INQ_REFRESH	= 0x060000,
-	SS_MASK		= 0xff0000
-} aic_sense_action;
-
-typedef enum {
-	SSQ_NONE		= 0x0000,
-	SSQ_DECREMENT_COUNT	= 0x0100,  /* Decrement the retry count */
-	SSQ_MANY		= 0x0200,  /* send lots of recovery commands */
-	SSQ_RANGE		= 0x0400,  /*
-					    * This table entry represents the
-					    * end of a range of ASCQs that
-					    * have identical error actions
-					    * and text.
-					    */
-	SSQ_PRINT_SENSE		= 0x0800,
-	SSQ_DELAY		= 0x1000,  /* Delay before retry. */
-	SSQ_DELAY_RANDOM	= 0x2000,  /* Randomized delay before retry. */
-	SSQ_FALLBACK		= 0x4000,  /* Do a speed fallback to recover */
-	SSQ_MASK		= 0xff00
-} aic_sense_action_qualifier;
-
-/* Mask for error status values */
-#define SS_ERRMASK	0xff
-
-/* The default, retyable, error action */
-#define SS_RDEF		SS_RETRY|SSQ_DECREMENT_COUNT|SSQ_PRINT_SENSE|EIO
-
-/* The retyable, error action, with table specified error code */
-#define SS_RET		SS_RETRY|SSQ_DECREMENT_COUNT|SSQ_PRINT_SENSE
-
-/* Fatal error action, with table specified error code */
-#define SS_FATAL	SS_FAIL|SSQ_PRINT_SENSE
-
-struct scsi_generic
-{
-	uint8_t opcode;
-	uint8_t bytes[11];
-};
-
-struct scsi_request_sense
-{
-	uint8_t opcode;
-	uint8_t byte2;
-	uint8_t unused[2];
-	uint8_t length;
-	uint8_t control;
-};
-
-struct scsi_test_unit_ready
-{
-	uint8_t opcode;
-	uint8_t byte2;
-	uint8_t unused[3];
-	uint8_t control;
-};
-
-struct scsi_send_diag
-{
-	uint8_t opcode;
-	uint8_t byte2;
-#define	SSD_UOL		0x01
-#define	SSD_DOL		0x02
-#define	SSD_SELFTEST	0x04
-#define	SSD_PF		0x10
-	uint8_t unused[1];
-	uint8_t paramlen[2];
-	uint8_t control;
-};
-
-struct scsi_sense
-{
-	uint8_t opcode;
-	uint8_t byte2;
-	uint8_t unused[2];
-	uint8_t length;
-	uint8_t control;
-};
-
-struct scsi_inquiry
-{
-	uint8_t opcode;
-	uint8_t byte2;
-#define	SI_EVPD 0x01
-	uint8_t page_code;
-	uint8_t reserved;
-	uint8_t length;
-	uint8_t control;
-};
-
-struct scsi_mode_sense_6
-{
-	uint8_t opcode;
-	uint8_t byte2;
-#define	SMS_DBD				0x08
-	uint8_t page;
-#define	SMS_PAGE_CODE 			0x3F
-#define SMS_VENDOR_SPECIFIC_PAGE	0x00
-#define SMS_DISCONNECT_RECONNECT_PAGE	0x02
-#define SMS_PERIPHERAL_DEVICE_PAGE	0x09
-#define SMS_CONTROL_MODE_PAGE		0x0A
-#define SMS_ALL_PAGES_PAGE		0x3F
-#define	SMS_PAGE_CTRL_MASK		0xC0
-#define	SMS_PAGE_CTRL_CURRENT 		0x00
-#define	SMS_PAGE_CTRL_CHANGEABLE 	0x40
-#define	SMS_PAGE_CTRL_DEFAULT 		0x80
-#define	SMS_PAGE_CTRL_SAVED 		0xC0
-	uint8_t unused;
-	uint8_t length;
-	uint8_t control;
-};
-
-struct scsi_mode_sense_10
-{
-	uint8_t opcode;
-	uint8_t byte2;		/* same bits as small version */
-	uint8_t page; 		/* same bits as small version */
-	uint8_t unused[4];
-	uint8_t length[2];
-	uint8_t control;
-};
-
-struct scsi_mode_select_6
-{
-	uint8_t opcode;
-	uint8_t byte2;
-#define	SMS_SP	0x01
-#define	SMS_PF	0x10
-	uint8_t unused[2];
-	uint8_t length;
-	uint8_t control;
-};
-
-struct scsi_mode_select_10
-{
-	uint8_t opcode;
-	uint8_t byte2;		/* same bits as small version */
-	uint8_t unused[5];
-	uint8_t length[2];
-	uint8_t control;
-};
-
-/*
- * When sending a mode select to a tape drive, the medium type must be 0.
- */
-struct scsi_mode_hdr_6
-{
-	uint8_t datalen;
-	uint8_t medium_type;
-	uint8_t dev_specific;
-	uint8_t block_descr_len;
-};
-
-struct scsi_mode_hdr_10
-{
-	uint8_t datalen[2];
-	uint8_t medium_type;
-	uint8_t dev_specific;
-	uint8_t reserved[2];
-	uint8_t block_descr_len[2];
-};
-
-struct scsi_mode_block_descr
-{
-	uint8_t density_code;
-	uint8_t num_blocks[3];
-	uint8_t reserved;
-	uint8_t block_len[3];
-};
-
-struct scsi_log_sense
-{
-	uint8_t opcode;
-	uint8_t byte2;
-#define	SLS_SP				0x01
-#define	SLS_PPC				0x02
-	uint8_t page;
-#define	SLS_PAGE_CODE 			0x3F
-#define	SLS_ALL_PAGES_PAGE		0x00
-#define	SLS_OVERRUN_PAGE		0x01
-#define	SLS_ERROR_WRITE_PAGE		0x02
-#define	SLS_ERROR_READ_PAGE		0x03
-#define	SLS_ERROR_READREVERSE_PAGE	0x04
-#define	SLS_ERROR_VERIFY_PAGE		0x05
-#define	SLS_ERROR_NONMEDIUM_PAGE	0x06
-#define	SLS_ERROR_LASTN_PAGE		0x07
-#define	SLS_PAGE_CTRL_MASK		0xC0
-#define	SLS_PAGE_CTRL_THRESHOLD		0x00
-#define	SLS_PAGE_CTRL_CUMULATIVE	0x40
-#define	SLS_PAGE_CTRL_THRESH_DEFAULT	0x80
-#define	SLS_PAGE_CTRL_CUMUL_DEFAULT	0xC0
-	uint8_t reserved[2];
-	uint8_t paramptr[2];
-	uint8_t length[2];
-	uint8_t control;
-};
-
-struct scsi_log_select
-{
-	uint8_t opcode;
-	uint8_t byte2;
-/*	SLS_SP				0x01 */
-#define	SLS_PCR				0x02
-	uint8_t page;
-/*	SLS_PAGE_CTRL_MASK		0xC0 */
-/*	SLS_PAGE_CTRL_THRESHOLD		0x00 */
-/*	SLS_PAGE_CTRL_CUMULATIVE	0x40 */
-/*	SLS_PAGE_CTRL_THRESH_DEFAULT	0x80 */
-/*	SLS_PAGE_CTRL_CUMUL_DEFAULT	0xC0 */
-	uint8_t reserved[4];
-	uint8_t length[2];
-	uint8_t control;
-};
-
-struct scsi_log_header
-{
-	uint8_t page;
-	uint8_t reserved;
-	uint8_t datalen[2];
-};
-
-struct scsi_log_param_header {
-	uint8_t param_code[2];
-	uint8_t param_control;
-#define	SLP_LP				0x01
-#define	SLP_LBIN			0x02
-#define	SLP_TMC_MASK			0x0C
-#define	SLP_TMC_ALWAYS			0x00
-#define	SLP_TMC_EQUAL			0x04
-#define	SLP_TMC_NOTEQUAL		0x08
-#define	SLP_TMC_GREATER			0x0C
-#define	SLP_ETC				0x10
-#define	SLP_TSD				0x20
-#define	SLP_DS				0x40
-#define	SLP_DU				0x80
-	uint8_t param_len;
-};
-
-struct scsi_control_page {
-	uint8_t page_code;
-	uint8_t page_length;
-	uint8_t rlec;
-#define SCB_RLEC			0x01	/*Report Log Exception Cond*/
-	uint8_t queue_flags;
-#define SCP_QUEUE_ALG_MASK		0xF0
-#define SCP_QUEUE_ALG_RESTRICTED	0x00
-#define SCP_QUEUE_ALG_UNRESTRICTED	0x10
-#define SCP_QUEUE_ERR			0x02	/*Queued I/O aborted for CACs*/
-#define SCP_QUEUE_DQUE			0x01	/*Queued I/O disabled*/
-	uint8_t eca_and_aen;
-#define SCP_EECA			0x80	/*Enable Extended CA*/
-#define SCP_RAENP			0x04	/*Ready AEN Permission*/
-#define SCP_UAAENP			0x02	/*UA AEN Permission*/
-#define SCP_EAENP			0x01	/*Error AEN Permission*/
-	uint8_t reserved;
-	uint8_t aen_holdoff_period[2];
-};
-
-struct scsi_reserve
-{
-	uint8_t opcode;
-	uint8_t byte2;
-	uint8_t unused[2];
-	uint8_t length;
-	uint8_t control;
-};
-
-struct scsi_release
-{
-	uint8_t opcode;
-	uint8_t byte2;
-	uint8_t unused[2];
-	uint8_t length;
-	uint8_t control;
-};
-
-struct scsi_prevent
-{
-	uint8_t opcode;
-	uint8_t byte2;
-	uint8_t unused[2];
-	uint8_t how;
-	uint8_t control;
-};
-#define	PR_PREVENT 0x01
-#define PR_ALLOW   0x00
-
-struct scsi_sync_cache
-{
-	uint8_t opcode;
-	uint8_t byte2;
-	uint8_t begin_lba[4];
-	uint8_t reserved;
-	uint8_t lb_count[2];
-	uint8_t control;	
-};
-
-
-struct scsi_changedef
-{
-	uint8_t opcode;
-	uint8_t byte2;
-	uint8_t unused1;
-	uint8_t how;
-	uint8_t unused[4];
-	uint8_t datalen;
-	uint8_t control;
-};
-
-struct scsi_read_buffer
-{
-	uint8_t opcode;
-	uint8_t byte2;
-#define	RWB_MODE		0x07
-#define	RWB_MODE_HDR_DATA	0x00
-#define	RWB_MODE_DATA		0x02
-#define	RWB_MODE_DOWNLOAD	0x04
-#define	RWB_MODE_DOWNLOAD_SAVE	0x05
-        uint8_t buffer_id;
-        uint8_t offset[3];
-        uint8_t length[3];
-        uint8_t control;
-};
-
-struct scsi_write_buffer
-{
-	uint8_t opcode;
-	uint8_t byte2;
-	uint8_t buffer_id;
-	uint8_t offset[3];
-	uint8_t length[3];
-	uint8_t control;
-};
-
-struct scsi_rw_6
-{
-	uint8_t opcode;
-	uint8_t addr[3];
-/* only 5 bits are valid in the MSB address byte */
-#define	SRW_TOPADDR	0x1F
-	uint8_t length;
-	uint8_t control;
-};
-
-struct scsi_rw_10
-{
-	uint8_t opcode;
-#define	SRW10_RELADDR	0x01
-#define SRW10_FUA	0x08
-#define	SRW10_DPO	0x10
-	uint8_t byte2;
-	uint8_t addr[4];
-	uint8_t reserved;
-	uint8_t length[2];
-	uint8_t control;
-};
-
-struct scsi_rw_12
-{
-	uint8_t opcode;
-#define	SRW12_RELADDR	0x01
-#define SRW12_FUA	0x08
-#define	SRW12_DPO	0x10
-	uint8_t byte2;
-	uint8_t addr[4];
-	uint8_t length[4];
-	uint8_t reserved;
-	uint8_t control;
-};
-
-struct scsi_start_stop_unit
-{
-	uint8_t opcode;
-	uint8_t byte2;
-#define	SSS_IMMED		0x01
-	uint8_t reserved[2];
-	uint8_t how;
-#define	SSS_START		0x01
-#define	SSS_LOEJ		0x02
-	uint8_t control;
-};
-
-#define SC_SCSI_1 0x01
-#define SC_SCSI_2 0x03
-
-/*
- * Opcodes
- */
-
-#define	TEST_UNIT_READY		0x00
-#define REQUEST_SENSE		0x03
-#define	READ_6			0x08
-#define WRITE_6			0x0a
-#define INQUIRY			0x12
-#define MODE_SELECT_6		0x15
-#define MODE_SENSE_6		0x1a
-#define START_STOP_UNIT		0x1b
-#define START_STOP		0x1b
-#define RESERVE      		0x16
-#define RELEASE      		0x17
-#define	RECEIVE_DIAGNOSTIC	0x1c
-#define	SEND_DIAGNOSTIC		0x1d
-#define PREVENT_ALLOW		0x1e
-#define	READ_CAPACITY		0x25
-#define	READ_10			0x28
-#define WRITE_10		0x2a
-#define POSITION_TO_ELEMENT	0x2b
-#define	SYNCHRONIZE_CACHE	0x35
-#define	WRITE_BUFFER            0x3b
-#define	READ_BUFFER             0x3c
-#define	CHANGE_DEFINITION	0x40
-#define	LOG_SELECT		0x4c
-#define	LOG_SENSE		0x4d
-#ifdef XXXCAM
-#define	MODE_SENSE_10		0x5A
-#endif
-#define	MODE_SELECT_10		0x55
-#define MOVE_MEDIUM     	0xa5
-#define READ_12			0xa8
-#define WRITE_12		0xaa
-#define READ_ELEMENT_STATUS	0xb8
-
-
-/*
- * Device Types
- */
-#define T_DIRECT	0x00
-#define T_SEQUENTIAL	0x01
-#define T_PRINTER	0x02
-#define T_PROCESSOR	0x03
-#define T_WORM		0x04
-#define T_CDROM		0x05
-#define T_SCANNER 	0x06
-#define T_OPTICAL 	0x07
-#define T_CHANGER	0x08
-#define T_COMM		0x09
-#define T_ASC0		0x0a
-#define T_ASC1		0x0b
-#define	T_STORARRAY	0x0c
-#define	T_ENCLOSURE	0x0d
-#define	T_RBC		0x0e
-#define	T_OCRW		0x0f
-#define T_NODEVICE	0x1F
-#define	T_ANY		0xFF	/* Used in Quirk table matches */
-
-#define T_REMOV		1
-#define	T_FIXED		0
-
-/*
- * This length is the initial inquiry length used by the probe code, as    
- * well as the legnth necessary for aic_print_inquiry() to function 
- * correctly.  If either use requires a different length in the future, 
- * the two values should be de-coupled.
- */
-#define	SHORT_INQUIRY_LENGTH	36
-
-struct scsi_inquiry_data
-{
-	uint8_t device;
-#define	SID_TYPE(inq_data) ((inq_data)->device & 0x1f)
-#define	SID_QUAL(inq_data) (((inq_data)->device & 0xE0) >> 5)
-#define	SID_QUAL_LU_CONNECTED	0x00	/*
-					 * The specified peripheral device
-					 * type is currently connected to
-					 * logical unit.  If the target cannot
-					 * determine whether or not a physical
-					 * device is currently connected, it
-					 * shall also use this peripheral
-					 * qualifier when returning the INQUIRY
-					 * data.  This peripheral qualifier
-					 * does not mean that the device is
-					 * ready for access by the initiator.
-					 */
-#define	SID_QUAL_LU_OFFLINE	0x01	/*
-					 * The target is capable of supporting
-					 * the specified peripheral device type
-					 * on this logical unit; however, the
-					 * physical device is not currently
-					 * connected to this logical unit.
-					 */
-#define SID_QUAL_RSVD		0x02
-#define	SID_QUAL_BAD_LU		0x03	/*
-					 * The target is not capable of
-					 * supporting a physical device on
-					 * this logical unit. For this
-					 * peripheral qualifier the peripheral
-					 * device type shall be set to 1Fh to
-					 * provide compatibility with previous
-					 * versions of SCSI. All other
-					 * peripheral device type values are
-					 * reserved for this peripheral
-					 * qualifier.
-					 */
-#define	SID_QUAL_IS_VENDOR_UNIQUE(inq_data) ((SID_QUAL(inq_data) & 0x08) != 0)
-	uint8_t dev_qual2;
-#define	SID_QUAL2	0x7F
-#define	SID_IS_REMOVABLE(inq_data) (((inq_data)->dev_qual2 & 0x80) != 0)
-	uint8_t version;
-#define SID_ANSI_REV(inq_data) ((inq_data)->version & 0x07)
-#define		SCSI_REV_0		0
-#define		SCSI_REV_CCS		1
-#define		SCSI_REV_2		2
-#define		SCSI_REV_SPC		3
-#define		SCSI_REV_SPC2		4
-
-#define SID_ECMA	0x38
-#define SID_ISO		0xC0
-	uint8_t response_format;
-#define SID_AENC	0x80
-#define SID_TrmIOP	0x40
-	uint8_t additional_length;
-	uint8_t reserved[2];
-	uint8_t flags;
-#define	SID_SftRe	0x01
-#define	SID_CmdQue	0x02
-#define	SID_Linked	0x08
-#define	SID_Sync	0x10
-#define	SID_WBus16	0x20
-#define	SID_WBus32	0x40
-#define	SID_RelAdr	0x80
-#define SID_VENDOR_SIZE   8
-	char	 vendor[SID_VENDOR_SIZE];
-#define SID_PRODUCT_SIZE  16
-	char	 product[SID_PRODUCT_SIZE];
-#define SID_REVISION_SIZE 4
-	char	 revision[SID_REVISION_SIZE];
-	/*
-	 * The following fields were taken from SCSI Primary Commands - 2
-	 * (SPC-2) Revision 14, Dated 11 November 1999
-	 */
-#define	SID_VENDOR_SPECIFIC_0_SIZE	20
-	uint8_t vendor_specific0[SID_VENDOR_SPECIFIC_0_SIZE];
-	/*
-	 * An extension of SCSI Parallel Specific Values
-	 */
-#define	SID_SPI_IUS		0x01
-#define	SID_SPI_QAS		0x02
-#define	SID_SPI_CLOCK_ST	0x00
-#define	SID_SPI_CLOCK_DT	0x04
-#define	SID_SPI_CLOCK_DT_ST	0x0C
-#define	SID_SPI_MASK		0x0F
-	uint8_t spi3data;
-	uint8_t reserved2;
-	/*
-	 * Version Descriptors, stored 2 byte values.
-	 */
-	uint8_t version1[2];
-	uint8_t version2[2];
-	uint8_t version3[2];
-	uint8_t version4[2];
-	uint8_t version5[2];
-	uint8_t version6[2];
-	uint8_t version7[2];
-	uint8_t version8[2];
-
-	uint8_t reserved3[22];
-
-#define	SID_VENDOR_SPECIFIC_1_SIZE	160
-	uint8_t vendor_specific1[SID_VENDOR_SPECIFIC_1_SIZE];
-};
-
-struct scsi_vpd_unit_serial_number
-{
-	uint8_t device;
-	uint8_t page_code;
-#define SVPD_UNIT_SERIAL_NUMBER	0x80
-	uint8_t reserved;
-	uint8_t length; /* serial number length */
-#define SVPD_SERIAL_NUM_SIZE 251
-	uint8_t serial_num[SVPD_SERIAL_NUM_SIZE];
-};
-
-struct scsi_read_capacity
-{
-	uint8_t opcode;
-	uint8_t byte2;
-	uint8_t addr[4];
-	uint8_t unused[3];
-	uint8_t control;
-};
-
-struct scsi_read_capacity_data
-{
-	uint8_t addr[4];
-	uint8_t length[4];
-};
-
-struct scsi_report_luns
-{
-	uint8_t opcode;
-	uint8_t byte2;
-	uint8_t unused[3];
-	uint8_t addr[4];
-	uint8_t control;
-};
-
-struct scsi_report_luns_data {
-	uint8_t length[4];	/* length of LUN inventory, in bytes */
-	uint8_t reserved[4];	/* unused */
-	/*
-	 * LUN inventory- we only support the type zero form for now.
-	 */
-	struct {
-		uint8_t lundata[8];
-	} luns[1];
-};
-#define	RPL_LUNDATA_ATYP_MASK	0xc0	/* MBZ for type 0 lun */
-#define	RPL_LUNDATA_T0LUN	1	/* @ lundata[1] */
-
-
-struct scsi_sense_data
-{
-	uint8_t error_code;
-#define	SSD_ERRCODE			0x7F
-#define		SSD_CURRENT_ERROR	0x70
-#define		SSD_DEFERRED_ERROR	0x71
-#define	SSD_ERRCODE_VALID	0x80	
-	uint8_t segment;
-	uint8_t flags;
-#define	SSD_KEY				0x0F
-#define		SSD_KEY_NO_SENSE	0x00
-#define		SSD_KEY_RECOVERED_ERROR	0x01
-#define		SSD_KEY_NOT_READY	0x02
-#define		SSD_KEY_MEDIUM_ERROR	0x03
-#define		SSD_KEY_HARDWARE_ERROR	0x04
-#define		SSD_KEY_ILLEGAL_REQUEST	0x05
-#define		SSD_KEY_UNIT_ATTENTION	0x06
-#define		SSD_KEY_DATA_PROTECT	0x07
-#define		SSD_KEY_BLANK_CHECK	0x08
-#define		SSD_KEY_Vendor_Specific	0x09
-#define		SSD_KEY_COPY_ABORTED	0x0a
-#define		SSD_KEY_ABORTED_COMMAND	0x0b		
-#define		SSD_KEY_EQUAL		0x0c
-#define		SSD_KEY_VOLUME_OVERFLOW	0x0d
-#define		SSD_KEY_MISCOMPARE	0x0e
-#define		SSD_KEY_RESERVED	0x0f			
-#define	SSD_ILI		0x20
-#define	SSD_EOM		0x40
-#define	SSD_FILEMARK	0x80
-	uint8_t info[4];
-	uint8_t extra_len;
-	uint8_t cmd_spec_info[4];
-	uint8_t add_sense_code;
-	uint8_t add_sense_code_qual;
-	uint8_t fru;
-	uint8_t sense_key_spec[3];
-#define	SSD_SCS_VALID		0x80
-#define SSD_FIELDPTR_CMD	0x40
-#define SSD_BITPTR_VALID	0x08
-#define SSD_BITPTR_VALUE	0x07
-#define SSD_MIN_SIZE 18
-	uint8_t extra_bytes[14];
-#define SSD_FULL_SIZE sizeof(struct scsi_sense_data)
-};
-
-struct scsi_mode_header_6
-{
-	uint8_t data_length;	/* Sense data length */
-	uint8_t medium_type;
-	uint8_t dev_spec;
-	uint8_t blk_desc_len;
-};
-
-struct scsi_mode_header_10
-{
-	uint8_t data_length[2];/* Sense data length */
-	uint8_t medium_type;
-	uint8_t dev_spec;
-	uint8_t unused[2];
-	uint8_t blk_desc_len[2];
-};
-
-struct scsi_mode_page_header
-{
-	uint8_t page_code;
-	uint8_t page_length;
-};
-
-struct scsi_mode_blk_desc
-{
-	uint8_t density;
-	uint8_t nblocks[3];
-	uint8_t reserved;
-	uint8_t blklen[3];
-};
-
-#define	SCSI_DEFAULT_DENSITY	0x00	/* use 'default' density */
-#define	SCSI_SAME_DENSITY	0x7f	/* use 'same' density- >= SCSI-2 only */
-
-
-/*
- * Status Byte
- */
-#define	SCSI_STATUS_OK			0x00
-#define	SCSI_STATUS_CHECK_COND		0x02
-#define	SCSI_STATUS_COND_MET		0x04
-#define	SCSI_STATUS_BUSY		0x08
-#define SCSI_STATUS_INTERMED		0x10
-#define SCSI_STATUS_INTERMED_COND_MET	0x14
-#define SCSI_STATUS_RESERV_CONFLICT	0x18
-#define SCSI_STATUS_CMD_TERMINATED	0x22	/* Obsolete in SAM-2 */
-#define SCSI_STATUS_QUEUE_FULL		0x28
-#define SCSI_STATUS_ACA_ACTIVE		0x30
-#define SCSI_STATUS_TASK_ABORTED	0x40
-
-struct scsi_inquiry_pattern {
-	uint8_t   type;
-	uint8_t   media_type;
-#define	SIP_MEDIA_REMOVABLE	0x01
-#define	SIP_MEDIA_FIXED		0x02
-	const char *vendor;
-	const char *product;
-	const char *revision;
-}; 
-
-struct scsi_static_inquiry_pattern {
-	uint8_t   type;
-	uint8_t   media_type;
-	char       vendor[SID_VENDOR_SIZE+1];
-	char       product[SID_PRODUCT_SIZE+1];
-	char       revision[SID_REVISION_SIZE+1];
-};
-
-struct scsi_sense_quirk_entry {
-	struct scsi_inquiry_pattern	inq_pat;
-	int				num_sense_keys;
-	int				num_ascs;
-	struct sense_key_table_entry	*sense_key_info;
-	struct asc_table_entry		*asc_info;
-};
-
-struct sense_key_table_entry {
-	uint8_t    sense_key;
-	uint32_t   action;
-	const char *desc;
-};
-
-struct asc_table_entry {
-	uint8_t    asc;
-	uint8_t    ascq;
-	uint32_t   action;
-	const char *desc;
-};
-
-struct op_table_entry {
-	uint8_t    opcode;
-	uint16_t   opmask;
-	const char  *desc;
-};
-
-struct scsi_op_quirk_entry {
-	struct scsi_inquiry_pattern	inq_pat;
-	int				num_ops;
-	struct op_table_entry		*op_table;
-};
-
-typedef enum {
-	SSS_FLAG_NONE		= 0x00,
-	SSS_FLAG_PRINT_COMMAND	= 0x01
-} scsi_sense_string_flags;
-
-extern const char *scsi_sense_key_text[];
-
-/************************* Large Disk Handling ********************************/
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-static __inline int aic_sector_div(u_long capacity, int heads, int sectors);
-
-static __inline int
-aic_sector_div(u_long capacity, int heads, int sectors)
-{
-	return (capacity / (heads * sectors));
-}
-#else
-static __inline int aic_sector_div(sector_t capacity, int heads, int sectors);
-
-static __inline int
-aic_sector_div(sector_t capacity, int heads, int sectors)
-{
-	/* ugly, ugly sector_div calling convention.. */
-	sector_div(capacity, (heads * sectors));
-	return (int)capacity;
-}
-#endif
-
-/**************************** Module Library Hack *****************************/
-/*
- * What we'd like to do is have a single "scsi library" module that both the
- * aic7xxx and aic79xx drivers could load and depend on.  A cursory examination
- * of implementing module dependencies in Linux (handling the install and
- * initrd cases) does not look promissing.  For now, we just duplicate this
- * code in both drivers using a simple symbol renaming scheme that hides this
- * hack from the drivers.
- */
-#define AIC_LIB_ENTRY_CONCAT(x, prefix)	prefix ## x
-#define	AIC_LIB_ENTRY_EXPAND(x, prefix) AIC_LIB_ENTRY_CONCAT(x, prefix)
-#define AIC_LIB_ENTRY(x)		AIC_LIB_ENTRY_EXPAND(x, AIC_LIB_PREFIX)
-
-#define	aic_sense_desc			AIC_LIB_ENTRY(_sense_desc)
-#define	aic_sense_error_action		AIC_LIB_ENTRY(_sense_error_action)
-#define	aic_error_action		AIC_LIB_ENTRY(_error_action)
-#define	aic_op_desc			AIC_LIB_ENTRY(_op_desc)
-#define	aic_cdb_string			AIC_LIB_ENTRY(_cdb_string)
-#define aic_print_inquiry		AIC_LIB_ENTRY(_print_inquiry)
-#define aic_calc_syncsrate		AIC_LIB_ENTRY(_calc_syncrate)
-#define	aic_calc_syncparam		AIC_LIB_ENTRY(_calc_syncparam)
-#define	aic_calc_speed			AIC_LIB_ENTRY(_calc_speed)
-#define	aic_inquiry_match		AIC_LIB_ENTRY(_inquiry_match)
-#define	aic_static_inquiry_match	AIC_LIB_ENTRY(_static_inquiry_match)
-
-/******************************************************************************/
-
-void			aic_sense_desc(int /*sense_key*/, int /*asc*/,
-				       int /*ascq*/, struct scsi_inquiry_data*,
-				       const char** /*sense_key_desc*/,
-				       const char** /*asc_desc*/);
-aic_sense_action	aic_sense_error_action(struct scsi_sense_data*,
-					       struct scsi_inquiry_data*,
-					       uint32_t /*sense_flags*/);
-uint32_t		aic_error_action(struct scsi_cmnd *,
-					 struct scsi_inquiry_data *,
-					 cam_status, u_int);
-
-#define	SF_RETRY_UA	0x01
-#define SF_NO_PRINT	0x02
-#define SF_QUIET_IR	0x04	/* Be quiet about Illegal Request reponses */
-#define SF_PRINT_ALWAYS	0x08
-
-
-const char *	aic_op_desc(uint16_t /*opcode*/, struct scsi_inquiry_data*);
-char *		aic_cdb_string(uint8_t* /*cdb_ptr*/, char* /*cdb_string*/,
-			       size_t /*len*/);
-void		aic_print_inquiry(struct scsi_inquiry_data*);
-
-u_int		aic_calc_syncsrate(u_int /*period_factor*/);
-u_int		aic_calc_syncparam(u_int /*period*/);
-u_int		aic_calc_speed(u_int width, u_int period, u_int offset,
-			       u_int min_rate);
-	
-int		aic_inquiry_match(caddr_t /*inqbuffer*/,
-				  caddr_t /*table_entry*/);
-int		aic_static_inquiry_match(caddr_t /*inqbuffer*/,
-					 caddr_t /*table_entry*/);
-
-
-static __inline void	 scsi_extract_sense(struct scsi_sense_data *sense,
-					    int *error_code, int *sense_key,
-					    int *asc, int *ascq);
-static __inline void	 scsi_ulto2b(uint32_t val, uint8_t *bytes);
-static __inline void	 scsi_ulto3b(uint32_t val, uint8_t *bytes);
-static __inline void	 scsi_ulto4b(uint32_t val, uint8_t *bytes);
-static __inline uint32_t scsi_2btoul(uint8_t *bytes);
-static __inline uint32_t scsi_3btoul(uint8_t *bytes);
-static __inline int32_t	 scsi_3btol(uint8_t *bytes);
-static __inline uint32_t scsi_4btoul(uint8_t *bytes);
-
-static __inline void scsi_extract_sense(struct scsi_sense_data *sense,
-				       int *error_code, int *sense_key,
-				       int *asc, int *ascq)
-{
-	*error_code = sense->error_code & SSD_ERRCODE;
-	*sense_key = sense->flags & SSD_KEY;
-	*asc = (sense->extra_len >= 5) ? sense->add_sense_code : 0;
-	*ascq = (sense->extra_len >= 6) ? sense->add_sense_code_qual : 0;
-}
-
-static __inline void
-scsi_ulto2b(uint32_t val, uint8_t *bytes)
-{
-
-	bytes[0] = (val >> 8) & 0xff;
-	bytes[1] = val & 0xff;
-}
-
-static __inline void
-scsi_ulto3b(uint32_t val, uint8_t *bytes)
-{
-
-	bytes[0] = (val >> 16) & 0xff;
-	bytes[1] = (val >> 8) & 0xff;
-	bytes[2] = val & 0xff;
-}
-
-static __inline void
-scsi_ulto4b(uint32_t val, uint8_t *bytes)
-{
-
-	bytes[0] = (val >> 24) & 0xff;
-	bytes[1] = (val >> 16) & 0xff;
-	bytes[2] = (val >> 8) & 0xff;
-	bytes[3] = val & 0xff;
-}
-
-static __inline uint32_t
-scsi_2btoul(uint8_t *bytes)
-{
-	uint32_t rv;
-
-	rv = (bytes[0] << 8) |
-	     bytes[1];
-	return (rv);
-}
-
-static __inline uint32_t
-scsi_3btoul(uint8_t *bytes)
-{
-	uint32_t rv;
-
-	rv = (bytes[0] << 16) |
-	     (bytes[1] << 8) |
-	     bytes[2];
-	return (rv);
-}
-
-static __inline int32_t 
-scsi_3btol(uint8_t *bytes)
-{
-	uint32_t rc = scsi_3btoul(bytes);
- 
-	if (rc & 0x00800000)
-		rc |= 0xff000000;
-
-	return (int32_t) rc;
-}
-
-static __inline uint32_t
-scsi_4btoul(uint8_t *bytes)
-{
-	uint32_t rv;
-
-	rv = (bytes[0] << 24) |
-	     (bytes[1] << 16) |
-	     (bytes[2] << 8) |
-	     bytes[3];
-	return (rv);
-}
-
-#endif /*_SCSI_SCSI_ALL_H*/
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/cam.h linux-2.4.22-pre2/drivers/scsi/aic79xx/cam.h
--- linux-2.4.21/drivers/scsi/aic79xx/cam.h	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/cam.h	2003-06-26 21:43:16.000000000 +0000
@@ -1,117 +0,0 @@
-/*
- * Data structures and definitions for the CAM system.
- *
- * Copyright (c) 1997 Justin T. Gibbs.
- * Copyright (c) 2000 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. The name of the author may not 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").
- *
- * 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.
- *
- * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/cam.h#15 $
- */
-
-#ifndef _AIC7XXX_CAM_H
-#define _AIC7XXX_CAM_H 1
-
-#include <linux/types.h>
-
-#define	CAM_BUS_WILDCARD ((u_int)~0)
-#define	CAM_TARGET_WILDCARD ((u_int)~0)
-#define	CAM_LUN_WILDCARD ((u_int)~0)
-
-/* CAM Status field values */
-typedef enum {
-	CAM_REQ_INPROG,		/* CCB request is in progress */
-	CAM_REQ_CMP,		/* CCB request completed without error */
-	CAM_REQ_ABORTED,	/* CCB request aborted by the host */
-	CAM_UA_ABORT,		/* Unable to abort CCB request */
-	CAM_REQ_CMP_ERR,	/* CCB request completed with an error */
-	CAM_BUSY,		/* CAM subsytem is busy */
-	CAM_REQ_INVALID,	/* CCB request was invalid */
-	CAM_PATH_INVALID,	/* Supplied Path ID is invalid */
-	CAM_SEL_TIMEOUT,	/* Target Selection Timeout */
-	CAM_CMD_TIMEOUT,	/* Command timeout */
-	CAM_SCSI_STATUS_ERROR,	/* SCSI error, look at error code in CCB */
-	CAM_SCSI_BUS_RESET,	/* SCSI Bus Reset Sent/Received */
-	CAM_UNCOR_PARITY,	/* Uncorrectable parity error occurred */
-	CAM_AUTOSENSE_FAIL,	/* Autosense: request sense cmd fail */
-	CAM_NO_HBA,		/* No HBA Detected Error */
-	CAM_DATA_RUN_ERR,	/* Data Overrun error */
-	CAM_UNEXP_BUSFREE,	/* Unexpected Bus Free */
-	CAM_SEQUENCE_FAIL,	/* Protocol Violation */
-	CAM_CCB_LEN_ERR,	/* CCB length supplied is inadequate */
-	CAM_PROVIDE_FAIL,	/* Unable to provide requested capability */
-	CAM_BDR_SENT,		/* A SCSI BDR msg was sent to target */
-	CAM_REQ_TERMIO,		/* CCB request terminated by the host */
-	CAM_UNREC_HBA_ERROR,	/* Unrecoverable Host Bus Adapter Error */
-	CAM_REQ_TOO_BIG,	/* The request was too large for this host */
-	CAM_UA_TERMIO,		/* Unable to terminate I/O CCB request */
-	CAM_MSG_REJECT_REC,	/* Message Reject Received */
-	CAM_DEV_NOT_THERE,	/* SCSI Device Not Installed/there */
-	CAM_RESRC_UNAVAIL,	/* Resource Unavailable */
-	/*
-	 * This request should be requeued to preserve
-	 * transaction ordering.  This typically occurs
-	 * when the SIM recognizes an error that should
-	 * freeze the queue and must place additional
-	 * requests for the target at the sim level
-	 * back into the XPT queue.
-	 */
-	CAM_REQUEUE_REQ,
-	CAM_DEV_QFRZN		= 0x40,
-
-	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.
- */
-typedef enum {
-	AC_GETDEV_CHANGED	= 0x800,/* Getdev info might have changed */
-	AC_INQ_CHANGED		= 0x400,/* Inquiry info might have changed */
-	AC_TRANSFER_NEG		= 0x200,/* New transfer settings in effect */
-	AC_LOST_DEVICE		= 0x100,/* A device went away */
-	AC_FOUND_DEVICE		= 0x080,/* A new device was found */
-	AC_PATH_DEREGISTERED	= 0x040,/* A path has de-registered */
-	AC_PATH_REGISTERED	= 0x020,/* A new path has been registered */
-	AC_SENT_BDR		= 0x010,/* A BDR message was sent to target */
-	AC_SCSI_AEN		= 0x008,/* A SCSI AEN has been received */
-	AC_UNSOL_RESEL		= 0x002,/* Unsolicited reselection occurred */
-	AC_BUS_RESET		= 0x001 /* A SCSI bus reset occurred */
-} ac_code;
-
-typedef enum {
-	CAM_DIR_IN		= SCSI_DATA_READ,
-	CAM_DIR_OUT		= SCSI_DATA_WRITE,
-	CAM_DIR_NONE		= SCSI_DATA_NONE
-} ccb_flags;
-
-#endif /* _AIC7XXX_CAM_H */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/queue.h linux-2.4.22-pre2/drivers/scsi/aic79xx/queue.h
--- linux-2.4.21/drivers/scsi/aic79xx/queue.h	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/queue.h	2003-06-26 21:43:19.000000000 +0000
@@ -1,501 +0,0 @@
-/*
- * Copyright (c) 1991, 1993
- *	The Regents of the University of California.  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.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- *	@(#)queue.h	8.5 (Berkeley) 8/20/94
- * $FreeBSD: src/sys/sys/queue.h,v 1.38 2000/05/26 02:06:56 jake Exp $
- */
-
-#ifndef _SYS_QUEUE_H_
-#define	_SYS_QUEUE_H_
-
-/*
- * This file defines five types of data structures: singly-linked lists,
- * singly-linked tail queues, lists, tail queues, and circular queues.
- *
- * A singly-linked list is headed by a single forward pointer. The elements
- * are singly linked for minimum space and pointer manipulation overhead at
- * the expense of O(n) removal for arbitrary elements. New elements can be
- * added to the list after an existing element or at the head of the list.
- * Elements being removed from the head of the list should use the explicit
- * macro for this purpose for optimum efficiency. A singly-linked list may
- * only be traversed in the forward direction.  Singly-linked lists are ideal
- * for applications with large datasets and few or no removals or for
- * implementing a LIFO queue.
- *
- * A singly-linked tail queue is headed by a pair of pointers, one to the
- * head of the list and the other to the tail of the list. The elements are
- * singly linked for minimum space and pointer manipulation overhead at the
- * expense of O(n) removal for arbitrary elements. New elements can be added
- * to the list after an existing element, at the head of the list, or at the
- * end of the list. Elements being removed from the head of the tail queue
- * should use the explicit macro for this purpose for optimum efficiency.
- * A singly-linked tail queue may only be traversed in the forward direction.
- * Singly-linked tail queues are ideal for applications with large datasets
- * and few or no removals or for implementing a FIFO queue.
- *
- * A list is headed by a single forward pointer (or an array of forward
- * pointers for a hash table header). The elements are doubly linked
- * so that an arbitrary element can be removed without a need to
- * traverse the list. New elements can be added to the list before
- * or after an existing element or at the head of the list. A list
- * may only be traversed in the forward direction.
- *
- * A tail queue is headed by a pair of pointers, one to the head of the
- * list and the other to the tail of the list. The elements are doubly
- * linked so that an arbitrary element can be removed without a need to
- * traverse the list. New elements can be added to the list before or
- * after an existing element, at the head of the list, or at the end of
- * the list. A tail queue may be traversed in either direction.
- *
- * A circle queue is headed by a pair of pointers, one to the head of the
- * list and the other to the tail of the list. The elements are doubly
- * linked so that an arbitrary element can be removed without a need to
- * traverse the list. New elements can be added to the list before or after
- * an existing element, at the head of the list, or at the end of the list.
- * A circle queue may be traversed in either direction, but has a more
- * complex end of list detection.
- *
- * For details on the use of these macros, see the queue(3) manual page.
- *
- *
- *			SLIST	LIST	STAILQ	TAILQ	CIRCLEQ
- * _HEAD		+	+	+	+	+
- * _HEAD_INITIALIZER	+	+	+	+	+
- * _ENTRY		+	+	+	+	+
- * _INIT		+	+	+	+	+
- * _EMPTY		+	+	+	+	+
- * _FIRST		+	+	+	+	+
- * _NEXT		+	+	+	+	+
- * _PREV		-	-	-	+	+
- * _LAST		-	-	+	+	+
- * _FOREACH		+	+	+	+	+
- * _FOREACH_REVERSE	-	-	-	+	+
- * _INSERT_HEAD		+	+	+	+	+
- * _INSERT_BEFORE	-	+	-	+	+
- * _INSERT_AFTER	+	+	+	+	+
- * _INSERT_TAIL		-	-	+	+	+
- * _REMOVE_HEAD		+	-	+	-	-
- * _REMOVE		+	+	+	+	+
- *
- */
-
-/*
- * Singly-linked List declarations.
- */
-#define	SLIST_HEAD(name, type)						\
-struct name {								\
-	struct type *slh_first;	/* first element */			\
-}
-
-#define	SLIST_HEAD_INITIALIZER(head)					\
-	{ NULL }
- 
-#define	SLIST_ENTRY(type)						\
-struct {								\
-	struct type *sle_next;	/* next element */			\
-}
- 
-/*
- * Singly-linked List functions.
- */
-#define	SLIST_EMPTY(head)	((head)->slh_first == NULL)
-
-#define	SLIST_FIRST(head)	((head)->slh_first)
-
-#define	SLIST_FOREACH(var, head, field)					\
-	for ((var) = SLIST_FIRST((head));				\
-	    (var);							\
-	    (var) = SLIST_NEXT((var), field))
-
-#define	SLIST_INIT(head) do {						\
-	SLIST_FIRST((head)) = NULL;					\
-} while (0)
-
-#define	SLIST_INSERT_AFTER(slistelm, elm, field) do {			\
-	SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field);	\
-	SLIST_NEXT((slistelm), field) = (elm);				\
-} while (0)
-
-#define	SLIST_INSERT_HEAD(head, elm, field) do {			\
-	SLIST_NEXT((elm), field) = SLIST_FIRST((head));			\
-	SLIST_FIRST((head)) = (elm);					\
-} while (0)
-
-#define	SLIST_NEXT(elm, field)	((elm)->field.sle_next)
-
-#define	SLIST_REMOVE(head, elm, type, field) do {			\
-	if (SLIST_FIRST((head)) == (elm)) {				\
-		SLIST_REMOVE_HEAD((head), field);			\
-	}								\
-	else {								\
-		struct type *curelm = SLIST_FIRST((head));		\
-		while (SLIST_NEXT(curelm, field) != (elm))		\
-			curelm = SLIST_NEXT(curelm, field);		\
-		SLIST_NEXT(curelm, field) =				\
-		    SLIST_NEXT(SLIST_NEXT(curelm, field), field);	\
-	}								\
-} while (0)
-
-#define	SLIST_REMOVE_HEAD(head, field) do {				\
-	SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field);	\
-} while (0)
-
-/*
- * Singly-linked Tail queue declarations.
- */
-#define	STAILQ_HEAD(name, type)						\
-struct name {								\
-	struct type *stqh_first;/* first element */			\
-	struct type **stqh_last;/* addr of last next element */		\
-}
-
-#define	STAILQ_HEAD_INITIALIZER(head)					\
-	{ NULL, &(head).stqh_first }
-
-#define	STAILQ_ENTRY(type)						\
-struct {								\
-	struct type *stqe_next;	/* next element */			\
-}
-
-/*
- * Singly-linked Tail queue functions.
- */
-#define	STAILQ_EMPTY(head)	((head)->stqh_first == NULL)
-
-#define	STAILQ_FIRST(head)	((head)->stqh_first)
-
-#define	STAILQ_FOREACH(var, head, field)				\
-	for((var) = STAILQ_FIRST((head));				\
-	   (var);							\
-	   (var) = STAILQ_NEXT((var), field))
-
-#define	STAILQ_INIT(head) do {						\
-	STAILQ_FIRST((head)) = NULL;					\
-	(head)->stqh_last = &STAILQ_FIRST((head));			\
-} while (0)
-
-#define	STAILQ_INSERT_AFTER(head, tqelm, elm, field) do {		\
-	if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
-		(head)->stqh_last = &STAILQ_NEXT((elm), field);		\
-	STAILQ_NEXT((tqelm), field) = (elm);				\
-} while (0)
-
-#define	STAILQ_INSERT_HEAD(head, elm, field) do {			\
-	if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL)	\
-		(head)->stqh_last = &STAILQ_NEXT((elm), field);		\
-	STAILQ_FIRST((head)) = (elm);					\
-} while (0)
-
-#define	STAILQ_INSERT_TAIL(head, elm, field) do {			\
-	STAILQ_NEXT((elm), field) = NULL;				\
-	STAILQ_LAST((head)) = (elm);					\
-	(head)->stqh_last = &STAILQ_NEXT((elm), field);			\
-} while (0)
-
-#define	STAILQ_LAST(head)	(*(head)->stqh_last)
-
-#define	STAILQ_NEXT(elm, field)	((elm)->field.stqe_next)
-
-#define	STAILQ_REMOVE(head, elm, type, field) do {			\
-	if (STAILQ_FIRST((head)) == (elm)) {				\
-		STAILQ_REMOVE_HEAD(head, field);			\
-	}								\
-	else {								\
-		struct type *curelm = STAILQ_FIRST((head));		\
-		while (STAILQ_NEXT(curelm, field) != (elm))		\
-			curelm = STAILQ_NEXT(curelm, field);		\
-		if ((STAILQ_NEXT(curelm, field) =			\
-		     STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\
-			(head)->stqh_last = &STAILQ_NEXT((curelm), field);\
-	}								\
-} while (0)
-
-#define	STAILQ_REMOVE_HEAD(head, field) do {				\
-	if ((STAILQ_FIRST((head)) =					\
-	     STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL)		\
-		(head)->stqh_last = &STAILQ_FIRST((head));		\
-} while (0)
-
-#define	STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do {			\
-	if ((STAILQ_FIRST((head)) = STAILQ_NEXT((elm), field)) == NULL)	\
-		(head)->stqh_last = &STAILQ_FIRST((head));		\
-} while (0)
-
-/*
- * List declarations.
- */
-#define	LIST_HEAD(name, type)						\
-struct name {								\
-	struct type *lh_first;	/* first element */			\
-}
-
-#define	LIST_HEAD_INITIALIZER(head)					\
-	{ NULL }
-
-#define	LIST_ENTRY(type)						\
-struct {								\
-	struct type *le_next;	/* next element */			\
-	struct type **le_prev;	/* address of previous next element */	\
-}
-
-/*
- * List functions.
- */
-
-#define	LIST_EMPTY(head)	((head)->lh_first == NULL)
-
-#define	LIST_FIRST(head)	((head)->lh_first)
-
-#define	LIST_FOREACH(var, head, field)					\
-	for ((var) = LIST_FIRST((head));				\
-	    (var);							\
-	    (var) = LIST_NEXT((var), field))
-
-#define	LIST_INIT(head) do {						\
-	LIST_FIRST((head)) = NULL;					\
-} while (0)
-
-#define	LIST_INSERT_AFTER(listelm, elm, field) do {			\
-	if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
-		LIST_NEXT((listelm), field)->field.le_prev =		\
-		    &LIST_NEXT((elm), field);				\
-	LIST_NEXT((listelm), field) = (elm);				\
-	(elm)->field.le_prev = &LIST_NEXT((listelm), field);		\
-} while (0)
-
-#define	LIST_INSERT_BEFORE(listelm, elm, field) do {			\
-	(elm)->field.le_prev = (listelm)->field.le_prev;		\
-	LIST_NEXT((elm), field) = (listelm);				\
-	*(listelm)->field.le_prev = (elm);				\
-	(listelm)->field.le_prev = &LIST_NEXT((elm), field);		\
-} while (0)
-
-#define	LIST_INSERT_HEAD(head, elm, field) do {				\
-	if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL)	\
-		LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
-	LIST_FIRST((head)) = (elm);					\
-	(elm)->field.le_prev = &LIST_FIRST((head));			\
-} while (0)
-
-#define	LIST_NEXT(elm, field)	((elm)->field.le_next)
-
-#define	LIST_REMOVE(elm, field) do {					\
-	if (LIST_NEXT((elm), field) != NULL)				\
-		LIST_NEXT((elm), field)->field.le_prev = 		\
-		    (elm)->field.le_prev;				\
-	*(elm)->field.le_prev = LIST_NEXT((elm), field);		\
-} while (0)
-
-/*
- * Tail queue declarations.
- */
-#define	TAILQ_HEAD(name, type)						\
-struct name {								\
-	struct type *tqh_first;	/* first element */			\
-	struct type **tqh_last;	/* addr of last next element */		\
-}
-
-#define	TAILQ_HEAD_INITIALIZER(head)					\
-	{ NULL, &(head).tqh_first }
-
-#define	TAILQ_ENTRY(type)						\
-struct {								\
-	struct type *tqe_next;	/* next element */			\
-	struct type **tqe_prev;	/* address of previous next element */	\
-}
-
-/*
- * Tail queue functions.
- */
-#define	TAILQ_EMPTY(head)	((head)->tqh_first == NULL)
-
-#define	TAILQ_FIRST(head)	((head)->tqh_first)
-
-#define	TAILQ_FOREACH(var, head, field)					\
-	for ((var) = TAILQ_FIRST((head));				\
-	    (var);							\
-	    (var) = TAILQ_NEXT((var), field))
-
-#define	TAILQ_FOREACH_REVERSE(var, head, headname, field)		\
-	for ((var) = TAILQ_LAST((head), headname);			\
-	    (var);							\
-	    (var) = TAILQ_PREV((var), headname, field))
-
-#define	TAILQ_INIT(head) do {						\
-	TAILQ_FIRST((head)) = NULL;					\
-	(head)->tqh_last = &TAILQ_FIRST((head));			\
-} while (0)
-
-#define	TAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
-	if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
-		TAILQ_NEXT((elm), field)->field.tqe_prev = 		\
-		    &TAILQ_NEXT((elm), field);				\
-	else								\
-		(head)->tqh_last = &TAILQ_NEXT((elm), field);		\
-	TAILQ_NEXT((listelm), field) = (elm);				\
-	(elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field);		\
-} while (0)
-
-#define	TAILQ_INSERT_BEFORE(listelm, elm, field) do {			\
-	(elm)->field.tqe_prev = (listelm)->field.tqe_prev;		\
-	TAILQ_NEXT((elm), field) = (listelm);				\
-	*(listelm)->field.tqe_prev = (elm);				\
-	(listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field);		\
-} while (0)
-
-#define	TAILQ_INSERT_HEAD(head, elm, field) do {			\
-	if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL)	\
-		TAILQ_FIRST((head))->field.tqe_prev =			\
-		    &TAILQ_NEXT((elm), field);				\
-	else								\
-		(head)->tqh_last = &TAILQ_NEXT((elm), field);		\
-	TAILQ_FIRST((head)) = (elm);					\
-	(elm)->field.tqe_prev = &TAILQ_FIRST((head));			\
-} while (0)
-
-#define	TAILQ_INSERT_TAIL(head, elm, field) do {			\
-	TAILQ_NEXT((elm), field) = NULL;				\
-	(elm)->field.tqe_prev = (head)->tqh_last;			\
-	*(head)->tqh_last = (elm);					\
-	(head)->tqh_last = &TAILQ_NEXT((elm), field);			\
-} while (0)
-
-#define	TAILQ_LAST(head, headname)					\
-	(*(((struct headname *)((head)->tqh_last))->tqh_last))
-
-#define	TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
-
-#define	TAILQ_PREV(elm, headname, field)				\
-	(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
-
-#define	TAILQ_REMOVE(head, elm, field) do {				\
-	if ((TAILQ_NEXT((elm), field)) != NULL)				\
-		TAILQ_NEXT((elm), field)->field.tqe_prev = 		\
-		    (elm)->field.tqe_prev;				\
-	else								\
-		(head)->tqh_last = (elm)->field.tqe_prev;		\
-	*(elm)->field.tqe_prev = TAILQ_NEXT((elm), field);		\
-} while (0)
-
-/*
- * Circular queue declarations.
- */
-#define	CIRCLEQ_HEAD(name, type)					\
-struct name {								\
-	struct type *cqh_first;		/* first element */		\
-	struct type *cqh_last;		/* last element */		\
-}
-
-#define	CIRCLEQ_HEAD_INITIALIZER(head)					\
-	{ (void *)&(head), (void *)&(head) }
-
-#define	CIRCLEQ_ENTRY(type)						\
-struct {								\
-	struct type *cqe_next;		/* next element */		\
-	struct type *cqe_prev;		/* previous element */		\
-}
-
-/*
- * Circular queue functions.
- */
-#define	CIRCLEQ_EMPTY(head)	((head)->cqh_first == (void *)(head))
-
-#define	CIRCLEQ_FIRST(head)	((head)->cqh_first)
-
-#define	CIRCLEQ_FOREACH(var, head, field)				\
-	for ((var) = CIRCLEQ_FIRST((head));				\
-	    (var) != (void *)(head);					\
-	    (var) = CIRCLEQ_NEXT((var), field))
-
-#define	CIRCLEQ_FOREACH_REVERSE(var, head, field)			\
-	for ((var) = CIRCLEQ_LAST((head));				\
-	    (var) != (void *)(head);					\
-	    (var) = CIRCLEQ_PREV((var), field))
-
-#define	CIRCLEQ_INIT(head) do {						\
-	CIRCLEQ_FIRST((head)) = (void *)(head);				\
-	CIRCLEQ_LAST((head)) = (void *)(head);				\
-} while (0)
-
-#define	CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
-	CIRCLEQ_NEXT((elm), field) = CIRCLEQ_NEXT((listelm), field);	\
-	CIRCLEQ_PREV((elm), field) = (listelm);				\
-	if (CIRCLEQ_NEXT((listelm), field) == (void *)(head))		\
-		CIRCLEQ_LAST((head)) = (elm);				\
-	else								\
-		CIRCLEQ_PREV(CIRCLEQ_NEXT((listelm), field), field) = (elm);\
-	CIRCLEQ_NEXT((listelm), field) = (elm);				\
-} while (0)
-
-#define	CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do {		\
-	CIRCLEQ_NEXT((elm), field) = (listelm);				\
-	CIRCLEQ_PREV((elm), field) = CIRCLEQ_PREV((listelm), field);	\
-	if (CIRCLEQ_PREV((listelm), field) == (void *)(head))		\
-		CIRCLEQ_FIRST((head)) = (elm);				\
-	else								\
-		CIRCLEQ_NEXT(CIRCLEQ_PREV((listelm), field), field) = (elm);\
-	CIRCLEQ_PREV((listelm), field) = (elm);				\
-} while (0)
-
-#define	CIRCLEQ_INSERT_HEAD(head, elm, field) do {			\
-	CIRCLEQ_NEXT((elm), field) = CIRCLEQ_FIRST((head));		\
-	CIRCLEQ_PREV((elm), field) = (void *)(head);			\
-	if (CIRCLEQ_LAST((head)) == (void *)(head))			\
-		CIRCLEQ_LAST((head)) = (elm);				\
-	else								\
-		CIRCLEQ_PREV(CIRCLEQ_FIRST((head)), field) = (elm);	\
-	CIRCLEQ_FIRST((head)) = (elm);					\
-} while (0)
-
-#define	CIRCLEQ_INSERT_TAIL(head, elm, field) do {			\
-	CIRCLEQ_NEXT((elm), field) = (void *)(head);			\
-	CIRCLEQ_PREV((elm), field) = CIRCLEQ_LAST((head));		\
-	if (CIRCLEQ_FIRST((head)) == (void *)(head))			\
-		CIRCLEQ_FIRST((head)) = (elm);				\
-	else								\
-		CIRCLEQ_NEXT(CIRCLEQ_LAST((head)), field) = (elm);	\
-	CIRCLEQ_LAST((head)) = (elm);					\
-} while (0)
-
-#define	CIRCLEQ_LAST(head)	((head)->cqh_last)
-
-#define	CIRCLEQ_NEXT(elm,field)	((elm)->field.cqe_next)
-
-#define	CIRCLEQ_PREV(elm,field)	((elm)->field.cqe_prev)
-
-#define	CIRCLEQ_REMOVE(head, elm, field) do {				\
-	if (CIRCLEQ_NEXT((elm), field) == (void *)(head))		\
-		CIRCLEQ_LAST((head)) = CIRCLEQ_PREV((elm), field);	\
-	else								\
-		CIRCLEQ_PREV(CIRCLEQ_NEXT((elm), field), field) =	\
-		    CIRCLEQ_PREV((elm), field);				\
-	if (CIRCLEQ_PREV((elm), field) == (void *)(head))		\
-		CIRCLEQ_FIRST((head)) = CIRCLEQ_NEXT((elm), field);	\
-	else								\
-		CIRCLEQ_NEXT(CIRCLEQ_PREV((elm), field), field) =	\
-		    CIRCLEQ_NEXT((elm), field);				\
-} while (0)
-
-#endif /* !_SYS_QUEUE_H_ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/scsi_iu.h linux-2.4.22-pre2/drivers/scsi/aic79xx/scsi_iu.h
--- linux-2.4.21/drivers/scsi/aic79xx/scsi_iu.h	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/scsi_iu.h	2003-06-26 21:43:33.000000000 +0000
@@ -1,39 +0,0 @@
-/*
- * This file is in the public domain.
- */
-#ifndef	_SCSI_SCSI_IU_H
-#define _SCSI_SCSI_IU_H 1
-
-struct scsi_status_iu_header
-{
-	u_int8_t reserved[2];
-	u_int8_t flags;
-#define	SIU_SNSVALID 0x2
-#define	SIU_RSPVALID 0x1
-	u_int8_t status;
-	u_int8_t sense_length[4];
-	u_int8_t pkt_failures_length[4];
-	u_int8_t pkt_failures[1];
-};
-
-#define SIU_PKTFAIL_OFFSET(siu) 12
-#define SIU_PKTFAIL_CODE(siu) (scsi_4btoul((siu)->pkt_failures) & 0xFF)
-#define		SIU_PFC_NONE			0
-#define		SIU_PFC_CIU_FIELDS_INVALID	2
-#define		SIU_PFC_TMF_NOT_SUPPORTED	4
-#define		SIU_PFC_TMF_FAILED		5
-#define		SIU_PFC_INVALID_TYPE_CODE	6
-#define		SIU_PFC_ILLEGAL_REQUEST		7
-#define SIU_SENSE_OFFSET(siu)				\
-    (12 + (((siu)->flags & SIU_RSPVALID)		\
-	? scsi_4btoul((siu)->pkt_failures_length)	\
-	: 0))
-
-#define	SIU_TASKMGMT_NONE		0x00
-#define	SIU_TASKMGMT_ABORT_TASK		0x01
-#define	SIU_TASKMGMT_ABORT_TASK_SET	0x02
-#define	SIU_TASKMGMT_CLEAR_TASK_SET	0x04
-#define	SIU_TASKMGMT_LUN_RESET		0x08
-#define	SIU_TASKMGMT_TARGET_RESET	0x20
-#define	SIU_TASKMGMT_CLEAR_ACA		0x40
-#endif /*_SCSI_SCSI_IU_H*/
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic79xx/scsi_message.h linux-2.4.22-pre2/drivers/scsi/aic79xx/scsi_message.h
--- linux-2.4.21/drivers/scsi/aic79xx/scsi_message.h	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic79xx/scsi_message.h	2003-06-26 21:43:12.000000000 +0000
@@ -1,70 +0,0 @@
-/*
- * This file is in the public domain.
- * $FreeBSD: src/sys/cam/scsi/scsi_message.h,v 1.2 2000/05/01 20:21:29 peter Exp $
- */
-
-/* Messages (1 byte) */		     /* I/T (M)andatory or (O)ptional */
-#define MSG_CMDCOMPLETE		0x00 /* M/M */
-#define MSG_TASK_COMPLETE	0x00 /* M/M */ /* SPI3 Terminology */
-#define MSG_EXTENDED		0x01 /* O/O */
-#define MSG_SAVEDATAPOINTER	0x02 /* O/O */
-#define MSG_RESTOREPOINTERS	0x03 /* O/O */
-#define MSG_DISCONNECT		0x04 /* O/O */
-#define MSG_INITIATOR_DET_ERR	0x05 /* M/M */
-#define MSG_ABORT		0x06 /* O/M */
-#define MSG_ABORT_TASK_SET	0x06 /* O/M */ /* SPI3 Terminology */
-#define MSG_MESSAGE_REJECT	0x07 /* M/M */
-#define MSG_NOOP		0x08 /* M/M */
-#define MSG_PARITY_ERROR	0x09 /* M/M */
-#define MSG_LINK_CMD_COMPLETE	0x0a /* O/O */
-#define MSG_LINK_CMD_COMPLETEF	0x0b /* O/O */
-#define MSG_BUS_DEV_RESET	0x0c /* O/M */
-#define MSG_TARGET_RESET	0x0c /* O/M */ /* SPI3 Terminology */
-#define MSG_ABORT_TAG		0x0d /* O/O */
-#define MSG_ABORT_TASK		0x0d /* O/O */ /* SPI3 Terminology */
-#define MSG_CLEAR_QUEUE		0x0e /* O/O */
-#define MSG_CLEAR_TASK_SET	0x0e /* O/O */ /* SPI3 Terminology */
-#define MSG_INIT_RECOVERY	0x0f /* O/O */ /* Deprecated in SPI3 */
-#define MSG_REL_RECOVERY	0x10 /* O/O */ /* Deprecated in SPI3 */
-#define MSG_TERM_IO_PROC	0x11 /* O/O */ /* Deprecated in SPI3 */
-#define MSG_CLEAR_ACA		0x16 /* O/O */ /* SPI3 */
-#define MSG_LOGICAL_UNIT_RESET	0x17 /* O/O */ /* SPI3 */
-#define MSG_QAS_REQUEST		0x55 /* O/O */ /* SPI3 */
-
-/* Messages (2 byte) */
-#define MSG_SIMPLE_Q_TAG	0x20 /* O/O */
-#define MSG_SIMPLE_TASK		0x20 /* O/O */ /* SPI3 Terminology */
-#define MSG_HEAD_OF_Q_TAG	0x21 /* O/O */
-#define MSG_HEAD_OF_QUEUE_TASK	0x21 /* O/O */ /* SPI3 Terminology */
-#define MSG_ORDERED_Q_TAG	0x22 /* O/O */
-#define MSG_ORDERED_TASK	0x22 /* O/O */ /* SPI3 Terminology */
-#define MSG_IGN_WIDE_RESIDUE	0x23 /* O/O */
-#define MSG_ACA_TASK		0x24 /* 0/0 */ /* SPI3 */
-
-/* Identify message */		     /* M/M */	
-#define MSG_IDENTIFYFLAG	0x80 
-#define MSG_IDENTIFY_DISCFLAG	0x40 
-#define MSG_IDENTIFY(lun, disc)	(((disc) ? 0xc0 : MSG_IDENTIFYFLAG) | (lun))
-#define MSG_ISIDENTIFY(m)	((m) & MSG_IDENTIFYFLAG)
-#define MSG_IDENTIFY_LUNMASK	0x3F 
-
-/* Extended messages (opcode and length) */
-#define MSG_EXT_SDTR		0x01
-#define MSG_EXT_SDTR_LEN	0x03
-
-#define MSG_EXT_WDTR		0x03
-#define MSG_EXT_WDTR_LEN	0x02
-#define MSG_EXT_WDTR_BUS_8_BIT	0x00
-#define MSG_EXT_WDTR_BUS_16_BIT	0x01
-#define MSG_EXT_WDTR_BUS_32_BIT	0x02 /* Deprecated in SPI3 */
-
-#define MSG_EXT_PPR		0x04 /* SPI3 */
-#define MSG_EXT_PPR_LEN		0x06
-#define	MSG_EXT_PPR_PCOMP_EN	0x80
-#define	MSG_EXT_PPR_RTI		0x40
-#define	MSG_EXT_PPR_RD_STRM	0x20
-#define	MSG_EXT_PPR_WR_FLOW	0x10
-#define	MSG_EXT_PPR_HOLD_MCS	0x08
-#define	MSG_EXT_PPR_QAS_REQ	0x04
-#define	MSG_EXT_PPR_DT_REQ	0x02
-#define MSG_EXT_PPR_IU_REQ	0x01
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/Config.in linux-2.4.22-pre2/drivers/scsi/aic7xxx/Config.in
--- linux-2.4.21/drivers/scsi/aic7xxx/Config.in	2002-08-03 00:39:44.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/Config.in	2003-06-26 21:43:12.000000000 +0000
@@ -2,12 +2,35 @@
    dep_tristate 'Adaptec AIC7xxx support' CONFIG_SCSI_AIC7XXX $CONFIG_SCSI
    if [ "$CONFIG_SCSI_AIC7XXX" != "n" ]; then
       int  '  Maximum number of TCQ commands per device' \
-	CONFIG_AIC7XXX_CMDS_PER_DEVICE 253
+	CONFIG_AIC7XXX_CMDS_PER_DEVICE 32
       int  '  Initial bus reset delay in milli-seconds' \
 	CONFIG_AIC7XXX_RESET_DELAY_MS 15000
       bool  '  Probe for EISA and VL AIC7XXX Adapters' \
 	CONFIG_AIC7XXX_PROBE_EISA_VL
       bool  '  Build Adapter Firmware with Kernel Build' \
 	CONFIG_AIC7XXX_BUILD_FIRMWARE
+      bool  '  Compile in Debugging Code' \
+	CONFIG_AIC7XXX_DEBUG_ENABLE
+      int  '  Debug code enable mask (2048 for all debugging)' \
+	CONFIG_AIC7XXX_DEBUG_MASK 0
+      bool  '  Decode registers during diagnostics' \
+	CONFIG_AIC7XXX_REG_PRETTY_PRINT
    fi
 fi
+dep_tristate 'Adaptec AIC79xx support' CONFIG_SCSI_AIC79XX $CONFIG_SCSI
+if [ "$CONFIG_SCSI_AIC79XX" != "n" ]; then
+   int  '  Maximum number of TCQ commands per device' \
+	CONFIG_AIC79XX_CMDS_PER_DEVICE 32
+   int  '  Initial bus reset delay in milli-seconds' \
+	CONFIG_AIC79XX_RESET_DELAY_MS 15000
+   bool  '  Build Adapter Firmware with Kernel Build' \
+	CONFIG_AIC79XX_BUILD_FIRMWARE
+   bool  '  Enable Read Streaming for All Targets' \
+	CONFIG_AIC79XX_ENABLE_RD_STRM
+   bool  '  Compile in Debugging Code' \
+	CONFIG_AIC79XX_DEBUG_ENABLE
+   int  '  Debug code enable mask (16384 for all debugging)' \
+	CONFIG_AIC79XX_DEBUG_MASK 0
+   bool  '  Decode registers during diagnostics' \
+	CONFIG_AIC79XX_REG_PRETTY_PRINT
+fi
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/Makefile linux-2.4.22-pre2/drivers/scsi/aic7xxx/Makefile
--- linux-2.4.21/drivers/scsi/aic7xxx/Makefile	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/Makefile	2003-06-26 21:43:33.000000000 +0000
@@ -6,23 +6,46 @@
 
 O_TARGET := aic7xxx_drv.o
 
-list-multi	:= aic7xxx.o
+list-multi	:= aic7xxx.o aic79xx.o
 
 obj-$(CONFIG_SCSI_AIC7XXX)	+= aic7xxx.o
+ifeq ($(CONFIG_PCI),y)
+obj-$(CONFIG_SCSI_AIC79XX)	+= aic79xx.o
+endif
 
+EXTRA_CFLAGS += -I$(TOPDIR)/drivers/scsi -Werror
 #EXTRA_CFLAGS += -g
 
 # Platform Specific Files
-obj-aic7xxx = aic7xxx_osm.o aic7xxx_proc.o aic7770_osm.o
-#PCI Specific Platform Files
+obj-aic7xxx = aic7xxx_osm.o aic7xxx_proc.o
+
+# Core Files
+obj-aic7xxx += aic7xxx_core.o aic7xxx_93cx6.o
+ifeq ($(CONFIG_AIC7XXX_REG_PRETTY_PRINT),y)
+obj-aic7xxx += aic7xxx_reg_print.o
+endif
+
+#EISA Specific Files
+AIC7XXX_EISA_ARCH = $(filter i386 alpha,$(ARCH))
+ifneq ($(AIC7XXX_EISA_ARCH),)
+obj-aic7xxx += aic7770.o
+# Platform Specific EISA Files
+obj-aic7xxx += aic7770_osm.o
+endif
+
+#PCI Specific Files
 ifeq ($(CONFIG_PCI),y)
+obj-aic7xxx += aic7xxx_pci.o
+# Platform Specific PCI Files
 obj-aic7xxx += aic7xxx_osm_pci.o
 endif
+
+# Platform Specific U320 Files
+obj-aic79xx = aic79xx_osm.o aic79xx_proc.o aic79xx_osm_pci.o
 # Core Files
-obj-aic7xxx += aic7xxx_core.o aic7xxx_93cx6.o aic7770.o
-#PCI Specific Core Files
-ifeq ($(CONFIG_PCI),y)
-obj-aic7xxx += aic7xxx_pci.o
+obj-aic79xx += aic79xx_core.o aic79xx_pci.o
+ifeq ($(CONFIG_AIC79XX_REG_PRETTY_PRINT),y)
+obj-aic79xx += aic79xx_reg_print.o
 endif
 
 # Override our module desitnation
@@ -35,9 +58,39 @@
 aic7xxx.o: aic7xxx_seq.h aic7xxx_reg.h $(obj-aic7xxx)
 	$(LD) $(LD_RFLAG) -r -o $@ $(obj-aic7xxx)
 
+aic79xx_core.o: aic79xx_seq.h
+$(obj-aic79xx): aic79xx_reg.h
+aic79xx.o: aic79xx_seq.h aic79xx_reg.h $(obj-aic79xx)
+	$(LD) $(LD_RFLAG) -r -o $@ $(obj-aic79xx)
+
 ifeq ($(CONFIG_AIC7XXX_BUILD_FIRMWARE),y)
-aic7xxx_seq.h aic7xxx_reg.h: aic7xxx.seq aic7xxx.reg aicasm/aicasm
-	aicasm/aicasm -I. -r aic7xxx_reg.h -o aic7xxx_seq.h aic7xxx.seq
+aic7xxx_gen = aic7xxx_seq.h aic7xxx_reg.h
+ifeq ($(CONFIG_AIC7XXX_REG_PRETTY_PRINT),y)
+aic7xxx_gen += aic7xxx_reg_print.c
+aic7xxx_asm_cmd = aicasm/aicasm -I. -r aic7xxx_reg.h		\
+		 -p aic7xxx_reg_print.c -i aic7xxx_osm.h	\
+		 -o aic7xxx_seq.h aic7xxx.seq
+else
+aic7xxx_asm_cmd = aicasm/aicasm -I. -r aic7xxx_reg.h		\
+		 -o aic7xxx_seq.h aic7xxx.seq
+endif
+$(aic7xxx_gen): aic7xxx.seq aic7xxx.reg aicasm/aicasm
+	$(aic7xxx_asm_cmd)
+endif
+
+ifeq ($(CONFIG_AIC79XX_BUILD_FIRMWARE),y)
+aic79xx_gen = aic79xx_seq.h aic79xx_reg.h
+ifeq ($(CONFIG_AIC79XX_REG_PRETTY_PRINT),y)
+aic79xx_gen += aic79xx_reg_print.c
+aic79xx_asm_cmd = aicasm/aicasm -I. -r aic79xx_reg.h		\
+		 -p aic79xx_reg_print.c -i aic79xx_osm.h	\
+		 -o aic79xx_seq.h aic79xx.seq
+else
+aic79xx_asm_cmd = aicasm/aicasm -I. -r aic79xx_reg.h \
+		 -o aic79xx_seq.h aic79xx.seq
+endif
+$(aic79xx_gen): aic79xx.seq aic79xx.reg aicasm/aicasm
+	$(aic79xx_asm_cmd)
 endif
 
 aicasm/aicasm: aicasm/*.[chyl]
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/README.aic79xx linux-2.4.22-pre2/drivers/scsi/aic7xxx/README.aic79xx
--- linux-2.4.21/drivers/scsi/aic7xxx/README.aic79xx	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/README.aic79xx	2003-06-26 21:43:27.000000000 +0000
@@ -0,0 +1,496 @@
+====================================================================
+=             Adaptec Ultra320 Family Manager Set v1.3.0           =
+=                                                                  =
+=                            README for                            =
+=                    The Linux Operating System                    =
+====================================================================
+
+The following information is available in this file:
+
+  1. Supported Hardware
+  2. Version History
+  3. Command Line Options
+  4. Additional Notes
+  5. Contacting Adaptec
+
+
+1. Supported Hardware
+
+   The following Adaptec SCSI Host Adapters are supported by this 
+   driver set. 
+
+   Ultra320 Adapters         Description
+   ----------------------------------------------------------------
+   Adaptec SCSI Card 39320   Dual Channel 64-bit PCI-X 133MHz to
+                             Ultra320 SCSI Card (one external 
+                             68-pin, two internal 68-pin)
+   Adaptec SCSI Card 39320D  Dual Channel 64-bit PCI-X 133MHz to
+                             Ultra320 SCSI Card (two external VHDC
+                             and one internal 68-pin)
+   Adaptec SCSI Card 39320D  Dual Channel 64-bit PCI-X 133MHz to
+                             Ultra320 SCSI Card (two external VHDC
+                             and one internal 68-pin) based on the
+                             AIC-7902B ASIC
+   Adaptec SCSI Card 29320   Single Channel 64-bit PCI-X 133MHz to
+                             Ultra320 SCSI Card (one external 
+                             68-pin, two internal 68-pin, one
+                             internal 50-pin)
+   Adaptec SCSI Card 29320LP Single Channel 64-bit Low Profile
+                             PCI-X 133MHz to Ultra320 SCSI Card
+                             (One external VHDC, one internal
+                             68-pin)
+   AIC-7901A                 Single Channel 64-bit PCI-X 133MHz to 
+                             Ultra320 SCSI ASIC
+   AIC-7902A4                Dual Channel 64-bit PCI-X 133MHz to 
+                             Ultra320 SCSI ASIC
+   AIC-7902B                 Dual Channel 64-bit PCI-X 133MHz to
+                             Ultra320 SCSI ASIC
+
+2. Version History
+   1.3.10 (June 3rd, 2003)
+        - Align the SCB_TAG field on a 16byte boundary.  This avoids
+          SCB corruption on some PCI-33 busses.
+        - Correct non-zero luns on Rev B. hardware.
+        - Update for change in 2.5.X SCSI proc FS interface.
+        - When negotiation async via an 8bit WDTR message, send
+          an SDTR with an offset of 0 to be sure the target
+          knows we are async.  This works around a firmware defect
+          in the Quantum Atlas 10K.
+        - Implement controller susupend and resume.
+        - Clear PCI error state during driver attach so that we
+          don't disable memory mapped I/O due to a stray write
+          by some other driver probe that occurred before we
+          claimed the controller.
+
+   1.3.9 (May 22nd, 2003)
+        - Fix compiler errors.
+        - Remove S/G splitting for segments that cross a 4GB boundary.
+          This is guaranteed not to happen in Linux.
+        - Add support for scsi_report_device_reset() found in
+          2.5.X kernels.
+        - Add 7901B support.
+        - Simplify handling of the packtized lun Rev A workaround.
+        - Correct and simplify handling of the ignore wide residue
+          message.  The previous code would fail to report a residual
+          if the transaction data length was even and we received
+          an IWR message.
+
+   1.3.8 (April 29th, 2003)
+        - Fix types accessed via the command line interface code.
+        - Perform a few firmware optimizations.
+        - Fix "Unexpected PKT busfree" errors.
+        - Use a sequencer interrupt to notify the host of
+          commands with bad status.  We defer the notification
+          until there are no outstanding selections to ensure
+          that the host is interrupted for as short a time as
+          possible.
+        - Remove pre-2.2.X support.
+        - Add support for new 2.5.X interrupt API.
+        - Correct big-endian architecture support.
+
+   1.3.7 (April 16th, 2003)
+        - Use del_timer_sync() to ensure that no timeouts
+          are pending during controller shutdown.
+        - For pre-2.5.X kernels, carefully adjust our segment
+          list size to avoid SCSI malloc pool fragmentation.
+        - Cleanup channel display in our /proc output.
+        - Workaround duplicate device entries in the mid-layer
+          devlice list during add-single-device.
+
+   1.3.6 (March 28th, 2003)
+        - Correct a double free in the Domain Validation code.
+        - Correct a reference to free'ed memory during controller
+          shutdown.
+        - Reset the bus on an SE->LVD change.  This is required
+          to reset our transcievers.
+
+   1.3.5 (March 24th, 2003)
+        - Fix a few register window mode bugs.
+        - Include read streaming in the PPR flags we display in
+          diagnostics as well as /proc.
+        - Add PCI hot plug support for 2.5.X kernels.
+        - Correct default precompensation value for RevA hardware.
+        - Fix Domain Validation thread shutdown.
+        - Add a firmware workaround to make the LED blink
+          brighter during packetized operations on the H2A4.
+        - Correct /proc display of user read streaming settings.
+        - Simplify driver locking by releasing the io_request_lock
+          upon driver entry from the mid-layer.
+        - Cleanup command line parsing and move much of this code
+          to aiclib.
+
+   1.3.4 (February 28th, 2003)
+        - Correct a race condition in our error recovery handler.
+        - Allow Test Unit Ready commands to take a full 5 seconds
+          during Domain Validation.
+
+   1.3.2 (February 19th, 2003)
+        - Correct a Rev B. regression due to the GEM318
+          compatibility fix included in 1.3.1.
+          
+   1.3.1 (February 11th, 2003)
+        - Add support for the 39320A.
+        - Improve recovery for certain PCI-X errors.
+        - Fix handling of LQ/DATA/LQ/DATA for the
+          same write transaction that can occur without
+          interveining training.
+        - Correct compatibility issues with the GEM318
+          enclosure services device.
+        - Correct data corruption issue that occurred under
+          high tag depth write loads.
+        - Adapt to a change in the 2.5.X daemonize() API.
+        - Correct a "Missing case in ahd_handle_scsiint" panic.
+
+   1.3.0 (January 21st, 2003)
+        - Full regression testing for all U320 products completed.
+        - Added abort and target/lun reset error recovery handler and
+          interrupt coalessing.
+
+   1.2.0 (November 14th, 2002)
+        - Added support for Domain Validation
+        - Add support for the Hewlett-Packard version of the 39320D
+          and AIC-7902 adapters.
+        Support for previous adapters has not been fully tested and should
+        only be used at the customer's own risk.
+
+   1.1.1 (September 24th, 2002)
+        - Added support for the Linux 2.5.X kernel series
+
+   1.1.0 (September 17th, 2002)
+        - Added support for four additional SCSI products:
+          ASC-39320, ASC-29320, ASC-29320LP, AIC-7901.
+
+   1.0.0 (May 30th, 2002)
+        - Initial driver release.
+
+   2.1. Software/Hardware Features
+        - Support for the SPI-4 "Ultra320" standard:
+          - 320MB/s transfer rates
+          - Packetized SCSI Protocol at 160MB/s and 320MB/s
+          - Quick Arbitration Selection (QAS)
+          - Retained Training Information (Rev B. ASIC only)
+        - Interrupt Coalessing
+        - Initiator Mode (target mode not currently 
+          supported)
+        - Support for the PCI-X standard up to 133MHz
+        - Support for the PCI v2.2 standard
+	- Domain Validation
+
+   2.2. Operating System Support:
+        - Redhat Linux 7.2, 7.3, 8.0, Advanced Server 2.1
+        - SuSE Linux 7.3, 8.0, 8.1, Enterprise Server 7
+        - only Intel and AMD x86 supported at this time
+        - >4GB memory configurations supported.
+
+     Refer to the User's Guide for more details on this.
+
+3. Command Line Options
+
+        WARNING: ALTERING OR ADDING THESE DRIVER PARAMETERS
+                 INCORRECTLY CAN RENDER YOUR SYSTEM INOPERABLE.
+                 USE THEM WITH CAUTION. 
+
+   Edit the file "modules.conf" in the directory /etc and add/edit a
+   line containing 'options aic79xx aic79xx=[command[,command...]]' where
+   'command' is one or more of the following:
+   -----------------------------------------------------------------
+              Option: verbose
+          Definition: enable additional informative messages during
+                      driver operation.
+     Possible Values: This option is a flag
+       Default Value: disabled
+   -----------------------------------------------------------------
+              Option: debug:[value]
+          Definition: Enables various levels of debugging information
+                      The bit definitions for the debugging mask can
+                      be found in drivers/scsi/aic7xxx/aic79xx.h under
+                      the "Debug" heading.
+     Possible Values: 0x0000 = no debugging, 0xffff = full debugging
+       Default Value: 0x0000
+   -----------------------------------------------------------------
+              Option: no_reset
+          Definition: Do not reset the bus during the initial probe
+                      phase
+     Possible Values: This option is a flag
+       Default Value: disabled
+   -----------------------------------------------------------------
+              Option: extended
+          Definition: Force extended translation on the controller
+     Possible Values: This option is a flag
+       Default Value: disabled
+   -----------------------------------------------------------------
+              Option: periodic_otag
+          Definition: Send an ordered tag periodically to prevent
+                      tag starvation.  Needed for some older devices
+     Possible Values: This option is a flag
+       Default Value: disabled
+   -----------------------------------------------------------------
+              Option: reverse_scan
+          Definition: Probe the scsi bus in reverse order, starting
+                      with target 15
+     Possible Values: This option is a flag
+       Default Value: disabled
+   -----------------------------------------------------------------
+              Option: global_tag_depth
+          Definition: Global tag depth for all targets on all busses.
+                      This option sets the default tag depth which
+                      may be selectively overridden vi the tag_info
+                      option.
+     Possible Values: 1 - 253
+       Default Value: 32
+   -----------------------------------------------------------------
+              Option: tag_info:{{value[,value...]}[,{value[,value...]}...]}
+          Definition: Set the per-target tagged queue depth on a
+                      per controller basis.  Both controllers and targets
+                      may be ommitted indicating that they should retain
+                      the default tag depth.
+            Examples: tag_info:{{16,32,32,64,8,8,,32,32,32,32,32,32,32,32,32}
+                        On Controller 0
+                          specifies a tag depth of 16 for target 0
+                          specifies a tag depth of 64 for target 3
+                          specifies a tag depth of 8 for targets 4 and 5
+                          leaves target 6 at the default
+                          specifies a tag depth of 32 for targets 1,2,7-15
+                        All other targets retain the default depth.
+
+                      tag_info:{{},{32,,32}}
+                        On Controller 1
+                          specifies a tag depth of 32 for targets 0 and 2
+                        All other targets retain the default depth.
+                        
+     Possible Values: 1 - 253
+       Default Value: 32
+   -----------------------------------------------------------------
+              Option: rd_strm: {rd_strm_bitmask[,rd_strm_bitmask...]}
+          Definition: Enable read streaming on a per target basis.
+                      The rd_strm_bitmask is a 16 bit hex value in which
+                      each bit represents a target.  Setting the target's
+                      bit to '1' enables read streaming for that
+                      target.  Controllers may be ommitted indicating that
+                      they should retain the default read streaming setting.
+             Example: rd_strm:{0x0041}
+                        On Controller 0
+                          enables read streaming for targets 0 and 6.
+                          disables read streaming for targets 1-5,7-15.
+                        All other targets retain the default read
+                        streaming setting.
+             Example: rd_strm:{0x0023,,0xFFFF}
+                        On Controller 0
+                          enables read streaming for targets 1,2, and 5.
+                          disables read streaming for targets 3,4,6-15.
+                        On Controller 2
+                          enables read streaming for all targets.
+                        All other targets retain the default read
+                        streaming setting.
+                      
+     Possible Values: 0x0000 - 0xffff
+       Default Value: 0x0000
+   -----------------------------------------------------------------
+              Option: dv: {value[,value...]}
+          Definition: Set Domain Validation Policy on a per-controller basis.
+                      Controllers may be ommitted indicating that
+                      they should retain the default read streaming setting.
+             Example: dv:{-1,0,,1,1,0}
+                        On Controller 0 leave DV at its default setting.
+                        On Controller 1 disable DV.
+                        Skip configuration on Controller 2.
+                        On Controllers 3 and 4 enable DV.
+                        On Controller 5 disable DV.
+
+     Possible Values: < 0 Use setting from serial EEPROM.
+                      0 Disable DV
+                      > 0 Enable DV
+       Default Value: DV Serial EEPROM configuration setting.
+   -----------------------------------------------------------------
+              Option: seltime:[value]
+          Definition: Specifies the selection timeout value
+     Possible Values: 0 = 256ms, 1 = 128ms, 2 = 64ms, 3 = 32ms
+       Default Value: 0
+   -----------------------------------------------------------------
+
+   *** The following three options should only be changed at ***
+   *** the direction of a technical support representative.  ***
+
+   -----------------------------------------------------------------
+              Option: precomp: {value[,value...]}
+          Definition: Set IO Cell precompensation value on a per-controller
+                      basis.
+                      Controllers may be ommitted indicating that
+                      they should retain the default precompensation setting.
+             Example: precomp:{0x1}
+                        On Controller 0 set precompensation to 1.
+             Example: precomp:{1,,7}
+                        On Controller 0 set precompensation to 1.
+                        On Controller 2 set precompensation to 8.
+                      
+     Possible Values: 0 - 7
+       Default Value: Varies based on chip revision
+   -----------------------------------------------------------------
+              Option: slewrate: {value[,value...]}
+          Definition: Set IO Cell slew rate on a per-controller basis.
+                      Controllers may be ommitted indicating that
+                      they should retain the default slew rate setting.
+             Example: slewrate:{0x1}
+                        On Controller 0 set slew rate to 1.
+             Example: slewrate :{1,,8}
+                        On Controller 0 set slew rate to 1.
+                        On Controller 2 set slew rate to 8.
+                      
+     Possible Values: 0 - 15
+       Default Value: Varies based on chip revision
+   -----------------------------------------------------------------
+              Option: amplitude: {value[,value...]}
+          Definition: Set IO Cell signal amplitude on a per-controller basis.
+                      Controllers may be ommitted indicating that
+                      they should retain the default read streaming setting.
+             Example: amplitude:{0x1}
+                        On Controller 0 set amplitude to 1.
+             Example: amplitude :{1,,7}
+                        On Controller 0 set amplitude to 1.
+                        On Controller 2 set amplitude to 7.
+                      
+     Possible Values: 1 - 7
+       Default Value: Varies based on chip revision
+   -----------------------------------------------------------------
+
+   Example: 'options aic79xx aic79xx=verbose,rd_strm:{{0x0041}}'
+        enables verbose output in the driver and turns read streaming on
+        for targets 0 and 6 of Controller 0.
+
+4. Additional Notes
+
+   4.1. Known/Unresolved or FYI Issues
+
+        * Under SuSE Linux Enterprise 7, the driver may fail to operate
+          correctly due to a problem with PCI interrupt routing in the
+          Linux kernel.  Please contact SuSE for an updated Linux
+          kernel.
+
+   4.2. Third-Party Compatibility Issues
+
+        * Adaptec only supports Ultra320 hard drives running
+          the latest firmware available. Please check with
+          your hard drive manufacturer to ensure you have the
+          latest version.
+
+   4.3. Operating System or Technology Limitations
+        
+        * PCI Hot Plug is untested and may cause the operating system 
+          to stop responding.
+        * Luns that are not numbered contiguously starting with 0 might not
+          be automatically probed during system startup.  This is a limitation
+          of the OS.  Please contact your Linux vendor for instructions on
+          manually probing non-contiguous luns.
+        * Using the Driver Update Disk version of this package during OS
+          installation under RedHat might result in two versions of this
+          driver being installed into the system module directory.  This
+          might cause problems with the /sbin/mkinitrd program and/or
+          other RPM packages that try to install system modules.  The best
+          way to correct this once the system is running is to install
+          the latest RPM package version of this driver, available from
+          http://www.adaptec.com.
+
+
+5. Contacting Adaptec
+
+   A Technical Support Identification (TSID) Number is required for 
+   Adaptec technical support.
+    - The 12-digit TSID can be found on the white barcode-type label
+      included inside the box with your product. The TSID helps us 
+      provide more efficient service by accurately identifying your 
+      product and support status.
+   Support Options
+    - Search the Adaptec Support Knowledgebase (ASK) at
+      http://ask.adaptec.com for articles, troubleshooting tips, and
+      frequently asked questions for your product.
+    - For support via Email, submit your question to Adaptec's 
+      Technical Support Specialists at http://ask.adaptec.com.
+     
+   North America
+    - Visit our Web site at http://www.adaptec.com.
+    - To speak with a Fibre Channel/RAID/External Storage Technical
+      Support Specialist, call 1-321-207-2000,
+      Hours: Monday-Friday, 3:00 A.M. to 5:00 P.M., PST.
+      (Not open on holidays)
+    - For Technical Support in all other technologies including 
+      SCSI, call 1-408-934-7274,
+      Hours: Monday-Friday, 6:00 A.M. to 5:00 P.M., PST.
+      (Not open on holidays)
+    - For after hours support, call 1-800-416-8066 ($99/call, 
+      $149/call on holidays)
+    - To order Adaptec products including software and cables, call
+      1-800-442-7274 or 1-408-957-7274. You can also visit our 
+      online store at http://www.adaptecstore.com
+
+   Europe
+    - Visit our Web site at http://www.adaptec-europe.com.
+    - English and French: To speak with a Technical Support 
+      Specialist, call one of the following numbers:
+        - English: +32-2-352-3470
+        - French:  +32-2-352-3460
+      Hours: Monday-Thursday, 10:00 to 12:30, 13:30 to 17:30 CET 
+             Friday, 10:00 to 12:30, 13:30 to 16:30 CET
+    - German: To speak with a Technical Support Specialist,
+      call +49-89-456-40660
+      Hours: Monday-Thursday, 09:30 to 12:30, 13:30 to 16:30 CET
+             Friday, 09:30 to 12:30, 13:30 to 15:00 CET
+    - To order Adaptec products, including accessories and cables:
+        - UK: +0800-96-65-26 or fax +0800-731-02-95
+        - Other European countries: +32-11-300-379
+
+   Australia and New Zealand
+    - Visit our Web site at http://www.adaptec.com.au.
+    - To speak with a Technical Support Specialist, call 
+      +612-9416-0698
+      Hours: Monday-Friday, 10:00 A.M. to 4:30 P.M., EAT
+      (Not open on holidays)
+
+   Japan
+    - To speak with a Technical Support Specialist, call 
+      +81-3-5308-6120 
+      Hours: Monday-Friday, 9:00 a.m. to 12:00 p.m., 1:00 p.m. to
+      6:00 p.m. TSC
+
+   Hong Kong and China
+    - To speak with a Technical Support Specialist, call 
+      +852-2869-7200
+      Hours: Monday-Friday, 10:00 to 17:00.
+    - Fax Technical Support at +852-2869-7100.
+
+   Singapore
+    - To speak with a Technical Support Specialist, call 
+      +65-245-7470
+      Hours: Monday-Friday, 10:00 to 17:00.
+    - Fax Technical Support at +852-2869-7100
+
+-------------------------------------------------------------------
+/*
+ * Copyright (c) 2003 Adaptec Inc. 691 S. Milpitas Blvd., Milpitas CA 95035 USA.
+ * All rights reserved.
+ *
+ * You are permitted to redistribute, use and modify this README file in whole
+ * or in part in conjunction with redistribution of software governed by the
+ * General Public License, provided that the following conditions are met:
+ * 1. Redistributions of README file must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ * 3. Modifications or new contributions must be attributed in a copyright
+ *    notice identifying the author ("Contributor") and added below the
+ *    original copyright notice. The copyright notice is for purposes of
+ *    identifying contributors and should not be deemed as permission to alter
+ *    the permissions given by Adaptec.
+ *
+ * THIS README FILE IS PROVIDED BY ADAPTEC AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ANY
+ * WARRANTIES OF NON-INFRINGEMENT OR THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * ADAPTEC 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 README
+ * FILE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/README.aic7xxx linux-2.4.22-pre2/drivers/scsi/aic7xxx/README.aic7xxx
--- linux-2.4.21/drivers/scsi/aic7xxx/README.aic7xxx	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/README.aic7xxx	2003-06-26 21:43:31.000000000 +0000
@@ -0,0 +1,414 @@
+====================================================================
+=    Adaptec Aic7xxx Fast -> Ultra160 Family Manager Set v6.2.28   =
+=                            README for                            =
+=                     The Linux Operating System                   =
+====================================================================
+
+The following information is available in this file:
+
+  1. Supported Hardware
+  2. Version History
+  3. Command Line Options
+  4. Contacting Adaptec
+
+1. Supported Hardware
+
+   The following Adaptec SCSI Chips and Host Adapters are supported by
+   the aic7xxx driver. 
+
+   Chip    MIPS  Host Bus  MaxSync  MaxWidth  SCBs  Notes
+   ---------------------------------------------------------------
+   aic7770  10    EISA/VL   10MHz    16Bit      4   1
+   aic7850  10    PCI/32    10MHz    8Bit       3
+   aic7855  10    PCI/32    10MHz    8Bit       3
+   aic7856  10    PCI/32    10MHz    8Bit       3
+   aic7859  10    PCI/32    20MHz    8Bit       3
+   aic7860  10    PCI/32    20MHz    8Bit       3
+   aic7870  10    PCI/32    10MHz    16Bit      16
+   aic7880  10    PCI/32    20MHz    16Bit      16
+   aic7890  20    PCI/32    40MHz    16Bit      16      3 4 5 6 7 8
+   aic7891  20    PCI/64    40MHz    16Bit      16      3 4 5 6 7 8
+   aic7892  20   PCI/64-66  80MHz    16Bit      16      3 4 5 6 7 8
+   aic7895  15    PCI/32    20MHz    16Bit      16    2 3 4 5
+   aic7895C 15    PCI/32    20MHz    16Bit      16    2 3 4 5     8
+   aic7896  20    PCI/32    40MHz    16Bit      16    2 3 4 5 6 7 8
+   aic7897  20    PCI/64    40MHz    16Bit      16    2 3 4 5 6 7 8
+   aic7899  20   PCI/64-66  80MHz    16Bit      16    2 3 4 5 6 7 8
+
+   1.   Multiplexed Twin Channel Device - One controller servicing two
+        busses.
+   2.   Multi-function Twin Channel Device - Two controllers on one chip.
+   3.   Command Channel Secondary DMA Engine - Allows scatter gather list
+        and SCB prefetch.
+   4.   64 Byte SCB Support - Allows disconnected, unttagged request table
+        for all possible target/lun combinations.
+   5.   Block Move Instruction Support - Doubles the speed of certain
+        sequencer operations.
+   6.   `Bayonet' style Scatter Gather Engine - Improves S/G prefetch
+        performance.
+   7.   Queuing Registers - Allows queuing of new transactions without
+        pausing the sequencer.
+   8.   Multiple Target IDs - Allows the controller to respond to selection
+        as a target on multiple SCSI IDs.
+
+   Controller      Chip   Host-Bus    Int-Connectors  Ext-Connectors  Notes
+   --------------------------------------------------------------------------
+   AHA-274X[A]    aic7770   EISA         SE-50M         SE-HD50F
+   AHA-274X[A]W   aic7770   EISA         SE-HD68F       SE-HD68F
+                                         SE-50M
+   AHA-274X[A]T   aic7770   EISA       2 X SE-50M       SE-HD50F
+   AHA-2842       aic7770    VL          SE-50M         SE-HD50F
+   AHA-2940AU     aic7860   PCI/32       SE-50M         SE-HD50F
+   AVA-2902I      aic7860   PCI/32       SE-50M
+   AVA-2902E      aic7860   PCI/32       SE-50M
+   AVA-2906       aic7856   PCI/32       SE-50M         SE-DB25F
+   APC-7850       aic7850   PCI/32       SE-50M                       1
+   AVA-2940       aic7860   PCI/32       SE-50M
+   AHA-2920B      aic7860   PCI/32       SE-50M
+   AHA-2930B      aic7860   PCI/32       SE-50M
+   AHA-2920C      aic7856   PCI/32       SE-50M         SE-HD50F
+   AHA-2930C      aic7860   PCI/32       SE-50M
+   AHA-2930C      aic7860   PCI/32       SE-50M
+   AHA-2910C      aic7860   PCI/32       SE-50M
+   AHA-2915C      aic7860   PCI/32       SE-50M
+   AHA-2940AU/CN  aic7860   PCI/32       SE-50M         SE-HD50F
+   AHA-2944W      aic7870   PCI/32     HVD-HD68F        HVD-HD68F
+                                        HVD-50M
+   AHA-3940W      aic7870   PCI/32     2 X SE-HD68F     SE-HD68F        2
+   AHA-2940UW     aic7880   PCI/32       SE-HD68F
+                                         SE-50M         SE-HD68F
+   AHA-2940U      aic7880   PCI/32       SE-50M         SE-HD50F
+   AHA-2940D      aic7880   PCI/32
+   aHA-2940 A/T   aic7880   PCI/32
+   AHA-2940D A/T  aic7880   PCI/32
+   AHA-3940UW     aic7880   PCI/32     2 X SE-HD68F     SE-HD68F          3
+   AHA-3940UWD    aic7880   PCI/32     2 X SE-HD68F   2 X SE-VHD68F       3
+   AHA-3940U      aic7880   PCI/32     2 X SE-50M       SE-HD50F          3
+   AHA-2944UW     aic7880   PCI/32      HVD-HD68F       HVD-HD68F
+                                         HVD-50M
+   AHA-3944UWD    aic7880   PCI/32     2 X HVD-HD68F  2 X HVD-VHD68F      3
+   AHA-4944UW     aic7880   PCI/32
+   AHA-2930UW     aic7880   PCI/32
+   AHA-2940UW Pro aic7880   PCI/32      SE-HD68F        SE-HD68F            4
+                                         SE-50M
+   AHA-2940UW/CN  aic7880   PCI/32
+   AHA-2940UDual  aic7895   PCI/32
+   AHA-2940UWDual aic7895   PCI/32
+   AHA-3940UWD    aic7895   PCI/32
+   AHA-3940AUW    aic7895   PCI/32
+   AHA-3940AUWD   aic7895   PCI/32
+   AHA-3940AU     aic7895   PCI/32
+   AHA-3944AUWD   aic7895   PCI/32     2 X HVD-HD68F  2 X HVD-VHD68F
+   AHA-2940U2B    aic7890   PCI/32      LVD-HD68F       LVD-HD68F
+   AHA-2940U2 OEM aic7891   PCI/64
+   AHA-2940U2W    aic7890   PCI/32      LVD-HD68F       LVD-HD68F
+                                        SE-HD68F 
+                                         SE-50M
+   AHA-2950U2B    aic7891   PCI/64      LVD-HD68F       LVD-HD68F
+   AHA-2930U2     aic7890   PCI/32      LVD-HD68F       SE-HD50F
+                                         SE-50M 
+   AHA-3950U2B    aic7897   PCI/64
+   AHA-3950U2D    aic7897   PCI/64
+   AHA-29160      aic7892   PCI/64-66
+   AHA-29160 CPQ  aic7892   PCI/64-66
+   AHA-29160N     aic7892   PCI/32      LVD-HD68F       SE-HD50F
+                                         SE-50M
+   AHA-29160LP    aic7892   PCI/64-66
+   AHA-19160      aic7892   PCI/64-66
+   AHA-29150LP    aic7892   PCI/64-66
+   AHA-29130LP    aic7892   PCI/64-66
+   AHA-3960D      aic7899   PCI/64-66  2 X LVD-HD68F  2 X LVD-VHD68F
+                                         LVD-50M
+   AHA-3960D CPQ  aic7899   PCI/64-66  2 X LVD-HD68F  2 X LVD-VHD68F
+                                         LVD-50M
+   AHA-39160      aic7899   PCI/64-66  2 X LVD-HD68F  2 X LVD-VHD68F
+                                         LVD-50M
+
+   1. No BIOS support
+   2. DEC21050 PCI-PCI bridge with multiple controller chips on secondary bus
+   3. DEC2115X PCI-PCI bridge with multiple controller chips on secondary bus
+   4. All three SCSI connectors may be used simultaneously without
+      SCSI "stub" effects.
+
+2. Version History
+   6.2.36 (June 3rd, 2003)
+        - Correct code that disables PCI parity error checking.
+        - Correct and simplify handling of the ignore wide residue
+          message.  The previous code would fail to report a residual
+          if the transaction data length was even and we received
+          an IWR message.
+        - Add support for the 2.5.X EISA framework.
+        - Update for change in 2.5.X SCSI proc FS interface.
+        - Correct Domain Validation command-line option parsing.
+        - When negotiation async via an 8bit WDTR message, send
+          an SDTR with an offset of 0 to be sure the target
+          knows we are async.  This works around a firmware defect
+          in the Quantum Atlas 10K.
+        - Clear PCI error state during driver attach so that we
+          don't disable memory mapped I/O due to a stray write
+          by some other driver probe that occurred before we
+          claimed the controller.
+
+   6.2.35 (May 14th, 2003)
+        - Fix a few GCC 3.3 compiler warnings.
+        - Correct operation on EISA Twin Channel controller.
+        - Add support for 2.5.X's scsi_report_device_reset().
+
+   6.2.34 (May 5th, 2003)
+        - Fix locking regression instroduced in 6.2.29 that
+          could cuase a lock order reversal between the io_request_lock
+          and our per-softc lock.  This was only possible on RH9,
+          SuSE, and kernel.org 2.4.X kernels.
+
+   6.2.33 (April 30th, 2003)
+        - Dynamically disable PCI parity error reporting after
+          10 errors are reported to the user.  These errors are
+          the result of some other device issuing PCI transactions
+          with bad parity.  Once the user has been informed of the
+          problem, continuing to report the errors just degrades
+          our performance.
+
+   6.2.32 (March 28th, 2003)
+        - Dynamically sized S/G lists to avoid SCSI malloc
+          pool fragmentation and SCSI mid-layer deadlock.
+
+   6.2.28 (January 20th, 2003)
+        - Domain Validation Fixes
+        - Add ability to disable PCI parity error checking.
+        - Enhanced Memory Mapped I/O probe
+
+   6.2.20 (November 7th, 2002)
+        - Added Domain Validation.
+
+3. Command Line Options
+
+        WARNING: ALTERING OR ADDING THESE DRIVER PARAMETERS
+                 INCORRECTLY CAN RENDER YOUR SYSTEM INOPERABLE.
+                 USE THEM WITH CAUTION. 
+
+   Edit the file "modules.conf" in the directory /etc and add/edit a
+   line containing 'options aic7xxx aic7xxx=[command[,command...]]' where
+   'command' is one or more of the following:
+   -----------------------------------------------------------------
+              Option: verbose
+          Definition: enable additional informative messages during
+                      driver operation.
+     Possible Values: This option is a flag
+       Default Value: disabled
+   -----------------------------------------------------------------
+              Option: debug:[value]
+          Definition: Enables various levels of debugging information
+     Possible Values: 0x0000 = no debugging, 0xffff = full debugging
+       Default Value: 0x0000
+   -----------------------------------------------------------------
+              Option: no_probe
+              Option: probe_eisa_vl
+          Definition: Do not probe for EISA/VLB controllers.
+                      This is a toggle.  If the driver is compiled
+                      to not probe EISA/VLB controllers by default,
+                      specifying "no_probe" will enable this probing.
+                      If the driver is compiled to probe EISA/VLB
+                      controllers by default, specifying "no_probe"
+                      will disable this probing.
+     Possible Values: This option is a toggle
+       Default Value: EISA/VLB probing is disabled by default.
+   -----------------------------------------------------------------
+              Option: pci_parity
+          Definition: Toggles the detection of PCI parity errors.
+                      On many motherboards with VIA chipsets,
+                      PCI parity is not generated correctly on the
+                      PCI bus.  It is impossible for the hardware to
+                      differentiate between these "spurious" parity
+                      errors and real parity errors.  The symptom of
+                      this problem is a stream of the message:
+    "scsi0: Data Parity Error Detected during address or write data phase"
+                      output by the driver.
+     Possible Values: This option is a toggle
+       Default Value: PCI Parity Error reporting is disabled
+   -----------------------------------------------------------------
+              Option: no_reset
+          Definition: Do not reset the bus during the initial probe
+                      phase
+     Possible Values: This option is a flag
+       Default Value: disabled
+   -----------------------------------------------------------------
+              Option: extended
+          Definition: Force extended translation on the controller
+     Possible Values: This option is a flag
+       Default Value: disabled
+   -----------------------------------------------------------------
+              Option: periodic_otag
+          Definition: Send an ordered tag periodically to prevent
+                      tag starvation.  Needed for some older devices
+     Possible Values: This option is a flag
+       Default Value: disabled
+   -----------------------------------------------------------------
+              Option: reverse_scan
+          Definition: Probe the scsi bus in reverse order, starting
+                      with target 15
+     Possible Values: This option is a flag
+       Default Value: disabled
+   -----------------------------------------------------------------
+              Option: global_tag_depth:[value]
+          Definition: Global tag depth for all targets on all busses.
+                      This option sets the default tag depth which
+                      may be selectively overridden vi the tag_info
+                      option.
+     Possible Values: 1 - 253
+       Default Value: 32
+   -----------------------------------------------------------------
+              Option: tag_info:{{value[,value...]}[,{value[,value...]}...]}
+          Definition: Set the per-target tagged queue depth on a
+                      per controller basis.  Both controllers and targets
+                      may be ommitted indicating that they should retain
+                      the default tag depth.
+            Examples: tag_info:{{16,32,32,64,8,8,,32,32,32,32,32,32,32,32,32}
+                        On Controller 0
+                          specifies a tag depth of 16 for target 0
+                          specifies a tag depth of 64 for target 3
+                          specifies a tag depth of 8 for targets 4 and 5
+                          leaves target 6 at the default
+                          specifies a tag depth of 32 for targets 1,2,7-15
+                        All other targets retain the default depth.
+
+                      tag_info:{{},{32,,32}}
+                        On Controller 1
+                          specifies a tag depth of 32 for targets 0 and 2
+                        All other targets retain the default depth.
+                        
+     Possible Values: 1 - 253
+       Default Value: 32
+   -----------------------------------------------------------------
+              Option: seltime:[value]
+          Definition: Specifies the selection timeout value
+     Possible Values: 0 = 256ms, 1 = 128ms, 2 = 64ms, 3 = 32ms
+       Default Value: 0
+   -----------------------------------------------------------------
+              Option: dv: {value[,value...]} 
+          Definition: Set Domain Validation Policy on a per-controller basis.
+                      Controllers may be ommitted indicating that
+                      they should retain the default read streaming setting.
+             Example: dv:{-1,0,,1,1,0}
+                        On Controller 0 leave DV at its default setting.
+                        On Controller 1 disable DV.
+                        Skip configuration on Controller 2.
+                        On Controllers 3 and 4 enable DV.
+                        On Controller 5 disable DV.
+
+     Possible Values: < 0 Use setting from serial EEPROM.
+                      0 Disable DV
+                      > 0 Enable DV
+
+       Default Value: SCSI-Select setting on controllers with a SCSI Select
+                      option for DV.  Otherwise, on for controllers supporting
+                      U160 speeds and off for all other controller types.
+   -----------------------------------------------------------------
+
+   Example:
+   'options aic7xxx aic7xxx=verbose,no_probe,tag_info:{{},{,,10}},seltime:1"
+        enables verbose logging, Disable EISA/VLB probing,
+        and set tag depth on Controller 1/Target 2 to 10 tags.
+
+3. Contacting Adaptec
+
+   A Technical Support Identification (TSID) Number is required for 
+   Adaptec technical support.
+    - The 12-digit TSID can be found on the white barcode-type label
+      included inside the box with your product. The TSID helps us 
+      provide more efficient service by accurately identifying your 
+      product and support status.
+   Support Options
+    - Search the Adaptec Support Knowledgebase (ASK) at
+      http://ask.adaptec.com for articles, troubleshooting tips, and
+      frequently asked questions for your product.
+    - For support via Email, submit your question to Adaptec's 
+      Technical Support Specialists at http://ask.adaptec.com.
+     
+   North America
+    - Visit our Web site at http://www.adaptec.com.
+    - To speak with a Fibre Channel/RAID/External Storage Technical
+      Support Specialist, call 1-321-207-2000,
+      Hours: Monday-Friday, 3:00 A.M. to 5:00 P.M., PST.
+      (Not open on holidays)
+    - For Technical Support in all other technologies including 
+      SCSI, call 1-408-934-7274,
+      Hours: Monday-Friday, 6:00 A.M. to 5:00 P.M., PST.
+      (Not open on holidays)
+    - For after hours support, call 1-800-416-8066 ($99/call, 
+      $149/call on holidays)
+    - To order Adaptec products including software and cables, call
+      1-800-442-7274 or 1-408-957-7274. You can also visit our 
+      online store at http://www.adaptecstore.com
+
+   Europe
+    - Visit our Web site at http://www.adaptec-europe.com.
+    - English and French: To speak with a Technical Support 
+      Specialist, call one of the following numbers:
+        - English: +32-2-352-3470
+        - French:  +32-2-352-3460
+      Hours: Monday-Thursday, 10:00 to 12:30, 13:30 to 17:30 CET 
+             Friday, 10:00 to 12:30, 13:30 to 16:30 CET
+    - German: To speak with a Technical Support Specialist,
+      call +49-89-456-40660
+      Hours: Monday-Thursday, 09:30 to 12:30, 13:30 to 16:30 CET
+             Friday, 09:30 to 12:30, 13:30 to 15:00 CET
+    - To order Adaptec products, including accessories and cables:
+        - UK: +0800-96-65-26 or fax +0800-731-02-95
+        - Other European countries: +32-11-300-379
+
+   Australia and New Zealand
+    - Visit our Web site at http://www.adaptec.com.au.
+    - To speak with a Technical Support Specialist, call 
+      +612-9416-0698
+      Hours: Monday-Friday, 10:00 A.M. to 4:30 P.M., EAT
+      (Not open on holidays)
+
+   Japan
+    - To speak with a Technical Support Specialist, call 
+      +81-3-5308-6120 
+      Hours: Monday-Friday, 9:00 a.m. to 12:00 p.m., 1:00 p.m. to
+      6:00 p.m. TSC
+
+   Hong Kong and China
+    - To speak with a Technical Support Specialist, call 
+      +852-2869-7200
+      Hours: Monday-Friday, 10:00 to 17:00.
+    - Fax Technical Support at +852-2869-7100.
+
+   Singapore
+    - To speak with a Technical Support Specialist, call 
+      +65-245-7470
+      Hours: Monday-Friday, 10:00 to 17:00.
+    - Fax Technical Support at +852-2869-7100
+
+-------------------------------------------------------------------
+/*
+ * Copyright (c) 2003 Adaptec Inc. 691 S. Milpitas Blvd., Milpitas CA 95035 USA.
+ * All rights reserved.
+ *
+ * You are permitted to redistribute, use and modify this README file in whole
+ * or in part in conjunction with redistribution of software governed by the
+ * General Public License, provided that the following conditions are met:
+ * 1. Redistributions of README file must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ * 3. Modifications or new contributions must be attributed in a copyright
+ *    notice identifying the author ("Contributor") and added below the
+ *    original copyright notice. The copyright notice is for purposes of
+ *    identifying contributors and should not be deemed as permission to alter
+ *    the permissions given by Adaptec.
+ *
+ * THIS README FILE IS PROVIDED BY ADAPTEC AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ANY
+ * WARRANTIES OF NON-INFRINGEMENT OR THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * ADAPTEC 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 README
+ * FILE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic7770.c linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7770.c
--- linux-2.4.21/drivers/scsi/aic7xxx/aic7770.c	2002-11-28 23:53:14.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7770.c	2003-06-26 21:43:33.000000000 +0000
@@ -37,9 +37,9 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic7770.c#21 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic7770.c#32 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic7770.c,v 1.1 2000/09/16 20:02:27 gibbs Exp $
+ * $FreeBSD$
  */
 
 #ifdef __linux__
@@ -56,14 +56,18 @@
 #define ID_AHA_274x	0x04907771
 #define ID_AHA_284xB	0x04907756 /* BIOS enabled */
 #define ID_AHA_284x	0x04907757 /* BIOS disabled*/
+#define	ID_OLV_274x	0x04907782 /* Olivetti OEM */
+#define	ID_OLV_274xD	0x04907783 /* Olivetti OEM (Differential) */
 
+static int aic7770_chip_init(struct ahc_softc *ahc);
+static int aic7770_suspend(struct ahc_softc *ahc);
+static int aic7770_resume(struct ahc_softc *ahc);
 static int aha2840_load_seeprom(struct ahc_softc *ahc);
 static ahc_device_setup_t ahc_aic7770_VL_setup;
 static ahc_device_setup_t ahc_aic7770_EISA_setup;;
 static ahc_device_setup_t ahc_aic7770_setup;
 
-
-struct aic7770_identity aic7770_ident_table [] =
+struct aic7770_identity aic7770_ident_table[] =
 {
 	{
 		ID_AHA_274x,
@@ -77,6 +81,24 @@
 		"Adaptec 284X SCSI adapter",
 		ahc_aic7770_VL_setup
 	},
+	{
+		ID_AHA_284x,
+		0xFFFFFFFE,
+		"Adaptec 284X SCSI adapter (BIOS Disabled)",
+		ahc_aic7770_VL_setup
+	},
+	{
+		ID_OLV_274x,
+		0xFFFFFFFF,
+		"Adaptec (Olivetti OEM) 274X SCSI adapter",
+		ahc_aic7770_EISA_setup
+	},
+	{
+		ID_OLV_274xD,
+		0xFFFFFFFF,
+		"Adaptec (Olivetti OEM) 274X Differential SCSI adapter",
+		ahc_aic7770_EISA_setup
+	},
 	/* Generic chip probes for devices we don't know 'exactly' */
 	{
 		ID_AIC7770,
@@ -105,7 +127,6 @@
 aic7770_config(struct ahc_softc *ahc, struct aic7770_identity *entry, u_int io)
 {
 	u_long	l;
-	u_long	s;
 	int	error;
 	int	have_seeprom;
 	u_int	hostconf;
@@ -131,8 +152,14 @@
 
 	ahc->description = entry->name;
 	error = ahc_softc_init(ahc);
+	if (error != 0)
+		return (error);
 
-	error = ahc_reset(ahc);
+	ahc->bus_chip_init = aic7770_chip_init;
+	ahc->bus_suspend = aic7770_suspend;
+	ahc->bus_resume = aic7770_resume;
+
+	error = ahc_reset(ahc, /*reinit*/FALSE);
 	if (error != 0)
 		return (error);
 
@@ -213,6 +240,9 @@
 	ahc_outb(ahc, BUSSPD, hostconf & DFTHRSH);
 	ahc_outb(ahc, BUSTIME, (hostconf << 2) & BOFF);
 
+	ahc->bus_softc.aic7770_softc.busspd = hostconf & DFTHRSH;
+	ahc->bus_softc.aic7770_softc.bustime = (hostconf << 2) & BOFF;
+
 	/*
 	 * Generic aic7xxx initialization.
 	 */
@@ -235,18 +265,33 @@
 	 */
 	ahc_outb(ahc, BCTL, ENABLE);
 
-	/*
-	 * Allow interrupts.
-	 */
-	ahc_lock(ahc, &s);
-	ahc_intr_enable(ahc, TRUE);
-	ahc_unlock(ahc, &s);
-
 	ahc_list_unlock(&l);
 
 	return (0);
 }
 
+static int
+aic7770_chip_init(struct ahc_softc *ahc)
+{
+	ahc_outb(ahc, BUSSPD, ahc->bus_softc.aic7770_softc.busspd);
+	ahc_outb(ahc, BUSTIME, ahc->bus_softc.aic7770_softc.bustime);
+	ahc_outb(ahc, SBLKCTL, ahc_inb(ahc, SBLKCTL) & ~AUTOFLUSHDIS);
+	ahc_outb(ahc, BCTL, ENABLE);
+	return (ahc_chip_init(ahc));
+}
+
+static int
+aic7770_suspend(struct ahc_softc *ahc)
+{
+	return (ahc_suspend(ahc));
+}
+
+static int
+aic7770_resume(struct ahc_softc *ahc)
+{
+	return (ahc_resume(ahc));
+}
+
 /*
  * Read the 284x SEEPROM.
  */
@@ -365,5 +410,6 @@
 	ahc->features = AHC_AIC7770_FE;
 	ahc->bugs |= AHC_TMODE_WIDEODD_BUG;
 	ahc->flags |= AHC_PAGESCBS;
+	ahc->instruction_ram_size = 448;
 	return (0);
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic7770_osm.c linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7770_osm.c
--- linux-2.4.21/drivers/scsi/aic7xxx/aic7770_osm.c	2002-08-03 00:39:44.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7770_osm.c	2003-06-26 21:43:16.000000000 +0000
@@ -1,7 +1,7 @@
 /*
  * Linux driver attachment glue for aic7770 based controllers.
  *
- * Copyright (c) 2000-2001 Adaptec Inc.
+ * Copyright (c) 2000-2003 Adaptec Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -36,33 +36,102 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7770_osm.c#11 $
+ * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7770_osm.c#14 $
  */
 
 #include "aic7xxx_osm.h"
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+#include <linux/device.h>
+#include <linux/eisa.h>
+
+#define EISA_MFCTR_CHAR0(ID) (char)(((ID>>26) & 0x1F) | '@')  /* Bits 26-30 */
+#define EISA_MFCTR_CHAR1(ID) (char)(((ID>>21) & 0x1F) | '@')  /* Bits 21-25 */
+#define EISA_MFCTR_CHAR2(ID) (char)(((ID>>16) & 0x1F) | '@')  /* Bits 16-20 */
+#define EISA_PRODUCT_ID(ID)  (short)((ID>>4)  & 0xFFF)        /* Bits  4-15 */
+#define EISA_REVISION_ID(ID) (uint8_t)(ID & 0x0F)             /* Bits  0-3  */
+
+static int aic7770_eisa_dev_probe(struct device *dev);
+static int aic7770_eisa_dev_remove(struct device *dev);
+static struct eisa_driver aic7770_driver = {
+	.driver = {
+		.name   = "aic7xxx",
+		.probe  = aic7770_eisa_dev_probe,
+		.remove = aic7770_eisa_dev_remove,
+	}
+};
+
+typedef  struct device *aic7770_dev_t;
+#else
 #define MINSLOT			1
 #define NUMSLOTS		16
 #define IDOFFSET		0x80
 
-int
-aic7770_linux_probe(Scsi_Host_Template *template)
+typedef void *aic7770_dev_t;
+#endif
+
+static int aic7770_linux_config(struct aic7770_identity *entry,
+				aic7770_dev_t dev, u_int eisaBase);
+
+void
+ahc_linux_eisa_init(void)
 {
-#if defined(__i386__) || defined(__alpha__)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+	struct eisa_device_id *eid;
+	struct aic7770_identity *id;
+	int i;
+
+	if (aic7xxx_probe_eisa_vl == 0)
+		return;
+
+	/*
+	 * Linux requires the EISA IDs to be specified in
+	 * the EISA ID string format.  Perform the conversion
+	 * and setup a table with a NUL terminal entry.
+	 */
+	aic7770_driver.id_table = malloc(sizeof(struct eisa_device_id) *
+					 (ahc_num_aic7770_devs + 1),
+					 M_DEVBUF, M_NOWAIT);
+	if (aic7770_driver.id_table == NULL)
+		return;
+
+	for (eid = (struct eisa_device_id *)aic7770_driver.id_table,
+	     id = aic7770_ident_table, i = 0;
+	     i < ahc_num_aic7770_devs; eid++, id++, i++) {
+
+		sprintf(eid->sig, "%c%c%c%03X%01X",
+			EISA_MFCTR_CHAR0(id->full_id),
+			EISA_MFCTR_CHAR1(id->full_id),
+			EISA_MFCTR_CHAR2(id->full_id),
+			EISA_PRODUCT_ID(id->full_id),
+			EISA_REVISION_ID(id->full_id));
+		eid->driver_data = i;
+	}
+	eid->sig[0] = 0;
+
+	eisa_driver_register(&aic7770_driver);
+#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) */
 	struct aic7770_identity *entry;
-	struct ahc_softc *ahc;
-	int i, slot;
-	int eisaBase;
-	int found;
+	u_int  slot;
+	u_int  eisaBase;
+	u_int  i;
+
+	if (aic7xxx_probe_eisa_vl == 0)
+		return;
 
 	eisaBase = 0x1000 + AHC_EISA_SLOT_OFFSET;
-	found = 0;
 	for (slot = 1; slot < NUMSLOTS; eisaBase+=0x1000, slot++) {
 		uint32_t eisa_id;
 		size_t	 id_size;
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
 		if (check_region(eisaBase, AHC_EISA_IOSIZE) != 0)
 			continue;
+		request_region(eisaBase, AHC_EISA_IOSIZE, "aic7xxx");
+#else
+		if (request_region(eisaBase, AHC_EISA_IOSIZE, "aic7xxx") == 0)
+			continue;
+#endif
 
 		eisa_id = 0;
 		id_size = sizeof(eisa_id);
@@ -72,49 +141,69 @@
 			eisa_id |= inb(eisaBase + IDOFFSET + i)
 				   << ((id_size-i-1) * 8);
 		}
+		release_region(eisaBase, AHC_EISA_IOSIZE);
 		if (eisa_id & 0x80000000)
 			continue;  /* no EISA card in slot */
 
 		entry = aic7770_find_device(eisa_id);
-		if (entry != NULL) {
-			char	 buf[80];
-			char	*name;
-			int	 error;
-
-			/*
-			 * Allocate a softc for this card and
-			 * set it up for attachment by our
-			 * common detect routine.
-			 */
-			sprintf(buf, "ahc_eisa:%d", slot);
-			name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT);
-			if (name == NULL)
-				break;
-			strcpy(name, buf);
-			ahc = ahc_alloc(template, name);
-			if (ahc == NULL) {
-				/*
-				 * If we can't allocate this one,
-				 * chances are we won't be able to
-				 * allocate future card structures.
-				 */
-				break;
-			}
-			error = aic7770_config(ahc, entry, eisaBase);
-			if (error != 0) {
-				ahc->bsh.ioport = 0;
-				ahc_free(ahc);
-				continue;
-			}
-			found++;
-		}
+		if (entry != NULL)
+			aic7770_linux_config(entry, NULL, eisaBase);
+	}
+#endif
+}
+
+void
+ahc_linux_eisa_exit(void)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+	if (aic7xxx_probe_eisa_vl == 0)
+		return;
+
+	if (aic7770_driver.id_table != NULL) {
+		eisa_driver_unregister(&aic7770_driver);
+		free(aic7770_driver.id_table, M_DEVBUF);
 	}
-	return (found);
-#else
-	return (0);
 #endif
 }
 
+static int
+aic7770_linux_config(struct aic7770_identity *entry, aic7770_dev_t dev,
+		     u_int eisaBase)
+{
+	struct	ahc_softc *ahc;
+	char	buf[80];
+	char   *name;
+	int	error;
+
+	/*
+	 * Allocate a softc for this card and
+	 * set it up for attachment by our
+	 * common detect routine.
+	 */
+	sprintf(buf, "ahc_eisa:%d", eisaBase >> 12);
+	name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT);
+	if (name == NULL)
+		return (ENOMEM);
+	strcpy(name, buf);
+	ahc = ahc_alloc(&aic7xxx_driver_template, name);
+	if (ahc == NULL) {
+		free(name, M_DEVBUF);
+		return (ENOMEM);
+	}
+	error = aic7770_config(ahc, entry, eisaBase);
+	if (error != 0) {
+		ahc->bsh.ioport = 0;
+		ahc_free(ahc);
+		return (error);
+	}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+	dev->driver_data = (void *)ahc;
+	if (aic7xxx_detect_complete)
+		error = ahc_linux_register_host(ahc, &aic7xxx_driver_template);
+#endif
+	return (error);
+}
+
 int
 aic7770_map_registers(struct ahc_softc *ahc, u_int port)
 {
@@ -122,6 +211,8 @@
 	 * Lock out other contenders for our i/o space.
 	 */
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
+	if (check_region(port, AHC_EISA_IOSIZE) != 0)
+		return (ENOMEM);
 	request_region(port, AHC_EISA_IOSIZE, "aic7xxx");
 #else
 	if (request_region(port, AHC_EISA_IOSIZE, "aic7xxx") == 0)
@@ -148,3 +239,41 @@
 	
 	return (-error);
 }
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+static int
+aic7770_eisa_dev_probe(struct device *dev)
+{
+	struct eisa_device *edev;
+
+	edev = to_eisa_device(dev);
+	return (aic7770_linux_config(aic7770_ident_table + edev->id.driver_data,
+				    dev, edev->base_addr+AHC_EISA_SLOT_OFFSET));
+}
+
+static int
+aic7770_eisa_dev_remove(struct device *dev)
+{
+	struct ahc_softc *ahc;
+	u_long l;
+
+	/*
+	 * We should be able to just perform
+	 * the free directly, but check our
+	 * list for extra sanity.
+	 */
+	ahc_list_lock(&l);
+	ahc = ahc_find_softc((struct ahc_softc *)dev->driver_data);
+	if (ahc != NULL) {
+		u_long s;
+
+		ahc_lock(ahc, &s);
+		ahc_intr_enable(ahc, FALSE);
+		ahc_unlock(ahc, &s);
+		ahc_free(ahc);
+	}
+	ahc_list_unlock(&l);
+
+	return (0);
+}
+#endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic79xx.h linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx.h
--- linux-2.4.21/drivers/scsi/aic7xxx/aic79xx.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx.h	2003-06-26 21:43:16.000000000 +0000
@@ -0,0 +1,1534 @@
+/*
+ * Core definitions and data structures shareable across OS platforms.
+ *
+ * Copyright (c) 1994-2002 Justin T. Gibbs.
+ * Copyright (c) 2000-2002 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: //depot/aic7xxx/aic7xxx/aic79xx.h#92 $
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _AIC79XX_H_
+#define _AIC79XX_H_
+
+/* Register Definitions */
+#include "aic79xx_reg.h"
+
+/************************* Forward Declarations *******************************/
+struct ahd_platform_data;
+struct scb_platform_data;
+
+/****************************** Useful Macros *********************************/
+#ifndef MAX
+#define MAX(a,b) (((a) > (b)) ? (a) : (b))
+#endif
+
+#ifndef MIN
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#define NUM_ELEMENTS(array) (sizeof(array) / sizeof(*array))
+
+#define ALL_CHANNELS '\0'
+#define ALL_TARGETS_MASK 0xFFFF
+#define INITIATOR_WILDCARD	(~0)
+#define	SCB_LIST_NULL		0xFF00
+#define	SCB_LIST_NULL_LE	(ahd_htole16(SCB_LIST_NULL))
+#define QOUTFIFO_ENTRY_VALID 0x8000
+#define QOUTFIFO_ENTRY_VALID_LE (ahd_htole16(0x8000))
+#define SCBID_IS_NULL(scbid) (((scbid) & 0xFF00 ) == SCB_LIST_NULL)
+
+#define SCSIID_TARGET(ahd, scsiid)	\
+	(((scsiid) & TID) >> TID_SHIFT)
+#define SCSIID_OUR_ID(scsiid)		\
+	((scsiid) & OID)
+#define SCSIID_CHANNEL(ahd, scsiid) ('A')
+#define	SCB_IS_SCSIBUS_B(ahd, scb) (0)
+#define	SCB_GET_OUR_ID(scb) \
+	SCSIID_OUR_ID((scb)->hscb->scsiid)
+#define	SCB_GET_TARGET(ahd, scb) \
+	SCSIID_TARGET((ahd), (scb)->hscb->scsiid)
+#define	SCB_GET_CHANNEL(ahd, scb) \
+	SCSIID_CHANNEL(ahd, (scb)->hscb->scsiid)
+#define	SCB_GET_LUN(scb) \
+	((scb)->hscb->lun)
+#define SCB_GET_TARGET_OFFSET(ahd, scb)	\
+	SCB_GET_TARGET(ahd, scb)
+#define SCB_GET_TARGET_MASK(ahd, scb) \
+	(0x01 << (SCB_GET_TARGET_OFFSET(ahd, scb)))
+#ifdef AHD_DEBUG
+#define SCB_IS_SILENT(scb)					\
+	((ahd_debug & AHD_SHOW_MASKED_ERRORS) == 0		\
+      && (((scb)->flags & SCB_SILENT) != 0))
+#else
+#define SCB_IS_SILENT(scb)					\
+	(((scb)->flags & SCB_SILENT) != 0)
+#endif
+/*
+ * TCLs have the following format: TTTTLLLLLLLL
+ */
+#define TCL_TARGET_OFFSET(tcl) \
+	((((tcl) >> 4) & TID) >> 4)
+#define TCL_LUN(tcl) \
+	(tcl & (AHD_NUM_LUNS - 1))
+#define BUILD_TCL(scsiid, lun) \
+	((lun) | (((scsiid) & TID) << 4))
+#define BUILD_TCL_RAW(target, channel, lun) \
+	((lun) | ((target) << 8))
+
+#define SCB_GET_TAG(scb) \
+	ahd_le16toh(scb->hscb->tag)
+
+#ifndef	AHD_TARGET_MODE
+#undef	AHD_TMODE_ENABLE
+#define	AHD_TMODE_ENABLE 0
+#endif
+
+#define AHD_BUILD_COL_IDX(target, lun)				\
+	(((lun) << 4) | target)
+
+#define AHD_GET_SCB_COL_IDX(ahd, scb)				\
+	((SCB_GET_LUN(scb) << 4) | SCB_GET_TARGET(ahd, scb))
+
+#define AHD_SET_SCB_COL_IDX(scb, col_idx)				\
+do {									\
+	(scb)->hscb->scsiid = ((col_idx) << TID_SHIFT) & TID;		\
+	(scb)->hscb->lun = ((col_idx) >> 4) & (AHD_NUM_LUNS_NONPKT-1);	\
+} while (0)
+
+#define AHD_COPY_SCB_COL_IDX(dst, src)				\
+do {								\
+	dst->hscb->scsiid = src->hscb->scsiid;			\
+	dst->hscb->lun = src->hscb->lun;			\
+} while (0)
+
+#define	AHD_NEVER_COL_IDX 0xFFFF
+
+/**************************** Driver Constants ********************************/
+/*
+ * The maximum number of supported targets.
+ */
+#define AHD_NUM_TARGETS 16
+
+/*
+ * The maximum number of supported luns.
+ * The identify message only supports 64 luns in non-packetized transfers.
+ * You can have 2^64 luns when information unit transfers are enabled,
+ * but until we see a need to support that many, we support 256.
+ */
+#define AHD_NUM_LUNS_NONPKT 64
+#define AHD_NUM_LUNS 256
+
+/*
+ * The maximum transfer per S/G segment.
+ */
+#define AHD_MAXTRANSFER_SIZE	 0x00ffffff	/* limited by 24bit counter */
+
+/*
+ * The maximum amount of SCB storage in hardware on a controller.
+ * This value represents an upper bound.  Due to software design,
+ * we may not be able to use this number.
+ */
+#define AHD_SCB_MAX	512
+
+/*
+ * The maximum number of concurrent transactions supported per driver instance.
+ * Sequencer Control Blocks (SCBs) store per-transaction information.
+ */
+#define AHD_MAX_QUEUE	AHD_SCB_MAX
+
+/*
+ * Define the size of our QIN and QOUT FIFOs.  They must be a power of 2
+ * in size and accommodate as many transactions as can be queued concurrently.
+ */
+#define	AHD_QIN_SIZE	AHD_MAX_QUEUE
+#define	AHD_QOUT_SIZE	AHD_MAX_QUEUE
+
+#define AHD_QIN_WRAP(x) ((x) & (AHD_QIN_SIZE-1))
+/*
+ * The maximum amount of SCB storage we allocate in host memory.
+ */
+#define AHD_SCB_MAX_ALLOC AHD_MAX_QUEUE
+
+/*
+ * Ring Buffer of incoming target commands.
+ * We allocate 256 to simplify the logic in the sequencer
+ * by using the natural wrap point of an 8bit counter.
+ */
+#define AHD_TMODE_CMDS	256
+
+/* Reset line assertion time in us */
+#define AHD_BUSRESET_DELAY	25
+
+/******************* Chip Characteristics/Operating Settings  *****************/
+/*
+ * Chip Type
+ * The chip order is from least sophisticated to most sophisticated.
+ */
+typedef enum {
+	AHD_NONE	= 0x0000,
+	AHD_CHIPID_MASK	= 0x00FF,
+	AHD_AIC7901	= 0x0001,
+	AHD_AIC7902	= 0x0002,
+	AHD_AIC7901A	= 0x0003,
+	AHD_PCI		= 0x0100,	/* Bus type PCI */
+	AHD_PCIX	= 0x0200,	/* Bus type PCIX */
+	AHD_BUS_MASK	= 0x0F00
+} ahd_chip;
+
+/*
+ * Features available in each chip type.
+ */
+typedef enum {
+	AHD_FENONE		= 0x00000,
+	AHD_WIDE  		= 0x00001,/* Wide Channel */
+	AHD_MULTI_FUNC		= 0x00100,/* Multi-Function/Channel Device */
+	AHD_TARGETMODE		= 0x01000,/* Has tested target mode support */
+	AHD_MULTIROLE		= 0x02000,/* Space for two roles at a time */
+	AHD_RTI			= 0x04000,/* Retained Training Support */
+	AHD_NEW_IOCELL_OPTS	= 0x08000,/* More Signal knobs in the IOCELL */
+	AHD_NEW_DFCNTRL_OPTS	= 0x10000,/* SCSIENWRDIS bit */
+	AHD_REMOVABLE		= 0x00000,/* Hot-Swap supported - None so far*/
+	AHD_AIC7901_FE		= AHD_FENONE,
+	AHD_AIC7902_FE		= AHD_MULTI_FUNC
+} ahd_feature;
+
+/*
+ * Bugs in the silicon that we work around in software.
+ */
+typedef enum {
+	AHD_BUGNONE		= 0x0000,
+	/*
+	 * Rev A hardware fails to update LAST/CURR/NEXTSCB
+	 * correctly in certain packetized selection cases.
+	 */
+	AHD_SENT_SCB_UPDATE_BUG	= 0x0001,
+	/* The wrong SCB is accessed to check the abort pending bit. */
+	AHD_ABORT_LQI_BUG	= 0x0002,
+	/* Packetized bitbucket crosses packet boundaries. */
+	AHD_PKT_BITBUCKET_BUG	= 0x0004,
+	/* The selection timer runs twice as long as its setting. */
+	AHD_LONG_SETIMO_BUG	= 0x0008,
+	/* The Non-LQ CRC error status is delayed until phase change. */
+	AHD_NLQICRC_DELAYED_BUG	= 0x0010,
+	/* The chip must be reset for all outgoing bus resets.  */
+	AHD_SCSIRST_BUG		= 0x0020,
+	/* Some PCIX fields must be saved and restored across chip reset. */
+	AHD_PCIX_CHIPRST_BUG	= 0x0040,
+	/* MMAPIO is not functional in PCI-X mode.  */
+	AHD_PCIX_MMAPIO_BUG	= 0x0080,
+	/* Reads to SCBRAM fail to reset the discard timer. */
+	AHD_PCIX_SCBRAM_RD_BUG  = 0x0100,
+	/* Bug workarounds that can be disabled on non-PCIX busses. */
+	AHD_PCIX_BUG_MASK	= AHD_PCIX_CHIPRST_BUG
+				| AHD_PCIX_MMAPIO_BUG
+				| AHD_PCIX_SCBRAM_RD_BUG,
+	/*
+	 * LQOSTOP0 status set even for forced selections with ATN
+	 * to perform non-packetized message delivery.
+	 */
+	AHD_LQO_ATNO_BUG	= 0x0200,
+	/* FIFO auto-flush does not always trigger.  */
+	AHD_AUTOFLUSH_BUG	= 0x0400,
+	/* The CLRLQO registers are not self-clearing. */
+	AHD_CLRLQO_AUTOCLR_BUG	= 0x0800,
+	/* The PACKETIZED status bit refers to the previous connection. */
+	AHD_PKTIZED_STATUS_BUG  = 0x1000,
+	/* "Short Luns" are not placed into outgoing LQ packets correctly. */
+	AHD_PKT_LUN_BUG		= 0x2000,
+	/*
+	 * Only the FIFO allocated to the non-packetized connection may
+	 * be in use during a non-packetzied connection.
+	 */
+	AHD_NONPACKFIFO_BUG	= 0x4000,
+	/*
+	 * Writing to a DFF SCBPTR register may fail if concurent with
+	 * a hardware write to the other DFF SCBPTR register.  This is
+	 * not currently a concern in our sequencer since all chips with
+	 * this bug have the AHD_NONPACKFIFO_BUG and all writes of concern
+	 * occur in non-packetized connections.
+	 */
+	AHD_MDFF_WSCBPTR_BUG	= 0x8000,
+	/* SGHADDR updates are slow. */
+	AHD_REG_SLOW_SETTLE_BUG	= 0x10000,
+	/*
+	 * Changing the MODE_PTR coincident with an interrupt that
+	 * switches to a different mode will cause the interrupt to
+	 * be in the mode written outside of interrupt context.
+	 */
+	AHD_SET_MODE_BUG	= 0x20000,
+	/* Non-packetized busfree revision does not work. */
+	AHD_BUSFREEREV_BUG	= 0x40000,
+	/*
+	 * Paced transfers are indicated with a non-standard PPR
+	 * option bit in the neg table, 160MHz is indicated by
+	 * sync factor 0x7, and the offset if off by a factor of 2.
+	 */
+	AHD_PACED_NEGTABLE_BUG	= 0x80000,
+	/* LQOOVERRUN false positives. */
+	AHD_LQOOVERRUN_BUG	= 0x100000,
+	/*
+	 * Controller write to INTSTAT will lose to a host
+	 * write to CLRINT.
+	 */
+	AHD_INTCOLLISION_BUG	= 0x200000,
+	/*
+	 * The GEM318 violates the SCSI spec by not waiting
+	 * the mandated bus settle delay between phase changes
+	 * in some situations.  Some aic79xx chip revs. are more
+	 * strict in this regard and will treat REQ assertions
+	 * that fall within the bus settle delay window as
+	 * glitches.  This flag tells the firmware to tolerate
+	 * early REQ assertions.
+	 */
+	AHD_EARLY_REQ_BUG	= 0x400000,
+	/*
+	 * The LED does not stay on long enough in packetized modes.
+	 */
+	AHD_FAINT_LED_BUG	= 0x800000
+} ahd_bug;
+
+/*
+ * Configuration specific settings.
+ * The driver determines these settings by probing the
+ * chip/controller's configuration.
+ */
+typedef enum {
+	AHD_FNONE	      = 0x00000,
+	AHD_BOOT_CHANNEL      = 0x00001,/* We were set as the boot channel. */
+	AHD_USEDEFAULTS	      = 0x00004,/*
+					 * For cards without an seeprom
+					 * or a BIOS to initialize the chip's
+					 * SRAM, we use the default target
+					 * settings.
+					 */
+	AHD_SEQUENCER_DEBUG   = 0x00008,
+	AHD_RESET_BUS_A	      = 0x00010,
+	AHD_EXTENDED_TRANS_A  = 0x00020,
+	AHD_TERM_ENB_A	      = 0x00040,
+	AHD_SPCHK_ENB_A	      = 0x00080,
+	AHD_STPWLEVEL_A	      = 0x00100,
+	AHD_INITIATORROLE     = 0x00200,/*
+					 * Allow initiator operations on
+					 * this controller.
+					 */
+	AHD_TARGETROLE	      = 0x00400,/*
+					 * Allow target operations on this
+					 * controller.
+					 */
+	AHD_RESOURCE_SHORTAGE = 0x00800,
+	AHD_TQINFIFO_BLOCKED  = 0x01000,/* Blocked waiting for ATIOs */
+	AHD_INT50_SPEEDFLEX   = 0x02000,/*
+					 * Internal 50pin connector
+					 * sits behind an aic3860
+					 */
+	AHD_BIOS_ENABLED      = 0x04000,
+	AHD_ALL_INTERRUPTS    = 0x08000,
+	AHD_39BIT_ADDRESSING  = 0x10000,/* Use 39 bit addressing scheme. */
+	AHD_64BIT_ADDRESSING  = 0x20000,/* Use 64 bit addressing scheme. */
+	AHD_CURRENT_SENSING   = 0x40000,
+	AHD_SCB_CONFIG_USED   = 0x80000,/* No SEEPROM but SCB had info. */
+	AHD_HP_BOARD	      = 0x100000,
+	AHD_RESET_POLL_ACTIVE = 0x200000,
+	AHD_UPDATE_PEND_CMDS  = 0x400000,
+	AHD_RUNNING_QOUTFIFO  = 0x800000
+} ahd_flag;
+
+/************************* Hardware  SCB Definition ***************************/
+
+/*
+ * The driver keeps up to MAX_SCB scb structures per card in memory.  The SCB
+ * consists of a "hardware SCB" mirroring the fields available on the card
+ * and additional information the kernel stores for each transaction.
+ *
+ * To minimize space utilization, a portion of the hardware scb stores
+ * different data during different portions of a SCSI transaction.
+ * As initialized by the host driver for the initiator role, this area
+ * contains the SCSI cdb (or a pointer to the  cdb) to be executed.  After
+ * the cdb has been presented to the target, this area serves to store
+ * residual transfer information and the SCSI status byte.
+ * For the target role, the contents of this area do not change, but
+ * still serve a different purpose than for the initiator role.  See
+ * struct target_data for details.
+ */
+
+/*
+ * Status information embedded in the shared poriton of
+ * an SCB after passing the cdb to the target.  The kernel
+ * driver will only read this data for transactions that
+ * complete abnormally.
+ */
+struct initiator_status {
+	uint32_t residual_datacnt;	/* Residual in the current S/G seg */
+	uint32_t residual_sgptr;	/* The next S/G for this transfer */
+	uint8_t	 scsi_status;		/* Standard SCSI status byte */
+};
+
+struct target_status {
+	uint32_t residual_datacnt;	/* Residual in the current S/G seg */
+	uint32_t residual_sgptr;	/* The next S/G for this transfer */
+	uint8_t  scsi_status;		/* SCSI status to give to initiator */
+	uint8_t  target_phases;		/* Bitmap of phases to execute */
+	uint8_t  data_phase;		/* Data-In or Data-Out */
+	uint8_t  initiator_tag;		/* Initiator's transaction tag */
+};
+
+/*
+ * Initiator mode SCB shared data area.
+ * If the embedded CDB is 12 bytes or less, we embed
+ * the sense buffer address in the SCB.  This allows
+ * us to retrieve sense information without interrupting
+ * the host in packetized mode.
+ */
+typedef uint32_t sense_addr_t;
+#define MAX_CDB_LEN 16
+#define MAX_CDB_LEN_WITH_SENSE_ADDR (MAX_CDB_LEN - sizeof(sense_addr_t))
+union initiator_data {
+	struct {
+		uint64_t cdbptr;
+		uint8_t  cdblen;
+	} cdb_from_host;
+	uint8_t	 cdb[MAX_CDB_LEN];
+	struct {
+		uint8_t	 cdb[MAX_CDB_LEN_WITH_SENSE_ADDR];
+		sense_addr_t sense_addr;
+	} cdb_plus_saddr;
+};
+
+/*
+ * Target mode version of the shared data SCB segment.
+ */
+struct target_data {
+	uint32_t spare[2];	
+	uint8_t  scsi_status;		/* SCSI status to give to initiator */
+	uint8_t  target_phases;		/* Bitmap of phases to execute */
+	uint8_t  data_phase;		/* Data-In or Data-Out */
+	uint8_t  initiator_tag;		/* Initiator's transaction tag */
+};
+
+struct hardware_scb {
+/*0*/	union {
+		union	initiator_data idata;
+		struct	target_data tdata;
+		struct	initiator_status istatus;
+		struct	target_status tstatus;
+	} shared_data;
+/*
+ * A word about residuals.
+ * The scb is presented to the sequencer with the dataptr and datacnt
+ * fields initialized to the contents of the first S/G element to
+ * transfer.  The sgptr field is initialized to the bus address for
+ * the S/G element that follows the first in the in core S/G array
+ * or'ed with the SG_FULL_RESID flag.  Sgptr may point to an invalid
+ * S/G entry for this transfer (single S/G element transfer with the
+ * first elements address and length preloaded in the dataptr/datacnt
+ * fields).  If no transfer is to occur, sgptr is set to SG_LIST_NULL.
+ * The SG_FULL_RESID flag ensures that the residual will be correctly
+ * noted even if no data transfers occur.  Once the data phase is entered,
+ * the residual sgptr and datacnt are loaded from the sgptr and the
+ * datacnt fields.  After each S/G element's dataptr and length are
+ * loaded into the hardware, the residual sgptr is advanced.  After
+ * each S/G element is expired, its datacnt field is checked to see
+ * if the LAST_SEG flag is set.  If so, SG_LIST_NULL is set in the
+ * residual sg ptr and the transfer is considered complete.  If the
+ * sequencer determines that there is a residual in the tranfer, or
+ * there is non-zero status, it will set the SG_STATUS_VALID flag in
+ * sgptr and dma the scb back into host memory.  To sumarize:
+ *
+ * Sequencer:
+ *	o A residual has occurred if SG_FULL_RESID is set in sgptr,
+ *	  or residual_sgptr does not have SG_LIST_NULL set.
+ *
+ *	o We are transfering the last segment if residual_datacnt has
+ *	  the SG_LAST_SEG flag set.
+ *
+ * Host:
+ *	o A residual can only have occurred if a completed scb has the
+ *	  SG_STATUS_VALID flag set.  Inspection of the SCSI status field,
+ *	  the residual_datacnt, and the residual_sgptr field will tell
+ *	  for sure.
+ *
+ *	o residual_sgptr and sgptr refer to the "next" sg entry
+ *	  and so may point beyond the last valid sg entry for the
+ *	  transfer.
+ */ 
+#define SG_PTR_MASK	0xFFFFFFF8
+/*16*/	uint16_t tag;		/* Reused by Sequencer. */
+/*18*/	uint8_t  control;	/* See SCB_CONTROL in aic79xx.reg for details */
+/*19*/	uint8_t	 scsiid;	/*
+				 * Selection out Id
+				 * Our Id (bits 0-3) Their ID (bits 4-7)
+				 */
+/*20*/	uint8_t  lun;
+/*21*/	uint8_t  task_attribute;
+/*22*/	uint8_t  cdb_len;
+/*23*/	uint8_t  task_management;
+/*24*/	uint64_t dataptr;
+/*32*/	uint32_t datacnt;	/* Byte 3 is spare. */
+/*36*/	uint32_t sgptr;
+/*40*/	uint32_t hscb_busaddr;
+/*44*/	uint32_t next_hscb_busaddr;
+/********** Long lun field only downloaded for full 8 byte lun support ********/
+/*48*/  uint8_t	 pkt_long_lun[8];
+/******* Fields below are not Downloaded (Sequencer may use for scratch) ******/
+/*56*/  uint8_t	 spare[8];
+};
+
+/************************ Kernel SCB Definitions ******************************/
+/*
+ * Some fields of the SCB are OS dependent.  Here we collect the
+ * definitions for elements that all OS platforms need to include
+ * in there SCB definition.
+ */
+
+/*
+ * Definition of a scatter/gather element as transfered to the controller.
+ * The aic7xxx chips only support a 24bit length.  We use the top byte of
+ * the length to store additional address bits and a flag to indicate
+ * that a given segment terminates the transfer.  This gives us an
+ * addressable range of 512GB on machines with 64bit PCI or with chips
+ * that can support dual address cycles on 32bit PCI busses.
+ */
+struct ahd_dma_seg {
+	uint32_t	addr;
+	uint32_t	len;
+#define	AHD_DMA_LAST_SEG	0x80000000
+#define	AHD_SG_HIGH_ADDR_MASK	0x7F000000
+#define	AHD_SG_LEN_MASK		0x00FFFFFF
+};
+
+struct ahd_dma64_seg {
+	uint64_t	addr;
+	uint32_t	len;
+	uint32_t	pad;
+};
+
+struct map_node {
+	bus_dmamap_t		 dmamap;
+	bus_addr_t		 physaddr;
+	uint8_t			*vaddr;
+	SLIST_ENTRY(map_node)	 links;
+};
+
+/*
+ * The current state of this SCB.
+ */
+typedef enum {
+	SCB_FLAG_NONE		= 0x00000,
+	SCB_TRANSMISSION_ERROR	= 0x00001,/*
+					   * We detected a parity or CRC
+					   * error that has effected the
+					   * payload of the command.  This
+					   * flag is checked when normal
+					   * status is returned to catch
+					   * the case of a target not
+					   * responding to our attempt
+					   * to report the error.
+					   */
+	SCB_OTHERTCL_TIMEOUT	= 0x00002,/*
+					   * Another device was active
+					   * during the first timeout for
+					   * this SCB so we gave ourselves
+					   * an additional timeout period
+					   * in case it was hogging the
+					   * bus.
+				           */
+	SCB_DEVICE_RESET	= 0x00004,
+	SCB_SENSE		= 0x00008,
+	SCB_CDB32_PTR		= 0x00010,
+	SCB_RECOVERY_SCB	= 0x00020,
+	SCB_AUTO_NEGOTIATE	= 0x00040,/* Negotiate to achieve goal. */
+	SCB_NEGOTIATE		= 0x00080,/* Negotiation forced for command. */
+	SCB_ABORT		= 0x00100,
+	SCB_ACTIVE		= 0x00200,
+	SCB_TARGET_IMMEDIATE	= 0x00400,
+	SCB_PACKETIZED		= 0x00800,
+	SCB_EXPECT_PPR_BUSFREE	= 0x01000,
+	SCB_PKT_SENSE		= 0x02000,
+	SCB_CMDPHASE_ABORT	= 0x04000,
+	SCB_ON_COL_LIST		= 0x08000,
+	SCB_SILENT		= 0x10000 /*
+					   * Be quiet about transmission type
+					   * errors.  They are expected and we
+					   * don't want to upset the user.  This
+					   * flag is typically used during DV.
+					   */
+} scb_flag;
+
+struct scb {
+	struct	hardware_scb	 *hscb;
+	union {
+		SLIST_ENTRY(scb)  sle;
+		LIST_ENTRY(scb)	  le;
+		TAILQ_ENTRY(scb)  tqe;
+	} links;
+	union {
+		SLIST_ENTRY(scb)  sle;
+		LIST_ENTRY(scb)	  le;
+		TAILQ_ENTRY(scb)  tqe;
+	} links2;
+#define pending_links links2.le
+#define collision_links links2.le
+	struct scb		 *col_scb;
+	ahd_io_ctx_t		  io_ctx;
+	struct ahd_softc	 *ahd_softc;
+	scb_flag		  flags;
+#ifndef __linux__
+	bus_dmamap_t		  dmamap;
+#endif
+	struct scb_platform_data *platform_data;
+	struct map_node	 	 *hscb_map;
+	struct map_node	 	 *sg_map;
+	struct map_node	 	 *sense_map;
+	void			 *sg_list;
+	uint8_t			 *sense_data;
+	bus_addr_t		  sg_list_busaddr;
+	bus_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;
+};
+
+TAILQ_HEAD(scb_tailq, scb);
+LIST_HEAD(scb_list, scb);
+
+struct scb_data {
+	/*
+	 * TAILQ of lists of free SCBs grouped by device
+	 * collision domains.
+	 */
+	struct scb_tailq free_scbs;
+
+	/*
+	 * Per-device lists of SCBs whose tag ID would collide
+	 * with an already active tag on the device.
+	 */
+	struct scb_list free_scb_lists[AHD_NUM_TARGETS * AHD_NUM_LUNS_NONPKT];
+
+	/*
+	 * SCBs that will not collide with any active device.
+	 */
+	struct scb_list any_dev_free_scb_list;
+
+	/*
+	 * Mapping from tag to SCB.
+	 */
+	struct	scb *scbindex[AHD_SCB_MAX];
+
+	/*
+	 * "Bus" addresses of our data structures.
+	 */
+	bus_dma_tag_t	 hscb_dmat;	/* dmat for our hardware SCB array */
+	bus_dma_tag_t	 sg_dmat;	/* dmat for our sg segments */
+	bus_dma_tag_t	 sense_dmat;	/* dmat for our sense buffers */
+	SLIST_HEAD(, map_node) hscb_maps;
+	SLIST_HEAD(, map_node) sg_maps;
+	SLIST_HEAD(, map_node) sense_maps;
+	int		 scbs_left;	/* unallocated scbs in head map_node */
+	int		 sgs_left;	/* unallocated sgs in head map_node */
+	int		 sense_left;	/* unallocated sense in head map_node */
+	uint16_t	 numscbs;
+	uint16_t	 maxhscbs;	/* Number of SCBs on the card */
+	uint8_t		 init_level;	/*
+					 * How far we've initialized
+					 * this structure.
+					 */
+};
+
+/************************ Target Mode Definitions *****************************/
+
+/*
+ * Connection desciptor for select-in requests in target mode.
+ */
+struct target_cmd {
+	uint8_t scsiid;		/* Our ID and the initiator's ID */
+	uint8_t identify;	/* Identify message */
+	uint8_t bytes[22];	/* 
+				 * Bytes contains any additional message
+				 * bytes terminated by 0xFF.  The remainder
+				 * is the cdb to execute.
+				 */
+	uint8_t cmd_valid;	/*
+				 * When a command is complete, the firmware
+				 * will set cmd_valid to all bits set.
+				 * After the host has seen the command,
+				 * the bits are cleared.  This allows us
+				 * to just peek at host memory to determine
+				 * if more work is complete. cmd_valid is on
+				 * an 8 byte boundary to simplify setting
+				 * it on aic7880 hardware which only has
+				 * limited direct access to the DMA FIFO.
+				 */
+	uint8_t pad[7];
+};
+
+/*
+ * Number of events we can buffer up if we run out
+ * of immediate notify ccbs.
+ */
+#define AHD_TMODE_EVENT_BUFFER_SIZE 8
+struct ahd_tmode_event {
+	uint8_t initiator_id;
+	uint8_t event_type;	/* MSG type or EVENT_TYPE_BUS_RESET */
+#define	EVENT_TYPE_BUS_RESET 0xFF
+	uint8_t event_arg;
+};
+
+/*
+ * Per enabled lun target mode state.
+ * As this state is directly influenced by the host OS'es target mode
+ * environment, we let the OS module define it.  Forward declare the
+ * structure here so we can store arrays of them, etc. in OS neutral
+ * data structures.
+ */
+#ifdef AHD_TARGET_MODE 
+struct ahd_tmode_lstate {
+	struct cam_path *path;
+	struct ccb_hdr_slist accept_tios;
+	struct ccb_hdr_slist immed_notifies;
+	struct ahd_tmode_event event_buffer[AHD_TMODE_EVENT_BUFFER_SIZE];
+	uint8_t event_r_idx;
+	uint8_t event_w_idx;
+};
+#else
+struct ahd_tmode_lstate;
+#endif
+
+/******************** Transfer Negotiation Datastructures *********************/
+#define AHD_TRANS_CUR		0x01	/* Modify current neogtiation status */
+#define AHD_TRANS_ACTIVE	0x03	/* Assume this target is on the bus */
+#define AHD_TRANS_GOAL		0x04	/* Modify negotiation goal */
+#define AHD_TRANS_USER		0x08	/* Modify user negotiation settings */
+#define AHD_PERIOD_10MHz	0x19
+
+#define AHD_WIDTH_UNKNOWN	0xFF
+#define AHD_PERIOD_UNKNOWN	0xFF
+#define AHD_OFFSET_UNKNOWN	0xFF
+#define AHD_PPR_OPTS_UNKNOWN	0xFF
+
+/*
+ * Transfer Negotiation Information.
+ */
+struct ahd_transinfo {
+	uint8_t protocol_version;	/* SCSI Revision level */
+	uint8_t transport_version;	/* SPI Revision level */
+	uint8_t width;			/* Bus width */
+	uint8_t period;			/* Sync rate factor */
+	uint8_t offset;			/* Sync offset */
+	uint8_t ppr_options;		/* Parallel Protocol Request options */
+};
+
+/*
+ * Per-initiator current, goal and user transfer negotiation information. */
+struct ahd_initiator_tinfo {
+	struct ahd_transinfo curr;
+	struct ahd_transinfo goal;
+	struct ahd_transinfo user;
+};
+
+/*
+ * Per enabled target ID state.
+ * Pointers to lun target state as well as sync/wide negotiation information
+ * for each initiator<->target mapping.  For the initiator role we pretend
+ * that we are the target and the targets are the initiators since the
+ * negotiation is the same regardless of role.
+ */
+struct ahd_tmode_tstate {
+	struct ahd_tmode_lstate*	enabled_luns[AHD_NUM_LUNS];
+	struct ahd_initiator_tinfo	transinfo[AHD_NUM_TARGETS];
+
+	/*
+	 * Per initiator state bitmasks.
+	 */
+	uint16_t	 auto_negotiate;/* Auto Negotiation Required */
+	uint16_t	 discenable;	/* Disconnection allowed  */
+	uint16_t	 tagenable;	/* Tagged Queuing allowed */
+};
+
+/*
+ * Points of interest along the negotiated transfer scale.
+ */
+#define AHD_SYNCRATE_160	0x8
+#define AHD_SYNCRATE_PACED	0x8
+#define AHD_SYNCRATE_DT		0x9
+#define AHD_SYNCRATE_ULTRA2	0xa
+#define AHD_SYNCRATE_ULTRA	0xc
+#define AHD_SYNCRATE_FAST	0x19
+#define AHD_SYNCRATE_MIN_DT	AHD_SYNCRATE_FAST
+#define AHD_SYNCRATE_SYNC	0x32
+#define AHD_SYNCRATE_MIN	0x60
+#define	AHD_SYNCRATE_ASYNC	0xFF
+#define AHD_SYNCRATE_MAX	AHD_SYNCRATE_160
+
+/* Safe and valid period for async negotiations. */
+#define	AHD_ASYNC_XFER_PERIOD	0x44
+
+/*
+ * In RevA, the synctable uses a 120MHz rate for the period
+ * factor 8 and 160MHz for the period factor 7.  The 120MHz
+ * rate never made it into the official SCSI spec, so we must
+ * compensate when setting the negotiation table for Rev A
+ * parts.
+ */
+#define AHD_SYNCRATE_REVA_120	0x8
+#define AHD_SYNCRATE_REVA_160	0x7
+
+/***************************** Lookup Tables **********************************/
+/*
+ * Phase -> name and message out response
+ * to parity errors in each phase table. 
+ */
+struct ahd_phase_table_entry {
+        uint8_t phase;
+        uint8_t mesg_out; /* Message response to parity errors */
+	char *phasemsg;
+};
+
+/************************** Serial EEPROM Format ******************************/
+
+struct seeprom_config {
+/*
+ * Per SCSI ID Configuration Flags
+ */
+	uint16_t device_flags[16];	/* words 0-15 */
+#define		CFXFER		0x003F	/* synchronous transfer rate */
+#define			CFXFER_ASYNC	0x3F
+#define		CFQAS		0x0040	/* Negotiate QAS */
+#define		CFPACKETIZED	0x0080	/* Negotiate Packetized Transfers */
+#define		CFSTART		0x0100	/* send start unit SCSI command */
+#define		CFINCBIOS	0x0200	/* include in BIOS scan */
+#define		CFDISC		0x0400	/* enable disconnection */
+#define		CFMULTILUNDEV	0x0800	/* Probe multiple luns in BIOS scan */
+#define		CFWIDEB		0x1000	/* wide bus device */
+#define		CFHOSTMANAGED	0x8000	/* Managed by a RAID controller */
+
+/*
+ * BIOS Control Bits
+ */
+	uint16_t bios_control;		/* word 16 */
+#define		CFSUPREM	0x0001	/* support all removeable drives */
+#define		CFSUPREMB	0x0002	/* support removeable boot drives */
+#define		CFBIOSSTATE	0x000C	/* BIOS Action State */
+#define		    CFBS_DISABLED	0x00
+#define		    CFBS_ENABLED	0x04
+#define		    CFBS_DISABLED_SCAN	0x08
+#define		CFENABLEDV	0x0010	/* Perform Domain Validation */
+#define		CFCTRL_A	0x0020	/* BIOS displays Ctrl-A message */	
+#define		CFSPARITY	0x0040	/* SCSI parity */
+#define		CFEXTEND	0x0080	/* extended translation enabled */
+#define		CFBOOTCD	0x0100  /* Support Bootable CD-ROM */
+#define		CFMSG_LEVEL	0x0600	/* BIOS Message Level */
+#define			CFMSG_VERBOSE	0x0000
+#define			CFMSG_SILENT	0x0200
+#define			CFMSG_DIAG	0x0400
+#define		CFRESETB	0x0800	/* reset SCSI bus at boot */
+/*		UNUSED		0xf000	*/
+
+/*
+ * Host Adapter Control Bits
+ */
+	uint16_t adapter_control;	/* word 17 */	
+#define		CFAUTOTERM	0x0001	/* Perform Auto termination */
+#define		CFSTERM		0x0002	/* SCSI low byte termination */
+#define		CFWSTERM	0x0004	/* SCSI high byte termination */
+#define		CFSEAUTOTERM	0x0008	/* Ultra2 Perform secondary Auto Term*/
+#define		CFSELOWTERM	0x0010	/* Ultra2 secondary low term */
+#define		CFSEHIGHTERM	0x0020	/* Ultra2 secondary high term */
+#define		CFSTPWLEVEL	0x0040	/* Termination level control */
+#define		CFBIOSAUTOTERM	0x0080	/* Perform Auto termination */
+#define		CFTERM_MENU	0x0100	/* BIOS displays termination menu */	
+#define		CFCLUSTERENB	0x8000	/* Cluster Enable */
+
+/*
+ * Bus Release Time, Host Adapter ID
+ */
+	uint16_t brtime_id;		/* word 18 */
+#define		CFSCSIID	0x000f	/* host adapter SCSI ID */
+/*		UNUSED		0x00f0	*/
+#define		CFBRTIME	0xff00	/* bus release time/PCI Latency Time */
+
+/*
+ * Maximum targets
+ */
+	uint16_t max_targets;		/* word 19 */	
+#define		CFMAXTARG	0x00ff	/* maximum targets */
+#define		CFBOOTLUN	0x0f00	/* Lun to boot from */
+#define		CFBOOTID	0xf000	/* Target to boot from */
+	uint16_t res_1[10];		/* words 20-29 */
+	uint16_t signature;		/* BIOS Signature */
+#define		CFSIGNATURE	0x400
+	uint16_t checksum;		/* word 31 */
+};
+
+/*
+ * Vital Product Data used during POST and by the BIOS.
+ */
+struct vpd_config {
+	uint8_t  bios_flags;
+#define		VPDMASTERBIOS	0x0001
+#define		VPDBOOTHOST	0x0002
+	uint8_t  reserved_1[21];
+	uint8_t  resource_type;
+	uint8_t  resource_len[2];
+	uint8_t  resource_data[8];
+	uint8_t  vpd_tag;
+	uint16_t vpd_len;
+	uint8_t  vpd_keyword[2];
+	uint8_t  length;
+	uint8_t  revision;
+	uint8_t  device_flags;
+	uint8_t  termnation_menus[2];
+	uint8_t  fifo_threshold;
+	uint8_t  end_tag;
+	uint8_t  vpd_checksum;
+	uint16_t default_target_flags;
+	uint16_t default_bios_flags;
+	uint16_t default_ctrl_flags;
+	uint8_t  default_irq;
+	uint8_t  pci_lattime;
+	uint8_t  max_target;
+	uint8_t  boot_lun;
+	uint16_t signature;
+	uint8_t  reserved_2;
+	uint8_t  checksum;
+	uint8_t	 reserved_3[4];
+};
+
+/****************************** Flexport Logic ********************************/
+#define FLXADDR_TERMCTL			0x0
+#define		FLX_TERMCTL_ENSECHIGH	0x8
+#define		FLX_TERMCTL_ENSECLOW	0x4
+#define		FLX_TERMCTL_ENPRIHIGH	0x2
+#define		FLX_TERMCTL_ENPRILOW	0x1
+#define FLXADDR_ROMSTAT_CURSENSECTL	0x1
+#define		FLX_ROMSTAT_SEECFG	0xF0
+#define		FLX_ROMSTAT_EECFG	0x0F
+#define		FLX_ROMSTAT_SEE_93C66	0x00
+#define		FLX_ROMSTAT_SEE_NONE	0xF0
+#define		FLX_ROMSTAT_EE_512x8	0x0
+#define		FLX_ROMSTAT_EE_1MBx8	0x1
+#define		FLX_ROMSTAT_EE_2MBx8	0x2
+#define		FLX_ROMSTAT_EE_4MBx8	0x3
+#define		FLX_ROMSTAT_EE_16MBx8	0x4
+#define 		CURSENSE_ENB	0x1
+#define	FLXADDR_FLEXSTAT		0x2
+#define		FLX_FSTAT_BUSY		0x1
+#define FLXADDR_CURRENT_STAT		0x4
+#define		FLX_CSTAT_SEC_HIGH	0xC0
+#define		FLX_CSTAT_SEC_LOW	0x30
+#define		FLX_CSTAT_PRI_HIGH	0x0C
+#define		FLX_CSTAT_PRI_LOW	0x03
+#define		FLX_CSTAT_MASK		0x03
+#define		FLX_CSTAT_SHIFT		2
+#define		FLX_CSTAT_OKAY		0x0
+#define		FLX_CSTAT_OVER		0x1
+#define		FLX_CSTAT_UNDER		0x2
+#define		FLX_CSTAT_INVALID	0x3
+
+int		ahd_read_seeprom(struct ahd_softc *ahd, uint16_t *buf,
+				 u_int start_addr, u_int count, int bstream);
+
+int		ahd_write_seeprom(struct ahd_softc *ahd, uint16_t *buf,
+				  u_int start_addr, u_int count);
+int		ahd_wait_seeprom(struct ahd_softc *ahd);
+int		ahd_verify_vpd_cksum(struct vpd_config *vpd);
+int		ahd_verify_cksum(struct seeprom_config *sc);
+int		ahd_acquire_seeprom(struct ahd_softc *ahd);
+void		ahd_release_seeprom(struct ahd_softc *ahd);
+
+/****************************  Message Buffer *********************************/
+typedef enum {
+	MSG_FLAG_NONE			= 0x00,
+	MSG_FLAG_EXPECT_PPR_BUSFREE	= 0x01,
+	MSG_FLAG_IU_REQ_CHANGED		= 0x02,
+	MSG_FLAG_EXPECT_IDE_BUSFREE	= 0x04,
+	MSG_FLAG_EXPECT_QASREJ_BUSFREE	= 0x08,
+	MSG_FLAG_PACKETIZED		= 0x10
+} ahd_msg_flags;
+
+typedef enum {
+	MSG_TYPE_NONE			= 0x00,
+	MSG_TYPE_INITIATOR_MSGOUT	= 0x01,
+	MSG_TYPE_INITIATOR_MSGIN	= 0x02,
+	MSG_TYPE_TARGET_MSGOUT		= 0x03,
+	MSG_TYPE_TARGET_MSGIN		= 0x04
+} ahd_msg_type;
+
+typedef enum {
+	MSGLOOP_IN_PROG,
+	MSGLOOP_MSGCOMPLETE,
+	MSGLOOP_TERMINATED
+} msg_loop_stat;
+
+/*********************** Software Configuration Structure *********************/
+struct ahd_suspend_channel_state {
+	uint8_t	scsiseq;
+	uint8_t	sxfrctl0;
+	uint8_t	sxfrctl1;
+	uint8_t	simode0;
+	uint8_t	simode1;
+	uint8_t	seltimer;
+	uint8_t	seqctl;
+};
+
+struct ahd_suspend_state {
+	struct	ahd_suspend_channel_state channel[2];
+	uint8_t	optionmode;
+	uint8_t	dscommand0;
+	uint8_t	dspcistatus;
+	/* hsmailbox */
+	uint8_t	crccontrol1;
+	uint8_t	scbbaddr;
+	/* Host and sequencer SCB counts */
+	uint8_t	dff_thrsh;
+	uint8_t	*scratch_ram;
+	uint8_t	*btt;
+};
+
+typedef void (*ahd_bus_intr_t)(struct ahd_softc *);
+
+typedef enum {
+	AHD_MODE_DFF0,
+	AHD_MODE_DFF1,
+	AHD_MODE_CCHAN,
+	AHD_MODE_SCSI,
+	AHD_MODE_CFG,
+	AHD_MODE_UNKNOWN
+} ahd_mode;
+
+#define AHD_MK_MSK(x) (0x01 << (x))
+#define AHD_MODE_DFF0_MSK	AHD_MK_MSK(AHD_MODE_DFF0)
+#define AHD_MODE_DFF1_MSK	AHD_MK_MSK(AHD_MODE_DFF1)
+#define AHD_MODE_CCHAN_MSK	AHD_MK_MSK(AHD_MODE_CCHAN)
+#define AHD_MODE_SCSI_MSK	AHD_MK_MSK(AHD_MODE_SCSI)
+#define AHD_MODE_CFG_MSK	AHD_MK_MSK(AHD_MODE_CFG)
+#define AHD_MODE_UNKNOWN_MSK	AHD_MK_MSK(AHD_MODE_UNKNOWN)
+#define AHD_MODE_ANY_MSK (~0)
+
+typedef uint8_t ahd_mode_state;
+
+typedef void ahd_callback_t (void *);
+
+struct ahd_softc {
+	bus_space_tag_t           tags[2];
+	bus_space_handle_t        bshs[2];
+#ifndef __linux__
+	bus_dma_tag_t		  buffer_dmat;   /* dmat for buffer I/O */
+#endif
+	struct scb_data		  scb_data;
+
+	struct hardware_scb	 *next_queued_hscb;
+
+	/*
+	 * SCBs that have been sent to the controller
+	 */
+	LIST_HEAD(, scb)	  pending_scbs;
+
+	/*
+	 * Current register window mode information.
+	 */
+	ahd_mode		  dst_mode;
+	ahd_mode		  src_mode;
+
+	/*
+	 * Saved register window mode information
+	 * used for restore on next unpause.
+	 */
+	ahd_mode		  saved_dst_mode;
+	ahd_mode		  saved_src_mode;
+
+	/*
+	 * Platform specific data.
+	 */
+	struct ahd_platform_data *platform_data;
+
+	/*
+	 * Platform specific device information.
+	 */
+	ahd_dev_softc_t		  dev_softc;
+
+	/*
+	 * Bus specific device information.
+	 */
+	ahd_bus_intr_t		  bus_intr;
+
+	/*
+	 * Target mode related state kept on a per enabled lun basis.
+	 * Targets that are not enabled will have null entries.
+	 * As an initiator, we keep one target entry for our initiator
+	 * ID to store our sync/wide transfer settings.
+	 */
+	struct ahd_tmode_tstate  *enabled_targets[AHD_NUM_TARGETS];
+
+	/*
+	 * The black hole device responsible for handling requests for
+	 * disabled luns on enabled targets.
+	 */
+	struct ahd_tmode_lstate  *black_hole;
+
+	/*
+	 * Device instance currently on the bus awaiting a continue TIO
+	 * for a command that was not given the disconnect priveledge.
+	 */
+	struct ahd_tmode_lstate  *pending_device;
+
+	/*
+	 * Timer handles for timer driven callbacks.
+	 */
+	ahd_timer_t		  reset_timer;
+	ahd_timer_t		  stat_timer;
+
+	/*
+	 * Statistics.
+	 */
+#define	AHD_STAT_UPDATE_US	250000 /* 250ms */
+#define	AHD_STAT_BUCKETS	4
+	u_int			  cmdcmplt_bucket;
+	uint32_t		  cmdcmplt_counts[AHD_STAT_BUCKETS];
+	uint32_t		  cmdcmplt_total;
+
+	/*
+	 * Card characteristics
+	 */
+	ahd_chip		  chip;
+	ahd_feature		  features;
+	ahd_bug			  bugs;
+	ahd_flag		  flags;
+	struct seeprom_config	 *seep_config;
+
+	/* Values to store in the SEQCTL register for pause and unpause */
+	uint8_t			  unpause;
+	uint8_t			  pause;
+
+	/* Command Queues */
+	uint16_t		  qoutfifonext;
+	uint16_t		  qoutfifonext_valid_tag;
+	uint16_t		  qinfifonext;
+	uint16_t		  qinfifo[AHD_SCB_MAX];
+	uint16_t		 *qoutfifo;
+
+	/* Critical Section Data */
+	struct cs		 *critical_sections;
+	u_int			  num_critical_sections;
+
+	/* Buffer for handling packetized bitbucket. */
+	uint8_t			 *overrun_buf;
+
+	/* Links for chaining softcs */
+	TAILQ_ENTRY(ahd_softc)	  links;
+
+	/* Channel Names ('A', 'B', etc.) */
+	char			  channel;
+
+	/* Initiator Bus ID */
+	uint8_t			  our_id;
+
+	/*
+	 * Target incoming command FIFO.
+	 */
+	struct target_cmd	 *targetcmds;
+	uint8_t			  tqinfifonext;
+
+	/*
+	 * Cached verson of the hs_mailbox so we can avoid
+	 * pausing the sequencer during mailbox updates.
+	 */
+	uint8_t			  hs_mailbox;
+
+	/*
+	 * Incoming and outgoing message handling.
+	 */
+	uint8_t			  send_msg_perror;
+	ahd_msg_flags		  msg_flags;
+	ahd_msg_type		  msg_type;
+	uint8_t			  msgout_buf[12];/* Message we are sending */
+	uint8_t			  msgin_buf[12];/* Message we are receiving */
+	u_int			  msgout_len;	/* Length of message to send */
+	u_int			  msgout_index;	/* Current index in msgout */
+	u_int			  msgin_index;	/* Current index in msgin */
+
+	/*
+	 * Mapping information for data structures shared
+	 * between the sequencer and kernel.
+	 */
+	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;
+
+	/* Information saved through suspend/resume cycles */
+	struct ahd_suspend_state  suspend_state;
+
+	/* Number of enabled target mode device on this card */
+	u_int			  enabled_luns;
+
+	/* Initialization level of this data structure */
+	u_int			  init_level;
+
+	/* PCI cacheline size. */
+	u_int			  pci_cachesize;
+
+	/* IO Cell Parameters */
+	uint8_t			  iocell_opts[AHD_NUM_PER_DEV_ANNEXCOLS];
+
+	u_int			  stack_size;
+	uint16_t		 *saved_stack;
+
+	/* Per-Unit descriptive information */
+	const char		 *description;
+	const char		 *bus_description;
+	char			 *name;
+	int			  unit;
+
+	/* Selection Timer settings */
+	int			  seltime;
+
+	/*
+	 * Interrupt coalescing settings.
+	 */
+#define	AHD_INT_COALESCING_TIMER_DEFAULT		250 /*us*/
+#define	AHD_INT_COALESCING_MAXCMDS_DEFAULT		10
+#define	AHD_INT_COALESCING_MAXCMDS_MAX			127
+#define	AHD_INT_COALESCING_MINCMDS_DEFAULT		5
+#define	AHD_INT_COALESCING_MINCMDS_MAX			127
+#define	AHD_INT_COALESCING_THRESHOLD_DEFAULT		2000
+#define	AHD_INT_COALESCING_STOP_THRESHOLD_DEFAULT	1000
+	u_int			  int_coalescing_timer;
+	u_int			  int_coalescing_maxcmds;
+	u_int			  int_coalescing_mincmds;
+	u_int			  int_coalescing_threshold;
+	u_int			  int_coalescing_stop_threshold;
+
+	uint16_t	 	  user_discenable;/* Disconnection allowed  */
+	uint16_t		  user_tagenable;/* Tagged Queuing allowed */
+};
+
+TAILQ_HEAD(ahd_softc_tailq, ahd_softc);
+extern struct ahd_softc_tailq ahd_tailq;
+
+/*************************** IO Cell Configuration ****************************/
+#define	AHD_PRECOMP_SLEW_INDEX						\
+    (AHD_ANNEXCOL_PRECOMP_SLEW - AHD_ANNEXCOL_PER_DEV0)
+
+#define	AHD_AMPLITUDE_INDEX						\
+    (AHD_ANNEXCOL_AMPLITUDE - AHD_ANNEXCOL_PER_DEV0)
+
+#define AHD_SET_SLEWRATE(ahd, new_slew)					\
+do {									\
+    (ahd)->iocell_opts[AHD_PRECOMP_SLEW_INDEX] &= ~AHD_SLEWRATE_MASK;	\
+    (ahd)->iocell_opts[AHD_PRECOMP_SLEW_INDEX] |=			\
+	(((new_slew) << AHD_SLEWRATE_SHIFT) & AHD_SLEWRATE_MASK);	\
+} while (0)
+
+#define AHD_SET_PRECOMP(ahd, new_pcomp)					\
+do {									\
+    (ahd)->iocell_opts[AHD_PRECOMP_SLEW_INDEX] &= ~AHD_PRECOMP_MASK;	\
+    (ahd)->iocell_opts[AHD_PRECOMP_SLEW_INDEX] |=			\
+	(((new_pcomp) << AHD_PRECOMP_SHIFT) & AHD_PRECOMP_MASK);	\
+} while (0)
+
+#define AHD_SET_AMPLITUDE(ahd, new_amp)					\
+do {									\
+    (ahd)->iocell_opts[AHD_AMPLITUDE_INDEX] &= ~AHD_AMPLITUDE_MASK;	\
+    (ahd)->iocell_opts[AHD_AMPLITUDE_INDEX] |=				\
+	(((new_amp) << AHD_AMPLITUDE_SHIFT) & AHD_AMPLITUDE_MASK);	\
+} while (0)
+
+/************************ Active Device Information ***************************/
+typedef enum {
+	ROLE_UNKNOWN,
+	ROLE_INITIATOR,
+	ROLE_TARGET
+} role_t;
+
+struct ahd_devinfo {
+	int	 our_scsiid;
+	int	 target_offset;
+	uint16_t target_mask;
+	u_int	 target;
+	u_int	 lun;
+	char	 channel;
+	role_t	 role;		/*
+				 * Only guaranteed to be correct if not
+				 * in the busfree state.
+				 */
+};
+
+/****************************** PCI Structures ********************************/
+#define AHD_PCI_IOADDR0	PCIR_MAPS	/* I/O BAR*/
+#define AHD_PCI_MEMADDR	(PCIR_MAPS + 4)	/* Memory BAR */
+#define AHD_PCI_IOADDR1	(PCIR_MAPS + 12)/* Second I/O BAR */
+
+typedef int (ahd_device_setup_t)(struct ahd_softc *);
+
+struct ahd_pci_identity {
+	uint64_t		 full_id;
+	uint64_t		 id_mask;
+	char			*name;
+	ahd_device_setup_t	*setup;
+};
+extern struct ahd_pci_identity ahd_pci_ident_table [];
+extern const u_int ahd_num_pci_devs;
+
+/***************************** VL/EISA Declarations ***************************/
+struct aic7770_identity {
+	uint32_t		 full_id;
+	uint32_t		 id_mask;
+	char			*name;
+	ahd_device_setup_t	*setup;
+};
+extern struct aic7770_identity aic7770_ident_table [];
+extern const int ahd_num_aic7770_devs;
+
+#define AHD_EISA_SLOT_OFFSET	0xc00
+#define AHD_EISA_IOSIZE		0x100
+
+/*************************** Function Declarations ****************************/
+/******************************************************************************/
+void			ahd_reset_cmds_pending(struct ahd_softc *ahd);
+u_int			ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl);
+void			ahd_busy_tcl(struct ahd_softc *ahd,
+				     u_int tcl, u_int busyid);
+static __inline void	ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl);
+static __inline void
+ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl)
+{
+	ahd_busy_tcl(ahd, tcl, SCB_LIST_NULL);
+}
+
+/***************************** PCI Front End *********************************/
+struct	ahd_pci_identity *ahd_find_pci_device(ahd_dev_softc_t);
+int			  ahd_pci_config(struct ahd_softc *,
+					 struct ahd_pci_identity *);
+int	ahd_pci_test_register_access(struct ahd_softc *);
+
+/************************** SCB and SCB queue management **********************/
+int		ahd_probe_scbs(struct ahd_softc *);
+void		ahd_qinfifo_requeue_tail(struct ahd_softc *ahd,
+					 struct scb *scb);
+int		ahd_match_scb(struct ahd_softc *ahd, struct scb *scb,
+			      int target, char channel, int lun,
+			      u_int tag, role_t role);
+
+/****************************** Initialization ********************************/
+struct ahd_softc	*ahd_alloc(void *platform_arg, char *name);
+int			 ahd_softc_init(struct ahd_softc *);
+void			 ahd_controller_info(struct ahd_softc *ahd, char *buf);
+int			 ahd_init(struct ahd_softc *ahd);
+int			 ahd_default_config(struct ahd_softc *ahd);
+int			 ahd_parse_vpddata(struct ahd_softc *ahd,
+					   struct vpd_config *vpd);
+int			 ahd_parse_cfgdata(struct ahd_softc *ahd,
+					   struct seeprom_config *sc);
+void			 ahd_intr_enable(struct ahd_softc *ahd, int enable);
+void			 ahd_update_coalescing_values(struct ahd_softc *ahd,
+						      u_int timer,
+						      u_int maxcmds,
+						      u_int mincmds);
+void			 ahd_enable_coalescing(struct ahd_softc *ahd,
+					       int enable);
+void			 ahd_pause_and_flushwork(struct ahd_softc *ahd);
+int			 ahd_suspend(struct ahd_softc *ahd); 
+int			 ahd_resume(struct ahd_softc *ahd);
+void			 ahd_softc_insert(struct ahd_softc *);
+struct ahd_softc	*ahd_find_softc(struct ahd_softc *ahd);
+void			 ahd_set_unit(struct ahd_softc *, int);
+void			 ahd_set_name(struct ahd_softc *, char *);
+struct scb		*ahd_get_scb(struct ahd_softc *ahd, u_int col_idx);
+void			 ahd_free_scb(struct ahd_softc *ahd, struct scb *scb);
+void			 ahd_alloc_scbs(struct ahd_softc *ahd);
+void			 ahd_free(struct ahd_softc *ahd);
+int			 ahd_reset(struct ahd_softc *ahd, int reinit);
+void			 ahd_shutdown(void *arg);
+int			 ahd_write_flexport(struct ahd_softc *ahd,
+					    u_int addr, u_int value);
+int			 ahd_read_flexport(struct ahd_softc *ahd, u_int addr,
+					   uint8_t *value);
+int			 ahd_wait_flexport(struct ahd_softc *ahd);
+
+/*************************** Interrupt Services *******************************/
+void			ahd_pci_intr(struct ahd_softc *ahd);
+void			ahd_clear_intstat(struct ahd_softc *ahd);
+void			ahd_flush_qoutfifo(struct ahd_softc *ahd);
+void			ahd_run_qoutfifo(struct ahd_softc *ahd);
+#ifdef AHD_TARGET_MODE
+void			ahd_run_tqinfifo(struct ahd_softc *ahd, int paused);
+#endif
+void			ahd_handle_hwerrint(struct ahd_softc *ahd);
+void			ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat);
+void			ahd_handle_scsiint(struct ahd_softc *ahd,
+					   u_int intstat);
+void			ahd_clear_critical_section(struct ahd_softc *ahd);
+
+/***************************** Error Recovery *********************************/
+typedef enum {
+	SEARCH_COMPLETE,
+	SEARCH_COUNT,
+	SEARCH_REMOVE,
+	SEARCH_PRINT
+} ahd_search_action;
+int			ahd_search_qinfifo(struct ahd_softc *ahd, int target,
+					   char channel, int lun, u_int tag,
+					   role_t role, uint32_t status,
+					   ahd_search_action action);
+int			ahd_search_disc_list(struct ahd_softc *ahd, int target,
+					     char channel, int lun, u_int tag,
+					     int stop_on_first, int remove,
+					     int save_state);
+void			ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb);
+int			ahd_reset_channel(struct ahd_softc *ahd, char channel,
+					  int initiate_reset);
+int			ahd_abort_scbs(struct ahd_softc *ahd, int target,
+				       char channel, int lun, u_int tag,
+				       role_t role, uint32_t status);
+void			ahd_restart(struct ahd_softc *ahd);
+void			ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo);
+void			ahd_handle_scb_status(struct ahd_softc *ahd,
+					      struct scb *scb);
+void			ahd_handle_scsi_status(struct ahd_softc *ahd,
+					       struct scb *scb);
+void			ahd_calc_residual(struct ahd_softc *ahd,
+					  struct scb *scb);
+/*************************** Utility Functions ********************************/
+struct ahd_phase_table_entry*
+			ahd_lookup_phase_entry(int phase);
+void			ahd_compile_devinfo(struct ahd_devinfo *devinfo,
+					    u_int our_id, u_int target,
+					    u_int lun, char channel,
+					    role_t role);
+/************************** Transfer Negotiation ******************************/
+void			ahd_find_syncrate(struct ahd_softc *ahd, u_int *period,
+					  u_int *ppr_options, u_int maxsync);
+void			ahd_validate_offset(struct ahd_softc *ahd,
+					    struct ahd_initiator_tinfo *tinfo,
+					    u_int period, u_int *offset,
+					    int wide, role_t role);
+void			ahd_validate_width(struct ahd_softc *ahd,
+					   struct ahd_initiator_tinfo *tinfo,
+					   u_int *bus_width,
+					   role_t role);
+/*
+ * Negotiation types.  These are used to qualify if we should renegotiate
+ * even if our goal and current transport parameters are identical.
+ */
+typedef enum {
+	AHD_NEG_TO_GOAL,	/* Renegotiate only if goal and curr differ. */
+	AHD_NEG_IF_NON_ASYNC,	/* Renegotiate so long as goal is non-async. */
+	AHD_NEG_ALWAYS		/* Renegotiat even if goal is async. */
+} ahd_neg_type;
+int			ahd_update_neg_request(struct ahd_softc*,
+					       struct ahd_devinfo*,
+					       struct ahd_tmode_tstate*,
+					       struct ahd_initiator_tinfo*,
+					       ahd_neg_type);
+void			ahd_set_width(struct ahd_softc *ahd,
+				      struct ahd_devinfo *devinfo,
+				      u_int width, u_int type, int paused);
+void			ahd_set_syncrate(struct ahd_softc *ahd,
+					 struct ahd_devinfo *devinfo,
+					 u_int period, u_int offset,
+					 u_int ppr_options,
+					 u_int type, int paused);
+typedef enum {
+	AHD_QUEUE_NONE,
+	AHD_QUEUE_BASIC,
+	AHD_QUEUE_TAGGED
+} ahd_queue_alg;
+
+void			ahd_set_tags(struct ahd_softc *ahd,
+				     struct ahd_devinfo *devinfo,
+				     ahd_queue_alg alg);
+
+/**************************** Target Mode *************************************/
+#ifdef AHD_TARGET_MODE
+void		ahd_send_lstate_events(struct ahd_softc *,
+				       struct ahd_tmode_lstate *);
+void		ahd_handle_en_lun(struct ahd_softc *ahd,
+				  struct cam_sim *sim, union ccb *ccb);
+cam_status	ahd_find_tmode_devs(struct ahd_softc *ahd,
+				    struct cam_sim *sim, union ccb *ccb,
+				    struct ahd_tmode_tstate **tstate,
+				    struct ahd_tmode_lstate **lstate,
+				    int notfound_failure);
+#ifndef AHD_TMODE_ENABLE
+#define AHD_TMODE_ENABLE 0
+#endif
+#endif
+/******************************* Debug ***************************************/
+#ifdef AHD_DEBUG
+extern uint32_t ahd_debug;
+#define AHD_SHOW_MISC		0x00001
+#define AHD_SHOW_SENSE		0x00002
+#define AHD_SHOW_RECOVERY	0x00004
+#define AHD_DUMP_SEEPROM	0x00008
+#define AHD_SHOW_TERMCTL	0x00010
+#define AHD_SHOW_MEMORY		0x00020
+#define AHD_SHOW_MESSAGES	0x00040
+#define AHD_SHOW_MODEPTR	0x00080
+#define AHD_SHOW_SELTO		0x00100
+#define AHD_SHOW_FIFOS		0x00200
+#define AHD_SHOW_QFULL		0x00400
+#define	AHD_SHOW_DV		0x00800
+#define AHD_SHOW_MASKED_ERRORS	0x01000
+#define AHD_SHOW_QUEUE		0x02000
+#define AHD_SHOW_TQIN		0x04000
+#define AHD_SHOW_SG		0x08000
+#define AHD_SHOW_INT_COALESCING	0x10000
+#define AHD_DEBUG_SEQUENCER	0x20000
+#endif
+void			ahd_print_scb(struct scb *scb);
+void			ahd_print_devinfo(struct ahd_softc *ahd,
+					  struct ahd_devinfo *devinfo);
+void			ahd_dump_sglist(struct scb *scb);
+void			ahd_dump_all_cards_state(void);
+void			ahd_dump_card_state(struct ahd_softc *ahd);
+int			ahd_print_register(ahd_reg_parse_entry_t *table,
+					   u_int num_entries,
+					   const char *name,
+					   u_int address,
+					   u_int value,
+					   u_int *cur_column,
+					   u_int wrap_point);
+void			ahd_dump_scbs(struct ahd_softc *ahd);
+#endif /* _AIC79XX_H_ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic79xx.reg linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx.reg
--- linux-2.4.21/drivers/scsi/aic7xxx/aic79xx.reg	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx.reg	2003-06-26 21:43:31.000000000 +0000
@@ -0,0 +1,3958 @@
+/*
+ * Aic79xx register and scratch ram definitions.
+ *
+ * Copyright (c) 1994-2001 Justin T. Gibbs.
+ * Copyright (c) 2000-2002 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.
+ *
+ * $FreeBSD$
+ */
+VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#70 $"
+
+/*
+ * This file is processed by the aic7xxx_asm utility for use in assembling
+ * firmware for the aic79xx family of SCSI host adapters as well as to generate
+ * a C header file for use in the kernel portion of the Aic79xx driver.
+ */
+
+/* Register window Modes */
+#define M_DFF0		0
+#define M_DFF1		1
+#define M_CCHAN		2
+#define M_SCSI		3
+#define M_CFG		4
+#define M_DST_SHIFT	4
+
+#define MK_MODE(src, dst) ((src) | ((dst) << M_DST_SHIFT))
+#define SET_MODE(src, dst)						\
+	SET_SRC_MODE	src;						\
+	SET_DST_MODE	dst;						\
+	if ((ahd->bugs & AHD_SET_MODE_BUG) != 0) {			\
+		mvi	MK_MODE(src, dst) call set_mode_work_around;	\
+	} else {							\
+		mvi	MODE_PTR, MK_MODE(src, dst);			\
+	}
+
+#define TOGGLE_DFF_MODE							\
+	if ((ahd->bugs & AHD_SET_MODE_BUG) != 0) {			\
+		call	toggle_dff_mode_work_around;			\
+	} else {							\
+		xor	MODE_PTR, MK_MODE(M_DFF1, M_DFF1);		\
+	}
+	
+#define RESTORE_MODE(mode)						\
+	if ((ahd->bugs & AHD_SET_MODE_BUG) != 0) {			\
+		mov	mode call set_mode_work_around;			\
+	} else {							\
+		mov	MODE_PTR, mode;					\
+	}
+
+#define SET_SEQINTCODE(code)						\
+	if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) {			\
+		mvi	code call set_seqint_work_around;		\
+	} else {							\
+		mvi	SEQINTCODE, code;				\
+	}
+
+/*
+ * Mode Pointer
+ * Controls which of the 5, 512byte, address spaces should be used
+ * as the source and destination of any register accesses in our
+ * register window.
+ */
+register MODE_PTR {
+	address			0x000
+	access_mode	RW
+	field	DST_MODE	0x70
+	field	SRC_MODE	0x07
+	mode_pointer
+}
+
+const SRC_MODE_SHIFT	0
+const DST_MODE_SHIFT	4
+
+/*
+ * Host Interrupt Status
+ */
+register INTSTAT {
+	address			0x001
+	access_mode	RW
+	field	HWERRINT	0x80
+	field	BRKADRINT	0x40
+	field	SWTMINT		0x20
+	field	PCIINT		0x10
+	field	SCSIINT		0x08
+	field	SEQINT		0x04
+	field	CMDCMPLT	0x02
+	field	SPLTINT		0x01
+	mask	INT_PEND 0xFF
+}
+
+/*
+ * Sequencer Interrupt Code
+ */
+register SEQINTCODE {
+	address			0x002
+	access_mode	RW
+	field {
+		NO_SEQINT,			/* No seqint pending. */
+		BAD_PHASE,			/* unknown scsi bus phase */
+		SEND_REJECT,			/* sending a message reject */
+		PROTO_VIOLATION, 		/* Protocol Violation */
+		NO_MATCH,			/* no cmd match for reconnect */
+		IGN_WIDE_RES,			/* Complex IGN Wide Res Msg */
+		PDATA_REINIT,			/*
+						 * Returned to data phase
+						 * that requires data
+						 * transfer pointers to be
+						 * recalculated from the
+						 * transfer residual.
+						 */
+		HOST_MSG_LOOP,			/*
+						 * The bus is ready for the
+						 * host to perform another
+						 * message transaction.  This
+						 * mechanism is used for things
+						 * like sync/wide negotiation
+						 * that require a kernel based
+						 * message state engine.
+						 */
+		BAD_STATUS,			/* Bad status from target */
+		DATA_OVERRUN,			/*
+						 * Target attempted to write
+						 * beyond the bounds of its
+						 * command.
+						 */
+		MKMSG_FAILED,			/*
+						 * Target completed command
+						 * without honoring our ATN
+						 * request to issue a message. 
+						 */
+		MISSED_BUSFREE,			/*
+						 * The sequencer never saw
+						 * the bus go free after
+						 * either a command complete
+						 * or disconnect message.
+						 */
+		DUMP_CARD_STATE,
+		ILLEGAL_PHASE,
+		INVALID_SEQINT,
+		CFG4ISTAT_INTR,
+		STATUS_OVERRUN,
+		CFG4OVERRUN,
+		ENTERING_NONPACK,
+		TASKMGMT_FUNC_COMPLETE,		/*
+						 * Task management function
+						 * request completed with
+						 * an expected busfree.
+						 */
+		TASKMGMT_CMD_CMPLT_OKAY,	/*
+						 * A command with a non-zero
+						 * task management function
+						 * has completed via the normal
+						 * command completion method
+						 * for commands with a zero
+						 * task management function.
+						 * This happens when an attempt
+						 * to abort a command loses
+						 * the race for the command to
+						 * complete normally.
+						 */
+		TRACEPOINT0,
+		TRACEPOINT1,
+		TRACEPOINT2,
+		TRACEPOINT3,
+		SAW_HWERR,
+		BAD_SCB_STATUS
+	}
+}
+
+/*
+ * Clear Host Interrupt
+ */
+register CLRINT {
+	address			0x003
+	access_mode	WO
+	field	CLRHWERRINT	0x80 /* Rev B or greater */
+	field	CLRBRKADRINT	0x40
+	field	CLRSWTMINT	0x20
+	field	CLRPCIINT	0x10
+	field	CLRSCSIINT	0x08
+	field	CLRSEQINT	0x04
+	field	CLRCMDINT	0x02
+	field	CLRSPLTINT	0x01
+}
+
+/*
+ * Error Register
+ */
+register ERROR {
+	address			0x004
+	access_mode	RO
+	field	CIOPARERR	0x80
+	field	CIOACCESFAIL	0x40 /* Rev B or greater */
+	field	MPARERR		0x20
+	field	DPARERR		0x10
+	field	SQPARERR	0x08
+	field	ILLOPCODE	0x04
+	field	DSCTMOUT	0x02
+}
+
+/*
+ * Clear Error
+ */
+register CLRERR {
+	address			0x004
+	access_mode 	WO
+	field	CLRCIOPARERR	0x80
+	field	CLRCIOACCESFAIL	0x40 /* Rev B or greater */
+	field	CLRMPARERR	0x20
+	field	CLRDPARERR	0x10
+	field	CLRSQPARERR	0x08
+	field	CLRILLOPCODE	0x04
+	field	CLRDSCTMOUT	0x02
+}
+
+/*
+ * Host Control Register
+ * Overall host control of the device.
+ */
+register HCNTRL {
+	address			0x005
+	access_mode	RW
+	field	SEQ_RESET	0x80 /* Rev B or greater */
+	field	POWRDN		0x40
+	field	SWINT		0x10
+	field	SWTIMER_START_B	0x08 /* Rev B or greater */
+	field	PAUSE		0x04
+	field	INTEN		0x02
+	field	CHIPRST		0x01
+	field	CHIPRSTACK	0x01
+}
+
+/*
+ * Host New SCB Queue Offset
+ */
+register HNSCB_QOFF {
+	address			0x006
+	access_mode	RW
+	size		2
+}
+
+/*
+ * Host Empty SCB Queue Offset
+ */
+register HESCB_QOFF {
+	address			0x008
+	access_mode	RW
+}
+
+/*
+ * Host Mailbox
+ */
+register HS_MAILBOX {
+	address			0x00B
+	access_mode	RW
+	mask	HOST_TQINPOS	0x80	/* Boundary at either 0 or 128 */
+	mask	ENINT_COALESCE	0x40	/* Perform interrupt coalescing */
+}
+
+/*
+ * Sequencer Interupt Status
+ */
+register SEQINTSTAT {
+	address			0x00C
+	access_mode	RO
+	field	SEQ_SWTMRTO	0x10
+	field	SEQ_SEQINT	0x08
+	field	SEQ_SCSIINT	0x04
+	field	SEQ_PCIINT	0x02
+	field	SEQ_SPLTINT	0x01
+}
+
+/*
+ * Clear SEQ Interrupt
+ */
+register CLRSEQINTSTAT {
+	address			0x00C
+	access_mode	WO
+	field	CLRSEQ_SWTMRTO	0x10
+	field	CLRSEQ_SEQINT	0x08
+	field	CLRSEQ_SCSIINT	0x04
+	field	CLRSEQ_PCIINT	0x02
+	field	CLRSEQ_SPLTINT	0x01
+}
+
+/*
+ * Software Timer
+ */
+register SWTIMER {
+	address			0x00E
+	access_mode	RW
+	size		2
+}
+
+/*
+ * SEQ New SCB Queue Offset
+ */
+register SNSCB_QOFF {
+	address			0x010
+	access_mode	RW
+	size		2
+	modes		M_CCHAN
+}
+
+/*
+ * SEQ Empty SCB Queue Offset
+ */
+register SESCB_QOFF {
+	address			0x012
+	access_mode	RW
+	modes		M_CCHAN
+}
+
+/*
+ * SEQ Done SCB Queue Offset
+ */
+register SDSCB_QOFF {
+	address			0x014
+	access_mode	RW
+	modes		M_CCHAN
+	size		2
+}
+
+/*
+ * Queue Offset Control & Status
+ */
+register QOFF_CTLSTA {
+	address			0x016
+	access_mode	RW
+	modes		M_CCHAN
+	field	EMPTY_SCB_AVAIL	0x80
+	field	NEW_SCB_AVAIL	0x40
+	field	SDSCB_ROLLOVR	0x20
+	field	HS_MAILBOX_ACT	0x10
+	field	SCB_QSIZE	0x0F {
+		SCB_QSIZE_4,
+		SCB_QSIZE_8,
+		SCB_QSIZE_16,
+		SCB_QSIZE_32,
+		SCB_QSIZE_64,
+		SCB_QSIZE_128,
+		SCB_QSIZE_256,
+		SCB_QSIZE_512,
+		SCB_QSIZE_1024,
+		SCB_QSIZE_2048,
+		SCB_QSIZE_4096,
+		SCB_QSIZE_8192,
+		SCB_QSIZE_16384
+	}
+}
+
+/*
+ * Interrupt Control
+ */
+register INTCTL {
+	address			0x018
+	access_mode	RW
+	field	SWTMINTMASK	0x80
+	field	SWTMINTEN	0x40
+	field	SWTIMER_START	0x20
+	field	AUTOCLRCMDINT	0x10
+	field	PCIINTEN	0x08
+	field	SCSIINTEN	0x04
+	field	SEQINTEN	0x02
+	field	SPLTINTEN	0x01
+}
+
+/*
+ * Data FIFO Control
+ */
+register DFCNTRL {
+	address			0x019
+	access_mode	RW
+	modes		M_DFF0, M_DFF1
+	field	PRELOADEN	0x80
+	field	SCSIENWRDIS	0x40	/* Rev B only. */
+	field	SCSIEN		0x20
+	field	SCSIENACK	0x20
+	field	HDMAEN		0x08
+	field	HDMAENACK	0x08
+	field	DIRECTION	0x04
+	field	DIRECTIONACK	0x04
+	field	FIFOFLUSH	0x02
+	field	FIFOFLUSHACK	0x02
+	field	DIRECTIONEN	0x01
+}
+
+/*
+ * Device Space Command 0
+ */
+register DSCOMMAND0 {
+	address			0x019
+	access_mode	RW
+	modes		M_CFG
+	field	CACHETHEN	0x80	/* Cache Threshold enable */
+	field	DPARCKEN	0x40	/* Data Parity Check Enable */
+	field	MPARCKEN	0x20	/* Memory Parity Check Enable */
+	field	EXTREQLCK	0x10	/* External Request Lock */
+	field	DISABLE_TWATE	0x02	/* Rev B or greater */
+	field	CIOPARCKEN	0x01	/* Internal bus parity error enable */
+}
+
+/*
+ * Data FIFO Status
+ */
+register DFSTATUS {
+	address			0x01A
+	access_mode	RO
+	modes		M_DFF0, M_DFF1
+	field	PRELOAD_AVAIL		0x80
+	field	PKT_PRELOAD_AVAIL	0x40
+	field	MREQPEND		0x10
+	field	HDONE			0x08
+	field	DFTHRESH		0x04
+	field	FIFOFULL		0x02
+	field	FIFOEMP			0x01
+}
+
+/*
+ * S/G Cache Pointer
+ */
+register SG_CACHE_PRE {
+	address			0x01B
+	access_mode	WO
+	modes		M_DFF0, M_DFF1
+	field	SG_ADDR_MASK	0xf8
+	field	ODD_SEG		0x04
+	field	LAST_SEG	0x02
+}
+
+register SG_CACHE_SHADOW {
+	address			0x01B
+	access_mode	RO
+	modes		M_DFF0, M_DFF1
+	field	SG_ADDR_MASK	0xf8
+	field	ODD_SEG		0x04
+	field	LAST_SEG	0x02
+	field	LAST_SEG_DONE	0x01
+}
+
+/*
+ * Arbiter Control
+ */
+register ARBCTL {
+	address			0x01B
+	access_mode	RW
+	modes		M_CFG
+	field	RESET_HARB	0x80
+	field	RETRY_SWEN	0x08
+	field	USE_TIME	0x07
+}
+
+/*
+ * Data Channel Host Address
+ */
+register HADDR {
+	address			0x070
+	access_mode	RW
+	size		8
+	modes		M_DFF0, M_DFF1
+}
+
+/*
+ * Host Overlay DMA Address
+ */
+register HODMAADR {
+	address			0x070
+	access_mode	RW
+	size		8
+	modes		M_SCSI
+}
+
+/*
+ * PCI PLL Delay.
+ */
+register PLLDELAY {
+	address			0x070
+	access_mode	RW
+	size		1
+	modes		M_CFG
+	field	SPLIT_DROP_REQ	0x80
+}
+
+/*
+ * Data Channel Host Count
+ */
+register HCNT {
+	address			0x078
+	access_mode	RW
+	size		3
+	modes		M_DFF0, M_DFF1
+}
+
+/*
+ * Host Overlay DMA Count
+ */
+register HODMACNT {
+	address			0x078
+	access_mode	RW
+	size		2
+	modes		M_SCSI
+}
+
+/*
+ * Host Overlay DMA Enable
+ */
+register HODMAEN {
+	address			0x07A
+	access_mode	RW
+	modes		M_SCSI
+}
+
+/*
+ * Scatter/Gather Host Address
+ */
+register SGHADDR {
+	address			0x07C
+	access_mode	RW
+	size		8
+	modes		M_DFF0, M_DFF1
+}
+
+/*
+ * SCB Host Address
+ */
+register SCBHADDR {
+	address			0x07C
+	access_mode	RW
+	size		8
+	modes		M_CCHAN
+}
+
+/*
+ * Scatter/Gather Host Count
+ */
+register SGHCNT {
+	address			0x084
+	access_mode	RW
+	modes		M_DFF0, M_DFF1
+}
+
+/*
+ * SCB Host Count
+ */
+register SCBHCNT {
+	address			0x084
+	access_mode	RW
+	modes		M_CCHAN
+}
+
+/*
+ * Data FIFO Threshold
+ */
+register DFF_THRSH {
+	address			0x088
+	access_mode	RW
+	modes		M_CFG
+	field	WR_DFTHRSH	0x70 {
+		WR_DFTHRSH_MIN,
+		WR_DFTHRSH_25,
+		WR_DFTHRSH_50,
+		WR_DFTHRSH_63,
+		WR_DFTHRSH_75,
+		WR_DFTHRSH_85,
+		WR_DFTHRSH_90,
+		WR_DFTHRSH_MAX
+	}
+	field	RD_DFTHRSH	0x07 {
+		RD_DFTHRSH_MIN,
+		RD_DFTHRSH_25,
+		RD_DFTHRSH_50,
+		RD_DFTHRSH_63,
+		RD_DFTHRSH_75,
+		RD_DFTHRSH_85,
+		RD_DFTHRSH_90,
+		RD_DFTHRSH_MAX
+	}
+}
+
+/*
+ * ROM Address
+ */
+register ROMADDR {
+	address			0x08A
+	access_mode	RW
+	size		3
+}
+
+/*
+ * ROM Control
+ */
+register ROMCNTRL {
+	address			0x08D
+	access_mode	RW
+	field	ROMOP		0xE0
+	field	ROMSPD		0x18
+	field	REPEAT		0x02
+	field	RDY		0x01
+}
+
+/*
+ * ROM Data
+ */
+register ROMDATA {
+	address			0x08E
+	access_mode	RW
+}
+
+/*
+ * Data Channel Receive Message 0
+ */
+register DCHRXMSG0 {
+	address			0x090
+	access_mode	RO
+	modes		M_DFF0, M_DFF1
+	field		CDNUM	0xF8
+	field		CFNUM	0x07
+}
+
+/*
+ * CMC Recieve Message 0
+ */
+register CMCRXMSG0 {
+	address			0x090
+	access_mode	RO
+	modes		M_CCHAN
+	field		CDNUM	0xF8
+	field		CFNUM	0x07
+}
+
+/*
+ * Overlay Recieve Message 0
+ */
+register OVLYRXMSG0 {
+	address			0x090
+	access_mode	RO
+	modes		M_SCSI
+	field		CDNUM	0xF8
+	field		CFNUM	0x07
+}
+
+/*
+ * Relaxed Order Enable
+ */
+register ROENABLE {
+	address			0x090
+	access_mode	RW
+	modes		M_CFG
+	field	MSIROEN		0x20
+	field	OVLYROEN	0x10
+	field	CMCROEN		0x08
+	field	SGROEN		0x04
+	field	DCH1ROEN	0x02
+	field	DCH0ROEN	0x01
+}
+
+/*
+ * Data Channel Receive Message 1
+ */
+register DCHRXMSG1 {
+	address			0x091
+	access_mode	RO
+	modes		M_DFF0, M_DFF1
+	field	CBNUM		0xFF
+}
+
+/*
+ * CMC Recieve Message 1
+ */
+register CMCRXMSG1 {
+	address			0x091
+	access_mode	RO
+	modes		M_CCHAN
+	field	CBNUM		0xFF
+}
+
+/*
+ * Overlay Recieve Message 1
+ */
+register OVLYRXMSG1 {
+	address			0x091
+	access_mode	RO
+	modes		M_SCSI
+	field	CBNUM		0xFF
+}
+
+/*
+ * No Snoop Enable
+ */
+register NSENABLE {
+	address			0x091
+	access_mode	RW
+	modes		M_CFG
+	field	MSINSEN		0x20
+	field	OVLYNSEN	0x10
+	field	CMCNSEN		0x08
+	field	SGNSEN		0x04
+	field	DCH1NSEN	0x02
+	field	DCH0NSEN	0x01
+}
+
+/*
+ * Data Channel Receive Message 2
+ */
+register DCHRXMSG2 {
+	address			0x092
+	access_mode	RO
+	modes		M_DFF0, M_DFF1
+	field	MINDEX		0xFF
+}
+
+/*
+ * CMC Recieve Message 2
+ */
+register CMCRXMSG2 {
+	address			0x092
+	access_mode	RO
+	modes		M_CCHAN
+	field	MINDEX		0xFF
+}
+
+/*
+ * Overlay Recieve Message 2
+ */
+register OVLYRXMSG2 {
+	address			0x092
+	access_mode	RO
+	modes		M_SCSI
+	field	MINDEX		0xFF
+}
+
+/*
+ * Outstanding Split Transactions
+ */
+register OST {
+	address			0x092
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * Data Channel Receive Message 3
+ */
+register DCHRXMSG3 {
+	address			0x093
+	access_mode	RO
+	modes		M_DFF0, M_DFF1
+	field	MCLASS		0x0F
+}
+
+/*
+ * CMC Recieve Message 3
+ */
+register CMCRXMSG3 {
+	address			0x093
+	access_mode	RO
+	modes		M_CCHAN
+	field	MCLASS		0x0F
+}
+
+/*
+ * Overlay Recieve Message 3
+ */
+register OVLYRXMSG3 {
+	address			0x093
+	access_mode	RO
+	modes		M_SCSI
+	field	MCLASS		0x0F
+}
+
+/*
+ * PCI-X Control
+ */
+register PCIXCTL {
+	address			0x093
+	access_mode	RW
+	modes		M_CFG
+	field	SERRPULSE	0x80
+	field	UNEXPSCIEN	0x20
+	field	SPLTSMADIS	0x10
+	field	SPLTSTADIS	0x08
+	field	SRSPDPEEN	0x04
+	field	TSCSERREN	0x02
+	field	CMPABCDIS	0x01
+}
+
+/*
+ * CMC Sequencer Byte Count
+ */
+register CMCSEQBCNT {
+	address			0x094
+	access_mode	RO
+	modes		M_CCHAN
+}
+
+/*
+ * Overlay Sequencer Byte Count
+ */
+register OVLYSEQBCNT {
+	address			0x094
+	access_mode	RO
+	modes		M_SCSI
+}
+
+/*
+ * Data Channel Sequencer Byte Count
+ */
+register DCHSEQBCNT {
+	address			0x094
+	access_mode	RO
+	size		2
+	modes		M_DFF0, M_DFF1
+}
+
+/*
+ * Data Channel Split Status 0
+ */
+register DCHSPLTSTAT0 {
+	address			0x096
+	access_mode	RW
+	modes		M_DFF0, M_DFF1
+	field	STAETERM	0x80
+	field	SCBCERR		0x40
+	field	SCADERR		0x20
+	field	SCDATBUCKET	0x10
+	field	CNTNOTCMPLT	0x08
+	field	RXOVRUN		0x04
+	field	RXSCEMSG	0x02
+	field	RXSPLTRSP	0x01
+}
+
+/*
+ * CMC Split Status 0
+ */
+register CMCSPLTSTAT0 {
+	address			0x096
+	access_mode	RW
+	modes		M_CCHAN
+	field	STAETERM	0x80
+	field	SCBCERR		0x40
+	field	SCADERR		0x20
+	field	SCDATBUCKET	0x10
+	field	CNTNOTCMPLT	0x08
+	field	RXOVRUN		0x04
+	field	RXSCEMSG	0x02
+	field	RXSPLTRSP	0x01
+}
+
+/*
+ * Overlay Split Status 0
+ */
+register OVLYSPLTSTAT0 {
+	address			0x096
+	access_mode	RW
+	modes		M_SCSI
+	field	STAETERM	0x80
+	field	SCBCERR		0x40
+	field	SCADERR		0x20
+	field	SCDATBUCKET	0x10
+	field	CNTNOTCMPLT	0x08
+	field	RXOVRUN		0x04
+	field	RXSCEMSG	0x02
+	field	RXSPLTRSP	0x01
+}
+
+/*
+ * Data Channel Split Status 1
+ */
+register DCHSPLTSTAT1 {
+	address			0x097
+	access_mode	RW
+	modes		M_DFF0, M_DFF1
+	field	RXDATABUCKET	0x01
+}
+
+/*
+ * CMC Split Status 1
+ */
+register CMCSPLTSTAT1 {
+	address			0x097
+	access_mode	RW
+	modes		M_CCHAN
+	field	RXDATABUCKET	0x01
+}
+
+/*
+ * Overlay Split Status 1
+ */
+register OVLYSPLTSTAT1 {
+	address			0x097
+	access_mode	RW
+	modes		M_SCSI
+	field	RXDATABUCKET	0x01
+}
+
+/*
+ * S/G Receive Message 0
+ */
+register SGRXMSG0 {
+	address			0x098
+	access_mode	RO
+	modes		M_DFF0, M_DFF1
+	field		CDNUM	0xF8
+	field		CFNUM	0x07
+}
+
+/*
+ * S/G Receive Message 1
+ */
+register SGRXMSG1 {
+	address			0x099
+	access_mode	RO
+	modes		M_DFF0, M_DFF1
+	field	CBNUM		0xFF
+}
+
+/*
+ * S/G Receive Message 2
+ */
+register SGRXMSG2 {
+	address			0x09A
+	access_mode	RO
+	modes		M_DFF0, M_DFF1
+	field	MINDEX		0xFF
+}
+
+/*
+ * S/G Receive Message 3
+ */
+register SGRXMSG3 {
+	address			0x09B
+	access_mode	RO
+	modes		M_DFF0, M_DFF1
+	field	MCLASS		0x0F
+}
+
+/*
+ * Slave Split Out Address 0
+ */
+register SLVSPLTOUTADR0 {
+	address			0x098
+	access_mode	RO
+	modes		M_SCSI
+	field	LOWER_ADDR	0x7F
+}
+
+/*
+ * Slave Split Out Address 1
+ */
+register SLVSPLTOUTADR1 {
+	address			0x099
+	access_mode	RO
+	modes		M_SCSI
+	field	REQ_DNUM	0xF8
+	field	REQ_FNUM	0x07
+}
+
+/*
+ * Slave Split Out Address 2
+ */
+register SLVSPLTOUTADR2 {
+	address			0x09A
+	access_mode	RO
+	modes		M_SCSI
+	field	REQ_BNUM	0xFF
+}
+
+/*
+ * Slave Split Out Address 3
+ */
+register SLVSPLTOUTADR3 {
+	address			0x09B
+	access_mode	RO
+	modes		M_SCSI
+	field	RLXORD		020
+	field	TAG_NUM		0x1F
+}
+
+/*
+ * SG Sequencer Byte Count
+ */
+register SGSEQBCNT {
+	address			0x09C
+	access_mode	RO
+	modes		M_DFF0, M_DFF1
+}
+
+/*
+ * Slave Split Out Attribute 0
+ */
+register SLVSPLTOUTATTR0 {
+	address			0x09C
+	access_mode	RO
+	modes		M_SCSI
+	field	LOWER_BCNT	0xFF
+}
+
+/*
+ * Slave Split Out Attribute 1
+ */
+register SLVSPLTOUTATTR1 {
+	address			0x09D
+	access_mode	RO
+	modes		M_SCSI
+	field	CMPLT_DNUM	0xF8
+	field	CMPLT_FNUM	0x07
+}
+
+/*
+ * Slave Split Out Attribute 2
+ */
+register SLVSPLTOUTATTR2 {
+	address			0x09E
+	access_mode	RO
+	size		2
+	modes		M_SCSI
+	field	CMPLT_BNUM	0xFF
+}
+/*
+ * S/G Split Status 0
+ */
+register SGSPLTSTAT0 {
+	address			0x09E
+	access_mode	RW
+	modes		M_DFF0, M_DFF1
+	field	STAETERM	0x80
+	field	SCBCERR		0x40
+	field	SCADERR		0x20
+	field	SCDATBUCKET	0x10
+	field	CNTNOTCMPLT	0x08
+	field	RXOVRUN		0x04
+	field	RXSCEMSG	0x02
+	field	RXSPLTRSP	0x01
+}
+
+/*
+ * S/G Split Status 1
+ */
+register SGSPLTSTAT1 {
+	address			0x09F
+	access_mode	RW
+	modes		M_DFF0, M_DFF1
+	field	RXDATABUCKET	0x01
+}
+
+/*
+ * Special Function
+ */
+register SFUNCT {
+	address			0x09f
+	access_mode	RW
+	modes		M_CFG
+	field	TEST_GROUP	0xF0
+	field	TEST_NUM	0x0F
+}
+
+/*
+ * Data FIFO 0 PCI Status 
+ */
+register DF0PCISTAT {
+	address			0x0A0
+	access_mode	RW
+	modes		M_CFG
+	field	DPE		0x80
+	field	SSE		0x40
+	field	RMA		0x20
+	field	RTA		0x10
+	field	SCAAPERR	0x08
+	field	RDPERR		0x04
+	field	TWATERR		0x02
+	field	DPR		0x01
+}
+
+/*
+ * Data FIFO 1 PCI Status 
+ */
+register DF1PCISTAT {
+	address			0x0A1
+	access_mode	RW
+	modes		M_CFG
+	field	DPE		0x80
+	field	SSE		0x40
+	field	RMA		0x20
+	field	RTA		0x10
+	field	SCAAPERR	0x08
+	field	RDPERR		0x04
+	field	TWATERR		0x02
+	field	DPR		0x01
+}
+
+/*
+ * S/G PCI Status 
+ */
+register SGPCISTAT {
+	address			0x0A2
+	access_mode	RW
+	modes		M_CFG
+	field	DPE		0x80
+	field	SSE		0x40
+	field	RMA		0x20
+	field	RTA		0x10
+	field	SCAAPERR	0x08
+	field	RDPERR		0x04
+	field	DPR		0x01
+}
+
+/*
+ * CMC PCI Status 
+ */
+register CMCPCISTAT {
+	address			0x0A3
+	access_mode	RW
+	modes		M_CFG
+	field	DPE		0x80
+	field	SSE		0x40
+	field	RMA		0x20
+	field	RTA		0x10
+	field	SCAAPERR	0x08
+	field	RDPERR		0x04
+	field	TWATERR		0x02
+	field	DPR		0x01
+}
+
+/*
+ * Overlay PCI Status 
+ */
+register OVLYPCISTAT {
+	address			0x0A4
+	access_mode	RW
+	modes		M_CFG
+	field	DPE		0x80
+	field	SSE		0x40
+	field	RMA		0x20
+	field	RTA		0x10
+	field	SCAAPERR	0x08
+	field	RDPERR		0x04
+	field	DPR		0x01
+}
+
+/*
+ * PCI Status for MSI Master DMA Transfer
+ */
+register MSIPCISTAT {
+	address			0x0A6
+	access_mode	RW
+	modes		M_CFG
+	field	SSE		0x40
+	field	RMA		0x20
+	field	RTA		0x10
+	field	CLRPENDMSI	0x08
+	field	TWATERR		0x02
+	field	DPR		0x01
+}
+
+/*
+ * PCI Status for Target
+ */
+register TARGPCISTAT {
+	address			0x0A7
+	access_mode	RW
+	modes		M_CFG
+	field	DPE		0x80
+	field	SSE		0x40
+	field	STA		0x08
+	field	TWATERR		0x02
+}
+
+/*
+ * LQ Packet In
+ * The last LQ Packet recieved
+ */
+register LQIN {
+	address			0x020
+	access_mode	RW
+	size		20
+	modes		M_DFF0, M_DFF1, M_SCSI
+}
+
+/*
+ * SCB Type Pointer
+ * SCB offset for Target Mode SCB type information
+ */
+register TYPEPTR {
+	address			0x020
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * Queue Tag Pointer
+ * SCB offset to the Two Byte tag identifier used for target mode.
+ */
+register TAGPTR {
+	address			0x021
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * Logical Unit Number Pointer
+ * SCB offset to the LSB (little endian) of the lun field.
+ */
+register LUNPTR {
+	address			0x022
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * Data Length Pointer
+ * SCB offset for the 4 byte data length field in target mode.
+ */
+register DATALENPTR {
+	address			0x023
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * Status Length Pointer
+ * SCB offset to the two byte status field in target SCBs.
+ */
+register STATLENPTR {
+	address			0x024
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * Command Length Pointer
+ * Scb offset for the CDB length field in initiator SCBs.
+ */
+register CMDLENPTR {
+	address			0x025
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * Task Attribute Pointer
+ * Scb offset for the byte field specifying the attribute byte
+ * to be used in command packets.
+ */ 
+register ATTRPTR {
+	address			0x026
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * Task Management Flags Pointer
+ * Scb offset for the byte field specifying the attribute flags
+ * byte to be used in command packets.
+ */ 
+register FLAGPTR {
+	address			0x027
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * Command Pointer
+ * Scb offset for the first byte in the CDB for initiator SCBs.
+ */
+register CMDPTR {
+	address			0x028
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * Queue Next Pointer
+ * Scb offset for the 2 byte "next scb link".
+ */
+register QNEXTPTR {
+	address			0x029
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * SCSI ID Pointer
+ * Scb offset to the value to place in the SCSIID register
+ * during target mode connections.
+ */
+register IDPTR {
+	address			0x02A
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * Command Aborted Byte Pointer
+ * Offset to the SCB flags field that includes the
+ * "SCB aborted" status bit.
+ */
+register ABRTBYTEPTR {
+	address			0x02B
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * Command Aborted Bit Pointer
+ * Bit offset in the SCB flags field for "SCB aborted" status.
+ */
+register ABRTBITPTR {
+	address			0x02C
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * Rev B or greater.
+ */
+register MAXCMDBYTES {
+	address			0x02D
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * Rev B or greater.
+ */
+register MAXCMD2RCV {
+	address			0x02E
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * Rev B or greater.
+ */
+register SHORTTHRESH {
+	address			0x02F
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * Logical Unit Number Length
+ * The length, in bytes, of the SCB lun field.
+ */
+register LUNLEN {
+	address			0x030
+	access_mode	RW
+	modes		M_CFG
+	mask		ILUNLEN	0x0F
+	mask		TLUNLEN	0xF0
+}
+const LUNLEN_SINGLE_LEVEL_LUN 0xF
+
+/*
+ * CDB Limit
+ * The size, in bytes, of the embedded CDB field in initator SCBs.
+ */
+register CDBLIMIT {
+	address			0x031
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * Maximum Commands
+ * The maximum number of commands to issue during a
+ * single packetized connection.
+ */
+register MAXCMD {
+	address			0x032
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * Maximum Command Counter
+ * The number of commands already sent during this connection
+ */
+register MAXCMDCNT {
+	address			0x033
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * LQ Packet Reserved Bytes
+ * The bytes to be sent in the currently reserved fileds
+ * of all LQ packets.
+ */
+register LQRSVD01 {
+	address			0x034
+	access_mode	RW
+	modes		M_SCSI
+}
+register LQRSVD16 {
+	address			0x035
+	access_mode	RW
+	modes		M_SCSI
+}
+register LQRSVD17 {
+	address			0x036
+	access_mode	RW
+	modes		M_SCSI
+}
+
+/*
+ * Command Reserved 0
+ * The byte to be sent for the reserved byte 0 of
+ * outgoing command packets.
+ */
+register CMDRSVD0 {
+	address			0x037
+	access_mode	RW
+	modes		M_CFG
+}
+
+/*
+ * LQ Manager Control 0
+ */
+register LQCTL0 {
+	address			0x038
+	access_mode	RW
+	modes		M_CFG
+	field	LQITARGCLT	0xC0
+	field	LQIINITGCLT	0x30
+	field	LQ0TARGCLT	0x0C
+	field	LQ0INITGCLT	0x03
+}
+
+/*
+ * LQ Manager Control 1
+ */
+register LQCTL1 {
+	address			0x038
+	access_mode	RW
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	PCI2PCI		0x04
+	field	SINGLECMD	0x02
+	field	ABORTPENDING	0x01
+}
+
+/*
+ * LQ Manager Control 2
+ */
+register LQCTL2 {
+	address			0x039
+	access_mode	RW
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	LQIRETRY	0x80
+	field	LQICONTINUE	0x40
+	field	LQITOIDLE	0x20
+	field	LQIPAUSE	0x10
+	field	LQORETRY	0x08
+	field	LQOCONTINUE	0x04
+	field	LQOTOIDLE	0x02
+	field	LQOPAUSE	0x01
+}
+
+/*
+ * SCSI RAM BIST0
+ */
+register SCSBIST0 {
+	address			0x039
+	access_mode	RW
+	modes		M_CFG
+	field	GSBISTERR	0x40
+	field	GSBISTDONE	0x20
+	field	GSBISTRUN	0x10
+	field	OSBISTERR	0x04
+	field	OSBISTDONE	0x02
+	field	OSBISTRUN	0x01
+}
+
+/*
+ * SCSI Sequence Control0
+ */
+register SCSISEQ0 {
+	address			0x03A
+	access_mode	RW
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	TEMODEO		0x80
+	field	ENSELO		0x40
+	field	ENARBO		0x20
+	field	FORCEBUSFREE	0x10
+	field	SCSIRSTO	0x01
+}
+
+/*
+ * SCSI RAM BIST 1
+ */
+register SCSBIST1 {
+	address			0x03A
+	access_mode	RW
+	modes		M_CFG
+	field	NTBISTERR	0x04
+	field	NTBISTDONE	0x02
+	field	NTBISTRUN	0x01
+}
+
+/*
+ * SCSI Sequence Control 1
+ */
+register SCSISEQ1 {
+	address			0x03B
+	access_mode	RW
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	MANUALCTL	0x40
+	field	ENSELI		0x20
+	field	ENRSELI		0x10
+	field	MANUALP		0x0C
+	field	ENAUTOATNP	0x02
+	field	ALTSTIM		0x01
+}
+
+/*
+ * SCSI Transfer Control 0
+ */
+register SXFRCTL0 {
+	address			0x03C
+	access_mode	RW
+	modes		M_SCSI
+	field	DFON		0x80
+	field	DFPEXP		0x40
+	field	BIOSCANCELEN	0x10
+	field	SPIOEN		0x08
+}
+
+/*
+ * SCSI Transfer Control 1
+ */
+register SXFRCTL1 {
+	address			0x03D
+	access_mode	RW
+	modes		M_SCSI
+	field	BITBUCKET	0x80
+	field	ENSACHK		0x40
+	field	ENSPCHK		0x20
+	field	STIMESEL	0x18
+	field	ENSTIMER	0x04
+	field	ACTNEGEN	0x02
+	field	STPWEN		0x01
+}
+
+/*
+ * SCSI Transfer Control 2
+ */
+register SXFRCTL2 {
+	address			0x03E
+	access_mode	RW
+	modes		M_SCSI
+	field	AUTORSTDIS	0x10
+	field	CMDDMAEN	0x08
+	field	ASU		0x07
+}
+
+/*
+ * SCSI Bus Initiator IDs
+ * Bitmask of observed initiators on the bus.
+ */
+register BUSINITID {
+	address			0x03C
+	access_mode	RW
+	modes		M_CFG
+	size		2
+}
+
+/*
+ * Data Length Counters
+ * Packet byte counter.
+ */
+register DLCOUNT {
+	address			0x03C
+	access_mode	RW
+	modes		M_DFF0, M_DFF1
+	size		3
+}
+
+/*
+ * Data FIFO Status
+ */
+register DFFSTAT {
+	address			0x03F
+	access_mode	RW
+	modes		M_SCSI
+	field	FIFO1FREE	0x20
+	field	FIFO0FREE	0x10
+	/*
+	 * On the B, this enum only works
+	 * in the read direction.  For writes,
+	 * you must use the B version of the
+	 * CURRFIFO_0 definition which is defined
+	 * as a constant outside of this register
+	 * definition to avoid confusing the
+	 * register pretty printing code.
+	 */
+	enum	CURRFIFO	0x03 {
+		CURRFIFO_0,
+		CURRFIFO_1,
+		CURRFIFO_NONE	0x3
+	}
+}
+
+const B_CURRFIFO_0 0x2
+
+/*
+ * SCSI Bus Target IDs
+ * Bitmask of observed targets on the bus.
+ */
+register BUSTARGID {
+	address			0x03E
+	access_mode	RW
+	modes		M_CFG
+	size		2
+}
+
+/*
+ * SCSI Control Signal Out
+ */
+register SCSISIGO {
+	address			0x040
+	access_mode	RW
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	CDO		0x80
+	field	IOO		0x40
+	field	MSGO		0x20
+	field	ATNO		0x10
+	field	SELO		0x08
+	field	BSYO		0x04
+	field	REQO		0x02
+	field	ACKO		0x01
+/*
+ * Possible phases to write into SCSISIG0
+ */
+	enum	PHASE_MASK  CDO|IOO|MSGO {
+		P_DATAOUT	0x0,
+		P_DATAIN	IOO,
+		P_DATAOUT_DT	P_DATAOUT|MSGO,
+		P_DATAIN_DT	P_DATAIN|MSGO,
+		P_COMMAND	CDO,
+		P_MESGOUT	CDO|MSGO,
+		P_STATUS	CDO|IOO,
+		P_MESGIN	CDO|IOO|MSGO
+	}
+}
+
+register SCSISIGI {
+	address			0x041
+	access_mode	RO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	CDI		0x80
+	field	IOI		0x40
+	field	MSGI		0x20
+	field	ATNI		0x10
+	field	SELI		0x08
+	field	BSYI		0x04
+	field	REQI		0x02
+	field	ACKI		0x01
+/*
+ * Possible phases in SCSISIGI
+ */
+	enum	PHASE_MASK  CDO|IOO|MSGO {
+		P_DATAOUT	0x0,
+		P_DATAIN	IOO,
+		P_DATAOUT_DT	P_DATAOUT|MSGO,
+		P_DATAIN_DT	P_DATAIN|MSGO,
+		P_COMMAND	CDO,
+		P_MESGOUT	CDO|MSGO,
+		P_STATUS	CDO|IOO,
+		P_MESGIN	CDO|IOO|MSGO
+	}
+}
+
+/*
+ * Multiple Target IDs
+ * Bitmask of ids to respond as a target.
+ */
+register MULTARGID {
+	address			0x040
+	access_mode	RW
+	modes		M_CFG
+	size		2
+}
+
+/*
+ * SCSI Phase
+ */
+register SCSIPHASE {
+	address			0x042
+	access_mode	RO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	STATUS_PHASE	0x20
+	field	COMMAND_PHASE	0x10
+	field	MSG_IN_PHASE	0x08
+	field	MSG_OUT_PHASE	0x04
+	field	DATA_PHASE_MASK	0x03 {
+		DATA_OUT_PHASE	0x01,
+		DATA_IN_PHASE	0x02
+	}
+}
+
+/*
+ * SCSI Data 0 Image
+ */
+register SCSIDAT0_IMG {
+	address			0x043
+	access_mode	RW
+	modes		M_DFF0, M_DFF1, M_SCSI
+}
+
+/*
+ * SCSI Latched Data
+ */
+register SCSIDAT {
+	address			0x044
+	access_mode	RW
+	modes		M_DFF0, M_DFF1, M_SCSI
+	size		2
+}
+
+/*
+ * SCSI Data Bus
+ */
+register SCSIBUS {
+	address			0x046
+	access_mode	RW
+	modes		M_DFF0, M_DFF1, M_SCSI
+	size		2
+}
+
+/*
+ * Target ID In
+ */
+register TARGIDIN {
+	address			0x048
+	access_mode	RO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	CLKOUT		0x80
+	field	TARGID		0x0F
+}
+
+/*
+ * Selection/Reselection ID
+ * Upper four bits are the device id.  The ONEBIT is set when the re/selecting
+ * device did not set its own ID.
+ */
+register SELID {
+	address			0x049
+	access_mode	RW
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	SELID_MASK	0xf0
+	field	ONEBIT		0x08
+}
+
+/*
+ * SCSI Block Control
+ * Controls Bus type and channel selection.  SELWIDE allows for the
+ * coexistence of 8bit and 16bit devices on a wide bus.
+ */
+register SBLKCTL {
+	address			0x04A
+	access_mode	RW
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	DIAGLEDEN	0x80
+	field	DIAGLEDON	0x40
+	field	ENAB40		0x08	/* LVD transceiver active */
+	field	ENAB20		0x04	/* SE/HVD transceiver active */
+	field	SELWIDE		0x02
+}
+
+/*
+ * Option Mode
+ */
+register OPTIONMODE {
+	address			0x04A
+	access_mode	RW
+	modes		M_CFG
+	field	BIOSCANCTL		0x80
+	field	AUTOACKEN		0x40
+	field	BIASCANCTL		0x20
+	field	BUSFREEREV		0x10
+	field	ENDGFORMCHK		0x04
+	field	AUTO_MSGOUT_DE		0x02
+	mask	OPTIONMODE_DEFAULTS	AUTO_MSGOUT_DE
+}
+
+/*
+ * SCSI Status 0
+ */
+register SSTAT0	{
+	address			0x04B
+	access_mode	RO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	TARGET		0x80	/* Board acting as target */
+	field	SELDO		0x40	/* Selection Done */
+	field	SELDI		0x20	/* Board has been selected */
+	field	SELINGO		0x10	/* Selection In Progress */
+	field	IOERR		0x08	/* LVD Tranceiver mode changed */
+	field	OVERRUN		0x04	/* SCSI Offset overrun detected */
+	field	SPIORDY		0x02	/* SCSI PIO Ready */
+	field	ARBDO		0x01	/* Arbitration Done Out */
+}
+
+/*
+ * Clear SCSI Interrupt 0
+ * Writing a 1 to a bit clears the associated SCSI Interrupt in SSTAT0.
+ */
+register CLRSINT0 {
+	address			0x04B
+	access_mode	WO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	CLRSELDO	0x40
+	field	CLRSELDI	0x20
+	field	CLRSELINGO	0x10
+	field	CLRIOERR	0x08
+	field	CLROVERRUN	0x04
+	field	CLRSPIORDY	0x02
+	field	CLRARBDO	0x01
+}
+
+/*
+ * SCSI Interrupt Mode 0
+ * Setting any bit will enable the corresponding function
+ * in SIMODE0 to interrupt via the IRQ pin.
+ */
+register SIMODE0 {
+	address			0x04B
+	access_mode	RW
+	modes		M_CFG
+	field	ENSELDO		0x40
+	field	ENSELDI		0x20
+	field	ENSELINGO	0x10
+	field	ENIOERR		0x08
+	field	ENOVERRUN	0x04
+	field	ENSPIORDY	0x02
+	field	ENARBDO		0x01
+}
+
+/*
+ * SCSI Status 1
+ */
+register SSTAT1 {
+	address			0x04C
+	access_mode	RO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	SELTO		0x80
+	field	ATNTARG 	0x40
+	field	SCSIRSTI	0x20
+	field	PHASEMIS	0x10
+	field	BUSFREE		0x08
+	field	SCSIPERR	0x04
+	field	STRB2FAST	0x02
+	field	REQINIT		0x01
+}
+
+/*
+ * Clear SCSI Interrupt 1
+ * Writing a 1 to a bit clears the associated SCSI Interrupt in SSTAT1.
+ */
+register CLRSINT1 {
+	address			0x04C
+	access_mode	WO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	CLRSELTIMEO	0x80
+	field	CLRATNO		0x40
+	field	CLRSCSIRSTI	0x20
+	field	CLRBUSFREE	0x08
+	field	CLRSCSIPERR	0x04
+	field	CLRSTRB2FAST	0x02
+	field	CLRREQINIT	0x01
+}
+
+/*
+ * SCSI Status 2
+ */
+register SSTAT2 {
+	address			0x04d
+	access_mode	RO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	BUSFREETIME	0xc0 {
+		BUSFREE_LQO	0x40,
+		BUSFREE_DFF0	0x80,
+		BUSFREE_DFF1	0xC0
+	}
+	field	NONPACKREQ	0x20
+	field	EXP_ACTIVE	0x10	/* SCSI Expander Active */
+	field	BSYX		0x08	/* Busy Expander */
+	field	WIDE_RES	0x04	/* Modes 0 and 1 only */
+	field	SDONE		0x02	/* Modes 0 and 1 only */
+	field	DMADONE		0x01	/* Modes 0 and 1 only */
+}
+
+/*
+ * Clear SCSI Interrupt 2
+ */
+register CLRSINT2 {
+	address			0x04D
+	access_mode	WO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	CLRNONPACKREQ	0x20
+	field	CLRWIDE_RES	0x04	/* Modes 0 and 1 only */
+	field	CLRSDONE	0x02	/* Modes 0 and 1 only */
+	field	CLRDMADONE	0x01	/* Modes 0 and 1 only */
+}
+
+/*
+ * SCSI Interrupt Mode 2
+ */
+register SIMODE2 {
+	address			0x04D
+	access_mode	RW
+	modes		M_CFG
+	field	ENWIDE_RES	0x04
+	field	ENSDONE		0x02
+	field	ENDMADONE	0x01
+}
+
+/*
+ * Physical Error Diagnosis
+ */
+register PERRDIAG {
+	address			0x04E
+	access_mode	RO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	HIZERO		0x80
+	field	HIPERR		0x40
+	field	PREVPHASE	0x20
+	field	PARITYERR	0x10
+	field	AIPERR		0x08
+	field	CRCERR		0x04
+	field	DGFORMERR	0x02
+	field	DTERR		0x01
+}
+
+/*
+ * LQI Manager Current State
+ */
+register LQISTATE {
+	address			0x04E
+	access_mode	RO
+	modes		M_CFG
+}
+
+/*
+ * SCSI Offset Count
+ */
+register SOFFCNT {
+	address			0x04F
+	access_mode	RO
+	modes		M_DFF0, M_DFF1, M_SCSI
+}
+
+/*
+ * LQO Manager Current State
+ */
+register LQOSTATE {
+	address			0x04F
+	access_mode	RO
+	modes		M_CFG
+}
+
+/*
+ * LQI Manager Status
+ */
+register LQISTAT0 {
+	address			0x050
+	access_mode	RO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	LQIATNQAS	0x20
+	field	LQICRCT1	0x10
+	field	LQICRCT2	0x08
+	field	LQIBADLQT	0x04
+	field	LQIATNLQ	0x02
+	field	LQIATNCMD	0x01
+}
+
+/*
+ * Clear LQI Interrupts 0
+ */
+register CLRLQIINT0 {
+	address			0x050
+	access_mode	WO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	CLRLQIATNQAS	0x20
+	field	CLRLQICRCT1	0x10
+	field	CLRLQICRCT2	0x08
+	field	CLRLQIBADLQT	0x04
+	field	CLRLQIATNLQ	0x02
+	field	CLRLQIATNCMD	0x01
+}
+
+/*
+ * LQI Manager Interrupt Mode 0
+ */
+register LQIMODE0 {
+	address			0x050
+	access_mode	RW
+	modes		M_CFG
+	field	ENLQIATNQASK	0x20
+	field	ENLQICRCT1	0x10
+	field	ENLQICRCT2	0x08
+	field	ENLQIBADLQT	0x04
+	field	ENLQIATNLQ	0x02
+	field	ENLQIATNCMD	0x01
+}
+
+/*
+ * LQI Manager Status 1
+ */
+register LQISTAT1 {
+	address			0x051
+	access_mode	RO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	LQIPHASE_LQ	0x80
+	field	LQIPHASE_NLQ	0x40
+	field	LQIABORT	0x20
+	field	LQICRCI_LQ	0x10
+	field	LQICRCI_NLQ	0x08
+	field	LQIBADLQI	0x04
+	field	LQIOVERI_LQ	0x02
+	field	LQIOVERI_NLQ	0x01
+}
+
+/*
+ * Clear LQI Manager Interrupts1
+ */
+register CLRLQIINT1 {
+	address			0x051
+	access_mode	WO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	CLRLQIPHASE_LQ	0x80
+	field	CLRLQIPHASE_NLQ	0x40
+	field	CLRLIQABORT	0x20
+	field	CLRLQICRCI_LQ	0x10
+	field	CLRLQICRCI_NLQ	0x08
+	field	CLRLQIBADLQI	0x04
+	field	CLRLQIOVERI_LQ	0x02
+	field	CLRLQIOVERI_NLQ	0x01
+}
+
+/*
+ * LQI Manager Interrupt Mode 1
+ */
+register LQIMODE1 {
+	address			0x051
+	access_mode	RW
+	modes		M_CFG
+	field	ENLQIPHASE_LQ	0x80	/* LQIPHASE1 */
+	field	ENLQIPHASE_NLQ	0x40	/* LQIPHASE2 */
+	field	ENLIQABORT	0x20
+	field	ENLQICRCI_LQ	0x10	/* LQICRCI1 */
+	field	ENLQICRCI_NLQ	0x08	/* LQICRCI2 */
+	field	ENLQIBADLQI	0x04
+	field	ENLQIOVERI_LQ	0x02	/* LQIOVERI1 */
+	field	ENLQIOVERI_NLQ	0x01	/* LQIOVERI2 */
+}
+
+/*
+ * LQI Manager Status 2
+ */
+register LQISTAT2 {
+	address			0x052
+	access_mode	RO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	PACKETIZED	0x80
+	field	LQIPHASE_OUTPKT	0x40
+	field	LQIWORKONLQ	0x20
+	field	LQIWAITFIFO	0x10
+	field	LQISTOPPKT	0x08
+	field	LQISTOPLQ	0x04
+	field	LQISTOPCMD	0x02
+	field	LQIGSAVAIL	0x01
+}
+
+/*
+ * SCSI Status 3
+ */
+register SSTAT3 {
+	address			0x053
+	access_mode	RO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	NTRAMPERR	0x02
+	field	OSRAMPERR	0x01
+}
+
+/*
+ * Clear SCSI Status 3
+ */
+register CLRSINT3 {
+	address			0x053
+	access_mode	WO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	CLRNTRAMPERR	0x02
+	field	CLROSRAMPERR	0x01
+}
+
+/*
+ * SCSI Interrupt Mode 3
+ */
+register SIMODE3 {
+	address			0x053
+	access_mode	RW
+	modes		M_CFG
+	field	ENNTRAMPERR	0x02
+	field	ENOSRAMPERR	0x01
+}
+
+/*
+ * LQO Manager Status 0
+ */
+register LQOSTAT0 {
+	address			0x054
+	access_mode	RO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	LQOTARGSCBPERR	0x10
+	field	LQOSTOPT2	0x08
+	field	LQOATNLQ	0x04
+	field	LQOATNPKT	0x02
+	field	LQOTCRC		0x01
+}
+
+/*
+ * Clear LQO Manager interrupt 0
+ */
+register CLRLQOINT0 {
+	address			0x054
+	access_mode	WO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	CLRLQOTARGSCBPERR	0x10
+	field	CLRLQOSTOPT2		0x08
+	field	CLRLQOATNLQ		0x04
+	field	CLRLQOATNPKT		0x02
+	field	CLRLQOTCRC		0x01
+}
+
+/*
+ * LQO Manager Interrupt Mode 0
+ */
+register LQOMODE0 {
+	address			0x054
+	access_mode	RW
+	modes		M_CFG
+	field	ENLQOTARGSCBPERR	0x10
+	field	ENLQOSTOPT2		0x08
+	field	ENLQOATNLQ		0x04
+	field	ENLQOATNPKT		0x02
+	field	ENLQOTCRC		0x01
+}
+
+/*
+ * LQO Manager Status 1
+ */
+register LQOSTAT1 {
+	address			0x055
+	access_mode	RO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	LQOINITSCBPERR	0x10
+	field	LQOSTOPI2	0x08
+	field	LQOBADQAS	0x04
+	field	LQOBUSFREE	0x02
+	field	LQOPHACHGINPKT	0x01
+}
+
+/*
+ * Clear LOQ Interrupt 1
+ */
+register CLRLQOINT1 {
+	address			0x055
+	access_mode	WO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	CLRLQOINITSCBPERR	0x10
+	field	CLRLQOSTOPI2		0x08
+	field	CLRLQOBADQAS		0x04
+	field	CLRLQOBUSFREE		0x02
+	field	CLRLQOPHACHGINPKT	0x01
+}
+
+/*
+ * LQO Manager Interrupt Mode 1
+ */
+register LQOMODE1 {
+	address			0x055
+	access_mode	RW
+	modes		M_CFG
+	field	ENLQOINITSCBPERR	0x10
+	field	ENLQOSTOPI2		0x08
+	field	ENLQOBADQAS		0x04
+	field	ENLQOBUSFREE		0x02
+	field	ENLQOPHACHGINPKT	0x01
+}
+
+/*
+ * LQO Manager Status 2
+ */
+register LQOSTAT2 {
+	address			0x056
+	access_mode	RO
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	LQOPKT		0xE0
+	field	LQOWAITFIFO	0x10
+	field	LQOPHACHGOUTPKT	0x02	/* outside of packet boundaries. */
+	field	LQOSTOP0	0x01	/* Stopped after sending all packets */
+}
+
+/*
+ * Output Synchronizer Space Count
+ */
+register OS_SPACE_CNT {
+	address			0x056
+	access_mode	RO
+	modes		M_CFG
+}
+
+/*
+ * SCSI Interrupt Mode 1
+ * Setting any bit will enable the corresponding function
+ * in SIMODE1 to interrupt via the IRQ pin.
+ */
+register SIMODE1 {
+	address			0x057
+	access_mode	RW
+	modes		M_DFF0, M_DFF1, M_SCSI
+	field	ENSELTIMO	0x80
+	field	ENATNTARG	0x40
+	field	ENSCSIRST	0x20
+	field	ENPHASEMIS	0x10
+	field	ENBUSFREE	0x08
+	field	ENSCSIPERR	0x04
+	field	ENSTRB2FAST	0x02
+	field	ENREQINIT	0x01
+}
+
+/*
+ * Good Status FIFO
+ */
+register GSFIFO {
+	address			0x058
+	access_mode	RO
+	size		2
+	modes		M_DFF0, M_DFF1, M_SCSI
+}
+
+/*
+ * Data FIFO SCSI Transfer Control
+ */
+register DFFSXFRCTL {
+	address			0x05A
+	access_mode	RW
+	modes		M_DFF0, M_DFF1
+	field	DFFBITBUCKET	0x08
+	field	CLRSHCNT	0x04
+	field	CLRCHN		0x02
+	field	RSTCHN		0x01
+}
+
+/*
+ * Next SCSI Control Block
+ */
+register NEXTSCB {
+	address			0x05A
+	access_mode	RW
+	size		2
+	modes		M_SCSI
+}
+
+/* Rev B only. */
+register LQOSCSCTL {
+	address			0x05A
+	access_mode	RW
+	size		1
+	modes		M_CFG
+	field		LQOH2A_VERSION	0x80
+	field		LQONOCHKOVER	0x01
+}
+
+/*
+ * SEQ Interrupts
+ */
+register SEQINTSRC {
+	address			0x05B
+	access_mode	RO
+	modes		M_DFF0, M_DFF1
+	field	CTXTDONE	0x40
+	field	SAVEPTRS	0x20
+	field	CFG4DATA	0x10
+	field	CFG4ISTAT	0x08
+	field	CFG4TSTAT	0x04
+	field	CFG4ICMD	0x02
+	field	CFG4TCMD	0x01
+}
+
+/*
+ * Clear Arp Interrupts
+ */
+register CLRSEQINTSRC {
+	address			0x05B
+	access_mode	WO
+	modes		M_DFF0, M_DFF1
+	field	CLRCTXTDONE	0x40
+	field	CLRSAVEPTRS	0x20
+	field	CLRCFG4DATA	0x10
+	field	CLRCFG4ISTAT	0x08
+	field	CLRCFG4TSTAT	0x04
+	field	CLRCFG4ICMD	0x02
+	field	CLRCFG4TCMD	0x01
+}
+
+/*
+ * SEQ Interrupt Enabled (Shared)
+ */
+register SEQIMODE {
+	address			0x05C
+	access_mode	RW
+	modes		M_DFF0, M_DFF1
+	field	ENCTXTDONE	0x40
+	field	ENSAVEPTRS	0x20
+	field	ENCFG4DATA	0x10
+	field	ENCFG4ISTAT	0x08
+	field	ENCFG4TSTAT	0x04
+	field	ENCFG4ICMD	0x02
+	field	ENCFG4TCMD	0x01
+}
+
+/*
+ * Current SCSI Control Block
+ */
+register CURRSCB {
+	address			0x05C
+	access_mode	RW
+	size		2
+	modes		M_SCSI
+}
+
+/*
+ * Data FIFO Status
+ */
+register MDFFSTAT {
+	address			0x05D
+	access_mode	RO
+	modes		M_DFF0, M_DFF1
+	field	SHCNTNEGATIVE	0x40 /* Rev B or higher */
+	field	SHCNTMINUS1	0x20 /* Rev B or higher */
+	field	LASTSDONE	0x10
+	field	SHVALID		0x08
+	field	DLZERO		0x04 /* FIFO data ends on packet boundary. */
+	field	DATAINFIFO	0x02
+	field	FIFOFREE	0x01
+}
+
+/*
+ * CRC Control
+ */
+register CRCCONTROL {
+	address			0x05d
+	access_mode	RW
+	modes		M_CFG
+	field	CRCVALCHKEN		0x40
+}
+
+/*
+ * SCSI Test Control
+ */
+register SCSITEST {
+	address			0x05E
+	access_mode	RW
+	modes		M_CFG
+	field	CNTRTEST	0x08
+	field	SEL_TXPLL_DEBUG	0x04
+}
+
+/*
+ * Data FIFO Queue Tag
+ */
+register DFFTAG {
+	address			0x05E
+	access_mode	RW
+	size		2
+	modes		M_DFF0, M_DFF1
+}
+
+/*
+ * Last SCSI Control Block
+ */
+register LASTSCB {
+	address			0x05E
+	access_mode	RW
+	size		2
+	modes		M_SCSI
+}
+
+/*
+ * SCSI I/O Cell Power-down Control
+ */
+register IOPDNCTL {
+	address			0x05F
+	access_mode	RW
+	modes		M_CFG
+	field	DISABLE_OE	0x80
+	field	PDN_IDIST	0x04
+	field	PDN_DIFFSENSE	0x01
+}
+
+/*
+ * Shaddow Host Address.
+ */
+register SHADDR {
+	address			0x060
+	access_mode	RO
+	size		8
+	modes		M_DFF0, M_DFF1
+}
+
+/*
+ * Data Group CRC Interval.
+ */
+register DGRPCRCI {
+	address			0x060
+	access_mode	RW
+	size		2
+	modes		M_CFG
+}
+
+/*
+ * Data Transfer Negotiation Address
+ */
+register NEGOADDR {
+	address			0x060
+	access_mode	RW
+	modes		M_SCSI
+}
+
+/*
+ * Data Transfer Negotiation Data - Period Byte
+ */
+register NEGPERIOD {
+	address			0x061
+	access_mode	RW
+	modes		M_SCSI
+}
+
+/*
+ * Packetized CRC Interval
+ */
+register PACKCRCI {
+	address			0x062
+	access_mode	RW
+	size		2
+	modes		M_CFG
+}
+
+/*
+ * Data Transfer Negotiation Data - Offset Byte
+ */
+register NEGOFFSET {
+	address			0x062
+	access_mode	RW
+	modes		M_SCSI
+}
+
+/*
+ * Data Transfer Negotiation Data - PPR Options
+ */
+register NEGPPROPTS {
+	address			0x063
+	access_mode	RW
+	modes		M_SCSI
+	field	PPROPT_PACE	0x08
+	field	PPROPT_QAS	0x04
+	field	PPROPT_DT	0x02
+	field	PPROPT_IUT	0x01
+}
+
+/*
+ * Data Transfer Negotiation Data -  Connection Options
+ */
+register NEGCONOPTS {
+	address			0x064
+	access_mode	RW
+	modes		M_SCSI
+	field	ENSNAPSHOT	0x40
+	field	RTI_WRTDIS	0x20
+	field	RTI_OVRDTRN	0x10
+	field	ENSLOWCRC	0x08
+	field	ENAUTOATNI	0x04
+	field	ENAUTOATNO	0x02
+	field	WIDEXFER	0x01
+}
+
+/*
+ * Negotiation Table Annex Column Index.
+ */
+register ANNEXCOL {
+	address			0x065
+	access_mode	RW
+	modes		M_SCSI
+}
+
+register SCSCHKN {
+	address			0x066
+	access_mode	RW
+	modes		M_CFG
+	field	STSELSKIDDIS	0x40
+	field	CURRFIFODEF	0x20
+	field	WIDERESEN	0x10
+	field	SDONEMSKDIS	0x08
+	field	DFFACTCLR	0x04
+	field	SHVALIDSTDIS	0x02
+	field	LSTSGCLRDIS	0x01
+}
+
+const AHD_ANNEXCOL_PER_DEV0	4
+const AHD_NUM_PER_DEV_ANNEXCOLS	4
+const AHD_ANNEXCOL_PRECOMP_SLEW	4
+const	AHD_PRECOMP_MASK	0x07
+const	AHD_PRECOMP_SHIFT	0
+const	AHD_PRECOMP_CUTBACK_17	0x04
+const	AHD_PRECOMP_CUTBACK_29	0x06
+const	AHD_PRECOMP_CUTBACK_37	0x07
+const	AHD_SLEWRATE_MASK	0x78
+const	AHD_SLEWRATE_SHIFT	3
+/*
+ * Rev A has only a single bit (high bit of field) of slew adjustment.
+ * Rev B has 4 bits.  The current default happens to be the same for both.
+ */
+const	AHD_SLEWRATE_DEF_REVA	0x08
+const	AHD_SLEWRATE_DEF_REVB	0x08
+
+/* Rev A does not have any amplitude setting. */
+const AHD_ANNEXCOL_AMPLITUDE	6
+const	AHD_AMPLITUDE_MASK	0x7
+const	AHD_AMPLITUDE_SHIFT	0
+const	AHD_AMPLITUDE_DEF	0x7
+
+/*
+ * Negotiation Table Annex Data Port.
+ */
+register ANNEXDAT {
+	address			0x066
+	access_mode	RW
+	modes		M_SCSI
+}
+
+/*
+ * Initiator's Own Id.
+ * The SCSI ID to use for Selection Out and seen during a reselection..
+ */
+register IOWNID {
+	address			0x067
+	access_mode	RW
+	modes		M_SCSI
+}
+
+/*
+ * 960MHz Phase-Locked Loop Control 0
+ */
+register PLL960CTL0 {
+	address			0x068
+	access_mode	RW
+	modes		M_CFG
+	field	PLL_VCOSEL	0x80
+	field	PLL_PWDN	0x40
+	field	PLL_NS		0x30
+	field	PLL_ENLUD	0x08
+	field	PLL_ENLPF	0x04
+	field	PLL_DLPF	0x02
+	field	PLL_ENFBM	0x01
+}
+
+/*
+ * Target Own Id
+ */
+register TOWNID {
+	address			0x069
+	access_mode	RW
+	modes		M_SCSI
+}
+
+/*
+ * 960MHz Phase-Locked Loop Control 1
+ */
+register PLL960CTL1 {
+	address			0x069
+	access_mode	RW
+	modes		M_CFG
+	field	PLL_CNTEN	0x80
+	field	PLL_CNTCLR	0x40
+	field	PLL_RST		0x01
+}
+
+/*
+ * Expander Signature
+ */
+register XSIG {
+	address			0x06A
+	access_mode	RW
+	modes		M_SCSI
+}
+
+/*
+ * Shadow Byte Count
+ */
+register SHCNT {
+	address			0x068
+	access_mode	RW
+	size		3
+	modes		M_DFF0, M_DFF1
+}
+
+/*
+ * Selection Out ID
+ */
+register SELOID {
+	address			0x06B
+	access_mode	RW
+	modes		M_SCSI
+}
+
+/*
+ * 960-MHz Phase-Locked Loop Test Count
+ */
+register PLL960CNT0 {
+	address			0x06A
+	access_mode	RO
+	size		2
+	modes		M_CFG
+}
+
+/*
+ * 400-MHz Phase-Locked Loop Control 0
+ */
+register PLL400CTL0 {
+	address			0x06C
+	access_mode	RW
+	modes		M_CFG
+	field	PLL_VCOSEL	0x80
+	field	PLL_PWDN	0x40
+	field	PLL_NS		0x30
+	field	PLL_ENLUD	0x08
+	field	PLL_ENLPF	0x04
+	field	PLL_DLPF	0x02
+	field	PLL_ENFBM	0x01
+}
+
+/*
+ * Arbitration Fairness
+ */
+register FAIRNESS {
+	address			0x06C
+	access_mode	RW
+	size		2
+	modes		M_SCSI
+}
+
+/*
+ * 400-MHz Phase-Locked Loop Control 1
+ */
+register PLL400CTL1 {
+	address			0x06D
+	access_mode	RW
+	modes		M_CFG
+	field	PLL_CNTEN	0x80
+	field	PLL_CNTCLR	0x40
+	field	PLL_RST		0x01
+}
+
+/*
+ * Arbitration Unfairness
+ */
+register UNFAIRNESS {
+	address			0x06E
+	access_mode	RW
+	size		2
+	modes		M_SCSI
+}
+
+/*
+ * 400-MHz Phase-Locked Loop Test Count
+ */
+register PLL400CNT0 {
+	address			0x06E
+	access_mode	RO
+	size		2
+	modes		M_CFG
+}
+
+/*
+ * SCB Page Pointer
+ */
+register SCBPTR {
+	address			0x0A8
+	access_mode	RW
+	size		2
+	modes		M_DFF0, M_DFF1, M_CCHAN, M_SCSI
+}
+
+/*
+ * CMC SCB Array Count
+ * Number of bytes to transfer between CMC SCB memory and SCBRAM.
+ * Transfers must be 8byte aligned and sized.
+ */
+register CCSCBACNT {
+	address			0x0AB
+	access_mode	RW
+	modes		M_CCHAN
+}
+
+/*
+ * SCB Autopointer
+ * SCB-Next Address Snooping logic.  When an SCB is transferred to
+ * the card, the next SCB address to be used by the CMC array can
+ * be autoloaded from that transfer.
+ */
+register SCBAUTOPTR {
+	address			0x0AB
+	access_mode	RW
+	modes		M_CFG
+	field	AUSCBPTR_EN	0x80
+	field	SCBPTR_ADDR	0x38
+	field	SCBPTR_OFF	0x07
+}
+
+/*
+ * CMC SG Ram Address Pointer
+ */
+register CCSGADDR {
+	address			0x0AC
+	access_mode	RW
+	modes		M_DFF0, M_DFF1
+}
+
+/*
+ * CMC SCB RAM Address Pointer
+ */
+register CCSCBADDR {
+	address			0x0AC
+	access_mode	RW
+	modes		M_CCHAN
+}
+
+/*
+ * CMC SCB Ram Back-up Address Pointer
+ * Indicates the true stop location of transfers halted prior
+ * to SCBHCNT going to 0.
+ */
+register CCSCBADR_BK {
+	address			0x0AC
+	access_mode	RO
+	modes		M_CFG
+}
+
+/*
+ * CMC SG Control
+ */
+register CCSGCTL {
+	address			0x0AD
+	access_mode	RW
+	modes		M_DFF0, M_DFF1
+	field	CCSGDONE	0x80
+	field	SG_CACHE_AVAIL	0x10
+	field	CCSGENACK	0x08
+	mask	CCSGEN		0x0C
+	field	SG_FETCH_REQ	0x02
+	field	CCSGRESET	0x01
+}
+
+/*
+ * CMD SCB Control
+ */
+register CCSCBCTL {
+	address			0x0AD
+	access_mode	RW
+	modes		M_CCHAN
+	field	CCSCBDONE	0x80
+	field	ARRDONE		0x40
+	field	CCARREN		0x10
+	field	CCSCBEN		0x08
+	field	CCSCBDIR	0x04
+	field	CCSCBRESET	0x01
+}
+
+/*
+ * CMC Ram BIST
+ */
+register CMC_RAMBIST {
+	address			0x0AD
+	access_mode	RW
+	modes		M_CFG
+	field	SG_ELEMENT_SIZE		0x80
+	field	SCBRAMBIST_FAIL		0x40
+	field	SG_BIST_FAIL		0x20
+	field	SG_BIST_EN		0x10
+	field	CMC_BUFFER_BIST_FAIL	0x02
+	field	CMC_BUFFER_BIST_EN	0x01
+}
+
+/*
+ * CMC SG RAM Data Port
+ */
+register CCSGRAM {
+	address			0x0B0
+	access_mode	RW
+	modes		M_DFF0, M_DFF1
+}
+
+/*
+ * CMC SCB RAM Data Port
+ */
+register CCSCBRAM {
+	address			0x0B0
+	access_mode	RW
+	modes		M_CCHAN
+}
+
+/*
+ * Flex DMA Address.
+ */
+register FLEXADR {
+	address			0x0B0
+	access_mode	RW
+	size		3
+	modes		M_SCSI
+}
+
+/*
+ * Flex DMA Byte Count
+ */
+register FLEXCNT {
+	address			0x0B3
+	access_mode	RW
+	size		2
+	modes		M_SCSI
+}
+
+/*
+ * Flex DMA Status
+ */
+register FLEXDMASTAT {
+	address			0x0B5
+	access_mode	RW
+	modes		M_SCSI
+	field	FLEXDMAERR	0x02
+	field	FLEXDMADONE	0x01
+}
+
+/*
+ * Flex DMA Data Port
+ */
+register FLEXDATA {
+	address			0x0B6
+	access_mode	RW
+	modes		M_SCSI
+}
+
+/*
+ * Board Data
+ */
+register BRDDAT {
+	address			0x0B8
+	access_mode	RW
+	modes		M_SCSI
+}
+
+/*
+ * Board Control
+ */
+register BRDCTL {
+	address			0x0B9
+	access_mode	RW
+	modes		M_SCSI
+	field	FLXARBACK	0x80
+	field	FLXARBREQ	0x40
+	field	BRDADDR		0x38
+	field	BRDEN		0x04
+	field	BRDRW		0x02
+	field	BRDSTB		0x01
+}
+
+/*
+ * Serial EEPROM Address
+ */
+register SEEADR {
+	address			0x0BA
+	access_mode	RW
+	modes		M_SCSI
+}
+
+/*
+ * Serial EEPROM Data
+ */
+register SEEDAT {
+	address			0x0BC
+	access_mode	RW
+	size		2
+	modes		M_SCSI
+}
+
+/*
+ * Serial EEPROM Status
+ */
+register SEESTAT {
+	address			0x0BE
+	access_mode	RO
+	modes		M_SCSI
+	field	INIT_DONE	0x80
+	field	SEEOPCODE	0x70
+	field	LDALTID_L	0x08
+	field	SEEARBACK	0x04
+	field	SEEBUSY		0x02
+	field	SEESTART	0x01
+}
+
+/*
+ * Serial EEPROM Control
+ */
+register SEECTL {
+	address			0x0BE
+	access_mode	RW
+	modes		M_SCSI
+	field	SEEOPCODE	0x70 {
+		SEEOP_ERASE	0x70,
+		SEEOP_READ	0x60,
+		SEEOP_WRITE	0x50,
+	/*
+	 * The following four commands use special
+	 * addresses for differentiation.
+	 */
+		SEEOP_ERAL	0x40
+	}
+	mask	SEEOP_EWEN	0x40
+	mask	SEEOP_WALL	0x40
+	mask	SEEOP_EWDS	0x40
+	field	SEERST		0x02
+	field	SEESTART	0x01
+}
+
+const SEEOP_ERAL_ADDR	0x80
+const SEEOP_EWEN_ADDR	0xC0
+const SEEOP_WRAL_ADDR	0x40
+const SEEOP_EWDS_ADDR	0x00
+
+/*
+ * SCB Counter
+ */
+register SCBCNT {
+	address			0x0BF
+	access_mode	RW
+	modes		M_SCSI
+}
+
+/*
+ * Data FIFO Write Address
+ * Pointer to the next QWD location to be written to the data FIFO.
+ */
+register DFWADDR {
+	address			0x0C0
+	access_mode	RW
+	size		2
+	modes		M_DFF0, M_DFF1
+}
+
+/*
+ * DSP Filter Control
+ */
+register DSPFLTRCTL {
+	address			0x0C0
+	access_mode	RW
+	modes		M_CFG
+	field	FLTRDISABLE	0x20
+	field	EDGESENSE	0x10
+	field	DSPFCNTSEL	0x0F
+}
+
+/*
+ * DSP Data Channel Control
+ */
+register DSPDATACTL {
+	address			0x0C1
+	access_mode	RW
+	modes		M_CFG
+	field	BYPASSENAB	0x80
+	field	DESQDIS		0x10
+	field	RCVROFFSTDIS	0x04
+	field	XMITOFFSTDIS	0x02
+}
+
+/*
+ * Data FIFO Read Address
+ * Pointer to the next QWD location to be read from the data FIFO.
+ */
+register DFRADDR {
+	address			0x0C2
+	access_mode	RW
+	size		2
+	modes		M_DFF0, M_DFF1
+}
+
+/*
+ * DSP REQ Control
+ */
+register DSPREQCTL {
+	address			0x0C2
+	access_mode	RW
+	modes		M_CFG
+	field	MANREQCTL	0xC0
+	field	MANREQDLY	0x3F
+}
+
+/*
+ * DSP ACK Control
+ */
+register DSPACKCTL {
+	address			0x0C3
+	access_mode	RW
+	modes		M_CFG
+	field	MANACKCTL	0xC0
+	field	MANACKDLY	0x3F
+}
+
+/*
+ * Data FIFO Data
+ * Read/Write byte port into the data FIFO.  The read and write
+ * FIFO pointers increment with each read and write respectively
+ * to this port.
+ */
+register DFDAT {
+	address			0x0C4
+	access_mode	RW
+	modes		M_DFF0, M_DFF1
+}
+
+/*
+ * DSP Channel Select
+ */
+register DSPSELECT {
+	address			0x0C4
+	access_mode	RW
+	modes		M_CFG
+	field	AUTOINCEN	0x80
+	field	DSPSEL		0x1F
+}
+
+const NUMDSPS 0x14
+
+/*
+ * Write Bias Control
+ */
+register WRTBIASCTL {
+	address			0x0C5
+	access_mode	WO
+	modes		M_CFG
+	field	AUTOXBCDIS	0x80
+	field	XMITMANVAL	0x3F
+}
+
+/*
+ * Currently the WRTBIASCTL is the same as the default.
+ */
+const WRTBIASCTL_HP_DEFAULT 0x0
+
+/*
+ * Receiver Bias Control
+ */
+register RCVRBIOSCTL {
+	address			0x0C6
+	access_mode	WO
+	modes		M_CFG
+	field	AUTORBCDIS	0x80
+	field	RCVRMANVAL	0x3F
+}
+
+/*
+ * Write Bias Calculator
+ */
+register WRTBIASCALC {
+	address			0x0C7
+	access_mode	RO
+	modes		M_CFG
+}
+
+/*
+ * Data FIFO Pointers
+ * Contains the byte offset from DFWADDR and DWRADDR to the current
+ * FIFO write/read locations.
+ */
+register DFPTRS {
+	address			0x0C8
+	access_mode	RW
+	modes		M_DFF0, M_DFF1
+}
+
+/*
+ * Receiver Bias Calculator
+ */
+register RCVRBIASCALC {
+	address			0x0C8
+	access_mode	RO
+	modes		M_CFG
+}
+
+/*
+ * Data FIFO Backup Read Pointer
+ * Contains the data FIFO address to be restored if the last
+ * data accessed from the data FIFO was not transferred successfully.
+ */
+register DFBKPTR {
+	address			0x0C9
+	access_mode	RW
+	size		2
+	modes		M_DFF0, M_DFF1
+}
+
+/*
+ * Skew Calculator
+ */
+register SKEWCALC {
+	address			0x0C9
+	access_mode	RO
+	modes		M_CFG
+}
+
+/*
+ * Data FIFO Debug Control
+ */
+register DFDBCTL {
+	address				0x0CB
+	access_mode	RW
+	modes		M_DFF0, M_DFF1
+	field	DFF_CIO_WR_RDY		0x20
+	field	DFF_CIO_RD_RDY		0x10
+	field	DFF_DIR_ERR		0x08
+	field	DFF_RAMBIST_FAIL	0x04
+	field	DFF_RAMBIST_DONE	0x02
+	field	DFF_RAMBIST_EN		0x01
+}
+
+/*
+ * Data FIFO Space Count
+ * Number of FIFO locations that are free.
+ */
+register DFSCNT {
+	address			0x0CC
+	access_mode	RO
+	size		2
+	modes		M_DFF0, M_DFF1
+}
+
+/*
+ * Data FIFO Byte Count
+ * Number of filled FIFO locations.
+ */
+register DFBCNT {
+	address			0x0CE
+	access_mode	RO
+	size		2
+	modes		M_DFF0, M_DFF1
+}
+
+/*
+ * Sequencer Program Overlay Address.
+ * Low address must be written prior to high address.
+ */
+register OVLYADDR {
+	address			0x0D4
+	modes		M_SCSI
+	size		2
+	access_mode	RW
+}
+
+/*
+ * Sequencer Control 0
+ * Error detection mode, speed configuration,
+ * single step, breakpoints and program load.
+ */
+register SEQCTL0 {
+	address			0x0D6
+	access_mode RW
+	field	PERRORDIS	0x80
+	field	PAUSEDIS	0x40
+	field	FAILDIS		0x20
+	field	FASTMODE	0x10
+	field	BRKADRINTEN	0x08
+	field	STEP		0x04
+	field	SEQRESET	0x02
+	field	LOADRAM		0x01
+}
+
+/*
+ * Sequencer Control 1
+ * Instruction RAM Diagnostics
+ */
+register SEQCTL1 {
+	address			0x0D7
+	access_mode RW
+	field	OVRLAY_DATA_CHK	0x08
+	field	RAMBIST_DONE	0x04
+	field	RAMBIST_FAIL	0x02
+	field	RAMBIST_EN	0x01
+}
+
+/*
+ * Sequencer Flags
+ * Zero and Carry state of the ALU.
+ */
+register FLAGS {
+	address			0x0D8
+	access_mode RO
+	field	ZERO		0x02
+	field	CARRY		0x01
+}
+
+/*
+ * Sequencer Interrupt Control
+ */ 
+register SEQINTCTL {
+	address			0x0D9
+	access_mode RW
+	field	INTVEC1DSL	0x80
+	field	INT1_CONTEXT	0x20
+	field	SCS_SEQ_INT1M1	0x10
+	field	SCS_SEQ_INT1M0	0x08
+	field	INTMASK2	0x04
+	field	INTMASK1	0x02
+	field	IRET		0x01
+}
+
+/*
+ * Sequencer RAM Data Port
+ * Single byte window into the Sequencer Instruction Ram area starting
+ * at the address specified by OVLYADDR.  To write a full instruction word,
+ * simply write four bytes in succession.  OVLYADDR will increment after the
+ * most significant instrution byte (the byte with the parity bit) is written.
+ */
+register SEQRAM {
+	address			0x0DA
+	access_mode RW
+}
+
+/*
+ * Sequencer Program Counter
+ * Low byte must be written prior to high byte.
+ */
+register PRGMCNT {
+	address			0x0DE
+	access_mode	RW
+	size		2
+}
+
+/*
+ * Accumulator
+ */
+register ACCUM {
+	address			0x0E0
+	access_mode RW
+	accumulator
+}
+
+/*
+ * Source Index Register
+ * Incrementing index for reads of SINDIR and the destination (low byte only)
+ * for any immediate operands passed in jmp, jc, jnc, call instructions.
+ * Example:
+ *		mvi	0xFF	call some_routine;
+ *
+ *  Will set SINDEX[0] to 0xFF and call the routine "some_routine.
+ */
+register SINDEX	{
+	address			0x0E2
+	access_mode	RW
+	size		2
+	sindex
+}
+
+/*
+ * Destination Index Register
+ * Incrementing index for writes to DINDIR.  Can be used as a scratch register.
+ */
+register DINDEX {
+	address			0x0E4
+	access_mode	RW
+	size		2
+}
+
+/*
+ * Break Address
+ * Sequencer instruction breakpoint address address.
+ */
+register BRKADDR0 {
+	address			0x0E6
+	access_mode	RW
+}
+
+register BRKADDR1 {
+	address			0x0E6
+	access_mode	RW
+	field	BRKDIS		0x80	/* Disable Breakpoint */
+}
+
+/*
+ * All Ones
+ * All reads to this register return the value 0xFF.
+ */
+register ALLONES {
+	address			0x0E8
+	access_mode RO
+	allones
+}
+
+/*
+ * All Zeros
+ * All reads to this register return the value 0.
+ */
+register ALLZEROS {
+	address			0x0EA
+	access_mode RO
+	allzeros
+}
+
+/*
+ * No Destination
+ * Writes to this register have no effect.
+ */
+register NONE {
+	address			0x0EA
+	access_mode WO
+	none
+}
+
+/*
+ * Source Index Indirect
+ * Reading this register is equivalent to reading (register_base + SINDEX) and
+ * incrementing SINDEX by 1.
+ */
+register SINDIR	{
+	address			0x0EC
+	access_mode RO
+}
+
+/*
+ * Destination Index Indirect
+ * Writing this register is equivalent to writing to (register_base + DINDEX)
+ * and incrementing DINDEX by 1.
+ */
+register DINDIR	 {
+	address			0x0ED
+	access_mode WO
+}
+
+/*
+ * Function One
+ * 2's complement to bit value conversion.  Write the 2's complement value
+ * (0-7 only) to the top nibble and retrieve the bit indexed by that value
+ * on the next read of this register. 
+ * Example:
+ *	Write	0x60
+ *	Read	0x40
+ */
+register FUNCTION1 {
+	address			0x0F0
+	access_mode RW
+}
+
+/*
+ * Stack
+ * Window into the stack.  Each stack location is 10 bits wide reported
+ * low byte followed by high byte.  There are 8 stack locations.
+ */
+register STACK {
+	address			0x0F2
+	access_mode RW
+}
+
+/*
+ * Interrupt Vector 1 Address
+ * Interrupt branch address for SCS SEQ_INT1 mode 0 and 1 interrupts.
+ */
+register INTVEC1_ADDR {
+	address			0x0F4
+	access_mode	RW
+	size		2
+	modes		M_CFG
+}
+
+/*
+ * Current Address
+ * Address of the SEQRAM instruction currently executing instruction.
+ */
+register CURADDR {
+	address			0x0F4
+	access_mode	RW
+	size		2
+	modes		M_SCSI
+}
+
+/*
+ * Interrupt Vector 2 Address
+ * Interrupt branch address for HST_SEQ_INT2 interrupts.
+ */
+register INTVEC2_ADDR {
+	address			0x0F6
+	access_mode	RW
+	size		2
+	modes		M_CFG
+}
+
+/*
+ * Last Address
+ * Address of the SEQRAM instruction executed prior to the current instruction.
+ */
+register LASTADDR {
+	address			0x0F6
+	access_mode	RW
+	size		2
+	modes		M_SCSI
+}
+
+register AHD_PCI_CONFIG_BASE {
+	address			0x100
+	access_mode	RW
+	size		256
+	modes		M_CFG
+}
+
+/* ---------------------- Scratch RAM Offsets ------------------------- */
+scratch_ram {
+	/* Mode Specific */
+	address			0x0A0
+	size	8
+	modes	0, 1, 2, 3
+	REG0 {
+		size		2
+	}
+	REG1 {
+		size		2
+	}
+	REG_ISR {
+		size		2
+	}
+	SG_STATE {
+		size		1
+		field	SEGS_AVAIL	0x01
+		field	LOADING_NEEDED	0x02
+		field	FETCH_INPROG	0x04
+	}
+	/*
+	 * Track whether the transfer byte count for
+	 * the current data phase is odd.
+	 */
+	DATA_COUNT_ODD {
+		size		1
+	}
+}
+
+scratch_ram {
+	/* Mode Specific */
+	address			0x0F8
+	size	8
+	modes	0, 1, 2, 3
+	LONGJMP_ADDR {
+		size		2
+	}
+	ACCUM_SAVE {
+		size		1
+	}
+}
+
+
+scratch_ram {
+	address			0x100
+	size	128
+	modes	0, 1, 2, 3
+	/*
+	 * Per "other-id" execution queues.  We use an array of
+	 * tail pointers into lists of SCBs sorted by "other-id".
+	 * The execution head pointer threads the head SCBs for
+	 * each list.
+	 */
+	WAITING_SCB_TAILS {
+		size		32
+	}
+	WAITING_TID_HEAD {
+		size		2
+	}
+	WAITING_TID_TAIL {
+		size		2
+	}
+	/*
+	 * SCBID of the next SCB in the new SCB queue.
+	 */
+	NEXT_QUEUED_SCB_ADDR {
+		size		4
+	}
+	/*
+	 * head of list of SCBs that have
+	 * completed but have not been
+	 * put into the qoutfifo.
+	 */
+	COMPLETE_SCB_HEAD {
+		size		2
+	}
+	/*
+	 * The list of completed SCBs in
+	 * the active DMA.
+	 */
+	COMPLETE_SCB_DMAINPROG_HEAD {
+		size		2
+	}
+	/*
+	 * head of list of SCBs that have
+	 * completed but need to be uploaded
+	 * to the host prior to being completed.
+	 */
+	COMPLETE_DMA_SCB_HEAD {
+		size		2
+	}
+	/* Counting semaphore to prevent new select-outs */
+	QFREEZE_COUNT {
+		size		2
+	}
+	/*
+	 * Mode to restore on legacy idle loop exit.
+	 */
+	SAVED_MODE {
+		size		1
+	}
+	/*
+	 * Single byte buffer used to designate the type or message
+	 * to send to a target.
+	 */
+	MSG_OUT {
+		size		1
+	}
+	/* Parameters for DMA Logic */
+	DMAPARAMS {
+		size		1
+		field	PRELOADEN	0x80
+		field	WIDEODD		0x40
+		field	SCSIEN		0x20
+		field	SDMAEN		0x10
+		field	SDMAENACK	0x10
+		field	HDMAEN		0x08
+		field	HDMAENACK	0x08
+		field	DIRECTION	0x04	/* Set indicates PCI->SCSI */
+		field	FIFOFLUSH	0x02
+		field	FIFORESET	0x01
+	}
+	SEQ_FLAGS {
+		size		1
+		field	NOT_IDENTIFIED		0x80
+		field	NO_CDB_SENT		0x40
+		field	TARGET_CMD_IS_TAGGED	0x40
+		field	DPHASE			0x20
+		/* Target flags */
+		field	TARG_CMD_PENDING	0x10
+		field	CMDPHASE_PENDING	0x08
+		field	DPHASE_PENDING		0x04
+		field	SPHASE_PENDING		0x02
+		field	NO_DISCONNECT		0x01
+	}
+	/*
+	 * Temporary storage for the
+	 * target/channel/lun of a
+	 * reconnecting target
+	 */
+	SAVED_SCSIID {
+		size		1
+	}
+	SAVED_LUN {
+		size		1
+	}
+	/*
+	 * The last bus phase as seen by the sequencer. 
+	 */
+	LASTPHASE {
+		size		1
+		field	CDI		0x80
+		field	IOI		0x40
+		field	MSGI		0x20
+		field	P_BUSFREE	0x01
+		enum	PHASE_MASK  CDO|IOO|MSGO {
+			P_DATAOUT	0x0,
+			P_DATAIN	IOO,
+			P_DATAOUT_DT	P_DATAOUT|MSGO,
+			P_DATAIN_DT	P_DATAIN|MSGO,
+			P_COMMAND	CDO,
+			P_MESGOUT	CDO|MSGO,
+			P_STATUS	CDO|IOO,
+			P_MESGIN	CDO|IOO|MSGO
+		}
+	}
+	/*
+	 * Value to "or" into the SCBPTR[1] value to
+	 * indicate that an entry in the QINFIFO is valid.
+	 */
+	QOUTFIFO_ENTRY_VALID_TAG {
+		size		1
+	}
+	/*
+	 * Base address of our shared data with the kernel driver in host
+	 * memory.  This includes the qoutfifo and target mode
+	 * incoming command queue.
+	 */
+	SHARED_DATA_ADDR {
+		size		4
+	}
+	/*
+	 * Pointer to location in host memory for next
+	 * position in the qoutfifo.
+	 */
+	QOUTFIFO_NEXT_ADDR {
+		size		4
+	}
+	/*
+	 * Kernel and sequencer offsets into the queue of
+	 * incoming target mode command descriptors.  The
+	 * queue is full when the KERNEL_TQINPOS == TQINPOS.
+	 */
+	KERNEL_TQINPOS {
+		size		1
+	}
+	TQINPOS {                
+		size		1
+	}
+	ARG_1 {
+		size		1
+		mask	SEND_MSG		0x80
+		mask	SEND_SENSE		0x40
+		mask	SEND_REJ		0x20
+		mask	MSGOUT_PHASEMIS		0x10
+		mask	EXIT_MSG_LOOP		0x08
+		mask	CONT_MSG_LOOP_WRITE	0x04
+		mask	CONT_MSG_LOOP_READ	0x03
+		mask	CONT_MSG_LOOP_TARG	0x02
+		alias	RETURN_1
+	}
+	ARG_2 {
+		size		1
+		alias	RETURN_2
+	}
+
+	/*
+	 * Snapshot of MSG_OUT taken after each message is sent.
+	 */
+	LAST_MSG {
+		size		1
+	}
+
+	/*
+	 * Sequences the kernel driver has okayed for us.  This allows
+	 * the driver to do things like prevent initiator or target
+	 * operations.
+	 */
+	SCSISEQ_TEMPLATE {
+		size		1
+		field	MANUALCTL	0x40
+		field	ENSELI		0x20
+		field	ENRSELI		0x10
+		field	MANUALP		0x0C
+		field	ENAUTOATNP	0x02
+		field	ALTSTIM		0x01
+	}
+
+	/*
+	 * The initiator specified tag for this target mode transaction.
+	 */
+	INITIATOR_TAG {
+		size		1
+	}
+
+	SEQ_FLAGS2 {
+		size		1
+		field	TARGET_MSG_PENDING	  0x02
+		field	SELECTOUT_QFROZEN	  0x04
+	}
+
+	ALLOCFIFO_SCBPTR {
+		size		2
+	}
+
+	/*
+	 * The maximum amount of time to wait, when interrupt coalescing
+	 * is enabled, before issueing a CMDCMPLT interrupt for a completed
+	 * command.
+	 */
+	INT_COALESCING_TIMER {
+		size		2
+	}
+
+	/*
+	 * The maximum number of commands to coalesce into a single interrupt.
+	 * Actually the 2's complement of that value to simplify sequencer
+	 * code.
+	 */
+	INT_COALESCING_MAXCMDS {
+		size		1
+	}
+
+	/*
+	 * The minimum number of commands still outstanding required
+	 * to continue coalescing (2's complement of value).
+	 */
+	INT_COALESCING_MINCMDS {
+		size		1
+	}
+
+	/*
+	 * Number of commands "in-flight".
+	 */
+	CMDS_PENDING {
+		size		2
+	}
+
+	/*
+	 * The count of commands that have been coalesced.
+	 */
+	INT_COALESCING_CMDCOUNT {
+		size		1
+	}
+
+	/*
+	 * Since the HS_MAIBOX is self clearing, copy its contents to
+	 * this position in scratch ram every time it changes.
+	 */
+	LOCAL_HS_MAILBOX {
+		size		1
+	}
+	/*
+	 * Target-mode CDB type to CDB length table used
+	 * in non-packetized operation.
+	 */
+	CMDSIZE_TABLE {
+		size		8
+	}
+}
+
+/************************* Hardware SCB Definition ****************************/
+scb {
+	address			0x180
+	size	64
+	modes	0, 1, 2, 3
+	SCB_RESIDUAL_DATACNT {
+		size	4
+		alias	SCB_CDB_STORE
+		alias	SCB_HOST_CDB_PTR
+	}
+	SCB_RESIDUAL_SGPTR {
+		size	4
+		field	SG_ADDR_MASK		0xf8	/* In the last byte */
+		field	SG_OVERRUN_RESID	0x02	/* In the first byte */
+		field	SG_LIST_NULL		0x01	/* In the first byte */
+	}
+	SCB_SCSI_STATUS {
+		size	1
+		alias	SCB_HOST_CDB_LEN
+	}
+	SCB_TARGET_PHASES {
+		size	1
+	}
+	SCB_TARGET_DATA_DIR {
+		size	1
+	}
+	SCB_TARGET_ITAG {
+		size	1
+	}
+	SCB_SENSE_BUSADDR {
+		/*
+		 * Only valid if CDB length is less than 13 bytes or
+		 * we are using a CDB pointer.  Otherwise contains
+		 * the last 4 bytes of embedded cdb information.
+		 */
+		size	4
+		alias	SCB_NEXT_COMPLETE
+	}
+	SCB_TAG {
+		alias	SCB_FIFO_USE_COUNT
+		size	2
+	}
+	SCB_CONTROL {
+		size	1
+		field	TARGET_SCB	0x80
+		field	DISCENB		0x40
+		field	TAG_ENB		0x20
+		field	MK_MESSAGE	0x10
+		field	STATUS_RCVD	0x08
+		field	DISCONNECTED	0x04
+		field	SCB_TAG_TYPE	0x03
+	}
+	SCB_SCSIID {
+		size	1
+		field	TID	0xF0
+		field	OID	0x0F
+	}
+	SCB_LUN {
+		size	1
+		field	LID	0xff
+	}
+	SCB_TASK_ATTRIBUTE {
+		size	1
+		/*
+		 * Overloaded field for non-packetized 
+		 * ignore wide residue message handling.
+		 */
+		field	SCB_XFERLEN_ODD	0x01
+	}
+	SCB_CDB_LEN {
+		size	1
+		field	SCB_CDB_LEN_PTR	0x80	/* CDB in host memory */
+	}
+	SCB_TASK_MANAGEMENT {
+		size	1
+	}
+	SCB_DATAPTR {
+		size	8
+	}
+	SCB_DATACNT {
+		/*
+		 * The last byte is really the high address bits for
+		 * the data address.
+		 */
+		size	4
+		field	SG_LAST_SEG		0x80	/* In the fourth byte */
+		field	SG_HIGH_ADDR_BITS	0x7F	/* In the fourth byte */
+	}
+	SCB_SGPTR {
+		size	4
+		field	SG_STATUS_VALID	0x04	/* In the first byte */
+		field	SG_FULL_RESID	0x02	/* In the first byte */
+		field	SG_LIST_NULL	0x01	/* In the first byte */
+	}
+	SCB_BUSADDR {
+		size	4
+	}
+	SCB_NEXT {
+		alias	SCB_NEXT_SCB_BUSADDR
+		size	2
+	}
+	SCB_NEXT2 {
+		size	2
+	}
+	SCB_SPARE {
+		size	8
+		alias	SCB_PKT_LUN
+	}
+	SCB_DISCONNECTED_LISTS {
+		size	8
+	}
+}
+
+/*********************************** Constants ********************************/
+const MK_MESSAGE_BIT_OFFSET	4
+const TID_SHIFT		4
+const TARGET_CMD_CMPLT	0xfe
+const INVALID_ADDR	0x80
+#define SCB_LIST_NULL	0xff
+#define QOUTFIFO_ENTRY_VALID_TOGGLE	0x80
+
+const CCSGADDR_MAX	0x80
+const CCSCBADDR_MAX	0x80
+const CCSGRAM_MAXSEGS	16
+
+/* Selection Timeout Timer Constants */
+const STIMESEL_SHIFT	3
+const STIMESEL_MIN	0x18
+const STIMESEL_BUG_ADJ	0x8
+
+/* WDTR Message values */
+const BUS_8_BIT			0x00
+const BUS_16_BIT		0x01
+const BUS_32_BIT		0x02
+
+/* Offset maximums */
+const MAX_OFFSET		0xfe
+const MAX_OFFSET_PACED		0xfe
+const MAX_OFFSET_PACED_BUG	0x7f
+/*
+ * Some 160 devices incorrectly accept 0xfe as a
+ * sync offset, but will overrun this value.  Limit
+ * to 0x7f for speed lower than U320 which will
+ * avoid the persistent sync offset overruns.
+ */
+const MAX_OFFSET_NON_PACED	0x7f
+const HOST_MSG			0xff
+
+/*
+ * The size of our sense buffers.
+ * Sense buffer mapping can be handled in either of two ways.
+ * The first is to allocate a dmamap for each transaction.
+ * Depending on the architecture, dmamaps can be costly. The
+ * alternative is to statically map the buffers in much the same
+ * way we handle our scatter gather lists.  The driver implements
+ * the later.
+ */
+const AHD_SENSE_BUFSIZE		256
+
+/* Target mode command processing constants */
+const CMD_GROUP_CODE_SHIFT	0x05
+
+const STATUS_BUSY		0x08
+const STATUS_QUEUE_FULL		0x28
+const STATUS_PKT_SENSE		0xFF
+const TARGET_DATA_IN		1
+
+const SCB_TRANSFER_SIZE_FULL_LUN	56
+const SCB_TRANSFER_SIZE_1BYTE_LUN	48
+/* PKT_OVERRUN_BUFSIZE must be a multiple of 256 less than 64K */
+const PKT_OVERRUN_BUFSIZE	512
+
+/*
+ * Timer parameters.
+ */
+const AHD_TIMER_US_PER_TICK	25
+const AHD_TIMER_MAX_TICKS	0xFFFF
+const AHD_TIMER_MAX_US		(AHD_TIMER_MAX_TICKS * AHD_TIMER_US_PER_TICK)
+
+/*
+ * Downloaded (kernel inserted) constants
+ */
+const SG_PREFETCH_CNT download
+const SG_PREFETCH_CNT_LIMIT download
+const SG_PREFETCH_ALIGN_MASK download
+const SG_PREFETCH_ADDR_MASK download
+const SG_SIZEOF download
+const PKT_OVERRUN_BUFOFFSET download
+const SCB_TRANSFER_SIZE	download
+
+/*
+ * BIOS SCB offsets
+ */
+const NVRAM_SCB_OFFSET	0x2C
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic79xx.seq linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx.seq
--- linux-2.4.21/drivers/scsi/aic7xxx/aic79xx.seq	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx.seq	2003-06-26 21:43:10.000000000 +0000
@@ -0,0 +1,2032 @@
+/*
+ * Adaptec U320 device driver firmware for Linux and FreeBSD.
+ *
+ * Copyright (c) 1994-2001 Justin T. Gibbs.
+ * Copyright (c) 2000-2002 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.
+ *
+ * $FreeBSD$
+ */
+
+VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#94 $"
+PATCH_ARG_LIST = "struct ahd_softc *ahd"
+PREFIX = "ahd_"
+
+#include "aic79xx.reg"
+#include "scsi_message.h"
+
+restart:
+if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) {
+	test	SEQINTCODE, 0xFF jz idle_loop;
+	SET_SEQINTCODE(NO_SEQINT)
+}
+
+idle_loop:
+
+	if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) {
+		/*
+		 * Convert ERROR status into a sequencer
+		 * interrupt to handle the case of an
+		 * interrupt collision on the hardware
+		 * setting of HWERR.
+		 */
+		test	ERROR, 0xFF jz no_error_set;
+		SET_SEQINTCODE(SAW_HWERR)
+no_error_set:
+	}
+	SET_MODE(M_SCSI, M_SCSI)
+	test	SCSISEQ0, ENSELO|ENARBO jnz idle_loop_checkbus;
+	test	SEQ_FLAGS2, SELECTOUT_QFROZEN jnz idle_loop_checkbus;
+	cmp	WAITING_TID_HEAD[1], SCB_LIST_NULL je idle_loop_checkbus;
+	/*
+	 * ENSELO is cleared by a SELDO, so we must test for SELDO
+	 * one last time.
+	 */
+BEGIN_CRITICAL;
+	test	SSTAT0, SELDO jnz select_out;
+END_CRITICAL;
+	call	start_selection;
+idle_loop_checkbus:
+BEGIN_CRITICAL;
+	test	SSTAT0, SELDO jnz select_out;
+END_CRITICAL;
+	test	SSTAT0, SELDI jnz select_in;
+	test	SCSIPHASE, ~DATA_PHASE_MASK jz idle_loop_check_nonpackreq;
+	test	SCSISIGO, ATNO jz idle_loop_check_nonpackreq;
+	call	unexpected_nonpkt_phase_find_ctxt;
+idle_loop_check_nonpackreq:
+	test	SSTAT2, NONPACKREQ jz . + 2;
+	call	unexpected_nonpkt_phase_find_ctxt;
+	if ((ahd->bugs & AHD_FAINT_LED_BUG) != 0) {
+		and	A, FIFO0FREE|FIFO1FREE, DFFSTAT;
+		cmp	A, FIFO0FREE|FIFO1FREE jne . + 3;
+		and	SBLKCTL, ~DIAGLEDEN|DIAGLEDON;
+		jmp	. + 2;
+		or	SBLKCTL, DIAGLEDEN|DIAGLEDON;
+	}
+	call	idle_loop_gsfifo_in_scsi_mode;
+	call	idle_loop_service_fifos;
+	call	idle_loop_cchan;
+	jmp	idle_loop;
+
+BEGIN_CRITICAL;
+idle_loop_gsfifo:
+	SET_MODE(M_SCSI, M_SCSI)
+idle_loop_gsfifo_in_scsi_mode:
+	test	LQISTAT2, LQIGSAVAIL jz return;
+	/*
+	 * We have received good status for this transaction.  There may
+	 * still be data in our FIFOs draining to the host.  Complete
+	 * the SCB only if all data has transferred to the host.
+	 */
+good_status_IU_done:
+	bmov	SCBPTR, GSFIFO, 2;
+	clr	SCB_SCSI_STATUS;
+	/*
+	 * If a command completed before an attempted task management
+	 * function completed, notify the host after disabling any
+	 * pending select-outs.
+	 */
+	test	SCB_TASK_MANAGEMENT, 0xFF jz gsfifo_complete_normally;
+	test	SSTAT0, SELDO|SELINGO jnz . + 2;
+	and	SCSISEQ0, ~ENSELO;
+	SET_SEQINTCODE(TASKMGMT_CMD_CMPLT_OKAY)
+gsfifo_complete_normally:
+	or	SCB_CONTROL, STATUS_RCVD;
+
+	/*
+	 * Since this status did not consume a FIFO, we have to
+	 * be a bit more dilligent in how we check for FIFOs pertaining
+	 * to this transaction.  There are two states that a FIFO still
+	 * transferring data may be in.
+	 *
+	 * 1) Configured and draining to the host, with a FIFO handler.
+	 * 2) Pending cfg4data, fifo not empty.
+	 *
+	 * Case 1 can be detected by noticing a non-zero FIFO active
+	 * count in the SCB.  In this case, we allow the routine servicing
+	 * the FIFO to complete the SCB.
+	 * 
+	 * Case 2 implies either a pending or yet to occur save data
+	 * pointers for this same context in the other FIFO.  So, if
+	 * we detect case 1, we will properly defer the post of the SCB
+	 * and achieve the desired result.  The pending cfg4data will
+	 * notice that status has been received and complete the SCB.
+	 */
+	test	SCB_FIFO_USE_COUNT, 0xFF jnz idle_loop_gsfifo_in_scsi_mode;
+	call	complete;
+END_CRITICAL;
+	jmp	idle_loop_gsfifo_in_scsi_mode;
+
+idle_loop_service_fifos:
+	SET_MODE(M_DFF0, M_DFF0)
+	test	LONGJMP_ADDR[1], INVALID_ADDR jnz idle_loop_next_fifo;
+	call	longjmp;
+idle_loop_next_fifo:
+	SET_MODE(M_DFF1, M_DFF1)
+	test	LONGJMP_ADDR[1], INVALID_ADDR jz longjmp;
+return:
+	ret;
+
+idle_loop_cchan:
+	SET_MODE(M_CCHAN, M_CCHAN)
+	test	QOFF_CTLSTA, HS_MAILBOX_ACT jz	hs_mailbox_empty;
+	mov	LOCAL_HS_MAILBOX, HS_MAILBOX;
+	or	QOFF_CTLSTA, HS_MAILBOX_ACT;
+hs_mailbox_empty:
+BEGIN_CRITICAL;
+	test	CCSCBCTL, CCARREN|CCSCBEN jz scbdma_idle;
+	test	CCSCBCTL, CCSCBDIR jnz fetch_new_scb_inprog;
+	test	CCSCBCTL, CCSCBDONE jz return;
+END_CRITICAL;
+	/* FALLTHROUGH */
+scbdma_tohost_done:
+	test	CCSCBCTL, CCARREN jz fill_qoutfifo_dmadone;
+	/*
+	 * An SCB has been succesfully uploaded to the host.
+	 * If the SCB was uploaded for some reason other than
+	 * bad SCSI status (currently only for underruns), we
+	 * queue the SCB for normal completion.  Otherwise, we
+	 * wait until any select-out activity has halted, and
+	 * then notify the host so that the transaction can be
+	 * dealt with.
+	 */
+	test	SCB_SCSI_STATUS, 0xff jnz scbdma_notify_host;
+	and	CCSCBCTL, ~(CCARREN|CCSCBEN);
+	bmov	COMPLETE_DMA_SCB_HEAD, SCB_NEXT_COMPLETE, 2;
+	bmov	SCB_NEXT_COMPLETE, COMPLETE_SCB_HEAD, 2;
+	bmov	COMPLETE_SCB_HEAD, SCBPTR, 2 ret;
+scbdma_notify_host:
+	SET_MODE(M_SCSI, M_SCSI)
+	test	SCSISEQ0, ENSELO jnz return;
+	test	SSTAT0, (SELDO|SELINGO) jnz return;
+	SET_MODE(M_CCHAN, M_CCHAN)
+	/*
+	 * Remove SCB and notify host.
+	 */
+	and	CCSCBCTL, ~(CCARREN|CCSCBEN);
+	bmov	COMPLETE_DMA_SCB_HEAD, SCB_NEXT_COMPLETE, 2;
+	SET_SEQINTCODE(BAD_SCB_STATUS)
+	ret;
+fill_qoutfifo_dmadone:
+	and	CCSCBCTL, ~(CCARREN|CCSCBEN);
+	call	qoutfifo_updated;
+	mvi	COMPLETE_SCB_DMAINPROG_HEAD[1], SCB_LIST_NULL;
+	bmov	QOUTFIFO_NEXT_ADDR, SCBHADDR, 4;
+	test	QOFF_CTLSTA, SDSCB_ROLLOVR jz return;
+	bmov	QOUTFIFO_NEXT_ADDR, SHARED_DATA_ADDR, 4;
+	xor	QOUTFIFO_ENTRY_VALID_TAG, QOUTFIFO_ENTRY_VALID_TOGGLE ret;
+
+qoutfifo_updated:
+	/*
+	 * If there are more commands waiting to be dma'ed
+	 * to the host, always coalesce.  Otherwise honor the
+	 * host's wishes.
+	 */
+	cmp	COMPLETE_DMA_SCB_HEAD[1], SCB_LIST_NULL jne coalesce_by_count;
+	cmp	COMPLETE_SCB_HEAD[1], SCB_LIST_NULL jne coalesce_by_count;
+	test	LOCAL_HS_MAILBOX, ENINT_COALESCE jz issue_cmdcmplt;
+
+	/*
+	 * If we have relatively few commands outstanding, don't
+	 * bother waiting for another command to complete.
+	 */
+	test	CMDS_PENDING[1], 0xFF jnz coalesce_by_count;
+	/* Add -1 so that jnc means <= not just < */
+	add	A, -1, INT_COALESCING_MINCMDS;
+	add	NONE, A, CMDS_PENDING;
+	jnc	issue_cmdcmplt;
+	
+	/*
+	 * If coalescing, only coalesce up to the limit
+	 * provided by the host driver.
+	 */
+coalesce_by_count:
+	mov	A, INT_COALESCING_MAXCMDS;
+	add	NONE, A, INT_COALESCING_CMDCOUNT;
+	jc	issue_cmdcmplt;
+	/*
+	 * If the timer is not currently active,
+	 * fire it up.
+	 */
+	test	INTCTL, SWTMINTMASK jz return;
+	bmov	SWTIMER, INT_COALESCING_TIMER, 2;
+	mvi	CLRSEQINTSTAT, CLRSEQ_SWTMRTO;
+	or	INTCTL, SWTMINTEN|SWTIMER_START;
+	and	INTCTL, ~SWTMINTMASK ret;
+
+issue_cmdcmplt:
+	mvi	INTSTAT, CMDCMPLT;
+	clr	INT_COALESCING_CMDCOUNT;
+	or	INTCTL, SWTMINTMASK ret;
+
+BEGIN_CRITICAL;
+fetch_new_scb_inprog:
+	test	CCSCBCTL, ARRDONE jz return;
+fetch_new_scb_done:
+	and	CCSCBCTL, ~(CCARREN|CCSCBEN);
+	bmov	REG0, SCBPTR, 2;
+	clr	A;
+	add	CMDS_PENDING, 1;
+	adc	CMDS_PENDING[1], A;
+	if ((ahd->bugs & AHD_PKT_LUN_BUG) != 0) {
+		/*
+		 * "Short Luns" are not placed into outgoing LQ
+		 * packets in the correct byte order.  Use a full
+		 * sized lun field instead and fill it with the
+		 * one byte of lun information we support.
+		 */
+		mov	SCB_PKT_LUN[6], SCB_LUN;
+	}
+	/*
+	 * The FIFO use count field is shared with the
+	 * tag set by the host so that our SCB dma engine
+	 * knows the correct location to store the SCB.
+	 * Set it to zero before processing the SCB.
+	 */
+	mov	SCB_FIFO_USE_COUNT, ALLZEROS;
+	/* Update the next SCB address to download. */
+	bmov	NEXT_QUEUED_SCB_ADDR, SCB_NEXT_SCB_BUSADDR, 4;
+	mvi	SCB_NEXT[1], SCB_LIST_NULL;
+	mvi	SCB_NEXT2[1], SCB_LIST_NULL;
+	/* Increment our position in the QINFIFO. */
+	mov	NONE, SNSCB_QOFF;
+	/*
+	 * SCBs that want to send messages are always
+	 * queued independently.  This ensures that they
+	 * are at the head of the SCB list to select out
+	 * to a target and we will see the MK_MESSAGE flag.
+	 */
+	test	SCB_CONTROL, MK_MESSAGE jnz first_new_target_scb;
+	shr	SINDEX, 3, SCB_SCSIID;
+	and	SINDEX, ~0x1;
+	mvi	SINDEX[1], (WAITING_SCB_TAILS >> 8);
+	bmov	DINDEX, SINDEX, 2;
+	bmov	SCBPTR, SINDIR, 2;
+	bmov	DINDIR, REG0, 2;
+	cmp	SCBPTR[1], SCB_LIST_NULL je first_new_target_scb;
+	bmov	SCB_NEXT, REG0, 2 ret;
+first_new_target_scb:
+	cmp	WAITING_TID_HEAD[1], SCB_LIST_NULL je first_new_scb;
+	bmov	SCBPTR, WAITING_TID_TAIL, 2;
+	bmov	SCB_NEXT2, REG0, 2;
+	bmov	WAITING_TID_TAIL, REG0, 2 ret;
+first_new_scb:
+	bmov	WAITING_TID_HEAD, REG0, 2;
+	bmov	WAITING_TID_TAIL, REG0, 2 ret;
+END_CRITICAL;
+
+scbdma_idle:
+	/*
+	 * Give precedence to downloading new SCBs to execute
+	 * unless select-outs are currently frozen.
+	 */
+	test	SEQ_FLAGS2, SELECTOUT_QFROZEN jnz . + 2;
+BEGIN_CRITICAL;
+	test	QOFF_CTLSTA, NEW_SCB_AVAIL jnz fetch_new_scb;
+	cmp	COMPLETE_DMA_SCB_HEAD[1], SCB_LIST_NULL jne dma_complete_scb;
+	cmp	COMPLETE_SCB_HEAD[1], SCB_LIST_NULL je return;
+	/* FALLTHROUGH */
+fill_qoutfifo:
+	/*
+	 * Keep track of the SCBs we are dmaing just
+	 * in case the DMA fails or is aborted.
+	 */
+	mov	A, QOUTFIFO_ENTRY_VALID_TAG;
+	bmov	COMPLETE_SCB_DMAINPROG_HEAD, COMPLETE_SCB_HEAD, 2;
+	mvi	CCSCBCTL, CCSCBRESET;
+	bmov	SCBHADDR, QOUTFIFO_NEXT_ADDR, 4;
+	bmov	SCBPTR, COMPLETE_SCB_HEAD, 2;
+fill_qoutfifo_loop:
+	mov	CCSCBRAM, SCBPTR;
+	or	CCSCBRAM, A, SCBPTR[1];
+	mov	NONE, SDSCB_QOFF;
+	inc	INT_COALESCING_CMDCOUNT;
+	add	CMDS_PENDING, -1;
+	adc	CMDS_PENDING[1], -1;
+	cmp	SCB_NEXT_COMPLETE[1], SCB_LIST_NULL je fill_qoutfifo_done;
+	cmp	CCSCBADDR, CCSCBADDR_MAX je fill_qoutfifo_done;
+	test	QOFF_CTLSTA, SDSCB_ROLLOVR jnz fill_qoutfifo_done;
+	bmov	SCBPTR, SCB_NEXT_COMPLETE, 2;
+	jmp	fill_qoutfifo_loop;
+fill_qoutfifo_done:
+	mov	SCBHCNT, CCSCBADDR;
+	mvi	CCSCBCTL, CCSCBEN|CCSCBRESET;
+	bmov	COMPLETE_SCB_HEAD, SCB_NEXT_COMPLETE, 2;
+	mvi	SCB_NEXT_COMPLETE[1], SCB_LIST_NULL ret;
+
+fetch_new_scb:
+	bmov	SCBHADDR, NEXT_QUEUED_SCB_ADDR, 4;
+	mvi	CCARREN|CCSCBEN|CCSCBDIR|CCSCBRESET jmp dma_scb;
+dma_complete_scb:
+	bmov	SCBPTR, COMPLETE_DMA_SCB_HEAD, 2;
+	bmov	SCBHADDR, SCB_BUSADDR, 4;
+	mvi	CCARREN|CCSCBEN|CCSCBRESET jmp dma_scb;
+END_CRITICAL;
+
+/*
+ * Either post or fetch an SCB from host memory.  The caller
+ * is responsible for polling for transfer completion.
+ *
+ * Prerequisits: Mode == M_CCHAN
+ *		 SINDEX contains CCSCBCTL flags
+ *		 SCBHADDR set to Host SCB address
+ *		 SCBPTR set to SCB src location on "push" operations
+ */
+SET_SRC_MODE	M_CCHAN;
+SET_DST_MODE	M_CCHAN;
+dma_scb:
+	mvi	SCBHCNT, SCB_TRANSFER_SIZE;
+	mov	CCSCBCTL, SINDEX ret;
+
+BEGIN_CRITICAL;
+setjmp:
+	bmov	LONGJMP_ADDR, STACK, 2 ret;
+setjmp_inline:
+	bmov	LONGJMP_ADDR, STACK, 2;
+longjmp:
+	bmov	STACK, LONGJMP_ADDR, 2 ret;
+END_CRITICAL;
+
+/*************************** Chip Bug Work Arounds ****************************/
+/*
+ * Must disable interrupts when setting the mode pointer
+ * register as an interrupt occurring mid update will
+ * fail to store the new mode value for restoration on
+ * an iret.
+ */
+if ((ahd->bugs & AHD_SET_MODE_BUG) != 0) {
+set_mode_work_around:
+	mvi	SEQINTCTL, INTVEC1DSL;
+	mov	MODE_PTR, SINDEX;
+	clr	SEQINTCTL ret;
+
+toggle_dff_mode_work_around:
+	mvi	SEQINTCTL, INTVEC1DSL;
+	xor	MODE_PTR, MK_MODE(M_DFF1, M_DFF1);
+	clr	SEQINTCTL ret;
+}
+
+
+if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) {
+set_seqint_work_around:
+	mov	SEQINTCODE, SINDEX;
+	mvi	SEQINTCODE, NO_SEQINT ret;
+}
+
+/************************ Packetized LongJmp Routines *************************/
+SET_SRC_MODE	M_SCSI;
+SET_DST_MODE	M_SCSI;
+start_selection:
+BEGIN_CRITICAL;
+	if ((ahd->bugs & AHD_SENT_SCB_UPDATE_BUG) != 0) {
+		/*
+		 * Razor #494
+		 * Rev A hardware fails to update LAST/CURR/NEXTSCB
+		 * correctly after a packetized selection in several
+		 * situations:
+		 *
+		 * 1) If only one command existed in the queue, the
+		 *    LAST/CURR/NEXTSCB are unchanged.
+		 *
+		 * 2) In a non QAS, protocol allowed phase change,
+		 *    the queue is shifted 1 too far.  LASTSCB is
+		 *    the last SCB that was correctly processed.
+		 * 
+		 * 3) In the QAS case, if the full list of commands
+		 *    was successfully sent, NEXTSCB is NULL and neither
+		 *    CURRSCB nor LASTSCB can be trusted.  We must
+		 *    manually walk the list counting MAXCMDCNT elements
+		 *    to find the last SCB that was sent correctly.
+		 *
+		 * To simplify the workaround for this bug in SELDO
+		 * handling, we initialize LASTSCB prior to enabling
+		 * selection so we can rely on it even for case #1 above.
+		 */
+		bmov	LASTSCB, WAITING_TID_HEAD, 2;
+	}
+	bmov	CURRSCB, WAITING_TID_HEAD, 2;
+	bmov	SCBPTR, WAITING_TID_HEAD, 2;
+	shr	SELOID, 4, SCB_SCSIID;
+	/*
+	 * If we want to send a message to the device, ensure
+	 * we are selecting with atn irregardless of our packetized
+	 * agreement.  Since SPI4 only allows target reset or PPR
+	 * messages if this is a packetized connection, the change
+	 * to our negotiation table entry for this selection will
+	 * be cleared when the message is acted on.
+	 */
+	test	SCB_CONTROL, MK_MESSAGE jz . + 3;
+	mov	NEGOADDR, SELOID;
+	or	NEGCONOPTS, ENAUTOATNO;
+	or	SCSISEQ0, ENSELO ret;
+END_CRITICAL;
+
+/*
+ * Allocate a FIFO for a non-packetized transaction.
+ * In RevA hardware, both FIFOs must be free before we
+ * can allocate a FIFO for a non-packetized transaction.
+ */
+allocate_fifo_loop:
+	/*
+	 * Do whatever work is required to free a FIFO.
+	 */
+	call	idle_loop_service_fifos;
+	SET_MODE(M_SCSI, M_SCSI)
+allocate_fifo:
+	if ((ahd->bugs & AHD_NONPACKFIFO_BUG) != 0) {
+		and	A, FIFO0FREE|FIFO1FREE, DFFSTAT;
+		cmp	A, FIFO0FREE|FIFO1FREE jne allocate_fifo_loop;
+	} else {
+		test	DFFSTAT, FIFO1FREE jnz allocate_fifo1;
+		test	DFFSTAT, FIFO0FREE jz allocate_fifo_loop;
+		mvi	DFFSTAT, B_CURRFIFO_0;
+		SET_MODE(M_DFF0, M_DFF0)
+		bmov	SCBPTR, ALLOCFIFO_SCBPTR, 2 ret;
+	}
+SET_SRC_MODE	M_SCSI;
+SET_DST_MODE	M_SCSI;
+allocate_fifo1:
+	mvi	DFFSTAT, CURRFIFO_1;
+	SET_MODE(M_DFF1, M_DFF1)
+	bmov	SCBPTR, ALLOCFIFO_SCBPTR, 2 ret;
+
+/*
+ * We have been reselected as an initiator
+ * or selected as a target.
+ */
+SET_SRC_MODE	M_SCSI;
+SET_DST_MODE	M_SCSI;
+select_in:
+	if ((ahd->bugs & AHD_BUSFREEREV_BUG) != 0) {
+		/*
+		 * This exposes a window whereby a
+		 * busfree just after a selection will
+		 * be missed, but there is no other safe
+		 * way to enable busfree detection if
+		 * the busfreerev function is broken.
+		 */
+		mvi	CLRSINT1,CLRBUSFREE;
+		or	SIMODE1, ENBUSFREE;
+	}
+	or	SXFRCTL0, SPIOEN;
+	and	SAVED_SCSIID, SELID_MASK, SELID;
+	and	A, OID, IOWNID;
+	or	SAVED_SCSIID, A;
+	mvi	CLRSINT0, CLRSELDI;
+	jmp	ITloop;
+
+/*
+ * We have successfully selected out.
+ *
+ * Clear SELDO.
+ * Dequeue all SCBs sent from the waiting queue
+ * Requeue all SCBs *not* sent to the tail of the waiting queue
+ * Take Razor #494 into account for above.
+ *
+ * In Packetized Mode:
+ *	Return to the idle loop.  Our interrupt handler will take
+ *	care of any incoming L_Qs.
+ *
+ * In Non-Packetize Mode:
+ *	Continue to our normal state machine.
+ */
+SET_SRC_MODE	M_SCSI;
+SET_DST_MODE	M_SCSI;
+select_out:
+BEGIN_CRITICAL;
+	/* Clear out all SCBs that have been successfully sent. */
+	if ((ahd->bugs & AHD_SENT_SCB_UPDATE_BUG) != 0) {
+		/*
+		 * For packetized, the LQO manager clears ENSELO on
+		 * the assertion of SELDO.  If we are non-packetized,
+		 * LASTSCB and CURRSCB are accurate.
+		 */
+		test	SCSISEQ0, ENSELO jnz use_lastscb;
+
+		/*
+		 * The update is correct for LQOSTAT1 errors.  All
+		 * but LQOBUSFREE are handled by kernel interrupts.
+		 * If we see LQOBUSFREE, return to the idle loop.
+		 * Once we are out of the select_out critical section,
+		 * the kernel will cleanup the LQOBUSFREE and we will
+		 * eventually restart the selection if appropriate.
+		 */
+		test	LQOSTAT1, LQOBUSFREE jnz idle_loop;
+
+		/*
+		 * On a phase change oustside of packet boundaries,
+		 * LASTSCB points to the currently active SCB context
+		 * on the bus.
+		 */
+		test	LQOSTAT2, LQOPHACHGOUTPKT jnz use_lastscb;
+
+		/*
+		 * If the hardware has traversed the whole list, NEXTSCB
+		 * will be NULL, CURRSCB and LASTSCB cannot be trusted,
+		 * but MAXCMDCNT is accurate.  If we stop part way through
+		 * the list or only had one command to issue, NEXTSCB[1] is
+		 * not NULL and LASTSCB is the last command to go out.
+		 */
+		cmp	NEXTSCB[1], SCB_LIST_NULL jne use_lastscb;
+
+		/*
+		 * Brute force walk.
+		 */
+		bmov	SCBPTR, WAITING_TID_HEAD, 2;
+		mvi	SEQINTCTL, INTVEC1DSL;
+		mvi	MODE_PTR, MK_MODE(M_CFG, M_CFG);
+		mov	A, MAXCMDCNT;
+		mvi	MODE_PTR, MK_MODE(M_SCSI, M_SCSI);
+		clr	SEQINTCTL;
+find_lastscb_loop:
+		dec	A;
+		test	A, 0xFF jz found_last_sent_scb;
+		bmov	SCBPTR, SCB_NEXT, 2;
+		jmp	find_lastscb_loop;
+use_lastscb:
+		bmov	SCBPTR, LASTSCB, 2;
+found_last_sent_scb:
+		bmov	CURRSCB, SCBPTR, 2;
+curscb_ww_done:
+	} else {
+		/*
+		 * Untested - Verify with Rev B.
+		 */
+		bmov	SCBPTR, CURRSCB, 2;
+	}
+
+	/*
+	 * Requeue any SCBs not sent, to the tail of the waiting Q.
+	 */
+	cmp	SCB_NEXT[1], SCB_LIST_NULL je select_out_list_done;
+
+	/*
+	 * We know that neither the per-TID list nor the list of
+	 * TIDs is empty.  Use this knowledge to our advantage.
+	 */
+	bmov	REG0, SCB_NEXT, 2;
+	bmov	SCBPTR, WAITING_TID_TAIL, 2;
+	bmov	SCB_NEXT2, REG0, 2;
+	bmov	WAITING_TID_TAIL, REG0, 2;
+	jmp	select_out_inc_tid_q;
+
+select_out_list_done:
+	/*
+	 * The whole list made it.  Just clear our TID's tail pointer
+	 * unless we were queued independently due to our need to
+	 * send a message.
+	 */
+	test	SCB_CONTROL, MK_MESSAGE jnz select_out_inc_tid_q;
+	shr	DINDEX, 3, SCB_SCSIID;
+	or	DINDEX, 1;	/* Want only the second byte */
+	mvi	DINDEX[1], ((WAITING_SCB_TAILS) >> 8);
+	mvi	DINDIR, SCB_LIST_NULL;
+select_out_inc_tid_q:
+	bmov	SCBPTR, WAITING_TID_HEAD, 2;
+	bmov	WAITING_TID_HEAD, SCB_NEXT2, 2;
+	cmp	WAITING_TID_HEAD[1], SCB_LIST_NULL jne . + 2;
+	mvi	WAITING_TID_TAIL[1], SCB_LIST_NULL;
+	bmov	SCBPTR, CURRSCB, 2;
+	mvi	CLRSINT0, CLRSELDO;
+	test	LQOSTAT2, LQOPHACHGOUTPKT jnz unexpected_nonpkt_phase;
+	test	LQOSTAT1, LQOPHACHGINPKT jnz unexpected_nonpkt_phase;
+
+	/*
+	 * If this is a packetized connection, return to our
+	 * idle_loop and let our interrupt handler deal with
+	 * any connection setup/teardown issues.  The only
+	 * exceptions are the case of MK_MESSAGE and task management
+	 * SCBs.
+	 */
+	if ((ahd->bugs & AHD_LQO_ATNO_BUG) != 0) {
+		/*
+		 * In the A, the LQO manager transitions to LQOSTOP0 even if
+		 * we have selected out with ATN asserted and the target
+		 * REQs in a non-packet phase.
+		 */
+		test 	SCB_CONTROL, MK_MESSAGE jz select_out_no_message;
+		test	SCSISIGO, ATNO jnz select_out_non_packetized;
+select_out_no_message:
+	}
+	test	LQOSTAT2, LQOSTOP0 jz select_out_non_packetized;
+	test	SCB_TASK_MANAGEMENT, 0xFF jz idle_loop;
+	SET_SEQINTCODE(TASKMGMT_FUNC_COMPLETE)
+	jmp	idle_loop;
+
+select_out_non_packetized:
+	/* Non packetized request. */
+	and     SCSISEQ0, ~ENSELO;
+	if ((ahd->bugs & AHD_BUSFREEREV_BUG) != 0) {
+		/*
+		 * This exposes a window whereby a
+		 * busfree just after a selection will
+		 * be missed, but there is no other safe
+		 * way to enable busfree detection if
+		 * the busfreerev function is broken.
+		 */
+		mvi	CLRSINT1,CLRBUSFREE;
+		or	SIMODE1, ENBUSFREE;
+	}
+	mov	SAVED_SCSIID, SCB_SCSIID;
+	mov	SAVED_LUN, SCB_LUN;
+	mvi	SEQ_FLAGS, NO_CDB_SENT;
+END_CRITICAL;
+	or	SXFRCTL0, SPIOEN;
+
+	/*
+	 * As soon as we get a successful selection, the target
+	 * should go into the message out phase since we have ATN
+	 * asserted.
+	 */
+	mvi	MSG_OUT, MSG_IDENTIFYFLAG;
+
+	/*
+	 * Main loop for information transfer phases.  Wait for the
+	 * target to assert REQ before checking MSG, C/D and I/O for
+	 * the bus phase.
+	 */
+mesgin_phasemis:
+ITloop:
+	call	phase_lock;
+
+	mov	A, LASTPHASE;
+
+	test	A, ~P_DATAIN_DT	jz p_data;
+	cmp	A,P_COMMAND	je p_command;
+	cmp	A,P_MESGOUT	je p_mesgout;
+	cmp	A,P_STATUS	je p_status;
+	cmp	A,P_MESGIN	je p_mesgin;
+
+	SET_SEQINTCODE(BAD_PHASE)
+	jmp	ITloop;			/* Try reading the bus again. */
+
+/*
+ * Command phase.  Set up the DMA registers and let 'er rip.
+ */
+p_command:
+	test	SEQ_FLAGS, NOT_IDENTIFIED jz p_command_okay;
+	SET_SEQINTCODE(PROTO_VIOLATION)
+p_command_okay:
+	test	MODE_PTR, ~(MK_MODE(M_DFF1, M_DFF1))
+		jnz p_command_allocate_fifo;
+	/*
+	 * Command retry.  Free our current FIFO and
+	 * re-allocate a FIFO so transfer state is
+	 * reset.
+	 */
+SET_SRC_MODE	M_DFF1;
+SET_DST_MODE	M_DFF1;
+	mvi	DFFSXFRCTL, RSTCHN|CLRSHCNT;
+	SET_MODE(M_SCSI, M_SCSI)
+p_command_allocate_fifo:
+	bmov	ALLOCFIFO_SCBPTR, SCBPTR, 2;
+	call	allocate_fifo;
+SET_SRC_MODE	M_DFF1;
+SET_DST_MODE	M_DFF1;
+	add	NONE, -17, SCB_CDB_LEN;
+	jnc	p_command_embedded;
+p_command_from_host:
+	bmov	HADDR[0], SCB_HOST_CDB_PTR, 9;
+	mvi	SG_CACHE_PRE, LAST_SEG;
+	mvi	DFCNTRL, (PRELOADEN|SCSIEN|HDMAEN);
+	jmp	p_command_xfer;
+p_command_embedded:
+	bmov	SHCNT[0], SCB_CDB_LEN,  1;
+	bmov	DFDAT, SCB_CDB_STORE, 16; 
+	mvi	DFCNTRL, SCSIEN;
+p_command_xfer:
+	and	SEQ_FLAGS, ~NO_CDB_SENT;
+	test	DFCNTRL, SCSIEN jnz .;
+	/*
+	 * DMA Channel automatically disabled.
+	 * Don't allow a data phase if the command
+	 * was not fully transferred.
+	 */
+	test	SSTAT2, SDONE jnz ITloop;
+	or	SEQ_FLAGS, NO_CDB_SENT;
+	jmp	ITloop;
+
+
+/*
+ * Status phase.  Wait for the data byte to appear, then read it
+ * and store it into the SCB.
+ */
+SET_SRC_MODE	M_SCSI;
+SET_DST_MODE	M_SCSI;
+p_status:
+	test	SEQ_FLAGS,NOT_IDENTIFIED jnz mesgin_proto_violation;
+p_status_okay:
+	mov	SCB_SCSI_STATUS, SCSIDAT;
+	or	SCB_CONTROL, STATUS_RCVD;
+	jmp	ITloop;
+
+/*
+ * Message out phase.  If MSG_OUT is MSG_IDENTIFYFLAG, build a full
+ * indentify message sequence and send it to the target.  The host may
+ * override this behavior by setting the MK_MESSAGE bit in the SCB
+ * control byte.  This will cause us to interrupt the host and allow
+ * it to handle the message phase completely on its own.  If the bit
+ * associated with this target is set, we will also interrupt the host,
+ * thereby allowing it to send a message on the next selection regardless
+ * of the transaction being sent.
+ * 
+ * If MSG_OUT is == HOST_MSG, also interrupt the host and take a message.
+ * This is done to allow the host to send messages outside of an identify
+ * sequence while protecting the seqencer from testing the MK_MESSAGE bit
+ * on an SCB that might not be for the current nexus. (For example, a
+ * BDR message in responce to a bad reselection would leave us pointed to
+ * an SCB that doesn't have anything to do with the current target).
+ *
+ * Otherwise, treat MSG_OUT as a 1 byte message to send (abort, abort tag,
+ * bus device reset).
+ *
+ * When there are no messages to send, MSG_OUT should be set to MSG_NOOP,
+ * in case the target decides to put us in this phase for some strange
+ * reason.
+ */
+p_mesgout_retry:
+	/* Turn on ATN for the retry */
+	mvi	SCSISIGO, ATNO;
+p_mesgout:
+	mov	SINDEX, MSG_OUT;
+	cmp	SINDEX, MSG_IDENTIFYFLAG jne p_mesgout_from_host;
+	test	SCB_CONTROL,MK_MESSAGE	jnz host_message_loop;
+p_mesgout_identify:
+	or	SINDEX, MSG_IDENTIFYFLAG|DISCENB, SCB_LUN;
+	test	SCB_CONTROL, DISCENB jnz . + 2;
+	and	SINDEX, ~DISCENB;
+/*
+ * Send a tag message if TAG_ENB is set in the SCB control block.
+ * Use SCB_NONPACKET_TAG as the tag value.
+ */
+p_mesgout_tag:
+	test	SCB_CONTROL,TAG_ENB jz  p_mesgout_onebyte;
+	mov	SCSIDAT, SINDEX;	/* Send the identify message */
+	call	phase_lock;
+	cmp	LASTPHASE, P_MESGOUT	jne p_mesgout_done;
+	and	SCSIDAT,TAG_ENB|SCB_TAG_TYPE,SCB_CONTROL;
+	call	phase_lock;
+	cmp	LASTPHASE, P_MESGOUT	jne p_mesgout_done;
+	mov	SCBPTR jmp p_mesgout_onebyte;
+/*
+ * Interrupt the driver, and allow it to handle this message
+ * phase and any required retries.
+ */
+p_mesgout_from_host:
+	cmp	SINDEX, HOST_MSG	jne p_mesgout_onebyte;
+	jmp	host_message_loop;
+
+p_mesgout_onebyte:
+	mvi	CLRSINT1, CLRATNO;
+	mov	SCSIDAT, SINDEX;
+
+/*
+ * If the next bus phase after ATN drops is message out, it means
+ * that the target is requesting that the last message(s) be resent.
+ */
+	call	phase_lock;
+	cmp	LASTPHASE, P_MESGOUT	je p_mesgout_retry;
+
+p_mesgout_done:
+	mvi	CLRSINT1,CLRATNO;	/* Be sure to turn ATNO off */
+	mov	LAST_MSG, MSG_OUT;
+	mvi	MSG_OUT, MSG_NOOP;	/* No message left */
+	jmp	ITloop;
+
+/*
+ * Message in phase.  Bytes are read using Automatic PIO mode.
+ */
+p_mesgin:
+	/* read the 1st message byte */
+	mvi	ACCUM		call inb_first;
+
+	test	A,MSG_IDENTIFYFLAG	jnz mesgin_identify;
+	cmp	A,MSG_DISCONNECT	je mesgin_disconnect;
+	cmp	A,MSG_SAVEDATAPOINTER	je mesgin_sdptrs;
+	cmp	ALLZEROS,A		je mesgin_complete;
+	cmp	A,MSG_RESTOREPOINTERS	je mesgin_rdptrs;
+	cmp	A,MSG_IGN_WIDE_RESIDUE	je mesgin_ign_wide_residue;
+	cmp	A,MSG_NOOP		je mesgin_done;
+
+/*
+ * Pushed message loop to allow the kernel to
+ * run it's own message state engine.  To avoid an
+ * extra nop instruction after signaling the kernel,
+ * we perform the phase_lock before checking to see
+ * if we should exit the loop and skip the phase_lock
+ * in the ITloop.  Performing back to back phase_locks
+ * shouldn't hurt, but why do it twice...
+ */
+host_message_loop:
+	call	phase_lock;	/* Benign the first time through. */
+	SET_SEQINTCODE(HOST_MSG_LOOP)
+	cmp	RETURN_1, EXIT_MSG_LOOP	je ITloop;
+	cmp	RETURN_1, CONT_MSG_LOOP_WRITE	jne . + 3;
+	mov	SCSIDAT, RETURN_2;
+	jmp	host_message_loop;
+	/* Must be CONT_MSG_LOOP_READ */
+	mov	NONE, SCSIDAT;	/* ACK Byte */
+	jmp	host_message_loop;
+
+mesgin_ign_wide_residue:
+	mov	SAVED_MODE, MODE_PTR;
+	SET_MODE(M_SCSI, M_SCSI)
+	shr	NEGOADDR, 4, SAVED_SCSIID;
+	mov	A, NEGCONOPTS;
+	RESTORE_MODE(SAVED_MODE)
+	test	A, WIDEXFER jz mesgin_reject;
+	/* Pull the residue byte */
+	mvi	REG0	call inb_next;
+	cmp	REG0, 0x01 jne mesgin_reject;
+	test	SCB_RESIDUAL_SGPTR[0], SG_LIST_NULL jz . + 2;
+	test	SCB_TASK_ATTRIBUTE, SCB_XFERLEN_ODD jnz mesgin_done;
+	SET_SEQINTCODE(IGN_WIDE_RES)
+	jmp	mesgin_done;
+
+mesgin_proto_violation:
+	SET_SEQINTCODE(PROTO_VIOLATION)
+	jmp	mesgin_done;
+mesgin_reject:
+	mvi	MSG_MESSAGE_REJECT	call mk_mesg;
+mesgin_done:
+	mov	NONE,SCSIDAT;		/*dummy read from latch to ACK*/
+	jmp	ITloop;
+
+#define INDEX_DISC_LIST(scsiid, lun)					\
+	and	A, 0xC0, scsiid;					\
+	or	SCBPTR, A, lun;						\
+	clr	SCBPTR[1];						\
+	and	SINDEX, 0x30, scsiid;					\
+	shr	SINDEX, 3;	/* Multiply by 2 */			\
+	add	SINDEX, (SCB_DISCONNECTED_LISTS & 0xFF);		\
+	mvi	SINDEX[1], ((SCB_DISCONNECTED_LISTS >> 8) & 0xFF)
+
+mesgin_identify:
+	/*
+	 * Determine whether a target is using tagged or non-tagged
+	 * transactions by first looking at the transaction stored in
+	 * the per-device, disconnected array.  If there is no untagged
+	 * transaction for this target, this must be a tagged transaction.
+	 */
+	and	SAVED_LUN, MSG_IDENTIFY_LUNMASK, A;
+	INDEX_DISC_LIST(SAVED_SCSIID, SAVED_LUN);
+	bmov	DINDEX, SINDEX, 2;
+	bmov	REG0, SINDIR, 2;
+	cmp	REG0[1], SCB_LIST_NULL je snoop_tag;
+	/* Untagged.  Clear the busy table entry and setup the SCB. */
+	bmov	DINDIR, ALLONES, 2;
+	bmov	SCBPTR, REG0, 2;
+	jmp	setup_SCB;
+
+/*
+ * Here we "snoop" the bus looking for a SIMPLE QUEUE TAG message.
+ * If we get one, we use the tag returned to find the proper
+ * SCB.  After receiving the tag, look for the SCB at SCB locations tag and
+ * tag + 256.
+ */
+snoop_tag:
+	if ((ahd->flags & AHD_SEQUENCER_DEBUG) != 0) {
+		or	SEQ_FLAGS, 0x80;
+	}
+	mov	NONE, SCSIDAT;		/* ACK Identify MSG */
+	call	phase_lock;
+	if ((ahd->flags & AHD_SEQUENCER_DEBUG) != 0) {
+		or	SEQ_FLAGS, 0x1;
+	}
+	cmp	LASTPHASE, P_MESGIN	jne not_found_ITloop;
+	if ((ahd->flags & AHD_SEQUENCER_DEBUG) != 0) {
+		or	SEQ_FLAGS, 0x2;
+	}
+	cmp	SCSIBUS, MSG_SIMPLE_Q_TAG jne not_found;
+get_tag:
+	clr	SCBPTR[1];
+	mvi	SCBPTR	call inb_next;	/* tag value */
+verify_scb:
+	test	SCB_CONTROL,DISCONNECTED jz verify_other_scb;
+	mov	A, SAVED_SCSIID;
+	cmp	SCB_SCSIID, A jne verify_other_scb;
+	mov	A, SAVED_LUN;
+	cmp	SCB_LUN, A je setup_SCB_disconnected;
+verify_other_scb:
+	xor	SCBPTR[1], 1;
+	test	SCBPTR[1], 0xFF jnz verify_scb;
+	jmp	not_found;
+
+/*
+ * Ensure that the SCB the tag points to is for
+ * an SCB transaction to the reconnecting target.
+ */
+setup_SCB:
+	if ((ahd->flags & AHD_SEQUENCER_DEBUG) != 0) {
+		or	SEQ_FLAGS, 0x10;
+	}
+	test	SCB_CONTROL,DISCONNECTED jz not_found;
+setup_SCB_disconnected:
+	and	SCB_CONTROL,~DISCONNECTED;
+	clr	SEQ_FLAGS;	/* make note of IDENTIFY */
+	test	SCB_SGPTR, SG_LIST_NULL jnz . + 3;
+	bmov	ALLOCFIFO_SCBPTR, SCBPTR, 2;
+	call	allocate_fifo;
+	/* See if the host wants to send a message upon reconnection */
+	test	SCB_CONTROL, MK_MESSAGE jz mesgin_done;
+	mvi	HOST_MSG	call mk_mesg;
+	jmp	mesgin_done;
+
+not_found:
+	SET_SEQINTCODE(NO_MATCH)
+	jmp	mesgin_done;
+
+not_found_ITloop:
+	SET_SEQINTCODE(NO_MATCH)
+	jmp	ITloop;
+
+/*
+ * We received a "command complete" message.  Put the SCB on the complete
+ * queue and trigger a completion interrupt via the idle loop.  Before doing
+ * so, check to see if there
+ * is a residual or the status byte is something other than STATUS_GOOD (0).
+ * In either of these conditions, we upload the SCB back to the host so it can
+ * process this information.  In the case of a non zero status byte, we 
+ * additionally interrupt the kernel driver synchronously, allowing it to
+ * decide if sense should be retrieved.  If the kernel driver wishes to request
+ * sense, it will fill the kernel SCB with a request sense command, requeue
+ * it to the QINFIFO and tell us not to post to the QOUTFIFO by setting 
+ * RETURN_1 to SEND_SENSE.
+ */
+mesgin_complete:
+
+	/*
+	 * If ATN is raised, we still want to give the target a message.
+	 * Perhaps there was a parity error on this last message byte.
+	 * Either way, the target should take us to message out phase
+	 * and then attempt to complete the command again.  We should use a
+	 * critical section here to guard against a timeout triggering
+	 * for this command and setting ATN while we are still processing
+	 * the completion.
+	test	SCSISIGI, ATNI jnz mesgin_done;
+	 */
+
+	/*
+	 * If we are identified and have successfully sent the CDB,
+	 * any status will do.  Optimize this fast path.
+	 */
+	test	SCB_CONTROL, STATUS_RCVD jz mesgin_proto_violation;
+	test	SEQ_FLAGS, NOT_IDENTIFIED|NO_CDB_SENT jz complete_accepted;
+
+	/*
+	 * If the target never sent an identify message but instead went
+	 * to mesgin to give an invalid message, let the host abort us.
+	 */
+	test	SEQ_FLAGS, NOT_IDENTIFIED jnz mesgin_proto_violation;
+
+	/*
+	 * If we recevied good status but never successfully sent the
+	 * cdb, abort the command.
+	 */
+	test	SCB_SCSI_STATUS,0xff	jnz complete_accepted;
+	test	SEQ_FLAGS, NO_CDB_SENT jnz mesgin_proto_violation;
+complete_accepted:
+
+	/*
+	 * See if we attempted to deliver a message but the target ingnored us.
+	 */
+	test	SCB_CONTROL, MK_MESSAGE jz complete_nomsg;
+	SET_SEQINTCODE(MKMSG_FAILED)
+complete_nomsg:
+	call	queue_scb_completion;
+	jmp	await_busfree;
+
+freeze_queue:
+	/* Cancel any pending select-out. */
+	test	SSTAT0, SELDO|SELINGO jnz . + 2;
+	and	SCSISEQ0, ~ENSELO;
+	mov	ACCUM_SAVE, A;
+	clr	A;
+	add	QFREEZE_COUNT, 1;
+	adc	QFREEZE_COUNT[1], A;
+	or	SEQ_FLAGS2, SELECTOUT_QFROZEN;
+	mov	A, ACCUM_SAVE ret;
+
+/*
+ * Complete the current FIFO's SCB if data for this same
+ * SCB is not transferring in the other FIFO.
+ */
+SET_SRC_MODE	M_DFF1;
+SET_DST_MODE	M_DFF1;
+pkt_complete_scb_if_fifos_idle:
+	bmov	ARG_1, SCBPTR, 2;
+	mvi	DFFSXFRCTL, CLRCHN;
+	SET_MODE(M_SCSI, M_SCSI)
+	bmov	SCBPTR, ARG_1, 2;
+	test	SCB_FIFO_USE_COUNT, 0xFF jnz return;
+queue_scb_completion:
+	test	SCB_SCSI_STATUS,0xff	jnz bad_status;
+	/*
+	 * Check for residuals
+	 */
+	test	SCB_SGPTR, SG_LIST_NULL jnz complete;	/* No xfer */
+	test	SCB_SGPTR, SG_FULL_RESID jnz upload_scb;/* Never xfered */
+	test	SCB_RESIDUAL_SGPTR, SG_LIST_NULL jz upload_scb;
+complete:
+	bmov	SCB_NEXT_COMPLETE, COMPLETE_SCB_HEAD, 2;
+	bmov	COMPLETE_SCB_HEAD, SCBPTR, 2 ret;
+bad_status:
+	cmp	SCB_SCSI_STATUS, STATUS_PKT_SENSE je upload_scb;
+	call	freeze_queue;
+upload_scb:
+	/*
+	 * Restore SCB TAG since we reuse this field
+	 * in the sequencer.  We don't want to corrupt
+	 * it on the host.
+	 */
+	bmov	SCB_TAG, SCBPTR, 2;
+	bmov	SCB_NEXT_COMPLETE, COMPLETE_DMA_SCB_HEAD, 2;
+	bmov	COMPLETE_DMA_SCB_HEAD, SCBPTR, 2;
+	or	SCB_SGPTR, SG_STATUS_VALID ret;
+
+/*
+ * Is it a disconnect message?  Set a flag in the SCB to remind us
+ * and await the bus going free.  If this is an untagged transaction
+ * store the SCB id for it in our untagged target table for lookup on
+ * a reselction.
+ */
+mesgin_disconnect:
+	/*
+	 * If ATN is raised, we still want to give the target a message.
+	 * Perhaps there was a parity error on this last message byte
+	 * or we want to abort this command.  Either way, the target
+	 * should take us to message out phase and then attempt to
+	 * disconnect again.
+	 * XXX - Wait for more testing.
+	test	SCSISIGI, ATNI jnz mesgin_done;
+	 */
+	test	SEQ_FLAGS, NOT_IDENTIFIED|NO_CDB_SENT
+		jnz mesgin_proto_violation;
+	or	SCB_CONTROL,DISCONNECTED;
+	test	SCB_CONTROL, TAG_ENB jnz await_busfree;
+queue_disc_scb:
+	bmov	REG0, SCBPTR, 2;
+	INDEX_DISC_LIST(SAVED_SCSIID, SAVED_LUN);
+	bmov	DINDEX, SINDEX, 2;
+	bmov	DINDIR, REG0, 2;
+	bmov	SCBPTR, REG0, 2;
+	/* FALLTHROUGH */
+await_busfree:
+	and	SIMODE1, ~ENBUSFREE;
+	if ((ahd->bugs & AHD_BUSFREEREV_BUG) == 0) {
+		/*
+		 * In the BUSFREEREV_BUG case, the
+		 * busfree status was cleared at the
+		 * beginning of the connection.
+		 */
+		mvi	CLRSINT1,CLRBUSFREE;
+	}
+	mov	NONE, SCSIDAT;		/* Ack the last byte */
+	test	MODE_PTR, ~(MK_MODE(M_DFF1, M_DFF1))
+		jnz await_busfree_not_m_dff;
+SET_SRC_MODE	M_DFF1;
+SET_DST_MODE	M_DFF1;
+await_busfree_clrchn:
+	mvi	DFFSXFRCTL, CLRCHN;
+await_busfree_not_m_dff:
+	call	clear_target_state;
+	test	SSTAT1,REQINIT|BUSFREE	jz .;
+	test	SSTAT1, BUSFREE jnz idle_loop;
+	SET_SEQINTCODE(MISSED_BUSFREE)
+
+
+/*
+ * Save data pointers message:
+ * Copying RAM values back to SCB, for Save Data Pointers message, but
+ * only if we've actually been into a data phase to change them.  This
+ * protects against bogus data in scratch ram and the residual counts
+ * since they are only initialized when we go into data_in or data_out.
+ * Ack the message as soon as possible.
+ */
+SET_SRC_MODE	M_DFF1;
+SET_DST_MODE	M_DFF1;
+mesgin_sdptrs:
+	mov	NONE,SCSIDAT;		/*dummy read from latch to ACK*/
+	test	SEQ_FLAGS, DPHASE	jz ITloop;
+	call	save_pointers;
+	jmp	ITloop;
+
+save_pointers:
+	/*
+	 * If we are asked to save our position at the end of the
+	 * transfer, just mark us at the end rather than perform a
+	 * full save.
+	 */
+	test	SCB_RESIDUAL_SGPTR[0], SG_LIST_NULL jz save_pointers_full;
+	or	SCB_SGPTR, SG_LIST_NULL ret;
+
+save_pointers_full:
+	/*
+	 * The SCB_DATAPTR becomes the current SHADDR.
+	 * All other information comes directly from our residual
+	 * state.
+	 */
+	bmov	SCB_DATAPTR, SHADDR, 8;
+	bmov	SCB_DATACNT, SCB_RESIDUAL_DATACNT, 8 ret;
+
+/*
+ * Restore pointers message?  Data pointers are recopied from the
+ * SCB anytime we enter a data phase for the first time, so all
+ * we need to do is clear the DPHASE flag and let the data phase
+ * code do the rest.  We also reset/reallocate the FIFO to make
+ * sure we have a clean start for the next data or command phase.
+ */
+mesgin_rdptrs:
+	and	SEQ_FLAGS, ~DPHASE;
+	test	MODE_PTR, ~(MK_MODE(M_DFF1, M_DFF1)) jnz msgin_rdptrs_get_fifo;
+	mvi	DFFSXFRCTL, RSTCHN|CLRSHCNT;
+	SET_MODE(M_SCSI, M_SCSI)
+msgin_rdptrs_get_fifo:
+	call	allocate_fifo;
+	jmp	mesgin_done;
+
+clear_target_state:
+	mvi	LASTPHASE, P_BUSFREE;
+	/* clear target specific flags */
+	mvi	SEQ_FLAGS, NOT_IDENTIFIED|NO_CDB_SENT ret;
+
+phase_lock:     
+	if ((ahd->bugs & AHD_EARLY_REQ_BUG) != 0) {
+		/*
+		 * Don't ignore persistent REQ assertions just because
+		 * they were asserted within the bus settle delay window.
+		 * This allows us to tolerate devices like the GEM318
+		 * that violate the SCSI spec.  We are careful not to
+		 * count REQ while we are waiting for it to fall during
+		 * an async phase due to our asserted ACK.  Each
+		 * sequencer instruction takes ~25ns, so the REQ must
+		 * last at least 100ns in order to be counted as a true
+		 * REQ.
+		 */
+		test	SCSIPHASE, 0xFF jnz phase_locked;
+		test	SCSISIGI, ACKI jnz phase_lock;
+		test	SCSISIGI, REQI jz phase_lock;
+		test	SCSIPHASE, 0xFF jnz phase_locked;
+		test	SCSISIGI, ACKI jnz phase_lock;
+		test	SCSISIGI, REQI jz phase_lock;
+phase_locked:
+	} else {
+		test	SCSIPHASE, 0xFF jz .;
+	}
+	test	SSTAT1, SCSIPERR jnz phase_lock;
+phase_lock_latch_phase:
+	and	LASTPHASE, PHASE_MASK, SCSISIGI ret;
+
+/*
+ * Functions to read data in Automatic PIO mode.
+ *
+ * An ACK is not sent on input from the target until SCSIDATL is read from.
+ * So we wait until SCSIDATL is latched (the usual way), then read the data
+ * byte directly off the bus using SCSIBUSL.  When we have pulled the ATN
+ * line, or we just want to acknowledge the byte, then we do a dummy read
+ * from SCISDATL.  The SCSI spec guarantees that the target will hold the
+ * data byte on the bus until we send our ACK.
+ *
+ * The assumption here is that these are called in a particular sequence,
+ * and that REQ is already set when inb_first is called.  inb_{first,next}
+ * use the same calling convention as inb.
+ */
+inb_next:
+	mov	NONE,SCSIDAT;		/*dummy read from latch to ACK*/
+inb_next_wait:
+	/*
+	 * If there is a parity error, wait for the kernel to
+	 * see the interrupt and prepare our message response
+	 * before continuing.
+	 */
+	test	SCSIPHASE, 0xFF jz .;
+	test	SSTAT1, SCSIPERR jnz inb_next_wait;
+inb_next_check_phase:
+	and	LASTPHASE, PHASE_MASK, SCSISIGI;
+	cmp	LASTPHASE, P_MESGIN jne mesgin_phasemis;
+inb_first:
+	clr	DINDEX[1];
+	mov	DINDEX,SINDEX;
+	mov	DINDIR,SCSIBUS	ret;		/*read byte directly from bus*/
+inb_last:
+	mov	NONE,SCSIDAT ret;		/*dummy read from latch to ACK*/
+
+mk_mesg:
+	mvi	SCSISIGO, ATNO;
+	mov	MSG_OUT,SINDEX ret;
+
+SET_SRC_MODE	M_DFF1;
+SET_DST_MODE	M_DFF1;
+disable_ccsgen:
+	test	SG_STATE, FETCH_INPROG jz disable_ccsgen_fetch_done;
+	clr	CCSGCTL;
+disable_ccsgen_fetch_done:
+	clr	SG_STATE ret;
+
+service_fifo:
+	/*
+	 * Do we have any prefetch left???
+	 */
+	test	SG_STATE, SEGS_AVAIL jnz idle_sg_avail;
+
+	/*
+	 * Can this FIFO have access to the S/G cache yet?
+	 */
+	test	CCSGCTL, SG_CACHE_AVAIL jz return;
+
+	/* Did we just finish fetching segs? */
+	test	CCSGCTL, CCSGDONE jnz idle_sgfetch_complete;
+
+	/* Are we actively fetching segments? */
+	test	CCSGCTL, CCSGENACK jnz return;
+
+	/*
+	 * We fetch a "cacheline aligned" and sized amount of data
+	 * so we don't end up referencing a non-existant page.
+	 * Cacheline aligned is in quotes because the kernel will
+	 * set the prefetch amount to a reasonable level if the
+	 * cacheline size is unknown.
+	 */
+	bmov	SGHADDR, SCB_RESIDUAL_SGPTR, 4;
+	mvi	SGHCNT, SG_PREFETCH_CNT;
+	if ((ahd->bugs & AHD_REG_SLOW_SETTLE_BUG) != 0) {
+		/*
+		 * Need two instruction between "touches" of SGHADDR.
+		 */
+		nop;
+	}
+	and	SGHADDR[0], SG_PREFETCH_ALIGN_MASK, SCB_RESIDUAL_SGPTR;
+	mvi	CCSGCTL, CCSGEN|CCSGRESET;
+	or	SG_STATE, FETCH_INPROG ret;
+idle_sgfetch_complete:
+	/*
+	 * Guard against SG_CACHE_AVAIL activating during sg fetch
+	 * request in the other FIFO.
+	 */
+	test	SG_STATE, FETCH_INPROG jz return;
+	clr	CCSGCTL;
+	and	CCSGADDR, SG_PREFETCH_ADDR_MASK, SCB_RESIDUAL_SGPTR;
+	mvi	SG_STATE, SEGS_AVAIL|LOADING_NEEDED;
+idle_sg_avail:
+	/* Does the hardware have space for another SG entry? */
+	test	DFSTATUS, PRELOAD_AVAIL jz return;
+	/*
+	 * On the A, preloading a segment before HDMAENACK
+	 * comes true can clobber the shaddow address of the
+	 * first segment in the S/G FIFO.  Wait until it is
+	 * safe to proceed.
+	 */
+	if ((ahd->features & AHD_NEW_DFCNTRL_OPTS) == 0) {
+		test	DFCNTRL, HDMAENACK jz return;
+	}
+	if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
+		bmov	HADDR, CCSGRAM, 8;
+	} else {
+		bmov 	HADDR, CCSGRAM, 4;
+	}
+	bmov	HCNT, CCSGRAM, 3;
+	bmov	SCB_RESIDUAL_DATACNT[3], CCSGRAM, 1;
+	if ((ahd->flags & AHD_39BIT_ADDRESSING) != 0) {
+		and	HADDR[4], SG_HIGH_ADDR_BITS, SCB_RESIDUAL_DATACNT[3];
+	}
+	if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
+		/* Skip 4 bytes of pad. */
+		add	CCSGADDR, 4;
+	}
+sg_advance:
+	clr	A;			/* add sizeof(struct scatter) */
+	add	SCB_RESIDUAL_SGPTR[0],SG_SIZEOF;
+	adc	SCB_RESIDUAL_SGPTR[1],A;
+	adc	SCB_RESIDUAL_SGPTR[2],A;
+	adc	SCB_RESIDUAL_SGPTR[3],A;
+	mov	SINDEX, SCB_RESIDUAL_SGPTR[0];
+	test	SCB_RESIDUAL_DATACNT[3], SG_LAST_SEG jz . + 3;
+	or	SINDEX, LAST_SEG;
+	clr	SG_STATE;
+	mov	SG_CACHE_PRE, SINDEX;
+	if ((ahd->features & AHD_NEW_DFCNTRL_OPTS) != 0) {
+		/*
+		 * Use SCSIENWRDIS so that SCSIEN is never
+		 * modified by this operation.
+		 */
+		or	DFCNTRL, PRELOADEN|HDMAEN|SCSIENWRDIS;
+	} else {
+		or	DFCNTRL, PRELOADEN|HDMAEN;
+	}
+	/*
+	 * Do we have another segment in the cache?
+	 */
+	add	NONE, SG_PREFETCH_CNT_LIMIT, CCSGADDR;
+	jnc	return;
+	and	SG_STATE, ~SEGS_AVAIL ret;
+
+/*
+ * Initialize the DMA address and counter from the SCB.
+ */
+load_first_seg:
+	bmov	HADDR, SCB_DATAPTR, 11;
+	and	REG_ISR, ~SG_FULL_RESID, SCB_SGPTR[0];
+	test	SCB_DATACNT[3], SG_LAST_SEG jz . + 2;
+	or	REG_ISR, LAST_SEG;
+	mov	SG_CACHE_PRE, REG_ISR;
+	mvi	DFCNTRL, (PRELOADEN|SCSIEN|HDMAEN);
+	/*
+	 * Since we've are entering a data phase, we will
+	 * rely on the SCB_RESID* fields.  Initialize the
+	 * residual and clear the full residual flag.
+	 */
+	and	SCB_SGPTR[0], ~SG_FULL_RESID;
+	bmov	SCB_RESIDUAL_DATACNT[3], SCB_DATACNT[3], 5;
+	/* If we need more S/G elements, tell the idle loop */
+	test	SCB_RESIDUAL_DATACNT[3], SG_LAST_SEG jnz . + 2;
+	mvi	SG_STATE, LOADING_NEEDED ret;
+	clr	SG_STATE ret;
+
+p_data_handle_xfer:
+	call	setjmp;
+	test	SG_STATE, LOADING_NEEDED jnz service_fifo;
+p_data_clear_handler:
+	or	LONGJMP_ADDR[1], INVALID_ADDR ret;
+
+p_data:
+	test	SEQ_FLAGS, NOT_IDENTIFIED|NO_CDB_SENT	jz p_data_allowed;
+	SET_SEQINTCODE(PROTO_VIOLATION)
+p_data_allowed:
+ 
+	test	SEQ_FLAGS, DPHASE	jz data_phase_initialize;
+
+	/*
+	 * If we re-enter the data phase after going through another
+	 * phase, our transfer location has almost certainly been
+	 * corrupted by the interveining, non-data, transfers.  Ask
+	 * the host driver to fix us up based on the transfer residual
+	 * unless we already know that we should be bitbucketing.
+	 */
+	test	SCB_RESIDUAL_SGPTR[0], SG_LIST_NULL jnz p_data_bitbucket;
+	SET_SEQINTCODE(PDATA_REINIT)
+	jmp	data_phase_inbounds;
+
+p_data_bitbucket:
+	/*
+	 * Turn on `Bit Bucket' mode, wait until the target takes
+	 * us to another phase, and then notify the host.
+	 */
+	mov	SAVED_MODE, MODE_PTR;
+	test	MODE_PTR, ~(MK_MODE(M_DFF1, M_DFF1))
+		jnz bitbucket_not_m_dff;
+	/*
+	 * Ensure that any FIFO contents are cleared out and the
+	 * FIFO free'd prior to starting the BITBUCKET.  BITBUCKET
+	 * doesn't discard data already in the FIFO.
+	 */
+	mvi	DFFSXFRCTL, RSTCHN|CLRSHCNT;
+	SET_MODE(M_SCSI, M_SCSI)
+bitbucket_not_m_dff:
+	or	SXFRCTL1,BITBUCKET;
+	/* Wait for non-data phase. */
+	test	SCSIPHASE, ~DATA_PHASE_MASK jz .;
+	and	SXFRCTL1, ~BITBUCKET;
+	RESTORE_MODE(SAVED_MODE)
+SET_SRC_MODE	M_DFF1;
+SET_DST_MODE	M_DFF1;
+	SET_SEQINTCODE(DATA_OVERRUN)
+	jmp	ITloop;
+
+data_phase_initialize:
+	test	SCB_SGPTR[0], SG_LIST_NULL jnz p_data_bitbucket;
+	call	load_first_seg;
+data_phase_inbounds:
+	/* We have seen a data phase at least once. */
+	or	SEQ_FLAGS, DPHASE;
+	mov	SAVED_MODE, MODE_PTR;
+	test	SG_STATE, LOADING_NEEDED jz data_group_dma_loop;
+	call	p_data_handle_xfer;
+data_group_dma_loop:
+	/*
+	 * The transfer is complete if either the last segment
+	 * completes or the target changes phase.  Both conditions
+	 * will clear SCSIEN.
+	 */
+	call	idle_loop_service_fifos;
+	call	idle_loop_cchan;
+	call	idle_loop_gsfifo;
+	RESTORE_MODE(SAVED_MODE)
+	test	DFCNTRL, SCSIEN jnz data_group_dma_loop;
+
+data_group_dmafinish:
+	/*
+	 * The transfer has terminated either due to a phase
+	 * change, and/or the completion of the last segment.
+	 * We have two goals here.  Do as much other work
+	 * as possible while the data fifo drains on a read
+	 * and respond as quickly as possible to the standard
+	 * messages (save data pointers/disconnect and command
+	 * complete) that usually follow a data phase.
+	 */
+	call	calc_residual;
+
+	/*
+	 * Go ahead and shut down the DMA engine now.
+	 */
+	test	DFCNTRL, DIRECTION jnz data_phase_finish;
+data_group_fifoflush:
+	if ((ahd->bugs & AHD_AUTOFLUSH_BUG) != 0) {
+		or	DFCNTRL, FIFOFLUSH;
+	}
+	/*
+	 * We have enabled the auto-ack feature.  This means
+	 * that the controller may have already transferred
+	 * some overrun bytes into the data FIFO and acked them
+	 * on the bus.  The only way to detect this situation is
+	 * to wait for LAST_SEG_DONE to come true on a completed
+	 * transfer and then test to see if the data FIFO is
+	 * non-empty.  We know there is more data yet to transfer
+	 * if SG_LIST_NULL is not yet set, thus there cannot be
+	 * an overrun.
+	 */
+	test	SCB_RESIDUAL_SGPTR[0], SG_LIST_NULL jz data_phase_finish;
+	test	SG_CACHE_SHADOW, LAST_SEG_DONE jz .;
+	test	DFSTATUS, FIFOEMP jnz data_phase_finish;
+	/* Overrun */
+	jmp	p_data;
+data_phase_finish:
+	/*
+	 * If the target has left us in data phase, loop through
+	 * the dma code again.  We will only loop if there is a
+	 * data overrun.  
+	 */
+	if ((ahd->flags & AHD_TARGETROLE) != 0) {
+		test	SSTAT0, TARGET jnz data_phase_done;
+	}
+	if ((ahd->flags & AHD_INITIATORROLE) != 0) {
+		test	SSTAT1, REQINIT jz .;
+		test	SCSIPHASE, DATA_PHASE_MASK jnz p_data;
+	}
+
+data_phase_done:
+	/* Kill off any pending prefetch */
+	call	disable_ccsgen;
+	or 	LONGJMP_ADDR[1], INVALID_ADDR;
+
+	if ((ahd->flags & AHD_TARGETROLE) != 0) {
+		test	SEQ_FLAGS, DPHASE_PENDING jz ITloop;
+		/*
+		and	SEQ_FLAGS, ~DPHASE_PENDING;
+		 * For data-in phases, wait for any pending acks from the
+		 * initiator before changing phase.  We only need to
+		 * send Ignore Wide Residue messages for data-in phases.
+		test	DFCNTRL, DIRECTION jz target_ITloop;
+		test	SSTAT1, REQINIT	jnz .;
+		test	SCB_TASK_ATTRIBUTE, SCB_XFERLEN_ODD jz target_ITloop;
+		SET_MODE(M_SCSI, M_SCSI)
+		test	NEGCONOPTS, WIDEXFER jz target_ITloop;
+		 */
+		/*
+		 * Issue an Ignore Wide Residue Message.
+		mvi	P_MESGIN|BSYO call change_phase;
+		mvi	MSG_IGN_WIDE_RESIDUE call target_outb;
+		mvi	1 call target_outb;
+		jmp	target_ITloop;
+		 */
+	} else {
+		jmp	ITloop;
+	}
+
+/*
+ * We assume that, even though data may still be
+ * transferring to the host, that the SCSI side of
+ * the DMA engine is now in a static state.  This
+ * allows us to update our notion of where we are
+ * in this transfer.
+ *
+ * If, by chance, we stopped before being able
+ * to fetch additional segments for this transfer,
+ * yet the last S/G was completely exhausted,
+ * call our idle loop until it is able to load
+ * another segment.  This will allow us to immediately
+ * pickup on the next segment on the next data phase.
+ *
+ * If we happened to stop on the last segment, then
+ * our residual information is still correct from
+ * the idle loop and there is no need to perform
+ * any fixups.
+ */
+residual_before_last_seg:
+	test    MDFFSTAT, SHVALID	jnz sgptr_fixup;
+	/*
+	 * Can never happen from an interrupt as the packetized
+	 * hardware will only interrupt us once SHVALID or
+	 * LAST_SEG_DONE.
+	 */
+	call	idle_loop_service_fifos;
+	RESTORE_MODE(SAVED_MODE)
+	/* FALLTHROUGH */
+calc_residual:
+	test	SG_CACHE_SHADOW, LAST_SEG jz residual_before_last_seg;
+	/* Record if we've consumed all S/G entries */
+	test	MDFFSTAT, SHVALID	jz . + 2;
+	bmov	SCB_RESIDUAL_DATACNT, SHCNT, 3 ret;
+	or	SCB_RESIDUAL_SGPTR[0], SG_LIST_NULL ret;
+
+sgptr_fixup:
+	/*
+	 * Fixup the residual next S/G pointer.  The S/G preload
+	 * feature of the chip allows us to load two elements
+	 * in addition to the currently active element.  We
+	 * store the bottom byte of the next S/G pointer in
+	 * the SG_CACHE_PTR register so we can restore the
+	 * correct value when the DMA completes.  If the next
+	 * sg ptr value has advanced to the point where higher
+	 * bytes in the address have been affected, fix them
+	 * too.
+	 */
+	test	SG_CACHE_SHADOW, 0x80 jz sgptr_fixup_done;
+	test	SCB_RESIDUAL_SGPTR[0], 0x80 jnz sgptr_fixup_done;
+	add	SCB_RESIDUAL_SGPTR[1], -1;
+	adc	SCB_RESIDUAL_SGPTR[2], -1; 
+	adc	SCB_RESIDUAL_SGPTR[3], -1;
+sgptr_fixup_done:
+	and	SCB_RESIDUAL_SGPTR[0], SG_ADDR_MASK, SG_CACHE_SHADOW;
+	clr	SCB_RESIDUAL_DATACNT[3]; /* We are not the last seg */
+	bmov	SCB_RESIDUAL_DATACNT, SHCNT, 3 ret;
+
+export timer_isr:
+	call	issue_cmdcmplt;
+	mvi	CLRSEQINTSTAT, CLRSEQ_SWTMRTO;
+	if ((ahd->bugs & AHD_SET_MODE_BUG) != 0) {
+		/*
+		 * In H2A4, the mode pointer is not saved
+		 * for intvec2, but is restored on iret.
+		 * This can lead to the restoration of a
+		 * bogus mode ptr.  Manually clear the
+		 * intmask bits and do a normal return
+		 * to compensate.
+		 */
+		and	SEQINTCTL, ~(INTMASK2|INTMASK1) ret;
+	} else {
+		or	SEQINTCTL, IRET ret;
+	}
+
+export seq_isr:
+	if ((ahd->features & AHD_RTI) == 0) {
+		/*
+		 * On RevA Silicon, if the target returns us to data-out
+		 * after we have already trained for data-out, it is
+		 * possible for us to transition the free running clock to
+		 * data-valid before the required 100ns P1 setup time (8 P1
+		 * assertions in fast-160 mode).  This will only happen if
+		 * this L-Q is a continuation of a data transfer for which
+		 * we have already prefetched data into our FIFO (LQ/Data
+		 * followed by LQ/Data for the same write transaction).
+		 * This can cause some target implementations to miss the
+		 * first few data transfers on the bus.  We detect this
+		 * situation by noticing that this is the first data transfer
+		 * after an LQ (LQIWORKONLQ true), that the data transfer is
+		 * a continuation of a transfer already setup in our FIFO
+		 * (SAVEPTRS interrupt), and that the transaction is a write
+		 * (DIRECTION set in DFCNTRL). The delay is performed by
+		 * disabling SCSIEN until we see the first REQ from the
+		 * target.
+		 * 
+		 * First instruction in an ISR cannot be a branch on
+		 * Rev A.  Snapshot LQISTAT2 so the status is not missed
+		 * and deffer the test by one instruction.
+		 */
+		mov	REG_ISR, LQISTAT2;
+		test	REG_ISR, LQIWORKONLQ jz main_isr;
+		test	SEQINTSRC, SAVEPTRS  jz main_isr;
+		test	LONGJMP_ADDR[1], INVALID_ADDR jz saveptr_active_fifo;
+		/*
+		 * Switch to the active FIFO after clearing the snapshot
+		 * savepointer in the current FIFO.  We do this so that
+		 * a pending CTXTDONE or SAVEPTR is visible in the active
+		 * FIFO.  This status is the only way we can detect if we
+		 * have lost the race (e.g. host paused us) and our attepts
+		 * to disable the channel occurred after all REQs were
+		 * already seen and acked (REQINIT never comes true).
+		 */
+		mvi	DFFSXFRCTL, CLRCHN;
+		xor	MODE_PTR, MK_MODE(M_DFF1, M_DFF1);
+		test	DFCNTRL, DIRECTION jz interrupt_return;
+		and	DFCNTRL, ~SCSIEN;
+snapshot_wait_data_valid:
+		test	SEQINTSRC, (CTXTDONE|SAVEPTRS) jnz snapshot_data_valid;
+		test	SSTAT1, REQINIT	jz snapshot_wait_data_valid;
+snapshot_data_valid:
+		or	DFCNTRL, SCSIEN;
+		or	SEQINTCTL, IRET ret;
+snapshot_saveptr:
+		mvi	DFFSXFRCTL, CLRCHN;
+		or	SEQINTCTL, IRET ret;
+main_isr:
+	}
+	test	SEQINTSRC, CFG4DATA	jnz cfg4data_intr;
+	test	SEQINTSRC, CFG4ISTAT	jnz cfg4istat_intr;
+	test	SEQINTSRC, SAVEPTRS	jnz saveptr_intr;
+	test	SEQINTSRC, CFG4ICMD	jnz cfg4icmd_intr;
+	SET_SEQINTCODE(INVALID_SEQINT)
+
+/*
+ * There are two types of save pointers interrupts:
+ * The first is a snapshot save pointers where the current FIFO is not
+ * active and contains a snapshot of the current poniter information.
+ * This happens between packets in a stream for a single L_Q.  Since we
+ * are not performing a pointer save, we can safely clear the channel
+ * so it can be used for other transactions.  On RTI capable controllers,
+ * where snapshots can, and are, disabled, the code to handle this type
+ * of snapshot is not active.
+ *
+ * The second case is a save pointers on an active FIFO which occurs
+ * if the target changes to a new L_Q or busfrees/QASes and the transfer
+ * has a residual.  This should occur coincident with a ctxtdone.  We
+ * disable the interrupt and allow our active routine to handle the
+ * save.
+ */
+saveptr_intr:
+	if ((ahd->features & AHD_RTI) == 0) {
+		test	LONGJMP_ADDR[1], INVALID_ADDR jnz snapshot_saveptr;
+	}
+saveptr_active_fifo:
+	and	SEQIMODE, ~ENSAVEPTRS;
+	or	SEQINTCTL, IRET ret;
+
+cfg4data_intr:
+	test	SCB_SGPTR[0], SG_LIST_NULL jnz pkt_handle_overrun_inc_use_count;
+	call	load_first_seg;
+	call	pkt_handle_xfer;
+	inc	SCB_FIFO_USE_COUNT;
+interrupt_return:
+	or	SEQINTCTL, IRET ret;
+
+cfg4istat_intr:
+	call	freeze_queue;
+	add	NONE, -13, SCB_CDB_LEN;
+	jnc	cfg4istat_have_sense_addr;
+	test	SCB_CDB_LEN, SCB_CDB_LEN_PTR jnz cfg4istat_have_sense_addr;
+	/*
+	 * Host sets up address/count and enables transfer.
+	 */
+	SET_SEQINTCODE(CFG4ISTAT_INTR)
+	jmp	cfg4istat_setup_handler;
+cfg4istat_have_sense_addr:
+	bmov	HADDR, SCB_SENSE_BUSADDR, 4;
+	mvi	HCNT[1], (AHD_SENSE_BUFSIZE >> 8);
+	mvi	SG_CACHE_PRE, LAST_SEG;
+	mvi	DFCNTRL, PRELOADEN|SCSIEN|HDMAEN;
+cfg4istat_setup_handler:
+	/*
+	 * Status pkt is transferring to host.
+	 * Wait in idle loop for transfer to complete.
+	 * If a command completed before an attempted
+	 * task management function completed, notify the host.
+	 */
+	test	SCB_TASK_MANAGEMENT, 0xFF jz cfg4istat_no_taskmgmt_func;
+	SET_SEQINTCODE(TASKMGMT_CMD_CMPLT_OKAY)
+cfg4istat_no_taskmgmt_func:
+	call	pkt_handle_status;
+	or	SEQINTCTL, IRET ret;
+
+cfg4icmd_intr:
+	/*
+	 * In the case of DMAing a CDB from the host, the normal
+	 * CDB buffer is formatted with an 8 byte address followed
+	 * by a 1 byte count.
+	 */
+	bmov	HADDR[0], SCB_HOST_CDB_PTR, 9;
+	mvi	SG_CACHE_PRE, LAST_SEG;
+	mvi	DFCNTRL, (PRELOADEN|SCSIEN|HDMAEN);
+	call	pkt_handle_cdb;
+	or	SEQINTCTL, IRET ret;
+
+/*
+ * See if the target has gone on in this context creating an
+ * overrun condition.  For the write case, the hardware cannot
+ * ack bytes until data are provided.  So, if the target begins
+ * another  packet without changing contexts, implying we are
+ * not sitting on a packet boundary, we are in an overrun
+ * situation.  For the read case, the hardware will continue to
+ * ack bytes into the FIFO, and may even ack the last overrun packet
+ * into the FIFO.   If the FIFO should become non-empty, we are in
+ * a read overrun case.
+ */
+#define check_overrun							\
+	/* Not on a packet boundary. */					\
+	test 	MDFFSTAT, DLZERO jz pkt_handle_overrun;			\
+	test	DFSTATUS, FIFOEMP jz pkt_handle_overrun
+
+pkt_handle_xfer:
+	test	SG_STATE, LOADING_NEEDED jz pkt_last_seg;
+	call	setjmp;
+	test	SEQINTSRC, SAVEPTRS jnz pkt_saveptrs;
+	test	SCSIPHASE, ~DATA_PHASE_MASK jz . + 2;
+	test	SCSISIGO, ATNO jnz . + 2;
+	test	SSTAT2, NONPACKREQ jz pkt_service_fifo;
+	/*
+	 * Defer handling of this NONPACKREQ until we
+	 * can be sure it pertains to this FIFO.  SAVEPTRS
+	 * will not be asserted if the NONPACKREQ is for us,
+	 * so we must simulate it if shaddow is valid.  If
+	 * shaddow is not valid, keep running this FIFO until we
+	 * have satisfied the transfer by loading segments and
+	 * waiting for either shaddow valid or last_seg_done.
+	 */
+	test	MDFFSTAT, SHVALID jnz pkt_saveptrs;
+pkt_service_fifo:
+	test	SG_STATE, LOADING_NEEDED jnz service_fifo;
+pkt_last_seg:
+	call	setjmp;
+	test	SEQINTSRC, SAVEPTRS jnz pkt_saveptrs;
+	test	SG_CACHE_SHADOW, LAST_SEG_DONE jnz pkt_last_seg_done;
+	test	SCSIPHASE, ~DATA_PHASE_MASK jz . + 2;
+	test	SCSISIGO, ATNO jnz . + 2;
+	test	SSTAT2, NONPACKREQ jz return;
+	test	MDFFSTAT, SHVALID jz return;
+	/* FALLTHROUGH */
+
+/*
+ * Either a SAVEPTRS interrupt condition is pending for this FIFO
+ * or we have a pending NONPACKREQ for this FIFO.  We differentiate
+ * between the two by capturing the state of the SAVEPTRS interrupt
+ * prior to clearing this status and executing the common code for
+ * these two cases.
+ */
+pkt_saveptrs:
+BEGIN_CRITICAL;
+	if ((ahd->bugs & AHD_AUTOFLUSH_BUG) != 0) {
+		or	DFCNTRL, FIFOFLUSH;
+	}
+	mov	REG0, SEQINTSRC;
+	call	calc_residual;
+	call	save_pointers;
+	mvi	CLRSEQINTSRC, CLRSAVEPTRS;
+	call	disable_ccsgen;
+	or	SEQIMODE, ENSAVEPTRS;
+	test	DFCNTRL, DIRECTION jnz pkt_saveptrs_check_status;
+	test	DFSTATUS, FIFOEMP jnz pkt_saveptrs_check_status;
+	/*
+	 * Keep a handler around for this FIFO until it drains
+	 * to the host to guarantee that we don't complete the
+	 * command to the host before the data arrives.
+	 */
+pkt_saveptrs_wait_fifoemp:
+	call	setjmp;
+	test	DFSTATUS, FIFOEMP jz return;
+pkt_saveptrs_check_status:
+	or	LONGJMP_ADDR[1], INVALID_ADDR;
+	test	REG0, SAVEPTRS jz unexpected_nonpkt_phase;
+	dec	SCB_FIFO_USE_COUNT;
+	test	SCB_CONTROL, STATUS_RCVD jnz pkt_complete_scb_if_fifos_idle;
+	mvi	DFFSXFRCTL, CLRCHN ret;
+END_CRITICAL;
+
+/*
+ * LAST_SEG_DONE status has been seen in the current FIFO.
+ * This indicates that all of the allowed data for this
+ * command has transferred across the SCSI and host buses.
+ * Check for overrun and see if we can complete this command.
+ */
+pkt_last_seg_done:
+BEGIN_CRITICAL;
+	/*
+	 * Mark transfer as completed.
+	 */
+	or	SCB_SGPTR, SG_LIST_NULL;
+
+	/*
+	 * Wait for the current context to finish to verify that
+	 * no overrun condition has occurred.
+	 */
+	test	SEQINTSRC, CTXTDONE jnz pkt_ctxt_done;
+	call	setjmp;
+pkt_wait_ctxt_done_loop:
+	test	SEQINTSRC, CTXTDONE jnz pkt_ctxt_done;
+	/*
+	 * A sufficiently large overrun or a NONPACKREQ may
+	 * prevent CTXTDONE from ever asserting, so we must
+	 * poll for these statuses too.
+	 */
+	check_overrun;
+	test	SSTAT2, NONPACKREQ jz return;
+	test	SEQINTSRC, CTXTDONE jz unexpected_nonpkt_phase;
+	/* FALLTHROUGH */
+
+pkt_ctxt_done:
+	check_overrun;
+	or	LONGJMP_ADDR[1], INVALID_ADDR;
+	/*
+	 * If status has been received, it is safe to skip
+	 * the check to see if another FIFO is active because
+	 * LAST_SEG_DONE has been observed.  However, we check
+	 * the FIFO anyway since it costs us only one extra
+	 * instruction to leverage common code to perform the
+	 * SCB completion.
+	 */
+	dec	SCB_FIFO_USE_COUNT;
+	test	SCB_CONTROL, STATUS_RCVD jnz pkt_complete_scb_if_fifos_idle;
+	mvi	DFFSXFRCTL, CLRCHN ret;
+END_CRITICAL;
+
+/*
+ * Must wait until CDB xfer is over before issuing the
+ * clear channel.
+ */
+pkt_handle_cdb:
+	call	setjmp;
+	test	SG_CACHE_SHADOW, LAST_SEG_DONE jz return;
+	or	LONGJMP_ADDR[1], INVALID_ADDR;
+	mvi	DFFSXFRCTL, CLRCHN ret;
+
+/*
+ * Watch over the status transfer.  Our host sense buffer is
+ * large enough to take the maximum allowed status packet.
+ * None-the-less, we must still catch and report overruns to
+ * the host.  Additionally, properly catch unexpected non-packet
+ * phases that are typically caused by CRC errors in status packet
+ * transmission.
+ */
+pkt_handle_status:
+	call	setjmp;
+	test	SG_CACHE_SHADOW, LAST_SEG_DONE jnz pkt_status_check_overrun;
+	test	SEQINTSRC, CTXTDONE jz pkt_status_check_nonpackreq;
+	test	SG_CACHE_SHADOW, LAST_SEG_DONE jnz pkt_status_check_overrun;
+pkt_status_IU_done:
+	if ((ahd->bugs & AHD_AUTOFLUSH_BUG) != 0) {
+		or	DFCNTRL, FIFOFLUSH;
+	}
+	test	DFSTATUS, FIFOEMP jz return;
+BEGIN_CRITICAL;
+	or	LONGJMP_ADDR[1], INVALID_ADDR;
+	mvi	SCB_SCSI_STATUS, STATUS_PKT_SENSE;
+	or	SCB_CONTROL, STATUS_RCVD;
+	jmp	pkt_complete_scb_if_fifos_idle;
+END_CRITICAL;
+pkt_status_check_overrun:
+	/*
+	 * Status PKT overruns are uncerimoniously recovered with a
+	 * bus reset.  If we've overrun, let the host know so that
+	 * recovery can be performed.
+	 *
+	 * LAST_SEG_DONE has been observed.  If either CTXTDONE or
+	 * a NONPACKREQ phase change have occurred and the FIFO is
+	 * empty, there is no overrun.
+	 */
+	test	DFSTATUS, FIFOEMP jz pkt_status_report_overrun;
+	test	SEQINTSRC, CTXTDONE jz . + 2;
+	test	DFSTATUS, FIFOEMP jnz pkt_status_IU_done;
+	test	SCSIPHASE, ~DATA_PHASE_MASK jz return;
+	test	DFSTATUS, FIFOEMP jnz pkt_status_check_nonpackreq;
+pkt_status_report_overrun:
+	SET_SEQINTCODE(STATUS_OVERRUN)
+	/* SEQUENCER RESTARTED */
+pkt_status_check_nonpackreq:
+	/*
+	 * CTXTDONE may be held off if a NONPACKREQ is associated with
+	 * the current context.  If a NONPACKREQ is observed, decide
+	 * if it is for the current context.  If it is for the current
+	 * context, we must defer NONPACKREQ processing until all data
+	 * has transferred to the host.
+	 */
+	test	SCSIPHASE, ~DATA_PHASE_MASK jz return;
+	test	SCSISIGO, ATNO jnz . + 2;
+	test	SSTAT2, NONPACKREQ jz return;
+	test	SEQINTSRC, CTXTDONE jnz pkt_status_IU_done;
+	test	DFSTATUS, FIFOEMP jz return;
+	/*
+	 * The unexpected nonpkt phase handler assumes that any
+	 * data channel use will have a FIFO reference count.  It
+	 * turns out that the status handler doesn't need a refernce
+	 * count since the status received flag, and thus completion
+	 * processing, cannot be set until the handler is finished.
+	 * We increment the count here to make the nonpkt handler
+	 * happy.
+	 */
+	inc	SCB_FIFO_USE_COUNT;
+	/* FALLTHROUGH */
+
+/*
+ * Nonpackreq is a polled status.  It can come true in three situations:
+ * we have received an L_Q, we have sent one or more L_Qs, or there is no
+ * L_Q context associated with this REQ (REQ occurs immediately after a
+ * (re)selection).  Routines that know that the context responsible for this
+ * nonpackreq call directly into unexpected_nonpkt_phase.  In the case of the
+ * top level idle loop, we exhaust all active contexts prior to determining that
+ * we simply do not have the full I_T_L_Q for this phase.
+ */
+unexpected_nonpkt_phase_find_ctxt:
+	/*
+	 * This nonpackreq is most likely associated with one of the tags
+	 * in a FIFO or an outgoing LQ.  Only treat it as an I_T only
+	 * nonpackreq if we've cleared out the FIFOs and handled any
+	 * pending SELDO.
+	 */
+SET_SRC_MODE	M_SCSI;
+SET_DST_MODE	M_SCSI;
+	and	A, FIFO1FREE|FIFO0FREE, DFFSTAT;
+	cmp	A, FIFO1FREE|FIFO0FREE jne return;
+	test	SSTAT0, SELDO jnz return;
+	mvi	SCBPTR[1], SCB_LIST_NULL;
+unexpected_nonpkt_phase:
+	test	MODE_PTR, ~(MK_MODE(M_DFF1, M_DFF1)) jnz . + 3;
+SET_SRC_MODE	M_DFF0;
+SET_DST_MODE	M_DFF0;
+	or	LONGJMP_ADDR[1], INVALID_ADDR;
+	dec	SCB_FIFO_USE_COUNT;
+	mvi	DFFSXFRCTL, CLRCHN;
+	mvi	CLRSINT2, CLRNONPACKREQ;
+	test	SCSIPHASE, ~(MSG_IN_PHASE|MSG_OUT_PHASE) jnz illegal_phase;
+	SET_SEQINTCODE(ENTERING_NONPACK)
+	jmp	ITloop;
+
+illegal_phase:
+	SET_SEQINTCODE(ILLEGAL_PHASE)
+	jmp	ITloop;
+
+/*
+ * We have entered an overrun situation.  If we have working
+ * BITBUCKET, flip that on and let the hardware eat any overrun
+ * data.  Otherwise use an overrun buffer in the host to simulate
+ * BITBUCKET.
+ */
+pkt_handle_overrun_inc_use_count:
+	inc	SCB_FIFO_USE_COUNT;
+pkt_handle_overrun:
+	SET_SEQINTCODE(CFG4OVERRUN)
+	call	freeze_queue;
+	if ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) == 0) {
+		or	DFFSXFRCTL, DFFBITBUCKET;
+SET_SRC_MODE	M_DFF1;
+SET_DST_MODE	M_DFF1;
+	} else {
+		call	load_overrun_buf;
+		mvi	DFCNTRL, (HDMAEN|SCSIEN|PRELOADEN);
+	}
+	call	setjmp;
+	if ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0) {
+		test	DFSTATUS, PRELOAD_AVAIL jz overrun_load_done;
+		call	load_overrun_buf;
+		or	DFCNTRL, PRELOADEN;
+overrun_load_done:
+		test	SEQINTSRC, CTXTDONE jnz pkt_overrun_end;
+	} else {
+		test	DFFSXFRCTL, DFFBITBUCKET jz pkt_overrun_end;
+	}
+	test	SSTAT2, NONPACKREQ jz return;
+pkt_overrun_end:
+	or	SCB_RESIDUAL_SGPTR, SG_OVERRUN_RESID;
+	test	SEQINTSRC, CTXTDONE jz unexpected_nonpkt_phase;
+	dec	SCB_FIFO_USE_COUNT;
+	or	LONGJMP_ADDR[1], INVALID_ADDR;
+	test	SCB_CONTROL, STATUS_RCVD jnz pkt_complete_scb_if_fifos_idle;
+	mvi	DFFSXFRCTL, CLRCHN ret;
+
+if ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0) {
+load_overrun_buf:
+	/*
+	 * Load a dummy segment if preload space is available.
+	 */
+	mov 	HADDR[0], SHARED_DATA_ADDR;
+	add	HADDR[1], PKT_OVERRUN_BUFOFFSET, SHARED_DATA_ADDR[1];
+	mov	ACCUM_SAVE, A;
+	clr	A;
+	adc	HADDR[2], A, SHARED_DATA_ADDR[2];
+	adc	HADDR[3], A, SHARED_DATA_ADDR[3];
+	mov	A, ACCUM_SAVE;
+	bmov	HADDR[4], ALLZEROS, 4;
+	/* PKT_OVERRUN_BUFSIZE is a multiple of 256 */
+	clr	HCNT[0];
+	mvi	HCNT[1], ((PKT_OVERRUN_BUFSIZE >> 8) & 0xFF);
+	clr	HCNT[2] ret;
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic79xx_core.c linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx_core.c
--- linux-2.4.21/drivers/scsi/aic7xxx/aic79xx_core.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx_core.c	2003-06-26 21:43:16.000000000 +0000
@@ -0,0 +1,9541 @@
+/*
+ * Core routines and tables shareable across OS platforms.
+ *
+ * Copyright (c) 1994-2002 Justin T. Gibbs.
+ * Copyright (c) 2000-2003 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: //depot/aic7xxx/aic7xxx/aic79xx.c#197 $
+ *
+ * $FreeBSD$
+ */
+
+#ifdef __linux__
+#include "aic79xx_osm.h"
+#include "aic79xx_inline.h"
+#include "aicasm/aicasm_insformat.h"
+#else
+#include <dev/aic7xxx/aic79xx_osm.h>
+#include <dev/aic7xxx/aic79xx_inline.h>
+#include <dev/aic7xxx/aicasm/aicasm_insformat.h>
+#endif
+
+/******************************** Globals *************************************/
+struct ahd_softc_tailq ahd_tailq = TAILQ_HEAD_INITIALIZER(ahd_tailq);
+
+/***************************** Lookup Tables **********************************/
+char *ahd_chip_names[] =
+{
+	"NONE",
+	"aic7901",
+	"aic7902",
+	"aic7901A"
+};
+static const u_int num_chip_names = NUM_ELEMENTS(ahd_chip_names);
+
+/*
+ * Hardware error codes.
+ */
+struct ahd_hard_error_entry {
+        uint8_t errno;
+	char *errmesg;
+};
+
+static struct ahd_hard_error_entry ahd_hard_errors[] = {
+	{ DSCTMOUT,	"Discard Timer has timed out" },
+	{ ILLOPCODE,	"Illegal Opcode in sequencer program" },
+	{ SQPARERR,	"Sequencer Parity Error" },
+	{ DPARERR,	"Data-path Parity Error" },
+	{ MPARERR,	"Scratch or SCB Memory Parity Error" },
+	{ CIOPARERR,	"CIOBUS Parity Error" },
+};
+static const u_int num_errors = NUM_ELEMENTS(ahd_hard_errors);
+
+static struct ahd_phase_table_entry ahd_phase_table[] =
+{
+	{ P_DATAOUT,	MSG_NOOP,		"in Data-out phase"	},
+	{ P_DATAIN,	MSG_INITIATOR_DET_ERR,	"in Data-in phase"	},
+	{ P_DATAOUT_DT,	MSG_NOOP,		"in DT Data-out phase"	},
+	{ P_DATAIN_DT,	MSG_INITIATOR_DET_ERR,	"in DT Data-in phase"	},
+	{ P_COMMAND,	MSG_NOOP,		"in Command phase"	},
+	{ P_MESGOUT,	MSG_NOOP,		"in Message-out phase"	},
+	{ P_STATUS,	MSG_INITIATOR_DET_ERR,	"in Status phase"	},
+	{ P_MESGIN,	MSG_PARITY_ERROR,	"in Message-in phase"	},
+	{ P_BUSFREE,	MSG_NOOP,		"while idle"		},
+	{ 0,		MSG_NOOP,		"in unknown phase"	}
+};
+
+/*
+ * In most cases we only wish to itterate over real phases, so
+ * exclude the last element from the count.
+ */
+static const u_int num_phases = NUM_ELEMENTS(ahd_phase_table) - 1;
+
+/* Our Sequencer Program */
+#include "aic79xx_seq.h"
+
+/**************************** Function Declarations ***************************/
+static void		ahd_handle_transmission_error(struct ahd_softc *ahd);
+static void		ahd_handle_lqiphase_error(struct ahd_softc *ahd,
+						  u_int lqistat1);
+static int		ahd_handle_pkt_busfree(struct ahd_softc *ahd,
+					       u_int busfreetime);
+static int		ahd_handle_nonpkt_busfree(struct ahd_softc *ahd);
+static void		ahd_handle_proto_violation(struct ahd_softc *ahd);
+static void		ahd_force_renegotiation(struct ahd_softc *ahd,
+						struct ahd_devinfo *devinfo);
+
+static struct ahd_tmode_tstate*
+			ahd_alloc_tstate(struct ahd_softc *ahd,
+					 u_int scsi_id, char channel);
+#ifdef AHD_TARGET_MODE
+static void		ahd_free_tstate(struct ahd_softc *ahd,
+					u_int scsi_id, char channel, int force);
+#endif
+static void		ahd_devlimited_syncrate(struct ahd_softc *ahd,
+					        struct ahd_initiator_tinfo *,
+						u_int *period,
+						u_int *ppr_options,
+						role_t role);
+static void		ahd_update_neg_table(struct ahd_softc *ahd,
+					     struct ahd_devinfo *devinfo,
+					     struct ahd_transinfo *tinfo);
+static void		ahd_update_pending_scbs(struct ahd_softc *ahd);
+static void		ahd_fetch_devinfo(struct ahd_softc *ahd,
+					  struct ahd_devinfo *devinfo);
+static void		ahd_scb_devinfo(struct ahd_softc *ahd,
+					struct ahd_devinfo *devinfo,
+					struct scb *scb);
+static void		ahd_setup_initiator_msgout(struct ahd_softc *ahd,
+						   struct ahd_devinfo *devinfo,
+						   struct scb *scb);
+static void		ahd_build_transfer_msg(struct ahd_softc *ahd,
+					       struct ahd_devinfo *devinfo);
+static void		ahd_construct_sdtr(struct ahd_softc *ahd,
+					   struct ahd_devinfo *devinfo,
+					   u_int period, u_int offset);
+static void		ahd_construct_wdtr(struct ahd_softc *ahd,
+					   struct ahd_devinfo *devinfo,
+					   u_int bus_width);
+static void		ahd_construct_ppr(struct ahd_softc *ahd,
+					  struct ahd_devinfo *devinfo,
+					  u_int period, u_int offset,
+					  u_int bus_width, u_int ppr_options);
+static void		ahd_clear_msg_state(struct ahd_softc *ahd);
+static void		ahd_handle_message_phase(struct ahd_softc *ahd);
+typedef enum {
+	AHDMSG_1B,
+	AHDMSG_2B,
+	AHDMSG_EXT
+} ahd_msgtype;
+static int		ahd_sent_msg(struct ahd_softc *ahd, ahd_msgtype type,
+				     u_int msgval, int full);
+static int		ahd_parse_msg(struct ahd_softc *ahd,
+				      struct ahd_devinfo *devinfo);
+static int		ahd_handle_msg_reject(struct ahd_softc *ahd,
+					      struct ahd_devinfo *devinfo);
+static void		ahd_handle_ign_wide_residue(struct ahd_softc *ahd,
+						struct ahd_devinfo *devinfo);
+static void		ahd_reinitialize_dataptrs(struct ahd_softc *ahd);
+static void		ahd_handle_devreset(struct ahd_softc *ahd,
+					    struct ahd_devinfo *devinfo,
+					    u_int lun, cam_status status,
+					    char *message, int verbose_level);
+#if AHD_TARGET_MODE
+static void		ahd_setup_target_msgin(struct ahd_softc *ahd,
+					       struct ahd_devinfo *devinfo,
+					       struct scb *scb);
+#endif
+
+static u_int		ahd_sglist_size(struct ahd_softc *ahd);
+static u_int		ahd_sglist_allocsize(struct ahd_softc *ahd);
+static bus_dmamap_callback_t
+			ahd_dmamap_cb; 
+static void		ahd_initialize_hscbs(struct ahd_softc *ahd);
+static int		ahd_init_scbdata(struct ahd_softc *ahd);
+static void		ahd_fini_scbdata(struct ahd_softc *ahd);
+static void		ahd_setup_iocell_workaround(struct ahd_softc *ahd);
+static void		ahd_iocell_first_selection(struct ahd_softc *ahd);
+static void		ahd_add_col_list(struct ahd_softc *ahd,
+					 struct scb *scb, u_int col_idx);
+static void		ahd_rem_col_list(struct ahd_softc *ahd,
+					 struct scb *scb);
+static void		ahd_chip_init(struct ahd_softc *ahd);
+static void		ahd_qinfifo_requeue(struct ahd_softc *ahd,
+					    struct scb *prev_scb,
+					    struct scb *scb);
+static int		ahd_qinfifo_count(struct ahd_softc *ahd);
+static int		ahd_search_scb_list(struct ahd_softc *ahd, int target,
+					    char channel, int lun, u_int tag,
+					    role_t role, uint32_t status,
+					    ahd_search_action action,
+					    u_int *list_head, u_int tid);
+static void		ahd_stitch_tid_list(struct ahd_softc *ahd,
+					    u_int tid_prev, u_int tid_cur,
+					    u_int tid_next);
+static void		ahd_add_scb_to_free_list(struct ahd_softc *ahd,
+						 u_int scbid);
+static u_int		ahd_rem_wscb(struct ahd_softc *ahd, u_int scbid,
+				     u_int prev, u_int next, u_int tid);
+static void		ahd_reset_current_bus(struct ahd_softc *ahd);
+static ahd_callback_t	ahd_reset_poll;
+static ahd_callback_t	ahd_stat_timer;
+#ifdef AHD_DUMP_SEQ
+static void		ahd_dumpseq(struct ahd_softc *ahd);
+#endif
+static void		ahd_loadseq(struct ahd_softc *ahd);
+static int		ahd_check_patch(struct ahd_softc *ahd,
+					struct patch **start_patch,
+					u_int start_instr, u_int *skip_addr);
+static u_int		ahd_resolve_seqaddr(struct ahd_softc *ahd,
+					    u_int address);
+static void		ahd_download_instr(struct ahd_softc *ahd,
+					   u_int instrptr, uint8_t *dconsts);
+static int		ahd_probe_stack_size(struct ahd_softc *ahd);
+#ifdef AHD_TARGET_MODE
+static void		ahd_queue_lstate_event(struct ahd_softc *ahd,
+					       struct ahd_tmode_lstate *lstate,
+					       u_int initiator_id,
+					       u_int event_type,
+					       u_int event_arg);
+static void		ahd_update_scsiid(struct ahd_softc *ahd,
+					  u_int targid_mask);
+static int		ahd_handle_target_cmd(struct ahd_softc *ahd,
+					      struct target_cmd *cmd);
+#endif
+
+/******************************** Private Inlines *****************************/
+static __inline void	ahd_assert_atn(struct ahd_softc *ahd);
+static __inline int	ahd_currently_packetized(struct ahd_softc *ahd);
+static __inline int	ahd_set_active_fifo(struct ahd_softc *ahd);
+
+static __inline void
+ahd_assert_atn(struct ahd_softc *ahd)
+{
+	ahd_outb(ahd, SCSISIGO, ATNO);
+}
+
+/*
+ * Determine if the current connection has a packetized
+ * agreement.  This does not necessarily mean that we
+ * are currently in a packetized transfer.  We could
+ * just as easily be sending or receiving a message.
+ */
+static __inline int
+ahd_currently_packetized(struct ahd_softc *ahd)
+{
+	ahd_mode_state	 saved_modes;
+	int		 packetized;
+
+	saved_modes = ahd_save_modes(ahd);
+	if ((ahd->bugs & AHD_PKTIZED_STATUS_BUG) != 0) {
+		/*
+		 * The packetized bit refers to the last
+		 * connection, not the current one.  Check
+		 * for non-zero LQISTATE instead.
+		 */
+		ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
+		packetized = ahd_inb(ahd, LQISTATE) != 0;
+	} else {
+		ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+		packetized = ahd_inb(ahd, LQISTAT2) & PACKETIZED;
+	}
+	ahd_restore_modes(ahd, saved_modes);
+	return (packetized);
+}
+
+static __inline int
+ahd_set_active_fifo(struct ahd_softc *ahd)
+{
+	u_int active_fifo;
+
+	AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
+	active_fifo = ahd_inb(ahd, DFFSTAT) & CURRFIFO;
+	switch (active_fifo) {
+	case 0:
+	case 1:
+		ahd_set_modes(ahd, active_fifo, active_fifo);
+		return (1);
+	default:
+		return (0);
+	}
+}
+
+/************************* Sequencer Execution Control ************************/
+/*
+ * Restart the sequencer program from address zero
+ */
+void
+ahd_restart(struct ahd_softc *ahd)
+{
+
+	ahd_pause(ahd);
+
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+
+	/* No more pending messages */
+	ahd_clear_msg_state(ahd);
+	ahd_outb(ahd, SCSISIGO, 0);		/* De-assert BSY */
+	ahd_outb(ahd, MSG_OUT, MSG_NOOP);	/* No message to send */
+	ahd_outb(ahd, SXFRCTL1, ahd_inb(ahd, SXFRCTL1) & ~BITBUCKET);
+	ahd_outb(ahd, SEQINTCTL, 0);
+	ahd_outb(ahd, LASTPHASE, P_BUSFREE);
+	ahd_outb(ahd, SEQ_FLAGS, 0);
+	ahd_outb(ahd, SAVED_SCSIID, 0xFF);
+	ahd_outb(ahd, SAVED_LUN, 0xFF);
+
+	/*
+	 * Ensure that the sequencer's idea of TQINPOS
+	 * matches our own.  The sequencer increments TQINPOS
+	 * only after it sees a DMA complete and a reset could
+	 * occur before the increment leaving the kernel to believe
+	 * the command arrived but the sequencer to not.
+	 */
+	ahd_outb(ahd, TQINPOS, ahd->tqinfifonext);
+
+	/* Always allow reselection */
+	ahd_outb(ahd, SCSISEQ1,
+		 ahd_inb(ahd, SCSISEQ_TEMPLATE) & (ENSELI|ENRSELI|ENAUTOATNP));
+	/* Ensure that no DMA operations are in progress */
+	ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
+	ahd_outb(ahd, SCBHCNT, 0);
+	ahd_outb(ahd, CCSCBCTL, CCSCBRESET);
+	ahd_outb(ahd, SEQCTL0, FASTMODE|SEQRESET);
+	ahd_unpause(ahd);
+}
+
+void
+ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo)
+{
+	ahd_mode_state	 saved_modes;
+
+#ifdef AHD_DEBUG
+	if ((ahd_debug & AHD_SHOW_FIFOS) != 0)
+		printf("%s: Clearing FIFO %d\n", ahd_name(ahd), fifo);
+#endif
+	saved_modes = ahd_save_modes(ahd);
+	ahd_set_modes(ahd, fifo, fifo);
+	ahd_outb(ahd, DFFSXFRCTL, RSTCHN|CLRSHCNT);
+	if ((ahd_inb(ahd, SG_STATE) & FETCH_INPROG) != 0)
+		ahd_outb(ahd, CCSGCTL, CCSGRESET);
+	ahd_outb(ahd, LONGJMP_ADDR + 1, INVALID_ADDR);
+	ahd_outb(ahd, SG_STATE, 0);
+	ahd_restore_modes(ahd, saved_modes);
+}
+
+/************************* Input/Output Queues ********************************/
+/*
+ * Flush and completed commands that are sitting in the command
+ * complete queues down on the chip but have yet to be dma'ed back up.
+ */
+void
+ahd_flush_qoutfifo(struct ahd_softc *ahd)
+{
+	struct		scb *scb;
+	ahd_mode_state	saved_modes;
+	u_int		saved_scbptr;
+	u_int		ccscbctl;
+	u_int		scbid;
+	u_int		next_scbid;
+
+	saved_modes = ahd_save_modes(ahd);
+	ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
+	saved_scbptr = ahd_get_scbptr(ahd);
+
+	/*
+	 * Wait for any inprogress DMA to complete and clear DMA state
+	 * if this if for an SCB in the qinfifo.
+	 */
+	while ((ccscbctl = ahd_inb(ahd, CCSCBCTL) & (CCARREN|CCSCBEN)) != 0) {
+
+		if ((ccscbctl & (CCSCBDIR|CCARREN)) == (CCSCBDIR|CCARREN)) {
+			if ((ccscbctl & ARRDONE) != 0)
+				break;
+		} else if ((ccscbctl & CCSCBDONE) != 0)
+			break;
+		ahd_delay(200);
+	}
+	if ((ccscbctl & CCSCBDIR) != 0)
+		ahd_outb(ahd, CCSCBCTL, ccscbctl & ~(CCARREN|CCSCBEN));
+
+	/*
+	 * Complete any SCBs that just finished being
+	 * DMA'ed into the qoutfifo.
+	 */
+	ahd_run_qoutfifo(ahd);
+
+	/*
+	 * Manually update/complete any completed SCBs that are waiting to be
+	 * DMA'ed back up to the host.
+	 */
+	scbid = ahd_inw(ahd, COMPLETE_DMA_SCB_HEAD);
+	while (!SCBID_IS_NULL(scbid)) {
+		uint8_t *hscb_ptr;
+		u_int	 i;
+		
+		ahd_set_scbptr(ahd, scbid);
+		next_scbid = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
+		scb = ahd_lookup_scb(ahd, scbid);
+		if (scb == NULL) {
+			printf("%s: Warning - DMA-up and complete "
+			       "SCB %d invalid\n", ahd_name(ahd), scbid);
+			continue;
+		}
+		hscb_ptr = (uint8_t *)scb->hscb;
+		for (i = 0; i < sizeof(struct hardware_scb); i++)
+			*hscb_ptr++ = ahd_inb_scbram(ahd, SCB_BASE + i);
+
+		ahd_complete_scb(ahd, scb);
+		scbid = next_scbid;
+	}
+	ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, SCB_LIST_NULL);
+
+	scbid = ahd_inw(ahd, COMPLETE_SCB_HEAD);
+	while (!SCBID_IS_NULL(scbid)) {
+
+		ahd_set_scbptr(ahd, scbid);
+		next_scbid = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
+		scb = ahd_lookup_scb(ahd, scbid);
+		if (scb == NULL) {
+			printf("%s: Warning - Complete SCB %d invalid\n",
+			       ahd_name(ahd), scbid);
+			continue;
+		}
+
+		ahd_complete_scb(ahd, scb);
+		scbid = next_scbid;
+	}
+	ahd_outw(ahd, COMPLETE_SCB_HEAD, SCB_LIST_NULL);
+	ahd_set_scbptr(ahd, saved_scbptr);
+
+	/*
+	 * Flush the good status FIFO for compelted packetized commands.
+	 */
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+	while ((ahd_inb(ahd, LQISTAT2) & LQIGSAVAIL) != 0) {
+		scbid = (ahd_inb(ahd, GSFIFO+1) << 8)
+		      | ahd_inb(ahd, GSFIFO);
+		scb = ahd_lookup_scb(ahd, scbid);
+		if (scb == NULL) {
+			printf("%s: Warning - GSFIFO SCB %d invalid\n",
+			       ahd_name(ahd), scbid);
+			continue;
+		}
+		ahd_complete_scb(ahd, scb);
+	}
+
+	/*
+	 * Restore state.
+	 */
+	ahd_restore_modes(ahd, saved_modes);
+	ahd->flags |= AHD_UPDATE_PEND_CMDS;
+}
+
+void
+ahd_run_qoutfifo(struct ahd_softc *ahd)
+{
+	struct scb *scb;
+	u_int  scb_index;
+
+	if ((ahd->flags & AHD_RUNNING_QOUTFIFO) != 0)
+		panic("ahd_run_qoutfifo recursion");
+	ahd->flags |= AHD_RUNNING_QOUTFIFO;
+	ahd_sync_qoutfifo(ahd, BUS_DMASYNC_POSTREAD);
+	while ((ahd->qoutfifo[ahd->qoutfifonext]
+	     & QOUTFIFO_ENTRY_VALID_LE) == ahd->qoutfifonext_valid_tag) {
+
+		scb_index = ahd_le16toh(ahd->qoutfifo[ahd->qoutfifonext]
+				      & ~QOUTFIFO_ENTRY_VALID_LE);
+		scb = ahd_lookup_scb(ahd, scb_index);
+		if (scb == NULL) {
+			printf("%s: WARNING no command for scb %d "
+			       "(cmdcmplt)\nQOUTPOS = %d\n",
+			       ahd_name(ahd), scb_index,
+			       ahd->qoutfifonext);
+			ahd_dump_card_state(ahd);
+		} else
+			ahd_complete_scb(ahd, scb);
+
+		ahd->qoutfifonext = (ahd->qoutfifonext+1) & (AHD_QOUT_SIZE-1);
+		if (ahd->qoutfifonext == 0)
+			ahd->qoutfifonext_valid_tag ^= QOUTFIFO_ENTRY_VALID_LE;
+	}
+	ahd->flags &= ~AHD_RUNNING_QOUTFIFO;
+}
+
+/************************* Interrupt Handling *********************************/
+void
+ahd_handle_hwerrint(struct ahd_softc *ahd)
+{
+	/*
+	 * Some catastrophic hardware error has occurred.
+	 * Print it for the user and disable the controller.
+	 */
+	int i;
+	int error;
+
+	error = ahd_inb(ahd, ERROR);
+	for (i = 0; i < num_errors; i++) {
+		if ((error & ahd_hard_errors[i].errno) != 0)
+			printf("%s: hwerrint, %s\n",
+			       ahd_name(ahd), ahd_hard_errors[i].errmesg);
+	}
+
+	ahd_dump_card_state(ahd);
+	panic("BRKADRINT");
+
+	/* Tell everyone that this HBA is no longer available */
+	ahd_abort_scbs(ahd, CAM_TARGET_WILDCARD, ALL_CHANNELS,
+		       CAM_LUN_WILDCARD, SCB_LIST_NULL, ROLE_UNKNOWN,
+		       CAM_NO_HBA);
+
+	/* Tell the system that this controller has gone away. */
+	ahd_free(ahd);
+}
+
+void
+ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
+{
+	u_int seqintcode;
+
+	/*
+	 * Save the sequencer interrupt code and clear the SEQINT
+	 * bit. We will unpause the sequencer, if appropriate,
+	 * after servicing the request.
+	 */
+	seqintcode = ahd_inb(ahd, SEQINTCODE);
+	ahd_outb(ahd, CLRINT, CLRSEQINT);
+	if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) {
+		/*
+		 * Unpause the sequencer and let it clear
+		 * SEQINT by writing NO_SEQINT to it.  This
+		 * will cause the sequencer to be paused again,
+		 * which is the expected state of this routine.
+		 */
+		ahd_unpause(ahd);
+		while (!ahd_is_paused(ahd))
+			;
+		ahd_outb(ahd, CLRINT, CLRSEQINT);
+	}
+	ahd_update_modes(ahd);
+#ifdef AHD_DEBUG
+	if ((ahd_debug & AHD_SHOW_MISC) != 0)
+		printf("%s: Handle Seqint Called for code %d\n",
+		       ahd_name(ahd), seqintcode);
+#endif
+	switch (seqintcode) {
+	case BAD_SCB_STATUS:
+	{
+		struct	scb *scb;
+		u_int	scbid;
+		int	cmds_pending;
+
+		scbid = ahd_get_scbptr(ahd);
+		scb = ahd_lookup_scb(ahd, scbid);
+		if (scb != NULL) {
+			ahd_complete_scb(ahd, scb);
+		} else {
+			printf("%s: WARNING no command for scb %d "
+			       "(bad status)\n", ahd_name(ahd), scbid);
+			ahd_dump_card_state(ahd);
+		}
+		cmds_pending = ahd_inw(ahd, CMDS_PENDING);
+		if (cmds_pending > 0)
+			ahd_outw(ahd, CMDS_PENDING, cmds_pending - 1);
+		break;
+	}
+	case ENTERING_NONPACK:
+	{
+		struct	scb *scb;
+		u_int	scbid;
+
+		AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
+				 ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
+		scbid = ahd_get_scbptr(ahd);
+		scb = ahd_lookup_scb(ahd, scbid);
+		if (scb == NULL) {
+			/*
+			 * Somehow need to know if this
+			 * is from a selection or reselection.
+			 * From that, we can termine target
+			 * ID so we at least have an I_T nexus.
+			 */
+		} else {
+			ahd_outb(ahd, SAVED_SCSIID, scb->hscb->scsiid);
+			ahd_outb(ahd, SAVED_LUN, scb->hscb->lun);
+			ahd_outb(ahd, SEQ_FLAGS, 0x0);
+		}
+		if ((ahd_inb(ahd, LQISTAT2) & LQIPHASE_OUTPKT) != 0
+		 && (ahd_inb(ahd, SCSISIGO) & ATNO) != 0) {
+			/*
+			 * Phase change after read stream with
+			 * CRC error with P0 asserted on last
+			 * packet.
+			 */
+#ifdef AHD_DEBUG
+			if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)
+				printf("%s: Assuming LQIPHASE_NLQ with "
+				       "P0 assertion\n", ahd_name(ahd));
+#endif
+		}
+#ifdef AHD_DEBUG
+		if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)
+			printf("%s: Entering NONPACK\n", ahd_name(ahd));
+#endif
+		break;
+	}
+	case INVALID_SEQINT:
+		printf("%s: Invalid Sequencer interrupt occurred.\n",
+		       ahd_name(ahd));
+		ahd_dump_card_state(ahd);
+		ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
+		break;
+	case STATUS_OVERRUN:
+	{
+		struct	scb *scb;
+		u_int	scbid;
+
+		scbid = ahd_get_scbptr(ahd);
+		scb = ahd_lookup_scb(ahd, scbid);
+		if (scb != NULL)
+			ahd_print_path(ahd, scb);
+		else
+			printf("%s: ", ahd_name(ahd));
+		printf("SCB %d Packetized Status Overrun", scbid);
+		ahd_dump_card_state(ahd);
+		ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
+		break;
+	}
+	case CFG4ISTAT_INTR:
+	{
+		struct	scb *scb;
+		u_int	scbid;
+
+		scbid = ahd_get_scbptr(ahd);
+		scb = ahd_lookup_scb(ahd, scbid);
+		if (scb == NULL) {
+			ahd_dump_card_state(ahd);
+			printf("CFG4ISTAT: Free SCB %d referenced", scbid);
+			panic("For safety");
+		}
+		ahd_outq(ahd, HADDR, scb->sense_busaddr);
+		ahd_outw(ahd, HCNT, AHD_SENSE_BUFSIZE);
+		ahd_outb(ahd, HCNT + 2, 0);
+		ahd_outb(ahd, SG_CACHE_PRE, SG_LAST_SEG);
+		ahd_outb(ahd, DFCNTRL, PRELOADEN|SCSIEN|HDMAEN);
+		break;
+	}
+	case ILLEGAL_PHASE:
+	{
+		u_int bus_phase;
+
+		bus_phase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK;
+		printf("%s: ILLEGAL_PHASE 0x%x\n",
+		       ahd_name(ahd), bus_phase);
+
+		switch (bus_phase) {
+		case P_DATAOUT:
+		case P_DATAIN:
+		case P_DATAOUT_DT:
+		case P_DATAIN_DT:
+		case P_MESGOUT:
+		case P_STATUS:
+		case P_MESGIN:
+			ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
+			printf("%s: Issued Bus Reset.\n", ahd_name(ahd));
+			break;
+		case P_COMMAND:
+		{
+			struct	ahd_devinfo devinfo;
+			struct	scb *scb;
+			struct	ahd_initiator_tinfo *targ_info;
+			struct	ahd_tmode_tstate *tstate;
+			struct	ahd_transinfo *tinfo;
+			u_int	scbid;
+
+			/*
+			 * If a target takes us into the command phase
+			 * assume that it has been externally reset and
+			 * has thus lost our previous packetized negotiation
+			 * agreement.  Since we have not sent an identify
+			 * message and may not have fully qualified the
+			 * connection, we change our command to TUR, assert
+			 * ATN and ABORT the task when we go to message in
+			 * phase.  The OSM will see the REQUEUE_REQUEST
+			 * status and retry the command.
+			 */
+			scbid = ahd_get_scbptr(ahd);
+			scb = ahd_lookup_scb(ahd, scbid);
+			if (scb == NULL) {
+				printf("Invalid phase with no valid SCB.  "
+				       "Resetting bus.\n");
+				ahd_reset_channel(ahd, 'A',
+						  /*Initiate Reset*/TRUE);
+				break;
+			}
+			ahd_compile_devinfo(&devinfo, SCB_GET_OUR_ID(scb),
+					    SCB_GET_TARGET(ahd, scb),
+					    SCB_GET_LUN(scb),
+					    SCB_GET_CHANNEL(ahd, scb),
+					    ROLE_INITIATOR);
+			targ_info = ahd_fetch_transinfo(ahd,
+							devinfo.channel,
+							devinfo.our_scsiid,
+							devinfo.target,
+							&tstate);
+			tinfo = &targ_info->curr;
+			ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
+				      AHD_TRANS_ACTIVE, /*paused*/TRUE);
+			ahd_set_syncrate(ahd, &devinfo, /*period*/0,
+					 /*offset*/0, /*ppr_options*/0,
+					 AHD_TRANS_ACTIVE, /*paused*/TRUE);
+			ahd_outb(ahd, SCB_CDB_STORE, 0);
+			ahd_outb(ahd, SCB_CDB_STORE+1, 0);
+			ahd_outb(ahd, SCB_CDB_STORE+2, 0);
+			ahd_outb(ahd, SCB_CDB_STORE+3, 0);
+			ahd_outb(ahd, SCB_CDB_STORE+4, 0);
+			ahd_outb(ahd, SCB_CDB_STORE+5, 0);
+			ahd_outb(ahd, SCB_CDB_LEN, 6);
+			scb->hscb->control &= ~(TAG_ENB|SCB_TAG_TYPE);
+			scb->hscb->control |= MK_MESSAGE;
+			ahd_outb(ahd, SCB_CONTROL, scb->hscb->control);
+			ahd_outb(ahd, MSG_OUT, HOST_MSG);
+			ahd_outb(ahd, SAVED_SCSIID, scb->hscb->scsiid);
+			/*
+			 * The lun is 0, regardless of the SCB's lun
+			 * as we have not sent an identify message.
+			 */
+			ahd_outb(ahd, SAVED_LUN, 0);
+			ahd_outb(ahd, SEQ_FLAGS, 0);
+			ahd_assert_atn(ahd);
+			scb->flags &= ~(SCB_PACKETIZED);
+			scb->flags |= SCB_ABORT|SCB_CMDPHASE_ABORT;
+			ahd_freeze_devq(ahd, scb);
+			ahd_set_transaction_status(scb, CAM_REQUEUE_REQ);
+			ahd_freeze_scb(scb);
+
+			/*
+			 * Allow the sequencer to continue with
+			 * non-pack processing.
+			 */
+			ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+			ahd_outb(ahd, CLRLQOINT1, CLRLQOPHACHGINPKT);
+			if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0) {
+				ahd_outb(ahd, CLRLQOINT1, 0);
+			}
+#ifdef AHD_DEBUG
+			if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
+				ahd_print_path(ahd, scb);
+				printf("Unexpected command phase from "
+				       "packetized target\n");
+			}
+#endif
+			break;
+		}
+		}
+		break;
+	}
+	case CFG4OVERRUN:
+	{
+		struct	scb *scb;
+		u_int	scb_index;
+		
+#ifdef AHD_DEBUG
+		if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
+			printf("%s: CFG4OVERRUN mode = %x\n", ahd_name(ahd),
+			       ahd_inb(ahd, MODE_PTR));
+		}
+#endif
+		scb_index = ahd_get_scbptr(ahd);
+		scb = ahd_lookup_scb(ahd, scb_index);
+		if (scb == NULL) {
+			/*
+			 * Attempt to transfer to an SCB that is
+			 * not outstanding.
+			 */
+			ahd_assert_atn(ahd);
+			ahd_outb(ahd, MSG_OUT, HOST_MSG);
+			ahd->msgout_buf[0] = MSG_ABORT_TASK;
+			ahd->msgout_len = 1;
+			ahd->msgout_index = 0;
+			ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
+			/*
+			 * Clear status received flag to prevent any
+			 * attempt to complete this bogus SCB.
+			 */
+			ahd_outb(ahd, SCB_CONTROL,
+				 ahd_inb(ahd, SCB_CONTROL) & ~STATUS_RCVD);
+		}
+		break;
+	}
+	case DUMP_CARD_STATE:
+	{
+		ahd_dump_card_state(ahd);
+		break;
+	}
+	case PDATA_REINIT:
+	{
+#ifdef AHD_DEBUG
+		if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
+			printf("%s: PDATA_REINIT - DFCNTRL = 0x%x "
+			       "SG_CACHE_SHADOW = 0x%x\n",
+			       ahd_name(ahd), ahd_inb(ahd, DFCNTRL),
+			       ahd_inb(ahd, SG_CACHE_SHADOW));
+		}
+#endif
+		ahd_reinitialize_dataptrs(ahd);
+		break;
+	}
+	case HOST_MSG_LOOP:
+	{
+		struct ahd_devinfo devinfo;
+
+		/*
+		 * The sequencer has encountered a message phase
+		 * that requires host assistance for completion.
+		 * While handling the message phase(s), we will be
+		 * notified by the sequencer after each byte is
+		 * transfered so we can track bus phase changes.
+		 *
+		 * If this is the first time we've seen a HOST_MSG_LOOP
+		 * interrupt, initialize the state of the host message
+		 * loop.
+		 */
+		ahd_fetch_devinfo(ahd, &devinfo);
+		if (ahd->msg_type == MSG_TYPE_NONE) {
+			struct scb *scb;
+			u_int scb_index;
+			u_int bus_phase;
+
+			bus_phase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK;
+			if (bus_phase != P_MESGIN
+			 && bus_phase != P_MESGOUT) {
+				printf("ahd_intr: HOST_MSG_LOOP bad "
+				       "phase 0x%x\n", bus_phase);
+				/*
+				 * Probably transitioned to bus free before
+				 * we got here.  Just punt the message.
+				 */
+				ahd_dump_card_state(ahd);
+				ahd_clear_intstat(ahd);
+				ahd_restart(ahd);
+				return;
+			}
+
+			scb_index = ahd_get_scbptr(ahd);
+			scb = ahd_lookup_scb(ahd, scb_index);
+			if (devinfo.role == ROLE_INITIATOR) {
+				if (bus_phase == P_MESGOUT)
+					ahd_setup_initiator_msgout(ahd,
+								   &devinfo,
+								   scb);
+				else {
+					ahd->msg_type =
+					    MSG_TYPE_INITIATOR_MSGIN;
+					ahd->msgin_index = 0;
+				}
+			}
+#if AHD_TARGET_MODE
+			else {
+				if (bus_phase == P_MESGOUT) {
+					ahd->msg_type =
+					    MSG_TYPE_TARGET_MSGOUT;
+					ahd->msgin_index = 0;
+				}
+				else 
+					ahd_setup_target_msgin(ahd,
+							       &devinfo,
+							       scb);
+			}
+#endif
+		}
+
+		ahd_handle_message_phase(ahd);
+		break;
+	}
+	case NO_MATCH:
+	{
+		/* Ensure we don't leave the selection hardware on */
+		AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
+		ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
+
+		printf("%s:%c:%d: no active SCB for reconnecting "
+		       "target - issuing BUS DEVICE RESET\n",
+		       ahd_name(ahd), 'A', ahd_inb(ahd, SELID) >> 4);
+		printf("SAVED_SCSIID == 0x%x, SAVED_LUN == 0x%x, "
+		       "REG0 == 0x%x ACCUM = 0x%x\n",
+		       ahd_inb(ahd, SAVED_SCSIID), ahd_inb(ahd, SAVED_LUN),
+		       ahd_inw(ahd, REG0), ahd_inb(ahd, ACCUM));
+		printf("SEQ_FLAGS == 0x%x, SCBPTR == 0x%x, BTT == 0x%x, "
+		       "SINDEX == 0x%x\n",
+		       ahd_inb(ahd, SEQ_FLAGS), ahd_get_scbptr(ahd),
+		       ahd_find_busy_tcl(ahd,
+					 BUILD_TCL(ahd_inb(ahd, SAVED_SCSIID),
+						   ahd_inb(ahd, SAVED_LUN))),
+		       ahd_inw(ahd, SINDEX));
+		printf("SELID == 0x%x, SCB_SCSIID == 0x%x, SCB_LUN == 0x%x, "
+		       "SCB_CONTROL == 0x%x\n",
+		       ahd_inb(ahd, SELID), ahd_inb_scbram(ahd, SCB_SCSIID),
+		       ahd_inb_scbram(ahd, SCB_LUN),
+		       ahd_inb_scbram(ahd, SCB_CONTROL));
+		printf("SCSIBUS[0] == 0x%x, SCSISIGI == 0x%x\n",
+		       ahd_inb(ahd, SCSIBUS), ahd_inb(ahd, SCSISIGI));
+		printf("SXFRCTL0 == 0x%x\n", ahd_inb(ahd, SXFRCTL0));
+		printf("SEQCTL0 == 0x%x\n", ahd_inb(ahd, SEQCTL0));
+		ahd_dump_card_state(ahd);
+		ahd->msgout_buf[0] = MSG_BUS_DEV_RESET;
+		ahd->msgout_len = 1;
+		ahd->msgout_index = 0;
+		ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
+		ahd_outb(ahd, MSG_OUT, HOST_MSG);
+		ahd_assert_atn(ahd);
+		break;
+	}
+	case PROTO_VIOLATION:
+	{
+		ahd_handle_proto_violation(ahd);
+		break;
+	}
+	case IGN_WIDE_RES:
+	{
+		struct ahd_devinfo devinfo;
+
+		ahd_fetch_devinfo(ahd, &devinfo);
+		ahd_handle_ign_wide_residue(ahd, &devinfo);
+		break;
+	}
+	case BAD_PHASE:
+	{
+		u_int lastphase;
+
+		lastphase = ahd_inb(ahd, LASTPHASE);
+		printf("%s:%c:%d: unknown scsi bus phase %x, "
+		       "lastphase = 0x%x.  Attempting to continue\n",
+		       ahd_name(ahd), 'A',
+		       SCSIID_TARGET(ahd, ahd_inb(ahd, SAVED_SCSIID)),
+		       lastphase, ahd_inb(ahd, SCSISIGI));
+		break;
+	}
+	case MISSED_BUSFREE:
+	{
+		u_int lastphase;
+
+		lastphase = ahd_inb(ahd, LASTPHASE);
+		printf("%s:%c:%d: Missed busfree. "
+		       "Lastphase = 0x%x, Curphase = 0x%x\n",
+		       ahd_name(ahd), 'A',
+		       SCSIID_TARGET(ahd, ahd_inb(ahd, SAVED_SCSIID)),
+		       lastphase, ahd_inb(ahd, SCSISIGI));
+		ahd_restart(ahd);
+		return;
+	}
+	case DATA_OVERRUN:
+	{
+		/*
+		 * When the sequencer detects an overrun, it
+		 * places the controller in "BITBUCKET" mode
+		 * and allows the target to complete its transfer.
+		 * Unfortunately, none of the counters get updated
+		 * when the controller is in this mode, so we have
+		 * no way of knowing how large the overrun was.
+		 */
+		struct	scb *scb;
+		u_int	scbindex;
+#ifdef AHD_DEBUG
+		u_int	lastphase;
+#endif
+
+		scbindex = ahd_get_scbptr(ahd);
+		scb = ahd_lookup_scb(ahd, scbindex);
+#ifdef AHD_DEBUG
+		lastphase = ahd_inb(ahd, LASTPHASE);
+		if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
+			ahd_print_path(ahd, scb);
+			printf("data overrun detected %s.  Tag == 0x%x.\n",
+			       ahd_lookup_phase_entry(lastphase)->phasemsg,
+			       SCB_GET_TAG(scb));
+			ahd_print_path(ahd, scb);
+			printf("%s seen Data Phase.  Length = %ld.  "
+			       "NumSGs = %d.\n",
+			       ahd_inb(ahd, SEQ_FLAGS) & DPHASE
+			       ? "Have" : "Haven't",
+			       ahd_get_transfer_length(scb), scb->sg_count);
+			ahd_dump_sglist(scb);
+		}
+#endif
+
+		/*
+		 * Set this and it will take effect when the
+		 * target does a command complete.
+		 */
+		ahd_freeze_devq(ahd, scb);
+		ahd_set_transaction_status(scb, CAM_DATA_RUN_ERR);
+		ahd_freeze_scb(scb);
+		break;
+	}
+	case MKMSG_FAILED:
+	{
+		struct ahd_devinfo devinfo;
+		struct scb *scb;
+		u_int scbid;
+
+		ahd_fetch_devinfo(ahd, &devinfo);
+		printf("%s:%c:%d:%d: Attempt to issue message failed\n",
+		       ahd_name(ahd), devinfo.channel, devinfo.target,
+		       devinfo.lun);
+		scbid = ahd_get_scbptr(ahd);
+		scb = ahd_lookup_scb(ahd, scbid);
+		if (scb != NULL
+		 && (scb->flags & SCB_RECOVERY_SCB) != 0)
+			/*
+			 * Ensure that we didn't put a second instance of this
+			 * SCB into the QINFIFO.
+			 */
+			ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb),
+					   SCB_GET_CHANNEL(ahd, scb),
+					   SCB_GET_LUN(scb), SCB_GET_TAG(scb),
+					   ROLE_INITIATOR, /*status*/0,
+					   SEARCH_REMOVE);
+		ahd_outb(ahd, SCB_CONTROL,
+			 ahd_inb(ahd, SCB_CONTROL) & ~MK_MESSAGE);
+		break;
+	}
+	case TASKMGMT_FUNC_COMPLETE:
+	{
+		u_int	scbid;
+		struct	scb *scb;
+
+		scbid = ahd_get_scbptr(ahd);
+		scb = ahd_lookup_scb(ahd, scbid);
+		if (scb != NULL) {
+			u_int	   lun;
+			u_int	   tag;
+			cam_status error;
+
+			ahd_print_path(ahd, scb);
+			printf("Task Management Func 0x%x Complete\n",
+			       scb->hscb->task_management);
+			lun = CAM_LUN_WILDCARD;
+			tag = SCB_LIST_NULL;
+
+			switch (scb->hscb->task_management) {
+			case SIU_TASKMGMT_ABORT_TASK:
+				tag = SCB_GET_TAG(scb);
+			case SIU_TASKMGMT_ABORT_TASK_SET:
+			case SIU_TASKMGMT_CLEAR_TASK_SET:
+				lun = scb->hscb->lun;
+				error = CAM_REQ_ABORTED;
+				ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb),
+					       'A', lun, tag, ROLE_INITIATOR,
+					       error);
+				break;
+			case SIU_TASKMGMT_LUN_RESET:
+				lun = scb->hscb->lun;
+			case SIU_TASKMGMT_TARGET_RESET:
+			{
+				struct ahd_devinfo devinfo;
+
+				ahd_scb_devinfo(ahd, &devinfo, scb);
+				error = CAM_BDR_SENT;
+				ahd_handle_devreset(ahd, &devinfo, lun,
+						    CAM_BDR_SENT,
+						    lun != CAM_LUN_WILDCARD
+						    ? "Lun Reset"
+						    : "Target Reset",
+						    /*verbose_level*/0);
+				break;
+			}
+			default:
+				panic("Unexpected TaskMgmt Func\n");
+				break;
+			}
+		}
+		break;
+	}
+	case TASKMGMT_CMD_CMPLT_OKAY:
+	{
+		u_int	scbid;
+		struct	scb *scb;
+
+		/*
+		 * An ABORT TASK TMF failed to be delivered before
+		 * the targeted command completed normally.
+		 */
+		scbid = ahd_get_scbptr(ahd);
+		scb = ahd_lookup_scb(ahd, scbid);
+		if (scb != NULL) {
+			/*
+			 * Remove the second instance of this SCB from
+			 * the QINFIFO if it is still there.
+                         */
+			ahd_print_path(ahd, scb);
+			printf("SCB completes before TMF\n");
+			/*
+			 * Handle losing the race.  Wait until any
+			 * current selection completes.  We will then
+			 * set the TMF back to zero in this SCB so that
+			 * the sequencer doesn't bother to issue another
+			 * sequencer interrupt for its completion.
+			 */
+			while ((ahd_inb(ahd, SCSISEQ0) & ENSELO) != 0
+			    && (ahd_inb(ahd, SSTAT0) & SELDO) == 0
+			    && (ahd_inb(ahd, SSTAT1) & SELTO) == 0)
+				;
+			ahd_outb(ahd, SCB_TASK_MANAGEMENT, 0);
+			ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb),
+					   SCB_GET_CHANNEL(ahd, scb),  
+					   SCB_GET_LUN(scb), SCB_GET_TAG(scb), 
+					   ROLE_INITIATOR, /*status*/0,   
+					   SEARCH_REMOVE);
+		}
+		break;
+	}
+	case TRACEPOINT0:
+	case TRACEPOINT1:
+	case TRACEPOINT2:
+	case TRACEPOINT3:
+		printf("%s: Tracepoint %d\n", ahd_name(ahd),
+		       seqintcode - TRACEPOINT0);
+		break;
+	case NO_SEQINT:
+		break;
+	case SAW_HWERR:
+		ahd_handle_hwerrint(ahd);
+		break;
+	default:
+		printf("%s: Unexpected SEQINTCODE %d\n", ahd_name(ahd),
+		       seqintcode);
+		break;
+	}
+	/*
+	 *  The sequencer is paused immediately on
+	 *  a SEQINT, so we should restart it when
+	 *  we're done.
+	 */
+	ahd_unpause(ahd);
+}
+
+void
+ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat)
+{
+	struct scb	*scb;
+	u_int		 status0;
+	u_int		 status3;
+	u_int		 status;
+	u_int		 lqistat1;
+	u_int		 lqostat0;
+	u_int		 scbid;
+	u_int		 busfreetime;
+
+	ahd_update_modes(ahd);
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+
+	status3 = ahd_inb(ahd, SSTAT3) & (NTRAMPERR|OSRAMPERR);
+	status0 = ahd_inb(ahd, SSTAT0) & (IOERR|OVERRUN|SELDI|SELDO);
+	status = ahd_inb(ahd, SSTAT1) & (SELTO|SCSIRSTI|BUSFREE|SCSIPERR);
+	lqistat1 = ahd_inb(ahd, LQISTAT1);
+	lqostat0 = ahd_inb(ahd, LQOSTAT0);
+	busfreetime = ahd_inb(ahd, SSTAT2) & BUSFREETIME;
+	if ((status0 & (SELDI|SELDO)) != 0) {
+		u_int simode0;
+
+		ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
+		simode0 = ahd_inb(ahd, SIMODE0);
+		status0 &= simode0 & (IOERR|OVERRUN|SELDI|SELDO);
+		ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+	}
+	scbid = ahd_get_scbptr(ahd);
+	scb = ahd_lookup_scb(ahd, scbid);
+	if (scb != NULL
+	 && (ahd_inb(ahd, SEQ_FLAGS) & NOT_IDENTIFIED) != 0)
+		scb = NULL;
+
+	/* Make sure the sequencer is in a safe location. */
+	ahd_clear_critical_section(ahd);
+
+	if ((status0 & IOERR) != 0) {
+		u_int now_lvd;
+
+		now_lvd = ahd_inb(ahd, SBLKCTL) & ENAB40;
+		printf("%s: Transceiver State Has Changed to %s mode\n",
+		       ahd_name(ahd), now_lvd ? "LVD" : "SE");
+		ahd_outb(ahd, CLRSINT0, CLRIOERR);
+		/*
+		 * A change in I/O mode is equivalent to a bus reset.
+		 */
+		ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
+		ahd_pause(ahd);
+		ahd_setup_iocell_workaround(ahd);
+		ahd_unpause(ahd);
+	} else if ((status0 & OVERRUN) != 0) {
+		printf("%s: SCSI offset overrun detected.  Resetting bus.\n",
+		       ahd_name(ahd));
+		ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
+	} else if ((status & SCSIRSTI) != 0) {
+		printf("%s: Someone reset channel A\n", ahd_name(ahd));
+		ahd_reset_channel(ahd, 'A', /*Initiate Reset*/FALSE);
+	} else if ((status & SCSIPERR) != 0) {
+		ahd_handle_transmission_error(ahd);
+	} else if (lqostat0 != 0) {
+		printf("%s: lqostat0 == 0x%x!\n", ahd_name(ahd), lqostat0);
+		ahd_outb(ahd, CLRLQOINT0, lqostat0);
+		if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0) {
+			ahd_outb(ahd, CLRLQOINT1, 0);
+		}
+	} else if ((status & SELTO) != 0) {
+		u_int  scbid;
+
+		/* Stop the selection */
+		ahd_outb(ahd, SCSISEQ0, 0);
+
+		/* No more pending messages */
+		ahd_clear_msg_state(ahd);
+
+		/* Clear interrupt state */
+		ahd_outb(ahd, CLRSINT1, CLRSELTIMEO|CLRBUSFREE|CLRSCSIPERR);
+
+		/*
+		 * Although the driver does not care about the
+		 * 'Selection in Progress' status bit, the busy
+		 * LED does.  SELINGO is only cleared by a sucessfull
+		 * selection, so we must manually clear it to insure
+		 * the LED turns off just incase no future successful
+		 * selections occur (e.g. no devices on the bus).
+		 */
+		ahd_outb(ahd, CLRSINT0, CLRSELINGO);
+
+		scbid = ahd_inw(ahd, WAITING_TID_HEAD);
+		scb = ahd_lookup_scb(ahd, scbid);
+		if (scb == NULL) {
+			printf("%s: ahd_intr - referenced scb not "
+			       "valid during SELTO scb(0x%x)\n",
+			       ahd_name(ahd), scbid);
+			ahd_dump_card_state(ahd);
+		} else {
+			struct ahd_devinfo devinfo;
+#ifdef AHD_DEBUG
+			if ((ahd_debug & AHD_SHOW_SELTO) != 0) {
+				ahd_print_path(ahd, scb);
+				printf("Saw Selection Timeout for SCB 0x%x\n",
+				       scbid);
+			}
+#endif
+			/*
+			 * Force a renegotiation with this target just in
+			 * case the cable was pulled and will later be
+			 * re-attached.  The target may forget its negotiation
+			 * settings with us should it attempt to reselect
+			 * during the interruption.  The target will not issue
+			 * a unit attention in this case, so we must always
+			 * renegotiate.
+			 */
+			ahd_scb_devinfo(ahd, &devinfo, scb);
+			ahd_force_renegotiation(ahd, &devinfo);
+			ahd_set_transaction_status(scb, CAM_SEL_TIMEOUT);
+			ahd_freeze_devq(ahd, scb);
+		}
+		ahd_outb(ahd, CLRINT, CLRSCSIINT);
+		ahd_iocell_first_selection(ahd);
+		ahd_unpause(ahd);
+	} else if ((status0 & (SELDI|SELDO)) != 0) {
+		ahd_iocell_first_selection(ahd);
+		ahd_unpause(ahd);
+	} else if (status3 != 0) {
+		printf("%s: SCSI Cell parity error SSTAT3 == 0x%x\n",
+		       ahd_name(ahd), status3);
+		ahd_outb(ahd, CLRSINT3, status3);
+	} else if ((lqistat1 & (LQIPHASE_LQ|LQIPHASE_NLQ)) != 0) {
+		ahd_handle_lqiphase_error(ahd, lqistat1);
+	} else if ((lqistat1 & LQICRCI_NLQ) != 0) {
+		/*
+		 * This status can be delayed during some
+		 * streaming operations.  The SCSIPHASE
+		 * handler has already dealt with this case
+		 * so just clear the error.
+		 */
+		ahd_outb(ahd, CLRLQIINT1, CLRLQICRCI_NLQ);
+	} else if ((status & BUSFREE) != 0) {
+		u_int lqostat1;
+		int   restart;
+		int   clear_fifo;
+		int   packetized;
+		u_int mode;
+
+		/*
+		 * Clear our selection hardware as soon as possible.
+		 * We may have an entry in the waiting Q for this target,
+		 * that is affected by this busfree and we don't want to
+		 * go about selecting the target while we handle the event.
+		 */
+		ahd_outb(ahd, SCSISEQ0, 0);
+
+		/*
+		 * Determine what we were up to at the time of
+		 * the busfree.
+		 */
+		mode = AHD_MODE_SCSI;
+		busfreetime = ahd_inb(ahd, SSTAT2) & BUSFREETIME;
+		lqostat1 = ahd_inb(ahd, LQOSTAT1);
+		switch (busfreetime) {
+		case BUSFREE_DFF0:
+		case BUSFREE_DFF1:
+		{
+			u_int	scbid;
+			struct	scb *scb;
+
+			mode = busfreetime == BUSFREE_DFF0
+			     ? AHD_MODE_DFF0 : AHD_MODE_DFF1;
+			ahd_set_modes(ahd, mode, mode);
+			scbid = ahd_get_scbptr(ahd);
+			scb = ahd_lookup_scb(ahd, scbid);
+			if (scb == NULL) {
+				printf("%s: Invalid SCB %d in DFF%d "
+				       "during unexpected busfree\n",
+				       ahd_name(ahd), scbid, mode);
+				packetized = 0;
+			} else
+				packetized = (scb->flags & SCB_PACKETIZED) != 0;
+			clear_fifo = 1;
+			break;
+		}
+		case BUSFREE_LQO:
+			clear_fifo = 0;
+			packetized = 1;
+			break;
+		default:
+			clear_fifo = 0;
+			packetized =  (lqostat1 & LQOBUSFREE) != 0;
+			if (!packetized
+			 && ahd_inb(ahd, LASTPHASE) == P_BUSFREE)
+				packetized = 1;
+			break;
+		}
+
+#ifdef AHD_DEBUG
+		if ((ahd_debug & AHD_SHOW_MISC) != 0)
+			printf("Saw Busfree.  Busfreetime = 0x%x.\n",
+			       busfreetime);
+#endif
+		/*
+		 * Busfrees that occur in non-packetized phases are
+		 * handled by the nonpkt_busfree handler.
+		 */
+		if (packetized && ahd_inb(ahd, LASTPHASE) == P_BUSFREE) {
+			restart = ahd_handle_pkt_busfree(ahd, busfreetime);
+		} else {
+			packetized = 0;
+			restart = ahd_handle_nonpkt_busfree(ahd);
+		}
+		/*
+		 * Clear the busfree interrupt status.  The setting of
+		 * the interrupt is a pulse, so in a perfect world, we
+		 * would not need to muck with the ENBUSFREE logic.  This
+		 * would ensure that if the bus moves on to another
+		 * connection, busfree protection is still in force.  If
+		 * BUSFREEREV is broken, however, we must manually clear
+		 * the ENBUSFREE if the busfree occurred during a non-pack
+		 * connection so that we don't get false positives during
+		 * future, packetized, connections.
+		 */
+		ahd_outb(ahd, CLRSINT1, CLRBUSFREE);
+		if (packetized == 0
+		 && (ahd->bugs & AHD_BUSFREEREV_BUG) != 0)
+			ahd_outb(ahd, SIMODE1,
+				 ahd_inb(ahd, SIMODE1) & ~ENBUSFREE);
+
+		if (clear_fifo)
+			ahd_clear_fifo(ahd, mode);
+
+		ahd_clear_msg_state(ahd);
+		ahd_outb(ahd, CLRINT, CLRSCSIINT);
+		if (restart) {
+			ahd_restart(ahd);
+		} else {
+			ahd_unpause(ahd);
+		}
+	} else {
+		printf("%s: Missing case in ahd_handle_scsiint. status = %x\n",
+		       ahd_name(ahd), status);
+		ahd_dump_card_state(ahd);
+		ahd_clear_intstat(ahd);
+		ahd_unpause(ahd);
+	}
+}
+
+static void
+ahd_handle_transmission_error(struct ahd_softc *ahd)
+{
+	struct	scb *scb;
+	u_int	scbid;
+	u_int	lqistat1;
+	u_int	lqistat2;
+	u_int	msg_out;
+	u_int	curphase;
+	u_int	lastphase;
+	u_int	perrdiag;
+	u_int	cur_col;
+	int	silent;
+
+	scb = NULL;
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+	lqistat1 = ahd_inb(ahd, LQISTAT1) & ~(LQIPHASE_LQ|LQIPHASE_NLQ);
+	lqistat2 = ahd_inb(ahd, LQISTAT2);
+	if ((lqistat1 & (LQICRCI_NLQ|LQICRCI_LQ)) == 0
+	 && (ahd->bugs & AHD_NLQICRC_DELAYED_BUG) != 0) {
+		u_int lqistate;
+
+		ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
+		lqistate = ahd_inb(ahd, LQISTATE);
+		if ((lqistate >= 0x1E && lqistate <= 0x24)
+		 || (lqistate == 0x29)) {
+#ifdef AHD_DEBUG
+			if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
+				printf("%s: NLQCRC found via LQISTATE\n",
+				       ahd_name(ahd));
+			}
+#endif
+			lqistat1 |= LQICRCI_NLQ;
+		}
+		ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+	}
+
+	ahd_outb(ahd, CLRLQIINT1, lqistat1);
+	lastphase = ahd_inb(ahd, LASTPHASE);
+	curphase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK;
+	perrdiag = ahd_inb(ahd, PERRDIAG);
+	msg_out = MSG_INITIATOR_DET_ERR;
+	ahd_outb(ahd, CLRSINT1, CLRSCSIPERR);
+	
+	/*
+	 * Try to find the SCB associated with this error.
+	 */
+	silent = FALSE;
+	if (lqistat1 == 0
+	 || (lqistat1 & LQICRCI_NLQ) != 0) {
+	 	if ((lqistat1 & (LQICRCI_NLQ|LQIOVERI_NLQ)) != 0)
+			ahd_set_active_fifo(ahd);
+		scbid = ahd_get_scbptr(ahd);
+		scb = ahd_lookup_scb(ahd, scbid);
+		if (scb != NULL && SCB_IS_SILENT(scb))
+			silent = TRUE;
+	}
+
+	cur_col = 0;
+	if (silent == FALSE) {
+		printf("%s: Transmission error detected\n", ahd_name(ahd));
+		ahd_lqistat1_print(lqistat1, &cur_col, 50);
+		ahd_lastphase_print(lastphase, &cur_col, 50);
+		ahd_scsisigi_print(curphase, &cur_col, 50);
+		ahd_perrdiag_print(perrdiag, &cur_col, 50);
+		printf("\n");
+		ahd_dump_card_state(ahd);
+	}
+
+	if ((lqistat1 & (LQIOVERI_LQ|LQIOVERI_NLQ)) != 0) {
+		if (silent == FALSE) {
+			printf("%s: Gross protocol error during incoming "
+			       "packet.  lqistat1 == 0x%x.  Resetting bus.\n",
+			       ahd_name(ahd), lqistat1);
+		}
+		ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
+		return;
+	} else if ((lqistat1 & LQICRCI_LQ) != 0) {
+		/*
+		 * A CRC error has been detected on an incoming LQ.
+		 * The bus is currently hung on the last ACK.
+		 * Hit LQIRETRY to release the last ack, and
+		 * wait for the sequencer to determine that ATNO
+		 * is asserted while in message out to take us
+		 * to our host message loop.  No NONPACKREQ or
+		 * LQIPHASE type errors will occur in this
+		 * scenario.  After this first LQIRETRY, the LQI
+		 * manager will be in ISELO where it will
+		 * happily sit until another packet phase begins.
+		 * Unexpected bus free detection is enabled
+		 * through any phases that occur after we release
+		 * this last ack until the LQI manager sees a
+		 * packet phase.  This implies we may have to
+		 * ignore a perfectly valid "unexected busfree"
+		 * after our "initiator detected error" message is
+		 * sent.  A busfree is the expected response after
+		 * we tell the target that it's L_Q was corrupted.
+		 * (SPI4R09 10.7.3.3.3)
+		 */
+		ahd_outb(ahd, LQCTL2, LQIRETRY);
+		printf("LQIRetry for LQICRCI_LQ to release ACK\n");
+	} else if ((lqistat1 & LQICRCI_NLQ) != 0) {
+		/*
+		 * We detected a CRC error in a NON-LQ packet.
+		 * The hardware has varying behavior in this situation
+		 * depending on whether this packet was part of a
+		 * stream or not.
+		 *
+		 * PKT by PKT mode:
+		 * The hardware has already acked the complete packet.
+		 * If the target honors our outstanding ATN condition,
+		 * we should be (or soon will be) in MSGOUT phase.
+		 * This will trigger the LQIPHASE_LQ status bit as the
+		 * hardware was expecting another LQ.  Unexpected
+		 * busfree detection is enabled.  Once LQIPHASE_LQ is
+		 * true (first entry into host message loop is much
+		 * the same), we must clear LQIPHASE_LQ and hit
+		 * LQIRETRY so the hardware is ready to handle
+		 * a future LQ.  NONPACKREQ will not be asserted again
+		 * once we hit LQIRETRY until another packet is
+		 * processed.  The target may either go busfree
+		 * or start another packet in response to our message.
+		 *
+		 * Read Streaming P0 asserted:
+		 * If we raise ATN and the target completes the entire
+		 * stream (P0 asserted during the last packet), the
+		 * hardware will ack all data and return to the ISTART
+		 * state.  When the target reponds to our ATN condition,
+		 * LQIPHASE_LQ will be asserted.  We should respond to
+		 * this with an LQIRETRY to prepare for any future
+		 * packets.  NONPACKREQ will not be asserted again
+		 * once we hit LQIRETRY until another packet is
+		 * processed.  The target may either go busfree or
+		 * start another packet in response to our message.
+		 * Busfree detection is enabled.
+		 *
+		 * Read Streaming P0 not asserted:
+		 * If we raise ATN and the target transitions to
+		 * MSGOUT in or after a packet where P0 is not
+		 * asserted, the hardware will assert LQIPHASE_NLQ.
+		 * We should respond to the LQIPHASE_NLQ with an
+		 * LQIRETRY.  Should the target stay in a non-pkt
+		 * phase after we send our message, the hardware
+		 * will assert LQIPHASE_LQ.  Recovery is then just as
+		 * listed above for the read streaming with P0 asserted.
+		 * Busfree detection is enabled.
+		 */
+		if (silent == FALSE)
+			printf("LQICRC_NLQ\n");
+		if (scb == NULL) {
+			printf("%s: No SCB valid for LQICRC_NLQ.  "
+			       "Resetting bus\n", ahd_name(ahd));
+			ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
+			return;
+		}
+	} else if ((lqistat1 & LQIBADLQI) != 0) {
+		printf("Need to handle BADLQI!\n");
+		ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
+		return;
+	} else if ((perrdiag & (PARITYERR|PREVPHASE)) == PARITYERR) {
+		if ((curphase & ~P_DATAIN_DT) != 0) {
+			/* Ack the byte.  So we can continue. */
+			if (silent == FALSE)
+				printf("Acking %s to clear perror\n",
+				    ahd_lookup_phase_entry(curphase)->phasemsg);
+			ahd_inb(ahd, SCSIDAT);
+		}
+	
+		if (curphase == P_MESGIN)
+			msg_out = MSG_PARITY_ERROR;
+	}
+
+	/*
+	 * We've set the hardware to assert ATN if we 
+	 * get a parity error on "in" phases, so all we
+	 * need to do is stuff the message buffer with
+	 * the appropriate message.  "In" phases have set
+	 * mesg_out to something other than MSG_NOP.
+	 */
+	ahd->send_msg_perror = msg_out;
+	if (scb != NULL && msg_out == MSG_INITIATOR_DET_ERR)
+		scb->flags |= SCB_TRANSMISSION_ERROR;
+	ahd_outb(ahd, MSG_OUT, HOST_MSG);
+	ahd_outb(ahd, CLRINT, CLRSCSIINT);
+	ahd_unpause(ahd);
+}
+
+static void
+ahd_handle_lqiphase_error(struct ahd_softc *ahd, u_int lqistat1)
+{
+	/*
+	 * Clear the sources of the interrupts.
+	 */
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+	ahd_outb(ahd, CLRLQIINT1, lqistat1);
+
+	/*
+	 * If the "illegal" phase changes were in response
+	 * to our ATN to flag a CRC error, AND we ended up
+	 * on packet boundaries, clear the error, restart the
+	 * LQI manager as appropriate, and go on our merry
+	 * way toward sending the message.  Otherwise, reset
+	 * the bus to clear the error.
+	 */
+	ahd_set_active_fifo(ahd);
+	if ((ahd_inb(ahd, SCSISIGO) & ATNO) != 0
+	 && (ahd_inb(ahd, MDFFSTAT) & DLZERO) != 0) {
+		if ((lqistat1 & LQIPHASE_LQ) != 0) {
+			printf("LQIRETRY for LQIPHASE_LQ\n");
+			ahd_outb(ahd, LQCTL2, LQIRETRY);
+		} else if ((lqistat1 & LQIPHASE_NLQ) != 0) {
+			printf("LQIRETRY for LQIPHASE_NLQ\n");
+			ahd_outb(ahd, LQCTL2, LQIRETRY);
+		} else
+			panic("ahd_handle_lqiphase_error: No phase errors\n");
+		ahd_dump_card_state(ahd);
+		ahd_outb(ahd, CLRINT, CLRSCSIINT);
+		ahd_unpause(ahd);
+	} else {
+		printf("Reseting Channel for LQI Phase error\n");
+		ahd_dump_card_state(ahd);
+		ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
+	}
+}
+
+/*
+ * Packetized unexpected or expected busfree.
+ * Entered in mode based on busfreetime.
+ */
+static int
+ahd_handle_pkt_busfree(struct ahd_softc *ahd, u_int busfreetime)
+{
+	u_int lqostat1;
+
+	AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
+			 ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
+	lqostat1 = ahd_inb(ahd, LQOSTAT1);
+	if ((lqostat1 & LQOBUSFREE) != 0) {
+		struct scb *scb;
+		u_int scbid;
+		u_int saved_scbptr;
+		u_int waiting_h;
+		u_int waiting_t;
+		u_int next;
+
+		if ((busfreetime & BUSFREE_LQO) == 0)
+			printf("%s: Warning, BUSFREE time is 0x%x.  "
+			       "Expected BUSFREE_LQO.\n",
+			       ahd_name(ahd), busfreetime);
+		/*
+		 * The LQO manager detected an unexpected busfree
+		 * either:
+		 *
+		 * 1) During an outgoing LQ.
+		 * 2) After an outgoing LQ but before the first
+		 *    REQ of the command packet.
+		 * 3) During an outgoing command packet.
+		 *
+		 * In all cases, CURRSCB is pointing to the
+		 * SCB that encountered the failure.  Clean
+		 * up the queue, clear SELDO and LQOBUSFREE,
+		 * and allow the sequencer to restart the select
+		 * out at its lesure.
+		 */
+		ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+		scbid = ahd_inw(ahd, CURRSCB);
+		scb = ahd_lookup_scb(ahd, scbid);
+		if (scb == NULL)
+		       panic("SCB not valid during LQOBUSFREE");
+		/*
+		 * Clear the status.
+		 */
+		ahd_outb(ahd, CLRLQOINT1, CLRLQOBUSFREE);
+		if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0)
+			ahd_outb(ahd, CLRLQOINT1, 0);
+		ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
+		ahd_flush_device_writes(ahd);
+		ahd_outb(ahd, CLRSINT0, CLRSELDO);
+
+		/*
+		 * Return the LQO manager to its idle loop.  It will
+		 * not do this automatically if the busfree occurs
+		 * after the first REQ of either the LQ or command
+		 * packet or between the LQ and command packet.
+		 */
+		ahd_outb(ahd, LQCTL2, ahd_inb(ahd, LQCTL2) | LQOTOIDLE);
+
+		/*
+		 * Update the waiting for selection queue so
+		 * we restart on the correct SCB.
+		 */
+		waiting_h = ahd_inw(ahd, WAITING_TID_HEAD);
+		saved_scbptr = ahd_get_scbptr(ahd);
+		if (waiting_h != scbid) {
+
+			ahd_outw(ahd, WAITING_TID_HEAD, scbid);
+			waiting_t = ahd_inw(ahd, WAITING_TID_TAIL);
+			if (waiting_t == waiting_h) {
+				ahd_outw(ahd, WAITING_TID_TAIL, scbid);
+				next = SCB_LIST_NULL;
+			} else {
+				ahd_set_scbptr(ahd, waiting_h);
+				next = ahd_inw_scbram(ahd, SCB_NEXT2);
+			}
+			ahd_set_scbptr(ahd, scbid);
+			ahd_outw(ahd, SCB_NEXT2, next);
+		}
+		ahd_set_scbptr(ahd, saved_scbptr);
+		if (scb->crc_retry_count < AHD_MAX_LQ_CRC_ERRORS) {
+			if (SCB_IS_SILENT(scb) == FALSE) {
+				ahd_print_path(ahd, scb);
+				printf("Probable outgoing LQ CRC error.  "
+				       "Retrying command\n");
+			}
+			scb->crc_retry_count++;
+		} else {
+			ahd_set_transaction_status(scb, CAM_UNCOR_PARITY);
+			ahd_freeze_scb(scb);
+			ahd_freeze_devq(ahd, scb);
+		}
+		/* Return unpausing the sequencer. */
+		return (0);
+	} else if ((ahd_inb(ahd, PERRDIAG) & PARITYERR) != 0) {
+		/*
+		 * Ignore what are really parity errors that
+		 * occur on the last REQ of a free running
+		 * clock prior to going busfree.  Some drives
+		 * do not properly active negate just before
+		 * going busfree resulting in a parity glitch.
+		 */
+		ahd_outb(ahd, CLRSINT1, CLRSCSIPERR|CLRBUSFREE);
+#ifdef AHD_DEBUG
+		if ((ahd_debug & AHD_SHOW_MASKED_ERRORS) != 0)
+			printf("%s: Parity on last REQ detected "
+			       "during busfree phase.\n",
+			       ahd_name(ahd));
+#endif
+		/* Return unpausing the sequencer. */
+		return (0);
+	}
+	if (ahd->src_mode != AHD_MODE_SCSI) {
+		u_int	scbid;
+		struct	scb *scb;
+
+		scbid = ahd_get_scbptr(ahd);
+		scb = ahd_lookup_scb(ahd, scbid);
+		ahd_print_path(ahd, scb);
+		printf("Unexpected PKT busfree condition\n");
+		ahd_dump_card_state(ahd);
+		ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb), 'A',
+			       SCB_GET_LUN(scb), SCB_GET_TAG(scb),
+			       ROLE_INITIATOR, CAM_UNEXP_BUSFREE);
+
+		/* Return restarting the sequencer. */
+		return (1);
+	}
+	printf("%s: Unexpected PKT busfree condition\n", ahd_name(ahd));
+	ahd_dump_card_state(ahd);
+	/* Restart the sequencer. */
+	return (1);
+}
+
+/*
+ * Non-packetized unexpected or expected busfree.
+ */
+static int
+ahd_handle_nonpkt_busfree(struct ahd_softc *ahd)
+{
+	struct	ahd_devinfo devinfo;
+	struct	scb *scb;
+	u_int	lastphase;
+	u_int	saved_scsiid;
+	u_int	saved_lun;
+	u_int	target;
+	u_int	initiator_role_id;
+	u_int	scbid;
+	u_int	ppr_busfree;
+	int	printerror;
+
+	/*
+	 * Look at what phase we were last in.  If its message out,
+	 * chances are pretty good that the busfree was in response
+	 * to one of our abort requests.
+	 */
+	lastphase = ahd_inb(ahd, LASTPHASE);
+	saved_scsiid = ahd_inb(ahd, SAVED_SCSIID);
+	saved_lun = ahd_inb(ahd, SAVED_LUN);
+	target = SCSIID_TARGET(ahd, saved_scsiid);
+	initiator_role_id = SCSIID_OUR_ID(saved_scsiid);
+	ahd_compile_devinfo(&devinfo, initiator_role_id,
+			    target, saved_lun, 'A', ROLE_INITIATOR);
+	printerror = 1;
+
+	scbid = ahd_get_scbptr(ahd);
+	scb = ahd_lookup_scb(ahd, scbid);
+	if (scb != NULL
+	 && (ahd_inb(ahd, SEQ_FLAGS) & NOT_IDENTIFIED) != 0)
+		scb = NULL;
+
+	ppr_busfree = (ahd->msg_flags & MSG_FLAG_EXPECT_PPR_BUSFREE) != 0;
+	if (lastphase == P_MESGOUT) {
+		u_int tag;
+
+		tag = SCB_LIST_NULL;
+		if (ahd_sent_msg(ahd, AHDMSG_1B, MSG_ABORT_TAG, TRUE)
+		 || ahd_sent_msg(ahd, AHDMSG_1B, MSG_ABORT, TRUE)) {
+			int found;
+			int sent_msg;
+
+			if (scb == NULL) {
+				ahd_print_devinfo(ahd, &devinfo);
+				printf("Abort for unidentified "
+				       "connection completed.\n");
+				/* restart the sequencer. */
+				return (1);
+			}
+			sent_msg = ahd->msgout_buf[ahd->msgout_index - 1];
+			ahd_print_path(ahd, scb);
+			printf("SCB %d - Abort%s Completed.\n",
+			       SCB_GET_TAG(scb),
+			       sent_msg == MSG_ABORT_TAG ? "" : " Tag");
+
+			if (sent_msg == MSG_ABORT_TAG)
+				tag = SCB_GET_TAG(scb);
+
+			if ((scb->flags & SCB_CMDPHASE_ABORT) != 0) {
+				/*
+				 * This abort is in response to an
+				 * unexpected switch to command phase
+				 * for a packetized connection.  Since
+				 * the identify message was never sent,
+				 * "saved lun" is 0.  We really want to
+				 * abort only the SCB that encountered
+				 * this error, which could have a different
+				 * lun.  The SCB will be retried so the OS
+				 * will see the UA after renegotiating to
+				 * packetized.
+				 */
+				tag = SCB_GET_TAG(scb);
+				saved_lun = scb->hscb->lun;
+			}
+			found = ahd_abort_scbs(ahd, target, 'A', saved_lun,
+					       tag, ROLE_INITIATOR,
+					       CAM_REQ_ABORTED);
+			printf("found == 0x%x\n", found);
+			printerror = 0;
+		} else if (ahd_sent_msg(ahd, AHDMSG_1B,
+					MSG_BUS_DEV_RESET, TRUE)) {
+#ifdef __FreeBSD__
+			/*
+			 * Don't mark the user's request for this BDR
+			 * as completing with CAM_BDR_SENT.  CAM3
+			 * specifies CAM_REQ_CMP.
+			 */
+			if (scb != NULL
+			 && scb->io_ctx->ccb_h.func_code== XPT_RESET_DEV
+			 && ahd_match_scb(ahd, scb, target, 'A',
+					  CAM_LUN_WILDCARD, SCB_LIST_NULL,
+					  ROLE_INITIATOR))
+				ahd_set_transaction_status(scb, CAM_REQ_CMP);
+#endif
+			ahd_handle_devreset(ahd, &devinfo, CAM_LUN_WILDCARD,
+					    CAM_BDR_SENT, "Bus Device Reset",
+					    /*verbose_level*/0);
+			printerror = 0;
+		} else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_PPR, FALSE)
+			&& ppr_busfree == 0) {
+			struct ahd_initiator_tinfo *tinfo;
+			struct ahd_tmode_tstate *tstate;
+
+			/*
+			 * PPR Rejected.  Try non-ppr negotiation
+			 * and retry command.
+			 */
+#ifdef AHD_DEBUG
+			if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
+				printf("PPR negotiation rejected busfree.\n");
+#endif
+			tinfo = ahd_fetch_transinfo(ahd, devinfo.channel,
+						    devinfo.our_scsiid,
+						    devinfo.target, &tstate);
+			tinfo->curr.transport_version = 2;
+			tinfo->goal.transport_version = 2;
+			tinfo->goal.ppr_options = 0;
+			ahd_qinfifo_requeue_tail(ahd, scb);
+			printerror = 0;
+		} else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_WDTR, FALSE)
+			&& ppr_busfree == 0) {
+			/*
+			 * Negotiation Rejected.  Go-narrow and
+			 * retry command.
+			 */
+#ifdef AHD_DEBUG
+			if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
+				printf("WDTR negotiation rejected busfree.\n");
+#endif
+			ahd_set_width(ahd, &devinfo,
+				      MSG_EXT_WDTR_BUS_8_BIT,
+				      AHD_TRANS_CUR|AHD_TRANS_GOAL,
+				      /*paused*/TRUE);
+			ahd_qinfifo_requeue_tail(ahd, scb);
+			printerror = 0;
+		} else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_SDTR, FALSE)
+			&& ppr_busfree == 0) {
+			/*
+			 * Negotiation Rejected.  Go-async and
+			 * retry command.
+			 */
+#ifdef AHD_DEBUG
+			if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
+				printf("SDTR negotiation rejected busfree.\n");
+#endif
+			ahd_set_syncrate(ahd, &devinfo,
+					/*period*/0, /*offset*/0,
+					/*ppr_options*/0,
+					AHD_TRANS_CUR|AHD_TRANS_GOAL,
+					/*paused*/TRUE);
+			ahd_qinfifo_requeue_tail(ahd, scb);
+			printerror = 0;
+		} else if ((ahd->msg_flags & MSG_FLAG_EXPECT_IDE_BUSFREE) != 0
+			&& ahd_sent_msg(ahd, AHDMSG_1B,
+					 MSG_INITIATOR_DET_ERR, TRUE)) {
+
+#ifdef AHD_DEBUG
+			if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
+				printf("Expected IDE Busfree\n");
+#endif
+			printerror = 0;
+		} else if ((ahd->msg_flags & MSG_FLAG_EXPECT_QASREJ_BUSFREE)
+			&& ahd_sent_msg(ahd, AHDMSG_1B,
+					MSG_MESSAGE_REJECT, TRUE)) {
+
+#ifdef AHD_DEBUG
+			if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
+				printf("Expected QAS Reject Busfree\n");
+#endif
+			printerror = 0;
+		}
+	}
+
+	/*
+	 * The busfree required flag is honored at the end of
+	 * the message phases.  We check it last in case we
+	 * had to send some other message that caused a busfree.
+	 */
+	if (printerror != 0
+	 && (lastphase == P_MESGIN || lastphase == P_MESGOUT)
+	 && ((ahd->msg_flags & MSG_FLAG_EXPECT_PPR_BUSFREE) != 0)) {
+
+		ahd_freeze_devq(ahd, scb);
+		ahd_set_transaction_status(scb, CAM_REQUEUE_REQ);
+		ahd_freeze_scb(scb);
+		if ((ahd->msg_flags & MSG_FLAG_IU_REQ_CHANGED) != 0) {
+			ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb),
+				       SCB_GET_CHANNEL(ahd, scb),
+				       SCB_GET_LUN(scb), SCB_LIST_NULL,
+				       ROLE_INITIATOR, CAM_REQ_ABORTED);
+		} else {
+#ifdef AHD_DEBUG
+			if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
+				printf("PPR Negotiation Busfree.\n");
+#endif
+			ahd_done(ahd, scb);
+		}
+		printerror = 0;
+	}
+	if (printerror != 0) {
+		int aborted;
+
+		aborted = 0;
+		if (scb != NULL) {
+			u_int tag;
+
+			if ((scb->hscb->control & TAG_ENB) != 0)
+				tag = SCB_GET_TAG(scb);
+			else
+				tag = SCB_LIST_NULL;
+			ahd_print_path(ahd, scb);
+			aborted = ahd_abort_scbs(ahd, target, 'A',
+				       SCB_GET_LUN(scb), tag,
+				       ROLE_INITIATOR,
+				       CAM_UNEXP_BUSFREE);
+		} else {
+			/*
+			 * We had not fully identified this connection,
+			 * so we cannot abort anything.
+			 */
+			printf("%s: ", ahd_name(ahd));
+		}
+		if (lastphase != P_BUSFREE)
+			ahd_force_renegotiation(ahd, &devinfo);
+		printf("Unexpected busfree %s, %d SCBs aborted, "
+		       "PRGMCNT == 0x%x\n",
+		       ahd_lookup_phase_entry(lastphase)->phasemsg,
+		       aborted,
+		       ahd_inb(ahd, PRGMCNT)
+			| (ahd_inb(ahd, PRGMCNT+1) << 8));
+		ahd_dump_card_state(ahd);
+	}
+	/* Always restart the sequencer. */
+	return (1);
+}
+
+static void
+ahd_handle_proto_violation(struct ahd_softc *ahd)
+{
+	struct	ahd_devinfo devinfo;
+	struct	scb *scb;
+	u_int	scbid;
+	u_int	seq_flags;
+	u_int	curphase;
+	u_int	lastphase;
+	int	found;
+
+	ahd_fetch_devinfo(ahd, &devinfo);
+	scbid = ahd_get_scbptr(ahd);
+	scb = ahd_lookup_scb(ahd, scbid);
+	seq_flags = ahd_inb(ahd, SEQ_FLAGS);
+	curphase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK;
+	lastphase = ahd_inb(ahd, LASTPHASE);
+	if ((seq_flags & NOT_IDENTIFIED) != 0) {
+
+		/*
+		 * The reconnecting target either did not send an
+		 * identify message, or did, but we didn't find an SCB
+		 * to match.
+		 */
+		ahd_print_devinfo(ahd, &devinfo);
+		printf("Target did not send an IDENTIFY message. "
+		       "LASTPHASE = 0x%x.\n", lastphase);
+		scb = NULL;
+	} else if (scb == NULL) {
+		/*
+		 * We don't seem to have an SCB active for this
+		 * transaction.  Print an error and reset the bus.
+		 */
+		ahd_print_devinfo(ahd, &devinfo);
+		printf("No SCB found during protocol violation\n");
+		goto proto_violation_reset;
+	} else {
+		ahd_set_transaction_status(scb, CAM_SEQUENCE_FAIL);
+		if ((seq_flags & NO_CDB_SENT) != 0) {
+			ahd_print_path(ahd, scb);
+			printf("No or incomplete CDB sent to device.\n");
+		} else if ((ahd_inb_scbram(ahd, SCB_CONTROL)
+			  & STATUS_RCVD) == 0) {
+			/*
+			 * The target never bothered to provide status to
+			 * us prior to completing the command.  Since we don't
+			 * know the disposition of this command, we must attempt
+			 * to abort it.  Assert ATN and prepare to send an abort
+			 * message.
+			 */
+			ahd_print_path(ahd, scb);
+			printf("Completed command without status.\n");
+		} else {
+			ahd_print_path(ahd, scb);
+			printf("Unknown protocol violation.\n");
+			ahd_dump_card_state(ahd);
+		}
+	}
+	if ((lastphase & ~P_DATAIN_DT) == 0
+	 || lastphase == P_COMMAND) {
+proto_violation_reset:
+		/*
+		 * Target either went directly to data
+		 * phase or didn't respond to our ATN.
+		 * The only safe thing to do is to blow
+		 * it away with a bus reset.
+		 */
+		found = ahd_reset_channel(ahd, 'A', TRUE);
+		printf("%s: Issued Channel %c Bus Reset. "
+		       "%d SCBs aborted\n", ahd_name(ahd), 'A', found);
+	} else {
+		/*
+		 * Leave the selection hardware off in case
+		 * this abort attempt will affect yet to
+		 * be sent commands.
+		 */
+		ahd_outb(ahd, SCSISEQ0,
+			 ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
+		ahd_assert_atn(ahd);
+		ahd_outb(ahd, MSG_OUT, HOST_MSG);
+		if (scb == NULL) {
+			ahd_print_devinfo(ahd, &devinfo);
+			ahd->msgout_buf[0] = MSG_ABORT_TASK;
+			ahd->msgout_len = 1;
+			ahd->msgout_index = 0;
+			ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
+		} else {
+			ahd_print_path(ahd, scb);
+			scb->flags |= SCB_ABORT;
+		}
+		printf("Protocol violation %s.  Attempting to abort.\n",
+		       ahd_lookup_phase_entry(curphase)->phasemsg);
+	}
+}
+
+/*
+ * Force renegotiation to occur the next time we initiate
+ * a command to the current device.
+ */
+static void
+ahd_force_renegotiation(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
+{
+	struct	ahd_initiator_tinfo *targ_info;
+	struct	ahd_tmode_tstate *tstate;
+
+#ifdef AHD_DEBUG
+	if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
+		ahd_print_devinfo(ahd, devinfo);
+		printf("Forcing renegotiation\n");
+	}
+#endif
+	targ_info = ahd_fetch_transinfo(ahd,
+					devinfo->channel,
+					devinfo->our_scsiid,
+					devinfo->target,
+					&tstate);
+	ahd_update_neg_request(ahd, devinfo, tstate,
+			       targ_info, AHD_NEG_IF_NON_ASYNC);
+}
+
+#define AHD_MAX_STEPS 2000
+void
+ahd_clear_critical_section(struct ahd_softc *ahd)
+{
+	ahd_mode_state	saved_modes;
+	int		stepping;
+	int		steps;
+	int		first_instr;
+	u_int		simode0;
+	u_int		simode1;
+	u_int		simode3;
+	u_int		lqimode0;
+	u_int		lqimode1;
+	u_int		lqomode0;
+	u_int		lqomode1;
+
+	if (ahd->num_critical_sections == 0)
+		return;
+
+	stepping = FALSE;
+	steps = 0;
+	first_instr = 0;
+	simode0 = 0;
+	simode1 = 0;
+	simode3 = 0;
+	lqimode0 = 0;
+	lqimode1 = 0;
+	lqomode0 = 0;
+	lqomode1 = 0;
+	saved_modes = ahd_save_modes(ahd);
+	for (;;) {
+		struct	cs *cs;
+		u_int	seqaddr;
+		u_int	i;
+
+		ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+		seqaddr = ahd_inb(ahd, CURADDR)
+			| (ahd_inb(ahd, CURADDR+1) << 8);
+
+		cs = ahd->critical_sections;
+		for (i = 0; i < ahd->num_critical_sections; i++, cs++) {
+			
+			if (cs->begin < seqaddr && cs->end >= seqaddr)
+				break;
+		}
+
+		if (i == ahd->num_critical_sections)
+			break;
+
+		if (steps > AHD_MAX_STEPS) {
+			printf("%s: Infinite loop in critical section\n"
+			       "%s: First Instruction 0x%x now 0x%x\n",
+			       ahd_name(ahd), ahd_name(ahd), first_instr,
+			       seqaddr);
+			ahd_dump_card_state(ahd);
+			panic("critical section loop");
+		}
+
+		steps++;
+#ifdef AHD_DEBUG
+		if ((ahd_debug & AHD_SHOW_MISC) != 0)
+			printf("%s: Single stepping at 0x%x\n", ahd_name(ahd),
+			       seqaddr);
+#endif
+		if (stepping == FALSE) {
+
+			first_instr = seqaddr;
+  			ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
+  			simode0 = ahd_inb(ahd, SIMODE0);
+			simode3 = ahd_inb(ahd, SIMODE3);
+			lqimode0 = ahd_inb(ahd, LQIMODE0);
+			lqimode1 = ahd_inb(ahd, LQIMODE1);
+			lqomode0 = ahd_inb(ahd, LQOMODE0);
+			lqomode1 = ahd_inb(ahd, LQOMODE1);
+			ahd_outb(ahd, SIMODE0, 0);
+			ahd_outb(ahd, SIMODE3, 0);
+			ahd_outb(ahd, LQIMODE0, 0);
+			ahd_outb(ahd, LQIMODE1, 0);
+			ahd_outb(ahd, LQOMODE0, 0);
+			ahd_outb(ahd, LQOMODE1, 0);
+			ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+  			simode1 = ahd_inb(ahd, SIMODE1);
+  			ahd_outb(ahd, SIMODE1, ENBUSFREE);
+			ahd_outb(ahd, SEQCTL0, ahd_inb(ahd, SEQCTL0) | STEP);
+			stepping = TRUE;
+		}
+		ahd_outb(ahd, CLRSINT1, CLRBUSFREE);
+		ahd_outb(ahd, CLRINT, CLRSCSIINT);
+		ahd_set_modes(ahd, ahd->saved_src_mode, ahd->saved_dst_mode);
+		ahd_outb(ahd, HCNTRL, ahd->unpause);
+		do {
+			ahd_delay(200);
+		} while (!ahd_is_paused(ahd));
+		ahd_update_modes(ahd);
+	}
+	if (stepping) {
+		ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
+		ahd_outb(ahd, SIMODE0, simode0);
+		ahd_outb(ahd, SIMODE3, simode3);
+		ahd_outb(ahd, LQIMODE0, lqimode0);
+		ahd_outb(ahd, LQIMODE1, lqimode1);
+		ahd_outb(ahd, LQOMODE0, lqomode0);
+		ahd_outb(ahd, LQOMODE1, lqomode1);
+		ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+		ahd_outb(ahd, SEQCTL0, ahd_inb(ahd, SEQCTL0) & ~STEP);
+  		ahd_outb(ahd, SIMODE1, simode1);
+		/*
+		 * SCSIINT seems to glitch occassionally when
+		 * the interrupt masks are restored.  Clear SCSIINT
+		 * one more time so that only persistent errors
+		 * are seen as a real interrupt.
+		 */
+		ahd_outb(ahd, CLRINT, CLRSCSIINT);
+	}
+	ahd_restore_modes(ahd, saved_modes);
+}
+
+/*
+ * Clear any pending interrupt status.
+ */
+void
+ahd_clear_intstat(struct ahd_softc *ahd)
+{
+	AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
+			 ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
+	/* Clear any interrupt conditions this may have caused */
+	ahd_outb(ahd, CLRLQIINT0, CLRLQIATNQAS|CLRLQICRCT1|CLRLQICRCT2
+				 |CLRLQIBADLQT|CLRLQIATNLQ|CLRLQIATNCMD);
+	ahd_outb(ahd, CLRLQIINT1, CLRLQIPHASE_LQ|CLRLQIPHASE_NLQ|CLRLIQABORT
+				 |CLRLQICRCI_LQ|CLRLQICRCI_NLQ|CLRLQIBADLQI
+				 |CLRLQIOVERI_LQ|CLRLQIOVERI_NLQ|CLRNONPACKREQ);
+	ahd_outb(ahd, CLRLQOINT0, CLRLQOTARGSCBPERR|CLRLQOSTOPT2|CLRLQOATNLQ
+				 |CLRLQOATNPKT|CLRLQOTCRC);
+	ahd_outb(ahd, CLRLQOINT1, CLRLQOINITSCBPERR|CLRLQOSTOPI2|CLRLQOBADQAS
+				 |CLRLQOBUSFREE|CLRLQOPHACHGINPKT);
+	if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0) {
+		ahd_outb(ahd, CLRLQOINT0, 0);
+		ahd_outb(ahd, CLRLQOINT1, 0);
+	}
+	ahd_outb(ahd, CLRSINT3, CLRNTRAMPERR|CLROSRAMPERR);
+	ahd_outb(ahd, CLRSINT1, CLRSELTIMEO|CLRATNO|CLRSCSIRSTI
+				|CLRBUSFREE|CLRSCSIPERR|CLRREQINIT);
+	ahd_outb(ahd, CLRSINT0, CLRSELDO|CLRSELDI|CLRSELINGO
+			        |CLRIOERR|CLROVERRUN);
+	ahd_outb(ahd, CLRINT, CLRSCSIINT);
+}
+
+/**************************** Debugging Routines ******************************/
+#ifdef AHD_DEBUG
+uint32_t ahd_debug = AHD_DEBUG_OPTS;
+#endif
+void
+ahd_print_scb(struct scb *scb)
+{
+	struct hardware_scb *hscb;
+	int i;
+
+	hscb = scb->hscb;
+	printf("scb:%p control:0x%x scsiid:0x%x lun:%d cdb_len:%d\n",
+	       (void *)scb,
+	       hscb->control,
+	       hscb->scsiid,
+	       hscb->lun,
+	       hscb->cdb_len);
+	printf("Shared Data: ");
+	for (i = 0; i < sizeof(hscb->shared_data.idata.cdb); i++)
+		printf("%#02x", hscb->shared_data.idata.cdb[i]);
+	printf("        dataptr:%#x%x datacnt:%#x sgptr:%#x tag:%#x\n",
+	       (uint32_t)((ahd_le64toh(hscb->dataptr) >> 32) & 0xFFFFFFFF),
+	       (uint32_t)(ahd_le64toh(hscb->dataptr) & 0xFFFFFFFF),
+	       ahd_le32toh(hscb->datacnt),
+	       ahd_le32toh(hscb->sgptr),
+	       SCB_GET_TAG(scb));
+	ahd_dump_sglist(scb);
+}
+
+void
+ahd_dump_sglist(struct scb *scb)
+{
+	int i;
+
+	if (scb->sg_count > 0) {
+		if ((scb->ahd_softc->flags & AHD_64BIT_ADDRESSING) != 0) {
+			struct ahd_dma64_seg *sg_list;
+
+			sg_list = (struct ahd_dma64_seg*)scb->sg_list;
+			for (i = 0; i < scb->sg_count; i++) {
+				uint64_t addr;
+				uint32_t len;
+
+				addr = ahd_le64toh(sg_list[i].addr);
+				len = ahd_le32toh(sg_list[i].len);
+				printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
+				       i,
+				       (uint32_t)((addr >> 32) & 0xFFFFFFFF),
+				       (uint32_t)(addr & 0xFFFFFFFF),
+				       sg_list[i].len & AHD_SG_LEN_MASK,
+				       (sg_list[i].len & AHD_DMA_LAST_SEG)
+				     ? " Last" : "");
+			}
+		} else {
+			struct ahd_dma_seg *sg_list;
+
+			sg_list = (struct ahd_dma_seg*)scb->sg_list;
+			for (i = 0; i < scb->sg_count; i++) {
+				uint32_t len;
+
+				len = ahd_le32toh(sg_list[i].len);
+				printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
+				       i,
+				       (len >> 24) & SG_HIGH_ADDR_BITS,
+				       ahd_le32toh(sg_list[i].addr),
+				       len & AHD_SG_LEN_MASK,
+				       len & AHD_DMA_LAST_SEG ? " Last" : "");
+			}
+		}
+	}
+}
+
+/************************* Transfer Negotiation *******************************/
+/*
+ * Allocate per target mode instance (ID we respond to as a target)
+ * transfer negotiation data structures.
+ */
+static struct ahd_tmode_tstate *
+ahd_alloc_tstate(struct ahd_softc *ahd, u_int scsi_id, char channel)
+{
+	struct ahd_tmode_tstate *master_tstate;
+	struct ahd_tmode_tstate *tstate;
+	int i;
+
+	master_tstate = ahd->enabled_targets[ahd->our_id];
+	if (ahd->enabled_targets[scsi_id] != NULL
+	 && ahd->enabled_targets[scsi_id] != master_tstate)
+		panic("%s: ahd_alloc_tstate - Target already allocated",
+		      ahd_name(ahd));
+	tstate = malloc(sizeof(*tstate), M_DEVBUF, M_NOWAIT);
+	if (tstate == NULL)
+		return (NULL);
+
+	/*
+	 * If we have allocated a master tstate, copy user settings from
+	 * the master tstate (taken from SRAM or the EEPROM) for this
+	 * channel, but reset our current and goal settings to async/narrow
+	 * until an initiator talks to us.
+	 */
+	if (master_tstate != NULL) {
+		memcpy(tstate, master_tstate, sizeof(*tstate));
+		memset(tstate->enabled_luns, 0, sizeof(tstate->enabled_luns));
+		for (i = 0; i < 16; i++) {
+			memset(&tstate->transinfo[i].curr, 0,
+			      sizeof(tstate->transinfo[i].curr));
+			memset(&tstate->transinfo[i].goal, 0,
+			      sizeof(tstate->transinfo[i].goal));
+		}
+	} else
+		memset(tstate, 0, sizeof(*tstate));
+	ahd->enabled_targets[scsi_id] = tstate;
+	return (tstate);
+}
+
+#ifdef AHD_TARGET_MODE
+/*
+ * Free per target mode instance (ID we respond to as a target)
+ * transfer negotiation data structures.
+ */
+static void
+ahd_free_tstate(struct ahd_softc *ahd, u_int scsi_id, char channel, int force)
+{
+	struct ahd_tmode_tstate *tstate;
+
+	/*
+	 * Don't clean up our "master" tstate.
+	 * It has our default user settings.
+	 */
+	if (scsi_id == ahd->our_id
+	 && force == FALSE)
+		return;
+
+	tstate = ahd->enabled_targets[scsi_id];
+	if (tstate != NULL)
+		free(tstate, M_DEVBUF);
+	ahd->enabled_targets[scsi_id] = NULL;
+}
+#endif
+
+/*
+ * Called when we have an active connection to a target on the bus,
+ * this function finds the nearest period to the input period limited
+ * by the capabilities of the bus connectivity of and sync settings for
+ * the target.
+ */
+void
+ahd_devlimited_syncrate(struct ahd_softc *ahd,
+			struct ahd_initiator_tinfo *tinfo,
+			u_int *period, u_int *ppr_options, role_t role)
+{
+	struct	ahd_transinfo *transinfo;
+	u_int	maxsync;
+
+	if ((ahd_inb(ahd, SBLKCTL) & ENAB40) != 0
+	 && (ahd_inb(ahd, SSTAT2) & EXP_ACTIVE) == 0) {
+		maxsync = AHD_SYNCRATE_PACED;
+	} else {
+		maxsync = AHD_SYNCRATE_ULTRA;
+		/* Can't do DT related options on an SE bus */
+		*ppr_options &= MSG_EXT_PPR_QAS_REQ;
+	}
+	/*
+	 * Never allow a value higher than our current goal
+	 * period otherwise we may allow a target initiated
+	 * negotiation to go above the limit as set by the
+	 * user.  In the case of an initiator initiated
+	 * sync negotiation, we limit based on the user
+	 * setting.  This allows the system to still accept
+	 * incoming negotiations even if target initiated
+	 * negotiation is not performed.
+	 */
+	if (role == ROLE_TARGET)
+		transinfo = &tinfo->user;
+	else 
+		transinfo = &tinfo->goal;
+	*ppr_options &= (transinfo->ppr_options|MSG_EXT_PPR_PCOMP_EN);
+	if (transinfo->width == MSG_EXT_WDTR_BUS_8_BIT) {
+		maxsync = MAX(maxsync, AHD_SYNCRATE_ULTRA2);
+		*ppr_options &= ~MSG_EXT_PPR_DT_REQ;
+	}
+	if (transinfo->period == 0) {
+		*period = 0;
+		*ppr_options = 0;
+	} else {
+		*period = MAX(*period, transinfo->period);
+		ahd_find_syncrate(ahd, period, ppr_options, maxsync);
+	}
+}
+
+/*
+ * Look up the valid period to SCSIRATE conversion in our table.
+ * Return the period and offset that should be sent to the target
+ * if this was the beginning of an SDTR.
+ */
+void
+ahd_find_syncrate(struct ahd_softc *ahd, u_int *period,
+		  u_int *ppr_options, u_int maxsync)
+{
+	if (*period < maxsync)
+		*period = maxsync;
+
+	if ((*ppr_options & MSG_EXT_PPR_DT_REQ) != 0
+	 && *period > AHD_SYNCRATE_MIN_DT)
+		*ppr_options &= ~MSG_EXT_PPR_DT_REQ;
+		
+	if (*period > AHD_SYNCRATE_MIN)
+		*period = 0;
+
+	/* Honor PPR option conformance rules. */
+	if (*period > AHD_SYNCRATE_PACED)
+		*ppr_options &= ~MSG_EXT_PPR_RTI;
+
+	if ((*ppr_options & MSG_EXT_PPR_IU_REQ) == 0)
+		*ppr_options &= (MSG_EXT_PPR_DT_REQ|MSG_EXT_PPR_QAS_REQ);
+
+	if ((*ppr_options & MSG_EXT_PPR_DT_REQ) == 0)
+		*ppr_options &= MSG_EXT_PPR_QAS_REQ;
+
+	/* Skip all PACED only entries if IU is not available */
+	if ((*ppr_options & MSG_EXT_PPR_IU_REQ) == 0
+	 && *period < AHD_SYNCRATE_DT)
+		*period = AHD_SYNCRATE_DT;
+
+	/* Skip all DT only entries if DT is not available */
+	if ((*ppr_options & MSG_EXT_PPR_DT_REQ) == 0
+	 && *period < AHD_SYNCRATE_ULTRA2)
+		*period = AHD_SYNCRATE_ULTRA2;
+}
+
+/*
+ * Truncate the given synchronous offset to a value the
+ * current adapter type and syncrate are capable of.
+ */
+void
+ahd_validate_offset(struct ahd_softc *ahd,
+		    struct ahd_initiator_tinfo *tinfo,
+		    u_int period, u_int *offset, int wide,
+		    role_t role)
+{
+	u_int maxoffset;
+
+	/* Limit offset to what we can do */
+	if (period == 0)
+		maxoffset = 0;
+	else if (period <= AHD_SYNCRATE_PACED) {
+		if ((ahd->bugs & AHD_PACED_NEGTABLE_BUG) != 0)
+			maxoffset = MAX_OFFSET_PACED_BUG;
+		else
+			maxoffset = MAX_OFFSET_PACED;
+	} else
+		maxoffset = MAX_OFFSET_NON_PACED;
+	*offset = MIN(*offset, maxoffset);
+	if (tinfo != NULL) {
+		if (role == ROLE_TARGET)
+			*offset = MIN(*offset, tinfo->user.offset);
+		else
+			*offset = MIN(*offset, tinfo->goal.offset);
+	}
+}
+
+/*
+ * Truncate the given transfer width parameter to a value the
+ * current adapter type is capable of.
+ */
+void
+ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo,
+		   u_int *bus_width, role_t role)
+{
+	switch (*bus_width) {
+	default:
+		if (ahd->features & AHD_WIDE) {
+			/* Respond Wide */
+			*bus_width = MSG_EXT_WDTR_BUS_16_BIT;
+			break;
+		}
+		/* FALLTHROUGH */
+	case MSG_EXT_WDTR_BUS_8_BIT:
+		*bus_width = MSG_EXT_WDTR_BUS_8_BIT;
+		break;
+	}
+	if (tinfo != NULL) {
+		if (role == ROLE_TARGET)
+			*bus_width = MIN(tinfo->user.width, *bus_width);
+		else
+			*bus_width = MIN(tinfo->goal.width, *bus_width);
+	}
+}
+
+/*
+ * Update the bitmask of targets for which the controller should
+ * negotiate with at the next convenient oportunity.  This currently
+ * means the next time we send the initial identify messages for
+ * a new transaction.
+ */
+int
+ahd_update_neg_request(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
+		       struct ahd_tmode_tstate *tstate,
+		       struct ahd_initiator_tinfo *tinfo, ahd_neg_type neg_type)
+{
+	u_int auto_negotiate_orig;
+
+	auto_negotiate_orig = tstate->auto_negotiate;
+	if (neg_type == AHD_NEG_ALWAYS) {
+		/*
+		 * Force our "current" settings to be
+		 * unknown so that unless a bus reset
+		 * occurs the need to renegotiate is
+		 * recorded persistently.
+		 */
+		if ((ahd->features & AHD_WIDE) != 0)
+			tinfo->curr.width = AHD_WIDTH_UNKNOWN;
+		tinfo->curr.period = AHD_PERIOD_UNKNOWN;
+		tinfo->curr.offset = AHD_OFFSET_UNKNOWN;
+	}
+	if (tinfo->curr.period != tinfo->goal.period
+	 || tinfo->curr.width != tinfo->goal.width
+	 || tinfo->curr.offset != tinfo->goal.offset
+	 || tinfo->curr.ppr_options != tinfo->goal.ppr_options
+	 || (neg_type == AHD_NEG_IF_NON_ASYNC
+	  && (tinfo->goal.offset != 0
+	   || tinfo->goal.width != MSG_EXT_WDTR_BUS_8_BIT
+	   || tinfo->goal.ppr_options != 0)))
+		tstate->auto_negotiate |= devinfo->target_mask;
+	else
+		tstate->auto_negotiate &= ~devinfo->target_mask;
+
+	return (auto_negotiate_orig != tstate->auto_negotiate);
+}
+
+/*
+ * Update the user/goal/curr tables of synchronous negotiation
+ * parameters as well as, in the case of a current or active update,
+ * any data structures on the host controller.  In the case of an
+ * active update, the specified target is currently talking to us on
+ * the bus, so the transfer parameter update must take effect
+ * immediately.
+ */
+void
+ahd_set_syncrate(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
+		 u_int period, u_int offset, u_int ppr_options,
+		 u_int type, int paused)
+{
+	struct	ahd_initiator_tinfo *tinfo;
+	struct	ahd_tmode_tstate *tstate;
+	u_int	old_period;
+	u_int	old_offset;
+	u_int	old_ppr;
+	int	active;
+	int	update_needed;
+
+	active = (type & AHD_TRANS_ACTIVE) == AHD_TRANS_ACTIVE;
+	update_needed = 0;
+
+	if (period == 0 || offset == 0) {
+		period = 0;
+		offset = 0;
+	}
+
+	tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid,
+				    devinfo->target, &tstate);
+
+	if ((type & AHD_TRANS_USER) != 0) {
+		tinfo->user.period = period;
+		tinfo->user.offset = offset;
+		tinfo->user.ppr_options = ppr_options;
+	}
+
+	if ((type & AHD_TRANS_GOAL) != 0) {
+		tinfo->goal.period = period;
+		tinfo->goal.offset = offset;
+		tinfo->goal.ppr_options = ppr_options;
+	}
+
+	old_period = tinfo->curr.period;
+	old_offset = tinfo->curr.offset;
+	old_ppr	   = tinfo->curr.ppr_options;
+
+	if ((type & AHD_TRANS_CUR) != 0
+	 && (old_period != period
+	  || old_offset != offset
+	  || old_ppr != ppr_options)) {
+
+		update_needed++;
+
+		tinfo->curr.period = period;
+		tinfo->curr.offset = offset;
+		tinfo->curr.ppr_options = ppr_options;
+
+		ahd_send_async(ahd, devinfo->channel, devinfo->target,
+			       CAM_LUN_WILDCARD, AC_TRANSFER_NEG, NULL);
+		if (bootverbose) {
+			if (offset != 0) {
+				int options;
+
+				printf("%s: target %d synchronous with "
+				       "period = 0x%x, offset = 0x%x",
+				       ahd_name(ahd), devinfo->target,
+				       period, offset);
+				options = 0;
+				if ((ppr_options & MSG_EXT_PPR_RD_STRM) != 0) {
+					printf("(RDSTRM");
+					options++;
+				}
+				if ((ppr_options & MSG_EXT_PPR_DT_REQ) != 0) {
+					printf("%s", options ? "|DT" : "(DT");
+					options++;
+				}
+				if ((ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
+					printf("%s", options ? "|IU" : "(IU");
+					options++;
+				}
+				if ((ppr_options & MSG_EXT_PPR_RTI) != 0) {
+					printf("%s", options ? "|RTI" : "(RTI");
+					options++;
+				}
+				if ((ppr_options & MSG_EXT_PPR_QAS_REQ) != 0) {
+					printf("%s", options ? "|QAS" : "(QAS");
+					options++;
+				}
+				if (options != 0)
+					printf(")\n");
+				else
+					printf("\n");
+			} else {
+				printf("%s: target %d using "
+				       "asynchronous transfers%s\n",
+				       ahd_name(ahd), devinfo->target,
+				       (ppr_options & MSG_EXT_PPR_QAS_REQ) != 0
+				     ?  "(QAS)" : "");
+			}
+		}
+	}
+	/*
+	 * Always refresh the neg-table to handle the case of the
+	 * sequencer setting the ENATNO bit for a MK_MESSAGE request.
+	 * We will always renegotiate in that case if this is a
+	 * packetized request.  Also manage the busfree expected flag
+	 * from this common routine so that we catch changes due to
+	 * WDTR or SDTR messages.
+	 */
+	if ((type & AHD_TRANS_CUR) != 0) {
+		if (!paused)
+			ahd_pause(ahd);
+		ahd_update_neg_table(ahd, devinfo, &tinfo->curr);
+		if (!paused)
+			ahd_unpause(ahd);
+		if (ahd->msg_type != MSG_TYPE_NONE) {
+			if ((old_ppr & MSG_EXT_PPR_IU_REQ)
+			 != (ppr_options & MSG_EXT_PPR_IU_REQ)) {
+#ifdef AHD_DEBUG
+				if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
+					ahd_print_devinfo(ahd, devinfo);
+					printf("Expecting IU Change busfree\n");
+				}
+#endif
+				ahd->msg_flags |= MSG_FLAG_EXPECT_PPR_BUSFREE
+					       |  MSG_FLAG_IU_REQ_CHANGED;
+			}
+			if ((old_ppr & MSG_EXT_PPR_IU_REQ) != 0) {
+#ifdef AHD_DEBUG
+				if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
+					printf("PPR with IU_REQ outstanding\n");
+#endif
+				ahd->msg_flags |= MSG_FLAG_EXPECT_PPR_BUSFREE;
+			}
+		}
+	}
+
+	update_needed += ahd_update_neg_request(ahd, devinfo, tstate,
+						tinfo, AHD_NEG_TO_GOAL);
+
+	if (update_needed && active)
+		ahd_update_pending_scbs(ahd);
+}
+
+/*
+ * Update the user/goal/curr tables of wide negotiation
+ * parameters as well as, in the case of a current or active update,
+ * any data structures on the host controller.  In the case of an
+ * active update, the specified target is currently talking to us on
+ * the bus, so the transfer parameter update must take effect
+ * immediately.
+ */
+void
+ahd_set_width(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
+	      u_int width, u_int type, int paused)
+{
+	struct	ahd_initiator_tinfo *tinfo;
+	struct	ahd_tmode_tstate *tstate;
+	u_int	oldwidth;
+	int	active;
+	int	update_needed;
+
+	active = (type & AHD_TRANS_ACTIVE) == AHD_TRANS_ACTIVE;
+	update_needed = 0;
+	tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid,
+				    devinfo->target, &tstate);
+
+	if ((type & AHD_TRANS_USER) != 0)
+		tinfo->user.width = width;
+
+	if ((type & AHD_TRANS_GOAL) != 0)
+		tinfo->goal.width = width;
+
+	oldwidth = tinfo->curr.width;
+	if ((type & AHD_TRANS_CUR) != 0 && oldwidth != width) {
+
+		update_needed++;
+
+		tinfo->curr.width = width;
+		ahd_send_async(ahd, devinfo->channel, devinfo->target,
+			       CAM_LUN_WILDCARD, AC_TRANSFER_NEG, NULL);
+		if (bootverbose) {
+			printf("%s: target %d using %dbit transfers\n",
+			       ahd_name(ahd), devinfo->target,
+			       8 * (0x01 << width));
+		}
+	}
+
+	if ((type & AHD_TRANS_CUR) != 0) {
+		if (!paused)
+			ahd_pause(ahd);
+		ahd_update_neg_table(ahd, devinfo, &tinfo->curr);
+		if (!paused)
+			ahd_unpause(ahd);
+	}
+
+	update_needed += ahd_update_neg_request(ahd, devinfo, tstate,
+						tinfo, AHD_NEG_TO_GOAL);
+	if (update_needed && active)
+		ahd_update_pending_scbs(ahd);
+
+}
+
+/*
+ * Update the current state of tagged queuing for a given target.
+ */
+void
+ahd_set_tags(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
+	     ahd_queue_alg alg)
+{
+	ahd_platform_set_tags(ahd, devinfo, alg);
+	ahd_send_async(ahd, devinfo->channel, devinfo->target,
+		       devinfo->lun, AC_TRANSFER_NEG, &alg);
+}
+
+static void
+ahd_update_neg_table(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
+		     struct ahd_transinfo *tinfo)
+{
+	ahd_mode_state	saved_modes;
+	u_int		period;
+	u_int		ppr_opts;
+	u_int		con_opts;
+	u_int		offset;
+	u_int		saved_negoaddr;
+	uint8_t		iocell_opts[sizeof(ahd->iocell_opts)];
+
+	saved_modes = ahd_save_modes(ahd);
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+
+	saved_negoaddr = ahd_inb(ahd, NEGOADDR);
+	ahd_outb(ahd, NEGOADDR, devinfo->target);
+	period = tinfo->period;
+	offset = tinfo->offset;
+	memcpy(iocell_opts, ahd->iocell_opts, sizeof(ahd->iocell_opts)); 
+	ppr_opts = tinfo->ppr_options & (MSG_EXT_PPR_QAS_REQ|MSG_EXT_PPR_DT_REQ
+					|MSG_EXT_PPR_IU_REQ|MSG_EXT_PPR_RTI);
+	con_opts = 0;
+	if (period == 0)
+		period = AHD_SYNCRATE_ASYNC;
+	if (period == AHD_SYNCRATE_160) {
+
+		if ((ahd->bugs & AHD_PACED_NEGTABLE_BUG) != 0) {
+			/*
+			 * When the SPI4 spec was finalized, PACE transfers
+			 * was not made a configurable option in the PPR
+			 * message.  Instead it is assumed to be enabled for
+			 * any syncrate faster than 80MHz.  Nevertheless,
+			 * Harpoon2A4 allows this to be configurable.
+			 *
+			 * Harpoon2A4 also assumes at most 2 data bytes per
+			 * negotiated REQ/ACK offset.  Paced transfers take
+			 * 4, so we must adjust our offset.
+			 */
+			ppr_opts |= PPROPT_PACE;
+			offset *= 2;
+
+			/*
+			 * Harpoon2A assumed that there would be a
+			 * fallback rate between 160MHz and 80Mhz,
+			 * so 7 is used as the period factor rather
+			 * than 8 for 160MHz.
+			 */
+			period = AHD_SYNCRATE_REVA_160;
+		}
+		if ((tinfo->ppr_options & MSG_EXT_PPR_PCOMP_EN) == 0)
+			iocell_opts[AHD_PRECOMP_SLEW_INDEX] &=
+			    ~AHD_PRECOMP_MASK;
+	} else {
+		/*
+		 * Precomp should be disabled for non-paced transfers.
+		 */
+		iocell_opts[AHD_PRECOMP_SLEW_INDEX] &= ~AHD_PRECOMP_MASK;
+
+		if ((ahd->features & AHD_NEW_IOCELL_OPTS) != 0
+		 && (ppr_opts & MSG_EXT_PPR_DT_REQ) != 0) {
+			/*
+			 * Slow down our CRC interval to be
+			 * compatible with devices that can't
+			 * handle a CRC at full speed.
+			 */
+			con_opts |= ENSLOWCRC;
+		}
+	}
+
+	ahd_outb(ahd, ANNEXCOL, AHD_ANNEXCOL_PRECOMP_SLEW);
+	ahd_outb(ahd, ANNEXDAT, iocell_opts[AHD_PRECOMP_SLEW_INDEX]);
+	ahd_outb(ahd, ANNEXCOL, AHD_ANNEXCOL_AMPLITUDE);
+	ahd_outb(ahd, ANNEXDAT, iocell_opts[AHD_AMPLITUDE_INDEX]);
+
+	ahd_outb(ahd, NEGPERIOD, period);
+	ahd_outb(ahd, NEGPPROPTS, ppr_opts);
+	ahd_outb(ahd, NEGOFFSET, offset);
+
+	if (tinfo->width == MSG_EXT_WDTR_BUS_16_BIT)
+		con_opts |= WIDEXFER;
+
+	/*
+	 * During packetized transfers, the target will
+	 * give us the oportunity to send command packets
+	 * without us asserting attention.
+	 */
+	if ((tinfo->ppr_options & MSG_EXT_PPR_IU_REQ) == 0)
+		con_opts |= ENAUTOATNO;
+	ahd_outb(ahd, NEGCONOPTS, con_opts);
+	ahd_outb(ahd, NEGOADDR, saved_negoaddr);
+	ahd_restore_modes(ahd, saved_modes);
+}
+
+/*
+ * When the transfer settings for a connection change, setup for
+ * negotiation in pending SCBs to effect the change as quickly as
+ * possible.  We also cancel any negotiations that are scheduled
+ * for inflight SCBs that have not been started yet.
+ */
+static void
+ahd_update_pending_scbs(struct ahd_softc *ahd)
+{
+	struct		scb *pending_scb;
+	int		pending_scb_count;
+	int		i;
+	int		paused;
+	u_int		saved_scbptr;
+	ahd_mode_state	saved_modes;
+
+	/*
+	 * Traverse the pending SCB list and ensure that all of the
+	 * SCBs there have the proper settings.  We can only safely
+	 * clear the negotiation required flag (setting requires the
+	 * execution queue to be modified) and this is only possible
+	 * if we are not already attempting to select out for this
+	 * SCB.  For this reason, all callers only call this routine
+	 * if we are changing the negotiation settings for the currently
+	 * active transaction on the bus.
+	 */
+	pending_scb_count = 0;
+	LIST_FOREACH(pending_scb, &ahd->pending_scbs, pending_links) {
+		struct ahd_devinfo devinfo;
+		struct hardware_scb *pending_hscb;
+		struct ahd_initiator_tinfo *tinfo;
+		struct ahd_tmode_tstate *tstate;
+
+		ahd_scb_devinfo(ahd, &devinfo, pending_scb);
+		tinfo = ahd_fetch_transinfo(ahd, devinfo.channel,
+					    devinfo.our_scsiid,
+					    devinfo.target, &tstate);
+		pending_hscb = pending_scb->hscb;
+		if ((tstate->auto_negotiate & devinfo.target_mask) == 0
+		 && (pending_scb->flags & SCB_AUTO_NEGOTIATE) != 0) {
+			pending_scb->flags &= ~SCB_AUTO_NEGOTIATE;
+			pending_hscb->control &= ~MK_MESSAGE;
+		}
+		ahd_sync_scb(ahd, pending_scb,
+			     BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
+		pending_scb_count++;
+	}
+
+	if (pending_scb_count == 0)
+		return;
+
+	if (ahd_is_paused(ahd)) {
+		paused = 1;
+	} else {
+		paused = 0;
+		ahd_pause(ahd);
+	}
+
+	/*
+	 * Force the sequencer to reinitialize the selection for
+	 * the command at the head of the execution queue if it
+	 * has already been setup.  The negotiation changes may
+	 * effect whether we select-out with ATN.
+	 */
+	saved_modes = ahd_save_modes(ahd);
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+	ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
+	saved_scbptr = ahd_get_scbptr(ahd);
+	/* Ensure that the hscbs down on the card match the new information */
+	for (i = 0; i < ahd->scb_data.maxhscbs; i++) {
+		struct	hardware_scb *pending_hscb;
+		u_int	control;
+		u_int	scb_tag;
+
+		ahd_set_scbptr(ahd, i);
+		scb_tag = i;
+		pending_scb = ahd_lookup_scb(ahd, scb_tag);
+		if (pending_scb == NULL)
+			continue;
+
+		pending_hscb = pending_scb->hscb;
+		control = ahd_inb_scbram(ahd, SCB_CONTROL);
+		control &= ~MK_MESSAGE;
+		control |= pending_hscb->control & MK_MESSAGE;
+		ahd_outb(ahd, SCB_CONTROL, control);
+	}
+	ahd_set_scbptr(ahd, saved_scbptr);
+	ahd_restore_modes(ahd, saved_modes);
+
+	if (paused == 0)
+		ahd_unpause(ahd);
+}
+
+/**************************** Pathing Information *****************************/
+static void
+ahd_fetch_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
+{
+	ahd_mode_state	saved_modes;
+	u_int		saved_scsiid;
+	role_t		role;
+	int		our_id;
+
+	saved_modes = ahd_save_modes(ahd);
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+
+	if (ahd_inb(ahd, SSTAT0) & TARGET)
+		role = ROLE_TARGET;
+	else
+		role = ROLE_INITIATOR;
+
+	if (role == ROLE_TARGET
+	 && (ahd_inb(ahd, SEQ_FLAGS) & CMDPHASE_PENDING) != 0) {
+		/* We were selected, so pull our id from TARGIDIN */
+		our_id = ahd_inb(ahd, TARGIDIN) & OID;
+	} else if (role == ROLE_TARGET)
+		our_id = ahd_inb(ahd, TOWNID);
+	else
+		our_id = ahd_inb(ahd, IOWNID);
+
+	saved_scsiid = ahd_inb(ahd, SAVED_SCSIID);
+	ahd_compile_devinfo(devinfo,
+			    our_id,
+			    SCSIID_TARGET(ahd, saved_scsiid),
+			    ahd_inb(ahd, SAVED_LUN),
+			    SCSIID_CHANNEL(ahd, saved_scsiid),
+			    role);
+	ahd_restore_modes(ahd, saved_modes);
+}
+
+void
+ahd_print_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
+{
+	printf("%s:%c:%d:%d: ", ahd_name(ahd), 'A',
+	       devinfo->target, devinfo->lun);
+}
+
+struct ahd_phase_table_entry*
+ahd_lookup_phase_entry(int phase)
+{
+	struct ahd_phase_table_entry *entry;
+	struct ahd_phase_table_entry *last_entry;
+
+	/*
+	 * num_phases doesn't include the default entry which
+	 * will be returned if the phase doesn't match.
+	 */
+	last_entry = &ahd_phase_table[num_phases];
+	for (entry = ahd_phase_table; entry < last_entry; entry++) {
+		if (phase == entry->phase)
+			break;
+	}
+	return (entry);
+}
+
+void
+ahd_compile_devinfo(struct ahd_devinfo *devinfo, u_int our_id, u_int target,
+		    u_int lun, char channel, role_t role)
+{
+	devinfo->our_scsiid = our_id;
+	devinfo->target = target;
+	devinfo->lun = lun;
+	devinfo->target_offset = target;
+	devinfo->channel = channel;
+	devinfo->role = role;
+	if (channel == 'B')
+		devinfo->target_offset += 8;
+	devinfo->target_mask = (0x01 << devinfo->target_offset);
+}
+
+static void
+ahd_scb_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
+		struct scb *scb)
+{
+	role_t	role;
+	int	our_id;
+
+	our_id = SCSIID_OUR_ID(scb->hscb->scsiid);
+	role = ROLE_INITIATOR;
+	if ((scb->hscb->control & TARGET_SCB) != 0)
+		role = ROLE_TARGET;
+	ahd_compile_devinfo(devinfo, our_id, SCB_GET_TARGET(ahd, scb),
+			    SCB_GET_LUN(scb), SCB_GET_CHANNEL(ahd, scb), role);
+}
+
+
+/************************ Message Phase Processing ****************************/
+/*
+ * When an initiator transaction with the MK_MESSAGE flag either reconnects
+ * or enters the initial message out phase, we are interrupted.  Fill our
+ * outgoing message buffer with the appropriate message and beging handing
+ * the message phase(s) manually.
+ */
+static void
+ahd_setup_initiator_msgout(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
+			   struct scb *scb)
+{
+	/*
+	 * To facilitate adding multiple messages together,
+	 * each routine should increment the index and len
+	 * variables instead of setting them explicitly.
+	 */
+	ahd->msgout_index = 0;
+	ahd->msgout_len = 0;
+
+	if (ahd_currently_packetized(ahd))
+		ahd->msg_flags |= MSG_FLAG_PACKETIZED;
+
+	if (ahd->send_msg_perror
+	 && ahd_inb(ahd, MSG_OUT) == HOST_MSG) {
+		ahd->msgout_buf[ahd->msgout_index++] = ahd->send_msg_perror;
+		ahd->msgout_len++;
+		ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
+#ifdef AHD_DEBUG
+		if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
+			printf("Setting up for Parity Error delivery\n");
+#endif
+		return;
+	} else if (scb == NULL) {
+		printf("%s: WARNING. No pending message for "
+		       "I_T msgin.  Issuing NO-OP\n", ahd_name(ahd));
+		ahd->msgout_buf[ahd->msgout_index++] = MSG_NOOP;
+		ahd->msgout_len++;
+		ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
+		return;
+	}
+
+	if ((scb->flags & SCB_DEVICE_RESET) == 0
+	 && (scb->flags & SCB_PACKETIZED) == 0
+	 && ahd_inb(ahd, MSG_OUT) == MSG_IDENTIFYFLAG) {
+		u_int identify_msg;
+
+		identify_msg = MSG_IDENTIFYFLAG | SCB_GET_LUN(scb);
+		if ((scb->hscb->control & DISCENB) != 0)
+			identify_msg |= MSG_IDENTIFY_DISCFLAG;
+		ahd->msgout_buf[ahd->msgout_index++] = identify_msg;
+		ahd->msgout_len++;
+
+		if ((scb->hscb->control & TAG_ENB) != 0) {
+			ahd->msgout_buf[ahd->msgout_index++] =
+			    scb->hscb->control & (TAG_ENB|SCB_TAG_TYPE);
+			ahd->msgout_buf[ahd->msgout_index++] = SCB_GET_TAG(scb);
+			ahd->msgout_len += 2;
+		}
+	}
+
+	if (scb->flags & SCB_DEVICE_RESET) {
+		ahd->msgout_buf[ahd->msgout_index++] = MSG_BUS_DEV_RESET;
+		ahd->msgout_len++;
+		ahd_print_path(ahd, scb);
+		printf("Bus Device Reset Message Sent\n");
+		/*
+		 * Clear our selection hardware in advance of
+		 * the busfree.  We may have an entry in the waiting
+		 * Q for this target, and we don't want to go about
+		 * selecting while we handle the busfree and blow it
+		 * away.
+		 */
+		ahd_outb(ahd, SCSISEQ0, 0);
+	} else if ((scb->flags & SCB_ABORT) != 0) {
+
+		if ((scb->hscb->control & TAG_ENB) != 0) {
+			ahd->msgout_buf[ahd->msgout_index++] = MSG_ABORT_TAG;
+		} else {
+			ahd->msgout_buf[ahd->msgout_index++] = MSG_ABORT;
+		}
+		ahd->msgout_len++;
+		ahd_print_path(ahd, scb);
+		printf("Abort%s Message Sent\n",
+		       (scb->hscb->control & TAG_ENB) != 0 ? " Tag" : "");
+		/*
+		 * Clear our selection hardware in advance of
+		 * the busfree.  We may have an entry in the waiting
+		 * Q for this target, and we don't want to go about
+		 * selecting while we handle the busfree and blow it
+		 * away.
+		 */
+		ahd_outb(ahd, SCSISEQ0, 0);
+	} else if ((scb->flags & (SCB_AUTO_NEGOTIATE|SCB_NEGOTIATE)) != 0) {
+		ahd_build_transfer_msg(ahd, devinfo);
+		/*
+		 * Clear our selection hardware in advance of potential
+		 * PPR IU status change busfree.  We may have an entry in
+		 * the waiting Q for this target, and we don't want to go
+		 * about selecting while we handle the busfree and blow
+		 * it away.
+		 */
+		ahd_outb(ahd, SCSISEQ0, 0);
+	} else {
+		printf("ahd_intr: AWAITING_MSG for an SCB that "
+		       "does not have a waiting message\n");
+		printf("SCSIID = %x, target_mask = %x\n", scb->hscb->scsiid,
+		       devinfo->target_mask);
+		panic("SCB = %d, SCB Control = %x:%x, MSG_OUT = %x "
+		      "SCB flags = %x", SCB_GET_TAG(scb), scb->hscb->control,
+		      ahd_inb(ahd, SCB_CONTROL), ahd_inb(ahd, MSG_OUT),
+		      scb->flags);
+	}
+
+	/*
+	 * Clear the MK_MESSAGE flag from the SCB so we aren't
+	 * asked to send this message again.
+	 */
+	ahd_outb(ahd, SCB_CONTROL,
+		 ahd_inb_scbram(ahd, SCB_CONTROL) & ~MK_MESSAGE);
+	scb->hscb->control &= ~MK_MESSAGE;
+	ahd->msgout_index = 0;
+	ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
+}
+
+/*
+ * Build an appropriate transfer negotiation message for the
+ * currently active target.
+ */
+static void
+ahd_build_transfer_msg(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
+{
+	/*
+	 * We need to initiate transfer negotiations.
+	 * If our current and goal settings are identical,
+	 * we want to renegotiate due to a check condition.
+	 */
+	struct	ahd_initiator_tinfo *tinfo;
+	struct	ahd_tmode_tstate *tstate;
+	int	dowide;
+	int	dosync;
+	int	doppr;
+	u_int	period;
+	u_int	ppr_options;
+	u_int	offset;
+
+	tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid,
+				    devinfo->target, &tstate);
+	/*
+	 * Filter our period based on the current connection.
+	 * If we can't perform DT transfers on this segment (not in LVD
+	 * mode for instance), then our decision to issue a PPR message
+	 * may change.
+	 */
+	period = tinfo->goal.period;
+	offset = tinfo->goal.offset;
+	ppr_options = tinfo->goal.ppr_options;
+	/* Target initiated PPR is not allowed in the SCSI spec */
+	if (devinfo->role == ROLE_TARGET)
+		ppr_options = 0;
+	ahd_devlimited_syncrate(ahd, tinfo, &period,
+				&ppr_options, devinfo->role);
+	dowide = tinfo->curr.width != tinfo->goal.width;
+	dosync = tinfo->curr.offset != offset || tinfo->curr.period != period;
+	/*
+	 * Only use PPR if we have options that need it, even if the device
+	 * claims to support it.  There might be an expander in the way
+	 * that doesn't.
+	 */
+	doppr = ppr_options != 0;
+
+	if (!dowide && !dosync && !doppr) {
+		dowide = tinfo->goal.width != MSG_EXT_WDTR_BUS_8_BIT;
+		dosync = tinfo->goal.offset != 0;
+	}
+
+	if (!dowide && !dosync && !doppr) {
+		/*
+		 * Force async with a WDTR message if we have a wide bus,
+		 * or just issue an SDTR with a 0 offset.
+		 */
+		if ((ahd->features & AHD_WIDE) != 0)
+			dowide = 1;
+		else
+			dosync = 1;
+
+		if (bootverbose) {
+			ahd_print_devinfo(ahd, devinfo);
+			printf("Ensuring async\n");
+		}
+	}
+	/* Target initiated PPR is not allowed in the SCSI spec */
+	if (devinfo->role == ROLE_TARGET)
+		doppr = 0;
+
+	/*
+	 * Both the PPR message and SDTR message require the
+	 * goal syncrate to be limited to what the target device
+	 * is capable of handling (based on whether an LVD->SE
+	 * expander is on the bus), so combine these two cases.
+	 * Regardless, guarantee that if we are using WDTR and SDTR
+	 * messages that WDTR comes first.
+	 */
+	if (doppr || (dosync && !dowide)) {
+
+		offset = tinfo->goal.offset;
+		ahd_validate_offset(ahd, tinfo, period, &offset,
+				    doppr ? tinfo->goal.width
+					  : tinfo->curr.width,
+				    devinfo->role);
+		if (doppr) {
+			ahd_construct_ppr(ahd, devinfo, period, offset,
+					  tinfo->goal.width, ppr_options);
+		} else {
+			ahd_construct_sdtr(ahd, devinfo, period, offset);
+		}
+	} else {
+		ahd_construct_wdtr(ahd, devinfo, tinfo->goal.width);
+	}
+}
+
+/*
+ * Build a synchronous negotiation message in our message
+ * buffer based on the input parameters.
+ */
+static void
+ahd_construct_sdtr(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
+		   u_int period, u_int offset)
+{
+	if (offset == 0)
+		period = AHD_ASYNC_XFER_PERIOD;
+	ahd->msgout_buf[ahd->msgout_index++] = MSG_EXTENDED;
+	ahd->msgout_buf[ahd->msgout_index++] = MSG_EXT_SDTR_LEN;
+	ahd->msgout_buf[ahd->msgout_index++] = MSG_EXT_SDTR;
+	ahd->msgout_buf[ahd->msgout_index++] = period;
+	ahd->msgout_buf[ahd->msgout_index++] = offset;
+	ahd->msgout_len += 5;
+	if (bootverbose) {
+		printf("(%s:%c:%d:%d): Sending SDTR period %x, offset %x\n",
+		       ahd_name(ahd), devinfo->channel, devinfo->target,
+		       devinfo->lun, period, offset);
+	}
+}
+
+/*
+ * Build a wide negotiateion message in our message
+ * buffer based on the input parameters.
+ */
+static void
+ahd_construct_wdtr(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
+		   u_int bus_width)
+{
+	ahd->msgout_buf[ahd->msgout_index++] = MSG_EXTENDED;
+	ahd->msgout_buf[ahd->msgout_index++] = MSG_EXT_WDTR_LEN;
+	ahd->msgout_buf[ahd->msgout_index++] = MSG_EXT_WDTR;
+	ahd->msgout_buf[ahd->msgout_index++] = bus_width;
+	ahd->msgout_len += 4;
+	if (bootverbose) {
+		printf("(%s:%c:%d:%d): Sending WDTR %x\n",
+		       ahd_name(ahd), devinfo->channel, devinfo->target,
+		       devinfo->lun, bus_width);
+	}
+}
+
+/*
+ * Build a parallel protocol request message in our message
+ * buffer based on the input parameters.
+ */
+static void
+ahd_construct_ppr(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
+		  u_int period, u_int offset, u_int bus_width,
+		  u_int ppr_options)
+{
+	/*
+	 * Always request precompensation from
+	 * the other target if we are running
+	 * at paced syncrates.
+	 */
+	if (period <= AHD_SYNCRATE_PACED)
+		ppr_options |= MSG_EXT_PPR_PCOMP_EN;
+	if (offset == 0)
+		period = AHD_ASYNC_XFER_PERIOD;
+	ahd->msgout_buf[ahd->msgout_index++] = MSG_EXTENDED;
+	ahd->msgout_buf[ahd->msgout_index++] = MSG_EXT_PPR_LEN;
+	ahd->msgout_buf[ahd->msgout_index++] = MSG_EXT_PPR;
+	ahd->msgout_buf[ahd->msgout_index++] = period;
+	ahd->msgout_buf[ahd->msgout_index++] = 0;
+	ahd->msgout_buf[ahd->msgout_index++] = offset;
+	ahd->msgout_buf[ahd->msgout_index++] = bus_width;
+	ahd->msgout_buf[ahd->msgout_index++] = ppr_options;
+	ahd->msgout_len += 8;
+	if (bootverbose) {
+		printf("(%s:%c:%d:%d): Sending PPR bus_width %x, period %x, "
+		       "offset %x, ppr_options %x\n", ahd_name(ahd),
+		       devinfo->channel, devinfo->target, devinfo->lun,
+		       bus_width, period, offset, ppr_options);
+	}
+}
+
+/*
+ * Clear any active message state.
+ */
+static void
+ahd_clear_msg_state(struct ahd_softc *ahd)
+{
+	ahd_mode_state saved_modes;
+
+	saved_modes = ahd_save_modes(ahd);
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+	ahd->send_msg_perror = 0;
+	ahd->msg_flags = MSG_FLAG_NONE;
+	ahd->msgout_len = 0;
+	ahd->msgin_index = 0;
+	ahd->msg_type = MSG_TYPE_NONE;
+	if ((ahd_inb(ahd, SCSISIGO) & ATNO) != 0) {
+		/*
+		 * The target didn't care to respond to our
+		 * message request, so clear ATN.
+		 */
+		ahd_outb(ahd, CLRSINT1, CLRATNO);
+	}
+	ahd_outb(ahd, MSG_OUT, MSG_NOOP);
+	ahd_outb(ahd, SEQ_FLAGS2,
+		 ahd_inb(ahd, SEQ_FLAGS2) & ~TARGET_MSG_PENDING);
+	ahd_restore_modes(ahd, saved_modes);
+}
+
+/*
+ * Manual message loop handler.
+ */
+static void
+ahd_handle_message_phase(struct ahd_softc *ahd)
+{ 
+	struct	ahd_devinfo devinfo;
+	u_int	bus_phase;
+	int	end_session;
+
+	ahd_fetch_devinfo(ahd, &devinfo);
+	end_session = FALSE;
+	bus_phase = ahd_inb(ahd, LASTPHASE);
+
+	if ((ahd_inb(ahd, LQISTAT2) & LQIPHASE_OUTPKT) != 0) {
+		printf("LQIRETRY for LQIPHASE_OUTPKT\n");
+		ahd_outb(ahd, LQCTL2, LQIRETRY);
+	}
+reswitch:
+	switch (ahd->msg_type) {
+	case MSG_TYPE_INITIATOR_MSGOUT:
+	{
+		int lastbyte;
+		int phasemis;
+		int msgdone;
+
+		if (ahd->msgout_len == 0 && ahd->send_msg_perror == 0)
+			panic("HOST_MSG_LOOP interrupt with no active message");
+
+#ifdef AHD_DEBUG
+		if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
+			ahd_print_devinfo(ahd, &devinfo);
+			printf("INITIATOR_MSG_OUT");
+		}
+#endif
+		phasemis = bus_phase != P_MESGOUT;
+		if (phasemis) {
+#ifdef AHD_DEBUG
+			if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
+				printf(" PHASEMIS %s\n",
+				       ahd_lookup_phase_entry(bus_phase)
+							     ->phasemsg);
+			}
+#endif
+			if (bus_phase == P_MESGIN) {
+				/*
+				 * Change gears and see if
+				 * this messages is of interest to
+				 * us or should be passed back to
+				 * the sequencer.
+				 */
+				ahd_outb(ahd, CLRSINT1, CLRATNO);
+				ahd->send_msg_perror = 0;
+				ahd->msg_type = MSG_TYPE_INITIATOR_MSGIN;
+				ahd->msgin_index = 0;
+				goto reswitch;
+			}
+			end_session = TRUE;
+			break;
+		}
+
+		if (ahd->send_msg_perror) {
+			ahd_outb(ahd, CLRSINT1, CLRATNO);
+			ahd_outb(ahd, CLRSINT1, CLRREQINIT);
+#ifdef AHD_DEBUG
+			if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
+				printf(" byte 0x%x\n", ahd->send_msg_perror);
+#endif
+			/*
+			 * If we are notifying the target of a CRC error
+			 * during packetized operations, the target is
+			 * within its rights to acknowledge our message
+			 * with a busfree.
+			 */
+			if ((ahd->msg_flags & MSG_FLAG_PACKETIZED) != 0
+			 && ahd->send_msg_perror == MSG_INITIATOR_DET_ERR)
+				ahd->msg_flags |= MSG_FLAG_EXPECT_IDE_BUSFREE;
+
+			ahd_outb(ahd, RETURN_2, ahd->send_msg_perror);
+			ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_WRITE);
+			break;
+		}
+
+		msgdone	= ahd->msgout_index == ahd->msgout_len;
+		if (msgdone) {
+			/*
+			 * The target has requested a retry.
+			 * Re-assert ATN, reset our message index to
+			 * 0, and try again.
+			 */
+			ahd->msgout_index = 0;
+			ahd_assert_atn(ahd);
+		}
+
+		lastbyte = ahd->msgout_index == (ahd->msgout_len - 1);
+		if (lastbyte) {
+			/* Last byte is signified by dropping ATN */
+			ahd_outb(ahd, CLRSINT1, CLRATNO);
+		}
+
+		/*
+		 * Clear our interrupt status and present
+		 * the next byte on the bus.
+		 */
+		ahd_outb(ahd, CLRSINT1, CLRREQINIT);
+#ifdef AHD_DEBUG
+		if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
+			printf(" byte 0x%x\n",
+			       ahd->msgout_buf[ahd->msgout_index]);
+#endif
+		ahd_outb(ahd, RETURN_2, ahd->msgout_buf[ahd->msgout_index++]);
+		ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_WRITE);
+		break;
+	}
+	case MSG_TYPE_INITIATOR_MSGIN:
+	{
+		int phasemis;
+		int message_done;
+
+#ifdef AHD_DEBUG
+		if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
+			ahd_print_devinfo(ahd, &devinfo);
+			printf("INITIATOR_MSG_IN");
+		}
+#endif
+		phasemis = bus_phase != P_MESGIN;
+		if (phasemis) {
+#ifdef AHD_DEBUG
+			if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
+				printf(" PHASEMIS %s\n",
+				       ahd_lookup_phase_entry(bus_phase)
+							     ->phasemsg);
+			}
+#endif
+			ahd->msgin_index = 0;
+			if (bus_phase == P_MESGOUT
+			 && (ahd->send_msg_perror != 0
+			  || (ahd->msgout_len != 0
+			   && ahd->msgout_index == 0))) {
+				ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
+				goto reswitch;
+			}
+			end_session = TRUE;
+			break;
+		}
+
+		/* Pull the byte in without acking it */
+		ahd->msgin_buf[ahd->msgin_index] = ahd_inb(ahd, SCSIBUS);
+#ifdef AHD_DEBUG
+		if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
+			printf(" byte 0x%x\n",
+			       ahd->msgin_buf[ahd->msgin_index]);
+#endif
+
+		message_done = ahd_parse_msg(ahd, &devinfo);
+
+		if (message_done) {
+			/*
+			 * Clear our incoming message buffer in case there
+			 * is another message following this one.
+			 */
+			ahd->msgin_index = 0;
+
+			/*
+			 * If this message illicited a response,
+			 * assert ATN so the target takes us to the
+			 * message out phase.
+			 */
+			if (ahd->msgout_len != 0) {
+#ifdef AHD_DEBUG
+				if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
+					ahd_print_devinfo(ahd, &devinfo);
+					printf("Asserting ATN for response\n");
+				}
+#endif
+				ahd_assert_atn(ahd);
+			}
+		} else 
+			ahd->msgin_index++;
+
+		if (message_done == MSGLOOP_TERMINATED) {
+			end_session = TRUE;
+		} else {
+			/* Ack the byte */
+			ahd_outb(ahd, CLRSINT1, CLRREQINIT);
+			ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_READ);
+		}
+		break;
+	}
+	case MSG_TYPE_TARGET_MSGIN:
+	{
+		int msgdone;
+		int msgout_request;
+
+		/*
+		 * By default, the message loop will continue.
+		 */
+		ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_TARG);
+
+		if (ahd->msgout_len == 0)
+			panic("Target MSGIN with no active message");
+
+		/*
+		 * If we interrupted a mesgout session, the initiator
+		 * will not know this until our first REQ.  So, we
+		 * only honor mesgout requests after we've sent our
+		 * first byte.
+		 */
+		if ((ahd_inb(ahd, SCSISIGI) & ATNI) != 0
+		 && ahd->msgout_index > 0)
+			msgout_request = TRUE;
+		else
+			msgout_request = FALSE;
+
+		if (msgout_request) {
+
+			/*
+			 * Change gears and see if
+			 * this messages is of interest to
+			 * us or should be passed back to
+			 * the sequencer.
+			 */
+			ahd->msg_type = MSG_TYPE_TARGET_MSGOUT;
+			ahd_outb(ahd, SCSISIGO, P_MESGOUT | BSYO);
+			ahd->msgin_index = 0;
+			/* Dummy read to REQ for first byte */
+			ahd_inb(ahd, SCSIDAT);
+			ahd_outb(ahd, SXFRCTL0,
+				 ahd_inb(ahd, SXFRCTL0) | SPIOEN);
+			break;
+		}
+
+		msgdone = ahd->msgout_index == ahd->msgout_len;
+		if (msgdone) {
+			ahd_outb(ahd, SXFRCTL0,
+				 ahd_inb(ahd, SXFRCTL0) & ~SPIOEN);
+			end_session = TRUE;
+			break;
+		}
+
+		/*
+		 * Present the next byte on the bus.
+		 */
+		ahd_outb(ahd, SXFRCTL0, ahd_inb(ahd, SXFRCTL0) | SPIOEN);
+		ahd_outb(ahd, SCSIDAT, ahd->msgout_buf[ahd->msgout_index++]);
+		break;
+	}
+	case MSG_TYPE_TARGET_MSGOUT:
+	{
+		int lastbyte;
+		int msgdone;
+
+		/*
+		 * By default, the message loop will continue.
+		 */
+		ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_TARG);
+
+		/*
+		 * The initiator signals that this is
+		 * the last byte by dropping ATN.
+		 */
+		lastbyte = (ahd_inb(ahd, SCSISIGI) & ATNI) == 0;
+
+		/*
+		 * Read the latched byte, but turn off SPIOEN first
+		 * so that we don't inadvertently cause a REQ for the
+		 * next byte.
+		 */
+		ahd_outb(ahd, SXFRCTL0, ahd_inb(ahd, SXFRCTL0) & ~SPIOEN);
+		ahd->msgin_buf[ahd->msgin_index] = ahd_inb(ahd, SCSIDAT);
+		msgdone = ahd_parse_msg(ahd, &devinfo);
+		if (msgdone == MSGLOOP_TERMINATED) {
+			/*
+			 * The message is *really* done in that it caused
+			 * us to go to bus free.  The sequencer has already
+			 * been reset at this point, so pull the ejection
+			 * handle.
+			 */
+			return;
+		}
+		
+		ahd->msgin_index++;
+
+		/*
+		 * XXX Read spec about initiator dropping ATN too soon
+		 *     and use msgdone to detect it.
+		 */
+		if (msgdone == MSGLOOP_MSGCOMPLETE) {
+			ahd->msgin_index = 0;
+
+			/*
+			 * If this message illicited a response, transition
+			 * to the Message in phase and send it.
+			 */
+			if (ahd->msgout_len != 0) {
+				ahd_outb(ahd, SCSISIGO, P_MESGIN | BSYO);
+				ahd_outb(ahd, SXFRCTL0,
+					 ahd_inb(ahd, SXFRCTL0) | SPIOEN);
+				ahd->msg_type = MSG_TYPE_TARGET_MSGIN;
+				ahd->msgin_index = 0;
+				break;
+			}
+		}
+
+		if (lastbyte)
+			end_session = TRUE;
+		else {
+			/* Ask for the next byte. */
+			ahd_outb(ahd, SXFRCTL0,
+				 ahd_inb(ahd, SXFRCTL0) | SPIOEN);
+		}
+
+		break;
+	}
+	default:
+		panic("Unknown REQINIT message type");
+	}
+
+	if (end_session) {
+		if ((ahd->msg_flags & MSG_FLAG_PACKETIZED) != 0) {
+			printf("%s: Returning to Idle Loop\n",
+			       ahd_name(ahd));
+			ahd_outb(ahd, LASTPHASE, P_BUSFREE);
+			ahd_clear_msg_state(ahd);
+			ahd_outb(ahd, SEQCTL0, FASTMODE|SEQRESET);
+		} else {
+			ahd_clear_msg_state(ahd);
+			ahd_outb(ahd, RETURN_1, EXIT_MSG_LOOP);
+		}
+	}
+}
+
+/*
+ * See if we sent a particular extended message to the target.
+ * If "full" is true, return true only if the target saw the full
+ * message.  If "full" is false, return true if the target saw at
+ * least the first byte of the message.
+ */
+static int
+ahd_sent_msg(struct ahd_softc *ahd, ahd_msgtype type, u_int msgval, int full)
+{
+	int found;
+	u_int index;
+
+	found = FALSE;
+	index = 0;
+
+	while (index < ahd->msgout_len) {
+		if (ahd->msgout_buf[index] == MSG_EXTENDED) {
+			u_int end_index;
+
+			end_index = index + 1 + ahd->msgout_buf[index + 1];
+			if (ahd->msgout_buf[index+2] == msgval
+			 && type == AHDMSG_EXT) {
+
+				if (full) {
+					if (ahd->msgout_index > end_index)
+						found = TRUE;
+				} else if (ahd->msgout_index > index)
+					found = TRUE;
+			}
+			index = end_index;
+		} else if (ahd->msgout_buf[index] >= MSG_SIMPLE_TASK
+			&& ahd->msgout_buf[index] <= MSG_IGN_WIDE_RESIDUE) {
+
+			/* Skip tag type and tag id or residue param*/
+			index += 2;
+		} else {
+			/* Single byte message */
+			if (type == AHDMSG_1B
+			 && ahd->msgout_index > index
+			 && (ahd->msgout_buf[index] == msgval
+			  || ((ahd->msgout_buf[index] & MSG_IDENTIFYFLAG) != 0
+			   && msgval == MSG_IDENTIFYFLAG)))
+				found = TRUE;
+			index++;
+		}
+
+		if (found)
+			break;
+	}
+	return (found);
+}
+
+/*
+ * Wait for a complete incoming message, parse it, and respond accordingly.
+ */
+static int
+ahd_parse_msg(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
+{
+	struct	ahd_initiator_tinfo *tinfo;
+	struct	ahd_tmode_tstate *tstate;
+	int	reject;
+	int	done;
+	int	response;
+
+	done = MSGLOOP_IN_PROG;
+	response = FALSE;
+	reject = FALSE;
+	tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid,
+				    devinfo->target, &tstate);
+
+	/*
+	 * Parse as much of the message as is available,
+	 * rejecting it if we don't support it.  When
+	 * the entire message is available and has been
+	 * handled, return MSGLOOP_MSGCOMPLETE, indicating
+	 * that we have parsed an entire message.
+	 *
+	 * In the case of extended messages, we accept the length
+	 * byte outright and perform more checking once we know the
+	 * extended message type.
+	 */
+	switch (ahd->msgin_buf[0]) {
+	case MSG_DISCONNECT:
+	case MSG_SAVEDATAPOINTER:
+	case MSG_CMDCOMPLETE:
+	case MSG_RESTOREPOINTERS:
+	case MSG_IGN_WIDE_RESIDUE:
+		/*
+		 * End our message loop as these are messages
+		 * the sequencer handles on its own.
+		 */
+		done = MSGLOOP_TERMINATED;
+		break;
+	case MSG_MESSAGE_REJECT:
+		response = ahd_handle_msg_reject(ahd, devinfo);
+		/* FALLTHROUGH */
+	case MSG_NOOP:
+		done = MSGLOOP_MSGCOMPLETE;
+		break;
+	case MSG_EXTENDED:
+	{
+		/* Wait for enough of the message to begin validation */
+		if (ahd->msgin_index < 2)
+			break;
+		switch (ahd->msgin_buf[2]) {
+		case MSG_EXT_SDTR:
+		{
+			u_int	 period;
+			u_int	 ppr_options;
+			u_int	 offset;
+			u_int	 saved_offset;
+			
+			if (ahd->msgin_buf[1] != MSG_EXT_SDTR_LEN) {
+				reject = TRUE;
+				break;
+			}
+
+			/*
+			 * Wait until we have both args before validating
+			 * and acting on this message.
+			 *
+			 * Add one to MSG_EXT_SDTR_LEN to account for
+			 * the extended message preamble.
+			 */
+			if (ahd->msgin_index < (MSG_EXT_SDTR_LEN + 1))
+				break;
+
+			period = ahd->msgin_buf[3];
+			ppr_options = 0;
+			saved_offset = offset = ahd->msgin_buf[4];
+			ahd_devlimited_syncrate(ahd, tinfo, &period,
+						&ppr_options, devinfo->role);
+			ahd_validate_offset(ahd, tinfo, period, &offset,
+					    tinfo->curr.width, devinfo->role);
+			if (bootverbose) {
+				printf("(%s:%c:%d:%d): Received "
+				       "SDTR period %x, offset %x\n\t"
+				       "Filtered to period %x, offset %x\n",
+				       ahd_name(ahd), devinfo->channel,
+				       devinfo->target, devinfo->lun,
+				       ahd->msgin_buf[3], saved_offset,
+				       period, offset);
+			}
+			ahd_set_syncrate(ahd, devinfo, period,
+					 offset, ppr_options,
+					 AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
+					 /*paused*/TRUE);
+
+			/*
+			 * See if we initiated Sync Negotiation
+			 * and didn't have to fall down to async
+			 * transfers.
+			 */
+			if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_SDTR, TRUE)) {
+				/* We started it */
+				if (saved_offset != offset) {
+					/* Went too low - force async */
+					reject = TRUE;
+				}
+			} else {
+				/*
+				 * Send our own SDTR in reply
+				 */
+				if (bootverbose
+				 && devinfo->role == ROLE_INITIATOR) {
+					printf("(%s:%c:%d:%d): Target "
+					       "Initiated SDTR\n",
+					       ahd_name(ahd), devinfo->channel,
+					       devinfo->target, devinfo->lun);
+				}
+				ahd->msgout_index = 0;
+				ahd->msgout_len = 0;
+				ahd_construct_sdtr(ahd, devinfo,
+						   period, offset);
+				ahd->msgout_index = 0;
+				response = TRUE;
+			}
+			done = MSGLOOP_MSGCOMPLETE;
+			break;
+		}
+		case MSG_EXT_WDTR:
+		{
+			u_int bus_width;
+			u_int saved_width;
+			u_int sending_reply;
+
+			sending_reply = FALSE;
+			if (ahd->msgin_buf[1] != MSG_EXT_WDTR_LEN) {
+				reject = TRUE;
+				break;
+			}
+
+			/*
+			 * Wait until we have our arg before validating
+			 * and acting on this message.
+			 *
+			 * Add one to MSG_EXT_WDTR_LEN to account for
+			 * the extended message preamble.
+			 */
+			if (ahd->msgin_index < (MSG_EXT_WDTR_LEN + 1))
+				break;
+
+			bus_width = ahd->msgin_buf[3];
+			saved_width = bus_width;
+			ahd_validate_width(ahd, tinfo, &bus_width,
+					   devinfo->role);
+			if (bootverbose) {
+				printf("(%s:%c:%d:%d): Received WDTR "
+				       "%x filtered to %x\n",
+				       ahd_name(ahd), devinfo->channel,
+				       devinfo->target, devinfo->lun,
+				       saved_width, bus_width);
+			}
+
+			if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_WDTR, TRUE)) {
+				/*
+				 * Don't send a WDTR back to the
+				 * target, since we asked first.
+				 * If the width went higher than our
+				 * request, reject it.
+				 */
+				if (saved_width > bus_width) {
+					reject = TRUE;
+					printf("(%s:%c:%d:%d): requested %dBit "
+					       "transfers.  Rejecting...\n",
+					       ahd_name(ahd), devinfo->channel,
+					       devinfo->target, devinfo->lun,
+					       8 * (0x01 << bus_width));
+					bus_width = 0;
+				}
+			} else {
+				/*
+				 * Send our own WDTR in reply
+				 */
+				if (bootverbose
+				 && devinfo->role == ROLE_INITIATOR) {
+					printf("(%s:%c:%d:%d): Target "
+					       "Initiated WDTR\n",
+					       ahd_name(ahd), devinfo->channel,
+					       devinfo->target, devinfo->lun);
+				}
+				ahd->msgout_index = 0;
+				ahd->msgout_len = 0;
+				ahd_construct_wdtr(ahd, devinfo, bus_width);
+				ahd->msgout_index = 0;
+				response = TRUE;
+				sending_reply = TRUE;
+			}
+			/*
+			 * After a wide message, we are async, but
+			 * some devices don't seem to honor this portion
+			 * of the spec.  Force a renegotiation of the
+			 * sync component of our transfer agreement even
+			 * if our goal is async.  By updating our width
+			 * after forcing the negotiation, we avoid
+			 * renegotiating for width.
+			 */
+			ahd_update_neg_request(ahd, devinfo, tstate,
+					       tinfo, AHD_NEG_ALWAYS);
+			ahd_set_width(ahd, devinfo, bus_width,
+				      AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
+				      /*paused*/TRUE);
+			if (sending_reply == FALSE && reject == FALSE) {
+
+				/*
+				 * We will always have an SDTR to send.
+				 */
+				ahd->msgout_index = 0;
+				ahd->msgout_len = 0;
+				ahd_build_transfer_msg(ahd, devinfo);
+				ahd->msgout_index = 0;
+				response = TRUE;
+			}
+			done = MSGLOOP_MSGCOMPLETE;
+			break;
+		}
+		case MSG_EXT_PPR:
+		{
+			u_int	period;
+			u_int	offset;
+			u_int	bus_width;
+			u_int	ppr_options;
+			u_int	saved_width;
+			u_int	saved_offset;
+			u_int	saved_ppr_options;
+
+			if (ahd->msgin_buf[1] != MSG_EXT_PPR_LEN) {
+				reject = TRUE;
+				break;
+			}
+
+			/*
+			 * Wait until we have all args before validating
+			 * and acting on this message.
+			 *
+			 * Add one to MSG_EXT_PPR_LEN to account for
+			 * the extended message preamble.
+			 */
+			if (ahd->msgin_index < (MSG_EXT_PPR_LEN + 1))
+				break;
+
+			period = ahd->msgin_buf[3];
+			offset = ahd->msgin_buf[5];
+			bus_width = ahd->msgin_buf[6];
+			saved_width = bus_width;
+			ppr_options = ahd->msgin_buf[7];
+			/*
+			 * According to the spec, a DT only
+			 * period factor with no DT option
+			 * set implies async.
+			 */
+			if ((ppr_options & MSG_EXT_PPR_DT_REQ) == 0
+			 && period <= 9)
+				offset = 0;
+			saved_ppr_options = ppr_options;
+			saved_offset = offset;
+
+			/*
+			 * Transfer options are only available if we
+			 * are negotiating wide.
+			 */
+			if (bus_width == 0)
+				ppr_options &= MSG_EXT_PPR_QAS_REQ;
+
+			ahd_validate_width(ahd, tinfo, &bus_width,
+					   devinfo->role);
+			ahd_devlimited_syncrate(ahd, tinfo, &period,
+						&ppr_options, devinfo->role);
+			ahd_validate_offset(ahd, tinfo, period, &offset,
+					    bus_width, devinfo->role);
+
+			if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_PPR, TRUE)) {
+				/*
+				 * If we are unable to do any of the
+				 * requested options (we went too low),
+				 * then we'll have to reject the message.
+				 */
+				if (saved_width > bus_width
+				 || saved_offset != offset
+				 || saved_ppr_options != ppr_options) {
+					reject = TRUE;
+					period = 0;
+					offset = 0;
+					bus_width = 0;
+					ppr_options = 0;
+				}
+			} else {
+				if (devinfo->role != ROLE_TARGET)
+					printf("(%s:%c:%d:%d): Target "
+					       "Initiated PPR\n",
+					       ahd_name(ahd), devinfo->channel,
+					       devinfo->target, devinfo->lun);
+				else
+					printf("(%s:%c:%d:%d): Initiator "
+					       "Initiated PPR\n",
+					       ahd_name(ahd), devinfo->channel,
+					       devinfo->target, devinfo->lun);
+				ahd->msgout_index = 0;
+				ahd->msgout_len = 0;
+				ahd_construct_ppr(ahd, devinfo, period, offset,
+						  bus_width, ppr_options);
+				ahd->msgout_index = 0;
+				response = TRUE;
+			}
+			if (bootverbose) {
+				printf("(%s:%c:%d:%d): Received PPR width %x, "
+				       "period %x, offset %x,options %x\n"
+				       "\tFiltered to width %x, period %x, "
+				       "offset %x, options %x\n",
+				       ahd_name(ahd), devinfo->channel,
+				       devinfo->target, devinfo->lun,
+				       saved_width, ahd->msgin_buf[3],
+				       saved_offset, saved_ppr_options,
+				       bus_width, period, offset, ppr_options);
+			}
+			ahd_set_width(ahd, devinfo, bus_width,
+				      AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
+				      /*paused*/TRUE);
+			ahd_set_syncrate(ahd, devinfo, period,
+					 offset, ppr_options,
+					 AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
+					 /*paused*/TRUE);
+
+			done = MSGLOOP_MSGCOMPLETE;
+			break;
+		}
+		default:
+			/* Unknown extended message.  Reject it. */
+			reject = TRUE;
+			break;
+		}
+		break;
+	}
+#ifdef AHD_TARGET_MODE
+	case MSG_BUS_DEV_RESET:
+		ahd_handle_devreset(ahd, devinfo, CAM_LUN_WILDCARD,
+				    CAM_BDR_SENT,
+				    "Bus Device Reset Received",
+				    /*verbose_level*/0);
+		ahd_restart(ahd);
+		done = MSGLOOP_TERMINATED;
+		break;
+	case MSG_ABORT_TAG:
+	case MSG_ABORT:
+	case MSG_CLEAR_QUEUE:
+	{
+		int tag;
+
+		/* Target mode messages */
+		if (devinfo->role != ROLE_TARGET) {
+			reject = TRUE;
+			break;
+		}
+		tag = SCB_LIST_NULL;
+		if (ahd->msgin_buf[0] == MSG_ABORT_TAG)
+			tag = ahd_inb(ahd, INITIATOR_TAG);
+		ahd_abort_scbs(ahd, devinfo->target, devinfo->channel,
+			       devinfo->lun, tag, ROLE_TARGET,
+			       CAM_REQ_ABORTED);
+
+		tstate = ahd->enabled_targets[devinfo->our_scsiid];
+		if (tstate != NULL) {
+			struct ahd_tmode_lstate* lstate;
+
+			lstate = tstate->enabled_luns[devinfo->lun];
+			if (lstate != NULL) {
+				ahd_queue_lstate_event(ahd, lstate,
+						       devinfo->our_scsiid,
+						       ahd->msgin_buf[0],
+						       /*arg*/tag);
+				ahd_send_lstate_events(ahd, lstate);
+			}
+		}
+		ahd_restart(ahd);
+		done = MSGLOOP_TERMINATED;
+		break;
+	}
+#endif
+	case MSG_QAS_REQUEST:
+#ifdef AHD_DEBUG
+		if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
+			printf("%s: QAS request.  SCSISIGI == 0x%x\n",
+			       ahd_name(ahd), ahd_inb(ahd, SCSISIGI));
+#endif
+		ahd->msg_flags |= MSG_FLAG_EXPECT_QASREJ_BUSFREE;
+		/* FALLTHROUGH */
+	case MSG_TERM_IO_PROC:
+	default:
+		reject = TRUE;
+		break;
+	}
+
+	if (reject) {
+		/*
+		 * Setup to reject the message.
+		 */
+		ahd->msgout_index = 0;
+		ahd->msgout_len = 1;
+		ahd->msgout_buf[0] = MSG_MESSAGE_REJECT;
+		done = MSGLOOP_MSGCOMPLETE;
+		response = TRUE;
+	}
+
+	if (done != MSGLOOP_IN_PROG && !response)
+		/* Clear the outgoing message buffer */
+		ahd->msgout_len = 0;
+
+	return (done);
+}
+
+/*
+ * Process a message reject message.
+ */
+static int
+ahd_handle_msg_reject(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
+{
+	/*
+	 * What we care about here is if we had an
+	 * outstanding SDTR or WDTR message for this
+	 * target.  If we did, this is a signal that
+	 * the target is refusing negotiation.
+	 */
+	struct scb *scb;
+	struct ahd_initiator_tinfo *tinfo;
+	struct ahd_tmode_tstate *tstate;
+	u_int scb_index;
+	u_int last_msg;
+	int   response = 0;
+
+	scb_index = ahd_get_scbptr(ahd);
+	scb = ahd_lookup_scb(ahd, scb_index);
+	tinfo = ahd_fetch_transinfo(ahd, devinfo->channel,
+				    devinfo->our_scsiid,
+				    devinfo->target, &tstate);
+	/* Might be necessary */
+	last_msg = ahd_inb(ahd, LAST_MSG);
+
+	if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_PPR, /*full*/FALSE)) {
+		if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_PPR, /*full*/TRUE)
+		 && tinfo->goal.period <= AHD_SYNCRATE_PACED) {
+			/*
+			 * Target may not like our SPI-4 PPR Options.
+			 * Attempt to negotiate 80MHz which will turn
+			 * off these options.
+			 */
+			if (bootverbose) {
+				printf("(%s:%c:%d:%d): PPR Rejected. "
+				       "Trying simple U160 PPR\n",
+				       ahd_name(ahd), devinfo->channel,
+				       devinfo->target, devinfo->lun);
+			}
+			tinfo->goal.period = AHD_SYNCRATE_DT;
+			tinfo->goal.ppr_options &= MSG_EXT_PPR_IU_REQ
+						|  MSG_EXT_PPR_QAS_REQ
+						|  MSG_EXT_PPR_DT_REQ;
+		} else {
+			/*
+			 * Target does not support the PPR message.
+			 * Attempt to negotiate SPI-2 style.
+			 */
+			if (bootverbose) {
+				printf("(%s:%c:%d:%d): PPR Rejected. "
+				       "Trying WDTR/SDTR\n",
+				       ahd_name(ahd), devinfo->channel,
+				       devinfo->target, devinfo->lun);
+			}
+			tinfo->goal.ppr_options = 0;
+			tinfo->curr.transport_version = 2;
+			tinfo->goal.transport_version = 2;
+		}
+		ahd->msgout_index = 0;
+		ahd->msgout_len = 0;
+		ahd_build_transfer_msg(ahd, devinfo);
+		ahd->msgout_index = 0;
+		response = 1;
+	} else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_WDTR, /*full*/FALSE)) {
+
+		/* note 8bit xfers */
+		printf("(%s:%c:%d:%d): refuses WIDE negotiation.  Using "
+		       "8bit transfers\n", ahd_name(ahd),
+		       devinfo->channel, devinfo->target, devinfo->lun);
+		ahd_set_width(ahd, devinfo, MSG_EXT_WDTR_BUS_8_BIT,
+			      AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
+			      /*paused*/TRUE);
+		/*
+		 * No need to clear the sync rate.  If the target
+		 * did not accept the command, our syncrate is
+		 * unaffected.  If the target started the negotiation,
+		 * but rejected our response, we already cleared the
+		 * sync rate before sending our WDTR.
+		 */
+		if (tinfo->goal.offset != tinfo->curr.offset) {
+
+			/* Start the sync negotiation */
+			ahd->msgout_index = 0;
+			ahd->msgout_len = 0;
+			ahd_build_transfer_msg(ahd, devinfo);
+			ahd->msgout_index = 0;
+			response = 1;
+		}
+	} else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_SDTR, /*full*/FALSE)) {
+		/* note asynch xfers and clear flag */
+		ahd_set_syncrate(ahd, devinfo, /*period*/0,
+				 /*offset*/0, /*ppr_options*/0,
+				 AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
+				 /*paused*/TRUE);
+		printf("(%s:%c:%d:%d): refuses synchronous negotiation. "
+		       "Using asynchronous transfers\n",
+		       ahd_name(ahd), devinfo->channel,
+		       devinfo->target, devinfo->lun);
+	} else if ((scb->hscb->control & MSG_SIMPLE_TASK) != 0) {
+		int tag_type;
+		int mask;
+
+		tag_type = (scb->hscb->control & MSG_SIMPLE_TASK);
+
+		if (tag_type == MSG_SIMPLE_TASK) {
+			printf("(%s:%c:%d:%d): refuses tagged commands.  "
+			       "Performing non-tagged I/O\n", ahd_name(ahd),
+			       devinfo->channel, devinfo->target, devinfo->lun);
+			ahd_set_tags(ahd, devinfo, AHD_QUEUE_NONE);
+			mask = ~0x23;
+		} else {
+			printf("(%s:%c:%d:%d): refuses %s tagged commands.  "
+			       "Performing simple queue tagged I/O only\n",
+			       ahd_name(ahd), devinfo->channel, devinfo->target,
+			       devinfo->lun, tag_type == MSG_ORDERED_TASK
+			       ? "ordered" : "head of queue");
+			ahd_set_tags(ahd, devinfo, AHD_QUEUE_BASIC);
+			mask = ~0x03;
+		}
+
+		/*
+		 * Resend the identify for this CCB as the target
+		 * may believe that the selection is invalid otherwise.
+		 */
+		ahd_outb(ahd, SCB_CONTROL,
+			 ahd_inb_scbram(ahd, SCB_CONTROL) & mask);
+	 	scb->hscb->control &= mask;
+		ahd_set_transaction_tag(scb, /*enabled*/FALSE,
+					/*type*/MSG_SIMPLE_TASK);
+		ahd_outb(ahd, MSG_OUT, MSG_IDENTIFYFLAG);
+		ahd_assert_atn(ahd);
+		ahd_busy_tcl(ahd, BUILD_TCL(scb->hscb->scsiid, devinfo->lun),
+			     SCB_GET_TAG(scb));
+
+		/*
+		 * Requeue all tagged commands for this target
+		 * currently in our posession so they can be
+		 * converted to untagged commands.
+		 */
+		ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb),
+				   SCB_GET_CHANNEL(ahd, scb),
+				   SCB_GET_LUN(scb), /*tag*/SCB_LIST_NULL,
+				   ROLE_INITIATOR, CAM_REQUEUE_REQ,
+				   SEARCH_COMPLETE);
+	} else if (ahd_sent_msg(ahd, AHDMSG_1B, MSG_IDENTIFYFLAG, TRUE)) {
+		/*
+		 * Most likely the device believes that we had
+		 * previously negotiated packetized.
+		 */
+		ahd->msg_flags |= MSG_FLAG_EXPECT_PPR_BUSFREE
+			       |  MSG_FLAG_IU_REQ_CHANGED;
+
+		ahd_force_renegotiation(ahd, devinfo);
+		ahd->msgout_index = 0;
+		ahd->msgout_len = 0;
+		ahd_build_transfer_msg(ahd, devinfo);
+		ahd->msgout_index = 0;
+		response = 1;
+	} else {
+		/*
+		 * Otherwise, we ignore it.
+		 */
+		printf("%s:%c:%d: Message reject for %x -- ignored\n",
+		       ahd_name(ahd), devinfo->channel, devinfo->target,
+		       last_msg);
+	}
+	return (response);
+}
+
+/*
+ * Process an ingnore wide residue message.
+ */
+static void
+ahd_handle_ign_wide_residue(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
+{
+	u_int scb_index;
+	struct scb *scb;
+
+	scb_index = ahd_get_scbptr(ahd);
+	scb = ahd_lookup_scb(ahd, scb_index);
+	/*
+	 * XXX Actually check data direction in the sequencer?
+	 * Perhaps add datadir to some spare bits in the hscb?
+	 */
+	if ((ahd_inb(ahd, SEQ_FLAGS) & DPHASE) == 0
+	 || ahd_get_transfer_dir(scb) != CAM_DIR_IN) {
+		/*
+		 * Ignore the message if we haven't
+		 * seen an appropriate data phase yet.
+		 */
+	} else {
+		/*
+		 * If the residual occurred on the last
+		 * transfer and the transfer request was
+		 * expected to end on an odd count, do
+		 * nothing.  Otherwise, subtract a byte
+		 * and update the residual count accordingly.
+		 */
+		uint32_t sgptr;
+
+		sgptr = ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR);
+		if ((sgptr & SG_LIST_NULL) != 0
+		 && (ahd_inb(ahd, SCB_TASK_ATTRIBUTE) & SCB_XFERLEN_ODD) != 0) {
+			/*
+			 * If the residual occurred on the last
+			 * transfer and the transfer request was
+			 * expected to end on an odd count, do
+			 * nothing.
+			 */
+		} else {
+			uint32_t data_cnt;
+			uint64_t data_addr;
+			uint32_t sglen;
+
+			/* Pull in the rest of the sgptr */
+			sgptr = ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR);
+			data_cnt = ahd_inl_scbram(ahd, SCB_RESIDUAL_DATACNT);
+			if ((sgptr & SG_LIST_NULL) != 0) {
+				/*
+				 * The residual data count is not updated
+				 * for the command run to completion case.
+				 * Explicitly zero the count.
+				 */
+				data_cnt &= ~AHD_SG_LEN_MASK;
+			}
+			data_addr = ahd_inq(ahd, SHADDR);
+			data_cnt += 1;
+			data_addr -= 1;
+			sgptr &= SG_PTR_MASK;
+			if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
+				struct ahd_dma64_seg *sg;
+
+				sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
+
+				/*
+				 * The residual sg ptr points to the next S/G
+				 * to load so we must go back one.
+				 */
+				sg--;
+				sglen = ahd_le32toh(sg->len) & AHD_SG_LEN_MASK;
+				if (sg != scb->sg_list
+				 && sglen < (data_cnt & AHD_SG_LEN_MASK)) {
+
+					sg--;
+					sglen = ahd_le32toh(sg->len);
+					/*
+					 * Preserve High Address and SG_LIST
+					 * bits while setting the count to 1.
+					 */
+					data_cnt = 1|(sglen&(~AHD_SG_LEN_MASK));
+					data_addr = ahd_le64toh(sg->addr)
+						  + (sglen & AHD_SG_LEN_MASK)
+						  - 1;
+
+					/*
+					 * Increment sg so it points to the
+					 * "next" sg.
+					 */
+					sg++;
+					sgptr = ahd_sg_virt_to_bus(ahd, scb,
+								   sg);
+				}
+			} else {
+				struct ahd_dma_seg *sg;
+
+				sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
+
+				/*
+				 * The residual sg ptr points to the next S/G
+				 * to load so we must go back one.
+				 */
+				sg--;
+				sglen = ahd_le32toh(sg->len) & AHD_SG_LEN_MASK;
+				if (sg != scb->sg_list
+				 && sglen < (data_cnt & AHD_SG_LEN_MASK)) {
+
+					sg--;
+					sglen = ahd_le32toh(sg->len);
+					/*
+					 * Preserve High Address and SG_LIST
+					 * bits while setting the count to 1.
+					 */
+					data_cnt = 1|(sglen&(~AHD_SG_LEN_MASK));
+					data_addr = ahd_le32toh(sg->addr)
+						  + (sglen & AHD_SG_LEN_MASK)
+						  - 1;
+
+					/*
+					 * Increment sg so it points to the
+					 * "next" sg.
+					 */
+					sg++;
+					sgptr = ahd_sg_virt_to_bus(ahd, scb,
+								  sg);
+				}
+			}
+			/*
+			 * Toggle the "oddness" of the transfer length
+			 * to handle this mid-transfer ignore wide
+			 * residue.  This ensures that the oddness is
+			 * correct for subsequent data transfers.
+			 */
+			ahd_outb(ahd, SCB_TASK_ATTRIBUTE,
+			    ahd_inb(ahd, SCB_TASK_ATTRIBUTE) ^ SCB_XFERLEN_ODD);
+
+			ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr);
+			ahd_outl(ahd, SCB_RESIDUAL_DATACNT, data_cnt);
+			/*
+			 * The FIFO's pointers will be updated if/when the
+			 * sequencer re-enters a data phase.
+			 */
+		}
+	}
+}
+
+
+/*
+ * Reinitialize the data pointers for the active transfer
+ * based on its current residual.
+ */
+static void
+ahd_reinitialize_dataptrs(struct ahd_softc *ahd)
+{
+	struct		 scb *scb;
+	ahd_mode_state	 saved_modes;
+	u_int		 scb_index;
+	u_int		 wait;
+	uint32_t	 sgptr;
+	uint32_t	 resid;
+	uint64_t	 dataptr;
+
+	AHD_ASSERT_MODES(ahd, AHD_MODE_DFF0_MSK|AHD_MODE_DFF1_MSK,
+			 AHD_MODE_DFF0_MSK|AHD_MODE_DFF1_MSK);
+			 
+	scb_index = ahd_get_scbptr(ahd);
+	scb = ahd_lookup_scb(ahd, scb_index);
+
+	/*
+	 * Release and reacquire the FIFO so we
+	 * have a clean slate.
+	 */
+	ahd_outb(ahd, DFFSXFRCTL, CLRCHN);
+	wait = 1000;
+	do {
+		ahd_delay(100);
+	} while (--wait && !(ahd_inb(ahd, MDFFSTAT) & FIFOFREE));
+	if (wait == 0) {
+		ahd_print_path(ahd, scb);
+		printf("ahd_reinitialize_dataptrs: Forcing FIFO free.\n");
+		ahd_outb(ahd, DFFSXFRCTL, RSTCHN|CLRSHCNT);
+	}
+	saved_modes = ahd_save_modes(ahd);
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+	ahd_outb(ahd, DFFSTAT,
+		 ahd_inb(ahd, DFFSTAT)
+		| (saved_modes == 0x11 ? CURRFIFO_1 : CURRFIFO_0));
+
+	/*
+	 * Determine initial values for data_addr and data_cnt
+	 * for resuming the data phase.
+	 */
+	sgptr = (ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR + 3) << 24)
+	      | (ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR + 2) << 16)
+	      | (ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR + 1) << 8)
+	      |	ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR);
+	sgptr &= SG_PTR_MASK;
+
+	resid = (ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT + 2) << 16)
+	      | (ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT + 1) << 8)
+	      | ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT);
+
+	if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
+		struct ahd_dma64_seg *sg;
+
+		sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
+
+		/* The residual sg_ptr always points to the next sg */
+		sg--;
+
+		dataptr = ahd_le64toh(sg->addr)
+			+ (ahd_le32toh(sg->len) & AHD_SG_LEN_MASK)
+			- resid;
+		ahd_outb(ahd, HADDR + 7, dataptr >> 56);
+		ahd_outb(ahd, HADDR + 6, dataptr >> 48);
+		ahd_outb(ahd, HADDR + 5, dataptr >> 40);
+		ahd_outb(ahd, HADDR + 4, dataptr >> 32);
+	} else {
+		struct	 ahd_dma_seg *sg;
+
+		sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
+
+		/* The residual sg_ptr always points to the next sg */
+		sg--;
+
+		dataptr = ahd_le32toh(sg->addr)
+			+ (ahd_le32toh(sg->len) & AHD_SG_LEN_MASK)
+			- resid;
+		ahd_outb(ahd, HADDR + 4,
+			 (ahd_le32toh(sg->len) & ~AHD_SG_LEN_MASK) >> 24);
+	}
+	ahd_outb(ahd, HADDR + 3, dataptr >> 24);
+	ahd_outb(ahd, HADDR + 2, dataptr >> 16);
+	ahd_outb(ahd, HADDR + 1, dataptr >> 8);
+	ahd_outb(ahd, HADDR, dataptr);
+	ahd_outb(ahd, HCNT + 2, resid >> 16);
+	ahd_outb(ahd, HCNT + 1, resid >> 8);
+	ahd_outb(ahd, HCNT, resid);
+}
+
+/*
+ * Handle the effects of issuing a bus device reset message.
+ */
+static void
+ahd_handle_devreset(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
+		    u_int lun, cam_status status, char *message,
+		    int verbose_level)
+{
+#ifdef AHD_TARGET_MODE
+	struct ahd_tmode_tstate* tstate;
+#endif
+	int found;
+
+	found = ahd_abort_scbs(ahd, devinfo->target, devinfo->channel,
+			       lun, SCB_LIST_NULL, devinfo->role,
+			       status);
+
+#ifdef AHD_TARGET_MODE
+	/*
+	 * Send an immediate notify ccb to all target mord peripheral
+	 * drivers affected by this action.
+	 */
+	tstate = ahd->enabled_targets[devinfo->our_scsiid];
+	if (tstate != NULL) {
+		u_int cur_lun;
+		u_int max_lun;
+
+		if (lun != CAM_LUN_WILDCARD) {
+			cur_lun = 0;
+			max_lun = AHD_NUM_LUNS - 1;
+		} else {
+			cur_lun = lun;
+			max_lun = lun;
+		}
+		for (cur_lun <= max_lun; cur_lun++) {
+			struct ahd_tmode_lstate* lstate;
+
+			lstate = tstate->enabled_luns[cur_lun];
+			if (lstate == NULL)
+				continue;
+
+			ahd_queue_lstate_event(ahd, lstate, devinfo->our_scsiid,
+					       MSG_BUS_DEV_RESET, /*arg*/0);
+			ahd_send_lstate_events(ahd, lstate);
+		}
+	}
+#endif
+
+	/*
+	 * Go back to async/narrow transfers and renegotiate.
+	 */
+	ahd_set_width(ahd, devinfo, MSG_EXT_WDTR_BUS_8_BIT,
+		      AHD_TRANS_CUR, /*paused*/TRUE);
+	ahd_set_syncrate(ahd, devinfo, /*period*/0, /*offset*/0,
+			 /*ppr_options*/0, AHD_TRANS_CUR, /*paused*/TRUE);
+	
+	ahd_send_async(ahd, devinfo->channel, devinfo->target,
+		       lun, AC_SENT_BDR, NULL);
+
+	if (message != NULL
+	 && (verbose_level <= bootverbose))
+		printf("%s: %s on %c:%d. %d SCBs aborted\n", ahd_name(ahd),
+		       message, devinfo->channel, devinfo->target, found);
+}
+
+#ifdef AHD_TARGET_MODE
+static void
+ahd_setup_target_msgin(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
+		       struct scb *scb)
+{
+
+	/*              
+	 * To facilitate adding multiple messages together,
+	 * each routine should increment the index and len
+	 * variables instead of setting them explicitly.
+	 */             
+	ahd->msgout_index = 0;
+	ahd->msgout_len = 0;
+
+	if (scb != NULL && (scb->flags & SCB_AUTO_NEGOTIATE) != 0)
+		ahd_build_transfer_msg(ahd, devinfo);
+	else
+		panic("ahd_intr: AWAITING target message with no message");
+
+	ahd->msgout_index = 0;
+	ahd->msg_type = MSG_TYPE_TARGET_MSGIN;
+}
+#endif
+/**************************** Initialization **********************************/
+static u_int
+ahd_sglist_size(struct ahd_softc *ahd)
+{
+	bus_size_t list_size;
+
+	list_size = sizeof(struct ahd_dma_seg) * AHD_NSEG;
+	if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0)
+		list_size = sizeof(struct ahd_dma64_seg) * AHD_NSEG;
+	return (list_size);
+}
+
+/*
+ * Calculate the optimum S/G List allocation size.  S/G elements used
+ * for a given transaction must be physically contiguous.  Assume the
+ * OS will allocate full pages to us, so it doesn't make sense to request
+ * less than a page.
+ */
+static u_int
+ahd_sglist_allocsize(struct ahd_softc *ahd)
+{
+	bus_size_t sg_list_increment;
+	bus_size_t sg_list_size;
+	bus_size_t max_list_size;
+	bus_size_t best_list_size;
+
+	/* Start out with the minimum required for AHD_NSEG. */
+	sg_list_increment = ahd_sglist_size(ahd);
+	sg_list_size = sg_list_increment;
+
+	/* Get us as close as possible to a page in size. */
+	while ((sg_list_size + sg_list_increment) <= PAGE_SIZE)
+		sg_list_size += sg_list_increment;
+
+	/*
+	 * Try to reduce the amount of wastage by allocating
+	 * multiple pages.
+	 */
+	best_list_size = sg_list_size;
+	max_list_size = roundup(sg_list_increment, PAGE_SIZE);
+	if (max_list_size < 4 * PAGE_SIZE)
+		max_list_size = 4 * PAGE_SIZE;
+	if (max_list_size > (AHD_SCB_MAX_ALLOC * sg_list_increment))
+		max_list_size = (AHD_SCB_MAX_ALLOC * sg_list_increment);
+	while ((sg_list_size + sg_list_increment) <= max_list_size
+	   &&  (sg_list_size % PAGE_SIZE) != 0) {
+		bus_size_t new_mod;
+		bus_size_t best_mod;
+
+		sg_list_size += sg_list_increment;
+		new_mod = sg_list_size % PAGE_SIZE;
+		best_mod = best_list_size % PAGE_SIZE;
+		if (new_mod > best_mod || new_mod == 0) {
+			best_list_size = sg_list_size;
+		}
+	}
+	return (best_list_size);
+}
+
+/*
+ * Allocate a controller structure for a new device
+ * and perform initial initializion.
+ */
+struct ahd_softc *
+ahd_alloc(void *platform_arg, char *name)
+{
+	struct  ahd_softc *ahd;
+
+#ifndef	__FreeBSD__
+	ahd = malloc(sizeof(*ahd), M_DEVBUF, M_NOWAIT);
+	if (!ahd) {
+		printf("aic7xxx: cannot malloc softc!\n");
+		free(name, M_DEVBUF);
+		return NULL;
+	}
+#else
+	ahd = device_get_softc((device_t)platform_arg);
+#endif
+	memset(ahd, 0, sizeof(*ahd));
+	ahd->seep_config = malloc(sizeof(*ahd->seep_config),
+				  M_DEVBUF, M_NOWAIT);
+	if (ahd->seep_config == NULL) {
+#ifndef	__FreeBSD__
+		free(ahd, M_DEVBUF);
+#endif
+		free(name, M_DEVBUF);
+		return (NULL);
+	}
+	LIST_INIT(&ahd->pending_scbs);
+	/* We don't know our unit number until the OSM sets it */
+	ahd->name = name;
+	ahd->unit = -1;
+	ahd->description = NULL;
+	ahd->bus_description = NULL;
+	ahd->channel = 'A';
+	ahd->chip = AHD_NONE;
+	ahd->features = AHD_FENONE;
+	ahd->bugs = AHD_BUGNONE;
+	ahd->flags = AHD_SPCHK_ENB_A|AHD_RESET_BUS_A|AHD_TERM_ENB_A
+		   | AHD_EXTENDED_TRANS_A|AHD_STPWLEVEL_A;
+	ahd_timer_init(&ahd->reset_timer);
+	ahd_timer_init(&ahd->stat_timer);
+	ahd->int_coalescing_timer = AHD_INT_COALESCING_TIMER_DEFAULT;
+	ahd->int_coalescing_maxcmds = AHD_INT_COALESCING_MAXCMDS_DEFAULT;
+	ahd->int_coalescing_mincmds = AHD_INT_COALESCING_MINCMDS_DEFAULT;
+	ahd->int_coalescing_threshold = AHD_INT_COALESCING_THRESHOLD_DEFAULT;
+	ahd->int_coalescing_stop_threshold =
+	    AHD_INT_COALESCING_STOP_THRESHOLD_DEFAULT;
+
+	if (ahd_platform_alloc(ahd, platform_arg) != 0) {
+		ahd_free(ahd);
+		ahd = NULL;
+	}
+#ifdef AHD_DEBUG
+	if ((ahd_debug & AHD_SHOW_MEMORY) != 0) {
+		printf("%s: scb size = 0x%x, hscb size = 0x%x\n",
+		       ahd_name(ahd), (u_int)sizeof(struct scb),
+		       (u_int)sizeof(struct hardware_scb));
+	}
+#endif
+	return (ahd);
+}
+
+int
+ahd_softc_init(struct ahd_softc *ahd)
+{
+
+	ahd->unpause = 0;
+	ahd->pause = PAUSE; 
+	return (0);
+}
+
+void
+ahd_softc_insert(struct ahd_softc *ahd)
+{
+	struct ahd_softc *list_ahd;
+
+#if AHD_PCI_CONFIG > 0
+	/*
+	 * Second Function PCI devices need to inherit some
+	 * settings from function 0.
+	 */
+	if ((ahd->features & AHD_MULTI_FUNC) != 0) {
+		TAILQ_FOREACH(list_ahd, &ahd_tailq, links) {
+			ahd_dev_softc_t list_pci;
+			ahd_dev_softc_t pci;
+
+			list_pci = list_ahd->dev_softc;
+			pci = ahd->dev_softc;
+			if (ahd_get_pci_slot(list_pci) == ahd_get_pci_slot(pci)
+			 && ahd_get_pci_bus(list_pci) == ahd_get_pci_bus(pci)) {
+				struct ahd_softc *master;
+				struct ahd_softc *slave;
+
+				if (ahd_get_pci_function(list_pci) == 0) {
+					master = list_ahd;
+					slave = ahd;
+				} else {
+					master = ahd;
+					slave = list_ahd;
+				}
+				slave->flags &= ~AHD_BIOS_ENABLED; 
+				slave->flags |=
+				    master->flags & AHD_BIOS_ENABLED;
+				break;
+			}
+		}
+	}
+#endif
+
+	/*
+	 * Insertion sort into our list of softcs.
+	 */
+	list_ahd = TAILQ_FIRST(&ahd_tailq);
+	while (list_ahd != NULL
+	    && ahd_softc_comp(ahd, list_ahd) <= 0)
+		list_ahd = TAILQ_NEXT(list_ahd, links);
+	if (list_ahd != NULL)
+		TAILQ_INSERT_BEFORE(list_ahd, ahd, links);
+	else
+		TAILQ_INSERT_TAIL(&ahd_tailq, ahd, links);
+	ahd->init_level++;
+}
+
+/*
+ * Verify that the passed in softc pointer is for a
+ * controller that is still configured.
+ */
+struct ahd_softc *
+ahd_find_softc(struct ahd_softc *ahd)
+{
+	struct ahd_softc *list_ahd;
+
+	TAILQ_FOREACH(list_ahd, &ahd_tailq, links) {
+		if (list_ahd == ahd)
+			return (ahd);
+	}
+	return (NULL);
+}
+
+void
+ahd_set_unit(struct ahd_softc *ahd, int unit)
+{
+	ahd->unit = unit;
+}
+
+void
+ahd_set_name(struct ahd_softc *ahd, char *name)
+{
+	if (ahd->name != NULL)
+		free(ahd->name, M_DEVBUF);
+	ahd->name = name;
+}
+
+void
+ahd_free(struct ahd_softc *ahd)
+{
+	int i;
+
+	switch (ahd->init_level) {
+	default:
+	case 5:
+		ahd_shutdown(ahd);
+		TAILQ_REMOVE(&ahd_tailq, ahd, links);
+		/* FALLTHROUGH */
+	case 4:
+		ahd_dmamap_unload(ahd, ahd->shared_data_dmat,
+				  ahd->shared_data_dmamap);
+		/* FALLTHROUGH */
+	case 3:
+		ahd_dmamem_free(ahd, ahd->shared_data_dmat, ahd->qoutfifo,
+				ahd->shared_data_dmamap);
+		ahd_dmamap_destroy(ahd, ahd->shared_data_dmat,
+				   ahd->shared_data_dmamap);
+		/* FALLTHROUGH */
+	case 2:
+		ahd_dma_tag_destroy(ahd, ahd->shared_data_dmat);
+	case 1:
+#ifndef __linux__
+		ahd_dma_tag_destroy(ahd, ahd->buffer_dmat);
+#endif
+		break;
+	case 0:
+		break;
+	}
+
+#ifndef __linux__
+	ahd_dma_tag_destroy(ahd, ahd->parent_dmat);
+#endif
+	ahd_platform_free(ahd);
+	ahd_fini_scbdata(ahd);
+	for (i = 0; i < AHD_NUM_TARGETS; i++) {
+		struct ahd_tmode_tstate *tstate;
+
+		tstate = ahd->enabled_targets[i];
+		if (tstate != NULL) {
+#if AHD_TARGET_MODE
+			int j;
+
+			for (j = 0; j < AHD_NUM_LUNS; j++) {
+				struct ahd_tmode_lstate *lstate;
+
+				lstate = tstate->enabled_luns[j];
+				if (lstate != NULL) {
+					xpt_free_path(lstate->path);
+					free(lstate, M_DEVBUF);
+				}
+			}
+#endif
+			free(tstate, M_DEVBUF);
+		}
+	}
+#if AHD_TARGET_MODE
+	if (ahd->black_hole != NULL) {
+		xpt_free_path(ahd->black_hole->path);
+		free(ahd->black_hole, M_DEVBUF);
+	}
+#endif
+	if (ahd->name != NULL)
+		free(ahd->name, M_DEVBUF);
+	if (ahd->seep_config != NULL)
+		free(ahd->seep_config, M_DEVBUF);
+	if (ahd->saved_stack != NULL)
+		free(ahd->saved_stack, M_DEVBUF);
+#ifndef __FreeBSD__
+	free(ahd, M_DEVBUF);
+#endif
+	return;
+}
+
+void
+ahd_shutdown(void *arg)
+{
+	struct	ahd_softc *ahd;
+
+	ahd = (struct ahd_softc *)arg;
+
+	/*
+	 * Stop periodic timer callbacks.
+	 */
+	ahd_timer_stop(&ahd->reset_timer);
+	ahd_timer_stop(&ahd->stat_timer);
+
+	/* This will reset most registers to 0, but not all */
+	ahd_reset(ahd, /*reinit*/FALSE);
+}
+
+/*
+ * Reset the controller and record some information about it
+ * that is only available just after a reset.  If "reinit" is
+ * non-zero, this reset occured after initial configuration
+ * and the caller requests that the chip be fully reinitialized
+ * to a runable state.  Chip interrupts are *not* enabled after
+ * a reinitialization.  The caller must enable interrupts via
+ * ahd_intr_enable().
+ */
+int
+ahd_reset(struct ahd_softc *ahd, int reinit)
+{
+	u_int	 sxfrctl1;
+	int	 wait;
+	uint32_t cmd;
+	
+	/*
+	 * Preserve the value of the SXFRCTL1 register for all channels.
+	 * It contains settings that affect termination and we don't want
+	 * to disturb the integrity of the bus.
+	 */
+	ahd_pause(ahd);
+	ahd_update_modes(ahd);
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+	sxfrctl1 = ahd_inb(ahd, SXFRCTL1);
+
+	cmd = ahd_pci_read_config(ahd->dev_softc, PCIR_COMMAND, /*bytes*/2);
+	if ((ahd->bugs & AHD_PCIX_CHIPRST_BUG) != 0) {
+		uint32_t mod_cmd;
+
+		/*
+		 * A4 Razor #632
+		 * During the assertion of CHIPRST, the chip
+		 * does not disable its parity logic prior to
+		 * the start of the reset.  This may cause a
+		 * parity error to be detected and thus a
+		 * spurious SERR or PERR assertion.  Disble
+		 * PERR and SERR responses during the CHIPRST.
+		 */
+		mod_cmd = cmd & ~(PCIM_CMD_PERRESPEN|PCIM_CMD_SERRESPEN);
+		ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND,
+				     mod_cmd, /*bytes*/2);
+	}
+	ahd_outb(ahd, HCNTRL, CHIPRST | ahd->pause);
+
+	/*
+	 * Ensure that the reset has finished.  We delay 1000us
+	 * prior to reading the register to make sure the chip
+	 * has sufficiently completed its reset to handle register
+	 * accesses.
+	 */
+	wait = 1000;
+	do {
+		ahd_delay(1000);
+	} while (--wait && !(ahd_inb(ahd, HCNTRL) & CHIPRSTACK));
+
+	if (wait == 0) {
+		printf("%s: WARNING - Failed chip reset!  "
+		       "Trying to initialize anyway.\n", ahd_name(ahd));
+	}
+	ahd_outb(ahd, HCNTRL, ahd->pause);
+
+	if ((ahd->bugs & AHD_PCIX_CHIPRST_BUG) != 0) {
+		/*
+		 * Clear any latched PCI error status and restore
+		 * previous SERR and PERR response enables.
+		 */
+		ahd_pci_write_config(ahd->dev_softc, PCIR_STATUS + 1,
+				     0xFF, /*bytes*/1);
+		ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND,
+				     cmd, /*bytes*/2);
+	}
+
+	/*
+	 * Mode should be SCSI after a chip reset, but lets
+	 * set it just to be safe.  We touch the MODE_PTR
+	 * register directly so as to bypass the lazy update
+	 * code in ahd_set_modes().
+	 */
+	ahd_known_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+	ahd_outb(ahd, MODE_PTR,
+		 ahd_build_mode_state(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI));
+
+	/*
+	 * Restore SXFRCTL1.
+	 *
+	 * We must always initialize STPWEN to 1 before we
+	 * restore the saved values.  STPWEN is initialized
+	 * to a tri-state condition which can only be cleared
+	 * by turning it on.
+	 */
+	ahd_outb(ahd, SXFRCTL1, sxfrctl1|STPWEN);
+	ahd_outb(ahd, SXFRCTL1, sxfrctl1);
+
+	/* Determine chip configuration */
+	ahd->features &= ~AHD_WIDE;
+	if ((ahd_inb(ahd, SBLKCTL) & SELWIDE) != 0)
+		ahd->features |= AHD_WIDE;
+
+	/*
+	 * If a recovery action has forced a chip reset,
+	 * re-initialize the chip to our liking.
+	 */
+	if (reinit != 0)
+		ahd_chip_init(ahd);
+
+	return (0);
+}
+
+/*
+ * Determine the number of SCBs available on the controller
+ */
+int
+ahd_probe_scbs(struct ahd_softc *ahd) {
+	int i;
+
+	AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
+			 ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
+	for (i = 0; i < AHD_SCB_MAX; i++) {
+		int j;
+
+		ahd_set_scbptr(ahd, i);
+		ahd_outw(ahd, SCB_BASE, i);
+		for (j = 2; j < 64; j++)
+			ahd_outb(ahd, SCB_BASE+j, 0);
+		/* Start out life as unallocated (needing an abort) */
+		ahd_outb(ahd, SCB_CONTROL, MK_MESSAGE);
+		if (ahd_inw_scbram(ahd, SCB_BASE) != i)
+			break;
+		ahd_set_scbptr(ahd, 0);
+		if (ahd_inw_scbram(ahd, SCB_BASE) != 0)
+			break;
+	}
+	return (i);
+}
+
+static void
+ahd_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error) 
+{
+	bus_addr_t *baddr;
+
+	baddr = (bus_addr_t *)arg;
+	*baddr = segs->ds_addr;
+}
+
+static void
+ahd_initialize_hscbs(struct ahd_softc *ahd)
+{
+	int i;
+
+	for (i = 0; i < ahd->scb_data.maxhscbs; i++) {
+		ahd_set_scbptr(ahd, i);
+
+		/* Clear the control byte. */
+		ahd_outb(ahd, SCB_CONTROL, 0);
+
+		/* Set the next pointer */
+		ahd_outw(ahd, SCB_NEXT, SCB_LIST_NULL);
+	}
+}
+
+static int
+ahd_init_scbdata(struct ahd_softc *ahd)
+{
+	struct	scb_data *scb_data;
+	int	i;
+
+	scb_data = &ahd->scb_data;
+	TAILQ_INIT(&scb_data->free_scbs);
+	for (i = 0; i < AHD_NUM_TARGETS * AHD_NUM_LUNS_NONPKT; i++)
+		LIST_INIT(&scb_data->free_scb_lists[i]);
+	LIST_INIT(&scb_data->any_dev_free_scb_list);
+	SLIST_INIT(&scb_data->hscb_maps);
+	SLIST_INIT(&scb_data->sg_maps);
+	SLIST_INIT(&scb_data->sense_maps);
+
+	/* Determine the number of hardware SCBs and initialize them */
+	scb_data->maxhscbs = ahd_probe_scbs(ahd);
+	if (scb_data->maxhscbs == 0) {
+		printf("%s: No SCB space found\n", ahd_name(ahd));
+		return (ENXIO);
+	}
+
+	ahd_initialize_hscbs(ahd);
+
+	/*
+	 * Create our DMA tags.  These tags define the kinds of device
+	 * accessible memory allocations and memory mappings we will
+	 * need to perform during normal operation.
+	 *
+	 * Unless we need to further restrict the allocation, we rely
+	 * on the restrictions of the parent dmat, hence the common
+	 * use of MAXADDR and MAXSIZE.
+	 */
+
+	/* DMA tag for our hardware scb structures */
+	if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1,
+			       /*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
+			       /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
+			       /*highaddr*/BUS_SPACE_MAXADDR,
+			       /*filter*/NULL, /*filterarg*/NULL,
+			       PAGE_SIZE, /*nsegments*/1,
+			       /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
+			       /*flags*/0, &scb_data->hscb_dmat) != 0) {
+		goto error_exit;
+	}
+
+	scb_data->init_level++;
+
+	/* DMA tag for our S/G structures. */
+	if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/8,
+			       /*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
+			       /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
+			       /*highaddr*/BUS_SPACE_MAXADDR,
+			       /*filter*/NULL, /*filterarg*/NULL,
+			       ahd_sglist_allocsize(ahd), /*nsegments*/1,
+			       /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
+			       /*flags*/0, &scb_data->sg_dmat) != 0) {
+		goto error_exit;
+	}
+#ifdef AHD_DEBUG
+	if ((ahd_debug & AHD_SHOW_MEMORY) != 0)
+		printf("%s: ahd_sglist_allocsize = 0x%x\n", ahd_name(ahd),
+		       ahd_sglist_allocsize(ahd));
+#endif
+
+	scb_data->init_level++;
+
+	/* DMA tag for our sense buffers.  We allocate in page sized chunks */
+	if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1,
+			       /*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
+			       /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
+			       /*highaddr*/BUS_SPACE_MAXADDR,
+			       /*filter*/NULL, /*filterarg*/NULL,
+			       PAGE_SIZE, /*nsegments*/1,
+			       /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
+			       /*flags*/0, &scb_data->sense_dmat) != 0) {
+		goto error_exit;
+	}
+
+	scb_data->init_level++;
+
+	/* Perform initial CCB allocation */
+	ahd_alloc_scbs(ahd);
+
+	if (scb_data->numscbs == 0) {
+		printf("%s: ahd_init_scbdata - "
+		       "Unable to allocate initial scbs\n",
+		       ahd_name(ahd));
+		goto error_exit;
+	}
+
+	/*
+	 * Note that we were successfull
+	 */
+	return (0); 
+
+error_exit:
+
+	return (ENOMEM);
+}
+
+static struct scb *
+ahd_find_scb_by_tag(struct ahd_softc *ahd, u_int tag)
+{
+	struct scb *scb;
+
+	/*
+	 * Look on the pending list.
+	 */
+	LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) {
+		if (SCB_GET_TAG(scb) == tag)
+			return (scb);
+	}
+
+	/*
+	 * Then on all of the collision free lists.
+	 */
+	TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) {
+		struct scb *list_scb;
+
+		list_scb = scb;
+		do {
+			if (SCB_GET_TAG(list_scb) == tag)
+				return (list_scb);
+			list_scb = LIST_NEXT(list_scb, collision_links);
+		} while (list_scb);
+	}
+
+	/*
+	 * And finally on the generic free list.
+	 */
+	LIST_FOREACH(scb, &ahd->scb_data.any_dev_free_scb_list, links.le) {
+		if (SCB_GET_TAG(scb) == tag)
+			return (scb);
+	}
+
+	return (NULL);
+}
+
+static void
+ahd_fini_scbdata(struct ahd_softc *ahd)
+{
+	struct scb_data *scb_data;
+
+	scb_data = &ahd->scb_data;
+	if (scb_data == NULL)
+		return;
+
+	switch (scb_data->init_level) {
+	default:
+	case 7:
+	{
+		struct map_node *sns_map;
+
+		while ((sns_map = SLIST_FIRST(&scb_data->sense_maps)) != NULL) {
+			SLIST_REMOVE_HEAD(&scb_data->sense_maps, links);
+			ahd_dmamap_unload(ahd, scb_data->sense_dmat,
+					  sns_map->dmamap);
+			ahd_dmamem_free(ahd, scb_data->sense_dmat,
+					sns_map->vaddr, sns_map->dmamap);
+			free(sns_map, M_DEVBUF);
+		}
+		ahd_dma_tag_destroy(ahd, scb_data->sense_dmat);
+		/* FALLTHROUGH */
+	}
+	case 6:
+	{
+		struct map_node *sg_map;
+
+		while ((sg_map = SLIST_FIRST(&scb_data->sg_maps)) != NULL) {
+			SLIST_REMOVE_HEAD(&scb_data->sg_maps, links);
+			ahd_dmamap_unload(ahd, scb_data->sg_dmat,
+					  sg_map->dmamap);
+			ahd_dmamem_free(ahd, scb_data->sg_dmat,
+					sg_map->vaddr, sg_map->dmamap);
+			free(sg_map, M_DEVBUF);
+		}
+		ahd_dma_tag_destroy(ahd, scb_data->sg_dmat);
+		/* FALLTHROUGH */
+	}
+	case 5:
+	{
+		struct map_node *hscb_map;
+
+		while ((hscb_map = SLIST_FIRST(&scb_data->hscb_maps)) != NULL) {
+			SLIST_REMOVE_HEAD(&scb_data->hscb_maps, links);
+			ahd_dmamap_unload(ahd, scb_data->hscb_dmat,
+					  hscb_map->dmamap);
+			ahd_dmamem_free(ahd, scb_data->hscb_dmat,
+					hscb_map->vaddr, hscb_map->dmamap);
+			free(hscb_map, M_DEVBUF);
+		}
+		ahd_dma_tag_destroy(ahd, scb_data->hscb_dmat);
+		/* FALLTHROUGH */
+	}
+	case 4:
+	case 3:
+	case 2:
+	case 1:
+	case 0:
+		break;
+	}
+}
+
+/*
+ * DSP filter Bypass must be enabled until the first selection
+ * after a change in bus mode (Razor #491 and #493).
+ */
+static void
+ahd_setup_iocell_workaround(struct ahd_softc *ahd)
+{
+	ahd_mode_state saved_modes;
+
+	saved_modes = ahd_save_modes(ahd);
+	ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
+	ahd_outb(ahd, DSPDATACTL, ahd_inb(ahd, DSPDATACTL)
+	       | BYPASSENAB | RCVROFFSTDIS | XMITOFFSTDIS);
+	ahd_outb(ahd, SIMODE0, ahd_inb(ahd, SIMODE0) | (ENSELDO|ENSELDI));
+#ifdef AHD_DEBUG
+	if ((ahd_debug & AHD_SHOW_MISC) != 0)
+		printf("%s: Setting up iocell workaround\n", ahd_name(ahd));
+#endif
+	ahd_restore_modes(ahd, saved_modes);
+}
+
+static void
+ahd_iocell_first_selection(struct ahd_softc *ahd)
+{
+	ahd_mode_state	saved_modes;
+	u_int		sblkctl;
+
+	saved_modes = ahd_save_modes(ahd);
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+	sblkctl = ahd_inb(ahd, SBLKCTL);
+	ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
+#ifdef AHD_DEBUG
+	if ((ahd_debug & AHD_SHOW_MISC) != 0)
+		printf("%s: iocell first selection\n", ahd_name(ahd));
+#endif
+	if ((sblkctl & ENAB40) != 0) {
+		ahd_outb(ahd, DSPDATACTL,
+			 ahd_inb(ahd, DSPDATACTL) & ~BYPASSENAB);
+#ifdef AHD_DEBUG
+		if ((ahd_debug & AHD_SHOW_MISC) != 0)
+			printf("%s: BYPASS now disabled\n", ahd_name(ahd));
+#endif
+	}
+	ahd_outb(ahd, SIMODE0, ahd_inb(ahd, SIMODE0) & ~(ENSELDO|ENSELDI));
+	ahd_outb(ahd, CLRINT, CLRSCSIINT);
+	ahd_restore_modes(ahd, saved_modes);
+}
+
+/*************************** SCB Management ***********************************/
+static void
+ahd_add_col_list(struct ahd_softc *ahd, struct scb *scb, u_int col_idx)
+{
+	struct	scb_list *free_list;
+	struct	scb_tailq *free_tailq;
+	struct	scb *first_scb;
+
+	scb->flags |= SCB_ON_COL_LIST;
+	AHD_SET_SCB_COL_IDX(scb, col_idx);
+	free_list = &ahd->scb_data.free_scb_lists[col_idx];
+	free_tailq = &ahd->scb_data.free_scbs;
+	first_scb = LIST_FIRST(free_list);
+	if (first_scb != NULL) {
+		LIST_INSERT_AFTER(first_scb, scb, collision_links);
+	} else {
+		LIST_INSERT_HEAD(free_list, scb, collision_links);
+		TAILQ_INSERT_TAIL(free_tailq, scb, links.tqe);
+	}
+}
+
+static void
+ahd_rem_col_list(struct ahd_softc *ahd, struct scb *scb)
+{
+	struct	scb_list *free_list;
+	struct	scb_tailq *free_tailq;
+	struct	scb *first_scb;
+	u_int	col_idx;
+
+	scb->flags &= ~SCB_ON_COL_LIST;
+	col_idx = AHD_GET_SCB_COL_IDX(ahd, scb);
+	free_list = &ahd->scb_data.free_scb_lists[col_idx];
+	free_tailq = &ahd->scb_data.free_scbs;
+	first_scb = LIST_FIRST(free_list);
+	if (first_scb == scb) {
+		struct scb *next_scb;
+
+		/*
+		 * Maintain order in the collision free
+		 * lists for fairness if this device has
+		 * other colliding tags active.
+		 */
+		next_scb = LIST_NEXT(scb, collision_links);
+		if (next_scb != NULL) {
+			TAILQ_INSERT_AFTER(free_tailq, scb,
+					   next_scb, links.tqe);
+		}
+		TAILQ_REMOVE(free_tailq, scb, links.tqe);
+	}
+	LIST_REMOVE(scb, collision_links);
+}
+
+/*
+ * Get a free scb. If there are none, see if we can allocate a new SCB.
+ */
+struct scb *
+ahd_get_scb(struct ahd_softc *ahd, u_int col_idx)
+{
+	struct scb *scb;
+	int tries;
+
+	tries = 0;
+look_again:
+	TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) {
+		if (AHD_GET_SCB_COL_IDX(ahd, scb) != col_idx) {
+			ahd_rem_col_list(ahd, scb);
+			goto found;
+		}
+	}
+	if ((scb = LIST_FIRST(&ahd->scb_data.any_dev_free_scb_list)) == NULL) {
+
+		if (tries++ != 0)
+			return (NULL);
+		ahd_alloc_scbs(ahd);
+		goto look_again;
+	}
+	LIST_REMOVE(scb, links.le);
+	if (col_idx != AHD_NEVER_COL_IDX
+	 && (scb->col_scb != NULL)
+	 && (scb->col_scb->flags & SCB_ACTIVE) == 0) {
+		LIST_REMOVE(scb->col_scb, links.le);
+		ahd_add_col_list(ahd, scb->col_scb, col_idx);
+	}
+found:
+	scb->flags |= SCB_ACTIVE;
+	return (scb);
+}
+
+/*
+ * Return an SCB resource to the free list.
+ */
+void
+ahd_free_scb(struct ahd_softc *ahd, struct scb *scb)
+{       
+
+	/* Clean up for the next user */
+	scb->flags = SCB_FLAG_NONE;
+	scb->hscb->control = 0;
+	ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = NULL;
+
+	if (scb->col_scb == NULL) {
+
+		/*
+		 * No collision possible.  Just free normally.
+		 */
+		LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list,
+				 scb, links.le);
+	} else if ((scb->col_scb->flags & SCB_ON_COL_LIST) != 0) {
+
+		/*
+		 * The SCB we might have collided with is on
+		 * a free collision list.  Put both SCBs on
+		 * the generic list.
+		 */
+		ahd_rem_col_list(ahd, scb->col_scb);
+		LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list,
+				 scb, links.le);
+		LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list,
+				 scb->col_scb, links.le);
+	} else if ((scb->col_scb->flags
+		  & (SCB_PACKETIZED|SCB_ACTIVE)) == SCB_ACTIVE
+		&& (scb->col_scb->hscb->control & TAG_ENB) != 0) {
+
+		/*
+		 * The SCB we might collide with on the next allocation
+		 * is still active in a non-packetized, tagged, context.
+		 * Put us on the SCB collision list.
+		 */
+		ahd_add_col_list(ahd, scb,
+				 AHD_GET_SCB_COL_IDX(ahd, scb->col_scb));
+	} else {
+		/*
+		 * The SCB we might collide with on the next allocation
+		 * is either active in a packetized context, or free.
+		 * Since we can't collide, put this SCB on the generic
+		 * free list.
+		 */
+		LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list,
+				 scb, links.le);
+	}
+
+	ahd_platform_scb_free(ahd, scb);
+}
+
+void
+ahd_alloc_scbs(struct ahd_softc *ahd)
+{
+	struct scb_data *scb_data;
+	struct scb	*next_scb;
+	struct hardware_scb *hscb;
+	struct map_node *hscb_map;
+	struct map_node *sg_map;
+	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;
+	int		 newcount;
+	int		 i;
+
+	scb_data = &ahd->scb_data;
+	if (scb_data->numscbs >= AHD_SCB_MAX_ALLOC)
+		/* Can't allocate any more */
+		return;
+
+	if (scb_data->scbs_left != 0) {
+		int offset;
+
+		offset = (PAGE_SIZE / sizeof(*hscb)) - scb_data->scbs_left;
+		hscb_map = SLIST_FIRST(&scb_data->hscb_maps);
+		hscb = &((struct hardware_scb *)hscb_map->vaddr)[offset];
+		hscb_busaddr = hscb_map->physaddr + (offset * sizeof(*hscb));
+	} else {
+		hscb_map = malloc(sizeof(*hscb_map), M_DEVBUF, M_NOWAIT);
+
+		if (hscb_map == NULL)
+			return;
+
+		/* Allocate the next batch of hardware SCBs */
+		if (ahd_dmamem_alloc(ahd, scb_data->hscb_dmat,
+				     (void **)&hscb_map->vaddr,
+				     BUS_DMA_NOWAIT, &hscb_map->dmamap) != 0) {
+			free(hscb_map, M_DEVBUF);
+			return;
+		}
+
+		SLIST_INSERT_HEAD(&scb_data->hscb_maps, hscb_map, links);
+
+		ahd_dmamap_load(ahd, scb_data->hscb_dmat, hscb_map->dmamap,
+				hscb_map->vaddr, PAGE_SIZE, ahd_dmamap_cb,
+				&hscb_map->physaddr, /*flags*/0);
+
+		hscb = (struct hardware_scb *)hscb_map->vaddr;
+		hscb_busaddr = hscb_map->physaddr;
+		scb_data->scbs_left = PAGE_SIZE / sizeof(*hscb);
+	}
+
+	if (scb_data->sgs_left != 0) {
+		int offset;
+
+		offset = ((ahd_sglist_allocsize(ahd) / ahd_sglist_size(ahd))
+		       - scb_data->sgs_left) * ahd_sglist_size(ahd);
+		sg_map = SLIST_FIRST(&scb_data->sg_maps);
+		segs = sg_map->vaddr + offset;
+		sg_busaddr = sg_map->physaddr + offset;
+	} else {
+		sg_map = malloc(sizeof(*sg_map), M_DEVBUF, M_NOWAIT);
+
+		if (sg_map == NULL)
+			return;
+
+		/* Allocate the next batch of S/G lists */
+		if (ahd_dmamem_alloc(ahd, scb_data->sg_dmat,
+				     (void **)&sg_map->vaddr,
+				     BUS_DMA_NOWAIT, &sg_map->dmamap) != 0) {
+			free(sg_map, M_DEVBUF);
+			return;
+		}
+
+		SLIST_INSERT_HEAD(&scb_data->sg_maps, sg_map, links);
+
+		ahd_dmamap_load(ahd, scb_data->sg_dmat, sg_map->dmamap,
+				sg_map->vaddr, ahd_sglist_allocsize(ahd),
+				ahd_dmamap_cb, &sg_map->physaddr, /*flags*/0);
+
+		segs = sg_map->vaddr;
+		sg_busaddr = sg_map->physaddr;
+		scb_data->sgs_left =
+		    ahd_sglist_allocsize(ahd) / ahd_sglist_size(ahd);
+#ifdef AHD_DEBUG
+		if (ahd_debug & AHD_SHOW_MEMORY)
+			printf("Mapped SG data\n");
+#endif
+	}
+
+	if (scb_data->sense_left != 0) {
+		int offset;
+
+		offset = PAGE_SIZE - (AHD_SENSE_BUFSIZE * scb_data->sense_left);
+		sense_map = SLIST_FIRST(&scb_data->sense_maps);
+		sense_data = sense_map->vaddr + offset;
+		sense_busaddr = sense_map->physaddr + offset;
+	} else {
+		sense_map = malloc(sizeof(*sense_map), M_DEVBUF, M_NOWAIT);
+
+		if (sense_map == NULL)
+			return;
+
+		/* Allocate the next batch of sense buffers */
+		if (ahd_dmamem_alloc(ahd, scb_data->sense_dmat,
+				     (void **)&sense_map->vaddr,
+				     BUS_DMA_NOWAIT, &sense_map->dmamap) != 0) {
+			free(sense_map, M_DEVBUF);
+			return;
+		}
+
+		SLIST_INSERT_HEAD(&scb_data->sense_maps, sense_map, links);
+
+		ahd_dmamap_load(ahd, scb_data->sense_dmat, sense_map->dmamap,
+				sense_map->vaddr, PAGE_SIZE, ahd_dmamap_cb,
+				&sense_map->physaddr, /*flags*/0);
+
+		sense_data = sense_map->vaddr;
+		sense_busaddr = sense_map->physaddr;
+		scb_data->sense_left = PAGE_SIZE / AHD_SENSE_BUFSIZE;
+#ifdef AHD_DEBUG
+		if (ahd_debug & AHD_SHOW_MEMORY)
+			printf("Mapped sense data\n");
+#endif
+	}
+
+	newcount = MIN(scb_data->sense_left, scb_data->scbs_left);
+	newcount = MIN(newcount, scb_data->sgs_left);
+	newcount = MIN(newcount, (AHD_SCB_MAX_ALLOC - scb_data->numscbs));
+	scb_data->sense_left -= newcount;
+	scb_data->scbs_left -= newcount;
+	scb_data->sgs_left -= newcount;
+	for (i = 0; i < newcount; i++) {
+		u_int col_tag;
+
+		struct scb_platform_data *pdata;
+#ifndef __linux__
+		int error;
+#endif
+		next_scb = (struct scb *)malloc(sizeof(*next_scb),
+						M_DEVBUF, M_NOWAIT);
+		if (next_scb == NULL)
+			break;
+
+		pdata = (struct scb_platform_data *)malloc(sizeof(*pdata),
+							   M_DEVBUF, M_NOWAIT);
+		if (pdata == NULL) {
+			free(next_scb, M_DEVBUF);
+			break;
+		}
+		next_scb->platform_data = pdata;
+		next_scb->hscb_map = hscb_map;
+		next_scb->sg_map = sg_map;
+		next_scb->sense_map = sense_map;
+		next_scb->sg_list = segs;
+		next_scb->sense_data = sense_data;
+		next_scb->sense_busaddr = sense_busaddr;
+		memset(hscb, 0, sizeof(*hscb));
+		next_scb->hscb = hscb;
+		hscb->hscb_busaddr = ahd_htole32(hscb_busaddr);
+
+		/*
+		 * The sequencer always starts with the second entry.
+		 * The first entry is embedded in the scb.
+		 */
+		next_scb->sg_list_busaddr = sg_busaddr;
+		if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0)
+			next_scb->sg_list_busaddr
+			    += sizeof(struct ahd_dma64_seg);
+		else
+			next_scb->sg_list_busaddr += sizeof(struct ahd_dma_seg);
+		next_scb->ahd_softc = ahd;
+		next_scb->flags = SCB_FLAG_NONE;
+#ifndef __linux__
+		error = ahd_dmamap_create(ahd, ahd->buffer_dmat, /*flags*/0,
+					  &next_scb->dmamap);
+		if (error != 0) {
+			free(next_scb, M_DEVBUF);
+			free(pdata, M_DEVBUF);
+			break;
+		}
+#endif
+		next_scb->hscb->tag = ahd_htole16(scb_data->numscbs);
+		col_tag = scb_data->numscbs ^ 0x100;
+		next_scb->col_scb = ahd_find_scb_by_tag(ahd, col_tag);
+		if (next_scb->col_scb != NULL)
+			next_scb->col_scb->col_scb = next_scb;
+		ahd_free_scb(ahd, next_scb);
+		hscb++;
+		hscb_busaddr += sizeof(*hscb);
+		segs += ahd_sglist_size(ahd);
+		sg_busaddr += ahd_sglist_size(ahd);
+		sense_data += AHD_SENSE_BUFSIZE;
+		sense_busaddr += AHD_SENSE_BUFSIZE;
+		scb_data->numscbs++;
+	}
+}
+
+void
+ahd_controller_info(struct ahd_softc *ahd, char *buf)
+{
+	const char *speed;
+	const char *type;
+	int len;
+
+	len = sprintf(buf, "%s: ", ahd_chip_names[ahd->chip & AHD_CHIPID_MASK]);
+	buf += len;
+
+	speed = "Ultra320 ";
+	if ((ahd->features & AHD_WIDE) != 0) {
+		type = "Wide ";
+	} else {
+		type = "Single ";
+	}
+	len = sprintf(buf, "%s%sChannel %c, SCSI Id=%d, ",
+		      speed, type, ahd->channel, ahd->our_id);
+	buf += len;
+
+	sprintf(buf, "%s, %d SCBs", ahd->bus_description,
+		ahd->scb_data.maxhscbs);
+}
+
+static const char *channel_strings[] = {
+	"Primary Low",
+	"Primary High",
+	"Secondary Low", 
+	"Secondary High"
+};
+
+static const char *termstat_strings[] = {
+	"Terminated Correctly",
+	"Over Terminated",
+	"Under Terminated",
+	"Not Configured"
+};
+
+/*
+ * Start the board, ready for normal operation
+ */
+int
+ahd_init(struct ahd_softc *ahd)
+{
+	uint8_t		*base_vaddr;
+	uint8_t		*next_vaddr;
+	bus_addr_t	 next_baddr;
+	size_t		 driver_data_size;
+	int		 i;
+	int		 error;
+	u_int		 warn_user;
+	uint8_t		 current_sensing;
+	uint8_t		 fstat;
+
+	AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
+
+	ahd->stack_size = ahd_probe_stack_size(ahd);
+	ahd->saved_stack = malloc(ahd->stack_size * sizeof(uint16_t),
+				  M_DEVBUF, M_NOWAIT);
+	if (ahd->saved_stack == NULL)
+		return (ENOMEM);
+
+	/*
+	 * Verify that the compiler hasn't over-agressively
+	 * padded important structures.
+	 */
+	if (sizeof(struct hardware_scb) != 64)
+		panic("Hardware SCB size is incorrect");
+
+#ifdef AHD_DEBUG
+	if ((ahd_debug & AHD_DEBUG_SEQUENCER) != 0)
+		ahd->flags |= AHD_SEQUENCER_DEBUG;
+#endif
+
+	/*
+	 * Default to allowing initiator operations.
+	 */
+	ahd->flags |= AHD_INITIATORROLE;
+
+	/*
+	 * Only allow target mode features if this unit has them enabled.
+	 */
+	if ((AHD_TMODE_ENABLE & (0x1 << ahd->unit)) == 0)
+		ahd->features &= ~AHD_TARGETMODE;
+
+#ifndef __linux__
+	/* DMA tag for mapping buffers into device visible space. */
+	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
+					: BUS_SPACE_MAXADDR_32BIT,
+			       /*highaddr*/BUS_SPACE_MAXADDR,
+			       /*filter*/NULL, /*filterarg*/NULL,
+			       /*maxsize*/(AHD_NSEG - 1) * PAGE_SIZE,
+			       /*nsegments*/AHD_NSEG,
+			       /*maxsegsz*/AHD_MAXTRANSFER_SIZE,
+			       /*flags*/BUS_DMA_ALLOCNOW,
+			       &ahd->buffer_dmat) != 0) {
+		return (ENOMEM);
+	}
+#endif
+
+	ahd->init_level++;
+
+	/*
+	 * DMA tag for our command fifos and other data in system memory
+	 * the card's sequencer must be able to access.  For initiator
+	 * roles, we need to allocate space for the qoutfifo.  When providing
+	 * for the target mode role, we must additionally provide space for
+	 * the incoming target command fifo.
+	 */
+	driver_data_size = AHD_SCB_MAX * sizeof(uint16_t)
+			 + sizeof(struct hardware_scb);
+	if ((ahd->features & AHD_TARGETMODE) != 0)
+		driver_data_size += AHD_TMODE_CMDS * sizeof(struct target_cmd);
+	if ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0)
+		driver_data_size += PKT_OVERRUN_BUFSIZE;
+	if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1,
+			       /*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
+			       /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
+			       /*highaddr*/BUS_SPACE_MAXADDR,
+			       /*filter*/NULL, /*filterarg*/NULL,
+			       driver_data_size,
+			       /*nsegments*/1,
+			       /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
+			       /*flags*/0, &ahd->shared_data_dmat) != 0) {
+		return (ENOMEM);
+	}
+
+	ahd->init_level++;
+
+	/* Allocation of driver data */
+	if (ahd_dmamem_alloc(ahd, ahd->shared_data_dmat,
+			     (void **)&base_vaddr,
+			     BUS_DMA_NOWAIT, &ahd->shared_data_dmamap) != 0) {
+		return (ENOMEM);
+	}
+
+	ahd->init_level++;
+
+	/* And permanently map it in */
+	ahd_dmamap_load(ahd, ahd->shared_data_dmat, ahd->shared_data_dmamap,
+			base_vaddr, driver_data_size, ahd_dmamap_cb,
+			&ahd->shared_data_busaddr, /*flags*/0);
+	ahd->qoutfifo = (uint16_t *)base_vaddr;
+	next_vaddr = (uint8_t *)&ahd->qoutfifo[AHD_QOUT_SIZE];
+	next_baddr = ahd->shared_data_busaddr + AHD_QOUT_SIZE*sizeof(uint16_t);
+	if ((ahd->features & AHD_TARGETMODE) != 0) {
+		ahd->targetcmds = (struct target_cmd *)next_vaddr;
+		next_vaddr += AHD_TMODE_CMDS * sizeof(struct target_cmd);
+		next_baddr += AHD_TMODE_CMDS * sizeof(struct target_cmd);
+	}
+
+	if ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0) {
+		ahd->overrun_buf = next_vaddr;
+		next_vaddr += PKT_OVERRUN_BUFSIZE;
+		next_baddr += PKT_OVERRUN_BUFSIZE;
+	}
+
+	/*
+	 * We need one SCB to serve as the "next SCB".  Since the
+	 * tag identifier in this SCB will never be used, there is
+	 * no point in using a valid HSCB tag from an SCB pulled from
+	 * the standard free pool.  So, we allocate this "sentinel"
+	 * specially from the DMA safe memory chunk used for the QOUTFIFO.
+	 */
+	ahd->next_queued_hscb = (struct hardware_scb *)next_vaddr;
+	ahd->next_queued_hscb->hscb_busaddr = ahd_htole32(next_baddr);
+
+	ahd->init_level++;
+
+	/* Allocate SCB data now that buffer_dmat is initialized */
+	if (ahd_init_scbdata(ahd) != 0)
+		return (ENOMEM);
+
+	if ((ahd->flags & AHD_INITIATORROLE) == 0)
+		ahd->flags &= ~AHD_RESET_BUS_A;
+
+	/*
+	 * Before committing these settings to the chip, give
+	 * the OSM one last chance to modify our configuration.
+	 */
+	ahd_platform_init(ahd);
+
+	/* Bring up the chip. */
+	ahd_chip_init(ahd);
+
+	AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
+
+	if ((ahd->flags & AHD_CURRENT_SENSING) == 0)
+		goto init_done;
+
+	/*
+	 * Verify termination based on current draw and
+	 * warn user if the bus is over/under terminated.
+	 */
+	error = ahd_write_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL,
+				   CURSENSE_ENB);
+	if (error != 0) {
+		printf("%s: current sensing timeout 1\n", ahd_name(ahd));
+		goto init_done;
+	}
+	for (i = 20, fstat = FLX_FSTAT_BUSY;
+	     (fstat & FLX_FSTAT_BUSY) != 0 && i; i--) {
+		error = ahd_read_flexport(ahd, FLXADDR_FLEXSTAT, &fstat);
+		if (error != 0) {
+			printf("%s: current sensing timeout 2\n",
+			       ahd_name(ahd));
+			goto init_done;
+		}
+	}
+	if (i == 0) {
+		printf("%s: Timedout during current-sensing test\n",
+		       ahd_name(ahd));
+		goto init_done;
+	}
+
+	/* Latch Current Sensing status. */
+	error = ahd_read_flexport(ahd, FLXADDR_CURRENT_STAT, &current_sensing);
+	if (error != 0) {
+		printf("%s: current sensing timeout 3\n", ahd_name(ahd));
+		goto init_done;
+	}
+
+	/* Diable current sensing. */
+	ahd_write_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL, 0);
+
+#ifdef AHD_DEBUG
+	if ((ahd_debug & AHD_SHOW_TERMCTL) != 0) {
+		printf("%s: current_sensing == 0x%x\n",
+		       ahd_name(ahd), current_sensing);
+	}
+#endif
+	warn_user = 0;
+	for (i = 0; i < 4; i++, current_sensing >>= FLX_CSTAT_SHIFT) {
+		u_int term_stat;
+
+		term_stat = (current_sensing & FLX_CSTAT_MASK);
+		switch (term_stat) {
+		case FLX_CSTAT_OVER:
+		case FLX_CSTAT_UNDER:
+			warn_user++;
+		case FLX_CSTAT_INVALID:
+		case FLX_CSTAT_OKAY:
+			if (warn_user == 0 && bootverbose == 0)
+				break;
+			printf("%s: %s Channel %s\n", ahd_name(ahd),
+			       channel_strings[i], termstat_strings[term_stat]);
+			break;
+		}
+	}
+	if (warn_user) {
+		printf("%s: WARNING. Termination is not configured correctly.\n"
+		       "%s: WARNING. SCSI bus operations may FAIL.\n",
+		       ahd_name(ahd), ahd_name(ahd));
+	}
+init_done:
+	ahd_restart(ahd);
+	ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US,
+			ahd_stat_timer, ahd);
+	return (0);
+}
+
+/*
+ * (Re)initialize chip state after a chip reset.
+ */
+static void
+ahd_chip_init(struct ahd_softc *ahd)
+{
+	uint32_t busaddr;
+	u_int	 sxfrctl1;
+	u_int	 scsiseq_template;
+	u_int	 wait;
+	u_int	 i;
+	u_int	 target;
+
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+	/*
+	 * Take the LED out of diagnostic mode
+	 */
+	ahd_outb(ahd, SBLKCTL, ahd_inb(ahd, SBLKCTL) & ~(DIAGLEDEN|DIAGLEDON));
+
+	/*
+	 * Return HS_MAILBOX to its default value.
+	 */
+	ahd->hs_mailbox = 0;
+	ahd_outb(ahd, HS_MAILBOX, 0);
+
+	/* Set the SCSI Id, SXFRCTL0, SXFRCTL1, and SIMODE1. */
+	ahd_outb(ahd, IOWNID, ahd->our_id);
+	ahd_outb(ahd, TOWNID, ahd->our_id);
+	sxfrctl1 = (ahd->flags & AHD_TERM_ENB_A) != 0 ? STPWEN : 0;
+	sxfrctl1 |= (ahd->flags & AHD_SPCHK_ENB_A) != 0 ? ENSPCHK : 0;
+	if ((ahd->bugs & AHD_LONG_SETIMO_BUG)
+	 && (ahd->seltime != STIMESEL_MIN)) {
+		/*
+		 * The selection timer duration is twice as long
+		 * as it should be.  Halve it by adding "1" to
+		 * the user specified setting.
+		 */
+		sxfrctl1 |= ahd->seltime + STIMESEL_BUG_ADJ;
+	} else {
+		sxfrctl1 |= ahd->seltime;
+	}
+		
+	ahd_outb(ahd, SXFRCTL0, DFON);
+	ahd_outb(ahd, SXFRCTL1, sxfrctl1|ahd->seltime|ENSTIMER|ACTNEGEN);
+	ahd_outb(ahd, SIMODE1, ENSELTIMO|ENSCSIRST|ENSCSIPERR);
+
+	/*
+	 * Now that termination is set, wait for up
+	 * to 500ms for our transceivers to settle.  If
+	 * the adapter does not have a cable attached,
+	 * the transceivers may never settle, so don't
+	 * complain if we fail here.
+	 */
+	for (wait = 10000;
+	     (ahd_inb(ahd, SBLKCTL) & (ENAB40|ENAB20)) == 0 && wait;
+	     wait--)
+		ahd_delay(100);
+
+	/* Clear any false bus resets due to the transceivers settling */
+	ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI);
+	ahd_outb(ahd, CLRINT, CLRSCSIINT);
+
+	/* Initialize mode specific S/G state. */
+	for (i = 0; i < 2; i++) {
+		ahd_set_modes(ahd, AHD_MODE_DFF0 + i, AHD_MODE_DFF0 + i);
+		ahd_outb(ahd, LONGJMP_ADDR + 1, INVALID_ADDR);
+		ahd_outb(ahd, SG_STATE, 0);
+		ahd_outb(ahd, CLRSEQINTSRC, 0xFF);
+		ahd_outb(ahd, SEQIMODE,
+			 ENSAVEPTRS|ENCFG4DATA|ENCFG4ISTAT
+			|ENCFG4TSTAT|ENCFG4ICMD|ENCFG4TCMD);
+	}
+
+	ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
+	ahd_outb(ahd, DSCOMMAND0, ahd_inb(ahd, DSCOMMAND0)|MPARCKEN|CACHETHEN);
+	ahd_outb(ahd, DFF_THRSH, RD_DFTHRSH_75|WR_DFTHRSH_75);
+	ahd_outb(ahd, SIMODE0, ENIOERR|ENOVERRUN);
+	ahd_outb(ahd, SIMODE3, ENNTRAMPERR|ENOSRAMPERR);
+	if ((ahd->bugs & AHD_BUSFREEREV_BUG) != 0) {
+		ahd_outb(ahd, OPTIONMODE, AUTOACKEN|AUTO_MSGOUT_DE);
+	} else {
+		ahd_outb(ahd, OPTIONMODE, AUTOACKEN|BUSFREEREV|AUTO_MSGOUT_DE);
+	}
+	ahd_outb(ahd, SCSCHKN, CURRFIFODEF|WIDERESEN|SHVALIDSTDIS);
+	if ((ahd->chip & AHD_BUS_MASK) == AHD_PCIX)
+		/*
+		 * Do not issue a target abort when a split completion
+		 * error occurs.  Let our PCIX interrupt handler deal
+		 * with it instead. H2A4 Razor #625
+		 */
+		ahd_outb(ahd, PCIXCTL, ahd_inb(ahd, PCIXCTL) | SPLTSTADIS);
+
+	if ((ahd->bugs & AHD_LQOOVERRUN_BUG) != 0)
+		ahd_outb(ahd, LQOSCSCTL, LQONOCHKOVER);
+
+	/*
+	 * Tweak IOCELL settings.
+	 */
+	if ((ahd->flags & AHD_HP_BOARD) != 0) {
+		for (i = 0; i < NUMDSPS; i++) {
+			ahd_outb(ahd, DSPSELECT, i);
+			ahd_outb(ahd, WRTBIASCTL, WRTBIASCTL_HP_DEFAULT);
+		}
+#ifdef AHD_DEBUG
+		if ((ahd_debug & AHD_SHOW_MISC) != 0)
+			printf("%s: WRTBIASCTL now 0x%x\n", ahd_name(ahd),
+			       WRTBIASCTL_HP_DEFAULT);
+#endif
+	}
+	ahd_setup_iocell_workaround(ahd);
+
+	/*
+	 * Enable LQI Manager interrupts.
+	 */
+	ahd_outb(ahd, LQIMODE1, ENLQIPHASE_LQ|ENLQIPHASE_NLQ|ENLIQABORT
+			      | ENLQICRCI_LQ|ENLQICRCI_NLQ|ENLQIBADLQI
+			      | ENLQIOVERI_LQ|ENLQIOVERI_NLQ);
+	ahd_outb(ahd, LQOMODE0, ENLQOATNLQ|ENLQOATNPKT|ENLQOTCRC);
+	/*
+	 * An interrupt from LQOBUSFREE is made redundant by the
+	 * BUSFREE interrupt.  We choose to have the sequencer catch
+	 * LQOPHCHGINPKT errors manually for the command phase at the
+	 * start of a packetized selection case.
+	ahd_outb(ahd, LQOMODE1, ENLQOBUSFREE|ENLQOPHACHGINPKT);
+	 */
+	ahd_outb(ahd, LQOMODE1, 0);
+
+	/*
+	 * Setup sequencer interrupt handlers.
+	 */
+	ahd_outw(ahd, INTVEC1_ADDR, ahd_resolve_seqaddr(ahd, LABEL_seq_isr));
+	ahd_outw(ahd, INTVEC2_ADDR, ahd_resolve_seqaddr(ahd, LABEL_timer_isr));
+
+	/*
+	 * Setup SCB Offset registers.
+	 */
+	if ((ahd->bugs & AHD_PKT_LUN_BUG) != 0) {
+		ahd_outb(ahd, LUNPTR, offsetof(struct hardware_scb,
+			 pkt_long_lun));
+	} else {
+		ahd_outb(ahd, LUNPTR, offsetof(struct hardware_scb, lun));
+	}
+	ahd_outb(ahd, CMDLENPTR, offsetof(struct hardware_scb, cdb_len));
+	ahd_outb(ahd, ATTRPTR, offsetof(struct hardware_scb, task_attribute));
+	ahd_outb(ahd, FLAGPTR, offsetof(struct hardware_scb, task_management));
+	ahd_outb(ahd, CMDPTR, offsetof(struct hardware_scb,
+				       shared_data.idata.cdb));
+	ahd_outb(ahd, QNEXTPTR,
+		 offsetof(struct hardware_scb, next_hscb_busaddr));
+	ahd_outb(ahd, ABRTBITPTR, MK_MESSAGE_BIT_OFFSET);
+	ahd_outb(ahd, ABRTBYTEPTR, offsetof(struct hardware_scb, control));
+	if ((ahd->bugs & AHD_PKT_LUN_BUG) != 0) {
+		ahd_outb(ahd, LUNLEN,
+			 sizeof(ahd->next_queued_hscb->pkt_long_lun) - 1);
+	} else {
+		ahd_outb(ahd, LUNLEN, LUNLEN_SINGLE_LEVEL_LUN);
+	}
+	ahd_outb(ahd, CDBLIMIT, SCB_CDB_LEN_PTR - 1);
+	ahd_outb(ahd, MAXCMD, 0xFF);
+	ahd_outb(ahd, SCBAUTOPTR,
+		 AUSCBPTR_EN | offsetof(struct hardware_scb, tag));
+
+	/* We haven't been enabled for target mode yet. */
+	ahd_outb(ahd, MULTARGID, 0);
+	ahd_outb(ahd, MULTARGID + 1, 0);
+
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+	/* Initialize the negotiation table. */
+	if ((ahd->features & AHD_NEW_IOCELL_OPTS) == 0) {
+		/*
+		 * Clear the spare bytes in the neg table to avoid
+		 * spurious parity errors.
+		 */
+		for (target = 0; target < AHD_NUM_TARGETS; target++) {
+			ahd_outb(ahd, NEGOADDR, target);
+			ahd_outb(ahd, ANNEXCOL, AHD_ANNEXCOL_PER_DEV0);
+			for (i = 0; i < AHD_NUM_PER_DEV_ANNEXCOLS; i++)
+				ahd_outb(ahd, ANNEXDAT, 0);
+		}
+	}
+	for (target = 0; target < AHD_NUM_TARGETS; target++) {
+		struct	 ahd_devinfo devinfo;
+		struct	 ahd_initiator_tinfo *tinfo;
+		struct	 ahd_tmode_tstate *tstate;
+
+		tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
+					    target, &tstate);
+		ahd_compile_devinfo(&devinfo, ahd->our_id,
+				    target, CAM_LUN_WILDCARD,
+				    'A', ROLE_INITIATOR);
+		ahd_update_neg_table(ahd, &devinfo, &tinfo->curr);
+	}
+
+	ahd_outb(ahd, CLRSINT3, NTRAMPERR|OSRAMPERR);
+	ahd_outb(ahd, CLRINT, CLRSCSIINT);
+
+	/*
+	 * Always enable abort on incoming L_Qs if this feature is
+	 * supported.  We use this to catch invalid SCB references.
+	 */
+	if ((ahd->bugs & AHD_ABORT_LQI_BUG) == 0)
+		ahd_outb(ahd, LQCTL1, ABORTPENDING);
+	else
+		ahd_outb(ahd, LQCTL1, 0);
+
+	/* All of our queues are empty */
+	ahd->qoutfifonext = 0;
+	ahd->qoutfifonext_valid_tag = QOUTFIFO_ENTRY_VALID_LE;
+	ahd_outb(ahd, QOUTFIFO_ENTRY_VALID_TAG, QOUTFIFO_ENTRY_VALID >> 8);
+	for (i = 0; i < AHD_QOUT_SIZE; i++)
+		ahd->qoutfifo[i] = 0;
+	ahd_sync_qoutfifo(ahd, BUS_DMASYNC_PREREAD);
+
+	ahd->qinfifonext = 0;
+	for (i = 0; i < AHD_QIN_SIZE; i++)
+		ahd->qinfifo[i] = SCB_LIST_NULL;
+
+	if ((ahd->features & AHD_TARGETMODE) != 0) {
+		/* All target command blocks start out invalid. */
+		for (i = 0; i < AHD_TMODE_CMDS; i++)
+			ahd->targetcmds[i].cmd_valid = 0;
+		ahd_sync_tqinfifo(ahd, BUS_DMASYNC_PREREAD);
+		ahd->tqinfifonext = 1;
+		ahd_outb(ahd, KERNEL_TQINPOS, ahd->tqinfifonext - 1);
+		ahd_outb(ahd, TQINPOS, ahd->tqinfifonext);
+	}
+
+	/* Initialize Scratch Ram. */
+	ahd_outb(ahd, SEQ_FLAGS, 0);
+	ahd_outb(ahd, SEQ_FLAGS2, 0);
+
+	/* We don't have any waiting selections */
+	ahd_outw(ahd, WAITING_TID_HEAD, SCB_LIST_NULL);
+	ahd_outw(ahd, WAITING_TID_TAIL, SCB_LIST_NULL);
+	for (i = 0; i < AHD_NUM_TARGETS; i++)
+		ahd_outw(ahd, WAITING_SCB_TAILS + (2 * i), SCB_LIST_NULL);
+
+	/*
+	 * Nobody is waiting to be DMAed into the QOUTFIFO.
+	 */
+	ahd_outw(ahd, COMPLETE_SCB_HEAD, SCB_LIST_NULL);
+	ahd_outw(ahd, COMPLETE_SCB_DMAINPROG_HEAD, SCB_LIST_NULL);
+	ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, SCB_LIST_NULL);
+
+	/*
+	 * The Freeze Count is 0.
+	 */
+	ahd_outw(ahd, QFREEZE_COUNT, 0);
+
+	/*
+	 * Tell the sequencer where it can find our arrays in memory.
+	 */
+	busaddr = ahd->shared_data_busaddr;
+	ahd_outb(ahd, SHARED_DATA_ADDR, busaddr & 0xFF);
+	ahd_outb(ahd, SHARED_DATA_ADDR + 1, (busaddr >> 8) & 0xFF);
+	ahd_outb(ahd, SHARED_DATA_ADDR + 2, (busaddr >> 16) & 0xFF);
+	ahd_outb(ahd, SHARED_DATA_ADDR + 3, (busaddr >> 24) & 0xFF);
+	ahd_outb(ahd, QOUTFIFO_NEXT_ADDR, busaddr & 0xFF);
+	ahd_outb(ahd, QOUTFIFO_NEXT_ADDR + 1, (busaddr >> 8) & 0xFF);
+	ahd_outb(ahd, QOUTFIFO_NEXT_ADDR + 2, (busaddr >> 16) & 0xFF);
+	ahd_outb(ahd, QOUTFIFO_NEXT_ADDR + 3, (busaddr >> 24) & 0xFF);
+
+	/*
+	 * Setup the allowed SCSI Sequences based on operational mode.
+	 * If we are a target, we'll enable select in operations once
+	 * we've had a lun enabled.
+	 */
+	scsiseq_template = ENAUTOATNP;
+	if ((ahd->flags & AHD_INITIATORROLE) != 0)
+		scsiseq_template |= ENRSELI;
+	ahd_outb(ahd, SCSISEQ_TEMPLATE, scsiseq_template);
+
+	/* There are no busy SCBs yet. */
+	for (target = 0; target < AHD_NUM_TARGETS; target++) {
+		int lun;
+
+		for (lun = 0; lun < AHD_NUM_LUNS_NONPKT; lun++)
+			ahd_unbusy_tcl(ahd, BUILD_TCL_RAW(target, 'A', lun));
+	}
+
+	/*
+	 * Initialize the group code to command length table.
+	 * Vendor Unique codes are set to 0 so we only capture
+	 * the first byte of the cdb.  These can be overridden
+	 * when target mode is enabled.
+	 */
+	ahd_outb(ahd, CMDSIZE_TABLE, 5);
+	ahd_outb(ahd, CMDSIZE_TABLE + 1, 9);
+	ahd_outb(ahd, CMDSIZE_TABLE + 2, 9);
+	ahd_outb(ahd, CMDSIZE_TABLE + 3, 0);
+	ahd_outb(ahd, CMDSIZE_TABLE + 4, 15);
+	ahd_outb(ahd, CMDSIZE_TABLE + 5, 11);
+	ahd_outb(ahd, CMDSIZE_TABLE + 6, 0);
+	ahd_outb(ahd, CMDSIZE_TABLE + 7, 0);
+		
+	/* Tell the sequencer of our initial queue positions */
+	ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
+	ahd_outb(ahd, QOFF_CTLSTA, SCB_QSIZE_512);
+	ahd->qinfifonext = 0;
+	ahd_set_hnscb_qoff(ahd, ahd->qinfifonext);
+	ahd_set_hescb_qoff(ahd, 0);
+	ahd_set_snscb_qoff(ahd, 0);
+	ahd_set_sescb_qoff(ahd, 0);
+	ahd_set_sdscb_qoff(ahd, 0);
+
+	/*
+	 * Tell the sequencer which SCB will be the next one it receives.
+	 */
+	busaddr = ahd_le32toh(ahd->next_queued_hscb->hscb_busaddr);
+	ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 0, busaddr & 0xFF);
+	ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 1, (busaddr >> 8) & 0xFF);
+	ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 2, (busaddr >> 16) & 0xFF);
+	ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 3, (busaddr >> 24) & 0xFF);
+
+	/*
+	 * Default to coalescing disabled.
+	 */
+	ahd_outw(ahd, INT_COALESCING_CMDCOUNT, 0);
+	ahd_outw(ahd, CMDS_PENDING, 0);
+	ahd_update_coalescing_values(ahd, ahd->int_coalescing_timer,
+				     ahd->int_coalescing_maxcmds,
+				     ahd->int_coalescing_mincmds);
+	ahd_enable_coalescing(ahd, FALSE);
+
+	ahd_loadseq(ahd);
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+}
+
+/*
+ * Setup default device and controller settings.
+ * This should only be called if our probe has
+ * determined that no configuration data is available.
+ */
+int
+ahd_default_config(struct ahd_softc *ahd)
+{
+	int	targ;
+
+	ahd->our_id = 7;
+
+	/*
+	 * Allocate a tstate to house information for our
+	 * initiator presence on the bus as well as the user
+	 * data for any target mode initiator.
+	 */
+	if (ahd_alloc_tstate(ahd, ahd->our_id, 'A') == NULL) {
+		printf("%s: unable to allocate ahd_tmode_tstate.  "
+		       "Failing attach\n", ahd_name(ahd));
+		return (ENOMEM);
+	}
+
+	for (targ = 0; targ < AHD_NUM_TARGETS; targ++) {
+		struct	 ahd_devinfo devinfo;
+		struct	 ahd_initiator_tinfo *tinfo;
+		struct	 ahd_tmode_tstate *tstate;
+		uint16_t target_mask;
+
+		tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
+					    targ, &tstate);
+		/*
+		 * We support SPC2 and SPI4.
+		 */
+		tinfo->user.protocol_version = 4;
+		tinfo->user.transport_version = 4;
+
+		target_mask = 0x01 << targ;
+		ahd->user_discenable |= target_mask;
+		tstate->discenable |= target_mask;
+		ahd->user_tagenable |= target_mask;
+#ifdef AHD_FORCE_160
+		tinfo->user.period = AHD_SYNCRATE_DT;
+#else
+		tinfo->user.period = AHD_SYNCRATE_160;
+#endif
+		tinfo->user.offset = MAX_OFFSET;
+		tinfo->user.ppr_options = MSG_EXT_PPR_RD_STRM
+					| MSG_EXT_PPR_WR_FLOW
+					| MSG_EXT_PPR_HOLD_MCS
+					| MSG_EXT_PPR_IU_REQ
+					| MSG_EXT_PPR_QAS_REQ
+					| MSG_EXT_PPR_DT_REQ;
+		if ((ahd->features & AHD_RTI) != 0)
+			tinfo->user.ppr_options |= MSG_EXT_PPR_RTI;
+
+		tinfo->user.width = MSG_EXT_WDTR_BUS_16_BIT;
+
+		/*
+		 * Start out Async/Narrow/Untagged and with
+		 * conservative protocol support.
+		 */
+		tinfo->goal.protocol_version = 2;
+		tinfo->goal.transport_version = 2;
+		tinfo->curr.protocol_version = 2;
+		tinfo->curr.transport_version = 2;
+		ahd_compile_devinfo(&devinfo, ahd->our_id,
+				    targ, CAM_LUN_WILDCARD,
+				    'A', ROLE_INITIATOR);
+		tstate->tagenable &= ~target_mask;
+		ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
+			      AHD_TRANS_CUR|AHD_TRANS_GOAL, /*paused*/TRUE);
+		ahd_set_syncrate(ahd, &devinfo, /*period*/0, /*offset*/0,
+				 /*ppr_options*/0, AHD_TRANS_CUR|AHD_TRANS_GOAL,
+				 /*paused*/TRUE);
+	}
+	return (0);
+}
+
+/*
+ * Parse device configuration information.
+ */
+int
+ahd_parse_cfgdata(struct ahd_softc *ahd, struct seeprom_config *sc)
+{
+	int targ;
+	int max_targ;
+
+	max_targ = sc->max_targets & CFMAXTARG;
+	ahd->our_id = sc->brtime_id & CFSCSIID;
+
+	/*
+	 * Allocate a tstate to house information for our
+	 * initiator presence on the bus as well as the user
+	 * data for any target mode initiator.
+	 */
+	if (ahd_alloc_tstate(ahd, ahd->our_id, 'A') == NULL) {
+		printf("%s: unable to allocate ahd_tmode_tstate.  "
+		       "Failing attach\n", ahd_name(ahd));
+		return (ENOMEM);
+	}
+
+	for (targ = 0; targ < max_targ; targ++) {
+		struct	 ahd_devinfo devinfo;
+		struct	 ahd_initiator_tinfo *tinfo;
+		struct	 ahd_transinfo *user_tinfo;
+		struct	 ahd_tmode_tstate *tstate;
+		uint16_t target_mask;
+
+		tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
+					    targ, &tstate);
+		user_tinfo = &tinfo->user;
+
+		/*
+		 * We support SPC2 and SPI4.
+		 */
+		tinfo->user.protocol_version = 4;
+		tinfo->user.transport_version = 4;
+
+		target_mask = 0x01 << targ;
+		ahd->user_discenable &= ~target_mask;
+		tstate->discenable &= ~target_mask;
+		ahd->user_tagenable &= ~target_mask;
+		if (sc->device_flags[targ] & CFDISC) {
+			tstate->discenable |= target_mask;
+			ahd->user_discenable |= target_mask;
+			ahd->user_tagenable |= target_mask;
+		} else {
+			/*
+			 * Cannot be packetized without disconnection.
+			 */
+			sc->device_flags[targ] &= ~CFPACKETIZED;
+		}
+
+		user_tinfo->ppr_options = 0;
+		user_tinfo->period = (sc->device_flags[targ] & CFXFER);
+		if (user_tinfo->period < CFXFER_ASYNC) {
+			if (user_tinfo->period <= AHD_PERIOD_10MHz)
+				user_tinfo->ppr_options |= MSG_EXT_PPR_DT_REQ;
+			user_tinfo->offset = MAX_OFFSET;
+		} else  {
+			user_tinfo->offset = 0;
+			user_tinfo->period = AHD_ASYNC_XFER_PERIOD;
+		}
+#ifdef AHD_FORCE_160
+		if (user_tinfo->period <= AHD_SYNCRATE_160)
+			user_tinfo->period = AHD_SYNCRATE_DT;
+#endif
+
+		if ((sc->device_flags[targ] & CFPACKETIZED) != 0) {
+			user_tinfo->ppr_options |= MSG_EXT_PPR_RD_STRM
+						|  MSG_EXT_PPR_WR_FLOW
+						|  MSG_EXT_PPR_HOLD_MCS
+						|  MSG_EXT_PPR_IU_REQ;
+			if ((ahd->features & AHD_RTI) != 0)
+				user_tinfo->ppr_options |= MSG_EXT_PPR_RTI;
+		}
+
+		if ((sc->device_flags[targ] & CFQAS) != 0)
+			user_tinfo->ppr_options |= MSG_EXT_PPR_QAS_REQ;
+
+		if ((sc->device_flags[targ] & CFWIDEB) != 0)
+			user_tinfo->width = MSG_EXT_WDTR_BUS_16_BIT;
+		else
+			user_tinfo->width = MSG_EXT_WDTR_BUS_8_BIT;
+#ifdef AHD_DEBUG
+		if ((ahd_debug & AHD_SHOW_MISC) != 0)
+			printf("(%d): %x:%x:%x:%x\n", targ, user_tinfo->width,
+			       user_tinfo->period, user_tinfo->offset,
+			       user_tinfo->ppr_options);
+#endif
+		/*
+		 * Start out Async/Narrow/Untagged and with
+		 * conservative protocol support.
+		 */
+		tstate->tagenable &= ~target_mask;
+		tinfo->goal.protocol_version = 2;
+		tinfo->goal.transport_version = 2;
+		tinfo->curr.protocol_version = 2;
+		tinfo->curr.transport_version = 2;
+		ahd_compile_devinfo(&devinfo, ahd->our_id,
+				    targ, CAM_LUN_WILDCARD,
+				    'A', ROLE_INITIATOR);
+		ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
+			      AHD_TRANS_CUR|AHD_TRANS_GOAL, /*paused*/TRUE);
+		ahd_set_syncrate(ahd, &devinfo, /*period*/0, /*offset*/0,
+				 /*ppr_options*/0, AHD_TRANS_CUR|AHD_TRANS_GOAL,
+				 /*paused*/TRUE);
+	}
+
+	ahd->flags &= ~AHD_SPCHK_ENB_A;
+	if (sc->bios_control & CFSPARITY)
+		ahd->flags |= AHD_SPCHK_ENB_A;
+
+	ahd->flags &= ~AHD_RESET_BUS_A;
+	if (sc->bios_control & CFRESETB)
+		ahd->flags |= AHD_RESET_BUS_A;
+
+	ahd->flags &= ~AHD_EXTENDED_TRANS_A;
+	if (sc->bios_control & CFEXTEND)
+		ahd->flags |= AHD_EXTENDED_TRANS_A;
+
+	ahd->flags &= ~AHD_BIOS_ENABLED;
+	if ((sc->bios_control & CFBIOSSTATE) == CFBS_ENABLED)
+		ahd->flags |= AHD_BIOS_ENABLED;
+
+	ahd->flags &= ~AHD_STPWLEVEL_A;
+	if ((sc->adapter_control & CFSTPWLEVEL) != 0)
+		ahd->flags |= AHD_STPWLEVEL_A;
+
+	return (0);
+}
+
+/*
+ * Parse device configuration information.
+ */
+int
+ahd_parse_vpddata(struct ahd_softc *ahd, struct vpd_config *vpd)
+{
+	int error;
+
+	error = ahd_verify_vpd_cksum(vpd);
+	if (error == 0)
+		return (EINVAL);
+	if ((vpd->bios_flags & VPDBOOTHOST) != 0)
+		ahd->flags |= AHD_BOOT_CHANNEL;
+	return (0);
+}
+
+void
+ahd_intr_enable(struct ahd_softc *ahd, int enable)
+{
+	u_int hcntrl;
+
+	hcntrl = ahd_inb(ahd, HCNTRL);
+	hcntrl &= ~INTEN;
+	ahd->pause &= ~INTEN;
+	ahd->unpause &= ~INTEN;
+	if (enable) {
+		hcntrl |= INTEN;
+		ahd->pause |= INTEN;
+		ahd->unpause |= INTEN;
+	}
+	ahd_outb(ahd, HCNTRL, hcntrl);
+}
+
+void
+ahd_update_coalescing_values(struct ahd_softc *ahd, u_int timer, u_int maxcmds,
+			     u_int mincmds)
+{
+	if (timer > AHD_TIMER_MAX_US)
+		timer = AHD_TIMER_MAX_US;
+	ahd->int_coalescing_timer = timer;
+
+	if (maxcmds > AHD_INT_COALESCING_MAXCMDS_MAX)
+		maxcmds = AHD_INT_COALESCING_MAXCMDS_MAX;
+	if (mincmds > AHD_INT_COALESCING_MINCMDS_MAX)
+		mincmds = AHD_INT_COALESCING_MINCMDS_MAX;
+	ahd->int_coalescing_maxcmds = maxcmds;
+	ahd_outw(ahd, INT_COALESCING_TIMER, timer / AHD_TIMER_US_PER_TICK);
+	ahd_outb(ahd, INT_COALESCING_MAXCMDS, -maxcmds);
+	ahd_outb(ahd, INT_COALESCING_MINCMDS, -mincmds);
+}
+
+void
+ahd_enable_coalescing(struct ahd_softc *ahd, int enable)
+{
+
+	ahd->hs_mailbox &= ~ENINT_COALESCE;
+	if (enable)
+		ahd->hs_mailbox |= ENINT_COALESCE;
+	ahd_outb(ahd, HS_MAILBOX, ahd->hs_mailbox);
+	ahd_flush_device_writes(ahd);
+	ahd_run_qoutfifo(ahd);
+}
+
+/*
+ * Ensure that the card is paused in a location
+ * outside of all critical sections and that all
+ * pending work is completed prior to returning.
+ * This routine should only be called from outside
+ * an interrupt context.
+ */
+void
+ahd_pause_and_flushwork(struct ahd_softc *ahd)
+{
+	u_int intstat;
+	u_int maxloops;
+	u_int qfreeze_cnt;
+
+	maxloops = 1000;
+	ahd->flags |= AHD_ALL_INTERRUPTS;
+	ahd_pause(ahd);
+	/*
+	 * Increment the QFreeze Count so that the sequencer
+	 * will not start new selections.  We do this only
+	 * until we are safely paused without further selections
+	 * pending.
+	 */
+	ahd_outw(ahd, QFREEZE_COUNT, ahd_inw(ahd, QFREEZE_COUNT) + 1);
+	ahd_outb(ahd, SEQ_FLAGS2, ahd_inb(ahd, SEQ_FLAGS2) | SELECTOUT_QFROZEN);
+	do {
+		struct scb *waiting_scb;
+
+		ahd_unpause(ahd);
+		ahd_intr(ahd);
+		ahd_pause(ahd);
+		ahd_clear_critical_section(ahd);
+		intstat = ahd_inb(ahd, INTSTAT);
+		ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+		if ((ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO)) == 0)
+			ahd_outb(ahd, SCSISEQ0,
+				 ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
+		/*
+		 * In the non-packetized case, the sequencer (for Rev A),
+		 * relies on ENSELO remaining set after SELDO.  The hardware
+		 * auto-clears ENSELO in the packetized case.
+		 */
+		waiting_scb = ahd_lookup_scb(ahd,
+					     ahd_inw(ahd, WAITING_TID_HEAD));
+		if (waiting_scb != NULL
+		 && (waiting_scb->flags & SCB_PACKETIZED) == 0
+		 && (ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO)) != 0)
+			ahd_outb(ahd, SCSISEQ0,
+				 ahd_inb(ahd, SCSISEQ0) | ENSELO);
+	} while (--maxloops
+	      && (intstat != 0xFF || (ahd->features & AHD_REMOVABLE) == 0)
+	      && ((intstat & INT_PEND) != 0
+	       || (ahd_inb(ahd, SCSISEQ0) & ENSELO) != 0
+	       || (ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO)) != 0));
+
+	if (maxloops == 0) {
+		printf("Infinite interrupt loop, INTSTAT = %x",
+		      ahd_inb(ahd, INTSTAT));
+	}
+	qfreeze_cnt = ahd_inw(ahd, QFREEZE_COUNT);
+	if (qfreeze_cnt == 0) {
+		printf("%s: ahd_pause_and_flushwork with 0 qfreeze count!\n",
+		       ahd_name(ahd));
+	} else {
+		qfreeze_cnt--;
+	}
+	ahd_outw(ahd, QFREEZE_COUNT, qfreeze_cnt);
+	if (qfreeze_cnt == 0)
+		ahd_outb(ahd, SEQ_FLAGS2,
+			 ahd_inb(ahd, SEQ_FLAGS2) & ~SELECTOUT_QFROZEN);
+
+	ahd_flush_qoutfifo(ahd);
+
+	ahd_platform_flushwork(ahd);
+	ahd->flags &= ~AHD_ALL_INTERRUPTS;
+}
+
+int
+ahd_suspend(struct ahd_softc *ahd)
+{
+
+	ahd_pause_and_flushwork(ahd);
+
+	if (LIST_FIRST(&ahd->pending_scbs) != NULL) {
+		ahd_unpause(ahd);
+		return (EBUSY);
+	}
+	ahd_shutdown(ahd);
+	return (0);
+}
+
+int
+ahd_resume(struct ahd_softc *ahd)
+{
+
+	ahd_reset(ahd, /*reinit*/TRUE);
+	ahd_intr_enable(ahd, TRUE); 
+	ahd_restart(ahd);
+	return (0);
+}
+
+/************************** Busy Target Table *********************************/
+/*
+ * Set SCBPTR to the SCB that contains the busy
+ * table entry for TCL.  Return the offset into
+ * the SCB that contains the entry for TCL.
+ * saved_scbid is dereferenced and set to the
+ * scbid that should be restored once manipualtion
+ * of the TCL entry is complete.
+ */
+static __inline u_int
+ahd_index_busy_tcl(struct ahd_softc *ahd, u_int *saved_scbid, u_int tcl)
+{
+	/*
+	 * Index to the SCB that contains the busy entry.
+	 */
+	AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
+	*saved_scbid = ahd_get_scbptr(ahd);
+	ahd_set_scbptr(ahd, TCL_LUN(tcl)
+		     | ((TCL_TARGET_OFFSET(tcl) & 0xC) << 4));
+
+	/*
+	 * And now calculate the SCB offset to the entry.
+	 * Each entry is 2 bytes wide, hence the
+	 * multiplication by 2.
+	 */
+	return (((TCL_TARGET_OFFSET(tcl) & 0x3) << 1) + SCB_DISCONNECTED_LISTS);
+}
+
+/*
+ * Return the untagged transaction id for a given target/channel lun.
+ */
+u_int
+ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl)
+{
+	u_int scbid;
+	u_int scb_offset;
+	u_int saved_scbptr;
+		
+	scb_offset = ahd_index_busy_tcl(ahd, &saved_scbptr, tcl);
+	scbid = ahd_inw_scbram(ahd, scb_offset);
+	ahd_set_scbptr(ahd, saved_scbptr);
+	return (scbid);
+}
+
+void
+ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl, u_int scbid)
+{
+	u_int scb_offset;
+	u_int saved_scbptr;
+		
+	scb_offset = ahd_index_busy_tcl(ahd, &saved_scbptr, tcl);
+	ahd_outw(ahd, scb_offset, scbid);
+	ahd_set_scbptr(ahd, saved_scbptr);
+}
+
+/************************** SCB and SCB queue management **********************/
+int
+ahd_match_scb(struct ahd_softc *ahd, struct scb *scb, int target,
+	      char channel, int lun, u_int tag, role_t role)
+{
+	int targ = SCB_GET_TARGET(ahd, scb);
+	char chan = SCB_GET_CHANNEL(ahd, scb);
+	int slun = SCB_GET_LUN(scb);
+	int match;
+
+	match = ((chan == channel) || (channel == ALL_CHANNELS));
+	if (match != 0)
+		match = ((targ == target) || (target == CAM_TARGET_WILDCARD));
+	if (match != 0)
+		match = ((lun == slun) || (lun == CAM_LUN_WILDCARD));
+	if (match != 0) {
+#if AHD_TARGET_MODE
+		int group;
+
+		group = XPT_FC_GROUP(scb->io_ctx->ccb_h.func_code);
+		if (role == ROLE_INITIATOR) {
+			match = (group != XPT_FC_GROUP_TMODE)
+			      && ((tag == SCB_GET_TAG(scb))
+			       || (tag == SCB_LIST_NULL));
+		} else if (role == ROLE_TARGET) {
+			match = (group == XPT_FC_GROUP_TMODE)
+			      && ((tag == scb->io_ctx->csio.tag_id)
+			       || (tag == SCB_LIST_NULL));
+		}
+#else /* !AHD_TARGET_MODE */
+		match = ((tag == SCB_GET_TAG(scb)) || (tag == SCB_LIST_NULL));
+#endif /* AHD_TARGET_MODE */
+	}
+
+	return match;
+}
+
+void
+ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb)
+{
+	int	target;
+	char	channel;
+	int	lun;
+
+	target = SCB_GET_TARGET(ahd, scb);
+	lun = SCB_GET_LUN(scb);
+	channel = SCB_GET_CHANNEL(ahd, scb);
+	
+	ahd_search_qinfifo(ahd, target, channel, lun,
+			   /*tag*/SCB_LIST_NULL, ROLE_UNKNOWN,
+			   CAM_REQUEUE_REQ, SEARCH_COMPLETE);
+
+	ahd_platform_freeze_devq(ahd, scb);
+}
+
+void
+ahd_qinfifo_requeue_tail(struct ahd_softc *ahd, struct scb *scb)
+{
+	struct scb	*prev_scb;
+	ahd_mode_state	 saved_modes;
+
+	saved_modes = ahd_save_modes(ahd);
+	ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
+	prev_scb = NULL;
+	if (ahd_qinfifo_count(ahd) != 0) {
+		u_int prev_tag;
+		u_int prev_pos;
+
+		prev_pos = AHD_QIN_WRAP(ahd->qinfifonext - 1);
+		prev_tag = ahd->qinfifo[prev_pos];
+		prev_scb = ahd_lookup_scb(ahd, prev_tag);
+	}
+	ahd_qinfifo_requeue(ahd, prev_scb, scb);
+	ahd_set_hnscb_qoff(ahd, ahd->qinfifonext);
+	ahd_restore_modes(ahd, saved_modes);
+}
+
+static void
+ahd_qinfifo_requeue(struct ahd_softc *ahd, struct scb *prev_scb,
+		    struct scb *scb)
+{
+	if (prev_scb == NULL) {
+		uint32_t busaddr;
+
+		busaddr = ahd_le32toh(scb->hscb->hscb_busaddr);
+		ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 0, busaddr & 0xFF);
+		ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 1, (busaddr >> 8) & 0xFF);
+		ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 2, (busaddr >> 16) & 0xFF);
+		ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 3, (busaddr >> 24) & 0xFF);
+	} else {
+		prev_scb->hscb->next_hscb_busaddr = scb->hscb->hscb_busaddr;
+		ahd_sync_scb(ahd, prev_scb, 
+			     BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
+	}
+	ahd->qinfifo[AHD_QIN_WRAP(ahd->qinfifonext)] = SCB_GET_TAG(scb);
+	ahd->qinfifonext++;
+	scb->hscb->next_hscb_busaddr = ahd->next_queued_hscb->hscb_busaddr;
+	ahd_sync_scb(ahd, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
+}
+
+static int
+ahd_qinfifo_count(struct ahd_softc *ahd)
+{
+	u_int qinpos;
+	u_int wrap_qinpos;
+	u_int wrap_qinfifonext;
+
+	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
+	qinpos = ahd_get_snscb_qoff(ahd);
+	wrap_qinpos = AHD_QIN_WRAP(qinpos);
+	wrap_qinfifonext = AHD_QIN_WRAP(ahd->qinfifonext);
+	if (wrap_qinfifonext >= wrap_qinpos)
+		return (wrap_qinfifonext - wrap_qinpos);
+	else
+		return (wrap_qinfifonext
+		      + NUM_ELEMENTS(ahd->qinfifo) - wrap_qinpos);
+}
+
+void
+ahd_reset_cmds_pending(struct ahd_softc *ahd)
+{
+	struct		scb *scb;
+	ahd_mode_state	saved_modes;
+	u_int		pending_cmds;
+
+	saved_modes = ahd_save_modes(ahd);
+	ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
+
+	/*
+	 * Don't count any commands as outstanding that the
+	 * sequencer has already marked for completion.
+	 */
+	ahd_flush_qoutfifo(ahd);
+
+	pending_cmds = 0;
+	LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) {
+		pending_cmds++;
+	}
+	ahd_outw(ahd, CMDS_PENDING, pending_cmds - ahd_qinfifo_count(ahd));
+	ahd_restore_modes(ahd, saved_modes);
+	ahd->flags &= ~AHD_UPDATE_PEND_CMDS;
+}
+
+int
+ahd_search_qinfifo(struct ahd_softc *ahd, int target, char channel,
+		   int lun, u_int tag, role_t role, uint32_t status,
+		   ahd_search_action action)
+{
+	struct scb	*scb;
+	struct scb	*prev_scb;
+	ahd_mode_state	 saved_modes;
+	u_int		 qinstart;
+	u_int		 qinpos;
+	u_int		 qintail;
+	u_int		 tid_next;
+	u_int		 tid_prev;
+	u_int		 scbid;
+	u_int		 savedscbptr;
+	uint32_t	 busaddr;
+	int		 found;
+	int		 targets;
+
+	/* Must be in CCHAN mode */
+	saved_modes = ahd_save_modes(ahd);
+	ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
+
+	/*
+	 * Halt any pending SCB DMA.  The sequencer will reinitiate
+	 * this dma if the qinfifo is not empty once we unpause.
+	 */
+	if ((ahd_inb(ahd, CCSCBCTL) & (CCARREN|CCSCBEN|CCSCBDIR))
+	 == (CCARREN|CCSCBEN|CCSCBDIR)) {
+		ahd_outb(ahd, CCSCBCTL,
+			 ahd_inb(ahd, CCSCBCTL) & ~(CCARREN|CCSCBEN));
+		while ((ahd_inb(ahd, CCSCBCTL) & (CCARREN|CCSCBEN)) != 0)
+			;
+	}
+	/* Determine sequencer's position in the qinfifo. */
+	qintail = AHD_QIN_WRAP(ahd->qinfifonext);
+	qinstart = ahd_get_snscb_qoff(ahd);
+	qinpos = AHD_QIN_WRAP(qinstart);
+	found = 0;
+	prev_scb = NULL;
+
+	if (action == SEARCH_PRINT) {
+		printf("qinstart = %d qinfifonext = %d\nQINFIFO:",
+		       qinstart, ahd->qinfifonext);
+	}
+
+	/*
+	 * Start with an empty queue.  Entries that are not chosen
+	 * for removal will be re-added to the queue as we go.
+	 */
+	ahd->qinfifonext = qinstart;
+	busaddr = ahd_le32toh(ahd->next_queued_hscb->hscb_busaddr);
+	ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 0, busaddr & 0xFF);
+	ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 1, (busaddr >> 8) & 0xFF);
+	ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 2, (busaddr >> 16) & 0xFF);
+	ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 3, (busaddr >> 24) & 0xFF);
+
+	while (qinpos != qintail) {
+		scb = ahd_lookup_scb(ahd, ahd->qinfifo[qinpos]);
+		if (scb == NULL) {
+			printf("qinpos = %d, SCB index = %d\n",
+				qinpos, ahd->qinfifo[qinpos]);
+			panic("Loop 1\n");
+		}
+
+		if (ahd_match_scb(ahd, scb, target, channel, lun, tag, role)) {
+			/*
+			 * We found an scb that needs to be acted on.
+			 */
+			found++;
+			switch (action) {
+			case SEARCH_COMPLETE:
+			{
+				cam_status ostat;
+				cam_status cstat;
+
+				ostat = ahd_get_transaction_status(scb);
+				if (ostat == CAM_REQ_INPROG)
+					ahd_set_transaction_status(scb,
+								   status);
+				cstat = ahd_get_transaction_status(scb);
+				if (cstat != CAM_REQ_CMP)
+					ahd_freeze_scb(scb);
+				if ((scb->flags & SCB_ACTIVE) == 0)
+					printf("Inactive SCB in qinfifo\n");
+				ahd_done(ahd, scb);
+
+				/* FALLTHROUGH */
+			}
+			case SEARCH_REMOVE:
+				break;
+			case SEARCH_PRINT:
+				printf(" 0x%x", ahd->qinfifo[qinpos]);
+				/* FALLTHROUGH */
+			case SEARCH_COUNT:
+				ahd_qinfifo_requeue(ahd, prev_scb, scb);
+				prev_scb = scb;
+				break;
+			}
+		} else {
+			ahd_qinfifo_requeue(ahd, prev_scb, scb);
+			prev_scb = scb;
+		}
+		qinpos = AHD_QIN_WRAP(qinpos+1);
+	}
+
+	ahd_set_hnscb_qoff(ahd, ahd->qinfifonext);
+
+	if (action == SEARCH_PRINT)
+		printf("\nWAITING_TID_QUEUES:\n");
+
+	/*
+	 * Search waiting for selection lists.  We traverse the
+	 * list of "their ids" waiting for selection and, if
+	 * appropriate, traverse the SCBs of each "their id"
+	 * looking for matches.
+	 */
+	savedscbptr = ahd_get_scbptr(ahd);
+	tid_next = ahd_inw(ahd, WAITING_TID_HEAD);
+	tid_prev = SCB_LIST_NULL;
+	targets = 0;
+	for (scbid = tid_next; !SCBID_IS_NULL(scbid); scbid = tid_next) {
+		u_int tid_head;
+
+		/*
+		 * We limit based on the number of SCBs since
+		 * MK_MESSAGE SCBs are not in the per-tid lists.
+		 */
+		targets++;
+		if (targets > AHD_SCB_MAX) {
+			panic("TID LIST LOOP");
+		}
+		if (scbid >= ahd->scb_data.numscbs) {
+			printf("%s: Waiting TID List inconsistency. "
+			       "SCB index == 0x%x, yet numscbs == 0x%x.",
+			       ahd_name(ahd), scbid, ahd->scb_data.numscbs);
+			ahd_dump_card_state(ahd);
+			panic("for safety");
+		}
+		scb = ahd_lookup_scb(ahd, scbid);
+		if (scb == NULL) {
+			printf("%s: SCB = 0x%x Not Active!\n",
+			       ahd_name(ahd), scbid);
+			panic("Waiting TID List traversal\n");
+		}
+		ahd_set_scbptr(ahd, scbid);
+		tid_next = ahd_inw_scbram(ahd, SCB_NEXT2);
+		if (ahd_match_scb(ahd, scb, target, channel, CAM_LUN_WILDCARD,
+				  SCB_LIST_NULL, ROLE_UNKNOWN) == 0) {
+			tid_prev = scbid;
+			continue;
+		}
+
+		/*
+		 * We found a list of scbs that needs to be searched.
+		 */
+		if (action == SEARCH_PRINT)
+			printf("       %d ( ", SCB_GET_TARGET(ahd, scb));
+		tid_head = scbid;
+		found += ahd_search_scb_list(ahd, target, channel,
+					     lun, tag, role, status,
+					     action, &tid_head,
+					     SCB_GET_TARGET(ahd, scb));
+		if (tid_head != scbid)
+			ahd_stitch_tid_list(ahd, tid_prev, tid_head, tid_next);
+		if (!SCBID_IS_NULL(tid_head))
+			tid_prev = tid_head;
+		if (action == SEARCH_PRINT)
+			printf(")\n");
+	}
+	ahd_set_scbptr(ahd, savedscbptr);
+	ahd_restore_modes(ahd, saved_modes);
+	return (found);
+}
+
+static int
+ahd_search_scb_list(struct ahd_softc *ahd, int target, char channel,
+		    int lun, u_int tag, role_t role, uint32_t status,
+		    ahd_search_action action, u_int *list_head, u_int tid)
+{
+	struct	scb *scb;
+	u_int	scbid;
+	u_int	next;
+	u_int	prev;
+	int	found;
+
+	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
+	found = 0;
+	prev = SCB_LIST_NULL;
+	next = *list_head;
+	for (scbid = next; !SCBID_IS_NULL(scbid); scbid = next) {
+		if (scbid >= ahd->scb_data.numscbs) {
+			printf("%s:SCB List inconsistency. "
+			       "SCB == 0x%x, yet numscbs == 0x%x.",
+			       ahd_name(ahd), scbid, ahd->scb_data.numscbs);
+			ahd_dump_card_state(ahd);
+			panic("for safety");
+		}
+		scb = ahd_lookup_scb(ahd, scbid);
+		if (scb == NULL) {
+			printf("%s: SCB = %d Not Active!\n",
+			       ahd_name(ahd), scbid);
+			panic("Waiting List traversal\n");
+		}
+		ahd_set_scbptr(ahd, scbid);
+		next = ahd_inw_scbram(ahd, SCB_NEXT);
+		if (ahd_match_scb(ahd, scb, target, channel,
+				  lun, SCB_LIST_NULL, role) == 0) {
+			prev = scbid;
+			continue;
+		}
+		found++;
+		switch (action) {
+		case SEARCH_COMPLETE:
+		{
+			cam_status ostat;
+			cam_status cstat;
+
+			ostat = ahd_get_transaction_status(scb);
+			if (ostat == CAM_REQ_INPROG)
+				ahd_set_transaction_status(scb, status);
+			cstat = ahd_get_transaction_status(scb);
+			if (cstat != CAM_REQ_CMP)
+				ahd_freeze_scb(scb);
+			if ((scb->flags & SCB_ACTIVE) == 0)
+				printf("Inactive SCB in Waiting List\n");
+			ahd_done(ahd, scb);
+			/* FALLTHROUGH */
+		}
+		case SEARCH_REMOVE:
+			ahd_rem_wscb(ahd, scbid, prev, next, tid);
+			if (prev == SCB_LIST_NULL)
+				*list_head = next;
+			break;
+		case SEARCH_PRINT:
+			printf("0x%x ", scbid);
+		case SEARCH_COUNT:
+			prev = scbid;
+			break;
+		}
+		if (found > AHD_SCB_MAX)
+			panic("SCB LIST LOOP");
+	}
+	if (action == SEARCH_COMPLETE
+	 || action == SEARCH_REMOVE)
+		ahd_outw(ahd, CMDS_PENDING, ahd_inw(ahd, CMDS_PENDING) - found);
+	return (found);
+}
+
+static void
+ahd_stitch_tid_list(struct ahd_softc *ahd, u_int tid_prev,
+		    u_int tid_cur, u_int tid_next)
+{
+	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
+
+	if (SCBID_IS_NULL(tid_cur)) {
+
+		/* Bypass current TID list */
+		if (SCBID_IS_NULL(tid_prev)) {
+			ahd_outw(ahd, WAITING_TID_HEAD, tid_next);
+		} else {
+			ahd_set_scbptr(ahd, tid_prev);
+			ahd_outw(ahd, SCB_NEXT2, tid_next);
+		}
+		if (SCBID_IS_NULL(tid_next))
+			ahd_outw(ahd, WAITING_TID_TAIL, tid_prev);
+	} else {
+
+		/* Stitch through tid_cur */
+		if (SCBID_IS_NULL(tid_prev)) {
+			ahd_outw(ahd, WAITING_TID_HEAD, tid_cur);
+		} else {
+			ahd_set_scbptr(ahd, tid_prev);
+			ahd_outw(ahd, SCB_NEXT2, tid_cur);
+		}
+		ahd_set_scbptr(ahd, tid_cur);
+		ahd_outw(ahd, SCB_NEXT2, tid_next);
+
+		if (SCBID_IS_NULL(tid_next))
+			ahd_outw(ahd, WAITING_TID_TAIL, tid_cur);
+	}
+}
+
+/*
+ * Manipulate the waiting for selection list and return the
+ * scb that follows the one that we remove.
+ */
+static u_int
+ahd_rem_wscb(struct ahd_softc *ahd, u_int scbid,
+	     u_int prev, u_int next, u_int tid)
+{
+	u_int tail_offset;
+
+	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
+	if (!SCBID_IS_NULL(prev)) {
+		ahd_set_scbptr(ahd, prev);
+		ahd_outw(ahd, SCB_NEXT, next);
+	}
+
+	/*
+	 * SCBs that had MK_MESSAGE set in them will not
+	 * be queued to the per-target lists, so don't
+	 * blindly clear the tail pointer.
+	 */
+	tail_offset = WAITING_SCB_TAILS + (2 * tid);
+	if (SCBID_IS_NULL(next)
+	 && ahd_inw(ahd, tail_offset) == scbid)
+		ahd_outw(ahd, tail_offset, prev);
+	ahd_add_scb_to_free_list(ahd, scbid);
+	return (next);
+}
+
+/*
+ * Add the SCB as selected by SCBPTR onto the on chip list of
+ * free hardware SCBs.  This list is empty/unused if we are not
+ * performing SCB paging.
+ */
+static void
+ahd_add_scb_to_free_list(struct ahd_softc *ahd, u_int scbid)
+{
+/* XXX Need some other mechanism to designate "free". */
+	/*
+	 * Invalidate the tag so that our abort
+	 * routines don't think it's active.
+	ahd_outb(ahd, SCB_TAG, SCB_LIST_NULL);
+	 */
+}
+
+/******************************** Error Handling ******************************/
+/*
+ * Abort all SCBs that match the given description (target/channel/lun/tag),
+ * setting their status to the passed in status if the status has not already
+ * been modified from CAM_REQ_INPROG.  This routine assumes that the sequencer
+ * is paused before it is called.
+ */
+int
+ahd_abort_scbs(struct ahd_softc *ahd, int target, char channel,
+	       int lun, u_int tag, role_t role, uint32_t status)
+{
+	struct		scb *scbp;
+	struct		scb *scbp_next;
+	u_int		i, j;
+	u_int		maxtarget;
+	u_int		minlun;
+	u_int		maxlun;
+	int		found;
+	ahd_mode_state	saved_modes;
+
+	/* restore this when we're done */
+	saved_modes = ahd_save_modes(ahd);
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+
+	found = ahd_search_qinfifo(ahd, target, channel, lun, SCB_LIST_NULL,
+				   role, CAM_REQUEUE_REQ, SEARCH_COMPLETE);
+
+	/*
+	 * Clean out the busy target table for any untagged commands.
+	 */
+	i = 0;
+	maxtarget = 16;
+	if (target != CAM_TARGET_WILDCARD) {
+		i = target;
+		if (channel == 'B')
+			i += 8;
+		maxtarget = i + 1;
+	}
+
+	if (lun == CAM_LUN_WILDCARD) {
+		minlun = 0;
+		maxlun = AHD_NUM_LUNS_NONPKT;
+	} else if (lun >= AHD_NUM_LUNS_NONPKT) {
+		minlun = maxlun = 0;
+	} else {
+		minlun = lun;
+		maxlun = lun + 1;
+	}
+
+	if (role != ROLE_TARGET) {
+		for (;i < maxtarget; i++) {
+			for (j = minlun;j < maxlun; j++) {
+				u_int scbid;
+				u_int tcl;
+
+				tcl = BUILD_TCL_RAW(i, 'A', j);
+				scbid = ahd_find_busy_tcl(ahd, tcl);
+				scbp = ahd_lookup_scb(ahd, scbid);
+				if (scbp == NULL
+				 || ahd_match_scb(ahd, scbp, target, channel,
+						  lun, tag, role) == 0)
+					continue;
+				ahd_unbusy_tcl(ahd, BUILD_TCL_RAW(i, 'A', j));
+			}
+		}
+	}
+
+	/*
+	 * Don't abort commands that have already completed,
+	 * but haven't quite made it up to the host yet.
+	 */
+	ahd_flush_qoutfifo(ahd);
+
+	/*
+	 * Go through the pending CCB list and look for
+	 * commands for this target that are still active.
+	 * These are other tagged commands that were
+	 * disconnected when the reset occurred.
+	 */
+	scbp_next = LIST_FIRST(&ahd->pending_scbs);
+	while (scbp_next != NULL) {
+		scbp = scbp_next;
+		scbp_next = LIST_NEXT(scbp, pending_links);
+		if (ahd_match_scb(ahd, scbp, target, channel, lun, tag, role)) {
+			cam_status ostat;
+
+			ostat = ahd_get_transaction_status(scbp);
+			if (ostat == CAM_REQ_INPROG)
+				ahd_set_transaction_status(scbp, status);
+			if (ahd_get_transaction_status(scbp) != CAM_REQ_CMP)
+				ahd_freeze_scb(scbp);
+			if ((scbp->flags & SCB_ACTIVE) == 0)
+				printf("Inactive SCB on pending list\n");
+			ahd_done(ahd, scbp);
+			found++;
+		}
+	}
+	ahd_restore_modes(ahd, saved_modes);
+	ahd_platform_abort_scbs(ahd, target, channel, lun, tag, role, status);
+	ahd->flags |= AHD_UPDATE_PEND_CMDS;
+	return found;
+}
+
+static void
+ahd_reset_current_bus(struct ahd_softc *ahd)
+{
+	uint8_t scsiseq;
+
+	AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
+	ahd_outb(ahd, SIMODE1, ahd_inb(ahd, SIMODE1) & ~ENSCSIRST);
+	scsiseq = ahd_inb(ahd, SCSISEQ0) & ~(ENSELO|ENARBO|SCSIRSTO);
+	ahd_outb(ahd, SCSISEQ0, scsiseq | SCSIRSTO);
+	ahd_delay(AHD_BUSRESET_DELAY);
+	/* Turn off the bus reset */
+	ahd_outb(ahd, SCSISEQ0, scsiseq);
+	if ((ahd->bugs & AHD_SCSIRST_BUG) != 0) {
+		/*
+		 * 2A Razor #474
+		 * Certain chip state is not cleared for
+		 * SCSI bus resets that we initiate, so
+		 * we must reset the chip.
+		 */
+		ahd_delay(AHD_BUSRESET_DELAY);
+		ahd_reset(ahd, /*reinit*/TRUE);
+		ahd_intr_enable(ahd, /*enable*/TRUE);
+		AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
+	}
+
+	ahd_clear_intstat(ahd);
+}
+
+int
+ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset)
+{
+	struct	ahd_devinfo devinfo;
+	u_int	initiator;
+	u_int	target;
+	u_int	max_scsiid;
+	int	found;
+	u_int	fifo;
+	u_int	next_fifo;
+
+	ahd->pending_device = NULL;
+
+	ahd_compile_devinfo(&devinfo,
+			    CAM_TARGET_WILDCARD,
+			    CAM_TARGET_WILDCARD,
+			    CAM_LUN_WILDCARD,
+			    channel, ROLE_UNKNOWN);
+	ahd_pause(ahd);
+
+	/* Make sure the sequencer is in a safe location. */
+	ahd_clear_critical_section(ahd);
+
+#if AHD_TARGET_MODE
+	if ((ahd->flags & AHD_TARGETROLE) != 0) {
+		ahd_run_tqinfifo(ahd, /*paused*/TRUE);
+	}
+#endif
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+
+	/*
+	 * Disable selections so no automatic hardware
+	 * functions will modify chip state.
+	 */
+	ahd_outb(ahd, SCSISEQ0, 0);
+	ahd_outb(ahd, SCSISEQ1, 0);
+
+	/*
+	 * Safely shut down our DMA engines.  Always start with
+	 * the FIFO that is not currently active (if any are
+	 * actively connected).
+	 */
+	next_fifo = fifo = ahd_inb(ahd, DFFSTAT) & CURRFIFO;
+	if (next_fifo > CURRFIFO_1)
+		/* If disconneced, arbitrarily start with FIFO1. */
+		next_fifo = fifo = 0;
+	do {
+		next_fifo ^= CURRFIFO_1;
+		ahd_set_modes(ahd, next_fifo, next_fifo);
+		ahd_outb(ahd, DFCNTRL,
+			 ahd_inb(ahd, DFCNTRL) & ~(SCSIEN|HDMAEN));
+		while ((ahd_inb(ahd, DFCNTRL) & HDMAENACK) != 0)
+			ahd_delay(10);
+		/*
+		 * Set CURRFIFO to the now inactive channel.
+		 */
+		ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+		ahd_outb(ahd, DFFSTAT, next_fifo);
+	} while (next_fifo != fifo);
+
+	/*
+	 * Reset the bus if we are initiating this reset
+	 */
+	ahd_clear_msg_state(ahd);
+	ahd_outb(ahd, SIMODE1,
+		 ahd_inb(ahd, SIMODE1) & ~(ENBUSFREE|ENSCSIRST|ENBUSFREE));
+
+	if (initiate_reset)
+		ahd_reset_current_bus(ahd);
+
+	ahd_clear_intstat(ahd);
+
+	/*
+	 * Clean up all the state information for the
+	 * pending transactions on this bus.
+	 */
+	found = ahd_abort_scbs(ahd, CAM_TARGET_WILDCARD, channel,
+			       CAM_LUN_WILDCARD, SCB_LIST_NULL,
+			       ROLE_UNKNOWN, CAM_SCSI_BUS_RESET);
+
+	/*
+	 * Cleanup anything left in the FIFOs.
+	 */
+	ahd_clear_fifo(ahd, 0);
+	ahd_clear_fifo(ahd, 1);
+
+	/*
+	 * Revert to async/narrow transfers until we renegotiate.
+	 */
+	max_scsiid = (ahd->features & AHD_WIDE) ? 15 : 7;
+	for (target = 0; target <= max_scsiid; target++) {
+
+		if (ahd->enabled_targets[target] == NULL)
+			continue;
+		for (initiator = 0; initiator <= max_scsiid; initiator++) {
+			struct ahd_devinfo devinfo;
+
+			ahd_compile_devinfo(&devinfo, target, initiator,
+					    CAM_LUN_WILDCARD,
+					    'A', ROLE_UNKNOWN);
+			ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
+				      AHD_TRANS_CUR, /*paused*/TRUE);
+			ahd_set_syncrate(ahd, &devinfo, /*period*/0,
+					 /*offset*/0, /*ppr_options*/0,
+					 AHD_TRANS_CUR, /*paused*/TRUE);
+		}
+	}
+
+#ifdef AHD_TARGET_MODE
+	max_scsiid = (ahd->features & AHD_WIDE) ? 15 : 7;
+
+	/*
+	 * Send an immediate notify ccb to all target more peripheral
+	 * drivers affected by this action.
+	 */
+	for (target = 0; target <= max_scsiid; target++) {
+		struct ahd_tmode_tstate* tstate;
+		u_int lun;
+
+		tstate = ahd->enabled_targets[target];
+		if (tstate == NULL)
+			continue;
+		for (lun = 0; lun < AHD_NUM_LUNS; lun++) {
+			struct ahd_tmode_lstate* lstate;
+
+			lstate = tstate->enabled_luns[lun];
+			if (lstate == NULL)
+				continue;
+
+			ahd_queue_lstate_event(ahd, lstate, CAM_TARGET_WILDCARD,
+					       EVENT_TYPE_BUS_RESET, /*arg*/0);
+			ahd_send_lstate_events(ahd, lstate);
+		}
+	}
+#endif
+	/* Notify the XPT that a bus reset occurred */
+	ahd_send_async(ahd, devinfo.channel, CAM_TARGET_WILDCARD,
+		       CAM_LUN_WILDCARD, AC_BUS_RESET, NULL);
+	ahd_restart(ahd);
+	/*
+	 * Freeze the SIMQ until our poller can determine that
+	 * the bus reset has really gone away.  We set the initial
+	 * timer to 0 to have the check performed as soon as possible
+	 * from the timer context.
+	 */
+	if ((ahd->flags & AHD_RESET_POLL_ACTIVE) == 0) {
+		ahd->flags |= AHD_RESET_POLL_ACTIVE;
+		ahd_freeze_simq(ahd);
+		ahd_timer_reset(&ahd->reset_timer, 0, ahd_reset_poll, ahd);
+	}
+	return (found);
+}
+
+
+#define AHD_RESET_POLL_US 1000
+static void
+ahd_reset_poll(void *arg)
+{
+	struct	ahd_softc *ahd;
+	u_int	scsiseq1;
+	u_long	l;
+	u_long	s;
+	
+	ahd_list_lock(&l);
+	ahd = ahd_find_softc((struct ahd_softc *)arg);
+	if (ahd == NULL) {
+		printf("ahd_reset_poll: Instance %p no longer exists\n", arg);
+		ahd_list_unlock(&l);
+		return;
+	}
+	ahd_lock(ahd, &s);
+	ahd_pause(ahd);
+	ahd_update_modes(ahd);
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+	ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI);
+	if ((ahd_inb(ahd, SSTAT1) & SCSIRSTI) != 0) {
+		ahd_timer_reset(&ahd->reset_timer, AHD_RESET_POLL_US,
+				ahd_reset_poll, ahd);
+		ahd_unpause(ahd);
+		ahd_unlock(ahd, &s);
+		ahd_list_unlock(&l);
+		return;
+	}
+
+	/* Reset is now low.  Complete chip reinitialization. */
+	ahd_outb(ahd, SIMODE1, ahd_inb(ahd, SIMODE1) | ENSCSIRST);
+	scsiseq1 = ahd_inb(ahd, SCSISEQ_TEMPLATE);
+	ahd_outb(ahd, SCSISEQ1, scsiseq1 & (ENSELI|ENRSELI|ENAUTOATNP));
+	ahd_unpause(ahd);
+	ahd->flags &= ~AHD_RESET_POLL_ACTIVE;
+	ahd_unlock(ahd, &s);
+	ahd_release_simq(ahd);
+	ahd_list_unlock(&l);
+}
+
+/**************************** Statistics Processing ***************************/
+static void
+ahd_stat_timer(void *arg)
+{
+	struct	ahd_softc *ahd;
+	u_long	l;
+	u_long	s;
+	int	enint_coal;
+	
+	ahd_list_lock(&l);
+	ahd = ahd_find_softc((struct ahd_softc *)arg);
+	if (ahd == NULL) {
+		printf("ahd_stat_timer: Instance %p no longer exists\n", arg);
+		ahd_list_unlock(&l);
+		return;
+	}
+	ahd_lock(ahd, &s);
+
+	enint_coal = ahd->hs_mailbox & ENINT_COALESCE;
+	if (ahd->cmdcmplt_total > ahd->int_coalescing_threshold)
+		enint_coal |= ENINT_COALESCE;
+	else if (ahd->cmdcmplt_total < ahd->int_coalescing_stop_threshold)
+		enint_coal &= ~ENINT_COALESCE;
+
+	if (enint_coal != (ahd->hs_mailbox & ENINT_COALESCE)) {
+		ahd_enable_coalescing(ahd, enint_coal);
+#ifdef AHD_DEBUG
+		if ((ahd_debug & AHD_SHOW_INT_COALESCING) != 0)
+			printf("%s: Interrupt coalescing "
+			       "now %sabled. Cmds %d\n",
+			       ahd_name(ahd),
+			       (enint_coal & ENINT_COALESCE) ? "en" : "dis",
+			       ahd->cmdcmplt_total);
+#endif
+	}
+
+	ahd->cmdcmplt_bucket = (ahd->cmdcmplt_bucket+1) & (AHD_STAT_BUCKETS-1);
+	ahd->cmdcmplt_total -= ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket];
+	ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket] = 0;
+	ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US,
+			ahd_stat_timer, ahd);
+	ahd_unlock(ahd, &s);
+	ahd_list_unlock(&l);
+}
+
+/****************************** Status Processing *****************************/
+void
+ahd_handle_scb_status(struct ahd_softc *ahd, struct scb *scb)
+{
+	if (scb->hscb->shared_data.istatus.scsi_status != 0) {
+		ahd_handle_scsi_status(ahd, scb);
+	} else {
+		ahd_calc_residual(ahd, scb);
+		ahd_done(ahd, scb);
+	}
+}
+
+void
+ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)
+{
+	struct hardware_scb *hscb;
+	u_int  qfreeze_cnt;
+
+	/*
+	 * The sequencer freezes its select-out queue
+	 * anytime a SCSI status error occurs.  We must
+	 * handle the error and decrement the QFREEZE count
+	 * to allow the sequencer to continue.
+	 */
+	hscb = scb->hscb; 
+
+	/* Freeze the queue until the client sees the error. */
+	ahd_freeze_devq(ahd, scb);
+	ahd_freeze_scb(scb);
+	qfreeze_cnt = ahd_inw(ahd, QFREEZE_COUNT);
+	if (qfreeze_cnt == 0) {
+		printf("%s: Bad status with 0 qfreeze count!\n", ahd_name(ahd));
+	} else {
+		qfreeze_cnt--;
+		ahd_outw(ahd, QFREEZE_COUNT, qfreeze_cnt);
+	}
+	if (qfreeze_cnt == 0)
+		ahd_outb(ahd, SEQ_FLAGS2,
+			 ahd_inb(ahd, SEQ_FLAGS2) & ~SELECTOUT_QFROZEN);
+
+	/* Don't want to clobber the original sense code */
+	if ((scb->flags & SCB_SENSE) != 0) {
+		/*
+		 * Clear the SCB_SENSE Flag and perform
+		 * a normal command completion.
+		 */
+		scb->flags &= ~SCB_SENSE;
+		ahd_set_transaction_status(scb, CAM_AUTOSENSE_FAIL);
+		ahd_done(ahd, scb);
+		return;
+	}
+	ahd_set_transaction_status(scb, CAM_SCSI_STATUS_ERROR);
+	ahd_set_scsi_status(scb, hscb->shared_data.istatus.scsi_status);
+	switch (hscb->shared_data.istatus.scsi_status) {
+	case STATUS_PKT_SENSE:
+	{
+		struct scsi_status_iu_header *siu;
+
+		ahd_sync_sense(ahd, scb, BUS_DMASYNC_POSTREAD);
+		siu = (struct scsi_status_iu_header *)scb->sense_data;
+		ahd_set_scsi_status(scb, siu->status);
+#ifdef AHD_DEBUG
+		if ((ahd_debug & AHD_SHOW_SENSE) != 0) {
+			ahd_print_path(ahd, scb);
+			printf("SCB 0x%x Received PKT Status of 0x%x\n",
+			       SCB_GET_TAG(scb), siu->status);
+			printf("\tflags = 0x%x, sense len = 0x%x, "
+			       "pktfail = 0x%x\n",
+			       siu->flags, scsi_4btoul(siu->sense_length),
+			       scsi_4btoul(siu->pkt_failures_length));
+		}
+#endif
+		if ((siu->flags & SIU_RSPVALID) != 0) {
+			ahd_print_path(ahd, scb);
+			if (scsi_4btoul(siu->pkt_failures_length) < 4) {
+				printf("Unable to parse pkt_failures\n");
+			} else {
+
+				switch (SIU_PKTFAIL_CODE(siu)) {
+				case SIU_PFC_NONE:
+					printf("No packet failure found\n");
+					break;
+				case SIU_PFC_CIU_FIELDS_INVALID:
+					printf("Invalid Command IU Field\n");
+					break;
+				case SIU_PFC_TMF_NOT_SUPPORTED:
+					printf("TMF not supportd\n");
+					break;
+				case SIU_PFC_TMF_FAILED:
+					printf("TMF failed\n");
+					break;
+				case SIU_PFC_INVALID_TYPE_CODE:
+					printf("Invalid L_Q Type code\n");
+					break;
+				case SIU_PFC_ILLEGAL_REQUEST:
+					printf("Illegal request\n");
+				default:
+					break;
+				}
+			}
+			if (siu->status == SCSI_STATUS_OK)
+				ahd_set_transaction_status(scb,
+							   CAM_REQ_CMP_ERR);
+		}
+		if ((siu->flags & SIU_SNSVALID) != 0) {
+			scb->flags |= SCB_PKT_SENSE;
+#ifdef AHD_DEBUG
+			if ((ahd_debug & AHD_SHOW_SENSE) != 0)
+				printf("Sense data available\n");
+#endif
+		}
+		ahd_done(ahd, scb);
+		break;
+	}
+	case SCSI_STATUS_CMD_TERMINATED:
+	case SCSI_STATUS_CHECK_COND:
+	{
+		struct ahd_devinfo devinfo;
+		struct ahd_dma_seg *sg;
+		struct scsi_sense *sc;
+		struct ahd_initiator_tinfo *targ_info;
+		struct ahd_tmode_tstate *tstate;
+		struct ahd_transinfo *tinfo;
+#ifdef AHD_DEBUG
+		if (ahd_debug & AHD_SHOW_SENSE) {
+			ahd_print_path(ahd, scb);
+			printf("SCB %d: requests Check Status\n",
+			       SCB_GET_TAG(scb));
+		}
+#endif
+
+		if (ahd_perform_autosense(scb) == 0)
+			break;
+
+		ahd_compile_devinfo(&devinfo, SCB_GET_OUR_ID(scb),
+				    SCB_GET_TARGET(ahd, scb),
+				    SCB_GET_LUN(scb),
+				    SCB_GET_CHANNEL(ahd, scb),
+				    ROLE_INITIATOR);
+		targ_info = ahd_fetch_transinfo(ahd,
+						devinfo.channel,
+						devinfo.our_scsiid,
+						devinfo.target,
+						&tstate);
+		tinfo = &targ_info->curr;
+		sg = scb->sg_list;
+		sc = (struct scsi_sense *)hscb->shared_data.idata.cdb;
+		/*
+		 * Save off the residual if there is one.
+		 */
+		ahd_update_residual(ahd, scb);
+#ifdef AHD_DEBUG
+		if (ahd_debug & AHD_SHOW_SENSE) {
+			ahd_print_path(ahd, scb);
+			printf("Sending Sense\n");
+		}
+#endif
+		scb->sg_count = 0;
+		sg = ahd_sg_setup(ahd, scb, sg, ahd_get_sense_bufaddr(ahd, scb),
+				  ahd_get_sense_bufsize(ahd, scb),
+				  /*last*/TRUE);
+		sc->opcode = REQUEST_SENSE;
+		sc->byte2 = 0;
+		if (tinfo->protocol_version <= SCSI_REV_2
+		 && SCB_GET_LUN(scb) < 8)
+			sc->byte2 = SCB_GET_LUN(scb) << 5;
+		sc->unused[0] = 0;
+		sc->unused[1] = 0;
+		sc->length = ahd_get_sense_bufsize(ahd, scb);
+		sc->control = 0;
+
+		/*
+		 * We can't allow the target to disconnect.
+		 * This will be an untagged transaction and
+		 * having the target disconnect will make this
+		 * transaction indestinguishable from outstanding
+		 * tagged transactions.
+		 */
+		hscb->control = 0;
+
+		/*
+		 * This request sense could be because the
+		 * the device lost power or in some other
+		 * way has lost our transfer negotiations.
+		 * Renegotiate if appropriate.  Unit attention
+		 * errors will be reported before any data
+		 * phases occur.
+		 */
+		if (ahd_get_residual(scb) == ahd_get_transfer_length(scb)) {
+			ahd_update_neg_request(ahd, &devinfo,
+					       tstate, targ_info,
+					       AHD_NEG_IF_NON_ASYNC);
+		}
+		if (tstate->auto_negotiate & devinfo.target_mask) {
+			hscb->control |= MK_MESSAGE;
+			scb->flags &=
+			    ~(SCB_NEGOTIATE|SCB_ABORT|SCB_DEVICE_RESET);
+			scb->flags |= SCB_AUTO_NEGOTIATE;
+		}
+		hscb->cdb_len = sizeof(*sc);
+		ahd_setup_data_scb(ahd, scb);
+		scb->flags |= SCB_SENSE;
+		ahd_queue_scb(ahd, scb);
+		/*
+		 * Ensure we have enough time to actually
+		 * retrieve the sense.
+		 */
+		ahd_scb_timer_reset(scb, 5 * 1000000);
+		break;
+	}
+	case SCSI_STATUS_OK:
+		printf("%s: Interrupted for staus of 0???\n",
+		       ahd_name(ahd));
+		/* FALLTHROUGH */
+	default:
+		ahd_done(ahd, scb);
+		break;
+	}
+}
+
+/*
+ * Calculate the residual for a just completed SCB.
+ */
+void
+ahd_calc_residual(struct ahd_softc *ahd, struct scb *scb)
+{
+	struct hardware_scb *hscb;
+	struct initiator_status *spkt;
+	uint32_t sgptr;
+	uint32_t resid_sgptr;
+	uint32_t resid;
+
+	/*
+	 * 5 cases.
+	 * 1) No residual.
+	 *    SG_STATUS_VALID clear in sgptr.
+	 * 2) Transferless command
+	 * 3) Never performed any transfers.
+	 *    sgptr has SG_FULL_RESID set.
+	 * 4) No residual but target did not
+	 *    save data pointers after the
+	 *    last transfer, so sgptr was
+	 *    never updated.
+	 * 5) We have a partial residual.
+	 *    Use residual_sgptr to determine
+	 *    where we are.
+	 */
+
+	hscb = scb->hscb;
+	sgptr = ahd_le32toh(hscb->sgptr);
+	if ((sgptr & SG_STATUS_VALID) == 0)
+		/* Case 1 */
+		return;
+	sgptr &= ~SG_STATUS_VALID;
+
+	if ((sgptr & SG_LIST_NULL) != 0)
+		/* Case 2 */
+		return;
+
+	/*
+	 * Residual fields are the same in both
+	 * target and initiator status packets,
+	 * so we can always use the initiator fields
+	 * regardless of the role for this SCB.
+	 */
+	spkt = &hscb->shared_data.istatus;
+	resid_sgptr = ahd_le32toh(spkt->residual_sgptr);
+	if ((sgptr & SG_FULL_RESID) != 0) {
+		/* Case 3 */
+		resid = ahd_get_transfer_length(scb);
+	} else if ((resid_sgptr & SG_LIST_NULL) != 0) {
+		/* Case 4 */
+		return;
+	} else if ((resid_sgptr & SG_OVERRUN_RESID) != 0) {
+		ahd_print_path(ahd, scb);
+		printf("data overrun detected Tag == 0x%x.\n",
+		       SCB_GET_TAG(scb));
+		ahd_freeze_devq(ahd, scb);
+		ahd_set_transaction_status(scb, CAM_DATA_RUN_ERR);
+		ahd_freeze_scb(scb);
+		return;
+	} else if ((resid_sgptr & ~SG_PTR_MASK) != 0) {
+		panic("Bogus resid sgptr value 0x%x\n", resid_sgptr);
+		/* NOTREACHED */
+	} else {
+		struct ahd_dma_seg *sg;
+
+		/*
+		 * Remainder of the SG where the transfer
+		 * stopped.  
+		 */
+		resid = ahd_le32toh(spkt->residual_datacnt) & AHD_SG_LEN_MASK;
+		sg = ahd_sg_bus_to_virt(ahd, scb, resid_sgptr & SG_PTR_MASK);
+
+		/* The residual sg_ptr always points to the next sg */
+		sg--;
+
+		/*
+		 * Add up the contents of all residual
+		 * SG segments that are after the SG where
+		 * the transfer stopped.
+		 */
+		while ((ahd_le32toh(sg->len) & AHD_DMA_LAST_SEG) == 0) {
+			sg++;
+			resid += ahd_le32toh(sg->len) & AHD_SG_LEN_MASK;
+		}
+	}
+	if ((scb->flags & SCB_SENSE) == 0)
+		ahd_set_residual(scb, resid);
+	else
+		ahd_set_sense_residual(scb, resid);
+
+#ifdef AHD_DEBUG
+	if ((ahd_debug & AHD_SHOW_MISC) != 0) {
+		ahd_print_path(ahd, scb);
+		printf("Handled %sResidual of %d bytes\n",
+		       (scb->flags & SCB_SENSE) ? "Sense " : "", resid);
+	}
+#endif
+}
+
+/******************************* Target Mode **********************************/
+#ifdef AHD_TARGET_MODE
+/*
+ * Add a target mode event to this lun's queue
+ */
+static void
+ahd_queue_lstate_event(struct ahd_softc *ahd, struct ahd_tmode_lstate *lstate,
+		       u_int initiator_id, u_int event_type, u_int event_arg)
+{
+	struct ahd_tmode_event *event;
+	int pending;
+
+	xpt_freeze_devq(lstate->path, /*count*/1);
+	if (lstate->event_w_idx >= lstate->event_r_idx)
+		pending = lstate->event_w_idx - lstate->event_r_idx;
+	else
+		pending = AHD_TMODE_EVENT_BUFFER_SIZE + 1
+			- (lstate->event_r_idx - lstate->event_w_idx);
+
+	if (event_type == EVENT_TYPE_BUS_RESET
+	 || event_type == MSG_BUS_DEV_RESET) {
+		/*
+		 * Any earlier events are irrelevant, so reset our buffer.
+		 * This has the effect of allowing us to deal with reset
+		 * floods (an external device holding down the reset line)
+		 * without losing the event that is really interesting.
+		 */
+		lstate->event_r_idx = 0;
+		lstate->event_w_idx = 0;
+		xpt_release_devq(lstate->path, pending, /*runqueue*/FALSE);
+	}
+
+	if (pending == AHD_TMODE_EVENT_BUFFER_SIZE) {
+		xpt_print_path(lstate->path);
+		printf("immediate event %x:%x lost\n",
+		       lstate->event_buffer[lstate->event_r_idx].event_type,
+		       lstate->event_buffer[lstate->event_r_idx].event_arg);
+		lstate->event_r_idx++;
+		if (lstate->event_r_idx == AHD_TMODE_EVENT_BUFFER_SIZE)
+			lstate->event_r_idx = 0;
+		xpt_release_devq(lstate->path, /*count*/1, /*runqueue*/FALSE);
+	}
+
+	event = &lstate->event_buffer[lstate->event_w_idx];
+	event->initiator_id = initiator_id;
+	event->event_type = event_type;
+	event->event_arg = event_arg;
+	lstate->event_w_idx++;
+	if (lstate->event_w_idx == AHD_TMODE_EVENT_BUFFER_SIZE)
+		lstate->event_w_idx = 0;
+}
+
+/*
+ * Send any target mode events queued up waiting
+ * for immediate notify resources.
+ */
+void
+ahd_send_lstate_events(struct ahd_softc *ahd, struct ahd_tmode_lstate *lstate)
+{
+	struct ccb_hdr *ccbh;
+	struct ccb_immed_notify *inot;
+
+	while (lstate->event_r_idx != lstate->event_w_idx
+	    && (ccbh = SLIST_FIRST(&lstate->immed_notifies)) != NULL) {
+		struct ahd_tmode_event *event;
+
+		event = &lstate->event_buffer[lstate->event_r_idx];
+		SLIST_REMOVE_HEAD(&lstate->immed_notifies, sim_links.sle);
+		inot = (struct ccb_immed_notify *)ccbh;
+		switch (event->event_type) {
+		case EVENT_TYPE_BUS_RESET:
+			ccbh->status = CAM_SCSI_BUS_RESET|CAM_DEV_QFRZN;
+			break;
+		default:
+			ccbh->status = CAM_MESSAGE_RECV|CAM_DEV_QFRZN;
+			inot->message_args[0] = event->event_type;
+			inot->message_args[1] = event->event_arg;
+			break;
+		}
+		inot->initiator_id = event->initiator_id;
+		inot->sense_len = 0;
+		xpt_done((union ccb *)inot);
+		lstate->event_r_idx++;
+		if (lstate->event_r_idx == AHD_TMODE_EVENT_BUFFER_SIZE)
+			lstate->event_r_idx = 0;
+	}
+}
+#endif
+
+/******************** Sequencer Program Patching/Download *********************/
+
+#ifdef AHD_DUMP_SEQ
+void
+ahd_dumpseq(struct ahd_softc* ahd)
+{
+	int i;
+	int max_prog;
+
+	max_prog = 2048;
+
+	ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE|LOADRAM);
+	ahd_outb(ahd, PRGMCNT, 0);
+	ahd_outb(ahd, PRGMCNT+1, 0);
+	for (i = 0; i < max_prog; i++) {
+		uint8_t ins_bytes[4];
+
+		ahd_insb(ahd, SEQRAM, ins_bytes, 4);
+		printf("0x%08x\n", ins_bytes[0] << 24
+				 | ins_bytes[1] << 16
+				 | ins_bytes[2] << 8
+				 | ins_bytes[3]);
+	}
+}
+#endif
+
+static void
+ahd_loadseq(struct ahd_softc *ahd)
+{
+	struct	cs cs_table[num_critical_sections];
+	u_int	begin_set[num_critical_sections];
+	u_int	end_set[num_critical_sections];
+	struct	patch *cur_patch;
+	u_int	cs_count;
+	u_int	cur_cs;
+	u_int	i;
+	int	downloaded;
+	u_int	skip_addr;
+	u_int	sg_prefetch_cnt;
+	u_int	sg_prefetch_cnt_limit;
+	u_int	sg_prefetch_align;
+	u_int	sg_size;
+	uint8_t	download_consts[DOWNLOAD_CONST_COUNT];
+
+	if (bootverbose)
+		printf("%s: Downloading Sequencer Program...",
+		       ahd_name(ahd));
+
+#if DOWNLOAD_CONST_COUNT != 7
+#error "Download Const Mismatch"
+#endif
+	/*
+	 * Start out with 0 critical sections
+	 * that apply to this firmware load.
+	 */
+	cs_count = 0;
+	cur_cs = 0;
+	memset(begin_set, 0, sizeof(begin_set));
+	memset(end_set, 0, sizeof(end_set));
+
+	/*
+	 * Setup downloadable constant table.
+	 * 
+	 * The computation for the S/G prefetch variables is
+	 * a bit complicated.  We would like to always fetch
+	 * in terms of cachelined sized increments.  However,
+	 * if the cacheline is not an even multiple of the
+	 * SG element size or is larger than our SG RAM, using
+	 * just the cache size might leave us with only a portion
+	 * of an SG element at the tail of a prefetch.  If the
+	 * cacheline is larger than our S/G prefetch buffer less
+	 * the size of an SG element, we may round down to a cacheline
+	 * that doesn't contain any or all of the S/G of interest
+	 * within the bounds of our S/G ram.  Provide variables to
+	 * the sequencer that will allow it to handle these edge
+	 * cases.
+	 */
+	/* Start by aligning to the nearest cacheline. */
+	sg_prefetch_align = ahd->pci_cachesize;
+	if (sg_prefetch_align == 0)
+		sg_prefetch_align = 8;
+	/* Round down to the nearest power of 2. */
+	while (powerof2(sg_prefetch_align) == 0)
+		sg_prefetch_align--;
+	/*
+	 * If the cacheline boundary is greater than half our prefetch RAM
+	 * we risk not being able to fetch even a single complete S/G
+	 * segment if we align to that boundary.
+	 */
+	if (sg_prefetch_align > CCSGADDR_MAX/2)
+		sg_prefetch_align = CCSGADDR_MAX/2;
+	/* Start by fetching a single cacheline. */
+	sg_prefetch_cnt = sg_prefetch_align;
+	/*
+	 * Increment the prefetch count by cachelines until
+	 * at least one S/G element will fit.
+	 */
+	sg_size = sizeof(struct ahd_dma_seg);
+	if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0)
+		sg_size = sizeof(struct ahd_dma64_seg);
+	while (sg_prefetch_cnt < sg_size)
+		sg_prefetch_cnt += sg_prefetch_align;
+	/*
+	 * If the cacheline is not an even multiple of
+	 * the S/G size, we may only get a partial S/G when
+	 * we align. Add a cacheline if this is the case.
+	 */
+	if ((sg_prefetch_align % sg_size) != 0
+	 && (sg_prefetch_cnt < CCSGADDR_MAX))
+		sg_prefetch_cnt += sg_prefetch_align;
+	/*
+	 * Lastly, compute a value that the sequencer can use
+	 * to determine if the remainder of the CCSGRAM buffer
+	 * has a full S/G element in it.
+	 */
+	sg_prefetch_cnt_limit = -(sg_prefetch_cnt - sg_size + 1);
+	download_consts[SG_PREFETCH_CNT] = sg_prefetch_cnt;
+	download_consts[SG_PREFETCH_CNT_LIMIT] = sg_prefetch_cnt_limit;
+	download_consts[SG_PREFETCH_ALIGN_MASK] = ~(sg_prefetch_align - 1);
+	download_consts[SG_PREFETCH_ADDR_MASK] = (sg_prefetch_align - 1);
+	download_consts[SG_SIZEOF] = sg_size;
+	download_consts[PKT_OVERRUN_BUFOFFSET] =
+		(ahd->overrun_buf - (uint8_t *)ahd->qoutfifo) / 256;
+	download_consts[SCB_TRANSFER_SIZE] = SCB_TRANSFER_SIZE_1BYTE_LUN;
+	cur_patch = patches;
+	downloaded = 0;
+	skip_addr = 0;
+	ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE|LOADRAM);
+	ahd_outb(ahd, PRGMCNT, 0);
+	ahd_outb(ahd, PRGMCNT+1, 0);
+
+	for (i = 0; i < sizeof(seqprog)/4; i++) {
+		if (ahd_check_patch(ahd, &cur_patch, i, &skip_addr) == 0) {
+			/*
+			 * Don't download this instruction as it
+			 * is in a patch that was removed.
+			 */
+			continue;
+		}
+		/*
+		 * Move through the CS table until we find a CS
+		 * that might apply to this instruction.
+		 */
+		for (; cur_cs < num_critical_sections; cur_cs++) {
+			if (critical_sections[cur_cs].end <= i) {
+				if (begin_set[cs_count] == TRUE
+				 && end_set[cs_count] == FALSE) {
+					cs_table[cs_count].end = downloaded;
+				 	end_set[cs_count] = TRUE;
+					cs_count++;
+				}
+				continue;
+			}
+			if (critical_sections[cur_cs].begin <= i
+			 && begin_set[cs_count] == FALSE) {
+				cs_table[cs_count].begin = downloaded;
+				begin_set[cs_count] = TRUE;
+			}
+			break;
+		}
+		ahd_download_instr(ahd, i, download_consts);
+		downloaded++;
+	}
+
+	ahd->num_critical_sections = cs_count;
+	if (cs_count != 0) {
+
+		cs_count *= sizeof(struct cs);
+		ahd->critical_sections = malloc(cs_count, M_DEVBUF, M_NOWAIT);
+		if (ahd->critical_sections == NULL)
+			panic("ahd_loadseq: Could not malloc");
+		memcpy(ahd->critical_sections, cs_table, cs_count);
+	}
+	ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE);
+
+	if (bootverbose) {
+		printf(" %d instructions downloaded\n", downloaded);
+		printf("%s: Features 0x%x, Bugs 0x%x, Flags 0x%x\n",
+		       ahd_name(ahd), ahd->features, ahd->bugs, ahd->flags);
+	}
+}
+
+static int
+ahd_check_patch(struct ahd_softc *ahd, struct patch **start_patch,
+		u_int start_instr, u_int *skip_addr)
+{
+	struct	patch *cur_patch;
+	struct	patch *last_patch;
+	u_int	num_patches;
+
+	num_patches = sizeof(patches)/sizeof(struct patch);
+	last_patch = &patches[num_patches];
+	cur_patch = *start_patch;
+
+	while (cur_patch < last_patch && start_instr == cur_patch->begin) {
+
+		if (cur_patch->patch_func(ahd) == 0) {
+
+			/* Start rejecting code */
+			*skip_addr = start_instr + cur_patch->skip_instr;
+			cur_patch += cur_patch->skip_patch;
+		} else {
+			/* Accepted this patch.  Advance to the next
+			 * one and wait for our intruction pointer to
+			 * hit this point.
+			 */
+			cur_patch++;
+		}
+	}
+
+	*start_patch = cur_patch;
+	if (start_instr < *skip_addr)
+		/* Still skipping */
+		return (0);
+
+	return (1);
+}
+
+static u_int
+ahd_resolve_seqaddr(struct ahd_softc *ahd, u_int address)
+{
+	struct patch *cur_patch;
+	int address_offset;
+	u_int skip_addr;
+	u_int i;
+
+	address_offset = 0;
+	cur_patch = patches;
+	skip_addr = 0;
+
+	for (i = 0; i < address;) {
+
+		ahd_check_patch(ahd, &cur_patch, i, &skip_addr);
+
+		if (skip_addr > i) {
+			int end_addr;
+
+			end_addr = MIN(address, skip_addr);
+			address_offset += end_addr - i;
+			i = skip_addr;
+		} else {
+			i++;
+		}
+	}
+	return (address - address_offset);
+}
+
+static void
+ahd_download_instr(struct ahd_softc *ahd, u_int instrptr, uint8_t *dconsts)
+{
+	union	ins_formats instr;
+	struct	ins_format1 *fmt1_ins;
+	struct	ins_format3 *fmt3_ins;
+	u_int	opcode;
+
+	/*
+	 * The firmware is always compiled into a little endian format.
+	 */
+	instr.integer = ahd_le32toh(*(uint32_t*)&seqprog[instrptr * 4]);
+
+	fmt1_ins = &instr.format1;
+	fmt3_ins = NULL;
+
+	/* Pull the opcode */
+	opcode = instr.format1.opcode;
+	switch (opcode) {
+	case AIC_OP_JMP:
+	case AIC_OP_JC:
+	case AIC_OP_JNC:
+	case AIC_OP_CALL:
+	case AIC_OP_JNE:
+	case AIC_OP_JNZ:
+	case AIC_OP_JE:
+	case AIC_OP_JZ:
+	{
+		fmt3_ins = &instr.format3;
+		fmt3_ins->address = ahd_resolve_seqaddr(ahd, fmt3_ins->address);
+		/* FALLTHROUGH */
+	}
+	case AIC_OP_OR:
+	case AIC_OP_AND:
+	case AIC_OP_XOR:
+	case AIC_OP_ADD:
+	case AIC_OP_ADC:
+	case AIC_OP_BMOV:
+		if (fmt1_ins->parity != 0) {
+			fmt1_ins->immediate = dconsts[fmt1_ins->immediate];
+		}
+		fmt1_ins->parity = 0;
+		/* FALLTHROUGH */
+	case AIC_OP_ROL:
+	{
+		int i, count;
+
+		/* Calculate odd parity for the instruction */
+		for (i = 0, count = 0; i < 31; i++) {
+			uint32_t mask;
+
+			mask = 0x01 << i;
+			if ((instr.integer & mask) != 0)
+				count++;
+		}
+		if ((count & 0x01) == 0)
+			instr.format1.parity = 1;
+
+		/* The sequencer is a little endian cpu */
+		instr.integer = ahd_htole32(instr.integer);
+		ahd_outsb(ahd, SEQRAM, instr.bytes, 4);
+		break;
+	}
+	default:
+		panic("Unknown opcode encountered in seq program");
+		break;
+	}
+}
+
+static int
+ahd_probe_stack_size(struct ahd_softc *ahd)
+{
+	int last_probe;
+
+	last_probe = 0;
+	while (1) {
+		int i;
+
+		/*
+		 * We avoid using 0 as a pattern to avoid
+		 * confusion if the stack implementation
+		 * "back-fills" with zeros when "poping'
+		 * entries.
+		 */
+		for (i = 1; i <= last_probe+1; i++) {
+		       ahd_outb(ahd, STACK, i & 0xFF);
+		       ahd_outb(ahd, STACK, (i >> 8) & 0xFF);
+		}
+
+		/* Verify */
+		for (i = last_probe+1; i > 0; i--) {
+			u_int stack_entry;
+
+			stack_entry = ahd_inb(ahd, STACK)
+				    |(ahd_inb(ahd, STACK) << 8);
+			if (stack_entry != i)
+				goto sized;
+		}
+		last_probe++;
+	}
+sized:
+	return (last_probe);
+}
+
+void
+ahd_dump_all_cards_state(void)
+{
+	struct ahd_softc *list_ahd;
+
+	TAILQ_FOREACH(list_ahd, &ahd_tailq, links) {
+		ahd_dump_card_state(list_ahd);
+	}
+}
+
+int
+ahd_print_register(ahd_reg_parse_entry_t *table, u_int num_entries,
+		   const char *name, u_int address, u_int value,
+		   u_int *cur_column, u_int wrap_point)
+{
+	int	printed;
+	u_int	printed_mask;
+
+	if (cur_column != NULL && *cur_column >= wrap_point) {
+		printf("\n");
+		*cur_column = 0;
+	}
+	printed = printf("%s[0x%x]", name, value);
+	if (table == NULL) {
+		printed += printf(" ");
+		*cur_column += printed;
+		return (printed);
+	}
+	printed_mask = 0;
+	while (printed_mask != 0xFF) {
+		int entry;
+
+		for (entry = 0; entry < num_entries; entry++) {
+			if (((value & table[entry].mask)
+			  != table[entry].value)
+			 || ((printed_mask & table[entry].mask)
+			  == table[entry].mask))
+				continue;
+
+			printed += printf("%s%s",
+					  printed_mask == 0 ? ":(" : "|",
+					  table[entry].name);
+			printed_mask |= table[entry].mask;
+			
+			break;
+		}
+		if (entry >= num_entries)
+			break;
+	}
+	if (printed_mask != 0)
+		printed += printf(") ");
+	else
+		printed += printf(" ");
+	if (cur_column != NULL)
+		*cur_column += printed;
+	return (printed);
+}
+
+void
+ahd_dump_card_state(struct ahd_softc *ahd)
+{
+	struct scb	*scb;
+	ahd_mode_state	 saved_modes;
+	u_int		 dffstat;
+	int		 paused;
+	u_int		 scb_index;
+	u_int		 saved_scb_index;
+	u_int		 cur_col;
+	int		 i;
+
+	if (ahd_is_paused(ahd)) {
+		paused = 1;
+	} else {
+		paused = 0;
+		ahd_pause(ahd);
+	}
+	saved_modes = ahd_save_modes(ahd);
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+	printf(">>>>>>>>>>>>>>>>>> Dump Card State Begins <<<<<<<<<<<<<<<<<\n"
+	       "%s: Dumping Card State at program address 0x%x Mode 0x%x\n",
+	       ahd_name(ahd), 
+	       ahd_inb(ahd, CURADDR) | (ahd_inb(ahd, CURADDR+1) << 8),
+	       ahd_build_mode_state(ahd, ahd->saved_src_mode,
+				    ahd->saved_dst_mode));
+	if (paused)
+		printf("Card was paused\n");
+	/*
+	 * Mode independent registers.
+	 */
+	cur_col = 0;
+	ahd_hs_mailbox_print(ahd_inb(ahd, LOCAL_HS_MAILBOX), &cur_col, 50);
+	ahd_intctl_print(ahd_inb(ahd, INTCTL), &cur_col, 50);
+	ahd_seqintstat_print(ahd_inb(ahd, SEQINTSTAT), &cur_col, 50);
+	ahd_saved_mode_print(ahd_inb(ahd, SAVED_MODE), &cur_col, 50);
+	ahd_dffstat_print(ahd_inb(ahd, DFFSTAT), &cur_col, 50);
+	ahd_scsisigi_print(ahd_inb(ahd, SCSISIGI), &cur_col, 50);
+	ahd_scsiphase_print(ahd_inb(ahd, SCSIPHASE), &cur_col, 50);
+	ahd_scsibus_print(ahd_inb(ahd, SCSIBUS), &cur_col, 50);
+	ahd_lastphase_print(ahd_inb(ahd, LASTPHASE), &cur_col, 50);
+	ahd_scsiseq0_print(ahd_inb(ahd, SCSISEQ0), &cur_col, 50);
+	ahd_scsiseq1_print(ahd_inb(ahd, SCSISEQ1), &cur_col, 50);
+	ahd_seqctl0_print(ahd_inb(ahd, SEQCTL0), &cur_col, 50);
+	ahd_seqintctl_print(ahd_inb(ahd, SEQINTCTL), &cur_col, 50);
+	ahd_seq_flags_print(ahd_inb(ahd, SEQ_FLAGS), &cur_col, 50);
+	ahd_seq_flags2_print(ahd_inb(ahd, SEQ_FLAGS2), &cur_col, 50);
+	ahd_sstat0_print(ahd_inb(ahd, SSTAT0), &cur_col, 50);
+	ahd_sstat1_print(ahd_inb(ahd, SSTAT1), &cur_col, 50);
+	ahd_sstat2_print(ahd_inb(ahd, SSTAT2), &cur_col, 50);
+	ahd_sstat3_print(ahd_inb(ahd, SSTAT3), &cur_col, 50);
+	ahd_perrdiag_print(ahd_inb(ahd, PERRDIAG), &cur_col, 50);
+	ahd_simode1_print(ahd_inb(ahd, SIMODE1), &cur_col, 50);
+	ahd_lqistat0_print(ahd_inb(ahd, LQISTAT0), &cur_col, 50);
+	ahd_lqistat1_print(ahd_inb(ahd, LQISTAT1), &cur_col, 50);
+	ahd_lqistat2_print(ahd_inb(ahd, LQISTAT2), &cur_col, 50);
+	ahd_lqostat0_print(ahd_inb(ahd, LQOSTAT0), &cur_col, 50);
+	ahd_lqostat1_print(ahd_inb(ahd, LQOSTAT1), &cur_col, 50);
+	ahd_lqostat2_print(ahd_inb(ahd, LQOSTAT2), &cur_col, 50);
+	printf("\n");
+	printf("\nSCB Count = %d CMDS_PENDING = %d LASTSCB 0x%x "
+	       "CURRSCB 0x%x NEXTSCB 0x%x\n",
+	       ahd->scb_data.numscbs, ahd_inw(ahd, CMDS_PENDING),
+	       ahd_inw(ahd, LASTSCB), ahd_inw(ahd, CURRSCB),
+	       ahd_inw(ahd, NEXTSCB));
+	cur_col = 0;
+	/* QINFIFO */
+	ahd_search_qinfifo(ahd, CAM_TARGET_WILDCARD, ALL_CHANNELS,
+			   CAM_LUN_WILDCARD, SCB_LIST_NULL,
+			   ROLE_UNKNOWN, /*status*/0, SEARCH_PRINT);
+	saved_scb_index = ahd_get_scbptr(ahd);
+	printf("Pending list:");
+	i = 0;
+	LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) {
+		if (i++ > AHD_SCB_MAX)
+			break;
+		cur_col = printf("\n%3d FIFO_USE[0x%x] ", SCB_GET_TAG(scb),
+				 ahd_inb(ahd, SCB_FIFO_USE_COUNT));
+		ahd_set_scbptr(ahd, SCB_GET_TAG(scb));
+		ahd_scb_control_print(ahd_inb(ahd, SCB_CONTROL), &cur_col, 60);
+		ahd_scb_scsiid_print(ahd_inb(ahd, SCB_SCSIID), &cur_col, 60);
+	}
+	printf("\nTotal %d\n", i);
+
+	printf("Kernel Free SCB list: ");
+	i = 0;
+	TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) {
+		struct scb *list_scb;
+
+		list_scb = scb;
+		do {
+			printf("%d ", SCB_GET_TAG(list_scb));
+			list_scb = LIST_NEXT(list_scb, collision_links);
+		} while (list_scb && i++ < AHD_SCB_MAX);
+	}
+
+	LIST_FOREACH(scb, &ahd->scb_data.any_dev_free_scb_list, links.le) {
+		if (i++ > AHD_SCB_MAX)
+			break;
+		printf("%d ", SCB_GET_TAG(scb));
+	}
+	printf("\n");
+
+	printf("Sequencer Complete DMA-inprog list: ");
+	scb_index = ahd_inw(ahd, COMPLETE_SCB_DMAINPROG_HEAD);
+	i = 0;
+	while (!SCBID_IS_NULL(scb_index) && i++ < AHD_SCB_MAX) {
+		ahd_set_scbptr(ahd, scb_index);
+		printf("%d ", scb_index);
+		scb_index = ahd_inw(ahd, SCB_NEXT_COMPLETE);
+	}
+	printf("\n");
+
+	printf("Sequencer Complete list: ");
+	scb_index = ahd_inw(ahd, COMPLETE_SCB_HEAD);
+	i = 0;
+	while (!SCBID_IS_NULL(scb_index) && i++ < AHD_SCB_MAX) {
+		ahd_set_scbptr(ahd, scb_index);
+		printf("%d ", scb_index);
+		scb_index = ahd_inw(ahd, SCB_NEXT_COMPLETE);
+	}
+	printf("\n");
+
+	
+	printf("Sequencer DMA-Up and Complete list: ");
+	scb_index = ahd_inw(ahd, COMPLETE_DMA_SCB_HEAD);
+	i = 0;
+	while (!SCBID_IS_NULL(scb_index) && i++ < AHD_SCB_MAX) {
+		ahd_set_scbptr(ahd, scb_index);
+		printf("%d ", scb_index);
+		scb_index = ahd_inw(ahd, SCB_NEXT_COMPLETE);
+	}
+	printf("\n");
+	ahd_set_scbptr(ahd, saved_scb_index);
+	dffstat = ahd_inb(ahd, DFFSTAT);
+	for (i = 0; i < 2; i++) {
+#ifdef AHD_DEBUG
+		struct scb *fifo_scb;
+#endif
+		u_int	    fifo_scbptr;
+
+		ahd_set_modes(ahd, AHD_MODE_DFF0 + i, AHD_MODE_DFF0 + i);
+		fifo_scbptr = ahd_get_scbptr(ahd);
+		printf("\n%s: FIFO%d %s, LONGJMP == 0x%x, SCB 0x%x\n",
+		       ahd_name(ahd), i,
+		       (dffstat & (FIFO0FREE << i)) ? "Free" : "Active",
+		       ahd_inw(ahd, LONGJMP_ADDR), fifo_scbptr);
+		cur_col = 0;
+		ahd_seqimode_print(ahd_inb(ahd, SEQIMODE), &cur_col, 50);
+		ahd_seqintsrc_print(ahd_inb(ahd, SEQINTSRC), &cur_col, 50);
+		ahd_dfcntrl_print(ahd_inb(ahd, DFCNTRL), &cur_col, 50);
+		ahd_dfstatus_print(ahd_inb(ahd, DFSTATUS), &cur_col, 50);
+		ahd_sg_cache_shadow_print(ahd_inb(ahd, SG_CACHE_SHADOW),
+					  &cur_col, 50);
+		ahd_sg_state_print(ahd_inb(ahd, SG_STATE), &cur_col, 50);
+		ahd_dffsxfrctl_print(ahd_inb(ahd, DFFSXFRCTL), &cur_col, 50);
+		ahd_soffcnt_print(ahd_inb(ahd, SOFFCNT), &cur_col, 50);
+		ahd_mdffstat_print(ahd_inb(ahd, MDFFSTAT), &cur_col, 50);
+		if (cur_col > 50) {
+			printf("\n");
+			cur_col = 0;
+		}
+		cur_col += printf("SHADDR = 0x%x%x, SHCNT = 0x%x ",
+				  ahd_inl(ahd, SHADDR+4),
+				  ahd_inl(ahd, SHADDR),
+				  (ahd_inb(ahd, SHCNT)
+				| (ahd_inb(ahd, SHCNT + 1) << 8)
+				| (ahd_inb(ahd, SHCNT + 2) << 16)));
+		if (cur_col > 50) {
+			printf("\n");
+			cur_col = 0;
+		}
+		cur_col += printf("HADDR = 0x%x%x, HCNT = 0x%x ",
+				  ahd_inl(ahd, HADDR+4),
+				  ahd_inl(ahd, HADDR),
+				  (ahd_inb(ahd, HCNT)
+				| (ahd_inb(ahd, HCNT + 1) << 8)
+				| (ahd_inb(ahd, HCNT + 2) << 16)));
+		ahd_ccsgctl_print(ahd_inb(ahd, CCSGCTL), &cur_col, 50);
+#ifdef AHD_DEBUG
+		if ((ahd_debug & AHD_SHOW_SG) != 0) {
+			fifo_scb = ahd_lookup_scb(ahd, fifo_scbptr);
+			if (fifo_scb != NULL)
+				ahd_dump_sglist(fifo_scb);
+		}
+#endif
+	}
+	printf("\nLQIN: ");
+	for (i = 0; i < 20; i++)
+		printf("0x%x ", ahd_inb(ahd, LQIN + i));
+	printf("\n");
+	ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
+	printf("%s: LQISTATE = 0x%x, LQOSTATE = 0x%x, OPTIONMODE = 0x%x\n",
+	       ahd_name(ahd), ahd_inb(ahd, LQISTATE), ahd_inb(ahd, LQOSTATE),
+	       ahd_inb(ahd, OPTIONMODE));
+	printf("%s: OS_SPACE_CNT = 0x%x MAXCMDCNT = 0x%x\n",
+	       ahd_name(ahd), ahd_inb(ahd, OS_SPACE_CNT),
+	       ahd_inb(ahd, MAXCMDCNT));
+	ahd_simode0_print(ahd_inb(ahd, SIMODE0), &cur_col, 50);
+	printf("\n");
+	ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
+	cur_col = 0;
+	ahd_ccscbctl_print(ahd_inb(ahd, CCSCBCTL), &cur_col, 50);
+	printf("\n");
+	ahd_set_modes(ahd, ahd->saved_src_mode, ahd->saved_dst_mode);
+	printf("%s: REG0 == 0x%x, SINDEX = 0x%x, DINDEX = 0x%x\n",
+	       ahd_name(ahd), ahd_inw(ahd, REG0), ahd_inw(ahd, SINDEX),
+	       ahd_inw(ahd, DINDEX));
+	printf("%s: SCBPTR == 0x%x, SCB_NEXT == 0x%x, SCB_NEXT2 == 0x%x\n",
+	       ahd_name(ahd), ahd_get_scbptr(ahd), ahd_inw(ahd, SCB_NEXT),
+	       ahd_inw(ahd, SCB_NEXT2));
+	printf("CDB %x %x %x %x %x %x\n",
+	       ahd_inb(ahd, SCB_CDB_STORE),
+	       ahd_inb(ahd, SCB_CDB_STORE+1),
+	       ahd_inb(ahd, SCB_CDB_STORE+2),
+	       ahd_inb(ahd, SCB_CDB_STORE+3),
+	       ahd_inb(ahd, SCB_CDB_STORE+4),
+	       ahd_inb(ahd, SCB_CDB_STORE+5));
+	printf("STACK:");
+	for (i = 0; i < ahd->stack_size; i++) {
+		ahd->saved_stack[i] =
+		    ahd_inb(ahd, STACK)|(ahd_inb(ahd, STACK) << 8);
+		printf(" 0x%x", ahd->saved_stack[i]);
+	}
+	for (i = ahd->stack_size-1; i >= 0; i--) {
+		ahd_outb(ahd, STACK, ahd->saved_stack[i] & 0xFF);
+		ahd_outb(ahd, STACK, (ahd->saved_stack[i] >> 8) & 0xFF);
+	}
+	printf("\n<<<<<<<<<<<<<<<<< Dump Card State Ends >>>>>>>>>>>>>>>>>>\n");
+	ahd_platform_dump_card_state(ahd);
+	ahd_restore_modes(ahd, saved_modes);
+	if (paused == 0)
+		ahd_unpause(ahd);
+}
+
+void
+ahd_dump_scbs(struct ahd_softc *ahd)
+{
+	ahd_mode_state saved_modes;
+	u_int	       saved_scb_index;
+	int	       i;
+
+	saved_modes = ahd_save_modes(ahd);
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+	saved_scb_index = ahd_get_scbptr(ahd);
+	for (i = 0; i < AHD_SCB_MAX; i++) {
+		ahd_set_scbptr(ahd, i);
+		printf("%3d", i);
+		printf("(CTRL 0x%x ID 0x%x N 0x%x N2 0x%x SG 0x%x, RSG 0x%x)\n",
+		       ahd_inb(ahd, SCB_CONTROL),
+		       ahd_inb(ahd, SCB_SCSIID), ahd_inw(ahd, SCB_NEXT),
+		       ahd_inw(ahd, SCB_NEXT2), ahd_inl(ahd, SCB_SGPTR),
+		       ahd_inl(ahd, SCB_RESIDUAL_SGPTR));
+	}
+	printf("\n");
+	ahd_set_scbptr(ahd, saved_scb_index);
+	ahd_restore_modes(ahd, saved_modes);
+}
+
+/**************************** Flexport Logic **********************************/
+/*
+ * Read count 16bit words from 16bit word address start_addr from the
+ * SEEPROM attached to the controller, into buf, using the controller's
+ * SEEPROM reading state machine.  Optionally treat the data as a byte
+ * stream in terms of byte order.
+ */
+int
+ahd_read_seeprom(struct ahd_softc *ahd, uint16_t *buf,
+		 u_int start_addr, u_int count, int bytestream)
+{
+	u_int cur_addr;
+	u_int end_addr;
+	int   error;
+
+	/*
+	 * If we never make it through the loop even once,
+	 * we were passed invalid arguments.
+	 */
+	error = EINVAL;
+	AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
+	end_addr = start_addr + count;
+	for (cur_addr = start_addr; cur_addr < end_addr; cur_addr++) {
+
+		ahd_outb(ahd, SEEADR, cur_addr);
+		ahd_outb(ahd, SEECTL, SEEOP_READ | SEESTART);
+		
+		error = ahd_wait_seeprom(ahd);
+		if (error)
+			break;
+		if (bytestream != 0) {
+			uint8_t *bytestream_ptr;
+
+			bytestream_ptr = (uint8_t *)buf;
+			*bytestream_ptr++ = ahd_inb(ahd, SEEDAT);
+			*bytestream_ptr = ahd_inb(ahd, SEEDAT+1);
+		} else {
+			/*
+			 * ahd_inw() already handles machine byte order.
+			 */
+			*buf = ahd_inw(ahd, SEEDAT);
+		}
+		buf++;
+	}
+	return (error);
+}
+
+/*
+ * Write count 16bit words from buf, into SEEPROM attache to the
+ * controller starting at 16bit word address start_addr, using the
+ * controller's SEEPROM writing state machine.
+ */
+int
+ahd_write_seeprom(struct ahd_softc *ahd, uint16_t *buf,
+		  u_int start_addr, u_int count)
+{
+	u_int cur_addr;
+	u_int end_addr;
+	int   error;
+	int   retval;
+
+	AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
+	error = ENOENT;
+
+	/* Place the chip into write-enable mode */
+	ahd_outb(ahd, SEEADR, SEEOP_EWEN_ADDR);
+	ahd_outb(ahd, SEECTL, SEEOP_EWEN | SEESTART);
+	error = ahd_wait_seeprom(ahd);
+	if (error)
+		return (error);
+
+	/*
+	 * Write the data.  If we don't get throught the loop at
+	 * least once, the arguments were invalid.
+	 */
+	retval = EINVAL;
+	end_addr = start_addr + count;
+	for (cur_addr = start_addr; cur_addr < end_addr; cur_addr++) {
+		ahd_outw(ahd, SEEDAT, *buf++);
+		ahd_outb(ahd, SEEADR, cur_addr);
+		ahd_outb(ahd, SEECTL, SEEOP_WRITE | SEESTART);
+		
+		retval = ahd_wait_seeprom(ahd);
+		if (retval)
+			break;
+	}
+
+	/*
+	 * Disable writes.
+	 */
+	ahd_outb(ahd, SEEADR, SEEOP_EWDS_ADDR);
+	ahd_outb(ahd, SEECTL, SEEOP_EWDS | SEESTART);
+	error = ahd_wait_seeprom(ahd);
+	if (error)
+		return (error);
+	return (retval);
+}
+
+/*
+ * Wait ~100us for the serial eeprom to satisfy our request.
+ */
+int
+ahd_wait_seeprom(struct ahd_softc *ahd)
+{
+	int cnt;
+
+	cnt = 20;
+	while ((ahd_inb(ahd, SEESTAT) & (SEEARBACK|SEEBUSY)) != 0 && --cnt)
+		ahd_delay(5);
+
+	if (cnt == 0)
+		return (ETIMEDOUT);
+	return (0);
+}
+
+/*
+ * Validate the two checksums in the per_channel
+ * vital product data struct.
+ */
+int
+ahd_verify_vpd_cksum(struct vpd_config *vpd)
+{
+	int i;
+	int maxaddr;
+	uint32_t checksum;
+	uint8_t *vpdarray;
+
+	vpdarray = (uint8_t *)vpd;
+	maxaddr = offsetof(struct vpd_config, vpd_checksum);
+	checksum = 0;
+	for (i = offsetof(struct vpd_config, resource_type); i < maxaddr; i++)
+		checksum = checksum + vpdarray[i];
+	if (checksum == 0
+	 || (-checksum & 0xFF) != vpd->vpd_checksum)
+		return (0);
+
+	checksum = 0;
+	maxaddr = offsetof(struct vpd_config, checksum);
+	for (i = offsetof(struct vpd_config, default_target_flags);
+	     i < maxaddr; i++)
+		checksum = checksum + vpdarray[i];
+	if (checksum == 0
+	 || (-checksum & 0xFF) != vpd->checksum)
+		return (0);
+	return (1);
+}
+
+int
+ahd_verify_cksum(struct seeprom_config *sc)
+{
+	int i;
+	int maxaddr;
+	uint32_t checksum;
+	uint16_t *scarray;
+
+	maxaddr = (sizeof(*sc)/2) - 1;
+	checksum = 0;
+	scarray = (uint16_t *)sc;
+
+	for (i = 0; i < maxaddr; i++)
+		checksum = checksum + scarray[i];
+	if (checksum == 0
+	 || (checksum & 0xFFFF) != sc->checksum) {
+		return (0);
+	} else {
+		return (1);
+	}
+}
+
+int
+ahd_acquire_seeprom(struct ahd_softc *ahd)
+{
+	/*
+	 * We should be able to determine the SEEPROM type
+	 * from the flexport logic, but unfortunately not
+	 * all implementations have this logic and there is
+	 * no programatic method for determining if the logic
+	 * is present.
+	 */
+	return (1);
+#if 0
+	uint8_t	seetype;
+	int	error;
+
+	error = ahd_read_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL, &seetype);
+	if (error != 0
+         || ((seetype & FLX_ROMSTAT_SEECFG) == FLX_ROMSTAT_SEE_NONE))
+		return (0);
+	return (1);
+#endif
+}
+
+void
+ahd_release_seeprom(struct ahd_softc *ahd)
+{
+	/* Currently a no-op */
+}
+
+int
+ahd_write_flexport(struct ahd_softc *ahd, u_int addr, u_int value)
+{
+	int error;
+
+	AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
+	if (addr > 7)
+		panic("ahd_write_flexport: address out of range");
+	ahd_outb(ahd, BRDCTL, BRDEN|(addr << 3));
+	error = ahd_wait_flexport(ahd);
+	if (error != 0)
+		return (error);
+	ahd_outb(ahd, BRDDAT, value);
+	ahd_flush_device_writes(ahd);
+	ahd_outb(ahd, BRDCTL, BRDSTB|BRDEN|(addr << 3));
+	ahd_flush_device_writes(ahd);
+	ahd_outb(ahd, BRDCTL, BRDEN|(addr << 3));
+	ahd_flush_device_writes(ahd);
+	ahd_outb(ahd, BRDCTL, 0);
+	ahd_flush_device_writes(ahd);
+	return (0);
+}
+
+int
+ahd_read_flexport(struct ahd_softc *ahd, u_int addr, uint8_t *value)
+{
+	int	error;
+
+	AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
+	if (addr > 7)
+		panic("ahd_read_flexport: address out of range");
+	ahd_outb(ahd, BRDCTL, BRDRW|BRDEN|(addr << 3));
+	error = ahd_wait_flexport(ahd);
+	if (error != 0)
+		return (error);
+	*value = ahd_inb(ahd, BRDDAT);
+	ahd_outb(ahd, BRDCTL, 0);
+	ahd_flush_device_writes(ahd);
+	return (0);
+}
+
+/*
+ * Wait at most 2 seconds for flexport arbitration to succeed.
+ */
+int
+ahd_wait_flexport(struct ahd_softc *ahd)
+{
+	int cnt;
+
+	AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
+	cnt = 1000000 * 2 / 5;
+	while ((ahd_inb(ahd, BRDCTL) & FLXARBACK) == 0 && --cnt)
+		ahd_delay(5);
+
+	if (cnt == 0)
+		return (ETIMEDOUT);
+	return (0);
+}
+
+/************************* Target Mode ****************************************/
+#ifdef AHD_TARGET_MODE
+cam_status
+ahd_find_tmode_devs(struct ahd_softc *ahd, struct cam_sim *sim, union ccb *ccb,
+		    struct ahd_tmode_tstate **tstate,
+		    struct ahd_tmode_lstate **lstate,
+		    int notfound_failure)
+{
+
+	if ((ahd->features & AHD_TARGETMODE) == 0)
+		return (CAM_REQ_INVALID);
+
+	/*
+	 * Handle the 'black hole' device that sucks up
+	 * requests to unattached luns on enabled targets.
+	 */
+	if (ccb->ccb_h.target_id == CAM_TARGET_WILDCARD
+	 && ccb->ccb_h.target_lun == CAM_LUN_WILDCARD) {
+		*tstate = NULL;
+		*lstate = ahd->black_hole;
+	} else {
+		u_int max_id;
+
+		max_id = (ahd->features & AHD_WIDE) ? 15 : 7;
+		if (ccb->ccb_h.target_id > max_id)
+			return (CAM_TID_INVALID);
+
+		if (ccb->ccb_h.target_lun >= AHD_NUM_LUNS)
+			return (CAM_LUN_INVALID);
+
+		*tstate = ahd->enabled_targets[ccb->ccb_h.target_id];
+		*lstate = NULL;
+		if (*tstate != NULL)
+			*lstate =
+			    (*tstate)->enabled_luns[ccb->ccb_h.target_lun];
+	}
+
+	if (notfound_failure != 0 && *lstate == NULL)
+		return (CAM_PATH_INVALID);
+
+	return (CAM_REQ_CMP);
+}
+
+void
+ahd_handle_en_lun(struct ahd_softc *ahd, struct cam_sim *sim, union ccb *ccb)
+{
+#if NOT_YET
+	struct	   ahd_tmode_tstate *tstate;
+	struct	   ahd_tmode_lstate *lstate;
+	struct	   ccb_en_lun *cel;
+	cam_status status;
+	u_int	   target;
+	u_int	   lun;
+	u_int	   target_mask;
+	u_long	   s;
+	char	   channel;
+
+	status = ahd_find_tmode_devs(ahd, sim, ccb, &tstate, &lstate,
+				     /*notfound_failure*/FALSE);
+
+	if (status != CAM_REQ_CMP) {
+		ccb->ccb_h.status = status;
+		return;
+	}
+
+	if ((ahd->features & AHD_MULTIROLE) != 0) {
+		u_int	   our_id;
+
+		our_id = ahd->our_id;
+		if (ccb->ccb_h.target_id != our_id) {
+			if ((ahd->features & AHD_MULTI_TID) != 0
+		   	 && (ahd->flags & AHD_INITIATORROLE) != 0) {
+				/*
+				 * Only allow additional targets if
+				 * the initiator role is disabled.
+				 * The hardware cannot handle a re-select-in
+				 * on the initiator id during a re-select-out
+				 * on a different target id.
+				 */
+				status = CAM_TID_INVALID;
+			} else if ((ahd->flags & AHD_INITIATORROLE) != 0
+				|| ahd->enabled_luns > 0) {
+				/*
+				 * Only allow our target id to change
+				 * if the initiator role is not configured
+				 * and there are no enabled luns which
+				 * are attached to the currently registered
+				 * scsi id.
+				 */
+				status = CAM_TID_INVALID;
+			}
+		}
+	}
+
+	if (status != CAM_REQ_CMP) {
+		ccb->ccb_h.status = status;
+		return;
+	}
+
+	/*
+	 * We now have an id that is valid.
+	 * If we aren't in target mode, switch modes.
+	 */
+	if ((ahd->flags & AHD_TARGETROLE) == 0
+	 && ccb->ccb_h.target_id != CAM_TARGET_WILDCARD) {
+		u_long	s;
+
+		printf("Configuring Target Mode\n");
+		ahd_lock(ahd, &s);
+		if (LIST_FIRST(&ahd->pending_scbs) != NULL) {
+			ccb->ccb_h.status = CAM_BUSY;
+			ahd_unlock(ahd, &s);
+			return;
+		}
+		ahd->flags |= AHD_TARGETROLE;
+		if ((ahd->features & AHD_MULTIROLE) == 0)
+			ahd->flags &= ~AHD_INITIATORROLE;
+		ahd_pause(ahd);
+		ahd_loadseq(ahd);
+		ahd_restart(ahd);
+		ahd_unlock(ahd, &s);
+	}
+	cel = &ccb->cel;
+	target = ccb->ccb_h.target_id;
+	lun = ccb->ccb_h.target_lun;
+	channel = SIM_CHANNEL(ahd, sim);
+	target_mask = 0x01 << target;
+	if (channel == 'B')
+		target_mask <<= 8;
+
+	if (cel->enable != 0) {
+		u_int scsiseq1;
+
+		/* Are we already enabled?? */
+		if (lstate != NULL) {
+			xpt_print_path(ccb->ccb_h.path);
+			printf("Lun already enabled\n");
+			ccb->ccb_h.status = CAM_LUN_ALRDY_ENA;
+			return;
+		}
+
+		if (cel->grp6_len != 0
+		 || cel->grp7_len != 0) {
+			/*
+			 * Don't (yet?) support vendor
+			 * specific commands.
+			 */
+			ccb->ccb_h.status = CAM_REQ_INVALID;
+			printf("Non-zero Group Codes\n");
+			return;
+		}
+
+		/*
+		 * Seems to be okay.
+		 * Setup our data structures.
+		 */
+		if (target != CAM_TARGET_WILDCARD && tstate == NULL) {
+			tstate = ahd_alloc_tstate(ahd, target, channel);
+			if (tstate == NULL) {
+				xpt_print_path(ccb->ccb_h.path);
+				printf("Couldn't allocate tstate\n");
+				ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
+				return;
+			}
+		}
+		lstate = malloc(sizeof(*lstate), M_DEVBUF, M_NOWAIT);
+		if (lstate == NULL) {
+			xpt_print_path(ccb->ccb_h.path);
+			printf("Couldn't allocate lstate\n");
+			ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
+			return;
+		}
+		memset(lstate, 0, sizeof(*lstate));
+		status = xpt_create_path(&lstate->path, /*periph*/NULL,
+					 xpt_path_path_id(ccb->ccb_h.path),
+					 xpt_path_target_id(ccb->ccb_h.path),
+					 xpt_path_lun_id(ccb->ccb_h.path));
+		if (status != CAM_REQ_CMP) {
+			free(lstate, M_DEVBUF);
+			xpt_print_path(ccb->ccb_h.path);
+			printf("Couldn't allocate path\n");
+			ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
+			return;
+		}
+		SLIST_INIT(&lstate->accept_tios);
+		SLIST_INIT(&lstate->immed_notifies);
+		ahd_lock(ahd, &s);
+		ahd_pause(ahd);
+		if (target != CAM_TARGET_WILDCARD) {
+			tstate->enabled_luns[lun] = lstate;
+			ahd->enabled_luns++;
+
+			if ((ahd->features & AHD_MULTI_TID) != 0) {
+				u_int targid_mask;
+
+				targid_mask = ahd_inb(ahd, TARGID)
+					    | (ahd_inb(ahd, TARGID + 1) << 8);
+
+				targid_mask |= target_mask;
+				ahd_outb(ahd, TARGID, targid_mask);
+				ahd_outb(ahd, TARGID+1, (targid_mask >> 8));
+				
+				ahd_update_scsiid(ahd, targid_mask);
+			} else {
+				u_int our_id;
+				char  channel;
+
+				channel = SIM_CHANNEL(ahd, sim);
+				our_id = SIM_SCSI_ID(ahd, sim);
+
+				/*
+				 * This can only happen if selections
+				 * are not enabled
+				 */
+				if (target != our_id) {
+					u_int sblkctl;
+					char  cur_channel;
+					int   swap;
+
+					sblkctl = ahd_inb(ahd, SBLKCTL);
+					cur_channel = (sblkctl & SELBUSB)
+						    ? 'B' : 'A';
+					if ((ahd->features & AHD_TWIN) == 0)
+						cur_channel = 'A';
+					swap = cur_channel != channel;
+					ahd->our_id = target;
+
+					if (swap)
+						ahd_outb(ahd, SBLKCTL,
+							 sblkctl ^ SELBUSB);
+
+					ahd_outb(ahd, SCSIID, target);
+
+					if (swap)
+						ahd_outb(ahd, SBLKCTL, sblkctl);
+				}
+			}
+		} else
+			ahd->black_hole = lstate;
+		/* Allow select-in operations */
+		if (ahd->black_hole != NULL && ahd->enabled_luns > 0) {
+			scsiseq1 = ahd_inb(ahd, SCSISEQ_TEMPLATE);
+			scsiseq1 |= ENSELI;
+			ahd_outb(ahd, SCSISEQ_TEMPLATE, scsiseq1);
+			scsiseq1 = ahd_inb(ahd, SCSISEQ1);
+			scsiseq1 |= ENSELI;
+			ahd_outb(ahd, SCSISEQ1, scsiseq1);
+		}
+		ahd_unpause(ahd);
+		ahd_unlock(ahd, &s);
+		ccb->ccb_h.status = CAM_REQ_CMP;
+		xpt_print_path(ccb->ccb_h.path);
+		printf("Lun now enabled for target mode\n");
+	} else {
+		struct scb *scb;
+		int i, empty;
+
+		if (lstate == NULL) {
+			ccb->ccb_h.status = CAM_LUN_INVALID;
+			return;
+		}
+
+		ahd_lock(ahd, &s);
+		
+		ccb->ccb_h.status = CAM_REQ_CMP;
+		LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) {
+			struct ccb_hdr *ccbh;
+
+			ccbh = &scb->io_ctx->ccb_h;
+			if (ccbh->func_code == XPT_CONT_TARGET_IO
+			 && !xpt_path_comp(ccbh->path, ccb->ccb_h.path)){
+				printf("CTIO pending\n");
+				ccb->ccb_h.status = CAM_REQ_INVALID;
+				ahd_unlock(ahd, &s);
+				return;
+			}
+		}
+
+		if (SLIST_FIRST(&lstate->accept_tios) != NULL) {
+			printf("ATIOs pending\n");
+			ccb->ccb_h.status = CAM_REQ_INVALID;
+		}
+
+		if (SLIST_FIRST(&lstate->immed_notifies) != NULL) {
+			printf("INOTs pending\n");
+			ccb->ccb_h.status = CAM_REQ_INVALID;
+		}
+
+		if (ccb->ccb_h.status != CAM_REQ_CMP) {
+			ahd_unlock(ahd, &s);
+			return;
+		}
+
+		xpt_print_path(ccb->ccb_h.path);
+		printf("Target mode disabled\n");
+		xpt_free_path(lstate->path);
+		free(lstate, M_DEVBUF);
+
+		ahd_pause(ahd);
+		/* Can we clean up the target too? */
+		if (target != CAM_TARGET_WILDCARD) {
+			tstate->enabled_luns[lun] = NULL;
+			ahd->enabled_luns--;
+			for (empty = 1, i = 0; i < 8; i++)
+				if (tstate->enabled_luns[i] != NULL) {
+					empty = 0;
+					break;
+				}
+
+			if (empty) {
+				ahd_free_tstate(ahd, target, channel,
+						/*force*/FALSE);
+				if (ahd->features & AHD_MULTI_TID) {
+					u_int targid_mask;
+
+					targid_mask = ahd_inb(ahd, TARGID)
+						    | (ahd_inb(ahd, TARGID + 1)
+						       << 8);
+
+					targid_mask &= ~target_mask;
+					ahd_outb(ahd, TARGID, targid_mask);
+					ahd_outb(ahd, TARGID+1,
+					 	 (targid_mask >> 8));
+					ahd_update_scsiid(ahd, targid_mask);
+				}
+			}
+		} else {
+
+			ahd->black_hole = NULL;
+
+			/*
+			 * We can't allow selections without
+			 * our black hole device.
+			 */
+			empty = TRUE;
+		}
+		if (ahd->enabled_luns == 0) {
+			/* Disallow select-in */
+			u_int scsiseq1;
+
+			scsiseq1 = ahd_inb(ahd, SCSISEQ_TEMPLATE);
+			scsiseq1 &= ~ENSELI;
+			ahd_outb(ahd, SCSISEQ_TEMPLATE, scsiseq1);
+			scsiseq1 = ahd_inb(ahd, SCSISEQ1);
+			scsiseq1 &= ~ENSELI;
+			ahd_outb(ahd, SCSISEQ1, scsiseq1);
+
+			if ((ahd->features & AHD_MULTIROLE) == 0) {
+				printf("Configuring Initiator Mode\n");
+				ahd->flags &= ~AHD_TARGETROLE;
+				ahd->flags |= AHD_INITIATORROLE;
+				ahd_pause(ahd);
+				ahd_loadseq(ahd);
+				ahd_restart(ahd);
+				/*
+				 * Unpaused.  The extra unpause
+				 * that follows is harmless.
+				 */
+			}
+		}
+		ahd_unpause(ahd);
+		ahd_unlock(ahd, &s);
+	}
+#endif
+}
+
+static void
+ahd_update_scsiid(struct ahd_softc *ahd, u_int targid_mask)
+{
+#if NOT_YET
+	u_int scsiid_mask;
+	u_int scsiid;
+
+	if ((ahd->features & AHD_MULTI_TID) == 0)
+		panic("ahd_update_scsiid called on non-multitid unit\n");
+
+	/*
+	 * Since we will rely on the TARGID mask
+	 * for selection enables, ensure that OID
+	 * in SCSIID is not set to some other ID
+	 * that we don't want to allow selections on.
+	 */
+	if ((ahd->features & AHD_ULTRA2) != 0)
+		scsiid = ahd_inb(ahd, SCSIID_ULTRA2);
+	else
+		scsiid = ahd_inb(ahd, SCSIID);
+	scsiid_mask = 0x1 << (scsiid & OID);
+	if ((targid_mask & scsiid_mask) == 0) {
+		u_int our_id;
+
+		/* ffs counts from 1 */
+		our_id = ffs(targid_mask);
+		if (our_id == 0)
+			our_id = ahd->our_id;
+		else
+			our_id--;
+		scsiid &= TID;
+		scsiid |= our_id;
+	}
+	if ((ahd->features & AHD_ULTRA2) != 0)
+		ahd_outb(ahd, SCSIID_ULTRA2, scsiid);
+	else
+		ahd_outb(ahd, SCSIID, scsiid);
+#endif
+}
+
+void
+ahd_run_tqinfifo(struct ahd_softc *ahd, int paused)
+{
+	struct target_cmd *cmd;
+
+	ahd_sync_tqinfifo(ahd, BUS_DMASYNC_POSTREAD);
+	while ((cmd = &ahd->targetcmds[ahd->tqinfifonext])->cmd_valid != 0) {
+
+		/*
+		 * Only advance through the queue if we
+		 * have the resources to process the command.
+		 */
+		if (ahd_handle_target_cmd(ahd, cmd) != 0)
+			break;
+
+		cmd->cmd_valid = 0;
+		ahd_dmamap_sync(ahd, ahd->shared_data_dmat,
+				ahd->shared_data_dmamap,
+				ahd_targetcmd_offset(ahd, ahd->tqinfifonext),
+				sizeof(struct target_cmd),
+				BUS_DMASYNC_PREREAD);
+		ahd->tqinfifonext++;
+
+		/*
+		 * Lazily update our position in the target mode incoming
+		 * command queue as seen by the sequencer.
+		 */
+		if ((ahd->tqinfifonext & (HOST_TQINPOS - 1)) == 1) {
+			u_int hs_mailbox;
+
+			hs_mailbox = ahd_inb(ahd, HS_MAILBOX);
+			hs_mailbox &= ~HOST_TQINPOS;
+			hs_mailbox |= ahd->tqinfifonext & HOST_TQINPOS;
+			ahd_outb(ahd, HS_MAILBOX, hs_mailbox);
+		}
+	}
+}
+
+static int
+ahd_handle_target_cmd(struct ahd_softc *ahd, struct target_cmd *cmd)
+{
+	struct	  ahd_tmode_tstate *tstate;
+	struct	  ahd_tmode_lstate *lstate;
+	struct	  ccb_accept_tio *atio;
+	uint8_t *byte;
+	int	  initiator;
+	int	  target;
+	int	  lun;
+
+	initiator = SCSIID_TARGET(ahd, cmd->scsiid);
+	target = SCSIID_OUR_ID(cmd->scsiid);
+	lun    = (cmd->identify & MSG_IDENTIFY_LUNMASK);
+
+	byte = cmd->bytes;
+	tstate = ahd->enabled_targets[target];
+	lstate = NULL;
+	if (tstate != NULL)
+		lstate = tstate->enabled_luns[lun];
+
+	/*
+	 * Commands for disabled luns go to the black hole driver.
+	 */
+	if (lstate == NULL)
+		lstate = ahd->black_hole;
+
+	atio = (struct ccb_accept_tio*)SLIST_FIRST(&lstate->accept_tios);
+	if (atio == NULL) {
+		ahd->flags |= AHD_TQINFIFO_BLOCKED;
+		/*
+		 * Wait for more ATIOs from the peripheral driver for this lun.
+		 */
+		return (1);
+	} else
+		ahd->flags &= ~AHD_TQINFIFO_BLOCKED;
+#ifdef AHD_DEBUG
+	if ((ahd_debug & AHD_SHOW_TQIN) != 0)
+		printf("Incoming command from %d for %d:%d%s\n",
+		       initiator, target, lun,
+		       lstate == ahd->black_hole ? "(Black Holed)" : "");
+#endif
+	SLIST_REMOVE_HEAD(&lstate->accept_tios, sim_links.sle);
+
+	if (lstate == ahd->black_hole) {
+		/* Fill in the wildcards */
+		atio->ccb_h.target_id = target;
+		atio->ccb_h.target_lun = lun;
+	}
+
+	/*
+	 * Package it up and send it off to
+	 * whomever has this lun enabled.
+	 */
+	atio->sense_len = 0;
+	atio->init_id = initiator;
+	if (byte[0] != 0xFF) {
+		/* Tag was included */
+		atio->tag_action = *byte++;
+		atio->tag_id = *byte++;
+		atio->ccb_h.flags = CAM_TAG_ACTION_VALID;
+	} else {
+		atio->ccb_h.flags = 0;
+	}
+	byte++;
+
+	/* Okay.  Now determine the cdb size based on the command code */
+	switch (*byte >> CMD_GROUP_CODE_SHIFT) {
+	case 0:
+		atio->cdb_len = 6;
+		break;
+	case 1:
+	case 2:
+		atio->cdb_len = 10;
+		break;
+	case 4:
+		atio->cdb_len = 16;
+		break;
+	case 5:
+		atio->cdb_len = 12;
+		break;
+	case 3:
+	default:
+		/* Only copy the opcode. */
+		atio->cdb_len = 1;
+		printf("Reserved or VU command code type encountered\n");
+		break;
+	}
+	
+	memcpy(atio->cdb_io.cdb_bytes, byte, atio->cdb_len);
+
+	atio->ccb_h.status |= CAM_CDB_RECVD;
+
+	if ((cmd->identify & MSG_IDENTIFY_DISCFLAG) == 0) {
+		/*
+		 * We weren't allowed to disconnect.
+		 * We're hanging on the bus until a
+		 * continue target I/O comes in response
+		 * to this accept tio.
+		 */
+#ifdef AHD_DEBUG
+		if ((ahd_debug & AHD_SHOW_TQIN) != 0)
+			printf("Received Immediate Command %d:%d:%d - %p\n",
+			       initiator, target, lun, ahd->pending_device);
+#endif
+		ahd->pending_device = lstate;
+		ahd_freeze_ccb((union ccb *)atio);
+		atio->ccb_h.flags |= CAM_DIS_DISCONNECT;
+	}
+	xpt_done((union ccb*)atio);
+	return (0);
+}
+
+#endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic79xx_inline.h linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx_inline.h
--- linux-2.4.21/drivers/scsi/aic7xxx/aic79xx_inline.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx_inline.h	2003-06-26 21:43:21.000000000 +0000
@@ -0,0 +1,958 @@
+/*
+ * Inline routines shareable across OS platforms.
+ *
+ * Copyright (c) 1994-2001 Justin T. Gibbs.
+ * Copyright (c) 2000-2003 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: //depot/aic7xxx/aic7xxx/aic79xx_inline.h#50 $
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _AIC79XX_INLINE_H_
+#define _AIC79XX_INLINE_H_
+
+/******************************** Debugging ***********************************/
+static __inline char *ahd_name(struct ahd_softc *ahd);
+
+static __inline char *
+ahd_name(struct ahd_softc *ahd)
+{
+	return (ahd->name);
+}
+
+/************************ Sequencer Execution Control *************************/
+static __inline void ahd_known_modes(struct ahd_softc *ahd,
+				     ahd_mode src, ahd_mode dst);
+static __inline ahd_mode_state ahd_build_mode_state(struct ahd_softc *ahd,
+						    ahd_mode src,
+						    ahd_mode dst);
+static __inline void ahd_extract_mode_state(struct ahd_softc *ahd,
+					    ahd_mode_state state,
+					    ahd_mode *src, ahd_mode *dst);
+static __inline void ahd_set_modes(struct ahd_softc *ahd, ahd_mode src,
+				   ahd_mode dst);
+static __inline void ahd_update_modes(struct ahd_softc *ahd);
+static __inline void ahd_assert_modes(struct ahd_softc *ahd, ahd_mode srcmode,
+				      ahd_mode dstmode, const char *file,
+				      int line);
+static __inline ahd_mode_state ahd_save_modes(struct ahd_softc *ahd);
+static __inline void ahd_restore_modes(struct ahd_softc *ahd,
+				       ahd_mode_state state);
+static __inline int  ahd_is_paused(struct ahd_softc *ahd);
+static __inline void ahd_pause(struct ahd_softc *ahd);
+static __inline void ahd_unpause(struct ahd_softc *ahd);
+
+static __inline void
+ahd_known_modes(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
+{
+	ahd->src_mode = src;
+	ahd->dst_mode = dst;
+	ahd->saved_src_mode = src;
+	ahd->saved_dst_mode = dst;
+}
+
+static __inline ahd_mode_state
+ahd_build_mode_state(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
+{
+	return ((src << SRC_MODE_SHIFT) | (dst << DST_MODE_SHIFT));
+}
+
+static __inline void
+ahd_extract_mode_state(struct ahd_softc *ahd, ahd_mode_state state,
+		       ahd_mode *src, ahd_mode *dst)
+{
+	*src = (state & SRC_MODE) >> SRC_MODE_SHIFT;
+	*dst = (state & DST_MODE) >> DST_MODE_SHIFT;
+}
+
+static __inline void
+ahd_set_modes(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
+{
+	if (ahd->src_mode == src && ahd->dst_mode == dst)
+		return;
+#ifdef AHD_DEBUG
+	if (ahd->src_mode == AHD_MODE_UNKNOWN
+	 || ahd->dst_mode == AHD_MODE_UNKNOWN)
+		panic("Setting mode prior to saving it.\n");
+	if ((ahd_debug & AHD_SHOW_MODEPTR) != 0)
+		printf("%s: Setting mode 0x%x\n", ahd_name(ahd),
+		       ahd_build_mode_state(ahd, src, dst));
+#endif
+	ahd_outb(ahd, MODE_PTR, ahd_build_mode_state(ahd, src, dst));
+	ahd->src_mode = src;
+	ahd->dst_mode = dst;
+}
+
+static __inline void
+ahd_update_modes(struct ahd_softc *ahd)
+{
+	ahd_mode_state mode_ptr;
+	ahd_mode src;
+	ahd_mode dst;
+
+	mode_ptr = ahd_inb(ahd, MODE_PTR);
+#ifdef AHD_DEBUG
+	if ((ahd_debug & AHD_SHOW_MODEPTR) != 0)
+		printf("Reading mode 0x%x\n", mode_ptr);
+#endif
+	ahd_extract_mode_state(ahd, mode_ptr, &src, &dst);
+	ahd_known_modes(ahd, src, dst);
+}
+
+static __inline void
+ahd_assert_modes(struct ahd_softc *ahd, ahd_mode srcmode,
+		 ahd_mode dstmode, const char *file, int line)
+{
+#ifdef AHD_DEBUG
+	if ((srcmode & AHD_MK_MSK(ahd->src_mode)) == 0
+	 || (dstmode & AHD_MK_MSK(ahd->dst_mode)) == 0) {
+		panic("%s:%s:%d: Mode assertion failed.\n",
+		       ahd_name(ahd), file, line);
+	}
+#endif
+}
+
+static __inline ahd_mode_state
+ahd_save_modes(struct ahd_softc *ahd)
+{
+	if (ahd->src_mode == AHD_MODE_UNKNOWN
+	 || ahd->dst_mode == AHD_MODE_UNKNOWN)
+		ahd_update_modes(ahd);
+
+	return (ahd_build_mode_state(ahd, ahd->src_mode, ahd->dst_mode));
+}
+
+static __inline void
+ahd_restore_modes(struct ahd_softc *ahd, ahd_mode_state state)
+{
+	ahd_mode src;
+	ahd_mode dst;
+
+	ahd_extract_mode_state(ahd, state, &src, &dst);
+	ahd_set_modes(ahd, src, dst);
+}
+
+#define AHD_ASSERT_MODES(ahd, source, dest) \
+	ahd_assert_modes(ahd, source, dest, __FILE__, __LINE__);
+
+/*
+ * Determine whether the sequencer has halted code execution.
+ * Returns non-zero status if the sequencer is stopped.
+ */
+static __inline int
+ahd_is_paused(struct ahd_softc *ahd)
+{
+	return ((ahd_inb(ahd, HCNTRL) & PAUSE) != 0);
+}
+
+/*
+ * Request that the sequencer stop and wait, indefinitely, for it
+ * to stop.  The sequencer will only acknowledge that it is paused
+ * once it has reached an instruction boundary and PAUSEDIS is
+ * cleared in the SEQCTL register.  The sequencer may use PAUSEDIS
+ * for critical sections.
+ */
+static __inline void
+ahd_pause(struct ahd_softc *ahd)
+{
+	ahd_outb(ahd, HCNTRL, ahd->pause);
+
+	/*
+	 * Since the sequencer can disable pausing in a critical section, we
+	 * must loop until it actually stops.
+	 */
+	while (ahd_is_paused(ahd) == 0)
+		;
+}
+
+/*
+ * Allow the sequencer to continue program execution.
+ * We check here to ensure that no additional interrupt
+ * sources that would cause the sequencer to halt have been
+ * asserted.  If, for example, a SCSI bus reset is detected
+ * while we are fielding a different, pausing, interrupt type,
+ * we don't want to release the sequencer before going back
+ * into our interrupt handler and dealing with this new
+ * condition.
+ */
+static __inline void
+ahd_unpause(struct ahd_softc *ahd)
+{
+	/*
+	 * Automatically restore our modes to those saved
+	 * prior to the first change of the mode.
+	 */
+	if (ahd->saved_src_mode != AHD_MODE_UNKNOWN
+	 && ahd->saved_dst_mode != AHD_MODE_UNKNOWN) {
+		if ((ahd->flags & AHD_UPDATE_PEND_CMDS) != 0)
+			ahd_reset_cmds_pending(ahd);
+		ahd_set_modes(ahd, ahd->saved_src_mode, ahd->saved_dst_mode);
+	}
+
+	if ((ahd_inb(ahd, INTSTAT) & ~CMDCMPLT) == 0)
+		ahd_outb(ahd, HCNTRL, ahd->unpause);
+
+	ahd_known_modes(ahd, AHD_MODE_UNKNOWN, AHD_MODE_UNKNOWN);
+}
+
+/*********************** Scatter Gather List Handling *************************/
+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);
+static __inline void	 ahd_setup_scb_common(struct ahd_softc *ahd,
+					      struct scb *scb);
+static __inline void	 ahd_setup_data_scb(struct ahd_softc *ahd,
+					    struct scb *scb);
+static __inline void	 ahd_setup_noxfer_scb(struct ahd_softc *ahd,
+					      struct scb *scb);
+
+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)
+{
+	scb->sg_count++;
+	if (sizeof(bus_addr_t) > 4
+	 && (ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
+		struct ahd_dma64_seg *sg;
+
+		sg = (struct ahd_dma64_seg *)sgptr;
+		sg->addr = ahd_htole64(addr);
+		sg->len = ahd_htole32(len | (last ? AHD_DMA_LAST_SEG : 0));
+		return (sg + 1);
+	} else {
+		struct ahd_dma_seg *sg;
+
+		sg = (struct ahd_dma_seg *)sgptr;
+		sg->addr = ahd_htole32(addr & 0xFFFFFFFF);
+		sg->len = ahd_htole32(len | ((addr >> 8) & 0x7F000000)
+				    | (last ? AHD_DMA_LAST_SEG : 0));
+		return (sg + 1);
+	}
+}
+
+static __inline void
+ahd_setup_scb_common(struct ahd_softc *ahd, struct scb *scb)
+{
+	/* XXX Handle target mode SCBs. */
+	scb->crc_retry_count = 0;
+	if ((scb->flags & SCB_PACKETIZED) != 0) {
+		/* XXX what about ACA??  It is type 4, but TAG_TYPE == 0x3. */
+		scb->hscb->task_attribute = scb->hscb->control & SCB_TAG_TYPE;
+	} else {
+		if (ahd_get_transfer_length(scb) & 0x01)
+			scb->hscb->task_attribute = SCB_XFERLEN_ODD;
+		else
+			scb->hscb->task_attribute = 0;
+	}
+
+	if (scb->hscb->cdb_len <= MAX_CDB_LEN_WITH_SENSE_ADDR
+	 || (scb->hscb->cdb_len & SCB_CDB_LEN_PTR) != 0)
+		scb->hscb->shared_data.idata.cdb_plus_saddr.sense_addr =
+		    ahd_htole32(scb->sense_busaddr);
+}
+
+static __inline void
+ahd_setup_data_scb(struct ahd_softc *ahd, struct scb *scb)
+{
+	/*
+	 * Copy the first SG into the "current" data ponter area.
+	 */
+	if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
+		struct ahd_dma64_seg *sg;
+
+		sg = (struct ahd_dma64_seg *)scb->sg_list;
+		scb->hscb->dataptr = sg->addr;
+		scb->hscb->datacnt = sg->len;
+	} else {
+		struct ahd_dma_seg *sg;
+		uint32_t *dataptr_words;
+
+		sg = (struct ahd_dma_seg *)scb->sg_list;
+		dataptr_words = (uint32_t*)&scb->hscb->dataptr;
+		dataptr_words[0] = sg->addr;
+		dataptr_words[1] = 0;
+		if ((ahd->flags & AHD_39BIT_ADDRESSING) != 0) {
+			uint64_t high_addr;
+
+			high_addr = ahd_le32toh(sg->len) & 0x7F000000;
+			scb->hscb->dataptr |= ahd_htole64(high_addr << 8);
+		}
+		scb->hscb->datacnt = sg->len;
+	}
+	/*
+	 * Note where to find the SG entries in bus space.
+	 * We also set the full residual flag which the 
+	 * sequencer will clear as soon as a data transfer
+	 * occurs.
+	 */
+	scb->hscb->sgptr = ahd_htole32(scb->sg_list_busaddr|SG_FULL_RESID);
+}
+
+static __inline void
+ahd_setup_noxfer_scb(struct ahd_softc *ahd, struct scb *scb)
+{
+	scb->hscb->sgptr = ahd_htole32(SG_LIST_NULL);
+	scb->hscb->dataptr = 0;
+	scb->hscb->datacnt = 0;
+}
+
+/************************** Memory mapping routines ***************************/
+static __inline size_t	ahd_sg_size(struct ahd_softc *ahd);
+static __inline void *
+			ahd_sg_bus_to_virt(struct ahd_softc *ahd,
+					   struct scb *scb,
+					   uint32_t sg_busaddr);
+static __inline uint32_t
+			ahd_sg_virt_to_bus(struct ahd_softc *ahd,
+					   struct scb *scb,
+					   void *sg);
+static __inline void	ahd_sync_scb(struct ahd_softc *ahd,
+				     struct scb *scb, int op);
+static __inline void	ahd_sync_sglist(struct ahd_softc *ahd,
+					struct scb *scb, int op);
+static __inline void	ahd_sync_sense(struct ahd_softc *ahd,
+				       struct scb *scb, int op);
+static __inline uint32_t
+			ahd_targetcmd_offset(struct ahd_softc *ahd,
+					     u_int index);
+
+static __inline size_t
+ahd_sg_size(struct ahd_softc *ahd)
+{
+	if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0)
+		return (sizeof(struct ahd_dma64_seg));
+	return (sizeof(struct ahd_dma_seg));
+}
+
+static __inline void *
+ahd_sg_bus_to_virt(struct ahd_softc *ahd, struct scb *scb, uint32_t sg_busaddr)
+{
+	bus_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));
+	return ((uint8_t *)scb->sg_list + sg_offset);
+}
+
+static __inline uint32_t
+ahd_sg_virt_to_bus(struct ahd_softc *ahd, struct scb *scb, void *sg)
+{
+	bus_addr_t sg_offset;
+
+	/* sg_list_phys points to entry 1, not 0 */
+	sg_offset = ((uint8_t *)sg - (uint8_t *)scb->sg_list)
+		  - ahd_sg_size(ahd);
+
+	return (scb->sg_list_busaddr + sg_offset);
+}
+
+static __inline void
+ahd_sync_scb(struct ahd_softc *ahd, struct scb *scb, int op)
+{
+	ahd_dmamap_sync(ahd, ahd->scb_data.hscb_dmat,
+			scb->hscb_map->dmamap,
+			/*offset*/(uint8_t*)scb->hscb - scb->hscb_map->vaddr,
+			/*len*/sizeof(*scb->hscb), op);
+}
+
+static __inline void
+ahd_sync_sglist(struct ahd_softc *ahd, struct scb *scb, int op)
+{
+	if (scb->sg_count == 0)
+		return;
+
+	ahd_dmamap_sync(ahd, ahd->scb_data.sg_dmat,
+			scb->sg_map->dmamap,
+			/*offset*/scb->sg_list_busaddr - ahd_sg_size(ahd),
+			/*len*/ahd_sg_size(ahd) * scb->sg_count, op);
+}
+
+static __inline void
+ahd_sync_sense(struct ahd_softc *ahd, struct scb *scb, int op)
+{
+	ahd_dmamap_sync(ahd, ahd->scb_data.sense_dmat,
+			scb->sense_map->dmamap,
+			/*offset*/scb->sense_busaddr,
+			/*len*/AHD_SENSE_BUFSIZE, op);
+}
+
+static __inline uint32_t
+ahd_targetcmd_offset(struct ahd_softc *ahd, u_int index)
+{
+	return (((uint8_t *)&ahd->targetcmds[index])
+	       - (uint8_t *)ahd->qoutfifo);
+}
+
+/*********************** Miscelaneous Support Functions ***********************/
+static __inline void	ahd_complete_scb(struct ahd_softc *ahd,
+					 struct scb *scb);
+static __inline void	ahd_update_residual(struct ahd_softc *ahd,
+					    struct scb *scb);
+static __inline struct ahd_initiator_tinfo *
+			ahd_fetch_transinfo(struct ahd_softc *ahd,
+					    char channel, u_int our_id,
+					    u_int remote_id,
+					    struct ahd_tmode_tstate **tstate);
+static __inline uint16_t
+			ahd_inw(struct ahd_softc *ahd, u_int port);
+static __inline void	ahd_outw(struct ahd_softc *ahd, u_int port,
+				 u_int value);
+static __inline uint32_t
+			ahd_inl(struct ahd_softc *ahd, u_int port);
+static __inline void	ahd_outl(struct ahd_softc *ahd, u_int port,
+				 uint32_t value);
+static __inline uint64_t
+			ahd_inq(struct ahd_softc *ahd, u_int port);
+static __inline void	ahd_outq(struct ahd_softc *ahd, u_int port,
+				 uint64_t value);
+static __inline u_int	ahd_get_scbptr(struct ahd_softc *ahd);
+static __inline void	ahd_set_scbptr(struct ahd_softc *ahd, u_int scbptr);
+static __inline u_int	ahd_get_hnscb_qoff(struct ahd_softc *ahd);
+static __inline void	ahd_set_hnscb_qoff(struct ahd_softc *ahd, u_int value);
+static __inline u_int	ahd_get_hescb_qoff(struct ahd_softc *ahd);
+static __inline void	ahd_set_hescb_qoff(struct ahd_softc *ahd, u_int value);
+static __inline u_int	ahd_get_snscb_qoff(struct ahd_softc *ahd);
+static __inline void	ahd_set_snscb_qoff(struct ahd_softc *ahd, u_int value);
+static __inline u_int	ahd_get_sescb_qoff(struct ahd_softc *ahd);
+static __inline void	ahd_set_sescb_qoff(struct ahd_softc *ahd, u_int value);
+static __inline u_int	ahd_get_sdscb_qoff(struct ahd_softc *ahd);
+static __inline void	ahd_set_sdscb_qoff(struct ahd_softc *ahd, u_int value);
+static __inline u_int	ahd_inb_scbram(struct ahd_softc *ahd, u_int offset);
+static __inline u_int	ahd_inw_scbram(struct ahd_softc *ahd, u_int offset);
+static __inline uint32_t
+			ahd_inl_scbram(struct ahd_softc *ahd, u_int offset);
+static __inline void	ahd_swap_with_next_hscb(struct ahd_softc *ahd,
+						struct scb *scb);
+static __inline void	ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb);
+static __inline uint8_t *
+			ahd_get_sense_buf(struct ahd_softc *ahd,
+					  struct scb *scb);
+static __inline uint32_t
+			ahd_get_sense_bufaddr(struct ahd_softc *ahd,
+					      struct scb *scb);
+
+static __inline void
+ahd_complete_scb(struct ahd_softc *ahd, struct scb *scb)
+{
+	uint32_t sgptr;
+
+	sgptr = ahd_le32toh(scb->hscb->sgptr);
+	if ((sgptr & SG_STATUS_VALID) != 0)
+		ahd_handle_scb_status(ahd, scb);
+	else
+		ahd_done(ahd, scb);
+}
+
+/*
+ * Determine whether the sequencer reported a residual
+ * for this SCB/transaction.
+ */
+static __inline void
+ahd_update_residual(struct ahd_softc *ahd, struct scb *scb)
+{
+	uint32_t sgptr;
+
+	sgptr = ahd_le32toh(scb->hscb->sgptr);
+	if ((sgptr & SG_STATUS_VALID) != 0)
+		ahd_calc_residual(ahd, scb);
+}
+
+/*
+ * Return pointers to the transfer negotiation information
+ * for the specified our_id/remote_id pair.
+ */
+static __inline struct ahd_initiator_tinfo *
+ahd_fetch_transinfo(struct ahd_softc *ahd, char channel, u_int our_id,
+		    u_int remote_id, struct ahd_tmode_tstate **tstate)
+{
+	/*
+	 * Transfer data structures are stored from the perspective
+	 * of the target role.  Since the parameters for a connection
+	 * in the initiator role to a given target are the same as
+	 * when the roles are reversed, we pretend we are the target.
+	 */
+	if (channel == 'B')
+		our_id += 8;
+	*tstate = ahd->enabled_targets[our_id];
+	return (&(*tstate)->transinfo[remote_id]);
+}
+
+#define AHD_COPY_COL_IDX(dst, src)				\
+do {								\
+	dst->hscb->scsiid = src->hscb->scsiid;			\
+	dst->hscb->lun = src->hscb->lun;			\
+} while (0)
+
+static __inline uint16_t
+ahd_inw(struct ahd_softc *ahd, u_int port)
+{
+	return ((ahd_inb(ahd, port+1) << 8) | ahd_inb(ahd, port));
+}
+
+static __inline void
+ahd_outw(struct ahd_softc *ahd, u_int port, u_int value)
+{
+	ahd_outb(ahd, port, value & 0xFF);
+	ahd_outb(ahd, port+1, (value >> 8) & 0xFF);
+}
+
+static __inline uint32_t
+ahd_inl(struct ahd_softc *ahd, u_int port)
+{
+	return ((ahd_inb(ahd, port))
+	      | (ahd_inb(ahd, port+1) << 8)
+	      | (ahd_inb(ahd, port+2) << 16)
+	      | (ahd_inb(ahd, port+3) << 24));
+}
+
+static __inline void
+ahd_outl(struct ahd_softc *ahd, u_int port, uint32_t value)
+{
+	ahd_outb(ahd, port, (value) & 0xFF);
+	ahd_outb(ahd, port+1, ((value) >> 8) & 0xFF);
+	ahd_outb(ahd, port+2, ((value) >> 16) & 0xFF);
+	ahd_outb(ahd, port+3, ((value) >> 24) & 0xFF);
+}
+
+static __inline uint64_t
+ahd_inq(struct ahd_softc *ahd, u_int port)
+{
+	return ((ahd_inb(ahd, port))
+	      | (ahd_inb(ahd, port+1) << 8)
+	      | (ahd_inb(ahd, port+2) << 16)
+	      | (ahd_inb(ahd, port+3) << 24)
+	      | (((uint64_t)ahd_inb(ahd, port+4)) << 32)
+	      | (((uint64_t)ahd_inb(ahd, port+5)) << 40)
+	      | (((uint64_t)ahd_inb(ahd, port+6)) << 48)
+	      | (((uint64_t)ahd_inb(ahd, port+7)) << 56));
+}
+
+static __inline void
+ahd_outq(struct ahd_softc *ahd, u_int port, uint64_t value)
+{
+	ahd_outb(ahd, port, value & 0xFF);
+	ahd_outb(ahd, port+1, (value >> 8) & 0xFF);
+	ahd_outb(ahd, port+2, (value >> 16) & 0xFF);
+	ahd_outb(ahd, port+3, (value >> 24) & 0xFF);
+	ahd_outb(ahd, port+4, (value >> 32) & 0xFF);
+	ahd_outb(ahd, port+5, (value >> 40) & 0xFF);
+	ahd_outb(ahd, port+6, (value >> 48) & 0xFF);
+	ahd_outb(ahd, port+7, (value >> 56) & 0xFF);
+}
+
+static __inline u_int
+ahd_get_scbptr(struct ahd_softc *ahd)
+{
+	AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
+			 ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
+	return (ahd_inb(ahd, SCBPTR) | (ahd_inb(ahd, SCBPTR + 1) << 8));
+}
+
+static __inline void
+ahd_set_scbptr(struct ahd_softc *ahd, u_int scbptr)
+{
+	AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
+			 ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
+	ahd_outb(ahd, SCBPTR, scbptr & 0xFF);
+	ahd_outb(ahd, SCBPTR+1, (scbptr >> 8) & 0xFF);
+}
+
+static __inline u_int
+ahd_get_hnscb_qoff(struct ahd_softc *ahd)
+{
+	return (ahd_inw_atomic(ahd, HNSCB_QOFF));
+}
+
+static __inline void
+ahd_set_hnscb_qoff(struct ahd_softc *ahd, u_int value)
+{
+	ahd_outw_atomic(ahd, HNSCB_QOFF, value);
+}
+
+static __inline u_int
+ahd_get_hescb_qoff(struct ahd_softc *ahd)
+{
+	return (ahd_inb(ahd, HESCB_QOFF));
+}
+
+static __inline void
+ahd_set_hescb_qoff(struct ahd_softc *ahd, u_int value)
+{
+	ahd_outb(ahd, HESCB_QOFF, value);
+}
+
+static __inline u_int
+ahd_get_snscb_qoff(struct ahd_softc *ahd)
+{
+	u_int oldvalue;
+
+	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
+	oldvalue = ahd_inw(ahd, SNSCB_QOFF);
+	ahd_outw(ahd, SNSCB_QOFF, oldvalue);
+	return (oldvalue);
+}
+
+static __inline void
+ahd_set_snscb_qoff(struct ahd_softc *ahd, u_int value)
+{
+	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
+	ahd_outw(ahd, SNSCB_QOFF, value);
+}
+
+static __inline u_int
+ahd_get_sescb_qoff(struct ahd_softc *ahd)
+{
+	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
+	return (ahd_inb(ahd, SESCB_QOFF));
+}
+
+static __inline void
+ahd_set_sescb_qoff(struct ahd_softc *ahd, u_int value)
+{
+	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
+	ahd_outb(ahd, SESCB_QOFF, value);
+}
+
+static __inline u_int
+ahd_get_sdscb_qoff(struct ahd_softc *ahd)
+{
+	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
+	return (ahd_inb(ahd, SDSCB_QOFF) | (ahd_inb(ahd, SDSCB_QOFF + 1) << 8));
+}
+
+static __inline void
+ahd_set_sdscb_qoff(struct ahd_softc *ahd, u_int value)
+{
+	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
+	ahd_outb(ahd, SDSCB_QOFF, value & 0xFF);
+	ahd_outb(ahd, SDSCB_QOFF+1, (value >> 8) & 0xFF);
+}
+
+static __inline u_int
+ahd_inb_scbram(struct ahd_softc *ahd, u_int offset)
+{
+	u_int value;
+
+	/*
+	 * Workaround PCI-X Rev A. hardware bug.
+	 * After a host read of SCB memory, the chip
+	 * may become confused into thinking prefetch
+	 * was required.  This starts the discard timer
+	 * running and can cause an unexpected discard
+	 * timer interrupt.  The work around is to read
+	 * a normal register prior to the exhaustion of
+	 * the discard timer.  The mode pointer register
+	 * has no side effects and so serves well for
+	 * this purpose.
+	 *
+	 * Razor #528
+	 */
+	value = ahd_inb(ahd, offset);
+	if ((ahd->flags & AHD_PCIX_SCBRAM_RD_BUG) != 0)
+		ahd_inb(ahd, MODE_PTR);
+	return (value);
+}
+
+static __inline u_int
+ahd_inw_scbram(struct ahd_softc *ahd, u_int offset)
+{
+	return (ahd_inb_scbram(ahd, offset)
+	      | (ahd_inb_scbram(ahd, offset+1) << 8));
+}
+
+static __inline uint32_t
+ahd_inl_scbram(struct ahd_softc *ahd, u_int offset)
+{
+	return (ahd_inb_scbram(ahd, offset)
+	      | (ahd_inb_scbram(ahd, offset+1) << 8)
+	      | (ahd_inb_scbram(ahd, offset+2) << 16)
+	      | (ahd_inb_scbram(ahd, offset+3) << 24));
+}
+
+static __inline struct scb *
+ahd_lookup_scb(struct ahd_softc *ahd, u_int tag)
+{
+	struct scb* scb;
+
+	if (tag >= AHD_SCB_MAX)
+		return (NULL);
+	scb = ahd->scb_data.scbindex[tag];
+	if (scb != NULL)
+		ahd_sync_scb(ahd, scb,
+			     BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);
+	return (scb);
+}
+
+static __inline void
+ahd_swap_with_next_hscb(struct ahd_softc *ahd, struct scb *scb)
+{
+	struct hardware_scb *q_hscb;
+	uint32_t saved_hscb_busaddr;
+
+	/*
+	 * Our queuing method is a bit tricky.  The card
+	 * knows in advance which HSCB (by address) to download,
+	 * and we can't disappoint it.  To achieve this, the next
+	 * HSCB to download is saved off in ahd->next_queued_hscb.
+	 * When we are called to queue "an arbitrary scb",
+	 * we copy the contents of the incoming HSCB to the one
+	 * the sequencer knows about, swap HSCB pointers and
+	 * finally assign the SCB to the tag indexed location
+	 * in the scb_array.  This makes sure that we can still
+	 * locate the correct SCB by SCB_TAG.
+	 */
+	q_hscb = ahd->next_queued_hscb;
+	saved_hscb_busaddr = q_hscb->hscb_busaddr;
+	memcpy(q_hscb, scb->hscb, sizeof(*scb->hscb));
+	q_hscb->hscb_busaddr = saved_hscb_busaddr;
+	q_hscb->next_hscb_busaddr = scb->hscb->hscb_busaddr;
+
+	/* Now swap HSCB pointers. */
+	ahd->next_queued_hscb = scb->hscb;
+	scb->hscb = q_hscb;
+
+	/* Now define the mapping from tag to SCB in the scbindex */
+	ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = scb;
+}
+
+/*
+ * Tell the sequencer about a new transaction to execute.
+ */
+static __inline void
+ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb)
+{
+	ahd_swap_with_next_hscb(ahd, scb);
+
+	if (SCBID_IS_NULL(SCB_GET_TAG(scb)))
+		panic("Attempt to queue invalid SCB tag %x\n",
+		      SCB_GET_TAG(scb));
+
+	/*
+	 * Keep a history of SCBs we've downloaded in the qinfifo.
+	 */
+	ahd->qinfifo[AHD_QIN_WRAP(ahd->qinfifonext)] = SCB_GET_TAG(scb);
+	ahd->qinfifonext++;
+
+	if (scb->sg_count != 0)
+		ahd_setup_data_scb(ahd, scb);
+	else
+		ahd_setup_noxfer_scb(ahd, scb);
+	ahd_setup_scb_common(ahd, scb);
+
+	/*
+	 * Make sure our data is consistent from the
+	 * perspective of the adapter.
+	 */
+	ahd_sync_scb(ahd, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
+
+#ifdef AHD_DEBUG
+	if ((ahd_debug & AHD_SHOW_QUEUE) != 0) {
+		uint64_t host_dataptr;
+
+		host_dataptr = ahd_le64toh(scb->hscb->dataptr);
+		printf("%s: Queueing SCB 0x%x bus addr 0x%x - 0x%x%x/0x%x\n",
+		       ahd_name(ahd),
+		       SCB_GET_TAG(scb), ahd_le32toh(scb->hscb->hscb_busaddr),
+		       (u_int)((host_dataptr >> 32) & 0xFFFFFFFF),
+		       (u_int)(host_dataptr & 0xFFFFFFFF),
+		       ahd_le32toh(scb->hscb->datacnt));
+	}
+#endif
+	/* Tell the adapter about the newly queued SCB */
+	ahd_set_hnscb_qoff(ahd, ahd->qinfifonext);
+}
+
+static __inline uint8_t *
+ahd_get_sense_buf(struct ahd_softc *ahd, struct scb *scb)
+{
+	return (scb->sense_data);
+}
+
+static __inline uint32_t
+ahd_get_sense_bufaddr(struct ahd_softc *ahd, struct scb *scb)
+{
+	return (scb->sense_busaddr);
+}
+
+/************************** Interrupt Processing ******************************/
+static __inline void	ahd_sync_qoutfifo(struct ahd_softc *ahd, int op);
+static __inline void	ahd_sync_tqinfifo(struct ahd_softc *ahd, int op);
+static __inline u_int	ahd_check_cmdcmpltqueues(struct ahd_softc *ahd);
+static __inline int	ahd_intr(struct ahd_softc *ahd);
+
+static __inline void
+ahd_sync_qoutfifo(struct ahd_softc *ahd, int op)
+{
+	ahd_dmamap_sync(ahd, ahd->shared_data_dmat, ahd->shared_data_dmamap,
+			/*offset*/0, /*len*/AHC_SCB_MAX * sizeof(uint16_t), op);
+}
+
+static __inline void
+ahd_sync_tqinfifo(struct ahd_softc *ahd, int op)
+{
+#ifdef AHD_TARGET_MODE
+	if ((ahd->flags & AHD_TARGETROLE) != 0) {
+		ahd_dmamap_sync(ahd, ahd->shared_data_dmat,
+				ahd->shared_data_dmamap,
+				ahd_targetcmd_offset(ahd, 0),
+				sizeof(struct target_cmd) * AHD_TMODE_CMDS,
+				op);
+	}
+#endif
+}
+
+/*
+ * See if the firmware has posted any completed commands
+ * into our in-core command complete fifos.
+ */
+#define AHD_RUN_QOUTFIFO 0x1
+#define AHD_RUN_TQINFIFO 0x2
+static __inline u_int
+ahd_check_cmdcmpltqueues(struct ahd_softc *ahd)
+{
+	u_int retval;
+
+	retval = 0;
+	ahd_dmamap_sync(ahd, ahd->shared_data_dmat, ahd->shared_data_dmamap,
+			/*offset*/ahd->qoutfifonext, /*len*/2,
+			BUS_DMASYNC_POSTREAD);
+	if ((ahd->qoutfifo[ahd->qoutfifonext]
+	     & QOUTFIFO_ENTRY_VALID_LE) == ahd->qoutfifonext_valid_tag)
+		retval |= AHD_RUN_QOUTFIFO;
+#ifdef AHD_TARGET_MODE
+	if ((ahd->flags & AHD_TARGETROLE) != 0
+	 && (ahd->flags & AHD_TQINFIFO_BLOCKED) == 0) {
+		ahd_dmamap_sync(ahd, ahd->shared_data_dmat,
+				ahd->shared_data_dmamap,
+				ahd_targetcmd_offset(ahd, ahd->tqinfifofnext),
+				/*len*/sizeof(struct target_cmd),
+				BUS_DMASYNC_POSTREAD);
+		if (ahd->targetcmds[ahd->tqinfifonext].cmd_valid != 0)
+			retval |= AHD_RUN_TQINFIFO;
+	}
+#endif
+	return (retval);
+}
+
+/*
+ * Catch an interrupt from the adapter
+ */
+static __inline int
+ahd_intr(struct ahd_softc *ahd)
+{
+	u_int	intstat;
+
+	if ((ahd->pause & INTEN) == 0) {
+		/*
+		 * Our interrupt is not enabled on the chip
+		 * and may be disabled for re-entrancy reasons,
+		 * so just return.  This is likely just a shared
+		 * interrupt.
+		 */
+		return (0);
+	}
+
+	/*
+	 * Instead of directly reading the interrupt status register,
+	 * infer the cause of the interrupt by checking our in-core
+	 * completion queues.  This avoids a costly PCI bus read in
+	 * most cases.
+	 */
+	if ((ahd->flags & AHD_ALL_INTERRUPTS) == 0
+	 && (ahd_check_cmdcmpltqueues(ahd) != 0))
+		intstat = CMDCMPLT;
+	else
+		intstat = ahd_inb(ahd, INTSTAT);
+
+	if ((intstat & INT_PEND) == 0)
+		return (0);
+
+	if (intstat & CMDCMPLT) {
+		ahd_outb(ahd, CLRINT, CLRCMDINT);
+
+		/*
+		 * Ensure that the chip sees that we've cleared
+		 * this interrupt before we walk the output fifo.
+		 * Otherwise, we may, due to posted bus writes,
+		 * clear the interrupt after we finish the scan,
+		 * and after the sequencer has added new entries
+		 * and asserted the interrupt again.
+		 */
+		if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) {
+			if (ahd_is_paused(ahd)) {
+				/*
+				 * Potentially lost SEQINT.
+				 * If SEQINTCODE is non-zero,
+				 * simulate the SEQINT.
+				 */
+				if (ahd_inb(ahd, SEQINTCODE) != NO_SEQINT)
+					intstat |= SEQINT;
+			}
+		} else {
+			ahd_flush_device_writes(ahd);
+		}
+		ahd_run_qoutfifo(ahd);
+		ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket]++;
+		ahd->cmdcmplt_total++;
+#ifdef AHD_TARGET_MODE
+		if ((ahd->flags & AHD_TARGETROLE) != 0)
+			ahd_run_tqinfifo(ahd, /*paused*/FALSE);
+#endif
+	}
+
+	/*
+	 * Handle statuses that may invalidate our cached
+	 * copy of INTSTAT separately.
+	 */
+	if (intstat == 0xFF && (ahd->features & AHD_REMOVABLE) != 0) {
+		/* Hot eject.  Do nothing */
+	} else if (intstat & HWERRINT) {
+		ahd_handle_hwerrint(ahd);
+	} else if ((intstat & (PCIINT|SPLTINT)) != 0) {
+		ahd->bus_intr(ahd);
+	} else {
+
+		if ((intstat & SEQINT) != 0)
+			ahd_handle_seqint(ahd, intstat);
+
+		if ((intstat & SCSIINT) != 0)
+			ahd_handle_scsiint(ahd, intstat);
+	}
+	return (1);
+}
+
+#endif  /* _AIC79XX_INLINE_H_ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic79xx_osm.c linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx_osm.c
--- linux-2.4.21/drivers/scsi/aic7xxx/aic79xx_osm.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx_osm.c	2003-06-26 21:43:11.000000000 +0000
@@ -0,0 +1,5129 @@
+/*
+ * Adaptec AIC79xx device driver for Linux.
+ *
+ * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#169 $
+ *
+ * --------------------------------------------------------------------------
+ * Copyright (c) 1994-2000 Justin T. Gibbs.
+ * Copyright (c) 1997-1999 Doug Ledford
+ * Copyright (c) 2000-2003 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.
+ */
+
+#include "aic79xx_osm.h"
+#include "aic79xx_inline.h"
+#include <scsi/scsicam.h>
+
+/*
+ * Include aiclib.c as part of our
+ * "module dependencies are hard" work around.
+ */
+#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 */
+#endif
+
+#include <linux/mm.h>		/* For fetching system memory size */
+
+/*
+ * Lock protecting manipulation of the ahd softc list.
+ */
+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;
+#endif
+
+/*
+ * Bucket size for counting good commands in between bad ones.
+ */
+#define AHD_LINUX_ERR_THRESH	1000
+
+/*
+ * Set this to the delay in seconds after SCSI bus reset.
+ * Note, we honor this only for the initial bus reset.
+ * The scsi error recovery code performs its own bus settle
+ * delay handling for error recovery actions.
+ */
+#ifdef CONFIG_AIC79XX_RESET_DELAY_MS
+#define AIC79XX_RESET_DELAY CONFIG_AIC79XX_RESET_DELAY_MS
+#else
+#define AIC79XX_RESET_DELAY 5000
+#endif
+
+/*
+ * To change the default number of tagged transactions allowed per-device,
+ * add a line to the lilo.conf file like:
+ * append="aic79xx=verbose,tag_info:{{32,32,32,32},{32,32,32,32}}"
+ * which will result in the first four devices on the first two
+ * controllers being set to a tagged queue depth of 32.
+ *
+ * The tag_commands is an array of 16 to allow for wide and twin adapters.
+ * Twin adapters will use indexes 0-7 for channel 0, and indexes 8-15
+ * for channel 1.
+ */
+typedef struct {
+	uint16_t tag_commands[16];	/* Allow for wide/twin adapters. */
+} adapter_tag_info_t;
+
+/*
+ * Modify this as you see fit for your system.
+ *
+ * 0			tagged queuing disabled
+ * 1 <= n <= 253	n == max tags ever dispatched.
+ *
+ * The driver will throttle the number of commands dispatched to a
+ * device if it returns queue full.  For devices with a fixed maximum
+ * queue depth, the driver will eventually determine this depth and
+ * lock it in (a console message is printed to indicate that a lock
+ * has occurred).  On some devices, queue full is returned for a temporary
+ * resource shortage.  These devices will return queue full at varying
+ * depths.  The driver will throttle back when the queue fulls occur and
+ * attempt to slowly increase the depth over time as the device recovers
+ * from the resource shortage.
+ *
+ * In this example, the first line will disable tagged queueing for all
+ * the devices on the first probed aic79xx adapter.
+ *
+ * The second line enables tagged queueing with 4 commands/LUN for IDs
+ * (0, 2-11, 13-15), disables tagged queueing for ID 12, and tells the
+ * driver to attempt to use up to 64 tags for ID 1.
+ *
+ * The third line is the same as the first line.
+ *
+ * The fourth line disables tagged queueing for devices 0 and 3.  It
+ * enables tagged queueing for the other IDs, with 16 commands/LUN
+ * for IDs 1 and 4, 127 commands/LUN for ID 8, and 4 commands/LUN for
+ * IDs 2, 5-7, and 9-15.
+ */
+
+/*
+ * NOTE: The below structure is for reference only, the actual structure
+ *       to modify in order to change things is just below this comment block.
+adapter_tag_info_t aic79xx_tag_info[] =
+{
+	{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
+	{{4, 64, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 4, 4, 4}},
+	{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
+	{{0, 16, 4, 0, 16, 4, 4, 4, 127, 4, 4, 4, 4, 4, 4, 4}}
+};
+*/
+
+#ifdef CONFIG_AIC79XX_CMDS_PER_DEVICE
+#define AIC79XX_CMDS_PER_DEVICE CONFIG_AIC79XX_CMDS_PER_DEVICE
+#else
+#define AIC79XX_CMDS_PER_DEVICE AHD_MAX_QUEUE
+#endif
+
+#define AIC79XX_CONFIGED_TAG_COMMANDS {					\
+	AIC79XX_CMDS_PER_DEVICE, AIC79XX_CMDS_PER_DEVICE,		\
+	AIC79XX_CMDS_PER_DEVICE, AIC79XX_CMDS_PER_DEVICE,		\
+	AIC79XX_CMDS_PER_DEVICE, AIC79XX_CMDS_PER_DEVICE,		\
+	AIC79XX_CMDS_PER_DEVICE, AIC79XX_CMDS_PER_DEVICE,		\
+	AIC79XX_CMDS_PER_DEVICE, AIC79XX_CMDS_PER_DEVICE,		\
+	AIC79XX_CMDS_PER_DEVICE, AIC79XX_CMDS_PER_DEVICE,		\
+	AIC79XX_CMDS_PER_DEVICE, AIC79XX_CMDS_PER_DEVICE,		\
+	AIC79XX_CMDS_PER_DEVICE, AIC79XX_CMDS_PER_DEVICE		\
+}
+
+/*
+ * By default, use the number of commands specified by
+ * the users kernel configuration.
+ */
+static adapter_tag_info_t aic79xx_tag_info[] =
+{
+	{AIC79XX_CONFIGED_TAG_COMMANDS},
+	{AIC79XX_CONFIGED_TAG_COMMANDS},
+	{AIC79XX_CONFIGED_TAG_COMMANDS},
+	{AIC79XX_CONFIGED_TAG_COMMANDS},
+	{AIC79XX_CONFIGED_TAG_COMMANDS},
+	{AIC79XX_CONFIGED_TAG_COMMANDS},
+	{AIC79XX_CONFIGED_TAG_COMMANDS},
+	{AIC79XX_CONFIGED_TAG_COMMANDS},
+	{AIC79XX_CONFIGED_TAG_COMMANDS},
+	{AIC79XX_CONFIGED_TAG_COMMANDS},
+	{AIC79XX_CONFIGED_TAG_COMMANDS},
+	{AIC79XX_CONFIGED_TAG_COMMANDS},
+	{AIC79XX_CONFIGED_TAG_COMMANDS},
+	{AIC79XX_CONFIGED_TAG_COMMANDS},
+	{AIC79XX_CONFIGED_TAG_COMMANDS},
+	{AIC79XX_CONFIGED_TAG_COMMANDS}
+};
+
+/*
+ * By default, read streaming is disabled.  In theory,
+ * read streaming should enhance performance, but early
+ * U320 drive firmware actually performs slower with
+ * read streaming enabled.
+ */
+#ifdef CONFIG_AIC79XX_ENABLE_RD_STRM
+#define AIC79XX_CONFIGED_RD_STRM 0xFFFF
+#else
+#define AIC79XX_CONFIGED_RD_STRM 0
+#endif
+
+static uint16_t aic79xx_rd_strm_info[] =
+{
+	AIC79XX_CONFIGED_RD_STRM,
+	AIC79XX_CONFIGED_RD_STRM,
+	AIC79XX_CONFIGED_RD_STRM,
+	AIC79XX_CONFIGED_RD_STRM,
+	AIC79XX_CONFIGED_RD_STRM,
+	AIC79XX_CONFIGED_RD_STRM,
+	AIC79XX_CONFIGED_RD_STRM,
+	AIC79XX_CONFIGED_RD_STRM,
+	AIC79XX_CONFIGED_RD_STRM,
+	AIC79XX_CONFIGED_RD_STRM,
+	AIC79XX_CONFIGED_RD_STRM,
+	AIC79XX_CONFIGED_RD_STRM,
+	AIC79XX_CONFIGED_RD_STRM,
+	AIC79XX_CONFIGED_RD_STRM,
+	AIC79XX_CONFIGED_RD_STRM,
+	AIC79XX_CONFIGED_RD_STRM
+};
+
+/*
+ * DV option:
+ *
+ * positive value = DV Enabled
+ * zero		  = DV Disabled
+ * negative value = DV Default for adapter type/seeprom
+ */
+#ifdef CONFIG_AIC79XX_DV_SETTING
+#define AIC79XX_CONFIGED_DV CONFIG_AIC79XX_DV_SETTING
+#else
+#define AIC79XX_CONFIGED_DV -1
+#endif
+
+static int8_t aic79xx_dv_settings[] =
+{
+	AIC79XX_CONFIGED_DV,
+	AIC79XX_CONFIGED_DV,
+	AIC79XX_CONFIGED_DV,
+	AIC79XX_CONFIGED_DV,
+	AIC79XX_CONFIGED_DV,
+	AIC79XX_CONFIGED_DV,
+	AIC79XX_CONFIGED_DV,
+	AIC79XX_CONFIGED_DV,
+	AIC79XX_CONFIGED_DV,
+	AIC79XX_CONFIGED_DV,
+	AIC79XX_CONFIGED_DV,
+	AIC79XX_CONFIGED_DV,
+	AIC79XX_CONFIGED_DV,
+	AIC79XX_CONFIGED_DV,
+	AIC79XX_CONFIGED_DV,
+	AIC79XX_CONFIGED_DV
+};
+
+/*
+ * The I/O cell on the chip is very configurable in respect to its analog
+ * characteristics.  Set the defaults here; they can be overriden with
+ * the proper insmod parameters.
+ */
+struct ahd_linux_iocell_opts
+{
+	uint8_t	precomp;
+	uint8_t	slewrate;
+	uint8_t amplitude;
+};
+#define AIC79XX_DEFAULT_PRECOMP		0xFF
+#define AIC79XX_DEFAULT_SLEWRATE	0xFF
+#define AIC79XX_DEFAULT_AMPLITUDE	0xFF
+#define AIC79XX_DEFAULT_IOOPTS			\
+{						\
+	AIC79XX_DEFAULT_PRECOMP,		\
+	AIC79XX_DEFAULT_SLEWRATE,		\
+	AIC79XX_DEFAULT_AMPLITUDE		\
+}
+#define AIC79XX_PRECOMP_INDEX	0
+#define AIC79XX_SLEWRATE_INDEX	1
+#define AIC79XX_AMPLITUDE_INDEX	2
+static struct ahd_linux_iocell_opts aic79xx_iocell_info[] =
+{
+	AIC79XX_DEFAULT_IOOPTS,
+	AIC79XX_DEFAULT_IOOPTS,
+	AIC79XX_DEFAULT_IOOPTS,
+	AIC79XX_DEFAULT_IOOPTS,
+	AIC79XX_DEFAULT_IOOPTS,
+	AIC79XX_DEFAULT_IOOPTS,
+	AIC79XX_DEFAULT_IOOPTS,
+	AIC79XX_DEFAULT_IOOPTS,
+	AIC79XX_DEFAULT_IOOPTS,
+	AIC79XX_DEFAULT_IOOPTS,
+	AIC79XX_DEFAULT_IOOPTS,
+	AIC79XX_DEFAULT_IOOPTS,
+	AIC79XX_DEFAULT_IOOPTS,
+	AIC79XX_DEFAULT_IOOPTS,
+	AIC79XX_DEFAULT_IOOPTS,
+	AIC79XX_DEFAULT_IOOPTS
+};
+
+/*
+ * There should be a specific return value for this in scsi.h, but
+ * it seems that most drivers ignore it.
+ */
+#define DID_UNDERFLOW   DID_ERROR
+
+void
+ahd_print_path(struct ahd_softc *ahd, struct scb *scb)
+{
+	printk("(scsi%d:%c:%d:%d): ",
+	       ahd->platform_data->host->host_no,
+	       scb != NULL ? SCB_GET_CHANNEL(ahd, scb) : 'X',
+	       scb != NULL ? SCB_GET_TARGET(ahd, scb) : -1,
+	       scb != NULL ? SCB_GET_LUN(scb) : -1);
+}
+
+/*
+ * XXX - these options apply unilaterally to _all_ adapters
+ *       cards in the system.  This should be fixed.  Exceptions to this
+ *       rule are noted in the comments.
+ */
+
+/*
+ * Skip the scsi bus reset.  Non 0 make us skip the reset at startup.  This
+ * has no effect on any later resets that might occur due to things like
+ * SCSI bus timeouts.
+ */
+static uint32_t aic79xx_no_reset;
+
+/*
+ * Certain PCI motherboards will scan PCI devices from highest to lowest,
+ * others scan from lowest to highest, and they tend to do all kinds of
+ * strange things when they come into contact with PCI bridge chips.  The
+ * net result of all this is that the PCI card that is actually used to boot
+ * the machine is very hard to detect.  Most motherboards go from lowest
+ * PCI slot number to highest, and the first SCSI controller found is the
+ * one you boot from.  The only exceptions to this are when a controller
+ * has its BIOS disabled.  So, we by default sort all of our SCSI controllers
+ * from lowest PCI slot number to highest PCI slot number.  We also force
+ * all controllers with their BIOS disabled to the end of the list.  This
+ * works on *almost* all computers.  Where it doesn't work, we have this
+ * option.  Setting this option to non-0 will reverse the order of the sort
+ * to highest first, then lowest, but will still leave cards with their BIOS
+ * disabled at the very end.  That should fix everyone up unless there are
+ * really strange cirumstances.
+ */
+static uint32_t aic79xx_reverse_scan;
+
+/*
+ * Should we force EXTENDED translation on a controller.
+ *     0 == Use whatever is in the SEEPROM or default to off
+ *     1 == Use whatever is in the SEEPROM or default to on
+ */
+static uint32_t aic79xx_extended;
+
+/*
+ * PCI bus parity checking of the Adaptec controllers.  This is somewhat
+ * dubious at best.  To my knowledge, this option has never actually
+ * solved a PCI parity problem, but on certain machines with broken PCI
+ * chipset configurations, it can generate tons of false error messages.
+ * It's included in the driver for completeness.
+ *   0	   = Shut off PCI parity check
+ *   non-0 = Enable PCI parity check
+ *
+ * NOTE: you can't actually pass -1 on the lilo prompt.  So, to set this
+ * variable to -1 you would actually want to simply pass the variable
+ * name without a number.  That will invert the 0 which will result in
+ * -1.
+ */
+static uint32_t aic79xx_pci_parity = ~0;
+
+/*
+ * There are lots of broken chipsets in the world.  Some of them will
+ * violate the PCI spec when we issue byte sized memory writes to our
+ * controller.  I/O mapped register access, if allowed by the given
+ * platform, will work in almost all cases.
+ */
+uint32_t aic79xx_allow_memio = ~0;
+
+/*
+ * aic79xx_detect() has been run, so register all device arrivals
+ * immediately with the system rather than deferring to the sorted
+ * attachment performed by aic79xx_detect().
+ */
+int aic79xx_detect_complete;
+
+/*
+ * So that we can set how long each device is given as a selection timeout.
+ * The table of values goes like this:
+ *   0 - 256ms
+ *   1 - 128ms
+ *   2 - 64ms
+ *   3 - 32ms
+ * We default to 256ms because some older devices need a longer time
+ * to respond to initial selection.
+ */
+static uint32_t aic79xx_seltime;
+
+/*
+ * Certain devices do not perform any aging on commands.  Should the
+ * device be saturated by commands in one portion of the disk, it is
+ * possible for transactions on far away sectors to never be serviced.
+ * To handle these devices, we can periodically send an ordered tag to
+ * force all outstanding transactions to be serviced prior to a new
+ * transaction.
+ */
+uint32_t aic79xx_periodic_otag;
+
+/*
+ * Module information and settable options.
+ */
+#ifdef MODULE
+static char *aic79xx = NULL;
+/*
+ * Just in case someone uses commas to separate items on the insmod
+ * command line, we define a dummy buffer here to avoid having insmod
+ * write wild stuff into our code segment
+ */
+static char dummy_buffer[60] = "Please don't trounce on me insmod!!\n";
+
+MODULE_AUTHOR("Maintainer: Justin T. Gibbs <gibbs@scsiguy.com>");
+MODULE_DESCRIPTION("Adaptec Aic77XX/78XX SCSI Host Bus Adapter driver");
+#ifdef MODULE_LICENSE
+MODULE_LICENSE("Dual BSD/GPL");
+#endif
+MODULE_PARM(aic79xx, "s");
+MODULE_PARM_DESC(aic79xx,
+"period delimited, options string.\n"
+"	verbose			Enable verbose/diagnostic logging\n"
+"	allow_memio		Allow device registers to be memory mapped\n"
+"	debug			Bitmask of debug values to enable\n"
+"	no_reset		Supress initial bus resets\n"
+"	extended		Enable extended geometry on all controllers\n"
+"	periodic_otag		Send an ordered tagged transaction\n"
+"				periodically to prevent tag starvation.\n"
+"				This may be required by some older disk\n"
+"				or drives/RAID arrays.\n"
+"	reverse_scan		Sort PCI devices highest Bus/Slot to lowest\n"
+"	tag_info:<tag_str>	Set per-target tag depth\n"
+"	global_tag_depth:<int>	Global tag depth for all targets on all buses\n"
+"	rd_strm:<rd_strm_masks> Set per-target read streaming setting.\n"
+"	dv:<dv_settings>	Set per-controller Domain Validation Setting.\n"
+"	slewrate:<slewrate_list>Set the signal slew rate (0-15).\n"
+"	precomp:<pcomp_list>	Set the signal precompensation (0-7).\n"
+"	amplitude:<int>		Set the signal amplitude (0-7).\n"
+"	seltime:<int>		Selection Timeout:\n"
+"				(0/256ms,1/128ms,2/64ms,3/32ms)\n"
+"\n"
+"	Sample /etc/modules.conf line:\n"
+"		Enable verbose logging\n"
+"		Set tag depth on Controller 2/Target 2 to 10 tags\n"
+"		Shorten the selection timeout to 128ms\n"
+"\n"
+"	options aic79xx 'aic79xx=verbose.tag_info:{{}.{}.{..10}}.seltime:1'\n"
+"\n"
+"	Sample /etc/modules.conf line:\n"
+"		Change Read Streaming for Controller's 2 and 3\n"
+"\n"
+"	options aic79xx 'aic79xx=rd_strm:{..0xFFF0.0xC0F0}'");
+#endif
+
+static void ahd_linux_handle_scsi_status(struct ahd_softc *,
+					 struct ahd_linux_device *,
+					 struct scb *);
+static void ahd_linux_queue_cmd_complete(struct ahd_softc *ahd,
+					 Scsi_Cmnd *cmd);
+static void ahd_linux_filter_inquiry(struct ahd_softc *ahd,
+				     struct ahd_devinfo *devinfo);
+static void ahd_linux_dev_timed_unfreeze(u_long arg);
+static void ahd_linux_sem_timeout(u_long arg);
+static void ahd_linux_initialize_scsi_bus(struct ahd_softc *ahd);
+static void ahd_linux_size_nseg(void);
+static void ahd_linux_thread_run_complete_queue(struct ahd_softc *ahd);
+static void ahd_linux_start_dv(struct ahd_softc *ahd);
+static void ahd_linux_dv_timeout(struct scsi_cmnd *cmd);
+static int  ahd_linux_dv_thread(void *data);
+static void ahd_linux_kill_dv_thread(struct ahd_softc *ahd);
+static void ahd_linux_dv_target(struct ahd_softc *ahd, u_int target);
+static void ahd_linux_dv_transition(struct ahd_softc *ahd,
+				    struct scsi_cmnd *cmd,
+				    struct ahd_devinfo *devinfo,
+				    struct ahd_linux_target *targ);
+static void ahd_linux_dv_fill_cmd(struct ahd_softc *ahd,
+				  struct scsi_cmnd *cmd,
+				  struct ahd_devinfo *devinfo);
+static void ahd_linux_dv_inq(struct ahd_softc *ahd,
+			     struct scsi_cmnd *cmd,
+			     struct ahd_devinfo *devinfo,
+			     struct ahd_linux_target *targ,
+			     u_int request_length);
+static void ahd_linux_dv_tur(struct ahd_softc *ahd,
+			     struct scsi_cmnd *cmd,
+			     struct ahd_devinfo *devinfo);
+static void ahd_linux_dv_rebd(struct ahd_softc *ahd,
+			      struct scsi_cmnd *cmd,
+			      struct ahd_devinfo *devinfo,
+			      struct ahd_linux_target *targ);
+static void ahd_linux_dv_web(struct ahd_softc *ahd,
+			     struct scsi_cmnd *cmd,
+			     struct ahd_devinfo *devinfo,
+			     struct ahd_linux_target *targ);
+static void ahd_linux_dv_reb(struct ahd_softc *ahd,
+			     struct scsi_cmnd *cmd,
+			     struct ahd_devinfo *devinfo,
+			     struct ahd_linux_target *targ);
+static void ahd_linux_dv_su(struct ahd_softc *ahd,
+			    struct scsi_cmnd *cmd,
+			    struct ahd_devinfo *devinfo,
+			    struct ahd_linux_target *targ);
+static __inline int
+	   ahd_linux_dv_fallback(struct ahd_softc *ahd,
+				 struct ahd_devinfo *devinfo);
+static int ahd_linux_fallback(struct ahd_softc *ahd,
+			      struct ahd_devinfo *devinfo);
+static __inline int ahd_linux_dv_fallback(struct ahd_softc *ahd,
+					  struct ahd_devinfo *devinfo);
+static void ahd_linux_dv_complete(Scsi_Cmnd *cmd);
+static void ahd_linux_generate_dv_pattern(struct ahd_linux_target *targ);
+static u_int ahd_linux_user_tagdepth(struct ahd_softc *ahd,
+				     struct ahd_devinfo *devinfo);
+static u_int ahd_linux_user_dv_setting(struct ahd_softc *ahd);
+static void ahd_linux_setup_user_rd_strm_settings(struct ahd_softc *ahd);
+static void ahd_linux_device_queue_depth(struct ahd_softc *ahd,
+					 struct ahd_linux_device *dev);
+static struct ahd_linux_target*	ahd_linux_alloc_target(struct ahd_softc*,
+						       u_int, u_int);
+static void			ahd_linux_free_target(struct ahd_softc*,
+						      struct ahd_linux_target*);
+static struct ahd_linux_device*	ahd_linux_alloc_device(struct ahd_softc*,
+						       struct ahd_linux_target*,
+						       u_int);
+static void			ahd_linux_free_device(struct ahd_softc*,
+						      struct ahd_linux_device*);
+static void ahd_linux_run_device_queue(struct ahd_softc*,
+				       struct ahd_linux_device*);
+static void ahd_linux_setup_tag_info_global(char *p);
+static aic_option_callback_t ahd_linux_setup_tag_info;
+static aic_option_callback_t ahd_linux_setup_rd_strm_info;
+static aic_option_callback_t ahd_linux_setup_dv;
+static aic_option_callback_t ahd_linux_setup_iocell_info;
+static int ahd_linux_next_unit(void);
+static void ahd_runq_tasklet(unsigned long data);
+static int aic79xx_setup(char *c);
+
+/****************************** Inlines ***************************************/
+static __inline void ahd_schedule_completeq(struct ahd_softc *ahd);
+static __inline void ahd_schedule_runq(struct ahd_softc *ahd);
+static __inline void ahd_setup_runq_tasklet(struct ahd_softc *ahd);
+static __inline void ahd_teardown_runq_tasklet(struct ahd_softc *ahd);
+static __inline struct ahd_linux_device*
+		     ahd_linux_get_device(struct ahd_softc *ahd, u_int channel,
+					  u_int target, u_int lun, int alloc);
+static struct ahd_cmd *ahd_linux_run_complete_queue(struct ahd_softc *ahd);
+static __inline void ahd_linux_check_device_queue(struct ahd_softc *ahd,
+						  struct ahd_linux_device *dev);
+static __inline struct ahd_linux_device *
+		     ahd_linux_next_device_to_run(struct ahd_softc *ahd);
+static __inline void ahd_linux_run_device_queues(struct ahd_softc *ahd);
+static __inline void ahd_linux_unmap_scb(struct ahd_softc*, struct scb*);
+
+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);
+
+static __inline void
+ahd_schedule_completeq(struct ahd_softc *ahd)
+{
+	if ((ahd->platform_data->flags & AHD_RUN_CMPLT_Q_TIMER) == 0) {
+		ahd->platform_data->flags |= AHD_RUN_CMPLT_Q_TIMER;
+		ahd->platform_data->completeq_timer.expires = jiffies;
+		add_timer(&ahd->platform_data->completeq_timer);
+	}
+}
+
+/*
+ * Must be called with our lock held.
+ */
+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*
+ahd_linux_get_device(struct ahd_softc *ahd, u_int channel, u_int target,
+		     u_int lun, int alloc)
+{
+	struct ahd_linux_target *targ;
+	struct ahd_linux_device *dev;
+	u_int target_offset;
+
+	target_offset = target;
+	if (channel != 0)
+		target_offset += 8;
+	targ = ahd->platform_data->targets[target_offset];
+	if (targ == NULL) {
+		if (alloc != 0) {
+			targ = ahd_linux_alloc_target(ahd, channel, target);
+			if (targ == NULL)
+				return (NULL);
+		} else
+			return (NULL);
+	}
+	dev = targ->devices[lun];
+	if (dev == NULL && alloc != 0)
+		dev = ahd_linux_alloc_device(ahd, targ, lun);
+	return (dev);
+}
+
+#define AHD_LINUX_MAX_RETURNED_ERRORS 4
+static struct ahd_cmd *
+ahd_linux_run_complete_queue(struct ahd_softc *ahd)
+{	
+	struct	ahd_cmd *acmd;
+	u_long	done_flags;
+	int	with_errors;
+
+	with_errors = 0;
+	ahd_done_lock(ahd, &done_flags);
+	while ((acmd = TAILQ_FIRST(&ahd->platform_data->completeq)) != NULL) {
+		Scsi_Cmnd *cmd;
+
+		if (with_errors > AHD_LINUX_MAX_RETURNED_ERRORS) {
+			/*
+			 * Linux uses stack recursion to requeue
+			 * commands that need to be retried.  Avoid
+			 * blowing out the stack by "spoon feeding"
+			 * commands that completed with error back
+			 * the operating system in case they are going
+			 * to be retried. "ick"
+			 */
+			ahd_schedule_completeq(ahd);
+			break;
+		}
+		TAILQ_REMOVE(&ahd->platform_data->completeq,
+			     acmd, acmd_links.tqe);
+		cmd = &acmd_scsi_cmd(acmd);
+		cmd->host_scribble = NULL;
+		if (ahd_cmd_get_transaction_status(cmd) != DID_OK
+		 || (cmd->result & 0xFF) != SCSI_STATUS_OK)
+			with_errors++;
+
+		cmd->scsi_done(cmd);
+	}
+	ahd_done_unlock(ahd, &done_flags);
+	return (acmd);
+}
+
+static __inline void
+ahd_linux_check_device_queue(struct ahd_softc *ahd,
+			     struct ahd_linux_device *dev)
+{
+	if ((dev->flags & AHD_DEV_FREEZE_TIL_EMPTY) != 0
+	 && dev->active == 0) {
+		dev->flags &= ~AHD_DEV_FREEZE_TIL_EMPTY;
+		dev->qfrozen--;
+	}
+
+	if (TAILQ_FIRST(&dev->busyq) == NULL
+	 || dev->openings == 0 || dev->qfrozen != 0)
+		return;
+
+	ahd_linux_run_device_queue(ahd, dev);
+}
+
+static __inline struct ahd_linux_device *
+ahd_linux_next_device_to_run(struct ahd_softc *ahd)
+{
+	
+	if ((ahd->flags & AHD_RESOURCE_SHORTAGE) != 0
+	 || (ahd->platform_data->qfrozen != 0
+	  && AHD_DV_SIMQ_FROZEN(ahd) == 0))
+		return (NULL);
+	return (TAILQ_FIRST(&ahd->platform_data->device_runq));
+}
+
+static __inline void
+ahd_linux_run_device_queues(struct ahd_softc *ahd)
+{
+	struct ahd_linux_device *dev;
+
+	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);
+	}
+}
+
+static __inline void
+ahd_linux_unmap_scb(struct ahd_softc *ahd, struct scb *scb)
+{
+	Scsi_Cmnd *cmd;
+	int direction;
+
+	cmd = scb->io_ctx;
+	direction = scsi_to_pci_dma_dir(cmd->sc_data_direction);
+	ahd_sync_sglist(ahd, scb, BUS_DMASYNC_POSTWRITE);
+	if (cmd->use_sg != 0) {
+		struct scatterlist *sg;
+
+		sg = (struct scatterlist *)cmd->request_buffer;
+		pci_unmap_sg(ahd->dev_softc, sg, cmd->use_sg, direction);
+	} else if (cmd->request_bufflen != 0) {
+		pci_unmap_single(ahd->dev_softc,
+				 scb->platform_data->buf_busaddr,
+				 cmd->request_bufflen, direction);
+	}
+}
+
+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)
+{
+	int	 consumed;
+
+	if ((scb->sg_count + 1) > AHD_NSEG)
+		panic("Too few segs for dma mapping.  "
+		      "Increase AHD_NSEG\n");
+
+	consumed = 1;
+	sg->addr = ahd_htole32(addr & 0xFFFFFFFF);
+	scb->platform_data->xfer_len += len;
+
+	if (sizeof(bus_addr_t) > 4
+	 && (ahd->flags & AHD_39BIT_ADDRESSING) != 0)
+		len |= (addr >> 8) & AHD_SG_HIGH_ADDR_MASK;
+
+	sg->len = ahd_htole32(len);
+	return (consumed);
+}
+
+/******************************** Macros **************************************/
+#define BUILD_SCSIID(ahd, cmd)						\
+	((((cmd)->device->id << TID_SHIFT) & TID) | (ahd)->our_id)
+
+/************************  Host template entry points *************************/
+static int	   ahd_linux_detect(Scsi_Host_Template *);
+static const char *ahd_linux_info(struct Scsi_Host *);
+static int	   ahd_linux_queue(Scsi_Cmnd *, void (*)(Scsi_Cmnd *));
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+static int	   ahd_linux_slave_alloc(Scsi_Device *);
+static int	   ahd_linux_slave_configure(Scsi_Device *);
+static void	   ahd_linux_slave_destroy(Scsi_Device *);
+#if defined(__i386__)
+static int	   ahd_linux_biosparam(struct scsi_device*,
+				       struct block_device*, sector_t, int[]);
+#endif
+#else
+static int	   ahd_linux_release(struct Scsi_Host *);
+static void	   ahd_linux_select_queue_depth(struct Scsi_Host *host,
+						Scsi_Device *scsi_devs);
+#if defined(__i386__)
+static int	   ahd_linux_biosparam(Disk *, kdev_t, int[]);
+#endif
+#endif
+static int	   ahd_linux_bus_reset(Scsi_Cmnd *);
+static int	   ahd_linux_dev_reset(Scsi_Cmnd *);
+static int	   ahd_linux_abort(Scsi_Cmnd *);
+
+/*
+ * Calculate a safe value for AHD_NSEG (as expressed through ahd_linux_nseg).
+ *
+ * In pre-2.5.X...
+ * The midlayer allocates an S/G array dynamically when a command is issued
+ * using SCSI malloc.  This array, which is in an OS dependent format that
+ * must later be copied to our private S/G list, is sized to house just the
+ * number of segments needed for the current transfer.  Since the code that
+ * sizes the SCSI malloc pool does not take into consideration fragmentation
+ * of the pool, executing transactions numbering just a fraction of our
+ * concurrent transaction limit with SG list lengths aproaching AHC_NSEG will
+ * quickly depleat the SCSI malloc pool of usable space.  Unfortunately, the
+ * mid-layer does not properly handle this scsi malloc failures for the S/G
+ * array and the result can be a lockup of the I/O subsystem.  We try to size
+ * our S/G list so that it satisfies our drivers allocation requirements in
+ * addition to avoiding fragmentation of the SCSI malloc pool.
+ */
+static void
+ahd_linux_size_nseg(void)
+{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+	u_int cur_size;
+	u_int best_size;
+
+	/*
+	 * The SCSI allocator rounds to the nearest 512 bytes
+	 * an cannot allocate across a page boundary.  Our algorithm
+	 * is to start at 1K of scsi malloc space per-command and
+	 * loop through all factors of the PAGE_SIZE and pick the best.
+	 */
+	best_size = 0;
+	for (cur_size = 1024; cur_size <= PAGE_SIZE; cur_size *= 2) {
+		u_int nseg;
+
+		nseg = cur_size / sizeof(struct scatterlist);
+		if (nseg < AHD_LINUX_MIN_NSEG)
+			continue;
+
+		if (best_size == 0) {
+			best_size = cur_size;
+			ahd_linux_nseg = nseg;
+		} else {
+			u_int best_rem;
+			u_int cur_rem;
+
+			/*
+			 * Compare the traits of the current "best_size"
+			 * with the current size to determine if the
+			 * current size is a better size.
+			 */
+			best_rem = best_size % sizeof(struct scatterlist);
+			cur_rem = cur_size % sizeof(struct scatterlist);
+			if (cur_rem < best_rem) {
+				best_size = cur_size;
+				ahd_linux_nseg = nseg;
+			}
+		}
+	}
+#endif
+}
+
+/*
+ * Try to detect an Adaptec 79XX controller.
+ */
+static int
+ahd_linux_detect(Scsi_Host_Template *template)
+{
+	struct	ahd_softc *ahd;
+	int     found;
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+	/*
+	 * It is a bug that the upper layer takes
+	 * this lock just prior to calling us.
+	 */
+	spin_unlock_irq(&io_request_lock);
+#endif
+
+	/*
+	 * Sanity checking of Linux SCSI data structures so
+	 * that some of our hacks^H^H^H^H^Hassumptions aren't
+	 * violated.
+	 */
+	if (offsetof(struct ahd_cmd_internal, end)
+	  > offsetof(struct scsi_cmnd, host_scribble)) {
+		printf("ahd_linux_detect: SCSI data structures changed.\n");
+		printf("ahd_linux_detect: Unable to attach\n");
+		return (0);
+	}
+	/*
+	 * Determine an appropriate size for our Scatter Gatther lists.
+	 */
+	ahd_linux_size_nseg();
+#ifdef MODULE
+	/*
+	 * If we've been passed any parameters, process them now.
+	 */
+	if (aic79xx)
+		aic79xx_setup(aic79xx);
+	if (dummy_buffer[0] != 'P')
+		printk(KERN_WARNING
+"aic79xx: Please read the file /usr/src/linux/drivers/scsi/README.aic79xx\n"
+"aic79xx: to see the proper way to specify options to the aic79xx module\n"
+"aic79xx: Specifically, don't use any commas when passing arguments to\n"
+"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
+	 * probing for any adapters.
+	 */
+	ahd_list_lockinit();
+
+#ifdef CONFIG_PCI
+	ahd_linux_pci_init();
+#endif
+
+	/*
+	 * Register with the SCSI layer all
+	 * controllers we've found.
+	 */
+	found = 0;
+	TAILQ_FOREACH(ahd, &ahd_tailq, links) {
+
+		if (ahd_linux_register_host(ahd, template) == 0)
+			found++;
+	}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+	spin_lock_irq(&io_request_lock);
+#endif
+	aic79xx_detect_complete++;
+	return (found);
+}
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+/*
+ * Free the passed in Scsi_Host memory structures prior to unloading the
+ * module.
+ */
+static int
+ahd_linux_release(struct Scsi_Host * host)
+{
+	struct ahd_softc *ahd;
+	u_long l;
+
+	ahd_list_lock(&l);
+	if (host != NULL) {
+
+		/*
+		 * We should be able to just perform
+		 * the free directly, but check our
+		 * list for extra sanity.
+		 */
+		ahd = ahd_find_softc(*(struct ahd_softc **)host->hostdata);
+		if (ahd != NULL) {
+			u_long s;
+
+			ahd_lock(ahd, &s);
+			ahd_intr_enable(ahd, FALSE);
+			ahd_unlock(ahd, &s);
+			ahd_free(ahd);
+		}
+	}
+	ahd_list_unlock(&l);
+	return (0);
+}
+#endif
+
+/*
+ * Return a string describing the driver.
+ */
+static const char *
+ahd_linux_info(struct Scsi_Host *host)
+{
+	static char buffer[512];
+	char	ahd_info[256];
+	char   *bp;
+	struct ahd_softc *ahd;
+
+	bp = &buffer[0];
+	ahd = *(struct ahd_softc **)host->hostdata;
+	memset(bp, 0, sizeof(buffer));
+	strcpy(bp, "Adaptec AIC79XX PCI-X SCSI HBA DRIVER, Rev ");
+	strcat(bp, AIC79XX_DRIVER_VERSION);
+	strcat(bp, "\n");
+	strcat(bp, "        <");
+	strcat(bp, ahd->description);
+	strcat(bp, ">\n");
+	strcat(bp, "        ");
+	ahd_controller_info(ahd, ahd_info);
+	strcat(bp, ahd_info);
+	strcat(bp, "\n");
+
+	return (bp);
+}
+
+/*
+ * Queue an SCB to the controller.
+ */
+static int
+ahd_linux_queue(Scsi_Cmnd * cmd, void (*scsi_done) (Scsi_Cmnd *))
+{
+	struct	 ahd_softc *ahd;
+	struct	 ahd_linux_device *dev;
+	u_long	 flags;
+
+	ahd = *(struct ahd_softc **)cmd->device->host->hostdata;
+
+	/*
+	 * Save the callback on completion function.
+	 */
+	cmd->scsi_done = scsi_done;
+
+	ahd_midlayer_entrypoint_lock(ahd, &flags);
+
+	/*
+	 * Close the race of a command that was in the process of
+	 * being queued to us just as our simq was frozen.  Let
+	 * DV commands through so long as we are only frozen to
+	 * perform DV.
+	 */
+	if (ahd->platform_data->qfrozen != 0
+	 && AHD_DV_CMD(cmd) == 0) {
+
+		ahd_cmd_set_transaction_status(cmd, CAM_REQUEUE_REQ);
+		ahd_linux_queue_cmd_complete(ahd, cmd);
+		ahd_schedule_completeq(ahd);
+		ahd_midlayer_entrypoint_unlock(ahd, &flags);
+		return (0);
+	}
+	dev = ahd_linux_get_device(ahd, cmd->device->channel,
+				   cmd->device->id, cmd->device->lun,
+				   /*alloc*/TRUE);
+	if (dev == NULL) {
+		ahd_cmd_set_transaction_status(cmd, CAM_RESRC_UNAVAIL);
+		ahd_linux_queue_cmd_complete(ahd, cmd);
+		ahd_schedule_completeq(ahd);
+		ahd_midlayer_entrypoint_unlock(ahd, &flags);
+		printf("%s: aic79xx_linux_queue - Unable to allocate device!\n",
+		       ahd_name(ahd));
+		return (0);
+	}
+	if (cmd->cmd_len > MAX_CDB_LEN)
+		return (-EINVAL);
+	cmd->result = CAM_REQ_INPROG << 16;
+	TAILQ_INSERT_TAIL(&dev->busyq, (struct ahd_cmd *)cmd, acmd_links.tqe);
+	if ((dev->flags & AHD_DEV_ON_RUN_LIST) == 0) {
+		TAILQ_INSERT_TAIL(&ahd->platform_data->device_runq, dev, links);
+		dev->flags |= AHD_DEV_ON_RUN_LIST;
+		ahd_linux_run_device_queues(ahd);
+	}
+	ahd_midlayer_entrypoint_unlock(ahd, &flags);
+	return (0);
+}
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+static int
+ahd_linux_slave_alloc(Scsi_Device *device)
+{
+	struct	ahd_softc *ahd;
+
+	ahd = *((struct ahd_softc **)device->host->hostdata);
+	if (bootverbose)
+		printf("%s: Slave Alloc %d\n", ahd_name(ahd), device->id);
+	return (0);
+}
+
+static int
+ahd_linux_slave_configure(Scsi_Device *device)
+{
+	struct	ahd_softc *ahd;
+	struct	ahd_linux_device *dev;
+	u_long	flags;
+
+	ahd = *((struct ahd_softc **)device->host->hostdata);
+	if (bootverbose)
+		printf("%s: Slave Configure %d\n", ahd_name(ahd), device->id);
+	ahd_midlayer_entrypoint_lock(ahd, &flags);
+	/*
+	 * Since Linux has attached to the device, configure
+	 * it so we don't free and allocate the device
+	 * structure on every command.
+	 */
+	dev = ahd_linux_get_device(ahd, device->channel,
+				   device->id, device->lun,
+				   /*alloc*/TRUE);
+	if (dev != NULL) {
+		dev->flags &= ~AHD_DEV_UNCONFIGURED;
+		dev->flags |= AHD_DEV_SLAVE_CONFIGURED;
+		dev->scsi_device = device;
+		ahd_linux_device_queue_depth(ahd, dev);
+	}
+	ahd_midlayer_entrypoint_unlock(ahd, &flags);
+	return (0);
+}
+
+static void
+ahd_linux_slave_destroy(Scsi_Device *device)
+{
+	struct	ahd_softc *ahd;
+	struct	ahd_linux_device *dev;
+	u_long	flags;
+
+	ahd = *((struct ahd_softc **)device->host->hostdata);
+	if (bootverbose)
+		printf("%s: Slave Destroy %d\n", ahd_name(ahd), device->id);
+	ahd_midlayer_entrypoint_lock(ahd, &flags);
+	dev = ahd_linux_get_device(ahd, device->channel,
+				   device->id, device->lun,
+					   /*alloc*/FALSE);
+
+	/*
+	 * Filter out "silly" deletions of real devices by only
+	 * deleting devices that have had slave_configure()
+	 * called on them.  All other devices that have not
+	 * been configured will automatically be deleted by
+	 * the refcounting process.
+	 */
+	if (dev != NULL
+	 && (dev->flags & AHD_DEV_SLAVE_CONFIGURED) != 0) {
+		dev->flags |= AHD_DEV_UNCONFIGURED;
+		if (TAILQ_EMPTY(&dev->busyq)
+		 && dev->active == 0
+		 && (dev->flags & AHD_DEV_TIMER_ACTIVE) == 0)
+			ahd_linux_free_device(ahd, dev);
+	}
+	ahd_midlayer_entrypoint_unlock(ahd, &flags);
+}
+#else
+/*
+ * Sets the queue depth for each SCSI device hanging
+ * off the input host adapter.
+ */
+static void
+ahd_linux_select_queue_depth(struct Scsi_Host * host,
+			     Scsi_Device * scsi_devs)
+{
+	Scsi_Device *device;
+	Scsi_Device *ldev;
+	struct	ahd_softc *ahd;
+	u_long	flags;
+
+	ahd = *((struct ahd_softc **)host->hostdata);
+	ahd_lock(ahd, &flags);
+	for (device = scsi_devs; device != NULL; device = device->next) {
+
+		/*
+		 * Watch out for duplicate devices.  This works around
+		 * some quirks in how the SCSI scanning code does its
+		 * device management.
+		 */
+		for (ldev = scsi_devs; ldev != device; ldev = ldev->next) {
+			if (ldev->host == device->host
+			 && ldev->channel == device->channel
+			 && ldev->id == device->id
+			 && ldev->lun == device->lun)
+				break;
+		}
+		/* Skip duplicate. */
+		if (ldev != device)
+			continue;
+
+		if (device->host == host) {
+			struct	 ahd_linux_device *dev;
+
+			/*
+			 * Since Linux has attached to the device, configure
+			 * it so we don't free and allocate the device
+			 * structure on every command.
+			 */
+			dev = ahd_linux_get_device(ahd, device->channel,
+						   device->id, device->lun,
+						   /*alloc*/TRUE);
+			if (dev != NULL) {
+				dev->flags &= ~AHD_DEV_UNCONFIGURED;
+				dev->scsi_device = device;
+				ahd_linux_device_queue_depth(ahd, dev);
+				device->queue_depth = dev->openings
+						    + dev->active;
+				if ((dev->flags & (AHD_DEV_Q_BASIC
+						| AHD_DEV_Q_TAGGED)) == 0) {
+					/*
+					 * We allow the OS to queue 2 untagged
+					 * transactions to us at any time even
+					 * though we can only execute them
+					 * serially on the controller/device.
+					 * This should remove some latency.
+					 */
+					device->queue_depth = 2;
+				}
+			}
+		}
+	}
+	ahd_unlock(ahd, &flags);
+}
+#endif
+
+#if defined(__i386__)
+/*
+ * Return the disk geometry for the given SCSI device.
+ */
+static int
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ahd_linux_biosparam(struct scsi_device *sdev, struct block_device *bdev,
+		    sector_t capacity, int geom[])
+{
+	uint8_t *bh;
+#else
+ahd_linux_biosparam(Disk *disk, kdev_t dev, int geom[])
+{
+	struct	scsi_device *sdev = disk->device;
+	u_long	capacity = disk->capacity;
+	struct	buffer_head *bh;
+#endif
+	int	 heads;
+	int	 sectors;
+	int	 cylinders;
+	int	 ret;
+	int	 extended;
+	struct	 ahd_softc *ahd;
+
+	ahd = *((struct ahd_softc **)sdev->host->hostdata);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+	bh = scsi_bios_ptable(bdev);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,17)
+	bh = bread(MKDEV(MAJOR(dev), MINOR(dev) & ~0xf), 0, block_size(dev));
+#else
+	bh = bread(MKDEV(MAJOR(dev), MINOR(dev) & ~0xf), 0, 1024);
+#endif
+
+	if (bh) {
+		ret = scsi_partsize(bh, capacity,
+				    &geom[2], &geom[0], &geom[1]);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+		kfree(bh);
+#else
+		brelse(bh);
+#endif
+		if (ret != -1)
+			return (ret);
+	}
+	heads = 64;
+	sectors = 32;
+	cylinders = aic_sector_div(capacity, heads, sectors);
+
+	if (aic79xx_extended != 0)
+		extended = 1;
+	else
+		extended = (ahd->flags & AHD_EXTENDED_TRANS_A) != 0;
+	if (extended && cylinders >= 1024) {
+		heads = 255;
+		sectors = 63;
+		cylinders = aic_sector_div(capacity, heads, sectors);
+	}
+	geom[0] = heads;
+	geom[1] = sectors;
+	geom[2] = cylinders;
+	return (0);
+}
+#endif
+
+/*
+ * Abort the current SCSI command(s).
+ */
+static int
+ahd_linux_abort(Scsi_Cmnd *cmd)
+{
+	struct ahd_softc *ahd;
+	struct ahd_cmd *acmd;
+	struct ahd_cmd *list_acmd;
+	struct ahd_linux_device *dev;
+	struct scb *pending_scb;
+	u_long s;
+	u_int  saved_scbptr;
+	u_int  active_scbptr;
+	u_int  last_phase;
+	u_int  cdb_byte;
+	int    retval;
+	int    was_paused;
+	int    paused;
+	int    wait;
+	int    disconnected;
+	ahd_mode_state saved_modes;
+
+	pending_scb = NULL;
+	paused = FALSE;
+	wait = FALSE;
+	ahd = *(struct ahd_softc **)cmd->device->host->hostdata;
+	acmd = (struct ahd_cmd *)cmd;
+
+	printf("%s:%d:%d:%d: Attempting to abort cmd %p:",
+	       ahd_name(ahd), cmd->device->channel, cmd->device->id,
+	       cmd->device->lun, cmd);
+	for (cdb_byte = 0; cdb_byte < cmd->cmd_len; cdb_byte++)
+		printf(" 0x%x", cmd->cmnd[cdb_byte]);
+	printf("\n");
+
+	/*
+	 * In all versions of Linux, we have to work around
+	 * a major flaw in how the mid-layer is locked down
+	 * if we are to sleep successfully in our error handler
+	 * while allowing our interrupt handler to run.  Since
+	 * the midlayer acquires either the io_request_lock or
+	 * our lock prior to calling us, we must use the
+	 * spin_unlock_irq() method for unlocking our lock.
+	 * This will force interrupts to be enabled on the
+	 * current CPU.  Since the EH thread should not have
+	 * been running with CPU interrupts disabled other than
+	 * by acquiring either the io_request_lock or our own
+	 * lock, this *should* be safe.
+	 */
+	ahd_midlayer_entrypoint_lock(ahd, &s);
+
+	/*
+	 * First determine if we currently own this command.
+	 * Start by searching the device queue.  If not found
+	 * there, check the pending_scb list.  If not found
+	 * at all, and the system wanted us to just abort the
+	 * command, return success.
+	 */
+	dev = ahd_linux_get_device(ahd, cmd->device->channel,
+				   cmd->device->id, cmd->device->lun,
+				   /*alloc*/FALSE);
+
+	if (dev == NULL) {
+		/*
+		 * No target device for this command exists,
+		 * so we must not still own the command.
+		 */
+		printf("%s:%d:%d:%d: Is not an active device\n",
+		       ahd_name(ahd), cmd->device->channel, cmd->device->id,
+		       cmd->device->lun);
+		retval = SUCCESS;
+		goto no_cmd;
+	}
+
+	TAILQ_FOREACH(list_acmd, &dev->busyq, acmd_links.tqe) {
+		if (list_acmd == acmd)
+			break;
+	}
+
+	if (list_acmd != NULL) {
+		printf("%s:%d:%d:%d: Command found on device queue\n",
+		       ahd_name(ahd), cmd->device->channel, cmd->device->id,
+		       cmd->device->lun);
+		TAILQ_REMOVE(&dev->busyq, list_acmd, acmd_links.tqe);
+		cmd->result = DID_ABORT << 16;
+		ahd_linux_queue_cmd_complete(ahd, cmd);
+		retval = SUCCESS;
+		goto done;
+	}
+
+	/*
+	 * See if we can find a matching cmd in the pending list.
+	 */
+	LIST_FOREACH(pending_scb, &ahd->pending_scbs, pending_links) {
+		if (pending_scb->io_ctx == cmd)
+			break;
+	}
+
+	if (pending_scb == NULL) {
+		printf("%s:%d:%d:%d: Command not found\n",
+		       ahd_name(ahd), cmd->device->channel, cmd->device->id,
+		       cmd->device->lun);
+		goto no_cmd;
+	}
+
+	if ((pending_scb->flags & SCB_RECOVERY_SCB) != 0) {
+		/*
+		 * We can't queue two recovery actions using the same SCB
+		 */
+		retval = FAILED;
+		goto  done;
+	}
+
+	/*
+	 * Ensure that the card doesn't do anything
+	 * behind our back.  Also make sure that we
+	 * didn't "just" miss an interrupt that would
+	 * affect this cmd.
+	 */
+	was_paused = ahd_is_paused(ahd);
+	ahd_pause_and_flushwork(ahd);
+	paused = TRUE;
+
+	if ((pending_scb->flags & SCB_ACTIVE) == 0) {
+		printf("%s:%d:%d:%d: Command already completed\n",
+		       ahd_name(ahd), cmd->device->channel, cmd->device->id,
+		       cmd->device->lun);
+		goto no_cmd;
+	}
+
+	printf("%s: At time of recovery, card was %spaused\n",
+	       ahd_name(ahd), was_paused ? "" : "not ");
+	ahd_dump_card_state(ahd);
+
+	disconnected = TRUE;
+	if (ahd_search_qinfifo(ahd, cmd->device->id, cmd->device->channel + 'A',
+			       cmd->device->lun, SCB_GET_TAG(pending_scb),
+			       ROLE_INITIATOR, CAM_REQ_ABORTED,
+			       SEARCH_COMPLETE) > 0) {
+		printf("%s:%d:%d:%d: Cmd aborted from QINFIFO\n",
+		       ahd_name(ahd), cmd->device->channel, cmd->device->id,
+				cmd->device->lun);
+		retval = SUCCESS;
+		goto done;
+	}
+
+	saved_modes = ahd_save_modes(ahd);
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+	last_phase = ahd_inb(ahd, LASTPHASE);
+	saved_scbptr = ahd_get_scbptr(ahd);
+	active_scbptr = saved_scbptr;
+	if (disconnected && (ahd_inb(ahd, SEQ_FLAGS) & NOT_IDENTIFIED) == 0) {
+		struct scb *bus_scb;
+
+		bus_scb = ahd_lookup_scb(ahd, active_scbptr);
+		if (bus_scb == pending_scb)
+			disconnected = FALSE;
+	}
+
+	/*
+	 * At this point, pending_scb is the scb associated with the
+	 * passed in command.  That command is currently active on the
+	 * bus or is in the disconnected state.
+	 */
+	if (last_phase != P_BUSFREE
+	 && SCB_GET_TAG(pending_scb) == active_scbptr) {
+
+		/*
+		 * We're active on the bus, so assert ATN
+		 * and hope that the target responds.
+		 */
+		pending_scb = ahd_lookup_scb(ahd, active_scbptr);
+		pending_scb->flags |= SCB_RECOVERY_SCB|SCB_ABORT;
+		ahd_outb(ahd, MSG_OUT, HOST_MSG);
+		ahd_outb(ahd, SCSISIGO, last_phase|ATNO);
+		printf("%s:%d:%d:%d: Device is active, asserting ATN\n",
+		       ahd_name(ahd), cmd->device->channel,
+		       cmd->device->id, cmd->device->lun);
+		wait = TRUE;
+	} else if (disconnected) {
+
+		/*
+		 * Actually re-queue this SCB in an attempt
+		 * to select the device before it reconnects.
+		 */
+		pending_scb->flags |= SCB_RECOVERY_SCB|SCB_ABORT;
+		ahd_set_scbptr(ahd, SCB_GET_TAG(pending_scb));
+		pending_scb->hscb->cdb_len = 0;
+		pending_scb->hscb->task_attribute = 0;
+		pending_scb->hscb->task_management = SIU_TASKMGMT_ABORT_TASK;
+
+		if ((pending_scb->flags & SCB_PACKETIZED) != 0) {
+			/*
+			 * Mark the SCB has having an outstanding
+			 * task management function.  Should the command
+			 * complete normally before the task management
+			 * function can be sent, the host will be notified
+			 * to abort our requeued SCB.
+			 */
+			ahd_outb(ahd, SCB_TASK_MANAGEMENT,
+				 pending_scb->hscb->task_management);
+		} else {
+			/*
+			 * If non-packetized, set the MK_MESSAGE control
+			 * bit indicating that we desire to send a message.
+			 * We also set the disconnected flag since there is
+			 * no guarantee that our SCB control byte matches
+			 * the version on the card.  We don't want the
+			 * sequencer to abort the command thinking an
+			 * unsolicited reselection occurred.
+			 */
+			pending_scb->hscb->control |= MK_MESSAGE|DISCONNECTED;
+
+			/*
+			 * The sequencer will never re-reference the
+			 * in-core SCB.  To make sure we are notified
+			 * during reslection, set the MK_MESSAGE flag in
+			 * the card's copy of the SCB.
+			 */
+			ahd_outb(ahd, SCB_CONTROL,
+				 ahd_inb(ahd, SCB_CONTROL)|MK_MESSAGE);
+		}
+
+		/*
+		 * Clear out any entries in the QINFIFO first
+		 * so we are the next SCB for this target
+		 * to run.
+		 */
+		ahd_search_qinfifo(ahd, cmd->device->id,
+				   cmd->device->channel + 'A', cmd->device->lun,
+				   SCB_LIST_NULL, ROLE_INITIATOR,
+				   CAM_REQUEUE_REQ, SEARCH_COMPLETE);
+		ahd_qinfifo_requeue_tail(ahd, pending_scb);
+		ahd_set_scbptr(ahd, saved_scbptr);
+		ahd_print_path(ahd, pending_scb);
+		printf("Device is disconnected, re-queuing SCB\n");
+		wait = TRUE;
+	} else {
+		printf("%s:%d:%d:%d: Unable to deliver message\n",
+		       ahd_name(ahd), cmd->device->channel,
+		       cmd->device->id, cmd->device->lun);
+		retval = FAILED;
+		goto done;
+	}
+
+no_cmd:
+	/*
+	 * Our assumption is that if we don't have the command, no
+	 * recovery action was required, so we return success.  Again,
+	 * the semantics of the mid-layer recovery engine are not
+	 * well defined, so this may change in time.
+	 */
+	retval = SUCCESS;
+done:
+	if (paused)
+		ahd_unpause(ahd);
+	if (wait) {
+		struct timer_list timer;
+		int ret;
+
+		pending_scb->platform_data->flags |= AHD_SCB_UP_EH_SEM;
+		spin_unlock_irq(&ahd->platform_data->spin_lock);
+		init_timer(&timer);
+		timer.data = (u_long)pending_scb;
+		timer.expires = jiffies + (5 * HZ);
+		timer.function = ahd_linux_sem_timeout;
+		add_timer(&timer);
+		printf("Recovery code sleeping\n");
+		down(&ahd->platform_data->eh_sem);
+		printf("Recovery code awake\n");
+        	ret = del_timer_sync(&timer);
+		if (ret == 0) {
+			printf("Timer Expired\n");
+			retval = FAILED;
+		}
+		spin_lock_irq(&ahd->platform_data->spin_lock);
+	}
+	ahd_schedule_runq(ahd);
+	ahd_linux_run_complete_queue(ahd);
+	ahd_midlayer_entrypoint_unlock(ahd, &s);
+	return (retval);
+}
+
+
+static void
+ahd_linux_dev_reset_complete(Scsi_Cmnd *cmd)
+{
+	free(cmd, M_DEVBUF);
+}
+
+/*
+ * Attempt to send a target reset message to the device that timed out.
+ */
+static int
+ahd_linux_dev_reset(Scsi_Cmnd *cmd)
+{
+	struct	ahd_softc *ahd;
+	struct	scsi_cmnd *recovery_cmd;
+	struct	ahd_linux_device *dev;
+	struct	ahd_initiator_tinfo *tinfo;
+	struct	ahd_tmode_tstate *tstate;
+	struct	scb *scb;
+	struct	hardware_scb *hscb;
+	u_long	s;
+	struct	timer_list timer;
+	int	retval;
+
+	ahd = *(struct ahd_softc **)cmd->device->host->hostdata;
+	recovery_cmd = malloc(sizeof(struct scsi_cmnd), M_DEVBUF, M_WAITOK);
+	memset(recovery_cmd, 0, sizeof(struct scsi_cmnd));
+	recovery_cmd->device = cmd->device;
+	recovery_cmd->scsi_done = ahd_linux_dev_reset_complete;
+#if AHD_DEBUG
+	if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)
+		printf("%s:%d:%d:%d: Device reset called for cmd %p\n",
+		       ahd_name(ahd), cmd->device->channel, cmd->device->id,
+		       cmd->device->lun, cmd);
+#endif
+	ahd_midlayer_entrypoint_lock(ahd, &s);
+
+	dev = ahd_linux_get_device(ahd, cmd->device->channel, cmd->device->id,
+				   cmd->device->lun, /*alloc*/FALSE);
+	if (dev == NULL) {
+		ahd_midlayer_entrypoint_unlock(ahd, &s);
+		return (FAILED);
+	}
+	if ((scb = ahd_get_scb(ahd, AHD_NEVER_COL_IDX)) == NULL) {
+		ahd_midlayer_entrypoint_unlock(ahd, &s);
+		return (FAILED);
+	}
+	tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
+				    cmd->device->id, &tstate);
+	recovery_cmd->result = CAM_REQ_INPROG << 16;
+	recovery_cmd->host_scribble = (char *)scb;
+	scb->io_ctx = recovery_cmd;
+	scb->platform_data->dev = dev;
+	scb->sg_count = 0;
+	ahd_set_residual(scb, 0);
+	ahd_set_sense_residual(scb, 0);
+	hscb = scb->hscb;
+	hscb->control = 0;
+	hscb->scsiid = BUILD_SCSIID(ahd, cmd);
+	hscb->lun = cmd->device->lun;
+	hscb->cdb_len = 0;
+	hscb->task_management = SIU_TASKMGMT_LUN_RESET;
+	scb->flags |= SCB_DEVICE_RESET|SCB_RECOVERY_SCB|SCB_ACTIVE;
+	if ((tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
+		scb->flags |= SCB_PACKETIZED;
+	} else {
+		hscb->control |= MK_MESSAGE;
+	}
+	dev->openings--;
+	dev->active++;
+	dev->commands_issued++;
+	LIST_INSERT_HEAD(&ahd->pending_scbs, scb, pending_links);
+	ahd_queue_scb(ahd, scb);
+
+	scb->platform_data->flags |= AHD_SCB_UP_EH_SEM;
+	spin_unlock_irq(&ahd->platform_data->spin_lock);
+	init_timer(&timer);
+	timer.data = (u_long)scb;
+	timer.expires = jiffies + (5 * HZ);
+	timer.function = ahd_linux_sem_timeout;
+	add_timer(&timer);
+	printf("Recovery code sleeping\n");
+	down(&ahd->platform_data->eh_sem);
+	printf("Recovery code awake\n");
+	retval = SUCCESS;
+	if (del_timer_sync(&timer) == 0) {
+		printf("Timer Expired\n");
+		retval = FAILED;
+	}
+	spin_lock_irq(&ahd->platform_data->spin_lock);
+	ahd_schedule_runq(ahd);
+	ahd_linux_run_complete_queue(ahd);
+	ahd_midlayer_entrypoint_unlock(ahd, &s);
+	printf("%s: Device reset returning 0x%x\n", ahd_name(ahd), retval);
+	return (retval);
+}
+
+/*
+ * Reset the SCSI bus.
+ */
+static int
+ahd_linux_bus_reset(Scsi_Cmnd *cmd)
+{
+	struct ahd_softc *ahd;
+	u_long s;
+	int    found;
+
+	ahd = *(struct ahd_softc **)cmd->device->host->hostdata;
+#ifdef AHD_DEBUG
+	if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)
+		printf("%s: Bus reset called for cmd %p\n",
+		       ahd_name(ahd), cmd);
+#endif
+	ahd_midlayer_entrypoint_lock(ahd, &s);
+	found = ahd_reset_channel(ahd, cmd->device->channel + 'A',
+				  /*initiate reset*/TRUE);
+	ahd_linux_run_complete_queue(ahd);
+	ahd_midlayer_entrypoint_unlock(ahd, &s);
+
+	if (bootverbose)
+		printf("%s: SCSI bus reset delivered. "
+		       "%d SCBs aborted.\n", ahd_name(ahd), found);
+
+	return (SUCCESS);
+}
+
+Scsi_Host_Template aic79xx_driver_template = {
+	.module			= THIS_MODULE,
+	.name			= "aic79xx",
+	.proc_info		= ahd_linux_proc_info,
+	.info			= ahd_linux_info,
+	.queuecommand		= ahd_linux_queue,
+	.eh_abort_handler	= ahd_linux_abort,
+	.eh_device_reset_handler = ahd_linux_dev_reset,
+	.eh_bus_reset_handler	= ahd_linux_bus_reset,
+#if defined(__i386__)
+	.bios_param		= ahd_linux_biosparam,
+#endif
+	.can_queue		= AHD_MAX_QUEUE,
+	.this_id		= -1,
+	.cmd_per_lun		= 2,
+	.use_clustering		= ENABLE_CLUSTERING,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,7)
+	/*
+	 * We can only map 16MB per-SG
+	 * so create a sector limit of
+	 * "16MB" in 2K sectors.
+	 */
+	.max_sectors		= 8192,
+#endif
+#if defined CONFIG_HIGHIO || LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10)
+/* Assume RedHat Distribution with its different HIGHIO conventions. */
+	.can_dma_32		= 1,
+	.single_sg_okay		= 1,
+#else
+	.highmem_io		= 1,
+#endif
+#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+	.slave_alloc		= ahd_linux_slave_alloc,
+	.slave_configure	= ahd_linux_slave_configure,
+	.slave_destroy		= ahd_linux_slave_destroy,
+#else
+	.detect			= ahd_linux_detect,
+	.release		= ahd_linux_release,
+	.select_queue_depths	= ahd_linux_select_queue_depth,
+	.use_new_eh_code	= 1,
+#endif
+};
+
+/**************************** Tasklet Handler *********************************/
+
+/*
+ * In 2.4.X and above, this routine is called from a tasklet,
+ * so we must re-acquire our lock prior to executing this code.
+ * In all prior kernels, ahd_schedule_runq() calls this routine
+ * directly and ahd_schedule_runq() is called with our lock held.
+ */
+static void
+ahd_runq_tasklet(unsigned long data)
+{
+	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,
+		   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)
+{
+	bus_dma_tag_t dmat;
+
+	dmat = malloc(sizeof(*dmat), M_DEVBUF, M_NOWAIT);
+	if (dmat == NULL)
+		return (ENOMEM);
+
+	/*
+	 * Linux is very simplistic about DMA memory.  For now don't
+	 * maintain all specification information.  Once Linux supplies
+	 * better facilities for doing these operations, or the
+	 * needs of this particular driver change, we might need to do
+	 * more here.
+	 */
+	dmat->alignment = alignment;
+	dmat->boundary = boundary;
+	dmat->maxsize = maxsize;
+	*ret_tag = dmat;
+	return (0);
+}
+
+void
+ahd_dma_tag_destroy(struct ahd_softc *ahd, bus_dma_tag_t dmat)
+{
+	free(dmat, M_DEVBUF);
+}
+
+int
+ahd_dmamem_alloc(struct ahd_softc *ahd, bus_dma_tag_t dmat, void** vaddr,
+		 int flags, bus_dmamap_t *mapp)
+{
+	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);
+	/*
+	 * Although we can dma data above 4GB, our
+	 * "consistent" memory is below 4GB for
+	 * space efficiency reasons (only need a 4byte
+	 * address).  For this reason, we have to reset
+	 * our dma mask when doing allocations.
+	 */
+	if (ahd->dev_softc != NULL)
+		ahd_pci_set_dma_mask(ahd->dev_softc, 0xFFFFFFFF);
+	*vaddr = pci_alloc_consistent(ahd->dev_softc,
+				      dmat->maxsize, &map->bus_addr);
+	if (ahd->dev_softc != NULL)
+		ahd_pci_set_dma_mask(ahd->dev_softc,
+				     ahd->platform_data->hw_dma_mask);
+#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;
+	return(0);
+}
+
+void
+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
+ahd_dmamap_load(struct ahd_softc *ahd, bus_dma_tag_t dmat, bus_dmamap_t map,
+		void *buf, bus_size_t buflen, bus_dmamap_callback_t *cb,
+		void *cb_arg, int flags)
+{
+	/*
+	 * Assume for now that this will only be used during
+	 * initialization and not for per-transaction buffer mapping.
+	 */
+	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);
+}
+
+void
+ahd_dmamap_destroy(struct ahd_softc *ahd, bus_dma_tag_t dmat, bus_dmamap_t map)
+{
+	/*
+	 * The map may is NULL in our < 2.3.X implementation.
+	 */
+	if (map != NULL)
+		free(map, M_DEVBUF);
+}
+
+int
+ahd_dmamap_unload(struct ahd_softc *ahd, bus_dma_tag_t dmat, bus_dmamap_t map)
+{
+	/* Nothing to do */
+	return (0);
+}
+
+/********************* Platform Dependent Functions ***************************/
+/*
+ * Compare "left hand" softc with "right hand" softc, returning:
+ * < 0 - lahd has a lower priority than rahd
+ *   0 - Softcs are equal
+ * > 0 - lahd has a higher priority than rahd
+ */
+int
+ahd_softc_comp(struct ahd_softc *lahd, struct ahd_softc *rahd)
+{
+	int	value;
+
+	/*
+	 * Under Linux, cards are ordered as follows:
+	 *	1) PCI devices that are marked as the boot controller.
+	 *	2) PCI devices with BIOS enabled sorted by bus/slot/func.
+	 *	3) All remaining PCI devices sorted by bus/slot/func.
+	 */
+#if 0
+	value = (lahd->flags & AHD_BOOT_CHANNEL)
+	      - (rahd->flags & AHD_BOOT_CHANNEL);
+	if (value != 0)
+		/* Controllers set for boot have a *higher* priority */
+		return (value);
+#endif
+
+	value = (lahd->flags & AHD_BIOS_ENABLED)
+	      - (rahd->flags & AHD_BIOS_ENABLED);
+	if (value != 0)
+		/* Controllers with BIOS enabled have a *higher* priority */
+		return (value);
+
+	/* Still equal.  Sort by bus/slot/func. */
+	if (aic79xx_reverse_scan != 0)
+		value = ahd_get_pci_bus(lahd->dev_softc)
+		      - ahd_get_pci_bus(rahd->dev_softc);
+	else
+		value = ahd_get_pci_bus(rahd->dev_softc)
+		      - ahd_get_pci_bus(lahd->dev_softc);
+	if (value != 0)
+		return (value);
+	if (aic79xx_reverse_scan != 0)
+		value = ahd_get_pci_slot(lahd->dev_softc)
+		      - ahd_get_pci_slot(rahd->dev_softc);
+	else
+		value = ahd_get_pci_slot(rahd->dev_softc)
+		      - ahd_get_pci_slot(lahd->dev_softc);
+	if (value != 0)
+		return (value);
+
+	value = rahd->channel - lahd->channel;
+	return (value);
+}
+
+static void
+ahd_linux_setup_tag_info(u_long arg, int instance, int targ, int32_t value)
+{
+
+	if ((instance >= 0) && (targ >= 0)
+	 && (instance < NUM_ELEMENTS(aic79xx_tag_info))
+	 && (targ < AHD_NUM_TARGETS)) {
+		aic79xx_tag_info[instance].tag_commands[targ] = value & 0x1FF;
+		if (bootverbose)
+			printf("tag_info[%d:%d] = %d\n", instance, targ, value);
+	}
+}
+
+static void
+ahd_linux_setup_rd_strm_info(u_long arg, int instance, int targ, int32_t value)
+{
+	if ((instance >= 0)
+	 && (instance < NUM_ELEMENTS(aic79xx_rd_strm_info))) {
+		aic79xx_rd_strm_info[instance] = value & 0xFFFF;
+		if (bootverbose)
+			printf("rd_strm[%d] = 0x%x\n", instance, value);
+	}
+}
+
+static void
+ahd_linux_setup_dv(u_long arg, int instance, int targ, int32_t value)
+{
+	if ((instance >= 0)
+	 && (instance < NUM_ELEMENTS(aic79xx_dv_settings))) {
+		aic79xx_dv_settings[instance] = value;
+		if (bootverbose)
+			printf("dv[%d] = %d\n", instance, value);
+	}
+}
+
+static void
+ahd_linux_setup_iocell_info(u_long index, int instance, int targ, int32_t value)
+{
+
+	if ((instance >= 0)
+	 && (instance < NUM_ELEMENTS(aic79xx_iocell_info))) {
+		uint8_t *iocell_info;
+
+		iocell_info = (uint8_t*)&aic79xx_iocell_info[instance];
+		iocell_info[index] = value & 0xFFFF;
+		if (bootverbose)
+			printf("iocell[%d:%ld] = %d\n", instance, index, value);
+	}
+}
+
+static void
+ahd_linux_setup_tag_info_global(char *p)
+{
+	int tags, i, j;
+
+	tags = simple_strtoul(p + 1, NULL, 0) & 0xff;
+	printf("Setting Global Tags= %d\n", tags);
+
+	for (i = 0; i < NUM_ELEMENTS(aic79xx_tag_info); i++) {
+		for (j = 0; j < AHD_NUM_TARGETS; j++) {
+			aic79xx_tag_info[i].tag_commands[j] = tags;
+		}
+	}
+}
+
+/*
+ * Handle Linux boot parameters. This routine allows for assigning a value
+ * to a parameter with a ':' between the parameter and the value.
+ * ie. aic79xx=stpwlev:1,extended
+ */
+static int
+aic79xx_setup(char *s)
+{
+	int	i, n;
+	char   *p;
+	char   *end;
+
+	static struct {
+		const char *name;
+		uint32_t *flag;
+	} options[] = {
+		{ "extended", &aic79xx_extended },
+		{ "no_reset", &aic79xx_no_reset },
+		{ "verbose", &aic79xx_verbose },
+		{ "allow_memio", &aic79xx_allow_memio},
+#ifdef AHD_DEBUG
+		{ "debug", &ahd_debug },
+#endif
+		{ "reverse_scan", &aic79xx_reverse_scan },
+		{ "periodic_otag", &aic79xx_periodic_otag },
+		{ "pci_parity", &aic79xx_pci_parity },
+		{ "seltime", &aic79xx_seltime },
+		{ "tag_info", NULL },
+		{ "global_tag_depth", NULL},
+		{ "rd_strm", NULL },
+		{ "dv", NULL },
+		{ "slewrate", NULL },
+		{ "precomp", NULL },
+		{ "amplitude", NULL },
+	};
+
+	end = strchr(s, '\0');
+
+	/*
+	 * XXX ia64 gcc isn't smart enough to know that NUM_ELEMENTS
+	 * will never be 0 in this case.
+	 */      
+	n = 0;  
+
+	while ((p = strsep(&s, ",.")) != NULL) {
+		if (*p == '\0')
+			continue;
+		for (i = 0; i < NUM_ELEMENTS(options); i++) {
+
+			n = strlen(options[i].name);
+			if (strncmp(options[i].name, p, n) == 0)
+				break;
+		}
+		if (i == NUM_ELEMENTS(options))
+			continue;
+
+		if (strncmp(p, "global_tag_depth", n) == 0) {
+			ahd_linux_setup_tag_info_global(p + n);
+		} else if (strncmp(p, "tag_info", n) == 0) {
+			s = aic_parse_brace_option("tag_info", p + n, end,
+			    2, ahd_linux_setup_tag_info, 0);
+		} else if (strncmp(p, "rd_strm", n) == 0) {
+			s = aic_parse_brace_option("rd_strm", p + n, end,
+			    1, ahd_linux_setup_rd_strm_info, 0);
+		} else if (strncmp(p, "dv", n) == 0) {
+			s = aic_parse_brace_option("dv", p + n, end, 1,
+			    ahd_linux_setup_dv, 0);
+		} else if (strncmp(p, "slewrate", n) == 0) {
+			s = aic_parse_brace_option("slewrate",
+			    p + n, end, 1, ahd_linux_setup_iocell_info,
+			    AIC79XX_SLEWRATE_INDEX);
+		} else if (strncmp(p, "precomp", n) == 0) {
+			s = aic_parse_brace_option("precomp",
+			    p + n, end, 1, ahd_linux_setup_iocell_info,
+			    AIC79XX_PRECOMP_INDEX);
+		} else if (strncmp(p, "amplitude", n) == 0) {
+			s = aic_parse_brace_option("amplitude",
+			    p + n, end, 1, ahd_linux_setup_iocell_info,
+			    AIC79XX_AMPLITUDE_INDEX);
+		} else if (p[n] == ':') {
+			*(options[i].flag) = simple_strtoul(p + n + 1, NULL, 0);
+		} else if (!strncmp(p, "verbose", n)) {
+			*(options[i].flag) = 1;
+		} else {
+			*(options[i].flag) ^= 0xFFFFFFFF;
+		}
+	}
+	return 1;
+}
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0)
+__setup("aic79xx=", aic79xx_setup);
+#endif
+
+uint32_t aic79xx_verbose;
+
+int
+ahd_linux_register_host(struct ahd_softc *ahd, Scsi_Host_Template *template)
+{
+	char	buf[80];
+	struct	Scsi_Host *host;
+	char	*new_name;
+	u_long	s;
+	u_long	target;
+
+	template->name = ahd->description;
+	host = scsi_register(template, sizeof(struct ahd_softc *));
+	if (host == NULL)
+		return (ENOMEM);
+
+	*((struct ahd_softc **)host->hostdata) = ahd;
+	ahd_lock(ahd, &s);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+	scsi_assign_lock(host, &ahd->platform_data->spin_lock);
+#elif AHD_SCSI_HAS_HOST_LOCK != 0
+	host->lock = &ahd->platform_data->spin_lock;
+#endif
+	ahd->platform_data->host = host;
+	host->can_queue = AHD_MAX_QUEUE;
+	host->cmd_per_lun = 2;
+	host->sg_tablesize = AHD_NSEG;
+	host->this_id = ahd->our_id;
+	host->irq = ahd->platform_data->irq;
+	host->max_id = (ahd->features & AHD_WIDE) ? 16 : 8;
+	host->max_lun = AHD_NUM_LUNS;
+	host->max_channel = 0;
+	host->sg_tablesize = AHD_NSEG;
+	ahd_set_unit(ahd, ahd_linux_next_unit());
+	sprintf(buf, "scsi%d", host->host_no);
+	new_name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT);
+	if (new_name != NULL) {
+		strcpy(new_name, buf);
+		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)
+	scsi_set_pci_device(host, ahd->dev_softc);
+#endif
+	ahd_linux_setup_user_rd_strm_settings(ahd);
+	ahd_linux_initialize_scsi_bus(ahd);
+	ahd_unlock(ahd, &s);
+	ahd->platform_data->dv_pid = kernel_thread(ahd_linux_dv_thread, ahd, 0);
+	ahd_lock(ahd, &s);
+	if (ahd->platform_data->dv_pid < 0) {
+		printf("%s: Failed to create DV thread, error= %d\n",
+		       ahd_name(ahd), ahd->platform_data->dv_pid);
+		return (-ahd->platform_data->dv_pid);
+	}
+	/*
+	 * Initially allocate *all* of our linux target objects
+	 * so that the DV thread will scan them all in parallel
+	 * just after driver initialization.  Any device that
+	 * does not exist will have its target object destroyed
+	 * by the selection timeout handler.  In the case of a
+	 * device that appears after the initial DV scan, async
+	 * negotiation will occur for the first command, and DV
+	 * will comence should that first command be successful.
+	 */
+	for (target = 0; target < host->max_id; target++) {
+
+		/*
+		 * Skip our own ID.  Some Compaq/HP storage devices
+		 * have enclosure management devices that respond to
+		 * single bit selection (i.e. selecting ourselves).
+		 * It is expected that either an external application
+		 * or a modified kernel will be used to probe this
+		 * ID if it is appropriate.  To accommodate these
+		 * installations, ahc_linux_alloc_target() will allocate
+		 * for our ID if asked to do so.
+		 */
+		if (target == ahd->our_id) 
+			continue;
+
+		ahd_linux_alloc_target(ahd, 0, target);
+	}
+	ahd_intr_enable(ahd, TRUE);
+	ahd_linux_start_dv(ahd);
+	ahd_unlock(ahd, &s);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+	scsi_add_host(host, &ahd->dev_softc->dev);
+#endif
+	return (0);
+}
+
+uint64_t
+ahd_linux_get_memsize(void)
+{
+	struct sysinfo si;
+
+	si_meminfo(&si);
+	return ((uint64_t)si.totalram << PAGE_SHIFT);
+}
+
+/*
+ * Find the smallest available unit number to use
+ * for a new device.  We don't just use a static
+ * count to handle the "repeated hot-(un)plug"
+ * scenario.
+ */
+static int
+ahd_linux_next_unit(void)
+{
+	struct ahd_softc *ahd;
+	int unit;
+
+	unit = 0;
+retry:
+	TAILQ_FOREACH(ahd, &ahd_tailq, links) {
+		if (ahd->unit == unit) {
+			unit++;
+			goto retry;
+		}
+	}
+	return (unit);
+}
+
+/*
+ * Place the SCSI bus into a known state by either resetting it,
+ * or forcing transfer negotiations on the next command to any
+ * target.
+ */
+static void
+ahd_linux_initialize_scsi_bus(struct ahd_softc *ahd)
+{
+	u_int target_id;
+	u_int numtarg;
+
+	target_id = 0;
+	numtarg = 0;
+
+	if (aic79xx_no_reset != 0)
+		ahd->flags &= ~AHD_RESET_BUS_A;
+
+	if ((ahd->flags & AHD_RESET_BUS_A) != 0)
+		ahd_reset_channel(ahd, 'A', /*initiate_reset*/TRUE);
+	else
+		numtarg = (ahd->features & AHD_WIDE) ? 16 : 8;
+
+	/*
+	 * Force negotiation to async for all targets that
+	 * will not see an initial bus reset.
+	 */
+	for (; target_id < numtarg; target_id++) {
+		struct ahd_devinfo devinfo;
+		struct ahd_initiator_tinfo *tinfo;
+		struct ahd_tmode_tstate *tstate;
+
+		tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
+					    target_id, &tstate);
+		ahd_compile_devinfo(&devinfo, ahd->our_id, target_id,
+				    CAM_LUN_WILDCARD, 'A', ROLE_INITIATOR);
+		ahd_update_neg_request(ahd, &devinfo, tstate,
+				       tinfo, AHD_NEG_ALWAYS);
+	}
+	/* Give the bus some time to recover */
+	if ((ahd->flags & AHD_RESET_BUS_A) != 0) {
+		ahd_freeze_simq(ahd);
+		init_timer(&ahd->platform_data->reset_timer);
+		ahd->platform_data->reset_timer.data = (u_long)ahd;
+		ahd->platform_data->reset_timer.expires =
+		    jiffies + (AIC79XX_RESET_DELAY * HZ)/1000;
+		ahd->platform_data->reset_timer.function =
+		    (ahd_linux_callback_t *)ahd_release_simq;
+		add_timer(&ahd->platform_data->reset_timer);
+	}
+}
+
+int
+ahd_platform_alloc(struct ahd_softc *ahd, void *platform_arg)
+{
+	ahd->platform_data =
+	    malloc(sizeof(struct ahd_platform_data), M_DEVBUF, M_NOWAIT);
+	if (ahd->platform_data == NULL)
+		return (ENOMEM);
+	memset(ahd->platform_data, 0, sizeof(struct ahd_platform_data));
+	TAILQ_INIT(&ahd->platform_data->completeq);
+	TAILQ_INIT(&ahd->platform_data->device_runq);
+	ahd->platform_data->irq = AHD_LINUX_NOIRQ;
+	ahd->platform_data->hw_dma_mask = 0xFFFFFFFF;
+	ahd_lockinit(ahd);
+	ahd_done_lockinit(ahd);
+	init_timer(&ahd->platform_data->completeq_timer);
+	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);
+}
+
+void
+ahd_platform_free(struct ahd_softc *ahd)
+{
+	struct ahd_linux_target *targ;
+	struct ahd_linux_device *dev;
+	int i, j;
+
+	if (ahd->platform_data != NULL) {
+		del_timer_sync(&ahd->platform_data->completeq_timer);
+		ahd_linux_kill_dv_thread(ahd);
+		ahd_teardown_runq_tasklet(ahd);
+		if (ahd->platform_data->host != NULL) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+			scsi_remove_host(ahd->platform_data->host);
+#endif
+			scsi_unregister(ahd->platform_data->host);
+		}
+
+		/* destroy all of the device and target objects */
+		for (i = 0; i < AHD_NUM_TARGETS; i++) {
+			targ = ahd->platform_data->targets[i];
+			if (targ != NULL) {
+				/* Keep target around through the loop. */
+				targ->refcount++;
+				for (j = 0; j < AHD_NUM_LUNS; j++) {
+
+					if (targ->devices[j] == NULL)
+						continue;
+					dev = targ->devices[j];
+					ahd_linux_free_device(ahd, dev);
+				}
+				/*
+				 * Forcibly free the target now that
+				 * all devices are gone.
+				 */
+				ahd_linux_free_target(ahd, targ);
+			}
+		}
+
+		if (ahd->platform_data->irq != AHD_LINUX_NOIRQ)
+			free_irq(ahd->platform_data->irq, ahd);
+		if (ahd->tags[0] == BUS_SPACE_PIO
+		 && ahd->bshs[0].ioport != 0)
+			release_region(ahd->bshs[0].ioport, 256);
+		if (ahd->tags[1] == BUS_SPACE_PIO
+		 && ahd->bshs[1].ioport != 0)
+			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)
+			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)
+    		/*
+		 * In 2.4 we detach from the scsi midlayer before the PCI
+		 * layer invokes our remove callback.  No per-instance
+		 * detach is provided, so we must reach inside the PCI
+		 * subsystem's internals and detach our driver manually.
+		 */
+		if (ahd->dev_softc != NULL)
+			ahd->dev_softc->driver = NULL;
+#endif
+		free(ahd->platform_data, M_DEVBUF);
+	}
+}
+
+void
+ahd_platform_init(struct ahd_softc *ahd)
+{
+	/*
+	 * Lookup and commit any modified IO Cell options.
+	 */
+	if (ahd->unit < NUM_ELEMENTS(aic79xx_iocell_info)) {
+		struct ahd_linux_iocell_opts *iocell_opts;
+
+		iocell_opts = &aic79xx_iocell_info[ahd->unit];
+		if (iocell_opts->precomp != AIC79XX_DEFAULT_PRECOMP)
+			AHD_SET_PRECOMP(ahd, iocell_opts->precomp);
+		if (iocell_opts->slewrate != AIC79XX_DEFAULT_SLEWRATE)
+			AHD_SET_SLEWRATE(ahd, iocell_opts->slewrate);
+		if (iocell_opts->amplitude != AIC79XX_DEFAULT_AMPLITUDE)
+			AHD_SET_AMPLITUDE(ahd, iocell_opts->amplitude);
+	}
+
+}
+
+void
+ahd_platform_freeze_devq(struct ahd_softc *ahd, struct scb *scb)
+{
+	ahd_platform_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb),
+				SCB_GET_CHANNEL(ahd, scb),
+				SCB_GET_LUN(scb), SCB_LIST_NULL,
+				ROLE_UNKNOWN, CAM_REQUEUE_REQ);
+}
+
+void
+ahd_platform_set_tags(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
+		      ahd_queue_alg alg)
+{
+	struct ahd_linux_device *dev;
+	int was_queuing;
+	int now_queuing;
+
+	dev = ahd_linux_get_device(ahd, devinfo->channel - 'A',
+				   devinfo->target,
+				   devinfo->lun, /*alloc*/FALSE);
+	if (dev == NULL)
+		return;
+	was_queuing = dev->flags & (AHD_DEV_Q_BASIC|AHD_DEV_Q_TAGGED);
+	switch (alg) {
+	default:
+	case AHD_QUEUE_NONE:
+		now_queuing = 0;
+		break; 
+	case AHD_QUEUE_BASIC:
+		now_queuing = AHD_DEV_Q_BASIC;
+		break;
+	case AHD_QUEUE_TAGGED:
+		now_queuing = AHD_DEV_Q_TAGGED;
+		break;
+	}
+	if ((dev->flags & AHD_DEV_FREEZE_TIL_EMPTY) == 0
+	 && (was_queuing != now_queuing)
+	 && (dev->active != 0)) {
+		dev->flags |= AHD_DEV_FREEZE_TIL_EMPTY;
+		dev->qfrozen++;
+	}
+
+	dev->flags &= ~(AHD_DEV_Q_BASIC|AHD_DEV_Q_TAGGED|AHD_DEV_PERIODIC_OTAG);
+	if (now_queuing) {
+		u_int usertags;
+
+		usertags = ahd_linux_user_tagdepth(ahd, devinfo);
+		if (!was_queuing) {
+			/*
+			 * Start out agressively and allow our
+			 * dynamic queue depth algorithm to take
+			 * care of the rest.
+			 */
+			dev->maxtags = usertags;
+			dev->openings = dev->maxtags - dev->active;
+		}
+		if (dev->maxtags == 0) {
+			/*
+			 * Queueing is disabled by the user.
+			 */
+			dev->openings = 1;
+		} else if (alg == AHD_QUEUE_TAGGED) {
+			dev->flags |= AHD_DEV_Q_TAGGED;
+			if (aic79xx_periodic_otag != 0)
+				dev->flags |= AHD_DEV_PERIODIC_OTAG;
+		} else
+			dev->flags |= AHD_DEV_Q_BASIC;
+	} else {
+		/* We can only have one opening. */
+		dev->maxtags = 0;
+		dev->openings =  1 - dev->active;
+	}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+	if (dev->scsi_device != NULL) {
+		switch ((dev->flags & (AHD_DEV_Q_BASIC|AHD_DEV_Q_TAGGED))) {
+		case AHD_DEV_Q_BASIC:
+			scsi_adjust_queue_depth(dev->scsi_device,
+						MSG_SIMPLE_TASK,
+						dev->openings + dev->active);
+			break;
+		case AHD_DEV_Q_TAGGED:
+			scsi_adjust_queue_depth(dev->scsi_device,
+						MSG_ORDERED_TASK,
+						dev->openings + dev->active);
+			break;
+		default:
+			/*
+			 * We allow the OS to queue 2 untagged transactions to
+			 * us at any time even though we can only execute them
+			 * serially on the controller/device.  This should
+			 * remove some latency.
+			 */
+			scsi_adjust_queue_depth(dev->scsi_device,
+						/*NON-TAGGED*/0,
+						/*queue depth*/2);
+			break;
+		}
+	}
+#endif
+}
+
+int
+ahd_platform_abort_scbs(struct ahd_softc *ahd, int target, char channel,
+			int lun, u_int tag, role_t role, uint32_t status)
+{
+	int targ;
+	int maxtarg;
+	int maxlun;
+	int clun;
+	int count;
+
+	if (tag != SCB_LIST_NULL)
+		return (0);
+
+	targ = 0;
+	if (target != CAM_TARGET_WILDCARD) {
+		targ = target;
+		maxtarg = targ + 1;
+	} else {
+		maxtarg = (ahd->features & AHD_WIDE) ? 16 : 8;
+	}
+	clun = 0;
+	if (lun != CAM_LUN_WILDCARD) {
+		clun = lun;
+		maxlun = clun + 1;
+	} else {
+		maxlun = AHD_NUM_LUNS;
+	}
+
+	count = 0;
+	for (; targ < maxtarg; targ++) {
+
+		for (; clun < maxlun; clun++) {
+			struct ahd_linux_device *dev;
+			struct ahd_busyq *busyq;
+			struct ahd_cmd *acmd;
+
+			dev = ahd_linux_get_device(ahd, /*chan*/0, targ,
+						   clun, /*alloc*/FALSE);
+			if (dev == NULL)
+				continue;
+
+			busyq = &dev->busyq;
+			while ((acmd = TAILQ_FIRST(busyq)) != NULL) {
+				Scsi_Cmnd *cmd;
+
+				cmd = &acmd_scsi_cmd(acmd);
+				TAILQ_REMOVE(busyq, acmd,
+					     acmd_links.tqe);
+				count++;
+				cmd->result = status << 16;
+				ahd_linux_queue_cmd_complete(ahd, cmd);
+			}
+		}
+	}
+
+	return (count);
+}
+
+static void
+ahd_linux_thread_run_complete_queue(struct ahd_softc *ahd)
+{
+	u_long flags;
+
+	ahd_lock(ahd, &flags);
+	del_timer(&ahd->platform_data->completeq_timer);
+	ahd->platform_data->flags &= ~AHD_RUN_CMPLT_Q_TIMER;
+	ahd_linux_run_complete_queue(ahd);
+	ahd_unlock(ahd, &flags);
+}
+
+static void
+ahd_linux_start_dv(struct ahd_softc *ahd)
+{
+
+	/*
+	 * Freeze the simq and signal ahd_linux_queue to not let any
+	 * more commands through
+	 */
+	if ((ahd->platform_data->flags & AHD_DV_ACTIVE) == 0) {
+#ifdef AHD_DEBUG
+		if (ahd_debug & AHD_SHOW_DV)
+			printf("%s: Starting DV\n", ahd_name(ahd));
+#endif
+
+		ahd->platform_data->flags |= AHD_DV_ACTIVE;
+		ahd_freeze_simq(ahd);
+
+		/* Wake up the DV kthread */
+		up(&ahd->platform_data->dv_sem);
+	}
+}
+
+static int
+ahd_linux_dv_thread(void *data)
+{
+	struct	ahd_softc *ahd;
+	int	target;
+	u_long	s;
+
+	ahd = (struct ahd_softc *)data;
+
+#ifdef AHD_DEBUG
+	if (ahd_debug & AHD_SHOW_DV)
+		printf("In DV Thread\n");
+#endif
+
+	/*
+	 * Complete thread creation.
+	 */
+	lock_kernel();
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,60)
+	/*
+	 * Don't care about any signals.
+	 */
+	siginitsetinv(&current->blocked, 0);
+
+	daemonize();
+	sprintf(current->comm, "ahd_dv_%d", ahd->unit);
+#else
+	daemonize("ahd_dv_%d", ahd->unit);
+#endif
+	unlock_kernel();
+
+	while (1) {
+		/*
+		 * Use down_interruptible() rather than down() to
+		 * avoid inclusion in the load average.
+		 */
+		down_interruptible(&ahd->platform_data->dv_sem);
+
+		/* Check to see if we've been signaled to exit */
+		ahd_lock(ahd, &s);
+		if ((ahd->platform_data->flags & AHD_DV_SHUTDOWN) != 0) {
+			ahd_unlock(ahd, &s);
+			break;
+		}
+		ahd_unlock(ahd, &s);
+
+#ifdef AHD_DEBUG
+		if (ahd_debug & AHD_SHOW_DV)
+			printf("%s: Beginning Domain Validation\n",
+			       ahd_name(ahd));
+#endif
+
+		/*
+		 * Wait for any pending commands to drain before proceeding.
+		 */
+		ahd_lock(ahd, &s);
+		while (LIST_FIRST(&ahd->pending_scbs) != NULL) {
+			ahd->platform_data->flags |= AHD_DV_WAIT_SIMQ_EMPTY;
+			ahd_unlock(ahd, &s);
+			down_interruptible(&ahd->platform_data->dv_sem);
+			ahd_lock(ahd, &s);
+		}
+
+		/*
+		 * Wait for the SIMQ to be released so that DV is the
+		 * only reason the queue is frozen.
+		 */
+		while (AHD_DV_SIMQ_FROZEN(ahd) == 0) {
+			ahd->platform_data->flags |= AHD_DV_WAIT_SIMQ_RELEASE;
+			ahd_unlock(ahd, &s);
+			down_interruptible(&ahd->platform_data->dv_sem);
+			ahd_lock(ahd, &s);
+		}
+		ahd_unlock(ahd, &s);
+
+		for (target = 0; target < AHD_NUM_TARGETS; target++)
+			ahd_linux_dv_target(ahd, target);
+
+		ahd_lock(ahd, &s);
+		ahd->platform_data->flags &= ~AHD_DV_ACTIVE;
+		ahd_unlock(ahd, &s);
+
+		/*
+		 * Release the SIMQ so that normal commands are
+		 * allowed to continue on the bus.
+		 */
+		ahd_release_simq(ahd);
+	}
+	up(&ahd->platform_data->eh_sem);
+	return (0);
+}
+
+static void
+ahd_linux_kill_dv_thread(struct ahd_softc *ahd)
+{
+	u_long s;
+
+	ahd_lock(ahd, &s);
+	if (ahd->platform_data->dv_pid != 0) {
+		ahd->platform_data->flags |= AHD_DV_SHUTDOWN;
+		ahd_unlock(ahd, &s);
+		up(&ahd->platform_data->dv_sem);
+
+		/*
+		 * Use the eh_sem as an indicator that the
+		 * dv thread is exiting.  Note that the dv
+		 * thread must still return after performing
+		 * the up on our semaphore before it has
+		 * completely exited this module.  Unfortunately,
+		 * there seems to be no easy way to wait for the
+		 * exit of a thread for which you are not the
+		 * parent (dv threads are parented by init).
+		 * Cross your fingers...
+		 */
+		down(&ahd->platform_data->eh_sem);
+
+		/*
+		 * Mark the dv thread as already dead.  This
+		 * avoids attempting to kill it a second time.
+		 * This is necessary because we must kill the
+		 * DV thread before calling ahd_free() in the
+		 * module shutdown case to avoid bogus locking
+		 * in the SCSI mid-layer, but we ahd_free() is
+		 * called without killing the DV thread in the
+		 * instance detach case, so ahd_platform_free()
+		 * calls us again to verify that the DV thread
+		 * is dead.
+		 */
+		ahd->platform_data->dv_pid = 0;
+	} else {
+		ahd_unlock(ahd, &s);
+	}
+}
+
+#define AHD_LINUX_DV_INQ_SHORT_LEN	36
+#define AHD_LINUX_DV_INQ_LEN		256
+#define AHD_LINUX_DV_TIMEOUT		(HZ / 4)
+
+#define AHD_SET_DV_STATE(ahd, targ, newstate) \
+	ahd_set_dv_state(ahd, targ, newstate, __LINE__)
+
+static __inline void
+ahd_set_dv_state(struct ahd_softc *ahd, struct ahd_linux_target *targ,
+		 ahd_dv_state newstate, u_int line)
+{
+	ahd_dv_state oldstate;
+
+	oldstate = targ->dv_state;
+#ifdef AHD_DEBUG
+	if (ahd_debug & AHD_SHOW_DV)
+		printf("%s:%d: Going from state %d to state %d\n",
+		       ahd_name(ahd), line, oldstate, newstate);
+#endif
+
+	if (oldstate == newstate)
+		targ->dv_state_retry++;
+	else
+		targ->dv_state_retry = 0;
+	targ->dv_state = newstate;
+}
+
+static void
+ahd_linux_dv_target(struct ahd_softc *ahd, u_int target_offset)
+{
+	struct	 ahd_devinfo devinfo;
+	struct	 ahd_linux_target *targ;
+	struct	 scsi_cmnd *cmd;
+	struct	 scsi_device *scsi_dev;
+	struct	 scsi_sense_data *sense;
+	uint8_t *buffer;
+	u_long	 s;
+	u_int	 timeout;
+	int	 echo_size;
+
+	sense = NULL;
+	buffer = NULL;
+	echo_size = 0;
+	ahd_lock(ahd, &s);
+	targ = ahd->platform_data->targets[target_offset];
+	if (targ == NULL || (targ->flags & AHD_DV_REQUIRED) == 0) {
+		ahd_unlock(ahd, &s);
+		return;
+	}
+	ahd_compile_devinfo(&devinfo, ahd->our_id, targ->target, /*lun*/0,
+			    targ->channel + 'A', ROLE_INITIATOR);
+#ifdef AHD_DEBUG
+	if (ahd_debug & AHD_SHOW_DV) {
+		ahd_print_devinfo(ahd, &devinfo);
+		printf("Performing DV\n");
+	}
+#endif
+
+	ahd_unlock(ahd, &s);
+
+	cmd = malloc(sizeof(struct scsi_cmnd), M_DEVBUF, M_WAITOK);
+	scsi_dev = malloc(sizeof(struct scsi_device), M_DEVBUF, M_WAITOK);
+	scsi_dev->host = ahd->platform_data->host;
+	scsi_dev->id = devinfo.target;
+	scsi_dev->lun = devinfo.lun;
+	scsi_dev->channel = devinfo.channel - 'A';
+	ahd->platform_data->dv_scsi_dev = scsi_dev;
+
+	AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_INQ_SHORT_ASYNC);
+
+	while (targ->dv_state != AHD_DV_STATE_EXIT) {
+		timeout = AHD_LINUX_DV_TIMEOUT;
+		switch (targ->dv_state) {
+		case AHD_DV_STATE_INQ_SHORT_ASYNC:
+		case AHD_DV_STATE_INQ_ASYNC:
+		case AHD_DV_STATE_INQ_ASYNC_VERIFY:
+			/*
+			 * Set things to async narrow to reduce the
+			 * chance that the INQ will fail.
+			 */
+			ahd_lock(ahd, &s);
+			ahd_set_syncrate(ahd, &devinfo, 0, 0, 0,
+					 AHD_TRANS_GOAL, /*paused*/FALSE);
+			ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
+				      AHD_TRANS_GOAL, /*paused*/FALSE);
+			ahd_unlock(ahd, &s);
+			timeout = 10 * HZ;
+			targ->flags &= ~AHD_INQ_VALID;
+			/* FALLTHROUGH */
+		case AHD_DV_STATE_INQ_VERIFY:
+		{
+			u_int inq_len;
+
+			if (targ->dv_state == AHD_DV_STATE_INQ_SHORT_ASYNC)
+				inq_len = AHD_LINUX_DV_INQ_SHORT_LEN;
+			else
+				inq_len = targ->inq_data->additional_length + 5;
+			ahd_linux_dv_inq(ahd, cmd, &devinfo, targ, inq_len);
+			break;
+		}
+		case AHD_DV_STATE_TUR:
+		case AHD_DV_STATE_BUSY:
+			timeout = 5 * HZ;
+			ahd_linux_dv_tur(ahd, cmd, &devinfo);
+			break;
+		case AHD_DV_STATE_REBD:
+			ahd_linux_dv_rebd(ahd, cmd, &devinfo, targ);
+			break;
+		case AHD_DV_STATE_WEB:
+			ahd_linux_dv_web(ahd, cmd, &devinfo, targ);
+			break;
+
+		case AHD_DV_STATE_REB:
+			ahd_linux_dv_reb(ahd, cmd, &devinfo, targ);
+			break;
+
+		case AHD_DV_STATE_SU:
+			ahd_linux_dv_su(ahd, cmd, &devinfo, targ);
+			timeout = 50 * HZ;
+			break;
+
+		default:
+			ahd_print_devinfo(ahd, &devinfo);
+			printf("Unknown DV state %d\n", targ->dv_state);
+			goto out;
+		}
+
+		/* Queue the command and wait for it to complete */
+		/* Abuse eh_timeout in the scsi_cmnd struct for our purposes */
+		init_timer(&cmd->eh_timeout);
+#ifdef AHD_DEBUG
+		if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
+			/*
+			 * All of the printfs during negotiation
+			 * really slow down the negotiation.
+			 * Add a bit of time just to be safe.
+			 */
+			timeout += HZ;
+#endif
+		scsi_add_timer(cmd, timeout, ahd_linux_dv_timeout);
+		/*
+		 * In 2.5.X, it is assumed that all calls from the
+		 * "midlayer" (which we are emulating) will have the
+		 * ahd host lock held.  For other kernels, the
+		 * io_request_lock must be held.
+		 */
+#if AHD_SCSI_HAS_HOST_LOCK != 0
+		ahd_lock(ahd, &s);
+#else
+		spin_lock_irqsave(&io_request_lock, s);
+#endif
+		ahd_linux_queue(cmd, ahd_linux_dv_complete);
+#if AHD_SCSI_HAS_HOST_LOCK != 0
+		ahd_unlock(ahd, &s);
+#else
+		spin_unlock_irqrestore(&io_request_lock, s);
+#endif
+		down_interruptible(&ahd->platform_data->dv_cmd_sem);
+		/*
+		 * Wait for the SIMQ to be released so that DV is the
+		 * only reason the queue is frozen.
+		 */
+		ahd_lock(ahd, &s);
+		while (AHD_DV_SIMQ_FROZEN(ahd) == 0) {
+			ahd->platform_data->flags |= AHD_DV_WAIT_SIMQ_RELEASE;
+			ahd_unlock(ahd, &s);
+			down_interruptible(&ahd->platform_data->dv_sem);
+			ahd_lock(ahd, &s);
+		}
+		ahd_unlock(ahd, &s);
+
+		ahd_linux_dv_transition(ahd, cmd, &devinfo, targ);
+	}
+
+out:
+	if ((targ->flags & AHD_INQ_VALID) != 0
+	 && ahd_linux_get_device(ahd, devinfo.channel - 'A',
+				 devinfo.target, devinfo.lun,
+				 /*alloc*/FALSE) == NULL) {
+		/*
+		 * The DV state machine failed to configure this device.  
+		 * This is normal if DV is disabled.  Since we have inquiry
+		 * data, filter it and use the "optimistic" negotiation
+		 * parameters found in the inquiry string.
+		 */
+		ahd_linux_filter_inquiry(ahd, &devinfo);
+		if ((targ->flags & (AHD_BASIC_DV|AHD_ENHANCED_DV)) != 0) {
+			ahd_print_devinfo(ahd, &devinfo);
+			printf("DV failed to configure device.  "
+			       "Please file a bug report against "
+			       "this driver.\n");
+		}
+	}
+
+	if (cmd != NULL)
+		free(cmd, M_DEVBUF);
+
+	if (ahd->platform_data->dv_scsi_dev != NULL) {
+		free(ahd->platform_data->dv_scsi_dev, M_DEVBUF);
+		ahd->platform_data->dv_scsi_dev = NULL;
+	}
+
+	ahd_lock(ahd, &s);
+	if (targ->dv_buffer != NULL) {
+		free(targ->dv_buffer, M_DEVBUF);
+		targ->dv_buffer = NULL;
+	}
+	if (targ->dv_buffer1 != NULL) {
+		free(targ->dv_buffer1, M_DEVBUF);
+		targ->dv_buffer1 = NULL;
+	}
+	targ->flags &= ~AHD_DV_REQUIRED;
+	if (targ->refcount == 0)
+		ahd_linux_free_target(ahd, targ);
+	ahd_unlock(ahd, &s);
+}
+
+static void
+ahd_linux_dv_transition(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
+			struct ahd_devinfo *devinfo,
+			struct ahd_linux_target *targ)
+{
+	u_int32_t status;
+
+	status = aic_error_action(cmd, targ->inq_data,
+				  ahd_cmd_get_transaction_status(cmd),
+				  ahd_cmd_get_scsi_status(cmd));
+
+	
+#ifdef AHD_DEBUG
+	if (ahd_debug & AHD_SHOW_DV) {
+		ahd_print_devinfo(ahd, devinfo);
+		printf("Entering ahd_linux_dv_transition, state= %d, "
+		       "status= 0x%x, cmd->result= 0x%x\n", targ->dv_state,
+		       status, cmd->result);
+	}
+#endif
+
+	switch (targ->dv_state) {
+	case AHD_DV_STATE_INQ_SHORT_ASYNC:
+	case AHD_DV_STATE_INQ_ASYNC:
+		switch (status & SS_MASK) {
+		case SS_NOP:
+		{
+			AHD_SET_DV_STATE(ahd, targ, targ->dv_state+1);
+			break;
+		}
+		case SS_INQ_REFRESH:
+			AHD_SET_DV_STATE(ahd, targ,
+					 AHD_DV_STATE_INQ_SHORT_ASYNC);
+			break;
+		case SS_TUR:
+		case SS_RETRY:
+			AHD_SET_DV_STATE(ahd, targ, targ->dv_state);
+			if (ahd_cmd_get_transaction_status(cmd)
+			 == CAM_REQUEUE_REQ)
+				targ->dv_state_retry--;
+			if ((status & SS_ERRMASK) == EBUSY)
+				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_BUSY);
+			if (targ->dv_state_retry < 10)
+				break;
+			/* FALLTHROUGH */
+		default:
+			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
+#ifdef AHD_DEBUG
+			if (ahd_debug & AHD_SHOW_DV) {
+				ahd_print_devinfo(ahd, devinfo);
+				printf("Failed DV inquiry, skipping\n");
+			}
+#endif
+			break;
+		}
+		break;
+	case AHD_DV_STATE_INQ_ASYNC_VERIFY:
+		switch (status & SS_MASK) {
+		case SS_NOP:
+		{
+			u_int xportflags;
+			u_int spi3data;
+
+			if (memcmp(targ->inq_data, targ->dv_buffer,
+				   AHD_LINUX_DV_INQ_LEN) != 0) {
+				/*
+				 * Inquiry data must have changed.
+				 * Try from the top again.
+				 */
+				AHD_SET_DV_STATE(ahd, targ,
+						 AHD_DV_STATE_INQ_SHORT_ASYNC);
+				break;
+			}
+
+			AHD_SET_DV_STATE(ahd, targ, targ->dv_state+1);
+			targ->flags |= AHD_INQ_VALID;
+			if (ahd_linux_user_dv_setting(ahd) == 0)
+				break;
+
+			xportflags = targ->inq_data->flags;
+			if ((xportflags & (SID_Sync|SID_WBus16)) == 0)
+				break;
+
+			spi3data = targ->inq_data->spi3data;
+			switch (spi3data & SID_SPI_CLOCK_DT_ST) {
+			default:
+			case SID_SPI_CLOCK_ST:
+				/* Assume only basic DV is supported. */
+				targ->flags |= AHD_BASIC_DV;
+				break;
+			case SID_SPI_CLOCK_DT:
+			case SID_SPI_CLOCK_DT_ST:
+				targ->flags |= AHD_ENHANCED_DV;
+				break;
+			}
+			break;
+		}
+		case SS_INQ_REFRESH:
+			AHD_SET_DV_STATE(ahd, targ,
+					 AHD_DV_STATE_INQ_SHORT_ASYNC);
+			break;
+		case SS_TUR:
+		case SS_RETRY:
+			AHD_SET_DV_STATE(ahd, targ, targ->dv_state);
+			if (ahd_cmd_get_transaction_status(cmd)
+			 == CAM_REQUEUE_REQ)
+				targ->dv_state_retry--;
+
+			if ((status & SS_ERRMASK) == EBUSY)
+				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_BUSY);
+			if (targ->dv_state_retry < 10)
+				break;
+			/* FALLTHROUGH */
+		default:
+			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
+#ifdef AHD_DEBUG
+			if (ahd_debug & AHD_SHOW_DV) {
+				ahd_print_devinfo(ahd, devinfo);
+				printf("Failed DV inquiry, skipping\n");
+			}
+#endif
+			break;
+		}
+		break;
+	case AHD_DV_STATE_INQ_VERIFY:
+		switch (status & SS_MASK) {
+		case SS_NOP:
+		{
+
+			if (memcmp(targ->inq_data, targ->dv_buffer,
+				   AHD_LINUX_DV_INQ_LEN) == 0) {
+				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
+				break;
+			}
+
+#ifdef AHD_DEBUG
+			if (ahd_debug & AHD_SHOW_DV) {
+				int i;
+
+				ahd_print_devinfo(ahd, devinfo);
+				printf("Inquiry buffer mismatch:");
+				for (i = 0; i < AHD_LINUX_DV_INQ_LEN; i++) {
+					if ((i & 0xF) == 0)
+						printf("\n        ");
+					printf("0x%x:0x0%x ",
+					       ((uint8_t *)targ->inq_data)[i], 
+					       targ->dv_buffer[i]);
+				}
+				printf("\n");
+			}
+#endif
+
+			if (ahd_linux_dv_fallback(ahd, devinfo) != 0) {
+				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
+				break;
+			}
+			/*
+			 * Do not count "falling back"
+			 * against our retries.
+			 */
+			targ->dv_state_retry = 0;
+			AHD_SET_DV_STATE(ahd, targ, targ->dv_state);
+			break;
+		}
+		case SS_INQ_REFRESH:
+			AHD_SET_DV_STATE(ahd, targ,
+					 AHD_DV_STATE_INQ_SHORT_ASYNC);
+			break;
+		case SS_TUR:
+		case SS_RETRY:
+			AHD_SET_DV_STATE(ahd, targ, targ->dv_state);
+			if (ahd_cmd_get_transaction_status(cmd)
+			 == CAM_REQUEUE_REQ) {
+				targ->dv_state_retry--;
+			} else if ((status & SSQ_FALLBACK) != 0) {
+				if (ahd_linux_dv_fallback(ahd, devinfo) != 0) {
+					AHD_SET_DV_STATE(ahd, targ,
+							 AHD_DV_STATE_EXIT);
+					break;
+				}
+				/*
+				 * Do not count "falling back"
+				 * against our retries.
+				 */
+				targ->dv_state_retry = 0;
+			} else if ((status & SS_ERRMASK) == EBUSY)
+				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_BUSY);
+			if (targ->dv_state_retry < 10)
+				break;
+			/* FALLTHROUGH */
+		default:
+			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
+#ifdef AHD_DEBUG
+			if (ahd_debug & AHD_SHOW_DV) {
+				ahd_print_devinfo(ahd, devinfo);
+				printf("Failed DV inquiry, skipping\n");
+			}
+#endif
+			break;
+		}
+		break;
+
+	case AHD_DV_STATE_TUR:
+		switch (status & SS_MASK) {
+		case SS_NOP:
+			if ((targ->flags & AHD_BASIC_DV) != 0) {
+				ahd_linux_filter_inquiry(ahd, devinfo);
+				AHD_SET_DV_STATE(ahd, targ,
+						 AHD_DV_STATE_INQ_VERIFY);
+			} else if ((targ->flags & AHD_ENHANCED_DV) != 0) {
+				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_REBD);
+			} else {
+				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
+			}
+			break;
+		case SS_RETRY:
+		case SS_TUR:
+			if ((status & SS_ERRMASK) == EBUSY) {
+				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_BUSY);
+				break;
+			}
+			AHD_SET_DV_STATE(ahd, targ, targ->dv_state);
+			if (ahd_cmd_get_transaction_status(cmd)
+			 == CAM_REQUEUE_REQ) {
+				targ->dv_state_retry--;
+			} else if ((status & SSQ_FALLBACK) != 0) {
+				if (ahd_linux_dv_fallback(ahd, devinfo) != 0) {
+					AHD_SET_DV_STATE(ahd, targ,
+							 AHD_DV_STATE_EXIT);
+					break;
+				}
+				/*
+				 * Do not count "falling back"
+				 * against our retries.
+				 */
+				targ->dv_state_retry = 0;
+			}
+			if (targ->dv_state_retry >= 10) {
+#ifdef AHD_DEBUG
+				if (ahd_debug & AHD_SHOW_DV) {
+					ahd_print_devinfo(ahd, devinfo);
+					printf("DV TUR reties exhausted\n");
+				}
+#endif
+				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
+				break;
+			}
+			if (status & SSQ_DELAY)
+				scsi_sleep(1 * HZ);
+
+			break;
+		case SS_START:
+			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_SU);
+			break;
+		case SS_INQ_REFRESH:
+			AHD_SET_DV_STATE(ahd, targ,
+					 AHD_DV_STATE_INQ_SHORT_ASYNC);
+			break;
+		default:
+			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
+			break;
+		}
+		break;
+
+	case AHD_DV_STATE_REBD:
+		switch (status & SS_MASK) {
+		case SS_NOP:
+		{
+			uint32_t echo_size;
+
+			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_WEB);
+			echo_size = scsi_3btoul(&targ->dv_buffer[1]);
+			echo_size &= 0x1FFF;
+#ifdef AHD_DEBUG
+			if (ahd_debug & AHD_SHOW_DV) {
+				ahd_print_devinfo(ahd, devinfo);
+				printf("Echo buffer size= %d\n", echo_size);
+			}
+#endif
+			if (echo_size == 0) {
+				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
+				break;
+			}
+
+			/* Generate the buffer pattern */
+			targ->dv_echo_size = echo_size;
+			ahd_linux_generate_dv_pattern(targ);
+			/*
+			 * Setup initial negotiation values.
+			 */
+			ahd_linux_filter_inquiry(ahd, devinfo);
+			break;
+		}
+		case SS_INQ_REFRESH:
+			AHD_SET_DV_STATE(ahd, targ,
+					 AHD_DV_STATE_INQ_SHORT_ASYNC);
+			break;
+		case SS_RETRY:
+			AHD_SET_DV_STATE(ahd, targ, targ->dv_state);
+			if (ahd_cmd_get_transaction_status(cmd)
+			 == CAM_REQUEUE_REQ)
+				targ->dv_state_retry--;
+			if (targ->dv_state_retry <= 10)
+				break;
+#ifdef AHD_DEBUG
+			if (ahd_debug & AHD_SHOW_DV) {
+				ahd_print_devinfo(ahd, devinfo);
+				printf("DV REBD reties exhausted\n");
+			}
+#endif
+			/* FALLTHROUGH */
+		case SS_FATAL:
+		default:
+			/*
+			 * Setup initial negotiation values
+			 * and try level 1 DV.
+			 */
+			ahd_linux_filter_inquiry(ahd, devinfo);
+			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_INQ_VERIFY);
+			targ->dv_echo_size = 0;
+			break;
+		}
+		break;
+
+	case AHD_DV_STATE_WEB:
+		switch (status & SS_MASK) {
+		case SS_NOP:
+			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_REB);
+			break;
+		case SS_INQ_REFRESH:
+			AHD_SET_DV_STATE(ahd, targ,
+					 AHD_DV_STATE_INQ_SHORT_ASYNC);
+			break;
+		case SS_RETRY:
+			AHD_SET_DV_STATE(ahd, targ, targ->dv_state);
+			if (ahd_cmd_get_transaction_status(cmd)
+			 == CAM_REQUEUE_REQ) {
+				targ->dv_state_retry--;
+			} else if ((status & SSQ_FALLBACK) != 0) {
+				if (ahd_linux_dv_fallback(ahd, devinfo) != 0) {
+					AHD_SET_DV_STATE(ahd, targ,
+							 AHD_DV_STATE_EXIT);
+					break;
+				}
+				/*
+				 * Do not count "falling back"
+				 * against our retries.
+				 */
+				targ->dv_state_retry = 0;
+			}
+			if (targ->dv_state_retry <= 10)
+				break;
+			/* FALLTHROUGH */
+#ifdef AHD_DEBUG
+			if (ahd_debug & AHD_SHOW_DV) {
+				ahd_print_devinfo(ahd, devinfo);
+				printf("DV WEB reties exhausted\n");
+			}
+#endif
+		default:
+			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
+			break;
+		}
+		break;
+
+	case AHD_DV_STATE_REB:
+		switch (status & SS_MASK) {
+		case SS_NOP:
+			if (memcmp(targ->dv_buffer, targ->dv_buffer1,
+				   targ->dv_echo_size) != 0) {
+				if (ahd_linux_dv_fallback(ahd, devinfo) != 0)
+					AHD_SET_DV_STATE(ahd, targ,
+							 AHD_DV_STATE_EXIT);
+				else
+					AHD_SET_DV_STATE(ahd, targ,
+							 AHD_DV_STATE_WEB);
+				break;
+			}
+			
+			if (targ->dv_buffer != NULL) {
+				free(targ->dv_buffer, M_DEVBUF);
+				targ->dv_buffer = NULL;
+			}
+			if (targ->dv_buffer1 != NULL) {
+				free(targ->dv_buffer1, M_DEVBUF);
+				targ->dv_buffer1 = NULL;
+			}
+			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
+			break;
+		case SS_INQ_REFRESH:
+			AHD_SET_DV_STATE(ahd, targ,
+					 AHD_DV_STATE_INQ_SHORT_ASYNC);
+			break;
+		case SS_RETRY:
+			AHD_SET_DV_STATE(ahd, targ, targ->dv_state);
+			if (ahd_cmd_get_transaction_status(cmd)
+			 == CAM_REQUEUE_REQ) {
+				targ->dv_state_retry--;
+			} else if ((status & SSQ_FALLBACK) != 0) {
+				if (ahd_linux_dv_fallback(ahd, devinfo) != 0) {
+					AHD_SET_DV_STATE(ahd, targ,
+							 AHD_DV_STATE_EXIT);
+					break;
+				}
+				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_WEB);
+			}
+			if (targ->dv_state_retry <= 10) {
+				if ((status & (SSQ_DELAY_RANDOM|SSQ_DELAY))!= 0)
+					scsi_sleep(ahd->our_id*HZ/10);
+				break;
+			}
+#ifdef AHD_DEBUG
+			if (ahd_debug & AHD_SHOW_DV) {
+				ahd_print_devinfo(ahd, devinfo);
+				printf("DV REB reties exhausted\n");
+			}
+#endif
+			/* FALLTHROUGH */
+		default:
+			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
+			break;
+		}
+		break;
+
+	case AHD_DV_STATE_SU:
+		switch (status & SS_MASK) {
+		case SS_NOP:
+		case SS_INQ_REFRESH:
+			AHD_SET_DV_STATE(ahd, targ,
+					 AHD_DV_STATE_INQ_SHORT_ASYNC);
+			break;
+		default:
+			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
+			break;
+		}
+		break;
+
+	case AHD_DV_STATE_BUSY:
+		switch (status & SS_MASK) {
+		case SS_NOP:
+		case SS_INQ_REFRESH:
+			AHD_SET_DV_STATE(ahd, targ,
+					 AHD_DV_STATE_INQ_SHORT_ASYNC);
+			break;
+		case SS_TUR:
+		case SS_RETRY:
+			AHD_SET_DV_STATE(ahd, targ, targ->dv_state);
+			if (ahd_cmd_get_transaction_status(cmd)
+			 == CAM_REQUEUE_REQ) {
+				targ->dv_state_retry--;
+			} else if (targ->dv_state_retry < 60) {
+				if ((status & SSQ_DELAY) != 0)
+					scsi_sleep(1 * HZ);
+			} else {
+#ifdef AHD_DEBUG
+				if (ahd_debug & AHD_SHOW_DV) {
+					ahd_print_devinfo(ahd, devinfo);
+					printf("DV BUSY reties exhausted\n");
+				}
+#endif
+				AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
+			}
+			break;
+		default:
+			AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
+			break;
+		}
+		break;
+
+	default:
+		printf("%s: Invalid DV completion state %d\n", ahd_name(ahd),
+		       targ->dv_state);
+		AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT);
+		break;
+	}
+}
+
+static void
+ahd_linux_dv_fill_cmd(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
+		      struct ahd_devinfo *devinfo)
+{
+	memset(cmd, 0, sizeof(struct scsi_cmnd));
+	cmd->device = ahd->platform_data->dv_scsi_dev;
+	cmd->scsi_done = ahd_linux_dv_complete;
+}
+
+/*
+ * Synthesize an inquiry command.  On the return trip, it'll be
+ * sniffed and the device transfer settings set for us.
+ */
+static void
+ahd_linux_dv_inq(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
+		 struct ahd_devinfo *devinfo, struct ahd_linux_target *targ,
+		 u_int request_length)
+{
+
+#ifdef AHD_DEBUG
+	if (ahd_debug & AHD_SHOW_DV) {
+		ahd_print_devinfo(ahd, devinfo);
+		printf("Sending INQ\n");
+	}
+#endif
+	if (targ->inq_data == NULL)
+		targ->inq_data = malloc(AHD_LINUX_DV_INQ_LEN,
+					M_DEVBUF, M_WAITOK);
+	if (targ->dv_state > AHD_DV_STATE_INQ_ASYNC) {
+		if (targ->dv_buffer != NULL)
+			free(targ->dv_buffer, M_DEVBUF);
+		targ->dv_buffer = malloc(AHD_LINUX_DV_INQ_LEN,
+					 M_DEVBUF, M_WAITOK);
+	}
+
+	ahd_linux_dv_fill_cmd(ahd, cmd, devinfo);
+	cmd->sc_data_direction = SCSI_DATA_READ;
+	cmd->cmd_len = 6;
+	cmd->cmnd[0] = INQUIRY;
+	cmd->cmnd[4] = request_length;
+	cmd->request_bufflen = request_length;
+	if (targ->dv_state > AHD_DV_STATE_INQ_ASYNC)
+		cmd->request_buffer = targ->dv_buffer;
+	else
+		cmd->request_buffer = targ->inq_data;
+	memset(cmd->request_buffer, 0, AHD_LINUX_DV_INQ_LEN);
+}
+
+static void
+ahd_linux_dv_tur(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
+		 struct ahd_devinfo *devinfo)
+{
+
+#ifdef AHD_DEBUG
+	if (ahd_debug & AHD_SHOW_DV) {
+		ahd_print_devinfo(ahd, devinfo);
+		printf("Sending TUR\n");
+	}
+#endif
+	/* Do a TUR to clear out any non-fatal transitional state */
+	ahd_linux_dv_fill_cmd(ahd, cmd, devinfo);
+	cmd->sc_data_direction = SCSI_DATA_NONE;
+	cmd->cmd_len = 6;
+	cmd->cmnd[0] = TEST_UNIT_READY;
+}
+
+#define AHD_REBD_LEN 4
+
+static void
+ahd_linux_dv_rebd(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
+		 struct ahd_devinfo *devinfo, struct ahd_linux_target *targ)
+{
+
+#ifdef AHD_DEBUG
+	if (ahd_debug & AHD_SHOW_DV) {
+		ahd_print_devinfo(ahd, devinfo);
+		printf("Sending REBD\n");
+	}
+#endif
+	if (targ->dv_buffer != NULL)
+		free(targ->dv_buffer, M_DEVBUF);
+	targ->dv_buffer = malloc(AHD_REBD_LEN, M_DEVBUF, M_WAITOK);
+	ahd_linux_dv_fill_cmd(ahd, cmd, devinfo);
+	cmd->sc_data_direction = SCSI_DATA_READ;
+	cmd->cmd_len = 10;
+	cmd->cmnd[0] = READ_BUFFER;
+	cmd->cmnd[1] = 0x0b;
+	scsi_ulto3b(AHD_REBD_LEN, &cmd->cmnd[6]);
+	cmd->request_bufflen = AHD_REBD_LEN;
+	cmd->underflow = cmd->request_bufflen;
+	cmd->request_buffer = targ->dv_buffer;
+}
+
+static void
+ahd_linux_dv_web(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
+		 struct ahd_devinfo *devinfo, struct ahd_linux_target *targ)
+{
+
+#ifdef AHD_DEBUG
+	if (ahd_debug & AHD_SHOW_DV) {
+		ahd_print_devinfo(ahd, devinfo);
+		printf("Sending WEB\n");
+	}
+#endif
+	ahd_linux_dv_fill_cmd(ahd, cmd, devinfo);
+	cmd->sc_data_direction = SCSI_DATA_WRITE;
+	cmd->cmd_len = 10;
+	cmd->cmnd[0] = WRITE_BUFFER;
+	cmd->cmnd[1] = 0x0a;
+	scsi_ulto3b(targ->dv_echo_size, &cmd->cmnd[6]);
+	cmd->request_bufflen = targ->dv_echo_size;
+	cmd->underflow = cmd->request_bufflen;
+	cmd->request_buffer = targ->dv_buffer;
+}
+
+static void
+ahd_linux_dv_reb(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
+		 struct ahd_devinfo *devinfo, struct ahd_linux_target *targ)
+{
+
+#ifdef AHD_DEBUG
+	if (ahd_debug & AHD_SHOW_DV) {
+		ahd_print_devinfo(ahd, devinfo);
+		printf("Sending REB\n");
+	}
+#endif
+	ahd_linux_dv_fill_cmd(ahd, cmd, devinfo);
+	cmd->sc_data_direction = SCSI_DATA_READ;
+	cmd->cmd_len = 10;
+	cmd->cmnd[0] = READ_BUFFER;
+	cmd->cmnd[1] = 0x0a;
+	scsi_ulto3b(targ->dv_echo_size, &cmd->cmnd[6]);
+	cmd->request_bufflen = targ->dv_echo_size;
+	cmd->underflow = cmd->request_bufflen;
+	cmd->request_buffer = targ->dv_buffer1;
+}
+
+static void
+ahd_linux_dv_su(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
+		struct ahd_devinfo *devinfo,
+		struct ahd_linux_target *targ)
+{
+	u_int le;
+
+	le = SID_IS_REMOVABLE(targ->inq_data) ? SSS_LOEJ : 0;
+
+#ifdef AHD_DEBUG
+	if (ahd_debug & AHD_SHOW_DV) {
+		ahd_print_devinfo(ahd, devinfo);
+		printf("Sending SU\n");
+	}
+#endif
+	ahd_linux_dv_fill_cmd(ahd, cmd, devinfo);
+	cmd->sc_data_direction = SCSI_DATA_NONE;
+	cmd->cmd_len = 6;
+	cmd->cmnd[0] = START_STOP_UNIT;
+	cmd->cmnd[4] = le | SSS_START;
+}
+
+static __inline int
+ahd_linux_dv_fallback(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
+{
+	u_long s;
+	int retval;
+
+	ahd_lock(ahd, &s);
+	retval = ahd_linux_fallback(ahd, devinfo);
+	ahd_unlock(ahd, &s);
+
+	return (retval);
+}
+
+static int
+ahd_linux_fallback(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
+{
+	struct	ahd_linux_target *targ;
+	struct	ahd_initiator_tinfo *tinfo;
+	struct	ahd_transinfo *goal;
+	struct	ahd_tmode_tstate *tstate;
+	u_int	width;
+	u_int	period;
+	u_int	offset;
+	u_int	ppr_options;
+	u_int	cur_speed;
+	u_int	wide_speed;
+	u_int	narrow_speed;
+	u_int	fallback_speed;
+
+#ifdef AHD_DEBUG
+	if (ahd_debug & AHD_SHOW_DV) {
+		ahd_print_devinfo(ahd, devinfo);
+		printf("Trying to fallback\n");
+	}
+#endif
+	targ = ahd->platform_data->targets[devinfo->target_offset];
+	tinfo = ahd_fetch_transinfo(ahd, devinfo->channel,
+				    devinfo->our_scsiid,
+				    devinfo->target, &tstate);
+	goal = &tinfo->goal;
+	width = goal->width;
+	period = goal->period;
+	offset = goal->offset;
+	ppr_options = goal->ppr_options;
+	if (offset == 0)
+		period = AHD_ASYNC_XFER_PERIOD;
+	if (targ->dv_next_narrow_period == 0)
+		targ->dv_next_narrow_period = MAX(period, AHD_SYNCRATE_ULTRA2);
+	if (targ->dv_next_wide_period == 0)
+		targ->dv_next_wide_period = period;
+	if (targ->dv_max_width == 0)
+		targ->dv_max_width = width;
+	if (targ->dv_max_ppr_options == 0)
+		targ->dv_max_ppr_options = ppr_options;
+	if (targ->dv_last_ppr_options == 0)
+		targ->dv_last_ppr_options = ppr_options;
+
+	cur_speed = aic_calc_speed(width, period, offset, AHD_SYNCRATE_MIN);
+	wide_speed = aic_calc_speed(MSG_EXT_WDTR_BUS_16_BIT,
+					  targ->dv_next_wide_period,
+					  MAX_OFFSET, AHD_SYNCRATE_MIN);
+	narrow_speed = aic_calc_speed(MSG_EXT_WDTR_BUS_8_BIT,
+					    targ->dv_next_narrow_period,
+					    MAX_OFFSET, AHD_SYNCRATE_MIN);
+	fallback_speed = aic_calc_speed(width, period+1, offset,
+					      AHD_SYNCRATE_MIN);
+#ifdef AHD_DEBUG
+	if (ahd_debug & AHD_SHOW_DV) {
+		printf("cur_speed= %d, wide_speed= %d, narrow_speed= %d, "
+		       "fallback_speed= %d\n", cur_speed, wide_speed,
+		       narrow_speed, fallback_speed);
+	}
+#endif
+
+	if (cur_speed > 160000) {
+		/*
+		 * Paced/DT/IU_REQ only transfer speeds.  All we
+		 * can do is fallback in terms of syncrate.
+		 */
+		period++;
+	} else if (cur_speed > 80000) {
+		if ((ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
+			/*
+			 * Try without IU_REQ as it may be confusing
+			 * an expander.
+			 */
+			ppr_options &= ~MSG_EXT_PPR_IU_REQ;
+		} else {
+			/*
+			 * Paced/DT only transfer speeds.  All we
+			 * can do is fallback in terms of syncrate.
+			 */
+			period++;
+			ppr_options = targ->dv_max_ppr_options;
+		}
+	} else if (cur_speed > 3300) {
+
+		/*
+		 * In this range we the following
+		 * options ordered from highest to
+		 * lowest desireability:
+		 *
+		 * o Wide/DT
+		 * o Wide/non-DT
+		 * o Narrow at a potentally higher sync rate.
+		 *
+		 * All modes are tested with and without IU_REQ
+		 * set since using IUs may confuse an expander.
+		 */
+		if ((ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
+
+			ppr_options &= ~MSG_EXT_PPR_IU_REQ;
+		} else if ((ppr_options & MSG_EXT_PPR_DT_REQ) != 0) {
+			/*
+			 * Try going non-DT.
+			 */
+			ppr_options = targ->dv_max_ppr_options;
+			ppr_options &= ~MSG_EXT_PPR_DT_REQ;
+		} else if (targ->dv_last_ppr_options != 0) {
+			/*
+			 * Try without QAS or any other PPR options.
+			 * We may need a non-PPR message to work with
+			 * an expander.  We look at the "last PPR options"
+			 * so we will perform this fallback even if the
+			 * target responded to our PPR negotiation with
+			 * no option bits set.
+			 */
+			ppr_options = 0;
+		} else if (width == MSG_EXT_WDTR_BUS_16_BIT) {
+			/*
+			 * If the next narrow speed is greater than
+			 * the next wide speed, fallback to narrow.
+			 * Otherwise fallback to the next DT/Wide setting.
+			 * The narrow async speed will always be smaller
+			 * than the wide async speed, so handle this case
+			 * specifically.
+			 */
+			ppr_options = targ->dv_max_ppr_options;
+			if (narrow_speed > fallback_speed
+			 || period >= AHD_ASYNC_XFER_PERIOD) {
+				targ->dv_next_wide_period = period+1;
+				width = MSG_EXT_WDTR_BUS_8_BIT;
+				period = targ->dv_next_narrow_period;
+			} else {
+				period++;
+			}
+		} else if ((ahd->features & AHD_WIDE) != 0
+			&& targ->dv_max_width != 0
+			&& wide_speed >= fallback_speed
+			&& (targ->dv_next_wide_period <= AHD_ASYNC_XFER_PERIOD
+			 || period >= AHD_ASYNC_XFER_PERIOD)) {
+
+			/*
+			 * We are narrow.  Try falling back
+			 * to the next wide speed with 
+			 * all supported ppr options set.
+			 */
+			targ->dv_next_narrow_period = period+1;
+			width = MSG_EXT_WDTR_BUS_16_BIT;
+			period = targ->dv_next_wide_period;
+			ppr_options = targ->dv_max_ppr_options;
+		} else {
+			/* Only narrow fallback is allowed. */
+			period++;
+			ppr_options = targ->dv_max_ppr_options;
+		}
+	} else {
+		return (-1);
+	}
+	offset = MAX_OFFSET;
+	ahd_find_syncrate(ahd, &period, &ppr_options, AHD_SYNCRATE_PACED);
+	ahd_set_width(ahd, devinfo, width, AHD_TRANS_GOAL, FALSE);
+	if (period == 0) {
+		period = 0;
+		offset = 0;
+		ppr_options = 0;
+		if (width == MSG_EXT_WDTR_BUS_8_BIT)
+			targ->dv_next_narrow_period = AHD_ASYNC_XFER_PERIOD;
+		else
+			targ->dv_next_wide_period = AHD_ASYNC_XFER_PERIOD;
+	}
+	ahd_set_syncrate(ahd, devinfo, period, offset,
+			 ppr_options, AHD_TRANS_GOAL, FALSE);
+	targ->dv_last_ppr_options = ppr_options;
+	return (0);
+}
+
+static void
+ahd_linux_dv_timeout(struct scsi_cmnd *cmd)
+{
+	struct	ahd_softc *ahd;
+	struct	scb *scb;
+	u_long	flags;
+
+	ahd = *((struct ahd_softc **)cmd->device->host->hostdata);
+	ahd_lock(ahd, &flags);
+
+#ifdef AHD_DEBUG
+	if (ahd_debug & AHD_SHOW_DV) {
+		printf("%s: Timeout while doing DV command %x.\n",
+		       ahd_name(ahd), cmd->cmnd[0]);
+		ahd_dump_card_state(ahd);
+	}
+#endif
+	
+	/*
+	 * Guard against "done race".  No action is
+	 * required if we just completed.
+	 */
+	if ((scb = (struct scb *)cmd->host_scribble) == NULL) {
+		ahd_unlock(ahd, &flags);
+		return;
+	}
+
+	/*
+	 * Command has not completed.  Mark this
+	 * SCB as having failing status prior to
+	 * resetting the bus, so we get the correct
+	 * error code.
+	 */
+	if ((scb->flags & SCB_SENSE) != 0)
+		ahd_set_transaction_status(scb, CAM_AUTOSENSE_FAIL);
+	else
+		ahd_set_transaction_status(scb, CAM_CMD_TIMEOUT);
+	ahd_reset_channel(ahd, cmd->device->channel + 'A', /*initiate*/TRUE);
+
+	/*
+	 * Add a minimal bus settle delay for devices that are slow to
+	 * respond after bus resets.
+	 */
+	ahd_freeze_simq(ahd);
+	init_timer(&ahd->platform_data->reset_timer);
+	ahd->platform_data->reset_timer.data = (u_long)ahd;
+	ahd->platform_data->reset_timer.expires = jiffies + HZ / 2;
+	ahd->platform_data->reset_timer.function =
+	    (ahd_linux_callback_t *)ahd_release_simq;
+	add_timer(&ahd->platform_data->reset_timer);
+	if (ahd_linux_next_device_to_run(ahd) != NULL)
+		ahd_schedule_runq(ahd);
+	ahd_linux_run_complete_queue(ahd);
+	ahd_unlock(ahd, &flags);
+}
+
+static void
+ahd_linux_dv_complete(struct scsi_cmnd *cmd)
+{
+	struct ahd_softc *ahd;
+
+	ahd = *((struct ahd_softc **)cmd->device->host->hostdata);
+
+	/* Delete the DV timer before it goes off! */
+	scsi_delete_timer(cmd);
+
+#ifdef AHD_DEBUG
+	if (ahd_debug & AHD_SHOW_DV)
+		printf("%s:%c:%d: Command completed, status= 0x%x\n",
+		       ahd_name(ahd), cmd->device->channel, cmd->device->id,
+		       cmd->result);
+#endif
+
+	/* Wake up the state machine */
+	up(&ahd->platform_data->dv_cmd_sem);
+}
+
+static void
+ahd_linux_generate_dv_pattern(struct ahd_linux_target *targ)
+{
+	uint16_t b;
+	u_int	 i;
+	u_int	 j;
+
+	if (targ->dv_buffer != NULL)
+		free(targ->dv_buffer, M_DEVBUF);
+	targ->dv_buffer = malloc(targ->dv_echo_size, M_DEVBUF, M_WAITOK);
+	if (targ->dv_buffer1 != NULL)
+		free(targ->dv_buffer1, M_DEVBUF);
+	targ->dv_buffer1 = malloc(targ->dv_echo_size, M_DEVBUF, M_WAITOK);
+
+	i = 0;
+
+	b = 0x0001;
+	for (j = 0 ; i < targ->dv_echo_size; j++) {
+		if (j < 32) {
+			/*
+			 * 32bytes of sequential numbers.
+			 */
+			targ->dv_buffer[i++] = j & 0xff;
+		} else if (j < 48) {
+			/*
+			 * 32bytes of repeating 0x0000, 0xffff.
+			 */
+			targ->dv_buffer[i++] = (j & 0x02) ? 0xff : 0x00;
+		} else if (j < 64) {
+			/*
+			 * 32bytes of repeating 0x5555, 0xaaaa.
+			 */
+			targ->dv_buffer[i++] = (j & 0x02) ? 0xaa : 0x55;
+		} else {
+			/*
+			 * Remaining buffer is filled with a repeating
+			 * patter of:
+			 *
+			 *	 0xffff
+			 *	~0x0001 << shifted once in each loop.
+			 */
+			if (j & 0x02) {
+				if (j & 0x01) {
+					targ->dv_buffer[i++] = ~(b >> 8) & 0xff;
+					b <<= 1;
+					if (b == 0x0000)
+						b = 0x0001;
+				} else {
+					targ->dv_buffer[i++] = (~b & 0xff);
+				}
+			} else {
+				targ->dv_buffer[i++] = 0xff;
+			}
+		}
+	}
+}
+
+static u_int
+ahd_linux_user_tagdepth(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
+{
+	static int warned_user;
+	u_int tags;
+
+	tags = 0;
+	if ((ahd->user_discenable & devinfo->target_mask) != 0) {
+		if (ahd->unit >= NUM_ELEMENTS(aic79xx_tag_info)) {
+
+			if (warned_user == 0) {
+				printf(KERN_WARNING
+"aic79xx: WARNING: Insufficient tag_info instances\n"
+"aic79xx: for installed controllers.  Using defaults\n"
+"aic79xx: Please update the aic79xx_tag_info array in\n"
+"aic79xx: the aic79xx_osm.c source file.\n");
+				warned_user++;
+			}
+			tags = AHD_MAX_QUEUE;
+		} else {
+			adapter_tag_info_t *tag_info;
+
+			tag_info = &aic79xx_tag_info[ahd->unit];
+			tags = tag_info->tag_commands[devinfo->target_offset];
+			if (tags > AHD_MAX_QUEUE)
+				tags = AHD_MAX_QUEUE;
+		}
+	}
+	return (tags);
+}
+
+static u_int
+ahd_linux_user_dv_setting(struct ahd_softc *ahd)
+{
+	static int warned_user;
+	int dv;
+
+	if (ahd->unit >= NUM_ELEMENTS(aic79xx_dv_settings)) {
+
+		if (warned_user == 0) {
+			printf(KERN_WARNING
+"aic79xx: WARNING: Insufficient dv settings instances\n"
+"aic79xx: for installed controllers. Using defaults\n"
+"aic79xx: Please update the aic79xx_dv_settings array in"
+"aic79xx: the aic79xx_osm.c source file.\n");
+			warned_user++;
+		}
+		dv = -1;
+	} else {
+
+		dv = aic79xx_dv_settings[ahd->unit];
+	}
+
+	if (dv < 0) {
+		/*
+		 * Apply the default.
+		 */
+		dv = 1;
+		if (ahd->seep_config != 0)
+			dv = (ahd->seep_config->bios_control & CFENABLEDV);
+	}
+	return (dv);
+}
+
+static void
+ahd_linux_setup_user_rd_strm_settings(struct ahd_softc *ahd)
+{
+	static	int warned_user;
+	u_int	rd_strm_mask;
+	u_int	target_id;
+
+	/*
+	 * If we have specific read streaming info for this controller,
+	 * apply it.  Otherwise use the defaults.
+	 */
+	 if (ahd->unit >= NUM_ELEMENTS(aic79xx_rd_strm_info)) {
+
+		if (warned_user == 0) {
+
+			printf(KERN_WARNING
+"aic79xx: WARNING: Insufficient rd_strm instances\n"
+"aic79xx: for installed controllers. Using defaults\n"
+"aic79xx: Please update the aic79xx_rd_strm_info array\n"
+"aic79xx: in the aic79xx_osm.c source file.\n");
+			warned_user++;
+		}
+		rd_strm_mask = AIC79XX_CONFIGED_RD_STRM;
+	} else {
+
+		rd_strm_mask = aic79xx_rd_strm_info[ahd->unit];
+	}
+	for (target_id = 0; target_id < 16; target_id++) {
+		struct ahd_devinfo devinfo;
+		struct ahd_initiator_tinfo *tinfo;
+		struct ahd_tmode_tstate *tstate;
+
+		tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
+					    target_id, &tstate);
+		ahd_compile_devinfo(&devinfo, ahd->our_id, target_id,
+				    CAM_LUN_WILDCARD, 'A', ROLE_INITIATOR);
+		tinfo->user.ppr_options &= ~MSG_EXT_PPR_RD_STRM;
+		if ((rd_strm_mask & devinfo.target_mask) != 0)
+			tinfo->user.ppr_options |= MSG_EXT_PPR_RD_STRM;
+	}
+}
+
+/*
+ * Determines the queue depth for a given device.
+ */
+static void
+ahd_linux_device_queue_depth(struct ahd_softc *ahd,
+			     struct ahd_linux_device *dev)
+{
+	struct	ahd_devinfo devinfo;
+	u_int	tags;
+
+	ahd_compile_devinfo(&devinfo,
+			    ahd->our_id,
+			    dev->target->target, dev->lun,
+			    dev->target->channel == 0 ? 'A' : 'B',
+			    ROLE_INITIATOR);
+	tags = ahd_linux_user_tagdepth(ahd, &devinfo);
+	if (tags != 0
+	 && dev->scsi_device != NULL
+	 && dev->scsi_device->tagged_supported != 0) {
+
+		ahd_set_tags(ahd, &devinfo, AHD_QUEUE_TAGGED);
+		ahd_print_devinfo(ahd, &devinfo);
+		printf("Tagged Queuing enabled.  Depth %d\n", tags);
+	} else {
+		ahd_set_tags(ahd, &devinfo, AHD_QUEUE_NONE);
+	}
+}
+
+static void
+ahd_linux_run_device_queue(struct ahd_softc *ahd, struct ahd_linux_device *dev)
+{
+	struct	 ahd_cmd *acmd;
+	struct	 scsi_cmnd *cmd;
+	struct	 scb *scb;
+	struct	 hardware_scb *hscb;
+	struct	 ahd_initiator_tinfo *tinfo;
+	struct	 ahd_tmode_tstate *tstate;
+	u_int	 col_idx;
+	uint16_t mask;
+
+	if ((dev->flags & AHD_DEV_ON_RUN_LIST) != 0)
+		panic("running device on run list");
+
+	while ((acmd = TAILQ_FIRST(&dev->busyq)) != NULL
+	    && dev->openings > 0 && dev->qfrozen == 0) {
+
+		/*
+		 * Schedule us to run later.  The only reason we are not
+		 * running is because the whole controller Q is frozen.
+		 */
+		if (ahd->platform_data->qfrozen != 0
+		 && AHD_DV_SIMQ_FROZEN(ahd) == 0) {
+
+			TAILQ_INSERT_TAIL(&ahd->platform_data->device_runq,
+					  dev, links);
+			dev->flags |= AHD_DEV_ON_RUN_LIST;
+			return;
+		}
+
+		cmd = &acmd_scsi_cmd(acmd);
+
+		/*
+		 * Get an scb to use.
+		 */
+		tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
+					    cmd->device->id, &tstate);
+		if ((dev->flags & (AHD_DEV_Q_TAGGED|AHD_DEV_Q_BASIC)) == 0
+		 || (tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
+			col_idx = AHD_NEVER_COL_IDX;
+		} else {
+			col_idx = AHD_BUILD_COL_IDX(cmd->device->id,
+						    cmd->device->lun);
+		}
+		if ((scb = ahd_get_scb(ahd, col_idx)) == NULL) {
+			TAILQ_INSERT_TAIL(&ahd->platform_data->device_runq,
+					 dev, links);
+			dev->flags |= AHD_DEV_ON_RUN_LIST;
+			ahd->flags |= AHD_RESOURCE_SHORTAGE;
+			return;
+		}
+		TAILQ_REMOVE(&dev->busyq, acmd, acmd_links.tqe);
+		scb->io_ctx = cmd;
+		scb->platform_data->dev = dev;
+		hscb = scb->hscb;
+		cmd->host_scribble = (char *)scb;
+
+		/*
+		 * Fill out basics of the HSCB.
+		 */
+		hscb->control = 0;
+		hscb->scsiid = BUILD_SCSIID(ahd, cmd);
+		hscb->lun = cmd->device->lun;
+		scb->hscb->task_management = 0;
+		mask = SCB_GET_TARGET_MASK(ahd, scb);
+
+		if ((ahd->user_discenable & mask) != 0)
+			hscb->control |= DISCENB;
+
+	 	if (AHD_DV_CMD(cmd) != 0)
+			scb->flags |= SCB_SILENT;
+
+		if ((tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0)
+			scb->flags |= SCB_PACKETIZED;
+
+		if ((tstate->auto_negotiate & mask) != 0) {
+			scb->flags |= SCB_AUTO_NEGOTIATE;
+			scb->hscb->control |= MK_MESSAGE;
+		}
+
+		if ((dev->flags & (AHD_DEV_Q_TAGGED|AHD_DEV_Q_BASIC)) != 0) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+			int	msg_bytes;
+			uint8_t tag_msgs[2];
+
+			msg_bytes = scsi_populate_tag_msg(cmd, tag_msgs);
+			if (msg_bytes && tag_msgs[0] != MSG_SIMPLE_TASK) {
+				hscb->control |= tag_msgs[0];
+				if (tag_msgs[0] == MSG_ORDERED_TASK)
+					dev->commands_since_idle_or_otag = 0;
+			} else
+#endif
+			if (dev->commands_since_idle_or_otag == AHD_OTAG_THRESH
+			 && (dev->flags & AHD_DEV_Q_TAGGED) != 0) {
+				hscb->control |= MSG_ORDERED_TASK;
+				dev->commands_since_idle_or_otag = 0;
+			} else {
+				hscb->control |= MSG_SIMPLE_TASK;
+			}
+		}
+
+		hscb->cdb_len = cmd->cmd_len;
+		memcpy(hscb->shared_data.idata.cdb, cmd->cmnd, hscb->cdb_len);
+
+		scb->sg_count = 0;
+		ahd_set_residual(scb, 0);
+		ahd_set_sense_residual(scb, 0);
+		if (cmd->use_sg != 0) {
+			void	*sg;
+			struct	 scatterlist *cur_seg;
+			u_int	 nseg;
+			int	 dir;
+
+			cur_seg = (struct scatterlist *)cmd->request_buffer;
+			dir = scsi_to_pci_dma_dir(cmd->sc_data_direction);
+			nseg = pci_map_sg(ahd->dev_softc, cur_seg,
+					  cmd->use_sg, dir);
+			scb->platform_data->xfer_len = 0;
+			for (sg = scb->sg_list; nseg > 0; nseg--, cur_seg++) {
+				bus_addr_t addr;
+				bus_size_t len;
+
+				addr = sg_dma_address(cur_seg);
+				len = sg_dma_len(cur_seg);
+				scb->platform_data->xfer_len += len;
+				sg = ahd_sg_setup(ahd, scb, sg, addr, len,
+						  /*last*/nseg == 1);
+			}
+		} else if (cmd->request_bufflen != 0) {
+			void *sg;
+			bus_addr_t addr;
+			int dir;
+
+			sg = scb->sg_list;
+			dir = scsi_to_pci_dma_dir(cmd->sc_data_direction);
+			addr = pci_map_single(ahd->dev_softc,
+					      cmd->request_buffer,
+					      cmd->request_bufflen, dir);
+			scb->platform_data->xfer_len = cmd->request_bufflen;
+			scb->platform_data->buf_busaddr = addr;
+			sg = ahd_sg_setup(ahd, scb, sg, addr,
+					  cmd->request_bufflen, /*last*/TRUE);
+		}
+
+		LIST_INSERT_HEAD(&ahd->pending_scbs, scb, pending_links);
+		dev->openings--;
+		dev->active++;
+		dev->commands_issued++;
+
+		/* Update the error counting bucket and dump if needed */
+		if (dev->target->cmds_since_error) {
+			dev->target->cmds_since_error++;
+			if (dev->target->cmds_since_error >
+			    AHD_LINUX_ERR_THRESH)
+				dev->target->cmds_since_error = 0;
+		}
+
+		if ((dev->flags & AHD_DEV_PERIODIC_OTAG) != 0)
+			dev->commands_since_idle_or_otag++;
+		scb->flags |= SCB_ACTIVE;
+		ahd_queue_scb(ahd, scb);
+	}
+}
+
+/*
+ * SCSI controller interrupt handler.
+ */
+irqreturn_t
+ahd_linux_isr(int irq, void *dev_id, struct pt_regs * regs)
+{
+	struct	ahd_softc *ahd;
+	u_long	flags;
+	int	ours;
+
+	ahd = (struct ahd_softc *) dev_id;
+	ahd_lock(ahd, &flags); 
+	ours = ahd_intr(ahd);
+	if (ahd_linux_next_device_to_run(ahd) != NULL)
+		ahd_schedule_runq(ahd);
+	ahd_linux_run_complete_queue(ahd);
+	ahd_unlock(ahd, &flags);
+	return IRQ_RETVAL(ours);
+}
+
+void
+ahd_platform_flushwork(struct ahd_softc *ahd)
+{
+
+	while (ahd_linux_run_complete_queue(ahd) != NULL)
+		;
+}
+
+static struct ahd_linux_target*
+ahd_linux_alloc_target(struct ahd_softc *ahd, u_int channel, u_int target)
+{
+	struct ahd_linux_target *targ;
+
+	targ = malloc(sizeof(*targ), M_DEVBUF, M_NOWAIT);
+	if (targ == NULL)
+		return (NULL);
+	memset(targ, 0, sizeof(*targ));
+	targ->channel = channel;
+	targ->target = target;
+	targ->ahd = ahd;
+	targ->flags = AHD_DV_REQUIRED;
+	ahd->platform_data->targets[target] = targ;
+	return (targ);
+}
+
+static void
+ahd_linux_free_target(struct ahd_softc *ahd, struct ahd_linux_target *targ)
+{
+	struct ahd_devinfo devinfo;
+	struct ahd_initiator_tinfo *tinfo;
+	struct ahd_tmode_tstate *tstate;
+	u_int our_id;
+	u_int target_offset;
+	char channel;
+
+	/*
+	 * Force a negotiation to async/narrow on any
+	 * future command to this device unless a bus
+	 * reset occurs between now and that command.
+	 */
+	channel = 'A' + targ->channel;
+	our_id = ahd->our_id;
+	target_offset = targ->target;
+	tinfo = ahd_fetch_transinfo(ahd, channel, our_id,
+				    targ->target, &tstate);
+	ahd_compile_devinfo(&devinfo, our_id, targ->target, CAM_LUN_WILDCARD,
+			    channel, ROLE_INITIATOR);
+	ahd_set_syncrate(ahd, &devinfo, 0, 0, 0,
+			 AHD_TRANS_GOAL, /*paused*/FALSE);
+	ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
+		      AHD_TRANS_GOAL, /*paused*/FALSE);
+	ahd_update_neg_request(ahd, &devinfo, tstate, tinfo, AHD_NEG_ALWAYS);
+ 	ahd->platform_data->targets[target_offset] = NULL;
+	if (targ->inq_data != NULL)
+		free(targ->inq_data, M_DEVBUF);
+	if (targ->dv_buffer != NULL)
+		free(targ->dv_buffer, M_DEVBUF);
+	if (targ->dv_buffer1 != NULL)
+		free(targ->dv_buffer1, M_DEVBUF);
+	free(targ, M_DEVBUF);
+}
+
+static struct ahd_linux_device*
+ahd_linux_alloc_device(struct ahd_softc *ahd,
+		 struct ahd_linux_target *targ, u_int lun)
+{
+	struct ahd_linux_device *dev;
+
+	dev = malloc(sizeof(*dev), M_DEVBUG, M_NOWAIT);
+	if (dev == NULL)
+		return (NULL);
+	memset(dev, 0, sizeof(*dev));
+	init_timer(&dev->timer);
+	TAILQ_INIT(&dev->busyq);
+	dev->flags = AHD_DEV_UNCONFIGURED;
+	dev->lun = lun;
+	dev->target = targ;
+
+	/*
+	 * We start out life using untagged
+	 * transactions of which we allow one.
+	 */
+	dev->openings = 1;
+
+	/*
+	 * Set maxtags to 0.  This will be changed if we
+	 * later determine that we are dealing with
+	 * a tagged queuing capable device.
+	 */
+	dev->maxtags = 0;
+	
+	targ->refcount++;
+	targ->devices[lun] = dev;
+	return (dev);
+}
+
+static void
+ahd_linux_free_device(struct ahd_softc *ahd, struct ahd_linux_device *dev)
+{
+	struct ahd_linux_target *targ;
+
+	del_timer(&dev->timer);
+	targ = dev->target;
+	targ->devices[dev->lun] = NULL;
+	free(dev, M_DEVBUF);
+	targ->refcount--;
+	if (targ->refcount == 0
+	 && (targ->flags & AHD_DV_REQUIRED) == 0)
+		ahd_linux_free_target(ahd, targ);
+}
+
+void
+ahd_send_async(struct ahd_softc *ahd, char channel,
+	       u_int target, u_int lun, ac_code code, void *arg)
+{
+	switch (code) {
+	case AC_TRANSFER_NEG:
+	{
+		char	buf[80];
+		struct	ahd_linux_target *targ;
+		struct	info_str info;
+		struct	ahd_initiator_tinfo *tinfo;
+		struct	ahd_tmode_tstate *tstate;
+
+		info.buffer = buf;
+		info.length = sizeof(buf);
+		info.offset = 0;
+		info.pos = 0;
+		tinfo = ahd_fetch_transinfo(ahd, channel, ahd->our_id,
+					    target, &tstate);
+
+		/*
+		 * Don't bother reporting results while
+		 * negotiations are still pending.
+		 */
+		if (tinfo->curr.period != tinfo->goal.period
+		 || tinfo->curr.width != tinfo->goal.width
+		 || tinfo->curr.offset != tinfo->goal.offset
+		 || tinfo->curr.ppr_options != tinfo->goal.ppr_options)
+			if (bootverbose == 0)
+				break;
+
+		/*
+		 * Don't bother reporting results that
+		 * are identical to those last reported.
+		 */
+		targ = ahd->platform_data->targets[target];
+		if (targ == NULL)
+			break;
+		if (tinfo->curr.period == targ->last_tinfo.period
+		 && tinfo->curr.width == targ->last_tinfo.width
+		 && tinfo->curr.offset == targ->last_tinfo.offset
+		 && tinfo->curr.ppr_options == targ->last_tinfo.ppr_options)
+			if (bootverbose == 0)
+				break;
+
+		targ->last_tinfo.period = tinfo->curr.period;
+		targ->last_tinfo.width = tinfo->curr.width;
+		targ->last_tinfo.offset = tinfo->curr.offset;
+		targ->last_tinfo.ppr_options = tinfo->curr.ppr_options;
+
+		printf("(%s:%c:", ahd_name(ahd), channel);
+		if (target == CAM_TARGET_WILDCARD)
+			printf("*): ");
+		else
+			printf("%d): ", target);
+		ahd_format_transinfo(&info, &tinfo->curr);
+		if (info.pos < info.length)
+			*info.buffer = '\0';
+		else
+			buf[info.length - 1] = '\0';
+		printf("%s", buf);
+		break;
+	}
+        case AC_SENT_BDR:
+	{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+		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)
+		Scsi_Device *scsi_dev;
+
+		/*
+		 * Find the SCSI device associated with this
+		 * request and indicate that a UA is expected.
+		 */
+		for (scsi_dev = ahd->platform_data->host->host_queue;
+		     scsi_dev != NULL; scsi_dev = scsi_dev->next) {
+			if (channel - 'A' == scsi_dev->channel
+			 && target == scsi_dev->id
+			 && (lun == CAM_LUN_WILDCARD
+			  || lun == scsi_dev->lun)) {
+				scsi_dev->was_reset = 1;
+				scsi_dev->expecting_cc_ua = 1;
+			}
+		}
+#endif
+		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");
+        }
+}
+
+/*
+ * Calls the higher level scsi done function and frees the scb.
+ */
+void
+ahd_done(struct ahd_softc *ahd, struct scb *scb)
+{
+	Scsi_Cmnd *cmd;
+	struct	  ahd_linux_device *dev;
+
+	if ((scb->flags & SCB_ACTIVE) == 0) {
+		printf("SCB %d done'd twice\n", SCB_GET_TAG(scb));
+		ahd_dump_card_state(ahd);
+		panic("Stopping for safety");
+	}
+	LIST_REMOVE(scb, pending_links);
+	cmd = scb->io_ctx;
+	dev = scb->platform_data->dev;
+	dev->active--;
+	dev->openings++;
+	if ((cmd->result & (CAM_DEV_QFRZN << 16)) != 0) {
+		cmd->result &= ~(CAM_DEV_QFRZN << 16);
+		dev->qfrozen--;
+	}
+	ahd_linux_unmap_scb(ahd, scb);
+
+	/*
+	 * Guard against stale sense data.
+	 * The Linux mid-layer assumes that sense
+	 * was retrieved anytime the first byte of
+	 * the sense buffer looks "sane".
+	 */
+	cmd->sense_buffer[0] = 0;
+	if (ahd_get_transaction_status(scb) == CAM_REQ_INPROG) {
+		uint32_t amount_xferred;
+
+		amount_xferred =
+		    ahd_get_transfer_length(scb) - ahd_get_residual(scb);
+		if ((scb->flags & SCB_TRANSMISSION_ERROR) != 0) {
+#ifdef AHD_DEBUG
+			if ((ahd_debug & AHD_SHOW_MISC) != 0) {
+				ahd_print_path(ahd, scb);
+				printf("Set CAM_UNCOR_PARITY\n");
+			}
+#endif
+			ahd_set_transaction_status(scb, CAM_UNCOR_PARITY);
+		} else if (amount_xferred < scb->io_ctx->underflow) {
+			u_int i;
+
+			ahd_print_path(ahd, scb);
+			printf("CDB:");
+			for (i = 0; i < scb->io_ctx->cmd_len; i++)
+				printf(" 0x%x", scb->io_ctx->cmnd[i]);
+			printf("\n");
+			ahd_print_path(ahd, scb);
+			printf("Saw underflow (%ld of %ld bytes). "
+			       "Treated as error\n",
+				ahd_get_residual(scb),
+				ahd_get_transfer_length(scb));
+			ahd_set_transaction_status(scb, CAM_DATA_RUN_ERR);
+		} else {
+			ahd_set_transaction_status(scb, CAM_REQ_CMP);
+		}
+	} else if (ahd_get_transaction_status(scb) == CAM_SCSI_STATUS_ERROR) {
+		ahd_linux_handle_scsi_status(ahd, dev, scb);
+	} else if (ahd_get_transaction_status(scb) == CAM_SEL_TIMEOUT) {
+		dev->flags |= AHD_DEV_UNCONFIGURED;
+		if (AHD_DV_CMD(cmd) == FALSE)
+			dev->target->flags &= ~AHD_DV_REQUIRED;
+	}
+	/*
+	 * Start DV for devices that require it assuming the first command
+	 * sent does not result in a selection timeout.
+	 */
+	if (ahd_get_transaction_status(scb) != CAM_SEL_TIMEOUT
+	 && (dev->target->flags & AHD_DV_REQUIRED) != 0)
+		ahd_linux_start_dv(ahd);
+
+	if (dev->openings == 1
+	 && ahd_get_transaction_status(scb) == CAM_REQ_CMP
+	 && ahd_get_scsi_status(scb) != SCSI_STATUS_QUEUE_FULL)
+		dev->tag_success_count++;
+	/*
+	 * Some devices deal with temporary internal resource
+	 * shortages by returning queue full.  When the queue
+	 * full occurrs, we throttle back.  Slowly try to get
+	 * back to our previous queue depth.
+	 */
+	if ((dev->openings + dev->active) < dev->maxtags
+	 && dev->tag_success_count > AHD_TAG_SUCCESS_INTERVAL) {
+		dev->tag_success_count = 0;
+		dev->openings++;
+	}
+
+	if (dev->active == 0)
+		dev->commands_since_idle_or_otag = 0;
+
+	if (TAILQ_EMPTY(&dev->busyq)) {
+		if ((dev->flags & AHD_DEV_UNCONFIGURED) != 0
+		 && dev->active == 0
+		 && (dev->flags & AHD_DEV_TIMER_ACTIVE) == 0)
+			ahd_linux_free_device(ahd, dev);
+	} else if ((dev->flags & AHD_DEV_ON_RUN_LIST) == 0) {
+		TAILQ_INSERT_TAIL(&ahd->platform_data->device_runq, dev, links);
+		dev->flags |= AHD_DEV_ON_RUN_LIST;
+	}
+
+	if ((scb->flags & SCB_RECOVERY_SCB) != 0) {
+		printf("Recovery SCB completes\n");
+		if (ahd_get_transaction_status(scb) == CAM_BDR_SENT
+		 || ahd_get_transaction_status(scb) == CAM_REQ_ABORTED)
+			ahd_set_transaction_status(scb, CAM_CMD_TIMEOUT);
+		if ((scb->platform_data->flags & AHD_SCB_UP_EH_SEM) != 0) {
+			scb->platform_data->flags &= ~AHD_SCB_UP_EH_SEM;
+			up(&ahd->platform_data->eh_sem);
+		}
+	}
+
+	ahd_free_scb(ahd, scb);
+	ahd_linux_queue_cmd_complete(ahd, cmd);
+
+	if ((ahd->platform_data->flags & AHD_DV_WAIT_SIMQ_EMPTY) != 0
+	 && LIST_FIRST(&ahd->pending_scbs) == NULL) {
+		ahd->platform_data->flags &= ~AHD_DV_WAIT_SIMQ_EMPTY;
+		up(&ahd->platform_data->dv_sem);
+	}
+}
+
+static void
+ahd_linux_handle_scsi_status(struct ahd_softc *ahd,
+			     struct ahd_linux_device *dev, struct scb *scb)
+{
+	struct	ahd_devinfo devinfo;
+
+	ahd_compile_devinfo(&devinfo,
+			    ahd->our_id,
+			    dev->target->target, dev->lun,
+			    dev->target->channel == 0 ? 'A' : 'B',
+			    ROLE_INITIATOR);
+	
+	/*
+	 * We don't currently trust the mid-layer to
+	 * properly deal with queue full or busy.  So,
+	 * when one occurs, we tell the mid-layer to
+	 * unconditionally requeue the command to us
+	 * so that we can retry it ourselves.  We also
+	 * implement our own throttling mechanism so
+	 * we don't clobber the device with too many
+	 * commands.
+	 */
+	switch (ahd_get_scsi_status(scb)) {
+	default:
+		break;
+	case SCSI_STATUS_CHECK_COND:
+	case SCSI_STATUS_CMD_TERMINATED:
+	{
+		Scsi_Cmnd *cmd;
+
+		/*
+		 * Copy sense information to the OS's cmd
+		 * structure if it is available.
+		 */
+		cmd = scb->io_ctx;
+		if ((scb->flags & (SCB_SENSE|SCB_PKT_SENSE)) != 0) {
+			struct scsi_status_iu_header *siu;
+			u_int sense_size;
+			u_int sense_offset;
+
+			if (scb->flags & SCB_SENSE) {
+				sense_size = MIN(sizeof(struct scsi_sense_data)
+					       - ahd_get_sense_residual(scb),
+						 sizeof(cmd->sense_buffer));
+				sense_offset = 0;
+			} else {
+				/*
+				 * Copy only the sense data into the provided
+				 * buffer.
+				 */
+				siu = (struct scsi_status_iu_header *)
+				    scb->sense_data;
+				sense_size = MIN(scsi_4btoul(siu->sense_length),
+						sizeof(cmd->sense_buffer));
+				sense_offset = SIU_SENSE_OFFSET(siu);
+			}
+
+			memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
+			memcpy(cmd->sense_buffer,
+			       ahd_get_sense_buf(ahd, scb)
+			       + sense_offset, sense_size);
+			cmd->result |= (DRIVER_SENSE << 24);
+
+#ifdef AHD_DEBUG
+			if (ahd_debug & AHD_SHOW_SENSE) {
+				int i;
+
+				printf("Copied %d bytes of sense data at %d:",
+				       sense_size, sense_offset);
+				for (i = 0; i < sense_size; i++) {
+					if ((i & 0xF) == 0)
+						printf("\n");
+					printf("0x%x ", cmd->sense_buffer[i]);
+				}
+				printf("\n");
+			}
+#endif
+		}
+		break;
+	}
+	case SCSI_STATUS_QUEUE_FULL:
+	{
+		/*
+		 * By the time the core driver has returned this
+		 * command, all other commands that were queued
+		 * to us but not the device have been returned.
+		 * This ensures that dev->active is equal to
+		 * the number of commands actually queued to
+		 * the device.
+		 */
+		dev->tag_success_count = 0;
+		if (dev->active != 0) {
+			/*
+			 * Drop our opening count to the number
+			 * of commands currently outstanding.
+			 */
+			dev->openings = 0;
+#ifdef AHD_DEBUG
+			if ((ahd_debug & AHD_SHOW_QFULL) != 0) {
+				ahd_print_path(ahd, scb);
+				printf("Dropping tag count to %d\n",
+				       dev->active);
+			}
+#endif
+			if (dev->active == dev->tags_on_last_queuefull) {
+
+				dev->last_queuefull_same_count++;
+				/*
+				 * If we repeatedly see a queue full
+				 * at the same queue depth, this
+				 * device has a fixed number of tag
+				 * slots.  Lock in this tag depth
+				 * so we stop seeing queue fulls from
+				 * this device.
+				 */
+				if (dev->last_queuefull_same_count
+				 == AHD_LOCK_TAGS_COUNT) {
+					dev->maxtags = dev->active;
+					ahd_print_path(ahd, scb);
+					printf("Locking max tag count at %d\n",
+					       dev->active);
+				}
+			} else {
+				dev->tags_on_last_queuefull = dev->active;
+				dev->last_queuefull_same_count = 0;
+			}
+			ahd_set_transaction_status(scb, CAM_REQUEUE_REQ);
+			ahd_set_scsi_status(scb, SCSI_STATUS_OK);
+			ahd_platform_set_tags(ahd, &devinfo,
+				     (dev->flags & AHD_DEV_Q_BASIC)
+				   ? AHD_QUEUE_BASIC : AHD_QUEUE_TAGGED);
+			break;
+		}
+		/*
+		 * Drop down to a single opening, and treat this
+		 * as if the target returned BUSY SCSI status.
+		 */
+		dev->openings = 1;
+		ahd_platform_set_tags(ahd, &devinfo,
+			     (dev->flags & AHD_DEV_Q_BASIC)
+			   ? AHD_QUEUE_BASIC : AHD_QUEUE_TAGGED);
+		ahd_set_scsi_status(scb, SCSI_STATUS_BUSY);
+		/* FALLTHROUGH */
+	}
+	case SCSI_STATUS_BUSY:
+		/*
+		 * Set a short timer to defer sending commands for
+		 * a bit since Linux will not delay in this case.
+		 */
+		if ((dev->flags & AHD_DEV_TIMER_ACTIVE) != 0) {
+			printf("%s:%c:%d: Device Timer still active during "
+			       "busy processing\n", ahd_name(ahd),
+				dev->target->channel, dev->target->target);
+			break;
+		}
+		dev->flags |= AHD_DEV_TIMER_ACTIVE;
+		dev->qfrozen++;
+		init_timer(&dev->timer);
+		dev->timer.data = (u_long)dev;
+		dev->timer.expires = jiffies + (HZ/2);
+		dev->timer.function = ahd_linux_dev_timed_unfreeze;
+		add_timer(&dev->timer);
+		break;
+	}
+}
+
+static void
+ahd_linux_queue_cmd_complete(struct ahd_softc *ahd, Scsi_Cmnd *cmd)
+{
+	/*
+	 * Typically, the complete queue has very few entries
+	 * queued to it before the queue is emptied by
+	 * ahd_linux_run_complete_queue, so sorting the entries
+	 * by generation number should be inexpensive.
+	 * We perform the sort so that commands that complete
+	 * with an error are retuned in the order origionally
+	 * queued to the controller so that any subsequent retries
+	 * are performed in order.  The underlying ahd routines do
+	 * not guarantee the order that aborted commands will be
+	 * returned to us.
+	 */
+	struct ahd_completeq *completeq;
+	struct ahd_cmd *list_cmd;
+	struct ahd_cmd *acmd;
+
+	/*
+	 * Map CAM error codes into Linux Error codes.  We
+	 * avoid the conversion so that the DV code has the
+	 * full error information available when making
+	 * state change decisions.
+	 */
+	if (AHD_DV_CMD(cmd) == FALSE) {
+		uint32_t status;
+		u_int new_status;
+
+		status = ahd_cmd_get_transaction_status(cmd);
+		if (status != CAM_REQ_CMP) {
+			struct ahd_linux_device *dev;
+			struct ahd_devinfo devinfo;
+			cam_status cam_status;
+			uint32_t action;
+			u_int scsi_status;
+
+			dev = ahd_linux_get_device(ahd, cmd->device->channel,
+						   cmd->device->id,
+						   cmd->device->lun,
+						   /*alloc*/FALSE);
+
+			if (dev == NULL)
+				goto no_fallback;
+
+			ahd_compile_devinfo(&devinfo,
+					    ahd->our_id,
+					    dev->target->target, dev->lun,
+					    dev->target->channel == 0 ? 'A':'B',
+					    ROLE_INITIATOR);
+
+			scsi_status = ahd_cmd_get_scsi_status(cmd);
+			cam_status = ahd_cmd_get_transaction_status(cmd);
+			action = aic_error_action(cmd, dev->target->inq_data,
+						  cam_status, scsi_status);
+			if ((action & SSQ_FALLBACK) != 0) {
+
+				/* Update stats */
+				dev->target->errors_detected++;
+				if (dev->target->cmds_since_error == 0)
+					dev->target->cmds_since_error++;
+				else {
+					dev->target->cmds_since_error = 0;
+					ahd_linux_fallback(ahd, &devinfo);
+				}
+			}
+		}
+no_fallback:
+		switch (status) {
+		case CAM_REQ_INPROG:
+		case CAM_REQ_CMP:
+		case CAM_SCSI_STATUS_ERROR:
+			new_status = DID_OK;
+			break;
+		case CAM_REQ_ABORTED:
+			new_status = DID_ABORT;
+			break;
+		case CAM_BUSY:
+			new_status = DID_BUS_BUSY;
+			break;
+		case CAM_REQ_INVALID:
+		case CAM_PATH_INVALID:
+			new_status = DID_BAD_TARGET;
+			break;
+		case CAM_SEL_TIMEOUT:
+			new_status = DID_NO_CONNECT;
+			break;
+		case CAM_SCSI_BUS_RESET:
+		case CAM_BDR_SENT:
+			new_status = DID_RESET;
+			break;
+		case CAM_UNCOR_PARITY:
+			new_status = DID_PARITY;
+			break;
+		case CAM_CMD_TIMEOUT:
+			new_status = DID_TIME_OUT;
+			break;
+		case CAM_UA_ABORT:
+		case CAM_REQ_CMP_ERR:
+		case CAM_AUTOSENSE_FAIL:
+		case CAM_NO_HBA:
+		case CAM_DATA_RUN_ERR:
+		case CAM_UNEXP_BUSFREE:
+		case CAM_SEQUENCE_FAIL:
+		case CAM_CCB_LEN_ERR:
+		case CAM_PROVIDE_FAIL:
+		case CAM_REQ_TERMIO:
+		case CAM_UNREC_HBA_ERROR:
+		case CAM_REQ_TOO_BIG:
+			new_status = DID_ERROR;
+			break;
+		case CAM_REQUEUE_REQ:
+			/*
+			 * If we want the request requeued, make sure there
+			 * are sufficent retries.  In the old scsi error code,
+			 * we used to be able to specify a result code that
+			 * bypassed the retry count.  Now we must use this
+			 * hack.  We also "fake" a check condition with
+			 * a sense code of ABORTED COMMAND.  This seems to
+			 * evoke a retry even if this command is being sent
+			 * via the eh thread.  Ick!  Ick!  Ick!
+			 */
+			if (cmd->retries > 0)
+				cmd->retries--;
+			new_status = DID_OK;
+			ahd_cmd_set_scsi_status(cmd, SCSI_STATUS_CHECK_COND);
+			cmd->result |= (DRIVER_SENSE << 24);
+			memset(cmd->sense_buffer, 0,
+			       sizeof(cmd->sense_buffer));
+			cmd->sense_buffer[0] = SSD_ERRCODE_VALID
+					     | SSD_CURRENT_ERROR;
+			cmd->sense_buffer[2] = SSD_KEY_ABORTED_COMMAND;
+			break;
+		default:
+			/* We should never get here */
+			new_status = DID_ERROR;
+			break;
+		}
+
+		ahd_cmd_set_transaction_status(cmd, new_status);
+	}
+
+	completeq = &ahd->platform_data->completeq;
+	list_cmd = TAILQ_FIRST(completeq);
+	acmd = (struct ahd_cmd *)cmd;
+	while (list_cmd != NULL
+	    && acmd_scsi_cmd(list_cmd).serial_number
+	     < acmd_scsi_cmd(acmd).serial_number)
+		list_cmd = TAILQ_NEXT(list_cmd, acmd_links.tqe);
+	if (list_cmd != NULL)
+		TAILQ_INSERT_BEFORE(list_cmd, acmd, acmd_links.tqe);
+	else
+		TAILQ_INSERT_TAIL(completeq, acmd, acmd_links.tqe);
+}
+
+static void
+ahd_linux_filter_inquiry(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
+{
+	struct	scsi_inquiry_data *sid;
+	struct	ahd_initiator_tinfo *tinfo;
+	struct	ahd_transinfo *user;
+	struct	ahd_transinfo *goal;
+	struct	ahd_transinfo *curr;
+	struct	ahd_tmode_tstate *tstate;
+	struct	ahd_linux_device *dev;
+	u_int	width;
+	u_int	period;
+	u_int	offset;
+	u_int	ppr_options;
+	u_int	trans_version;
+	u_int	prot_version;
+
+	/*
+	 * Determine if this lun actually exists.  If so,
+	 * hold on to its corresponding device structure.
+	 * If not, make sure we release the device and
+	 * don't bother processing the rest of this inquiry
+	 * command.
+	 */
+	dev = ahd_linux_get_device(ahd, devinfo->channel - 'A',
+				   devinfo->target, devinfo->lun,
+				   /*alloc*/TRUE);
+
+	sid = (struct scsi_inquiry_data *)dev->target->inq_data;
+	if (SID_QUAL(sid) == SID_QUAL_LU_CONNECTED) {
+
+		dev->flags &= ~AHD_DEV_UNCONFIGURED;
+	} else {
+		dev->flags |= AHD_DEV_UNCONFIGURED;
+		return;
+	}
+
+	/*
+	 * Update our notion of this device's transfer
+	 * negotiation capabilities.
+	 */
+	tinfo = ahd_fetch_transinfo(ahd, devinfo->channel,
+				    devinfo->our_scsiid,
+				    devinfo->target, &tstate);
+	user = &tinfo->user;
+	goal = &tinfo->goal;
+	curr = &tinfo->curr;
+	width = user->width;
+	period = user->period;
+	offset = user->offset;
+	ppr_options = user->ppr_options;
+	trans_version = user->transport_version;
+	prot_version = MIN(user->protocol_version, SID_ANSI_REV(sid));
+
+	/*
+	 * Only attempt SPI3/4 once we've verified that
+	 * the device claims to support SPI3/4 features.
+	 */
+	if (prot_version < SCSI_REV_2)
+		trans_version = SID_ANSI_REV(sid);
+	else
+		trans_version = SCSI_REV_2;
+
+	if ((sid->flags & SID_WBus16) == 0)
+		width = MSG_EXT_WDTR_BUS_8_BIT;
+	if ((sid->flags & SID_Sync) == 0) {
+		period = 0;
+		offset = 0;
+		ppr_options = 0;
+	}
+	if ((sid->spi3data & SID_SPI_QAS) == 0)
+		ppr_options &= ~MSG_EXT_PPR_QAS_REQ;
+	if ((sid->spi3data & SID_SPI_CLOCK_DT) == 0)
+		ppr_options &= MSG_EXT_PPR_QAS_REQ;
+	if ((sid->spi3data & SID_SPI_IUS) == 0)
+		ppr_options &= (MSG_EXT_PPR_DT_REQ
+			      | MSG_EXT_PPR_QAS_REQ);
+
+	if (prot_version > SCSI_REV_2
+	 && ppr_options != 0)
+		trans_version = user->transport_version;
+
+	ahd_validate_width(ahd, /*tinfo limit*/NULL, &width, ROLE_UNKNOWN);
+	ahd_find_syncrate(ahd, &period, &ppr_options, AHD_SYNCRATE_MAX);
+	ahd_validate_offset(ahd, /*tinfo limit*/NULL, period,
+			    &offset, width, ROLE_UNKNOWN);
+	if (offset == 0 || period == 0) {
+		period = 0;
+		offset = 0;
+		ppr_options = 0;
+	}
+	/* Apply our filtered user settings. */
+	curr->transport_version = trans_version;
+	curr->protocol_version = prot_version;
+	ahd_set_width(ahd, devinfo, width, AHD_TRANS_GOAL, /*paused*/FALSE);
+	ahd_set_syncrate(ahd, devinfo, period, offset, ppr_options,
+			 AHD_TRANS_GOAL, /*paused*/FALSE);
+}
+
+void
+ahd_freeze_simq(struct ahd_softc *ahd)
+{
+	ahd->platform_data->qfrozen++;
+	if (ahd->platform_data->qfrozen == 1) {
+		scsi_block_requests(ahd->platform_data->host);
+		ahd_platform_abort_scbs(ahd, CAM_TARGET_WILDCARD, ALL_CHANNELS,
+					CAM_LUN_WILDCARD, SCB_LIST_NULL,
+					ROLE_INITIATOR, CAM_REQUEUE_REQ);
+	}
+}
+
+void
+ahd_release_simq(struct ahd_softc *ahd)
+{
+	u_long s;
+	int    unblock_reqs;
+
+	unblock_reqs = 0;
+	ahd_lock(ahd, &s);
+	if (ahd->platform_data->qfrozen > 0)
+		ahd->platform_data->qfrozen--;
+	if (ahd->platform_data->qfrozen == 0) {
+		unblock_reqs = 1;
+	}
+	if (AHD_DV_SIMQ_FROZEN(ahd)
+	 && ((ahd->platform_data->flags & AHD_DV_WAIT_SIMQ_RELEASE) != 0)) {
+		ahd->platform_data->flags &= ~AHD_DV_WAIT_SIMQ_RELEASE;
+		up(&ahd->platform_data->dv_sem);
+	}
+	ahd_schedule_runq(ahd);
+	ahd_unlock(ahd, &s);
+	/*
+	 * There is still a race here.  The mid-layer
+	 * should keep its own freeze count and use
+	 * a bottom half handler to run the queues
+	 * so we can unblock with our own lock held.
+	 */
+	if (unblock_reqs)
+		scsi_unblock_requests(ahd->platform_data->host);
+}
+
+static void
+ahd_linux_sem_timeout(u_long arg)
+{
+	struct	scb *scb;
+	struct	ahd_softc *ahd;
+	u_long	s;
+
+	scb = (struct scb *)arg;
+	ahd = scb->ahd_softc;
+	ahd_lock(ahd, &s);
+	if ((scb->platform_data->flags & AHD_SCB_UP_EH_SEM) != 0) {
+		scb->platform_data->flags &= ~AHD_SCB_UP_EH_SEM;
+		up(&ahd->platform_data->eh_sem);
+	}
+	ahd_unlock(ahd, &s);
+}
+
+static void
+ahd_linux_dev_timed_unfreeze(u_long arg)
+{
+	struct ahd_linux_device *dev;
+	struct ahd_softc *ahd;
+	u_long s;
+
+	dev = (struct ahd_linux_device *)arg;
+	ahd = dev->target->ahd;
+	ahd_lock(ahd, &s);
+	dev->flags &= ~AHD_DEV_TIMER_ACTIVE;
+	if (dev->qfrozen > 0)
+		dev->qfrozen--;
+	if (dev->qfrozen == 0
+	 && (dev->flags & AHD_DEV_ON_RUN_LIST) == 0)
+		ahd_linux_run_device_queue(ahd, dev);
+	if ((dev->flags & AHD_DEV_UNCONFIGURED) != 0
+	 && dev->active == 0)
+		ahd_linux_free_device(ahd, dev);
+	ahd_unlock(ahd, &s);
+}
+
+void
+ahd_platform_dump_card_state(struct ahd_softc *ahd)
+{
+	struct ahd_linux_device *dev;
+	int target;
+	int maxtarget;
+	int lun;
+	int i;
+
+	maxtarget = (ahd->features & AHD_WIDE) ? 15 : 7;
+	for (target = 0; target <=maxtarget; target++) {
+
+		for (lun = 0; lun < AHD_NUM_LUNS; lun++) {
+			struct ahd_cmd *acmd;
+
+			dev = ahd_linux_get_device(ahd, 0, target,
+						   lun, /*alloc*/FALSE);
+			if (dev == NULL)
+				continue;
+
+			printf("DevQ(%d:%d:%d): ", 0, target, lun);
+			i = 0;
+			TAILQ_FOREACH(acmd, &dev->busyq, acmd_links.tqe) {
+				if (i++ > AHD_SCB_MAX)
+					break;
+			}
+			printf("%d waiting\n", i);
+		}
+	}
+}
+
+static int __init
+ahd_linux_init(void)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+       return (ahd_linux_detect(&aic79xx_driver_template) ? 0 : -ENODEV);
+#else
+	scsi_register_module(MODULE_SCSI_HA, &aic79xx_driver_template);
+	if (aic79xx_driver_template.present == 0) {
+		scsi_unregister_module(MODULE_SCSI_HA,
+				       &aic79xx_driver_template);
+		return (-ENODEV);
+	}
+
+	return (0);
+#endif
+}
+
+static void __exit
+ahd_linux_exit(void)
+{
+	struct ahd_softc *ahd;
+	u_long l;
+
+	/*
+	 * Shutdown DV threads before going into the SCSI mid-layer.
+	 * This avoids situations where the mid-layer locks the entire
+	 * 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_
+	 * unregistering from the scsi midlayer to avoid dangling
+	 * references.
+	 */
+	scsi_unregister_module(MODULE_SCSI_HA, &aic79xx_driver_template);
+#endif
+	ahd_linux_pci_exit();
+}
+
+module_init(ahd_linux_init);
+module_exit(ahd_linux_exit);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic79xx_osm.h linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx_osm.h
--- linux-2.4.21/drivers/scsi/aic7xxx/aic79xx_osm.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx_osm.h	2003-06-26 21:43:11.000000000 +0000
@@ -0,0 +1,1236 @@
+/*
+ * 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: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#135 $
+ *
+ */
+#ifndef _AIC79XX_LINUX_H_
+#define _AIC79XX_LINUX_H_
+
+#include <linux/types.h>
+#include <linux/blk.h>
+#include <linux/blkdev.h>
+#include <linux/delay.h>
+#include <linux/ioport.h>
+#include <linux/pci.h>
+#include <linux/smp_lock.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#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
+#include "scsi.h"
+#include "hosts.h"
+
+/* Name space conflict with BSD queue macros */
+#ifdef LIST_HEAD
+#undef LIST_HEAD
+#endif
+
+#include "cam.h"
+#include "queue.h"
+#include "scsi_message.h"
+#include "scsi_iu.h"
+#include "aiclib.h"
+
+/*********************************** Debugging ********************************/
+#ifdef CONFIG_AIC79XX_DEBUG_ENABLE
+#ifdef CONFIG_AIC79XX_DEBUG_MASK
+#define AHD_DEBUG 1
+#define AHD_DEBUG_OPTS CONFIG_AIC79XX_DEBUG_MASK
+#else
+/*
+ * Compile in debugging code, but do not enable any printfs.
+ */
+#define AHD_DEBUG 1
+#define AHD_DEBUG_OPTS 0
+#endif
+/* No debugging code. */
+#endif
+
+/********************************** Misc Macros *******************************/
+#define	roundup(x, y)   ((((x)+((y)-1))/(y))*(y))
+#define	powerof2(x)	((((x)-1)&(x))==0)
+
+/************************* Forward Declarations *******************************/
+struct ahd_softc;
+typedef struct pci_dev *ahd_dev_softc_t;
+typedef Scsi_Cmnd      *ahd_io_ctx_t;
+
+/******************************* Byte Order ***********************************/
+#define ahd_htobe16(x)	cpu_to_be16(x)
+#define ahd_htobe32(x)	cpu_to_be32(x)
+#define ahd_htobe64(x)	cpu_to_be64(x)
+#define ahd_htole16(x)	cpu_to_le16(x)
+#define ahd_htole32(x)	cpu_to_le32(x)
+#define ahd_htole64(x)	cpu_to_le64(x)
+
+#define ahd_be16toh(x)	be16_to_cpu(x)
+#define ahd_be32toh(x)	be32_to_cpu(x)
+#define ahd_be64toh(x)	be64_to_cpu(x)
+#define ahd_le16toh(x)	le16_to_cpu(x)
+#define ahd_le32toh(x)	le32_to_cpu(x)
+#define ahd_le64toh(x)	le64_to_cpu(x)
+
+#ifndef LITTLE_ENDIAN
+#define LITTLE_ENDIAN 1234
+#endif
+
+#ifndef BIG_ENDIAN
+#define BIG_ENDIAN 4321
+#endif
+
+#ifndef BYTE_ORDER
+#if defined(__BIG_ENDIAN)
+#define BYTE_ORDER BIG_ENDIAN
+#endif
+#if defined(__LITTLE_ENDIAN)
+#define BYTE_ORDER LITTLE_ENDIAN
+#endif
+#endif /* BYTE_ORDER */
+
+/************************* Configuration Data *********************************/
+extern uint32_t aic79xx_allow_memio;
+extern int aic79xx_detect_complete;
+extern Scsi_Host_Template aic79xx_driver_template;
+
+/***************************** 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 {
+	BUS_SPACE_MEMIO,
+	BUS_SPACE_PIO
+} bus_space_tag_t;
+
+typedef union {
+	u_long		  ioport;
+	volatile uint8_t *maddr;
+} bus_space_handle_t;
+
+typedef struct bus_dma_segment
+{
+	bus_addr_t	ds_addr;
+	bus_size_t	ds_len;
+} bus_dma_segment_t;
+
+struct ahd_linux_dma_tag
+{
+	bus_size_t	alignment;
+	bus_size_t	boundary;
+	bus_size_t	maxsize;
+};
+typedef struct ahd_linux_dma_tag* bus_dma_tag_t;
+
+struct ahd_linux_dmamap
+{
+	bus_addr_t	bus_addr;
+};
+typedef struct ahd_linux_dmamap* bus_dmamap_t;
+
+typedef int bus_dma_filter_t(void*, bus_addr_t);
+typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
+
+#define BUS_DMA_WAITOK		0x0
+#define BUS_DMA_NOWAIT		0x1
+#define BUS_DMA_ALLOCNOW	0x2
+#define BUS_DMA_LOAD_SEGS	0x4	/*
+					 * Argument is an S/G list not
+					 * a single buffer.
+					 */
+
+#define BUS_SPACE_MAXADDR	0xFFFFFFFF
+#define BUS_SPACE_MAXADDR_32BIT	0xFFFFFFFF
+#define BUS_SPACE_MAXSIZE_32BIT	0xFFFFFFFF
+
+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*/,
+			   bus_dma_filter_t*/*filter*/, void */*filterarg*/,
+			   bus_size_t /*maxsize*/, int /*nsegments*/,
+			   bus_size_t /*maxsegsz*/, int /*flags*/,
+			   bus_dma_tag_t */*dma_tagp*/);
+
+void	ahd_dma_tag_destroy(struct ahd_softc *, bus_dma_tag_t /*tag*/);
+
+int	ahd_dmamem_alloc(struct ahd_softc *, bus_dma_tag_t /*dmat*/,
+			 void** /*vaddr*/, int /*flags*/,
+			 bus_dmamap_t* /*mapp*/);
+
+void	ahd_dmamem_free(struct ahd_softc *, bus_dma_tag_t /*dmat*/,
+			void* /*vaddr*/, bus_dmamap_t /*map*/);
+
+void	ahd_dmamap_destroy(struct ahd_softc *, bus_dma_tag_t /*tag*/,
+			   bus_dmamap_t /*map*/);
+
+int	ahd_dmamap_load(struct ahd_softc *ahd, bus_dma_tag_t /*dmat*/,
+			bus_dmamap_t /*map*/, void * /*buf*/,
+			bus_size_t /*buflen*/, bus_dmamap_callback_t *,
+			void */*callback_arg*/, int /*flags*/);
+
+int	ahd_dmamap_unload(struct ahd_softc *, bus_dma_tag_t, bus_dmamap_t);
+
+/*
+ * Operations performed by ahd_dmamap_sync().
+ */
+#define BUS_DMASYNC_PREREAD	0x01	/* pre-read synchronization */
+#define BUS_DMASYNC_POSTREAD	0x02	/* post-read synchronization */
+#define BUS_DMASYNC_PREWRITE	0x04	/* pre-write synchronization */
+#define BUS_DMASYNC_POSTWRITE	0x08	/* post-write synchronization */
+
+/*
+ * XXX
+ * ahd_dmamap_sync is only used on buffers allocated with
+ * the pci_alloc_consistent() API.  Although I'm not sure how
+ * this works on architectures with a write buffer, Linux does
+ * not have an API to sync "coherent" memory.  Perhaps we need
+ * to do an mb()?
+ */
+#define ahd_dmamap_sync(ahd, dma_tag, dmamap, offset, len, op)
+
+/************************** Timer DataStructures ******************************/
+typedef struct timer_list ahd_timer_t;
+
+/********************************** Includes **********************************/
+#ifdef CONFIG_AIC79XX_REG_PRETTY_PRINT
+#define AIC_DEBUG_REGISTERS 1
+#else
+#define AIC_DEBUG_REGISTERS 0
+#endif
+#include "aic79xx.h"
+
+/***************************** Timer Facilities *******************************/
+#define ahd_timer_init init_timer
+#define ahd_timer_stop del_timer_sync
+typedef void ahd_linux_callback_t (u_long);  
+static __inline void ahd_timer_reset(ahd_timer_t *timer, u_int usec,
+				     ahd_callback_t *func, void *arg);
+static __inline void ahd_scb_timer_reset(struct scb *scb, u_int usec);
+
+static __inline void
+ahd_timer_reset(ahd_timer_t *timer, u_int usec, ahd_callback_t *func, void *arg)
+{
+	struct ahd_softc *ahd;
+
+	ahd = (struct ahd_softc *)arg;
+	del_timer(timer);
+	timer->data = (u_long)arg;
+	timer->expires = jiffies + (usec * HZ)/1000000;
+	timer->function = (ahd_linux_callback_t*)func;
+	add_timer(timer);
+}
+
+static __inline void
+ahd_scb_timer_reset(struct scb *scb, u_int usec)
+{
+	mod_timer(&scb->io_ctx->eh_timeout, jiffies + (usec * HZ)/1000000);
+}
+
+/***************************** 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
+#else
+#define AHD_SCSI_HAS_HOST_LOCK 0
+#endif
+
+#define AIC79XX_DRIVER_VERSION "1.3.10"
+
+/**************************** Front End Queues ********************************/
+/*
+ * Data structure used to cast the Linux struct scsi_cmnd to something
+ * that allows us to use the queue macros.  The linux structure has
+ * plenty of space to hold the links fields as required by the queue
+ * macros, but the queue macors require them to have the correct type.
+ */
+struct ahd_cmd_internal {
+	/* Area owned by the Linux scsi layer. */
+	uint8_t	private[offsetof(struct scsi_cmnd, SCp.Status)];
+	union {
+		STAILQ_ENTRY(ahd_cmd)	ste;
+		LIST_ENTRY(ahd_cmd)	le;
+		TAILQ_ENTRY(ahd_cmd)	tqe;
+	} links;
+	uint32_t			end;
+};
+
+struct ahd_cmd {
+	union {
+		struct ahd_cmd_internal	icmd;
+		struct scsi_cmnd	scsi_cmd;
+	} un;
+};
+
+#define acmd_icmd(cmd) ((cmd)->un.icmd)
+#define acmd_scsi_cmd(cmd) ((cmd)->un.scsi_cmd)
+#define acmd_links un.icmd.links
+
+/*************************** Device Data Structures ***************************/
+/*
+ * A per probed device structure used to deal with some error recovery
+ * scenarios that the Linux mid-layer code just doesn't know how to
+ * handle.  The structure allocated for a device only becomes persistent
+ * after a successfully completed inquiry command to the target when
+ * that inquiry data indicates a lun is present.
+ */
+TAILQ_HEAD(ahd_busyq, ahd_cmd);
+typedef enum {
+	AHD_DEV_UNCONFIGURED	 = 0x01,
+	AHD_DEV_FREEZE_TIL_EMPTY = 0x02, /* Freeze queue until active == 0 */
+	AHD_DEV_TIMER_ACTIVE	 = 0x04, /* Our timer is active */
+	AHD_DEV_ON_RUN_LIST	 = 0x08, /* Queued to be run later */
+	AHD_DEV_Q_BASIC		 = 0x10, /* Allow basic device queuing */
+	AHD_DEV_Q_TAGGED	 = 0x20, /* Allow full SCSI2 command queueing */
+	AHD_DEV_PERIODIC_OTAG	 = 0x40, /* Send OTAG to prevent starvation */
+	AHD_DEV_SLAVE_CONFIGURED = 0x80	 /* slave_configure() has been called */
+} ahd_linux_dev_flags;
+
+struct ahd_linux_target;
+struct ahd_linux_device {
+	TAILQ_ENTRY(ahd_linux_device) links;
+	struct			ahd_busyq busyq;
+
+	/*
+	 * The number of transactions currently
+	 * queued to the device.
+	 */
+	int			active;
+
+	/*
+	 * The currently allowed number of 
+	 * transactions that can be queued to
+	 * the device.  Must be signed for
+	 * conversion from tagged to untagged
+	 * mode where the device may have more
+	 * than one outstanding active transaction.
+	 */
+	int			openings;
+
+	/*
+	 * A positive count indicates that this
+	 * device's queue is halted.
+	 */
+	u_int			qfrozen;
+	
+	/*
+	 * Cumulative command counter.
+	 */
+	u_long			commands_issued;
+
+	/*
+	 * The number of tagged transactions when
+	 * running at our current opening level
+	 * that have been successfully received by
+	 * this device since the last QUEUE FULL.
+	 */
+	u_int			tag_success_count;
+#define AHD_TAG_SUCCESS_INTERVAL 50
+
+	ahd_linux_dev_flags	flags;
+
+	/*
+	 * Per device timer.
+	 */
+	struct timer_list	timer;
+
+	/*
+	 * The high limit for the tags variable.
+	 */
+	u_int			maxtags;
+
+	/*
+	 * The computed number of tags outstanding
+	 * at the time of the last QUEUE FULL event.
+	 */
+	u_int			tags_on_last_queuefull;
+
+	/*
+	 * How many times we have seen a queue full
+	 * with the same number of tags.  This is used
+	 * to stop our adaptive queue depth algorithm
+	 * on devices with a fixed number of tags.
+	 */
+	u_int			last_queuefull_same_count;
+#define AHD_LOCK_TAGS_COUNT 50
+
+	/*
+	 * How many transactions have been queued
+	 * without the device going idle.  We use
+	 * this statistic to determine when to issue
+	 * an ordered tag to prevent transaction
+	 * starvation.  This statistic is only updated
+	 * if the AHD_DEV_PERIODIC_OTAG flag is set
+	 * on this device.
+	 */
+	u_int			commands_since_idle_or_otag;
+#define AHD_OTAG_THRESH	500
+
+	int			lun;
+	Scsi_Device	       *scsi_device;
+	struct			ahd_linux_target *target;
+};
+
+typedef enum {
+	AHD_DV_REQUIRED		 = 0x01,
+	AHD_INQ_VALID		 = 0x02,
+	AHD_BASIC_DV		 = 0x04,
+	AHD_ENHANCED_DV		 = 0x08
+} ahd_linux_targ_flags;
+
+/* DV States */
+typedef enum {
+	AHD_DV_STATE_EXIT = 0,
+	AHD_DV_STATE_INQ_SHORT_ASYNC,
+	AHD_DV_STATE_INQ_ASYNC,
+	AHD_DV_STATE_INQ_ASYNC_VERIFY,
+	AHD_DV_STATE_TUR,
+	AHD_DV_STATE_REBD,
+	AHD_DV_STATE_INQ_VERIFY,
+	AHD_DV_STATE_WEB,
+	AHD_DV_STATE_REB,
+	AHD_DV_STATE_SU,
+	AHD_DV_STATE_BUSY
+} ahd_dv_state;
+
+struct ahd_linux_target {
+	struct ahd_linux_device	 *devices[AHD_NUM_LUNS];
+	int			  channel;
+	int			  target;
+	int			  refcount;
+	struct ahd_transinfo	  last_tinfo;
+	struct ahd_softc	 *ahd;
+	ahd_linux_targ_flags	  flags;
+	struct scsi_inquiry_data *inq_data;
+	/*
+	 * The next "fallback" period to use for narrow/wide transfers.
+	 */
+	uint8_t			  dv_next_narrow_period;
+	uint8_t			  dv_next_wide_period;
+	uint8_t			  dv_max_width;
+	uint8_t			  dv_max_ppr_options;
+	uint8_t			  dv_last_ppr_options;
+	u_int			  dv_echo_size;
+	ahd_dv_state		  dv_state;
+	u_int			  dv_state_retry;
+	uint8_t			 *dv_buffer;
+	uint8_t			 *dv_buffer1;
+
+	/*
+	 * Cumulative counter of errors.
+	 */
+	u_long			errors_detected;
+	u_long			cmds_since_error;
+};
+
+/********************* Definitions Required by the Core ***********************/
+/*
+ * Number of SG segments we require.  So long as the S/G segments for
+ * a particular transaction are allocated in a physically contiguous
+ * manner and are allocated below 4GB, the number of S/G segments is
+ * unrestricted.
+ */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+/*
+ * We dynamically adjust the number of segments in pre-2.5 kernels to
+ * avoid fragmentation issues in the SCSI mid-layer's private memory
+ * allocator.  See aic79xx_osm.c ahd_linux_size_nseg() for details.
+ */
+extern u_int ahd_linux_nseg;
+#define	AHD_NSEG ahd_linux_nseg
+#define	AHD_LINUX_MIN_NSEG 64
+#else
+#define	AHD_NSEG 128
+#endif
+
+/*
+ * Per-SCB OSM storage.
+ */
+typedef enum {
+	AHD_SCB_UP_EH_SEM = 0x1
+} ahd_linux_scb_flags;
+
+struct scb_platform_data {
+	struct ahd_linux_device	*dev;
+	bus_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;
+};
+
+/*
+ * Define a structure used for each host adapter.  All members are
+ * aligned on a boundary >= the size of the member to honor the
+ * alignment restrictions of the various platforms supported by
+ * this driver.
+ */
+typedef enum {
+	AHD_DV_WAIT_SIMQ_EMPTY	 = 0x01,
+	AHD_DV_WAIT_SIMQ_RELEASE = 0x02,
+	AHD_DV_ACTIVE		 = 0x04,
+	AHD_DV_SHUTDOWN		 = 0x08,
+	AHD_RUN_CMPLT_Q_TIMER	 = 0x10
+} ahd_linux_softc_flags;
+
+TAILQ_HEAD(ahd_completeq, ahd_cmd);
+
+struct ahd_platform_data {
+	/*
+	 * Fields accessed from interrupt context.
+	 */
+	struct ahd_linux_target *targets[AHD_NUM_TARGETS]; 
+	TAILQ_HEAD(, ahd_linux_device) device_runq;
+	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;
+	struct timer_list	 reset_timer;
+	struct timer_list	 stats_timer;
+	struct semaphore	 eh_sem;
+	struct semaphore	 dv_sem;
+	struct semaphore	 dv_cmd_sem;	/* XXX This needs to be in
+						 * the target struct
+						 */
+	struct scsi_device	*dv_scsi_dev;
+	struct Scsi_Host        *host;		/* pointer to scsi host */
+#define AHD_LINUX_NOIRQ	((uint32_t)~0)
+	uint32_t		 irq;		/* IRQ for this adapter */
+	uint32_t		 bios_address;
+	uint32_t		 mem_busaddr;	/* Mem Base Addr */
+	bus_addr_t		 hw_dma_mask;
+	ahd_linux_softc_flags	 flags;
+};
+
+/************************** OS Utility Wrappers *******************************/
+#define printf printk
+#define M_NOWAIT GFP_ATOMIC
+#define M_WAITOK 0
+#define malloc(size, type, flags) kmalloc(size, flags)
+#define free(ptr, type) kfree(ptr)
+
+static __inline void ahd_delay(long);
+static __inline void
+ahd_delay(long usec)
+{
+	/*
+	 * udelay on Linux can have problems for
+	 * multi-millisecond waits.  Wait at most
+	 * 1024us per call.
+	 */
+	while (usec > 0) {
+		udelay(usec % 1024);
+		usec -= 1024;
+	}
+}
+
+
+/***************************** Low Level I/O **********************************/
+#if defined(__powerpc__) || defined(__i386__) || defined(__ia64__)
+#define MMAPIO
+#endif
+
+static __inline uint8_t ahd_inb(struct ahd_softc * ahd, long port);
+static __inline uint16_t ahd_inw_atomic(struct ahd_softc * ahd, long port);
+static __inline void ahd_outb(struct ahd_softc * ahd, long port, uint8_t val);
+static __inline void ahd_outw_atomic(struct ahd_softc * ahd,
+				     long port, uint16_t val);
+static __inline void ahd_outsb(struct ahd_softc * ahd, long port,
+			       uint8_t *, int count);
+static __inline void ahd_insb(struct ahd_softc * ahd, long port,
+			       uint8_t *, int count);
+
+static __inline uint8_t
+ahd_inb(struct ahd_softc * ahd, long port)
+{
+	uint8_t x;
+#ifdef MMAPIO
+
+	if (ahd->tags[0] == BUS_SPACE_MEMIO) {
+		x = readb(ahd->bshs[0].maddr + port);
+	} else {
+		x = inb(ahd->bshs[(port) >> 8].ioport + ((port) & 0xFF));
+	}
+#else
+	x = inb(ahd->bshs[(port) >> 8].ioport + ((port) & 0xFF));
+#endif
+	mb();
+	return (x);
+}
+
+static __inline uint16_t
+ahd_inw_atomic(struct ahd_softc * ahd, long port)
+{
+	uint8_t x;
+#ifdef MMAPIO
+
+	if (ahd->tags[0] == BUS_SPACE_MEMIO) {
+		x = readw(ahd->bshs[0].maddr + port);
+	} else {
+		x = inw(ahd->bshs[(port) >> 8].ioport + ((port) & 0xFF));
+	}
+#else
+	x = inw(ahd->bshs[(port) >> 8].ioport + ((port) & 0xFF));
+#endif
+	mb();
+	return (x);
+}
+
+static __inline void
+ahd_outb(struct ahd_softc * ahd, long port, uint8_t val)
+{
+#ifdef MMAPIO
+	if (ahd->tags[0] == BUS_SPACE_MEMIO) {
+		writeb(val, ahd->bshs[0].maddr + port);
+	} else {
+		outb(val, ahd->bshs[(port) >> 8].ioport + (port & 0xFF));
+	}
+#else
+	outb(val, ahd->bshs[(port) >> 8].ioport + (port & 0xFF));
+#endif
+	mb();
+}
+
+static __inline void
+ahd_outw_atomic(struct ahd_softc * ahd, long port, uint16_t val)
+{
+#ifdef MMAPIO
+	if (ahd->tags[0] == BUS_SPACE_MEMIO) {
+		writew(val, ahd->bshs[0].maddr + port);
+	} else {
+		outw(val, ahd->bshs[(port) >> 8].ioport + (port & 0xFF));
+	}
+#else
+	outw(val, ahd->bshs[(port) >> 8].ioport + (port & 0xFF));
+#endif
+	mb();
+}
+
+static __inline void
+ahd_outsb(struct ahd_softc * ahd, long port, uint8_t *array, int count)
+{
+	int i;
+
+	/*
+	 * There is probably a more efficient way to do this on Linux
+	 * but we don't use this for anything speed critical and this
+	 * should work.
+	 */
+	for (i = 0; i < count; i++)
+		ahd_outb(ahd, port, *array++);
+}
+
+static __inline void
+ahd_insb(struct ahd_softc * ahd, long port, uint8_t *array, int count)
+{
+	int i;
+
+	/*
+	 * There is probably a more efficient way to do this on Linux
+	 * but we don't use this for anything speed critical and this
+	 * should work.
+	 */
+	for (i = 0; i < count; i++)
+		*array++ = ahd_inb(ahd, port);
+}
+
+/**************************** Initialization **********************************/
+int		ahd_linux_register_host(struct ahd_softc *,
+					Scsi_Host_Template *);
+
+uint64_t	ahd_linux_get_memsize(void);
+
+/*************************** Pretty Printing **********************************/
+struct info_str {
+	char *buffer;
+	int length;
+	off_t offset;
+	int pos;
+};
+
+void	ahd_format_transinfo(struct info_str *info,
+			     struct ahd_transinfo *tinfo);
+
+/******************************** Locking *************************************/
+/* Lock protecting internal data structures */
+static __inline void ahd_lockinit(struct ahd_softc *);
+static __inline void ahd_lock(struct ahd_softc *, unsigned long *flags);
+static __inline void ahd_unlock(struct ahd_softc *, unsigned long *flags);
+
+/* Lock acquisition and release of the above lock in midlayer entry points. */
+static __inline void ahd_midlayer_entrypoint_lock(struct ahd_softc *,
+						  unsigned long *flags);
+static __inline void ahd_midlayer_entrypoint_unlock(struct ahd_softc *,
+						    unsigned long *flags);
+
+/* Lock held during command compeletion to the upper layer */
+static __inline void ahd_done_lockinit(struct ahd_softc *);
+static __inline void ahd_done_lock(struct ahd_softc *, unsigned long *flags);
+static __inline void ahd_done_unlock(struct ahd_softc *, unsigned long *flags);
+
+/* Lock held during ahd_list manipulation and ahd softc frees */
+extern spinlock_t ahd_list_spinlock;
+static __inline void ahd_list_lockinit(void);
+static __inline void ahd_list_lock(unsigned long *flags);
+static __inline void ahd_list_unlock(unsigned long *flags);
+
+static __inline void
+ahd_lockinit(struct ahd_softc *ahd)
+{
+	spin_lock_init(&ahd->platform_data->spin_lock);
+}
+
+static __inline void
+ahd_lock(struct ahd_softc *ahd, unsigned long *flags)
+{
+	spin_lock_irqsave(&ahd->platform_data->spin_lock, *flags);
+}
+
+static __inline void
+ahd_unlock(struct ahd_softc *ahd, unsigned long *flags)
+{
+	spin_unlock_irqrestore(&ahd->platform_data->spin_lock, *flags);
+}
+
+static __inline void
+ahd_midlayer_entrypoint_lock(struct ahd_softc *ahd, unsigned long *flags)
+{
+	/*
+	 * In 2.5.X and some 2.4.X versions, the midlayer takes our
+	 * lock just before calling us, so we avoid locking again.
+	 * For other kernel versions, the io_request_lock is taken
+	 * just before our entry point is called.  In this case, we
+	 * trade the io_request_lock for our per-softc lock.
+	 */
+#if AHD_SCSI_HAS_HOST_LOCK == 0
+	spin_unlock(&io_request_lock);
+	spin_lock(&ahd->platform_data->spin_lock);
+#endif
+}
+
+static __inline void
+ahd_midlayer_entrypoint_unlock(struct ahd_softc *ahd, unsigned long *flags)
+{
+#if AHD_SCSI_HAS_HOST_LOCK == 0
+	spin_unlock(&ahd->platform_data->spin_lock);
+	spin_lock(&io_request_lock);
+#endif
+}
+
+static __inline void
+ahd_done_lockinit(struct ahd_softc *ahd)
+{
+	/*
+	 * In 2.5.X, our own lock is held during completions.
+	 * In previous versions, the io_request_lock is used.
+	 * In either case, we can't initialize this lock again.
+	 */
+}
+
+static __inline void
+ahd_done_lock(struct ahd_softc *ahd, unsigned long *flags)
+{
+#if AHD_SCSI_HAS_HOST_LOCK == 0
+	spin_lock(&io_request_lock);
+#endif
+}
+
+static __inline void
+ahd_done_unlock(struct ahd_softc *ahd, unsigned long *flags)
+{
+#if AHD_SCSI_HAS_HOST_LOCK == 0
+	spin_unlock(&io_request_lock);
+#endif
+}
+
+static __inline void
+ahd_list_lockinit()
+{
+	spin_lock_init(&ahd_list_spinlock);
+}
+
+static __inline void
+ahd_list_lock(unsigned long *flags)
+{
+	spin_lock_irqsave(&ahd_list_spinlock, *flags);
+}
+
+static __inline void
+ahd_list_unlock(unsigned long *flags)
+{
+	spin_unlock_irqrestore(&ahd_list_spinlock, *flags);
+}
+
+/******************************* PCI Definitions ******************************/
+/*
+ * PCIM_xxx: mask to locate subfield in register
+ * PCIR_xxx: config register offset
+ * PCIC_xxx: device class
+ * PCIS_xxx: device subclass
+ * PCIP_xxx: device programming interface
+ * PCIV_xxx: PCI vendor ID (only required to fixup ancient devices)
+ * PCID_xxx: device ID
+ */
+#define PCIR_DEVVENDOR		0x00
+#define PCIR_VENDOR		0x00
+#define PCIR_DEVICE		0x02
+#define PCIR_COMMAND		0x04
+#define PCIM_CMD_PORTEN		0x0001
+#define PCIM_CMD_MEMEN		0x0002
+#define PCIM_CMD_BUSMASTEREN	0x0004
+#define PCIM_CMD_MWRICEN	0x0010
+#define PCIM_CMD_PERRESPEN	0x0040
+#define	PCIM_CMD_SERRESPEN	0x0100
+#define PCIR_STATUS		0x06
+#define PCIR_REVID		0x08
+#define PCIR_PROGIF		0x09
+#define PCIR_SUBCLASS		0x0a
+#define PCIR_CLASS		0x0b
+#define PCIR_CACHELNSZ		0x0c
+#define PCIR_LATTIMER		0x0d
+#define PCIR_HEADERTYPE		0x0e
+#define PCIM_MFDEV		0x80
+#define PCIR_BIST		0x0f
+#define PCIR_CAP_PTR		0x34
+
+/* config registers for header type 0 devices */
+#define PCIR_MAPS	0x10
+#define PCIR_SUBVEND_0	0x2c
+#define PCIR_SUBDEV_0	0x2e
+
+/****************************** PCI-X definitions *****************************/
+#define PCIXR_COMMAND	0x96
+#define PCIXR_DEVADDR	0x98
+#define PCIXM_DEVADDR_FNUM	0x0003	/* Function Number */
+#define PCIXM_DEVADDR_DNUM	0x00F8	/* Device Number */
+#define PCIXM_DEVADDR_BNUM	0xFF00	/* Bus Number */
+#define PCIXR_STATUS	0x9A
+#define PCIXM_STATUS_64BIT	0x0001	/* Active 64bit connection to device. */
+#define PCIXM_STATUS_133CAP	0x0002	/* Device is 133MHz capable */
+#define PCIXM_STATUS_SCDISC	0x0004	/* Split Completion Discarded */
+#define PCIXM_STATUS_UNEXPSC	0x0008	/* Unexpected Split Completion */
+#define PCIXM_STATUS_CMPLEXDEV	0x0010	/* Device Complexity (set == bridge) */
+#define PCIXM_STATUS_MAXMRDBC	0x0060	/* Maximum Burst Read Count */
+#define PCIXM_STATUS_MAXSPLITS	0x0380	/* Maximum Split Transactions */
+#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
+{
+	AHD_POWER_STATE_D0,
+	AHD_POWER_STATE_D1,
+	AHD_POWER_STATE_D2,
+	AHD_POWER_STATE_D3
+} ahd_power_state;
+
+void ahd_power_state_change(struct ahd_softc *ahd,
+			    ahd_power_state new_state);
+
+/******************************* PCI Routines *********************************/
+int			 ahd_linux_pci_init(void);
+void			 ahd_linux_pci_exit(void);
+int			 ahd_pci_map_registers(struct ahd_softc *ahd);
+int			 ahd_pci_map_int(struct ahd_softc *ahd);
+
+static __inline uint32_t ahd_pci_read_config(ahd_dev_softc_t pci,
+					     int reg, int width);
+
+static __inline uint32_t
+ahd_pci_read_config(ahd_dev_softc_t pci, int reg, int width)
+{
+	switch (width) {
+	case 1:
+	{
+		uint8_t retval;
+
+		pci_read_config_byte(pci, reg, &retval);
+		return (retval);
+	}
+	case 2:
+	{
+		uint16_t retval;
+		pci_read_config_word(pci, reg, &retval);
+		return (retval);
+	}
+	case 4:
+	{
+		uint32_t retval;
+		pci_read_config_dword(pci, reg, &retval);
+		return (retval);
+	}
+	default:
+		panic("ahd_pci_read_config: Read size too big");
+		/* NOTREACHED */
+		return (0);
+	}
+}
+
+static __inline void ahd_pci_write_config(ahd_dev_softc_t pci,
+					  int reg, uint32_t value,
+					  int width);
+
+static __inline void
+ahd_pci_write_config(ahd_dev_softc_t pci, int reg, uint32_t value, int width)
+{
+	switch (width) {
+	case 1:
+		pci_write_config_byte(pci, reg, value);
+		break;
+	case 2:
+		pci_write_config_word(pci, reg, value);
+		break;
+	case 4:
+		pci_write_config_dword(pci, reg, value);
+		break;
+	default:
+		panic("ahd_pci_write_config: Write size too big");
+		/* NOTREACHED */
+	}
+}
+
+static __inline int ahd_get_pci_function(ahd_dev_softc_t);
+static __inline int
+ahd_get_pci_function(ahd_dev_softc_t pci)
+{
+	return (PCI_FUNC(pci->devfn));
+}
+
+static __inline int ahd_get_pci_slot(ahd_dev_softc_t);
+static __inline int
+ahd_get_pci_slot(ahd_dev_softc_t pci)
+{
+	return (PCI_SLOT(pci->devfn));
+}
+
+static __inline int ahd_get_pci_bus(ahd_dev_softc_t);
+static __inline int
+ahd_get_pci_bus(ahd_dev_softc_t pci)
+{
+	return (pci->bus->number);
+}
+
+static __inline void ahd_flush_device_writes(struct ahd_softc *);
+static __inline void
+ahd_flush_device_writes(struct ahd_softc *ahd)
+{
+	/* XXX Is this sufficient for all architectures??? */
+	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);
+#else
+int	ahd_linux_proc_info(struct Scsi_Host *, char *, char **,
+			    off_t, int, int);
+#endif
+
+/*************************** Domain Validation ********************************/
+#define AHD_DV_CMD(cmd) ((cmd)->scsi_done == ahd_linux_dv_complete)
+#define AHD_DV_SIMQ_FROZEN(ahd)					\
+	((((ahd)->platform_data->flags & AHD_DV_ACTIVE) != 0)	\
+	 && (ahd)->platform_data->qfrozen == 1)
+
+/*********************** Transaction Access Wrappers **************************/
+static __inline void ahd_cmd_set_transaction_status(Scsi_Cmnd *, uint32_t);
+static __inline void ahd_set_transaction_status(struct scb *, uint32_t);
+static __inline void ahd_cmd_set_scsi_status(Scsi_Cmnd *, uint32_t);
+static __inline void ahd_set_scsi_status(struct scb *, uint32_t);
+static __inline uint32_t ahd_cmd_get_transaction_status(Scsi_Cmnd *cmd);
+static __inline uint32_t ahd_get_transaction_status(struct scb *);
+static __inline uint32_t ahd_cmd_get_scsi_status(Scsi_Cmnd *cmd);
+static __inline uint32_t ahd_get_scsi_status(struct scb *);
+static __inline void ahd_set_transaction_tag(struct scb *, int, u_int);
+static __inline u_long ahd_get_transfer_length(struct scb *);
+static __inline int ahd_get_transfer_dir(struct scb *);
+static __inline void ahd_set_residual(struct scb *, u_long);
+static __inline void ahd_set_sense_residual(struct scb *scb, u_long resid);
+static __inline u_long ahd_get_residual(struct scb *);
+static __inline u_long ahd_get_sense_residual(struct scb *);
+static __inline int ahd_perform_autosense(struct scb *);
+static __inline uint32_t ahd_get_sense_bufsize(struct ahd_softc *,
+					       struct scb *);
+static __inline void ahd_notify_xfer_settings_change(struct ahd_softc *,
+						     struct ahd_devinfo *);
+static __inline void ahd_platform_scb_free(struct ahd_softc *ahd,
+					   struct scb *scb);
+static __inline void ahd_freeze_scb(struct scb *scb);
+
+static __inline
+void ahd_cmd_set_transaction_status(Scsi_Cmnd *cmd, uint32_t status)
+{
+	cmd->result &= ~(CAM_STATUS_MASK << 16);
+	cmd->result |= status << 16;
+}
+
+static __inline
+void ahd_set_transaction_status(struct scb *scb, uint32_t status)
+{
+	ahd_cmd_set_transaction_status(scb->io_ctx,status);
+}
+
+static __inline
+void ahd_cmd_set_scsi_status(Scsi_Cmnd *cmd, uint32_t status)
+{
+	cmd->result &= ~0xFFFF;
+	cmd->result |= status;
+}
+
+static __inline
+void ahd_set_scsi_status(struct scb *scb, uint32_t status)
+{
+	ahd_cmd_set_scsi_status(scb->io_ctx, status);
+}
+
+static __inline
+uint32_t ahd_cmd_get_transaction_status(Scsi_Cmnd *cmd)
+{
+	return ((cmd->result >> 16) & CAM_STATUS_MASK);
+}
+
+static __inline
+uint32_t ahd_get_transaction_status(struct scb *scb)
+{
+	return (ahd_cmd_get_transaction_status(scb->io_ctx));
+}
+
+static __inline
+uint32_t ahd_cmd_get_scsi_status(Scsi_Cmnd *cmd)
+{
+	return (cmd->result & 0xFFFF);
+}
+
+static __inline
+uint32_t ahd_get_scsi_status(struct scb *scb)
+{
+	return (ahd_cmd_get_scsi_status(scb->io_ctx));
+}
+
+static __inline
+void ahd_set_transaction_tag(struct scb *scb, int enabled, u_int type)
+{
+	/*
+	 * Nothing to do for linux as the incoming transaction
+	 * has no concept of tag/non tagged, etc.
+	 */
+}
+
+static __inline
+u_long ahd_get_transfer_length(struct scb *scb)
+{
+	return (scb->platform_data->xfer_len);
+}
+
+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
+void ahd_set_sense_residual(struct scb *scb, u_long resid)
+{
+	scb->platform_data->sense_resid = resid;
+}
+
+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
+u_long ahd_get_sense_residual(struct scb *scb)
+{
+	return (scb->platform_data->sense_resid);
+}
+
+static __inline
+int ahd_perform_autosense(struct scb *scb)
+{
+	/*
+	 * We always perform autosense in Linux.
+	 * On other platforms this is set on a
+	 * per-transaction basis.
+	 */
+	return (1);
+}
+
+static __inline uint32_t
+ahd_get_sense_bufsize(struct ahd_softc *ahd, struct scb *scb)
+{
+	return (sizeof(struct scsi_sense_data));
+}
+
+static __inline void
+ahd_notify_xfer_settings_change(struct ahd_softc *ahd,
+				struct ahd_devinfo *devinfo)
+{
+	/* Nothing to do here for linux */
+}
+
+static __inline void
+ahd_platform_scb_free(struct ahd_softc *ahd, struct scb *scb)
+{
+	ahd->flags &= ~AHD_RESOURCE_SHORTAGE;
+}
+
+int	ahd_platform_alloc(struct ahd_softc *ahd, void *platform_arg);
+void	ahd_platform_free(struct ahd_softc *ahd);
+void	ahd_platform_init(struct ahd_softc *ahd);
+void	ahd_platform_freeze_devq(struct ahd_softc *ahd, struct scb *scb);
+void	ahd_freeze_simq(struct ahd_softc *ahd);
+void	ahd_release_simq(struct ahd_softc *ahd);
+
+static __inline void
+ahd_freeze_scb(struct scb *scb)
+{
+	if ((scb->io_ctx->result & (CAM_DEV_QFRZN << 16)) == 0) {
+                scb->io_ctx->result |= CAM_DEV_QFRZN << 16;
+                scb->platform_data->dev->qfrozen++;
+        }
+}
+
+void	ahd_platform_set_tags(struct ahd_softc *ahd,
+			      struct ahd_devinfo *devinfo, ahd_queue_alg);
+int	ahd_platform_abort_scbs(struct ahd_softc *ahd, int target,
+				char channel, int lun, u_int tag,
+				role_t role, uint32_t status);
+irqreturn_t
+	ahd_linux_isr(int irq, void *dev_id, struct pt_regs * regs);
+void	ahd_platform_flushwork(struct ahd_softc *ahd);
+int	ahd_softc_comp(struct ahd_softc *, struct ahd_softc *);
+void	ahd_done(struct ahd_softc*, struct scb*);
+void	ahd_send_async(struct ahd_softc *, char channel,
+		       u_int target, u_int lun, ac_code, void *);
+void	ahd_print_path(struct ahd_softc *, struct scb *);
+void	ahd_platform_dump_card_state(struct ahd_softc *ahd);
+
+#ifdef CONFIG_PCI
+#define AHD_PCI_CONFIG 1
+#else
+#define AHD_PCI_CONFIG 0
+#endif
+#define bootverbose aic79xx_verbose
+extern uint32_t aic79xx_verbose;
+#endif /* _AIC79XX_LINUX_H_ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic79xx_osm_pci.c linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
--- linux-2.4.21/drivers/scsi/aic7xxx/aic79xx_osm_pci.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx_osm_pci.c	2003-06-26 21:43:12.000000000 +0000
@@ -0,0 +1,447 @@
+/*
+ * Linux driver attachment glue for PCI based U320 controllers.
+ *
+ * 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: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#24 $
+ */
+
+#include "aic79xx_osm.h"
+#include "aic79xx_inline.h"
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
+struct pci_device_id
+{
+};
+#endif
+
+static int	ahd_linux_pci_dev_probe(struct pci_dev *pdev,
+					const struct pci_device_id *ent);
+static int	ahd_linux_pci_reserve_io_regions(struct ahd_softc *ahd,
+						 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)
+static void	ahd_linux_pci_dev_remove(struct pci_dev *pdev);
+
+/* We do our own ID filtering.  So, grab all SCSI storage class devices. */
+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
+	},
+	{ 0 }
+};
+
+MODULE_DEVICE_TABLE(pci, ahd_linux_pci_id_table);
+
+struct pci_driver aic79xx_pci_driver = {
+	name:		"aic79xx",
+	probe:		ahd_linux_pci_dev_probe,
+	remove:		ahd_linux_pci_dev_remove,
+	id_table:	ahd_linux_pci_id_table
+};
+
+static void
+ahd_linux_pci_dev_remove(struct pci_dev *pdev)
+{
+	struct ahd_softc *ahd;
+	u_long l;
+
+	/*
+	 * We should be able to just perform
+	 * the free directly, but check our
+	 * list for extra sanity.
+	 */
+	ahd_list_lock(&l);
+	ahd = ahd_find_softc((struct ahd_softc *)pci_get_drvdata(pdev));
+	if (ahd != NULL) {
+		u_long s;
+
+		ahd_lock(ahd, &s);
+		ahd_intr_enable(ahd, FALSE);
+		ahd_unlock(ahd, &s);
+		ahd_free(ahd);
+	}
+	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)
+{
+	char		 buf[80];
+	struct		 ahd_softc *ahd;
+	ahd_dev_softc_t	 pci;
+	struct		 ahd_pci_identity *entry;
+	char		*name;
+	int		 error;
+
+	/*
+	 * Some BIOSen report the same device multiple times.
+	 */
+	TAILQ_FOREACH(ahd, &ahd_tailq, links) {
+		struct pci_dev *probed_pdev;
+
+		probed_pdev = ahd->dev_softc;
+		if (probed_pdev->bus->number == pdev->bus->number
+		 && probed_pdev->devfn == pdev->devfn)
+			break;
+	}
+	if (ahd != NULL) {
+		/* Skip duplicate. */
+		return (-ENODEV);
+	}
+
+	pci = pdev;
+	entry = ahd_find_pci_device(pci);
+	if (entry == NULL)
+		return (-ENODEV);
+
+	/*
+	 * Allocate a softc for this card and
+	 * set it up for attachment by our
+	 * common detect routine.
+	 */
+	sprintf(buf, "ahd_pci:%d:%d:%d",
+		ahd_get_pci_bus(pci),
+		ahd_get_pci_slot(pci),
+		ahd_get_pci_function(pci));
+	name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT);
+	if (name == NULL)
+		return (-ENOMEM);
+	strcpy(name, buf);
+	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) {
+		uint64_t   memsize;
+		bus_addr_t mask_64bit;
+		bus_addr_t mask_39bit;
+
+		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) {
+			ahd->flags |= AHD_64BIT_ADDRESSING;
+			ahd->platform_data->hw_dma_mask = mask_64bit;
+		} else if (memsize > 0x80000000
+			&& ahd_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;
+	}
+#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)
+		ahd_linux_register_host(ahd, &aic79xx_driver_template);
+#else
+		printf("aic79xx: ignoring PCI device found after "
+		       "initialization\n");
+		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
+ahd_linux_pci_exit(void)
+{
+	pci_unregister_driver(&aic79xx_pci_driver);
+}
+
+static int
+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,
+	 * but the Linux PCI code doesn't know how to "count" 64bit
+	 * 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)
+{
+	u_long	start;
+	u_long	base_page;
+	u_long	base_offset;
+	int	error;
+
+	if (aic79xx_allow_memio == 0)
+		return (ENOMEM);
+
+	if ((ahd->bugs & AHD_PCIX_MMAPIO_BUG) != 0)
+		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;
+		}
+	} else
+		error = ENOMEM;
+	return (error);
+}
+
+int
+ahd_pci_map_registers(struct ahd_softc *ahd)
+{
+	uint32_t command;
+	u_long	 base;
+	uint8_t	*maddr;
+	int	 error;
+
+	/*
+	 * If its allowed, we prefer memory mapped access.
+	 */
+	command = ahd_pci_read_config(ahd->dev_softc, PCIR_COMMAND, 4);
+	command &= ~(PCIM_CMD_PORTEN|PCIM_CMD_MEMEN);
+	base = 0;
+	maddr = NULL;
+#ifdef MMAPIO
+	error = ahd_linux_pci_reserve_mem_region(ahd, &base, &maddr);
+	if (error == 0) {
+		ahd->platform_data->mem_busaddr = base;
+		ahd->tags[0] = BUS_SPACE_MEMIO;
+		ahd->bshs[0].maddr = maddr;
+		ahd->tags[1] = BUS_SPACE_MEMIO;
+		ahd->bshs[1].maddr = maddr + 0x100;
+		ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND,
+				     command | PCIM_CMD_MEMEN, 4);
+
+		if (ahd_pci_test_register_access(ahd) != 0) {
+
+			printf("aic79xx: PCI Device %d:%d:%d "
+			       "failed memory mapped test.  Using PIO.\n",
+			       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)
+			release_mem_region(ahd->platform_data->mem_busaddr,
+					   0x1000);
+#endif
+			ahd->bshs[0].maddr = NULL;
+			maddr = NULL;
+		} else
+			command |= PCIM_CMD_MEMEN;
+	} else if (bootverbose) {
+		printf("aic79xx: PCI%d:%d:%d MEM region 0x%lx "
+		       "unavailable. Cannot memory map device.\n",
+		       ahd_get_pci_bus(ahd->dev_softc),
+		       ahd_get_pci_slot(ahd->dev_softc),
+		       ahd_get_pci_function(ahd->dev_softc),
+		       base);
+	}
+#endif
+
+	if (maddr == NULL) {
+		u_long	 base2;
+
+		error = ahd_linux_pci_reserve_io_regions(ahd, &base, &base2);
+		if (error == 0) {
+			ahd->tags[0] = BUS_SPACE_PIO;
+			ahd->tags[1] = BUS_SPACE_PIO;
+			ahd->bshs[0].ioport = base;
+			ahd->bshs[1].ioport = base2;
+			command |= PCIM_CMD_PORTEN;
+		} else {
+			printf("aic79xx: PCI%d:%d:%d IO regions 0x%lx and 0x%lx"
+			       "unavailable. Cannot map device.\n",
+			       ahd_get_pci_bus(ahd->dev_softc),
+			       ahd_get_pci_slot(ahd->dev_softc),
+			       ahd_get_pci_function(ahd->dev_softc),
+			       base, base2);
+		}
+	}
+	ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND, command, 4);
+	return (error);
+}
+
+int
+ahd_pci_map_int(struct ahd_softc *ahd)
+{
+	int error;
+
+	error = request_irq(ahd->dev_softc->irq, ahd_linux_isr,
+			    SA_SHIRQ, "aic79xx", ahd);
+	if (error == 0)
+		ahd->platform_data->irq = ahd->dev_softc->irq;
+	
+	return (-error);
+}
+
+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 -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic79xx_pci.c linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx_pci.c
--- linux-2.4.21/drivers/scsi/aic7xxx/aic79xx_pci.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx_pci.c	2003-06-26 21:43:17.000000000 +0000
@@ -0,0 +1,1006 @@
+/*
+ * Product specific probe and attach routines for:
+ *	aic7901 and aic7902 SCSI controllers
+ *
+ * Copyright (c) 1994-2001 Justin T. Gibbs.
+ * Copyright (c) 2000-2002 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: //depot/aic7xxx/aic7xxx/aic79xx_pci.c#75 $
+ *
+ * $FreeBSD$
+ */
+
+#ifdef __linux__
+#include "aic79xx_osm.h"
+#include "aic79xx_inline.h"
+#else
+#include <dev/aic7xxx/aic79xx_osm.h>
+#include <dev/aic7xxx/aic79xx_inline.h>
+#endif
+
+static __inline uint64_t
+ahd_compose_id(u_int device, u_int vendor, u_int subdevice, u_int subvendor)
+{
+	uint64_t id;
+
+	id = subvendor
+	   | (subdevice << 16)
+	   | ((uint64_t)vendor << 32)
+	   | ((uint64_t)device << 48);
+
+	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_TYPE(id) ((id) & 0xF)
+#define		DEVID_9005_TYPE_HBA		0x0	/* Standard Card */
+#define		DEVID_9005_TYPE_HBA_2EXT	0x1	/* 2 External Ports */
+#define		DEVID_9005_TYPE_IROC		0x8	/* Raid(0,1,10) Card */
+#define		DEVID_9005_TYPE_MB		0xF	/* On Motherboard */
+
+#define DEVID_9005_MFUNC(id) ((id) & 0x10)
+
+#define DEVID_9005_PACKETIZED(id) ((id) & 0x8000)
+
+#define SUBID_9005_TYPE(id) ((id) & 0xF)
+#define		SUBID_9005_TYPE_HBA		0x0	/* Standard Card */
+#define		SUBID_9005_TYPE_MB		0xF	/* On Motherboard */
+
+#define SUBID_9005_AUTOTERM(id)	(((id) & 0x10) == 0)
+
+#define SUBID_9005_LEGACYCONN_FUNC(id) ((id) & 0x20)
+
+#define SUBID_9005_SEEPTYPE(id) ((id) & 0x0C0) >> 6)
+#define		SUBID_9005_SEEPTYPE_NONE	0x0
+#define		SUBID_9005_SEEPTYPE_4K		0x1
+
+static ahd_device_setup_t ahd_aic7901_setup;
+static ahd_device_setup_t ahd_aic7901A_setup;
+static ahd_device_setup_t ahd_aic7902_setup;
+
+struct ahd_pci_identity ahd_pci_ident_table [] =
+{
+	/* aic7901 based controllers */
+	{
+		ID_AHA_29320A,
+		ID_ALL_MASK,
+		"Adaptec 29320A Ultra320 SCSI adapter",
+		ahd_aic7901_setup
+	},
+	{
+		ID_AHA_29320ALP,
+		ID_ALL_MASK,
+		"Adaptec 29320ALP Ultra320 SCSI adapter",
+		ahd_aic7901_setup
+	},
+	/* aic7901A based controllers */
+	{
+		ID_AHA_29320,
+		ID_ALL_MASK,
+		"Adaptec 29320 Ultra320 SCSI adapter",
+		ahd_aic7901A_setup
+	},
+	{
+		ID_AHA_29320B,
+		ID_ALL_MASK,
+		"Adaptec 29320B Ultra320 SCSI adapter",
+		ahd_aic7901A_setup
+	},
+	{
+		ID_AHA_29320LP,
+		ID_ALL_MASK,
+		"Adaptec 29320LP Ultra320 SCSI adapter",
+		ahd_aic7901A_setup
+	},
+	/* aic7902 based controllers */	
+	{
+		ID_AHA_39320,
+		ID_ALL_MASK,
+		"Adaptec 39320 Ultra320 SCSI adapter",
+		ahd_aic7902_setup
+	},
+	{
+		ID_AHA_39320_B,
+		ID_ALL_MASK,
+		"Adaptec 39320 Ultra320 SCSI adapter",
+		ahd_aic7902_setup
+	},
+	{
+		ID_AHA_39320A,
+		ID_ALL_MASK,
+		"Adaptec 39320A Ultra320 SCSI adapter",
+		ahd_aic7902_setup
+	},
+	{
+		ID_AHA_39320D,
+		ID_ALL_MASK,
+		"Adaptec 39320D Ultra320 SCSI adapter",
+		ahd_aic7902_setup
+	},
+	{
+		ID_AHA_39320D_HP,
+		ID_ALL_MASK,
+		"Adaptec (HP OEM) 39320D Ultra320 SCSI adapter",
+		ahd_aic7902_setup
+	},
+	{
+		ID_AHA_39320D_B,
+		ID_ALL_MASK,
+		"Adaptec 39320D Ultra320 SCSI adapter",
+		ahd_aic7902_setup
+	},
+	{
+		ID_AHA_39320D_B_HP,
+		ID_ALL_MASK,
+		"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,
+		"Adaptec AIC7901 Ultra320 SCSI adapter",
+		ahd_aic7901_setup
+	},
+	{
+		ID_AIC7901A & ID_DEV_VENDOR_MASK,
+		ID_DEV_VENDOR_MASK,
+		"Adaptec AIC7901A Ultra320 SCSI adapter",
+		ahd_aic7901A_setup
+	},
+	{
+		ID_AIC7902 & ID_9005_GENERIC_MASK,
+		ID_9005_GENERIC_MASK,
+		"Adaptec AIC7902 Ultra320 SCSI adapter",
+		ahd_aic7902_setup
+	}
+};
+
+const u_int ahd_num_pci_devs = NUM_ELEMENTS(ahd_pci_ident_table);
+		
+#define	DEVCONFIG		0x40
+#define		PCIXINITPAT	0x0000E000ul
+#define			PCIXINIT_PCI33_66	0x0000E000ul
+#define			PCIXINIT_PCIX50_66	0x0000C000ul
+#define			PCIXINIT_PCIX66_100	0x0000A000ul
+#define			PCIXINIT_PCIX100_133	0x00008000ul
+#define	PCI_BUS_MODES_INDEX(devconfig)	\
+	(((devconfig) & PCIXINITPAT) >> 13)
+static const char *pci_bus_modes[] =
+{
+	"PCI bus mode unknown",
+	"PCI bus mode unknown",
+	"PCI bus mode unknown",
+	"PCI bus mode unknown",
+	"PCI-X 101-133Mhz",
+	"PCI-X 67-100Mhz",
+	"PCI-X 50-66Mhz",
+	"PCI 33 or 66Mhz"
+};
+
+#define		TESTMODE	0x00000800ul
+#define		IRDY_RST	0x00000200ul
+#define		FRAME_RST	0x00000100ul
+#define		PCI64BIT	0x00000080ul
+#define		MRDCEN		0x00000040ul
+#define		ENDIANSEL	0x00000020ul
+#define		MIXQWENDIANEN	0x00000008ul
+#define		DACEN		0x00000004ul
+#define		STPWLEVEL	0x00000002ul
+#define		QWENDIANSEL	0x00000001ul
+
+#define	DEVCONFIG1		0x44
+#define		PREQDIS		0x01
+
+#define	CSIZE_LATTIME		0x0c
+#define		CACHESIZE	0x000000fful
+#define		LATTIME		0x0000ff00ul
+
+static int	ahd_check_extport(struct ahd_softc *ahd);
+static void	ahd_configure_termination(struct ahd_softc *ahd,
+					  u_int adapter_control);
+static void	ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat);
+
+struct ahd_pci_identity *
+ahd_find_pci_device(ahd_dev_softc_t pci)
+{
+	uint64_t  full_id;
+	uint16_t  device;
+	uint16_t  vendor;
+	uint16_t  subdevice;
+	uint16_t  subvendor;
+	struct	  ahd_pci_identity *entry;
+	u_int	  i;
+
+	vendor = ahd_pci_read_config(pci, PCIR_DEVVENDOR, /*bytes*/2);
+	device = ahd_pci_read_config(pci, PCIR_DEVICE, /*bytes*/2);
+	subvendor = ahd_pci_read_config(pci, PCIR_SUBVEND_0, /*bytes*/2);
+	subdevice = ahd_pci_read_config(pci, PCIR_SUBDEV_0, /*bytes*/2);
+	full_id = ahd_compose_id(device,
+				 vendor,
+				 subdevice,
+				 subvendor);
+
+	for (i = 0; i < ahd_num_pci_devs; i++) {
+		entry = &ahd_pci_ident_table[i];
+		if (entry->full_id == (full_id & entry->id_mask)) {
+			/* Honor exclusion entries. */
+			if (entry->name == NULL)
+				return (NULL);
+			return (entry);
+		}
+	}
+	return (NULL);
+}
+
+int
+ahd_pci_config(struct ahd_softc *ahd, struct ahd_pci_identity *entry)
+{
+	struct scb_data *shared_scb_data;
+	u_long		 l;
+	u_int		 command;
+	uint32_t	 devconfig;
+	uint16_t	 subvendor; 
+	int		 error;
+
+	shared_scb_data = NULL;
+	ahd->description = entry->name;
+	/*
+	 * Record if this is an HP board.
+	 */
+	subvendor = ahd_pci_read_config(ahd->dev_softc,
+					PCIR_SUBVEND_0, /*bytes*/2);
+	if (subvendor == SUBID_HP)
+		ahd->flags |= AHD_HP_BOARD;
+
+	error = entry->setup(ahd);
+	if (error != 0)
+		return (error);
+	
+	devconfig = ahd_pci_read_config(ahd->dev_softc, DEVCONFIG, /*bytes*/4);
+	if ((devconfig & PCIXINITPAT) == PCIXINIT_PCI33_66) {
+		ahd->chip |= AHD_PCI;
+		/* Disable PCIX workarounds when running in PCI mode. */
+		ahd->bugs &= ~AHD_PCIX_BUG_MASK;
+	} else {
+		ahd->chip |= AHD_PCIX;
+	}
+	ahd->bus_description = pci_bus_modes[PCI_BUS_MODES_INDEX(devconfig)];
+
+	ahd_power_state_change(ahd, AHD_POWER_STATE_D0);
+
+	error = ahd_pci_map_registers(ahd);
+	if (error != 0)
+		return (error);
+
+	/*
+	 * If we need to support high memory, enable dual
+	 * address cycles.  This bit must be set to enable
+	 * high address bit generation even if we are on a
+	 * 64bit bus (PCI64BIT set in devconfig).
+	 */
+	if ((ahd->flags & (AHD_39BIT_ADDRESSING|AHD_64BIT_ADDRESSING)) != 0) {
+		uint32_t devconfig;
+
+		if (bootverbose)
+			printf("%s: Enabling 39Bit Addressing\n",
+			       ahd_name(ahd));
+		devconfig = ahd_pci_read_config(ahd->dev_softc,
+						DEVCONFIG, /*bytes*/4);
+		devconfig |= DACEN;
+		ahd_pci_write_config(ahd->dev_softc, DEVCONFIG,
+				     devconfig, /*bytes*/4);
+	}
+	
+	/* Ensure busmastering is enabled */
+	command = ahd_pci_read_config(ahd->dev_softc, PCIR_COMMAND, /*bytes*/2);
+	command |= PCIM_CMD_BUSMASTEREN;
+	ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND, command, /*bytes*/2);
+
+	error = ahd_softc_init(ahd);
+	if (error != 0)
+		return (error);
+
+	ahd->bus_intr = ahd_pci_intr;
+
+	error = ahd_reset(ahd, /*reinit*/FALSE);
+	if (error != 0)
+		return (ENXIO);
+
+	ahd->pci_cachesize =
+	    ahd_pci_read_config(ahd->dev_softc, CSIZE_LATTIME,
+				/*bytes*/1) & CACHESIZE;
+	ahd->pci_cachesize *= 4;
+
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+	/* See if we have a SEEPROM and perform auto-term */
+	error = ahd_check_extport(ahd);
+	if (error != 0)
+		return (error);
+
+	/* Core initialization */
+	error = ahd_init(ahd);
+	if (error != 0)
+		return (error);
+
+	/*
+	 * Allow interrupts now that we are completely setup.
+	 */
+	error = ahd_pci_map_int(ahd);
+	if (error != 0)
+		return (error);
+
+	ahd_list_lock(&l);
+	/*
+	 * Link this softc in with all other ahd instances.
+	 */
+	ahd_softc_insert(ahd);
+	ahd_list_unlock(&l);
+	return (0);
+}
+
+/*
+ * Perform some simple tests that should catch situations where
+ * our registers are invalidly mapped.
+ */
+int
+ahd_pci_test_register_access(struct ahd_softc *ahd)
+{
+	uint32_t cmd;
+	u_int	 targpcistat;
+	u_int	 pci_status1;
+	int	 error;
+	uint8_t	 hcntrl;
+
+	error = EIO;
+
+	/*
+	 * Enable PCI error interrupt status, but suppress NMIs
+	 * generated by SERR raised due to target aborts.
+	 */
+	cmd = ahd_pci_read_config(ahd->dev_softc, PCIR_COMMAND, /*bytes*/2);
+	ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND,
+			     cmd & ~PCIM_CMD_SERRESPEN, /*bytes*/2);
+
+	/*
+	 * First a simple test to see if any
+	 * registers can be read.  Reading
+	 * HCNTRL has no side effects and has
+	 * at least one bit that is guaranteed to
+	 * be zero so it is a good register to
+	 * use for this test.
+	 */
+	hcntrl = ahd_inb(ahd, HCNTRL);
+	if (hcntrl == 0xFF)
+		goto fail;
+
+	/*
+	 * Next create a situation where write combining
+	 * or read prefetching could be initiated by the
+	 * CPU or host bridge.  Our device does not support
+	 * either, so look for data corruption and/or flaged
+	 * PCI errors.
+	 */
+	ahd_outb(ahd, HCNTRL, hcntrl|PAUSE);
+	while (ahd_is_paused(ahd) == 0)
+		;
+
+	/* Clear any PCI errors that occurred before our driver attached. */
+	ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
+	targpcistat = ahd_inb(ahd, TARGPCISTAT);
+	ahd_outb(ahd, TARGPCISTAT, targpcistat);
+	pci_status1 = ahd_pci_read_config(ahd->dev_softc,
+					  PCIR_STATUS + 1, /*bytes*/1);
+	ahd_pci_write_config(ahd->dev_softc, PCIR_STATUS + 1,
+			     pci_status1, /*bytes*/1);
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+	ahd_outb(ahd, CLRINT, CLRPCIINT);
+
+	ahd_outb(ahd, SEQCTL0, PERRORDIS);
+	ahd_outl(ahd, SRAM_BASE, 0x5aa555aa);
+	if (ahd_inl(ahd, SRAM_BASE) != 0x5aa555aa)
+		goto fail;
+
+	if ((ahd_inb(ahd, INTSTAT) & PCIINT) != 0) {
+		u_int targpcistat;
+
+		ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
+		targpcistat = ahd_inb(ahd, TARGPCISTAT);
+		if ((targpcistat & STA) != 0)
+			goto fail;
+	}
+
+	error = 0;
+
+fail:
+	if ((ahd_inb(ahd, INTSTAT) & PCIINT) != 0) {
+
+		ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
+		targpcistat = ahd_inb(ahd, TARGPCISTAT);
+
+		/* Silently clear any latched errors. */
+		ahd_outb(ahd, TARGPCISTAT, targpcistat);
+		pci_status1 = ahd_pci_read_config(ahd->dev_softc,
+						  PCIR_STATUS + 1, /*bytes*/1);
+		ahd_pci_write_config(ahd->dev_softc, PCIR_STATUS + 1,
+				     pci_status1, /*bytes*/1);
+		ahd_outb(ahd, CLRINT, CLRPCIINT);
+	}
+	ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS);
+	ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND, cmd, /*bytes*/2);
+	return (error);
+}
+
+/*
+ * Check the external port logic for a serial eeprom
+ * and termination/cable detection contrls.
+ */
+static int
+ahd_check_extport(struct ahd_softc *ahd)
+{
+	struct	vpd_config vpd;
+	struct	seeprom_config *sc;
+	u_int	adapter_control;
+	int	have_seeprom;
+	int	error;
+
+	sc = ahd->seep_config;
+	have_seeprom = ahd_acquire_seeprom(ahd);
+	if (have_seeprom) {
+		u_int start_addr;
+
+		/*
+		 * Fetch VPD for this function and parse it.
+		 */
+		if (bootverbose) 
+			printf("%s: Reading VPD from SEEPROM...",
+			       ahd_name(ahd));
+
+		/* Address is always in units of 16bit words */
+		start_addr = ((2 * sizeof(*sc))
+			    + (sizeof(vpd) * (ahd->channel - 'A'))) / 2;
+
+		error = ahd_read_seeprom(ahd, (uint16_t *)&vpd,
+					 start_addr, sizeof(vpd)/2,
+					 /*bytestream*/TRUE);
+		if (error == 0)
+			error = ahd_parse_vpddata(ahd, &vpd);
+		if (bootverbose) 
+			printf("%s: VPD parsing %s\n",
+			       ahd_name(ahd),
+			       error == 0 ? "successful" : "failed");
+
+		if (bootverbose) 
+			printf("%s: Reading SEEPROM...", ahd_name(ahd));
+
+		/* Address is always in units of 16bit words */
+		start_addr = (sizeof(*sc) / 2) * (ahd->channel - 'A');
+
+		error = ahd_read_seeprom(ahd, (uint16_t *)sc,
+					 start_addr, sizeof(*sc)/2,
+					 /*bytestream*/FALSE);
+
+		if (error != 0) {
+			printf("Unable to read SEEPROM\n");
+			have_seeprom = 0;
+		} else {
+			have_seeprom = ahd_verify_cksum(sc);
+
+			if (bootverbose) {
+				if (have_seeprom == 0)
+					printf ("checksum error\n");
+				else
+					printf ("done.\n");
+			}
+		}
+		ahd_release_seeprom(ahd);
+	}
+
+	if (!have_seeprom) {
+		u_int	  nvram_scb;
+
+		/*
+		 * Pull scratch ram settings and treat them as
+		 * if they are the contents of an seeprom if
+		 * the 'ADPT', 'BIOS', or 'ASPI' signature is found
+		 * in SCB 0xFF.  We manually compose the data as 16bit
+		 * values to avoid endian issues.
+		 */
+		ahd_set_scbptr(ahd, 0xFF);
+		nvram_scb = ahd_inb_scbram(ahd, SCB_BASE + NVRAM_SCB_OFFSET);
+		if (nvram_scb != 0xFF
+		 && ((ahd_inb_scbram(ahd, SCB_BASE + 0) == 'A'
+		   && ahd_inb_scbram(ahd, SCB_BASE + 1) == 'D'
+		   && ahd_inb_scbram(ahd, SCB_BASE + 2) == 'P'
+		   && ahd_inb_scbram(ahd, SCB_BASE + 3) == 'T')
+		  || (ahd_inb_scbram(ahd, SCB_BASE + 0) == 'B'
+		   && ahd_inb_scbram(ahd, SCB_BASE + 1) == 'I'
+		   && ahd_inb_scbram(ahd, SCB_BASE + 2) == 'O'
+		   && ahd_inb_scbram(ahd, SCB_BASE + 3) == 'S')
+		  || (ahd_inb_scbram(ahd, SCB_BASE + 0) == 'A'
+		   && ahd_inb_scbram(ahd, SCB_BASE + 1) == 'S'
+		   && ahd_inb_scbram(ahd, SCB_BASE + 2) == 'P'
+		   && ahd_inb_scbram(ahd, SCB_BASE + 3) == 'I'))) {
+			uint16_t *sc_data;
+			int	  i;
+
+			ahd_set_scbptr(ahd, nvram_scb);
+			sc_data = (uint16_t *)sc;
+			for (i = 0; i < 64; i += 2)
+				*sc_data++ = ahd_inw_scbram(ahd, SCB_BASE+i);
+			have_seeprom = ahd_verify_cksum(sc);
+			if (have_seeprom)
+				ahd->flags |= AHD_SCB_CONFIG_USED;
+		}
+	}
+
+#if AHD_DEBUG
+	if (have_seeprom != 0
+	 && (ahd_debug & AHD_DUMP_SEEPROM) != 0) {
+		uint16_t *sc_data;
+		int	  i;
+
+		printf("%s: Seeprom Contents:", ahd_name(ahd));
+		sc_data = (uint16_t *)sc;
+		for (i = 0; i < (sizeof(*sc)); i += 2)
+			printf("\n\t0x%.4x", sc_data[i]);
+		printf("\n");
+	}
+#endif
+
+	if (!have_seeprom) {
+		if (bootverbose)
+			printf("%s: No SEEPROM available.\n", ahd_name(ahd));
+		ahd->flags |= AHD_USEDEFAULTS;
+		error = ahd_default_config(ahd);
+		adapter_control = CFAUTOTERM|CFSEAUTOTERM;
+		free(ahd->seep_config, M_DEVBUF);
+		ahd->seep_config = NULL;
+	} else {
+		error = ahd_parse_cfgdata(ahd, sc);
+		adapter_control = sc->adapter_control;
+	}
+	if (error != 0)
+		return (error);
+
+	ahd_configure_termination(ahd, adapter_control);
+
+	return (0);
+}
+
+static void
+ahd_configure_termination(struct ahd_softc *ahd, u_int adapter_control)
+{
+	int	 error;
+	u_int	 sxfrctl1;
+	uint8_t	 termctl;
+	uint32_t devconfig;
+
+	devconfig = ahd_pci_read_config(ahd->dev_softc, DEVCONFIG, /*bytes*/4);
+	devconfig &= ~STPWLEVEL;
+	if ((ahd->flags & AHD_STPWLEVEL_A) != 0)
+		devconfig |= STPWLEVEL;
+	if (bootverbose)
+		printf("%s: STPWLEVEL is %s\n",
+		       ahd_name(ahd), (devconfig & STPWLEVEL) ? "on" : "off");
+	ahd_pci_write_config(ahd->dev_softc, DEVCONFIG, devconfig, /*bytes*/4);
+ 
+	/* Make sure current sensing is off. */
+	if ((ahd->flags & AHD_CURRENT_SENSING) != 0) {
+		(void)ahd_write_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL, 0);
+	}
+
+	/*
+	 * Read to sense.  Write to set.
+	 */
+	error = ahd_read_flexport(ahd, FLXADDR_TERMCTL, &termctl);
+	if ((adapter_control & CFAUTOTERM) == 0) {
+		if (bootverbose)
+			printf("%s: Manual Primary Termination\n",
+			       ahd_name(ahd));
+		termctl &= ~(FLX_TERMCTL_ENPRILOW|FLX_TERMCTL_ENPRIHIGH);
+		if ((adapter_control & CFSTERM) != 0)
+			termctl |= FLX_TERMCTL_ENPRILOW;
+		if ((adapter_control & CFWSTERM) != 0)
+			termctl |= FLX_TERMCTL_ENPRIHIGH;
+	} else if (error != 0) {
+		printf("%s: Primary Auto-Term Sensing failed! "
+		       "Using Defaults.\n", ahd_name(ahd));
+		termctl = FLX_TERMCTL_ENPRILOW|FLX_TERMCTL_ENPRIHIGH;
+	}
+
+	if ((adapter_control & CFSEAUTOTERM) == 0) {
+		if (bootverbose)
+			printf("%s: Manual Secondary Termination\n",
+			       ahd_name(ahd));
+		termctl &= ~(FLX_TERMCTL_ENSECLOW|FLX_TERMCTL_ENSECHIGH);
+		if ((adapter_control & CFSELOWTERM) != 0)
+			termctl |= FLX_TERMCTL_ENSECLOW;
+		if ((adapter_control & CFSEHIGHTERM) != 0)
+			termctl |= FLX_TERMCTL_ENSECHIGH;
+	} else if (error != 0) {
+		printf("%s: Secondary Auto-Term Sensing failed! "
+		       "Using Defaults.\n", ahd_name(ahd));
+		termctl |= FLX_TERMCTL_ENSECLOW|FLX_TERMCTL_ENSECHIGH;
+	}
+
+	/*
+	 * Now set the termination based on what we found.
+	 */
+	sxfrctl1 = ahd_inb(ahd, SXFRCTL1) & ~STPWEN;
+	if ((termctl & FLX_TERMCTL_ENPRILOW) != 0) {
+		ahd->flags |= AHD_TERM_ENB_A;
+		sxfrctl1 |= STPWEN;
+	}
+	/* Must set the latch once in order to be effective. */
+	ahd_outb(ahd, SXFRCTL1, sxfrctl1|STPWEN);
+	ahd_outb(ahd, SXFRCTL1, sxfrctl1);
+
+	error = ahd_write_flexport(ahd, FLXADDR_TERMCTL, termctl);
+	if (error != 0) {
+		printf("%s: Unable to set termination settings!\n",
+		       ahd_name(ahd));
+	} else if (bootverbose) {
+		printf("%s: Primary High byte termination %sabled\n",
+		       ahd_name(ahd),
+		       (termctl & FLX_TERMCTL_ENPRIHIGH) ? "En" : "Dis");
+
+		printf("%s: Primary Low byte termination %sabled\n",
+		       ahd_name(ahd),
+		       (termctl & FLX_TERMCTL_ENPRILOW) ? "En" : "Dis");
+
+		printf("%s: Secondary High byte termination %sabled\n",
+		       ahd_name(ahd),
+		       (termctl & FLX_TERMCTL_ENSECHIGH) ? "En" : "Dis");
+
+		printf("%s: Secondary Low byte termination %sabled\n",
+		       ahd_name(ahd),
+		       (termctl & FLX_TERMCTL_ENSECLOW) ? "En" : "Dis");
+	}
+	return;
+}
+
+#define	DPE	0x80
+#define SSE	0x40
+#define	RMA	0x20
+#define	RTA	0x10
+#define STA	0x08
+#define DPR	0x01
+
+static const char *split_status_source[] =
+{
+	"DFF0",
+	"DFF1",
+	"OVLY",
+	"CMC",
+};
+
+static const char *pci_status_source[] =
+{
+	"DFF0",
+	"DFF1",
+	"SG",
+	"CMC",
+	"OVLY",
+	"NONE",
+	"MSI",
+	"TARG"
+};
+
+static const char *split_status_strings[] =
+{
+	"%s: Received split response in %s.\n",
+	"%s: Received split completion error message in %s\n",
+	"%s: Receive overrun in %s\n",
+	"%s: Count not complete in %s\n",
+	"%s: Split completion data bucket in %s\n",
+	"%s: Split completion address error in %s\n",
+	"%s: Split completion byte count error in %s\n",
+	"%s: Signaled Target-abort to early terminate a split in %s\n"
+};
+
+static const char *pci_status_strings[] =
+{
+	"%s: Data Parity Error has been reported via PERR# in %s\n",
+	"%s: Target initial wait state error in %s\n",
+	"%s: Split completion read data parity error in %s\n",
+	"%s: Split completion address attribute parity error in %s\n",
+	"%s: Received a Target Abort in %s\n",
+	"%s: Received a Master Abort in %s\n",
+	"%s: Signal System Error Detected in %s\n",
+	"%s: Address or Write Phase Parity Error Detected in %s.\n"
+};
+
+void
+ahd_pci_intr(struct ahd_softc *ahd)
+{
+	uint8_t		pci_status[8];
+	ahd_mode_state	saved_modes;
+	u_int		pci_status1;
+	u_int		intstat;
+	u_int		i;
+	u_int		reg;
+	
+	intstat = ahd_inb(ahd, INTSTAT);
+
+	if ((intstat & SPLTINT) != 0)
+		ahd_pci_split_intr(ahd, intstat);
+
+	if ((intstat & PCIINT) == 0)
+		return;
+
+	printf("%s: PCI error Interrupt\n", ahd_name(ahd));
+	saved_modes = ahd_save_modes(ahd);
+	ahd_dump_card_state(ahd);
+	ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
+	for (i = 0, reg = DF0PCISTAT; i < 8; i++, reg++) {
+
+		if (i == 5)
+			continue;
+		pci_status[i] = ahd_inb(ahd, reg);
+		/* Clear latched errors.  So our interrupt deasserts. */
+		ahd_outb(ahd, reg, pci_status[i]);
+	}
+
+	for (i = 0; i < 8; i++) {
+		u_int bit;
+	
+		if (i == 5)
+			continue;
+
+		for (bit = 0; bit < 8; bit++) {
+
+			if ((pci_status[i] & (0x1 << bit)) != 0) {
+				static const char *s;
+
+				s = pci_status_strings[bit];
+				if (i == 7/*TARG*/ && bit == 3)
+					s = "%s: Signaled Target Abort\n";
+				printf(s, ahd_name(ahd), pci_status_source[i]);
+			}
+		}	
+	}
+	pci_status1 = ahd_pci_read_config(ahd->dev_softc,
+					  PCIR_STATUS + 1, /*bytes*/1);
+	ahd_pci_write_config(ahd->dev_softc, PCIR_STATUS + 1,
+			     pci_status1, /*bytes*/1);
+	ahd_restore_modes(ahd, saved_modes);
+	ahd_outb(ahd, CLRINT, CLRPCIINT);
+	ahd_unpause(ahd);
+}
+
+static void
+ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat)
+{
+	uint8_t		split_status[4];
+	uint8_t		split_status1[4];
+	uint8_t		sg_split_status[2];
+	uint8_t		sg_split_status1[2];
+	ahd_mode_state	saved_modes;
+	u_int		i;
+	uint16_t	pcix_status;
+
+	/*
+	 * Check for splits in all modes.  Modes 0 and 1
+	 * additionally have SG engine splits to look at.
+	 */
+	pcix_status = ahd_pci_read_config(ahd->dev_softc, PCIXR_STATUS,
+					  /*bytes*/2);
+	printf("%s: PCI Split Interrupt - PCI-X status = 0x%x\n",
+	       ahd_name(ahd), pcix_status);
+	saved_modes = ahd_save_modes(ahd);
+	for (i = 0; i < 4; i++) {
+		ahd_set_modes(ahd, i, i);
+
+		split_status[i] = ahd_inb(ahd, DCHSPLTSTAT0);
+		split_status1[i] = ahd_inb(ahd, DCHSPLTSTAT1);
+		/* Clear latched errors.  So our interrupt deasserts. */
+		ahd_outb(ahd, DCHSPLTSTAT0, split_status[i]);
+		ahd_outb(ahd, DCHSPLTSTAT1, split_status1[i]);
+		if (i > 1)
+			continue;
+		sg_split_status[i] = ahd_inb(ahd, SGSPLTSTAT0);
+		sg_split_status1[i] = ahd_inb(ahd, SGSPLTSTAT1);
+		/* Clear latched errors.  So our interrupt deasserts. */
+		ahd_outb(ahd, SGSPLTSTAT0, sg_split_status[i]);
+		ahd_outb(ahd, SGSPLTSTAT1, sg_split_status1[i]);
+	}
+
+	for (i = 0; i < 4; i++) {
+		u_int bit;
+
+		for (bit = 0; bit < 8; bit++) {
+
+			if ((split_status[i] & (0x1 << bit)) != 0) {
+				static const char *s;
+
+				s = split_status_strings[bit];
+				printf(s, ahd_name(ahd),
+				       split_status_source[i]);
+			}
+
+			if (i > 1)
+				continue;
+
+			if ((sg_split_status[i] & (0x1 << bit)) != 0) {
+				static const char *s;
+
+				s = split_status_strings[bit];
+				printf(s, ahd_name(ahd), "SG");
+			}
+		}
+	}
+	/*
+	 * Clear PCI-X status bits.
+	 */
+	ahd_pci_write_config(ahd->dev_softc, PCIXR_STATUS,
+			     pcix_status, /*bytes*/2);
+	ahd_outb(ahd, CLRINT, CLRSPLTINT);
+	ahd_restore_modes(ahd, saved_modes);
+}
+
+static int
+ahd_aic7901_setup(struct ahd_softc *ahd)
+{
+	int error;
+
+	error = ahd_aic7902_setup(ahd);
+	if (error != 0)
+		return (error);
+	ahd->chip = AHD_AIC7901;
+	return (0);
+}
+
+static int
+ahd_aic7901A_setup(struct ahd_softc *ahd)
+{
+	int error;
+
+	error = ahd_aic7902_setup(ahd);
+	if (error != 0)
+		return (error);
+	ahd->chip = AHD_AIC7901A;
+	return (0);
+}
+
+static int
+ahd_aic7902_setup(struct ahd_softc *ahd)
+{
+	ahd_dev_softc_t pci;
+	u_int rev;
+
+	pci = ahd->dev_softc;
+	rev = ahd_pci_read_config(pci, PCIR_REVID, /*bytes*/1);
+	if (rev < ID_AIC7902_PCI_REV_A4) {
+		printf("%s: Unable to attach to unsupported chip revision %d\n",
+		       ahd_name(ahd), rev);
+		ahd_pci_write_config(pci, PCIR_COMMAND, 0, /*bytes*/2);
+		return (ENXIO);
+	}
+	ahd->channel = ahd_get_pci_function(pci) + 'A';
+	ahd->chip = AHD_AIC7902;
+	ahd->features = AHD_AIC7902_FE;
+	if (rev < ID_AIC7902_PCI_REV_B0) {
+		/*
+		 * Enable A series workarounds.
+		 */
+		ahd->bugs |= AHD_SENT_SCB_UPDATE_BUG|AHD_ABORT_LQI_BUG
+			  |  AHD_PKT_BITBUCKET_BUG|AHD_LONG_SETIMO_BUG
+			  |  AHD_NLQICRC_DELAYED_BUG|AHD_SCSIRST_BUG
+			  |  AHD_LQO_ATNO_BUG|AHD_AUTOFLUSH_BUG
+			  |  AHD_CLRLQO_AUTOCLR_BUG|AHD_PCIX_MMAPIO_BUG
+			  |  AHD_PCIX_CHIPRST_BUG|AHD_PCIX_SCBRAM_RD_BUG
+			  |  AHD_PKTIZED_STATUS_BUG|AHD_PKT_LUN_BUG
+			  |  AHD_MDFF_WSCBPTR_BUG|AHD_REG_SLOW_SETTLE_BUG
+			  |  AHD_SET_MODE_BUG|AHD_BUSFREEREV_BUG
+			  |  AHD_NONPACKFIFO_BUG|AHD_PACED_NEGTABLE_BUG
+			  |  AHD_FAINT_LED_BUG;
+
+		/*
+		 * IO Cell paramter setup.
+		 */
+		AHD_SET_PRECOMP(ahd, AHD_PRECOMP_CUTBACK_29);
+
+		if ((ahd->flags & AHD_HP_BOARD) == 0)
+			AHD_SET_SLEWRATE(ahd, AHD_SLEWRATE_DEF_REVA);
+	} else {
+		u_int devconfig1;
+
+		ahd->features |= AHD_RTI|AHD_NEW_IOCELL_OPTS
+			      |  AHD_NEW_DFCNTRL_OPTS;
+		ahd->bugs |= AHD_LQOOVERRUN_BUG|AHD_ABORT_LQI_BUG
+			  |  AHD_INTCOLLISION_BUG|AHD_EARLY_REQ_BUG;
+
+		/*
+		 * IO Cell paramter setup.
+		 */
+		AHD_SET_PRECOMP(ahd, AHD_PRECOMP_CUTBACK_29);
+		AHD_SET_SLEWRATE(ahd, AHD_SLEWRATE_DEF_REVB);
+		AHD_SET_AMPLITUDE(ahd, AHD_AMPLITUDE_DEF);
+
+		/*
+		 * Set the PREQDIS bit for H2B which disables some workaround
+		 * that doesn't work on regular PCI busses.
+		 * XXX - Find out exactly what this does from the hardware
+		 * 	 folks!
+		 */
+		devconfig1 = ahd_pci_read_config(pci, DEVCONFIG1, /*bytes*/1);
+		ahd_pci_write_config(pci, DEVCONFIG1,
+				     devconfig1|PREQDIS, /*bytes*/1);
+		devconfig1 = ahd_pci_read_config(pci, DEVCONFIG1, /*bytes*/1);
+	}
+
+	return (0);
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic79xx_proc.c linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx_proc.c
--- linux-2.4.21/drivers/scsi/aic7xxx/aic79xx_proc.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx_proc.c	2003-06-26 21:43:22.000000000 +0000
@@ -0,0 +1,362 @@
+/*
+ * 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.
+ *
+ * String handling code courtesy of Gerard Roudier's <groudier@club-internet.fr>
+ * sym driver.
+ *
+ * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_proc.c#19 $
+ */
+#include "aic79xx_osm.h"
+#include "aic79xx_inline.h"
+
+static void	copy_mem_info(struct info_str *info, char *data, int len);
+static int	copy_info(struct info_str *info, char *fmt, ...);
+static void	ahd_dump_target_state(struct ahd_softc *ahd,
+				      struct info_str *info,
+				      u_int our_id, char channel,
+				      u_int target_id, u_int target_offset);
+static void	ahd_dump_device_state(struct info_str *info,
+				      struct ahd_linux_device *dev);
+static int	ahd_proc_write_seeprom(struct ahd_softc *ahd,
+				       char *buffer, int length);
+
+static void
+copy_mem_info(struct info_str *info, char *data, int len)
+{
+	if (info->pos + len > info->offset + info->length)
+		len = info->offset + info->length - info->pos;
+
+	if (info->pos + len < info->offset) {
+		info->pos += len;
+		return;
+	}
+
+	if (info->pos < info->offset) {
+		off_t partial;
+
+		partial = info->offset - info->pos;
+		data += partial;
+		info->pos += partial;
+		len  -= partial;
+	}
+
+	if (len > 0) {
+		memcpy(info->buffer, data, len);
+		info->pos += len;
+		info->buffer += len;
+	}
+}
+
+static int
+copy_info(struct info_str *info, char *fmt, ...)
+{
+	va_list args;
+	char buf[256];
+	int len;
+
+	va_start(args, fmt);
+	len = vsprintf(buf, fmt, args);
+	va_end(args);
+
+	copy_mem_info(info, buf, len);
+	return (len);
+}
+
+void
+ahd_format_transinfo(struct info_str *info, struct ahd_transinfo *tinfo)
+{
+	u_int speed;
+	u_int freq;
+	u_int mb;
+
+	if (tinfo->period == AHD_PERIOD_UNKNOWN) {
+		copy_info(info, "Renegotiation Pending\n");
+		return;
+	}
+        speed = 3300;
+        freq = 0;
+	if (tinfo->offset != 0) {
+		freq = aic_calc_syncsrate(tinfo->period);
+		speed = freq;
+	}
+	speed *= (0x01 << tinfo->width);
+        mb = speed / 1000;
+        if (mb > 0)
+		copy_info(info, "%d.%03dMB/s transfers", mb, speed % 1000);
+        else
+		copy_info(info, "%dKB/s transfers", speed);
+
+	if (freq != 0) {
+		int	printed_options;
+
+		printed_options = 0;
+		copy_info(info, " (%d.%03dMHz", freq / 1000, freq % 1000);
+		if ((tinfo->ppr_options & MSG_EXT_PPR_RD_STRM) != 0) {
+			copy_info(info, " RDSTRM");
+			printed_options++;
+		}
+		if ((tinfo->ppr_options & MSG_EXT_PPR_DT_REQ) != 0) {
+			copy_info(info, "%s", printed_options ? "|DT" : " DT");
+			printed_options++;
+		}
+		if ((tinfo->ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
+			copy_info(info, "%s", printed_options ? "|IU" : " IU");
+			printed_options++;
+		}
+		if ((tinfo->ppr_options & MSG_EXT_PPR_RTI) != 0) {
+			copy_info(info, "%s",
+				  printed_options ? "|RTI" : " RTI");
+			printed_options++;
+		}
+		if ((tinfo->ppr_options & MSG_EXT_PPR_QAS_REQ) != 0) {
+			copy_info(info, "%s",
+				  printed_options ? "|QAS" : " QAS");
+			printed_options++;
+		}
+	}
+
+	if (tinfo->width > 0) {
+		if (freq != 0) {
+			copy_info(info, ", ");
+		} else {
+			copy_info(info, " (");
+		}
+		copy_info(info, "%dbit)", 8 * (0x01 << tinfo->width));
+	} else if (freq != 0) {
+		copy_info(info, ")");
+	}
+	copy_info(info, "\n");
+}
+
+static void
+ahd_dump_target_state(struct ahd_softc *ahd, struct info_str *info,
+		      u_int our_id, char channel, u_int target_id,
+		      u_int target_offset)
+{
+	struct	ahd_linux_target *targ;
+	struct	ahd_initiator_tinfo *tinfo;
+	struct	ahd_tmode_tstate *tstate;
+	int	lun;
+
+	tinfo = ahd_fetch_transinfo(ahd, channel, our_id,
+				    target_id, &tstate);
+	copy_info(info, "Target %d Negotiation Settings\n", target_id);
+	copy_info(info, "\tUser: ");
+	ahd_format_transinfo(info, &tinfo->user);
+	targ = ahd->platform_data->targets[target_offset];
+	if (targ == NULL)
+		return;
+
+	copy_info(info, "\tGoal: ");
+	ahd_format_transinfo(info, &tinfo->goal);
+	copy_info(info, "\tCurr: ");
+	ahd_format_transinfo(info, &tinfo->curr);
+	copy_info(info, "\tTransmission Errors %ld\n", targ->errors_detected);
+
+	for (lun = 0; lun < AHD_NUM_LUNS; lun++) {
+		struct ahd_linux_device *dev;
+
+		dev = targ->devices[lun];
+
+		if (dev == NULL)
+			continue;
+
+		ahd_dump_device_state(info, dev);
+	}
+}
+
+static void
+ahd_dump_device_state(struct info_str *info, struct ahd_linux_device *dev)
+{
+	copy_info(info, "\tChannel %c Target %d Lun %d Settings\n",
+		  dev->target->channel + 'A', dev->target->target, dev->lun);
+
+	copy_info(info, "\t\tCommands Queued %ld\n", dev->commands_issued);
+	copy_info(info, "\t\tCommands Active %d\n", dev->active);
+	copy_info(info, "\t\tCommand Openings %d\n", dev->openings);
+	copy_info(info, "\t\tMax Tagged Openings %d\n", dev->maxtags);
+	copy_info(info, "\t\tDevice Queue Frozen Count %d\n", dev->qfrozen);
+}
+
+static int
+ahd_proc_write_seeprom(struct ahd_softc *ahd, char *buffer, int length)
+{
+	ahd_mode_state saved_modes;
+	int have_seeprom;
+	u_long s;
+	int paused;
+	int written;
+
+	/* Default to failure. */
+	written = -EINVAL;
+	ahd_lock(ahd, &s);
+	paused = ahd_is_paused(ahd);
+	if (!paused)
+		ahd_pause(ahd);
+
+	saved_modes = ahd_save_modes(ahd);
+	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
+	if (length != sizeof(struct seeprom_config)) {
+		printf("ahd_proc_write_seeprom: incorrect buffer size\n");
+		goto done;
+	}
+
+	have_seeprom = ahd_verify_cksum((struct seeprom_config*)buffer);
+	if (have_seeprom == 0) {
+		printf("ahd_proc_write_seeprom: cksum verification failed\n");
+		goto done;
+	}
+
+	have_seeprom = ahd_acquire_seeprom(ahd);
+	if (!have_seeprom) {
+		printf("ahd_proc_write_seeprom: No Serial EEPROM\n");
+		goto done;
+	} else {
+		u_int start_addr;
+
+		if (ahd->seep_config == NULL) {
+			ahd->seep_config = malloc(sizeof(*ahd->seep_config),
+						  M_DEVBUF, M_NOWAIT);
+			if (ahd->seep_config == NULL) {
+				printf("aic79xx: Unable to allocate serial "
+				       "eeprom buffer.  Write failing\n");
+				goto done;
+			}
+		}
+		printf("aic79xx: Writing Serial EEPROM\n");
+		start_addr = 32 * (ahd->channel - 'A');
+		ahd_write_seeprom(ahd, (u_int16_t *)buffer, start_addr,
+				  sizeof(struct seeprom_config)/2);
+		ahd_read_seeprom(ahd, (uint16_t *)ahd->seep_config,
+				 start_addr, sizeof(struct seeprom_config)/2,
+				 /*ByteStream*/FALSE);
+		ahd_release_seeprom(ahd);
+		written = length;
+	}
+
+done:
+	ahd_restore_modes(ahd, saved_modes);
+	if (!paused)
+		ahd_unpause(ahd);
+	ahd_unlock(ahd, &s);
+	return (written);
+}
+/*
+ * Return information to handle /proc support for the driver.
+ */
+int
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ahd_linux_proc_info(char *buffer, char **start, off_t offset,
+		    int length, int hostno, int inout)
+#else
+ahd_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
+		    off_t offset, int length, int inout)
+#endif
+{
+	struct	ahd_softc *ahd;
+	struct	info_str info;
+	char	ahd_info[256];
+	u_long	l;
+	u_int	max_targ;
+	u_int	i;
+	int	retval;
+
+	retval = -EINVAL;
+	ahd_list_lock(&l);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+	TAILQ_FOREACH(ahd, &ahd_tailq, links) {
+		if (ahd->platform_data->host->host_no == hostno)
+			break;
+	}
+#else
+	ahd = ahd_find_softc(*(struct ahd_softc **)shost->hostdata);
+#endif
+
+	if (ahd == NULL)
+		goto done;
+
+	 /* Has data been written to the file? */ 
+	if (inout == TRUE) {
+		retval = ahd_proc_write_seeprom(ahd, buffer, length);
+		goto done;
+	}
+
+	if (start)
+		*start = buffer;
+
+	info.buffer	= buffer;
+	info.length	= length;
+	info.offset	= offset;
+	info.pos	= 0;
+
+	copy_info(&info, "Adaptec AIC79xx driver version: %s\n",
+		  AIC79XX_DRIVER_VERSION);
+	copy_info(&info, "%s\n", ahd->description);
+	ahd_controller_info(ahd, ahd_info);
+	copy_info(&info, "%s\n", ahd_info);
+	copy_info(&info, "Allocated SCBs: %d, SG List Length: %d\n\n",
+		  ahd->scb_data.numscbs, AHD_NSEG);
+
+	max_targ = 15;
+
+	if (ahd->seep_config == NULL)
+		copy_info(&info, "No Serial EEPROM\n");
+	else {
+		copy_info(&info, "Serial EEPROM:\n");
+		for (i = 0; i < sizeof(*ahd->seep_config)/2; i++) {
+			if (((i % 8) == 0) && (i != 0)) {
+				copy_info(&info, "\n");
+			}
+			copy_info(&info, "0x%.4x ",
+				  ((uint16_t*)ahd->seep_config)[i]);
+		}
+		copy_info(&info, "\n");
+	}
+	copy_info(&info, "\n");
+
+	if ((ahd->features & AHD_WIDE) == 0)
+		max_targ = 7;
+
+	for (i = 0; i <= max_targ; i++) {
+
+		ahd_dump_target_state(ahd, &info, ahd->our_id, 'A',
+				      /*target_id*/i, /*target_offset*/i);
+	}
+	retval = info.pos > info.offset ? info.pos - info.offset : 0;
+done:
+	ahd_list_unlock(&l);
+	return (retval);
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic79xx_reg.h linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx_reg.h
--- linux-2.4.21/drivers/scsi/aic7xxx/aic79xx_reg.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx_reg.h	2003-06-26 21:43:22.000000000 +0000
@@ -0,0 +1,3776 @@
+/*
+ * DO NOT EDIT - This file is automatically generated
+ *		 from the following source files:
+ *
+ * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#94 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#70 $
+ */
+typedef int (ahd_reg_print_t)(u_int, u_int *, u_int);
+typedef struct ahd_reg_parse_entry {
+	char	*name;
+	uint8_t	 value;
+	uint8_t	 mask;
+} ahd_reg_parse_entry_t;
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_mode_ptr_print;
+#else
+#define ahd_mode_ptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "MODE_PTR", 0x00, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_intstat_print;
+#else
+#define ahd_intstat_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "INTSTAT", 0x01, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_seqintcode_print;
+#else
+#define ahd_seqintcode_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SEQINTCODE", 0x02, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_clrint_print;
+#else
+#define ahd_clrint_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CLRINT", 0x03, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_error_print;
+#else
+#define ahd_error_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "ERROR", 0x04, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_clrerr_print;
+#else
+#define ahd_clrerr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CLRERR", 0x04, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_hcntrl_print;
+#else
+#define ahd_hcntrl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "HCNTRL", 0x05, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_hnscb_qoff_print;
+#else
+#define ahd_hnscb_qoff_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "HNSCB_QOFF", 0x06, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_hescb_qoff_print;
+#else
+#define ahd_hescb_qoff_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "HESCB_QOFF", 0x08, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_hs_mailbox_print;
+#else
+#define ahd_hs_mailbox_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "HS_MAILBOX", 0x0b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_clrseqintstat_print;
+#else
+#define ahd_clrseqintstat_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CLRSEQINTSTAT", 0x0c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_seqintstat_print;
+#else
+#define ahd_seqintstat_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SEQINTSTAT", 0x0c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_swtimer_print;
+#else
+#define ahd_swtimer_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SWTIMER", 0x0e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_snscb_qoff_print;
+#else
+#define ahd_snscb_qoff_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SNSCB_QOFF", 0x10, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sescb_qoff_print;
+#else
+#define ahd_sescb_qoff_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SESCB_QOFF", 0x12, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sdscb_qoff_print;
+#else
+#define ahd_sdscb_qoff_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SDSCB_QOFF", 0x14, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_qoff_ctlsta_print;
+#else
+#define ahd_qoff_ctlsta_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "QOFF_CTLSTA", 0x16, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_intctl_print;
+#else
+#define ahd_intctl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "INTCTL", 0x18, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dfcntrl_print;
+#else
+#define ahd_dfcntrl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DFCNTRL", 0x19, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dscommand0_print;
+#else
+#define ahd_dscommand0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DSCOMMAND0", 0x19, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dfstatus_print;
+#else
+#define ahd_dfstatus_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DFSTATUS", 0x1a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sg_cache_shadow_print;
+#else
+#define ahd_sg_cache_shadow_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SG_CACHE_SHADOW", 0x1b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_arbctl_print;
+#else
+#define ahd_arbctl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "ARBCTL", 0x1b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sg_cache_pre_print;
+#else
+#define ahd_sg_cache_pre_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SG_CACHE_PRE", 0x1b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lqin_print;
+#else
+#define ahd_lqin_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LQIN", 0x20, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_typeptr_print;
+#else
+#define ahd_typeptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "TYPEPTR", 0x20, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_tagptr_print;
+#else
+#define ahd_tagptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "TAGPTR", 0x21, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lunptr_print;
+#else
+#define ahd_lunptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LUNPTR", 0x22, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_datalenptr_print;
+#else
+#define ahd_datalenptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DATALENPTR", 0x23, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_statlenptr_print;
+#else
+#define ahd_statlenptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "STATLENPTR", 0x24, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_cmdlenptr_print;
+#else
+#define ahd_cmdlenptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CMDLENPTR", 0x25, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_attrptr_print;
+#else
+#define ahd_attrptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "ATTRPTR", 0x26, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_flagptr_print;
+#else
+#define ahd_flagptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "FLAGPTR", 0x27, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_cmdptr_print;
+#else
+#define ahd_cmdptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CMDPTR", 0x28, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_qnextptr_print;
+#else
+#define ahd_qnextptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "QNEXTPTR", 0x29, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_idptr_print;
+#else
+#define ahd_idptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "IDPTR", 0x2a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_abrtbyteptr_print;
+#else
+#define ahd_abrtbyteptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "ABRTBYTEPTR", 0x2b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_abrtbitptr_print;
+#else
+#define ahd_abrtbitptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "ABRTBITPTR", 0x2c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_maxcmdbytes_print;
+#else
+#define ahd_maxcmdbytes_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "MAXCMDBYTES", 0x2d, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_maxcmd2rcv_print;
+#else
+#define ahd_maxcmd2rcv_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "MAXCMD2RCV", 0x2e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_shortthresh_print;
+#else
+#define ahd_shortthresh_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SHORTTHRESH", 0x2f, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lunlen_print;
+#else
+#define ahd_lunlen_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LUNLEN", 0x30, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_cdblimit_print;
+#else
+#define ahd_cdblimit_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CDBLIMIT", 0x31, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_maxcmd_print;
+#else
+#define ahd_maxcmd_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "MAXCMD", 0x32, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_maxcmdcnt_print;
+#else
+#define ahd_maxcmdcnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "MAXCMDCNT", 0x33, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lqrsvd01_print;
+#else
+#define ahd_lqrsvd01_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LQRSVD01", 0x34, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lqrsvd16_print;
+#else
+#define ahd_lqrsvd16_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LQRSVD16", 0x35, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lqrsvd17_print;
+#else
+#define ahd_lqrsvd17_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LQRSVD17", 0x36, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_cmdrsvd0_print;
+#else
+#define ahd_cmdrsvd0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CMDRSVD0", 0x37, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lqctl0_print;
+#else
+#define ahd_lqctl0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LQCTL0", 0x38, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lqctl1_print;
+#else
+#define ahd_lqctl1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LQCTL1", 0x38, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scsbist0_print;
+#else
+#define ahd_scsbist0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCSBIST0", 0x39, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lqctl2_print;
+#else
+#define ahd_lqctl2_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LQCTL2", 0x39, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scsbist1_print;
+#else
+#define ahd_scsbist1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCSBIST1", 0x3a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scsiseq0_print;
+#else
+#define ahd_scsiseq0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCSISEQ0", 0x3a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scsiseq1_print;
+#else
+#define ahd_scsiseq1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCSISEQ1", 0x3b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sxfrctl0_print;
+#else
+#define ahd_sxfrctl0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SXFRCTL0", 0x3c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_businitid_print;
+#else
+#define ahd_businitid_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "BUSINITID", 0x3c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dlcount_print;
+#else
+#define ahd_dlcount_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DLCOUNT", 0x3c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sxfrctl1_print;
+#else
+#define ahd_sxfrctl1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SXFRCTL1", 0x3d, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_bustargid_print;
+#else
+#define ahd_bustargid_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "BUSTARGID", 0x3e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sxfrctl2_print;
+#else
+#define ahd_sxfrctl2_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SXFRCTL2", 0x3e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dffstat_print;
+#else
+#define ahd_dffstat_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DFFSTAT", 0x3f, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scsisigo_print;
+#else
+#define ahd_scsisigo_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCSISIGO", 0x40, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_multargid_print;
+#else
+#define ahd_multargid_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "MULTARGID", 0x40, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scsisigi_print;
+#else
+#define ahd_scsisigi_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCSISIGI", 0x41, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scsiphase_print;
+#else
+#define ahd_scsiphase_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCSIPHASE", 0x42, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scsidat0_img_print;
+#else
+#define ahd_scsidat0_img_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCSIDAT0_IMG", 0x43, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scsidat_print;
+#else
+#define ahd_scsidat_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCSIDAT", 0x44, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scsibus_print;
+#else
+#define ahd_scsibus_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCSIBUS", 0x46, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_targidin_print;
+#else
+#define ahd_targidin_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "TARGIDIN", 0x48, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_selid_print;
+#else
+#define ahd_selid_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SELID", 0x49, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sblkctl_print;
+#else
+#define ahd_sblkctl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SBLKCTL", 0x4a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_optionmode_print;
+#else
+#define ahd_optionmode_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "OPTIONMODE", 0x4a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sstat0_print;
+#else
+#define ahd_sstat0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SSTAT0", 0x4b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_clrsint0_print;
+#else
+#define ahd_clrsint0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CLRSINT0", 0x4b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_simode0_print;
+#else
+#define ahd_simode0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SIMODE0", 0x4b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_clrsint1_print;
+#else
+#define ahd_clrsint1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CLRSINT1", 0x4c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sstat1_print;
+#else
+#define ahd_sstat1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SSTAT1", 0x4c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sstat2_print;
+#else
+#define ahd_sstat2_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SSTAT2", 0x4d, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_clrsint2_print;
+#else
+#define ahd_clrsint2_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CLRSINT2", 0x4d, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_simode2_print;
+#else
+#define ahd_simode2_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SIMODE2", 0x4d, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_perrdiag_print;
+#else
+#define ahd_perrdiag_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "PERRDIAG", 0x4e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lqistate_print;
+#else
+#define ahd_lqistate_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LQISTATE", 0x4e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_soffcnt_print;
+#else
+#define ahd_soffcnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SOFFCNT", 0x4f, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lqostate_print;
+#else
+#define ahd_lqostate_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LQOSTATE", 0x4f, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lqistat0_print;
+#else
+#define ahd_lqistat0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LQISTAT0", 0x50, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_clrlqiint0_print;
+#else
+#define ahd_clrlqiint0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CLRLQIINT0", 0x50, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lqimode0_print;
+#else
+#define ahd_lqimode0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LQIMODE0", 0x50, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lqimode1_print;
+#else
+#define ahd_lqimode1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LQIMODE1", 0x51, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lqistat1_print;
+#else
+#define ahd_lqistat1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LQISTAT1", 0x51, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_clrlqiint1_print;
+#else
+#define ahd_clrlqiint1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CLRLQIINT1", 0x51, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lqistat2_print;
+#else
+#define ahd_lqistat2_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LQISTAT2", 0x52, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sstat3_print;
+#else
+#define ahd_sstat3_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SSTAT3", 0x53, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_simode3_print;
+#else
+#define ahd_simode3_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SIMODE3", 0x53, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_clrsint3_print;
+#else
+#define ahd_clrsint3_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CLRSINT3", 0x53, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lqomode0_print;
+#else
+#define ahd_lqomode0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LQOMODE0", 0x54, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lqostat0_print;
+#else
+#define ahd_lqostat0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LQOSTAT0", 0x54, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_clrlqoint0_print;
+#else
+#define ahd_clrlqoint0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CLRLQOINT0", 0x54, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lqostat1_print;
+#else
+#define ahd_lqostat1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LQOSTAT1", 0x55, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_clrlqoint1_print;
+#else
+#define ahd_clrlqoint1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CLRLQOINT1", 0x55, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lqomode1_print;
+#else
+#define ahd_lqomode1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LQOMODE1", 0x55, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lqostat2_print;
+#else
+#define ahd_lqostat2_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LQOSTAT2", 0x56, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_os_space_cnt_print;
+#else
+#define ahd_os_space_cnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "OS_SPACE_CNT", 0x56, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_simode1_print;
+#else
+#define ahd_simode1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SIMODE1", 0x57, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_gsfifo_print;
+#else
+#define ahd_gsfifo_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "GSFIFO", 0x58, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dffsxfrctl_print;
+#else
+#define ahd_dffsxfrctl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DFFSXFRCTL", 0x5a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lqoscsctl_print;
+#else
+#define ahd_lqoscsctl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LQOSCSCTL", 0x5a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_nextscb_print;
+#else
+#define ahd_nextscb_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "NEXTSCB", 0x5a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_clrseqintsrc_print;
+#else
+#define ahd_clrseqintsrc_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CLRSEQINTSRC", 0x5b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_seqintsrc_print;
+#else
+#define ahd_seqintsrc_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SEQINTSRC", 0x5b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_currscb_print;
+#else
+#define ahd_currscb_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CURRSCB", 0x5c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_seqimode_print;
+#else
+#define ahd_seqimode_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SEQIMODE", 0x5c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_mdffstat_print;
+#else
+#define ahd_mdffstat_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "MDFFSTAT", 0x5d, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_crccontrol_print;
+#else
+#define ahd_crccontrol_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CRCCONTROL", 0x5d, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dfftag_print;
+#else
+#define ahd_dfftag_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DFFTAG", 0x5e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lastscb_print;
+#else
+#define ahd_lastscb_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LASTSCB", 0x5e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scsitest_print;
+#else
+#define ahd_scsitest_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCSITEST", 0x5e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_iopdnctl_print;
+#else
+#define ahd_iopdnctl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "IOPDNCTL", 0x5f, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_shaddr_print;
+#else
+#define ahd_shaddr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SHADDR", 0x60, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_negoaddr_print;
+#else
+#define ahd_negoaddr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "NEGOADDR", 0x60, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dgrpcrci_print;
+#else
+#define ahd_dgrpcrci_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DGRPCRCI", 0x60, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_negperiod_print;
+#else
+#define ahd_negperiod_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "NEGPERIOD", 0x61, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_packcrci_print;
+#else
+#define ahd_packcrci_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "PACKCRCI", 0x62, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_negoffset_print;
+#else
+#define ahd_negoffset_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "NEGOFFSET", 0x62, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_negppropts_print;
+#else
+#define ahd_negppropts_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "NEGPPROPTS", 0x63, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_negconopts_print;
+#else
+#define ahd_negconopts_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "NEGCONOPTS", 0x64, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_annexcol_print;
+#else
+#define ahd_annexcol_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "ANNEXCOL", 0x65, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scschkn_print;
+#else
+#define ahd_scschkn_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCSCHKN", 0x66, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_annexdat_print;
+#else
+#define ahd_annexdat_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "ANNEXDAT", 0x66, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_iownid_print;
+#else
+#define ahd_iownid_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "IOWNID", 0x67, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_pll960ctl0_print;
+#else
+#define ahd_pll960ctl0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "PLL960CTL0", 0x68, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_shcnt_print;
+#else
+#define ahd_shcnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SHCNT", 0x68, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_townid_print;
+#else
+#define ahd_townid_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "TOWNID", 0x69, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_pll960ctl1_print;
+#else
+#define ahd_pll960ctl1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "PLL960CTL1", 0x69, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_pll960cnt0_print;
+#else
+#define ahd_pll960cnt0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "PLL960CNT0", 0x6a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_xsig_print;
+#else
+#define ahd_xsig_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "XSIG", 0x6a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_seloid_print;
+#else
+#define ahd_seloid_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SELOID", 0x6b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_pll400ctl0_print;
+#else
+#define ahd_pll400ctl0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "PLL400CTL0", 0x6c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_fairness_print;
+#else
+#define ahd_fairness_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "FAIRNESS", 0x6c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_pll400ctl1_print;
+#else
+#define ahd_pll400ctl1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "PLL400CTL1", 0x6d, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_pll400cnt0_print;
+#else
+#define ahd_pll400cnt0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "PLL400CNT0", 0x6e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_unfairness_print;
+#else
+#define ahd_unfairness_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "UNFAIRNESS", 0x6e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_haddr_print;
+#else
+#define ahd_haddr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "HADDR", 0x70, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_plldelay_print;
+#else
+#define ahd_plldelay_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "PLLDELAY", 0x70, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_hodmaadr_print;
+#else
+#define ahd_hodmaadr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "HODMAADR", 0x70, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_hodmacnt_print;
+#else
+#define ahd_hodmacnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "HODMACNT", 0x78, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_hcnt_print;
+#else
+#define ahd_hcnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "HCNT", 0x78, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_hodmaen_print;
+#else
+#define ahd_hodmaen_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "HODMAEN", 0x7a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sghaddr_print;
+#else
+#define ahd_sghaddr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SGHADDR", 0x7c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scbhaddr_print;
+#else
+#define ahd_scbhaddr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCBHADDR", 0x7c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sghcnt_print;
+#else
+#define ahd_sghcnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SGHCNT", 0x84, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scbhcnt_print;
+#else
+#define ahd_scbhcnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCBHCNT", 0x84, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dff_thrsh_print;
+#else
+#define ahd_dff_thrsh_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DFF_THRSH", 0x88, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_romaddr_print;
+#else
+#define ahd_romaddr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "ROMADDR", 0x8a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_romcntrl_print;
+#else
+#define ahd_romcntrl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "ROMCNTRL", 0x8d, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_romdata_print;
+#else
+#define ahd_romdata_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "ROMDATA", 0x8e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_cmcrxmsg0_print;
+#else
+#define ahd_cmcrxmsg0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CMCRXMSG0", 0x90, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_roenable_print;
+#else
+#define ahd_roenable_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "ROENABLE", 0x90, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_ovlyrxmsg0_print;
+#else
+#define ahd_ovlyrxmsg0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "OVLYRXMSG0", 0x90, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dchrxmsg0_print;
+#else
+#define ahd_dchrxmsg0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DCHRXMSG0", 0x90, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_ovlyrxmsg1_print;
+#else
+#define ahd_ovlyrxmsg1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "OVLYRXMSG1", 0x91, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_nsenable_print;
+#else
+#define ahd_nsenable_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "NSENABLE", 0x91, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dchrxmsg1_print;
+#else
+#define ahd_dchrxmsg1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DCHRXMSG1", 0x91, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_cmcrxmsg1_print;
+#else
+#define ahd_cmcrxmsg1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CMCRXMSG1", 0x91, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dchrxmsg2_print;
+#else
+#define ahd_dchrxmsg2_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DCHRXMSG2", 0x92, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_ovlyrxmsg2_print;
+#else
+#define ahd_ovlyrxmsg2_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "OVLYRXMSG2", 0x92, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_cmcrxmsg2_print;
+#else
+#define ahd_cmcrxmsg2_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CMCRXMSG2", 0x92, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_ost_print;
+#else
+#define ahd_ost_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "OST", 0x92, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dchrxmsg3_print;
+#else
+#define ahd_dchrxmsg3_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DCHRXMSG3", 0x93, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_cmcrxmsg3_print;
+#else
+#define ahd_cmcrxmsg3_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CMCRXMSG3", 0x93, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_pcixctl_print;
+#else
+#define ahd_pcixctl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "PCIXCTL", 0x93, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_ovlyrxmsg3_print;
+#else
+#define ahd_ovlyrxmsg3_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "OVLYRXMSG3", 0x93, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_ovlyseqbcnt_print;
+#else
+#define ahd_ovlyseqbcnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "OVLYSEQBCNT", 0x94, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_cmcseqbcnt_print;
+#else
+#define ahd_cmcseqbcnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CMCSEQBCNT", 0x94, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dchseqbcnt_print;
+#else
+#define ahd_dchseqbcnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DCHSEQBCNT", 0x94, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_cmcspltstat0_print;
+#else
+#define ahd_cmcspltstat0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CMCSPLTSTAT0", 0x96, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_ovlyspltstat0_print;
+#else
+#define ahd_ovlyspltstat0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "OVLYSPLTSTAT0", 0x96, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dchspltstat0_print;
+#else
+#define ahd_dchspltstat0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DCHSPLTSTAT0", 0x96, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dchspltstat1_print;
+#else
+#define ahd_dchspltstat1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DCHSPLTSTAT1", 0x97, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_cmcspltstat1_print;
+#else
+#define ahd_cmcspltstat1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CMCSPLTSTAT1", 0x97, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_ovlyspltstat1_print;
+#else
+#define ahd_ovlyspltstat1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "OVLYSPLTSTAT1", 0x97, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sgrxmsg0_print;
+#else
+#define ahd_sgrxmsg0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SGRXMSG0", 0x98, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_slvspltoutadr0_print;
+#else
+#define ahd_slvspltoutadr0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SLVSPLTOUTADR0", 0x98, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sgrxmsg1_print;
+#else
+#define ahd_sgrxmsg1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SGRXMSG1", 0x99, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_slvspltoutadr1_print;
+#else
+#define ahd_slvspltoutadr1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SLVSPLTOUTADR1", 0x99, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sgrxmsg2_print;
+#else
+#define ahd_sgrxmsg2_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SGRXMSG2", 0x9a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_slvspltoutadr2_print;
+#else
+#define ahd_slvspltoutadr2_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SLVSPLTOUTADR2", 0x9a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sgrxmsg3_print;
+#else
+#define ahd_sgrxmsg3_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SGRXMSG3", 0x9b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_slvspltoutadr3_print;
+#else
+#define ahd_slvspltoutadr3_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SLVSPLTOUTADR3", 0x9b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sgseqbcnt_print;
+#else
+#define ahd_sgseqbcnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SGSEQBCNT", 0x9c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_slvspltoutattr0_print;
+#else
+#define ahd_slvspltoutattr0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SLVSPLTOUTATTR0", 0x9c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_slvspltoutattr1_print;
+#else
+#define ahd_slvspltoutattr1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SLVSPLTOUTATTR1", 0x9d, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_slvspltoutattr2_print;
+#else
+#define ahd_slvspltoutattr2_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SLVSPLTOUTATTR2", 0x9e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sgspltstat0_print;
+#else
+#define ahd_sgspltstat0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SGSPLTSTAT0", 0x9e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sfunct_print;
+#else
+#define ahd_sfunct_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SFUNCT", 0x9f, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sgspltstat1_print;
+#else
+#define ahd_sgspltstat1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SGSPLTSTAT1", 0x9f, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_df0pcistat_print;
+#else
+#define ahd_df0pcistat_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DF0PCISTAT", 0xa0, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_reg0_print;
+#else
+#define ahd_reg0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "REG0", 0xa0, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_df1pcistat_print;
+#else
+#define ahd_df1pcistat_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DF1PCISTAT", 0xa1, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sgpcistat_print;
+#else
+#define ahd_sgpcistat_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SGPCISTAT", 0xa2, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_reg1_print;
+#else
+#define ahd_reg1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "REG1", 0xa2, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_cmcpcistat_print;
+#else
+#define ahd_cmcpcistat_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CMCPCISTAT", 0xa3, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_ovlypcistat_print;
+#else
+#define ahd_ovlypcistat_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "OVLYPCISTAT", 0xa4, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_reg_isr_print;
+#else
+#define ahd_reg_isr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "REG_ISR", 0xa4, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sg_state_print;
+#else
+#define ahd_sg_state_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SG_STATE", 0xa6, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_msipcistat_print;
+#else
+#define ahd_msipcistat_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "MSIPCISTAT", 0xa6, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_targpcistat_print;
+#else
+#define ahd_targpcistat_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "TARGPCISTAT", 0xa7, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_data_count_odd_print;
+#else
+#define ahd_data_count_odd_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DATA_COUNT_ODD", 0xa7, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scbptr_print;
+#else
+#define ahd_scbptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCBPTR", 0xa8, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_ccscbacnt_print;
+#else
+#define ahd_ccscbacnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CCSCBACNT", 0xab, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scbautoptr_print;
+#else
+#define ahd_scbautoptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCBAUTOPTR", 0xab, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_ccsgaddr_print;
+#else
+#define ahd_ccsgaddr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CCSGADDR", 0xac, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_ccscbaddr_print;
+#else
+#define ahd_ccscbaddr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CCSCBADDR", 0xac, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_ccscbadr_bk_print;
+#else
+#define ahd_ccscbadr_bk_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CCSCBADR_BK", 0xac, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_cmc_rambist_print;
+#else
+#define ahd_cmc_rambist_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CMC_RAMBIST", 0xad, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_ccsgctl_print;
+#else
+#define ahd_ccsgctl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CCSGCTL", 0xad, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_ccscbctl_print;
+#else
+#define ahd_ccscbctl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CCSCBCTL", 0xad, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_ccsgram_print;
+#else
+#define ahd_ccsgram_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CCSGRAM", 0xb0, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_flexadr_print;
+#else
+#define ahd_flexadr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "FLEXADR", 0xb0, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_ccscbram_print;
+#else
+#define ahd_ccscbram_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CCSCBRAM", 0xb0, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_flexcnt_print;
+#else
+#define ahd_flexcnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "FLEXCNT", 0xb3, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_flexdmastat_print;
+#else
+#define ahd_flexdmastat_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "FLEXDMASTAT", 0xb5, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_flexdata_print;
+#else
+#define ahd_flexdata_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "FLEXDATA", 0xb6, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_brddat_print;
+#else
+#define ahd_brddat_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "BRDDAT", 0xb8, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_brdctl_print;
+#else
+#define ahd_brdctl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "BRDCTL", 0xb9, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_seeadr_print;
+#else
+#define ahd_seeadr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SEEADR", 0xba, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_seedat_print;
+#else
+#define ahd_seedat_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SEEDAT", 0xbc, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_seectl_print;
+#else
+#define ahd_seectl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SEECTL", 0xbe, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_seestat_print;
+#else
+#define ahd_seestat_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SEESTAT", 0xbe, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scbcnt_print;
+#else
+#define ahd_scbcnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCBCNT", 0xbf, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dfwaddr_print;
+#else
+#define ahd_dfwaddr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DFWADDR", 0xc0, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dspfltrctl_print;
+#else
+#define ahd_dspfltrctl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DSPFLTRCTL", 0xc0, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dspdatactl_print;
+#else
+#define ahd_dspdatactl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DSPDATACTL", 0xc1, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dfraddr_print;
+#else
+#define ahd_dfraddr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DFRADDR", 0xc2, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dspreqctl_print;
+#else
+#define ahd_dspreqctl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DSPREQCTL", 0xc2, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dspackctl_print;
+#else
+#define ahd_dspackctl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DSPACKCTL", 0xc3, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dfdat_print;
+#else
+#define ahd_dfdat_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DFDAT", 0xc4, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dspselect_print;
+#else
+#define ahd_dspselect_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DSPSELECT", 0xc4, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_wrtbiasctl_print;
+#else
+#define ahd_wrtbiasctl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "WRTBIASCTL", 0xc5, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_rcvrbiosctl_print;
+#else
+#define ahd_rcvrbiosctl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "RCVRBIOSCTL", 0xc6, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_wrtbiascalc_print;
+#else
+#define ahd_wrtbiascalc_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "WRTBIASCALC", 0xc7, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dfptrs_print;
+#else
+#define ahd_dfptrs_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DFPTRS", 0xc8, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_rcvrbiascalc_print;
+#else
+#define ahd_rcvrbiascalc_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "RCVRBIASCALC", 0xc8, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dfbkptr_print;
+#else
+#define ahd_dfbkptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DFBKPTR", 0xc9, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_skewcalc_print;
+#else
+#define ahd_skewcalc_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SKEWCALC", 0xc9, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dfdbctl_print;
+#else
+#define ahd_dfdbctl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DFDBCTL", 0xcb, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dfscnt_print;
+#else
+#define ahd_dfscnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DFSCNT", 0xcc, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dfbcnt_print;
+#else
+#define ahd_dfbcnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DFBCNT", 0xce, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_ovlyaddr_print;
+#else
+#define ahd_ovlyaddr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "OVLYADDR", 0xd4, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_seqctl0_print;
+#else
+#define ahd_seqctl0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SEQCTL0", 0xd6, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_seqctl1_print;
+#else
+#define ahd_seqctl1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SEQCTL1", 0xd7, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_flags_print;
+#else
+#define ahd_flags_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "FLAGS", 0xd8, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_seqintctl_print;
+#else
+#define ahd_seqintctl_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SEQINTCTL", 0xd9, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_seqram_print;
+#else
+#define ahd_seqram_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SEQRAM", 0xda, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_prgmcnt_print;
+#else
+#define ahd_prgmcnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "PRGMCNT", 0xde, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_accum_print;
+#else
+#define ahd_accum_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "ACCUM", 0xe0, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sindex_print;
+#else
+#define ahd_sindex_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SINDEX", 0xe2, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dindex_print;
+#else
+#define ahd_dindex_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DINDEX", 0xe4, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_brkaddr1_print;
+#else
+#define ahd_brkaddr1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "BRKADDR1", 0xe6, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_brkaddr0_print;
+#else
+#define ahd_brkaddr0_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "BRKADDR0", 0xe6, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_allones_print;
+#else
+#define ahd_allones_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "ALLONES", 0xe8, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_allzeros_print;
+#else
+#define ahd_allzeros_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "ALLZEROS", 0xea, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_none_print;
+#else
+#define ahd_none_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "NONE", 0xea, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sindir_print;
+#else
+#define ahd_sindir_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SINDIR", 0xec, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dindir_print;
+#else
+#define ahd_dindir_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DINDIR", 0xed, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_function1_print;
+#else
+#define ahd_function1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "FUNCTION1", 0xf0, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_stack_print;
+#else
+#define ahd_stack_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "STACK", 0xf2, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_curaddr_print;
+#else
+#define ahd_curaddr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CURADDR", 0xf4, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_intvec1_addr_print;
+#else
+#define ahd_intvec1_addr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "INTVEC1_ADDR", 0xf4, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_intvec2_addr_print;
+#else
+#define ahd_intvec2_addr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "INTVEC2_ADDR", 0xf6, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lastaddr_print;
+#else
+#define ahd_lastaddr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LASTADDR", 0xf6, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_longjmp_addr_print;
+#else
+#define ahd_longjmp_addr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LONGJMP_ADDR", 0xf8, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_accum_save_print;
+#else
+#define ahd_accum_save_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "ACCUM_SAVE", 0xfa, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_waiting_scb_tails_print;
+#else
+#define ahd_waiting_scb_tails_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "WAITING_SCB_TAILS", 0x100, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_ahd_pci_config_base_print;
+#else
+#define ahd_ahd_pci_config_base_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "AHD_PCI_CONFIG_BASE", 0x100, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_sram_base_print;
+#else
+#define ahd_sram_base_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SRAM_BASE", 0x100, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_waiting_tid_head_print;
+#else
+#define ahd_waiting_tid_head_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "WAITING_TID_HEAD", 0x120, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_waiting_tid_tail_print;
+#else
+#define ahd_waiting_tid_tail_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "WAITING_TID_TAIL", 0x122, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_next_queued_scb_addr_print;
+#else
+#define ahd_next_queued_scb_addr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "NEXT_QUEUED_SCB_ADDR", 0x124, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_complete_scb_head_print;
+#else
+#define ahd_complete_scb_head_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "COMPLETE_SCB_HEAD", 0x128, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_complete_scb_dmainprog_head_print;
+#else
+#define ahd_complete_scb_dmainprog_head_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "COMPLETE_SCB_DMAINPROG_HEAD", 0x12a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_complete_dma_scb_head_print;
+#else
+#define ahd_complete_dma_scb_head_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "COMPLETE_DMA_SCB_HEAD", 0x12c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_qfreeze_count_print;
+#else
+#define ahd_qfreeze_count_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "QFREEZE_COUNT", 0x12e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_saved_mode_print;
+#else
+#define ahd_saved_mode_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SAVED_MODE", 0x130, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_msg_out_print;
+#else
+#define ahd_msg_out_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "MSG_OUT", 0x131, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_dmaparams_print;
+#else
+#define ahd_dmaparams_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "DMAPARAMS", 0x132, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_seq_flags_print;
+#else
+#define ahd_seq_flags_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SEQ_FLAGS", 0x133, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_saved_scsiid_print;
+#else
+#define ahd_saved_scsiid_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SAVED_SCSIID", 0x134, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_saved_lun_print;
+#else
+#define ahd_saved_lun_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SAVED_LUN", 0x135, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_lastphase_print;
+#else
+#define ahd_lastphase_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LASTPHASE", 0x136, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_qoutfifo_entry_valid_tag_print;
+#else
+#define ahd_qoutfifo_entry_valid_tag_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "QOUTFIFO_ENTRY_VALID_TAG", 0x137, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_shared_data_addr_print;
+#else
+#define ahd_shared_data_addr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SHARED_DATA_ADDR", 0x138, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_qoutfifo_next_addr_print;
+#else
+#define ahd_qoutfifo_next_addr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "QOUTFIFO_NEXT_ADDR", 0x13c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_kernel_tqinpos_print;
+#else
+#define ahd_kernel_tqinpos_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "KERNEL_TQINPOS", 0x140, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_tqinpos_print;
+#else
+#define ahd_tqinpos_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "TQINPOS", 0x141, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_arg_1_print;
+#else
+#define ahd_arg_1_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "ARG_1", 0x142, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_arg_2_print;
+#else
+#define ahd_arg_2_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "ARG_2", 0x143, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_last_msg_print;
+#else
+#define ahd_last_msg_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LAST_MSG", 0x144, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scsiseq_template_print;
+#else
+#define ahd_scsiseq_template_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCSISEQ_TEMPLATE", 0x145, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_initiator_tag_print;
+#else
+#define ahd_initiator_tag_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "INITIATOR_TAG", 0x146, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_seq_flags2_print;
+#else
+#define ahd_seq_flags2_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SEQ_FLAGS2", 0x147, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_allocfifo_scbptr_print;
+#else
+#define ahd_allocfifo_scbptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "ALLOCFIFO_SCBPTR", 0x148, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_int_coalescing_timer_print;
+#else
+#define ahd_int_coalescing_timer_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "INT_COALESCING_TIMER", 0x14a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_int_coalescing_maxcmds_print;
+#else
+#define ahd_int_coalescing_maxcmds_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "INT_COALESCING_MAXCMDS", 0x14c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_int_coalescing_mincmds_print;
+#else
+#define ahd_int_coalescing_mincmds_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "INT_COALESCING_MINCMDS", 0x14d, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_cmds_pending_print;
+#else
+#define ahd_cmds_pending_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CMDS_PENDING", 0x14e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_int_coalescing_cmdcount_print;
+#else
+#define ahd_int_coalescing_cmdcount_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "INT_COALESCING_CMDCOUNT", 0x150, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_local_hs_mailbox_print;
+#else
+#define ahd_local_hs_mailbox_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "LOCAL_HS_MAILBOX", 0x151, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_cmdsize_table_print;
+#else
+#define ahd_cmdsize_table_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "CMDSIZE_TABLE", 0x152, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_base_print;
+#else
+#define ahd_scb_base_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_BASE", 0x180, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_residual_datacnt_print;
+#else
+#define ahd_scb_residual_datacnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_RESIDUAL_DATACNT", 0x180, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_residual_sgptr_print;
+#else
+#define ahd_scb_residual_sgptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_RESIDUAL_SGPTR", 0x184, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_scsi_status_print;
+#else
+#define ahd_scb_scsi_status_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_SCSI_STATUS", 0x188, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_target_phases_print;
+#else
+#define ahd_scb_target_phases_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_TARGET_PHASES", 0x189, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_target_data_dir_print;
+#else
+#define ahd_scb_target_data_dir_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_TARGET_DATA_DIR", 0x18a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_target_itag_print;
+#else
+#define ahd_scb_target_itag_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_TARGET_ITAG", 0x18b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_sense_busaddr_print;
+#else
+#define ahd_scb_sense_busaddr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_SENSE_BUSADDR", 0x18c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_tag_print;
+#else
+#define ahd_scb_tag_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_TAG", 0x190, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_control_print;
+#else
+#define ahd_scb_control_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_CONTROL", 0x192, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_scsiid_print;
+#else
+#define ahd_scb_scsiid_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_SCSIID", 0x193, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_lun_print;
+#else
+#define ahd_scb_lun_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_LUN", 0x194, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_task_attribute_print;
+#else
+#define ahd_scb_task_attribute_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_TASK_ATTRIBUTE", 0x195, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_cdb_len_print;
+#else
+#define ahd_scb_cdb_len_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_CDB_LEN", 0x196, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_task_management_print;
+#else
+#define ahd_scb_task_management_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_TASK_MANAGEMENT", 0x197, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_dataptr_print;
+#else
+#define ahd_scb_dataptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_DATAPTR", 0x198, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_datacnt_print;
+#else
+#define ahd_scb_datacnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_DATACNT", 0x1a0, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_sgptr_print;
+#else
+#define ahd_scb_sgptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_SGPTR", 0x1a4, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_busaddr_print;
+#else
+#define ahd_scb_busaddr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_BUSADDR", 0x1a8, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_next_print;
+#else
+#define ahd_scb_next_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_NEXT", 0x1ac, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_next2_print;
+#else
+#define ahd_scb_next2_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_NEXT2", 0x1ae, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_spare_print;
+#else
+#define ahd_scb_spare_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_SPARE", 0x1b0, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_disconnected_lists_print;
+#else
+#define ahd_scb_disconnected_lists_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_DISCONNECTED_LISTS", 0x1b8, regvalue, cur_col, wrap)
+#endif
+
+
+#define	MODE_PTR        		0x00
+#define		DST_MODE        	0x70
+#define		SRC_MODE        	0x07
+
+#define	INTSTAT         		0x01
+#define		INT_PEND        	0xff
+#define		HWERRINT        	0x80
+#define		BRKADRINT       	0x40
+#define		SWTMINT         	0x20
+#define		PCIINT          	0x10
+#define		SCSIINT         	0x08
+#define		SEQINT          	0x04
+#define		CMDCMPLT        	0x02
+#define		SPLTINT         	0x01
+
+#define	SEQINTCODE      		0x02
+#define		BAD_SCB_STATUS  	0x1a
+#define		SAW_HWERR       	0x19
+#define		TRACEPOINT3     	0x18
+#define		TRACEPOINT2     	0x17
+#define		TRACEPOINT1     	0x16
+#define		TRACEPOINT0     	0x15
+#define		TASKMGMT_CMD_CMPLT_OKAY	0x14
+#define		TASKMGMT_FUNC_COMPLETE	0x13
+#define		ENTERING_NONPACK	0x12
+#define		CFG4OVERRUN     	0x11
+#define		STATUS_OVERRUN  	0x10
+#define		CFG4ISTAT_INTR  	0x0f
+#define		INVALID_SEQINT  	0x0e
+#define		ILLEGAL_PHASE   	0x0d
+#define		DUMP_CARD_STATE 	0x0c
+#define		MISSED_BUSFREE  	0x0b
+#define		MKMSG_FAILED    	0x0a
+#define		DATA_OVERRUN    	0x09
+#define		BAD_STATUS      	0x08
+#define		HOST_MSG_LOOP   	0x07
+#define		PDATA_REINIT    	0x06
+#define		IGN_WIDE_RES    	0x05
+#define		NO_MATCH        	0x04
+#define		PROTO_VIOLATION 	0x03
+#define		SEND_REJECT     	0x02
+#define		BAD_PHASE       	0x01
+#define		NO_SEQINT       	0x00
+
+#define	CLRINT          		0x03
+#define		CLRHWERRINT     	0x80
+#define		CLRBRKADRINT    	0x40
+#define		CLRSWTMINT      	0x20
+#define		CLRPCIINT       	0x10
+#define		CLRSCSIINT      	0x08
+#define		CLRSEQINT       	0x04
+#define		CLRCMDINT       	0x02
+#define		CLRSPLTINT      	0x01
+
+#define	ERROR           		0x04
+#define		CIOPARERR       	0x80
+#define		CIOACCESFAIL    	0x40
+#define		MPARERR         	0x20
+#define		DPARERR         	0x10
+#define		SQPARERR        	0x08
+#define		ILLOPCODE       	0x04
+#define		DSCTMOUT        	0x02
+
+#define	CLRERR          		0x04
+#define		CLRCIOPARERR    	0x80
+#define		CLRCIOACCESFAIL 	0x40
+#define		CLRMPARERR      	0x20
+#define		CLRDPARERR      	0x10
+#define		CLRSQPARERR     	0x08
+#define		CLRILLOPCODE    	0x04
+#define		CLRDSCTMOUT     	0x02
+
+#define	HCNTRL          		0x05
+#define		SEQ_RESET       	0x80
+#define		POWRDN          	0x40
+#define		SWINT           	0x10
+#define		SWTIMER_START_B 	0x08
+#define		PAUSE           	0x04
+#define		INTEN           	0x02
+#define		CHIPRST         	0x01
+#define		CHIPRSTACK      	0x01
+
+#define	HNSCB_QOFF      		0x06
+
+#define	HESCB_QOFF      		0x08
+
+#define	HS_MAILBOX      		0x0b
+#define		HOST_TQINPOS    	0x80
+#define		ENINT_COALESCE  	0x40
+
+#define	CLRSEQINTSTAT   		0x0c
+#define		CLRSEQ_SWTMRTO  	0x10
+#define		CLRSEQ_SEQINT   	0x08
+#define		CLRSEQ_SCSIINT  	0x04
+#define		CLRSEQ_PCIINT   	0x02
+#define		CLRSEQ_SPLTINT  	0x01
+
+#define	SEQINTSTAT      		0x0c
+#define		SEQ_SWTMRTO     	0x10
+#define		SEQ_SEQINT      	0x08
+#define		SEQ_SCSIINT     	0x04
+#define		SEQ_PCIINT      	0x02
+#define		SEQ_SPLTINT     	0x01
+
+#define	SWTIMER         		0x0e
+
+#define	SNSCB_QOFF      		0x10
+
+#define	SESCB_QOFF      		0x12
+
+#define	SDSCB_QOFF      		0x14
+
+#define	QOFF_CTLSTA     		0x16
+#define		EMPTY_SCB_AVAIL 	0x80
+#define		NEW_SCB_AVAIL   	0x40
+#define		SDSCB_ROLLOVR   	0x20
+#define		HS_MAILBOX_ACT  	0x10
+#define		SCB_QSIZE       	0x0f
+#define		SCB_QSIZE_16384 	0x0c
+#define		SCB_QSIZE_8192  	0x0b
+#define		SCB_QSIZE_4096  	0x0a
+#define		SCB_QSIZE_2048  	0x09
+#define		SCB_QSIZE_1024  	0x08
+#define		SCB_QSIZE_512   	0x07
+#define		SCB_QSIZE_256   	0x06
+#define		SCB_QSIZE_128   	0x05
+#define		SCB_QSIZE_64    	0x04
+#define		SCB_QSIZE_32    	0x03
+#define		SCB_QSIZE_16    	0x02
+#define		SCB_QSIZE_8     	0x01
+#define		SCB_QSIZE_4     	0x00
+
+#define	INTCTL          		0x18
+#define		SWTMINTMASK     	0x80
+#define		SWTMINTEN       	0x40
+#define		SWTIMER_START   	0x20
+#define		AUTOCLRCMDINT   	0x10
+#define		PCIINTEN        	0x08
+#define		SCSIINTEN       	0x04
+#define		SEQINTEN        	0x02
+#define		SPLTINTEN       	0x01
+
+#define	DFCNTRL         		0x19
+#define		SCSIENWRDIS     	0x40
+#define		SCSIENACK       	0x20
+#define		DIRECTIONACK    	0x04
+#define		FIFOFLUSHACK    	0x02
+#define		DIRECTIONEN     	0x01
+
+#define	DSCOMMAND0      		0x19
+#define		CACHETHEN       	0x80
+#define		DPARCKEN        	0x40
+#define		MPARCKEN        	0x20
+#define		EXTREQLCK       	0x10
+#define		DISABLE_TWATE   	0x02
+#define		CIOPARCKEN      	0x01
+
+#define	DFSTATUS        		0x1a
+#define		PRELOAD_AVAIL   	0x80
+#define		PKT_PRELOAD_AVAIL	0x40
+#define		MREQPEND        	0x10
+#define		HDONE           	0x08
+#define		DFTHRESH        	0x04
+#define		FIFOFULL        	0x02
+#define		FIFOEMP         	0x01
+
+#define	SG_CACHE_SHADOW 		0x1b
+#define		ODD_SEG         	0x04
+#define		LAST_SEG        	0x02
+#define		LAST_SEG_DONE   	0x01
+
+#define	ARBCTL          		0x1b
+#define		RESET_HARB      	0x80
+#define		RETRY_SWEN      	0x08
+#define		USE_TIME        	0x07
+
+#define	SG_CACHE_PRE    		0x1b
+
+#define	LQIN            		0x20
+
+#define	TYPEPTR         		0x20
+
+#define	TAGPTR          		0x21
+
+#define	LUNPTR          		0x22
+
+#define	DATALENPTR      		0x23
+
+#define	STATLENPTR      		0x24
+
+#define	CMDLENPTR       		0x25
+
+#define	ATTRPTR         		0x26
+
+#define	FLAGPTR         		0x27
+
+#define	CMDPTR          		0x28
+
+#define	QNEXTPTR        		0x29
+
+#define	IDPTR           		0x2a
+
+#define	ABRTBYTEPTR     		0x2b
+
+#define	ABRTBITPTR      		0x2c
+
+#define	MAXCMDBYTES     		0x2d
+
+#define	MAXCMD2RCV      		0x2e
+
+#define	SHORTTHRESH     		0x2f
+
+#define	LUNLEN          		0x30
+#define		TLUNLEN         	0xf0
+#define		ILUNLEN         	0x0f
+
+#define	CDBLIMIT        		0x31
+
+#define	MAXCMD          		0x32
+
+#define	MAXCMDCNT       		0x33
+
+#define	LQRSVD01        		0x34
+
+#define	LQRSVD16        		0x35
+
+#define	LQRSVD17        		0x36
+
+#define	CMDRSVD0        		0x37
+
+#define	LQCTL0          		0x38
+#define		LQITARGCLT      	0xc0
+#define		LQIINITGCLT     	0x30
+#define		LQ0TARGCLT      	0x0c
+#define		LQ0INITGCLT     	0x03
+
+#define	LQCTL1          		0x38
+#define		PCI2PCI         	0x04
+#define		SINGLECMD       	0x02
+#define		ABORTPENDING    	0x01
+
+#define	SCSBIST0        		0x39
+#define		GSBISTERR       	0x40
+#define		GSBISTDONE      	0x20
+#define		GSBISTRUN       	0x10
+#define		OSBISTERR       	0x04
+#define		OSBISTDONE      	0x02
+#define		OSBISTRUN       	0x01
+
+#define	LQCTL2          		0x39
+#define		LQIRETRY        	0x80
+#define		LQICONTINUE     	0x40
+#define		LQITOIDLE       	0x20
+#define		LQIPAUSE        	0x10
+#define		LQORETRY        	0x08
+#define		LQOCONTINUE     	0x04
+#define		LQOTOIDLE       	0x02
+#define		LQOPAUSE        	0x01
+
+#define	SCSBIST1        		0x3a
+#define		NTBISTERR       	0x04
+#define		NTBISTDONE      	0x02
+#define		NTBISTRUN       	0x01
+
+#define	SCSISEQ0        		0x3a
+#define		TEMODEO         	0x80
+#define		ENSELO          	0x40
+#define		ENARBO          	0x20
+#define		FORCEBUSFREE    	0x10
+#define		SCSIRSTO        	0x01
+
+#define	SCSISEQ1        		0x3b
+
+#define	SXFRCTL0        		0x3c
+#define		DFON            	0x80
+#define		DFPEXP          	0x40
+#define		BIOSCANCELEN    	0x10
+#define		SPIOEN          	0x08
+
+#define	BUSINITID       		0x3c
+
+#define	DLCOUNT         		0x3c
+
+#define	SXFRCTL1        		0x3d
+#define		BITBUCKET       	0x80
+#define		ENSACHK         	0x40
+#define		ENSPCHK         	0x20
+#define		STIMESEL        	0x18
+#define		ENSTIMER        	0x04
+#define		ACTNEGEN        	0x02
+#define		STPWEN          	0x01
+
+#define	BUSTARGID       		0x3e
+
+#define	SXFRCTL2        		0x3e
+#define		AUTORSTDIS      	0x10
+#define		CMDDMAEN        	0x08
+#define		ASU             	0x07
+
+#define	DFFSTAT         		0x3f
+#define		CURRFIFO        	0x03
+#define		FIFO1FREE       	0x20
+#define		FIFO0FREE       	0x10
+#define		CURRFIFO_NONE   	0x03
+#define		CURRFIFO_1      	0x01
+#define		CURRFIFO_0      	0x00
+
+#define	SCSISIGO        		0x40
+#define		CDO             	0x80
+#define		IOO             	0x40
+#define		MSGO            	0x20
+#define		ATNO            	0x10
+#define		SELO            	0x08
+#define		BSYO            	0x04
+#define		REQO            	0x02
+#define		ACKO            	0x01
+
+#define	MULTARGID       		0x40
+
+#define	SCSISIGI        		0x41
+#define		ATNI            	0x10
+#define		SELI            	0x08
+#define		BSYI            	0x04
+#define		REQI            	0x02
+#define		ACKI            	0x01
+
+#define	SCSIPHASE       		0x42
+#define		STATUS_PHASE    	0x20
+#define		COMMAND_PHASE   	0x10
+#define		MSG_IN_PHASE    	0x08
+#define		MSG_OUT_PHASE   	0x04
+#define		DATA_PHASE_MASK 	0x03
+#define		DATA_IN_PHASE   	0x02
+#define		DATA_OUT_PHASE  	0x01
+
+#define	SCSIDAT0_IMG    		0x43
+
+#define	SCSIDAT         		0x44
+
+#define	SCSIBUS         		0x46
+
+#define	TARGIDIN        		0x48
+#define		CLKOUT          	0x80
+#define		TARGID          	0x0f
+
+#define	SELID           		0x49
+#define		SELID_MASK      	0xf0
+#define		ONEBIT          	0x08
+
+#define	SBLKCTL         		0x4a
+#define		DIAGLEDEN       	0x80
+#define		DIAGLEDON       	0x40
+#define		ENAB40          	0x08
+#define		ENAB20          	0x04
+#define		SELWIDE         	0x02
+
+#define	OPTIONMODE      		0x4a
+#define		OPTIONMODE_DEFAULTS	0x02
+#define		BIOSCANCTL      	0x80
+#define		AUTOACKEN       	0x40
+#define		BIASCANCTL      	0x20
+#define		BUSFREEREV      	0x10
+#define		ENDGFORMCHK     	0x04
+#define		AUTO_MSGOUT_DE  	0x02
+
+#define	SSTAT0          		0x4b
+#define		TARGET          	0x80
+#define		SELDO           	0x40
+#define		SELDI           	0x20
+#define		SELINGO         	0x10
+#define		IOERR           	0x08
+#define		OVERRUN         	0x04
+#define		SPIORDY         	0x02
+#define		ARBDO           	0x01
+
+#define	CLRSINT0        		0x4b
+#define		CLRSELDO        	0x40
+#define		CLRSELDI        	0x20
+#define		CLRSELINGO      	0x10
+#define		CLRIOERR        	0x08
+#define		CLROVERRUN      	0x04
+#define		CLRSPIORDY      	0x02
+#define		CLRARBDO        	0x01
+
+#define	SIMODE0         		0x4b
+#define		ENSELDO         	0x40
+#define		ENSELDI         	0x20
+#define		ENSELINGO       	0x10
+#define		ENIOERR         	0x08
+#define		ENOVERRUN       	0x04
+#define		ENSPIORDY       	0x02
+#define		ENARBDO         	0x01
+
+#define	CLRSINT1        		0x4c
+#define		CLRSELTIMEO     	0x80
+#define		CLRATNO         	0x40
+#define		CLRSCSIRSTI     	0x20
+#define		CLRBUSFREE      	0x08
+#define		CLRSCSIPERR     	0x04
+#define		CLRSTRB2FAST    	0x02
+#define		CLRREQINIT      	0x01
+
+#define	SSTAT1          		0x4c
+#define		SELTO           	0x80
+#define		ATNTARG         	0x40
+#define		SCSIRSTI        	0x20
+#define		PHASEMIS        	0x10
+#define		BUSFREE         	0x08
+#define		SCSIPERR        	0x04
+#define		STRB2FAST       	0x02
+#define		REQINIT         	0x01
+
+#define	SSTAT2          		0x4d
+#define		BUSFREETIME     	0xc0
+#define		NONPACKREQ      	0x20
+#define		EXP_ACTIVE      	0x10
+#define		BSYX            	0x08
+#define		WIDE_RES        	0x04
+#define		SDONE           	0x02
+#define		DMADONE         	0x01
+#define		BUSFREE_DFF1    	0xc0
+#define		BUSFREE_DFF0    	0x80
+#define		BUSFREE_LQO     	0x40
+
+#define	CLRSINT2        		0x4d
+#define		CLRNONPACKREQ   	0x20
+#define		CLRWIDE_RES     	0x04
+#define		CLRSDONE        	0x02
+#define		CLRDMADONE      	0x01
+
+#define	SIMODE2         		0x4d
+#define		ENWIDE_RES      	0x04
+#define		ENSDONE         	0x02
+#define		ENDMADONE       	0x01
+
+#define	PERRDIAG        		0x4e
+#define		HIZERO          	0x80
+#define		HIPERR          	0x40
+#define		PREVPHASE       	0x20
+#define		PARITYERR       	0x10
+#define		AIPERR          	0x08
+#define		CRCERR          	0x04
+#define		DGFORMERR       	0x02
+#define		DTERR           	0x01
+
+#define	LQISTATE        		0x4e
+
+#define	SOFFCNT         		0x4f
+
+#define	LQOSTATE        		0x4f
+
+#define	LQISTAT0        		0x50
+#define		LQIATNQAS       	0x20
+#define		LQICRCT1        	0x10
+#define		LQICRCT2        	0x08
+#define		LQIBADLQT       	0x04
+#define		LQIATNLQ        	0x02
+#define		LQIATNCMD       	0x01
+
+#define	CLRLQIINT0      		0x50
+#define		CLRLQIATNQAS    	0x20
+#define		CLRLQICRCT1     	0x10
+#define		CLRLQICRCT2     	0x08
+#define		CLRLQIBADLQT    	0x04
+#define		CLRLQIATNLQ     	0x02
+#define		CLRLQIATNCMD    	0x01
+
+#define	LQIMODE0        		0x50
+#define		ENLQIATNQASK    	0x20
+#define		ENLQICRCT1      	0x10
+#define		ENLQICRCT2      	0x08
+#define		ENLQIBADLQT     	0x04
+#define		ENLQIATNLQ      	0x02
+#define		ENLQIATNCMD     	0x01
+
+#define	LQIMODE1        		0x51
+#define		ENLQIPHASE_LQ   	0x80
+#define		ENLQIPHASE_NLQ  	0x40
+#define		ENLIQABORT      	0x20
+#define		ENLQICRCI_LQ    	0x10
+#define		ENLQICRCI_NLQ   	0x08
+#define		ENLQIBADLQI     	0x04
+#define		ENLQIOVERI_LQ   	0x02
+#define		ENLQIOVERI_NLQ  	0x01
+
+#define	LQISTAT1        		0x51
+#define		LQIPHASE_LQ     	0x80
+#define		LQIPHASE_NLQ    	0x40
+#define		LQIABORT        	0x20
+#define		LQICRCI_LQ      	0x10
+#define		LQICRCI_NLQ     	0x08
+#define		LQIBADLQI       	0x04
+#define		LQIOVERI_LQ     	0x02
+#define		LQIOVERI_NLQ    	0x01
+
+#define	CLRLQIINT1      		0x51
+#define		CLRLQIPHASE_LQ  	0x80
+#define		CLRLQIPHASE_NLQ 	0x40
+#define		CLRLIQABORT     	0x20
+#define		CLRLQICRCI_LQ   	0x10
+#define		CLRLQICRCI_NLQ  	0x08
+#define		CLRLQIBADLQI    	0x04
+#define		CLRLQIOVERI_LQ  	0x02
+#define		CLRLQIOVERI_NLQ 	0x01
+
+#define	LQISTAT2        		0x52
+#define		PACKETIZED      	0x80
+#define		LQIPHASE_OUTPKT 	0x40
+#define		LQIWORKONLQ     	0x20
+#define		LQIWAITFIFO     	0x10
+#define		LQISTOPPKT      	0x08
+#define		LQISTOPLQ       	0x04
+#define		LQISTOPCMD      	0x02
+#define		LQIGSAVAIL      	0x01
+
+#define	SSTAT3          		0x53
+#define		NTRAMPERR       	0x02
+#define		OSRAMPERR       	0x01
+
+#define	SIMODE3         		0x53
+#define		ENNTRAMPERR     	0x02
+#define		ENOSRAMPERR     	0x01
+
+#define	CLRSINT3        		0x53
+#define		CLRNTRAMPERR    	0x02
+#define		CLROSRAMPERR    	0x01
+
+#define	LQOMODE0        		0x54
+#define		ENLQOTARGSCBPERR	0x10
+#define		ENLQOSTOPT2     	0x08
+#define		ENLQOATNLQ      	0x04
+#define		ENLQOATNPKT     	0x02
+#define		ENLQOTCRC       	0x01
+
+#define	LQOSTAT0        		0x54
+#define		LQOTARGSCBPERR  	0x10
+#define		LQOSTOPT2       	0x08
+#define		LQOATNLQ        	0x04
+#define		LQOATNPKT       	0x02
+#define		LQOTCRC         	0x01
+
+#define	CLRLQOINT0      		0x54
+#define		CLRLQOTARGSCBPERR	0x10
+#define		CLRLQOSTOPT2    	0x08
+#define		CLRLQOATNLQ     	0x04
+#define		CLRLQOATNPKT    	0x02
+#define		CLRLQOTCRC      	0x01
+
+#define	LQOSTAT1        		0x55
+#define		LQOINITSCBPERR  	0x10
+#define		LQOSTOPI2       	0x08
+#define		LQOBADQAS       	0x04
+#define		LQOBUSFREE      	0x02
+#define		LQOPHACHGINPKT  	0x01
+
+#define	CLRLQOINT1      		0x55
+#define		CLRLQOINITSCBPERR	0x10
+#define		CLRLQOSTOPI2    	0x08
+#define		CLRLQOBADQAS    	0x04
+#define		CLRLQOBUSFREE   	0x02
+#define		CLRLQOPHACHGINPKT	0x01
+
+#define	LQOMODE1        		0x55
+#define		ENLQOINITSCBPERR	0x10
+#define		ENLQOSTOPI2     	0x08
+#define		ENLQOBADQAS     	0x04
+#define		ENLQOBUSFREE    	0x02
+#define		ENLQOPHACHGINPKT	0x01
+
+#define	LQOSTAT2        		0x56
+#define		LQOPKT          	0xe0
+#define		LQOWAITFIFO     	0x10
+#define		LQOPHACHGOUTPKT 	0x02
+#define		LQOSTOP0        	0x01
+
+#define	OS_SPACE_CNT    		0x56
+
+#define	SIMODE1         		0x57
+#define		ENSELTIMO       	0x80
+#define		ENATNTARG       	0x40
+#define		ENSCSIRST       	0x20
+#define		ENPHASEMIS      	0x10
+#define		ENBUSFREE       	0x08
+#define		ENSCSIPERR      	0x04
+#define		ENSTRB2FAST     	0x02
+#define		ENREQINIT       	0x01
+
+#define	GSFIFO          		0x58
+
+#define	DFFSXFRCTL      		0x5a
+#define		DFFBITBUCKET    	0x08
+#define		CLRSHCNT        	0x04
+#define		CLRCHN          	0x02
+#define		RSTCHN          	0x01
+
+#define	LQOSCSCTL       		0x5a
+#define		LQOH2A_VERSION  	0x80
+#define		LQONOCHKOVER    	0x01
+
+#define	NEXTSCB         		0x5a
+
+#define	CLRSEQINTSRC    		0x5b
+#define		CLRCTXTDONE     	0x40
+#define		CLRSAVEPTRS     	0x20
+#define		CLRCFG4DATA     	0x10
+#define		CLRCFG4ISTAT    	0x08
+#define		CLRCFG4TSTAT    	0x04
+#define		CLRCFG4ICMD     	0x02
+#define		CLRCFG4TCMD     	0x01
+
+#define	SEQINTSRC       		0x5b
+#define		CTXTDONE        	0x40
+#define		SAVEPTRS        	0x20
+#define		CFG4DATA        	0x10
+#define		CFG4ISTAT       	0x08
+#define		CFG4TSTAT       	0x04
+#define		CFG4ICMD        	0x02
+#define		CFG4TCMD        	0x01
+
+#define	CURRSCB         		0x5c
+
+#define	SEQIMODE        		0x5c
+#define		ENCTXTDONE      	0x40
+#define		ENSAVEPTRS      	0x20
+#define		ENCFG4DATA      	0x10
+#define		ENCFG4ISTAT     	0x08
+#define		ENCFG4TSTAT     	0x04
+#define		ENCFG4ICMD      	0x02
+#define		ENCFG4TCMD      	0x01
+
+#define	MDFFSTAT        		0x5d
+#define		SHCNTNEGATIVE   	0x40
+#define		SHCNTMINUS1     	0x20
+#define		LASTSDONE       	0x10
+#define		SHVALID         	0x08
+#define		DLZERO          	0x04
+#define		DATAINFIFO      	0x02
+#define		FIFOFREE        	0x01
+
+#define	CRCCONTROL      		0x5d
+#define		CRCVALCHKEN     	0x40
+
+#define	DFFTAG          		0x5e
+
+#define	LASTSCB         		0x5e
+
+#define	SCSITEST        		0x5e
+#define		CNTRTEST        	0x08
+#define		SEL_TXPLL_DEBUG 	0x04
+
+#define	IOPDNCTL        		0x5f
+#define		DISABLE_OE      	0x80
+#define		PDN_IDIST       	0x04
+#define		PDN_DIFFSENSE   	0x01
+
+#define	SHADDR          		0x60
+
+#define	NEGOADDR        		0x60
+
+#define	DGRPCRCI        		0x60
+
+#define	NEGPERIOD       		0x61
+
+#define	PACKCRCI        		0x62
+
+#define	NEGOFFSET       		0x62
+
+#define	NEGPPROPTS      		0x63
+#define		PPROPT_PACE     	0x08
+#define		PPROPT_QAS      	0x04
+#define		PPROPT_DT       	0x02
+#define		PPROPT_IUT      	0x01
+
+#define	NEGCONOPTS      		0x64
+#define		ENSNAPSHOT      	0x40
+#define		RTI_WRTDIS      	0x20
+#define		RTI_OVRDTRN     	0x10
+#define		ENSLOWCRC       	0x08
+#define		ENAUTOATNI      	0x04
+#define		ENAUTOATNO      	0x02
+#define		WIDEXFER        	0x01
+
+#define	ANNEXCOL        		0x65
+
+#define	SCSCHKN         		0x66
+#define		STSELSKIDDIS    	0x40
+#define		CURRFIFODEF     	0x20
+#define		WIDERESEN       	0x10
+#define		SDONEMSKDIS     	0x08
+#define		DFFACTCLR       	0x04
+#define		SHVALIDSTDIS    	0x02
+#define		LSTSGCLRDIS     	0x01
+
+#define	ANNEXDAT        		0x66
+
+#define	IOWNID          		0x67
+
+#define	PLL960CTL0      		0x68
+
+#define	SHCNT           		0x68
+
+#define	TOWNID          		0x69
+
+#define	PLL960CTL1      		0x69
+
+#define	PLL960CNT0      		0x6a
+
+#define	XSIG            		0x6a
+
+#define	SELOID          		0x6b
+
+#define	PLL400CTL0      		0x6c
+#define		PLL_VCOSEL      	0x80
+#define		PLL_PWDN        	0x40
+#define		PLL_NS          	0x30
+#define		PLL_ENLUD       	0x08
+#define		PLL_ENLPF       	0x04
+#define		PLL_DLPF        	0x02
+#define		PLL_ENFBM       	0x01
+
+#define	FAIRNESS        		0x6c
+
+#define	PLL400CTL1      		0x6d
+#define		PLL_CNTEN       	0x80
+#define		PLL_CNTCLR      	0x40
+#define		PLL_RST         	0x01
+
+#define	PLL400CNT0      		0x6e
+
+#define	UNFAIRNESS      		0x6e
+
+#define	HADDR           		0x70
+
+#define	PLLDELAY        		0x70
+#define		SPLIT_DROP_REQ  	0x80
+
+#define	HODMAADR        		0x70
+
+#define	HODMACNT        		0x78
+
+#define	HCNT            		0x78
+
+#define	HODMAEN         		0x7a
+
+#define	SGHADDR         		0x7c
+
+#define	SCBHADDR        		0x7c
+
+#define	SGHCNT          		0x84
+
+#define	SCBHCNT         		0x84
+
+#define	DFF_THRSH       		0x88
+#define		WR_DFTHRSH      	0x70
+#define		RD_DFTHRSH      	0x07
+#define		WR_DFTHRSH_MAX  	0x70
+#define		WR_DFTHRSH_90   	0x60
+#define		WR_DFTHRSH_85   	0x50
+#define		WR_DFTHRSH_75   	0x40
+#define		WR_DFTHRSH_63   	0x30
+#define		WR_DFTHRSH_50   	0x20
+#define		WR_DFTHRSH_25   	0x10
+#define		RD_DFTHRSH_MAX  	0x07
+#define		RD_DFTHRSH_90   	0x06
+#define		RD_DFTHRSH_85   	0x05
+#define		RD_DFTHRSH_75   	0x04
+#define		RD_DFTHRSH_63   	0x03
+#define		RD_DFTHRSH_50   	0x02
+#define		RD_DFTHRSH_25   	0x01
+#define		WR_DFTHRSH_MIN  	0x00
+#define		RD_DFTHRSH_MIN  	0x00
+
+#define	ROMADDR         		0x8a
+
+#define	ROMCNTRL        		0x8d
+#define		ROMOP           	0xe0
+#define		ROMSPD          	0x18
+#define		REPEAT          	0x02
+#define		RDY             	0x01
+
+#define	ROMDATA         		0x8e
+
+#define	CMCRXMSG0       		0x90
+
+#define	ROENABLE        		0x90
+#define		MSIROEN         	0x20
+#define		OVLYROEN        	0x10
+#define		CMCROEN         	0x08
+#define		SGROEN          	0x04
+#define		DCH1ROEN        	0x02
+#define		DCH0ROEN        	0x01
+
+#define	OVLYRXMSG0      		0x90
+
+#define	DCHRXMSG0       		0x90
+
+#define	OVLYRXMSG1      		0x91
+
+#define	NSENABLE        		0x91
+#define		MSINSEN         	0x20
+#define		OVLYNSEN        	0x10
+#define		CMCNSEN         	0x08
+#define		SGNSEN          	0x04
+#define		DCH1NSEN        	0x02
+#define		DCH0NSEN        	0x01
+
+#define	DCHRXMSG1       		0x91
+
+#define	CMCRXMSG1       		0x91
+
+#define	DCHRXMSG2       		0x92
+
+#define	OVLYRXMSG2      		0x92
+
+#define	CMCRXMSG2       		0x92
+
+#define	OST             		0x92
+
+#define	DCHRXMSG3       		0x93
+
+#define	CMCRXMSG3       		0x93
+
+#define	PCIXCTL         		0x93
+#define		SERRPULSE       	0x80
+#define		UNEXPSCIEN      	0x20
+#define		SPLTSMADIS      	0x10
+#define		SPLTSTADIS      	0x08
+#define		SRSPDPEEN       	0x04
+#define		TSCSERREN       	0x02
+#define		CMPABCDIS       	0x01
+
+#define	OVLYRXMSG3      		0x93
+
+#define	OVLYSEQBCNT     		0x94
+
+#define	CMCSEQBCNT      		0x94
+
+#define	DCHSEQBCNT      		0x94
+
+#define	CMCSPLTSTAT0    		0x96
+
+#define	OVLYSPLTSTAT0   		0x96
+
+#define	DCHSPLTSTAT0    		0x96
+
+#define	DCHSPLTSTAT1    		0x97
+
+#define	CMCSPLTSTAT1    		0x97
+
+#define	OVLYSPLTSTAT1   		0x97
+
+#define	SGRXMSG0        		0x98
+#define		CDNUM           	0xf8
+#define		CFNUM           	0x07
+
+#define	SLVSPLTOUTADR0  		0x98
+#define		LOWER_ADDR      	0x7f
+
+#define	SGRXMSG1        		0x99
+#define		CBNUM           	0xff
+
+#define	SLVSPLTOUTADR1  		0x99
+#define		REQ_DNUM        	0xf8
+#define		REQ_FNUM        	0x07
+
+#define	SGRXMSG2        		0x9a
+#define		MINDEX          	0xff
+
+#define	SLVSPLTOUTADR2  		0x9a
+#define		REQ_BNUM        	0xff
+
+#define	SGRXMSG3        		0x9b
+#define		MCLASS          	0x0f
+
+#define	SLVSPLTOUTADR3  		0x9b
+#define		TAG_NUM         	0x1f
+#define		RLXORD          	0x10
+
+#define	SGSEQBCNT       		0x9c
+
+#define	SLVSPLTOUTATTR0 		0x9c
+#define		LOWER_BCNT      	0xff
+
+#define	SLVSPLTOUTATTR1 		0x9d
+#define		CMPLT_DNUM      	0xf8
+#define		CMPLT_FNUM      	0x07
+
+#define	SLVSPLTOUTATTR2 		0x9e
+#define		CMPLT_BNUM      	0xff
+
+#define	SGSPLTSTAT0     		0x9e
+#define		STAETERM        	0x80
+#define		SCBCERR         	0x40
+#define		SCADERR         	0x20
+#define		SCDATBUCKET     	0x10
+#define		CNTNOTCMPLT     	0x08
+#define		RXOVRUN         	0x04
+#define		RXSCEMSG        	0x02
+#define		RXSPLTRSP       	0x01
+
+#define	SFUNCT          		0x9f
+#define		TEST_GROUP      	0xf0
+#define		TEST_NUM        	0x0f
+
+#define	SGSPLTSTAT1     		0x9f
+#define		RXDATABUCKET    	0x01
+
+#define	DF0PCISTAT      		0xa0
+
+#define	REG0            		0xa0
+
+#define	DF1PCISTAT      		0xa1
+
+#define	SGPCISTAT       		0xa2
+
+#define	REG1            		0xa2
+
+#define	CMCPCISTAT      		0xa3
+
+#define	OVLYPCISTAT     		0xa4
+#define		SCAAPERR        	0x08
+#define		RDPERR          	0x04
+
+#define	REG_ISR         		0xa4
+
+#define	SG_STATE        		0xa6
+#define		FETCH_INPROG    	0x04
+#define		LOADING_NEEDED  	0x02
+#define		SEGS_AVAIL      	0x01
+
+#define	MSIPCISTAT      		0xa6
+#define		RMA             	0x20
+#define		RTA             	0x10
+#define		CLRPENDMSI      	0x08
+#define		DPR             	0x01
+
+#define	TARGPCISTAT     		0xa7
+#define		DPE             	0x80
+#define		SSE             	0x40
+#define		STA             	0x08
+#define		TWATERR         	0x02
+
+#define	DATA_COUNT_ODD  		0xa7
+
+#define	SCBPTR          		0xa8
+
+#define	CCSCBACNT       		0xab
+
+#define	SCBAUTOPTR      		0xab
+#define		AUSCBPTR_EN     	0x80
+#define		SCBPTR_ADDR     	0x38
+#define		SCBPTR_OFF      	0x07
+
+#define	CCSGADDR        		0xac
+
+#define	CCSCBADDR       		0xac
+
+#define	CCSCBADR_BK     		0xac
+
+#define	CMC_RAMBIST     		0xad
+#define		SG_ELEMENT_SIZE 	0x80
+#define		SCBRAMBIST_FAIL 	0x40
+#define		SG_BIST_FAIL    	0x20
+#define		SG_BIST_EN      	0x10
+#define		CMC_BUFFER_BIST_FAIL	0x02
+#define		CMC_BUFFER_BIST_EN	0x01
+
+#define	CCSGCTL         		0xad
+#define		CCSGEN          	0x0c
+#define		CCSGDONE        	0x80
+#define		SG_CACHE_AVAIL  	0x10
+#define		CCSGENACK       	0x08
+#define		SG_FETCH_REQ    	0x02
+#define		CCSGRESET       	0x01
+
+#define	CCSCBCTL        		0xad
+#define		CCSCBDONE       	0x80
+#define		ARRDONE         	0x40
+#define		CCARREN         	0x10
+#define		CCSCBEN         	0x08
+#define		CCSCBDIR        	0x04
+#define		CCSCBRESET      	0x01
+
+#define	CCSGRAM         		0xb0
+
+#define	FLEXADR         		0xb0
+
+#define	CCSCBRAM        		0xb0
+
+#define	FLEXCNT         		0xb3
+
+#define	FLEXDMASTAT     		0xb5
+#define		FLEXDMAERR      	0x02
+#define		FLEXDMADONE     	0x01
+
+#define	FLEXDATA        		0xb6
+
+#define	BRDDAT          		0xb8
+
+#define	BRDCTL          		0xb9
+#define		FLXARBACK       	0x80
+#define		FLXARBREQ       	0x40
+#define		BRDADDR         	0x38
+#define		BRDEN           	0x04
+#define		BRDRW           	0x02
+#define		BRDSTB          	0x01
+
+#define	SEEADR          		0xba
+
+#define	SEEDAT          		0xbc
+
+#define	SEECTL          		0xbe
+#define		SEEOP_EWEN      	0x40
+#define		SEEOP_WALL      	0x40
+#define		SEEOP_EWDS      	0x40
+#define		SEEOPCODE       	0x70
+#define		SEERST          	0x02
+#define		SEESTART        	0x01
+#define		SEEOP_ERASE     	0x70
+#define		SEEOP_READ      	0x60
+#define		SEEOP_WRITE     	0x50
+#define		SEEOP_ERAL      	0x40
+
+#define	SEESTAT         		0xbe
+#define		INIT_DONE       	0x80
+#define		LDALTID_L       	0x08
+#define		SEEARBACK       	0x04
+#define		SEEBUSY         	0x02
+
+#define	SCBCNT          		0xbf
+
+#define	DFWADDR         		0xc0
+
+#define	DSPFLTRCTL      		0xc0
+#define		FLTRDISABLE     	0x20
+#define		EDGESENSE       	0x10
+#define		DSPFCNTSEL      	0x0f
+
+#define	DSPDATACTL      		0xc1
+#define		BYPASSENAB      	0x80
+#define		DESQDIS         	0x10
+#define		RCVROFFSTDIS    	0x04
+#define		XMITOFFSTDIS    	0x02
+
+#define	DFRADDR         		0xc2
+
+#define	DSPREQCTL       		0xc2
+#define		MANREQCTL       	0xc0
+#define		MANREQDLY       	0x3f
+
+#define	DSPACKCTL       		0xc3
+#define		MANACKCTL       	0xc0
+#define		MANACKDLY       	0x3f
+
+#define	DFDAT           		0xc4
+
+#define	DSPSELECT       		0xc4
+#define		AUTOINCEN       	0x80
+#define		DSPSEL          	0x1f
+
+#define	WRTBIASCTL      		0xc5
+#define		AUTOXBCDIS      	0x80
+#define		XMITMANVAL      	0x3f
+
+#define	RCVRBIOSCTL     		0xc6
+#define		AUTORBCDIS      	0x80
+#define		RCVRMANVAL      	0x3f
+
+#define	WRTBIASCALC     		0xc7
+
+#define	DFPTRS          		0xc8
+
+#define	RCVRBIASCALC    		0xc8
+
+#define	DFBKPTR         		0xc9
+
+#define	SKEWCALC        		0xc9
+
+#define	DFDBCTL         		0xcb
+#define		DFF_CIO_WR_RDY  	0x20
+#define		DFF_CIO_RD_RDY  	0x10
+#define		DFF_DIR_ERR     	0x08
+#define		DFF_RAMBIST_FAIL	0x04
+#define		DFF_RAMBIST_DONE	0x02
+#define		DFF_RAMBIST_EN  	0x01
+
+#define	DFSCNT          		0xcc
+
+#define	DFBCNT          		0xce
+
+#define	OVLYADDR        		0xd4
+
+#define	SEQCTL0         		0xd6
+#define		PERRORDIS       	0x80
+#define		PAUSEDIS        	0x40
+#define		FAILDIS         	0x20
+#define		FASTMODE        	0x10
+#define		BRKADRINTEN     	0x08
+#define		STEP            	0x04
+#define		SEQRESET        	0x02
+#define		LOADRAM         	0x01
+
+#define	SEQCTL1         		0xd7
+#define		OVRLAY_DATA_CHK 	0x08
+#define		RAMBIST_DONE    	0x04
+#define		RAMBIST_FAIL    	0x02
+#define		RAMBIST_EN      	0x01
+
+#define	FLAGS           		0xd8
+#define		ZERO            	0x02
+#define		CARRY           	0x01
+
+#define	SEQINTCTL       		0xd9
+#define		INTVEC1DSL      	0x80
+#define		INT1_CONTEXT    	0x20
+#define		SCS_SEQ_INT1M1  	0x10
+#define		SCS_SEQ_INT1M0  	0x08
+#define		INTMASK2        	0x04
+#define		INTMASK1        	0x02
+#define		IRET            	0x01
+
+#define	SEQRAM          		0xda
+
+#define	PRGMCNT         		0xde
+
+#define	ACCUM           		0xe0
+
+#define	SINDEX          		0xe2
+
+#define	DINDEX          		0xe4
+
+#define	BRKADDR1        		0xe6
+#define		BRKDIS          	0x80
+
+#define	BRKADDR0        		0xe6
+
+#define	ALLONES         		0xe8
+
+#define	ALLZEROS        		0xea
+
+#define	NONE            		0xea
+
+#define	SINDIR          		0xec
+
+#define	DINDIR          		0xed
+
+#define	FUNCTION1       		0xf0
+
+#define	STACK           		0xf2
+
+#define	CURADDR         		0xf4
+
+#define	INTVEC1_ADDR    		0xf4
+
+#define	INTVEC2_ADDR    		0xf6
+
+#define	LASTADDR        		0xf6
+
+#define	LONGJMP_ADDR    		0xf8
+
+#define	ACCUM_SAVE      		0xfa
+
+#define	WAITING_SCB_TAILS		0x100
+
+#define	AHD_PCI_CONFIG_BASE		0x100
+
+#define	SRAM_BASE       		0x100
+
+#define	WAITING_TID_HEAD		0x120
+
+#define	WAITING_TID_TAIL		0x122
+
+#define	NEXT_QUEUED_SCB_ADDR		0x124
+
+#define	COMPLETE_SCB_HEAD		0x128
+
+#define	COMPLETE_SCB_DMAINPROG_HEAD		0x12a
+
+#define	COMPLETE_DMA_SCB_HEAD		0x12c
+
+#define	QFREEZE_COUNT   		0x12e
+
+#define	SAVED_MODE      		0x130
+
+#define	MSG_OUT         		0x131
+
+#define	DMAPARAMS       		0x132
+#define		PRELOADEN       	0x80
+#define		WIDEODD         	0x40
+#define		SCSIEN          	0x20
+#define		SDMAEN          	0x10
+#define		SDMAENACK       	0x10
+#define		HDMAENACK       	0x08
+#define		HDMAEN          	0x08
+#define		DIRECTION       	0x04
+#define		FIFOFLUSH       	0x02
+#define		FIFORESET       	0x01
+
+#define	SEQ_FLAGS       		0x133
+#define		NOT_IDENTIFIED  	0x80
+#define		NO_CDB_SENT     	0x40
+#define		TARGET_CMD_IS_TAGGED	0x40
+#define		DPHASE          	0x20
+#define		TARG_CMD_PENDING	0x10
+#define		CMDPHASE_PENDING	0x08
+#define		DPHASE_PENDING  	0x04
+#define		SPHASE_PENDING  	0x02
+#define		NO_DISCONNECT   	0x01
+
+#define	SAVED_SCSIID    		0x134
+
+#define	SAVED_LUN       		0x135
+
+#define	LASTPHASE       		0x136
+#define		PHASE_MASK      	0xe0
+#define		CDI             	0x80
+#define		IOI             	0x40
+#define		MSGI            	0x20
+#define		P_BUSFREE       	0x01
+#define		P_MESGIN        	0xe0
+#define		P_STATUS        	0xc0
+#define		P_MESGOUT       	0xa0
+#define		P_COMMAND       	0x80
+#define		P_DATAIN_DT     	0x60
+#define		P_DATAIN        	0x40
+#define		P_DATAOUT_DT    	0x20
+#define		P_DATAOUT       	0x00
+
+#define	QOUTFIFO_ENTRY_VALID_TAG		0x137
+
+#define	SHARED_DATA_ADDR		0x138
+
+#define	QOUTFIFO_NEXT_ADDR		0x13c
+
+#define	KERNEL_TQINPOS  		0x140
+
+#define	TQINPOS         		0x141
+
+#define	ARG_1           		0x142
+#define	RETURN_1        		0x142
+#define		SEND_MSG        	0x80
+#define		SEND_SENSE      	0x40
+#define		SEND_REJ        	0x20
+#define		MSGOUT_PHASEMIS 	0x10
+#define		EXIT_MSG_LOOP   	0x08
+#define		CONT_MSG_LOOP_WRITE	0x04
+#define		CONT_MSG_LOOP_READ	0x03
+#define		CONT_MSG_LOOP_TARG	0x02
+
+#define	ARG_2           		0x143
+#define	RETURN_2        		0x143
+
+#define	LAST_MSG        		0x144
+
+#define	SCSISEQ_TEMPLATE		0x145
+#define		MANUALCTL       	0x40
+#define		ENSELI          	0x20
+#define		ENRSELI         	0x10
+#define		MANUALP         	0x0c
+#define		ENAUTOATNP      	0x02
+#define		ALTSTIM         	0x01
+
+#define	INITIATOR_TAG   		0x146
+
+#define	SEQ_FLAGS2      		0x147
+#define		SELECTOUT_QFROZEN	0x04
+#define		TARGET_MSG_PENDING	0x02
+
+#define	ALLOCFIFO_SCBPTR		0x148
+
+#define	INT_COALESCING_TIMER		0x14a
+
+#define	INT_COALESCING_MAXCMDS		0x14c
+
+#define	INT_COALESCING_MINCMDS		0x14d
+
+#define	CMDS_PENDING    		0x14e
+
+#define	INT_COALESCING_CMDCOUNT		0x150
+
+#define	LOCAL_HS_MAILBOX		0x151
+
+#define	CMDSIZE_TABLE   		0x152
+
+#define	SCB_BASE        		0x180
+
+#define	SCB_RESIDUAL_DATACNT		0x180
+#define	SCB_CDB_STORE   		0x180
+#define	SCB_HOST_CDB_PTR		0x180
+
+#define	SCB_RESIDUAL_SGPTR		0x184
+#define		SG_ADDR_MASK    	0xf8
+#define		SG_OVERRUN_RESID	0x02
+
+#define	SCB_SCSI_STATUS 		0x188
+#define	SCB_HOST_CDB_LEN		0x188
+
+#define	SCB_TARGET_PHASES		0x189
+
+#define	SCB_TARGET_DATA_DIR		0x18a
+
+#define	SCB_TARGET_ITAG 		0x18b
+
+#define	SCB_SENSE_BUSADDR		0x18c
+#define	SCB_NEXT_COMPLETE		0x18c
+
+#define	SCB_TAG         		0x190
+#define	SCB_FIFO_USE_COUNT		0x190
+
+#define	SCB_CONTROL     		0x192
+#define		TARGET_SCB      	0x80
+#define		DISCENB         	0x40
+#define		TAG_ENB         	0x20
+#define		MK_MESSAGE      	0x10
+#define		STATUS_RCVD     	0x08
+#define		DISCONNECTED    	0x04
+#define		SCB_TAG_TYPE    	0x03
+
+#define	SCB_SCSIID      		0x193
+#define		TID             	0xf0
+#define		OID             	0x0f
+
+#define	SCB_LUN         		0x194
+#define		LID             	0xff
+
+#define	SCB_TASK_ATTRIBUTE		0x195
+#define		SCB_XFERLEN_ODD 	0x01
+
+#define	SCB_CDB_LEN     		0x196
+#define		SCB_CDB_LEN_PTR 	0x80
+
+#define	SCB_TASK_MANAGEMENT		0x197
+
+#define	SCB_DATAPTR     		0x198
+
+#define	SCB_DATACNT     		0x1a0
+#define		SG_LAST_SEG     	0x80
+#define		SG_HIGH_ADDR_BITS	0x7f
+
+#define	SCB_SGPTR       		0x1a4
+#define		SG_STATUS_VALID 	0x04
+#define		SG_FULL_RESID   	0x02
+#define		SG_LIST_NULL    	0x01
+
+#define	SCB_BUSADDR     		0x1a8
+
+#define	SCB_NEXT        		0x1ac
+#define	SCB_NEXT_SCB_BUSADDR		0x1ac
+
+#define	SCB_NEXT2       		0x1ae
+
+#define	SCB_SPARE       		0x1b0
+#define	SCB_PKT_LUN     		0x1b0
+
+#define	SCB_DISCONNECTED_LISTS		0x1b8
+
+
+#define	AHD_TIMER_US_PER_TICK	0x19
+#define	SCB_TRANSFER_SIZE_FULL_LUN	0x38
+#define	STATUS_QUEUE_FULL	0x28
+#define	STATUS_BUSY	0x08
+#define	MAX_OFFSET_NON_PACED	0x7f
+#define	MAX_OFFSET_PACED	0xfe
+#define	BUS_32_BIT	0x02
+#define	CCSGADDR_MAX	0x80
+#define	TID_SHIFT	0x04
+#define	MK_MESSAGE_BIT_OFFSET	0x04
+#define	WRTBIASCTL_HP_DEFAULT	0x00
+#define	SEEOP_EWDS_ADDR	0x00
+#define	AHD_AMPLITUDE_SHIFT	0x00
+#define	AHD_AMPLITUDE_MASK	0x07
+#define	AHD_ANNEXCOL_AMPLITUDE	0x06
+#define	AHD_SLEWRATE_DEF_REVA	0x08
+#define	AHD_SLEWRATE_SHIFT	0x03
+#define	AHD_SLEWRATE_MASK	0x78
+#define	AHD_PRECOMP_CUTBACK_29	0x06
+#define	AHD_NUM_PER_DEV_ANNEXCOLS	0x04
+#define	B_CURRFIFO_0	0x02
+#define	LUNLEN_SINGLE_LEVEL_LUN	0x0f
+#define	NVRAM_SCB_OFFSET	0x2c
+#define	AHD_TIMER_MAX_US	0x18ffe7
+#define	AHD_TIMER_MAX_TICKS	0xffff
+#define	STATUS_PKT_SENSE	0xff
+#define	CMD_GROUP_CODE_SHIFT	0x05
+#define	AHD_SENSE_BUFSIZE	0x100
+#define	MAX_OFFSET_PACED_BUG	0x7f
+#define	BUS_8_BIT	0x00
+#define	STIMESEL_BUG_ADJ	0x08
+#define	STIMESEL_MIN	0x18
+#define	STIMESEL_SHIFT	0x03
+#define	CCSGRAM_MAXSEGS	0x10
+#define	INVALID_ADDR	0x80
+#define	TARGET_CMD_CMPLT	0xfe
+#define	SEEOP_WRAL_ADDR	0x40
+#define	SEEOP_ERAL_ADDR	0x80
+#define	AHD_AMPLITUDE_DEF	0x07
+#define	AHD_SLEWRATE_DEF_REVB	0x08
+#define	AHD_PRECOMP_CUTBACK_37	0x07
+#define	AHD_PRECOMP_CUTBACK_17	0x04
+#define	AHD_PRECOMP_SHIFT	0x00
+#define	AHD_PRECOMP_MASK	0x07
+#define	AHD_ANNEXCOL_PRECOMP_SLEW	0x04
+#define	SRC_MODE_SHIFT	0x00
+#define	PKT_OVERRUN_BUFSIZE	0x200
+#define	SCB_TRANSFER_SIZE_1BYTE_LUN	0x30
+#define	TARGET_DATA_IN	0x01
+#define	HOST_MSG	0xff
+#define	MAX_OFFSET	0xfe
+#define	BUS_16_BIT	0x01
+#define	CCSCBADDR_MAX	0x80
+#define	NUMDSPS 	0x14
+#define	SEEOP_EWEN_ADDR	0xc0
+#define	AHD_ANNEXCOL_PER_DEV0	0x04
+#define	DST_MODE_SHIFT	0x04
+
+
+/* Downloaded Constant Definitions */
+#define	SCB_TRANSFER_SIZE	0x06
+#define	PKT_OVERRUN_BUFOFFSET	0x05
+#define	SG_SIZEOF	0x04
+#define	SG_PREFETCH_ADDR_MASK	0x03
+#define	SG_PREFETCH_ALIGN_MASK	0x02
+#define	SG_PREFETCH_CNT_LIMIT	0x01
+#define	SG_PREFETCH_CNT	0x00
+#define	DOWNLOAD_CONST_COUNT	0x07
+
+
+/* Exported Labels */
+#define	LABEL_seq_isr 	0x269
+#define	LABEL_timer_isr	0x265
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic79xx_reg_print.c linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx_reg_print.c
--- linux-2.4.21/drivers/scsi/aic7xxx/aic79xx_reg_print.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx_reg_print.c	2003-06-26 21:43:11.000000000 +0000
@@ -0,0 +1,3635 @@
+/*
+ * DO NOT EDIT - This file is automatically generated
+ *		 from the following source files:
+ *
+ * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#94 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#70 $
+ */
+
+#include "aic79xx_osm.h"
+
+static ahd_reg_parse_entry_t MODE_PTR_parse_table[] = {
+	{ "SRC_MODE",		0x07, 0x07 },
+	{ "DST_MODE",		0x70, 0x70 }
+};
+
+int
+ahd_mode_ptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(MODE_PTR_parse_table, 2, "MODE_PTR",
+	    0x00, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t INTSTAT_parse_table[] = {
+	{ "SPLTINT",		0x01, 0x01 },
+	{ "CMDCMPLT",		0x02, 0x02 },
+	{ "SEQINT",		0x04, 0x04 },
+	{ "SCSIINT",		0x08, 0x08 },
+	{ "PCIINT",		0x10, 0x10 },
+	{ "SWTMINT",		0x20, 0x20 },
+	{ "BRKADRINT",		0x40, 0x40 },
+	{ "HWERRINT",		0x80, 0x80 },
+	{ "INT_PEND",		0xff, 0xff }
+};
+
+int
+ahd_intstat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(INTSTAT_parse_table, 9, "INTSTAT",
+	    0x01, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SEQINTCODE_parse_table[] = {
+	{ "NO_SEQINT",		0x00, 0xff },
+	{ "BAD_PHASE",		0x01, 0xff },
+	{ "SEND_REJECT",	0x02, 0xff },
+	{ "PROTO_VIOLATION",	0x03, 0xff },
+	{ "NO_MATCH",		0x04, 0xff },
+	{ "IGN_WIDE_RES",	0x05, 0xff },
+	{ "PDATA_REINIT",	0x06, 0xff },
+	{ "HOST_MSG_LOOP",	0x07, 0xff },
+	{ "BAD_STATUS",		0x08, 0xff },
+	{ "DATA_OVERRUN",	0x09, 0xff },
+	{ "MKMSG_FAILED",	0x0a, 0xff },
+	{ "MISSED_BUSFREE",	0x0b, 0xff },
+	{ "DUMP_CARD_STATE",	0x0c, 0xff },
+	{ "ILLEGAL_PHASE",	0x0d, 0xff },
+	{ "INVALID_SEQINT",	0x0e, 0xff },
+	{ "CFG4ISTAT_INTR",	0x0f, 0xff },
+	{ "STATUS_OVERRUN",	0x10, 0xff },
+	{ "CFG4OVERRUN",	0x11, 0xff },
+	{ "ENTERING_NONPACK",	0x12, 0xff },
+	{ "TASKMGMT_FUNC_COMPLETE",0x13, 0xff },
+	{ "TASKMGMT_CMD_CMPLT_OKAY",0x14, 0xff },
+	{ "TRACEPOINT0",	0x15, 0xff },
+	{ "TRACEPOINT1",	0x16, 0xff },
+	{ "TRACEPOINT2",	0x17, 0xff },
+	{ "TRACEPOINT3",	0x18, 0xff },
+	{ "SAW_HWERR",		0x19, 0xff },
+	{ "BAD_SCB_STATUS",	0x1a, 0xff }
+};
+
+int
+ahd_seqintcode_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SEQINTCODE_parse_table, 27, "SEQINTCODE",
+	    0x02, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CLRINT_parse_table[] = {
+	{ "CLRSPLTINT",		0x01, 0x01 },
+	{ "CLRCMDINT",		0x02, 0x02 },
+	{ "CLRSEQINT",		0x04, 0x04 },
+	{ "CLRSCSIINT",		0x08, 0x08 },
+	{ "CLRPCIINT",		0x10, 0x10 },
+	{ "CLRSWTMINT",		0x20, 0x20 },
+	{ "CLRBRKADRINT",	0x40, 0x40 },
+	{ "CLRHWERRINT",	0x80, 0x80 }
+};
+
+int
+ahd_clrint_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CLRINT_parse_table, 8, "CLRINT",
+	    0x03, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t ERROR_parse_table[] = {
+	{ "DSCTMOUT",		0x02, 0x02 },
+	{ "ILLOPCODE",		0x04, 0x04 },
+	{ "SQPARERR",		0x08, 0x08 },
+	{ "DPARERR",		0x10, 0x10 },
+	{ "MPARERR",		0x20, 0x20 },
+	{ "CIOACCESFAIL",	0x40, 0x40 },
+	{ "CIOPARERR",		0x80, 0x80 }
+};
+
+int
+ahd_error_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(ERROR_parse_table, 7, "ERROR",
+	    0x04, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CLRERR_parse_table[] = {
+	{ "CLRDSCTMOUT",	0x02, 0x02 },
+	{ "CLRILLOPCODE",	0x04, 0x04 },
+	{ "CLRSQPARERR",	0x08, 0x08 },
+	{ "CLRDPARERR",		0x10, 0x10 },
+	{ "CLRMPARERR",		0x20, 0x20 },
+	{ "CLRCIOACCESFAIL",	0x40, 0x40 },
+	{ "CLRCIOPARERR",	0x80, 0x80 }
+};
+
+int
+ahd_clrerr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CLRERR_parse_table, 7, "CLRERR",
+	    0x04, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t HCNTRL_parse_table[] = {
+	{ "CHIPRST",		0x01, 0x01 },
+	{ "CHIPRSTACK",		0x01, 0x01 },
+	{ "INTEN",		0x02, 0x02 },
+	{ "PAUSE",		0x04, 0x04 },
+	{ "SWTIMER_START_B",	0x08, 0x08 },
+	{ "SWINT",		0x10, 0x10 },
+	{ "POWRDN",		0x40, 0x40 },
+	{ "SEQ_RESET",		0x80, 0x80 }
+};
+
+int
+ahd_hcntrl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(HCNTRL_parse_table, 8, "HCNTRL",
+	    0x05, regvalue, cur_col, wrap));
+}
+
+int
+ahd_hnscb_qoff_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "HNSCB_QOFF",
+	    0x06, regvalue, cur_col, wrap));
+}
+
+int
+ahd_hescb_qoff_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "HESCB_QOFF",
+	    0x08, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t HS_MAILBOX_parse_table[] = {
+	{ "ENINT_COALESCE",	0x40, 0x40 },
+	{ "HOST_TQINPOS",	0x80, 0x80 }
+};
+
+int
+ahd_hs_mailbox_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(HS_MAILBOX_parse_table, 2, "HS_MAILBOX",
+	    0x0b, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CLRSEQINTSTAT_parse_table[] = {
+	{ "CLRSEQ_SPLTINT",	0x01, 0x01 },
+	{ "CLRSEQ_PCIINT",	0x02, 0x02 },
+	{ "CLRSEQ_SCSIINT",	0x04, 0x04 },
+	{ "CLRSEQ_SEQINT",	0x08, 0x08 },
+	{ "CLRSEQ_SWTMRTO",	0x10, 0x10 }
+};
+
+int
+ahd_clrseqintstat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CLRSEQINTSTAT_parse_table, 5, "CLRSEQINTSTAT",
+	    0x0c, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SEQINTSTAT_parse_table[] = {
+	{ "SEQ_SPLTINT",	0x01, 0x01 },
+	{ "SEQ_PCIINT",		0x02, 0x02 },
+	{ "SEQ_SCSIINT",	0x04, 0x04 },
+	{ "SEQ_SEQINT",		0x08, 0x08 },
+	{ "SEQ_SWTMRTO",	0x10, 0x10 }
+};
+
+int
+ahd_seqintstat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SEQINTSTAT_parse_table, 5, "SEQINTSTAT",
+	    0x0c, regvalue, cur_col, wrap));
+}
+
+int
+ahd_swtimer_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SWTIMER",
+	    0x0e, regvalue, cur_col, wrap));
+}
+
+int
+ahd_snscb_qoff_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SNSCB_QOFF",
+	    0x10, regvalue, cur_col, wrap));
+}
+
+int
+ahd_sescb_qoff_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SESCB_QOFF",
+	    0x12, regvalue, cur_col, wrap));
+}
+
+int
+ahd_sdscb_qoff_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SDSCB_QOFF",
+	    0x14, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t QOFF_CTLSTA_parse_table[] = {
+	{ "SCB_QSIZE_4",	0x00, 0x0f },
+	{ "SCB_QSIZE_8",	0x01, 0x0f },
+	{ "SCB_QSIZE_16",	0x02, 0x0f },
+	{ "SCB_QSIZE_32",	0x03, 0x0f },
+	{ "SCB_QSIZE_64",	0x04, 0x0f },
+	{ "SCB_QSIZE_128",	0x05, 0x0f },
+	{ "SCB_QSIZE_256",	0x06, 0x0f },
+	{ "SCB_QSIZE_512",	0x07, 0x0f },
+	{ "SCB_QSIZE_1024",	0x08, 0x0f },
+	{ "SCB_QSIZE_2048",	0x09, 0x0f },
+	{ "SCB_QSIZE_4096",	0x0a, 0x0f },
+	{ "SCB_QSIZE_8192",	0x0b, 0x0f },
+	{ "SCB_QSIZE_16384",	0x0c, 0x0f },
+	{ "SCB_QSIZE",		0x0f, 0x0f },
+	{ "HS_MAILBOX_ACT",	0x10, 0x10 },
+	{ "SDSCB_ROLLOVR",	0x20, 0x20 },
+	{ "NEW_SCB_AVAIL",	0x40, 0x40 },
+	{ "EMPTY_SCB_AVAIL",	0x80, 0x80 }
+};
+
+int
+ahd_qoff_ctlsta_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(QOFF_CTLSTA_parse_table, 18, "QOFF_CTLSTA",
+	    0x16, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t INTCTL_parse_table[] = {
+	{ "SPLTINTEN",		0x01, 0x01 },
+	{ "SEQINTEN",		0x02, 0x02 },
+	{ "SCSIINTEN",		0x04, 0x04 },
+	{ "PCIINTEN",		0x08, 0x08 },
+	{ "AUTOCLRCMDINT",	0x10, 0x10 },
+	{ "SWTIMER_START",	0x20, 0x20 },
+	{ "SWTMINTEN",		0x40, 0x40 },
+	{ "SWTMINTMASK",	0x80, 0x80 }
+};
+
+int
+ahd_intctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(INTCTL_parse_table, 8, "INTCTL",
+	    0x18, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DFCNTRL_parse_table[] = {
+	{ "DIRECTIONEN",	0x01, 0x01 },
+	{ "FIFOFLUSH",		0x02, 0x02 },
+	{ "FIFOFLUSHACK",	0x02, 0x02 },
+	{ "DIRECTION",		0x04, 0x04 },
+	{ "DIRECTIONACK",	0x04, 0x04 },
+	{ "HDMAEN",		0x08, 0x08 },
+	{ "HDMAENACK",		0x08, 0x08 },
+	{ "SCSIEN",		0x20, 0x20 },
+	{ "SCSIENACK",		0x20, 0x20 },
+	{ "SCSIENWRDIS",	0x40, 0x40 },
+	{ "PRELOADEN",		0x80, 0x80 }
+};
+
+int
+ahd_dfcntrl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DFCNTRL_parse_table, 11, "DFCNTRL",
+	    0x19, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DSCOMMAND0_parse_table[] = {
+	{ "CIOPARCKEN",		0x01, 0x01 },
+	{ "DISABLE_TWATE",	0x02, 0x02 },
+	{ "EXTREQLCK",		0x10, 0x10 },
+	{ "MPARCKEN",		0x20, 0x20 },
+	{ "DPARCKEN",		0x40, 0x40 },
+	{ "CACHETHEN",		0x80, 0x80 }
+};
+
+int
+ahd_dscommand0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DSCOMMAND0_parse_table, 6, "DSCOMMAND0",
+	    0x19, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DFSTATUS_parse_table[] = {
+	{ "FIFOEMP",		0x01, 0x01 },
+	{ "FIFOFULL",		0x02, 0x02 },
+	{ "DFTHRESH",		0x04, 0x04 },
+	{ "HDONE",		0x08, 0x08 },
+	{ "MREQPEND",		0x10, 0x10 },
+	{ "PKT_PRELOAD_AVAIL",	0x40, 0x40 },
+	{ "PRELOAD_AVAIL",	0x80, 0x80 }
+};
+
+int
+ahd_dfstatus_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DFSTATUS_parse_table, 7, "DFSTATUS",
+	    0x1a, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SG_CACHE_SHADOW_parse_table[] = {
+	{ "LAST_SEG_DONE",	0x01, 0x01 },
+	{ "LAST_SEG",		0x02, 0x02 },
+	{ "ODD_SEG",		0x04, 0x04 },
+	{ "SG_ADDR_MASK",	0xf8, 0xf8 }
+};
+
+int
+ahd_sg_cache_shadow_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SG_CACHE_SHADOW_parse_table, 4, "SG_CACHE_SHADOW",
+	    0x1b, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t ARBCTL_parse_table[] = {
+	{ "USE_TIME",		0x07, 0x07 },
+	{ "RETRY_SWEN",		0x08, 0x08 },
+	{ "RESET_HARB",		0x80, 0x80 }
+};
+
+int
+ahd_arbctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(ARBCTL_parse_table, 3, "ARBCTL",
+	    0x1b, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SG_CACHE_PRE_parse_table[] = {
+	{ "LAST_SEG",		0x02, 0x02 },
+	{ "ODD_SEG",		0x04, 0x04 },
+	{ "SG_ADDR_MASK",	0xf8, 0xf8 }
+};
+
+int
+ahd_sg_cache_pre_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SG_CACHE_PRE_parse_table, 3, "SG_CACHE_PRE",
+	    0x1b, regvalue, cur_col, wrap));
+}
+
+int
+ahd_lqin_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "LQIN",
+	    0x20, regvalue, cur_col, wrap));
+}
+
+int
+ahd_typeptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "TYPEPTR",
+	    0x20, regvalue, cur_col, wrap));
+}
+
+int
+ahd_tagptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "TAGPTR",
+	    0x21, regvalue, cur_col, wrap));
+}
+
+int
+ahd_lunptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "LUNPTR",
+	    0x22, regvalue, cur_col, wrap));
+}
+
+int
+ahd_datalenptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "DATALENPTR",
+	    0x23, regvalue, cur_col, wrap));
+}
+
+int
+ahd_statlenptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "STATLENPTR",
+	    0x24, regvalue, cur_col, wrap));
+}
+
+int
+ahd_cmdlenptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "CMDLENPTR",
+	    0x25, regvalue, cur_col, wrap));
+}
+
+int
+ahd_attrptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "ATTRPTR",
+	    0x26, regvalue, cur_col, wrap));
+}
+
+int
+ahd_flagptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "FLAGPTR",
+	    0x27, regvalue, cur_col, wrap));
+}
+
+int
+ahd_cmdptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "CMDPTR",
+	    0x28, regvalue, cur_col, wrap));
+}
+
+int
+ahd_qnextptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "QNEXTPTR",
+	    0x29, regvalue, cur_col, wrap));
+}
+
+int
+ahd_idptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "IDPTR",
+	    0x2a, regvalue, cur_col, wrap));
+}
+
+int
+ahd_abrtbyteptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "ABRTBYTEPTR",
+	    0x2b, regvalue, cur_col, wrap));
+}
+
+int
+ahd_abrtbitptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "ABRTBITPTR",
+	    0x2c, regvalue, cur_col, wrap));
+}
+
+int
+ahd_maxcmdbytes_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "MAXCMDBYTES",
+	    0x2d, regvalue, cur_col, wrap));
+}
+
+int
+ahd_maxcmd2rcv_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "MAXCMD2RCV",
+	    0x2e, regvalue, cur_col, wrap));
+}
+
+int
+ahd_shortthresh_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SHORTTHRESH",
+	    0x2f, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t LUNLEN_parse_table[] = {
+	{ "ILUNLEN",		0x0f, 0x0f },
+	{ "TLUNLEN",		0xf0, 0xf0 }
+};
+
+int
+ahd_lunlen_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(LUNLEN_parse_table, 2, "LUNLEN",
+	    0x30, regvalue, cur_col, wrap));
+}
+
+int
+ahd_cdblimit_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "CDBLIMIT",
+	    0x31, regvalue, cur_col, wrap));
+}
+
+int
+ahd_maxcmd_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "MAXCMD",
+	    0x32, regvalue, cur_col, wrap));
+}
+
+int
+ahd_maxcmdcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "MAXCMDCNT",
+	    0x33, regvalue, cur_col, wrap));
+}
+
+int
+ahd_lqrsvd01_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "LQRSVD01",
+	    0x34, regvalue, cur_col, wrap));
+}
+
+int
+ahd_lqrsvd16_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "LQRSVD16",
+	    0x35, regvalue, cur_col, wrap));
+}
+
+int
+ahd_lqrsvd17_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "LQRSVD17",
+	    0x36, regvalue, cur_col, wrap));
+}
+
+int
+ahd_cmdrsvd0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "CMDRSVD0",
+	    0x37, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t LQCTL0_parse_table[] = {
+	{ "LQ0INITGCLT",	0x03, 0x03 },
+	{ "LQ0TARGCLT",		0x0c, 0x0c },
+	{ "LQIINITGCLT",	0x30, 0x30 },
+	{ "LQITARGCLT",		0xc0, 0xc0 }
+};
+
+int
+ahd_lqctl0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(LQCTL0_parse_table, 4, "LQCTL0",
+	    0x38, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t LQCTL1_parse_table[] = {
+	{ "ABORTPENDING",	0x01, 0x01 },
+	{ "SINGLECMD",		0x02, 0x02 },
+	{ "PCI2PCI",		0x04, 0x04 }
+};
+
+int
+ahd_lqctl1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(LQCTL1_parse_table, 3, "LQCTL1",
+	    0x38, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SCSBIST0_parse_table[] = {
+	{ "OSBISTRUN",		0x01, 0x01 },
+	{ "OSBISTDONE",		0x02, 0x02 },
+	{ "OSBISTERR",		0x04, 0x04 },
+	{ "GSBISTRUN",		0x10, 0x10 },
+	{ "GSBISTDONE",		0x20, 0x20 },
+	{ "GSBISTERR",		0x40, 0x40 }
+};
+
+int
+ahd_scsbist0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SCSBIST0_parse_table, 6, "SCSBIST0",
+	    0x39, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t LQCTL2_parse_table[] = {
+	{ "LQOPAUSE",		0x01, 0x01 },
+	{ "LQOTOIDLE",		0x02, 0x02 },
+	{ "LQOCONTINUE",	0x04, 0x04 },
+	{ "LQORETRY",		0x08, 0x08 },
+	{ "LQIPAUSE",		0x10, 0x10 },
+	{ "LQITOIDLE",		0x20, 0x20 },
+	{ "LQICONTINUE",	0x40, 0x40 },
+	{ "LQIRETRY",		0x80, 0x80 }
+};
+
+int
+ahd_lqctl2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(LQCTL2_parse_table, 8, "LQCTL2",
+	    0x39, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SCSBIST1_parse_table[] = {
+	{ "NTBISTRUN",		0x01, 0x01 },
+	{ "NTBISTDONE",		0x02, 0x02 },
+	{ "NTBISTERR",		0x04, 0x04 }
+};
+
+int
+ahd_scsbist1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SCSBIST1_parse_table, 3, "SCSBIST1",
+	    0x3a, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SCSISEQ0_parse_table[] = {
+	{ "SCSIRSTO",		0x01, 0x01 },
+	{ "FORCEBUSFREE",	0x10, 0x10 },
+	{ "ENARBO",		0x20, 0x20 },
+	{ "ENSELO",		0x40, 0x40 },
+	{ "TEMODEO",		0x80, 0x80 }
+};
+
+int
+ahd_scsiseq0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SCSISEQ0_parse_table, 5, "SCSISEQ0",
+	    0x3a, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SCSISEQ1_parse_table[] = {
+	{ "ALTSTIM",		0x01, 0x01 },
+	{ "ENAUTOATNP",		0x02, 0x02 },
+	{ "MANUALP",		0x0c, 0x0c },
+	{ "ENRSELI",		0x10, 0x10 },
+	{ "ENSELI",		0x20, 0x20 },
+	{ "MANUALCTL",		0x40, 0x40 }
+};
+
+int
+ahd_scsiseq1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SCSISEQ1_parse_table, 6, "SCSISEQ1",
+	    0x3b, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SXFRCTL0_parse_table[] = {
+	{ "SPIOEN",		0x08, 0x08 },
+	{ "BIOSCANCELEN",	0x10, 0x10 },
+	{ "DFPEXP",		0x40, 0x40 },
+	{ "DFON",		0x80, 0x80 }
+};
+
+int
+ahd_sxfrctl0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SXFRCTL0_parse_table, 4, "SXFRCTL0",
+	    0x3c, regvalue, cur_col, wrap));
+}
+
+int
+ahd_businitid_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "BUSINITID",
+	    0x3c, regvalue, cur_col, wrap));
+}
+
+int
+ahd_dlcount_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "DLCOUNT",
+	    0x3c, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SXFRCTL1_parse_table[] = {
+	{ "STPWEN",		0x01, 0x01 },
+	{ "ACTNEGEN",		0x02, 0x02 },
+	{ "ENSTIMER",		0x04, 0x04 },
+	{ "STIMESEL",		0x18, 0x18 },
+	{ "ENSPCHK",		0x20, 0x20 },
+	{ "ENSACHK",		0x40, 0x40 },
+	{ "BITBUCKET",		0x80, 0x80 }
+};
+
+int
+ahd_sxfrctl1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SXFRCTL1_parse_table, 7, "SXFRCTL1",
+	    0x3d, regvalue, cur_col, wrap));
+}
+
+int
+ahd_bustargid_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "BUSTARGID",
+	    0x3e, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SXFRCTL2_parse_table[] = {
+	{ "ASU",		0x07, 0x07 },
+	{ "CMDDMAEN",		0x08, 0x08 },
+	{ "AUTORSTDIS",		0x10, 0x10 }
+};
+
+int
+ahd_sxfrctl2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SXFRCTL2_parse_table, 3, "SXFRCTL2",
+	    0x3e, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DFFSTAT_parse_table[] = {
+	{ "CURRFIFO_0",		0x00, 0x03 },
+	{ "CURRFIFO_1",		0x01, 0x03 },
+	{ "CURRFIFO_NONE",	0x03, 0x03 },
+	{ "FIFO0FREE",		0x10, 0x10 },
+	{ "FIFO1FREE",		0x20, 0x20 },
+	{ "CURRFIFO",		0x03, 0x03 }
+};
+
+int
+ahd_dffstat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DFFSTAT_parse_table, 6, "DFFSTAT",
+	    0x3f, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SCSISIGO_parse_table[] = {
+	{ "P_DATAOUT",		0x00, 0xe0 },
+	{ "P_DATAOUT_DT",	0x20, 0xe0 },
+	{ "P_DATAIN",		0x40, 0xe0 },
+	{ "P_DATAIN_DT",	0x60, 0xe0 },
+	{ "P_COMMAND",		0x80, 0xe0 },
+	{ "P_MESGOUT",		0xa0, 0xe0 },
+	{ "P_STATUS",		0xc0, 0xe0 },
+	{ "P_MESGIN",		0xe0, 0xe0 },
+	{ "ACKO",		0x01, 0x01 },
+	{ "REQO",		0x02, 0x02 },
+	{ "BSYO",		0x04, 0x04 },
+	{ "SELO",		0x08, 0x08 },
+	{ "ATNO",		0x10, 0x10 },
+	{ "MSGO",		0x20, 0x20 },
+	{ "IOO",		0x40, 0x40 },
+	{ "CDO",		0x80, 0x80 },
+	{ "PHASE_MASK",		0xe0, 0xe0 }
+};
+
+int
+ahd_scsisigo_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SCSISIGO_parse_table, 17, "SCSISIGO",
+	    0x40, regvalue, cur_col, wrap));
+}
+
+int
+ahd_multargid_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "MULTARGID",
+	    0x40, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SCSISIGI_parse_table[] = {
+	{ "P_DATAOUT",		0x00, 0xe0 },
+	{ "P_DATAOUT_DT",	0x20, 0xe0 },
+	{ "P_DATAIN",		0x40, 0xe0 },
+	{ "P_DATAIN_DT",	0x60, 0xe0 },
+	{ "P_COMMAND",		0x80, 0xe0 },
+	{ "P_MESGOUT",		0xa0, 0xe0 },
+	{ "P_STATUS",		0xc0, 0xe0 },
+	{ "P_MESGIN",		0xe0, 0xe0 },
+	{ "ACKI",		0x01, 0x01 },
+	{ "REQI",		0x02, 0x02 },
+	{ "BSYI",		0x04, 0x04 },
+	{ "SELI",		0x08, 0x08 },
+	{ "ATNI",		0x10, 0x10 },
+	{ "MSGI",		0x20, 0x20 },
+	{ "IOI",		0x40, 0x40 },
+	{ "CDI",		0x80, 0x80 },
+	{ "PHASE_MASK",		0xe0, 0xe0 }
+};
+
+int
+ahd_scsisigi_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SCSISIGI_parse_table, 17, "SCSISIGI",
+	    0x41, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SCSIPHASE_parse_table[] = {
+	{ "DATA_OUT_PHASE",	0x01, 0x03 },
+	{ "DATA_IN_PHASE",	0x02, 0x03 },
+	{ "DATA_PHASE_MASK",	0x03, 0x03 },
+	{ "MSG_OUT_PHASE",	0x04, 0x04 },
+	{ "MSG_IN_PHASE",	0x08, 0x08 },
+	{ "COMMAND_PHASE",	0x10, 0x10 },
+	{ "STATUS_PHASE",	0x20, 0x20 }
+};
+
+int
+ahd_scsiphase_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SCSIPHASE_parse_table, 7, "SCSIPHASE",
+	    0x42, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scsidat0_img_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCSIDAT0_IMG",
+	    0x43, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scsidat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCSIDAT",
+	    0x44, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scsibus_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCSIBUS",
+	    0x46, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t TARGIDIN_parse_table[] = {
+	{ "TARGID",		0x0f, 0x0f },
+	{ "CLKOUT",		0x80, 0x80 }
+};
+
+int
+ahd_targidin_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(TARGIDIN_parse_table, 2, "TARGIDIN",
+	    0x48, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SELID_parse_table[] = {
+	{ "ONEBIT",		0x08, 0x08 },
+	{ "SELID_MASK",		0xf0, 0xf0 }
+};
+
+int
+ahd_selid_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SELID_parse_table, 2, "SELID",
+	    0x49, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SBLKCTL_parse_table[] = {
+	{ "SELWIDE",		0x02, 0x02 },
+	{ "ENAB20",		0x04, 0x04 },
+	{ "ENAB40",		0x08, 0x08 },
+	{ "DIAGLEDON",		0x40, 0x40 },
+	{ "DIAGLEDEN",		0x80, 0x80 }
+};
+
+int
+ahd_sblkctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SBLKCTL_parse_table, 5, "SBLKCTL",
+	    0x4a, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t OPTIONMODE_parse_table[] = {
+	{ "AUTO_MSGOUT_DE",	0x02, 0x02 },
+	{ "ENDGFORMCHK",	0x04, 0x04 },
+	{ "BUSFREEREV",		0x10, 0x10 },
+	{ "BIASCANCTL",		0x20, 0x20 },
+	{ "AUTOACKEN",		0x40, 0x40 },
+	{ "BIOSCANCTL",		0x80, 0x80 },
+	{ "OPTIONMODE_DEFAULTS",0x02, 0x02 }
+};
+
+int
+ahd_optionmode_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(OPTIONMODE_parse_table, 7, "OPTIONMODE",
+	    0x4a, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SSTAT0_parse_table[] = {
+	{ "ARBDO",		0x01, 0x01 },
+	{ "SPIORDY",		0x02, 0x02 },
+	{ "OVERRUN",		0x04, 0x04 },
+	{ "IOERR",		0x08, 0x08 },
+	{ "SELINGO",		0x10, 0x10 },
+	{ "SELDI",		0x20, 0x20 },
+	{ "SELDO",		0x40, 0x40 },
+	{ "TARGET",		0x80, 0x80 }
+};
+
+int
+ahd_sstat0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SSTAT0_parse_table, 8, "SSTAT0",
+	    0x4b, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CLRSINT0_parse_table[] = {
+	{ "CLRARBDO",		0x01, 0x01 },
+	{ "CLRSPIORDY",		0x02, 0x02 },
+	{ "CLROVERRUN",		0x04, 0x04 },
+	{ "CLRIOERR",		0x08, 0x08 },
+	{ "CLRSELINGO",		0x10, 0x10 },
+	{ "CLRSELDI",		0x20, 0x20 },
+	{ "CLRSELDO",		0x40, 0x40 }
+};
+
+int
+ahd_clrsint0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CLRSINT0_parse_table, 7, "CLRSINT0",
+	    0x4b, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SIMODE0_parse_table[] = {
+	{ "ENARBDO",		0x01, 0x01 },
+	{ "ENSPIORDY",		0x02, 0x02 },
+	{ "ENOVERRUN",		0x04, 0x04 },
+	{ "ENIOERR",		0x08, 0x08 },
+	{ "ENSELINGO",		0x10, 0x10 },
+	{ "ENSELDI",		0x20, 0x20 },
+	{ "ENSELDO",		0x40, 0x40 }
+};
+
+int
+ahd_simode0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SIMODE0_parse_table, 7, "SIMODE0",
+	    0x4b, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CLRSINT1_parse_table[] = {
+	{ "CLRREQINIT",		0x01, 0x01 },
+	{ "CLRSTRB2FAST",	0x02, 0x02 },
+	{ "CLRSCSIPERR",	0x04, 0x04 },
+	{ "CLRBUSFREE",		0x08, 0x08 },
+	{ "CLRSCSIRSTI",	0x20, 0x20 },
+	{ "CLRATNO",		0x40, 0x40 },
+	{ "CLRSELTIMEO",	0x80, 0x80 }
+};
+
+int
+ahd_clrsint1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CLRSINT1_parse_table, 7, "CLRSINT1",
+	    0x4c, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SSTAT1_parse_table[] = {
+	{ "REQINIT",		0x01, 0x01 },
+	{ "STRB2FAST",		0x02, 0x02 },
+	{ "SCSIPERR",		0x04, 0x04 },
+	{ "BUSFREE",		0x08, 0x08 },
+	{ "PHASEMIS",		0x10, 0x10 },
+	{ "SCSIRSTI",		0x20, 0x20 },
+	{ "ATNTARG",		0x40, 0x40 },
+	{ "SELTO",		0x80, 0x80 }
+};
+
+int
+ahd_sstat1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SSTAT1_parse_table, 8, "SSTAT1",
+	    0x4c, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SSTAT2_parse_table[] = {
+	{ "BUSFREE_LQO",	0x40, 0xc0 },
+	{ "BUSFREE_DFF0",	0x80, 0xc0 },
+	{ "BUSFREE_DFF1",	0xc0, 0xc0 },
+	{ "DMADONE",		0x01, 0x01 },
+	{ "SDONE",		0x02, 0x02 },
+	{ "WIDE_RES",		0x04, 0x04 },
+	{ "BSYX",		0x08, 0x08 },
+	{ "EXP_ACTIVE",		0x10, 0x10 },
+	{ "NONPACKREQ",		0x20, 0x20 },
+	{ "BUSFREETIME",	0xc0, 0xc0 }
+};
+
+int
+ahd_sstat2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SSTAT2_parse_table, 10, "SSTAT2",
+	    0x4d, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CLRSINT2_parse_table[] = {
+	{ "CLRDMADONE",		0x01, 0x01 },
+	{ "CLRSDONE",		0x02, 0x02 },
+	{ "CLRWIDE_RES",	0x04, 0x04 },
+	{ "CLRNONPACKREQ",	0x20, 0x20 }
+};
+
+int
+ahd_clrsint2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CLRSINT2_parse_table, 4, "CLRSINT2",
+	    0x4d, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SIMODE2_parse_table[] = {
+	{ "ENDMADONE",		0x01, 0x01 },
+	{ "ENSDONE",		0x02, 0x02 },
+	{ "ENWIDE_RES",		0x04, 0x04 }
+};
+
+int
+ahd_simode2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SIMODE2_parse_table, 3, "SIMODE2",
+	    0x4d, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t PERRDIAG_parse_table[] = {
+	{ "DTERR",		0x01, 0x01 },
+	{ "DGFORMERR",		0x02, 0x02 },
+	{ "CRCERR",		0x04, 0x04 },
+	{ "AIPERR",		0x08, 0x08 },
+	{ "PARITYERR",		0x10, 0x10 },
+	{ "PREVPHASE",		0x20, 0x20 },
+	{ "HIPERR",		0x40, 0x40 },
+	{ "HIZERO",		0x80, 0x80 }
+};
+
+int
+ahd_perrdiag_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(PERRDIAG_parse_table, 8, "PERRDIAG",
+	    0x4e, regvalue, cur_col, wrap));
+}
+
+int
+ahd_lqistate_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "LQISTATE",
+	    0x4e, regvalue, cur_col, wrap));
+}
+
+int
+ahd_soffcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SOFFCNT",
+	    0x4f, regvalue, cur_col, wrap));
+}
+
+int
+ahd_lqostate_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "LQOSTATE",
+	    0x4f, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t LQISTAT0_parse_table[] = {
+	{ "LQIATNCMD",		0x01, 0x01 },
+	{ "LQIATNLQ",		0x02, 0x02 },
+	{ "LQIBADLQT",		0x04, 0x04 },
+	{ "LQICRCT2",		0x08, 0x08 },
+	{ "LQICRCT1",		0x10, 0x10 },
+	{ "LQIATNQAS",		0x20, 0x20 }
+};
+
+int
+ahd_lqistat0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(LQISTAT0_parse_table, 6, "LQISTAT0",
+	    0x50, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CLRLQIINT0_parse_table[] = {
+	{ "CLRLQIATNCMD",	0x01, 0x01 },
+	{ "CLRLQIATNLQ",	0x02, 0x02 },
+	{ "CLRLQIBADLQT",	0x04, 0x04 },
+	{ "CLRLQICRCT2",	0x08, 0x08 },
+	{ "CLRLQICRCT1",	0x10, 0x10 },
+	{ "CLRLQIATNQAS",	0x20, 0x20 }
+};
+
+int
+ahd_clrlqiint0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CLRLQIINT0_parse_table, 6, "CLRLQIINT0",
+	    0x50, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t LQIMODE0_parse_table[] = {
+	{ "ENLQIATNCMD",	0x01, 0x01 },
+	{ "ENLQIATNLQ",		0x02, 0x02 },
+	{ "ENLQIBADLQT",	0x04, 0x04 },
+	{ "ENLQICRCT2",		0x08, 0x08 },
+	{ "ENLQICRCT1",		0x10, 0x10 },
+	{ "ENLQIATNQASK",	0x20, 0x20 }
+};
+
+int
+ahd_lqimode0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(LQIMODE0_parse_table, 6, "LQIMODE0",
+	    0x50, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t LQIMODE1_parse_table[] = {
+	{ "ENLQIOVERI_NLQ",	0x01, 0x01 },
+	{ "ENLQIOVERI_LQ",	0x02, 0x02 },
+	{ "ENLQIBADLQI",	0x04, 0x04 },
+	{ "ENLQICRCI_NLQ",	0x08, 0x08 },
+	{ "ENLQICRCI_LQ",	0x10, 0x10 },
+	{ "ENLIQABORT",		0x20, 0x20 },
+	{ "ENLQIPHASE_NLQ",	0x40, 0x40 },
+	{ "ENLQIPHASE_LQ",	0x80, 0x80 }
+};
+
+int
+ahd_lqimode1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(LQIMODE1_parse_table, 8, "LQIMODE1",
+	    0x51, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t LQISTAT1_parse_table[] = {
+	{ "LQIOVERI_NLQ",	0x01, 0x01 },
+	{ "LQIOVERI_LQ",	0x02, 0x02 },
+	{ "LQIBADLQI",		0x04, 0x04 },
+	{ "LQICRCI_NLQ",	0x08, 0x08 },
+	{ "LQICRCI_LQ",		0x10, 0x10 },
+	{ "LQIABORT",		0x20, 0x20 },
+	{ "LQIPHASE_NLQ",	0x40, 0x40 },
+	{ "LQIPHASE_LQ",	0x80, 0x80 }
+};
+
+int
+ahd_lqistat1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(LQISTAT1_parse_table, 8, "LQISTAT1",
+	    0x51, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CLRLQIINT1_parse_table[] = {
+	{ "CLRLQIOVERI_NLQ",	0x01, 0x01 },
+	{ "CLRLQIOVERI_LQ",	0x02, 0x02 },
+	{ "CLRLQIBADLQI",	0x04, 0x04 },
+	{ "CLRLQICRCI_NLQ",	0x08, 0x08 },
+	{ "CLRLQICRCI_LQ",	0x10, 0x10 },
+	{ "CLRLIQABORT",	0x20, 0x20 },
+	{ "CLRLQIPHASE_NLQ",	0x40, 0x40 },
+	{ "CLRLQIPHASE_LQ",	0x80, 0x80 }
+};
+
+int
+ahd_clrlqiint1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CLRLQIINT1_parse_table, 8, "CLRLQIINT1",
+	    0x51, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t LQISTAT2_parse_table[] = {
+	{ "LQIGSAVAIL",		0x01, 0x01 },
+	{ "LQISTOPCMD",		0x02, 0x02 },
+	{ "LQISTOPLQ",		0x04, 0x04 },
+	{ "LQISTOPPKT",		0x08, 0x08 },
+	{ "LQIWAITFIFO",	0x10, 0x10 },
+	{ "LQIWORKONLQ",	0x20, 0x20 },
+	{ "LQIPHASE_OUTPKT",	0x40, 0x40 },
+	{ "PACKETIZED",		0x80, 0x80 }
+};
+
+int
+ahd_lqistat2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(LQISTAT2_parse_table, 8, "LQISTAT2",
+	    0x52, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SSTAT3_parse_table[] = {
+	{ "OSRAMPERR",		0x01, 0x01 },
+	{ "NTRAMPERR",		0x02, 0x02 }
+};
+
+int
+ahd_sstat3_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SSTAT3_parse_table, 2, "SSTAT3",
+	    0x53, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SIMODE3_parse_table[] = {
+	{ "ENOSRAMPERR",	0x01, 0x01 },
+	{ "ENNTRAMPERR",	0x02, 0x02 }
+};
+
+int
+ahd_simode3_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SIMODE3_parse_table, 2, "SIMODE3",
+	    0x53, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CLRSINT3_parse_table[] = {
+	{ "CLROSRAMPERR",	0x01, 0x01 },
+	{ "CLRNTRAMPERR",	0x02, 0x02 }
+};
+
+int
+ahd_clrsint3_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CLRSINT3_parse_table, 2, "CLRSINT3",
+	    0x53, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t LQOMODE0_parse_table[] = {
+	{ "ENLQOTCRC",		0x01, 0x01 },
+	{ "ENLQOATNPKT",	0x02, 0x02 },
+	{ "ENLQOATNLQ",		0x04, 0x04 },
+	{ "ENLQOSTOPT2",	0x08, 0x08 },
+	{ "ENLQOTARGSCBPERR",	0x10, 0x10 }
+};
+
+int
+ahd_lqomode0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(LQOMODE0_parse_table, 5, "LQOMODE0",
+	    0x54, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t LQOSTAT0_parse_table[] = {
+	{ "LQOTCRC",		0x01, 0x01 },
+	{ "LQOATNPKT",		0x02, 0x02 },
+	{ "LQOATNLQ",		0x04, 0x04 },
+	{ "LQOSTOPT2",		0x08, 0x08 },
+	{ "LQOTARGSCBPERR",	0x10, 0x10 }
+};
+
+int
+ahd_lqostat0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(LQOSTAT0_parse_table, 5, "LQOSTAT0",
+	    0x54, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CLRLQOINT0_parse_table[] = {
+	{ "CLRLQOTCRC",		0x01, 0x01 },
+	{ "CLRLQOATNPKT",	0x02, 0x02 },
+	{ "CLRLQOATNLQ",	0x04, 0x04 },
+	{ "CLRLQOSTOPT2",	0x08, 0x08 },
+	{ "CLRLQOTARGSCBPERR",	0x10, 0x10 }
+};
+
+int
+ahd_clrlqoint0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CLRLQOINT0_parse_table, 5, "CLRLQOINT0",
+	    0x54, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t LQOSTAT1_parse_table[] = {
+	{ "LQOPHACHGINPKT",	0x01, 0x01 },
+	{ "LQOBUSFREE",		0x02, 0x02 },
+	{ "LQOBADQAS",		0x04, 0x04 },
+	{ "LQOSTOPI2",		0x08, 0x08 },
+	{ "LQOINITSCBPERR",	0x10, 0x10 }
+};
+
+int
+ahd_lqostat1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(LQOSTAT1_parse_table, 5, "LQOSTAT1",
+	    0x55, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CLRLQOINT1_parse_table[] = {
+	{ "CLRLQOPHACHGINPKT",	0x01, 0x01 },
+	{ "CLRLQOBUSFREE",	0x02, 0x02 },
+	{ "CLRLQOBADQAS",	0x04, 0x04 },
+	{ "CLRLQOSTOPI2",	0x08, 0x08 },
+	{ "CLRLQOINITSCBPERR",	0x10, 0x10 }
+};
+
+int
+ahd_clrlqoint1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CLRLQOINT1_parse_table, 5, "CLRLQOINT1",
+	    0x55, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t LQOMODE1_parse_table[] = {
+	{ "ENLQOPHACHGINPKT",	0x01, 0x01 },
+	{ "ENLQOBUSFREE",	0x02, 0x02 },
+	{ "ENLQOBADQAS",	0x04, 0x04 },
+	{ "ENLQOSTOPI2",	0x08, 0x08 },
+	{ "ENLQOINITSCBPERR",	0x10, 0x10 }
+};
+
+int
+ahd_lqomode1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(LQOMODE1_parse_table, 5, "LQOMODE1",
+	    0x55, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t LQOSTAT2_parse_table[] = {
+	{ "LQOSTOP0",		0x01, 0x01 },
+	{ "LQOPHACHGOUTPKT",	0x02, 0x02 },
+	{ "LQOWAITFIFO",	0x10, 0x10 },
+	{ "LQOPKT",		0xe0, 0xe0 }
+};
+
+int
+ahd_lqostat2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(LQOSTAT2_parse_table, 4, "LQOSTAT2",
+	    0x56, regvalue, cur_col, wrap));
+}
+
+int
+ahd_os_space_cnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "OS_SPACE_CNT",
+	    0x56, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SIMODE1_parse_table[] = {
+	{ "ENREQINIT",		0x01, 0x01 },
+	{ "ENSTRB2FAST",	0x02, 0x02 },
+	{ "ENSCSIPERR",		0x04, 0x04 },
+	{ "ENBUSFREE",		0x08, 0x08 },
+	{ "ENPHASEMIS",		0x10, 0x10 },
+	{ "ENSCSIRST",		0x20, 0x20 },
+	{ "ENATNTARG",		0x40, 0x40 },
+	{ "ENSELTIMO",		0x80, 0x80 }
+};
+
+int
+ahd_simode1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SIMODE1_parse_table, 8, "SIMODE1",
+	    0x57, regvalue, cur_col, wrap));
+}
+
+int
+ahd_gsfifo_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "GSFIFO",
+	    0x58, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DFFSXFRCTL_parse_table[] = {
+	{ "RSTCHN",		0x01, 0x01 },
+	{ "CLRCHN",		0x02, 0x02 },
+	{ "CLRSHCNT",		0x04, 0x04 },
+	{ "DFFBITBUCKET",	0x08, 0x08 }
+};
+
+int
+ahd_dffsxfrctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DFFSXFRCTL_parse_table, 4, "DFFSXFRCTL",
+	    0x5a, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t LQOSCSCTL_parse_table[] = {
+	{ "LQONOCHKOVER",	0x01, 0x01 },
+	{ "LQOH2A_VERSION",	0x80, 0x80 }
+};
+
+int
+ahd_lqoscsctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(LQOSCSCTL_parse_table, 2, "LQOSCSCTL",
+	    0x5a, regvalue, cur_col, wrap));
+}
+
+int
+ahd_nextscb_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "NEXTSCB",
+	    0x5a, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CLRSEQINTSRC_parse_table[] = {
+	{ "CLRCFG4TCMD",	0x01, 0x01 },
+	{ "CLRCFG4ICMD",	0x02, 0x02 },
+	{ "CLRCFG4TSTAT",	0x04, 0x04 },
+	{ "CLRCFG4ISTAT",	0x08, 0x08 },
+	{ "CLRCFG4DATA",	0x10, 0x10 },
+	{ "CLRSAVEPTRS",	0x20, 0x20 },
+	{ "CLRCTXTDONE",	0x40, 0x40 }
+};
+
+int
+ahd_clrseqintsrc_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CLRSEQINTSRC_parse_table, 7, "CLRSEQINTSRC",
+	    0x5b, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SEQINTSRC_parse_table[] = {
+	{ "CFG4TCMD",		0x01, 0x01 },
+	{ "CFG4ICMD",		0x02, 0x02 },
+	{ "CFG4TSTAT",		0x04, 0x04 },
+	{ "CFG4ISTAT",		0x08, 0x08 },
+	{ "CFG4DATA",		0x10, 0x10 },
+	{ "SAVEPTRS",		0x20, 0x20 },
+	{ "CTXTDONE",		0x40, 0x40 }
+};
+
+int
+ahd_seqintsrc_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SEQINTSRC_parse_table, 7, "SEQINTSRC",
+	    0x5b, regvalue, cur_col, wrap));
+}
+
+int
+ahd_currscb_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "CURRSCB",
+	    0x5c, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SEQIMODE_parse_table[] = {
+	{ "ENCFG4TCMD",		0x01, 0x01 },
+	{ "ENCFG4ICMD",		0x02, 0x02 },
+	{ "ENCFG4TSTAT",	0x04, 0x04 },
+	{ "ENCFG4ISTAT",	0x08, 0x08 },
+	{ "ENCFG4DATA",		0x10, 0x10 },
+	{ "ENSAVEPTRS",		0x20, 0x20 },
+	{ "ENCTXTDONE",		0x40, 0x40 }
+};
+
+int
+ahd_seqimode_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SEQIMODE_parse_table, 7, "SEQIMODE",
+	    0x5c, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t MDFFSTAT_parse_table[] = {
+	{ "FIFOFREE",		0x01, 0x01 },
+	{ "DATAINFIFO",		0x02, 0x02 },
+	{ "DLZERO",		0x04, 0x04 },
+	{ "SHVALID",		0x08, 0x08 },
+	{ "LASTSDONE",		0x10, 0x10 },
+	{ "SHCNTMINUS1",	0x20, 0x20 },
+	{ "SHCNTNEGATIVE",	0x40, 0x40 }
+};
+
+int
+ahd_mdffstat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(MDFFSTAT_parse_table, 7, "MDFFSTAT",
+	    0x5d, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CRCCONTROL_parse_table[] = {
+	{ "CRCVALCHKEN",	0x40, 0x40 }
+};
+
+int
+ahd_crccontrol_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CRCCONTROL_parse_table, 1, "CRCCONTROL",
+	    0x5d, regvalue, cur_col, wrap));
+}
+
+int
+ahd_dfftag_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "DFFTAG",
+	    0x5e, regvalue, cur_col, wrap));
+}
+
+int
+ahd_lastscb_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "LASTSCB",
+	    0x5e, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SCSITEST_parse_table[] = {
+	{ "SEL_TXPLL_DEBUG",	0x04, 0x04 },
+	{ "CNTRTEST",		0x08, 0x08 }
+};
+
+int
+ahd_scsitest_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SCSITEST_parse_table, 2, "SCSITEST",
+	    0x5e, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t IOPDNCTL_parse_table[] = {
+	{ "PDN_DIFFSENSE",	0x01, 0x01 },
+	{ "PDN_IDIST",		0x04, 0x04 },
+	{ "DISABLE_OE",		0x80, 0x80 }
+};
+
+int
+ahd_iopdnctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(IOPDNCTL_parse_table, 3, "IOPDNCTL",
+	    0x5f, regvalue, cur_col, wrap));
+}
+
+int
+ahd_shaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SHADDR",
+	    0x60, regvalue, cur_col, wrap));
+}
+
+int
+ahd_negoaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "NEGOADDR",
+	    0x60, regvalue, cur_col, wrap));
+}
+
+int
+ahd_dgrpcrci_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "DGRPCRCI",
+	    0x60, regvalue, cur_col, wrap));
+}
+
+int
+ahd_negperiod_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "NEGPERIOD",
+	    0x61, regvalue, cur_col, wrap));
+}
+
+int
+ahd_packcrci_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "PACKCRCI",
+	    0x62, regvalue, cur_col, wrap));
+}
+
+int
+ahd_negoffset_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "NEGOFFSET",
+	    0x62, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t NEGPPROPTS_parse_table[] = {
+	{ "PPROPT_IUT",		0x01, 0x01 },
+	{ "PPROPT_DT",		0x02, 0x02 },
+	{ "PPROPT_QAS",		0x04, 0x04 },
+	{ "PPROPT_PACE",	0x08, 0x08 }
+};
+
+int
+ahd_negppropts_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NEGPPROPTS_parse_table, 4, "NEGPPROPTS",
+	    0x63, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t NEGCONOPTS_parse_table[] = {
+	{ "WIDEXFER",		0x01, 0x01 },
+	{ "ENAUTOATNO",		0x02, 0x02 },
+	{ "ENAUTOATNI",		0x04, 0x04 },
+	{ "ENSLOWCRC",		0x08, 0x08 },
+	{ "RTI_OVRDTRN",	0x10, 0x10 },
+	{ "RTI_WRTDIS",		0x20, 0x20 },
+	{ "ENSNAPSHOT",		0x40, 0x40 }
+};
+
+int
+ahd_negconopts_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NEGCONOPTS_parse_table, 7, "NEGCONOPTS",
+	    0x64, regvalue, cur_col, wrap));
+}
+
+int
+ahd_annexcol_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "ANNEXCOL",
+	    0x65, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SCSCHKN_parse_table[] = {
+	{ "LSTSGCLRDIS",	0x01, 0x01 },
+	{ "SHVALIDSTDIS",	0x02, 0x02 },
+	{ "DFFACTCLR",		0x04, 0x04 },
+	{ "SDONEMSKDIS",	0x08, 0x08 },
+	{ "WIDERESEN",		0x10, 0x10 },
+	{ "CURRFIFODEF",	0x20, 0x20 },
+	{ "STSELSKIDDIS",	0x40, 0x40 }
+};
+
+int
+ahd_scschkn_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SCSCHKN_parse_table, 7, "SCSCHKN",
+	    0x66, regvalue, cur_col, wrap));
+}
+
+int
+ahd_annexdat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "ANNEXDAT",
+	    0x66, regvalue, cur_col, wrap));
+}
+
+int
+ahd_iownid_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "IOWNID",
+	    0x67, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t PLL960CTL0_parse_table[] = {
+	{ "PLL_ENFBM",		0x01, 0x01 },
+	{ "PLL_DLPF",		0x02, 0x02 },
+	{ "PLL_ENLPF",		0x04, 0x04 },
+	{ "PLL_ENLUD",		0x08, 0x08 },
+	{ "PLL_NS",		0x30, 0x30 },
+	{ "PLL_PWDN",		0x40, 0x40 },
+	{ "PLL_VCOSEL",		0x80, 0x80 }
+};
+
+int
+ahd_pll960ctl0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(PLL960CTL0_parse_table, 7, "PLL960CTL0",
+	    0x68, regvalue, cur_col, wrap));
+}
+
+int
+ahd_shcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SHCNT",
+	    0x68, regvalue, cur_col, wrap));
+}
+
+int
+ahd_townid_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "TOWNID",
+	    0x69, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t PLL960CTL1_parse_table[] = {
+	{ "PLL_RST",		0x01, 0x01 },
+	{ "PLL_CNTCLR",		0x40, 0x40 },
+	{ "PLL_CNTEN",		0x80, 0x80 }
+};
+
+int
+ahd_pll960ctl1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(PLL960CTL1_parse_table, 3, "PLL960CTL1",
+	    0x69, regvalue, cur_col, wrap));
+}
+
+int
+ahd_pll960cnt0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "PLL960CNT0",
+	    0x6a, regvalue, cur_col, wrap));
+}
+
+int
+ahd_xsig_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "XSIG",
+	    0x6a, regvalue, cur_col, wrap));
+}
+
+int
+ahd_seloid_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SELOID",
+	    0x6b, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t PLL400CTL0_parse_table[] = {
+	{ "PLL_ENFBM",		0x01, 0x01 },
+	{ "PLL_DLPF",		0x02, 0x02 },
+	{ "PLL_ENLPF",		0x04, 0x04 },
+	{ "PLL_ENLUD",		0x08, 0x08 },
+	{ "PLL_NS",		0x30, 0x30 },
+	{ "PLL_PWDN",		0x40, 0x40 },
+	{ "PLL_VCOSEL",		0x80, 0x80 }
+};
+
+int
+ahd_pll400ctl0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(PLL400CTL0_parse_table, 7, "PLL400CTL0",
+	    0x6c, regvalue, cur_col, wrap));
+}
+
+int
+ahd_fairness_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "FAIRNESS",
+	    0x6c, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t PLL400CTL1_parse_table[] = {
+	{ "PLL_RST",		0x01, 0x01 },
+	{ "PLL_CNTCLR",		0x40, 0x40 },
+	{ "PLL_CNTEN",		0x80, 0x80 }
+};
+
+int
+ahd_pll400ctl1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(PLL400CTL1_parse_table, 3, "PLL400CTL1",
+	    0x6d, regvalue, cur_col, wrap));
+}
+
+int
+ahd_pll400cnt0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "PLL400CNT0",
+	    0x6e, regvalue, cur_col, wrap));
+}
+
+int
+ahd_unfairness_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "UNFAIRNESS",
+	    0x6e, regvalue, cur_col, wrap));
+}
+
+int
+ahd_haddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "HADDR",
+	    0x70, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t PLLDELAY_parse_table[] = {
+	{ "SPLIT_DROP_REQ",	0x80, 0x80 }
+};
+
+int
+ahd_plldelay_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(PLLDELAY_parse_table, 1, "PLLDELAY",
+	    0x70, regvalue, cur_col, wrap));
+}
+
+int
+ahd_hodmaadr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "HODMAADR",
+	    0x70, regvalue, cur_col, wrap));
+}
+
+int
+ahd_hodmacnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "HODMACNT",
+	    0x78, regvalue, cur_col, wrap));
+}
+
+int
+ahd_hcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "HCNT",
+	    0x78, regvalue, cur_col, wrap));
+}
+
+int
+ahd_hodmaen_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "HODMAEN",
+	    0x7a, regvalue, cur_col, wrap));
+}
+
+int
+ahd_sghaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SGHADDR",
+	    0x7c, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scbhaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCBHADDR",
+	    0x7c, regvalue, cur_col, wrap));
+}
+
+int
+ahd_sghcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SGHCNT",
+	    0x84, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scbhcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCBHCNT",
+	    0x84, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DFF_THRSH_parse_table[] = {
+	{ "WR_DFTHRSH_MIN",	0x00, 0x70 },
+	{ "RD_DFTHRSH_MIN",	0x00, 0x07 },
+	{ "RD_DFTHRSH_25",	0x01, 0x07 },
+	{ "RD_DFTHRSH_50",	0x02, 0x07 },
+	{ "RD_DFTHRSH_63",	0x03, 0x07 },
+	{ "RD_DFTHRSH_75",	0x04, 0x07 },
+	{ "RD_DFTHRSH_85",	0x05, 0x07 },
+	{ "RD_DFTHRSH_90",	0x06, 0x07 },
+	{ "RD_DFTHRSH_MAX",	0x07, 0x07 },
+	{ "WR_DFTHRSH_25",	0x10, 0x70 },
+	{ "WR_DFTHRSH_50",	0x20, 0x70 },
+	{ "WR_DFTHRSH_63",	0x30, 0x70 },
+	{ "WR_DFTHRSH_75",	0x40, 0x70 },
+	{ "WR_DFTHRSH_85",	0x50, 0x70 },
+	{ "WR_DFTHRSH_90",	0x60, 0x70 },
+	{ "WR_DFTHRSH_MAX",	0x70, 0x70 },
+	{ "RD_DFTHRSH",		0x07, 0x07 },
+	{ "WR_DFTHRSH",		0x70, 0x70 }
+};
+
+int
+ahd_dff_thrsh_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DFF_THRSH_parse_table, 18, "DFF_THRSH",
+	    0x88, regvalue, cur_col, wrap));
+}
+
+int
+ahd_romaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "ROMADDR",
+	    0x8a, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t ROMCNTRL_parse_table[] = {
+	{ "RDY",		0x01, 0x01 },
+	{ "REPEAT",		0x02, 0x02 },
+	{ "ROMSPD",		0x18, 0x18 },
+	{ "ROMOP",		0xe0, 0xe0 }
+};
+
+int
+ahd_romcntrl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(ROMCNTRL_parse_table, 4, "ROMCNTRL",
+	    0x8d, regvalue, cur_col, wrap));
+}
+
+int
+ahd_romdata_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "ROMDATA",
+	    0x8e, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CMCRXMSG0_parse_table[] = {
+	{ "CFNUM",		0x07, 0x07 },
+	{ "CDNUM",		0xf8, 0xf8 }
+};
+
+int
+ahd_cmcrxmsg0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CMCRXMSG0_parse_table, 2, "CMCRXMSG0",
+	    0x90, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t ROENABLE_parse_table[] = {
+	{ "DCH0ROEN",		0x01, 0x01 },
+	{ "DCH1ROEN",		0x02, 0x02 },
+	{ "SGROEN",		0x04, 0x04 },
+	{ "CMCROEN",		0x08, 0x08 },
+	{ "OVLYROEN",		0x10, 0x10 },
+	{ "MSIROEN",		0x20, 0x20 }
+};
+
+int
+ahd_roenable_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(ROENABLE_parse_table, 6, "ROENABLE",
+	    0x90, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t OVLYRXMSG0_parse_table[] = {
+	{ "CFNUM",		0x07, 0x07 },
+	{ "CDNUM",		0xf8, 0xf8 }
+};
+
+int
+ahd_ovlyrxmsg0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(OVLYRXMSG0_parse_table, 2, "OVLYRXMSG0",
+	    0x90, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DCHRXMSG0_parse_table[] = {
+	{ "CFNUM",		0x07, 0x07 },
+	{ "CDNUM",		0xf8, 0xf8 }
+};
+
+int
+ahd_dchrxmsg0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DCHRXMSG0_parse_table, 2, "DCHRXMSG0",
+	    0x90, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t OVLYRXMSG1_parse_table[] = {
+	{ "CBNUM",		0xff, 0xff }
+};
+
+int
+ahd_ovlyrxmsg1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(OVLYRXMSG1_parse_table, 1, "OVLYRXMSG1",
+	    0x91, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t NSENABLE_parse_table[] = {
+	{ "DCH0NSEN",		0x01, 0x01 },
+	{ "DCH1NSEN",		0x02, 0x02 },
+	{ "SGNSEN",		0x04, 0x04 },
+	{ "CMCNSEN",		0x08, 0x08 },
+	{ "OVLYNSEN",		0x10, 0x10 },
+	{ "MSINSEN",		0x20, 0x20 }
+};
+
+int
+ahd_nsenable_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NSENABLE_parse_table, 6, "NSENABLE",
+	    0x91, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DCHRXMSG1_parse_table[] = {
+	{ "CBNUM",		0xff, 0xff }
+};
+
+int
+ahd_dchrxmsg1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DCHRXMSG1_parse_table, 1, "DCHRXMSG1",
+	    0x91, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CMCRXMSG1_parse_table[] = {
+	{ "CBNUM",		0xff, 0xff }
+};
+
+int
+ahd_cmcrxmsg1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CMCRXMSG1_parse_table, 1, "CMCRXMSG1",
+	    0x91, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DCHRXMSG2_parse_table[] = {
+	{ "MINDEX",		0xff, 0xff }
+};
+
+int
+ahd_dchrxmsg2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DCHRXMSG2_parse_table, 1, "DCHRXMSG2",
+	    0x92, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t OVLYRXMSG2_parse_table[] = {
+	{ "MINDEX",		0xff, 0xff }
+};
+
+int
+ahd_ovlyrxmsg2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(OVLYRXMSG2_parse_table, 1, "OVLYRXMSG2",
+	    0x92, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CMCRXMSG2_parse_table[] = {
+	{ "MINDEX",		0xff, 0xff }
+};
+
+int
+ahd_cmcrxmsg2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CMCRXMSG2_parse_table, 1, "CMCRXMSG2",
+	    0x92, regvalue, cur_col, wrap));
+}
+
+int
+ahd_ost_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "OST",
+	    0x92, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DCHRXMSG3_parse_table[] = {
+	{ "MCLASS",		0x0f, 0x0f }
+};
+
+int
+ahd_dchrxmsg3_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DCHRXMSG3_parse_table, 1, "DCHRXMSG3",
+	    0x93, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CMCRXMSG3_parse_table[] = {
+	{ "MCLASS",		0x0f, 0x0f }
+};
+
+int
+ahd_cmcrxmsg3_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CMCRXMSG3_parse_table, 1, "CMCRXMSG3",
+	    0x93, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t PCIXCTL_parse_table[] = {
+	{ "CMPABCDIS",		0x01, 0x01 },
+	{ "TSCSERREN",		0x02, 0x02 },
+	{ "SRSPDPEEN",		0x04, 0x04 },
+	{ "SPLTSTADIS",		0x08, 0x08 },
+	{ "SPLTSMADIS",		0x10, 0x10 },
+	{ "UNEXPSCIEN",		0x20, 0x20 },
+	{ "SERRPULSE",		0x80, 0x80 }
+};
+
+int
+ahd_pcixctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(PCIXCTL_parse_table, 7, "PCIXCTL",
+	    0x93, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t OVLYRXMSG3_parse_table[] = {
+	{ "MCLASS",		0x0f, 0x0f }
+};
+
+int
+ahd_ovlyrxmsg3_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(OVLYRXMSG3_parse_table, 1, "OVLYRXMSG3",
+	    0x93, regvalue, cur_col, wrap));
+}
+
+int
+ahd_ovlyseqbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "OVLYSEQBCNT",
+	    0x94, regvalue, cur_col, wrap));
+}
+
+int
+ahd_cmcseqbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "CMCSEQBCNT",
+	    0x94, regvalue, cur_col, wrap));
+}
+
+int
+ahd_dchseqbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "DCHSEQBCNT",
+	    0x94, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CMCSPLTSTAT0_parse_table[] = {
+	{ "RXSPLTRSP",		0x01, 0x01 },
+	{ "RXSCEMSG",		0x02, 0x02 },
+	{ "RXOVRUN",		0x04, 0x04 },
+	{ "CNTNOTCMPLT",	0x08, 0x08 },
+	{ "SCDATBUCKET",	0x10, 0x10 },
+	{ "SCADERR",		0x20, 0x20 },
+	{ "SCBCERR",		0x40, 0x40 },
+	{ "STAETERM",		0x80, 0x80 }
+};
+
+int
+ahd_cmcspltstat0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CMCSPLTSTAT0_parse_table, 8, "CMCSPLTSTAT0",
+	    0x96, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t OVLYSPLTSTAT0_parse_table[] = {
+	{ "RXSPLTRSP",		0x01, 0x01 },
+	{ "RXSCEMSG",		0x02, 0x02 },
+	{ "RXOVRUN",		0x04, 0x04 },
+	{ "CNTNOTCMPLT",	0x08, 0x08 },
+	{ "SCDATBUCKET",	0x10, 0x10 },
+	{ "SCADERR",		0x20, 0x20 },
+	{ "SCBCERR",		0x40, 0x40 },
+	{ "STAETERM",		0x80, 0x80 }
+};
+
+int
+ahd_ovlyspltstat0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(OVLYSPLTSTAT0_parse_table, 8, "OVLYSPLTSTAT0",
+	    0x96, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DCHSPLTSTAT0_parse_table[] = {
+	{ "RXSPLTRSP",		0x01, 0x01 },
+	{ "RXSCEMSG",		0x02, 0x02 },
+	{ "RXOVRUN",		0x04, 0x04 },
+	{ "CNTNOTCMPLT",	0x08, 0x08 },
+	{ "SCDATBUCKET",	0x10, 0x10 },
+	{ "SCADERR",		0x20, 0x20 },
+	{ "SCBCERR",		0x40, 0x40 },
+	{ "STAETERM",		0x80, 0x80 }
+};
+
+int
+ahd_dchspltstat0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DCHSPLTSTAT0_parse_table, 8, "DCHSPLTSTAT0",
+	    0x96, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DCHSPLTSTAT1_parse_table[] = {
+	{ "RXDATABUCKET",	0x01, 0x01 }
+};
+
+int
+ahd_dchspltstat1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DCHSPLTSTAT1_parse_table, 1, "DCHSPLTSTAT1",
+	    0x97, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CMCSPLTSTAT1_parse_table[] = {
+	{ "RXDATABUCKET",	0x01, 0x01 }
+};
+
+int
+ahd_cmcspltstat1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CMCSPLTSTAT1_parse_table, 1, "CMCSPLTSTAT1",
+	    0x97, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t OVLYSPLTSTAT1_parse_table[] = {
+	{ "RXDATABUCKET",	0x01, 0x01 }
+};
+
+int
+ahd_ovlyspltstat1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(OVLYSPLTSTAT1_parse_table, 1, "OVLYSPLTSTAT1",
+	    0x97, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SGRXMSG0_parse_table[] = {
+	{ "CFNUM",		0x07, 0x07 },
+	{ "CDNUM",		0xf8, 0xf8 }
+};
+
+int
+ahd_sgrxmsg0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SGRXMSG0_parse_table, 2, "SGRXMSG0",
+	    0x98, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SLVSPLTOUTADR0_parse_table[] = {
+	{ "LOWER_ADDR",		0x7f, 0x7f }
+};
+
+int
+ahd_slvspltoutadr0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SLVSPLTOUTADR0_parse_table, 1, "SLVSPLTOUTADR0",
+	    0x98, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SGRXMSG1_parse_table[] = {
+	{ "CBNUM",		0xff, 0xff }
+};
+
+int
+ahd_sgrxmsg1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SGRXMSG1_parse_table, 1, "SGRXMSG1",
+	    0x99, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SLVSPLTOUTADR1_parse_table[] = {
+	{ "REQ_FNUM",		0x07, 0x07 },
+	{ "REQ_DNUM",		0xf8, 0xf8 }
+};
+
+int
+ahd_slvspltoutadr1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SLVSPLTOUTADR1_parse_table, 2, "SLVSPLTOUTADR1",
+	    0x99, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SGRXMSG2_parse_table[] = {
+	{ "MINDEX",		0xff, 0xff }
+};
+
+int
+ahd_sgrxmsg2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SGRXMSG2_parse_table, 1, "SGRXMSG2",
+	    0x9a, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SLVSPLTOUTADR2_parse_table[] = {
+	{ "REQ_BNUM",		0xff, 0xff }
+};
+
+int
+ahd_slvspltoutadr2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SLVSPLTOUTADR2_parse_table, 1, "SLVSPLTOUTADR2",
+	    0x9a, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SGRXMSG3_parse_table[] = {
+	{ "MCLASS",		0x0f, 0x0f }
+};
+
+int
+ahd_sgrxmsg3_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SGRXMSG3_parse_table, 1, "SGRXMSG3",
+	    0x9b, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SLVSPLTOUTADR3_parse_table[] = {
+	{ "RLXORD",		0x10, 0x10 },
+	{ "TAG_NUM",		0x1f, 0x1f }
+};
+
+int
+ahd_slvspltoutadr3_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SLVSPLTOUTADR3_parse_table, 2, "SLVSPLTOUTADR3",
+	    0x9b, regvalue, cur_col, wrap));
+}
+
+int
+ahd_sgseqbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SGSEQBCNT",
+	    0x9c, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SLVSPLTOUTATTR0_parse_table[] = {
+	{ "LOWER_BCNT",		0xff, 0xff }
+};
+
+int
+ahd_slvspltoutattr0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SLVSPLTOUTATTR0_parse_table, 1, "SLVSPLTOUTATTR0",
+	    0x9c, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SLVSPLTOUTATTR1_parse_table[] = {
+	{ "CMPLT_FNUM",		0x07, 0x07 },
+	{ "CMPLT_DNUM",		0xf8, 0xf8 }
+};
+
+int
+ahd_slvspltoutattr1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SLVSPLTOUTATTR1_parse_table, 2, "SLVSPLTOUTATTR1",
+	    0x9d, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SLVSPLTOUTATTR2_parse_table[] = {
+	{ "CMPLT_BNUM",		0xff, 0xff }
+};
+
+int
+ahd_slvspltoutattr2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SLVSPLTOUTATTR2_parse_table, 1, "SLVSPLTOUTATTR2",
+	    0x9e, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SGSPLTSTAT0_parse_table[] = {
+	{ "RXSPLTRSP",		0x01, 0x01 },
+	{ "RXSCEMSG",		0x02, 0x02 },
+	{ "RXOVRUN",		0x04, 0x04 },
+	{ "CNTNOTCMPLT",	0x08, 0x08 },
+	{ "SCDATBUCKET",	0x10, 0x10 },
+	{ "SCADERR",		0x20, 0x20 },
+	{ "SCBCERR",		0x40, 0x40 },
+	{ "STAETERM",		0x80, 0x80 }
+};
+
+int
+ahd_sgspltstat0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SGSPLTSTAT0_parse_table, 8, "SGSPLTSTAT0",
+	    0x9e, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SFUNCT_parse_table[] = {
+	{ "TEST_NUM",		0x0f, 0x0f },
+	{ "TEST_GROUP",		0xf0, 0xf0 }
+};
+
+int
+ahd_sfunct_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SFUNCT_parse_table, 2, "SFUNCT",
+	    0x9f, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SGSPLTSTAT1_parse_table[] = {
+	{ "RXDATABUCKET",	0x01, 0x01 }
+};
+
+int
+ahd_sgspltstat1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SGSPLTSTAT1_parse_table, 1, "SGSPLTSTAT1",
+	    0x9f, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DF0PCISTAT_parse_table[] = {
+	{ "DPR",		0x01, 0x01 },
+	{ "TWATERR",		0x02, 0x02 },
+	{ "RDPERR",		0x04, 0x04 },
+	{ "SCAAPERR",		0x08, 0x08 },
+	{ "RTA",		0x10, 0x10 },
+	{ "RMA",		0x20, 0x20 },
+	{ "SSE",		0x40, 0x40 },
+	{ "DPE",		0x80, 0x80 }
+};
+
+int
+ahd_df0pcistat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DF0PCISTAT_parse_table, 8, "DF0PCISTAT",
+	    0xa0, regvalue, cur_col, wrap));
+}
+
+int
+ahd_reg0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "REG0",
+	    0xa0, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DF1PCISTAT_parse_table[] = {
+	{ "DPR",		0x01, 0x01 },
+	{ "TWATERR",		0x02, 0x02 },
+	{ "RDPERR",		0x04, 0x04 },
+	{ "SCAAPERR",		0x08, 0x08 },
+	{ "RTA",		0x10, 0x10 },
+	{ "RMA",		0x20, 0x20 },
+	{ "SSE",		0x40, 0x40 },
+	{ "DPE",		0x80, 0x80 }
+};
+
+int
+ahd_df1pcistat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DF1PCISTAT_parse_table, 8, "DF1PCISTAT",
+	    0xa1, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SGPCISTAT_parse_table[] = {
+	{ "DPR",		0x01, 0x01 },
+	{ "RDPERR",		0x04, 0x04 },
+	{ "SCAAPERR",		0x08, 0x08 },
+	{ "RTA",		0x10, 0x10 },
+	{ "RMA",		0x20, 0x20 },
+	{ "SSE",		0x40, 0x40 },
+	{ "DPE",		0x80, 0x80 }
+};
+
+int
+ahd_sgpcistat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SGPCISTAT_parse_table, 7, "SGPCISTAT",
+	    0xa2, regvalue, cur_col, wrap));
+}
+
+int
+ahd_reg1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "REG1",
+	    0xa2, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CMCPCISTAT_parse_table[] = {
+	{ "DPR",		0x01, 0x01 },
+	{ "TWATERR",		0x02, 0x02 },
+	{ "RDPERR",		0x04, 0x04 },
+	{ "SCAAPERR",		0x08, 0x08 },
+	{ "RTA",		0x10, 0x10 },
+	{ "RMA",		0x20, 0x20 },
+	{ "SSE",		0x40, 0x40 },
+	{ "DPE",		0x80, 0x80 }
+};
+
+int
+ahd_cmcpcistat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CMCPCISTAT_parse_table, 8, "CMCPCISTAT",
+	    0xa3, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t OVLYPCISTAT_parse_table[] = {
+	{ "DPR",		0x01, 0x01 },
+	{ "RDPERR",		0x04, 0x04 },
+	{ "SCAAPERR",		0x08, 0x08 },
+	{ "RTA",		0x10, 0x10 },
+	{ "RMA",		0x20, 0x20 },
+	{ "SSE",		0x40, 0x40 },
+	{ "DPE",		0x80, 0x80 }
+};
+
+int
+ahd_ovlypcistat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(OVLYPCISTAT_parse_table, 7, "OVLYPCISTAT",
+	    0xa4, regvalue, cur_col, wrap));
+}
+
+int
+ahd_reg_isr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "REG_ISR",
+	    0xa4, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SG_STATE_parse_table[] = {
+	{ "SEGS_AVAIL",		0x01, 0x01 },
+	{ "LOADING_NEEDED",	0x02, 0x02 },
+	{ "FETCH_INPROG",	0x04, 0x04 }
+};
+
+int
+ahd_sg_state_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SG_STATE_parse_table, 3, "SG_STATE",
+	    0xa6, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t MSIPCISTAT_parse_table[] = {
+	{ "DPR",		0x01, 0x01 },
+	{ "TWATERR",		0x02, 0x02 },
+	{ "CLRPENDMSI",		0x08, 0x08 },
+	{ "RTA",		0x10, 0x10 },
+	{ "RMA",		0x20, 0x20 },
+	{ "SSE",		0x40, 0x40 }
+};
+
+int
+ahd_msipcistat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(MSIPCISTAT_parse_table, 6, "MSIPCISTAT",
+	    0xa6, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t TARGPCISTAT_parse_table[] = {
+	{ "TWATERR",		0x02, 0x02 },
+	{ "STA",		0x08, 0x08 },
+	{ "SSE",		0x40, 0x40 },
+	{ "DPE",		0x80, 0x80 }
+};
+
+int
+ahd_targpcistat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(TARGPCISTAT_parse_table, 4, "TARGPCISTAT",
+	    0xa7, regvalue, cur_col, wrap));
+}
+
+int
+ahd_data_count_odd_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "DATA_COUNT_ODD",
+	    0xa7, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scbptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCBPTR",
+	    0xa8, regvalue, cur_col, wrap));
+}
+
+int
+ahd_ccscbacnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "CCSCBACNT",
+	    0xab, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SCBAUTOPTR_parse_table[] = {
+	{ "SCBPTR_OFF",		0x07, 0x07 },
+	{ "SCBPTR_ADDR",	0x38, 0x38 },
+	{ "AUSCBPTR_EN",	0x80, 0x80 }
+};
+
+int
+ahd_scbautoptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SCBAUTOPTR_parse_table, 3, "SCBAUTOPTR",
+	    0xab, regvalue, cur_col, wrap));
+}
+
+int
+ahd_ccsgaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "CCSGADDR",
+	    0xac, regvalue, cur_col, wrap));
+}
+
+int
+ahd_ccscbaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "CCSCBADDR",
+	    0xac, regvalue, cur_col, wrap));
+}
+
+int
+ahd_ccscbadr_bk_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "CCSCBADR_BK",
+	    0xac, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CMC_RAMBIST_parse_table[] = {
+	{ "CMC_BUFFER_BIST_EN",	0x01, 0x01 },
+	{ "CMC_BUFFER_BIST_FAIL",0x02, 0x02 },
+	{ "SG_BIST_EN",		0x10, 0x10 },
+	{ "SG_BIST_FAIL",	0x20, 0x20 },
+	{ "SCBRAMBIST_FAIL",	0x40, 0x40 },
+	{ "SG_ELEMENT_SIZE",	0x80, 0x80 }
+};
+
+int
+ahd_cmc_rambist_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CMC_RAMBIST_parse_table, 6, "CMC_RAMBIST",
+	    0xad, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CCSGCTL_parse_table[] = {
+	{ "CCSGRESET",		0x01, 0x01 },
+	{ "SG_FETCH_REQ",	0x02, 0x02 },
+	{ "CCSGENACK",		0x08, 0x08 },
+	{ "SG_CACHE_AVAIL",	0x10, 0x10 },
+	{ "CCSGDONE",		0x80, 0x80 },
+	{ "CCSGEN",		0x0c, 0x0c }
+};
+
+int
+ahd_ccsgctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CCSGCTL_parse_table, 6, "CCSGCTL",
+	    0xad, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t CCSCBCTL_parse_table[] = {
+	{ "CCSCBRESET",		0x01, 0x01 },
+	{ "CCSCBDIR",		0x04, 0x04 },
+	{ "CCSCBEN",		0x08, 0x08 },
+	{ "CCARREN",		0x10, 0x10 },
+	{ "ARRDONE",		0x40, 0x40 },
+	{ "CCSCBDONE",		0x80, 0x80 }
+};
+
+int
+ahd_ccscbctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(CCSCBCTL_parse_table, 6, "CCSCBCTL",
+	    0xad, regvalue, cur_col, wrap));
+}
+
+int
+ahd_ccsgram_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "CCSGRAM",
+	    0xb0, regvalue, cur_col, wrap));
+}
+
+int
+ahd_flexadr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "FLEXADR",
+	    0xb0, regvalue, cur_col, wrap));
+}
+
+int
+ahd_ccscbram_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "CCSCBRAM",
+	    0xb0, regvalue, cur_col, wrap));
+}
+
+int
+ahd_flexcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "FLEXCNT",
+	    0xb3, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t FLEXDMASTAT_parse_table[] = {
+	{ "FLEXDMADONE",	0x01, 0x01 },
+	{ "FLEXDMAERR",		0x02, 0x02 }
+};
+
+int
+ahd_flexdmastat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(FLEXDMASTAT_parse_table, 2, "FLEXDMASTAT",
+	    0xb5, regvalue, cur_col, wrap));
+}
+
+int
+ahd_flexdata_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "FLEXDATA",
+	    0xb6, regvalue, cur_col, wrap));
+}
+
+int
+ahd_brddat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "BRDDAT",
+	    0xb8, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t BRDCTL_parse_table[] = {
+	{ "BRDSTB",		0x01, 0x01 },
+	{ "BRDRW",		0x02, 0x02 },
+	{ "BRDEN",		0x04, 0x04 },
+	{ "BRDADDR",		0x38, 0x38 },
+	{ "FLXARBREQ",		0x40, 0x40 },
+	{ "FLXARBACK",		0x80, 0x80 }
+};
+
+int
+ahd_brdctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(BRDCTL_parse_table, 6, "BRDCTL",
+	    0xb9, regvalue, cur_col, wrap));
+}
+
+int
+ahd_seeadr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SEEADR",
+	    0xba, regvalue, cur_col, wrap));
+}
+
+int
+ahd_seedat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SEEDAT",
+	    0xbc, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SEECTL_parse_table[] = {
+	{ "SEEOP_ERAL",		0x40, 0x70 },
+	{ "SEEOP_WRITE",	0x50, 0x70 },
+	{ "SEEOP_READ",		0x60, 0x70 },
+	{ "SEEOP_ERASE",	0x70, 0x70 },
+	{ "SEESTART",		0x01, 0x01 },
+	{ "SEERST",		0x02, 0x02 },
+	{ "SEEOPCODE",		0x70, 0x70 },
+	{ "SEEOP_EWEN",		0x40, 0x40 },
+	{ "SEEOP_WALL",		0x40, 0x40 },
+	{ "SEEOP_EWDS",		0x40, 0x40 }
+};
+
+int
+ahd_seectl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SEECTL_parse_table, 10, "SEECTL",
+	    0xbe, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SEESTAT_parse_table[] = {
+	{ "SEESTART",		0x01, 0x01 },
+	{ "SEEBUSY",		0x02, 0x02 },
+	{ "SEEARBACK",		0x04, 0x04 },
+	{ "LDALTID_L",		0x08, 0x08 },
+	{ "SEEOPCODE",		0x70, 0x70 },
+	{ "INIT_DONE",		0x80, 0x80 }
+};
+
+int
+ahd_seestat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SEESTAT_parse_table, 6, "SEESTAT",
+	    0xbe, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCBCNT",
+	    0xbf, regvalue, cur_col, wrap));
+}
+
+int
+ahd_dfwaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "DFWADDR",
+	    0xc0, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DSPFLTRCTL_parse_table[] = {
+	{ "DSPFCNTSEL",		0x0f, 0x0f },
+	{ "EDGESENSE",		0x10, 0x10 },
+	{ "FLTRDISABLE",	0x20, 0x20 }
+};
+
+int
+ahd_dspfltrctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DSPFLTRCTL_parse_table, 3, "DSPFLTRCTL",
+	    0xc0, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DSPDATACTL_parse_table[] = {
+	{ "XMITOFFSTDIS",	0x02, 0x02 },
+	{ "RCVROFFSTDIS",	0x04, 0x04 },
+	{ "DESQDIS",		0x10, 0x10 },
+	{ "BYPASSENAB",		0x80, 0x80 }
+};
+
+int
+ahd_dspdatactl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DSPDATACTL_parse_table, 4, "DSPDATACTL",
+	    0xc1, regvalue, cur_col, wrap));
+}
+
+int
+ahd_dfraddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "DFRADDR",
+	    0xc2, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DSPREQCTL_parse_table[] = {
+	{ "MANREQDLY",		0x3f, 0x3f },
+	{ "MANREQCTL",		0xc0, 0xc0 }
+};
+
+int
+ahd_dspreqctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DSPREQCTL_parse_table, 2, "DSPREQCTL",
+	    0xc2, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DSPACKCTL_parse_table[] = {
+	{ "MANACKDLY",		0x3f, 0x3f },
+	{ "MANACKCTL",		0xc0, 0xc0 }
+};
+
+int
+ahd_dspackctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DSPACKCTL_parse_table, 2, "DSPACKCTL",
+	    0xc3, regvalue, cur_col, wrap));
+}
+
+int
+ahd_dfdat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "DFDAT",
+	    0xc4, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DSPSELECT_parse_table[] = {
+	{ "DSPSEL",		0x1f, 0x1f },
+	{ "AUTOINCEN",		0x80, 0x80 }
+};
+
+int
+ahd_dspselect_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DSPSELECT_parse_table, 2, "DSPSELECT",
+	    0xc4, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t WRTBIASCTL_parse_table[] = {
+	{ "XMITMANVAL",		0x3f, 0x3f },
+	{ "AUTOXBCDIS",		0x80, 0x80 }
+};
+
+int
+ahd_wrtbiasctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(WRTBIASCTL_parse_table, 2, "WRTBIASCTL",
+	    0xc5, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t RCVRBIOSCTL_parse_table[] = {
+	{ "RCVRMANVAL",		0x3f, 0x3f },
+	{ "AUTORBCDIS",		0x80, 0x80 }
+};
+
+int
+ahd_rcvrbiosctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(RCVRBIOSCTL_parse_table, 2, "RCVRBIOSCTL",
+	    0xc6, regvalue, cur_col, wrap));
+}
+
+int
+ahd_wrtbiascalc_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "WRTBIASCALC",
+	    0xc7, regvalue, cur_col, wrap));
+}
+
+int
+ahd_dfptrs_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "DFPTRS",
+	    0xc8, regvalue, cur_col, wrap));
+}
+
+int
+ahd_rcvrbiascalc_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "RCVRBIASCALC",
+	    0xc8, regvalue, cur_col, wrap));
+}
+
+int
+ahd_dfbkptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "DFBKPTR",
+	    0xc9, regvalue, cur_col, wrap));
+}
+
+int
+ahd_skewcalc_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SKEWCALC",
+	    0xc9, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DFDBCTL_parse_table[] = {
+	{ "DFF_RAMBIST_EN",	0x01, 0x01 },
+	{ "DFF_RAMBIST_DONE",	0x02, 0x02 },
+	{ "DFF_RAMBIST_FAIL",	0x04, 0x04 },
+	{ "DFF_DIR_ERR",	0x08, 0x08 },
+	{ "DFF_CIO_RD_RDY",	0x10, 0x10 },
+	{ "DFF_CIO_WR_RDY",	0x20, 0x20 }
+};
+
+int
+ahd_dfdbctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DFDBCTL_parse_table, 6, "DFDBCTL",
+	    0xcb, regvalue, cur_col, wrap));
+}
+
+int
+ahd_dfscnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "DFSCNT",
+	    0xcc, regvalue, cur_col, wrap));
+}
+
+int
+ahd_dfbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "DFBCNT",
+	    0xce, regvalue, cur_col, wrap));
+}
+
+int
+ahd_ovlyaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "OVLYADDR",
+	    0xd4, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SEQCTL0_parse_table[] = {
+	{ "LOADRAM",		0x01, 0x01 },
+	{ "SEQRESET",		0x02, 0x02 },
+	{ "STEP",		0x04, 0x04 },
+	{ "BRKADRINTEN",	0x08, 0x08 },
+	{ "FASTMODE",		0x10, 0x10 },
+	{ "FAILDIS",		0x20, 0x20 },
+	{ "PAUSEDIS",		0x40, 0x40 },
+	{ "PERRORDIS",		0x80, 0x80 }
+};
+
+int
+ahd_seqctl0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SEQCTL0_parse_table, 8, "SEQCTL0",
+	    0xd6, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SEQCTL1_parse_table[] = {
+	{ "RAMBIST_EN",		0x01, 0x01 },
+	{ "RAMBIST_FAIL",	0x02, 0x02 },
+	{ "RAMBIST_DONE",	0x04, 0x04 },
+	{ "OVRLAY_DATA_CHK",	0x08, 0x08 }
+};
+
+int
+ahd_seqctl1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SEQCTL1_parse_table, 4, "SEQCTL1",
+	    0xd7, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t FLAGS_parse_table[] = {
+	{ "CARRY",		0x01, 0x01 },
+	{ "ZERO",		0x02, 0x02 }
+};
+
+int
+ahd_flags_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(FLAGS_parse_table, 2, "FLAGS",
+	    0xd8, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SEQINTCTL_parse_table[] = {
+	{ "IRET",		0x01, 0x01 },
+	{ "INTMASK1",		0x02, 0x02 },
+	{ "INTMASK2",		0x04, 0x04 },
+	{ "SCS_SEQ_INT1M0",	0x08, 0x08 },
+	{ "SCS_SEQ_INT1M1",	0x10, 0x10 },
+	{ "INT1_CONTEXT",	0x20, 0x20 },
+	{ "INTVEC1DSL",		0x80, 0x80 }
+};
+
+int
+ahd_seqintctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SEQINTCTL_parse_table, 7, "SEQINTCTL",
+	    0xd9, regvalue, cur_col, wrap));
+}
+
+int
+ahd_seqram_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SEQRAM",
+	    0xda, regvalue, cur_col, wrap));
+}
+
+int
+ahd_prgmcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "PRGMCNT",
+	    0xde, regvalue, cur_col, wrap));
+}
+
+int
+ahd_accum_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "ACCUM",
+	    0xe0, regvalue, cur_col, wrap));
+}
+
+int
+ahd_sindex_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SINDEX",
+	    0xe2, regvalue, cur_col, wrap));
+}
+
+int
+ahd_dindex_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "DINDEX",
+	    0xe4, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t BRKADDR1_parse_table[] = {
+	{ "BRKDIS",		0x80, 0x80 }
+};
+
+int
+ahd_brkaddr1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(BRKADDR1_parse_table, 1, "BRKADDR1",
+	    0xe6, regvalue, cur_col, wrap));
+}
+
+int
+ahd_brkaddr0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "BRKADDR0",
+	    0xe6, regvalue, cur_col, wrap));
+}
+
+int
+ahd_allones_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "ALLONES",
+	    0xe8, regvalue, cur_col, wrap));
+}
+
+int
+ahd_allzeros_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "ALLZEROS",
+	    0xea, regvalue, cur_col, wrap));
+}
+
+int
+ahd_none_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "NONE",
+	    0xea, regvalue, cur_col, wrap));
+}
+
+int
+ahd_sindir_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SINDIR",
+	    0xec, regvalue, cur_col, wrap));
+}
+
+int
+ahd_dindir_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "DINDIR",
+	    0xed, regvalue, cur_col, wrap));
+}
+
+int
+ahd_function1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "FUNCTION1",
+	    0xf0, regvalue, cur_col, wrap));
+}
+
+int
+ahd_stack_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "STACK",
+	    0xf2, regvalue, cur_col, wrap));
+}
+
+int
+ahd_curaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "CURADDR",
+	    0xf4, regvalue, cur_col, wrap));
+}
+
+int
+ahd_intvec1_addr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "INTVEC1_ADDR",
+	    0xf4, regvalue, cur_col, wrap));
+}
+
+int
+ahd_intvec2_addr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "INTVEC2_ADDR",
+	    0xf6, regvalue, cur_col, wrap));
+}
+
+int
+ahd_lastaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "LASTADDR",
+	    0xf6, regvalue, cur_col, wrap));
+}
+
+int
+ahd_longjmp_addr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "LONGJMP_ADDR",
+	    0xf8, regvalue, cur_col, wrap));
+}
+
+int
+ahd_accum_save_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "ACCUM_SAVE",
+	    0xfa, regvalue, cur_col, wrap));
+}
+
+int
+ahd_waiting_scb_tails_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "WAITING_SCB_TAILS",
+	    0x100, regvalue, cur_col, wrap));
+}
+
+int
+ahd_ahd_pci_config_base_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "AHD_PCI_CONFIG_BASE",
+	    0x100, regvalue, cur_col, wrap));
+}
+
+int
+ahd_sram_base_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SRAM_BASE",
+	    0x100, regvalue, cur_col, wrap));
+}
+
+int
+ahd_waiting_tid_head_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "WAITING_TID_HEAD",
+	    0x120, regvalue, cur_col, wrap));
+}
+
+int
+ahd_waiting_tid_tail_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "WAITING_TID_TAIL",
+	    0x122, regvalue, cur_col, wrap));
+}
+
+int
+ahd_next_queued_scb_addr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "NEXT_QUEUED_SCB_ADDR",
+	    0x124, regvalue, cur_col, wrap));
+}
+
+int
+ahd_complete_scb_head_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "COMPLETE_SCB_HEAD",
+	    0x128, regvalue, cur_col, wrap));
+}
+
+int
+ahd_complete_scb_dmainprog_head_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "COMPLETE_SCB_DMAINPROG_HEAD",
+	    0x12a, regvalue, cur_col, wrap));
+}
+
+int
+ahd_complete_dma_scb_head_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "COMPLETE_DMA_SCB_HEAD",
+	    0x12c, regvalue, cur_col, wrap));
+}
+
+int
+ahd_qfreeze_count_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "QFREEZE_COUNT",
+	    0x12e, regvalue, cur_col, wrap));
+}
+
+int
+ahd_saved_mode_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SAVED_MODE",
+	    0x130, regvalue, cur_col, wrap));
+}
+
+int
+ahd_msg_out_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "MSG_OUT",
+	    0x131, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t DMAPARAMS_parse_table[] = {
+	{ "FIFORESET",		0x01, 0x01 },
+	{ "FIFOFLUSH",		0x02, 0x02 },
+	{ "DIRECTION",		0x04, 0x04 },
+	{ "HDMAEN",		0x08, 0x08 },
+	{ "HDMAENACK",		0x08, 0x08 },
+	{ "SDMAEN",		0x10, 0x10 },
+	{ "SDMAENACK",		0x10, 0x10 },
+	{ "SCSIEN",		0x20, 0x20 },
+	{ "WIDEODD",		0x40, 0x40 },
+	{ "PRELOADEN",		0x80, 0x80 }
+};
+
+int
+ahd_dmaparams_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(DMAPARAMS_parse_table, 10, "DMAPARAMS",
+	    0x132, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SEQ_FLAGS_parse_table[] = {
+	{ "NO_DISCONNECT",	0x01, 0x01 },
+	{ "SPHASE_PENDING",	0x02, 0x02 },
+	{ "DPHASE_PENDING",	0x04, 0x04 },
+	{ "CMDPHASE_PENDING",	0x08, 0x08 },
+	{ "TARG_CMD_PENDING",	0x10, 0x10 },
+	{ "DPHASE",		0x20, 0x20 },
+	{ "NO_CDB_SENT",	0x40, 0x40 },
+	{ "TARGET_CMD_IS_TAGGED",0x40, 0x40 },
+	{ "NOT_IDENTIFIED",	0x80, 0x80 }
+};
+
+int
+ahd_seq_flags_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SEQ_FLAGS_parse_table, 9, "SEQ_FLAGS",
+	    0x133, regvalue, cur_col, wrap));
+}
+
+int
+ahd_saved_scsiid_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SAVED_SCSIID",
+	    0x134, regvalue, cur_col, wrap));
+}
+
+int
+ahd_saved_lun_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SAVED_LUN",
+	    0x135, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t LASTPHASE_parse_table[] = {
+	{ "P_DATAOUT",		0x00, 0xe0 },
+	{ "P_DATAOUT_DT",	0x20, 0xe0 },
+	{ "P_DATAIN",		0x40, 0xe0 },
+	{ "P_DATAIN_DT",	0x60, 0xe0 },
+	{ "P_COMMAND",		0x80, 0xe0 },
+	{ "P_MESGOUT",		0xa0, 0xe0 },
+	{ "P_STATUS",		0xc0, 0xe0 },
+	{ "P_MESGIN",		0xe0, 0xe0 },
+	{ "P_BUSFREE",		0x01, 0x01 },
+	{ "MSGI",		0x20, 0x20 },
+	{ "IOI",		0x40, 0x40 },
+	{ "CDI",		0x80, 0x80 },
+	{ "PHASE_MASK",		0xe0, 0xe0 }
+};
+
+int
+ahd_lastphase_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(LASTPHASE_parse_table, 13, "LASTPHASE",
+	    0x136, regvalue, cur_col, wrap));
+}
+
+int
+ahd_qoutfifo_entry_valid_tag_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "QOUTFIFO_ENTRY_VALID_TAG",
+	    0x137, regvalue, cur_col, wrap));
+}
+
+int
+ahd_shared_data_addr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SHARED_DATA_ADDR",
+	    0x138, regvalue, cur_col, wrap));
+}
+
+int
+ahd_qoutfifo_next_addr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "QOUTFIFO_NEXT_ADDR",
+	    0x13c, regvalue, cur_col, wrap));
+}
+
+int
+ahd_kernel_tqinpos_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "KERNEL_TQINPOS",
+	    0x140, regvalue, cur_col, wrap));
+}
+
+int
+ahd_tqinpos_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "TQINPOS",
+	    0x141, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t ARG_1_parse_table[] = {
+	{ "CONT_MSG_LOOP_TARG",	0x02, 0x02 },
+	{ "CONT_MSG_LOOP_READ",	0x03, 0x03 },
+	{ "CONT_MSG_LOOP_WRITE",0x04, 0x04 },
+	{ "EXIT_MSG_LOOP",	0x08, 0x08 },
+	{ "MSGOUT_PHASEMIS",	0x10, 0x10 },
+	{ "SEND_REJ",		0x20, 0x20 },
+	{ "SEND_SENSE",		0x40, 0x40 },
+	{ "SEND_MSG",		0x80, 0x80 }
+};
+
+int
+ahd_arg_1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(ARG_1_parse_table, 8, "ARG_1",
+	    0x142, regvalue, cur_col, wrap));
+}
+
+int
+ahd_arg_2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "ARG_2",
+	    0x143, regvalue, cur_col, wrap));
+}
+
+int
+ahd_last_msg_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "LAST_MSG",
+	    0x144, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SCSISEQ_TEMPLATE_parse_table[] = {
+	{ "ALTSTIM",		0x01, 0x01 },
+	{ "ENAUTOATNP",		0x02, 0x02 },
+	{ "MANUALP",		0x0c, 0x0c },
+	{ "ENRSELI",		0x10, 0x10 },
+	{ "ENSELI",		0x20, 0x20 },
+	{ "MANUALCTL",		0x40, 0x40 }
+};
+
+int
+ahd_scsiseq_template_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SCSISEQ_TEMPLATE_parse_table, 6, "SCSISEQ_TEMPLATE",
+	    0x145, regvalue, cur_col, wrap));
+}
+
+int
+ahd_initiator_tag_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "INITIATOR_TAG",
+	    0x146, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SEQ_FLAGS2_parse_table[] = {
+	{ "TARGET_MSG_PENDING",	0x02, 0x02 },
+	{ "SELECTOUT_QFROZEN",	0x04, 0x04 }
+};
+
+int
+ahd_seq_flags2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SEQ_FLAGS2_parse_table, 2, "SEQ_FLAGS2",
+	    0x147, regvalue, cur_col, wrap));
+}
+
+int
+ahd_allocfifo_scbptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "ALLOCFIFO_SCBPTR",
+	    0x148, regvalue, cur_col, wrap));
+}
+
+int
+ahd_int_coalescing_timer_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "INT_COALESCING_TIMER",
+	    0x14a, regvalue, cur_col, wrap));
+}
+
+int
+ahd_int_coalescing_maxcmds_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "INT_COALESCING_MAXCMDS",
+	    0x14c, regvalue, cur_col, wrap));
+}
+
+int
+ahd_int_coalescing_mincmds_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "INT_COALESCING_MINCMDS",
+	    0x14d, regvalue, cur_col, wrap));
+}
+
+int
+ahd_cmds_pending_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "CMDS_PENDING",
+	    0x14e, regvalue, cur_col, wrap));
+}
+
+int
+ahd_int_coalescing_cmdcount_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "INT_COALESCING_CMDCOUNT",
+	    0x150, regvalue, cur_col, wrap));
+}
+
+int
+ahd_local_hs_mailbox_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "LOCAL_HS_MAILBOX",
+	    0x151, regvalue, cur_col, wrap));
+}
+
+int
+ahd_cmdsize_table_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "CMDSIZE_TABLE",
+	    0x152, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scb_base_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCB_BASE",
+	    0x180, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scb_residual_datacnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCB_RESIDUAL_DATACNT",
+	    0x180, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SCB_RESIDUAL_SGPTR_parse_table[] = {
+	{ "SG_LIST_NULL",	0x01, 0x01 },
+	{ "SG_OVERRUN_RESID",	0x02, 0x02 },
+	{ "SG_ADDR_MASK",	0xf8, 0xf8 }
+};
+
+int
+ahd_scb_residual_sgptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SCB_RESIDUAL_SGPTR_parse_table, 3, "SCB_RESIDUAL_SGPTR",
+	    0x184, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scb_scsi_status_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCB_SCSI_STATUS",
+	    0x188, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scb_target_phases_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCB_TARGET_PHASES",
+	    0x189, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scb_target_data_dir_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCB_TARGET_DATA_DIR",
+	    0x18a, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scb_target_itag_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCB_TARGET_ITAG",
+	    0x18b, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scb_sense_busaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCB_SENSE_BUSADDR",
+	    0x18c, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scb_tag_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCB_TAG",
+	    0x190, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SCB_CONTROL_parse_table[] = {
+	{ "SCB_TAG_TYPE",	0x03, 0x03 },
+	{ "DISCONNECTED",	0x04, 0x04 },
+	{ "STATUS_RCVD",	0x08, 0x08 },
+	{ "MK_MESSAGE",		0x10, 0x10 },
+	{ "TAG_ENB",		0x20, 0x20 },
+	{ "DISCENB",		0x40, 0x40 },
+	{ "TARGET_SCB",		0x80, 0x80 }
+};
+
+int
+ahd_scb_control_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SCB_CONTROL_parse_table, 7, "SCB_CONTROL",
+	    0x192, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SCB_SCSIID_parse_table[] = {
+	{ "OID",		0x0f, 0x0f },
+	{ "TID",		0xf0, 0xf0 }
+};
+
+int
+ahd_scb_scsiid_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SCB_SCSIID_parse_table, 2, "SCB_SCSIID",
+	    0x193, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SCB_LUN_parse_table[] = {
+	{ "LID",		0xff, 0xff }
+};
+
+int
+ahd_scb_lun_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SCB_LUN_parse_table, 1, "SCB_LUN",
+	    0x194, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SCB_TASK_ATTRIBUTE_parse_table[] = {
+	{ "SCB_XFERLEN_ODD",	0x01, 0x01 }
+};
+
+int
+ahd_scb_task_attribute_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SCB_TASK_ATTRIBUTE_parse_table, 1, "SCB_TASK_ATTRIBUTE",
+	    0x195, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SCB_CDB_LEN_parse_table[] = {
+	{ "SCB_CDB_LEN_PTR",	0x80, 0x80 }
+};
+
+int
+ahd_scb_cdb_len_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SCB_CDB_LEN_parse_table, 1, "SCB_CDB_LEN",
+	    0x196, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scb_task_management_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCB_TASK_MANAGEMENT",
+	    0x197, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scb_dataptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCB_DATAPTR",
+	    0x198, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SCB_DATACNT_parse_table[] = {
+	{ "SG_HIGH_ADDR_BITS",	0x7f, 0x7f },
+	{ "SG_LAST_SEG",	0x80, 0x80 }
+};
+
+int
+ahd_scb_datacnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SCB_DATACNT_parse_table, 2, "SCB_DATACNT",
+	    0x1a0, regvalue, cur_col, wrap));
+}
+
+static ahd_reg_parse_entry_t SCB_SGPTR_parse_table[] = {
+	{ "SG_LIST_NULL",	0x01, 0x01 },
+	{ "SG_FULL_RESID",	0x02, 0x02 },
+	{ "SG_STATUS_VALID",	0x04, 0x04 }
+};
+
+int
+ahd_scb_sgptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(SCB_SGPTR_parse_table, 3, "SCB_SGPTR",
+	    0x1a4, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scb_busaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCB_BUSADDR",
+	    0x1a8, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scb_next_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCB_NEXT",
+	    0x1ac, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scb_next2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCB_NEXT2",
+	    0x1ae, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scb_spare_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCB_SPARE",
+	    0x1b0, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scb_disconnected_lists_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCB_DISCONNECTED_LISTS",
+	    0x1b8, regvalue, cur_col, wrap));
+}
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic79xx_seq.h linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx_seq.h
--- linux-2.4.21/drivers/scsi/aic7xxx/aic79xx_seq.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic79xx_seq.h	2003-06-26 21:43:13.000000000 +0000
@@ -0,0 +1,1139 @@
+/*
+ * DO NOT EDIT - This file is automatically generated
+ *		 from the following source files:
+ *
+ * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#94 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#70 $
+ */
+static uint8_t seqprog[] = {
+	0xff, 0x02, 0x06, 0x78,
+	0x00, 0xea, 0x50, 0x59,
+	0x01, 0xea, 0x04, 0x30,
+	0xff, 0x04, 0x0c, 0x78,
+	0x19, 0xea, 0x50, 0x59,
+	0x19, 0xea, 0x04, 0x00,
+	0x33, 0xea, 0x44, 0x59,
+	0x33, 0xea, 0x00, 0x00,
+	0x60, 0x3a, 0x1a, 0x68,
+	0x04, 0x47, 0x1b, 0x68,
+	0xff, 0x21, 0x1b, 0x70,
+	0x40, 0x4b, 0x92, 0x69,
+	0x00, 0xe2, 0x54, 0x59,
+	0x40, 0x4b, 0x92, 0x69,
+	0x20, 0x4b, 0x82, 0x69,
+	0xfc, 0x42, 0x24, 0x78,
+	0x10, 0x40, 0x24, 0x78,
+	0x00, 0xe2, 0xc4, 0x5d,
+	0x20, 0x4d, 0x28, 0x78,
+	0x00, 0xe2, 0xc4, 0x5d,
+	0x30, 0x3f, 0xc0, 0x09,
+	0x30, 0xe0, 0x30, 0x60,
+	0x7f, 0x4a, 0x94, 0x08,
+	0x00, 0xe2, 0x32, 0x40,
+	0xc0, 0x4a, 0x94, 0x00,
+	0x00, 0xe2, 0x3e, 0x58,
+	0x00, 0xe2, 0x56, 0x58,
+	0x00, 0xe2, 0x66, 0x58,
+	0x00, 0xe2, 0x06, 0x40,
+	0x33, 0xea, 0x44, 0x59,
+	0x33, 0xea, 0x00, 0x00,
+	0x01, 0x52, 0x64, 0x78,
+	0x02, 0x58, 0x50, 0x31,
+	0xff, 0xea, 0x10, 0x0b,
+	0xff, 0x97, 0x4f, 0x78,
+	0x50, 0x4b, 0x4a, 0x68,
+	0xbf, 0x3a, 0x74, 0x08,
+	0x14, 0xea, 0x50, 0x59,
+	0x14, 0xea, 0x04, 0x00,
+	0x08, 0x92, 0x25, 0x03,
+	0xff, 0x90, 0x3f, 0x68,
+	0x00, 0xe2, 0x56, 0x5b,
+	0x00, 0xe2, 0x3e, 0x40,
+	0x00, 0xea, 0x44, 0x59,
+	0x01, 0xea, 0x00, 0x30,
+	0x80, 0xf9, 0x5e, 0x68,
+	0x00, 0xe2, 0x42, 0x59,
+	0x11, 0xea, 0x44, 0x59,
+	0x11, 0xea, 0x00, 0x00,
+	0x80, 0xf9, 0x42, 0x79,
+	0xff, 0xea, 0xd4, 0x0d,
+	0x22, 0xea, 0x44, 0x59,
+	0x22, 0xea, 0x00, 0x00,
+	0x10, 0x16, 0x70, 0x78,
+	0x01, 0x0b, 0xa2, 0x32,
+	0x10, 0x16, 0x2c, 0x00,
+	0x18, 0xad, 0x00, 0x79,
+	0x04, 0xad, 0xca, 0x68,
+	0x80, 0xad, 0x64, 0x78,
+	0x10, 0xad, 0x98, 0x78,
+	0xff, 0x88, 0x83, 0x68,
+	0xe7, 0xad, 0x5a, 0x09,
+	0x02, 0x8c, 0x59, 0x32,
+	0x02, 0x28, 0x19, 0x33,
+	0x02, 0xa8, 0x50, 0x36,
+	0x33, 0xea, 0x44, 0x59,
+	0x33, 0xea, 0x00, 0x00,
+	0x40, 0x3a, 0x64, 0x68,
+	0x50, 0x4b, 0x64, 0x68,
+	0x22, 0xea, 0x44, 0x59,
+	0x22, 0xea, 0x00, 0x00,
+	0xe7, 0xad, 0x5a, 0x09,
+	0x02, 0x8c, 0x59, 0x32,
+	0x1a, 0xea, 0x50, 0x59,
+	0x1a, 0xea, 0x04, 0x00,
+	0xff, 0xea, 0xd4, 0x0d,
+	0xe7, 0xad, 0x5a, 0x09,
+	0x00, 0xe2, 0xa6, 0x58,
+	0xff, 0xea, 0x56, 0x02,
+	0x04, 0x7c, 0x78, 0x32,
+	0x20, 0x16, 0x64, 0x78,
+	0x04, 0x38, 0x79, 0x32,
+	0x80, 0x37, 0x6f, 0x16,
+	0xff, 0x2d, 0xb5, 0x60,
+	0xff, 0x29, 0xb5, 0x60,
+	0x40, 0x51, 0xc5, 0x78,
+	0xff, 0x4f, 0xb5, 0x68,
+	0xff, 0x4d, 0xc1, 0x19,
+	0x00, 0x4e, 0xd5, 0x19,
+	0x00, 0xe2, 0xc4, 0x50,
+	0x01, 0x4c, 0xc1, 0x31,
+	0x00, 0x50, 0xd5, 0x19,
+	0x00, 0xe2, 0xc4, 0x48,
+	0x80, 0x18, 0x64, 0x78,
+	0x02, 0x4a, 0x1d, 0x30,
+	0x10, 0xea, 0x18, 0x00,
+	0x60, 0x18, 0x30, 0x00,
+	0x7f, 0x18, 0x30, 0x0c,
+	0x02, 0xea, 0x02, 0x00,
+	0xff, 0xea, 0xa0, 0x0a,
+	0x80, 0x18, 0x30, 0x04,
+	0x40, 0xad, 0x64, 0x78,
+	0xe7, 0xad, 0x5a, 0x09,
+	0x02, 0xa8, 0x40, 0x31,
+	0xff, 0xea, 0xc0, 0x09,
+	0x01, 0x4e, 0x9d, 0x1a,
+	0x00, 0x4f, 0x9f, 0x22,
+	0x01, 0x94, 0x6d, 0x33,
+	0x01, 0xea, 0x20, 0x33,
+	0x04, 0xac, 0x49, 0x32,
+	0xff, 0xea, 0x5a, 0x03,
+	0xff, 0xea, 0x5e, 0x03,
+	0x01, 0x10, 0xd4, 0x31,
+	0x10, 0x92, 0xf5, 0x68,
+	0x3d, 0x93, 0xc5, 0x29,
+	0xfe, 0xe2, 0xc4, 0x09,
+	0x01, 0xea, 0xc6, 0x01,
+	0x02, 0xe2, 0xc8, 0x31,
+	0x02, 0xec, 0x50, 0x31,
+	0x02, 0xa0, 0xda, 0x31,
+	0xff, 0xa9, 0xf4, 0x70,
+	0x02, 0xa0, 0x58, 0x37,
+	0xff, 0x21, 0xfd, 0x70,
+	0x02, 0x22, 0x51, 0x31,
+	0x02, 0xa0, 0x5c, 0x33,
+	0x02, 0xa0, 0x44, 0x36,
+	0x02, 0xa0, 0x40, 0x32,
+	0x02, 0xa0, 0x44, 0x36,
+	0x04, 0x47, 0x05, 0x69,
+	0x40, 0x16, 0x30, 0x69,
+	0xff, 0x2d, 0x35, 0x61,
+	0xff, 0x29, 0x65, 0x70,
+	0x01, 0x37, 0xc1, 0x31,
+	0x02, 0x28, 0x55, 0x32,
+	0x01, 0xea, 0x5a, 0x01,
+	0x04, 0x3c, 0xf9, 0x30,
+	0x02, 0x28, 0x51, 0x31,
+	0x01, 0xa8, 0x60, 0x31,
+	0x00, 0xa9, 0x60, 0x01,
+	0x01, 0x14, 0xd4, 0x31,
+	0x01, 0x50, 0xa1, 0x1a,
+	0xff, 0x4e, 0x9d, 0x1a,
+	0xff, 0x4f, 0x9f, 0x22,
+	0xff, 0x8d, 0x29, 0x71,
+	0x80, 0xac, 0x28, 0x71,
+	0x20, 0x16, 0x28, 0x69,
+	0x02, 0x8c, 0x51, 0x31,
+	0x00, 0xe2, 0x12, 0x41,
+	0x01, 0xac, 0x08, 0x31,
+	0x09, 0xea, 0x5a, 0x01,
+	0x02, 0x8c, 0x51, 0x32,
+	0xff, 0xea, 0x1a, 0x07,
+	0x04, 0x24, 0xf9, 0x30,
+	0x1d, 0xea, 0x3a, 0x41,
+	0x02, 0x2c, 0x51, 0x31,
+	0x04, 0xa8, 0xf9, 0x30,
+	0x19, 0xea, 0x3a, 0x41,
+	0x06, 0xea, 0x08, 0x81,
+	0x01, 0xe2, 0x5a, 0x35,
+	0x02, 0xf2, 0xf0, 0x35,
+	0x02, 0xf2, 0xf0, 0x31,
+	0x02, 0xf8, 0xe4, 0x35,
+	0x80, 0xea, 0xb2, 0x01,
+	0x01, 0xe2, 0x00, 0x30,
+	0xff, 0xea, 0xb2, 0x0d,
+	0x80, 0xea, 0xb2, 0x01,
+	0x11, 0x00, 0x00, 0x10,
+	0xff, 0xea, 0xb2, 0x0d,
+	0x01, 0xe2, 0x04, 0x30,
+	0x01, 0xea, 0x04, 0x34,
+	0x02, 0x20, 0xbd, 0x30,
+	0x02, 0x20, 0xb9, 0x30,
+	0x02, 0x20, 0x51, 0x31,
+	0x4c, 0x93, 0xd7, 0x28,
+	0x10, 0x92, 0x63, 0x79,
+	0x01, 0x6b, 0xc0, 0x30,
+	0x02, 0x64, 0xc8, 0x00,
+	0x40, 0x3a, 0x74, 0x04,
+	0x00, 0xe2, 0x56, 0x58,
+	0x33, 0xea, 0x44, 0x59,
+	0x33, 0xea, 0x00, 0x00,
+	0x30, 0x3f, 0xc0, 0x09,
+	0x30, 0xe0, 0x64, 0x61,
+	0x20, 0x3f, 0x7a, 0x69,
+	0x10, 0x3f, 0x64, 0x79,
+	0x02, 0xea, 0x7e, 0x00,
+	0x00, 0xea, 0x44, 0x59,
+	0x01, 0xea, 0x00, 0x30,
+	0x02, 0x48, 0x51, 0x35,
+	0x01, 0xea, 0x7e, 0x00,
+	0x11, 0xea, 0x44, 0x59,
+	0x11, 0xea, 0x00, 0x00,
+	0x02, 0x48, 0x51, 0x35,
+	0x08, 0xea, 0x98, 0x00,
+	0x08, 0x57, 0xae, 0x00,
+	0x08, 0x3c, 0x78, 0x00,
+	0xf0, 0x49, 0x68, 0x0a,
+	0x0f, 0x67, 0xc0, 0x09,
+	0x00, 0x34, 0x69, 0x02,
+	0x20, 0xea, 0x96, 0x00,
+	0x00, 0xe2, 0xf8, 0x41,
+	0x40, 0x3a, 0xae, 0x69,
+	0x02, 0x55, 0x06, 0x68,
+	0x02, 0x56, 0xae, 0x69,
+	0xff, 0x5b, 0xae, 0x61,
+	0x02, 0x20, 0x51, 0x31,
+	0x80, 0xea, 0xb2, 0x01,
+	0x44, 0xea, 0x00, 0x00,
+	0x01, 0x33, 0xc0, 0x31,
+	0x33, 0xea, 0x00, 0x00,
+	0xff, 0xea, 0xb2, 0x09,
+	0xff, 0xe0, 0xc0, 0x19,
+	0xff, 0xe0, 0xb0, 0x79,
+	0x02, 0xac, 0x51, 0x31,
+	0x00, 0xe2, 0xa6, 0x41,
+	0x02, 0x5e, 0x50, 0x31,
+	0x02, 0xa8, 0xb8, 0x30,
+	0x02, 0x5c, 0x50, 0x31,
+	0xff, 0xad, 0xc1, 0x71,
+	0x02, 0xac, 0x41, 0x31,
+	0x02, 0x22, 0x51, 0x31,
+	0x02, 0xa0, 0x5c, 0x33,
+	0x02, 0xa0, 0x44, 0x32,
+	0x00, 0xe2, 0xca, 0x41,
+	0x10, 0x92, 0xcb, 0x69,
+	0x3d, 0x93, 0xc9, 0x29,
+	0x01, 0xe4, 0xc8, 0x01,
+	0x01, 0xea, 0xca, 0x01,
+	0xff, 0xea, 0xda, 0x01,
+	0x02, 0x20, 0x51, 0x31,
+	0x02, 0xae, 0x41, 0x32,
+	0xff, 0x21, 0xd3, 0x61,
+	0xff, 0xea, 0x46, 0x02,
+	0x02, 0x5c, 0x50, 0x31,
+	0x40, 0xea, 0x96, 0x00,
+	0x02, 0x56, 0xcc, 0x6d,
+	0x01, 0x55, 0xcc, 0x6d,
+	0x10, 0x92, 0xdf, 0x79,
+	0x10, 0x40, 0xe8, 0x69,
+	0x01, 0x56, 0xe8, 0x79,
+	0xff, 0x97, 0x07, 0x78,
+	0x13, 0xea, 0x50, 0x59,
+	0x13, 0xea, 0x04, 0x00,
+	0x00, 0xe2, 0x06, 0x40,
+	0xbf, 0x3a, 0x74, 0x08,
+	0x08, 0xea, 0x98, 0x00,
+	0x08, 0x57, 0xae, 0x00,
+	0x01, 0x93, 0x69, 0x32,
+	0x01, 0x94, 0x6b, 0x32,
+	0x40, 0xea, 0x66, 0x02,
+	0x08, 0x3c, 0x78, 0x00,
+	0x80, 0xea, 0x62, 0x02,
+	0x00, 0xe2, 0xb8, 0x5b,
+	0x01, 0x36, 0xc1, 0x31,
+	0x9f, 0xe0, 0x4c, 0x7c,
+	0x80, 0xe0, 0x0c, 0x72,
+	0xa0, 0xe0, 0x44, 0x72,
+	0xc0, 0xe0, 0x3a, 0x72,
+	0xe0, 0xe0, 0x74, 0x72,
+	0x01, 0xea, 0x50, 0x59,
+	0x01, 0xea, 0x04, 0x00,
+	0x00, 0xe2, 0xf8, 0x41,
+	0x80, 0x33, 0x13, 0x7a,
+	0x03, 0xea, 0x50, 0x59,
+	0x03, 0xea, 0x04, 0x00,
+	0xee, 0x00, 0x1a, 0x6a,
+	0x05, 0xea, 0xb4, 0x00,
+	0x33, 0xea, 0x44, 0x59,
+	0x33, 0xea, 0x00, 0x00,
+	0x02, 0xa8, 0x90, 0x32,
+	0x00, 0xe2, 0x6a, 0x59,
+	0xef, 0x96, 0xd5, 0x19,
+	0x00, 0xe2, 0x2a, 0x52,
+	0x09, 0x80, 0xe1, 0x30,
+	0x02, 0xea, 0x36, 0x00,
+	0xa8, 0xea, 0x32, 0x00,
+	0x00, 0xe2, 0x30, 0x42,
+	0x01, 0x96, 0xd1, 0x30,
+	0x10, 0x80, 0x89, 0x31,
+	0x20, 0xea, 0x32, 0x00,
+	0xbf, 0x33, 0x67, 0x0a,
+	0x20, 0x19, 0x32, 0x6a,
+	0x02, 0x4d, 0xf8, 0x69,
+	0x40, 0x33, 0x67, 0x02,
+	0x00, 0xe2, 0xf8, 0x41,
+	0x80, 0x33, 0xb5, 0x6a,
+	0x01, 0x44, 0x10, 0x33,
+	0x08, 0x92, 0x25, 0x03,
+	0x00, 0xe2, 0xf8, 0x41,
+	0x10, 0xea, 0x80, 0x00,
+	0x01, 0x31, 0xc5, 0x31,
+	0x80, 0xe2, 0x60, 0x62,
+	0x10, 0x92, 0x85, 0x6a,
+	0xc0, 0x94, 0xc5, 0x01,
+	0x40, 0x92, 0x51, 0x6a,
+	0xbf, 0xe2, 0xc4, 0x09,
+	0x20, 0x92, 0x65, 0x7a,
+	0x01, 0xe2, 0x88, 0x30,
+	0x00, 0xe2, 0xb8, 0x5b,
+	0xa0, 0x36, 0x6d, 0x62,
+	0x23, 0x92, 0x89, 0x08,
+	0x00, 0xe2, 0xb8, 0x5b,
+	0xa0, 0x36, 0x6d, 0x62,
+	0x00, 0xa8, 0x64, 0x42,
+	0xff, 0xe2, 0x64, 0x62,
+	0x00, 0xe2, 0x84, 0x42,
+	0x40, 0xea, 0x98, 0x00,
+	0x01, 0xe2, 0x88, 0x30,
+	0x00, 0xe2, 0xb8, 0x5b,
+	0xa0, 0x36, 0x43, 0x72,
+	0x40, 0xea, 0x98, 0x00,
+	0x01, 0x31, 0x89, 0x32,
+	0x08, 0xea, 0x62, 0x02,
+	0x00, 0xe2, 0xf8, 0x41,
+	0xe0, 0xea, 0xd4, 0x5b,
+	0x80, 0xe0, 0xc0, 0x6a,
+	0x04, 0xe0, 0x66, 0x73,
+	0x02, 0xe0, 0x96, 0x73,
+	0x00, 0xea, 0x1e, 0x73,
+	0x03, 0xe0, 0xa6, 0x73,
+	0x23, 0xe0, 0x96, 0x72,
+	0x08, 0xe0, 0xbc, 0x72,
+	0x00, 0xe2, 0xb8, 0x5b,
+	0x07, 0xea, 0x50, 0x59,
+	0x07, 0xea, 0x04, 0x00,
+	0x08, 0x42, 0xf9, 0x71,
+	0x04, 0x42, 0x93, 0x62,
+	0x01, 0x43, 0x89, 0x30,
+	0x00, 0xe2, 0x84, 0x42,
+	0x01, 0x44, 0xd4, 0x31,
+	0x00, 0xe2, 0x84, 0x42,
+	0x01, 0x00, 0x60, 0x32,
+	0x33, 0xea, 0x44, 0x59,
+	0x33, 0xea, 0x00, 0x00,
+	0x4c, 0x34, 0xc1, 0x28,
+	0x01, 0x64, 0xc0, 0x31,
+	0x00, 0x30, 0x45, 0x59,
+	0x01, 0x30, 0x01, 0x30,
+	0x01, 0xe0, 0xba, 0x7a,
+	0xa0, 0xea, 0xca, 0x5b,
+	0x01, 0xa0, 0xba, 0x62,
+	0x01, 0x84, 0xaf, 0x7a,
+	0x01, 0x95, 0xbd, 0x6a,
+	0x05, 0xea, 0x50, 0x59,
+	0x05, 0xea, 0x04, 0x00,
+	0x00, 0xe2, 0xbc, 0x42,
+	0x03, 0xea, 0x50, 0x59,
+	0x03, 0xea, 0x04, 0x00,
+	0x00, 0xe2, 0xbc, 0x42,
+	0x07, 0xea, 0xdc, 0x5b,
+	0x01, 0x44, 0xd4, 0x31,
+	0x00, 0xe2, 0xf8, 0x41,
+	0x3f, 0xe0, 0x6a, 0x0a,
+	0xc0, 0x34, 0xc1, 0x09,
+	0x00, 0x35, 0x51, 0x01,
+	0xff, 0xea, 0x52, 0x09,
+	0x30, 0x34, 0xc5, 0x09,
+	0x3d, 0xe2, 0xc4, 0x29,
+	0xb8, 0xe2, 0xc4, 0x19,
+	0x01, 0xea, 0xc6, 0x01,
+	0x02, 0xe2, 0xc8, 0x31,
+	0x02, 0xec, 0x40, 0x31,
+	0xff, 0xa1, 0xdc, 0x72,
+	0x02, 0xe8, 0xda, 0x31,
+	0x02, 0xa0, 0x50, 0x31,
+	0x00, 0xe2, 0xfe, 0x42,
+	0x80, 0x33, 0x67, 0x02,
+	0x01, 0x44, 0xd4, 0x31,
+	0x00, 0xe2, 0xb8, 0x5b,
+	0x01, 0x33, 0x67, 0x02,
+	0xe0, 0x36, 0x19, 0x63,
+	0x02, 0x33, 0x67, 0x02,
+	0x20, 0x46, 0x12, 0x63,
+	0xff, 0xea, 0x52, 0x09,
+	0xa8, 0xea, 0xca, 0x5b,
+	0x04, 0x92, 0xf9, 0x7a,
+	0x01, 0x34, 0xc1, 0x31,
+	0x00, 0x93, 0xf9, 0x62,
+	0x01, 0x35, 0xc1, 0x31,
+	0x00, 0x94, 0x03, 0x73,
+	0x01, 0xa9, 0x52, 0x11,
+	0xff, 0xa9, 0xee, 0x6a,
+	0x00, 0xe2, 0x12, 0x43,
+	0x10, 0x33, 0x67, 0x02,
+	0x04, 0x92, 0x13, 0x7b,
+	0xfb, 0x92, 0x25, 0x0b,
+	0xff, 0xea, 0x66, 0x0a,
+	0x01, 0xa4, 0x0d, 0x6b,
+	0x02, 0xa8, 0x90, 0x32,
+	0x00, 0xe2, 0x6a, 0x59,
+	0x10, 0x92, 0xbd, 0x7a,
+	0xff, 0xea, 0xdc, 0x5b,
+	0x00, 0xe2, 0xbc, 0x42,
+	0x04, 0xea, 0x50, 0x59,
+	0x04, 0xea, 0x04, 0x00,
+	0x00, 0xe2, 0xbc, 0x42,
+	0x04, 0xea, 0x50, 0x59,
+	0x04, 0xea, 0x04, 0x00,
+	0x00, 0xe2, 0xf8, 0x41,
+	0x08, 0x92, 0xb5, 0x7a,
+	0xc0, 0x33, 0x29, 0x7b,
+	0x80, 0x33, 0xb5, 0x6a,
+	0xff, 0x88, 0x29, 0x6b,
+	0x40, 0x33, 0xb5, 0x6a,
+	0x10, 0x92, 0x2f, 0x7b,
+	0x0a, 0xea, 0x50, 0x59,
+	0x0a, 0xea, 0x04, 0x00,
+	0x00, 0xe2, 0x4e, 0x5b,
+	0x00, 0xe2, 0x82, 0x43,
+	0x50, 0x4b, 0x36, 0x6b,
+	0xbf, 0x3a, 0x74, 0x08,
+	0x01, 0xe0, 0xf4, 0x31,
+	0xff, 0xea, 0xc0, 0x09,
+	0x01, 0x2e, 0x5d, 0x1a,
+	0x00, 0x2f, 0x5f, 0x22,
+	0x04, 0x47, 0x8f, 0x02,
+	0x01, 0xfa, 0xc0, 0x35,
+	0x02, 0xa8, 0x84, 0x32,
+	0x02, 0xea, 0xb4, 0x00,
+	0x33, 0xea, 0x44, 0x59,
+	0x33, 0xea, 0x00, 0x00,
+	0x02, 0x42, 0x51, 0x31,
+	0xff, 0x90, 0x65, 0x68,
+	0xff, 0x88, 0x5b, 0x6b,
+	0x01, 0xa4, 0x57, 0x6b,
+	0x02, 0xa4, 0x5f, 0x6b,
+	0x01, 0x84, 0x5f, 0x7b,
+	0x02, 0x28, 0x19, 0x33,
+	0x02, 0xa8, 0x50, 0x36,
+	0xff, 0x88, 0x5f, 0x73,
+	0x00, 0xe2, 0x32, 0x5b,
+	0x02, 0xa8, 0x20, 0x33,
+	0x02, 0x2c, 0x19, 0x33,
+	0x02, 0xa8, 0x58, 0x32,
+	0x04, 0xa4, 0x49, 0x07,
+	0xc0, 0x33, 0xb5, 0x6a,
+	0x04, 0x92, 0x25, 0x03,
+	0x20, 0x92, 0x83, 0x6b,
+	0x02, 0xa8, 0x40, 0x31,
+	0xc0, 0x34, 0xc1, 0x09,
+	0x00, 0x35, 0x51, 0x01,
+	0xff, 0xea, 0x52, 0x09,
+	0x30, 0x34, 0xc5, 0x09,
+	0x3d, 0xe2, 0xc4, 0x29,
+	0xb8, 0xe2, 0xc4, 0x19,
+	0x01, 0xea, 0xc6, 0x01,
+	0x02, 0xe2, 0xc8, 0x31,
+	0x02, 0xa0, 0xda, 0x31,
+	0x02, 0xa0, 0x50, 0x31,
+	0xf7, 0x57, 0xae, 0x08,
+	0x08, 0xea, 0x98, 0x00,
+	0x01, 0x44, 0xd4, 0x31,
+	0xee, 0x00, 0x8c, 0x6b,
+	0x02, 0xea, 0xb4, 0x00,
+	0x00, 0xe2, 0xb4, 0x5b,
+	0x09, 0x4c, 0x8e, 0x7b,
+	0x08, 0x4c, 0x06, 0x68,
+	0x0b, 0xea, 0x50, 0x59,
+	0x0b, 0xea, 0x04, 0x00,
+	0x01, 0x44, 0xd4, 0x31,
+	0x20, 0x33, 0xf9, 0x79,
+	0x00, 0xe2, 0x9e, 0x5b,
+	0x00, 0xe2, 0xf8, 0x41,
+	0x01, 0x84, 0xa3, 0x7b,
+	0x01, 0xa4, 0x49, 0x07,
+	0x08, 0x60, 0x30, 0x33,
+	0x08, 0x80, 0x41, 0x37,
+	0xdf, 0x33, 0x67, 0x0a,
+	0xee, 0x00, 0xb0, 0x6b,
+	0x05, 0xea, 0xb4, 0x00,
+	0x33, 0xea, 0x44, 0x59,
+	0x33, 0xea, 0x00, 0x00,
+	0x00, 0xe2, 0x6a, 0x59,
+	0x00, 0xe2, 0xbc, 0x42,
+	0x01, 0xea, 0x6c, 0x02,
+	0xc0, 0xea, 0x66, 0x06,
+	0xff, 0x42, 0xc4, 0x6b,
+	0x01, 0x41, 0xb8, 0x6b,
+	0x02, 0x41, 0xb8, 0x7b,
+	0xff, 0x42, 0xc4, 0x6b,
+	0x01, 0x41, 0xb8, 0x6b,
+	0x02, 0x41, 0xb8, 0x7b,
+	0xff, 0x42, 0xc4, 0x7b,
+	0x04, 0x4c, 0xb8, 0x6b,
+	0xe0, 0x41, 0x6c, 0x0e,
+	0x01, 0x44, 0xd4, 0x31,
+	0xff, 0x42, 0xcc, 0x7b,
+	0x04, 0x4c, 0xcc, 0x6b,
+	0xe0, 0x41, 0x6c, 0x0a,
+	0xe0, 0x36, 0xf9, 0x61,
+	0xff, 0xea, 0xca, 0x09,
+	0x01, 0xe2, 0xc8, 0x31,
+	0x01, 0x46, 0xda, 0x35,
+	0x01, 0x44, 0xd4, 0x35,
+	0x10, 0xea, 0x80, 0x00,
+	0x01, 0xe2, 0x62, 0x36,
+	0x04, 0xa6, 0xe4, 0x7b,
+	0xff, 0xea, 0x5a, 0x09,
+	0xff, 0xea, 0x4c, 0x0d,
+	0x01, 0xa6, 0x02, 0x6c,
+	0x10, 0xad, 0x64, 0x78,
+	0x80, 0xad, 0xfa, 0x6b,
+	0x08, 0xad, 0x64, 0x68,
+	0x04, 0x84, 0xf9, 0x30,
+	0x00, 0xea, 0x08, 0x81,
+	0xff, 0xea, 0xd4, 0x09,
+	0x02, 0x84, 0xf9, 0x88,
+	0x0d, 0xea, 0x5a, 0x01,
+	0x04, 0xa6, 0x4c, 0x05,
+	0x04, 0xa6, 0x64, 0x78,
+	0xff, 0xea, 0x5a, 0x09,
+	0x03, 0x84, 0x59, 0x89,
+	0x03, 0xea, 0x4c, 0x01,
+	0x80, 0x1a, 0x64, 0x78,
+	0x08, 0x19, 0x64, 0x78,
+	0x08, 0xb0, 0xe0, 0x30,
+	0x04, 0xb0, 0xe0, 0x30,
+	0x03, 0xb0, 0xf0, 0x30,
+	0x01, 0xb0, 0x06, 0x33,
+	0x7f, 0x83, 0xe9, 0x08,
+	0x04, 0xac, 0x58, 0x19,
+	0xff, 0xea, 0xc0, 0x09,
+	0x04, 0x84, 0x09, 0x9b,
+	0x00, 0x85, 0x0b, 0x23,
+	0x00, 0x86, 0x0d, 0x23,
+	0x00, 0x87, 0x0f, 0x23,
+	0x01, 0x84, 0xc5, 0x31,
+	0x80, 0x83, 0x25, 0x7c,
+	0x02, 0xe2, 0xc4, 0x01,
+	0xff, 0xea, 0x4c, 0x09,
+	0x01, 0xe2, 0x36, 0x30,
+	0xc8, 0x19, 0x32, 0x00,
+	0x88, 0x19, 0x32, 0x00,
+	0x01, 0xac, 0xd4, 0x99,
+	0x00, 0xe2, 0x64, 0x50,
+	0xfe, 0xa6, 0x4c, 0x0d,
+	0x0b, 0x98, 0xe1, 0x30,
+	0xfd, 0xa4, 0x49, 0x09,
+	0x80, 0xa3, 0x39, 0x7c,
+	0x02, 0xa4, 0x48, 0x01,
+	0x01, 0xa4, 0x36, 0x30,
+	0xa8, 0xea, 0x32, 0x00,
+	0xfd, 0xa4, 0x49, 0x0b,
+	0x05, 0xa3, 0x07, 0x33,
+	0x80, 0x83, 0x45, 0x6c,
+	0x02, 0xea, 0x4c, 0x05,
+	0xff, 0xea, 0x4c, 0x0d,
+	0x00, 0xe2, 0x3e, 0x59,
+	0x02, 0xa6, 0xe6, 0x6b,
+	0x80, 0xf9, 0xf2, 0x05,
+	0xc0, 0x33, 0x53, 0x7c,
+	0x03, 0xea, 0x50, 0x59,
+	0x03, 0xea, 0x04, 0x00,
+	0x20, 0x33, 0x77, 0x7c,
+	0x01, 0x84, 0x5d, 0x6c,
+	0x06, 0xea, 0x50, 0x59,
+	0x06, 0xea, 0x04, 0x00,
+	0x00, 0xe2, 0x7a, 0x44,
+	0x01, 0x00, 0x60, 0x32,
+	0xee, 0x00, 0x66, 0x6c,
+	0x05, 0xea, 0xb4, 0x00,
+	0x33, 0xea, 0x44, 0x59,
+	0x33, 0xea, 0x00, 0x00,
+	0x80, 0x3d, 0x7a, 0x00,
+	0xfc, 0x42, 0x68, 0x7c,
+	0x7f, 0x3d, 0x7a, 0x08,
+	0x00, 0x30, 0x45, 0x59,
+	0x01, 0x30, 0x01, 0x30,
+	0x09, 0xea, 0x50, 0x59,
+	0x09, 0xea, 0x04, 0x00,
+	0x00, 0xe2, 0xf8, 0x41,
+	0x01, 0xa4, 0x5d, 0x6c,
+	0x00, 0xe2, 0x30, 0x5c,
+	0x20, 0x33, 0x67, 0x02,
+	0x01, 0x00, 0x60, 0x32,
+	0x02, 0xa6, 0x82, 0x7c,
+	0x00, 0xe2, 0x46, 0x5c,
+	0x00, 0xe2, 0x56, 0x58,
+	0x00, 0xe2, 0x66, 0x58,
+	0x00, 0xe2, 0x3a, 0x58,
+	0x00, 0x30, 0x45, 0x59,
+	0x01, 0x30, 0x01, 0x30,
+	0x20, 0x19, 0x82, 0x6c,
+	0x00, 0xe2, 0xb2, 0x5c,
+	0x04, 0x19, 0x9c, 0x6c,
+	0x02, 0x19, 0x32, 0x00,
+	0x01, 0x84, 0x9d, 0x7c,
+	0x01, 0x1b, 0x96, 0x7c,
+	0x01, 0x1a, 0x9c, 0x6c,
+	0x00, 0xe2, 0x4c, 0x44,
+	0x80, 0x4b, 0xa2, 0x6c,
+	0x01, 0x4c, 0x9e, 0x7c,
+	0x03, 0x42, 0x4c, 0x6c,
+	0x00, 0xe2, 0xe0, 0x5b,
+	0x80, 0xf9, 0xf2, 0x01,
+	0x04, 0x33, 0xf9, 0x79,
+	0x00, 0xe2, 0xf8, 0x41,
+	0x08, 0x5d, 0xba, 0x6c,
+	0x00, 0xe2, 0x56, 0x58,
+	0x00, 0x30, 0x45, 0x59,
+	0x01, 0x30, 0x01, 0x30,
+	0x02, 0x1b, 0xaa, 0x7c,
+	0x08, 0x5d, 0xb8, 0x7c,
+	0x03, 0x68, 0x00, 0x37,
+	0x01, 0x84, 0x09, 0x07,
+	0x80, 0x1b, 0xc4, 0x7c,
+	0x80, 0x84, 0xc5, 0x6c,
+	0xff, 0x85, 0x0b, 0x1b,
+	0xff, 0x86, 0x0d, 0x23,
+	0xff, 0x87, 0x0f, 0x23,
+	0xf8, 0x1b, 0x08, 0x0b,
+	0xff, 0xea, 0x06, 0x0b,
+	0x03, 0x68, 0x00, 0x37,
+	0x00, 0xe2, 0xc4, 0x58,
+	0x10, 0xea, 0x18, 0x00,
+	0xf9, 0xd9, 0xb2, 0x0d,
+	0x01, 0xd9, 0xb2, 0x05,
+	0x01, 0x52, 0x48, 0x31,
+	0x20, 0xa4, 0xee, 0x7c,
+	0x20, 0x5b, 0xee, 0x7c,
+	0x80, 0xf9, 0xfc, 0x7c,
+	0x02, 0xea, 0xb4, 0x00,
+	0x11, 0x00, 0x00, 0x10,
+	0x04, 0x19, 0x08, 0x7d,
+	0xdf, 0x19, 0x32, 0x08,
+	0x60, 0x5b, 0xe6, 0x6c,
+	0x01, 0x4c, 0xe2, 0x7c,
+	0x20, 0x19, 0x32, 0x00,
+	0x01, 0xd9, 0xb2, 0x05,
+	0x02, 0xea, 0xb4, 0x00,
+	0x01, 0xd9, 0xb2, 0x05,
+	0x10, 0x5b, 0x00, 0x6d,
+	0x08, 0x5b, 0x0a, 0x6d,
+	0x20, 0x5b, 0xfa, 0x6c,
+	0x02, 0x5b, 0x2a, 0x6d,
+	0x0e, 0xea, 0x50, 0x59,
+	0x0e, 0xea, 0x04, 0x00,
+	0x80, 0xf9, 0xea, 0x6c,
+	0xdf, 0x5c, 0xb8, 0x08,
+	0x01, 0xd9, 0xb2, 0x05,
+	0x01, 0xa4, 0xe5, 0x6d,
+	0x00, 0xe2, 0x30, 0x5c,
+	0x00, 0xe2, 0x34, 0x5d,
+	0x01, 0x90, 0x21, 0x1b,
+	0x01, 0xd9, 0xb2, 0x05,
+	0x00, 0xe2, 0x32, 0x5b,
+	0xf3, 0x96, 0xd5, 0x19,
+	0x00, 0xe2, 0x18, 0x55,
+	0x80, 0x96, 0x19, 0x6d,
+	0x0f, 0xea, 0x50, 0x59,
+	0x0f, 0xea, 0x04, 0x00,
+	0x00, 0xe2, 0x20, 0x45,
+	0x04, 0x8c, 0xe1, 0x30,
+	0x01, 0xea, 0xf2, 0x00,
+	0x02, 0xea, 0x36, 0x00,
+	0xa8, 0xea, 0x32, 0x00,
+	0xff, 0x97, 0x27, 0x7d,
+	0x14, 0xea, 0x50, 0x59,
+	0x14, 0xea, 0x04, 0x00,
+	0x00, 0xe2, 0x96, 0x5d,
+	0x01, 0xd9, 0xb2, 0x05,
+	0x09, 0x80, 0xe1, 0x30,
+	0x02, 0xea, 0x36, 0x00,
+	0xa8, 0xea, 0x32, 0x00,
+	0x00, 0xe2, 0x8e, 0x5d,
+	0x01, 0xd9, 0xb2, 0x05,
+	0x02, 0xa6, 0x44, 0x7d,
+	0x00, 0xe2, 0x3e, 0x59,
+	0x20, 0x5b, 0x52, 0x6d,
+	0xfc, 0x42, 0x3e, 0x7d,
+	0x10, 0x40, 0x40, 0x6d,
+	0x20, 0x4d, 0x42, 0x7d,
+	0x08, 0x5d, 0x52, 0x6d,
+	0x02, 0xa6, 0xe6, 0x6b,
+	0x00, 0xe2, 0x3e, 0x59,
+	0x20, 0x5b, 0x52, 0x6d,
+	0x01, 0x1b, 0x72, 0x6d,
+	0xfc, 0x42, 0x4e, 0x7d,
+	0x10, 0x40, 0x50, 0x6d,
+	0x20, 0x4d, 0x64, 0x78,
+	0x08, 0x5d, 0x64, 0x78,
+	0x02, 0x19, 0x32, 0x00,
+	0x01, 0x5b, 0x40, 0x31,
+	0x00, 0xe2, 0xb2, 0x5c,
+	0x00, 0xe2, 0x9e, 0x5b,
+	0x20, 0xea, 0xb6, 0x00,
+	0x00, 0xe2, 0xe0, 0x5b,
+	0x20, 0x5c, 0xb8, 0x00,
+	0x04, 0x19, 0x68, 0x6d,
+	0x01, 0x1a, 0x68, 0x6d,
+	0x00, 0xe2, 0x3e, 0x59,
+	0x01, 0x1a, 0x64, 0x78,
+	0x80, 0xf9, 0xf2, 0x01,
+	0x20, 0xa0, 0xcc, 0x7d,
+	0xff, 0x90, 0x21, 0x1b,
+	0x08, 0x92, 0x43, 0x6b,
+	0x02, 0xea, 0xb4, 0x04,
+	0x01, 0xa4, 0x49, 0x03,
+	0x40, 0x5b, 0x82, 0x6d,
+	0x00, 0xe2, 0x3e, 0x59,
+	0x40, 0x5b, 0x82, 0x6d,
+	0x04, 0x5d, 0xe6, 0x7d,
+	0x01, 0x1a, 0xe6, 0x7d,
+	0x20, 0x4d, 0x64, 0x78,
+	0x40, 0x5b, 0xcc, 0x7d,
+	0x04, 0x5d, 0xe6, 0x7d,
+	0x01, 0x1a, 0xe6, 0x7d,
+	0x80, 0xf9, 0xf2, 0x01,
+	0xff, 0x90, 0x21, 0x1b,
+	0x08, 0x92, 0x43, 0x6b,
+	0x02, 0xea, 0xb4, 0x04,
+	0x00, 0xe2, 0x3e, 0x59,
+	0x01, 0x1b, 0x64, 0x78,
+	0x80, 0xf9, 0xf2, 0x01,
+	0x02, 0xea, 0xb4, 0x04,
+	0x00, 0xe2, 0x3e, 0x59,
+	0x01, 0x1b, 0xaa, 0x6d,
+	0x40, 0x5b, 0xb8, 0x7d,
+	0x01, 0x1b, 0xaa, 0x6d,
+	0x02, 0x19, 0x32, 0x00,
+	0x01, 0x1a, 0x64, 0x78,
+	0x80, 0xf9, 0xf2, 0x01,
+	0xff, 0xea, 0x10, 0x03,
+	0x08, 0x92, 0x25, 0x03,
+	0x00, 0xe2, 0x42, 0x43,
+	0x01, 0x1a, 0xb4, 0x7d,
+	0x40, 0x5b, 0xb0, 0x7d,
+	0x01, 0x1a, 0x9e, 0x6d,
+	0xfc, 0x42, 0x64, 0x78,
+	0x01, 0x1a, 0xb8, 0x6d,
+	0x10, 0xea, 0x50, 0x59,
+	0x10, 0xea, 0x04, 0x00,
+	0xfc, 0x42, 0x64, 0x78,
+	0x10, 0x40, 0xbe, 0x6d,
+	0x20, 0x4d, 0x64, 0x78,
+	0x40, 0x5b, 0x9e, 0x6d,
+	0x01, 0x1a, 0x64, 0x78,
+	0x01, 0x90, 0x21, 0x1b,
+	0x30, 0x3f, 0xc0, 0x09,
+	0x30, 0xe0, 0x64, 0x60,
+	0x40, 0x4b, 0x64, 0x68,
+	0xff, 0xea, 0x52, 0x01,
+	0xee, 0x00, 0xd2, 0x6d,
+	0x80, 0xf9, 0xf2, 0x01,
+	0xff, 0x90, 0x21, 0x1b,
+	0x02, 0xea, 0xb4, 0x00,
+	0x20, 0xea, 0x9a, 0x00,
+	0xf3, 0x42, 0xde, 0x6d,
+	0x12, 0xea, 0x50, 0x59,
+	0x12, 0xea, 0x04, 0x00,
+	0x00, 0xe2, 0xf8, 0x41,
+	0x0d, 0xea, 0x50, 0x59,
+	0x0d, 0xea, 0x04, 0x00,
+	0x00, 0xe2, 0xf8, 0x41,
+	0x01, 0x90, 0x21, 0x1b,
+	0x11, 0xea, 0x50, 0x59,
+	0x11, 0xea, 0x04, 0x00,
+	0x00, 0xe2, 0x32, 0x5b,
+	0x08, 0x5a, 0xb4, 0x00,
+	0x00, 0xe2, 0x0c, 0x5e,
+	0xa8, 0xea, 0x32, 0x00,
+	0x00, 0xe2, 0x3e, 0x59,
+	0x80, 0x1a, 0xfa, 0x7d,
+	0x00, 0xe2, 0x0c, 0x5e,
+	0x80, 0x19, 0x32, 0x00,
+	0x40, 0x5b, 0x00, 0x6e,
+	0x08, 0x5a, 0x00, 0x7e,
+	0x20, 0x4d, 0x64, 0x78,
+	0x02, 0x84, 0x09, 0x03,
+	0x40, 0x5b, 0xcc, 0x7d,
+	0xff, 0x90, 0x21, 0x1b,
+	0x80, 0xf9, 0xf2, 0x01,
+	0x08, 0x92, 0x43, 0x6b,
+	0x02, 0xea, 0xb4, 0x04,
+	0x01, 0x38, 0xe1, 0x30,
+	0x05, 0x39, 0xe3, 0x98,
+	0x01, 0xe0, 0xf4, 0x31,
+	0xff, 0xea, 0xc0, 0x09,
+	0x00, 0x3a, 0xe5, 0x20,
+	0x00, 0x3b, 0xe7, 0x20,
+	0x01, 0xfa, 0xc0, 0x31,
+	0x04, 0xea, 0xe8, 0x30,
+	0xff, 0xea, 0xf0, 0x08,
+	0x02, 0xea, 0xf2, 0x00,
+	0xff, 0xea, 0xf4, 0x0c
+};
+
+typedef int ahd_patch_func_t (struct ahd_softc *ahd);
+static ahd_patch_func_t ahd_patch22_func;
+
+static int
+ahd_patch22_func(struct ahd_softc *ahd)
+{
+	return ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0);
+}
+
+static ahd_patch_func_t ahd_patch21_func;
+
+static int
+ahd_patch21_func(struct ahd_softc *ahd)
+{
+	return ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) == 0);
+}
+
+static ahd_patch_func_t ahd_patch20_func;
+
+static int
+ahd_patch20_func(struct ahd_softc *ahd)
+{
+	return ((ahd->features & AHD_RTI) == 0);
+}
+
+static ahd_patch_func_t ahd_patch19_func;
+
+static int
+ahd_patch19_func(struct ahd_softc *ahd)
+{
+	return ((ahd->flags & AHD_INITIATORROLE) != 0);
+}
+
+static ahd_patch_func_t ahd_patch18_func;
+
+static int
+ahd_patch18_func(struct ahd_softc *ahd)
+{
+	return ((ahd->flags & AHD_TARGETROLE) != 0);
+}
+
+static ahd_patch_func_t ahd_patch17_func;
+
+static int
+ahd_patch17_func(struct ahd_softc *ahd)
+{
+	return ((ahd->bugs & AHD_AUTOFLUSH_BUG) != 0);
+}
+
+static ahd_patch_func_t ahd_patch16_func;
+
+static int
+ahd_patch16_func(struct ahd_softc *ahd)
+{
+	return ((ahd->features & AHD_NEW_DFCNTRL_OPTS) != 0);
+}
+
+static ahd_patch_func_t ahd_patch15_func;
+
+static int
+ahd_patch15_func(struct ahd_softc *ahd)
+{
+	return ((ahd->flags & AHD_39BIT_ADDRESSING) != 0);
+}
+
+static ahd_patch_func_t ahd_patch14_func;
+
+static int
+ahd_patch14_func(struct ahd_softc *ahd)
+{
+	return ((ahd->flags & AHD_64BIT_ADDRESSING) != 0);
+}
+
+static ahd_patch_func_t ahd_patch13_func;
+
+static int
+ahd_patch13_func(struct ahd_softc *ahd)
+{
+	return ((ahd->features & AHD_NEW_DFCNTRL_OPTS) == 0);
+}
+
+static ahd_patch_func_t ahd_patch12_func;
+
+static int
+ahd_patch12_func(struct ahd_softc *ahd)
+{
+	return ((ahd->bugs & AHD_REG_SLOW_SETTLE_BUG) != 0);
+}
+
+static ahd_patch_func_t ahd_patch11_func;
+
+static int
+ahd_patch11_func(struct ahd_softc *ahd)
+{
+	return ((ahd->bugs & AHD_EARLY_REQ_BUG) != 0);
+}
+
+static ahd_patch_func_t ahd_patch10_func;
+
+static int
+ahd_patch10_func(struct ahd_softc *ahd)
+{
+	return ((ahd->bugs & AHD_BUSFREEREV_BUG) == 0);
+}
+
+static ahd_patch_func_t ahd_patch9_func;
+
+static int
+ahd_patch9_func(struct ahd_softc *ahd)
+{
+	return ((ahd->flags & AHD_SEQUENCER_DEBUG) != 0);
+}
+
+static ahd_patch_func_t ahd_patch8_func;
+
+static int
+ahd_patch8_func(struct ahd_softc *ahd)
+{
+	return ((ahd->bugs & AHD_LQO_ATNO_BUG) != 0);
+}
+
+static ahd_patch_func_t ahd_patch7_func;
+
+static int
+ahd_patch7_func(struct ahd_softc *ahd)
+{
+	return ((ahd->bugs & AHD_BUSFREEREV_BUG) != 0);
+}
+
+static ahd_patch_func_t ahd_patch6_func;
+
+static int
+ahd_patch6_func(struct ahd_softc *ahd)
+{
+	return ((ahd->bugs & AHD_NONPACKFIFO_BUG) != 0);
+}
+
+static ahd_patch_func_t ahd_patch5_func;
+
+static int
+ahd_patch5_func(struct ahd_softc *ahd)
+{
+	return ((ahd->bugs & AHD_SENT_SCB_UPDATE_BUG) != 0);
+}
+
+static ahd_patch_func_t ahd_patch4_func;
+
+static int
+ahd_patch4_func(struct ahd_softc *ahd)
+{
+	return ((ahd->bugs & AHD_PKT_LUN_BUG) != 0);
+}
+
+static ahd_patch_func_t ahd_patch3_func;
+
+static int
+ahd_patch3_func(struct ahd_softc *ahd)
+{
+	return ((ahd->bugs & AHD_FAINT_LED_BUG) != 0);
+}
+
+static ahd_patch_func_t ahd_patch2_func;
+
+static int
+ahd_patch2_func(struct ahd_softc *ahd)
+{
+	return ((ahd->bugs & AHD_SET_MODE_BUG) != 0);
+}
+
+static ahd_patch_func_t ahd_patch1_func;
+
+static int
+ahd_patch1_func(struct ahd_softc *ahd)
+{
+	return ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0);
+}
+
+static ahd_patch_func_t ahd_patch0_func;
+
+static int
+ahd_patch0_func(struct ahd_softc *ahd)
+{
+	return (0);
+}
+
+static struct patch {
+	ahd_patch_func_t		*patch_func;
+	uint32_t		 begin		:10,
+				 skip_instr	:10,
+				 skip_patch	:12;
+} patches[] = {
+	{ ahd_patch1_func, 0, 3, 3 },
+	{ ahd_patch1_func, 1, 1, 2 },
+	{ ahd_patch0_func, 2, 1, 1 },
+	{ ahd_patch1_func, 3, 3, 3 },
+	{ ahd_patch1_func, 4, 1, 2 },
+	{ ahd_patch0_func, 5, 1, 1 },
+	{ ahd_patch2_func, 6, 1, 2 },
+	{ ahd_patch0_func, 7, 1, 1 },
+	{ ahd_patch3_func, 20, 5, 1 },
+	{ ahd_patch2_func, 29, 1, 2 },
+	{ ahd_patch0_func, 30, 1, 1 },
+	{ ahd_patch1_func, 37, 1, 2 },
+	{ ahd_patch0_func, 38, 1, 1 },
+	{ ahd_patch2_func, 43, 1, 2 },
+	{ ahd_patch0_func, 44, 1, 1 },
+	{ ahd_patch2_func, 47, 1, 2 },
+	{ ahd_patch0_func, 48, 1, 1 },
+	{ ahd_patch2_func, 51, 1, 2 },
+	{ ahd_patch0_func, 52, 1, 1 },
+	{ ahd_patch2_func, 65, 1, 2 },
+	{ ahd_patch0_func, 66, 1, 1 },
+	{ ahd_patch2_func, 69, 1, 2 },
+	{ ahd_patch0_func, 70, 1, 1 },
+	{ ahd_patch1_func, 73, 1, 2 },
+	{ ahd_patch0_func, 74, 1, 1 },
+	{ ahd_patch4_func, 107, 1, 1 },
+	{ ahd_patch2_func, 162, 6, 1 },
+	{ ahd_patch1_func, 168, 2, 1 },
+	{ ahd_patch5_func, 170, 1, 1 },
+	{ ahd_patch2_func, 179, 1, 2 },
+	{ ahd_patch0_func, 180, 1, 1 },
+	{ ahd_patch6_func, 181, 2, 2 },
+	{ ahd_patch0_func, 183, 6, 3 },
+	{ ahd_patch2_func, 186, 1, 2 },
+	{ ahd_patch0_func, 187, 1, 1 },
+	{ ahd_patch2_func, 190, 1, 2 },
+	{ ahd_patch0_func, 191, 1, 1 },
+	{ ahd_patch7_func, 193, 2, 1 },
+	{ ahd_patch5_func, 201, 16, 2 },
+	{ ahd_patch0_func, 217, 1, 1 },
+	{ ahd_patch8_func, 237, 2, 1 },
+	{ ahd_patch1_func, 241, 1, 2 },
+	{ ahd_patch0_func, 242, 1, 1 },
+	{ ahd_patch7_func, 245, 2, 1 },
+	{ ahd_patch1_func, 259, 1, 2 },
+	{ ahd_patch0_func, 260, 1, 1 },
+	{ ahd_patch1_func, 263, 1, 2 },
+	{ ahd_patch0_func, 264, 1, 1 },
+	{ ahd_patch2_func, 267, 1, 2 },
+	{ ahd_patch0_func, 268, 1, 1 },
+	{ ahd_patch1_func, 323, 1, 2 },
+	{ ahd_patch0_func, 324, 1, 1 },
+	{ ahd_patch2_func, 332, 1, 2 },
+	{ ahd_patch0_func, 333, 1, 1 },
+	{ ahd_patch2_func, 336, 1, 2 },
+	{ ahd_patch0_func, 337, 1, 1 },
+	{ ahd_patch1_func, 343, 1, 2 },
+	{ ahd_patch0_func, 344, 1, 1 },
+	{ ahd_patch1_func, 346, 1, 2 },
+	{ ahd_patch0_func, 347, 1, 1 },
+	{ ahd_patch9_func, 366, 1, 1 },
+	{ ahd_patch9_func, 369, 1, 1 },
+	{ ahd_patch9_func, 371, 1, 1 },
+	{ ahd_patch9_func, 383, 1, 1 },
+	{ ahd_patch1_func, 393, 1, 2 },
+	{ ahd_patch0_func, 394, 1, 1 },
+	{ ahd_patch1_func, 396, 1, 2 },
+	{ ahd_patch0_func, 397, 1, 1 },
+	{ ahd_patch1_func, 405, 1, 2 },
+	{ ahd_patch0_func, 406, 1, 1 },
+	{ ahd_patch2_func, 419, 1, 2 },
+	{ ahd_patch0_func, 420, 1, 1 },
+	{ ahd_patch10_func, 450, 1, 1 },
+	{ ahd_patch1_func, 457, 1, 2 },
+	{ ahd_patch0_func, 458, 1, 1 },
+	{ ahd_patch2_func, 470, 1, 2 },
+	{ ahd_patch0_func, 471, 1, 1 },
+	{ ahd_patch11_func, 476, 6, 2 },
+	{ ahd_patch0_func, 482, 1, 1 },
+	{ ahd_patch12_func, 505, 1, 1 },
+	{ ahd_patch13_func, 514, 1, 1 },
+	{ ahd_patch14_func, 515, 1, 2 },
+	{ ahd_patch0_func, 516, 1, 1 },
+	{ ahd_patch15_func, 519, 1, 1 },
+	{ ahd_patch14_func, 520, 1, 1 },
+	{ ahd_patch16_func, 531, 1, 2 },
+	{ ahd_patch0_func, 532, 1, 1 },
+	{ ahd_patch1_func, 551, 1, 2 },
+	{ ahd_patch0_func, 552, 1, 1 },
+	{ ahd_patch1_func, 555, 1, 2 },
+	{ ahd_patch0_func, 556, 1, 1 },
+	{ ahd_patch2_func, 561, 1, 2 },
+	{ ahd_patch0_func, 562, 1, 1 },
+	{ ahd_patch2_func, 566, 1, 2 },
+	{ ahd_patch0_func, 567, 1, 1 },
+	{ ahd_patch1_func, 568, 1, 2 },
+	{ ahd_patch0_func, 569, 1, 1 },
+	{ ahd_patch2_func, 580, 1, 2 },
+	{ ahd_patch0_func, 581, 1, 1 },
+	{ ahd_patch17_func, 585, 1, 1 },
+	{ ahd_patch18_func, 590, 1, 1 },
+	{ ahd_patch19_func, 591, 2, 1 },
+	{ ahd_patch18_func, 595, 1, 2 },
+	{ ahd_patch0_func, 596, 1, 1 },
+	{ ahd_patch2_func, 599, 1, 2 },
+	{ ahd_patch0_func, 600, 1, 1 },
+	{ ahd_patch2_func, 615, 1, 2 },
+	{ ahd_patch0_func, 616, 1, 1 },
+	{ ahd_patch20_func, 617, 14, 1 },
+	{ ahd_patch1_func, 635, 1, 2 },
+	{ ahd_patch0_func, 636, 1, 1 },
+	{ ahd_patch20_func, 637, 1, 1 },
+	{ ahd_patch1_func, 649, 1, 2 },
+	{ ahd_patch0_func, 650, 1, 1 },
+	{ ahd_patch1_func, 657, 1, 2 },
+	{ ahd_patch0_func, 658, 1, 1 },
+	{ ahd_patch17_func, 681, 1, 1 },
+	{ ahd_patch17_func, 719, 1, 1 },
+	{ ahd_patch1_func, 730, 1, 2 },
+	{ ahd_patch0_func, 731, 1, 1 },
+	{ ahd_patch1_func, 748, 1, 2 },
+	{ ahd_patch0_func, 749, 1, 1 },
+	{ ahd_patch1_func, 751, 1, 2 },
+	{ ahd_patch0_func, 752, 1, 1 },
+	{ ahd_patch1_func, 755, 1, 2 },
+	{ ahd_patch0_func, 756, 1, 1 },
+	{ ahd_patch21_func, 758, 1, 2 },
+	{ ahd_patch0_func, 759, 2, 1 },
+	{ ahd_patch22_func, 762, 4, 2 },
+	{ ahd_patch0_func, 766, 1, 1 },
+	{ ahd_patch22_func, 774, 11, 1 }
+};
+
+static struct cs {
+	uint16_t	begin;
+	uint16_t	end;
+} critical_sections[] = {
+	{ 11, 12 },
+	{ 13, 14 },
+	{ 29, 42 },
+	{ 56, 59 },
+	{ 101, 128 },
+	{ 129, 157 },
+	{ 159, 162 },
+	{ 170, 178 },
+	{ 201, 250 },
+	{ 681, 697 },
+	{ 697, 711 },
+	{ 721, 725 }
+};
+
+static const int num_critical_sections = sizeof(critical_sections)
+				       / sizeof(*critical_sections);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx.h linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx.h
--- linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx.h	2002-08-03 00:39:44.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx.h	2003-06-26 21:43:22.000000000 +0000
@@ -37,9 +37,9 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.h#45 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.h#79 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx.h,v 1.16.2.13 2002/04/29 19:36:29 gibbs Exp $
+ * $FreeBSD$
  */
 
 #ifndef _AIC7XXX_H_
@@ -93,11 +93,19 @@
 #define	SCB_GET_CHANNEL(ahc, scb) \
 	SCSIID_CHANNEL(ahc, (scb)->hscb->scsiid)
 #define	SCB_GET_LUN(scb) \
-	((scb)->hscb->lun)
+	((scb)->hscb->lun & LID)
 #define SCB_GET_TARGET_OFFSET(ahc, scb)	\
 	(SCB_GET_TARGET(ahc, scb) + (SCB_IS_SCSIBUS_B(ahc, scb) ? 8 : 0))
 #define SCB_GET_TARGET_MASK(ahc, scb) \
 	(0x01 << (SCB_GET_TARGET_OFFSET(ahc, scb)))
+#ifdef AHC_DEBUG
+#define SCB_IS_SILENT(scb)					\
+	((ahc_debug & AHC_SHOW_MASKED_ERRORS) == 0		\
+      && (((scb)->flags & SCB_SILENT) != 0))
+#else
+#define SCB_IS_SILENT(scb)					\
+	(((scb)->flags & SCB_SILENT) != 0)
+#endif
 #define TCL_TARGET_OFFSET(tcl) \
 	((((tcl) >> 4) & TID) >> 4)
 #define TCL_LUN(tcl) \
@@ -171,7 +179,7 @@
 #define AHC_TMODE_CMDS	256
 
 /* Reset line assertion time in us */
-#define AHC_BUSRESET_DELAY	250
+#define AHC_BUSRESET_DELAY	25
 
 /******************* Chip Characteristics/Operating Settings  *****************/
 /*
@@ -310,11 +318,11 @@
  */
 typedef enum {
 	AHC_FNONE	      = 0x000,
-	AHC_PRIMARY_CHANNEL   = 0x003,/*
+	AHC_PRIMARY_CHANNEL   = 0x003,  /*
 					 * The channel that should
 					 * be probed first.
 					 */
-	AHC_USEDEFAULTS	      = 0x004,/*
+	AHC_USEDEFAULTS	      = 0x004,  /*
 					 * For cards without an seeprom
 					 * or a BIOS to initialize the chip's
 					 * SRAM, we use the default target
@@ -322,29 +330,29 @@
 					 */
 	AHC_SEQUENCER_DEBUG   = 0x008,
 	AHC_SHARED_SRAM	      = 0x010,
-	AHC_LARGE_SEEPROM     = 0x020,/* Uses C56_66 not C46 */
+	AHC_LARGE_SEEPROM     = 0x020,  /* Uses C56_66 not C46 */
 	AHC_RESET_BUS_A	      = 0x040,
 	AHC_RESET_BUS_B	      = 0x080,
 	AHC_EXTENDED_TRANS_A  = 0x100,
 	AHC_EXTENDED_TRANS_B  = 0x200,
 	AHC_TERM_ENB_A	      = 0x400,
 	AHC_TERM_ENB_B	      = 0x800,
-	AHC_INITIATORROLE     = 0x1000,/*
+	AHC_INITIATORROLE     = 0x1000,  /*
 					  * Allow initiator operations on
 					  * this controller.
 					  */
-	AHC_TARGETROLE	      = 0x2000,/*
+	AHC_TARGETROLE	      = 0x2000,  /*
 					  * Allow target operations on this
 					  * controller.
 					  */
 	AHC_NEWEEPROM_FMT     = 0x4000,
 	AHC_RESOURCE_SHORTAGE = 0x8000,
-	AHC_TQINFIFO_BLOCKED  = 0x10000,/* Blocked waiting for ATIOs */
-	AHC_INT50_SPEEDFLEX   = 0x20000,/*
+	AHC_TQINFIFO_BLOCKED  = 0x10000,  /* Blocked waiting for ATIOs */
+	AHC_INT50_SPEEDFLEX   = 0x20000,  /*
 					   * Internal 50pin connector
 					   * sits behind an aic3860
 					   */
-	AHC_SCB_BTT	      = 0x40000,/*
+	AHC_SCB_BTT	      = 0x40000,  /*
 					   * The busy targets table is
 					   * stored in SCB space rather
 					   * than SRAM.
@@ -355,14 +363,17 @@
 	AHC_EDGE_INTERRUPT    = 0x800000,  /* Device uses edge triggered ints */
 	AHC_39BIT_ADDRESSING  = 0x1000000, /* Use 39 bit addressing scheme. */
 	AHC_LSCBS_ENABLED     = 0x2000000, /* 64Byte SCBs enabled */
-	AHC_SCB_CONFIG_USED   = 0x4000000  /* No SEEPROM but SCB2 had info. */
+	AHC_SCB_CONFIG_USED   = 0x4000000, /* No SEEPROM but SCB2 had info. */
+	AHC_NO_BIOS_INIT      = 0x8000000, /* No BIOS left over settings. */
+	AHC_DISABLE_PCI_PERR  = 0x10000000,
+	AHC_HAS_TERM_LOGIC    = 0x20000000
 } ahc_flag;
 
 /************************* Hardware  SCB Definition ***************************/
 
 /*
  * The driver keeps up to MAX_SCB scb structures per card in memory.  The SCB
- * consists of a "hardware SCB" mirroring the fields availible on the card
+ * consists of a "hardware SCB" mirroring the fields available on the card
  * and additional information the kernel stores for each transaction.
  *
  * To minimize space utilization, a portion of the hardware scb stores
@@ -534,10 +545,27 @@
 	SCB_RECOVERY_SCB	= 0x0020,
 	SCB_AUTO_NEGOTIATE	= 0x0040,/* Negotiate to achieve goal. */
 	SCB_NEGOTIATE		= 0x0080,/* Negotiation forced for command. */
-	SCB_ABORT		= 0x1000,
-	SCB_UNTAGGEDQ		= 0x2000,
-	SCB_ACTIVE		= 0x4000,
-	SCB_TARGET_IMMEDIATE	= 0x8000
+	SCB_ABORT		= 0x0100,
+	SCB_UNTAGGEDQ		= 0x0200,
+	SCB_ACTIVE		= 0x0400,
+	SCB_TARGET_IMMEDIATE	= 0x0800,
+	SCB_TRANSMISSION_ERROR	= 0x1000,/*
+					  * We detected a parity or CRC
+					  * error that has effected the
+					  * payload of the command.  This
+					  * flag is checked when normal
+					  * status is returned to catch
+					  * the case of a target not
+					  * responding to our attempt
+					  * to report the error.
+					  */
+	SCB_TARGET_SCB		= 0x2000,
+	SCB_SILENT		= 0x4000 /*
+					  * Be quiet about transmission type
+					  * errors.  They are expected and we
+					  * don't want to upset the user.  This
+					  * flag is typically used during DV.
+					  */
 } scb_flag;
 
 struct scb {
@@ -662,6 +690,11 @@
 #define AHC_TRANS_GOAL		0x04	/* Modify negotiation goal */
 #define AHC_TRANS_USER		0x08	/* Modify user negotiation settings */
 
+#define AHC_WIDTH_UNKNOWN	0xFF
+#define AHC_PERIOD_UNKNOWN	0xFF
+#define AHC_OFFSET_UNKNOWN	0xFF
+#define AHC_PPR_OPTS_UNKNOWN	0xFF
+
 /*
  * Transfer Negotiation Information.
  */
@@ -716,10 +749,9 @@
 	char *rate;
 };
 
-/*
- * The synchronouse transfer rate table.
- */
-extern struct ahc_syncrate ahc_syncrates[];
+/* Safe and valid period for async negotiations. */
+#define	AHC_ASYNC_XFER_PERIOD 0x45
+#define	AHC_ULTRA2_XFER_PERIOD 0x0a
 
 /*
  * Indexes into our table of syncronous transfer rates.
@@ -728,6 +760,8 @@
 #define AHC_SYNCRATE_ULTRA2	1
 #define AHC_SYNCRATE_ULTRA	3
 #define AHC_SYNCRATE_FAST	6
+#define AHC_SYNCRATE_MAX	AHC_SYNCRATE_DT
+#define	AHC_SYNCRATE_MIN	13
 
 /***************************** Lookup Tables **********************************/
 /*
@@ -802,7 +836,7 @@
 #define		CFSEAUTOTERM	0x0400	/* Ultra2 Perform secondary Auto Term*/
 #define		CFSELOWTERM	0x0800	/* Ultra2 secondary low term */
 #define		CFSEHIGHTERM	0x1000	/* Ultra2 secondary high term */
-#define		CFDOMAINVAL	0x4000	/* Perform Domain Validation*/
+#define		CFENABLEDV	0x4000	/* Perform Domain Validation*/
 
 /*
  * Bus Release Time, Host Adapter ID
@@ -844,31 +878,40 @@
 /*********************** Software Configuration Structure *********************/
 TAILQ_HEAD(scb_tailq, scb);
 
-struct ahc_suspend_channel_state {
-	uint8_t	scsiseq;
-	uint8_t	sxfrctl0;
-	uint8_t	sxfrctl1;
-	uint8_t	simode0;
-	uint8_t	simode1;
-	uint8_t	seltimer;
-	uint8_t	seqctl;
-};
-
-struct ahc_suspend_state {
-	struct	ahc_suspend_channel_state channel[2];
-	uint8_t	optionmode;
-	uint8_t	dscommand0;
-	uint8_t	dspcistatus;
-	/* hsmailbox */
-	uint8_t	crccontrol1;
-	uint8_t	scbbaddr;
-	/* Host and sequencer SCB counts */
-	uint8_t	dff_thrsh;
-	uint8_t	*scratch_ram;
-	uint8_t	*btt;
+struct ahc_aic7770_softc {
+	/*
+	 * Saved register state used for chip_init().
+	 */
+	uint8_t busspd;
+	uint8_t bustime;
+};
+
+struct ahc_pci_softc {
+	/*
+	 * Saved register state used for chip_init().
+	 */
+	uint32_t  devconfig;
+	uint16_t  targcrccnt;
+	uint8_t   command;
+	uint8_t   csize_lattime;
+	uint8_t   optionmode;
+	uint8_t   crccontrol1;
+	uint8_t   dscommand0;
+	uint8_t   dspcistatus;
+	uint8_t   scbbaddr;
+	uint8_t   dff_thrsh;
+};
+
+union ahc_bus_softc {
+	struct ahc_aic7770_softc aic7770_softc;
+	struct ahc_pci_softc pci_softc;
 };
 
 typedef void (*ahc_bus_intr_t)(struct ahc_softc *);
+typedef int (*ahc_bus_chip_init_t)(struct ahc_softc *);
+typedef int (*ahc_bus_suspend_t)(struct ahc_softc *);
+typedef int (*ahc_bus_resume_t)(struct ahc_softc *);
+typedef void ahc_callback_t (void *);
 
 struct ahc_softc {
 	bus_space_tag_t           tag;
@@ -903,6 +946,11 @@
 	struct scb_tailq	  untagged_queues[AHC_NUM_TARGETS];
 
 	/*
+	 * Bus attachment specific data.
+	 */
+	union ahc_bus_softc	  bus_softc;
+
+	/*
 	 * Platform specific data.
 	 */
 	struct ahc_platform_data *platform_data;
@@ -918,6 +966,22 @@
 	ahc_bus_intr_t		  bus_intr;
 
 	/*
+	 * Bus specific initialization required
+	 * after a chip reset.
+	 */
+	ahc_bus_chip_init_t	  bus_chip_init;
+
+	/*
+	 * Bus specific suspend routine.
+	 */
+	ahc_bus_suspend_t	  bus_suspend;
+
+	/*
+	 * Bus specific resume routine.
+	 */
+	ahc_bus_resume_t	  bus_resume;
+
+	/*
 	 * Target mode related state kept on a per enabled lun basis.
 	 * Targets that are not enabled will have null entries.
 	 * As an initiator, we keep one target entry for our initiator
@@ -983,6 +1047,11 @@
 	uint8_t			  tqinfifonext;
 
 	/*
+	 * Cached copy of the sequencer control register.
+	 */
+	uint8_t			  seqctl;
+
+	/*
 	 * Incoming and outgoing message handling.
 	 */
 	uint8_t			  send_msg_perror;
@@ -1009,9 +1078,6 @@
 	 */
 	bus_addr_t		  dma_bug_buf;
 
-	/* Information saved through suspend/resume cycles */
-	struct ahc_suspend_state  suspend_state;
-
 	/* Number of enabled target mode device on this card */
 	u_int			  enabled_luns;
 
@@ -1021,6 +1087,17 @@
 	/* PCI cacheline size. */
 	u_int			  pci_cachesize;
 
+	/*
+	 * Count of parity errors we have seen as a target.
+	 * We auto-disable parity error checking after seeing
+	 * AHC_PCI_TARGET_PERR_THRESH number of errors.
+	 */
+	u_int			  pci_target_perr_count;
+#define		AHC_PCI_TARGET_PERR_THRESH	10
+
+	/* Maximum number of sequencer instructions supported. */
+	u_int			  instruction_ram_size;
+
 	/* Per-Unit descriptive information */
 	const char		 *description;
 	char			 *name;
@@ -1066,17 +1143,17 @@
 	char			*name;
 	ahc_device_setup_t	*setup;
 };
-extern struct ahc_pci_identity ahc_pci_ident_table [];
+extern struct ahc_pci_identity ahc_pci_ident_table[];
 extern const u_int ahc_num_pci_devs;
 
 /***************************** VL/EISA Declarations ***************************/
 struct aic7770_identity {
 	uint32_t		 full_id;
 	uint32_t		 id_mask;
-	char			*name;
+	const char		*name;
 	ahc_device_setup_t	*setup;
 };
-extern struct aic7770_identity aic7770_ident_table [];
+extern struct aic7770_identity aic7770_ident_table[];
 extern const int ahc_num_aic7770_devs;
 
 #define AHC_EISA_SLOT_OFFSET	0xc00
@@ -1093,6 +1170,7 @@
 struct ahc_pci_identity	*ahc_find_pci_device(ahc_dev_softc_t);
 int			 ahc_pci_config(struct ahc_softc *,
 					struct ahc_pci_identity *);
+int			 ahc_pci_test_register_access(struct ahc_softc *);
 
 /*************************** EISA/VL Front End ********************************/
 struct aic7770_identity *aic7770_find_device(uint32_t);
@@ -1115,6 +1193,7 @@
 struct ahc_softc	*ahc_alloc(void *platform_arg, char *name);
 int			 ahc_softc_init(struct ahc_softc *);
 void			 ahc_controller_info(struct ahc_softc *ahc, char *buf);
+int			 ahc_chip_init(struct ahc_softc *ahc);
 int			 ahc_init(struct ahc_softc *ahc);
 void			 ahc_intr_enable(struct ahc_softc *ahc, int enable);
 void			 ahc_pause_and_flushwork(struct ahc_softc *ahc);
@@ -1126,11 +1205,10 @@
 void			 ahc_set_name(struct ahc_softc *, char *);
 void			 ahc_alloc_scbs(struct ahc_softc *ahc);
 void			 ahc_free(struct ahc_softc *ahc);
-int			 ahc_reset(struct ahc_softc *ahc);
+int			 ahc_reset(struct ahc_softc *ahc, int reinit);
 void			 ahc_shutdown(void *arg);
 
 /*************************** Interrupt Services *******************************/
-void			ahc_pci_intr(struct ahc_softc *ahc);
 void			ahc_clear_intstat(struct ahc_softc *ahc);
 void			ahc_run_qoutfifo(struct ahc_softc *ahc);
 #ifdef AHC_TARGET_MODE
@@ -1191,11 +1269,20 @@
 					   struct ahc_initiator_tinfo *tinfo,
 					   u_int *bus_width,
 					   role_t role);
+/*
+ * Negotiation types.  These are used to qualify if we should renegotiate
+ * even if our goal and current transport parameters are identical.
+ */
+typedef enum {
+	AHC_NEG_TO_GOAL,	/* Renegotiate only if goal and curr differ. */
+	AHC_NEG_IF_NON_ASYNC,	/* Renegotiate so long as goal is non-async. */
+	AHC_NEG_ALWAYS		/* Renegotiat even if goal is async. */
+} ahc_neg_type;
 int			ahc_update_neg_request(struct ahc_softc*,
 					       struct ahc_devinfo*,
 					       struct ahc_tmode_tstate*,
 					       struct ahc_initiator_tinfo*,
-					       int /*force*/);
+					       ahc_neg_type);
 void			ahc_set_width(struct ahc_softc *ahc,
 				      struct ahc_devinfo *devinfo,
 				      u_int width, u_int type, int paused);
@@ -1232,12 +1319,32 @@
 #endif
 /******************************* Debug ***************************************/
 #ifdef AHC_DEBUG
-extern int ahc_debug;
-#define	AHC_SHOWMISC	0x1
-#define	AHC_SHOWSENSE	0x2
+extern uint32_t ahc_debug;
+#define	AHC_SHOW_MISC		0x0001
+#define	AHC_SHOW_SENSE		0x0002
+#define AHC_DUMP_SEEPROM	0x0004
+#define AHC_SHOW_TERMCTL	0x0008
+#define AHC_SHOW_MEMORY		0x0010
+#define AHC_SHOW_MESSAGES	0x0020
+#define	AHC_SHOW_DV		0x0040
+#define AHC_SHOW_SELTO		0x0080
+#define AHC_SHOW_QFULL		0x0200
+#define AHC_SHOW_QUEUE		0x0400
+#define AHC_SHOW_TQIN		0x0800
+#define AHC_SHOW_MASKED_ERRORS	0x1000
+#define AHC_DEBUG_SEQUENCER	0x2000
 #endif
 void			ahc_print_scb(struct scb *scb);
+void			ahc_print_devinfo(struct ahc_softc *ahc,
+					  struct ahc_devinfo *dev);
 void			ahc_dump_card_state(struct ahc_softc *ahc);
+int			ahc_print_register(ahc_reg_parse_entry_t *table,
+					   u_int num_entries,
+					   const char *name,
+					   u_int address,
+					   u_int value,
+					   u_int *cur_column,
+					   u_int wrap_point);
 /******************************* SEEPROM *************************************/
 int		ahc_acquire_seeprom(struct ahc_softc *ahc,
 				    struct seeprom_descriptor *sd);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx.reg linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx.reg
--- linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx.reg	2002-08-03 00:39:44.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx.reg	2003-06-26 21:43:33.000000000 +0000
@@ -37,9 +37,9 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx.reg,v 1.20.2.11 2002/04/29 19:36:30 gibbs Exp $
+ * $FreeBSD$
  */
-VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic7xxx.reg#30 $"
+VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic7xxx.reg#39 $"
 
 /*
  * This file is processed by the aic7xxx_asm utility for use in assembling
@@ -57,14 +57,14 @@
 register SCSISEQ {
 	address			0x000
 	access_mode RW
-	bit	TEMODE		0x80
-	bit	ENSELO		0x40
-	bit	ENSELI		0x20
-	bit	ENRSELI		0x10
-	bit	ENAUTOATNO	0x08
-	bit	ENAUTOATNI	0x04
-	bit	ENAUTOATNP	0x02
-	bit	SCSIRSTO	0x01
+	field	TEMODE		0x80
+	field	ENSELO		0x40
+	field	ENSELI		0x20
+	field	ENRSELI		0x10
+	field	ENAUTOATNO	0x08
+	field	ENAUTOATNI	0x04
+	field	ENAUTOATNP	0x02
+	field	SCSIRSTO	0x01
 }
 
 /*
@@ -74,13 +74,13 @@
 register SXFRCTL0 {
 	address			0x001
 	access_mode RW
-	bit	DFON		0x80
-	bit	DFPEXP		0x40
-	bit	FAST20		0x20
-	bit	CLRSTCNT	0x10
-	bit	SPIOEN		0x08
-	bit	SCAMEN		0x04
-	bit	CLRCHN		0x02
+	field	DFON		0x80
+	field	DFPEXP		0x40
+	field	FAST20		0x20
+	field	CLRSTCNT	0x10
+	field	SPIOEN		0x08
+	field	SCAMEN		0x04
+	field	CLRCHN		0x02
 }
 
 /*
@@ -90,13 +90,13 @@
 register SXFRCTL1 {
 	address			0x002
 	access_mode RW
-	bit	BITBUCKET	0x80
-	bit	SWRAPEN		0x40
-	bit	ENSPCHK		0x20
+	field	BITBUCKET	0x80
+	field	SWRAPEN		0x40
+	field	ENSPCHK		0x20
 	mask	STIMESEL	0x18
-	bit	ENSTIMER	0x04
-	bit	ACTNEGEN	0x02
-	bit	STPWEN		0x01	/* Powered Termination */
+	field	ENSTIMER	0x04
+	field	ACTNEGEN	0x02
+	field	STPWEN		0x01	/* Powered Termination */
 }
 
 /*
@@ -106,14 +106,14 @@
 register SCSISIGI {
 	address			0x003
 	access_mode RO
-	bit	CDI		0x80
-	bit	IOI		0x40
-	bit	MSGI		0x20
-	bit	ATNI		0x10
-	bit	SELI		0x08
-	bit	BSYI		0x04
-	bit	REQI		0x02
-	bit	ACKI		0x01
+	field	CDI		0x80
+	field	IOI		0x40
+	field	MSGI		0x20
+	field	ATNI		0x10
+	field	SELI		0x08
+	field	BSYI		0x04
+	field	REQI		0x02
+	field	ACKI		0x01
 /*
  * Possible phases in SCSISIGI
  */
@@ -137,14 +137,14 @@
 register SCSISIGO {
 	address			0x003
 	access_mode WO
-	bit	CDO		0x80
-	bit	IOO		0x40
-	bit	MSGO		0x20
-	bit	ATNO		0x10
-	bit	SELO		0x08
-	bit	BSYO		0x04
-	bit	REQO		0x02
-	bit	ACKO		0x01
+	field	CDO		0x80
+	field	IOO		0x40
+	field	MSGO		0x20
+	field	ATNO		0x10
+	field	SELO		0x08
+	field	BSYO		0x04
+	field	REQO		0x02
+	field	ACKO		0x01
 /*
  * Possible phases to write into SCSISIG0
  */
@@ -167,9 +167,9 @@
 register SCSIRATE {
 	address			0x004
 	access_mode RW
-	bit	WIDEXFER	0x80		/* Wide transfer control */
-	bit	ENABLE_CRC	0x40		/* CRC for D-Phases */
-	bit	SINGLE_EDGE	0x10		/* Disable DT Transfers */
+	field	WIDEXFER	0x80		/* Wide transfer control */
+	field	ENABLE_CRC	0x40		/* CRC for D-Phases */
+	field	SINGLE_EDGE	0x10		/* Disable DT Transfers */
 	mask	SXFR		0x70		/* Sync transfer rate */
 	mask	SXFR_ULTRA2	0x0f		/* Sync transfer rate */
 	mask	SOFS		0x0f		/* Sync offset */
@@ -185,7 +185,7 @@
 	access_mode RW
 	mask	TID		0xf0		/* Target ID mask */
 	mask	TWIN_TID	0x70
-	bit	TWIN_CHNLB	0x80
+	field	TWIN_CHNLB	0x80
 	mask	OID		0x0f		/* Our ID mask */
 	/*
 	 * SCSI Maximum Offset (p. 4-61 aic7890/91 Data Book)
@@ -225,18 +225,27 @@
 	access_mode RW
 }
 
+/* ALT_MODE registers (Ultra2 and Ultra160 chips) */
+register SXFRCTL2 {
+	address			0x013
+	access_mode RW
+	field	AUTORSTDIS	0x10
+	field	CMDDMAEN	0x08
+	mask	ASYNC_SETUP	0x07
+}
+
 /* ALT_MODE register on Ultra160 chips */
 register OPTIONMODE {
 	address			0x008
 	access_mode RW
-	bit	AUTORATEEN		0x80
-	bit	AUTOACKEN		0x40
-	bit	ATNMGMNTEN		0x20
-	bit	BUSFREEREV		0x10
-	bit	EXPPHASEDIS		0x08
-	bit	SCSIDATL_IMGEN		0x04
-	bit	AUTO_MSGOUT_DE		0x02
-	bit	DIS_MSGIN_DUALEDGE	0x01
+	field	AUTORATEEN		0x80
+	field	AUTOACKEN		0x40
+	field	ATNMGMNTEN		0x20
+	field	BUSFREEREV		0x10
+	field	EXPPHASEDIS		0x08
+	field	SCSIDATL_IMGEN		0x04
+	field	AUTO_MSGOUT_DE		0x02
+	field	DIS_MSGIN_DUALEDGE	0x01
 	mask	OPTIONMODE_DEFAULTS	AUTO_MSGOUT_DE|DIS_MSGIN_DUALEDGE
 }
 
@@ -254,12 +263,12 @@
 register CLRSINT0 {
 	address			0x00b
 	access_mode WO
-	bit	CLRSELDO	0x40
-	bit	CLRSELDI	0x20
-	bit	CLRSELINGO	0x10
-	bit	CLRSWRAP	0x08
-	bit	CLRIOERR	0x08	/* Ultra2 Only */
-	bit	CLRSPIORDY	0x02
+	field	CLRSELDO	0x40
+	field	CLRSELDI	0x20
+	field	CLRSELINGO	0x10
+	field	CLRSWRAP	0x08
+	field	CLRIOERR	0x08	/* Ultra2 Only */
+	field	CLRSPIORDY	0x02
 }
 
 /*
@@ -270,15 +279,15 @@
 register SSTAT0	{
 	address			0x00b
 	access_mode RO
-	bit	TARGET		0x80	/* Board acting as target */
-	bit	SELDO		0x40	/* Selection Done */
-	bit	SELDI		0x20	/* Board has been selected */
-	bit	SELINGO		0x10	/* Selection In Progress */
-	bit	SWRAP		0x08	/* 24bit counter wrap */
-	bit	IOERR		0x08	/* LVD Tranceiver mode changed */
-	bit	SDONE		0x04	/* STCNT = 0x000000 */
-	bit	SPIORDY		0x02	/* SCSI PIO Ready */
-	bit	DMADONE		0x01	/* DMA transfer completed */
+	field	TARGET		0x80	/* Board acting as target */
+	field	SELDO		0x40	/* Selection Done */
+	field	SELDI		0x20	/* Board has been selected */
+	field	SELINGO		0x10	/* Selection In Progress */
+	field	SWRAP		0x08	/* 24bit counter wrap */
+	field	IOERR		0x08	/* LVD Tranceiver mode changed */
+	field	SDONE		0x04	/* STCNT = 0x000000 */
+	field	SPIORDY		0x02	/* SCSI PIO Ready */
+	field	DMADONE		0x01	/* DMA transfer completed */
 }
 
 /*
@@ -288,13 +297,13 @@
 register CLRSINT1 {
 	address			0x00c
 	access_mode WO
-	bit	CLRSELTIMEO	0x80
-	bit	CLRATNO		0x40
-	bit	CLRSCSIRSTI	0x20
-	bit	CLRBUSFREE	0x08
-	bit	CLRSCSIPERR	0x04
-	bit	CLRPHASECHG	0x02
-	bit	CLRREQINIT	0x01
+	field	CLRSELTIMEO	0x80
+	field	CLRATNO		0x40
+	field	CLRSCSIRSTI	0x20
+	field	CLRBUSFREE	0x08
+	field	CLRSCSIPERR	0x04
+	field	CLRPHASECHG	0x02
+	field	CLRREQINIT	0x01
 }
 
 /*
@@ -303,14 +312,14 @@
 register SSTAT1	{
 	address			0x00c
 	access_mode RO
-	bit	SELTO		0x80
-	bit	ATNTARG 	0x40
-	bit	SCSIRSTI	0x20
-	bit	PHASEMIS	0x10
-	bit	BUSFREE		0x08
-	bit	SCSIPERR	0x04
-	bit	PHASECHG	0x02
-	bit	REQINIT		0x01
+	field	SELTO		0x80
+	field	ATNTARG 	0x40
+	field	SCSIRSTI	0x20
+	field	PHASEMIS	0x10
+	field	BUSFREE		0x08
+	field	SCSIPERR	0x04
+	field	PHASECHG	0x02
+	field	REQINIT		0x01
 }
 
 /*
@@ -319,13 +328,13 @@
 register SSTAT2 {
 	address			0x00d
 	access_mode RO
-	bit	OVERRUN		0x80
-	bit	SHVALID		0x40	/* Shaddow Layer non-zero */
-	bit	EXP_ACTIVE	0x10	/* SCSI Expander Active */
-	bit	CRCVALERR	0x08	/* CRC doesn't match (U3 only) */
-	bit	CRCENDERR	0x04	/* No terminal CRC packet (U3 only) */
-	bit	CRCREQERR	0x02	/* Illegal CRC packet req (U3 only) */
-	bit	DUAL_EDGE_ERR	0x01	/* Incorrect data phase (U3 only) */
+	field	OVERRUN		0x80
+	field	SHVALID		0x40	/* Shaddow Layer non-zero */
+	field	EXP_ACTIVE	0x10	/* SCSI Expander Active */
+	field	CRCVALERR	0x08	/* CRC doesn't match (U3 only) */
+	field	CRCENDERR	0x04	/* No terminal CRC packet (U3 only) */
+	field	CRCREQERR	0x02	/* Illegal CRC packet req (U3 only) */
+	field	DUAL_EDGE_ERR	0x01	/* Incorrect data phase (U3 only) */
 	mask	SFCNT		0x1f
 }
 
@@ -358,14 +367,14 @@
 register SIMODE0 {
 	address			0x010
 	access_mode RW
-	bit	ENSELDO		0x40
-	bit	ENSELDI		0x20
-	bit	ENSELINGO	0x10
-	bit	ENSWRAP		0x08
-	bit	ENIOERR		0x08	/* LVD Tranceiver mode changes */
-	bit	ENSDONE		0x04
-	bit	ENSPIORDY	0x02
-	bit	ENDMADONE	0x01
+	field	ENSELDO		0x40
+	field	ENSELDI		0x20
+	field	ENSELINGO	0x10
+	field	ENSWRAP		0x08
+	field	ENIOERR		0x08	/* LVD Tranceiver mode changes */
+	field	ENSDONE		0x04
+	field	ENSPIORDY	0x02
+	field	ENDMADONE	0x01
 }
 
 /*
@@ -376,14 +385,14 @@
 register SIMODE1 {
 	address			0x011
 	access_mode RW
-	bit	ENSELTIMO	0x80
-	bit	ENATNTARG	0x40
-	bit	ENSCSIRST	0x20
-	bit	ENPHASEMIS	0x10
-	bit	ENBUSFREE	0x08
-	bit	ENSCSIPERR	0x04
-	bit	ENPHASECHG	0x02
-	bit	ENREQINIT	0x01
+	field	ENSELTIMO	0x80
+	field	ENATNTARG	0x40
+	field	ENSCSIRST	0x20
+	field	ENPHASEMIS	0x10
+	field	ENBUSFREE	0x08
+	field	ENSCSIPERR	0x04
+	field	ENPHASECHG	0x02
+	field	ENREQINIT	0x01
 }
 
 /*
@@ -420,12 +429,12 @@
 register SELTIMER {
 	address			0x018
 	access_mode RW
-	bit	STAGE6		0x20
-	bit	STAGE5		0x10
-	bit	STAGE4		0x08
-	bit	STAGE3		0x04
-	bit	STAGE2		0x02
-	bit	STAGE1		0x01
+	field	STAGE6		0x20
+	field	STAGE5		0x10
+	field	STAGE4		0x08
+	field	STAGE3		0x04
+	field	STAGE2		0x02
+	field	STAGE1		0x01
 	alias	TARGIDIN
 }
 
@@ -438,16 +447,16 @@
 	address			0x019
 	access_mode RW
 	mask	SELID_MASK	0xf0
-	bit	ONEBIT		0x08
+	field	ONEBIT		0x08
 }
 
 register SCAMCTL {
 	address			0x01a
 	access_mode RW
-	bit	ENSCAMSELO	0x80
-	bit	CLRSCAMSELID	0x40
-	bit	ALTSTIM		0x20
-	bit	DFLTTID		0x10
+	field	ENSCAMSELO	0x80
+	field	CLRSCAMSELID	0x40
+	field	ALTSTIM		0x20
+	field	DFLTTID		0x10
 	mask	SCAMLVL		0x03
 }
 
@@ -471,32 +480,32 @@
 register SPIOCAP {
 	address			0x01b
 	access_mode RW
-	bit	SOFT1		0x80
-	bit	SOFT0		0x40
-	bit	SOFTCMDEN	0x20	
-	bit	EXT_BRDCTL	0x10	/* External Board control */
-	bit	SEEPROM		0x08	/* External serial eeprom logic */
-	bit	EEPROM		0x04	/* Writable external BIOS ROM */
-	bit	ROM		0x02	/* Logic for accessing external ROM */
-	bit	SSPIOCPS	0x01	/* Termination and cable detection */
+	field	SOFT1		0x80
+	field	SOFT0		0x40
+	field	SOFTCMDEN	0x20	
+	field	EXT_BRDCTL	0x10	/* External Board control */
+	field	SEEPROM		0x08	/* External serial eeprom logic */
+	field	EEPROM		0x04	/* Writable external BIOS ROM */
+	field	ROM		0x02	/* Logic for accessing external ROM */
+	field	SSPIOCPS	0x01	/* Termination and cable detection */
 }
 
 register BRDCTL	{
 	address			0x01d
-	bit	BRDDAT7		0x80
-	bit	BRDDAT6		0x40
-	bit	BRDDAT5		0x20
-	bit	BRDSTB		0x10
-	bit	BRDCS		0x08
-	bit	BRDRW		0x04
-	bit	BRDCTL1		0x02
-	bit	BRDCTL0		0x01
+	field	BRDDAT7		0x80
+	field	BRDDAT6		0x40
+	field	BRDDAT5		0x20
+	field	BRDSTB		0x10
+	field	BRDCS		0x08
+	field	BRDRW		0x04
+	field	BRDCTL1		0x02
+	field	BRDCTL0		0x01
 	/* 7890 Definitions */
-	bit	BRDDAT4		0x10
-	bit	BRDDAT3		0x08
-	bit	BRDDAT2		0x04
-	bit	BRDRW_ULTRA2	0x02
-	bit	BRDSTB_ULTRA2	0x01
+	field	BRDDAT4		0x10
+	field	BRDDAT3		0x08
+	field	BRDDAT2		0x04
+	field	BRDRW_ULTRA2	0x02
+	field	BRDSTB_ULTRA2	0x01
 }
 
 /*
@@ -525,14 +534,14 @@
  */
 register SEECTL {
 	address			0x01e
-	bit	EXTARBACK	0x80
-	bit	EXTARBREQ	0x40
-	bit	SEEMS		0x20
-	bit	SEERDY		0x10
-	bit	SEECS		0x08
-	bit	SEECK		0x04
-	bit	SEEDO		0x02
-	bit	SEEDI		0x01
+	field	EXTARBACK	0x80
+	field	EXTARBREQ	0x40
+	field	SEEMS		0x20
+	field	SEERDY		0x10
+	field	SEECS		0x08
+	field	SEECK		0x04
+	field	SEEDO		0x02
+	field	SEEDI		0x01
 }
 /*
  * SCSI Block Control (p. 3-32)
@@ -544,14 +553,14 @@
 register SBLKCTL {
 	address			0x01f
 	access_mode RW
-	bit	DIAGLEDEN	0x80	/* Aic78X0 only */
-	bit	DIAGLEDON	0x40	/* Aic78X0 only */
-	bit	AUTOFLUSHDIS	0x20
-	bit	SELBUSB		0x08
-	bit	ENAB40		0x08	/* LVD transceiver active */
-	bit	ENAB20		0x04	/* SE/HVD transceiver active */
-	bit	SELWIDE		0x02
-	bit	XCVR		0x01	/* External transceiver active */
+	field	DIAGLEDEN	0x80	/* Aic78X0 only */
+	field	DIAGLEDON	0x40	/* Aic78X0 only */
+	field	AUTOFLUSHDIS	0x20
+	field	SELBUSB		0x08
+	field	ENAB40		0x08	/* LVD transceiver active */
+	field	ENAB20		0x04	/* SE/HVD transceiver active */
+	field	SELWIDE		0x02
+	field	XCVR		0x01	/* External transceiver active */
 }
 
 /*
@@ -561,14 +570,14 @@
 register SEQCTL {
 	address			0x060
 	access_mode RW
-	bit	PERRORDIS	0x80
-	bit	PAUSEDIS	0x40
-	bit	FAILDIS		0x20
-	bit	FASTMODE	0x10
-	bit	BRKADRINTEN	0x08
-	bit	STEP		0x04
-	bit	SEQRESET	0x02
-	bit	LOADRAM		0x01
+	field	PERRORDIS	0x80
+	field	PAUSEDIS	0x40
+	field	FAILDIS		0x20
+	field	FASTMODE	0x10
+	field	BRKADRINTEN	0x08
+	field	STEP		0x04
+	field	SEQRESET	0x02
+	field	LOADRAM		0x01
 }
 
 /*
@@ -640,8 +649,8 @@
 register FLAGS {
 	address			0x06b
 	access_mode RO
-	bit	ZERO		0x02
-	bit	CARRY		0x01
+	field	ZERO		0x02
+	field	CARRY		0x01
 }
 
 register SINDIR	{
@@ -664,14 +673,16 @@
 	access_mode RO
 }
 
+const	STACK_SIZE	4
+
 /*
  * Board Control (p. 3-43)
  */
 register BCTL {
 	address			0x084
 	access_mode RW
-	bit	ACE		0x08
-	bit	ENABLE		0x01
+	field	ACE		0x08
+	field	ENABLE		0x01
 }
 
 /*
@@ -681,23 +692,23 @@
 register DSCOMMAND0 {
 	address			0x084
 	access_mode RW
-	bit	CACHETHEN	0x80	/* Cache Threshold enable */
-	bit	DPARCKEN	0x40	/* Data Parity Check Enable */
-	bit	MPARCKEN	0x20	/* Memory Parity Check Enable */
-	bit	EXTREQLCK	0x10	/* External Request Lock */
+	field	CACHETHEN	0x80	/* Cache Threshold enable */
+	field	DPARCKEN	0x40	/* Data Parity Check Enable */
+	field	MPARCKEN	0x20	/* Memory Parity Check Enable */
+	field	EXTREQLCK	0x10	/* External Request Lock */
 	/* aic7890/91/96/97 only */
-	bit	INTSCBRAMSEL	0x08	/* Internal SCB RAM Select */
-	bit	RAMPS		0x04	/* External SCB RAM Present */
-	bit	USCBSIZE32	0x02	/* Use 32byte SCB Page Size */
-	bit	CIOPARCKEN	0x01	/* Internal bus parity error enable */
+	field	INTSCBRAMSEL	0x08	/* Internal SCB RAM Select */
+	field	RAMPS		0x04	/* External SCB RAM Present */
+	field	USCBSIZE32	0x02	/* Use 32byte SCB Page Size */
+	field	CIOPARCKEN	0x01	/* Internal bus parity error enable */
 }
 
 register DSCOMMAND1 {
 	address			0x085
 	access_mode RW
 	mask	DSLATT		0xfc	/* PCI latency timer (non-ultra2) */
-	bit	HADDLDSEL1	0x02	/* Host Address Load Select Bits */
-	bit	HADDLDSEL0	0x01
+	field	HADDLDSEL1	0x02	/* Host Address Load Select Bits */
+	field	HADDLDSEL0	0x01
 }
 
 /*
@@ -747,13 +758,13 @@
 register HCNTRL {
 	address			0x087
 	access_mode RW
-	bit	POWRDN		0x40
-	bit	SWINT		0x10
-	bit	IRQMS		0x08
-	bit	PAUSE		0x04
-	bit	INTEN		0x02
-	bit	CHIPRST		0x01
-	bit	CHIPRSTACK	0x01
+	field	POWRDN		0x40
+	field	SWINT		0x10
+	field	IRQMS		0x08
+	field	PAUSE		0x04
+	field	INTEN		0x02
+	field	CHIPRST		0x01
+	field	CHIPRSTACK	0x01
 }
 
 /*
@@ -789,13 +800,13 @@
 register INTSTAT {
 	address			0x091
 	access_mode RW
-	bit	BRKADRINT 0x08
-	bit	SCSIINT	  0x04
-	bit	CMDCMPLT  0x02
-	bit	SEQINT    0x01
+	field	BRKADRINT 0x08
+	field	SCSIINT	  0x04
+	field	CMDCMPLT  0x02
+	field	SEQINT    0x01
 	mask	BAD_PHASE	SEQINT		/* unknown scsi bus phase */
 	mask	SEND_REJECT	0x10|SEQINT	/* sending a message reject */
-	mask	NO_IDENT	0x20|SEQINT	/* no IDENTIFY after reconnect*/
+	mask	PROTO_VIOLATION	0x20|SEQINT	/* SCSI protocol violation */ 
 	mask	NO_MATCH	0x30|SEQINT	/* no cmd match for reconnect */
 	mask	IGN_WIDE_RES	0x40|SEQINT	/* Complex IGN Wide Res Msg */
 	mask	PDATA_REINIT	0x50|SEQINT	/*
@@ -858,14 +869,14 @@
 register ERROR {
 	address			0x092
 	access_mode RO
-	bit	CIOPARERR	0x80	/* Ultra2 only */
-	bit	PCIERRSTAT	0x40	/* PCI only */
-	bit	MPARERR		0x20	/* PCI only */
-	bit	DPARERR		0x10	/* PCI only */
-	bit	SQPARERR	0x08
-	bit	ILLOPCODE	0x04
-	bit	ILLSADDR	0x02
-	bit	ILLHADDR	0x01
+	field	CIOPARERR	0x80	/* Ultra2 only */
+	field	PCIERRSTAT	0x40	/* PCI only */
+	field	MPARERR		0x20	/* PCI only */
+	field	DPARERR		0x10	/* PCI only */
+	field	SQPARERR	0x08
+	field	ILLOPCODE	0x04
+	field	ILLSADDR	0x02
+	field	ILLHADDR	0x01
 }
 
 /*
@@ -874,39 +885,39 @@
 register CLRINT {
 	address			0x092
 	access_mode WO
-	bit	CLRPARERR	0x10	/* PCI only */
-	bit	CLRBRKADRINT	0x08
-	bit	CLRSCSIINT      0x04
-	bit	CLRCMDINT 	0x02
-	bit	CLRSEQINT 	0x01
+	field	CLRPARERR	0x10	/* PCI only */
+	field	CLRBRKADRINT	0x08
+	field	CLRSCSIINT      0x04
+	field	CLRCMDINT 	0x02
+	field	CLRSEQINT 	0x01
 }
 
 register DFCNTRL {
 	address			0x093
 	access_mode RW
-	bit	PRELOADEN	0x80	/* aic7890 only */
-	bit	WIDEODD		0x40
-	bit	SCSIEN		0x20
-	bit	SDMAEN		0x10
-	bit	SDMAENACK	0x10
-	bit	HDMAEN		0x08
-	bit	HDMAENACK	0x08
-	bit	DIRECTION	0x04
-	bit	FIFOFLUSH	0x02
-	bit	FIFORESET	0x01
+	field	PRELOADEN	0x80	/* aic7890 only */
+	field	WIDEODD		0x40
+	field	SCSIEN		0x20
+	field	SDMAEN		0x10
+	field	SDMAENACK	0x10
+	field	HDMAEN		0x08
+	field	HDMAENACK	0x08
+	field	DIRECTION	0x04
+	field	FIFOFLUSH	0x02
+	field	FIFORESET	0x01
 }
 
 register DFSTATUS {
 	address			0x094
 	access_mode RO
-	bit	PRELOAD_AVAIL	0x80
-	bit	DFCACHETH	0x40
-	bit	FIFOQWDEMP	0x20
-	bit	MREQPEND	0x10
-	bit	HDONE		0x08
-	bit	DFTHRESH	0x04
-	bit	FIFOFULL	0x02
-	bit	FIFOEMP		0x01
+	field	PRELOAD_AVAIL	0x80
+	field	DFCACHETH	0x40
+	field	FIFOQWDEMP	0x20
+	field	MREQPEND	0x10
+	field	HDONE		0x08
+	field	DFTHRESH	0x04
+	field	FIFOFULL	0x02
+	field	FIFOEMP		0x01
 }
 
 register DFWADDR {
@@ -932,7 +943,7 @@
 register SCBCNT {
 	address			0x09a
 	access_mode RW
-	bit	SCBAUTO		0x80
+	field	SCBAUTO		0x80
 	mask	SCBCNT_MASK	0x1f
 }
 
@@ -966,12 +977,12 @@
 register CRCCONTROL1 {
 	address			0x09d
 	access_mode RW
-	bit	CRCONSEEN		0x80
-	bit	CRCVALCHKEN		0x40
-	bit	CRCENDCHKEN		0x20
-	bit	CRCREQCHKEN		0x10
-	bit	TARGCRCENDEN		0x08
-	bit	TARGCRCCNTEN		0x04
+	field	CRCONSEEN		0x80
+	field	CRCVALCHKEN		0x40
+	field	CRCENDCHKEN		0x20
+	field	CRCREQCHKEN		0x10
+	field	TARGCRCENDEN		0x08
+	field	TARGCRCCNTEN		0x04
 }
 
 
@@ -987,12 +998,12 @@
 register SCSIPHASE {
 	address			0x09e
 	access_mode RO
-	bit	STATUS_PHASE	0x20
-	bit	COMMAND_PHASE	0x10
-	bit	MSG_IN_PHASE	0x08
-	bit	MSG_OUT_PHASE	0x04
-	bit	DATA_IN_PHASE	0x02
-	bit	DATA_OUT_PHASE	0x01
+	field	STATUS_PHASE	0x20
+	field	COMMAND_PHASE	0x10
+	field	MSG_IN_PHASE	0x08
+	field	MSG_OUT_PHASE	0x04
+	field	DATA_IN_PHASE	0x02
+	field	DATA_OUT_PHASE	0x01
 	mask	DATA_PHASE_MASK	0x03
 }
 
@@ -1002,7 +1013,7 @@
 register SFUNCT {
 	address			0x09f
 	access_mode RW
-	bit	ALT_MODE	0x80
+	field	ALT_MODE	0x80
 }
 
 /*
@@ -1041,34 +1052,36 @@
 		 * the data address.
 		 */
 		size	4
-		bit	SG_LAST_SEG		0x80	/* In the fourth byte */
+		field	SG_LAST_SEG		0x80	/* In the fourth byte */
 		mask	SG_HIGH_ADDR_BITS	0x7F	/* In the fourth byte */
 	}
 	SCB_SGPTR {
 		size	4
-		bit	SG_RESID_VALID	0x04	/* In the first byte */
-		bit	SG_FULL_RESID	0x02	/* In the first byte */
-		bit	SG_LIST_NULL	0x01	/* In the first byte */
+		field	SG_RESID_VALID	0x04	/* In the first byte */
+		field	SG_FULL_RESID	0x02	/* In the first byte */
+		field	SG_LIST_NULL	0x01	/* In the first byte */
 	}
 	SCB_CONTROL {
 		size	1
-		bit	TARGET_SCB			0x80
-		bit	DISCENB				0x40
-		bit	TAG_ENB				0x20
-		bit	MK_MESSAGE			0x10
-		bit	ULTRAENB			0x08
-		bit	DISCONNECTED			0x04
+		field	TARGET_SCB			0x80
+		field	STATUS_RCVD			0x80
+		field	DISCENB				0x40
+		field	TAG_ENB				0x20
+		field	MK_MESSAGE			0x10
+		field	ULTRAENB			0x08
+		field	DISCONNECTED			0x04
 		mask	SCB_TAG_TYPE			0x03
 	}
 	SCB_SCSIID {
 		size	1
-		bit	TWIN_CHNLB			0x80
+		field	TWIN_CHNLB			0x80
 		mask	TWIN_TID			0x70
 		mask	TID				0xf0
 		mask	OID				0x0f
 	}
 	SCB_LUN {
-		mask	LID				0xff
+		field	SCB_XFERLEN_ODD			0x80
+		mask	LID				0x3f
 		size	1
 	}
 	SCB_TAG {
@@ -1105,18 +1118,18 @@
 register SEECTL_2840 {
 	address			0x0c0
 	access_mode RW
-	bit	CS_2840		0x04
-	bit	CK_2840		0x02
-	bit	DO_2840		0x01
+	field	CS_2840		0x04
+	field	CK_2840		0x02
+	field	DO_2840		0x01
 }
 
 register STATUS_2840 {
 	address			0x0c1
 	access_mode RW
-	bit	EEPROM_TF	0x80
+	field	EEPROM_TF	0x80
 	mask	BIOS_SEL	0x60
 	mask	ADSEL		0x1e
-	bit	DI_2840		0x01
+	field	DI_2840		0x01
 }
 
 /* --------------------- AIC-7870-only definitions -------------------- */
@@ -1140,10 +1153,10 @@
 
 register CCSGCTL {
 	address			0x0EB
-	bit	CCSGDONE	0x80
-	bit	CCSGEN		0x08
-	bit	SG_FETCH_NEEDED 0x02	/* Bit used for software state */
-	bit	CCSGRESET	0x01
+	field	CCSGDONE	0x80
+	field	CCSGEN		0x08
+	field	SG_FETCH_NEEDED 0x02	/* Bit used for software state */
+	field	CCSGRESET	0x01
 }
 
 register CCSCBCNT {
@@ -1152,12 +1165,12 @@
 
 register CCSCBCTL {
 	address			0x0EE
-	bit	CCSCBDONE	0x80
-	bit	ARRDONE		0x40	/* SCB Array prefetch done */
-	bit	CCARREN		0x10
-	bit	CCSCBEN		0x08
-	bit	CCSCBDIR	0x04
-	bit	CCSCBRESET	0x01
+	field	CCSCBDONE	0x80
+	field	ARRDONE		0x40	/* SCB Array prefetch done */
+	field	CCARREN		0x10
+	field	CCSCBEN		0x08
+	field	CCSCBDIR	0x04
+	field	CCSCBRESET	0x01
 }
 
 register CCSCBADDR {
@@ -1194,9 +1207,9 @@
 
 register QOFF_CTLSTA {
 	address			0x0FA
-	bit	SCB_AVAIL	0x40
-	bit	SNSCB_ROLLOVER	0x20
-	bit	SDSCB_ROLLOVER	0x10
+	field	SCB_AVAIL	0x40
+	field	SNSCB_ROLLOVER	0x20
+	field	SDSCB_ROLLOVER	0x10
 	mask	SCB_QSIZE	0x07
 	mask	SCB_QSIZE_256	0x06
 }
@@ -1227,18 +1240,16 @@
 	access_mode WO
 	address			0x0fc
 	mask	SG_ADDR_MASK	0xf8
-	bit	ODD_SEG		0x04
-	bit	LAST_SEG	0x02
-	bit	LAST_SEG_DONE	0x01
+	field	LAST_SEG	0x02
+	field	LAST_SEG_DONE	0x01
 }
 
 register SG_CACHE_SHADOW {
 	access_mode RO
 	address			0x0fc
 	mask	SG_ADDR_MASK	0xf8
-	bit	ODD_SEG		0x04
-	bit	LAST_SEG	0x02
-	bit	LAST_SEG_DONE	0x01
+	field	LAST_SEG	0x02
+	field	LAST_SEG_DONE	0x01
 }
 /* ---------------------- Scratch RAM Offsets ------------------------- */
 /* These offsets are either to values that are initialized by the board's
@@ -1295,6 +1306,7 @@
 	 */
 	MWI_RESIDUAL {
 		size		1
+		alias	TARG_IMMEDIATE_SCB
 	}
 	/*
 	 * SCBID of the next SCB to be started by the controller.
@@ -1312,28 +1324,29 @@
 	/* Parameters for DMA Logic */
 	DMAPARAMS {
 		size		1
-		bit	PRELOADEN	0x80
-		bit	WIDEODD		0x40
-		bit	SCSIEN		0x20
-		bit	SDMAEN		0x10
-		bit	SDMAENACK	0x10
-		bit	HDMAEN		0x08
-		bit	HDMAENACK	0x08
-		bit	DIRECTION	0x04	/* Set indicates PCI->SCSI */
-		bit	FIFOFLUSH	0x02
-		bit	FIFORESET	0x01
+		field	PRELOADEN	0x80
+		field	WIDEODD		0x40
+		field	SCSIEN		0x20
+		field	SDMAEN		0x10
+		field	SDMAENACK	0x10
+		field	HDMAEN		0x08
+		field	HDMAENACK	0x08
+		field	DIRECTION	0x04	/* Set indicates PCI->SCSI */
+		field	FIFOFLUSH	0x02
+		field	FIFORESET	0x01
 	}
 	SEQ_FLAGS {
 		size		1
-		bit	IDENTIFY_SEEN		0x80
-		bit	TARGET_CMD_IS_TAGGED	0x40
-		bit	DPHASE			0x20
+		field	NOT_IDENTIFIED		0x80
+		field	NO_CDB_SENT		0x40
+		field	TARGET_CMD_IS_TAGGED	0x40
+		field	DPHASE			0x20
 		/* Target flags */
-		bit	TARG_CMD_PENDING	0x10
-		bit	CMDPHASE_PENDING	0x08
-		bit	DPHASE_PENDING		0x04
-		bit	SPHASE_PENDING		0x02
-		bit	NO_DISCONNECT		0x01
+		field	TARG_CMD_PENDING	0x10
+		field	CMDPHASE_PENDING	0x08
+		field	DPHASE_PENDING		0x04
+		field	SPHASE_PENDING		0x02
+		field	NO_DISCONNECT		0x01
 	}
 	/*
 	 * Temporary storage for the
@@ -1351,9 +1364,9 @@
 	 */
 	LASTPHASE {
 		size		1
-		bit	CDI		0x80
-		bit	IOI		0x40
-		bit	MSGI		0x20
+		field	CDI		0x80
+		field	IOI		0x40
+		field	MSGI		0x20
 		mask	PHASE_MASK	CDI|IOI|MSGI
 		mask	P_DATAOUT	0x00
 		mask	P_DATAIN	IOI
@@ -1457,20 +1470,12 @@
 	 */
 	SCSISEQ_TEMPLATE {
 		size		1
-		bit	ENSELO		0x40
-		bit	ENSELI		0x20
-		bit	ENRSELI		0x10
-		bit	ENAUTOATNO	0x08
-		bit	ENAUTOATNI	0x04
-		bit	ENAUTOATNP	0x02
-	}
-
-	/*
-	 * Track whether the transfer byte count for
-	 * the current data phase is odd.
-	 */
-	DATA_COUNT_ODD {
-		size		1
+		field	ENSELO		0x40
+		field	ENSELI		0x20
+		field	ENRSELI		0x10
+		field	ENAUTOATNO	0x08
+		field	ENAUTOATNI	0x04
+		field	ENAUTOATNP	0x02
 	}
 }
 
@@ -1488,14 +1493,14 @@
 	 */
 	HA_274_BIOSGLOBAL {
 		size	1
-		bit	HA_274_EXTENDED_TRANS	0x01
+		field	HA_274_EXTENDED_TRANS	0x01
 		alias	INITIATOR_TAG
 	}
 
 	SEQ_FLAGS2 {
 		size	1
-		bit	SCB_DMA			0x01
-		bit	TARGET_MSG_PENDING	0x02
+		field	SCB_DMA			0x01
+		field	TARGET_MSG_PENDING	0x02
 	}
 }
 
@@ -1513,16 +1518,16 @@
 	 */
 	SCSICONF {
 		size		1
-		bit	TERM_ENB	0x80
-		bit	RESET_SCSI	0x40
-		bit	ENSPCHK		0x20
+		field	TERM_ENB	0x80
+		field	RESET_SCSI	0x40
+		field	ENSPCHK		0x20
 		mask	HSCSIID		0x07	/* our SCSI ID */
 		mask	HWSCSIID	0x0f	/* our SCSI ID if Wide Bus */
 	}
 	INTDEF {
 		address		0x05c
 		size		1
-		bit	EDGE_TRIG	0x80
+		field	EDGE_TRIG	0x80
 		mask	VECTOR		0x0f
 	}
 	HOSTCONF {
@@ -1534,7 +1539,7 @@
 		size		1
 		mask	BIOSMODE		0x30
 		mask	BIOSDISABLED		0x30	
-		bit	CHANNEL_B_PRIMARY	0x08
+		field	CHANNEL_B_PRIMARY	0x08
 	}
 }
 
@@ -1566,6 +1571,7 @@
 const MAX_OFFSET_8BIT		0x0f
 const MAX_OFFSET_16BIT		0x08
 const MAX_OFFSET_ULTRA2		0x7f
+const MAX_OFFSET		0x7f
 const HOST_MSG			0xff
 
 /* Target mode command processing constants */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx.seq linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx.seq
--- linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx.seq	2002-08-03 00:39:44.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx.seq	2003-06-26 21:43:30.000000000 +0000
@@ -37,11 +37,12 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx.seq,v 1.94.2.16 2002/04/29 19:36:30 gibbs Exp $
+ * $FreeBSD$
  */
 
-VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic7xxx.seq#43 $"
+VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic7xxx.seq#56 $"
 PATCH_ARG_LIST = "struct ahc_softc *ahc"
+PREFIX = "ahc_"
 
 #include "aic7xxx.reg"
 #include "scsi_message.h"
@@ -69,7 +70,7 @@
 	 * Turn off the selection hardware.  We need to reset the
 	 * selection request in order to perform a new selection.
 	 */
-	and	SCSISEQ, TEMODE|ENSELI|ENRSELI|ENAUTOATNP, SCSISEQ;
+	and	SCSISEQ, TEMODE|ENSELI|ENRSELI|ENAUTOATNP;
 	and	SIMODE1, ~ENBUSFREE;
 poll_for_work:
 	call	clear_target_state;
@@ -192,7 +193,7 @@
 		 * Setup the DMA for sending the identify and
 		 * command information.
 		 */
-		or	SEQ_FLAGS, CMDPHASE_PENDING;
+		mvi	SEQ_FLAGS, CMDPHASE_PENDING;
 
 		mov     A, TQINPOS;
 		if ((ahc->features & AHC_CMD_CHAN) != 0) {
@@ -305,7 +306,7 @@
 		} else {
 			mvi	DFDAT, SCB_LIST_NULL;
 		}
-		or	SEQ_FLAGS, TARG_CMD_PENDING|IDENTIFY_SEEN;
+		or	SEQ_FLAGS, TARG_CMD_PENDING;
 		test	SEQ_FLAGS2, TARGET_MSG_PENDING
 			jnz target_mesgout_pending;
 		test	SCSISIGI, ATNI jnz target_mesgout_continue;
@@ -389,13 +390,8 @@
 	}
 
 /*
- * Initialize transfer settings and clear the SCSI channel.
- * SINDEX should contain any additional bit's the client wants
- * set in SXFRCTL0.  We also assume that the current SCB is
- * a valid SCB for the target we wish to talk to.
+ * Initialize transfer settings with SCB provided settings.
  */
-initialize_channel:
-	or	SXFRCTL0, SPIOEN|CLRSTCNT|CLRCHN;
 set_transfer_settings:
 	if ((ahc->features & AHC_ULTRA) != 0) {
 		test	SCB_CONTROL, ULTRAENB jz . + 2;
@@ -441,11 +437,19 @@
 	mov	SCBPTR, WAITING_SCBH;
 	mov	WAITING_SCBH,SCB_NEXT;
 	mov	SAVED_SCSIID, SCB_SCSIID;
-	mov	SAVED_LUN, SCB_LUN;
-	call	initialize_channel;
+	and	SAVED_LUN, LID, SCB_LUN;
+	call	set_transfer_settings;
 	if ((ahc->flags & AHC_TARGETROLE) != 0) {
 		test	SSTAT0, TARGET	jz initiator_select;
 
+		or	SXFRCTL0, CLRSTCNT|CLRCHN;
+
+		/*
+		 * Put tag in connonical location since not
+		 * all connections have an SCB.
+		 */
+		mov	INITIATOR_TAG, SCB_TARGET_ITAG;
+
 		/*
 		 * We've just re-selected an initiator.
 		 * Assert BSY and setup the phase for
@@ -457,7 +461,7 @@
 		/*
 		 * Start out with a simple identify message.
 		 */
-		or	SCB_LUN, MSG_IDENTIFYFLAG call target_outb;
+		or	SAVED_LUN, MSG_IDENTIFYFLAG call target_outb;
 
 		/*
 		 * If we are the result of a tagged command, send
@@ -491,15 +495,16 @@
 		 * on the state of NO_DISCONNECT.
 		 */
 		test	SEQ_FLAGS, NO_DISCONNECT jz target_disconnect; 
-		mov	RETURN_1, ALLZEROS;
+		mvi	TARG_IMMEDIATE_SCB, SCB_LIST_NULL;
 		call	complete_target_cmd;
-		cmp	RETURN_1, CONT_MSG_LOOP jne .;
 		if ((ahc->flags & AHC_PAGESCBS) != 0) {
 			mov	ALLZEROS	call	get_free_or_disc_scb;
 		}
+		cmp	TARG_IMMEDIATE_SCB, SCB_LIST_NULL je .;
 		mvi	DMAPARAMS, HDMAEN|DIRECTION|FIFORESET;
-		mov	SCB_TAG	 call dma_scb;
+		mov	TARG_IMMEDIATE_SCB call dma_scb;
 		call	set_transfer_settings;
+		or	SXFRCTL0, CLRSTCNT|CLRCHN;
 		jmp	target_synccmd;
 
 target_mesgout:
@@ -507,6 +512,7 @@
 target_mesgout_continue:
 		call	target_inb;
 target_mesgout_pending:
+		and	SEQ_FLAGS2, ~TARGET_MSG_PENDING;
 		/* Local Processing goes here... */
 		jmp	host_target_message_loop;
 		
@@ -636,13 +642,14 @@
 
 if ((ahc->flags & AHC_INITIATORROLE) != 0) {
 initiator_select:
+	or	SXFRCTL0, SPIOEN|CLRSTCNT|CLRCHN;
 	/*
 	 * As soon as we get a successful selection, the target
 	 * should go into the message out phase since we have ATN
 	 * asserted.
 	 */
 	mvi	MSG_OUT, MSG_IDENTIFYFLAG;
-	or	SEQ_FLAGS, IDENTIFY_SEEN;
+	mvi	SEQ_FLAGS, NO_CDB_SENT;
 	mvi	CLRSINT0, CLRSELDO;
 
 	/*
@@ -701,7 +708,7 @@
 	}
 	mvi	LASTPHASE, P_BUSFREE;
 	/* clear target specific flags */
-	clr	SEQ_FLAGS ret;
+	mvi	SEQ_FLAGS, NOT_IDENTIFIED|NO_CDB_SENT ret;
 
 sg_advance:
 	clr	A;			/* add sizeof(struct scatter) */
@@ -761,16 +768,12 @@
 		/* Does the hardware have space for another SG entry? */
 		test	DFSTATUS, PRELOAD_AVAIL jz return;
 		bmov 	HADDR, CCSGRAM, 7;
-		test	HCNT[0], 0x1 jz . + 2;
-		xor	DATA_COUNT_ODD, 0x1;
 		bmov	SCB_RESIDUAL_DATACNT[3], CCSGRAM, 1;
 		if ((ahc->flags & AHC_39BIT_ADDRESSING) != 0) {
 			mov	SCB_RESIDUAL_DATACNT[3] call set_hhaddr;
 		}
 		call	sg_advance;
 		mov	SINDEX, SCB_RESIDUAL_SGPTR[0];
-		test	DATA_COUNT_ODD, 0x1 jz . + 2;
-		or	SINDEX, ODD_SEG;
 		test	SCB_RESIDUAL_DATACNT[3], SG_LAST_SEG jz . + 2;
 		or	SINDEX, LAST_SEG;
 		mov	SG_CACHE_PRE, SINDEX;
@@ -815,9 +818,9 @@
 }
 
 p_data:
-	test	SEQ_FLAGS,IDENTIFY_SEEN	jnz p_data_okay;
-	mvi	NO_IDENT jmp set_seqint;
-p_data_okay:
+	test	SEQ_FLAGS,NOT_IDENTIFIED|NO_CDB_SENT jz p_data_allowed;
+	mvi	PROTO_VIOLATION call set_seqint;
+p_data_allowed:
 	if ((ahc->features & AHC_ULTRA2) != 0) {
 		mvi	DMAPARAMS, PRELOADEN|SCSIEN|HDMAEN;
 	} else {
@@ -868,7 +871,6 @@
 		call	calc_mwi_residual;
 	}
 	and	SCB_RESIDUAL_SGPTR[0], ~SG_FULL_RESID;
-	and	DATA_COUNT_ODD, 0x1, HCNT[0];
 
 	if ((ahc->features & AHC_ULTRA2) == 0) {
 		if ((ahc->features & AHC_CMD_CHAN) != 0) {
@@ -903,8 +905,6 @@
 		mov	SINDEX, SCB_RESIDUAL_SGPTR[0];
 		test	SCB_RESIDUAL_DATACNT[3], SG_LAST_SEG jz . + 2;
 		or	SINDEX, LAST_SEG;
-		test	DATA_COUNT_ODD, 0x1 jz . + 2;
-		or	SINDEX, ODD_SEG;
 		mov	SG_CACHE_PRE, SINDEX;
 		mov	DFCNTRL, DMAPARAMS;
 ultra2_dma_loop:
@@ -999,10 +999,8 @@
 		adc	SCB_RESIDUAL_SGPTR[3], -1;
 sgptr_fixup_done:
 		and	SCB_RESIDUAL_SGPTR[0], SG_ADDR_MASK, SG_CACHE_SHADOW;
-		clr	DATA_COUNT_ODD;
-		test	SG_CACHE_SHADOW, ODD_SEG jz . + 2;
-		or	DATA_COUNT_ODD, 0x1;
-		clr	SCB_RESIDUAL_DATACNT[3]; /* We are not the last seg */
+		/* We are not the last seg */
+		and	SCB_RESIDUAL_DATACNT[3], ~SG_LAST_SEG;
 residuals_correct:
 		/*
 		 * Go ahead and shut down the DMA engine now.
@@ -1046,11 +1044,19 @@
 			 * LAST_SEG_DONE to come true on a completed transfer
 			 * and then test to see if the data FIFO is non-empty.
 			 */
-			test	SCB_RESIDUAL_SGPTR[0], SG_LIST_NULL jz . + 4;
+			test	SCB_RESIDUAL_SGPTR[0], SG_LIST_NULL
+				jz ultra2_wait_fifoemp;
 			test	SG_CACHE_SHADOW, LAST_SEG_DONE jz .;
+			/*
+			 * FIFOEMP can lag LAST_SEG_DONE.  Wait a few
+			 * clocks before calling this an overrun.
+			 */
+			test	DFSTATUS, FIFOEMP jnz ultra2_fifoempty;
+			test	DFSTATUS, FIFOEMP jnz ultra2_fifoempty;
 			test	DFSTATUS, FIFOEMP jnz ultra2_fifoempty;
 			/* Overrun */
 			jmp	data_phase_loop;
+ultra2_wait_fifoemp:
 			test	DFSTATUS, FIFOEMP jz .;
 		}
 ultra2_fifoempty:
@@ -1239,9 +1245,6 @@
 		} else {
 			call	set_stcnt_from_hcnt;
 		}
-		/* Track odd'ness */
-		test	HCNT[0], 0x1 jz . + 2;
-		xor	DATA_COUNT_ODD, 0x1;
 
 		if ((ahc->flags & AHC_TARGETROLE) != 0) {
 			test	SSTAT0, TARGET jnz data_phase_loop;
@@ -1343,7 +1346,7 @@
 		 */
 		test	DFCNTRL, DIRECTION jz target_ITloop;
 		test	SSTAT1, REQINIT	jnz .;
-		test	DATA_COUNT_ODD, 0x1 jz target_ITloop;
+		test	SCB_LUN, SCB_XFERLEN_ODD jz target_ITloop;
 		test	SCSIRATE, WIDEXFER jz target_ITloop;
 		/*
 		 * Issue an Ignore Wide Residue Message.
@@ -1361,8 +1364,8 @@
  * Command phase.  Set up the DMA registers and let 'er rip.
  */
 p_command:
-	test	SEQ_FLAGS,IDENTIFY_SEEN	jnz p_command_okay;
-	mvi	NO_IDENT jmp set_seqint;
+	test	SEQ_FLAGS, NOT_IDENTIFIED jz p_command_okay;
+	mvi	PROTO_VIOLATION call set_seqint;
 p_command_okay:
 
 	if ((ahc->features & AHC_ULTRA2) != 0) {
@@ -1394,7 +1397,7 @@
 		}
 		mvi	DFCNTRL, (SCSIEN|SDMAEN|HDMAEN|DIRECTION|FIFORESET);
 	}
-	jmp	p_command_loop;
+	jmp	p_command_xfer;
 p_command_embedded:
 	/*
 	 * The data fifo seems to require 4 byte aligned
@@ -1432,24 +1435,28 @@
 		call	copy_to_fifo_6;
 		or	DFCNTRL, FIFOFLUSH;
 	}
-p_command_loop:
+p_command_xfer:
+	and	SEQ_FLAGS, ~NO_CDB_SENT;
 	if ((ahc->features & AHC_DT) == 0) {
 		test	SSTAT0, SDONE jnz . + 2;
-		test    SSTAT1, PHASEMIS jz p_command_loop;
+		test    SSTAT1, PHASEMIS jz . - 1;
 		/*
 		 * Wait for our ACK to go-away on it's own
 		 * instead of being killed by SCSIEN getting cleared.
 		 */
 		test	SCSISIGI, ACKI jnz .;
 	} else {
-		test	DFCNTRL, SCSIEN jnz p_command_loop;
+		test	DFCNTRL, SCSIEN jnz .;
 	}
+	test	SSTAT0, SDONE jnz p_command_successful;
+	/*
+	 * Don't allow a data phase if the command
+	 * was not fully transferred.
+	 */
+	or	SEQ_FLAGS, NO_CDB_SENT;
+p_command_successful:
 	and	DFCNTRL, ~(SCSIEN|SDMAEN|HDMAEN);
 	test	DFCNTRL, (SCSIEN|SDMAEN|HDMAEN) jnz .;
-	if ((ahc->features & AHC_ULTRA2) != 0) {
-		/* Drop any residual from the S/G Preload queue */
-		or	SXFRCTL0, CLRSTCNT;
-	}
 	jmp	ITloop;
 
 /*
@@ -1457,10 +1464,10 @@
  * and store it into the SCB.
  */
 p_status:
-	test	SEQ_FLAGS,IDENTIFY_SEEN	jnz p_status_okay;
-	mvi	NO_IDENT jmp set_seqint;
+	test	SEQ_FLAGS, NOT_IDENTIFIED jnz mesgin_proto_violation;
 p_status_okay:
 	mov	SCB_SCSI_STATUS, SCSIDATL;
+	or	SCB_CONTROL, STATUS_RCVD;
 	jmp	ITloop;
 
 /*
@@ -1499,7 +1506,7 @@
 	cmp	SINDEX, MSG_IDENTIFYFLAG jne p_mesgout_from_host;
 	test	SCB_CONTROL,MK_MESSAGE	jnz host_message_loop;
 p_mesgout_identify:
-	or	SINDEX, MSG_IDENTIFYFLAG|DISCENB, SCB_LUN;
+	or	SINDEX, MSG_IDENTIFYFLAG|DISCENB, SAVED_LUN;
 	test	SCB_CONTROL, DISCENB jnz . + 2;
 	and	SINDEX, ~DISCENB;
 /*
@@ -1576,18 +1583,20 @@
 	mvi	ARG_1	call inb_next;
 	cmp	ARG_1, 0x01 jne mesgin_reject;
 	test	SCB_RESIDUAL_SGPTR[0], SG_LIST_NULL jz . + 2;
-	test	DATA_COUNT_ODD, 0x1	jz mesgin_done;
+	test	SCB_LUN, SCB_XFERLEN_ODD jnz mesgin_done;
 	mvi	IGN_WIDE_RES call set_seqint;
 	jmp	mesgin_done;
 }
 
+mesgin_proto_violation:
+	mvi	PROTO_VIOLATION call set_seqint;
+	jmp	mesgin_done;
 mesgin_reject:
 	mvi	MSG_MESSAGE_REJECT	call mk_mesg;
 mesgin_done:
 	mov	NONE,SCSIDATL;		/*dummy read from latch to ACK*/
 	jmp	ITloop;
 
-mesgin_complete:
 /*
  * We received a "command complete" message.  Put the SCB_TAG into the QOUTFIFO,
  * and trigger a completion interrupt.  Before doing so, check to see if there
@@ -1600,27 +1609,49 @@
  * it to the QINFIFO and tell us not to post to the QOUTFIFO by setting 
  * RETURN_1 to SEND_SENSE.
  */
+mesgin_complete:
 
-/*
- * If ATN is raised, we still want to give the target a message.
- * Perhaps there was a parity error on this last message byte.
- * Either way, the target should take us to message out phase
- * and then attempt to complete the command again.  We should use a
- * critical section here to guard against a timeout triggering
- * for this command and setting ATN while we are still processing
- * the completion.
+	/*
+	 * If ATN is raised, we still want to give the target a message.
+	 * Perhaps there was a parity error on this last message byte.
+	 * Either way, the target should take us to message out phase
+	 * and then attempt to complete the command again.  We should use a
+	 * critical section here to guard against a timeout triggering
+	 * for this command and setting ATN while we are still processing
+	 * the completion.
 	test	SCSISIGI, ATNI jnz mesgin_done;
- */
+	 */
 
-/*
- * See if we attempted to deliver a message but the target ingnored us.
- */
+	/*
+	 * If we are identified and have successfully sent the CDB,
+	 * any status will do.  Optimize this fast path.
+	 */
+	test	SCB_CONTROL, STATUS_RCVD jz mesgin_proto_violation;
+	test	SEQ_FLAGS, NOT_IDENTIFIED|NO_CDB_SENT jz complete_accepted; 
+
+	/*
+	 * If the target never sent an identify message but instead went
+	 * to mesgin to give an invalid message, let the host abort us.
+	 */
+	test	SEQ_FLAGS, NOT_IDENTIFIED jnz mesgin_proto_violation;
+
+	/*
+	 * If we recevied good status but never successfully sent the
+	 * cdb, abort the command.
+	 */
+	test	SCB_SCSI_STATUS,0xff	jnz complete_accepted;
+	test	SEQ_FLAGS, NO_CDB_SENT jnz mesgin_proto_violation;
+
+complete_accepted:
+	/*
+	 * See if we attempted to deliver a message but the target ingnored us.
+	 */
 	test	SCB_CONTROL, MK_MESSAGE jz . + 2;
 	mvi	MKMSG_FAILED call set_seqint;
 
-/*
- * Check for residuals
- */
+	/*
+	 * Check for residuals
+	 */
 	test	SCB_SGPTR, SG_LIST_NULL jnz check_status;/* No xfer */
 	test	SCB_SGPTR, SG_FULL_RESID jnz upload_scb;/* Never xfered */
 	test	SCB_RESIDUAL_SGPTR, SG_LIST_NULL jz upload_scb;
@@ -1673,14 +1704,15 @@
 	 * XXX - Wait for more testing.
 	test	SCSISIGI, ATNI jnz mesgin_done;
 	 */
-
+	test	SEQ_FLAGS, NOT_IDENTIFIED|NO_CDB_SENT
+		jnz mesgin_proto_violation;
 	or	SCB_CONTROL,DISCONNECTED;
 	if ((ahc->flags & AHC_PAGESCBS) != 0) {
 		call	add_scb_to_disc_list;
 	}
 	test	SCB_CONTROL, TAG_ENB jnz await_busfree;
 	mov	ARG_1, SCB_TAG;
-	mov	SAVED_LUN, SCB_LUN;
+	and	SAVED_LUN, LID, SCB_LUN;
 	mov	SCB_SCSIID	call set_busy_target;
 	jmp	await_busfree;
 
@@ -1741,7 +1773,8 @@
  * Restore pointers message?  Data pointers are recopied from the
  * SCB anytime we enter a data phase for the first time, so all
  * we need to do is clear the DPHASE flag and let the data phase
- * code do the rest.
+ * code do the rest.  We also reset/reallocate the FIFO to make
+ * sure we have a clean start for the next data or command phase.
  */
 mesgin_rdptrs:
 	and	SEQ_FLAGS, ~DPHASE;		/*
@@ -1749,6 +1782,7 @@
 						 * the next time through
 						 * the dataphase.
 						 */
+	or	SXFRCTL0, CLRSTCNT|CLRCHN;
 	jmp	mesgin_done;
 
 /*
@@ -1776,7 +1810,7 @@
 	 * transactions by first looking at the transaction stored in
 	 * the busy target array.  If there is no untagged transaction
 	 * for this target or the transaction is for a different lun, then
-	 * this must be an untagged transaction.
+	 * this must be a tagged transaction.
 	 */
 	shr	SINDEX, 4, SAVED_SCSIID;
 	and	SAVED_LUN, MSG_IDENTIFY_LUNMASK, A;
@@ -1821,7 +1855,7 @@
 		 * at a time.  So, if the lun doesn't match, look
 		 * for a tag message.
 		 */
-		mov	A, SCB_LUN;
+		and	A, LID, SCB_LUN;
 		cmp	SAVED_LUN, A	je setup_SCB_id_lun_okay;
 		if ((ahc->flags & AHC_PAGESCBS) != 0) {
 			/*
@@ -1879,7 +1913,7 @@
 		or	SEQ_FLAGS, 0x8;
 	}
 setup_SCB_id_okay:
-	mov	A, SCB_LUN;
+	and	A, LID, SCB_LUN;
 	cmp	SAVED_LUN, A	jne not_found_cleanup_scb;
 setup_SCB_id_lun_okay:
 	if ((ahc->flags & AHC_SEQUENCER_DEBUG) != 0) {
@@ -1897,7 +1931,7 @@
 		mov	SCBPTR, A;
 	}
 setup_SCB_tagged:
-	mvi	SEQ_FLAGS,IDENTIFY_SEEN;	/* make note of IDENTIFY */
+	clr	SEQ_FLAGS;	/* make note of IDENTIFY */
 	call	set_transfer_settings;
 	/* See if the host wants to send a message upon reconnection */
 	test	SCB_CONTROL, MK_MESSAGE jz mesgin_done;
@@ -2218,9 +2252,9 @@
 			 * available data to force the chip to
 			 * continue the transfer.  This does not
 			 * happen for SCSI transfers as the SCSI module
-			 * will drain the FIFO as data is made available.
+			 * will drain the FIFO as data are made available.
 			 * When the hang occurs, we know that a multiple
-			 * of 8 bytes are in the FIFO because the PCI
+			 * of 8 bytes is in the FIFO because the PCI
 			 * module has an 8 byte input latch that only
 			 * dumps to the FIFO when HCNT == 0 or the
 			 * latch is full.
@@ -2257,7 +2291,6 @@
 		} else {
 			call	dma_finish;
 		}
-		/* If we were putting the SCB, we are done */
 		call	dfdat_in_8;
 		call	dfdat_in_8;
 		call	dfdat_in_8;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_93cx6.c linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_93cx6.c
--- linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_93cx6.c	2002-08-03 00:39:44.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_93cx6.c	2003-06-26 21:43:20.000000000 +0000
@@ -28,9 +28,9 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#15 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#17 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx_93cx6.c,v 1.8.2.5 2002/04/29 19:36:31 gibbs Exp $
+ * $FreeBSD$
  */
 
 /*
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_93cx6.h linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_93cx6.h
--- linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_93cx6.h	2002-08-03 00:39:44.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_93cx6.h	2003-06-26 21:43:16.000000000 +0000
@@ -38,9 +38,9 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#10 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#12 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx_93cx6.h,v 1.7.2.3 2002/04/29 19:36:31 gibbs Exp $
+ * $FreeBSD$
  */
 #ifndef _AIC7XXX_93CX6_H_
 #define _AIC7XXX_93CX6_H_
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_core.c linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_core.c
--- linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_core.c	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_core.c	2003-06-26 21:43:20.000000000 +0000
@@ -1,8 +1,8 @@
 /*
  * Core routines and tables shareable across OS platforms.
  *
- * Copyright (c) 1994-2001 Justin T. Gibbs.
- * Copyright (c) 2000-2001 Adaptec Inc.
+ * Copyright (c) 1994-2002 Justin T. Gibbs.
+ * Copyright (c) 2000-2002 Adaptec Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -37,9 +37,9 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.c#69 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.c#133 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx.c,v 1.41.2.22 2002/04/29 19:36:26 gibbs Exp $
+ * $FreeBSD$
  */
 
 #ifdef __linux__
@@ -144,7 +144,8 @@
 #include "aic7xxx_seq.h"
 
 /**************************** Function Declarations ***************************/
-static void		ahc_force_renegotiation(struct ahc_softc *ahc);
+static void		ahc_force_renegotiation(struct ahc_softc *ahc,
+						struct ahc_devinfo *devinfo);
 static struct ahc_tmode_tstate*
 			ahc_alloc_tstate(struct ahc_softc *ahc,
 					 u_int scsi_id, char channel);
@@ -181,6 +182,7 @@
 					  u_int period, u_int offset,
 					  u_int bus_width, u_int ppr_options);
 static void		ahc_clear_msg_state(struct ahc_softc *ahc);
+static void		ahc_handle_proto_violation(struct ahc_softc *ahc);
 static void		ahc_handle_message_phase(struct ahc_softc *ahc);
 typedef enum {
 	AHCMSG_1B,
@@ -200,7 +202,7 @@
 					    struct ahc_devinfo *devinfo,
 					    cam_status status, char *message,
 					    int verbose_level);
-#if AHC_TARGET_MODE
+#ifdef AHC_TARGET_MODE
 static void		ahc_setup_target_msgin(struct ahc_softc *ahc,
 					       struct ahc_devinfo *devinfo,
 					       struct scb *scb);
@@ -223,7 +225,7 @@
 #ifdef AHC_DUMP_SEQ
 static void		ahc_dumpseq(struct ahc_softc *ahc);
 #endif
-static void		ahc_loadseq(struct ahc_softc *ahc);
+static int		ahc_loadseq(struct ahc_softc *ahc);
 static int		ahc_check_patch(struct ahc_softc *ahc,
 					struct patch **start_patch,
 					u_int start_instr, u_int *skip_addr);
@@ -289,7 +291,7 @@
 			 ahc_inb(ahc, SEQ_FLAGS2) & ~SCB_DMA);
 	}
 	ahc_outb(ahc, MWI_RESIDUAL, 0);
-	ahc_outb(ahc, SEQCTL, FASTMODE);
+	ahc_outb(ahc, SEQCTL, ahc->seqctl);
 	ahc_outb(ahc, SEQADDR0, 0);
 	ahc_outb(ahc, SEQADDR1, 0);
 	ahc_unpause(ahc);
@@ -330,7 +332,7 @@
 			printf("%s: WARNING no command for scb %d "
 			       "(cmdcmplt)\nQOUTPOS = %d\n",
 			       ahc_name(ahc), scb_index,
-			       ahc->qoutfifonext - 1);
+			       (ahc->qoutfifonext - 1) & 0xFF);
 			continue;
 		}
 
@@ -388,7 +390,7 @@
 
 	ahc_dump_card_state(ahc);
 
-	/* Tell everyone that this HBA is no longer availible */
+	/* Tell everyone that this HBA is no longer available */
 	ahc_abort_scbs(ahc, CAM_TARGET_WILDCARD, ALL_CHANNELS,
 		       CAM_LUN_WILDCARD, SCB_LIST_NULL, ROLE_UNKNOWN,
 		       CAM_NO_HBA);
@@ -437,10 +439,10 @@
 		scb_index = ahc_inb(ahc, SCB_TAG);
 		scb = ahc_lookup_scb(ahc, scb_index);
 		if (scb == NULL) {
-			printf("%s:%c:%d: ahc_intr - referenced scb "
+			ahc_print_devinfo(ahc, &devinfo);
+			printf("ahc_intr - referenced scb "
 			       "not valid during seqint 0x%x scb(%d)\n",
-			       ahc_name(ahc), devinfo.channel,
-			       devinfo.target, intstat, scb_index);
+			       intstat, scb_index);
 			ahc_dump_card_state(ahc);
 			panic("for safety");
 			goto unpause;
@@ -478,7 +480,7 @@
 			struct ahc_tmode_tstate *tstate;
 			struct ahc_transinfo *tinfo;
 #ifdef AHC_DEBUG
-			if (ahc_debug & AHC_SHOWSENSE) {
+			if (ahc_debug & AHC_SHOW_SENSE) {
 				ahc_print_path(ahc, scb);
 				printf("SCB %d: requests Check Status\n",
 				       scb->hscb->tag);
@@ -501,7 +503,7 @@
 			 */
 			ahc_update_residual(ahc, scb);
 #ifdef AHC_DEBUG
-			if (ahc_debug & AHC_SHOWSENSE) {
+			if (ahc_debug & AHC_SHOW_SENSE) {
 				ahc_print_path(ahc, scb);
 				printf("Sending Sense\n");
 			}
@@ -545,7 +547,7 @@
 			 == ahc_get_transfer_length(scb)) {
 				ahc_update_neg_request(ahc, &devinfo,
 						       tstate, targ_info,
-						       /*force*/TRUE);
+						       AHC_NEG_IF_NON_ASYNC);
 			}
 			if (tstate->auto_negotiate & devinfo.target_mask) {
 				hscb->control |= MK_MESSAGE;
@@ -561,16 +563,11 @@
 			scb->flags |= SCB_SENSE;
 			ahc_qinfifo_requeue_tail(ahc, scb);
 			ahc_outb(ahc, RETURN_1, SEND_SENSE);
-#ifdef __FreeBSD__
 			/*
 			 * Ensure we have enough time to actually
 			 * retrieve the sense.
 			 */
-			untimeout(ahc_timeout, (caddr_t)scb,
-				  scb->io_ctx->ccb_h.timeout_ch);
-			scb->io_ctx->ccb_h.timeout_ch =
-			    timeout(ahc_timeout, (caddr_t)scb, 5 * hz);
-#endif
+			ahc_scb_timer_reset(scb, 5 * 1000000);
 			break;
 		}
 		default:
@@ -624,27 +621,10 @@
 		       ahc_name(ahc), devinfo.channel, devinfo.target, rejbyte);
 		break; 
 	}
-	case NO_IDENT: 
+	case PROTO_VIOLATION:
 	{
-		/*
-		 * The reconnecting target either did not send an identify
-		 * message, or did, but we didn't find an SCB to match and
-		 * before it could respond to our ATN/abort, it hit a dataphase.
-		 * The only safe thing to do is to blow it away with a bus
-		 * reset.
-		 */
-		int found;
-
-		printf("%s:%c:%d: Target did not send an IDENTIFY message. "
-		       "LASTPHASE = 0x%x, SAVED_SCSIID == 0x%x\n",
-		       ahc_name(ahc), devinfo.channel, devinfo.target,
-		       ahc_inb(ahc, LASTPHASE), ahc_inb(ahc, SAVED_SCSIID));
-		found = ahc_reset_channel(ahc, devinfo.channel, 
-					  /*initiate reset*/TRUE);
-		printf("%s: Issued Channel %c Bus Reset. "
-		       "%d SCBs aborted\n", ahc_name(ahc), devinfo.channel,
-		       found);
-		return;
+		ahc_handle_proto_violation(ahc);
+		break;
 	}
 	case IGN_WIDE_RES:
 		ahc_handle_ign_wide_residue(ahc, &devinfo);
@@ -725,7 +705,7 @@
 					ahc->msgin_index = 0;
 				}
 			}
-#if AHC_TARGET_MODE
+#ifdef AHC_TARGET_MODE
 			else {
 				if (bus_phase == P_MESGOUT) {
 					ahc->msg_type =
@@ -772,7 +752,44 @@
 				ahc_outb(ahc, LASTPHASE, curphase);
 				ahc_outb(ahc, SCSISIGO, curphase);
 			}
-			ahc_inb(ahc, SCSIDATL);
+			if ((ahc_inb(ahc, SCSISIGI) & (CDI|MSGI)) == 0) {
+				int wait;
+
+				/*
+				 * In a data phase.  Faster to bitbucket
+				 * the data than to individually ack each
+				 * byte.  This is also the only strategy
+				 * that will work with AUTOACK enabled.
+				 */
+				ahc_outb(ahc, SXFRCTL1,
+					 ahc_inb(ahc, SXFRCTL1) | BITBUCKET);
+				wait = 5000;
+				while (--wait != 0) {
+					if ((ahc_inb(ahc, SCSISIGI)
+					  & (CDI|MSGI)) != 0)
+						break;
+					ahc_delay(100);
+				}
+				ahc_outb(ahc, SXFRCTL1,
+					 ahc_inb(ahc, SXFRCTL1) & ~BITBUCKET);
+				if (wait == 0) {
+					struct	scb *scb;
+					u_int	scb_index;
+
+					ahc_print_devinfo(ahc, &devinfo);
+					printf("Unable to clear parity error.  "
+					       "Resetting bus.\n");
+					scb_index = ahc_inb(ahc, SCB_TAG);
+					scb = ahc_lookup_scb(ahc, scb_index);
+					if (scb != NULL)
+						ahc_set_transaction_status(scb,
+						    CAM_UNCOR_PARITY);
+					ahc_reset_channel(ahc, devinfo.channel, 
+							  /*init reset*/TRUE);
+				}
+			} else {
+				ahc_inb(ahc, SCSIDATL);
+			}
 		}
 		break;
 	}
@@ -942,9 +959,6 @@
 	char	cur_channel;
 	char	intr_channel;
 
-	/* Make sure the sequencer is in a safe location. */
-	ahc_clear_critical_section(ahc);
-
 	if ((ahc->features & AHC_TWIN) != 0
 	 && ((ahc_inb(ahc, SBLKCTL) & SELBUSB) != 0))
 		cur_channel = 'B';
@@ -973,10 +987,13 @@
 		}
 	}
 
+	/* Make sure the sequencer is in a safe location. */
+	ahc_clear_critical_section(ahc);
+
 	scb_index = ahc_inb(ahc, SCB_TAG);
 	scb = ahc_lookup_scb(ahc, scb_index);
 	if (scb != NULL
-	 && (ahc_inb(ahc, SEQ_FLAGS) & IDENTIFY_SEEN) == 0)
+	 && (ahc_inb(ahc, SEQ_FLAGS) & NOT_IDENTIFIED) != 0)
 		scb = NULL;
 
 	if ((ahc->features & AHC_ULTRA2) != 0
@@ -1016,13 +1033,15 @@
 		 * we should look at the last phase the sequencer recorded,
 		 * or the current phase presented on the bus.
 		 */
-		u_int mesg_out;
-		u_int curphase;
-		u_int errorphase;
-		u_int lastphase;
-		u_int scsirate;
-		u_int i;
-		u_int sstat2;
+		struct	ahc_devinfo devinfo;
+		u_int	mesg_out;
+		u_int	curphase;
+		u_int	errorphase;
+		u_int	lastphase;
+		u_int	scsirate;
+		u_int	i;
+		u_int	sstat2;
+		int	silent;
 
 		lastphase = ahc_inb(ahc, LASTPHASE);
 		curphase = ahc_inb(ahc, SCSISIGI) & PHASE_MASK;
@@ -1050,29 +1069,47 @@
 				break;
 		}
 		mesg_out = ahc_phase_table[i].mesg_out;
-		if (scb != NULL)
-			ahc_print_path(ahc, scb);
-		else
+		silent = FALSE;
+		if (scb != NULL) {
+			if (SCB_IS_SILENT(scb))
+				silent = TRUE;
+			else
+				ahc_print_path(ahc, scb);
+			scb->flags |= SCB_TRANSMISSION_ERROR;
+		} else
 			printf("%s:%c:%d: ", ahc_name(ahc), intr_channel,
 			       SCSIID_TARGET(ahc, ahc_inb(ahc, SAVED_SCSIID)));
 		scsirate = ahc_inb(ahc, SCSIRATE);
-		printf("parity error detected %s. "
-		       "SEQADDR(0x%x) SCSIRATE(0x%x)\n",
-		       ahc_phase_table[i].phasemsg,
-		       ahc_inb(ahc, SEQADDR0) | (ahc_inb(ahc, SEQADDR1) << 8),
-		       scsirate);
-
-		if ((ahc->features & AHC_DT) != 0) {
+		if (silent == FALSE) {
+			printf("parity error detected %s. "
+			       "SEQADDR(0x%x) SCSIRATE(0x%x)\n",
+			       ahc_phase_table[i].phasemsg,
+			       ahc_inw(ahc, SEQADDR0),
+			       scsirate);
+			if ((ahc->features & AHC_DT) != 0) {
+				if ((sstat2 & CRCVALERR) != 0)
+					printf("\tCRC Value Mismatch\n");
+				if ((sstat2 & CRCENDERR) != 0)
+					printf("\tNo terminal CRC packet "
+					       "recevied\n");
+				if ((sstat2 & CRCREQERR) != 0)
+					printf("\tIllegal CRC packet "
+					       "request\n");
+				if ((sstat2 & DUAL_EDGE_ERR) != 0)
+					printf("\tUnexpected %sDT Data Phase\n",
+					       (scsirate & SINGLE_EDGE)
+					     ? "" : "non-");
+			}
+		}
 
-			if ((sstat2 & CRCVALERR) != 0)
-				printf("\tCRC Value Mismatch\n");
-			if ((sstat2 & CRCENDERR) != 0)
-				printf("\tNo terminal CRC packet recevied\n");
-			if ((sstat2 & CRCREQERR) != 0)
-				printf("\tIllegal CRC packet request\n");
-			if ((sstat2 & DUAL_EDGE_ERR) != 0)
-				printf("\tUnexpected %sDT Data Phase\n",
-				       (scsirate & SINGLE_EDGE) ? "" : "non-");
+		if ((ahc->features & AHC_DT) != 0
+		 && (sstat2 & DUAL_EDGE_ERR) != 0) {
+			/*
+			 * This error applies regardless of
+			 * data direction, so ignore the value
+			 * in the phase table.
+			 */
+			mesg_out = MSG_INITIATOR_DET_ERR;
 		}
 
 		/*
@@ -1093,7 +1130,9 @@
 		 * case we are out of sync for some external reason
 		 * unknown (or unreported) by the target.
 		 */
-		ahc_force_renegotiation(ahc);
+		ahc_fetch_devinfo(ahc, &devinfo);
+		ahc_force_renegotiation(ahc, &devinfo);
+
 		ahc_outb(ahc, CLRINT, CLRSCSIINT);
 		ahc_unpause(ahc);
 	} else if ((status & SELTO) != 0) {
@@ -1128,31 +1167,42 @@
 			printf("%s: ahc_intr - referenced scb not "
 			       "valid during SELTO scb(%d, %d)\n",
 			       ahc_name(ahc), scbptr, scb_index);
+			ahc_dump_card_state(ahc);
 		} else {
+			struct ahc_devinfo devinfo;
+#ifdef AHC_DEBUG
+			if ((ahc_debug & AHC_SHOW_SELTO) != 0) {
+				ahc_print_path(ahc, scb);
+				printf("Saw Selection Timeout for SCB 0x%x\n",
+				       scb_index);
+			}
+#endif
+			/*
+			 * Force a renegotiation with this target just in
+			 * case the cable was pulled and will later be
+			 * re-attached.  The target may forget its negotiation
+			 * settings with us should it attempt to reselect
+			 * during the interruption.  The target will not issue
+			 * a unit attention in this case, so we must always
+			 * renegotiate.
+			 */
+			ahc_scb_devinfo(ahc, &devinfo, scb);
+			ahc_force_renegotiation(ahc, &devinfo);
 			ahc_set_transaction_status(scb, CAM_SEL_TIMEOUT);
 			ahc_freeze_devq(ahc, scb);
 		}
 		ahc_outb(ahc, CLRINT, CLRSCSIINT);
-		/*
-		 * Force a renegotiation with this target just in
-		 * case the cable was pulled and will later be
-		 * re-attached.  The target may forget its negotiation
-		 * settings with us should it attempt to reselect
-		 * during the interruption.  The target will not issue
-		 * a unit attention in this case, so we must always
-		 * renegotiate.
-		 */
-		ahc_force_renegotiation(ahc);
 		ahc_restart(ahc);
 	} else if ((status & BUSFREE) != 0
 		&& (ahc_inb(ahc, SIMODE1) & ENBUSFREE) != 0) {
-		u_int lastphase;
-		u_int saved_scsiid;
-		u_int saved_lun;
-		u_int target;
-		u_int initiator_role_id;
-		char channel;
-		int printerror;
+		struct	ahc_devinfo devinfo;
+		u_int	lastphase;
+		u_int	saved_scsiid;
+		u_int	saved_lun;
+		u_int	target;
+		u_int	initiator_role_id;
+		char	channel;
+		int	printerror;
 
 		/*
 		 * Clear our selection hardware as soon as possible.
@@ -1184,13 +1234,13 @@
 		target = SCSIID_TARGET(ahc, saved_scsiid);
 		initiator_role_id = SCSIID_OUR_ID(saved_scsiid);
 		channel = SCSIID_CHANNEL(ahc, saved_scsiid);
+		ahc_compile_devinfo(&devinfo, initiator_role_id,
+				    target, saved_lun, channel, ROLE_INITIATOR);
 		printerror = 1;
 
 		if (lastphase == P_MESGOUT) {
-			struct ahc_devinfo devinfo;
 			u_int tag;
 
-			ahc_fetch_devinfo(ahc, &devinfo);
 			tag = SCB_LIST_NULL;
 			if (ahc_sent_msg(ahc, AHCMSG_1B, MSG_ABORT_TAG, TRUE)
 			 || ahc_sent_msg(ahc, AHCMSG_1B, MSG_ABORT, TRUE)) {
@@ -1254,17 +1304,23 @@
 				ahc_qinfifo_requeue_tail(ahc, scb);
 				printerror = 0;
 			} else if (ahc_sent_msg(ahc, AHCMSG_EXT,
-						MSG_EXT_WDTR, FALSE)
-				|| ahc_sent_msg(ahc, AHCMSG_EXT,
-						MSG_EXT_SDTR, FALSE)) {
+						MSG_EXT_WDTR, FALSE)) {
 				/*
-				 * Negotiation Rejected.  Go-async and
+				 * Negotiation Rejected.  Go-narrow and
 				 * retry command.
 				 */
 				ahc_set_width(ahc, &devinfo,
 					      MSG_EXT_WDTR_BUS_8_BIT,
 					      AHC_TRANS_CUR|AHC_TRANS_GOAL,
 					      /*paused*/TRUE);
+				ahc_qinfifo_requeue_tail(ahc, scb);
+				printerror = 0;
+			} else if (ahc_sent_msg(ahc, AHCMSG_EXT,
+						MSG_EXT_SDTR, FALSE)) {
+				/*
+				 * Negotiation Rejected.  Go-async and
+				 * retry command.
+				 */
 				ahc_set_syncrate(ahc, &devinfo,
 						/*syncrate*/NULL,
 						/*period*/0, /*offset*/0,
@@ -1301,13 +1357,15 @@
 				if (lastphase == ahc_phase_table[i].phase)
 					break;
 			}
-			/*
-			 * Renegotiate with this device at the
-			 * next oportunity just in case this busfree
-			 * is due to a negotiation mismatch with the
-			 * device.
-			 */
-			ahc_force_renegotiation(ahc);
+			if (lastphase != P_BUSFREE) {
+				/*
+				 * Renegotiate with this device at the
+				 * next oportunity just in case this busfree
+				 * is due to a negotiation mismatch with the
+				 * device.
+				 */
+				ahc_force_renegotiation(ahc, &devinfo);
+			}
 			printf("Unexpected busfree %s\n"
 			       "SEQADDR == 0x%x\n",
 			       ahc_phase_table[i].phasemsg,
@@ -1328,20 +1386,18 @@
  * a command to the current device.
  */
 static void
-ahc_force_renegotiation(struct ahc_softc *ahc)
+ahc_force_renegotiation(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
 {
-	struct	ahc_devinfo devinfo;
 	struct	ahc_initiator_tinfo *targ_info;
 	struct	ahc_tmode_tstate *tstate;
 
-	ahc_fetch_devinfo(ahc, &devinfo);
 	targ_info = ahc_fetch_transinfo(ahc,
-					devinfo.channel,
-					devinfo.our_scsiid,
-					devinfo.target,
+					devinfo->channel,
+					devinfo->our_scsiid,
+					devinfo->target,
 					&tstate);
-	ahc_update_neg_request(ahc, &devinfo, tstate,
-			       targ_info, /*force*/TRUE);
+	ahc_update_neg_request(ahc, devinfo, tstate,
+			       targ_info, AHC_NEG_IF_NON_ASYNC);
 }
 
 #define AHC_MAX_STEPS 2000
@@ -1404,11 +1460,26 @@
 			simode0 = ahc_inb(ahc, SIMODE0);
 			ahc_outb(ahc, SIMODE0, 0);
 			simode1 = ahc_inb(ahc, SIMODE1);
-			ahc_outb(ahc, SIMODE1, 0);
+			if ((ahc->features & AHC_DT) != 0)
+				/*
+				 * On DT class controllers, we
+				 * use the enhanced busfree logic.
+				 * Unfortunately we cannot re-enable
+				 * busfree detection within the
+				 * current connection, so we must
+				 * leave it on while single stepping.
+				 */
+				ahc_outb(ahc, SIMODE1, ENBUSFREE);
+			else
+				ahc_outb(ahc, SIMODE1, 0);
 			ahc_outb(ahc, CLRINT, CLRSCSIINT);
-			ahc_outb(ahc, SEQCTL, ahc_inb(ahc, SEQCTL) | STEP);
+			ahc_outb(ahc, SEQCTL, ahc->seqctl | STEP);
 			stepping = TRUE;
 		}
+		if ((ahc->features & AHC_DT) != 0) {
+			ahc_outb(ahc, CLRSINT1, CLRBUSFREE);
+			ahc_outb(ahc, CLRINT, CLRSCSIINT);
+		}
 		ahc_outb(ahc, HCNTRL, ahc->unpause);
 		while (!ahc_is_paused(ahc))
 			ahc_delay(200);
@@ -1416,7 +1487,7 @@
 	if (stepping) {
 		ahc_outb(ahc, SIMODE0, simode0);
 		ahc_outb(ahc, SIMODE1, simode1);
-		ahc_outb(ahc, SEQCTL, ahc_inb(ahc, SEQCTL) & ~STEP);
+		ahc_outb(ahc, SEQCTL, ahc->seqctl);
 	}
 }
 
@@ -1439,7 +1510,7 @@
 
 /**************************** Debugging Routines ******************************/
 #ifdef AHC_DEBUG
-int ahc_debug = AHC_DEBUG;
+uint32_t ahc_debug = AHC_DEBUG_OPTS;
 #endif
 
 void
@@ -1496,7 +1567,8 @@
 	 && ahc->enabled_targets[scsi_id] != master_tstate)
 		panic("%s: ahc_alloc_tstate - Target already allocated",
 		      ahc_name(ahc));
-	tstate = malloc(sizeof(*tstate), M_DEVBUF, M_NOWAIT);
+	tstate = (struct ahc_tmode_tstate*)malloc(sizeof(*tstate),
+						   M_DEVBUF, M_NOWAIT);
 	if (tstate == NULL)
 		return (NULL);
 
@@ -1593,6 +1665,10 @@
 	else 
 		transinfo = &tinfo->goal;
 	*ppr_options &= transinfo->ppr_options;
+	if (transinfo->width == MSG_EXT_WDTR_BUS_8_BIT) {
+		maxsync = MAX(maxsync, AHC_SYNCRATE_ULTRA2);
+		*ppr_options &= ~MSG_EXT_PPR_DT_REQ;
+	}
 	if (transinfo->period == 0) {
 		*period = 0;
 		*ppr_options = 0;
@@ -1769,17 +1845,29 @@
 int
 ahc_update_neg_request(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
 		       struct ahc_tmode_tstate *tstate,
-		       struct ahc_initiator_tinfo *tinfo, int force)
+		       struct ahc_initiator_tinfo *tinfo, ahc_neg_type neg_type)
 {
 	u_int auto_negotiate_orig;
 
 	auto_negotiate_orig = tstate->auto_negotiate;
+	if (neg_type == AHC_NEG_ALWAYS) {
+		/*
+		 * Force our "current" settings to be
+		 * unknown so that unless a bus reset
+		 * occurs the need to renegotiate is
+		 * recorded persistently.
+		 */
+		if ((ahc->features & AHC_WIDE) != 0)
+			tinfo->curr.width = AHC_WIDTH_UNKNOWN;
+		tinfo->curr.period = AHC_PERIOD_UNKNOWN;
+		tinfo->curr.offset = AHC_OFFSET_UNKNOWN;
+	}
 	if (tinfo->curr.period != tinfo->goal.period
 	 || tinfo->curr.width != tinfo->goal.width
 	 || tinfo->curr.offset != tinfo->goal.offset
 	 || tinfo->curr.ppr_options != tinfo->goal.ppr_options
-	 || (force
-	  && (tinfo->goal.period != 0
+	 || (neg_type == AHC_NEG_IF_NON_ASYNC
+	  && (tinfo->goal.offset != 0
 	   || tinfo->goal.width != MSG_EXT_WDTR_BUS_8_BIT
 	   || tinfo->goal.ppr_options != 0)))
 		tstate->auto_negotiate |= devinfo->target_mask;
@@ -1910,7 +1998,7 @@
 	}
 
 	update_needed += ahc_update_neg_request(ahc, devinfo, tstate,
-						tinfo, /*force*/FALSE);
+						tinfo, AHC_NEG_TO_GOAL);
 
 	if (update_needed)
 		ahc_update_pending_scbs(ahc);
@@ -1972,7 +2060,7 @@
 	}
 
 	update_needed += ahc_update_neg_request(ahc, devinfo, tstate,
-						tinfo, /*force*/FALSE);
+						tinfo, AHC_NEG_TO_GOAL);
 	if (update_needed)
 		ahc_update_pending_scbs(ahc);
 }
@@ -2086,7 +2174,8 @@
 
 	if (role == ROLE_TARGET
 	 && (ahc->features & AHC_MULTI_TID) != 0
-	 && (ahc_inb(ahc, SEQ_FLAGS) & CMDPHASE_PENDING) != 0) {
+	 && (ahc_inb(ahc, SEQ_FLAGS)
+ 	   & (CMDPHASE_PENDING|TARG_CMD_PENDING|NO_DISCONNECT)) != 0) {
 		/* We were selected, so pull our id from TARGIDIN */
 		our_id = ahc_inb(ahc, TARGIDIN) & OID;
 	} else if ((ahc->features & AHC_ULTRA2) != 0)
@@ -2136,6 +2225,13 @@
 	devinfo->target_mask = (0x01 << devinfo->target_offset);
 }
 
+void
+ahc_print_devinfo(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
+{
+	printf("%s:%c:%d:%d: ", ahc_name(ahc), devinfo->channel,
+	       devinfo->target, devinfo->lun);
+}
+
 static void
 ahc_scb_devinfo(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
 		struct scb *scb)
@@ -2145,7 +2241,7 @@
 
 	our_id = SCSIID_OUR_ID(scb->hscb->scsiid);
 	role = ROLE_INITIATOR;
-	if ((scb->hscb->control & TARGET_SCB) != 0)
+	if ((scb->flags & SCB_TARGET_SCB) != 0)
 		role = ROLE_TARGET;
 	ahc_compile_devinfo(devinfo, our_id, SCB_GET_TARGET(ahc, scb),
 			    SCB_GET_LUN(scb), SCB_GET_CHANNEL(ahc, scb), role);
@@ -2270,7 +2366,6 @@
 	int	dowide;
 	int	dosync;
 	int	doppr;
-	int	use_ppr;
 	u_int	period;
 	u_int	ppr_options;
 	u_int	offset;
@@ -2284,6 +2379,7 @@
 	 * may change.
 	 */
 	period = tinfo->goal.period;
+	offset = tinfo->goal.offset;
 	ppr_options = tinfo->goal.ppr_options;
 	/* Target initiated PPR is not allowed in the SCSI spec */
 	if (devinfo->role == ROLE_TARGET)
@@ -2291,24 +2387,38 @@
 	rate = ahc_devlimited_syncrate(ahc, tinfo, &period,
 				       &ppr_options, devinfo->role);
 	dowide = tinfo->curr.width != tinfo->goal.width;
-	dosync = tinfo->curr.period != period;
-	doppr = tinfo->curr.ppr_options != ppr_options;
+	dosync = tinfo->curr.offset != offset || tinfo->curr.period != period;
+	/*
+	 * Only use PPR if we have options that need it, even if the device
+	 * claims to support it.  There might be an expander in the way
+	 * that doesn't.
+	 */
+	doppr = ppr_options != 0;
 
 	if (!dowide && !dosync && !doppr) {
 		dowide = tinfo->goal.width != MSG_EXT_WDTR_BUS_8_BIT;
-		dosync = tinfo->goal.period != 0;
-		doppr = tinfo->goal.ppr_options != 0;
+		dosync = tinfo->goal.offset != 0;
 	}
 
 	if (!dowide && !dosync && !doppr) {
-		panic("ahc_intr: AWAITING_MSG for negotiation, "
-		      "but no negotiation needed\n");	
+		/*
+		 * Force async with a WDTR message if we have a wide bus,
+		 * or just issue an SDTR with a 0 offset.
+		 */
+		if ((ahc->features & AHC_WIDE) != 0)
+			dowide = 1;
+		else
+			dosync = 1;
+
+		if (bootverbose) {
+			ahc_print_devinfo(ahc, devinfo);
+			printf("Ensuring async\n");
+		}
 	}
 
-	use_ppr = (tinfo->curr.transport_version >= 3) || doppr;
 	/* Target initiated PPR is not allowed in the SCSI spec */
 	if (devinfo->role == ROLE_TARGET)
-		use_ppr = 0;
+		doppr = 0;
 
 	/*
 	 * Both the PPR message and SDTR message require the
@@ -2318,14 +2428,14 @@
 	 * Regardless, guarantee that if we are using WDTR and SDTR
 	 * messages that WDTR comes first.
 	 */
-	if (use_ppr || (dosync && !dowide)) {
+	if (doppr || (dosync && !dowide)) {
 
 		offset = tinfo->goal.offset;
 		ahc_validate_offset(ahc, tinfo, rate, &offset,
-				    use_ppr ? tinfo->goal.width
-					    : tinfo->curr.width,
+				    doppr ? tinfo->goal.width
+					  : tinfo->curr.width,
 				    devinfo->role);
-		if (use_ppr) {
+		if (doppr) {
 			ahc_construct_ppr(ahc, devinfo, period, offset,
 					  tinfo->goal.width, ppr_options);
 		} else {
@@ -2344,6 +2454,8 @@
 ahc_construct_sdtr(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
 		   u_int period, u_int offset)
 {
+	if (offset == 0)
+		period = AHC_ASYNC_XFER_PERIOD;
 	ahc->msgout_buf[ahc->msgout_index++] = MSG_EXTENDED;
 	ahc->msgout_buf[ahc->msgout_index++] = MSG_EXT_SDTR_LEN;
 	ahc->msgout_buf[ahc->msgout_index++] = MSG_EXT_SDTR;
@@ -2386,6 +2498,8 @@
 		  u_int period, u_int offset, u_int bus_width,
 		  u_int ppr_options)
 {
+	if (offset == 0)
+		period = AHC_ASYNC_XFER_PERIOD;
 	ahc->msgout_buf[ahc->msgout_index++] = MSG_EXTENDED;
 	ahc->msgout_buf[ahc->msgout_index++] = MSG_EXT_PPR_LEN;
 	ahc->msgout_buf[ahc->msgout_index++] = MSG_EXT_PPR;
@@ -2424,6 +2538,100 @@
 		 ahc_inb(ahc, SEQ_FLAGS2) & ~TARGET_MSG_PENDING);
 }
 
+static void
+ahc_handle_proto_violation(struct ahc_softc *ahc)
+{
+	struct	ahc_devinfo devinfo;
+	struct	scb *scb;
+	u_int	scbid;
+	u_int	seq_flags;
+	u_int	curphase;
+	u_int	lastphase;
+	int	found;
+
+	ahc_fetch_devinfo(ahc, &devinfo);
+	scbid = ahc_inb(ahc, SCB_TAG);
+	scb = ahc_lookup_scb(ahc, scbid);
+	seq_flags = ahc_inb(ahc, SEQ_FLAGS);
+	curphase = ahc_inb(ahc, SCSISIGI) & PHASE_MASK;
+	lastphase = ahc_inb(ahc, LASTPHASE);
+	if ((seq_flags & NOT_IDENTIFIED) != 0) {
+
+		/*
+		 * The reconnecting target either did not send an
+		 * identify message, or did, but we didn't find an SCB
+		 * to match.
+		 */
+		ahc_print_devinfo(ahc, &devinfo);
+		printf("Target did not send an IDENTIFY message. "
+		       "LASTPHASE = 0x%x.\n", lastphase);
+		scb = NULL;
+	} else if (scb == NULL) {
+		/*
+		 * We don't seem to have an SCB active for this
+		 * transaction.  Print an error and reset the bus.
+		 */
+		ahc_print_devinfo(ahc, &devinfo);
+		printf("No SCB found during protocol violation\n");
+		goto proto_violation_reset;
+	} else {
+		ahc_set_transaction_status(scb, CAM_SEQUENCE_FAIL);
+		if ((seq_flags & NO_CDB_SENT) != 0) {
+			ahc_print_path(ahc, scb);
+			printf("No or incomplete CDB sent to device.\n");
+		} else if ((ahc_inb(ahc, SCB_CONTROL) & STATUS_RCVD) == 0) {
+			/*
+			 * The target never bothered to provide status to
+			 * us prior to completing the command.  Since we don't
+			 * know the disposition of this command, we must attempt
+			 * to abort it.  Assert ATN and prepare to send an abort
+			 * message.
+			 */
+			ahc_print_path(ahc, scb);
+			printf("Completed command without status.\n");
+		} else {
+			ahc_print_path(ahc, scb);
+			printf("Unknown protocol violation.\n");
+			ahc_dump_card_state(ahc);
+		}
+	}
+	if ((lastphase & ~P_DATAIN_DT) == 0
+	 || lastphase == P_COMMAND) {
+proto_violation_reset:
+		/*
+		 * Target either went directly to data/command
+		 * phase or didn't respond to our ATN.
+		 * The only safe thing to do is to blow
+		 * it away with a bus reset.
+		 */
+		found = ahc_reset_channel(ahc, 'A', TRUE);
+		printf("%s: Issued Channel %c Bus Reset. "
+		       "%d SCBs aborted\n", ahc_name(ahc), 'A', found);
+	} else {
+		/*
+		 * Leave the selection hardware off in case
+		 * this abort attempt will affect yet to
+		 * be sent commands.
+		 */
+		ahc_outb(ahc, SCSISEQ,
+			 ahc_inb(ahc, SCSISEQ) & ~ENSELO);
+		ahc_assert_atn(ahc);
+		ahc_outb(ahc, MSG_OUT, HOST_MSG);
+		if (scb == NULL) {
+			ahc_print_devinfo(ahc, &devinfo);
+			ahc->msgout_buf[0] = MSG_ABORT_TASK;
+			ahc->msgout_len = 1;
+			ahc->msgout_index = 0;
+			ahc->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
+		} else {
+			ahc_print_path(ahc, scb);
+			scb->flags |= SCB_ABORT;
+		}
+		printf("Protocol violation %s.  Attempting to abort.\n",
+		       ahc_lookup_phase_entry(curphase)->phasemsg);
+	}
+}
+
 /*
  * Manual message loop handler.
  */
@@ -2449,8 +2657,21 @@
 		if (ahc->msgout_len == 0)
 			panic("HOST_MSG_LOOP interrupt with no active message");
 
+#ifdef AHC_DEBUG
+		if ((ahc_debug & AHC_SHOW_MESSAGES) != 0) {
+			ahc_print_devinfo(ahc, &devinfo);
+			printf("INITIATOR_MSG_OUT");
+		}
+#endif
 		phasemis = bus_phase != P_MESGOUT;
 		if (phasemis) {
+#ifdef AHC_DEBUG
+			if ((ahc_debug & AHC_SHOW_MESSAGES) != 0) {
+				printf(" PHASEMIS %s\n",
+				       ahc_lookup_phase_entry(bus_phase)
+							     ->phasemsg);
+			}
+#endif
 			if (bus_phase == P_MESGIN) {
 				/*
 				 * Change gears and see if
@@ -2471,6 +2692,10 @@
 		if (ahc->send_msg_perror) {
 			ahc_outb(ahc, CLRSINT1, CLRATNO);
 			ahc_outb(ahc, CLRSINT1, CLRREQINIT);
+#ifdef AHC_DEBUG
+			if ((ahc_debug & AHC_SHOW_MESSAGES) != 0)
+				printf(" byte 0x%x\n", ahc->send_msg_perror);
+#endif
 			ahc_outb(ahc, SCSIDATL, MSG_PARITY_ERROR);
 			break;
 		}
@@ -2497,6 +2722,11 @@
 		 * the next byte on the bus.
 		 */
 		ahc_outb(ahc, CLRSINT1, CLRREQINIT);
+#ifdef AHC_DEBUG
+		if ((ahc_debug & AHC_SHOW_MESSAGES) != 0)
+			printf(" byte 0x%x\n",
+			       ahc->msgout_buf[ahc->msgout_index]);
+#endif
 		ahc_outb(ahc, SCSIDATL, ahc->msgout_buf[ahc->msgout_index++]);
 		break;
 	}
@@ -2505,9 +2735,21 @@
 		int phasemis;
 		int message_done;
 
+#ifdef AHC_DEBUG
+		if ((ahc_debug & AHC_SHOW_MESSAGES) != 0) {
+			ahc_print_devinfo(ahc, &devinfo);
+			printf("INITIATOR_MSG_IN");
+		}
+#endif
 		phasemis = bus_phase != P_MESGIN;
-
 		if (phasemis) {
+#ifdef AHC_DEBUG
+			if ((ahc_debug & AHC_SHOW_MESSAGES) != 0) {
+				printf(" PHASEMIS %s\n",
+				       ahc_lookup_phase_entry(bus_phase)
+							     ->phasemsg);
+			}
+#endif
 			ahc->msgin_index = 0;
 			if (bus_phase == P_MESGOUT
 			 && (ahc->send_msg_perror == TRUE
@@ -2522,6 +2764,11 @@
 
 		/* Pull the byte in without acking it */
 		ahc->msgin_buf[ahc->msgin_index] = ahc_inb(ahc, SCSIBUSL);
+#ifdef AHC_DEBUG
+		if ((ahc_debug & AHC_SHOW_MESSAGES) != 0)
+			printf(" byte 0x%x\n",
+			       ahc->msgin_buf[ahc->msgin_index]);
+#endif
 
 		message_done = ahc_parse_msg(ahc, &devinfo);
 
@@ -2537,8 +2784,15 @@
 			 * assert ATN so the target takes us to the
 			 * message out phase.
 			 */
-			if (ahc->msgout_len != 0)
+			if (ahc->msgout_len != 0) {
+#ifdef AHC_DEBUG
+				if ((ahc_debug & AHC_SHOW_MESSAGES) != 0) {
+					ahc_print_devinfo(ahc, &devinfo);
+					printf("Asserting ATN for response\n");
+				}
+#endif
 				ahc_assert_atn(ahc);
+			}
 		} else 
 			ahc->msgin_index++;
 
@@ -2748,9 +3002,9 @@
 	targ_scsirate = tinfo->scsirate;
 
 	/*
-	 * Parse as much of the message as is availible,
+	 * Parse as much of the message as is available,
 	 * rejecting it if we don't support it.  When
-	 * the entire message is availible and has been
+	 * the entire message is available and has been
 	 * handled, return MSGLOOP_MSGCOMPLETE, indicating
 	 * that we have parsed an entire message.
 	 *
@@ -2929,23 +3183,30 @@
 				response = TRUE;
 				sending_reply = TRUE;
 			}
+			/*
+			 * After a wide message, we are async, but
+			 * some devices don't seem to honor this portion
+			 * of the spec.  Force a renegotiation of the
+			 * sync component of our transfer agreement even
+			 * if our goal is async.  By updating our width
+			 * after forcing the negotiation, we avoid
+			 * renegotiating for width.
+			 */
+			ahc_update_neg_request(ahc, devinfo, tstate,
+					       tinfo, AHC_NEG_ALWAYS);
 			ahc_set_width(ahc, devinfo, bus_width,
 				      AHC_TRANS_ACTIVE|AHC_TRANS_GOAL,
 				      /*paused*/TRUE);
-			/* After a wide message, we are async */
-			ahc_set_syncrate(ahc, devinfo,
-					 /*syncrate*/NULL, /*period*/0,
-					 /*offset*/0, /*ppr_options*/0,
-					 AHC_TRANS_ACTIVE, /*paused*/TRUE);
 			if (sending_reply == FALSE && reject == FALSE) {
 
-				if (tinfo->goal.period) {
-					ahc->msgout_index = 0;
-					ahc->msgout_len = 0;
-					ahc_build_transfer_msg(ahc, devinfo);
-					ahc->msgout_index = 0;
-					response = TRUE;
-				}
+				/*
+				 * We will always have an SDTR to send.
+				 */
+				ahc->msgout_index = 0;
+				ahc->msgout_len = 0;
+				ahc_build_transfer_msg(ahc, devinfo);
+				ahc->msgout_index = 0;
+				response = TRUE;
 			}
 			done = MSGLOOP_MSGCOMPLETE;
 			break;
@@ -3204,7 +3465,7 @@
 		 * but rejected our response, we already cleared the
 		 * sync rate before sending our WDTR.
 		 */
-		if (tinfo->goal.period) {
+		if (tinfo->goal.offset != tinfo->curr.offset) {
 
 			/* Start the sync negotiation */
 			ahc->msgout_index = 0;
@@ -3326,7 +3587,7 @@
 
 		sgptr = ahc_inb(ahc, SCB_RESIDUAL_SGPTR);
 		if ((sgptr & SG_LIST_NULL) != 0
-		 && ahc_inb(ahc, DATA_COUNT_ODD) == 1) {
+		 && (ahc_inb(ahc, SCB_LUN) & SCB_XFERLEN_ODD) != 0) {
 			/*
 			 * If the residual occurred on the last
 			 * transfer and the transfer request was
@@ -3339,25 +3600,27 @@
 			uint32_t data_addr;
 			uint32_t sglen;
 
-			/* Pull in the rest of the sgptr */
-			sgptr |= (ahc_inb(ahc, SCB_RESIDUAL_SGPTR + 3) << 24)
-			      | (ahc_inb(ahc, SCB_RESIDUAL_SGPTR + 2) << 16)
-			      | (ahc_inb(ahc, SCB_RESIDUAL_SGPTR + 1) << 8);
-			sgptr &= SG_PTR_MASK;
-			data_cnt = (ahc_inb(ahc, SCB_RESIDUAL_DATACNT+3) << 24)
-				 | (ahc_inb(ahc, SCB_RESIDUAL_DATACNT+2) << 16)
-				 | (ahc_inb(ahc, SCB_RESIDUAL_DATACNT+1) << 8)
-				 | (ahc_inb(ahc, SCB_RESIDUAL_DATACNT));
-
-			data_addr = (ahc_inb(ahc, SHADDR + 3) << 24)
-				  | (ahc_inb(ahc, SHADDR + 2) << 16)
-				  | (ahc_inb(ahc, SHADDR + 1) << 8)
-				  | (ahc_inb(ahc, SHADDR));
+			/* Pull in all of the sgptr */
+			sgptr = ahc_inl(ahc, SCB_RESIDUAL_SGPTR);
+			data_cnt = ahc_inl(ahc, SCB_RESIDUAL_DATACNT);
+
+			if ((sgptr & SG_LIST_NULL) != 0) {
+				/*
+				 * The residual data count is not updated
+				 * for the command run to completion case.
+				 * Explicitly zero the count.
+				 */
+				data_cnt &= ~AHC_SG_LEN_MASK;
+			}
+
+			data_addr = ahc_inl(ahc, SHADDR);
 
 			data_cnt += 1;
 			data_addr -= 1;
+			sgptr &= SG_PTR_MASK;
 
 			sg = ahc_sg_bus_to_virt(scb, sgptr);
+
 			/*
 			 * The residual sg ptr points to the next S/G
 			 * to load so we must go back one.
@@ -3383,19 +3646,17 @@
 				 */
 				sg++;
 				sgptr = ahc_sg_virt_to_bus(scb, sg);
-				ahc_outb(ahc, SCB_RESIDUAL_SGPTR + 3,
-					 sgptr >> 24);
-				ahc_outb(ahc, SCB_RESIDUAL_SGPTR + 2,
-					 sgptr >> 16);
-				ahc_outb(ahc, SCB_RESIDUAL_SGPTR + 1,
-					 sgptr >> 8);
-				ahc_outb(ahc, SCB_RESIDUAL_SGPTR, sgptr);
 			}
-
-			ahc_outb(ahc, SCB_RESIDUAL_DATACNT + 3, data_cnt >> 24);
-			ahc_outb(ahc, SCB_RESIDUAL_DATACNT + 2, data_cnt >> 16);
-			ahc_outb(ahc, SCB_RESIDUAL_DATACNT + 1, data_cnt >> 8);
-			ahc_outb(ahc, SCB_RESIDUAL_DATACNT, data_cnt);
+			ahc_outl(ahc, SCB_RESIDUAL_SGPTR, sgptr);
+			ahc_outl(ahc, SCB_RESIDUAL_DATACNT, data_cnt);
+			/*
+			 * Toggle the "oddness" of the transfer length
+			 * to handle this mid-transfer ignore wide
+			 * residue.  This ensures that the oddness is
+			 * correct for subsequent data transfers.
+			 */
+			ahc_outb(ahc, SCB_LUN,
+				 ahc_inb(ahc, SCB_LUN) ^ SCB_XFERLEN_ODD);
 		}
 	}
 }
@@ -3579,6 +3840,12 @@
 	ahc->features = AHC_FENONE;
 	ahc->bugs = AHC_BUGNONE;
 	ahc->flags = AHC_FNONE;
+	/*
+	 * Default to all error reporting enabled with the
+	 * sequencer operating at its fastest speed.
+	 * The bus attach code may modify this.
+	 */
+	ahc->seqctl = FASTMODE;
 
 	for (i = 0; i < AHC_NUM_TARGETS; i++)
 		TAILQ_INIT(&ahc->untagged_queues[i]);
@@ -3658,7 +3925,7 @@
 	 */
 	list_ahc = TAILQ_FIRST(&ahc_tailq);
 	while (list_ahc != NULL
-	    && ahc_softc_comp(list_ahc, ahc) <= 0)
+	    && ahc_softc_comp(ahc, list_ahc) <= 0)
 		list_ahc = TAILQ_NEXT(list_ahc, links);
 	if (list_ahc != NULL)
 		TAILQ_INSERT_BEFORE(list_ahc, ahc, links);
@@ -3702,7 +3969,6 @@
 {
 	int i;
 
-	ahc_fini_scbdata(ahc);
 	switch (ahc->init_level) {
 	default:
 	case 5:
@@ -3734,12 +4000,13 @@
 	ahc_dma_tag_destroy(ahc, ahc->parent_dmat);
 #endif
 	ahc_platform_free(ahc);
+	ahc_fini_scbdata(ahc);
 	for (i = 0; i < AHC_NUM_TARGETS; i++) {
 		struct ahc_tmode_tstate *tstate;
 
 		tstate = ahc->enabled_targets[i];
 		if (tstate != NULL) {
-#if AHC_TARGET_MODE
+#ifdef AHC_TARGET_MODE
 			int j;
 
 			for (j = 0; j < AHC_NUM_LUNS; j++) {
@@ -3755,7 +4022,7 @@
 			free(tstate, M_DEVBUF);
 		}
 	}
-#if AHC_TARGET_MODE
+#ifdef AHC_TARGET_MODE
 	if (ahc->black_hole != NULL) {
 		xpt_free_path(ahc->black_hole->path);
 		free(ahc->black_hole, M_DEVBUF);
@@ -3780,7 +4047,7 @@
 	ahc = (struct ahc_softc *)arg;
 
 	/* This will reset most registers to 0, but not all */
-	ahc_reset(ahc);
+	ahc_reset(ahc, /*reinit*/FALSE);
 	ahc_outb(ahc, SCSISEQ, 0);
 	ahc_outb(ahc, SXFRCTL0, 0);
 	ahc_outb(ahc, DSPCISTATUS, 0);
@@ -3791,13 +4058,19 @@
 
 /*
  * Reset the controller and record some information about it
- * that is only available just after a reset.
+ * that is only available just after a reset.  If "reinit" is
+ * non-zero, this reset occured after initial configuration
+ * and the caller requests that the chip be fully reinitialized
+ * to a runable state.  Chip interrupts are *not* enabled after
+ * a reinitialization.  The caller must enable interrupts via
+ * ahc_intr_enable().
  */
 int
-ahc_reset(struct ahc_softc *ahc)
+ahc_reset(struct ahc_softc *ahc, int reinit)
 {
 	u_int	sblkctl;
 	u_int	sxfrctl1_a, sxfrctl1_b;
+	int	error;
 	int	wait;
 	
 	/*
@@ -3806,6 +4079,14 @@
 	 * to disturb the integrity of the bus.
 	 */
 	ahc_pause(ahc);
+	if ((ahc_inb(ahc, HCNTRL) & CHIPRST) != 0) {
+		/*
+		 * The chip has not been initialized since
+		 * PCI/EISA/VLB bus reset.  Don't trust
+		 * "left over BIOS data".
+		 */
+		ahc->flags |= AHC_NO_BIOS_INIT;
+	}
 	sxfrctl1_b = 0;
 	if ((ahc->chip & AHC_CHIPID_MASK) == AHC_AIC7770) {
 		u_int sblkctl;
@@ -3821,7 +4102,7 @@
 	}
 	sxfrctl1_a = ahc_inb(ahc, SXFRCTL1);
 
-	ahc_outb_reset(ahc, HCNTRL, CHIPRST | ahc->pause);
+	ahc_outb(ahc, HCNTRL, CHIPRST | ahc->pause);
 
 	/*
 	 * Ensure that the reset has finished.  We delay 1000us
@@ -3880,12 +4161,19 @@
 	}
 	ahc_outb(ahc, SXFRCTL1, sxfrctl1_a);
 
+	error = 0;
+	if (reinit != 0)
+		/*
+		 * If a recovery action has forced a chip reset,
+		 * re-initialize the chip to our liking.
+		 */
+		error = ahc->bus_chip_init(ahc);
 #ifdef AHC_DUMP_SEQ
-	if (ahc->init_level == 0)
+	else 
 		ahc_dumpseq(ahc);
 #endif
 
-	return (0);
+	return (error);
 }
 
 /*
@@ -3955,6 +4243,14 @@
 		ahc_outb(ahc, SCB_LUN, 0xFF);
 	}
 
+	if ((ahc->flags & AHC_PAGESCBS) != 0) {
+		/* SCB 0 heads the free list. */
+		ahc_outb(ahc, FREE_SCBH, 0);
+	} else {
+		/* No free list. */
+		ahc_outb(ahc, FREE_SCBH, SCB_LIST_NULL);
+	}
+
 	/* Make sure that the last SCB terminates the free list */
 	ahc_outb(ahc, SCBPTR, i-1);
 	ahc_outb(ahc, SCB_NEXT, SCB_LIST_NULL);
@@ -3980,20 +4276,11 @@
 	/* Determine the number of hardware SCBs and initialize them */
 
 	scb_data->maxhscbs = ahc_probe_scbs(ahc);
-	if ((ahc->flags & AHC_PAGESCBS) != 0) {
-		/* SCB 0 heads the free list */
-		ahc_outb(ahc, FREE_SCBH, 0);
-	} else {
-		ahc_outb(ahc, FREE_SCBH, SCB_LIST_NULL);
-	}
-
 	if (ahc->scb_data->maxhscbs == 0) {
 		printf("%s: No SCB space found\n", ahc_name(ahc));
 		return (ENXIO);
 	}
 
-	ahc_build_free_scb_list(ahc);
-
 	/*
 	 * Create our DMA tags.  These tags define the kinds of device
 	 * accessible memory allocations and memory mappings we will
@@ -4069,7 +4356,7 @@
 	scb_data->init_level++;
 
 	/* DMA tag for our S/G structures.  We allocate in page sized chunks */
-	if (ahc_dma_tag_create(ahc, ahc->parent_dmat, /*alignment*/1,
+	if (ahc_dma_tag_create(ahc, ahc->parent_dmat, /*alignment*/8,
 			       /*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
 			       /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
 			       /*highaddr*/BUS_SPACE_MAXADDR,
@@ -4095,10 +4382,9 @@
 	}
 
 	/*
-	 * Tell the sequencer which SCB will be the next one it receives.
+	 * Reserve the next queued SCB.
 	 */
 	ahc->next_queued_scb = ahc_get_scb(ahc);
-	ahc_outb(ahc, NEXT_QUEUED_SCB, ahc->next_queued_scb->hscb->tag);
 
 	/*
 	 * Note that we were successfull
@@ -4283,60 +4569,242 @@
 		sprintf(buf, "%d SCBs", ahc->scb_data->maxhscbs);
 }
 
-/*
- * Start the board, ready for normal operation
- */
 int
-ahc_init(struct ahc_softc *ahc)
+ahc_chip_init(struct ahc_softc *ahc)
 {
-	int	 max_targ;
-	int	 i;
 	int	 term;
+	int	 error;
+	u_int	 i;
 	u_int	 scsi_conf;
 	u_int	 scsiseq_template;
-	u_int	 ultraenb;
-	u_int	 discenable;
-	u_int	 tagenable;
-	size_t	 driver_data_size;
 	uint32_t physaddr;
 
-#ifdef AHC_DEBUG_SEQUENCER
-	ahc->flags |= AHC_SEQUENCER_DEBUG;
-#endif
+	ahc_outb(ahc, SEQ_FLAGS, 0);
+	ahc_outb(ahc, SEQ_FLAGS2, 0);
 
-#ifdef AHC_PRINT_SRAM
-	printf("Scratch Ram:");
-	for (i = 0x20; i < 0x5f; i++) {
-		if (((i % 8) == 0) && (i != 0)) {
-			printf ("\n              ");
-		}
-		printf (" 0x%x", ahc_inb(ahc, i));
-	}
-	if ((ahc->features & AHC_MORE_SRAM) != 0) {
-		for (i = 0x70; i < 0x7f; i++) {
-			if (((i % 8) == 0) && (i != 0)) {
-				printf ("\n              ");
-			}
-			printf (" 0x%x", ahc_inb(ahc, i));
-		}
-	}
-	printf ("\n");
-	/*
-	 * Reading uninitialized scratch ram may
-	 * generate parity errors.
-	 */
-	ahc_outb(ahc, CLRINT, CLRPARERR);
-	ahc_outb(ahc, CLRINT, CLRBRKADRINT);
-#endif
-	max_targ = 15;
+	/* Set the SCSI Id, SXFRCTL0, SXFRCTL1, and SIMODE1, for both channels*/
+	if (ahc->features & AHC_TWIN) {
+
+		/*
+		 * Setup Channel B first.
+		 */
+		ahc_outb(ahc, SBLKCTL, ahc_inb(ahc, SBLKCTL) | SELBUSB);
+		term = (ahc->flags & AHC_TERM_ENB_B) != 0 ? STPWEN : 0;
+		ahc_outb(ahc, SCSIID, ahc->our_id_b);
+		scsi_conf = ahc_inb(ahc, SCSICONF + 1);
+		ahc_outb(ahc, SXFRCTL1, (scsi_conf & (ENSPCHK|STIMESEL))
+					|term|ahc->seltime_b|ENSTIMER|ACTNEGEN);
+		if ((ahc->features & AHC_ULTRA2) != 0)
+			ahc_outb(ahc, SIMODE0, ahc_inb(ahc, SIMODE0)|ENIOERR);
+		ahc_outb(ahc, SIMODE1, ENSELTIMO|ENSCSIRST|ENSCSIPERR);
+		ahc_outb(ahc, SXFRCTL0, DFON|SPIOEN);
+
+		/* Select Channel A */
+		ahc_outb(ahc, SBLKCTL, ahc_inb(ahc, SBLKCTL) & ~SELBUSB);
+	}
+	term = (ahc->flags & AHC_TERM_ENB_A) != 0 ? STPWEN : 0;
+	if ((ahc->features & AHC_ULTRA2) != 0)
+		ahc_outb(ahc, SCSIID_ULTRA2, ahc->our_id);
+	else
+		ahc_outb(ahc, SCSIID, ahc->our_id);
+	scsi_conf = ahc_inb(ahc, SCSICONF);
+	ahc_outb(ahc, SXFRCTL1, (scsi_conf & (ENSPCHK|STIMESEL))
+				|term|ahc->seltime
+				|ENSTIMER|ACTNEGEN);
+	if ((ahc->features & AHC_ULTRA2) != 0)
+		ahc_outb(ahc, SIMODE0, ahc_inb(ahc, SIMODE0)|ENIOERR);
+	ahc_outb(ahc, SIMODE1, ENSELTIMO|ENSCSIRST|ENSCSIPERR);
+	ahc_outb(ahc, SXFRCTL0, DFON|SPIOEN);
+
+	/* There are no untagged SCBs active yet. */
+	for (i = 0; i < 16; i++) {
+		ahc_unbusy_tcl(ahc, BUILD_TCL(i << 4, 0));
+		if ((ahc->flags & AHC_SCB_BTT) != 0) {
+			int lun;
+
+			/*
+			 * The SCB based BTT allows an entry per
+			 * target and lun pair.
+			 */
+			for (lun = 1; lun < AHC_NUM_LUNS; lun++)
+				ahc_unbusy_tcl(ahc, BUILD_TCL(i << 4, lun));
+		}
+	}
+
+	/* All of our queues are empty */
+	for (i = 0; i < 256; i++)
+		ahc->qoutfifo[i] = SCB_LIST_NULL;
+	ahc_sync_qoutfifo(ahc, BUS_DMASYNC_PREREAD);
+
+	for (i = 0; i < 256; i++)
+		ahc->qinfifo[i] = SCB_LIST_NULL;
+
+	if ((ahc->features & AHC_MULTI_TID) != 0) {
+		ahc_outb(ahc, TARGID, 0);
+		ahc_outb(ahc, TARGID + 1, 0);
+	}
 
 	/*
-	 * Assume we have a board at this stage and it has been reset.
-	 */
-	if ((ahc->flags & AHC_USEDEFAULTS) != 0)
-		ahc->our_id = ahc->our_id_b = 7;
-	
-	/*
+	 * Tell the sequencer where it can find our arrays in memory.
+	 */
+	physaddr = ahc->scb_data->hscb_busaddr;
+	ahc_outb(ahc, HSCB_ADDR, physaddr & 0xFF);
+	ahc_outb(ahc, HSCB_ADDR + 1, (physaddr >> 8) & 0xFF);
+	ahc_outb(ahc, HSCB_ADDR + 2, (physaddr >> 16) & 0xFF);
+	ahc_outb(ahc, HSCB_ADDR + 3, (physaddr >> 24) & 0xFF);
+
+	physaddr = ahc->shared_data_busaddr;
+	ahc_outb(ahc, SHARED_DATA_ADDR, physaddr & 0xFF);
+	ahc_outb(ahc, SHARED_DATA_ADDR + 1, (physaddr >> 8) & 0xFF);
+	ahc_outb(ahc, SHARED_DATA_ADDR + 2, (physaddr >> 16) & 0xFF);
+	ahc_outb(ahc, SHARED_DATA_ADDR + 3, (physaddr >> 24) & 0xFF);
+
+	/*
+	 * Initialize the group code to command length table.
+	 * This overrides the values in TARG_SCSIRATE, so only
+	 * setup the table after we have processed that information.
+	 */
+	ahc_outb(ahc, CMDSIZE_TABLE, 5);
+	ahc_outb(ahc, CMDSIZE_TABLE + 1, 9);
+	ahc_outb(ahc, CMDSIZE_TABLE + 2, 9);
+	ahc_outb(ahc, CMDSIZE_TABLE + 3, 0);
+	ahc_outb(ahc, CMDSIZE_TABLE + 4, 15);
+	ahc_outb(ahc, CMDSIZE_TABLE + 5, 11);
+	ahc_outb(ahc, CMDSIZE_TABLE + 6, 0);
+	ahc_outb(ahc, CMDSIZE_TABLE + 7, 0);
+		
+	if ((ahc->features & AHC_HS_MAILBOX) != 0)
+		ahc_outb(ahc, HS_MAILBOX, 0);
+
+	/* Tell the sequencer of our initial queue positions */
+	if ((ahc->features & AHC_TARGETMODE) != 0) {
+		ahc->tqinfifonext = 1;
+		ahc_outb(ahc, KERNEL_TQINPOS, ahc->tqinfifonext - 1);
+		ahc_outb(ahc, TQINPOS, ahc->tqinfifonext);
+	}
+	ahc->qinfifonext = 0;
+	ahc->qoutfifonext = 0;
+	if ((ahc->features & AHC_QUEUE_REGS) != 0) {
+		ahc_outb(ahc, QOFF_CTLSTA, SCB_QSIZE_256);
+		ahc_outb(ahc, HNSCB_QOFF, ahc->qinfifonext);
+		ahc_outb(ahc, SNSCB_QOFF, ahc->qinfifonext);
+		ahc_outb(ahc, SDSCB_QOFF, 0);
+	} else {
+		ahc_outb(ahc, KERNEL_QINPOS, ahc->qinfifonext);
+		ahc_outb(ahc, QINPOS, ahc->qinfifonext);
+		ahc_outb(ahc, QOUTPOS, ahc->qoutfifonext);
+	}
+
+	/* We don't have any waiting selections */
+	ahc_outb(ahc, WAITING_SCBH, SCB_LIST_NULL);
+
+	/* Our disconnection list is empty too */
+	ahc_outb(ahc, DISCONNECTED_SCBH, SCB_LIST_NULL);
+
+	/* Message out buffer starts empty */
+	ahc_outb(ahc, MSG_OUT, MSG_NOOP);
+
+	/*
+	 * Setup the allowed SCSI Sequences based on operational mode.
+	 * If we are a target, we'll enalbe select in operations once
+	 * we've had a lun enabled.
+	 */
+	scsiseq_template = ENSELO|ENAUTOATNO|ENAUTOATNP;
+	if ((ahc->flags & AHC_INITIATORROLE) != 0)
+		scsiseq_template |= ENRSELI;
+	ahc_outb(ahc, SCSISEQ_TEMPLATE, scsiseq_template);
+
+	/* Initialize our list of free SCBs. */
+	ahc_build_free_scb_list(ahc);
+
+	/*
+	 * Tell the sequencer which SCB will be the next one it receives.
+	 */
+	ahc_outb(ahc, NEXT_QUEUED_SCB, ahc->next_queued_scb->hscb->tag);
+
+	/*
+	 * Load the Sequencer program and Enable the adapter
+	 * in "fast" mode.
+	 */
+	if (bootverbose)
+		printf("%s: Downloading Sequencer Program...",
+		       ahc_name(ahc));
+
+	error = ahc_loadseq(ahc);
+	if (error != 0)
+		return (error);
+
+	if ((ahc->features & AHC_ULTRA2) != 0) {
+		int wait;
+
+		/*
+		 * Wait for up to 500ms for our transceivers
+		 * to settle.  If the adapter does not have
+		 * a cable attached, the transceivers may
+		 * never settle, so don't complain if we
+		 * fail here.
+		 */
+		for (wait = 5000;
+		     (ahc_inb(ahc, SBLKCTL) & (ENAB40|ENAB20)) == 0 && wait;
+		     wait--)
+			ahc_delay(100);
+	}
+	ahc_restart(ahc);
+	return (0);
+}
+
+/*
+ * Start the board, ready for normal operation
+ */
+int
+ahc_init(struct ahc_softc *ahc)
+{
+	int	 max_targ;
+	u_int	 i;
+	u_int	 scsi_conf;
+	u_int	 ultraenb;
+	u_int	 discenable;
+	u_int	 tagenable;
+	size_t	 driver_data_size;
+
+#ifdef AHC_DEBUG
+	if ((ahc_debug & AHC_DEBUG_SEQUENCER) != 0)
+		ahc->flags |= AHC_SEQUENCER_DEBUG;
+#endif
+
+#ifdef AHC_PRINT_SRAM
+	printf("Scratch Ram:");
+	for (i = 0x20; i < 0x5f; i++) {
+		if (((i % 8) == 0) && (i != 0)) {
+			printf ("\n              ");
+		}
+		printf (" 0x%x", ahc_inb(ahc, i));
+	}
+	if ((ahc->features & AHC_MORE_SRAM) != 0) {
+		for (i = 0x70; i < 0x7f; i++) {
+			if (((i % 8) == 0) && (i != 0)) {
+				printf ("\n              ");
+			}
+			printf (" 0x%x", ahc_inb(ahc, i));
+		}
+	}
+	printf ("\n");
+	/*
+	 * Reading uninitialized scratch ram may
+	 * generate parity errors.
+	 */
+	ahc_outb(ahc, CLRINT, CLRPARERR);
+	ahc_outb(ahc, CLRINT, CLRBRKADRINT);
+#endif
+	max_targ = 15;
+
+	/*
+	 * Assume we have a board at this stage and it has been reset.
+	 */
+	if ((ahc->flags & AHC_USEDEFAULTS) != 0)
+		ahc->our_id = ahc->our_id_b = 7;
+	
+	/*
 	 * Default to allowing initiator operations.
 	 */
 	ahc->flags |= AHC_INITIATORROLE;
@@ -4351,10 +4819,13 @@
 	/* DMA tag for mapping buffers into device visible space. */
 	if (ahc_dma_tag_create(ahc, ahc->parent_dmat, /*alignment*/1,
 			       /*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
-			       /*lowaddr*/BUS_SPACE_MAXADDR,
+			       /*lowaddr*/ahc->flags & AHC_39BIT_ADDRESSING
+					? (bus_addr_t)0x7FFFFFFFFFULL
+					: BUS_SPACE_MAXADDR_32BIT,
 			       /*highaddr*/BUS_SPACE_MAXADDR,
 			       /*filter*/NULL, /*filterarg*/NULL,
-			       /*maxsize*/MAXBSIZE, /*nsegments*/AHC_NSEG,
+			       /*maxsize*/(AHC_NSEG - 1) * PAGE_SIZE,
+			       /*nsegments*/AHC_NSEG,
 			       /*maxsegsz*/AHC_MAXTRANSFER_SIZE,
 			       /*flags*/BUS_DMA_ALLOCNOW,
 			       &ahc->buffer_dmat) != 0) {
@@ -4414,9 +4885,6 @@
 		for (i = 0; i < AHC_TMODE_CMDS; i++)
 			ahc->targetcmds[i].cmd_valid = 0;
 		ahc_sync_tqinfifo(ahc, BUS_DMASYNC_PREREAD);
-		ahc->tqinfifonext = 1;
-		ahc_outb(ahc, KERNEL_TQINPOS, ahc->tqinfifonext - 1);
-		ahc_outb(ahc, TQINPOS, ahc->tqinfifonext);
 		ahc->qoutfifo = (uint8_t *)&ahc->targetcmds[256];
 	}
 	ahc->qinfifo = &ahc->qoutfifo[256];
@@ -4447,9 +4915,6 @@
 		}
 	}
 
-	ahc_outb(ahc, SEQ_FLAGS, 0);
-	ahc_outb(ahc, SEQ_FLAGS2, 0);
-
 	if (ahc->scb_data->maxhscbs < AHC_SCB_MAX_ALLOC) {
 		ahc->flags |= AHC_PAGESCBS;
 	} else {
@@ -4457,63 +4922,32 @@
 	}
 
 #ifdef AHC_DEBUG
-	if (ahc_debug & AHC_SHOWMISC) {
-		printf("%s: hardware scb %d bytes; kernel scb %d bytes; "
-		       "ahc_dma %d bytes\n",
+	if (ahc_debug & AHC_SHOW_MISC) {
+		printf("%s: hardware scb %u bytes; kernel scb %u bytes; "
+		       "ahc_dma %u bytes\n",
 			ahc_name(ahc),
-			sizeof(struct hardware_scb),
-			sizeof(struct scb),
-			sizeof(struct ahc_dma_seg));
+			(u_int)sizeof(struct hardware_scb),
+			(u_int)sizeof(struct scb),
+			(u_int)sizeof(struct ahc_dma_seg));
 	}
 #endif /* AHC_DEBUG */
 
-	/* Set the SCSI Id, SXFRCTL0, SXFRCTL1, and SIMODE1, for both channels*/
+	/*
+	 * Look at the information that board initialization or
+	 * the board bios has left us.
+	 */
 	if (ahc->features & AHC_TWIN) {
-
-		/*
-		 * The device is gated to channel B after a chip reset,
-		 * so set those values first
-		 */
-		ahc_outb(ahc, SBLKCTL, ahc_inb(ahc, SBLKCTL) | SELBUSB);
-		term = (ahc->flags & AHC_TERM_ENB_B) != 0 ? STPWEN : 0;
-		ahc_outb(ahc, SCSIID, ahc->our_id_b);
 		scsi_conf = ahc_inb(ahc, SCSICONF + 1);
-		ahc_outb(ahc, SXFRCTL1, (scsi_conf & (ENSPCHK|STIMESEL))
-					|term|ahc->seltime_b|ENSTIMER|ACTNEGEN);
-		if ((ahc->features & AHC_ULTRA2) != 0)
-			ahc_outb(ahc, SIMODE0, ahc_inb(ahc, SIMODE0)|ENIOERR);
-		ahc_outb(ahc, SIMODE1, ENSELTIMO|ENSCSIRST|ENSCSIPERR);
-		ahc_outb(ahc, SXFRCTL0, DFON|SPIOEN);
-
 		if ((scsi_conf & RESET_SCSI) != 0
 		 && (ahc->flags & AHC_INITIATORROLE) != 0)
 			ahc->flags |= AHC_RESET_BUS_B;
-
-		/* Select Channel A */
-		ahc_outb(ahc, SBLKCTL, ahc_inb(ahc, SBLKCTL) & ~SELBUSB);
 	}
-	term = (ahc->flags & AHC_TERM_ENB_A) != 0 ? STPWEN : 0;
-	if ((ahc->features & AHC_ULTRA2) != 0)
-		ahc_outb(ahc, SCSIID_ULTRA2, ahc->our_id);
-	else
-		ahc_outb(ahc, SCSIID, ahc->our_id);
-	scsi_conf = ahc_inb(ahc, SCSICONF);
-	ahc_outb(ahc, SXFRCTL1, (scsi_conf & (ENSPCHK|STIMESEL))
-				|term|ahc->seltime
-				|ENSTIMER|ACTNEGEN);
-	if ((ahc->features & AHC_ULTRA2) != 0)
-		ahc_outb(ahc, SIMODE0, ahc_inb(ahc, SIMODE0)|ENIOERR);
-	ahc_outb(ahc, SIMODE1, ENSELTIMO|ENSCSIRST|ENSCSIPERR);
-	ahc_outb(ahc, SXFRCTL0, DFON|SPIOEN);
 
+	scsi_conf = ahc_inb(ahc, SCSICONF);
 	if ((scsi_conf & RESET_SCSI) != 0
 	 && (ahc->flags & AHC_INITIATORROLE) != 0)
 		ahc->flags |= AHC_RESET_BUS_A;
 
-	/*
-	 * Look at the information that board initialization or
-	 * the board bios has left us.
-	 */
 	ultraenb = 0;	
 	tagenable = ALL_TARGETS_MASK;
 
@@ -4565,7 +4999,7 @@
 			 * connection type we have with the target.
 			 */
 			tinfo->user.period = ahc_syncrates->period;
-			tinfo->user.offset = ~0;
+			tinfo->user.offset = MAX_OFFSET;
 		} else {
 			u_int scsirate;
 			uint16_t mask;
@@ -4600,7 +5034,7 @@
 				if (offset == 0)
 					tinfo->user.period = 0;
 				else
-					tinfo->user.offset = ~0;
+					tinfo->user.offset = MAX_OFFSET;
 				if ((scsirate & SXFR_ULTRA2) <= 8/*10MHz*/
 				 && (ahc->features & AHC_DT) != 0)
 					tinfo->user.ppr_options =
@@ -4618,7 +5052,7 @@
 						   ? AHC_SYNCRATE_ULTRA
 						   : AHC_SYNCRATE_FAST);
 				if (tinfo->user.period != 0)
-					tinfo->user.offset = ~0;
+					tinfo->user.offset = MAX_OFFSET;
 			}
 			if (tinfo->user.period == 0)
 				tinfo->user.offset = 0;
@@ -4635,132 +5069,12 @@
 			tinfo->curr.protocol_version = 2;
 			tinfo->curr.transport_version = 2;
 		}
-		tstate->ultraenb = ultraenb;
+		tstate->ultraenb = 0;
 	}
 	ahc->user_discenable = discenable;
 	ahc->user_tagenable = tagenable;
 
-	/* There are no untagged SCBs active yet. */
-	for (i = 0; i < 16; i++) {
-		ahc_unbusy_tcl(ahc, BUILD_TCL(i << 4, 0));
-		if ((ahc->flags & AHC_SCB_BTT) != 0) {
-			int lun;
-
-			/*
-			 * The SCB based BTT allows an entry per
-			 * target and lun pair.
-			 */
-			for (lun = 1; lun < AHC_NUM_LUNS; lun++)
-				ahc_unbusy_tcl(ahc, BUILD_TCL(i << 4, lun));
-		}
-	}
-
-	/* All of our queues are empty */
-	for (i = 0; i < 256; i++)
-		ahc->qoutfifo[i] = SCB_LIST_NULL;
-	ahc_sync_qoutfifo(ahc, BUS_DMASYNC_PREREAD);
-
-	for (i = 0; i < 256; i++)
-		ahc->qinfifo[i] = SCB_LIST_NULL;
-
-	if ((ahc->features & AHC_MULTI_TID) != 0) {
-		ahc_outb(ahc, TARGID, 0);
-		ahc_outb(ahc, TARGID + 1, 0);
-	}
-
-	/*
-	 * Tell the sequencer where it can find our arrays in memory.
-	 */
-	physaddr = ahc->scb_data->hscb_busaddr;
-	ahc_outb(ahc, HSCB_ADDR, physaddr & 0xFF);
-	ahc_outb(ahc, HSCB_ADDR + 1, (physaddr >> 8) & 0xFF);
-	ahc_outb(ahc, HSCB_ADDR + 2, (physaddr >> 16) & 0xFF);
-	ahc_outb(ahc, HSCB_ADDR + 3, (physaddr >> 24) & 0xFF);
-
-	physaddr = ahc->shared_data_busaddr;
-	ahc_outb(ahc, SHARED_DATA_ADDR, physaddr & 0xFF);
-	ahc_outb(ahc, SHARED_DATA_ADDR + 1, (physaddr >> 8) & 0xFF);
-	ahc_outb(ahc, SHARED_DATA_ADDR + 2, (physaddr >> 16) & 0xFF);
-	ahc_outb(ahc, SHARED_DATA_ADDR + 3, (physaddr >> 24) & 0xFF);
-
-	/*
-	 * Initialize the group code to command length table.
-	 * This overrides the values in TARG_SCSIRATE, so only
-	 * setup the table after we have processed that information.
-	 */
-	ahc_outb(ahc, CMDSIZE_TABLE, 5);
-	ahc_outb(ahc, CMDSIZE_TABLE + 1, 9);
-	ahc_outb(ahc, CMDSIZE_TABLE + 2, 9);
-	ahc_outb(ahc, CMDSIZE_TABLE + 3, 0);
-	ahc_outb(ahc, CMDSIZE_TABLE + 4, 15);
-	ahc_outb(ahc, CMDSIZE_TABLE + 5, 11);
-	ahc_outb(ahc, CMDSIZE_TABLE + 6, 0);
-	ahc_outb(ahc, CMDSIZE_TABLE + 7, 0);
-		
-	/* Tell the sequencer of our initial queue positions */
-	ahc_outb(ahc, KERNEL_QINPOS, 0);
-	ahc_outb(ahc, QINPOS, 0);
-	ahc_outb(ahc, QOUTPOS, 0);
-
-	/*
-	 * Use the built in queue management registers
-	 * if they are available.
-	 */
-	if ((ahc->features & AHC_QUEUE_REGS) != 0) {
-		ahc_outb(ahc, QOFF_CTLSTA, SCB_QSIZE_256);
-		ahc_outb(ahc, SDSCB_QOFF, 0);
-		ahc_outb(ahc, SNSCB_QOFF, 0);
-		ahc_outb(ahc, HNSCB_QOFF, 0);
-	}
-
-
-	/* We don't have any waiting selections */
-	ahc_outb(ahc, WAITING_SCBH, SCB_LIST_NULL);
-
-	/* Our disconnection list is empty too */
-	ahc_outb(ahc, DISCONNECTED_SCBH, SCB_LIST_NULL);
-
-	/* Message out buffer starts empty */
-	ahc_outb(ahc, MSG_OUT, MSG_NOOP);
-
-	/*
-	 * Setup the allowed SCSI Sequences based on operational mode.
-	 * If we are a target, we'll enalbe select in operations once
-	 * we've had a lun enabled.
-	 */
-	scsiseq_template = ENSELO|ENAUTOATNO|ENAUTOATNP;
-	if ((ahc->flags & AHC_INITIATORROLE) != 0)
-		scsiseq_template |= ENRSELI;
-	ahc_outb(ahc, SCSISEQ_TEMPLATE, scsiseq_template);
-
-	/*
-	 * Load the Sequencer program and Enable the adapter
-	 * in "fast" mode.
-	 */
-	if (bootverbose)
-		printf("%s: Downloading Sequencer Program...",
-		       ahc_name(ahc));
-
-	ahc_loadseq(ahc);
-
-	if ((ahc->features & AHC_ULTRA2) != 0) {
-		int wait;
-
-		/*
-		 * Wait for up to 500ms for our transceivers
-		 * to settle.  If the adapter does not have
-		 * a cable attached, the tranceivers may
-		 * never settle, so don't complain if we
-		 * fail here.
-		 */
-		ahc_pause(ahc);
-		for (wait = 5000;
-		     (ahc_inb(ahc, SBLKCTL) & (ENAB40|ENAB20)) == 0 && wait;
-		     wait--)
-			ahc_delay(100);
-		ahc_unpause(ahc);
-	}
-	return (0);
+	return (ahc->bus_chip_init(ahc));
 }
 
 void
@@ -4792,21 +5106,27 @@
 {
 	int intstat;
 	int maxloops;
+	int paused;
 
 	maxloops = 1000;
 	ahc->flags |= AHC_ALL_INTERRUPTS;
-	intstat = 0;
+	paused = FALSE;
 	do {
+		if (paused)
+			ahc_unpause(ahc);
 		ahc_intr(ahc);
 		ahc_pause(ahc);
+		paused = TRUE;
+		ahc_outb(ahc, SCSISEQ, ahc_inb(ahc, SCSISEQ) & ~ENSELO);
 		ahc_clear_critical_section(ahc);
-		if (intstat == 0xFF && (ahc->features & AHC_REMOVABLE) != 0)
-			break;
-		maxloops--;
-	} while (((intstat = ahc_inb(ahc, INTSTAT)) & INT_PEND) && --maxloops);
+		intstat = ahc_inb(ahc, INTSTAT);
+	} while (--maxloops
+	      && (intstat != 0xFF || (ahc->features & AHC_REMOVABLE) == 0)
+	      && ((intstat & INT_PEND) != 0
+	       || (ahc_inb(ahc, SSTAT0) & (SELDO|SELINGO)) != 0));
 	if (maxloops == 0) {
 		printf("Infinite interrupt loop, INTSTAT = %x",
-		      ahc_inb(ahc, INTSTAT));
+		       ahc_inb(ahc, INTSTAT));
 	}
 	ahc_platform_flushwork(ahc);
 	ahc->flags &= ~AHC_ALL_INTERRUPTS;
@@ -4815,87 +5135,25 @@
 int
 ahc_suspend(struct ahc_softc *ahc)
 {
-	uint8_t *ptr;
-	int	 i;
 
 	ahc_pause_and_flushwork(ahc);
 
-	if (LIST_FIRST(&ahc->pending_scbs) != NULL)
+	if (LIST_FIRST(&ahc->pending_scbs) != NULL) {
+		ahc_unpause(ahc);
 		return (EBUSY);
+	}
 
-#if AHC_TARGET_MODE
+#ifdef AHC_TARGET_MODE
 	/*
 	 * XXX What about ATIOs that have not yet been serviced?
 	 * Perhaps we should just refuse to be suspended if we
 	 * are acting in a target role.
 	 */
-	if (ahc->pending_device != NULL)
+	if (ahc->pending_device != NULL) {
+		ahc_unpause(ahc);
 		return (EBUSY);
-#endif
-
-	/* Save volatile registers */
-	if ((ahc->features & AHC_TWIN) != 0) {
-		ahc_outb(ahc, SBLKCTL, ahc_inb(ahc, SBLKCTL) | SELBUSB);
-		ahc->suspend_state.channel[1].scsiseq = ahc_inb(ahc, SCSISEQ);
-		ahc->suspend_state.channel[1].sxfrctl0 = ahc_inb(ahc, SXFRCTL0);
-		ahc->suspend_state.channel[1].sxfrctl1 = ahc_inb(ahc, SXFRCTL1);
-		ahc->suspend_state.channel[1].simode0 = ahc_inb(ahc, SIMODE0);
-		ahc->suspend_state.channel[1].simode1 = ahc_inb(ahc, SIMODE1);
-		ahc->suspend_state.channel[1].seltimer = ahc_inb(ahc, SELTIMER);
-		ahc->suspend_state.channel[1].seqctl = ahc_inb(ahc, SEQCTL);
-		ahc_outb(ahc, SBLKCTL, ahc_inb(ahc, SBLKCTL) & ~SELBUSB);
-	}
-	ahc->suspend_state.channel[0].scsiseq = ahc_inb(ahc, SCSISEQ);
-	ahc->suspend_state.channel[0].sxfrctl0 = ahc_inb(ahc, SXFRCTL0);
-	ahc->suspend_state.channel[0].sxfrctl1 = ahc_inb(ahc, SXFRCTL1);
-	ahc->suspend_state.channel[0].simode0 = ahc_inb(ahc, SIMODE0);
-	ahc->suspend_state.channel[0].simode1 = ahc_inb(ahc, SIMODE1);
-	ahc->suspend_state.channel[0].seltimer = ahc_inb(ahc, SELTIMER);
-	ahc->suspend_state.channel[0].seqctl = ahc_inb(ahc, SEQCTL);
-
-	if ((ahc->chip & AHC_PCI) != 0) {
-		ahc->suspend_state.dscommand0 = ahc_inb(ahc, DSCOMMAND0);
-		ahc->suspend_state.dspcistatus = ahc_inb(ahc, DSPCISTATUS);
-	}
-
-	if ((ahc->features & AHC_DT) != 0) {
-		u_int sfunct;
-
-		sfunct = ahc_inb(ahc, SFUNCT) & ~ALT_MODE;
-		ahc_outb(ahc, SFUNCT, sfunct | ALT_MODE);
-		ahc->suspend_state.optionmode = ahc_inb(ahc, OPTIONMODE);
-		ahc_outb(ahc, SFUNCT, sfunct);
-		ahc->suspend_state.crccontrol1 = ahc_inb(ahc, CRCCONTROL1);
-	}
-
-	if ((ahc->features & AHC_MULTI_FUNC) != 0)
-		ahc->suspend_state.scbbaddr = ahc_inb(ahc, SCBBADDR);
-
-	if ((ahc->features & AHC_ULTRA2) != 0)
-		ahc->suspend_state.dff_thrsh = ahc_inb(ahc, DFF_THRSH);
-
-	ptr = ahc->suspend_state.scratch_ram;
-	for (i = 0; i < 64; i++)
-		*ptr++ = ahc_inb(ahc, SRAM_BASE + i);
-
-	if ((ahc->features & AHC_MORE_SRAM) != 0) {
-		for (i = 0; i < 16; i++)
-			*ptr++ = ahc_inb(ahc, TARG_OFFSET + i);
-	}
-
-	ptr = ahc->suspend_state.btt;
-	if ((ahc->flags & AHC_SCB_BTT) != 0) {
-		for (i = 0;i < AHC_NUM_TARGETS; i++) {
-			int j;
-
-			for (j = 0;j < AHC_NUM_LUNS; j++) {
-				u_int tcl;
-
-				tcl = BUILD_TCL(i << 4, j);
-				*ptr = ahc_index_busy_tcl(ahc, tcl);
-			}
-		}
 	}
+#endif
 	ahc_shutdown(ahc);
 	return (0);
 }
@@ -4903,81 +5161,10 @@
 int
 ahc_resume(struct ahc_softc *ahc)
 {
-	uint8_t *ptr;
-	int	 i;
-
-	ahc_reset(ahc);
-
-	ahc_build_free_scb_list(ahc);
-
-	/* Restore volatile registers */
-	if ((ahc->features & AHC_TWIN) != 0) {
-		ahc_outb(ahc, SBLKCTL, ahc_inb(ahc, SBLKCTL) | SELBUSB);
-		ahc_outb(ahc, SCSIID, ahc->our_id);
-		ahc_outb(ahc, SCSISEQ, ahc->suspend_state.channel[1].scsiseq);
-		ahc_outb(ahc, SXFRCTL0, ahc->suspend_state.channel[1].sxfrctl0);
-		ahc_outb(ahc, SXFRCTL1, ahc->suspend_state.channel[1].sxfrctl1);
-		ahc_outb(ahc, SIMODE0, ahc->suspend_state.channel[1].simode0);
-		ahc_outb(ahc, SIMODE1, ahc->suspend_state.channel[1].simode1);
-		ahc_outb(ahc, SELTIMER, ahc->suspend_state.channel[1].seltimer);
-		ahc_outb(ahc, SEQCTL, ahc->suspend_state.channel[1].seqctl);
-		ahc_outb(ahc, SBLKCTL, ahc_inb(ahc, SBLKCTL) & ~SELBUSB);
-	}
-	ahc_outb(ahc, SCSISEQ, ahc->suspend_state.channel[0].scsiseq);
-	ahc_outb(ahc, SXFRCTL0, ahc->suspend_state.channel[0].sxfrctl0);
-	ahc_outb(ahc, SXFRCTL1, ahc->suspend_state.channel[0].sxfrctl1);
-	ahc_outb(ahc, SIMODE0, ahc->suspend_state.channel[0].simode0);
-	ahc_outb(ahc, SIMODE1, ahc->suspend_state.channel[0].simode1);
-	ahc_outb(ahc, SELTIMER, ahc->suspend_state.channel[0].seltimer);
-	ahc_outb(ahc, SEQCTL, ahc->suspend_state.channel[0].seqctl);
-	if ((ahc->features & AHC_ULTRA2) != 0)
-		ahc_outb(ahc, SCSIID_ULTRA2, ahc->our_id);
-	else
-		ahc_outb(ahc, SCSIID, ahc->our_id);
-
-	if ((ahc->chip & AHC_PCI) != 0) {
-		ahc_outb(ahc, DSCOMMAND0, ahc->suspend_state.dscommand0);
-		ahc_outb(ahc, DSPCISTATUS, ahc->suspend_state.dspcistatus);
-	}
-
-	if ((ahc->features & AHC_DT) != 0) {
-		u_int sfunct;
 
-		sfunct = ahc_inb(ahc, SFUNCT) & ~ALT_MODE;
-		ahc_outb(ahc, SFUNCT, sfunct | ALT_MODE);
-		ahc_outb(ahc, OPTIONMODE, ahc->suspend_state.optionmode);
-		ahc_outb(ahc, SFUNCT, sfunct);
-		ahc_outb(ahc, CRCCONTROL1, ahc->suspend_state.crccontrol1);
-	}
-
-	if ((ahc->features & AHC_MULTI_FUNC) != 0)
-		ahc_outb(ahc, SCBBADDR, ahc->suspend_state.scbbaddr);
-
-	if ((ahc->features & AHC_ULTRA2) != 0)
-		ahc_outb(ahc, DFF_THRSH, ahc->suspend_state.dff_thrsh);
-
-	ptr = ahc->suspend_state.scratch_ram;
-	for (i = 0; i < 64; i++)
-		ahc_outb(ahc, SRAM_BASE + i, *ptr++);
-
-	if ((ahc->features & AHC_MORE_SRAM) != 0) {
-		for (i = 0; i < 16; i++)
-			ahc_outb(ahc, TARG_OFFSET + i, *ptr++);
-	}
-
-	ptr = ahc->suspend_state.btt;
-	if ((ahc->flags & AHC_SCB_BTT) != 0) {
-		for (i = 0;i < AHC_NUM_TARGETS; i++) {
-			int j;
-
-			for (j = 0;j < AHC_NUM_LUNS; j++) {
-				u_int tcl;
-
-				tcl = BUILD_TCL(i << 4, j);
-				ahc_busy_tcl(ahc, tcl, *ptr);
-			}
-		}
-	}
+	ahc_reset(ahc, /*reinit*/TRUE);
+	ahc_intr_enable(ahc, TRUE); 
+	ahc_restart(ahc);
 	return (0);
 }
 
@@ -5059,7 +5246,7 @@
 	if (match != 0)
 		match = ((lun == slun) || (lun == CAM_LUN_WILDCARD));
 	if (match != 0) {
-#if AHC_TARGET_MODE
+#ifdef AHC_TARGET_MODE
 		int group;
 
 		group = XPT_FC_GROUP(scb->io_ctx->ccb_h.func_code);
@@ -5139,8 +5326,8 @@
 static int
 ahc_qinfifo_count(struct ahc_softc *ahc)
 {
-	u_int8_t qinpos;
-	u_int8_t diff;
+	uint8_t qinpos;
+	uint8_t diff;
 
 	if ((ahc->features & AHC_QUEUE_REGS) != 0) {
 		qinpos = ahc_inb(ahc, SNSCB_QOFF);
@@ -5444,6 +5631,7 @@
 				break;
 			}
 			case SEARCH_REMOVE:
+				scb->flags &= ~SCB_UNTAGGEDQ;
 				TAILQ_REMOVE(untagged_q, scb, links.tqe);
 				break;
 			case SEARCH_COUNT:
@@ -5801,7 +5989,7 @@
 	 * before the reset occurred.
 	 */
 	ahc_run_qoutfifo(ahc);
-#if AHC_TARGET_MODE
+#ifdef AHC_TARGET_MODE
 	/*
 	 * XXX - In Twin mode, the tqinfifo may have commands
 	 *	 for an unaffected channel in it.  However, if
@@ -5833,7 +6021,7 @@
 		 */
 		ahc_outb(ahc, SBLKCTL, sblkctl ^ SELBUSB);
 		simode1 = ahc_inb(ahc, SIMODE1) & ~(ENBUSFREE|ENSCSIRST);
-#if AHC_TARGET_MODE
+#ifdef AHC_TARGET_MODE
 		/*
 		 * Bus resets clear ENSELI, so we cannot
 		 * defer re-enabling bus reset interrupts
@@ -5852,7 +6040,7 @@
 	} else {
 		/* Case 2: A command from this bus is active or we're idle */
 		simode1 = ahc_inb(ahc, SIMODE1) & ~(ENBUSFREE|ENSCSIRST);
-#if AHC_TARGET_MODE
+#ifdef AHC_TARGET_MODE
 		/*
 		 * Bus resets clear ENSELI, so we cannot
 		 * defer re-enabling bus reset interrupts
@@ -6017,9 +6205,10 @@
 		ahc_set_sense_residual(scb, resid);
 
 #ifdef AHC_DEBUG
-	if ((ahc_debug & AHC_SHOWMISC) != 0) {
+	if ((ahc_debug & AHC_SHOW_MISC) != 0) {
 		ahc_print_path(ahc, scb);
-		printf("Handled Residual of %d bytes\n", resid);
+		printf("Handled %sResidual of %d bytes\n",
+		       (scb->flags & SCB_SENSE) ? "Sense " : "", resid);
 	}
 #endif
 }
@@ -6120,19 +6309,11 @@
 ahc_dumpseq(struct ahc_softc* ahc)
 {
 	int i;
-	int max_prog;
-
-	if ((ahc->chip & AHC_BUS_MASK) < AHC_PCI)
-		max_prog = 448;
-	else if ((ahc->features & AHC_ULTRA2) != 0)
-		max_prog = 768;
-	else
-		max_prog = 512;
 
 	ahc_outb(ahc, SEQCTL, PERRORDIS|FAILDIS|FASTMODE|LOADRAM);
 	ahc_outb(ahc, SEQADDR0, 0);
 	ahc_outb(ahc, SEQADDR1, 0);
-	for (i = 0; i < max_prog; i++) {
+	for (i = 0; i < ahc->instruction_ram_size; i++) {
 		uint8_t ins_bytes[4];
 
 		ahc_insb(ahc, SEQRAM, ins_bytes, 4);
@@ -6144,7 +6325,7 @@
 }
 #endif
 
-static void
+static int
 ahc_loadseq(struct ahc_softc *ahc)
 {
 	struct	cs cs_table[num_critical_sections];
@@ -6154,9 +6335,9 @@
 	u_int	cs_count;
 	u_int	cur_cs;
 	u_int	i;
-	int	downloaded;
 	u_int	skip_addr;
 	u_int	sg_prefetch_cnt;
+	int	downloaded;
 	uint8_t	download_consts[7];
 
 	/*
@@ -6197,6 +6378,19 @@
 			 */
 			continue;
 		}
+
+		if (downloaded == ahc->instruction_ram_size) {
+			/*
+			 * We're about to exceed the instruction
+			 * storage capacity for this chip.  Fail
+			 * the load.
+			 */
+			printf("\n%s: Program too large for instruction memory "
+			       "size of %d!\n", ahc_name(ahc),
+			       ahc->instruction_ram_size);
+			return (ENOMEM);
+		}
+
 		/*
 		 * Move through the CS table until we find a CS
 		 * that might apply to this instruction.
@@ -6232,10 +6426,13 @@
 		memcpy(ahc->critical_sections, cs_table, cs_count);
 	}
 	ahc_outb(ahc, SEQCTL, PERRORDIS|FAILDIS|FASTMODE);
-	ahc_restart(ahc);
 
-	if (bootverbose)
+	if (bootverbose) {
 		printf(" %d instructions downloaded\n", downloaded);
+		printf("%s: Features 0x%x, Bugs 0x%x, Flags 0x%x\n",
+		       ahc_name(ahc), ahc->features, ahc->bugs, ahc->flags);
+	}
+	return (0);
 }
 
 static int
@@ -6399,14 +6596,64 @@
 	}
 }
 
+int
+ahc_print_register(ahc_reg_parse_entry_t *table, u_int num_entries,
+		   const char *name, u_int address, u_int value,
+		   u_int *cur_column, u_int wrap_point)
+{
+	int	printed;
+	u_int	printed_mask;
+
+	if (cur_column != NULL && *cur_column >= wrap_point) {
+		printf("\n");
+		*cur_column = 0;
+	}
+	printed = printf("%s[0x%x]", name, value);
+	if (table == NULL) {
+		printed += printf(" ");
+		*cur_column += printed;
+		return (printed);
+	}
+	printed_mask = 0;
+	while (printed_mask != 0xFF) {
+		int entry;
+
+		for (entry = 0; entry < num_entries; entry++) {
+			if (((value & table[entry].mask)
+			  != table[entry].value)
+			 || ((printed_mask & table[entry].mask)
+			  == table[entry].mask))
+				continue;
+
+			printed += printf("%s%s",
+					  printed_mask == 0 ? ":(" : "|",
+					  table[entry].name);
+			printed_mask |= table[entry].mask;
+			
+			break;
+		}
+		if (entry >= num_entries)
+			break;
+	}
+	if (printed_mask != 0)
+		printed += printf(") ");
+	else
+		printed += printf(" ");
+	if (cur_column != NULL)
+		*cur_column += printed;
+	return (printed);
+}
+
 void
 ahc_dump_card_state(struct ahc_softc *ahc)
 {
-	struct scb *scb;
-	struct scb_tailq *untagged_q;
-	int target;
-	int maxtarget;
-	int i;
+	struct	scb *scb;
+	struct	scb_tailq *untagged_q;
+	u_int	cur_col;
+	int	paused;
+	int	target;
+	int	maxtarget;
+	int	i;
 	uint8_t last_phase;
 	uint8_t qinpos;
 	uint8_t qintail;
@@ -6414,33 +6661,53 @@
 	uint8_t scb_index;
 	uint8_t saved_scbptr;
 
-	saved_scbptr = ahc_inb(ahc, SCBPTR);
+	if (ahc_is_paused(ahc)) {
+		paused = 1;
+	} else {
+		paused = 0;
+		ahc_pause(ahc);
+	}
 
+	saved_scbptr = ahc_inb(ahc, SCBPTR);
 	last_phase = ahc_inb(ahc, LASTPHASE);
-	printf("%s: Dumping Card State %s, at SEQADDR 0x%x\n",
+	printf(">>>>>>>>>>>>>>>>>> Dump Card State Begins <<<<<<<<<<<<<<<<<\n"
+	       "%s: Dumping Card State %s, at SEQADDR 0x%x\n",
 	       ahc_name(ahc), ahc_lookup_phase_entry(last_phase)->phasemsg,
 	       ahc_inb(ahc, SEQADDR0) | (ahc_inb(ahc, SEQADDR1) << 8));
+	if (paused)
+		printf("Card was paused\n");
 	printf("ACCUM = 0x%x, SINDEX = 0x%x, DINDEX = 0x%x, ARG_2 = 0x%x\n",
 	       ahc_inb(ahc, ACCUM), ahc_inb(ahc, SINDEX), ahc_inb(ahc, DINDEX),
 	       ahc_inb(ahc, ARG_2));
 	printf("HCNT = 0x%x SCBPTR = 0x%x\n", ahc_inb(ahc, HCNT),
 	       ahc_inb(ahc, SCBPTR));
-	printf("SCSISEQ = 0x%x, SBLKCTL = 0x%x\n",
-	       ahc_inb(ahc, SCSISEQ), ahc_inb(ahc, SBLKCTL));
-	printf(" DFCNTRL = 0x%x, DFSTATUS = 0x%x\n",
-	       ahc_inb(ahc, DFCNTRL), ahc_inb(ahc, DFSTATUS));
-	printf("LASTPHASE = 0x%x, SCSISIGI = 0x%x, SXFRCTL0 = 0x%x\n",
-	       last_phase, ahc_inb(ahc, SCSISIGI), ahc_inb(ahc, SXFRCTL0));
-	printf("SSTAT0 = 0x%x, SSTAT1 = 0x%x\n",
-	       ahc_inb(ahc, SSTAT0), ahc_inb(ahc, SSTAT1));
+	cur_col = 0;
 	if ((ahc->features & AHC_DT) != 0)
-		printf("SCSIPHASE = 0x%x\n", ahc_inb(ahc, SCSIPHASE));
-	printf("STACK == 0x%x, 0x%x, 0x%x, 0x%x\n",
-		ahc_inb(ahc, STACK) | (ahc_inb(ahc, STACK) << 8),
-		ahc_inb(ahc, STACK) | (ahc_inb(ahc, STACK) << 8),
-		ahc_inb(ahc, STACK) | (ahc_inb(ahc, STACK) << 8),
-		ahc_inb(ahc, STACK) | (ahc_inb(ahc, STACK) << 8));
-	printf("SCB count = %d\n", ahc->scb_data->numscbs);
+		ahc_scsiphase_print(ahc_inb(ahc, SCSIPHASE), &cur_col, 50);
+	ahc_scsisigi_print(ahc_inb(ahc, SCSISIGI), &cur_col, 50);
+	ahc_error_print(ahc_inb(ahc, ERROR), &cur_col, 50);
+	ahc_scsibusl_print(ahc_inb(ahc, SCSIBUSL), &cur_col, 50);
+	ahc_lastphase_print(ahc_inb(ahc, LASTPHASE), &cur_col, 50);
+	ahc_scsiseq_print(ahc_inb(ahc, SCSISEQ), &cur_col, 50);
+	ahc_sblkctl_print(ahc_inb(ahc, SBLKCTL), &cur_col, 50);
+	ahc_scsirate_print(ahc_inb(ahc, SCSIRATE), &cur_col, 50);
+	ahc_seqctl_print(ahc_inb(ahc, SEQCTL), &cur_col, 50);
+	ahc_seq_flags_print(ahc_inb(ahc, SEQ_FLAGS), &cur_col, 50);
+	ahc_sstat0_print(ahc_inb(ahc, SSTAT0), &cur_col, 50);
+	ahc_sstat1_print(ahc_inb(ahc, SSTAT1), &cur_col, 50);
+	ahc_sstat2_print(ahc_inb(ahc, SSTAT2), &cur_col, 50);
+	ahc_sstat3_print(ahc_inb(ahc, SSTAT3), &cur_col, 50);
+	ahc_simode0_print(ahc_inb(ahc, SIMODE0), &cur_col, 50);
+	ahc_simode1_print(ahc_inb(ahc, SIMODE1), &cur_col, 50);
+	ahc_sxfrctl0_print(ahc_inb(ahc, SXFRCTL0), &cur_col, 50);
+	ahc_dfcntrl_print(ahc_inb(ahc, DFCNTRL), &cur_col, 50);
+	ahc_dfstatus_print(ahc_inb(ahc, DFSTATUS), &cur_col, 50);
+	if (cur_col != 0)
+		printf("\n");
+	printf("STACK:");
+	for (i = 0; i < STACK_SIZE; i++)
+	       printf(" 0x%x", ahc_inb(ahc, STACK)|(ahc_inb(ahc, STACK) << 8));
+	printf("\nSCB count = %d\n", ahc->scb_data->numscbs);
 	printf("Kernel NEXTQSCB = %d\n", ahc->next_queued_scb->hscb->tag);
 	printf("Card NEXTQSCB = %d\n", ahc_inb(ahc, NEXT_QUEUED_SCB));
 	/* QINFIFO */
@@ -6500,11 +6767,12 @@
 	printf("Sequencer SCB Info: ");
 	for (i = 0; i < ahc->scb_data->maxhscbs; i++) {
 		ahc_outb(ahc, SCBPTR, i);
-		printf("%d(c 0x%x, s 0x%x, l %d, t 0x%x) ",
-		       i, ahc_inb(ahc, SCB_CONTROL),
-		       ahc_inb(ahc, SCB_SCSIID),
-		       ahc_inb(ahc, SCB_LUN),
-		       ahc_inb(ahc, SCB_TAG));
+		cur_col = printf("\n%3d ", i);
+
+		ahc_scb_control_print(ahc_inb(ahc, SCB_CONTROL), &cur_col, 60);
+		ahc_scb_scsiid_print(ahc_inb(ahc, SCB_SCSIID), &cur_col, 60);
+		ahc_scb_lun_print(ahc_inb(ahc, SCB_LUN), &cur_col, 60);
+		ahc_scb_tag_print(ahc_inb(ahc, SCB_TAG), &cur_col, 60);
 	}
 	printf("\n");
 
@@ -6513,14 +6781,17 @@
 	LIST_FOREACH(scb, &ahc->pending_scbs, pending_links) {
 		if (i++ > 256)
 			break;
-		if (scb != LIST_FIRST(&ahc->pending_scbs))
-			printf(", ");
-		printf("%d(c 0x%x, s 0x%x, l %d)", scb->hscb->tag,
-		       scb->hscb->control, scb->hscb->scsiid, scb->hscb->lun);
+		cur_col = printf("\n%3d ", scb->hscb->tag);
+		ahc_scb_control_print(scb->hscb->control, &cur_col, 60);
+		ahc_scb_scsiid_print(scb->hscb->scsiid, &cur_col, 60);
+		ahc_scb_lun_print(scb->hscb->lun, &cur_col, 60);
 		if ((ahc->flags & AHC_PAGESCBS) == 0) {
 			ahc_outb(ahc, SCBPTR, scb->hscb->tag);
-			printf("(0x%x, 0x%x)", ahc_inb(ahc, SCB_CONTROL),
-			       ahc_inb(ahc, SCB_TAG));
+			printf("(");
+			ahc_scb_control_print(ahc_inb(ahc, SCB_CONTROL),
+					      &cur_col, 60);
+			ahc_scb_tag_print(ahc_inb(ahc, SCB_TAG), &cur_col, 60);
+			printf(")");
 		}
 	}
 	printf("\n");
@@ -6550,7 +6821,10 @@
 	}
 
 	ahc_platform_dump_card_state(ahc);
+	printf("\n<<<<<<<<<<<<<<<<< Dump Card State Ends >>>>>>>>>>>>>>>>>>\n");
 	ahc_outb(ahc, SCBPTR, saved_scbptr);
+	if (paused == 0)
+		ahc_unpause(ahc);
 }
 
 /************************* Target Mode ****************************************/
@@ -6603,10 +6877,12 @@
 	struct	   ahc_tmode_lstate *lstate;
 	struct	   ccb_en_lun *cel;
 	cam_status status;
+	u_long	   s;
 	u_int	   target;
 	u_int	   lun;
 	u_int	   target_mask;
-	u_long	   s;
+	u_int	   our_id;
+	int	   error;
 	char	   channel;
 
 	status = ahc_find_tmode_devs(ahc, sim, ccb, &tstate, &lstate,
@@ -6617,15 +6893,33 @@
 		return;
 	}
 
-	if ((ahc->features & AHC_MULTIROLE) != 0) {
-		u_int	   our_id;
+	if (cam_sim_bus(sim) == 0)
+		our_id = ahc->our_id;
+	else
+		our_id = ahc->our_id_b;
 
-		if (cam_sim_bus(sim) == 0)
-			our_id = ahc->our_id;
-		else
-			our_id = ahc->our_id_b;
+	if (ccb->ccb_h.target_id != our_id) {
+		/*
+		 * our_id represents our initiator ID, or
+		 * the ID of the first target to have an
+		 * enabled lun in target mode.  There are
+		 * two cases that may preclude enabling a
+		 * target id other than our_id.
+		 *
+		 *   o our_id is for an active initiator role.
+		 *     Since the hardware does not support
+		 *     reselections to the initiator role at
+		 *     anything other than our_id, and our_id
+		 *     is used by the hardware to indicate the
+		 *     ID to use for both select-out and
+		 *     reselect-out operations, the only target
+		 *     ID we can support in this mode is our_id.
+		 *
+		 *   o The MULTARGID feature is not available and
+		 *     a previous target mode ID has been enabled.
+		 */
+		if ((ahc->features & AHC_MULTIROLE) != 0) {
 
-		if (ccb->ccb_h.target_id != our_id) {
 			if ((ahc->features & AHC_MULTI_TID) != 0
 		   	 && (ahc->flags & AHC_INITIATORROLE) != 0) {
 				/*
@@ -6647,6 +6941,10 @@
 				 */
 				status = CAM_TID_INVALID;
 			}
+		} else if ((ahc->features & AHC_MULTI_TID) == 0
+			&& ahc->enabled_luns > 0) {
+
+			status = CAM_TID_INVALID;
 		}
 	}
 
@@ -6661,7 +6959,8 @@
 	 */
 	if ((ahc->flags & AHC_TARGETROLE) == 0
 	 && ccb->ccb_h.target_id != CAM_TARGET_WILDCARD) {
-		u_long	s;
+		u_long	 s;
+		ahc_flag saved_flags;
 
 		printf("Configuring Target Mode\n");
 		ahc_lock(ahc, &s);
@@ -6670,11 +6969,29 @@
 			ahc_unlock(ahc, &s);
 			return;
 		}
+		saved_flags = ahc->flags;
 		ahc->flags |= AHC_TARGETROLE;
 		if ((ahc->features & AHC_MULTIROLE) == 0)
 			ahc->flags &= ~AHC_INITIATORROLE;
 		ahc_pause(ahc);
-		ahc_loadseq(ahc);
+		error = ahc_loadseq(ahc);
+		if (error != 0) {
+			/*
+			 * Restore original configuration and notify
+			 * the caller that we cannot support target mode.
+			 * Since the adapter started out in this
+			 * configuration, the firmware load will succeed,
+			 * so there is no point in checking ahc_loadseq's
+			 * return value.
+			 */
+			ahc->flags = saved_flags;
+			(void)ahc_loadseq(ahc);
+			ahc_restart(ahc);
+			ahc_unlock(ahc, &s);
+			ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;
+			return;
+		}
+		ahc_restart(ahc);
 		ahc_unlock(ahc, &s);
 	}
 	cel = &ccb->cel;
@@ -6909,8 +7226,16 @@
 				printf("Configuring Initiator Mode\n");
 				ahc->flags &= ~AHC_TARGETROLE;
 				ahc->flags |= AHC_INITIATORROLE;
-				ahc_pause(ahc);
-				ahc_loadseq(ahc);
+				/*
+				 * Returning to a configuration that
+				 * fit previously will always succeed.
+				 */
+				(void)ahc_loadseq(ahc);
+				ahc_restart(ahc);
+				/*
+				 * Unpaused.  The extra unpause
+				 * that follows is harmless.
+				 */
 			}
 		}
 		ahc_unpause(ahc);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_host.h linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_host.h
--- linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_host.h	2002-11-28 23:53:14.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_host.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,96 +0,0 @@
-/*
- * Adaptec AIC7xxx device driver host template 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: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_host.h#9 $
- */
-
-#ifndef _AIC7XXX_HOST_H_
-#define _AIC7XXX_HOST_H_
-
-int		 ahc_linux_proc_info(char *, char **, off_t, int, int, int);
-int		 ahc_linux_queue(Scsi_Cmnd *, void (*)(Scsi_Cmnd *));
-int		 ahc_linux_detect(Scsi_Host_Template *);
-int		 ahc_linux_release(struct Scsi_Host *);
-const char	*ahc_linux_info(struct Scsi_Host *);
-int		 ahc_linux_biosparam(Disk *, kdev_t, int[]);
-int		 ahc_linux_bus_reset(Scsi_Cmnd *);
-int		 ahc_linux_dev_reset(Scsi_Cmnd *);
-int		 ahc_linux_abort(Scsi_Cmnd *);
-
-#if defined(__i386__)
-#  define AIC7XXX_BIOSPARAM ahc_linux_biosparam
-#else
-#  define AIC7XXX_BIOSPARAM NULL
-#endif
-
-/*
- * Scsi_Host_Template (see hosts.h) for AIC-7xxx - some fields
- * to do with card config are filled in after the card is detected.
- */
-#define AIC7XXX	{						\
-	next: NULL,						\
-	module: NULL,						\
-	proc_dir: NULL,						\
-	proc_info: ahc_linux_proc_info,				\
-	name: NULL,						\
-	detect: ahc_linux_detect,				\
-	release: ahc_linux_release,				\
-	info: ahc_linux_info,					\
-	command: NULL,						\
-	queuecommand: ahc_linux_queue,				\
-	eh_strategy_handler: NULL,				\
-	eh_abort_handler: ahc_linux_abort,			\
-	eh_device_reset_handler: ahc_linux_dev_reset,		\
-	eh_bus_reset_handler: ahc_linux_bus_reset,		\
-	eh_host_reset_handler: NULL,				\
-	abort: NULL,						\
-	reset: NULL,						\
-	slave_attach: NULL,					\
-	bios_param: AIC7XXX_BIOSPARAM,				\
-	can_queue: AHC_MAX_QUEUE,/* max simultaneous cmds     */\
-	this_id: -1,		 /* scsi id of host adapter   */\
-	sg_tablesize: AHC_NSEG,	 /* max scatter-gather cmds   */\
-	cmd_per_lun: 2,		 /* cmds per lun	      */\
-	present: 0,		 /* number of 7xxx's present  */\
-	unchecked_isa_dma: 0,	 /* no memory DMA restrictions*/\
-	use_clustering: ENABLE_CLUSTERING,			\
-	use_new_eh_code: 1,					\
-	highmem_io: 1,						\
-}
-
-#endif /* _AIC7XXX_HOST_H_ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_inline.h linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_inline.h
--- linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_inline.h	2002-08-03 00:39:44.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_inline.h	2003-06-26 21:43:33.000000000 +0000
@@ -37,9 +37,9 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#35 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#43 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx_inline.h,v 1.2.2.11 2002/04/29 19:36:31 gibbs Exp $
+ * $FreeBSD$
  */
 
 #ifndef _AIC7XXX_INLINE_H_
@@ -238,6 +238,18 @@
 					    char channel, u_int our_id,
 					    u_int remote_id,
 					    struct ahc_tmode_tstate **tstate);
+static __inline uint16_t
+			ahc_inw(struct ahc_softc *ahc, u_int port);
+static __inline void	ahc_outw(struct ahc_softc *ahc, u_int port,
+				 u_int value);
+static __inline uint32_t
+			ahc_inl(struct ahc_softc *ahc, u_int port);
+static __inline void	ahc_outl(struct ahc_softc *ahc, u_int port,
+				 uint32_t value);
+static __inline uint64_t
+			ahc_inq(struct ahc_softc *ahc, u_int port);
+static __inline void	ahc_outq(struct ahc_softc *ahc, u_int port,
+				 uint64_t value);
 static __inline struct scb*
 			ahc_get_scb(struct ahc_softc *ahc);
 static __inline void	ahc_free_scb(struct ahc_softc *ahc, struct scb *scb);
@@ -285,6 +297,63 @@
 	return (&(*tstate)->transinfo[remote_id]);
 }
 
+static __inline uint16_t
+ahc_inw(struct ahc_softc *ahc, u_int port)
+{
+	return ((ahc_inb(ahc, port+1) << 8) | ahc_inb(ahc, port));
+}
+
+static __inline void
+ahc_outw(struct ahc_softc *ahc, u_int port, u_int value)
+{
+	ahc_outb(ahc, port, value & 0xFF);
+	ahc_outb(ahc, port+1, (value >> 8) & 0xFF);
+}
+
+static __inline uint32_t
+ahc_inl(struct ahc_softc *ahc, u_int port)
+{
+	return ((ahc_inb(ahc, port))
+	      | (ahc_inb(ahc, port+1) << 8)
+	      | (ahc_inb(ahc, port+2) << 16)
+	      | (ahc_inb(ahc, port+3) << 24));
+}
+
+static __inline void
+ahc_outl(struct ahc_softc *ahc, u_int port, uint32_t value)
+{
+	ahc_outb(ahc, port, (value) & 0xFF);
+	ahc_outb(ahc, port+1, ((value) >> 8) & 0xFF);
+	ahc_outb(ahc, port+2, ((value) >> 16) & 0xFF);
+	ahc_outb(ahc, port+3, ((value) >> 24) & 0xFF);
+}
+
+static __inline uint64_t
+ahc_inq(struct ahc_softc *ahc, u_int port)
+{
+	return ((ahc_inb(ahc, port))
+	      | (ahc_inb(ahc, port+1) << 8)
+	      | (ahc_inb(ahc, port+2) << 16)
+	      | (ahc_inb(ahc, port+3) << 24)
+	      | (((uint64_t)ahc_inb(ahc, port+4)) << 32)
+	      | (((uint64_t)ahc_inb(ahc, port+5)) << 40)
+	      | (((uint64_t)ahc_inb(ahc, port+6)) << 48)
+	      | (((uint64_t)ahc_inb(ahc, port+7)) << 56));
+}
+
+static __inline void
+ahc_outq(struct ahc_softc *ahc, u_int port, uint64_t value)
+{
+	ahc_outb(ahc, port, value & 0xFF);
+	ahc_outb(ahc, port+1, (value >> 8) & 0xFF);
+	ahc_outb(ahc, port+2, (value >> 16) & 0xFF);
+	ahc_outb(ahc, port+3, (value >> 24) & 0xFF);
+	ahc_outb(ahc, port+4, (value >> 32) & 0xFF);
+	ahc_outb(ahc, port+5, (value >> 40) & 0xFF);
+	ahc_outb(ahc, port+6, (value >> 48) & 0xFF);
+	ahc_outb(ahc, port+7, (value >> 56) & 0xFF);
+}
+
 /*
  * Get a free scb. If there are none, see if we can allocate a new SCB.
  */
@@ -386,12 +455,19 @@
 		      scb->hscb->tag, scb->hscb->next);
 
 	/*
+	 * Setup data "oddness".
+	 */
+	scb->hscb->lun &= LID;
+	if (ahc_get_transfer_length(scb) & 0x1)
+		scb->hscb->lun |= SCB_XFERLEN_ODD;
+
+	/*
 	 * Keep a history of SCBs we've downloaded in the qinfifo.
 	 */
 	ahc->qinfifo[ahc->qinfifonext++] = scb->hscb->tag;
 
 	/*
-	 * Make sure our data is consistant from the
+	 * Make sure our data is consistent from the
 	 * perspective of the adapter.
 	 */
 	ahc_sync_scb(ahc, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
@@ -431,7 +507,7 @@
 static __inline void	ahc_sync_qoutfifo(struct ahc_softc *ahc, int op);
 static __inline void	ahc_sync_tqinfifo(struct ahc_softc *ahc, int op);
 static __inline u_int	ahc_check_cmdcmpltqueues(struct ahc_softc *ahc);
-static __inline void	ahc_intr(struct ahc_softc *ahc);
+static __inline int	ahc_intr(struct ahc_softc *ahc);
 
 static __inline void
 ahc_sync_qoutfifo(struct ahc_softc *ahc, int op)
@@ -489,11 +565,20 @@
 /*
  * Catch an interrupt from the adapter
  */
-static __inline void
+static __inline int
 ahc_intr(struct ahc_softc *ahc)
 {
 	u_int	intstat;
 
+	if ((ahc->pause & INTEN) == 0) {
+		/*
+		 * Our interrupt is not enabled on the chip
+		 * and may be disabled for re-entrancy reasons,
+		 * so just return.  This is likely just a shared
+		 * interrupt.
+		 */
+		return (0);
+	}
 	/*
 	 * Instead of directly reading the interrupt status register,
 	 * infer the cause of the interrupt by checking our in-core
@@ -507,6 +592,20 @@
 		intstat = ahc_inb(ahc, INTSTAT);
 	}
 
+	if ((intstat & INT_PEND) == 0) {
+#if AHC_PCI_CONFIG > 0
+		if (ahc->unsolicited_ints > 500) {
+			ahc->unsolicited_ints = 0;
+			if ((ahc->chip & AHC_PCI) != 0
+			 && (ahc_inb(ahc, ERROR) & PCIERRSTAT) != 0)
+				ahc->bus_intr(ahc);
+		}
+#endif
+		ahc->unsolicited_ints++;
+		return (0);
+	}
+	ahc->unsolicited_ints = 0;
+
 	if (intstat & CMDCMPLT) {
 		ahc_outb(ahc, CLRINT, CLRCMDINT);
 
@@ -526,38 +625,25 @@
 #endif
 	}
 
-	if (intstat == 0xFF && (ahc->features & AHC_REMOVABLE) != 0)
-		/* Hot eject */
-		return;
-
-	if ((intstat & INT_PEND) == 0) {
-#if AHC_PCI_CONFIG > 0
-		if (ahc->unsolicited_ints > 500) {
-			ahc->unsolicited_ints = 0;
-			if ((ahc->chip & AHC_PCI) != 0
-			 && (ahc_inb(ahc, ERROR) & PCIERRSTAT) != 0)
-				ahc->bus_intr(ahc);
-		}
-#endif
-		ahc->unsolicited_ints++;
-		return;
-	}
-	ahc->unsolicited_ints = 0;
-
-	if (intstat & BRKADRINT) {
+	/*
+	 * Handle statuses that may invalidate our cached
+	 * copy of INTSTAT separately.
+	 */
+	if (intstat == 0xFF && (ahc->features & AHC_REMOVABLE) != 0) {
+		/* Hot eject.  Do nothing */
+	} else if (intstat & BRKADRINT) {
 		ahc_handle_brkadrint(ahc);
-		/* Fatal error, no more interrupts to handle. */
-		return;
-	}
+	} else if ((intstat & (SEQINT|SCSIINT)) != 0) {
 
-	if ((intstat & (SEQINT|SCSIINT)) != 0)
 		ahc_pause_bug_fix(ahc);
 
-	if ((intstat & SEQINT) != 0)
-		ahc_handle_seqint(ahc, intstat);
+		if ((intstat & SEQINT) != 0)
+			ahc_handle_seqint(ahc, intstat);
 
-	if ((intstat & SCSIINT) != 0)
-		ahc_handle_scsiint(ahc, intstat);
+		if ((intstat & SCSIINT) != 0)
+			ahc_handle_scsiint(ahc, intstat);
+	}
+	return (1);
 }
 
 #endif  /* _AIC7XXX_INLINE_H_ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_osm.c linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_osm.c
--- linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_osm.c	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_osm.c	2003-06-26 21:43:19.000000000 +0000
@@ -1,7 +1,7 @@
 /*
  * Adaptec AIC7xxx device driver for Linux.
  *
- * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#103 $
+ * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#234 $
  *
  * Copyright (c) 1994 John Aycock
  *   The University of Calgary Department of Computer Science.
@@ -108,7 +108,7 @@
  * but are not limited to:
  *
  *  1: Import of the latest FreeBSD sequencer code for this driver
- *  2: Modification of kernel code to accomodate different sequencer semantics
+ *  2: Modification of kernel code to accommodate different sequencer semantics
  *  3: Extensive changes throughout kernel portion of driver to improve
  *     abort/reset processing and error hanndling
  *  4: Other work contributed by various people on the Internet
@@ -119,36 +119,37 @@
  *
  */
 
-/*
- * This is the only file where module.h should
- * embed module global version info.
- */
-#define AHC_MODVERSION_FILE
-
 #include "aic7xxx_osm.h"
 #include "aic7xxx_inline.h"
+#include <scsi/scsicam.h>
+
+/*
+ * Include aiclib.c as part of our
+ * "module dependencies are hard" work around.
+ */
+#include "aiclib.c"
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 #include <linux/init.h>		/* __setup */
 #endif
 
-#include "../sd.h"		/* For geometry detection */
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+#include "sd.h"			/* For geometry detection */
+#endif
 
 #include <linux/mm.h>		/* For fetching system memory size */
 #include <linux/blk.h>		/* For block_size() */
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
 /*
  * Lock protecting manipulation of the ahc softc list.
  */
 spinlock_t ahc_list_spinlock;
-#endif
 
-/*
- * To generate the correct addresses for the controller to issue
- * on the bus.  Originally added for DEC Alpha support.
- */
-#define VIRT_TO_BUS(a) (uint32_t)virt_to_bus((void *)(a))
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+/* For dynamic sglist size calculation. */
+u_int ahc_linux_nseg;
+#endif
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
 struct proc_dir_entry proc_scsi_aic7xxx = {
@@ -280,6 +281,39 @@
 };
 
 /*
+ * DV option:
+ *
+ * positive value = DV Enabled
+ * zero		  = DV Disabled
+ * negative value = DV Default for adapter type/seeprom
+ */
+#ifdef CONFIG_AIC7XXX_DV_SETTING
+#define AIC7XXX_CONFIGED_DV CONFIG_AIC7XXX_DV_SETTING
+#else
+#define AIC7XXX_CONFIGED_DV -1
+#endif
+
+static int8_t aic7xxx_dv_settings[] =
+{
+	AIC7XXX_CONFIGED_DV,
+	AIC7XXX_CONFIGED_DV,
+	AIC7XXX_CONFIGED_DV,
+	AIC7XXX_CONFIGED_DV,
+	AIC7XXX_CONFIGED_DV,
+	AIC7XXX_CONFIGED_DV,
+	AIC7XXX_CONFIGED_DV,
+	AIC7XXX_CONFIGED_DV,
+	AIC7XXX_CONFIGED_DV,
+	AIC7XXX_CONFIGED_DV,
+	AIC7XXX_CONFIGED_DV,
+	AIC7XXX_CONFIGED_DV,
+	AIC7XXX_CONFIGED_DV,
+	AIC7XXX_CONFIGED_DV,
+	AIC7XXX_CONFIGED_DV,
+	AIC7XXX_CONFIGED_DV
+};
+
+/*
  * There should be a specific return value for this in scsi.h, but
  * it seems that most drivers ignore it.
  */
@@ -325,31 +359,26 @@
  * disabled at the very end.  That should fix everyone up unless there are
  * really strange cirumstances.
  */
-static int aic7xxx_reverse_scan = 0;
+static uint32_t aic7xxx_reverse_scan;
 
 /*
  * Should we force EXTENDED translation on a controller.
  *     0 == Use whatever is in the SEEPROM or default to off
  *     1 == Use whatever is in the SEEPROM or default to on
  */
-static uint32_t aic7xxx_extended = 0;
+static uint32_t aic7xxx_extended;
 
 /*
  * PCI bus parity checking of the Adaptec controllers.  This is somewhat
  * dubious at best.  To my knowledge, this option has never actually
  * solved a PCI parity problem, but on certain machines with broken PCI
- * chipset configurations, it can generate tons of false error messages.
+ * chipset configurations where stray PCI transactions with bad parity are
+ * the norm rather than the exception, the error messages can be overwelming.
  * It's included in the driver for completeness.
- *   0 = Shut off PCI parity check
- *  -1 = Normal polarity pci parity checking
- *   1 = reverse polarity pci parity checking
- *
- * NOTE: you can't actually pass -1 on the lilo prompt.  So, to set this
- * variable to -1 you would actually want to simply pass the variable
- * name without a number.  That will invert the 0 which will result in
- * -1.
+ *   0	   = Shut off PCI parity check
+ *   non-0 = reverse polarity pci parity checking
  */
-static int aic7xxx_pci_parity = 0;
+static uint32_t aic7xxx_pci_parity = ~0;
 
 /*
  * Certain newer motherboards have put new PCI based devices into the
@@ -362,15 +391,20 @@
  * would result in never finding any devices :)
  */
 #ifndef CONFIG_AIC7XXX_PROBE_EISA_VL
-#define CONFIG_AIC7XXX_PROBE_EISA_VL n
-#endif
-#if CONFIG_AIC7XXX_PROBE_EISA_VL == n
-static int aic7xxx_no_probe = 1;
+uint32_t aic7xxx_probe_eisa_vl;
 #else
-static int aic7xxx_no_probe;
+uint32_t aic7xxx_probe_eisa_vl = ~0;
 #endif
 
 /*
+ * There are lots of broken chipsets in the world.  Some of them will
+ * violate the PCI spec when we issue byte sized memory writes to our
+ * controller.  I/O mapped register access, if allowed by the given
+ * platform, will work in almost all cases.
+ */
+uint32_t aic7xxx_allow_memio = ~0;
+
+/*
  * aic7xxx_detect() has been run, so register all device arrivals
  * immediately with the system rather than deferring to the sorted
  * attachment performed by aic7xxx_detect().
@@ -387,7 +421,7 @@
  * We default to 256ms because some older devices need a longer time
  * to respond to initial selection.
  */
-static int aic7xxx_seltime = 0x00;
+static uint32_t aic7xxx_seltime;
 
 /*
  * Certain devices do not perform any aging on commands.  Should the
@@ -397,7 +431,7 @@
  * force all outstanding transactions to be serviced prior to a new
  * transaction.
  */
-int aic7xxx_periodic_otag;
+uint32_t aic7xxx_periodic_otag;
 
 /*
  * Module information and settable options.
@@ -413,49 +447,99 @@
 
 MODULE_AUTHOR("Maintainer: Justin T. Gibbs <gibbs@scsiguy.com>");
 MODULE_DESCRIPTION("Adaptec Aic77XX/78XX SCSI Host Bus Adapter driver");
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,10)
+#ifdef MODULE_LICENSE
 MODULE_LICENSE("Dual BSD/GPL");
 #endif
 MODULE_PARM(aic7xxx, "s");
-MODULE_PARM_DESC(aic7xxx, "period delimited, options string.\n"
+MODULE_PARM_DESC(aic7xxx,
+"period delimited, options string.\n"
 "	verbose			Enable verbose/diagnostic logging\n"
-"	no_probe		Disable EISA/VLB controller probing\n"
+"	allow_memio		Allow device registers to be memory mapped\n"
+"	debug			Bitmask of debug values to enable\n"
+"	no_probe		Toggle EISA/VLB controller probing\n"
+"	probe_eisa_vl		Toggle EISA/VLB controller probing\n"
 "	no_reset		Supress initial bus resets\n"
 "	extended		Enable extended geometry on all controllers\n"
-"	periodic_otag		Send an ordered tagged transaction periodically\n"
-"				to prevent tag starvation.  This may be\n"
-"				required by some older disk drives/RAID arrays.\n"
+"	periodic_otag		Send an ordered tagged transaction\n"
+"				periodically to prevent tag starvation.\n"
+"				This may be required by some older disk\n"
+"				drives or RAID arrays.\n"
 "	reverse_scan		Sort PCI devices highest Bus/Slot to lowest\n"
 "	tag_info:<tag_str>	Set per-target tag depth\n"
-"	seltime:<int>		Selection Timeout(0/256ms,1/128ms,2/64ms,3/32ms)\n"
+"	global_tag_depth:<int>	Global tag depth for every target\n"
+"				on every bus\n"
+"	dv:<dv_settings>	Set per-controller Domain Validation Setting.\n"
+"	seltime:<int>		Selection Timeout\n"
+"				(0/256ms,1/128ms,2/64ms,3/32ms)\n"
 "\n"
 "	Sample /etc/modules.conf line:\n"
-"		Enable verbose logging\n"
-"		Disable EISA/VLB probing\n"
-"		Set tag depth on Controller 2/Target 2 to 10 tags\n"
-"		Shorten the selection timeout to 128ms from its default of 256\n"
+"		Toggle EISA/VLB probing\n"
+"		Set tag depth on Controller 1/Target 1 to 10 tags\n"
+"		Shorten the selection timeout to 128ms\n"
 "\n"
-"	options aic7xxx='\"verbose.no_probe.tag_info:{{}.{}.{..10}}.seltime:1\"'"
+"	options aic7xxx 'aic7xxx=probe_eisa_vl.tag_info:{{}.{.10}}.seltime:1'\n"
 );
 #endif
 
 static void ahc_linux_handle_scsi_status(struct ahc_softc *,
 					 struct ahc_linux_device *,
 					 struct scb *);
-static void ahc_linux_filter_command(struct ahc_softc*, Scsi_Cmnd*,
-				     struct scb*);
+static void ahc_linux_queue_cmd_complete(struct ahc_softc *ahc,
+					 Scsi_Cmnd *cmd);
+static void ahc_linux_filter_inquiry(struct ahc_softc*, struct ahc_devinfo*);
 static void ahc_linux_sem_timeout(u_long arg);
-static void ahc_linux_freeze_sim_queue(struct ahc_softc *ahc);
-static void ahc_linux_release_sim_queue(u_long arg);
+static void ahc_linux_freeze_simq(struct ahc_softc *ahc);
+static void ahc_linux_release_simq(u_long arg);
 static void ahc_linux_dev_timed_unfreeze(u_long arg);
 static int  ahc_linux_queue_recovery_cmd(Scsi_Cmnd *cmd, scb_flag flag);
 static void ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc);
-static void ahc_linux_select_queue_depth(struct Scsi_Host *host,
-					 Scsi_Device *scsi_devs);
+static void ahc_linux_size_nseg(void);
+static void ahc_linux_thread_run_complete_queue(struct ahc_softc *ahc);
+static void ahc_linux_start_dv(struct ahc_softc *ahc);
+static void ahc_linux_dv_timeout(struct scsi_cmnd *cmd);
+static int  ahc_linux_dv_thread(void *data);
+static void ahc_linux_kill_dv_thread(struct ahc_softc *ahc);
+static void ahc_linux_dv_target(struct ahc_softc *ahc, u_int target);
+static void ahc_linux_dv_transition(struct ahc_softc *ahc,
+				    struct scsi_cmnd *cmd,
+				    struct ahc_devinfo *devinfo,
+				    struct ahc_linux_target *targ);
+static void ahc_linux_dv_fill_cmd(struct ahc_softc *ahc,
+				  struct scsi_cmnd *cmd,
+				  struct ahc_devinfo *devinfo);
+static void ahc_linux_dv_inq(struct ahc_softc *ahc,
+			     struct scsi_cmnd *cmd,
+			     struct ahc_devinfo *devinfo,
+			     struct ahc_linux_target *targ,
+			     u_int request_length);
+static void ahc_linux_dv_tur(struct ahc_softc *ahc,
+			     struct scsi_cmnd *cmd,
+			     struct ahc_devinfo *devinfo);
+static void ahc_linux_dv_rebd(struct ahc_softc *ahc,
+			      struct scsi_cmnd *cmd,
+			      struct ahc_devinfo *devinfo,
+			      struct ahc_linux_target *targ);
+static void ahc_linux_dv_web(struct ahc_softc *ahc,
+			     struct scsi_cmnd *cmd,
+			     struct ahc_devinfo *devinfo,
+			     struct ahc_linux_target *targ);
+static void ahc_linux_dv_reb(struct ahc_softc *ahc,
+			     struct scsi_cmnd *cmd,
+			     struct ahc_devinfo *devinfo,
+			     struct ahc_linux_target *targ);
+static void ahc_linux_dv_su(struct ahc_softc *ahc,
+			    struct scsi_cmnd *cmd,
+			    struct ahc_devinfo *devinfo,
+			    struct ahc_linux_target *targ);
+static int ahc_linux_fallback(struct ahc_softc *ahc,
+			      struct ahc_devinfo *devinfo);
+static void ahc_linux_dv_complete(Scsi_Cmnd *cmd);
+static void ahc_linux_generate_dv_pattern(struct ahc_linux_target *targ);
 static u_int ahc_linux_user_tagdepth(struct ahc_softc *ahc,
 				     struct ahc_devinfo *devinfo);
+static u_int ahc_linux_user_dv_setting(struct ahc_softc *ahc);
 static void ahc_linux_device_queue_depth(struct ahc_softc *ahc,
-					 Scsi_Device *device);
+					 struct ahc_linux_device *dev);
 static struct ahc_linux_target*	ahc_linux_alloc_target(struct ahc_softc*,
 						       u_int, u_int);
 static void			ahc_linux_free_target(struct ahc_softc*,
@@ -467,34 +551,60 @@
 						      struct ahc_linux_device*);
 static void ahc_linux_run_device_queue(struct ahc_softc*,
 				       struct ahc_linux_device*);
-static void ahc_linux_setup_tag_info(char *p, char *end);
-static int ahc_linux_next_unit(void);
+static void ahc_linux_setup_tag_info_global(char *p);
+static aic_option_callback_t ahc_linux_setup_tag_info;
+static aic_option_callback_t ahc_linux_setup_dv;
+static int  aic7xxx_setup(char *s);
+static int  ahc_linux_next_unit(void);
 static void ahc_runq_tasklet(unsigned long data);
-static int ahc_linux_halt(struct notifier_block *nb, u_long event, void *buf);
+static struct ahc_cmd *ahc_linux_run_complete_queue(struct ahc_softc *ahc);
 
+/********************************* Inlines ************************************/
+static __inline void ahc_schedule_runq(struct ahc_softc *ahc);
 static __inline struct ahc_linux_device*
 		     ahc_linux_get_device(struct ahc_softc *ahc, u_int channel,
 					  u_int target, u_int lun, int alloc);
-static __inline void ahc_linux_queue_cmd_complete(struct ahc_softc *ahc,
-						  Scsi_Cmnd *cmd);
-static __inline void ahc_linux_run_complete_queue(struct ahc_softc *ahc,
-						  struct ahc_cmd *acmd);
+static __inline void ahc_schedule_completeq(struct ahc_softc *ahc);
 static __inline void ahc_linux_check_device_queue(struct ahc_softc *ahc,
 						  struct ahc_linux_device *dev);
 static __inline struct ahc_linux_device *
 		     ahc_linux_next_device_to_run(struct ahc_softc *ahc);
 static __inline void ahc_linux_run_device_queues(struct ahc_softc *ahc);
-static __inline void ahc_linux_sniff_command(struct ahc_softc*, Scsi_Cmnd*,
-					     struct scb*);
 static __inline void ahc_linux_unmap_scb(struct ahc_softc*, struct scb*);
 
 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);
 
+static __inline void
+ahc_schedule_completeq(struct ahc_softc *ahc)
+{
+	if ((ahc->platform_data->flags & AHC_RUN_CMPLT_Q_TIMER) == 0) {
+		ahc->platform_data->flags |= AHC_RUN_CMPLT_Q_TIMER;
+		ahc->platform_data->completeq_timer.expires = jiffies;
+		add_timer(&ahc->platform_data->completeq_timer);
+	}
+}
+
+/*
+ * Must be called with our lock held.
+ */
+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*
 ahc_linux_get_device(struct ahc_softc *ahc, u_int channel, u_int target,
-	       u_int lun, int alloc)
+		     u_int lun, int alloc)
 {
 	struct ahc_linux_target *targ;
 	struct ahc_linux_device *dev;
@@ -518,62 +628,43 @@
 	return (dev);
 }
 
-static __inline void
-ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, Scsi_Cmnd *cmd)
+#define AHC_LINUX_MAX_RETURNED_ERRORS 4
+static struct ahc_cmd *
+ahc_linux_run_complete_queue(struct ahc_softc *ahc)
 {
-	/*
-	 * Typically, the complete queue has very few entries
-	 * queued to it before the queue is emptied by
-	 * ahc_linux_run_complete_queue, so sorting the entries
-	 * by generation number should be inexpensive.
-	 * We perform the sort so that commands that complete
-	 * with an error are retuned in the order origionally
-	 * queued to the controller so that any subsequent retries
-	 * are performed in order.  The underlying ahc routines do
-	 * not guarantee the order that aborted commands will be
-	 * returned to us.
-	 */
-	struct ahc_completeq *completeq;
-	struct ahc_cmd *list_cmd;
-	struct ahc_cmd *acmd;
-
-	/*
-	 * If we want the request requeued, make sure there
-	 * are sufficent retries.  In the old scsi error code,
-	 * we used to be able to specify a result code that
-	 * bypassed the retry count.  Now we must use this
-	 * hack.
-	 */
-	if (cmd->result == (CAM_REQUEUE_REQ << 16))
-		cmd->retries--;
-	completeq = &ahc->platform_data->completeq;
-	list_cmd = TAILQ_FIRST(completeq);
-	acmd = (struct ahc_cmd *)cmd;
-	while (list_cmd != NULL
-	    && acmd_scsi_cmd(list_cmd).serial_number
-	     < acmd_scsi_cmd(acmd).serial_number)
-		list_cmd = TAILQ_NEXT(list_cmd, acmd_links.tqe);
-	if (list_cmd != NULL)
-		TAILQ_INSERT_BEFORE(list_cmd, acmd, acmd_links.tqe);
-	else
-		TAILQ_INSERT_TAIL(completeq, acmd, acmd_links.tqe);
-}
-
-static __inline void
-ahc_linux_run_complete_queue(struct ahc_softc *ahc, struct ahc_cmd *acmd)
-{	
-	u_long done_flags;
+	struct	ahc_cmd *acmd;
+	u_long	done_flags;
+	int	with_errors;
 
+	with_errors = 0;
 	ahc_done_lock(ahc, &done_flags);
-	while (acmd != NULL) {
+	while ((acmd = TAILQ_FIRST(&ahc->platform_data->completeq)) != NULL) {
 		Scsi_Cmnd *cmd;
 
+		if (with_errors > AHC_LINUX_MAX_RETURNED_ERRORS) {
+			/*
+			 * Linux uses stack recursion to requeue
+			 * commands that need to be retried.  Avoid
+			 * blowing out the stack by "spoon feeding"
+			 * commands that completed with error back
+			 * the operating system in case they are going
+			 * to be retried. "ick"
+			 */
+			ahc_schedule_completeq(ahc);
+			break;
+		}
+		TAILQ_REMOVE(&ahc->platform_data->completeq,
+			     acmd, acmd_links.tqe);
 		cmd = &acmd_scsi_cmd(acmd);
-		acmd = TAILQ_NEXT(acmd, acmd_links.tqe);
 		cmd->host_scribble = NULL;
+		if (ahc_cmd_get_transaction_status(cmd) != DID_OK
+		 || (cmd->result & 0xFF) != SCSI_STATUS_OK)
+			with_errors++;
+
 		cmd->scsi_done(cmd);
 	}
 	ahc_done_unlock(ahc, &done_flags);
+	return (acmd);
 }
 
 static __inline void
@@ -598,7 +689,8 @@
 {
 	
 	if ((ahc->flags & AHC_RESOURCE_SHORTAGE) != 0
-	 || ahc->platform_data->qfrozen != 0)
+	 || (ahc->platform_data->qfrozen != 0
+	  && AHC_DV_SIMQ_FROZEN(ahc) == 0))
 		return (NULL);
 	return (TAILQ_FIRST(&ahc->platform_data->device_runq));
 }
@@ -616,19 +708,6 @@
 }
 
 static __inline void
-ahc_linux_sniff_command(struct ahc_softc *ahc, Scsi_Cmnd *cmd, struct scb *scb)
-{
-	/*
-	 * Determine whether we care to filter
-	 * information out of this command.  If so,
-	 * pass it on to ahc_linux_filter_command() for more
-	 * heavy weight processing.
-	 */
-	if (cmd->cmnd[0] == INQUIRY)
-		ahc_linux_filter_command(ahc, cmd, scb);
-}
-
-static __inline void
 ahc_linux_unmap_scb(struct ahc_softc *ahc, struct scb *scb)
 {
 	Scsi_Cmnd *cmd;
@@ -662,906 +741,2808 @@
 	consumed = 1;
 	sg->addr = ahc_htole32(addr & 0xFFFFFFFF);
 	scb->platform_data->xfer_len += len;
+
 	if (sizeof(bus_addr_t) > 4
-	 && (ahc->flags & AHC_39BIT_ADDRESSING) != 0) {
-		/*
-		 * Due to DAC restrictions, we can't
-		 * cross a 4GB boundary.
-		 */
-		if ((addr ^ (addr + len - 1)) & ~0xFFFFFFFF) {
-			struct	 ahc_dma_seg *next_sg;
-			uint32_t next_len;
-
-			printf("Crossed Seg\n");
-			if ((scb->sg_count + 2) > AHC_NSEG)
-				panic("Too few segs for dma mapping.  "
-				      "Increase AHC_NSEG\n");
-
-			consumed++;
-			next_sg = sg + 1;
-			next_sg->addr = 0;
-			next_len = 0x100000000 - (addr & 0xFFFFFFFF);
-			len -= next_len;
-			next_len |= ((addr >> 8) + 0x1000000) & 0x7F000000;
-			next_sg->len = ahc_htole32(next_len);
-		}
-		len |= (addr >> 8) & 0x7F000000;
-	}
+	 && (ahc->flags & AHC_39BIT_ADDRESSING) != 0)
+		len |= (addr >> 8) & AHC_SG_HIGH_ADDR_MASK;
+
 	sg->len = ahc_htole32(len);
 	return (consumed);
 }
 
-/**************************** Tasklet Handler *********************************/
+/************************  Host template entry points *************************/
+static int	   ahc_linux_detect(Scsi_Host_Template *);
+static int	   ahc_linux_queue(Scsi_Cmnd *, void (*)(Scsi_Cmnd *));
+static const char *ahc_linux_info(struct Scsi_Host *);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+static int	   ahc_linux_slave_alloc(Scsi_Device *);
+static int	   ahc_linux_slave_configure(Scsi_Device *);
+static void	   ahc_linux_slave_destroy(Scsi_Device *);
+#if defined(__i386__)
+static int	   ahc_linux_biosparam(struct scsi_device*,
+				       struct block_device*,
+				       sector_t, int[]);
+#endif
+#else
+static int	   ahc_linux_release(struct Scsi_Host *);
+static void	   ahc_linux_select_queue_depth(struct Scsi_Host *host,
+						Scsi_Device *scsi_devs);
+#if defined(__i386__)
+static int	   ahc_linux_biosparam(Disk *, kdev_t, int[]);
+#endif
+#endif
+static int	   ahc_linux_bus_reset(Scsi_Cmnd *);
+static int	   ahc_linux_dev_reset(Scsi_Cmnd *);
+static int	   ahc_linux_abort(Scsi_Cmnd *);
 
+/*
+ * Calculate a safe value for AHC_NSEG (as expressed through ahc_linux_nseg).
+ *
+ * In pre-2.5.X...
+ * The midlayer allocates an S/G array dynamically when a command is issued
+ * using SCSI malloc.  This array, which is in an OS dependent format that
+ * must later be copied to our private S/G list, is sized to house just the
+ * number of segments needed for the current transfer.  Since the code that
+ * sizes the SCSI malloc pool does not take into consideration fragmentation
+ * of the pool, executing transactions numbering just a fraction of our
+ * concurrent transaction limit with list lengths aproaching AHC_NSEG will
+ * quickly depleat the SCSI malloc pool of usable space.  Unfortunately, the
+ * mid-layer does not properly handle this scsi malloc failures for the S/G
+ * array and the result can be a lockup of the I/O subsystem.  We try to size
+ * our S/G list so that it satisfies our drivers allocation requirements in
+ * addition to avoiding fragmentation of the SCSI malloc pool.
+ */
 static void
-ahc_runq_tasklet(unsigned long data)
+ahc_linux_size_nseg(void)
 {
-	struct ahc_softc* ahc;
-	struct ahc_linux_device *dev;
-	u_long flags;
-
-	ahc = (struct ahc_softc *)data;
-	ahc_lock(ahc, &flags);
-	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);
-		/* Yeild to our interrupt handler */
-		ahc_unlock(ahc, &flags);
-		ahc_lock(ahc, &flags);
-	}
-	ahc_unlock(ahc, &flags);
-}
-
-/************************ Shutdown/halt/reboot hook ***************************/
-#include <linux/notifier.h>
-#include <linux/reboot.h>
-
-static struct notifier_block ahc_linux_notifier = {
-	ahc_linux_halt, NULL, 0
-};
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+	u_int cur_size;
+	u_int best_size;
 
-static int ahc_linux_halt(struct notifier_block *nb, u_long event, void *buf)
-{
-	struct ahc_softc *ahc;
+	/*
+	 * The SCSI allocator rounds to the nearest 512 bytes
+	 * an cannot allocate across a page boundary.  Our algorithm
+	 * is to start at 1K of scsi malloc space per-command and
+	 * loop through all factors of the PAGE_SIZE and pick the best.
+	 */
+	best_size = 0;
+	for (cur_size = 1024; cur_size <= PAGE_SIZE; cur_size *= 2) {
+		u_int nseg;
+
+		nseg = cur_size / sizeof(struct scatterlist);
+		if (nseg < AHC_LINUX_MIN_NSEG)
+			continue;
+
+		if (best_size == 0) {
+			best_size = cur_size;
+			ahc_linux_nseg = nseg;
+		} else {
+			u_int best_rem;
+			u_int cur_rem;
 
-	if (event == SYS_DOWN || event == SYS_HALT) {
-		TAILQ_FOREACH(ahc, &ahc_tailq, links) {
-			ahc_shutdown(ahc);
+			/*
+			 * Compare the traits of the current "best_size"
+			 * with the current size to determine if the
+			 * current size is a better size.
+			 */
+			best_rem = best_size % sizeof(struct scatterlist);
+			cur_rem = cur_size % sizeof(struct scatterlist);
+			if (cur_rem < best_rem) {
+				best_size = cur_size;
+				ahc_linux_nseg = nseg;
+			}
 		}
 	}
-	return (NOTIFY_OK);
+#endif
 }
 
-/******************************** Macros **************************************/
-#define BUILD_SCSIID(ahc, cmd)						\
-	((((cmd)->target << TID_SHIFT) & TID)				\
-	| (((cmd)->channel == 0) ? (ahc)->our_id : (ahc)->our_id_b)	\
-	| (((cmd)->channel == 0) ? 0 : TWIN_CHNLB))
-
-/******************************** Bus DMA *************************************/
-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,
-		   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)
+/*
+ * Try to detect an Adaptec 7XXX controller.
+ */
+static int
+ahc_linux_detect(Scsi_Host_Template *template)
 {
-	bus_dma_tag_t dmat;
-
-	dmat = malloc(sizeof(*dmat), M_DEVBUF, M_NOWAIT);
-	if (dmat == NULL)
-		return (ENOMEM);
+	struct	ahc_softc *ahc;
+	int     found;
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 	/*
-	 * Linux is very simplistic about DMA memory.  For now don't
-	 * maintain all specification information.  Once Linux supplies
-	 * better facilities for doing these operations, or the
-	 * needs of this particular driver change, we might need to do
-	 * more here.
+	 * It is a bug that the upper layer takes
+	 * this lock just prior to calling us.
 	 */
-	dmat->alignment = alignment;
-	dmat->boundary = boundary;
-	dmat->maxsize = maxsize;
-	*ret_tag = dmat;
-	return (0);
-}
-
-void
-ahc_dma_tag_destroy(struct ahc_softc *ahc, bus_dma_tag_t dmat)
-{
-	free(dmat, M_DEVBUF);
-}
-
-int
-ahc_dmamem_alloc(struct ahc_softc *ahc, bus_dma_tag_t dmat, void** vaddr,
-		 int flags, bus_dmamap_t *mapp)
-{
-	bus_dmamap_t map;
+	spin_unlock_irq(&io_request_lock);
+#endif
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
-	map = malloc(sizeof(*map), M_DEVBUF, M_NOWAIT);
-	if (map == NULL)
-		return (ENOMEM);
 	/*
-	 * Although we can dma data above 4GB, our
-	 * "consistent" memory is below 4GB for
-	 * space efficiency reasons (only need a 4byte
-	 * address).  For this reason, we have to reset
-	 * our dma mask when doing allocations.
+	 * Sanity checking of Linux SCSI data structures so
+	 * that some of our hacks^H^H^H^H^Hassumptions aren't
+	 * violated.
 	 */
-	if (ahc->dev_softc != NULL) {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,3)
-		pci_set_dma_mask(ahc->dev_softc, 0xFFFFFFFF);
-#else
-		ahc->dev_softc->dma_mask = 0xFFFFFFFF;
-#endif
-	}
-	*vaddr = pci_alloc_consistent(ahc->dev_softc,
-				      dmat->maxsize, &map->bus_addr);
-	if (ahc->dev_softc != NULL) {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,3)
-		pci_set_dma_mask(ahc->dev_softc,
-				 ahc->platform_data->hw_dma_mask);
-#else
-		ahc->dev_softc->dma_mask = ahc->platform_data->hw_dma_mask;
-#endif
+	if (offsetof(struct ahc_cmd_internal, end)
+	  > offsetof(struct scsi_cmnd, host_scribble)) {
+		printf("ahc_linux_detect: SCSI data structures changed.\n");
+		printf("ahc_linux_detect: Unable to attach\n");
+		return (0);
 	}
-#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */
+	ahc_linux_size_nseg();
+#ifdef MODULE
 	/*
-	 * 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 accessable via DMA by the controller.
+	 * If we've been passed any parameters, process them now.
 	 */
-	map = NULL; /* No additional information to store */
-	*vaddr = malloc(dmat->maxsize, M_DEVBUF, M_NOWAIT);
+	if (aic7xxx)
+		aic7xxx_setup(aic7xxx);
+	if (dummy_buffer[0] != 'P')
+		printk(KERN_WARNING
+"aic7xxx: Please read the file /usr/src/linux/drivers/scsi/README.aic7xxx\n"
+"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 (*vaddr == NULL)
-		return (ENOMEM);
-	*mapp = map;
-	return(0);
-}
 
-void
-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);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0)
+	template->proc_name = "aic7xxx";
 #else
-	free(vaddr, M_DEVBUF);
+	template->proc_dir = &proc_scsi_aic7xxx;
 #endif
-}
 
-int
-ahc_dmamap_load(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map,
-		void *buf, bus_size_t buflen, bus_dmamap_callback_t *cb,
-		void *cb_arg, int flags)
-{
 	/*
-	 * Assume for now that this will only be used during
-	 * initialization and not for per-transaction buffer mapping.
+	 * Initialize our softc list lock prior to
+	 * probing for any adapters.
 	 */
-	bus_dma_segment_t stack_sg;
+	ahc_list_lockinit();
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
-	stack_sg.ds_addr = map->bus_addr;
-#else
-	stack_sg.ds_addr = VIRT_TO_BUS(buf);
+#ifdef CONFIG_PCI
+	ahc_linux_pci_init();
+#endif
+
+#ifdef CONFIG_EISA
+	ahc_linux_eisa_init();
 #endif
-	stack_sg.ds_len = dmat->maxsize;
-	cb(cb_arg, &stack_sg, /*nseg*/1, /*error*/0);
-	return (0);
-}
 
-void
-ahc_dmamap_destroy(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map)
-{
 	/*
-	 * The map may is NULL in our < 2.3.X implementation.
+	 * Register with the SCSI layer all
+	 * controllers we've found.
 	 */
-	if (map != NULL)
-		free(map, M_DEVBUF);
-}
+	found = 0;
+	TAILQ_FOREACH(ahc, &ahc_tailq, links) {
 
-int
-ahc_dmamap_unload(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map)
-{
-	/* Nothing to do */
-	return (0);
+		if (ahc_linux_register_host(ahc, template) == 0)
+			found++;
+	}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+	spin_lock_irq(&io_request_lock);
+#endif
+	aic7xxx_detect_complete++;
+	return (found);
 }
 
-/********************* Platform Dependent Functions ***************************/
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+/*
+ * Free the passed in Scsi_Host memory structures prior to unloading the
+ * module.
+ */
 int
-ahc_softc_comp(struct ahc_softc *lahc, struct ahc_softc *rahc)
+ahc_linux_release(struct Scsi_Host * host)
 {
-	int	value;
-	int	rvalue;
-	int	lvalue;
-
-	/*
-	 * Under Linux, cards are ordered as follows:
-	 *	1) VLB/EISA BIOS enabled devices sorted by BIOS address.
-	 *	2) PCI devices with BIOS enabled sorted by bus/slot/func.
-	 *	3) All remaining VLB/EISA devices sorted by ioport.
-	 *	4) All remaining PCI devices sorted by bus/slot/func.
-	 */
-	value = (lahc->flags & AHC_BIOS_ENABLED)
-	      - (rahc->flags & AHC_BIOS_ENABLED);
-	if (value != 0)
-		/* Controllers with BIOS enabled have a *higher* priority */
-		return (-value);
-
-	/*
-	 * Same BIOS setting, now sort based on bus type.
-	 * EISA and VL controllers sort together.  EISA/VL
-	 * have higher priority than PCI.
-	 */
-	rvalue = (rahc->chip & AHC_BUS_MASK);
- 	if (rvalue == AHC_VL)
-		rvalue = AHC_EISA;
-	lvalue = (lahc->chip & AHC_BUS_MASK);
- 	if (lvalue == AHC_VL)
-		lvalue = AHC_EISA;
-	value = lvalue - rvalue;
-	if (value != 0)
-		return (value);
+	struct ahc_softc *ahc;
+	u_long l;
 
-	/* Still equal.  Sort by BIOS address, ioport, or bus/slot/func. */
-	switch (rvalue) {
-	case AHC_PCI:
-	{
-		char primary_channel;
+	ahc_list_lock(&l);
+	if (host != NULL) {
 
-		if (aic7xxx_reverse_scan != 0)
-			value = ahc_get_pci_bus(rahc->dev_softc)
-			      - ahc_get_pci_bus(lahc->dev_softc);
-		else
-			value = ahc_get_pci_bus(lahc->dev_softc)
-			      - ahc_get_pci_bus(rahc->dev_softc);
-		if (value != 0)
-			break;
-		if (aic7xxx_reverse_scan != 0)
-			value = ahc_get_pci_slot(rahc->dev_softc)
-			      - ahc_get_pci_slot(lahc->dev_softc);
-		else
-			value = ahc_get_pci_slot(lahc->dev_softc)
-			      - ahc_get_pci_slot(rahc->dev_softc);
-		if (value != 0)
-			break;
 		/*
-		 * On multi-function devices, the user can choose
-		 * to have function 1 probed before function 0.
-		 * Give whichever channel is the primary channel
-		 * the lowest priority.
+		 * We should be able to just perform
+		 * the free directly, but check our
+		 * list for extra sanity.
 		 */
-		primary_channel = (lahc->flags & AHC_PRIMARY_CHANNEL) + 'A';
-		value = 1;
-		if (lahc->channel == primary_channel)
-			value = -1;
-		break;
-	}
-	case AHC_EISA:
-		if ((rahc->flags & AHC_BIOS_ENABLED) != 0) {
-			value = lahc->platform_data->bios_address
-			      - rahc->platform_data->bios_address; 
-		} else {
-			value = lahc->bsh.ioport
-			      - rahc->bsh.ioport; 
+		ahc = ahc_find_softc(*(struct ahc_softc **)host->hostdata);
+		if (ahc != NULL) {
+			u_long s;
+
+			ahc_lock(ahc, &s);
+			ahc_intr_enable(ahc, FALSE);
+			ahc_unlock(ahc, &s);
+			ahc_free(ahc);
 		}
-		break;
-	default:
-		panic("ahc_softc_sort: invalid bus type");
 	}
-	return (value);
+	ahc_list_unlock(&l);
+	return (0);
 }
+#endif
 
-static void
-ahc_linux_setup_tag_info(char *p, char *end)
+/*
+ * Return a string describing the driver.
+ */
+static const char *
+ahc_linux_info(struct Scsi_Host *host)
 {
-	char	*base;
-	char	*tok;
-	char	*tok_end;
-	char	*tok_end2;
-	int      i;
-	int      instance;
-	int	 targ;
-	int	 done;
-	char	 tok_list[] = {'.', ',', '{', '}', '\0'};
+	static char buffer[512];
+	char	ahc_info[256];
+	char   *bp;
+	struct ahc_softc *ahc;
 
-	if (*p != ':')
-		return;
+	bp = &buffer[0];
+	ahc = *(struct ahc_softc **)host->hostdata;
+	memset(bp, 0, sizeof(buffer));
+	strcpy(bp, "Adaptec AIC7XXX EISA/VLB/PCI SCSI HBA DRIVER, Rev ");
+	strcat(bp, AIC7XXX_DRIVER_VERSION);
+	strcat(bp, "\n");
+	strcat(bp, "        <");
+	strcat(bp, ahc->description);
+	strcat(bp, ">\n");
+	strcat(bp, "        ");
+	ahc_controller_info(ahc, ahc_info);
+	strcat(bp, ahc_info);
+	strcat(bp, "\n");
 
-	instance = -1;
-	targ = -1;
-	done = FALSE;
-	base = p;
-	/* Forward us just past the ':' */
-	tok = base + 1;
-	tok_end = strchr(tok, '\0');
-	if (tok_end < end)
-		*tok_end = ',';
-	while (!done) {
-		switch (*tok) {
-		case '{':
-			if (instance == -1)
-				instance = 0;
-			else if (targ == -1)
-				targ = 0;
-			tok++;
-			break;
-		case '}':
-			if (targ != -1)
-				targ = -1;
-			else if (instance != -1)
-				instance = -1;
-			tok++;
-			break;
-		case ',':
-		case '.':
-			if (instance == -1)
-				done = TRUE;
-			else if (targ >= 0)
-				targ++;
-			else if (instance >= 0)
-				instance++;
-			if ((targ >= AHC_NUM_TARGETS) ||
-			    (instance >= NUM_ELEMENTS(aic7xxx_tag_info)))
-				done = TRUE;
-			tok++;
-			if (!done) {
-				base = tok;
-			}
-			break;
-		case '\0':
-			done = TRUE;
-			break;
-		default:
-			done = TRUE;
-			tok_end = strchr(tok, '\0');
-			for (i = 0; tok_list[i]; i++) {
-				tok_end2 = strchr(tok, tok_list[i]);
-				if ((tok_end2) && (tok_end2 < tok_end)) {
-					tok_end = tok_end2;
-					done = FALSE;
-				}
-			}
-			if ((instance >= 0) && (targ >= 0)
-			 && (instance < NUM_ELEMENTS(aic7xxx_tag_info))
-			 && (targ < AHC_NUM_TARGETS)) {
-				aic7xxx_tag_info[instance].tag_commands[targ] =
-				    simple_strtoul(tok, NULL, 0) & 0xff;
-			}
-			tok = tok_end;
-			break;
-		}
-	}
-	while ((p != base) && (p != NULL))
-		p = strtok(NULL, ",.");
+	return (bp);
 }
 
 /*
- * Handle Linux boot parameters. This routine allows for assigning a value
- * to a parameter with a ':' between the parameter and the value.
- * ie. aic7xxx=stpwlev:1,extended
+ * Queue an SCB to the controller.
  */
-int
-aic7xxx_setup(char *s)
+static int
+ahc_linux_queue(Scsi_Cmnd * cmd, void (*scsi_done) (Scsi_Cmnd *))
 {
-	int	i, n;
-	char   *p;
-	char   *end;
+	struct	 ahc_softc *ahc;
+	struct	 ahc_linux_device *dev;
+	u_long	 flags;
 
-	static struct {
-		const char *name;
-		uint32_t *flag;
-	} options[] = {
-		{ "extended", &aic7xxx_extended },
-		{ "no_reset", &aic7xxx_no_reset },
-		{ "verbose", &aic7xxx_verbose },
-		{ "reverse_scan", &aic7xxx_reverse_scan },
-		{ "no_probe", &aic7xxx_no_probe },
-		{ "periodic_otag", &aic7xxx_periodic_otag },
-		{ "pci_parity", &aic7xxx_pci_parity },
-		{ "seltime", &aic7xxx_seltime },
-		{ "tag_info", NULL }
-	};
+	ahc = *(struct ahc_softc **)cmd->device->host->hostdata;
 
-	end = strchr(s, '\0');
+	/*
+	 * Save the callback on completion function.
+	 */
+	cmd->scsi_done = scsi_done;
 
-	for (p = strtok(s, ",."); p; p = strtok(NULL, ",.")) {
-		for (i = 0; i < NUM_ELEMENTS(options); i++) {
-			n = strlen(options[i].name);
+	ahc_midlayer_entrypoint_lock(ahc, &flags);
 
-			if (strncmp(options[i].name, p, n) != 0)
-				continue;
+	/*
+	 * Close the race of a command that was in the process of
+	 * being queued to us just as our simq was frozen.  Let
+	 * DV commands through so long as we are only frozen to
+	 * perform DV.
+	 */
+	if (ahc->platform_data->qfrozen != 0
+	 && AHC_DV_CMD(cmd) == 0) {
 
-			if (strncmp(p, "tag_info", n) == 0) {
-				ahc_linux_setup_tag_info(p + n, end);
-			} else if (p[n] == ':') {
-				*(options[i].flag) =
-				    simple_strtoul(p + n + 1, NULL, 0);
-			} else if (!strncmp(p, "verbose", n)) {
-				*(options[i].flag) = 1;
-			} else {
-				*(options[i].flag) = ~(*(options[i].flag));
-			}
-			break;
-		}
+		ahc_cmd_set_transaction_status(cmd, CAM_REQUEUE_REQ);
+		ahc_linux_queue_cmd_complete(ahc, cmd);
+		ahc_schedule_completeq(ahc);
+		ahc_midlayer_entrypoint_unlock(ahc, &flags);
+		return (0);
 	}
-	return 1;
+	dev = ahc_linux_get_device(ahc, cmd->device->channel, cmd->device->id,
+				   cmd->device->lun, /*alloc*/TRUE);
+	if (dev == NULL) {
+		ahc_cmd_set_transaction_status(cmd, CAM_RESRC_UNAVAIL);
+		ahc_linux_queue_cmd_complete(ahc, cmd);
+		ahc_schedule_completeq(ahc);
+		ahc_midlayer_entrypoint_unlock(ahc, &flags);
+		printf("%s: aic7xxx_linux_queue - Unable to allocate device!\n",
+		       ahc_name(ahc));
+		return (0);
+	}
+	cmd->result = CAM_REQ_INPROG << 16;
+	TAILQ_INSERT_TAIL(&dev->busyq, (struct ahc_cmd *)cmd, acmd_links.tqe);
+	if ((dev->flags & AHC_DEV_ON_RUN_LIST) == 0) {
+		TAILQ_INSERT_TAIL(&ahc->platform_data->device_runq, dev, links);
+		dev->flags |= AHC_DEV_ON_RUN_LIST;
+		ahc_linux_run_device_queues(ahc);
+	}
+	ahc_midlayer_entrypoint_unlock(ahc, &flags);
+	return (0);
 }
 
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0)
-__setup("aic7xxx=", aic7xxx_setup);
-#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+static int
+ahc_linux_slave_alloc(Scsi_Device *device)
+{
+	struct	ahc_softc *ahc;
 
-int aic7xxx_verbose;
+	ahc = *((struct ahc_softc **)device->host->hostdata);
+	if (bootverbose)
+		printf("%s: Slave Alloc %d\n", ahc_name(ahc), device->id);
+	return (0);
+}
 
-/*
- * Try to detect an Adaptec 7XXX controller.
- */
-int
-ahc_linux_detect(Scsi_Host_Template *template)
+static int
+ahc_linux_slave_configure(Scsi_Device *device)
 {
 	struct	ahc_softc *ahc;
-	int     found;
+	struct	ahc_linux_device *dev;
+	u_long	flags;
 
+	ahc = *((struct ahc_softc **)device->host->hostdata);
+	if (bootverbose)
+		printf("%s: Slave Configure %d\n", ahc_name(ahc), device->id);
+	ahc_midlayer_entrypoint_lock(ahc, &flags);
 	/*
-	 * It is a bug that the upper layer takes
-	 * this lock just prior to calling us.
+	 * Since Linux has attached to the device, configure
+	 * it so we don't free and allocate the device
+	 * structure on every command.
 	 */
-	spin_unlock_irq(&io_request_lock);
+	dev = ahc_linux_get_device(ahc, device->channel,
+				   device->id, device->lun,
+				   /*alloc*/TRUE);
+	if (dev != NULL) {
+		dev->flags &= ~AHC_DEV_UNCONFIGURED;
+		dev->scsi_device = device;
+		ahc_linux_device_queue_depth(ahc, dev);
+	}
+	ahc_midlayer_entrypoint_unlock(ahc, &flags);
+	return (0);
+}
+
+static void
+ahc_linux_slave_destroy(Scsi_Device *device)
+{
+	struct	ahc_softc *ahc;
+	struct	ahc_linux_device *dev;
+	u_long	flags;
 
+	ahc = *((struct ahc_softc **)device->host->hostdata);
+	if (bootverbose)
+		printf("%s: Slave Destroy %d\n", ahc_name(ahc), device->id);
+	ahc_midlayer_entrypoint_lock(ahc, &flags);
+	dev = ahc_linux_get_device(ahc, device->channel,
+				   device->id, device->lun,
+					   /*alloc*/FALSE);
 	/*
-	 * Sanity checking of Linux SCSI data structures so
-	 * that some of our hacks^H^H^H^H^Hassumptions aren't
-	 * violated.
+	 * Filter out "silly" deletions of real devices by only
+	 * deleting devices that have had slave_configure()
+	 * called on them.  All other devices that have not
+	 * been configured will automatically be deleted by
+	 * the refcounting process.
 	 */
-	if (offsetof(struct ahc_cmd_internal, end)
-	  > offsetof(struct scsi_cmnd, host_scribble)) {
-		printf("ahc_linux_detect: SCSI data structures changed.\n");
-		printf("ahc_linux_detect: Unable to attach\n");
-		return (0);
+	if (dev != NULL
+	 && (dev->flags & AHC_DEV_SLAVE_CONFIGURED) != 0) {
+		dev->flags |= AHC_DEV_UNCONFIGURED;
+		if (TAILQ_EMPTY(&dev->busyq)
+		 && dev->active == 0
+	 	 && (dev->flags & AHC_DEV_TIMER_ACTIVE) == 0)
+			ahc_linux_free_device(ahc, dev);
 	}
-#ifdef MODULE
-	/*
-	 * If we've been passed any parameters, process them now.
-	 */
-	if (aic7xxx)
-		aic7xxx_setup(aic7xxx);
-	if (dummy_buffer[0] != 'P')
-		printk(KERN_WARNING
-"aic7xxx: Please read the file /usr/src/linux/drivers/scsi/README.aic7xxx\n"
-"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");
+	ahc_midlayer_entrypoint_unlock(ahc, &flags);
+}
+#else
+/*
+ * Sets the queue depth for each SCSI device hanging
+ * off the input host adapter.
+ */
+static void
+ahc_linux_select_queue_depth(struct Scsi_Host *host, Scsi_Device *scsi_devs)
+{
+	Scsi_Device *device;
+	Scsi_Device *ldev;
+	struct	ahc_softc *ahc;
+	u_long	flags;
+
+	ahc = *((struct ahc_softc **)host->hostdata);
+	ahc_lock(ahc, &flags);
+	for (device = scsi_devs; device != NULL; device = device->next) {
+
+		/*
+		 * Watch out for duplicate devices.  This works around
+		 * some quirks in how the SCSI scanning code does its
+		 * device management.
+		 */
+		for (ldev = scsi_devs; ldev != device; ldev = ldev->next) {
+			if (ldev->host == device->host
+			 && ldev->channel == device->channel
+			 && ldev->id == device->id
+			 && ldev->lun == device->lun)
+				break;
+		}
+		/* Skip duplicate. */
+		if (ldev != device)
+			continue;
+
+		if (device->host == host) {
+			struct	 ahc_linux_device *dev;
+
+			/*
+			 * Since Linux has attached to the device, configure
+			 * it so we don't free and allocate the device
+			 * structure on every command.
+			 */
+			dev = ahc_linux_get_device(ahc, device->channel,
+						   device->id, device->lun,
+						   /*alloc*/TRUE);
+			if (dev != NULL) {
+				dev->flags &= ~AHC_DEV_UNCONFIGURED;
+				dev->scsi_device = device;
+				ahc_linux_device_queue_depth(ahc, dev);
+				device->queue_depth = dev->openings
+						    + dev->active;
+				if ((dev->flags & (AHC_DEV_Q_BASIC
+						| AHC_DEV_Q_TAGGED)) == 0) {
+					/*
+					 * We allow the OS to queue 2 untagged
+					 * transactions to us at any time even
+					 * though we can only execute them
+					 * serially on the controller/device.
+					 * This should remove some latency.
+					 */
+					device->queue_depth = 2;
+				}
+			}
+		}
+	}
+	ahc_unlock(ahc, &flags);
+}
 #endif
 
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0)
-	template->proc_name = "aic7xxx";
+#if defined(__i386__)
+/*
+ * Return the disk geometry for the given SCSI device.
+ */
+static int
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ahc_linux_biosparam(struct scsi_device *sdev, struct block_device *bdev,
+		    sector_t capacity, int geom[])
+{
+	uint8_t *bh;
 #else
-	template->proc_dir = &proc_scsi_aic7xxx;
+ahc_linux_biosparam(Disk *disk, kdev_t dev, int geom[])
+{
+	struct	scsi_device *sdev = disk->device;
+	u_long	capacity = disk->capacity;
+	struct	buffer_head *bh;
+#endif
+	int	 heads;
+	int	 sectors;
+	int	 cylinders;
+	int	 ret;
+	int	 extended;
+	struct	 ahc_softc *ahc;
+	u_int	 channel;
+
+	ahc = *((struct ahc_softc **)sdev->host->hostdata);
+	channel = sdev->channel;
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+	bh = scsi_bios_ptable(bdev);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,17)
+	bh = bread(MKDEV(MAJOR(dev), MINOR(dev) & ~0xf), 0, block_size(dev));
+#else
+	bh = bread(MKDEV(MAJOR(dev), MINOR(dev) & ~0xf), 0, 1024);
+#endif
+
+	if (bh) {
+		ret = scsi_partsize(bh, capacity,
+				    &geom[2], &geom[0], &geom[1]);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+		kfree(bh);
+#else
+		brelse(bh);
+#endif
+		if (ret != -1)
+			return (ret);
+	}
+	heads = 64;
+	sectors = 32;
+	cylinders = aic_sector_div(capacity, heads, sectors);
+
+	if (aic7xxx_extended != 0)
+		extended = 1;
+	else if (channel == 0)
+		extended = (ahc->flags & AHC_EXTENDED_TRANS_A) != 0;
+	else
+		extended = (ahc->flags & AHC_EXTENDED_TRANS_B) != 0;
+	if (extended && cylinders >= 1024) {
+		heads = 255;
+		sectors = 63;
+		cylinders = aic_sector_div(capacity, heads, sectors);
+	}
+	geom[0] = heads;
+	geom[1] = sectors;
+	geom[2] = cylinders;
+	return (0);
+}
 #endif
 
+/*
+ * Abort the current SCSI command(s).
+ */
+static int
+ahc_linux_abort(Scsi_Cmnd *cmd)
+{
+	int error;
+
+	error = ahc_linux_queue_recovery_cmd(cmd, SCB_ABORT);
+	if (error != 0)
+		printf("aic7xxx_abort returns 0x%x\n", error);
+	return (error);
+}
+
+/*
+ * Attempt to send a target reset message to the device that timed out.
+ */
+static int
+ahc_linux_dev_reset(Scsi_Cmnd *cmd)
+{
+	int error;
+
+	error = ahc_linux_queue_recovery_cmd(cmd, SCB_DEVICE_RESET);
+	if (error != 0)
+		printf("aic7xxx_dev_reset returns 0x%x\n", error);
+	return (error);
+}
+
+/*
+ * Reset the SCSI bus.
+ */
+static int
+ahc_linux_bus_reset(Scsi_Cmnd *cmd)
+{
+	struct ahc_softc *ahc;
+	u_long s;
+	int    found;
+
+	ahc = *(struct ahc_softc **)cmd->device->host->hostdata;
+	ahc_midlayer_entrypoint_lock(ahc, &s);
+	found = ahc_reset_channel(ahc, cmd->device->channel + 'A',
+				  /*initiate reset*/TRUE);
+	ahc_linux_run_complete_queue(ahc);
+	ahc_midlayer_entrypoint_unlock(ahc, &s);
+
+	if (bootverbose)
+		printf("%s: SCSI bus reset delivered. "
+		       "%d SCBs aborted.\n", ahc_name(ahc), found);
+
+	return SUCCESS;
+}
+
+Scsi_Host_Template aic7xxx_driver_template = {
+	.module			= THIS_MODULE,
+	.name			= "aic7xxx",
+	.proc_info		= ahc_linux_proc_info,
+	.info			= ahc_linux_info,
+	.queuecommand		= ahc_linux_queue,
+	.eh_abort_handler	= ahc_linux_abort,
+	.eh_device_reset_handler = ahc_linux_dev_reset,
+	.eh_bus_reset_handler	= ahc_linux_bus_reset,
+#if defined(__i386__)
+	.bios_param		= ahc_linux_biosparam,
+#endif
+	.can_queue		= AHC_MAX_QUEUE,
+	.this_id		= -1,
+	.cmd_per_lun		= 2,
+	.use_clustering		= ENABLE_CLUSTERING,
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,7)
 	/*
 	 * We can only map 16MB per-SG
 	 * so create a sector limit of
 	 * "16MB" in 2K sectors.
 	 */
-	template->max_sectors = 8192;
+	.max_sectors		= 8192,
 #endif
-
-	/*
-	 * Initialize our softc list lock prior to
-	 * probing for any adapters.
-	 */
-	ahc_list_lockinit();
-
-#ifdef CONFIG_PCI
-	ahc_linux_pci_probe(template);
+#if defined CONFIG_HIGHIO || LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10)
+/* Assume RedHat Distribution with its different HIGHIO conventions. */
+	.can_dma_32		= 1,
+	.single_sg_okay		= 1,
+#else
+	.highmem_io		= 1,
+#endif
+#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+	.slave_alloc		= ahc_linux_slave_alloc,
+	.slave_configure	= ahc_linux_slave_configure,
+	.slave_destroy		= ahc_linux_slave_destroy,
+#else
+	.detect			= ahc_linux_detect,
+	.release		= ahc_linux_release,
+	.select_queue_depths	= ahc_linux_select_queue_depth,
+	.use_new_eh_code	= 1,
 #endif
+};
 
-	if (aic7xxx_no_probe == 0)
-		aic7770_linux_probe(template);
+/**************************** Tasklet Handler *********************************/
 
-	/*
-	 * Register with the SCSI layer all
-	 * controllers we've found.
-	 */
-	spin_lock_irq(&io_request_lock);
-	found = 0;
-	TAILQ_FOREACH(ahc, &ahc_tailq, links) {
+/*
+ * In 2.4.X and above, this routine is called from a tasklet,
+ * so we must re-acquire our lock prior to executing this code.
+ * In all prior kernels, ahc_schedule_runq() calls this routine
+ * directly and ahc_schedule_runq() is called with our lock held.
+ */
+static void
+ahc_runq_tasklet(unsigned long data)
+{
+	struct ahc_softc* ahc;
+	struct ahc_linux_device *dev;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+	u_long flags;
+#endif
 
-		if (ahc_linux_register_host(ahc, template) == 0)
-			found++;
+	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
 	}
-	aic7xxx_detect_complete++;
-	return (found);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+	ahc_unlock(ahc, &flags);
+#endif
 }
 
+/******************************** Macros **************************************/
+#define BUILD_SCSIID(ahc, cmd)						    \
+	((((cmd)->device->id << TID_SHIFT) & TID)			    \
+	| (((cmd)->device->channel == 0) ? (ahc)->our_id : (ahc)->our_id_b) \
+	| (((cmd)->device->channel == 0) ? 0 : TWIN_CHNLB))
+
+/******************************** Bus DMA *************************************/
 int
-ahc_linux_register_host(struct ahc_softc *ahc, Scsi_Host_Template *template)
+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,
+		   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)
 {
-	char  buf[80];
-	struct Scsi_Host *host;
-	char *new_name;
-	u_long s;
-
+	bus_dma_tag_t dmat;
 
-	template->name = ahc->description;
-	host = scsi_register(template, sizeof(struct ahc_softc *));
-	if (host == NULL)
+	dmat = malloc(sizeof(*dmat), M_DEVBUF, M_NOWAIT);
+	if (dmat == NULL)
 		return (ENOMEM);
 
-	ahc_lock(ahc, &s);
-	*((struct ahc_softc **)host->hostdata) = ahc;
-	ahc->platform_data->host = host;
-	host->can_queue = AHC_MAX_QUEUE;
-	host->cmd_per_lun = 2;
-	host->sg_tablesize = AHC_NSEG;
-	host->select_queue_depths = ahc_linux_select_queue_depth;
-	/* XXX No way to communicate the ID for multiple channels */
-	host->this_id = ahc->our_id;
-	host->irq = ahc->platform_data->irq;
-	host->max_id = (ahc->features & AHC_WIDE) ? 16 : 8;
-	host->max_lun = AHC_NUM_LUNS;
-	host->max_channel = (ahc->features & AHC_TWIN) ? 1 : 0;
-	ahc_set_unit(ahc, ahc_linux_next_unit());
-	sprintf(buf, "scsi%d", host->host_no);
-	new_name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT);
-	if (new_name != NULL) {
-		strcpy(new_name, buf);
-		ahc_set_name(ahc, new_name);
-	}
-	host->unique_id = ahc->unit;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4)
-	scsi_set_pci_device(host, ahc->dev_softc);
-#endif
-	ahc_linux_initialize_scsi_bus(ahc);
-	ahc_unlock(ahc, &s);
+	/*
+	 * Linux is very simplistic about DMA memory.  For now don't
+	 * maintain all specification information.  Once Linux supplies
+	 * better facilities for doing these operations, or the
+	 * needs of this particular driver change, we might need to do
+	 * more here.
+	 */
+	dmat->alignment = alignment;
+	dmat->boundary = boundary;
+	dmat->maxsize = maxsize;
+	*ret_tag = dmat;
 	return (0);
 }
 
-uint64_t
-ahc_linux_get_memsize()
+void
+ahc_dma_tag_destroy(struct ahc_softc *ahc, bus_dma_tag_t dmat)
 {
-	struct sysinfo si;
-
-	si_meminfo(&si);
-	return (si.totalram << PAGE_SHIFT);
+	free(dmat, M_DEVBUF);
 }
 
-/*
- * Find the smallest available unit number to use
- * for a new device.  We don't just use a static
- * count to handle the "repeated hot-(un)plug"
- * scenario.
- */
-static int
-ahc_linux_next_unit()
+int
+ahc_dmamem_alloc(struct ahc_softc *ahc, bus_dma_tag_t dmat, void** vaddr,
+		 int flags, bus_dmamap_t *mapp)
 {
-	struct ahc_softc *ahc;
-	int unit;
+	bus_dmamap_t map;
 
-	unit = 0;
-retry:
-	TAILQ_FOREACH(ahc, &ahc_tailq, links) {
-		if (ahc->unit == unit) {
-			unit++;
-			goto retry;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
+	map = malloc(sizeof(*map), M_DEVBUF, M_NOWAIT);
+	if (map == NULL)
+		return (ENOMEM);
+	/*
+	 * Although we can dma data above 4GB, our
+	 * "consistent" memory is below 4GB for
+	 * space efficiency reasons (only need a 4byte
+	 * address).  For this reason, we have to reset
+	 * our dma mask when doing allocations.
+	 */
+	if (ahc->dev_softc != NULL)
+		ahc_pci_set_dma_mask(ahc->dev_softc, 0xFFFFFFFF);
+	*vaddr = pci_alloc_consistent(ahc->dev_softc,
+				      dmat->maxsize, &map->bus_addr);
+	if (ahc->dev_softc != NULL)
+		ahc_pci_set_dma_mask(ahc->dev_softc,
+				     ahc->platform_data->hw_dma_mask);
+#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;
+	return(0);
+}
+
+void
+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
+ahc_dmamap_load(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map,
+		void *buf, bus_size_t buflen, bus_dmamap_callback_t *cb,
+		void *cb_arg, int flags)
+{
+	/*
+	 * Assume for now that this will only be used during
+	 * initialization and not for per-transaction buffer mapping.
+	 */
+	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);
+}
+
+void
+ahc_dmamap_destroy(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map)
+{
+	/*
+	 * The map may is NULL in our < 2.3.X implementation.
+	 */
+	if (map != NULL)
+		free(map, M_DEVBUF);
+}
+
+int
+ahc_dmamap_unload(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map)
+{
+	/* Nothing to do */
+	return (0);
+}
+
+/********************* Platform Dependent Functions ***************************/
+/*
+ * Compare "left hand" softc with "right hand" softc, returning:
+ * < 0 - lahc has a lower priority than rahc
+ *   0 - Softcs are equal
+ * > 0 - lahc has a higher priority than rahc
+ */
+int
+ahc_softc_comp(struct ahc_softc *lahc, struct ahc_softc *rahc)
+{
+	int	value;
+	int	rvalue;
+	int	lvalue;
+
+	/*
+	 * Under Linux, cards are ordered as follows:
+	 *	1) VLB/EISA BIOS enabled devices sorted by BIOS address.
+	 *	2) PCI devices with BIOS enabled sorted by bus/slot/func.
+	 *	3) All remaining VLB/EISA devices sorted by ioport.
+	 *	4) All remaining PCI devices sorted by bus/slot/func.
+	 */
+	value = (lahc->flags & AHC_BIOS_ENABLED)
+	      - (rahc->flags & AHC_BIOS_ENABLED);
+	if (value != 0)
+		/* Controllers with BIOS enabled have a *higher* priority */
+		return (value);
+
+	/*
+	 * Same BIOS setting, now sort based on bus type.
+	 * EISA and VL controllers sort together.  EISA/VL
+	 * have higher priority than PCI.
+	 */
+	rvalue = (rahc->chip & AHC_BUS_MASK);
+ 	if (rvalue == AHC_VL)
+		rvalue = AHC_EISA;
+	lvalue = (lahc->chip & AHC_BUS_MASK);
+ 	if (lvalue == AHC_VL)
+		lvalue = AHC_EISA;
+	value = rvalue - lvalue;
+	if (value != 0)
+		return (value);
+
+	/* Still equal.  Sort by BIOS address, ioport, or bus/slot/func. */
+	switch (rvalue) {
+	case AHC_PCI:
+	{
+		char primary_channel;
+
+		if (aic7xxx_reverse_scan != 0)
+			value = ahc_get_pci_bus(lahc->dev_softc)
+			      - ahc_get_pci_bus(rahc->dev_softc);
+		else
+			value = ahc_get_pci_bus(rahc->dev_softc)
+			      - ahc_get_pci_bus(lahc->dev_softc);
+		if (value != 0)
+			break;
+		if (aic7xxx_reverse_scan != 0)
+			value = ahc_get_pci_slot(lahc->dev_softc)
+			      - ahc_get_pci_slot(rahc->dev_softc);
+		else
+			value = ahc_get_pci_slot(rahc->dev_softc)
+			      - ahc_get_pci_slot(lahc->dev_softc);
+		if (value != 0)
+			break;
+		/*
+		 * On multi-function devices, the user can choose
+		 * to have function 1 probed before function 0.
+		 * Give whichever channel is the primary channel
+		 * the highest priority.
+		 */
+		primary_channel = (lahc->flags & AHC_PRIMARY_CHANNEL) + 'A';
+		value = -1;
+		if (lahc->channel == primary_channel)
+			value = 1;
+		break;
+	}
+	case AHC_EISA:
+		if ((rahc->flags & AHC_BIOS_ENABLED) != 0) {
+			value = rahc->platform_data->bios_address
+			      - lahc->platform_data->bios_address; 
+		} else {
+			value = rahc->bsh.ioport
+			      - lahc->bsh.ioport; 
+		}
+		break;
+	default:
+		panic("ahc_softc_sort: invalid bus type");
+	}
+	return (value);
+}
+
+static void
+ahc_linux_setup_tag_info_global(char *p)
+{
+	int tags, i, j;
+
+	tags = simple_strtoul(p + 1, NULL, 0) & 0xff;
+	printf("Setting Global Tags= %d\n", tags);
+
+	for (i = 0; i < NUM_ELEMENTS(aic7xxx_tag_info); i++) {
+		for (j = 0; j < AHC_NUM_TARGETS; j++) {
+			aic7xxx_tag_info[i].tag_commands[j] = tags;
+		}
+	}
+}
+
+static void
+ahc_linux_setup_tag_info(u_long arg, int instance, int targ, int32_t value)
+{
+
+	if ((instance >= 0) && (targ >= 0)
+	 && (instance < NUM_ELEMENTS(aic7xxx_tag_info))
+	 && (targ < AHC_NUM_TARGETS)) {
+		aic7xxx_tag_info[instance].tag_commands[targ] = value & 0xff;
+		if (bootverbose)
+			printf("tag_info[%d:%d] = %d\n", instance, targ, value);
+	}
+}
+
+static void
+ahc_linux_setup_dv(u_long arg, int instance, int targ, int32_t value)
+{
+
+	if ((instance >= 0)
+	 && (instance < NUM_ELEMENTS(aic7xxx_dv_settings))) {
+		aic7xxx_dv_settings[instance] = value;
+		if (bootverbose)
+			printf("dv[%d] = %d\n", instance, value);
+	}
+}
+
+/*
+ * Handle Linux boot parameters. This routine allows for assigning a value
+ * to a parameter with a ':' between the parameter and the value.
+ * ie. aic7xxx=stpwlev:1,extended
+ */
+static int
+aic7xxx_setup(char *s)
+{
+	int	i, n;
+	char   *p;
+	char   *end;
+
+	static struct {
+		const char *name;
+		uint32_t *flag;
+	} options[] = {
+		{ "extended", &aic7xxx_extended },
+		{ "no_reset", &aic7xxx_no_reset },
+		{ "verbose", &aic7xxx_verbose },
+		{ "allow_memio", &aic7xxx_allow_memio},
+#ifdef AHC_DEBUG
+		{ "debug", &ahc_debug },
+#endif
+		{ "reverse_scan", &aic7xxx_reverse_scan },
+		{ "no_probe", &aic7xxx_probe_eisa_vl },
+		{ "probe_eisa_vl", &aic7xxx_probe_eisa_vl },
+		{ "periodic_otag", &aic7xxx_periodic_otag },
+		{ "pci_parity", &aic7xxx_pci_parity },
+		{ "seltime", &aic7xxx_seltime },
+		{ "tag_info", NULL },
+		{ "global_tag_depth", NULL },
+		{ "dv", NULL }
+	};
+
+	end = strchr(s, '\0');
+
+	/*
+	 * XXX ia64 gcc isn't smart enough to know that NUM_ELEMENTS
+	 * will never be 0 in this case.
+	 */
+	n = 0;
+
+	while ((p = strsep(&s, ",.")) != NULL) {
+		if (*p == '\0')
+			continue;
+		for (i = 0; i < NUM_ELEMENTS(options); i++) {
+
+			n = strlen(options[i].name);
+			if (strncmp(options[i].name, p, n) == 0)
+				break;
+		}
+		if (i == NUM_ELEMENTS(options))
+			continue;
+
+		if (strncmp(p, "global_tag_depth", n) == 0) {
+			ahc_linux_setup_tag_info_global(p + n);
+		} else if (strncmp(p, "tag_info", n) == 0) {
+			s = aic_parse_brace_option("tag_info", p + n, end,
+			    2, ahc_linux_setup_tag_info, 0);
+		} else if (strncmp(p, "dv", n) == 0) {
+			s = aic_parse_brace_option("dv", p + n, end, 1,
+			    ahc_linux_setup_dv, 0);
+		} else if (p[n] == ':') {
+			*(options[i].flag) = simple_strtoul(p + n + 1, NULL, 0);
+		} else if (strncmp(p, "verbose", n) == 0) {
+			*(options[i].flag) = 1;
+		} else {
+			*(options[i].flag) ^= 0xFFFFFFFF;
+		}
+	}
+	return 1;
+}
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0)
+__setup("aic7xxx=", aic7xxx_setup);
+#endif
+
+uint32_t aic7xxx_verbose;
+
+int
+ahc_linux_register_host(struct ahc_softc *ahc, Scsi_Host_Template *template)
+{
+	char	 buf[80];
+	struct	 Scsi_Host *host;
+	char	*new_name;
+	u_long	 s;
+	u_int	 targ_offset;
+
+	template->name = ahc->description;
+	host = scsi_register(template, sizeof(struct ahc_softc *));
+	if (host == NULL)
+		return (ENOMEM);
+
+	*((struct ahc_softc **)host->hostdata) = ahc;
+	ahc_lock(ahc, &s);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+	scsi_assign_lock(host, &ahc->platform_data->spin_lock);
+#elif AHC_SCSI_HAS_HOST_LOCK != 0
+	host->lock = &ahc->platform_data->spin_lock;
+#endif
+	ahc->platform_data->host = host;
+	host->can_queue = AHC_MAX_QUEUE;
+	host->cmd_per_lun = 2;
+	/* XXX No way to communicate the ID for multiple channels */
+	host->this_id = ahc->our_id;
+	host->irq = ahc->platform_data->irq;
+	host->max_id = (ahc->features & AHC_WIDE) ? 16 : 8;
+	host->max_lun = AHC_NUM_LUNS;
+	host->max_channel = (ahc->features & AHC_TWIN) ? 1 : 0;
+	host->sg_tablesize = AHC_NSEG;
+	ahc_set_unit(ahc, ahc_linux_next_unit());
+	sprintf(buf, "scsi%d", host->host_no);
+	new_name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT);
+	if (new_name != NULL) {
+		strcpy(new_name, buf);
+		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)
+	scsi_set_pci_device(host, ahc->dev_softc);
+#endif
+	ahc_linux_initialize_scsi_bus(ahc);
+	ahc_unlock(ahc, &s);
+	ahc->platform_data->dv_pid = kernel_thread(ahc_linux_dv_thread, ahc, 0);
+	ahc_lock(ahc, &s);
+	if (ahc->platform_data->dv_pid < 0) {
+		printf("%s: Failed to create DV thread, error= %d\n",
+		       ahc_name(ahc), ahc->platform_data->dv_pid);
+		return (-ahc->platform_data->dv_pid);
+	}
+	/*
+	 * Initially allocate *all* of our linux target objects
+	 * so that the DV thread will scan them all in parallel
+	 * just after driver initialization.  Any device that
+	 * does not exist will have its target object destroyed
+	 * by the selection timeout handler.  In the case of a
+	 * device that appears after the initial DV scan, async
+	 * negotiation will occur for the first command, and DV
+	 * will comence should that first command be successful.
+	 */
+	for (targ_offset = 0;
+	     targ_offset < host->max_id * (host->max_channel + 1);
+	     targ_offset++) {
+		u_int channel;
+		u_int target;
+
+		channel = 0;
+		target = targ_offset;
+		if (target > 7
+		 && (ahc->features & AHC_TWIN) != 0) {
+			channel = 1;
+			target &= 0x7;
+		}
+		/*
+		 * Skip our own ID.  Some Compaq/HP storage devices
+		 * have enclosure management devices that respond to
+		 * single bit selection (i.e. selecting ourselves).
+		 * It is expected that either an external application
+		 * or a modified kernel will be used to probe this
+		 * ID if it is appropriate.  To accommodate these
+		 * installations, ahc_linux_alloc_target() will allocate
+		 * for our ID if asked to do so.
+		 */
+		if ((channel == 0 && target == ahc->our_id)
+		 || (channel == 1 && target == ahc->our_id_b))
+			continue;
+
+		ahc_linux_alloc_target(ahc, channel, target);
+	}
+	ahc_intr_enable(ahc, TRUE);
+	ahc_linux_start_dv(ahc);
+	ahc_unlock(ahc, &s);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+	scsi_add_host(host, (ahc->dev_softc ? &ahc->dev_softc->dev : NULL));
+#endif
+	return (0);
+}
+
+uint64_t
+ahc_linux_get_memsize(void)
+{
+	struct sysinfo si;
+
+	si_meminfo(&si);
+	return ((uint64_t)si.totalram << PAGE_SHIFT);
+}
+
+/*
+ * Find the smallest available unit number to use
+ * for a new device.  We don't just use a static
+ * count to handle the "repeated hot-(un)plug"
+ * scenario.
+ */
+static int
+ahc_linux_next_unit(void)
+{
+	struct ahc_softc *ahc;
+	int unit;
+
+	unit = 0;
+retry:
+	TAILQ_FOREACH(ahc, &ahc_tailq, links) {
+		if (ahc->unit == unit) {
+			unit++;
+			goto retry;
+		}
+	}
+	return (unit);
+}
+
+/*
+ * Place the SCSI bus into a known state by either resetting it,
+ * or forcing transfer negotiations on the next command to any
+ * target.
+ */
+void
+ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc)
+{
+	int i;
+	int numtarg;
+
+	i = 0;
+	numtarg = 0;
+
+	if (aic7xxx_no_reset != 0)
+		ahc->flags &= ~(AHC_RESET_BUS_A|AHC_RESET_BUS_B);
+
+	if ((ahc->flags & AHC_RESET_BUS_A) != 0)
+		ahc_reset_channel(ahc, 'A', /*initiate_reset*/TRUE);
+	else
+		numtarg = (ahc->features & AHC_WIDE) ? 16 : 8;
+
+	if ((ahc->features & AHC_TWIN) != 0) {
+
+		if ((ahc->flags & AHC_RESET_BUS_B) != 0) {
+			ahc_reset_channel(ahc, 'B', /*initiate_reset*/TRUE);
+		} else {
+			if (numtarg == 0)
+				i = 8;
+			numtarg += 8;
+		}
+	}
+
+	/*
+	 * Force negotiation to async for all targets that
+	 * will not see an initial bus reset.
+	 */
+	for (; i < numtarg; i++) {
+		struct ahc_devinfo devinfo;
+		struct ahc_initiator_tinfo *tinfo;
+		struct ahc_tmode_tstate *tstate;
+		u_int our_id;
+		u_int target_id;
+		char channel;
+
+		channel = 'A';
+		our_id = ahc->our_id;
+		target_id = i;
+		if (i > 7 && (ahc->features & AHC_TWIN) != 0) {
+			channel = 'B';
+			our_id = ahc->our_id_b;
+			target_id = i % 8;
+		}
+		tinfo = ahc_fetch_transinfo(ahc, channel, our_id,
+					    target_id, &tstate);
+		ahc_compile_devinfo(&devinfo, our_id, target_id,
+				    CAM_LUN_WILDCARD, channel, ROLE_INITIATOR);
+		ahc_update_neg_request(ahc, &devinfo, tstate,
+				       tinfo, AHC_NEG_ALWAYS);
+	}
+	/* Give the bus some time to recover */
+	if ((ahc->flags & (AHC_RESET_BUS_A|AHC_RESET_BUS_B)) != 0) {
+		ahc_linux_freeze_simq(ahc);
+		init_timer(&ahc->platform_data->reset_timer);
+		ahc->platform_data->reset_timer.data = (u_long)ahc;
+		ahc->platform_data->reset_timer.expires =
+		    jiffies + (AIC7XXX_RESET_DELAY * HZ)/1000;
+		ahc->platform_data->reset_timer.function =
+		    ahc_linux_release_simq;
+		add_timer(&ahc->platform_data->reset_timer);
+	}
+}
+
+int
+ahc_platform_alloc(struct ahc_softc *ahc, void *platform_arg)
+{
+
+	ahc->platform_data =
+	    malloc(sizeof(struct ahc_platform_data), M_DEVBUF, M_NOWAIT);
+	if (ahc->platform_data == NULL)
+		return (ENOMEM);
+	memset(ahc->platform_data, 0, sizeof(struct ahc_platform_data));
+	TAILQ_INIT(&ahc->platform_data->completeq);
+	TAILQ_INIT(&ahc->platform_data->device_runq);
+	ahc->platform_data->irq = AHC_LINUX_NOIRQ;
+	ahc->platform_data->hw_dma_mask = 0xFFFFFFFF;
+	ahc_lockinit(ahc);
+	ahc_done_lockinit(ahc);
+	init_timer(&ahc->platform_data->completeq_timer);
+	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)
+		ahc->flags |= AHC_DISABLE_PCI_PERR;
+
+	return (0);
+}
+
+void
+ahc_platform_free(struct ahc_softc *ahc)
+{
+	struct ahc_linux_target *targ;
+	struct ahc_linux_device *dev;
+	int i, j;
+
+	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);
+#endif
+			scsi_unregister(ahc->platform_data->host);
+		}
+
+		/* destroy all of the device and target objects */
+		for (i = 0; i < AHC_NUM_TARGETS; i++) {
+			targ = ahc->platform_data->targets[i];
+			if (targ != NULL) {
+				/* Keep target around through the loop. */
+				targ->refcount++;
+				for (j = 0; j < AHC_NUM_LUNS; j++) {
+
+					if (targ->devices[j] == NULL)
+						continue;
+					dev = targ->devices[j];
+					ahc_linux_free_device(ahc, dev);
+				}
+				/*
+				 * Forcibly free the target now that
+				 * all devices are gone.
+				 */
+				ahc_linux_free_target(ahc, targ);
+ 			}
+ 		}
+
+		if (ahc->platform_data->irq != AHC_LINUX_NOIRQ)
+			free_irq(ahc->platform_data->irq, ahc);
+		if (ahc->tag == BUS_SPACE_PIO
+		 && ahc->bsh.ioport != 0)
+			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)
+			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)
+		/*
+		 * In 2.4 we detach from the scsi midlayer before the PCI
+		 * layer invokes our remove callback.  No per-instance
+		 * detach is provided, so we must reach inside the PCI
+		 * subsystem's internals and detach our driver manually.
+		 */
+		if (ahc->dev_softc != NULL)
+			ahc->dev_softc->driver = NULL;
+#endif
+		free(ahc->platform_data, M_DEVBUF);
+	}
+}
+
+void
+ahc_platform_freeze_devq(struct ahc_softc *ahc, struct scb *scb)
+{
+	ahc_platform_abort_scbs(ahc, SCB_GET_TARGET(ahc, scb),
+				SCB_GET_CHANNEL(ahc, scb),
+				SCB_GET_LUN(scb), SCB_LIST_NULL,
+				ROLE_UNKNOWN, CAM_REQUEUE_REQ);
+}
+
+void
+ahc_platform_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
+		      ahc_queue_alg alg)
+{
+	struct ahc_linux_device *dev;
+	int was_queuing;
+	int now_queuing;
+
+	dev = ahc_linux_get_device(ahc, devinfo->channel - 'A',
+				   devinfo->target,
+				   devinfo->lun, /*alloc*/FALSE);
+	if (dev == NULL)
+		return;
+	was_queuing = dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED);
+	switch (alg) {
+	default:
+	case AHC_QUEUE_NONE:
+		now_queuing = 0;
+		break; 
+	case AHC_QUEUE_BASIC:
+		now_queuing = AHC_DEV_Q_BASIC;
+		break;
+	case AHC_QUEUE_TAGGED:
+		now_queuing = AHC_DEV_Q_TAGGED;
+		break;
+	}
+	if ((dev->flags & AHC_DEV_FREEZE_TIL_EMPTY) == 0
+	 && (was_queuing != now_queuing)
+	 && (dev->active != 0)) {
+		dev->flags |= AHC_DEV_FREEZE_TIL_EMPTY;
+		dev->qfrozen++;
+	}
+
+	dev->flags &= ~(AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED|AHC_DEV_PERIODIC_OTAG);
+	if (now_queuing) {
+		u_int usertags;
+
+		usertags = ahc_linux_user_tagdepth(ahc, devinfo);
+		if (!was_queuing) {
+			/*
+			 * Start out agressively and allow our
+			 * dynamic queue depth algorithm to take
+			 * care of the rest.
+			 */
+			dev->maxtags = usertags;
+			dev->openings = dev->maxtags - dev->active;
+		}
+		if (dev->maxtags == 0) {
+			/*
+			 * Queueing is disabled by the user.
+			 */
+			dev->openings = 1;
+		} else if (alg == AHC_QUEUE_TAGGED) {
+			dev->flags |= AHC_DEV_Q_TAGGED;
+			if (aic7xxx_periodic_otag != 0)
+				dev->flags |= AHC_DEV_PERIODIC_OTAG;
+		} else
+			dev->flags |= AHC_DEV_Q_BASIC;
+	} else {
+		/* We can only have one opening. */
+		dev->maxtags = 0;
+		dev->openings =  1 - dev->active;
+	}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+	if (dev->scsi_device != NULL) {
+		switch ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED))) {
+		case AHC_DEV_Q_BASIC:
+			scsi_adjust_queue_depth(dev->scsi_device,
+						MSG_SIMPLE_TASK,
+						dev->openings + dev->active);
+			break;
+		case AHC_DEV_Q_TAGGED:
+			scsi_adjust_queue_depth(dev->scsi_device,
+						MSG_ORDERED_TASK,
+						dev->openings + dev->active);
+			break;
+		default:
+			/*
+			 * We allow the OS to queue 2 untagged transactions to
+			 * us at any time even though we can only execute them
+			 * serially on the controller/device.  This should
+			 * remove some latency.
+			 */
+			scsi_adjust_queue_depth(dev->scsi_device,
+						/*NON-TAGGED*/0,
+						/*queue depth*/2);
+			break;
+		}
+	}
+#endif
+}
+
+int
+ahc_platform_abort_scbs(struct ahc_softc *ahc, int target, char channel,
+			int lun, u_int tag, role_t role, uint32_t status)
+{
+	int chan;
+	int maxchan;
+	int targ;
+	int maxtarg;
+	int clun;
+	int maxlun;
+	int count;
+
+	if (tag != SCB_LIST_NULL)
+		return (0);
+
+	chan = 0;
+	if (channel != ALL_CHANNELS) {
+		chan = channel - 'A';
+		maxchan = chan + 1;
+	} else {
+		maxchan = (ahc->features & AHC_TWIN) ? 2 : 1;
+	}
+	targ = 0;
+	if (target != CAM_TARGET_WILDCARD) {
+		targ = target;
+		maxtarg = targ + 1;
+	} else {
+		maxtarg = (ahc->features & AHC_WIDE) ? 16 : 8;
+	}
+	clun = 0;
+	if (lun != CAM_LUN_WILDCARD) {
+		clun = lun;
+		maxlun = clun + 1;
+	} else {
+		maxlun = AHC_NUM_LUNS;
+	}
+
+	count = 0;
+	for (; chan < maxchan; chan++) {
+
+		for (; targ < maxtarg; targ++) {
+
+			for (; clun < maxlun; clun++) {
+				struct ahc_linux_device *dev;
+				struct ahc_busyq *busyq;
+				struct ahc_cmd *acmd;
+
+				dev = ahc_linux_get_device(ahc, chan,
+							   targ, clun,
+							   /*alloc*/FALSE);
+				if (dev == NULL)
+					continue;
+
+				busyq = &dev->busyq;
+				while ((acmd = TAILQ_FIRST(busyq)) != NULL) {
+					Scsi_Cmnd *cmd;
+
+					cmd = &acmd_scsi_cmd(acmd);
+					TAILQ_REMOVE(busyq, acmd,
+						     acmd_links.tqe);
+					count++;
+					cmd->result = status << 16;
+					ahc_linux_queue_cmd_complete(ahc, cmd);
+				}
+			}
+		}
+	}
+
+	return (count);
+}
+
+static void
+ahc_linux_thread_run_complete_queue(struct ahc_softc *ahc)
+{
+	u_long flags;
+
+	ahc_lock(ahc, &flags);
+	del_timer(&ahc->platform_data->completeq_timer);
+	ahc->platform_data->flags &= ~AHC_RUN_CMPLT_Q_TIMER;
+	ahc_linux_run_complete_queue(ahc);
+	ahc_unlock(ahc, &flags);
+}
+
+static void
+ahc_linux_start_dv(struct ahc_softc *ahc)
+{
+
+	/*
+	 * Freeze the simq and signal ahc_linux_queue to not let any
+	 * more commands through.
+	 */
+	if ((ahc->platform_data->flags & AHC_DV_ACTIVE) == 0) {
+#ifdef AHC_DEBUG
+		if (ahc_debug & AHC_SHOW_DV)
+			printf("%s: Waking DV thread\n", ahc_name(ahc));
+#endif
+
+		ahc->platform_data->flags |= AHC_DV_ACTIVE;
+		ahc_linux_freeze_simq(ahc);
+
+		/* Wake up the DV kthread */
+		up(&ahc->platform_data->dv_sem);
+	}
+}
+
+static void
+ahc_linux_kill_dv_thread(struct ahc_softc *ahc)
+{
+	u_long s;
+
+	ahc_lock(ahc, &s);
+	if (ahc->platform_data->dv_pid != 0) {
+		ahc->platform_data->flags |= AHC_DV_SHUTDOWN;
+		ahc_unlock(ahc, &s);
+		up(&ahc->platform_data->dv_sem);
+
+		/*
+		 * Use the eh_sem as an indicator that the
+		 * dv thread is exiting.  Note that the dv
+		 * thread must still return after performing
+		 * the up on our semaphore before it has
+		 * completely exited this module.  Unfortunately,
+		 * there seems to be no easy way to wait for the
+		 * exit of a thread for which you are not the
+		 * parent (dv threads are parented by init).
+		 * Cross your fingers...
+		 */
+		down(&ahc->platform_data->eh_sem);
+
+		/*
+		 * Mark the dv thread as already dead.  This
+		 * avoids attempting to kill it a second time.
+		 * This is necessary because we must kill the
+		 * DV thread before calling ahc_free() in the
+		 * module shutdown case to avoid bogus locking
+		 * in the SCSI mid-layer, but we ahc_free() is
+		 * called without killing the DV thread in the
+		 * instance detach case, so ahc_platform_free()
+		 * calls us again to verify that the DV thread
+		 * is dead.
+		 */
+		ahc->platform_data->dv_pid = 0;
+	} else {
+		ahc_unlock(ahc, &s);
+	}
+}
+
+static int
+ahc_linux_dv_thread(void *data)
+{
+	struct	ahc_softc *ahc;
+	int	target;
+	u_long	s;
+
+	ahc = (struct ahc_softc *)data;
+
+#ifdef AHC_DEBUG
+	if (ahc_debug & AHC_SHOW_DV)
+		printf("Launching DV Thread\n");
+#endif
+
+	/*
+	 * Complete thread creation.
+	 */
+	lock_kernel();
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+	/*
+	 * Don't care about any signals.
+	 */
+	siginitsetinv(&current->blocked, 0);
+
+	daemonize();
+	sprintf(current->comm, "ahc_dv_%d", ahc->unit);
+#else
+	daemonize("ahc_dv_%d", ahc->unit);
+#endif
+	unlock_kernel();
+
+	while (1) {
+		/*
+		 * Use down_interruptible() rather than down() to
+		 * avoid inclusion in the load average.
+		 */
+		down_interruptible(&ahc->platform_data->dv_sem);
+
+		/* Check to see if we've been signaled to exit */
+		ahc_lock(ahc, &s);
+		if ((ahc->platform_data->flags & AHC_DV_SHUTDOWN) != 0) {
+			ahc_unlock(ahc, &s);
+			break;
+		}
+		ahc_unlock(ahc, &s);
+
+#ifdef AHC_DEBUG
+		if (ahc_debug & AHC_SHOW_DV)
+			printf("%s: Beginning Domain Validation\n",
+			       ahc_name(ahc));
+#endif
+
+		/*
+		 * Wait for any pending commands to drain before proceeding.
+		 */
+		ahc_lock(ahc, &s);
+		while (LIST_FIRST(&ahc->pending_scbs) != NULL) {
+			ahc->platform_data->flags |= AHC_DV_WAIT_SIMQ_EMPTY;
+			ahc_unlock(ahc, &s);
+			down_interruptible(&ahc->platform_data->dv_sem);
+			ahc_lock(ahc, &s);
+		}
+
+		/*
+		 * Wait for the SIMQ to be released so that DV is the
+		 * only reason the queue is frozen.
+		 */
+		while (AHC_DV_SIMQ_FROZEN(ahc) == 0) {
+			ahc->platform_data->flags |= AHC_DV_WAIT_SIMQ_RELEASE;
+			ahc_unlock(ahc, &s);
+			down_interruptible(&ahc->platform_data->dv_sem);
+			ahc_lock(ahc, &s);
+		}
+		ahc_unlock(ahc, &s);
+
+		for (target = 0; target < AHC_NUM_TARGETS; target++)
+			ahc_linux_dv_target(ahc, target);
+
+		ahc_lock(ahc, &s);
+		ahc->platform_data->flags &= ~AHC_DV_ACTIVE;
+		ahc_unlock(ahc, &s);
+
+		/*
+		 * Release the SIMQ so that normal commands are
+		 * allowed to continue on the bus.
+		 */
+		ahc_linux_release_simq((u_long)ahc);
+	}
+	up(&ahc->platform_data->eh_sem);
+	return (0);
+}
+
+#define AHC_LINUX_DV_INQ_SHORT_LEN	36
+#define AHC_LINUX_DV_INQ_LEN		256
+#define AHC_LINUX_DV_TIMEOUT		(HZ / 4)
+
+#define AHC_SET_DV_STATE(ahc, targ, newstate) \
+	ahc_set_dv_state(ahc, targ, newstate, __LINE__)
+
+static __inline void
+ahc_set_dv_state(struct ahc_softc *ahc, struct ahc_linux_target *targ,
+		 ahc_dv_state newstate, u_int line)
+{
+	ahc_dv_state oldstate;
+
+	oldstate = targ->dv_state;
+#ifdef AHC_DEBUG
+	if (ahc_debug & AHC_SHOW_DV)
+		printf("%s:%d: Going from state %d to state %d\n",
+		       ahc_name(ahc), line, oldstate, newstate);
+#endif
+
+	if (oldstate == newstate)
+		targ->dv_state_retry++;
+	else
+		targ->dv_state_retry = 0;
+	targ->dv_state = newstate;
+}
+
+static void
+ahc_linux_dv_target(struct ahc_softc *ahc, u_int target_offset)
+{
+	struct	 ahc_devinfo devinfo;
+	struct	 ahc_linux_target *targ;
+	struct	 scsi_cmnd *cmd;
+	struct	 scsi_device *scsi_dev;
+	struct	 scsi_sense_data *sense;
+	uint8_t *buffer;
+	u_long	 s;
+	u_int	 timeout;
+	int	 echo_size;
+
+	sense = NULL;
+	buffer = NULL;
+	echo_size = 0;
+	ahc_lock(ahc, &s);
+	targ = ahc->platform_data->targets[target_offset];
+	if (targ == NULL || (targ->flags & AHC_DV_REQUIRED) == 0) {
+		ahc_unlock(ahc, &s);
+		return;
+	}
+	ahc_compile_devinfo(&devinfo,
+			    targ->channel == 0 ? ahc->our_id : ahc->our_id_b,
+			    targ->target, /*lun*/0, targ->channel + 'A',
+			    ROLE_INITIATOR);
+#ifdef AHC_DEBUG
+	if (ahc_debug & AHC_SHOW_DV) {
+		ahc_print_devinfo(ahc, &devinfo);
+		printf("Performing DV\n");
+	}
+#endif
+
+	ahc_unlock(ahc, &s);
+
+	cmd = malloc(sizeof(struct scsi_cmnd), M_DEVBUF, M_WAITOK);
+	scsi_dev = malloc(sizeof(struct scsi_device), M_DEVBUF, M_WAITOK);
+	scsi_dev->host = ahc->platform_data->host;
+	scsi_dev->id = devinfo.target;
+	scsi_dev->lun = devinfo.lun;
+	scsi_dev->channel = devinfo.channel - 'A';
+	ahc->platform_data->dv_scsi_dev = scsi_dev;
+
+	AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_INQ_SHORT_ASYNC);
+
+	while (targ->dv_state != AHC_DV_STATE_EXIT) {
+		timeout = AHC_LINUX_DV_TIMEOUT;
+		switch (targ->dv_state) {
+		case AHC_DV_STATE_INQ_SHORT_ASYNC:
+		case AHC_DV_STATE_INQ_ASYNC:
+		case AHC_DV_STATE_INQ_ASYNC_VERIFY:
+			/*
+			 * Set things to async narrow to reduce the
+			 * chance that the INQ will fail.
+			 */
+			ahc_lock(ahc, &s);
+			ahc_set_syncrate(ahc, &devinfo, NULL, 0, 0, 0,
+					 AHC_TRANS_GOAL, /*paused*/FALSE);
+			ahc_set_width(ahc, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
+				      AHC_TRANS_GOAL, /*paused*/FALSE);
+			ahc_unlock(ahc, &s);
+			timeout = 10 * HZ;
+			targ->flags &= ~AHC_INQ_VALID;
+			/* FALLTHROUGH */
+		case AHC_DV_STATE_INQ_VERIFY:
+		{
+			u_int inq_len;
+
+			if (targ->dv_state == AHC_DV_STATE_INQ_SHORT_ASYNC)
+				inq_len = AHC_LINUX_DV_INQ_SHORT_LEN;
+			else
+				inq_len = targ->inq_data->additional_length + 5;
+			ahc_linux_dv_inq(ahc, cmd, &devinfo, targ, inq_len);
+			break;
+		}
+		case AHC_DV_STATE_TUR:
+		case AHC_DV_STATE_BUSY:
+			timeout = 5 * HZ;
+			ahc_linux_dv_tur(ahc, cmd, &devinfo);
+			break;
+		case AHC_DV_STATE_REBD:
+			ahc_linux_dv_rebd(ahc, cmd, &devinfo, targ);
+			break;
+		case AHC_DV_STATE_WEB:
+			ahc_linux_dv_web(ahc, cmd, &devinfo, targ);
+			break;
+
+		case AHC_DV_STATE_REB:
+			ahc_linux_dv_reb(ahc, cmd, &devinfo, targ);
+			break;
+
+		case AHC_DV_STATE_SU:
+			ahc_linux_dv_su(ahc, cmd, &devinfo, targ);
+			timeout = 50 * HZ;
+			break;
+
+		default:
+			ahc_print_devinfo(ahc, &devinfo);
+			printf("Unknown DV state %d\n", targ->dv_state);
+			goto out;
+		}
+
+		/* Queue the command and wait for it to complete */
+		/* Abuse eh_timeout in the scsi_cmnd struct for our purposes */
+		init_timer(&cmd->eh_timeout);
+#ifdef AHC_DEBUG
+		if ((ahc_debug & AHC_SHOW_MESSAGES) != 0)
+			/*
+			 * All of the printfs during negotiation
+			 * really slow down the negotiation.
+			 * Add a bit of time just to be safe.
+			 */
+			timeout += HZ;
+#endif
+		scsi_add_timer(cmd, timeout, ahc_linux_dv_timeout);
+		/*
+		 * In 2.5.X, it is assumed that all calls from the
+		 * "midlayer" (which we are emulating) will have the
+		 * ahc host lock held.  For other kernels, the
+		 * io_request_lock must be held.
+		 */
+#if AHC_SCSI_HAS_HOST_LOCK != 0
+		ahc_lock(ahc, &s);
+#else
+		spin_lock_irqsave(&io_request_lock, s);
+#endif
+		ahc_linux_queue(cmd, ahc_linux_dv_complete);
+#if AHC_SCSI_HAS_HOST_LOCK != 0
+		ahc_unlock(ahc, &s);
+#else
+		spin_unlock_irqrestore(&io_request_lock, s);
+#endif
+		down_interruptible(&ahc->platform_data->dv_cmd_sem);
+		/*
+		 * Wait for the SIMQ to be released so that DV is the
+		 * only reason the queue is frozen.
+		 */
+		ahc_lock(ahc, &s);
+		while (AHC_DV_SIMQ_FROZEN(ahc) == 0) {
+			ahc->platform_data->flags |= AHC_DV_WAIT_SIMQ_RELEASE;
+			ahc_unlock(ahc, &s);
+			down_interruptible(&ahc->platform_data->dv_sem);
+			ahc_lock(ahc, &s);
+		}
+		ahc_unlock(ahc, &s);
+
+		ahc_linux_dv_transition(ahc, cmd, &devinfo, targ);
+	}
+
+out:
+	if ((targ->flags & AHC_INQ_VALID) != 0
+	 && ahc_linux_get_device(ahc, devinfo.channel - 'A',
+				 devinfo.target, devinfo.lun,
+				 /*alloc*/FALSE) == NULL) {
+		/*
+		 * The DV state machine failed to configure this device.  
+		 * This is normal if DV is disabled.  Since we have inquiry
+		 * data, filter it and use the "optimistic" negotiation
+		 * parameters found in the inquiry string.
+		 */
+		ahc_linux_filter_inquiry(ahc, &devinfo);
+		if ((targ->flags & (AHC_BASIC_DV|AHC_ENHANCED_DV)) != 0) {
+			ahc_print_devinfo(ahc, &devinfo);
+			printf("DV failed to configure device.  "
+			       "Please file a bug report against "
+			       "this driver.\n");
+		}
+	}
+
+	if (cmd != NULL)
+		free(cmd, M_DEVBUF);
+
+	if (ahc->platform_data->dv_scsi_dev != NULL) {
+		free(ahc->platform_data->dv_scsi_dev, M_DEVBUF);
+		ahc->platform_data->dv_scsi_dev = NULL;
+	}
+
+	ahc_lock(ahc, &s);
+	if (targ->dv_buffer != NULL) {
+		free(targ->dv_buffer, M_DEVBUF);
+		targ->dv_buffer = NULL;
+	}
+	if (targ->dv_buffer1 != NULL) {
+		free(targ->dv_buffer1, M_DEVBUF);
+		targ->dv_buffer1 = NULL;
+	}
+	targ->flags &= ~AHC_DV_REQUIRED;
+	if (targ->refcount == 0)
+		ahc_linux_free_target(ahc, targ);
+	ahc_unlock(ahc, &s);
+}
+
+static void
+ahc_linux_dv_transition(struct ahc_softc *ahc, struct scsi_cmnd *cmd,
+			struct ahc_devinfo *devinfo,
+			struct ahc_linux_target *targ)
+{
+	u_int32_t status;
+
+	status = aic_error_action(cmd, targ->inq_data,
+				  ahc_cmd_get_transaction_status(cmd),
+				  ahc_cmd_get_scsi_status(cmd));
+	
+#ifdef AHC_DEBUG
+	if (ahc_debug & AHC_SHOW_DV) {
+		ahc_print_devinfo(ahc, devinfo);
+		printf("Entering ahc_linux_dv_transition, state= %d, "
+		       "status= 0x%x, cmd->result= 0x%x\n", targ->dv_state,
+		       status, cmd->result);
+	}
+#endif
+
+	switch (targ->dv_state) {
+	case AHC_DV_STATE_INQ_SHORT_ASYNC:
+	case AHC_DV_STATE_INQ_ASYNC:
+		switch (status & SS_MASK) {
+		case SS_NOP:
+		{
+			AHC_SET_DV_STATE(ahc, targ, targ->dv_state+1);
+			break;
+		}
+		case SS_INQ_REFRESH:
+			AHC_SET_DV_STATE(ahc, targ,
+					 AHC_DV_STATE_INQ_SHORT_ASYNC);
+			break;
+		case SS_TUR:
+		case SS_RETRY:
+			AHC_SET_DV_STATE(ahc, targ, targ->dv_state);
+			if (ahc_cmd_get_transaction_status(cmd)
+			 == CAM_REQUEUE_REQ)
+				targ->dv_state_retry--;
+			if ((status & SS_ERRMASK) == EBUSY)
+				AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_BUSY);
+			if (targ->dv_state_retry < 10)
+				break;
+			/* FALLTHROUGH */
+		default:
+			AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_EXIT);
+#ifdef AHC_DEBUG
+			if (ahc_debug & AHC_SHOW_DV) {
+				ahc_print_devinfo(ahc, devinfo);
+				printf("Failed DV inquiry, skipping\n");
+			}
+#endif
+			break;
+		}
+		break;
+	case AHC_DV_STATE_INQ_ASYNC_VERIFY:
+		switch (status & SS_MASK) {
+		case SS_NOP:
+		{
+			u_int xportflags;
+			u_int spi3data;
+
+			if (memcmp(targ->inq_data, targ->dv_buffer,
+				   AHC_LINUX_DV_INQ_LEN) != 0) {
+				/*
+				 * Inquiry data must have changed.
+				 * Try from the top again.
+				 */
+				AHC_SET_DV_STATE(ahc, targ,
+						 AHC_DV_STATE_INQ_SHORT_ASYNC);
+				break;
+			}
+
+			AHC_SET_DV_STATE(ahc, targ, targ->dv_state+1);
+			targ->flags |= AHC_INQ_VALID;
+			if (ahc_linux_user_dv_setting(ahc) == 0)
+				break;
+
+			xportflags = targ->inq_data->flags;
+			if ((xportflags & (SID_Sync|SID_WBus16)) == 0)
+				break;
+
+			spi3data = targ->inq_data->spi3data;
+			switch (spi3data & SID_SPI_CLOCK_DT_ST) {
+			default:
+			case SID_SPI_CLOCK_ST:
+				/* Assume only basic DV is supported. */
+				targ->flags |= AHC_BASIC_DV;
+				break;
+			case SID_SPI_CLOCK_DT:
+			case SID_SPI_CLOCK_DT_ST:
+				targ->flags |= AHC_ENHANCED_DV;
+				break;
+			}
+			break;
+		}
+		case SS_INQ_REFRESH:
+			AHC_SET_DV_STATE(ahc, targ,
+					 AHC_DV_STATE_INQ_SHORT_ASYNC);
+			break;
+		case SS_TUR:
+		case SS_RETRY:
+			AHC_SET_DV_STATE(ahc, targ, targ->dv_state);
+			if (ahc_cmd_get_transaction_status(cmd)
+			 == CAM_REQUEUE_REQ)
+				targ->dv_state_retry--;
+
+			if ((status & SS_ERRMASK) == EBUSY)
+				AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_BUSY);
+			if (targ->dv_state_retry < 10)
+				break;
+			/* FALLTHROUGH */
+		default:
+			AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_EXIT);
+#ifdef AHC_DEBUG
+			if (ahc_debug & AHC_SHOW_DV) {
+				ahc_print_devinfo(ahc, devinfo);
+				printf("Failed DV inquiry, skipping\n");
+			}
+#endif
+			break;
+		}
+		break;
+	case AHC_DV_STATE_INQ_VERIFY:
+		switch (status & SS_MASK) {
+		case SS_NOP:
+		{
+
+			if (memcmp(targ->inq_data, targ->dv_buffer,
+				   AHC_LINUX_DV_INQ_LEN) == 0) {
+				AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_EXIT);
+				break;
+			}
+#ifdef AHC_DEBUG
+			if (ahc_debug & AHC_SHOW_DV) {
+				int i;
+
+				ahc_print_devinfo(ahc, devinfo);
+				printf("Inquiry buffer mismatch:");
+				for (i = 0; i < AHC_LINUX_DV_INQ_LEN; i++) {
+					if ((i & 0xF) == 0)
+						printf("\n        ");
+					printf("0x%x:0x0%x ",
+					       ((uint8_t *)targ->inq_data)[i], 
+					       targ->dv_buffer[i]);
+				}
+				printf("\n");
+			}
+#endif
+
+			if (ahc_linux_fallback(ahc, devinfo) != 0) {
+				AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_EXIT);
+				break;
+			}
+			/*
+			 * Do not count "falling back"
+			 * against our retries.
+			 */
+			targ->dv_state_retry = 0;
+			AHC_SET_DV_STATE(ahc, targ, targ->dv_state);
+			break;
+		}
+		case SS_INQ_REFRESH:
+			AHC_SET_DV_STATE(ahc, targ,
+					 AHC_DV_STATE_INQ_SHORT_ASYNC);
+			break;
+		case SS_TUR:
+		case SS_RETRY:
+			AHC_SET_DV_STATE(ahc, targ, targ->dv_state);
+			if (ahc_cmd_get_transaction_status(cmd)
+			 == CAM_REQUEUE_REQ) {
+				targ->dv_state_retry--;
+			} else if ((status & SSQ_FALLBACK) != 0) {
+				if (ahc_linux_fallback(ahc, devinfo) != 0) {
+					AHC_SET_DV_STATE(ahc, targ,
+							 AHC_DV_STATE_EXIT);
+					break;
+				}
+				/*
+				 * Do not count "falling back"
+				 * against our retries.
+				 */
+				targ->dv_state_retry = 0;
+			} else if ((status & SS_ERRMASK) == EBUSY)
+				AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_BUSY);
+			if (targ->dv_state_retry < 10)
+				break;
+			/* FALLTHROUGH */
+		default:
+			AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_EXIT);
+#ifdef AHC_DEBUG
+			if (ahc_debug & AHC_SHOW_DV) {
+				ahc_print_devinfo(ahc, devinfo);
+				printf("Failed DV inquiry, skipping\n");
+			}
+#endif
+			break;
+		}
+		break;
+
+	case AHC_DV_STATE_TUR:
+		switch (status & SS_MASK) {
+		case SS_NOP:
+			if ((targ->flags & AHC_BASIC_DV) != 0) {
+				ahc_linux_filter_inquiry(ahc, devinfo);
+				AHC_SET_DV_STATE(ahc, targ,
+						 AHC_DV_STATE_INQ_VERIFY);
+			} else if ((targ->flags & AHC_ENHANCED_DV) != 0) {
+				AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_REBD);
+			} else {
+				AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_EXIT);
+			}
+			break;
+		case SS_RETRY:
+		case SS_TUR:
+			if ((status & SS_ERRMASK) == EBUSY) {
+				AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_BUSY);
+				break;
+			}
+			AHC_SET_DV_STATE(ahc, targ, targ->dv_state);
+			if (ahc_cmd_get_transaction_status(cmd)
+			 == CAM_REQUEUE_REQ) {
+				targ->dv_state_retry--;
+			} else if ((status & SSQ_FALLBACK) != 0) {
+				if (ahc_linux_fallback(ahc, devinfo) != 0) {
+					AHC_SET_DV_STATE(ahc, targ,
+							 AHC_DV_STATE_EXIT);
+					break;
+				}
+				/*
+				 * Do not count "falling back"
+				 * against our retries.
+				 */
+				targ->dv_state_retry = 0;
+			}
+			if (targ->dv_state_retry >= 10) {
+#ifdef AHC_DEBUG
+				if (ahc_debug & AHC_SHOW_DV) {
+					ahc_print_devinfo(ahc, devinfo);
+					printf("DV TUR reties exhausted\n");
+				}
+#endif
+				AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_EXIT);
+				break;
+			}
+			if (status & SSQ_DELAY)
+				scsi_sleep(1 * HZ);
+
+			break;
+		case SS_START:
+			AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_SU);
+			break;
+		case SS_INQ_REFRESH:
+			AHC_SET_DV_STATE(ahc, targ,
+					 AHC_DV_STATE_INQ_SHORT_ASYNC);
+			break;
+		default:
+			AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_EXIT);
+			break;
+		}
+		break;
+
+	case AHC_DV_STATE_REBD:
+		switch (status & SS_MASK) {
+		case SS_NOP:
+		{
+			uint32_t echo_size;
+
+			AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_WEB);
+			echo_size = scsi_3btoul(&targ->dv_buffer[1]);
+			echo_size &= 0x1FFF;
+#ifdef AHC_DEBUG
+			if (ahc_debug & AHC_SHOW_DV) {
+				ahc_print_devinfo(ahc, devinfo);
+				printf("Echo buffer size= %d\n", echo_size);
+			}
+#endif
+			if (echo_size == 0) {
+				AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_EXIT);
+				break;
+			}
+
+			/* Generate the buffer pattern */
+			targ->dv_echo_size = echo_size;
+			ahc_linux_generate_dv_pattern(targ);
+			/*
+			 * Setup initial negotiation values.
+			 */
+			ahc_linux_filter_inquiry(ahc, devinfo);
+			break;
+		}
+		case SS_INQ_REFRESH:
+			AHC_SET_DV_STATE(ahc, targ,
+					 AHC_DV_STATE_INQ_SHORT_ASYNC);
+			break;
+		case SS_RETRY:
+			AHC_SET_DV_STATE(ahc, targ, targ->dv_state);
+			if (ahc_cmd_get_transaction_status(cmd)
+			 == CAM_REQUEUE_REQ)
+				targ->dv_state_retry--;
+			if (targ->dv_state_retry <= 10)
+				break;
+#ifdef AHC_DEBUG
+			if (ahc_debug & AHC_SHOW_DV) {
+				ahc_print_devinfo(ahc, devinfo);
+				printf("DV REBD reties exhausted\n");
+			}
+#endif
+			/* FALLTHROUGH */
+		case SS_FATAL:
+		default:
+			/*
+			 * Setup initial negotiation values
+			 * and try level 1 DV.
+			 */
+			ahc_linux_filter_inquiry(ahc, devinfo);
+			AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_INQ_VERIFY);
+			targ->dv_echo_size = 0;
+			break;
+		}
+		break;
+
+	case AHC_DV_STATE_WEB:
+		switch (status & SS_MASK) {
+		case SS_NOP:
+			AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_REB);
+			break;
+		case SS_INQ_REFRESH:
+			AHC_SET_DV_STATE(ahc, targ,
+					 AHC_DV_STATE_INQ_SHORT_ASYNC);
+			break;
+		case SS_RETRY:
+			AHC_SET_DV_STATE(ahc, targ, targ->dv_state);
+			if (ahc_cmd_get_transaction_status(cmd)
+			 == CAM_REQUEUE_REQ) {
+				targ->dv_state_retry--;
+			} else if ((status & SSQ_FALLBACK) != 0) {
+				if (ahc_linux_fallback(ahc, devinfo) != 0) {
+					AHC_SET_DV_STATE(ahc, targ,
+							 AHC_DV_STATE_EXIT);
+					break;
+				}
+				/*
+				 * Do not count "falling back"
+				 * against our retries.
+				 */
+				targ->dv_state_retry = 0;
+			}
+			if (targ->dv_state_retry <= 10)
+				break;
+			/* FALLTHROUGH */
+#ifdef AHC_DEBUG
+			if (ahc_debug & AHC_SHOW_DV) {
+				ahc_print_devinfo(ahc, devinfo);
+				printf("DV WEB reties exhausted\n");
+			}
+#endif
+		default:
+			AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_EXIT);
+			break;
+		}
+		break;
+
+	case AHC_DV_STATE_REB:
+		switch (status & SS_MASK) {
+		case SS_NOP:
+			if (memcmp(targ->dv_buffer, targ->dv_buffer1,
+				   targ->dv_echo_size) != 0) {
+				if (ahc_linux_fallback(ahc, devinfo) != 0)
+					AHC_SET_DV_STATE(ahc, targ,
+							 AHC_DV_STATE_EXIT);
+				else
+					AHC_SET_DV_STATE(ahc, targ,
+							 AHC_DV_STATE_WEB);
+				break;
+			}
+			
+			if (targ->dv_buffer != NULL) {
+				free(targ->dv_buffer, M_DEVBUF);
+				targ->dv_buffer = NULL;
+			}
+			if (targ->dv_buffer1 != NULL) {
+				free(targ->dv_buffer1, M_DEVBUF);
+				targ->dv_buffer1 = NULL;
+			}
+			AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_EXIT);
+			break;
+		case SS_INQ_REFRESH:
+			AHC_SET_DV_STATE(ahc, targ,
+					 AHC_DV_STATE_INQ_SHORT_ASYNC);
+			break;
+		case SS_RETRY:
+			AHC_SET_DV_STATE(ahc, targ, targ->dv_state);
+			if (ahc_cmd_get_transaction_status(cmd)
+			 == CAM_REQUEUE_REQ) {
+				targ->dv_state_retry--;
+			} else if ((status & SSQ_FALLBACK) != 0) {
+				if (ahc_linux_fallback(ahc, devinfo) != 0) {
+					AHC_SET_DV_STATE(ahc, targ,
+							 AHC_DV_STATE_EXIT);
+					break;
+				}
+				AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_WEB);
+			}
+			if (targ->dv_state_retry <= 10) {
+				if ((status & (SSQ_DELAY_RANDOM|SSQ_DELAY))!= 0)
+					scsi_sleep(ahc->our_id*HZ/10);
+				break;
+			}
+#ifdef AHC_DEBUG
+			if (ahc_debug & AHC_SHOW_DV) {
+				ahc_print_devinfo(ahc, devinfo);
+				printf("DV REB reties exhausted\n");
+			}
+#endif
+			/* FALLTHROUGH */
+		default:
+			AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_EXIT);
+			break;
+		}
+		break;
+
+	case AHC_DV_STATE_SU:
+		switch (status & SS_MASK) {
+		case SS_NOP:
+		case SS_INQ_REFRESH:
+			AHC_SET_DV_STATE(ahc, targ,
+					 AHC_DV_STATE_INQ_SHORT_ASYNC);
+			break;
+		default:
+			AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_EXIT);
+			break;
+		}
+		break;
+
+	case AHC_DV_STATE_BUSY:
+		switch (status & SS_MASK) {
+		case SS_NOP:
+		case SS_INQ_REFRESH:
+			AHC_SET_DV_STATE(ahc, targ,
+					 AHC_DV_STATE_INQ_SHORT_ASYNC);
+			break;
+		case SS_TUR:
+		case SS_RETRY:
+			AHC_SET_DV_STATE(ahc, targ, targ->dv_state);
+			if (ahc_cmd_get_transaction_status(cmd)
+			 == CAM_REQUEUE_REQ) {
+				targ->dv_state_retry--;
+			} else if (targ->dv_state_retry < 60) {
+				if ((status & SSQ_DELAY) != 0)
+					scsi_sleep(1 * HZ);
+			} else {
+#ifdef AHC_DEBUG
+				if (ahc_debug & AHC_SHOW_DV) {
+					ahc_print_devinfo(ahc, devinfo);
+					printf("DV BUSY reties exhausted\n");
+				}
+#endif
+				AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_EXIT);
+			}
+			break;
+		default:
+			AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_EXIT);
+			break;
 		}
+		break;
+
+	default:
+		printf("%s: Invalid DV completion state %d\n", ahc_name(ahc),
+		       targ->dv_state);
+		AHC_SET_DV_STATE(ahc, targ, AHC_DV_STATE_EXIT);
+		break;
 	}
-	return (unit);
+}
+
+static void
+ahc_linux_dv_fill_cmd(struct ahc_softc *ahc, struct scsi_cmnd *cmd,
+		      struct ahc_devinfo *devinfo)
+{
+	memset(cmd, 0, sizeof(struct scsi_cmnd));
+	cmd->device = ahc->platform_data->dv_scsi_dev;
+	cmd->scsi_done = ahc_linux_dv_complete;
 }
 
 /*
- * Place the SCSI bus into a known state by either resetting it,
- * or forcing transfer negotiations on the next command to any
- * target.
+ * Synthesize an inquiry command.  On the return trip, it'll be
+ * sniffed and the device transfer settings set for us.
  */
-void
-ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc)
+static void
+ahc_linux_dv_inq(struct ahc_softc *ahc, struct scsi_cmnd *cmd,
+		 struct ahc_devinfo *devinfo, struct ahc_linux_target *targ,
+		 u_int request_length)
 {
-	int i;
-	int numtarg;
-
-	i = 0;
-	numtarg = 0;
-
-	if (aic7xxx_no_reset != 0)
-		ahc->flags &= ~(AHC_RESET_BUS_A|AHC_RESET_BUS_B);
 
-	if ((ahc->flags & AHC_RESET_BUS_A) != 0)
-		ahc_reset_channel(ahc, 'A', /*initiate_reset*/TRUE);
+#ifdef AHC_DEBUG
+	if (ahc_debug & AHC_SHOW_DV) {
+		ahc_print_devinfo(ahc, devinfo);
+		printf("Sending INQ\n");
+	}
+#endif
+	if (targ->inq_data == NULL)
+		targ->inq_data = malloc(AHC_LINUX_DV_INQ_LEN,
+					M_DEVBUF, M_WAITOK);
+	if (targ->dv_state > AHC_DV_STATE_INQ_ASYNC) {
+		if (targ->dv_buffer != NULL)
+			free(targ->dv_buffer, M_DEVBUF);
+		targ->dv_buffer = malloc(AHC_LINUX_DV_INQ_LEN,
+					 M_DEVBUF, M_WAITOK);
+	}
+
+	ahc_linux_dv_fill_cmd(ahc, cmd, devinfo);
+	cmd->sc_data_direction = SCSI_DATA_READ;
+	cmd->cmd_len = 6;
+	cmd->cmnd[0] = INQUIRY;
+	cmd->cmnd[4] = request_length;
+	cmd->request_bufflen = request_length;
+	if (targ->dv_state > AHC_DV_STATE_INQ_ASYNC)
+		cmd->request_buffer = targ->dv_buffer;
 	else
-		numtarg = (ahc->features & AHC_WIDE) ? 16 : 8;
+		cmd->request_buffer = targ->inq_data;
+	memset(cmd->request_buffer, 0, AHC_LINUX_DV_INQ_LEN);
+}
 
-	if ((ahc->features & AHC_TWIN) != 0) {
+static void
+ahc_linux_dv_tur(struct ahc_softc *ahc, struct scsi_cmnd *cmd,
+		 struct ahc_devinfo *devinfo)
+{
 
-		if ((ahc->flags & AHC_RESET_BUS_B) != 0) {
-			ahc_reset_channel(ahc, 'B', /*initiate_reset*/TRUE);
-		} else {
-			if (numtarg == 0)
-				i = 8;
-			numtarg += 8;
-		}
+#ifdef AHC_DEBUG
+	if (ahc_debug & AHC_SHOW_DV) {
+		ahc_print_devinfo(ahc, devinfo);
+		printf("Sending TUR\n");
 	}
+#endif
+	/* Do a TUR to clear out any non-fatal transitional state */
+	ahc_linux_dv_fill_cmd(ahc, cmd, devinfo);
+	cmd->sc_data_direction = SCSI_DATA_NONE;
+	cmd->cmd_len = 6;
+	cmd->cmnd[0] = TEST_UNIT_READY;
+}
 
-	for (; i < numtarg; i++) {
-		struct ahc_devinfo devinfo;
-		struct ahc_initiator_tinfo *tinfo;
-		struct ahc_tmode_tstate *tstate;
-		u_int our_id;
-		u_int target_id;
-		char channel;
+#define AHC_REBD_LEN 4
 
-		channel = 'A';
-		our_id = ahc->our_id;
-		target_id = i;
-		if (i > 7 && (ahc->features & AHC_TWIN) != 0) {
-			channel = 'B';
-			our_id = ahc->our_id_b;
-			target_id = i % 8;
-		}
-		tinfo = ahc_fetch_transinfo(ahc, channel, our_id,
-					    target_id, &tstate);
-		tinfo->goal = tinfo->user;
-		/*
-		 * Don't try negotiations that require PPR messages
-		 * until we successfully retrieve Inquiry data.
-		 */
-		tinfo->goal.ppr_options = 0;
-		if (tinfo->goal.transport_version > SCSI_REV_2)
-			tinfo->goal.transport_version = SCSI_REV_2;
-		ahc_compile_devinfo(&devinfo, our_id, target_id,
-				   CAM_LUN_WILDCARD, channel, ROLE_INITIATOR);
-		ahc_update_neg_request(ahc, &devinfo, tstate,
-				       tinfo, /*force*/FALSE);
-	}
-	/* Give the bus some time to recover */
-	if ((ahc->flags & (AHC_RESET_BUS_A|AHC_RESET_BUS_B)) != 0) {
-		ahc_linux_freeze_sim_queue(ahc);
-		init_timer(&ahc->platform_data->reset_timer);
-		ahc->platform_data->reset_timer.data = (u_long)ahc;
-		ahc->platform_data->reset_timer.expires =
-		    jiffies + (AIC7XXX_RESET_DELAY * HZ)/1000;
-		ahc->platform_data->reset_timer.function =
-		    ahc_linux_release_sim_queue;
-		add_timer(&ahc->platform_data->reset_timer);
+static void
+ahc_linux_dv_rebd(struct ahc_softc *ahc, struct scsi_cmnd *cmd,
+		 struct ahc_devinfo *devinfo, struct ahc_linux_target *targ)
+{
+
+#ifdef AHC_DEBUG
+	if (ahc_debug & AHC_SHOW_DV) {
+		ahc_print_devinfo(ahc, devinfo);
+		printf("Sending REBD\n");
 	}
+#endif
+	if (targ->dv_buffer != NULL)
+		free(targ->dv_buffer, M_DEVBUF);
+	targ->dv_buffer = malloc(AHC_REBD_LEN, M_DEVBUF, M_WAITOK);
+	ahc_linux_dv_fill_cmd(ahc, cmd, devinfo);
+	cmd->sc_data_direction = SCSI_DATA_READ;
+	cmd->cmd_len = 10;
+	cmd->cmnd[0] = READ_BUFFER;
+	cmd->cmnd[1] = 0x0b;
+	scsi_ulto3b(AHC_REBD_LEN, &cmd->cmnd[6]);
+	cmd->request_bufflen = AHC_REBD_LEN;
+	cmd->underflow = cmd->request_bufflen;
+	cmd->request_buffer = targ->dv_buffer;
 }
 
-int
-ahc_platform_alloc(struct ahc_softc *ahc, void *platform_arg)
+static void
+ahc_linux_dv_web(struct ahc_softc *ahc, struct scsi_cmnd *cmd,
+		 struct ahc_devinfo *devinfo, struct ahc_linux_target *targ)
 {
-	ahc->platform_data =
-	    malloc(sizeof(struct ahc_platform_data), M_DEVBUF, M_NOWAIT);
-	if (ahc->platform_data == NULL)
-		return (ENOMEM);
-	memset(ahc->platform_data, 0, sizeof(struct ahc_platform_data));
-	TAILQ_INIT(&ahc->platform_data->completeq);
-	TAILQ_INIT(&ahc->platform_data->device_runq);
-	ahc->platform_data->irq = AHC_LINUX_NOIRQ;
-	ahc->platform_data->hw_dma_mask = 0xFFFFFFFF;
-	ahc_lockinit(ahc);
-	ahc_done_lockinit(ahc);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
-	init_MUTEX_LOCKED(&ahc->platform_data->eh_sem);
-#else
-	ahc->platform_data->eh_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);
+
+#ifdef AHC_DEBUG
+	if (ahc_debug & AHC_SHOW_DV) {
+		ahc_print_devinfo(ahc, devinfo);
+		printf("Sending WEB\n");
+	}
 #endif
-	ahc->seltime = (aic7xxx_seltime & 0x3) << 4;
-	ahc->seltime_b = (aic7xxx_seltime & 0x3) << 4;
-	if (TAILQ_EMPTY(&ahc_tailq))
-		register_reboot_notifier(&ahc_linux_notifier);
-	return (0);
+	ahc_linux_dv_fill_cmd(ahc, cmd, devinfo);
+	cmd->sc_data_direction = SCSI_DATA_WRITE;
+	cmd->cmd_len = 10;
+	cmd->cmnd[0] = WRITE_BUFFER;
+	cmd->cmnd[1] = 0x0a;
+	scsi_ulto3b(targ->dv_echo_size, &cmd->cmnd[6]);
+	cmd->request_bufflen = targ->dv_echo_size;
+	cmd->underflow = cmd->request_bufflen;
+	cmd->request_buffer = targ->dv_buffer;
 }
 
-void
-ahc_platform_free(struct ahc_softc *ahc)
+static void
+ahc_linux_dv_reb(struct ahc_softc *ahc, struct scsi_cmnd *cmd,
+		 struct ahc_devinfo *devinfo, struct ahc_linux_target *targ)
 {
-	if (ahc->platform_data != NULL) {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		tasklet_kill(&ahc->platform_data->runq_tasklet);
-#endif
-		if (ahc->platform_data->host != NULL)
-			scsi_unregister(ahc->platform_data->host);
-		if (ahc->platform_data->irq != AHC_LINUX_NOIRQ)
-			free_irq(ahc->platform_data->irq, ahc);
-		if (ahc->tag == BUS_SPACE_PIO
-		 && ahc->bsh.ioport != 0)
-			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)
-			release_mem_region(ahc->platform_data->mem_busaddr,
-					   0x1000);
-#endif
-		}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		/* XXX Need an instance detach in the PCI code */
-		if (ahc->dev_softc != NULL)
-			ahc->dev_softc->driver = NULL;
-#endif
-		free(ahc->platform_data, M_DEVBUF);
+#ifdef AHC_DEBUG
+	if (ahc_debug & AHC_SHOW_DV) {
+		ahc_print_devinfo(ahc, devinfo);
+		printf("Sending REB\n");
 	}
-	if (TAILQ_EMPTY(&ahc_tailq)) {
-		unregister_reboot_notifier(&ahc_linux_notifier);
-#ifdef CONFIG_PCI
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		pci_unregister_driver(&aic7xxx_pci_driver);
-#endif
 #endif
-	}
+	ahc_linux_dv_fill_cmd(ahc, cmd, devinfo);
+	cmd->sc_data_direction = SCSI_DATA_READ;
+	cmd->cmd_len = 10;
+	cmd->cmnd[0] = READ_BUFFER;
+	cmd->cmnd[1] = 0x0a;
+	scsi_ulto3b(targ->dv_echo_size, &cmd->cmnd[6]);
+	cmd->request_bufflen = targ->dv_echo_size;
+	cmd->underflow = cmd->request_bufflen;
+	cmd->request_buffer = targ->dv_buffer1;
 }
 
-void
-ahc_platform_freeze_devq(struct ahc_softc *ahc, struct scb *scb)
-{
-	ahc_platform_abort_scbs(ahc, SCB_GET_TARGET(ahc, scb),
-				SCB_GET_CHANNEL(ahc, scb),
-				SCB_GET_LUN(scb), SCB_LIST_NULL,
-				ROLE_UNKNOWN, CAM_REQUEUE_REQ);
+static void
+ahc_linux_dv_su(struct ahc_softc *ahc, struct scsi_cmnd *cmd,
+		struct ahc_devinfo *devinfo,
+		struct ahc_linux_target *targ)
+{
+	u_int le;
+
+	le = SID_IS_REMOVABLE(targ->inq_data) ? SSS_LOEJ : 0;
+
+#ifdef AHC_DEBUG
+	if (ahc_debug & AHC_SHOW_DV) {
+		ahc_print_devinfo(ahc, devinfo);
+		printf("Sending SU\n");
+	}
+#endif
+	ahc_linux_dv_fill_cmd(ahc, cmd, devinfo);
+	cmd->sc_data_direction = SCSI_DATA_NONE;
+	cmd->cmd_len = 6;
+	cmd->cmnd[0] = START_STOP_UNIT;
+	cmd->cmnd[4] = le | SSS_START;
 }
 
-void
-ahc_platform_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
-		      ahc_queue_alg alg)
+static int
+ahc_linux_fallback(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
 {
-	struct ahc_linux_device *dev;
-	int was_queuing;
-	int now_queuing;
-
-	dev = ahc_linux_get_device(ahc, devinfo->channel - 'A',
-				   devinfo->target,
-				   devinfo->lun, /*alloc*/FALSE);
-	if (dev == NULL)
-		return;
-	was_queuing = dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED);
-	now_queuing = alg != AHC_QUEUE_NONE;
-	if ((dev->flags & AHC_DEV_FREEZE_TIL_EMPTY) == 0
-	 && (was_queuing != now_queuing)
-	 && (dev->active != 0)) {
-		dev->flags |= AHC_DEV_FREEZE_TIL_EMPTY;
-		dev->qfrozen++;
+	struct	ahc_linux_target *targ;
+	struct	ahc_initiator_tinfo *tinfo;
+	struct	ahc_transinfo *goal;
+	struct	ahc_tmode_tstate *tstate;
+	struct	ahc_syncrate *syncrate;
+	u_long	s;
+	u_int	width;
+	u_int	period;
+	u_int	offset;
+	u_int	ppr_options;
+	u_int	cur_speed;
+	u_int	wide_speed;
+	u_int	narrow_speed;
+	u_int	fallback_speed;
+
+#ifdef AHC_DEBUG
+	if (ahc_debug & AHC_SHOW_DV) {
+		ahc_print_devinfo(ahc, devinfo);
+		printf("Trying to fallback\n");
+	}
+#endif
+	ahc_lock(ahc, &s);
+	targ = ahc->platform_data->targets[devinfo->target_offset];
+	tinfo = ahc_fetch_transinfo(ahc, devinfo->channel,
+				    devinfo->our_scsiid,
+				    devinfo->target, &tstate);
+	goal = &tinfo->goal;
+	width = goal->width;
+	period = goal->period;
+	offset = goal->offset;
+	ppr_options = goal->ppr_options;
+	if (offset == 0)
+		period = AHC_ASYNC_XFER_PERIOD;
+	if (targ->dv_next_narrow_period == 0)
+		targ->dv_next_narrow_period = MAX(period, AHC_SYNCRATE_ULTRA2);
+	if (targ->dv_next_wide_period == 0)
+		targ->dv_next_wide_period = period;
+	if (targ->dv_max_width == 0)
+		targ->dv_max_width = width;
+	if (targ->dv_max_ppr_options == 0)
+		targ->dv_max_ppr_options = ppr_options;
+	if (targ->dv_last_ppr_options == 0)
+		targ->dv_last_ppr_options = ppr_options;
+
+	cur_speed = aic_calc_speed(width, period, offset, AHC_SYNCRATE_MIN);
+	wide_speed = aic_calc_speed(MSG_EXT_WDTR_BUS_16_BIT,
+					  targ->dv_next_wide_period,
+					  MAX_OFFSET,
+					  AHC_SYNCRATE_MIN);
+	narrow_speed = aic_calc_speed(MSG_EXT_WDTR_BUS_8_BIT,
+					    targ->dv_next_narrow_period,
+					    MAX_OFFSET,
+					    AHC_SYNCRATE_MIN);
+	fallback_speed = aic_calc_speed(width, period+1, offset,
+					AHC_SYNCRATE_MIN);
+#ifdef AHC_DEBUG
+	if (ahc_debug & AHC_SHOW_DV) {
+		printf("cur_speed= %d, wide_speed= %d, narrow_speed= %d, "
+		       "fallback_speed= %d\n", cur_speed, wide_speed,
+		       narrow_speed, fallback_speed);
 	}
+#endif
 
-	dev->flags &= ~(AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED|AHC_DEV_PERIODIC_OTAG);
-	if (now_queuing) {
-		u_int usertags;
+	if (cur_speed > 160000) {
+		/*
+		 * Paced/DT/IU_REQ only transfer speeds.  All we
+		 * can do is fallback in terms of syncrate.
+		 */
+		period++;
+	} else if (cur_speed > 80000) {
+		if ((ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
+			/*
+			 * Try without IU_REQ as it may be confusing
+			 * an expander.
+			 */
+			ppr_options &= ~MSG_EXT_PPR_IU_REQ;
+		} else {
+			/*
+			 * Paced/DT only transfer speeds.  All we
+			 * can do is fallback in terms of syncrate.
+			 */
+			period++;
+			ppr_options = targ->dv_max_ppr_options;
+		}
+	} else if (cur_speed > 3300) {
 
-		usertags = ahc_linux_user_tagdepth(ahc, devinfo);
-		if (!was_queuing) {
+		/*
+		 * In this range we the following
+		 * options ordered from highest to
+		 * lowest desireability:
+		 *
+		 * o Wide/DT
+		 * o Wide/non-DT
+		 * o Narrow at a potentally higher sync rate.
+		 *
+		 * All modes are tested with and without IU_REQ
+		 * set since using IUs may confuse an expander.
+		 */
+		if ((ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
+
+			ppr_options &= ~MSG_EXT_PPR_IU_REQ;
+		} else if ((ppr_options & MSG_EXT_PPR_DT_REQ) != 0) {
 			/*
-			 * Start out agressively and allow our
-			 * dynamic queue depth algorithm to take
-			 * care of the rest.
+			 * Try going non-DT.
 			 */
-			dev->maxtags = usertags;
-			dev->openings = dev->maxtags - dev->active;
+			ppr_options = targ->dv_max_ppr_options;
+			ppr_options &= ~MSG_EXT_PPR_DT_REQ;
+		} else if (targ->dv_last_ppr_options != 0) {
+			/*
+			 * Try without QAS or any other PPR options.
+			 * We may need a non-PPR message to work with
+			 * an expander.  We look at the "last PPR options"
+			 * so we will perform this fallback even if the
+			 * target responded to our PPR negotiation with
+			 * no option bits set.
+			 */
+			ppr_options = 0;
+		} else if (width == MSG_EXT_WDTR_BUS_16_BIT) {
+			/*
+			 * If the next narrow speed is greater than
+			 * the next wide speed, fallback to narrow.
+			 * Otherwise fallback to the next DT/Wide setting.
+			 * The narrow async speed will always be smaller
+			 * than the wide async speed, so handle this case
+			 * specifically.
+			 */
+			ppr_options = targ->dv_max_ppr_options;
+			if (narrow_speed > fallback_speed
+			 || period >= AHC_ASYNC_XFER_PERIOD) {
+				targ->dv_next_wide_period = period+1;
+				width = MSG_EXT_WDTR_BUS_8_BIT;
+				period = targ->dv_next_narrow_period;
+			} else {
+				period++;
+			}
+		} else if ((ahc->features & AHC_WIDE) != 0
+			&& targ->dv_max_width != 0
+			&& wide_speed >= fallback_speed
+			&& (targ->dv_next_wide_period <= AHC_ASYNC_XFER_PERIOD
+			 || period >= AHC_ASYNC_XFER_PERIOD)) {
+
+			/*
+			 * We are narrow.  Try falling back
+			 * to the next wide speed with 
+			 * all supported ppr options set.
+			 */
+			targ->dv_next_narrow_period = period+1;
+			width = MSG_EXT_WDTR_BUS_16_BIT;
+			period = targ->dv_next_wide_period;
+			ppr_options = targ->dv_max_ppr_options;
+		} else {
+			/* Only narrow fallback is allowed. */
+			period++;
+			ppr_options = targ->dv_max_ppr_options;
 		}
-		if (alg == AHC_QUEUE_TAGGED) {
-			dev->flags |= AHC_DEV_Q_TAGGED;
-			if (aic7xxx_periodic_otag != 0)
-				dev->flags |= AHC_DEV_PERIODIC_OTAG;
-		} else
-			dev->flags |= AHC_DEV_Q_BASIC;
 	} else {
-		/* We can only have one opening. */
-		dev->maxtags = 0;
-		dev->openings =  1 - dev->active;
+		ahc_unlock(ahc, &s);
+		return (-1);
+	}
+	offset = MAX_OFFSET;
+	syncrate = ahc_find_syncrate(ahc, &period, &ppr_options,
+				     AHC_SYNCRATE_DT);
+	ahc_set_width(ahc, devinfo, width, AHC_TRANS_GOAL, FALSE);
+	if (period == 0) {
+		period = 0;
+		offset = 0;
+		ppr_options = 0;
+		if (width == MSG_EXT_WDTR_BUS_8_BIT)
+			targ->dv_next_narrow_period = AHC_ASYNC_XFER_PERIOD;
+		else
+			targ->dv_next_wide_period = AHC_ASYNC_XFER_PERIOD;
 	}
+	ahc_set_syncrate(ahc, devinfo, syncrate, period, offset,
+			 ppr_options, AHC_TRANS_GOAL, FALSE);
+	targ->dv_last_ppr_options = ppr_options;
+	ahc_unlock(ahc, &s);
+	return (0);
 }
 
-int
-ahc_platform_abort_scbs(struct ahc_softc *ahc, int target, char channel,
-			int lun, u_int tag, role_t role, uint32_t status)
+static void
+ahc_linux_dv_timeout(struct scsi_cmnd *cmd)
 {
-	int chan;
-	int maxchan;
-	int targ;
-	int maxtarg;
-	int clun;
-	int maxlun;
-	int count;
+	struct	ahc_softc *ahc;
+	struct	scb *scb;
+	u_long	flags;
 
-	if (tag != SCB_LIST_NULL)
-		return (0);
+	ahc = *((struct ahc_softc **)cmd->device->host->hostdata);
+	ahc_lock(ahc, &flags);
 
-	chan = 0;
-	if (channel != ALL_CHANNELS) {
-		chan = channel - 'A';
-		maxchan = chan + 1;
-	} else {
-		maxchan = (ahc->features & AHC_TWIN) ? 2 : 1;
-	}
-	targ = 0;
-	if (target != CAM_TARGET_WILDCARD) {
-		targ = target;
-		maxtarg = targ + 1;
-	} else {
-		maxtarg = (ahc->features & AHC_WIDE) ? 16 : 8;
+#ifdef AHC_DEBUG
+	if (ahc_debug & AHC_SHOW_DV) {
+		printf("%s: Timeout while doing DV command %x.\n",
+		       ahc_name(ahc), cmd->cmnd[0]);
+		ahc_dump_card_state(ahc);
 	}
-	clun = 0;
-	if (lun != CAM_LUN_WILDCARD) {
-		clun = lun;
-		maxlun = clun + 1;
-	} else {
-		maxlun = AHC_NUM_LUNS;
+#endif
+	
+	/*
+	 * Guard against "done race".  No action is
+	 * required if we just completed.
+	 */
+	if ((scb = (struct scb *)cmd->host_scribble) == NULL) {
+		ahc_unlock(ahc, &flags);
+		return;
 	}
 
-	count = 0;
-	for (; chan < maxchan; chan++) {
+	/*
+	 * Command has not completed.  Mark this
+	 * SCB as having failing status prior to
+	 * resetting the bus, so we get the correct
+	 * error code.
+	 */
+	if ((scb->flags & SCB_SENSE) != 0)
+		ahc_set_transaction_status(scb, CAM_AUTOSENSE_FAIL);
+	else
+		ahc_set_transaction_status(scb, CAM_CMD_TIMEOUT);
+	ahc_reset_channel(ahc, cmd->device->channel + 'A', /*initiate*/TRUE);
 
-		for (; targ < maxtarg; targ++) {
+	/*
+	 * Add a minimal bus settle delay for devices that are slow to
+	 * respond after bus resets.
+	 */
+	ahc_linux_freeze_simq(ahc);
+	init_timer(&ahc->platform_data->reset_timer);
+	ahc->platform_data->reset_timer.data = (u_long)ahc;
+	ahc->platform_data->reset_timer.expires = jiffies + HZ / 2;
+	ahc->platform_data->reset_timer.function =
+	    (ahc_linux_callback_t *)ahc_linux_release_simq;
+	add_timer(&ahc->platform_data->reset_timer);
+	if (ahc_linux_next_device_to_run(ahc) != NULL)
+		ahc_schedule_runq(ahc);
+	ahc_linux_run_complete_queue(ahc);
+	ahc_unlock(ahc, &flags);
+}
 
-			for (; clun < maxlun; clun++) {
-				struct ahc_linux_device *dev;
-				struct ahc_busyq *busyq;
-				struct ahc_cmd *acmd;
+static void
+ahc_linux_dv_complete(struct scsi_cmnd *cmd)
+{
+	struct ahc_softc *ahc;
 
-				dev = ahc_linux_get_device(ahc, chan,
-							   targ, clun,
-							   /*alloc*/FALSE);
-				if (dev == NULL)
-					continue;
+	ahc = *((struct ahc_softc **)cmd->device->host->hostdata);
 
-				busyq = &dev->busyq;
-				while ((acmd = TAILQ_FIRST(busyq)) != NULL) {
-					Scsi_Cmnd *cmd;
+	/* Delete the DV timer before it goes off! */
+	scsi_delete_timer(cmd);
 
-					cmd = &acmd_scsi_cmd(acmd);
-					TAILQ_REMOVE(busyq, acmd,
-						     acmd_links.tqe);
-					count++;
-					cmd->result = status << 16;
-					ahc_linux_queue_cmd_complete(ahc, cmd);
-				}
-			}
-		}
-	}
+#ifdef AHC_DEBUG
+	if (ahc_debug & AHC_SHOW_DV)
+		printf("%s:%d:%d: Command completed, status= 0x%x\n",
+		       ahc_name(ahc), cmd->device->channel,
+		       cmd->device->id, cmd->result);
+#endif
 
-	return (count);
+	/* Wake up the state machine */
+	up(&ahc->platform_data->dv_cmd_sem);
 }
 
-/*
- * Sets the queue depth for each SCSI device hanging
- * off the input host adapter.
- */
 static void
-ahc_linux_select_queue_depth(struct Scsi_Host * host,
-			     Scsi_Device * scsi_devs)
+ahc_linux_generate_dv_pattern(struct ahc_linux_target *targ)
 {
-	Scsi_Device *device;
-	struct	ahc_softc *ahc;
-	u_long	flags;
-	int	scbnum;
+	uint16_t b;
+	u_int	 i;
+	u_int	 j;
+
+	if (targ->dv_buffer != NULL)
+		free(targ->dv_buffer, M_DEVBUF);
+	targ->dv_buffer = malloc(targ->dv_echo_size, M_DEVBUF, M_WAITOK);
+	if (targ->dv_buffer1 != NULL)
+		free(targ->dv_buffer1, M_DEVBUF);
+	targ->dv_buffer1 = malloc(targ->dv_echo_size, M_DEVBUF, M_WAITOK);
 
-	ahc = *((struct ahc_softc **)host->hostdata);
-	ahc_lock(ahc, &flags);
-	scbnum = 0;
-	for (device = scsi_devs; device != NULL; device = device->next) {
-		if (device->host == host) {
-			ahc_linux_device_queue_depth(ahc, device);
-			scbnum += device->queue_depth;
+	i = 0;
+	b = 0x0001;
+	for (j = 0 ; i < targ->dv_echo_size; j++) {
+		if (j < 32) {
+			/*
+			 * 32bytes of sequential numbers.
+			 */
+			targ->dv_buffer[i++] = j & 0xff;
+		} else if (j < 48) {
+			/*
+			 * 32bytes of repeating 0x0000, 0xffff.
+			 */
+			targ->dv_buffer[i++] = (j & 0x02) ? 0xff : 0x00;
+		} else if (j < 64) {
+			/*
+			 * 32bytes of repeating 0x5555, 0xaaaa.
+			 */
+			targ->dv_buffer[i++] = (j & 0x02) ? 0xaa : 0x55;
+		} else {
+			/*
+			 * Remaining buffer is filled with a repeating
+			 * patter of:
+			 *
+			 *	 0xffff
+			 *	~0x0001 << shifted once in each loop.
+			 */
+			if (j & 0x02) {
+				if (j & 0x01) {
+					targ->dv_buffer[i++] = ~(b >> 8) & 0xff;
+					b <<= 1;
+					if (b == 0x0000)
+						b = 0x0001;
+				} else {
+					targ->dv_buffer[i++] = (~b & 0xff);
+				}
+			} else {
+				targ->dv_buffer[i++] = 0xff;
+			}
 		}
 	}
-	ahc_unlock(ahc, &flags);
 }
 
 static u_int
@@ -1572,17 +3553,17 @@
 
 	tags = 0;
 	if ((ahc->user_discenable & devinfo->target_mask) != 0) {
-		if (warned_user == 0
-		 && ahc->unit >= NUM_ELEMENTS(aic7xxx_tag_info)) {
+		if (ahc->unit >= NUM_ELEMENTS(aic7xxx_tag_info)) {
+			if (warned_user == 0) {
 
-			printf("aic7xxx: WARNING, insufficient "
-			       "tag_info instances for installed "
-			       "controllers. Using defaults\n");
-			printf("aic7xxx: Please update the "
-			       "aic7xxx_tag_info array in the "
-			       "aic7xxx.c source file.\n");
+				printf(KERN_WARNING
+"aic7xxx: WARNING: Insufficient tag_info instances\n"
+"aic7xxx: for installed controllers. Using defaults\n"
+"aic7xxx: Please update the aic7xxx_tag_info array in\n"
+"aic7xxx: the aic7xxx_osm..c source file.\n");
+				warned_user++;
+			}
 			tags = AHC_MAX_QUEUE;
-			warned_user++;
 		} else {
 			adapter_tag_info_t *tag_info;
 
@@ -1595,74 +3576,75 @@
 	return (tags);
 }
 
+static u_int
+ahc_linux_user_dv_setting(struct ahc_softc *ahc)
+{
+	static int warned_user;
+	int dv;
+
+	if (ahc->unit >= NUM_ELEMENTS(aic7xxx_dv_settings)) {
+		if (warned_user == 0) {
+
+			printf(KERN_WARNING
+"aic7xxx: WARNING: Insufficient dv settings instances\n"
+"aic7xxx: for installed controllers. Using defaults\n"
+"aic7xxx: Please update the aic7xxx_dv_settings array\n"
+"aic7xxx: in the aic7xxx_osm.c source file.\n");
+			warned_user++;
+		}
+		dv = -1;
+	} else {
+
+		dv = aic7xxx_dv_settings[ahc->unit];
+	}
+
+	if (dv < 0) {
+		u_long s;
+
+		/*
+		 * Apply the default.
+		 */
+		/*
+		 * XXX - Enable DV on non-U160 controllers once it
+		 *       has been tested there.
+		 */
+		ahc_lock(ahc, &s);
+		dv = (ahc->features & AHC_DT);
+		if (ahc->seep_config != 0
+		 && ahc->seep_config->signature >= CFSIGNATURE2)
+			dv = (ahc->seep_config->adapter_control & CFENABLEDV);
+		ahc_unlock(ahc, &s);
+	}
+	return (dv);
+}
+
 /*
  * Determines the queue depth for a given device.
  */
 static void
-ahc_linux_device_queue_depth(struct ahc_softc *ahc, Scsi_Device * device)
+ahc_linux_device_queue_depth(struct ahc_softc *ahc,
+			     struct ahc_linux_device *dev)
 {
 	struct	ahc_devinfo devinfo;
 	u_int	tags;
 
 	ahc_compile_devinfo(&devinfo,
-			    device->channel == 0 ? ahc->our_id : ahc->our_id_b,
-			    device->id, device->lun,
-			    device->channel == 0 ? 'A' : 'B',
+			    dev->target->channel == 0
+			  ? ahc->our_id : ahc->our_id_b,
+			    dev->target->target, dev->lun,
+			    dev->target->channel == 0 ? 'A' : 'B',
 			    ROLE_INITIATOR);
 	tags = ahc_linux_user_tagdepth(ahc, &devinfo);
 	if (tags != 0
-	 && device->tagged_supported != 0) {
+	 && dev->scsi_device != NULL
+	 && dev->scsi_device->tagged_supported != 0) {
 
-		device->queue_depth = tags;
 		ahc_set_tags(ahc, &devinfo, AHC_QUEUE_TAGGED);
-		printf("scsi%d:%c:%d:%d: Tagged Queuing enabled.  Depth %d\n",
-	       	       ahc->platform_data->host->host_no, devinfo.channel,
-		       devinfo.target, devinfo.lun, tags);
+		ahc_print_devinfo(ahc, &devinfo);
+		printf("Tagged Queuing enabled.  Depth %d\n", tags);
 	} else {
-		/*
-		 * We allow the OS to queue 2 untagged transactions to
-		 * us at any time even though we can only execute them
-		 * serially on the controller/device.  This should remove
-		 * some latency.
-		 */
-		device->queue_depth = 2;
-	}
-}
-
-/*
- * Queue an SCB to the controller.
- */
-int
-ahc_linux_queue(Scsi_Cmnd * cmd, void (*scsi_done) (Scsi_Cmnd *))
-{
-	struct	 ahc_softc *ahc;
-	struct	 ahc_linux_device *dev;
-	u_long	 flags;
-
-	ahc = *(struct ahc_softc **)cmd->host->hostdata;
-
-	/*
-	 * Save the callback on completion function.
-	 */
-	cmd->scsi_done = scsi_done;
-
-	ahc_lock(ahc, &flags);
-	dev = ahc_linux_get_device(ahc, cmd->channel, cmd->target,
-				   cmd->lun, /*alloc*/TRUE);
-	if (dev == NULL) {
-		ahc_unlock(ahc, &flags);
-		printf("aic7xxx_linux_queue: Unable to allocate device!\n");
-		return (-ENOMEM);
-	}
-	cmd->result = CAM_REQ_INPROG << 16;
-	TAILQ_INSERT_TAIL(&dev->busyq, (struct ahc_cmd *)cmd, acmd_links.tqe);
-	if ((dev->flags & AHC_DEV_ON_RUN_LIST) == 0) {
-		TAILQ_INSERT_TAIL(&ahc->platform_data->device_runq, dev, links);
-		dev->flags |= AHC_DEV_ON_RUN_LIST;
-		ahc_linux_run_device_queues(ahc);
+		ahc_set_tags(ahc, &devinfo, AHC_QUEUE_NONE);
 	}
-	ahc_unlock(ahc, &flags);
-	return (0);
 }
 
 static void
@@ -1686,8 +3668,8 @@
 		 * Schedule us to run later.  The only reason we are not
 		 * running is because the whole controller Q is frozen.
 		 */
-		if (ahc->platform_data->qfrozen != 0) {
-
+		if (ahc->platform_data->qfrozen != 0
+	 	 && AHC_DV_SIMQ_FROZEN(ahc) == 0) {
 			TAILQ_INSERT_TAIL(&ahc->platform_data->device_runq,
 					  dev, links);
 			dev->flags |= AHC_DEV_ON_RUN_LIST;
@@ -1715,7 +3697,7 @@
 		 */
 		hscb->control = 0;
 		hscb->scsiid = BUILD_SCSIID(ahc, cmd);
-		hscb->lun = cmd->lun;
+		hscb->lun = cmd->device->lun;
 		mask = SCB_GET_TARGET_MASK(ahc, scb);
 		tinfo = ahc_fetch_transinfo(ahc, SCB_GET_CHANNEL(ahc, scb),
 					    SCB_GET_OUR_ID(scb),
@@ -1728,12 +3710,26 @@
 		if ((ahc->user_discenable & mask) != 0)
 			hscb->control |= DISCENB;
 
+	 	if (AHC_DV_CMD(cmd) != 0)
+			scb->flags |= SCB_SILENT;
+
 		if ((tstate->auto_negotiate & mask) != 0) {
 			scb->flags |= SCB_AUTO_NEGOTIATE;
 			scb->hscb->control |= MK_MESSAGE;
 		}
 
 		if ((dev->flags & (AHC_DEV_Q_TAGGED|AHC_DEV_Q_BASIC)) != 0) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+			int	msg_bytes;
+			uint8_t tag_msgs[2];
+
+			msg_bytes = scsi_populate_tag_msg(cmd, tag_msgs);
+			if (msg_bytes && tag_msgs[0] != MSG_SIMPLE_TASK) {
+				hscb->control |= tag_msgs[0];
+				if (tag_msgs[0] == MSG_ORDERED_TASK)
+					dev->commands_since_idle_or_otag = 0;
+			} else
+#endif
 			if (dev->commands_since_idle_or_otag == AHC_OTAG_THRESH
 			 && (dev->flags & AHC_DEV_Q_TAGGED) != 0) {
 				hscb->control |= MSG_ORDERED_TASK;
@@ -1763,7 +3759,7 @@
 
 			cur_seg = (struct scatterlist *)cmd->request_buffer;
 			nseg = pci_map_sg(ahc->dev_softc, cur_seg, cmd->use_sg,
-				 scsi_to_pci_dma_dir(cmd ->sc_data_direction));
+			    scsi_to_pci_dma_dir(cmd->sc_data_direction));
 			end_seg = cur_seg + nseg;
 			/* Copy the segments into the SG list. */
 			sg = scb->sg_list;
@@ -1867,41 +3863,29 @@
 /*
  * SCSI controller interrupt handler.
  */
-void
+irqreturn_t
 ahc_linux_isr(int irq, void *dev_id, struct pt_regs * regs)
 {
 	struct	ahc_softc *ahc;
-	struct	ahc_cmd *acmd;
 	u_long	flags;
-	struct	ahc_linux_device *next_dev;
+	int	ours;
 
 	ahc = (struct ahc_softc *) dev_id;
 	ahc_lock(ahc, &flags); 
-	ahc_intr(ahc);
-	acmd = TAILQ_FIRST(&ahc->platform_data->completeq);
-	TAILQ_INIT(&ahc->platform_data->completeq);
-	next_dev = ahc_linux_next_device_to_run(ahc);
+	ours = ahc_intr(ahc);
+	if (ahc_linux_next_device_to_run(ahc) != NULL)
+		ahc_schedule_runq(ahc);
+	ahc_linux_run_complete_queue(ahc);
 	ahc_unlock(ahc, &flags);
-	if (next_dev) {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		tasklet_schedule(&ahc->platform_data->runq_tasklet);
-#else
-		ahc_runq_tasklet((unsigned long)ahc);
-#endif
-	}
-	if (acmd != NULL)
-		ahc_linux_run_complete_queue(ahc, acmd);
+	return IRQ_RETVAL(ours);
 }
 
 void
 ahc_platform_flushwork(struct ahc_softc *ahc)
 {
-	struct ahc_cmd *acmd;
 
-	acmd = TAILQ_FIRST(&ahc->platform_data->completeq);
-	TAILQ_INIT(&ahc->platform_data->completeq);
-	if (acmd != NULL)
-		ahc_linux_run_complete_queue(ahc, acmd);
+	while (ahc_linux_run_complete_queue(ahc) != NULL)
+		;
 }
 
 static struct ahc_linux_target*
@@ -1910,6 +3894,10 @@
 	struct ahc_linux_target *targ;
 	u_int target_offset;
 
+	target_offset = target;
+	if (channel != 0)
+		target_offset += 8;
+
 	targ = malloc(sizeof(*targ), M_DEVBUG, M_NOWAIT);
 	if (targ == NULL)
 		return (NULL);
@@ -1917,9 +3905,7 @@
 	targ->channel = channel;
 	targ->target = target;
 	targ->ahc = ahc;
-	target_offset = target;
-	if (channel != 0)
-		target_offset += 8;
+	targ->flags = AHC_DV_REQUIRED;
 	ahc->platform_data->targets[target_offset] = targ;
 	return (targ);
 }
@@ -1927,12 +3913,41 @@
 static void
 ahc_linux_free_target(struct ahc_softc *ahc, struct ahc_linux_target *targ)
 {
+	struct ahc_devinfo devinfo;
+	struct ahc_initiator_tinfo *tinfo;
+	struct ahc_tmode_tstate *tstate;
+	u_int our_id;
 	u_int target_offset;
+	char channel;
 
+	/*
+	 * Force a negotiation to async/narrow on any
+	 * future command to this device unless a bus
+	 * reset occurs between now and that command.
+	 */
+	channel = 'A' + targ->channel;
+	our_id = ahc->our_id;
 	target_offset = targ->target;
-	if (targ->channel != 0)
+	if (targ->channel != 0) {
 		target_offset += 8;
+		our_id = ahc->our_id_b;
+	}
+	tinfo = ahc_fetch_transinfo(ahc, channel, our_id,
+				    targ->target, &tstate);
+	ahc_compile_devinfo(&devinfo, our_id, targ->target, CAM_LUN_WILDCARD,
+			    channel, ROLE_INITIATOR);
+	ahc_set_syncrate(ahc, &devinfo, NULL, 0, 0, 0,
+			 AHC_TRANS_GOAL, /*paused*/FALSE);
+	ahc_set_width(ahc, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
+		      AHC_TRANS_GOAL, /*paused*/FALSE);
+	ahc_update_neg_request(ahc, &devinfo, tstate, tinfo, AHC_NEG_ALWAYS);
 	ahc->platform_data->targets[target_offset] = NULL;
+	if (targ->inq_data != NULL)
+		free(targ->inq_data, M_DEVBUF);
+	if (targ->dv_buffer != NULL)
+		free(targ->dv_buffer, M_DEVBUF);
+	if (targ->dv_buffer1 != NULL)
+		free(targ->dv_buffer1, M_DEVBUF);
 	free(targ, M_DEVBUF);
 }
 
@@ -1975,43 +3990,16 @@
 {
 	struct ahc_linux_target *targ;
 
-	del_timer(&dev->timer);
+	del_timer_sync(&dev->timer);
 	targ = dev->target;
 	targ->devices[dev->lun] = NULL;
 	free(dev, M_DEVBUF);
 	targ->refcount--;
-	if (targ->refcount == 0)
+	if (targ->refcount == 0
+	 && (targ->flags & AHC_DV_REQUIRED) == 0)
 		ahc_linux_free_target(ahc, targ);
 }
 
-/*
- * Return a string describing the driver.
- */
-const char *
-ahc_linux_info(struct Scsi_Host *host)
-{
-	static char buffer[512];
-	char	ahc_info[256];
-	char   *bp;
-	struct ahc_softc *ahc;
-
-	bp = &buffer[0];
-	ahc = *(struct ahc_softc **)host->hostdata;
-	memset(bp, 0, sizeof(buffer));
-	strcpy(bp, "Adaptec AIC7XXX EISA/VLB/PCI SCSI HBA DRIVER, Rev ");
-	strcat(bp, AIC7XXX_DRIVER_VERSION);
-	strcat(bp, "\n");
-	strcat(bp, "        <");
-	strcat(bp, ahc->description);
-	strcat(bp, ">\n");
-	strcat(bp, "        ");
-	ahc_controller_info(ahc, ahc_info);
-	strcat(bp, ahc_info);
-	strcat(bp, "\n");
-
-	return (bp);
-}
-
 void
 ahc_send_async(struct ahc_softc *ahc, char channel,
 	       u_int target, u_int lun, ac_code code, void *arg)
@@ -2082,7 +4070,31 @@
 		break;
 	}
         case AC_SENT_BDR:
+	{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+		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)
+		Scsi_Device *scsi_dev;
+
+		/*
+		 * Find the SCSI device associated with this
+		 * request and indicate that a UA is expected.
+		 */
+		for (scsi_dev = ahc->platform_data->host->host_queue;
+		     scsi_dev != NULL; scsi_dev = scsi_dev->next) {
+			if (channel - 'A' == scsi_dev->channel
+			 && target == scsi_dev->id
+			 && (lun == CAM_LUN_WILDCARD
+			  || lun == scsi_dev->lun)) {
+				scsi_dev->was_reset = 1;
+				scsi_dev->expecting_cc_ua = 1;
+			}
+		}
+#endif
 		break;
+	}
         case AC_BUS_RESET:
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 		if (ahc->platform_data->host != NULL) {
@@ -2100,10 +4112,10 @@
  * Calls the higher level scsi done function and frees the scb.
  */
 void
-ahc_done(struct ahc_softc *ahc, struct scb * scb)
+ahc_done(struct ahc_softc *ahc, struct scb *scb)
 {
 	Scsi_Cmnd *cmd;
-	struct ahc_linux_device *dev;
+	struct	   ahc_linux_device *dev;
 
 	LIST_REMOVE(scb, pending_links);
 	if ((scb->flags & SCB_UNTAGGEDQ) != 0) {
@@ -2125,27 +4137,41 @@
 	dev = scb->platform_data->dev;
 	dev->active--;
 	dev->openings++;
-	ahc_linux_unmap_scb(ahc, scb);
-	if (scb->flags & SCB_SENSE) {
-		memcpy(cmd->sense_buffer, ahc_get_sense_buf(ahc, scb),
-		       MIN(sizeof(struct scsi_sense_data),
-			   sizeof(cmd->sense_buffer)));
-		cmd->result |= (DRIVER_SENSE << 24);
-	} else {
-		/*
-		 * Guard against stale sense data.
-		 * The Linux mid-layer assumes that sense
-		 * was retrieved anytime the first byte of
-		 * the sense buffer looks "sane".
-		 */
-		cmd->sense_buffer[0] = 0;
+	if ((cmd->result & (CAM_DEV_QFRZN << 16)) != 0) {
+		cmd->result &= ~(CAM_DEV_QFRZN << 16);
+		dev->qfrozen--;
 	}
+	ahc_linux_unmap_scb(ahc, scb);
+
+	/*
+	 * Guard against stale sense data.
+	 * The Linux mid-layer assumes that sense
+	 * was retrieved anytime the first byte of
+	 * the sense buffer looks "sane".
+	 */
+	cmd->sense_buffer[0] = 0;
 	if (ahc_get_transaction_status(scb) == CAM_REQ_INPROG) {
 		uint32_t amount_xferred;
 
 		amount_xferred =
 		    ahc_get_transfer_length(scb) - ahc_get_residual(scb);
-		if (amount_xferred < scb->io_ctx->underflow) {
+		if ((scb->flags & SCB_TRANSMISSION_ERROR) != 0) {
+#ifdef AHC_DEBUG
+			if ((ahc_debug & AHC_SHOW_MISC) != 0) {
+				ahc_print_path(ahc, scb);
+				printf("Set CAM_UNCOR_PARITY\n");
+			}
+#endif
+			ahc_set_transaction_status(scb, CAM_UNCOR_PARITY);
+		} else if (amount_xferred < scb->io_ctx->underflow) {
+			u_int i;
+
+			ahc_print_path(ahc, scb);
+			printf("CDB:");
+			for (i = 0; i < scb->io_ctx->cmd_len; i++)
+				printf(" 0x%x", scb->io_ctx->cmnd[i]);
+			printf("\n");
+			ahc_print_path(ahc, scb);
 			printf("Saw underflow (%ld of %ld bytes). "
 			       "Treated as error\n",
 				ahc_get_residual(scb),
@@ -2153,20 +4179,21 @@
 			ahc_set_transaction_status(scb, CAM_DATA_RUN_ERR);
 		} else {
 			ahc_set_transaction_status(scb, CAM_REQ_CMP);
-			ahc_linux_sniff_command(ahc, cmd, scb);
 		}
-	} else if (ahc_get_transaction_status(scb) == DID_OK) {
+	} else if (ahc_get_transaction_status(scb) == CAM_SCSI_STATUS_ERROR) {
 		ahc_linux_handle_scsi_status(ahc, dev, scb);
-	} else if (ahc_get_transaction_status(scb) == DID_NO_CONNECT) {
-		/*
-		 * Should a selection timeout kill the device?
-		 * That depends on whether the selection timeout
-		 * is persistent.  Since we have no guarantee that
-		 * the mid-layer will issue an inquiry for this device
-		 * again, we can't just kill it off.
+	} else if (ahc_get_transaction_status(scb) == CAM_SEL_TIMEOUT) {
 		dev->flags |= AHC_DEV_UNCONFIGURED;
-		 */
+		if (AHC_DV_CMD(cmd) == FALSE)
+			dev->target->flags &= ~AHC_DV_REQUIRED;
 	}
+	/*
+	 * Start DV for devices that require it assuming the first command
+	 * sent does not result in a selection timeout.
+	 */
+	if (ahc_get_transaction_status(scb) != CAM_SEL_TIMEOUT
+	 && (dev->target->flags & AHC_DV_REQUIRED) != 0)
+		ahc_linux_start_dv(ahc);
 
 	if (dev->openings == 1
 	 && ahc_get_transaction_status(scb) == CAM_REQ_CMP
@@ -2189,7 +4216,8 @@
 
 	if (TAILQ_EMPTY(&dev->busyq)) {
 		if ((dev->flags & AHC_DEV_UNCONFIGURED) != 0
-		 && dev->active == 0)
+		 && dev->active == 0
+	 	 && (dev->flags & AHC_DEV_TIMER_ACTIVE) == 0)
 			ahc_linux_free_device(ahc, dev);
 	} else if ((dev->flags & AHC_DEV_ON_RUN_LIST) == 0) {
 		TAILQ_INSERT_TAIL(&ahc->platform_data->device_runq, dev, links);
@@ -2198,17 +4226,38 @@
 
 	if ((scb->flags & SCB_RECOVERY_SCB) != 0) {
 		printf("Recovery SCB completes\n");
-		up(&ahc->platform_data->eh_sem);
+		if (ahc_get_transaction_status(scb) == CAM_BDR_SENT
+		 || ahc_get_transaction_status(scb) == CAM_REQ_ABORTED)
+			ahc_set_transaction_status(scb, CAM_CMD_TIMEOUT);
+		if ((ahc->platform_data->flags & AHC_UP_EH_SEMAPHORE) != 0) {
+			ahc->platform_data->flags &= ~AHC_UP_EH_SEMAPHORE;
+			up(&ahc->platform_data->eh_sem);
+		}
 	}
 
 	ahc_free_scb(ahc, scb);
 	ahc_linux_queue_cmd_complete(ahc, cmd);
+
+	if ((ahc->platform_data->flags & AHC_DV_WAIT_SIMQ_EMPTY) != 0
+	 && LIST_FIRST(&ahc->pending_scbs) == NULL) {
+		ahc->platform_data->flags &= ~AHC_DV_WAIT_SIMQ_EMPTY;
+		up(&ahc->platform_data->dv_sem);
+	}
+		
 }
 
 static void
 ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
 			     struct ahc_linux_device *dev, struct scb *scb)
 {
+	struct	ahc_devinfo devinfo;
+
+	ahc_compile_devinfo(&devinfo,
+			    ahc->our_id,
+			    dev->target->target, dev->lun,
+			    dev->target->channel == 0 ? 'A' : 'B',
+			    ROLE_INITIATOR);
+	
 	/*
 	 * We don't currently trust the mid-layer to
 	 * properly deal with queue full or busy.  So,
@@ -2222,6 +4271,45 @@
 	switch (ahc_get_scsi_status(scb)) {
 	default:
 		break;
+	case SCSI_STATUS_CHECK_COND:
+	case SCSI_STATUS_CMD_TERMINATED:
+	{
+		Scsi_Cmnd *cmd;
+
+		/*
+		 * Copy sense information to the OS's cmd
+		 * structure if it is available.
+		 */
+		cmd = scb->io_ctx;
+		if (scb->flags & SCB_SENSE) {
+			u_int sense_size;
+
+			sense_size = MIN(sizeof(struct scsi_sense_data)
+				       - ahc_get_sense_residual(scb),
+					 sizeof(cmd->sense_buffer));
+			memcpy(cmd->sense_buffer,
+			       ahc_get_sense_buf(ahc, scb), sense_size);
+			if (sense_size < sizeof(cmd->sense_buffer))
+				memset(&cmd->sense_buffer[sense_size], 0,
+				       sizeof(cmd->sense_buffer) - sense_size);
+			cmd->result |= (DRIVER_SENSE << 24);
+#ifdef AHC_DEBUG
+			if (ahc_debug & AHC_SHOW_SENSE) {
+				int i;
+
+				printf("Copied %d bytes of sense data:",
+				       sense_size);
+				for (i = 0; i < sense_size; i++) {
+					if ((i & 0xF) == 0)
+						printf("\n");
+					printf("0x%x ", cmd->sense_buffer[i]);
+				}
+				printf("\n");
+			}
+#endif
+		}
+		break;
+	}
 	case SCSI_STATUS_QUEUE_FULL:
 	{
 		/*
@@ -2267,13 +4355,20 @@
 			}
 			ahc_set_transaction_status(scb, CAM_REQUEUE_REQ);
 			ahc_set_scsi_status(scb, SCSI_STATUS_OK);
+			ahc_platform_set_tags(ahc, &devinfo,
+				     (dev->flags & AHC_DEV_Q_BASIC)
+				   ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED);
 			break;
 		}
 		/*
 		 * Drop down to a single opening, and treat this
-		 * as if the target return BUSY SCSI status.
+		 * as if the target returned BUSY SCSI status.
 		 */
 		dev->openings = 1;
+		ahc_set_scsi_status(scb, SCSI_STATUS_BUSY);
+		ahc_platform_set_tags(ahc, &devinfo,
+			     (dev->flags & AHC_DEV_Q_BASIC)
+			   ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED);
 		/* FALLTHROUGH */
 	}
 	case SCSI_STATUS_BUSY:
@@ -2301,206 +4396,280 @@
 }
 
 static void
-ahc_linux_filter_command(struct ahc_softc *ahc, Scsi_Cmnd *cmd, struct scb *scb)
+ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, Scsi_Cmnd *cmd)
+{
+	/*
+	 * Typically, the complete queue has very few entries
+	 * queued to it before the queue is emptied by
+	 * ahc_linux_run_complete_queue, so sorting the entries
+	 * by generation number should be inexpensive.
+	 * We perform the sort so that commands that complete
+	 * with an error are retuned in the order origionally
+	 * queued to the controller so that any subsequent retries
+	 * are performed in order.  The underlying ahc routines do
+	 * not guarantee the order that aborted commands will be
+	 * returned to us.
+	 */
+	struct ahc_completeq *completeq;
+	struct ahc_cmd *list_cmd;
+	struct ahc_cmd *acmd;
+
+	/*
+	 * Map CAM error codes into Linux Error codes.  We
+	 * avoid the conversion so that the DV code has the
+	 * full error information available when making
+	 * state change decisions.
+	 */
+	if (AHC_DV_CMD(cmd) == FALSE) {
+		u_int new_status;
+
+		switch (ahc_cmd_get_transaction_status(cmd)) {
+		case CAM_REQ_INPROG:
+		case CAM_REQ_CMP:
+		case CAM_SCSI_STATUS_ERROR:
+			new_status = DID_OK;
+			break;
+		case CAM_REQ_ABORTED:
+			new_status = DID_ABORT;
+			break;
+		case CAM_BUSY:
+			new_status = DID_BUS_BUSY;
+			break;
+		case CAM_REQ_INVALID:
+		case CAM_PATH_INVALID:
+			new_status = DID_BAD_TARGET;
+			break;
+		case CAM_SEL_TIMEOUT:
+			new_status = DID_NO_CONNECT;
+			break;
+		case CAM_SCSI_BUS_RESET:
+		case CAM_BDR_SENT:
+			new_status = DID_RESET;
+			break;
+		case CAM_UNCOR_PARITY:
+			new_status = DID_PARITY;
+			break;
+		case CAM_CMD_TIMEOUT:
+			new_status = DID_TIME_OUT;
+			break;
+		case CAM_UA_ABORT:
+		case CAM_REQ_CMP_ERR:
+		case CAM_AUTOSENSE_FAIL:
+		case CAM_NO_HBA:
+		case CAM_DATA_RUN_ERR:
+		case CAM_UNEXP_BUSFREE:
+		case CAM_SEQUENCE_FAIL:
+		case CAM_CCB_LEN_ERR:
+		case CAM_PROVIDE_FAIL:
+		case CAM_REQ_TERMIO:
+		case CAM_UNREC_HBA_ERROR:
+		case CAM_REQ_TOO_BIG:
+			new_status = DID_ERROR;
+			break;
+		case CAM_REQUEUE_REQ:
+			/*
+			 * If we want the request requeued, make sure there
+			 * are sufficent retries.  In the old scsi error code,
+			 * we used to be able to specify a result code that
+			 * bypassed the retry count.  Now we must use this
+			 * hack.  We also "fake" a check condition with
+			 * a sense code of ABORTED COMMAND.  This seems to
+			 * evoke a retry even if this command is being sent
+			 * via the eh thread.  Ick!  Ick!  Ick!
+			 */
+			if (cmd->retries > 0)
+				cmd->retries--;
+			new_status = DID_OK;
+			ahc_cmd_set_scsi_status(cmd, SCSI_STATUS_CHECK_COND);
+			cmd->result |= (DRIVER_SENSE << 24);
+			memset(cmd->sense_buffer, 0,
+			       sizeof(cmd->sense_buffer));
+			cmd->sense_buffer[0] = SSD_ERRCODE_VALID
+					     | SSD_CURRENT_ERROR;
+			cmd->sense_buffer[2] = SSD_KEY_ABORTED_COMMAND;
+			break;
+		default:
+			/* We should never get here */
+			new_status = DID_ERROR;
+			break;
+		}
+
+		ahc_cmd_set_transaction_status(cmd, new_status);
+	}
+
+	completeq = &ahc->platform_data->completeq;
+	list_cmd = TAILQ_FIRST(completeq);
+	acmd = (struct ahc_cmd *)cmd;
+	while (list_cmd != NULL
+	    && acmd_scsi_cmd(list_cmd).serial_number
+	     < acmd_scsi_cmd(acmd).serial_number)
+		list_cmd = TAILQ_NEXT(list_cmd, acmd_links.tqe);
+	if (list_cmd != NULL)
+		TAILQ_INSERT_BEFORE(list_cmd, acmd, acmd_links.tqe);
+	else
+		TAILQ_INSERT_TAIL(completeq, acmd, acmd_links.tqe);
+}
+
+static void
+ahc_linux_filter_inquiry(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
 {
-	switch (cmd->cmnd[0]) {
-	case INQUIRY:
-	{
-		struct	ahc_devinfo devinfo;
-		struct	scsi_inquiry *inq;
-		struct	scsi_inquiry_data *sid;
-		struct	ahc_initiator_tinfo *tinfo;
-		struct	ahc_transinfo *user;
-		struct	ahc_transinfo *goal;
-		struct	ahc_transinfo *curr;
-		struct	ahc_tmode_tstate *tstate;
-		struct	ahc_syncrate *syncrate;
-		struct	ahc_linux_device *dev;
-		u_int	scsiid;
-		u_int	maxsync;
-		int	transferred_len;
-		int	minlen;
-		u_int	width;
-		u_int	period;
-		u_int	offset;
-		u_int	ppr_options;
-
-		 /*
-		  * Validate the command.  We only want to filter
-		  * standard inquiry commands, not those querying
-		  * Vital Product Data.
-		  */
-		inq = (struct scsi_inquiry *)cmd->cmnd;
-		if ((inq->byte2 & SI_EVPD) != 0
-		 || inq->page_code != 0)
-			break;
-
-		if (cmd->use_sg != 0) {
-			printf("%s: SG Inquiry response ignored\n",
-			       ahc_name(ahc));
-			break;
-		}
-		transferred_len = ahc_get_transfer_length(scb)
-				- ahc_get_residual(scb);
-		sid = (struct scsi_inquiry_data *)cmd->request_buffer;
+	struct	scsi_inquiry_data *sid;
+	struct	ahc_initiator_tinfo *tinfo;
+	struct	ahc_transinfo *user;
+	struct	ahc_transinfo *goal;
+	struct	ahc_transinfo *curr;
+	struct	ahc_tmode_tstate *tstate;
+	struct	ahc_syncrate *syncrate;
+	struct	ahc_linux_device *dev;
+	u_int	maxsync;
+	u_int	width;
+	u_int	period;
+	u_int	offset;
+	u_int	ppr_options;
+	u_int	trans_version;
+	u_int	prot_version;
 
-		/*
-		 * Determine if this lun actually exists.  If so,
-		 * hold on to its corresponding device structure.
-		 * If not, make sure we release the device and
-		 * don't bother processing the rest of this inquiry
-		 * command.
-		 */
-		dev = ahc_linux_get_device(ahc, cmd->channel,
-					   cmd->target, cmd->lun,
-					   /*alloc*/FALSE);
-		if (transferred_len >= 1
-		 && SID_QUAL(sid) == SID_QUAL_LU_CONNECTED) {
+	/*
+	 * Determine if this lun actually exists.  If so,
+	 * hold on to its corresponding device structure.
+	 * If not, make sure we release the device and
+	 * don't bother processing the rest of this inquiry
+	 * command.
+	 */
+	dev = ahc_linux_get_device(ahc, devinfo->channel - 'A',
+				   devinfo->target, devinfo->lun,
+				   /*alloc*/TRUE);
 
-			dev->flags &= ~AHC_DEV_UNCONFIGURED;
-		} else {
-			dev->flags |= AHC_DEV_UNCONFIGURED;
-			break;
-		}
+	sid = (struct scsi_inquiry_data *)dev->target->inq_data;
+	if (SID_QUAL(sid) == SID_QUAL_LU_CONNECTED) {
 
-		/*
-		 * Update our notion of this device's transfer
-		 * negotiation capabilities.
-		 */
-		scsiid = BUILD_SCSIID(ahc, cmd);
-		ahc_compile_devinfo(&devinfo, SCSIID_OUR_ID(scsiid),
-				    cmd->target, cmd->lun,
-				    SCSIID_CHANNEL(ahc, scsiid),
-				    ROLE_INITIATOR);
-		tinfo = ahc_fetch_transinfo(ahc, devinfo.channel,
-					    devinfo.our_scsiid,
-					    devinfo.target, &tstate);
-		user = &tinfo->user;
-		goal = &tinfo->goal;
-		curr = &tinfo->curr;
-		width = user->width;
-		period = user->period;
-		offset = user->offset;
-		ppr_options = user->ppr_options;
-		minlen = offsetof(struct scsi_inquiry_data, version) + 1;
-		if (transferred_len >= minlen) {
-			curr->protocol_version = SID_ANSI_REV(sid);
+		dev->flags &= ~AHC_DEV_UNCONFIGURED;
+	} else {
+		dev->flags |= AHC_DEV_UNCONFIGURED;
+		return;
+	}
 
-			/*
-			 * Only attempt SPI3 once we've verified that
-			 * the device claims to support SPI3 features.
-			 */
-			if (curr->protocol_version < SCSI_REV_2)
-				curr->transport_version = SID_ANSI_REV(sid);
-			else
-				curr->transport_version = SCSI_REV_2;
-		}
+	/*
+	 * Update our notion of this device's transfer
+	 * negotiation capabilities.
+	 */
+	tinfo = ahc_fetch_transinfo(ahc, devinfo->channel,
+				    devinfo->our_scsiid,
+				    devinfo->target, &tstate);
+	user = &tinfo->user;
+	goal = &tinfo->goal;
+	curr = &tinfo->curr;
+	width = user->width;
+	period = user->period;
+	offset = user->offset;
+	ppr_options = user->ppr_options;
+	trans_version = user->transport_version;
+	prot_version = MIN(user->protocol_version, SID_ANSI_REV(sid));
 
-		minlen = offsetof(struct scsi_inquiry_data, flags) + 1;
-		if (transferred_len >= minlen
-		 && (sid->additional_length + 4) >= minlen) {
-			if ((sid->flags & SID_WBus16) == 0)
-				width = MSG_EXT_WDTR_BUS_8_BIT;
-			if ((sid->flags & SID_Sync) == 0) {
-				period = 0;
-				offset = 0;
-				ppr_options = 0;
-			}
-		} else {
-			/* Keep current settings */
-			break;
-		}
-		minlen = offsetof(struct scsi_inquiry_data, spi3data) + 1;
-		/*
-		 * This is a kludge to deal with inquiry requests that
-		 * are not large enough for us to pull the spi3/4 bits.
-		 * In this case, we assume that a device that tells us
-		 * they can provide inquiry data that spans the SPI3
-		 * bits and says its SCSI3 can handle a PPR request.
-		 * If the inquiry request has sufficient buffer space to
-		 * cover SPI3 bits, we honor them regardless of reported
-		 * SCSI REV.  We also allow any device that has had its
-		 * goal ppr_options set to allow DT speeds to keep that
-		 * option if a short inquiry occurs that would fail the
-		 * normal tests outlined above.
-		 */
-		if ((sid->additional_length + 4) >= minlen) {
-			if (transferred_len >= minlen) {
-				 if ((sid->spi3data & SID_SPI_CLOCK_DT) == 0)
-					ppr_options = 0;
-			} else if ((goal->ppr_options & MSG_EXT_PPR_DT_REQ)== 0)
-				ppr_options = 0;
+	/*
+	 * Only attempt SPI3/4 once we've verified that
+	 * the device claims to support SPI3/4 features.
+	 */
+	if (prot_version < SCSI_REV_2)
+		trans_version = SID_ANSI_REV(sid);
+	else
+		trans_version = SCSI_REV_2;
 
-			if (curr->protocol_version > SCSI_REV_2)
-				curr->transport_version = 3;
-		} else {
-			ppr_options = 0;
-		}
-		ahc_validate_width(ahc, /*tinfo limit*/NULL, &width,
-				   ROLE_UNKNOWN);
-		if ((ahc->features & AHC_ULTRA2) != 0)
-			maxsync = AHC_SYNCRATE_DT;
-		else if ((ahc->features & AHC_ULTRA) != 0)
-			maxsync = AHC_SYNCRATE_ULTRA;
-		else
-			maxsync = AHC_SYNCRATE_FAST;
+	if ((sid->flags & SID_WBus16) == 0)
+		width = MSG_EXT_WDTR_BUS_8_BIT;
+	if ((sid->flags & SID_Sync) == 0) {
+		period = 0;
+		offset = 0;
+		ppr_options = 0;
+	}
+	if ((sid->spi3data & SID_SPI_QAS) == 0)
+		ppr_options &= ~MSG_EXT_PPR_QAS_REQ;
+	if ((sid->spi3data & SID_SPI_CLOCK_DT) == 0)
+		ppr_options &= MSG_EXT_PPR_QAS_REQ;
+	if ((sid->spi3data & SID_SPI_IUS) == 0)
+		ppr_options &= (MSG_EXT_PPR_DT_REQ
+			      | MSG_EXT_PPR_QAS_REQ);
+
+	if (prot_version > SCSI_REV_2
+	 && ppr_options != 0)
+		trans_version = user->transport_version;
+
+	ahc_validate_width(ahc, /*tinfo limit*/NULL, &width, ROLE_UNKNOWN);
+	if ((ahc->features & AHC_ULTRA2) != 0)
+		maxsync = AHC_SYNCRATE_DT;
+	else if ((ahc->features & AHC_ULTRA) != 0)
+		maxsync = AHC_SYNCRATE_ULTRA;
+	else
+		maxsync = AHC_SYNCRATE_FAST;
 
-		syncrate = ahc_find_syncrate(ahc, &period,
-					     &ppr_options, maxsync);
-		ahc_validate_offset(ahc, /*tinfo limit*/NULL, syncrate,
-				    &offset, width, ROLE_UNKNOWN);
-		if (offset == 0 || period == 0) {
-			period = 0;
-			offset = 0;
-			ppr_options = 0;
-		}
-		/* Apply our filtered user settings. */
-		ahc_set_width(ahc, &devinfo, width,
-			      AHC_TRANS_GOAL, /*paused*/FALSE);
-		ahc_set_syncrate(ahc, &devinfo, syncrate, period,
-				 offset, ppr_options, AHC_TRANS_GOAL,
-				 /*paused*/FALSE);
-		break;
-	}
-	default:
-		panic("ahc_linux_filter_command: Unexpected Command type  %x\n",
-		      cmd->cmnd[0]);
-		break;
-	}
+	syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, maxsync);
+	ahc_validate_offset(ahc, /*tinfo limit*/NULL, syncrate,
+			    &offset, width, ROLE_UNKNOWN);
+	if (offset == 0 || period == 0) {
+		period = 0;
+		offset = 0;
+		ppr_options = 0;
+	}
+	/* Apply our filtered user settings. */
+	curr->transport_version = trans_version;
+	curr->protocol_version = prot_version;
+	ahc_set_width(ahc, devinfo, width, AHC_TRANS_GOAL, /*paused*/FALSE);
+	ahc_set_syncrate(ahc, devinfo, syncrate, period,
+			 offset, ppr_options, AHC_TRANS_GOAL,
+			 /*paused*/FALSE);
 }
 
 static void
 ahc_linux_sem_timeout(u_long arg)
 {
-	struct semaphore *sem;
+	struct	ahc_softc *ahc;
+	u_long	s;
+
+	ahc = (struct ahc_softc *)arg;
 
-	sem = (struct semaphore *)arg;
-	up(sem);
+	ahc_lock(ahc, &s);
+	if ((ahc->platform_data->flags & AHC_UP_EH_SEMAPHORE) != 0) {
+		ahc->platform_data->flags &= ~AHC_UP_EH_SEMAPHORE;
+		up(&ahc->platform_data->eh_sem);
+	}
+	ahc_unlock(ahc, &s);
 }
 
 static void
-ahc_linux_freeze_sim_queue(struct ahc_softc *ahc)
+ahc_linux_freeze_simq(struct ahc_softc *ahc)
 {
 	ahc->platform_data->qfrozen++;
-	if (ahc->platform_data->qfrozen == 1)
+	if (ahc->platform_data->qfrozen == 1) {
 		scsi_block_requests(ahc->platform_data->host);
+
+		/* XXX What about Twin channels? */
+		ahc_platform_abort_scbs(ahc, CAM_TARGET_WILDCARD, ALL_CHANNELS,
+					CAM_LUN_WILDCARD, SCB_LIST_NULL,
+					ROLE_INITIATOR, CAM_REQUEUE_REQ);
+	}
 }
 
 static void
-ahc_linux_release_sim_queue(u_long arg)
+ahc_linux_release_simq(u_long arg)
 {
 	struct ahc_softc *ahc;
 	u_long s;
 	int    unblock_reqs;
 
 	ahc = (struct ahc_softc *)arg;
+
 	unblock_reqs = 0;
 	ahc_lock(ahc, &s);
 	if (ahc->platform_data->qfrozen > 0)
 		ahc->platform_data->qfrozen--;
-	if (ahc->platform_data->qfrozen == 0) {
+	if (ahc->platform_data->qfrozen == 0)
 		unblock_reqs = 1;
+	if (AHC_DV_SIMQ_FROZEN(ahc)
+	 && ((ahc->platform_data->flags & AHC_DV_WAIT_SIMQ_RELEASE) != 0)) {
+		ahc->platform_data->flags &= ~AHC_DV_WAIT_SIMQ_RELEASE;
+		up(&ahc->platform_data->dv_sem);
 	}
+	ahc_schedule_runq(ahc);
 	ahc_unlock(ahc, &s);
 	/*
 	 * There is still a race here.  The mid-layer
@@ -2508,14 +4677,8 @@
 	 * a bottom half handler to run the queues
 	 * so we can unblock with our own lock held.
 	 */
-	if (unblock_reqs) {
+	if (unblock_reqs)
 		scsi_unblock_requests(ahc->platform_data->host);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-		tasklet_schedule(&ahc->platform_data->runq_tasklet);
-#else
-		ahc_runq_tasklet((unsigned long)ahc);
-#endif
-	}
 }
 
 static void
@@ -2534,6 +4697,9 @@
 	if (dev->qfrozen == 0
 	 && (dev->flags & AHC_DEV_ON_RUN_LIST) == 0)
 		ahc_linux_run_device_queue(ahc, dev);
+	if (TAILQ_EMPTY(&dev->busyq)
+	 && dev->active == 0)
+		ahc_linux_free_device(ahc, dev);
 	ahc_unlock(ahc, &s);
 }
 
@@ -2549,37 +4715,55 @@
 	u_int  saved_scbptr;
 	u_int  active_scb_index;
 	u_int  last_phase;
+	u_int  saved_scsiid;
+	u_int  cdb_byte;
 	int    retval;
+	int    was_paused;
 	int    paused;
 	int    wait;
 	int    disconnected;
 
+	pending_scb = NULL;
 	paused = FALSE;
 	wait = FALSE;
-	ahc = *(struct ahc_softc **)cmd->host->hostdata;
+	ahc = *(struct ahc_softc **)cmd->device->host->hostdata;
 	acmd = (struct ahc_cmd *)cmd;
 
 	printf("%s:%d:%d:%d: Attempting to queue a%s message\n",
-	       ahc_name(ahc), cmd->channel, cmd->target, cmd->lun,
+	       ahc_name(ahc), cmd->device->channel,
+	       cmd->device->id, cmd->device->lun,
 	       flag == SCB_ABORT ? "n ABORT" : " TARGET RESET");
 
+	printf("CDB:");
+	for (cdb_byte = 0; cdb_byte < cmd->cmd_len; cdb_byte++)
+		printf(" 0x%x", cmd->cmnd[cdb_byte]);
+	printf("\n");
+
 	/*
-	 * It is a bug that the upper layer takes
-	 * this lock just prior to calling us.
+	 * In all versions of Linux, we have to work around
+	 * a major flaw in how the mid-layer is locked down
+	 * if we are to sleep successfully in our error handler
+	 * while allowing our interrupt handler to run.  Since
+	 * the midlayer acquires either the io_request_lock or
+	 * our lock prior to calling us, we must use the
+	 * spin_unlock_irq() method for unlocking our lock.
+	 * This will force interrupts to be enabled on the
+	 * current CPU.  Since the EH thread should not have
+	 * been running with CPU interrupts disabled other than
+	 * by acquiring either the io_request_lock or our own
+	 * lock, this *should* be safe.
 	 */
-	spin_unlock_irq(&io_request_lock);
-
-	ahc_lock(ahc, &s);
+	ahc_midlayer_entrypoint_lock(ahc, &s);
 
 	/*
 	 * First determine if we currently own this command.
 	 * Start by searching the device queue.  If not found
 	 * there, check the pending_scb list.  If not found
 	 * at all, and the system wanted us to just abort the
-	 * command return success.
+	 * command, return success.
 	 */
-	dev = ahc_linux_get_device(ahc, cmd->channel, cmd->target,
-				   cmd->lun, /*alloc*/FALSE);
+	dev = ahc_linux_get_device(ahc, cmd->device->channel, cmd->device->id,
+				   cmd->device->lun, /*alloc*/FALSE);
 
 	if (dev == NULL) {
 		/*
@@ -2587,7 +4771,8 @@
 		 * so we must not still own the command.
 		 */
 		printf("%s:%d:%d:%d: Is not an active device\n",
-		       ahc_name(ahc), cmd->channel, cmd->target, cmd->lun);
+		       ahc_name(ahc), cmd->device->channel, cmd->device->id,
+		       cmd->device->lun);
 		retval = SUCCESS;
 		goto no_cmd;
 	}
@@ -2599,7 +4784,8 @@
 
 	if (list_acmd != NULL) {
 		printf("%s:%d:%d:%d: Command found on device queue\n",
-		       ahc_name(ahc), cmd->channel, cmd->target, cmd->lun);
+		       ahc_name(ahc), cmd->device->channel, cmd->device->id,
+		       cmd->device->lun);
 		if (flag == SCB_ABORT) {
 			TAILQ_REMOVE(&dev->busyq, list_acmd, acmd_links.tqe);
 			cmd->result = DID_ABORT << 16;
@@ -2610,11 +4796,13 @@
 	}
 
 	if ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED)) == 0
-	 && ahc_search_untagged_queues(ahc, cmd, cmd->target,
-				       cmd->channel + 'A', cmd->lun,
+	 && ahc_search_untagged_queues(ahc, cmd, cmd->device->id,
+				       cmd->device->channel + 'A',
+				       cmd->device->lun,
 				       CAM_REQ_ABORTED, SEARCH_COMPLETE) != 0) {
 		printf("%s:%d:%d:%d: Command found on untagged queue\n",
-		       ahc_name(ahc), cmd->channel, cmd->target, cmd->lun);
+		       ahc_name(ahc), cmd->device->channel, cmd->device->id,
+		       cmd->device->lun);
 		retval = SUCCESS;
 		goto done;
 	}
@@ -2631,8 +4819,9 @@
 
 		/* Any SCB for this device will do for a target reset */
 		LIST_FOREACH(pending_scb, &ahc->pending_scbs, pending_links) {
-		  	if (ahc_match_scb(ahc, pending_scb, cmd->target,
-					  cmd->channel + 'A', CAM_LUN_WILDCARD,
+		  	if (ahc_match_scb(ahc, pending_scb, cmd->device->id,
+					  cmd->device->channel + 'A',
+					  CAM_LUN_WILDCARD,
 					  SCB_LIST_NULL, ROLE_INITIATOR) == 0)
 				break;
 		}
@@ -2640,7 +4829,8 @@
 
 	if (pending_scb == NULL) {
 		printf("%s:%d:%d:%d: Command not found\n",
-		       ahc_name(ahc), cmd->channel, cmd->target, cmd->lun);
+		       ahc_name(ahc), cmd->device->channel, cmd->device->id,
+		       cmd->device->lun);
 		goto no_cmd;
 	}
 
@@ -2654,52 +4844,47 @@
 
 	/*
 	 * Ensure that the card doesn't do anything
-	 * behind our back and that no selections have occurred
-	 * that have not been serviced.  Also make sure that we
-	 * didn't "just" miss an interrupt that would
-	 * affect this cmd.
-	 */
-	ahc->flags |= AHC_ALL_INTERRUPTS;
-	do {
-		if (paused)
-			ahc_unpause(ahc);
-		ahc_intr(ahc);
-		ahc_pause(ahc);
-		paused = TRUE;
-		ahc_outb(ahc, SCSISEQ, ahc_inb(ahc, SCSISEQ) & ~ENSELO);
-		ahc_clear_critical_section(ahc);
-	} while ((ahc_inb(ahc, INTSTAT) & INT_PEND) != 0
-	      || (ahc_inb(ahc, SSTAT0) & (SELDO|SELINGO)));
-	ahc->flags &= ~AHC_ALL_INTERRUPTS;
-
-	ahc_dump_card_state(ahc);
+	 * behind our back and that we didn't "just" miss
+	 * an interrupt that would affect this cmd.
+	 */
+	was_paused = ahc_is_paused(ahc);
+	ahc_pause_and_flushwork(ahc);
+	paused = TRUE;
 
 	if ((pending_scb->flags & SCB_ACTIVE) == 0) {
 		printf("%s:%d:%d:%d: Command already completed\n",
-		       ahc_name(ahc), cmd->channel, cmd->target, cmd->lun);
+		       ahc_name(ahc), cmd->device->channel, cmd->device->id,
+		       cmd->device->lun);
 		goto no_cmd;
 	}
 
+	printf("%s: At time of recovery, card was %spaused\n",
+	       ahc_name(ahc), was_paused ? "" : "not ");
+	ahc_dump_card_state(ahc);
+
 	disconnected = TRUE;
 	if (flag == SCB_ABORT) {
-		if (ahc_search_qinfifo(ahc, cmd->target, cmd->channel + 'A',
-				       cmd->lun, pending_scb->hscb->tag,
+		if (ahc_search_qinfifo(ahc, cmd->device->id,
+				       cmd->device->channel + 'A',
+				       cmd->device->lun,
+				       pending_scb->hscb->tag,
 				       ROLE_INITIATOR, CAM_REQ_ABORTED,
 				       SEARCH_COMPLETE) > 0) {
 			printf("%s:%d:%d:%d: Cmd aborted from QINFIFO\n",
-			       ahc_name(ahc), cmd->channel, cmd->target,
-					cmd->lun);
+			       ahc_name(ahc), cmd->device->channel,
+					cmd->device->id, cmd->device->lun);
 			retval = SUCCESS;
 			goto done;
 		}
-	} else if (ahc_search_qinfifo(ahc, cmd->target, cmd->channel + 'A',
-				      cmd->lun, pending_scb->hscb->tag,
+	} else if (ahc_search_qinfifo(ahc, cmd->device->id,
+				      cmd->device->channel + 'A',
+				      cmd->device->lun, pending_scb->hscb->tag,
 				      ROLE_INITIATOR, /*status*/0,
 				      SEARCH_COUNT) > 0) {
 		disconnected = FALSE;
 	}
 
-	if (disconnected && (ahc_inb(ahc, SEQ_FLAGS) & IDENTIFY_SEEN) != 0) {
+	if (disconnected && (ahc_inb(ahc, SEQ_FLAGS) & NOT_IDENTIFIED) == 0) {
 		struct scb *bus_scb;
 
 		bus_scb = ahc_lookup_scb(ahc, ahc_inb(ahc, SCB_TAG));
@@ -2707,7 +4892,7 @@
 			disconnected = FALSE;
 		else if (flag != SCB_ABORT
 		      && ahc_inb(ahc, SAVED_SCSIID) == pending_scb->hscb->scsiid
-		      && ahc_inb(ahc, SAVED_LUN) == pending_scb->hscb->lun)
+		      && ahc_inb(ahc, SAVED_LUN) == SCB_GET_LUN(pending_scb))
 			disconnected = FALSE;
 	}
 
@@ -2722,10 +4907,11 @@
 	last_phase = ahc_inb(ahc, LASTPHASE);
 	saved_scbptr = ahc_inb(ahc, SCBPTR);
 	active_scb_index = ahc_inb(ahc, SCB_TAG);
+	saved_scsiid = ahc_inb(ahc, SAVED_SCSIID);
 	if (last_phase != P_BUSFREE
 	 && (pending_scb->hscb->tag == active_scb_index
 	  || (flag == SCB_DEVICE_RESET
-	   && SCSIID_TARGET(ahc, ahc_inb(ahc, SAVED_SCSIID)) == cmd->target))) {
+	   && SCSIID_TARGET(ahc, saved_scsiid) == cmd->device->id))) {
 
 		/*
 		 * We're active on the bus, so assert ATN
@@ -2736,7 +4922,8 @@
 		ahc_outb(ahc, MSG_OUT, HOST_MSG);
 		ahc_outb(ahc, SCSISIGO, last_phase|ATNO);
 		printf("%s:%d:%d:%d: Device is active, asserting ATN\n",
-		       ahc_name(ahc), cmd->channel, cmd->target, cmd->lun);
+		       ahc_name(ahc), cmd->device->channel, cmd->device->id,
+		       cmd->device->lun);
 		wait = TRUE;
 	} else if (disconnected) {
 
@@ -2766,8 +4953,9 @@
 		 * same element in the SCB, SCB_NEXT, for
 		 * both the qinfifo and the disconnected list.
 		 */
-		ahc_search_disc_list(ahc, cmd->target, cmd->channel + 'A',
-				     cmd->lun, pending_scb->hscb->tag,
+		ahc_search_disc_list(ahc, cmd->device->id,
+				     cmd->device->channel + 'A',
+				     cmd->device->lun, pending_scb->hscb->tag,
 				     /*stop_on_first*/TRUE,
 				     /*remove*/TRUE,
 				     /*save_state*/FALSE);
@@ -2790,19 +4978,20 @@
 		 * so we are the next SCB for this target
 		 * to run.
 		 */
-		ahc_search_qinfifo(ahc, cmd->target, cmd->channel + 'A',
-				   cmd->lun, SCB_LIST_NULL, ROLE_INITIATOR,
-				   CAM_REQUEUE_REQ, SEARCH_COMPLETE);
-		ahc_print_path(ahc, pending_scb);
-		printf("Queuing a recovery SCB\n");
+		ahc_search_qinfifo(ahc, cmd->device->id,
+				   cmd->device->channel + 'A',
+				   cmd->device->lun, SCB_LIST_NULL,
+				   ROLE_INITIATOR, CAM_REQUEUE_REQ,
+				   SEARCH_COMPLETE);
 		ahc_qinfifo_requeue_tail(ahc, pending_scb);
 		ahc_outb(ahc, SCBPTR, saved_scbptr);
-		printf("%s:%d:%d:%d: Device is disconnected, re-queuing SCB\n",
-		       ahc_name(ahc), cmd->channel, cmd->target, cmd->lun);
+		ahc_print_path(ahc, pending_scb);
+		printf("Device is disconnected, re-queuing SCB\n");
 		wait = TRUE;
 	} else {
 		printf("%s:%d:%d:%d: Unable to deliver message\n",
-		       ahc_name(ahc), cmd->channel, cmd->target, cmd->lun);
+		       ahc_name(ahc), cmd->device->channel, cmd->device->id,
+		       cmd->device->lun);
 		retval = FAILED;
 		goto done;
 	}
@@ -2822,176 +5011,29 @@
 		struct timer_list timer;
 		int ret;
 
-		ahc_unlock(ahc, &s);
+		ahc->platform_data->flags |= AHC_UP_EH_SEMAPHORE;
+		spin_unlock_irq(&ahc->platform_data->spin_lock);
 		init_timer(&timer);
-		timer.data = (u_long)&ahc->platform_data->eh_sem;
+		timer.data = (u_long)ahc;
 		timer.expires = jiffies + (5 * HZ);
 		timer.function = ahc_linux_sem_timeout;
 		add_timer(&timer);
 		printf("Recovery code sleeping\n");
 		down(&ahc->platform_data->eh_sem);
 		printf("Recovery code awake\n");
-        	ret = del_timer(&timer);
+        	ret = del_timer_sync(&timer);
 		if (ret == 0) {
 			printf("Timer Expired\n");
 			retval = FAILED;
 		}
-		ahc_lock(ahc, &s);
+		spin_lock_irq(&ahc->platform_data->spin_lock);
 	}
-	acmd = TAILQ_FIRST(&ahc->platform_data->completeq);
-	TAILQ_INIT(&ahc->platform_data->completeq);
-	ahc_unlock(ahc, &s);
-	if (acmd != NULL)
-		ahc_linux_run_complete_queue(ahc, acmd);
-	ahc_runq_tasklet((unsigned long)ahc);
-	spin_lock_irq(&io_request_lock);
+	ahc_schedule_runq(ahc);
+	ahc_linux_run_complete_queue(ahc);
+	ahc_midlayer_entrypoint_unlock(ahc, &s);
 	return (retval);
 }
 
-/*
- * Abort the current SCSI command(s).
- */
-int
-ahc_linux_abort(Scsi_Cmnd *cmd)
-{
-	int error;
-
-	error = ahc_linux_queue_recovery_cmd(cmd, SCB_ABORT);
-	if (error != 0)
-		printf("aic7xxx_abort returns 0x%x\n", error);
-	return (error);
-}
-
-/*
- * Attempt to send a target reset message to the device that timed out.
- */
-int
-ahc_linux_dev_reset(Scsi_Cmnd *cmd)
-{
-	int error;
-
-	error = ahc_linux_queue_recovery_cmd(cmd, SCB_DEVICE_RESET);
-	if (error != 0)
-		printf("aic7xxx_dev_reset returns 0x%x\n", error);
-	return (error);
-}
-
-/*
- * Reset the SCSI bus.
- */
-int
-ahc_linux_bus_reset(Scsi_Cmnd *cmd)
-{
-	struct ahc_softc *ahc;
-	struct ahc_cmd *acmd;
-	u_long s;
-	int    found;
-
-	/*
-	 * It is a bug that the upper layer takes
-	 * this lock just prior to calling us.
-	 */
-	spin_unlock_irq(&io_request_lock);
-
-	ahc = *(struct ahc_softc **)cmd->host->hostdata;
-	ahc_lock(ahc, &s);
-	found = ahc_reset_channel(ahc, cmd->channel + 'A',
-				  /*initiate reset*/TRUE);
-	acmd = TAILQ_FIRST(&ahc->platform_data->completeq);
-	TAILQ_INIT(&ahc->platform_data->completeq);
-	ahc_unlock(ahc, &s);
-	if (bootverbose)
-		printf("%s: SCSI bus reset delivered. "
-		       "%d SCBs aborted.\n", ahc_name(ahc), found);
-
-	if (acmd != NULL)
-		ahc_linux_run_complete_queue(ahc, acmd);
-
-	spin_lock_irq(&io_request_lock);
-	return SUCCESS;
-}
-
-/*
- * Return the disk geometry for the given SCSI device.
- */
-int
-ahc_linux_biosparam(Disk *disk, kdev_t dev, int geom[])
-{
-	int	heads;
-	int	sectors;
-	int	cylinders;
-	int	ret;
-	int	extended;
-	struct	ahc_softc *ahc;
-	struct	buffer_head *bh;
-
-	ahc = *((struct ahc_softc **)disk->device->host->hostdata);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,17)
-	bh = bread(MKDEV(MAJOR(dev), MINOR(dev) & ~0xf), 0, block_size(dev));
-#else
-	bh = bread(MKDEV(MAJOR(dev), MINOR(dev) & ~0xf), 0, 1024);
-#endif
-
-	if (bh) {
-		ret = scsi_partsize(bh, disk->capacity,
-				    &geom[2], &geom[0], &geom[1]);
-		brelse(bh);
-		if (ret != -1)
-			return (ret);
-	}
-	heads = 64;
-	sectors = 32;
-	cylinders = disk->capacity / (heads * sectors);
-
-	if (aic7xxx_extended != 0)
-		extended = 1;
-	else if (disk->device->channel == 0)
-		extended = (ahc->flags & AHC_EXTENDED_TRANS_A) != 0;
-	else
-		extended = (ahc->flags & AHC_EXTENDED_TRANS_B) != 0;
-	if (extended && cylinders >= 1024) {
-		heads = 255;
-		sectors = 63;
-		cylinders = disk->capacity / (heads * sectors);
-	}
-	geom[0] = heads;
-	geom[1] = sectors;
-	geom[2] = cylinders;
-	return (0);
-}
-
-/*
- * Free the passed in Scsi_Host memory structures prior to unloading the
- * module.
- */
-int
-ahc_linux_release(struct Scsi_Host * host)
-{
-	struct ahc_softc *ahc;
-	u_long l;
-
-	ahc_list_lock(&l);
-	if (host != NULL) {
-
-		/*
-		 * We should be able to just perform
-		 * the free directly, but check our
-		 * list for extra sanity.
-		 */
-		ahc = ahc_find_softc(*(struct ahc_softc **)host->hostdata);
-		if (ahc != NULL) {
-			u_long s;
-
-			ahc_lock(ahc, &s);
-			ahc_intr_enable(ahc, FALSE);
-			ahc_unlock(ahc, &s);
-			ahc_free(ahc);
-		}
-	}
-	ahc_list_unlock(&l);
-	return (0);
-}
-
 void
 ahc_platform_dump_card_state(struct ahc_softc *ahc)
 {
@@ -3031,8 +5073,57 @@
 	}
 }
 
-#if defined(MODULE) || LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-static Scsi_Host_Template driver_template = AIC7XXX;
-Scsi_Host_Template *aic7xxx_driver_template = &driver_template;
-#include "../scsi_module.c"
+static int __init
+ahc_linux_init(void)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+	return (ahc_linux_detect(&aic7xxx_driver_template) ? 0 : -ENODEV);
+#else
+	scsi_register_module(MODULE_SCSI_HA, &aic7xxx_driver_template);
+	if (aic7xxx_driver_template.present == 0) {
+		scsi_unregister_module(MODULE_SCSI_HA,
+				       &aic7xxx_driver_template);
+		return (-ENODEV);
+	}
+
+	return (0);
+#endif
+}
+
+static void __exit
+ahc_linux_exit(void)
+{
+	struct ahc_softc *ahc;
+	u_long l;
+
+	/*
+	 * Shutdown DV threads before going into the SCSI mid-layer.
+	 * This avoids situations where the mid-layer locks the entire
+	 * 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)
+	/*
+	 * In 2.4 we have to unregister from the PCI core _after_
+	 * unregistering from the scsi midlayer to avoid dangling
+	 * references.
+	 */
+	scsi_unregister_module(MODULE_SCSI_HA, &aic7xxx_driver_template);
+#endif
+#ifdef CONFIG_PCI
+	ahc_linux_pci_exit();
+#endif
+#ifdef CONFIG_EISA
+	ahc_linux_eisa_exit();
 #endif
+}
+
+module_init(ahc_linux_init);
+module_exit(ahc_linux_exit);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_osm.h linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_osm.h
--- linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_osm.h	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_osm.h	2003-06-26 21:43:17.000000000 +0000
@@ -18,9 +18,7 @@
  * along with this program; see the file COPYING.  If not, write to
  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  * 
- * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#82 $
- *
- * Copyright (c) 2000-2001 Adaptec Inc.
+ * Copyright (c) 2000-2003 Adaptec Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -55,7 +53,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#82 $
+ * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#150 $
  *
  */
 #ifndef _AIC7XXX_LINUX_H_
@@ -67,12 +65,11 @@
 #include <linux/delay.h>
 #include <linux/ioport.h>
 #include <linux/pci.h>
+#include <linux/smp_lock.h>
 #include <linux/version.h>
-#ifndef AHC_MODVERSION_FILE
-#define __NO_VERSION__
-#endif
 #include <linux/module.h>
 #include <asm/byteorder.h>
+#include <asm/io.h>
 
 #ifndef KERNEL_VERSION
 #define KERNEL_VERSION(x,y,z) (((x)<<16)+((y)<<8)+(z))
@@ -87,8 +84,9 @@
 #endif
 
 /* Core SCSI definitions */
-#include "../scsi.h"
-#include "../hosts.h"
+#define AIC_LIB_PREFIX ahc
+#include "scsi.h"
+#include "hosts.h"
 
 /* Name space conflict with BSD queue macros */
 #ifdef LIST_HEAD
@@ -98,6 +96,21 @@
 #include "cam.h"
 #include "queue.h"
 #include "scsi_message.h"
+#include "aiclib.h"
+
+/*********************************** Debugging ********************************/
+#ifdef CONFIG_AIC7XXX_DEBUG_ENABLE
+#ifdef CONFIG_AIC7XXX_DEBUG_MASK
+#define AHC_DEBUG 1
+#define AHC_DEBUG_OPTS CONFIG_AIC7XXX_DEBUG_MASK
+#else
+/*
+ * Compile in debugging code, but do not enable any printfs.
+ */
+#define AHC_DEBUG 1
+#endif
+/* No debugging code. */
+#endif
 
 /************************* Forward Declarations *******************************/
 struct ahc_softc;
@@ -137,9 +150,10 @@
 #endif /* BYTE_ORDER */
 
 /************************* Configuration Data *********************************/
-extern int aic7xxx_no_probe;
+extern u_int aic7xxx_no_probe;
+extern u_int aic7xxx_allow_memio;
 extern int aic7xxx_detect_complete;
-extern Scsi_Host_Template* aic7xxx_driver_template;
+extern Scsi_Host_Template aic7xxx_driver_template;
 
 /***************************** Bus Space/DMA **********************************/
 
@@ -240,176 +254,58 @@
  */
 #define ahc_dmamap_sync(ahc, dma_tag, dmamap, offset, len, op)
 
-/************************** SCSI Constants/Structures *************************/
-#define SCSI_REV_2 2
-#define	SCSI_STATUS_OK			0x00
-#define	SCSI_STATUS_CHECK_COND		0x02
-#define	SCSI_STATUS_COND_MET		0x04
-#define	SCSI_STATUS_BUSY		0x08
-#define SCSI_STATUS_INTERMED		0x10
-#define SCSI_STATUS_INTERMED_COND_MET	0x14
-#define SCSI_STATUS_RESERV_CONFLICT	0x18
-#define SCSI_STATUS_CMD_TERMINATED	0x22
-#define SCSI_STATUS_QUEUE_FULL		0x28
-
-/*
- * 6 byte request sense CDB format.
- */
-struct scsi_sense
-{
-	uint8_t opcode;
-	uint8_t byte2;
-	uint8_t unused[2];
-	uint8_t length;
-	uint8_t control;
-};
+/************************** Timer DataStructures ******************************/
+typedef struct timer_list ahc_timer_t;
 
-struct scsi_sense_data
-{
-	uint8_t	error_code;
-	uint8_t	segment;
-	uint8_t	flags;
-	uint8_t	info[4];
-	uint8_t	extra_len;
-	uint8_t	cmd_spec_info[4];
-	uint8_t add_sense_code;
-	uint8_t add_sense_code_qual;
-	uint8_t	fru;
-	uint8_t	sense_key_spec[3];
-	uint8_t	extra_bytes[14];
-};
+/********************************** Includes **********************************/
+#ifdef CONFIG_AIC7XXX_REG_PRETTY_PRINT
+#define AIC_DEBUG_REGISTERS 1
+#else
+#define AIC_DEBUG_REGISTERS 0
+#endif
+#include "aic7xxx.h"
 
-struct scsi_inquiry
-{ 
-	u_int8_t opcode;
-	u_int8_t byte2;
-#define	SI_EVPD 0x01
-	u_int8_t page_code;
-	u_int8_t reserved;
-	u_int8_t length;
-	u_int8_t control;
-};
+/***************************** Timer Facilities *******************************/
+#define ahc_timer_init init_timer
+#define ahc_timer_stop del_timer_sync
+typedef void ahc_linux_callback_t (u_long);  
+static __inline void ahc_timer_reset(ahc_timer_t *timer, int usec,
+				     ahc_callback_t *func, void *arg);
+static __inline void ahc_scb_timer_reset(struct scb *scb, u_int usec);
 
-struct scsi_inquiry_data
+static __inline void
+ahc_timer_reset(ahc_timer_t *timer, int usec, ahc_callback_t *func, void *arg)
 {
-	uint8_t device;
-#define	SID_TYPE(inq_data) ((inq_data)->device & 0x1f)
-#define	SID_QUAL(inq_data) (((inq_data)->device & 0xE0) >> 5)
-#define	SID_QUAL_LU_CONNECTED	0x00	/*
-					 * The specified peripheral device
-					 * type is currently connected to
-					 * logical unit.  If the target cannot
-					 * determine whether or not a physical
-					 * device is currently connected, it
-					 * shall also use this peripheral
-					 * qualifier when returning the INQUIRY
-					 * data.  This peripheral qualifier
-					 * does not mean that the device is
-					 * ready for access by the initiator.
-					 */
-#define	SID_QUAL_LU_OFFLINE	0x01	/*
-					 * The target is capable of supporting
-					 * the specified peripheral device type
-					 * on this logical unit; however, the
-					 * physical device is not currently
-					 * connected to this logical unit.
-					 */
-#define SID_QUAL_RSVD		0x02
-#define	SID_QUAL_BAD_LU		0x03	/*
-					 * The target is not capable of
-					 * supporting a physical device on
-					 * this logical unit. For this
-					 * peripheral qualifier the peripheral
-					 * device type shall be set to 1Fh to
-					 * provide compatibility with previous
-					 * versions of SCSI. All other
-					 * peripheral device type values are
-					 * reserved for this peripheral
-					 * qualifier.
-					 */
-#define	SID_QUAL_IS_VENDOR_UNIQUE(inq_data) ((SID_QUAL(inq_data) & 0x08) != 0)
-	uint8_t dev_qual2;
-#define	SID_QUAL2	0x7F
-#define	SID_IS_REMOVABLE(inq_data) (((inq_data)->dev_qual2 & 0x80) != 0)
-	uint8_t version;
-#define SID_ANSI_REV(inq_data) ((inq_data)->version & 0x07)
-#define		SCSI_REV_0		0
-#define		SCSI_REV_CCS		1
-#define		SCSI_REV_2		2
-#define		SCSI_REV_SPC		3
-#define		SCSI_REV_SPC2		4
-
-#define SID_ECMA	0x38
-#define SID_ISO		0xC0
-	uint8_t response_format;
-#define SID_AENC	0x80
-#define SID_TrmIOP	0x40
-	uint8_t additional_length;
-	uint8_t reserved[2];
-	uint8_t flags;
-#define	SID_SftRe	0x01
-#define	SID_CmdQue	0x02
-#define	SID_Linked	0x08
-#define	SID_Sync	0x10
-#define	SID_WBus16	0x20
-#define	SID_WBus32	0x40
-#define	SID_RelAdr	0x80
-#define SID_VENDOR_SIZE   8
-	char	 vendor[SID_VENDOR_SIZE];
-#define SID_PRODUCT_SIZE  16
-	char	 product[SID_PRODUCT_SIZE];
-#define SID_REVISION_SIZE 4
-	char	 revision[SID_REVISION_SIZE];
-	/*
-	 * The following fields were taken from SCSI Primary Commands - 2
-	 * (SPC-2) Revision 14, Dated 11 November 1999
-	 */
-#define	SID_VENDOR_SPECIFIC_0_SIZE	20
-	u_int8_t vendor_specific0[SID_VENDOR_SPECIFIC_0_SIZE];
-	/*
-	 * An extension of SCSI Parallel Specific Values
-	 */
-#define	SID_SPI_IUS		0x01
-#define	SID_SPI_QAS		0x02
-#define	SID_SPI_CLOCK_ST	0x00
-#define	SID_SPI_CLOCK_DT	0x04
-#define	SID_SPI_CLOCK_DT_ST	0x0C
-#define	SID_SPI_MASK		0x0F
-	uint8_t spi3data;
-	uint8_t reserved2;
-	/*
-	 * Version Descriptors, stored 2 byte values.
-	 */
-	uint8_t version1[2];
-	uint8_t version2[2];
-	uint8_t version3[2];
-	uint8_t version4[2];
-	uint8_t version5[2];
-	uint8_t version6[2];
-	uint8_t version7[2];
-	uint8_t version8[2];
-
-	uint8_t reserved3[22];
+	struct ahc_softc *ahc;
 
-#define	SID_VENDOR_SPECIFIC_1_SIZE	160
-	uint8_t vendor_specific1[SID_VENDOR_SPECIFIC_1_SIZE];
-};
-
-/********************************** Includes **********************************/
-/* Host template and function declarations referenced by the template. */
-#include "aic7xxx_host.h"
+	ahc = (struct ahc_softc *)arg;
+	del_timer(timer);
+	timer->data = (u_long)arg;
+	timer->expires = jiffies + (usec * HZ)/1000000;
+	timer->function = (ahc_linux_callback_t*)func;
+	add_timer(timer);
+}
 
-/* Core driver definitions */
-#include "aic7xxx.h"
+static __inline void
+ahc_scb_timer_reset(struct scb *scb, u_int usec)
+{
+	mod_timer(&scb->io_ctx->eh_timeout, jiffies + (usec * HZ)/1000000);
+}
 
-/* SMP support */
+/***************************** 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
 
-#define AIC7XXX_DRIVER_VERSION  "6.2.8"
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) || defined(SCSI_HAS_HOST_LOCK))
+#define AHC_SCSI_HAS_HOST_LOCK 1
+#else
+#define AHC_SCSI_HAS_HOST_LOCK 0
+#endif
+
+#define AIC7XXX_DRIVER_VERSION "6.2.36"
 
 /**************************** Front End Queues ********************************/
 /*
@@ -444,7 +340,7 @@
 /*
  * A per probed device structure used to deal with some error recovery
  * scenarios that the Linux mid-layer code just doesn't know how to
- * handle.  The structure allocated for a device only becomes persistant
+ * handle.  The structure allocated for a device only becomes persistent
  * after a successfully completed inquiry command to the target when
  * that inquiry data indicates a lun is present.
  */
@@ -456,8 +352,9 @@
 	AHC_DEV_ON_RUN_LIST	 = 0x08, /* Queued to be run later */
 	AHC_DEV_Q_BASIC		 = 0x10, /* Allow basic device queuing */
 	AHC_DEV_Q_TAGGED	 = 0x20, /* Allow full SCSI2 command queueing */
-	AHC_DEV_PERIODIC_OTAG	 = 0x40	 /* Send OTAG to prevent starvation */
-} ahc_dev_flags;
+	AHC_DEV_PERIODIC_OTAG	 = 0x40, /* Send OTAG to prevent starvation */
+	AHC_DEV_SLAVE_CONFIGURED = 0x80	 /* slave_configure() has been called */
+} ahc_linux_dev_flags;
 
 struct ahc_linux_target;
 struct ahc_linux_device {
@@ -500,7 +397,7 @@
 	u_int			tag_success_count;
 #define AHC_TAG_SUCCESS_INTERVAL 50
 
-	ahc_dev_flags		flags;
+	ahc_linux_dev_flags	flags;
 
 	/*
 	 * Per device timer.
@@ -540,16 +437,54 @@
 #define AHC_OTAG_THRESH	500
 
 	int			lun;
+	Scsi_Device	       *scsi_device;
 	struct			ahc_linux_target *target;
 };
 
+typedef enum {
+	AHC_DV_REQUIRED		 = 0x01,
+	AHC_INQ_VALID		 = 0x02,
+	AHC_BASIC_DV		 = 0x04,
+	AHC_ENHANCED_DV		 = 0x08
+} ahc_linux_targ_flags;
+
+/* DV States */
+typedef enum {
+	AHC_DV_STATE_EXIT = 0,
+	AHC_DV_STATE_INQ_SHORT_ASYNC,
+	AHC_DV_STATE_INQ_ASYNC,
+	AHC_DV_STATE_INQ_ASYNC_VERIFY,
+	AHC_DV_STATE_TUR,
+	AHC_DV_STATE_REBD,
+	AHC_DV_STATE_INQ_VERIFY,
+	AHC_DV_STATE_WEB,
+	AHC_DV_STATE_REB,
+	AHC_DV_STATE_SU,
+	AHC_DV_STATE_BUSY
+} ahc_dv_state;
+
 struct ahc_linux_target {
-	struct	ahc_linux_device *devices[AHC_NUM_LUNS];
-	int	channel;
-	int	target;
-	int	refcount;
-	struct	ahc_transinfo last_tinfo;
-	struct	ahc_softc *ahc;
+	struct ahc_linux_device	 *devices[AHC_NUM_LUNS];
+	int			  channel;
+	int			  target;
+	int			  refcount;
+	struct ahc_transinfo	  last_tinfo;
+	struct ahc_softc	 *ahc;
+	ahc_linux_targ_flags	  flags;
+	struct scsi_inquiry_data *inq_data;
+	/*
+	 * The next "fallback" period to use for narrow/wide transfers.
+	 */
+	uint8_t			  dv_next_narrow_period;
+	uint8_t			  dv_next_wide_period;
+	uint8_t			  dv_max_width;
+	uint8_t			  dv_max_ppr_options;
+	uint8_t			  dv_last_ppr_options;
+	u_int			  dv_echo_size;
+	ahc_dv_state		  dv_state;
+	u_int			  dv_state_retry;
+	char			 *dv_buffer;
+	char			 *dv_buffer1;
 };
 
 /********************* Definitions Required by the Core ***********************/
@@ -559,11 +494,26 @@
  * manner and are allocated below 4GB, the number of S/G segments is
  * unrestricted.
  */
-#define        AHC_NSEG 128
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+/*
+ * We dynamically adjust the number of segments in pre-2.5 kernels to
+ * avoid fragmentation issues in the SCSI mid-layer's private memory
+ * allocator.  See aic7xxx_osm.c ahc_linux_size_nseg() for details.
+ */
+extern u_int ahc_linux_nseg;
+#define	AHC_NSEG ahc_linux_nseg
+#define	AHC_LINUX_MIN_NSEG 64
+#else
+#define	AHC_NSEG 128
+#endif
 
 /*
  * Per-SCB OSM storage.
  */
+typedef enum {
+	AHC_UP_EH_SEMAPHORE = 0x1
+} ahc_linux_scb_flags;
+
 struct scb_platform_data {
 	struct ahc_linux_device	*dev;
 	bus_addr_t		 buf_busaddr;
@@ -571,6 +521,8 @@
 #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;
 };
 
 /*
@@ -579,7 +531,16 @@
  * alignment restrictions of the various platforms supported by
  * this driver.
  */
+typedef enum {
+	AHC_DV_WAIT_SIMQ_EMPTY	 = 0x01,
+	AHC_DV_WAIT_SIMQ_RELEASE = 0x02,
+	AHC_DV_ACTIVE		 = 0x04,
+	AHC_DV_SHUTDOWN		 = 0x08,
+	AHC_RUN_CMPLT_Q_TIMER	 = 0x10
+} ahc_linux_softc_flags;
+
 TAILQ_HEAD(ahc_completeq, ahc_cmd);
+
 struct ahc_platform_data {
 	/*
 	 * Fields accessed from interrupt context.
@@ -588,21 +549,27 @@
 	TAILQ_HEAD(, ahc_linux_device) device_runq;
 	struct ahc_completeq	 completeq;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
 	spinlock_t		 spin_lock;
-#endif
 #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;
 	struct timer_list	 reset_timer;
 	struct semaphore	 eh_sem;
+	struct semaphore	 dv_sem;
+	struct semaphore	 dv_cmd_sem;	/* XXX This needs to be in
+						 * the target struct
+						 */
+	struct scsi_device	*dv_scsi_dev;
 	struct Scsi_Host        *host;		/* pointer to scsi host */
 #define AHC_LINUX_NOIRQ	((uint32_t)~0)
 	uint32_t		 irq;		/* IRQ for this adapter */
 	uint32_t		 bios_address;
 	uint32_t		 mem_busaddr;	/* Mem Base Addr */
 	bus_addr_t		 hw_dma_mask;
+	ahc_linux_softc_flags	 flags;
 };
 
 /************************** OS Utility Wrappers *******************************/
@@ -635,7 +602,6 @@
 
 static __inline uint8_t ahc_inb(struct ahc_softc * ahc, long port);
 static __inline void ahc_outb(struct ahc_softc * ahc, long port, uint8_t val);
-static __inline void ahc_outb_reset(struct ahc_softc * ahc, long port, uint8_t val);
 static __inline void ahc_outsb(struct ahc_softc * ahc, long port,
 			       uint8_t *, int count);
 static __inline void ahc_insb(struct ahc_softc * ahc, long port,
@@ -665,22 +631,6 @@
 #ifdef MMAPIO
 	if (ahc->tag == BUS_SPACE_MEMIO) {
 		writeb(val, ahc->bsh.maddr + port);
-		readb(ahc->bsh.maddr + HCNTRL); /* flush PCI posting */
-	} else {
-		outb(val, ahc->bsh.ioport + port);
-	}
-#else
-	outb(val, ahc->bsh.ioport + port);
-#endif
-	mb();
-}
-
-static __inline void
-ahc_outb_reset(struct ahc_softc * ahc, long port, uint8_t val)
-{
-#ifdef MMAPIO
-	if (ahc->tag == BUS_SPACE_MEMIO) {
-		writeb(val, ahc->bsh.maddr + port);
 	} else {
 		outb(val, ahc->bsh.ioport + port);
 	}
@@ -741,6 +691,12 @@
 static __inline void ahc_lock(struct ahc_softc *, unsigned long *flags);
 static __inline void ahc_unlock(struct ahc_softc *, unsigned long *flags);
 
+/* Lock acquisition and release of the above lock in midlayer entry points. */
+static __inline void ahc_midlayer_entrypoint_lock(struct ahc_softc *,
+						  unsigned long *flags);
+static __inline void ahc_midlayer_entrypoint_unlock(struct ahc_softc *,
+						    unsigned long *flags);
+
 /* Lock held during command compeletion to the upper layer */
 static __inline void ahc_done_lockinit(struct ahc_softc *);
 static __inline void ahc_done_lock(struct ahc_softc *, unsigned long *flags);
@@ -752,7 +708,6 @@
 static __inline void ahc_list_lock(unsigned long *flags);
 static __inline void ahc_list_unlock(unsigned long *flags);
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
 static __inline void
 ahc_lockinit(struct ahc_softc *ahc)
 {
@@ -762,7 +717,6 @@
 static __inline void
 ahc_lock(struct ahc_softc *ahc, unsigned long *flags)
 {
-	*flags = 0;
 	spin_lock_irqsave(&ahc->platform_data->spin_lock, *flags);
 }
 
@@ -773,102 +727,73 @@
 }
 
 static __inline void
-ahc_done_lockinit(struct ahc_softc *ahc)
-{
-	/* We don't own the iorequest lock, so we don't initialize it. */
-}
-
-static __inline void
-ahc_done_lock(struct ahc_softc *ahc, unsigned long *flags)
-{
-	*flags = 0;
-	spin_lock_irqsave(&io_request_lock, *flags);
-}
-
-static __inline void
-ahc_done_unlock(struct ahc_softc *ahc, unsigned long *flags)
-{
-	spin_unlock_irqrestore(&io_request_lock, *flags);
-}
-
-static __inline void
-ahc_list_lockinit()
-{
-	spin_lock_init(&ahc_list_spinlock);
-}
-
-static __inline void
-ahc_list_lock(unsigned long *flags)
-{
-	*flags = 0;
-	spin_lock_irqsave(&ahc_list_spinlock, *flags);
-}
-
-static __inline void
-ahc_list_unlock(unsigned long *flags)
+ahc_midlayer_entrypoint_lock(struct ahc_softc *ahc, unsigned long *flags)
 {
-	spin_unlock_irqrestore(&ahc_list_spinlock, *flags);
-}
-
-#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0) */
-
-ahc_lockinit(struct ahc_softc *ahc)
-{
-}
-
-static __inline void
-ahc_lock(struct ahc_softc *ahc, unsigned long *flags)
-{
-	*flags = 0;
-	save_flags(*flags);
-	cli();
+	/*
+	 * In 2.5.X and some 2.4.X versions, the midlayer takes our
+	 * lock just before calling us, so we avoid locking again.
+	 * For other kernel versions, the io_request_lock is taken
+	 * just before our entry point is called.  In this case, we
+	 * trade the io_request_lock for our per-softc lock.
+	 */
+#if AHC_SCSI_HAS_HOST_LOCK == 0
+	spin_unlock(&io_request_lock);
+	spin_lock(&ahc->platform_data->spin_lock);
+#endif
 }
 
 static __inline void
-ahc_unlock(struct ahc_softc *ahc, unsigned long *flags)
+ahc_midlayer_entrypoint_unlock(struct ahc_softc *ahc, unsigned long *flags)
 {
-	restore_flags(*flags);
+#if AHC_SCSI_HAS_HOST_LOCK == 0
+	spin_unlock(&ahc->platform_data->spin_lock);
+	spin_lock(&io_request_lock);
+#endif
 }
 
 static __inline void
 ahc_done_lockinit(struct ahc_softc *ahc)
 {
+	/*
+	 * In 2.5.X, our own lock is held during completions.
+	 * In previous versions, the io_request_lock is used.
+	 * In either case, we can't initialize this lock again.
+	 */
 }
 
 static __inline void
 ahc_done_lock(struct ahc_softc *ahc, unsigned long *flags)
 {
-	/*
-	 * The done lock is always held while
-	 * the ahc lock is held so blocking
-	 * interrupts again would have no effect.
-	 */
+#if AHC_SCSI_HAS_HOST_LOCK == 0
+	spin_lock_irqsave(&io_request_lock, *flags);
+#endif
 }
 
 static __inline void
 ahc_done_unlock(struct ahc_softc *ahc, unsigned long *flags)
 {
+#if AHC_SCSI_HAS_HOST_LOCK == 0
+	spin_unlock_irqrestore(&io_request_lock, *flags);
+#endif
 }
 
 static __inline void
-ahc_list_lockinit()
+ahc_list_lockinit(void)
 {
+	spin_lock_init(&ahc_list_spinlock);
 }
 
 static __inline void
 ahc_list_lock(unsigned long *flags)
 {
-	*flags = 0;
-	save_flags(*flags);
-	cli();
+	spin_lock_irqsave(&ahc_list_spinlock, *flags);
 }
 
 static __inline void
 ahc_list_unlock(unsigned long *flags)
 {
-	restore_flags(*flags);
+	spin_unlock_irqrestore(&ahc_list_spinlock, *flags);
 }
-#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0) */
 
 /******************************* PCI Definitions ******************************/
 /*
@@ -889,6 +814,7 @@
 #define PCIM_CMD_BUSMASTEREN	0x0004
 #define PCIM_CMD_MWRICEN	0x0010
 #define PCIM_CMD_PERRESPEN	0x0040
+#define	PCIM_CMD_SERRESPEN	0x0100
 #define PCIR_STATUS		0x06
 #define PCIR_REVID		0x08
 #define PCIR_PROGIF		0x09
@@ -918,26 +844,28 @@
 	AHC_POWER_STATE_D3
 } ahc_power_state;
 
-void ahc_power_state_change(struct ahc_softc *ahc,
-			    ahc_power_state new_state);
 /**************************** VL/EISA Routines ********************************/
-int			 aic7770_linux_probe(Scsi_Host_Template *);
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) \
+  && (defined(__i386__) || defined(__alpha__)) \
+  && (!defined(CONFIG_EISA)))
+#define CONFIG_EISA
+#endif
+
+#ifdef CONFIG_EISA
+extern uint32_t aic7xxx_probe_eisa_vl;
+void			 ahc_linux_eisa_init(void);
+void			 ahc_linux_eisa_exit(void);
 int			 aic7770_map_registers(struct ahc_softc *ahc,
 					       u_int port);
 int			 aic7770_map_int(struct ahc_softc *ahc, u_int irq);
-
-/******************************* PCI Routines *********************************/
-/*
- * We need to use the bios32.h routines if we are kernel version 2.1.92 or less.
- */
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,1,92)
-#if defined(__sparc_v9__) || defined(__powerpc__)
-#error "PPC and Sparc platforms are only support under 2.1.92 and above"
-#endif
-#include <linux/bios32.h>
 #endif
 
-int			 ahc_linux_pci_probe(Scsi_Host_Template *);
+/******************************* PCI Routines *********************************/
+#ifdef CONFIG_PCI
+void			 ahc_power_state_change(struct ahc_softc *ahc,
+						ahc_power_state new_state);
+int			 ahc_linux_pci_init(void);
+void			 ahc_linux_pci_exit(void);
 int			 ahc_pci_map_registers(struct ahc_softc *ahc);
 int			 ahc_pci_map_int(struct ahc_softc *ahc);
 
@@ -1017,6 +945,7 @@
 {
 	return (pci->bus->number);
 }
+#endif
 
 static __inline void ahc_flush_device_writes(struct ahc_softc *);
 static __inline void
@@ -1036,38 +965,104 @@
 #define pci_unmap_single(pdev, buffer, buflen, direction)
 #endif
 
-/*********************** Transaction Access Wrappers **************************/
+#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);
+#else
+int	ahc_linux_proc_info(struct Scsi_Host *, char *, char **,
+			    off_t, int, int);
+#endif
+
+/*************************** Domain Validation ********************************/
+#define AHC_DV_CMD(cmd) ((cmd)->scsi_done == ahc_linux_dv_complete)
+#define AHC_DV_SIMQ_FROZEN(ahc)					\
+	((((ahc)->platform_data->flags & AHC_DV_ACTIVE) != 0)	\
+	 && (ahc)->platform_data->qfrozen == 1)
+
+/*********************** Transaction Access Wrappers *************************/
+static __inline void ahc_cmd_set_transaction_status(Scsi_Cmnd *, uint32_t);
 static __inline void ahc_set_transaction_status(struct scb *, uint32_t);
+static __inline void ahc_cmd_set_scsi_status(Scsi_Cmnd *, uint32_t);
+static __inline void ahc_set_scsi_status(struct scb *, uint32_t);
+static __inline uint32_t ahc_cmd_get_transaction_status(Scsi_Cmnd *cmd);
+static __inline uint32_t ahc_get_transaction_status(struct scb *);
+static __inline uint32_t ahc_cmd_get_scsi_status(Scsi_Cmnd *cmd);
+static __inline uint32_t ahc_get_scsi_status(struct scb *);
+static __inline void ahc_set_transaction_tag(struct scb *, int, u_int);
+static __inline u_long ahc_get_transfer_length(struct scb *);
+static __inline int ahc_get_transfer_dir(struct scb *);
+static __inline void ahc_set_residual(struct scb *, u_long);
+static __inline void ahc_set_sense_residual(struct scb *scb, u_long resid);
+static __inline u_long ahc_get_residual(struct scb *);
+static __inline u_long ahc_get_sense_residual(struct scb *);
+static __inline int ahc_perform_autosense(struct scb *);
+static __inline uint32_t ahc_get_sense_bufsize(struct ahc_softc *,
+					       struct scb *);
+static __inline void ahc_notify_xfer_settings_change(struct ahc_softc *,
+						     struct ahc_devinfo *);
+static __inline void ahc_platform_scb_free(struct ahc_softc *ahc,
+					   struct scb *scb);
+static __inline void ahc_freeze_scb(struct scb *scb);
+
+static __inline
+void ahc_cmd_set_transaction_status(Scsi_Cmnd *cmd, uint32_t status)
+{
+	cmd->result &= ~(CAM_STATUS_MASK << 16);
+	cmd->result |= status << 16;
+}
+
 static __inline
 void ahc_set_transaction_status(struct scb *scb, uint32_t status)
 {
-	scb->io_ctx->result &= ~(CAM_STATUS_MASK << 16);
-	scb->io_ctx->result |= status << 16;
+	ahc_cmd_set_transaction_status(scb->io_ctx,status);
+}
+
+static __inline
+void ahc_cmd_set_scsi_status(Scsi_Cmnd *cmd, uint32_t status)
+{
+	cmd->result &= ~0xFFFF;
+	cmd->result |= status;
 }
 
-static __inline void ahc_set_scsi_status(struct scb *, uint32_t);
 static __inline
 void ahc_set_scsi_status(struct scb *scb, uint32_t status)
 {
-	scb->io_ctx->result &= ~0xFFFF;
-	scb->io_ctx->result |= status;
+	ahc_cmd_set_scsi_status(scb->io_ctx, status);
+}
+
+static __inline
+uint32_t ahc_cmd_get_transaction_status(Scsi_Cmnd *cmd)
+{
+	return ((cmd->result >> 16) & CAM_STATUS_MASK);
 }
 
-static __inline uint32_t ahc_get_transaction_status(struct scb *);
 static __inline
 uint32_t ahc_get_transaction_status(struct scb *scb)
 {
-	return ((scb->io_ctx->result >> 16) & CAM_STATUS_MASK);
+	return (ahc_cmd_get_transaction_status(scb->io_ctx));
+}
+
+static __inline
+uint32_t ahc_cmd_get_scsi_status(Scsi_Cmnd *cmd)
+{
+	return (cmd->result & 0xFFFF);
 }
 
-static __inline uint32_t ahc_get_scsi_status(struct scb *);
 static __inline
 uint32_t ahc_get_scsi_status(struct scb *scb)
 {
-	return (scb->io_ctx->result & 0xFFFF);
+	return (ahc_cmd_get_scsi_status(scb->io_ctx));
 }
 
-static __inline void ahc_set_transaction_tag(struct scb *, int, u_int);
 static __inline
 void ahc_set_transaction_tag(struct scb *scb, int enabled, u_int type)
 {
@@ -1077,14 +1072,12 @@
 	 */
 }
 
-static __inline u_long ahc_get_transfer_length(struct scb *);
 static __inline
 u_long ahc_get_transfer_length(struct scb *scb)
 {
 	return (scb->platform_data->xfer_len);
 }
 
-static __inline int ahc_get_transfer_dir(struct scb *);
 static __inline
 int ahc_get_transfer_dir(struct scb *scb)
 {
@@ -1109,7 +1102,6 @@
 #endif
 }
 
-static __inline void ahc_set_residual(struct scb *, u_long);
 static __inline
 void ahc_set_residual(struct scb *scb, u_long resid)
 {
@@ -1120,14 +1112,12 @@
 #endif
 }
 
-static __inline void ahc_set_sense_residual(struct scb *, u_long);
 static __inline
 void ahc_set_sense_residual(struct scb *scb, u_long resid)
 {
-	/* This can't be reported in Linux */
+	scb->platform_data->sense_resid = resid;
 }
 
-static __inline u_long ahc_get_residual(struct scb *);
 static __inline
 u_long ahc_get_residual(struct scb *scb)
 {
@@ -1138,7 +1128,12 @@
 #endif
 }
 
-static __inline int ahc_perform_autosense(struct scb *);
+static __inline
+u_long ahc_get_sense_residual(struct scb *scb)
+{
+	return (scb->platform_data->sense_resid);
+}
+
 static __inline
 int ahc_perform_autosense(struct scb *scb)
 {
@@ -1156,8 +1151,6 @@
 	return (sizeof(struct scsi_sense_data));
 }
 
-static __inline void ahc_notify_xfer_settings_change(struct ahc_softc *,
-						     struct ahc_devinfo *);
 static __inline void
 ahc_notify_xfer_settings_change(struct ahc_softc *ahc,
 				struct ahc_devinfo *devinfo)
@@ -1165,8 +1158,6 @@
 	/* Nothing to do here for linux */
 }
 
-static __inline void ahc_platform_scb_free(struct ahc_softc *ahc,
-					   struct scb *scb);
 static __inline void
 ahc_platform_scb_free(struct ahc_softc *ahc, struct scb *scb)
 {
@@ -1176,11 +1167,14 @@
 int	ahc_platform_alloc(struct ahc_softc *ahc, void *platform_arg);
 void	ahc_platform_free(struct ahc_softc *ahc);
 void	ahc_platform_freeze_devq(struct ahc_softc *ahc, struct scb *scb);
-static __inline void	ahc_freeze_scb(struct scb *scb);
+
 static __inline void
 ahc_freeze_scb(struct scb *scb)
 {
-	/* Noting to do here for linux */
+	if ((scb->io_ctx->result & (CAM_DEV_QFRZN << 16)) == 0) {
+                scb->io_ctx->result |= CAM_DEV_QFRZN << 16;
+                scb->platform_data->dev->qfrozen++;
+        }
 }
 
 void	ahc_platform_set_tags(struct ahc_softc *ahc,
@@ -1188,7 +1182,8 @@
 int	ahc_platform_abort_scbs(struct ahc_softc *ahc, int target,
 				char channel, int lun, u_int tag,
 				role_t role, uint32_t status);
-void	ahc_linux_isr(int irq, void *dev_id, struct pt_regs * regs);
+irqreturn_t
+	ahc_linux_isr(int irq, void *dev_id, struct pt_regs * regs);
 void	ahc_platform_flushwork(struct ahc_softc *ahc);
 int	ahc_softc_comp(struct ahc_softc *, struct ahc_softc *);
 void	ahc_done(struct ahc_softc*, struct scb*);
@@ -1203,5 +1198,5 @@
 #define AHC_PCI_CONFIG 0
 #endif
 #define bootverbose aic7xxx_verbose
-extern int aic7xxx_verbose;
+extern u_int aic7xxx_verbose;
 #endif /* _AIC7XXX_LINUX_H_ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
--- linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c	2002-08-03 00:39:44.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c	2003-06-26 21:43:16.000000000 +0000
@@ -36,7 +36,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#32 $
+ * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#46 $
  */
 
 #include "aic7xxx_osm.h"
@@ -93,7 +93,7 @@
 	 * list for extra sanity.
 	 */
 	ahc_list_lock(&l);
-	ahc = ahc_find_softc((struct ahc_softc *)pdev->driver_data);
+	ahc = ahc_find_softc((struct ahc_softc *)pci_get_drvdata(pdev));
 	if (ahc != NULL) {
 		u_long s;
 
@@ -110,6 +110,7 @@
 ahc_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
 	char		 buf[80];
+	bus_addr_t	 mask_39bit;
 	struct		 ahc_softc *ahc;
 	ahc_dev_softc_t	 pci;
 	struct		 ahc_pci_identity *entry;
@@ -160,19 +161,15 @@
 	}
 	pci_set_master(pdev);
 
+	mask_39bit = (bus_addr_t)0x7FFFFFFFFFULL;
 	if (sizeof(bus_addr_t) > 4
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,3)
 	 && ahc_linux_get_memsize() > 0x80000000
-	 && pci_set_dma_mask(pdev, 0x7FFFFFFFFFULL) == 0) {
-#else
-	 && ahc_linux_get_memsize() > 0x80000000) {
-
-		ahc->dev_softc->dma_mask = 
-		    (bus_addr_t)(0x7FFFFFFFFFULL & (bus_addr_t)~0);
-#endif
+	 && ahc_pci_set_dma_mask(pdev, mask_39bit) == 0) {
 		ahc->flags |= AHC_39BIT_ADDRESSING;
-		ahc->platform_data->hw_dma_mask =
-		    (bus_addr_t)(0x7FFFFFFFFFULL & (bus_addr_t)~0);
+		ahc->platform_data->hw_dma_mask = mask_39bit;
+	} else {
+		ahc_pci_set_dma_mask(pdev, 0xFFFFFFFF);
+		ahc->platform_data->hw_dma_mask = 0xFFFFFFFF;
 	}
 #endif
 	ahc->dev_softc = pci;
@@ -183,14 +180,21 @@
 	}
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	pci_set_drvdata(pdev, ahc);
-	if (aic7xxx_detect_complete)
-		ahc_linux_register_host(ahc, aic7xxx_driver_template);
+	if (aic7xxx_detect_complete) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+		ahc_linux_register_host(ahc, &aic7xxx_driver_template);
+#else
+		printf("aic7xxx: ignoring PCI device found after "
+		       "initialization\n");
+		return (-ENODEV);
+#endif
+	}
 #endif
 	return (0);
 }
 
 int
-ahc_linux_pci_probe(Scsi_Host_Template *template)
+ahc_linux_pci_init(void)
 {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	return (pci_module_init(&aic7xxx_pci_driver));
@@ -219,9 +223,18 @@
 #endif
 }
 
+void
+ahc_linux_pci_exit(void)
+{
+	pci_unregister_driver(&aic7xxx_pci_driver);
+}
+
 static int
 ahc_linux_pci_reserve_io_region(struct ahc_softc *ahc, u_long *base)
 {
+	if (aic7xxx_allow_memio == 0)
+		return (ENOMEM);
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 	*base = pci_resource_start(ahc->dev_softc, 0);
 #else
@@ -233,8 +246,7 @@
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
 	if (check_region(*base, 256) != 0)
 		return (ENOMEM);
-	else
-		request_region(*base, 256, "aic7xxx");
+	request_region(*base, 256, "aic7xxx");
 #else
 	if (request_region(*base, 256, "aic7xxx") == 0)
 		return (ENOMEM);
@@ -314,10 +326,10 @@
 		 * Do a quick test to see if memory mapped
 		 * I/O is functioning correctly.
 		 */
-		if (ahc_inb(ahc, HCNTRL) == 0xFF) {
+		if (ahc_pci_test_register_access(ahc) != 0) {
 
 			printf("aic7xxx: PCI Device %d:%d:%d "
-			       "failed memory mapped test\n",
+			       "failed memory mapped test.  Using PIO.\n",
 			       ahc_get_pci_bus(ahc->dev_softc),
 			       ahc_get_pci_slot(ahc->dev_softc),
 			       ahc_get_pci_function(ahc->dev_softc));
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_pci.c linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_pci.c
--- linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_pci.c	2002-11-28 23:53:14.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_pci.c	2003-06-26 21:43:11.000000000 +0000
@@ -39,9 +39,9 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#46 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#69 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx_pci.c,v 1.2.2.14 2002/04/29 19:36:31 gibbs Exp $
+ * $FreeBSD$
  */
 
 #ifdef __linux__
@@ -76,7 +76,7 @@
 #define ID_9005_SISL_MASK		0x000FFFFF00000000ull
 #define ID_9005_SISL_ID			0x0005900500000000ull
 #define ID_AIC7850			0x5078900400000000ull
-#define ID_AHA_2902_04_10_15_20_30C	0x5078900478509004ull
+#define ID_AHA_2902_04_10_15_20C_30C	0x5078900478509004ull
 #define ID_AIC7855			0x5578900400000000ull
 #define ID_AIC7859			0x3860900400000000ull
 #define ID_AHA_2930CU			0x3860900438699004ull
@@ -245,9 +245,9 @@
 {
 	/* aic7850 based controllers */
 	{
-		ID_AHA_2902_04_10_15_20_30C,
+		ID_AHA_2902_04_10_15_20C_30C,
 		ID_ALL_MASK,
-		"Adaptec 2902/04/10/15/20/30C SCSI adapter",
+		"Adaptec 2902/04/10/15/20C/30C SCSI adapter",
 		ahc_aic785X_setup
 	},
 	/* aic7860 based controllers */
@@ -641,6 +641,7 @@
 #define AHC_494X_SLOT_CHANNEL_D	7
 
 #define	DEVCONFIG		0x40
+#define		PCIERRGENDIS	0x80000000ul
 #define		SCBSIZE32	0x00010000ul	/* aic789X only */
 #define		REXTVALID	0x00001000ul	/* ultra cards only */
 #define		MPORTMODE	0x00000400ul	/* aic7870+ only */
@@ -660,6 +661,14 @@
 #define		CACHESIZE	0x0000003ful	/* only 5 bits */
 #define		LATTIME		0x0000ff00ul
 
+/* PCI STATUS definitions */
+#define	DPE	0x80
+#define SSE	0x40
+#define	RMA	0x20
+#define	RTA	0x10
+#define STA	0x08
+#define DPR	0x01
+
 static int ahc_9005_subdevinfo_valid(uint16_t vendor, uint16_t device,
 				     uint16_t subvendor, uint16_t subdevice);
 static int ahc_ext_scbram_present(struct ahc_softc *ahc);
@@ -687,8 +696,12 @@
 static void aic785X_cable_detect(struct ahc_softc *ahc, int *internal50_present,
 				 int *externalcable_present,
 				 int *eeprom_present);
-static void write_brdctl(struct ahc_softc *ahc, uint8_t value);
+static void    write_brdctl(struct ahc_softc *ahc, uint8_t value);
 static uint8_t read_brdctl(struct ahc_softc *ahc);
+static void ahc_pci_intr(struct ahc_softc *ahc);
+static int  ahc_pci_chip_init(struct ahc_softc *ahc);
+static int  ahc_pci_suspend(struct ahc_softc *ahc);
+static int  ahc_pci_resume(struct ahc_softc *ahc);
 
 static int
 ahc_9005_subdevinfo_valid(uint16_t device, uint16_t vendor,
@@ -739,10 +752,7 @@
 	device = ahc_pci_read_config(pci, PCIR_DEVICE, /*bytes*/2);
 	subvendor = ahc_pci_read_config(pci, PCIR_SUBVEND_0, /*bytes*/2);
 	subdevice = ahc_pci_read_config(pci, PCIR_SUBDEV_0, /*bytes*/2);
-	full_id = ahc_compose_id(device,
-				 vendor,
-				 subdevice,
-				 subvendor);
+	full_id = ahc_compose_id(device, vendor, subdevice, subvendor);
 
 	/*
 	 * If the second function is not hooked up, ignore it.
@@ -771,18 +781,17 @@
 int
 ahc_pci_config(struct ahc_softc *ahc, struct ahc_pci_identity *entry)
 {
-	struct scb_data *shared_scb_data;
-	u_long		 l;
-	u_long		 s;
-	u_int		 command;
-	u_int		 our_id = 0;
-	u_int		 sxfrctl1;
-	u_int		 scsiseq;
-	u_int		 dscommand0;
-	int		 error;
-	uint8_t		 sblkctl;
+	u_long	 l;
+	u_int	 command;
+	u_int	 our_id;
+	u_int	 sxfrctl1;
+	u_int	 scsiseq;
+	u_int	 dscommand0;
+	uint32_t devconfig;
+	int	 error;
+	uint8_t	 sblkctl;
 
-	shared_scb_data = NULL;
+	our_id = 0;
 	error = entry->setup(ahc);
 	if (error != 0)
 		return (error);
@@ -803,6 +812,8 @@
 	 */
 	ahc_intr_enable(ahc, FALSE);
 
+	devconfig = ahc_pci_read_config(ahc->dev_softc, DEVCONFIG, /*bytes*/4);
+
 	/*
 	 * If we need to support high memory, enable dual
 	 * address cycles.  This bit must be set to enable
@@ -810,22 +821,23 @@
 	 * 64bit bus (PCI64BIT set in devconfig).
 	 */
 	if ((ahc->flags & AHC_39BIT_ADDRESSING) != 0) {
-		uint32_t devconfig;
 
 		if (bootverbose)
 			printf("%s: Enabling 39Bit Addressing\n",
 			       ahc_name(ahc));
-		devconfig = ahc_pci_read_config(ahc->dev_softc,
-						DEVCONFIG, /*bytes*/4);
 		devconfig |= DACEN;
-		ahc_pci_write_config(ahc->dev_softc, DEVCONFIG,
-				     devconfig, /*bytes*/4);
 	}
 	
+	/* Ensure that pci error generation, a test feature, is disabled. */
+	devconfig |= PCIERRGENDIS;
+
+	ahc_pci_write_config(ahc->dev_softc, DEVCONFIG, devconfig, /*bytes*/4);
+
 	/* Ensure busmastering is enabled */
-	command = ahc_pci_read_config(ahc->dev_softc, PCIR_COMMAND, /*bytes*/1);
+	command = ahc_pci_read_config(ahc->dev_softc, PCIR_COMMAND, /*bytes*/2);
 	command |= PCIM_CMD_BUSMASTEREN;
-	ahc_pci_write_config(ahc->dev_softc, PCIR_COMMAND, command, /*bytes*/1);
+
+	ahc_pci_write_config(ahc->dev_softc, PCIR_COMMAND, command, /*bytes*/2);
 
 	/* On all PCI adapters, we allow SCB paging */
 	ahc->flags |= AHC_PAGESCBS;
@@ -834,7 +846,21 @@
 	if (error != 0)
 		return (error);
 
+	/*
+	 * Disable PCI parity error checking.  Users typically
+	 * do this to work around broken PCI chipsets that get
+	 * the parity timing wrong and thus generate lots of spurious
+	 * errors.  The chip only allows us to disable *all* parity
+	 * error reporting when doing this, so CIO bus, scb ram, and
+	 * scratch ram parity errors will be ignored too.
+	 */
+	if ((ahc->flags & AHC_DISABLE_PCI_PERR) != 0)
+		ahc->seqctl |= FAILDIS;
+
 	ahc->bus_intr = ahc_pci_intr;
+	ahc->bus_chip_init = ahc_pci_chip_init;
+	ahc->bus_suspend = ahc_pci_suspend;
+	ahc->bus_resume = ahc_pci_resume;
 
 	/* Remeber how the card was setup in case there is no SEEPROM */
 	if ((ahc_inb(ahc, HCNTRL) & POWRDN) == 0) {
@@ -851,7 +877,7 @@
 		scsiseq = 0;
 	}
 
-	error = ahc_reset(ahc);
+	error = ahc_reset(ahc, /*reinit*/FALSE);
 	if (error != 0)
 		return (ENXIO);
 
@@ -941,7 +967,8 @@
 		 * a SEEPROM.
 		 */
 		/* See if someone else set us up already */
-		if (scsiseq != 0) {
+		if ((ahc->flags & AHC_NO_BIOS_INIT) == 0
+		 && scsiseq != 0) {
 			printf("%s: Using left over BIOS settings\n",
 				ahc_name(ahc));
 			ahc->flags &= ~AHC_USEDEFAULTS;
@@ -973,6 +1000,35 @@
 	if ((sxfrctl1 & STPWEN) != 0)
 		ahc->flags |= AHC_TERM_ENB_A;
 
+	/*
+	 * Save chip register configuration data for chip resets
+	 * that occur during runtime and resume events.
+	 */
+	ahc->bus_softc.pci_softc.devconfig =
+	    ahc_pci_read_config(ahc->dev_softc, DEVCONFIG, /*bytes*/4);
+	ahc->bus_softc.pci_softc.command =
+	    ahc_pci_read_config(ahc->dev_softc, PCIR_COMMAND, /*bytes*/1);
+	ahc->bus_softc.pci_softc.csize_lattime =
+	    ahc_pci_read_config(ahc->dev_softc, CSIZE_LATTIME, /*bytes*/1);
+	ahc->bus_softc.pci_softc.dscommand0 = ahc_inb(ahc, DSCOMMAND0);
+	ahc->bus_softc.pci_softc.dspcistatus = ahc_inb(ahc, DSPCISTATUS);
+	if ((ahc->features & AHC_DT) != 0) {
+		u_int sfunct;
+
+		sfunct = ahc_inb(ahc, SFUNCT) & ~ALT_MODE;
+		ahc_outb(ahc, SFUNCT, sfunct | ALT_MODE);
+		ahc->bus_softc.pci_softc.optionmode = ahc_inb(ahc, OPTIONMODE);
+		ahc->bus_softc.pci_softc.targcrccnt = ahc_inw(ahc, TARGCRCCNT);
+		ahc_outb(ahc, SFUNCT, sfunct);
+		ahc->bus_softc.pci_softc.crccontrol1 =
+		    ahc_inb(ahc, CRCCONTROL1);
+	}
+	if ((ahc->features & AHC_MULTI_FUNC) != 0)
+		ahc->bus_softc.pci_softc.scbbaddr = ahc_inb(ahc, SCBBADDR);
+
+	if ((ahc->features & AHC_ULTRA2) != 0)
+		ahc->bus_softc.pci_softc.dff_thrsh = ahc_inb(ahc, DFF_THRSH);
+
 	/* Core initialization */
 	error = ahc_init(ahc);
 	if (error != 0)
@@ -990,11 +1046,6 @@
 	 * Link this softc in with all other ahc instances.
 	 */
 	ahc_softc_insert(ahc);
-
-	ahc_lock(ahc, &s);
-	ahc_intr_enable(ahc, TRUE);
-	ahc_unlock(ahc, &s);
-
 	ahc_list_unlock(&l);
 	return (0);
 }
@@ -1195,6 +1246,83 @@
 }
 
 /*
+ * Perform some simple tests that should catch situations where
+ * our registers are invalidly mapped.
+ */
+int
+ahc_pci_test_register_access(struct ahc_softc *ahc)
+{
+	int	 error;
+	u_int	 status1;
+	uint32_t cmd;
+	uint8_t	 hcntrl;
+
+	error = EIO;
+
+	/*
+	 * Enable PCI error interrupt status, but suppress NMIs
+	 * generated by SERR raised due to target aborts.
+	 */
+	cmd = ahc_pci_read_config(ahc->dev_softc, PCIR_COMMAND, /*bytes*/2);
+	ahc_pci_write_config(ahc->dev_softc, PCIR_COMMAND,
+			     cmd & ~PCIM_CMD_SERRESPEN, /*bytes*/2);
+
+	/*
+	 * First a simple test to see if any
+	 * registers can be read.  Reading
+	 * HCNTRL has no side effects and has
+	 * at least one bit that is guaranteed to
+	 * be zero so it is a good register to
+	 * use for this test.
+	 */
+	hcntrl = ahc_inb(ahc, HCNTRL);
+	if (hcntrl == 0xFF)
+		goto fail;
+
+	/*
+	 * Next create a situation where write combining
+	 * or read prefetching could be initiated by the
+	 * CPU or host bridge.  Our device does not support
+	 * either, so look for data corruption and/or flagged
+	 * PCI errors.
+	 */
+	ahc_outb(ahc, HCNTRL, hcntrl|PAUSE);
+	while (ahc_is_paused(ahc) == 0)
+		;
+
+	/* Clear any PCI errors that occurred before our driver attached. */
+	status1 = ahc_pci_read_config(ahc->dev_softc,
+				      PCIR_STATUS + 1, /*bytes*/1);
+	ahc_pci_write_config(ahc->dev_softc, PCIR_STATUS + 1,
+			     status1, /*bytes*/1);
+	ahc_outb(ahc, CLRINT, CLRPARERR);
+
+	ahc_outb(ahc, SEQCTL, PERRORDIS);
+	ahc_outb(ahc, SCBPTR, 0);
+	ahc_outl(ahc, SCB_BASE, 0x5aa555aa);
+	if (ahc_inl(ahc, SCB_BASE) != 0x5aa555aa)
+		goto fail;
+
+	status1 = ahc_pci_read_config(ahc->dev_softc,
+				      PCIR_STATUS + 1, /*bytes*/1);
+	if ((status1 & STA) != 0)
+		goto fail;
+
+	error = 0;
+
+fail:
+	/* Silently clear any latched errors. */
+	status1 = ahc_pci_read_config(ahc->dev_softc,
+				      PCIR_STATUS + 1, /*bytes*/1);
+	ahc_pci_write_config(ahc->dev_softc, PCIR_STATUS + 1,
+			     status1, /*bytes*/1);
+	ahc_outb(ahc, CLRINT, CLRPARERR);
+	ahc_outb(ahc, SEQCTL, PERRORDIS|FAILDIS);
+	ahc_pci_write_config(ahc->dev_softc, PCIR_COMMAND, cmd, /*bytes*/2);
+	return (error);
+}
+
+/*
  * Check the external port logic for a serial eeprom
  * and termination/cable detection contrls.
  */
@@ -1279,13 +1407,12 @@
 			int	  i;
 
 			sc_data = (uint16_t *)sc;
-			for (i = 0; i < 32; i++) {
-				uint16_t val;
-				int	 j;
+			for (i = 0; i < 32; i++, sc_data++) {
+				int	j;
 
 				j = i * 2;
-				val = ahc_inb(ahc, SRAM_BASE + j)
-				    | ahc_inb(ahc, SRAM_BASE + j + 1) << 8;
+				*sc_data = ahc_inb(ahc, SRAM_BASE + j)
+					 | ahc_inb(ahc, SRAM_BASE + j + 1) << 8;
 			}
 			have_seeprom = ahc_verify_cksum(sc);
 			if (have_seeprom)
@@ -1329,6 +1456,7 @@
 	}
 
 	if (have_autoterm) {
+		ahc->flags |= AHC_HAS_TERM_LOGIC;
 		ahc_acquire_seeprom(ahc, &sd);
 		configure_termination(ahc, &sd, sc->adapter_control, sxfrctl1);
 		ahc_release_seeprom(&sd);
@@ -1528,6 +1656,8 @@
 			aic785X_cable_detect(ahc, &internal50_present,
 					     &externalcable_present,
 					     &eeprom_present);
+			/* Can never support a wide connector. */
+			internal68_present = 0;
 		} else {
 			aic787X_cable_detect(ahc, &internal50_present,
 					     &internal68_present,
@@ -1760,14 +1890,52 @@
 	spiocap |= EXT_BRDCTL;
 	ahc_outb(ahc, SPIOCAP, spiocap);
 	ahc_outb(ahc, BRDCTL, BRDRW|BRDCS);
+	ahc_flush_device_writes(ahc);
+	ahc_delay(500);
 	ahc_outb(ahc, BRDCTL, 0);
+	ahc_flush_device_writes(ahc);
+	ahc_delay(500);
 	brdctl = ahc_inb(ahc, BRDCTL);
 	*internal50_present = (brdctl & BRDDAT5) ? 0 : 1;
 	*externalcable_present = (brdctl & BRDDAT6) ? 0 : 1;
-
 	*eeprom_present = (ahc_inb(ahc, SPIOCAP) & EEPROM) ? 1 : 0;
 }
 	
+int
+ahc_acquire_seeprom(struct ahc_softc *ahc, struct seeprom_descriptor *sd)
+{
+	int wait;
+
+	if ((ahc->features & AHC_SPIOCAP) != 0
+	 && (ahc_inb(ahc, SPIOCAP) & SEEPROM) == 0)
+		return (0);
+
+	/*
+	 * Request access of the memory port.  When access is
+	 * granted, SEERDY will go high.  We use a 1 second
+	 * timeout which should be near 1 second more than
+	 * is needed.  Reason: after the chip reset, there
+	 * should be no contention.
+	 */
+	SEEPROM_OUTB(sd, sd->sd_MS);
+	wait = 1000;  /* 1 second timeout in msec */
+	while (--wait && ((SEEPROM_STATUS_INB(sd) & sd->sd_RDY) == 0)) {
+		ahc_delay(1000);  /* delay 1 msec */
+	}
+	if ((SEEPROM_STATUS_INB(sd) & sd->sd_RDY) == 0) {
+		SEEPROM_OUTB(sd, 0); 
+		return (0);
+	}
+	return(1);
+}
+
+void
+ahc_release_seeprom(struct seeprom_descriptor *sd)
+{
+	/* Release access to the memory port and the serial EEPROM. */
+	SEEPROM_OUTB(sd, 0);
+}
+
 static void
 write_brdctl(struct ahc_softc *ahc, uint8_t value)
 {
@@ -1801,8 +1969,7 @@
 }
 
 static uint8_t
-read_brdctl(ahc)
-	struct 	ahc_softc *ahc;
+read_brdctl(struct ahc_softc *ahc)
 {
 	uint8_t brdctl;
 	uint8_t value;
@@ -1823,14 +1990,7 @@
 	return (value);
 }
 
-#define	DPE	0x80
-#define SSE	0x40
-#define	RMA	0x20
-#define	RTA	0x10
-#define STA	0x08
-#define DPR	0x01
-
-void
+static void
 ahc_pci_intr(struct ahc_softc *ahc)
 {
 	u_int error;
@@ -1848,6 +2008,7 @@
 	      ahc_inb(ahc, SEQADDR0) | (ahc_inb(ahc, SEQADDR1) << 8));
 
 	if (status1 & DPE) {
+		ahc->pci_target_perr_count++;
 		printf("%s: Data Parity Error Detected during address "
 		       "or write data phase\n", ahc_name(ahc));
 	}
@@ -1879,10 +2040,90 @@
 		ahc_outb(ahc, CLRINT, CLRPARERR);
 	}
 
+	if (ahc->pci_target_perr_count > AHC_PCI_TARGET_PERR_THRESH) {
+		printf(
+"%s: WARNING WARNING WARNING WARNING\n"
+"%s: Too many PCI parity errors observed as a target.\n"
+"%s: Some device on this bus is generating bad parity.\n"
+"%s: This is an error *observed by*, not *generated by*, this controller.\n"
+"%s: PCI parity error checking has been disabled.\n"
+"%s: WARNING WARNING WARNING WARNING\n",
+		       ahc_name(ahc), ahc_name(ahc), ahc_name(ahc),
+		       ahc_name(ahc), ahc_name(ahc), ahc_name(ahc));
+		ahc->seqctl |= FAILDIS;
+		ahc_outb(ahc, SEQCTL, ahc->seqctl);
+	}
 	ahc_unpause(ahc);
 }
 
 static int
+ahc_pci_chip_init(struct ahc_softc *ahc)
+{
+	ahc_outb(ahc, DSCOMMAND0, ahc->bus_softc.pci_softc.dscommand0);
+	ahc_outb(ahc, DSPCISTATUS, ahc->bus_softc.pci_softc.dspcistatus);
+	if ((ahc->features & AHC_DT) != 0) {
+		u_int sfunct;
+
+		sfunct = ahc_inb(ahc, SFUNCT) & ~ALT_MODE;
+		ahc_outb(ahc, SFUNCT, sfunct | ALT_MODE);
+		ahc_outb(ahc, OPTIONMODE, ahc->bus_softc.pci_softc.optionmode);
+		ahc_outw(ahc, TARGCRCCNT, ahc->bus_softc.pci_softc.targcrccnt);
+		ahc_outb(ahc, SFUNCT, sfunct);
+		ahc_outb(ahc, CRCCONTROL1,
+			 ahc->bus_softc.pci_softc.crccontrol1);
+	}
+	if ((ahc->features & AHC_MULTI_FUNC) != 0)
+		ahc_outb(ahc, SCBBADDR, ahc->bus_softc.pci_softc.scbbaddr);
+
+	if ((ahc->features & AHC_ULTRA2) != 0)
+		ahc_outb(ahc, DFF_THRSH, ahc->bus_softc.pci_softc.dff_thrsh);
+
+	return (ahc_chip_init(ahc));
+}
+
+static int
+ahc_pci_suspend(struct ahc_softc *ahc)
+{
+	return (ahc_suspend(ahc));
+}
+
+static int
+ahc_pci_resume(struct ahc_softc *ahc)
+{
+
+	ahc_power_state_change(ahc, AHC_POWER_STATE_D0);
+
+	/*
+	 * We assume that the OS has restored our register
+	 * mappings, etc.  Just update the config space registers
+	 * that the OS doesn't know about and rely on our chip
+	 * reset handler to handle the rest.
+	 */
+	ahc_pci_write_config(ahc->dev_softc, DEVCONFIG, /*bytes*/4,
+			     ahc->bus_softc.pci_softc.devconfig);
+	ahc_pci_write_config(ahc->dev_softc, PCIR_COMMAND, /*bytes*/1,
+			     ahc->bus_softc.pci_softc.command);
+	ahc_pci_write_config(ahc->dev_softc, CSIZE_LATTIME, /*bytes*/1,
+			     ahc->bus_softc.pci_softc.csize_lattime);
+	if ((ahc->flags & AHC_HAS_TERM_LOGIC) != 0) {
+		struct	seeprom_descriptor sd;
+		u_int	sxfrctl1;
+
+		sd.sd_ahc = ahc;
+		sd.sd_control_offset = SEECTL;		
+		sd.sd_status_offset = SEECTL;		
+		sd.sd_dataout_offset = SEECTL;		
+
+		ahc_acquire_seeprom(ahc, &sd);
+		configure_termination(ahc, &sd,
+				      ahc->seep_config->adapter_control,
+				      &sxfrctl1);
+		ahc_release_seeprom(&sd);
+	}
+	return (ahc_resume(ahc));
+}
+
+static int
 ahc_aic785X_setup(struct ahc_softc *ahc)
 {
 	ahc_dev_softc_t pci;
@@ -1896,6 +2137,7 @@
 	rev = ahc_pci_read_config(pci, PCIR_REVID, /*bytes*/1);
 	if (rev >= 1)
 		ahc->bugs |= AHC_PCI_2_1_RETRY_BUG;
+	ahc->instruction_ram_size = 512;
 	return (0);
 }
 
@@ -1913,16 +2155,15 @@
 	rev = ahc_pci_read_config(pci, PCIR_REVID, /*bytes*/1);
 	if (rev >= 1)
 		ahc->bugs |= AHC_PCI_2_1_RETRY_BUG;
+	ahc->instruction_ram_size = 512;
 	return (0);
 }
 
 static int
 ahc_apa1480_setup(struct ahc_softc *ahc)
 {
-	ahc_dev_softc_t pci;
 	int error;
 
-	pci = ahc->dev_softc;
 	error = ahc_aic7860_setup(ahc);
 	if (error != 0)
 		return (error);
@@ -1933,13 +2174,12 @@
 static int
 ahc_aic7870_setup(struct ahc_softc *ahc)
 {
-	ahc_dev_softc_t pci;
 
-	pci = ahc->dev_softc;
 	ahc->channel = 'A';
 	ahc->chip = AHC_AIC7870;
 	ahc->features = AHC_AIC7870_FE;
 	ahc->bugs |= AHC_TMODE_WIDEODD_BUG|AHC_CACHETHEN_BUG|AHC_PCI_MWI_BUG;
+	ahc->instruction_ram_size = 512;
 	return (0);
 }
 
@@ -1993,19 +2233,16 @@
 	} else {
 		ahc->bugs |= AHC_CACHETHEN_BUG|AHC_PCI_MWI_BUG;
 	}
+	ahc->instruction_ram_size = 512;
 	return (0);
 }
 
 static int
 ahc_aha2940Pro_setup(struct ahc_softc *ahc)
 {
-	ahc_dev_softc_t pci;
-	int error;
 
-	pci = ahc->dev_softc;
 	ahc->flags |= AHC_INT50_SPEEDFLEX;
-	error = ahc_aic7880_setup(ahc);
-	return (0);
+	return (ahc_aic7880_setup(ahc));
 }
 
 static int
@@ -2044,20 +2281,20 @@
 	rev = ahc_pci_read_config(pci, PCIR_REVID, /*bytes*/1);
 	if (rev == 0)
 		ahc->bugs |= AHC_AUTOFLUSH_BUG|AHC_CACHETHEN_BUG;
+	ahc->instruction_ram_size = 768;
 	return (0);
 }
 
 static int
 ahc_aic7892_setup(struct ahc_softc *ahc)
 {
-	ahc_dev_softc_t pci;
 
-	pci = ahc->dev_softc;
 	ahc->channel = 'A';
 	ahc->chip = AHC_AIC7892;
 	ahc->features = AHC_AIC7892_FE;
 	ahc->flags |= AHC_NEWEEPROM_FMT;
 	ahc->bugs |= AHC_SCBCHAN_UPLOAD_BUG;
+	ahc->instruction_ram_size = 1024;
 	return (0);
 }
 
@@ -2113,6 +2350,7 @@
 	ahc_pci_write_config(pci, DEVCONFIG, devconfig, /*bytes*/1);
 #endif
 	ahc->flags |= AHC_NEWEEPROM_FMT;
+	ahc->instruction_ram_size = 512;
 	return (0);
 }
 
@@ -2127,6 +2365,7 @@
 	ahc->features = AHC_AIC7896_FE;
 	ahc->flags |= AHC_NEWEEPROM_FMT;
 	ahc->bugs |= AHC_CACHETHEN_DIS_BUG;
+	ahc->instruction_ram_size = 768;
 	return (0);
 }
 
@@ -2141,6 +2380,7 @@
 	ahc->features = AHC_AIC7899_FE;
 	ahc->flags |= AHC_NEWEEPROM_FMT;
 	ahc->bugs |= AHC_SCBCHAN_UPLOAD_BUG;
+	ahc->instruction_ram_size = 1024;
 	return (0);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_proc.c linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_proc.c
--- linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_proc.c	2002-11-28 23:53:14.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_proc.c	2003-06-26 21:43:10.000000000 +0000
@@ -37,7 +37,7 @@
  * String handling code courtesy of Gerard Roudier's <groudier@club-internet.fr>
  * sym driver.
  *
- * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#19 $
+ * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#29 $
  */
 #include "aic7xxx_osm.h"
 #include "aic7xxx_inline.h"
@@ -45,7 +45,6 @@
 
 static void	copy_mem_info(struct info_str *info, char *data, int len);
 static int	copy_info(struct info_str *info, char *fmt, ...);
-static u_int	scsi_calc_syncsrate(u_int period_factor);
 static void	ahc_dump_target_state(struct ahc_softc *ahc,
 				      struct info_str *info,
 				      u_int our_id, char channel,
@@ -54,44 +53,6 @@
 				      struct ahc_linux_device *dev);
 static int	ahc_proc_write_seeprom(struct ahc_softc *ahc,
 				       char *buffer, int length);
-				       
-
-int
-ahc_acquire_seeprom(struct ahc_softc *ahc, struct seeprom_descriptor *sd)
-{
-	int wait;
-
-	if ((ahc->features & AHC_SPIOCAP) != 0
-	 && (ahc_inb(ahc, SPIOCAP) & SEEPROM) == 0)
-		return (0);
-
-	/*
-	 * Request access of the memory port.  When access is
-	 * granted, SEERDY will go high.  We use a 1 second
-	 * timeout which should be near 1 second more than
-	 * is needed.  Reason: after the chip reset, there
-	 * should be no contention.
-	 */
-	SEEPROM_OUTB(sd, sd->sd_MS);
-	wait = 1000;  /* 1 second timeout in msec */
-	while (--wait && ((SEEPROM_STATUS_INB(sd) & sd->sd_RDY) == 0)) {
-		ahc_delay(1000);  /* delay 1 msec */
-	}
-	if ((SEEPROM_STATUS_INB(sd) & sd->sd_RDY) == 0) {
-		SEEPROM_OUTB(sd, 0); 
-		return (0);
-	}
-	return(1);
-}
-
-
-void
-ahc_release_seeprom(struct seeprom_descriptor *sd)
-{
-	/* Release access to the memory port and the serial EEPROM. */
-	SEEPROM_OUTB(sd, 0);
-}
-
 
 static void
 copy_mem_info(struct info_str *info, char *data, int len)
@@ -135,47 +96,6 @@
 	return (len);
 }
 
-/*
- * Table of syncrates that don't follow the "divisible by 4"
- * rule. This table will be expanded in future SCSI specs.
- */
-static struct {
-	u_int period_factor;
-	u_int period;	/* in 10ths of ns */
-} scsi_syncrates[] = {
-	{ 0x09, 125 },	/* FAST-80 */
-	{ 0x0a, 250 },	/* FAST-40 40MHz */
-	{ 0x0b, 303 },	/* FAST-40 33MHz */
-	{ 0x0c, 500 }	/* FAST-20 */
-};
- 
-/*
- * Return the frequency in kHz corresponding to the given
- * sync period factor.
- */
-static u_int
-scsi_calc_syncsrate(u_int period_factor)
-{
-	int i; 
-	int num_syncrates;
- 
-	num_syncrates = sizeof(scsi_syncrates) / sizeof(scsi_syncrates[0]);
-	/* See if the period is in the "exception" table */
-	for (i = 0; i < num_syncrates; i++) {
-
-		if (period_factor == scsi_syncrates[i].period_factor) {
-       			/* Period in kHz */
-			return (10000000 / scsi_syncrates[i].period);
-		}
-	}
-
-	/*
-	 * Wasn't in the table, so use the standard
-	 * 4 times conversion.
-	 */
-	return (10000000 / (period_factor * 4 * 10));
-}
-
 void
 ahc_format_transinfo(struct info_str *info, struct ahc_transinfo *tinfo)
 {
@@ -186,7 +106,7 @@
         speed = 3300;
         freq = 0;
 	if (tinfo->offset != 0) {
-		freq = scsi_calc_syncsrate(tinfo->period);
+		freq = aic_calc_syncsrate(tinfo->period);
 		speed = freq;
 	}
 	speed *= (0x01 << tinfo->width);
@@ -228,8 +148,9 @@
 
 	tinfo = ahc_fetch_transinfo(ahc, channel, our_id,
 				    target_id, &tstate);
-	copy_info(info, "Channel %c Target %d Negotiation Settings\n",
-		  channel, target_id);
+	if ((ahc->features & AHC_TWIN) != 0)
+		copy_info(info, "Channel %c ", channel);
+	copy_info(info, "Target %d Negotiation Settings\n", target_id);
 	copy_info(info, "\tUser: ");
 	ahc_format_transinfo(info, &tinfo->user);
 	targ = ahc->platform_data->targets[target_offset];
@@ -294,19 +215,8 @@
 	}
 
 	sd.sd_ahc = ahc;
-	if ((ahc->chip & AHC_VL) != 0) {
-		sd.sd_control_offset = SEECTL_2840;
-		sd.sd_status_offset = STATUS_2840;
-		sd.sd_dataout_offset = STATUS_2840;		
-		sd.sd_chip = C46;
-		sd.sd_MS = 0;
-		sd.sd_RDY = EEPROM_TF;
-		sd.sd_CS = CS_2840;
-		sd.sd_CK = CK_2840;
-		sd.sd_DO = DO_2840;
-		sd.sd_DI = DI_2840;
-		have_seeprom = TRUE;
-	} else {
+#if AHC_PCI_CONFIG > 0
+	if ((ahc->chip & AHC_PCI) != 0) {
 		sd.sd_control_offset = SEECTL;
 		sd.sd_status_offset = SEECTL;
 		sd.sd_dataout_offset = SEECTL;
@@ -321,6 +231,23 @@
 		sd.sd_DO = SEEDO;
 		sd.sd_DI = SEEDI;
 		have_seeprom = ahc_acquire_seeprom(ahc, &sd);
+	} else
+#endif
+	if ((ahc->chip & AHC_VL) != 0) {
+		sd.sd_control_offset = SEECTL_2840;
+		sd.sd_status_offset = STATUS_2840;
+		sd.sd_dataout_offset = STATUS_2840;		
+		sd.sd_chip = C46;
+		sd.sd_MS = 0;
+		sd.sd_RDY = EEPROM_TF;
+		sd.sd_CS = CS_2840;
+		sd.sd_CK = CK_2840;
+		sd.sd_DO = DO_2840;
+		sd.sd_DI = DI_2840;
+		have_seeprom = TRUE;
+	} else {
+		printf("ahc_proc_write_seeprom: unsupported adapter type\n");
+		goto done;
 	}
 
 	if (!have_seeprom) {
@@ -344,8 +271,10 @@
 				  sizeof(struct seeprom_config)/2);
 		ahc_read_seeprom(&sd, (uint16_t *)ahc->seep_config,
 				 start_addr, sizeof(struct seeprom_config)/2);
+#if AHC_PCI_CONFIG > 0
 		if ((ahc->chip & AHC_VL) == 0)
 			ahc_release_seeprom(&sd);
+#endif
 		written = length;
 	}
 
@@ -360,8 +289,13 @@
  * Return information to handle /proc support for the driver.
  */
 int
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 ahc_linux_proc_info(char *buffer, char **start, off_t offset,
-		  int length, int hostno, int inout)
+		    int length, int hostno, int inout)
+#else
+ahc_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
+		    off_t offset, int length, int inout)
+#endif
 {
 	struct	ahc_softc *ahc;
 	struct	info_str info;
@@ -373,10 +307,14 @@
 
 	retval = -EINVAL;
 	ahc_list_lock(&s);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 	TAILQ_FOREACH(ahc, &ahc_tailq, links) {
 		if (ahc->platform_data->host->host_no == hostno)
 			break;
 	}
+#else
+	ahc = ahc_find_softc(*(struct ahc_softc **)shost->hostdata);
+#endif
 
 	if (ahc == NULL)
 		goto done;
@@ -397,8 +335,12 @@
 
 	copy_info(&info, "Adaptec AIC7xxx driver version: %s\n",
 		  AIC7XXX_DRIVER_VERSION);
+	copy_info(&info, "%s\n", ahc->description);
 	ahc_controller_info(ahc, ahc_info);
-	copy_info(&info, "%s\n\n", ahc_info);
+	copy_info(&info, "%s\n", ahc_info);
+	copy_info(&info, "Allocated SCBs: %d, SG List Length: %d\n\n",
+		  ahc->scb_data->numscbs, AHC_NSEG);
+
 
 	if (ahc->seep_config == NULL)
 		copy_info(&info, "No Serial EEPROM\n");
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_reg.h linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_reg.h
--- linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_reg.h	2002-08-03 00:39:44.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_reg.h	2003-06-26 21:43:11.000000000 +0000
@@ -2,9 +2,1066 @@
  * DO NOT EDIT - This file is automatically generated
  *		 from the following source files:
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.seq#43 $
- * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.reg#30 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.seq#56 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.reg#39 $
  */
+typedef int (ahc_reg_print_t)(u_int, u_int *, u_int);
+typedef struct ahc_reg_parse_entry {
+	char	*name;
+	uint8_t	 value;
+	uint8_t	 mask;
+} ahc_reg_parse_entry_t;
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scsiseq_print;
+#else
+#define ahc_scsiseq_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCSISEQ", 0x00, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_sxfrctl0_print;
+#else
+#define ahc_sxfrctl0_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SXFRCTL0", 0x01, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_sxfrctl1_print;
+#else
+#define ahc_sxfrctl1_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SXFRCTL1", 0x02, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scsisigo_print;
+#else
+#define ahc_scsisigo_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCSISIGO", 0x03, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scsisigi_print;
+#else
+#define ahc_scsisigi_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCSISIGI", 0x03, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scsirate_print;
+#else
+#define ahc_scsirate_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCSIRATE", 0x04, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scsiid_print;
+#else
+#define ahc_scsiid_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCSIID", 0x05, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scsidatl_print;
+#else
+#define ahc_scsidatl_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCSIDATL", 0x06, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scsidath_print;
+#else
+#define ahc_scsidath_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCSIDATH", 0x07, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_stcnt_print;
+#else
+#define ahc_stcnt_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "STCNT", 0x08, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_optionmode_print;
+#else
+#define ahc_optionmode_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "OPTIONMODE", 0x08, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_targcrccnt_print;
+#else
+#define ahc_targcrccnt_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "TARGCRCCNT", 0x0a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_clrsint0_print;
+#else
+#define ahc_clrsint0_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "CLRSINT0", 0x0b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_sstat0_print;
+#else
+#define ahc_sstat0_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SSTAT0", 0x0b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_clrsint1_print;
+#else
+#define ahc_clrsint1_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "CLRSINT1", 0x0c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_sstat1_print;
+#else
+#define ahc_sstat1_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SSTAT1", 0x0c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_sstat2_print;
+#else
+#define ahc_sstat2_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SSTAT2", 0x0d, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_sstat3_print;
+#else
+#define ahc_sstat3_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SSTAT3", 0x0e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scsiid_ultra2_print;
+#else
+#define ahc_scsiid_ultra2_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCSIID_ULTRA2", 0x0f, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_simode0_print;
+#else
+#define ahc_simode0_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SIMODE0", 0x10, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_simode1_print;
+#else
+#define ahc_simode1_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SIMODE1", 0x11, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scsibusl_print;
+#else
+#define ahc_scsibusl_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCSIBUSL", 0x12, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scsibush_print;
+#else
+#define ahc_scsibush_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCSIBUSH", 0x13, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_sxfrctl2_print;
+#else
+#define ahc_sxfrctl2_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SXFRCTL2", 0x13, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_shaddr_print;
+#else
+#define ahc_shaddr_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SHADDR", 0x14, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_seltimer_print;
+#else
+#define ahc_seltimer_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SELTIMER", 0x18, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_selid_print;
+#else
+#define ahc_selid_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SELID", 0x19, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scamctl_print;
+#else
+#define ahc_scamctl_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCAMCTL", 0x1a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_targid_print;
+#else
+#define ahc_targid_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "TARGID", 0x1b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_spiocap_print;
+#else
+#define ahc_spiocap_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SPIOCAP", 0x1b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_brdctl_print;
+#else
+#define ahc_brdctl_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "BRDCTL", 0x1d, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_seectl_print;
+#else
+#define ahc_seectl_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SEECTL", 0x1e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_sblkctl_print;
+#else
+#define ahc_sblkctl_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SBLKCTL", 0x1f, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_busy_targets_print;
+#else
+#define ahc_busy_targets_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "BUSY_TARGETS", 0x20, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_ultra_enb_print;
+#else
+#define ahc_ultra_enb_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "ULTRA_ENB", 0x30, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_disc_dsb_print;
+#else
+#define ahc_disc_dsb_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "DISC_DSB", 0x32, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_cmdsize_table_tail_print;
+#else
+#define ahc_cmdsize_table_tail_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "CMDSIZE_TABLE_TAIL", 0x34, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_mwi_residual_print;
+#else
+#define ahc_mwi_residual_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "MWI_RESIDUAL", 0x38, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_next_queued_scb_print;
+#else
+#define ahc_next_queued_scb_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "NEXT_QUEUED_SCB", 0x39, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_msg_out_print;
+#else
+#define ahc_msg_out_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "MSG_OUT", 0x3a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_dmaparams_print;
+#else
+#define ahc_dmaparams_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "DMAPARAMS", 0x3b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_seq_flags_print;
+#else
+#define ahc_seq_flags_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SEQ_FLAGS", 0x3c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_saved_scsiid_print;
+#else
+#define ahc_saved_scsiid_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SAVED_SCSIID", 0x3d, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_saved_lun_print;
+#else
+#define ahc_saved_lun_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SAVED_LUN", 0x3e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_lastphase_print;
+#else
+#define ahc_lastphase_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "LASTPHASE", 0x3f, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_waiting_scbh_print;
+#else
+#define ahc_waiting_scbh_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "WAITING_SCBH", 0x40, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_disconnected_scbh_print;
+#else
+#define ahc_disconnected_scbh_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "DISCONNECTED_SCBH", 0x41, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_free_scbh_print;
+#else
+#define ahc_free_scbh_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "FREE_SCBH", 0x42, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_complete_scbh_print;
+#else
+#define ahc_complete_scbh_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "COMPLETE_SCBH", 0x43, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_hscb_addr_print;
+#else
+#define ahc_hscb_addr_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "HSCB_ADDR", 0x44, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_shared_data_addr_print;
+#else
+#define ahc_shared_data_addr_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SHARED_DATA_ADDR", 0x48, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_kernel_qinpos_print;
+#else
+#define ahc_kernel_qinpos_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "KERNEL_QINPOS", 0x4c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_qinpos_print;
+#else
+#define ahc_qinpos_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "QINPOS", 0x4d, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_qoutpos_print;
+#else
+#define ahc_qoutpos_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "QOUTPOS", 0x4e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_kernel_tqinpos_print;
+#else
+#define ahc_kernel_tqinpos_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "KERNEL_TQINPOS", 0x4f, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_tqinpos_print;
+#else
+#define ahc_tqinpos_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "TQINPOS", 0x50, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_arg_1_print;
+#else
+#define ahc_arg_1_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "ARG_1", 0x51, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_arg_2_print;
+#else
+#define ahc_arg_2_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "ARG_2", 0x52, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_last_msg_print;
+#else
+#define ahc_last_msg_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "LAST_MSG", 0x53, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scsiseq_template_print;
+#else
+#define ahc_scsiseq_template_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCSISEQ_TEMPLATE", 0x54, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_ha_274_biosglobal_print;
+#else
+#define ahc_ha_274_biosglobal_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "HA_274_BIOSGLOBAL", 0x56, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_seq_flags2_print;
+#else
+#define ahc_seq_flags2_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SEQ_FLAGS2", 0x57, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scsiconf_print;
+#else
+#define ahc_scsiconf_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCSICONF", 0x5a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_intdef_print;
+#else
+#define ahc_intdef_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "INTDEF", 0x5c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_hostconf_print;
+#else
+#define ahc_hostconf_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "HOSTCONF", 0x5d, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_ha_274_biosctrl_print;
+#else
+#define ahc_ha_274_biosctrl_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "HA_274_BIOSCTRL", 0x5f, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_seqctl_print;
+#else
+#define ahc_seqctl_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SEQCTL", 0x60, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_seqram_print;
+#else
+#define ahc_seqram_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SEQRAM", 0x61, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_seqaddr0_print;
+#else
+#define ahc_seqaddr0_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SEQADDR0", 0x62, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_seqaddr1_print;
+#else
+#define ahc_seqaddr1_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SEQADDR1", 0x63, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_accum_print;
+#else
+#define ahc_accum_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "ACCUM", 0x64, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_sindex_print;
+#else
+#define ahc_sindex_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SINDEX", 0x65, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_dindex_print;
+#else
+#define ahc_dindex_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "DINDEX", 0x66, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_allones_print;
+#else
+#define ahc_allones_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "ALLONES", 0x69, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_allzeros_print;
+#else
+#define ahc_allzeros_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "ALLZEROS", 0x6a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_none_print;
+#else
+#define ahc_none_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "NONE", 0x6a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_flags_print;
+#else
+#define ahc_flags_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "FLAGS", 0x6b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_sindir_print;
+#else
+#define ahc_sindir_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SINDIR", 0x6c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_dindir_print;
+#else
+#define ahc_dindir_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "DINDIR", 0x6d, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_function1_print;
+#else
+#define ahc_function1_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "FUNCTION1", 0x6e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_stack_print;
+#else
+#define ahc_stack_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "STACK", 0x6f, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_targ_offset_print;
+#else
+#define ahc_targ_offset_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "TARG_OFFSET", 0x70, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_sram_base_print;
+#else
+#define ahc_sram_base_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SRAM_BASE", 0x70, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_bctl_print;
+#else
+#define ahc_bctl_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "BCTL", 0x84, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_dscommand0_print;
+#else
+#define ahc_dscommand0_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "DSCOMMAND0", 0x84, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_bustime_print;
+#else
+#define ahc_bustime_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "BUSTIME", 0x85, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_dscommand1_print;
+#else
+#define ahc_dscommand1_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "DSCOMMAND1", 0x85, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_busspd_print;
+#else
+#define ahc_busspd_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "BUSSPD", 0x86, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_hs_mailbox_print;
+#else
+#define ahc_hs_mailbox_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "HS_MAILBOX", 0x86, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_dspcistatus_print;
+#else
+#define ahc_dspcistatus_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "DSPCISTATUS", 0x86, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_hcntrl_print;
+#else
+#define ahc_hcntrl_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "HCNTRL", 0x87, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_haddr_print;
+#else
+#define ahc_haddr_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "HADDR", 0x88, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_hcnt_print;
+#else
+#define ahc_hcnt_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "HCNT", 0x8c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scbptr_print;
+#else
+#define ahc_scbptr_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCBPTR", 0x90, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_intstat_print;
+#else
+#define ahc_intstat_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "INTSTAT", 0x91, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_clrint_print;
+#else
+#define ahc_clrint_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "CLRINT", 0x92, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_error_print;
+#else
+#define ahc_error_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "ERROR", 0x92, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_dfcntrl_print;
+#else
+#define ahc_dfcntrl_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "DFCNTRL", 0x93, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_dfstatus_print;
+#else
+#define ahc_dfstatus_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "DFSTATUS", 0x94, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_dfwaddr_print;
+#else
+#define ahc_dfwaddr_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "DFWADDR", 0x95, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_dfraddr_print;
+#else
+#define ahc_dfraddr_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "DFRADDR", 0x97, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_dfdat_print;
+#else
+#define ahc_dfdat_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "DFDAT", 0x99, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scbcnt_print;
+#else
+#define ahc_scbcnt_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCBCNT", 0x9a, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_qinfifo_print;
+#else
+#define ahc_qinfifo_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "QINFIFO", 0x9b, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_qincnt_print;
+#else
+#define ahc_qincnt_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "QINCNT", 0x9c, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_qoutfifo_print;
+#else
+#define ahc_qoutfifo_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "QOUTFIFO", 0x9d, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_crccontrol1_print;
+#else
+#define ahc_crccontrol1_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "CRCCONTROL1", 0x9d, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_qoutcnt_print;
+#else
+#define ahc_qoutcnt_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "QOUTCNT", 0x9e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scsiphase_print;
+#else
+#define ahc_scsiphase_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCSIPHASE", 0x9e, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_sfunct_print;
+#else
+#define ahc_sfunct_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SFUNCT", 0x9f, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scb_base_print;
+#else
+#define ahc_scb_base_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCB_BASE", 0xa0, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scb_cdb_ptr_print;
+#else
+#define ahc_scb_cdb_ptr_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCB_CDB_PTR", 0xa0, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scb_residual_sgptr_print;
+#else
+#define ahc_scb_residual_sgptr_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCB_RESIDUAL_SGPTR", 0xa4, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scb_scsi_status_print;
+#else
+#define ahc_scb_scsi_status_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCB_SCSI_STATUS", 0xa8, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scb_target_phases_print;
+#else
+#define ahc_scb_target_phases_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCB_TARGET_PHASES", 0xa9, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scb_target_data_dir_print;
+#else
+#define ahc_scb_target_data_dir_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCB_TARGET_DATA_DIR", 0xaa, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scb_target_itag_print;
+#else
+#define ahc_scb_target_itag_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCB_TARGET_ITAG", 0xab, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scb_dataptr_print;
+#else
+#define ahc_scb_dataptr_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCB_DATAPTR", 0xac, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scb_datacnt_print;
+#else
+#define ahc_scb_datacnt_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCB_DATACNT", 0xb0, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scb_sgptr_print;
+#else
+#define ahc_scb_sgptr_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCB_SGPTR", 0xb4, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scb_control_print;
+#else
+#define ahc_scb_control_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCB_CONTROL", 0xb8, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scb_scsiid_print;
+#else
+#define ahc_scb_scsiid_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCB_SCSIID", 0xb9, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scb_lun_print;
+#else
+#define ahc_scb_lun_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCB_LUN", 0xba, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scb_tag_print;
+#else
+#define ahc_scb_tag_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCB_TAG", 0xbb, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scb_cdb_len_print;
+#else
+#define ahc_scb_cdb_len_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCB_CDB_LEN", 0xbc, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scb_scsirate_print;
+#else
+#define ahc_scb_scsirate_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCB_SCSIRATE", 0xbd, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scb_scsioffset_print;
+#else
+#define ahc_scb_scsioffset_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCB_SCSIOFFSET", 0xbe, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scb_next_print;
+#else
+#define ahc_scb_next_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCB_NEXT", 0xbf, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scb_64_spare_print;
+#else
+#define ahc_scb_64_spare_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCB_64_SPARE", 0xc0, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_seectl_2840_print;
+#else
+#define ahc_seectl_2840_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SEECTL_2840", 0xc0, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_status_2840_print;
+#else
+#define ahc_status_2840_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "STATUS_2840", 0xc1, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scb_64_btt_print;
+#else
+#define ahc_scb_64_btt_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCB_64_BTT", 0xd0, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_cchaddr_print;
+#else
+#define ahc_cchaddr_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "CCHADDR", 0xe0, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_cchcnt_print;
+#else
+#define ahc_cchcnt_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "CCHCNT", 0xe8, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_ccsgram_print;
+#else
+#define ahc_ccsgram_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "CCSGRAM", 0xe9, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_ccsgaddr_print;
+#else
+#define ahc_ccsgaddr_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "CCSGADDR", 0xea, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_ccsgctl_print;
+#else
+#define ahc_ccsgctl_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "CCSGCTL", 0xeb, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_ccscbram_print;
+#else
+#define ahc_ccscbram_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "CCSCBRAM", 0xec, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_ccscbaddr_print;
+#else
+#define ahc_ccscbaddr_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "CCSCBADDR", 0xed, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_ccscbctl_print;
+#else
+#define ahc_ccscbctl_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "CCSCBCTL", 0xee, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_ccscbcnt_print;
+#else
+#define ahc_ccscbcnt_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "CCSCBCNT", 0xef, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_scbbaddr_print;
+#else
+#define ahc_scbbaddr_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SCBBADDR", 0xf0, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_ccscbptr_print;
+#else
+#define ahc_ccscbptr_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "CCSCBPTR", 0xf1, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_hnscb_qoff_print;
+#else
+#define ahc_hnscb_qoff_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "HNSCB_QOFF", 0xf4, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_snscb_qoff_print;
+#else
+#define ahc_snscb_qoff_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SNSCB_QOFF", 0xf6, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_sdscb_qoff_print;
+#else
+#define ahc_sdscb_qoff_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SDSCB_QOFF", 0xf8, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_qoff_ctlsta_print;
+#else
+#define ahc_qoff_ctlsta_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "QOFF_CTLSTA", 0xfa, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_dff_thrsh_print;
+#else
+#define ahc_dff_thrsh_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "DFF_THRSH", 0xfb, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_sg_cache_shadow_print;
+#else
+#define ahc_sg_cache_shadow_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SG_CACHE_SHADOW", 0xfc, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahc_reg_print_t ahc_sg_cache_pre_print;
+#else
+#define ahc_sg_cache_pre_print(regvalue, cur_col, wrap) \
+    ahc_print_register(NULL, 0, "SG_CACHE_PRE", 0xfc, regvalue, cur_col, wrap)
+#endif
+
 
 #define	SCSISEQ         		0x00
 #define		TEMODE          	0x80
@@ -20,9 +1077,9 @@
 #define		CLRCHN          	0x02
 
 #define	SXFRCTL1        		0x02
+#define		STIMESEL        	0x18
 #define		BITBUCKET       	0x80
 #define		SWRAPEN         	0x40
-#define		STIMESEL        	0x18
 #define		ENSTIMER        	0x04
 #define		ACTNEGEN        	0x02
 #define		STPWEN          	0x01
@@ -47,12 +1104,12 @@
 #define		ACKI            	0x01
 
 #define	SCSIRATE        		0x04
-#define		WIDEXFER        	0x80
 #define		SXFR            	0x70
-#define		ENABLE_CRC      	0x40
-#define		SINGLE_EDGE     	0x10
 #define		SOFS            	0x0f
 #define		SXFR_ULTRA2     	0x0f
+#define		WIDEXFER        	0x80
+#define		ENABLE_CRC      	0x40
+#define		SINGLE_EDGE     	0x10
 
 #define	SCSIID          		0x05
 #define	SCSIOFFSET      		0x05
@@ -65,13 +1122,13 @@
 #define	STCNT           		0x08
 
 #define	OPTIONMODE      		0x08
+#define		OPTIONMODE_DEFAULTS	0x03
 #define		AUTORATEEN      	0x80
 #define		AUTOACKEN       	0x40
 #define		ATNMGMNTEN      	0x20
 #define		BUSFREEREV      	0x10
 #define		EXPPHASEDIS     	0x08
 #define		SCSIDATL_IMGEN  	0x04
-#define		OPTIONMODE_DEFAULTS	0x03
 #define		AUTO_MSGOUT_DE  	0x02
 #define		DIS_MSGIN_DUALEDGE	0x01
 
@@ -116,9 +1173,9 @@
 #define		REQINIT         	0x01
 
 #define	SSTAT2          		0x0d
+#define		SFCNT           	0x1f
 #define		OVERRUN         	0x80
 #define		SHVALID         	0x40
-#define		SFCNT           	0x1f
 #define		EXP_ACTIVE      	0x10
 #define		CRCVALERR       	0x08
 #define		CRCENDERR       	0x04
@@ -156,6 +1213,11 @@
 
 #define	SCSIBUSH        		0x13
 
+#define	SXFRCTL2        		0x13
+#define		ASYNC_SETUP     	0x07
+#define		AUTORSTDIS      	0x10
+#define		CMDDMAEN        	0x08
+
 #define	SHADDR          		0x14
 
 #define	SELTIMER        		0x18
@@ -172,11 +1234,11 @@
 #define		ONEBIT          	0x08
 
 #define	SCAMCTL         		0x1a
+#define		SCAMLVL         	0x03
 #define		ENSCAMSELO      	0x80
 #define		CLRSCAMSELID    	0x40
 #define		ALTSTIM         	0x20
 #define		DFLTTID         	0x10
-#define		SCAMLVL         	0x03
 
 #define	TARGID          		0x1b
 
@@ -236,6 +1298,7 @@
 #define	CMDSIZE_TABLE_TAIL		0x34
 
 #define	MWI_RESIDUAL    		0x38
+#define	TARG_IMMEDIATE_SCB		0x38
 
 #define	NEXT_QUEUED_SCB 		0x39
 
@@ -254,7 +1317,8 @@
 #define		FIFORESET       	0x01
 
 #define	SEQ_FLAGS       		0x3c
-#define		IDENTIFY_SEEN   	0x80
+#define		NOT_IDENTIFIED  	0x80
+#define		NO_CDB_SENT     	0x40
 #define		TARGET_CMD_IS_TAGGED	0x40
 #define		DPHASE          	0x20
 #define		TARG_CMD_PENDING	0x10
@@ -273,12 +1337,12 @@
 #define		P_STATUS        	0xc0
 #define		P_MESGOUT       	0xa0
 #define		P_COMMAND       	0x80
-#define		CDI             	0x80
 #define		P_DATAIN        	0x40
-#define		IOI             	0x40
-#define		MSGI            	0x20
 #define		P_BUSFREE       	0x01
 #define		P_DATAOUT       	0x00
+#define		CDI             	0x80
+#define		IOI             	0x40
+#define		MSGI            	0x20
 
 #define	WAITING_SCBH    		0x40
 
@@ -325,8 +1389,6 @@
 #define		ENAUTOATNI      	0x04
 #define		ENAUTOATNP      	0x02
 
-#define	DATA_COUNT_ODD  		0x55
-
 #define	HA_274_BIOSGLOBAL		0x56
 #define	INITIATOR_TAG   		0x56
 #define		HA_274_EXTENDED_TRANS	0x01
@@ -336,15 +1398,15 @@
 #define		SCB_DMA         	0x01
 
 #define	SCSICONF        		0x5a
+#define		HWSCSIID        	0x0f
+#define		HSCSIID         	0x07
 #define		TERM_ENB        	0x80
 #define		RESET_SCSI      	0x40
 #define		ENSPCHK         	0x20
-#define		HWSCSIID        	0x0f
-#define		HSCSIID         	0x07
 
 #define	INTDEF          		0x5c
-#define		EDGE_TRIG       	0x80
 #define		VECTOR          	0x0f
+#define		EDGE_TRIG       	0x80
 
 #define	HOSTCONF        		0x5d
 
@@ -464,13 +1526,13 @@
 #define		PDATA_REINIT    	0x51
 #define		IGN_WIDE_RES    	0x41
 #define		NO_MATCH        	0x31
-#define		NO_IDENT        	0x21
+#define		PROTO_VIOLATION 	0x21
 #define		SEND_REJECT     	0x11
 #define		INT_PEND        	0x0f
+#define		BAD_PHASE       	0x01
 #define		BRKADRINT       	0x08
 #define		SCSIINT         	0x04
 #define		CMDCMPLT        	0x02
-#define		BAD_PHASE       	0x01
 #define		SEQINT          	0x01
 
 #define	CLRINT          		0x92
@@ -509,8 +1571,8 @@
 #define	DFDAT           		0x99
 
 #define	SCBCNT          		0x9a
-#define		SCBAUTO         	0x80
 #define		SCBCNT_MASK     	0x1f
+#define		SCBAUTO         	0x80
 
 #define	QINFIFO         		0x9b
 
@@ -529,11 +1591,11 @@
 #define	QOUTCNT         		0x9e
 
 #define	SCSIPHASE       		0x9e
+#define		DATA_PHASE_MASK 	0x03
 #define		STATUS_PHASE    	0x20
 #define		COMMAND_PHASE   	0x10
 #define		MSG_IN_PHASE    	0x08
 #define		MSG_OUT_PHASE   	0x04
-#define		DATA_PHASE_MASK 	0x03
 #define		DATA_IN_PHASE   	0x02
 #define		DATA_OUT_PHASE  	0x01
 
@@ -559,8 +1621,8 @@
 #define	SCB_DATAPTR     		0xac
 
 #define	SCB_DATACNT     		0xb0
-#define		SG_LAST_SEG     	0x80
 #define		SG_HIGH_ADDR_BITS	0x7f
+#define		SG_LAST_SEG     	0x80
 
 #define	SCB_SGPTR       		0xb4
 #define		SG_RESID_VALID  	0x04
@@ -568,22 +1630,24 @@
 #define		SG_LIST_NULL    	0x01
 
 #define	SCB_CONTROL     		0xb8
+#define		SCB_TAG_TYPE    	0x03
+#define		STATUS_RCVD     	0x80
 #define		TARGET_SCB      	0x80
 #define		DISCENB         	0x40
 #define		TAG_ENB         	0x20
 #define		MK_MESSAGE      	0x10
 #define		ULTRAENB        	0x08
 #define		DISCONNECTED    	0x04
-#define		SCB_TAG_TYPE    	0x03
 
 #define	SCB_SCSIID      		0xb9
 #define		TID             	0xf0
-#define		TWIN_CHNLB      	0x80
 #define		TWIN_TID        	0x70
 #define		OID             	0x0f
+#define		TWIN_CHNLB      	0x80
 
 #define	SCB_LUN         		0xba
-#define		LID             	0xff
+#define		LID             	0x3f
+#define		SCB_XFERLEN_ODD 	0x80
 
 #define	SCB_TAG         		0xbb
 
@@ -603,9 +1667,9 @@
 #define		DO_2840         	0x01
 
 #define	STATUS_2840     		0xc1
-#define		EEPROM_TF       	0x80
 #define		BIOS_SEL        	0x60
 #define		ADSEL           	0x1e
+#define		EEPROM_TF       	0x80
 #define		DI_2840         	0x01
 
 #define	SCB_64_BTT      		0xd0
@@ -649,11 +1713,11 @@
 #define	SDSCB_QOFF      		0xf8
 
 #define	QOFF_CTLSTA     		0xfa
+#define		SCB_QSIZE       	0x07
+#define		SCB_QSIZE_256   	0x06
 #define		SCB_AVAIL       	0x40
 #define		SNSCB_ROLLOVER  	0x20
 #define		SDSCB_ROLLOVER  	0x10
-#define		SCB_QSIZE       	0x07
-#define		SCB_QSIZE_256   	0x06
 
 #define	DFF_THRSH       		0xfb
 #define		WR_DFTHRSH      	0x70
@@ -677,7 +1741,6 @@
 
 #define	SG_CACHE_SHADOW 		0xfc
 #define		SG_ADDR_MASK    	0xf8
-#define		ODD_SEG         	0x04
 #define		LAST_SEG        	0x02
 #define		LAST_SEG_DONE   	0x01
 
@@ -704,8 +1767,10 @@
 #define	SEQ_MAILBOX_SHIFT	0x00
 #define	TARGET_DATA_IN	0x01
 #define	HOST_MSG	0xff
+#define	MAX_OFFSET	0x7f
 #define	BUS_16_BIT	0x01
 #define	SCB_UPLOAD_SIZE	0x20
+#define	STACK_SIZE	0x04
 
 
 /* Downloaded Constant Definitions */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_reg_print.c linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_reg_print.c
--- linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_reg_print.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_reg_print.c	2003-06-26 21:43:14.000000000 +0000
@@ -0,0 +1,1681 @@
+/*
+ * DO NOT EDIT - This file is automatically generated
+ *		 from the following source files:
+ *
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.seq#56 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.reg#39 $
+ */
+
+#include "aic7xxx_osm.h"
+
+static ahc_reg_parse_entry_t SCSISEQ_parse_table[] = {
+	{ "SCSIRSTO",		0x01, 0x01 },
+	{ "ENAUTOATNP",		0x02, 0x02 },
+	{ "ENAUTOATNI",		0x04, 0x04 },
+	{ "ENAUTOATNO",		0x08, 0x08 },
+	{ "ENRSELI",		0x10, 0x10 },
+	{ "ENSELI",		0x20, 0x20 },
+	{ "ENSELO",		0x40, 0x40 },
+	{ "TEMODE",		0x80, 0x80 }
+};
+
+int
+ahc_scsiseq_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SCSISEQ_parse_table, 8, "SCSISEQ",
+	    0x00, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SXFRCTL0_parse_table[] = {
+	{ "CLRCHN",		0x02, 0x02 },
+	{ "SCAMEN",		0x04, 0x04 },
+	{ "SPIOEN",		0x08, 0x08 },
+	{ "CLRSTCNT",		0x10, 0x10 },
+	{ "FAST20",		0x20, 0x20 },
+	{ "DFPEXP",		0x40, 0x40 },
+	{ "DFON",		0x80, 0x80 }
+};
+
+int
+ahc_sxfrctl0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SXFRCTL0_parse_table, 7, "SXFRCTL0",
+	    0x01, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SXFRCTL1_parse_table[] = {
+	{ "STPWEN",		0x01, 0x01 },
+	{ "ACTNEGEN",		0x02, 0x02 },
+	{ "ENSTIMER",		0x04, 0x04 },
+	{ "ENSPCHK",		0x20, 0x20 },
+	{ "SWRAPEN",		0x40, 0x40 },
+	{ "BITBUCKET",		0x80, 0x80 },
+	{ "STIMESEL",		0x18, 0x18 }
+};
+
+int
+ahc_sxfrctl1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SXFRCTL1_parse_table, 7, "SXFRCTL1",
+	    0x02, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SCSISIGO_parse_table[] = {
+	{ "ACKO",		0x01, 0x01 },
+	{ "REQO",		0x02, 0x02 },
+	{ "BSYO",		0x04, 0x04 },
+	{ "SELO",		0x08, 0x08 },
+	{ "ATNO",		0x10, 0x10 },
+	{ "MSGO",		0x20, 0x20 },
+	{ "IOO",		0x40, 0x40 },
+	{ "CDO",		0x80, 0x80 },
+	{ "P_DATAOUT",		0x00, 0x00 },
+	{ "P_DATAIN",		0x40, 0x40 },
+	{ "P_COMMAND",		0x80, 0x80 },
+	{ "P_MESGOUT",		0xa0, 0xa0 },
+	{ "P_STATUS",		0xc0, 0xc0 },
+	{ "PHASE_MASK",		0xe0, 0xe0 },
+	{ "P_MESGIN",		0xe0, 0xe0 }
+};
+
+int
+ahc_scsisigo_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SCSISIGO_parse_table, 15, "SCSISIGO",
+	    0x03, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SCSISIGI_parse_table[] = {
+	{ "ACKI",		0x01, 0x01 },
+	{ "REQI",		0x02, 0x02 },
+	{ "BSYI",		0x04, 0x04 },
+	{ "SELI",		0x08, 0x08 },
+	{ "ATNI",		0x10, 0x10 },
+	{ "MSGI",		0x20, 0x20 },
+	{ "IOI",		0x40, 0x40 },
+	{ "CDI",		0x80, 0x80 },
+	{ "P_DATAOUT",		0x00, 0x00 },
+	{ "P_DATAOUT_DT",	0x20, 0x20 },
+	{ "P_DATAIN",		0x40, 0x40 },
+	{ "P_DATAIN_DT",	0x60, 0x60 },
+	{ "P_COMMAND",		0x80, 0x80 },
+	{ "P_MESGOUT",		0xa0, 0xa0 },
+	{ "P_STATUS",		0xc0, 0xc0 },
+	{ "PHASE_MASK",		0xe0, 0xe0 },
+	{ "P_MESGIN",		0xe0, 0xe0 }
+};
+
+int
+ahc_scsisigi_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SCSISIGI_parse_table, 17, "SCSISIGI",
+	    0x03, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SCSIRATE_parse_table[] = {
+	{ "SINGLE_EDGE",	0x10, 0x10 },
+	{ "ENABLE_CRC",		0x40, 0x40 },
+	{ "WIDEXFER",		0x80, 0x80 },
+	{ "SXFR_ULTRA2",	0x0f, 0x0f },
+	{ "SOFS",		0x0f, 0x0f },
+	{ "SXFR",		0x70, 0x70 }
+};
+
+int
+ahc_scsirate_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SCSIRATE_parse_table, 6, "SCSIRATE",
+	    0x04, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SCSIID_parse_table[] = {
+	{ "TWIN_CHNLB",		0x80, 0x80 },
+	{ "OID",		0x0f, 0x0f },
+	{ "TWIN_TID",		0x70, 0x70 },
+	{ "SOFS_ULTRA2",	0x7f, 0x7f },
+	{ "TID",		0xf0, 0xf0 }
+};
+
+int
+ahc_scsiid_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SCSIID_parse_table, 5, "SCSIID",
+	    0x05, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scsidatl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCSIDATL",
+	    0x06, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scsidath_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCSIDATH",
+	    0x07, regvalue, cur_col, wrap));
+}
+
+int
+ahc_stcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "STCNT",
+	    0x08, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t OPTIONMODE_parse_table[] = {
+	{ "DIS_MSGIN_DUALEDGE",	0x01, 0x01 },
+	{ "AUTO_MSGOUT_DE",	0x02, 0x02 },
+	{ "SCSIDATL_IMGEN",	0x04, 0x04 },
+	{ "EXPPHASEDIS",	0x08, 0x08 },
+	{ "BUSFREEREV",		0x10, 0x10 },
+	{ "ATNMGMNTEN",		0x20, 0x20 },
+	{ "AUTOACKEN",		0x40, 0x40 },
+	{ "AUTORATEEN",		0x80, 0x80 },
+	{ "OPTIONMODE_DEFAULTS",0x03, 0x03 }
+};
+
+int
+ahc_optionmode_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(OPTIONMODE_parse_table, 9, "OPTIONMODE",
+	    0x08, regvalue, cur_col, wrap));
+}
+
+int
+ahc_targcrccnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "TARGCRCCNT",
+	    0x0a, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t CLRSINT0_parse_table[] = {
+	{ "CLRSPIORDY",		0x02, 0x02 },
+	{ "CLRSWRAP",		0x08, 0x08 },
+	{ "CLRIOERR",		0x08, 0x08 },
+	{ "CLRSELINGO",		0x10, 0x10 },
+	{ "CLRSELDI",		0x20, 0x20 },
+	{ "CLRSELDO",		0x40, 0x40 }
+};
+
+int
+ahc_clrsint0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(CLRSINT0_parse_table, 6, "CLRSINT0",
+	    0x0b, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SSTAT0_parse_table[] = {
+	{ "DMADONE",		0x01, 0x01 },
+	{ "SPIORDY",		0x02, 0x02 },
+	{ "SDONE",		0x04, 0x04 },
+	{ "SWRAP",		0x08, 0x08 },
+	{ "IOERR",		0x08, 0x08 },
+	{ "SELINGO",		0x10, 0x10 },
+	{ "SELDI",		0x20, 0x20 },
+	{ "SELDO",		0x40, 0x40 },
+	{ "TARGET",		0x80, 0x80 }
+};
+
+int
+ahc_sstat0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SSTAT0_parse_table, 9, "SSTAT0",
+	    0x0b, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t CLRSINT1_parse_table[] = {
+	{ "CLRREQINIT",		0x01, 0x01 },
+	{ "CLRPHASECHG",	0x02, 0x02 },
+	{ "CLRSCSIPERR",	0x04, 0x04 },
+	{ "CLRBUSFREE",		0x08, 0x08 },
+	{ "CLRSCSIRSTI",	0x20, 0x20 },
+	{ "CLRATNO",		0x40, 0x40 },
+	{ "CLRSELTIMEO",	0x80, 0x80 }
+};
+
+int
+ahc_clrsint1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(CLRSINT1_parse_table, 7, "CLRSINT1",
+	    0x0c, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SSTAT1_parse_table[] = {
+	{ "REQINIT",		0x01, 0x01 },
+	{ "PHASECHG",		0x02, 0x02 },
+	{ "SCSIPERR",		0x04, 0x04 },
+	{ "BUSFREE",		0x08, 0x08 },
+	{ "PHASEMIS",		0x10, 0x10 },
+	{ "SCSIRSTI",		0x20, 0x20 },
+	{ "ATNTARG",		0x40, 0x40 },
+	{ "SELTO",		0x80, 0x80 }
+};
+
+int
+ahc_sstat1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SSTAT1_parse_table, 8, "SSTAT1",
+	    0x0c, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SSTAT2_parse_table[] = {
+	{ "DUAL_EDGE_ERR",	0x01, 0x01 },
+	{ "CRCREQERR",		0x02, 0x02 },
+	{ "CRCENDERR",		0x04, 0x04 },
+	{ "CRCVALERR",		0x08, 0x08 },
+	{ "EXP_ACTIVE",		0x10, 0x10 },
+	{ "SHVALID",		0x40, 0x40 },
+	{ "OVERRUN",		0x80, 0x80 },
+	{ "SFCNT",		0x1f, 0x1f }
+};
+
+int
+ahc_sstat2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SSTAT2_parse_table, 8, "SSTAT2",
+	    0x0d, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SSTAT3_parse_table[] = {
+	{ "OFFCNT",		0x0f, 0x0f },
+	{ "U2OFFCNT",		0x7f, 0x7f },
+	{ "SCSICNT",		0xf0, 0xf0 }
+};
+
+int
+ahc_sstat3_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SSTAT3_parse_table, 3, "SSTAT3",
+	    0x0e, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SCSIID_ULTRA2_parse_table[] = {
+	{ "OID",		0x0f, 0x0f },
+	{ "TID",		0xf0, 0xf0 }
+};
+
+int
+ahc_scsiid_ultra2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SCSIID_ULTRA2_parse_table, 2, "SCSIID_ULTRA2",
+	    0x0f, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SIMODE0_parse_table[] = {
+	{ "ENDMADONE",		0x01, 0x01 },
+	{ "ENSPIORDY",		0x02, 0x02 },
+	{ "ENSDONE",		0x04, 0x04 },
+	{ "ENSWRAP",		0x08, 0x08 },
+	{ "ENIOERR",		0x08, 0x08 },
+	{ "ENSELINGO",		0x10, 0x10 },
+	{ "ENSELDI",		0x20, 0x20 },
+	{ "ENSELDO",		0x40, 0x40 }
+};
+
+int
+ahc_simode0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SIMODE0_parse_table, 8, "SIMODE0",
+	    0x10, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SIMODE1_parse_table[] = {
+	{ "ENREQINIT",		0x01, 0x01 },
+	{ "ENPHASECHG",		0x02, 0x02 },
+	{ "ENSCSIPERR",		0x04, 0x04 },
+	{ "ENBUSFREE",		0x08, 0x08 },
+	{ "ENPHASEMIS",		0x10, 0x10 },
+	{ "ENSCSIRST",		0x20, 0x20 },
+	{ "ENATNTARG",		0x40, 0x40 },
+	{ "ENSELTIMO",		0x80, 0x80 }
+};
+
+int
+ahc_simode1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SIMODE1_parse_table, 8, "SIMODE1",
+	    0x11, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scsibusl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCSIBUSL",
+	    0x12, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scsibush_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCSIBUSH",
+	    0x13, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SXFRCTL2_parse_table[] = {
+	{ "CMDDMAEN",		0x08, 0x08 },
+	{ "AUTORSTDIS",		0x10, 0x10 },
+	{ "ASYNC_SETUP",	0x07, 0x07 }
+};
+
+int
+ahc_sxfrctl2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SXFRCTL2_parse_table, 3, "SXFRCTL2",
+	    0x13, regvalue, cur_col, wrap));
+}
+
+int
+ahc_shaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SHADDR",
+	    0x14, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SELTIMER_parse_table[] = {
+	{ "STAGE1",		0x01, 0x01 },
+	{ "STAGE2",		0x02, 0x02 },
+	{ "STAGE3",		0x04, 0x04 },
+	{ "STAGE4",		0x08, 0x08 },
+	{ "STAGE5",		0x10, 0x10 },
+	{ "STAGE6",		0x20, 0x20 }
+};
+
+int
+ahc_seltimer_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SELTIMER_parse_table, 6, "SELTIMER",
+	    0x18, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SELID_parse_table[] = {
+	{ "ONEBIT",		0x08, 0x08 },
+	{ "SELID_MASK",		0xf0, 0xf0 }
+};
+
+int
+ahc_selid_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SELID_parse_table, 2, "SELID",
+	    0x19, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SCAMCTL_parse_table[] = {
+	{ "DFLTTID",		0x10, 0x10 },
+	{ "ALTSTIM",		0x20, 0x20 },
+	{ "CLRSCAMSELID",	0x40, 0x40 },
+	{ "ENSCAMSELO",		0x80, 0x80 },
+	{ "SCAMLVL",		0x03, 0x03 }
+};
+
+int
+ahc_scamctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SCAMCTL_parse_table, 5, "SCAMCTL",
+	    0x1a, regvalue, cur_col, wrap));
+}
+
+int
+ahc_targid_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "TARGID",
+	    0x1b, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SPIOCAP_parse_table[] = {
+	{ "SSPIOCPS",		0x01, 0x01 },
+	{ "ROM",		0x02, 0x02 },
+	{ "EEPROM",		0x04, 0x04 },
+	{ "SEEPROM",		0x08, 0x08 },
+	{ "EXT_BRDCTL",		0x10, 0x10 },
+	{ "SOFTCMDEN",		0x20, 0x20 },
+	{ "SOFT0",		0x40, 0x40 },
+	{ "SOFT1",		0x80, 0x80 }
+};
+
+int
+ahc_spiocap_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SPIOCAP_parse_table, 8, "SPIOCAP",
+	    0x1b, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t BRDCTL_parse_table[] = {
+	{ "BRDCTL0",		0x01, 0x01 },
+	{ "BRDSTB_ULTRA2",	0x01, 0x01 },
+	{ "BRDCTL1",		0x02, 0x02 },
+	{ "BRDRW_ULTRA2",	0x02, 0x02 },
+	{ "BRDRW",		0x04, 0x04 },
+	{ "BRDDAT2",		0x04, 0x04 },
+	{ "BRDCS",		0x08, 0x08 },
+	{ "BRDDAT3",		0x08, 0x08 },
+	{ "BRDSTB",		0x10, 0x10 },
+	{ "BRDDAT4",		0x10, 0x10 },
+	{ "BRDDAT5",		0x20, 0x20 },
+	{ "BRDDAT6",		0x40, 0x40 },
+	{ "BRDDAT7",		0x80, 0x80 }
+};
+
+int
+ahc_brdctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(BRDCTL_parse_table, 13, "BRDCTL",
+	    0x1d, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SEECTL_parse_table[] = {
+	{ "SEEDI",		0x01, 0x01 },
+	{ "SEEDO",		0x02, 0x02 },
+	{ "SEECK",		0x04, 0x04 },
+	{ "SEECS",		0x08, 0x08 },
+	{ "SEERDY",		0x10, 0x10 },
+	{ "SEEMS",		0x20, 0x20 },
+	{ "EXTARBREQ",		0x40, 0x40 },
+	{ "EXTARBACK",		0x80, 0x80 }
+};
+
+int
+ahc_seectl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SEECTL_parse_table, 8, "SEECTL",
+	    0x1e, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SBLKCTL_parse_table[] = {
+	{ "XCVR",		0x01, 0x01 },
+	{ "SELWIDE",		0x02, 0x02 },
+	{ "ENAB20",		0x04, 0x04 },
+	{ "SELBUSB",		0x08, 0x08 },
+	{ "ENAB40",		0x08, 0x08 },
+	{ "AUTOFLUSHDIS",	0x20, 0x20 },
+	{ "DIAGLEDON",		0x40, 0x40 },
+	{ "DIAGLEDEN",		0x80, 0x80 }
+};
+
+int
+ahc_sblkctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SBLKCTL_parse_table, 8, "SBLKCTL",
+	    0x1f, regvalue, cur_col, wrap));
+}
+
+int
+ahc_busy_targets_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "BUSY_TARGETS",
+	    0x20, regvalue, cur_col, wrap));
+}
+
+int
+ahc_ultra_enb_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "ULTRA_ENB",
+	    0x30, regvalue, cur_col, wrap));
+}
+
+int
+ahc_disc_dsb_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "DISC_DSB",
+	    0x32, regvalue, cur_col, wrap));
+}
+
+int
+ahc_cmdsize_table_tail_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "CMDSIZE_TABLE_TAIL",
+	    0x34, regvalue, cur_col, wrap));
+}
+
+int
+ahc_mwi_residual_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "MWI_RESIDUAL",
+	    0x38, regvalue, cur_col, wrap));
+}
+
+int
+ahc_next_queued_scb_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "NEXT_QUEUED_SCB",
+	    0x39, regvalue, cur_col, wrap));
+}
+
+int
+ahc_msg_out_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "MSG_OUT",
+	    0x3a, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t DMAPARAMS_parse_table[] = {
+	{ "FIFORESET",		0x01, 0x01 },
+	{ "FIFOFLUSH",		0x02, 0x02 },
+	{ "DIRECTION",		0x04, 0x04 },
+	{ "HDMAEN",		0x08, 0x08 },
+	{ "HDMAENACK",		0x08, 0x08 },
+	{ "SDMAEN",		0x10, 0x10 },
+	{ "SDMAENACK",		0x10, 0x10 },
+	{ "SCSIEN",		0x20, 0x20 },
+	{ "WIDEODD",		0x40, 0x40 },
+	{ "PRELOADEN",		0x80, 0x80 }
+};
+
+int
+ahc_dmaparams_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(DMAPARAMS_parse_table, 10, "DMAPARAMS",
+	    0x3b, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SEQ_FLAGS_parse_table[] = {
+	{ "NO_DISCONNECT",	0x01, 0x01 },
+	{ "SPHASE_PENDING",	0x02, 0x02 },
+	{ "DPHASE_PENDING",	0x04, 0x04 },
+	{ "CMDPHASE_PENDING",	0x08, 0x08 },
+	{ "TARG_CMD_PENDING",	0x10, 0x10 },
+	{ "DPHASE",		0x20, 0x20 },
+	{ "NO_CDB_SENT",	0x40, 0x40 },
+	{ "TARGET_CMD_IS_TAGGED",0x40, 0x40 },
+	{ "NOT_IDENTIFIED",	0x80, 0x80 }
+};
+
+int
+ahc_seq_flags_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SEQ_FLAGS_parse_table, 9, "SEQ_FLAGS",
+	    0x3c, regvalue, cur_col, wrap));
+}
+
+int
+ahc_saved_scsiid_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SAVED_SCSIID",
+	    0x3d, regvalue, cur_col, wrap));
+}
+
+int
+ahc_saved_lun_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SAVED_LUN",
+	    0x3e, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t LASTPHASE_parse_table[] = {
+	{ "MSGI",		0x20, 0x20 },
+	{ "IOI",		0x40, 0x40 },
+	{ "CDI",		0x80, 0x80 },
+	{ "P_DATAOUT",		0x00, 0x00 },
+	{ "P_BUSFREE",		0x01, 0x01 },
+	{ "P_DATAIN",		0x40, 0x40 },
+	{ "P_COMMAND",		0x80, 0x80 },
+	{ "P_MESGOUT",		0xa0, 0xa0 },
+	{ "P_STATUS",		0xc0, 0xc0 },
+	{ "PHASE_MASK",		0xe0, 0xe0 },
+	{ "P_MESGIN",		0xe0, 0xe0 }
+};
+
+int
+ahc_lastphase_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(LASTPHASE_parse_table, 11, "LASTPHASE",
+	    0x3f, regvalue, cur_col, wrap));
+}
+
+int
+ahc_waiting_scbh_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "WAITING_SCBH",
+	    0x40, regvalue, cur_col, wrap));
+}
+
+int
+ahc_disconnected_scbh_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "DISCONNECTED_SCBH",
+	    0x41, regvalue, cur_col, wrap));
+}
+
+int
+ahc_free_scbh_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "FREE_SCBH",
+	    0x42, regvalue, cur_col, wrap));
+}
+
+int
+ahc_complete_scbh_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "COMPLETE_SCBH",
+	    0x43, regvalue, cur_col, wrap));
+}
+
+int
+ahc_hscb_addr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "HSCB_ADDR",
+	    0x44, regvalue, cur_col, wrap));
+}
+
+int
+ahc_shared_data_addr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SHARED_DATA_ADDR",
+	    0x48, regvalue, cur_col, wrap));
+}
+
+int
+ahc_kernel_qinpos_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "KERNEL_QINPOS",
+	    0x4c, regvalue, cur_col, wrap));
+}
+
+int
+ahc_qinpos_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "QINPOS",
+	    0x4d, regvalue, cur_col, wrap));
+}
+
+int
+ahc_qoutpos_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "QOUTPOS",
+	    0x4e, regvalue, cur_col, wrap));
+}
+
+int
+ahc_kernel_tqinpos_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "KERNEL_TQINPOS",
+	    0x4f, regvalue, cur_col, wrap));
+}
+
+int
+ahc_tqinpos_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "TQINPOS",
+	    0x50, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t ARG_1_parse_table[] = {
+	{ "CONT_TARG_SESSION",	0x02, 0x02 },
+	{ "CONT_MSG_LOOP",	0x04, 0x04 },
+	{ "EXIT_MSG_LOOP",	0x08, 0x08 },
+	{ "MSGOUT_PHASEMIS",	0x10, 0x10 },
+	{ "SEND_REJ",		0x20, 0x20 },
+	{ "SEND_SENSE",		0x40, 0x40 },
+	{ "SEND_MSG",		0x80, 0x80 }
+};
+
+int
+ahc_arg_1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(ARG_1_parse_table, 7, "ARG_1",
+	    0x51, regvalue, cur_col, wrap));
+}
+
+int
+ahc_arg_2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "ARG_2",
+	    0x52, regvalue, cur_col, wrap));
+}
+
+int
+ahc_last_msg_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "LAST_MSG",
+	    0x53, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SCSISEQ_TEMPLATE_parse_table[] = {
+	{ "ENAUTOATNP",		0x02, 0x02 },
+	{ "ENAUTOATNI",		0x04, 0x04 },
+	{ "ENAUTOATNO",		0x08, 0x08 },
+	{ "ENRSELI",		0x10, 0x10 },
+	{ "ENSELI",		0x20, 0x20 },
+	{ "ENSELO",		0x40, 0x40 }
+};
+
+int
+ahc_scsiseq_template_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SCSISEQ_TEMPLATE_parse_table, 6, "SCSISEQ_TEMPLATE",
+	    0x54, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t HA_274_BIOSGLOBAL_parse_table[] = {
+	{ "HA_274_EXTENDED_TRANS",0x01, 0x01 }
+};
+
+int
+ahc_ha_274_biosglobal_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(HA_274_BIOSGLOBAL_parse_table, 1, "HA_274_BIOSGLOBAL",
+	    0x56, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SEQ_FLAGS2_parse_table[] = {
+	{ "SCB_DMA",		0x01, 0x01 },
+	{ "TARGET_MSG_PENDING",	0x02, 0x02 }
+};
+
+int
+ahc_seq_flags2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SEQ_FLAGS2_parse_table, 2, "SEQ_FLAGS2",
+	    0x57, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SCSICONF_parse_table[] = {
+	{ "ENSPCHK",		0x20, 0x20 },
+	{ "RESET_SCSI",		0x40, 0x40 },
+	{ "TERM_ENB",		0x80, 0x80 },
+	{ "HSCSIID",		0x07, 0x07 },
+	{ "HWSCSIID",		0x0f, 0x0f }
+};
+
+int
+ahc_scsiconf_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SCSICONF_parse_table, 5, "SCSICONF",
+	    0x5a, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t INTDEF_parse_table[] = {
+	{ "EDGE_TRIG",		0x80, 0x80 },
+	{ "VECTOR",		0x0f, 0x0f }
+};
+
+int
+ahc_intdef_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(INTDEF_parse_table, 2, "INTDEF",
+	    0x5c, regvalue, cur_col, wrap));
+}
+
+int
+ahc_hostconf_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "HOSTCONF",
+	    0x5d, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t HA_274_BIOSCTRL_parse_table[] = {
+	{ "CHANNEL_B_PRIMARY",	0x08, 0x08 },
+	{ "BIOSMODE",		0x30, 0x30 },
+	{ "BIOSDISABLED",	0x30, 0x30 }
+};
+
+int
+ahc_ha_274_biosctrl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(HA_274_BIOSCTRL_parse_table, 3, "HA_274_BIOSCTRL",
+	    0x5f, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SEQCTL_parse_table[] = {
+	{ "LOADRAM",		0x01, 0x01 },
+	{ "SEQRESET",		0x02, 0x02 },
+	{ "STEP",		0x04, 0x04 },
+	{ "BRKADRINTEN",	0x08, 0x08 },
+	{ "FASTMODE",		0x10, 0x10 },
+	{ "FAILDIS",		0x20, 0x20 },
+	{ "PAUSEDIS",		0x40, 0x40 },
+	{ "PERRORDIS",		0x80, 0x80 }
+};
+
+int
+ahc_seqctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SEQCTL_parse_table, 8, "SEQCTL",
+	    0x60, regvalue, cur_col, wrap));
+}
+
+int
+ahc_seqram_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SEQRAM",
+	    0x61, regvalue, cur_col, wrap));
+}
+
+int
+ahc_seqaddr0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SEQADDR0",
+	    0x62, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SEQADDR1_parse_table[] = {
+	{ "SEQADDR1_MASK",	0x01, 0x01 }
+};
+
+int
+ahc_seqaddr1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SEQADDR1_parse_table, 1, "SEQADDR1",
+	    0x63, regvalue, cur_col, wrap));
+}
+
+int
+ahc_accum_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "ACCUM",
+	    0x64, regvalue, cur_col, wrap));
+}
+
+int
+ahc_sindex_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SINDEX",
+	    0x65, regvalue, cur_col, wrap));
+}
+
+int
+ahc_dindex_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "DINDEX",
+	    0x66, regvalue, cur_col, wrap));
+}
+
+int
+ahc_allones_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "ALLONES",
+	    0x69, regvalue, cur_col, wrap));
+}
+
+int
+ahc_allzeros_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "ALLZEROS",
+	    0x6a, regvalue, cur_col, wrap));
+}
+
+int
+ahc_none_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "NONE",
+	    0x6a, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t FLAGS_parse_table[] = {
+	{ "CARRY",		0x01, 0x01 },
+	{ "ZERO",		0x02, 0x02 }
+};
+
+int
+ahc_flags_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(FLAGS_parse_table, 2, "FLAGS",
+	    0x6b, regvalue, cur_col, wrap));
+}
+
+int
+ahc_sindir_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SINDIR",
+	    0x6c, regvalue, cur_col, wrap));
+}
+
+int
+ahc_dindir_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "DINDIR",
+	    0x6d, regvalue, cur_col, wrap));
+}
+
+int
+ahc_function1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "FUNCTION1",
+	    0x6e, regvalue, cur_col, wrap));
+}
+
+int
+ahc_stack_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "STACK",
+	    0x6f, regvalue, cur_col, wrap));
+}
+
+int
+ahc_targ_offset_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "TARG_OFFSET",
+	    0x70, regvalue, cur_col, wrap));
+}
+
+int
+ahc_sram_base_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SRAM_BASE",
+	    0x70, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t BCTL_parse_table[] = {
+	{ "ENABLE",		0x01, 0x01 },
+	{ "ACE",		0x08, 0x08 }
+};
+
+int
+ahc_bctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(BCTL_parse_table, 2, "BCTL",
+	    0x84, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t DSCOMMAND0_parse_table[] = {
+	{ "CIOPARCKEN",		0x01, 0x01 },
+	{ "USCBSIZE32",		0x02, 0x02 },
+	{ "RAMPS",		0x04, 0x04 },
+	{ "INTSCBRAMSEL",	0x08, 0x08 },
+	{ "EXTREQLCK",		0x10, 0x10 },
+	{ "MPARCKEN",		0x20, 0x20 },
+	{ "DPARCKEN",		0x40, 0x40 },
+	{ "CACHETHEN",		0x80, 0x80 }
+};
+
+int
+ahc_dscommand0_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(DSCOMMAND0_parse_table, 8, "DSCOMMAND0",
+	    0x84, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t BUSTIME_parse_table[] = {
+	{ "BON",		0x0f, 0x0f },
+	{ "BOFF",		0xf0, 0xf0 }
+};
+
+int
+ahc_bustime_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(BUSTIME_parse_table, 2, "BUSTIME",
+	    0x85, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t DSCOMMAND1_parse_table[] = {
+	{ "HADDLDSEL0",		0x01, 0x01 },
+	{ "HADDLDSEL1",		0x02, 0x02 },
+	{ "DSLATT",		0xfc, 0xfc }
+};
+
+int
+ahc_dscommand1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(DSCOMMAND1_parse_table, 3, "DSCOMMAND1",
+	    0x85, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t BUSSPD_parse_table[] = {
+	{ "STBON",		0x07, 0x07 },
+	{ "STBOFF",		0x38, 0x38 },
+	{ "DFTHRSH_75",		0x80, 0x80 },
+	{ "DFTHRSH",		0xc0, 0xc0 },
+	{ "DFTHRSH_100",	0xc0, 0xc0 }
+};
+
+int
+ahc_busspd_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(BUSSPD_parse_table, 5, "BUSSPD",
+	    0x86, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t HS_MAILBOX_parse_table[] = {
+	{ "SEQ_MAILBOX",	0x0f, 0x0f },
+	{ "HOST_TQINPOS",	0x80, 0x80 },
+	{ "HOST_MAILBOX",	0xf0, 0xf0 }
+};
+
+int
+ahc_hs_mailbox_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(HS_MAILBOX_parse_table, 3, "HS_MAILBOX",
+	    0x86, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t DSPCISTATUS_parse_table[] = {
+	{ "DFTHRSH_100",	0xc0, 0xc0 }
+};
+
+int
+ahc_dspcistatus_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(DSPCISTATUS_parse_table, 1, "DSPCISTATUS",
+	    0x86, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t HCNTRL_parse_table[] = {
+	{ "CHIPRST",		0x01, 0x01 },
+	{ "CHIPRSTACK",		0x01, 0x01 },
+	{ "INTEN",		0x02, 0x02 },
+	{ "PAUSE",		0x04, 0x04 },
+	{ "IRQMS",		0x08, 0x08 },
+	{ "SWINT",		0x10, 0x10 },
+	{ "POWRDN",		0x40, 0x40 }
+};
+
+int
+ahc_hcntrl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(HCNTRL_parse_table, 7, "HCNTRL",
+	    0x87, regvalue, cur_col, wrap));
+}
+
+int
+ahc_haddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "HADDR",
+	    0x88, regvalue, cur_col, wrap));
+}
+
+int
+ahc_hcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "HCNT",
+	    0x8c, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scbptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCBPTR",
+	    0x90, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t INTSTAT_parse_table[] = {
+	{ "SEQINT",		0x01, 0x01 },
+	{ "CMDCMPLT",		0x02, 0x02 },
+	{ "SCSIINT",		0x04, 0x04 },
+	{ "BRKADRINT",		0x08, 0x08 },
+	{ "BAD_PHASE",		0x01, 0x01 },
+	{ "INT_PEND",		0x0f, 0x0f },
+	{ "SEND_REJECT",	0x11, 0x11 },
+	{ "PROTO_VIOLATION",	0x21, 0x21 },
+	{ "NO_MATCH",		0x31, 0x31 },
+	{ "IGN_WIDE_RES",	0x41, 0x41 },
+	{ "PDATA_REINIT",	0x51, 0x51 },
+	{ "HOST_MSG_LOOP",	0x61, 0x61 },
+	{ "BAD_STATUS",		0x71, 0x71 },
+	{ "PERR_DETECTED",	0x81, 0x81 },
+	{ "DATA_OVERRUN",	0x91, 0x91 },
+	{ "MKMSG_FAILED",	0xa1, 0xa1 },
+	{ "MISSED_BUSFREE",	0xb1, 0xb1 },
+	{ "SCB_MISMATCH",	0xc1, 0xc1 },
+	{ "NO_FREE_SCB",	0xd1, 0xd1 },
+	{ "OUT_OF_RANGE",	0xe1, 0xe1 },
+	{ "SEQINT_MASK",	0xf1, 0xf1 }
+};
+
+int
+ahc_intstat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(INTSTAT_parse_table, 21, "INTSTAT",
+	    0x91, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t CLRINT_parse_table[] = {
+	{ "CLRSEQINT",		0x01, 0x01 },
+	{ "CLRCMDINT",		0x02, 0x02 },
+	{ "CLRSCSIINT",		0x04, 0x04 },
+	{ "CLRBRKADRINT",	0x08, 0x08 },
+	{ "CLRPARERR",		0x10, 0x10 }
+};
+
+int
+ahc_clrint_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(CLRINT_parse_table, 5, "CLRINT",
+	    0x92, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t ERROR_parse_table[] = {
+	{ "ILLHADDR",		0x01, 0x01 },
+	{ "ILLSADDR",		0x02, 0x02 },
+	{ "ILLOPCODE",		0x04, 0x04 },
+	{ "SQPARERR",		0x08, 0x08 },
+	{ "DPARERR",		0x10, 0x10 },
+	{ "MPARERR",		0x20, 0x20 },
+	{ "PCIERRSTAT",		0x40, 0x40 },
+	{ "CIOPARERR",		0x80, 0x80 }
+};
+
+int
+ahc_error_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(ERROR_parse_table, 8, "ERROR",
+	    0x92, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t DFCNTRL_parse_table[] = {
+	{ "FIFORESET",		0x01, 0x01 },
+	{ "FIFOFLUSH",		0x02, 0x02 },
+	{ "DIRECTION",		0x04, 0x04 },
+	{ "HDMAEN",		0x08, 0x08 },
+	{ "HDMAENACK",		0x08, 0x08 },
+	{ "SDMAEN",		0x10, 0x10 },
+	{ "SDMAENACK",		0x10, 0x10 },
+	{ "SCSIEN",		0x20, 0x20 },
+	{ "WIDEODD",		0x40, 0x40 },
+	{ "PRELOADEN",		0x80, 0x80 }
+};
+
+int
+ahc_dfcntrl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(DFCNTRL_parse_table, 10, "DFCNTRL",
+	    0x93, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t DFSTATUS_parse_table[] = {
+	{ "FIFOEMP",		0x01, 0x01 },
+	{ "FIFOFULL",		0x02, 0x02 },
+	{ "DFTHRESH",		0x04, 0x04 },
+	{ "HDONE",		0x08, 0x08 },
+	{ "MREQPEND",		0x10, 0x10 },
+	{ "FIFOQWDEMP",		0x20, 0x20 },
+	{ "DFCACHETH",		0x40, 0x40 },
+	{ "PRELOAD_AVAIL",	0x80, 0x80 }
+};
+
+int
+ahc_dfstatus_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(DFSTATUS_parse_table, 8, "DFSTATUS",
+	    0x94, regvalue, cur_col, wrap));
+}
+
+int
+ahc_dfwaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "DFWADDR",
+	    0x95, regvalue, cur_col, wrap));
+}
+
+int
+ahc_dfraddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "DFRADDR",
+	    0x97, regvalue, cur_col, wrap));
+}
+
+int
+ahc_dfdat_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "DFDAT",
+	    0x99, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SCBCNT_parse_table[] = {
+	{ "SCBAUTO",		0x80, 0x80 },
+	{ "SCBCNT_MASK",	0x1f, 0x1f }
+};
+
+int
+ahc_scbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SCBCNT_parse_table, 2, "SCBCNT",
+	    0x9a, regvalue, cur_col, wrap));
+}
+
+int
+ahc_qinfifo_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "QINFIFO",
+	    0x9b, regvalue, cur_col, wrap));
+}
+
+int
+ahc_qincnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "QINCNT",
+	    0x9c, regvalue, cur_col, wrap));
+}
+
+int
+ahc_qoutfifo_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "QOUTFIFO",
+	    0x9d, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t CRCCONTROL1_parse_table[] = {
+	{ "TARGCRCCNTEN",	0x04, 0x04 },
+	{ "TARGCRCENDEN",	0x08, 0x08 },
+	{ "CRCREQCHKEN",	0x10, 0x10 },
+	{ "CRCENDCHKEN",	0x20, 0x20 },
+	{ "CRCVALCHKEN",	0x40, 0x40 },
+	{ "CRCONSEEN",		0x80, 0x80 }
+};
+
+int
+ahc_crccontrol1_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(CRCCONTROL1_parse_table, 6, "CRCCONTROL1",
+	    0x9d, regvalue, cur_col, wrap));
+}
+
+int
+ahc_qoutcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "QOUTCNT",
+	    0x9e, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SCSIPHASE_parse_table[] = {
+	{ "DATA_OUT_PHASE",	0x01, 0x01 },
+	{ "DATA_IN_PHASE",	0x02, 0x02 },
+	{ "MSG_OUT_PHASE",	0x04, 0x04 },
+	{ "MSG_IN_PHASE",	0x08, 0x08 },
+	{ "COMMAND_PHASE",	0x10, 0x10 },
+	{ "STATUS_PHASE",	0x20, 0x20 },
+	{ "DATA_PHASE_MASK",	0x03, 0x03 }
+};
+
+int
+ahc_scsiphase_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SCSIPHASE_parse_table, 7, "SCSIPHASE",
+	    0x9e, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SFUNCT_parse_table[] = {
+	{ "ALT_MODE",		0x80, 0x80 }
+};
+
+int
+ahc_sfunct_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SFUNCT_parse_table, 1, "SFUNCT",
+	    0x9f, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scb_base_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCB_BASE",
+	    0xa0, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scb_cdb_ptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCB_CDB_PTR",
+	    0xa0, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scb_residual_sgptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCB_RESIDUAL_SGPTR",
+	    0xa4, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scb_scsi_status_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCB_SCSI_STATUS",
+	    0xa8, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scb_target_phases_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCB_TARGET_PHASES",
+	    0xa9, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scb_target_data_dir_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCB_TARGET_DATA_DIR",
+	    0xaa, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scb_target_itag_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCB_TARGET_ITAG",
+	    0xab, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scb_dataptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCB_DATAPTR",
+	    0xac, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SCB_DATACNT_parse_table[] = {
+	{ "SG_LAST_SEG",	0x80, 0x80 },
+	{ "SG_HIGH_ADDR_BITS",	0x7f, 0x7f }
+};
+
+int
+ahc_scb_datacnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SCB_DATACNT_parse_table, 2, "SCB_DATACNT",
+	    0xb0, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SCB_SGPTR_parse_table[] = {
+	{ "SG_LIST_NULL",	0x01, 0x01 },
+	{ "SG_FULL_RESID",	0x02, 0x02 },
+	{ "SG_RESID_VALID",	0x04, 0x04 }
+};
+
+int
+ahc_scb_sgptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SCB_SGPTR_parse_table, 3, "SCB_SGPTR",
+	    0xb4, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SCB_CONTROL_parse_table[] = {
+	{ "DISCONNECTED",	0x04, 0x04 },
+	{ "ULTRAENB",		0x08, 0x08 },
+	{ "MK_MESSAGE",		0x10, 0x10 },
+	{ "TAG_ENB",		0x20, 0x20 },
+	{ "DISCENB",		0x40, 0x40 },
+	{ "TARGET_SCB",		0x80, 0x80 },
+	{ "STATUS_RCVD",	0x80, 0x80 },
+	{ "SCB_TAG_TYPE",	0x03, 0x03 }
+};
+
+int
+ahc_scb_control_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SCB_CONTROL_parse_table, 8, "SCB_CONTROL",
+	    0xb8, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SCB_SCSIID_parse_table[] = {
+	{ "TWIN_CHNLB",		0x80, 0x80 },
+	{ "OID",		0x0f, 0x0f },
+	{ "TWIN_TID",		0x70, 0x70 },
+	{ "TID",		0xf0, 0xf0 }
+};
+
+int
+ahc_scb_scsiid_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SCB_SCSIID_parse_table, 4, "SCB_SCSIID",
+	    0xb9, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SCB_LUN_parse_table[] = {
+	{ "SCB_XFERLEN_ODD",	0x80, 0x80 },
+	{ "LID",		0x3f, 0x3f }
+};
+
+int
+ahc_scb_lun_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SCB_LUN_parse_table, 2, "SCB_LUN",
+	    0xba, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scb_tag_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCB_TAG",
+	    0xbb, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scb_cdb_len_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCB_CDB_LEN",
+	    0xbc, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scb_scsirate_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCB_SCSIRATE",
+	    0xbd, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scb_scsioffset_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCB_SCSIOFFSET",
+	    0xbe, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scb_next_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCB_NEXT",
+	    0xbf, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scb_64_spare_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCB_64_SPARE",
+	    0xc0, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SEECTL_2840_parse_table[] = {
+	{ "DO_2840",		0x01, 0x01 },
+	{ "CK_2840",		0x02, 0x02 },
+	{ "CS_2840",		0x04, 0x04 }
+};
+
+int
+ahc_seectl_2840_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SEECTL_2840_parse_table, 3, "SEECTL_2840",
+	    0xc0, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t STATUS_2840_parse_table[] = {
+	{ "DI_2840",		0x01, 0x01 },
+	{ "EEPROM_TF",		0x80, 0x80 },
+	{ "ADSEL",		0x1e, 0x1e },
+	{ "BIOS_SEL",		0x60, 0x60 }
+};
+
+int
+ahc_status_2840_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(STATUS_2840_parse_table, 4, "STATUS_2840",
+	    0xc1, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scb_64_btt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCB_64_BTT",
+	    0xd0, regvalue, cur_col, wrap));
+}
+
+int
+ahc_cchaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "CCHADDR",
+	    0xe0, regvalue, cur_col, wrap));
+}
+
+int
+ahc_cchcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "CCHCNT",
+	    0xe8, regvalue, cur_col, wrap));
+}
+
+int
+ahc_ccsgram_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "CCSGRAM",
+	    0xe9, regvalue, cur_col, wrap));
+}
+
+int
+ahc_ccsgaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "CCSGADDR",
+	    0xea, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t CCSGCTL_parse_table[] = {
+	{ "CCSGRESET",		0x01, 0x01 },
+	{ "SG_FETCH_NEEDED",	0x02, 0x02 },
+	{ "CCSGEN",		0x08, 0x08 },
+	{ "CCSGDONE",		0x80, 0x80 }
+};
+
+int
+ahc_ccsgctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(CCSGCTL_parse_table, 4, "CCSGCTL",
+	    0xeb, regvalue, cur_col, wrap));
+}
+
+int
+ahc_ccscbram_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "CCSCBRAM",
+	    0xec, regvalue, cur_col, wrap));
+}
+
+int
+ahc_ccscbaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "CCSCBADDR",
+	    0xed, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t CCSCBCTL_parse_table[] = {
+	{ "CCSCBRESET",		0x01, 0x01 },
+	{ "CCSCBDIR",		0x04, 0x04 },
+	{ "CCSCBEN",		0x08, 0x08 },
+	{ "CCARREN",		0x10, 0x10 },
+	{ "ARRDONE",		0x40, 0x40 },
+	{ "CCSCBDONE",		0x80, 0x80 }
+};
+
+int
+ahc_ccscbctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(CCSCBCTL_parse_table, 6, "CCSCBCTL",
+	    0xee, regvalue, cur_col, wrap));
+}
+
+int
+ahc_ccscbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "CCSCBCNT",
+	    0xef, regvalue, cur_col, wrap));
+}
+
+int
+ahc_scbbaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SCBBADDR",
+	    0xf0, regvalue, cur_col, wrap));
+}
+
+int
+ahc_ccscbptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "CCSCBPTR",
+	    0xf1, regvalue, cur_col, wrap));
+}
+
+int
+ahc_hnscb_qoff_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "HNSCB_QOFF",
+	    0xf4, regvalue, cur_col, wrap));
+}
+
+int
+ahc_snscb_qoff_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SNSCB_QOFF",
+	    0xf6, regvalue, cur_col, wrap));
+}
+
+int
+ahc_sdscb_qoff_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(NULL, 0, "SDSCB_QOFF",
+	    0xf8, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t QOFF_CTLSTA_parse_table[] = {
+	{ "SDSCB_ROLLOVER",	0x10, 0x10 },
+	{ "SNSCB_ROLLOVER",	0x20, 0x20 },
+	{ "SCB_AVAIL",		0x40, 0x40 },
+	{ "SCB_QSIZE_256",	0x06, 0x06 },
+	{ "SCB_QSIZE",		0x07, 0x07 }
+};
+
+int
+ahc_qoff_ctlsta_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(QOFF_CTLSTA_parse_table, 5, "QOFF_CTLSTA",
+	    0xfa, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t DFF_THRSH_parse_table[] = {
+	{ "RD_DFTHRSH_MIN",	0x00, 0x00 },
+	{ "WR_DFTHRSH_MIN",	0x00, 0x00 },
+	{ "RD_DFTHRSH_25",	0x01, 0x01 },
+	{ "RD_DFTHRSH_50",	0x02, 0x02 },
+	{ "RD_DFTHRSH_63",	0x03, 0x03 },
+	{ "RD_DFTHRSH_75",	0x04, 0x04 },
+	{ "RD_DFTHRSH_85",	0x05, 0x05 },
+	{ "RD_DFTHRSH_90",	0x06, 0x06 },
+	{ "RD_DFTHRSH",		0x07, 0x07 },
+	{ "RD_DFTHRSH_MAX",	0x07, 0x07 },
+	{ "WR_DFTHRSH_25",	0x10, 0x10 },
+	{ "WR_DFTHRSH_50",	0x20, 0x20 },
+	{ "WR_DFTHRSH_63",	0x30, 0x30 },
+	{ "WR_DFTHRSH_75",	0x40, 0x40 },
+	{ "WR_DFTHRSH_85",	0x50, 0x50 },
+	{ "WR_DFTHRSH_90",	0x60, 0x60 },
+	{ "WR_DFTHRSH",		0x70, 0x70 },
+	{ "WR_DFTHRSH_MAX",	0x70, 0x70 }
+};
+
+int
+ahc_dff_thrsh_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(DFF_THRSH_parse_table, 18, "DFF_THRSH",
+	    0xfb, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SG_CACHE_SHADOW_parse_table[] = {
+	{ "LAST_SEG_DONE",	0x01, 0x01 },
+	{ "LAST_SEG",		0x02, 0x02 },
+	{ "SG_ADDR_MASK",	0xf8, 0xf8 }
+};
+
+int
+ahc_sg_cache_shadow_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SG_CACHE_SHADOW_parse_table, 3, "SG_CACHE_SHADOW",
+	    0xfc, regvalue, cur_col, wrap));
+}
+
+static ahc_reg_parse_entry_t SG_CACHE_PRE_parse_table[] = {
+	{ "LAST_SEG_DONE",	0x01, 0x01 },
+	{ "LAST_SEG",		0x02, 0x02 },
+	{ "SG_ADDR_MASK",	0xf8, 0xf8 }
+};
+
+int
+ahc_sg_cache_pre_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahc_print_register(SG_CACHE_PRE_parse_table, 3, "SG_CACHE_PRE",
+	    0xfc, regvalue, cur_col, wrap));
+}
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_seq.h linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_seq.h
--- linux-2.4.21/drivers/scsi/aic7xxx/aic7xxx_seq.h	2002-08-03 00:39:44.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aic7xxx_seq.h	2003-06-26 21:43:34.000000000 +0000
@@ -2,13 +2,13 @@
  * DO NOT EDIT - This file is automatically generated
  *		 from the following source files:
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.seq#43 $
- * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.reg#30 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.seq#56 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.reg#39 $
  */
 static uint8_t seqprog[] = {
 	0xb2, 0x00, 0x00, 0x08,
 	0xf7, 0x11, 0x22, 0x08,
-	0x00, 0x65, 0xe4, 0x59,
+	0x00, 0x65, 0xec, 0x59,
 	0xf7, 0x01, 0x02, 0x08,
 	0xff, 0x6a, 0x24, 0x08,
 	0x40, 0x00, 0x40, 0x68,
@@ -21,15 +21,15 @@
 	0x01, 0x4d, 0xc8, 0x30,
 	0x00, 0x4c, 0x12, 0x70,
 	0x01, 0x39, 0xa2, 0x30,
-	0x00, 0x6a, 0xb6, 0x5e,
+	0x00, 0x6a, 0xc0, 0x5e,
 	0x01, 0x51, 0x20, 0x31,
 	0x01, 0x57, 0xae, 0x00,
 	0x0d, 0x6a, 0x76, 0x00,
-	0x00, 0x51, 0x08, 0x5e,
+	0x00, 0x51, 0x12, 0x5e,
 	0x01, 0x51, 0xc8, 0x30,
 	0x00, 0x39, 0xc8, 0x60,
 	0x00, 0xbb, 0x30, 0x70,
-	0xc1, 0x6a, 0xce, 0x5e,
+	0xc1, 0x6a, 0xd8, 0x5e,
 	0x01, 0xbf, 0x72, 0x30,
 	0x01, 0x40, 0x7e, 0x31,
 	0x01, 0x90, 0x80, 0x30,
@@ -42,17 +42,17 @@
 	0x08, 0x6a, 0x18, 0x00,
 	0x08, 0x11, 0x22, 0x00,
 	0x60, 0x0b, 0x00, 0x78,
-	0x40, 0x0b, 0xfc, 0x68,
+	0x40, 0x0b, 0xfa, 0x68,
 	0x80, 0x0b, 0xb6, 0x78,
 	0x20, 0x6a, 0x16, 0x00,
 	0xa4, 0x6a, 0x06, 0x00,
-	0x08, 0x3c, 0x78, 0x00,
+	0x08, 0x6a, 0x78, 0x00,
 	0x01, 0x50, 0xc8, 0x30,
 	0xe0, 0x6a, 0xcc, 0x00,
-	0x48, 0x6a, 0xf2, 0x5d,
+	0x48, 0x6a, 0xfc, 0x5d,
 	0x01, 0x6a, 0xdc, 0x01,
 	0x88, 0x6a, 0xcc, 0x00,
-	0x48, 0x6a, 0xf2, 0x5d,
+	0x48, 0x6a, 0xfc, 0x5d,
 	0x01, 0x6a, 0x26, 0x01,
 	0xf0, 0x19, 0x7a, 0x08,
 	0x0f, 0x18, 0xc8, 0x08,
@@ -63,8 +63,8 @@
 	0x80, 0x3d, 0x7a, 0x00,
 	0x01, 0x3d, 0xd8, 0x31,
 	0x01, 0x3d, 0x32, 0x31,
-	0x10, 0x03, 0x48, 0x79,
-	0x00, 0x65, 0xf4, 0x58,
+	0x10, 0x03, 0x4e, 0x79,
+	0x00, 0x65, 0xf2, 0x58,
 	0x80, 0x66, 0xae, 0x78,
 	0x01, 0x66, 0xd8, 0x31,
 	0x01, 0x66, 0x32, 0x31,
@@ -72,29 +72,29 @@
 	0x40, 0x66, 0x82, 0x68,
 	0x01, 0x3c, 0x78, 0x00,
 	0x10, 0x03, 0x9e, 0x78,
-	0x00, 0x65, 0xf4, 0x58,
+	0x00, 0x65, 0xf2, 0x58,
 	0xe0, 0x66, 0xc8, 0x18,
 	0x00, 0x65, 0xaa, 0x50,
 	0xdd, 0x66, 0xc8, 0x18,
 	0x00, 0x65, 0xaa, 0x48,
 	0x01, 0x66, 0xd8, 0x31,
 	0x01, 0x66, 0x32, 0x31,
-	0x10, 0x03, 0x48, 0x79,
-	0x00, 0x65, 0xf4, 0x58,
+	0x10, 0x03, 0x4e, 0x79,
+	0x00, 0x65, 0xf2, 0x58,
 	0x01, 0x66, 0xd8, 0x31,
 	0x01, 0x66, 0x32, 0x31,
 	0x01, 0x66, 0xac, 0x30,
 	0x40, 0x3c, 0x78, 0x00,
 	0xff, 0x6a, 0xd8, 0x01,
 	0xff, 0x6a, 0x32, 0x01,
-	0x90, 0x3c, 0x78, 0x00,
-	0x02, 0x57, 0x3c, 0x69,
-	0x10, 0x03, 0x3a, 0x69,
-	0x00, 0x65, 0x1e, 0x41,
+	0x10, 0x3c, 0x78, 0x00,
+	0x02, 0x57, 0x40, 0x69,
+	0x10, 0x03, 0x3e, 0x69,
+	0x00, 0x65, 0x20, 0x41,
 	0x02, 0x57, 0xae, 0x00,
 	0x00, 0x65, 0x9e, 0x40,
-	0x61, 0x6a, 0xce, 0x5e,
-	0x08, 0x51, 0x1e, 0x71,
+	0x61, 0x6a, 0xd8, 0x5e,
+	0x08, 0x51, 0x20, 0x71,
 	0x02, 0x0b, 0xb2, 0x78,
 	0x00, 0x65, 0xae, 0x40,
 	0x1a, 0x01, 0x02, 0x00,
@@ -105,8 +105,8 @@
 	0x08, 0x1f, 0xc4, 0x78,
 	0x80, 0x3d, 0x7a, 0x00,
 	0x20, 0x6a, 0x16, 0x00,
-	0x00, 0x65, 0xc4, 0x41,
-	0x00, 0x65, 0xa8, 0x5e,
+	0x00, 0x65, 0xcc, 0x41,
+	0x00, 0x65, 0xb2, 0x5e,
 	0x00, 0x65, 0x12, 0x40,
 	0x20, 0x11, 0xd2, 0x68,
 	0x20, 0x6a, 0x18, 0x00,
@@ -123,169 +123,169 @@
 	0x80, 0x65, 0xca, 0x00,
 	0x01, 0x65, 0x00, 0x34,
 	0x01, 0x54, 0x00, 0x34,
-	0x1a, 0x01, 0x02, 0x00,
-	0x08, 0xb8, 0xf0, 0x78,
+	0x08, 0xb8, 0xee, 0x78,
 	0x20, 0x01, 0x02, 0x00,
 	0x02, 0xbd, 0x08, 0x34,
 	0x01, 0xbd, 0x08, 0x34,
 	0x08, 0x01, 0x02, 0x00,
-	0x02, 0x0b, 0xf6, 0x78,
+	0x02, 0x0b, 0xf4, 0x78,
 	0xf7, 0x01, 0x02, 0x08,
 	0x01, 0x06, 0xcc, 0x34,
 	0xb2, 0x00, 0x00, 0x08,
 	0x01, 0x40, 0x20, 0x31,
 	0x01, 0xbf, 0x80, 0x30,
 	0x01, 0xb9, 0x7a, 0x30,
-	0x01, 0xba, 0x7c, 0x30,
+	0x3f, 0xba, 0x7c, 0x08,
 	0x00, 0x65, 0xea, 0x58,
-	0x80, 0x0b, 0xbe, 0x79,
-	0xe4, 0x6a, 0x64, 0x5d,
+	0x80, 0x0b, 0xc4, 0x79,
+	0x12, 0x01, 0x02, 0x00,
+	0x01, 0xab, 0xac, 0x30,
+	0xe4, 0x6a, 0x6e, 0x5d,
 	0x40, 0x6a, 0x16, 0x00,
-	0x80, 0xba, 0x7a, 0x5d,
-	0x20, 0xb8, 0x16, 0x79,
-	0x20, 0x6a, 0x7a, 0x5d,
-	0x00, 0xab, 0x7a, 0x5d,
+	0x80, 0x3e, 0x84, 0x5d,
+	0x20, 0xb8, 0x18, 0x79,
+	0x20, 0x6a, 0x84, 0x5d,
+	0x00, 0xab, 0x84, 0x5d,
 	0x01, 0xa9, 0x78, 0x30,
-	0x10, 0xb8, 0x1e, 0x79,
-	0xe4, 0x6a, 0x64, 0x5d,
+	0x10, 0xb8, 0x20, 0x79,
+	0xe4, 0x6a, 0x6e, 0x5d,
 	0x00, 0x65, 0xae, 0x40,
-	0x10, 0x03, 0x38, 0x69,
-	0x08, 0x3c, 0x54, 0x69,
-	0x04, 0x3c, 0x8c, 0x69,
-	0x02, 0x3c, 0x92, 0x69,
-	0x01, 0x3c, 0x3e, 0x79,
-	0x01, 0x6a, 0xa2, 0x30,
-	0x00, 0x65, 0x9e, 0x59,
-	0x04, 0x51, 0x2c, 0x61,
-	0x00, 0x6a, 0xb6, 0x5e,
+	0x10, 0x03, 0x3c, 0x69,
+	0x08, 0x3c, 0x5a, 0x69,
+	0x04, 0x3c, 0x92, 0x69,
+	0x02, 0x3c, 0x98, 0x69,
+	0x01, 0x3c, 0x44, 0x79,
+	0xff, 0x6a, 0x70, 0x00,
+	0x00, 0x65, 0xa4, 0x59,
+	0x00, 0x6a, 0xc0, 0x5e,
+	0xff, 0x38, 0x30, 0x71,
 	0x0d, 0x6a, 0x76, 0x00,
-	0x00, 0xbb, 0x08, 0x5e,
-	0x00, 0x65, 0xec, 0x58,
-	0x00, 0x65, 0x16, 0x41,
+	0x00, 0x38, 0x12, 0x5e,
+	0x00, 0x65, 0xea, 0x58,
+	0x12, 0x01, 0x02, 0x00,
+	0x00, 0x65, 0x18, 0x41,
 	0xa4, 0x6a, 0x06, 0x00,
-	0x00, 0x65, 0xf4, 0x58,
+	0x00, 0x65, 0xf2, 0x58,
+	0xfd, 0x57, 0xae, 0x08,
 	0x00, 0x65, 0xae, 0x40,
-	0xe4, 0x6a, 0x64, 0x5d,
-	0x20, 0x3c, 0x44, 0x79,
-	0x02, 0x6a, 0x7a, 0x5d,
-	0x04, 0x6a, 0x7a, 0x5d,
-	0x01, 0x03, 0x46, 0x69,
+	0xe4, 0x6a, 0x6e, 0x5d,
+	0x20, 0x3c, 0x4a, 0x79,
+	0x02, 0x6a, 0x84, 0x5d,
+	0x04, 0x6a, 0x84, 0x5d,
+	0x01, 0x03, 0x4c, 0x69,
 	0xf7, 0x11, 0x22, 0x08,
 	0xff, 0x6a, 0x24, 0x08,
 	0xff, 0x6a, 0x06, 0x08,
 	0x01, 0x6a, 0x7e, 0x00,
-	0x00, 0x65, 0x9e, 0x59,
+	0x00, 0x65, 0xa4, 0x59,
 	0x00, 0x65, 0x04, 0x40,
 	0x80, 0x86, 0xc8, 0x08,
 	0x01, 0x4f, 0xc8, 0x30,
-	0x00, 0x50, 0x66, 0x61,
-	0xc4, 0x6a, 0x64, 0x5d,
-	0x40, 0x3c, 0x62, 0x79,
-	0x28, 0x6a, 0x7a, 0x5d,
-	0x00, 0x65, 0x46, 0x41,
-	0x08, 0x6a, 0x7a, 0x5d,
-	0x00, 0x65, 0x46, 0x41,
-	0x84, 0x6a, 0x64, 0x5d,
-	0x00, 0x65, 0xf4, 0x58,
+	0x00, 0x50, 0x6c, 0x61,
+	0xc4, 0x6a, 0x6e, 0x5d,
+	0x40, 0x3c, 0x68, 0x79,
+	0x28, 0x6a, 0x84, 0x5d,
+	0x00, 0x65, 0x4c, 0x41,
+	0x08, 0x6a, 0x84, 0x5d,
+	0x00, 0x65, 0x4c, 0x41,
+	0x84, 0x6a, 0x6e, 0x5d,
+	0x00, 0x65, 0xf2, 0x58,
 	0x01, 0x66, 0xc8, 0x30,
 	0x01, 0x64, 0xd8, 0x31,
 	0x01, 0x64, 0x32, 0x31,
 	0x5b, 0x64, 0xc8, 0x28,
 	0x30, 0x64, 0xca, 0x18,
 	0x01, 0x6c, 0xc8, 0x30,
-	0xff, 0x64, 0x88, 0x79,
+	0xff, 0x64, 0x8e, 0x79,
 	0x08, 0x01, 0x02, 0x00,
-	0x02, 0x0b, 0x7a, 0x79,
-	0x01, 0x64, 0x80, 0x61,
+	0x02, 0x0b, 0x80, 0x79,
+	0x01, 0x64, 0x86, 0x61,
 	0xf7, 0x01, 0x02, 0x08,
 	0x01, 0x06, 0xd8, 0x31,
 	0x01, 0x06, 0x32, 0x31,
 	0xff, 0x64, 0xc8, 0x18,
-	0xff, 0x64, 0x7a, 0x69,
+	0xff, 0x64, 0x80, 0x69,
 	0xf7, 0x3c, 0x78, 0x08,
-	0x00, 0x65, 0x1e, 0x41,
+	0x00, 0x65, 0x20, 0x41,
 	0x40, 0xaa, 0x7e, 0x10,
-	0x04, 0xaa, 0x64, 0x5d,
+	0x04, 0xaa, 0x6e, 0x5d,
 	0x00, 0x65, 0x56, 0x42,
-	0xc4, 0x6a, 0x64, 0x5d,
+	0xc4, 0x6a, 0x6e, 0x5d,
 	0xc0, 0x6a, 0x7e, 0x00,
-	0x00, 0xa8, 0x7a, 0x5d,
+	0x00, 0xa8, 0x84, 0x5d,
 	0xe4, 0x6a, 0x06, 0x00,
-	0x00, 0x6a, 0x7a, 0x5d,
-	0x00, 0x65, 0x46, 0x41,
-	0x10, 0x3c, 0xa2, 0x69,
-	0x00, 0xbb, 0x84, 0x44,
+	0x00, 0x6a, 0x84, 0x5d,
+	0x00, 0x65, 0x4c, 0x41,
+	0x10, 0x3c, 0xa8, 0x69,
+	0x00, 0xbb, 0x8a, 0x44,
 	0x18, 0x6a, 0xda, 0x01,
 	0x01, 0x69, 0xd8, 0x31,
 	0x1c, 0x6a, 0xd0, 0x01,
 	0x09, 0xee, 0xdc, 0x01,
-	0x80, 0xee, 0xaa, 0x79,
+	0x80, 0xee, 0xb0, 0x79,
 	0xff, 0x6a, 0xdc, 0x09,
 	0x01, 0x93, 0x26, 0x01,
 	0x03, 0x6a, 0x2a, 0x01,
 	0x01, 0x69, 0x32, 0x31,
-	0x1c, 0x6a, 0xd6, 0x5d,
+	0x1c, 0x6a, 0xe0, 0x5d,
 	0x0a, 0x93, 0x26, 0x01,
-	0x00, 0x65, 0x9e, 0x5e,
+	0x00, 0x65, 0xa8, 0x5e,
 	0x01, 0x50, 0xa0, 0x18,
 	0x02, 0x6a, 0x22, 0x05,
+	0x1a, 0x01, 0x02, 0x00,
 	0x80, 0x6a, 0x74, 0x00,
-	0x80, 0x3c, 0x78, 0x00,
+	0x40, 0x6a, 0x78, 0x00,
 	0x40, 0x6a, 0x16, 0x00,
-	0x00, 0x65, 0xce, 0x5d,
+	0x00, 0x65, 0xd8, 0x5d,
 	0x01, 0x3f, 0xc8, 0x30,
 	0xbf, 0x64, 0x56, 0x7a,
-	0x80, 0x64, 0xaa, 0x73,
-	0xa0, 0x64, 0x08, 0x74,
-	0xc0, 0x64, 0xfc, 0x73,
-	0xe0, 0x64, 0x38, 0x74,
-	0x01, 0x6a, 0xce, 0x5e,
-	0x00, 0x65, 0xc4, 0x41,
+	0x80, 0x64, 0x9e, 0x73,
+	0xa0, 0x64, 0x00, 0x74,
+	0xc0, 0x64, 0xf4, 0x73,
+	0xe0, 0x64, 0x30, 0x74,
+	0x01, 0x6a, 0xd8, 0x5e,
+	0x00, 0x65, 0xcc, 0x41,
 	0xf7, 0x11, 0x22, 0x08,
 	0x01, 0x06, 0xd4, 0x30,
 	0xff, 0x6a, 0x24, 0x08,
 	0xf7, 0x01, 0x02, 0x08,
-	0x09, 0x0c, 0xde, 0x79,
+	0x09, 0x0c, 0xe6, 0x79,
 	0x08, 0x0c, 0x04, 0x68,
-	0xb1, 0x6a, 0xce, 0x5e,
+	0xb1, 0x6a, 0xd8, 0x5e,
 	0xff, 0x6a, 0x26, 0x09,
 	0x12, 0x01, 0x02, 0x00,
 	0x02, 0x6a, 0x08, 0x30,
 	0xff, 0x6a, 0x08, 0x08,
 	0xdf, 0x01, 0x02, 0x08,
 	0x01, 0x6a, 0x7e, 0x00,
-	0xff, 0x6a, 0x78, 0x0c,
+	0xc0, 0x6a, 0x78, 0x04,
 	0xff, 0x6a, 0xc8, 0x08,
 	0x08, 0xa4, 0x48, 0x19,
 	0x00, 0xa5, 0x4a, 0x21,
 	0x00, 0xa6, 0x4c, 0x21,
 	0x00, 0xa7, 0x4e, 0x25,
-	0x08, 0xeb, 0xd2, 0x7e,
-	0x80, 0xeb, 0xfe, 0x79,
+	0x08, 0xeb, 0xdc, 0x7e,
+	0x80, 0xeb, 0x06, 0x7a,
 	0xff, 0x6a, 0xd6, 0x09,
-	0x08, 0xeb, 0x02, 0x6a,
+	0x08, 0xeb, 0x0a, 0x6a,
 	0xff, 0x6a, 0xd4, 0x0c,
-	0x80, 0xa3, 0xd2, 0x6e,
-	0x88, 0xeb, 0x18, 0x72,
-	0x08, 0xeb, 0xd2, 0x6e,
-	0x04, 0xea, 0x1c, 0xe2,
-	0x08, 0xee, 0xd2, 0x6e,
+	0x80, 0xa3, 0xdc, 0x6e,
+	0x88, 0xeb, 0x20, 0x72,
+	0x08, 0xeb, 0xdc, 0x6e,
+	0x04, 0xea, 0x24, 0xe2,
+	0x08, 0xee, 0xdc, 0x6e,
 	0x04, 0x6a, 0xd0, 0x81,
 	0x05, 0xa4, 0xc0, 0x89,
 	0x03, 0xa5, 0xc2, 0x31,
 	0x09, 0x6a, 0xd6, 0x05,
-	0x00, 0x65, 0x00, 0x5a,
+	0x00, 0x65, 0x08, 0x5a,
 	0x06, 0xa4, 0xd4, 0x89,
-	0x80, 0x94, 0xd2, 0x7e,
+	0x80, 0x94, 0xdc, 0x7e,
 	0x07, 0xe9, 0x10, 0x31,
-	0x01, 0x8c, 0x24, 0x7a,
-	0x01, 0x55, 0xaa, 0x10,
 	0x01, 0xe9, 0x46, 0x31,
-	0x00, 0xa3, 0xb0, 0x5e,
-	0x00, 0x65, 0xf2, 0x59,
+	0x00, 0xa3, 0xba, 0x5e,
+	0x00, 0x65, 0xfa, 0x59,
 	0x01, 0xa4, 0xca, 0x30,
-	0x01, 0x55, 0x30, 0x7a,
-	0x04, 0x65, 0xca, 0x00,
 	0x80, 0xa3, 0x34, 0x7a,
 	0x02, 0x65, 0xca, 0x00,
 	0x01, 0x65, 0xf8, 0x31,
@@ -294,168 +294,162 @@
 	0x01, 0x8c, 0xc8, 0x30,
 	0x00, 0x88, 0xc8, 0x18,
 	0x02, 0x64, 0xc8, 0x88,
-	0xff, 0x64, 0xd2, 0x7e,
+	0xff, 0x64, 0xdc, 0x7e,
 	0xff, 0x8d, 0x4a, 0x6a,
 	0xff, 0x8e, 0x4a, 0x6a,
 	0x03, 0x8c, 0xd4, 0x98,
-	0x00, 0x65, 0xd2, 0x56,
+	0x00, 0x65, 0xdc, 0x56,
 	0x01, 0x64, 0x70, 0x30,
 	0xff, 0x64, 0xc8, 0x10,
 	0x01, 0x64, 0xc8, 0x18,
 	0x00, 0x8c, 0x18, 0x19,
 	0xff, 0x8d, 0x1a, 0x21,
 	0xff, 0x8e, 0x1c, 0x25,
-	0x80, 0x3c, 0x5a, 0x6a,
-	0x21, 0x6a, 0xce, 0x46,
+	0xc0, 0x3c, 0x5a, 0x7a,
+	0x21, 0x6a, 0xd8, 0x5e,
 	0xa8, 0x6a, 0x76, 0x00,
 	0x79, 0x6a, 0x76, 0x00,
 	0x40, 0x3f, 0x62, 0x6a,
 	0x04, 0x3b, 0x76, 0x00,
 	0x04, 0x6a, 0xd4, 0x81,
 	0x20, 0x3c, 0x6a, 0x7a,
-	0x51, 0x6a, 0xce, 0x5e,
-	0x00, 0x65, 0x84, 0x42,
+	0x51, 0x6a, 0xd8, 0x5e,
+	0x00, 0x65, 0x82, 0x42,
 	0x20, 0x3c, 0x78, 0x00,
-	0x00, 0xb3, 0xb0, 0x5e,
+	0x00, 0xb3, 0xba, 0x5e,
 	0x07, 0xac, 0x10, 0x31,
 	0x05, 0xb3, 0x46, 0x31,
 	0x88, 0x6a, 0xcc, 0x00,
-	0xac, 0x6a, 0xe4, 0x5d,
+	0xac, 0x6a, 0xee, 0x5d,
 	0xa3, 0x6a, 0xcc, 0x00,
-	0xb3, 0x6a, 0xe8, 0x5d,
+	0xb3, 0x6a, 0xf2, 0x5d,
 	0x00, 0x65, 0x3a, 0x5a,
 	0xfd, 0xa4, 0x48, 0x09,
-	0x01, 0x8c, 0xaa, 0x08,
 	0x03, 0x8c, 0x10, 0x30,
-	0x00, 0x65, 0xdc, 0x5d,
-	0x01, 0xa4, 0x96, 0x7a,
+	0x00, 0x65, 0xe6, 0x5d,
+	0x01, 0xa4, 0x94, 0x7a,
 	0x04, 0x3b, 0x76, 0x08,
 	0x01, 0x3b, 0x26, 0x31,
 	0x80, 0x02, 0x04, 0x00,
-	0x10, 0x0c, 0x8c, 0x7a,
-	0x03, 0x9e, 0x8e, 0x6a,
+	0x10, 0x0c, 0x8a, 0x7a,
+	0x03, 0x9e, 0x8c, 0x6a,
 	0x7f, 0x02, 0x04, 0x08,
-	0x91, 0x6a, 0xce, 0x5e,
-	0x00, 0x65, 0xc4, 0x41,
+	0x91, 0x6a, 0xd8, 0x5e,
+	0x00, 0x65, 0xcc, 0x41,
 	0x01, 0xa4, 0xca, 0x30,
-	0x80, 0xa3, 0x9c, 0x7a,
+	0x80, 0xa3, 0x9a, 0x7a,
 	0x02, 0x65, 0xca, 0x00,
-	0x01, 0x55, 0xa0, 0x7a,
-	0x04, 0x65, 0xca, 0x00,
 	0x01, 0x65, 0xf8, 0x31,
 	0x01, 0x3b, 0x26, 0x31,
-	0x00, 0x65, 0x06, 0x5a,
-	0x01, 0xfc, 0xae, 0x6a,
-	0x80, 0x0b, 0xa4, 0x6a,
-	0x10, 0x0c, 0xa4, 0x7a,
-	0x20, 0x93, 0xa4, 0x6a,
+	0x00, 0x65, 0x0e, 0x5a,
+	0x01, 0xfc, 0xa8, 0x6a,
+	0x80, 0x0b, 0x9e, 0x6a,
+	0x10, 0x0c, 0x9e, 0x7a,
+	0x20, 0x93, 0x9e, 0x6a,
 	0x02, 0x93, 0x26, 0x01,
-	0x02, 0xfc, 0xb8, 0x7a,
-	0x40, 0x0d, 0xd2, 0x6a,
+	0x02, 0xfc, 0xb2, 0x7a,
+	0x40, 0x0d, 0xc6, 0x6a,
 	0x01, 0xa4, 0x48, 0x01,
-	0x00, 0x65, 0xd2, 0x42,
-	0x40, 0x0d, 0xbe, 0x6a,
-	0x00, 0x65, 0x06, 0x5a,
-	0x00, 0x65, 0xb0, 0x42,
-	0x80, 0xfc, 0xc8, 0x7a,
-	0x80, 0xa4, 0xc8, 0x6a,
+	0x00, 0x65, 0xc6, 0x42,
+	0x40, 0x0d, 0xb8, 0x6a,
+	0x00, 0x65, 0x0e, 0x5a,
+	0x00, 0x65, 0xaa, 0x42,
+	0x80, 0xfc, 0xc2, 0x7a,
+	0x80, 0xa4, 0xc2, 0x6a,
 	0xff, 0xa5, 0x4a, 0x19,
 	0xff, 0xa6, 0x4c, 0x21,
 	0xff, 0xa7, 0x4e, 0x21,
 	0xf8, 0xfc, 0x48, 0x09,
-	0xff, 0x6a, 0xaa, 0x08,
-	0x04, 0xfc, 0xd0, 0x7a,
-	0x01, 0x55, 0xaa, 0x00,
-	0xff, 0x6a, 0x46, 0x09,
-	0x04, 0x3b, 0xea, 0x6a,
+	0x7f, 0xa3, 0x46, 0x09,
+	0x04, 0x3b, 0xe2, 0x6a,
 	0x02, 0x93, 0x26, 0x01,
-	0x01, 0x94, 0xd4, 0x7a,
-	0x01, 0x94, 0xd4, 0x7a,
-	0x01, 0x94, 0xd4, 0x7a,
-	0x01, 0x94, 0xd4, 0x7a,
-	0x01, 0x94, 0xd4, 0x7a,
-	0x01, 0xa4, 0xe8, 0x7a,
-	0x01, 0xfc, 0xe2, 0x7a,
-	0x01, 0x94, 0xea, 0x6a,
-	0x00, 0x65, 0x84, 0x42,
-	0x01, 0x94, 0xe8, 0x7a,
-	0x10, 0x94, 0xea, 0x6a,
+	0x01, 0x94, 0xc8, 0x7a,
+	0x01, 0x94, 0xc8, 0x7a,
+	0x01, 0x94, 0xc8, 0x7a,
+	0x01, 0x94, 0xc8, 0x7a,
+	0x01, 0x94, 0xc8, 0x7a,
+	0x01, 0xa4, 0xe0, 0x7a,
+	0x01, 0xfc, 0xd6, 0x7a,
+	0x01, 0x94, 0xe2, 0x6a,
+	0x01, 0x94, 0xe2, 0x6a,
+	0x01, 0x94, 0xe2, 0x6a,
+	0x00, 0x65, 0x82, 0x42,
+	0x01, 0x94, 0xe0, 0x7a,
+	0x10, 0x94, 0xe2, 0x6a,
 	0xd7, 0x93, 0x26, 0x09,
-	0x28, 0x93, 0xee, 0x6a,
+	0x28, 0x93, 0xe6, 0x6a,
 	0x01, 0x85, 0x0a, 0x01,
-	0x02, 0xfc, 0xf6, 0x6a,
+	0x02, 0xfc, 0xee, 0x6a,
 	0x01, 0x14, 0x46, 0x31,
 	0xff, 0x6a, 0x10, 0x09,
 	0xfe, 0x85, 0x0a, 0x09,
-	0xff, 0x38, 0x04, 0x6b,
-	0x80, 0xa3, 0x04, 0x7b,
-	0x80, 0x0b, 0x02, 0x7b,
-	0x04, 0x3b, 0x04, 0x7b,
+	0xff, 0x38, 0xfc, 0x6a,
+	0x80, 0xa3, 0xfc, 0x7a,
+	0x80, 0x0b, 0xfa, 0x7a,
+	0x04, 0x3b, 0xfc, 0x7a,
 	0xbf, 0x3b, 0x76, 0x08,
 	0x01, 0x3b, 0x26, 0x31,
-	0x00, 0x65, 0x06, 0x5a,
-	0x01, 0x0b, 0x12, 0x6b,
-	0x10, 0x0c, 0x06, 0x7b,
-	0x04, 0x93, 0x10, 0x6b,
-	0x01, 0x94, 0x0e, 0x7b,
-	0x10, 0x94, 0x10, 0x6b,
+	0x00, 0x65, 0x0e, 0x5a,
+	0x01, 0x0b, 0x0a, 0x6b,
+	0x10, 0x0c, 0xfe, 0x7a,
+	0x04, 0x93, 0x08, 0x6b,
+	0x01, 0x94, 0x06, 0x7b,
+	0x10, 0x94, 0x08, 0x6b,
 	0xc7, 0x93, 0x26, 0x09,
 	0x01, 0x99, 0xd4, 0x30,
-	0x38, 0x93, 0x14, 0x6b,
-	0xff, 0x08, 0x66, 0x6b,
-	0xff, 0x09, 0x66, 0x6b,
-	0xff, 0x0a, 0x66, 0x6b,
-	0xff, 0x38, 0x30, 0x7b,
+	0x38, 0x93, 0x0c, 0x6b,
+	0xff, 0x08, 0x5a, 0x6b,
+	0xff, 0x09, 0x5a, 0x6b,
+	0xff, 0x0a, 0x5a, 0x6b,
+	0xff, 0x38, 0x28, 0x7b,
 	0x04, 0x14, 0x10, 0x31,
 	0x01, 0x38, 0x18, 0x31,
 	0x02, 0x6a, 0x1a, 0x31,
 	0x88, 0x6a, 0xcc, 0x00,
-	0x14, 0x6a, 0xea, 0x5d,
-	0x00, 0x38, 0xd6, 0x5d,
+	0x14, 0x6a, 0xf4, 0x5d,
+	0x00, 0x38, 0xe0, 0x5d,
 	0xff, 0x6a, 0x70, 0x08,
-	0x00, 0x65, 0x5c, 0x43,
-	0x80, 0xa3, 0x36, 0x7b,
+	0x00, 0x65, 0x54, 0x43,
+	0x80, 0xa3, 0x2e, 0x7b,
 	0x01, 0xa4, 0x48, 0x01,
-	0x00, 0x65, 0x66, 0x43,
-	0x08, 0xeb, 0x3c, 0x7b,
-	0x00, 0x65, 0x06, 0x5a,
-	0x08, 0xeb, 0x38, 0x6b,
+	0x00, 0x65, 0x5a, 0x43,
+	0x08, 0xeb, 0x34, 0x7b,
+	0x00, 0x65, 0x0e, 0x5a,
+	0x08, 0xeb, 0x30, 0x6b,
 	0x07, 0xe9, 0x10, 0x31,
 	0x01, 0xe9, 0xca, 0x30,
 	0x01, 0x65, 0x46, 0x31,
-	0x00, 0x6a, 0xb0, 0x5e,
+	0x00, 0x6a, 0xba, 0x5e,
 	0x88, 0x6a, 0xcc, 0x00,
-	0xa4, 0x6a, 0xea, 0x5d,
-	0x08, 0x6a, 0xd6, 0x5d,
+	0xa4, 0x6a, 0xf4, 0x5d,
+	0x08, 0x6a, 0xe0, 0x5d,
 	0x0d, 0x93, 0x26, 0x01,
-	0x00, 0x65, 0x9e, 0x5e,
+	0x00, 0x65, 0xa8, 0x5e,
 	0x88, 0x6a, 0xcc, 0x00,
-	0x00, 0x65, 0x80, 0x5e,
+	0x00, 0x65, 0x8a, 0x5e,
 	0x01, 0x99, 0x46, 0x31,
-	0x00, 0xa3, 0xb0, 0x5e,
+	0x00, 0xa3, 0xba, 0x5e,
 	0x01, 0x88, 0x10, 0x31,
 	0x00, 0x65, 0x3a, 0x5a,
-	0x00, 0x65, 0xf2, 0x59,
+	0x00, 0x65, 0xfa, 0x59,
 	0x03, 0x8c, 0x10, 0x30,
-	0x00, 0x65, 0xdc, 0x5d,
-	0x01, 0x8c, 0x64, 0x7b,
-	0x01, 0x55, 0xaa, 0x10,
-	0x80, 0x0b, 0x84, 0x6a,
-	0x80, 0x0b, 0x6e, 0x6b,
-	0x01, 0x0c, 0x68, 0x7b,
-	0x10, 0x0c, 0x84, 0x7a,
-	0x03, 0x9e, 0x84, 0x6a,
-	0x00, 0x65, 0xfc, 0x59,
-	0x00, 0x6a, 0xb0, 0x5e,
-	0x01, 0xa4, 0x8e, 0x6b,
-	0xff, 0x38, 0x84, 0x7b,
+	0x00, 0x65, 0xe6, 0x5d,
+	0x80, 0x0b, 0x82, 0x6a,
+	0x80, 0x0b, 0x62, 0x6b,
+	0x01, 0x0c, 0x5c, 0x7b,
+	0x10, 0x0c, 0x82, 0x7a,
+	0x03, 0x9e, 0x82, 0x6a,
+	0x00, 0x65, 0x04, 0x5a,
+	0x00, 0x6a, 0xba, 0x5e,
+	0x01, 0xa4, 0x82, 0x6b,
+	0xff, 0x38, 0x78, 0x7b,
 	0x01, 0x38, 0xc8, 0x30,
 	0x00, 0x08, 0x40, 0x19,
 	0xff, 0x6a, 0xc8, 0x08,
 	0x00, 0x09, 0x42, 0x21,
 	0x00, 0x0a, 0x44, 0x21,
 	0xff, 0x6a, 0x70, 0x08,
-	0x00, 0x65, 0x86, 0x43,
+	0x00, 0x65, 0x7a, 0x43,
 	0x03, 0x08, 0x40, 0x31,
 	0x03, 0x08, 0x40, 0x31,
 	0x01, 0x08, 0x40, 0x31,
@@ -464,19 +458,19 @@
 	0xfd, 0xb4, 0x68, 0x09,
 	0x12, 0x01, 0x02, 0x00,
 	0x12, 0x01, 0x02, 0x00,
-	0x04, 0x3c, 0xc4, 0x79,
+	0x04, 0x3c, 0xcc, 0x79,
 	0xfb, 0x3c, 0x78, 0x08,
-	0x04, 0x93, 0x1e, 0x79,
-	0x01, 0x0c, 0x9a, 0x6b,
-	0x01, 0x55, 0x1e, 0x79,
-	0x80, 0x04, 0x1e, 0x79,
-	0xe4, 0x6a, 0x64, 0x5d,
-	0x23, 0x6a, 0x7a, 0x5d,
-	0x01, 0x6a, 0x7a, 0x5d,
-	0x00, 0x65, 0x1e, 0x41,
-	0x00, 0x65, 0xc4, 0x41,
-	0x80, 0x3c, 0xae, 0x6b,
-	0x21, 0x6a, 0xce, 0x46,
+	0x04, 0x93, 0x20, 0x79,
+	0x01, 0x0c, 0x8e, 0x6b,
+	0x80, 0xba, 0x20, 0x79,
+	0x80, 0x04, 0x20, 0x79,
+	0xe4, 0x6a, 0x6e, 0x5d,
+	0x23, 0x6a, 0x84, 0x5d,
+	0x01, 0x6a, 0x84, 0x5d,
+	0x00, 0x65, 0x20, 0x41,
+	0x00, 0x65, 0xcc, 0x41,
+	0x80, 0x3c, 0xa2, 0x7b,
+	0x21, 0x6a, 0xd8, 0x5e,
 	0x01, 0xbc, 0x18, 0x31,
 	0x02, 0x6a, 0x1a, 0x31,
 	0x02, 0x6a, 0xf8, 0x01,
@@ -486,16 +480,16 @@
 	0xff, 0x6a, 0x12, 0x08,
 	0xff, 0x6a, 0x14, 0x08,
 	0xf3, 0xbc, 0xd4, 0x18,
-	0xa0, 0x6a, 0xd4, 0x53,
+	0xa0, 0x6a, 0xc8, 0x53,
 	0x04, 0xa0, 0x10, 0x31,
 	0xac, 0x6a, 0x26, 0x01,
 	0x04, 0xa0, 0x10, 0x31,
 	0x03, 0x08, 0x18, 0x31,
 	0x88, 0x6a, 0xcc, 0x00,
-	0xa0, 0x6a, 0xea, 0x5d,
-	0x00, 0xbc, 0xd6, 0x5d,
+	0xa0, 0x6a, 0xf4, 0x5d,
+	0x00, 0xbc, 0xe0, 0x5d,
 	0x3d, 0x6a, 0x26, 0x01,
-	0x00, 0x65, 0xec, 0x43,
+	0x00, 0x65, 0xe0, 0x43,
 	0xff, 0x6a, 0x10, 0x09,
 	0xa4, 0x6a, 0x26, 0x01,
 	0x0c, 0xa0, 0x32, 0x31,
@@ -505,117 +499,128 @@
 	0x36, 0x6a, 0x26, 0x01,
 	0x02, 0x93, 0x26, 0x01,
 	0x35, 0x6a, 0x26, 0x01,
-	0x00, 0x65, 0x92, 0x5e,
-	0x00, 0x65, 0x92, 0x5e,
+	0x00, 0x65, 0x9c, 0x5e,
+	0x00, 0x65, 0x9c, 0x5e,
 	0x02, 0x93, 0x26, 0x01,
-	0x04, 0x0b, 0xf0, 0x6b,
-	0x10, 0x0c, 0xec, 0x7b,
-	0x01, 0x03, 0xf0, 0x6b,
-	0x20, 0x93, 0xec, 0x6b,
+	0xbf, 0x3c, 0x78, 0x08,
+	0x04, 0x0b, 0xe6, 0x6b,
+	0x10, 0x0c, 0xe2, 0x7b,
+	0x01, 0x03, 0xe6, 0x6b,
+	0x20, 0x93, 0xe8, 0x6b,
+	0x04, 0x0b, 0xee, 0x6b,
+	0x40, 0x3c, 0x78, 0x00,
 	0xc7, 0x93, 0x26, 0x09,
-	0x38, 0x93, 0xf6, 0x6b,
-	0x10, 0x01, 0x02, 0x00,
-	0x00, 0x65, 0xc4, 0x41,
-	0x80, 0x3c, 0x00, 0x6c,
-	0x21, 0x6a, 0xce, 0x46,
+	0x38, 0x93, 0xf0, 0x6b,
+	0x00, 0x65, 0xcc, 0x41,
+	0x80, 0x3c, 0x56, 0x6c,
 	0x01, 0x06, 0x50, 0x31,
-	0x00, 0x65, 0xc4, 0x41,
+	0x80, 0xb8, 0x70, 0x01,
+	0x00, 0x65, 0xcc, 0x41,
 	0x10, 0x3f, 0x06, 0x00,
 	0x10, 0x6a, 0x06, 0x00,
 	0x01, 0x3a, 0xca, 0x30,
-	0x80, 0x65, 0x24, 0x64,
-	0x10, 0xb8, 0x48, 0x6c,
-	0xc0, 0xba, 0xca, 0x00,
-	0x40, 0xb8, 0x14, 0x6c,
+	0x80, 0x65, 0x1c, 0x64,
+	0x10, 0xb8, 0x40, 0x6c,
+	0xc0, 0x3e, 0xca, 0x00,
+	0x40, 0xb8, 0x0c, 0x6c,
 	0xbf, 0x65, 0xca, 0x08,
-	0x20, 0xb8, 0x28, 0x7c,
+	0x20, 0xb8, 0x20, 0x7c,
 	0x01, 0x65, 0x0c, 0x30,
-	0x00, 0x65, 0xce, 0x5d,
-	0xa0, 0x3f, 0x30, 0x64,
+	0x00, 0x65, 0xd8, 0x5d,
+	0xa0, 0x3f, 0x28, 0x64,
 	0x23, 0xb8, 0x0c, 0x08,
-	0x00, 0x65, 0xce, 0x5d,
-	0xa0, 0x3f, 0x30, 0x64,
-	0x00, 0xbb, 0x28, 0x44,
-	0xff, 0x65, 0x28, 0x64,
-	0x00, 0x65, 0x48, 0x44,
+	0x00, 0x65, 0xd8, 0x5d,
+	0xa0, 0x3f, 0x28, 0x64,
+	0x00, 0xbb, 0x20, 0x44,
+	0xff, 0x65, 0x20, 0x64,
+	0x00, 0x65, 0x40, 0x44,
 	0x40, 0x6a, 0x18, 0x00,
 	0x01, 0x65, 0x0c, 0x30,
-	0x00, 0x65, 0xce, 0x5d,
-	0xa0, 0x3f, 0x04, 0x74,
+	0x00, 0x65, 0xd8, 0x5d,
+	0xa0, 0x3f, 0xfc, 0x73,
 	0x40, 0x6a, 0x18, 0x00,
 	0x01, 0x3a, 0xa6, 0x30,
 	0x08, 0x6a, 0x74, 0x00,
-	0x00, 0x65, 0xc4, 0x41,
-	0x64, 0x6a, 0x5e, 0x5d,
-	0x80, 0x64, 0xce, 0x6c,
-	0x04, 0x64, 0x94, 0x74,
-	0x02, 0x64, 0xa2, 0x74,
-	0x00, 0x6a, 0x64, 0x74,
-	0x03, 0x64, 0xc0, 0x74,
-	0x23, 0x64, 0x50, 0x74,
-	0x08, 0x64, 0x60, 0x74,
-	0x61, 0x6a, 0xce, 0x5e,
-	0x00, 0x65, 0xce, 0x5d,
-	0x08, 0x51, 0xc6, 0x71,
-	0x00, 0x65, 0x48, 0x44,
-	0x80, 0x04, 0x5e, 0x7c,
-	0x51, 0x6a, 0x54, 0x5d,
-	0x01, 0x51, 0x5e, 0x64,
-	0x01, 0xa4, 0x5a, 0x7c,
-	0x01, 0x55, 0x60, 0x7c,
-	0x41, 0x6a, 0xce, 0x5e,
-	0x00, 0x65, 0x60, 0x44,
-	0x07, 0x6a, 0x4a, 0x5d,
+	0x00, 0x65, 0xcc, 0x41,
+	0x64, 0x6a, 0x68, 0x5d,
+	0x80, 0x64, 0xd8, 0x6c,
+	0x04, 0x64, 0x9a, 0x74,
+	0x02, 0x64, 0xaa, 0x74,
+	0x00, 0x6a, 0x60, 0x74,
+	0x03, 0x64, 0xc8, 0x74,
+	0x23, 0x64, 0x48, 0x74,
+	0x08, 0x64, 0x5c, 0x74,
+	0x61, 0x6a, 0xd8, 0x5e,
+	0x00, 0x65, 0xd8, 0x5d,
+	0x08, 0x51, 0xce, 0x71,
+	0x00, 0x65, 0x40, 0x44,
+	0x80, 0x04, 0x5a, 0x7c,
+	0x51, 0x6a, 0x5e, 0x5d,
+	0x01, 0x51, 0x5a, 0x64,
+	0x01, 0xa4, 0x52, 0x7c,
+	0x80, 0xba, 0x5c, 0x6c,
+	0x41, 0x6a, 0xd8, 0x5e,
+	0x00, 0x65, 0x5c, 0x44,
+	0x21, 0x6a, 0xd8, 0x5e,
+	0x00, 0x65, 0x5c, 0x44,
+	0x07, 0x6a, 0x54, 0x5d,
 	0x01, 0x06, 0xd4, 0x30,
-	0x00, 0x65, 0xc4, 0x41,
-	0x10, 0xb8, 0x68, 0x7c,
-	0xa1, 0x6a, 0xce, 0x5e,
-	0x01, 0xb4, 0x6e, 0x6c,
-	0x02, 0xb4, 0x70, 0x6c,
-	0x01, 0xa4, 0x70, 0x7c,
-	0xff, 0xa8, 0x80, 0x7c,
+	0x00, 0x65, 0xcc, 0x41,
+	0x80, 0xb8, 0x56, 0x7c,
+	0xc0, 0x3c, 0x6a, 0x7c,
+	0x80, 0x3c, 0x56, 0x6c,
+	0xff, 0xa8, 0x6a, 0x6c,
+	0x40, 0x3c, 0x56, 0x6c,
+	0x10, 0xb8, 0x6e, 0x7c,
+	0xa1, 0x6a, 0xd8, 0x5e,
+	0x01, 0xb4, 0x74, 0x6c,
+	0x02, 0xb4, 0x76, 0x6c,
+	0x01, 0xa4, 0x76, 0x7c,
+	0xff, 0xa8, 0x86, 0x7c,
 	0x04, 0xb4, 0x68, 0x01,
 	0x01, 0x6a, 0x76, 0x00,
-	0x00, 0xbb, 0x08, 0x5e,
-	0xff, 0xa8, 0x80, 0x7c,
-	0x71, 0x6a, 0xce, 0x5e,
-	0x40, 0x51, 0x80, 0x64,
-	0x00, 0x65, 0xa8, 0x5e,
-	0x00, 0x65, 0xd6, 0x41,
-	0x00, 0xbb, 0x84, 0x5c,
-	0x00, 0x65, 0xd6, 0x41,
-	0x00, 0x65, 0xa8, 0x5e,
+	0x00, 0xbb, 0x12, 0x5e,
+	0xff, 0xa8, 0x86, 0x7c,
+	0x71, 0x6a, 0xd8, 0x5e,
+	0x40, 0x51, 0x86, 0x64,
+	0x00, 0x65, 0xb2, 0x5e,
+	0x00, 0x65, 0xde, 0x41,
+	0x00, 0xbb, 0x8a, 0x5c,
+	0x00, 0x65, 0xde, 0x41,
+	0x00, 0x65, 0xb2, 0x5e,
 	0x01, 0x65, 0xa2, 0x30,
 	0x01, 0xf8, 0xc8, 0x30,
 	0x01, 0x4e, 0xc8, 0x30,
-	0x00, 0x6a, 0xac, 0xdd,
-	0x00, 0x51, 0xbe, 0x5d,
+	0x00, 0x6a, 0xb6, 0xdd,
+	0x00, 0x51, 0xc8, 0x5d,
 	0x01, 0x4e, 0x9c, 0x18,
 	0x02, 0x6a, 0x22, 0x05,
+	0xc0, 0x3c, 0x56, 0x6c,
 	0x04, 0xb8, 0x70, 0x01,
-	0x00, 0x65, 0xca, 0x5e,
-	0x20, 0xb8, 0xd6, 0x69,
+	0x00, 0x65, 0xd4, 0x5e,
+	0x20, 0xb8, 0xde, 0x69,
 	0x01, 0xbb, 0xa2, 0x30,
-	0x01, 0xba, 0x7c, 0x30,
-	0x00, 0xb9, 0xc4, 0x5c,
-	0x00, 0x65, 0xd6, 0x41,
+	0x3f, 0xba, 0x7c, 0x08,
+	0x00, 0xb9, 0xce, 0x5c,
+	0x00, 0x65, 0xde, 0x41,
 	0x01, 0x06, 0xd4, 0x30,
-	0x20, 0x3c, 0xc4, 0x79,
-	0x20, 0x3c, 0x60, 0x7c,
-	0x01, 0xa4, 0xb0, 0x7c,
+	0x20, 0x3c, 0xcc, 0x79,
+	0x20, 0x3c, 0x5c, 0x7c,
+	0x01, 0xa4, 0xb8, 0x7c,
 	0x01, 0xb4, 0x68, 0x01,
-	0x00, 0x65, 0xc4, 0x41,
-	0x00, 0x65, 0x60, 0x44,
+	0x00, 0x65, 0xcc, 0x41,
+	0x00, 0x65, 0x5c, 0x44,
 	0x04, 0x14, 0x58, 0x31,
 	0x01, 0x06, 0xd4, 0x30,
 	0x08, 0xa0, 0x60, 0x31,
 	0xac, 0x6a, 0xcc, 0x00,
-	0x14, 0x6a, 0xea, 0x5d,
+	0x14, 0x6a, 0xf4, 0x5d,
 	0x01, 0x06, 0xd4, 0x30,
-	0xa0, 0x6a, 0xe2, 0x5d,
-	0x00, 0x65, 0xc4, 0x41,
+	0xa0, 0x6a, 0xec, 0x5d,
+	0x00, 0x65, 0xcc, 0x41,
 	0xdf, 0x3c, 0x78, 0x08,
-	0x00, 0x65, 0x60, 0x44,
+	0x12, 0x01, 0x02, 0x00,
+	0x00, 0x65, 0x5c, 0x44,
 	0x4c, 0x65, 0xcc, 0x28,
 	0x01, 0x3e, 0x20, 0x31,
 	0xd0, 0x66, 0xcc, 0x18,
@@ -626,102 +631,102 @@
 	0xd0, 0x65, 0xca, 0x18,
 	0x01, 0x3e, 0x20, 0x31,
 	0x30, 0x65, 0xd4, 0x18,
-	0x00, 0x65, 0xdc, 0x4c,
+	0x00, 0x65, 0xe6, 0x4c,
 	0xe1, 0x6a, 0x22, 0x01,
 	0xff, 0x6a, 0xd4, 0x08,
 	0x20, 0x65, 0xd4, 0x18,
-	0x00, 0x65, 0xe4, 0x54,
+	0x00, 0x65, 0xee, 0x54,
 	0xe1, 0x6a, 0x22, 0x01,
 	0xff, 0x6a, 0xd4, 0x08,
 	0x20, 0x65, 0xca, 0x18,
 	0xe0, 0x65, 0xd4, 0x18,
-	0x00, 0x65, 0xee, 0x4c,
+	0x00, 0x65, 0xf8, 0x4c,
 	0xe1, 0x6a, 0x22, 0x01,
 	0xff, 0x6a, 0xd4, 0x08,
 	0xd0, 0x65, 0xd4, 0x18,
-	0x00, 0x65, 0xf6, 0x54,
+	0x00, 0x65, 0x00, 0x55,
 	0xe1, 0x6a, 0x22, 0x01,
 	0xff, 0x6a, 0xd4, 0x08,
 	0x01, 0x6c, 0xa2, 0x30,
-	0xff, 0x51, 0x08, 0x75,
-	0x00, 0x51, 0x84, 0x5d,
+	0xff, 0x51, 0x12, 0x75,
+	0x00, 0x51, 0x8e, 0x5d,
 	0x01, 0x51, 0x20, 0x31,
-	0x00, 0x65, 0x2a, 0x45,
-	0x01, 0xba, 0xc8, 0x30,
-	0x00, 0x3e, 0x2a, 0x75,
-	0x00, 0x65, 0xa6, 0x5e,
+	0x00, 0x65, 0x34, 0x45,
+	0x3f, 0xba, 0xc8, 0x08,
+	0x00, 0x3e, 0x34, 0x75,
+	0x00, 0x65, 0xb0, 0x5e,
 	0x80, 0x3c, 0x78, 0x00,
 	0x01, 0x06, 0xd4, 0x30,
-	0x00, 0x65, 0xce, 0x5d,
+	0x00, 0x65, 0xd8, 0x5d,
 	0x01, 0x3c, 0x78, 0x00,
-	0xe0, 0x3f, 0x46, 0x65,
+	0xe0, 0x3f, 0x50, 0x65,
 	0x02, 0x3c, 0x78, 0x00,
-	0x20, 0x12, 0x46, 0x65,
-	0x51, 0x6a, 0x54, 0x5d,
-	0x00, 0x51, 0x84, 0x5d,
-	0x51, 0x6a, 0x54, 0x5d,
+	0x20, 0x12, 0x50, 0x65,
+	0x51, 0x6a, 0x5e, 0x5d,
+	0x00, 0x51, 0x8e, 0x5d,
+	0x51, 0x6a, 0x5e, 0x5d,
 	0x01, 0x51, 0x20, 0x31,
 	0x04, 0x3c, 0x78, 0x00,
 	0x01, 0xb9, 0xc8, 0x30,
-	0x00, 0x3d, 0x44, 0x65,
+	0x00, 0x3d, 0x4e, 0x65,
 	0x08, 0x3c, 0x78, 0x00,
-	0x01, 0xba, 0xc8, 0x30,
-	0x00, 0x3e, 0x44, 0x65,
+	0x3f, 0xba, 0xc8, 0x08,
+	0x00, 0x3e, 0x4e, 0x65,
 	0x10, 0x3c, 0x78, 0x00,
-	0x04, 0xb8, 0x44, 0x7d,
+	0x04, 0xb8, 0x4e, 0x7d,
 	0xfb, 0xb8, 0x70, 0x09,
-	0x20, 0xb8, 0x3a, 0x6d,
+	0x20, 0xb8, 0x44, 0x6d,
 	0x01, 0x90, 0xc8, 0x30,
 	0xff, 0x6a, 0xa2, 0x00,
-	0x00, 0x3d, 0xc4, 0x5c,
+	0x00, 0x3d, 0xce, 0x5c,
 	0x01, 0x64, 0x20, 0x31,
-	0x80, 0x6a, 0x78, 0x00,
-	0x00, 0x65, 0xec, 0x58,
-	0x10, 0xb8, 0x60, 0x7c,
-	0xff, 0x6a, 0x4a, 0x5d,
-	0x00, 0x65, 0x60, 0x44,
-	0x00, 0x65, 0xa6, 0x5e,
-	0x31, 0x6a, 0xce, 0x5e,
-	0x00, 0x65, 0x60, 0x44,
+	0xff, 0x6a, 0x78, 0x08,
+	0x00, 0x65, 0xea, 0x58,
+	0x10, 0xb8, 0x5c, 0x7c,
+	0xff, 0x6a, 0x54, 0x5d,
+	0x00, 0x65, 0x5c, 0x44,
+	0x00, 0x65, 0xb0, 0x5e,
+	0x31, 0x6a, 0xd8, 0x5e,
+	0x00, 0x65, 0x5c, 0x44,
 	0x10, 0x3f, 0x06, 0x00,
 	0x10, 0x6a, 0x06, 0x00,
 	0x01, 0x65, 0x74, 0x34,
-	0x81, 0x6a, 0xce, 0x5e,
-	0x00, 0x65, 0x56, 0x45,
+	0x81, 0x6a, 0xd8, 0x5e,
+	0x00, 0x65, 0x60, 0x45,
 	0x01, 0x06, 0xd4, 0x30,
-	0x01, 0x0c, 0x56, 0x7d,
-	0x04, 0x0c, 0x50, 0x6d,
+	0x01, 0x0c, 0x60, 0x7d,
+	0x04, 0x0c, 0x5a, 0x6d,
 	0xe0, 0x03, 0x7e, 0x08,
-	0xe0, 0x3f, 0xc4, 0x61,
+	0xe0, 0x3f, 0xcc, 0x61,
 	0x01, 0x65, 0xcc, 0x30,
 	0x01, 0x12, 0xda, 0x34,
 	0x01, 0x06, 0xd4, 0x34,
-	0x01, 0x03, 0x64, 0x6d,
+	0x01, 0x03, 0x6e, 0x6d,
 	0x40, 0x03, 0xcc, 0x08,
 	0x01, 0x65, 0x06, 0x30,
 	0x40, 0x65, 0xc8, 0x08,
-	0x00, 0x66, 0x72, 0x75,
-	0x40, 0x65, 0x72, 0x7d,
-	0x00, 0x65, 0x72, 0x5d,
+	0x00, 0x66, 0x7c, 0x75,
+	0x40, 0x65, 0x7c, 0x7d,
+	0x00, 0x65, 0x7c, 0x5d,
 	0xff, 0x6a, 0xd4, 0x08,
 	0xff, 0x6a, 0xd4, 0x08,
 	0xff, 0x6a, 0xd4, 0x08,
 	0xff, 0x6a, 0xd4, 0x0c,
 	0x08, 0x01, 0x02, 0x00,
-	0x02, 0x0b, 0x7c, 0x7d,
+	0x02, 0x0b, 0x86, 0x7d,
 	0x01, 0x65, 0x0c, 0x30,
-	0x02, 0x0b, 0x80, 0x7d,
+	0x02, 0x0b, 0x8a, 0x7d,
 	0xf7, 0x01, 0x02, 0x0c,
 	0x01, 0x65, 0xc8, 0x30,
-	0xff, 0x41, 0xa4, 0x75,
+	0xff, 0x41, 0xae, 0x75,
 	0x01, 0x41, 0x20, 0x31,
 	0xff, 0x6a, 0xa4, 0x00,
-	0x00, 0x65, 0x94, 0x45,
-	0xff, 0xbf, 0xa4, 0x75,
+	0x00, 0x65, 0x9e, 0x45,
+	0xff, 0xbf, 0xae, 0x75,
 	0x01, 0x90, 0xa4, 0x30,
 	0x01, 0xbf, 0x20, 0x31,
-	0x00, 0xbb, 0x8e, 0x65,
-	0xff, 0x52, 0xa2, 0x75,
+	0x00, 0xbb, 0x98, 0x65,
+	0xff, 0x52, 0xac, 0x75,
 	0x01, 0xbf, 0xcc, 0x30,
 	0x01, 0x90, 0xca, 0x30,
 	0x01, 0x52, 0x20, 0x31,
@@ -729,28 +734,28 @@
 	0x01, 0x65, 0x20, 0x35,
 	0x01, 0xbf, 0x82, 0x34,
 	0x01, 0x64, 0xa2, 0x30,
-	0x00, 0x6a, 0xb6, 0x5e,
+	0x00, 0x6a, 0xc0, 0x5e,
 	0x0d, 0x6a, 0x76, 0x00,
-	0x00, 0x51, 0x08, 0x46,
+	0x00, 0x51, 0x12, 0x46,
 	0x01, 0x65, 0xa4, 0x30,
 	0xe0, 0x6a, 0xcc, 0x00,
-	0x48, 0x6a, 0xfc, 0x5d,
+	0x48, 0x6a, 0x06, 0x5e,
 	0x01, 0x6a, 0xd0, 0x01,
 	0x01, 0x6a, 0xdc, 0x05,
 	0x88, 0x6a, 0xcc, 0x00,
-	0x48, 0x6a, 0xfc, 0x5d,
-	0x01, 0x6a, 0xd6, 0x5d,
+	0x48, 0x6a, 0x06, 0x5e,
+	0x01, 0x6a, 0xe0, 0x5d,
 	0x01, 0x6a, 0x26, 0x05,
 	0x01, 0x65, 0xd8, 0x31,
 	0x09, 0xee, 0xdc, 0x01,
-	0x80, 0xee, 0xc2, 0x7d,
+	0x80, 0xee, 0xcc, 0x7d,
 	0xff, 0x6a, 0xdc, 0x0d,
 	0x01, 0x65, 0x32, 0x31,
 	0x0a, 0x93, 0x26, 0x01,
-	0x00, 0x65, 0x9e, 0x46,
-	0x81, 0x6a, 0xce, 0x5e,
-	0x01, 0x0c, 0xce, 0x7d,
-	0x04, 0x0c, 0xcc, 0x6d,
+	0x00, 0x65, 0xa8, 0x46,
+	0x81, 0x6a, 0xd8, 0x5e,
+	0x01, 0x0c, 0xd8, 0x7d,
+	0x04, 0x0c, 0xd6, 0x6d,
 	0xe0, 0x03, 0x06, 0x08,
 	0xe0, 0x03, 0x7e, 0x0c,
 	0x01, 0x65, 0x18, 0x31,
@@ -769,7 +774,7 @@
 	0x01, 0x6c, 0xda, 0x34,
 	0x3d, 0x64, 0xa4, 0x28,
 	0x55, 0x64, 0xc8, 0x28,
-	0x00, 0x65, 0xfc, 0x45,
+	0x00, 0x65, 0x06, 0x46,
 	0x2e, 0x64, 0xa4, 0x28,
 	0x66, 0x64, 0xc8, 0x28,
 	0x00, 0x6c, 0xda, 0x18,
@@ -780,63 +785,63 @@
 	0x00, 0x6c, 0xda, 0x24,
 	0x01, 0x65, 0xc8, 0x30,
 	0xe0, 0x6a, 0xcc, 0x00,
-	0x44, 0x6a, 0xf8, 0x5d,
+	0x44, 0x6a, 0x02, 0x5e,
 	0x01, 0x90, 0xe2, 0x31,
-	0x04, 0x3b, 0x1c, 0x7e,
+	0x04, 0x3b, 0x26, 0x7e,
 	0x30, 0x6a, 0xd0, 0x01,
 	0x20, 0x6a, 0xd0, 0x01,
 	0x1d, 0x6a, 0xdc, 0x01,
-	0xdc, 0xee, 0x18, 0x66,
-	0x00, 0x65, 0x34, 0x46,
+	0xdc, 0xee, 0x22, 0x66,
+	0x00, 0x65, 0x3e, 0x46,
 	0x20, 0x6a, 0xd0, 0x01,
 	0x01, 0x6a, 0xdc, 0x01,
 	0x20, 0xa0, 0xd8, 0x31,
 	0x09, 0xee, 0xdc, 0x01,
-	0x80, 0xee, 0x24, 0x7e,
+	0x80, 0xee, 0x2e, 0x7e,
 	0x11, 0x6a, 0xdc, 0x01,
-	0x50, 0xee, 0x28, 0x66,
+	0x50, 0xee, 0x32, 0x66,
 	0x20, 0x6a, 0xd0, 0x01,
 	0x09, 0x6a, 0xdc, 0x01,
-	0x88, 0xee, 0x2e, 0x66,
+	0x88, 0xee, 0x38, 0x66,
 	0x19, 0x6a, 0xdc, 0x01,
-	0xd8, 0xee, 0x32, 0x66,
+	0xd8, 0xee, 0x3c, 0x66,
 	0xff, 0x6a, 0xdc, 0x09,
-	0x18, 0xee, 0x36, 0x6e,
+	0x18, 0xee, 0x40, 0x6e,
 	0xff, 0x6a, 0xd4, 0x0c,
 	0x88, 0x6a, 0xcc, 0x00,
-	0x44, 0x6a, 0xf8, 0x5d,
-	0x20, 0x6a, 0xd6, 0x5d,
+	0x44, 0x6a, 0x02, 0x5e,
+	0x20, 0x6a, 0xe0, 0x5d,
 	0x01, 0x3b, 0x26, 0x31,
-	0x04, 0x3b, 0x50, 0x6e,
+	0x04, 0x3b, 0x5a, 0x6e,
 	0xa0, 0x6a, 0xca, 0x00,
 	0x20, 0x65, 0xc8, 0x18,
-	0x00, 0x65, 0x8e, 0x5e,
-	0x00, 0x65, 0x48, 0x66,
+	0x00, 0x65, 0x98, 0x5e,
+	0x00, 0x65, 0x52, 0x66,
 	0x0a, 0x93, 0x26, 0x01,
-	0x00, 0x65, 0x9e, 0x46,
+	0x00, 0x65, 0xa8, 0x46,
 	0xa0, 0x6a, 0xcc, 0x00,
 	0xff, 0x6a, 0xc8, 0x08,
-	0x20, 0x94, 0x54, 0x6e,
-	0x10, 0x94, 0x56, 0x6e,
-	0x08, 0x94, 0x70, 0x6e,
-	0x08, 0x94, 0x70, 0x6e,
-	0x08, 0x94, 0x70, 0x6e,
+	0x20, 0x94, 0x5e, 0x6e,
+	0x10, 0x94, 0x60, 0x6e,
+	0x08, 0x94, 0x7a, 0x6e,
+	0x08, 0x94, 0x7a, 0x6e,
+	0x08, 0x94, 0x7a, 0x6e,
 	0xff, 0x8c, 0xc8, 0x10,
 	0xc1, 0x64, 0xc8, 0x18,
 	0xf8, 0x64, 0xc8, 0x08,
 	0x01, 0x99, 0xda, 0x30,
-	0x00, 0x66, 0x64, 0x66,
-	0xc0, 0x66, 0xa0, 0x76,
+	0x00, 0x66, 0x6e, 0x66,
+	0xc0, 0x66, 0xaa, 0x76,
 	0x60, 0x66, 0xc8, 0x18,
 	0x3d, 0x64, 0xc8, 0x28,
-	0x00, 0x65, 0x54, 0x46,
+	0x00, 0x65, 0x5e, 0x46,
 	0xf7, 0x93, 0x26, 0x09,
-	0x08, 0x93, 0x72, 0x6e,
+	0x08, 0x93, 0x7c, 0x6e,
 	0x00, 0x62, 0xc4, 0x18,
-	0x00, 0x65, 0x9e, 0x5e,
-	0x00, 0x65, 0x7e, 0x5e,
-	0x00, 0x65, 0x7e, 0x5e,
-	0x00, 0x65, 0x7e, 0x5e,
+	0x00, 0x65, 0xa8, 0x5e,
+	0x00, 0x65, 0x88, 0x5e,
+	0x00, 0x65, 0x88, 0x5e,
+	0x00, 0x65, 0x88, 0x5e,
 	0x01, 0x99, 0xda, 0x30,
 	0x01, 0x99, 0xda, 0x30,
 	0x01, 0x99, 0xda, 0x30,
@@ -853,11 +858,11 @@
 	0x01, 0x6c, 0x32, 0x31,
 	0x01, 0x6c, 0x32, 0x31,
 	0x01, 0x6c, 0x32, 0x35,
-	0x08, 0x94, 0x9e, 0x7e,
+	0x08, 0x94, 0xa8, 0x7e,
 	0xf7, 0x93, 0x26, 0x09,
-	0x08, 0x93, 0xa2, 0x6e,
+	0x08, 0x93, 0xac, 0x6e,
 	0xff, 0x6a, 0xd4, 0x0c,
-	0x04, 0xb8, 0xca, 0x6e,
+	0x04, 0xb8, 0xd4, 0x6e,
 	0x01, 0x42, 0x7e, 0x31,
 	0xff, 0x6a, 0x76, 0x01,
 	0x01, 0x90, 0x84, 0x34,
@@ -865,14 +870,14 @@
 	0x01, 0x85, 0x0a, 0x01,
 	0x7f, 0x65, 0x10, 0x09,
 	0xfe, 0x85, 0x0a, 0x0d,
-	0xff, 0x42, 0xc6, 0x66,
-	0xff, 0x41, 0xbe, 0x66,
-	0xd1, 0x6a, 0xce, 0x5e,
+	0xff, 0x42, 0xd0, 0x66,
+	0xff, 0x41, 0xc8, 0x66,
+	0xd1, 0x6a, 0xd8, 0x5e,
 	0xff, 0x6a, 0xca, 0x04,
 	0x01, 0x41, 0x20, 0x31,
 	0x01, 0xbf, 0x82, 0x30,
 	0x01, 0x6a, 0x76, 0x00,
-	0x00, 0xbb, 0x08, 0x46,
+	0x00, 0xbb, 0x12, 0x46,
 	0x01, 0x42, 0x20, 0x31,
 	0x01, 0xbf, 0x84, 0x34,
 	0x01, 0x41, 0x7e, 0x31,
@@ -882,420 +887,421 @@
 	0xff, 0x6a, 0xd4, 0x0c
 };
 
-static int aic_patch23_func(struct ahc_softc *ahc);
+typedef int ahc_patch_func_t (struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch23_func;
 
 static int
-aic_patch23_func(struct ahc_softc *ahc)
+ahc_patch23_func(struct ahc_softc *ahc)
 {
 	return ((ahc->bugs & AHC_SCBCHAN_UPLOAD_BUG) != 0);
 }
 
-static int aic_patch22_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch22_func;
 
 static int
-aic_patch22_func(struct ahc_softc *ahc)
+ahc_patch22_func(struct ahc_softc *ahc)
 {
 	return ((ahc->features & AHC_CMD_CHAN) == 0);
 }
 
-static int aic_patch21_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch21_func;
 
 static int
-aic_patch21_func(struct ahc_softc *ahc)
+ahc_patch21_func(struct ahc_softc *ahc)
 {
 	return ((ahc->features & AHC_QUEUE_REGS) == 0);
 }
 
-static int aic_patch20_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch20_func;
 
 static int
-aic_patch20_func(struct ahc_softc *ahc)
+ahc_patch20_func(struct ahc_softc *ahc)
 {
 	return ((ahc->features & AHC_WIDE) != 0);
 }
 
-static int aic_patch19_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch19_func;
 
 static int
-aic_patch19_func(struct ahc_softc *ahc)
+ahc_patch19_func(struct ahc_softc *ahc)
 {
 	return ((ahc->flags & AHC_SCB_BTT) != 0);
 }
 
-static int aic_patch18_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch18_func;
 
 static int
-aic_patch18_func(struct ahc_softc *ahc)
+ahc_patch18_func(struct ahc_softc *ahc)
 {
 	return ((ahc->bugs & AHC_PCI_2_1_RETRY_BUG) != 0);
 }
 
-static int aic_patch17_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch17_func;
 
 static int
-aic_patch17_func(struct ahc_softc *ahc)
+ahc_patch17_func(struct ahc_softc *ahc)
 {
 	return ((ahc->flags & AHC_TMODE_WIDEODD_BUG) != 0);
 }
 
-static int aic_patch16_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch16_func;
 
 static int
-aic_patch16_func(struct ahc_softc *ahc)
+ahc_patch16_func(struct ahc_softc *ahc)
 {
 	return ((ahc->bugs & AHC_AUTOFLUSH_BUG) != 0);
 }
 
-static int aic_patch15_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch15_func;
 
 static int
-aic_patch15_func(struct ahc_softc *ahc)
+ahc_patch15_func(struct ahc_softc *ahc)
 {
 	return ((ahc->features & AHC_ULTRA2) == 0);
 }
 
-static int aic_patch14_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch14_func;
 
 static int
-aic_patch14_func(struct ahc_softc *ahc)
+ahc_patch14_func(struct ahc_softc *ahc)
 {
 	return ((ahc->bugs & AHC_PCI_MWI_BUG) != 0 && ahc->pci_cachesize != 0);
 }
 
-static int aic_patch13_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch13_func;
 
 static int
-aic_patch13_func(struct ahc_softc *ahc)
+ahc_patch13_func(struct ahc_softc *ahc)
 {
 	return ((ahc->flags & AHC_39BIT_ADDRESSING) != 0);
 }
 
-static int aic_patch12_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch12_func;
 
 static int
-aic_patch12_func(struct ahc_softc *ahc)
+ahc_patch12_func(struct ahc_softc *ahc)
 {
 	return ((ahc->features & AHC_HS_MAILBOX) != 0);
 }
 
-static int aic_patch11_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch11_func;
 
 static int
-aic_patch11_func(struct ahc_softc *ahc)
+ahc_patch11_func(struct ahc_softc *ahc)
 {
 	return ((ahc->features & AHC_ULTRA) != 0);
 }
 
-static int aic_patch10_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch10_func;
 
 static int
-aic_patch10_func(struct ahc_softc *ahc)
+ahc_patch10_func(struct ahc_softc *ahc)
 {
 	return ((ahc->features & AHC_MULTI_TID) != 0);
 }
 
-static int aic_patch9_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch9_func;
 
 static int
-aic_patch9_func(struct ahc_softc *ahc)
+ahc_patch9_func(struct ahc_softc *ahc)
 {
 	return ((ahc->features & AHC_CMD_CHAN) != 0);
 }
 
-static int aic_patch8_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch8_func;
 
 static int
-aic_patch8_func(struct ahc_softc *ahc)
+ahc_patch8_func(struct ahc_softc *ahc)
 {
 	return ((ahc->flags & AHC_INITIATORROLE) != 0);
 }
 
-static int aic_patch7_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch7_func;
 
 static int
-aic_patch7_func(struct ahc_softc *ahc)
+ahc_patch7_func(struct ahc_softc *ahc)
 {
 	return ((ahc->flags & AHC_TARGETROLE) != 0);
 }
 
-static int aic_patch6_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch6_func;
 
 static int
-aic_patch6_func(struct ahc_softc *ahc)
+ahc_patch6_func(struct ahc_softc *ahc)
 {
 	return ((ahc->features & AHC_DT) == 0);
 }
 
-static int aic_patch5_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch5_func;
 
 static int
-aic_patch5_func(struct ahc_softc *ahc)
+ahc_patch5_func(struct ahc_softc *ahc)
 {
 	return ((ahc->flags & AHC_SEQUENCER_DEBUG) != 0);
 }
 
-static int aic_patch4_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch4_func;
 
 static int
-aic_patch4_func(struct ahc_softc *ahc)
+ahc_patch4_func(struct ahc_softc *ahc)
 {
 	return ((ahc->flags & AHC_PAGESCBS) != 0);
 }
 
-static int aic_patch3_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch3_func;
 
 static int
-aic_patch3_func(struct ahc_softc *ahc)
+ahc_patch3_func(struct ahc_softc *ahc)
 {
 	return ((ahc->features & AHC_QUEUE_REGS) != 0);
 }
 
-static int aic_patch2_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch2_func;
 
 static int
-aic_patch2_func(struct ahc_softc *ahc)
+ahc_patch2_func(struct ahc_softc *ahc)
 {
 	return ((ahc->features & AHC_TWIN) != 0);
 }
 
-static int aic_patch1_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch1_func;
 
 static int
-aic_patch1_func(struct ahc_softc *ahc)
+ahc_patch1_func(struct ahc_softc *ahc)
 {
 	return ((ahc->features & AHC_ULTRA2) != 0);
 }
 
-static int aic_patch0_func(struct ahc_softc *ahc);
+static ahc_patch_func_t ahc_patch0_func;
 
 static int
-aic_patch0_func(struct ahc_softc *ahc)
+ahc_patch0_func(struct ahc_softc *ahc)
 {
 	return (0);
 }
 
-typedef int patch_func_t (struct ahc_softc *ahc);
 static struct patch {
-	patch_func_t	*patch_func;
-	uint32_t	begin	   :10,
-			skip_instr :10,
-			skip_patch :12;
+	ahc_patch_func_t		*patch_func;
+	uint32_t		 begin		:10,
+				 skip_instr	:10,
+				 skip_patch	:12;
 } patches[] = {
-	{ aic_patch1_func, 4, 1, 1 },
-	{ aic_patch2_func, 6, 2, 1 },
-	{ aic_patch2_func, 9, 1, 1 },
-	{ aic_patch3_func, 11, 1, 2 },
-	{ aic_patch0_func, 12, 2, 1 },
-	{ aic_patch4_func, 15, 1, 2 },
-	{ aic_patch0_func, 16, 1, 1 },
-	{ aic_patch5_func, 22, 2, 1 },
-	{ aic_patch3_func, 27, 1, 2 },
-	{ aic_patch0_func, 28, 1, 1 },
-	{ aic_patch6_func, 34, 1, 1 },
-	{ aic_patch7_func, 37, 54, 19 },
-	{ aic_patch8_func, 37, 1, 1 },
-	{ aic_patch9_func, 42, 3, 2 },
-	{ aic_patch0_func, 45, 3, 1 },
-	{ aic_patch10_func, 49, 1, 2 },
-	{ aic_patch0_func, 50, 2, 3 },
-	{ aic_patch1_func, 50, 1, 2 },
-	{ aic_patch0_func, 51, 1, 1 },
-	{ aic_patch2_func, 53, 2, 1 },
-	{ aic_patch9_func, 55, 1, 2 },
-	{ aic_patch0_func, 56, 1, 1 },
-	{ aic_patch9_func, 60, 1, 2 },
-	{ aic_patch0_func, 61, 1, 1 },
-	{ aic_patch9_func, 71, 1, 2 },
-	{ aic_patch0_func, 72, 1, 1 },
-	{ aic_patch9_func, 75, 1, 2 },
-	{ aic_patch0_func, 76, 1, 1 },
-	{ aic_patch9_func, 79, 1, 2 },
-	{ aic_patch0_func, 80, 1, 1 },
-	{ aic_patch8_func, 91, 9, 4 },
-	{ aic_patch1_func, 93, 1, 2 },
-	{ aic_patch0_func, 94, 1, 1 },
-	{ aic_patch2_func, 96, 2, 1 },
-	{ aic_patch2_func, 105, 4, 1 },
-	{ aic_patch1_func, 109, 1, 2 },
-	{ aic_patch0_func, 110, 2, 3 },
-	{ aic_patch2_func, 110, 1, 2 },
-	{ aic_patch0_func, 111, 1, 1 },
-	{ aic_patch7_func, 112, 4, 2 },
-	{ aic_patch0_func, 116, 1, 1 },
-	{ aic_patch11_func, 118, 2, 1 },
-	{ aic_patch1_func, 120, 1, 2 },
-	{ aic_patch0_func, 121, 1, 1 },
-	{ aic_patch7_func, 122, 4, 1 },
-	{ aic_patch7_func, 132, 91, 11 },
-	{ aic_patch4_func, 151, 1, 1 },
-	{ aic_patch1_func, 165, 1, 1 },
-	{ aic_patch12_func, 170, 1, 2 },
-	{ aic_patch0_func, 171, 1, 1 },
-	{ aic_patch9_func, 182, 1, 2 },
-	{ aic_patch0_func, 183, 1, 1 },
-	{ aic_patch9_func, 192, 1, 2 },
-	{ aic_patch0_func, 193, 1, 1 },
-	{ aic_patch9_func, 209, 6, 2 },
-	{ aic_patch0_func, 215, 6, 1 },
-	{ aic_patch8_func, 223, 19, 2 },
-	{ aic_patch1_func, 237, 1, 1 },
-	{ aic_patch1_func, 244, 1, 2 },
-	{ aic_patch0_func, 245, 2, 2 },
-	{ aic_patch11_func, 246, 1, 1 },
-	{ aic_patch9_func, 254, 31, 3 },
-	{ aic_patch1_func, 270, 14, 2 },
-	{ aic_patch13_func, 275, 1, 1 },
-	{ aic_patch14_func, 285, 14, 1 },
-	{ aic_patch1_func, 301, 1, 2 },
-	{ aic_patch0_func, 302, 1, 1 },
-	{ aic_patch9_func, 305, 1, 1 },
-	{ aic_patch13_func, 310, 1, 1 },
-	{ aic_patch9_func, 311, 2, 2 },
-	{ aic_patch0_func, 313, 4, 1 },
-	{ aic_patch14_func, 317, 1, 1 },
-	{ aic_patch15_func, 320, 2, 3 },
-	{ aic_patch9_func, 320, 1, 2 },
-	{ aic_patch0_func, 321, 1, 1 },
-	{ aic_patch6_func, 326, 1, 2 },
-	{ aic_patch0_func, 327, 1, 1 },
-	{ aic_patch1_func, 331, 50, 11 },
-	{ aic_patch6_func, 340, 2, 4 },
-	{ aic_patch7_func, 340, 1, 1 },
-	{ aic_patch8_func, 341, 1, 1 },
-	{ aic_patch0_func, 342, 1, 1 },
-	{ aic_patch16_func, 343, 1, 1 },
-	{ aic_patch6_func, 362, 6, 3 },
-	{ aic_patch16_func, 362, 5, 1 },
-	{ aic_patch0_func, 368, 5, 1 },
-	{ aic_patch13_func, 376, 5, 1 },
-	{ aic_patch0_func, 381, 54, 17 },
-	{ aic_patch14_func, 381, 1, 1 },
-	{ aic_patch7_func, 383, 2, 2 },
-	{ aic_patch17_func, 384, 1, 1 },
-	{ aic_patch9_func, 387, 1, 1 },
-	{ aic_patch18_func, 394, 1, 1 },
-	{ aic_patch14_func, 399, 9, 3 },
-	{ aic_patch9_func, 400, 3, 2 },
-	{ aic_patch0_func, 403, 3, 1 },
-	{ aic_patch9_func, 411, 6, 2 },
-	{ aic_patch0_func, 417, 9, 2 },
-	{ aic_patch13_func, 417, 1, 1 },
-	{ aic_patch13_func, 426, 2, 1 },
-	{ aic_patch14_func, 428, 1, 1 },
-	{ aic_patch9_func, 430, 1, 2 },
-	{ aic_patch0_func, 431, 1, 1 },
-	{ aic_patch7_func, 434, 1, 1 },
-	{ aic_patch7_func, 435, 1, 1 },
-	{ aic_patch8_func, 436, 3, 3 },
-	{ aic_patch6_func, 437, 1, 2 },
-	{ aic_patch0_func, 438, 1, 1 },
-	{ aic_patch9_func, 439, 1, 1 },
-	{ aic_patch15_func, 440, 1, 2 },
-	{ aic_patch13_func, 440, 1, 1 },
-	{ aic_patch14_func, 442, 9, 4 },
-	{ aic_patch9_func, 442, 1, 1 },
-	{ aic_patch9_func, 449, 2, 1 },
-	{ aic_patch0_func, 451, 4, 3 },
-	{ aic_patch9_func, 451, 1, 2 },
-	{ aic_patch0_func, 452, 3, 1 },
-	{ aic_patch1_func, 456, 2, 1 },
-	{ aic_patch7_func, 458, 10, 2 },
-	{ aic_patch0_func, 468, 1, 1 },
-	{ aic_patch8_func, 469, 109, 23 },
-	{ aic_patch1_func, 471, 3, 2 },
-	{ aic_patch0_func, 474, 5, 3 },
-	{ aic_patch9_func, 474, 2, 2 },
-	{ aic_patch0_func, 476, 3, 1 },
-	{ aic_patch1_func, 481, 2, 2 },
-	{ aic_patch0_func, 483, 6, 3 },
-	{ aic_patch9_func, 483, 2, 2 },
-	{ aic_patch0_func, 485, 3, 1 },
-	{ aic_patch1_func, 491, 2, 2 },
-	{ aic_patch0_func, 493, 9, 7 },
-	{ aic_patch9_func, 493, 5, 6 },
-	{ aic_patch19_func, 493, 1, 2 },
-	{ aic_patch0_func, 494, 1, 1 },
-	{ aic_patch19_func, 496, 1, 2 },
-	{ aic_patch0_func, 497, 1, 1 },
-	{ aic_patch0_func, 498, 4, 1 },
-	{ aic_patch6_func, 502, 3, 2 },
-	{ aic_patch0_func, 505, 1, 1 },
-	{ aic_patch1_func, 508, 1, 1 },
-	{ aic_patch6_func, 514, 1, 2 },
-	{ aic_patch0_func, 515, 1, 1 },
-	{ aic_patch20_func, 552, 7, 1 },
-	{ aic_patch3_func, 580, 1, 2 },
-	{ aic_patch0_func, 581, 1, 1 },
-	{ aic_patch21_func, 584, 1, 1 },
-	{ aic_patch8_func, 586, 104, 33 },
-	{ aic_patch4_func, 587, 1, 1 },
-	{ aic_patch1_func, 593, 2, 2 },
-	{ aic_patch0_func, 595, 1, 1 },
-	{ aic_patch1_func, 598, 1, 2 },
-	{ aic_patch0_func, 599, 1, 1 },
-	{ aic_patch9_func, 600, 3, 3 },
-	{ aic_patch15_func, 601, 1, 1 },
-	{ aic_patch0_func, 603, 4, 1 },
-	{ aic_patch19_func, 611, 2, 2 },
-	{ aic_patch0_func, 613, 1, 1 },
-	{ aic_patch19_func, 617, 10, 3 },
-	{ aic_patch5_func, 619, 8, 1 },
-	{ aic_patch0_func, 627, 9, 2 },
-	{ aic_patch5_func, 628, 8, 1 },
-	{ aic_patch4_func, 638, 1, 2 },
-	{ aic_patch0_func, 639, 1, 1 },
-	{ aic_patch19_func, 640, 1, 2 },
-	{ aic_patch0_func, 641, 3, 2 },
-	{ aic_patch4_func, 643, 1, 1 },
-	{ aic_patch5_func, 644, 1, 1 },
-	{ aic_patch5_func, 647, 1, 1 },
-	{ aic_patch5_func, 649, 1, 1 },
-	{ aic_patch4_func, 651, 2, 2 },
-	{ aic_patch0_func, 653, 2, 1 },
-	{ aic_patch5_func, 655, 1, 1 },
-	{ aic_patch5_func, 658, 1, 1 },
-	{ aic_patch5_func, 661, 1, 1 },
-	{ aic_patch19_func, 665, 1, 1 },
-	{ aic_patch19_func, 668, 1, 1 },
-	{ aic_patch4_func, 674, 1, 1 },
-	{ aic_patch6_func, 677, 1, 2 },
-	{ aic_patch0_func, 678, 1, 1 },
-	{ aic_patch7_func, 690, 16, 1 },
-	{ aic_patch4_func, 706, 20, 1 },
-	{ aic_patch9_func, 727, 4, 2 },
-	{ aic_patch0_func, 731, 4, 1 },
-	{ aic_patch9_func, 735, 4, 2 },
-	{ aic_patch0_func, 739, 3, 1 },
-	{ aic_patch6_func, 745, 1, 1 },
-	{ aic_patch22_func, 747, 14, 1 },
-	{ aic_patch7_func, 761, 3, 1 },
-	{ aic_patch9_func, 773, 24, 8 },
-	{ aic_patch19_func, 777, 1, 2 },
-	{ aic_patch0_func, 778, 1, 1 },
-	{ aic_patch15_func, 783, 4, 2 },
-	{ aic_patch0_func, 787, 7, 3 },
-	{ aic_patch23_func, 787, 5, 2 },
-	{ aic_patch0_func, 792, 2, 1 },
-	{ aic_patch0_func, 797, 42, 3 },
-	{ aic_patch18_func, 809, 18, 2 },
-	{ aic_patch0_func, 827, 1, 1 },
-	{ aic_patch4_func, 851, 1, 1 },
-	{ aic_patch4_func, 852, 3, 2 },
-	{ aic_patch0_func, 855, 1, 1 },
-	{ aic_patch13_func, 856, 3, 1 },
-	{ aic_patch4_func, 859, 12, 1 }
+	{ ahc_patch1_func, 4, 1, 1 },
+	{ ahc_patch2_func, 6, 2, 1 },
+	{ ahc_patch2_func, 9, 1, 1 },
+	{ ahc_patch3_func, 11, 1, 2 },
+	{ ahc_patch0_func, 12, 2, 1 },
+	{ ahc_patch4_func, 15, 1, 2 },
+	{ ahc_patch0_func, 16, 1, 1 },
+	{ ahc_patch5_func, 22, 2, 1 },
+	{ ahc_patch3_func, 27, 1, 2 },
+	{ ahc_patch0_func, 28, 1, 1 },
+	{ ahc_patch6_func, 34, 1, 1 },
+	{ ahc_patch7_func, 37, 54, 19 },
+	{ ahc_patch8_func, 37, 1, 1 },
+	{ ahc_patch9_func, 42, 3, 2 },
+	{ ahc_patch0_func, 45, 3, 1 },
+	{ ahc_patch10_func, 49, 1, 2 },
+	{ ahc_patch0_func, 50, 2, 3 },
+	{ ahc_patch1_func, 50, 1, 2 },
+	{ ahc_patch0_func, 51, 1, 1 },
+	{ ahc_patch2_func, 53, 2, 1 },
+	{ ahc_patch9_func, 55, 1, 2 },
+	{ ahc_patch0_func, 56, 1, 1 },
+	{ ahc_patch9_func, 60, 1, 2 },
+	{ ahc_patch0_func, 61, 1, 1 },
+	{ ahc_patch9_func, 71, 1, 2 },
+	{ ahc_patch0_func, 72, 1, 1 },
+	{ ahc_patch9_func, 75, 1, 2 },
+	{ ahc_patch0_func, 76, 1, 1 },
+	{ ahc_patch9_func, 79, 1, 2 },
+	{ ahc_patch0_func, 80, 1, 1 },
+	{ ahc_patch8_func, 91, 9, 4 },
+	{ ahc_patch1_func, 93, 1, 2 },
+	{ ahc_patch0_func, 94, 1, 1 },
+	{ ahc_patch2_func, 96, 2, 1 },
+	{ ahc_patch2_func, 105, 4, 1 },
+	{ ahc_patch1_func, 109, 1, 2 },
+	{ ahc_patch0_func, 110, 2, 3 },
+	{ ahc_patch2_func, 110, 1, 2 },
+	{ ahc_patch0_func, 111, 1, 1 },
+	{ ahc_patch7_func, 112, 4, 2 },
+	{ ahc_patch0_func, 116, 1, 1 },
+	{ ahc_patch11_func, 117, 2, 1 },
+	{ ahc_patch1_func, 119, 1, 2 },
+	{ ahc_patch0_func, 120, 1, 1 },
+	{ ahc_patch7_func, 121, 4, 1 },
+	{ ahc_patch7_func, 131, 95, 11 },
+	{ ahc_patch4_func, 151, 1, 1 },
+	{ ahc_patch1_func, 168, 1, 1 },
+	{ ahc_patch12_func, 173, 1, 2 },
+	{ ahc_patch0_func, 174, 1, 1 },
+	{ ahc_patch9_func, 185, 1, 2 },
+	{ ahc_patch0_func, 186, 1, 1 },
+	{ ahc_patch9_func, 195, 1, 2 },
+	{ ahc_patch0_func, 196, 1, 1 },
+	{ ahc_patch9_func, 212, 6, 2 },
+	{ ahc_patch0_func, 218, 6, 1 },
+	{ ahc_patch8_func, 226, 20, 2 },
+	{ ahc_patch1_func, 241, 1, 1 },
+	{ ahc_patch1_func, 248, 1, 2 },
+	{ ahc_patch0_func, 249, 2, 2 },
+	{ ahc_patch11_func, 250, 1, 1 },
+	{ ahc_patch9_func, 258, 27, 3 },
+	{ ahc_patch1_func, 274, 10, 2 },
+	{ ahc_patch13_func, 277, 1, 1 },
+	{ ahc_patch14_func, 285, 14, 1 },
+	{ ahc_patch1_func, 301, 1, 2 },
+	{ ahc_patch0_func, 302, 1, 1 },
+	{ ahc_patch9_func, 305, 1, 1 },
+	{ ahc_patch13_func, 310, 1, 1 },
+	{ ahc_patch9_func, 311, 2, 2 },
+	{ ahc_patch0_func, 313, 4, 1 },
+	{ ahc_patch14_func, 317, 1, 1 },
+	{ ahc_patch15_func, 319, 2, 3 },
+	{ ahc_patch9_func, 319, 1, 2 },
+	{ ahc_patch0_func, 320, 1, 1 },
+	{ ahc_patch6_func, 325, 1, 2 },
+	{ ahc_patch0_func, 326, 1, 1 },
+	{ ahc_patch1_func, 330, 47, 11 },
+	{ ahc_patch6_func, 337, 2, 4 },
+	{ ahc_patch7_func, 337, 1, 1 },
+	{ ahc_patch8_func, 338, 1, 1 },
+	{ ahc_patch0_func, 339, 1, 1 },
+	{ ahc_patch16_func, 340, 1, 1 },
+	{ ahc_patch6_func, 356, 6, 3 },
+	{ ahc_patch16_func, 356, 5, 1 },
+	{ ahc_patch0_func, 362, 7, 1 },
+	{ ahc_patch13_func, 372, 5, 1 },
+	{ ahc_patch0_func, 377, 52, 17 },
+	{ ahc_patch14_func, 377, 1, 1 },
+	{ ahc_patch7_func, 379, 2, 2 },
+	{ ahc_patch17_func, 380, 1, 1 },
+	{ ahc_patch9_func, 383, 1, 1 },
+	{ ahc_patch18_func, 390, 1, 1 },
+	{ ahc_patch14_func, 395, 9, 3 },
+	{ ahc_patch9_func, 396, 3, 2 },
+	{ ahc_patch0_func, 399, 3, 1 },
+	{ ahc_patch9_func, 407, 6, 2 },
+	{ ahc_patch0_func, 413, 9, 2 },
+	{ ahc_patch13_func, 413, 1, 1 },
+	{ ahc_patch13_func, 422, 2, 1 },
+	{ ahc_patch14_func, 424, 1, 1 },
+	{ ahc_patch9_func, 426, 1, 2 },
+	{ ahc_patch0_func, 427, 1, 1 },
+	{ ahc_patch7_func, 428, 1, 1 },
+	{ ahc_patch7_func, 429, 1, 1 },
+	{ ahc_patch8_func, 430, 3, 3 },
+	{ ahc_patch6_func, 431, 1, 2 },
+	{ ahc_patch0_func, 432, 1, 1 },
+	{ ahc_patch9_func, 433, 1, 1 },
+	{ ahc_patch15_func, 434, 1, 2 },
+	{ ahc_patch13_func, 434, 1, 1 },
+	{ ahc_patch14_func, 436, 9, 4 },
+	{ ahc_patch9_func, 436, 1, 1 },
+	{ ahc_patch9_func, 443, 2, 1 },
+	{ ahc_patch0_func, 445, 4, 3 },
+	{ ahc_patch9_func, 445, 1, 2 },
+	{ ahc_patch0_func, 446, 3, 1 },
+	{ ahc_patch1_func, 450, 2, 1 },
+	{ ahc_patch7_func, 452, 10, 2 },
+	{ ahc_patch0_func, 462, 1, 1 },
+	{ ahc_patch8_func, 463, 118, 22 },
+	{ ahc_patch1_func, 465, 3, 2 },
+	{ ahc_patch0_func, 468, 5, 3 },
+	{ ahc_patch9_func, 468, 2, 2 },
+	{ ahc_patch0_func, 470, 3, 1 },
+	{ ahc_patch1_func, 475, 2, 2 },
+	{ ahc_patch0_func, 477, 6, 3 },
+	{ ahc_patch9_func, 477, 2, 2 },
+	{ ahc_patch0_func, 479, 3, 1 },
+	{ ahc_patch1_func, 485, 2, 2 },
+	{ ahc_patch0_func, 487, 9, 7 },
+	{ ahc_patch9_func, 487, 5, 6 },
+	{ ahc_patch19_func, 487, 1, 2 },
+	{ ahc_patch0_func, 488, 1, 1 },
+	{ ahc_patch19_func, 490, 1, 2 },
+	{ ahc_patch0_func, 491, 1, 1 },
+	{ ahc_patch0_func, 492, 4, 1 },
+	{ ahc_patch6_func, 497, 3, 2 },
+	{ ahc_patch0_func, 500, 1, 1 },
+	{ ahc_patch6_func, 510, 1, 2 },
+	{ ahc_patch0_func, 511, 1, 1 },
+	{ ahc_patch20_func, 548, 7, 1 },
+	{ ahc_patch3_func, 583, 1, 2 },
+	{ ahc_patch0_func, 584, 1, 1 },
+	{ ahc_patch21_func, 587, 1, 1 },
+	{ ahc_patch8_func, 589, 106, 33 },
+	{ ahc_patch4_func, 591, 1, 1 },
+	{ ahc_patch1_func, 597, 2, 2 },
+	{ ahc_patch0_func, 599, 1, 1 },
+	{ ahc_patch1_func, 602, 1, 2 },
+	{ ahc_patch0_func, 603, 1, 1 },
+	{ ahc_patch9_func, 604, 3, 3 },
+	{ ahc_patch15_func, 605, 1, 1 },
+	{ ahc_patch0_func, 607, 4, 1 },
+	{ ahc_patch19_func, 616, 2, 2 },
+	{ ahc_patch0_func, 618, 1, 1 },
+	{ ahc_patch19_func, 622, 10, 3 },
+	{ ahc_patch5_func, 624, 8, 1 },
+	{ ahc_patch0_func, 632, 9, 2 },
+	{ ahc_patch5_func, 633, 8, 1 },
+	{ ahc_patch4_func, 643, 1, 2 },
+	{ ahc_patch0_func, 644, 1, 1 },
+	{ ahc_patch19_func, 645, 1, 2 },
+	{ ahc_patch0_func, 646, 3, 2 },
+	{ ahc_patch4_func, 648, 1, 1 },
+	{ ahc_patch5_func, 649, 1, 1 },
+	{ ahc_patch5_func, 652, 1, 1 },
+	{ ahc_patch5_func, 654, 1, 1 },
+	{ ahc_patch4_func, 656, 2, 2 },
+	{ ahc_patch0_func, 658, 2, 1 },
+	{ ahc_patch5_func, 660, 1, 1 },
+	{ ahc_patch5_func, 663, 1, 1 },
+	{ ahc_patch5_func, 666, 1, 1 },
+	{ ahc_patch19_func, 670, 1, 1 },
+	{ ahc_patch19_func, 673, 1, 1 },
+	{ ahc_patch4_func, 679, 1, 1 },
+	{ ahc_patch6_func, 682, 1, 2 },
+	{ ahc_patch0_func, 683, 1, 1 },
+	{ ahc_patch7_func, 695, 16, 1 },
+	{ ahc_patch4_func, 711, 20, 1 },
+	{ ahc_patch9_func, 732, 4, 2 },
+	{ ahc_patch0_func, 736, 4, 1 },
+	{ ahc_patch9_func, 740, 4, 2 },
+	{ ahc_patch0_func, 744, 3, 1 },
+	{ ahc_patch6_func, 750, 1, 1 },
+	{ ahc_patch22_func, 752, 14, 1 },
+	{ ahc_patch7_func, 766, 3, 1 },
+	{ ahc_patch9_func, 778, 24, 8 },
+	{ ahc_patch19_func, 782, 1, 2 },
+	{ ahc_patch0_func, 783, 1, 1 },
+	{ ahc_patch15_func, 788, 4, 2 },
+	{ ahc_patch0_func, 792, 7, 3 },
+	{ ahc_patch23_func, 792, 5, 2 },
+	{ ahc_patch0_func, 797, 2, 1 },
+	{ ahc_patch0_func, 802, 42, 3 },
+	{ ahc_patch18_func, 814, 18, 2 },
+	{ ahc_patch0_func, 832, 1, 1 },
+	{ ahc_patch4_func, 856, 1, 1 },
+	{ ahc_patch4_func, 857, 3, 2 },
+	{ ahc_patch0_func, 860, 1, 1 },
+	{ ahc_patch13_func, 861, 3, 1 },
+	{ ahc_patch4_func, 864, 12, 1 }
 };
+
 static struct cs {
-	u_int16_t	begin;
-	u_int16_t	end;
+	uint16_t	begin;
+	uint16_t	end;
 } critical_sections[] = {
 	{ 11, 18 },
 	{ 21, 30 },
-	{ 706, 722 },
-	{ 852, 855 },
-	{ 859, 865 },
-	{ 867, 869 },
-	{ 869, 871 }
+	{ 711, 727 },
+	{ 857, 860 },
+	{ 864, 870 },
+	{ 872, 874 },
+	{ 874, 876 }
 };
+
 static const int num_critical_sections = sizeof(critical_sections)
 				       / sizeof(*critical_sections);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aicasm/Makefile linux-2.4.22-pre2/drivers/scsi/aic7xxx/aicasm/Makefile
--- linux-2.4.21/drivers/scsi/aic7xxx/aicasm/Makefile	2002-08-03 00:39:44.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aicasm/Makefile	2003-06-26 21:43:16.000000000 +0000
@@ -10,9 +10,10 @@
 GENSRCS=	$(YSRCS:.y=.c) $(LSRCS:.l=.c)
 
 SRCS=	${CSRCS} ${GENSRCS}
-CLEANFILES= ${GENSRCS} ${GENHDRS} $(YSRCS:.y=.output)
+LIBS=	-ldb
+clean-files:= ${GENSRCS} ${GENHDRS} $(YSRCS:.y=.output) $(PROG)
 # Override default kernel CFLAGS.  This is a userland app.
-AICASM_CFLAGS:= -I/usr/include -I. -ldb
+AICASM_CFLAGS:= -I/usr/include -I.
 YFLAGS= -d
 
 NOMAN=	noman
@@ -30,7 +31,7 @@
 endif
 
 $(PROG):  ${GENHDRS} $(SRCS)
-	$(AICASM_CC) $(AICASM_CFLAGS) $(SRCS) -o $(PROG)
+	$(AICASM_CC) $(AICASM_CFLAGS) $(SRCS) -o $(PROG) $(LIBS)
 
 aicdb.h:
 	@if [ -e "/usr/include/db3/db_185.h" ]; then		\
@@ -46,7 +47,7 @@
 	 fi
 
 clean:
-	rm -f $(CLEANFILES) $(PROG)
+	rm -f $(clean-files)
 
 aicasm_gram.c aicasm_gram.h: aicasm_gram.y
 	$(YACC) $(YFLAGS) -b $(<:.y=) $<
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aicasm/aicasm.c linux-2.4.22-pre2/drivers/scsi/aic7xxx/aicasm/aicasm.c
--- linux-2.4.21/drivers/scsi/aic7xxx/aicasm/aicasm.c	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aicasm/aicasm.c	2003-06-26 21:43:16.000000000 +0000
@@ -2,7 +2,7 @@
  * Aic7xxx SCSI host adapter firmware asssembler
  *
  * Copyright (c) 1997, 1998, 2000, 2001 Justin T. Gibbs.
- * Copyright (c) 2001 Adaptec Inc.
+ * Copyright (c) 2001, 2002 Adaptec Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -37,9 +37,9 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#16 $
+ * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#22 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm.c,v 1.28.2.5 2002/04/29 19:36:36 gibbs Exp $
+ * $FreeBSD$
  */
 #include <sys/types.h>
 #include <sys/mman.h>
@@ -85,12 +85,15 @@
 struct path_list search_path;
 int includes_search_curdir;
 char *appname;
+char *stock_include_file;
 FILE *ofile;
 char *ofilename;
 char *regfilename;
 FILE *regfile;
 char *listfilename;
 FILE *listfile;
+char *regdiagfilename;
+FILE *regdiagfile;
 int   src_mode;
 int   dst_mode;
 
@@ -140,7 +143,7 @@
 	yydebug = 0;
 	mmdebug = 0;
 #endif
-	while ((ch = getopt(argc, argv, "d:l:n:o:r:I:O:")) != -1) {
+	while ((ch = getopt(argc, argv, "d:i:l:n:o:p:r:I:")) != -1) {
 		switch(ch) {
 		case 'd':
 #if DEBUG
@@ -160,6 +163,9 @@
 			     "information", EX_SOFTWARE);
 #endif
 			break;
+		case 'i':
+			stock_include_file = optarg;
+			break;
 		case 'l':
 			/* Create a program listing */
 			if ((listfile = fopen(optarg, "w")) == NULL) {
@@ -184,6 +190,14 @@
 			}
 			ofilename = optarg;
 			break;
+		case 'p':
+			/* Create Register Diagnostic "printing" Functions */
+			if ((regdiagfile = fopen(optarg, "w")) == NULL) {
+				perror(optarg);
+				stop(NULL, EX_CANTCREAT);
+			}
+			regdiagfilename = optarg;
+			break;
 		case 'r':
 			if ((regfile = fopen(optarg, "w")) == NULL) {
 				perror(optarg);
@@ -245,6 +259,14 @@
 		/* NOTREACHED */
 	}
 
+	if (regdiagfile != NULL
+	 && (regfile == NULL || stock_include_file == NULL)) {
+		fprintf(stderr,
+			"%s: The -p option requires the -r and -i options.\n",
+			appname);
+		usage();
+		/* NOTREACHED */
+	}
 	symtable_open();
 	inputfilename = *argv;
 	include_file(*argv, SOURCE_FILE);
@@ -271,9 +293,8 @@
 
 		if (ofile != NULL)
 			output_code();
-		if (regfile != NULL) {
-			symtable_dump(regfile);
-		}
+		if (regfile != NULL)
+			symtable_dump(regfile, regdiagfile);
 		if (listfile != NULL)
 			output_listing(inputfilename);
 	}
@@ -288,10 +309,10 @@
 {
 
 	(void)fprintf(stderr,
-"usage: %-16s [-nostdinc] [-I-] [-I directory] [-o output_file]
-			[-r register_output_file] [-l program_list_file]
-			input_file\n",
-			appname);
+"usage: %-16s [-nostdinc] [-I-] [-I directory] [-o output_file]\n"
+"	[-r register_output_file [-p register_diag_file -i includefile]]\n"
+"	[-l program_list_file]\n"
+"	input_file\n", appname);
 	exit(EX_USAGE);
 }
 
@@ -335,11 +356,11 @@
 
 	instrcount = 0;
 	fprintf(ofile,
-"/*
- * DO NOT EDIT - This file is automatically generated
- *		 from the following source files:
- *
-%s */\n", versions);
+"/*\n"
+" * DO NOT EDIT - This file is automatically generated\n"
+" *		 from the following source files:\n"
+" *\n"
+"%s */\n", versions);
 
 	fprintf(ofile, "static uint8_t seqprog[] = {\n");
 	for (cur_instr = STAILQ_FIRST(&seq_program);
@@ -370,49 +391,54 @@
 	/*
 	 *  Output patch information.  Patch functions first.
 	 */
+	fprintf(ofile,
+"typedef int %spatch_func_t (%s);\n", prefix, patch_arg_list);
+
 	for (cur_node = SLIST_FIRST(&patch_functions);
 	     cur_node != NULL;
 	     cur_node = SLIST_NEXT(cur_node,links)) {
 		fprintf(ofile,
-"static int aic_patch%d_func(%s);
-
-static int
-aic_patch%d_func(%s)
-{
-	return (%s);
-}\n\n",
+"static %spatch_func_t %spatch%d_func;\n"
+"\n"
+"static int\n"
+"%spatch%d_func(%s)\n"
+"{\n"
+"	return (%s);\n"
+"}\n\n",
+			prefix,
+			prefix,
 			cur_node->symbol->info.condinfo->func_num,
-			patch_arg_list,
+			prefix,
 			cur_node->symbol->info.condinfo->func_num,
 			patch_arg_list,
 			cur_node->symbol->name);
 	}
 
 	fprintf(ofile,
-"typedef int patch_func_t (%s);
-static struct patch {
-	patch_func_t	*patch_func;
-	uint32_t	begin	   :10,
-			skip_instr :10,
-			skip_patch :12;
-} patches[] = {\n", patch_arg_list);
+"static struct patch {\n"
+"	%spatch_func_t		*patch_func;\n"
+"	uint32_t		 begin		:10,\n"
+"				 skip_instr	:10,\n"
+"				 skip_patch	:12;\n"
+"} patches[] = {\n", prefix);
 
 	for (cur_patch = STAILQ_FIRST(&patches);
 	     cur_patch != NULL;
 	     cur_patch = STAILQ_NEXT(cur_patch,links)) {
-		fprintf(ofile, "%s\t{ aic_patch%d_func, %d, %d, %d }",
+		fprintf(ofile, "%s\t{ %spatch%d_func, %d, %d, %d }",
 			cur_patch == STAILQ_FIRST(&patches) ? "" : ",\n",
+			prefix,
 			cur_patch->patch_func, cur_patch->begin,
 			cur_patch->skip_instr, cur_patch->skip_patch);
 	}
 
-	fprintf(ofile, "\n};\n");
+	fprintf(ofile, "\n};\n\n");
 
 	fprintf(ofile,
-"static struct cs {
-	u_int16_t	begin;
-	u_int16_t	end;
-} critical_sections[] = {\n");
+"static struct cs {\n"
+"	uint16_t	begin;\n"
+"	uint16_t	end;\n"
+"} critical_sections[] = {\n");
 
 	for (cs = TAILQ_FIRST(&cs_tailq);
 	     cs != NULL;
@@ -422,11 +448,11 @@
 			cs->begin_addr, cs->end_addr);
 	}
 
-	fprintf(ofile, "\n};\n");
+	fprintf(ofile, "\n};\n\n");
 
 	fprintf(ofile,
-"static const int num_critical_sections = sizeof(critical_sections)
-				       / sizeof(*critical_sections);\n");
+"static const int num_critical_sections = sizeof(critical_sections)\n"
+"				       / sizeof(*critical_sections);\n");
 
 	fprintf(stderr, "%s: %d instructions used\n", appname, instrcount);
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aicasm/aicasm.h linux-2.4.22-pre2/drivers/scsi/aic7xxx/aicasm/aicasm.h
--- linux-2.4.21/drivers/scsi/aic7xxx/aicasm/aicasm.h	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aicasm/aicasm.h	2003-06-26 21:43:16.000000000 +0000
@@ -2,7 +2,7 @@
  * Assembler for the sequencer program downloaded to Aic7xxx SCSI host adapters
  *
  * Copyright (c) 1997 Justin T. Gibbs.
- * Copyright (c) 2001 Adaptec Inc.
+ * Copyright (c) 2001, 2002 Adaptec Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -37,9 +37,9 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm.h#10 $
+ * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm.h#14 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm.h,v 1.11.2.4 2002/04/29 19:36:36 gibbs Exp $
+ * $FreeBSD$
  */
 
 #ifdef __linux__
@@ -76,8 +76,10 @@
 extern struct symlist patch_functions;
 extern int includes_search_curdir;		/* False if we've seen -I- */
 extern char *appname;
+extern char *stock_include_file;
 extern int yylineno;
 extern char *yyfilename;
+extern char *prefix;
 extern char *patch_arg_list;
 extern char *versions;
 extern int   src_mode;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aicasm/aicasm_gram.y linux-2.4.22-pre2/drivers/scsi/aic7xxx/aicasm/aicasm_gram.y
--- linux-2.4.21/drivers/scsi/aic7xxx/aicasm/aicasm_gram.y	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aicasm/aicasm_gram.y	2003-06-26 21:43:12.000000000 +0000
@@ -3,7 +3,7 @@
  * Parser for the Aic7xxx SCSI Host adapter sequencer assembler.
  *
  * Copyright (c) 1997, 1998, 2000 Justin T. Gibbs.
- * Copyright (c) 2001 Adaptec Inc.
+ * Copyright (c) 2001, 2002 Adaptec Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -38,9 +38,9 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#15 $
+ * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#29 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_gram.y,v 1.11.2.5 2002/04/29 19:36:36 gibbs Exp $
+ * $FreeBSD$
  */
 
 #include <sys/types.h>
@@ -64,11 +64,14 @@
 
 int yylineno;
 char *yyfilename;
+char stock_prefix[] = "aic_";
+char *prefix = stock_prefix;
 char *patch_arg_list;
 char *versions;
 static char errbuf[255];
 static char regex_pattern[255];
 static symbol_t *cur_symbol;
+static symbol_t *field_symbol;
 static symbol_t *scb_or_sram_symbol;
 static symtype cur_symtype;
 static symbol_ref_t accumulator;
@@ -82,8 +85,10 @@
 static int sram_or_scb_offset;
 static int download_constant_count;
 static int in_critical_section;
+static u_int enum_increment;
+static u_int enum_next_value;
 
-static void process_bitmask(int mask_type, symbol_t *sym, int mask);
+static void process_field(int field_type, symbol_t *sym, int mask);
 static void initialize_symbol(symbol_t *symbol);
 static void add_macro_arg(const char *argtext, int position);
 static void add_macro_body(const char *bodytext);
@@ -152,7 +157,9 @@
 
 %token T_END_CS
 
-%token T_BIT
+%token T_FIELD
+
+%token T_ENUM
 
 %token T_MASK
 
@@ -162,7 +169,7 @@
 
 %token <sym> T_CEXPR
 
-%token T_EOF T_INCLUDE T_VERSION T_PATCH_ARG_LIST
+%token T_EOF T_INCLUDE T_VERSION T_PREFIX T_PATCH_ARG_LIST
 
 %token <value> T_SHR T_SHL T_ROR T_ROL
 
@@ -202,7 +209,7 @@
 
 %type <value> export ret f1_opcode f2_opcode jmp_jc_jnc_call jz_jnz je_jne
 
-%type <value> numerical_value mode_value mode_list macro_arglist
+%type <value> mode_value mode_list macro_arglist
 
 %left '|'
 %left '&'
@@ -216,6 +223,8 @@
 program:
 	include
 |	program include
+|	prefix
+|	program prefix
 |	patch_arg_list
 |	program patch_arg_list
 |	version
@@ -257,6 +266,18 @@
 	}
 ;
 
+prefix:
+	T_PREFIX '=' T_STRING
+	{
+		if (prefix != stock_prefix)
+			stop("Prefix multiply defined",
+			     EX_DATAERR);
+		prefix = strdup($3);
+		if (prefix == NULL)
+			stop("Unable to record prefix", EX_SOFTWARE);
+	}
+;
+
 patch_arg_list:
 	T_PATCH_ARG_LIST '=' T_STRING
 	{
@@ -326,7 +347,8 @@
 |	size
 |	access_mode
 |	modes
-|	bit_defn
+|	field_defn
+|	enum_defn
 |	mask_defn
 |	alias
 |	accumulator
@@ -418,17 +440,68 @@
 	}
 ;
 
-bit_defn:
-	T_BIT T_SYMBOL T_NUMBER
+field_defn:
+	T_FIELD
+		{
+			field_symbol = NULL;
+			enum_next_value = 0;
+			enum_increment = 1;
+		}
+	'{' enum_entry_list '}'
+|	T_FIELD T_SYMBOL expression
+		{
+			process_field(FIELD, $2, $3.value);
+			field_symbol = $2;
+			enum_next_value = 0;
+			enum_increment = 0x01 << (ffs($3.value) - 1);
+		}
+	'{' enum_entry_list '}'
+|	T_FIELD T_SYMBOL expression
+	{
+		process_field(FIELD, $2, $3.value);
+	}
+;
+
+enum_defn:
+	T_ENUM
+		{
+			field_symbol = NULL;
+			enum_next_value = 0;
+			enum_increment = 1;
+		}
+	'{' enum_entry_list '}'
+|	T_ENUM T_SYMBOL expression
+		{
+			process_field(ENUM, $2, $3.value);
+			field_symbol = $2;
+			enum_next_value = 0;
+			enum_increment = 0x01 << (ffs($3.value) - 1);
+		}
+	'{' enum_entry_list '}'
+;
+
+enum_entry_list:
+	enum_entry
+|	enum_entry_list ',' enum_entry
+;
+
+enum_entry:
+	T_SYMBOL
 	{
-		process_bitmask(BIT, $2, $3);
+		process_field(ENUM_ENTRY, $1, enum_next_value);
+		enum_next_value += enum_increment;
+	}
+|	T_SYMBOL expression
+	{
+		process_field(ENUM_ENTRY, $1, $2.value);
+		enum_next_value = $2.value + enum_increment;
 	}
 ;
 
 mask_defn:
 	T_MASK T_SYMBOL expression
 	{
-		process_bitmask(MASK, $2, $3.value);
+		process_field(MASK, $2, $3.value);
 	}
 ;
 
@@ -608,8 +681,10 @@
 			$$.value = symbol->info.rinfo->address;
 			break;
 		case MASK:
-		case BIT:
-			$$.value = symbol->info.minfo->mask;
+		case FIELD:
+		case ENUM:
+		case ENUM_ENTRY:
+			$$.value = symbol->info.finfo->value;
 			break;
 		case DOWNLOAD_CONST:
 		case CONST:
@@ -632,7 +707,7 @@
 ;
 
 constant:
-	T_CONST T_SYMBOL numerical_value
+	T_CONST T_SYMBOL expression 
 	{
 		if ($2->type != UNINITIALIZED) {
 			stop("Re-definition of symbol as a constant",
@@ -641,7 +716,7 @@
 		}
 		$2->type = CONST;
 		initialize_symbol($2);
-		$2->info.cinfo->value = $3;
+		$2->info.cinfo->value = $3.value;
 	}
 |	T_CONST T_SYMBOL T_DOWNLOAD
 	{
@@ -709,17 +784,6 @@
 	}
 ;
 
-numerical_value:
-	T_NUMBER
-	{
-		$$ = $1;
-	}
-|	'-' T_NUMBER
-	{
-		$$ = -$2;
-	}
-;
-
 scratch_ram:
 	T_SRAM '{'
 		{
@@ -862,6 +926,8 @@
 |	T_A
 	{
 		SLIST_INIT(&$$.referenced_syms);
+		symlist_add(&$$.referenced_syms, accumulator.symbol,
+			    SYMLIST_INSERT_HEAD);
 		$$.value = 0;
 	}
 ;
@@ -917,6 +983,7 @@
 		cs->begin_addr = instruction_ptr;
 		in_critical_section = TRUE;
 	}
+;
 
 critical_section_end:
 	T_END_CS ';'
@@ -931,6 +998,7 @@
 		cs->end_addr = instruction_ptr;
 		in_critical_section = FALSE;
 	}
+;
 
 export:
 	{ $$ = 0; }
@@ -1161,9 +1229,22 @@
 ;
 
 code:
-	T_MVI destination ',' immediate_or_a ret ';'
+	T_MVI destination ',' immediate ret ';'
 	{
-		format_1_instr(AIC_OP_OR, &$2, &$4, &allzeros, $5);
+		if ($4.value == 0
+		 && is_download_const(&$4) == 0) {
+			expression_t immed;
+
+			/*
+			 * Allow move immediates of 0 so that macros,
+			 * that can't know the immediate's value and
+			 * otherwise compensate, still work.
+			 */
+			make_expression(&immed, 1);
+			format_1_instr(AIC_OP_BMOV, &$2, &immed, &allzeros, $5);
+		} else {
+			format_1_instr(AIC_OP_OR, &$2, &$4, &allzeros, $5);
+		}
 	}
 ;
 
@@ -1298,7 +1379,7 @@
 %%
 
 static void
-process_bitmask(int mask_type, symbol_t *sym, int mask)
+process_field(int field_type, symbol_t *sym, int value)
 {
 	/*
 	 * Add the current register to its
@@ -1308,52 +1389,54 @@
 	 * the "allowed bits" of this register.
 	 */
 	if (sym->type == UNINITIALIZED) {
-		sym->type = mask_type;
+		sym->type = field_type;
 		initialize_symbol(sym);
-		if (mask_type == BIT) {
-			if (mask == 0) {
-				stop("Bitmask with no bits set", EX_DATAERR);
-				/* NOTREACHED */
-			}
-			if ((mask & ~(0x01 << (ffs(mask) - 1))) != 0) {
-				stop("Bitmask with more than one bit set",
-				     EX_DATAERR);
+		sym->info.finfo->value = value;
+		if (field_type != ENUM_ENTRY) {
+			if (field_type != MASK && value == 0) {
+				stop("Empty Field, or Enum", EX_DATAERR);
 				/* NOTREACHED */
 			}
+			sym->info.finfo->value = value;
+			sym->info.finfo->mask = value;
+		} else if (field_symbol != NULL) {
+			sym->info.finfo->mask = field_symbol->info.finfo->value;
+		} else {
+			sym->info.finfo->mask = 0xFF;
 		}
-		sym->info.minfo->mask = mask;
-	} else if (sym->type != mask_type) {
-		stop("Bit definition mirrors a definition of the same "
+	} else if (sym->type != field_type) {
+		stop("Field definition mirrors a definition of the same "
 		     " name, but a different type", EX_DATAERR);
 		/* NOTREACHED */
-	} else if (mask != sym->info.minfo->mask) {
-		stop("Bitmask redefined with a conflicting value", EX_DATAERR);
+	} else if (value != sym->info.finfo->value) {
+		stop("Field redefined with a conflicting value", EX_DATAERR);
 		/* NOTREACHED */
 	}
 	/* Fail if this symbol is already listed */
-	if (symlist_search(&(sym->info.minfo->symrefs),
+	if (symlist_search(&(sym->info.finfo->symrefs),
 			   cur_symbol->name) != NULL) {
-		stop("Bitmask defined multiple times for register", EX_DATAERR);
+		stop("Field defined multiple times for register", EX_DATAERR);
 		/* NOTREACHED */
 	}
-	symlist_add(&(sym->info.minfo->symrefs), cur_symbol,
+	symlist_add(&(sym->info.finfo->symrefs), cur_symbol,
 		    SYMLIST_INSERT_HEAD);
-	cur_symbol->info.rinfo->valid_bitmask |= mask;
+	cur_symbol->info.rinfo->valid_bitmask |= sym->info.finfo->mask;
 	cur_symbol->info.rinfo->typecheck_masks = TRUE;
+	symlist_add(&(cur_symbol->info.rinfo->fields), sym, SYMLIST_SORT);
 }
 
 static void
 initialize_symbol(symbol_t *symbol)
 {
 	switch (symbol->type) {
-        case UNINITIALIZED:
+	case UNINITIALIZED:
 		stop("Call to initialize_symbol with type field unset",
 		     EX_SOFTWARE);
 		/* NOTREACHED */
 		break;
-        case REGISTER:
-        case SRAMLOC:
-        case SCBLOC:
+	case REGISTER:
+	case SRAMLOC:
+	case SCBLOC:
 		symbol->info.rinfo =
 		    (struct reg_info *)malloc(sizeof(struct reg_info));
 		if (symbol->info.rinfo == NULL) {
@@ -1362,6 +1445,7 @@
 		}
 		memset(symbol->info.rinfo, 0,
 		       sizeof(struct reg_info));
+		SLIST_INIT(&(symbol->info.rinfo->fields));
 		/*
 		 * Default to allowing access in all register modes
 		 * or to the mode specified by the SCB or SRAM space
@@ -1373,7 +1457,7 @@
 		else
 			symbol->info.rinfo->modes = ~0;
 		break;
-        case ALIAS:
+	case ALIAS:
 		symbol->info.ainfo =
 		    (struct alias_info *)malloc(sizeof(struct alias_info));
 		if (symbol->info.ainfo == NULL) {
@@ -1383,19 +1467,21 @@
 		memset(symbol->info.ainfo, 0,
 		       sizeof(struct alias_info));
 		break;
-        case MASK:
-        case BIT:
-		symbol->info.minfo =
-		    (struct mask_info *)malloc(sizeof(struct mask_info));
-		if (symbol->info.minfo == NULL) {
-			stop("Can't create bitmask info", EX_SOFTWARE);
+	case MASK:
+	case FIELD:
+	case ENUM:
+	case ENUM_ENTRY:
+		symbol->info.finfo =
+		    (struct field_info *)malloc(sizeof(struct field_info));
+		if (symbol->info.finfo == NULL) {
+			stop("Can't create field info", EX_SOFTWARE);
 			/* NOTREACHED */
 		}
-		memset(symbol->info.minfo, 0, sizeof(struct mask_info));
-		SLIST_INIT(&(symbol->info.minfo->symrefs));
+		memset(symbol->info.finfo, 0, sizeof(struct field_info));
+		SLIST_INIT(&(symbol->info.finfo->symrefs));
 		break;
-        case CONST:
-        case DOWNLOAD_CONST:
+	case CONST:
+	case DOWNLOAD_CONST:
 		symbol->info.cinfo =
 		    (struct const_info *)malloc(sizeof(struct const_info));
 		if (symbol->info.cinfo == NULL) {
@@ -1577,7 +1663,6 @@
 		case AIC_OP_OR:
 			dst_value = src_value | immed->value;
 			break;
-			break;
 		case AIC_OP_BMOV:
 			dst_value = src_value;
 			break;
@@ -1586,9 +1671,9 @@
 		}
 		src_mode = dst_value & 0xF;
 		dst_mode = (dst_value >> 4) & 0xF;
-cant_update:
 	}
 
+cant_update:
 	symlist_free(&immed->referenced_syms);
 	instruction_ptr++;
 }
@@ -1763,11 +1848,13 @@
 		    node != NULL;
 		    node = node->links.sle_next) {
 			if ((node->symbol->type == MASK
-			  || node->symbol->type == BIT)
-			 && symlist_search(&node->symbol->info.minfo->symrefs,
+			  || node->symbol->type == FIELD
+			  || node->symbol->type == ENUM
+			  || node->symbol->type == ENUM_ENTRY)
+			 && symlist_search(&node->symbol->info.finfo->symrefs,
 					   symbol->name) == NULL) {
 				snprintf(errbuf, sizeof(errbuf),
-					 "Invalid bit or mask %s "
+					 "Invalid field or mask %s "
 					 "for register %s",
 					 node->symbol->name, symbol->name);
 				stop(errbuf, EX_DATAERR);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h linux-2.4.22-pre2/drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h
--- linux-2.4.21/drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h	2003-06-26 21:43:33.000000000 +0000
@@ -37,9 +37,9 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_insformat.h#9 $
+ * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_insformat.h#11 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_insformat.h,v 1.3.2.3 2002/04/29 19:36:36 gibbs Exp $
+ * $FreeBSD$
  */
 
 struct ins_format1 {
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aicasm/aicasm_macro_gram.y linux-2.4.22-pre2/drivers/scsi/aic7xxx/aicasm/aicasm_macro_gram.y
--- linux-2.4.21/drivers/scsi/aic7xxx/aicasm/aicasm_macro_gram.y	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aicasm/aicasm_macro_gram.y	2003-06-26 21:43:11.000000000 +0000
@@ -38,9 +38,9 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id$
+ * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_macro_gram.y#5 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_macro_gram.y,v 1.1.2.1 2002/04/29 19:36:36 gibbs Exp $
+ * $FreeBSD$
  */
 
 #include <sys/types.h>
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aicasm/aicasm_macro_scan.l linux-2.4.22-pre2/drivers/scsi/aic7xxx/aicasm/aicasm_macro_scan.l
--- linux-2.4.21/drivers/scsi/aic7xxx/aicasm/aicasm_macro_scan.l	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aicasm/aicasm_macro_scan.l	2003-06-26 21:43:10.000000000 +0000
@@ -38,13 +38,14 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id$
+ * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_macro_scan.l#7 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_macro_scan.l,v 1.1.2.1 2002/04/29 19:36:36 gibbs Exp $
+ * $FreeBSD$
  */
 
 #include <sys/types.h>
 
+#include <inttypes.h>
 #include <limits.h>
 #include <regex.h>
 #include <stdio.h>
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aicasm/aicasm_scan.l linux-2.4.22-pre2/drivers/scsi/aic7xxx/aicasm/aicasm_scan.l
--- linux-2.4.21/drivers/scsi/aic7xxx/aicasm/aicasm_scan.l	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aicasm/aicasm_scan.l	2003-06-26 21:43:30.000000000 +0000
@@ -3,7 +3,7 @@
  * Lexical Analyzer for the Aic7xxx SCSI Host adapter sequencer assembler.
  *
  * Copyright (c) 1997, 1998, 2000 Justin T. Gibbs.
- * Copyright (c) 2001 Adaptec Inc.
+ * Copyright (c) 2001, 2002 Adaptec Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -38,13 +38,14 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#11 $
+ * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#18 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_scan.l,v 1.13.2.4 2002/04/29 19:36:36 gibbs Exp $
+ * $FreeBSD$
  */
 
 #include <sys/types.h>
 
+#include <inttypes.h>
 #include <limits.h>
 #include <regex.h>
 #include <stdio.h>
@@ -131,6 +132,7 @@
 			}
 
 VERSION			{ return T_VERSION; }
+PREFIX			{ return T_PREFIX; }
 PATCH_ARG_LIST		{ return T_PATCH_ARG_LIST; }
 \"			{
 				string_buf_ptr = string_buf;
@@ -173,7 +175,8 @@
 END_CRITICAL		{ return T_END_CS; }
 SET_SRC_MODE		{ return T_SET_SRC_MODE; }
 SET_DST_MODE		{ return T_SET_DST_MODE; }
-bit			{ return T_BIT; }
+field			{ return T_FIELD; }
+enum			{ return T_ENUM; }
 mask			{ return T_MASK; }
 alias			{ return T_ALIAS; }
 size			{ return T_SIZE; }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.c linux-2.4.22-pre2/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.c
--- linux-2.4.21/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.c	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.c	2003-06-26 21:43:33.000000000 +0000
@@ -2,6 +2,7 @@
  * Aic7xxx SCSI host adapter firmware asssembler symbol table implementation
  *
  * Copyright (c) 1997 Justin T. Gibbs.
+ * Copyright (c) 2002 Adaptec Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -36,9 +37,9 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#14 $
+ * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#24 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_symbol.c,v 1.11.2.4 2002/04/29 19:36:36 gibbs Exp $
+ * $FreeBSD$
  */
 
 #include <sys/types.h>
@@ -49,6 +50,7 @@
 #include <db.h>
 #endif
 #include <fcntl.h>
+#include <inttypes.h>
 #include <regex.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -72,6 +74,8 @@
 	}
 	memset(new_symbol, 0, sizeof(*new_symbol));
 	new_symbol->name = strdup(name);
+	if (new_symbol->name == NULL)
+		 stop("Unable to strdup symbol name", EX_SOFTWARE);
 	new_symbol->type = UNINITIALIZED;
 	return (new_symbol);
 }
@@ -98,10 +102,12 @@
 			free(symbol->info.ainfo);
 		break;
 	case MASK:
-	case BIT:
-		if (symbol->info.minfo != NULL) {
-			symlist_free(&symbol->info.minfo->symrefs);
-			free(symbol->info.minfo);
+	case FIELD:
+	case ENUM:
+	case ENUM_ENTRY:
+		if (symbol->info.finfo != NULL) {
+			symlist_free(&symbol->info.finfo->symrefs);
+			free(symbol->info.finfo);
 		}
 		break;
 	case DOWNLOAD_CONST:
@@ -222,17 +228,19 @@
 	newnode->symbol = symbol;
 	if (how == SYMLIST_SORT) {
 		symbol_node_t *curnode;
-		int mask;
+		int field;
 
-		mask = FALSE;
+		field = FALSE;
 		switch(symbol->type) {
 		case REGISTER:
 		case SCBLOC:
 		case SRAMLOC:
 			break;
-		case BIT:
+		case FIELD:
 		case MASK:
-			mask = TRUE;
+		case ENUM:
+		case ENUM_ENTRY:
+			field = TRUE;
 			break;
 		default:
 			stop("symlist_add: Invalid symbol type for sorting",
@@ -242,9 +250,12 @@
 
 		curnode = SLIST_FIRST(symlist);
 		if (curnode == NULL
-		 || (mask && (curnode->symbol->info.minfo->mask >
-		              newnode->symbol->info.minfo->mask))
-		 || (!mask && (curnode->symbol->info.rinfo->address >
+		 || (field
+		  && (curnode->symbol->type > newnode->symbol->type
+		   || (curnode->symbol->type == newnode->symbol->type
+		    && (curnode->symbol->info.finfo->value >
+			newnode->symbol->info.finfo->value))))
+		 || (!field && (curnode->symbol->info.rinfo->address >
 		               newnode->symbol->info.rinfo->address))) {
 			SLIST_INSERT_HEAD(symlist, newnode, links);
 			return;
@@ -259,10 +270,14 @@
 				symbol_t *cursymbol;
 
 				cursymbol = SLIST_NEXT(curnode, links)->symbol;
-				if ((mask && (cursymbol->info.minfo->mask >
-				              symbol->info.minfo->mask))
-				 || (!mask &&(cursymbol->info.rinfo->address >
-				              symbol->info.rinfo->address))){
+				if ((field
+		  		  && (cursymbol->type > symbol->type
+				   || (cursymbol->type == symbol->type
+				    && (cursymbol->info.finfo->value >
+					symbol->info.finfo->value))))
+				 || (!field
+				   && (cursymbol->info.rinfo->address >
+				       symbol->info.rinfo->address))) {
 					SLIST_INSERT_AFTER(curnode, newnode,
 							   links);
 					break;
@@ -307,20 +322,160 @@
 }
 
 void
-symtable_dump(FILE *ofile)
+aic_print_file_prologue(FILE *ofile)
+{
+
+	if (ofile == NULL)
+		return;
+
+	fprintf(ofile,
+"/*\n"
+" * DO NOT EDIT - This file is automatically generated\n"
+" *		 from the following source files:\n"
+" *\n"
+"%s */\n",
+		versions);
+}
+
+void
+aic_print_include(FILE *dfile, char *include_file)
+{
+
+	if (dfile == NULL)
+		return;
+	fprintf(dfile, "\n#include \"%s\"\n\n", include_file);
+}
+
+void
+aic_print_reg_dump_types(FILE *ofile)
+{
+	if (ofile == NULL)
+		return;
+		
+	fprintf(ofile,
+"typedef int (%sreg_print_t)(u_int, u_int *, u_int);\n"
+"typedef struct %sreg_parse_entry {\n"
+"	char	*name;\n"
+"	uint8_t	 value;\n"
+"	uint8_t	 mask;\n"
+"} %sreg_parse_entry_t;\n"
+"\n",
+		prefix, prefix, prefix);
+}
+
+static void
+aic_print_reg_dump_start(FILE *dfile, symbol_node_t *regnode)
+{
+	if (dfile == NULL)
+		return;
+
+	fprintf(dfile,
+"static %sreg_parse_entry_t %s_parse_table[] = {\n",
+		prefix,
+		regnode->symbol->name);
+}
+
+static void
+aic_print_reg_dump_end(FILE *ofile, FILE *dfile,
+		       symbol_node_t *regnode, u_int num_entries)
+{
+	char *lower_name;
+	char *letter;
+
+	lower_name = strdup(regnode->symbol->name);
+	if (lower_name == NULL)
+		 stop("Unable to strdup symbol name", EX_SOFTWARE);
+	
+	for (letter = lower_name; *letter != '\0'; letter++)
+		*letter = tolower(*letter);
+
+	if (dfile != NULL) {
+		if (num_entries != 0)
+			fprintf(dfile,
+"\n"
+"};\n"
+"\n");
+
+		fprintf(dfile,
+"int\n"
+"%s%s_print(u_int regvalue, u_int *cur_col, u_int wrap)\n"
+"{\n"
+"	return (%sprint_register(%s%s, %d, \"%s\",\n"
+"	    0x%02x, regvalue, cur_col, wrap));\n"
+"}\n"
+"\n",
+			prefix,
+			lower_name,
+			prefix,
+			num_entries != 0 ? regnode->symbol->name : "NULL",
+			num_entries != 0 ? "_parse_table" : "",
+			num_entries,
+			regnode->symbol->name,
+			regnode->symbol->info.rinfo->address);
+	}
+
+	fprintf(ofile,
+"#if AIC_DEBUG_REGISTERS\n"
+"%sreg_print_t %s%s_print;\n"
+"#else\n"
+"#define %s%s_print(regvalue, cur_col, wrap) \\\n"
+"    %sprint_register(NULL, 0, \"%s\", 0x%02x, regvalue, cur_col, wrap)\n"
+"#endif\n"
+"\n",
+		prefix,
+		prefix,
+		lower_name,
+		prefix,
+		lower_name,
+		prefix,
+		regnode->symbol->name,
+		regnode->symbol->info.rinfo->address);
+}
+
+static void
+aic_print_reg_dump_entry(FILE *dfile, symbol_node_t *curnode)
+{
+	int num_tabs;
+
+	if (dfile == NULL)
+		return;
+
+	fprintf(dfile,
+"	{ \"%s\",",
+		curnode->symbol->name);
+
+	num_tabs = 3 - (strlen(curnode->symbol->name) + 5) / 8;
+
+	while (num_tabs-- > 0)
+		fputc('\t', dfile);
+	fprintf(dfile, "0x%02x, 0x%02x }",
+		curnode->symbol->info.finfo->value,
+		curnode->symbol->info.finfo->mask);
+}
+
+void
+symtable_dump(FILE *ofile, FILE *dfile)
 {
 	/*
 	 * Sort the registers by address with a simple insertion sort.
 	 * Put bitmasks next to the first register that defines them.
 	 * Put constants at the end.
 	 */
-	symlist_t registers;
-	symlist_t masks;
-	symlist_t constants;
-	symlist_t download_constants;
-	symlist_t aliases;
-	symlist_t exported_labels;
-	u_int	  i;
+	symlist_t	 registers;
+	symlist_t	 masks;
+	symlist_t	 constants;
+	symlist_t	 download_constants;
+	symlist_t	 aliases;
+	symlist_t	 exported_labels;
+	symbol_node_t	*curnode;
+	symbol_node_t	*regnode;
+	DBT		 key;
+	DBT		 data;
+	int		 flag;
+	u_int		 i;
+
+	if (symtable == NULL)
+		return;
 
 	SLIST_INIT(&registers);
 	SLIST_INIT(&masks);
@@ -328,173 +483,195 @@
 	SLIST_INIT(&download_constants);
 	SLIST_INIT(&aliases);
 	SLIST_INIT(&exported_labels);
+	flag = R_FIRST;
+	while (symtable->seq(symtable, &key, &data, flag) == 0) {
+		symbol_t *cursym;
 
-	if (symtable != NULL) {
-		DBT	 key;
-		DBT	 data;
-		int	 flag = R_FIRST;
+		memcpy(&cursym, data.data, sizeof(cursym));
+		switch(cursym->type) {
+		case REGISTER:
+		case SCBLOC:
+		case SRAMLOC:
+			symlist_add(&registers, cursym, SYMLIST_SORT);
+			break;
+		case MASK:
+		case FIELD:
+		case ENUM:
+		case ENUM_ENTRY:
+			symlist_add(&masks, cursym, SYMLIST_SORT);
+			break;
+		case CONST:
+			symlist_add(&constants, cursym,
+				    SYMLIST_INSERT_HEAD);
+			break;
+		case DOWNLOAD_CONST:
+			symlist_add(&download_constants, cursym,
+				    SYMLIST_INSERT_HEAD);
+			break;
+		case ALIAS:
+			symlist_add(&aliases, cursym,
+				    SYMLIST_INSERT_HEAD);
+			break;
+		case LABEL:
+			if (cursym->info.linfo->exported == 0)
+				break;
+			symlist_add(&exported_labels, cursym,
+				    SYMLIST_INSERT_HEAD);
+			break;
+		default:
+			break;
+		}
+		flag = R_NEXT;
+	}
 
-		while (symtable->seq(symtable, &key, &data, flag) == 0) {
-			symbol_t *cursym;
+	/* Register dianostic functions/declarations first. */
+	aic_print_file_prologue(ofile);
+	aic_print_reg_dump_types(ofile);
+	aic_print_file_prologue(dfile);
+	aic_print_include(dfile, stock_include_file);
+	SLIST_FOREACH(curnode, &registers, links) {
 
-			memcpy(&cursym, data.data, sizeof(cursym));
-			switch(cursym->type) {
-			case REGISTER:
-			case SCBLOC:
-			case SRAMLOC:
-				symlist_add(&registers, cursym, SYMLIST_SORT);
-				break;
-			case MASK:
-			case BIT:
-				symlist_add(&masks, cursym, SYMLIST_SORT);
-				break;
-			case CONST:
-				symlist_add(&constants, cursym,
-					    SYMLIST_INSERT_HEAD);
-				break;
-			case DOWNLOAD_CONST:
-				symlist_add(&download_constants, cursym,
-					    SYMLIST_INSERT_HEAD);
-				break;
-			case ALIAS:
-				symlist_add(&aliases, cursym,
-					    SYMLIST_INSERT_HEAD);
-				break;
-			case LABEL:
-				if (cursym->info.linfo->exported == 0)
-					break;
-				symlist_add(&exported_labels, cursym,
-					    SYMLIST_INSERT_HEAD);
-				break;
-			default:
-				break;
+		switch(curnode->symbol->type) {
+		case REGISTER:
+		case SCBLOC:
+		case SRAMLOC:
+		{
+			symlist_t	*fields;
+			symbol_node_t	*fieldnode;
+			int		 num_entries;
+
+			num_entries = 0;
+			fields = &curnode->symbol->info.rinfo->fields;
+			SLIST_FOREACH(fieldnode, fields, links) {
+				if (num_entries == 0)
+					aic_print_reg_dump_start(dfile,
+								 curnode);
+				else if (dfile != NULL)
+					fputs(",\n", dfile);
+				num_entries++;
+				aic_print_reg_dump_entry(dfile, fieldnode);
 			}
-			flag = R_NEXT;
+			aic_print_reg_dump_end(ofile, dfile,
+					       curnode, num_entries);
+		}
+		default:
+			break;
 		}
+	}
 
-		/* Put in the masks and bits */
-		while (SLIST_FIRST(&masks) != NULL) {
-			symbol_node_t *curnode;
-			symbol_node_t *regnode;
-			char *regname;
+	/* Fold in the masks and bits */
+	while (SLIST_FIRST(&masks) != NULL) {
+		char *regname;
 
-			curnode = SLIST_FIRST(&masks);
-			SLIST_REMOVE_HEAD(&masks, links);
+		curnode = SLIST_FIRST(&masks);
+		SLIST_REMOVE_HEAD(&masks, links);
 
-			regnode =
-			    SLIST_FIRST(&curnode->symbol->info.minfo->symrefs);
-			regname = regnode->symbol->name;
-			regnode = symlist_search(&registers, regname);
-			SLIST_INSERT_AFTER(regnode, curnode, links);
-		}
+		regnode = SLIST_FIRST(&curnode->symbol->info.finfo->symrefs);
+		regname = regnode->symbol->name;
+		regnode = symlist_search(&registers, regname);
+		SLIST_INSERT_AFTER(regnode, curnode, links);
+	}
 
-		/* Add the aliases */
-		while (SLIST_FIRST(&aliases) != NULL) {
-			symbol_node_t *curnode;
-			symbol_node_t *regnode;
-			char *regname;
+	/* Add the aliases */
+	while (SLIST_FIRST(&aliases) != NULL) {
+		char *regname;
 
-			curnode = SLIST_FIRST(&aliases);
-			SLIST_REMOVE_HEAD(&aliases, links);
+		curnode = SLIST_FIRST(&aliases);
+		SLIST_REMOVE_HEAD(&aliases, links);
 
-			regname = curnode->symbol->info.ainfo->parent->name;
-			regnode = symlist_search(&registers, regname);
-			SLIST_INSERT_AFTER(regnode, curnode, links);
-		}
+		regname = curnode->symbol->info.ainfo->parent->name;
+		regnode = symlist_search(&registers, regname);
+		SLIST_INSERT_AFTER(regnode, curnode, links);
+	}
 
-		/* Output what we have */
-		fprintf(ofile,
-"/*
- * DO NOT EDIT - This file is automatically generated
- *		 from the following source files:
- *
-%s */\n", versions);
-		while (SLIST_FIRST(&registers) != NULL) {
-			symbol_node_t *curnode;
-			u_int value;
-			char *tab_str;
-			char *tab_str2;
-
-			curnode = SLIST_FIRST(&registers);
-			SLIST_REMOVE_HEAD(&registers, links);
-			switch(curnode->symbol->type) {
-			case REGISTER:
-			case SCBLOC:
-			case SRAMLOC:
-				fprintf(ofile, "\n");
-				value = curnode->symbol->info.rinfo->address;
-				tab_str = "\t";
-				tab_str2 = "\t\t";
-				break;
-			case ALIAS:
-			{
-				symbol_t *parent;
-
-				parent = curnode->symbol->info.ainfo->parent;
-				value = parent->info.rinfo->address;
-				tab_str = "\t";
-				tab_str2 = "\t\t";
-				break;
-			}
-			case MASK:
-			case BIT:
-				value = curnode->symbol->info.minfo->mask;
-				tab_str = "\t\t";
-				tab_str2 = "\t";
-				break;
-			default:
-				value = 0; /* Quiet compiler */
-				tab_str = NULL;
-				tab_str2 = NULL;
-				stop("symtable_dump: Invalid symbol type "
-				     "encountered", EX_SOFTWARE);
-				break;
-			}
-			fprintf(ofile, "#define%s%-16s%s0x%02x\n",
-				tab_str, curnode->symbol->name, tab_str2,
-				value);
-			free(curnode);
-		}
-		fprintf(ofile, "\n\n");
-
-		while (SLIST_FIRST(&constants) != NULL) {
-			symbol_node_t *curnode;
-
-			curnode = SLIST_FIRST(&constants);
-			SLIST_REMOVE_HEAD(&constants, links);
-			fprintf(ofile, "#define\t%-8s\t0x%02x\n",
-				curnode->symbol->name,
-				curnode->symbol->info.cinfo->value);
-			free(curnode);
+	/* Output generated #defines. */
+	while (SLIST_FIRST(&registers) != NULL) {
+		symbol_node_t *curnode;
+		u_int value;
+		char *tab_str;
+		char *tab_str2;
+
+		curnode = SLIST_FIRST(&registers);
+		SLIST_REMOVE_HEAD(&registers, links);
+		switch(curnode->symbol->type) {
+		case REGISTER:
+		case SCBLOC:
+		case SRAMLOC:
+			fprintf(ofile, "\n");
+			value = curnode->symbol->info.rinfo->address;
+			tab_str = "\t";
+			tab_str2 = "\t\t";
+			break;
+		case ALIAS:
+		{
+			symbol_t *parent;
+
+			parent = curnode->symbol->info.ainfo->parent;
+			value = parent->info.rinfo->address;
+			tab_str = "\t";
+			tab_str2 = "\t\t";
+			break;
 		}
+		case MASK:
+		case FIELD:
+		case ENUM:
+		case ENUM_ENTRY:
+			value = curnode->symbol->info.finfo->value;
+			tab_str = "\t\t";
+			tab_str2 = "\t";
+			break;
+		default:
+			value = 0; /* Quiet compiler */
+			tab_str = NULL;
+			tab_str2 = NULL;
+			stop("symtable_dump: Invalid symbol type "
+			     "encountered", EX_SOFTWARE);
+			break;
+		}
+		fprintf(ofile, "#define%s%-16s%s0x%02x\n",
+			tab_str, curnode->symbol->name, tab_str2,
+			value);
+		free(curnode);
+	}
+	fprintf(ofile, "\n\n");
 
-		
-		fprintf(ofile, "\n\n/* Downloaded Constant Definitions */\n");
+	while (SLIST_FIRST(&constants) != NULL) {
+		symbol_node_t *curnode;
+
+		curnode = SLIST_FIRST(&constants);
+		SLIST_REMOVE_HEAD(&constants, links);
+		fprintf(ofile, "#define\t%-8s\t0x%02x\n",
+			curnode->symbol->name,
+			curnode->symbol->info.cinfo->value);
+		free(curnode);
+	}
 
-		for (i = 0; SLIST_FIRST(&download_constants) != NULL; i++) {
-			symbol_node_t *curnode;
+	
+	fprintf(ofile, "\n\n/* Downloaded Constant Definitions */\n");
 
-			curnode = SLIST_FIRST(&download_constants);
-			SLIST_REMOVE_HEAD(&download_constants, links);
-			fprintf(ofile, "#define\t%-8s\t0x%02x\n",
-				curnode->symbol->name,
-				curnode->symbol->info.cinfo->value);
-			free(curnode);
-		}
-		fprintf(ofile, "#define\tDOWNLOAD_CONST_COUNT\t0x%02x\n", i);
-
-		fprintf(ofile, "\n\n/* Exported Labels */\n");
-
-		while (SLIST_FIRST(&exported_labels) != NULL) {
-			symbol_node_t *curnode;
-
-			curnode = SLIST_FIRST(&exported_labels);
-			SLIST_REMOVE_HEAD(&exported_labels, links);
-			fprintf(ofile, "#define\tLABEL_%-8s\t0x%02x\n",
-				curnode->symbol->name,
-				curnode->symbol->info.linfo->address);
-			free(curnode);
-		}
+	for (i = 0; SLIST_FIRST(&download_constants) != NULL; i++) {
+		symbol_node_t *curnode;
+
+		curnode = SLIST_FIRST(&download_constants);
+		SLIST_REMOVE_HEAD(&download_constants, links);
+		fprintf(ofile, "#define\t%-8s\t0x%02x\n",
+			curnode->symbol->name,
+			curnode->symbol->info.cinfo->value);
+		free(curnode);
+	}
+	fprintf(ofile, "#define\tDOWNLOAD_CONST_COUNT\t0x%02x\n", i);
+
+	fprintf(ofile, "\n\n/* Exported Labels */\n");
+
+	while (SLIST_FIRST(&exported_labels) != NULL) {
+		symbol_node_t *curnode;
+
+		curnode = SLIST_FIRST(&exported_labels);
+		SLIST_REMOVE_HEAD(&exported_labels, links);
+		fprintf(ofile, "#define\tLABEL_%-8s\t0x%02x\n",
+			curnode->symbol->name,
+			curnode->symbol->info.linfo->address);
+		free(curnode);
 	}
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.h linux-2.4.22-pre2/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.h
--- linux-2.4.21/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.h	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.h	2003-06-26 21:43:12.000000000 +0000
@@ -2,6 +2,7 @@
  * Aic7xxx SCSI host adapter firmware asssembler symbol table definitions
  *
  * Copyright (c) 1997 Justin T. Gibbs.
+ * Copyright (c) 2002 Adaptec Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -36,9 +37,9 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#11 $
+ * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#17 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_symbol.h,v 1.11.2.3 2002/04/29 19:36:36 gibbs Exp $
+ * $FreeBSD$
  */
 
 #ifdef __linux__
@@ -53,8 +54,10 @@
 	ALIAS,
 	SCBLOC,
 	SRAMLOC,
+	ENUM_ENTRY,
+	FIELD,
 	MASK,
-	BIT,
+	ENUM,
 	CONST,
 	DOWNLOAD_CONST,
 	LABEL,
@@ -68,20 +71,22 @@
 	RW = 0x03
 }amode_t;
 
+typedef SLIST_HEAD(symlist, symbol_node) symlist_t;
+
 struct reg_info {
-	u_int	 address;
-	int	 size;
-	amode_t	 mode;
-	u_int8_t valid_bitmask;
-	u_int8_t modes;
-	int	 typecheck_masks;
+	u_int	  address;
+	int	  size;
+	amode_t	  mode;
+	symlist_t fields;
+	uint8_t	  valid_bitmask;
+	uint8_t	  modes;
+	int	  typecheck_masks;
 };
 
-typedef SLIST_HEAD(symlist, symbol_node) symlist_t;
-
-struct mask_info {
+struct field_info {
 	symlist_t symrefs;
-	u_int8_t mask;
+	uint8_t	  value;
+	uint8_t	  mask;
 };
 
 struct const_info {
@@ -125,7 +130,7 @@
 	symtype	type;
 	union	{
 		struct reg_info	  *rinfo;
-		struct mask_info  *minfo;
+		struct field_info *finfo;
 		struct const_info *cinfo;
 		struct alias_info *ainfo;
 		struct label_info *linfo;
@@ -178,25 +183,25 @@
 SLIST_HEAD(scope_list, scope);
 TAILQ_HEAD(scope_tailq, scope);
 
-void	symbol_delete __P((symbol_t *symbol));
+void	symbol_delete(symbol_t *symbol);
 
-void	symtable_open __P((void));
+void	symtable_open(void);
 
-void	symtable_close __P((void));
+void	symtable_close(void);
 
 symbol_t *
-	symtable_get __P((char *name));
+	symtable_get(char *name);
 
 symbol_node_t *
-	symlist_search __P((symlist_t *symlist, char *symname));
+	symlist_search(symlist_t *symlist, char *symname);
 
 void
-	symlist_add __P((symlist_t *symlist, symbol_t *symbol, int how));
+	symlist_add(symlist_t *symlist, symbol_t *symbol, int how);
 #define SYMLIST_INSERT_HEAD	0x00
 #define SYMLIST_SORT		0x01
 
-void	symlist_free __P((symlist_t *symlist));
+void	symlist_free(symlist_t *symlist);
 
-void	symlist_merge __P((symlist_t *symlist_dest, symlist_t *symlist_src1,
-			   symlist_t *symlist_src2));
-void	symtable_dump __P((FILE *ofile));
+void	symlist_merge(symlist_t *symlist_dest, symlist_t *symlist_src1,
+		      symlist_t *symlist_src2);
+void	symtable_dump(FILE *ofile, FILE *dfile);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aiclib.c linux-2.4.22-pre2/drivers/scsi/aic7xxx/aiclib.c
--- linux-2.4.21/drivers/scsi/aic7xxx/aiclib.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aiclib.c	2003-06-26 21:43:29.000000000 +0000
@@ -0,0 +1,1413 @@
+/*
+ * Implementation of Utility functions for all SCSI device types.
+ *
+ * Copyright (c) 1997, 1998, 1999 Justin T. Gibbs.
+ * Copyright (c) 1997, 1998 Kenneth D. Merry.
+ * 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, immediately at the beginning of the file.
+ * 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 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.
+ *
+ * $FreeBSD: src/sys/cam/scsi/scsi_all.c,v 1.38 2002/09/23 04:56:35 mjacob Exp $
+ * $Id$
+ */
+
+#include <linux/blk.h>
+#include <linux/blkdev.h>
+#include <linux/delay.h>
+#include <linux/version.h>
+
+/* Core SCSI definitions */
+#include "scsi.h"
+#include "hosts.h"
+#include "aiclib.h"
+#include "cam.h"
+
+#ifndef FALSE
+#define FALSE   0
+#endif /* FALSE */
+#ifndef TRUE
+#define TRUE    1
+#endif /* TRUE */
+#ifndef ERESTART
+#define ERESTART        -1              /* restart syscall */
+#endif
+#ifndef EJUSTRETURN
+#define EJUSTRETURN     -2              /* don't modify regs, just return */
+#endif
+
+static int	ascentrycomp(const void *key, const void *member);
+static int	senseentrycomp(const void *key, const void *member);
+static void	fetchtableentries(int sense_key, int asc, int ascq,
+				  struct scsi_inquiry_data *,
+				  const struct sense_key_table_entry **,
+				  const struct asc_table_entry **);
+static void *	scsibsearch(const void *key, const void *base, size_t nmemb,
+			    size_t size,
+			    int (*compar)(const void *, const void *));
+typedef int (cam_quirkmatch_t)(caddr_t, caddr_t);
+static int	cam_strmatch(const u_int8_t *str, const u_int8_t *pattern,
+			     int str_len);
+static caddr_t	cam_quirkmatch(caddr_t target, caddr_t quirk_table,
+			       int num_entries, int entry_size,
+			       cam_quirkmatch_t *comp_func);
+
+#define SCSI_NO_SENSE_STRINGS 1
+#if !defined(SCSI_NO_SENSE_STRINGS)
+#define SST(asc, ascq, action, desc) \
+	asc, ascq, action, desc
+#else 
+static const char empty_string[] = "";
+
+#define SST(asc, ascq, action, desc) \
+	asc, ascq, action, empty_string
+#endif 
+
+static const struct sense_key_table_entry sense_key_table[] = 
+{
+	{ SSD_KEY_NO_SENSE, SS_NOP, "NO SENSE" },
+	{ SSD_KEY_RECOVERED_ERROR, SS_NOP|SSQ_PRINT_SENSE, "RECOVERED ERROR" },
+	{
+	  SSD_KEY_NOT_READY, SS_TUR|SSQ_MANY|SSQ_DECREMENT_COUNT|EBUSY,
+	  "NOT READY"
+	},
+	{ SSD_KEY_MEDIUM_ERROR, SS_RDEF, "MEDIUM ERROR" },
+	{ SSD_KEY_HARDWARE_ERROR, SS_RDEF, "HARDWARE FAILURE" },
+	{ SSD_KEY_ILLEGAL_REQUEST, SS_FATAL|EINVAL, "ILLEGAL REQUEST" },
+	{ SSD_KEY_UNIT_ATTENTION, SS_FATAL|ENXIO, "UNIT ATTENTION" },
+	{ SSD_KEY_DATA_PROTECT, SS_FATAL|EACCES, "DATA PROTECT" },
+	{ SSD_KEY_BLANK_CHECK, SS_FATAL|ENOSPC, "BLANK CHECK" },
+	{ SSD_KEY_Vendor_Specific, SS_FATAL|EIO, "Vendor Specific" },
+	{ SSD_KEY_COPY_ABORTED, SS_FATAL|EIO, "COPY ABORTED" },
+	{ SSD_KEY_ABORTED_COMMAND, SS_RDEF, "ABORTED COMMAND" },
+	{ SSD_KEY_EQUAL, SS_NOP, "EQUAL" },
+	{ SSD_KEY_VOLUME_OVERFLOW, SS_FATAL|EIO, "VOLUME OVERFLOW" },
+	{ SSD_KEY_MISCOMPARE, SS_NOP, "MISCOMPARE" },
+	{ SSD_KEY_RESERVED, SS_FATAL|EIO, "RESERVED" }
+};
+
+static const int sense_key_table_size =
+    sizeof(sense_key_table)/sizeof(sense_key_table[0]);
+
+static struct asc_table_entry quantum_fireball_entries[] = {
+	{SST(0x04, 0x0b, SS_START|SSQ_DECREMENT_COUNT|ENXIO, 
+	     "Logical unit not ready, initializing cmd. required")}
+};
+
+static struct asc_table_entry sony_mo_entries[] = {
+	{SST(0x04, 0x00, SS_START|SSQ_DECREMENT_COUNT|ENXIO,
+	     "Logical unit not ready, cause not reportable")}
+};
+
+static struct scsi_sense_quirk_entry sense_quirk_table[] = {
+	{
+		/*
+		 * The Quantum Fireball ST and SE like to return 0x04 0x0b when
+		 * they really should return 0x04 0x02.  0x04,0x0b isn't
+		 * defined in any SCSI spec, and it isn't mentioned in the
+		 * hardware manual for these drives.
+		 */
+		{T_DIRECT, SIP_MEDIA_FIXED, "QUANTUM", "FIREBALL S*", "*"},
+		/*num_sense_keys*/0,
+		sizeof(quantum_fireball_entries)/sizeof(struct asc_table_entry),
+		/*sense key entries*/NULL,
+		quantum_fireball_entries
+	},
+	{
+		/*
+		 * This Sony MO drive likes to return 0x04, 0x00 when it
+		 * isn't spun up.
+		 */
+		{T_DIRECT, SIP_MEDIA_REMOVABLE, "SONY", "SMO-*", "*"},
+		/*num_sense_keys*/0,
+		sizeof(sony_mo_entries)/sizeof(struct asc_table_entry),
+		/*sense key entries*/NULL,
+		sony_mo_entries
+	}
+};
+
+static const int sense_quirk_table_size =
+    sizeof(sense_quirk_table)/sizeof(sense_quirk_table[0]);
+
+static struct asc_table_entry asc_table[] = {
+/*
+ * From File: ASC-NUM.TXT
+ * SCSI ASC/ASCQ Assignments
+ * Numeric Sorted Listing
+ * as of  5/12/97
+ *
+ * D - DIRECT ACCESS DEVICE (SBC)                     device column key
+ * .T - SEQUENTIAL ACCESS DEVICE (SSC)               -------------------
+ * . L - PRINTER DEVICE (SSC)                           blank = reserved
+ * .  P - PROCESSOR DEVICE (SPC)                     not blank = allowed
+ * .  .W - WRITE ONCE READ MULTIPLE DEVICE (SBC)
+ * .  . R - CD DEVICE (MMC)
+ * .  .  S - SCANNER DEVICE (SGC)
+ * .  .  .O - OPTICAL MEMORY DEVICE (SBC)
+ * .  .  . M - MEDIA CHANGER DEVICE (SMC)
+ * .  .  .  C - COMMUNICATION DEVICE (SSC)
+ * .  .  .  .A - STORAGE ARRAY DEVICE (SCC)
+ * .  .  .  . E - ENCLOSURE SERVICES DEVICE (SES)
+ * DTLPWRSOMCAE        ASC   ASCQ  Action  Description
+ * ------------        ----  ----  ------  -----------------------------------*/
+/* DTLPWRSOMCAE */{SST(0x00, 0x00, SS_NOP,
+			"No additional sense information") },
+/*  T    S      */{SST(0x00, 0x01, SS_RDEF,
+			"Filemark detected") },
+/*  T    S      */{SST(0x00, 0x02, SS_RDEF,
+			"End-of-partition/medium detected") },
+/*  T           */{SST(0x00, 0x03, SS_RDEF,
+			"Setmark detected") },
+/*  T    S      */{SST(0x00, 0x04, SS_RDEF,
+			"Beginning-of-partition/medium detected") },
+/*  T    S      */{SST(0x00, 0x05, SS_RDEF,
+			"End-of-data detected") },
+/* DTLPWRSOMCAE */{SST(0x00, 0x06, SS_RDEF,
+			"I/O process terminated") },
+/*      R       */{SST(0x00, 0x11, SS_FATAL|EBUSY,
+			"Audio play operation in progress") },
+/*      R       */{SST(0x00, 0x12, SS_NOP,
+			"Audio play operation paused") },
+/*      R       */{SST(0x00, 0x13, SS_NOP,
+			"Audio play operation successfully completed") },
+/*      R       */{SST(0x00, 0x14, SS_RDEF,
+			"Audio play operation stopped due to error") },
+/*      R       */{SST(0x00, 0x15, SS_NOP,
+			"No current audio status to return") },
+/* DTLPWRSOMCAE */{SST(0x00, 0x16, SS_FATAL|EBUSY,
+			"Operation in progress") },
+/* DTL WRSOM AE */{SST(0x00, 0x17, SS_RDEF,
+			"Cleaning requested") },
+/* D   W  O     */{SST(0x01, 0x00, SS_RDEF,
+			"No index/sector signal") },
+/* D   WR OM    */{SST(0x02, 0x00, SS_RDEF,
+			"No seek complete") },
+/* DTL W SO     */{SST(0x03, 0x00, SS_RDEF,
+			"Peripheral device write fault") },
+/*  T           */{SST(0x03, 0x01, SS_RDEF,
+			"No write current") },
+/*  T           */{SST(0x03, 0x02, SS_RDEF,
+			"Excessive write errors") },
+/* DTLPWRSOMCAE */{SST(0x04, 0x00,
+			SS_TUR|SSQ_DELAY|SSQ_MANY|SSQ_DECREMENT_COUNT|EIO,
+			"Logical unit not ready, cause not reportable") },
+/* DTLPWRSOMCAE */{SST(0x04, 0x01,
+			SS_TUR|SSQ_DELAY|SSQ_MANY|SSQ_DECREMENT_COUNT|EBUSY,
+			"Logical unit is in process of becoming ready") },
+/* DTLPWRSOMCAE */{SST(0x04, 0x02, SS_START|SSQ_DECREMENT_COUNT|ENXIO,
+			"Logical unit not ready, initializing cmd. required") },
+/* DTLPWRSOMCAE */{SST(0x04, 0x03, SS_FATAL|ENXIO,
+			"Logical unit not ready, manual intervention required")},
+/* DTL    O     */{SST(0x04, 0x04, SS_FATAL|EBUSY,
+			"Logical unit not ready, format in progress") },
+/* DT  W  OMCA  */{SST(0x04, 0x05, SS_FATAL|EBUSY,
+			"Logical unit not ready, rebuild in progress") },
+/* DT  W  OMCA  */{SST(0x04, 0x06, SS_FATAL|EBUSY,
+			"Logical unit not ready, recalculation in progress") },
+/* DTLPWRSOMCAE */{SST(0x04, 0x07, SS_FATAL|EBUSY,
+			"Logical unit not ready, operation in progress") },
+/*      R       */{SST(0x04, 0x08, SS_FATAL|EBUSY,
+			"Logical unit not ready, long write in progress") },
+/* DTL WRSOMCAE */{SST(0x05, 0x00, SS_RDEF,
+			"Logical unit does not respond to selection") },
+/* D   WR OM    */{SST(0x06, 0x00, SS_RDEF,
+			"No reference position found") },
+/* DTL WRSOM    */{SST(0x07, 0x00, SS_RDEF,
+			"Multiple peripheral devices selected") },
+/* DTL WRSOMCAE */{SST(0x08, 0x00, SS_RDEF,
+			"Logical unit communication failure") },
+/* DTL WRSOMCAE */{SST(0x08, 0x01, SS_RDEF,
+			"Logical unit communication time-out") },
+/* DTL WRSOMCAE */{SST(0x08, 0x02, SS_RDEF,
+			"Logical unit communication parity error") },
+/* DT   R OM    */{SST(0x08, 0x03, SS_RDEF,
+			"Logical unit communication crc error (ultra-dma/32)")},
+/* DT  WR O     */{SST(0x09, 0x00, SS_RDEF,
+			"Track following error") },
+/*     WR O     */{SST(0x09, 0x01, SS_RDEF,
+			"Tracking servo failure") },
+/*     WR O     */{SST(0x09, 0x02, SS_RDEF,
+			"Focus servo failure") },
+/*     WR O     */{SST(0x09, 0x03, SS_RDEF,
+			"Spindle servo failure") },
+/* DT  WR O     */{SST(0x09, 0x04, SS_RDEF,
+			"Head select fault") },
+/* DTLPWRSOMCAE */{SST(0x0A, 0x00, SS_FATAL|ENOSPC,
+			"Error log overflow") },
+/* DTLPWRSOMCAE */{SST(0x0B, 0x00, SS_RDEF,
+			"Warning") },
+/* DTLPWRSOMCAE */{SST(0x0B, 0x01, SS_RDEF,
+			"Specified temperature exceeded") },
+/* DTLPWRSOMCAE */{SST(0x0B, 0x02, SS_RDEF,
+			"Enclosure degraded") },
+/*  T   RS      */{SST(0x0C, 0x00, SS_RDEF,
+			"Write error") },
+/* D   W  O     */{SST(0x0C, 0x01, SS_NOP|SSQ_PRINT_SENSE,
+			"Write error - recovered with auto reallocation") },
+/* D   W  O     */{SST(0x0C, 0x02, SS_RDEF,
+			"Write error - auto reallocation failed") },
+/* D   W  O     */{SST(0x0C, 0x03, SS_RDEF,
+			"Write error - recommend reassignment") },
+/* DT  W  O     */{SST(0x0C, 0x04, SS_RDEF,
+			"Compression check miscompare error") },
+/* DT  W  O     */{SST(0x0C, 0x05, SS_RDEF,
+			"Data expansion occurred during compression") },
+/* DT  W  O     */{SST(0x0C, 0x06, SS_RDEF,
+			"Block not compressible") },
+/*      R       */{SST(0x0C, 0x07, SS_RDEF,
+			"Write error - recovery needed") },
+/*      R       */{SST(0x0C, 0x08, SS_RDEF,
+			"Write error - recovery failed") },
+/*      R       */{SST(0x0C, 0x09, SS_RDEF,
+			"Write error - loss of streaming") },
+/*      R       */{SST(0x0C, 0x0A, SS_RDEF,
+			"Write error - padding blocks added") },
+/* D   W  O     */{SST(0x10, 0x00, SS_RDEF,
+			"ID CRC or ECC error") },
+/* DT  WRSO     */{SST(0x11, 0x00, SS_RDEF,
+			"Unrecovered read error") },
+/* DT  W SO     */{SST(0x11, 0x01, SS_RDEF,
+			"Read retries exhausted") },
+/* DT  W SO     */{SST(0x11, 0x02, SS_RDEF,
+			"Error too long to correct") },
+/* DT  W SO     */{SST(0x11, 0x03, SS_RDEF,
+			"Multiple read errors") },
+/* D   W  O     */{SST(0x11, 0x04, SS_RDEF,
+			"Unrecovered read error - auto reallocate failed") },
+/*     WR O     */{SST(0x11, 0x05, SS_RDEF,
+			"L-EC uncorrectable error") },
+/*     WR O     */{SST(0x11, 0x06, SS_RDEF,
+			"CIRC unrecovered error") },
+/*     W  O     */{SST(0x11, 0x07, SS_RDEF,
+			"Data re-synchronization error") },
+/*  T           */{SST(0x11, 0x08, SS_RDEF,
+			"Incomplete block read") },
+/*  T           */{SST(0x11, 0x09, SS_RDEF,
+			"No gap found") },
+/* DT     O     */{SST(0x11, 0x0A, SS_RDEF,
+			"Miscorrected error") },
+/* D   W  O     */{SST(0x11, 0x0B, SS_RDEF,
+			"Unrecovered read error - recommend reassignment") },
+/* D   W  O     */{SST(0x11, 0x0C, SS_RDEF,
+			"Unrecovered read error - recommend rewrite the data")},
+/* DT  WR O     */{SST(0x11, 0x0D, SS_RDEF,
+			"De-compression CRC error") },
+/* DT  WR O     */{SST(0x11, 0x0E, SS_RDEF,
+			"Cannot decompress using declared algorithm") },
+/*      R       */{SST(0x11, 0x0F, SS_RDEF,
+			"Error reading UPC/EAN number") },
+/*      R       */{SST(0x11, 0x10, SS_RDEF,
+			"Error reading ISRC number") },
+/*      R       */{SST(0x11, 0x11, SS_RDEF,
+			"Read error - loss of streaming") },
+/* D   W  O     */{SST(0x12, 0x00, SS_RDEF,
+			"Address mark not found for id field") },
+/* D   W  O     */{SST(0x13, 0x00, SS_RDEF,
+			"Address mark not found for data field") },
+/* DTL WRSO     */{SST(0x14, 0x00, SS_RDEF,
+			"Recorded entity not found") },
+/* DT  WR O     */{SST(0x14, 0x01, SS_RDEF,
+			"Record not found") },
+/*  T           */{SST(0x14, 0x02, SS_RDEF,
+			"Filemark or setmark not found") },
+/*  T           */{SST(0x14, 0x03, SS_RDEF,
+			"End-of-data not found") },
+/*  T           */{SST(0x14, 0x04, SS_RDEF,
+			"Block sequence error") },
+/* DT  W  O     */{SST(0x14, 0x05, SS_RDEF,
+			"Record not found - recommend reassignment") },
+/* DT  W  O     */{SST(0x14, 0x06, SS_RDEF,
+			"Record not found - data auto-reallocated") },
+/* DTL WRSOM    */{SST(0x15, 0x00, SS_RDEF,
+			"Random positioning error") },
+/* DTL WRSOM    */{SST(0x15, 0x01, SS_RDEF,
+			"Mechanical positioning error") },
+/* DT  WR O     */{SST(0x15, 0x02, SS_RDEF,
+			"Positioning error detected by read of medium") },
+/* D   W  O     */{SST(0x16, 0x00, SS_RDEF,
+			"Data synchronization mark error") },
+/* D   W  O     */{SST(0x16, 0x01, SS_RDEF,
+			"Data sync error - data rewritten") },
+/* D   W  O     */{SST(0x16, 0x02, SS_RDEF,
+			"Data sync error - recommend rewrite") },
+/* D   W  O     */{SST(0x16, 0x03, SS_NOP|SSQ_PRINT_SENSE,
+			"Data sync error - data auto-reallocated") },
+/* D   W  O     */{SST(0x16, 0x04, SS_RDEF,
+			"Data sync error - recommend reassignment") },
+/* DT  WRSO     */{SST(0x17, 0x00, SS_NOP|SSQ_PRINT_SENSE,
+			"Recovered data with no error correction applied") },
+/* DT  WRSO     */{SST(0x17, 0x01, SS_NOP|SSQ_PRINT_SENSE,
+			"Recovered data with retries") },
+/* DT  WR O     */{SST(0x17, 0x02, SS_NOP|SSQ_PRINT_SENSE,
+			"Recovered data with positive head offset") },
+/* DT  WR O     */{SST(0x17, 0x03, SS_NOP|SSQ_PRINT_SENSE,
+			"Recovered data with negative head offset") },
+/*     WR O     */{SST(0x17, 0x04, SS_NOP|SSQ_PRINT_SENSE,
+			"Recovered data with retries and/or CIRC applied") },
+/* D   WR O     */{SST(0x17, 0x05, SS_NOP|SSQ_PRINT_SENSE,
+			"Recovered data using previous sector id") },
+/* D   W  O     */{SST(0x17, 0x06, SS_NOP|SSQ_PRINT_SENSE,
+			"Recovered data without ECC - data auto-reallocated") },
+/* D   W  O     */{SST(0x17, 0x07, SS_NOP|SSQ_PRINT_SENSE,
+			"Recovered data without ECC - recommend reassignment")},
+/* D   W  O     */{SST(0x17, 0x08, SS_NOP|SSQ_PRINT_SENSE,
+			"Recovered data without ECC - recommend rewrite") },
+/* D   W  O     */{SST(0x17, 0x09, SS_NOP|SSQ_PRINT_SENSE,
+			"Recovered data without ECC - data rewritten") },
+/* D   W  O     */{SST(0x18, 0x00, SS_NOP|SSQ_PRINT_SENSE,
+			"Recovered data with error correction applied") },
+/* D   WR O     */{SST(0x18, 0x01, SS_NOP|SSQ_PRINT_SENSE,
+			"Recovered data with error corr. & retries applied") },
+/* D   WR O     */{SST(0x18, 0x02, SS_NOP|SSQ_PRINT_SENSE,
+			"Recovered data - data auto-reallocated") },
+/*      R       */{SST(0x18, 0x03, SS_NOP|SSQ_PRINT_SENSE,
+			"Recovered data with CIRC") },
+/*      R       */{SST(0x18, 0x04, SS_NOP|SSQ_PRINT_SENSE,
+			"Recovered data with L-EC") },
+/* D   WR O     */{SST(0x18, 0x05, SS_NOP|SSQ_PRINT_SENSE,
+			"Recovered data - recommend reassignment") },
+/* D   WR O     */{SST(0x18, 0x06, SS_NOP|SSQ_PRINT_SENSE,
+			"Recovered data - recommend rewrite") },
+/* D   W  O     */{SST(0x18, 0x07, SS_NOP|SSQ_PRINT_SENSE,
+			"Recovered data with ECC - data rewritten") },
+/* D      O     */{SST(0x19, 0x00, SS_RDEF,
+			"Defect list error") },
+/* D      O     */{SST(0x19, 0x01, SS_RDEF,
+			"Defect list not available") },
+/* D      O     */{SST(0x19, 0x02, SS_RDEF,
+			"Defect list error in primary list") },
+/* D      O     */{SST(0x19, 0x03, SS_RDEF,
+			"Defect list error in grown list") },
+/* DTLPWRSOMCAE */{SST(0x1A, 0x00, SS_RDEF,
+			"Parameter list length error") },
+/* DTLPWRSOMCAE */{SST(0x1B, 0x00, SS_RDEF,
+			"Synchronous data transfer error") },
+/* D      O     */{SST(0x1C, 0x00, SS_RDEF,
+			"Defect list not found") },
+/* D      O     */{SST(0x1C, 0x01, SS_RDEF,
+			"Primary defect list not found") },
+/* D      O     */{SST(0x1C, 0x02, SS_RDEF,
+			"Grown defect list not found") },
+/* D   W  O     */{SST(0x1D, 0x00, SS_FATAL,
+			"Miscompare during verify operation" )},
+/* D   W  O     */{SST(0x1E, 0x00, SS_NOP|SSQ_PRINT_SENSE,
+			"Recovered id with ecc correction") },
+/* D      O     */{SST(0x1F, 0x00, SS_RDEF,
+			"Partial defect list transfer") },
+/* DTLPWRSOMCAE */{SST(0x20, 0x00, SS_FATAL|EINVAL,
+			"Invalid command operation code") },
+/* DT  WR OM    */{SST(0x21, 0x00, SS_FATAL|EINVAL,
+			"Logical block address out of range" )},
+/* DT  WR OM    */{SST(0x21, 0x01, SS_FATAL|EINVAL,
+			"Invalid element address") },
+/* D            */{SST(0x22, 0x00, SS_FATAL|EINVAL,
+			"Illegal function") }, /* Deprecated. Use 20 00, 24 00, or 26 00 instead */
+/* DTLPWRSOMCAE */{SST(0x24, 0x00, SS_FATAL|EINVAL,
+			"Invalid field in CDB") },
+/* DTLPWRSOMCAE */{SST(0x25, 0x00, SS_FATAL|ENXIO,
+			"Logical unit not supported") },
+/* DTLPWRSOMCAE */{SST(0x26, 0x00, SS_FATAL|EINVAL,
+			"Invalid field in parameter list") },
+/* DTLPWRSOMCAE */{SST(0x26, 0x01, SS_FATAL|EINVAL,
+			"Parameter not supported") },
+/* DTLPWRSOMCAE */{SST(0x26, 0x02, SS_FATAL|EINVAL,
+			"Parameter value invalid") },
+/* DTLPWRSOMCAE */{SST(0x26, 0x03, SS_FATAL|EINVAL,
+			"Threshold parameters not supported") },
+/* DTLPWRSOMCAE */{SST(0x26, 0x04, SS_FATAL|EINVAL,
+			"Invalid release of active persistent reservation") },
+/* DT  W  O     */{SST(0x27, 0x00, SS_FATAL|EACCES,
+			"Write protected") },
+/* DT  W  O     */{SST(0x27, 0x01, SS_FATAL|EACCES,
+			"Hardware write protected") },
+/* DT  W  O     */{SST(0x27, 0x02, SS_FATAL|EACCES,
+			"Logical unit software write protected") },
+/*  T           */{SST(0x27, 0x03, SS_FATAL|EACCES,
+			"Associated write protect") },
+/*  T           */{SST(0x27, 0x04, SS_FATAL|EACCES,
+			"Persistent write protect") },
+/*  T           */{SST(0x27, 0x05, SS_FATAL|EACCES,
+			"Permanent write protect") },
+/* DTLPWRSOMCAE */{SST(0x28, 0x00, SS_RDEF,
+			"Not ready to ready change, medium may have changed") },
+/* DTLPWRSOMCAE */{SST(0x28, 0x01, SS_FATAL|ENXIO,
+			"Import or export element accessed") },
+/*
+ * XXX JGibbs - All of these should use the same errno, but I don't think
+ * ENXIO is the correct choice.  Should we borrow from the networking
+ * errnos?  ECONNRESET anyone?
+ */
+/* DTLPWRSOMCAE */{SST(0x29, 0x00, SS_RDEF,
+			"Power on, reset, or bus device reset occurred") },
+/* DTLPWRSOMCAE */{SST(0x29, 0x01, SS_RDEF,
+			"Power on occurred") },
+/* DTLPWRSOMCAE */{SST(0x29, 0x02, SS_RDEF,
+			"Scsi bus reset occurred") },
+/* DTLPWRSOMCAE */{SST(0x29, 0x03, SS_RDEF,
+			"Bus device reset function occurred") },
+/* DTLPWRSOMCAE */{SST(0x29, 0x04, SS_RDEF,
+			"Device internal reset") },
+/* DTLPWRSOMCAE */{SST(0x29, 0x05, SS_RDEF,
+			"Transceiver mode changed to single-ended") },
+/* DTLPWRSOMCAE */{SST(0x29, 0x06, SS_RDEF,
+			"Transceiver mode changed to LVD") },
+/* DTL WRSOMCAE */{SST(0x2A, 0x00, SS_RDEF,
+			"Parameters changed") },
+/* DTL WRSOMCAE */{SST(0x2A, 0x01, SS_RDEF,
+			"Mode parameters changed") },
+/* DTL WRSOMCAE */{SST(0x2A, 0x02, SS_RDEF,
+			"Log parameters changed") },
+/* DTLPWRSOMCAE */{SST(0x2A, 0x03, SS_RDEF,
+			"Reservations preempted") },
+/* DTLPWRSO C   */{SST(0x2B, 0x00, SS_RDEF,
+			"Copy cannot execute since host cannot disconnect") },
+/* DTLPWRSOMCAE */{SST(0x2C, 0x00, SS_RDEF,
+			"Command sequence error") },
+/*       S      */{SST(0x2C, 0x01, SS_RDEF,
+			"Too many windows specified") },
+/*       S      */{SST(0x2C, 0x02, SS_RDEF,
+			"Invalid combination of windows specified") },
+/*      R       */{SST(0x2C, 0x03, SS_RDEF,
+			"Current program area is not empty") },
+/*      R       */{SST(0x2C, 0x04, SS_RDEF,
+			"Current program area is empty") },
+/*  T           */{SST(0x2D, 0x00, SS_RDEF,
+			"Overwrite error on update in place") },
+/* DTLPWRSOMCAE */{SST(0x2F, 0x00, SS_RDEF,
+			"Commands cleared by another initiator") },
+/* DT  WR OM    */{SST(0x30, 0x00, SS_RDEF,
+			"Incompatible medium installed") },
+/* DT  WR O     */{SST(0x30, 0x01, SS_RDEF,
+			"Cannot read medium - unknown format") },
+/* DT  WR O     */{SST(0x30, 0x02, SS_RDEF,
+			"Cannot read medium - incompatible format") },
+/* DT           */{SST(0x30, 0x03, SS_RDEF,
+			"Cleaning cartridge installed") },
+/* DT  WR O     */{SST(0x30, 0x04, SS_RDEF,
+			"Cannot write medium - unknown format") },
+/* DT  WR O     */{SST(0x30, 0x05, SS_RDEF,
+			"Cannot write medium - incompatible format") },
+/* DT  W  O     */{SST(0x30, 0x06, SS_RDEF,
+			"Cannot format medium - incompatible medium") },
+/* DTL WRSOM AE */{SST(0x30, 0x07, SS_RDEF,
+			"Cleaning failure") },
+/*      R       */{SST(0x30, 0x08, SS_RDEF,
+			"Cannot write - application code mismatch") },
+/*      R       */{SST(0x30, 0x09, SS_RDEF,
+			"Current session not fixated for append") },
+/* DT  WR O     */{SST(0x31, 0x00, SS_RDEF,
+			"Medium format corrupted") },
+/* D L  R O     */{SST(0x31, 0x01, SS_RDEF,
+			"Format command failed") },
+/* D   W  O     */{SST(0x32, 0x00, SS_RDEF,
+			"No defect spare location available") },
+/* D   W  O     */{SST(0x32, 0x01, SS_RDEF,
+			"Defect list update failure") },
+/*  T           */{SST(0x33, 0x00, SS_RDEF,
+			"Tape length error") },
+/* DTLPWRSOMCAE */{SST(0x34, 0x00, SS_RDEF,
+			"Enclosure failure") },
+/* DTLPWRSOMCAE */{SST(0x35, 0x00, SS_RDEF,
+			"Enclosure services failure") },
+/* DTLPWRSOMCAE */{SST(0x35, 0x01, SS_RDEF,
+			"Unsupported enclosure function") },
+/* DTLPWRSOMCAE */{SST(0x35, 0x02, SS_RDEF,
+			"Enclosure services unavailable") },
+/* DTLPWRSOMCAE */{SST(0x35, 0x03, SS_RDEF,
+			"Enclosure services transfer failure") },
+/* DTLPWRSOMCAE */{SST(0x35, 0x04, SS_RDEF,
+			"Enclosure services transfer refused") },
+/*   L          */{SST(0x36, 0x00, SS_RDEF,
+			"Ribbon, ink, or toner failure") },
+/* DTL WRSOMCAE */{SST(0x37, 0x00, SS_RDEF,
+			"Rounded parameter") },
+/* DTL WRSOMCAE */{SST(0x39, 0x00, SS_RDEF,
+			"Saving parameters not supported") },
+/* DTL WRSOM    */{SST(0x3A, 0x00, SS_NOP,
+			"Medium not present") },
+/* DT  WR OM    */{SST(0x3A, 0x01, SS_NOP,
+			"Medium not present - tray closed") },
+/* DT  WR OM    */{SST(0x3A, 0x01, SS_NOP,
+			"Medium not present - tray open") },
+/* DT  WR OM    */{SST(0x3A, 0x03, SS_NOP,
+			"Medium not present - Loadable") },
+/* DT  WR OM    */{SST(0x3A, 0x04, SS_NOP,
+			"Medium not present - medium auxiliary "
+			"memory accessible") },
+/* DT  WR OM    */{SST(0x3A, 0xFF, SS_NOP, NULL) },/* Range 0x05->0xFF */
+/*  TL          */{SST(0x3B, 0x00, SS_RDEF,
+			"Sequential positioning error") },
+/*  T           */{SST(0x3B, 0x01, SS_RDEF,
+			"Tape position error at beginning-of-medium") },
+/*  T           */{SST(0x3B, 0x02, SS_RDEF,
+			"Tape position error at end-of-medium") },
+/*   L          */{SST(0x3B, 0x03, SS_RDEF,
+			"Tape or electronic vertical forms unit not ready") },
+/*   L          */{SST(0x3B, 0x04, SS_RDEF,
+			"Slew failure") },
+/*   L          */{SST(0x3B, 0x05, SS_RDEF,
+			"Paper jam") },
+/*   L          */{SST(0x3B, 0x06, SS_RDEF,
+			"Failed to sense top-of-form") },
+/*   L          */{SST(0x3B, 0x07, SS_RDEF,
+			"Failed to sense bottom-of-form") },
+/*  T           */{SST(0x3B, 0x08, SS_RDEF,
+			"Reposition error") },
+/*       S      */{SST(0x3B, 0x09, SS_RDEF,
+			"Read past end of medium") },
+/*       S      */{SST(0x3B, 0x0A, SS_RDEF,
+			"Read past beginning of medium") },
+/*       S      */{SST(0x3B, 0x0B, SS_RDEF,
+			"Position past end of medium") },
+/*  T    S      */{SST(0x3B, 0x0C, SS_RDEF,
+			"Position past beginning of medium") },
+/* DT  WR OM    */{SST(0x3B, 0x0D, SS_FATAL|ENOSPC,
+			"Medium destination element full") },
+/* DT  WR OM    */{SST(0x3B, 0x0E, SS_RDEF,
+			"Medium source element empty") },
+/*      R       */{SST(0x3B, 0x0F, SS_RDEF,
+			"End of medium reached") },
+/* DT  WR OM    */{SST(0x3B, 0x11, SS_RDEF,
+			"Medium magazine not accessible") },
+/* DT  WR OM    */{SST(0x3B, 0x12, SS_RDEF,
+			"Medium magazine removed") },
+/* DT  WR OM    */{SST(0x3B, 0x13, SS_RDEF,
+			"Medium magazine inserted") },
+/* DT  WR OM    */{SST(0x3B, 0x14, SS_RDEF,
+			"Medium magazine locked") },
+/* DT  WR OM    */{SST(0x3B, 0x15, SS_RDEF,
+			"Medium magazine unlocked") },
+/* DTLPWRSOMCAE */{SST(0x3D, 0x00, SS_RDEF,
+			"Invalid bits in identify message") },
+/* DTLPWRSOMCAE */{SST(0x3E, 0x00, SS_RDEF,
+			"Logical unit has not self-configured yet") },
+/* DTLPWRSOMCAE */{SST(0x3E, 0x01, SS_RDEF,
+			"Logical unit failure") },
+/* DTLPWRSOMCAE */{SST(0x3E, 0x02, SS_RDEF,
+			"Timeout on logical unit") },
+/* DTLPWRSOMCAE */{SST(0x3F, 0x00, SS_RDEF,
+			"Target operating conditions have changed") },
+/* DTLPWRSOMCAE */{SST(0x3F, 0x01, SS_RDEF,
+			"Microcode has been changed") },
+/* DTLPWRSOMC   */{SST(0x3F, 0x02, SS_RDEF,
+			"Changed operating definition") },
+/* DTLPWRSOMCAE */{SST(0x3F, 0x03, SS_INQ_REFRESH|SSQ_DECREMENT_COUNT,
+			"Inquiry data has changed") },
+/* DT  WR OMCAE */{SST(0x3F, 0x04, SS_RDEF,
+			"Component device attached") },
+/* DT  WR OMCAE */{SST(0x3F, 0x05, SS_RDEF,
+			"Device identifier changed") },
+/* DT  WR OMCAE */{SST(0x3F, 0x06, SS_RDEF,
+			"Redundancy group created or modified") },
+/* DT  WR OMCAE */{SST(0x3F, 0x07, SS_RDEF,
+			"Redundancy group deleted") },
+/* DT  WR OMCAE */{SST(0x3F, 0x08, SS_RDEF,
+			"Spare created or modified") },
+/* DT  WR OMCAE */{SST(0x3F, 0x09, SS_RDEF,
+			"Spare deleted") },
+/* DT  WR OMCAE */{SST(0x3F, 0x0A, SS_RDEF,
+			"Volume set created or modified") },
+/* DT  WR OMCAE */{SST(0x3F, 0x0B, SS_RDEF,
+			"Volume set deleted") },
+/* DT  WR OMCAE */{SST(0x3F, 0x0C, SS_RDEF,
+			"Volume set deassigned") },
+/* DT  WR OMCAE */{SST(0x3F, 0x0D, SS_RDEF,
+			"Volume set reassigned") },
+/* DTLPWRSOMCAE */{SST(0x3F, 0x0E, SS_RDEF,
+			"Reported luns data has changed") },
+/* DTLPWRSOMCAE */{SST(0x3F, 0x0F, SS_RETRY|SSQ_DECREMENT_COUNT
+				 | SSQ_DELAY_RANDOM|EBUSY,
+			"Echo buffer overwritten") },
+/* DT  WR OM   B*/{SST(0x3F, 0x0F, SS_RDEF, "Medium Loadable") },
+/* DT  WR OM   B*/{SST(0x3F, 0x0F, SS_RDEF,
+			"Medium auxiliary memory accessible") },
+/* D            */{SST(0x40, 0x00, SS_RDEF,
+			"Ram failure") }, /* deprecated - use 40 NN instead */
+/* DTLPWRSOMCAE */{SST(0x40, 0x80, SS_RDEF,
+			"Diagnostic failure: ASCQ = Component ID") },
+/* DTLPWRSOMCAE */{SST(0x40, 0xFF, SS_RDEF|SSQ_RANGE,
+			NULL) },/* Range 0x80->0xFF */
+/* D            */{SST(0x41, 0x00, SS_RDEF,
+			"Data path failure") }, /* deprecated - use 40 NN instead */
+/* D            */{SST(0x42, 0x00, SS_RDEF,
+			"Power-on or self-test failure") }, /* deprecated - use 40 NN instead */
+/* DTLPWRSOMCAE */{SST(0x43, 0x00, SS_RDEF,
+			"Message error") },
+/* DTLPWRSOMCAE */{SST(0x44, 0x00, SS_RDEF,
+			"Internal target failure") },
+/* DTLPWRSOMCAE */{SST(0x45, 0x00, SS_RDEF,
+			"Select or reselect failure") },
+/* DTLPWRSOMC   */{SST(0x46, 0x00, SS_RDEF,
+			"Unsuccessful soft reset") },
+/* DTLPWRSOMCAE */{SST(0x47, 0x00, SS_RDEF|SSQ_FALLBACK,
+			"SCSI parity error") },
+/* DTLPWRSOMCAE */{SST(0x47, 0x01, SS_RDEF|SSQ_FALLBACK,
+			"Data Phase CRC error detected") },
+/* DTLPWRSOMCAE */{SST(0x47, 0x02, SS_RDEF|SSQ_FALLBACK,
+			"SCSI parity error detected during ST data phase") },
+/* DTLPWRSOMCAE */{SST(0x47, 0x03, SS_RDEF|SSQ_FALLBACK,
+			"Information Unit iuCRC error") },
+/* DTLPWRSOMCAE */{SST(0x47, 0x04, SS_RDEF|SSQ_FALLBACK,
+			"Asynchronous information protection error detected") },
+/* DTLPWRSOMCAE */{SST(0x47, 0x05, SS_RDEF|SSQ_FALLBACK,
+			"Protocol server CRC error") },
+/* DTLPWRSOMCAE */{SST(0x48, 0x00, SS_RDEF|SSQ_FALLBACK,
+			"Initiator detected error message received") },
+/* DTLPWRSOMCAE */{SST(0x49, 0x00, SS_RDEF,
+			"Invalid message error") },
+/* DTLPWRSOMCAE */{SST(0x4A, 0x00, SS_RDEF,
+			"Command phase error") },
+/* DTLPWRSOMCAE */{SST(0x4B, 0x00, SS_RDEF,
+			"Data phase error") },
+/* DTLPWRSOMCAE */{SST(0x4C, 0x00, SS_RDEF,
+			"Logical unit failed self-configuration") },
+/* DTLPWRSOMCAE */{SST(0x4D, 0x00, SS_RDEF,
+			"Tagged overlapped commands: ASCQ = Queue tag ID") },
+/* DTLPWRSOMCAE */{SST(0x4D, 0xFF, SS_RDEF|SSQ_RANGE,
+			NULL)}, /* Range 0x00->0xFF */
+/* DTLPWRSOMCAE */{SST(0x4E, 0x00, SS_RDEF,
+			"Overlapped commands attempted") },
+/*  T           */{SST(0x50, 0x00, SS_RDEF,
+			"Write append error") },
+/*  T           */{SST(0x50, 0x01, SS_RDEF,
+			"Write append position error") },
+/*  T           */{SST(0x50, 0x02, SS_RDEF,
+			"Position error related to timing") },
+/*  T     O     */{SST(0x51, 0x00, SS_RDEF,
+			"Erase failure") },
+/*  T           */{SST(0x52, 0x00, SS_RDEF,
+			"Cartridge fault") },
+/* DTL WRSOM    */{SST(0x53, 0x00, SS_RDEF,
+			"Media load or eject failed") },
+/*  T           */{SST(0x53, 0x01, SS_RDEF,
+			"Unload tape failure") },
+/* DT  WR OM    */{SST(0x53, 0x02, SS_RDEF,
+			"Medium removal prevented") },
+/*    P         */{SST(0x54, 0x00, SS_RDEF,
+			"Scsi to host system interface failure") },
+/*    P         */{SST(0x55, 0x00, SS_RDEF,
+			"System resource failure") },
+/* D      O     */{SST(0x55, 0x01, SS_FATAL|ENOSPC,
+			"System buffer full") },
+/*      R       */{SST(0x57, 0x00, SS_RDEF,
+			"Unable to recover table-of-contents") },
+/*        O     */{SST(0x58, 0x00, SS_RDEF,
+			"Generation does not exist") },
+/*        O     */{SST(0x59, 0x00, SS_RDEF,
+			"Updated block read") },
+/* DTLPWRSOM    */{SST(0x5A, 0x00, SS_RDEF,
+			"Operator request or state change input") },
+/* DT  WR OM    */{SST(0x5A, 0x01, SS_RDEF,
+			"Operator medium removal request") },
+/* DT  W  O     */{SST(0x5A, 0x02, SS_RDEF,
+			"Operator selected write protect") },
+/* DT  W  O     */{SST(0x5A, 0x03, SS_RDEF,
+			"Operator selected write permit") },
+/* DTLPWRSOM    */{SST(0x5B, 0x00, SS_RDEF,
+			"Log exception") },
+/* DTLPWRSOM    */{SST(0x5B, 0x01, SS_RDEF,
+			"Threshold condition met") },
+/* DTLPWRSOM    */{SST(0x5B, 0x02, SS_RDEF,
+			"Log counter at maximum") },
+/* DTLPWRSOM    */{SST(0x5B, 0x03, SS_RDEF,
+			"Log list codes exhausted") },
+/* D      O     */{SST(0x5C, 0x00, SS_RDEF,
+			"RPL status change") },
+/* D      O     */{SST(0x5C, 0x01, SS_NOP|SSQ_PRINT_SENSE,
+			"Spindles synchronized") },
+/* D      O     */{SST(0x5C, 0x02, SS_RDEF,
+			"Spindles not synchronized") },
+/* DTLPWRSOMCAE */{SST(0x5D, 0x00, SS_RDEF,
+			"Failure prediction threshold exceeded") },
+/* DTLPWRSOMCAE */{SST(0x5D, 0xFF, SS_RDEF,
+			"Failure prediction threshold exceeded (false)") },
+/* DTLPWRSO CA  */{SST(0x5E, 0x00, SS_RDEF,
+			"Low power condition on") },
+/* DTLPWRSO CA  */{SST(0x5E, 0x01, SS_RDEF,
+			"Idle condition activated by timer") },
+/* DTLPWRSO CA  */{SST(0x5E, 0x02, SS_RDEF,
+			"Standby condition activated by timer") },
+/* DTLPWRSO CA  */{SST(0x5E, 0x03, SS_RDEF,
+			"Idle condition activated by command") },
+/* DTLPWRSO CA  */{SST(0x5E, 0x04, SS_RDEF,
+			"Standby condition activated by command") },
+/*       S      */{SST(0x60, 0x00, SS_RDEF,
+			"Lamp failure") },
+/*       S      */{SST(0x61, 0x00, SS_RDEF,
+			"Video acquisition error") },
+/*       S      */{SST(0x61, 0x01, SS_RDEF,
+			"Unable to acquire video") },
+/*       S      */{SST(0x61, 0x02, SS_RDEF,
+			"Out of focus") },
+/*       S      */{SST(0x62, 0x00, SS_RDEF,
+			"Scan head positioning error") },
+/*      R       */{SST(0x63, 0x00, SS_RDEF,
+			"End of user area encountered on this track") },
+/*      R       */{SST(0x63, 0x01, SS_FATAL|ENOSPC,
+			"Packet does not fit in available space") },
+/*      R       */{SST(0x64, 0x00, SS_RDEF,
+			"Illegal mode for this track") },
+/*      R       */{SST(0x64, 0x01, SS_RDEF,
+			"Invalid packet size") },
+/* DTLPWRSOMCAE */{SST(0x65, 0x00, SS_RDEF,
+			"Voltage fault") },
+/*       S      */{SST(0x66, 0x00, SS_RDEF,
+			"Automatic document feeder cover up") },
+/*       S      */{SST(0x66, 0x01, SS_RDEF,
+			"Automatic document feeder lift up") },
+/*       S      */{SST(0x66, 0x02, SS_RDEF,
+			"Document jam in automatic document feeder") },
+/*       S      */{SST(0x66, 0x03, SS_RDEF,
+			"Document miss feed automatic in document feeder") },
+/*           A  */{SST(0x67, 0x00, SS_RDEF,
+			"Configuration failure") },
+/*           A  */{SST(0x67, 0x01, SS_RDEF,
+			"Configuration of incapable logical units failed") },
+/*           A  */{SST(0x67, 0x02, SS_RDEF,
+			"Add logical unit failed") },
+/*           A  */{SST(0x67, 0x03, SS_RDEF,
+			"Modification of logical unit failed") },
+/*           A  */{SST(0x67, 0x04, SS_RDEF,
+			"Exchange of logical unit failed") },
+/*           A  */{SST(0x67, 0x05, SS_RDEF,
+			"Remove of logical unit failed") },
+/*           A  */{SST(0x67, 0x06, SS_RDEF,
+			"Attachment of logical unit failed") },
+/*           A  */{SST(0x67, 0x07, SS_RDEF,
+			"Creation of logical unit failed") },
+/*           A  */{SST(0x68, 0x00, SS_RDEF,
+			"Logical unit not configured") },
+/*           A  */{SST(0x69, 0x00, SS_RDEF,
+			"Data loss on logical unit") },
+/*           A  */{SST(0x69, 0x01, SS_RDEF,
+			"Multiple logical unit failures") },
+/*           A  */{SST(0x69, 0x02, SS_RDEF,
+			"Parity/data mismatch") },
+/*           A  */{SST(0x6A, 0x00, SS_RDEF,
+			"Informational, refer to log") },
+/*           A  */{SST(0x6B, 0x00, SS_RDEF,
+			"State change has occurred") },
+/*           A  */{SST(0x6B, 0x01, SS_RDEF,
+			"Redundancy level got better") },
+/*           A  */{SST(0x6B, 0x02, SS_RDEF,
+			"Redundancy level got worse") },
+/*           A  */{SST(0x6C, 0x00, SS_RDEF,
+			"Rebuild failure occurred") },
+/*           A  */{SST(0x6D, 0x00, SS_RDEF,
+			"Recalculate failure occurred") },
+/*           A  */{SST(0x6E, 0x00, SS_RDEF,
+			"Command to logical unit failed") },
+/*  T           */{SST(0x70, 0x00, SS_RDEF,
+			"Decompression exception short: ASCQ = Algorithm ID") },
+/*  T           */{SST(0x70, 0xFF, SS_RDEF|SSQ_RANGE,
+			NULL) }, /* Range 0x00 -> 0xFF */
+/*  T           */{SST(0x71, 0x00, SS_RDEF,
+			"Decompression exception long: ASCQ = Algorithm ID") },
+/*  T           */{SST(0x71, 0xFF, SS_RDEF|SSQ_RANGE,
+			NULL) }, /* Range 0x00 -> 0xFF */	
+/*      R       */{SST(0x72, 0x00, SS_RDEF,
+			"Session fixation error") },
+/*      R       */{SST(0x72, 0x01, SS_RDEF,
+			"Session fixation error writing lead-in") },
+/*      R       */{SST(0x72, 0x02, SS_RDEF,
+			"Session fixation error writing lead-out") },
+/*      R       */{SST(0x72, 0x03, SS_RDEF,
+			"Session fixation error - incomplete track in session") },
+/*      R       */{SST(0x72, 0x04, SS_RDEF,
+			"Empty or partially written reserved track") },
+/*      R       */{SST(0x73, 0x00, SS_RDEF,
+			"CD control error") },
+/*      R       */{SST(0x73, 0x01, SS_RDEF,
+			"Power calibration area almost full") },
+/*      R       */{SST(0x73, 0x02, SS_FATAL|ENOSPC,
+			"Power calibration area is full") },
+/*      R       */{SST(0x73, 0x03, SS_RDEF,
+			"Power calibration area error") },
+/*      R       */{SST(0x73, 0x04, SS_RDEF,
+			"Program memory area update failure") },
+/*      R       */{SST(0x73, 0x05, SS_RDEF,
+			"program memory area is full") }
+};
+
+static const int asc_table_size = sizeof(asc_table)/sizeof(asc_table[0]);
+
+struct asc_key
+{
+	int asc;
+	int ascq;
+};
+
+static int
+ascentrycomp(const void *key, const void *member)
+{
+	int asc;
+	int ascq;
+	const struct asc_table_entry *table_entry;
+
+	asc = ((const struct asc_key *)key)->asc;
+	ascq = ((const struct asc_key *)key)->ascq;
+	table_entry = (const struct asc_table_entry *)member;
+
+	if (asc >= table_entry->asc) {
+
+		if (asc > table_entry->asc)
+			return (1);
+
+		if (ascq <= table_entry->ascq) {
+			/* Check for ranges */
+			if (ascq == table_entry->ascq
+		 	 || ((table_entry->action & SSQ_RANGE) != 0
+		  	   && ascq >= (table_entry - 1)->ascq))
+				return (0);
+			return (-1);
+		}
+		return (1);
+	}
+	return (-1);
+}
+
+static int
+senseentrycomp(const void *key, const void *member)
+{
+	int sense_key;
+	const struct sense_key_table_entry *table_entry;
+
+	sense_key = *((const int *)key);
+	table_entry = (const struct sense_key_table_entry *)member;
+
+	if (sense_key >= table_entry->sense_key) {
+		if (sense_key == table_entry->sense_key)
+			return (0);
+		return (1);
+	}
+	return (-1);
+}
+
+static void
+fetchtableentries(int sense_key, int asc, int ascq,
+		  struct scsi_inquiry_data *inq_data,
+		  const struct sense_key_table_entry **sense_entry,
+		  const struct asc_table_entry **asc_entry)
+{
+	void *match;
+	const struct asc_table_entry *asc_tables[2];
+	const struct sense_key_table_entry *sense_tables[2];
+	struct asc_key asc_ascq;
+	size_t asc_tables_size[2];
+	size_t sense_tables_size[2];
+	int num_asc_tables;
+	int num_sense_tables;
+	int i;
+
+	/* Default to failure */
+	*sense_entry = NULL;
+	*asc_entry = NULL;
+	match = NULL;
+	if (inq_data != NULL)
+		match = cam_quirkmatch((void *)inq_data,
+				       (void *)sense_quirk_table,
+				       sense_quirk_table_size,
+				       sizeof(*sense_quirk_table),
+				       aic_inquiry_match);
+
+	if (match != NULL) {
+		struct scsi_sense_quirk_entry *quirk;
+
+		quirk = (struct scsi_sense_quirk_entry *)match;
+		asc_tables[0] = quirk->asc_info;
+		asc_tables_size[0] = quirk->num_ascs;
+		asc_tables[1] = asc_table;
+		asc_tables_size[1] = asc_table_size;
+		num_asc_tables = 2;
+		sense_tables[0] = quirk->sense_key_info;
+		sense_tables_size[0] = quirk->num_sense_keys;
+		sense_tables[1] = sense_key_table;
+		sense_tables_size[1] = sense_key_table_size;
+		num_sense_tables = 2;
+	} else {
+		asc_tables[0] = asc_table;
+		asc_tables_size[0] = asc_table_size;
+		num_asc_tables = 1;
+		sense_tables[0] = sense_key_table;
+		sense_tables_size[0] = sense_key_table_size;
+		num_sense_tables = 1;
+	}
+
+	asc_ascq.asc = asc;
+	asc_ascq.ascq = ascq;
+	for (i = 0; i < num_asc_tables; i++) {
+		void *found_entry;
+
+		found_entry = scsibsearch(&asc_ascq, asc_tables[i],
+					  asc_tables_size[i],
+					  sizeof(**asc_tables),
+					  ascentrycomp);
+
+		if (found_entry) {
+			*asc_entry = (struct asc_table_entry *)found_entry;
+			break;
+		}
+	}
+
+	for (i = 0; i < num_sense_tables; i++) {
+		void *found_entry;
+
+		found_entry = scsibsearch(&sense_key, sense_tables[i],
+					  sense_tables_size[i],
+					  sizeof(**sense_tables),
+					  senseentrycomp);
+
+		if (found_entry) {
+			*sense_entry =
+			    (struct sense_key_table_entry *)found_entry;
+			break;
+		}
+	}
+}
+
+static void *
+scsibsearch(const void *key, const void *base, size_t nmemb, size_t size,
+		 int (*compar)(const void *, const void *))
+{
+	const void *entry;
+	u_int l;
+	u_int u;
+	u_int m;
+
+	l = -1;
+	u = nmemb;
+	while (l + 1 != u) {
+		m = (l + u) / 2;
+		entry = base + m * size;
+		if (compar(key, entry) > 0)
+			l = m;
+		else
+			u = m;
+	}
+
+	entry = base + u * size;
+	if (u == nmemb
+	 || compar(key, entry) != 0)
+		return (NULL);
+
+	return ((void *)entry);
+}
+
+/*
+ * Compare string with pattern, returning 0 on match.
+ * Short pattern matches trailing blanks in name,
+ * wildcard '*' in pattern matches rest of name,
+ * wildcard '?' matches a single non-space character.
+ */
+static int
+cam_strmatch(const uint8_t *str, const uint8_t *pattern, int str_len)
+{
+
+	while (*pattern != '\0'&& str_len > 0) {  
+
+		if (*pattern == '*') {
+			return (0);
+		}
+		if ((*pattern != *str)
+		 && (*pattern != '?' || *str == ' ')) {
+			return (1);
+		}
+		pattern++;
+		str++;
+		str_len--;
+	}
+	while (str_len > 0 && *str++ == ' ')
+		str_len--;
+
+	return (str_len);
+}
+
+static caddr_t
+cam_quirkmatch(caddr_t target, caddr_t quirk_table, int num_entries,
+	       int entry_size, cam_quirkmatch_t *comp_func)
+{
+	for (; num_entries > 0; num_entries--, quirk_table += entry_size) {
+		if ((*comp_func)(target, quirk_table) == 0)
+			return (quirk_table);
+	}
+	return (NULL);
+}
+
+void
+aic_sense_desc(int sense_key, int asc, int ascq,
+	       struct scsi_inquiry_data *inq_data,
+	       const char **sense_key_desc, const char **asc_desc)
+{
+	const struct asc_table_entry *asc_entry;
+	const struct sense_key_table_entry *sense_entry;
+
+	fetchtableentries(sense_key, asc, ascq,
+			  inq_data,
+			  &sense_entry,
+			  &asc_entry);
+
+	*sense_key_desc = sense_entry->desc;
+
+	if (asc_entry != NULL)
+		*asc_desc = asc_entry->desc;
+	else if (asc >= 0x80 && asc <= 0xff)
+		*asc_desc = "Vendor Specific ASC";
+	else if (ascq >= 0x80 && ascq <= 0xff)
+		*asc_desc = "Vendor Specific ASCQ";
+	else
+		*asc_desc = "Reserved ASC/ASCQ pair";
+}
+
+/*
+ * Given sense and device type information, return the appropriate action.
+ * If we do not understand the specific error as identified by the ASC/ASCQ
+ * pair, fall back on the more generic actions derived from the sense key.
+ */
+aic_sense_action
+aic_sense_error_action(struct scsi_sense_data *sense_data,
+		       struct scsi_inquiry_data *inq_data, uint32_t sense_flags)
+{
+	const struct asc_table_entry *asc_entry;
+	const struct sense_key_table_entry *sense_entry;
+	int error_code, sense_key, asc, ascq;
+	aic_sense_action action;
+
+	scsi_extract_sense(sense_data, &error_code, &sense_key, &asc, &ascq);
+
+	if (error_code == SSD_DEFERRED_ERROR) {
+		/*
+		 * XXX dufault@FreeBSD.org
+		 * This error doesn't relate to the command associated
+		 * with this request sense.  A deferred error is an error
+		 * for a command that has already returned GOOD status
+		 * (see SCSI2 8.2.14.2).
+		 *
+		 * By my reading of that section, it looks like the current
+		 * command has been cancelled, we should now clean things up
+		 * (hopefully recovering any lost data) and then retry the
+		 * current command.  There are two easy choices, both wrong:
+		 *
+		 * 1. Drop through (like we had been doing), thus treating
+		 *    this as if the error were for the current command and
+		 *    return and stop the current command.
+		 * 
+		 * 2. Issue a retry (like I made it do) thus hopefully
+		 *    recovering the current transfer, and ignoring the
+		 *    fact that we've dropped a command.
+		 *
+		 * These should probably be handled in a device specific
+		 * sense handler or punted back up to a user mode daemon
+		 */
+		action = SS_RETRY|SSQ_DECREMENT_COUNT|SSQ_PRINT_SENSE;
+	} else {
+		fetchtableentries(sense_key, asc, ascq,
+				  inq_data,
+				  &sense_entry,
+				  &asc_entry);
+
+		/*
+		 * Override the 'No additional Sense' entry (0,0)
+		 * with the error action of the sense key.
+		 */
+		if (asc_entry != NULL
+		 && (asc != 0 || ascq != 0))
+			action = asc_entry->action;
+		else
+			action = sense_entry->action;
+
+		if (sense_key == SSD_KEY_RECOVERED_ERROR) {
+			/*
+			 * The action succeeded but the device wants
+			 * the user to know that some recovery action
+			 * was required.
+			 */
+			action &= ~(SS_MASK|SSQ_MASK|SS_ERRMASK);
+			action |= SS_NOP|SSQ_PRINT_SENSE;
+		} else if (sense_key == SSD_KEY_ILLEGAL_REQUEST) {
+			if ((sense_flags & SF_QUIET_IR) != 0)
+				action &= ~SSQ_PRINT_SENSE;
+		} else if (sense_key == SSD_KEY_UNIT_ATTENTION) {
+			if ((sense_flags & SF_RETRY_UA) != 0
+			 && (action & SS_MASK) == SS_FAIL) {
+				action &= ~(SS_MASK|SSQ_MASK);
+				action |= SS_RETRY|SSQ_DECREMENT_COUNT|
+					  SSQ_PRINT_SENSE;
+			}
+		}
+	}
+
+	if ((sense_flags & SF_PRINT_ALWAYS) != 0)
+		action |= SSQ_PRINT_SENSE;
+	else if ((sense_flags & SF_NO_PRINT) != 0)
+		action &= ~SSQ_PRINT_SENSE;
+
+	return (action);
+}
+
+/*      
+ * Try make as good a match as possible with
+ * available sub drivers
+ */
+int
+aic_inquiry_match(caddr_t inqbuffer, caddr_t table_entry)
+{
+	struct scsi_inquiry_pattern *entry;
+	struct scsi_inquiry_data *inq;
+ 
+	entry = (struct scsi_inquiry_pattern *)table_entry;
+	inq = (struct scsi_inquiry_data *)inqbuffer;
+
+	if (((SID_TYPE(inq) == entry->type)
+	  || (entry->type == T_ANY))
+	 && (SID_IS_REMOVABLE(inq) ? entry->media_type & SIP_MEDIA_REMOVABLE
+				   : entry->media_type & SIP_MEDIA_FIXED)
+	 && (cam_strmatch(inq->vendor, entry->vendor, sizeof(inq->vendor)) == 0)
+	 && (cam_strmatch(inq->product, entry->product,
+			  sizeof(inq->product)) == 0)
+	 && (cam_strmatch(inq->revision, entry->revision,
+			  sizeof(inq->revision)) == 0)) {
+		return (0);
+	}
+        return (-1);
+}
+
+/*
+ * Table of syncrates that don't follow the "divisible by 4"
+ * rule. This table will be expanded in future SCSI specs.
+ */
+static struct {
+	u_int period_factor;
+	u_int period;	/* in 100ths of ns */
+} scsi_syncrates[] = {
+	{ 0x08, 625 },	/* FAST-160 */
+	{ 0x09, 1250 },	/* FAST-80 */
+	{ 0x0a, 2500 },	/* FAST-40 40MHz */
+	{ 0x0b, 3030 },	/* FAST-40 33MHz */
+	{ 0x0c, 5000 }	/* FAST-20 */
+};
+
+/*
+ * Return the frequency in kHz corresponding to the given
+ * sync period factor.
+ */
+u_int
+aic_calc_syncsrate(u_int period_factor)
+{
+	int i;
+	int num_syncrates;
+
+	num_syncrates = sizeof(scsi_syncrates) / sizeof(scsi_syncrates[0]);
+	/* See if the period is in the "exception" table */
+	for (i = 0; i < num_syncrates; i++) {
+
+		if (period_factor == scsi_syncrates[i].period_factor) {
+			/* Period in kHz */
+			return (100000000 / scsi_syncrates[i].period);
+		}
+	}
+
+	/*
+	 * Wasn't in the table, so use the standard
+	 * 4 times conversion.
+	 */
+	return (10000000 / (period_factor * 4 * 10));
+}
+
+/*
+ * Return speed in KB/s.
+ */
+u_int
+aic_calc_speed(u_int width, u_int period, u_int offset, u_int min_rate)
+{
+	u_int freq;
+
+	if (offset != 0 && period < min_rate)
+		freq  = aic_calc_syncsrate(period);
+	else
+		/* Roughly 3.3MB/s for async */
+		freq  = 3300;
+	freq <<= width;
+	return (freq);
+}
+
+uint32_t
+aic_error_action(struct scsi_cmnd *cmd, struct scsi_inquiry_data *inq_data,
+		 cam_status status, u_int scsi_status)
+{
+	aic_sense_action  err_action;
+	int		  sense;
+
+	sense  = (cmd->result >> 24) == DRIVER_SENSE;
+
+	switch (status) {
+	case CAM_REQ_CMP:
+		err_action = SS_NOP;
+		break;
+	case CAM_AUTOSENSE_FAIL:
+	case CAM_SCSI_STATUS_ERROR:
+
+		switch (scsi_status) {
+		case SCSI_STATUS_OK:
+		case SCSI_STATUS_COND_MET:
+		case SCSI_STATUS_INTERMED:
+		case SCSI_STATUS_INTERMED_COND_MET:
+			err_action = SS_NOP;
+			break;
+		case SCSI_STATUS_CMD_TERMINATED:
+		case SCSI_STATUS_CHECK_COND:
+			if (sense != 0) {
+				struct scsi_sense_data *sense;
+
+				sense = (struct scsi_sense_data *)
+				    &cmd->sense_buffer;
+				err_action =
+				    aic_sense_error_action(sense, inq_data, 0);
+
+			} else {
+				err_action = SS_RETRY|SSQ_FALLBACK
+					   | SSQ_DECREMENT_COUNT|EIO;
+			}
+			break;
+		case SCSI_STATUS_QUEUE_FULL:
+		case SCSI_STATUS_BUSY:
+			err_action = SS_RETRY|SSQ_DELAY|SSQ_MANY
+				   | SSQ_DECREMENT_COUNT|EBUSY;
+			break;
+		case SCSI_STATUS_RESERV_CONFLICT:
+		default:
+			err_action = SS_FAIL|EBUSY;
+			break;
+		}
+		break;
+	case CAM_CMD_TIMEOUT:
+	case CAM_REQ_CMP_ERR:
+	case CAM_UNEXP_BUSFREE:
+	case CAM_UNCOR_PARITY:
+	case CAM_DATA_RUN_ERR:
+		err_action = SS_RETRY|SSQ_FALLBACK|EIO;
+		break;
+	case CAM_UA_ABORT:
+	case CAM_UA_TERMIO:
+	case CAM_MSG_REJECT_REC:
+	case CAM_SEL_TIMEOUT:
+		err_action = SS_FAIL|EIO;
+		break;
+	case CAM_REQ_INVALID:
+	case CAM_PATH_INVALID:
+	case CAM_DEV_NOT_THERE:
+	case CAM_NO_HBA:
+	case CAM_PROVIDE_FAIL:
+	case CAM_REQ_TOO_BIG:		
+	case CAM_RESRC_UNAVAIL:
+	case CAM_BUSY:
+	default:
+		/* panic??  These should never occur in our application. */
+		err_action = SS_FAIL|EIO;
+		break;
+	case CAM_SCSI_BUS_RESET:
+	case CAM_BDR_SENT:		
+	case CAM_REQUEUE_REQ:
+		/* Unconditional requeue */
+		err_action = SS_RETRY;
+		break;
+	}
+
+	return (err_action);
+}
+
+char *
+aic_parse_brace_option(char *opt_name, char *opt_arg, char *end, int depth,
+		       aic_option_callback_t *callback, u_long callback_arg)
+{
+	char	*tok_end;
+	char	*tok_end2;
+	int      i;
+	int      instance;
+	int	 targ;
+	int	 done;
+	char	 tok_list[] = {'.', ',', '{', '}', '\0'};
+
+	/* All options use a ':' name/arg separator */
+	if (*opt_arg != ':')
+		return (opt_arg);
+	opt_arg++;
+	instance = -1;
+	targ = -1;
+	done = FALSE;
+	/*
+	 * Restore separator that may be in
+	 * the middle of our option argument.
+	 */
+	tok_end = strchr(opt_arg, '\0');
+	if (tok_end < end)
+		*tok_end = ',';
+	while (!done) {
+		switch (*opt_arg) {
+		case '{':
+			if (instance == -1) {
+				instance = 0;
+			} else {
+				if (depth > 1) {
+					if (targ == -1)
+						targ = 0;
+				} else {
+					printf("Malformed Option %s\n",
+					       opt_name);
+					done = TRUE;
+				}
+			}
+			opt_arg++;
+			break;
+		case '}':
+			if (targ != -1)
+				targ = -1;
+			else if (instance != -1)
+				instance = -1;
+			opt_arg++;
+			break;
+		case ',':
+		case '.':
+			if (instance == -1)
+				done = TRUE;
+			else if (targ >= 0)
+				targ++;
+			else if (instance >= 0)
+				instance++;
+			opt_arg++;
+			break;
+		case '\0':
+			done = TRUE;
+			break;
+		default:
+			tok_end = end;
+			for (i = 0; tok_list[i]; i++) {
+				tok_end2 = strchr(opt_arg, tok_list[i]);
+				if ((tok_end2) && (tok_end2 < tok_end))
+					tok_end = tok_end2;
+			}
+			callback(callback_arg, instance, targ,
+				 simple_strtol(opt_arg, NULL, 0));
+			opt_arg = tok_end;
+			break;
+		}
+	}
+	return (opt_arg);
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/aiclib.h linux-2.4.22-pre2/drivers/scsi/aic7xxx/aiclib.h
--- linux-2.4.21/drivers/scsi/aic7xxx/aiclib.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/aiclib.h	2003-06-26 21:43:12.000000000 +0000
@@ -0,0 +1,1046 @@
+/*
+ * Largely written by Julian Elischer (julian@tfs.com)
+ * for TRW Financial Systems.
+ *
+ * TRW Financial Systems, in accordance with their agreement with Carnegie
+ * Mellon University, makes this software available to CMU to distribute
+ * or use in any manner that they see fit as long as this message is kept with
+ * the software. For this reason TFS also grants any other persons or
+ * organisations permission to use or modify this software.
+ *
+ * TFS supplies this software to be publicly redistributed
+ * on the understanding that TFS is not responsible for the correct
+ * functioning of this software in any circumstances.
+ *
+ * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
+ *
+ * $FreeBSD: src/sys/cam/scsi/scsi_all.h,v 1.21 2002/10/08 17:12:44 ken Exp $
+ *
+ * Copyright (c) 2003 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	_AICLIB_H
+#define _AICLIB_H
+
+/*
+ * Linux Interrupt Support.
+ */
+#ifndef IRQ_RETVAL
+typedef void irqreturn_t;
+#define	IRQ_RETVAL(x)
+#endif
+
+/*
+ * SCSI command format
+ */
+
+/*
+ * Define dome bits that are in ALL (or a lot of) scsi commands
+ */
+#define SCSI_CTL_LINK		0x01
+#define SCSI_CTL_FLAG		0x02
+#define SCSI_CTL_VENDOR		0xC0
+#define	SCSI_CMD_LUN		0xA0	/* these two should not be needed */
+#define	SCSI_CMD_LUN_SHIFT	5	/* LUN in the cmd is no longer SCSI */
+
+#define SCSI_MAX_CDBLEN		16	/* 
+					 * 16 byte commands are in the 
+					 * SCSI-3 spec 
+					 */
+/* 6byte CDBs special case 0 length to be 256 */
+#define SCSI_CDB6_LEN(len)	((len) == 0 ? 256 : len)
+
+/*
+ * This type defines actions to be taken when a particular sense code is
+ * received.  Right now, these flags are only defined to take up 16 bits,
+ * but can be expanded in the future if necessary.
+ */
+typedef enum {
+	SS_NOP		= 0x000000, /* Do nothing */
+	SS_RETRY	= 0x010000, /* Retry the command */
+	SS_FAIL		= 0x020000, /* Bail out */
+	SS_START	= 0x030000, /* Send a Start Unit command to the device,
+				     * then retry the original command.
+				     */
+	SS_TUR		= 0x040000, /* Send a Test Unit Ready command to the
+				     * device, then retry the original command.
+				     */
+	SS_REQSENSE	= 0x050000, /* Send a RequestSense command to the
+				     * device, then retry the original command.
+				     */
+	SS_INQ_REFRESH	= 0x060000,
+	SS_MASK		= 0xff0000
+} aic_sense_action;
+
+typedef enum {
+	SSQ_NONE		= 0x0000,
+	SSQ_DECREMENT_COUNT	= 0x0100,  /* Decrement the retry count */
+	SSQ_MANY		= 0x0200,  /* send lots of recovery commands */
+	SSQ_RANGE		= 0x0400,  /*
+					    * This table entry represents the
+					    * end of a range of ASCQs that
+					    * have identical error actions
+					    * and text.
+					    */
+	SSQ_PRINT_SENSE		= 0x0800,
+	SSQ_DELAY		= 0x1000,  /* Delay before retry. */
+	SSQ_DELAY_RANDOM	= 0x2000,  /* Randomized delay before retry. */
+	SSQ_FALLBACK		= 0x4000,  /* Do a speed fallback to recover */
+	SSQ_MASK		= 0xff00
+} aic_sense_action_qualifier;
+
+/* Mask for error status values */
+#define SS_ERRMASK	0xff
+
+/* The default, retyable, error action */
+#define SS_RDEF		SS_RETRY|SSQ_DECREMENT_COUNT|SSQ_PRINT_SENSE|EIO
+
+/* The retyable, error action, with table specified error code */
+#define SS_RET		SS_RETRY|SSQ_DECREMENT_COUNT|SSQ_PRINT_SENSE
+
+/* Fatal error action, with table specified error code */
+#define SS_FATAL	SS_FAIL|SSQ_PRINT_SENSE
+
+struct scsi_generic
+{
+	uint8_t opcode;
+	uint8_t bytes[11];
+};
+
+struct scsi_request_sense
+{
+	uint8_t opcode;
+	uint8_t byte2;
+	uint8_t unused[2];
+	uint8_t length;
+	uint8_t control;
+};
+
+struct scsi_test_unit_ready
+{
+	uint8_t opcode;
+	uint8_t byte2;
+	uint8_t unused[3];
+	uint8_t control;
+};
+
+struct scsi_send_diag
+{
+	uint8_t opcode;
+	uint8_t byte2;
+#define	SSD_UOL		0x01
+#define	SSD_DOL		0x02
+#define	SSD_SELFTEST	0x04
+#define	SSD_PF		0x10
+	uint8_t unused[1];
+	uint8_t paramlen[2];
+	uint8_t control;
+};
+
+struct scsi_sense
+{
+	uint8_t opcode;
+	uint8_t byte2;
+	uint8_t unused[2];
+	uint8_t length;
+	uint8_t control;
+};
+
+struct scsi_inquiry
+{
+	uint8_t opcode;
+	uint8_t byte2;
+#define	SI_EVPD 0x01
+	uint8_t page_code;
+	uint8_t reserved;
+	uint8_t length;
+	uint8_t control;
+};
+
+struct scsi_mode_sense_6
+{
+	uint8_t opcode;
+	uint8_t byte2;
+#define	SMS_DBD				0x08
+	uint8_t page;
+#define	SMS_PAGE_CODE 			0x3F
+#define SMS_VENDOR_SPECIFIC_PAGE	0x00
+#define SMS_DISCONNECT_RECONNECT_PAGE	0x02
+#define SMS_PERIPHERAL_DEVICE_PAGE	0x09
+#define SMS_CONTROL_MODE_PAGE		0x0A
+#define SMS_ALL_PAGES_PAGE		0x3F
+#define	SMS_PAGE_CTRL_MASK		0xC0
+#define	SMS_PAGE_CTRL_CURRENT 		0x00
+#define	SMS_PAGE_CTRL_CHANGEABLE 	0x40
+#define	SMS_PAGE_CTRL_DEFAULT 		0x80
+#define	SMS_PAGE_CTRL_SAVED 		0xC0
+	uint8_t unused;
+	uint8_t length;
+	uint8_t control;
+};
+
+struct scsi_mode_sense_10
+{
+	uint8_t opcode;
+	uint8_t byte2;		/* same bits as small version */
+	uint8_t page; 		/* same bits as small version */
+	uint8_t unused[4];
+	uint8_t length[2];
+	uint8_t control;
+};
+
+struct scsi_mode_select_6
+{
+	uint8_t opcode;
+	uint8_t byte2;
+#define	SMS_SP	0x01
+#define	SMS_PF	0x10
+	uint8_t unused[2];
+	uint8_t length;
+	uint8_t control;
+};
+
+struct scsi_mode_select_10
+{
+	uint8_t opcode;
+	uint8_t byte2;		/* same bits as small version */
+	uint8_t unused[5];
+	uint8_t length[2];
+	uint8_t control;
+};
+
+/*
+ * When sending a mode select to a tape drive, the medium type must be 0.
+ */
+struct scsi_mode_hdr_6
+{
+	uint8_t datalen;
+	uint8_t medium_type;
+	uint8_t dev_specific;
+	uint8_t block_descr_len;
+};
+
+struct scsi_mode_hdr_10
+{
+	uint8_t datalen[2];
+	uint8_t medium_type;
+	uint8_t dev_specific;
+	uint8_t reserved[2];
+	uint8_t block_descr_len[2];
+};
+
+struct scsi_mode_block_descr
+{
+	uint8_t density_code;
+	uint8_t num_blocks[3];
+	uint8_t reserved;
+	uint8_t block_len[3];
+};
+
+struct scsi_log_sense
+{
+	uint8_t opcode;
+	uint8_t byte2;
+#define	SLS_SP				0x01
+#define	SLS_PPC				0x02
+	uint8_t page;
+#define	SLS_PAGE_CODE 			0x3F
+#define	SLS_ALL_PAGES_PAGE		0x00
+#define	SLS_OVERRUN_PAGE		0x01
+#define	SLS_ERROR_WRITE_PAGE		0x02
+#define	SLS_ERROR_READ_PAGE		0x03
+#define	SLS_ERROR_READREVERSE_PAGE	0x04
+#define	SLS_ERROR_VERIFY_PAGE		0x05
+#define	SLS_ERROR_NONMEDIUM_PAGE	0x06
+#define	SLS_ERROR_LASTN_PAGE		0x07
+#define	SLS_PAGE_CTRL_MASK		0xC0
+#define	SLS_PAGE_CTRL_THRESHOLD		0x00
+#define	SLS_PAGE_CTRL_CUMULATIVE	0x40
+#define	SLS_PAGE_CTRL_THRESH_DEFAULT	0x80
+#define	SLS_PAGE_CTRL_CUMUL_DEFAULT	0xC0
+	uint8_t reserved[2];
+	uint8_t paramptr[2];
+	uint8_t length[2];
+	uint8_t control;
+};
+
+struct scsi_log_select
+{
+	uint8_t opcode;
+	uint8_t byte2;
+/*	SLS_SP				0x01 */
+#define	SLS_PCR				0x02
+	uint8_t page;
+/*	SLS_PAGE_CTRL_MASK		0xC0 */
+/*	SLS_PAGE_CTRL_THRESHOLD		0x00 */
+/*	SLS_PAGE_CTRL_CUMULATIVE	0x40 */
+/*	SLS_PAGE_CTRL_THRESH_DEFAULT	0x80 */
+/*	SLS_PAGE_CTRL_CUMUL_DEFAULT	0xC0 */
+	uint8_t reserved[4];
+	uint8_t length[2];
+	uint8_t control;
+};
+
+struct scsi_log_header
+{
+	uint8_t page;
+	uint8_t reserved;
+	uint8_t datalen[2];
+};
+
+struct scsi_log_param_header {
+	uint8_t param_code[2];
+	uint8_t param_control;
+#define	SLP_LP				0x01
+#define	SLP_LBIN			0x02
+#define	SLP_TMC_MASK			0x0C
+#define	SLP_TMC_ALWAYS			0x00
+#define	SLP_TMC_EQUAL			0x04
+#define	SLP_TMC_NOTEQUAL		0x08
+#define	SLP_TMC_GREATER			0x0C
+#define	SLP_ETC				0x10
+#define	SLP_TSD				0x20
+#define	SLP_DS				0x40
+#define	SLP_DU				0x80
+	uint8_t param_len;
+};
+
+struct scsi_control_page {
+	uint8_t page_code;
+	uint8_t page_length;
+	uint8_t rlec;
+#define SCB_RLEC			0x01	/*Report Log Exception Cond*/
+	uint8_t queue_flags;
+#define SCP_QUEUE_ALG_MASK		0xF0
+#define SCP_QUEUE_ALG_RESTRICTED	0x00
+#define SCP_QUEUE_ALG_UNRESTRICTED	0x10
+#define SCP_QUEUE_ERR			0x02	/*Queued I/O aborted for CACs*/
+#define SCP_QUEUE_DQUE			0x01	/*Queued I/O disabled*/
+	uint8_t eca_and_aen;
+#define SCP_EECA			0x80	/*Enable Extended CA*/
+#define SCP_RAENP			0x04	/*Ready AEN Permission*/
+#define SCP_UAAENP			0x02	/*UA AEN Permission*/
+#define SCP_EAENP			0x01	/*Error AEN Permission*/
+	uint8_t reserved;
+	uint8_t aen_holdoff_period[2];
+};
+
+struct scsi_reserve
+{
+	uint8_t opcode;
+	uint8_t byte2;
+	uint8_t unused[2];
+	uint8_t length;
+	uint8_t control;
+};
+
+struct scsi_release
+{
+	uint8_t opcode;
+	uint8_t byte2;
+	uint8_t unused[2];
+	uint8_t length;
+	uint8_t control;
+};
+
+struct scsi_prevent
+{
+	uint8_t opcode;
+	uint8_t byte2;
+	uint8_t unused[2];
+	uint8_t how;
+	uint8_t control;
+};
+#define	PR_PREVENT 0x01
+#define PR_ALLOW   0x00
+
+struct scsi_sync_cache
+{
+	uint8_t opcode;
+	uint8_t byte2;
+	uint8_t begin_lba[4];
+	uint8_t reserved;
+	uint8_t lb_count[2];
+	uint8_t control;	
+};
+
+
+struct scsi_changedef
+{
+	uint8_t opcode;
+	uint8_t byte2;
+	uint8_t unused1;
+	uint8_t how;
+	uint8_t unused[4];
+	uint8_t datalen;
+	uint8_t control;
+};
+
+struct scsi_read_buffer
+{
+	uint8_t opcode;
+	uint8_t byte2;
+#define	RWB_MODE		0x07
+#define	RWB_MODE_HDR_DATA	0x00
+#define	RWB_MODE_DATA		0x02
+#define	RWB_MODE_DOWNLOAD	0x04
+#define	RWB_MODE_DOWNLOAD_SAVE	0x05
+        uint8_t buffer_id;
+        uint8_t offset[3];
+        uint8_t length[3];
+        uint8_t control;
+};
+
+struct scsi_write_buffer
+{
+	uint8_t opcode;
+	uint8_t byte2;
+	uint8_t buffer_id;
+	uint8_t offset[3];
+	uint8_t length[3];
+	uint8_t control;
+};
+
+struct scsi_rw_6
+{
+	uint8_t opcode;
+	uint8_t addr[3];
+/* only 5 bits are valid in the MSB address byte */
+#define	SRW_TOPADDR	0x1F
+	uint8_t length;
+	uint8_t control;
+};
+
+struct scsi_rw_10
+{
+	uint8_t opcode;
+#define	SRW10_RELADDR	0x01
+#define SRW10_FUA	0x08
+#define	SRW10_DPO	0x10
+	uint8_t byte2;
+	uint8_t addr[4];
+	uint8_t reserved;
+	uint8_t length[2];
+	uint8_t control;
+};
+
+struct scsi_rw_12
+{
+	uint8_t opcode;
+#define	SRW12_RELADDR	0x01
+#define SRW12_FUA	0x08
+#define	SRW12_DPO	0x10
+	uint8_t byte2;
+	uint8_t addr[4];
+	uint8_t length[4];
+	uint8_t reserved;
+	uint8_t control;
+};
+
+struct scsi_start_stop_unit
+{
+	uint8_t opcode;
+	uint8_t byte2;
+#define	SSS_IMMED		0x01
+	uint8_t reserved[2];
+	uint8_t how;
+#define	SSS_START		0x01
+#define	SSS_LOEJ		0x02
+	uint8_t control;
+};
+
+#define SC_SCSI_1 0x01
+#define SC_SCSI_2 0x03
+
+/*
+ * Opcodes
+ */
+
+#define	TEST_UNIT_READY		0x00
+#define REQUEST_SENSE		0x03
+#define	READ_6			0x08
+#define WRITE_6			0x0a
+#define INQUIRY			0x12
+#define MODE_SELECT_6		0x15
+#define MODE_SENSE_6		0x1a
+#define START_STOP_UNIT		0x1b
+#define START_STOP		0x1b
+#define RESERVE      		0x16
+#define RELEASE      		0x17
+#define	RECEIVE_DIAGNOSTIC	0x1c
+#define	SEND_DIAGNOSTIC		0x1d
+#define PREVENT_ALLOW		0x1e
+#define	READ_CAPACITY		0x25
+#define	READ_10			0x28
+#define WRITE_10		0x2a
+#define POSITION_TO_ELEMENT	0x2b
+#define	SYNCHRONIZE_CACHE	0x35
+#define	WRITE_BUFFER            0x3b
+#define	READ_BUFFER             0x3c
+#define	CHANGE_DEFINITION	0x40
+#define	LOG_SELECT		0x4c
+#define	LOG_SENSE		0x4d
+#ifdef XXXCAM
+#define	MODE_SENSE_10		0x5A
+#endif
+#define	MODE_SELECT_10		0x55
+#define MOVE_MEDIUM     	0xa5
+#define READ_12			0xa8
+#define WRITE_12		0xaa
+#define READ_ELEMENT_STATUS	0xb8
+
+
+/*
+ * Device Types
+ */
+#define T_DIRECT	0x00
+#define T_SEQUENTIAL	0x01
+#define T_PRINTER	0x02
+#define T_PROCESSOR	0x03
+#define T_WORM		0x04
+#define T_CDROM		0x05
+#define T_SCANNER 	0x06
+#define T_OPTICAL 	0x07
+#define T_CHANGER	0x08
+#define T_COMM		0x09
+#define T_ASC0		0x0a
+#define T_ASC1		0x0b
+#define	T_STORARRAY	0x0c
+#define	T_ENCLOSURE	0x0d
+#define	T_RBC		0x0e
+#define	T_OCRW		0x0f
+#define T_NODEVICE	0x1F
+#define	T_ANY		0xFF	/* Used in Quirk table matches */
+
+#define T_REMOV		1
+#define	T_FIXED		0
+
+/*
+ * This length is the initial inquiry length used by the probe code, as    
+ * well as the legnth necessary for aic_print_inquiry() to function 
+ * correctly.  If either use requires a different length in the future, 
+ * the two values should be de-coupled.
+ */
+#define	SHORT_INQUIRY_LENGTH	36
+
+struct scsi_inquiry_data
+{
+	uint8_t device;
+#define	SID_TYPE(inq_data) ((inq_data)->device & 0x1f)
+#define	SID_QUAL(inq_data) (((inq_data)->device & 0xE0) >> 5)
+#define	SID_QUAL_LU_CONNECTED	0x00	/*
+					 * The specified peripheral device
+					 * type is currently connected to
+					 * logical unit.  If the target cannot
+					 * determine whether or not a physical
+					 * device is currently connected, it
+					 * shall also use this peripheral
+					 * qualifier when returning the INQUIRY
+					 * data.  This peripheral qualifier
+					 * does not mean that the device is
+					 * ready for access by the initiator.
+					 */
+#define	SID_QUAL_LU_OFFLINE	0x01	/*
+					 * The target is capable of supporting
+					 * the specified peripheral device type
+					 * on this logical unit; however, the
+					 * physical device is not currently
+					 * connected to this logical unit.
+					 */
+#define SID_QUAL_RSVD		0x02
+#define	SID_QUAL_BAD_LU		0x03	/*
+					 * The target is not capable of
+					 * supporting a physical device on
+					 * this logical unit. For this
+					 * peripheral qualifier the peripheral
+					 * device type shall be set to 1Fh to
+					 * provide compatibility with previous
+					 * versions of SCSI. All other
+					 * peripheral device type values are
+					 * reserved for this peripheral
+					 * qualifier.
+					 */
+#define	SID_QUAL_IS_VENDOR_UNIQUE(inq_data) ((SID_QUAL(inq_data) & 0x08) != 0)
+	uint8_t dev_qual2;
+#define	SID_QUAL2	0x7F
+#define	SID_IS_REMOVABLE(inq_data) (((inq_data)->dev_qual2 & 0x80) != 0)
+	uint8_t version;
+#define SID_ANSI_REV(inq_data) ((inq_data)->version & 0x07)
+#define		SCSI_REV_0		0
+#define		SCSI_REV_CCS		1
+#define		SCSI_REV_2		2
+#define		SCSI_REV_SPC		3
+#define		SCSI_REV_SPC2		4
+
+#define SID_ECMA	0x38
+#define SID_ISO		0xC0
+	uint8_t response_format;
+#define SID_AENC	0x80
+#define SID_TrmIOP	0x40
+	uint8_t additional_length;
+	uint8_t reserved[2];
+	uint8_t flags;
+#define	SID_SftRe	0x01
+#define	SID_CmdQue	0x02
+#define	SID_Linked	0x08
+#define	SID_Sync	0x10
+#define	SID_WBus16	0x20
+#define	SID_WBus32	0x40
+#define	SID_RelAdr	0x80
+#define SID_VENDOR_SIZE   8
+	char	 vendor[SID_VENDOR_SIZE];
+#define SID_PRODUCT_SIZE  16
+	char	 product[SID_PRODUCT_SIZE];
+#define SID_REVISION_SIZE 4
+	char	 revision[SID_REVISION_SIZE];
+	/*
+	 * The following fields were taken from SCSI Primary Commands - 2
+	 * (SPC-2) Revision 14, Dated 11 November 1999
+	 */
+#define	SID_VENDOR_SPECIFIC_0_SIZE	20
+	uint8_t vendor_specific0[SID_VENDOR_SPECIFIC_0_SIZE];
+	/*
+	 * An extension of SCSI Parallel Specific Values
+	 */
+#define	SID_SPI_IUS		0x01
+#define	SID_SPI_QAS		0x02
+#define	SID_SPI_CLOCK_ST	0x00
+#define	SID_SPI_CLOCK_DT	0x04
+#define	SID_SPI_CLOCK_DT_ST	0x0C
+#define	SID_SPI_MASK		0x0F
+	uint8_t spi3data;
+	uint8_t reserved2;
+	/*
+	 * Version Descriptors, stored 2 byte values.
+	 */
+	uint8_t version1[2];
+	uint8_t version2[2];
+	uint8_t version3[2];
+	uint8_t version4[2];
+	uint8_t version5[2];
+	uint8_t version6[2];
+	uint8_t version7[2];
+	uint8_t version8[2];
+
+	uint8_t reserved3[22];
+
+#define	SID_VENDOR_SPECIFIC_1_SIZE	160
+	uint8_t vendor_specific1[SID_VENDOR_SPECIFIC_1_SIZE];
+};
+
+struct scsi_vpd_unit_serial_number
+{
+	uint8_t device;
+	uint8_t page_code;
+#define SVPD_UNIT_SERIAL_NUMBER	0x80
+	uint8_t reserved;
+	uint8_t length; /* serial number length */
+#define SVPD_SERIAL_NUM_SIZE 251
+	uint8_t serial_num[SVPD_SERIAL_NUM_SIZE];
+};
+
+struct scsi_read_capacity
+{
+	uint8_t opcode;
+	uint8_t byte2;
+	uint8_t addr[4];
+	uint8_t unused[3];
+	uint8_t control;
+};
+
+struct scsi_read_capacity_data
+{
+	uint8_t addr[4];
+	uint8_t length[4];
+};
+
+struct scsi_report_luns
+{
+	uint8_t opcode;
+	uint8_t byte2;
+	uint8_t unused[3];
+	uint8_t addr[4];
+	uint8_t control;
+};
+
+struct scsi_report_luns_data {
+	uint8_t length[4];	/* length of LUN inventory, in bytes */
+	uint8_t reserved[4];	/* unused */
+	/*
+	 * LUN inventory- we only support the type zero form for now.
+	 */
+	struct {
+		uint8_t lundata[8];
+	} luns[1];
+};
+#define	RPL_LUNDATA_ATYP_MASK	0xc0	/* MBZ for type 0 lun */
+#define	RPL_LUNDATA_T0LUN	1	/* @ lundata[1] */
+
+
+struct scsi_sense_data
+{
+	uint8_t error_code;
+#define	SSD_ERRCODE			0x7F
+#define		SSD_CURRENT_ERROR	0x70
+#define		SSD_DEFERRED_ERROR	0x71
+#define	SSD_ERRCODE_VALID	0x80	
+	uint8_t segment;
+	uint8_t flags;
+#define	SSD_KEY				0x0F
+#define		SSD_KEY_NO_SENSE	0x00
+#define		SSD_KEY_RECOVERED_ERROR	0x01
+#define		SSD_KEY_NOT_READY	0x02
+#define		SSD_KEY_MEDIUM_ERROR	0x03
+#define		SSD_KEY_HARDWARE_ERROR	0x04
+#define		SSD_KEY_ILLEGAL_REQUEST	0x05
+#define		SSD_KEY_UNIT_ATTENTION	0x06
+#define		SSD_KEY_DATA_PROTECT	0x07
+#define		SSD_KEY_BLANK_CHECK	0x08
+#define		SSD_KEY_Vendor_Specific	0x09
+#define		SSD_KEY_COPY_ABORTED	0x0a
+#define		SSD_KEY_ABORTED_COMMAND	0x0b		
+#define		SSD_KEY_EQUAL		0x0c
+#define		SSD_KEY_VOLUME_OVERFLOW	0x0d
+#define		SSD_KEY_MISCOMPARE	0x0e
+#define		SSD_KEY_RESERVED	0x0f			
+#define	SSD_ILI		0x20
+#define	SSD_EOM		0x40
+#define	SSD_FILEMARK	0x80
+	uint8_t info[4];
+	uint8_t extra_len;
+	uint8_t cmd_spec_info[4];
+	uint8_t add_sense_code;
+	uint8_t add_sense_code_qual;
+	uint8_t fru;
+	uint8_t sense_key_spec[3];
+#define	SSD_SCS_VALID		0x80
+#define SSD_FIELDPTR_CMD	0x40
+#define SSD_BITPTR_VALID	0x08
+#define SSD_BITPTR_VALUE	0x07
+#define SSD_MIN_SIZE 18
+	uint8_t extra_bytes[14];
+#define SSD_FULL_SIZE sizeof(struct scsi_sense_data)
+};
+
+struct scsi_mode_header_6
+{
+	uint8_t data_length;	/* Sense data length */
+	uint8_t medium_type;
+	uint8_t dev_spec;
+	uint8_t blk_desc_len;
+};
+
+struct scsi_mode_header_10
+{
+	uint8_t data_length[2];/* Sense data length */
+	uint8_t medium_type;
+	uint8_t dev_spec;
+	uint8_t unused[2];
+	uint8_t blk_desc_len[2];
+};
+
+struct scsi_mode_page_header
+{
+	uint8_t page_code;
+	uint8_t page_length;
+};
+
+struct scsi_mode_blk_desc
+{
+	uint8_t density;
+	uint8_t nblocks[3];
+	uint8_t reserved;
+	uint8_t blklen[3];
+};
+
+#define	SCSI_DEFAULT_DENSITY	0x00	/* use 'default' density */
+#define	SCSI_SAME_DENSITY	0x7f	/* use 'same' density- >= SCSI-2 only */
+
+
+/*
+ * Status Byte
+ */
+#define	SCSI_STATUS_OK			0x00
+#define	SCSI_STATUS_CHECK_COND		0x02
+#define	SCSI_STATUS_COND_MET		0x04
+#define	SCSI_STATUS_BUSY		0x08
+#define SCSI_STATUS_INTERMED		0x10
+#define SCSI_STATUS_INTERMED_COND_MET	0x14
+#define SCSI_STATUS_RESERV_CONFLICT	0x18
+#define SCSI_STATUS_CMD_TERMINATED	0x22	/* Obsolete in SAM-2 */
+#define SCSI_STATUS_QUEUE_FULL		0x28
+#define SCSI_STATUS_ACA_ACTIVE		0x30
+#define SCSI_STATUS_TASK_ABORTED	0x40
+
+struct scsi_inquiry_pattern {
+	uint8_t   type;
+	uint8_t   media_type;
+#define	SIP_MEDIA_REMOVABLE	0x01
+#define	SIP_MEDIA_FIXED		0x02
+	const char *vendor;
+	const char *product;
+	const char *revision;
+}; 
+
+struct scsi_static_inquiry_pattern {
+	uint8_t   type;
+	uint8_t   media_type;
+	char       vendor[SID_VENDOR_SIZE+1];
+	char       product[SID_PRODUCT_SIZE+1];
+	char       revision[SID_REVISION_SIZE+1];
+};
+
+struct scsi_sense_quirk_entry {
+	struct scsi_inquiry_pattern	inq_pat;
+	int				num_sense_keys;
+	int				num_ascs;
+	struct sense_key_table_entry	*sense_key_info;
+	struct asc_table_entry		*asc_info;
+};
+
+struct sense_key_table_entry {
+	uint8_t    sense_key;
+	uint32_t   action;
+	const char *desc;
+};
+
+struct asc_table_entry {
+	uint8_t    asc;
+	uint8_t    ascq;
+	uint32_t   action;
+	const char *desc;
+};
+
+struct op_table_entry {
+	uint8_t    opcode;
+	uint16_t   opmask;
+	const char  *desc;
+};
+
+struct scsi_op_quirk_entry {
+	struct scsi_inquiry_pattern	inq_pat;
+	int				num_ops;
+	struct op_table_entry		*op_table;
+};
+
+typedef enum {
+	SSS_FLAG_NONE		= 0x00,
+	SSS_FLAG_PRINT_COMMAND	= 0x01
+} scsi_sense_string_flags;
+
+extern const char *scsi_sense_key_text[];
+
+/************************* Large Disk Handling ********************************/
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+static __inline int aic_sector_div(u_long capacity, int heads, int sectors);
+
+static __inline int
+aic_sector_div(u_long capacity, int heads, int sectors)
+{
+	return (capacity / (heads * sectors));
+}
+#else
+static __inline int aic_sector_div(sector_t capacity, int heads, int sectors);
+
+static __inline int
+aic_sector_div(sector_t capacity, int heads, int sectors)
+{
+	/* ugly, ugly sector_div calling convention.. */
+	sector_div(capacity, (heads * sectors));
+	return (int)capacity;
+}
+#endif
+
+/**************************** Module Library Hack *****************************/
+/*
+ * What we'd like to do is have a single "scsi library" module that both the
+ * aic7xxx and aic79xx drivers could load and depend on.  A cursory examination
+ * of implementing module dependencies in Linux (handling the install and
+ * initrd cases) does not look promissing.  For now, we just duplicate this
+ * code in both drivers using a simple symbol renaming scheme that hides this
+ * hack from the drivers.
+ */
+#define AIC_LIB_ENTRY_CONCAT(x, prefix)	prefix ## x
+#define	AIC_LIB_ENTRY_EXPAND(x, prefix) AIC_LIB_ENTRY_CONCAT(x, prefix)
+#define AIC_LIB_ENTRY(x)		AIC_LIB_ENTRY_EXPAND(x, AIC_LIB_PREFIX)
+
+#define	aic_sense_desc			AIC_LIB_ENTRY(_sense_desc)
+#define	aic_sense_error_action		AIC_LIB_ENTRY(_sense_error_action)
+#define	aic_error_action		AIC_LIB_ENTRY(_error_action)
+#define	aic_op_desc			AIC_LIB_ENTRY(_op_desc)
+#define	aic_cdb_string			AIC_LIB_ENTRY(_cdb_string)
+#define aic_print_inquiry		AIC_LIB_ENTRY(_print_inquiry)
+#define aic_calc_syncsrate		AIC_LIB_ENTRY(_calc_syncrate)
+#define	aic_calc_syncparam		AIC_LIB_ENTRY(_calc_syncparam)
+#define	aic_calc_speed			AIC_LIB_ENTRY(_calc_speed)
+#define	aic_inquiry_match		AIC_LIB_ENTRY(_inquiry_match)
+#define	aic_static_inquiry_match	AIC_LIB_ENTRY(_static_inquiry_match)
+#define	aic_parse_brace_option		AIC_LIB_ENTRY(_parse_brace_option)
+
+/******************************************************************************/
+
+void			aic_sense_desc(int /*sense_key*/, int /*asc*/,
+				       int /*ascq*/, struct scsi_inquiry_data*,
+				       const char** /*sense_key_desc*/,
+				       const char** /*asc_desc*/);
+aic_sense_action	aic_sense_error_action(struct scsi_sense_data*,
+					       struct scsi_inquiry_data*,
+					       uint32_t /*sense_flags*/);
+uint32_t		aic_error_action(struct scsi_cmnd *,
+					 struct scsi_inquiry_data *,
+					 cam_status, u_int);
+
+#define	SF_RETRY_UA	0x01
+#define SF_NO_PRINT	0x02
+#define SF_QUIET_IR	0x04	/* Be quiet about Illegal Request reponses */
+#define SF_PRINT_ALWAYS	0x08
+
+
+const char *	aic_op_desc(uint16_t /*opcode*/, struct scsi_inquiry_data*);
+char *		aic_cdb_string(uint8_t* /*cdb_ptr*/, char* /*cdb_string*/,
+			       size_t /*len*/);
+void		aic_print_inquiry(struct scsi_inquiry_data*);
+
+u_int		aic_calc_syncsrate(u_int /*period_factor*/);
+u_int		aic_calc_syncparam(u_int /*period*/);
+u_int		aic_calc_speed(u_int width, u_int period, u_int offset,
+			       u_int min_rate);
+	
+int		aic_inquiry_match(caddr_t /*inqbuffer*/,
+				  caddr_t /*table_entry*/);
+int		aic_static_inquiry_match(caddr_t /*inqbuffer*/,
+					 caddr_t /*table_entry*/);
+
+typedef void aic_option_callback_t(u_long, int, int, int32_t);
+char *		aic_parse_brace_option(char *opt_name, char *opt_arg,
+				       char *end, int depth,
+				       aic_option_callback_t *, u_long);
+
+static __inline void	 scsi_extract_sense(struct scsi_sense_data *sense,
+					    int *error_code, int *sense_key,
+					    int *asc, int *ascq);
+static __inline void	 scsi_ulto2b(uint32_t val, uint8_t *bytes);
+static __inline void	 scsi_ulto3b(uint32_t val, uint8_t *bytes);
+static __inline void	 scsi_ulto4b(uint32_t val, uint8_t *bytes);
+static __inline uint32_t scsi_2btoul(uint8_t *bytes);
+static __inline uint32_t scsi_3btoul(uint8_t *bytes);
+static __inline int32_t	 scsi_3btol(uint8_t *bytes);
+static __inline uint32_t scsi_4btoul(uint8_t *bytes);
+
+static __inline void scsi_extract_sense(struct scsi_sense_data *sense,
+				       int *error_code, int *sense_key,
+				       int *asc, int *ascq)
+{
+	*error_code = sense->error_code & SSD_ERRCODE;
+	*sense_key = sense->flags & SSD_KEY;
+	*asc = (sense->extra_len >= 5) ? sense->add_sense_code : 0;
+	*ascq = (sense->extra_len >= 6) ? sense->add_sense_code_qual : 0;
+}
+
+static __inline void
+scsi_ulto2b(uint32_t val, uint8_t *bytes)
+{
+
+	bytes[0] = (val >> 8) & 0xff;
+	bytes[1] = val & 0xff;
+}
+
+static __inline void
+scsi_ulto3b(uint32_t val, uint8_t *bytes)
+{
+
+	bytes[0] = (val >> 16) & 0xff;
+	bytes[1] = (val >> 8) & 0xff;
+	bytes[2] = val & 0xff;
+}
+
+static __inline void
+scsi_ulto4b(uint32_t val, uint8_t *bytes)
+{
+
+	bytes[0] = (val >> 24) & 0xff;
+	bytes[1] = (val >> 16) & 0xff;
+	bytes[2] = (val >> 8) & 0xff;
+	bytes[3] = val & 0xff;
+}
+
+static __inline uint32_t
+scsi_2btoul(uint8_t *bytes)
+{
+	uint32_t rv;
+
+	rv = (bytes[0] << 8) |
+	     bytes[1];
+	return (rv);
+}
+
+static __inline uint32_t
+scsi_3btoul(uint8_t *bytes)
+{
+	uint32_t rv;
+
+	rv = (bytes[0] << 16) |
+	     (bytes[1] << 8) |
+	     bytes[2];
+	return (rv);
+}
+
+static __inline int32_t 
+scsi_3btol(uint8_t *bytes)
+{
+	uint32_t rc = scsi_3btoul(bytes);
+ 
+	if (rc & 0x00800000)
+		rc |= 0xff000000;
+
+	return (int32_t) rc;
+}
+
+static __inline uint32_t
+scsi_4btoul(uint8_t *bytes)
+{
+	uint32_t rv;
+
+	rv = (bytes[0] << 24) |
+	     (bytes[1] << 16) |
+	     (bytes[2] << 8) |
+	     bytes[3];
+	return (rv);
+}
+
+#endif /*_AICLIB_H */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/cam.h linux-2.4.22-pre2/drivers/scsi/aic7xxx/cam.h
--- linux-2.4.21/drivers/scsi/aic7xxx/cam.h	2001-10-25 20:53:49.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/cam.h	2003-06-26 21:43:21.000000000 +0000
@@ -29,13 +29,13 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/cam.h#11 $
+ * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/cam.h#15 $
  */
 
 #ifndef _AIC7XXX_CAM_H
 #define _AIC7XXX_CAM_H 1
 
-/* Provide a mapping from CAM constructs to Linux SCSI constructs */
+#include <linux/types.h>
 
 #define	CAM_BUS_WILDCARD ((u_int)~0)
 #define	CAM_TARGET_WILDCARD ((u_int)~0)
@@ -43,56 +43,34 @@
 
 /* CAM Status field values */
 typedef enum {
-	/* CCB request is in progress */
-	CAM_REQ_INPROG		= 0x3F, /* Some value unused by Linux */
-	/* CCB request completed without error */
-	CAM_REQ_CMP		= DID_OK,
-	/* CCB request aborted by the host */
-	CAM_REQ_ABORTED		= DID_ABORT,
-	/* Unable to abort CCB request */
-	CAM_UA_ABORT		= DID_ERROR,
-	/* CCB request completed with an error */
-	CAM_REQ_CMP_ERR		= DID_ERROR,
-	/* CAM subsytem is busy */
-	CAM_BUSY		= DID_BUS_BUSY,
-	/* CCB request was invalid */
-	CAM_REQ_INVALID		= DID_BAD_TARGET,
-	/* Supplied Path ID is invalid */
-	CAM_PATH_INVALID	= DID_BAD_TARGET,
-	/* Target Selection Timeout */
-	CAM_SEL_TIMEOUT		= DID_NO_CONNECT,
-	/* Command timeout */
-	CAM_CMD_TIMEOUT		= DID_ERROR, /*
-					      * Should never occur in Linux
-					      * as the upper level code
-					      * handles all timeout processing.
-					      */
-	/* SCSI error, look at error code in CCB */
-	CAM_SCSI_STATUS_ERROR	= DID_OK, /* Linux looks at status byte */
-	/* SCSI Bus Reset Sent/Received */
-	CAM_SCSI_BUS_RESET	= DID_RESET,
-	/* Uncorrectable parity error occurred */
-	CAM_UNCOR_PARITY	= DID_PARITY,
-	/* Autosense: request sense cmd fail */
-	CAM_AUTOSENSE_FAIL	= DID_ERROR,
-	/* No HBA Detected Error */
-	CAM_NO_HBA		= DID_ERROR,
-	/* Data Overrun error */
-	CAM_DATA_RUN_ERR	= DID_ERROR,
-	/* Unexpected Bus Free */
-	CAM_UNEXP_BUSFREE	= DID_ERROR,
-	/* CCB length supplied is inadequate */
-	CAM_CCB_LEN_ERR		= DID_ERROR,
-	/* Unable to provide requested capability */
-	CAM_PROVIDE_FAIL	= DID_ERROR,
-	/* A SCSI BDR msg was sent to target */
-	CAM_BDR_SENT		= DID_RESET,
-	/* CCB request terminated by the host */
-	CAM_REQ_TERMIO		= DID_ERROR,
-	/* Unrecoverable Host Bus Adapter Error */
-	CAM_UNREC_HBA_ERROR	= DID_ERROR,
-	/* The request was too large for this host */
-	CAM_REQ_TOO_BIG		= DID_ERROR,
+	CAM_REQ_INPROG,		/* CCB request is in progress */
+	CAM_REQ_CMP,		/* CCB request completed without error */
+	CAM_REQ_ABORTED,	/* CCB request aborted by the host */
+	CAM_UA_ABORT,		/* Unable to abort CCB request */
+	CAM_REQ_CMP_ERR,	/* CCB request completed with an error */
+	CAM_BUSY,		/* CAM subsytem is busy */
+	CAM_REQ_INVALID,	/* CCB request was invalid */
+	CAM_PATH_INVALID,	/* Supplied Path ID is invalid */
+	CAM_SEL_TIMEOUT,	/* Target Selection Timeout */
+	CAM_CMD_TIMEOUT,	/* Command timeout */
+	CAM_SCSI_STATUS_ERROR,	/* SCSI error, look at error code in CCB */
+	CAM_SCSI_BUS_RESET,	/* SCSI Bus Reset Sent/Received */
+	CAM_UNCOR_PARITY,	/* Uncorrectable parity error occurred */
+	CAM_AUTOSENSE_FAIL,	/* Autosense: request sense cmd fail */
+	CAM_NO_HBA,		/* No HBA Detected Error */
+	CAM_DATA_RUN_ERR,	/* Data Overrun error */
+	CAM_UNEXP_BUSFREE,	/* Unexpected Bus Free */
+	CAM_SEQUENCE_FAIL,	/* Protocol Violation */
+	CAM_CCB_LEN_ERR,	/* CCB length supplied is inadequate */
+	CAM_PROVIDE_FAIL,	/* Unable to provide requested capability */
+	CAM_BDR_SENT,		/* A SCSI BDR msg was sent to target */
+	CAM_REQ_TERMIO,		/* CCB request terminated by the host */
+	CAM_UNREC_HBA_ERROR,	/* Unrecoverable Host Bus Adapter Error */
+	CAM_REQ_TOO_BIG,	/* The request was too large for this host */
+	CAM_UA_TERMIO,		/* Unable to terminate I/O CCB request */
+	CAM_MSG_REJECT_REC,	/* Message Reject Received */
+	CAM_DEV_NOT_THERE,	/* SCSI Device Not Installed/there */
+	CAM_RESRC_UNAVAIL,	/* Resource Unavailable */
 	/*
 	 * This request should be requeued to preserve
 	 * transaction ordering.  This typically occurs
@@ -101,7 +79,8 @@
 	 * requests for the target at the sim level
 	 * back into the XPT queue.
 	 */
-	CAM_REQUEUE_REQ		= DID_BUS_BUSY,
+	CAM_REQUEUE_REQ,
+	CAM_DEV_QFRZN		= 0x40,
 
 	CAM_STATUS_MASK		= 0x3F
 } cam_status;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/aic7xxx/scsi_iu.h linux-2.4.22-pre2/drivers/scsi/aic7xxx/scsi_iu.h
--- linux-2.4.21/drivers/scsi/aic7xxx/scsi_iu.h	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/aic7xxx/scsi_iu.h	2003-06-26 21:43:21.000000000 +0000
@@ -28,4 +28,12 @@
     (12 + (((siu)->flags & SIU_RSPVALID)		\
 	? scsi_4btoul((siu)->pkt_failures_length)	\
 	: 0))
+
+#define	SIU_TASKMGMT_NONE		0x00
+#define	SIU_TASKMGMT_ABORT_TASK		0x01
+#define	SIU_TASKMGMT_ABORT_TASK_SET	0x02
+#define	SIU_TASKMGMT_CLEAR_TASK_SET	0x04
+#define	SIU_TASKMGMT_LUN_RESET		0x08
+#define	SIU_TASKMGMT_TARGET_RESET	0x20
+#define	SIU_TASKMGMT_CLEAR_ACA		0x40
 #endif /*_SCSI_SCSI_IU_H*/
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/scsi.h linux-2.4.22-pre2/drivers/scsi/scsi.h
--- linux-2.4.21/drivers/scsi/scsi.h	2002-11-28 23:53:14.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/scsi.h	2003-06-26 21:43:14.000000000 +0000
@@ -608,6 +608,7 @@
 	unsigned remap:1;	/* support remapping  */
 	unsigned starved:1;	/* unable to process commands because
 				   host busy */
+	unsigned no_start_on_add:1;	/* do not issue start on add */
 
 	// Flag to allow revalidate to succeed in sd_open
 	int allow_revalidate;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/scsi_scan.c linux-2.4.22-pre2/drivers/scsi/scsi_scan.c
--- linux-2.4.21/drivers/scsi/scsi_scan.c	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/scsi_scan.c	2003-06-26 21:43:30.000000000 +0000
@@ -37,6 +37,8 @@
 #define BLIST_ISDISK    	0x100	/* Treat as (removable) disk */
 #define BLIST_ISROM     	0x200	/* Treat as (removable) CD-ROM */
 #define BLIST_LARGELUN		0x400	/* LUNs larger than 7 despite reporting as SCSI 2 */
+#define BLIST_NOSTARTONADD	0x1000	/* do not do automatic start on add */
+
 
 static void print_inquiry(unsigned char *data);
 static int scan_scsis_single(unsigned int channel, unsigned int dev,
@@ -145,7 +147,7 @@
 	{"EMULEX", "MD21/S2     ESDI", "*", BLIST_SINGLELUN},
 	{"CANON", "IPUBJD", "*", BLIST_SPARSELUN},
 	{"nCipher", "Fastness Crypto", "*", BLIST_FORCELUN},
-	{"DEC","HSG80","*", BLIST_FORCELUN},
+	{"DEC","HSG80","*", BLIST_FORCELUN | BLIST_NOSTARTONADD},
 	{"COMPAQ","LOGICAL VOLUME","*", BLIST_FORCELUN},
 	{"COMPAQ","CR3500","*", BLIST_FORCELUN},
 	{"NEC", "PD-1 ODX654P", "*", BLIST_FORCELUN | BLIST_SINGLELUN},
@@ -173,7 +175,10 @@
 	{"HP", "NetRAID-4M", "*", BLIST_FORCELUN},
 	{"ADAPTEC", "AACRAID", "*", BLIST_FORCELUN},
 	{"ADAPTEC", "Adaptec 5400S", "*", BLIST_FORCELUN},
-	{"COMPAQ", "MSA1000", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
+	{"COMPAQ", "MSA1000", "*", BLIST_SPARSELUN | BLIST_LARGELUN | BLIST_NOSTARTONADD},
+	{"COMPAQ", "MSA1000 VOLUME", "*", BLIST_SPARSELUN | BLIST_LARGELUN | BLIST_NOSTARTONADD},
+	{"COMPAQ", "HSV110", "*", BLIST_SPARSELUN | BLIST_LARGELUN | BLIST_NOSTARTONADD},
+	{"HP", "HSV100", "*", BLIST_SPARSELUN | BLIST_LARGELUN | BLIST_NOSTARTONADD},
 	{"HP", "C1557A", "*", BLIST_FORCELUN},
 	{"IBM", "AuSaV1S2", "*", BLIST_FORCELUN},
 	{"FSC", "CentricStor", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
@@ -194,6 +199,7 @@
 	{"SGI", "TP9400", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
 	{"SGI", "TP9500", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
 	{"MYLEX", "DACARMRB", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
+	{"XYRATEX", "RS", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
 
 	/*
 	 * Must be at end of list...
@@ -742,6 +748,13 @@
 	if ((bflags & BLIST_BORKEN) == 0)
 		SDpnt->borken = 0;
 
+ 	/*
+	 * Some devices may not want to have a start command automatically
+	 * issued when a device is added.
+	 */
+	if (bflags & BLIST_NOSTARTONADD)
+		SDpnt->no_start_on_add = 1;
+
 	/*
 	 * If we want to only allow I/O to one of the luns attached to this device
 	 * at a time, then we set this flag.
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/sd.c linux-2.4.22-pre2/drivers/scsi/sd.c
--- linux-2.4.21/drivers/scsi/sd.c	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/sd.c	2003-06-26 21:43:30.000000000 +0000
@@ -774,7 +774,8 @@
 	char nbuff[6];
 	unsigned char *buffer;
 	unsigned long spintime_value = 0;
-	int the_result, retries, spintime;
+	int retries, spintime;
+	unsigned int the_result;
 	int sector_size;
 	Scsi_Request *SRpnt;
 
@@ -816,7 +817,7 @@
 	do {
 		retries = 0;
 
-		while (retries < 3) {
+		do {
 			cmd[0] = TEST_UNIT_READY;
 			cmd[1] = (rscsi_disks[i].device->scsi_level <= SCSI_2) ?
 				 ((rscsi_disks[i].device->lun << 5) & 0xe0) : 0;
@@ -831,10 +832,10 @@
 
 			the_result = SRpnt->sr_result;
 			retries++;
-			if (the_result == 0
-			    || SRpnt->sr_sense_buffer[2] != UNIT_ATTENTION)
-				break;
-		}
+		} while (retries < 3
+			 && (the_result !=0
+			     || ((driver_byte(the_result) & DRIVER_SENSE)
+				 && SRpnt->sr_sense_buffer[2] == UNIT_ATTENTION)));
 
 		/*
 		 * If the drive has indicated to us that it doesn't have
@@ -852,10 +853,33 @@
 			break;
 		}
 
+		if ((driver_byte(the_result) & DRIVER_SENSE) == 0) {
+			/* no sense, TUR either succeeded or failed
+			 * with a status error */
+			if(!spintime && the_result != 0)
+				printk(KERN_NOTICE "%s: Unit Not Ready, error = 0x%x\n", nbuff, the_result);
+			break;
+		}
+
+		/*
+		 * The device does not want the automatic start to be issued.
+		 */
+		if (rscsi_disks[i].device->no_start_on_add) {
+			break;
+		}
+
+		/*
+		 * If manual intervention is required, or this is an
+		 * absent USB storage device, a spinup is meaningless.
+		 */
+		if (SRpnt->sr_sense_buffer[2] == NOT_READY &&
+		    SRpnt->sr_sense_buffer[12] == 4 /* not ready */ &&
+		    SRpnt->sr_sense_buffer[13] == 3) {
+			break;		/* manual intervention required */
 		/* Look for non-removable devices that return NOT_READY.
 		 * Issue command to spin up drive for these cases. */
-		if (the_result && !rscsi_disks[i].device->removable &&
-		    SRpnt->sr_sense_buffer[2] == NOT_READY) {
+		} else if (the_result && !rscsi_disks[i].device->removable &&
+			   SRpnt->sr_sense_buffer[2] == NOT_READY) {
 			unsigned long time1;
 			if (!spintime) {
 				printk("%s: Spinning up disk...", nbuff);
@@ -869,7 +893,7 @@
 				SRpnt->sr_sense_buffer[0] = 0;
 				SRpnt->sr_sense_buffer[2] = 0;
 
-				SRpnt->sr_data_direction = SCSI_DATA_READ;
+				SRpnt->sr_data_direction = SCSI_DATA_NONE;
 				scsi_wait_req(SRpnt, (void *) cmd, (void *) buffer,
 					    0/*512*/, SD_TIMEOUT, MAX_RETRIES);
 				spintime_value = jiffies;
@@ -882,6 +906,14 @@
 				time1 = schedule_timeout(time1);
 			} while(time1);
 			printk(".");
+		} else {
+			/* we don't understand the sense code, so it's
+			 * probably pointless to loop */
+			if(!spintime) {
+				printk(KERN_NOTICE "%s: Unit Not Ready, sense:\n", nbuff);
+				print_req_sense("", SRpnt);
+			}
+			break;
 		}
 	} while (the_result && spintime &&
 		 time_after(spintime_value + 100 * HZ, jiffies));
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/scsi/sym53c8xx_2/sym_hipd.c linux-2.4.22-pre2/drivers/scsi/sym53c8xx_2/sym_hipd.c
--- linux-2.4.21/drivers/scsi/sym53c8xx_2/sym_hipd.c	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/scsi/sym53c8xx_2/sym_hipd.c	2003-06-26 21:43:10.000000000 +0000
@@ -4641,7 +4641,10 @@
 		case M_IGN_RESIDUE:
 			if (DEBUG_FLAGS & DEBUG_POINTER)
 				sym_print_msg(cp,"ign wide residue", np->msgin);
-			sym_modify_dp(np, tp, cp, -1);
+			if (cp->host_flags & HF_SENSE)
+				OUTL_DSP (SCRIPTA_BA (np, clrack));
+			else
+				sym_modify_dp(np, tp, cp, -1);
 			return;
 		case M_REJECT:
 			if (INB (HS_PRT) == HS_NEGOTIATE)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/sgi/char/ds1286.c linux-2.4.22-pre2/drivers/sgi/char/ds1286.c
--- linux-2.4.21/drivers/sgi/char/ds1286.c	2002-11-28 23:53:14.000000000 +0000
+++ linux-2.4.22-pre2/drivers/sgi/char/ds1286.c	2003-06-26 21:43:17.000000000 +0000
@@ -298,9 +298,7 @@
 int __init ds1286_init(void)
 {
 	printk(KERN_INFO "DS1286 Real Time Clock Driver v%s\n", DS1286_VERSION);
-	misc_register(&ds1286_dev);
-
-	return 0;
+	return misc_register(&ds1286_dev);
 }
 
 static char *days[] = {
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/CDCEther.c linux-2.4.22-pre2/drivers/usb/CDCEther.c
--- linux-2.4.21/drivers/usb/CDCEther.c	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/CDCEther.c	2003-06-26 21:43:11.000000000 +0000
@@ -37,6 +37,7 @@
 #define SHORT_DRIVER_DESC "CDC Ethernet Class"
 #define DRIVER_VERSION "0.98.6"
 
+static const char driver_name[] = "CDCEther";
 static const char *version = __FILE__ ": " DRIVER_VERSION " 7 Jan 2002 Brad Hards and another";
 // We only try to claim CDC Ethernet model devices */
 static struct usb_device_id CDCEther_ids[] = {
@@ -460,7 +461,7 @@
 	/* get driver info */
 	case ETHTOOL_GDRVINFO: {
 	struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
-		strncpy(info.driver, SHORT_DRIVER_DESC, ETHTOOL_BUSINFO_LEN);
+		strncpy(info.driver, driver_name, ETHTOOL_BUSINFO_LEN);
 		strncpy(info.version, DRIVER_VERSION, ETHTOOL_BUSINFO_LEN);
 		sprintf(tmp, "usb%d:%d", ether_dev->usb->bus->busnum, ether_dev->usb->devnum);
 		strncpy(info.bus_info, tmp, ETHTOOL_BUSINFO_LEN);
@@ -1421,7 +1422,7 @@
 //////////////////////////////////////////////////////////////////////////////
 
 static struct usb_driver CDCEther_driver = {
-	name:		"CDCEther",
+	name:		driver_name,
 	probe:		CDCEther_probe,
 	disconnect:	CDCEther_disconnect,
 	id_table:	CDCEther_ids,
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/Config.in linux-2.4.22-pre2/drivers/usb/Config.in
--- linux-2.4.21/drivers/usb/Config.in	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/Config.in	2003-06-26 21:43:18.000000000 +0000
@@ -91,6 +91,7 @@
       dep_tristate '  USB Realtek RTL8150 based ethernet device support (EXPERIMENTAL)' CONFIG_USB_RTL8150 $CONFIG_USB $CONFIG_NET $CONFIG_EXPERIMENTAL
       dep_tristate '  USB KLSI KL5USB101-based ethernet device support (EXPERIMENTAL)' CONFIG_USB_KAWETH $CONFIG_USB $CONFIG_NET $CONFIG_EXPERIMENTAL
       dep_tristate '  USB CATC NetMate-based Ethernet device support (EXPERIMENTAL)' CONFIG_USB_CATC $CONFIG_USB $CONFIG_NET $CONFIG_EXPERIMENTAL
+      dep_tristate '  USB ASIX AX88172 based ethernet device support (EXPERIMENTAL)' CONFIG_USB_AX8817X $CONFIG_USB $CONFIG_NET $CONFIG_EXPERIMENTAL
       dep_tristate '  USB Communication Class Ethernet device support (EXPERIMENTAL)' CONFIG_USB_CDCETHER $CONFIG_USB $CONFIG_NET $CONFIG_EXPERIMENTAL
       dep_tristate '  USB-to-USB Networking cables, Linux PDAs, ... (EXPERIMENTAL)' CONFIG_USB_USBNET $CONFIG_USB $CONFIG_NET $CONFIG_EXPERIMENTAL
    fi
@@ -105,5 +106,6 @@
    dep_tristate '  Texas Instruments Graph Link USB (aka SilverLink) cable support' CONFIG_USB_TIGL $CONFIG_USB
    dep_tristate '  Tieman Voyager USB Braille display support (EXPERIMENTAL)' CONFIG_USB_BRLVGER $CONFIG_USB $CONFIG_EXPERIMENTAL
    dep_tristate '  USB LCD device support' CONFIG_USB_LCD $CONFIG_USB
+   dep_tristate '  Alcatel Speedtouch USB support' CONFIG_USB_SPEEDTOUCH $CONFIG_ATM $CONFIG_USB
 fi
 endmenu
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/Makefile linux-2.4.22-pre2/drivers/usb/Makefile
--- linux-2.4.21/drivers/usb/Makefile	2003-06-26 21:45:10.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/Makefile	2003-06-26 21:43:18.000000000 +0000
@@ -19,6 +19,7 @@
 hid-objs		:= hid-core.o
 pwc-objs		:= pwc-if.o pwc-misc.o pwc-ctrl.o pwc-uncompress.o
 auerswald-objs		:= auerbuf.o auerchain.o auerchar.o auermain.o
+speedtch-objs		:= speedcrc.o speedtouch.o
 
 # Optional parts of multipart objects.
 
@@ -106,6 +107,7 @@
 obj-$(CONFIG_USB_RTL8150)	+= rtl8150.o
 obj-$(CONFIG_USB_CATC)		+= catc.o
 obj-$(CONFIG_USB_KAWETH)        += kaweth.o
+obj-$(CONFIG_USB_AX8817X)	+= ax8817x.o
 obj-$(CONFIG_USB_CDCETHER)	+= CDCEther.o
 obj-$(CONFIG_USB_RIO500)	+= rio500.o
 obj-$(CONFIG_USB_TIGL)          += tiglusb.o
@@ -117,6 +119,7 @@
 obj-$(CONFIG_USB_AUERSWALD)	+= auerswald.o
 obj-$(CONFIG_USB_BRLVGER)	+= brlvger.o
 obj-$(CONFIG_USB_LCD)		+= usblcd.o
+obj-$(CONFIG_USB_SPEEDTOUCH)	+= speedtch.o
 
 # Object files in subdirectories
 mod-subdirs	:= serial host
@@ -147,3 +150,6 @@
 
 auerswald.o: $(auerswald-objs)
 	$(LD) -r -o $@ $(auerswald-objs)
+
+speedtch.o: $(speedtch-objs)
+	$(LD) -r -o $@ $(speedtch-objs)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/Makefile.lib linux-2.4.22-pre2/drivers/usb/Makefile.lib
--- linux-2.4.21/drivers/usb/Makefile.lib	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/Makefile.lib	2003-06-26 21:43:10.000000000 +0000
@@ -0,0 +1,3 @@
+obj-$(CONFIG_USB_USBNET)		+= crc32.o
+obj-$(CONFIG_USB_CATC)			+= crc32.o
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/aiptek.c linux-2.4.22-pre2/drivers/usb/aiptek.c
--- linux-2.4.21/drivers/usb/aiptek.c	2002-11-28 23:53:14.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/aiptek.c	2003-06-26 21:43:13.000000000 +0000
@@ -1,7 +1,9 @@
 /*
- *  Native support for the Aiptek 8000U
+ *  Native support for the Aiptek HyperPen USB Tablets
+ *  (4000U/5000U/6000U/8000U/12000U)
  *
- *  Copyright (c) 2001 Chris Atenasio		<chris@crud.net>
+ *  Copyright (c) 2001      Chris Atenasio   <chris@crud.net>
+ *  Copyright (c) 2002-2003 Bryan W. Headley <bwheadley@earthlink.net>
  *
  *  based on wacom.c by
  *     Vojtech Pavlik      <vojtech@suse.cz>
@@ -11,13 +13,28 @@
  *     James E. Blair      <corvus@gnu.org>
  *     Daniel Egger        <egger@suse.de>
  *
- *
  *  Many thanks to Oliver Kuechemann for his support.
  *
  *  ChangeLog:
  *      v0.1 - Initial release
- *      v0.2 - Hack to get around fake event 28's.
+ *      v0.2 - Hack to get around fake event 28's. (Bryan W. Headley)
  *      v0.3 - Make URB dynamic (Bryan W. Headley, Jun-8-2002)
+ *             Released to Linux 2.4.19 and 2.5.x
+ *      v0.4 - Rewrote substantial portions of the code to deal with
+ *             corrected control sequences, timing, dynamic configuration,
+ *             support of 6000U - 12000U, procfs, and macro key support
+ *             (Jan-1-2003 - Feb-5-2003, Bryan W. Headley)
+ *      v1.0 - Added support for diagnostic messages, count of messages
+ *             received from URB - Mar-8-2003, Bryan W. Headley
+ *
+ * NOTE:
+ *      This kernel driver is augmented by the "Aiptek" XFree86 input
+ *      driver for your X server, as well as a GUI Front-end "Tablet Manager".
+ *      These three products are highly interactive with one another, 
+ *      so therefore it's easier to document them all as one subsystem.
+ *      Please visit the project's "home page", located at, 
+ *      http://aiptektablet.sourceforge.net.
+ *
  */
 
 /*
@@ -42,13 +59,15 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/usb.h>
+#include <linux/proc_fs.h>
+#include <asm/uaccess.h>
 
 /*
  * Version Information
  */
-#define DRIVER_VERSION "v0.3"
-#define DRIVER_AUTHOR "Chris Atenasio <chris@crud.net>"
-#define DRIVER_DESC "USB Aiptek 6000U/8000U tablet driver (Linux 2.4.x)"
+#define DRIVER_VERSION "v1.0 Mar-8-2003"
+#define DRIVER_AUTHOR  "Bryan W. Headley/Chris Atenasio"
+#define DRIVER_DESC    "Aiptek HyperPen USB Tablet Driver (Linux 2.4.x)"
 
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
@@ -56,6 +75,7 @@
 
 /*
  * Aiptek status packet:
+ * (returned as Report 1)
  *
  *        bit7  bit6  bit5  bit4  bit3  bit2  bit1  bit0
  * byte0   0     0     0     0     0     0     1     0
@@ -69,10 +89,14 @@
  *
  * IR: In Range = Proximity on
  * DV = Data Valid
+ * BS = Barrel Switch (as in, macro keys)
+ * BS2 also referred to as Tablet Pick
  *
- * 
  * Command Summary:
  *
+ * Use report_type CONTROL (3)
+ * Use report_id   2
+ *
  * Command/Data    Description     Return Bytes    Return Value
  * 0x10/0x00       SwitchToMouse       0
  * 0x10/0x01       SwitchToTablet      0
@@ -85,30 +109,278 @@
  * 0x03/0x00       GetODMCode          2           ODMCode
  * 0x08/0x00       GetPressureLevels   2           =512
  * 0x04/0x00       GetFirmwareVersion  2           Firmware Version
+ * 0x11/0x02       EnableMacroKeys     0
  *
  *
  * To initialize the tablet:
  *
- * (1) Send command Resolution500LPI
- * (2) Option Commands (GetXExtension, GetYExtension)
- * (3) Send command SwitchToTablet
+ * (1) Send Resolution500LPI (Command)
+ * (2) Query for Model code (Option Report)
+ * (3) Query for ODM code (Option Report)
+ * (4) Query for firmware (Option Report)
+ * (5) Query for GetXExtension (Option Report)
+ * (6) Query for GetYExtension (Option Report)
+ * (7) Query for GetPressureLevels (Option Report)
+ * (8) SwitchToTablet for Absolute coordinates, or
+ *     SwitchToMouse for Relative coordinates (Command)
+ * (9) EnableMacroKeys (Command)
+ * (10) FilterOn (Command)
+ * (11) AutoGainOn (Command)
+ *
+ * (Step 9 can be omitted, but you'll then have no function keys.)
+ *
+ *  The procfs interface
+ *  --------------------
+ *
+ *  This driver supports delivering configuration/status reports
+ *  through {procfs}/driver/usb/aiptek. ("procfs" is normally mounted
+ *  to /proc.) Said file can be found while the driver is active in
+ *  memory; it will be removed when the driver is removed, either 
+ *  through user intervention (rmmod aiptek) or through software
+ *  such as "hotplug".
+ *
+ *  Reading from the Procfs interface
+ *  ---------------------------------
+ *
+ *  The user may determine the status of the tablet by reading the
+ *  report in the procfs interface, /proc/driver/usb/aiptek.
+ *  The report as of driver version 1.0, looks like,
+ *
+ * Aiptek Tablet (3000x2250, 8.00x6.00", 202x152mm)
+ * (USB VendorID 0x08ca, ProductID 0x0020, ODMCode 0x0004
+ *  ModelCode: 0x64, FirmwareCode: 0x0400)
+ * on /dev/input/event0
+ * pointer=either
+ * coordinate=absolute
+ * tool=pen
+ * xtilt=disable
+ * ytilt=disable
+ * jitter=50
+ * diagnostic=none
+ * eventsReceived=0
+ *
+ *  (spurious ", for the benefit of vim's syntax highlighting.)
+ *
+ *  This report indicates the tablet recognized. (Because Aiptek reuses
+ *  the USB 'productID' over several tablets, it's pointless for us to
+ *  guess which model you have: we'll instead tell you the size of
+ *  the tablet's drawing area, which we indicate in coordinates, inches,
+ *  and millimeters.) We also indicate datum read from the USB interface,
+ *  such as vendorId, productId, ODMcode, etc. It's there "just in case."
+ *
+ *      on /dev/input/event0
+ *
+ *  Linux supports HID-compliant USB devices (such as this tablet) by
+ *  transposing their reports to the Linux Input Event System format. Which
+ *  means, if you want to data from the tablet, that's where it will be
+ *  made available from. For information on the Input Event System, see
+ *  the docs in ./Documentation/input, in the kernel source tree.
+ *
+ *  And yes, depending on the order in which other supported Input Event
+ *  devices are recognized and configured, the tablet may be allocated
+ *  to a different device driver name: it's all dynamic. Use of the devfs
+ *  file system is a help.
+ *
+ *  The keyword=value part of the report mostly shows what the programmable
+ *  parameters have been set to. We describe those below, and how to
+ *  program/reprogram them. Note: tablet parameters are to be programmed
+ *  while the tablet is attached and active. They are not set as arguments
+ *  to the kernel during bootup.
+ *
+ *  Here are the "read-only" parameters, and what they mean:
+ *
+ *      diagnostic=stringValue
+ *      eventsReceived=numericValue
+ *
+ * diagnostic: The tablet driver attempts to explain why things are not
+ *      working correctly. (To the best of it's insular abilities)
+ *
+ *      By default, the tablet boots up in Relative Coordinate
+ *      mode. This driver initially attempts to program it in Absolute
+ *      Coordinate mode (and of course, the user can subsequently choose
+ *      which mode they want.) So, therefore, the situation can arise
+ *      where the tablet is in one mode, and the driver believes it
+ *      is in the other mode. The driver, however, cannot divine
+ *      this mismatch until input events are received.  
+ *      Two reports indicate such mode-mismatches between the tablet
+ *      and the driver, and are,
+ *
+ *          "tablet sending relative reports"
+ *          "tablet sending absolute reports"
+ *
+ *      The next diagnostic operates in conjunction with the "pointer="
+ *      programmable parameter. With it, you can indicate that you want
+ *      the tablet to only accept reports from the stylus, or only from the 
+ *      mouse. (You can also specify to allow reports from either.) What
+ *      happens when you specify that you only want mouse reports, yet
+ *      the tablet keeps receiving reports from the stylus? Well, first,
+ *      it's a "pilot error", but secondly, it tries to diagnose the issue
+ *      with the following reports,
+ *
+ *          "tablet seeing reports from stylus"
+ *          "tablet seeing reports from mouse"
+ *
+ *      What if there is nothing to report? The inference in the diagnostic
+ *      reports is that something is happening which shouldn't: when things
+ *      appear to be working right, the report is,
+ *
+ *          "none"
+ *
+ *      The error diagnostic report is dynamic: it only reports issues
+ *      that are happening, or have happened as of the last event received.
+ *      It will reset following any attempt to reprogram the tablet's mode.
+ *
+ * eventsReceived: Occasionally, your movements on the tablet are not being
+ *      reported. Usually, this indicates that your tablet is out of sync
+ *      with the USB interface driver, or itself is not sending reports
+ *      out. To help diagnose this, we keep an active count of events
+ *      received from the tablet. So, if you move the stylus, and yet 
+ *      your client application doesn't notice, make
+ *      note of the eventsReceived, and then move the stylus again. If the
+ *      event counter's number doesn't change, then the tablet indeed has
+ *      "froze". 
+ *
+ *      We have found that sending the tablet a command sequence often
+ *      will clear up "frozen" tablets. Which segues into the section
+ *      about how to program your tablet through the procfs interface,
+ *
+ *  Writing to the procfs interface
+ *  -------------------------------
+ *
+ *  The user may configure the tablet by writing ASCII
+ *  commands to the /proc/driver/usb/aiptek file. Commands which are
+ *  accepted are,
+ *
+ *      pointer=stringvalue      {stylus|mouse|either}
+ *      coordinate=stringvalue   {absolute|relative}
+ *      tool=stringvalue         {mouse|rubber|pen|pencil|brush|airbrush}
+ *      xtilt=string_or_numeric  {disable|[-128..127]}
+ *      ytilt=string_or_numeric  {disable|[-128..127]}
+ *      jitter=numericvalue      {0..xxx}
+ *
+ *  pointer: you can specify that reports are to be excepted ONLY from the
+ *      stylus, or ONLY from the mouse. 'either' allows reports from either
+ *      device to be accepted, and is the default.
+ *  coordinate: you can specify that either absolute or relative coordinate
+ *      reports are issued by the tablet. By default, absolute reports are
+ *      sent.
+ *  tool: The stylus by default prepends TOOL_BTN_PEN events with it's
+ *      reports. But you may decide that you want your stylus to behave
+ *      like an eraser (named 'rubber', following tablet conventions,)
+ *      or a pencil, etc. The behavior is dependent upon the client software
+ *      consuming the tablet's events, e.g., the XFree86 tablet driver.
+ *  xtilt: By default this is disabled. However, other tablets have a notion
+ *      of measuring the angle at which the stylus pen is held against the
+ *      drawing surface, along the X axis. Aiptek tablets cannot sense this,
+ *      but if you want to send "held-at-angle" reports, specify the value,
+ *      an integer between -128 and 127 (inclusive) that you want to send.
+ *      This data will be sent along with regular tablet input. Obviously,
+ *      the inference here is that your hand does not change angles 
+ *      while drawing (until you go back to this procfs interface, and
+ *      change the value)!
+ *
+ *      When you consider actual drawing tools (real pens, brushes),
+ *      knowing the tools' tip shape and the angle that you hold the tool 
+ *      becomes important, insofar as calculating the surface of the tip 
+ *      that actually touches the surface of the paper. Knowledge of what 
+ *      to do with xtilt reports is solely in the realm of your client 
+ *      software.
+ *
+ *      Yes, there is a difference between xtilt=0 and xtilt=disable
+ *      settings. The former sends a report that the angle is a 0;
+ *      the other indicates that NO xtilt reports are to be sent at all.
+ *  ytilt: By default this is disabled. This provides similar functionality
+ *      to xtilt, except that we're measuring the angle the stylus pen is
+ *      held against the drawing surface, along the Y axis. Same cavaets
+ *      apply as for xtilt.
+ *  jitter: By default, this is set to 50. When pressing a button on
+ *      either the mouse or the stylus pen, you will probably notice that
+ *      the tool moves slightly from it's original position, until your
+ *      hand steadies it. During that period of time, the pen is "jittering",
+ *      sending spurious movement events that perhaps you'd like it not to
+ *      send. What we do is set a moratorium, measured in milliseconds,
+ *      during which we do not send movement events. So, the default is 50ms;
+ *      you obviously can set it to zero or incredibly unreasonable values
+ *      (no reports for 4 seconds following the pressing of a stylus button!)
+ *
+ * Interesting Side-Note
+ * ---------------------
+ *
+ *  The tablet has "frozen" and you'd like to send it a command to wake it
+ *  up. But you don't want to change how the driver's currently configured.
+ *
+ *  1. Send a command to /proc/driver/usb/aiptek with the same setting
+ *     already reported by the driver.
+ *  2. Send an illegal string to procfs file ("wakeup=now" is always good)
+ *  3. Because, the driver always attempts to reprogram the tablet to it's
+ *     current settings following a write to the procfs interface.
+ *
+ *  Hmm, still does not work.
+ *  -------------------------
+ *
+ *  This is slightly harder to diagnose. You may be receiving frame errors
+ *  from the USB interface driver (see /var/log/messages for any diagnostics).
+ *
+ *  Alternatively, you may be running something like 'hotplug' that attempts
+ *  to match discovered USB devices to it's list of device drivers. 
+ *  Unfortunately, because this is a tablet that can send relative X,Y events,
+ *  it "looks like" a mouse! A usb mouse driver may have possession of
+ *  input from the tablet. On the other hand, the tablet also supports 
+ *  absolute reports from barrel switches, which sounds a lot like a "joystick",
+ *  and the software again can be fooled into loading the wrong driver for
+ *  the tablet. The distinction is, USB HID devices tell you what they
+ *  are capable of, rather than what they are.
+ *
+ *  Come visit this driver's home page at http://aiptektablet.sourceforge.net
+ *  for further assistance.
  */
 
 #define USB_VENDOR_ID_AIPTEK   0x08ca
 
+#define AIPTEK_POINTER_ONLY_MOUSE_MODE      0
+#define AIPTEK_POINTER_ONLY_STYLUS_MODE     1
+#define AIPTEK_POINTER_EITHER_MODE          2
+
+#define AIPTEK_POINTER_ALLOW_MOUSE_MODE(a) \
+        (a == AIPTEK_POINTER_ONLY_MOUSE_MODE || \
+         a == AIPTEK_POINTER_EITHER_MODE)
+#define AIPTEK_POINTER_ALLOW_STYLUS_MODE(a) \
+        (a == AIPTEK_POINTER_ONLY_STYLUS_MODE || \
+         a == AIPTEK_POINTER_EITHER_MODE)
+
+#define AIPTEK_COORDINATE_RELATIVE_MODE 0
+#define AIPTEK_COORDINATE_ABSOLUTE_MODE 1
+
+#define AIPTEK_TILT_MIN                      (-128)
+#define AIPTEK_TILT_MAX                      127
+#define AIPTEK_TILT_DISABLE                  (-10101)
+
+#define AIPTEK_TOOL_BUTTON_PEN_MODE          0
+#define AIPTEK_TOOL_BUTTON_PENCIL_MODE       1
+#define AIPTEK_TOOL_BUTTON_BRUSH_MODE        2
+#define AIPTEK_TOOL_BUTTON_AIRBRUSH_MODE     3
+#define AIPTEK_TOOL_BUTTON_RUBBER_MODE       4
+#define AIPTEK_TOOL_BUTTON_MOUSE_MODE        5
+
+#define AIPTEK_DIAGNOSTIC_NA                 0
+#define AIPTEK_DIAGNOSTIC_SENDING_RELATIVE_IN_ABSOLUTE  1
+#define AIPTEK_DIAGNOSTIC_SENDING_ABSOLUTE_IN_RELATIVE  2
+#define AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED               3
+
+    // Time to wait (in ms) to help mask hand jittering
+    // when pressing the stylus buttons.
+#define AIPTEK_JITTER_DELAY_DEFAULT         50
+
 struct aiptek_features {
 	char *name;
 	int pktlen;
 	int x_max;
 	int y_max;
-	int pressure_min;
 	int pressure_max;
+	int odmCode;
+	int modelCode;
+	int firmwareCode;
 	void (*irq) (struct urb * urb);
-	unsigned long evbit;
-	unsigned long absbit;
-	unsigned long relbit;
-	unsigned long btnbit;
-	unsigned long digibit;
 };
 
 struct aiptek {
@@ -117,59 +389,385 @@
 	struct usb_device *usbdev;
 	struct urb *irq;
 	struct aiptek_features *features;
-	int tool;
-	int open;
+	unsigned int ifnum;
+	int open_count;
+	int pointer_mode;
+	int coordinate_mode;
+	int tool_mode;
+	int xTilt;
+	int yTilt;
+	int diagnostic;
+	unsigned long eventCount;
+	int jitterDelay;
+#ifdef CONFIG_PROC_FS
+	struct proc_dir_entry *usbProcfsEntry;
+	struct proc_dir_entry *aiptekProcfsEntry;
+#endif
 };
 
+/*
+ * Permit easy lookup of keyboard events to send, versus
+ * the bitmap which comes from the tablet. This hides the
+ * issue that the F_keys are not sequentially numbered.
+ */
+static int macroKeyEvents[] = { KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6,
+	KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12,
+	KEY_F13, KEY_F14, KEY_F15, KEY_F16, KEY_F17, KEY_F18,
+	KEY_F19, KEY_F20, KEY_F21, KEY_F22, KEY_F23, KEY_F24,
+	KEY_STOP, KEY_AGAIN, KEY_PROPS, KEY_UNDO, KEY_FRONT, KEY_COPY,
+	KEY_OPEN, KEY_PASTE, 0
+};
+
+#ifdef CONFIG_PROC_FS
+extern struct proc_dir_entry *proc_root_driver;
+#endif
+
+static int
+aiptek_convert_from_2s_complement(unsigned char c)
+{
+	unsigned char b = c;
+	int negate = 0;
+	int ret;
+
+	if (b & 0x80) {
+		b = ~b;
+		b--;
+		negate = 1;
+	}
+	ret = b;
+	ret = (negate == 1) ? -ret : ret;
+	return ret;
+}
+
+/*
+ * aiptek_irq can receive one of six potential reports.
+ * The documentation for each is in the body of the function.
+ *
+ * The tablet reports on several attributes per invocation of
+ * aiptek_irq. Because the Linux Input Event system allows the
+ * transmission of ONE attribute per input_report_xxx() call,
+ * collation has to be done on the other end to reconstitute
+ * a complete tablet report. Further, the number of Input Event reports
+ * submitted varies, depending on what USB report type, and circumstance.
+ * To deal with this, EV_MSC is used to indicate an 'end-of-report'
+ * message. This has been an undocumented convention understood by the kernel
+ * tablet driver and clients such as gpm and XFree86's tablet drivers.
+ *
+ * Of the information received from the tablet, the one piece I
+ * cannot transmit is the proximity bit (without resorting to an EV_MSC
+ * convention above.) I therefore have taken over REL_MISC and ABS_MISC
+ * (for relative and absolute reports, respectively) for communicating
+ * Proximity. Why two events? I thought it interesting to know if the
+ * Proximity event occured while the tablet was in absolute or relative
+ * mode.
+ *
+ * Other tablets use the notion of a certain minimum stylus pressure
+ * to infer proximity. While that could have been done, that is yet
+ * another 'by convention' behavior, the documentation for which
+ * would be spread between two (or more) pieces of software.
+ *
+ * EV_MSC usage is terminated in Linux 2.5.x.
+ */
+
 static void
 aiptek_irq(struct urb *urb)
 {
 	struct aiptek *aiptek = urb->context;
 	unsigned char *data = aiptek->data;
 	struct input_dev *dev = &aiptek->dev;
-	int x;
-	int y;
-	int pressure;
-	int proximity;
+	int jitterable = 0;
 
 	if (urb->status)
 		return;
 
-	if ((data[0] & 2) == 0) {
-		dbg("received unknown report #%d", data[0]);
-	}
-
-	proximity = data[5] & 0x01;
-	input_report_key(dev, BTN_TOOL_PEN, proximity);
+	aiptek->eventCount++;
 
-	x = ((__u32) data[1]) | ((__u32) data[2] << 8);
-	y = ((__u32) data[3]) | ((__u32) data[4] << 8);
-	pressure = ((__u32) data[6]) | ((__u32) data[7] << 8);
-	pressure -= aiptek->features->pressure_min;
+	// Report 1 delivers relative coordinates with either a stylus
+	// or the mouse. You do not know which tool generated the event.
+	if (data[0] == 1) {
+		if (aiptek->coordinate_mode == AIPTEK_COORDINATE_ABSOLUTE_MODE) {
+			aiptek->diagnostic =
+			    AIPTEK_DIAGNOSTIC_SENDING_RELATIVE_IN_ABSOLUTE;
+		} else {
+			int x, y, left, right, middle;
+
+			if (aiptek->tool_mode != AIPTEK_TOOL_BUTTON_MOUSE_MODE) {
+				aiptek->tool_mode =
+				    AIPTEK_TOOL_BUTTON_MOUSE_MODE;
+				input_report_key(dev, BTN_TOOL_MOUSE, 1);
+			}
+			x = aiptek_convert_from_2s_complement(data[2]);
+			y = aiptek_convert_from_2s_complement(data[3]);
+
+			left = data[5] & 0x01;
+			right = data[5] & 0x02;
+			middle = data[5] & 0x04;
+
+			jitterable = left | right | middle;
+
+			input_report_key(dev, BTN_LEFT, left);
+			input_report_key(dev, BTN_MIDDLE, middle);
+			input_report_key(dev, BTN_RIGHT, right);
+			input_report_rel(dev, REL_X, x);
+			input_report_rel(dev, REL_Y, y);
+			input_report_rel(dev, REL_MISC, 1);
 
-	if (pressure < 0) {
-		pressure = 0;
+			input_event(dev, EV_MSC, MSC_SERIAL, 0);
+		}
 	}
-
-	if (proximity) {
-		input_report_abs(dev, ABS_X, x);
-		input_report_abs(dev, ABS_Y, y);
-		input_report_abs(dev, ABS_PRESSURE, pressure);
-		input_report_key(dev, BTN_TOUCH, data[5] & 0x04);
-		input_report_key(dev, BTN_STYLUS, data[5] & 0x08);
-		input_report_key(dev, BTN_STYLUS2, data[5] & 0x10);
+	// Report 2 is delivered only by the stylus, and delivers
+	// absolute coordinates.
+	else if (data[0] == 2) {
+		if (aiptek->coordinate_mode == AIPTEK_COORDINATE_RELATIVE_MODE) {
+			aiptek->diagnostic =
+			    AIPTEK_DIAGNOSTIC_SENDING_ABSOLUTE_IN_RELATIVE;
+		} else
+		    if (!AIPTEK_POINTER_ALLOW_STYLUS_MODE(aiptek->pointer_mode))
+		{
+			aiptek->diagnostic = AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED;
+		} else {
+			int x = ((__u32) data[1]) | ((__u32) data[2] << 8);
+			int y = ((__u32) data[3]) | ((__u32) data[4] << 8);
+			int z = ((__u32) data[6]) | ((__u32) data[7] << 8);
+
+			int p = data[5] & 0x01;
+			int dv = data[5] & 0x02;
+			int tip = data[5] & 0x04;
+			int bs = data[5] & 0x08;
+			int pck = data[5] & 0x10;
+
+			// dv indicates 'data valid' (e.g., the tablet is in sync
+			// and has delivered a "correct" report) We will ignore
+			// all 'bad' reports...
+			if (dv != 0) {
+				switch (aiptek->tool_mode) {
+				case AIPTEK_TOOL_BUTTON_PEN_MODE:
+					{
+						input_report_key(dev,
+								 BTN_TOOL_PEN,
+								 1);
+					}
+					break;
+
+				case AIPTEK_TOOL_BUTTON_PENCIL_MODE:
+					{
+						input_report_key(dev,
+								 BTN_TOOL_PENCIL,
+								 1);
+					}
+					break;
+
+				case AIPTEK_TOOL_BUTTON_BRUSH_MODE:
+					{
+						input_report_key(dev,
+								 BTN_TOOL_BRUSH,
+								 1);
+					}
+					break;
+
+				case AIPTEK_TOOL_BUTTON_AIRBRUSH_MODE:
+					{
+						input_report_key(dev,
+								 BTN_TOOL_AIRBRUSH,
+								 1);
+					}
+					break;
+
+				case AIPTEK_TOOL_BUTTON_RUBBER_MODE:
+					{
+						input_report_key(dev,
+								 BTN_TOOL_RUBBER,
+								 1);
+					}
+					break;
+
+				case AIPTEK_TOOL_BUTTON_MOUSE_MODE:
+					{
+						input_report_key(dev,
+								 BTN_TOOL_MOUSE,
+								 1);
+					}
+					break;
+				}
+
+				input_report_abs(dev, ABS_X, x);
+				input_report_abs(dev, ABS_Y, y);
+
+				/*
+				 * The user is allowed to switch from one of the
+				 * stylus tools to the Mouse using the front-end GUI.
+				 * An issue that will arise, however, is what happens
+				 * when the user HAS issued a TOOL_BTN_MOUSE, but has not
+				 * yet swapped tools. Well, we can "pretend" to be a mouse
+				 * by sending overriding tip, barrelswitch and pick.
+				 * This stupidity should not be used as an excuse not
+				 * to physically move your Aiptek mouse into the tablet's
+				 * active area -- it merely provides momentary convenience
+				 * during that transition.
+				 */
+				if (aiptek->tool_mode ==
+				    AIPTEK_TOOL_BUTTON_MOUSE_MODE) {
+					input_report_key(dev, BTN_LEFT, tip);
+					input_report_key(dev, BTN_RIGHT, bs);
+					input_report_key(dev, BTN_MIDDLE, pck);
+
+					jitterable = tip | bs | pck;
+				} else {
+					input_report_abs(dev, ABS_PRESSURE, z);
+
+					input_report_key(dev, BTN_TOUCH, tip);
+					input_report_key(dev, BTN_STYLUS, bs);
+					input_report_key(dev, BTN_STYLUS2, pck);
+
+					jitterable = tip | bs | pck;
+
+					if (aiptek->xTilt !=
+					    AIPTEK_TILT_DISABLE)
+						input_report_abs(dev,
+								 ABS_TILT_X,
+								 aiptek->xTilt);
+					if (aiptek->yTilt !=
+					    AIPTEK_TILT_DISABLE)
+						input_report_abs(dev,
+								 ABS_TILT_Y,
+								 aiptek->yTilt);
+				}
+				input_report_abs(dev, ABS_MISC, p);
+				input_event(dev, EV_MSC, MSC_SERIAL, 0);
+			}
+		}
+	}
+	// Report 3's come from the mouse in absolute mode.
+	else if (data[0] == 3) {
+		if (aiptek->coordinate_mode == AIPTEK_COORDINATE_RELATIVE_MODE) {
+			aiptek->diagnostic =
+			    AIPTEK_DIAGNOSTIC_SENDING_ABSOLUTE_IN_RELATIVE;
+		} else
+		    if (!AIPTEK_POINTER_ALLOW_MOUSE_MODE(aiptek->pointer_mode))
+		{
+			aiptek->diagnostic = AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED;
+		} else {
+			int x = ((__u32) data[1]) | ((__u32) data[2] << 8);
+			int y = ((__u32) data[3]) | ((__u32) data[4] << 8);
+			int p = data[5] & 0x01;
+			int dv = data[5] & 0x02;
+			int left = data[5] & 0x04;
+			int right = data[5] & 0x08;
+			int middle = data[5] & 0x10;
+
+			if (dv != 0) {
+				input_report_key(dev, BTN_TOOL_MOUSE, 1);
+				input_report_abs(dev, ABS_X, x);
+				input_report_abs(dev, ABS_Y, y);
+
+				input_report_key(dev, BTN_LEFT, left);
+				input_report_key(dev, BTN_MIDDLE, middle);
+				input_report_key(dev, BTN_RIGHT, right);
+
+				jitterable = left | middle | right;
+
+				input_report_rel(dev, REL_MISC, p);
+				input_event(dev, EV_MSC, MSC_SERIAL, 0);
+			}
+		}
+	}
+	// Report 4s come from the macro keys when pressed by stylus
+	else if (data[0] == 4) {
+		int p = data[1] & 0x01;
+		int dv = data[1] & 0x02;
+		int tip = data[1] & 0x04;
+		int bs = data[1] & 0x08;
+		int pck = data[1] & 0x10;
+
+		int m = data[3];
+		int z = ((__u32) data[4]) | ((__u32) data[5] << 8);
+
+		if (dv != 0) {
+			input_report_key(dev, BTN_TOUCH, tip);
+			input_report_key(dev, BTN_STYLUS, bs);
+			input_report_key(dev, BTN_STYLUS2, pck);
+
+			jitterable = tip | bs | pck;
+
+			input_report_key(dev, macroKeyEvents[m - 1], 1);
+			input_report_abs(dev, ABS_PRESSURE, z);
+			input_report_abs(dev, ABS_MISC, p);
+			input_event(dev, EV_MSC, MSC_SERIAL, 0);
+		}
+	}
+	// Report 5s come from the macro keys when pressed by mouse
+	else if (data[0] == 5) {
+		int p = data[1] & 0x01;
+		int dv = data[1] & 0x02;
+		int left = data[1] & 0x04;
+		int right = data[1] & 0x08;
+		int middle = data[1] & 0x10;
+		int macro = data[3];
+
+		if (dv != 0) {
+			input_report_key(dev, BTN_LEFT, left);
+			input_report_key(dev, BTN_MIDDLE, middle);
+			input_report_key(dev, BTN_RIGHT, right);
+
+			jitterable = left | middle | right;
+
+			input_report_key(dev, macroKeyEvents[macro - 1], 1);
+			input_report_rel(dev, ABS_MISC, p);
+			input_event(dev, EV_MSC, MSC_SERIAL, 0);
+		}
+	}
+	// We have no idea which tool can generate a report 6. Theoretically,
+	// neither need to, having been given reports 4 & 5 for such use.
+	// However, report 6 is the 'official-looking' report for macroKeys;
+	// reports 4 & 5 supposively are used to support unnamed, unknown
+	// hat switches (which just so happen to be the macroKeys.)
+	else if (data[0] == 6) {
+		int macro = ((__u32) data[1]) | ((__u32) data[2] << 8);
+
+		input_report_key(dev, macroKeyEvents[macro - 1], 1);
+		input_report_abs(dev, ABS_MISC, 1);
+		input_event(dev, EV_MSC, MSC_SERIAL, 0);
+	} else {
+		dbg("Unknown report %d", data[0]);
 	}
 
+	// Jitter may occur when the user presses a button on the stlyus
+	// or the mouse. What we do to prevent that is wait 'x' milliseconds
+	// following a 'jitterable' event, which should give the hand some time
+	// stabilize itself.
+	if (jitterable != 0 && aiptek->jitterDelay != 0) {
+		wait_ms(aiptek->jitterDelay);
+	}
 }
 
+/*
+ * We are not able to reliably determine the tablet featureset by
+ * asking for the USB productID. Therefore, we will query the
+ * tablet dynamically and populate the struct in aiptek_probe().
+ */
+
 struct aiptek_features aiptek_features[] = {
-	{"Aiptek 6000U/8000U", 
-	 8, 3000, 2250, 26, 511, aiptek_irq, 0, 0, 0, 0},
+	{"Aiptek", 8, 0, 0, 0, 0, 0, 0, aiptek_irq},
 	{NULL, 0}
 };
 
+/*
+ * These are the USB id's known so far. We do not identify them to
+ * specific Aiptek model numbers, because there has been overlaps,
+ * use, and reuse of id's in existing models. Certain models have
+ * been known to use more than one ID, indicative perhaps of
+ * manufacturing revisions. In any event, we consider these 
+ * IDs to not be model-specific nor unique.
+ */
+
 struct usb_device_id aiptek_ids[] = {
-	{USB_DEVICE(USB_VENDOR_ID_AIPTEK, 0x20), driver_info:0},
+      {USB_DEVICE(USB_VENDOR_ID_AIPTEK, 0x01), driver_info:0},
+      {USB_DEVICE(USB_VENDOR_ID_AIPTEK, 0x10), driver_info:0},
+      {USB_DEVICE(USB_VENDOR_ID_AIPTEK, 0x20), driver_info:0},
+      {USB_DEVICE(USB_VENDOR_ID_AIPTEK, 0x21), driver_info:0},
+      {USB_DEVICE(USB_VENDOR_ID_AIPTEK, 0x22), driver_info:0},
+      {USB_DEVICE(USB_VENDOR_ID_AIPTEK, 0x23), driver_info:0},
+      {USB_DEVICE(USB_VENDOR_ID_AIPTEK, 0x24), driver_info:0},
 	{}
 };
 
@@ -179,8 +777,7 @@
 aiptek_open(struct input_dev *dev)
 {
 	struct aiptek *aiptek = dev->private;
-
-	if (aiptek->open++)
+	if (aiptek->open_count++)
 		return 0;
 
 	aiptek->irq->dev = aiptek->usbdev;
@@ -195,31 +792,416 @@
 {
 	struct aiptek *aiptek = dev->private;
 
-	if (!--aiptek->open)
+	if (!--aiptek->open_count)
 		usb_unlink_urb(aiptek->irq);
 }
 
+/*
+ * Send a command to the tablet. No reply is expected.
+ */
 static void
 aiptek_command(struct usb_device *dev, unsigned int ifnum,
 	       unsigned char command, unsigned char data)
 {
 	__u8 buf[3];
 
-	buf[0] = 4;
+	buf[0] = 2;
+	buf[1] = command;
+	buf[2] = data;
+
+	if (usb_set_report(dev, ifnum, 3, 2, buf, sizeof (buf)) != sizeof (buf)) {
+		dbg("aiptek_command failed, sending: 0x%02x 0x%02x", command,
+		    data);
+	}
+}
+
+/*
+ * Send a query to the tablet. This is done by sending the query stream
+ * first as a command, waiting a few milliseconds, then submitting the
+ * same stream as a query.
+ */
+static unsigned int
+aiptek_query(struct usb_device *dev, unsigned int ifnum,
+	     unsigned char command, unsigned char data)
+{
+	unsigned int ret;
+	__u8 buf[8];
+	buf[0] = 2;
 	buf[1] = command;
 	buf[2] = data;
 
-	if (usb_set_report(dev, ifnum, 3, 2, buf, 3) != 3) {
-		dbg("aiptek_command: 0x%x 0x%x\n", command, data);
+	aiptek_command(dev, ifnum, command, data);
+	wait_ms(400);
+
+	if (usb_get_report(dev, ifnum, 3, 2, buf, 3) < 3) {
+		dbg("aiptek_query failed: returns 0x%02x 0x%02x 0x%02x",
+		    buf[0], buf[1], buf[2]);
+		return 0;
+	}
+	ret = ((__u32) buf[1]) | ((__u32) buf[2] << 8);
+	return ret;
+}
+
+/*
+ * Program the tablet into either absolute or relative mode.
+ *
+ * We also get information about the tablet's size.
+ */
+static void
+aiptek_program_tablet(struct aiptek *aiptek)
+{
+	int modelCode, odmCode, firmwareCode;
+	int xResolution, yResolution, zResolution;
+
+	aiptek->diagnostic = AIPTEK_DIAGNOSTIC_NA;
+
+	// execute Resolution500LPI
+	aiptek_command(aiptek->usbdev, aiptek->ifnum, 0x18, 0x04);
+	// query getModelCode
+	modelCode = aiptek_query(aiptek->usbdev, aiptek->ifnum, 0x02, 0x00);
+	// query getODMCode
+	odmCode = aiptek_query(aiptek->usbdev, aiptek->ifnum, 0x03, 0x00);
+	// query getFirmwareCode
+	firmwareCode = aiptek_query(aiptek->usbdev, aiptek->ifnum, 0x04, 0x00);
+	// query getXextension
+	xResolution = aiptek_query(aiptek->usbdev, aiptek->ifnum, 0x01, 0x00);
+	// query getYextension
+	yResolution = aiptek_query(aiptek->usbdev, aiptek->ifnum, 0x01, 0x01);
+	// query getPressureLevels
+	zResolution = aiptek_query(aiptek->usbdev, aiptek->ifnum, 0x08, 0x00);
+
+	// Depending on whether we are in absolute or relative mode, we will
+	// do a switchToTablet(absolute) or switchToMouse(relative) command.
+	if (aiptek->coordinate_mode == AIPTEK_COORDINATE_ABSOLUTE_MODE) {
+		// execute switchToTablet
+		aiptek_command(aiptek->usbdev, aiptek->ifnum, 0x10, 0x01);
+	} else {
+		// execute switchToMouse
+		aiptek_command(aiptek->usbdev, aiptek->ifnum, 0x10, 0x00);
+	}
+	// This command enables the macro keys
+	aiptek_command(aiptek->usbdev, aiptek->ifnum, 0x11, 0x02);
+	// execute FilterOn
+	aiptek_command(aiptek->usbdev, aiptek->ifnum, 0x17, 0x00);
+	// execute AutoGainOn
+	aiptek_command(aiptek->usbdev, aiptek->ifnum, 0x12, 0xff);
+
+	aiptek->features->odmCode = odmCode;
+	aiptek->features->modelCode = modelCode & 0xff;
+	aiptek->features->firmwareCode = firmwareCode;
+	aiptek->features->pressure_max = zResolution;
+	aiptek->features->x_max = xResolution;
+	aiptek->features->y_max = yResolution;
+
+	aiptek->eventCount = 0;
+}
+
+#if defined(CONFIG_PROC_FS)
+/*
+ * This routine determines keywords and their associated values, and
+ * maps them to supported modes in this driver. It's input comes from
+ * aiptek_procfs_write().
+ */
+static void
+aiptek_procfs_parse(struct aiptek *aiptek, char *keyword, char *value)
+{
+	if (strcmp(keyword, "pointer") == 0) {
+		if (strcmp(value, "stylus") == 0) {
+			aiptek->pointer_mode = AIPTEK_POINTER_ONLY_STYLUS_MODE;
+		} else if (strcmp(value, "mouse") == 0) {
+			aiptek->pointer_mode = AIPTEK_POINTER_ONLY_MOUSE_MODE;
+		} else if (strcmp(value, "either") == 0) {
+			aiptek->pointer_mode = AIPTEK_POINTER_EITHER_MODE;
+		}
+	} else if (strcmp(keyword, "coordinate") == 0) {
+		if (strcmp(value, "relative") == 0) {
+			aiptek->coordinate_mode =
+			    AIPTEK_COORDINATE_RELATIVE_MODE;
+		} else if (strcmp(value, "absolute") == 0) {
+			aiptek->coordinate_mode =
+			    AIPTEK_COORDINATE_ABSOLUTE_MODE;
+		}
+	} else if (strcmp(keyword, "xtilt") == 0) {
+		if (strcmp(value, "disable") == 0) {
+			aiptek->xTilt = AIPTEK_TILT_DISABLE;
+		} else {
+			int x = (int) simple_strtol(value, 0, 10);
+			if (x >= AIPTEK_TILT_MIN && x <= AIPTEK_TILT_MAX)
+				aiptek->xTilt = x;
+		}
+	} else if (strcmp(keyword, "ytilt") == 0) {
+		if (strcmp(value, "disable") == 0) {
+			aiptek->yTilt = AIPTEK_TILT_DISABLE;
+		} else {
+			int y = (int) simple_strtol(value, 0, 10);
+			if (y >= AIPTEK_TILT_MIN && y <= AIPTEK_TILT_MAX)
+				aiptek->yTilt = y;
+		}
+	} else if (strcmp(keyword, "jitter") == 0) {
+		aiptek->jitterDelay = (int) simple_strtol(value, 0, 10);
+	} else if (strcmp(keyword, "tool") == 0) {
+		if (strcmp(value, "mouse") == 0) {
+			aiptek->tool_mode = AIPTEK_TOOL_BUTTON_MOUSE_MODE;
+		} else if (strcmp(value, "rubber") == 0) {
+			aiptek->tool_mode = AIPTEK_TOOL_BUTTON_RUBBER_MODE;
+		} else if (strcmp(value, "pencil") == 0) {
+			aiptek->tool_mode = AIPTEK_TOOL_BUTTON_PENCIL_MODE;
+		} else if (strcmp(value, "pen") == 0) {
+			aiptek->tool_mode = AIPTEK_TOOL_BUTTON_PEN_MODE;
+		} else if (strcmp(value, "brush") == 0) {
+			aiptek->tool_mode = AIPTEK_TOOL_BUTTON_BRUSH_MODE;
+		} else if (strcmp(value, "airbrush") == 0) {
+			aiptek->tool_mode = AIPTEK_TOOL_BUTTON_AIRBRUSH_MODE;
+		}
+	}
+}
+
+/*
+ * This routine reads the status of the aiptek driver, and makes it
+ * available as a procfs file. The description of the procfs file
+ * is at the top of this driver source code.
+ */
+static int
+aiptek_procfs_read(char *page, char **start, off_t offset, int count,
+		   int *eof, void *data)
+{
+	int len;
+	char *out = page;
+	struct aiptek *aiptek = data;
+
+	int inchX = aiptek->features->x_max / 375 * 100;
+	int inchY = aiptek->features->y_max / 375 * 100;
+	int mmX = (int) ((double) aiptek->features->x_max / 14.8);
+	int mmY = (int) ((double) aiptek->features->y_max / 14.8);
+
+	out +=
+	    sprintf(out, "Aiptek Tablet (%dx%d, %d.%02dx%d.%02d\", %dx%dmm)\n",
+		    aiptek->features->x_max, aiptek->features->y_max,
+		    inchX / 100, inchX % 100, inchY / 100, inchY % 100, mmX,
+		    mmY);
+
+	out +=
+	    sprintf(out,
+		    "(USB VendorID 0x%04x, ProductID 0x%04x, ODMCode 0x%04x\n",
+		    aiptek->dev.idvendor, aiptek->dev.idproduct,
+		    aiptek->features->odmCode);
+	out +=
+	    sprintf(out, " ModelCode: 0x%02x, FirmwareCode: 0x%04x)\n",
+		    aiptek->features->modelCode,
+		    aiptek->features->firmwareCode);
+
+	out += sprintf(out, "on /dev/input/event%d\n", aiptek->dev.number);
+	out += sprintf(out, "pointer=%s\n",
+		       (aiptek->pointer_mode == AIPTEK_POINTER_ONLY_MOUSE_MODE
+			? "mouse"
+			: (aiptek->pointer_mode ==
+			   AIPTEK_POINTER_ONLY_STYLUS_MODE ? "stylus" :
+			   "either")));
+	out +=
+	    sprintf(out, "coordinate=%s\n",
+		    (aiptek->coordinate_mode ==
+		     AIPTEK_COORDINATE_RELATIVE_MODE ? "relative" :
+		     "absolute"));
+
+	out += sprintf(out, "tool=");
+	switch (aiptek->tool_mode) {
+	case AIPTEK_TOOL_BUTTON_MOUSE_MODE:
+		out += sprintf(out, "mouse\n");
+		break;
+
+	case AIPTEK_TOOL_BUTTON_RUBBER_MODE:
+		out += sprintf(out, "rubber\n");
+		break;
+
+	case AIPTEK_TOOL_BUTTON_PEN_MODE:
+		out += sprintf(out, "pen\n");
+		break;
+
+	case AIPTEK_TOOL_BUTTON_PENCIL_MODE:
+		out += sprintf(out, "pencil\n");
+		break;
+
+	case AIPTEK_TOOL_BUTTON_BRUSH_MODE:
+		out += sprintf(out, "brush\n");
+		break;
+
+	case AIPTEK_TOOL_BUTTON_AIRBRUSH_MODE:
+		out += sprintf(out, "airbrush\n");
+		break;
 	}
+
+	out += sprintf(out, "xtilt=");
+	if (aiptek->xTilt == AIPTEK_TILT_DISABLE) {
+		out += sprintf(out, "disable\n");
+	} else {
+		out += sprintf(out, "%d\n", aiptek->xTilt);
+	}
+
+	out += sprintf(out, "ytilt=");
+	if (aiptek->yTilt == AIPTEK_TILT_DISABLE) {
+		out += sprintf(out, "disable\n");
+	} else {
+		out += sprintf(out, "%d\n", aiptek->yTilt);
+	}
+
+	out += sprintf(out, "jitter=%d\n", aiptek->jitterDelay);
+
+	out += sprintf(out, "diagnostic=");
+	switch (aiptek->diagnostic) {
+	case AIPTEK_DIAGNOSTIC_NA:
+		out += sprintf(out, "none\n");
+		break;
+	case AIPTEK_DIAGNOSTIC_SENDING_RELATIVE_IN_ABSOLUTE:
+		out += sprintf(out, "tablet sending relative reports\n");
+		break;
+	case AIPTEK_DIAGNOSTIC_SENDING_ABSOLUTE_IN_RELATIVE:
+		out += sprintf(out, "tablet sending absolute reports\n");
+		break;
+	case AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED:
+		out += sprintf(out, "tablet seeing reports from ");
+		if (aiptek->pointer_mode == AIPTEK_POINTER_ONLY_MOUSE_MODE)
+			out += sprintf(out, "stylus\n");
+		else
+			out += sprintf(out, "mouse\n");
+		break;
+	}
+
+	out += sprintf(out, "eventsReceived=%lu\n", aiptek->eventCount);
+
+	len = out - page;
+	len -= offset;
+	if (len < count) {
+		*eof = 1;
+		if (len <= 0) {
+			return 0;
+		}
+	} else {
+		len = count;
+	}
+
+	*start = page + offset;
+
+	return len;
 }
 
-static void*
+/*
+ * This routine permits the setting of driver parameters through a
+ * procfs file. Writing to the procfs file (/proc/driver/usb/aiptek),
+ * you can program the tablet's behavior. Parameters that can be programmed
+ * (and their legal values) are described at the top of this driver.
+ *
+ *
+ * This parser is order-insensitive, and supports one or many parameters
+ * to be sent in one write request. As many parameters as you may fit
+ * in 64 bytes; we only require that you separate them with \n's.
+ *
+ * Any command that is not understood by the parser is silently ignored.
+ */
+static int
+aiptek_procfs_write(struct file *file, const char *buffer, unsigned long count,
+		    void *data)
+{
+	char buf[64];
+	char *scan;
+	char *keyword = NULL;
+	char *value = NULL;
+	struct aiptek *aiptek = data;
+	int num;
+
+	num = (count < 64) ? count : 64;
+	copy_from_user(buf, buffer, num);
+	buf[num] = '\0';
+
+	scan = buf;
+	while (*scan) {
+		if (*scan == '\n' || *scan == '\0') {
+			if (*scan == '\n') {
+				*scan = '\0';
+				scan++;
+			}
+			if (keyword && value) {
+				aiptek_procfs_parse(aiptek, keyword, value);
+			}
+			keyword = NULL;
+			value = NULL;
+			continue;
+		}
+
+		if (*scan != '=' && keyword == NULL) {
+			keyword = scan;
+		} else if (*scan == '=') {
+			*scan++ = '\0';
+			value = scan;
+		}
+		scan++;
+	}
+	// We're insensitive as to whether the buffer ended in a \n or not.
+	if (keyword && value) {
+		aiptek_procfs_parse(aiptek, keyword, value);
+	}
+
+	aiptek_program_tablet(aiptek);
+
+	return num;
+}
+
+/*
+ * This routine destroys our procfs device interface. This will occur
+ * when you remove the driver, either through rmmod or the hotplug system.
+ */
+static void
+destroy_procfs_file(struct aiptek *aiptek)
+{
+	if (aiptek->aiptekProcfsEntry)
+		remove_proc_entry("aiptek", aiptek->usbProcfsEntry);
+	if (aiptek->usbProcfsEntry)
+		remove_proc_entry("usb", proc_root_driver);
+
+	aiptek->usbProcfsEntry = NULL;
+	aiptek->aiptekProcfsEntry = NULL;
+}
+
+/*
+ * This routine builds the procfs file. The file is located at,
+ *      procfs/driver/usb/aiptek.
+ */
+static void
+create_procfs_file(struct aiptek *aiptek)
+{
+	// Make procfs/driver/usb directory
+	aiptek->usbProcfsEntry = create_proc_entry("usb", S_IFDIR,
+						   proc_root_driver);
+	if (!aiptek->usbProcfsEntry) {
+		dbg("create_procfs_file failed; no procfs/driver/usb control file.");
+		destroy_procfs_file(aiptek);
+		return;
+	}
+	aiptek->usbProcfsEntry->owner = THIS_MODULE;
+
+	// Make procfs/driver/usb/aiptek file
+	aiptek->aiptekProcfsEntry = create_proc_entry("aiptek",
+						      S_IFREG | S_IRUGO |
+						      S_IWUGO,
+						      aiptek->usbProcfsEntry);
+	if (!aiptek->aiptekProcfsEntry) {
+		dbg("create_procfs_file failed; no procfs/driver/usb control file.");
+		destroy_procfs_file(aiptek);
+		return;
+	}
+	aiptek->aiptekProcfsEntry->owner = THIS_MODULE;
+	aiptek->aiptekProcfsEntry->data = aiptek;
+	aiptek->aiptekProcfsEntry->read_proc = aiptek_procfs_read;
+	aiptek->aiptekProcfsEntry->write_proc = aiptek_procfs_write;
+}
+#endif
+
+static void *
 aiptek_probe(struct usb_device *dev, unsigned int ifnum,
 	     const struct usb_device_id *id)
 {
 	struct usb_endpoint_descriptor *endpoint;
 	struct aiptek *aiptek;
+	int i;
 
 	if (!(aiptek = kmalloc(sizeof (struct aiptek), GFP_KERNEL)))
 		return NULL;
@@ -231,37 +1213,78 @@
 		kfree(aiptek);
 		return NULL;
 	}
+	// This used to be meaningful, when we had a matrix of
+	// different models with statically-assigned different
+	// features. Now we ask the tablet about everything.
+
+	aiptek->features = aiptek_features;
+
+	// Reset the tablet. The tablet boots up in 'SwitchtoMouse'
+	// mode, which indicates relative coordinates. 'SwitchToTablet'
+	// infers absolute coordinates. (Ergo, mice are inferred to be
+	// relative-only devices, which is not true. A misnomer.)
+	// The routine we use, aiptek_program_tablet, has been generalized
+	// enough such that it's callable through the procfs interface.
+	// This is why we use struct aiptek throughout.
+	aiptek->usbdev = dev;
+	aiptek->ifnum = ifnum;
+	aiptek->pointer_mode = AIPTEK_POINTER_EITHER_MODE;
+	aiptek->coordinate_mode = AIPTEK_COORDINATE_ABSOLUTE_MODE;
+	aiptek->tool_mode = AIPTEK_TOOL_BUTTON_PEN_MODE;
+	aiptek->xTilt = AIPTEK_TILT_DISABLE;
+	aiptek->yTilt = AIPTEK_TILT_DISABLE;
+	aiptek->jitterDelay = AIPTEK_JITTER_DELAY_DEFAULT;
+
+#ifdef CONFIG_PROC_FS
+	create_procfs_file(aiptek);
+#endif
+
+	aiptek_program_tablet(aiptek);
+
+	aiptek->dev.evbit[0] |= BIT(EV_KEY)
+	    | BIT(EV_ABS)
+	    | BIT(EV_MSC);
+
+	aiptek->dev.absbit[0] |= BIT(ABS_X)
+	    | BIT(ABS_Y)
+	    | BIT(ABS_PRESSURE)
+	    | BIT(ABS_TILT_X)
+	    | BIT(ABS_TILT_Y)
+	    | BIT(ABS_MISC);
+
+	aiptek->dev.relbit[0] |= BIT(REL_X)
+	    | BIT(REL_Y)
+	    | BIT(REL_MISC);
+
+	// Set the macro keys up. They are discontiguous, so it's better
+	// to set the bitmask this way.
+
+	for (i = 0; i < sizeof (macroKeyEvents) / sizeof (macroKeyEvents[0]);
+	     ++i) {
+		set_bit(macroKeyEvents[i], aiptek->dev.keybit);
+	}
 
-	// Resolution500LPI
-	aiptek_command(dev, ifnum, 0x18, 0x04);
-
-	// SwitchToTablet
-	aiptek_command(dev, ifnum, 0x10, 0x01);
-
-	aiptek->features = aiptek_features + id->driver_info;
-
-	aiptek->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC) |
-	    aiptek->features->evbit;
-
-	aiptek->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE) |
-	    BIT(ABS_MISC) | aiptek->features->absbit;
-
-	aiptek->dev.relbit[0] |= aiptek->features->relbit;
-
-	aiptek->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) |
-	    BIT(BTN_MIDDLE) | aiptek->features->btnbit;
-
-	aiptek->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) |
-	    BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOUCH) |
-	    BIT(BTN_STYLUS) | BIT(BTN_STYLUS2) | aiptek->features->digibit;
+	aiptek->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT)
+	    | BIT(BTN_RIGHT)
+	    | BIT(BTN_MIDDLE);
+
+	aiptek->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN)
+	    | BIT(BTN_TOOL_RUBBER)
+	    | BIT(BTN_TOOL_PENCIL)
+	    | BIT(BTN_TOOL_AIRBRUSH)
+	    | BIT(BTN_TOOL_BRUSH)
+	    | BIT(BTN_TOOL_MOUSE)
+	    | BIT(BTN_TOUCH)
+	    | BIT(BTN_STYLUS)
+	    | BIT(BTN_STYLUS2);
 
 	aiptek->dev.mscbit[0] = BIT(MSC_SERIAL);
 
 	aiptek->dev.absmax[ABS_X] = aiptek->features->x_max;
 	aiptek->dev.absmax[ABS_Y] = aiptek->features->y_max;
-	aiptek->dev.absmax[ABS_PRESSURE] = aiptek->features->pressure_max -
-	    aiptek->features->pressure_min;
-
+	aiptek->dev.absmax[ABS_PRESSURE] = aiptek->features->pressure_max;
+	aiptek->dev.absmax[ABS_TILT_X] = AIPTEK_TILT_MAX;
+	aiptek->dev.absmax[ABS_TILT_Y] = AIPTEK_TILT_MAX;
 	aiptek->dev.absfuzz[ABS_X] = 0;
 	aiptek->dev.absfuzz[ABS_Y] = 0;
 
@@ -278,28 +1301,31 @@
 
 	endpoint = dev->config[0].interface[ifnum].altsetting[0].endpoint + 0;
 
-	FILL_INT_URB(aiptek->irq,
-		  dev,
-		  usb_rcvintpipe(dev, endpoint->bEndpointAddress),
-		         aiptek->data,
-		  aiptek->features->pktlen,
-		         aiptek->features->irq,
-		  aiptek,
-		  endpoint->bInterval);
+	usb_fill_int_urb(aiptek->irq,
+			 dev,
+			 usb_rcvintpipe(dev, endpoint->bEndpointAddress),
+			 aiptek->data,
+			 aiptek->features->pktlen,
+			 aiptek->features->irq, aiptek, endpoint->bInterval);
 
 	input_register_device(&aiptek->dev);
 
 	printk(KERN_INFO "input%d: %s on usb%d:%d.%d\n",
-	       aiptek->dev.number, aiptek->features->name, dev->bus->busnum,
-	       dev->devnum, ifnum);
+	       aiptek->dev.number,
+	       aiptek->features->name, dev->bus->busnum, dev->devnum, ifnum);
 
 	return aiptek;
 }
 
+static struct usb_driver aiptek_driver;
+
 static void
 aiptek_disconnect(struct usb_device *dev, void *ptr)
 {
 	struct aiptek *aiptek = ptr;
+#ifdef CONFIG_PROC_FS
+	destroy_procfs_file(aiptek);
+#endif
 	usb_unlink_urb(aiptek->irq);
 	input_unregister_device(&aiptek->dev);
 	usb_free_urb(aiptek->irq);
@@ -317,7 +1343,7 @@
 aiptek_init(void)
 {
 	usb_register(&aiptek_driver);
-	info(DRIVER_VERSION " " DRIVER_AUTHOR);
+	info(DRIVER_VERSION ": " DRIVER_AUTHOR);
 	info(DRIVER_DESC);
 	return 0;
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/ax8817x.c linux-2.4.22-pre2/drivers/usb/ax8817x.c
--- linux-2.4.21/drivers/usb/ax8817x.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/ax8817x.c	2003-06-26 21:43:22.000000000 +0000
@@ -0,0 +1,1287 @@
+/*
+ * ASIX AX8817x USB 2.0 10/100/HomePNA Ethernet controller driver
+ *
+ * $Id: ax8817x.c,v 1.15 2003/06/15 18:45:21 dhollis Exp $
+ *
+ * Copyright (c) 2002-2003 TiVo Inc.
+ *
+ * This software may be used and distributed according to the terms
+ * of the GNU General Public License, incorporated herein by reference.
+ *
+ * History 
+ *
+ *	2003-06-12 - Dave Hollis <dhollis@davehollis.com>  1.0.1
+ *		* use usb_make_path for ethtool info
+ *		* Use crc32.h for crc functions
+ *		* Additional callback cases for other host ctrlrs
+ *		* Force minimum default rcv buffers
+ *
+ *	2003-06-12 - Dave Hollis <dhollis@davehollis.com>  1.0.0
+ *		* Backport removal of multiple tx_urb / lengthy 
+ *		  start_xmit routines, etc.
+ *		* ethtool driver name returns driver name, not
+ *		  long description
+ *
+ *	2003-06-05 - Dave Hollis <dhollis@davehollis.com>  0.9.9
+ *		* Cleanup unnecessary #if 0
+ *		* Fix coding style to match kernel style
+ *
+ *	2003-05-31 - Dave Hollis <dhollis@davehollis.com>  0.9.8
+ *		* Don't stop/start the queue in start_xmit
+ *		* Swallow URB status upon hard removal
+ *		* Cleanup remaining comments (kill // style)
+ *
+ *	2003-05-29 - Dave Hollis <dhollis@davehollis.com>  0.9.7
+ *		* Set module owner
+ *		* Follow-up on suggestions from David Brownell &
+ *		  Oliver Neukum which should help with robustness
+ *		* Use ether_crc from stock kernel if available
+ *
+ *	2003-05-28 - Dave Hollis <dhollis@davehollis.com>  0.9.6
+ *		* Added basic ethtool & mii support
+ *
+ *	2003-05-28 - Dave Hollis <dhollis@davehollis.com>  0.9.5
+ *		* Workout devrequest change to usb_ctrlrequest structure
+ *		* Replace FILL_BULK_URB macros to non-deprecated 
+ *		  usb_fill_bulk_urb macros
+ *		* Replace printks with equivalent macros
+ *		* Use defines for module description, version, author to
+ *		  simplify future changes
+ *
+ * Known Issues
+ *	usb-uhci.c: process_transfer: fixed toggle message to console
+ *		Possible bug in usb-uhci or bug in this driver that
+ *		makes it spit that out.  Doesn't seem to have harmful
+ *		effects.
+ *
+ * Todo
+ *	Fix mii/ethtool output
+*/
+
+#include <linux/slab.h>
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/usb.h>
+
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/ethtool.h>
+#include <linux/skbuff.h>
+#include <linux/mii.h>
+#include <asm/uaccess.h>
+#include <linux/crc32.h>
+
+/* Version Information */
+#define DRIVER_VERSION "v1.0.0"
+#define DRIVER_AUTHOR "TiVo, Inc."
+#define DRIVER_DESC "ASIX AX8817x USB Ethernet driver"
+
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_LICENSE("GPL");
+
+
+#define AX_REQ_READ         ( USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE )
+#define AX_REQ_WRITE        ( USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE )
+
+#define AX_CMD_SET_SW_MII           0x06
+#define AX_CMD_READ_MII_REG         0x07
+#define AX_CMD_WRITE_MII_REG        0x08
+#define AX_CMD_SET_HW_MII           0x0a
+#define AX_CMD_WRITE_RX_CTL         0x10
+#define AX_CMD_WRITE_MULTI_FILTER   0x16
+#define AX_CMD_READ_NODE_ID         0x17
+#define AX_CMD_READ_PHY_ID          0x19
+#define AX_CMD_WRITE_MEDIUM_MODE    0x1b
+#define AX_CMD_WRITE_GPIOS          0x1f
+
+#define AX_RX_MAX                   ETH_FRAME_LEN
+#define AX_TIMEOUT_CMD              ( HZ / 10 )
+#define AX_TIMEOUT_TX               ( HZ * 2 )
+#define AX_MAX_MCAST                64
+
+#define AX_DRV_STATE_INITIALIZING   0x00
+#define AX_DRV_STATE_RUNNING        0x01
+#define AX_DRV_STATE_EXITING        0x02
+
+#define AX_PHY_STATE_INITIALIZING   0x00
+#define AX_PHY_STATE_NO_LINK        0x01
+#define AX_PHY_STATE_POLLING_1      0x02
+#define AX_PHY_STATE_POLLING_2      0x03
+#define AX_PHY_STATE_POLLING_3      0x04
+#define AX_PHY_STATE_POLLING_4      0x05
+#define AX_PHY_STATE_SETTING_MAC    0x06
+#define AX_PHY_STATE_LINK           0x07
+#define AX_PHY_STATE_ABORT_POLL     0x08
+#define AX_PHY_STATE_ABORTING       0x09
+
+#define AX_MAX_PHY_RETRY            50
+
+#define AX_RX_URBS_DEFAULT	    2
+
+static const char driver_name[] = "ax8817x";
+static int n_rx_urbs = AX_RX_URBS_DEFAULT;
+
+MODULE_PARM(n_rx_urbs, "i");
+MODULE_PARM_DESC(n_rx_urbs,
+		 "Number of rx buffers to queue at once (def 2)");
+
+struct ax8817x_info;
+struct ax_cmd_req;
+typedef int (*ax_cmd_callback_t) (struct ax8817x_info *,
+				  struct ax_cmd_req *);
+
+struct ax_cmd_req {
+	struct list_head list;
+	ax_cmd_callback_t cmd_callback;
+	void *priv;
+	int status;
+	void *data;
+	int data_size;
+	int timeout;
+	struct usb_ctrlrequest devreq;
+};
+
+struct ax8817x_info {
+	struct usb_device *usb;
+	struct net_device *net;
+	struct urb **rx_urbs;
+	struct urb *tx_urb;
+	struct urb *int_urb;
+	u8 *int_buf;
+	struct urb *ctl_urb;
+	struct list_head ctl_queue;
+	spinlock_t ctl_lock;
+	atomic_t rx_refill_cnt;
+	int tx_head;
+	int tx_tail;
+	spinlock_t tx_lock;
+	struct net_device_stats stats;
+	struct ax_cmd_req phy_req;
+	u8 phy_id;
+	u8 phy_state;
+	u8 drv_state;
+};
+
+
+const struct usb_device_id ax8817x_id_table[] __devinitdata = {
+	/* Linksys USB200M */
+      {USB_DEVICE(0x077b, 0x2226), driver_info:0x00130103},
+	/* Hawking UF200, TRENDnet TU2-ET100 */
+      {USB_DEVICE(0x07b8, 0x420a), driver_info:0x001f1d1f},
+	/* NETGEAR FA120 */
+      {USB_DEVICE(0x0846, 0x1040), driver_info:0x00130103},
+	/* D-Link DUB-E100 */
+      {USB_DEVICE(0x2001, 0x1a00), driver_info:0x009f9d9f},
+
+	{}
+};
+
+MODULE_DEVICE_TABLE(usb, ax8817x_id_table);
+
+static void ax_run_ctl_queue(struct ax8817x_info *, struct ax_cmd_req *,
+			     int);
+static void ax_rx_callback(struct urb *urb);
+
+static void ax_ctl_callback(struct urb *urb)
+{
+	struct ax8817x_info *ax_info =
+	    (struct ax8817x_info *) urb->context;
+
+	ax_run_ctl_queue(ax_info, NULL,
+			 urb->status ? urb->status : urb->actual_length);
+}
+
+/* 
+ * Queue a new ctl request, or dequeue the first in the list
+*/
+static void ax_run_ctl_queue(struct ax8817x_info *ax_info,
+			     struct ax_cmd_req *req, int status)
+{
+	struct ax_cmd_req *next_req = NULL;
+	struct ax_cmd_req *last_req = NULL;
+	unsigned long flags;
+
+	/* Need to lock around queue list manipulation */
+	spin_lock_irqsave(&ax_info->ctl_lock, flags);
+
+	if (req == NULL) {
+		last_req =
+		    list_entry(ax_info->ctl_queue.next, struct ax_cmd_req,
+			       list);
+	} else {
+		if (list_empty(&ax_info->ctl_queue)) {
+			next_req = req;
+		}
+
+		req->status = -EINPROGRESS;
+		list_add_tail(&req->list, &ax_info->ctl_queue);
+	}
+
+	while (1) {
+		if (last_req != NULL) {
+			/* dequeue completed entry */
+			list_del(&last_req->list);
+
+			last_req->status = status;
+			if (last_req->cmd_callback(ax_info, last_req)) {
+				/* requeue if told to do so */
+				last_req->status = -EINPROGRESS;
+				list_add_tail(&last_req->list,
+					      &ax_info->ctl_queue);
+			}
+
+			if (list_empty(&ax_info->ctl_queue)) {
+				next_req = NULL;
+			} else {
+				next_req =
+				    list_entry(ax_info->ctl_queue.next,
+					       struct ax_cmd_req, list);
+			}
+		}
+
+		spin_unlock_irqrestore(&ax_info->ctl_lock, flags);
+
+		if (next_req == NULL) {
+			break;
+		}
+
+		/* XXX: do something with timeout */
+		usb_fill_control_urb(ax_info->ctl_urb, ax_info->usb,
+				     next_req->devreq.
+				     bRequestType & USB_DIR_IN ?
+				     usb_rcvctrlpipe(ax_info->usb,
+						     0) :
+				     usb_sndctrlpipe(ax_info->usb, 0),
+				     (void *) &next_req->devreq,
+				     next_req->data, next_req->data_size,
+				     ax_ctl_callback, ax_info);
+
+		status = usb_submit_urb(ax_info->ctl_urb);
+		if (status >= 0) {
+			break;
+		}
+
+		last_req = next_req;
+
+		spin_lock_irqsave(&ax_info->ctl_lock, flags);
+	}
+}
+
+static int ax_sync_cmd_callback(struct ax8817x_info *unused,
+				struct ax_cmd_req *req)
+{
+	wait_queue_head_t *wq = (wait_queue_head_t *) req->priv;
+
+	wake_up(wq);
+
+	return 0;
+}
+
+static int ax_async_cmd_callback(struct ax8817x_info *unused,
+				 struct ax_cmd_req *req)
+{
+	if (req->status < 0) {
+		err("%s: Async command %d failed: %d\n", __FUNCTION__,
+		    req->devreq.bRequest, req->status);
+	}
+
+	/* Nothing else to do here, just need to free the request (and its
+	   allocated data) */
+	if (req->data != NULL) {
+		kfree(req->data);
+	}
+	kfree(req);
+
+	return 0;
+}
+
+/*
+ * This is mostly the same as usb_control_msg(), except that it is able
+ * to queue control messages
+*/
+static int ax_control_msg(struct ax8817x_info *ax_info, u8 requesttype,
+			  u8 request, u16 value, u16 index, void *data,
+			  u16 size, int timeout)
+{
+	struct ax_cmd_req *req;
+	DECLARE_WAIT_QUEUE_HEAD(wq);
+	DECLARE_WAITQUEUE(wait, current);
+	int ret;
+
+	req = kmalloc(sizeof(struct ax_cmd_req), GFP_KERNEL);
+	if (req == NULL) {
+		return -ENOMEM;
+	}
+
+	req->devreq.bRequestType = requesttype;
+	req->devreq.bRequest = request;
+	req->devreq.wValue = cpu_to_le16(value);
+	req->devreq.wIndex = cpu_to_le16(index);
+	req->devreq.wLength = cpu_to_le16(size);
+	req->data = data;
+	req->data_size = size;
+	req->timeout = timeout;
+
+	req->priv = &wq;
+	set_current_state(TASK_UNINTERRUPTIBLE);
+	add_wait_queue(&wq, &wait);
+
+	req->cmd_callback = ax_sync_cmd_callback;
+
+	ax_run_ctl_queue(ax_info, req, 0);
+	schedule();
+
+	ret = req->status;
+
+	kfree(req);
+
+	return ret;
+}
+
+/*
+ * Same, but can be used asynchronously, may fail, and returns no exit
+ * status
+*/
+static void ax_control_msg_async(struct ax8817x_info *ax_info,
+				 u8 requesttype, u8 request, u16 value,
+				 u16 index, void *data, u16 size,
+				 int timeout)
+{
+	struct ax_cmd_req *req;
+
+	req = kmalloc(sizeof(struct ax_cmd_req), GFP_ATOMIC);
+	if (req == NULL) {
+		/* There's not much else we can do here... */
+		err("%s: Failed alloc\n", __FUNCTION__);
+		return;
+	}
+
+	req->devreq.bRequestType = requesttype;
+	req->devreq.bRequest = request;
+	req->devreq.wValue = cpu_to_le16(value);
+	req->devreq.wIndex = cpu_to_le16(index);
+	req->devreq.wLength = cpu_to_le16(size);
+	req->data = data;
+	req->data_size = size;
+	req->timeout = timeout;
+
+	req->cmd_callback = ax_async_cmd_callback;
+
+	ax_run_ctl_queue(ax_info, req, 0);
+}
+
+static inline int ax_read_cmd(struct ax8817x_info *ax_info, u8 cmd,
+			      u16 value, u16 index, u16 size, void *data)
+{
+	return ax_control_msg(ax_info, AX_REQ_READ, cmd, value, index,
+			      data, size, AX_TIMEOUT_CMD);
+}
+
+static inline int ax_write_cmd(struct ax8817x_info *ax_info, u8 cmd,
+			       u16 value, u16 index, u16 size, void *data)
+{
+	return ax_control_msg(ax_info, AX_REQ_WRITE, cmd, value, index,
+			      data, size, AX_TIMEOUT_CMD);
+}
+
+static inline void ax_write_cmd_async(struct ax8817x_info *ax_info, u8 cmd,
+				      u16 value, u16 index, u16 size,
+				      void *data)
+{
+	ax_control_msg_async(ax_info, AX_REQ_WRITE, cmd, value, index,
+			     data, size, AX_TIMEOUT_CMD);
+}
+
+static int ax_refill_rx_urb(struct ax8817x_info *ax_info, struct urb *urb)
+{
+	struct sk_buff *skb;
+	int ret;
+
+	skb = dev_alloc_skb(AX_RX_MAX + 2);
+	if (skb != NULL) {
+		skb_reserve(skb, 2);	/* for IP header alignment */
+		skb->dev = ax_info->net;
+
+		usb_fill_bulk_urb(urb, ax_info->usb,
+				  usb_rcvbulkpipe(ax_info->usb, 3),
+				  skb->data, AX_RX_MAX, ax_rx_callback,
+				  skb);
+
+		ret = usb_submit_urb(urb);
+		if (ret < 0) {
+			err("Failed submit rx URB (%d)\n", ret);
+			dev_kfree_skb_irq(skb);
+			urb->context = NULL;
+		} else {
+			ret = 0;
+		}
+	} else {
+		/* this just means we're low on memory at the moment. Try to
+		   handle it gracefully. */
+		urb->context = NULL;
+		ret = 1;
+	}
+
+	return ret;
+}
+
+static int ax_phy_cmd_callback(struct ax8817x_info *ax_info,
+			       struct ax_cmd_req *req)
+{
+	int full_duplex;
+	int flow_control;
+	u16 mii_data_le;
+
+	if (req->status < 0) {
+		err("%s: Failed at state %d: %d\n", __FUNCTION__,
+		    ax_info->phy_state, req->status);
+		/* Not sure what else we can do, so just bail */
+		ax_info->phy_state = AX_PHY_STATE_ABORTING;
+	}
+
+	switch (ax_info->phy_state) {
+		/* Now that we're in software MII mode, read the BMSR */
+	case AX_PHY_STATE_POLLING_1:
+		ax_info->phy_state = AX_PHY_STATE_POLLING_2;
+		req->devreq.bRequestType = AX_REQ_READ;
+		req->devreq.bRequest = AX_CMD_READ_MII_REG;
+		req->devreq.wValue = cpu_to_le16(ax_info->phy_id);
+		req->devreq.wIndex = cpu_to_le16(MII_BMSR);
+		req->devreq.wLength = cpu_to_le16(2);
+		req->data_size = 2;
+		(long) req->priv = 0;	/* This is the retry count */
+		return 1;
+
+		/* Done reading BMSR */
+	case AX_PHY_STATE_POLLING_2:
+		mii_data_le = *(u16 *) req->data;
+		if ((mii_data_le &
+		     cpu_to_le16(BMSR_LSTATUS | BMSR_ANEGCAPABLE))
+		    == cpu_to_le16(BMSR_LSTATUS | BMSR_ANEGCAPABLE)) {
+			if (mii_data_le & cpu_to_le16(BMSR_ANEGCOMPLETE)) {
+				/* Autonegotiation done, go on to read LPA */
+				ax_info->phy_state =
+				    AX_PHY_STATE_POLLING_3;
+				req->devreq.wIndex = cpu_to_le16(MII_LPA);
+				return 1;
+			} else if ((long) req->priv++ < AX_MAX_PHY_RETRY) {
+				/* Reread BMSR if it's still autonegotiating. This is
+				   probably unnecessary logic, I've never seen it take
+				   more than 1 try... */
+				return 1;
+			}
+			/* else fall through to abort */
+		}
+		/* XXX: should probably handle auto-neg failure better,
+		   by reverting to manual setting of something safe. (?) */
+
+		ax_info->phy_state = AX_PHY_STATE_ABORT_POLL;
+		/* and then fall through to set hw MII */
+
+		/* Got what we needed from PHY, set back to hardware MII mode
+		   (Do same for abort in mid-poll) */
+	case AX_PHY_STATE_POLLING_3:
+	case AX_PHY_STATE_ABORT_POLL:
+		ax_info->phy_state += 1;
+		req->devreq.bRequestType = AX_REQ_WRITE;
+		req->devreq.bRequest = AX_CMD_SET_HW_MII;
+		req->devreq.wValue = cpu_to_le16(0);
+		req->devreq.wIndex = cpu_to_le16(0);
+		req->devreq.wLength = cpu_to_le16(0);
+		req->data_size = 0;
+		return 1;
+
+		/* The end result, set the right duplex and flow control mode in the
+		   MAC (based on the PHY's LPA reg, which should still be in the data
+		   buffer) */
+	case AX_PHY_STATE_POLLING_4:
+		mii_data_le = *(u16 *) req->data;
+		ax_info->phy_state = AX_PHY_STATE_SETTING_MAC;
+		req->devreq.bRequest = AX_CMD_WRITE_MEDIUM_MODE;
+		full_duplex = mii_data_le & cpu_to_le16(LPA_DUPLEX);
+		flow_control = full_duplex &&
+		    (mii_data_le & cpu_to_le16(0x0400));
+		req->devreq.wValue = cpu_to_le16(0x04) |
+		    (full_duplex ? cpu_to_le16(0x02) : 0) |
+		    (flow_control ? cpu_to_le16(0x10) : 0);
+		info("%s: Link established, %s duplex, flow control %sabled\n", ax_info->net->name, full_duplex ? "full" : "half", flow_control ? "en" : "dis");
+		return 1;
+
+		/* All done */
+	case AX_PHY_STATE_SETTING_MAC:
+		ax_info->phy_state = AX_PHY_STATE_LINK;
+		netif_carrier_on(ax_info->net);
+		return 0;
+
+	default:
+		err("%s: Unknown state %d\n", __FUNCTION__,
+		    ax_info->phy_state);
+		/* fall through */
+	case AX_PHY_STATE_ABORTING:
+		ax_info->phy_state = AX_PHY_STATE_NO_LINK;
+		return 0;
+	}
+}
+
+static void ax_int_callback(struct urb *urb)
+{
+	struct ax8817x_info *ax_info =
+	    (struct ax8817x_info *) urb->context;
+	u8 phy_link;
+
+	if (ax_info->drv_state == AX_DRV_STATE_EXITING ||
+	    urb->actual_length < 3) {
+		return;
+	}
+
+	/* Ignore the first PHY link report, it will sometimes be reported as
+	   link active, even though we just told the PHY to reset. If it
+	   really has link, we'll pick it up next int callback.
+	 */
+	if (ax_info->phy_state == AX_PHY_STATE_INITIALIZING) {
+		netif_carrier_off(ax_info->net);
+		ax_info->phy_state = AX_PHY_STATE_NO_LINK;
+		return;
+	}
+
+	/* Assume we're only interested in the primary PHY for now. */
+	phy_link = ax_info->int_buf[2] & 1;
+
+	if (phy_link ==
+	    (ax_info->phy_state == AX_PHY_STATE_NO_LINK) ? 0 : 1) {
+		/* Common case, no change */
+		return;
+	}
+
+	if (phy_link == 0) {
+		netif_carrier_off(ax_info->net);
+		/* Abort an in-progress poll of the PHY if necessary */
+		switch (ax_info->phy_state) {
+		case AX_PHY_STATE_POLLING_1:
+		case AX_PHY_STATE_POLLING_2:
+		case AX_PHY_STATE_POLLING_3:
+			ax_info->phy_state = AX_PHY_STATE_ABORT_POLL;
+			break;
+
+		case AX_PHY_STATE_POLLING_4:
+		case AX_PHY_STATE_SETTING_MAC:
+			ax_info->phy_state = AX_PHY_STATE_ABORTING;
+			break;
+
+		case AX_PHY_STATE_LINK:
+			ax_info->phy_state = AX_PHY_STATE_NO_LINK;
+			break;
+
+		default:
+			/* If we're already aborting, continue aborting */
+			break;
+		}
+	} else {
+		/* Note that we only fall into this case if previous phy_state was
+		   AX_PHY_STATE_NO_LINK. When the link is reported active while
+		   we're still polling, or when we're aborting, the logic above
+		   will just return, and we'll check again next int callback. */
+
+		ax_info->phy_state = AX_PHY_STATE_POLLING_1;
+		ax_info->phy_req.devreq.bRequestType = AX_REQ_WRITE;
+		ax_info->phy_req.devreq.bRequest = AX_CMD_SET_SW_MII;
+		ax_info->phy_req.devreq.wValue = cpu_to_le16(0);
+		ax_info->phy_req.devreq.wIndex = cpu_to_le16(0);
+		ax_info->phy_req.devreq.wLength = cpu_to_le16(0);
+		ax_info->phy_req.data_size = 0;
+		ax_info->phy_req.timeout = AX_TIMEOUT_CMD;
+		ax_info->phy_req.cmd_callback = ax_phy_cmd_callback;
+
+		ax_run_ctl_queue(ax_info, &ax_info->phy_req, 0);
+	}
+}
+
+static void ax_rx_callback(struct urb *urb)
+{
+	struct sk_buff *skb = (struct sk_buff *) urb->context;
+	struct net_device *net = skb->dev;
+	struct ax8817x_info *ax_info = (struct ax8817x_info *) net->priv;
+	int ret, len, refill;
+
+	switch (urb->status) {
+	case 0:
+		break;
+
+	default:
+		err("%s: URB status %d\n", __FUNCTION__, urb->status);
+		/* It's not clear that we can do much in this case, the rx pipe
+		   doesn't ever seem to stall, so if we got -ETIMEDOUT, that
+		   usually means the device was unplugged, and we just haven't
+		   noticed yet.
+		   Just fall through and free skb without resubmitting urb. */
+	case -ENOENT:		/* */
+	case -ECONNRESET:	/* Async unlink */
+	case -ESHUTDOWN:	/* Hardware gone */
+	case -EILSEQ:		/* Get this when you yank it out on UHCI */
+	case -ETIMEDOUT:	/* OHCI */
+	case -EPROTO:		/* EHCI */
+	case -EPIPE:		
+		dev_kfree_skb_any(skb);
+		urb->context = NULL;
+		return;
+	}
+
+	if (ax_info->drv_state == AX_DRV_STATE_INITIALIZING) {
+		/* Not really expecting this to ever happen, since we haven't yet
+		   enabled receive in the rx_ctl register, but ya never know... */
+		goto refill_same;
+	} else if (ax_info->drv_state == AX_DRV_STATE_EXITING) {
+		dev_kfree_skb_any(skb);
+		urb->context = NULL;
+		return;
+	}
+
+	len = urb->actual_length;
+	if (len == 0) {
+		/* this shouldn't happen... */
+		goto refill_same;
+	}
+
+	refill = ax_refill_rx_urb(ax_info, urb);
+
+	if (refill == 0
+	    || atomic_read(&ax_info->rx_refill_cnt) < n_rx_urbs) {
+		/* Send the receive buffer up the network stack */
+		skb_put(skb, len);
+		skb->protocol = eth_type_trans(skb, net);
+		net->last_rx = jiffies;
+		ax_info->stats.rx_packets++;
+		ax_info->stats.rx_bytes += len;
+
+		netif_rx(skb);
+
+		if (refill == 0) {
+			int i;
+
+			/* This is the common case. This URB got refilled OK, and
+			   no other URBs need to be refilled. */
+			if (atomic_read(&ax_info->rx_refill_cnt) == 0) {
+				return;
+			}
+
+			for (i = 0; i < n_rx_urbs; i++) {
+				struct urb *urb = ax_info->rx_urbs[i];
+
+				if (urb->context == NULL) {
+					if (ax_refill_rx_urb(ax_info, urb)
+					    == 0) {
+						atomic_dec(&ax_info->
+							   rx_refill_cnt);
+					} else {
+						break;
+					}
+				}
+			}
+		} else {
+			/* remember to refill this one later */
+			atomic_inc(&ax_info->rx_refill_cnt);
+		}
+
+		return;
+	} else {
+		ax_info->stats.rx_dropped++;
+		if (refill < 0) {
+			/* the error code was already printk'ed in ax_refill_rx_urb()
+			   so just note the consequences here: */
+			warn("Halting rx due to error\n");
+			return;
+		}
+
+		/* fall through to resubmit this URB with the existing skb
+		   will try to reallocate skb's on next rx callback */
+	}
+
+      refill_same:
+	usb_fill_bulk_urb(urb, ax_info->usb,
+			  usb_rcvbulkpipe(ax_info->usb, 3), skb->data,
+			  AX_RX_MAX, ax_rx_callback, skb);
+
+	ret = usb_submit_urb(urb);
+	if (ret < 0) {
+		err("Failed submit rx URB (%d)\n", ret);
+	}
+}
+
+static int ax8817x_open(struct net_device *net)
+{
+	struct ax8817x_info *ax_info = (struct ax8817x_info *) net->priv;
+	u8 buf[4];
+	int i, ret;
+
+	ret = ax_write_cmd(ax_info, AX_CMD_WRITE_RX_CTL, 0x80, 0, 0, buf);
+	if (ret < 0) {
+		return ret;
+	}
+
+	ret = 0;
+
+	ax_info->tx_urb = usb_alloc_urb(0);
+	if (ax_info->tx_urb == NULL)
+		ret = -ENOMEM;
+
+	atomic_set(&ax_info->rx_refill_cnt, 0);
+
+	for (i = 0; i < n_rx_urbs && ret == 0; i++) {
+		struct urb *urb = ax_info->rx_urbs[i];
+
+		if (urb == NULL) {
+			urb = ax_info->rx_urbs[i] = usb_alloc_urb(0);
+			if (urb == NULL) {
+				ret = -ENOMEM;
+				break;
+			}
+			if (n_rx_urbs > 1) {
+				urb->transfer_flags |= USB_QUEUE_BULK;
+			}
+		}
+		ret = ax_refill_rx_urb(ax_info, urb);
+		if (ret == 1) {
+			atomic_inc(&ax_info->rx_refill_cnt);
+			ret = 0;
+		}
+	}
+
+	/* XXX: should handle the case where we couldn't allocate any skb's
+	   better. They get allocated with GFP_ATOMIC, so they may all fail... */
+	if (ret == 0 && atomic_read(&ax_info->rx_refill_cnt) < n_rx_urbs) {
+		netif_start_queue(net);
+	} else {
+		/* Error: clean up anything we allocated and bail. */
+		usb_free_urb(ax_info->tx_urb);
+
+		for (i = 0; i < n_rx_urbs; i++) {
+			struct urb *urb = ax_info->rx_urbs[i];
+
+			if (urb != NULL) {
+				/* skb gets freed in the URB callback */
+				usb_unlink_urb(urb);
+				usb_free_urb(urb);
+			}
+		}
+
+		err("%s: Failed start rx queue (%d)\n", __FUNCTION__, ret);
+	}
+	return ret;
+}
+
+static int ax8817x_stop(struct net_device *net)
+{
+	struct ax8817x_info *ax_info = (struct ax8817x_info *) net->priv;
+	u8 buf[4];
+	int i, ret;
+
+	netif_stop_queue(net);
+
+	ret = ax_write_cmd(ax_info, AX_CMD_WRITE_RX_CTL, 0x80, 0, 0, buf);
+	if (ret < 0 && ax_info->drv_state != AX_DRV_STATE_EXITING) {
+		err("%s: Failed cmd (%d)\n", __FUNCTION__, ret);
+	}
+
+	if (ax_info->tx_urb != NULL) {
+		usb_unlink_urb(ax_info->tx_urb);
+		usb_free_urb(ax_info->tx_urb);
+		ax_info->tx_urb = NULL;
+	}
+
+	for (i = 0; i < n_rx_urbs; i++) {
+		struct urb *urb = ax_info->rx_urbs[i];
+		if (urb != NULL) {
+			/* skb gets freed in the URB callback */
+			usb_unlink_urb(urb);
+			usb_free_urb(urb);
+			ax_info->rx_urbs[i] = NULL;
+		}
+	}
+
+	return 0;
+}
+
+static void write_bulk_callback(struct urb *urb)
+{
+	struct ax8817x_info *ax_info = urb->context;
+
+	if (!ax_info || (ax_info->drv_state == AX_DRV_STATE_EXITING))
+		return;
+
+	if (!netif_device_present(ax_info->net))
+		return;
+
+	if (urb->status)
+		info("%s: TX status %d", ax_info->net->name, urb->status);
+
+	ax_info->net->trans_start = jiffies;
+	netif_wake_queue(ax_info->net);
+}
+
+static int ax8817x_start_xmit(struct sk_buff *skb, struct net_device *net)
+{
+	struct ax8817x_info *ax_info = net->priv;
+	int res;
+
+	netif_stop_queue(net);
+
+	ax_info->tx_urb->transfer_flags |= USB_ZERO_PACKET;
+	usb_fill_bulk_urb(ax_info->tx_urb, ax_info->usb,
+			  usb_sndbulkpipe(ax_info->usb, 2),
+			  skb->data, skb->len, write_bulk_callback,
+			  ax_info);
+	if ((res = usb_submit_urb(ax_info->tx_urb))) {
+		warn("Failed tx_urb %d", res);
+		ax_info->stats.tx_errors++;
+		netif_start_queue(net);
+	} else {
+		ax_info->stats.tx_packets++;
+		ax_info->stats.tx_bytes += skb->len;
+		net->trans_start = jiffies;
+	}
+	dev_kfree_skb(skb);
+
+	return 0;
+}
+
+static void ax8817x_tx_timeout(struct net_device *net)
+{
+	struct ax8817x_info *ax_info = net->priv;
+
+	if (!ax_info)
+		return;
+
+	warn("%s: Tx timed out.", net->name);
+	ax_info->tx_urb->transfer_flags |= USB_ASYNC_UNLINK;
+	usb_unlink_urb(ax_info->tx_urb);
+	ax_info->stats.tx_errors++;
+}
+
+static struct net_device_stats *ax8817x_stats(struct net_device *net)
+{
+	struct ax8817x_info *ax_info = (struct ax8817x_info *) net->priv;
+
+	return &ax_info->stats;
+}
+
+static void ax8817x_set_multicast(struct net_device *net)
+{
+	struct ax8817x_info *ax_info = (struct ax8817x_info *) net->priv;
+	u8 rx_ctl = 0x8c;
+
+	if (net->flags & IFF_PROMISC) {
+		rx_ctl |= 0x01;
+	} else if (net->flags & IFF_ALLMULTI
+		   || net->mc_count > AX_MAX_MCAST) {
+		rx_ctl |= 0x02;
+	} else if (net->mc_count == 0) {
+		/* just broadcast and directed */
+	} else {
+		struct dev_mc_list *mc_list = net->mc_list;
+		u8 *multi_filter;
+		u32 crc_bits;
+		int i;
+
+		multi_filter = kmalloc(8, GFP_ATOMIC);
+		if (multi_filter == NULL) {
+			/* Oops, couldn't allocate a DMA buffer for setting the multicast
+			   filter. Try all multi mode, although the ax_write_cmd_async
+			   will almost certainly fail, too... (but it will printk). */
+			rx_ctl |= 0x02;
+		} else {
+			memset(multi_filter, 0, 8);
+
+			/* Build the multicast hash filter. */
+			for (i = 0; i < net->mc_count; i++) {
+				crc_bits =
+				    ether_crc(ETH_ALEN,
+					      mc_list->dmi_addr) >> 26;
+				multi_filter[crc_bits >> 3] |=
+				    1 << (crc_bits & 7);
+				mc_list = mc_list->next;
+			}
+
+			ax_write_cmd_async(ax_info,
+					   AX_CMD_WRITE_MULTI_FILTER, 0, 0,
+					   8, multi_filter);
+
+			rx_ctl |= 0x10;
+		}
+	}
+
+	ax_write_cmd_async(ax_info, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0,
+			   NULL);
+}
+
+static int ax8817x_ethtool_ioctl(struct net_device *net, void *uaddr)
+{
+	struct ax8817x_info *ax_info;
+	int cmd;
+
+	ax_info = net->priv;
+	if (get_user(cmd, (int *) uaddr))
+		return -EFAULT;
+
+	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(ax_info->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;
+
+			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 = 0;	/* FIXME */
+
+			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(net);
+			if (copy_to_user(uaddr, &edata, sizeof(edata)))
+				return -EFAULT;
+			return 0;
+		}
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
+static int ax8817x_mii_ioctl(struct net_device *net, struct ifreq *ifr,
+			     int cmd)
+{
+	struct ax8817x_info *ax_info;
+	struct mii_ioctl_data *data_ptr =
+	    (struct mii_ioctl_data *) &(ifr->ifr_data);
+
+	ax_info = net->priv;
+
+	switch (cmd) {
+	case SIOCGMIIPHY:
+		data_ptr->phy_id = ax_info->phy_id;
+		break;
+	case SIOCGMIIREG:
+		if (!capable(CAP_NET_ADMIN))
+			return -EPERM;
+
+		ax_read_cmd(ax_info, AX_CMD_READ_MII_REG, 0,
+			    data_ptr->reg_num & 0x1f, 2,
+			    &(data_ptr->val_out));
+		break;
+	default:
+		return -EOPNOTSUPP;
+	}
+	return 0;
+}
+
+static int ax8817x_ioctl(struct net_device *net, struct ifreq *ifr,
+			 int cmd)
+{
+	struct ax8817x_info *ax_info;
+	int res;
+
+	ax_info = net->priv;
+	res = 0;
+
+	switch (cmd) {
+	case SIOCETHTOOL:
+		res = ax8817x_ethtool_ioctl(net, ifr->ifr_data);
+		break;
+	case SIOCGMIIPHY:	/* Get address of PHY in use */
+	case SIOCGMIIREG:	/* Read from MII PHY register */
+	case SIOCSMIIREG:	/* Write to MII PHY register */
+		return ax8817x_mii_ioctl(net, ifr, cmd);
+	default:
+		res = -EOPNOTSUPP;
+	}
+
+	return res;
+}
+
+static int ax8817x_net_init(struct net_device *net)
+{
+	struct ax8817x_info *ax_info = (struct ax8817x_info *) net->priv;
+	u8 buf[6];
+	u16 *buf16 = (u16 *) buf;
+	int ret;
+
+	spin_lock_init(&ax_info->tx_lock);
+
+	ret = ax_write_cmd(ax_info, AX_CMD_WRITE_RX_CTL, 0x80, 0, 0, buf);
+	if (ret < 0) {
+		return ret;
+	}
+
+	memset(buf, 0, 6);
+
+	/* Get the MAC address */
+	ret = ax_read_cmd(ax_info, AX_CMD_READ_NODE_ID, 0, 0, 6, buf);
+	if (ret < 0) {
+		return ret;
+	}
+
+	memcpy(net->dev_addr, buf, 6);
+
+	/* Get the PHY id */
+	ret = ax_read_cmd(ax_info, AX_CMD_READ_PHY_ID, 0, 0, 2, buf);
+	if (ret < 0) {
+		return ret;
+	} else if (ret < 2) {
+		/* this should always return 2 bytes */
+		return -EIO;
+	}
+
+	/* Reset the PHY, and drop it into auto-negotiation mode */
+	ax_info->phy_id = buf[1];
+	ax_info->phy_state = AX_PHY_STATE_INITIALIZING;
+
+	ret = ax_write_cmd(ax_info, AX_CMD_SET_SW_MII, 0, 0, 0, &buf);
+	if (ret < 0) {
+		return ret;
+	}
+
+	*buf16 = cpu_to_le16(BMCR_RESET);
+	ret = ax_write_cmd(ax_info, AX_CMD_WRITE_MII_REG,
+			   ax_info->phy_id, MII_BMCR, 2, buf16);
+	if (ret < 0) {
+		return ret;
+	}
+
+	/* Advertise that we can do full-duplex pause */
+	*buf16 = cpu_to_le16(ADVERTISE_ALL | ADVERTISE_CSMA | 0x0400);
+	ret = ax_write_cmd(ax_info, AX_CMD_WRITE_MII_REG,
+			   ax_info->phy_id, MII_ADVERTISE, 2, buf16);
+	if (ret < 0) {
+		return ret;
+	}
+
+	*buf16 = cpu_to_le16(BMCR_ANENABLE | BMCR_ANRESTART);
+	ret = ax_write_cmd(ax_info, AX_CMD_WRITE_MII_REG,
+			   ax_info->phy_id, MII_BMCR, 2, buf16);
+	if (ret < 0) {
+		return ret;
+	}
+
+	ret = ax_write_cmd(ax_info, AX_CMD_SET_HW_MII, 0, 0, 0, &buf);
+	if (ret < 0) {
+		return ret;
+	}
+
+	net->open = ax8817x_open;
+	net->stop = ax8817x_stop;
+	net->hard_start_xmit = ax8817x_start_xmit;
+	net->tx_timeout = ax8817x_tx_timeout;
+	net->watchdog_timeo = AX_TIMEOUT_TX;
+	net->get_stats = ax8817x_stats;
+	net->do_ioctl = ax8817x_ioctl;
+	net->set_multicast_list = ax8817x_set_multicast;
+
+	return 0;
+}
+
+static void *ax8817x_bind(struct usb_device *usb, unsigned intf,
+			  const struct usb_device_id *id)
+{
+	struct ax8817x_info *ax_info;
+	struct net_device *net;
+	int i, ret;
+	unsigned long gpio_bits = id->driver_info;
+	u8 buf[2];
+
+	/* Allocate the URB lists along with the device info struct */
+	ax_info = kmalloc(sizeof(struct ax8817x_info) +
+			  n_rx_urbs * sizeof(struct urb *), GFP_KERNEL);
+	if (ax_info == NULL) {
+		err("%s: Failed ax alloc\n", __FUNCTION__);
+		goto exit_err;
+	}
+
+	memset(ax_info, 0, sizeof(struct ax8817x_info) +
+	       n_rx_urbs * sizeof(struct urb *));
+
+	ax_info->drv_state = AX_DRV_STATE_INITIALIZING;
+	ax_info->rx_urbs = (struct urb **) (ax_info + 1);
+	ax_info->usb = usb;
+
+	/* Set up the control URB queue */
+
+	INIT_LIST_HEAD(&ax_info->ctl_queue);
+	spin_lock_init(&ax_info->ctl_lock);
+	ax_info->ctl_urb = usb_alloc_urb(0);
+	if (ax_info->ctl_urb == NULL) {
+		goto exit_err_free_ax;
+	}
+
+	/* Toggle the GPIOs in a manufacturer/model specific way */
+
+	for (i = 2; i >= 0; i--) {
+		ret = ax_write_cmd(ax_info, AX_CMD_WRITE_GPIOS,
+				   (gpio_bits >> (i * 8)) & 0xff, 0, 0,
+				   buf);
+		if (ret < 0) {
+			goto exit_err_free_ax;
+		}
+		wait_ms(5);
+	}
+
+	/* Set up the net device */
+
+	net = alloc_etherdev(0);
+	if (net == NULL) {
+		err("%s: Failed net alloc\n", __FUNCTION__);
+		goto exit_err_free_ax;
+	}
+
+	ax_info->net = net;
+
+	SET_MODULE_OWNER(net);
+	net->init = ax8817x_net_init;
+	net->priv = ax_info;
+
+	ret = register_netdev(net);
+	if (ret < 0) {
+		err("%s: Failed net init (%d)\n", __FUNCTION__, ret);
+		goto exit_err_free_net;
+	}
+
+	/* Set up the interrupt URB, and start PHY state monitoring */
+
+	ax_info->int_urb = usb_alloc_urb(0);
+	if (ax_info->int_urb == NULL) {
+		goto exit_err_unregister_net;
+	}
+	ax_info->int_buf = kmalloc(8, GFP_KERNEL);
+	if (ax_info->int_buf == NULL) {
+		goto exit_err_free_int_urb;
+	}
+	ax_info->phy_req.data = kmalloc(2, GFP_KERNEL);
+	if (ax_info->phy_req.data == NULL) {
+		goto exit_err_free_int_buf;
+	}
+
+	usb_fill_int_urb(ax_info->int_urb, usb, usb_rcvintpipe(usb, 1),
+			 ax_info->int_buf, 8, ax_int_callback, ax_info,
+			 100);
+
+	ret = usb_submit_urb(ax_info->int_urb);
+	if (ret < 0) {
+		err("%s: Failed int URB submit (%d)\n", __FUNCTION__, ret);
+		goto exit_err_free_phy_buf;
+	}
+
+	ax_info->drv_state = AX_DRV_STATE_RUNNING;
+	return ax_info;
+
+      exit_err_free_phy_buf:
+	kfree(ax_info->phy_req.data);
+
+      exit_err_free_int_buf:
+	kfree(ax_info->int_buf);
+
+      exit_err_free_int_urb:
+	usb_free_urb(ax_info->int_urb);
+
+      exit_err_unregister_net:
+	ax_info->drv_state = AX_DRV_STATE_EXITING;
+	unregister_netdev(net);
+
+      exit_err_free_net:
+	kfree(net);
+
+      exit_err_free_ax:
+	if (ax_info->ctl_urb != NULL) {
+		/* no need to unlink, since there should not be any ctl URBs
+		   pending at this point */
+		usb_free_urb(ax_info->ctl_urb);
+	}
+
+	kfree(ax_info);
+
+      exit_err:
+	err("%s: Failed to initialize\n", __FUNCTION__);
+	return NULL;
+}
+
+static void ax8817x_disconnect(struct usb_device *usb, void *p)
+{
+	struct ax8817x_info *ax_info = (struct ax8817x_info *) p;
+
+	ax_info->drv_state = AX_DRV_STATE_EXITING;
+
+	if (ax_info->int_urb != NULL) {
+		usb_unlink_urb(ax_info->int_urb);
+		usb_free_urb(ax_info->int_urb);
+		kfree(ax_info->int_buf);
+	}
+
+	unregister_netdev(ax_info->net);
+
+	/* XXX: hmmm... need to go through and clear out the ctl queue, too... */
+	if (ax_info->ctl_urb != NULL) {
+		usb_unlink_urb(ax_info->ctl_urb);
+		usb_free_urb(ax_info->ctl_urb);
+	}
+
+	kfree(ax_info);
+}
+
+
+static struct usb_driver ax8817x_driver = {
+	.owner = THIS_MODULE,
+	.name = driver_name,
+	.probe = ax8817x_bind,
+	.disconnect = ax8817x_disconnect,
+	.id_table = ax8817x_id_table,
+};
+
+static int __init ax8817x_init(void)
+{
+	int ret;
+
+	if (n_rx_urbs < 1) 
+		n_rx_urbs = AX_RX_URBS_DEFAULT;
+
+	ret = usb_register(&ax8817x_driver);
+	if (ret < 0) {
+		err("%s: Failed to register\n", __FUNCTION__);
+	} else {
+		info(DRIVER_DESC " " DRIVER_VERSION);
+	}
+
+	return ret;
+}
+
+static void __exit ax8817x_exit(void)
+{
+	usb_deregister(&ax8817x_driver);
+}
+
+module_init(ax8817x_init);
+module_exit(ax8817x_exit);
+
+EXPORT_NO_SYMBOLS;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/catc.c linux-2.4.22-pre2/drivers/usb/catc.c
--- linux-2.4.21/drivers/usb/catc.c	2002-11-28 23:53:14.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/catc.c	2003-06-26 21:43:20.000000000 +0000
@@ -42,6 +42,7 @@
 #include <linux/skbuff.h>
 #include <linux/spinlock.h>
 #include <linux/ethtool.h>
+#include <linux/crc32.h>
 #include <asm/bitops.h>
 #include <asm/uaccess.h>
 
@@ -62,6 +63,8 @@
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
 
+static const char driver_name[] = "catc";
+
 /*
  * Some defines.
  */ 
@@ -596,20 +599,9 @@
  * Receive modes. Broadcast, Multicast, Promisc.
  */
 
-static inline u32 ether_crc_le(int cnt, unsigned char *addr)
-{
-	unsigned int crc = 0xffffffff;
-	u8 byte, idx, bit;
-	
-        for (idx = 0; idx < cnt; idx++)
-                for (byte = *addr++, bit = 0; bit < 8; bit++, byte >>= 1)
-                        crc = (crc >> 1) ^ (((crc ^ byte) & 1) ? 0xedb88320U : 0);
-	return crc;
-}
-
 static void catc_multicast(unsigned char *addr, u8 *multicast)
 {
-	unsigned int crc = ether_crc_le(6, addr);
+	u32 crc = ether_crc_le(6, addr);
 	multicast[(crc >> 3) & 0x3f] |= 1 << (crc & 7);
 }
 
@@ -674,7 +666,7 @@
         /* get driver info */
         case ETHTOOL_GDRVINFO: {
                 struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
-                strncpy(info.driver, SHORT_DRIVER_DESC, ETHTOOL_BUSINFO_LEN);
+                strncpy(info.driver, driver_name, ETHTOOL_BUSINFO_LEN);
                 strncpy(info.version, DRIVER_VERSION, ETHTOOL_BUSINFO_LEN);
 		sprintf(tmp, "usb%d:%d", catc->usbdev->bus->busnum, catc->usbdev->devnum);
                 strncpy(info.bus_info, tmp,ETHTOOL_BUSINFO_LEN);
@@ -937,7 +929,7 @@
 MODULE_DEVICE_TABLE(usb, catc_id_table);
 
 static struct usb_driver catc_driver = {
-	name:		"catc",
+	name:		driver_name,
 	probe:		catc_probe,
 	disconnect:	catc_disconnect,
 	id_table:	catc_id_table,
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/hid-core.c linux-2.4.22-pre2/drivers/usb/hid-core.c
--- linux-2.4.21/drivers/usb/hid-core.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/hid-core.c	2003-06-26 21:43:28.000000000 +0000
@@ -108,10 +108,11 @@
 	memset(field, 0, sizeof(struct hid_field) + usages * sizeof(struct hid_usage)
 		+ values * sizeof(unsigned));
 
-	report->field[report->maxfield++] = field;
+	report->field[report->maxfield] = field;
 	field->usage = (struct hid_usage *)(field + 1);
 	field->value = (unsigned *)(field->usage + usages);
 	field->report = report;
+	field->index = report->maxfield++;
 
 	return field;
 }
@@ -127,18 +128,42 @@
 
 	usage = parser->local.usage[0];
 
-	if (type == HID_COLLECTION_APPLICATION
-		&& parser->device->maxapplication < HID_MAX_APPLICATIONS)
-			parser->device->application[parser->device->maxapplication++] = usage;
-
 	if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) {
 		dbg("collection stack overflow");
 		return -1;
 	}
 
-	collection = parser->collection_stack + parser->collection_stack_ptr++;
+	if (parser->device->maxcollection == parser->device->collection_size) {
+		collection = kmalloc(sizeof(struct hid_collection) *
+				     parser->device->collection_size * 2,
+				     GFP_KERNEL);
+		if (collection == NULL) {
+			dbg("failed to reallocate collection array");
+			return -1;
+		}
+		memcpy(collection, parser->device->collection,
+		       sizeof(struct hid_collection) *
+		       parser->device->collection_size);
+		memset(collection + parser->device->collection_size, 0,
+		       sizeof(struct hid_collection) *
+		       parser->device->collection_size);
+		kfree(parser->device->collection);
+		parser->device->collection = collection;
+		parser->device->collection_size *= 2;
+	}
+
+	parser->collection_stack[parser->collection_stack_ptr++] =
+		parser->device->maxcollection;
+
+	collection = parser->device->collection + 
+		parser->device->maxcollection++;
+
 	collection->type = type;
 	collection->usage = usage;
+	collection->level = parser->collection_stack_ptr - 1;
+
+	if (type == HID_COLLECTION_APPLICATION)
+		parser->device->maxapplication++;
 
 	return 0;
 }
@@ -166,8 +191,9 @@
 {
 	int n;
 	for (n = parser->collection_stack_ptr - 1; n >= 0; n--)
-		if (parser->collection_stack[n].type == type)
-			return parser->collection_stack[n].usage;
+		if (parser->device->collection[parser->collection_stack[n]].type == type)
+			return parser->device->collection[parser->collection_stack[n]].usage;
+
 	return 0; /* we know nothing about this usage type */
 }
 
@@ -181,7 +207,12 @@
 		dbg("usage index exceeded");
 		return -1;
 	}
-	parser->local.usage[parser->local.usage_index++] = usage;
+	parser->local.usage[parser->local.usage_index] = usage;
+	parser->local.collection_index[parser->local.usage_index] =
+		parser->collection_stack_ptr ? 
+		parser->collection_stack[parser->collection_stack_ptr - 1] : 0;
+	parser->local.usage_index++;
+
 	return 0;
 }
 
@@ -202,7 +233,7 @@
 		return -1;
 	}
 
-	if (parser->global.logical_maximum <= parser->global.logical_minimum) {
+	if (parser->global.logical_maximum < parser->global.logical_minimum) {
 		dbg("logical range invalid %d %d", parser->global.logical_minimum, parser->global.logical_maximum);
 		return -1;
 	}
@@ -222,8 +253,11 @@
 	field->logical = hid_lookup_collection(parser, HID_COLLECTION_LOGICAL);
 	field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION);
 
-	for (i = 0; i < usages; i++)
+	for (i = 0; i < usages; i++) {
 		field->usage[i].hid = parser->local.usage[i];
+		field->usage[i].collection_index =
+			parser->local.collection_index[i];
+	}
 
 	field->maxusage = usages;
 	field->flags = flags;
@@ -461,7 +495,7 @@
 
 	switch (item->tag) {
 		case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION:
-			ret = open_collection(parser, data & 3);
+			ret = open_collection(parser, data & 0xff);
 			break;
 		case HID_MAIN_ITEM_TAG_END_COLLECTION:
 			ret = close_collection(parser);
@@ -530,6 +564,7 @@
 	}
 
 	if (device->rdesc) kfree(device->rdesc);
+	if (device->collection) kfree(device->collection);
 }
 
 /*
@@ -618,17 +653,30 @@
 		return NULL;
 	memset(device, 0, sizeof(struct hid_device));
 
+	if (!(device->collection = kmalloc(sizeof(struct hid_collection) *
+					   HID_DEFAULT_NUM_COLLECTIONS,
+					   GFP_KERNEL))) {
+		kfree(device);
+		return NULL;
+	}
+	memset(device->collection, 0, sizeof(struct hid_collection) *
+	       HID_DEFAULT_NUM_COLLECTIONS);
+	device->collection_size = HID_DEFAULT_NUM_COLLECTIONS;
+
 	for (i = 0; i < HID_REPORT_TYPES; i++)
 		INIT_LIST_HEAD(&device->report_enum[i].report_list);
 
 	if (!(device->rdesc = (__u8 *)kmalloc(size, GFP_KERNEL))) {
+		kfree(device->collection);
 		kfree(device);
 		return NULL;
 	}
 	memcpy(device->rdesc, start, size);
+	device->rsize = size;
 
 	if (!(parser = kmalloc(sizeof(struct hid_parser), GFP_KERNEL))) {
 		kfree(device->rdesc);
+		kfree(device->collection);
 		kfree(device);
 		return NULL;
 	}
@@ -736,7 +784,7 @@
 	if (hid->claimed & HID_CLAIMED_INPUT)
 		hidinput_hid_event(hid, field, usage, value);
 	if (hid->claimed & HID_CLAIMED_HIDDEV)
-		hiddev_hid_event(hid, usage->hid, value);
+		hiddev_hid_event(hid, field, usage, value);
 }
 
 
@@ -827,6 +875,9 @@
 		return -1;
 	}
 
+	if (hid->claimed & HID_CLAIMED_HIDDEV)
+		hiddev_report_event(hid, report);
+
 	size = ((report->size - 1) >> 3) + 1;
 
 	if (len < size) {
@@ -1016,10 +1067,16 @@
 
 void hid_write_report(struct hid_device *hid, struct hid_report *report)
 {
-	hid_output_report(report, hid->out[hid->outhead].buffer);
+	if (hid->report_enum[report->type].numbered) {
+		hid->out[hid->outhead].buffer[0] = report->id;
+		hid_output_report(report, hid->out[hid->outhead].buffer + 1);
+		hid->out[hid->outhead].dr.wLength = cpu_to_le16(((report->size + 7) >> 3) + 1);
+	} else {
+		hid_output_report(report, hid->out[hid->outhead].buffer);
+		hid->out[hid->outhead].dr.wLength = cpu_to_le16((report->size + 7) >> 3);
+	}
 
-	hid->out[hid->outhead].dr.wValue = cpu_to_le16(0x200 | report->id);
-	hid->out[hid->outhead].dr.wLength = cpu_to_le16((report->size + 7) >> 3);
+	hid->out[hid->outhead].dr.wValue = cpu_to_le16(((report->type + 1) << 8) | report->id);
 
 	hid->outhead = (hid->outhead + 1) & (HID_CONTROL_FIFO_SIZE - 1);
 
@@ -1083,12 +1140,29 @@
 #define USB_VENDOR_ID_KBGEAR		0x084e
 #define USB_DEVICE_ID_KBGEAR_JAMSTUDIO	0x1001
 
+#define USB_VENDOR_ID_AIPTEK		0x08ca
+#define USB_DEVICE_ID_AIPTEK_01	0x0001
+#define USB_DEVICE_ID_AIPTEK_10	0x0010
+#define USB_DEVICE_ID_AIPTEK_20	0x0020
+#define USB_DEVICE_ID_AIPTEK_21	0x0021
+#define USB_DEVICE_ID_AIPTEK_22	0x0022
+#define USB_DEVICE_ID_AIPTEK_23	0x0023
+#define USB_DEVICE_ID_AIPTEK_24	0x0024
+
 #define USB_VENDOR_ID_ATEN		0x0557
 #define USB_DEVICE_ID_ATEN_UC100KM	0x2004
 #define USB_DEVICE_ID_ATEN_CS124U	0x2202
 #define USB_DEVICE_ID_ATEN_2PORTKVM	0x2204
 #define USB_DEVICE_ID_ATEN_4PORTKVM	0x2205
 
+#define USB_VENDOR_ID_TOPMAX		0x0663
+#define USB_DEVICE_ID_TOPMAX_COBRAPAD	0x0103
+
+#define USB_VENDOR_ID_HAPP		0x078b
+#define USB_DEVICE_ID_UGCI_DRIVING	0x0010
+#define USB_DEVICE_ID_UGCI_FLYING	0x0020
+#define USB_DEVICE_ID_UGCI_FIGHTING	0x0030
+
 #define USB_VENDOR_ID_GRIFFIN		0x077d
 #define USB_DEVICE_ID_POWERMATE		0x0410 /* Griffin PowerMate */
 #define USB_DEVICE_ID_SOUNDKNOB		0x04AA /* Griffin SoundKnob */
@@ -1105,6 +1179,10 @@
 #define USB_VENDOR_ID_ESSENTIAL_REALITY	0x0d7f
 #define USB_DEVICE_ID_ESSENTIAL_REALITY_P5	0x0100
 
+#define USB_VENDOR_ID_MGE		0x0463
+#define USB_DEVICE_ID_MGE_UPS		0xffff
+#define USB_DEVICE_ID_MGE_UPS1		0x0001
+ 
 struct hid_blacklist {
 	__u16 idVendor;
 	__u16 idProduct;
@@ -1135,8 +1213,19 @@
 	{ USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS124U, HID_QUIRK_NOGET },
 	{ USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET },
 	{ USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET },
+	{ USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01, HID_QUIRK_IGNORE },
+	{ USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10, HID_QUIRK_IGNORE },
+	{ USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20, HID_QUIRK_IGNORE },
+	{ USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21, HID_QUIRK_IGNORE },
+	{ USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22, HID_QUIRK_IGNORE },
+	{ USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23, HID_QUIRK_IGNORE },
+	{ USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24, HID_QUIRK_IGNORE },
 	{ USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE, HID_QUIRK_IGNORE },
 	{ USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB, HID_QUIRK_IGNORE },
+	{ USB_VENDOR_ID_TOPMAX, USB_DEVICE_ID_TOPMAX_COBRAPAD, HID_QUIRK_BADPAD },
+	{ USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD|HID_QUIRK_MULTI_INPUT },
+	{ USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING, HID_QUIRK_BADPAD|HID_QUIRK_MULTI_INPUT },
+	{ USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD|HID_QUIRK_MULTI_INPUT },
  	{ USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100, HID_QUIRK_IGNORE },
  	{ USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100, HID_QUIRK_IGNORE },
  	{ USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200, HID_QUIRK_IGNORE },
@@ -1146,6 +1235,8 @@
  	{ USB_VENDOR_ID_TANGTOP, USB_DEVICE_ID_TANGTOP_USBPS2, HID_QUIRK_NOGET },
 	{ USB_VENDOR_ID_OKI, USB_VENDOR_ID_OKI_MULITI, HID_QUIRK_NOGET },
 	{ USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5, HID_QUIRK_IGNORE },
+	{ USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_HIDDEV },
+	{ USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1, HID_QUIRK_HIDDEV },
 	{ 0, 0 }
 };
 
@@ -1292,18 +1383,21 @@
 	printk(KERN_INFO);
 
 	if (hid->claimed & HID_CLAIMED_INPUT)
-		printk("input%d", hid->input.number);
+		printk("input");
 	if (hid->claimed == (HID_CLAIMED_INPUT | HID_CLAIMED_HIDDEV))
 		printk(",");
 	if (hid->claimed & HID_CLAIMED_HIDDEV)
 		printk("hiddev%d", hid->minor);
 
 	c = "Device";
-	for (i = 0; i < hid->maxapplication; i++)
-		if ((hid->application[i] & 0xffff) < ARRAY_SIZE(hid_types)) {
-			c = hid_types[hid->application[i] & 0xffff];
+	for (i = 0; i < hid->maxcollection; i++) {
+		if (hid->collection[i].type == HID_COLLECTION_APPLICATION &&
+		   (hid->collection[i].usage & HID_USAGE_PAGE) == HID_UP_GENDESK &&
+		   (hid->collection[i].usage & 0xffff) < ARRAY_SIZE(hid_types)) {
+			c = hid_types[hid->collection[i].usage & 0xffff];
 			break;
 		}
+	}
 
 	printk(": USB HID v%x.%02x %s [%s] on usb%d:%d.%d\n",
 		hid->version >> 8, hid->version & 0xff, c, hid->name,
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/hid-input.c linux-2.4.22-pre2/drivers/usb/hid-input.c
--- linux-2.4.21/drivers/usb/hid-input.c	2001-11-11 18:09:37.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/hid-input.c	2003-06-26 21:43:19.000000000 +0000
@@ -63,9 +63,39 @@
 	__s32 y;
 }  hid_hat_to_axis[] = {{0, 0}, { 0,-1}, { 1,-1}, { 1, 0}, { 1, 1}, { 0, 1}, {-1, 1}, {-1, 0}, {-1,-1}};
 
-static void hidinput_configure_usage(struct hid_device *device, struct hid_field *field, struct hid_usage *usage)
+static struct input_dev *find_input(struct hid_device *hid, struct hid_field *field)
 {
-	struct input_dev *input = &device->input;
+	struct list_head *lh;
+	struct hid_input *hidinput;
+
+	list_for_each (lh, &hid->inputs) {
+		int i;
+
+		hidinput = list_entry(lh, struct hid_input, list);
+
+		if (! hidinput->report)
+			continue;
+
+		for (i = 0; i < hidinput->report->maxfield; i++)
+			if (hidinput->report->field[i] == field)
+				return &hidinput->input;
+	}
+
+	/* Assume we only have one input and use it */
+	if (!list_empty(&hid->inputs)) {
+		hidinput = list_entry(hid->inputs.next, struct hid_input, list);
+		return &hidinput->input;
+	}
+
+	/* This is really a bug */
+	return NULL;
+}
+
+static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field,
+				     struct hid_usage *usage)
+{
+	struct input_dev *input = &hidinput->input;
+	struct hid_device *device = hidinput->input.private;
 	int max;
 	unsigned long *bit;
 
@@ -280,10 +310,20 @@
 		int a = field->logical_minimum;
 		int b = field->logical_maximum;
 
+		if ((device->quirks & HID_QUIRK_BADPAD) && (usage->code == ABS_X || usage->code == ABS_Y)) {
+			a = field->logical_minimum = 0;
+			b = field->logical_maximum = 255;
+		}
+
 		input->absmin[usage->code] = a;
 		input->absmax[usage->code] = b;
-		input->absfuzz[usage->code] = (b - a) >> 8;
-		input->absflat[usage->code] = (b - a) >> 4;
+		input->absfuzz[usage->code] = 0;
+		input->absflat[usage->code] = 0;
+
+		if (field->application == HID_GD_GAMEPAD || field->application == HID_GD_JOYSTICK) {
+			input->absfuzz[usage->code] = (b - a) >> 8;
+			input->absflat[usage->code] = (b - a) >> 4;
+		}
 	}
 
 	if (usage->hat_min != usage->hat_max) {
@@ -300,9 +340,12 @@
 
 void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value)
 {
-	struct input_dev *input = &hid->input;
+	struct input_dev *input = find_input(hid, field);
 	int *quirks = &hid->quirks;
 
+	if (!input)
+		return;
+
 	if (usage->hat_min != usage->hat_max) {
 		value = (value - usage->hat_min) * 8 / (usage->hat_max - usage->hat_min + 1) + 1;
 		if (value < 0 || value > 8) value = 0;
@@ -382,44 +425,84 @@
 	struct hid_report_enum *report_enum;
 	struct hid_report *report;
 	struct list_head *list;
+	struct hid_input *hidinput = NULL;
 	int i, j, k;
 
-	for (i = 0; i < hid->maxapplication; i++)
-		if (IS_INPUT_APPLICATION(hid->application[i]))
+	INIT_LIST_HEAD(&hid->inputs);
+
+	for (i = 0; i < hid->maxcollection; i++)
+		if (hid->collection[i].type == HID_COLLECTION_APPLICATION &&
+		    IS_INPUT_APPLICATION(hid->collection[i].usage))
 			break;
 
-	if (i == hid->maxapplication)
+	if (i == hid->maxcollection)
 		return -1;
 
-	hid->input.private = hid;
-	hid->input.event = hidinput_input_event;
-	hid->input.open = hidinput_open;
-	hid->input.close = hidinput_close;
-
-	hid->input.name = hid->name;
-	hid->input.idbus = BUS_USB;
-	hid->input.idvendor = dev->descriptor.idVendor;
-	hid->input.idproduct = dev->descriptor.idProduct;
-	hid->input.idversion = dev->descriptor.bcdDevice;
-
 	for (k = HID_INPUT_REPORT; k <= HID_OUTPUT_REPORT; k++) {
 		report_enum = hid->report_enum + k;
 		list = report_enum->report_list.next;
 		while (list != &report_enum->report_list) {
 			report = (struct hid_report *) list;
+
+			if (!report->maxfield)
+				continue;
+
+			if (!hidinput) {
+				hidinput = kmalloc(sizeof(*hidinput), GFP_KERNEL);
+				if (!hidinput) {
+					err("Out of memory during hid input probe");
+					return -1;
+				}
+				memset(hidinput, 0, sizeof(*hidinput));
+				list_add_tail(&hidinput->list, &hid->inputs);
+
+				hidinput->input.private = hid;
+				hidinput->input.event = hidinput_input_event;
+				hidinput->input.open = hidinput_open;
+				hidinput->input.close = hidinput_close;
+
+				hidinput->input.name = hid->name;
+				hidinput->input.idbus = BUS_USB;
+				hidinput->input.idvendor = dev->descriptor.idVendor;
+				hidinput->input.idproduct = dev->descriptor.idProduct;
+				hidinput->input.idversion = dev->descriptor.bcdDevice;
+			}
+
 			for (i = 0; i < report->maxfield; i++)
 				for (j = 0; j < report->field[i]->maxusage; j++)
-					hidinput_configure_usage(hid, report->field[i], report->field[i]->usage + j);
+					hidinput_configure_usage(hidinput, report->field[i],
+								 report->field[i]->usage + j);
+
+			if (hid->quirks & HID_QUIRK_MULTI_INPUT) {
+				/* This will leave hidinput NULL, so that it
+				 * allocates another one if we have more inputs on
+				 * the same interface. Some devices (e.g. Happ's
+				 * UGCI) cram a lot of unrelated inputs into the
+				 * same interface. */
+				hidinput->report = report;
+				input_register_device(&hidinput->input);
+				hidinput = NULL;
+			}
+
 			list = list->next;
 		}
 	}
 
-	input_register_device(&hid->input);
+	if (hidinput)
+		input_register_device(&hidinput->input);
 
 	return 0;
 }
 
 void hidinput_disconnect(struct hid_device *hid)
 {
-	input_unregister_device(&hid->input);
+	struct list_head *lh, *next;
+	struct hid_input *hidinput;
+
+	list_for_each_safe (lh, next, &hid->inputs) {
+		hidinput = list_entry(lh, struct hid_input, list);
+		input_unregister_device(&hidinput->input);
+		list_del(&hidinput->list);
+		kfree(hidinput);
+	}
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/hid.h linux-2.4.22-pre2/drivers/usb/hid.h
--- linux-2.4.21/drivers/usb/hid.h	2002-11-28 23:53:14.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/hid.h	2003-06-26 21:43:10.000000000 +0000
@@ -186,10 +186,13 @@
 #define HID_QUIRK_NOTOUCH	0x02
 #define HID_QUIRK_IGNORE	0x04
 #define HID_QUIRK_NOGET		0x08
+#define HID_QUIRK_HIDDEV	0x10
+#define HID_QUIRK_BADPAD	0x20
+#define HID_QUIRK_MULTI_INPUT	0x40
 
 /*
- * This is the global enviroment of the parser. This information is
- * persistent for main-items. The global enviroment can be saved and
+ * This is the global environment of the parser. This information is
+ * persistent for main-items. The global environment can be saved and
  * restored with PUSH/POP statements.
  */
 
@@ -207,15 +210,17 @@
 };
 
 /*
- * This is the local enviroment. It is resistent up the next main-item.
+ * This is the local environment. It is persistent up the next main-item.
  */
 
 #define HID_MAX_DESCRIPTOR_SIZE		4096
 #define HID_MAX_USAGES			1024
 #define HID_MAX_APPLICATIONS		16
+#define HID_DEFAULT_NUM_COLLECTIONS	16
 
 struct hid_local {
 	unsigned usage[HID_MAX_USAGES]; /* usage array */
+	unsigned collection_index[HID_MAX_USAGES]; /* collection index array */
 	unsigned usage_index;
 	unsigned usage_minimum;
 	unsigned delimiter_depth;
@@ -230,10 +235,12 @@
 struct hid_collection {
 	unsigned type;
 	unsigned usage;
+	unsigned level;
 };
 
 struct hid_usage {
 	unsigned  hid;			/* hid usage code */
+	unsigned  collection_index;	/* index into collection array */
 	__u16     code;			/* input driver code */
 	__u8      type;			/* input driver type */
 	__s8	  hat_min;		/* hat switch fun */
@@ -259,6 +266,7 @@
 	unsigned  unit_exponent;
 	unsigned  unit;
 	struct hid_report *report;	/* associated report */
+	unsigned index;			/* index into report->field[] */
 };
 
 #define HID_MAX_FIELDS 64
@@ -294,10 +302,18 @@
 #define HID_CLAIMED_INPUT	1
 #define HID_CLAIMED_HIDDEV	2
 
+struct hid_input {
+	struct list_head list;
+	struct hid_report *report;
+	struct input_dev input;
+};
+
 struct hid_device {							/* device report descriptor */
 	 __u8 *rdesc;
 	unsigned rsize;
-	unsigned application[HID_MAX_APPLICATIONS];			/* List of HID applications */
+	struct hid_collection *collection;                              /* List of HID collections */
+	unsigned collection_size;                                       /* Number of allocated hid_collections */
+	unsigned maxcollection;                                         /* Number of parsed collections */
 	unsigned maxapplication;					/* Number of applications */
 	unsigned version;						/* HID version */
 	unsigned country;						/* HID country */
@@ -316,7 +332,7 @@
 	unsigned claimed;						/* Claimed by hidinput, hiddev? */	
 	unsigned quirks;						/* Various quirks the device can pull on us */
 
-	struct input_dev input;						/* The input structure */
+	struct list_head inputs;					/* The list of inputs */
 	void *hiddev;							/* The hiddev structure */
 	int minor;							/* Hiddev minor number */
 
@@ -332,7 +348,7 @@
 	struct hid_global     global_stack[HID_GLOBAL_STACK_SIZE];
 	unsigned              global_stack_ptr;
 	struct hid_local      local;
-	struct hid_collection collection_stack[HID_COLLECTION_STACK_SIZE];
+	unsigned              collection_stack[HID_COLLECTION_STACK_SIZE];
 	unsigned              collection_stack_ptr;
 	struct hid_device    *device;
 };
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/hiddev.c linux-2.4.22-pre2/drivers/usb/hiddev.c
--- linux-2.4.21/drivers/usb/hiddev.c	2001-10-21 02:13:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/hiddev.c	2003-06-26 21:43:19.000000000 +0000
@@ -50,9 +50,10 @@
 };
 
 struct hiddev_list {
-	struct hiddev_event buffer[HIDDEV_BUFFER_SIZE];
+	struct hiddev_usage_ref buffer[HIDDEV_BUFFER_SIZE];
 	int head;
 	int tail;
+	unsigned flags;
 	struct fasync_struct *fasync;
 	struct hiddev *hiddev;
 	struct hiddev_list *next;
@@ -70,7 +71,8 @@
 static struct hid_report *
 hiddev_lookup_report(struct hid_device *hid, struct hiddev_report_info *rinfo)
 {
-	struct hid_report_enum *report_enum;
+	unsigned flags = rinfo->report_id & ~HID_REPORT_ID_MASK;
+	struct hid_report_enum *report_enum = NULL;
 	struct list_head *list;
 
 	if (rinfo->report_type < HID_REPORT_TYPE_MIN ||
@@ -78,27 +80,29 @@
 
 	report_enum = hid->report_enum +
 		(rinfo->report_type - HID_REPORT_TYPE_MIN);
-	if ((rinfo->report_id & ~HID_REPORT_ID_MASK) != 0) {
-		switch (rinfo->report_id & ~HID_REPORT_ID_MASK) {
-		case HID_REPORT_ID_FIRST:
-			list = report_enum->report_list.next;
-			if (list == &report_enum->report_list) return NULL;
-			rinfo->report_id = ((struct hid_report *) list)->id;
-			break;
-
-		case HID_REPORT_ID_NEXT:
-			list = (struct list_head *)
-				report_enum->report_id_hash[rinfo->report_id &
-							   HID_REPORT_ID_MASK];
-			if (list == NULL) return NULL;
-			list = list->next;
-			if (list == &report_enum->report_list) return NULL;
-			rinfo->report_id = ((struct hid_report *) list)->id;
-			break;
-
-		default:
-			return NULL;
-		}
+	      
+	switch (flags) {
+	case 0: /* Nothing to do -- report_id is already set correctly */
+		break;
+
+	case HID_REPORT_ID_FIRST:
+		list = report_enum->report_list.next;
+		if (list == &report_enum->report_list) return NULL;
+		rinfo->report_id = ((struct hid_report *) list)->id;
+		break;
+		
+	case HID_REPORT_ID_NEXT:
+		list = (struct list_head *)
+			report_enum->report_id_hash[rinfo->report_id &
+						    HID_REPORT_ID_MASK];
+		if (list == NULL) return NULL;
+		list = list->next;
+		if (list == &report_enum->report_list) return NULL;
+		rinfo->report_id = ((struct hid_report *) list)->id;
+		break;
+		
+	default:
+		return NULL;
 	}
 
 	return report_enum->report_id_hash[rinfo->report_id];
@@ -142,21 +146,20 @@
 	return NULL;
 }
 
-/*
- * This is where hid.c calls into hiddev to pass an event that occurred over
- * the interrupt pipe
- */
-void hiddev_hid_event(struct hid_device *hid, unsigned int usage, int value)
+static void hiddev_send_event(struct hid_device *hid,
+			      struct hiddev_usage_ref *uref)
 {
 	struct hiddev *hiddev = hid->hiddev;
 	struct hiddev_list *list = hiddev->list;
 
 	while (list) {
-		list->buffer[list->head].hid = usage;
-		list->buffer[list->head].value = value;
-		list->head = (list->head + 1) & (HIDDEV_BUFFER_SIZE - 1);
-
-		kill_fasync(&list->fasync, SIGIO, POLL_IN);
+		if (uref->field_index != HID_FIELD_INDEX_NONE ||
+		    (list->flags & HIDDEV_FLAG_REPORT) != 0) {
+			list->buffer[list->head] = *uref;
+			list->head = (list->head + 1) & 
+				(HIDDEV_BUFFER_SIZE - 1);
+			kill_fasync(&list->fasync, SIGIO, POLL_IN);
+		}
 
 		list = list->next;
 	}
@@ -165,6 +168,46 @@
 }
 
 /*
+ * This is where hid.c calls into hiddev to pass an event that occurred over
+ * the interrupt pipe
+ */
+void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
+		      struct hid_usage *usage, __s32 value)
+{
+	unsigned type = field->report_type;
+	struct hiddev_usage_ref uref;
+
+	uref.report_type = 
+	  (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT :
+	  ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT : 
+	   ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE:0));
+	uref.report_id = field->report->id;
+	uref.field_index = field->index;
+	uref.usage_index = (usage - field->usage);
+	uref.usage_code = usage->hid;
+	uref.value = value;
+
+	hiddev_send_event(hid, &uref);
+}
+
+
+void hiddev_report_event(struct hid_device *hid, struct hid_report *report)
+{
+	unsigned type = report->type;
+	struct hiddev_usage_ref uref;
+
+	memset(&uref, 0, sizeof(uref));
+	uref.report_type = 
+	  (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT :
+	  ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT : 
+	   ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE:0));
+	uref.report_id = report->id;
+	uref.field_index = HID_FIELD_INDEX_NONE;
+
+	hiddev_send_event(hid, &uref);
+}
+
+/*
  * fasync file op
  */
 static int hiddev_fasync(int fd, struct file *file, int on)
@@ -193,7 +236,6 @@
 	struct hiddev_list *list = file->private_data;
 	struct hiddev_list **listptr;
 
-	lock_kernel();
 	listptr = &list->hiddev->list;
 	hiddev_fasync(-1, file, 0);
 
@@ -209,7 +251,6 @@
 	}
 
 	kfree(list);
-	unlock_kernel();
 
 	return 0;
 }
@@ -259,43 +300,66 @@
 {
 	DECLARE_WAITQUEUE(wait, current);
 	struct hiddev_list *list = file->private_data;
+	int event_size;
 	int retval = 0;
 
-	if (list->head == list->tail) {
-
-		add_wait_queue(&list->hiddev->wait, &wait);
-		set_current_state(TASK_INTERRUPTIBLE);
+	event_size = ((list->flags & HIDDEV_FLAG_UREF) != 0) ?
+		sizeof(struct hiddev_usage_ref) : sizeof(struct hiddev_event);
 
-		while (list->head == list->tail) {
+	if (count < event_size) return 0;
 
-			if (file->f_flags & O_NONBLOCK) {
-				retval = -EAGAIN;
-				break;
-			}
-			if (signal_pending(current)) {
-				retval = -ERESTARTSYS;
-				break;
-			}
-			if (!list->hiddev->exist) {
-				retval = -EIO;
-				break;
+	while (retval == 0) {
+		if (list->head == list->tail) {
+			add_wait_queue(&list->hiddev->wait, &wait);
+			set_current_state(TASK_INTERRUPTIBLE);
+			
+			while (list->head == list->tail) {
+				if (file->f_flags & O_NONBLOCK) {
+					retval = -EAGAIN;
+					break;
+				}
+				if (signal_pending(current)) {
+					retval = -ERESTARTSYS;
+					break;
+				}
+				if (!list->hiddev->exist) {
+					retval = -EIO;
+					break;
+				}
+				
+				schedule();
 			}
 
-			schedule();
+			set_current_state(TASK_RUNNING);
+			remove_wait_queue(&list->hiddev->wait, &wait);
 		}
 
-		set_current_state(TASK_RUNNING);
-		remove_wait_queue(&list->hiddev->wait, &wait);
-	}
+		if (retval)
+			return retval;
 
-	if (retval)
-		return retval;
+		while (list->head != list->tail && 
+		       retval + event_size <= count) {
+			if ((list->flags & HIDDEV_FLAG_UREF) == 0) {
+				if (list->buffer[list->tail].field_index !=
+				    HID_FIELD_INDEX_NONE) {
+					struct hiddev_event event;
+					event.hid = list->buffer[list->tail].usage_code;
+					event.value = list->buffer[list->tail].value;
+					if (copy_to_user(buffer + retval, &event, sizeof(struct hiddev_event)))
+						return -EFAULT;
+					retval += sizeof(struct hiddev_event);
+				}
+			} else {
+				if (list->buffer[list->tail].field_index != HID_FIELD_INDEX_NONE ||
+				    (list->flags & HIDDEV_FLAG_REPORT) != 0) {
+					if (copy_to_user(buffer + retval, list->buffer + list->tail, sizeof(struct hiddev_usage_ref)))
+						return -EFAULT;
+					retval += sizeof(struct hiddev_usage_ref);
+				}
+			}
+			list->tail = (list->tail + 1) & (HIDDEV_BUFFER_SIZE - 1);
+		}
 
-	while (list->head != list->tail && retval + sizeof(struct hiddev_event) <= count) {
-		if (copy_to_user(buffer + retval, list->buffer + list->tail,
-				 sizeof(struct hiddev_event))) return -EFAULT;
-		list->tail = (list->tail + 1) & (HIDDEV_BUFFER_SIZE - 1);
-		retval += sizeof(struct hiddev_event);
 	}
 
 	return retval;
@@ -329,10 +393,14 @@
 	struct hiddev *hiddev = list->hiddev;
 	struct hid_device *hid = hiddev->hid;
 	struct usb_device *dev = hid->dev;
+	struct hiddev_collection_info cinfo;
 	struct hiddev_report_info rinfo;
+	struct hiddev_field_info finfo;
 	struct hiddev_usage_ref uref;
+	struct hiddev_devinfo dinfo;
 	struct hid_report *report;
 	struct hid_field *field;
+	int i;
 
 	if (!hiddev->exist) return -EIO;
 
@@ -344,11 +412,18 @@
 	case HIDIOCAPPLICATION:
 		if (arg < 0 || arg >= hid->maxapplication)
 			return -EINVAL;
-		return hid->application[arg];
+
+		for (i = 0; i < hid->maxcollection; i++)
+			if (hid->collection[i].type == 
+			    HID_COLLECTION_APPLICATION && arg-- == 0)
+				break;
+		
+		if (i == hid->maxcollection)
+			return -EINVAL;
+
+		return hid->collection[i].usage;
 
 	case HIDIOCGDEVINFO:
-	{
-		struct hiddev_devinfo dinfo;
 		dinfo.bustype = BUS_USB;
 		dinfo.busnum = dev->bus->busnum;
 		dinfo.devnum = dev->devnum;
@@ -358,7 +433,25 @@
 		dinfo.version = dev->descriptor.bcdDevice;
 		dinfo.num_applications = hid->maxapplication;
 		return copy_to_user((void *) arg, &dinfo, sizeof(dinfo));
-	}
+
+	case HIDIOCGFLAG:
+		return put_user(list->flags, (int *) arg);
+
+	case HIDIOCSFLAG:
+		{
+			int newflags;
+			if (get_user(newflags, (int *) arg))
+				return -EFAULT;
+
+			if ((newflags & ~HIDDEV_FLAGS) != 0 ||
+			    ((newflags & HIDDEV_FLAG_REPORT) != 0 &&
+			     (newflags & HIDDEV_FLAG_UREF) == 0))
+				return -EINVAL;
+
+			list->flags = newflags;
+
+			return 0;
+		}
 
 	case HIDIOCGSTRING:
 		{
@@ -387,7 +480,6 @@
 		}
 
 	case HIDIOCINITREPORT:
-
 		hid_init_reports(hid);
 
 		return 0;
@@ -432,8 +524,6 @@
 		return copy_to_user((void *) arg, &rinfo, sizeof(rinfo));
 
 	case HIDIOCGFIELDINFO:
-	{
-		struct hiddev_field_info finfo;
 		if (copy_from_user(&finfo, (void *) arg, sizeof(finfo)))
 			return -EFAULT;
 		rinfo.report_type = finfo.report_type;
@@ -462,7 +552,6 @@
 		finfo.unit = field->unit;
 
 		return copy_to_user((void *) arg, &finfo, sizeof(finfo));
-	}
 
 	case HIDIOCGUCODE:
 		if (copy_from_user(&uref, (void *) arg, sizeof(uref)))
@@ -485,9 +574,15 @@
 		return copy_to_user((void *) arg, &uref, sizeof(uref));
 
 	case HIDIOCGUSAGE:
+	case HIDIOCSUSAGE:
+	case HIDIOCGCOLLECTIONINDEX:
 		if (copy_from_user(&uref, (void *) arg, sizeof(uref)))
 			return -EFAULT;
 
+		if (cmd == HIDIOCSUSAGE &&
+		    uref.report_type == HID_REPORT_TYPE_INPUT)
+			return -EINVAL;
+
 		if (uref.report_id == HID_REPORT_ID_UNKNOWN) {
 			field = hiddev_lookup_usage(hid, &uref);
 			if (field == NULL)
@@ -506,38 +601,32 @@
 				return -EINVAL;
 		}
 
-		uref.value = field->value[uref.usage_index];
+		switch (cmd) {
+		case HIDIOCGUSAGE:
+			uref.value = field->value[uref.usage_index];
+			return copy_to_user((void *) arg, &uref, sizeof(uref));
+
+		case HIDIOCSUSAGE:
+			field->value[uref.usage_index] = uref.value;
+			return 0;
 
-		return copy_to_user((void *) arg, &uref, sizeof(uref));
+		case HIDIOCGCOLLECTIONINDEX:
+			return field->usage[uref.usage_index].collection_index;
+		}
+		break;
 
-	case HIDIOCSUSAGE:
-		if (copy_from_user(&uref, (void *) arg, sizeof(uref)))
+	case HIDIOCGCOLLECTIONINFO:
+		if (copy_from_user(&cinfo, (void *) arg, sizeof(cinfo)))
 			return -EFAULT;
 
-		if (uref.report_type == HID_REPORT_TYPE_INPUT)
+		if (cinfo.index >= hid->maxcollection)
 			return -EINVAL;
 
-		if (uref.report_id == HID_REPORT_ID_UNKNOWN) {
-			field = hiddev_lookup_usage(hid, &uref);
-			if (field == NULL)
-				return -EINVAL;
-		} else {
-			rinfo.report_type = uref.report_type;
-			rinfo.report_id = uref.report_id;
-			if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL)
-				return -EINVAL;
-
-			if (uref.field_index >= report->maxfield)
-				return -EINVAL;
-
-			field = report->field[uref.field_index];
-			if (uref.usage_index >= field->maxusage)
-				return -EINVAL;
-		}
-
-		field->value[uref.usage_index] = uref.value;
+		cinfo.type = hid->collection[cinfo.index].type;
+		cinfo.usage = hid->collection[cinfo.index].usage;
+		cinfo.level = hid->collection[cinfo.index].level;
 
-		return 0;
+		return copy_to_user((void *) arg, &cinfo, sizeof(cinfo));
 
 	default:
 
@@ -576,12 +665,18 @@
 	int minor, i;
 	char devfs_name[16];
 
-	for (i = 0; i < hid->maxapplication; i++)
-		if (!IS_INPUT_APPLICATION(hid->application[i]))
-			break;
 
-	if (i == hid->maxapplication)
-		return -1;
+
+	if ((hid->quirks & HID_QUIRK_HIDDEV) == 0) {
+		for (i = 0; i < hid->maxcollection; i++)
+			if (hid->collection[i].type == 
+			    HID_COLLECTION_APPLICATION &&
+			    !IS_INPUT_APPLICATION(hid->collection[i].usage))
+				break;
+
+		if (i == hid->maxcollection)
+			return -1;
+	}
 
 	for (minor = 0; minor < HIDDEV_MINORS && hiddev_table[minor]; minor++);
 	if (minor == HIDDEV_MINORS) {
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/host/ehci-dbg.c linux-2.4.22-pre2/drivers/usb/host/ehci-dbg.c
--- linux-2.4.21/drivers/usb/host/ehci-dbg.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/host/ehci-dbg.c	2003-06-26 21:43:22.000000000 +0000
@@ -125,19 +125,28 @@
 #ifdef	DEBUG
 
 static void __attribute__((__unused__))
+dbg_qtd (char *label, struct ehci_hcd *ehci, struct ehci_qtd *qtd)
+{
+	ehci_dbg (ehci, "%s td %p n%08x %08x t%08x p0=%08x\n", label, qtd,
+		cpu_to_le32p (&qtd->hw_next),
+		cpu_to_le32p (&qtd->hw_alt_next),
+		cpu_to_le32p (&qtd->hw_token),
+		cpu_to_le32p (&qtd->hw_buf [0]));
+	if (qtd->hw_buf [1])
+		ehci_dbg (ehci, "  p1=%08x p2=%08x p3=%08x p4=%08x\n",
+			cpu_to_le32p (&qtd->hw_buf [1]),
+			cpu_to_le32p (&qtd->hw_buf [2]),
+			cpu_to_le32p (&qtd->hw_buf [3]),
+			cpu_to_le32p (&qtd->hw_buf [4]));
+}
+
+static void __attribute__((__unused__))
 dbg_qh (char *label, struct ehci_hcd *ehci, struct ehci_qh *qh)
 {
-	dbg ("%s %p n%08x info1 %x info2 %x hw_curr %x qtd_next %x", label,
+	ehci_dbg (ehci, "%s qh %p n%08x info %x %x qtd %x\n", label,
 		qh, qh->hw_next, qh->hw_info1, qh->hw_info2,
-		qh->hw_current, qh->hw_qtd_next);
-	dbg ("  alt+nak+t= %x, token= %x, page0= %x, page1= %x",
-		qh->hw_alt_next, qh->hw_token,
-		qh->hw_buf [0], qh->hw_buf [1]);
-	if (qh->hw_buf [2]) {
-		dbg ("  page2= %x, page3= %x, page4= %x",
-			qh->hw_buf [2], qh->hw_buf [3],
-			qh->hw_buf [4]);
-	}
+		qh->hw_current);
+	dbg_qtd ("overlay", ehci, (struct ehci_qtd *) &qh->hw_qtd_next);
 }
 
 static int __attribute__((__unused__))
@@ -294,8 +303,7 @@
 		return '*';
 	if (token & QTD_STS_HALT)
 		return '-';
-	if (QTD_PID (token) != 1 /* not IN: OUT or SETUP */
-			|| QTD_LENGTH (token) == 0)
+	if (!IS_SHORT_READ (token))
 		return ' ';
 	/* tries to advance through hw_alt_next */
 	return '/';
@@ -317,11 +325,14 @@
 	char			*next = *nextp;
 	char			mark;
 
-	mark = token_mark (qh->hw_token);
+	if (qh->hw_qtd_next == EHCI_LIST_END)	/* NEC does this */
+		mark = '@';
+	else
+		mark = token_mark (qh->hw_token);
 	if (mark == '/') {	/* qh_alt_next controls qh advance? */
 		if ((qh->hw_alt_next & QTD_MASK) == ehci->async->hw_alt_next)
 			mark = '#';	/* blocked */
-		else if (qh->hw_alt_next & cpu_to_le32 (0x01))
+		else if (qh->hw_alt_next == EHCI_LIST_END)
 			mark = '.';	/* use hw_qtd_next */
 		/* else alt_next points to some other qtd */
 	}
@@ -334,7 +345,7 @@
 			(scratch >> 8) & 0x000f,
 			scratch, cpu_to_le32p (&qh->hw_info2),
 			cpu_to_le32p (&qh->hw_token), mark,
-			(cpu_to_le32 (0x8000000) & qh->hw_token)
+			(__constant_cpu_to_le32 (QTD_TOGGLE) & qh->hw_token)
 				? "data0" : "data1",
 			(cpu_to_le32p (&qh->hw_alt_next) >> 1) & 0x0f);
 	size -= temp;
@@ -400,6 +411,8 @@
 	char			*next;
 	struct ehci_qh		*qh;
 
+	*buf = 0;
+
 	pdev = container_of (dev, struct pci_dev, dev);
 	ehci = container_of (pci_get_drvdata (pdev), struct ehci_hcd, hcd);
 	next = buf;
@@ -422,7 +435,7 @@
 	}
 	spin_unlock_irqrestore (&ehci->lock, flags);
 
-	return PAGE_SIZE - size;
+	return strlen (buf);
 }
 static DEVICE_ATTR (async, S_IRUGO, show_async, NULL);
 
@@ -558,7 +571,8 @@
 	/* Capability Registers */
 	i = readw (&ehci->caps->hci_version);
 	temp = snprintf (next, size,
-		"EHCI %x.%02x, hcd state %d (version " DRIVER_VERSION ")\n",
+		"%s\nEHCI %x.%02x, hcd state %d (driver " DRIVER_VERSION ")\n",
+		pdev->dev.name,
 		i >> 8, i & 0x0ff, ehci->hcd.state);
 	size -= temp;
 	next += temp;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/host/ehci-hcd.c linux-2.4.22-pre2/drivers/usb/host/ehci-hcd.c
--- linux-2.4.21/drivers/usb/host/ehci-hcd.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/host/ehci-hcd.c	2003-06-26 21:43:21.000000000 +0000
@@ -31,6 +31,7 @@
 #include <linux/list.h>
 #include <linux/interrupt.h>
 #include <linux/reboot.h>
+#include <linux/bitops.h> /* for generic_ffs */
 
 #ifdef CONFIG_USB_DEBUG
 	#define DEBUG
@@ -41,11 +42,7 @@
 #include <linux/usb.h>
 
 #include <linux/version.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,32)
 #include "../hcd.h"
-#else
-#include "../core/hcd.h"
-#endif
 
 #include <asm/byteorder.h>
 #include <asm/io.h>
@@ -94,11 +91,11 @@
  * 2001-June	Works with usb-storage and NEC EHCI on 2.4
  */
 
-#define DRIVER_VERSION "2003-Jan-22"
+#define DRIVER_VERSION "2003-Jun-19/2.4"
 #define DRIVER_AUTHOR "David Brownell"
 #define DRIVER_DESC "USB 2.0 'Enhanced' Host Controller (EHCI) Driver"
 
-static const char	hcd_name [] = "ehci-hcd";
+static const char	hcd_name [] = "ehci_hcd";
 
 
 // #define EHCI_VERBOSE_DEBUG
@@ -118,8 +115,10 @@
 #define	EHCI_TUNE_MULT_TT	1
 #define	EHCI_TUNE_FLS		2	/* (small) 256 frame schedule */
 
-#define EHCI_WATCHDOG_JIFFIES	(HZ/100)	/* arbitrary; ~10 msec */
+#define EHCI_IAA_JIFFIES	(HZ/100)	/* arbitrary; ~10 msec */
+#define EHCI_IO_JIFFIES		(HZ/10)		/* io watchdog > irq_thresh */
 #define EHCI_ASYNC_JIFFIES	(HZ/20)		/* async idle timeout */
+#define EHCI_SHRINK_JIFFIES	(HZ/200)	/* async qh unlink delay */
 
 /* Initial IRQ latency:  lower than default */
 static int log2_irq_thresh = 0;		// 0 to 6
@@ -268,16 +267,13 @@
 		}
 	}
 
+ 	/* stop async processing after it's idled a bit */
+	if (test_bit (TIMER_ASYNC_OFF, &ehci->actions))
+ 		start_unlink_async (ehci, ehci->async);
+
+	/* ehci could run by timer, without IRQs ... */
 	ehci_work (ehci, NULL);
-	if (ehci->reclaim && !timer_pending (&ehci->watchdog))
-		mod_timer (&ehci->watchdog,
-				jiffies + EHCI_WATCHDOG_JIFFIES);
 
- 	/* stop async processing after it's idled a while */
-	else if (ehci->async_idle) {
- 		start_unlink_async (ehci, ehci->async);
- 		ehci->async_idle = 0;
-	}
 	spin_unlock_irqrestore (&ehci->lock, flags);
 }
 
@@ -437,7 +433,7 @@
 	pci_set_mwi (ehci->hcd.pdev);
 
 	/* clear interrupt enables, set irq latency */
-	temp = readl (&ehci->regs->command) & 0xff;
+	temp = readl (&ehci->regs->command) & 0x0fff;
 	if (log2_irq_thresh < 0 || log2_irq_thresh > 6)
 		log2_irq_thresh = 0;
 	temp |= 1 << (16 + log2_irq_thresh);
@@ -660,11 +656,18 @@
  */
 static void ehci_work (struct ehci_hcd *ehci, struct pt_regs *regs)
 {
+	timer_action_done (ehci, TIMER_IO_WATCHDOG);
 	if (ehci->reclaim_ready)
 		end_unlink_async (ehci, regs);
 	scan_async (ehci, regs);
 	if (ehci->next_uframe != -1)
 		scan_periodic (ehci, regs);
+
+	/* the IO watchdog guards against hardware or driver bugs that
+	 * misplace IRQs, and should let us run completely without IRQs.
+	 */
+	if ((ehci->async->qh_next.ptr != 0) || (ehci->periodic_sched != 0))
+		timer_action (ehci, TIMER_IO_WATCHDOG);
 }
 
 /*-------------------------------------------------------------------------*/
@@ -1039,8 +1042,8 @@
 
 static int __init init (void) 
 {
-	dbg (DRIVER_INFO);
-	dbg ("block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd",
+	pr_debug ("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
+		hcd_name,
 		sizeof (struct ehci_qh), sizeof (struct ehci_qtd),
 		sizeof (struct ehci_itd), sizeof (struct ehci_sitd));
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/host/ehci-q.c linux-2.4.22-pre2/drivers/usb/host/ehci-q.c
--- linux-2.4.21/drivers/usb/host/ehci-q.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/host/ehci-q.c	2003-06-26 21:43:10.000000000 +0000
@@ -88,7 +88,6 @@
 static inline void
 qh_update (struct ehci_hcd *ehci, struct ehci_qh *qh, struct ehci_qtd *qtd)
 {
-	qh->hw_current = 0;
 	qh->hw_qtd_next = QTD_NEXT (qtd->qtd_dma);
 	qh->hw_alt_next = EHCI_LIST_END;
 
@@ -99,8 +98,6 @@
 
 /*-------------------------------------------------------------------------*/
 
-#define IS_SHORT_READ(token) (QTD_LENGTH (token) != 0 && QTD_PID (token) == 1)
-
 static void qtd_copy_status (
 	struct ehci_hcd *ehci,
 	struct urb *urb,
@@ -314,16 +311,15 @@
 		/* hardware copies qtd out of qh overlay */
 		rmb ();
 		token = le32_to_cpu (qtd->hw_token);
-		stopped = stopped
-			|| (HALT_BIT & qh->hw_token) != 0
-			|| (ehci->hcd.state == USB_STATE_HALT);
 
 		/* always clean up qtds the hc de-activated */
 		if ((token & QTD_STS_ACTIVE) == 0) {
 
-			/* magic dummy for short reads; won't advance */
-			if (IS_SHORT_READ (token)
-					&& !(token & QTD_STS_HALT)
+			if ((token & QTD_STS_HALT) != 0) {
+				stopped = 1;
+
+			/* magic dummy for some short reads; qh won't advance */
+			} else if (IS_SHORT_READ (token)
 					&& (qh->hw_alt_next & QTD_MASK)
 						== ehci->async->hw_alt_next) {
 				stopped = 1;
@@ -331,10 +327,13 @@
 			}
 
 		/* stop scanning when we reach qtds the hc is using */
-		} else if (likely (!stopped)) {
+		} else if (likely (!stopped
+				&& HCD_IS_RUNNING (ehci->hcd.state))) {
 			break;
 
 		} else {
+			stopped = 1;
+
 			/* 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.
@@ -393,12 +392,20 @@
 	qh->qh_state = state;
 
 	/* update qh after fault cleanup */
-	if (unlikely ((HALT_BIT & qh->hw_token) != 0)) {
-		qh_update (ehci, qh,
-			list_empty (&qh->qtd_list)
-				? qh->dummy
-				: list_entry (qh->qtd_list.next,
-					struct ehci_qtd, qtd_list));
+	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 = 0;
+		}
+		if (end)
+			qh_update (ehci, qh, end);
 	}
 
 	return count;
@@ -718,12 +725,11 @@
 
 	/* NOTE:  if (PIPE_INTERRUPT) { scheduler sets s-mask } */
 
-	/* init as halted, toggle clear, advance to dummy */
+	/* init as live, toggle clear, advance to dummy */
 	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);
-	qh->hw_token = cpu_to_le32 (QTD_STS_HALT);
 	usb_settoggle (urb->dev, usb_pipeendpoint (urb->pipe), !is_input, 1);
 	return qh;
 }
@@ -741,8 +747,7 @@
 
 	/* (re)start the async schedule? */
 	head = ehci->async;
-	if (ehci->async_idle)
-		del_timer (&ehci->watchdog);
+	timer_action_done (ehci, TIMER_ASYNC_OFF);
 	if (!head->qh_next.qh) {
 		u32	cmd = readl (&ehci->regs->command);
 
@@ -773,8 +778,6 @@
 
 	qh->qh_state = QH_STATE_LINKED;
 	/* qtd completions reported later by interrupt */
-
-	ehci->async_idle = 0;
 }
 
 /*-------------------------------------------------------------------------*/
@@ -831,9 +834,8 @@
 			}
 		}
 
-		/* FIXME:  changing config or interface setting is not
-		 * supported yet.  preferred fix is for usbcore to tell
-		 * us to clear out each endpoint's state, but...
+		/* NOTE:  changing config or interface setting is not
+		 * supported without the 2.5 endpoint disable logic.
 		 */
 
 		/* usb_clear_halt() means qh data toggle gets reset */
@@ -955,17 +957,17 @@
 	struct ehci_qh		*qh = ehci->reclaim;
 	struct ehci_qh		*next;
 
-	del_timer (&ehci->watchdog);
+	timer_action_done (ehci, TIMER_IAA_WATCHDOG);
 
 	// qh->hw_next = cpu_to_le32 (qh->qh_dma);
 	qh->qh_state = QH_STATE_IDLE;
 	qh->qh_next.qh = 0;
 	qh_put (ehci, qh);			// refcount from reclaim 
-	ehci->reclaim = 0;
-	ehci->reclaim_ready = 0;
 
 	/* other unlink(s) may be pending (in QH_STATE_UNLINK_WAIT) */
 	next = qh->reclaim;
+	ehci->reclaim = next;
+	ehci->reclaim_ready = 0;
 	qh->reclaim = 0;
 
 	qh_completions (ehci, qh, regs);
@@ -980,16 +982,14 @@
 		 * active but idle for a while once it empties.
 		 */
 		if (HCD_IS_RUNNING (ehci->hcd.state)
-				&& ehci->async->qh_next.qh == 0
-				&& !timer_pending (&ehci->watchdog)) {
-			ehci->async_idle = 1;
-			mod_timer (&ehci->watchdog,
-					jiffies + EHCI_ASYNC_JIFFIES);
-		}
+				&& ehci->async->qh_next.qh == 0)
+			timer_action (ehci, TIMER_ASYNC_OFF);
 	}
 
-	if (next)
+	if (next) {
+		ehci->reclaim = 0;
 		start_unlink_async (ehci, next);
+	}
 }
 
 /* makes sure the async qh will become idle */
@@ -1020,6 +1020,7 @@
 			wmb ();
 			// handshake later, if we need to
 		}
+		timer_action_done (ehci, TIMER_ASYNC_OFF);
 		return;
 	} 
 
@@ -1045,9 +1046,8 @@
 	ehci->reclaim_ready = 0;
 	cmd |= CMD_IAAD;
 	writel (cmd, &ehci->regs->command);
-	/* posted write need not be known to HC yet ... */
-
-	mod_timer (&ehci->watchdog, jiffies + EHCI_WATCHDOG_JIFFIES);
+	(void) readl (&ehci->regs->command);
+	timer_action (ehci, TIMER_IAA_WATCHDOG);
 }
 
 /*-------------------------------------------------------------------------*/
@@ -1056,10 +1056,11 @@
 scan_async (struct ehci_hcd *ehci, struct pt_regs *regs)
 {
 	struct ehci_qh		*qh;
-	int			unlink_delay = 0;
+	enum ehci_timer_action	action = TIMER_IO_WATCHDOG;
 
 	if (!++(ehci->stamp))
 		ehci->stamp++;
+	timer_action_done (ehci, TIMER_ASYNC_SHRINK);
 rescan:
 	qh = ehci->async->qh_next.qh;
 	if (likely (qh != 0)) {
@@ -1091,17 +1092,15 @@
 			 */
 			if (list_empty (&qh->qtd_list)) {
 				if (qh->stamp == ehci->stamp)
-					unlink_delay = 1;
-				else if (!ehci->reclaim) {
+					action = TIMER_ASYNC_SHRINK;
+				else if (!ehci->reclaim
+					    && qh->qh_state == QH_STATE_LINKED)
 					start_unlink_async (ehci, qh);
-					unlink_delay = 0;
-				}
 			}
 
 			qh = qh->qh_next.qh;
 		} while (qh);
 	}
-
-	if (unlink_delay && !timer_pending (&ehci->watchdog))
-		mod_timer (&ehci->watchdog, jiffies + EHCI_WATCHDOG_JIFFIES/2);
+	if (action == TIMER_ASYNC_SHRINK)
+		timer_action (ehci, TIMER_ASYNC_SHRINK);
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/host/ehci.h linux-2.4.22-pre2/drivers/usb/host/ehci.h
--- linux-2.4.21/drivers/usb/host/ehci.h	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/host/ehci.h	2003-06-26 21:43:31.000000000 +0000
@@ -52,8 +52,7 @@
 	/* async schedule support */
 	struct ehci_qh		*async;
 	struct ehci_qh		*reclaim;
-	int			reclaim_ready : 1,
-				async_idle : 1;
+	int			reclaim_ready : 1;
 
 	/* periodic schedule support */
 #define	DEFAULT_I_TDPS		1024		/* some HCs can do less */
@@ -83,6 +82,7 @@
 
 	struct timer_list	watchdog;
 	struct notifier_block	reboot_notifier;
+	unsigned long		actions;
 	unsigned		stamp;
 
 	/* irq statistics */
@@ -100,6 +100,53 @@
 /* NOTE:  urb->transfer_flags expected to not use this bit !!! */
 #define EHCI_STATE_UNLINK	0x8000		/* urb being unlinked */
 
+enum ehci_timer_action {
+	TIMER_IO_WATCHDOG,
+	TIMER_IAA_WATCHDOG,
+	TIMER_ASYNC_SHRINK,
+	TIMER_ASYNC_OFF,
+};
+
+static inline void
+timer_action_done (struct ehci_hcd *ehci, enum ehci_timer_action action)
+{
+	clear_bit (action, &ehci->actions);
+}
+
+static inline void
+timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action)
+{
+	if (!test_and_set_bit (action, &ehci->actions)) {
+		unsigned long t;
+
+		switch (action) {
+		case TIMER_IAA_WATCHDOG:
+			t = EHCI_IAA_JIFFIES;
+			break;
+		case TIMER_IO_WATCHDOG:
+			t = EHCI_IO_JIFFIES;
+			break;
+		case TIMER_ASYNC_OFF:
+			t = EHCI_ASYNC_JIFFIES;
+			break;
+		// case TIMER_ASYNC_SHRINK:
+		default:
+			t = EHCI_SHRINK_JIFFIES;
+			break;
+		}
+		t += jiffies;
+		// all timings except IAA watchdog can be overridden.
+		// async queue SHRINK often precedes IAA.  while it's ready
+		// to go OFF neither can matter, and afterwards the IO
+		// watchdog stops unless there's still periodic traffic.
+		if (action != TIMER_IAA_WATCHDOG
+				&& t > ehci->watchdog.expires
+				&& timer_pending (&ehci->watchdog))
+			return;
+		mod_timer (&ehci->watchdog, t);
+	}
+}
+
 /*-------------------------------------------------------------------------*/
 
 /* EHCI register interface, corresponds to EHCI Revision 0.95 specification */
@@ -243,7 +290,10 @@
 	size_t			length;			/* length of buffer */
 } __attribute__ ((aligned (32)));
 
-#define QTD_MASK cpu_to_le32 (~0x1f)	/* mask NakCnt+T in qh->hw_alt_next */
+/* mask NakCnt+T in qh->hw_alt_next */
+#define QTD_MASK __constant_cpu_to_le32 (~0x1f)
+
+#define IS_SHORT_READ(token) (QTD_LENGTH (token) != 0 && QTD_PID (token) == 1)
 
 /*-------------------------------------------------------------------------*/
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/hub.c linux-2.4.22-pre2/drivers/usb/hub.c
--- linux-2.4.21/drivers/usb/hub.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/hub.c	2003-06-26 21:43:20.000000000 +0000
@@ -38,7 +38,7 @@
 static LIST_HEAD(hub_list);		/* List containing all of the hubs (for cleanup) */
 
 static DECLARE_WAIT_QUEUE_HEAD(khubd_wait);
-static int khubd_pid = 0;			/* PID of khubd */
+static pid_t khubd_pid = 0;			/* PID of khubd */
 static DECLARE_COMPLETION(khubd_exited);
 
 #ifdef	DEBUG
@@ -716,8 +716,6 @@
 			break;
 		}
 
-		hub->children[port] = dev;
-
 		/* Reset the device */
 		if (usb_hub_port_reset(hub, port, dev, delay)) {
 			usb_free_dev(dev);
@@ -761,8 +759,10 @@
 			dev->bus->bus_name, dev->devpath, dev->devnum);
 
 		/* Run it through the hoops (find a driver, etc) */
-		if (!usb_new_device(dev))
+		if (!usb_new_device(dev)) {
+			hub->children[port] = dev;
 			goto done;
+		}
 
 		/* Free the configuration if there was an error */
 		usb_free_dev(dev);
@@ -771,7 +771,6 @@
 		delay = HUB_LONG_RESET_TIME;
 	}
 
-	hub->children[port] = NULL;
 	usb_hub_port_disable(hub, port);
 done:
 	up(&usb_address0_sem);
@@ -949,7 +948,7 @@
  */
 int usb_hub_init(void)
 {
-	int pid;
+	pid_t pid;
 
 	if (usb_register(&hub_driver) < 0) {
 		err("Unable to register USB hub driver");
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/kaweth.c linux-2.4.22-pre2/drivers/usb/kaweth.c
--- linux-2.4.21/drivers/usb/kaweth.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/kaweth.c	2003-06-26 21:43:29.000000000 +0000
@@ -114,6 +114,8 @@
 MODULE_DESCRIPTION("KL5USB101 USB Ethernet driver");
 MODULE_LICENSE("GPL");
 
+static const char driver_name[] = "kaweth";
+
 static void *kaweth_probe(
             struct usb_device *dev,             /* the device */
             unsigned ifnum,                     /* what interface */
@@ -170,7 +172,7 @@
  *     kaweth_driver
  ****************************************************************/
 static struct usb_driver kaweth_driver = {
-	.name =		"kaweth",
+	.name =		driver_name,
 	.probe =	kaweth_probe,
 	.disconnect =	kaweth_disconnect,
 	.id_table =     usb_klsi_table,
@@ -659,7 +661,7 @@
 	switch (ethcmd) {
 	case ETHTOOL_GDRVINFO: {
 		struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
-		strncpy(info.driver, "kaweth", sizeof(info.driver)-1);
+		strncpy(info.driver, driver_name, sizeof(info.driver)-1);
 		if (copy_to_user(useraddr, &info, sizeof(info)))
 			return -EFAULT;
 		return 0;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/pegasus.c linux-2.4.22-pre2/drivers/usb/pegasus.c
--- linux-2.4.21/drivers/usb/pegasus.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/pegasus.c	2003-06-26 21:43:33.000000000 +0000
@@ -42,7 +42,7 @@
 /*
  * Version Information
  */
-#define DRIVER_VERSION "v0.4.30 (2003/04/01)"
+#define DRIVER_VERSION "v0.4.32 (2003/06/06)"
 #define DRIVER_AUTHOR "Petko Manolov <petkan@users.sourceforge.net>"
 #define DRIVER_DESC "Pegasus/Pegasus II USB Ethernet driver"
 
@@ -582,18 +582,34 @@
 static void write_bulk_callback(struct urb *urb)
 {
 	pegasus_t *pegasus = urb->context;
+	struct net_device *net = pegasus->net;
 
 	if (!pegasus || !(pegasus->flags & PEGASUS_RUNNING))
 		return;
 
-	if (!netif_device_present(pegasus->net))
+	if (!netif_device_present(net))
 		return;
 
-	if (urb->status)
-		info("%s: TX status %d", pegasus->net->name, urb->status);
+	switch (urb->status) {
+	case -EPIPE:
+		/* FIXME schedule_work() to clear the tx halt */
+		netif_stop_queue(net);
+		warn("%s: no tx stall recovery", net->name);
+		return;
+	case -ENOENT:
+	case -ECONNRESET:
+	case -ESHUTDOWN:
+		dbg("%s: tx unlink, %d", net->name, urb->status);
+		return;
+	default:
+		info("%s: TX status %d", net->name, urb->status);
+		/* FALL THROUGH */
+	case 0:
+		break;
+	}
 
-	pegasus->net->trans_start = jiffies;
-	netif_wake_queue(pegasus->net);
+	net->trans_start = jiffies;
+	netif_wake_queue(net);
 }
 
 #ifdef	PEGASUS_USE_INTR
@@ -665,9 +681,16 @@
 		      write_bulk_callback, pegasus);
 	pegasus->tx_urb->transfer_buffer_length = count;
 	if ((res = usb_submit_urb(pegasus->tx_urb))) {
-		warn("failed tx_urb %d", res);
-		pegasus->stats.tx_errors++;
-		netif_start_queue(net);
+		switch (res) {
+		case -EPIPE:	/* stall, or disconnect from TT */
+			/* cleanup should already have been scheduled */
+			break;
+		case -ENODEV:	/* disconnect() upcoming */
+			break;
+		default:
+			pegasus->stats.tx_errors++;
+			netif_start_queue(net);
+		}
 	} else {
 		pegasus->stats.tx_packets++;
 		pegasus->stats.tx_bytes += skb->len;
@@ -793,11 +816,16 @@
 	switch (ethcmd) {
 	/* get driver-specific version/etc. info */
 	case ETHTOOL_GDRVINFO:{
-			struct ethtool_drvinfo info = { 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;
@@ -860,20 +888,22 @@
 {
 	pegasus_t *pegasus;
 	int cmd;
-	char tmp[128];
 
 	pegasus = net->priv;
 	if (get_user(cmd, (int *) uaddr))
 		return -EFAULT;
 	switch (cmd) {
 	case ETHTOOL_GDRVINFO:{
-			struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
-			strncpy(info.driver, DRIVER_DESC, ETHTOOL_BUSINFO_LEN);
+			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,
-				ETHTOOL_BUSINFO_LEN);
-			sprintf(tmp, "usb%d:%d", pegasus->usb->bus->busnum,
-				pegasus->usb->devnum);
-			strncpy(info.bus_info, tmp, ETHTOOL_BUSINFO_LEN);
+				sizeof (info.version) - 1);
+			usb_make_path(pegasus->usb, info.bus_info,
+			              sizeof (info.bus_info) -1);
 			if (copy_to_user(uaddr, &info, sizeof(info)))
 				return -EFAULT;
 			return 0;
@@ -881,6 +911,7 @@
 	case ETHTOOL_GSET:{
 			struct ethtool_cmd ecmd;
 			short lpa, bmcr;
+			u8 port;
 
 			if (copy_from_user(&ecmd, uaddr, sizeof(ecmd)))
 				return -EFAULT;
@@ -890,7 +921,11 @@
 					  SUPPORTED_100baseT_Full |
 					  SUPPORTED_Autoneg |
 					  SUPPORTED_TP | SUPPORTED_MII);
-			ecmd.port = PORT_TP;
+			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);
@@ -1013,7 +1048,10 @@
 	set_register(pegasus, Reg1d, 0);
 	set_register(pegasus, Reg7b, 1);
 	mdelay(100);
-	set_register(pegasus, Reg7b, 2);
+	if ((pegasus->features & HAS_HOME_PNA) && mii_mode)
+		set_register(pegasus, Reg7b, 0);
+	else
+		set_register(pegasus, Reg7b, 2);
 	
 	set_register(pegasus, 0x83, data);
 	get_registers(pegasus, 0x83, 1, &data);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/pegasus.h linux-2.4.22-pre2/drivers/usb/pegasus.h
--- linux-2.4.21/drivers/usb/pegasus.h	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/pegasus.h	2003-06-26 21:43:33.000000000 +0000
@@ -127,6 +127,7 @@
 #define VENDOR_ELCON		0x0db7
 #define	VENDOR_ELSA		0x05cc
 #define	VENDOR_HAWKING		0x0e66
+#define	VENDOR_HP		0x03f0
 #define	VENDOR_IODATA		0x04bb
 #define	VENDOR_KINGSTON		0x0951
 #define	VENDOR_LANEED		0x056e
@@ -220,6 +221,8 @@
 		DEFAULT_GPIO_RESET )
 PEGASUS_DEV( "Hawking UF100 10/100 Ethernet", VENDOR_HAWKING, 0x400c,
 		DEFAULT_GPIO_RESET | PEGASUS_II )
+PEGASUS_DEV( "HP hn210c Ethernet USB", VENDOR_HP, 0x811c,
+		DEFAULT_GPIO_RESET | PEGASUS_II )
 PEGASUS_DEV( "IO DATA USB ET/TX", VENDOR_IODATA, 0x0904,
 		DEFAULT_GPIO_RESET )
 PEGASUS_DEV( "IO DATA USB ET/TX-S", VENDOR_IODATA, 0x0913,
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/rtl8150.c linux-2.4.22-pre2/drivers/usb/rtl8150.c
--- linux-2.4.21/drivers/usb/rtl8150.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/rtl8150.c	2003-06-26 21:43:32.000000000 +0000
@@ -111,8 +111,10 @@
 static void *rtl8150_probe(struct usb_device *dev, unsigned int ifnum,
 			   const struct usb_device_id *id);
 
+static const char driver_name[] = "rtl8150";
+
 static struct usb_driver rtl8150_driver = {
-	name:		"rtl8150",
+	name:		driver_name,
 	probe:		rtl8150_probe,
 	disconnect:	rtl8150_disconnect,
 	id_table:	rtl8150_table,
@@ -155,7 +157,7 @@
 	clear_bit(RX_REG_SET, &dev->flags);
 }
 
-static int async_set_registers(rtl8150_t * dev, u16 indx, u16 size, void *data)
+static int async_set_registers(rtl8150_t * dev, u16 indx, u16 size)
 {
 	int ret;
 
@@ -426,7 +428,8 @@
 	if (rtl8150_reset(dev)) {
 		warn("%s - device reset failed", __FUNCTION__);
 	}
-	dev->rx_creg = rcr = 0x9e;	/* bit7=1 attach Rx info at the end */
+	rcr = 0x9e;	/* bit7=1 attach Rx info at the end */
+	dev->rx_creg = cpu_to_le16(rcr);
 	tcr = 0xd8;
 	cr = 0x0c;
 	set_registers(dev, RCR, 1, &rcr);
@@ -471,18 +474,18 @@
 	dev = netdev->priv;
 	netif_stop_queue(netdev);
 	if (netdev->flags & IFF_PROMISC) {
-		dev->rx_creg |= 0x0001;
+		dev->rx_creg |= cpu_to_le16(0x0001);
 		info("%s: promiscuous mode", netdev->name);
 	} else if ((netdev->mc_count > multicast_filter_limit) ||
 		   (netdev->flags & IFF_ALLMULTI)) {
-		dev->rx_creg &= 0xfffe;
-		dev->rx_creg |= 0x0002;
+		dev->rx_creg &= cpu_to_le16(0xfffe);
+		dev->rx_creg |= cpu_to_le16(0x0002);
 		info("%s: allmulti set", netdev->name);
 	} else {
 		/* ~RX_MULTICAST, ~RX_PROMISCUOUS */
-		dev->rx_creg &= 0x00fc;
+		dev->rx_creg &= cpu_to_le16(0x00fc);
 	}
-	async_set_registers(dev, RCR, 2, &dev->rx_creg);
+	async_set_registers(dev, RCR, 2);
 	netif_wake_queue(netdev);
 }
 
@@ -577,7 +580,7 @@
 	case ETHTOOL_GDRVINFO:{
 			struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
 
-			strncpy(info.driver, DRIVER_DESC, ETHTOOL_BUSINFO_LEN);
+			strncpy(info.driver, driver_name, ETHTOOL_BUSINFO_LEN);
 			strncpy(info.version, DRIVER_VERSION,
 				ETHTOOL_BUSINFO_LEN);
 			sprintf(tmp, "usb%d:%d", dev->udev->bus->busnum,
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/scanner.c linux-2.4.22-pre2/drivers/usb/scanner.c
--- linux-2.4.21/drivers/usb/scanner.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/scanner.c	2003-06-26 21:43:14.000000000 +0000
@@ -362,6 +362,11 @@
  *      that assumption is not correct in all cases.
  *
  *
+ * 0.4.13  2003-06-14
+ *    - Added vendor/product ids for Genius, Hewlett-Packard, Microtek, 
+ *      Mustek, Pacific Image Electronics, Plustek, and Visioneer scanners.
+ *      Fixed names of some other scanners.
+ *
  * TODO
  *    - Performance
  *    - Select/poll methods
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/scanner.h linux-2.4.22-pre2/drivers/usb/scanner.h
--- linux-2.4.21/drivers/usb/scanner.h	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/scanner.h	2003-06-26 21:43:18.000000000 +0000
@@ -44,7 +44,7 @@
 
 // #define DEBUG
 
-#define DRIVER_VERSION "0.4.12"
+#define DRIVER_VERSION "0.4.13"
 #define DRIVER_DESC "USB Scanner Driver"
 
 #include <linux/usb.h>
@@ -71,7 +71,7 @@
 
 static struct usb_device_id scanner_device_ids [] = {
 	/* Acer (now Benq) */
-	{ USB_DEVICE(0x04a5, 0x1a20) },	/* Unknown - Oliver Schwartz */
+	{ USB_DEVICE(0x04a5, 0x1a20) },	/* Prisa 310U */
 	{ USB_DEVICE(0x04a5, 0x1a2a) },	/* Another 620U */
 	{ USB_DEVICE(0x04a5, 0x2022) },	/* 340U */
 	{ USB_DEVICE(0x04a5, 0x2040) },	/* 620U (!) */
@@ -102,6 +102,7 @@
 	{ USB_DEVICE(0x05d8, 0x4003) }, /* E+ 48U */
 	{ USB_DEVICE(0x05d8, 0x4004) }, /* E+ Pro */
 	/* Avision */
+	{ USB_DEVICE(0x0638, 0x0268) }, /* iVina 1200U */
 	{ USB_DEVICE(0x0638, 0x0a10) },	/* iVina FB1600 (=Umax Astra 4500) */
 	/* Benq: see Acer */
 	/* Brother */
@@ -139,6 +140,7 @@
 	{ USB_DEVICE(0x0458, 0x2013) }, /* ColorPage HR7 */
 	{ USB_DEVICE(0x0458, 0x2015) }, /* ColorPage HR7LE */
 	{ USB_DEVICE(0x0458, 0x2016) }, /* ColorPage HR6X */
+	{ USB_DEVICE(0x0458, 0x2018) },	/* ColorPage HR7X */
 	/* Hewlett Packard */
 	{ USB_DEVICE(0x03f0, 0x0101) },	/* ScanJet 4100C */
 	{ USB_DEVICE(0x03f0, 0x0102) },	/* PhotoSmart S20 */
@@ -158,10 +160,10 @@
 	{ USB_DEVICE(0x03F0, 0x1005) },	/* ScanJet 5400C */
 	{ USB_DEVICE(0x03F0, 0x1105) },	/* ScanJet 5470C */
 	{ USB_DEVICE(0x03f0, 0x1305) },	/* Scanjet 4570c */
+	{ USB_DEVICE(0x03f0, 0x1411) }, /* PSC 750 */
 	{ USB_DEVICE(0x03f0, 0x2005) },	/* ScanJet 3570c */
 	{ USB_DEVICE(0x03f0, 0x2205) },	/* ScanJet 3500c */
-	/* iVina */
-	{ USB_DEVICE(0x0638, 0x0268) }, /* 1200U */
+	{ USB_DEVICE(0x03f0, 0x2f11) }, /* PSC 1210 */
 	/* Lexmark */
 	{ USB_DEVICE(0x043d, 0x002d) }, /* X70/X73 */
 	{ USB_DEVICE(0x043d, 0x003d) }, /* X83 */
@@ -174,6 +176,7 @@
 	/* Microtek */
 	{ USB_DEVICE(0x05da, 0x30ce) },	/* ScanMaker 3800 */
 	{ USB_DEVICE(0x05da, 0x30cf) },	/* ScanMaker 4800 */
+	{ USB_DEVICE(0x04a7, 0x0224) },	/* Scanport 3000 (actually Visioneer?)*/
 	/* The following SCSI-over-USB Microtek devices are supported by the
 	   microtek driver: Enable SCSI and USB Microtek in kernel config */
 	//	{ USB_DEVICE(0x05da, 0x0099) },	/* ScanMaker X6 - X6U */
@@ -206,25 +209,30 @@
 	{ USB_DEVICE(0x055f, 0x021d) }, /* Bearpaw 2400 CU Plus */
 	{ USB_DEVICE(0x055f, 0x021e) }, /* BearPaw 1200 TA/CS */
 	{ USB_DEVICE(0x055f, 0x0400) }, /* BearPaw 2400 TA PRO */
+	{ USB_DEVICE(0x055f, 0x0401) },	/* P 3600 A3 Pro */
 	{ USB_DEVICE(0x055f, 0x0873) }, /* ScanExpress 600 USB */
 	{ USB_DEVICE(0x055f, 0x1000) }, /* BearPaw 4800 TA PRO */
 	//	{ USB_DEVICE(0x05d8, 0x4002) }, /* BearPaw 1200 CU and ScanExpress 1200 UB Plus (see Artec) */
 	/* Nikon */
 	{ USB_DEVICE(0x04b0, 0x4000) }, /* Coolscan LS 40 ED */
+	/* Pacific Image Electronics */
+	{ USB_DEVICE(0x05e3, 0x0120) },	/* PrimeFilm 1800u */
 	/* Plustek */
+	{ USB_DEVICE(0x07b3, 0x0001) },	/* 1212U */
 	{ USB_DEVICE(0x07b3, 0x0005) }, /* Unknown */
 	{ USB_DEVICE(0x07b3, 0x0007) }, /* Unknown */
 	{ USB_DEVICE(0x07b3, 0x000F) }, /* Unknown */
 	{ USB_DEVICE(0x07b3, 0x0010) }, /* OpticPro U12 */
 	{ USB_DEVICE(0x07b3, 0x0011) }, /* OpticPro U24 */
 	{ USB_DEVICE(0x07b3, 0x0012) }, /* Unknown */
-	{ USB_DEVICE(0x07b3, 0x0013) }, /* Unknown */
+	{ USB_DEVICE(0x07b3, 0x0013) }, /* UT12 */
 	{ USB_DEVICE(0x07b3, 0x0014) }, /* Unknown */
 	{ USB_DEVICE(0x07b3, 0x0015) }, /* OpticPro U24 */
 	{ USB_DEVICE(0x07b3, 0x0016) }, /* Unknown */
 	{ USB_DEVICE(0x07b3, 0x0017) }, /* OpticPro UT12/UT16/UT24 */
 	{ USB_DEVICE(0x07b3, 0x0400) }, /* OpticPro 1248U */
 	{ USB_DEVICE(0x07b3, 0x0401) }, /* OpticPro 1248U (another one) */
+	{ USB_DEVICE(0x07b3, 0x0403) },	/* U16B */
 	/* Primax/Colorado */
 	{ USB_DEVICE(0x0461, 0x0300) },	/* G2-300 #1 */
 	{ USB_DEVICE(0x0461, 0x0301) },	/* G2E-300 #1 */
@@ -282,6 +290,8 @@
 	/* Visioneer */
 	{ USB_DEVICE(0x04a7, 0x0211) },	/* OneTouch 7600 USB */
 	{ USB_DEVICE(0x04a7, 0x0221) },	/* OneTouch 5300 USB */
+	{ USB_DEVICE(0x04a7, 0x0224) },	/* OneTouch 4800 USB */
+	{ USB_DEVICE(0x04a7, 0x0226) },	/* OneTouch 5300 USB */
 	{ USB_DEVICE(0x04a7, 0x0231) },	/* 6100 USB */
 	{ USB_DEVICE(0x04a7, 0x0311) },	/* 6200 EPP/USB */
 	{ USB_DEVICE(0x04a7, 0x0321) },	/* OneTouch 8100 EPP/USB */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/serial/kobil_sct.c linux-2.4.22-pre2/drivers/usb/serial/kobil_sct.c
--- linux-2.4.21/drivers/usb/serial/kobil_sct.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/serial/kobil_sct.c	2003-06-26 21:43:15.000000000 +0000
@@ -21,7 +21,8 @@
  * Supported readers: USB TWIN, KAAN Standard Plus and SecOVID Reader Plus
  * (Adapter K), B1 Professional and KAAN Professional (Adapter B)
  * 
- * TODO: High baudrates
+ * (23/05/2003) tw
+ *      Add support for KAAN SIM
  *
  * (12/03/2002) tw
  *      Fixed bug with Pro-readers and PNP
@@ -66,6 +67,7 @@
 #define KOBIL_ADAPTER_B_PRODUCT_ID 0x2011
 #define KOBIL_ADAPTER_K_PRODUCT_ID 0x2012
 #define KOBIL_USBTWIN_PRODUCT_ID   0x0078
+#define KOBIL_KAAN_SIM_PRODUCT_ID  0x0081
 
 #define KOBIL_TIMEOUT    500
 #define KOBIL_BUF_LENGTH 300
@@ -89,6 +91,7 @@
 	{ USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_ADAPTER_B_PRODUCT_ID) },
 	{ USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_ADAPTER_K_PRODUCT_ID) },
 	{ USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_USBTWIN_PRODUCT_ID) },
+	{ USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_KAAN_SIM_PRODUCT_ID) },
 	{ }			/* Terminating entry */
 };
 
@@ -157,6 +160,9 @@
 	case KOBIL_USBTWIN_PRODUCT_ID:
 		printk(KERN_DEBUG "KOBIL USBTWIN detected\n");
 		break;
+	case KOBIL_KAAN_SIM_PRODUCT_ID:
+		printk(KERN_DEBUG "KOBIL KAAN SIM detected\n");
+		break;
 	}
 
 	// search for the neccessary endpoints
@@ -322,7 +328,8 @@
 		dbg("%s - port %d Send reset_all_queues URB returns: %i", __FUNCTION__, port->number, result);
 	}
 
-	if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) {
+	if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID ||
+	    priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) {
 		// start reading (Adapter B 'cause PNP string)
 		result = usb_submit_urb( port->interrupt_in_urb ); 
 		dbg("%s - port %d Send read URB returns: %i", __FUNCTION__, port->number, result);
@@ -444,12 +451,12 @@
 	priv->filled = priv->filled + count;
   
 
-	// only send complete block. TWIN and adapter K use the same protocol.
+	// only send complete block. TWIN, KAAN SIM and adapter K use the same protocol.
 	if ( ((priv->device_type != KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 2) && (priv->filled >= (priv->buf[1] + 3))) || 
 	     ((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 3) && (priv->filled >= (priv->buf[2] + 4))) ) {
 		
-		// stop reading (except TWIN)
-		if (priv->device_type != KOBIL_USBTWIN_PRODUCT_ID) {
+		// 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 );
 		}
 		
@@ -486,8 +493,8 @@
 		priv->filled = 0;
 		priv->cur_pos = 0;
 				
-		// start reading (except TWIN)	
-		if (priv->device_type != KOBIL_USBTWIN_PRODUCT_ID) {
+		// start reading (except TWIN and KAAN SIM)
+		if ( (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) || (priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) ) {
 			// someone sets the dev to 0 if the close method has been called
 			port->interrupt_in_urb->dev = port->serial->dev;
 		
@@ -519,7 +526,7 @@
 	char *settings;
 
 	priv = (struct kobil_private *) port->private;
-	if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) {
+	if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) {
 		// This device doesn't support ioctl calls
 		return 0;
 	}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/serial/pl2303.c linux-2.4.22-pre2/drivers/usb/serial/pl2303.c
--- linux-2.4.21/drivers/usb/serial/pl2303.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/serial/pl2303.c	2003-06-26 21:43:20.000000000 +0000
@@ -1,7 +1,8 @@
 /*
  * Prolific PL2303 USB to serial adaptor driver
  *
- * Copyright (C) 2001-2002 Greg Kroah-Hartman (greg@kroah.com)
+ * Copyright (C) 2001-2003 Greg Kroah-Hartman (greg@kroah.com)
+ * Copyright (C) 2003 IBM Corp.
  *
  * Original driver for 2.2.x by anonymous
  *
@@ -11,6 +12,8 @@
  *	(at your option) any later version.
  *
  * See Documentation/usb/usb-serial.txt for more information on using this driver
+ * 2003_Apr_24 gkh
+ *	Added line error reporting support.  Hopefully it is correct...
  *
  * 2001_Oct_06 gkh
  *	Added RTS and DTR line control.  Thanks to joe@bndlg.de for parts of it.
@@ -101,6 +104,16 @@
 #define VENDOR_READ_REQUEST_TYPE	0xc0
 #define VENDOR_READ_REQUEST		0x01
 
+#define UART_STATE			0x08
+#define UART_DCD			0x01
+#define UART_DSR			0x02
+#define UART_BREAK_ERROR		0x04
+#define UART_RING			0x08
+#define UART_FRAME_ERROR		0x10
+#define UART_PARITY_ERROR		0x20
+#define UART_OVERRUN_ERROR		0x40
+#define UART_CTS			0x80
+
 /* function prototypes for a PL2303 serial converter */
 static int pl2303_open (struct usb_serial_port *port, struct file *filp);
 static void pl2303_close (struct usb_serial_port *port, struct file *filp);
@@ -142,6 +155,7 @@
 
 struct pl2303_private { 
 	u8 line_control;
+	u8 line_status;
 	u8 termios_initialized;
 };
 
@@ -562,7 +576,7 @@
 		state = BREAK_ON;
 	dbg("%s - turning break %s", state==BREAK_OFF ? "off" : "on", __FUNCTION__);
 
-	result = usb_control_msg (serial->dev, usb_rcvctrlpipe (serial->dev, 0),
+	result = usb_control_msg (serial->dev, usb_sndctrlpipe (serial->dev, 0),
 				  BREAK_REQUEST, BREAK_REQUEST_TYPE, state, 
 				  0, NULL, 0, 100);
 	if (result)
@@ -585,10 +599,10 @@
 {
 	struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
 	struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
-	//unsigned char *data = urb->transfer_buffer;
-	//int i;
+	struct pl2303_private *priv = port->private;
+	unsigned char *data = urb->transfer_buffer;
 
-//ints auto restart...
+	/* ints auto restart... */
 
 	if (!serial) {
 		return;
@@ -600,9 +614,12 @@
 	}
 
 	usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, urb->transfer_buffer);
-#if 0
-//FIXME need to update state of terminal lines variable
-#endif
+
+	if (urb->actual_length > UART_STATE)
+		return;
+
+	/* Save off the uart status for others to look at */
+	priv->line_status = data[UART_STATE];
 
 	return;
 }
@@ -612,10 +629,13 @@
 {
 	struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
 	struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
+	struct pl2303_private *priv = port->private;
 	struct tty_struct *tty;
 	unsigned char *data = urb->transfer_buffer;
 	int i;
 	int result;
+	u8 status;
+	char tty_flag;
 
 	if (port_paranoia_check (port, __FUNCTION__))
 		return;
@@ -649,13 +669,31 @@
 
 	usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, data);
 
+	/* get tty_flag from status */
+	tty_flag = TTY_NORMAL;
+	status = priv->line_status;
+
+	/* break takes precedence over parity, */
+	/* which takes precedence over framing errors */
+	if (status & UART_BREAK_ERROR )
+		tty_flag = TTY_BREAK;
+	else if (status & UART_PARITY_ERROR)
+		tty_flag = TTY_PARITY;
+	else if (status & UART_FRAME_ERROR)
+		tty_flag = TTY_FRAME;
+	dbg("%s - tty_flag = %d", __FUNCTION__, tty_flag);
+
 	tty = port->tty;
 	if (tty && urb->actual_length) {
+		/* overrun is special, not associated with a char */
+		if (status & UART_OVERRUN_ERROR)
+			tty_insert_flip_char(tty, 0, TTY_OVERRUN);
+
 		for (i = 0; i < urb->actual_length; ++i) {
 			if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
 				tty_flip_buffer_push(tty);
 			}
-			tty_insert_flip_char (tty, data[i], 0);
+			tty_insert_flip_char (tty, data[i], tty_flag);
 		}
 		tty_flip_buffer_push (tty);
 	}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/serial/usbserial.c linux-2.4.22-pre2/drivers/usb/serial/usbserial.c
--- linux-2.4.21/drivers/usb/serial/usbserial.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/serial/usbserial.c	2003-06-26 21:43:19.000000000 +0000
@@ -556,6 +556,7 @@
 		else
 			generic_close(port, filp);
 		port->open_count = 0;
+		port->tty = NULL;
 	}
 
 	if (port->serial->type->owner)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/serial/visor.c linux-2.4.22-pre2/drivers/usb/serial/visor.c
--- linux-2.4.21/drivers/usb/serial/visor.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/serial/visor.c	2003-06-26 21:43:16.000000000 +0000
@@ -987,15 +987,3 @@
 
 MODULE_PARM(debug, "i");
 MODULE_PARM_DESC(debug, "Debug enabled or not");
-
-
-
-
-
-
-
-
-
-
-
-
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/speedcrc.c linux-2.4.22-pre2/drivers/usb/speedcrc.c
--- linux-2.4.21/drivers/usb/speedcrc.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/speedcrc.c	2003-06-26 21:43:29.000000000 +0000
@@ -0,0 +1,124 @@
+/******************************************************************************
+ *  speedcrc.c  --  CRC library for use with speedtouch.
+ *
+ *  Copyright (C) 2000, Johan Verrept
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the 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 <stddef.h>
+
+/*
+ * CRC Routines from  net/wan/sbni.c)
+ * table generated by Rocksoft^tm Model CRC Algorithm Table Generation Program V1.0
+ */
+#define CRC32_REMAINDER CBF43926
+#define CRC32_INITIAL 0xffffffff
+unsigned long crc32tab[256] = {
+	0x00000000L, 0x04C11DB7L, 0x09823B6EL, 0x0D4326D9L,
+	0x130476DCL, 0x17C56B6BL, 0x1A864DB2L, 0x1E475005L,
+	0x2608EDB8L, 0x22C9F00FL, 0x2F8AD6D6L, 0x2B4BCB61L,
+	0x350C9B64L, 0x31CD86D3L, 0x3C8EA00AL, 0x384FBDBDL,
+	0x4C11DB70L, 0x48D0C6C7L, 0x4593E01EL, 0x4152FDA9L,
+	0x5F15ADACL, 0x5BD4B01BL, 0x569796C2L, 0x52568B75L,
+	0x6A1936C8L, 0x6ED82B7FL, 0x639B0DA6L, 0x675A1011L,
+	0x791D4014L, 0x7DDC5DA3L, 0x709F7B7AL, 0x745E66CDL,
+	0x9823B6E0L, 0x9CE2AB57L, 0x91A18D8EL, 0x95609039L,
+	0x8B27C03CL, 0x8FE6DD8BL, 0x82A5FB52L, 0x8664E6E5L,
+	0xBE2B5B58L, 0xBAEA46EFL, 0xB7A96036L, 0xB3687D81L,
+	0xAD2F2D84L, 0xA9EE3033L, 0xA4AD16EAL, 0xA06C0B5DL,
+	0xD4326D90L, 0xD0F37027L, 0xDDB056FEL, 0xD9714B49L,
+	0xC7361B4CL, 0xC3F706FBL, 0xCEB42022L, 0xCA753D95L,
+	0xF23A8028L, 0xF6FB9D9FL, 0xFBB8BB46L, 0xFF79A6F1L,
+	0xE13EF6F4L, 0xE5FFEB43L, 0xE8BCCD9AL, 0xEC7DD02DL,
+	0x34867077L, 0x30476DC0L, 0x3D044B19L, 0x39C556AEL,
+	0x278206ABL, 0x23431B1CL, 0x2E003DC5L, 0x2AC12072L,
+	0x128E9DCFL, 0x164F8078L, 0x1B0CA6A1L, 0x1FCDBB16L,
+	0x018AEB13L, 0x054BF6A4L, 0x0808D07DL, 0x0CC9CDCAL,
+	0x7897AB07L, 0x7C56B6B0L, 0x71159069L, 0x75D48DDEL,
+	0x6B93DDDBL, 0x6F52C06CL, 0x6211E6B5L, 0x66D0FB02L,
+	0x5E9F46BFL, 0x5A5E5B08L, 0x571D7DD1L, 0x53DC6066L,
+	0x4D9B3063L, 0x495A2DD4L, 0x44190B0DL, 0x40D816BAL,
+	0xACA5C697L, 0xA864DB20L, 0xA527FDF9L, 0xA1E6E04EL,
+	0xBFA1B04BL, 0xBB60ADFCL, 0xB6238B25L, 0xB2E29692L,
+	0x8AAD2B2FL, 0x8E6C3698L, 0x832F1041L, 0x87EE0DF6L,
+	0x99A95DF3L, 0x9D684044L, 0x902B669DL, 0x94EA7B2AL,
+	0xE0B41DE7L, 0xE4750050L, 0xE9362689L, 0xEDF73B3EL,
+	0xF3B06B3BL, 0xF771768CL, 0xFA325055L, 0xFEF34DE2L,
+	0xC6BCF05FL, 0xC27DEDE8L, 0xCF3ECB31L, 0xCBFFD686L,
+	0xD5B88683L, 0xD1799B34L, 0xDC3ABDEDL, 0xD8FBA05AL,
+	0x690CE0EEL, 0x6DCDFD59L, 0x608EDB80L, 0x644FC637L,
+	0x7A089632L, 0x7EC98B85L, 0x738AAD5CL, 0x774BB0EBL,
+	0x4F040D56L, 0x4BC510E1L, 0x46863638L, 0x42472B8FL,
+	0x5C007B8AL, 0x58C1663DL, 0x558240E4L, 0x51435D53L,
+	0x251D3B9EL, 0x21DC2629L, 0x2C9F00F0L, 0x285E1D47L,
+	0x36194D42L, 0x32D850F5L, 0x3F9B762CL, 0x3B5A6B9BL,
+	0x0315D626L, 0x07D4CB91L, 0x0A97ED48L, 0x0E56F0FFL,
+	0x1011A0FAL, 0x14D0BD4DL, 0x19939B94L, 0x1D528623L,
+	0xF12F560EL, 0xF5EE4BB9L, 0xF8AD6D60L, 0xFC6C70D7L,
+	0xE22B20D2L, 0xE6EA3D65L, 0xEBA91BBCL, 0xEF68060BL,
+	0xD727BBB6L, 0xD3E6A601L, 0xDEA580D8L, 0xDA649D6FL,
+	0xC423CD6AL, 0xC0E2D0DDL, 0xCDA1F604L, 0xC960EBB3L,
+	0xBD3E8D7EL, 0xB9FF90C9L, 0xB4BCB610L, 0xB07DABA7L,
+	0xAE3AFBA2L, 0xAAFBE615L, 0xA7B8C0CCL, 0xA379DD7BL,
+	0x9B3660C6L, 0x9FF77D71L, 0x92B45BA8L, 0x9675461FL,
+	0x8832161AL, 0x8CF30BADL, 0x81B02D74L, 0x857130C3L,
+	0x5D8A9099L, 0x594B8D2EL, 0x5408ABF7L, 0x50C9B640L,
+	0x4E8EE645L, 0x4A4FFBF2L, 0x470CDD2BL, 0x43CDC09CL,
+	0x7B827D21L, 0x7F436096L, 0x7200464FL, 0x76C15BF8L,
+	0x68860BFDL, 0x6C47164AL, 0x61043093L, 0x65C52D24L,
+	0x119B4BE9L, 0x155A565EL, 0x18197087L, 0x1CD86D30L,
+	0x029F3D35L, 0x065E2082L, 0x0B1D065BL, 0x0FDC1BECL,
+	0x3793A651L, 0x3352BBE6L, 0x3E119D3FL, 0x3AD08088L,
+	0x2497D08DL, 0x2056CD3AL, 0x2D15EBE3L, 0x29D4F654L,
+	0xC5A92679L, 0xC1683BCEL, 0xCC2B1D17L, 0xC8EA00A0L,
+	0xD6AD50A5L, 0xD26C4D12L, 0xDF2F6BCBL, 0xDBEE767CL,
+	0xE3A1CBC1L, 0xE760D676L, 0xEA23F0AFL, 0xEEE2ED18L,
+	0xF0A5BD1DL, 0xF464A0AAL, 0xF9278673L, 0xFDE69BC4L,
+	0x89B8FD09L, 0x8D79E0BEL, 0x803AC667L, 0x84FBDBD0L,
+	0x9ABC8BD5L, 0x9E7D9662L, 0x933EB0BBL, 0x97FFAD0CL,
+	0xAFB010B1L, 0xAB710D06L, 0xA6322BDFL, 0xA2F33668L,
+	0xBCB4666DL, 0xB8757BDAL, 0xB5365D03L, 0xB1F740B4L
+};
+
+#ifdef CRCASM
+
+unsigned long spdcrc32 (char *mem, int len, unsigned initial)
+{
+	unsigned crc, dummy_len;
+      __asm__ ("xorl %%eax,%%eax\n\t" "1:\n\t" "movl %%edx,%%eax\n\t" "shrl $16,%%eax\n\t" "lodsb\n\t" "xorb %%ah,%%al\n\t" "andl $255,%%eax\n\t" "shll $8,%%edx\n\t" "xorl (%%edi,%%eax,4),%%edx\n\t" "loop 1b":"=d" (crc),
+		 "=c"
+		 (dummy_len)
+      :	 "S" (mem), "D" (&crc32tab[0]), "1" (len), "0" (initial)
+      :	 "eax");
+	return crc;
+}
+
+#else
+
+#define CRC32(c,crc) (crc32tab[((size_t)(crc>>24) ^ (c)) & 0xff] ^ (((crc) << 8)))
+
+unsigned long spdcrc32 (char *mem, int len, unsigned initial)
+{
+	unsigned crc;
+	crc = initial;
+
+	for (; len; mem++, len--) {
+		crc = CRC32 (*mem, crc);
+	}
+	return (crc);
+}
+#endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/speedcrc.h linux-2.4.22-pre2/drivers/usb/speedcrc.h
--- linux-2.4.21/drivers/usb/speedcrc.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/speedcrc.h	2003-06-26 21:43:11.000000000 +0000
@@ -0,0 +1,28 @@
+#ifndef _SPEEDCRC_H_
+#define _SPEEDCRC_H_
+
+/******************************************************************************
+ *  speedcrc.h  --  CRC library for use with speedtouch.
+ *
+ *  Copyright (C) 2000, Johan Verrept
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the 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.
+ *
+ ******************************************************************************/
+
+unsigned long spdcrc32 (char *mem, int len, unsigned initial);
+#define crc32_be(crc, mem, len) spdcrc32(mem, len, crc)
+
+#endif				/* _SPEEDCRC_H_ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/speedtouch.c linux-2.4.22-pre2/drivers/usb/speedtouch.c
--- linux-2.4.21/drivers/usb/speedtouch.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/speedtouch.c	2003-06-26 21:43:17.000000000 +0000
@@ -0,0 +1,1344 @@
+/******************************************************************************
+ *  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@wanadoo.fr)
+ *
+ *  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:	- Backport of 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/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/init.h>
+#include "speedcrc.h"
+
+/*
+#define DEBUG
+#define VERBOSE_DEBUG
+*/
+
+#include <linux/usb.h>
+
+
+#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@wanadoo.fr>"
+#define DRIVER_DESC	"Alcatel SpeedTouch USB driver"
+#define DRIVER_VERSION	"1.6"
+
+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		1
+#define UDSL_DEFAULT_SND_URBS		1
+#define UDSL_DEFAULT_RCV_BUFS		2
+#define UDSL_DEFAULT_SND_BUFS		2
+#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_PARM (num_rcv_urbs, "i");
+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_PARM (num_snd_urbs, "i");
+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_PARM (num_rcv_bufs, "i");
+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_PARM (num_snd_bufs, "i");
+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_PARM (rcv_buf_size, "i");
+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_PARM (snd_buf_size, "i");
+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 *skb;
+	unsigned int max_pdu;
+};
+
+/* 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, short vpi, int vci);
+static void udsl_atm_close (struct atm_vcc *vcc);
+static int udsl_atm_ioctl (struct atm_dev *dev, unsigned int cmd, void *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 void *udsl_usb_probe (struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *id);
+static void udsl_usb_disconnect (struct usb_device *dev, void *ptr);
+static int udsl_usb_ioctl (struct usb_device *hub, 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,
+};
+
+
+/*************
+**  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 *skb;
+	struct udsl_vcc_data *vcc_data;
+	int cached_vci = 0;
+	unsigned int i;
+	unsigned int length;
+	unsigned int pdu_length;
+	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;
+
+		if (!vcc_data->skb && !(vcc_data->skb = dev_alloc_skb (vcc_data->max_pdu))) {
+			dbg ("udsl_extract_cells: no memory for skb (vcc: 0x%p)!", vcc);
+			if (pti)
+				atomic_inc (&vcc->stats->rx_err);
+			continue;
+		}
+
+		skb = vcc_data->skb;
+
+		if (skb->len + ATM_CELL_PAYLOAD > vcc_data->max_pdu) {
+			dbg ("udsl_extract_cells: buffer overrun (max_pdu: %u, skb->len %u, vcc: 0x%p)", vcc_data->max_pdu, skb->len, vcc);
+			/* discard cells already received */
+			skb_trim (skb, 0);
+			BUG_ON (vcc_data->max_pdu < ATM_CELL_PAYLOAD);
+		}
+
+		memcpy (skb->tail, source + ATM_CELL_HEADER, ATM_CELL_PAYLOAD);
+		__skb_put (skb, ATM_CELL_PAYLOAD);
+
+		if (pti) {
+			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);
+				goto drop;
+			}
+
+			pdu_length = UDSL_NUM_CELLS (length) * ATM_CELL_PAYLOAD;
+
+			if (skb->len < pdu_length) {
+				dbg ("udsl_extract_cells: bogus pdu_length %u (skb->len: %u, vcc: 0x%p)", pdu_length, skb->len, vcc);
+				goto drop;
+			}
+
+			if (crc32_be (~0, skb->tail - pdu_length, pdu_length) != 0xc704dd7b) {
+				dbg ("udsl_extract_cells: packet failed crc check (vcc: 0x%p)", vcc);
+				goto drop;
+			}
+
+			if (!atm_charge (vcc, skb->truesize)) {
+				dbg ("udsl_extract_cells: failed atm_charge (skb->truesize: %u)", skb->truesize);
+				goto drop_no_stats; /* atm_charge increments rx_drop */
+			}
+
+			/* now that we are sure to send the skb, it is ok to change skb->data */
+			if (skb->len > pdu_length)
+				skb_pull (skb, skb->len - pdu_length); /* discard initial junk */
+
+			skb_trim (skb, length); /* drop zero padding and trailer */
+
+			atomic_inc (&vcc->stats->rx);
+
+			PACKETDEBUG (skb->data, skb->len);
+
+			vdbg ("udsl_extract_cells: sending skb 0x%p, skb->len %u, skb->truesize %u", skb, skb->len, skb->truesize);
+
+			vcc->push (vcc, skb);
+
+			vcc_data->skb = NULL;
+
+			continue;
+
+drop:
+			atomic_inc (&vcc->stats->rx_err);
+drop_no_stats:
+			skb_trim (skb, 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;
+
+		BUG_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 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);
+
+	BUG_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;
+
+		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);
+		rcv->urb->transfer_flags |= USB_QUEUE_BULK;
+
+		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)) < 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 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;
+	        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);
+		snd->urb->transfer_flags |= USB_QUEUE_BULK;
+
+		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)) < 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;
+
+		if (vcc->pop)
+			vcc->pop (vcc, skb);
+		else
+			dev_kfree_skb (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);
+			if (vcc->pop)
+				vcc->pop (vcc, skb);
+			else
+				dev_kfree_skb (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;
+		if (vcc->pop)
+			vcc->pop (vcc, skb);
+		else
+			dev_kfree_skb (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;
+
+	vdbg ("udsl_atm_send called (skb 0x%p, len %u)", skb, skb->len);
+
+	if (!instance || !instance->usb_dev) {
+		dbg ("udsl_atm_send: NULL data!");
+		return -ENODEV;
+	}
+
+	if (vcc->qos.aal != ATM_AAL5) {
+		dbg ("udsl_atm_send: unsupported ATM type %d!", vcc->qos.aal);
+		return -EINVAL;
+	}
+
+	if (skb->len > ATM_MAX_AAL5_PDU) {
+		dbg ("udsl_atm_send: packet too long (%d vs %d)!", skb->len, ATM_MAX_AAL5_PDU);
+		return -EINVAL;
+	}
+
+	PACKETDEBUG (skb->data, skb->len);
+
+	udsl_groom_skb (vcc, skb);
+	skb_queue_tail (&instance->sndqueue, skb);
+	tasklet_schedule (&instance->send_tasklet);
+
+	return 0;
+}
+
+
+/**********
+**  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, short vpi, int vci)
+{
+	struct udsl_instance_data *instance = vcc->dev->dev_data;
+	struct udsl_vcc_data *new;
+
+	dbg ("udsl_atm_open: vpi %hd, vci %d", vpi, vci);
+
+	if (!instance || !instance->usb_dev) {
+		dbg ("udsl_atm_open: NULL data!");
+		return -ENODEV;
+	}
+
+	if ((vpi == ATM_VPI_ANY) || (vci == ATM_VCI_ANY))
+		return -EINVAL;
+
+	/* only support AAL5 */
+	if ((vcc->qos.aal != ATM_AAL5) || (vcc->qos.rxtp.max_sdu < 0) || (vcc->qos.rxtp.max_sdu > ATM_MAX_AAL5_PDU))
+		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)) {
+		up (&instance->serialize);
+		return -EADDRINUSE;
+	}
+
+	if (!(new = kmalloc (sizeof (struct udsl_vcc_data), GFP_KERNEL))) {
+		up (&instance->serialize);
+		return -ENOMEM;
+	}
+
+	memset (new, 0, sizeof (struct udsl_vcc_data));
+	new->vcc = vcc;
+	new->vpi = vpi;
+	new->vci = vci;
+	new->max_pdu = max (1, UDSL_NUM_CELLS (vcc->qos.rxtp.max_sdu)) * ATM_CELL_PAYLOAD;
+
+	vcc->dev_data = new;
+	vcc->vpi = vpi;
+	vcc->vci = vci;
+
+	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, 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);
+
+	if (vcc_data->skb)
+		dev_kfree_skb (vcc_data->skb);
+	vcc_data->skb = 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 *arg)
+{
+	switch (cmd) {
+	case ATM_QUERYLOOP:
+		return put_user (ATM_LM_NONE, (int *) 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_device *dev, unsigned int code, void *user_data)
+{
+	struct usb_interface *intf = usb_ifnum_to_if (dev, 1);
+	struct udsl_instance_data *instance = intf->private_data;
+
+	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 void *udsl_usb_probe (struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *id)
+{
+	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 NULL;
+
+	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 NULL;
+	}
+
+	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))) {
+			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))) {
+			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, 0))) {
+		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 = snprintf (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;
+
+	return instance;
+
+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 NULL;
+}
+
+static void udsl_usb_disconnect (struct usb_device *dev, void *ptr)
+{
+	struct udsl_instance_data *instance = ptr;
+	struct list_head *pos;
+	unsigned int count;
+	int result, i;
+
+	dbg ("udsl_usb_disconnect entered");
+
+	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)
+			if (++count > num_rcv_urbs)
+				panic (__FILE__ ": memory corruption detected at line %d!\n", __LINE__);
+		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)
+			if (++count > num_snd_urbs)
+				panic (__FILE__ ": memory corruption detected at line %d!\n", __LINE__);
+		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)
+{
+	struct sk_buff *skb; /* dummy for sizeof */
+
+	dbg ("udsl_usb_init: driver version " DRIVER_VERSION);
+
+	if (sizeof (struct udsl_control) > sizeof (skb->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");
+
+
+/************
+**  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 -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/storage/protocol.h linux-2.4.22-pre2/drivers/usb/storage/protocol.h
--- linux-2.4.21/drivers/usb/storage/protocol.h	2001-11-22 19:49:34.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/storage/protocol.h	2003-06-26 21:43:19.000000000 +0000
@@ -57,6 +57,8 @@
 #define US_SC_MIN	US_SC_RBC
 #define US_SC_MAX	US_SC_ISD200
 
+#define US_SC_DEVICE	0xff		/* Use device's value */
+
 extern void usb_stor_ATAPI_command(Scsi_Cmnd*, struct us_data*);
 extern void usb_stor_qic157_command(Scsi_Cmnd*, struct us_data*);
 extern void usb_stor_ufi_command(Scsi_Cmnd*, struct us_data*);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/storage/transport.c linux-2.4.22-pre2/drivers/usb/storage/transport.c
--- linux-2.4.21/drivers/usb/storage/transport.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/storage/transport.c	2003-06-26 21:43:18.000000000 +0000
@@ -1250,7 +1250,7 @@
 	US_DEBUGP("Bulk status Sig 0x%x T 0x%x R %d Stat 0x%x\n",
 		  le32_to_cpu(bcs->Signature), bcs->Tag, 
 		  bcs->Residue, bcs->Status);
-	if (bcs->Signature != cpu_to_le32(US_BULK_CS_SIGN) || 
+	if ((bcs->Signature != cpu_to_le32(US_BULK_CS_SIGN) && bcs->Signature != cpu_to_le32(US_BULK_CS_OLYMPUS_SIGN)) ||
 	    bcs->Tag != bcb->Tag || 
 	    bcs->Status > US_BULK_STAT_PHASE || partial != 13) {
 		US_DEBUGP("Bulk logical error\n");
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/storage/transport.h linux-2.4.22-pre2/drivers/usb/storage/transport.h
--- linux-2.4.21/drivers/usb/storage/transport.h	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/storage/transport.h	2003-06-26 21:43:18.000000000 +0000
@@ -75,6 +75,8 @@
 #define US_PR_JUMPSHOT  0xf3            /* Lexar Jumpshot */
 #endif
 
+#define US_PR_DEVICE	0xff		/* Use device's value */
+
 /*
  * Bulk only data structures
  */
@@ -106,6 +108,8 @@
 
 #define US_BULK_CS_WRAP_LEN	13
 #define US_BULK_CS_SIGN		0x53425355	/* spells out 'USBS' */
+/* This is for Olympus Camedia digital cameras */
+#define US_BULK_CS_OLYMPUS_SIGN		0x55425355	/* spells out 'USBU' */
 #define US_BULK_STAT_OK		0
 #define US_BULK_STAT_FAIL	1
 #define US_BULK_STAT_PHASE	2
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/storage/unusual_devs.h linux-2.4.22-pre2/drivers/usb/storage/unusual_devs.h
--- linux-2.4.21/drivers/usb/storage/unusual_devs.h	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/storage/unusual_devs.h	2003-06-26 21:43:30.000000000 +0000
@@ -35,6 +35,14 @@
 
 /* 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.
+ *	- a copy of /proc/bus/usb/devices with your device plugged in
+ *	  running with this patch.
+ *
  */
 
 UNUSUAL_DEV(  0x03ee, 0x0000, 0x0000, 0x0245, 
@@ -90,6 +98,18 @@
 		"Nex II Digital",
 		US_SC_SCSI, US_PR_BULK, NULL, US_FL_START_STOP),
 
+/* Patch submitted by Philipp Friedrich <philipp@void.at> */
+UNUSUAL_DEV(  0x0482, 0x0100, 0x0100, 0x0100,
+		"Kyocera",
+		"Finecam S3x",
+		US_SC_8070, US_PR_CB, NULL, US_FL_FIX_INQUIRY),
+
+/* Patch submitted by Philipp Friedrich <philipp@void.at> */
+UNUSUAL_DEV(  0x0482, 0x0101, 0x0100, 0x0100,
+		"Kyocera",
+		"Finecam S4",
+		US_SC_8070, US_PR_CB, NULL, US_FL_FIX_INQUIRY),
+
 /* Reported by Paul Stewart <stewart@wetlogic.net>
  * This entry is needed because the device reports Sub=ff */
 UNUSUAL_DEV(  0x04a4, 0x0004, 0x0001, 0x0001,
@@ -222,10 +242,18 @@
 		US_SC_8070, US_PR_BULK, NULL,
 		US_FL_FIX_INQUIRY | US_FL_START_STOP ),
 
+/* Submitted by Lars Gemeinhardt <linux-usb@gemeinhardt.info>
+ * Needed for START_STOP flag */
+UNUSUAL_DEV(  0x0547, 0x2810, 0x0001, 0x0001,
+                "Mello",
+                "MP3 Player",
+		US_SC_SCSI, US_PR_BULK, NULL,
+		US_FL_START_STOP),
+
 /* This entry is needed because the device reports Sub=ff */
-UNUSUAL_DEV(  0x054c, 0x0010, 0x0106, 0x0440, 
+UNUSUAL_DEV(  0x054c, 0x0010, 0x0106, 0x0450, 
 		"Sony",
-		"DSC-S30/S70/S75/505V/F505/F707/F717", 
+		"DSC-S30/S70/S75/505V/F505/F707/F717/P8", 
 		US_SC_SCSI, US_PR_CB, NULL,
 		US_FL_SINGLE_LUN | US_FL_START_STOP | US_FL_MODE_XLATE ),
 
@@ -294,6 +322,26 @@
 		US_SC_SCSI, US_PR_BULK, NULL,
 		US_FL_START_STOP ),
 
+/* 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
+ *   of the SCSI layer ourselves.
+ * Tested on Rev. 10.00 (0x1000)
+ * Submitted by James Courtier-Dutton <James@superbug.demon.co.uk>
+ */
+UNUSUAL_DEV( 0x0a17, 0x0004, 0x1000, 0x1000,
+                "Pentax",
+                "Optio 2/3/400",
+                US_SC_8070, US_PR_CBI, NULL,
+                US_FL_FIX_INQUIRY ),
+
+/* Submitted by Per Winkvist <per.winkvist@uk.com> */
+UNUSUAL_DEV( 0x0a17, 0x006, 0x1000, 0x9009,
+                "Pentax",
+                "Optio S",
+                US_SC_8070, US_PR_CBI, NULL,
+                US_FL_FIX_INQUIRY ),
+
 #ifdef CONFIG_USB_STORAGE_ISD200
 UNUSUAL_DEV(  0x05ab, 0x0031, 0x0100, 0x0110,
                 "In-System",
@@ -364,6 +412,14 @@
 		US_SC_SCSI, US_PR_BULK, NULL,
 		US_FL_FIX_INQUIRY ),
 
+/* Reported by Hanno Boeck <hanno@gmx.de>
+ * Taken from the Lycoris Kernel */
+UNUSUAL_DEV(  0x0636, 0x0003, 0x0000, 0x9999,
+		"Vivitar",
+		"Vivicam 35Xx",
+		US_SC_SCSI, US_PR_BULK, NULL,
+		US_FL_FIX_INQUIRY | US_FL_MODE_XLATE),
+
 UNUSUAL_DEV(  0x0644, 0x0000, 0x0100, 0x0100, 
 		"TEAC",
 		"Floppy Drive",
@@ -543,6 +599,13 @@
                 US_SC_8070, US_PR_CB, NULL,
                 US_FL_FIX_INQUIRY ),
 
+/* Submitted by Hartmut Wahl <hwahl@hwahl.de>*/
+UNUSUAL_DEV( 0x0839, 0x000a, 0x0001, 0x0001,
+        "Samsung",
+        "Digimax 410",
+        US_SC_SCSI, US_PR_BULK, NULL,
+        US_FL_FIX_INQUIRY),
+                
 UNUSUAL_DEV(  0x097a, 0x0001, 0x0000, 0x0001,
 		"Minds@Work",
 		"Digital Wallet",
@@ -555,6 +618,16 @@
 		US_SC_SCSI, US_PR_BULK, NULL,
 		US_FL_FIX_INQUIRY ),
 		
+/* Pentax Optio S digital camera
+ * adapted from http://www2.goldfisch.at/knowledge/233
+ * (Peter Pilsl <pilsl@goldfisch.at>)
+ * by Christoph Weidemann <cweidema@indiana.edu> */
+UNUSUAL_DEV(  0x0a17, 0x0006, 0x0000, 0xffff,
+		"Pentax",
+		"Optio S",
+		US_SC_8070, US_PR_CB, NULL,
+		US_FL_MODE_XLATE|US_FL_FIX_INQUIRY),
+
 #ifdef CONFIG_USB_STORAGE_ISD200
 UNUSUAL_DEV(  0x0bf6, 0xa001, 0x0100, 0x0110,
                 "ATI",
@@ -594,3 +667,13 @@
 		US_SC_SCSI, US_PR_SDDR55, NULL,
 		US_FL_SINGLE_LUN),
 #endif
+
+/* Aiptek PocketCAM 3Mega
+ * Nicolas DUPEUX <nicolas@dupeux.net> 
+ */
+UNUSUAL_DEV(  0x08ca, 0x2011, 0x0000, 0x9999,
+	"AIPTEK",
+	"PocketCAM 3Mega",
+	US_SC_SCSI, US_PR_BULK, NULL,
+	US_FL_MODE_XLATE | US_FL_START_STOP),
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/storage/usb.c linux-2.4.22-pre2/drivers/usb/storage/usb.c
--- linux-2.4.21/drivers/usb/storage/usb.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/storage/usb.c	2003-06-26 21:43:14.000000000 +0000
@@ -621,8 +621,12 @@
 	US_DEBUGP("USB Mass Storage device detected\n");
 
 	/* Determine subclass and protocol, or copy from the interface */
-	subclass = unusual_dev->useProtocol;
-	protocol = unusual_dev->useTransport;
+	subclass = (unusual_dev->useProtocol == US_SC_DEVICE) ?
+			altsetting->bInterfaceSubClass :
+			unusual_dev->useProtocol;
+	protocol = (unusual_dev->useTransport == US_PR_DEVICE) ?
+			altsetting->bInterfaceProtocol :
+			unusual_dev->useTransport;
 	flags = unusual_dev->flags;
 
 	/*
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/storage/usb.h linux-2.4.22-pre2/drivers/usb/storage/usb.h
--- linux-2.4.21/drivers/usb/storage/usb.h	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/storage/usb.h	2003-06-26 21:43:29.000000000 +0000
@@ -155,7 +155,7 @@
 	/* thread information */
 	Scsi_Cmnd		*queue_srb;	 /* the single queue slot */
 	int			action;		 /* what to do		  */
-	int			pid;		 /* control thread	  */
+	pid_t			pid;		 /* control thread	  */
 
 	/* interrupt info for CBI devices -- only good if attached */
 	struct semaphore	ip_waitq;	 /* for CBI interrupts	 */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/usbnet.c linux-2.4.22-pre2/drivers/usb/usbnet.c
--- linux-2.4.21/drivers/usb/usbnet.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/usbnet.c	2003-06-26 21:43:10.000000000 +0000
@@ -1306,6 +1306,8 @@
 
 #ifdef CONFIG_USB_ZAURUS
 
+#include <linux/crc32.h>
+
 /*-------------------------------------------------------------------------
  *
  * Zaurus is also a SA-1110 based PDA, but one using a different driver
@@ -1318,57 +1320,6 @@
  *
  *-------------------------------------------------------------------------*/
 
-// NOTE: so far on 2.4 <linux/crc32.h> isn't for "bulk data" like this.
-// On 2.5 crc32_le() handles this for us.
-
-static const u32 crc32_table [256] = {
-    0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
-    0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
-    0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
-    0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
-    0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
-    0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
-    0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
-    0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
-    0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
-    0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
-    0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
-    0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
-    0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
-    0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
-    0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
-    0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
-    0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
-    0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
-    0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
-    0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
-    0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
-    0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
-    0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
-    0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
-    0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
-    0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
-    0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
-    0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
-    0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
-    0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
-    0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
-    0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
-};
-
-#define CRC32_INITFCS     0xffffffff  // Initial FCS value 
-#define CRC32_FCS(fcs, c) (((fcs) >> 8) ^ crc32_table[((fcs) ^ (c)) & 0xff])
-
-/* fcs_compute32 - memcpy and calculate fcs
- * Perform a memcpy and calculate fcs using ppp 32bit CRC algorithm.
- */
-static inline u32 fcs_compute32 (unsigned char *sp, int len, u32 fcs)
-{
-	for (;len-- > 0; fcs = CRC32_FCS (fcs, *sp++))
-		continue;
-	return fcs;
-}
-
 static struct sk_buff *
 zaurus_tx_fixup (struct usbnet *dev, struct sk_buff *skb, int flags)
 {
@@ -1387,7 +1338,7 @@
 	if (skb) {
 		u32		fcs;
 done:
-		fcs = fcs_compute32 (skb->data, skb->len, CRC32_INITFCS);
+		fcs = crc32_le (~0, skb->data, skb->len);
 		fcs = ~fcs;
 
 		*skb_put (skb, 1) = fcs       & 0xff;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/drivers/usb/vicam.c linux-2.4.22-pre2/drivers/usb/vicam.c
--- linux-2.4.21/drivers/usb/vicam.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/drivers/usb/vicam.c	2003-06-26 21:43:12.000000000 +0000
@@ -1,6 +1,10 @@
 /*
  * USB ViCam WebCam driver
- * Copyright (c) 2002 Joe Burks (jburks@wavicle.org)
+ * Copyright (c) 2002 Joe Burks (jburks@wavicle.org),
+ *                    Christopher L Cheney (ccheney@cheney.cx),
+ *                    Pavel Machek (pavel@suse.cz),
+ *                    John Tyner (jtyner@cs.ucr.edu),
+ *                    Monroe Williams (monroe@pobox.com)
  *
  * Supports 3COM HomeConnect PC Digital WebCam
  *
@@ -18,8 +22,17 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * This source code is based heavily on the CPiA webcam driver
- * */
+ * This source code is based heavily on the CPiA webcam driver which was
+ * written by Peter Pregler, Scott J. Bertin and Johannes Erdfelt
+ *
+ * Portions of this code were also copied from usbvideo.c
+ *
+ * Special thanks to the the whole team at Sourceforge for help making
+ * this driver become a reality.  Notably:
+ * Andy Armstrong who reverse engineered the color encoding and
+ * Pavel Machek and Chris Cheney who worked on reverse engineering the
+ *    camera controls and wrote the first generation driver.
+ */
 
 #include <linux/kernel.h>
 #include <linux/wrapper.h>
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/Makefile.lib linux-2.4.22-pre2/fs/Makefile.lib
--- linux-2.4.21/fs/Makefile.lib	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/fs/Makefile.lib	2003-06-26 21:43:17.000000000 +0000
@@ -0,0 +1,2 @@
+obj-$(CONFIG_JFFS2_FS)		+= crc32.o
+obj-$(CONFIG_EFI_PARTITION)	+= crc32.o
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/autofs4/root.c linux-2.4.22-pre2/fs/autofs4/root.c
--- linux-2.4.21/fs/autofs4/root.c	2002-08-03 00:39:45.000000000 +0000
+++ linux-2.4.22-pre2/fs/autofs4/root.c	2003-06-26 21:43:10.000000000 +0000
@@ -148,7 +148,6 @@
 {
 	struct inode * dir = dentry->d_parent->d_inode;
 	struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
-	struct autofs_info *ino;
 	int oz_mode = autofs4_oz_mode(sbi);
 
 	/* Pending dentry */
@@ -163,8 +162,6 @@
 	if (dentry->d_inode == NULL)
 		return (dentry->d_time - jiffies <= AUTOFS_NEGATIVE_TIMEOUT);
 
-	ino = autofs4_dentry_ino(dentry);
-
 	/* Check for a non-mountpoint directory with no contents */
 	spin_lock(&dcache_lock);
 	if (S_ISDIR(dentry->d_inode->i_mode) &&
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/buffer.c linux-2.4.22-pre2/fs/buffer.c
--- linux-2.4.21/fs/buffer.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/fs/buffer.c	2003-06-26 21:43:27.000000000 +0000
@@ -436,26 +436,18 @@
 	return ret;
 }
 
-asmlinkage long sys_fdatasync(unsigned int fd)
+int do_fdatasync(struct file *file)
 {
-	struct file * file;
-	struct dentry * dentry;
-	struct inode * inode;
 	int ret, err;
+	struct dentry *dentry;
+	struct inode *inode;
 
-	ret = -EBADF;
-	file = fget(fd);
-	if (!file)
-		goto out;
-
+	if (unlikely(!file->f_op || !file->f_op->fsync))
+		return -EINVAL;
+	
 	dentry = file->f_dentry;
 	inode = dentry->d_inode;
 
-	ret = -EINVAL;
-	if (!file->f_op || !file->f_op->fsync)
-		goto out_putf;
-
-	down(&inode->i_sem);
 	ret = filemap_fdatasync(inode->i_mapping);
 	err = file->f_op->fsync(file, dentry, 1);
 	if (err && !ret)
@@ -463,6 +455,23 @@
 	err = filemap_fdatawait(inode->i_mapping);
 	if (err && !ret)
 		ret = err;
+	return ret;
+}
+
+asmlinkage long sys_fdatasync(unsigned int fd)
+{
+	struct file * file;
+	struct inode *inode;
+	int ret;
+
+	ret = -EBADF;
+	file = fget(fd);
+	if (!file)
+		goto out;
+
+	inode = file->f_dentry->d_inode;
+	down(&inode->i_sem);
+	ret = do_fdatasync(file);
 	up(&inode->i_sem);
 
 out_putf:
@@ -2106,7 +2115,8 @@
 	int i, nr_blocks, retval;
 	unsigned long * blocks = iobuf->blocks;
 	int length;
-
+	int beyond_eof = 0;
+	
 	length = iobuf->length;
 	nr_blocks = length / blocksize;
 	/* build the blocklist */
@@ -2116,14 +2126,22 @@
 		bh.b_state = 0;
 		bh.b_dev = inode->i_dev;
 		bh.b_size = blocksize;
+		bh.b_page = NULL;
+
+		if (((loff_t) blocknr) * blocksize >= inode->i_size)
+			beyond_eof = 1;
+
+		/* Only allow get_block to create new blocks if we are safely
+		   beyond EOF.  O_DIRECT is unsafe inside sparse files. */
+		retval = get_block(inode, blocknr, &bh, 
+				   ((rw != READ) && beyond_eof));
 
-		retval = get_block(inode, blocknr, &bh, rw == READ ? 0 : 1);
 		if (retval) {
 			if (!i)
 				/* report error to userspace */
 				goto out;
 			else
-				/* do short I/O utill 'i' */
+				/* do short I/O until 'i' */
 				break;
 		}
 
@@ -2139,14 +2157,20 @@
 			if (buffer_new(&bh))
 				unmap_underlying_metadata(&bh);
 			if (!buffer_mapped(&bh))
-				BUG();
+				/* upper layers need to pass the error on or
+				 * fall back to buffered IO. */
+				return -ENOTBLK;
 		}
 		blocks[i] = bh.b_blocknr;
 	}
 
 	/* patch length to handle short I/O */
 	iobuf->length = i * blocksize;
+	if (!beyond_eof)
+		up(&inode->i_sem);
 	retval = brw_kiovec(rw, 1, &iobuf, inode->i_dev, iobuf->blocks, blocksize);
+	if (!beyond_eof)
+		down(&inode->i_sem);
 	/* restore orig length */
 	iobuf->length = length;
  out:
@@ -2187,9 +2211,7 @@
 	for (i = nr; --i >= 0; ) {
 		iosize += size;
 		tmp = bh[i];
-		if (buffer_locked(tmp)) {
-			wait_on_buffer(tmp);
-		}
+		wait_on_buffer(tmp);
 		
 		if (!buffer_uptodate(tmp)) {
 			/* We are traversing bh'es in reverse order so
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/hfs/mdb.c linux-2.4.22-pre2/fs/hfs/mdb.c
--- linux-2.4.21/fs/hfs/mdb.c	2001-02-13 22:13:45.000000000 +0000
+++ linux-2.4.22-pre2/fs/hfs/mdb.c	2003-06-26 21:43:18.000000000 +0000
@@ -197,7 +197,7 @@
 
 	if (!(mdb->attrib & htons(HFS_SB_ATTRIB_CLEAN))) {
 		hfs_warn("hfs_fs: WARNING: mounting unclean filesystem.\n");
-	} else if (!readonly) {
+	} else if (!readonly && !(mdb->attrib & (HFS_SB_ATTRIB_HLOCK | HFS_SB_ATTRIB_SLOCK))) {
 		/* Mark the volume uncleanly unmounted in case we crash */
 		hfs_put_ns(mdb->attrib & htons(~HFS_SB_ATTRIB_CLEAN),
 			   raw->drAtrb);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/hfs/super.c linux-2.4.22-pre2/fs/hfs/super.c
--- linux-2.4.21/fs/hfs/super.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/fs/hfs/super.c	2003-06-26 21:43:17.000000000 +0000
@@ -49,6 +49,7 @@
 	put_super:	hfs_put_super,
 	write_super:	hfs_write_super,
 	statfs:		hfs_statfs,
+	remount_fs:     hfs_remount,
 };
 
 /*================ File-local variables ================*/
@@ -162,23 +163,24 @@
 	char *this_char, *value;
 	char names, fork;
 
-	/* initialize the sb with defaults */
-	memset(hsb, 0, sizeof(*hsb));
-	hsb->magic = HFS_SB_MAGIC;
-	hsb->s_uid   = current->uid;
-	hsb->s_gid   = current->gid;
-	hsb->s_umask = current->fs->umask;
-	hsb->s_type    = 0x3f3f3f3f;	/* == '????' */
-	hsb->s_creator = 0x3f3f3f3f;	/* == '????' */
-	hsb->s_lowercase = 0;
-	hsb->s_quiet     = 0;
-	hsb->s_afpd      = 0;
-        /* default version. 0 just selects the defaults */
-	hsb->s_version   = 0; 
-	hsb->s_conv = 'b';
-	names = '?';
-	fork = '?';
-	*part = 0;
+	if (hsb->magic != HFS_SB_MAGIC) {
+		/* initialize the sb with defaults */
+		hsb->magic = HFS_SB_MAGIC;
+		hsb->s_uid   = current->uid;
+		hsb->s_gid   = current->gid;
+		hsb->s_umask = current->fs->umask;
+		hsb->s_type    = 0x3f3f3f3f;	/* == '????' */
+		hsb->s_creator = 0x3f3f3f3f;	/* == '????' */
+		hsb->s_lowercase = 0;
+		hsb->s_quiet     = 0;
+		hsb->s_afpd      = 0;
+		/* default version. 0 just selects the defaults */
+		hsb->s_version   = 0; 
+		hsb->s_conv = 'b';
+		names = '?';
+		fork = '?';
+		*part = 0;
+	}
 
 	if (!options) {
 		goto done;
@@ -397,6 +399,7 @@
 	struct inode *root_inode;
 	int part;
 
+	memset(HFS_SB(s), 0, sizeof(*(HFS_SB(s))));	
 	if (!parse_options((char *)data, HFS_SB(s), &part)) {
 		hfs_warn("hfs_fs: unable to parse mount options.\n");
 		goto bail3;
@@ -480,6 +483,27 @@
 	return NULL;	
 }
 
+int hfs_remount(struct super_block *s, int *flags, char *data)
+{
+        int part; /* ignored */
+
+        if (!parse_options(data, HFS_SB(s), &part)) {
+                hfs_warn("hfs_fs: unable to parse mount options.\n");
+                return -EINVAL;
+	}
+
+        if ((*flags & MS_RDONLY) == (s->s_flags & MS_RDONLY))
+                return 0;
+	if (!(*flags & MS_RDONLY)) {
+                if (HFS_SB(s)->s_mdb->attrib & (HFS_SB_ATTRIB_HLOCK | HFS_SB_ATTRIB_SLOCK)) {
+                        hfs_warn("hfs_fs: Filesystem is marked locked, leaving it read-only.\n");
+		        s->s_flags |= MS_RDONLY;
+			*flags |= MS_RDONLY;
+	        }
+        }
+	return 0;
+}
+
 static int __init init_hfs_fs(void)
 {
         hfs_cat_init();
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/inode.c linux-2.4.22-pre2/fs/inode.c
--- linux-2.4.21/fs/inode.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/fs/inode.c	2003-06-26 21:43:33.000000000 +0000
@@ -150,6 +150,7 @@
 	INIT_LIST_HEAD(&inode->i_devices);
 	sema_init(&inode->i_sem, 1);
 	sema_init(&inode->i_zombie, 1);
+	init_rwsem(&inode->i_alloc_sem);
 	spin_lock_init(&inode->i_data.i_shared_lock);
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/jffs2/Makefile linux-2.4.22-pre2/fs/jffs2/Makefile
--- linux-2.4.21/fs/jffs2/Makefile	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/fs/jffs2/Makefile	2003-06-26 21:43:13.000000000 +0000
@@ -12,7 +12,7 @@
 
 COMPR_OBJS	:= compr.o compr_rubin.o compr_rtime.o pushpull.o \
 			compr_zlib.o
-JFFS2_OBJS	:= crc32.o dir.o file.o ioctl.o nodelist.o malloc.o \
+JFFS2_OBJS	:= dir.o file.o ioctl.o nodelist.o malloc.o \
 	read.o nodemgmt.o readinode.o super.o write.o scan.o gc.o \
 	symlink.o build.o erase.o background.o
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/jffs2/crc32.c linux-2.4.22-pre2/fs/jffs2/crc32.c
--- linux-2.4.21/fs/jffs2/crc32.c	2001-09-14 21:04:07.000000000 +0000
+++ linux-2.4.22-pre2/fs/jffs2/crc32.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,97 +0,0 @@
-/*
- *  COPYRIGHT (C) 1986 Gary S. Brown.  You may use this program, or
- *  code or tables extracted from it, as desired without restriction.
- *
- *  First, the polynomial itself and its table of feedback terms.  The
- *  polynomial is
- *  X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0
- *
- *  Note that we take it "backwards" and put the highest-order term in
- *  the lowest-order bit.  The X^32 term is "implied"; the LSB is the
- *  X^31 term, etc.  The X^0 term (usually shown as "+1") results in
- *  the MSB being 1
- *
- *  Note that the usual hardware shift register implementation, which
- *  is what we're using (we're merely optimizing it by doing eight-bit
- *  chunks at a time) shifts bits into the lowest-order term.  In our
- *  implementation, that means shifting towards the right.  Why do we
- *  do it this way?  Because the calculated CRC must be transmitted in
- *  order from highest-order term to lowest-order term.  UARTs transmit
- *  characters in order from LSB to MSB.  By storing the CRC this way
- *  we hand it to the UART in the order low-byte to high-byte; the UART
- *  sends each low-bit to hight-bit; and the result is transmission bit
- *  by bit from highest- to lowest-order term without requiring any bit
- *  shuffling on our part.  Reception works similarly
- *
- *  The feedback terms table consists of 256, 32-bit entries.  Notes
- *
- *      The table can be generated at runtime if desired; code to do so
- *      is shown later.  It might not be obvious, but the feedback
- *      terms simply represent the results of eight shift/xor opera
- *      tions for all combinations of data and CRC register values
- *
- *      The values must be right-shifted by eight bits by the "updcrc
- *      logic; the shift must be unsigned (bring in zeroes).  On some
- *      hardware you could probably optimize the shift in assembler by
- *      using byte-swap instructions
- *      polynomial $edb88320
- */
-
-/* $Id: crc32.c,v 1.3 2001/02/07 16:45:32 dwmw2 Exp $ */
-
-#include "crc32.h"
-
-const __u32 crc32_table[256] = {
-	0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
-	0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
-	0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
-	0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
-	0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
-	0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
-	0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
-	0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
-	0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
-	0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
-	0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
-	0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
-	0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
-	0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
-	0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
-	0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
-	0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
-	0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
-	0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
-	0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
-	0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
-	0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
-	0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
-	0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
-	0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
-	0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
-	0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
-	0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
-	0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
-	0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
-	0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
-	0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
-	0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
-	0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
-	0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
-	0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
-	0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
-	0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
-	0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
-	0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
-	0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
-	0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
-	0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
-	0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
-	0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
-	0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
-	0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
-	0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
-	0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
-	0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
-	0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
-	0x2d02ef8dL
-};
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/jffs2/crc32.h linux-2.4.22-pre2/fs/jffs2/crc32.h
--- linux-2.4.21/fs/jffs2/crc32.h	2001-09-14 21:04:07.000000000 +0000
+++ linux-2.4.22-pre2/fs/jffs2/crc32.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,21 +0,0 @@
-#ifndef CRC32_H
-#define CRC32_H
-
-/* $Id: crc32.h,v 1.3 2001/02/26 14:44:37 dwmw2 Exp $ */
-
-#include <linux/types.h>
-
-extern const __u32 crc32_table[256];
-
-/* Return a 32-bit CRC of the contents of the buffer. */
-
-static inline __u32 
-crc32(__u32 val, const void *ss, int len)
-{
-	const unsigned char *s = ss;
-        while (--len >= 0)
-                val = crc32_table[(val ^ *s++) & 0xff] ^ (val >> 8);
-        return val;
-}
-
-#endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/jffs2/dir.c linux-2.4.22-pre2/fs/jffs2/dir.c
--- linux-2.4.21/fs/jffs2/dir.c	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/fs/jffs2/dir.c	2003-06-26 21:43:30.000000000 +0000
@@ -43,7 +43,7 @@
 #include <linux/jffs2_fs_i.h>
 #include <linux/jffs2_fs_sb.h>
 #include "nodelist.h"
-#include "crc32.h"
+#include <linux/crc32.h>
 
 static int jffs2_readdir (struct file *, void *, filldir_t);
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/jffs2/erase.c linux-2.4.22-pre2/fs/jffs2/erase.c
--- linux-2.4.21/fs/jffs2/erase.c	2002-08-03 00:39:45.000000000 +0000
+++ linux-2.4.22-pre2/fs/jffs2/erase.c	2003-06-26 21:43:11.000000000 +0000
@@ -40,7 +40,7 @@
 #include <linux/jffs2.h>
 #include <linux/interrupt.h>
 #include "nodelist.h"
-#include "crc32.h"
+#include <linux/crc32.h>
 
 struct erase_priv_struct {
 	struct jffs2_eraseblock *jeb;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/jffs2/file.c linux-2.4.22-pre2/fs/jffs2/file.c
--- linux-2.4.21/fs/jffs2/file.c	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/fs/jffs2/file.c	2003-06-26 21:43:21.000000000 +0000
@@ -42,7 +42,7 @@
 #include <linux/pagemap.h>
 #include <linux/jffs2.h>
 #include "nodelist.h"
-#include "crc32.h"
+#include <linux/crc32.h>
 
 extern int generic_file_open(struct inode *, struct file *) __attribute__((weak));
 extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin) __attribute__((weak));
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/jffs2/gc.c linux-2.4.22-pre2/fs/jffs2/gc.c
--- linux-2.4.21/fs/jffs2/gc.c	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/fs/jffs2/gc.c	2003-06-26 21:43:14.000000000 +0000
@@ -43,7 +43,7 @@
 #include <linux/interrupt.h>
 #include <linux/pagemap.h>
 #include "nodelist.h"
-#include "crc32.h"
+#include <linux/crc32.h>
 
 static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 
 					struct inode *inode, struct jffs2_full_dnode *fd);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/jffs2/read.c linux-2.4.22-pre2/fs/jffs2/read.c
--- linux-2.4.21/fs/jffs2/read.c	2002-08-03 00:39:45.000000000 +0000
+++ linux-2.4.22-pre2/fs/jffs2/read.c	2003-06-26 21:43:16.000000000 +0000
@@ -40,7 +40,7 @@
 #include <linux/jffs2.h>
 #include <linux/mtd/mtd.h>
 #include "nodelist.h"
-#include "crc32.h"
+#include <linux/crc32.h>
 
 int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_full_dnode *fd, unsigned char *buf, int ofs, int len)
 {
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/jffs2/readinode.c linux-2.4.22-pre2/fs/jffs2/readinode.c
--- linux-2.4.21/fs/jffs2/readinode.c	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/fs/jffs2/readinode.c	2003-06-26 21:43:11.000000000 +0000
@@ -44,7 +44,7 @@
 #include <linux/mtd/mtd.h>
 #include <linux/jffs2.h>
 #include "nodelist.h"
-#include "crc32.h"
+#include <linux/crc32.h>
 
 
 D1(void jffs2_print_frag_list(struct jffs2_inode_info *f)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/jffs2/scan.c linux-2.4.22-pre2/fs/jffs2/scan.c
--- linux-2.4.21/fs/jffs2/scan.c	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/fs/jffs2/scan.c	2003-06-26 21:43:18.000000000 +0000
@@ -40,7 +40,7 @@
 #include <linux/mtd/mtd.h>
 #include <linux/pagemap.h>
 #include "nodelist.h"
-#include "crc32.h"
+#include <linux/crc32.h>
 
 
 #define DIRTY_SPACE(x) do { typeof(x) _x = (x); \
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/jffs2/write.c linux-2.4.22-pre2/fs/jffs2/write.c
--- linux-2.4.21/fs/jffs2/write.c	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/fs/jffs2/write.c	2003-06-26 21:43:20.000000000 +0000
@@ -40,7 +40,7 @@
 #include <linux/jffs2.h>
 #include <linux/mtd/mtd.h>
 #include "nodelist.h"
-#include "crc32.h"
+#include <linux/crc32.h>
 
 /* jffs2_new_inode: allocate a new inode and inocache, add it to the hash,
    fill in the raw_inode while you're at it. */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/jfs/resize.c linux-2.4.22-pre2/fs/jfs/resize.c
--- linux-2.4.21/fs/jfs/resize.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/fs/jfs/resize.c	2003-06-26 21:43:32.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- *   Copyright (c) International Business Machines  Corp., 2000-2002
+ *   Copyright (c) International Business Machines  Corp., 2000-2003
  *
  *   This program is free software;  you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -351,7 +351,7 @@
 
 	/* need to grow map file ? */
 	if (nPages == newNpages)
-		goto updateImap;
+		goto finalizeBmap;
 
 	/*
 	 * grow bmap file for the new map pages required:
@@ -415,6 +415,7 @@
 	if (XSize)
 		goto extendBmap;
 
+      finalizeBmap:
 	/* finalize bmap */
 	dbFinalizeBmap(ipbmap);
 
@@ -428,7 +429,6 @@
 	 * (computation of ag number from agstart based on agsize
 	 * will correctly identify the new ag);
 	 */
-      updateImap:
 	/* if new AG size the same as old AG size, done! */
 	if (bmp->db_agsize != old_agsize) {
 		if ((rc = diExtendFS(ipimap, ipbmap)))
@@ -486,8 +486,8 @@
 
 	/* mark extendfs() completion */
 	j_sb->s_state &= cpu_to_le32(~FM_EXTENDFS);
-	j_sb->s_size = cpu_to_le64(bmp->db_mapsize) <<
-		       le16_to_cpu(j_sb->s_l2bfactor);
+	j_sb->s_size = cpu_to_le64(bmp->db_mapsize <<
+				   le16_to_cpu(j_sb->s_l2bfactor));
 	j_sb->s_agsize = cpu_to_le32(bmp->db_agsize);
 
 	/* update inline log space descriptor */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/nfsd/nfsfh.c linux-2.4.22-pre2/fs/nfsd/nfsfh.c
--- linux-2.4.21/fs/nfsd/nfsfh.c	2003-06-26 21:45:11.000000000 +0000
+++ linux-2.4.22-pre2/fs/nfsd/nfsfh.c	2003-06-26 21:43:17.000000000 +0000
@@ -697,33 +697,23 @@
 	error = 0;
 
 	if (!(exp->ex_flags & NFSEXP_NOSUBTREECHECK)) {
-		if (exp->ex_dentry != dentry) {
-			struct dentry *tdentry = dentry;
+		struct dentry *tdentry = dentry;
 
-			do {
-				tdentry = tdentry->d_parent;
-				if (exp->ex_dentry == tdentry)
-					break;
-				/* executable only by root and we can't be root */
-				if (current->fsuid
-				    && (exp->ex_flags & NFSEXP_ROOTSQUASH)
-				    && !(tdentry->d_inode->i_uid
-					 && (tdentry->d_inode->i_mode & S_IXUSR))
-				    && !(tdentry->d_inode->i_gid
-					 && (tdentry->d_inode->i_mode & S_IXGRP))
-				    && !(tdentry->d_inode->i_mode & S_IXOTH)
-					) {
-					error = nfserr_stale;
-					dprintk("fh_verify: no root_squashed access.\n");
-				}
-			} while ((tdentry != tdentry->d_parent));
-			if (exp->ex_dentry != tdentry) {
-				error = nfserr_stale;
-				printk("nfsd Security: %s/%s bad export.\n",
-				       dentry->d_parent->d_name.name,
-				       dentry->d_name.name);
-				goto out;
-			}
+		while (tdentry != exp->ex_dentry && !IS_ROOT(tdentry)) {
+			struct dentry *parent = tdentry->d_parent;
+
+			/* make sure parents give x permission to user */
+			error = permission(parent->d_inode, MAY_EXEC);
+			if (error)
+				break;
+			tdentry = parent;
+		}
+		if (exp->ex_dentry != tdentry) {
+			error = nfserr_stale;
+			printk("fh_verify: no root_squashed access at %s/%s.\n",
+			       dentry->d_parent->d_name.name,
+			       dentry->d_name.name);
+			goto out;
 		}
 	}
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/open.c linux-2.4.22-pre2/fs/open.c
--- linux-2.4.21/fs/open.c	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/fs/open.c	2003-06-26 21:43:11.000000000 +0000
@@ -105,11 +105,13 @@
 	if (length < 0)
 		return -EINVAL;
 
+	down_write(&inode->i_alloc_sem);
 	down(&inode->i_sem);
 	newattrs.ia_size = length;
 	newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
 	error = notify_change(dentry, &newattrs);
 	up(&inode->i_sem);
+	up_write(&inode->i_alloc_sem);
 	return error;
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/fs/partitions/efi.c linux-2.4.22-pre2/fs/partitions/efi.c
--- linux-2.4.21/fs/partitions/efi.c	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/fs/partitions/efi.c	2003-06-26 21:43:22.000000000 +0000
@@ -99,6 +99,7 @@
 #include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/init.h>
+#include <linux/crc32.h>
 #include <asm/system.h>
 #include <asm/byteorder.h>
 #include "check.h"
@@ -138,73 +139,6 @@
 }
 __setup("gpt", force_gpt_fn);
 
-
-/*
- * There are multiple 16-bit CRC polynomials in common use, but this is
- * *the* standard CRC-32 polynomial, first popularized by Ethernet.
- * x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x^1+x^0
- */
-#define CRCPOLY_LE 0xedb88320
-/* How many bits at a time to use.  Requires a table of 4<<CRC_xx_BITS bytes. */
-/* For less performance-sensitive, use 4 */
-#define CRC_LE_BITS 8
-static u32 *crc32table_le;
-
-/**
- * crc32init_le() - allocate and initialize LE table data
- *
- * crc is the crc of the byte i; other entries are filled in based on the
- * fact that crctable[i^j] = crctable[i] ^ crctable[j].
- *
- */
-static int __init crc32init_le(void)
-{
-	unsigned i, j;
-	u32 crc = 1;
-
-	crc32table_le =
-	    kmalloc((1 << CRC_LE_BITS) * sizeof(u32), GFP_KERNEL);
-	if (!crc32table_le)
-		return 1;
-	crc32table_le[0] = 0;
-
-	for (i = 1 << (CRC_LE_BITS - 1); i; i >>= 1) {
-		crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
-		for (j = 0; j < 1 << CRC_LE_BITS; j += 2 * i)
-			crc32table_le[i + j] = crc ^ crc32table_le[j];
-	}
-	return 0;
-}
-
-/**
- * crc32cleanup_le(): free LE table data
- */
-static void __exit crc32cleanup_le(void)
-{
-	if (crc32table_le) kfree(crc32table_le);
-	crc32table_le = NULL;
-}
-
-__initcall(crc32init_le);
-__exitcall(crc32cleanup_le);
-
-/**
- * crc32_le() - Calculate bitwise little-endian Ethernet AUTODIN II CRC32
- * @crc - seed value for computation.  ~0 for Ethernet, sometimes 0 for
- *        other uses, or the previous crc32 value if computing incrementally.
- * @p   - pointer to buffer over which CRC is run
- * @len - length of buffer @p
- * 
- */
-static u32 crc32_le(u32 crc, unsigned char const *p, size_t len)
-{
-	while (len--) {
-		crc = (crc >> 8) ^ crc32table_le[(crc ^ *p++) & 255];
-	}
-	return crc;
-}
-
-
 /**
  * efi_crc32() - EFI version of crc32 function
  * @buf: buffer to calculate crc32 of
@@ -220,7 +154,7 @@
 static inline u32
 efi_crc32(const void *buf, unsigned long len)
 {
-	return (crc32_le(~0L, buf, len) ^ ~0L);
+	return (crc32(~0L, buf, len) ^ ~0L);
 }
 
 /**
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acconfig.h linux-2.4.22-pre2/include/acpi/acconfig.h
--- linux-2.4.21/include/acpi/acconfig.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acconfig.h	2003-06-26 21:43:13.000000000 +0000
@@ -0,0 +1,202 @@
+/******************************************************************************
+ *
+ * Name: acconfig.h - Global configuration constants
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef _ACCONFIG_H
+#define _ACCONFIG_H
+
+
+/******************************************************************************
+ *
+ * Configuration options
+ *
+ *****************************************************************************/
+
+/*
+ * ACPI_DEBUG_OUTPUT    - This switch enables all the debug facilities of the
+ *                        ACPI subsystem.  This includes the DEBUG_PRINT output
+ *                        statements.  When disabled, all DEBUG_PRINT
+ *                        statements are compiled out.
+ *
+ * ACPI_APPLICATION     - Use this switch if the subsystem is going to be run
+ *                        at the application level.
+ *
+ */
+
+/* Version string */
+
+#define ACPI_CA_VERSION                 0x20030619
+
+/* Maximum objects in the various object caches */
+
+#define ACPI_MAX_STATE_CACHE_DEPTH      64          /* State objects for stacks */
+#define ACPI_MAX_PARSE_CACHE_DEPTH      96          /* Parse tree objects */
+#define ACPI_MAX_EXTPARSE_CACHE_DEPTH   64          /* Parse tree objects */
+#define ACPI_MAX_OBJECT_CACHE_DEPTH     64          /* Interpreter operand objects */
+#define ACPI_MAX_WALK_CACHE_DEPTH       4           /* Objects for parse tree walks */
+
+/*
+ * Should the subystem abort the loading of an ACPI table if the
+ * table checksum is incorrect?
+ */
+#define ACPI_CHECKSUM_ABORT             FALSE
+
+
+/******************************************************************************
+ *
+ * Subsystem Constants
+ *
+ *****************************************************************************/
+
+/* Version of ACPI supported */
+
+#define ACPI_CA_SUPPORT_LEVEL           2
+
+/* String size constants */
+
+#define ACPI_MAX_STRING_LENGTH          512
+#define ACPI_PATHNAME_MAX               256         /* A full namespace pathname */
+
+/* Maximum count for a semaphore object */
+
+#define ACPI_MAX_SEMAPHORE_COUNT        256
+
+/* Max reference count (for debug only) */
+
+#define ACPI_MAX_REFERENCE_COUNT        0x400
+
+/* Size of cached memory mapping for system memory operation region */
+
+#define ACPI_SYSMEM_REGION_WINDOW_SIZE  4096
+
+
+/******************************************************************************
+ *
+ * ACPI Specification constants (Do not change unless the specification changes)
+ *
+ *****************************************************************************/
+
+/* Number of distinct GPE register blocks and register width */
+
+#define ACPI_MAX_GPE_BLOCKS             2
+#define ACPI_GPE_REGISTER_WIDTH         8
+
+/*
+ * Method info (in WALK_STATE), containing local variables and argumetns
+ */
+#define ACPI_METHOD_NUM_LOCALS          8
+#define ACPI_METHOD_MAX_LOCAL           7
+
+#define ACPI_METHOD_NUM_ARGS            7
+#define ACPI_METHOD_MAX_ARG             6
+
+/* Maximum length of resulting string when converting from a buffer */
+
+#define ACPI_MAX_STRING_CONVERSION      200
+
+/* Length of _HID, _UID, and _CID values */
+
+#define ACPI_DEVICE_ID_LENGTH           0x09
+#define ACPI_MAX_CID_LENGTH             48
+
+/*
+ * Operand Stack (in WALK_STATE), Must be large enough to contain METHOD_MAX_ARG
+ */
+#define ACPI_OBJ_NUM_OPERANDS           8
+#define ACPI_OBJ_MAX_OPERAND            7
+
+/* Names within the namespace are 4 bytes long */
+
+#define ACPI_NAME_SIZE                  4
+#define ACPI_PATH_SEGMENT_LENGTH        5           /* 4 chars for name + 1 char for separator */
+#define ACPI_PATH_SEPARATOR             '.'
+
+/* Constants used in searching for the RSDP in low memory */
+
+#define ACPI_LO_RSDP_WINDOW_BASE        0           /* Physical Address */
+#define ACPI_HI_RSDP_WINDOW_BASE        0xE0000     /* Physical Address */
+#define ACPI_LO_RSDP_WINDOW_SIZE        0x400
+#define ACPI_HI_RSDP_WINDOW_SIZE        0x20000
+#define ACPI_RSDP_SCAN_STEP             16
+
+/* Operation regions */
+
+#define ACPI_NUM_PREDEFINED_REGIONS     8
+#define ACPI_USER_REGION_BEGIN          0x80
+
+/* Maximum space_ids for Operation Regions */
+
+#define ACPI_MAX_ADDRESS_SPACE          255
+
+/* Array sizes.  Used for range checking also */
+
+#define ACPI_NUM_ACCESS_TYPES           6
+#define ACPI_NUM_UPDATE_RULES           3
+#define ACPI_NUM_LOCK_RULES             2
+#define ACPI_NUM_MATCH_OPS              6
+#define ACPI_NUM_OPCODES                256
+#define ACPI_NUM_FIELD_NAMES            2
+
+/* RSDP checksums */
+
+#define ACPI_RSDP_CHECKSUM_LENGTH       20
+#define ACPI_RSDP_XCHECKSUM_LENGTH      36
+
+/* SMBus bidirectional buffer size */
+
+#define ACPI_SMBUS_BUFFER_SIZE          34
+
+
+/******************************************************************************
+ *
+ * ACPI AML Debugger
+ *
+ *****************************************************************************/
+
+#define ACPI_DEBUGGER_MAX_ARGS          8  /* Must be max method args + 1 */
+
+#define ACPI_DEBUGGER_COMMAND_PROMPT    '-'
+#define ACPI_DEBUGGER_EXECUTE_PROMPT    '%'
+
+
+#endif /* _ACCONFIG_H */
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acdebug.h linux-2.4.22-pre2/include/acpi/acdebug.h
--- linux-2.4.21/include/acpi/acdebug.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acdebug.h	2003-06-26 21:43:12.000000000 +0000
@@ -0,0 +1,469 @@
+/******************************************************************************
+ *
+ * Name: acdebug.h - ACPI/AML debugger
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACDEBUG_H__
+#define __ACDEBUG_H__
+
+
+#define ACPI_DEBUG_BUFFER_SIZE  4196
+
+struct command_info
+{
+	char                            *name;          /* Command Name */
+	u8                              min_args;       /* Minimum arguments required */
+};
+
+
+struct argument_info
+{
+	char                            *name;          /* Argument Name */
+};
+
+
+#define PARAM_LIST(pl)                  pl
+
+#define DBTEST_OUTPUT_LEVEL(lvl)        if (acpi_gbl_db_opt_verbose)
+
+#define VERBOSE_PRINT(fp)               DBTEST_OUTPUT_LEVEL(lvl) {\
+			  acpi_os_printf PARAM_LIST(fp);}
+
+#define EX_NO_SINGLE_STEP               1
+#define EX_SINGLE_STEP                  2
+
+
+/* Prototypes */
+
+
+/*
+ * dbxface - external debugger interfaces
+ */
+
+acpi_status
+acpi_db_initialize (
+	void);
+
+void
+acpi_db_terminate (
+	void);
+
+acpi_status
+acpi_db_single_step (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op,
+	u32                             op_type);
+
+acpi_status
+acpi_db_start_command (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op);
+
+void
+acpi_db_method_end (
+	struct acpi_walk_state          *walk_state);
+
+
+/*
+ * dbcmds - debug commands and output routines
+ */
+
+void
+acpi_db_display_table_info (
+	char                            *table_arg);
+
+void
+acpi_db_unload_acpi_table (
+	char                            *table_arg,
+	char                            *instance_arg);
+
+void
+acpi_db_set_method_breakpoint (
+	char                            *location,
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op);
+
+void
+acpi_db_set_method_call_breakpoint (
+	union acpi_parse_object         *op);
+
+void
+acpi_db_disassemble_aml (
+	char                            *statements,
+	union acpi_parse_object         *op);
+
+void
+acpi_db_dump_namespace (
+	char                            *start_arg,
+	char                            *depth_arg);
+
+void
+acpi_db_dump_namespace_by_owner (
+	char                            *owner_arg,
+	char                            *depth_arg);
+
+void
+acpi_db_send_notify (
+	char                            *name,
+	u32                             value);
+
+void
+acpi_db_set_method_data (
+	char                            *type_arg,
+	char                            *index_arg,
+	char                            *value_arg);
+
+acpi_status
+acpi_db_display_objects (
+	char                            *obj_type_arg,
+	char                            *display_count_arg);
+
+acpi_status
+acpi_db_find_name_in_namespace (
+	char                            *name_arg);
+
+void
+acpi_db_set_scope (
+	char                            *name);
+
+void
+acpi_db_find_references (
+	char                            *object_arg);
+
+void
+acpi_db_display_locks (void);
+
+
+void
+acpi_db_display_resources (
+	char                            *object_arg);
+
+void
+acpi_db_display_gpes (void);
+
+void
+acpi_db_check_integrity (
+	void);
+
+acpi_status
+acpi_db_integrity_walk (
+	acpi_handle                     obj_handle,
+	u32                             nesting_level,
+	void                            *context,
+	void                            **return_value);
+
+acpi_status
+acpi_db_walk_and_match_name (
+	acpi_handle                     obj_handle,
+	u32                             nesting_level,
+	void                            *context,
+	void                            **return_value);
+
+acpi_status
+acpi_db_walk_for_references (
+	acpi_handle                     obj_handle,
+	u32                             nesting_level,
+	void                            *context,
+	void                            **return_value);
+
+acpi_status
+acpi_db_walk_for_specific_objects (
+	acpi_handle                     obj_handle,
+	u32                             nesting_level,
+	void                            *context,
+	void                            **return_value);
+
+void
+acpi_db_generate_gpe (
+	char                            *gpe_arg,
+	char                            *block_arg);
+
+/*
+ * dbdisply - debug display commands
+ */
+
+void
+acpi_db_display_method_info (
+	union acpi_parse_object         *op);
+
+void
+acpi_db_decode_and_display_object (
+	char                            *target,
+	char                            *output_type);
+
+void
+acpi_db_display_result_object (
+	union acpi_operand_object       *obj_desc,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_db_display_all_methods (
+	char                            *display_count_arg);
+
+void
+acpi_db_display_arguments (
+	void);
+
+void
+acpi_db_display_locals (
+	void);
+
+void
+acpi_db_display_results (
+	void);
+
+void
+acpi_db_display_calling_tree (
+	void);
+
+void
+acpi_db_display_object_type (
+	char                            *object_arg);
+
+void
+acpi_db_display_argument_object (
+	union acpi_operand_object       *obj_desc,
+	struct acpi_walk_state          *walk_state);
+
+void
+acpi_db_dump_parser_descriptor (
+	union acpi_parse_object         *op);
+
+void *
+acpi_db_get_pointer (
+	void                            *target);
+
+
+/*
+ * dbexec - debugger control method execution
+ */
+
+void
+acpi_db_execute (
+	char                            *name,
+	char                            **args,
+	u32                             flags);
+
+void
+acpi_db_create_execution_threads (
+	char                            *num_threads_arg,
+	char                            *num_loops_arg,
+	char                            *method_name_arg);
+
+acpi_status
+acpi_db_execute_method (
+	struct acpi_db_method_info      *info,
+	struct acpi_buffer              *return_obj);
+
+void
+acpi_db_execute_setup (
+	struct acpi_db_method_info      *info);
+
+u32
+acpi_db_get_outstanding_allocations (
+	void);
+
+void ACPI_SYSTEM_XFACE
+acpi_db_method_thread (
+	void                            *context);
+
+acpi_status
+acpi_db_execution_walk (
+	acpi_handle                     obj_handle,
+	u32                             nesting_level,
+	void                            *context,
+	void                            **return_value);
+
+
+/*
+ * dbfileio - Debugger file I/O commands
+ */
+
+acpi_object_type
+acpi_db_match_argument (
+	char                            *user_argument,
+	struct argument_info            *arguments);
+
+acpi_status
+ae_local_load_table (
+	struct acpi_table_header        *table_ptr);
+
+void
+acpi_db_close_debug_file (
+	void);
+
+void
+acpi_db_open_debug_file (
+	char                            *name);
+
+acpi_status
+acpi_db_load_acpi_table (
+	char                            *filename);
+
+acpi_status
+acpi_db_get_table_from_file (
+	char                            *filename,
+	struct acpi_table_header        **table);
+
+acpi_status
+acpi_db_read_table_from_file (
+	char                            *filename,
+	struct acpi_table_header        **table);
+
+/*
+ * dbhistry - debugger HISTORY command
+ */
+
+void
+acpi_db_add_to_history (
+	char                            *command_line);
+
+void
+acpi_db_display_history (void);
+
+char *
+acpi_db_get_from_history (
+	char                            *command_num_arg);
+
+
+/*
+ * dbinput - user front-end to the AML debugger
+ */
+
+acpi_status
+acpi_db_command_dispatch (
+	char                            *input_buffer,
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op);
+
+void ACPI_SYSTEM_XFACE
+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);
+
+char *
+acpi_db_get_next_token (
+	char                            *string,
+	char                            **next);
+
+u32
+acpi_db_get_line (
+	char                            *input_buffer);
+
+u32
+acpi_db_match_command (
+	char                            *user_command);
+
+void
+acpi_db_single_thread (
+	void);
+
+
+/*
+ * dbstats - Generation and display of ACPI table statistics
+ */
+
+void
+acpi_db_generate_statistics (
+	union acpi_parse_object         *root,
+	u8                              is_method);
+
+
+acpi_status
+acpi_db_display_statistics (
+	char                            *type_arg);
+
+acpi_status
+acpi_db_classify_one_object (
+	acpi_handle                     obj_handle,
+	u32                             nesting_level,
+	void                            *context,
+	void                            **return_value);
+
+void
+acpi_db_count_namespace_objects (
+	void);
+
+void
+acpi_db_enumerate_object (
+	union acpi_operand_object       *obj_desc);
+
+
+/*
+ * dbutils - AML debugger utilities
+ */
+
+void
+acpi_db_set_output_destination (
+	u32                             where);
+
+void
+acpi_db_dump_buffer (
+	u32                             address);
+
+void
+acpi_db_dump_object (
+	union acpi_object               *obj_desc,
+	u32                             level);
+
+void
+acpi_db_prep_namestring (
+	char                            *name);
+
+
+acpi_status
+acpi_db_second_pass_parse (
+	union acpi_parse_object         *root);
+
+struct acpi_namespace_node *
+acpi_db_local_ns_lookup (
+	char                            *name);
+
+
+#endif  /* __ACDEBUG_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acdisasm.h linux-2.4.22-pre2/include/acpi/acdisasm.h
--- linux-2.4.21/include/acpi/acdisasm.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acdisasm.h	2003-06-26 21:43:30.000000000 +0000
@@ -0,0 +1,406 @@
+/******************************************************************************
+ *
+ * Name: acdisasm.h - AML disassembler
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACDISASM_H__
+#define __ACDISASM_H__
+
+#include "amlresrc.h"
+
+
+#define BLOCK_NONE              0
+#define BLOCK_PAREN             1
+#define BLOCK_BRACE             2
+#define BLOCK_COMMA_LIST        4
+
+extern const char                       *acpi_gbl_io_decode[2];
+extern const char                       *acpi_gbl_word_decode[4];
+extern const char                       *acpi_gbl_consume_decode[2];
+extern const char                       *acpi_gbl_min_decode[2];
+extern const char                       *acpi_gbl_max_decode[2];
+extern const char                       *acpi_gbl_DECdecode[2];
+extern const char                       *acpi_gbl_RNGdecode[4];
+extern const char                       *acpi_gbl_MEMdecode[4];
+extern const char                       *acpi_gbl_RWdecode[2];
+extern const char                       *acpi_gbl_irq_decode[2];
+extern const char                       *acpi_gbl_HEdecode[2];
+extern const char                       *acpi_gbl_LLdecode[2];
+extern const char                       *acpi_gbl_SHRdecode[2];
+extern const char                       *acpi_gbl_TYPdecode[4];
+extern const char                       *acpi_gbl_BMdecode[2];
+extern const char                       *acpi_gbl_SIZdecode[4];
+extern const char                       *acpi_gbl_lock_rule[ACPI_NUM_LOCK_RULES];
+extern const char                       *acpi_gbl_access_types[ACPI_NUM_ACCESS_TYPES];
+extern const char                       *acpi_gbl_update_rules[ACPI_NUM_UPDATE_RULES];
+extern const char                       *acpi_gbl_match_ops[ACPI_NUM_MATCH_OPS];
+
+
+struct acpi_op_walk_info
+{
+	u32                             level;
+	u32                             bit_offset;
+};
+
+typedef
+acpi_status (*asl_walk_callback) (
+	union acpi_parse_object             *op,
+	u32                                 level,
+	void                                *context);
+
+
+/*
+ * dmwalk
+ */
+
+void
+acpi_dm_walk_parse_tree (
+	union acpi_parse_object         *op,
+	asl_walk_callback               descending_callback,
+	asl_walk_callback               ascending_callback,
+	void                            *context);
+
+acpi_status
+acpi_dm_descending_op (
+	union acpi_parse_object         *op,
+	u32                             level,
+	void                            *context);
+
+acpi_status
+acpi_dm_ascending_op (
+	union acpi_parse_object         *op,
+	u32                             level,
+	void                            *context);
+
+
+/*
+ * dmopcode
+ */
+
+void
+acpi_dm_validate_name (
+	char                            *name,
+	union acpi_parse_object         *op);
+
+u32
+acpi_dm_dump_name (
+	char                            *name);
+
+void
+acpi_dm_unicode (
+	union acpi_parse_object         *op);
+
+void
+acpi_dm_disassemble (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *origin,
+	u32                             num_opcodes);
+
+void
+acpi_dm_namestring (
+	char                            *name);
+
+void
+acpi_dm_display_path (
+	union acpi_parse_object         *op);
+
+void
+acpi_dm_disassemble_one_op (
+	struct acpi_walk_state          *walk_state,
+	struct acpi_op_walk_info        *info,
+	union acpi_parse_object         *op);
+
+void
+acpi_dm_decode_internal_object (
+	union acpi_operand_object       *obj_desc);
+
+void
+acpi_dm_decode_node (
+	struct acpi_namespace_node      *node);
+
+u32
+acpi_dm_block_type (
+	union acpi_parse_object         *op);
+
+u32
+acpi_dm_list_type (
+	union acpi_parse_object         *op);
+
+acpi_status
+acpi_ps_display_object_pathname (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op);
+
+void
+acpi_dm_method_flags (
+	union acpi_parse_object         *op);
+
+void
+acpi_dm_field_flags (
+	union acpi_parse_object         *op);
+
+void
+acpi_dm_address_space (
+	u8                              space_id);
+
+void
+acpi_dm_region_flags (
+	union acpi_parse_object         *op);
+
+void
+acpi_dm_match_op (
+	union acpi_parse_object         *op);
+
+void
+acpi_dm_match_keyword (
+	union acpi_parse_object         *op);
+
+u8
+acpi_dm_comma_if_list_member (
+	union acpi_parse_object         *op);
+
+void
+acpi_dm_comma_if_field_member (
+	union acpi_parse_object         *op);
+
+
+/*
+ * dmobject
+ */
+
+void
+acpi_dm_decode_node (
+	struct acpi_namespace_node      *node);
+
+void
+acpi_dm_display_internal_object (
+	union acpi_operand_object       *obj_desc,
+	struct acpi_walk_state          *walk_state);
+
+void
+acpi_dm_display_arguments (
+	struct acpi_walk_state          *walk_state);
+
+void
+acpi_dm_display_locals (
+	struct acpi_walk_state          *walk_state);
+
+void
+acpi_dm_dump_method_info (
+	acpi_status                     status,
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op);
+
+
+/*
+ * dmbuffer
+ */
+
+void
+acpi_is_eisa_id (
+	union acpi_parse_object         *op);
+
+void
+acpi_dm_eisa_id (
+	u32                             encoded_id);
+
+u8
+acpi_dm_is_unicode_buffer (
+	union acpi_parse_object         *op);
+
+u8
+acpi_dm_is_string_buffer (
+	union acpi_parse_object         *op);
+
+
+/*
+ * dmresrc
+ */
+
+void
+acpi_dm_disasm_byte_list (
+	u32                             level,
+	u8                              *byte_data,
+	u32                             byte_count);
+
+void
+acpi_dm_byte_list (
+	struct acpi_op_walk_info        *info,
+	union acpi_parse_object         *op);
+
+void
+acpi_dm_resource_descriptor (
+	struct acpi_op_walk_info        *info,
+	u8                              *byte_data,
+	u32                             byte_count);
+
+u8
+acpi_dm_is_resource_descriptor (
+	union acpi_parse_object         *op);
+
+void
+acpi_dm_indent (
+	u32                             level);
+
+void
+acpi_dm_bit_list (
+	u16                             mask);
+
+void
+acpi_dm_decode_attribute (
+	u8                              attribute);
+
+/*
+ * dmresrcl
+ */
+
+void
+acpi_dm_io_flags (
+		u8                          flags);
+
+void
+acpi_dm_memory_flags (
+	u8                              flags,
+	u8                              specific_flags);
+
+void
+acpi_dm_word_descriptor (
+	struct asl_word_address_desc    *resource,
+	u32                             length,
+	u32                             level);
+
+void
+acpi_dm_dword_descriptor (
+	struct asl_dword_address_desc   *resource,
+	u32                             length,
+	u32                             level);
+
+void
+acpi_dm_qword_descriptor (
+	struct asl_qword_address_desc   *resource,
+	u32                             length,
+	u32                             level);
+
+void
+acpi_dm_memory24_descriptor (
+	struct asl_memory_24_desc       *resource,
+	u32                             length,
+	u32                             level);
+
+void
+acpi_dm_memory32_descriptor (
+	struct asl_memory_32_desc       *resource,
+	u32                             length,
+	u32                             level);
+
+void
+acpi_dm_fixed_mem32_descriptor (
+	struct asl_fixed_memory_32_desc *resource,
+	u32                             length,
+	u32                             level);
+
+void
+acpi_dm_generic_register_descriptor (
+	struct asl_general_register_desc *resource,
+	u32                             length,
+	u32                             level);
+
+void
+acpi_dm_interrupt_descriptor (
+	struct asl_extended_xrupt_desc *resource,
+	u32                             length,
+	u32                             level);
+
+void
+acpi_dm_vendor_large_descriptor (
+	struct asl_large_vendor_desc    *resource,
+	u32                             length,
+	u32                             level);
+
+
+/*
+ * dmresrcs
+ */
+
+void
+acpi_dm_irq_descriptor (
+	struct asl_irq_format_desc      *resource,
+	u32                             length,
+	u32                             level);
+
+void
+acpi_dm_dma_descriptor (
+	struct asl_dma_format_desc      *resource,
+	u32                             length,
+	u32                             level);
+
+void
+acpi_dm_io_descriptor (
+	struct asl_io_port_desc         *resource,
+	u32                             length,
+	u32                             level);
+
+void
+acpi_dm_fixed_io_descriptor (
+	struct asl_fixed_io_port_desc   *resource,
+	u32                             length,
+	u32                             level);
+
+void
+acpi_dm_start_dependent_descriptor (
+	struct asl_start_dependent_desc *resource,
+	u32                             length,
+	u32                             level);
+
+void
+acpi_dm_end_dependent_descriptor (
+	struct asl_start_dependent_desc *resource,
+	u32                             length,
+	u32                             level);
+
+void
+acpi_dm_vendor_small_descriptor (
+	struct asl_small_vendor_desc    *resource,
+	u32                             length,
+	u32                             level);
+
+
+#endif  /* __ACDISASM_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acdispat.h linux-2.4.22-pre2/include/acpi/acdispat.h
--- linux-2.4.21/include/acpi/acdispat.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acdispat.h	2003-06-26 21:43:30.000000000 +0000
@@ -0,0 +1,513 @@
+/******************************************************************************
+ *
+ * Name: acdispat.h - dispatcher (parser to interpreter interface)
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+
+#ifndef _ACDISPAT_H_
+#define _ACDISPAT_H_
+
+
+#define NAMEOF_LOCAL_NTE    "__L0"
+#define NAMEOF_ARG_NTE      "__A0"
+
+
+/* Common interfaces */
+
+acpi_status
+acpi_ds_obj_stack_push (
+	void                            *object,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_obj_stack_pop (
+	u32                             pop_count,
+	struct acpi_walk_state          *walk_state);
+
+void *
+acpi_ds_obj_stack_get_value (
+	u32                             index,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_obj_stack_pop_object (
+	union acpi_operand_object       **object,
+	struct acpi_walk_state          *walk_state);
+
+
+/* dsopcode - support for late evaluation */
+
+acpi_status
+acpi_ds_execute_arguments (
+	struct acpi_namespace_node      *node,
+	struct acpi_namespace_node      *scope_node,
+	u32                             aml_length,
+	u8                              *aml_start);
+
+acpi_status
+acpi_ds_get_buffer_field_arguments (
+	union acpi_operand_object       *obj_desc);
+
+acpi_status
+acpi_ds_get_region_arguments (
+	union acpi_operand_object       *rgn_desc);
+
+acpi_status
+acpi_ds_get_buffer_arguments (
+	union acpi_operand_object       *obj_desc);
+
+acpi_status
+acpi_ds_get_package_arguments (
+	union acpi_operand_object       *obj_desc);
+
+acpi_status
+acpi_ds_init_buffer_field (
+	u16                             aml_opcode,
+	union acpi_operand_object       *obj_desc,
+	union acpi_operand_object       *buffer_desc,
+	union acpi_operand_object       *offset_desc,
+	union acpi_operand_object       *length_desc,
+	union acpi_operand_object       *result_desc);
+
+acpi_status
+acpi_ds_eval_buffer_field_operands (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op);
+
+acpi_status
+acpi_ds_eval_region_operands (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op);
+
+acpi_status
+acpi_ds_eval_data_object_operands (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op,
+	union acpi_operand_object       *obj_desc);
+
+acpi_status
+acpi_ds_initialize_region (
+	acpi_handle                     obj_handle);
+
+
+/* dsctrl - Parser/Interpreter interface, control stack routines */
+
+
+acpi_status
+acpi_ds_exec_begin_control_op (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op);
+
+acpi_status
+acpi_ds_exec_end_control_op (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op);
+
+
+/* dsexec - Parser/Interpreter interface, method execution callbacks */
+
+
+acpi_status
+acpi_ds_get_predicate_value (
+	struct acpi_walk_state          *walk_state,
+	union acpi_operand_object       *result_obj);
+
+acpi_status
+acpi_ds_exec_begin_op (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         **out_op);
+
+acpi_status
+acpi_ds_exec_end_op (
+	struct acpi_walk_state          *state);
+
+
+/* dsfield - Parser/Interpreter interface for AML fields */
+
+acpi_status
+acpi_ds_get_field_names (
+	struct acpi_create_field_info   *info,
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *arg);
+
+acpi_status
+acpi_ds_create_field (
+	union acpi_parse_object         *op,
+	struct acpi_namespace_node      *region_node,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_create_bank_field (
+	union acpi_parse_object         *op,
+	struct acpi_namespace_node      *region_node,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_create_index_field (
+	union acpi_parse_object         *op,
+	struct acpi_namespace_node      *region_node,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_create_buffer_field (
+	union acpi_parse_object         *op,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_init_field_objects (
+	union acpi_parse_object         *op,
+	struct acpi_walk_state          *walk_state);
+
+
+/* dsload - Parser/Interpreter interface, namespace load callbacks */
+
+acpi_status
+acpi_ds_load1_begin_op (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         **out_op);
+
+acpi_status
+acpi_ds_load1_end_op (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_load2_begin_op (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         **out_op);
+
+acpi_status
+acpi_ds_load2_end_op (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_init_callbacks (
+	struct acpi_walk_state          *walk_state,
+	u32                             pass_number);
+
+
+/* dsmthdat - method data (locals/args) */
+
+
+acpi_status
+acpi_ds_store_object_to_local (
+	u16                             opcode,
+	u32                             index,
+	union acpi_operand_object       *src_desc,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_method_data_get_entry (
+	u16                             opcode,
+	u32                             index,
+	struct acpi_walk_state          *walk_state,
+	union acpi_operand_object       ***node);
+
+void
+acpi_ds_method_data_delete_all (
+	struct acpi_walk_state          *walk_state);
+
+u8
+acpi_ds_is_method_value (
+	union acpi_operand_object       *obj_desc);
+
+acpi_object_type
+acpi_ds_method_data_get_type (
+	u16                             opcode,
+	u32                             index,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_method_data_get_value (
+	u16                             opcode,
+	u32                             index,
+	struct acpi_walk_state          *walk_state,
+	union acpi_operand_object       **dest_desc);
+
+void
+acpi_ds_method_data_delete_value (
+	u16                             opcode,
+	u32                             index,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_method_data_init_args (
+	union acpi_operand_object       **params,
+	u32                             max_param_count,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_method_data_get_node (
+	u16                             opcode,
+	u32                             index,
+	struct acpi_walk_state          *walk_state,
+	struct acpi_namespace_node      **node);
+
+void
+acpi_ds_method_data_init (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_method_data_set_value (
+	u16                             opcode,
+	u32                             index,
+	union acpi_operand_object       *object,
+	struct acpi_walk_state          *walk_state);
+
+
+/* dsmethod - Parser/Interpreter interface - control method parsing */
+
+acpi_status
+acpi_ds_parse_method (
+	acpi_handle                     obj_handle);
+
+acpi_status
+acpi_ds_call_control_method (
+	struct acpi_thread_state        *thread,
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op);
+
+acpi_status
+acpi_ds_restart_control_method (
+	struct acpi_walk_state          *walk_state,
+	union acpi_operand_object       *return_desc);
+
+acpi_status
+acpi_ds_terminate_control_method (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_begin_method_execution (
+	struct acpi_namespace_node      *method_node,
+	union acpi_operand_object       *obj_desc,
+	struct acpi_namespace_node      *calling_method_node);
+
+
+/* dsobj - Parser/Interpreter interface - object initialization and conversion */
+
+acpi_status
+acpi_ds_init_one_object (
+	acpi_handle                     obj_handle,
+	u32                             level,
+	void                            *context,
+	void                            **return_value);
+
+acpi_status
+acpi_ds_initialize_objects (
+	struct acpi_table_desc          *table_desc,
+	struct acpi_namespace_node      *start_node);
+
+acpi_status
+acpi_ds_build_internal_buffer_obj (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op,
+	u32                             buffer_length,
+	union acpi_operand_object       **obj_desc_ptr);
+
+acpi_status
+acpi_ds_build_internal_package_obj (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op,
+	u32                             package_length,
+	union acpi_operand_object       **obj_desc);
+
+acpi_status
+acpi_ds_build_internal_object (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op,
+	union acpi_operand_object       **obj_desc_ptr);
+
+acpi_status
+acpi_ds_init_object_from_op (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op,
+	u16                             opcode,
+	union acpi_operand_object       **obj_desc);
+
+acpi_status
+acpi_ds_create_node (
+	struct acpi_walk_state          *walk_state,
+	struct acpi_namespace_node      *node,
+	union acpi_parse_object         *op);
+
+
+/* dsutils - Parser/Interpreter interface utility routines */
+
+u8
+acpi_ds_is_result_used (
+	union acpi_parse_object         *op,
+	struct acpi_walk_state          *walk_state);
+
+void
+acpi_ds_delete_result_if_not_used (
+	union acpi_parse_object         *op,
+	union acpi_operand_object       *result_obj,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_create_operand (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *arg,
+	u32                             args_remaining);
+
+acpi_status
+acpi_ds_create_operands (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *first_arg);
+
+acpi_status
+acpi_ds_resolve_operands (
+	struct acpi_walk_state          *walk_state);
+
+void
+acpi_ds_clear_operands (
+	struct acpi_walk_state          *walk_state);
+
+
+/*
+ * dswscope - Scope Stack manipulation
+ */
+
+acpi_status
+acpi_ds_scope_stack_push (
+	struct acpi_namespace_node      *node,
+	acpi_object_type                type,
+	struct acpi_walk_state          *walk_state);
+
+
+acpi_status
+acpi_ds_scope_stack_pop (
+	struct acpi_walk_state          *walk_state);
+
+void
+acpi_ds_scope_stack_clear (
+	struct acpi_walk_state          *walk_state);
+
+
+/* dswstate - parser WALK_STATE management routines */
+
+struct acpi_walk_state *
+acpi_ds_create_walk_state (
+	acpi_owner_id                   owner_id,
+	union acpi_parse_object         *origin,
+	union acpi_operand_object       *mth_desc,
+	struct acpi_thread_state        *thread);
+
+acpi_status
+acpi_ds_init_aml_walk (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op,
+	struct acpi_namespace_node      *method_node,
+	u8                              *aml_start,
+	u32                             aml_length,
+	union acpi_operand_object       **params,
+	union acpi_operand_object       **return_obj_desc,
+	u32                             pass_number);
+
+acpi_status
+acpi_ds_obj_stack_delete_all (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_obj_stack_pop_and_delete (
+	u32                             pop_count,
+	struct acpi_walk_state          *walk_state);
+
+void
+acpi_ds_delete_walk_state (
+	struct acpi_walk_state          *walk_state);
+
+struct acpi_walk_state *
+acpi_ds_pop_walk_state (
+	struct acpi_thread_state        *thread);
+
+void
+acpi_ds_push_walk_state (
+	struct acpi_walk_state          *walk_state,
+	struct acpi_thread_state        *thread);
+
+acpi_status
+acpi_ds_result_stack_pop (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_result_stack_push (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_result_stack_clear (
+	struct acpi_walk_state          *walk_state);
+
+struct acpi_walk_state *
+acpi_ds_get_current_walk_state (
+	struct acpi_thread_state        *thread);
+
+void
+acpi_ds_delete_walk_state_cache (
+	void);
+
+acpi_status
+acpi_ds_result_insert (
+	void                            *object,
+	u32                             index,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_result_remove (
+	union acpi_operand_object       **object,
+	u32                             index,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_result_pop (
+	union acpi_operand_object       **object,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_result_push (
+	union acpi_operand_object       *object,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ds_result_pop_from_bottom (
+	union acpi_operand_object       **object,
+	struct acpi_walk_state          *walk_state);
+
+#endif /* _ACDISPAT_H_ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acevents.h linux-2.4.22-pre2/include/acpi/acevents.h
--- linux-2.4.21/include/acpi/acevents.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acevents.h	2003-06-26 21:43:28.000000000 +0000
@@ -0,0 +1,263 @@
+/******************************************************************************
+ *
+ * Name: acevents.h - Event subcomponent prototypes and defines
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACEVENTS_H__
+#define __ACEVENTS_H__
+
+
+acpi_status
+acpi_ev_initialize (
+	void);
+
+acpi_status
+acpi_ev_handler_initialize (
+	void);
+
+
+/*
+ * Evfixed - Fixed event handling
+ */
+
+acpi_status
+acpi_ev_fixed_event_initialize (
+	void);
+
+u32
+acpi_ev_fixed_event_detect (
+	void);
+
+u32
+acpi_ev_fixed_event_dispatch (
+	u32                             event);
+
+
+/*
+ * Evmisc
+ */
+
+u8
+acpi_ev_is_notify_object (
+	struct acpi_namespace_node      *node);
+
+acpi_status
+acpi_ev_acquire_global_lock(
+	u16                             timeout);
+
+acpi_status
+acpi_ev_release_global_lock(
+	void);
+
+acpi_status
+acpi_ev_init_global_lock_handler (
+	void);
+
+u32
+acpi_ev_get_gpe_number_index (
+	u32                             gpe_number);
+
+acpi_status
+acpi_ev_queue_notify_request (
+	struct acpi_namespace_node      *node,
+	u32                             notify_value);
+
+void ACPI_SYSTEM_XFACE
+acpi_ev_notify_dispatch (
+	void                            *context);
+
+
+/*
+ * Evgpe - GPE handling and dispatch
+ */
+
+acpi_status
+acpi_ev_walk_gpe_list (
+	ACPI_GPE_CALLBACK       gpe_walk_callback);
+
+u8
+acpi_ev_valid_gpe_event (
+	struct acpi_gpe_event_info      *gpe_event_info);
+
+struct acpi_gpe_event_info *
+acpi_ev_get_gpe_event_info (
+	acpi_handle                     gpe_device,
+	u32                             gpe_number);
+
+acpi_status
+acpi_ev_gpe_initialize (
+	void);
+
+acpi_status
+acpi_ev_create_gpe_block (
+	struct acpi_namespace_node      *gpe_device,
+	struct acpi_generic_address     *gpe_block_address,
+	u32                             register_count,
+	u8                              gpe_block_base_number,
+	u32                             interrupt_level,
+	struct acpi_gpe_block_info      **return_gpe_block);
+
+acpi_status
+acpi_ev_delete_gpe_block (
+	struct acpi_gpe_block_info      *gpe_block);
+
+u32
+acpi_ev_gpe_dispatch (
+	struct acpi_gpe_event_info      *gpe_event_info,
+	u32                             gpe_number);
+
+u32
+acpi_ev_gpe_detect (
+	struct acpi_gpe_xrupt_info      *gpe_xrupt_list);
+
+/*
+ * Evregion - Address Space handling
+ */
+
+acpi_status
+acpi_ev_init_address_spaces (
+	void);
+
+acpi_status
+acpi_ev_address_space_dispatch (
+	union acpi_operand_object      *region_obj,
+	u32                             function,
+	acpi_physical_address           address,
+	u32                             bit_width,
+	void                            *value);
+
+acpi_status
+acpi_ev_install_handler (
+	acpi_handle                     obj_handle,
+	u32                             level,
+	void                            *context,
+	void                            **return_value);
+
+acpi_status
+acpi_ev_attach_region (
+	union acpi_operand_object       *handler_obj,
+	union acpi_operand_object       *region_obj,
+	u8                              acpi_ns_is_locked);
+
+void
+acpi_ev_detach_region (
+	union acpi_operand_object      *region_obj,
+	u8                              acpi_ns_is_locked);
+
+
+/*
+ * Evregini - Region initialization and setup
+ */
+
+acpi_status
+acpi_ev_system_memory_region_setup (
+	acpi_handle                     handle,
+	u32                             function,
+	void                            *handler_context,
+	void                            **region_context);
+
+acpi_status
+acpi_ev_io_space_region_setup (
+	acpi_handle                     handle,
+	u32                             function,
+	void                            *handler_context,
+	void                            **region_context);
+
+acpi_status
+acpi_ev_pci_config_region_setup (
+	acpi_handle                     handle,
+	u32                             function,
+	void                            *handler_context,
+	void                            **region_context);
+
+acpi_status
+acpi_ev_cmos_region_setup (
+	acpi_handle                     handle,
+	u32                             function,
+	void                            *handler_context,
+	void                            **region_context);
+
+acpi_status
+acpi_ev_pci_bar_region_setup (
+	acpi_handle                     handle,
+	u32                             function,
+	void                            *handler_context,
+	void                            **region_context);
+
+acpi_status
+acpi_ev_default_region_setup (
+	acpi_handle                     handle,
+	u32                             function,
+	void                            *handler_context,
+	void                            **region_context);
+
+acpi_status
+acpi_ev_initialize_region (
+	union acpi_operand_object       *region_obj,
+	u8                              acpi_ns_locked);
+
+
+/*
+ * Evsci - SCI (System Control Interrupt) handling/dispatch
+ */
+
+u32 ACPI_SYSTEM_XFACE
+acpi_ev_gpe_xrupt_handler (
+	void                            *context);
+
+u32
+acpi_ev_install_sci_handler (
+	void);
+
+acpi_status
+acpi_ev_remove_sci_handler (
+	void);
+
+u32
+acpi_ev_initialize_sCI (
+	u32                             program_sCI);
+
+void
+acpi_ev_terminate (
+	void);
+
+
+#endif  /* __ACEVENTS_H__  */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acexcep.h linux-2.4.22-pre2/include/acpi/acexcep.h
--- linux-2.4.21/include/acpi/acexcep.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acexcep.h	2003-06-26 21:43:11.000000000 +0000
@@ -0,0 +1,304 @@
+/******************************************************************************
+ *
+ * Name: acexcep.h - Exception codes returned by the ACPI subsystem
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACEXCEP_H__
+#define __ACEXCEP_H__
+
+
+/*
+ * Exceptions returned by external ACPI interfaces
+ */
+
+#define AE_CODE_ENVIRONMENTAL           0x0000
+#define AE_CODE_PROGRAMMER              0x1000
+#define AE_CODE_ACPI_TABLES             0x2000
+#define AE_CODE_AML                     0x3000
+#define AE_CODE_CONTROL                 0x4000
+#define AE_CODE_MASK                    0xF000
+
+
+#define ACPI_SUCCESS(a)                 (!(a))
+#define ACPI_FAILURE(a)                 (a)
+
+
+#define AE_OK                           (acpi_status) 0x0000
+
+/*
+ * Environmental exceptions
+ */
+#define AE_ERROR                        (acpi_status) (0x0001 | AE_CODE_ENVIRONMENTAL)
+#define AE_NO_ACPI_TABLES               (acpi_status) (0x0002 | AE_CODE_ENVIRONMENTAL)
+#define AE_NO_NAMESPACE                 (acpi_status) (0x0003 | AE_CODE_ENVIRONMENTAL)
+#define AE_NO_MEMORY                    (acpi_status) (0x0004 | AE_CODE_ENVIRONMENTAL)
+#define AE_NOT_FOUND                    (acpi_status) (0x0005 | AE_CODE_ENVIRONMENTAL)
+#define AE_NOT_EXIST                    (acpi_status) (0x0006 | AE_CODE_ENVIRONMENTAL)
+#define AE_ALREADY_EXISTS               (acpi_status) (0x0007 | AE_CODE_ENVIRONMENTAL)
+#define AE_TYPE                         (acpi_status) (0x0008 | AE_CODE_ENVIRONMENTAL)
+#define AE_NULL_OBJECT                  (acpi_status) (0x0009 | AE_CODE_ENVIRONMENTAL)
+#define AE_NULL_ENTRY                   (acpi_status) (0x000A | AE_CODE_ENVIRONMENTAL)
+#define AE_BUFFER_OVERFLOW              (acpi_status) (0x000B | AE_CODE_ENVIRONMENTAL)
+#define AE_STACK_OVERFLOW               (acpi_status) (0x000C | AE_CODE_ENVIRONMENTAL)
+#define AE_STACK_UNDERFLOW              (acpi_status) (0x000D | AE_CODE_ENVIRONMENTAL)
+#define AE_NOT_IMPLEMENTED              (acpi_status) (0x000E | AE_CODE_ENVIRONMENTAL)
+#define AE_VERSION_MISMATCH             (acpi_status) (0x000F | AE_CODE_ENVIRONMENTAL)
+#define AE_SUPPORT                      (acpi_status) (0x0010 | AE_CODE_ENVIRONMENTAL)
+#define AE_SHARE                        (acpi_status) (0x0011 | AE_CODE_ENVIRONMENTAL)
+#define AE_LIMIT                        (acpi_status) (0x0012 | AE_CODE_ENVIRONMENTAL)
+#define AE_TIME                         (acpi_status) (0x0013 | AE_CODE_ENVIRONMENTAL)
+#define AE_UNKNOWN_STATUS               (acpi_status) (0x0014 | AE_CODE_ENVIRONMENTAL)
+#define AE_ACQUIRE_DEADLOCK             (acpi_status) (0x0015 | AE_CODE_ENVIRONMENTAL)
+#define AE_RELEASE_DEADLOCK             (acpi_status) (0x0016 | AE_CODE_ENVIRONMENTAL)
+#define AE_NOT_ACQUIRED                 (acpi_status) (0x0017 | AE_CODE_ENVIRONMENTAL)
+#define AE_ALREADY_ACQUIRED             (acpi_status) (0x0018 | AE_CODE_ENVIRONMENTAL)
+#define AE_NO_HARDWARE_RESPONSE         (acpi_status) (0x0019 | AE_CODE_ENVIRONMENTAL)
+#define AE_NO_GLOBAL_LOCK               (acpi_status) (0x001A | AE_CODE_ENVIRONMENTAL)
+#define AE_LOGICAL_ADDRESS              (acpi_status) (0x001B | AE_CODE_ENVIRONMENTAL)
+#define AE_ABORT_METHOD                 (acpi_status) (0x001C | AE_CODE_ENVIRONMENTAL)
+#define AE_SAME_HANDLER                 (acpi_status) (0x001D | AE_CODE_ENVIRONMENTAL)
+
+#define AE_CODE_ENV_MAX                 0x001D
+
+/*
+ * Programmer exceptions
+ */
+#define AE_BAD_PARAMETER                (acpi_status) (0x0001 | AE_CODE_PROGRAMMER)
+#define AE_BAD_CHARACTER                (acpi_status) (0x0002 | AE_CODE_PROGRAMMER)
+#define AE_BAD_PATHNAME                 (acpi_status) (0x0003 | AE_CODE_PROGRAMMER)
+#define AE_BAD_DATA                     (acpi_status) (0x0004 | AE_CODE_PROGRAMMER)
+#define AE_BAD_ADDRESS                  (acpi_status) (0x0005 | AE_CODE_PROGRAMMER)
+#define AE_ALIGNMENT                    (acpi_status) (0x0006 | AE_CODE_PROGRAMMER)
+#define AE_BAD_HEX_CONSTANT             (acpi_status) (0x0007 | AE_CODE_PROGRAMMER)
+#define AE_BAD_OCTAL_CONSTANT           (acpi_status) (0x0008 | AE_CODE_PROGRAMMER)
+#define AE_BAD_DECIMAL_CONSTANT         (acpi_status) (0x0009 | AE_CODE_PROGRAMMER)
+
+#define AE_CODE_PGM_MAX                 0x0009
+
+
+/*
+ * Acpi table exceptions
+ */
+#define AE_BAD_SIGNATURE                (acpi_status) (0x0001 | AE_CODE_ACPI_TABLES)
+#define AE_BAD_HEADER                   (acpi_status) (0x0002 | AE_CODE_ACPI_TABLES)
+#define AE_BAD_CHECKSUM                 (acpi_status) (0x0003 | AE_CODE_ACPI_TABLES)
+#define AE_BAD_VALUE                    (acpi_status) (0x0004 | AE_CODE_ACPI_TABLES)
+#define AE_TABLE_NOT_SUPPORTED          (acpi_status) (0x0005 | AE_CODE_ACPI_TABLES)
+#define AE_INVALID_TABLE_LENGTH         (acpi_status) (0x0006 | AE_CODE_ACPI_TABLES)
+
+#define AE_CODE_TBL_MAX                 0x0006
+
+
+/*
+ * AML exceptions.  These are caused by problems with
+ * the actual AML byte stream
+ */
+#define AE_AML_ERROR                    (acpi_status) (0x0001 | AE_CODE_AML)
+#define AE_AML_PARSE                    (acpi_status) (0x0002 | AE_CODE_AML)
+#define AE_AML_BAD_OPCODE               (acpi_status) (0x0003 | AE_CODE_AML)
+#define AE_AML_NO_OPERAND               (acpi_status) (0x0004 | AE_CODE_AML)
+#define AE_AML_OPERAND_TYPE             (acpi_status) (0x0005 | AE_CODE_AML)
+#define AE_AML_OPERAND_VALUE            (acpi_status) (0x0006 | AE_CODE_AML)
+#define AE_AML_UNINITIALIZED_LOCAL      (acpi_status) (0x0007 | AE_CODE_AML)
+#define AE_AML_UNINITIALIZED_ARG        (acpi_status) (0x0008 | AE_CODE_AML)
+#define AE_AML_UNINITIALIZED_ELEMENT    (acpi_status) (0x0009 | AE_CODE_AML)
+#define AE_AML_NUMERIC_OVERFLOW         (acpi_status) (0x000A | AE_CODE_AML)
+#define AE_AML_REGION_LIMIT             (acpi_status) (0x000B | AE_CODE_AML)
+#define AE_AML_BUFFER_LIMIT             (acpi_status) (0x000C | AE_CODE_AML)
+#define AE_AML_PACKAGE_LIMIT            (acpi_status) (0x000D | AE_CODE_AML)
+#define AE_AML_DIVIDE_BY_ZERO           (acpi_status) (0x000E | AE_CODE_AML)
+#define AE_AML_BAD_NAME                 (acpi_status) (0x000F | AE_CODE_AML)
+#define AE_AML_NAME_NOT_FOUND           (acpi_status) (0x0010 | AE_CODE_AML)
+#define AE_AML_INTERNAL                 (acpi_status) (0x0011 | AE_CODE_AML)
+#define AE_AML_INVALID_SPACE_ID         (acpi_status) (0x0012 | AE_CODE_AML)
+#define AE_AML_STRING_LIMIT             (acpi_status) (0x0013 | AE_CODE_AML)
+#define AE_AML_NO_RETURN_VALUE          (acpi_status) (0x0014 | AE_CODE_AML)
+#define AE_AML_METHOD_LIMIT             (acpi_status) (0x0015 | AE_CODE_AML)
+#define AE_AML_NOT_OWNER                (acpi_status) (0x0016 | AE_CODE_AML)
+#define AE_AML_MUTEX_ORDER              (acpi_status) (0x0017 | AE_CODE_AML)
+#define AE_AML_MUTEX_NOT_ACQUIRED       (acpi_status) (0x0018 | AE_CODE_AML)
+#define AE_AML_INVALID_RESOURCE_TYPE    (acpi_status) (0x0019 | AE_CODE_AML)
+#define AE_AML_INVALID_INDEX            (acpi_status) (0x001A | AE_CODE_AML)
+#define AE_AML_REGISTER_LIMIT           (acpi_status) (0x001B | AE_CODE_AML)
+#define AE_AML_NO_WHILE                 (acpi_status) (0x001C | AE_CODE_AML)
+#define AE_AML_ALIGNMENT                (acpi_status) (0x001D | AE_CODE_AML)
+#define AE_AML_NO_RESOURCE_END_TAG      (acpi_status) (0x001E | AE_CODE_AML)
+#define AE_AML_BAD_RESOURCE_VALUE       (acpi_status) (0x001F | AE_CODE_AML)
+#define AE_AML_CIRCULAR_REFERENCE       (acpi_status) (0x0020 | AE_CODE_AML)
+
+#define AE_CODE_AML_MAX                 0x0020
+
+/*
+ * Internal exceptions used for control
+ */
+#define AE_CTRL_RETURN_VALUE            (acpi_status) (0x0001 | AE_CODE_CONTROL)
+#define AE_CTRL_PENDING                 (acpi_status) (0x0002 | AE_CODE_CONTROL)
+#define AE_CTRL_TERMINATE               (acpi_status) (0x0003 | AE_CODE_CONTROL)
+#define AE_CTRL_TRUE                    (acpi_status) (0x0004 | AE_CODE_CONTROL)
+#define AE_CTRL_FALSE                   (acpi_status) (0x0005 | AE_CODE_CONTROL)
+#define AE_CTRL_DEPTH                   (acpi_status) (0x0006 | AE_CODE_CONTROL)
+#define AE_CTRL_END                     (acpi_status) (0x0007 | AE_CODE_CONTROL)
+#define AE_CTRL_TRANSFER                (acpi_status) (0x0008 | AE_CODE_CONTROL)
+#define AE_CTRL_BREAK                   (acpi_status) (0x0009 | AE_CODE_CONTROL)
+#define AE_CTRL_CONTINUE                (acpi_status) (0x000A | AE_CODE_CONTROL)
+#define AE_CTRL_SKIP                    (acpi_status) (0x000B | AE_CODE_CONTROL)
+
+#define AE_CODE_CTRL_MAX                0x000B
+
+
+#ifdef DEFINE_ACPI_GLOBALS
+
+/*
+ * String versions of the exception codes above
+ * These strings must match the corresponding defines exactly
+ */
+char const   *acpi_gbl_exception_names_env[] =
+{
+	"AE_OK",
+	"AE_ERROR",
+	"AE_NO_ACPI_TABLES",
+	"AE_NO_NAMESPACE",
+	"AE_NO_MEMORY",
+	"AE_NOT_FOUND",
+	"AE_NOT_EXIST",
+	"AE_ALREADY_EXISTS",
+	"AE_TYPE",
+	"AE_NULL_OBJECT",
+	"AE_NULL_ENTRY",
+	"AE_BUFFER_OVERFLOW",
+	"AE_STACK_OVERFLOW",
+	"AE_STACK_UNDERFLOW",
+	"AE_NOT_IMPLEMENTED",
+	"AE_VERSION_MISMATCH",
+	"AE_SUPPORT",
+	"AE_SHARE",
+	"AE_LIMIT",
+	"AE_TIME",
+	"AE_UNKNOWN_STATUS",
+	"AE_ACQUIRE_DEADLOCK",
+	"AE_RELEASE_DEADLOCK",
+	"AE_NOT_ACQUIRED",
+	"AE_ALREADY_ACQUIRED",
+	"AE_NO_HARDWARE_RESPONSE",
+	"AE_NO_GLOBAL_LOCK",
+	"AE_LOGICAL_ADDRESS",
+	"AE_ABORT_METHOD",
+	"AE_SAME_HANDLER"
+};
+
+char const   *acpi_gbl_exception_names_pgm[] =
+{
+	"AE_BAD_PARAMETER",
+	"AE_BAD_CHARACTER",
+	"AE_BAD_PATHNAME",
+	"AE_BAD_DATA",
+	"AE_BAD_ADDRESS",
+	"AE_ALIGNMENT",
+	"AE_BAD_HEX_CONSTANT",
+	"AE_BAD_OCTAL_CONSTANT",
+	"AE_BAD_DECIMAL_CONSTANT"
+};
+
+char const   *acpi_gbl_exception_names_tbl[] =
+{
+	"AE_BAD_SIGNATURE",
+	"AE_BAD_HEADER",
+	"AE_BAD_CHECKSUM",
+	"AE_BAD_VALUE",
+	"AE_TABLE_NOT_SUPPORTED",
+	"AE_INVALID_TABLE_LENGTH"
+};
+
+char const   *acpi_gbl_exception_names_aml[] =
+{
+	"AE_AML_ERROR",
+	"AE_AML_PARSE",
+	"AE_AML_BAD_OPCODE",
+	"AE_AML_NO_OPERAND",
+	"AE_AML_OPERAND_TYPE",
+	"AE_AML_OPERAND_VALUE",
+	"AE_AML_UNINITIALIZED_LOCAL",
+	"AE_AML_UNINITIALIZED_ARG",
+	"AE_AML_UNINITIALIZED_ELEMENT",
+	"AE_AML_NUMERIC_OVERFLOW",
+	"AE_AML_REGION_LIMIT",
+	"AE_AML_BUFFER_LIMIT",
+	"AE_AML_PACKAGE_LIMIT",
+	"AE_AML_DIVIDE_BY_ZERO",
+	"AE_AML_BAD_NAME",
+	"AE_AML_NAME_NOT_FOUND",
+	"AE_AML_INTERNAL",
+	"AE_AML_INVALID_SPACE_ID",
+	"AE_AML_STRING_LIMIT",
+	"AE_AML_NO_RETURN_VALUE",
+	"AE_AML_METHOD_LIMIT",
+	"AE_AML_NOT_OWNER",
+	"AE_AML_MUTEX_ORDER",
+	"AE_AML_MUTEX_NOT_ACQUIRED",
+	"AE_AML_INVALID_RESOURCE_TYPE",
+	"AE_AML_INVALID_INDEX",
+	"AE_AML_REGISTER_LIMIT",
+	"AE_AML_NO_WHILE",
+	"AE_AML_ALIGNMENT",
+	"AE_AML_NO_RESOURCE_END_TAG",
+	"AE_AML_BAD_RESOURCE_VALUE",
+	"AE_AML_CIRCULAR_REFERENCE"
+};
+
+char const   *acpi_gbl_exception_names_ctrl[] =
+{
+	"AE_CTRL_RETURN_VALUE",
+	"AE_CTRL_PENDING",
+	"AE_CTRL_TERMINATE",
+	"AE_CTRL_TRUE",
+	"AE_CTRL_FALSE",
+	"AE_CTRL_DEPTH",
+	"AE_CTRL_END",
+	"AE_CTRL_TRANSFER",
+	"AE_CTRL_BREAK",
+	"AE_CTRL_CONTINUE",
+	"AE_CTRL_SKIP"
+};
+
+#endif /* ACPI GLOBALS */
+
+
+#endif /* __ACEXCEP_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acglobal.h linux-2.4.22-pre2/include/acpi/acglobal.h
--- linux-2.4.21/include/acpi/acglobal.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acglobal.h	2003-06-26 21:43:09.000000000 +0000
@@ -0,0 +1,307 @@
+/******************************************************************************
+ *
+ * Name: acglobal.h - Declarations for global variables
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACGLOBAL_H__
+#define __ACGLOBAL_H__
+
+
+/*
+ * Ensure that the globals are actually defined only once.
+ *
+ * The use of these defines allows a single list of globals (here) in order
+ * to simplify maintenance of the code.
+ */
+#ifdef DEFINE_ACPI_GLOBALS
+#define ACPI_EXTERN
+#else
+#define ACPI_EXTERN extern
+#endif
+
+
+/*****************************************************************************
+ *
+ * Debug support
+ *
+ ****************************************************************************/
+
+/* Runtime configuration of debug print levels */
+
+extern      u32                                 acpi_dbg_level;
+extern      u32                                 acpi_dbg_layer;
+
+/* Procedure nesting level for debug output */
+
+extern      u32                                 acpi_gbl_nesting_level;
+
+
+/*****************************************************************************
+ *
+ * ACPI Table globals
+ *
+ ****************************************************************************/
+
+/*
+ * Table pointers.
+ * Although these pointers are somewhat redundant with the global acpi_table,
+ * they are convenient because they are typed pointers.
+ *
+ * These tables are single-table only; meaning that there can be at most one
+ * of each in the system.  Each global points to the actual table.
+ *
+ */
+ACPI_EXTERN u32                                 acpi_gbl_table_flags;
+ACPI_EXTERN u32                                 acpi_gbl_rsdt_table_count;
+ACPI_EXTERN struct rsdp_descriptor             *acpi_gbl_RSDP;
+ACPI_EXTERN XSDT_DESCRIPTOR            *acpi_gbl_XSDT;
+ACPI_EXTERN FADT_DESCRIPTOR            *acpi_gbl_FADT;
+ACPI_EXTERN struct acpi_table_header           *acpi_gbl_DSDT;
+ACPI_EXTERN FACS_DESCRIPTOR            *acpi_gbl_FACS;
+ACPI_EXTERN struct acpi_common_facs             acpi_gbl_common_fACS;
+
+/*
+ * Handle both ACPI 1.0 and ACPI 2.0 Integer widths
+ * If we are running a method that exists in a 32-bit ACPI table.
+ * Use only 32 bits of the Integer for conversion.
+ */
+ACPI_EXTERN u8                                  acpi_gbl_integer_bit_width;
+ACPI_EXTERN u8                                  acpi_gbl_integer_byte_width;
+ACPI_EXTERN u8                                  acpi_gbl_integer_nybble_width;
+ACPI_EXTERN struct acpi_generic_address         acpi_gbl_xpm1a_enable;
+ACPI_EXTERN struct acpi_generic_address         acpi_gbl_xpm1b_enable;
+
+/*
+ * Since there may be multiple SSDTs and PSDTS, a single pointer is not
+ * sufficient; Therefore, there isn't one!
+ */
+
+
+/*
+ * ACPI Table info arrays
+ */
+extern      struct acpi_table_list              acpi_gbl_table_lists[NUM_ACPI_TABLE_TYPES];
+extern      struct acpi_table_support           acpi_gbl_table_data[NUM_ACPI_TABLE_TYPES];
+
+/*
+ * Predefined mutex objects.  This array contains the
+ * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs.
+ * (The table maps local handles to the real OS handles)
+ */
+ACPI_EXTERN struct acpi_mutex_info              acpi_gbl_mutex_info[NUM_MUTEX];
+
+
+/*****************************************************************************
+ *
+ * Miscellaneous globals
+ *
+ ****************************************************************************/
+
+
+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_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;
+
+ACPI_EXTERN u32                                 acpi_gbl_global_lock_thread_count;
+ACPI_EXTERN u32                                 acpi_gbl_original_mode;
+ACPI_EXTERN u32                                 acpi_gbl_rsdp_original_location;
+ACPI_EXTERN u32                                 acpi_gbl_ns_lookup_count;
+ACPI_EXTERN u32                                 acpi_gbl_ps_find_count;
+ACPI_EXTERN u16                                 acpi_gbl_pm1_enable_register_save;
+ACPI_EXTERN u16                                 acpi_gbl_next_table_owner_id;
+ACPI_EXTERN u16                                 acpi_gbl_next_method_owner_id;
+ACPI_EXTERN u16                                 acpi_gbl_global_lock_handle;
+ACPI_EXTERN u8                                  acpi_gbl_debugger_configuration;
+ACPI_EXTERN u8                                  acpi_gbl_global_lock_acquired;
+ACPI_EXTERN u8                                  acpi_gbl_step_to_next_call;
+ACPI_EXTERN u8                                  acpi_gbl_acpi_hardware_present;
+ACPI_EXTERN u8                                  acpi_gbl_global_lock_present;
+ACPI_EXTERN u8                                  acpi_gbl_events_initialized;
+
+extern u8                                       acpi_gbl_shutdown;
+extern u32                                      acpi_gbl_startup_flags;
+extern const u8                                 acpi_gbl_decode_to8bit[8];
+extern const char                              *acpi_gbl_db_sleep_states[ACPI_S_STATE_COUNT];
+extern const struct acpi_opcode_info            acpi_gbl_aml_op_info[AML_NUM_OPCODES];
+extern const char                              *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS];
+
+
+/*****************************************************************************
+ *
+ * Namespace globals
+ *
+ ****************************************************************************/
+
+#define NUM_NS_TYPES                    ACPI_TYPE_INVALID+1
+
+#if defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
+#define NUM_PREDEFINED_NAMES            10
+#else
+#define NUM_PREDEFINED_NAMES            9
+#endif
+
+ACPI_EXTERN struct acpi_namespace_node          acpi_gbl_root_node_struct;
+ACPI_EXTERN struct acpi_namespace_node         *acpi_gbl_root_node;
+
+extern const u8                                 acpi_gbl_ns_properties[NUM_NS_TYPES];
+extern const struct acpi_predefined_names       acpi_gbl_pre_defined_names [NUM_PREDEFINED_NAMES];
+
+#ifdef ACPI_DEBUG_OUTPUT
+ACPI_EXTERN u32                                 acpi_gbl_current_node_count;
+ACPI_EXTERN u32                                 acpi_gbl_current_node_size;
+ACPI_EXTERN u32                                 acpi_gbl_max_concurrent_node_count;
+ACPI_EXTERN acpi_size                           acpi_gbl_entry_stack_pointer;
+ACPI_EXTERN acpi_size                           acpi_gbl_lowest_stack_pointer;
+ACPI_EXTERN u32                                 acpi_gbl_deepest_nesting;
+#endif
+
+/*****************************************************************************
+ *
+ * Interpreter globals
+ *
+ ****************************************************************************/
+
+
+ACPI_EXTERN struct acpi_thread_state           *acpi_gbl_current_walk_list;
+
+/* Control method single step flag */
+
+ACPI_EXTERN u8                                  acpi_gbl_cm_single_step;
+
+
+/*****************************************************************************
+ *
+ * Parser globals
+ *
+ ****************************************************************************/
+
+ACPI_EXTERN union acpi_parse_object            *acpi_gbl_parsed_namespace_root;
+
+/*****************************************************************************
+ *
+ * Hardware globals
+ *
+ ****************************************************************************/
+
+extern      struct acpi_bit_register_info       acpi_gbl_bit_register_info[ACPI_NUM_BITREG];
+ACPI_EXTERN u8                                  acpi_gbl_sleep_type_a;
+ACPI_EXTERN u8                                  acpi_gbl_sleep_type_b;
+
+
+/*****************************************************************************
+ *
+ * Event and GPE globals
+ *
+ ****************************************************************************/
+
+extern      struct acpi_fixed_event_info        acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS];
+ACPI_EXTERN struct acpi_fixed_event_handler     acpi_gbl_fixed_event_handlers[ACPI_NUM_FIXED_EVENTS];
+ACPI_EXTERN struct acpi_gpe_xrupt_info         *acpi_gbl_gpe_xrupt_list_head;
+ACPI_EXTERN struct acpi_gpe_block_info         *acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS];
+ACPI_EXTERN acpi_handle                         acpi_gbl_gpe_lock;
+
+
+/*****************************************************************************
+ *
+ * Debugger globals
+ *
+ ****************************************************************************/
+
+
+ACPI_EXTERN u8                                  acpi_gbl_db_output_flags;
+
+#ifdef ACPI_DISASSEMBLER
+
+ACPI_EXTERN u8                                  acpi_gbl_db_opt_disasm;
+ACPI_EXTERN u8                                  acpi_gbl_db_opt_verbose;
+#endif
+
+
+#ifdef ACPI_DEBUGGER
+
+extern      u8                                  acpi_gbl_method_executing;
+extern      u8                                  acpi_gbl_abort_method;
+extern      u8                                  acpi_gbl_db_terminate_threads;
+
+ACPI_EXTERN int                                 optind;
+ACPI_EXTERN char                               *optarg;
+
+ACPI_EXTERN u8                                  acpi_gbl_db_opt_tables;
+ACPI_EXTERN u8                                  acpi_gbl_db_opt_stats;
+ACPI_EXTERN u8                                  acpi_gbl_db_opt_ini_methods;
+
+
+ACPI_EXTERN char                               *acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS];
+ACPI_EXTERN char                                acpi_gbl_db_line_buf[80];
+ACPI_EXTERN char                                acpi_gbl_db_parsed_buf[80];
+ACPI_EXTERN char                                acpi_gbl_db_scope_buf[40];
+ACPI_EXTERN char                                acpi_gbl_db_debug_filename[40];
+ACPI_EXTERN u8                                  acpi_gbl_db_output_to_file;
+ACPI_EXTERN char                               *acpi_gbl_db_buffer;
+ACPI_EXTERN char                               *acpi_gbl_db_filename;
+ACPI_EXTERN u32                                 acpi_gbl_db_debug_level;
+ACPI_EXTERN u32                                 acpi_gbl_db_console_debug_level;
+ACPI_EXTERN struct acpi_table_header           *acpi_gbl_db_table_ptr;
+ACPI_EXTERN struct acpi_namespace_node         *acpi_gbl_db_scope_node;
+
+/*
+ * Statistic globals
+ */
+ACPI_EXTERN u16                                 acpi_gbl_obj_type_count[ACPI_TYPE_NS_NODE_MAX+1];
+ACPI_EXTERN u16                                 acpi_gbl_node_type_count[ACPI_TYPE_NS_NODE_MAX+1];
+ACPI_EXTERN u16                                 acpi_gbl_obj_type_count_misc;
+ACPI_EXTERN u16                                 acpi_gbl_node_type_count_misc;
+ACPI_EXTERN u32                                 acpi_gbl_num_nodes;
+ACPI_EXTERN u32                                 acpi_gbl_num_objects;
+
+
+ACPI_EXTERN u32                                 acpi_gbl_size_of_parse_tree;
+ACPI_EXTERN u32                                 acpi_gbl_size_of_method_trees;
+ACPI_EXTERN u32                                 acpi_gbl_size_of_node_entries;
+ACPI_EXTERN u32                                 acpi_gbl_size_of_acpi_objects;
+
+#endif /* ACPI_DEBUGGER */
+
+
+#endif /* __ACGLOBAL_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/achware.h linux-2.4.22-pre2/include/acpi/achware.h
--- linux-2.4.21/include/acpi/achware.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/achware.h	2003-06-26 21:43:11.000000000 +0000
@@ -0,0 +1,177 @@
+/******************************************************************************
+ *
+ * Name: achware.h -- hardware specific interfaces
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACHWARE_H__
+#define __ACHWARE_H__
+
+
+/* PM Timer ticks per second (HZ) */
+#define PM_TIMER_FREQUENCY  3579545
+
+
+/* Prototypes */
+
+
+acpi_status
+acpi_hw_initialize (
+	void);
+
+acpi_status
+acpi_hw_shutdown (
+	void);
+
+acpi_status
+acpi_hw_initialize_system_info (
+	void);
+
+acpi_status
+acpi_hw_set_mode (
+	u32                             mode);
+
+u32
+acpi_hw_get_mode (
+	void);
+
+u32
+acpi_hw_get_mode_capabilities (
+	void);
+
+/* Register I/O Prototypes */
+
+struct acpi_bit_register_info *
+acpi_hw_get_bit_register_info (
+	u32                             register_id);
+
+acpi_status
+acpi_hw_register_read (
+	u8                              use_lock,
+	u32                             register_id,
+	u32                             *return_value);
+
+acpi_status
+acpi_hw_register_write (
+	u8                              use_lock,
+	u32                             register_id,
+	u32                             value);
+
+acpi_status
+acpi_hw_low_level_read (
+	u32                             width,
+	u32                             *value,
+	struct acpi_generic_address     *reg);
+
+acpi_status
+acpi_hw_low_level_write (
+	u32                             width,
+	u32                             value,
+	struct acpi_generic_address     *reg);
+
+acpi_status
+acpi_hw_clear_acpi_status (
+	u32                             flags);
+
+
+/* GPE support */
+
+acpi_status
+acpi_hw_enable_gpe (
+	struct acpi_gpe_event_info      *gpe_event_info);
+
+void
+acpi_hw_enable_gpe_for_wakeup (
+	struct acpi_gpe_event_info      *gpe_event_info);
+
+acpi_status
+acpi_hw_disable_gpe (
+	struct acpi_gpe_event_info      *gpe_event_info);
+
+acpi_status
+acpi_hw_disable_gpe_block (
+	struct acpi_gpe_xrupt_info      *gpe_xrupt_info,
+	struct acpi_gpe_block_info      *gpe_block);
+
+void
+acpi_hw_disable_gpe_for_wakeup (
+	struct acpi_gpe_event_info      *gpe_event_info);
+
+acpi_status
+acpi_hw_clear_gpe (
+	struct acpi_gpe_event_info      *gpe_event_info);
+
+acpi_status
+acpi_hw_clear_gpe_block (
+	struct acpi_gpe_xrupt_info      *gpe_xrupt_info,
+	struct acpi_gpe_block_info      *gpe_block);
+
+acpi_status
+acpi_hw_get_gpe_status (
+	struct acpi_gpe_event_info      *gpe_event_info,
+	acpi_event_status               *event_status);
+
+acpi_status
+acpi_hw_disable_non_wakeup_gpes (
+	void);
+
+acpi_status
+acpi_hw_enable_non_wakeup_gpes (
+	void);
+
+
+/* ACPI Timer prototypes */
+
+acpi_status
+acpi_get_timer_resolution (
+	u32                             *resolution);
+
+acpi_status
+acpi_get_timer (
+	u32                             *ticks);
+
+acpi_status
+acpi_get_timer_duration (
+	u32                             start_ticks,
+	u32                             end_ticks,
+	u32                             *time_elapsed);
+
+
+#endif /* __ACHWARE_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acinterp.h linux-2.4.22-pre2/include/acpi/acinterp.h
--- linux-2.4.21/include/acpi/acinterp.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acinterp.h	2003-06-26 21:43:31.000000000 +0000
@@ -0,0 +1,738 @@
+/******************************************************************************
+ *
+ * Name: acinterp.h - Interpreter subcomponent prototypes and defines
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACINTERP_H__
+#define __ACINTERP_H__
+
+
+#define ACPI_WALK_OPERANDS       (&(walk_state->operands [walk_state->num_operands -1]))
+
+
+acpi_status
+acpi_ex_resolve_operands (
+	u16                             opcode,
+	union acpi_operand_object       **stack_ptr,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_check_object_type (
+	acpi_object_type                type_needed,
+	acpi_object_type                this_type,
+	void                            *object);
+
+/*
+ * exxface - External interpreter interfaces
+ */
+
+acpi_status
+acpi_ex_load_table (
+	acpi_table_type                 table_id);
+
+acpi_status
+acpi_ex_execute_method (
+	struct acpi_namespace_node      *method_node,
+	union acpi_operand_object       **params,
+	union acpi_operand_object       **return_obj_desc);
+
+
+/*
+ * exconvrt - object conversion
+ */
+
+acpi_status
+acpi_ex_convert_to_integer (
+	union acpi_operand_object       *obj_desc,
+	union acpi_operand_object       **result_desc,
+	struct acpi_walk_state          *walk_state);
+
+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);
+
+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);
+
+acpi_status
+acpi_ex_convert_to_target_type (
+	acpi_object_type                destination_type,
+	union acpi_operand_object       *source_desc,
+	union acpi_operand_object       **result_desc,
+	struct acpi_walk_state          *walk_state);
+
+u32
+acpi_ex_convert_to_ascii (
+	acpi_integer                    integer,
+	u32                             base,
+	u8                              *string,
+	u8                              max_length);
+
+/*
+ * exfield - ACPI AML (p-code) execution - field manipulation
+ */
+
+acpi_status
+acpi_ex_extract_from_field (
+	union acpi_operand_object       *obj_desc,
+	void                            *buffer,
+	u32                             buffer_length);
+
+acpi_status
+acpi_ex_insert_into_field (
+	union acpi_operand_object       *obj_desc,
+	void                            *buffer,
+	u32                             buffer_length);
+
+acpi_status
+acpi_ex_setup_region (
+	union acpi_operand_object       *obj_desc,
+	u32                             field_datum_byte_offset);
+
+acpi_status
+acpi_ex_access_region (
+	union acpi_operand_object       *obj_desc,
+	u32                             field_datum_byte_offset,
+	acpi_integer                    *value,
+	u32                             read_write);
+
+u8
+acpi_ex_register_overflow (
+	union acpi_operand_object       *obj_desc,
+	acpi_integer                    value);
+
+acpi_status
+acpi_ex_field_datum_io (
+	union acpi_operand_object       *obj_desc,
+	u32                             field_datum_byte_offset,
+	acpi_integer                    *value,
+	u32                             read_write);
+
+acpi_status
+acpi_ex_write_with_update_rule (
+	union acpi_operand_object       *obj_desc,
+	acpi_integer                    mask,
+	acpi_integer                    field_value,
+	u32                             field_datum_byte_offset);
+
+void
+acpi_ex_get_buffer_datum(
+	acpi_integer                    *datum,
+	void                            *buffer,
+	u32                             buffer_length,
+	u32                             byte_granularity,
+	u32                             buffer_offset);
+
+void
+acpi_ex_set_buffer_datum (
+	acpi_integer                    merged_datum,
+	void                            *buffer,
+	u32                             buffer_length,
+	u32                             byte_granularity,
+	u32                             buffer_offset);
+
+acpi_status
+acpi_ex_read_data_from_field (
+	struct acpi_walk_state          *walk_state,
+	union acpi_operand_object       *obj_desc,
+	union acpi_operand_object       **ret_buffer_desc);
+
+acpi_status
+acpi_ex_write_data_to_field (
+	union acpi_operand_object       *source_desc,
+	union acpi_operand_object       *obj_desc,
+	union acpi_operand_object       **result_desc);
+
+/*
+ * exmisc - ACPI AML (p-code) execution - specific opcodes
+ */
+
+acpi_status
+acpi_ex_opcode_3A_0T_0R (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_opcode_3A_1T_1R (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_opcode_6A_0T_1R (
+	struct acpi_walk_state          *walk_state);
+
+u8
+acpi_ex_do_match (
+	u32                             match_op,
+	acpi_integer                    package_value,
+	acpi_integer                    match_value);
+
+acpi_status
+acpi_ex_get_object_reference (
+	union acpi_operand_object       *obj_desc,
+	union acpi_operand_object       **return_desc,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_resolve_multiple (
+	struct acpi_walk_state          *walk_state,
+	union acpi_operand_object       *operand,
+	acpi_object_type                *return_type,
+	union acpi_operand_object       **return_desc);
+
+acpi_status
+acpi_ex_concat_template (
+	union acpi_operand_object       *obj_desc,
+	union acpi_operand_object       *obj_desc2,
+	union acpi_operand_object       **actual_return_desc,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_do_concatenate (
+	union acpi_operand_object       *obj_desc,
+	union acpi_operand_object       *obj_desc2,
+	union acpi_operand_object       **actual_return_desc,
+	struct acpi_walk_state          *walk_state);
+
+u8
+acpi_ex_do_logical_op (
+	u16                             opcode,
+	acpi_integer                    operand0,
+	acpi_integer                    operand1);
+
+acpi_integer
+acpi_ex_do_math_op (
+	u16                             opcode,
+	acpi_integer                    operand0,
+	acpi_integer                    operand1);
+
+acpi_status
+acpi_ex_create_mutex (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_create_processor (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_create_power_resource (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_create_region (
+	u8                              *aml_start,
+	u32                             aml_length,
+	u8                              region_space,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_create_table_region (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_create_event (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_create_alias (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_create_method (
+	u8                              *aml_start,
+	u32                             aml_length,
+	struct acpi_walk_state          *walk_state);
+
+
+/*
+ * exconfig - dynamic table load/unload
+ */
+
+acpi_status
+acpi_ex_add_table (
+	struct acpi_table_header        *table,
+	struct acpi_namespace_node      *parent_node,
+	union acpi_operand_object       **ddb_handle);
+
+acpi_status
+acpi_ex_load_op (
+	union acpi_operand_object       *obj_desc,
+	union acpi_operand_object       *target,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_load_table_op (
+	struct acpi_walk_state          *walk_state,
+	union acpi_operand_object       **return_desc);
+
+acpi_status
+acpi_ex_unload_table (
+	union acpi_operand_object       *ddb_handle);
+
+
+/*
+ * exmutex - mutex support
+ */
+
+acpi_status
+acpi_ex_acquire_mutex (
+	union acpi_operand_object       *time_desc,
+	union acpi_operand_object       *obj_desc,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_release_mutex (
+	union acpi_operand_object       *obj_desc,
+	struct acpi_walk_state          *walk_state);
+
+void
+acpi_ex_release_all_mutexes (
+	struct acpi_thread_state        *thread);
+
+void
+acpi_ex_unlink_mutex (
+	union acpi_operand_object       *obj_desc);
+
+void
+acpi_ex_link_mutex (
+	union acpi_operand_object       *obj_desc,
+	struct acpi_thread_state        *thread);
+
+/*
+ * exprep - ACPI AML (p-code) execution - prep utilities
+ */
+
+acpi_status
+acpi_ex_prep_common_field_object (
+	union acpi_operand_object       *obj_desc,
+	u8                              field_flags,
+	u8                              field_attribute,
+	u32                             field_bit_position,
+	u32                             field_bit_length);
+
+acpi_status
+acpi_ex_prep_field_value (
+	struct acpi_create_field_info   *info);
+
+/*
+ * exsystem - Interface to OS services
+ */
+
+acpi_status
+acpi_ex_system_do_notify_op (
+	union acpi_operand_object       *value,
+	union acpi_operand_object       *obj_desc);
+
+acpi_status
+acpi_ex_system_do_suspend(
+	u32                             time);
+
+acpi_status
+acpi_ex_system_do_stall (
+	u32                             time);
+
+acpi_status
+acpi_ex_system_acquire_mutex(
+	union acpi_operand_object       *time,
+	union acpi_operand_object       *obj_desc);
+
+acpi_status
+acpi_ex_system_release_mutex(
+	union acpi_operand_object       *obj_desc);
+
+acpi_status
+acpi_ex_system_signal_event(
+	union acpi_operand_object       *obj_desc);
+
+acpi_status
+acpi_ex_system_wait_event(
+	union acpi_operand_object       *time,
+	union acpi_operand_object       *obj_desc);
+
+acpi_status
+acpi_ex_system_reset_event(
+	union acpi_operand_object       *obj_desc);
+
+acpi_status
+acpi_ex_system_wait_semaphore (
+	acpi_handle                     semaphore,
+	u16                             timeout);
+
+
+/*
+ * exmonadic - ACPI AML (p-code) execution, monadic operators
+ */
+
+acpi_status
+acpi_ex_opcode_1A_0T_0R (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_opcode_1A_0T_1R (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_opcode_1A_1T_1R (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_opcode_1A_1T_0R (
+	struct acpi_walk_state          *walk_state);
+
+/*
+ * exdyadic - ACPI AML (p-code) execution, dyadic operators
+ */
+
+acpi_status
+acpi_ex_opcode_2A_0T_0R (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_opcode_2A_0T_1R (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_opcode_2A_1T_1R (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_opcode_2A_2T_1R (
+	struct acpi_walk_state          *walk_state);
+
+
+/*
+ * exresolv  - Object resolution and get value functions
+ */
+
+acpi_status
+acpi_ex_resolve_to_value (
+	union acpi_operand_object       **stack_ptr,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_resolve_node_to_value (
+	struct acpi_namespace_node      **stack_ptr,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_resolve_object_to_value (
+	union acpi_operand_object       **stack_ptr,
+	struct acpi_walk_state          *walk_state);
+
+
+/*
+ * exdump - Scanner debug output routines
+ */
+
+void
+acpi_ex_dump_operand (
+	union acpi_operand_object       *entry_desc);
+
+void
+acpi_ex_dump_operands (
+	union acpi_operand_object       **operands,
+	acpi_interpreter_mode           interpreter_mode,
+	char                            *ident,
+	u32                             num_levels,
+	char                            *note,
+	char                            *module_name,
+	u32                             line_number);
+
+void
+acpi_ex_dump_object_descriptor (
+	union acpi_operand_object       *object,
+	u32                             flags);
+
+void
+acpi_ex_dump_node (
+	struct acpi_namespace_node      *node,
+	u32                             flags);
+
+void
+acpi_ex_out_string (
+	char                            *title,
+	char                            *value);
+
+void
+acpi_ex_out_pointer (
+	char                            *title,
+	void                            *value);
+
+void
+acpi_ex_out_integer (
+	char                            *title,
+	u32                             value);
+
+void
+acpi_ex_out_address (
+	char                            *title,
+	acpi_physical_address           value);
+
+
+/*
+ * exnames - interpreter/scanner name load/execute
+ */
+
+char *
+acpi_ex_allocate_name_string (
+	u32                             prefix_count,
+	u32                             num_name_segs);
+
+u32
+acpi_ex_good_char (
+	u32                             character);
+
+acpi_status
+acpi_ex_name_segment (
+	u8                              **in_aml_address,
+	char                            *name_string);
+
+acpi_status
+acpi_ex_get_name_string (
+	acpi_object_type                data_type,
+	u8                              *in_aml_address,
+	char                            **out_name_string,
+	u32                             *out_name_length);
+
+acpi_status
+acpi_ex_do_name (
+	acpi_object_type                data_type,
+	acpi_interpreter_mode           load_exec_mode);
+
+
+/*
+ * exstore - Object store support
+ */
+
+acpi_status
+acpi_ex_store (
+	union acpi_operand_object       *val_desc,
+	union acpi_operand_object       *dest_desc,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_store_object_to_index (
+	union acpi_operand_object       *val_desc,
+	union acpi_operand_object       *dest_desc,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_store_object_to_node (
+	union acpi_operand_object       *source_desc,
+	struct acpi_namespace_node      *node,
+	struct acpi_walk_state          *walk_state);
+
+
+/*
+ * exstoren
+ */
+
+acpi_status
+acpi_ex_resolve_object (
+	union acpi_operand_object       **source_desc_ptr,
+	acpi_object_type                target_type,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ex_store_object_to_object (
+	union acpi_operand_object       *source_desc,
+	union acpi_operand_object       *dest_desc,
+	union acpi_operand_object       **new_desc,
+	struct acpi_walk_state          *walk_state);
+
+
+/*
+ * excopy - object copy
+ */
+
+acpi_status
+acpi_ex_store_buffer_to_buffer (
+	union acpi_operand_object       *source_desc,
+	union acpi_operand_object       *target_desc);
+
+acpi_status
+acpi_ex_store_string_to_string (
+	union acpi_operand_object       *source_desc,
+	union acpi_operand_object       *target_desc);
+
+acpi_status
+acpi_ex_copy_integer_to_index_field (
+	union acpi_operand_object       *source_desc,
+	union acpi_operand_object       *target_desc);
+
+acpi_status
+acpi_ex_copy_integer_to_bank_field (
+	union acpi_operand_object       *source_desc,
+	union acpi_operand_object       *target_desc);
+
+acpi_status
+acpi_ex_copy_data_to_named_field (
+	union acpi_operand_object       *source_desc,
+	struct acpi_namespace_node      *node);
+
+acpi_status
+acpi_ex_copy_integer_to_buffer_field (
+	union acpi_operand_object       *source_desc,
+	union acpi_operand_object       *target_desc);
+
+/*
+ * exutils - interpreter/scanner utilities
+ */
+
+acpi_status
+acpi_ex_enter_interpreter (
+	void);
+
+void
+acpi_ex_exit_interpreter (
+	void);
+
+void
+acpi_ex_truncate_for32bit_table (
+	union acpi_operand_object       *obj_desc);
+
+u8
+acpi_ex_acquire_global_lock (
+	u32                             rule);
+
+void
+acpi_ex_release_global_lock (
+	u8                              locked);
+
+u32
+acpi_ex_digits_needed (
+	acpi_integer                    value,
+	u32                             base);
+
+void
+acpi_ex_eisa_id_to_string (
+	u32                             numeric_id,
+	char                            *out_string);
+
+void
+acpi_ex_unsigned_integer_to_string (
+	acpi_integer                    value,
+	char                            *out_string);
+
+
+/*
+ * exregion - default op_region handlers
+ */
+
+acpi_status
+acpi_ex_system_memory_space_handler (
+	u32                             function,
+	acpi_physical_address           address,
+	u32                             bit_width,
+	acpi_integer                    *value,
+	void                            *handler_context,
+	void                            *region_context);
+
+acpi_status
+acpi_ex_system_io_space_handler (
+	u32                             function,
+	acpi_physical_address           address,
+	u32                             bit_width,
+	acpi_integer                    *value,
+	void                            *handler_context,
+	void                            *region_context);
+
+acpi_status
+acpi_ex_pci_config_space_handler (
+	u32                             function,
+	acpi_physical_address           address,
+	u32                             bit_width,
+	acpi_integer                    *value,
+	void                            *handler_context,
+	void                            *region_context);
+
+acpi_status
+acpi_ex_cmos_space_handler (
+	u32                             function,
+	acpi_physical_address           address,
+	u32                             bit_width,
+	acpi_integer                    *value,
+	void                            *handler_context,
+	void                            *region_context);
+
+acpi_status
+acpi_ex_pci_bar_space_handler (
+	u32                             function,
+	acpi_physical_address           address,
+	u32                             bit_width,
+	acpi_integer                    *value,
+	void                            *handler_context,
+	void                            *region_context);
+
+acpi_status
+acpi_ex_embedded_controller_space_handler (
+	u32                             function,
+	acpi_physical_address           address,
+	u32                             bit_width,
+	acpi_integer                    *value,
+	void                            *handler_context,
+	void                            *region_context);
+
+acpi_status
+acpi_ex_sm_bus_space_handler (
+	u32                             function,
+	acpi_physical_address           address,
+	u32                             bit_width,
+	acpi_integer                    *value,
+	void                            *handler_context,
+	void                            *region_context);
+
+
+acpi_status
+acpi_ex_data_table_space_handler (
+	u32                             function,
+	acpi_physical_address           address,
+	u32                             bit_width,
+	acpi_integer                    *value,
+	void                            *handler_context,
+	void                            *region_context);
+
+#endif /* __INTERP_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/aclocal.h linux-2.4.22-pre2/include/acpi/aclocal.h
--- linux-2.4.21/include/acpi/aclocal.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/aclocal.h	2003-06-26 21:43:11.000000000 +0000
@@ -0,0 +1,972 @@
+/******************************************************************************
+ *
+ * Name: aclocal.h - Internal data types used across the ACPI subsystem
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACLOCAL_H__
+#define __ACLOCAL_H__
+
+
+#define ACPI_WAIT_FOREVER               0xFFFF  /* u16, as per ACPI spec */
+
+typedef void *                                  acpi_mutex;
+typedef u32                                     acpi_mutex_handle;
+
+
+/* Total number of aml opcodes defined */
+
+#define AML_NUM_OPCODES                 0x7E
+
+
+/*****************************************************************************
+ *
+ * Mutex typedefs and structs
+ *
+ ****************************************************************************/
+
+
+/*
+ * Predefined handles for the mutex objects used within the subsystem
+ * All mutex objects are automatically created by acpi_ut_mutex_initialize.
+ *
+ * The acquire/release ordering protocol is implied via this list.  Mutexes
+ * with a lower value must be acquired before mutexes with a higher value.
+ *
+ * NOTE: any changes here must be reflected in the acpi_gbl_mutex_names table also!
+ */
+
+#define ACPI_MTX_EXECUTE                0
+#define ACPI_MTX_INTERPRETER            1
+#define ACPI_MTX_PARSER                 2
+#define ACPI_MTX_DISPATCHER             3
+#define ACPI_MTX_TABLES                 4
+#define ACPI_MTX_OP_REGIONS             5
+#define ACPI_MTX_NAMESPACE              6
+#define ACPI_MTX_EVENTS                 7
+#define ACPI_MTX_HARDWARE               8
+#define ACPI_MTX_CACHES                 9
+#define ACPI_MTX_MEMORY                 10
+#define ACPI_MTX_DEBUG_CMD_COMPLETE     11
+#define ACPI_MTX_DEBUG_CMD_READY        12
+
+#define MAX_MUTEX                       12
+#define NUM_MUTEX                       MAX_MUTEX+1
+
+
+#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
+#ifdef DEFINE_ACPI_GLOBALS
+
+/* Names for the mutexes used in the subsystem */
+
+static char                         *acpi_gbl_mutex_names[] =
+{
+	"ACPI_MTX_Execute",
+	"ACPI_MTX_Interpreter",
+	"ACPI_MTX_Parser",
+	"ACPI_MTX_Dispatcher",
+	"ACPI_MTX_Tables",
+	"ACPI_MTX_op_regions",
+	"ACPI_MTX_Namespace",
+	"ACPI_MTX_Events",
+	"ACPI_MTX_Hardware",
+	"ACPI_MTX_Caches",
+	"ACPI_MTX_Memory",
+	"ACPI_MTX_debug_cmd_complete",
+	"ACPI_MTX_debug_cmd_ready",
+};
+
+#endif
+#endif
+
+
+/* Table for the global mutexes */
+
+struct acpi_mutex_info
+{
+	acpi_mutex                          mutex;
+	u32                                 use_count;
+	u32                                 owner_id;
+};
+
+/* This owner ID means that the mutex is not in use (unlocked) */
+
+#define ACPI_MUTEX_NOT_ACQUIRED         (u32) (-1)
+
+
+/* Lock flag parameter for various interfaces */
+
+#define ACPI_MTX_DO_NOT_LOCK            0
+#define ACPI_MTX_LOCK                   1
+
+
+typedef u16                                     acpi_owner_id;
+#define ACPI_OWNER_TYPE_TABLE           0x0
+#define ACPI_OWNER_TYPE_METHOD          0x1
+#define ACPI_FIRST_METHOD_ID            0x0001
+#define ACPI_FIRST_TABLE_ID             0xF000
+
+
+/* Field access granularities */
+
+#define ACPI_FIELD_BYTE_GRANULARITY     1
+#define ACPI_FIELD_WORD_GRANULARITY     2
+#define ACPI_FIELD_DWORD_GRANULARITY    4
+#define ACPI_FIELD_QWORD_GRANULARITY    8
+
+/*****************************************************************************
+ *
+ * Namespace typedefs and structs
+ *
+ ****************************************************************************/
+
+
+/* Operational modes of the AML interpreter/scanner */
+
+typedef enum
+{
+	ACPI_IMODE_LOAD_PASS1               = 0x01,
+	ACPI_IMODE_LOAD_PASS2               = 0x02,
+	ACPI_IMODE_EXECUTE                  = 0x0E
+
+} acpi_interpreter_mode;
+
+
+/*
+ * The Node describes a named object that appears in the AML
+ * An acpi_node is used to store Nodes.
+ *
+ * data_type is used to differentiate between internal descriptors, and MUST
+ * be the first byte in this structure.
+ */
+
+union acpi_name_union
+{
+	u32                                 integer;
+	char                                ascii[4];
+};
+
+struct acpi_namespace_node
+{
+	u8                                  descriptor;     /* Used to differentiate object descriptor types */
+	u8                                  type;           /* Type associated with this name */
+	u16                                 owner_id;
+	union acpi_name_union               name;           /* ACPI Name, always 4 chars per ACPI spec */
+
+
+	union acpi_operand_object           *object;        /* Pointer to attached ACPI object (optional) */
+	struct acpi_namespace_node          *child;         /* First child */
+	struct acpi_namespace_node          *peer;          /* Next peer*/
+	u16                                 reference_count; /* Current count of references and children */
+	u8                                  flags;
+};
+
+
+#define ACPI_ENTRY_NOT_FOUND            NULL
+
+
+/* Node flags */
+
+#define ANOBJ_RESERVED                  0x01
+#define ANOBJ_END_OF_PEER_LIST          0x02
+#define ANOBJ_DATA_WIDTH_32             0x04     /* Parent table is 64-bits */
+#define ANOBJ_METHOD_ARG                0x08
+#define ANOBJ_METHOD_LOCAL              0x10
+#define ANOBJ_METHOD_NO_RETVAL          0x20
+#define ANOBJ_METHOD_SOME_NO_RETVAL     0x40
+
+#define ANOBJ_IS_BIT_OFFSET             0x80
+
+
+/*
+ * ACPI Table Descriptor.  One per ACPI table
+ */
+struct acpi_table_desc
+{
+	struct acpi_table_desc          *prev;
+	struct acpi_table_desc          *next;
+	struct acpi_table_desc          *installed_desc;
+	struct acpi_table_header        *pointer;
+	u8                              *aml_start;
+	u64                             physical_address;
+	u32                             aml_length;
+	acpi_size                       length;
+	acpi_owner_id                   table_id;
+	u8                              type;
+	u8                              allocation;
+	u8                              loaded_into_namespace;
+};
+
+struct acpi_table_list
+{
+	struct acpi_table_desc          *next;
+	u32                             count;
+};
+
+
+struct acpi_find_context
+{
+	char                            *search_for;
+	acpi_handle                     *list;
+	u32                             *count;
+};
+
+
+struct acpi_ns_search_data
+{
+	struct acpi_namespace_node      *node;
+};
+
+
+/*
+ * Predefined Namespace items
+ */
+struct acpi_predefined_names
+{
+	char                            *name;
+	u8                              type;
+	char                            *val;
+};
+
+
+/* Object types used during package copies */
+
+
+#define ACPI_COPY_TYPE_SIMPLE           0
+#define ACPI_COPY_TYPE_PACKAGE          1
+
+/* Info structure used to convert external<->internal namestrings */
+
+struct acpi_namestring_info
+{
+	char                            *external_name;
+	char                            *next_external_char;
+	char                            *internal_name;
+	u32                             length;
+	u32                             num_segments;
+	u32                             num_carats;
+	u8                              fully_qualified;
+};
+
+
+/* Field creation info */
+
+struct acpi_create_field_info
+{
+	struct acpi_namespace_node      *region_node;
+	struct acpi_namespace_node      *field_node;
+	struct acpi_namespace_node      *register_node;
+	struct acpi_namespace_node      *data_register_node;
+	u32                             bank_value;
+	u32                             field_bit_position;
+	u32                             field_bit_length;
+	u8                              field_flags;
+	u8                              attribute;
+	u8                              field_type;
+};
+
+
+/*****************************************************************************
+ *
+ * Event typedefs and structs
+ *
+ ****************************************************************************/
+
+/* Information about a GPE, one per each GPE in an array */
+
+struct acpi_gpe_event_info
+{
+	struct acpi_namespace_node              *method_node;   /* Method node for this GPE level */
+	acpi_gpe_handler                        handler;        /* Address of handler, if any */
+	void                                    *context;       /* Context to be passed to handler */
+	struct acpi_gpe_register_info           *register_info; /* Backpointer to register info */
+	u8                                      flags;          /* Level or Edge */
+	u8                                      bit_mask;       /* This GPE within the register */
+};
+
+/* Information about a GPE register pair, one per each status/enable pair in an array */
+
+struct acpi_gpe_register_info
+{
+	struct acpi_generic_address             status_address; /* Address of status reg */
+	struct acpi_generic_address             enable_address; /* Address of enable reg */
+	u8                                      status;         /* Current value of status reg */
+	u8                                      enable;         /* Current value of enable reg */
+	u8                                      wake_enable;    /* Mask of bits to keep enabled when sleeping */
+	u8                                      base_gpe_number; /* Base GPE number for this register */
+};
+
+/*
+ * Information about a GPE register block, one per each installed block --
+ * GPE0, GPE1, and one per each installed GPE Block Device.
+ */
+struct acpi_gpe_block_info
+{
+	struct acpi_gpe_block_info              *previous;
+	struct acpi_gpe_block_info              *next;
+	struct acpi_gpe_xrupt_info              *xrupt_block;   /* Backpointer to interrupt block */
+	struct acpi_gpe_register_info           *register_info; /* One per GPE register pair */
+	struct acpi_gpe_event_info              *event_info;    /* One for each GPE */
+	struct acpi_generic_address             block_address;  /* Base address of the block */
+	u32                                     register_count; /* Number of register pairs in block */
+	u8                                      block_base_number;/* Base GPE number for this block */
+};
+
+/* Information about GPE interrupt handlers, one per each interrupt level used for GPEs */
+
+struct acpi_gpe_xrupt_info
+{
+	struct acpi_gpe_xrupt_info              *previous;
+	struct acpi_gpe_xrupt_info              *next;
+	struct acpi_gpe_block_info              *gpe_block_list_head; /* List of GPE blocks for this xrupt */
+	u32                                     interrupt_level;    /* System interrupt level */
+};
+
+
+typedef acpi_status (*ACPI_GPE_CALLBACK) (
+	struct acpi_gpe_xrupt_info      *gpe_xrupt_info,
+	struct acpi_gpe_block_info      *gpe_block);
+
+
+/* Information about each particular fixed event */
+
+struct acpi_fixed_event_handler
+{
+	acpi_event_handler              handler;        /* Address of handler. */
+	void                            *context;       /* Context to be passed to handler */
+};
+
+struct acpi_fixed_event_info
+{
+	u8                              status_register_id;
+	u8                              enable_register_id;
+	u16                             status_bit_mask;
+	u16                             enable_bit_mask;
+};
+
+/* Information used during field processing */
+
+struct acpi_field_info
+{
+	u8                              skip_field;
+	u8                              field_flag;
+	u32                             pkg_length;
+};
+
+
+/*****************************************************************************
+ *
+ * Generic "state" object for stacks
+ *
+ ****************************************************************************/
+
+
+#define ACPI_CONTROL_NORMAL                  0xC0
+#define ACPI_CONTROL_CONDITIONAL_EXECUTING   0xC1
+#define ACPI_CONTROL_PREDICATE_EXECUTING     0xC2
+#define ACPI_CONTROL_PREDICATE_FALSE         0xC3
+#define ACPI_CONTROL_PREDICATE_TRUE          0xC4
+
+
+/* Forward declarations */
+struct acpi_walk_state        ;
+struct acpi_obj_mutex;
+union acpi_parse_object        ;
+
+
+#define ACPI_STATE_COMMON                  /* Two 32-bit fields and a pointer */\
+	u8                                  data_type;          /* To differentiate various internal objs */\
+	u8                                  flags;      \
+	u16                                 value;      \
+	u16                                 state;      \
+	u16                                 reserved;   \
+	void                                *next;      \
+
+struct acpi_common_state
+{
+	ACPI_STATE_COMMON
+};
+
+
+/*
+ * Update state - used to traverse complex objects such as packages
+ */
+struct acpi_update_state
+{
+	ACPI_STATE_COMMON
+	union acpi_operand_object           *object;
+};
+
+
+/*
+ * Pkg state - used to traverse nested package structures
+ */
+struct acpi_pkg_state
+{
+	ACPI_STATE_COMMON
+	union acpi_operand_object           *source_object;
+	union acpi_operand_object           *dest_object;
+	struct acpi_walk_state              *walk_state;
+	void                                *this_target_obj;
+	u32                                 num_packages;
+	u16                                 index;
+};
+
+
+/*
+ * Control state - one per if/else and while constructs.
+ * Allows nesting of these constructs
+ */
+struct acpi_control_state
+{
+	ACPI_STATE_COMMON
+	union acpi_parse_object             *predicate_op;
+	u8                                  *aml_predicate_start;   /* Start of if/while predicate */
+	u8                                  *package_end;           /* End of if/while block */
+	u16                                 opcode;
+};
+
+
+/*
+ * Scope state - current scope during namespace lookups
+ */
+struct acpi_scope_state
+{
+	ACPI_STATE_COMMON
+	struct acpi_namespace_node          *node;
+};
+
+
+struct acpi_pscope_state
+{
+	ACPI_STATE_COMMON
+	union acpi_parse_object             *op;                    /* Current op being parsed */
+	u8                                  *arg_end;               /* Current argument end */
+	u8                                  *pkg_end;               /* Current package end */
+	u32                                 arg_list;               /* Next argument to parse */
+	u32                                 arg_count;              /* Number of fixed arguments */
+};
+
+
+/*
+ * Thread state - one per thread across multiple walk states.  Multiple walk
+ * states are created when there are nested control methods executing.
+ */
+struct acpi_thread_state
+{
+	ACPI_STATE_COMMON
+	struct acpi_walk_state              *walk_state_list;       /* Head of list of walk_states for this thread */
+	union acpi_operand_object           *acquired_mutex_list;   /* List of all currently acquired mutexes */
+	u32                                 thread_id;              /* Running thread ID */
+	u16                                 current_sync_level;     /* Mutex Sync (nested acquire) level */
+};
+
+
+/*
+ * Result values - used to accumulate the results of nested
+ * AML arguments
+ */
+struct acpi_result_values
+{
+	ACPI_STATE_COMMON
+	union acpi_operand_object           *obj_desc [ACPI_OBJ_NUM_OPERANDS];
+	u8                                  num_results;
+	u8                                  last_insert;
+};
+
+
+typedef
+acpi_status (*acpi_parse_downwards) (
+	struct acpi_walk_state              *walk_state,
+	union acpi_parse_object             **out_op);
+
+typedef
+acpi_status (*acpi_parse_upwards) (
+	struct acpi_walk_state              *walk_state);
+
+
+/*
+ * Notify info - used to pass info to the deferred notify
+ * handler/dispatcher.
+ */
+struct acpi_notify_info
+{
+	ACPI_STATE_COMMON
+	struct acpi_namespace_node          *node;
+	union acpi_operand_object           *handler_obj;
+};
+
+
+/* Generic state is union of structs above */
+
+union acpi_generic_state
+{
+	struct acpi_common_state            common;
+	struct acpi_control_state           control;
+	struct acpi_update_state            update;
+	struct acpi_scope_state             scope;
+	struct acpi_pscope_state            parse_scope;
+	struct acpi_pkg_state               pkg;
+	struct acpi_thread_state            thread;
+	struct acpi_result_values           results;
+	struct acpi_notify_info             notify;
+};
+
+
+/*****************************************************************************
+ *
+ * Interpreter typedefs and structs
+ *
+ ****************************************************************************/
+
+typedef
+acpi_status (*ACPI_EXECUTE_OP) (
+	struct acpi_walk_state              *walk_state);
+
+
+/*****************************************************************************
+ *
+ * Parser typedefs and structs
+ *
+ ****************************************************************************/
+
+/*
+ * AML opcode, name, and argument layout
+ */
+struct acpi_opcode_info
+{
+#if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT)
+	char                                *name;          /* Opcode name (disassembler/debug only) */
+#endif
+	u32                                 parse_args;     /* Grammar/Parse time arguments */
+	u32                                 runtime_args;   /* Interpret time arguments */
+	u32                                 flags;          /* Misc flags */
+	u8                                  object_type;    /* Corresponding internal object type */
+	u8                                  class;          /* Opcode class */
+	u8                                  type;           /* Opcode type */
+};
+
+
+union acpi_parse_value
+{
+	acpi_integer                        integer;        /* Integer constant (Up to 64 bits) */
+	struct uint64_struct                integer64;      /* Structure overlay for 2 32-bit Dwords */
+	u32                                 size;           /* bytelist or field size */
+	char                                *string;        /* NULL terminated string */
+	u8                                  *buffer;        /* buffer or string */
+	char                                *name;          /* NULL terminated string */
+	union acpi_parse_object             *arg;           /* arguments and contained ops */
+};
+
+
+#define ACPI_PARSE_COMMON \
+	u8                                  data_type;      /* To differentiate various internal objs */\
+	u8                                  flags;          /* Type of Op */\
+	u16                                 aml_opcode;     /* AML opcode */\
+	u32                                 aml_offset;     /* Offset of declaration in AML */\
+	union acpi_parse_object             *parent;        /* Parent op */\
+	union acpi_parse_object             *next;          /* Next op */\
+	ACPI_DISASM_ONLY_MEMBERS (\
+	u8                                  disasm_flags;   /* Used during AML disassembly */\
+	u8                                  disasm_opcode;  /* Subtype used for disassembly */\
+	char                                aml_op_name[16]) /* Op name (debug only) */\
+			   /* NON-DEBUG members below: */\
+	struct acpi_namespace_node          *node;          /* For use by interpreter */\
+	union acpi_parse_value              value;          /* Value or args associated with the opcode */\
+
+
+#define ACPI_DASM_BUFFER        0x00
+#define ACPI_DASM_RESOURCE      0x01
+#define ACPI_DASM_STRING        0x02
+#define ACPI_DASM_UNICODE       0x03
+#define ACPI_DASM_EISAID        0x04
+#define ACPI_DASM_MATCHOP       0x05
+
+/*
+ * generic operation (for example:  If, While, Store)
+ */
+struct acpi_parse_obj_common
+{
+	ACPI_PARSE_COMMON
+};
+
+
+/*
+ * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and op_regions),
+ * and bytelists.
+ */
+struct acpi_parse_obj_named
+{
+	ACPI_PARSE_COMMON
+	u8                                  *path;
+	u8                                  *data;          /* AML body or bytelist data */
+	u32                                 length;         /* AML length */
+	u32                                 name;           /* 4-byte name or zero if no name */
+};
+
+
+/* The parse node is the fundamental element of the parse tree */
+
+struct acpi_parse_obj_asl
+{
+	ACPI_PARSE_COMMON
+	union acpi_parse_object             *child;
+	union acpi_parse_object             *parent_method;
+	char                                *filename;
+	char                                *external_name;
+	char                                *namepath;
+	char                                name_seg[4];
+	u32                                 extra_value;
+	u32                                 column;
+	u32                                 line_number;
+	u32                                 logical_line_number;
+	u32                                 logical_byte_offset;
+	u32                                 end_line;
+	u32                                 end_logical_line;
+	u32                                 acpi_btype;
+	u32                                 aml_length;
+	u32                                 aml_subtree_length;
+	u32                                 final_aml_length;
+	u32                                 final_aml_offset;
+	u32                                 compile_flags;
+	u16                                 parse_opcode;
+	u8                                  aml_opcode_length;
+	u8                                  aml_pkg_len_bytes;
+	u8                                  extra;
+	char                                parse_op_name[12];
+};
+
+
+union acpi_parse_object
+{
+	struct acpi_parse_obj_common        common;
+	struct acpi_parse_obj_named         named;
+	struct acpi_parse_obj_asl           asl;
+};
+
+
+/*
+ * Parse state - one state per parser invocation and each control
+ * method.
+ */
+struct acpi_parse_state
+{
+	u32                                 aml_size;
+	u8                                  *aml_start;     /* First AML byte */
+	u8                                  *aml;           /* Next AML byte */
+	u8                                  *aml_end;       /* (last + 1) AML byte */
+	u8                                  *pkg_start;     /* Current package begin */
+	u8                                  *pkg_end;       /* Current package end */
+	union acpi_parse_object             *start_op;      /* Root of parse tree */
+	struct acpi_namespace_node          *start_node;
+	union acpi_generic_state            *scope;         /* Current scope */
+	union acpi_parse_object             *start_scope;
+};
+
+
+/* Parse object flags */
+
+#define ACPI_PARSEOP_GENERIC                    0x01
+#define ACPI_PARSEOP_NAMED                      0x02
+#define ACPI_PARSEOP_DEFERRED                   0x04
+#define ACPI_PARSEOP_BYTELIST                   0x08
+#define ACPI_PARSEOP_IN_CACHE                   0x80
+
+/* Parse object disasm_flags */
+
+#define ACPI_PARSEOP_IGNORE                     0x01
+#define ACPI_PARSEOP_PARAMLIST                  0x02
+#define ACPI_PARSEOP_EMPTY_TERMLIST             0x04
+#define ACPI_PARSEOP_SPECIAL                    0x10
+
+
+/*****************************************************************************
+ *
+ * Hardware (ACPI registers) and PNP
+ *
+ ****************************************************************************/
+
+#define PCI_ROOT_HID_STRING         "PNP0A03"
+
+struct acpi_bit_register_info
+{
+	u8                                  parent_register;
+	u8                                  bit_position;
+	u16                                 access_bit_mask;
+};
+
+
+/*
+ * Register IDs
+ * These are the full ACPI registers
+ */
+#define ACPI_REGISTER_PM1_STATUS                0x01
+#define ACPI_REGISTER_PM1_ENABLE                0x02
+#define ACPI_REGISTER_PM1_CONTROL               0x03
+#define ACPI_REGISTER_PM1A_CONTROL              0x04
+#define ACPI_REGISTER_PM1B_CONTROL              0x05
+#define ACPI_REGISTER_PM2_CONTROL               0x06
+#define ACPI_REGISTER_PM_TIMER                  0x07
+#define ACPI_REGISTER_PROCESSOR_BLOCK           0x08
+#define ACPI_REGISTER_SMI_COMMAND_BLOCK         0x09
+
+
+/* Masks used to access the bit_registers */
+
+#define ACPI_BITMASK_TIMER_STATUS               0x0001
+#define ACPI_BITMASK_BUS_MASTER_STATUS          0x0010
+#define ACPI_BITMASK_GLOBAL_LOCK_STATUS         0x0020
+#define ACPI_BITMASK_POWER_BUTTON_STATUS        0x0100
+#define ACPI_BITMASK_SLEEP_BUTTON_STATUS        0x0200
+#define ACPI_BITMASK_RT_CLOCK_STATUS            0x0400
+#define ACPI_BITMASK_WAKE_STATUS                0x8000
+
+#define ACPI_BITMASK_ALL_FIXED_STATUS           (ACPI_BITMASK_TIMER_STATUS          | \
+			 ACPI_BITMASK_BUS_MASTER_STATUS     | \
+			 ACPI_BITMASK_GLOBAL_LOCK_STATUS    | \
+			 ACPI_BITMASK_POWER_BUTTON_STATUS   | \
+			 ACPI_BITMASK_SLEEP_BUTTON_STATUS   | \
+			 ACPI_BITMASK_RT_CLOCK_STATUS       | \
+			 ACPI_BITMASK_WAKE_STATUS)
+
+#define ACPI_BITMASK_TIMER_ENABLE               0x0001
+#define ACPI_BITMASK_GLOBAL_LOCK_ENABLE         0x0020
+#define ACPI_BITMASK_POWER_BUTTON_ENABLE        0x0100
+#define ACPI_BITMASK_SLEEP_BUTTON_ENABLE        0x0200
+#define ACPI_BITMASK_RT_CLOCK_ENABLE            0x0400
+
+#define ACPI_BITMASK_SCI_ENABLE                 0x0001
+#define ACPI_BITMASK_BUS_MASTER_RLD             0x0002
+#define ACPI_BITMASK_GLOBAL_LOCK_RELEASE        0x0004
+#define ACPI_BITMASK_SLEEP_TYPE_X               0x1C00
+#define ACPI_BITMASK_SLEEP_ENABLE               0x2000
+
+#define ACPI_BITMASK_ARB_DISABLE                0x0001
+
+
+/* Raw bit position of each bit_register */
+
+#define ACPI_BITPOSITION_TIMER_STATUS           0x00
+#define ACPI_BITPOSITION_BUS_MASTER_STATUS      0x04
+#define ACPI_BITPOSITION_GLOBAL_LOCK_STATUS     0x05
+#define ACPI_BITPOSITION_POWER_BUTTON_STATUS    0x08
+#define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS    0x09
+#define ACPI_BITPOSITION_RT_CLOCK_STATUS        0x0A
+#define ACPI_BITPOSITION_WAKE_STATUS            0x0F
+
+#define ACPI_BITPOSITION_TIMER_ENABLE           0x00
+#define ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE     0x05
+#define ACPI_BITPOSITION_POWER_BUTTON_ENABLE    0x08
+#define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE    0x09
+#define ACPI_BITPOSITION_RT_CLOCK_ENABLE        0x0A
+
+#define ACPI_BITPOSITION_SCI_ENABLE             0x00
+#define ACPI_BITPOSITION_BUS_MASTER_RLD         0x01
+#define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE    0x02
+#define ACPI_BITPOSITION_SLEEP_TYPE_X           0x0A
+#define ACPI_BITPOSITION_SLEEP_ENABLE           0x0D
+
+#define ACPI_BITPOSITION_ARB_DISABLE            0x00
+
+
+/*****************************************************************************
+ *
+ * Resource descriptors
+ *
+ ****************************************************************************/
+
+
+/* resource_type values */
+
+#define ACPI_RESOURCE_TYPE_MEMORY_RANGE         0
+#define ACPI_RESOURCE_TYPE_IO_RANGE             1
+#define ACPI_RESOURCE_TYPE_BUS_NUMBER_RANGE     2
+
+/* Resource descriptor types and masks */
+
+#define ACPI_RDESC_TYPE_LARGE                   0x80
+#define ACPI_RDESC_TYPE_SMALL                   0x00
+
+#define ACPI_RDESC_TYPE_MASK                    0x80
+#define ACPI_RDESC_SMALL_MASK                   0x78 /* Only bits 6:3 contain the type */
+
+
+/*
+ * Small resource descriptor types
+ * Note: The 3 length bits (2:0) must be zero
+ */
+#define ACPI_RDESC_TYPE_IRQ_FORMAT              0x20
+#define ACPI_RDESC_TYPE_DMA_FORMAT              0x28
+#define ACPI_RDESC_TYPE_START_DEPENDENT         0x30
+#define ACPI_RDESC_TYPE_END_DEPENDENT           0x38
+#define ACPI_RDESC_TYPE_IO_PORT                 0x40
+#define ACPI_RDESC_TYPE_FIXED_IO_PORT           0x48
+#define ACPI_RDESC_TYPE_SMALL_VENDOR            0x70
+#define ACPI_RDESC_TYPE_END_TAG                 0x78
+
+/*
+ * Large resource descriptor types
+ */
+
+#define ACPI_RDESC_TYPE_MEMORY_24               0x81
+#define ACPI_RDESC_TYPE_GENERAL_REGISTER        0x82
+#define ACPI_RDESC_TYPE_LARGE_VENDOR            0x84
+#define ACPI_RDESC_TYPE_MEMORY_32               0x85
+#define ACPI_RDESC_TYPE_FIXED_MEMORY_32         0x86
+#define ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE     0x87
+#define ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE      0x88
+#define ACPI_RDESC_TYPE_EXTENDED_XRUPT          0x89
+#define ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE     0x8A
+
+
+/*****************************************************************************
+ *
+ * Miscellaneous
+ *
+ ****************************************************************************/
+
+#define ACPI_ASCII_ZERO                      0x30
+
+
+/*****************************************************************************
+ *
+ * Debugger
+ *
+ ****************************************************************************/
+
+struct acpi_db_method_info
+{
+	acpi_handle                     thread_gate;
+	char                            *name;
+	char                            **args;
+	u32                             flags;
+	u32                             num_loops;
+	char                            pathname[128];
+};
+
+struct acpi_integrity_info
+{
+	u32                         nodes;
+	u32                         objects;
+};
+
+
+#define ACPI_DB_REDIRECTABLE_OUTPUT  0x01
+#define ACPI_DB_CONSOLE_OUTPUT       0x02
+#define ACPI_DB_DUPLICATE_OUTPUT     0x03
+
+
+/*****************************************************************************
+ *
+ * Debug
+ *
+ ****************************************************************************/
+
+struct acpi_debug_print_info
+{
+	u32                             component_id;
+	char                            *proc_name;
+	char                            *module_name;
+};
+
+
+/* Entry for a memory allocation (debug only) */
+
+#define ACPI_MEM_MALLOC                      0
+#define ACPI_MEM_CALLOC                      1
+#define ACPI_MAX_MODULE_NAME                 16
+
+#define ACPI_COMMON_DEBUG_MEM_HEADER \
+	struct acpi_debug_mem_block         *previous; \
+	struct acpi_debug_mem_block         *next; \
+	u32                                 size; \
+	u32                                 component; \
+	u32                                 line; \
+	char                                module[ACPI_MAX_MODULE_NAME]; \
+	u8                                  alloc_type;
+
+struct acpi_debug_mem_header
+{
+	ACPI_COMMON_DEBUG_MEM_HEADER
+};
+
+struct acpi_debug_mem_block
+{
+	ACPI_COMMON_DEBUG_MEM_HEADER
+	u64                                 user_space;
+};
+
+
+#define ACPI_MEM_LIST_GLOBAL            0
+#define ACPI_MEM_LIST_NSNODE            1
+
+#define ACPI_MEM_LIST_FIRST_CACHE_LIST  2
+#define ACPI_MEM_LIST_STATE             2
+#define ACPI_MEM_LIST_PSNODE            3
+#define ACPI_MEM_LIST_PSNODE_EXT        4
+#define ACPI_MEM_LIST_OPERAND           5
+#define ACPI_MEM_LIST_WALK              6
+#define ACPI_MEM_LIST_MAX               6
+#define ACPI_NUM_MEM_LISTS              7
+
+
+struct acpi_memory_list
+{
+	void                                *list_head;
+	u16                                 link_offset;
+	u16                                 max_cache_depth;
+	u16                                 cache_depth;
+	u16                                 object_size;
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+
+	/* Statistics for debug memory tracking only */
+
+	u32                                 total_allocated;
+	u32                                 total_freed;
+	u32                                 current_total_size;
+	u32                                 cache_requests;
+	u32                                 cache_hits;
+	char                                *list_name;
+#endif
+};
+
+
+#endif /* __ACLOCAL_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acmacros.h linux-2.4.22-pre2/include/acpi/acmacros.h
--- linux-2.4.21/include/acpi/acmacros.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acmacros.h	2003-06-26 21:43:27.000000000 +0000
@@ -0,0 +1,690 @@
+/******************************************************************************
+ *
+ * Name: acmacros.h - C macros for the entire subsystem.
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACMACROS_H__
+#define __ACMACROS_H__
+
+
+/*
+ * Data manipulation macros
+ */
+
+#define ACPI_LOWORD(l)                  ((u16)(u32)(l))
+#define ACPI_HIWORD(l)                  ((u16)((((u32)(l)) >> 16) & 0xFFFF))
+#define ACPI_LOBYTE(l)                  ((u8)(u16)(l))
+#define ACPI_HIBYTE(l)                  ((u8)((((u16)(l)) >> 8) & 0xFF))
+
+
+#if ACPI_MACHINE_WIDTH == 16
+
+/*
+ * For 16-bit addresses, we have to assume that the upper 32 bits
+ * are zero.
+ */
+#define ACPI_LODWORD(l)                 ((u32)(l))
+#define ACPI_HIDWORD(l)                 ((u32)(0))
+
+#define ACPI_GET_ADDRESS(a)             ((a).lo)
+#define ACPI_STORE_ADDRESS(a,b)         {(a).hi=0;(a).lo=(u32)(b);}
+#define ACPI_VALID_ADDRESS(a)           ((a).hi | (a).lo)
+
+#else
+#ifdef ACPI_NO_INTEGER64_SUPPORT
+/*
+ * acpi_integer is 32-bits, no 64-bit support on this platform
+ */
+#define ACPI_LODWORD(l)                 ((u32)(l))
+#define ACPI_HIDWORD(l)                 ((u32)(0))
+
+#define ACPI_GET_ADDRESS(a)             (a)
+#define ACPI_STORE_ADDRESS(a,b)         ((a)=(b))
+#define ACPI_VALID_ADDRESS(a)           (a)
+
+#else
+
+/*
+ * Full 64-bit address/integer on both 32-bit and 64-bit platforms
+ */
+#define ACPI_LODWORD(l)                 ((u32)(u64)(l))
+#define ACPI_HIDWORD(l)                 ((u32)(((*(struct uint64_struct *)(void *)(&l))).hi))
+
+#define ACPI_GET_ADDRESS(a)             (a)
+#define ACPI_STORE_ADDRESS(a,b)         ((a)=(acpi_physical_address)(b))
+#define ACPI_VALID_ADDRESS(a)           (a)
+#endif
+#endif
+
+ /*
+  * Extract a byte of data using a pointer.  Any more than a byte and we
+  * get into potential aligment issues -- see the STORE macros below
+  */
+#define ACPI_GET8(addr)                 (*(u8*)(addr))
+
+/* Pointer arithmetic */
+
+#define ACPI_PTR_ADD(t,a,b)             (t *) (void *)((char *)(a) + (acpi_native_uint)(b))
+#define ACPI_PTR_DIFF(a,b)              (acpi_native_uint) ((char *)(a) - (char *)(b))
+
+/* Pointer/Integer type conversions */
+
+#define ACPI_TO_POINTER(i)              ACPI_PTR_ADD (void, (void *) NULL,(acpi_native_uint)i)
+#define ACPI_TO_INTEGER(p)              ACPI_PTR_DIFF (p,(void *) NULL)
+#define ACPI_OFFSET(d,f)                (acpi_size) ACPI_PTR_DIFF (&(((d *)0)->f),(void *) NULL)
+#define ACPI_FADT_OFFSET(f)             ACPI_OFFSET (FADT_DESCRIPTOR, f)
+
+#define ACPI_CAST_PTR(t, p)             ((t *)(void *)(p))
+#define ACPI_CAST_INDIRECT_PTR(t, p)    ((t **)(void *)(p))
+
+#if ACPI_MACHINE_WIDTH == 16
+#define ACPI_STORE_POINTER(d,s)         ACPI_MOVE_32_TO_32(d,s)
+#define ACPI_PHYSADDR_TO_PTR(i)         (void *)(i)
+#define ACPI_PTR_TO_PHYSADDR(i)         (u32) (char *)(i)
+#else
+#define ACPI_PHYSADDR_TO_PTR(i)         ACPI_TO_POINTER(i)
+#define ACPI_PTR_TO_PHYSADDR(i)         ACPI_TO_INTEGER(i)
+#endif
+
+/*
+ * Macros for moving data around to/from buffers that are possibly unaligned.
+ * If the hardware supports the transfer of unaligned data, just do the store.
+ * Otherwise, we have to move one byte at a time.
+ */
+
+#ifdef ACPI_BIG_ENDIAN
+/*
+ * Macros for big-endian machines
+ */
+
+/* This macro sets a buffer index, starting from the end of the buffer */
+
+#define ACPI_BUFFER_INDEX(buf_len,buf_offset,byte_gran) ((buf_len) - (((buf_offset)+1) * (byte_gran)))
+
+/* These macros reverse the bytes during the move, converting little-endian to big endian */
+
+	 /* Big Endian      <==        Little Endian */
+	 /*  Hi...Lo                     Lo...Hi     */
+/* 16-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_16_TO_16(d,s)         {((  u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[1];\
+			  ((  u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[0];}
+
+#define ACPI_MOVE_16_TO_32(d,s)         {(*(u32 *)(void *)(d))=0;\
+					  ((u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\
+					  ((u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];}
+
+#define ACPI_MOVE_16_TO_64(d,s)         {(*(u64 *)(void *)(d))=0;\
+							   ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\
+							   ((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];}
+
+/* 32-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_32_TO_16(d,s)         ACPI_MOVE_16_TO_16(d,s)    /* Truncate to 16 */
+
+#define ACPI_MOVE_32_TO_32(d,s)         {((  u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[3];\
+									  ((  u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[2];\
+									  ((  u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\
+									  ((  u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];}
+
+#define ACPI_MOVE_32_TO_64(d,s)         {(*(u64 *)(void *)(d))=0;\
+										   ((u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[3];\
+										   ((u8 *)(void *)(d))[5] = ((u8 *)(void *)(s))[2];\
+										   ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\
+										   ((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];}
+
+/* 64-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_64_TO_16(d,s)         ACPI_MOVE_16_TO_16(d,s)    /* Truncate to 16 */
+
+#define ACPI_MOVE_64_TO_32(d,s)         ACPI_MOVE_32_TO_32(d,s)    /* Truncate to 32 */
+
+#define ACPI_MOVE_64_TO_64(d,s)         {((  u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[7];\
+										 ((  u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[6];\
+										 ((  u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[5];\
+										 ((  u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[4];\
+										 ((  u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[3];\
+										 ((  u8 *)(void *)(d))[5] = ((u8 *)(void *)(s))[2];\
+										 ((  u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\
+										 ((  u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];}
+#else
+/*
+ * Macros for little-endian machines
+ */
+
+/* This macro sets a buffer index, starting from the beginning of the buffer */
+
+#define ACPI_BUFFER_INDEX(buf_len,buf_offset,byte_gran) (buf_offset)
+
+#ifdef ACPI_MISALIGNED_TRANSFERS
+
+/* The hardware supports unaligned transfers, just do the little-endian move */
+
+#if ACPI_MACHINE_WIDTH == 16
+
+/* No 64-bit integers */
+/* 16-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_16_TO_16(d,s)         *(u16 *)(void *)(d) = *(u16 *)(void *)(s)
+#define ACPI_MOVE_16_TO_32(d,s)         *(u32 *)(void *)(d) = *(u16 *)(void *)(s)
+#define ACPI_MOVE_16_TO_64(d,s)         ACPI_MOVE_16_TO_32(d,s)
+
+/* 32-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_32_TO_16(d,s)         ACPI_MOVE_16_TO_16(d,s)    /* Truncate to 16 */
+#define ACPI_MOVE_32_TO_32(d,s)         *(u32 *)(void *)(d) = *(u32 *)(void *)(s)
+#define ACPI_MOVE_32_TO_64(d,s)         ACPI_MOVE_32_TO_32(d,s)
+
+/* 64-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_64_TO_16(d,s)         ACPI_MOVE_16_TO_16(d,s)    /* Truncate to 16 */
+#define ACPI_MOVE_64_TO_32(d,s)         ACPI_MOVE_32_TO_32(d,s)    /* Truncate to 32 */
+#define ACPI_MOVE_64_TO_64(d,s)         ACPI_MOVE_32_TO_32(d,s)
+
+#else
+/* 16-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_16_TO_16(d,s)         *(u16 *)(void *)(d) = *(u16 *)(void *)(s)
+#define ACPI_MOVE_16_TO_32(d,s)         *(u32 *)(void *)(d) = *(u16 *)(void *)(s)
+#define ACPI_MOVE_16_TO_64(d,s)         *(u64 *)(void *)(d) = *(u16 *)(void *)(s)
+
+/* 32-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_32_TO_16(d,s)         ACPI_MOVE_16_TO_16(d,s)    /* Truncate to 16 */
+#define ACPI_MOVE_32_TO_32(d,s)         *(u32 *)(void *)(d) = *(u32 *)(void *)(s)
+#define ACPI_MOVE_32_TO_64(d,s)         *(u64 *)(void *)(d) = *(u32 *)(void *)(s)
+
+/* 64-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_64_TO_16(d,s)         ACPI_MOVE_16_TO_16(d,s)    /* Truncate to 16 */
+#define ACPI_MOVE_64_TO_32(d,s)         ACPI_MOVE_32_TO_32(d,s)    /* Truncate to 32 */
+#define ACPI_MOVE_64_TO_64(d,s)         *(u64 *)(void *)(d) = *(u64 *)(void *)(s)
+#endif
+
+#else
+/*
+ * The hardware does not support unaligned transfers.  We must move the
+ * data one byte at a time.  These macros work whether the source or
+ * the destination (or both) is/are unaligned.  (Little-endian move)
+ */
+
+/* 16-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_16_TO_16(d,s)         {((  u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\
+										 ((  u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];}
+
+#define ACPI_MOVE_16_TO_32(d,s)         {(*(u32 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d,s);}
+#define ACPI_MOVE_16_TO_64(d,s)         {(*(u64 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d,s);}
+
+/* 32-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_32_TO_16(d,s)         ACPI_MOVE_16_TO_16(d,s)    /* Truncate to 16 */
+
+#define ACPI_MOVE_32_TO_32(d,s)         {((  u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\
+										 ((  u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];\
+										 ((  u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[2];\
+										 ((  u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[3];}
+
+#define ACPI_MOVE_32_TO_64(d,s)         {(*(u64 *)(void *)(d)) = 0; ACPI_MOVE_32_TO_32(d,s);}
+
+/* 64-bit source, 16/32/64 destination */
+
+#define ACPI_MOVE_64_TO_16(d,s)         ACPI_MOVE_16_TO_16(d,s)    /* Truncate to 16 */
+#define ACPI_MOVE_64_TO_32(d,s)         ACPI_MOVE_32_TO_32(d,s)    /* Truncate to 32 */
+#define ACPI_MOVE_64_TO_64(d,s)         {((  u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\
+										 ((  u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];\
+										 ((  u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[2];\
+										 ((  u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[3];\
+										 ((  u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[4];\
+										 ((  u8 *)(void *)(d))[5] = ((u8 *)(void *)(s))[5];\
+										 ((  u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[6];\
+										 ((  u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[7];}
+#endif
+#endif
+
+/* Macros based on machine integer width */
+
+#if ACPI_MACHINE_WIDTH == 16
+#define ACPI_MOVE_SIZE_TO_16(d,s)       ACPI_MOVE_16_TO_16(d,s)
+
+#elif ACPI_MACHINE_WIDTH == 32
+#define ACPI_MOVE_SIZE_TO_16(d,s)       ACPI_MOVE_32_TO_16(d,s)
+
+#elif ACPI_MACHINE_WIDTH == 64
+#define ACPI_MOVE_SIZE_TO_16(d,s)       ACPI_MOVE_64_TO_16(d,s)
+
+#else
+#error unknown ACPI_MACHINE_WIDTH
+#endif
+
+
+/*
+ * Fast power-of-two math macros for non-optimized compilers
+ */
+
+#define _ACPI_DIV(value,power_of2)      ((u32) ((value) >> (power_of2)))
+#define _ACPI_MUL(value,power_of2)      ((u32) ((value) << (power_of2)))
+#define _ACPI_MOD(value,divisor)        ((u32) ((value) & ((divisor) -1)))
+
+#define ACPI_DIV_2(a)                   _ACPI_DIV(a,1)
+#define ACPI_MUL_2(a)                   _ACPI_MUL(a,1)
+#define ACPI_MOD_2(a)                   _ACPI_MOD(a,2)
+
+#define ACPI_DIV_4(a)                   _ACPI_DIV(a,2)
+#define ACPI_MUL_4(a)                   _ACPI_MUL(a,2)
+#define ACPI_MOD_4(a)                   _ACPI_MOD(a,4)
+
+#define ACPI_DIV_8(a)                   _ACPI_DIV(a,3)
+#define ACPI_MUL_8(a)                   _ACPI_MUL(a,3)
+#define ACPI_MOD_8(a)                   _ACPI_MOD(a,8)
+
+#define ACPI_DIV_16(a)                  _ACPI_DIV(a,4)
+#define ACPI_MUL_16(a)                  _ACPI_MUL(a,4)
+#define ACPI_MOD_16(a)                  _ACPI_MOD(a,16)
+
+
+/*
+ * Rounding macros (Power of two boundaries only)
+ */
+#define ACPI_ROUND_DOWN(value,boundary)      (((acpi_native_uint)(value)) & (~(((acpi_native_uint) boundary)-1)))
+#define ACPI_ROUND_UP(value,boundary)        ((((acpi_native_uint)(value)) + (((acpi_native_uint) boundary)-1)) & (~(((acpi_native_uint) boundary)-1)))
+
+#define ACPI_ROUND_DOWN_TO_32_BITS(a)        ACPI_ROUND_DOWN(a,4)
+#define ACPI_ROUND_DOWN_TO_64_BITS(a)        ACPI_ROUND_DOWN(a,8)
+#define ACPI_ROUND_DOWN_TO_NATIVE_WORD(a)    ACPI_ROUND_DOWN(a,ALIGNED_ADDRESS_BOUNDARY)
+
+#define ACPI_ROUND_UP_to_32_bITS(a)          ACPI_ROUND_UP(a,4)
+#define ACPI_ROUND_UP_to_64_bITS(a)          ACPI_ROUND_UP(a,8)
+#define ACPI_ROUND_UP_TO_NATIVE_WORD(a)      ACPI_ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY)
+
+
+#define ACPI_ROUND_BITS_UP_TO_BYTES(a)       ACPI_DIV_8((a) + 7)
+#define ACPI_ROUND_BITS_DOWN_TO_BYTES(a)     ACPI_DIV_8((a))
+
+#define ACPI_ROUND_UP_TO_1K(a)               (((a) + 1023) >> 10)
+
+/* Generic (non-power-of-two) rounding */
+
+#define ACPI_ROUND_UP_TO(value,boundary)     (((value) + ((boundary)-1)) / (boundary))
+
+/*
+ * Bitmask creation
+ * Bit positions start at zero.
+ * MASK_BITS_ABOVE creates a mask starting AT the position and above
+ * MASK_BITS_BELOW creates a mask starting one bit BELOW the position
+ */
+#define ACPI_MASK_BITS_ABOVE(position)       (~((ACPI_INTEGER_MAX) << ((u32) (position))))
+#define ACPI_MASK_BITS_BELOW(position)       ((ACPI_INTEGER_MAX) << ((u32) (position)))
+
+#define ACPI_IS_OCTAL_DIGIT(d)               (((char)(d) >= '0') && ((char)(d) <= '7'))
+
+/* Macros for GAS addressing */
+
+#if ACPI_MACHINE_WIDTH != 16
+
+#define ACPI_PCI_DEVICE(a)              (u16) ((ACPI_HIDWORD ((a))) & 0x0000FFFF)
+#define ACPI_PCI_FUNCTION(a)            (u16) ((ACPI_LODWORD ((a))) >> 16)
+#define ACPI_PCI_REGISTER(a)            (u16) ((ACPI_LODWORD ((a))) & 0x0000FFFF)
+
+#else
+
+/* No support for GAS and PCI IDs in 16-bit mode  */
+
+#define ACPI_PCI_FUNCTION(a)            (u16) ((a) & 0xFFFF0000)
+#define ACPI_PCI_DEVICE(a)              (u16) ((a) & 0x0000FFFF)
+#define ACPI_PCI_REGISTER(a)            (u16) ((a) & 0x0000FFFF)
+
+#endif
+
+
+/* Bitfields within ACPI registers */
+
+#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask)      ((val << pos) & mask)
+#define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val)  reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask)
+
+/*
+ * An struct acpi_namespace_node * can appear in some contexts,
+ * where a pointer to an union acpi_operand_object    can also
+ * appear.  This macro is used to distinguish them.
+ *
+ * The "Descriptor" field is the first field in both structures.
+ */
+#define ACPI_GET_DESCRIPTOR_TYPE(d)     (((union acpi_descriptor *)(void *)(d))->descriptor_id)
+#define ACPI_SET_DESCRIPTOR_TYPE(d,t)   (((union acpi_descriptor *)(void *)(d))->descriptor_id = t)
+
+
+/* Macro to test the object type */
+
+#define ACPI_GET_OBJECT_TYPE(d)         (((union acpi_operand_object *)(void *)(d))->common.type)
+
+/* Macro to check the table flags for SINGLE or MULTIPLE tables are allowed */
+
+#define ACPI_IS_SINGLE_TABLE(x)         (((x) & 0x01) == ACPI_TABLE_SINGLE ? 1 : 0)
+
+/*
+ * Macros for the master AML opcode table
+ */
+#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
+#define ACPI_OP(name,Pargs,Iargs,obj_type,class,type,flags)    {name,(u32)(Pargs),(u32)(Iargs),(u32)(flags),obj_type,class,type}
+#else
+#define ACPI_OP(name,Pargs,Iargs,obj_type,class,type,flags)    {(u32)(Pargs),(u32)(Iargs),(u32)(flags),obj_type,class,type}
+#endif
+
+#ifdef ACPI_DISASSEMBLER
+#define ACPI_DISASM_ONLY_MEMBERS(a)     a;
+#else
+#define ACPI_DISASM_ONLY_MEMBERS(a)
+#endif
+
+#define ARG_TYPE_WIDTH                  5
+#define ARG_1(x)                        ((u32)(x))
+#define ARG_2(x)                        ((u32)(x) << (1 * ARG_TYPE_WIDTH))
+#define ARG_3(x)                        ((u32)(x) << (2 * ARG_TYPE_WIDTH))
+#define ARG_4(x)                        ((u32)(x) << (3 * ARG_TYPE_WIDTH))
+#define ARG_5(x)                        ((u32)(x) << (4 * ARG_TYPE_WIDTH))
+#define ARG_6(x)                        ((u32)(x) << (5 * ARG_TYPE_WIDTH))
+
+#define ARGI_LIST1(a)                   (ARG_1(a))
+#define ARGI_LIST2(a,b)                 (ARG_1(b)|ARG_2(a))
+#define ARGI_LIST3(a,b,c)               (ARG_1(c)|ARG_2(b)|ARG_3(a))
+#define ARGI_LIST4(a,b,c,d)             (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a))
+#define ARGI_LIST5(a,b,c,d,e)           (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a))
+#define ARGI_LIST6(a,b,c,d,e,f)         (ARG_1(f)|ARG_2(e)|ARG_3(d)|ARG_4(c)|ARG_5(b)|ARG_6(a))
+
+#define ARGP_LIST1(a)                   (ARG_1(a))
+#define ARGP_LIST2(a,b)                 (ARG_1(a)|ARG_2(b))
+#define ARGP_LIST3(a,b,c)               (ARG_1(a)|ARG_2(b)|ARG_3(c))
+#define ARGP_LIST4(a,b,c,d)             (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d))
+#define ARGP_LIST5(a,b,c,d,e)           (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e))
+#define ARGP_LIST6(a,b,c,d,e,f)         (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)|ARG_6(f))
+
+#define GET_CURRENT_ARG_TYPE(list)      (list & ((u32) 0x1F))
+#define INCREMENT_ARG_LIST(list)        (list >>= ((u32) ARG_TYPE_WIDTH))
+
+
+/*
+ * Reporting macros that are never compiled out
+ */
+
+#define ACPI_PARAM_LIST(pl)                 pl
+
+/*
+ * Error reporting.  These versions add callers module and line#.  Since
+ * _THIS_MODULE gets compiled out when ACPI_DEBUG_OUTPUT isn't defined, only
+ * use it in debug mode.
+ */
+
+#ifdef ACPI_DEBUG_OUTPUT
+
+#define ACPI_REPORT_INFO(fp)                {acpi_ut_report_info(_THIS_MODULE,__LINE__,_COMPONENT); \
+												acpi_os_printf ACPI_PARAM_LIST(fp);}
+#define ACPI_REPORT_ERROR(fp)               {acpi_ut_report_error(_THIS_MODULE,__LINE__,_COMPONENT); \
+												acpi_os_printf ACPI_PARAM_LIST(fp);}
+#define ACPI_REPORT_WARNING(fp)             {acpi_ut_report_warning(_THIS_MODULE,__LINE__,_COMPONENT); \
+												acpi_os_printf ACPI_PARAM_LIST(fp);}
+#define ACPI_REPORT_NSERROR(s,e)            acpi_ns_report_error(_THIS_MODULE,__LINE__,_COMPONENT, s, e);
+
+#define ACPI_REPORT_METHOD_ERROR(s,n,p,e)   acpi_ns_report_method_error(_THIS_MODULE,__LINE__,_COMPONENT, s, n, p, e);
+
+#else
+
+#define ACPI_REPORT_INFO(fp)                {acpi_ut_report_info("ACPI",__LINE__,_COMPONENT); \
+												acpi_os_printf ACPI_PARAM_LIST(fp);}
+#define ACPI_REPORT_ERROR(fp)               {acpi_ut_report_error("ACPI",__LINE__,_COMPONENT); \
+												acpi_os_printf ACPI_PARAM_LIST(fp);}
+#define ACPI_REPORT_WARNING(fp)             {acpi_ut_report_warning("ACPI",__LINE__,_COMPONENT); \
+												acpi_os_printf ACPI_PARAM_LIST(fp);}
+#define ACPI_REPORT_NSERROR(s,e)            acpi_ns_report_error("ACPI",__LINE__,_COMPONENT, s, e);
+
+#define ACPI_REPORT_METHOD_ERROR(s,n,p,e)   acpi_ns_report_method_error("ACPI",__LINE__,_COMPONENT, s, n, p, e);
+
+#endif
+
+/* Error reporting.  These versions pass thru the module and line# */
+
+#define _ACPI_REPORT_INFO(a,b,c,fp)         {acpi_ut_report_info(a,b,c); \
+												acpi_os_printf ACPI_PARAM_LIST(fp);}
+#define _ACPI_REPORT_ERROR(a,b,c,fp)        {acpi_ut_report_error(a,b,c); \
+												acpi_os_printf ACPI_PARAM_LIST(fp);}
+#define _ACPI_REPORT_WARNING(a,b,c,fp)      {acpi_ut_report_warning(a,b,c); \
+												acpi_os_printf ACPI_PARAM_LIST(fp);}
+
+/*
+ * Debug macros that are conditionally compiled
+ */
+
+#ifdef ACPI_DEBUG_OUTPUT
+
+#define ACPI_MODULE_NAME(name)               static char ACPI_UNUSED_VAR *_THIS_MODULE = name;
+
+/*
+ * Function entry tracing.
+ * The first parameter should be the procedure name as a quoted string.  This is declared
+ * as a local string ("_proc_name) so that it can be also used by the function exit macros below.
+ */
+
+#define ACPI_FUNCTION_NAME(a)               struct acpi_debug_print_info _dbg; \
+												_dbg.component_id = _COMPONENT; \
+												_dbg.proc_name   = a; \
+												_dbg.module_name = _THIS_MODULE;
+
+#define ACPI_FUNCTION_TRACE(a)              ACPI_FUNCTION_NAME(a) \
+												acpi_ut_trace(__LINE__,&_dbg)
+#define ACPI_FUNCTION_TRACE_PTR(a,b)        ACPI_FUNCTION_NAME(a) \
+												acpi_ut_trace_ptr(__LINE__,&_dbg,(void *)b)
+#define ACPI_FUNCTION_TRACE_U32(a,b)        ACPI_FUNCTION_NAME(a) \
+												acpi_ut_trace_u32(__LINE__,&_dbg,(u32)b)
+#define ACPI_FUNCTION_TRACE_STR(a,b)        ACPI_FUNCTION_NAME(a) \
+												acpi_ut_trace_str(__LINE__,&_dbg,(char *)b)
+
+#define ACPI_FUNCTION_ENTRY()               acpi_ut_track_stack_ptr()
+
+/*
+ * Function exit tracing.
+ * WARNING: These macros include a return statement.  This is usually considered
+ * bad form, but having a separate exit macro is very ugly and difficult to maintain.
+ * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros
+ * so that "_proc_name" is defined.
+ */
+#ifdef ACPI_USE_DO_WHILE_0
+#define ACPI_DO_WHILE0(a)               do a while(0)
+#else
+#define ACPI_DO_WHILE0(a)               a
+#endif
+
+#define return_VOID                     ACPI_DO_WHILE0 ({acpi_ut_exit(__LINE__,&_dbg);return;})
+#define return_ACPI_STATUS(s)           ACPI_DO_WHILE0 ({acpi_ut_status_exit(__LINE__,&_dbg,(s));return((s));})
+#define return_VALUE(s)                 ACPI_DO_WHILE0 ({acpi_ut_value_exit(__LINE__,&_dbg,(acpi_integer)(s));return((s));})
+#define return_PTR(s)                   ACPI_DO_WHILE0 ({acpi_ut_ptr_exit(__LINE__,&_dbg,(u8 *)(s));return((s));})
+
+/* Conditional execution */
+
+#define ACPI_DEBUG_EXEC(a)              a
+#define ACPI_NORMAL_EXEC(a)
+
+#define ACPI_DEBUG_DEFINE(a)            a;
+#define ACPI_DEBUG_ONLY_MEMBERS(a)      a;
+#define _VERBOSE_STRUCTURES
+
+
+/* Stack and buffer dumping */
+
+#define ACPI_DUMP_STACK_ENTRY(a)        acpi_ex_dump_operand(a)
+#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)
+#define ACPI_DUMP_TABLES(a,b)           acpi_ns_dump_tables(a,b)
+#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)
+#define ACPI_BREAK_MSG(a)               acpi_os_signal (ACPI_SIGNAL_BREAKPOINT,(a))
+
+
+/*
+ * Generate INT3 on ACPI_ERROR (Debug only!)
+ */
+
+#define ACPI_ERROR_BREAK
+#ifdef  ACPI_ERROR_BREAK
+#define ACPI_BREAK_ON_ERROR(lvl)        if ((lvl)&ACPI_ERROR) \
+											acpi_os_signal(ACPI_SIGNAL_BREAKPOINT,"Fatal error encountered\n")
+#else
+#define ACPI_BREAK_ON_ERROR(lvl)
+#endif
+
+/*
+ * Master debug print macros
+ * Print iff:
+ *    1) Debug print for the current component is enabled
+ *    2) Debug error level or trace level for the print statement is enabled
+ */
+
+#define ACPI_DEBUG_PRINT(pl)            acpi_ut_debug_print ACPI_PARAM_LIST(pl)
+#define ACPI_DEBUG_PRINT_RAW(pl)        acpi_ut_debug_print_raw ACPI_PARAM_LIST(pl)
+
+
+#else
+/*
+ * This is the non-debug case -- make everything go away,
+ * leaving no executable debug code!
+ */
+
+#define ACPI_MODULE_NAME(name)
+#define _THIS_MODULE ""
+
+#define ACPI_DEBUG_EXEC(a)
+#define ACPI_NORMAL_EXEC(a)             a;
+
+#define ACPI_DEBUG_DEFINE(a)
+#define ACPI_DEBUG_ONLY_MEMBERS(a)
+#define ACPI_FUNCTION_NAME(a)
+#define ACPI_FUNCTION_TRACE(a)
+#define ACPI_FUNCTION_TRACE_PTR(a,b)
+#define ACPI_FUNCTION_TRACE_U32(a,b)
+#define ACPI_FUNCTION_TRACE_STR(a,b)
+#define ACPI_FUNCTION_EXIT
+#define ACPI_FUNCTION_STATUS_EXIT(s)
+#define ACPI_FUNCTION_VALUE_EXIT(s)
+#define ACPI_FUNCTION_ENTRY()
+#define ACPI_DUMP_STACK_ENTRY(a)
+#define ACPI_DUMP_OPERANDS(a,b,c,d,e)
+#define ACPI_DUMP_ENTRY(a,b)
+#define ACPI_DUMP_TABLES(a,b)
+#define ACPI_DUMP_PATHNAME(a,b,c,d)
+#define ACPI_DUMP_RESOURCE_LIST(a)
+#define ACPI_DUMP_BUFFER(a,b)
+#define ACPI_DEBUG_PRINT(pl)
+#define ACPI_DEBUG_PRINT_RAW(pl)
+#define ACPI_BREAK_MSG(a)
+
+#define return_VOID                     return
+#define return_ACPI_STATUS(s)           return(s)
+#define return_VALUE(s)                 return(s)
+#define return_PTR(s)                   return(s)
+
+#endif
+
+/*
+ * Some code only gets executed when the debugger is built in.
+ * Note that this is entirely independent of whether the
+ * DEBUG_PRINT stuff (set by ACPI_DEBUG_OUTPUT) is on, or not.
+ */
+#ifdef ACPI_DEBUGGER
+#define ACPI_DEBUGGER_EXEC(a)           a
+#else
+#define ACPI_DEBUGGER_EXEC(a)
+#endif
+
+
+/*
+ * For 16-bit code, we want to shrink some things even though
+ * we are using ACPI_DEBUG_OUTPUT to get the debug output
+ */
+#if ACPI_MACHINE_WIDTH == 16
+#undef ACPI_DEBUG_ONLY_MEMBERS
+#undef _VERBOSE_STRUCTURES
+#define ACPI_DEBUG_ONLY_MEMBERS(a)
+#endif
+
+
+#ifdef ACPI_DEBUG_OUTPUT
+/*
+ * 1) Set name to blanks
+ * 2) Copy the object name
+ */
+#define ACPI_ADD_OBJECT_NAME(a,b)       ACPI_MEMSET (a->common.name, ' ', sizeof (a->common.name));\
+										ACPI_STRNCPY (a->common.name, acpi_gbl_ns_type_names[b], sizeof (a->common.name))
+#else
+
+#define ACPI_ADD_OBJECT_NAME(a,b)
+#endif
+
+
+/*
+ * Memory allocation tracking (DEBUG ONLY)
+ */
+
+#ifndef ACPI_DBG_TRACK_ALLOCATIONS
+
+/* Memory allocation */
+
+#define ACPI_MEM_ALLOCATE(a)            acpi_ut_allocate((acpi_size)(a),_COMPONENT,_THIS_MODULE,__LINE__)
+#define ACPI_MEM_CALLOCATE(a)           acpi_ut_callocate((acpi_size)(a), _COMPONENT,_THIS_MODULE,__LINE__)
+#define ACPI_MEM_FREE(a)                acpi_os_free(a)
+#define ACPI_MEM_TRACKING(a)
+
+
+#else
+
+/* Memory allocation */
+
+#define ACPI_MEM_ALLOCATE(a)            acpi_ut_allocate_and_track((acpi_size)(a),_COMPONENT,_THIS_MODULE,__LINE__)
+#define ACPI_MEM_CALLOCATE(a)           acpi_ut_callocate_and_track((acpi_size)(a), _COMPONENT,_THIS_MODULE,__LINE__)
+#define ACPI_MEM_FREE(a)                acpi_ut_free_and_track(a,_COMPONENT,_THIS_MODULE,__LINE__)
+#define ACPI_MEM_TRACKING(a)            a
+
+#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
+
+
+#define ACPI_GET_STACK_POINTER          _asm {mov eax, ebx}
+
+#endif /* ACMACROS_H */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acnamesp.h linux-2.4.22-pre2/include/acpi/acnamesp.h
--- linux-2.4.21/include/acpi/acnamesp.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acnamesp.h	2003-06-26 21:43:12.000000000 +0000
@@ -0,0 +1,513 @@
+/******************************************************************************
+ *
+ * Name: acnamesp.h - Namespace subcomponent prototypes and defines
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACNAMESP_H__
+#define __ACNAMESP_H__
+
+
+/* To search the entire name space, pass this as search_base */
+
+#define ACPI_NS_ALL                 ((acpi_handle)0)
+
+/*
+ * Elements of acpi_ns_properties are bit significant
+ * and should be one-to-one with values of acpi_object_type
+ */
+#define ACPI_NS_NORMAL              0
+#define ACPI_NS_NEWSCOPE            1   /* a definition of this type opens a name scope */
+#define ACPI_NS_LOCAL               2   /* suppress search of enclosing scopes */
+
+
+/* Definitions of the predefined namespace names  */
+
+#define ACPI_UNKNOWN_NAME           (u32) 0x3F3F3F3F     /* Unknown name is  "????" */
+#define ACPI_ROOT_NAME              (u32) 0x5F5F5F5C     /* Root name is     "\___" */
+#define ACPI_SYS_BUS_NAME           (u32) 0x5F53425F     /* Sys bus name is  "_SB_" */
+
+#define ACPI_NS_ROOT_PATH           "\\"
+#define ACPI_NS_SYSTEM_BUS          "_SB_"
+
+
+/* Flags for acpi_ns_lookup, acpi_ns_search_and_enter */
+
+#define ACPI_NS_NO_UPSEARCH         0
+#define ACPI_NS_SEARCH_PARENT       0x01
+#define ACPI_NS_DONT_OPEN_SCOPE     0x02
+#define ACPI_NS_NO_PEER_SEARCH      0x04
+#define ACPI_NS_ERROR_IF_FOUND      0x08
+
+#define ACPI_NS_WALK_UNLOCK         TRUE
+#define ACPI_NS_WALK_NO_UNLOCK      FALSE
+
+
+acpi_status
+acpi_ns_load_namespace (
+	void);
+
+acpi_status
+acpi_ns_initialize_objects (
+	void);
+
+acpi_status
+acpi_ns_initialize_devices (
+	void);
+
+
+/* Namespace init - nsxfinit */
+
+acpi_status
+acpi_ns_init_one_device (
+	acpi_handle                     obj_handle,
+	u32                             nesting_level,
+	void                            *context,
+	void                            **return_value);
+
+acpi_status
+acpi_ns_init_one_object (
+	acpi_handle                     obj_handle,
+	u32                             level,
+	void                            *context,
+	void                            **return_value);
+
+
+acpi_status
+acpi_ns_walk_namespace (
+	acpi_object_type                type,
+	acpi_handle                     start_object,
+	u32                             max_depth,
+	u8                              unlock_before_callback,
+	acpi_walk_callback              user_function,
+	void                            *context,
+	void                            **return_value);
+
+struct acpi_namespace_node *
+acpi_ns_get_next_node (
+	acpi_object_type                type,
+	struct acpi_namespace_node      *parent,
+	struct acpi_namespace_node      *child);
+
+void
+acpi_ns_delete_namespace_by_owner (
+	u16                             table_id);
+
+
+/* Namespace loading - nsload */
+
+acpi_status
+acpi_ns_one_complete_parse (
+	u32                             pass_number,
+	struct acpi_table_desc          *table_desc);
+
+acpi_status
+acpi_ns_parse_table (
+	struct acpi_table_desc          *table_desc,
+	struct acpi_namespace_node      *scope);
+
+acpi_status
+acpi_ns_load_table (
+	struct acpi_table_desc          *table_desc,
+	struct acpi_namespace_node      *node);
+
+acpi_status
+acpi_ns_load_table_by_type (
+	acpi_table_type                 table_type);
+
+
+/*
+ * Top-level namespace access - nsaccess
+ */
+
+acpi_status
+acpi_ns_root_initialize (
+	void);
+
+acpi_status
+acpi_ns_lookup (
+	union acpi_generic_state        *scope_info,
+	char                            *name,
+	acpi_object_type                type,
+	acpi_interpreter_mode           interpreter_mode,
+	u32                             flags,
+	struct acpi_walk_state          *walk_state,
+	struct acpi_namespace_node      **ret_node);
+
+
+/*
+ * Named object allocation/deallocation - nsalloc
+ */
+
+struct acpi_namespace_node *
+acpi_ns_create_node (
+	u32                             name);
+
+void
+acpi_ns_delete_node (
+	struct acpi_namespace_node      *node);
+
+void
+acpi_ns_delete_namespace_subtree (
+	struct acpi_namespace_node      *parent_handle);
+
+void
+acpi_ns_detach_object (
+	struct acpi_namespace_node      *node);
+
+void
+acpi_ns_delete_children (
+	struct acpi_namespace_node      *parent);
+
+int
+acpi_ns_compare_names (
+	char                            *name1,
+	char                            *name2);
+
+void
+acpi_ns_remove_reference (
+	struct acpi_namespace_node      *node);
+
+
+/*
+ * Namespace modification - nsmodify
+ */
+
+acpi_status
+acpi_ns_unload_namespace (
+	acpi_handle                     handle);
+
+acpi_status
+acpi_ns_delete_subtree (
+	acpi_handle                     start_handle);
+
+
+/*
+ * Namespace dump/print utilities - nsdump
+ */
+
+void
+acpi_ns_dump_tables (
+	acpi_handle                     search_base,
+	u32                             max_depth);
+
+void
+acpi_ns_dump_entry (
+	acpi_handle                     handle,
+	u32                             debug_level);
+
+void
+acpi_ns_dump_pathname (
+	acpi_handle                     handle,
+	char                            *msg,
+	u32                             level,
+	u32                             component);
+
+void
+acpi_ns_print_pathname (
+	u32                             num_segments,
+	char                            *pathname);
+
+acpi_status
+acpi_ns_dump_one_device (
+	acpi_handle                     obj_handle,
+	u32                             level,
+	void                            *context,
+	void                            **return_value);
+
+void
+acpi_ns_dump_root_devices (
+	void);
+
+acpi_status
+acpi_ns_dump_one_object (
+	acpi_handle                     obj_handle,
+	u32                             level,
+	void                            *context,
+	void                            **return_value);
+
+void
+acpi_ns_dump_objects (
+	acpi_object_type                type,
+	u8                              display_type,
+	u32                             max_depth,
+	u32                             ownder_id,
+	acpi_handle                     start_handle);
+
+
+/*
+ * Namespace evaluation functions - nseval
+ */
+
+acpi_status
+acpi_ns_evaluate_by_handle (
+	struct acpi_namespace_node      *prefix_node,
+	union acpi_operand_object       **params,
+	union acpi_operand_object       **return_object);
+
+acpi_status
+acpi_ns_evaluate_by_name (
+	char                            *pathname,
+	union acpi_operand_object       **params,
+	union acpi_operand_object       **return_object);
+
+acpi_status
+acpi_ns_evaluate_relative (
+	struct acpi_namespace_node      *prefix_node,
+	char                            *pathname,
+	union acpi_operand_object       **params,
+	union acpi_operand_object       **return_object);
+
+acpi_status
+acpi_ns_execute_control_method (
+	struct acpi_namespace_node      *method_node,
+	union acpi_operand_object       **params,
+	union acpi_operand_object       **return_obj_desc);
+
+acpi_status
+acpi_ns_get_object_value (
+	struct acpi_namespace_node      *object_node,
+	union acpi_operand_object       **return_obj_desc);
+
+
+/*
+ * Parent/Child/Peer utility functions
+ */
+
+acpi_name
+acpi_ns_find_parent_name (
+	struct acpi_namespace_node      *node_to_search);
+
+
+/*
+ * Name and Scope manipulation - nsnames
+ */
+
+u32
+acpi_ns_opens_scope (
+	acpi_object_type                type);
+
+void
+acpi_ns_build_external_path (
+	struct acpi_namespace_node      *node,
+	acpi_size                       size,
+	char                            *name_buffer);
+
+char *
+acpi_ns_get_external_pathname (
+	struct acpi_namespace_node      *node);
+
+char *
+acpi_ns_name_of_current_scope (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ns_handle_to_pathname (
+	acpi_handle                     target_handle,
+	struct acpi_buffer              *buffer);
+
+u8
+acpi_ns_pattern_match (
+	struct acpi_namespace_node      *obj_node,
+	char                            *search_for);
+
+acpi_status
+acpi_ns_get_node_by_path (
+	char                            *external_pathname,
+	struct acpi_namespace_node      *in_prefix_node,
+	u32                             flags,
+	struct acpi_namespace_node      **out_node);
+
+acpi_size
+acpi_ns_get_pathname_length (
+	struct acpi_namespace_node      *node);
+
+
+/*
+ * Object management for namespace nodes - nsobject
+ */
+
+acpi_status
+acpi_ns_attach_object (
+	struct acpi_namespace_node      *node,
+	union acpi_operand_object       *object,
+	acpi_object_type                type);
+
+union acpi_operand_object *
+acpi_ns_get_attached_object (
+	struct acpi_namespace_node      *node);
+
+union acpi_operand_object *
+acpi_ns_get_secondary_object (
+	union acpi_operand_object       *obj_desc);
+
+acpi_status
+acpi_ns_attach_data (
+	struct acpi_namespace_node      *node,
+	acpi_object_handler             handler,
+	void                            *data);
+
+acpi_status
+acpi_ns_detach_data (
+	struct acpi_namespace_node      *node,
+	acpi_object_handler             handler);
+
+acpi_status
+acpi_ns_get_attached_data (
+	struct acpi_namespace_node      *node,
+	acpi_object_handler             handler,
+	void                            **data);
+
+
+/*
+ * Namespace searching and entry - nssearch
+ */
+
+acpi_status
+acpi_ns_search_and_enter (
+	u32                             entry_name,
+	struct acpi_walk_state          *walk_state,
+	struct acpi_namespace_node      *node,
+	acpi_interpreter_mode           interpreter_mode,
+	acpi_object_type                type,
+	u32                             flags,
+	struct acpi_namespace_node      **ret_node);
+
+acpi_status
+acpi_ns_search_node (
+	u32                             entry_name,
+	struct acpi_namespace_node      *node,
+	acpi_object_type                type,
+	struct acpi_namespace_node      **ret_node);
+
+void
+acpi_ns_install_node (
+	struct acpi_walk_state          *walk_state,
+	struct acpi_namespace_node      *parent_node,
+	struct acpi_namespace_node      *node,
+	acpi_object_type                type);
+
+
+/*
+ * Utility functions - nsutils
+ */
+
+u8
+acpi_ns_valid_root_prefix (
+	char                            prefix);
+
+u8
+acpi_ns_valid_path_separator (
+	char                            sep);
+
+acpi_object_type
+acpi_ns_get_type (
+	struct acpi_namespace_node      *node);
+
+u32
+acpi_ns_local (
+	acpi_object_type                type);
+
+void
+acpi_ns_report_error (
+	char                            *module_name,
+	u32                             line_number,
+	u32                             component_id,
+	char                            *internal_name,
+	acpi_status                     lookup_status);
+
+void
+acpi_ns_report_method_error (
+	char                            *module_name,
+	u32                             line_number,
+	u32                             component_id,
+	char                            *message,
+	struct acpi_namespace_node      *node,
+	char                            *path,
+	acpi_status                     lookup_status);
+
+void
+acpi_ns_print_node_pathname (
+	struct acpi_namespace_node      *node,
+	char                            *msg);
+
+acpi_status
+acpi_ns_build_internal_name (
+	struct acpi_namestring_info     *info);
+
+void
+acpi_ns_get_internal_name_length (
+	struct acpi_namestring_info     *info);
+
+acpi_status
+acpi_ns_internalize_name (
+	char                            *dotted_name,
+	char                            **converted_name);
+
+acpi_status
+acpi_ns_externalize_name (
+	u32                             internal_name_length,
+	char                            *internal_name,
+	u32                             *converted_name_length,
+	char                            **converted_name);
+
+struct acpi_namespace_node *
+acpi_ns_map_handle_to_node (
+	acpi_handle                     handle);
+
+acpi_handle
+acpi_ns_convert_entry_to_handle(
+	struct acpi_namespace_node      *node);
+
+void
+acpi_ns_terminate (
+	void);
+
+struct acpi_namespace_node *
+acpi_ns_get_parent_node (
+	struct acpi_namespace_node      *node);
+
+
+struct acpi_namespace_node *
+acpi_ns_get_next_valid_node (
+	struct acpi_namespace_node      *node);
+
+
+#endif /* __ACNAMESP_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acobject.h linux-2.4.22-pre2/include/acpi/acobject.h
--- linux-2.4.21/include/acpi/acobject.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acobject.h	2003-06-26 21:43:12.000000000 +0000
@@ -0,0 +1,493 @@
+
+/******************************************************************************
+ *
+ * Name: acobject.h - Definition of union acpi_operand_object    (Internal object only)
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef _ACOBJECT_H
+#define _ACOBJECT_H
+
+
+/*
+ * The union acpi_operand_object    is used to pass AML operands from the dispatcher
+ * to the interpreter, and to keep track of the various handlers such as
+ * address space handlers and notify handlers.  The object is a constant
+ * size in order to allow it to be cached and reused.
+ */
+
+/*******************************************************************************
+ *
+ * Common Descriptors
+ *
+ ******************************************************************************/
+
+/*
+ * Common area for all objects.
+ *
+ * data_type is used to differentiate between internal descriptors, and MUST
+ * be the first byte in this structure.
+ */
+#define ACPI_OBJECT_COMMON_HEADER   /* SIZE/ALIGNMENT: 32 bits, one ptr plus trailing 8-bit flag */\
+	u8                                      descriptor;         /* To differentiate various internal objs */\
+	u8                                      type;               /* acpi_object_type */\
+	u16                                     reference_count;    /* For object deletion management */\
+	union acpi_operand_object               *next_object;       /* Objects linked to parent NS node */\
+	u8                                      flags; \
+
+/* Values for flag byte above */
+
+#define AOPOBJ_AML_CONSTANT         0x01
+#define AOPOBJ_STATIC_POINTER       0x02
+#define AOPOBJ_DATA_VALID           0x04
+#define AOPOBJ_OBJECT_INITIALIZED   0x08
+#define AOPOBJ_SETUP_COMPLETE       0x10
+#define AOPOBJ_SINGLE_DATUM         0x20
+
+
+/*
+ * Common bitfield for the field objects
+ * "Field Datum"  -- a datum from the actual field object
+ * "Buffer Datum" -- a datum from a user buffer, read from or to be written to the field
+ */
+#define ACPI_COMMON_FIELD_INFO      /* SIZE/ALIGNMENT: 24 bits + three 32-bit values */\
+	u8                                      field_flags;        /* Access, update, and lock bits */\
+	u8                                      attribute;          /* From access_as keyword */\
+	u8                                      access_byte_width;  /* Read/Write size in bytes */\
+	u32                                     bit_length;         /* Length of field in bits */\
+	u32                                     base_byte_offset;   /* Byte offset within containing object */\
+	u8                                      start_field_bit_offset;/* Bit offset within first field datum (0-63) */\
+	u8                                      datum_valid_bits;   /* Valid bit in first "Field datum" */\
+	u8                                      end_field_valid_bits; /* Valid bits in the last "field datum" */\
+	u8                                      end_buffer_valid_bits; /* Valid bits in the last "buffer datum" */\
+	u32                                     value;              /* Value to store into the Bank or Index register */\
+	struct acpi_namespace_node              *node;              /* Link back to parent node */
+
+
+/*
+ * Fields common to both Strings and Buffers
+ */
+#define ACPI_COMMON_BUFFER_INFO \
+	u32                                     length;
+
+
+/*
+ * Common fields for objects that support ASL notifications
+ */
+#define ACPI_COMMON_NOTIFY_INFO \
+	union acpi_operand_object               *system_notify;     /* Handler for system notifies */\
+	union acpi_operand_object               *device_notify;     /* Handler for driver notifies */\
+	union acpi_operand_object               *address_space;     /* Handler for Address space */
+
+
+/******************************************************************************
+ *
+ * Basic data types
+ *
+ *****************************************************************************/
+
+struct acpi_object_common
+{
+	ACPI_OBJECT_COMMON_HEADER
+};
+
+
+struct acpi_object_integer
+{
+	ACPI_OBJECT_COMMON_HEADER
+	acpi_integer                            value;
+};
+
+
+struct acpi_object_string           /* Null terminated, ASCII characters only */
+{
+	ACPI_OBJECT_COMMON_HEADER
+	ACPI_COMMON_BUFFER_INFO
+	char                                    *pointer;           /* String in AML stream or allocated string */
+};
+
+
+struct acpi_object_buffer
+{
+	ACPI_OBJECT_COMMON_HEADER
+	ACPI_COMMON_BUFFER_INFO
+	u8                                      *pointer;           /* Buffer in AML stream or allocated buffer */
+	struct acpi_namespace_node              *node;              /* Link back to parent node */
+	u8                                      *aml_start;
+	u32                                     aml_length;
+};
+
+
+struct acpi_object_package
+{
+	ACPI_OBJECT_COMMON_HEADER
+
+	u32                                     count;              /* # of elements in package */
+	u32                                     aml_length;
+	u8                                      *aml_start;
+	struct acpi_namespace_node              *node;              /* Link back to parent node */
+	union acpi_operand_object               **elements;         /* Array of pointers to acpi_objects */
+};
+
+
+/******************************************************************************
+ *
+ * Complex data types
+ *
+ *****************************************************************************/
+
+struct acpi_object_event
+{
+	ACPI_OBJECT_COMMON_HEADER
+	void                                    *semaphore;
+};
+
+
+#define INFINITE_CONCURRENCY        0xFF
+
+struct acpi_object_method
+{
+	ACPI_OBJECT_COMMON_HEADER
+	u8                                      method_flags;
+	u8                                      param_count;
+	u32                                     aml_length;
+	void                                    *semaphore;
+	u8                                      *aml_start;
+	u8                                      concurrency;
+	u8                                      thread_count;
+	acpi_owner_id                           owning_id;
+};
+
+
+struct acpi_object_mutex
+{
+	ACPI_OBJECT_COMMON_HEADER
+	u16                                     sync_level;
+	u16                                     acquisition_depth;
+	struct acpi_thread_state                *owner_thread;
+	void                                    *semaphore;
+	union acpi_operand_object               *prev;              /* Link for list of acquired mutexes */
+	union acpi_operand_object               *next;              /* Link for list of acquired mutexes */
+	struct acpi_namespace_node              *node;              /* containing object */
+};
+
+
+struct acpi_object_region
+{
+	ACPI_OBJECT_COMMON_HEADER
+
+	u8                                      space_id;
+	union acpi_operand_object               *address_space;     /* Handler for region access */
+	struct acpi_namespace_node              *node;              /* containing object */
+	union acpi_operand_object               *next;
+	u32                                     length;
+	acpi_physical_address                   address;
+};
+
+
+/******************************************************************************
+ *
+ * Objects that can be notified.  All share a common notify_info area.
+ *
+ *****************************************************************************/
+
+struct acpi_object_notify_common            /* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */
+{
+	ACPI_OBJECT_COMMON_HEADER
+	ACPI_COMMON_NOTIFY_INFO
+};
+
+
+struct acpi_object_device
+{
+	ACPI_OBJECT_COMMON_HEADER
+	ACPI_COMMON_NOTIFY_INFO
+	struct acpi_gpe_block_info              *gpe_block;
+};
+
+
+struct acpi_object_power_resource
+{
+	ACPI_OBJECT_COMMON_HEADER
+	ACPI_COMMON_NOTIFY_INFO
+	u32                                     system_level;
+	u32                                     resource_order;
+};
+
+
+struct acpi_object_processor
+{
+	ACPI_OBJECT_COMMON_HEADER
+	ACPI_COMMON_NOTIFY_INFO
+	u32                                     proc_id;
+	u32                                     length;
+	acpi_io_address                         address;
+};
+
+
+struct acpi_object_thermal_zone
+{
+	ACPI_OBJECT_COMMON_HEADER
+	ACPI_COMMON_NOTIFY_INFO
+};
+
+
+/******************************************************************************
+ *
+ * Fields.  All share a common header/info field.
+ *
+ *****************************************************************************/
+
+struct acpi_object_field_common                         /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */
+{
+	ACPI_OBJECT_COMMON_HEADER
+	ACPI_COMMON_FIELD_INFO
+	union acpi_operand_object               *region_obj;        /* Containing Operation Region object */
+			  /* (REGION/BANK fields only) */
+};
+
+
+struct acpi_object_region_field
+{
+	ACPI_OBJECT_COMMON_HEADER
+	ACPI_COMMON_FIELD_INFO
+	union acpi_operand_object               *region_obj;        /* Containing op_region object */
+};
+
+
+struct acpi_object_bank_field
+{
+	ACPI_OBJECT_COMMON_HEADER
+	ACPI_COMMON_FIELD_INFO
+	union acpi_operand_object               *region_obj;        /* Containing op_region object */
+	union acpi_operand_object               *bank_obj;          /* bank_select Register object */
+};
+
+
+struct acpi_object_index_field
+{
+	ACPI_OBJECT_COMMON_HEADER
+	ACPI_COMMON_FIELD_INFO
+
+	/*
+	 * No "region_obj" pointer needed since the Index and Data registers
+	 * are each field definitions unto themselves.
+	 */
+	union acpi_operand_object               *index_obj;         /* Index register */
+	union acpi_operand_object               *data_obj;          /* Data register */
+};
+
+
+/* The buffer_field is different in that it is part of a Buffer, not an op_region */
+
+struct acpi_object_buffer_field
+{
+	ACPI_OBJECT_COMMON_HEADER
+	ACPI_COMMON_FIELD_INFO
+	union acpi_operand_object               *buffer_obj;        /* Containing Buffer object */
+};
+
+
+/******************************************************************************
+ *
+ * Objects for handlers
+ *
+ *****************************************************************************/
+
+struct acpi_object_notify_handler
+{
+	ACPI_OBJECT_COMMON_HEADER
+	struct acpi_namespace_node              *node;              /* Parent device */
+	acpi_notify_handler                     handler;
+	void                                    *context;
+};
+
+
+/* Flags for address handler */
+
+#define ACPI_ADDR_HANDLER_DEFAULT_INSTALLED  0x1
+
+
+struct acpi_object_addr_handler
+{
+	ACPI_OBJECT_COMMON_HEADER
+	u8                                      space_id;
+	u16                                     hflags;
+	acpi_adr_space_handler                  handler;
+	struct acpi_namespace_node              *node;              /* Parent device */
+	void                                    *context;
+	acpi_adr_space_setup                    setup;
+	union acpi_operand_object               *region_list;       /* regions using this handler */
+	union acpi_operand_object               *next;
+};
+
+
+/******************************************************************************
+ *
+ * Special internal objects
+ *
+ *****************************************************************************/
+
+/*
+ * The Reference object type is used for these opcodes:
+ * Arg[0-6], Local[0-7], index_op, name_op, zero_op, one_op, ones_op, debug_op
+ */
+struct acpi_object_reference
+{
+	ACPI_OBJECT_COMMON_HEADER
+	u8                                      target_type;        /* Used for index_op */
+	u16                                     opcode;
+	u32                                     offset;             /* Used for arg_op, local_op, and index_op */
+	void                                    *object;            /* name_op=>HANDLE to obj, index_op=>union acpi_operand_object  */
+	struct acpi_namespace_node              *node;
+	union acpi_operand_object               **where;
+};
+
+
+/*
+ * Extra object is used as additional storage for types that
+ * have AML code in their declarations (term_args) that must be
+ * evaluated at run time.
+ *
+ * Currently: Region and field_unit types
+ */
+struct acpi_object_extra
+{
+	ACPI_OBJECT_COMMON_HEADER
+	u8                                      byte_fill1;
+	u16                                     word_fill1;
+	u32                                     aml_length;
+	u8                                      *aml_start;
+	struct acpi_namespace_node              *method_REG;        /* _REG method for this region (if any) */
+	void                                    *region_context;    /* Region-specific data */
+};
+
+
+/* Additional data that can be attached to namespace nodes */
+
+struct acpi_object_data
+{
+	ACPI_OBJECT_COMMON_HEADER
+	acpi_object_handler                     handler;
+	void                                    *pointer;
+};
+
+
+/* Structure used when objects are cached for reuse */
+
+struct acpi_object_cache_list
+{
+	ACPI_OBJECT_COMMON_HEADER
+	union acpi_operand_object               *next;              /* Link for object cache and internal lists*/
+};
+
+
+/******************************************************************************
+ *
+ * union acpi_operand_object Descriptor - a giant union of all of the above
+ *
+ *****************************************************************************/
+
+union acpi_operand_object
+{
+	struct acpi_object_common               common;
+	struct acpi_object_integer              integer;
+	struct acpi_object_string               string;
+	struct acpi_object_buffer               buffer;
+	struct acpi_object_package              package;
+	struct acpi_object_event                event;
+	struct acpi_object_method               method;
+	struct acpi_object_mutex                mutex;
+	struct acpi_object_region               region;
+	struct acpi_object_notify_common        common_notify;
+	struct acpi_object_device               device;
+	struct acpi_object_power_resource       power_resource;
+	struct acpi_object_processor            processor;
+	struct acpi_object_thermal_zone         thermal_zone;
+	struct acpi_object_field_common         common_field;
+	struct acpi_object_region_field         field;
+	struct acpi_object_buffer_field         buffer_field;
+	struct acpi_object_bank_field           bank_field;
+	struct acpi_object_index_field          index_field;
+	struct acpi_object_notify_handler       notify;
+	struct acpi_object_addr_handler         address_space;
+	struct acpi_object_reference            reference;
+	struct acpi_object_extra                extra;
+	struct acpi_object_data                 data;
+	struct acpi_object_cache_list           cache;
+};
+
+
+/******************************************************************************
+ *
+ * union acpi_descriptor - objects that share a common descriptor identifier
+ *
+ *****************************************************************************/
+
+
+/* Object descriptor types */
+
+#define ACPI_DESC_TYPE_CACHED           0x11        /* Used only when object is cached */
+#define ACPI_DESC_TYPE_STATE            0x20
+#define ACPI_DESC_TYPE_STATE_UPDATE     0x21
+#define ACPI_DESC_TYPE_STATE_PACKAGE    0x22
+#define ACPI_DESC_TYPE_STATE_CONTROL    0x23
+#define ACPI_DESC_TYPE_STATE_RPSCOPE    0x24
+#define ACPI_DESC_TYPE_STATE_PSCOPE     0x25
+#define ACPI_DESC_TYPE_STATE_WSCOPE     0x26
+#define ACPI_DESC_TYPE_STATE_RESULT     0x27
+#define ACPI_DESC_TYPE_STATE_NOTIFY     0x28
+#define ACPI_DESC_TYPE_STATE_THREAD     0x29
+#define ACPI_DESC_TYPE_WALK             0x44
+#define ACPI_DESC_TYPE_PARSER           0x66
+#define ACPI_DESC_TYPE_OPERAND          0x88
+#define ACPI_DESC_TYPE_NAMED            0xAA
+
+
+union acpi_descriptor
+{
+	u8                                      descriptor_id;  /* To differentiate various internal objs */\
+	union acpi_operand_object               object;
+	struct acpi_namespace_node              node;
+	union acpi_parse_object                 op;
+};
+
+
+#endif /* _ACOBJECT_H */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acoutput.h linux-2.4.22-pre2/include/acpi/acoutput.h
--- linux-2.4.21/include/acpi/acoutput.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acoutput.h	2003-06-26 21:43:17.000000000 +0000
@@ -0,0 +1,185 @@
+/******************************************************************************
+ *
+ * Name: acoutput.h -- debug output
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACOUTPUT_H__
+#define __ACOUTPUT_H__
+
+/*
+ * Debug levels and component IDs.  These are used to control the
+ * granularity of the output of the DEBUG_PRINT macro -- on a per-
+ * component basis and a per-exception-type basis.
+ */
+
+/* Component IDs are used in the global "debug_layer" */
+
+#define ACPI_UTILITIES              0x00000001
+#define ACPI_HARDWARE               0x00000002
+#define ACPI_EVENTS                 0x00000004
+#define ACPI_TABLES                 0x00000008
+#define ACPI_NAMESPACE              0x00000010
+#define ACPI_PARSER                 0x00000020
+#define ACPI_DISPATCHER             0x00000040
+#define ACPI_EXECUTER               0x00000080
+#define ACPI_RESOURCES              0x00000100
+#define ACPI_CA_DEBUGGER            0x00000200
+#define ACPI_OS_SERVICES            0x00000400
+#define ACPI_CA_DISASSEMBLER        0x00000800
+
+/* Component IDs for ACPI tools and utilities */
+
+#define ACPI_COMPILER               0x00001000
+#define ACPI_TOOLS                  0x00002000
+
+#define ACPI_ALL_COMPONENTS         0x00003FFF
+#define ACPI_COMPONENT_DEFAULT      (ACPI_ALL_COMPONENTS)
+
+
+/* Component IDs reserved for ACPI drivers */
+
+#define ACPI_ALL_DRIVERS            0xFFFF0000
+
+
+/*
+ * Raw debug output levels, do not use these in the DEBUG_PRINT macros
+ */
+#define ACPI_LV_ERROR               0x00000001
+#define ACPI_LV_WARN                0x00000002
+#define ACPI_LV_INIT                0x00000004
+#define ACPI_LV_DEBUG_OBJECT        0x00000008
+#define ACPI_LV_INFO                0x00000010
+#define ACPI_LV_ALL_EXCEPTIONS      0x0000001F
+
+/* Trace verbosity level 1 [Standard Trace Level] */
+
+#define ACPI_LV_INIT_NAMES          0x00000020
+#define ACPI_LV_PARSE               0x00000040
+#define ACPI_LV_LOAD                0x00000080
+#define ACPI_LV_DISPATCH            0x00000100
+#define ACPI_LV_EXEC                0x00000200
+#define ACPI_LV_NAMES               0x00000400
+#define ACPI_LV_OPREGION            0x00000800
+#define ACPI_LV_BFIELD              0x00001000
+#define ACPI_LV_TABLES              0x00002000
+#define ACPI_LV_VALUES              0x00004000
+#define ACPI_LV_OBJECTS             0x00008000
+#define ACPI_LV_RESOURCES           0x00010000
+#define ACPI_LV_USER_REQUESTS       0x00020000
+#define ACPI_LV_PACKAGE             0x00040000
+#define ACPI_LV_VERBOSITY1          0x0007FF40 | ACPI_LV_ALL_EXCEPTIONS
+
+/* Trace verbosity level 2 [Function tracing and memory allocation] */
+
+#define ACPI_LV_ALLOCATIONS         0x00100000
+#define ACPI_LV_FUNCTIONS           0x00200000
+#define ACPI_LV_OPTIMIZATIONS       0x00400000
+#define ACPI_LV_VERBOSITY2          0x00700000 | ACPI_LV_VERBOSITY1
+#define ACPI_LV_ALL                 ACPI_LV_VERBOSITY2
+
+/* Trace verbosity level 3 [Threading, I/O, and Interrupts] */
+
+#define ACPI_LV_MUTEX               0x01000000
+#define ACPI_LV_THREADS             0x02000000
+#define ACPI_LV_IO                  0x04000000
+#define ACPI_LV_INTERRUPTS          0x08000000
+#define ACPI_LV_VERBOSITY3          0x0F000000 | ACPI_LV_VERBOSITY2
+
+/* Exceptionally verbose output -- also used in the global "debug_level" */
+
+#define ACPI_LV_AML_DISASSEMBLE     0x10000000
+#define ACPI_LV_VERBOSE_INFO        0x20000000
+#define ACPI_LV_FULL_TABLES         0x40000000
+#define ACPI_LV_EVENTS              0x80000000
+
+#define ACPI_LV_VERBOSE             0xF0000000
+
+
+/*
+ * Debug level macros that are used in the DEBUG_PRINT macros
+ */
+#define ACPI_DEBUG_LEVEL(dl)        (u32) dl,__LINE__,&_dbg
+
+/* Exception level -- used in the global "debug_level" */
+
+#define ACPI_DB_ERROR               ACPI_DEBUG_LEVEL (ACPI_LV_ERROR)
+#define ACPI_DB_WARN                ACPI_DEBUG_LEVEL (ACPI_LV_WARN)
+#define ACPI_DB_INIT                ACPI_DEBUG_LEVEL (ACPI_LV_INIT)
+#define ACPI_DB_DEBUG_OBJECT        ACPI_DEBUG_LEVEL (ACPI_LV_DEBUG_OBJECT)
+#define ACPI_DB_INFO                ACPI_DEBUG_LEVEL (ACPI_LV_INFO)
+#define ACPI_DB_ALL_EXCEPTIONS      ACPI_DEBUG_LEVEL (ACPI_LV_ALL_EXCEPTIONS)
+
+
+/* Trace level -- also used in the global "debug_level" */
+
+#define ACPI_DB_INIT_NAMES          ACPI_DEBUG_LEVEL (ACPI_LV_INIT_NAMES)
+#define ACPI_DB_THREADS             ACPI_DEBUG_LEVEL (ACPI_LV_THREADS)
+#define ACPI_DB_PARSE               ACPI_DEBUG_LEVEL (ACPI_LV_PARSE)
+#define ACPI_DB_DISPATCH            ACPI_DEBUG_LEVEL (ACPI_LV_DISPATCH)
+#define ACPI_DB_LOAD                ACPI_DEBUG_LEVEL (ACPI_LV_LOAD)
+#define ACPI_DB_EXEC                ACPI_DEBUG_LEVEL (ACPI_LV_EXEC)
+#define ACPI_DB_NAMES               ACPI_DEBUG_LEVEL (ACPI_LV_NAMES)
+#define ACPI_DB_OPREGION            ACPI_DEBUG_LEVEL (ACPI_LV_OPREGION)
+#define ACPI_DB_BFIELD              ACPI_DEBUG_LEVEL (ACPI_LV_BFIELD)
+#define ACPI_DB_TABLES              ACPI_DEBUG_LEVEL (ACPI_LV_TABLES)
+#define ACPI_DB_FUNCTIONS           ACPI_DEBUG_LEVEL (ACPI_LV_FUNCTIONS)
+#define ACPI_DB_OPTIMIZATIONS       ACPI_DEBUG_LEVEL (ACPI_LV_OPTIMIZATIONS)
+#define ACPI_DB_VALUES              ACPI_DEBUG_LEVEL (ACPI_LV_VALUES)
+#define ACPI_DB_OBJECTS             ACPI_DEBUG_LEVEL (ACPI_LV_OBJECTS)
+#define ACPI_DB_ALLOCATIONS         ACPI_DEBUG_LEVEL (ACPI_LV_ALLOCATIONS)
+#define ACPI_DB_RESOURCES           ACPI_DEBUG_LEVEL (ACPI_LV_RESOURCES)
+#define ACPI_DB_IO                  ACPI_DEBUG_LEVEL (ACPI_LV_IO)
+#define ACPI_DB_INTERRUPTS          ACPI_DEBUG_LEVEL (ACPI_LV_INTERRUPTS)
+#define ACPI_DB_USER_REQUESTS       ACPI_DEBUG_LEVEL (ACPI_LV_USER_REQUESTS)
+#define ACPI_DB_PACKAGE             ACPI_DEBUG_LEVEL (ACPI_LV_PACKAGE)
+#define ACPI_DB_MUTEX               ACPI_DEBUG_LEVEL (ACPI_LV_MUTEX)
+
+#define ACPI_DB_ALL                 ACPI_DEBUG_LEVEL (ACPI_LV_ALL)
+
+
+/* Defaults for debug_level, debug and normal */
+
+#define ACPI_DEBUG_DEFAULT          (ACPI_LV_INIT | ACPI_LV_WARN | ACPI_LV_ERROR | ACPI_LV_DEBUG_OBJECT)
+#define ACPI_NORMAL_DEFAULT         (ACPI_LV_INIT | ACPI_LV_WARN | ACPI_LV_ERROR | ACPI_LV_DEBUG_OBJECT)
+#define ACPI_DEBUG_ALL              (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL)
+
+
+#endif /* __ACOUTPUT_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acparser.h linux-2.4.22-pre2/include/acpi/acparser.h
--- linux-2.4.21/include/acpi/acparser.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acparser.h	2003-06-26 21:43:29.000000000 +0000
@@ -0,0 +1,347 @@
+/******************************************************************************
+ *
+ * Module Name: acparser.h - AML Parser subcomponent prototypes and defines
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+
+#ifndef __ACPARSER_H__
+#define __ACPARSER_H__
+
+
+#define OP_HAS_RETURN_VALUE             1
+
+/* variable # arguments */
+
+#define ACPI_VAR_ARGS                   ACPI_UINT32_MAX
+
+
+#define ACPI_PARSE_DELETE_TREE          0x0001
+#define ACPI_PARSE_NO_TREE_DELETE       0x0000
+#define ACPI_PARSE_TREE_MASK            0x0001
+
+#define ACPI_PARSE_LOAD_PASS1           0x0010
+#define ACPI_PARSE_LOAD_PASS2           0x0020
+#define ACPI_PARSE_EXECUTE              0x0030
+#define ACPI_PARSE_MODE_MASK            0x0030
+
+#define ACPI_PARSE_DEFERRED_OP          0x0100
+
+/* Parser external interfaces */
+
+acpi_status
+acpi_psx_load_table (
+	u8                              *pcode_addr,
+	u32                             pcode_length);
+
+acpi_status
+acpi_psx_execute (
+	struct acpi_namespace_node      *method_node,
+	union acpi_operand_object       **params,
+	union acpi_operand_object       **return_obj_desc);
+
+
+/******************************************************************************
+ *
+ * Parser interfaces
+ *
+ *****************************************************************************/
+
+
+/* psargs - Parse AML opcode arguments */
+
+u8 *
+acpi_ps_get_next_package_end (
+	struct acpi_parse_state         *parser_state);
+
+u32
+acpi_ps_get_next_package_length (
+	struct acpi_parse_state         *parser_state);
+
+char *
+acpi_ps_get_next_namestring (
+	struct acpi_parse_state         *parser_state);
+
+void
+acpi_ps_get_next_simple_arg (
+	struct acpi_parse_state         *parser_state,
+	u32                             arg_type,
+	union acpi_parse_object         *arg);
+
+acpi_status
+acpi_ps_get_next_namepath (
+	struct acpi_walk_state          *walk_state,
+	struct acpi_parse_state         *parser_state,
+	union acpi_parse_object         *arg,
+	u8                              method_call);
+
+union acpi_parse_object *
+acpi_ps_get_next_field (
+	struct acpi_parse_state         *parser_state);
+
+acpi_status
+acpi_ps_get_next_arg (
+	struct acpi_walk_state          *walk_state,
+	struct acpi_parse_state         *parser_state,
+	u32                             arg_type,
+	union acpi_parse_object         **return_arg);
+
+
+/* psfind */
+
+union acpi_parse_object *
+acpi_ps_find_name (
+	union acpi_parse_object         *scope,
+	u32                             name,
+	u32                             opcode);
+
+union acpi_parse_object*
+acpi_ps_get_parent (
+	union acpi_parse_object         *op);
+
+
+/* psopcode - AML Opcode information */
+
+const struct acpi_opcode_info *
+acpi_ps_get_opcode_info (
+	u16                             opcode);
+
+char *
+acpi_ps_get_opcode_name (
+	u16                             opcode);
+
+
+/* psparse - top level parsing routines */
+
+u32
+acpi_ps_get_opcode_size (
+	u32                             opcode);
+
+void
+acpi_ps_complete_this_op (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op);
+
+acpi_status
+acpi_ps_next_parse_state (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op,
+	acpi_status                     callback_status);
+
+acpi_status
+acpi_ps_find_object (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         **out_op);
+
+void
+acpi_ps_delete_parse_tree (
+	union acpi_parse_object         *root);
+
+acpi_status
+acpi_ps_parse_loop (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ps_parse_aml (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ps_parse_table (
+	u8                              *aml,
+	u32                             aml_size,
+	acpi_parse_downwards            descending_callback,
+	acpi_parse_upwards              ascending_callback,
+	union acpi_parse_object         **root_object);
+
+u16
+acpi_ps_peek_opcode (
+	struct acpi_parse_state         *state);
+
+
+/* psscope - Scope stack management routines */
+
+
+acpi_status
+acpi_ps_init_scope (
+	struct acpi_parse_state         *parser_state,
+	union acpi_parse_object         *root);
+
+union acpi_parse_object *
+acpi_ps_get_parent_scope (
+	struct acpi_parse_state         *state);
+
+u8
+acpi_ps_has_completed_scope (
+	struct acpi_parse_state         *parser_state);
+
+void
+acpi_ps_pop_scope (
+	struct acpi_parse_state         *parser_state,
+	union acpi_parse_object         **op,
+	u32                             *arg_list,
+	u32                             *arg_count);
+
+acpi_status
+acpi_ps_push_scope (
+	struct acpi_parse_state         *parser_state,
+	union acpi_parse_object         *op,
+	u32                             remaining_args,
+	u32                             arg_count);
+
+void
+acpi_ps_cleanup_scope (
+	struct acpi_parse_state         *state);
+
+
+/* pstree - parse tree manipulation routines */
+
+void
+acpi_ps_append_arg(
+	union acpi_parse_object         *op,
+	union acpi_parse_object         *arg);
+
+union acpi_parse_object*
+acpi_ps_find (
+	union acpi_parse_object         *scope,
+	char                            *path,
+	u16                             opcode,
+	u32                             create);
+
+union acpi_parse_object *
+acpi_ps_get_arg(
+	union acpi_parse_object         *op,
+	u32                              argn);
+
+union acpi_parse_object *
+acpi_ps_get_child (
+	union acpi_parse_object         *op);
+
+union acpi_parse_object *
+acpi_ps_get_depth_next (
+	union acpi_parse_object         *origin,
+	union acpi_parse_object         *op);
+
+
+/* pswalk - parse tree walk routines */
+
+acpi_status
+acpi_ps_walk_parsed_aml (
+	union acpi_parse_object         *start_op,
+	union acpi_parse_object         *end_op,
+	union acpi_operand_object       *mth_desc,
+	struct acpi_namespace_node      *start_node,
+	union acpi_operand_object       **params,
+	union acpi_operand_object       **caller_return_desc,
+	acpi_owner_id                   owner_id,
+	acpi_parse_downwards            descending_callback,
+	acpi_parse_upwards              ascending_callback);
+
+acpi_status
+acpi_ps_get_next_walk_op (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op,
+	acpi_parse_upwards              ascending_callback);
+
+acpi_status
+acpi_ps_delete_completed_op (
+	struct acpi_walk_state          *walk_state);
+
+
+/* psutils - parser utilities */
+
+union acpi_parse_object *
+acpi_ps_create_scope_op (
+	void);
+
+void
+acpi_ps_init_op (
+	union acpi_parse_object         *op,
+	u16                             opcode);
+
+union acpi_parse_object *
+acpi_ps_alloc_op (
+	u16                             opcode);
+
+void
+acpi_ps_free_op (
+	union acpi_parse_object         *op);
+
+void
+acpi_ps_delete_parse_cache (
+	void);
+
+u8
+acpi_ps_is_leading_char (
+	u32                             c);
+
+u8
+acpi_ps_is_prefix_char (
+	u32                             c);
+
+u32
+acpi_ps_get_name(
+	union acpi_parse_object         *op);
+
+void
+acpi_ps_set_name(
+	union acpi_parse_object         *op,
+	u32                             name);
+
+
+/* psdump - display parser tree */
+
+u32
+acpi_ps_sprint_path (
+	char                            *buffer_start,
+	u32                             buffer_size,
+	union acpi_parse_object         *op);
+
+u32
+acpi_ps_sprint_op (
+	char                            *buffer_start,
+	u32                             buffer_size,
+	union acpi_parse_object         *op);
+
+void
+acpi_ps_show (
+	union acpi_parse_object         *op);
+
+
+#endif /* __ACPARSER_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acpi.h linux-2.4.22-pre2/include/acpi/acpi.h
--- linux-2.4.21/include/acpi/acpi.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acpi.h	2003-06-26 21:43:22.000000000 +0000
@@ -0,0 +1,69 @@
+/******************************************************************************
+ *
+ * Name: acpi.h - Master include file, Publics and external data.
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACPI_H__
+#define __ACPI_H__
+
+/*
+ * Common includes for all ACPI driver files
+ * We put them here because we don't want to duplicate them
+ * in the rest of the source code again and again.
+ */
+#include "acconfig.h"           /* Configuration constants */
+#include "platform/acenv.h"     /* Target environment specific items */
+#include "actypes.h"            /* Fundamental common data types */
+#include "acexcep.h"            /* ACPI exception codes */
+#include "acmacros.h"           /* C macros */
+#include "actbl.h"              /* ACPI table definitions */
+#include "aclocal.h"            /* Internal data types */
+#include "acoutput.h"           /* Error output and Debug macros */
+#include "acpiosxf.h"           /* Interfaces to the ACPI-to-OS layer*/
+#include "acpixf.h"             /* ACPI core subsystem external interfaces */
+#include "acobject.h"           /* ACPI internal object */
+#include "acstruct.h"           /* Common structures */
+#include "acglobal.h"           /* All global variables */
+#include "achware.h"            /* Hardware defines and interfaces */
+#include "acutils.h"            /* Utility interfaces */
+
+
+#endif /* __ACPI_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acpi_bus.h linux-2.4.22-pre2/include/acpi/acpi_bus.h
--- linux-2.4.21/include/acpi/acpi_bus.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acpi_bus.h	2003-06-26 21:43:16.000000000 +0000
@@ -0,0 +1,315 @@
+/*
+ *  acpi_bus.h - ACPI Bus Driver ($Revision: 22 $)
+ *
+ *  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.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#ifndef __ACPI_BUS_H__
+#define __ACPI_BUS_H__
+
+#include <linux/version.h>
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,4))
+#include <linux/device.h>
+#define CONFIG_LDM
+#endif
+
+#include <acpi/acpi.h>
+
+
+/* TBD: Make dynamic */
+#define ACPI_MAX_HANDLES	10
+struct acpi_handle_list {
+	u32			count;
+	acpi_handle		handles[ACPI_MAX_HANDLES];
+};
+
+
+/* acpi_utils.h */
+acpi_status
+acpi_extract_package (
+	union acpi_object       *package,
+	struct acpi_buffer      *format,
+	struct acpi_buffer      *buffer);
+acpi_status
+acpi_evaluate_integer (
+	acpi_handle             handle,
+	acpi_string             pathname,
+	struct acpi_object_list *arguments,
+	unsigned long           *data);
+acpi_status
+acpi_evaluate_reference (
+	acpi_handle             handle,
+	acpi_string             pathname,
+	struct acpi_object_list *arguments,
+	struct acpi_handle_list *list);
+
+
+#ifdef CONFIG_ACPI_BUS
+
+#include <linux/proc_fs.h>
+
+#define ACPI_BUS_FILE_ROOT	"acpi"
+extern struct proc_dir_entry	*acpi_root_dir;
+extern FADT_DESCRIPTOR		acpi_fadt;
+
+enum acpi_bus_removal_type {
+	ACPI_BUS_REMOVAL_NORMAL	= 0,
+	ACPI_BUS_REMOVAL_EJECT,
+	ACPI_BUS_REMOVAL_SUPRISE,
+	ACPI_BUS_REMOVAL_TYPE_COUNT
+};
+
+enum acpi_bus_device_type {
+	ACPI_BUS_TYPE_DEVICE	= 0,
+	ACPI_BUS_TYPE_POWER,
+	ACPI_BUS_TYPE_PROCESSOR,
+	ACPI_BUS_TYPE_THERMAL,
+	ACPI_BUS_TYPE_SYSTEM,
+	ACPI_BUS_TYPE_POWER_BUTTON,
+	ACPI_BUS_TYPE_SLEEP_BUTTON,
+	ACPI_BUS_DEVICE_TYPE_COUNT
+};
+
+struct acpi_driver;
+struct acpi_device;
+
+
+/*
+ * ACPI Driver
+ * -----------
+ */
+
+typedef int (*acpi_op_add)	(struct acpi_device *device);
+typedef int (*acpi_op_remove)	(struct acpi_device *device, int type);
+typedef int (*acpi_op_lock)	(struct acpi_device *device, int type);
+typedef int (*acpi_op_start)	(struct acpi_device *device);
+typedef int (*acpi_op_stop)	(struct acpi_device *device, int type);
+typedef int (*acpi_op_suspend)	(struct acpi_device *device, int state);
+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);
+
+struct acpi_device_ops {
+	acpi_op_add		add;
+	acpi_op_remove		remove;
+	acpi_op_lock		lock;
+	acpi_op_start		start;
+	acpi_op_stop		stop;
+	acpi_op_suspend		suspend;
+	acpi_op_resume		resume;
+	acpi_op_scan		scan;
+	acpi_op_bind		bind;
+};
+
+struct acpi_driver {
+	struct list_head	node;
+	char			name[80];
+	char			class[80];
+	int			references;
+	char			*ids;		/* Supported Hardware IDs */
+	struct acpi_device_ops	ops;
+};
+
+/*
+ * ACPI Device
+ * -----------
+ */
+
+/* Status (_STA) */
+
+struct acpi_device_status {
+	u32			present:1;
+	u32			enabled:1;
+	u32			show_in_ui:1;
+	u32			functional:1;
+	u32			battery_present:1;
+	u32			reserved:27;
+};
+
+
+/* Flags */
+
+struct acpi_device_flags {
+	u32			dynamic_status:1;
+	u32			hardware_id:1;
+	u32			compatible_ids:1;
+	u32			bus_address:1;
+	u32			unique_id:1;
+	u32			removable:1;
+	u32			ejectable:1;
+	u32			lockable:1;
+	u32			suprise_removal_ok:1;
+	u32			power_manageable:1;
+	u32			performance_manageable:1;
+	u32			reserved:21;
+};
+
+
+/* File System */
+
+struct acpi_device_dir {
+	struct proc_dir_entry	*entry;
+};
+
+#define acpi_device_dir(d)	((d)->dir.entry)
+
+
+/* Plug and Play */
+
+typedef char			acpi_bus_id[5];
+typedef unsigned long		acpi_bus_address;
+typedef char			acpi_hardware_id[9];
+typedef char			acpi_unique_id[9];
+typedef char			acpi_device_name[40];
+typedef char			acpi_device_class[20];
+
+struct acpi_device_pnp {
+	acpi_bus_id		bus_id;		               /* Object name */
+	acpi_bus_address	bus_address;	                      /* _ADR */
+	acpi_hardware_id	hardware_id;	                      /* _HID */
+	struct acpi_compatible_id_list *cid_list;		     /* _CIDs */
+	acpi_unique_id		unique_id;	                      /* _UID */
+	acpi_device_name	device_name;	         /* Driver-determined */
+	acpi_device_class	device_class;	         /*        "          */
+};
+
+#define acpi_device_bid(d)	((d)->pnp.bus_id)
+#define acpi_device_adr(d)	((d)->pnp.bus_address)
+#define acpi_device_hid(d)	((d)->pnp.hardware_id)
+#define acpi_device_uid(d)	((d)->pnp.unique_id)
+#define acpi_device_name(d)	((d)->pnp.device_name)
+#define acpi_device_class(d)	((d)->pnp.device_class)
+
+
+/* Power Management */
+
+struct acpi_device_power_flags {
+	u32			explicit_get:1;		     /* _PSC present? */
+	u32			power_resources:1;	   /* Power resources */
+	u32			inrush_current:1;	  /* Serialize Dx->D0 */
+	u32			wake_capable:1;		 /* Wakeup supported? */
+	u32			wake_enabled:1;		/* Enabled for wakeup */
+	u32			power_removed:1;	   /* Optimize Dx->D0 */
+	u32			reserved:26;
+};
+
+struct acpi_device_power_state {
+	struct {
+		u8			valid:1;	
+		u8			explicit_set:1;	     /* _PSx present? */
+		u8			reserved:6;
+	}			flags;
+	int			power;		  /* % Power (compared to D0) */
+	int			latency;	/* Dx->D0 time (microseconds) */
+	struct acpi_handle_list	resources;	/* Power resources referenced */
+};
+
+struct acpi_device_power {
+	int			state;		             /* Current state */
+	struct acpi_device_power_flags flags;
+	struct acpi_device_power_state states[4];     /* Power states (D0-D3) */
+};
+
+
+/* Performance Management */
+
+struct acpi_device_perf_flags {
+	u8			reserved:8;
+};
+
+struct acpi_device_perf_state {
+	struct {
+		u8			valid:1;	
+		u8			reserved:7;
+	}			flags;
+	u8			power;		  /* % Power (compared to P0) */
+	u8			performance;	  /* % Performance (    "   ) */
+	int			latency;	/* Px->P0 time (microseconds) */
+};
+
+struct acpi_device_perf {
+	int			state;
+	struct acpi_device_perf_flags flags;
+	int			state_count;
+	struct acpi_device_perf_state *states;
+};
+
+
+/* Device */
+
+struct acpi_device {
+	acpi_handle		handle;
+	struct acpi_device	*parent;
+	struct list_head	children;
+	struct list_head	node;
+	struct acpi_device_status status;
+	struct acpi_device_flags flags;
+	struct acpi_device_pnp	pnp;
+	struct acpi_device_power power;
+	struct acpi_device_perf	performance;
+	struct acpi_device_dir	dir;
+	struct acpi_device_ops	ops;
+	struct acpi_driver	*driver;
+	void			*driver_data;
+#ifdef CONFIG_LDM
+	struct device		dev;
+#endif
+};
+
+#define acpi_driver_data(d)	((d)->driver_data)
+
+
+/*
+ * Events
+ * ------
+ */
+
+struct acpi_bus_event {
+	struct list_head	node;
+	acpi_device_class	device_class;
+	acpi_bus_id		bus_id;
+	u32			type;
+	u32			data;
+};
+
+
+/*
+ * External Functions
+ */
+
+int acpi_bus_get_device(acpi_handle, struct acpi_device **device);
+int acpi_bus_get_status (struct acpi_device *device);
+int acpi_bus_get_power (acpi_handle handle, int *state);
+int acpi_bus_set_power (acpi_handle handle, int state);
+int acpi_bus_generate_event (struct acpi_device *device, u8 type, int data);
+int acpi_bus_receive_event (struct acpi_bus_event *event);
+int acpi_bus_register_driver (struct acpi_driver *driver);
+int acpi_bus_unregister_driver (struct acpi_driver *driver);
+int acpi_bus_scan (struct acpi_device *device);
+int acpi_init (void);
+void acpi_exit (void);
+
+
+#endif /*CONFIG_ACPI_BUS*/
+
+#endif /*__ACPI_BUS_H__*/
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acpi_drivers.h linux-2.4.22-pre2/include/acpi/acpi_drivers.h
--- linux-2.4.21/include/acpi/acpi_drivers.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acpi_drivers.h	2003-06-26 21:43:12.000000000 +0000
@@ -0,0 +1,348 @@
+/*
+ *  acpi_drivers.h  ($Revision: 32 $)
+ *
+ *  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.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#ifndef __ACPI_DRIVERS_H__
+#define __ACPI_DRIVERS_H__
+
+#include <linux/acpi.h>
+#include "acpi_bus.h"
+
+
+#define ACPI_MAX_STRING			80
+
+
+/* --------------------------------------------------------------------------
+                                    ACPI Bus
+   -------------------------------------------------------------------------- */
+
+#define ACPI_BUS_COMPONENT		0x00010000
+#define ACPI_BUS_CLASS			"system_bus"
+#define ACPI_BUS_HID			"ACPI_BUS"
+#define ACPI_BUS_DRIVER_NAME		"ACPI Bus Driver"
+#define ACPI_BUS_DEVICE_NAME		"System Bus"
+
+
+/* --------------------------------------------------------------------------
+                                  AC Adapter
+   -------------------------------------------------------------------------- */
+
+#define ACPI_AC_COMPONENT		0x00020000
+#define ACPI_AC_CLASS			"ac_adapter"
+#define ACPI_AC_HID 			"ACPI0003"
+#define ACPI_AC_DRIVER_NAME		"ACPI AC Adapter Driver"
+#define ACPI_AC_DEVICE_NAME		"AC Adapter"
+#define ACPI_AC_FILE_STATE		"state"
+#define ACPI_AC_NOTIFY_STATUS		0x80
+#define ACPI_AC_STATUS_OFFLINE		0x00
+#define ACPI_AC_STATUS_ONLINE		0x01
+#define ACPI_AC_STATUS_UNKNOWN		0xFF
+
+
+/* --------------------------------------------------------------------------
+                                     Battery
+   -------------------------------------------------------------------------- */
+
+#define ACPI_BATTERY_COMPONENT		0x00040000
+#define ACPI_BATTERY_CLASS		"battery"
+#define ACPI_BATTERY_HID		"PNP0C0A"
+#define ACPI_BATTERY_DRIVER_NAME	"ACPI Battery Driver"
+#define ACPI_BATTERY_DEVICE_NAME	"Battery"
+#define ACPI_BATTERY_FILE_INFO		"info"
+#define ACPI_BATTERY_FILE_STATUS	"state"
+#define ACPI_BATTERY_FILE_ALARM		"alarm"
+#define ACPI_BATTERY_NOTIFY_STATUS	0x80
+#define ACPI_BATTERY_NOTIFY_INFO	0x81
+#define ACPI_BATTERY_UNITS_WATTS	"mW"
+#define ACPI_BATTERY_UNITS_AMPS		"mA"
+
+
+/* --------------------------------------------------------------------------
+                                      Button
+   -------------------------------------------------------------------------- */
+
+#define ACPI_BUTTON_COMPONENT		0x00080000
+#define ACPI_BUTTON_DRIVER_NAME		"ACPI Button Driver"
+#define ACPI_BUTTON_CLASS		"button"
+#define ACPI_BUTTON_FILE_INFO		"info"
+#define ACPI_BUTTON_FILE_STATE		"state"
+#define ACPI_BUTTON_TYPE_UNKNOWN	0x00
+#define ACPI_BUTTON_NOTIFY_STATUS	0x80
+
+#define ACPI_BUTTON_SUBCLASS_POWER	"power"
+#define ACPI_BUTTON_HID_POWER		"PNP0C0C"	
+#define ACPI_BUTTON_HID_POWERF		"ACPI_FPB"
+#define ACPI_BUTTON_DEVICE_NAME_POWER	"Power Button (CM)"
+#define ACPI_BUTTON_DEVICE_NAME_POWERF	"Power Button (FF)"
+#define ACPI_BUTTON_TYPE_POWER		0x01
+#define ACPI_BUTTON_TYPE_POWERF		0x02
+
+#define ACPI_BUTTON_SUBCLASS_SLEEP	"sleep"
+#define ACPI_BUTTON_HID_SLEEP		"PNP0C0E"
+#define ACPI_BUTTON_HID_SLEEPF		"ACPI_FSB"
+#define ACPI_BUTTON_DEVICE_NAME_SLEEP	"Sleep Button (CM)"
+#define ACPI_BUTTON_DEVICE_NAME_SLEEPF	"Sleep Button (FF)"
+#define ACPI_BUTTON_TYPE_SLEEP		0x03
+#define ACPI_BUTTON_TYPE_SLEEPF		0x04
+
+#define ACPI_BUTTON_SUBCLASS_LID	"lid"
+#define ACPI_BUTTON_HID_LID		"PNP0C0D"
+#define ACPI_BUTTON_DEVICE_NAME_LID	"Lid Switch"
+#define ACPI_BUTTON_TYPE_LID		0x05
+
+
+/* --------------------------------------------------------------------------
+                                Embedded Controller
+   -------------------------------------------------------------------------- */
+
+#define ACPI_EC_COMPONENT		0x00100000
+#define ACPI_EC_CLASS			"embedded_controller"
+#define ACPI_EC_HID			"PNP0C09"
+#define ACPI_EC_DRIVER_NAME		"ACPI Embedded Controller Driver"
+#define ACPI_EC_DEVICE_NAME		"Embedded Controller"
+#define ACPI_EC_FILE_INFO		"info"
+
+#ifdef CONFIG_ACPI_EC
+
+int acpi_ec_ecdt_probe (void);
+int acpi_ec_init (void);
+void acpi_ec_exit (void);
+
+#endif
+
+
+/* --------------------------------------------------------------------------
+                                       Fan
+   -------------------------------------------------------------------------- */
+
+#define ACPI_FAN_COMPONENT		0x00200000
+#define ACPI_FAN_CLASS			"fan"
+#define ACPI_FAN_HID			"PNP0C0B"
+#define ACPI_FAN_DRIVER_NAME		"ACPI Fan Driver"
+#define ACPI_FAN_DEVICE_NAME		"Fan"
+#define ACPI_FAN_FILE_STATE		"state"
+#define ACPI_FAN_NOTIFY_STATUS		0x80
+
+
+/* --------------------------------------------------------------------------
+                                       PCI
+   -------------------------------------------------------------------------- */
+
+#ifdef CONFIG_ACPI_PCI
+
+#define ACPI_PCI_COMPONENT		0x00400000
+
+/* ACPI PCI Root Bridge (pci_root.c) */
+
+#define ACPI_PCI_ROOT_CLASS		"pci_bridge"
+#define ACPI_PCI_ROOT_HID		"PNP0A03"
+#define ACPI_PCI_ROOT_DRIVER_NAME	"ACPI PCI Root Bridge Driver"
+#define ACPI_PCI_ROOT_DEVICE_NAME	"PCI Root Bridge"
+
+int acpi_pci_root_init (void);
+void acpi_pci_root_exit (void);
+void acpi_pci_get_translations (struct acpi_pci_id* id, u64* mem_tra, u64* io_tra);
+
+/* ACPI PCI Interrupt Link (pci_link.c) */
+
+#define ACPI_PCI_LINK_CLASS		"pci_irq_routing"
+#define ACPI_PCI_LINK_HID		"PNP0C0F"
+#define ACPI_PCI_LINK_DRIVER_NAME	"ACPI PCI Interrupt Link Driver"
+#define ACPI_PCI_LINK_DEVICE_NAME	"PCI Interrupt Link"
+#define ACPI_PCI_LINK_FILE_INFO		"info"
+#define ACPI_PCI_LINK_FILE_STATUS	"state"
+
+int acpi_pci_link_check (void);
+int acpi_pci_link_get_irq (acpi_handle handle, int index);
+int acpi_pci_link_init (void);
+void acpi_pci_link_exit (void);
+
+/* ACPI PCI Interrupt Routing (pci_irq.c) */
+
+int acpi_pci_irq_add_prt (acpi_handle handle, int segment, int bus);
+
+/* ACPI PCI Device Binding (pci_bind.c) */
+
+struct pci_bus;
+
+int acpi_pci_bind (struct acpi_device *device);
+int acpi_pci_bind_root (struct acpi_device *device, struct acpi_pci_id *id, struct pci_bus *bus);
+
+#endif /*CONFIG_ACPI_PCI*/
+
+
+/* --------------------------------------------------------------------------
+                                  Power Resource
+   -------------------------------------------------------------------------- */
+
+#define ACPI_POWER_COMPONENT		0x00800000
+#define ACPI_POWER_CLASS		"power_resource"
+#define ACPI_POWER_HID			"ACPI_PWR"
+#define ACPI_POWER_DRIVER_NAME		"ACPI Power Resource Driver"
+#define ACPI_POWER_DEVICE_NAME		"Power Resource"
+#define ACPI_POWER_FILE_INFO		"info"
+#define ACPI_POWER_FILE_STATUS		"state"
+#define ACPI_POWER_RESOURCE_STATE_OFF	0x00
+#define ACPI_POWER_RESOURCE_STATE_ON	0x01
+#define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF
+
+#ifdef CONFIG_ACPI_POWER
+
+int acpi_power_get_inferred_state (struct acpi_device *device);
+int acpi_power_transition (struct acpi_device *device, int state);
+int acpi_power_init (void);
+void acpi_power_exit (void);
+
+#endif
+
+
+/* --------------------------------------------------------------------------
+                                    Processor
+   -------------------------------------------------------------------------- */
+
+#define ACPI_PROCESSOR_COMPONENT	0x01000000
+#define ACPI_PROCESSOR_CLASS		"processor"
+#define ACPI_PROCESSOR_HID		"ACPI_CPU"
+#define ACPI_PROCESSOR_DRIVER_NAME	"ACPI Processor Driver"
+#define ACPI_PROCESSOR_DEVICE_NAME	"Processor"
+#define ACPI_PROCESSOR_FILE_INFO	"info"
+#define ACPI_PROCESSOR_FILE_POWER	"power"
+#define ACPI_PROCESSOR_FILE_PERFORMANCE	"performance"
+#define ACPI_PROCESSOR_FILE_THROTTLING	"throttling"
+#define ACPI_PROCESSOR_FILE_LIMIT	"limit"
+#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80
+#define ACPI_PROCESSOR_NOTIFY_POWER	0x81
+#define ACPI_PROCESSOR_LIMIT_NONE	0x00
+#define ACPI_PROCESSOR_LIMIT_INCREMENT	0x01
+#define ACPI_PROCESSOR_LIMIT_DECREMENT	0x02
+
+int acpi_processor_set_thermal_limit(acpi_handle handle, int type);
+
+
+/* --------------------------------------------------------------------------
+                                     System
+   -------------------------------------------------------------------------- */
+
+#define ACPI_SYSTEM_COMPONENT		0x02000000
+#define ACPI_SYSTEM_CLASS		"system"
+#define ACPI_SYSTEM_HID			"ACPI_SYS"
+#define ACPI_SYSTEM_DRIVER_NAME		"ACPI System Driver"
+#define ACPI_SYSTEM_DEVICE_NAME		"System"
+#define ACPI_SYSTEM_FILE_INFO		"info"
+#define ACPI_SYSTEM_FILE_EVENT		"event"
+#define ACPI_SYSTEM_FILE_ALARM		"alarm"
+#define ACPI_SYSTEM_FILE_DSDT		"dsdt"
+#define ACPI_SYSTEM_FILE_FADT		"fadt"
+#define ACPI_SYSTEM_FILE_SLEEP		"sleep"
+#define ACPI_SYSTEM_FILE_DEBUG_LAYER	"debug_layer"
+#define ACPI_SYSTEM_FILE_DEBUG_LEVEL	"debug_level"
+
+#ifdef CONFIG_ACPI_SYSTEM
+
+int acpi_system_init (void);
+void acpi_system_exit (void);
+
+#endif
+
+
+/* --------------------------------------------------------------------------
+                                 Thermal Zone
+   -------------------------------------------------------------------------- */
+
+#define ACPI_THERMAL_COMPONENT		0x04000000
+#define ACPI_THERMAL_CLASS		"thermal_zone"
+#define ACPI_THERMAL_HID		"ACPI_THM"
+#define ACPI_THERMAL_DRIVER_NAME	"ACPI Thermal Zone Driver"
+#define ACPI_THERMAL_DEVICE_NAME	"Thermal Zone"
+#define ACPI_THERMAL_FILE_STATE		"state"
+#define ACPI_THERMAL_FILE_TEMPERATURE	"temperature"
+#define ACPI_THERMAL_FILE_TRIP_POINTS	"trip_points"
+#define ACPI_THERMAL_FILE_COOLING_MODE	"cooling_mode"
+#define ACPI_THERMAL_FILE_POLLING_FREQ	"polling_frequency"
+#define ACPI_THERMAL_NOTIFY_TEMPERATURE	0x80
+#define ACPI_THERMAL_NOTIFY_THRESHOLDS	0x81
+#define ACPI_THERMAL_NOTIFY_DEVICES	0x82
+#define ACPI_THERMAL_NOTIFY_CRITICAL	0xF0
+#define ACPI_THERMAL_NOTIFY_HOT		0xF1
+#define ACPI_THERMAL_MODE_ACTIVE	0x00
+#define ACPI_THERMAL_MODE_PASSIVE	0x01
+#define ACPI_THERMAL_PATH_POWEROFF	"/sbin/poweroff"
+
+
+/* --------------------------------------------------------------------------
+                                Debug Support
+   -------------------------------------------------------------------------- */
+
+#define ACPI_DEBUG_RESTORE	0
+#define ACPI_DEBUG_LOW		1
+#define ACPI_DEBUG_MEDIUM	2
+#define ACPI_DEBUG_HIGH		3
+#define ACPI_DEBUG_DRIVERS	4
+
+extern u32 acpi_dbg_level;
+extern u32 acpi_dbg_layer;
+
+static inline void
+acpi_set_debug (
+	u32			flag)
+{
+	static u32		layer_save;
+	static u32		level_save;
+
+	switch (flag) {
+	case ACPI_DEBUG_RESTORE:
+		acpi_dbg_layer = layer_save;
+		acpi_dbg_level = level_save;
+		break;
+	case ACPI_DEBUG_LOW:
+	case ACPI_DEBUG_MEDIUM:
+	case ACPI_DEBUG_HIGH:
+	case ACPI_DEBUG_DRIVERS:
+		layer_save = acpi_dbg_layer;
+		level_save = acpi_dbg_level;
+		break;
+	}
+
+	switch (flag) {
+	case ACPI_DEBUG_LOW:
+		acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS;
+		acpi_dbg_level = ACPI_DEBUG_DEFAULT;
+		break;
+	case ACPI_DEBUG_MEDIUM:
+		acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS;
+		acpi_dbg_level = ACPI_LV_FUNCTIONS | ACPI_LV_ALL_EXCEPTIONS;
+		break;
+	case ACPI_DEBUG_HIGH:
+		acpi_dbg_layer = 0xFFFFFFFF;
+		acpi_dbg_level = 0xFFFFFFFF;
+		break;
+	case ACPI_DEBUG_DRIVERS:
+		acpi_dbg_layer = ACPI_ALL_DRIVERS;
+		acpi_dbg_level = 0xFFFFFFFF;
+		break;
+	}
+}
+
+
+#endif /*__ACPI_DRIVERS_H__*/
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acpiosxf.h linux-2.4.22-pre2/include/acpi/acpiosxf.h
--- linux-2.4.21/include/acpi/acpiosxf.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acpiosxf.h	2003-06-26 21:43:10.000000000 +0000
@@ -0,0 +1,373 @@
+
+/******************************************************************************
+ *
+ * Name: acpiosxf.h - All interfaces to the OS Services Layer (OSL).  These
+ *                    interfaces must be implemented by OSL to interface the
+ *                    ACPI components to the host operating system.
+ *
+ *****************************************************************************/
+
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACPIOSXF_H__
+#define __ACPIOSXF_H__
+
+#include "platform/acenv.h"
+#include "actypes.h"
+
+
+/* Priorities for acpi_os_queue_for_execution */
+
+#define OSD_PRIORITY_GPE            1
+#define OSD_PRIORITY_HIGH           2
+#define OSD_PRIORITY_MED            3
+#define OSD_PRIORITY_LO             4
+
+#define ACPI_NO_UNIT_LIMIT          ((u32) -1)
+#define ACPI_MUTEX_SEM              1
+
+
+/* Functions for acpi_os_signal */
+
+#define ACPI_SIGNAL_FATAL           0
+#define ACPI_SIGNAL_BREAKPOINT      1
+
+struct acpi_signal_fatal_info
+{
+	u32                             type;
+	u32                             code;
+	u32                             argument;
+};
+
+
+/*
+ * OSL Initialization and shutdown primitives
+ */
+
+acpi_status
+acpi_os_initialize (
+	void);
+
+acpi_status
+acpi_os_terminate (
+	void);
+
+
+/*
+ * ACPI Table interfaces
+ */
+
+acpi_status
+acpi_os_get_root_pointer (
+	u32                             flags,
+	struct acpi_pointer             *address);
+
+acpi_status
+acpi_os_predefined_override (
+	const struct acpi_predefined_names *init_val,
+	acpi_string                         *new_val);
+
+acpi_status
+acpi_os_table_override (
+	struct acpi_table_header        *existing_table,
+	struct acpi_table_header        **new_table);
+
+
+/*
+ * Synchronization primitives
+ */
+
+acpi_status
+acpi_os_create_semaphore (
+	u32                             max_units,
+	u32                             initial_units,
+	acpi_handle                     *out_handle);
+
+acpi_status
+acpi_os_delete_semaphore (
+	acpi_handle                     handle);
+
+acpi_status
+acpi_os_wait_semaphore (
+	acpi_handle                     handle,
+	u32                             units,
+	u16                             timeout);
+
+acpi_status
+acpi_os_signal_semaphore (
+	acpi_handle                     handle,
+	u32                             units);
+
+acpi_status
+acpi_os_create_lock (
+	acpi_handle                     *out_handle);
+
+void
+acpi_os_delete_lock (
+	acpi_handle                     handle);
+
+void
+acpi_os_acquire_lock (
+	acpi_handle                     handle,
+	u32                             flags);
+
+void
+acpi_os_release_lock (
+	acpi_handle                     handle,
+	u32                             flags);
+
+
+/*
+ * Memory allocation and mapping
+ */
+
+void *
+acpi_os_allocate (
+	acpi_size                       size);
+
+void
+acpi_os_free (
+	void *                          memory);
+
+acpi_status
+acpi_os_map_memory (
+	acpi_physical_address           physical_address,
+	acpi_size                       size,
+	void                            **logical_address);
+
+void
+acpi_os_unmap_memory (
+	void                            *logical_address,
+	acpi_size                       size);
+
+acpi_status
+acpi_os_get_physical_address (
+	void                            *logical_address,
+	acpi_physical_address           *physical_address);
+
+
+/*
+ * Interrupt handlers
+ */
+
+acpi_status
+acpi_os_install_interrupt_handler (
+	u32                             interrupt_number,
+	OSD_HANDLER             service_routine,
+	void                            *context);
+
+acpi_status
+acpi_os_remove_interrupt_handler (
+	u32                             interrupt_number,
+	OSD_HANDLER             service_routine);
+
+
+/*
+ * Threads and Scheduling
+ */
+
+u32
+acpi_os_get_thread_id (
+	void);
+
+acpi_status
+acpi_os_queue_for_execution (
+	u32                             priority,
+	OSD_EXECUTION_CALLBACK  function,
+	void                            *context);
+
+void
+acpi_os_sleep (
+	u32                             seconds,
+	u32                             milliseconds);
+
+void
+acpi_os_stall (
+	u32                             microseconds);
+
+
+/*
+ * Platform and hardware-independent I/O interfaces
+ */
+
+acpi_status
+acpi_os_read_port (
+	acpi_io_address                 address,
+	u32                             *value,
+	u32                             width);
+
+acpi_status
+acpi_os_write_port (
+	acpi_io_address                 address,
+	u32                             value,
+	u32                             width);
+
+
+/*
+ * Platform and hardware-independent physical memory interfaces
+ */
+
+acpi_status
+acpi_os_read_memory (
+	acpi_physical_address           address,
+	u32                             *value,
+	u32                             width);
+
+acpi_status
+acpi_os_write_memory (
+	acpi_physical_address           address,
+	u32                             value,
+	u32                             width);
+
+
+/*
+ * Platform and hardware-independent PCI configuration space access
+ */
+
+acpi_status
+acpi_os_read_pci_configuration (
+	struct acpi_pci_id              *pci_id,
+	u32                             register,
+	void                            *value,
+	u32                             width);
+
+acpi_status
+acpi_os_write_pci_configuration (
+	struct acpi_pci_id              *pci_id,
+	u32                             register,
+	acpi_integer                    value,
+	u32                             width);
+
+/*
+ * Interim function needed for PCI IRQ routing
+ */
+void
+acpi_os_derive_pci_id(
+	acpi_handle                     rhandle,
+	acpi_handle                     chandle,
+	struct acpi_pci_id              **pci_id);
+
+/*
+ * Miscellaneous
+ */
+
+u8
+acpi_os_readable (
+	void                            *pointer,
+	acpi_size                       length);
+
+u8
+acpi_os_writable (
+	void                            *pointer,
+	acpi_size                       length);
+
+u32
+acpi_os_get_timer (
+	void);
+
+acpi_status
+acpi_os_signal (
+	u32                             function,
+	void                            *info);
+
+/*
+ * Debug print routines
+ */
+
+void ACPI_INTERNAL_VAR_XFACE
+acpi_os_printf (
+	const char                      *format,
+	...);
+
+void
+acpi_os_vprintf (
+	const char                      *format,
+	va_list                 args);
+
+void
+acpi_os_redirect_output (
+	void                            *destination);
+
+
+/*
+ * Debug input
+ */
+
+u32
+acpi_os_get_line (
+	char                            *buffer);
+
+
+/*
+ * Directory manipulation
+ */
+
+void *
+acpi_os_open_directory (
+	char                            *pathname,
+	char                            *wildcard_spec,
+	char                            requested_file_type);
+
+/* requeste_file_type values */
+
+#define REQUEST_FILE_ONLY                   0
+#define REQUEST_DIR_ONLY                    1
+
+
+char *
+acpi_os_get_next_filename (
+	void                            *dir_handle);
+
+void
+acpi_os_close_directory (
+	void                            *dir_handle);
+
+/*
+ * Debug
+ */
+
+void
+acpi_os_dbg_assert(
+	void                            *failed_assertion,
+	void                            *file_name,
+	u32                             line_number,
+	char                            *message);
+
+
+#endif /* __ACPIOSXF_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acpixf.h linux-2.4.22-pre2/include/acpi/acpixf.h
--- linux-2.4.21/include/acpi/acpixf.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acpixf.h	2003-06-26 21:43:10.000000000 +0000
@@ -0,0 +1,462 @@
+
+/******************************************************************************
+ *
+ * Name: acpixf.h - External interfaces to the ACPI subsystem
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+
+#ifndef __ACXFACE_H__
+#define __ACXFACE_H__
+
+#include "actypes.h"
+#include "actbl.h"
+
+
+ /*
+ * Global interfaces
+ */
+
+acpi_status
+acpi_initialize_subsystem (
+	void);
+
+acpi_status
+acpi_enable_subsystem (
+	u32                             flags);
+
+acpi_status
+acpi_initialize_objects (
+	u32                             flags);
+
+acpi_status
+acpi_terminate (
+	void);
+
+acpi_status
+acpi_subsystem_status (
+	void);
+
+acpi_status
+acpi_enable (
+	void);
+
+acpi_status
+acpi_disable (
+	void);
+
+acpi_status
+acpi_get_system_info (
+	struct acpi_buffer              *ret_buffer);
+
+const char *
+acpi_format_exception (
+	acpi_status                     exception);
+
+acpi_status
+acpi_purge_cached_objects (
+	void);
+
+acpi_status
+acpi_install_initialization_handler (
+	acpi_init_handler               handler,
+	u32                             function);
+
+/*
+ * ACPI Memory manager
+ */
+
+void *
+acpi_allocate (
+	u32                             size);
+
+void *
+acpi_callocate (
+	u32                             size);
+
+void
+acpi_free (
+	void                            *address);
+
+
+/*
+ * ACPI table manipulation interfaces
+ */
+
+acpi_status
+acpi_find_root_pointer (
+	u32                             flags,
+	struct acpi_pointer             *rsdp_address);
+
+acpi_status
+acpi_load_tables (
+	void);
+
+acpi_status
+acpi_load_table (
+	struct acpi_table_header        *table_ptr);
+
+acpi_status
+acpi_unload_table (
+	acpi_table_type                 table_type);
+
+acpi_status
+acpi_get_table_header (
+	acpi_table_type                 table_type,
+	u32                             instance,
+	struct acpi_table_header        *out_table_header);
+
+acpi_status
+acpi_get_table (
+	acpi_table_type                 table_type,
+	u32                             instance,
+	struct acpi_buffer              *ret_buffer);
+
+acpi_status
+acpi_get_firmware_table (
+	acpi_string                     signature,
+	u32                             instance,
+	u32                             flags,
+	struct acpi_table_header        **table_pointer);
+
+
+/*
+ * Namespace and name interfaces
+ */
+
+acpi_status
+acpi_walk_namespace (
+	acpi_object_type                type,
+	acpi_handle                     start_object,
+	u32                             max_depth,
+	acpi_walk_callback              user_function,
+	void                            *context,
+	void                            **return_value);
+
+acpi_status
+acpi_get_devices (
+	char                            *HID,
+	acpi_walk_callback              user_function,
+	void                            *context,
+	void                            **return_value);
+
+acpi_status
+acpi_get_name (
+	acpi_handle                     handle,
+	u32                             name_type,
+	struct acpi_buffer              *ret_path_ptr);
+
+acpi_status
+acpi_get_handle (
+	acpi_handle                     parent,
+	acpi_string                     pathname,
+	acpi_handle                     *ret_handle);
+
+acpi_status
+acpi_attach_data (
+	acpi_handle                     obj_handle,
+	acpi_object_handler             handler,
+	void                            *data);
+
+acpi_status
+acpi_detach_data (
+	acpi_handle                     obj_handle,
+	acpi_object_handler             handler);
+
+acpi_status
+acpi_get_data (
+	acpi_handle                     obj_handle,
+	acpi_object_handler             handler,
+	void                            **data);
+
+
+/*
+ * Object manipulation and enumeration
+ */
+
+acpi_status
+acpi_evaluate_object (
+	acpi_handle                     object,
+	acpi_string                     pathname,
+	struct acpi_object_list         *parameter_objects,
+	struct acpi_buffer              *return_object_buffer);
+
+acpi_status
+acpi_evaluate_object_typed (
+	acpi_handle                     object,
+	acpi_string                     pathname,
+	struct acpi_object_list         *external_params,
+	struct acpi_buffer              *return_buffer,
+	acpi_object_type                return_type);
+
+acpi_status
+acpi_get_object_info (
+	acpi_handle                     handle,
+	struct acpi_buffer              *return_buffer);
+
+acpi_status
+acpi_get_next_object (
+	acpi_object_type                type,
+	acpi_handle                     parent,
+	acpi_handle                     child,
+	acpi_handle                     *out_handle);
+
+acpi_status
+acpi_get_type (
+	acpi_handle                     object,
+	acpi_object_type                *out_type);
+
+acpi_status
+acpi_get_parent (
+	acpi_handle                     object,
+	acpi_handle                     *out_handle);
+
+
+/*
+ * Event handler interfaces
+ */
+
+acpi_status
+acpi_install_fixed_event_handler (
+	u32                             acpi_event,
+	acpi_event_handler              handler,
+	void                            *context);
+
+acpi_status
+acpi_remove_fixed_event_handler (
+	u32                             acpi_event,
+	acpi_event_handler              handler);
+
+acpi_status
+acpi_install_notify_handler (
+	acpi_handle                     device,
+	u32                             handler_type,
+	acpi_notify_handler             handler,
+	void                            *context);
+
+acpi_status
+acpi_remove_notify_handler (
+	acpi_handle                     device,
+	u32                             handler_type,
+	acpi_notify_handler             handler);
+
+acpi_status
+acpi_install_address_space_handler (
+	acpi_handle                     device,
+	acpi_adr_space_type             space_id,
+	acpi_adr_space_handler          handler,
+	acpi_adr_space_setup            setup,
+	void                            *context);
+
+acpi_status
+acpi_remove_address_space_handler (
+	acpi_handle                     device,
+	acpi_adr_space_type             space_id,
+	acpi_adr_space_handler          handler);
+
+acpi_status
+acpi_install_gpe_handler (
+	acpi_handle                     gpe_device,
+	u32                             gpe_number,
+	u32                             type,
+	acpi_gpe_handler                handler,
+	void                            *context);
+
+acpi_status
+acpi_acquire_global_lock (
+	u16                             timeout,
+	u32                             *handle);
+
+acpi_status
+acpi_release_global_lock (
+	u32                             handle);
+
+acpi_status
+acpi_remove_gpe_handler (
+	acpi_handle                     gpe_device,
+	u32                             gpe_number,
+	acpi_gpe_handler                handler);
+
+acpi_status
+acpi_enable_event (
+	u32                             event,
+	u32                             flags);
+
+acpi_status
+acpi_disable_event (
+	u32                             event,
+	u32                             flags);
+
+acpi_status
+acpi_clear_event (
+	u32                             event);
+
+acpi_status
+acpi_get_event_status (
+	u32                             event,
+	acpi_event_status               *event_status);
+
+acpi_status
+acpi_enable_gpe (
+	acpi_handle                     gpe_device,
+	u32                             gpe_number,
+	u32                             flags);
+
+acpi_status
+acpi_disable_gpe (
+	acpi_handle                     gpe_device,
+	u32                             gpe_number,
+	u32                             flags);
+
+acpi_status
+acpi_clear_gpe (
+	acpi_handle                     gpe_device,
+	u32                             gpe_number,
+	u32                             flags);
+
+acpi_status
+acpi_get_gpe_status (
+	acpi_handle                     gpe_device,
+	u32                             gpe_number,
+	u32                             flags,
+	acpi_event_status               *event_status);
+
+acpi_status
+acpi_install_gpe_block (
+	acpi_handle                     gpe_device,
+	struct acpi_generic_address     *gpe_block_address,
+	u32                             register_count,
+	u32                             interrupt_level);
+
+acpi_status
+acpi_remove_gpe_block (
+	acpi_handle                     gpe_device);
+
+
+/*
+ * Resource interfaces
+ */
+
+typedef
+acpi_status (*ACPI_WALK_RESOURCE_CALLBACK) (
+	struct acpi_resource            *resource,
+	void                            *context);
+
+
+acpi_status
+acpi_get_current_resources(
+	acpi_handle                     device_handle,
+	struct acpi_buffer              *ret_buffer);
+
+acpi_status
+acpi_get_possible_resources(
+	acpi_handle                     device_handle,
+	struct acpi_buffer              *ret_buffer);
+
+acpi_status
+acpi_walk_resources (
+	acpi_handle                             device_handle,
+	char                                    *path,
+	ACPI_WALK_RESOURCE_CALLBACK     user_function,
+	void                                    *context);
+
+acpi_status
+acpi_set_current_resources (
+	acpi_handle                     device_handle,
+	struct acpi_buffer              *in_buffer);
+
+acpi_status
+acpi_get_irq_routing_table (
+	acpi_handle                     bus_device_handle,
+	struct acpi_buffer              *ret_buffer);
+
+acpi_status
+acpi_resource_to_address64 (
+	struct acpi_resource            *resource,
+	struct acpi_resource_address64 *out);
+
+/*
+ * Hardware (ACPI device) interfaces
+ */
+
+acpi_status
+acpi_get_register (
+	u32                             register_id,
+	u32                             *return_value,
+	u32                             flags);
+
+acpi_status
+acpi_set_register (
+	u32                             register_id,
+	u32                             value,
+	u32                             flags);
+
+acpi_status
+acpi_set_firmware_waking_vector (
+	acpi_physical_address           physical_address);
+
+acpi_status
+acpi_get_firmware_waking_vector (
+	acpi_physical_address           *physical_address);
+
+acpi_status
+acpi_get_sleep_type_data (
+	u8                              sleep_state,
+	u8                              *slp_typ_a,
+	u8                              *slp_typ_b);
+
+acpi_status
+acpi_enter_sleep_state_prep (
+	u8                              sleep_state);
+
+acpi_status
+acpi_enter_sleep_state (
+	u8                              sleep_state);
+
+acpi_status
+acpi_enter_sleep_state_s4bios (
+	void);
+
+acpi_status
+acpi_leave_sleep_state (
+	u8                              sleep_state);
+
+
+#endif /* __ACXFACE_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acresrc.h linux-2.4.22-pre2/include/acpi/acresrc.h
--- linux-2.4.21/include/acpi/acresrc.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acresrc.h	2003-06-26 21:43:12.000000000 +0000
@@ -0,0 +1,391 @@
+/******************************************************************************
+ *
+ * Name: acresrc.h - Resource Manager function prototypes
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACRESRC_H__
+#define __ACRESRC_H__
+
+
+/*
+ *  Function prototypes called from Acpi* APIs
+ */
+
+acpi_status
+acpi_rs_get_prt_method_data (
+	acpi_handle                     handle,
+	struct acpi_buffer              *ret_buffer);
+
+
+acpi_status
+acpi_rs_get_crs_method_data (
+	acpi_handle                     handle,
+	struct acpi_buffer              *ret_buffer);
+
+acpi_status
+acpi_rs_get_prs_method_data (
+	acpi_handle                     handle,
+	struct acpi_buffer              *ret_buffer);
+
+acpi_status
+acpi_rs_get_method_data (
+	acpi_handle                     handle,
+	char                            *path,
+	struct acpi_buffer              *ret_buffer);
+
+acpi_status
+acpi_rs_set_srs_method_data (
+	acpi_handle                     handle,
+	struct acpi_buffer              *ret_buffer);
+
+acpi_status
+acpi_rs_create_resource_list (
+	union acpi_operand_object       *byte_stream_buffer,
+	struct acpi_buffer              *output_buffer);
+
+acpi_status
+acpi_rs_create_byte_stream (
+	struct acpi_resource            *linked_list_buffer,
+	struct acpi_buffer              *output_buffer);
+
+acpi_status
+acpi_rs_create_pci_routing_table (
+	union acpi_operand_object       *package_object,
+	struct acpi_buffer              *output_buffer);
+
+
+/*
+ * Function prototypes called from acpi_rs_create*
+ */
+void
+acpi_rs_dump_irq (
+	union acpi_resource_data        *data);
+
+void
+acpi_rs_dump_address16 (
+	union acpi_resource_data        *data);
+
+void
+acpi_rs_dump_address32 (
+	union acpi_resource_data        *data);
+
+void
+acpi_rs_dump_address64 (
+	union acpi_resource_data        *data);
+
+void
+acpi_rs_dump_dma (
+	union acpi_resource_data        *data);
+
+void
+acpi_rs_dump_io (
+	union acpi_resource_data        *data);
+
+void
+acpi_rs_dump_extended_irq (
+	union acpi_resource_data        *data);
+
+void
+acpi_rs_dump_fixed_io (
+	union acpi_resource_data        *data);
+
+void
+acpi_rs_dump_fixed_memory32 (
+	union acpi_resource_data        *data);
+
+void
+acpi_rs_dump_memory24 (
+	union acpi_resource_data        *data);
+
+void
+acpi_rs_dump_memory32 (
+	union acpi_resource_data        *data);
+
+void
+acpi_rs_dump_start_depend_fns (
+	union acpi_resource_data        *data);
+
+void
+acpi_rs_dump_vendor_specific (
+	union acpi_resource_data        *data);
+
+void
+acpi_rs_dump_resource_list (
+	struct acpi_resource            *resource);
+
+void
+acpi_rs_dump_irq_list (
+	u8                              *route_table);
+
+acpi_status
+acpi_rs_get_byte_stream_start (
+	u8                              *byte_stream_buffer,
+	u8                              **byte_stream_start,
+	u32                             *size);
+
+acpi_status
+acpi_rs_get_list_length (
+	u8                              *byte_stream_buffer,
+	u32                             byte_stream_buffer_length,
+	acpi_size                       *size_needed);
+
+acpi_status
+acpi_rs_get_byte_stream_length (
+	struct acpi_resource            *linked_list_buffer,
+	acpi_size                       *size_needed);
+
+acpi_status
+acpi_rs_get_pci_routing_table_length (
+	union acpi_operand_object       *package_object,
+	acpi_size                       *buffer_size_needed);
+
+acpi_status
+acpi_rs_byte_stream_to_list (
+	u8                              *byte_stream_buffer,
+	u32                             byte_stream_buffer_length,
+	u8                              *output_buffer);
+
+acpi_status
+acpi_rs_list_to_byte_stream (
+	struct acpi_resource            *linked_list,
+	acpi_size                       byte_stream_size_needed,
+	u8                              *output_buffer);
+
+acpi_status
+acpi_rs_io_resource (
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size);
+
+acpi_status
+acpi_rs_fixed_io_resource (
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size);
+
+acpi_status
+acpi_rs_io_stream (
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed);
+
+acpi_status
+acpi_rs_fixed_io_stream (
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed);
+
+acpi_status
+acpi_rs_irq_resource (
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size);
+
+acpi_status
+acpi_rs_irq_stream (
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed);
+
+acpi_status
+acpi_rs_dma_resource (
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size);
+
+acpi_status
+acpi_rs_dma_stream (
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed);
+
+acpi_status
+acpi_rs_address16_resource (
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size);
+
+acpi_status
+acpi_rs_address16_stream (
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed);
+
+acpi_status
+acpi_rs_address32_resource (
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size);
+
+acpi_status
+acpi_rs_address32_stream (
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed);
+
+acpi_status
+acpi_rs_address64_resource (
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size);
+
+acpi_status
+acpi_rs_address64_stream (
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed);
+
+acpi_status
+acpi_rs_start_depend_fns_resource (
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size);
+
+acpi_status
+acpi_rs_end_depend_fns_resource (
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size);
+
+acpi_status
+acpi_rs_start_depend_fns_stream (
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed);
+
+acpi_status
+acpi_rs_end_depend_fns_stream (
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed);
+
+acpi_status
+acpi_rs_memory24_resource (
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size);
+
+acpi_status
+acpi_rs_memory24_stream (
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed);
+
+acpi_status
+acpi_rs_memory32_range_resource (
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size);
+
+acpi_status
+acpi_rs_fixed_memory32_resource (
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size);
+
+acpi_status
+acpi_rs_memory32_range_stream (
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed);
+
+acpi_status
+acpi_rs_fixed_memory32_stream (
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed);
+
+acpi_status
+acpi_rs_extended_irq_resource (
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size);
+
+acpi_status
+acpi_rs_extended_irq_stream (
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed);
+
+acpi_status
+acpi_rs_end_tag_resource (
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size);
+
+acpi_status
+acpi_rs_end_tag_stream (
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed);
+
+acpi_status
+acpi_rs_vendor_resource (
+	u8                              *byte_stream_buffer,
+	acpi_size                       *bytes_consumed,
+	u8                              **output_buffer,
+	acpi_size                       *structure_size);
+
+acpi_status
+acpi_rs_vendor_stream (
+	struct acpi_resource            *linked_list,
+	u8                              **output_buffer,
+	acpi_size                       *bytes_consumed);
+
+u8
+acpi_rs_get_resource_type (
+	u8                              resource_start_byte);
+
+#endif  /* __ACRESRC_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acstruct.h linux-2.4.22-pre2/include/acpi/acstruct.h
--- linux-2.4.21/include/acpi/acstruct.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acstruct.h	2003-06-26 21:43:11.000000000 +0000
@@ -0,0 +1,202 @@
+/******************************************************************************
+ *
+ * Name: acstruct.h - Internal structs
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACSTRUCT_H__
+#define __ACSTRUCT_H__
+
+
+/*****************************************************************************
+ *
+ * Tree walking typedefs and structs
+ *
+ ****************************************************************************/
+
+
+/*
+ * Walk state - current state of a parse tree walk.  Used for both a leisurely stroll through
+ * the tree (for whatever reason), and for control method execution.
+ */
+
+#define ACPI_NEXT_OP_DOWNWARD       1
+#define ACPI_NEXT_OP_UPWARD         2
+
+#define ACPI_WALK_NON_METHOD        0
+#define ACPI_WALK_METHOD            1
+#define ACPI_WALK_METHOD_RESTART    2
+#define ACPI_WALK_CONST_REQUIRED    3
+#define ACPI_WALK_CONST_OPTIONAL    4
+
+struct acpi_walk_state
+{
+	u8                                  data_type;                          /* To differentiate various internal objs MUST BE FIRST!*/\
+	acpi_owner_id                       owner_id;                           /* Owner of objects created during the walk */
+	u8                                  last_predicate;                     /* Result of last predicate */
+	u8                                  current_result;                     /* */
+	u8                                  next_op_info;                       /* Info about next_op */
+	u8                                  num_operands;                       /* Stack pointer for Operands[] array */
+	u8                                  return_used;
+	u8                                  walk_type;
+	u16                                 opcode;                             /* Current AML opcode */
+	u8                                  scope_depth;
+	u8                                  reserved1;
+	u32                                 arg_count;                          /* push for fixed or var args */
+	u32                                 aml_offset;
+	u32                                 arg_types;
+	u32                                 method_breakpoint;                  /* For single stepping */
+	u32                                 user_breakpoint;                    /* User AML breakpoint */
+	u32                                 parse_flags;
+	u32                                 prev_arg_types;
+
+	u8                                  *aml_last_while;
+	struct acpi_namespace_node          arguments[ACPI_METHOD_NUM_ARGS];    /* Control method arguments */
+	union acpi_operand_object           **caller_return_desc;
+	union acpi_generic_state            *control_state;                     /* List of control states (nested IFs) */
+	struct acpi_namespace_node          local_variables[ACPI_METHOD_NUM_LOCALS];    /* Control method locals */
+	struct acpi_namespace_node          *method_call_node;                  /* Called method Node*/
+	union acpi_parse_object             *method_call_op;                    /* method_call Op if running a method */
+	union acpi_operand_object           *method_desc;                       /* Method descriptor if running a method */
+	struct acpi_namespace_node          *method_node;                       /* Method Node if running a method */
+	union acpi_parse_object             *op;                                /* Current parser op */
+	union acpi_operand_object           *operands[ACPI_OBJ_NUM_OPERANDS+1]; /* Operands passed to the interpreter (+1 for NULL terminator) */
+	const struct acpi_opcode_info       *op_info;                           /* Info on current opcode */
+	union acpi_parse_object             *origin;                            /* Start of walk [Obsolete] */
+	union acpi_operand_object           **params;
+	struct acpi_parse_state             parser_state;                       /* Current state of parser */
+	union acpi_operand_object           *result_obj;
+	union acpi_generic_state            *results;                           /* Stack of accumulated results */
+	union acpi_operand_object           *return_desc;                       /* Return object, if any */
+	union acpi_generic_state            *scope_info;                        /* Stack of nested scopes */
+
+	union acpi_parse_object             *prev_op;                           /* Last op that was processed */
+	union acpi_parse_object             *next_op;                           /* next op to be processed */
+	acpi_parse_downwards                descending_callback;
+	acpi_parse_upwards                  ascending_callback;
+	struct acpi_thread_state            *thread;
+	struct acpi_walk_state              *next;                              /* Next walk_state in list */
+};
+
+
+/* Info used by acpi_ps_init_objects */
+
+struct acpi_init_walk_info
+{
+	u16                             method_count;
+	u16                             device_count;
+	u16                             op_region_count;
+	u16                             field_count;
+	u16                             buffer_count;
+	u16                             package_count;
+	u16                             op_region_init;
+	u16                             field_init;
+	u16                             buffer_init;
+	u16                             package_init;
+	u16                             object_count;
+	struct acpi_table_desc          *table_desc;
+};
+
+
+/* Info used by acpi_ns_initialize_devices */
+
+struct acpi_device_walk_info
+{
+	u16                             device_count;
+	u16                             num_STA;
+	u16                             num_INI;
+	struct acpi_table_desc          *table_desc;
+};
+
+
+/* TBD: [Restructure] Merge with struct above */
+
+struct acpi_walk_info
+{
+	u32                             debug_level;
+	u32                             owner_id;
+	u8                              display_type;
+};
+
+/* Display Types */
+
+#define ACPI_DISPLAY_SUMMARY    0
+#define ACPI_DISPLAY_OBJECTS    1
+
+struct acpi_get_devices_info
+{
+	acpi_walk_callback              user_function;
+	void                            *context;
+	char                            *hid;
+};
+
+
+union acpi_aml_operands
+{
+	union acpi_operand_object           *operands[7];
+
+	struct
+	{
+		struct acpi_object_integer      *type;
+		struct acpi_object_integer      *code;
+		struct acpi_object_integer      *argument;
+
+	} fatal;
+
+	struct
+	{
+		union acpi_operand_object       *source;
+		struct acpi_object_integer      *index;
+		union acpi_operand_object       *target;
+
+	} index;
+
+	struct
+	{
+		union acpi_operand_object       *source;
+		struct acpi_object_integer      *index;
+		struct acpi_object_integer      *length;
+		union acpi_operand_object       *target;
+
+	} mid;
+};
+
+
+#endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/actables.h linux-2.4.22-pre2/include/acpi/actables.h
--- linux-2.4.21/include/acpi/actables.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/actables.h	2003-06-26 21:43:15.000000000 +0000
@@ -0,0 +1,233 @@
+/******************************************************************************
+ *
+ * Name: actables.h - ACPI table management
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACTABLES_H__
+#define __ACTABLES_H__
+
+
+/* Used in acpi_tb_map_acpi_table for size parameter if table header is to be used */
+
+#define SIZE_IN_HEADER          0
+
+
+acpi_status
+acpi_tb_handle_to_object (
+	u16                             table_id,
+	struct acpi_table_desc          **table_desc);
+
+/*
+ * tbconvrt - Table conversion routines
+ */
+
+acpi_status
+acpi_tb_convert_to_xsdt (
+	struct acpi_table_desc          *table_info);
+
+acpi_status
+acpi_tb_convert_table_fadt (
+	void);
+
+acpi_status
+acpi_tb_build_common_facs (
+	struct acpi_table_desc          *table_info);
+
+u32
+acpi_tb_get_table_count (
+	struct rsdp_descriptor          *RSDP,
+	struct acpi_table_header        *RSDT);
+
+/*
+ * tbget - Table "get" routines
+ */
+
+acpi_status
+acpi_tb_get_table (
+	struct acpi_pointer             *address,
+	struct acpi_table_desc          *table_info);
+
+acpi_status
+acpi_tb_get_table_header (
+	struct acpi_pointer             *address,
+	struct acpi_table_header        *return_header);
+
+acpi_status
+acpi_tb_get_table_body (
+	struct acpi_pointer             *address,
+	struct acpi_table_header        *header,
+	struct acpi_table_desc          *table_info);
+
+acpi_status
+acpi_tb_get_this_table (
+	struct acpi_pointer             *address,
+	struct acpi_table_header        *header,
+	struct acpi_table_desc          *table_info);
+
+acpi_status
+acpi_tb_table_override (
+	struct acpi_table_header        *header,
+	struct acpi_table_desc          *table_info);
+
+acpi_status
+acpi_tb_get_table_ptr (
+	acpi_table_type                 table_type,
+	u32                             instance,
+	struct acpi_table_header        **table_ptr_loc);
+
+acpi_status
+acpi_tb_verify_rsdp (
+	struct acpi_pointer             *address);
+
+void
+acpi_tb_get_rsdt_address (
+	struct acpi_pointer             *out_address);
+
+acpi_status
+acpi_tb_validate_rsdt (
+	struct acpi_table_header        *table_ptr);
+
+acpi_status
+acpi_tb_get_required_tables (
+	void);
+
+acpi_status
+acpi_tb_get_primary_table (
+	struct acpi_pointer             *address,
+	struct acpi_table_desc          *table_info);
+
+acpi_status
+acpi_tb_get_secondary_table (
+	struct acpi_pointer             *address,
+	acpi_string                     signature,
+	struct acpi_table_desc          *table_info);
+
+/*
+ * tbinstall - Table installation
+ */
+
+acpi_status
+acpi_tb_install_table (
+	struct acpi_table_desc          *table_info);
+
+acpi_status
+acpi_tb_match_signature (
+	char                            *signature,
+	struct acpi_table_desc          *table_info,
+	u8                              search_type);
+
+acpi_status
+acpi_tb_recognize_table (
+	struct acpi_table_desc          *table_info,
+	u8                              search_type);
+
+acpi_status
+acpi_tb_init_table_descriptor (
+	acpi_table_type                 table_type,
+	struct acpi_table_desc          *table_info);
+
+
+/*
+ * tbremove - Table removal and deletion
+ */
+
+void
+acpi_tb_delete_all_tables (
+	void);
+
+void
+acpi_tb_delete_tables_by_type (
+	acpi_table_type                 type);
+
+void
+acpi_tb_delete_single_table (
+	struct acpi_table_desc          *table_desc);
+
+struct acpi_table_desc *
+acpi_tb_uninstall_table (
+	struct acpi_table_desc          *table_desc);
+
+
+/*
+ * tbrsd - RSDP, RSDT utilities
+ */
+
+acpi_status
+acpi_tb_get_table_rsdt (
+	void);
+
+u8 *
+acpi_tb_scan_memory_for_rsdp (
+	u8                              *start_address,
+	u32                             length);
+
+acpi_status
+acpi_tb_find_rsdp (
+	struct acpi_table_desc          *table_info,
+	u32                             flags);
+
+
+/*
+ * tbutils - common table utilities
+ */
+
+acpi_status
+acpi_tb_find_table (
+	char                            *signature,
+	char                            *oem_id,
+	char                            *oem_table_id,
+	struct acpi_table_header        **table_ptr);
+
+acpi_status
+acpi_tb_verify_table_checksum (
+	struct acpi_table_header        *table_header);
+
+u8
+acpi_tb_checksum (
+	void                            *buffer,
+	u32                             length);
+
+acpi_status
+acpi_tb_validate_table_header (
+	struct acpi_table_header        *table_header);
+
+
+#endif /* __ACTABLES_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/actbl.h linux-2.4.22-pre2/include/acpi/actbl.h
--- linux-2.4.21/include/acpi/actbl.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/actbl.h	2003-06-26 21:43:22.000000000 +0000
@@ -0,0 +1,235 @@
+/******************************************************************************
+ *
+ * Name: actbl.h - Table data structures defined in ACPI specification
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACTBL_H__
+#define __ACTBL_H__
+
+
+/*
+ *  Values for description table header signatures
+ */
+#define RSDP_NAME               "RSDP"
+#define RSDP_SIG                "RSD PTR "  /* RSDT Pointer signature */
+#define APIC_SIG                "APIC"      /* Multiple APIC Description Table */
+#define DSDT_SIG                "DSDT"      /* Differentiated System Description Table */
+#define FADT_SIG                "FACP"      /* Fixed ACPI Description Table */
+#define FACS_SIG                "FACS"      /* Firmware ACPI Control Structure */
+#define PSDT_SIG                "PSDT"      /* Persistent System Description Table */
+#define RSDT_SIG                "RSDT"      /* Root System Description Table */
+#define XSDT_SIG                "XSDT"      /* Extended  System Description Table */
+#define SSDT_SIG                "SSDT"      /* Secondary System Description Table */
+#define SBST_SIG                "SBST"      /* Smart Battery Specification Table */
+#define SPIC_SIG                "SPIC"      /* IOSAPIC table */
+#define BOOT_SIG                "BOOT"      /* Boot table */
+
+
+#define GL_OWNED                0x02        /* Ownership of global lock is bit 1 */
+
+/* values of Mapic.Model */
+
+#define DUAL_PIC                0
+#define MULTIPLE_APIC           1
+
+/* values of Type in struct apic_header */
+
+#define APIC_PROC               0
+#define APIC_IO                 1
+
+
+/*
+ * Common table types.  The base code can remain
+ * constant if the underlying tables are changed
+ */
+#define RSDT_DESCRIPTOR         struct rsdt_descriptor_rev2
+#define XSDT_DESCRIPTOR         struct xsdt_descriptor_rev2
+#define FACS_DESCRIPTOR         struct facs_descriptor_rev2
+#define FADT_DESCRIPTOR         struct fadt_descriptor_rev2
+
+
+#pragma pack(1)
+
+/*
+ * Architecture-independent tables
+ * The architecture dependent tables are in separate files
+ */
+struct rsdp_descriptor         /* Root System Descriptor Pointer */
+{
+	char                            signature [8];          /* ACPI signature, contains "RSD PTR " */
+	u8                              checksum;               /* To make sum of struct == 0 */
+	char                            oem_id [6];             /* OEM identification */
+	u8                              revision;               /* Must be 0 for 1.0, 2 for 2.0 */
+	u32                             rsdt_physical_address;  /* 32-bit physical address of RSDT */
+	u32                             length;                 /* XSDT Length in bytes including hdr */
+	u64                             xsdt_physical_address;  /* 64-bit physical address of XSDT */
+	u8                              extended_checksum;      /* Checksum of entire table */
+	char                            reserved [3];           /* Reserved field must be 0 */
+};
+
+
+struct acpi_table_header         /* ACPI common table header */
+{
+	char                            signature [4];          /* ACPI signature (4 ASCII characters) */
+	u32                             length;                 /* Length of table, in bytes, including header */
+	u8                              revision;               /* ACPI Specification minor version # */
+	u8                              checksum;               /* To make sum of entire table == 0 */
+	char                            oem_id [6];             /* OEM identification */
+	char                            oem_table_id [8];       /* OEM table identification */
+	u32                             oem_revision;           /* OEM revision number */
+	char                            asl_compiler_id [4];    /* ASL compiler vendor ID */
+	u32                             asl_compiler_revision;  /* ASL compiler revision number */
+};
+
+
+struct acpi_common_facs          /* Common FACS for internal use */
+{
+	u32                             *global_lock;
+	u64                             *firmware_waking_vector;
+	u8                              vector_width;
+};
+
+
+struct apic_table
+{
+	struct acpi_table_header        header;                 /* ACPI table header */
+	u32                             local_apic_address;     /* Physical address for accessing local APICs */
+	u32                             PCATcompat      : 1;    /* a one indicates system also has dual 8259s */
+	u32                             reserved1       : 31;
+};
+
+
+struct apic_header
+{
+	u8                              type;                   /* APIC type.  Either APIC_PROC or APIC_IO */
+	u8                              length;                 /* Length of APIC structure */
+};
+
+
+struct processor_apic
+{
+	struct apic_header              header;
+	u8                              processor_apic_id;      /* ACPI processor id */
+	u8                              local_apic_id;          /* Processor's local APIC id */
+	u32                             processor_enabled: 1;   /* Processor is usable if set */
+	u32                             reserved1       : 31;
+};
+
+
+struct io_apic
+{
+	struct apic_header              header;
+	u8                              io_apic_id;             /* I/O APIC ID */
+	u8                              reserved;               /* Reserved - must be zero */
+	u32                             io_apic_address;        /* APIC's physical address */
+	u32                             vector;                 /* Interrupt vector index where INTI
+			  * lines start */
+};
+
+
+/*
+ *  IA64 TBD:  Add SAPIC Tables
+ */
+
+/*
+ *  IA64 TBD:   Modify Smart Battery Description to comply with ACPI IA64
+ *              extensions.
+ */
+struct smart_battery_description_table
+{
+	struct acpi_table_header        header;
+	u32                             warning_level;
+	u32                             low_level;
+	u32                             critical_level;
+};
+
+struct hpet_description_table
+{
+	struct acpi_table_header        header;
+	u32                             hardware_id;
+	u32                             base_address[3];
+	u8                              hpet_number;
+	u16                             clock_tick;
+	u8                              attributes;
+};
+#pragma pack()
+
+
+/*
+ * ACPI Table information.  We save the table address, length,
+ * and type of memory allocation (mapped or allocated) for each
+ * table for 1) when we exit, and 2) if a new table is installed
+ */
+#define ACPI_MEM_NOT_ALLOCATED  0
+#define ACPI_MEM_ALLOCATED      1
+#define ACPI_MEM_MAPPED         2
+
+/* Definitions for the Flags bitfield member of struct acpi_table_support */
+
+#define ACPI_TABLE_SINGLE       0x00
+#define ACPI_TABLE_MULTIPLE     0x01
+#define ACPI_TABLE_EXECUTABLE   0x02
+
+#define ACPI_TABLE_ROOT         0x00
+#define ACPI_TABLE_PRIMARY      0x10
+#define ACPI_TABLE_SECONDARY    0x20
+#define ACPI_TABLE_ALL          0x30
+#define ACPI_TABLE_TYPE_MASK    0x30
+
+/* Data about each known table type */
+
+struct acpi_table_support
+{
+	char                            *name;
+	char                            *signature;
+	void                            **global_ptr;
+	u8                              sig_length;
+	u8                              flags;
+};
+
+
+/*
+ * Get the architecture-specific tables
+ */
+#include "actbl1.h"   /* Acpi 1.0 table definitions */
+#include "actbl2.h"   /* Acpi 2.0 table definitions */
+
+#endif /* __ACTBL_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/actbl1.h linux-2.4.22-pre2/include/acpi/actbl1.h
--- linux-2.4.21/include/acpi/actbl1.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/actbl1.h	2003-06-26 21:43:12.000000000 +0000
@@ -0,0 +1,136 @@
+/******************************************************************************
+ *
+ * Name: actbl1.h - ACPI 1.0 tables
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACTBL1_H__
+#define __ACTBL1_H__
+
+#pragma pack(1)
+
+/*
+ * ACPI 1.0 Root System Description Table (RSDT)
+ */
+struct rsdt_descriptor_rev1
+{
+	struct acpi_table_header        header;                 /* ACPI Table header */
+	u32                             table_offset_entry [1]; /* Array of pointers to other */
+			 /* ACPI tables */
+};
+
+
+/*
+ * ACPI 1.0 Firmware ACPI Control Structure (FACS)
+ */
+struct facs_descriptor_rev1
+{
+	char                            signature[4];           /* ACPI Signature */
+	u32                             length;                 /* Length of structure, in bytes */
+	u32                             hardware_signature;     /* Hardware configuration signature */
+	u32                             firmware_waking_vector; /* ACPI OS waking vector */
+	u32                             global_lock;            /* Global Lock */
+	u32                             S4bios_f        : 1;    /* Indicates if S4BIOS support is present */
+	u32                             reserved1       : 31;   /* Must be 0 */
+	u8                              resverved3 [40];        /* Reserved - must be zero */
+};
+
+
+/*
+ * ACPI 1.0 Fixed ACPI Description Table (FADT)
+ */
+struct fadt_descriptor_rev1
+{
+	struct acpi_table_header        header;                 /* ACPI Table header */
+	u32                             firmware_ctrl;          /* Physical address of FACS */
+	u32                             dsdt;                   /* Physical address of DSDT */
+	u8                              model;                  /* System Interrupt Model */
+	u8                              reserved1;              /* Reserved */
+	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                              reserved2;              /* Reserved - must be zero */
+	u32                             pm1a_evt_blk;           /* Port address of Power Mgt 1a acpi_event Reg Blk */
+	u32                             pm1b_evt_blk;           /* Port address of Power Mgt 1b acpi_event Reg Blk */
+	u32                             pm1a_cnt_blk;           /* Port address of Power Mgt 1a Control Reg Blk */
+	u32                             pm1b_cnt_blk;           /* Port address of Power Mgt 1b Control Reg Blk */
+	u32                             pm2_cnt_blk;            /* Port address of Power Mgt 2 Control Reg Blk */
+	u32                             pm_tmr_blk;             /* Port address of Power Mgt Timer Ctrl Reg Blk */
+	u32                             gpe0_blk;               /* Port addr of General Purpose acpi_event 0 Reg Blk */
+	u32                             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                              reserved3;              /* Reserved */
+	u16                             plvl2_lat;              /* Worst case HW latency to enter/exit C2 state */
+	u16                             plvl3_lat;              /* Worst case HW latency to enter/exit C3 state */
+	u16                             flush_size;             /* Size of area read to flush caches */
+	u16                             flush_stride;           /* Stride used in flushing caches */
+	u8                              duty_offset;            /* Bit location of duty cycle field in p_cnt reg */
+	u8                              duty_width;             /* Bit width of duty cycle field in p_cnt reg */
+	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 */
+	u8                              reserved4;              /* Reserved */
+	u8                              reserved4a;             /* Reserved */
+	u8                              reserved4b;             /* Reserved */
+	u32                             wb_invd         : 1;    /* The wbinvd instruction works properly */
+	u32                             wb_invd_flush   : 1;    /* The wbinvd flushes but does not invalidate */
+	u32                             proc_c1         : 1;    /* All processors support C1 state */
+	u32                             plvl2_up        : 1;    /* C2 state works on MP system */
+	u32                             pwr_button      : 1;    /* Power button is handled as a generic feature */
+	u32                             sleep_button    : 1;    /* Sleep button is handled as a generic feature, or not present */
+	u32                             fixed_rTC       : 1;    /* RTC wakeup stat not in fixed register space */
+	u32                             rtcs4           : 1;    /* RTC wakeup stat not possible from S4 */
+	u32                             tmr_val_ext     : 1;    /* The tmr_val width is 32 bits (0 = 24 bits) */
+	u32                             reserved5       : 23;   /* Reserved - must be zero */
+};
+
+#pragma pack()
+
+#endif /* __ACTBL1_H__ */
+
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/actbl2.h linux-2.4.22-pre2/include/acpi/actbl2.h
--- linux-2.4.21/include/acpi/actbl2.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/actbl2.h	2003-06-26 21:43:28.000000000 +0000
@@ -0,0 +1,201 @@
+/******************************************************************************
+ *
+ * Name: actbl2.h - ACPI Specification Revision 2.0 Tables
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACTBL2_H__
+#define __ACTBL2_H__
+
+/*
+ * Prefered Power Management Profiles
+ */
+#define PM_UNSPECIFIED                  0
+#define PM_DESKTOP                      1
+#define PM_MOBILE                       2
+#define PM_WORKSTATION                  3
+#define PM_ENTERPRISE_SERVER            4
+#define PM_SOHO_SERVER                  5
+#define PM_APPLIANCE_PC                 6
+
+/*
+ * ACPI Boot Arch Flags
+ */
+#define BAF_LEGACY_DEVICES              0x0001
+#define BAF_8042_KEYBOARD_CONTROLLER    0x0002
+
+#define FADT2_REVISION_ID               3
+
+
+#pragma pack(1)
+
+/*
+ * ACPI 2.0 Root System Description Table (RSDT)
+ */
+struct rsdt_descriptor_rev2
+{
+	struct acpi_table_header        header;                 /* ACPI table header */
+	u32                             table_offset_entry [1]; /* Array of pointers to  */
+			 /* ACPI table headers */
+};
+
+
+/*
+ * ACPI 2.0 Extended System Description Table (XSDT)
+ */
+struct xsdt_descriptor_rev2
+{
+	struct acpi_table_header        header;                 /* ACPI table header */
+	u64                             table_offset_entry [1]; /* Array of pointers to  */
+			 /* ACPI table headers */
+};
+
+
+/*
+ * ACPI 2.0 Firmware ACPI Control Structure (FACS)
+ */
+struct facs_descriptor_rev2
+{
+	char                            signature[4];           /* ACPI signature */
+	u32                             length;                 /* Length of structure, in bytes */
+	u32                             hardware_signature;     /* Hardware configuration signature */
+	u32                             firmware_waking_vector; /* 32bit physical address of the Firmware Waking Vector. */
+	u32                             global_lock;            /* Global Lock used to synchronize access to shared hardware resources */
+	u32                             S4bios_f        : 1;    /* S4Bios_f - Indicates if S4BIOS support is present */
+	u32                             reserved1       : 31;   /* Must be 0 */
+	u64                             xfirmware_waking_vector; /* 64bit physical address of the Firmware Waking Vector. */
+	u8                              version;                /* Version of this table */
+	u8                              reserved3 [31];         /* Reserved - must be zero */
+};
+
+
+/*
+ * ACPI 2.0 Generic Address Structure (GAS)
+ */
+struct acpi_generic_address
+{
+	u8                              address_space_id;       /* Address space where struct or register exists. */
+	u8                              register_bit_width;     /* Size in bits of given register */
+	u8                              register_bit_offset;    /* Bit offset within the register */
+	u8                              reserved;               /* Must be 0 */
+	u64                             address;                /* 64-bit address of struct or register */
+};
+
+
+/*
+ * ACPI 2.0 Fixed ACPI Description Table (FADT)
+ */
+struct fadt_descriptor_rev2
+{
+	struct acpi_table_header        header;             /* ACPI 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*/
+	u8                              reserved2;          /* Reserved */
+	u32                             wb_invd     : 1;    /* The wbinvd instruction works properly */
+	u32                             wb_invd_flush : 1;  /* The wbinvd flushes but does not invalidate */
+	u32                             proc_c1     : 1;    /* All processors support C1 state */
+	u32                             plvl2_up    : 1;    /* C2 state works on MP system */
+	u32                             pwr_button  : 1;    /* Power button is handled as a generic feature */
+	u32                             sleep_button : 1;   /* Sleep button is handled as a generic feature, or not present */
+	u32                             fixed_rTC   : 1;    /* RTC wakeup stat not in fixed register space */
+	u32                             rtcs4       : 1;    /* RTC wakeup stat not possible from S4 */
+	u32                             tmr_val_ext : 1;    /* Indicates tmr_val is 32 bits 0=24-bits*/
+	u32                             dock_cap    : 1;    /* Supports Docking */
+	u32                             reset_reg_sup : 1;  /* Indicates system supports system reset via the FADT RESET_REG*/
+	u32                             sealed_case : 1;    /* Indicates system has no internal expansion capabilities and case is sealed. */
+	u32                             headless    : 1;    /* Indicates system does not have local video capabilities or local input devices.*/
+	u32                             cpu_sw_sleep : 1;   /* Indicates to OSPM that a processor native instruction */
+			   /* Must be executed after writing the SLP_TYPx register. */
+	u32                             reserved6   : 18;   /* Reserved - must be zero */
+
+	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 */
+	u64                             xfirmware_ctrl;     /* 64-bit physical address of FACS */
+	u64                             Xdsdt;              /* 64-bit physical address of DSDT */
+	struct acpi_generic_address     xpm1a_evt_blk;      /* Extended Power Mgt 1a acpi_event Reg Blk address */
+	struct acpi_generic_address     xpm1b_evt_blk;      /* Extended Power Mgt 1b acpi_event Reg Blk address */
+	struct acpi_generic_address     xpm1a_cnt_blk;      /* Extended Power Mgt 1a Control Reg Blk address */
+	struct acpi_generic_address     xpm1b_cnt_blk;      /* Extended Power Mgt 1b Control Reg Blk address */
+	struct acpi_generic_address     xpm2_cnt_blk;       /* Extended Power Mgt 2 Control Reg Blk address */
+	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 */
+};
+
+
+#pragma pack()
+
+#endif /* __ACTBL2_H__ */
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/actbl71.h linux-2.4.22-pre2/include/acpi/actbl71.h
--- linux-2.4.21/include/acpi/actbl71.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/actbl71.h	2003-06-26 21:43:20.000000000 +0000
@@ -0,0 +1,144 @@
+/******************************************************************************
+ *
+ * Name: actbl71.h - IA-64 Extensions to the ACPI Spec Rev. 0.71
+ *                   This file includes tables specific to this
+ *                   specification revision.
+ *
+ *****************************************************************************/
+
+/*
+ *  Copyright (C) 2000 - 2003, R. Byron Moore
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __ACTBL71_H__
+#define __ACTBL71_H__
+
+
+/* 0.71 FADT address_space data item bitmasks defines */
+/* If the associated bit is zero then it is in memory space else in io space */
+
+#define SMI_CMD_ADDRESS_SPACE       0x01
+#define PM1_BLK_ADDRESS_SPACE       0x02
+#define PM2_CNT_BLK_ADDRESS_SPACE   0x04
+#define PM_TMR_BLK_ADDRESS_SPACE    0x08
+#define GPE0_BLK_ADDRESS_SPACE      0x10
+#define GPE1_BLK_ADDRESS_SPACE      0x20
+
+/* Only for clarity in declarations */
+
+typedef u64                         IO_ADDRESS;
+
+
+#pragma pack(1)
+struct  /* Root System Descriptor Pointer */
+{
+	NATIVE_CHAR             signature [8];          /* contains "RSD PTR " */
+	u8                              checksum;               /* to make sum of struct == 0 */
+	NATIVE_CHAR             oem_id [6];             /* OEM identification */
+	u8                              reserved;               /* Must be 0 for 1.0, 2 for 2.0 */
+	u64                             rsdt_physical_address;  /* 64-bit physical address of RSDT */
+};
+
+
+/*****************************************/
+/* IA64 Extensions to ACPI Spec Rev 0.71 */
+/* for the Root System Description Table */
+/*****************************************/
+struct
+{
+	struct acpi_table_header    header;                 /* Table header */
+	u32                         reserved_pad;           /* IA64 alignment, must be 0 */
+	u64                         table_offset_entry [1]; /* Array of pointers to other */
+			   /* tables' headers */
+};
+
+
+/*******************************************/
+/* IA64 Extensions to ACPI Spec Rev 0.71   */
+/* for the Firmware ACPI Control Structure */
+/*******************************************/
+struct
+{
+	NATIVE_CHAR         signature[4];         /* signature "FACS" */
+	u32                         length;               /* length of structure, in bytes */
+	u32                         hardware_signature;   /* hardware configuration signature */
+	u32                         reserved4;            /* must be 0 */
+	u64                         firmware_waking_vector; /* ACPI OS waking vector */
+	u64                         global_lock;          /* Global Lock */
+	u32                         S4bios_f      : 1;    /* Indicates if S4BIOS support is present */
+	u32                         reserved1     : 31;   /* must be 0 */
+	u8                          reserved3 [28];       /* reserved - must be zero */
+};
+
+
+/******************************************/
+/* IA64 Extensions to ACPI Spec Rev 0.71  */
+/* for the Fixed ACPI Description Table   */
+/******************************************/
+struct
+{
+	struct acpi_table_header    header;             /* table header */
+	u32                         reserved_pad;       /* IA64 alignment, must be 0 */
+	u64                         firmware_ctrl;      /* 64-bit Physical address of FACS */
+	u64                         dsdt;               /* 64-bit Physical address of DSDT */
+	u8                          model;              /* System Interrupt Model */
+	u8                          address_space;      /* Address Space Bitmask */
+	u16                         sci_int;            /* System vector of SCI interrupt */
+	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                          reserved2;          /* reserved - must be zero */
+	u64                         smi_cmd;            /* Port address of SMI command port */
+	u64                         pm1a_evt_blk;       /* Port address of Power Mgt 1a acpi_event Reg Blk */
+	u64                         pm1b_evt_blk;       /* Port address of Power Mgt 1b acpi_event Reg Blk */
+	u64                         pm1a_cnt_blk;       /* Port address of Power Mgt 1a Control Reg Blk */
+	u64                         pm1b_cnt_blk;       /* Port address of Power Mgt 1b Control Reg Blk */
+	u64                         pm2_cnt_blk;        /* Port address of Power Mgt 2 Control Reg Blk */
+	u64                         pm_tmr_blk;         /* Port address of Power Mgt Timer Ctrl Reg Blk */
+	u64                         gpe0_blk;           /* Port addr of General Purpose acpi_event 0 Reg Blk */
+	u64                         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                          reserved3;          /* reserved */
+	u16                         plvl2_lat;          /* worst case HW latency to enter/exit C2 state */
+	u16                         plvl3_lat;          /* worst case HW latency to enter/exit C3 state */
+	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 */
+	u8                          reserved4;          /* reserved */
+	u32                         flush_cash  : 1;    /* PAL_FLUSH_CACHE is correctly supported */
+	u32                         reserved5   : 1;    /* reserved - must be zero */
+	u32                         proc_c1     : 1;    /* all processors support C1 state */
+	u32                         plvl2_up    : 1;    /* C2 state works on MP system */
+	u32                         pwr_button  : 1;    /* Power button is handled as a generic feature */
+	u32                         sleep_button : 1;   /* Sleep button is handled as a generic feature, or not present */
+	u32                         fixed_rTC   : 1;    /* RTC wakeup stat not in fixed register space */
+	u32                         rtcs4       : 1;    /* RTC wakeup stat not possible from S4 */
+	u32                         tmr_val_ext : 1;    /* tmr_val is 32 bits */
+	u32                         dock_cap    : 1;    /* Supports Docking */
+	u32                         reserved6   : 22;    /* reserved - must be zero */
+};
+
+#pragma pack()
+
+#endif /* __ACTBL71_H__ */
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/actypes.h linux-2.4.22-pre2/include/acpi/actypes.h
--- linux-2.4.21/include/acpi/actypes.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/actypes.h	2003-06-26 21:43:28.000000000 +0000
@@ -0,0 +1,1247 @@
+/******************************************************************************
+ *
+ * Name: actypes.h - Common data types for the entire ACPI subsystem
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACTYPES_H__
+#define __ACTYPES_H__
+
+/*! [Begin] no source code translation (keep the typedefs) */
+
+
+
+/*
+ * Data type ranges
+ * Note: These macros are designed to be compiler independent as well as
+ * working around problems that some 32-bit compilers have with 64-bit
+ * constants.
+ */
+#define ACPI_UINT8_MAX                  (UINT8) (~((UINT8)  0)) /* 0xFF               */
+#define ACPI_UINT16_MAX                 (UINT16)(~((UINT16) 0)) /* 0xFFFF             */
+#define ACPI_UINT32_MAX                 (UINT32)(~((UINT32) 0)) /* 0xFFFFFFFF         */
+#define ACPI_UINT64_MAX                 (UINT64)(~((UINT64) 0)) /* 0xFFFFFFFFFFFFFFFF */
+#define ACPI_ASCII_MAX                  0x7F
+
+
+#ifdef DEFINE_ALTERNATE_TYPES
+/*
+ * Types used only in translated source, defined here to enable
+ * cross-platform compilation only.
+ */
+typedef int                             s32;
+typedef unsigned char                   u8;
+typedef unsigned short                  u16;
+typedef unsigned int                    u32;
+typedef COMPILER_DEPENDENT_UINT64       u64;
+
+#endif
+
+
+/*
+ * Data types - Fixed across all compilation models (16/32/64)
+ *
+ * BOOLEAN          Logical Boolean.
+ * INT8             8-bit  (1 byte) signed value
+ * UINT8            8-bit  (1 byte) unsigned value
+ * INT16            16-bit (2 byte) signed value
+ * UINT16           16-bit (2 byte) unsigned value
+ * INT32            32-bit (4 byte) signed value
+ * UINT32           32-bit (4 byte) unsigned value
+ * INT64            64-bit (8 byte) signed value
+ * UINT64           64-bit (8 byte) unsigned value
+ * ACPI_NATIVE_INT  32-bit on IA-32, 64-bit on IA-64 signed value
+ * ACPI_NATIVE_UINT 32-bit on IA-32, 64-bit on IA-64 unsigned value
+ */
+
+#ifndef ACPI_MACHINE_WIDTH
+#error ACPI_MACHINE_WIDTH not defined
+#endif
+
+#if ACPI_MACHINE_WIDTH == 64
+
+/*! [Begin] no source code translation (keep the typedefs) */
+
+/*
+ * 64-bit type definitions
+ */
+typedef unsigned char                   UINT8;
+typedef unsigned char                   BOOLEAN;
+typedef unsigned short                  UINT16;
+typedef int                             INT32;
+typedef unsigned int                    UINT32;
+typedef COMPILER_DEPENDENT_INT64        INT64;
+typedef COMPILER_DEPENDENT_UINT64       UINT64;
+
+/*! [End] no source code translation !*/
+
+typedef s64                                     acpi_native_int;
+typedef u64                                     acpi_native_uint;
+
+typedef u64                                     acpi_table_ptr;
+typedef u64                                     acpi_io_address;
+typedef u64                                     acpi_physical_address;
+typedef u64                                     acpi_size;
+
+#define ALIGNED_ADDRESS_BOUNDARY        0x00000008      /* No hardware alignment support in IA64 */
+#define ACPI_USE_NATIVE_DIVIDE                          /* Native 64-bit integer support */
+#define ACPI_MAX_PTR                    ACPI_UINT64_MAX
+#define ACPI_SIZE_MAX                   ACPI_UINT64_MAX
+
+
+#elif ACPI_MACHINE_WIDTH == 16
+
+/*! [Begin] no source code translation (keep the typedefs) */
+
+/*
+ * 16-bit type definitions
+ */
+typedef unsigned char                   UINT8;
+typedef unsigned char                   BOOLEAN;
+typedef unsigned int                    UINT16;
+typedef long                            INT32;
+typedef int                             INT16;
+typedef unsigned long                   UINT32;
+
+struct
+{
+	UINT32                                  Lo;
+	UINT32                                  Hi;
+};
+
+/*! [End] no source code translation !*/
+
+typedef u16                                     acpi_native_uint;
+typedef s16                                     acpi_native_int;
+
+typedef u32                                     acpi_table_ptr;
+typedef u32                                     acpi_io_address;
+typedef char                                    *acpi_physical_address;
+typedef u16                                     acpi_size;
+
+#define ALIGNED_ADDRESS_BOUNDARY        0x00000002
+#define ACPI_MISALIGNED_TRANSFERS
+#define ACPI_USE_NATIVE_DIVIDE                          /* No 64-bit integers, ok to use native divide */
+#define ACPI_MAX_PTR                    ACPI_UINT16_MAX
+#define ACPI_SIZE_MAX                   ACPI_UINT16_MAX
+
+/*
+ * (16-bit only) internal integers must be 32-bits, so
+ * 64-bit integers cannot be supported
+ */
+#define ACPI_NO_INTEGER64_SUPPORT
+
+
+#elif ACPI_MACHINE_WIDTH == 32
+
+/*! [Begin] no source code translation (keep the typedefs) */
+
+/*
+ * 32-bit type definitions (default)
+ */
+typedef unsigned char                   UINT8;
+typedef unsigned char                   BOOLEAN;
+typedef unsigned short                  UINT16;
+typedef int                             INT32;
+typedef unsigned int                    UINT32;
+typedef COMPILER_DEPENDENT_INT64        INT64;
+typedef COMPILER_DEPENDENT_UINT64       UINT64;
+
+/*! [End] no source code translation !*/
+
+typedef s32                                     acpi_native_int;
+typedef u32                                     acpi_native_uint;
+
+typedef u64                                     acpi_table_ptr;
+typedef u32                                     acpi_io_address;
+typedef u64                                     acpi_physical_address;
+typedef u32                                     acpi_size;
+
+#define ALIGNED_ADDRESS_BOUNDARY        0x00000004
+#define ACPI_MISALIGNED_TRANSFERS
+#define ACPI_MAX_PTR                    ACPI_UINT32_MAX
+#define ACPI_SIZE_MAX                   ACPI_UINT32_MAX
+
+#else
+#error unknown ACPI_MACHINE_WIDTH
+#endif
+
+
+/*
+ * Miscellaneous common types
+ */
+typedef u32                                     UINT32_BIT;
+typedef acpi_native_uint                        ACPI_PTRDIFF;
+
+/*
+ * Pointer overlays to avoid lots of typecasting for
+ * code that accepts both physical and logical pointers.
+ */
+union acpi_pointers
+{
+	acpi_physical_address               physical;
+	void                                *logical;
+	acpi_table_ptr                      value;
+};
+
+struct acpi_pointer
+{
+	u32                                 pointer_type;
+	union acpi_pointers                 pointer;
+};
+
+/* pointer_types for above */
+
+#define ACPI_PHYSICAL_POINTER           0x01
+#define ACPI_LOGICAL_POINTER            0x02
+
+/* Processor mode */
+
+#define ACPI_PHYSICAL_ADDRESSING        0x04
+#define ACPI_LOGICAL_ADDRESSING         0x08
+#define ACPI_MEMORY_MODE                0x0C
+
+#define ACPI_PHYSMODE_PHYSPTR           ACPI_PHYSICAL_ADDRESSING | ACPI_PHYSICAL_POINTER
+#define ACPI_LOGMODE_PHYSPTR            ACPI_LOGICAL_ADDRESSING  | ACPI_PHYSICAL_POINTER
+#define ACPI_LOGMODE_LOGPTR             ACPI_LOGICAL_ADDRESSING  | ACPI_LOGICAL_POINTER
+
+
+/*
+ * Useful defines
+ */
+#ifdef FALSE
+#undef FALSE
+#endif
+#define FALSE                           (1 == 0)
+
+#ifdef TRUE
+#undef TRUE
+#endif
+#define TRUE                            (1 == 1)
+
+#ifndef NULL
+#define NULL                            (void *) 0
+#endif
+
+
+/*
+ * Local datatypes
+ */
+typedef u32                                     acpi_status;    /* All ACPI Exceptions */
+typedef u32                                     acpi_name;      /* 4-byte ACPI name */
+typedef char *                                  acpi_string;    /* Null terminated ASCII string */
+typedef void *                                  acpi_handle;    /* Actually a ptr to an Node */
+
+struct uint64_struct
+{
+	u32                                 lo;
+	u32                                 hi;
+};
+
+union uint64_overlay
+{
+	u64                                 full;
+	struct uint64_struct                part;
+};
+
+struct uint32_struct
+{
+	u32                                 lo;
+	u32                                 hi;
+};
+
+
+/*
+ * Acpi integer width. In ACPI version 1, integers are
+ * 32 bits.  In ACPI version 2, integers are 64 bits.
+ * Note that this pertains to the ACPI integer type only, not
+ * other integers used in the implementation of the ACPI CA
+ * subsystem.
+ */
+#ifdef ACPI_NO_INTEGER64_SUPPORT
+
+/* 32-bit integers only, no 64-bit support */
+
+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_USE_NATIVE_DIVIDE          /* Use compiler native 32-bit divide */
+
+
+#else
+
+/* 64-bit integers */
+
+typedef u64                                     acpi_integer;
+#define ACPI_INTEGER_MAX                ACPI_UINT64_MAX
+#define ACPI_INTEGER_BIT_SIZE           64
+#define ACPI_MAX_DECIMAL_DIGITS         19
+
+#if ACPI_MACHINE_WIDTH == 64
+#define ACPI_USE_NATIVE_DIVIDE          /* Use compiler native 64-bit divide */
+#endif
+#endif
+
+
+/*
+ * Constants with special meanings
+ */
+#define ACPI_ROOT_OBJECT                (acpi_handle) ACPI_PTR_ADD (char, NULL, ACPI_MAX_PTR)
+
+
+/*
+ * Initialization sequence
+ */
+#define ACPI_FULL_INITIALIZATION        0x00
+#define ACPI_NO_ADDRESS_SPACE_INIT      0x01
+#define ACPI_NO_HARDWARE_INIT           0x02
+#define ACPI_NO_EVENT_INIT              0x04
+#define ACPI_NO_HANDLER_INIT            0x08
+#define ACPI_NO_ACPI_ENABLE             0x10
+#define ACPI_NO_DEVICE_INIT             0x20
+#define ACPI_NO_OBJECT_INIT             0x40
+
+/*
+ * Initialization state
+ */
+#define ACPI_INITIALIZED_OK             0x01
+
+/*
+ * Power state values
+ */
+
+#define ACPI_STATE_UNKNOWN              (u8) 0xFF
+
+#define ACPI_STATE_S0                   (u8) 0
+#define ACPI_STATE_S1                   (u8) 1
+#define ACPI_STATE_S2                   (u8) 2
+#define ACPI_STATE_S3                   (u8) 3
+#define ACPI_STATE_S4                   (u8) 4
+#define ACPI_STATE_S5                   (u8) 5
+#define ACPI_S_STATES_MAX               ACPI_STATE_S5
+#define ACPI_S_STATE_COUNT              6
+
+#define ACPI_STATE_D0                   (u8) 0
+#define ACPI_STATE_D1                   (u8) 1
+#define ACPI_STATE_D2                   (u8) 2
+#define ACPI_STATE_D3                   (u8) 3
+#define ACPI_D_STATES_MAX               ACPI_STATE_D3
+#define ACPI_D_STATE_COUNT              4
+
+#define ACPI_STATE_C0                   (u8) 0
+#define ACPI_STATE_C1                   (u8) 1
+#define ACPI_STATE_C2                   (u8) 2
+#define ACPI_STATE_C3                   (u8) 3
+#define ACPI_C_STATES_MAX               ACPI_STATE_C3
+#define ACPI_C_STATE_COUNT              4
+
+/*
+ * Sleep type invalid value
+ */
+#define ACPI_SLEEP_TYPE_MAX             0x7
+#define ACPI_SLEEP_TYPE_INVALID         0xFF
+
+/*
+ * Standard notify values
+ */
+#define ACPI_NOTIFY_BUS_CHECK           (u8) 0
+#define ACPI_NOTIFY_DEVICE_CHECK        (u8) 1
+#define ACPI_NOTIFY_DEVICE_WAKE         (u8) 2
+#define ACPI_NOTIFY_EJECT_REQUEST       (u8) 3
+#define ACPI_NOTIFY_DEVICE_CHECK_LIGHT  (u8) 4
+#define ACPI_NOTIFY_FREQUENCY_MISMATCH  (u8) 5
+#define ACPI_NOTIFY_BUS_MODE_MISMATCH   (u8) 6
+#define ACPI_NOTIFY_POWER_FAULT         (u8) 7
+
+
+/*
+ *  Table types.  These values are passed to the table related APIs
+ */
+typedef u32                                     acpi_table_type;
+
+#define ACPI_TABLE_RSDP                 (acpi_table_type) 0
+#define ACPI_TABLE_DSDT                 (acpi_table_type) 1
+#define ACPI_TABLE_FADT                 (acpi_table_type) 2
+#define ACPI_TABLE_FACS                 (acpi_table_type) 3
+#define ACPI_TABLE_PSDT                 (acpi_table_type) 4
+#define ACPI_TABLE_SSDT                 (acpi_table_type) 5
+#define ACPI_TABLE_XSDT                 (acpi_table_type) 6
+#define ACPI_TABLE_MAX                  6
+#define NUM_ACPI_TABLE_TYPES            (ACPI_TABLE_MAX+1)
+
+
+/*
+ * Types associated with ACPI names and objects.  The first group of
+ * values (up to ACPI_TYPE_EXTERNAL_MAX) correspond to the definition
+ * of the ACPI object_type() operator (See the ACPI Spec). Therefore,
+ * only add to the first group if the spec changes.
+ *
+ * Types must be kept in sync with the global acpi_ns_properties
+ * and acpi_ns_type_names arrays.
+ */
+typedef u32                                     acpi_object_type;
+
+#define ACPI_TYPE_ANY                   0x00
+#define ACPI_TYPE_INTEGER               0x01  /* Byte/Word/Dword/Zero/One/Ones */
+#define ACPI_TYPE_STRING                0x02
+#define ACPI_TYPE_BUFFER                0x03
+#define ACPI_TYPE_PACKAGE               0x04  /* byte_const, multiple data_term/Constant/super_name */
+#define ACPI_TYPE_FIELD_UNIT            0x05
+#define ACPI_TYPE_DEVICE                0x06  /* Name, multiple Node */
+#define ACPI_TYPE_EVENT                 0x07
+#define ACPI_TYPE_METHOD                0x08  /* Name, byte_const, multiple Code */
+#define ACPI_TYPE_MUTEX                 0x09
+#define ACPI_TYPE_REGION                0x0A
+#define ACPI_TYPE_POWER                 0x0B  /* Name,byte_const,word_const,multi Node */
+#define ACPI_TYPE_PROCESSOR             0x0C  /* Name,byte_const,Dword_const,byte_const,multi nm_o */
+#define ACPI_TYPE_THERMAL               0x0D  /* Name, multiple Node */
+#define ACPI_TYPE_BUFFER_FIELD          0x0E
+#define ACPI_TYPE_DDB_HANDLE            0x0F
+#define ACPI_TYPE_DEBUG_OBJECT          0x10
+
+#define ACPI_TYPE_EXTERNAL_MAX          0x10
+
+/*
+ * These are object types that do not map directly to the ACPI
+ * object_type() operator. They are used for various internal purposes only.
+ * If new predefined ACPI_TYPEs are added (via the ACPI specification), these
+ * internal types must move upwards. (There is code that depends on these
+ * values being contiguous with the external types above.)
+ */
+#define ACPI_TYPE_LOCAL_REGION_FIELD    0x11
+#define ACPI_TYPE_LOCAL_BANK_FIELD      0x12
+#define ACPI_TYPE_LOCAL_INDEX_FIELD     0x13
+#define ACPI_TYPE_LOCAL_REFERENCE       0x14  /* Arg#, Local#, Name, Debug, ref_of, Index */
+#define ACPI_TYPE_LOCAL_ALIAS           0x15
+#define ACPI_TYPE_LOCAL_NOTIFY          0x16
+#define ACPI_TYPE_LOCAL_ADDRESS_HANDLER 0x17
+#define ACPI_TYPE_LOCAL_RESOURCE        0x18
+#define ACPI_TYPE_LOCAL_RESOURCE_FIELD  0x19
+#define ACPI_TYPE_LOCAL_SCOPE           0x1A  /* 1 Name, multiple object_list Nodes */
+
+#define ACPI_TYPE_NS_NODE_MAX           0x1A  /* Last typecode used within a NS Node */
+
+/*
+ * These are special object types that never appear in
+ * a Namespace node, only in an union acpi_operand_object
+ */
+#define ACPI_TYPE_LOCAL_EXTRA           0x1B
+#define ACPI_TYPE_LOCAL_DATA            0x1C
+
+#define ACPI_TYPE_LOCAL_MAX             0x1C
+
+/* All types above here are invalid */
+
+#define ACPI_TYPE_INVALID               0x1D
+#define ACPI_TYPE_NOT_FOUND             0xFF
+
+
+/*
+ * Bitmapped ACPI types.  Used internally only
+ */
+#define ACPI_BTYPE_ANY                  0x00000000
+#define ACPI_BTYPE_INTEGER              0x00000001
+#define ACPI_BTYPE_STRING               0x00000002
+#define ACPI_BTYPE_BUFFER               0x00000004
+#define ACPI_BTYPE_PACKAGE              0x00000008
+#define ACPI_BTYPE_FIELD_UNIT           0x00000010
+#define ACPI_BTYPE_DEVICE               0x00000020
+#define ACPI_BTYPE_EVENT                0x00000040
+#define ACPI_BTYPE_METHOD               0x00000080
+#define ACPI_BTYPE_MUTEX                0x00000100
+#define ACPI_BTYPE_REGION               0x00000200
+#define ACPI_BTYPE_POWER                0x00000400
+#define ACPI_BTYPE_PROCESSOR            0x00000800
+#define ACPI_BTYPE_THERMAL              0x00001000
+#define ACPI_BTYPE_BUFFER_FIELD         0x00002000
+#define ACPI_BTYPE_DDB_HANDLE           0x00004000
+#define ACPI_BTYPE_DEBUG_OBJECT         0x00008000
+#define ACPI_BTYPE_REFERENCE            0x00010000
+#define ACPI_BTYPE_RESOURCE             0x00020000
+
+#define ACPI_BTYPE_COMPUTE_DATA         (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER)
+
+#define ACPI_BTYPE_DATA                 (ACPI_BTYPE_COMPUTE_DATA  | ACPI_BTYPE_PACKAGE)
+#define ACPI_BTYPE_DATA_REFERENCE       (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE)
+#define ACPI_BTYPE_DEVICE_OBJECTS       (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR)
+#define ACPI_BTYPE_OBJECTS_AND_REFS     0x0001FFFF  /* ARG or LOCAL */
+#define ACPI_BTYPE_ALL_OBJECTS          0x0000FFFF
+
+/*
+ * All I/O
+ */
+#define ACPI_READ                       0
+#define ACPI_WRITE                      1
+#define ACPI_IO_MASK                    1
+
+
+/*
+ * Acpi Event Types: Fixed & General Purpose
+ */
+typedef u32                                     acpi_event_type;
+
+/*
+ * Fixed events
+ */
+#define ACPI_EVENT_PMTIMER              0
+#define ACPI_EVENT_GLOBAL               1
+#define ACPI_EVENT_POWER_BUTTON         2
+#define ACPI_EVENT_SLEEP_BUTTON         3
+#define ACPI_EVENT_RTC                  4
+#define ACPI_EVENT_MAX                  4
+#define ACPI_NUM_FIXED_EVENTS           ACPI_EVENT_MAX + 1
+
+#define ACPI_GPE_INVALID                0xFF
+#define ACPI_GPE_MAX                    0xFF
+#define ACPI_NUM_GPE                    256
+
+#define ACPI_EVENT_LEVEL_TRIGGERED      1
+#define ACPI_EVENT_EDGE_TRIGGERED       2
+
+/*
+ * Flags for GPE and Lock interfaces
+ */
+#define ACPI_EVENT_WAKE_ENABLE          0x2
+#define ACPI_EVENT_WAKE_DISABLE         0x2
+
+#define ACPI_NOT_ISR                    0x1
+#define ACPI_ISR                        0x0
+
+
+/*
+ * acpi_event Status:
+ * -------------
+ * The encoding of acpi_event_status is illustrated below.
+ * Note that a set bit (1) indicates the property is TRUE
+ * (e.g. if bit 0 is set then the event is enabled).
+ * +-------------+-+-+-+
+ * |   Bits 31:3 |2|1|0|
+ * +-------------+-+-+-+
+ *          |     | | |
+ *          |     | | +- Enabled?
+ *          |     | +--- Enabled for wake?
+ *          |     +----- Set?
+ *          +----------- <Reserved>
+ */
+typedef u32                                     acpi_event_status;
+
+#define ACPI_EVENT_FLAG_DISABLED        (acpi_event_status) 0x00
+#define ACPI_EVENT_FLAG_ENABLED         (acpi_event_status) 0x01
+#define ACPI_EVENT_FLAG_WAKE_ENABLED    (acpi_event_status) 0x02
+#define ACPI_EVENT_FLAG_SET             (acpi_event_status) 0x04
+
+
+/* Notify types */
+
+#define ACPI_SYSTEM_NOTIFY              0
+#define ACPI_DEVICE_NOTIFY              1
+#define ACPI_MAX_NOTIFY_HANDLER_TYPE    1
+
+#define ACPI_MAX_SYS_NOTIFY             0x7f
+
+
+/* Address Space (Operation Region) Types */
+
+typedef u8                                      acpi_adr_space_type;
+
+#define ACPI_ADR_SPACE_SYSTEM_MEMORY    (acpi_adr_space_type) 0
+#define ACPI_ADR_SPACE_SYSTEM_IO        (acpi_adr_space_type) 1
+#define ACPI_ADR_SPACE_PCI_CONFIG       (acpi_adr_space_type) 2
+#define ACPI_ADR_SPACE_EC               (acpi_adr_space_type) 3
+#define ACPI_ADR_SPACE_SMBUS            (acpi_adr_space_type) 4
+#define ACPI_ADR_SPACE_CMOS             (acpi_adr_space_type) 5
+#define ACPI_ADR_SPACE_PCI_BAR_TARGET   (acpi_adr_space_type) 6
+#define ACPI_ADR_SPACE_DATA_TABLE       (acpi_adr_space_type) 7
+#define ACPI_ADR_SPACE_FIXED_HARDWARE   (acpi_adr_space_type) 127
+
+
+/*
+ * bit_register IDs
+ * These are bitfields defined within the full ACPI registers
+ */
+#define ACPI_BITREG_TIMER_STATUS                0x00
+#define ACPI_BITREG_BUS_MASTER_STATUS           0x01
+#define ACPI_BITREG_GLOBAL_LOCK_STATUS          0x02
+#define ACPI_BITREG_POWER_BUTTON_STATUS         0x03
+#define ACPI_BITREG_SLEEP_BUTTON_STATUS         0x04
+#define ACPI_BITREG_RT_CLOCK_STATUS             0x05
+#define ACPI_BITREG_WAKE_STATUS                 0x06
+
+#define ACPI_BITREG_TIMER_ENABLE                0x07
+#define ACPI_BITREG_GLOBAL_LOCK_ENABLE          0x08
+#define ACPI_BITREG_POWER_BUTTON_ENABLE         0x09
+#define ACPI_BITREG_SLEEP_BUTTON_ENABLE         0x0A
+#define ACPI_BITREG_RT_CLOCK_ENABLE             0x0B
+#define ACPI_BITREG_WAKE_ENABLE                 0x0C
+
+#define ACPI_BITREG_SCI_ENABLE                  0x0D
+#define ACPI_BITREG_BUS_MASTER_RLD              0x0E
+#define ACPI_BITREG_GLOBAL_LOCK_RELEASE         0x0F
+#define ACPI_BITREG_SLEEP_TYPE_A                0x10
+#define ACPI_BITREG_SLEEP_TYPE_B                0x11
+#define ACPI_BITREG_SLEEP_ENABLE                0x12
+
+#define ACPI_BITREG_ARB_DISABLE                 0x13
+
+#define ACPI_BITREG_MAX                         0x13
+#define ACPI_NUM_BITREG                         ACPI_BITREG_MAX + 1
+
+
+/*
+ * External ACPI object definition
+ */
+union acpi_object
+{
+	acpi_object_type                    type;   /* See definition of acpi_ns_type for values */
+	struct
+	{
+		acpi_object_type                    type;
+		acpi_integer                        value;      /* The actual number */
+	} integer;
+
+	struct
+	{
+		acpi_object_type                    type;
+		u32                                 length;     /* # of bytes in string, excluding trailing null */
+		char                                *pointer;   /* points to the string value */
+	} string;
+
+	struct
+	{
+		acpi_object_type                    type;
+		u32                                 length;     /* # of bytes in buffer */
+		u8                                  *pointer;   /* points to the buffer */
+	} buffer;
+
+	struct
+	{
+		acpi_object_type                    type;
+		u32                                 fill1;
+		acpi_handle                         handle;     /* object reference */
+	} reference;
+
+	struct
+	{
+		acpi_object_type                    type;
+		u32                                 count;      /* # of elements in package */
+		union acpi_object                   *elements;  /* Pointer to an array of ACPI_OBJECTs */
+	} package;
+
+	struct
+	{
+		acpi_object_type                    type;
+		u32                                 proc_id;
+		acpi_io_address                     pblk_address;
+		u32                                 pblk_length;
+	} processor;
+
+	struct
+	{
+		acpi_object_type                    type;
+		u32                                 system_level;
+		u32                                 resource_order;
+	} power_resource;
+};
+
+
+/*
+ * List of objects, used as a parameter list for control method evaluation
+ */
+struct acpi_object_list
+{
+	u32                                 count;
+	union acpi_object                   *pointer;
+};
+
+
+/*
+ * Miscellaneous common Data Structures used by the interfaces
+ */
+#define ACPI_NO_BUFFER              0
+#define ACPI_ALLOCATE_BUFFER        (acpi_size) (-1)
+#define ACPI_ALLOCATE_LOCAL_BUFFER  (acpi_size) (-2)
+
+struct acpi_buffer
+{
+	acpi_size                           length;         /* Length in bytes of the buffer */
+	void                                *pointer;       /* pointer to buffer */
+};
+
+
+/*
+ * name_type for acpi_get_name
+ */
+#define ACPI_FULL_PATHNAME              0
+#define ACPI_SINGLE_NAME                1
+#define ACPI_NAME_TYPE_MAX              1
+
+
+/*
+ * Structure and flags for acpi_get_system_info
+ */
+#define ACPI_SYS_MODE_UNKNOWN           0x0000
+#define ACPI_SYS_MODE_ACPI              0x0001
+#define ACPI_SYS_MODE_LEGACY            0x0002
+#define ACPI_SYS_MODES_MASK             0x0003
+
+
+/*
+ * ACPI Table Info.  One per ACPI table _type_
+ */
+struct acpi_table_info
+{
+	u32                                 count;
+};
+
+
+/*
+ * System info returned by acpi_get_system_info()
+ */
+struct acpi_system_info
+{
+	u32                                 acpi_ca_version;
+	u32                                 flags;
+	u32                                 timer_resolution;
+	u32                                 reserved1;
+	u32                                 reserved2;
+	u32                                 debug_level;
+	u32                                 debug_layer;
+	u32                                 num_table_types;
+	struct acpi_table_info              table_info [NUM_ACPI_TABLE_TYPES];
+};
+
+
+/*
+ * Types specific to the OS service interfaces
+ */
+
+typedef u32
+(ACPI_SYSTEM_XFACE *OSD_HANDLER) (
+	void                            *context);
+
+typedef void
+(ACPI_SYSTEM_XFACE *OSD_EXECUTION_CALLBACK) (
+	void                            *context);
+
+/*
+ * Various handlers and callback procedures
+ */
+typedef
+u32 (*acpi_event_handler) (
+	void                                *context);
+
+typedef
+void (*acpi_gpe_handler) (
+	void                                *context);
+
+typedef
+void (*acpi_notify_handler) (
+	acpi_handle                         device,
+	u32                                 value,
+	void                                *context);
+
+typedef
+void (*acpi_object_handler) (
+	acpi_handle                         object,
+	u32                                 function,
+	void                                *data);
+
+typedef
+acpi_status (*acpi_init_handler) (
+	acpi_handle                         object,
+	u32                                 function);
+
+#define ACPI_INIT_DEVICE_INI        1
+
+
+/* Address Spaces (Operation Regions */
+
+typedef
+acpi_status (*acpi_adr_space_handler) (
+	u32                                 function,
+	acpi_physical_address               address,
+	u32                                 bit_width,
+	acpi_integer                        *value,
+	void                                *handler_context,
+	void                                *region_context);
+
+#define ACPI_DEFAULT_HANDLER        NULL
+
+
+typedef
+acpi_status (*acpi_adr_space_setup) (
+	acpi_handle                         region_handle,
+	u32                                 function,
+	void                                *handler_context,
+	void                                **region_context);
+
+#define ACPI_REGION_ACTIVATE    0
+#define ACPI_REGION_DEACTIVATE  1
+
+typedef
+acpi_status (*acpi_walk_callback) (
+	acpi_handle                         obj_handle,
+	u32                                 nesting_level,
+	void                                *context,
+	void                                **return_value);
+
+
+/* Interrupt handler return values */
+
+#define ACPI_INTERRUPT_NOT_HANDLED      0x00
+#define ACPI_INTERRUPT_HANDLED          0x01
+
+
+/* Common string version of device HIDs and UIDs */
+
+struct acpi_device_id
+{
+	char                            value[ACPI_DEVICE_ID_LENGTH];
+};
+
+/* Common string version of device CIDs */
+
+struct acpi_compatible_id
+{
+	char                            value[ACPI_MAX_CID_LENGTH];
+};
+
+struct acpi_compatible_id_list
+{
+	u32                             count;
+	u32                             size;
+	struct acpi_compatible_id       id[1];
+};
+
+
+/* Structure and flags for acpi_get_object_info */
+
+#define ACPI_VALID_STA                  0x0001
+#define ACPI_VALID_ADR                  0x0002
+#define ACPI_VALID_HID                  0x0004
+#define ACPI_VALID_UID                  0x0008
+#define ACPI_VALID_CID                  0x0010
+
+
+#define ACPI_COMMON_OBJ_INFO \
+	acpi_object_type                    type;           /* ACPI object type */ \
+	acpi_name                           name            /* ACPI object Name */
+
+
+struct acpi_obj_info_header
+{
+	ACPI_COMMON_OBJ_INFO;
+};
+
+
+/* Structure returned from Get Object Info */
+
+struct acpi_device_info
+{
+	ACPI_COMMON_OBJ_INFO;
+
+	u32                                 valid;              /* Indicates which fields are valid */
+	u32                                 current_status;     /* _STA value */
+	acpi_integer                        address;            /* _ADR value if any */
+	struct acpi_device_id               hardware_id;        /* _HID value if any */
+	struct acpi_device_id               unique_id;          /* _UID value if any */
+	struct acpi_compatible_id_list      compatibility_id;   /* List of _CIDs if any */
+};
+
+
+/* Context structs for address space handlers */
+
+struct acpi_pci_id
+{
+	u16                                 segment;
+	u16                                 bus;
+	u16                                 device;
+	u16                                 function;
+};
+
+
+struct acpi_mem_space_context
+{
+	u32                                 length;
+	acpi_physical_address               address;
+	acpi_physical_address               mapped_physical_address;
+	u8                                  *mapped_logical_address;
+	acpi_size                           mapped_length;
+};
+
+
+/*
+ * Definitions for Resource Attributes
+ */
+
+/*
+ *  Memory Attributes
+ */
+#define ACPI_READ_ONLY_MEMORY           (u8) 0x00
+#define ACPI_READ_WRITE_MEMORY          (u8) 0x01
+
+#define ACPI_NON_CACHEABLE_MEMORY       (u8) 0x00
+#define ACPI_CACHABLE_MEMORY            (u8) 0x01
+#define ACPI_WRITE_COMBINING_MEMORY     (u8) 0x02
+#define ACPI_PREFETCHABLE_MEMORY        (u8) 0x03
+
+/*
+ *  IO Attributes
+ *  The ISA Io ranges are:     n000-n0_ffh, n400-n4_ffh, n800-n8_ffh, n_c00-n_cFFh.
+ *  The non-ISA Io ranges are: n100-n3_ffh, n500-n7_ffh, n900-n_bFfh, n_cd0-n_fFFh.
+ */
+#define ACPI_NON_ISA_ONLY_RANGES        (u8) 0x01
+#define ACPI_ISA_ONLY_RANGES            (u8) 0x02
+#define ACPI_ENTIRE_RANGE               (ACPI_NON_ISA_ONLY_RANGES | ACPI_ISA_ONLY_RANGES)
+
+#define ACPI_SPARSE_TRANSLATION         (u8) 0x03
+
+/*
+ *  IO Port Descriptor Decode
+ */
+#define ACPI_DECODE_10                  (u8) 0x00    /* 10-bit IO address decode */
+#define ACPI_DECODE_16                  (u8) 0x01    /* 16-bit IO address decode */
+
+/*
+ *  IRQ Attributes
+ */
+#define ACPI_EDGE_SENSITIVE             (u8) 0x00
+#define ACPI_LEVEL_SENSITIVE            (u8) 0x01
+
+#define ACPI_ACTIVE_HIGH                (u8) 0x00
+#define ACPI_ACTIVE_LOW                 (u8) 0x01
+
+#define ACPI_EXCLUSIVE                  (u8) 0x00
+#define ACPI_SHARED                     (u8) 0x01
+
+/*
+ *  DMA Attributes
+ */
+#define ACPI_COMPATIBILITY              (u8) 0x00
+#define ACPI_TYPE_A                     (u8) 0x01
+#define ACPI_TYPE_B                     (u8) 0x02
+#define ACPI_TYPE_F                     (u8) 0x03
+
+#define ACPI_NOT_BUS_MASTER             (u8) 0x00
+#define ACPI_BUS_MASTER                 (u8) 0x01
+
+#define ACPI_TRANSFER_8                 (u8) 0x00
+#define ACPI_TRANSFER_8_16              (u8) 0x01
+#define ACPI_TRANSFER_16                (u8) 0x02
+
+/*
+ * Start Dependent Functions Priority definitions
+ */
+#define ACPI_GOOD_CONFIGURATION         (u8) 0x00
+#define ACPI_ACCEPTABLE_CONFIGURATION   (u8) 0x01
+#define ACPI_SUB_OPTIMAL_CONFIGURATION  (u8) 0x02
+
+/*
+ *  16, 32 and 64-bit Address Descriptor resource types
+ */
+#define ACPI_MEMORY_RANGE               (u8) 0x00
+#define ACPI_IO_RANGE                   (u8) 0x01
+#define ACPI_BUS_NUMBER_RANGE           (u8) 0x02
+
+#define ACPI_ADDRESS_NOT_FIXED          (u8) 0x00
+#define ACPI_ADDRESS_FIXED              (u8) 0x01
+
+#define ACPI_POS_DECODE                 (u8) 0x00
+#define ACPI_SUB_DECODE                 (u8) 0x01
+
+#define ACPI_PRODUCER                   (u8) 0x00
+#define ACPI_CONSUMER                   (u8) 0x01
+
+
+/*
+ *  Structures used to describe device resources
+ */
+struct acpi_resource_irq
+{
+	u32                                 edge_level;
+	u32                                 active_high_low;
+	u32                                 shared_exclusive;
+	u32                                 number_of_interrupts;
+	u32                                 interrupts[1];
+};
+
+struct acpi_resource_dma
+{
+	u32                                 type;
+	u32                                 bus_master;
+	u32                                 transfer;
+	u32                                 number_of_channels;
+	u32                                 channels[1];
+};
+
+struct acpi_resource_start_dpf
+{
+	u32                                 compatibility_priority;
+	u32                                 performance_robustness;
+};
+
+/*
+ * END_DEPENDENT_FUNCTIONS_RESOURCE struct is not
+ * needed because it has no fields
+ */
+
+struct acpi_resource_io
+{
+	u32                                 io_decode;
+	u32                                 min_base_address;
+	u32                                 max_base_address;
+	u32                                 alignment;
+	u32                                 range_length;
+};
+
+struct acpi_resource_fixed_io
+{
+	u32                                 base_address;
+	u32                                 range_length;
+};
+
+struct acpi_resource_vendor
+{
+	u32                                 length;
+	u8                                  reserved[1];
+};
+
+struct acpi_resource_end_tag
+{
+	u8                                  checksum;
+};
+
+struct acpi_resource_mem24
+{
+	u32                                 read_write_attribute;
+	u32                                 min_base_address;
+	u32                                 max_base_address;
+	u32                                 alignment;
+	u32                                 range_length;
+};
+
+struct acpi_resource_mem32
+{
+	u32                                 read_write_attribute;
+	u32                                 min_base_address;
+	u32                                 max_base_address;
+	u32                                 alignment;
+	u32                                 range_length;
+};
+
+struct acpi_resource_fixed_mem32
+{
+	u32                                 read_write_attribute;
+	u32                                 range_base_address;
+	u32                                 range_length;
+};
+
+struct acpi_memory_attribute
+{
+	u16                                 cache_attribute;
+	u16                                 read_write_attribute;
+};
+
+struct acpi_io_attribute
+{
+	u16                                 range_attribute;
+	u16                                 translation_attribute;
+};
+
+struct acpi_bus_attribute
+{
+	u16                                 reserved1;
+	u16                                 reserved2;
+};
+
+union acpi_resource_attribute
+{
+	struct acpi_memory_attribute        memory;
+	struct acpi_io_attribute            io;
+	struct acpi_bus_attribute           bus;
+};
+
+struct acpi_resource_source
+{
+	u32                                 index;
+	u32                                 string_length;
+	char                                *string_ptr;
+};
+
+struct acpi_resource_address16
+{
+	u32                                 resource_type;
+	u32                                 producer_consumer;
+	u32                                 decode;
+	u32                                 min_address_fixed;
+	u32                                 max_address_fixed;
+	union acpi_resource_attribute       attribute;
+	u32                                 granularity;
+	u32                                 min_address_range;
+	u32                                 max_address_range;
+	u32                                 address_translation_offset;
+	u32                                 address_length;
+	struct acpi_resource_source         resource_source;
+};
+
+struct acpi_resource_address32
+{
+	u32                                 resource_type;
+	u32                                 producer_consumer;
+	u32                                 decode;
+	u32                                 min_address_fixed;
+	u32                                 max_address_fixed;
+	union acpi_resource_attribute       attribute;
+	u32                                 granularity;
+	u32                                 min_address_range;
+	u32                                 max_address_range;
+	u32                                 address_translation_offset;
+	u32                                 address_length;
+	struct acpi_resource_source         resource_source;
+};
+
+struct acpi_resource_address64
+{
+	u32                                 resource_type;
+	u32                                 producer_consumer;
+	u32                                 decode;
+	u32                                 min_address_fixed;
+	u32                                 max_address_fixed;
+	union acpi_resource_attribute       attribute;
+	u64                                 granularity;
+	u64                                 min_address_range;
+	u64                                 max_address_range;
+	u64                                 address_translation_offset;
+	u64                                 address_length;
+	struct acpi_resource_source         resource_source;
+};
+
+struct acpi_resource_ext_irq
+{
+	u32                                 producer_consumer;
+	u32                                 edge_level;
+	u32                                 active_high_low;
+	u32                                 shared_exclusive;
+	u32                                 number_of_interrupts;
+	struct acpi_resource_source         resource_source;
+	u32                                 interrupts[1];
+};
+
+
+/* ACPI_RESOURCE_TYPEs */
+
+#define ACPI_RSTYPE_IRQ                 0
+#define ACPI_RSTYPE_DMA                 1
+#define ACPI_RSTYPE_START_DPF           2
+#define ACPI_RSTYPE_END_DPF             3
+#define ACPI_RSTYPE_IO                  4
+#define ACPI_RSTYPE_FIXED_IO            5
+#define ACPI_RSTYPE_VENDOR              6
+#define ACPI_RSTYPE_END_TAG             7
+#define ACPI_RSTYPE_MEM24               8
+#define ACPI_RSTYPE_MEM32               9
+#define ACPI_RSTYPE_FIXED_MEM32         10
+#define ACPI_RSTYPE_ADDRESS16           11
+#define ACPI_RSTYPE_ADDRESS32           12
+#define ACPI_RSTYPE_ADDRESS64           13
+#define ACPI_RSTYPE_EXT_IRQ             14
+
+typedef u32                                     acpi_resource_type;
+
+union acpi_resource_data
+{
+	struct acpi_resource_irq            irq;
+	struct acpi_resource_dma            dma;
+	struct acpi_resource_start_dpf      start_dpf;
+	struct acpi_resource_io             io;
+	struct acpi_resource_fixed_io       fixed_io;
+	struct acpi_resource_vendor         vendor_specific;
+	struct acpi_resource_end_tag        end_tag;
+	struct acpi_resource_mem24          memory24;
+	struct acpi_resource_mem32          memory32;
+	struct acpi_resource_fixed_mem32    fixed_memory32;
+	struct acpi_resource_address16      address16;
+	struct acpi_resource_address32      address32;
+	struct acpi_resource_address64      address64;
+	struct acpi_resource_ext_irq        extended_irq;
+};
+
+struct acpi_resource
+{
+	acpi_resource_type                  id;
+	u32                                 length;
+	union acpi_resource_data            data;
+};
+
+#define ACPI_RESOURCE_LENGTH                12
+#define ACPI_RESOURCE_LENGTH_NO_DATA        8       /* Id + Length fields */
+
+#define ACPI_SIZEOF_RESOURCE(type)          (ACPI_RESOURCE_LENGTH_NO_DATA + sizeof (type))
+
+#define ACPI_NEXT_RESOURCE(res)             (struct acpi_resource *)((u8 *) res + res->length)
+
+#ifdef ACPI_MISALIGNED_TRANSFERS
+#define ACPI_ALIGN_RESOURCE_SIZE(length)    (length)
+#else
+#define ACPI_ALIGN_RESOURCE_SIZE(length)    ACPI_ROUND_UP_TO_NATIVE_WORD(length)
+#endif
+
+/*
+ * END: of definitions for Resource Attributes
+ */
+
+
+struct acpi_pci_routing_table
+{
+	u32                                 length;
+	u32                                 pin;
+	acpi_integer                        address;        /* here for 64-bit alignment */
+	u32                                 source_index;
+	char                                source[4];      /* pad to 64 bits so sizeof() works in all cases */
+};
+
+/*
+ * END: of definitions for PCI Routing tables
+ */
+
+
+#endif /* __ACTYPES_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/acutils.h linux-2.4.22-pre2/include/acpi/acutils.h
--- linux-2.4.21/include/acpi/acutils.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/acutils.h	2003-06-26 21:43:10.000000000 +0000
@@ -0,0 +1,836 @@
+/******************************************************************************
+ *
+ * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef _ACUTILS_H
+#define _ACUTILS_H
+
+
+typedef
+acpi_status (*acpi_pkg_callback) (
+	u8                              object_type,
+	union acpi_operand_object       *source_object,
+	union acpi_generic_state        *state,
+	void                            *context);
+
+
+acpi_status
+acpi_ut_walk_package_tree (
+	union acpi_operand_object       *source_object,
+	void                            *target_object,
+	acpi_pkg_callback               walk_callback,
+	void                            *context);
+
+
+struct acpi_pkg_info
+{
+	u8                              *free_space;
+	acpi_size                       length;
+	u32                             object_space;
+	u32                             num_packages;
+};
+
+#define REF_INCREMENT       (u16) 0
+#define REF_DECREMENT       (u16) 1
+#define REF_FORCE_DELETE    (u16) 2
+
+/* acpi_ut_dump_buffer */
+
+#define DB_BYTE_DISPLAY     1
+#define DB_WORD_DISPLAY     2
+#define DB_DWORD_DISPLAY    4
+#define DB_QWORD_DISPLAY    8
+
+
+/* Global initialization interfaces */
+
+void
+acpi_ut_init_globals (
+	void);
+
+void
+acpi_ut_terminate (
+	void);
+
+
+/*
+ * ut_init - miscellaneous initialization and shutdown
+ */
+
+acpi_status
+acpi_ut_hardware_initialize (
+	void);
+
+void
+acpi_ut_subsystem_shutdown (
+	void);
+
+acpi_status
+acpi_ut_validate_fadt (
+	void);
+
+/*
+ * ut_global - Global data structures and procedures
+ */
+
+#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
+
+char *
+acpi_ut_get_mutex_name (
+	u32                             mutex_id);
+
+#endif
+
+char *
+acpi_ut_get_type_name (
+	acpi_object_type                type);
+
+char *
+acpi_ut_get_object_type_name (
+	union acpi_operand_object       *obj_desc);
+
+char *
+acpi_ut_get_region_name (
+	u8                              space_id);
+
+char *
+acpi_ut_get_event_name (
+	u32                             event_id);
+
+char
+acpi_ut_hex_to_ascii_char (
+	acpi_integer                    integer,
+	u32                             position);
+
+u8
+acpi_ut_valid_object_type (
+	acpi_object_type                type);
+
+acpi_owner_id
+acpi_ut_allocate_owner_id (
+	u32                             id_type);
+
+
+/*
+ * ut_clib - Local implementations of C library functions
+ */
+
+#ifndef ACPI_USE_SYSTEM_CLIBRARY
+
+acpi_size
+acpi_ut_strlen (
+	const char                      *string);
+
+char *
+acpi_ut_strcpy (
+	char                            *dst_string,
+	const char                      *src_string);
+
+char *
+acpi_ut_strncpy (
+	char                            *dst_string,
+	const char                      *src_string,
+	acpi_size                       count);
+
+int
+acpi_ut_strncmp (
+	const char                      *string1,
+	const char                      *string2,
+	acpi_size                       count);
+
+int
+acpi_ut_strcmp (
+	const char                      *string1,
+	const char                      *string2);
+
+char *
+acpi_ut_strcat (
+	char                            *dst_string,
+	const char                      *src_string);
+
+char *
+acpi_ut_strncat (
+	char                            *dst_string,
+	const char                      *src_string,
+	acpi_size                       count);
+
+u32
+acpi_ut_strtoul (
+	const char                      *string,
+	char                            **terminator,
+	u32                             base);
+
+char *
+acpi_ut_strstr (
+	char                            *string1,
+	char                            *string2);
+
+void *
+acpi_ut_memcpy (
+	void                            *dest,
+	const void                      *src,
+	acpi_size                       count);
+
+void *
+acpi_ut_memset (
+	void                            *dest,
+	acpi_native_uint                value,
+	acpi_size                       count);
+
+int
+acpi_ut_to_upper (
+	int                             c);
+
+int
+acpi_ut_to_lower (
+	int                             c);
+
+extern const u8 _acpi_ctype[];
+
+#define _ACPI_XA     0x00    /* extra alphabetic - not supported */
+#define _ACPI_XS     0x40    /* extra space */
+#define _ACPI_BB     0x00    /* BEL, BS, etc. - not supported */
+#define _ACPI_CN     0x20    /* CR, FF, HT, NL, VT */
+#define _ACPI_DI     0x04    /* '0'-'9' */
+#define _ACPI_LO     0x02    /* 'a'-'z' */
+#define _ACPI_PU     0x10    /* punctuation */
+#define _ACPI_SP     0x08    /* space */
+#define _ACPI_UP     0x01    /* 'A'-'Z' */
+#define _ACPI_XD     0x80    /* '0'-'9', 'A'-'F', 'a'-'f' */
+
+#define ACPI_IS_DIGIT(c)  (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI))
+#define ACPI_IS_SPACE(c)  (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP))
+#define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD))
+#define ACPI_IS_UPPER(c)  (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP))
+#define ACPI_IS_LOWER(c)  (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO))
+#define ACPI_IS_PRINT(c)  (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU))
+#define ACPI_IS_ALPHA(c)  (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
+#define ACPI_IS_ASCII(c)  ((c) < 0x80)
+
+#endif /* ACPI_USE_SYSTEM_CLIBRARY */
+
+/*
+ * ut_copy - Object construction and conversion interfaces
+ */
+
+acpi_status
+acpi_ut_build_simple_object(
+	union acpi_operand_object       *obj,
+	union acpi_object               *user_obj,
+	u8                              *data_space,
+	u32                             *buffer_space_used);
+
+acpi_status
+acpi_ut_build_package_object (
+	union acpi_operand_object       *obj,
+	u8                              *buffer,
+	u32                             *space_used);
+
+acpi_status
+acpi_ut_copy_ielement_to_eelement (
+	u8                              object_type,
+	union acpi_operand_object       *source_object,
+	union acpi_generic_state        *state,
+	void                            *context);
+
+acpi_status
+acpi_ut_copy_ielement_to_ielement (
+	u8                              object_type,
+	union acpi_operand_object       *source_object,
+	union acpi_generic_state        *state,
+	void                            *context);
+
+acpi_status
+acpi_ut_copy_iobject_to_eobject (
+	union acpi_operand_object       *obj,
+	struct acpi_buffer              *ret_buffer);
+
+acpi_status
+acpi_ut_copy_esimple_to_isimple(
+	union acpi_object               *user_obj,
+	union acpi_operand_object       **return_obj);
+
+acpi_status
+acpi_ut_copy_eobject_to_iobject (
+	union acpi_object               *obj,
+	union acpi_operand_object       **internal_obj);
+
+acpi_status
+acpi_ut_copy_isimple_to_isimple (
+	union acpi_operand_object       *source_obj,
+	union acpi_operand_object       *dest_obj);
+
+acpi_status
+acpi_ut_copy_ipackage_to_ipackage (
+	union acpi_operand_object       *source_obj,
+	union acpi_operand_object       *dest_obj,
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
+acpi_ut_copy_simple_object (
+	union acpi_operand_object       *source_desc,
+	union acpi_operand_object       *dest_desc);
+
+acpi_status
+acpi_ut_copy_iobject_to_iobject (
+	union acpi_operand_object       *source_desc,
+	union acpi_operand_object       **dest_desc,
+	struct acpi_walk_state          *walk_state);
+
+
+/*
+ * ut_create - Object creation
+ */
+
+acpi_status
+acpi_ut_update_object_reference (
+	union acpi_operand_object       *object,
+	u16                             action);
+
+
+/*
+ * ut_debug - Debug interfaces
+ */
+
+void
+acpi_ut_init_stack_ptr_trace (
+	void);
+
+void
+acpi_ut_track_stack_ptr (
+	void);
+
+void
+acpi_ut_trace (
+	u32                             line_number,
+	struct acpi_debug_print_info    *dbg_info);
+
+void
+acpi_ut_trace_ptr (
+	u32                             line_number,
+	struct acpi_debug_print_info    *dbg_info,
+	void                            *pointer);
+
+void
+acpi_ut_trace_u32 (
+	u32                             line_number,
+	struct acpi_debug_print_info    *dbg_info,
+	u32                             integer);
+
+void
+acpi_ut_trace_str (
+	u32                             line_number,
+	struct acpi_debug_print_info    *dbg_info,
+	char                            *string);
+
+void
+acpi_ut_exit (
+	u32                             line_number,
+	struct acpi_debug_print_info    *dbg_info);
+
+void
+acpi_ut_status_exit (
+	u32                             line_number,
+	struct acpi_debug_print_info    *dbg_info,
+	acpi_status                     status);
+
+void
+acpi_ut_value_exit (
+	u32                             line_number,
+	struct acpi_debug_print_info    *dbg_info,
+	acpi_integer                    value);
+
+void
+acpi_ut_ptr_exit (
+	u32                             line_number,
+	struct acpi_debug_print_info    *dbg_info,
+	u8                              *ptr);
+
+void
+acpi_ut_report_info (
+	char                            *module_name,
+	u32                             line_number,
+	u32                             component_id);
+
+void
+acpi_ut_report_error (
+	char                            *module_name,
+	u32                             line_number,
+	u32                             component_id);
+
+void
+acpi_ut_report_warning (
+	char                            *module_name,
+	u32                             line_number,
+	u32                             component_id);
+
+void
+acpi_ut_dump_buffer (
+	u8                              *buffer,
+	u32                             count,
+	u32                             display,
+	u32                             component_id);
+
+void ACPI_INTERNAL_VAR_XFACE
+acpi_ut_debug_print (
+	u32                             requested_debug_level,
+	u32                             line_number,
+	struct acpi_debug_print_info    *dbg_info,
+	char                            *format,
+	...) ACPI_PRINTF_LIKE_FUNC;
+
+void ACPI_INTERNAL_VAR_XFACE
+acpi_ut_debug_print_raw (
+	u32                             requested_debug_level,
+	u32                             line_number,
+	struct acpi_debug_print_info    *dbg_info,
+	char                            *format,
+	...) ACPI_PRINTF_LIKE_FUNC;
+
+
+/*
+ * ut_delete - Object deletion
+ */
+
+void
+acpi_ut_delete_internal_obj (
+	union acpi_operand_object       *object);
+
+void
+acpi_ut_delete_internal_package_object (
+	union acpi_operand_object       *object);
+
+void
+acpi_ut_delete_internal_simple_object (
+	union acpi_operand_object       *object);
+
+void
+acpi_ut_delete_internal_object_list (
+	union acpi_operand_object       **obj_list);
+
+
+/*
+ * ut_eval - object evaluation
+ */
+
+/* Method name strings */
+
+#define METHOD_NAME__HID        "_HID"
+#define METHOD_NAME__CID        "_CID"
+#define METHOD_NAME__UID        "_UID"
+#define METHOD_NAME__ADR        "_ADR"
+#define METHOD_NAME__STA        "_STA"
+#define METHOD_NAME__REG        "_REG"
+#define METHOD_NAME__SEG        "_SEG"
+#define METHOD_NAME__BBN        "_BBN"
+#define METHOD_NAME__PRT        "_PRT"
+#define METHOD_NAME__CRS        "_CRS"
+#define METHOD_NAME__PRS        "_PRS"
+
+
+acpi_status
+acpi_ut_evaluate_object (
+	struct acpi_namespace_node      *prefix_node,
+	char                            *path,
+	u32                             expected_return_btypes,
+	union acpi_operand_object       **return_desc);
+
+acpi_status
+acpi_ut_evaluate_numeric_object (
+	char                            *object_name,
+	struct acpi_namespace_node      *device_node,
+	acpi_integer                    *address);
+
+acpi_status
+acpi_ut_execute_HID (
+	struct acpi_namespace_node      *device_node,
+	struct acpi_device_id           *hid);
+
+acpi_status
+acpi_ut_execute_CID (
+	struct acpi_namespace_node      *device_node,
+	struct acpi_compatible_id_list **return_cid_list);
+
+acpi_status
+acpi_ut_execute_STA (
+	struct acpi_namespace_node      *device_node,
+	u32                             *status_flags);
+
+acpi_status
+acpi_ut_execute_UID (
+	struct acpi_namespace_node      *device_node,
+	struct acpi_device_id           *uid);
+
+
+/*
+ * ut_mutex - mutual exclusion interfaces
+ */
+
+acpi_status
+acpi_ut_mutex_initialize (
+	void);
+
+void
+acpi_ut_mutex_terminate (
+	void);
+
+acpi_status
+acpi_ut_create_mutex (
+	acpi_mutex_handle               mutex_id);
+
+acpi_status
+acpi_ut_delete_mutex (
+	acpi_mutex_handle               mutex_id);
+
+acpi_status
+acpi_ut_acquire_mutex (
+	acpi_mutex_handle               mutex_id);
+
+acpi_status
+acpi_ut_release_mutex (
+	acpi_mutex_handle               mutex_id);
+
+
+/*
+ * ut_object - internal object create/delete/cache routines
+ */
+
+union acpi_operand_object    *
+acpi_ut_create_internal_object_dbg (
+	char                            *module_name,
+	u32                             line_number,
+	u32                             component_id,
+	acpi_object_type                type);
+
+void *
+acpi_ut_allocate_object_desc_dbg (
+	char                            *module_name,
+	u32                             line_number,
+	u32                             component_id);
+
+#define acpi_ut_create_internal_object(t) acpi_ut_create_internal_object_dbg (_THIS_MODULE,__LINE__,_COMPONENT,t)
+#define acpi_ut_allocate_object_desc()  acpi_ut_allocate_object_desc_dbg (_THIS_MODULE,__LINE__,_COMPONENT)
+
+void
+acpi_ut_delete_object_desc (
+	union acpi_operand_object       *object);
+
+u8
+acpi_ut_valid_internal_object (
+	void                            *object);
+
+union acpi_operand_object *
+acpi_ut_create_buffer_object (
+	acpi_size                       buffer_size);
+
+
+/*
+ * ut_ref_cnt - Object reference count management
+ */
+
+void
+acpi_ut_add_reference (
+	union acpi_operand_object       *object);
+
+void
+acpi_ut_remove_reference (
+	union acpi_operand_object       *object);
+
+/*
+ * ut_size - Object size routines
+ */
+
+acpi_status
+acpi_ut_get_simple_object_size (
+	union acpi_operand_object       *obj,
+	acpi_size                       *obj_length);
+
+acpi_status
+acpi_ut_get_package_object_size (
+	union acpi_operand_object       *obj,
+	acpi_size                       *obj_length);
+
+acpi_status
+acpi_ut_get_object_size(
+	union acpi_operand_object       *obj,
+	acpi_size                       *obj_length);
+
+acpi_status
+acpi_ut_get_element_length (
+	u8                              object_type,
+	union acpi_operand_object       *source_object,
+	union acpi_generic_state        *state,
+	void                            *context);
+
+
+/*
+ * ut_state - Generic state creation/cache routines
+ */
+
+void
+acpi_ut_push_generic_state (
+	union acpi_generic_state        **list_head,
+	union acpi_generic_state        *state);
+
+union acpi_generic_state *
+acpi_ut_pop_generic_state (
+	union acpi_generic_state        **list_head);
+
+
+union acpi_generic_state *
+acpi_ut_create_generic_state (
+	void);
+
+struct acpi_thread_state *
+acpi_ut_create_thread_state (
+	void);
+
+union acpi_generic_state *
+acpi_ut_create_update_state (
+	union acpi_operand_object       *object,
+	u16                             action);
+
+union acpi_generic_state *
+acpi_ut_create_pkg_state (
+	void                            *internal_object,
+	void                            *external_object,
+	u16                             index);
+
+acpi_status
+acpi_ut_create_update_state_and_push (
+	union acpi_operand_object       *object,
+	u16                             action,
+	union acpi_generic_state        **state_list);
+
+acpi_status
+acpi_ut_create_pkg_state_and_push (
+	void                            *internal_object,
+	void                            *external_object,
+	u16                             index,
+	union acpi_generic_state        **state_list);
+
+union acpi_generic_state *
+acpi_ut_create_control_state (
+	void);
+
+void
+acpi_ut_delete_generic_state (
+	union acpi_generic_state        *state);
+
+void
+acpi_ut_delete_generic_state_cache (
+	void);
+
+void
+acpi_ut_delete_object_cache (
+	void);
+
+/*
+ * utmisc
+ */
+
+void
+acpi_ut_print_string (
+	char                            *string,
+	u8                              max_length);
+
+acpi_status
+acpi_ut_divide (
+	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,
+	u32                             divisor,
+	acpi_integer                    *out_quotient,
+	u32                             *out_remainder);
+
+u8
+acpi_ut_valid_acpi_name (
+	u32                             name);
+
+u8
+acpi_ut_valid_acpi_character (
+	char                            character);
+
+acpi_status
+acpi_ut_strtoul64 (
+	char                            *string,
+	u32                             base,
+	acpi_integer                    *ret_integer);
+
+char *
+acpi_ut_strupr (
+	char                            *src_string);
+
+u8 *
+acpi_ut_get_resource_end_tag (
+	union acpi_operand_object       *obj_desc);
+
+u8
+acpi_ut_generate_checksum (
+	u8                              *buffer,
+	u32                             length);
+
+u32
+acpi_ut_dword_byte_swap (
+	u32                             value);
+
+void
+acpi_ut_set_integer_width (
+	u8                              revision);
+
+#ifdef ACPI_DEBUG_OUTPUT
+void
+acpi_ut_display_init_pathname (
+	u8                              type,
+	struct acpi_namespace_node      *obj_handle,
+	char                            *path);
+
+#endif
+
+
+/*
+ * Utalloc - memory allocation and object caching
+ */
+
+void *
+acpi_ut_acquire_from_cache (
+	u32                             list_id);
+
+void
+acpi_ut_release_to_cache (
+	u32                             list_id,
+	void                            *object);
+
+void
+acpi_ut_delete_generic_cache (
+	u32                             list_id);
+
+acpi_status
+acpi_ut_validate_buffer (
+	struct acpi_buffer              *buffer);
+
+acpi_status
+acpi_ut_initialize_buffer (
+	struct acpi_buffer              *buffer,
+	acpi_size                       required_length);
+
+
+/* Memory allocation functions */
+
+void *
+acpi_ut_allocate (
+	acpi_size                       size,
+	u32                             component,
+	char                            *module,
+	u32                             line);
+
+void *
+acpi_ut_callocate (
+	acpi_size                       size,
+	u32                             component,
+	char                            *module,
+	u32                             line);
+
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+
+void *
+acpi_ut_allocate_and_track (
+	acpi_size                       size,
+	u32                             component,
+	char                            *module,
+	u32                             line);
+
+void *
+acpi_ut_callocate_and_track (
+	acpi_size                       size,
+	u32                             component,
+	char                            *module,
+	u32                             line);
+
+void
+acpi_ut_free_and_track (
+	void                            *address,
+	u32                             component,
+	char                            *module,
+	u32                             line);
+
+struct acpi_debug_mem_block *
+acpi_ut_find_allocation (
+	u32                             list_id,
+	void                            *allocation);
+
+acpi_status
+acpi_ut_track_allocation (
+	u32                             list_id,
+	struct acpi_debug_mem_block     *address,
+	acpi_size                       size,
+	u8                              alloc_type,
+	u32                             component,
+	char                            *module,
+	u32                             line);
+
+acpi_status
+acpi_ut_remove_allocation (
+	u32                             list_id,
+	struct acpi_debug_mem_block     *address,
+	u32                             component,
+	char                            *module,
+	u32                             line);
+
+void
+acpi_ut_dump_allocation_info (
+	void);
+
+void
+acpi_ut_dump_allocations (
+	u32                             component,
+	char                            *module);
+#endif
+
+
+#endif /* _ACUTILS_H */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/amlcode.h linux-2.4.22-pre2/include/acpi/amlcode.h
--- linux-2.4.21/include/acpi/amlcode.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/amlcode.h	2003-06-26 21:43:29.000000000 +0000
@@ -0,0 +1,506 @@
+/******************************************************************************
+ *
+ * Name: amlcode.h - Definitions for AML, as included in "definition blocks"
+ *                   Declarations and definitions contained herein are derived
+ *                   directly from the ACPI specification.
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __AMLCODE_H__
+#define __AMLCODE_H__
+
+/* primary opcodes */
+
+#define AML_NULL_CHAR               (u16) 0x00
+
+#define AML_ZERO_OP                 (u16) 0x00
+#define AML_ONE_OP                  (u16) 0x01
+#define AML_UNASSIGNED              (u16) 0x02
+#define AML_ALIAS_OP                (u16) 0x06
+#define AML_NAME_OP                 (u16) 0x08
+#define AML_BYTE_OP                 (u16) 0x0a
+#define AML_WORD_OP                 (u16) 0x0b
+#define AML_DWORD_OP                (u16) 0x0c
+#define AML_STRING_OP               (u16) 0x0d
+#define AML_QWORD_OP                (u16) 0x0e     /* ACPI 2.0 */
+#define AML_SCOPE_OP                (u16) 0x10
+#define AML_BUFFER_OP               (u16) 0x11
+#define AML_PACKAGE_OP              (u16) 0x12
+#define AML_VAR_PACKAGE_OP          (u16) 0x13     /* ACPI 2.0 */
+#define AML_METHOD_OP               (u16) 0x14
+#define AML_DUAL_NAME_PREFIX        (u16) 0x2e
+#define AML_MULTI_NAME_PREFIX_OP    (u16) 0x2f
+#define AML_NAME_CHAR_SUBSEQ        (u16) 0x30
+#define AML_NAME_CHAR_FIRST         (u16) 0x41
+#define AML_OP_PREFIX               (u16) 0x5b
+#define AML_ROOT_PREFIX             (u16) 0x5c
+#define AML_PARENT_PREFIX           (u16) 0x5e
+#define AML_LOCAL_OP                (u16) 0x60
+#define AML_LOCAL0                  (u16) 0x60
+#define AML_LOCAL1                  (u16) 0x61
+#define AML_LOCAL2                  (u16) 0x62
+#define AML_LOCAL3                  (u16) 0x63
+#define AML_LOCAL4                  (u16) 0x64
+#define AML_LOCAL5                  (u16) 0x65
+#define AML_LOCAL6                  (u16) 0x66
+#define AML_LOCAL7                  (u16) 0x67
+#define AML_ARG_OP                  (u16) 0x68
+#define AML_ARG0                    (u16) 0x68
+#define AML_ARG1                    (u16) 0x69
+#define AML_ARG2                    (u16) 0x6a
+#define AML_ARG3                    (u16) 0x6b
+#define AML_ARG4                    (u16) 0x6c
+#define AML_ARG5                    (u16) 0x6d
+#define AML_ARG6                    (u16) 0x6e
+#define AML_STORE_OP                (u16) 0x70
+#define AML_REF_OF_OP               (u16) 0x71
+#define AML_ADD_OP                  (u16) 0x72
+#define AML_CONCAT_OP               (u16) 0x73
+#define AML_SUBTRACT_OP             (u16) 0x74
+#define AML_INCREMENT_OP            (u16) 0x75
+#define AML_DECREMENT_OP            (u16) 0x76
+#define AML_MULTIPLY_OP             (u16) 0x77
+#define AML_DIVIDE_OP               (u16) 0x78
+#define AML_SHIFT_LEFT_OP           (u16) 0x79
+#define AML_SHIFT_RIGHT_OP          (u16) 0x7a
+#define AML_BIT_AND_OP              (u16) 0x7b
+#define AML_BIT_NAND_OP             (u16) 0x7c
+#define AML_BIT_OR_OP               (u16) 0x7d
+#define AML_BIT_NOR_OP              (u16) 0x7e
+#define AML_BIT_XOR_OP              (u16) 0x7f
+#define AML_BIT_NOT_OP              (u16) 0x80
+#define AML_FIND_SET_LEFT_BIT_OP    (u16) 0x81
+#define AML_FIND_SET_RIGHT_BIT_OP   (u16) 0x82
+#define AML_DEREF_OF_OP             (u16) 0x83
+#define AML_CONCAT_RES_OP           (u16) 0x84     /* ACPI 2.0 */
+#define AML_MOD_OP                  (u16) 0x85     /* ACPI 2.0 */
+#define AML_NOTIFY_OP               (u16) 0x86
+#define AML_SIZE_OF_OP              (u16) 0x87
+#define AML_INDEX_OP                (u16) 0x88
+#define AML_MATCH_OP                (u16) 0x89
+#define AML_CREATE_DWORD_FIELD_OP   (u16) 0x8a
+#define AML_CREATE_WORD_FIELD_OP    (u16) 0x8b
+#define AML_CREATE_BYTE_FIELD_OP    (u16) 0x8c
+#define AML_CREATE_BIT_FIELD_OP     (u16) 0x8d
+#define AML_TYPE_OP                 (u16) 0x8e
+#define AML_CREATE_QWORD_FIELD_OP   (u16) 0x8f     /* ACPI 2.0 */
+#define AML_LAND_OP                 (u16) 0x90
+#define AML_LOR_OP                  (u16) 0x91
+#define AML_LNOT_OP                 (u16) 0x92
+#define AML_LEQUAL_OP               (u16) 0x93
+#define AML_LGREATER_OP             (u16) 0x94
+#define AML_LLESS_OP                (u16) 0x95
+#define AML_TO_BUFFER_OP            (u16) 0x96     /* ACPI 2.0 */
+#define AML_TO_DECSTRING_OP         (u16) 0x97     /* ACPI 2.0 */
+#define AML_TO_HEXSTRING_OP         (u16) 0x98     /* ACPI 2.0 */
+#define AML_TO_INTEGER_OP           (u16) 0x99     /* ACPI 2.0 */
+#define AML_TO_STRING_OP            (u16) 0x9c     /* ACPI 2.0 */
+#define AML_COPY_OP                 (u16) 0x9d     /* ACPI 2.0 */
+#define AML_MID_OP                  (u16) 0x9e     /* ACPI 2.0 */
+#define AML_CONTINUE_OP             (u16) 0x9f     /* ACPI 2.0 */
+#define AML_IF_OP                   (u16) 0xa0
+#define AML_ELSE_OP                 (u16) 0xa1
+#define AML_WHILE_OP                (u16) 0xa2
+#define AML_NOOP_OP                 (u16) 0xa3
+#define AML_RETURN_OP               (u16) 0xa4
+#define AML_BREAK_OP                (u16) 0xa5
+#define AML_BREAK_POINT_OP          (u16) 0xcc
+#define AML_ONES_OP                 (u16) 0xff
+
+/* prefixed opcodes */
+
+#define AML_EXTOP                   (u16) 0x005b
+
+
+#define AML_MUTEX_OP                (u16) 0x5b01
+#define AML_EVENT_OP                (u16) 0x5b02
+#define AML_SHIFT_RIGHT_BIT_OP      (u16) 0x5b10
+#define AML_SHIFT_LEFT_BIT_OP       (u16) 0x5b11
+#define AML_COND_REF_OF_OP          (u16) 0x5b12
+#define AML_CREATE_FIELD_OP         (u16) 0x5b13
+#define AML_LOAD_TABLE_OP           (u16) 0x5b1f     /* ACPI 2.0 */
+#define AML_LOAD_OP                 (u16) 0x5b20
+#define AML_STALL_OP                (u16) 0x5b21
+#define AML_SLEEP_OP                (u16) 0x5b22
+#define AML_ACQUIRE_OP              (u16) 0x5b23
+#define AML_SIGNAL_OP               (u16) 0x5b24
+#define AML_WAIT_OP                 (u16) 0x5b25
+#define AML_RESET_OP                (u16) 0x5b26
+#define AML_RELEASE_OP              (u16) 0x5b27
+#define AML_FROM_BCD_OP             (u16) 0x5b28
+#define AML_TO_BCD_OP               (u16) 0x5b29
+#define AML_UNLOAD_OP               (u16) 0x5b2a
+#define AML_REVISION_OP             (u16) 0x5b30
+#define AML_DEBUG_OP                (u16) 0x5b31
+#define AML_FATAL_OP                (u16) 0x5b32
+#define AML_REGION_OP               (u16) 0x5b80
+#define AML_FIELD_OP                (u16) 0x5b81
+#define AML_DEVICE_OP               (u16) 0x5b82
+#define AML_PROCESSOR_OP            (u16) 0x5b83
+#define AML_POWER_RES_OP            (u16) 0x5b84
+#define AML_THERMAL_ZONE_OP         (u16) 0x5b85
+#define AML_INDEX_FIELD_OP          (u16) 0x5b86
+#define AML_BANK_FIELD_OP           (u16) 0x5b87
+#define AML_DATA_REGION_OP          (u16) 0x5b88     /* ACPI 2.0 */
+
+
+/* Bogus opcodes (they are actually two separate opcodes) */
+
+#define AML_LGREATEREQUAL_OP        (u16) 0x9295
+#define AML_LLESSEQUAL_OP           (u16) 0x9294
+#define AML_LNOTEQUAL_OP            (u16) 0x9293
+
+
+/*
+ * Internal opcodes
+ * Use only "Unknown" AML opcodes, don't attempt to use
+ * any valid ACPI ASCII values (A-Z, 0-9, '-')
+ */
+
+#define AML_INT_NAMEPATH_OP         (u16) 0x002d
+#define AML_INT_NAMEDFIELD_OP       (u16) 0x0030
+#define AML_INT_RESERVEDFIELD_OP    (u16) 0x0031
+#define AML_INT_ACCESSFIELD_OP      (u16) 0x0032
+#define AML_INT_BYTELIST_OP         (u16) 0x0033
+#define AML_INT_STATICSTRING_OP     (u16) 0x0034
+#define AML_INT_METHODCALL_OP       (u16) 0x0035
+#define AML_INT_RETURN_VALUE_OP     (u16) 0x0036
+#define AML_INT_EVAL_SUBTREE_OP     (u16) 0x0037
+
+
+#define ARG_NONE                    0x0
+
+/*
+ * Argument types for the AML Parser
+ * Each field in the arg_types u32 is 5 bits, allowing for a maximum of 6 arguments.
+ * There can be up to 31 unique argument types
+ * Zero is reserved as end-of-list indicator
+ */
+
+#define ARGP_BYTEDATA               0x01
+#define ARGP_BYTELIST               0x02
+#define ARGP_CHARLIST               0x03
+#define ARGP_DATAOBJ                0x04
+#define ARGP_DATAOBJLIST            0x05
+#define ARGP_DWORDDATA              0x06
+#define ARGP_FIELDLIST              0x07
+#define ARGP_NAME                   0x08
+#define ARGP_NAMESTRING             0x09
+#define ARGP_OBJLIST                0x0A
+#define ARGP_PKGLENGTH              0x0B
+#define ARGP_SUPERNAME              0x0C
+#define ARGP_TARGET                 0x0D
+#define ARGP_TERMARG                0x0E
+#define ARGP_TERMLIST               0x0F
+#define ARGP_WORDDATA               0x10
+#define ARGP_QWORDDATA              0x11
+#define ARGP_SIMPLENAME             0x12
+
+/*
+ * Resolved argument types for the AML Interpreter
+ * Each field in the arg_types u32 is 5 bits, allowing for a maximum of 6 arguments.
+ * There can be up to 31 unique argument types (0 is end-of-arg-list indicator)
+ *
+ * Note1: These values are completely independent from the ACPI_TYPEs
+ *        i.e., ARGI_INTEGER != ACPI_TYPE_INTEGER
+ *
+ * Note2: If and when 5 bits becomes insufficient, it would probably be best
+ * to convert to a 6-byte array of argument types, allowing 8 bits per argument.
+ */
+
+/* Single, simple types */
+
+#define ARGI_ANYTYPE                0x01    /* Don't care */
+#define ARGI_PACKAGE                0x02
+#define ARGI_EVENT                  0x03
+#define ARGI_MUTEX                  0x04
+#define ARGI_DDBHANDLE              0x05
+
+/* Interchangeable types (via implicit conversion) */
+
+#define ARGI_INTEGER                0x06
+#define ARGI_STRING                 0x07
+#define ARGI_BUFFER                 0x08
+#define ARGI_BUFFER_OR_STRING       0x09    /* Used by MID op only */
+#define ARGI_COMPUTEDATA            0x0A    /* Buffer, String, or Integer */
+
+/* Reference objects */
+
+#define ARGI_INTEGER_REF            0x0B
+#define ARGI_OBJECT_REF             0x0C
+#define ARGI_DEVICE_REF             0x0D
+#define ARGI_REFERENCE              0x0E
+#define ARGI_TARGETREF              0x0F    /* Target, subject to implicit conversion */
+#define ARGI_FIXED_TARGET           0x10    /* Target, no implicit conversion */
+#define ARGI_SIMPLE_TARGET          0x11    /* Name, Local, Arg -- no implicit conversion */
+
+/* Multiple/complex types */
+
+#define ARGI_DATAOBJECT             0x12    /* Buffer, String, package or reference to a Node - Used only by size_of operator*/
+#define ARGI_COMPLEXOBJ             0x13    /* Buffer, String, or package (Used by INDEX op only) */
+#define ARGI_REF_OR_STRING          0x14    /* Reference or String (Used by DEREFOF op only) */
+#define ARGI_REGION_OR_FIELD        0x15    /* Used by LOAD op only */
+
+/* Note: types above can expand to 0x1F maximum */
+
+#define ARGI_INVALID_OPCODE         0xFFFFFFFF
+
+
+/*
+ * hash offsets
+ */
+#define AML_EXTOP_HASH_OFFSET       22
+#define AML_LNOT_HASH_OFFSET        19
+
+
+/*
+ * opcode groups and types
+ */
+
+#define OPGRP_NAMED                 0x01
+#define OPGRP_FIELD                 0x02
+#define OPGRP_BYTELIST              0x04
+
+
+/*
+ * Opcode information
+ */
+
+/* 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
+
+/* Convenient flag groupings */
+
+#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
+#define AML_FLAGS_EXEC_1A_1T_1R     AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* monadic2_r */
+#define AML_FLAGS_EXEC_2A_0T_0R     AML_HAS_ARGS                                   /* Dyadic1   */
+#define AML_FLAGS_EXEC_2A_0T_1R     AML_HAS_ARGS |                  AML_HAS_RETVAL /* Dyadic2   */
+#define AML_FLAGS_EXEC_2A_1T_1R     AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* dyadic2_r  */
+#define AML_FLAGS_EXEC_2A_2T_1R     AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL
+#define AML_FLAGS_EXEC_3A_0T_0R     AML_HAS_ARGS
+#define AML_FLAGS_EXEC_3A_1T_1R     AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL
+#define AML_FLAGS_EXEC_6A_0T_1R     AML_HAS_ARGS |                  AML_HAS_RETVAL
+
+
+/*
+ * 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
+/* End of types used in dispatch table */
+
+#define AML_TYPE_LITERAL            0x0B
+#define AML_TYPE_CONSTANT           0x0C
+#define AML_TYPE_METHOD_ARGUMENT    0x0D
+#define AML_TYPE_LOCAL_VARIABLE     0x0E
+#define AML_TYPE_DATA_TERM          0x0F
+
+/* Generic for an op that returns a value */
+
+#define AML_TYPE_METHOD_CALL        0x10
+
+/* Misc */
+
+#define AML_TYPE_CREATE_FIELD       0x11
+#define AML_TYPE_CREATE_OBJECT      0x12
+#define AML_TYPE_CONTROL            0x13
+#define AML_TYPE_NAMED_NO_OBJ       0x14
+#define AML_TYPE_NAMED_FIELD        0x15
+#define AML_TYPE_NAMED_SIMPLE       0x16
+#define AML_TYPE_NAMED_COMPLEX      0x17
+#define AML_TYPE_RETURN             0x18
+
+#define AML_TYPE_UNDEFINED          0x19
+#define AML_TYPE_BOGUS              0x1A
+
+
+/*
+ * Opcode classes
+ */
+#define AML_CLASS_EXECUTE           0x00
+#define AML_CLASS_CREATE            0x01
+#define AML_CLASS_ARGUMENT          0x02
+#define AML_CLASS_NAMED_OBJECT      0x03
+#define AML_CLASS_CONTROL           0x04
+#define AML_CLASS_ASCII             0x05
+#define AML_CLASS_PREFIX            0x06
+#define AML_CLASS_INTERNAL          0x07
+#define AML_CLASS_RETURN_VALUE      0x08
+#define AML_CLASS_METHOD_CALL       0x09
+#define AML_CLASS_UNKNOWN           0x0A
+
+
+/* Predefined Operation Region space_iDs */
+
+typedef enum
+{
+	REGION_MEMORY                   = 0,
+	REGION_IO,
+	REGION_PCI_CONFIG,
+	REGION_EC,
+	REGION_SMBUS,
+	REGION_CMOS,
+	REGION_PCI_BAR,
+	REGION_DATA_TABLE,              /* Internal use only */
+	REGION_FIXED_HW                 = 0x7F
+
+} AML_REGION_TYPES;
+
+
+/* Comparison operation codes for match_op operator */
+
+typedef enum
+{
+	MATCH_MTR                       = 0,
+	MATCH_MEQ                       = 1,
+	MATCH_MLE                       = 2,
+	MATCH_MLT                       = 3,
+	MATCH_MGE                       = 4,
+	MATCH_MGT                       = 5
+
+} AML_MATCH_OPERATOR;
+
+#define MAX_MATCH_OPERATOR          5
+
+
+/*
+ * field_flags
+ *
+ * This byte is extracted from the AML and includes three separate
+ * pieces of information about the field:
+ * 1) The field access type
+ * 2) The field update rule
+ * 3) The lock rule for the field
+ *
+ * Bits 00 - 03 : access_type (any_acc, byte_acc, etc.)
+ *      04      : lock_rule (1 == Lock)
+ *      05 - 06 : update_rule
+ */
+#define AML_FIELD_ACCESS_TYPE_MASK  0x0F
+#define AML_FIELD_LOCK_RULE_MASK    0x10
+#define AML_FIELD_UPDATE_RULE_MASK  0x60
+
+
+/* 1) Field Access Types */
+
+typedef enum
+{
+	AML_FIELD_ACCESS_ANY            = 0x00,
+	AML_FIELD_ACCESS_BYTE           = 0x01,
+	AML_FIELD_ACCESS_WORD           = 0x02,
+	AML_FIELD_ACCESS_DWORD          = 0x03,
+	AML_FIELD_ACCESS_QWORD          = 0x04,    /* ACPI 2.0 */
+	AML_FIELD_ACCESS_BUFFER         = 0x05     /* ACPI 2.0 */
+
+} AML_ACCESS_TYPE;
+
+
+/* 2) Field Lock Rules */
+
+typedef enum
+{
+	AML_FIELD_LOCK_NEVER            = 0x00,
+	AML_FIELD_LOCK_ALWAYS           = 0x10
+
+} AML_LOCK_RULE;
+
+
+/* 3) Field Update Rules */
+
+typedef enum
+{
+	AML_FIELD_UPDATE_PRESERVE       = 0x00,
+	AML_FIELD_UPDATE_WRITE_AS_ONES  = 0x20,
+	AML_FIELD_UPDATE_WRITE_AS_ZEROS = 0x40
+
+} AML_UPDATE_RULE;
+
+
+/*
+ * Field Access Attributes.
+ * This byte is extracted from the AML via the
+ * access_as keyword
+ */
+typedef enum
+{
+	AML_FIELD_ATTRIB_SMB_QUICK      = 0x02,
+	AML_FIELD_ATTRIB_SMB_SEND_RCV   = 0x04,
+	AML_FIELD_ATTRIB_SMB_BYTE       = 0x06,
+	AML_FIELD_ATTRIB_SMB_WORD       = 0x08,
+	AML_FIELD_ATTRIB_SMB_BLOCK      = 0x0A,
+	AML_FIELD_ATTRIB_SMB_WORD_CALL  = 0x0C,
+	AML_FIELD_ATTRIB_SMB_BLOCK_CALL = 0x0D
+
+} AML_ACCESS_ATTRIBUTE;
+
+
+/* bit fields in method_flags byte */
+
+#define METHOD_FLAGS_ARG_COUNT      0x07
+#define METHOD_FLAGS_SERIALIZED     0x08
+#define METHOD_FLAGS_SYNCH_LEVEL    0xF0
+
+
+#endif /* __AMLCODE_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/amlresrc.h linux-2.4.22-pre2/include/acpi/amlresrc.h
--- linux-2.4.21/include/acpi/amlresrc.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/amlresrc.h	2003-06-26 21:43:28.000000000 +0000
@@ -0,0 +1,329 @@
+
+/******************************************************************************
+ *
+ * Module Name: amlresrc.h - AML resource descriptors
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+
+#ifndef __AMLRESRC_H
+#define __AMLRESRC_H
+
+
+#define ASL_RESNAME_ADDRESS                     "_ADR"
+#define ASL_RESNAME_ALIGNMENT                   "_ALN"
+#define ASL_RESNAME_ADDRESSSPACE                "_ASI"
+#define ASL_RESNAME_BASEADDRESS                 "_BAS"
+#define ASL_RESNAME_BUSMASTER                   "_BM_"  /* Master(1), Slave(0) */
+#define ASL_RESNAME_DECODE                      "_DEC"
+#define ASL_RESNAME_DMA                         "_DMA"
+#define ASL_RESNAME_DMATYPE                     "_TYP"  /* Compatible(0), A(1), B(2), F(3) */
+#define ASL_RESNAME_GRANULARITY                 "_GRA"
+#define ASL_RESNAME_INTERRUPT                   "_INT"
+#define ASL_RESNAME_INTERRUPTLEVEL              "_LL_"  /* active_lo(1), active_hi(0) */
+#define ASL_RESNAME_INTERRUPTSHARE              "_SHR"  /* Shareable(1), no_share(0) */
+#define ASL_RESNAME_INTERRUPTTYPE               "_HE_"  /* Edge(1), Level(0) */
+#define ASL_RESNAME_LENGTH                      "_LEN"
+#define ASL_RESNAME_MEMATTRIBUTES               "_MTP"  /* Memory(0), Reserved(1), ACPI(2), NVS(3) */
+#define ASL_RESNAME_MEMTYPE                     "_MEM"  /* non_cache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */
+#define ASL_RESNAME_MAXADDR                     "_MAX"
+#define ASL_RESNAME_MINADDR                     "_MIN"
+#define ASL_RESNAME_MAXTYPE                     "_MAF"
+#define ASL_RESNAME_MINTYPE                     "_MIF"
+#define ASL_RESNAME_REGISTERBITOFFSET           "_RBO"
+#define ASL_RESNAME_REGISTERBITWIDTH            "_RBW"
+#define ASL_RESNAME_RANGETYPE                   "_RNG"
+#define ASL_RESNAME_READWRITETYPE               "_RW_"  /* read_only(0), Writeable (1) */
+#define ASL_RESNAME_TRANSLATION                 "_TRA"
+#define ASL_RESNAME_TRANSTYPE                   "_TRS"  /* Sparse(1), Dense(0) */
+#define ASL_RESNAME_TYPE                        "_TTP"  /* Translation(1), Static (0) */
+#define ASL_RESNAME_XFERTYPE                    "_SIz"  /* 8(0), 8_and16(1), 16(2) */
+
+
+/* Default sizes for "small" resource descriptors */
+
+#define ASL_RDESC_IRQ_SIZE                      0x02
+#define ASL_RDESC_DMA_SIZE                      0x02
+#define ASL_RDESC_ST_DEPEND_SIZE                0x00
+#define ASL_RDESC_END_DEPEND_SIZE               0x00
+#define ASL_RDESC_IO_SIZE                       0x07
+#define ASL_RDESC_FIXED_IO_SIZE                 0x03
+#define ASL_RDESC_END_TAG_SIZE                  0x01
+
+
+struct asl_resource_node
+{
+	u32                                 buffer_length;
+	void                                *buffer;
+	struct asl_resource_node            *next;
+};
+
+
+/*
+ * Resource descriptors defined in the ACPI specification.
+ *
+ * Alignment must be BYTE because these descriptors
+ * are used to overlay the AML byte stream.
+ */
+#pragma pack(1)
+
+struct asl_irq_format_desc
+{
+	u8                                  descriptor_type;
+	u16                                 irq_mask;
+	u8                                  flags;
+};
+
+
+struct asl_irq_noflags_desc
+{
+	u8                                  descriptor_type;
+	u16                                 irq_mask;
+};
+
+
+struct asl_dma_format_desc
+{
+	u8                                  descriptor_type;
+	u8                                  dma_channel_mask;
+	u8                                  flags;
+};
+
+
+struct asl_start_dependent_desc
+{
+	u8                                  descriptor_type;
+	u8                                  flags;
+};
+
+
+struct asl_start_dependent_noprio_desc
+{
+	u8                                  descriptor_type;
+};
+
+
+struct asl_end_dependent_desc
+{
+	u8                                  descriptor_type;
+};
+
+
+struct asl_io_port_desc
+{
+	u8                                  descriptor_type;
+	u8                                  information;
+	u16                                 address_min;
+	u16                                 address_max;
+	u8                                  alignment;
+	u8                                  length;
+};
+
+
+struct asl_fixed_io_port_desc
+{
+	u8                                  descriptor_type;
+	u16                                 base_address;
+	u8                                  length;
+};
+
+
+struct asl_small_vendor_desc
+{
+	u8                                  descriptor_type;
+	u8                                  vendor_defined[7];
+};
+
+
+struct asl_end_tag_desc
+{
+	u8                                  descriptor_type;
+	u8                                  checksum;
+};
+
+
+/* LARGE descriptors */
+
+struct asl_memory_24_desc
+{
+	u8                                  descriptor_type;
+	u16                                 length;
+	u8                                  information;
+	u16                                 address_min;
+	u16                                 address_max;
+	u16                                 alignment;
+	u16                                 range_length;
+};
+
+
+struct asl_large_vendor_desc
+{
+	u8                                  descriptor_type;
+	u16                                 length;
+	u8                                  vendor_defined[1];
+};
+
+
+struct asl_memory_32_desc
+{
+	u8                                  descriptor_type;
+	u16                                 length;
+	u8                                  information;
+	u32                                 address_min;
+	u32                                 address_max;
+	u32                                 alignment;
+	u32                                 range_length;
+};
+
+
+struct asl_fixed_memory_32_desc
+{
+	u8                                  descriptor_type;
+	u16                                 length;
+	u8                                  information;
+	u32                                 base_address;
+	u32                                 range_length;
+};
+
+
+struct asl_qword_address_desc
+{
+	u8                                  descriptor_type;
+	u16                                 length;
+	u8                                  resource_type;
+	u8                                  flags;
+	u8                                  specific_flags;
+	u64                                 granularity;
+	u64                                 address_min;
+	u64                                 address_max;
+	u64                                 translation_offset;
+	u64                                 address_length;
+	u8                                  optional_fields[2];
+};
+
+
+struct asl_dword_address_desc
+{
+	u8                                  descriptor_type;
+	u16                                 length;
+	u8                                  resource_type;
+	u8                                  flags;
+	u8                                  specific_flags;
+	u32                                 granularity;
+	u32                                 address_min;
+	u32                                 address_max;
+	u32                                 translation_offset;
+	u32                                 address_length;
+	u8                                  optional_fields[2];
+};
+
+
+struct asl_word_address_desc
+{
+	u8                                  descriptor_type;
+	u16                                 length;
+	u8                                  resource_type;
+	u8                                  flags;
+	u8                                  specific_flags;
+	u16                                 granularity;
+	u16                                 address_min;
+	u16                                 address_max;
+	u16                                 translation_offset;
+	u16                                 address_length;
+	u8                                  optional_fields[2];
+};
+
+
+struct asl_extended_xrupt_desc
+{
+	u8                                  descriptor_type;
+	u16                                 length;
+	u8                                  flags;
+	u8                                  table_length;
+	u32                                 interrupt_number[1];
+	/* res_source_index, res_source optional fields follow */
+};
+
+
+struct asl_general_register_desc
+{
+	u8                                  descriptor_type;
+	u16                                 length;
+	u8                                  address_space_id;
+	u8                                  bit_width;
+	u8                                  bit_offset;
+	u8                                  reserved;
+	u64                                 address;
+};
+
+/* restore default alignment */
+
+#pragma pack()
+
+/* Union of all resource descriptors, sow we can allocate the worst case */
+
+union asl_resource_desc
+{
+	struct asl_irq_format_desc          irq;
+	struct asl_dma_format_desc          dma;
+	struct asl_start_dependent_desc     std;
+	struct asl_end_dependent_desc       end;
+	struct asl_io_port_desc             iop;
+	struct asl_fixed_io_port_desc       fio;
+	struct asl_small_vendor_desc        smv;
+	struct asl_end_tag_desc             et;
+
+	struct asl_memory_24_desc           M24;
+	struct asl_large_vendor_desc        lgv;
+	struct asl_memory_32_desc           M32;
+	struct asl_fixed_memory_32_desc     F32;
+	struct asl_qword_address_desc       qas;
+	struct asl_dword_address_desc       das;
+	struct asl_word_address_desc        was;
+	struct asl_extended_xrupt_desc      exx;
+	struct asl_general_register_desc    grg;
+	u32                                 u32_item;
+	u16                                 u16_item;
+	u8                                  U8item;
+};
+
+
+#endif
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/platform/acenv.h linux-2.4.22-pre2/include/acpi/platform/acenv.h
--- linux-2.4.21/include/acpi/platform/acenv.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/platform/acenv.h	2003-06-26 21:43:13.000000000 +0000
@@ -0,0 +1,363 @@
+/******************************************************************************
+ *
+ * Name: acenv.h - Generation environment specific items
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACENV_H__
+#define __ACENV_H__
+
+
+/*
+ * Configuration for ACPI tools and utilities
+ */
+
+#ifdef _ACPI_DUMP_APP
+#ifndef MSDOS
+#define ACPI_DEBUG_OUTPUT
+#endif
+#define ACPI_APPLICATION
+#define ACPI_DISASSEMBLER
+#define ACPI_NO_METHOD_EXECUTION
+#define ACPI_USE_SYSTEM_CLIBRARY
+#endif
+
+#ifdef _ACPI_EXEC_APP
+#undef DEBUGGER_THREADING
+#define DEBUGGER_THREADING      DEBUGGER_SINGLE_THREADED
+#define ACPI_DEBUG_OUTPUT
+#define ACPI_APPLICATION
+#define ACPI_DEBUGGER
+#define ACPI_DISASSEMBLER
+#define ACPI_USE_SYSTEM_CLIBRARY
+#endif
+
+#ifdef _ACPI_ASL_COMPILER
+#define ACPI_DEBUG_OUTPUT
+#define ACPI_APPLICATION
+#define ACPI_DISASSEMBLER
+#define ACPI_CONSTANT_EVAL_ONLY
+#define ACPI_USE_SYSTEM_CLIBRARY
+#endif
+
+/*
+ * Environment configuration.  The purpose of this file is to interface to the
+ * local generation environment.
+ *
+ * 1) ACPI_USE_SYSTEM_CLIBRARY - Define this if linking to an actual C library.
+ *      Otherwise, local versions of string/memory functions will be used.
+ * 2) ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and
+ *      the standard header files may be used.
+ *
+ * The ACPI subsystem only uses low level C library functions that do not call
+ * operating system services and may therefore be inlined in the code.
+ *
+ * It may be necessary to tailor these include files to the target
+ * generation environment.
+ *
+ *
+ * Functions and constants used from each header:
+ *
+ * string.h:    memcpy
+ *              memset
+ *              strcat
+ *              strcmp
+ *              strcpy
+ *              strlen
+ *              strncmp
+ *              strncat
+ *              strncpy
+ *
+ * stdlib.h:    strtoul
+ *
+ * stdarg.h:    va_list
+ *              va_arg
+ *              va_start
+ *              va_end
+ *
+ */
+
+/*! [Begin] no source code translation */
+
+#if defined(__linux__)
+#include "aclinux.h"
+
+#elif defined(_AED_EFI)
+#include "acefi.h"
+
+#elif defined(WIN32)
+#include "acwin.h"
+
+#elif defined(WIN64)
+#include "acwin64.h"
+
+#elif defined(MSDOS)        /* Must appear after WIN32 and WIN64 check */
+#include "acdos16.h"
+
+#elif defined(__FreeBSD__)
+#include "acfreebsd.h"
+
+#elif defined(MODESTO)
+#include "acmodesto.h"
+
+#elif defined(NETWARE)
+#include "acnetware.h"
+
+#else
+
+/* All other environments */
+
+#define ACPI_USE_STANDARD_HEADERS
+
+#define COMPILER_DEPENDENT_INT64   long long
+#define COMPILER_DEPENDENT_UINT64  unsigned long long
+
+
+/* Name of host operating system (returned by the _OS_ namespace object) */
+
+#define ACPI_OS_NAME         "Intel ACPI/CA Core Subsystem"
+
+/* This macro is used to tag functions as "printf-like" because
+ * some compilers can catch printf format string problems. MSVC
+ * doesn't, so this is proprocessed away.
+ */
+#define ACPI_PRINTF_LIKE_FUNC
+
+#endif
+
+/*
+ * Memory allocation tracking.  Used only if
+ * 1) This is the debug version
+ * 2) This is NOT a 16-bit version of the code (not enough real-mode memory)
+ */
+#ifdef ACPI_DEBUG_OUTPUT
+#if ACPI_MACHINE_WIDTH != 16
+#define ACPI_DBG_TRACK_ALLOCATIONS
+#endif
+#endif
+
+/*! [End] no source code translation !*/
+
+
+/*
+ * Debugger threading model
+ * Use single threaded if the entire subsystem is contained in an application
+ * Use multiple threaded when the subsystem is running in the kernel.
+ *
+ * By default the model is single threaded if ACPI_APPLICATION is set,
+ * multi-threaded if ACPI_APPLICATION is not set.
+ */
+#define DEBUGGER_SINGLE_THREADED    0
+#define DEBUGGER_MULTI_THREADED     1
+
+#ifdef ACPI_APPLICATION
+#define DEBUGGER_THREADING          DEBUGGER_SINGLE_THREADED
+
+#else
+#define DEBUGGER_THREADING          DEBUGGER_MULTI_THREADED
+#endif
+
+
+/******************************************************************************
+ *
+ * C library configuration
+ *
+ *****************************************************************************/
+
+#ifdef ACPI_USE_SYSTEM_CLIBRARY
+/*
+ * Use the standard C library headers.
+ * We want to keep these to a minimum.
+ */
+
+#ifdef ACPI_USE_STANDARD_HEADERS
+/*
+ * Use the standard headers from the standard locations
+ */
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#endif /* ACPI_USE_STANDARD_HEADERS */
+
+/*
+ * We will be linking to the standard Clib functions
+ */
+
+#define ACPI_STRSTR(s1,s2)      strstr((s1), (s2))
+#define ACPI_STRUPR(s)          (void) acpi_ut_strupr ((s))
+#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))
+#define ACPI_STRNCMP(d,s,n)     strncmp((d), (s), (acpi_size)(n))
+#define ACPI_STRCMP(d,s)        strcmp((d), (s))
+#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_MEMCPY(d,s,n)      (void) memcpy((d), (s), (acpi_size)(n))
+#define ACPI_MEMSET(d,s,n)      (void) memset((d), (s), (acpi_size)(n))
+
+#define ACPI_TOUPPER            toupper
+#define ACPI_TOLOWER            tolower
+#define ACPI_IS_XDIGIT          isxdigit
+#define ACPI_IS_DIGIT           isdigit
+#define ACPI_IS_SPACE           isspace
+#define ACPI_IS_UPPER           isupper
+#define ACPI_IS_PRINT           isprint
+#define ACPI_IS_ALPHA           isalpha
+#define ACPI_IS_ASCII           isascii
+
+/******************************************************************************
+ *
+ * Not using native C library, use local implementations
+ *
+ *****************************************************************************/
+#else
+
+/*
+ * Use local definitions of C library macros and functions
+ * NOTE: The function implementations may not be as efficient
+ * as an inline or assembly code implementation provided by a
+ * native C library.
+ */
+
+#ifndef va_arg
+
+#ifndef _VALIST
+#define _VALIST
+typedef char *va_list;
+#endif /* _VALIST */
+
+/*
+ * Storage alignment properties
+ */
+
+#define  _AUPBND                (sizeof (acpi_native_int) - 1)
+#define  _ADNBND                (sizeof (acpi_native_int) - 1)
+
+/*
+ * Variable argument list macro definitions
+ */
+
+#define _bnd(X, bnd)            (((sizeof (X)) + (bnd)) & (~(bnd)))
+#define va_arg(ap, T)           (*(T *)(((ap) += (_bnd (T, _AUPBND))) - (_bnd (T,_ADNBND))))
+#define va_end(ap)              (void) 0
+#define va_start(ap, A)         (void) ((ap) = (((char *) &(A)) + (_bnd (A,_AUPBND))))
+
+#endif /* va_arg */
+
+
+#define ACPI_STRSTR(s1,s2)      acpi_ut_strstr ((s1), (s2))
+#define ACPI_STRUPR(s)          (void) acpi_ut_strupr ((s))
+#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))
+#define ACPI_STRNCMP(d,s,n)     acpi_ut_strncmp ((d), (s), (acpi_size)(n))
+#define ACPI_STRCMP(d,s)        acpi_ut_strcmp ((d), (s))
+#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_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
+#define ACPI_TOLOWER            acpi_ut_to_lower
+
+#endif /* ACPI_USE_SYSTEM_CLIBRARY */
+
+
+/******************************************************************************
+ *
+ * Assembly code macros
+ *
+ *****************************************************************************/
+
+/*
+ * Handle platform- and compiler-specific assembly language differences.
+ * These should already have been defined by the platform includes above.
+ *
+ * Notes:
+ * 1) Interrupt 3 is used to break into a debugger
+ * 2) Interrupts are turned off during ACPI register setup
+ */
+
+/* Unrecognized compiler, use defaults */
+
+#ifndef ACPI_ASM_MACROS
+
+/*
+ * Calling conventions:
+ *
+ * ACPI_SYSTEM_XFACE        - Interfaces to host OS (handlers, threads)
+ * ACPI_EXTERNAL_XFACE      - External ACPI interfaces
+ * ACPI_INTERNAL_XFACE      - Internal ACPI interfaces
+ * ACPI_INTERNAL_VAR_XFACE  - Internal variable-parameter list interfaces
+ */
+#define ACPI_SYSTEM_XFACE
+#define ACPI_EXTERNAL_XFACE
+#define ACPI_INTERNAL_XFACE
+#define ACPI_INTERNAL_VAR_XFACE
+
+#define ACPI_ASM_MACROS
+#define BREAKPOINT3
+#define ACPI_DISABLE_IRQS()
+#define ACPI_ENABLE_IRQS()
+#define ACPI_ACQUIRE_GLOBAL_LOCK(Glptr, acq)
+#define ACPI_RELEASE_GLOBAL_LOCK(Glptr, acq)
+
+#endif /* ACPI_ASM_MACROS */
+
+
+#ifdef ACPI_APPLICATION
+
+/* Don't want software interrupts within a ring3 application */
+
+#undef BREAKPOINT3
+#define BREAKPOINT3
+#endif
+
+
+/******************************************************************************
+ *
+ * Compiler-specific information is contained in the compiler-specific
+ * headers.
+ *
+ *****************************************************************************/
+#endif /* __ACENV_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/platform/acgcc.h linux-2.4.22-pre2/include/acpi/platform/acgcc.h
--- linux-2.4.21/include/acpi/platform/acgcc.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/platform/acgcc.h	2003-06-26 21:43:33.000000000 +0000
@@ -0,0 +1,59 @@
+/******************************************************************************
+ *
+ * Name: acgcc.h - GCC specific defines, etc.
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACGCC_H__
+#define __ACGCC_H__
+
+/* This macro is used to tag functions as "printf-like" because
+ * some compilers (like GCC) can catch printf format string problems.
+ */
+#define ACPI_PRINTF_LIKE_FUNC __attribute__ ((__format__ (__printf__, 4, 5)))
+
+/* Some compilers complain about unused variables. Sometimes we don't want to
+ * use all the variables (most specifically for _THIS_MODULE). This allow us
+ * to to tell the compiler warning in a per-variable manner that a variable
+ * is unused.
+ */
+#define ACPI_UNUSED_VAR __attribute__ ((unused))
+
+#endif /* __ACGCC_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/acpi/platform/aclinux.h linux-2.4.22-pre2/include/acpi/platform/aclinux.h
--- linux-2.4.21/include/acpi/platform/aclinux.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/acpi/platform/aclinux.h	2003-06-26 21:43:30.000000000 +0000
@@ -0,0 +1,92 @@
+/******************************************************************************
+ *
+ * Name: aclinux.h - OS specific defines, etc.
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * 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.
+ */
+
+#ifndef __ACLINUX_H__
+#define __ACLINUX_H__
+
+#define ACPI_OS_NAME                "Linux"
+
+#define ACPI_USE_SYSTEM_CLIBRARY
+#define ACPI_USE_DO_WHILE_0
+
+#ifdef __KERNEL__
+
+#include <linux/config.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <linux/ctype.h>
+#include <asm/system.h>
+#include <asm/atomic.h>
+#include <asm/div64.h>
+#include <asm/acpi.h>
+
+#define strtoul simple_strtoul
+
+#define ACPI_MACHINE_WIDTH  BITS_PER_LONG
+
+#else /* !__KERNEL__ */
+
+#include <stdarg.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <unistd.h>
+
+#if defined(__ia64__) || defined(__x86_64__)
+#define ACPI_MACHINE_WIDTH          64
+#define COMPILER_DEPENDENT_INT64    long
+#define COMPILER_DEPENDENT_UINT64   unsigned long
+#else
+#define ACPI_MACHINE_WIDTH          32
+#define COMPILER_DEPENDENT_INT64    long long
+#define COMPILER_DEPENDENT_UINT64   unsigned long long
+#define ACPI_USE_NATIVE_DIVIDE
+#endif
+
+#endif /* __KERNEL__ */
+
+/* Linux uses GCC */
+
+#include "acgcc.h"
+
+#endif /* __ACLINUX_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-alpha/core_t2.h linux-2.4.22-pre2/include/asm-alpha/core_t2.h
--- linux-2.4.21/include/asm-alpha/core_t2.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-alpha/core_t2.h	2003-06-26 21:43:21.000000000 +0000
@@ -3,8 +3,9 @@
 
 #include <linux/config.h>
 #include <linux/types.h>
+#include <linux/spinlock.h>
 #include <asm/compiler.h>
-
+#include <asm/system.h>
 
 /*
  * T2 is the internal name for the core logic chipset which provides
@@ -22,6 +23,7 @@
 #define T2_MEM_R1_MASK 0x07ffffff  /* Mem sparse region 1 mask is 26 bits */
 
 /* GAMMA-SABLE is a SABLE with EV5-based CPUs */
+/* All LYNX machines, EV4 or EV5, use the GAMMA bias also */
 #define _GAMMA_BIAS		0x8000000000UL
 
 #if defined(CONFIG_ALPHA_GENERIC)
@@ -57,10 +59,33 @@
 #define T2_WMASK2		(IDENT_ADDR + GAMMA_BIAS + 0x38e0001c0UL)
 #define T2_TBASE2		(IDENT_ADDR + GAMMA_BIAS + 0x38e0001e0UL)
 #define T2_TLBBR		(IDENT_ADDR + GAMMA_BIAS + 0x38e000200UL)
-
+#define T2_IVR			(IDENT_ADDR + GAMMA_BIAS + 0x38e000220UL)
 #define T2_HAE_3		(IDENT_ADDR + GAMMA_BIAS + 0x38e000240UL)
 #define T2_HAE_4		(IDENT_ADDR + GAMMA_BIAS + 0x38e000260UL)
 
+/* The CSRs below are T3/T4 only */
+#define T2_WBASE3		(IDENT_ADDR + GAMMA_BIAS + 0x38e000280UL)
+#define T2_WMASK3		(IDENT_ADDR + GAMMA_BIAS + 0x38e0002a0UL)
+#define T2_TBASE3		(IDENT_ADDR + GAMMA_BIAS + 0x38e0002c0UL)
+
+#define T2_TDR0			(IDENT_ADDR + GAMMA_BIAS + 0x38e000300UL)
+#define T2_TDR1			(IDENT_ADDR + GAMMA_BIAS + 0x38e000320UL)
+#define T2_TDR2			(IDENT_ADDR + GAMMA_BIAS + 0x38e000340UL)
+#define T2_TDR3			(IDENT_ADDR + GAMMA_BIAS + 0x38e000360UL)
+#define T2_TDR4			(IDENT_ADDR + GAMMA_BIAS + 0x38e000380UL)
+#define T2_TDR5			(IDENT_ADDR + GAMMA_BIAS + 0x38e0003a0UL)
+#define T2_TDR6			(IDENT_ADDR + GAMMA_BIAS + 0x38e0003c0UL)
+#define T2_TDR7			(IDENT_ADDR + GAMMA_BIAS + 0x38e0003e0UL)
+
+#define T2_WBASE4		(IDENT_ADDR + GAMMA_BIAS + 0x38e000400UL)
+#define T2_WMASK4		(IDENT_ADDR + GAMMA_BIAS + 0x38e000420UL)
+#define T2_TBASE4		(IDENT_ADDR + GAMMA_BIAS + 0x38e000440UL)
+
+#define T2_AIR			(IDENT_ADDR + GAMMA_BIAS + 0x38e000460UL)
+#define T2_VAR			(IDENT_ADDR + GAMMA_BIAS + 0x38e000480UL)
+#define T2_DIR			(IDENT_ADDR + GAMMA_BIAS + 0x38e0004a0UL)
+#define T2_ICE			(IDENT_ADDR + GAMMA_BIAS + 0x38e0004c0UL)
+
 #define T2_HAE_ADDRESS		T2_HAE_1
 
 /*  T2 CSRs are in the non-cachable primary IO space from 3.8000.0000 to
@@ -100,6 +125,9 @@
 #define T2_CPU1_BASE            (IDENT_ADDR + GAMMA_BIAS + 0x381000000L)
 #define T2_CPU2_BASE            (IDENT_ADDR + GAMMA_BIAS + 0x382000000L)
 #define T2_CPU3_BASE            (IDENT_ADDR + GAMMA_BIAS + 0x383000000L)
+
+#define T2_CPUn_BASE(n)		(T2_CPU0_BASE + (((n)&3) * 0x001000000L))
+
 #define T2_MEM0_BASE            (IDENT_ADDR + GAMMA_BIAS + 0x388000000L)
 #define T2_MEM1_BASE            (IDENT_ADDR + GAMMA_BIAS + 0x389000000L)
 #define T2_MEM2_BASE            (IDENT_ADDR + GAMMA_BIAS + 0x38a000000L)
@@ -408,87 +436,120 @@
 	set_hae(msb); \
 }
 
+static spinlock_t t2_hae_lock = SPIN_LOCK_UNLOCKED;
+
 __EXTERN_INLINE u8 t2_readb(unsigned long addr)
 {
 	unsigned long result, msb;
+	unsigned long flags;
+	spin_lock_irqsave(&t2_hae_lock, flags);
 
 	t2_set_hae;
 
 	result = *(vip) ((addr << 5) + T2_SPARSE_MEM + 0x00);
+	spin_unlock_irqrestore(&t2_hae_lock, flags);
 	return __kernel_extbl(result, addr & 3);
 }
 
 __EXTERN_INLINE u16 t2_readw(unsigned long addr)
 {
 	unsigned long result, msb;
+	unsigned long flags;
+	spin_lock_irqsave(&t2_hae_lock, flags);
 
 	t2_set_hae;
 
 	result = *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x08);
+	spin_unlock_irqrestore(&t2_hae_lock, flags);
 	return __kernel_extwl(result, addr & 3);
 }
 
-/* On SABLE with T2, we must use SPARSE memory even for 32-bit access. */
+/*
+ * On SABLE with T2, we must use SPARSE memory even for 32-bit access,
+ * because we cannot access all of DENSE without changing its HAE.
+ */
 __EXTERN_INLINE u32 t2_readl(unsigned long addr)
 {
-	unsigned long msb;
+	unsigned long result, msb;
+	unsigned long flags;
+	spin_lock_irqsave(&t2_hae_lock, flags);
 
 	t2_set_hae;
 
-	return *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x18);
+	result = *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x18);
+	spin_unlock_irqrestore(&t2_hae_lock, flags);
+	return result & 0xffffffffUL;
 }
 
 __EXTERN_INLINE u64 t2_readq(unsigned long addr)
 {
 	unsigned long r0, r1, work, msb;
+	unsigned long flags;
+	spin_lock_irqsave(&t2_hae_lock, flags);
 
 	t2_set_hae;
 
 	work = (addr << 5) + T2_SPARSE_MEM + 0x18;
 	r0 = *(vuip)(work);
 	r1 = *(vuip)(work + (4 << 5));
+	spin_unlock_irqrestore(&t2_hae_lock, flags);
 	return r1 << 32 | r0;
 }
 
 __EXTERN_INLINE void t2_writeb(u8 b, unsigned long addr)
 {
 	unsigned long msb, w;
+	unsigned long flags;
+	spin_lock_irqsave(&t2_hae_lock, flags);
 
 	t2_set_hae;
 
 	w = __kernel_insbl(b, addr & 3);
 	*(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x00) = w;
+	spin_unlock_irqrestore(&t2_hae_lock, flags);
 }
 
 __EXTERN_INLINE void t2_writew(u16 b, unsigned long addr)
 {
 	unsigned long msb, w;
+	unsigned long flags;
+	spin_lock_irqsave(&t2_hae_lock, flags);
 
 	t2_set_hae;
 
 	w = __kernel_inswl(b, addr & 3);
 	*(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x08) = w;
+	spin_unlock_irqrestore(&t2_hae_lock, flags);
 }
 
-/* On SABLE with T2, we must use SPARSE memory even for 32-bit access. */
+/*
+ * On SABLE with T2, we must use SPARSE memory even for 32-bit access,
+ * because we cannot access all of DENSE without changing its HAE.
+ */
 __EXTERN_INLINE void t2_writel(u32 b, unsigned long addr)
 {
 	unsigned long msb;
+	unsigned long flags;
+	spin_lock_irqsave(&t2_hae_lock, flags);
 
 	t2_set_hae;
 
 	*(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x18) = b;
+	spin_unlock_irqrestore(&t2_hae_lock, flags);
 }
 
 __EXTERN_INLINE void t2_writeq(u64 b, unsigned long addr)
 {
 	unsigned long msb, work;
+	unsigned long flags;
+	spin_lock_irqsave(&t2_hae_lock, flags);
 
 	t2_set_hae;
 
 	work = (addr << 5) + T2_SPARSE_MEM + 0x18;
 	*(vuip)work = b;
 	*(vuip)(work + (4 << 5)) = b >> 32;
+	spin_unlock_irqrestore(&t2_hae_lock, flags);
 }
 
 __EXTERN_INLINE unsigned long t2_ioremap(unsigned long addr, 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-alpha/elf.h linux-2.4.22-pre2/include/asm-alpha/elf.h
--- linux-2.4.21/include/asm-alpha/elf.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-alpha/elf.h	2003-06-26 21:43:22.000000000 +0000
@@ -52,6 +52,7 @@
 
 #define ELF_PLAT_INIT(_r)       _r->r0 = 0
 
+#ifdef __KERNEL__
 /* The registers are layed out in pt_regs for PAL and syscall
    convenience.  Re-order them for the linear elf_gregset_t.  */
 
@@ -59,6 +60,7 @@
 			    struct task_struct *);
 #define ELF_CORE_COPY_REGS(DEST, REGS) \
 	dump_elf_thread(DEST, REGS, current);
+#endif /* __KERNEL__ */
 
 /* This yields a mask that user programs can use to figure out what
    instruction set this CPU supports.  This is trivial on Alpha, 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-alpha/irq.h linux-2.4.22-pre2/include/asm-alpha/irq.h
--- linux-2.4.21/include/asm-alpha/irq.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-alpha/irq.h	2003-06-26 21:43:20.000000000 +0000
@@ -43,6 +43,7 @@
 # define NR_IRQS	40
 
 #elif defined(CONFIG_ALPHA_DP264) || \
+      defined(CONFIG_ALPHA_LYNX)  || \
       defined(CONFIG_ALPHA_SHARK) || \
       defined(CONFIG_ALPHA_EIGER)
 # define NR_IRQS	64
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-i386/acpi.h linux-2.4.22-pre2/include/asm-i386/acpi.h
--- linux-2.4.21/include/asm-i386/acpi.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-i386/acpi.h	2003-06-26 21:43:11.000000000 +0000
@@ -0,0 +1,173 @@
+/*
+ *  asm-i386/acpi.h
+ *
+ *  Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
+ *  Copyright (C) 2001 Patrick Mochel <mochel@osdl.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
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#ifndef _ASM_ACPI_H
+#define _ASM_ACPI_H
+
+#ifdef __KERNEL__
+
+#define COMPILER_DEPENDENT_INT64   long long
+#define COMPILER_DEPENDENT_UINT64  unsigned long long
+
+/*
+ * Calling conventions:
+ *
+ * ACPI_SYSTEM_XFACE        - Interfaces to host OS (handlers, threads)
+ * ACPI_EXTERNAL_XFACE      - External ACPI interfaces 
+ * ACPI_INTERNAL_XFACE      - Internal ACPI interfaces
+ * ACPI_INTERNAL_VAR_XFACE  - Internal variable-parameter list interfaces
+ */
+#define ACPI_SYSTEM_XFACE
+#define ACPI_EXTERNAL_XFACE
+#define ACPI_INTERNAL_XFACE
+#define ACPI_INTERNAL_VAR_XFACE
+
+/* Asm macros */
+
+#define ACPI_ASM_MACROS
+#define BREAKPOINT3
+#define ACPI_DISABLE_IRQS() __cli()
+#define ACPI_ENABLE_IRQS()  __sti()
+#define ACPI_FLUSH_CPU_CACHE()	wbinvd()
+
+/*
+ * A brief explanation as GNU inline assembly is a bit hairy
+ *  %0 is the output parameter in EAX ("=a")
+ *  %1 and %2 are the input parameters in ECX ("c")
+ *  and an immediate value ("i") respectively
+ *  All actual register references are preceded with "%%" as in "%%edx"
+ *  Immediate values in the assembly are preceded by "$" as in "$0x1"
+ *  The final asm parameter are the operation altered non-output registers.
+ */
+#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \
+    do { \
+        int dummy; \
+        asm("1:     movl (%1),%%eax;" \
+            "movl   %%eax,%%edx;" \
+            "andl   %2,%%edx;" \
+            "btsl   $0x1,%%edx;" \
+            "adcl   $0x0,%%edx;" \
+            "lock;  cmpxchgl %%edx,(%1);" \
+            "jnz    1b;" \
+            "cmpb   $0x3,%%dl;" \
+            "sbbl   %%eax,%%eax" \
+            :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~1L):"dx"); \
+    } while(0)
+
+#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \
+    do { \
+        int dummy; \
+        asm("1:     movl (%1),%%eax;" \
+            "movl   %%eax,%%edx;" \
+            "andl   %2,%%edx;" \
+            "lock;  cmpxchgl %%edx,(%1);" \
+            "jnz    1b;" \
+            "andl   $0x1,%%eax" \
+            :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~3L):"dx"); \
+    } while(0)
+
+
+/*
+ * Math helper asm macros
+ */
+#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
+        asm("divl %2;"        \
+        :"=a"(q32), "=d"(r32) \
+        :"r"(d32),            \
+        "0"(n_lo), "1"(n_hi))
+
+
+#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
+    asm("shrl   $1,%2;"             \
+        "rcrl   $1,%3;"             \
+        :"=r"(n_hi), "=r"(n_lo)     \
+        :"0"(n_hi), "1"(n_lo))
+
+
+#ifdef CONFIG_ACPI_HT_ONLY
+extern int acpi_lapic;
+#define acpi_ioapic 0
+#else
+#ifndef CONFIG_ACPI_BOOT
+#define acpi_lapic 0
+#define acpi_ioapic 0
+#else
+#ifdef CONFIG_X86_LOCAL_APIC
+extern int acpi_lapic;
+#else
+#define acpi_lapic 0
+#endif
+#ifdef CONFIG_X86_IO_APIC
+extern int acpi_ioapic;
+#else
+#define acpi_ioapic 0
+#endif
+#endif
+
+/* Fixmap pages to reserve for ACPI boot-time tables (see fixmap.h) */
+#define FIX_ACPI_PAGES 4
+
+#endif /*CONFIG_ACPI_BOOT*/
+
+#ifdef CONFIG_ACPI_SLEEP
+
+extern unsigned long saved_eip;
+extern unsigned long saved_esp;
+extern unsigned long saved_ebp;
+extern unsigned long saved_ebx;
+extern unsigned long saved_esi;
+extern unsigned long saved_edi;
+
+static inline void acpi_save_register_state(unsigned long return_point)
+{
+	saved_eip = return_point;
+	asm volatile ("movl %%esp,(%0)" : "=m" (saved_esp));
+	asm volatile ("movl %%ebp,(%0)" : "=m" (saved_ebp));
+	asm volatile ("movl %%ebx,(%0)" : "=m" (saved_ebx));
+	asm volatile ("movl %%edi,(%0)" : "=m" (saved_edi));
+	asm volatile ("movl %%esi,(%0)" : "=m" (saved_esi));
+}
+
+#define acpi_restore_register_state()   do {} while (0)
+
+
+/* routines for saving/restoring kernel state */
+extern int acpi_save_state_mem(void);
+extern int acpi_save_state_disk(void);
+extern void acpi_restore_state_mem(void);
+
+extern unsigned long acpi_wakeup_address;
+
+extern void do_suspend_lowlevel_s4bios(int resume);
+
+/* early initialization routine */
+extern void acpi_reserve_bootmem(void);
+
+#endif /*CONFIG_ACPI_SLEEP*/
+
+
+#endif /*__KERNEL__*/
+
+#endif /*_ASM_ACPI_H*/
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-i386/bitops.h linux-2.4.22-pre2/include/asm-i386/bitops.h
--- linux-2.4.21/include/asm-i386/bitops.h	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-i386/bitops.h	2003-06-26 21:43:29.000000000 +0000
@@ -80,7 +80,7 @@
 
 /**
  * __change_bit - Toggle a bit in memory
- * @nr: the bit to set
+ * @nr: the bit to change
  * @addr: the address to start counting from
  *
  * Unlike change_bit(), this function is non-atomic and may be reordered.
@@ -97,7 +97,7 @@
 
 /**
  * change_bit - Toggle a bit in memory
- * @nr: Bit to clear
+ * @nr: Bit to change
  * @addr: Address to start counting from
  *
  * change_bit() is atomic and may not be reordered.
@@ -153,7 +153,7 @@
 
 /**
  * test_and_clear_bit - Clear a bit and return its old value
- * @nr: Bit to set
+ * @nr: Bit to clear
  * @addr: Address to count from
  *
  * This operation is atomic and cannot be reordered.  
@@ -172,7 +172,7 @@
 
 /**
  * __test_and_clear_bit - Clear a bit and return its old value
- * @nr: Bit to set
+ * @nr: Bit to clear
  * @addr: Address to count from
  *
  * This operation is non-atomic and can be reordered.  
@@ -204,7 +204,7 @@
 
 /**
  * test_and_change_bit - Change a bit and return its new value
- * @nr: Bit to set
+ * @nr: Bit to change
  * @addr: Address to count from
  *
  * This operation is atomic and cannot be reordered.  
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-i386/dma.h linux-2.4.22-pre2/include/asm-i386/dma.h
--- linux-2.4.21/include/asm-i386/dma.h	2001-11-22 19:47:00.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-i386/dma.h	2003-06-26 21:43:21.000000000 +0000
@@ -239,7 +239,7 @@
 }
 
 
-/* Set transfer size (max 64k for DMA1..3, 128k for DMA5..7) for
+/* Set transfer size (max 64k for DMA0..3, 128k for DMA5..7) for
  * a specific DMA channel.
  * You must ensure the parameters are valid.
  * NOTE: from a manual: "the number of transfers is one more
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-i386/fixmap.h linux-2.4.22-pre2/include/asm-i386/fixmap.h
--- linux-2.4.21/include/asm-i386/fixmap.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-i386/fixmap.h	2003-06-26 21:43:11.000000000 +0000
@@ -15,6 +15,7 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
+#include <asm/acpi.h>
 #include <asm/apicdef.h>
 #include <asm/page.h>
 #ifdef CONFIG_HIGHMEM
@@ -57,7 +58,7 @@
 #endif
 #ifdef CONFIG_X86_VISWS_APIC
 	FIX_CO_CPU,	/* Cobalt timer */
-	FIX_CO_APIC,	/* Cobalt APIC Redirection Table */ 
+	FIX_CO_APIC,	/* Cobalt APIC Redirection Table */
 	FIX_LI_PCIA,	/* Lithium PCI Bridge A */
 	FIX_LI_PCIB,	/* Lithium PCI Bridge B */
 #endif
@@ -71,6 +72,10 @@
 	FIX_KMAP_BEGIN,	/* reserved pte's for temporary kernel mappings */
 	FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
 #endif
+#ifdef CONFIG_ACPI_BOOT
+	FIX_ACPI_BEGIN,
+	FIX_ACPI_END = FIX_ACPI_BEGIN + FIX_ACPI_PAGES - 1,
+#endif
 	__end_of_permanent_fixed_addresses,
 	/* temporary boot-time mappings, used before ioremap() is functional */
 #define NR_FIX_BTMAPS	16
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-i386/io_apic.h linux-2.4.22-pre2/include/asm-i386/io_apic.h
--- linux-2.4.21/include/asm-i386/io_apic.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-i386/io_apic.h	2003-06-26 21:43:29.000000000 +0000
@@ -44,6 +44,11 @@
 		__reserved_1	:  4;
 } __attribute__ ((packed));
 
+struct IO_APIC_reg_03 {
+	__u32	boot_DT		:  1,
+		__reserved_1	: 31;
+} __attribute__ ((packed));
+
 /*
  * # of IO-APICs and # of IRQ routing registers
  */
@@ -144,6 +149,13 @@
  */
 #define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup)
 
+#ifdef CONFIG_ACPI_BOOT
+extern int io_apic_get_unique_id (int ioapic, int apic_id);
+extern int io_apic_get_version (int ioapic);
+extern int io_apic_get_redir_entries (int ioapic);
+extern int io_apic_set_pci_routing (int ioapic, int pin, int irq);
+#endif
+
 #else  /* !CONFIG_X86_IO_APIC */
 #define io_apic_assign_pci_irqs 0
 #endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-i386/mpspec.h linux-2.4.22-pre2/include/asm-i386/mpspec.h
--- linux-2.4.21/include/asm-i386/mpspec.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-i386/mpspec.h	2003-06-26 21:43:10.000000000 +0000
@@ -219,5 +219,19 @@
 extern int pic_mode;
 extern int using_apic_timer;
 
+#ifdef CONFIG_ACPI_BOOT
+extern void mp_register_lapic (u8 id, u8 enabled);
+extern void mp_register_lapic_address (u64 address);
+
+#ifdef CONFIG_X86_IO_APIC
+extern void mp_register_ioapic (u8 id, u32 address, u32 irq_base);
+extern void mp_override_legacy_irq (u8 bus_irq, u8 polarity, u8 trigger, u32 global_irq);
+extern void mp_config_acpi_legacy_irqs (void);
+extern void mp_config_ioapic_for_sci(int irq);
+extern void mp_parse_prt (void);
+#endif /*CONFIG_X86_IO_APIC*/
+
+#endif /*CONFIG_ACPI_BOOT*/
+
 #endif
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-i386/pci.h linux-2.4.22-pre2/include/asm-i386/pci.h
--- linux-2.4.21/include/asm-i386/pci.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-i386/pci.h	2003-06-26 21:43:19.000000000 +0000
@@ -19,6 +19,11 @@
 #define PCIBIOS_MIN_IO		0x1000
 #define PCIBIOS_MIN_MEM		(pci_mem_start)
 
+void pcibios_config_init(void);
+struct pci_bus * pcibios_scan_root(int bus);
+extern int (*pci_config_read)(int seg, int bus, int dev, int fn, int reg, int len, u32 *value);
+extern int (*pci_config_write)(int seg, int bus, int dev, int fn, int reg, int len, u32 value);
+
 void pcibios_set_master(struct pci_dev *dev);
 void pcibios_penalize_isa_irq(int irq);
 struct irq_routing_table *pcibios_get_irq_routing_table(void);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-i386/save_state.h linux-2.4.22-pre2/include/asm-i386/save_state.h
--- linux-2.4.21/include/asm-i386/save_state.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-i386/save_state.h	2003-06-26 21:43:27.000000000 +0000
@@ -0,0 +1,212 @@
+#ifndef __ASM_I386_SAVE_STATE_H
+#define __ASM_I386_SAVE_STATE_H
+
+/*
+ * Copyright 2001-2002 Pavel Machek <pavel@suse.cz>
+ * Based on code
+ * Copyright 2001 Patrick Mochel <mochel@osdl.org>
+ */
+#include <asm/desc.h>
+#include <asm/i387.h>
+
+/* image of the saved processor state */
+struct saved_context {
+	u32 eax, ebx, ecx, edx;
+	u32 esp, ebp, esi, edi;
+	u16 es, fs, gs, ss;
+	u32 cr0, cr2, cr3, cr4;
+	u16 gdt_pad;
+	u16 gdt_limit;
+	u32 gdt_base;
+	u16 idt_pad;
+	u16 idt_limit;
+	u32 idt_base;
+	u16 ldt;
+	u16 tss;
+	u32 tr;
+	u32 safety;
+	u32 return_address;
+	u32 eflags;
+} __attribute__((packed));
+
+static struct saved_context saved_context;
+
+#define loaddebug(thread,register) \
+               __asm__("movl %0,%%db" #register  \
+                       : /* no output */ \
+                       :"r" ((thread)->debugreg[register]))
+
+
+/*
+ * save_processor_context
+ * 
+ * Save the state of the processor before we go to sleep.
+ *
+ * return_stack is the value of the stack pointer (%esp) as the caller sees it.
+ * A good way could not be found to obtain it from here (don't want to make _too_
+ * many assumptions about the layout of the stack this far down.) Also, the 
+ * handy little __builtin_frame_pointer(level) where level > 0, is blatantly 
+ * buggy - it returns the value of the stack at the proper location, not the 
+ * location, like it should (as of gcc 2.91.66)
+ * 
+ * Note that the context and timing of this function is pretty critical.
+ * With a minimal amount of things going on in the caller and in here, gcc
+ * does a good job of being just a dumb compiler.  Watch the assembly output
+ * if anything changes, though, and make sure everything is going in the right
+ * place. 
+ */
+static inline void save_processor_context (void)
+{
+	kernel_fpu_begin();
+
+	/*
+	 * descriptor tables
+	 */
+	asm volatile ("sgdt (%0)" : "=m" (saved_context.gdt_limit));
+	asm volatile ("sidt (%0)" : "=m" (saved_context.idt_limit));
+	asm volatile ("sldt (%0)" : "=m" (saved_context.ldt));
+	asm volatile ("str (%0)"  : "=m" (saved_context.tr));
+
+	/*
+	 * save the general registers.
+	 * note that gcc has constructs to specify output of certain registers,
+	 * but they're not used here, because it assumes that you want to modify
+	 * those registers, so it tries to be smart and save them beforehand.
+	 * It's really not necessary, and kinda fishy (check the assembly output),
+	 * so it's avoided. 
+	 */
+	asm volatile ("movl %%esp, (%0)" : "=m" (saved_context.esp));
+	asm volatile ("movl %%eax, (%0)" : "=m" (saved_context.eax));
+	asm volatile ("movl %%ebx, (%0)" : "=m" (saved_context.ebx));
+	asm volatile ("movl %%ecx, (%0)" : "=m" (saved_context.ecx));
+	asm volatile ("movl %%edx, (%0)" : "=m" (saved_context.edx));
+	asm volatile ("movl %%ebp, (%0)" : "=m" (saved_context.ebp));
+	asm volatile ("movl %%esi, (%0)" : "=m" (saved_context.esi));
+	asm volatile ("movl %%edi, (%0)" : "=m" (saved_context.edi));
+
+	/*
+	 * segment registers
+	 */
+	asm volatile ("movw %%es, %0" : "=r" (saved_context.es));
+	asm volatile ("movw %%fs, %0" : "=r" (saved_context.fs));
+	asm volatile ("movw %%gs, %0" : "=r" (saved_context.gs));
+	asm volatile ("movw %%ss, %0" : "=r" (saved_context.ss));
+
+	/*
+	 * control registers 
+	 */
+	asm volatile ("movl %%cr0, %0" : "=r" (saved_context.cr0));
+	asm volatile ("movl %%cr2, %0" : "=r" (saved_context.cr2));
+	asm volatile ("movl %%cr3, %0" : "=r" (saved_context.cr3));
+	asm volatile ("movl %%cr4, %0" : "=r" (saved_context.cr4));
+
+	/*
+	 * eflags
+	 */
+	asm volatile ("pushfl ; popl (%0)" : "=m" (saved_context.eflags));
+}
+
+static void fix_processor_context(void)
+{
+	int nr = smp_processor_id();
+	struct tss_struct * t = &init_tss[nr];
+
+	set_tss_desc(nr,t);	/* This just modifies memory; should not be neccessary. But... This is neccessary, because 386 hardware has concept of busy tsc or some similar stupidity. */
+        gdt_table[__TSS(nr)].b &= 0xfffffdff;
+
+	load_TR(nr);		/* This does ltr */
+	__load_LDT(nr);		/* This does lldt */
+
+	/*
+	 * Now maybe reload the debug registers
+	 */
+	if (current->thread.debugreg[7]){
+                loaddebug(&current->thread, 0);
+                loaddebug(&current->thread, 1);
+                loaddebug(&current->thread, 2);
+                loaddebug(&current->thread, 3);
+                /* no 4 and 5 */
+                loaddebug(&current->thread, 6);
+                loaddebug(&current->thread, 7);
+	}
+
+}
+
+static void
+do_fpu_end(void)
+{
+        /* restore FPU regs if necessary */
+	/* Do it out of line so that gcc does not move cr0 load to some stupid place */
+        kernel_fpu_end();
+}
+
+/*
+ * restore_processor_context
+ * 
+ * Restore the processor context as it was before we went to sleep
+ * - descriptor tables
+ * - control registers
+ * - segment registers
+ * - flags
+ * 
+ * Note that it is critical that this function is declared inline.  
+ * It was separated out from restore_state to make that function
+ * a little clearer, but it needs to be inlined because we won't have a
+ * stack when we get here (so we can't push a return address).
+ */
+static inline void restore_processor_context (void)
+{
+	/*
+	 * first restore %ds, so we can access our data properly
+	 */
+	asm volatile (".align 4");
+	asm volatile ("movw %0, %%ds" :: "r" ((u16)__KERNEL_DS));
+
+
+	/*
+	 * control registers
+	 */
+	asm volatile ("movl %0, %%cr4" :: "r" (saved_context.cr4));
+	asm volatile ("movl %0, %%cr3" :: "r" (saved_context.cr3));
+	asm volatile ("movl %0, %%cr2" :: "r" (saved_context.cr2));
+	asm volatile ("movl %0, %%cr0" :: "r" (saved_context.cr0));
+	
+	/*
+	 * segment registers
+	 */
+	asm volatile ("movw %0, %%es" :: "r" (saved_context.es));
+	asm volatile ("movw %0, %%fs" :: "r" (saved_context.fs));
+	asm volatile ("movw %0, %%gs" :: "r" (saved_context.gs));
+	asm volatile ("movw %0, %%ss" :: "r" (saved_context.ss));
+
+	/*
+	 * the other general registers
+	 *
+	 * note that even though gcc has constructs to specify memory 
+	 * input into certain registers, it will try to be too smart
+	 * and save them at the beginning of the function.  This is esp.
+	 * bad since we don't have a stack set up when we enter, and we 
+	 * want to preserve the values on exit. So, we set them manually.
+	 */
+	asm volatile ("movl %0, %%esp" :: "m" (saved_context.esp));
+	asm volatile ("movl %0, %%ebp" :: "m" (saved_context.ebp));
+	asm volatile ("movl %0, %%eax" :: "m" (saved_context.eax));
+	asm volatile ("movl %0, %%ebx" :: "m" (saved_context.ebx));
+	asm volatile ("movl %0, %%ecx" :: "m" (saved_context.ecx));
+	asm volatile ("movl %0, %%edx" :: "m" (saved_context.edx));
+	asm volatile ("movl %0, %%esi" :: "m" (saved_context.esi));
+	asm volatile ("movl %0, %%edi" :: "m" (saved_context.edi));
+
+	/*
+	 * now restore the descriptor tables to their proper values
+	 */
+	asm volatile ("lgdt (%0)" :: "m" (saved_context.gdt_limit));
+	asm volatile ("lidt (%0)" :: "m" (saved_context.idt_limit));
+	asm volatile ("lldt (%0)" :: "m" (saved_context.ldt));
+
+	fix_processor_context();
+	do_fpu_end();
+}
+
+#endif 
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ia64/sal.h linux-2.4.22-pre2/include/asm-ia64/sal.h
--- linux-2.4.21/include/asm-ia64/sal.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ia64/sal.h	2003-06-26 21:43:32.000000000 +0000
@@ -538,7 +538,7 @@
     u64             reg_data_pairs[1];
     /* array of address/data register pairs is num_mem_regs + num_io_regs
        elements long.  Each array element consists of a u64 address followed
-       by a u64 data value.  The oem_data array immediately follows the the
+       by a u64 data value.  The oem_data array immediately follows the
        reg_data_pairs array */
     u8              oem_data[1];        /* Variable length data */
 } sal_log_pci_comp_err_info_t;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc/ibm4xx.h linux-2.4.22-pre2/include/asm-ppc/ibm4xx.h
--- linux-2.4.21/include/asm-ppc/ibm4xx.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc/ibm4xx.h	2003-06-26 21:43:22.000000000 +0000
@@ -0,0 +1,104 @@
+/*
+ *
+ *    Copyright (c) 1999 Grant Erickson <grant@lcse.umn.edu>
+ *
+ *    Module name: ibm4xx.h
+ *
+ *    Description:
+ *	A generic include file which pulls in appropriate include files
+ *      for specific board types based on configuration settings.
+ *
+ */
+
+#ifdef __KERNEL__
+#ifndef __ASM_IBM4XX_H__
+#define __ASM_IBM4XX_H__
+
+#include <linux/config.h>
+#include <asm/types.h>
+
+#ifdef CONFIG_4xx
+
+#ifndef __ASSEMBLY__
+/*
+ * The "residual" board information structure the boot loader passes
+ * into the kernel.
+ */
+extern unsigned char __res[];
+
+/* Device Control Registers */
+
+#define stringify(s)	tostring(s)
+#define tostring(s)	#s
+
+#define mfdcr_or_dflt(rn,default_rval) \
+	({unsigned int rval;						\
+	if (rn == 0)							\
+		rval = default_rval;					\
+	else								\
+		asm volatile("mfdcr %0," stringify(rn) : "=r" (rval));	\
+	rval;})
+
+/* R/W of indirect DCRs make use of standard naming conventions for DCRs */
+
+#define mfdcri(base, reg)			\
+({						\
+     mtdcr(base##_CFGADDR, base##_##reg);	\
+     mfdcr(base##_CFGDATA);			\
+})
+
+#define mtdcri(base, reg, data)			\
+do {						\
+     mtdcr(base##_CFGADDR, base##_##reg);	\
+     mtdcr(base##_CFGDATA, data);		\
+} while (0)
+#endif /* __ASSEMBLY__ */
+
+#endif /* CONFIG_4xx */
+
+#ifdef CONFIG_40x
+
+#if defined(CONFIG_OAK)
+#include <platforms/oak.h>
+#endif
+
+#if defined(CONFIG_WALNUT)
+#include <platforms/walnut.h>
+#endif
+
+#ifndef PPC4xx_MACHINE_NAME
+#define PPC4xx_MACHINE_NAME	"Unidentified 4xx class"
+#endif
+
+/* IO_BASE is for PCI I/O.
+ * ISA not supported, just here to resolve copilation.
+ */
+
+#ifndef _IO_BASE
+#define _IO_BASE	0xe8000000	/* The PCI address window */
+#define _ISA_MEM_BASE	0
+#define PCI_DRAM_OFFSET	0
+#endif
+
+#endif /* CONFIG_40x */
+
+#ifndef __ASSEMBLY__
+#if defined(EMAC_NUMS) && EMAC_NUMS > 0
+/* 
+ * Per EMAC map of PHY ids which should be probed by emac_probe.
+ * Different EMACs can have overlapping maps.
+ *
+ * Note, this map uses inverse logic for bits:
+ *  0 - id should be probed
+ *  1 - id should be ignored
+ *
+ * Default value of 0x00000000 - will result in usual 
+ * auto-detection logic.
+ *
+ */
+extern u32 emac_phy_map[EMAC_NUMS];
+#endif
+#endif /* __ASSEMBLY__ */
+
+#endif /* __ASM_IBM4XX_H__ */
+#endif /* __KERNEL__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc/io.h linux-2.4.22-pre2/include/asm-ppc/io.h
--- linux-2.4.21/include/asm-ppc/io.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc/io.h	2003-06-26 21:43:15.000000000 +0000
@@ -21,25 +21,25 @@
 #define PREP_ISA_MEM_BASE 	0xc0000000
 #define PREP_PCI_DRAM_OFFSET 	0x80000000
 
-#if defined(CONFIG_4xx)
-#include <asm/ppc4xx.h>
+#if defined(CONFIG_40x)
+#include <asm/ibm4xx.h>
 #elif defined(CONFIG_8xx)
 #include <asm/mpc8xx.h>
 #elif defined(CONFIG_8260)
 #include <asm/mpc8260.h>
 #elif defined(CONFIG_APUS)
-#define _IO_BASE 0
-#define _ISA_MEM_BASE 0
+#define _IO_BASE	0
+#define _ISA_MEM_BASE	0
 #define PCI_DRAM_OFFSET 0
 #else /* Everyone else */
-extern unsigned long isa_io_base;
-extern unsigned long isa_mem_base;
-extern unsigned long pci_dram_offset;
 #define _IO_BASE	isa_io_base
 #define _ISA_MEM_BASE	isa_mem_base
 #define PCI_DRAM_OFFSET	pci_dram_offset
 #endif /* Platform-dependant I/O */
 
+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))
 #if defined(CONFIG_APUS)
@@ -223,23 +223,26 @@
  */
 extern inline unsigned long virt_to_bus(volatile void * address)
 {
-#ifndef CONFIG_APUS
-        if (address == (void *)0)
-		return 0;
-        return (unsigned long)address - KERNELBASE + PCI_DRAM_OFFSET;
+#if defined(CONFIG_APUS) || defined(CONFIG_8xx) || defined(CONFIG_4xx)
+	/* I think everyone will be using this version if we start allowing
+	 * uncached pages in alternate virtual spaces.  --  Dan
+	 */
+	return (iopa((unsigned long) address) + PCI_DRAM_OFFSET);
 #else
-	return iopa ((unsigned long) address);
+	if (address == (void *)0)
+		return 0;
+	return (unsigned long)address - KERNELBASE + PCI_DRAM_OFFSET;
 #endif
 }
 
 extern inline void * bus_to_virt(unsigned long address)
 {
-#ifndef CONFIG_APUS
-        if (address == 0)
-		return 0;
-        return (void *)(address - PCI_DRAM_OFFSET + KERNELBASE);
+#if defined(CONFIG_APUS) || defined(CONFIG_8xx) || defined(CONFIG_40x)
+	return (void*) mm_ptov (address - PCI_DRAM_OFFSET);
 #else
-	return (void*) mm_ptov (address);
+	if (address == 0)
+		return 0;
+	return (void *)(address - PCI_DRAM_OFFSET + KERNELBASE);
 #endif
 }
 
@@ -249,19 +252,19 @@
  */
 extern inline unsigned long virt_to_phys(volatile void * address)
 {
-#ifndef CONFIG_APUS
-	return (unsigned long) address - KERNELBASE;
-#else
+#if defined(CONFIG_APUS) || defined(CONFIG_8xx) || defined(CONFIG_40x)
 	return iopa ((unsigned long) address);
+#else
+	return (unsigned long) address - KERNELBASE;
 #endif
 }
 
 extern inline void * phys_to_virt(unsigned long address)
 {
-#ifndef CONFIG_APUS
-	return (void *) (address + KERNELBASE);
-#else
+#if defined(CONFIG_APUS) || defined(CONFIG_8xx) || defined(CONFIG_40x)
 	return (void*) mm_ptov (address);
+#else
+	return (void *) (address + KERNELBASE);
 #endif
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc/irq.h linux-2.4.22-pre2/include/asm-ppc/irq.h
--- linux-2.4.21/include/asm-ppc/irq.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc/irq.h	2003-06-26 21:43:12.000000000 +0000
@@ -23,8 +23,22 @@
 #define IRQ_POLARITY_POSITIVE	0x2	/* high level or low->high edge */
 #define IRQ_POLARITY_NEGATIVE	0x0	/* low level or high->low edge */
 
-#if defined(CONFIG_4xx)
+#if defined(CONFIG_40x)
+#include <asm/ibm4xx.h>
 
+#ifndef NR_BOARD_IRQS
+#define NR_BOARD_IRQS 0
+#endif
+
+#ifndef UIC_WIDTH /* Number of interrupts per device */
+#define UIC_WIDTH 32
+#endif
+
+#ifndef NR_UICS /* number  of UIC devices */
+#define NR_UICS 1
+#endif
+
+#if defined (CONFIG_403)
 /*
  * The PowerPC 403 cores' Asynchronous Interrupt Controller (AIC) has
  * 32 possible interrupts, a majority of which are not implemented on
@@ -32,30 +46,36 @@
  * there are eight internal interrupts for the on-chip serial port
  * (SPU), DMA controller, and JTAG controller.
  *
- * The PowerPC 405 cores' Universal Interrupt Controller (UIC) has 32
+ */
+
+#define	NR_AIC_IRQS 32 
+#define	NR_IRQS	 (NR_AIC_IRQS + NR_BOARD_IRQS)
+
+#elif !defined (CONFIG_403)
+
+/*
+ *  The PowerPC 405 cores' Universal Interrupt Controller (UIC) has 32
  * possible interrupts as well. There are seven, configurable external
  * interrupt pins and there are 17 internal interrupts for the on-chip
  * serial port, DMA controller, on-chip Ethernet controller, PCI, etc.
  *
  */
 
-#define	NR_IRQS		32
 
-#define	AIC_INT0	(0)
-#define	AIC_INT4	(4)
-#define	AIC_INT5	(5)
-#define	AIC_INT6	(6)
-#define	AIC_INT7	(7)
-#define	AIC_INT8	(8)
-#define	AIC_INT9	(9)
-#define	AIC_INT10	(10)
-#define	AIC_INT11	(11)
-#define	AIC_INT27	(27)
-#define	AIC_INT28	(28)
-#define	AIC_INT29	(29)
-#define	AIC_INT30	(30)
-#define	AIC_INT31	(31)
+#define NR_UIC_IRQS UIC_WIDTH
+#define NR_IRQS		((NR_UIC_IRQS * NR_UICS) + NR_BOARD_IRQS)
+#endif
+static __inline__ int
+irq_cannonicalize(int irq)
+{
+	return (irq);
+}
+
+#elif defined(CONFIG_440)
+#include <asm/ibm440.h>
 
+#define	NR_UIC_IRQS	32
+#define	NR_IRQS		((NR_UIC_IRQS * NR_UICS) + NR_BOARD_IRQS)
 
 static __inline__ int
 irq_cannonicalize(int irq)
@@ -145,7 +165,7 @@
 	return irq;
 }
 
-#else /* CONFIG_4xx + CONFIG_8xx */
+#else /* CONFIG_40x + CONFIG_8xx */
 /*
  * this is the # irq's for all ppc arch's (pmac/chrp/prep)
  * so it is the max of them all
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc/ocp.h linux-2.4.22-pre2/include/asm-ppc/ocp.h
--- linux-2.4.21/include/asm-ppc/ocp.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc/ocp.h	2003-06-26 21:43:16.000000000 +0000
@@ -0,0 +1,190 @@
+/*
+ * ocp.h
+ *
+ *      (c) Benjamin Herrenschmidt (benh@kernel.crashing.org)
+ *          Mipsys - France
+ *
+ "          Derived from work (c) Armin Kuster akuster@pacbell.net
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR   IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT,  INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ *  TODO: - Add get/put interface & fixup locking to provide same API for
+ *          2.4 and 2.5
+ *	  - Rework PM callbacks
+ */
+
+#ifdef __KERNEL__
+#ifndef __OCP_H__
+#define __OCP_H__
+
+#include <linux/list.h>
+#include <linux/config.h>
+#include <linux/devfs_fs_kernel.h>
+
+#include <asm/ocp_ids.h>
+#include <asm/rwsem.h>
+#include <asm/semaphore.h>
+
+#if defined(CONFIG_IBM_OCP)
+#include <platforms/ibm_ocp.h>
+#endif
+
+#define OCP_MAX_IRQS	7
+#define MAX_EMACS	4
+#define OCP_IRQ_NA	-1	/* used when ocp device does not have an irq */
+#define OCP_IRQ_MUL	-2	/* used for ocp devices with multiply irqs */
+#define OCP_NULL_TYPE	-1	/* used to mark end of list */
+#define OCP_CPM_NA	0	/* No Clock or Power Management avaliable */
+#define OCP_PADDR_NA	0	/* No MMIO registers */
+
+#define OCP_ANY_ID	(~0)
+#define OCP_ANY_INDEX	-1
+
+extern struct list_head 	ocp_devices;
+extern struct list_head 	ocp_drivers;
+extern struct rw_semaphore	ocp_devices_sem;
+extern struct semaphore		ocp_drivers_sem;
+
+struct ocp_device_id {
+	unsigned int	vendor, function;	/* Vendor and function ID or OCP_ANY_ID */
+	unsigned long	driver_data;		/* Data private to the driver */
+};
+
+
+/*
+ * Static definition of an OCP device.
+ *
+ * @vendor:    Vendor code. It is _STRONGLY_ discouraged to use
+ *             the vendor code as a way to match a unique device,
+ *             though I kept that possibility open, you should
+ *             really define different function codes for different
+ *             device types
+ * @function:  This is the function code for this device.
+ * @index:     This index is used for mapping the Nth function of a
+ *             given core. This is typically used for cross-driver
+ *             matching, like looking for a given MAL or ZMII from
+ *             an EMAC or for getting to the proper set of DCRs.
+ *             Indices are no longer magically calculated based on
+ *             structure ordering, they have to be actually coded
+ *             into the ocp_def to avoid any possible confusion
+ *             I _STRONGLY_ (again ? wow !) encourage anybody relying
+ *             on index mapping to encode the "target" index in an
+ *             associated structure pointed to by "additions", see
+ *             how it's done for the EMAC driver.
+ * @paddr:     Device physical address (may not mean anything...)
+ * @irq:       Interrupt line for this device (TODO: think about making
+ *             an array with this)
+ * @pm:        Currently, contains the bitmask in CPMFR DCR for the device
+ * @additions: Optionally points to a function specific structure
+ *             providing additional informations for a given device
+ *             instance. It's currently used by the EMAC driver for MAL
+ *             channel & ZMII port mapping among others.
+ */
+struct ocp_def {
+	unsigned int	vendor;
+	unsigned int	function;
+	int		index;
+	unsigned long	paddr;
+	int	  	irq;
+	unsigned long	pm;
+	void		*additions;
+};
+
+
+/* Struct for a given device instance */
+struct ocp_device {
+	struct list_head	link;
+	char			name[80];	/* device name */
+	const struct ocp_def	*def;		/* device definition */
+	void			*drvdata;	/* driver data for this device */
+	struct ocp_driver	*driver;
+	u32			current_state;	/* Current operating state. In ACPI-speak,
+						   this is D0-D3, D0 being fully functional,
+						   and D3 being off. */
+};
+
+/* Structure for a device driver */
+struct ocp_driver {
+	const char		   	*name;
+	const struct ocp_device_id	*id_table;	/* NULL if wants all devices */
+
+	int	 (*probe)  (struct ocp_device *dev);	/* New device inserted */
+	void	 (*remove) (struct ocp_device *dev);	/* Device removed (NULL if not a
+							   hot-plug capable driver) */
+	int 	 (*save_state) (struct ocp_device *dev, u32 state);  /* Save Device Context */
+	int 	 (*suspend) (struct ocp_device *dev, u32 state);     /* Device suspended */
+	int 	 (*resume) (struct ocp_device *dev);	             /* Device woken up */
+	int 	 (*enable_wake) (struct ocp_device *dev, u32 state, int enable);
+	                                                             /* Enable wake event */
+	struct list_head		link;
+};
+
+/* Similar to the helpers above, these manipulate per-ocp_dev
+ * driver-specific data.  Currently stored as ocp_dev::ocpdev,
+ * a void pointer, but it is not present on older kernels.
+ */
+static inline void *
+ocp_get_drvdata(struct ocp_device *pdev)
+{
+	return pdev->drvdata;
+}
+
+static inline void
+ocp_set_drvdata(struct ocp_device *pdev, void *data)
+{
+	pdev->drvdata = data;
+}
+
+#if defined (CONFIG_PM)
+/*
+ * This is right for the IBM 405 and 440 but will need to be
+ * generalized if the OCP stuff gets used on other processors.
+ */
+static inline void
+ocp_force_power_off(struct ocp_device *odev)
+{
+	mtdcr(DCRN_CPMFR, mfdcr(DCRN_CPMFR) | odev->def->pm);
+}
+
+static inline void
+ocp_force_power_on(struct ocp_device *odev)
+{
+	mtdcr(DCRN_CPMFR, mfdcr(DCRN_CPMFR) & ~odev->def->pm);
+}
+#else
+#define ocp_force_power_off(x)	(void)(x)
+#define ocp_force_power_on(x)	(void)(x)
+#endif
+
+/* Register/Unregister an OCP driver */
+extern int ocp_register_driver(struct ocp_driver *drv);
+extern void ocp_unregister_driver(struct ocp_driver *drv);
+
+/* Initialize the OCP management layer */
+extern int ocp_init(void);
+
+/* Find a device by index */
+extern struct ocp_device *ocp_find_device(unsigned int vendor, unsigned int function, int index);
+
+
+#endif				/* __OCP_H__ */
+#endif				/* __KERNEL__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc/ocp_ids.h linux-2.4.22-pre2/include/asm-ppc/ocp_ids.h
--- linux-2.4.21/include/asm-ppc/ocp_ids.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc/ocp_ids.h	2003-06-26 21:43:29.000000000 +0000
@@ -0,0 +1,127 @@
+/*
+ * FILE NAME: ocp_ids.h
+ *
+ * BRIEF MODULE DESCRIPTION: 
+ * OCP device ids based on the ideas from PCI
+ *
+ * Maintained by: Armin <akuster@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.
+ *
+ *  Version 1.0 08/22/02 -Armin
+ *  	initial release
+ */
+
+/*
+ * Vender  device
+ * [xxxx]  [xxxx]
+ *
+ *  Keep in order, please
+ */
+
+/* Vendor IDs 0x0001 - 0xFFFF copied from pci_ids.h */
+
+#define	OCP_VENDOR_INVALID	0x0000
+#define	OCP_VENDOR_ARM		0x0004
+#define OCP_VENDOR_IBM		0x1014
+#define OCP_VENDOR_MOTOROLA	0x1057
+#define	OCP_VENDOR_XILINX	0x10ee
+#define	OCP_VENDOR_UNKNOWN	0xFFFF
+
+/* device identification */
+
+/* define type */
+#define OCP_FUNC_INVALID	0x0000
+
+/* system 0x0001 - 0x001F */
+#define	OCP_FUNC_UIC		0x0001
+
+/* Timers 0x0020 - 0x002F */
+#define OCP_FUNC_GPT		0x0020 	/* General purpose timers */
+#define OCP_FUNC_RTC		0x0021
+
+/* Serial 0x0030 - 0x006F*/
+#define OCP_FUNC_16550		0x0031 
+#define OCP_FUNC_SSP		0x0032 /* sync serial port */
+#define OCP_FUNC_SCP		0x0033 	/* serial controller port */
+#define OCP_FUNC_SCC		0x0034 	/* serial contoller */
+#define OCP_FUNC_SCI		0x0035 	/* Smart card */
+#define OCP_FUNC_IIC		0x0040 
+#define OCP_FUNC_USB		0x0050 
+#define OCP_FUNC_IR		0x0060		
+
+/* Memory devices 0x0090 - 0x009F */
+#define	OCP_FUNC_SDRAM		0x0091
+#define OCP_FUNC_DMA		0x0092
+#define OCP_FUNC_MAL		0x0093
+
+	/* Additional data */
+	struct ocp_func_mal_data {
+		int	num_tx_chans;	/* Number of TX channels */
+		int	num_rx_chans;	/* Number of RX channels */
+	};
+
+/* Display 0x00A0 - 0x00AF */
+#define OCP_FUNC_VIDEO		0x00A0 
+#define OCP_FUNC_LED		0x00A1
+#define	OCP_FUNC_LCD		0x00A2
+
+/* Sound 0x00B0 - 0x00BF */
+#define OCP_FUNC_AUDIO		0x00B0 
+
+/* Mass Storage 0x00C0 - 0xxCF */
+#define OCP_FUNC_IDE		0x00C0 
+
+/* Misc 0x00D0 - 0x00DF*/
+#define OCP_FUNC_GPIO		0x00D0 
+#define OCP_FUNC_ZMII		0x00D1
+
+/* Network 0x0200 - 0x02FF */
+#define OCP_FUNC_EMAC		0x0200 
+
+	/* Additional data
+	 * 
+	 * Note about mdio_idx: When you have a zmii, it's usually
+	 * not necessary, it covers the case of the 405EP which has
+	 * the MDIO lines on EMAC0 only
+	 */
+	struct ocp_func_emac_data {
+		int	zmii_idx;	/* ZMII device index or -1 */
+		int	zmii_mux;	/* ZMII input of this EMAC */
+		int	mal_idx;	/* MAL device index */
+		int	mal_rx_chan;	/* MAL rx channel number */
+		int	mal_tx1_chan;	/* MAL tx channel 1 number */
+		int	mal_tx2_chan;	/* MAL tx channel 2 number */
+		int	wol_irq;	/* WOL interrupt */
+		int	mdio_idx;	/* EMAC idx of MDIO master or -1 */
+	};
+
+/* Bridge devices 0xE00 - 0xEFF */
+#define OCP_FUNC_HOST		0x0E00 
+#define OCP_FUNC_DCR		0x0E01 
+#define OCP_FUNC_OPB		0x0E02
+#define OCP_FUNC_PHY		0x0E03
+#define OCP_FUNC_EXT		0x0E04
+#define	OCP_FUNC_PCI		0x0E05
+#define	OCP_FUNC_PLB		0x0E06
+
+#define OCP_FUNC_UNKNOWN	0xFFFF
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc/pc_serial.h linux-2.4.22-pre2/include/asm-ppc/pc_serial.h
--- linux-2.4.21/include/asm-ppc/pc_serial.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc/pc_serial.h	2003-06-26 21:43:21.000000000 +0000
@@ -0,0 +1,129 @@
+/*
+ * BK Id: %F% %I% %G% %U% %#%
+ *
+ * include/asm-ppc/pc_serial.h
+ *
+ * This is basically a copy of include/asm-i386/serial.h.
+ * It is used on platforms which have an ISA bus and thus are likely
+ * to have PC-style serial ports at the legacy I/O port addresses.
+ * It also includes the definitions for the fourport, accent, boca
+ * and hub6 multiport serial cards, although I have never heard of
+ * anyone using any of those on a PPC platform.  -- paulus
+ */
+
+#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 )
+
+#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_SKIP_TEST | ASYNC_AUTO_IRQ)
+#define STD_COM4_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_AUTO_IRQ)
+#else
+#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
+#define STD_COM4_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, 0x3E8, 4, STD_COM_FLAGS },	/* ttyS2 */	\
+	{ 0, BASE_BAUD, 0x2E8, 3, STD_COM4_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 SERIAL_PORT_DFNS		\
+	STD_SERIAL_PORT_DEFNS		\
+	EXTRA_SERIAL_PORT_DEFNS		\
+	HUB6_SERIAL_PORT_DFNS
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc/pci-bridge.h linux-2.4.22-pre2/include/asm-ppc/pci-bridge.h
--- linux-2.4.21/include/asm-ppc/pci-bridge.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc/pci-bridge.h	2003-06-26 21:43:11.000000000 +0000
@@ -54,6 +54,7 @@
 
 	int first_busno;
 	int last_busno;
+	int bus_offset;
         
 	void *io_base_virt;
 	unsigned long io_base_phys;
@@ -66,6 +67,11 @@
 	struct pci_ops *ops;
 	volatile unsigned int *cfg_addr;
 	volatile unsigned char *cfg_data;
+	/*
+	 * If set, indirect method will set the cfg_type bit as
+	 * needed to generate type 1 configuration transactions.
+	 */
+	int set_cfg_type;
 
 	/* Currently, we limit ourselves to 1 IO range and 3 mem
 	 * ranges since the common pci_bus structure can't handle more
@@ -83,15 +89,21 @@
 
 /* These are used for config access before all the PCI probing
    has been done. */
-int early_read_config_byte(struct pci_controller *hose, int bus, int dev_fn, int where, u8 *val);
-int early_read_config_word(struct pci_controller *hose, int bus, int dev_fn, int where, u16 *val);
-int early_read_config_dword(struct pci_controller *hose, int bus, int dev_fn, int where, u32 *val);
-int early_write_config_byte(struct pci_controller *hose, int bus, int dev_fn, int where, u8 val);
-int early_write_config_word(struct pci_controller *hose, int bus, int dev_fn, int where, u16 val);
-int early_write_config_dword(struct pci_controller *hose, int bus, int dev_fn, int where, u32 val);
+int early_read_config_byte(struct pci_controller *hose, int bus, int dev_fn,
+			   int where, u8 *val);
+int early_read_config_word(struct pci_controller *hose, int bus, int dev_fn,
+			   int where, u16 *val);
+int early_read_config_dword(struct pci_controller *hose, int bus, int dev_fn,
+			    int where, u32 *val);
+int early_write_config_byte(struct pci_controller *hose, int bus, int dev_fn,
+			    int where, u8 val);
+int early_write_config_word(struct pci_controller *hose, int bus, int dev_fn,
+			    int where, u16 val);
+int early_write_config_dword(struct pci_controller *hose, int bus, int dev_fn,
+			     int where, u32 val);
 
-extern void setup_indirect_pci(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);
 
 extern unsigned char common_swizzle(struct pci_dev *, unsigned char *);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc/pgtable.h linux-2.4.22-pre2/include/asm-ppc/pgtable.h
--- linux-2.4.21/include/asm-ppc/pgtable.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc/pgtable.h	2003-06-26 21:43:13.000000000 +0000
@@ -11,16 +11,34 @@
 #include <asm/mmu.h>
 #include <asm/page.h>
 
-#if defined(CONFIG_4xx)
-extern void local_flush_tlb_all(void);
-extern void local_flush_tlb_mm(struct mm_struct *mm);
-extern void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
-extern void local_flush_tlb_range(struct mm_struct *mm, unsigned long start,
-				  unsigned long end);
+extern void _tlbie(unsigned long address);
+extern void _tlbia(void);
+
+#ifdef CONFIG_4xx
+#ifdef CONFIG_PIN_TLB
+/* When pinning entries on the 4xx, we have to use a software function
+ * to ensure we don't remove them since there isn't any hardware support
+ * for this.
+ */
+#define __tlbia()	_tlbia()
+#else
+#define __tlbia()	asm volatile ("tlbia; sync" : : : "memory")
+#endif
+
+static inline void local_flush_tlb_all(void)
+	{ __tlbia(); }
+static inline void local_flush_tlb_mm(struct mm_struct *mm)
+	{ __tlbia(); }
+static inline void local_flush_tlb_page(struct vm_area_struct *vma,
+				unsigned long vmaddr)
+	{ _tlbie(vmaddr); }
+static inline void local_flush_tlb_range(struct mm_struct *mm,
+				unsigned long start, unsigned long end)
+	{ __tlbia(); }
 #define update_mmu_cache(vma, addr, pte)	do { } while (0)
 
 #elif defined(CONFIG_8xx)
-#define __tlbia()	asm volatile ("tlbia" : : )
+#define __tlbia()	asm volatile ("tlbia; sync" : : : "memory")
 
 static inline void local_flush_tlb_all(void)
 	{ __tlbia(); }
@@ -28,7 +46,7 @@
 	{ __tlbia(); }
 static inline void local_flush_tlb_page(struct vm_area_struct *vma,
 				unsigned long vmaddr)
-	{ __tlbia(); }
+	{ _tlbie(vmaddr); }
 static inline void local_flush_tlb_range(struct mm_struct *mm,
 				unsigned long start, unsigned long end)
 	{ __tlbia(); }
@@ -193,18 +211,46 @@
  * (hardware-defined) PowerPC PTE as closely as possible.
  */
 
-#if defined(CONFIG_4xx)
+#if defined(CONFIG_40x)
+
+/* There are several potential gotchas here.  The 40x hardware TLBLO
+   field looks like this:
+
+   0  1  2  3  4  ... 18 19 20 21 22 23 24 25 26 27 28 29 30 31
+   RPN.....................  0  0 EX WR ZSEL.......  W  I  M  G
+
+   Where possible we make the Linux PTE bits match up with this
+
+   - bits 20 and 21 must be cleared, because we use 4k pages (4xx can
+     support down to 1k pages), this is done in the TLBMiss exception
+     handler.
+   - We use only zones 0 (for kernel pages) and 1 (for user pages)
+     of the 16 available.  Bit 24-26 of the TLB are cleared in the TLB
+     miss handler.  Bit 27 is PAGE_USER, thus selecting the correct
+     zone.
+   - PRESENT *must* be in the bottom two bits because swap cache
+     entries use the top 30 bits.  Because 4xx doesn't support SMP
+     anyway, M is irrelevant so we borrow it for PAGE_PRESENT.  Bit 30
+     is cleared in the TLB miss handler before the TLB entry is loaded.
+   - All other bits of the PTE are loaded into TLBLO without
+     modification, leaving us only the bits 20, 21, 24, 25, 26, 30 for
+     software PTE bits.  We actually use use bits 21, 24, 25, and
+     30 respectively for the software bits: ACCESSED, DIRTY, RW, and
+     PRESENT.
+*/
+
 /* Definitions for 4xx embedded chips. */
 #define	_PAGE_GUARDED	0x001	/* G: page is guarded from prefetch */
-#define	_PAGE_COHERENT	0x002	/* M: enforece memory coherence */
+#define _PAGE_PRESENT	0x002	/* software: PTE contains a translation */
 #define	_PAGE_NO_CACHE	0x004	/* I: caching is inhibited */
 #define	_PAGE_WRITETHRU	0x008	/* W: caching is write-through */
 #define	_PAGE_USER	0x010	/* matches one of the zone permission bits */
-#define _PAGE_EXEC	0x020	/* software: i-cache coherency required */
-#define	_PAGE_PRESENT	0x040	/* software: PTE contains a translation */
-#define _PAGE_DIRTY	0x100	/* C: page changed */
-#define	_PAGE_RW	0x200	/* Writes permitted */
-#define _PAGE_ACCESSED	0x400	/* R: page referenced */
+#define	_PAGE_RW	0x040	/* software: Writes permitted */
+#define	_PAGE_DIRTY	0x080	/* software: dirty page */
+#define _PAGE_HWWRITE	0x100	/* hardware: Dirty & RW, set in exception */
+#define _PAGE_HWEXEC	0x200	/* hardware: EX permission */
+#define _PAGE_ACCESSED	0x400	/* software: R: page referenced */
+#define _PMD_PRESENT	PAGE_MASK
 
 #elif defined(CONFIG_8xx)
 /* Definitions for 8xx embedded chips. */
@@ -260,6 +306,12 @@
 #ifndef _PAGE_HWWRITE
 #define _PAGE_HWWRITE	0
 #endif
+#ifndef _PAGE_HWEXEC
+#define _PAGE_HWEXEC	0
+#endif
+#ifndef _PAGE_EXEC
+#define _PAGE_EXEC	0
+#endif
 
 #define _PAGE_CHG_MASK	(PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
 
@@ -272,7 +324,7 @@
 #define _PAGE_BASE	_PAGE_PRESENT | _PAGE_ACCESSED
 #define _PAGE_WRENABLE	_PAGE_RW | _PAGE_DIRTY | _PAGE_HWWRITE
 
-#define _PAGE_KERNEL	_PAGE_BASE | _PAGE_WRENABLE | _PAGE_SHARED
+#define _PAGE_KERNEL	_PAGE_BASE | _PAGE_WRENABLE | _PAGE_SHARED | _PAGE_HWEXEC
 #define _PAGE_IO	_PAGE_KERNEL | _PAGE_NO_CACHE | _PAGE_GUARDED
 
 #define PAGE_NONE	__pgprot(_PAGE_BASE)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc/ppc4xx.h linux-2.4.22-pre2/include/asm-ppc/ppc4xx.h
--- linux-2.4.21/include/asm-ppc/ppc4xx.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc/ppc4xx.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,282 +0,0 @@
-/*
- *
- *    Copyright (c) 1999 Grant Erickson <grant@lcse.umn.edu>
- *
- *    Module name: ppc4xx.h
- *
- *    Description:
- *	A generic include file which pulls in appropriate include files
- *      for specific board types based on configuration settings.
- *
- */
-
-#ifdef __KERNEL__
-#ifndef __PPC4XX_H__
-#define	__PPC4XX_H__
-
-#include <linux/config.h>
-
-#ifndef __ASSEMBLY__
-
-#if defined(CONFIG_OAK)
-#include <platforms/oak.h>
-#endif
-
-#if defined(CONFIG_WALNUT)
-#include <platforms/walnut.h>
-#endif
-
-/* IO_BASE is for PCI I/O.
- * ISA not supported, just here to resolve copilation.
- */
-
-#ifndef _IO_BASE
-#define _IO_BASE	0xe8000000	/* The PCI address window */
-#define _ISA_MEM_BASE	0
-#define PCI_DRAM_OFFSET	0
-#endif
-
-/*
- * The "residual" board information structure the boot loader passes
- * into the kernel.
- */
-extern unsigned char __res[];
-
-/* I don't know if this is general to 4xx, or unique to a specific
- * processor or board.  In any case it is easy to move.
- */
-#define PPC4xx_PCI_IO_ADDR	((uint)0xe8000000)
-#define PPC4xx_PCI_IO_SIZE	((uint)64*1024)
-#define PPC4xx_PCI_CFG_ADDR	((uint)0xeec00000)
-#define PPC4xx_PCI_CFG_SIZE	((uint)4*1024)
-#define PPC4xx_PCI_LCFG_ADDR	((uint)0xef400000)
-#define PPC4xx_PCI_LCFG_SIZE	((uint)4*1024)
-#define PPC4xx_ONB_IO_ADDR	((uint)0xef600000)
-#define PPC4xx_ONB_IO_SIZE	((uint)4*1024)
-
-#endif /* __ASSEMBLY__ */
-
-/* Device Control Registers unique to 4xx */
-
-#define	DCRN_BEAR	0x090	/* Bus Error Address Register */
-#define	DCRN_BESR	0x091	/* Bus Error Syndrome Register */
-#define	  BESR_DSES    	0x80000000	/* Data-Side Error Status */
-#define	  BESR_DMES	0x40000000	/* DMA Error Status */
-#define	  BESR_RWS	0x20000000	/* Read/Write Status */
-#define	  BESR_ETMASK	0x1C000000	/* Error Type */
-#define	    ET_PROT	0
-#define	    ET_PARITY	1
-#define	    ET_NCFG	2
-#define	    ET_BUSERR	4
-#define	    ET_BUSTO	6
-#define DCRN_CHCR0	0x0B1	/* Chip Control Register 1                    */
-#define DCRN_CHCR1	0x0B2	/* Chip Control Register 2                    */
-#define DCRN_CHPSR	0x0B4	/* Chip Pin Strapping                         */
-#define DCRN_CPMER	0x0B9	/* CPM Enable                                 */
-#define DCRN_CPMFR	0x0BA	/* CPM Force                                  */
-#define   CPM_IIC	0x80000000  /* IIC interface                          */
-#define   CPM_PCI	0x40000000  /* PCI bridge                             */
-#define   CPM_CPU	0x20000000  /* processor core                         */
-#define   CPM_DMA	0x10000000  /* DMA controller                         */
-#define   CPM_BRG	0x08000000  /* PLB to OPB bridge                      */
-#define   CPM_DCP	0x04000000  /* CodePack                               */
-#define   CPM_EBC	0x02000000  /* ROM/SRAM peripheral controller         */
-#define   CPM_SDRAM	0x01000000  /* SDRAM memory controller                */
-#define   CPM_PLB	0x00800000  /* PLB bus arbiter                        */
-#define   CPM_GPIO	0x00400000  /* General Purpose IO (??)                */
-#define   CPM_UART0	0x00200000  /* serial port 0                          */
-#define   CPM_UART1	0x00100000  /* serial port 1                          */
-#define   CPM_UIC	0x00080000  /* Universal Interrupt Controller         */
-#define   CPM_TMRCLK	0x00040000  /* CPU timers                             */
-#define   CPM_EMAC_MM	0x00020000  /* on-chip ethernet MM unit               */
-#define   CPM_EMAC_RM	0x00010000  /* on-chip ethernet RM unit               */
-#define   CPM_EMAC_TM	0x00008000  /* on-chip ethernet TM unit               */
-#define DCRN_CPMSR	0x0B8	/* CPM Status                                 */
-
-#define	DCRN_DMACR0	0x100	/* DMA Channel Control Register 0             */
-#define	DCRN_DMACT0	0x101	/* DMA Count Register 0                       */
-#define	DCRN_DMADA0	0x102	/* DMA Destination Address Register 0         */
-#define	DCRN_DMASA0	0x103	/* DMA Source Address Register 0              */
-#define DCRN_ASG0	0x104	/* DMA Scatter/Gather Descriptor Addr 0       */
-
-#define	DCRN_DMACR1	0x108	/* DMA Channel Control Register 1             */
-#define	DCRN_DMACT1	0x109	/* DMA Count Register 1                       */
-#define	DCRN_DMADA1	0x10A	/* DMA Destination Address Register 1         */
-#define	DCRN_DMASA1	0x10B	/* DMA Source Address Register 1              */
-#define DCRN_ASG1	0x10C	/* DMA Scatter/Gather Descriptor Addr 1       */
-
-#define	DCRN_DMACR2	0x110	/* DMA Channel Control Register 2             */
-#define	DCRN_DMACT2	0x111	/* DMA Count Register 2                       */
-#define	DCRN_DMADA2	0x112	/* DMA Destination Address Register 2         */
-#define	DCRN_DMASA2	0x113	/* DMA Source Address Register 2              */
-#define DCRN_ASG2	0x114	/* DMA Scatter/Gather Descriptor Addr 2       */
-
-#define	DCRN_DMACR3	0x118	/* DMA Channel Control Register 3             */
-#define	DCRN_DMACT3	0x119	/* DMA Count Register 3                       */
-#define	DCRN_DMADA3	0x11A	/* DMA Destination Address Register 3         */
-#define	DCRN_DMASA3	0x11B	/* DMA Source Address Register 3              */
-#define DCRN_ASG3	0x11C	/* DMA Scatter/Gather Descriptor Addr 3       */
-
-#define	DCRN_DMASR	0x120	/* DMA Status Register                        */
-#define DCRN_ASGC	0x123	/* DMA Scatter/Gather Command                 */
-#define DCRN_ADR	0x124	/* DMA Address Decode                         */
-
-#define DCRN_SLP        0x125   /* DMA Sleep Register                         */
-#define DCRN_POL        0x126   /* DMA Polarity Register                      */
-
-
-#define DCRN_EBCCFGADR	0x012	/* Peripheral Controller Address              */
-#define DCRN_EBCCFGDATA	0x013	/* Peripheral Controller Data                 */
-#define	DCRN_EXISR	0x040    /* External Interrupt Status Register */
-#define	DCRN_EXIER	0x042    /* External Interrupt Enable Register */
-#define	  EXIER_CIE	0x80000000	/* Critical Interrupt Enable */
-#define	  EXIER_SRIE	0x08000000	/* Serial Port Rx Int. Enable */
-#define	  EXIER_STIE	0x04000000	/* Serial Port Tx Int. Enable */
-#define	  EXIER_JRIE	0x02000000	/* JTAG Serial Port Rx Int. Enable */
-#define	  EXIER_JTIE	0x01000000	/* JTAG Serial Port Tx Int. Enable */
-#define	  EXIER_D0IE	0x00800000	/* DMA Channel 0 Interrupt Enable */
-#define	  EXIER_D1IE	0x00400000	/* DMA Channel 1 Interrupt Enable */
-#define	  EXIER_D2IE	0x00200000	/* DMA Channel 2 Interrupt Enable */
-#define	  EXIER_D3IE	0x00100000	/* DMA Channel 3 Interrupt Enable */
-#define	  EXIER_E0IE	0x00000010	/* External Interrupt 0 Enable */
-#define	  EXIER_E1IE	0x00000008	/* External Interrupt 1 Enable */
-#define	  EXIER_E2IE	0x00000004	/* External Interrupt 2 Enable */
-#define	  EXIER_E3IE	0x00000002	/* External Interrupt 3 Enable */
-#define	  EXIER_E4IE	0x00000001	/* External Interrupt 4 Enable */
-#define	DCRN_IOCR	0x0A0    /* Input/Output Configuration Register */
-#define	  IOCR_E0TE	0x80000000
-#define	  IOCR_E0LP	0x40000000
-#define	  IOCR_E1TE	0x20000000
-#define	  IOCR_E1LP	0x10000000
-#define	  IOCR_E2TE	0x08000000
-#define	  IOCR_E2LP	0x04000000
-#define	  IOCR_E3TE	0x02000000
-#define	  IOCR_E3LP	0x01000000
-#define	  IOCR_E4TE	0x00800000
-#define	  IOCR_E4LP	0x00400000
-#define	  IOCR_EDT     	0x00080000
-#define	  IOCR_SOR     	0x00040000
-#define	  IOCR_EDO	0x00008000
-#define	  IOCR_2XC	0x00004000
-#define	  IOCR_ATC	0x00002000
-#define	  IOCR_SPD	0x00001000
-#define	  IOCR_BEM	0x00000800
-#define	  IOCR_PTD	0x00000400
-#define	  IOCR_ARE	0x00000080
-#define	  IOCR_DRC	0x00000020
-#define	  IOCR_RDM(x)	(((x) & 0x3) << 3)
-#define	  IOCR_TCS	0x00000004
-#define	  IOCR_SCS	0x00000002
-#define	  IOCR_SPC	0x00000001
-#define DCRN_KIAR	0x014	/* Decompression Controller Address           */
-#define DCRN_KIDR	0x015	/* Decompression Controller Data              */
-#define DCRN_MALCR	0x180	/* MAL Configuration                          */
-#define   MALCR_MMSR    0x80000000    /* MAL Software reset                   */
-#define   MALCR_PLBP_1  0x00400000    /* MAL reqest priority:                 */
-#define   MALCR_PLBP_2  0x00800000    /*   lowsest is 00                      */
-#define   MALCR_PLBP_3  0x00C00000    /*   highest                            */
-#define   MALCR_GA      0x00200000    /* Guarded Active Bit                   */
-#define   MALCR_OA      0x00100000    /* Ordered Active Bit                   */
-#define   MALCR_PLBLE   0x00080000    /* PLB Lock Error Bit                   */
-#define   MALCR_PLBLT_1 0x00040000    /* PLB Latency Timer                    */
-#define   MALCR_PLBLT_2 0x00020000
-#define   MALCR_PLBLT_3 0x00010000
-#define   MALCR_PLBLT_4 0x00008000
-#define   MALCR_PLBLT_DEFAULT 0x00078000 /* JSP: Is this a valid default??    */
-#define   MALCR_PLBB    0x00004000    /* PLB Burst Deactivation Bit           */
-#define   MALCR_OPBBL   0x00000080    /* OPB Lock Bit                         */
-#define   MALCR_EOPIE   0x00000004    /* End Of Packet Interrupt Enable       */
-#define   MALCR_LEA     0x00000002    /* Locked Error Active                  */
-#define   MALCR_MSD     0x00000001    /* MAL Scroll Descriptor Bit            */
-#define DCRN_MALDBR     0x183   /* Debug Register                             */
-#define DCRN_MALESR	0x181	/* Error Status                               */
-#define   MALESR_EVB    0x80000000    /* Error Valid Bit                      */
-#define   MALESR_CID    0x40000000    /* Channel ID Bit  for channel 0        */
-#define   MALESR_DE     0x00100000    /* Descriptor Error                     */
-#define   MALESR_OEN    0x00080000    /* OPB Non-Fullword Error               */
-#define   MALESR_OTE    0x00040000    /* OPB Timeout Error                    */
-#define   MALESR_OSE    0x00020000    /* OPB Slave Error                      */
-#define   MALESR_PEIN   0x00010000    /* PLB Bus Error Indication             */
-#define   MALESR_DEI    0x00000010    /* Descriptor Error Interrupt           */
-#define   MALESR_ONEI   0x00000008    /* OPB Non-Fullword Error Interrupt     */
-#define   MALESR_OTEI   0x00000004    /* OPB Timeout Error Interrupt          */
-#define   MALESR_OSEI   0x00000002    /* OPB Slace Error Interrupt            */
-#define   MALESR_PBEI   0x00000001    /* PLB Bus Error Interrupt              */
-#define DCRN_MALIER	0x182	/* Interrupt Enable                           */
-#define   MALIER_DE     0x00000010    /* Descriptor Error Interrupt Enable    */
-#define   MALIER_NE     0x00000008    /* OPB Non-word Transfer Int Enable     */
-#define   MALIER_TE     0x00000004    /* OPB Time Out Error Interrupt Enable  */
-#define   MALIER_OPBE   0x00000002    /* OPB Slave Error Interrupt Enable     */
-#define   MALIER_PLBE   0x00000001    /* PLB Error Interrupt Enable           */
-#define DCRN_MALTXCARR  0x185   /* TX Channed Active Reset Register           */
-#define DCRN_MALTXCASR  0x184   /* TX Channel Active Set Register             */
-#define DCRN_MALTXDEIR	0x187	/* Tx Descriptor Error Interrupt              */
-#define DCRN_MALTXEOBISR    0x186   /* Tx End of Buffer Interrupt Status      */
-#define   MALOBISR_CH0  0x80000000    /* EOB channel 1 bit                    */
-#define   MALOBISR_CH2  0x40000000    /* EOB channel 2 bit                    */
-#define DCRN_MALRXCARR  0x191   /* RX Channed Active Reset Register           */
-#define DCRN_MALRXCASR  0x190   /* RX Channel Active Set Register             */
-#define DCRN_MALRXDEIR	0x193	/* Rx Descriptor Error Interrupt              */
-#define DCRN_MALRXEOBISR    0x192   /* Rx End of Buffer Interrupt Status      */
-#define DCRN_MALRXCTP0R	0x1C0	/* Channel Rx 0 Channel Table Pointer         */
-#define DCRN_MALTXCTP0R	0x1A0	/* Channel Tx 0 Channel Table Pointer         */
-#define DCRN_MALTXCTP1R	0x1A1	/* Channel Tx 1 Channel Table Pointer         */
-#define DCRN_MALRCBS0	0x1E0	/* Channel Rx 0 Channel Buffer Size           */
-#define DCRN_MEMCFGADR	0x010	/* Memory Controller Address                  */
-#define DCRN_MEMCFGDATA	0x011	/* Memory Controller Data                     */
-#define DCRN_OCMISARC	0x018	/* OCM Instr Side Addr Range Compare          */
-#define DCRN_OCMISCR	0x019	/* OCM Instr Side Control                     */
-#define DCRN_OCMDSARC	0x01A	/* OCM Data Side Addr Range Compare           */
-#define DCRN_OCMDSCR	0x01B	/* OCM Data Side Control                      */
-#define DCRN_PLB0_ACR	0x087	/* PLB Arbiter Control                        */
-#define DCRN_PLB0_BEAR	0x086	/* PLB Error Address                          */
-#define DCRN_PLB0_BESR	0x084	/* PLB Error Status                           */
-#define DCRN_PLLMR	0x0B0	/* PLL Mode                                   */
-#define DCRN_POB0_BEAR	0x0A2	/* PLB to OPB Error Address                   */
-#define DCRN_POB0_BESR0	0x0A0	/* PLB to OPB Error Status Register 1         */
-#define DCRN_POB0_BESR1	0x0A4	/* PLB to OPB Error Status Register 1         */
-#define DCRN_UICCR	0x0C3	/* UIC Critical                               */
-#define DCRN_UICER	0x0C2	/* UIC Enable                                 */
-#define DCRN_UICPR	0x0C4	/* UIC Polarity                               */
-#define DCRN_UICSR	0x0C0	/* UIC Status                                 */
-#define DCRN_UICTR	0x0C5	/* UIC Triggering                             */
-#define DCRN_UICMSR	0x0C6	/* UIC Masked Status                          */
-#define DCRN_UICVR	0x0C7	/* UIC Vector                                 */
-#define DCRN_UICVCR	0x0C8	/* UIC Vector Configuration                   */
-#define   UIC_U0	0x80000000  /* UART0                                  */
-#define   UIC_U1	0x40000000  /* UART1                                  */
-#define   UIC_IIC	0x20000000  /* IIC                                    */
-#define   UIC_EM	0x10000000  /* External Master                        */
-#define   UIC_PCI	0x08000000  /* PCI                                    */
-#define   UIC_D0	0x04000000  /* DMA Channel 0                          */
-#define   UIC_D1	0x02000000  /* DMA Channel 1                          */
-#define   UIC_D2	0x01000000  /* DMA Channel 2                          */
-#define   UIC_D3	0x00800000  /* DMA Channel 3                          */
-#define   UIC_EW	0x00400000  /* Ethernet Wake-up                       */
-#define   UIC_MS	0x00200000  /* MAL SERR                               */
-#define   UIC_MTE	0x00100000  /* MAL TX EOB                             */
-#define   UIC_MRE	0x00080000  /* MAL RX EOB                             */
-#define   UIC_MTD	0x00040000  /* MAL TX DE                              */
-#define   UIC_MRD	0x00020000  /* MAL RX DE                              */
-#define   UIC_E		0x00010000  /* Ethernet                               */
-#define   UIC_EPS	0x00008000  /* External PCI SERR                      */
-#define   UIC_EC	0x00004000  /* ECC Correctable Error                  */
-#define   UIC_PPM	0x00002000  /* PCI Power Management                   */
-/*
-**			0x00001000  reserved
-**			0x00000800  reserved
-**			0x00000400  reserved
-**			0x00000200  reserved
-**			0x00000100  reserved
-**			0x00000080  reserved
-*/
-#define   UIC_EIR0	0x00000040  /* External IRQ 0                         */
-#define   UIC_EIR1	0x00000020  /* External IRQ 0                         */
-#define   UIC_EIR2	0x00000010  /* External IRQ 0                         */
-#define   UIC_EIR3	0x00000008  /* External IRQ 0                         */
-#define   UIC_EIR4	0x00000004  /* External IRQ 0                         */
-#define   UIC_EIR5	0x00000002  /* External IRQ 0                         */
-#define   UIC_EIR6	0x00000001  /* External IRQ 0                         */
-
-#endif /* __PPC4XX_H__ */
-#endif /* __KERNEL__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc/ppc4xx_pic.h linux-2.4.22-pre2/include/asm-ppc/ppc4xx_pic.h
--- linux-2.4.21/include/asm-ppc/ppc4xx_pic.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc/ppc4xx_pic.h	2003-06-26 21:43:17.000000000 +0000
@@ -12,15 +12,22 @@
 #define	__PPC4XX_PIC_H__
 
 #include <linux/config.h>
+#include <linux/irq.h>
 
 /* External Global Variables */
-
 extern struct hw_interrupt_type *ppc4xx_pic;
 
+/*
+ * The IBM4xxPIC_InitSenses table gives sense/polarity information
+ * for each interrupt, encoded using IRQ_SENSE_* and IRQ_POLARITY_*
+ * definitions from <asm-ppc/irq.h>.  -- paulus
+ */
+extern unsigned int ibm4xxPIC_NumInitSenses;
+extern unsigned char *ibm4xxPIC_InitSenses;
 
 /* Function Prototypes */
 
-extern void	 ppc4xx_pic_init(void);
-extern int	 ppc4xx_pic_get_irq(struct pt_regs *regs);
+extern void ppc4xx_pic_init(void);
+extern int ppc4xx_pic_get_irq(struct pt_regs *regs);
 
-#endif /* __PPC4XX_PIC_H__ */
+#endif				/* __PPC4XX_PIC_H__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc/ppc4xx_serial.h linux-2.4.22-pre2/include/asm-ppc/ppc4xx_serial.h
--- linux-2.4.21/include/asm-ppc/ppc4xx_serial.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc/ppc4xx_serial.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,101 +0,0 @@
-/*
- *    Copyright 2000 MontaVista Software Inc.
- *	PPC405GP modifications
- * 	Author: MontaVista Software, Inc.
- *         	frank_rowand@mvista.com or source@mvista.com
- * 	   	debbie_chu@mvista.com
- *
- *    Module name: ppc405_serial.h
- *
- *    Description:
- *      Macros, definitions, and data structures specific to the IBM PowerPC
- *      405 on-chip serial port devices.
- */
-
-#ifdef __KERNEL__
-#ifndef __ASMPPC_PPC4xx_SERIAL_H
-#define __ASMPPC_PPC4xx_SERIAL_H
-
-#include <linux/config.h>
-
-#ifdef CONFIG_SERIAL_MANY_PORTS
-#define RS_TABLE_SIZE	64
-#else
-#define RS_TABLE_SIZE	4
-#endif
-
-#define PPC405GP_UART0_INT	0
-#define PPC405GP_UART1_INT	1
-
-/*
-** 405GP UARTs are *not* PCI devices, so need to specify a non-pci memory
-** address and an io_type of SERIAL_IO_MEM.
-*/
-
-#define PPC405GP_UART0_IO_BASE	(u8 *) 0xef600300
-#define PPC405GP_UART1_IO_BASE	(u8 *) 0xef600400
-
-/*
-**  - there is no config option for this
-**  - this name could be more informative
-**  - also see arch/ppc/kernel/ppc405_serial.c
-**
-** #define CONFIG_PPC405GP_INTERNAL_CLOCK
-*/
-#ifdef	CONFIG_PPC405GP_INTERNAL_CLOCK
-#define BASE_BAUD		201600
-#else
-#define BASE_BAUD		691200
-#endif
-
-
-#ifdef CONFIG_SERIAL_DETECT_IRQ
-#define STD_COM_FLAGS	(ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ)
-#define STD_COM4_FLAGS	(ASYNC_BOOT_AUTOCONF | ASYNC_AUTO_IRQ)
-#else
-#define STD_COM_FLAGS	(ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-#define STD_COM4_FLAGS	(ASYNC_BOOT_AUTOCONF)
-#endif
-
-
-#ifdef CONFIG_STB03XXX
-
-#define UART0_IO_BASE 0x40040000
-#define UART0_INT     20
-
-#define STD_SERIAL_PORT_DFNS \
-    /* ttyS0 */ \
-    { 0, BASE_BAUD, 0, UART0_INT, STD_COM_FLAGS, 0, 0, 0, 0, 0, 0, 0, \
-    UART0_IO_BASE, 0, 0, 0, {}, {}, {}, SERIAL_IO_MEM, NULL },
-
-#elif defined(CONFIG_UART1_DFLT_CONSOLE)
-
-#define STD_SERIAL_PORT_DFNS \
-    /* ttyS1 */ \
-    { 0, BASE_BAUD, 0, PPC405GP_UART1_INT, STD_COM_FLAGS, 0, 0, 0, 0, 0, 0, 0, \
-    PPC405GP_UART1_IO_BASE, 0, 0, 0, {}, {}, {}, SERIAL_IO_MEM, NULL },        \
-    /* ttyS0 */ \
-    { 0, BASE_BAUD, 0, PPC405GP_UART0_INT, STD_COM_FLAGS, 0, 0, 0, 0, 0, 0, 0, \
-    PPC405GP_UART0_IO_BASE, 0, 0, 0, {}, {}, {}, SERIAL_IO_MEM, NULL },
-
-#else
-
-#define STD_SERIAL_PORT_DFNS \
-    /* ttyS0 */ \
-    { 0, BASE_BAUD, 0, PPC405GP_UART0_INT, STD_COM_FLAGS, 0, 0, 0, 0, 0, 0, 0, \
-    PPC405GP_UART0_IO_BASE, 0, 0, 0, {}, {}, {}, SERIAL_IO_MEM, NULL },        \
-    /* ttyS1 */ \
-    { 0, BASE_BAUD, 0, PPC405GP_UART1_INT, STD_COM_FLAGS, 0, 0, 0, 0, 0, 0, 0, \
-    PPC405GP_UART1_IO_BASE, 0, 0, 0, {}, {}, {}, SERIAL_IO_MEM, NULL },
-
-#endif
-
-
-#define SERIAL_PORT_DFNS     \
-	STD_SERIAL_PORT_DFNS \
-	{}
-
-
-
-#endif	/* __ASMPPC_PPC4xx_SERIAL_H */
-#endif /* __KERNEL__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc/ppc_asm.h linux-2.4.22-pre2/include/asm-ppc/ppc_asm.h
--- linux-2.4.21/include/asm-ppc/ppc_asm.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc/ppc_asm.h	2003-06-26 21:43:11.000000000 +0000
@@ -147,7 +147,11 @@
 
 #else
 #define FIX_SRR1(ra, rb)
+#ifndef CONFIG_4xx
 #define	RFI		rfi
+#else
+#define RFI		rfi; b .	/* prevent prefetch past rfi */
+#endif
 #define MTMSRD(r)	mtmsr	r
 #define CLR_TOP32(r)
 #endif /* CONFIG_PPC64BRIDGE */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc/processor.h linux-2.4.22-pre2/include/asm-ppc/processor.h
--- linux-2.4.21/include/asm-ppc/processor.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc/processor.h	2003-06-26 21:43:10.000000000 +0000
@@ -142,11 +142,33 @@
 #define	  DBCR_SDA	0x00000004	/* Second DAC Enable */
 #define	  DBCR_JOI	0x00000002	/* JTAG Serial Outbound Int. Enable */
 #define	  DBCR_JII	0x00000001	/* JTAG Serial Inbound Int. Enable */
-#define	SPRN_DBCR0	0x3F2	/* Debug Control Register 0 */
-#define	SPRN_DBCR1	0x3BD	/* Debug Control Register 1 */
-#define	SPRN_DBSR	0x3F0	/* Debug Status Register */
-#define   DBSR_IC	    0x80000000	/* Instruction Completion             */
-#define   DBSR_TIE	    0x10000000	/* Trap Instruction debug Event       */
+#define	SPRN_DBCR0	0x3F2		/* Debug Control Register 0 */
+#define   DBCR0_EDM         0x80000000  /* External Debug Mode             */
+#define   DBCR0_IDM         0x40000000  /* Internal Debug Mode             */
+#define   DBCR0_RST         0x30000000  /* all the bits in the RST field   */
+#define   DBCR0_RST_SYSTEM  0x30000000  /* System Reset                    */
+#define   DBCR0_RST_CHIP    0x20000000  /* Chip   Reset                    */
+#define   DBCR0_RST_CORE    0x10000000  /* Core   Reset                    */
+#define   DBCR0_RST_NONE    0x00000000  /* No     Reset                    */
+#define   DBCR0_IC          0x08000000  /* Instruction Completion          */
+#define   DBCR0_BT          0x04000000  /* Branch Taken                    */
+#define   DBCR0_EDE         0x02000000  /* Exception Debug Event           */
+#define   DBCR0_TDE         0x01000000  /* TRAP Debug Event                */
+#define   DBCR0_IA1         0x00800000  /* Instr Addr compare 1 enable     */
+#define   DBCR0_IA2         0x00400000  /* Instr Addr compare 2 enable     */
+#define   DBCR0_IA12        0x00200000  /* Instr Addr 1-2 range enable     */
+#define   DBCR0_IA12X       0x00100000  /* Instr Addr 1-2 range eXclusive  */
+#define   DBCR0_IA3         0x00080000  /* Instr Addr compare 3 enable     */
+#define   DBCR0_IA4         0x00040000  /* Instr Addr compare 4 enable     */
+#define   DBCR0_IA34        0x00020000  /* Instr Addr 3-4 range Enable     */
+#define   DBCR0_IA34X       0x00010000  /* Instr Addr 3-4 range eXclusive  */
+#define   DBCR0_IA12T       0x00008000  /* Instr Addr 1-2 range Toggle     */
+#define   DBCR0_IA34T       0x00004000  /* Instr Addr 3-4 range Toggle     */
+#define   DBCR0_FT          0x00000001  /* Freeze Timers on debug event    */
+#define	SPRN_DBCR1	0x3BD		/* Debug Control Register 1 */
+#define	SPRN_DBSR	0x3F0		/* Debug Status Register */
+#define   DBSR_IC	    0x80000000	/* Instruction Completion          */
+#define   DBSR_TIE	    0x10000000	/* Trap Instruction debug Event    */
 #define	SPRN_DCCR	0x3FA	/* Data Cache Cacheability Register */
 #define	  DCCR_NOCACHE		0	/* Noncacheable */
 #define	  DCCR_CACHE		1	/* Cacheable */
@@ -176,10 +198,10 @@
 #define   DER_IBRKE	0x00000004	/* Instruction Breakpoint Interrupt */
 #define   DER_EBRKE	0x00000002	/* External Breakpoint Interrupt */
 #define   DER_DPIE	0x00000001	/* Dev. Port Nonmaskable Request */
-#define	SPRN_DMISS	0x3D0	/* Data TLB Miss Register */
-#define	SPRN_DSISR	0x012	/* Data Storage Interrupt Status Register */
-#define	SPRN_EAR	0x11A	/* External Address Register */
-#define	SPRN_ESR	0x3D4	/* Exception Syndrome Register */
+#define	SPRN_DMISS	0x3D0		/* Data TLB Miss Register */
+#define	SPRN_DSISR	0x012		/* Data Storage Interrupt Status Register */
+#define	SPRN_EAR	0x11A		/* External Address Register */
+#define	SPRN_ESR	0x3D4		/* Exception Syndrome Register */
 #define	  ESR_IMCP	0x80000000	/* Instr. Machine Check - Protection */
 #define	  ESR_IMCN	0x40000000	/* Instr. Machine Check - Non-config */
 #define	  ESR_IMCB	0x20000000	/* Instr. Machine Check - Bus error */
@@ -343,10 +365,15 @@
 #define	SPRN_SRR1	0x01B	/* Save/Restore Register 1 */
 #define	SPRN_SRR2	0x3DE	/* Save/Restore Register 2 */
 #define	SPRN_SRR3 	0x3DF	/* Save/Restore Register 3 */
+#define	SPRN_SU0R	0x3BC	/* "User 0" real mode */
+#define	SPRN_TBHI	0x3DC	/* Time Base High (4xx) */
+#define	SPRN_TBHU	0x3CC	/* Time Base High User-mode (4xx) */
+#define	SPRN_TBLO	0x3DD	/* Time Base Low (4xx) */
+#define	SPRN_TBLU	0x3CD	/* Time Base Low User-mode (4xx) */
 #define	SPRN_TBRL	0x10C	/* Time Base Read Lower Register (user, R/O) */
 #define	SPRN_TBRU	0x10D	/* Time Base Read Upper Register (user, R/O) */
-#define	SPRN_TBWL	0x11C	/* Time Base Lower Register (supervisor, R/W) */
-#define	SPRN_TBWU	0x11D	/* Time Base Upper Register (supervisor, R/W) */
+#define	SPRN_TBWL	0x11C	/* Time Base Lower Register (super, R/W) */
+#define	SPRN_TBWU	0x11D	/* Time Base Upper Register (super, R/W) */
 #define	SPRN_TCR	0x3DA	/* Timer Control Register */
 #define	  TCR_WP(x)		(((x)&0x3)<<30)	/* WDT Period */
 #define	    WP_2_17		0		/* 2^17 clocks */
@@ -423,6 +450,7 @@
 #define	DBAT7U	SPRN_DBAT7U	/* Data BAT 7 Upper Register */
 #define	DCMP	SPRN_DCMP      	/* Data TLB Compare Register */
 #define	DEC	SPRN_DEC       	/* Decrement Register */
+#define DECAR	SPRN_DECAR	/* Decrementer Auto Reload Register */
 #define	DMISS	SPRN_DMISS     	/* Data TLB Miss Register */
 #define	DSISR	SPRN_DSISR	/* Data Storage Interrupt Status Register */
 #define	EAR	SPRN_EAR       	/* External Address Register */
@@ -456,6 +484,7 @@
 #define	PVR	SPRN_PVR	/* Processor Version */
 #define	RPA	SPRN_RPA	/* Required Physical Address Register */
 #define	SDR1	SPRN_SDR1      	/* MMU hash base register */
+#define USPRG0	SPRN_USPRG0
 #define	SPR0	SPRN_SPRG0	/* Supervisor Private Registers */
 #define	SPR1	SPRN_SPRG1
 #define	SPR2	SPRN_SPRG2
@@ -668,6 +697,10 @@
 	vector128	vscr;		/* AltiVec status */
 	unsigned long	vrsave;
 #endif /* CONFIG_ALTIVEC */
+#if defined(CONFIG_4xx)
+	/* Saved 4xx debug registers */
+	unsigned long dbcr0;
+#endif
 };
 
 #define INIT_SP		(sizeof(init_stack) + (unsigned long) &init_stack)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc/ptrace.h linux-2.4.22-pre2/include/asm-ppc/ptrace.h
--- linux-2.4.21/include/asm-ppc/ptrace.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc/ptrace.h	2003-06-26 21:43:10.000000000 +0000
@@ -31,7 +31,7 @@
 					/* Used on APUS to hold IPL value. */
 	unsigned long trap;		/* Reason for being here */
 	unsigned long dar;		/* Fault registers */
-	unsigned long dsisr;
+	unsigned long dsisr;		/* used for ESR on 4xx/Book-E */
 	unsigned long result; 		/* Result of a system call */
 };
 #endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc/serial.h linux-2.4.22-pre2/include/asm-ppc/serial.h
--- linux-2.4.21/include/asm-ppc/serial.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc/serial.h	2003-06-26 21:43:32.000000000 +0000
@@ -14,128 +14,21 @@
 #include <platforms/lopec_serial.h>
 #elif defined(CONFIG_SPRUCE)
 #include <platforms/spruce.h>
-#elif defined(CONFIG_4xx)
-#include <asm/ppc4xx_serial.h>
+#elif defined(CONFIG_40x)
+#include <asm/ibm4xx.h>
 #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.
+ * XXX Assume for now it has PC-style ISA serial ports.
+ * This is true for PReP and CHRP at least.
  */
-#define BASE_BAUD ( 1843200 / 16 )
+#include <asm/pc_serial.h>
+#include <asm/processor.h>
 
-#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_SKIP_TEST | ASYNC_AUTO_IRQ)
-#define STD_COM4_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_AUTO_IRQ)
-#else
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-#define STD_COM4_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, 0x3E8, 4, STD_COM_FLAGS },	/* ttyS2 */	\
-	{ 0, BASE_BAUD, 0x2E8, 3, STD_COM4_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
+#if defined(CONFIG_MAC_SERIAL)
+#define SERIAL_DEV_OFFSET	((_machine == _MACH_prep || _machine == _MACH_chrp) ? 0 : 2)
 #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
-
 #endif /* !CONFIG_GEMINI and others */
 #endif /* __ASM_SERIAL_H__ */
 #endif /* __KERNEL__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc/time.h linux-2.4.22-pre2/include/asm-ppc/time.h
--- linux-2.4.21/include/asm-ppc/time.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc/time.h	2003-06-26 21:43:11.000000000 +0000
@@ -29,14 +29,14 @@
 int via_calibrate_decr(void);
 
 /* Accessor functions for the decrementer register.
- * The 4xx doesn't even have a decrementer.  I tried to use the
- * generic timer interrupt code, which seems OK, with the 4xx PIT
+ * The 40x doesn't even have a decrementer.  I tried to use the
+ * generic timer interrupt code, which seems OK, with the 40x PIT
  * in auto-reload mode.  The problem is PIT stops counting when it
  * hits zero.  If it would wrap, we could use it just like a decrementer.
  */
 static __inline__ unsigned int get_dec(void)
 {
-#if defined(CONFIG_4xx)
+#if defined(CONFIG_40x)
 	return (mfspr(SPRN_PIT));
 #else
 	return (mfspr(SPRN_DEC));
@@ -45,7 +45,7 @@
 
 static __inline__ void set_dec(unsigned int val)
 {
-#if defined(CONFIG_4xx)
+#if defined(CONFIG_40x)
 	return;		/* Have to let it auto-reload */
 #elif defined(CONFIG_8xx_CPU6)
 	set_dec_cpu6(val);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc/walnut.h linux-2.4.22-pre2/include/asm-ppc/walnut.h
--- linux-2.4.21/include/asm-ppc/walnut.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc/walnut.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,55 +0,0 @@
-/*
- *
- *    Copyright (c) 1999 Grant Erickson <grant@lcse.umn.edu>
- *
- *    Copyright 2000 MontaVista Software Inc.
- *	PPC405 modifications
- * 	Author: MontaVista Software, Inc.
- *         	frank_rowand@mvista.com or source@mvista.com
- * 	   	debbie_chu@mvista.com
- *
- *    Module name: ppc405.h
- *
- *    Description:
- *      Macros, definitions, and data structures specific to the IBM PowerPC
- *      based boards.
- *
- *      This includes:
- *
- *         405GP "Walnut" evaluation board
- *
- */
-
-#ifdef __KERNEL__
-#ifndef	__WALNUT_H__
-#define	__WALNUT_H__
-
-#ifndef __ASSEMBLY__
-/*
- * Data structure defining board information maintained by the boot
- * ROM on IBM's "Walnut" evaluation board. An effort has been made to
- * keep the field names consistent with the 8xx 'bd_t' board info
- * structures.
- */
-
-typedef struct board_info {
-	unsigned char	 bi_s_version[4];	/* Version of this structure */
-	unsigned char	 bi_r_version[30];	/* Version of the IBM ROM */
-	unsigned int	 bi_memsize;		/* DRAM installed, in bytes */
-	unsigned char	 bi_enetaddr[6];	/* Local Ethernet MAC address */
-	unsigned char	 bi_pci_enetaddr[6];	/* PCI Ethernet MAC address */
-	unsigned int	 bi_procfreq;		/* Processor speed, in Hz */
-	unsigned int	 bi_plb_busfreq;	/* PLB Bus speed, in Hz */
-	unsigned int	 bi_pci_busfreq;	/* PCI Bus speed, in Hz */
-} bd_t;
-
-#endif /* !__ASSEMBLY__ */
-
-/* Memory map for the IBM "Walnut" 405GP evaluation board.
- * Generic 4xx plus RTC.
- */
-#define WALNUT_RTC_ADDR		((uint)0xf0001000)
-#define WALNUT_RTC_SIZE		((uint)4*1024)
-
-#endif /* __WALNUT_H__ */
-#endif /* __KERNEL__ */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc64/cputable.h linux-2.4.22-pre2/include/asm-ppc64/cputable.h
--- linux-2.4.21/include/asm-ppc64/cputable.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc64/cputable.h	2003-06-26 21:43:27.000000000 +0000
@@ -0,0 +1,152 @@
+/*
+ *  include/asm-ppc/cputable.h
+ *
+ *  Copyright (C) 2001 Ben. Herrenschmidt (benh@kernel.crashing.org)
+ *
+ *  Modifications for ppc64:
+ *      Copyright (C) 2003 Dave Engebretsen <engebret@us.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.
+ */
+
+#ifndef __ASM_PPC_CPUTABLE_H
+#define __ASM_PPC_CPUTABLE_H
+
+/* Exposed to userland CPU features - Must match ppc32 definitions */
+#define PPC_FEATURE_32			0x80000000
+#define PPC_FEATURE_64			0x40000000
+#define PPC_FEATURE_601_INSTR		0x20000000
+#define PPC_FEATURE_HAS_ALTIVEC		0x10000000
+#define PPC_FEATURE_HAS_FPU		0x08000000
+#define PPC_FEATURE_HAS_MMU		0x04000000
+#define PPC_FEATURE_HAS_4xxMAC		0x02000000
+#define PPC_FEATURE_UNIFIED_CACHE	0x01000000
+
+#ifdef __KERNEL__
+
+#ifndef __ASSEMBLY__
+
+/* This structure can grow, it's real size is used by head.S code
+ * via the mkdefs mecanism.
+ */
+struct cpu_spec;
+
+typedef	void (*cpu_setup_t)(unsigned long offset, struct cpu_spec* spec);
+
+struct cpu_spec {
+	/* CPU is matched via (PVR & pvr_mask) == pvr_value */
+	unsigned int	pvr_mask;
+	unsigned int	pvr_value;
+
+	char		*cpu_name;
+	unsigned long	cpu_features;		/* Kernel features */
+	unsigned int	cpu_user_features;	/* Userland features */
+
+	/* cache line sizes */
+	unsigned int	icache_bsize;
+	unsigned int	dcache_bsize;
+
+	/* this is called to initialize various CPU bits like L1 cache,
+	 * BHT, SPD, etc... from head.S before branching to identify_machine
+	 */
+	cpu_setup_t	cpu_setup;
+
+	/* This is used to identify firmware features which are available
+	 * to the kernel.
+	 */
+	unsigned long   firmware_features;
+};
+
+extern struct cpu_spec		cpu_specs[];
+extern struct cpu_spec		*cur_cpu_spec;
+
+
+/* firmware feature bitmask values */
+#define FIRMWARE_MAX_FEATURES 63
+
+#define FW_FEATURE_PFT		(1UL<<0)
+#define FW_FEATURE_TCE		(1UL<<1)	
+#define FW_FEATURE_SPRG0	(1UL<<2)	
+#define FW_FEATURE_DABR		(1UL<<3)	
+#define FW_FEATURE_COPY		(1UL<<4)	
+#define FW_FEATURE_ASR		(1UL<<5)	
+#define FW_FEATURE_DEBUG	(1UL<<6)	
+#define FW_FEATURE_PERF		(1UL<<7)	
+#define FW_FEATURE_DUMP		(1UL<<8)	
+#define FW_FEATURE_INTERRUPT	(1UL<<9)	
+#define FW_FEATURE_MIGRATE	(1UL<<10)	
+
+typedef struct {
+    unsigned long val;
+    char * name;
+} firmware_feature_t;
+
+extern firmware_feature_t firmware_features_table[];
+
+#endif /* __ASSEMBLY__ */
+
+/* CPU kernel features */
+
+/* Retain the 32b definitions for the time being - use bottom half of word */
+#define CPU_FTR_SPLIT_ID_CACHE		0x0000000000000001
+#define CPU_FTR_L2CR			0x0000000000000002
+#define CPU_FTR_SPEC7450		0x0000000000000004
+#define CPU_FTR_ALTIVEC			0x0000000000000008
+#define CPU_FTR_TAU			0x0000000000000010
+#define CPU_FTR_CAN_DOZE		0x0000000000000020
+#define CPU_FTR_USE_TB			0x0000000000000040
+#define CPU_FTR_604_PERF_MON		0x0000000000000080
+#define CPU_FTR_601			0x0000000000000100
+#define CPU_FTR_HPTE_TABLE		0x0000000000000200
+#define CPU_FTR_CAN_NAP			0x0000000000000400
+#define CPU_FTR_L3CR			0x0000000000000800
+#define CPU_FTR_L3_DISABLE_NAP		0x0000000000001000
+#define CPU_FTR_NAP_DISABLE_L2_PR	0x0000000000002000
+#define CPU_FTR_DUAL_PLL_750FX		0x0000000000004000
+
+/* Add the 64b processor unique features in the top half of the word */
+#define CPU_FTR_SLB           		0x0000000100000000
+#define CPU_FTR_16M_PAGE      		0x0000000200000000
+#define CPU_FTR_TLBIEL         		0x0000000400000000
+#define CPU_FTR_NOEXECUTE     		0x0000000800000000
+#define CPU_FTR_NODSISRALIGN  		0x0000001000000000
+
+/* Platform firmware features */
+#define FW_FTR_                         0x0000000000000001
+
+#ifndef __ASSEMBLY__
+#define COMMON_USER_PPC64	(PPC_FEATURE_32 | PPC_FEATURE_64 | \
+			         PPC_FEATURE_HAS_FPU | PPC_FEATURE_HAS_MMU)
+
+#define CPU_FTR_PPCAS_ARCH_V2   (CPU_FTR_SLB | CPU_FTR_16M_PAGE | \
+                                 CPU_FTR_TLBIEL | CPU_FTR_NOEXECUTE | \
+                                 CPU_FTR_NODSISRALIGN)
+
+#define COMMON_PPC64_FW	(0)
+#endif
+
+#ifdef __ASSEMBLY__
+
+#define BEGIN_FTR_SECTION		98:
+
+#define END_FTR_SECTION(msk, val)		\
+99:						\
+	.section __ftr_fixup,"a";		\
+	.align 3;				\
+	.llong msk;			        \
+	.llong val;			        \
+	.llong 98b;			        \
+	.llong 99b;	 		        \
+	.previous
+
+#define END_FTR_SECTION_IFSET(msk)	END_FTR_SECTION((msk), (msk))
+#define END_FTR_SECTION_IFCLR(msk)	END_FTR_SECTION((msk), 0)
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* __ASM_PPC_CPUTABLE_H */
+#endif /* __KERNEL__ */
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc64/eeh.h linux-2.4.22-pre2/include/asm-ppc64/eeh.h
--- linux-2.4.21/include/asm-ppc64/eeh.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc64/eeh.h	2003-06-26 21:43:15.000000000 +0000
@@ -82,8 +82,10 @@
 /* #define EEH_POSSIBLE_IO_ERROR(val) (~(val) == 0) */
 /* #define EEH_POSSIBLE_ERROR(addr, vaddr, val) ((vaddr) != (addr) && EEH_POSSIBLE_IO_ERROR(val) */
 /* This version is rearranged to collect some profiling data */
-#define EEH_POSSIBLE_IO_ERROR(val) (~(val) == 0 && ++eeh_total_mmio_ffs)
-#define EEH_POSSIBLE_ERROR(addr, vaddr, val) (EEH_POSSIBLE_IO_ERROR(val) && (vaddr) != (addr))
+#define EEH_POSSIBLE_IO_ERROR(val, type)				\
+		((val) == (type)~0 && ++eeh_total_mmio_ffs)
+#define EEH_POSSIBLE_ERROR(addr, vaddr, val, type)			\
+		(EEH_POSSIBLE_IO_ERROR(val, type) && (vaddr) != (addr))
 
 /* 
  * MMIO read/write operations with EEH support.
@@ -102,7 +104,7 @@
 static inline u8 eeh_readb(void *addr) {
 	volatile u8 *vaddr = (volatile u8 *)IO_TOKEN_TO_ADDR(addr);
 	u8 val = in_8(vaddr);
-	if (EEH_POSSIBLE_ERROR(addr, vaddr, val))
+	if (EEH_POSSIBLE_ERROR(addr, vaddr, val, u8))
 		return eeh_check_failure(addr, val);
 	return val;
 }
@@ -113,7 +115,7 @@
 static inline u16 eeh_readw(void *addr) {
 	volatile u16 *vaddr = (volatile u16 *)IO_TOKEN_TO_ADDR(addr);
 	u16 val = in_le16(vaddr);
-	if (EEH_POSSIBLE_ERROR(addr, vaddr, val))
+	if (EEH_POSSIBLE_ERROR(addr, vaddr, val, u16))
 		return eeh_check_failure(addr, val);
 	return val;
 }
@@ -121,10 +123,21 @@
 	volatile u16 *vaddr = (volatile u16 *)IO_TOKEN_TO_ADDR(addr);
 	out_le16(vaddr, val);
 }
+static inline u16 eeh_raw_readw(void *addr) {
+       volatile u16 *vaddr = (volatile u16 *)IO_TOKEN_TO_ADDR(addr);
+       u16 val = in_be16(vaddr);
+       if (EEH_POSSIBLE_ERROR(addr, vaddr, val, u16))
+               return eeh_check_failure(addr, val);
+       return val;
+}
+static inline void eeh_raw_writew(u16 val, void *addr) {
+       volatile u16 *vaddr = (volatile u16 *)IO_TOKEN_TO_ADDR(addr);
+       out_be16(vaddr, val);
+}
 static inline u32 eeh_readl(void *addr) {
 	volatile u32 *vaddr = (volatile u32 *)IO_TOKEN_TO_ADDR(addr);
 	u32 val = in_le32(vaddr);
-	if (EEH_POSSIBLE_ERROR(addr, vaddr, val))
+	if (EEH_POSSIBLE_ERROR(addr, vaddr, val, u32))
 		return eeh_check_failure(addr, val);
 	return val;
 }
@@ -132,6 +145,17 @@
 	volatile u32 *vaddr = (volatile u32 *)IO_TOKEN_TO_ADDR(addr);
 	out_le32(vaddr, val);
 }
+static inline u32 eeh_raw_readl(void *addr) {
+       volatile u32 *vaddr = (volatile u32 *)IO_TOKEN_TO_ADDR(addr);
+       u32 val = in_be32(vaddr);
+       if (EEH_POSSIBLE_ERROR(addr, vaddr, val, u32))
+               return eeh_check_failure(addr, val);
+       return val;
+}
+static inline void eeh_raw_writel(u32 val, void *addr) {
+       volatile u32 *vaddr = (volatile u32 *)IO_TOKEN_TO_ADDR(addr);
+       out_be32(vaddr, val);
+}
 
 static inline void eeh_memset_io(void *addr, int c, unsigned long n) {
 	void *vaddr = (void *)IO_TOKEN_TO_ADDR(addr);
@@ -159,7 +183,7 @@
 	if (_IO_IS_ISA(port) && !_IO_HAS_ISA_BUS)
 		return ~0;
 	val = in_8((u8 *)(port+pci_io_base));
-	if (!_IO_IS_ISA(port) && EEH_POSSIBLE_IO_ERROR(val))
+	if (!_IO_IS_ISA(port) && EEH_POSSIBLE_IO_ERROR(val, u8))
 		return eeh_check_failure((void*)(port+pci_io_base), val);
 	return val;
 }
@@ -174,7 +198,7 @@
 	if (_IO_IS_ISA(port) && !_IO_HAS_ISA_BUS)
 		return ~0;
 	val = in_le16((u16 *)(port+pci_io_base));
-	if (!_IO_IS_ISA(port) && EEH_POSSIBLE_IO_ERROR(val))
+	if (!_IO_IS_ISA(port) && EEH_POSSIBLE_IO_ERROR(val, u16))
 		return eeh_check_failure((void*)(port+pci_io_base), val);
 	return val;
 }
@@ -189,7 +213,7 @@
 	if (_IO_IS_ISA(port) && !_IO_HAS_ISA_BUS)
 		return ~0;
 	val = in_le32((u32 *)(port+pci_io_base));
-	if (!_IO_IS_ISA(port) && EEH_POSSIBLE_IO_ERROR(val))
+	if (!_IO_IS_ISA(port) && EEH_POSSIBLE_IO_ERROR(val, u32))
 		return eeh_check_failure((void*)(port+pci_io_base), val);
 	return val;
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc64/elf.h linux-2.4.22-pre2/include/asm-ppc64/elf.h
--- linux-2.4.21/include/asm-ppc64/elf.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc64/elf.h	2003-06-26 21:43:34.000000000 +0000
@@ -88,14 +88,22 @@
 
 #define ELF_PLATFORM	(NULL)
 
-
-#define ELF_PLAT_INIT(_r)	do { \
+#if 0
+#define ELF_PLAT_INIT(_r, interp_load_addr)	do { \
 	memset(_r->gpr, 0, sizeof(_r->gpr)); \
 	_r->ctr = _r->link = _r->xer = _r->ccr = 0; \
+	_r->gpr[2] = interp_load_addr; \
+} while (0)
+#endif
+
+#define ELF_PLAT_INIT(_r)       do { \
+        memset(_r->gpr, 0, sizeof(_r->gpr)); \
+        _r->ctr = _r->link = _r->xer = _r->ccr = 0; \
 } while (0)
 
 
 
+
 #define SET_PERSONALITY(ex, ibcs2)				\
 do {	if ((ex).e_ident[EI_CLASS] == ELFCLASS32)		\
 		current->thread.flags |= PPC_FLAG_32BIT;	\
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc64/iSeries/HvLpEvent.h linux-2.4.22-pre2/include/asm-ppc64/iSeries/HvLpEvent.h
--- linux-2.4.21/include/asm-ppc64/iSeries/HvLpEvent.h	2002-08-03 00:39:45.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc64/iSeries/HvLpEvent.h	2003-06-26 21:43:16.000000000 +0000
@@ -91,7 +91,7 @@
 
 
 // Close an Lp Event Path for a type and partition
-//  returns 0 on sucess
+//  returns 0 on success
 extern int HvLpEvent_closePath( HvLpEvent_Type eventType, HvLpIndex lpIndex );
 
 #define HvLpEvent_Type_Hypervisor 0
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc64/iSeries/iSeries_VpdInfo.h linux-2.4.22-pre2/include/asm-ppc64/iSeries/iSeries_VpdInfo.h
--- linux-2.4.21/include/asm-ppc64/iSeries/iSeries_VpdInfo.h	2002-08-03 00:39:45.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc64/iSeries/iSeries_VpdInfo.h	2003-06-26 21:43:19.000000000 +0000
@@ -24,7 +24,7 @@
 /************************************************************************/
 /* Change Activity:                                                     */
 /*   Created, Feg  8, 2001                                              */
-/*   Reformated for Card, March 8, 2001                                 */
+/*   Reformatted for Card, March 8, 2001                                 */
 /* End Change Activity                                                  */
 /************************************************************************/
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc64/ide.h linux-2.4.22-pre2/include/asm-ppc64/ide.h
--- linux-2.4.21/include/asm-ppc64/ide.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc64/ide.h	2003-06-26 21:43:18.000000000 +0000
@@ -48,7 +48,10 @@
 {
 }
 
-#include <asm-generic/ide_iops.h>
+#define __ide_mm_insw(p, a, c)  _insw_ns((volatile u16 *)(p), (a), (c))
+#define __ide_mm_insl(p, a, c)  _insl_ns((volatile u32 *)(p), (a), (c))
+#define __ide_mm_outsw(p, a, c) _outsw_ns((volatile u16 *)(p), (a), (c))
+#define __ide_mm_outsl(p, a, c) _outsl_ns((volatile u32 *)(p), (a), (c))
 
 #endif /* __KERNEL__ */
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc64/io.h linux-2.4.22-pre2/include/asm-ppc64/io.h
--- linux-2.4.21/include/asm-ppc64/io.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc64/io.h	2003-06-26 21:43:28.000000000 +0000
@@ -67,6 +67,18 @@
 #define outl(val, port)		eeh_outl(val, (unsigned long)port)
 
 /*
+ * The __raw_read/write macros don't do byte-swapping. 
+ * They are needed for some PCI devices such as the Matrox graphics 
+ * adapter which is programmed to operate in big endian mode.
+ */
+#define __raw_readb(addr)              eeh_readb((void*)(addr))
+#define __raw_readw(addr)              eeh_raw_readw((void*)(addr))
+#define __raw_readl(addr)              eeh_raw_readl((void*)(addr))
+#define __raw_writeb(data, addr)       eeh_writeb((data), ((void*)(addr)))
+#define __raw_writew(data, addr)       eeh_raw_writew((data), ((void*)(addr)))
+#define __raw_writel(data, addr)       eeh_raw_writel((data), ((void*)(addr)))
+
+/*
  * The insw/outsw/insl/outsl macros don't do byte-swapping.
  * They are only used in practice for transferring buffers which
  * are arrays of bytes, and byte-swapping is not appropriate in
@@ -99,7 +111,7 @@
 #define inw_p(port)             inw(port)
 #define outw_p(val, port)       (udelay(1), outw((val), (port)))
 #define inl_p(port)             inl(port)
-#define outl_p(val, port)       (udelay(1), outl((val, (port)))
+#define outl_p(val, port)       (udelay(1), outl((val), (port)))
 
 /*
  * The *_ns versions below don't do byte-swapping.
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc64/ioctls.h linux-2.4.22-pre2/include/asm-ppc64/ioctls.h
--- linux-2.4.21/include/asm-ppc64/ioctls.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc64/ioctls.h	2003-06-26 21:43:14.000000000 +0000
@@ -96,7 +96,6 @@
 #define TIOCGSID	0x5429  /* Return the session ID of FD */
 #define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
 #define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
-#define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
 
 #define TIOCSERCONFIG	0x5453
 #define TIOCSERGWILD	0x5454
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc64/memory.h linux-2.4.22-pre2/include/asm-ppc64/memory.h
--- linux-2.4.21/include/asm-ppc64/memory.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc64/memory.h	2003-06-26 21:43:19.000000000 +0000
@@ -58,7 +58,7 @@
 
 #define HMT_LOW
 #define HMT_MEDIUM
-#define HMT_LOW
+#define HMT_HIGH
 #endif
 
 #endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc64/pgtable.h linux-2.4.22-pre2/include/asm-ppc64/pgtable.h
--- linux-2.4.21/include/asm-ppc64/pgtable.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc64/pgtable.h	2003-06-26 21:43:10.000000000 +0000
@@ -51,7 +51,16 @@
  */
 #define VMALLOC_START (0xD000000000000000)
 #define VMALLOC_VMADDR(x) ((unsigned long)(x))
+
+#ifndef CONFIG_SHARED_MEMORY_ADDRESSING
 #define VMALLOC_END   (VMALLOC_START + VALID_EA_BITS)
+#else
+#define VMALLOC_END   (VMALLOC_START + (VALID_EA_BITS >> 1))
+#define SMALLOC_START (VMALLOC_START + (VALID_EA_BITS >> 1) + 1)
+#define SMALLOC_END   (VMALLOC_START + VALID_EA_BITS)
+#define SMALLOC_EA_SHIFT 40
+#define SMALLOC_ESID_SHIFT 12
+#endif
 
 /*
  * Define the address range of the imalloc VM area.
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc64/processor.h linux-2.4.22-pre2/include/asm-ppc64/processor.h
--- linux-2.4.21/include/asm-ppc64/processor.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc64/processor.h	2003-06-26 21:43:30.000000000 +0000
@@ -137,7 +137,7 @@
 #define	SPRN_DBAT2U	0x21C	/* Data BAT 2 Upper Register */
 #define	SPRN_DBAT3L	0x21F	/* Data BAT 3 Lower Register */
 #define	SPRN_DBAT3U	0x21E	/* Data BAT 3 Upper Register */
-#define	SPRN_DBCR	0x3F2	/* Debug Control Regsiter */
+#define	SPRN_DBCR	0x3F2	/* Debug Control Register */
 #define	  DBCR_EDM	0x80000000
 #define	  DBCR_IDM	0x40000000
 #define	  DBCR_RST(x)	(((x) & 0x3) << 28)
@@ -191,13 +191,13 @@
 #define	  ESR_IMCB	0x20000000	/* Instr. Machine Check - Bus error */
 #define	  ESR_IMCT	0x10000000	/* Instr. Machine Check - Timeout */
 #define	  ESR_PIL	0x08000000	/* Program Exception - Illegal */
-#define	  ESR_PPR	0x04000000	/* Program Exception - Priveleged */
+#define	  ESR_PPR	0x04000000	/* Program Exception - Privileged */
 #define	  ESR_PTR	0x02000000	/* Program Exception - Trap */
 #define	  ESR_DST	0x00800000	/* Storage Exception - Data miss */
 #define	  ESR_DIZ	0x00400000	/* Storage Exception - Zone fault */
 #define	SPRN_EVPR	0x3D6	/* Exception Vector Prefix Register */
 #define	SPRN_HASH1	0x3D2	/* Primary Hash Address Register */
-#define	SPRN_HASH2	0x3D3	/* Secondary Hash Address Resgister */
+#define	SPRN_HASH2	0x3D3	/* Secondary Hash Address Register */
 #define	SPRN_HID0	0x3F0	/* Hardware Implementation Register 0 */
 #define	  HID0_EMCP	(1<<31)		/* Enable Machine Check pin */
 #define	  HID0_EBA	(1<<29)		/* Enable Bus Address Parity */
@@ -246,7 +246,7 @@
 #define	SPRN_ICTC	0x3FB	/* Instruction Cache Throttling Control Reg */
 #define	SPRN_IMISS	0x3D4	/* Instruction TLB Miss Register */
 #define	SPRN_IMMR	0x27E  	/* Internal Memory Map Register */
-#define	SPRN_L2CR	0x3F9	/* Level 2 Cache Control Regsiter */
+#define	SPRN_L2CR	0x3F9	/* Level 2 Cache Control Register */
 #define	SPRN_LR		0x008	/* Link Register */
 #define	SPRN_PBL1	0x3FC	/* Protection Bound Lower 1 */
 #define	SPRN_PBL2	0x3FE	/* Protection Bound Lower 2 */
@@ -504,7 +504,7 @@
 #define GLUE(a,b) XGLUE(a,b)
 
 /*
- * Begining of traceback info work for asm functions.
+ * Beginning of traceback info work for asm functions.
  */
 #define TB_ASM		0x000C000000000000
 #define TB_GLOBALLINK	0x0000800000000000
@@ -635,8 +635,8 @@
 /* This decides where the kernel will search for a free chunk of vm
  * space during mmap's.
  */
-#define TASK_UNMAPPED_BASE_USER32 (STACK_TOP_USER32 / 4)
-#define TASK_UNMAPPED_BASE_USER64 (STACK_TOP_USER64 / 4)
+#define TASK_UNMAPPED_BASE_USER32 PAGE_ALIGN(STACK_TOP_USER32 / 4)
+#define TASK_UNMAPPED_BASE_USER64 PAGE_ALIGN(STACK_TOP_USER64 / 4)
 
 #define TASK_UNMAPPED_BASE (((current->thread.flags & PPC_FLAG_32BIT)||(ppcdebugset(PPCDBG_BINFMT_32ADDR))) ? \
 		TASK_UNMAPPED_BASE_USER32 : TASK_UNMAPPED_BASE_USER64 )
@@ -662,6 +662,10 @@
 #define PPC_FLAG_32BIT		0x01
 #define PPC_FLAG_RUN_LIGHT	RUN_FLAG
 
+#ifdef CONFIG_SHARED_MEMORY_ADDRESSING
+#define PPC_FLAG_SHARED   	0x4UL
+#endif
+
 #define INIT_SP		(sizeof(init_stack) + (unsigned long) &init_stack)
 
 #define INIT_THREAD  { \
@@ -754,18 +758,6 @@
 
 #define spin_lock_prefetch(x)	prefetchw(x)
 
-#define cpu_has_largepage()	(__is_processor(PV_POWER4) || \
-				 __is_processor(PV_POWER4p))
-
-#define cpu_has_slb()		(__is_processor(PV_POWER4) || \
-				 __is_processor(PV_POWER4p))
-
-#define cpu_has_tlbiel()	(__is_processor(PV_POWER4) || \
-				 __is_processor(PV_POWER4p))
-
-#define cpu_has_noexecute()	(__is_processor(PV_POWER4) || \
-				 __is_processor(PV_POWER4p))
-
 #endif /* ASSEMBLY */
 
 #endif /* __ASM_PPC64_PROCESSOR_H */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc64/prom.h linux-2.4.22-pre2/include/asm-ppc64/prom.h
--- linux-2.4.21/include/asm-ppc64/prom.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc64/prom.h	2003-06-26 21:43:13.000000000 +0000
@@ -179,7 +179,6 @@
 extern char *of_stdout_device;
 
 /* Prototypes */
-extern void abort(void);
 extern unsigned long prom_init(unsigned long, unsigned long, unsigned long,
     unsigned long, unsigned long, yaboot_debug_t *);
 extern void prom_print(const char *msg);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/asm-ppc64/rtas.h linux-2.4.22-pre2/include/asm-ppc64/rtas.h
--- linux-2.4.21/include/asm-ppc64/rtas.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/asm-ppc64/rtas.h	2003-06-26 21:43:16.000000000 +0000
@@ -19,6 +19,11 @@
 #define RTAS_UNKNOWN_SERVICE (-1)
 #define RTAS_INSTANTIATE_MAX (1UL<<30) /* Don't instantiate rtas at/above this value */
 
+/* Error inject defines */
+#define ERRINJCT_TOKEN_LEN 24 /* Max length of an error inject token */
+#define MAX_ERRINJCT_TOKENS 8 /* Max # tokens. */
+#define WORKSPACE_SIZE 1024 
+
 /*
  * In general to call RTAS use rtas_token("string") to lookup
  * an RTAS token for the given string (e.g. "event-scan").
@@ -131,6 +136,11 @@
 	unsigned char buffer[1];		/* allocated by klimit bump */
 };
 
+struct errinjct_token {
+    	char * name;
+	int value;
+};
+
 struct flash_block {
 	char *data;
 	unsigned long length;
@@ -165,15 +175,19 @@
 extern void rtas_restart(char *cmd);
 extern void rtas_power_off(void);
 extern void rtas_halt(void);
+extern int rtas_errinjct_open(void);
+extern int rtas_errinjct(unsigned int, char *, char *);
+extern int rtas_errinjct_close(unsigned int);
 
 extern struct proc_dir_entry *rtas_proc_dir;
+extern struct errinjct_token ei_token_list[MAX_ERRINJCT_TOKENS];
 
 /* Some RTAS ops require a data buffer and that buffer must be < 4G.
  * Rather than having a memory allocator, just use this buffer
  * (get the lock first), make the RTAS call.  Copy the data instead
  * of holding the buffer for long.
  */
-#define RTAS_DATA_BUF_SIZE 1024
+#define RTAS_DATA_BUF_SIZE 4096
 extern spinlock_t rtas_data_buf_lock;
 extern char rtas_data_buf[RTAS_DATA_BUF_SIZE];
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/acpi.h linux-2.4.22-pre2/include/linux/acpi.h
--- linux-2.4.21/include/linux/acpi.h	2001-10-11 20:53:22.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/acpi.h	2003-06-26 21:43:10.000000000 +0000
@@ -1,180 +1,423 @@
 /*
- *  acpi.h - ACPI driver interface
+ * acpi.h - ACPI Interface
  *
- *  Copyright (C) 1999 Andrew Henroid
+ * Copyright (C) 2001 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
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the 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 _LINUX_ACPI_H
 #define _LINUX_ACPI_H
 
-#include <linux/types.h>
-#include <linux/ioctl.h>
-#ifdef __KERNEL__
-#include <linux/sched.h>
-#include <linux/wait.h>
-#endif /* __KERNEL__ */
+#ifndef _LINUX
+#define _LINUX
+#endif
 
-/*
- * Device states
- */
-typedef enum {
-	ACPI_D0, /* fully-on */
-	ACPI_D1, /* partial-on */
-	ACPI_D2, /* partial-on */
-	ACPI_D3, /* fully-off */
-} acpi_dstate_t;
-
-typedef enum {
-	ACPI_S0, /* working state */
-	ACPI_S1, /* power-on suspend */
-	ACPI_S2, /* suspend to ram, with devices */
-	ACPI_S3, /* suspend to ram */
-	ACPI_S4, /* suspend to disk */
-	ACPI_S5, /* soft-off */
-} acpi_sstate_t;
-
-/* RSDP location */
-#define ACPI_BIOS_ROM_BASE (0x0e0000)
-#define ACPI_BIOS_ROM_END  (0x100000)
-
-/* Table signatures */
-#define ACPI_RSDP1_SIG 0x20445352 /* 'RSD ' */
-#define ACPI_RSDP2_SIG 0x20525450 /* 'PTR ' */
-#define ACPI_RSDT_SIG  0x54445352 /* 'RSDT' */
-#define ACPI_FADT_SIG  0x50434146 /* 'FACP' */
-#define ACPI_DSDT_SIG  0x54445344 /* 'DSDT' */
-#define ACPI_FACS_SIG  0x53434146 /* 'FACS' */
-
-#define ACPI_SIG_LEN		4
-#define ACPI_FADT_SIGNATURE	"FACP"
-
-/* PM1_STS/EN flags */
-#define ACPI_TMR    0x0001
-#define ACPI_BM	    0x0010
-#define ACPI_GBL    0x0020
-#define ACPI_PWRBTN 0x0100
-#define ACPI_SLPBTN 0x0200
-#define ACPI_RTC    0x0400
-#define ACPI_WAK    0x8000
-
-/* PM1_CNT flags */
-#define ACPI_SCI_EN   0x0001
-#define ACPI_BM_RLD   0x0002
-#define ACPI_GBL_RLS  0x0004
-#define ACPI_SLP_TYP0 0x0400
-#define ACPI_SLP_TYP1 0x0800
-#define ACPI_SLP_TYP2 0x1000
-#define ACPI_SLP_EN   0x2000
-
-#define ACPI_SLP_TYP_MASK  0x1c00
-#define ACPI_SLP_TYP_SHIFT 10
-
-/* PM_TMR masks */
-#define ACPI_TMR_VAL_EXT 0x00000100
-#define ACPI_TMR_MASK	 0x00ffffff
-#define ACPI_TMR_HZ	 3579545 /* 3.58 MHz */
-#define ACPI_TMR_KHZ	 (ACPI_TMR_HZ / 1000)
-
-#define ACPI_MICROSEC_TO_TMR_TICKS(val) \
-  (((val) * (ACPI_TMR_KHZ)) / 1000)
-
-/* PM2_CNT flags */
-#define ACPI_ARB_DIS 0x01
-
-/* FADT flags */
-#define ACPI_WBINVD	  0x00000001
-#define ACPI_WBINVD_FLUSH 0x00000002
-#define ACPI_PROC_C1	  0x00000004
-#define ACPI_P_LVL2_UP	  0x00000008
-#define ACPI_PWR_BUTTON	  0x00000010
-#define ACPI_SLP_BUTTON	  0x00000020
-#define ACPI_FIX_RTC	  0x00000040
-#define ACPI_RTC_64	  0x00000080
-#define ACPI_TMR_VAL_EXT  0x00000100
-#define ACPI_DCK_CAP	  0x00000200
-
-/* FADT BOOT_ARCH flags */
-#define FADT_BOOT_ARCH_LEGACY_DEVICES	0x0001
-#define FADT_BOOT_ARCH_KBD_CONTROLLER	0x0002
-
-/* FACS flags */
-#define ACPI_S4BIOS	  0x00000001
-
-/* processor block offsets */
-#define ACPI_P_CNT	  0x00000000
-#define ACPI_P_LVL2	  0x00000004
-#define ACPI_P_LVL3	  0x00000005
-
-/* C-state latencies (microseconds) */
-#define ACPI_MAX_P_LVL2_LAT 100
-#define ACPI_MAX_P_LVL3_LAT 1000
-#define ACPI_INFINITE_LAT   (~0UL)
+#include <linux/list.h>
+
+#include <acpi/acpi.h>
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+#include <asm/acpi.h>
+
+
+#ifdef CONFIG_ACPI_BOOT
+
+enum acpi_irq_model_id {
+	ACPI_IRQ_MODEL_PIC = 0,
+	ACPI_IRQ_MODEL_IOAPIC,
+	ACPI_IRQ_MODEL_IOSAPIC,
+	ACPI_IRQ_MODEL_COUNT
+};
+
+extern enum acpi_irq_model_id	acpi_irq_model;
+
+
+/* Root System Description Pointer (RSDP) */
+
+struct acpi_table_rsdp {
+	char			signature[8];
+	u8			checksum;
+	char			oem_id[6];
+	u8			revision;
+	u32			rsdt_address;
+} __attribute__ ((packed));
+
+struct acpi20_table_rsdp {
+	char			signature[8];
+	u8			checksum;
+	char			oem_id[6];
+	u8			revision;
+	u32			rsdt_address;
+	u32			length;
+	u64			xsdt_address;
+	u8			ext_checksum;
+	u8			reserved[3];
+} __attribute__ ((packed));
+
+typedef struct {
+	u8			type;
+	u8			length;
+} __attribute__ ((packed)) acpi_table_entry_header;
+
+/* Root System Description Table (RSDT) */
+
+struct acpi_table_rsdt {
+	struct acpi_table_header header;
+	u32			entry[1];
+} __attribute__ ((packed));
+
+/* Extended System Description Table (XSDT) */
+
+struct acpi_table_xsdt {
+	struct acpi_table_header header;
+	u64			entry[1];
+} __attribute__ ((packed));
+
+/* Fixed ACPI Description Table (FADT) */
+
+struct acpi_table_fadt {
+	struct acpi_table_header header;
+	u32 facs_addr;
+	u32 dsdt_addr;
+	/* ... */
+} __attribute__ ((packed));
+
+/* Multiple APIC Description Table (MADT) */
+
+struct acpi_table_madt {
+	struct acpi_table_header header;
+	u32			lapic_address;
+	struct {
+		u32			pcat_compat:1;
+		u32			reserved:31;
+	}			flags;
+} __attribute__ ((packed));
+
+enum acpi_madt_entry_id {
+	ACPI_MADT_LAPIC = 0,
+	ACPI_MADT_IOAPIC,
+	ACPI_MADT_INT_SRC_OVR,
+	ACPI_MADT_NMI_SRC,
+	ACPI_MADT_LAPIC_NMI,
+	ACPI_MADT_LAPIC_ADDR_OVR,
+	ACPI_MADT_IOSAPIC,
+	ACPI_MADT_LSAPIC,
+	ACPI_MADT_PLAT_INT_SRC,
+	ACPI_MADT_ENTRY_COUNT
+};
+
+typedef struct {
+	u16			polarity:2;
+	u16			trigger:2;
+	u16			reserved:12;
+} __attribute__ ((packed)) acpi_interrupt_flags;
+
+struct acpi_table_lapic {
+	acpi_table_entry_header	header;
+	u8			acpi_id;
+	u8			id;
+	struct {
+		u32			enabled:1;
+		u32			reserved:31;
+	}			flags;
+} __attribute__ ((packed));
+
+struct acpi_table_ioapic {
+	acpi_table_entry_header	header;
+	u8			id;
+	u8			reserved;
+	u32			address;
+	u32			global_irq_base;
+} __attribute__ ((packed));
+
+struct acpi_table_int_src_ovr {
+	acpi_table_entry_header	header;
+	u8			bus;
+	u8			bus_irq;
+	u32			global_irq;
+	acpi_interrupt_flags	flags;
+} __attribute__ ((packed));
+
+struct acpi_table_nmi_src {
+	acpi_table_entry_header	header;
+	acpi_interrupt_flags	flags;
+	u32			global_irq;
+} __attribute__ ((packed));
+
+struct acpi_table_lapic_nmi {
+	acpi_table_entry_header	header;
+	u8			acpi_id;
+	acpi_interrupt_flags	flags;
+	u8			lint;
+} __attribute__ ((packed));
+
+struct acpi_table_lapic_addr_ovr {
+	acpi_table_entry_header	header;
+	u8			reserved[2];
+	u64			address;
+} __attribute__ ((packed));
+
+struct acpi_table_iosapic {
+	acpi_table_entry_header	header;
+	u8			id;
+	u8			reserved;
+	u32			global_irq_base;
+	u64			address;
+} __attribute__ ((packed));
+
+struct acpi_table_lsapic {
+	acpi_table_entry_header	header;
+	u8			acpi_id;
+	u8			id;
+	u8			eid;
+	u8			reserved[3];
+	struct {
+		u32			enabled:1;
+		u32			reserved:31;
+	}			flags;
+} __attribute__ ((packed));
+
+struct acpi_table_plat_int_src {
+	acpi_table_entry_header	header;
+	acpi_interrupt_flags	flags;
+	u8			type;	/* See acpi_interrupt_type */
+	u8			id;
+	u8			eid;
+	u8			iosapic_vector;
+	u32			global_irq;
+	u32			reserved;
+} __attribute__ ((packed));
+
+enum acpi_interrupt_id {
+	ACPI_INTERRUPT_PMI	= 1,
+	ACPI_INTERRUPT_INIT,
+	ACPI_INTERRUPT_CPEI,
+	ACPI_INTERRUPT_COUNT
+};
+
+#define	ACPI_SPACE_MEM		0
+
+struct acpi_gen_regaddr {
+	u8  space_id;
+	u8  bit_width;
+	u8  bit_offset;
+	u8  resv;
+	u32 addrl;
+	u32 addrh;
+} __attribute__ ((packed));
+
+struct acpi_table_hpet {
+	struct acpi_table_header header;
+	u32 id;
+	struct acpi_gen_regaddr addr;
+	u8 number;
+	u16 min_tick;
+	u8 page_protect;
+} __attribute__ ((packed));
 
 /*
- * Sysctl declarations
+ * System Resource Affinity Table (SRAT)
+ *   see http://www.microsoft.com/hwdev/design/srat.htm
  */
 
-enum
-{
-	CTL_ACPI = 10
+struct acpi_table_srat {
+	struct acpi_table_header header;
+	u32			table_revision;
+	u64			reserved;
+} __attribute__ ((packed));
+
+enum acpi_srat_entry_id {
+	ACPI_SRAT_PROCESSOR_AFFINITY = 0,
+	ACPI_SRAT_MEMORY_AFFINITY,
+	ACPI_SRAT_ENTRY_COUNT
 };
 
-enum
-{
-	ACPI_FADT = 1,
+struct acpi_table_processor_affinity {
+	acpi_table_entry_header	header;
+	u8			proximity_domain;
+	u8			apic_id;
+	struct {
+		u32			enabled:1;
+		u32			reserved:31;
+	}			flags;
+	u8			lsapic_eid;
+	u8			reserved[7];
+} __attribute__ ((packed));
+
+struct acpi_table_memory_affinity {
+	acpi_table_entry_header	header;
+	u8			proximity_domain;
+	u8			reserved1[5];
+	u32			base_addr_lo;
+	u32			base_addr_hi;
+	u32			length_lo;
+	u32			length_hi;
+	u32			memory_type;	/* See acpi_address_range_id */
+	struct {
+		u32			enabled:1;
+		u32			hot_pluggable:1;
+		u32			reserved:30;
+	}			flags;
+	u64			reserved2;
+} __attribute__ ((packed));
+
+enum acpi_address_range_id {
+	ACPI_ADDRESS_RANGE_MEMORY = 1,
+	ACPI_ADDRESS_RANGE_RESERVED = 2,
+	ACPI_ADDRESS_RANGE_ACPI = 3,
+	ACPI_ADDRESS_RANGE_NVS	= 4,
+	ACPI_ADDRESS_RANGE_COUNT
+};
+
+/*
+ * System Locality Information Table (SLIT)
+ *   see http://devresource.hp.com/devresource/docs/techpapers/ia64/slit.pdf
+ */
+
+struct acpi_table_slit {
+	struct acpi_table_header header;
+	u64			localities;
+	u8			entry[1];	/* real size = localities^2 */
+} __attribute__ ((packed));
+
+/* Smart Battery Description Table (SBST) */
+
+struct acpi_table_sbst {
+	struct acpi_table_header header;
+	u32			warning;	/* Warn user */
+	u32			low;		/* Critical sleep */
+	u32			critical;	/* Critical shutdown */
+} __attribute__ ((packed));
+
+/* Embedded Controller Boot Resources Table (ECDT) */
+
+struct acpi_table_ecdt {
+	struct acpi_table_header	header;
+	struct acpi_generic_address	ec_control;
+	struct acpi_generic_address	ec_data;
+	u32				uid;
+	u8				gpe_bit;
+	char				ec_id[0];
+} __attribute__ ((packed));
+
+/* Table Handlers */
+
+enum acpi_table_id {
+	ACPI_TABLE_UNKNOWN = 0,
+	ACPI_APIC,
+	ACPI_BOOT,
+	ACPI_DBGP,
 	ACPI_DSDT,
-	ACPI_PM1_ENABLE,
-	ACPI_GPE_ENABLE,
-	ACPI_GPE_LEVEL,
-	ACPI_EVENT,
-	ACPI_P_BLK,
-	ACPI_ENTER_LVL2_LAT,
-	ACPI_ENTER_LVL3_LAT,
-	ACPI_P_LVL2_LAT,
-	ACPI_P_LVL3_LAT,
-	ACPI_C1_TIME,
-	ACPI_C2_TIME,
-	ACPI_C3_TIME,
-	ACPI_C1_COUNT,
-	ACPI_C2_COUNT,
-	ACPI_C3_COUNT,
-	ACPI_S0_SLP_TYP,
-	ACPI_S1_SLP_TYP,
-	ACPI_S5_SLP_TYP,
-	ACPI_SLEEP,
+	ACPI_ECDT,
+	ACPI_ETDT,
+	ACPI_FADT,
 	ACPI_FACS,
-	ACPI_XSDT,
-	ACPI_PMTIMER,
-	ACPI_BATT,
+	ACPI_OEMX,
+	ACPI_PSDT,
+	ACPI_SBST,
+	ACPI_SLIT,
+	ACPI_SPCR,
+	ACPI_SRAT,
+	ACPI_SSDT,
+	ACPI_SPMI,
+	ACPI_HPET,
+	ACPI_TABLE_COUNT
 };
 
-#define ACPI_SLP_TYP_DISABLED	(~0UL)
+typedef int (*acpi_table_handler) (unsigned long phys_addr, unsigned long size);
 
-#ifdef __KERNEL__
+extern acpi_table_handler acpi_table_ops[ACPI_TABLE_COUNT];
+
+typedef int (*acpi_madt_entry_handler) (acpi_table_entry_header *header);
+
+char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
+unsigned long acpi_find_rsdp (void);
+int acpi_boot_init (void);
+int acpi_numa_init (void);
+
+int acpi_table_init (void);
+int acpi_table_parse (enum acpi_table_id id, acpi_table_handler handler);
+int acpi_get_table_header_early (enum acpi_table_id id, struct acpi_table_header **header);
+int acpi_table_parse_madt (enum acpi_madt_entry_id id, acpi_madt_entry_handler handler);
+int acpi_table_parse_srat (enum acpi_srat_entry_id id, acpi_madt_entry_handler handler);
+void acpi_table_print (struct acpi_table_header *header, unsigned long phys_addr);
+void acpi_table_print_madt_entry (acpi_table_entry_header *madt);
+void acpi_table_print_srat_entry (acpi_table_entry_header *srat);
+
+/* the following four functions are architecture-dependent */
+void acpi_numa_slit_init (struct acpi_table_slit *slit);
+void acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *pa);
+void acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma);
+void acpi_numa_arch_fixup(void);
+
+#endif /*CONFIG_ACPI_BOOT*/
+
+
+#ifdef CONFIG_ACPI_PCI
+
+struct acpi_prt_entry {
+	struct list_head	node;
+	struct acpi_pci_id	id;
+	u8			pin;
+	struct {
+		acpi_handle		handle;
+		u32			index;
+	}			link;
+	u32			irq;
+};
+
+struct acpi_prt_list {
+	int			count;
+	struct list_head	entries;
+};
 
-/* routines for saving/restoring kernel state */
-FASTCALL(extern unsigned long acpi_save_state_mem(unsigned long return_point));
-FASTCALL(extern int acpi_save_state_disk(unsigned long return_point));
-extern void acpi_restore_state(void);
+extern struct acpi_prt_list	acpi_prt;
 
-extern unsigned long acpi_wakeup_address;
+struct pci_dev;
 
-#endif /* __KERNEL__ */
+int acpi_pci_irq_enable (struct pci_dev *dev);
+int acpi_pci_irq_init (void);
+
+struct acpi_pci_driver {
+	struct acpi_pci_driver *next;
+	int (*add)(acpi_handle handle);
+	void (*remove)(acpi_handle handle);
+};
+
+int acpi_pci_register_driver(struct acpi_pci_driver *driver);
+void acpi_pci_unregister_driver(struct acpi_pci_driver *driver);
+
+#endif /*CONFIG_ACPI_PCI*/
+
+#ifdef CONFIG_ACPI_EC
+
+int ec_read(u8 addr, u8 *val);
+int ec_write(u8 addr, u8 val);
+
+#endif /*CONFIG_ACPI_EC*/
+
+#ifdef CONFIG_ACPI
 
 int acpi_init(void);
+int acpi_blacklisted(void);
+
+#endif /*CONFIG_ACPI*/
 
-#endif /* _LINUX_ACPI_H */
+#endif /*_LINUX_ACPI_H*/
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/atm_he.h linux-2.4.22-pre2/include/linux/atm_he.h
--- linux-2.4.21/include/linux/atm_he.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/atm_he.h	2003-06-26 21:43:12.000000000 +0000
@@ -0,0 +1,20 @@
+/* atm_he.h */
+
+#ifndef LINUX_ATM_HE_H
+#define LINUX_ATM_HE_H
+
+#include <linux/atmioc.h>
+
+#define HE_GET_REG	_IOW('a', ATMIOC_SARPRV, struct atmif_sioc)
+
+#define HE_REGTYPE_PCI	1
+#define HE_REGTYPE_RCM	2
+#define HE_REGTYPE_TCM	3
+#define HE_REGTYPE_MBOX	4
+
+struct he_ioctl_reg {
+	unsigned addr, val;
+	char type;
+};
+
+#endif /* LINUX_ATM_HE_H */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/crc32.h linux-2.4.22-pre2/include/linux/crc32.h
--- linux-2.4.21/include/linux/crc32.h	2002-08-03 00:39:45.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/crc32.h	2003-06-26 21:43:17.000000000 +0000
@@ -1,49 +1,27 @@
 /*
- * crc32.h for early Linux 2.4.19pre kernel inclusion
- * This defines ether_crc_le() and ether_crc() as inline functions
- * This is slated to change to using the library crc32 functions
- * as kernel 2.5.2 included at some future date.
+ * crc32.h
+ * See linux/lib/crc32.c for license and changes
  */
 #ifndef _LINUX_CRC32_H
 #define _LINUX_CRC32_H
 
 #include <linux/types.h>
 
-/* The little-endian AUTODIN II ethernet CRC calculation.
-   N.B. Do not use for bulk data, use a table-based routine instead.
-   This is common code and should be moved to net/core/crc.c */
-static unsigned const ethernet_polynomial_le = 0xedb88320U;
-static inline unsigned ether_crc_le(int length, unsigned char *data)
-{
-	unsigned int crc = 0xffffffff;	/* Initial value. */
-	while(--length >= 0) {
-		unsigned char current_octet = *data++;
-		int bit;
-		for (bit = 8; --bit >= 0; current_octet >>= 1) {
-			if ((crc ^ current_octet) & 1) {
-				crc >>= 1;
-				crc ^= ethernet_polynomial_le;
-			} else
-				crc >>= 1;
-		}
-	}
-	return crc;
-}
+extern u32  crc32_le(u32 crc, unsigned char const *p, size_t len);
+extern u32  crc32_be(u32 crc, unsigned char const *p, size_t len);
+extern u32  bitreverse(u32 in);
 
-static unsigned const ethernet_polynomial = 0x04c11db7U;
-static inline u32 ether_crc(int length, unsigned char *data)
-{
-	int crc = -1;
-	while (--length >= 0) {
-		unsigned char current_octet = *data++;
-		int bit;
-		for (bit = 0; bit < 8; bit++, current_octet >>= 1) {
-			crc = (crc << 1) ^
-				((crc < 0) ^ (current_octet & 1) ?
-				 ethernet_polynomial : 0);
-		}
-	}
-	return crc;
-}
+#define crc32(seed, data, length)  crc32_le(seed, (unsigned char const *)data, length)
+
+/*
+ * Helpers for hash table generation of ethernet nics:
+ *
+ * Ethernet sends the least significant bit of a byte first, thus crc32_le
+ * is used. The output of crc32_le is bit reversed [most significant bit
+ * is in bit nr 0], thus it must be reversed before use. Except for
+ * nics that bit swap the result internally...
+ */
+#define ether_crc(length, data)    bitreverse(crc32_le(~0, data, length))
+#define ether_crc_le(length, data) crc32_le(~0, data, length)
 
 #endif /* _LINUX_CRC32_H */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/ethtool.h linux-2.4.22-pre2/include/linux/ethtool.h
--- linux-2.4.21/include/linux/ethtool.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/ethtool.h	2003-06-26 21:43:14.000000000 +0000
@@ -252,23 +252,23 @@
 
 /* CMDs currently supported */
 #define ETHTOOL_GSET		0x00000001 /* Get settings. */
-#define ETHTOOL_SSET		0x00000002 /* Set settings, privileged. */
+#define ETHTOOL_SSET		0x00000002 /* Set settings. */
 #define ETHTOOL_GDRVINFO	0x00000003 /* Get driver info. */
-#define ETHTOOL_GREGS		0x00000004 /* Get NIC registers, privileged. */
+#define ETHTOOL_GREGS		0x00000004 /* Get NIC registers. */
 #define ETHTOOL_GWOL		0x00000005 /* Get wake-on-lan options. */
-#define ETHTOOL_SWOL		0x00000006 /* Set wake-on-lan options, priv. */
+#define ETHTOOL_SWOL		0x00000006 /* Set wake-on-lan options. */
 #define ETHTOOL_GMSGLVL		0x00000007 /* Get driver message level */
-#define ETHTOOL_SMSGLVL		0x00000008 /* Set driver msg level, priv. */
-#define ETHTOOL_NWAY_RST	0x00000009 /* Restart autonegotiation, priv. */
+#define ETHTOOL_SMSGLVL		0x00000008 /* Set driver msg level. */
+#define ETHTOOL_NWAY_RST	0x00000009 /* Restart autonegotiation. */
 #define ETHTOOL_GLINK		0x0000000a /* Get link status (ethtool_value) */
 #define ETHTOOL_GEEPROM		0x0000000b /* Get EEPROM data */
-#define ETHTOOL_SEEPROM		0x0000000c /* Set EEPROM data, priv. */
+#define ETHTOOL_SEEPROM		0x0000000c /* Set EEPROM data. */
 #define ETHTOOL_GCOALESCE	0x0000000e /* Get coalesce config */
-#define ETHTOOL_SCOALESCE	0x0000000f /* Set coalesce config, priv. */
+#define ETHTOOL_SCOALESCE	0x0000000f /* Set coalesce config. */
 #define ETHTOOL_GRINGPARAM	0x00000010 /* Get ring parameters */
-#define ETHTOOL_SRINGPARAM	0x00000011 /* Set ring parameters, priv. */
+#define ETHTOOL_SRINGPARAM	0x00000011 /* Set ring parameters. */
 #define ETHTOOL_GPAUSEPARAM	0x00000012 /* Get pause parameters */
-#define ETHTOOL_SPAUSEPARAM	0x00000013 /* Set pause parameters, priv. */
+#define ETHTOOL_SPAUSEPARAM	0x00000013 /* Set pause parameters. */
 #define ETHTOOL_GRXCSUM		0x00000014 /* Get RX hw csum enable (ethtool_value) */
 #define ETHTOOL_SRXCSUM		0x00000015 /* Set RX hw csum enable (ethtool_value) */
 #define ETHTOOL_GTXCSUM		0x00000016 /* Get TX hw csum enable (ethtool_value) */
@@ -276,8 +276,8 @@
 #define ETHTOOL_GSG		0x00000018 /* Get scatter-gather enable
 					    * (ethtool_value) */
 #define ETHTOOL_SSG		0x00000019 /* Set scatter-gather enable
-					    * (ethtool_value), priv. */
-#define ETHTOOL_TEST		0x0000001a /* execute NIC self-test, priv. */
+					    * (ethtool_value). */
+#define ETHTOOL_TEST		0x0000001a /* execute NIC self-test. */
 #define ETHTOOL_GSTRINGS	0x0000001b /* get specified string set */
 #define ETHTOOL_PHYS_ID		0x0000001c /* identify the NIC */
 #define ETHTOOL_GSTATS		0x0000001d /* get NIC-specific statistics */
@@ -299,6 +299,7 @@
 #define SUPPORTED_MII			(1 << 9)
 #define SUPPORTED_FIBRE			(1 << 10)
 #define SUPPORTED_BNC			(1 << 11)
+#define SUPPORTED_10000baseT_Full	(1 << 12)
 
 /* Indicates what features are advertised by the interface. */
 #define ADVERTISED_10baseT_Half		(1 << 0)
@@ -313,6 +314,7 @@
 #define ADVERTISED_MII			(1 << 9)
 #define ADVERTISED_FIBRE		(1 << 10)
 #define ADVERTISED_BNC			(1 << 11)
+#define ADVERTISED_10000baseT_Full	(1 << 12)
 
 /* The following are all involved in forcing a particular link
  * mode for the device for setting things.  When getting the
@@ -320,10 +322,11 @@
  * it was foced up into this mode or autonegotiated.
  */
 
-/* The forced speed, 10Mb, 100Mb, gigabit. */
+/* The forced speed, 10Mb, 100Mb, gigabit, 10GbE. */
 #define SPEED_10		10
 #define SPEED_100		100
 #define SPEED_1000		1000
+#define SPEED_10000		10000
 
 /* Duplex, half or full. */
 #define DUPLEX_HALF		0x00
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/fs.h linux-2.4.22-pre2/include/linux/fs.h
--- linux-2.4.21/include/linux/fs.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/fs.h	2003-06-26 21:43:14.000000000 +0000
@@ -456,6 +456,7 @@
 	unsigned long		i_blocks;
 	unsigned long		i_version;
 	struct semaphore	i_sem;
+	struct rw_semaphore	i_alloc_sem;
 	struct semaphore	i_zombie;
 	struct inode_operations	*i_op;
 	struct file_operations	*i_fop;	/* former ->i_op->default_file_ops */
@@ -1268,6 +1269,7 @@
 	return fsync_buffers_list(&inode->i_dirty_data_buffers);
 }
 extern int inode_has_buffers(struct inode *);
+extern int do_fdatasync(struct file *);
 extern int filemap_fdatasync(struct address_space *);
 extern int filemap_fdatawait(struct address_space *);
 extern void sync_supers(kdev_t dev, int wait);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/hfs_fs.h linux-2.4.22-pre2/include/linux/hfs_fs.h
--- linux-2.4.21/include/linux/hfs_fs.h	2001-02-13 22:13:44.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/hfs_fs.h	2003-06-26 21:43:30.000000000 +0000
@@ -302,6 +302,7 @@
 
 /* super.c */
 extern struct super_block *hfs_read_super(struct super_block *,void *,int);
+extern int hfs_remount(struct super_block *, int *, char *);
 
 /* trans.c */
 extern void hfs_colon2mac(struct hfs_name *, const char *, int);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/hiddev.h linux-2.4.22-pre2/include/linux/hiddev.h
--- linux-2.4.21/include/linux/hiddev.h	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/hiddev.h	2003-06-26 21:43:14.000000000 +0000
@@ -49,6 +49,13 @@
 	unsigned num_applications;
 };
 
+struct hiddev_collection_info {
+	unsigned index;
+	unsigned type;
+	unsigned usage;
+	unsigned level;
+};
+
 #define HID_STRING_SIZE 256
 struct hiddev_string_descriptor {
 	int index;
@@ -119,12 +126,17 @@
 	__s32 value;
 };
 
+/* FIELD_INDEX_NONE is returned in read() data from the kernel when flags
+ * is set to (HIDDEV_FLAG_UREF | HIDDEV_FLAG_REPORT) and a new report has
+ * been sent by the device 
+ */
+#define HID_FIELD_INDEX_NONE 0xffffffff
 
 /*
  * Protocol version.
  */
 
-#define HID_VERSION		0x010002
+#define HID_VERSION		0x010004
 
 /*
  * IOCTLs (0x00 - 0x7f)
@@ -138,11 +150,22 @@
 #define HIDIOCGNAME(len)	_IOC(_IOC_READ, 'H', 0x06, len)
 #define HIDIOCGREPORT		_IOW('H', 0x07, struct hiddev_report_info)
 #define HIDIOCSREPORT		_IOW('H', 0x08, struct hiddev_report_info)
-#define HIDIOCGREPORTINFO       _IOWR('H', 0x09, struct hiddev_report_info)
-#define HIDIOCGFIELDINFO        _IOWR('H', 0x0A, struct hiddev_field_info)
-#define HIDIOCGUSAGE            _IOWR('H', 0x0B, struct hiddev_usage_ref)
-#define HIDIOCSUSAGE            _IOW('H', 0x0C, struct hiddev_usage_ref)
-#define HIDIOCGUCODE            _IOWR('H', 0x0D, struct hiddev_usage_ref)
+#define HIDIOCGREPORTINFO	_IOWR('H', 0x09, struct hiddev_report_info)
+#define HIDIOCGFIELDINFO	_IOWR('H', 0x0A, struct hiddev_field_info)
+#define HIDIOCGUSAGE		_IOWR('H', 0x0B, struct hiddev_usage_ref)
+#define HIDIOCSUSAGE		_IOW('H', 0x0C, struct hiddev_usage_ref)
+#define HIDIOCGUCODE		_IOWR('H', 0x0D, struct hiddev_usage_ref)
+#define HIDIOCGFLAG		_IOR('H', 0x0E, int)
+#define HIDIOCSFLAG		_IOW('H', 0x0F, int)
+#define HIDIOCGCOLLECTIONINDEX	_IOW('H', 0x10, struct hiddev_usage_ref)
+#define HIDIOCGCOLLECTIONINFO	_IOWR('H', 0x11, struct hiddev_collection_info)
+
+/* 
+ * Flags to be used in HIDIOCSFLAG
+ */
+#define HIDDEV_FLAG_UREF	0x1
+#define HIDDEV_FLAG_REPORT	0x2
+#define HIDDEV_FLAGS		0x3
 
 /* To traverse the input report descriptor info for a HID device, perform the 
  * following:
@@ -179,13 +202,19 @@
 #ifdef CONFIG_USB_HIDDEV
 int hiddev_connect(struct hid_device *);
 void hiddev_disconnect(struct hid_device *);
-void hiddev_hid_event(struct hid_device *, unsigned int usage, int value);
+void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
+		      struct hid_usage *usage, __s32 value);
 int __init hiddev_init(void);
 void __exit hiddev_exit(void);
 #else
 static inline int hiddev_connect(struct hid_device *hid) { return -1; }
 static inline void hiddev_disconnect(struct hid_device *hid) { }
-static inline void hiddev_hid_event(struct hid_device *hid, unsigned int usage, int value) { }
+static inline void hiddev_hid_event(struct hid_device *hid, 
+                                         struct hid_field *field,
+                                         struct hid_usage *usage,
+                                         __s32 value) { }
+static inline void hiddev_report_event(struct hid_device *hid,
+                                       struct hid_report *report) { }
 static inline int hiddev_init(void) { return 0; }
 static inline void hiddev_exit(void) { }
 #endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/icmpv6.h linux-2.4.22-pre2/include/linux/icmpv6.h
--- linux-2.4.21/include/linux/icmpv6.h	2001-11-22 19:47:11.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/icmpv6.h	2003-06-26 21:43:14.000000000 +0000
@@ -86,6 +86,19 @@
 #define ICMPV6_MGM_REPORT       	131
 #define ICMPV6_MGM_REDUCTION    	132
 
+/* definitions for MLDv2 */
+
+#define MLD2_MODE_IS_INCLUDE	1
+#define MLD2_MODE_IS_EXCLUDE	2
+#define MLD2_CHANGE_TO_INCLUDE	3
+#define MLD2_CHANGE_TO_EXCLUDE	4
+#define MLD2_ALLOW_NEW_SOURCES	5
+#define MLD2_BLOCK_OLD_SOURCES	6
+
+/* this must be an IANA-assigned value; 206 for testing only */
+#define ICMPV6_MLD2_REPORT		206
+#define MLD2_ALL_MCR_INIT { { { 0xff,0x02,0,0,0,0,0,0,0,0,0,0,0,0,0,0x16 } } }
+
 /*
  *	Codes for Destination Unreachable
  */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/if_arcnet.h linux-2.4.22-pre2/include/linux/if_arcnet.h
--- linux-2.4.21/include/linux/if_arcnet.h	2000-12-11 20:59:27.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/if_arcnet.h	2003-06-26 21:43:12.000000000 +0000
@@ -25,6 +25,7 @@
 
 /* RFC1201 Protocol ID's */
 #define ARC_P_IP		212	/* 0xD4 */
+#define ARC_P_IPV6		196	/* 0xC4: RFC2497 */
 #define ARC_P_ARP		213	/* 0xD5 */
 #define ARC_P_RARP		214	/* 0xD6 */
 #define ARC_P_IPX		250	/* 0xFA */
@@ -45,6 +46,9 @@
 #define ARC_P_LANSOFT		251	/* 0xFB - what is this? */
 #define ARC_P_ATALK		0xDD
 
+/* Hardware address length */
+#define ARCNET_ALEN	1
+
 /*
  * The RFC1201-specific components of an arcnet packet header.
  */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/if_bonding.h linux-2.4.22-pre2/include/linux/if_bonding.h
--- linux-2.4.21/include/linux/if_bonding.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/if_bonding.h	2003-06-26 21:43:14.000000000 +0000
@@ -11,18 +11,38 @@
  *	This software may be used and distributed according to the terms
  *	of the GNU Public License, incorporated herein by reference.
  * 
+ * 2003/03/18 - Amir Noam <amir.noam at intel dot com>
+ *	- Added support for getting slave's speed and duplex via ethtool.
+ *	  Needed for 802.3ad and other future modes.
+ * 
+ * 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
+ *		Shmulik Hen <shmulik.hen at intel dot com>
+ *	- Enable support of modes that need to use the unique mac address of
+ *	  each slave.
+ *
+ * 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
+ *		Amir Noam <amir.noam at intel dot com>
+ *	- Moved driver's private data types to bonding.h
+ *
+ * 2003/03/18 - Amir Noam <amir.noam at intel dot com>,
+ *		Tsippy Mendelson <tsippy.mendelson at intel dot com> and
+ *		Shmulik Hen <shmulik.hen at intel dot com>
+ *	- Added support for IEEE 802.3ad Dynamic link aggregation mode.
+ *
+ * 2003/05/01 - Amir Noam <amir.noam at intel dot com>
+ *	- Added ABI version control to restore compatibility between
+ *	  new/old ifenslave and new/old bonding.
  */
 
 #ifndef _LINUX_IF_BONDING_H
 #define _LINUX_IF_BONDING_H
 
-#ifdef __KERNEL__
-#include <linux/timer.h>
 #include <linux/if.h>
-#include <linux/proc_fs.h>
-#endif /* __KERNEL__ */
-
 #include <linux/types.h>
+#include <linux/if_ether.h>
+
+/* userland - kernel ABI version (2003/05/08) */
+#define BOND_ABI_VERSION 1
 
 /*
  * We can remove these ioctl definitions in 2.5.  People should use the
@@ -41,6 +61,9 @@
 #define BOND_MODE_ACTIVEBACKUP	1
 #define BOND_MODE_XOR		2
 #define BOND_MODE_BROADCAST	3
+#define BOND_MODE_8023AD        4
+#define BOND_MODE_TLB           5
+#define BOND_MODE_ALB		6 /* TLB + RLB (receive load balancing) */
 
 /* each slave's link has 4 states */
 #define BOND_LINK_UP    0           /* link is up and running */
@@ -58,11 +81,6 @@
 #define BOND_MULTICAST_ACTIVE   1
 #define BOND_MULTICAST_ALL      2
 
-struct bond_parm_tbl {
-	char *modename;
-	int mode;
-};
-
 typedef struct ifbond {
 	__s32 bond_mode;
 	__s32 num_slaves;
@@ -78,52 +96,15 @@
 	__u32  link_failure_count;
 } ifslave;
 
-#ifdef __KERNEL__
-typedef struct slave {
-	struct slave *next;
-	struct slave *prev;
-	struct net_device *dev;
-	short  delay;
-	unsigned long jiffies;	
-	char   link;    /* one of BOND_LINK_XXXX */
-	char   state;   /* one of BOND_STATE_XXXX */
-	unsigned short original_flags;
-	u32 link_failure_count;
-} slave_t;
-
-/*
- * Here are the locking policies for the two bonding locks:
- *
- * 1) Get bond->lock when reading/writing slave list.
- * 2) Get bond->ptrlock when reading/writing bond->current_slave.
- *    (It is unnecessary when the write-lock is put with bond->lock.)
- * 3) When we lock with bond->ptrlock, we must lock with bond->lock
- *    beforehand.
- */
-typedef struct bonding {
-	slave_t *next;
-	slave_t *prev;
-	slave_t *current_slave;
-	slave_t *primary_slave;
-	slave_t *current_arp_slave;
-	__s32 slave_cnt;
-	rwlock_t lock;
-	rwlock_t ptrlock;
-	struct timer_list mii_timer;
-	struct timer_list arp_timer;
-	struct net_device_stats *stats;
-#ifdef CONFIG_PROC_FS
-	struct proc_dir_entry *bond_proc_dir;
-	struct proc_dir_entry *bond_proc_info_file;
-#endif /* CONFIG_PROC_FS */
-	struct bonding *next_bond;
-	struct net_device *device;
-	struct dev_mc_list *mc_list;
-	unsigned short flags;
-} bonding_t;
-#endif /* __KERNEL__ */
+struct ad_info {
+	__u16 aggregator_id;
+	__u16 ports;
+	__u16 actor_key;
+	__u16 partner_key;
+	__u8 partner_system[ETH_ALEN];
+};
 
-#endif /* _LINUX_BOND_H */
+#endif /* _LINUX_IF_BONDING_H */
 
 /*
  * Local variables:
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/if_vlan.h linux-2.4.22-pre2/include/linux/if_vlan.h
--- linux-2.4.21/include/linux/if_vlan.h	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/if_vlan.h	2003-06-26 21:43:13.000000000 +0000
@@ -148,6 +148,7 @@
 {
 	struct net_device_stats *stats;
 
+	skb->real_dev = skb->dev;
 	skb->dev = grp->vlan_devices[vlan_tag & VLAN_VID_MASK];
 	if (skb->dev == NULL) {
 		kfree_skb(skb);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/igmp.h linux-2.4.22-pre2/include/linux/igmp.h
--- linux-2.4.21/include/linux/igmp.h	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/igmp.h	2003-06-26 21:43:22.000000000 +0000
@@ -32,13 +32,60 @@
 	__u32 group;
 };
 
+/* V3 group record types [grec_type] */
+#define IGMPV3_MODE_IS_INCLUDE		1
+#define IGMPV3_MODE_IS_EXCLUDE		2
+#define IGMPV3_CHANGE_TO_INCLUDE	3
+#define IGMPV3_CHANGE_TO_EXCLUDE	4
+#define IGMPV3_ALLOW_NEW_SOURCES	5
+#define IGMPV3_BLOCK_OLD_SOURCES	6
+
+struct igmpv3_grec {
+	__u8	grec_type;
+	__u8	grec_auxwords;
+	__u16	grec_nsrcs;
+	__u32	grec_mca;
+	__u32	grec_src[0];
+};
+
+struct igmpv3_report {
+	__u8 type;
+	__u8 resv1;
+	__u16 csum;
+	__u16 resv2;
+	__u16 ngrec;
+	struct igmpv3_grec grec[0];
+};
+
+struct igmpv3_query {
+	__u8 type;
+	__u8 code;
+	__u16 csum;
+	__u32 group;
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+	__u8 qrv:3,
+	     suppress:1,
+	     resv:4;
+#elif defined(__BIG_ENDIAN_BITFIELD)
+	__u8 resv:4,
+	     suppress:1,
+	     qrv:3;
+#else
+#error "Please fix <asm/byteorder.h>"
+#endif
+	__u8 qqic;
+	__u16 nsrcs;
+	__u32 srcs[0];
+};
+
 #define IGMP_HOST_MEMBERSHIP_QUERY	0x11	/* From RFC1112 */
 #define IGMP_HOST_MEMBERSHIP_REPORT	0x12	/* Ditto */
 #define IGMP_DVMRP			0x13	/* DVMRP routing */
 #define IGMP_PIM			0x14	/* PIM routing */
 #define IGMP_TRACE			0x15
-#define IGMP_HOST_NEW_MEMBERSHIP_REPORT 0x16	/* New version of 0x11 */
+#define IGMPV2_HOST_MEMBERSHIP_REPORT	0x16	/* V2 version of 0x11 */
 #define IGMP_HOST_LEAVE_MESSAGE 	0x17
+#define IGMPV3_HOST_MEMBERSHIP_REPORT	0x22	/* V3 version of 0x11 */
 
 #define IGMP_MTRACE_RESP		0x1e
 #define IGMP_MTRACE			0x1f
@@ -68,6 +115,7 @@
 
 #define IGMP_ALL_HOSTS		htonl(0xE0000001L)
 #define IGMP_ALL_ROUTER 	htonl(0xE0000002L)
+#define IGMPV3_ALL_MCR	 	htonl(0xE0000016L)
 #define IGMP_LOCAL_GROUP	htonl(0xE0000000L)
 #define IGMP_LOCAL_GROUP_MASK	htonl(0xFFFFFF00L)
 
@@ -77,6 +125,18 @@
 
 #ifdef __KERNEL__
 
+struct ip_sf_socklist
+{
+	unsigned int		sl_max;
+	unsigned int		sl_count;
+	__u32			sl_addr[0];
+};
+
+#define IP_SFLSIZE(count)	(sizeof(struct ip_sf_socklist) + \
+	(count) * sizeof(__u32))
+
+#define IP_SFBLOCK	10	/* allocate this many at once */
+
 /* ip_mc_socklist is real list now. Speed is not argument;
    this list never used in fast path code
  */
@@ -86,12 +146,28 @@
 	struct ip_mc_socklist	*next;
 	int			count;
 	struct ip_mreqn		multi;
+	unsigned int		sfmode;		/* MCAST_{INCLUDE,EXCLUDE} */
+	struct ip_sf_socklist	*sflist;
+};
+
+struct ip_sf_list
+{
+	struct ip_sf_list	*sf_next;
+	__u32			sf_inaddr;
+	unsigned long		sf_count[2];	/* include/exclude counts */
+	unsigned char		sf_gsresp;	/* include in g & s response? */
+	unsigned char		sf_oldin;	/* change state */
+	unsigned char		sf_crcount;	/* retrans. left to send */
 };
 
 struct ip_mc_list
 {
 	struct in_device	*interface;
 	unsigned long		multiaddr;
+	struct ip_sf_list	*sources;
+	struct ip_sf_list	*tomb;
+	unsigned int		sfmode;
+	unsigned long		sfcount[2];
 	struct ip_mc_list	*next;
 	struct timer_list	timer;
 	int			users;
@@ -101,13 +177,33 @@
 	char			reporter;
 	char			unsolicit_count;
 	char			loaded;
+	unsigned char		gsquery;	/* check source marks? */
+	unsigned char		crcount;
 };
 
-extern int ip_check_mc(struct in_device *dev, u32 mc_addr);
+/* V3 exponential field decoding */
+#define IGMPV3_MASK(value, nb) ((nb)>=32 ? (value) : ((1<<(nb))-1) & (value))
+#define IGMPV3_EXP(thresh, nbmant, nbexp, value) \
+	((value) < (thresh) ? (value) : \
+        ((IGMPV3_MASK(value, nbmant) | (1<<(nbmant+nbexp))) << \
+         (IGMPV3_MASK((value) >> (nbmant), nbexp) + (nbexp))))
+
+#define IGMPV3_QQIC(value) IGMPV3_EXP(0x80, 4, 3, value)
+#define IGMPV3_MRC(value) IGMPV3_EXP(0x80, 4, 3, value)
+
+extern int ip_check_mc(struct in_device *dev, u32 mc_addr, u32 src_addr);
 extern int igmp_rcv(struct sk_buff *);
 extern int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr);
 extern int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr);
 extern void ip_mc_drop_socket(struct sock *sk);
+extern int ip_mc_source(int add, int omode, struct sock *sk,
+		struct ip_mreq_source *mreqs, int ifindex);
+extern int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf,int ifindex);
+extern int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
+		struct ip_msfilter *optval, int *optlen);
+extern int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
+		struct group_filter *optval, int *optlen);
+extern int ip_mc_sf_allow(struct sock *sk, u32 local, u32 rmt, int dif);
 extern void ip_mr_init(void);
 extern void ip_mc_init_dev(struct in_device *);
 extern void ip_mc_destroy_dev(struct in_device *);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/in.h linux-2.4.22-pre2/include/linux/in.h
--- linux-2.4.21/include/linux/in.h	2001-11-22 19:46:18.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/in.h	2003-06-26 21:43:21.000000000 +0000
@@ -81,6 +81,21 @@
 #define IP_MULTICAST_LOOP 		34
 #define IP_ADD_MEMBERSHIP		35
 #define IP_DROP_MEMBERSHIP		36
+#define IP_UNBLOCK_SOURCE		37
+#define IP_BLOCK_SOURCE			38
+#define IP_ADD_SOURCE_MEMBERSHIP	39
+#define IP_DROP_SOURCE_MEMBERSHIP	40
+#define IP_MSFILTER			41
+#define MCAST_JOIN_GROUP		42
+#define MCAST_BLOCK_SOURCE		43
+#define MCAST_UNBLOCK_SOURCE		44
+#define MCAST_LEAVE_GROUP		45
+#define MCAST_JOIN_SOURCE_GROUP		46
+#define MCAST_LEAVE_SOURCE_GROUP	47
+#define MCAST_MSFILTER			48
+
+#define MCAST_EXCLUDE	0
+#define MCAST_INCLUDE	1
 
 /* These need to appear somewhere around here */
 #define IP_DEFAULT_MULTICAST_TTL        1
@@ -101,6 +116,50 @@
 	int		imr_ifindex;		/* Interface index */
 };
 
+struct ip_mreq_source {
+	__u32		imr_multiaddr;
+	__u32		imr_interface;
+	__u32		imr_sourceaddr;
+};
+
+struct ip_msfilter {
+	__u32		imsf_multiaddr;
+	__u32		imsf_interface;
+	__u32		imsf_fmode;
+	__u32		imsf_numsrc;
+	__u32		imsf_slist[1];
+};
+
+#define IP_MSFILTER_SIZE(numsrc) \
+	(sizeof(struct ip_msfilter) - sizeof(__u32) \
+	+ (numsrc) * sizeof(__u32))
+
+struct group_req
+{
+	__u32			gr_interface;	/* interface index */
+	struct sockaddr_storage	gr_group;	/* group address */
+};
+
+struct group_source_req
+{
+	__u32			gsr_interface;	/* interface index */
+	struct sockaddr_storage	gsr_group;	/* group address */
+	struct sockaddr_storage	gsr_source;	/* source address */
+};
+
+struct group_filter
+{
+	__u32			gf_interface;	/* interface index */
+	struct sockaddr_storage	gf_group;	/* multicast address */
+	__u32			gf_fmode;	/* filter mode */
+	__u32			gf_numsrc;	/* number of sources */
+	struct sockaddr_storage	gf_slist[1];	/* interface index */
+};
+
+#define GROUP_FILTER_SIZE(numsrc) \
+	(sizeof(struct group_filter) - sizeof(struct sockaddr_storage) \
+	+ (numsrc) * sizeof(struct sockaddr_storage))
+
 struct in_pktinfo
 {
 	int		ipi_ifindex;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/inetdevice.h linux-2.4.22-pre2/include/linux/inetdevice.h
--- linux-2.4.21/include/linux/inetdevice.h	2002-08-03 00:39:45.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/inetdevice.h	2003-06-26 21:43:12.000000000 +0000
@@ -32,7 +32,17 @@
 	int			dead;
 	struct in_ifaddr	*ifa_list;	/* IP ifaddr chain		*/
 	struct ip_mc_list	*mc_list;	/* IP multicast filter chain    */
+	rwlock_t		mc_lock;	/* for mc_tomb */
+	struct ip_mc_list	*mc_tomb;
 	unsigned long		mr_v1_seen;
+	unsigned long		mr_v2_seen;
+	unsigned long		mr_maxdelay;
+	unsigned char		mr_qrv;
+	unsigned char		mr_gq_running;
+	unsigned char		mr_ifc_count;
+	struct timer_list	mr_gq_timer;	/* general query timer */
+	struct timer_list	mr_ifc_timer;	/* interface change timer */
+
 	struct neigh_parms	*arp_parms;
 	struct ipv4_devconf	cnf;
 };
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/isdn_ppp.h linux-2.4.22-pre2/include/linux/isdn_ppp.h
--- linux-2.4.21/include/linux/isdn_ppp.h	2001-09-30 19:26:42.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/isdn_ppp.h	2003-06-26 21:43:13.000000000 +0000
@@ -65,6 +65,9 @@
 
 #include <linux/config.h>
 
+#ifdef CONFIG_IPPP_FILTER
+#include <linux/filter.h>
+#endif
 
 #define DECOMP_ERR_NOMEM	(-10)
 
@@ -223,6 +226,10 @@
   unsigned char *cbuf;
   struct slcompress *slcomp;
 #endif
+#ifdef CONFIG_IPPP_FILTER
+  struct sock_fprog pass_filter;	/* filter for packets to pass */
+  struct sock_fprog active_filter;	/* filter for pkts to reset idle */
+#endif
   unsigned long debug;
   struct isdn_ppp_compressor *compressor,*decompressor;
   struct isdn_ppp_compressor *link_compressor,*link_decompressor;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/netdevice.h linux-2.4.22-pre2/include/linux/netdevice.h
--- linux-2.4.21/include/linux/netdevice.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/netdevice.h	2003-06-26 21:43:18.000000000 +0000
@@ -191,8 +191,14 @@
 	int		hh_len;		/* length of header */
 	int		(*hh_output)(struct sk_buff *skb);
 	rwlock_t	hh_lock;
+
 	/* cached hardware header; allow for machine alignment needs.        */
-	unsigned long	hh_data[16/sizeof(unsigned long)];
+#define HH_DATA_MOD	16
+#define HH_DATA_OFF(__len) \
+	(HH_DATA_MOD - ((__len) & (HH_DATA_MOD - 1)))
+#define HH_DATA_ALIGN(__len) \
+	(((__len)+(HH_DATA_MOD-1))&~(HH_DATA_MOD - 1))
+	unsigned long	hh_data[HH_DATA_ALIGN(LL_MAX_HEADER)];
 };
 
 /* These flag bits are private to the generic network queueing
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/netfilter.h linux-2.4.22-pre2/include/linux/netfilter.h
--- linux-2.4.21/include/linux/netfilter.h	2001-11-22 19:47:48.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/netfilter.h	2003-06-26 21:43:22.000000000 +0000
@@ -19,9 +19,10 @@
 #define NF_REPEAT 4
 #define NF_MAX_VERDICT NF_REPEAT
 
-/* Generic cache responses from hook functions. */
-#define NFC_ALTERED 0x8000
+/* Generic cache responses from hook functions.
+   <= 0x2000 is used for protocol-flags. */
 #define NFC_UNKNOWN 0x4000
+#define NFC_ALTERED 0x8000
 
 #ifdef __KERNEL__
 #include <linux/config.h>
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/netfilter_arp/arp_tables.h linux-2.4.22-pre2/include/linux/netfilter_arp/arp_tables.h
--- linux-2.4.21/include/linux/netfilter_arp/arp_tables.h	2002-08-03 00:39:45.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/netfilter_arp/arp_tables.h	2003-06-26 21:43:16.000000000 +0000
@@ -111,7 +111,7 @@
 #define ARPT_INV_ARPHRD		0x0080	/* Invert the sense of ARP HRD. */
 #define ARPT_INV_ARPPRO		0x0100	/* Invert the sense of ARP PRO. */
 #define ARPT_INV_ARPHLN		0x0200	/* Invert the sense of ARP HLN. */
-#define ARPT_INV_MASK		0x007F	/* All possible flag bits mask. */
+#define ARPT_INV_MASK		0x03FF	/* All possible flag bits mask. */
 
 /* This structure defines each of the firewall rules.  Consists of 3
    parts which are 1) general ARP header stuff 2) match specific
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/netfilter_ipv4/ipt_recent.h linux-2.4.22-pre2/include/linux/netfilter_ipv4/ipt_recent.h
--- linux-2.4.21/include/linux/netfilter_ipv4/ipt_recent.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/netfilter_ipv4/ipt_recent.h	2003-06-26 21:43:13.000000000 +0000
@@ -0,0 +1,27 @@
+#ifndef _IPT_RECENT_H
+#define _IPT_RECENT_H
+
+#define RECENT_NAME	"ipt_recent"
+#define RECENT_VER	"v0.3.1"
+
+#define IPT_RECENT_CHECK  1
+#define IPT_RECENT_SET    2
+#define IPT_RECENT_UPDATE 4
+#define IPT_RECENT_REMOVE 8
+#define IPT_RECENT_TTL   16
+
+#define IPT_RECENT_SOURCE 0
+#define IPT_RECENT_DEST   1
+
+#define IPT_RECENT_NAME_LEN 200
+
+struct ipt_recent_info {
+	u_int32_t   seconds;
+	u_int32_t   hit_count;
+	u_int8_t    check_set;
+	u_int8_t    invert;
+	char        name[IPT_RECENT_NAME_LEN];
+	u_int8_t    side;
+};
+
+#endif /*_IPT_RECENT_H*/
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/netfilter_ipv4/listhelp.h linux-2.4.22-pre2/include/linux/netfilter_ipv4/listhelp.h
--- linux-2.4.21/include/linux/netfilter_ipv4/listhelp.h	2001-07-26 20:52:12.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/netfilter_ipv4/listhelp.h	2003-06-26 21:43:12.000000000 +0000
@@ -39,6 +39,22 @@
 	(type)__i;				\
 })
 
+/* Just like LIST_FIND but we search backwards */
+#define LIST_FIND_B(head, cmpfn, type, args...)		\
+({							\
+	const struct list_head *__i = (head);		\
+							\
+	ASSERT_READ_LOCK(head);				\
+	do {						\
+		__i = __i->prev;			\
+		if (__i == (head)) {			\
+			__i = NULL;			\
+			break;				\
+		}					\
+	} while (!cmpfn((const type)__i , ## args));	\
+	(type)__i;					\
+})
+
 static inline int
 __list_cmp_same(const void *p1, const void *p2) { return p1 == p2; }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/netfilter_ipv4/lockhelp.h linux-2.4.22-pre2/include/linux/netfilter_ipv4/lockhelp.h
--- linux-2.4.21/include/linux/netfilter_ipv4/lockhelp.h	2001-01-01 18:37:41.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/netfilter_ipv4/lockhelp.h	2003-06-26 21:43:11.000000000 +0000
@@ -42,22 +42,22 @@
 	printk("ASSERT %s:%u %s locked\n", __FILE__, __LINE__, #l);	\
 } while(0)
 
-/* Write locked OK as well. */						    \
+/* Write locked OK as well. */
 #define MUST_BE_READ_LOCKED(l)						    \
-do { if (!((l)->read_locked_map & (1 << smp_processor_id()))		    \
-	 && !((l)->write_locked_map & (1 << smp_processor_id())))	    \
+do { if (!((l)->read_locked_map & (1UL << smp_processor_id()))		    \
+	 && !((l)->write_locked_map & (1UL << smp_processor_id())))	    \
 	printk("ASSERT %s:%u %s not readlocked\n", __FILE__, __LINE__, #l); \
 } while(0)
 
 #define MUST_BE_WRITE_LOCKED(l)						     \
-do { if (!((l)->write_locked_map & (1 << smp_processor_id())))		     \
+do { if (!((l)->write_locked_map & (1UL << smp_processor_id())))	     \
 	printk("ASSERT %s:%u %s not writelocked\n", __FILE__, __LINE__, #l); \
 } while(0)
 
 #define MUST_BE_READ_WRITE_UNLOCKED(l)					  \
-do { if ((l)->read_locked_map & (1 << smp_processor_id()))		  \
+do { if ((l)->read_locked_map & (1UL << smp_processor_id()))		  \
 	printk("ASSERT %s:%u %s readlocked\n", __FILE__, __LINE__, #l);	  \
- else if ((l)->write_locked_map & (1 << smp_processor_id()))		  \
+ else if ((l)->write_locked_map & (1UL << smp_processor_id()))		  \
 	 printk("ASSERT %s:%u %s writelocked\n", __FILE__, __LINE__, #l); \
 } while(0)
 
@@ -91,7 +91,7 @@
 
 #define READ_UNLOCK(lk)							\
 do {									\
-	if (!((lk)->read_locked_map & (1 << smp_processor_id())))	\
+	if (!((lk)->read_locked_map & (1UL << smp_processor_id())))	\
 		printk("ASSERT: %s:%u %s not readlocked\n", 		\
 		       __FILE__, __LINE__, #lk);			\
 	clear_bit(smp_processor_id(), &(lk)->read_locked_map);		\
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/pci_ids.h linux-2.4.22-pre2/include/linux/pci_ids.h
--- linux-2.4.21/include/linux/pci_ids.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/pci_ids.h	2003-06-26 21:43:19.000000000 +0000
@@ -1640,6 +1640,9 @@
 #define PCI_DEVICE_ID_AKS_ALADDINCARD	0x0100
 #define PCI_DEVICE_ID_AKS_CPC		0x0200
 
+#define PCI_VENDOR_ID_REDCREEK		0x4916
+#define PCI_DEVICE_ID_RC45		0x1960
+
 #define PCI_VENDOR_ID_NETVIN		0x4a14
 #define PCI_DEVICE_ID_NETVIN_NV5000SC	0x5000
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/rtnetlink.h linux-2.4.22-pre2/include/linux/rtnetlink.h
--- linux-2.4.21/include/linux/rtnetlink.h	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/rtnetlink.h	2003-06-26 21:43:30.000000000 +0000
@@ -49,7 +49,7 @@
 #define	RTM_MAX		(RTM_BASE+31)
 
 /* 
-   Generic structure for encapsulation optional route information.
+   Generic structure for encapsulation of optional route information.
    It is reminiscent of sockaddr, but with sa_family replaced
    with attribute type.
  */
@@ -77,7 +77,7 @@
 
 
 /******************************************************************************
- *		Definitions used in routing table administation.
+ *		Definitions used in routing table administration.
  ****/
 
 struct rtmsg
@@ -128,14 +128,14 @@
 #define RTPROT_STATIC	4	/* Route installed by administrator	*/
 
 /* Values of protocol >= RTPROT_STATIC are not interpreted by kernel;
-   they just passed from user and back as is.
+   they are just passed from user and back as is.
    It will be used by hypothetical multiple routing daemons.
    Note that protocol values should be standardized in order to
    avoid conflicts.
  */
 
 #define RTPROT_GATED	8	/* Apparently, GateD */
-#define RTPROT_RA	9	/* RDISC/ND router advertisments */
+#define RTPROT_RA	9	/* RDISC/ND router advertisements */
 #define RTPROT_MRT	10	/* Merit MRT */
 #define RTPROT_ZEBRA	11	/* Zebra */
 #define RTPROT_BIRD	12	/* BIRD */
@@ -208,8 +208,8 @@
 
 /* RTM_MULTIPATH --- array of struct rtnexthop.
  *
- * "struct rtnexthop" describres all necessary nexthop information,
- * i.e. parameters of path to a destination via this nextop.
+ * "struct rtnexthop" describes all necessary nexthop information,
+ * i.e. parameters of path to a destination via this nexthop.
  *
  * At the moment it is impossible to set different prefsrc, mtu, window
  * and rtt for different paths from multipath.
@@ -463,7 +463,7 @@
 
    Comments:
    - Combination IFF_BROADCAST|IFF_POINTOPOINT is invalid
-   - If neiher of these three flags are set;
+   - If neither of these three flags are set;
      the interface is NBMA.
 
    - IFF_MULTICAST does not mean anything special:
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/skbuff.h linux-2.4.22-pre2/include/linux/skbuff.h
--- linux-2.4.21/include/linux/skbuff.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/skbuff.h	2003-06-26 21:43:11.000000000 +0000
@@ -135,6 +135,10 @@
 	struct sock	*sk;			/* Socket we are owned by 			*/
 	struct timeval	stamp;			/* Time we arrived				*/
 	struct net_device	*dev;		/* Device we arrived on/are leaving by		*/
+	struct net_device	*real_dev;	/* For support of point to point protocols 
+						   (e.g. 802.3ad) over bonding, we must save the
+						   physical device that got the packet before
+						   replacing skb->dev with the virtual device.  */
 
 	/* Transport layer header */
 	union
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/sysctl.h linux-2.4.22-pre2/include/linux/sysctl.h
--- linux-2.4.21/include/linux/sysctl.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/sysctl.h	2003-06-26 21:43:10.000000000 +0000
@@ -125,6 +125,7 @@
 	KERN_TAINTED=53,	/* int: various kernel tainted flags */
 	KERN_CADPID=54,		/* int: PID of the process to notify on CAD */
  	KERN_CORE_PATTERN=56,	/* string: pattern for core-files */
+	KERN_PPC_L3CR=57,       /* l3cr register on PPC */
 };
 
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/linux/wait.h linux-2.4.22-pre2/include/linux/wait.h
--- linux-2.4.21/include/linux/wait.h	2001-11-22 19:46:19.000000000 +0000
+++ linux-2.4.22-pre2/include/linux/wait.h	2003-06-26 21:43:10.000000000 +0000
@@ -125,7 +125,7 @@
 #endif
 
 /*
- * Macros for declaration and initialisaton of the datatypes
+ * Macros for declaration and initialization of the datatypes
  */
 
 #if WAITQUEUE_DEBUG
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/net/addrconf.h linux-2.4.22-pre2/include/net/addrconf.h
--- linux-2.4.21/include/net/addrconf.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/net/addrconf.h	2003-06-26 21:43:14.000000000 +0000
@@ -71,30 +71,26 @@
 /*
  *	multicast prototypes (mcast.c)
  */
-extern int			ipv6_sock_mc_join(struct sock *sk, 
-						  int ifindex, 
-						  struct in6_addr *addr);
-extern int			ipv6_sock_mc_drop(struct sock *sk,
-						  int ifindex, 
-						  struct in6_addr *addr);
-extern void			ipv6_sock_mc_close(struct sock *sk);
-extern int			inet6_mc_check(struct sock *sk, struct in6_addr *addr);
-
-extern int			ipv6_dev_mc_inc(struct net_device *dev,
-						struct in6_addr *addr);
-extern int			ipv6_dev_mc_dec(struct net_device *dev,
-						struct in6_addr *addr);
-extern void			ipv6_mc_up(struct inet6_dev *idev);
-extern void			ipv6_mc_down(struct inet6_dev *idev);
-extern void			ipv6_mc_init_dev(struct inet6_dev *idev);
-extern void			ipv6_mc_destroy_dev(struct inet6_dev *idev);
-extern void			addrconf_dad_failure(struct inet6_ifaddr *ifp);
+extern int ipv6_sock_mc_join(struct sock *sk, int ifindex, 
+		  struct in6_addr *addr);
+extern int ipv6_sock_mc_drop(struct sock *sk, int ifindex, 
+		  struct in6_addr *addr);
+extern void ipv6_sock_mc_close(struct sock *sk);
+extern int inet6_mc_check(struct sock *sk, struct in6_addr *mc_addr,
+		struct in6_addr *src_addr);
+
+extern int ipv6_dev_mc_inc(struct net_device *dev, struct in6_addr *addr);
+extern int ipv6_dev_mc_dec(struct net_device *dev, struct in6_addr *addr);
+extern void ipv6_mc_up(struct inet6_dev *idev);
+extern void ipv6_mc_down(struct inet6_dev *idev);
+extern void ipv6_mc_init_dev(struct inet6_dev *idev);
+extern void ipv6_mc_destroy_dev(struct inet6_dev *idev);
+extern void addrconf_dad_failure(struct inet6_ifaddr *ifp);
 
-extern int			ipv6_chk_mcast_addr(struct net_device *dev,
-						    struct in6_addr *addr);
+extern int ipv6_chk_mcast_addr(struct net_device *dev, struct in6_addr *group,
+		struct in6_addr *src_addr);
 
-extern void			addrconf_prefix_rcv(struct net_device *dev,
-						    u8 *opt, int len);
+extern void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len);
 
 /*
  *	anycast prototypes (anycast.c)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/net/bluetooth/bluetooth.h linux-2.4.22-pre2/include/net/bluetooth/bluetooth.h
--- linux-2.4.21/include/net/bluetooth/bluetooth.h	2002-08-03 00:39:46.000000000 +0000
+++ linux-2.4.22-pre2/include/net/bluetooth/bluetooth.h	2003-06-26 21:43:19.000000000 +0000
@@ -51,6 +51,7 @@
 #define BTPROTO_SCO   	2
 #define BTPROTO_RFCOMM	3
 #define BTPROTO_BNEP	4
+#define BTPROTO_CMTP	5
 
 #define SOL_HCI     0
 #define SOL_L2CAP   6
@@ -155,7 +156,7 @@
 void bluez_sock_unlink(struct bluez_sock_list *l, struct sock *s);
 int  bluez_sock_recvmsg(struct socket *sock, struct msghdr *msg, int len, int flags, struct scm_cookie *scm);
 uint bluez_sock_poll(struct file * file, struct socket *sock, poll_table *wait);
-int  bluez_sock_w4_connect(struct sock *sk, int flags);
+int  bluez_sock_wait_state(struct sock *sk, int state, unsigned long timeo);
 
 void bluez_accept_enqueue(struct sock *parent, struct sock *sk);
 struct sock * bluez_accept_dequeue(struct sock *parent, struct socket *newsock);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/net/bluetooth/hci.h linux-2.4.22-pre2/include/net/bluetooth/hci.h
--- linux-2.4.21/include/net/bluetooth/hci.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/net/bluetooth/hci.h	2003-06-26 21:43:17.000000000 +0000
@@ -160,6 +160,7 @@
 #define HCI_LM_AUTH	0x0002
 #define HCI_LM_ENCRYPT	0x0004
 #define HCI_LM_TRUSTED	0x0008
+#define HCI_LM_RELIABLE	0x0010
 
 /* -----  HCI Commands ----- */
 /* OGF & OCF values */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/net/bluetooth/l2cap.h linux-2.4.22-pre2/include/net/bluetooth/l2cap.h
--- linux-2.4.21/include/net/bluetooth/l2cap.h	2002-08-03 00:39:46.000000000 +0000
+++ linux-2.4.22-pre2/include/net/bluetooth/l2cap.h	2003-06-26 21:43:13.000000000 +0000
@@ -60,6 +60,7 @@
 #define L2CAP_LM_AUTH		0x0002
 #define L2CAP_LM_ENCRYPT	0x0004
 #define L2CAP_LM_TRUSTED	0x0008
+#define L2CAP_LM_RELIABLE	0x0010
 
 #define L2CAP_QOS	0x04
 struct l2cap_qos {
@@ -229,6 +230,7 @@
 	__u32		link_mode;
 
 	__u8		conf_state;
+	__u8		conf_retry;
 	__u16		conf_mtu;
 
 	__u8		ident;
@@ -238,8 +240,9 @@
 	struct sock 		*prev_c;
 };
 
-#define CONF_REQ_SENT    0x01
-#define CONF_INPUT_DONE  0x02
-#define CONF_OUTPUT_DONE 0x04
+#define L2CAP_CONF_REQ_SENT    0x01
+#define L2CAP_CONF_INPUT_DONE  0x02
+#define L2CAP_CONF_OUTPUT_DONE 0x04
+#define L2CAP_CONF_MAX_RETRIES 2
 
 #endif /* __L2CAP_H */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/net/bluetooth/rfcomm.h linux-2.4.22-pre2/include/net/bluetooth/rfcomm.h
--- linux-2.4.21/include/net/bluetooth/rfcomm.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/net/bluetooth/rfcomm.h	2003-06-26 21:43:11.000000000 +0000
@@ -185,10 +185,11 @@
 	atomic_t      refcnt;
 	u8            dlci;
 	u8            addr;
-
-	uint          mtu;
+	u8            priority;
 	u8            v24_sig;
+	u8            mscex;
 
+	uint          mtu;
 	uint          credits;
 	uint          rx_credits;
 	uint          tx_credits;
@@ -213,6 +214,11 @@
 #define RFCOMM_SCHED_TIMEO  3
 #define RFCOMM_SCHED_WAKEUP 31
 
+/* MSC exchange flags */
+#define RFCOMM_MSCEX_TX     1
+#define RFCOMM_MSCEX_RX     2
+#define RFCOMM_MSCEX_OK     (RFCOMM_MSCEX_TX + RFCOMM_MSCEX_RX)
+
 extern struct task_struct *rfcomm_thread;
 extern unsigned long rfcomm_event;
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/net/if_inet6.h linux-2.4.22-pre2/include/net/if_inet6.h
--- linux-2.4.21/include/net/if_inet6.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/net/if_inet6.h	2003-06-26 21:43:33.000000000 +0000
@@ -46,27 +46,58 @@
 	int			dead;
 };
 
+struct ip6_sf_socklist
+{
+	unsigned int		sl_max;
+	unsigned int		sl_count;
+	struct in6_addr		sl_addr[0];
+};
+
+#define IP6_SFLSIZE(count)	(sizeof(struct ip6_sf_socklist) + \
+	(count) * sizeof(struct in6_addr))
+
+#define IP6_SFBLOCK	10	/* allocate this many at once */
+
 struct ipv6_mc_socklist
 {
 	struct in6_addr		addr;
 	int			ifindex;
 	struct ipv6_mc_socklist *next;
+	unsigned int		sfmode;		/* MCAST_{INCLUDE,EXCLUDE} */
+	struct ip6_sf_socklist	*sflist;
+};
+
+struct ip6_sf_list
+{
+	struct ip6_sf_list	*sf_next;
+	struct in6_addr		sf_addr;
+	unsigned long		sf_count[2];	/* include/exclude counts */
+	unsigned char		sf_gsresp;	/* include in g & s response? */
+	unsigned char		sf_oldin;	/* change state */
+	unsigned char		sf_crcount;	/* retrans. left to send */
 };
 
 #define MAF_TIMER_RUNNING	0x01
 #define MAF_LAST_REPORTER	0x02
 #define MAF_LOADED		0x04
+#define MAF_NOREPORT		0x08
+#define MAF_GSQUERY		0x10
 
 struct ifmcaddr6
 {
 	struct in6_addr		mca_addr;
 	struct inet6_dev	*idev;
 	struct ifmcaddr6	*next;
+	struct ip6_sf_list	*mca_sources;
+	struct ip6_sf_list	*mca_tomb;
+	unsigned int		mca_sfmode;
+	unsigned long		mca_sfcount[2];
 	struct timer_list	mca_timer;
 	unsigned		mca_flags;
 	int			mca_users;
 	atomic_t		mca_refcnt;
 	spinlock_t		mca_lock;
+	unsigned char		mca_crcount;
 };
 
 /* Anycast stuff */
@@ -114,7 +145,18 @@
 	struct net_device		*dev;
 
 	struct inet6_ifaddr	*addr_list;
+
 	struct ifmcaddr6	*mc_list;
+	struct ifmcaddr6	*mc_tomb;
+	rwlock_t		mc_lock;
+	unsigned long		mc_v1_seen;
+	unsigned long		mc_maxdelay;
+	unsigned char		mc_qrv;
+	unsigned char		mc_gq_running;
+	unsigned char		mc_ifc_count;
+	struct timer_list	mc_gq_timer;	/* general query timer */
+	struct timer_list	mc_ifc_timer;	/* interface change timer */
+
 	struct ifacaddr6	*ac_list;
 	rwlock_t		lock;
 	atomic_t		refcnt;
@@ -195,5 +237,10 @@
 		buf[5]=0x00;
 	}
 }
+
+static inline void ipv6_arcnet_mc_map(const struct in6_addr *addr, char *buf)
+{
+	buf[0] = 0x00;
+}
 #endif
 #endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/net/ip.h linux-2.4.22-pre2/include/net/ip.h
--- linux-2.4.21/include/net/ip.h	2001-11-22 19:47:15.000000000 +0000
+++ linux-2.4.22-pre2/include/net/ip.h	2003-06-26 21:43:29.000000000 +0000
@@ -78,6 +78,7 @@
 extern void		ip_mc_dropsocket(struct sock *);
 extern void		ip_mc_dropdevice(struct net_device *dev);
 extern int		ip_mc_procinfo(char *, char **, off_t, int);
+extern int		ip_mcf_procinfo(char *, char **, off_t, int);
 
 /*
  *	Functions provided by ip.c
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/net/ip6_fib.h linux-2.4.22-pre2/include/net/ip6_fib.h
--- linux-2.4.21/include/net/ip6_fib.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/net/ip6_fib.h	2003-06-26 21:43:30.000000000 +0000
@@ -120,7 +120,7 @@
 struct rt6_statistics {
 	__u32		fib_nodes;
 	__u32		fib_route_nodes;
-	__u32		fib_rt_alloc;		/* permanet routes	*/
+	__u32		fib_rt_alloc;		/* permanent routes	*/
 	__u32		fib_rt_entries;		/* rt entries in table	*/
 	__u32		fib_rt_cache;		/* cache routes		*/
 };
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/net/irda/crc.h linux-2.4.22-pre2/include/net/irda/crc.h
--- linux-2.4.21/include/net/irda/crc.h	2000-12-11 21:33:31.000000000 +0000
+++ linux-2.4.22-pre2/include/net/irda/crc.h	2003-06-26 21:43:15.000000000 +0000
@@ -28,6 +28,6 @@
 }
 
 /* Recompute the FCS with len bytes appended. */
-unsigned short crc_calc( __u16 fcs, __u8 const *buf, size_t len);
+unsigned short irda_calc_crc16( __u16 fcs, __u8 const *buf, size_t len);
 
 #endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/net/irda/ircomm_tty.h linux-2.4.22-pre2/include/net/irda/ircomm_tty.h
--- linux-2.4.21/include/net/irda/ircomm_tty.h	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/include/net/irda/ircomm_tty.h	2003-06-26 21:43:18.000000000 +0000
@@ -47,7 +47,9 @@
 /* This is used as an initial value to max_header_size before the proper
  * value is filled in (5 for ttp, 4 for lmp). This allow us to detect
  * the state of the underlying connection. - Jean II */
-#define IRCOMM_TTY_HDR_UNITIALISED	32
+#define IRCOMM_TTY_HDR_UNINITIALISED	16
+/* Same for payload size. See qos.c for the smallest max data size */
+#define IRCOMM_TTY_DATA_UNINITIALISED	(64 - IRCOMM_TTY_HDR_UNINITIALISED)
 
 /*
  * IrCOMM TTY driver state
@@ -82,6 +84,7 @@
 
 	__u32 max_data_size;   /* Max data we can transmit in one packet */
 	__u32 max_header_size; /* The amount of header space we must reserve */
+	__u32 tx_data_size;	/* Max data size of current tx_skb */
 
 	struct iriap_cb *iriap; /* Instance used for querying remote IAS */
 	struct ias_object* obj;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/net/irda/irlan_common.h linux-2.4.22-pre2/include/net/irda/irlan_common.h
--- linux-2.4.21/include/net/irda/irlan_common.h	2000-12-11 21:33:09.000000000 +0000
+++ linux-2.4.22-pre2/include/net/irda/irlan_common.h	2003-06-26 21:43:13.000000000 +0000
@@ -195,8 +195,6 @@
 struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr);
 void irlan_close(struct irlan_cb *self);
 void irlan_close_tsaps(struct irlan_cb *self);
-void irlan_mod_inc_use_count(void);
-void irlan_mod_dec_use_count(void);
 
 int  irlan_register_netdev(struct irlan_cb *self);
 void irlan_ias_register(struct irlan_cb *self, __u8 tsap_sel);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/net/route.h linux-2.4.22-pre2/include/net/route.h
--- linux-2.4.21/include/net/route.h	2002-08-03 00:39:46.000000000 +0000
+++ linux-2.4.22-pre2/include/net/route.h	2003-06-26 21:43:10.000000000 +0000
@@ -114,6 +114,8 @@
         unsigned int gc_ignored;
         unsigned int gc_goal_miss;
         unsigned int gc_dst_overflow;
+	unsigned int in_hlist_search;
+	unsigned int out_hlist_search;
 } ____cacheline_aligned_in_smp;
 
 extern struct ip_rt_acct *ip_rt_acct;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/net/snmp.h linux-2.4.22-pre2/include/net/snmp.h
--- linux-2.4.21/include/net/snmp.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/net/snmp.h	2003-06-26 21:43:18.000000000 +0000
@@ -42,6 +42,11 @@
  */ 
 
  
+/*
+ * RFC 1213:  MIB-II
+ * RFC 2011 (updates 1213):  SNMPv2-MIB-IP
+ * RFC 2863:  Interfaces Group MIB
+ */
 struct ip_mib
 {
  	unsigned long	IpInReceives;
@@ -64,6 +69,9 @@
 	unsigned long   __pad[0]; 
 } ____cacheline_aligned;
  
+/*
+ * RFC 2465:  IPv6 MIB: General Group
+ */
 struct ipv6_mib
 {
 	unsigned long	Ip6InReceives;
@@ -91,6 +99,10 @@
 	unsigned long   __pad[0]; 
 } ____cacheline_aligned;
  
+/*
+ * RFC 1213:  MIB-II ICMP Group
+ * RFC 2011 (updates 1213):  SNMPv2 MIB for IP: ICMP group
+ */
 struct icmp_mib
 {
  	unsigned long	IcmpInMsgs;
@@ -123,6 +135,9 @@
 	unsigned long   __pad[0]; 
 } ____cacheline_aligned;
 
+/*
+ * RFC 2466:  ICMPv6-MIB
+ */
 struct icmpv6_mib
 {
 	unsigned long	Icmp6InMsgs;
@@ -161,6 +176,10 @@
 	unsigned long   __pad[0]; 
 } ____cacheline_aligned;
  
+/*
+ * RFC 1213:  MIB-II TCP group
+ * RFC 2012 (updates 1213):  SNMPv2-MIB-TCP
+ */
 struct tcp_mib
 {
  	unsigned long	TcpRtoAlgorithm;
@@ -180,6 +199,10 @@
 	unsigned long   __pad[0]; 
 } ____cacheline_aligned;
  
+/*
+ * RFC 1213:  MIB-II UDP group
+ * RFC 2013 (updates 1213):  SNMPv2-MIB-UDP
+ */
 struct udp_mib
 {
  	unsigned long	UdpInDatagrams;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/include/net/tcp.h linux-2.4.22-pre2/include/net/tcp.h
--- linux-2.4.21/include/net/tcp.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/include/net/tcp.h	2003-06-26 21:43:12.000000000 +0000
@@ -600,19 +600,19 @@
  * and worry about wraparound (automatic with unsigned arithmetic).
  */
 
-extern __inline int before(__u32 seq1, __u32 seq2)
+static inline int before(__u32 seq1, __u32 seq2)
 {
         return (__s32)(seq1-seq2) < 0;
 }
 
-extern __inline int after(__u32 seq1, __u32 seq2)
+static inline int after(__u32 seq1, __u32 seq2)
 {
 	return (__s32)(seq2-seq1) < 0;
 }
 
 
 /* is s2<=s1<=s3 ? */
-extern __inline int between(__u32 seq1, __u32 seq2, __u32 seq3)
+static inline int between(__u32 seq1, __u32 seq2, __u32 seq3)
 {
 	return seq3 - seq2 >= seq1 - seq2;
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/init/main.c linux-2.4.22-pre2/init/main.c
--- linux-2.4.21/init/main.c	2002-08-03 00:39:46.000000000 +0000
+++ linux-2.4.22-pre2/init/main.c	2003-06-26 21:43:12.000000000 +0000
@@ -36,6 +36,10 @@
 #include <asm/ccwcache.h>
 #endif
 
+#ifdef CONFIG_ACPI
+#include <linux/acpi.h>
+#endif
+
 #ifdef CONFIG_PCI
 #include <linux/pci.h>
 #endif
@@ -491,7 +495,9 @@
 #if defined(CONFIG_ARCH_S390)
 	s390_init_machine_check();
 #endif
-
+#ifdef CONFIG_ACPI_INTERPRETER
+	acpi_init();
+#endif
 #ifdef CONFIG_PCI
 	pci_init();
 #endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/kernel/ksyms.c linux-2.4.22-pre2/kernel/ksyms.c
--- linux-2.4.21/kernel/ksyms.c	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/kernel/ksyms.c	2003-06-26 21:43:10.000000000 +0000
@@ -48,6 +48,7 @@
 #include <linux/completion.h>
 #include <linux/seq_file.h>
 #include <linux/dnotify.h>
+#include <linux/crc32.h>
 #include <asm/checksum.h>
 
 #if defined(CONFIG_PROC_FS)
@@ -561,6 +562,12 @@
 EXPORT_SYMBOL(strspn);
 EXPORT_SYMBOL(strsep);
 
+#ifdef CONFIG_CRC32
+EXPORT_SYMBOL(crc32_le);
+EXPORT_SYMBOL(crc32_be);
+EXPORT_SYMBOL(bitreverse);
+#endif
+
 /* software interrupts */
 EXPORT_SYMBOL(tasklet_hi_vec);
 EXPORT_SYMBOL(tasklet_vec);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/kernel/sysctl.c linux-2.4.22-pre2/kernel/sysctl.c
--- linux-2.4.21/kernel/sysctl.c	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/kernel/sysctl.c	2003-06-26 21:43:11.000000000 +0000
@@ -90,7 +90,9 @@
 #ifdef CONFIG_PPC32
 extern unsigned long zero_paged_on, powersave_nap;
 int proc_dol2crvec(ctl_table *table, int write, struct file *filp,
-		  void *buffer, size_t *lenp);
+		void *buffer, size_t *lenp);
+int proc_dol3crvec(ctl_table *table, int write, struct file *filp,
+		void *buffer, size_t *lenp);
 #endif
 
 #ifdef CONFIG_BSD_PROCESS_ACCT
@@ -195,6 +197,8 @@
 	 0644, NULL, &proc_dointvec},
 	{KERN_PPC_L2CR, "l2cr", NULL, 0,
 	 0644, NULL, &proc_dol2crvec},
+	{KERN_PPC_L3CR, "l3cr", NULL, 0,
+	 0644, NULL, &proc_dol3crvec},
 #endif
 	{KERN_CTLALTDEL, "ctrl-alt-del", &C_A_D, sizeof(int),
 	 0644, NULL, &proc_dointvec},
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/lib/Config.in linux-2.4.22-pre2/lib/Config.in
--- linux-2.4.21/lib/Config.in	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/lib/Config.in	2003-06-26 21:43:29.000000000 +0000
@@ -4,6 +4,8 @@
 mainmenu_option next_comment
 comment 'Library routines'
 
+tristate 'CRC32 functions' CONFIG_CRC32
+
 #
 # Do we need the compression support?
 #
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/lib/Makefile linux-2.4.22-pre2/lib/Makefile
--- linux-2.4.21/lib/Makefile	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/lib/Makefile	2003-06-26 21:43:11.000000000 +0000
@@ -1,4 +1,4 @@
-#
+ #
 # Makefile for some libs needed in the kernel.
 #
 # Note! Dependencies are done automagically by 'make dep', which also
@@ -8,7 +8,8 @@
 
 L_TARGET := lib.a
 
-export-objs := cmdline.o dec_and_lock.o rwsem-spinlock.o rwsem.o rbtree.o
+export-objs := cmdline.o dec_and_lock.o rwsem-spinlock.o rwsem.o \
+	       rbtree.o crc32.o
 
 obj-y := errno.o ctype.o string.o vsprintf.o brlock.o cmdline.o \
 	 bust_spinlocks.o rbtree.o dump_stack.o
@@ -20,10 +21,26 @@
   obj-y += dec_and_lock.o
 endif
 
+obj-$(CONFIG_CRC32)     += crc32.o
+
 subdir-$(CONFIG_ZLIB_INFLATE) += zlib_inflate
 subdir-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate
 
+include $(TOPDIR)/drivers/net/Makefile.lib
+include $(TOPDIR)/drivers/usb/Makefile.lib
+include $(TOPDIR)/fs/Makefile.lib
+include $(TOPDIR)/net/bluetooth/bnep/Makefile.lib
+
 # Include the subdirs, if necessary.
 obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o))
 
+
 include $(TOPDIR)/Rules.make
+
+crc32.o: crc32table.h
+
+gen_crc32table: gen_crc32table.c
+	$(HOSTCC) $(HOSTCCFLAGS) -o $@ $<
+
+crc32table.h: gen_crc32table
+	./$< > $@
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/lib/crc32.c linux-2.4.22-pre2/lib/crc32.c
--- linux-2.4.21/lib/crc32.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/lib/crc32.c	2003-06-26 21:43:10.000000000 +0000
@@ -0,0 +1,536 @@
+/* 
+ * Oct 15, 2000 Matt Domsch <Matt_Domsch@dell.com>
+ * Nicer crc32 functions/docs submitted by linux@horizon.com.  Thanks!
+ *
+ * Oct 12, 2000 Matt Domsch <Matt_Domsch@dell.com>
+ * Same crc32 function was used in 5 other places in the kernel.
+ * I made one version, and deleted the others.
+ * There are various incantations of crc32().  Some use a seed of 0 or ~0.
+ * Some xor at the end with ~0.  The generic crc32() function takes
+ * seed as an argument, and doesn't xor at the end.  Then individual
+ * users can do whatever they need.
+ *   drivers/net/smc9194.c uses seed ~0, doesn't xor with ~0.
+ *   fs/jffs2 uses seed 0, doesn't xor with ~0.
+ *   fs/partitions/efi.c uses seed ~0, xor's with ~0.
+ * 
+ */
+
+#include <linux/crc32.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <asm/atomic.h>
+#include "crc32defs.h"
+#if CRC_LE_BITS == 8
+#define tole(x) __constant_cpu_to_le32(x)
+#define tobe(x) __constant_cpu_to_be32(x)
+#else
+#define tole(x) (x)
+#define tobe(x) (x)
+#endif
+#include "crc32table.h"
+
+#if __GNUC__ >= 3	/* 2.x has "attribute", but only 3.0 has "pure */
+#define attribute(x) __attribute__(x)
+#else
+#define attribute(x)
+#endif
+
+/*
+ * This code is in the public domain; copyright abandoned.
+ * Liability for non-performance of this code is limited to the amount
+ * you paid for it.  Since it is distributed for free, your refund will
+ * be very very small.  If it breaks, you get to keep both pieces.
+ */
+
+MODULE_AUTHOR("Matt Domsch <Matt_Domsch@dell.com>");
+MODULE_DESCRIPTION("Ethernet CRC32 calculations");
+MODULE_LICENSE("GPL and additional rights");
+
+#if CRC_LE_BITS == 1
+/*
+ * In fact, the table-based code will work in this case, but it can be
+ * simplified by inlining the table in ?: form.
+ */
+
+/**
+ * crc32_le() - Calculate bitwise little-endian Ethernet AUTODIN II CRC32
+ * @crc - seed value for computation.  ~0 for Ethernet, sometimes 0 for
+ *        other uses, or the previous crc32 value if computing incrementally.
+ * @p   - pointer to buffer over which CRC is run
+ * @len - length of buffer @p
+ * 
+ */
+u32 attribute((pure)) crc32_le(u32 crc, unsigned char const *p, size_t len)
+{
+	int i;
+	while (len--) {
+		crc ^= *p++;
+		for (i = 0; i < 8; i++)
+			crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
+	}
+	return crc;
+}
+#else				/* Table-based approach */
+
+/**
+ * crc32_le() - Calculate bitwise little-endian Ethernet AUTODIN II CRC32
+ * @crc - seed value for computation.  ~0 for Ethernet, sometimes 0 for
+ *        other uses, or the previous crc32 value if computing incrementally.
+ * @p   - pointer to buffer over which CRC is run
+ * @len - length of buffer @p
+ * 
+ */
+u32 attribute((pure)) crc32_le(u32 crc, unsigned char const *p, size_t len)
+{
+# if CRC_LE_BITS == 8
+	const u32      *b =(u32 *)p;
+	const u32      *tab = crc32table_le;
+
+# ifdef __LITTLE_ENDIAN
+#  define DO_CRC(x) crc = tab[ (crc ^ (x)) & 255 ] ^ (crc>>8)
+# else
+#  define DO_CRC(x) crc = tab[ ((crc >> 24) ^ (x)) & 255] ^ (crc<<8)
+# endif
+
+	crc = __cpu_to_le32(crc);
+	/* Align it */
+	if(unlikely(((long)b)&3 && len)){
+		do {
+			DO_CRC(*((u8 *)b)++);
+		} while ((--len) && ((long)b)&3 );
+	}
+	if(likely(len >= 4)){
+		/* load data 32 bits wide, xor data 32 bits wide. */
+		size_t save_len = len & 3;
+	        len = len >> 2;
+		--b; /* use pre increment below(*++b) for speed */
+		do {
+			crc ^= *++b;
+			DO_CRC(0);
+			DO_CRC(0);
+			DO_CRC(0);
+			DO_CRC(0);
+		} while (--len);
+		b++; /* point to next byte(s) */
+		len = save_len;
+	}
+	/* And the last few bytes */
+	if(len){
+		do {
+			DO_CRC(*((u8 *)b)++);
+		} while (--len);
+	}
+
+	return __le32_to_cpu(crc);
+#undef ENDIAN_SHIFT
+#undef DO_CRC
+
+# elif CRC_LE_BITS == 4
+	while (len--) {
+		crc ^= *p++;
+		crc = (crc >> 4) ^ crc32table_le[crc & 15];
+		crc = (crc >> 4) ^ crc32table_le[crc & 15];
+	}
+	return crc;
+# elif CRC_LE_BITS == 2
+	while (len--) {
+		crc ^= *p++;
+		crc = (crc >> 2) ^ crc32table_le[crc & 3];
+		crc = (crc >> 2) ^ crc32table_le[crc & 3];
+		crc = (crc >> 2) ^ crc32table_le[crc & 3];
+		crc = (crc >> 2) ^ crc32table_le[crc & 3];
+	}
+	return crc;
+# endif
+}
+#endif
+
+#if CRC_BE_BITS == 1
+/*
+ * In fact, the table-based code will work in this case, but it can be
+ * simplified by inlining the table in ?: form.
+ */
+
+/**
+ * crc32_be() - Calculate bitwise big-endian Ethernet AUTODIN II CRC32
+ * @crc - seed value for computation.  ~0 for Ethernet, sometimes 0 for
+ *        other uses, or the previous crc32 value if computing incrementally.
+ * @p   - pointer to buffer over which CRC is run
+ * @len - length of buffer @p
+ * 
+ */
+u32 attribute((pure)) crc32_be(u32 crc, unsigned char const *p, size_t len)
+{
+	int i;
+	while (len--) {
+		crc ^= *p++ << 24;
+		for (i = 0; i < 8; i++)
+			crc =
+			    (crc << 1) ^ ((crc & 0x80000000) ? CRCPOLY_BE :
+					  0);
+	}
+	return crc;
+}
+
+#else				/* Table-based approach */
+/**
+ * crc32_be() - Calculate bitwise big-endian Ethernet AUTODIN II CRC32
+ * @crc - seed value for computation.  ~0 for Ethernet, sometimes 0 for
+ *        other uses, or the previous crc32 value if computing incrementally.
+ * @p   - pointer to buffer over which CRC is run
+ * @len - length of buffer @p
+ * 
+ */
+u32 attribute((pure)) crc32_be(u32 crc, unsigned char const *p, size_t len)
+{
+# if CRC_BE_BITS == 8
+	const u32      *b =(u32 *)p;
+	const u32      *tab = crc32table_be;
+
+# ifdef __LITTLE_ENDIAN
+#  define DO_CRC(x) crc = tab[ (crc ^ (x)) & 255 ] ^ (crc>>8)
+# else
+#  define DO_CRC(x) crc = tab[ ((crc >> 24) ^ (x)) & 255] ^ (crc<<8)
+# endif
+
+	crc = __cpu_to_be32(crc);
+	/* Align it */
+	if(unlikely(((long)b)&3 && len)){
+		do {
+			DO_CRC(*((u8 *)b)++);
+		} while ((--len) && ((long)b)&3 );
+	}
+	if(likely(len >= 4)){
+		/* load data 32 bits wide, xor data 32 bits wide. */
+		size_t save_len = len & 3;
+	        len = len >> 2;
+		--b; /* use pre increment below(*++b) for speed */
+		do {
+			crc ^= *++b;
+			DO_CRC(0);
+			DO_CRC(0);
+			DO_CRC(0);
+			DO_CRC(0);
+		} while (--len);
+		b++; /* point to next byte(s) */
+		len = save_len;
+	}
+	/* And the last few bytes */
+	if(len){
+		do {
+			DO_CRC(*((u8 *)b)++);
+		} while (--len);
+	}
+	return __be32_to_cpu(crc);
+#undef ENDIAN_SHIFT
+#undef DO_CRC
+
+# elif CRC_BE_BITS == 4
+	while (len--) {
+		crc ^= *p++ << 24;
+		crc = (crc << 4) ^ crc32table_be[crc >> 28];
+		crc = (crc << 4) ^ crc32table_be[crc >> 28];
+	}
+	return crc;
+# elif CRC_BE_BITS == 2
+	while (len--) {
+		crc ^= *p++ << 24;
+		crc = (crc << 2) ^ crc32table_be[crc >> 30];
+		crc = (crc << 2) ^ crc32table_be[crc >> 30];
+		crc = (crc << 2) ^ crc32table_be[crc >> 30];
+		crc = (crc << 2) ^ crc32table_be[crc >> 30];
+	}
+	return crc;
+# endif
+}
+#endif
+
+u32 bitreverse(u32 x)
+{
+	x = (x >> 16) | (x << 16);
+	x = (x >> 8 & 0x00ff00ff) | (x << 8 & 0xff00ff00);
+	x = (x >> 4 & 0x0f0f0f0f) | (x << 4 & 0xf0f0f0f0);
+	x = (x >> 2 & 0x33333333) | (x << 2 & 0xcccccccc);
+	x = (x >> 1 & 0x55555555) | (x << 1 & 0xaaaaaaaa);
+	return x;
+}
+
+#ifndef CONFIG_CRC32 
+	/* To ensure that this file is pulled in from lib/lib.a if it's
+	   configured in but nothing in-kernel uses it, we export its
+	   symbols from kernel/ksyms.c in the CONFIG_CRC32=y case.
+	   Otherwise (either modular or pulled in by the makefile magic)
+	   we export them from here. */
+EXPORT_SYMBOL(crc32_le);
+EXPORT_SYMBOL(crc32_be);
+EXPORT_SYMBOL(bitreverse);
+#endif
+
+/*
+ * A brief CRC tutorial.
+ *
+ * A CRC is a long-division remainder.  You add the CRC to the message,
+ * and the whole thing (message+CRC) is a multiple of the given
+ * CRC polynomial.  To check the CRC, you can either check that the
+ * CRC matches the recomputed value, *or* you can check that the
+ * remainder computed on the message+CRC is 0.  This latter approach
+ * is used by a lot of hardware implementations, and is why so many
+ * protocols put the end-of-frame flag after the CRC.
+ *
+ * It's actually the same long division you learned in school, except that
+ * - We're working in binary, so the digits are only 0 and 1, and
+ * - When dividing polynomials, there are no carries.  Rather than add and
+ *   subtract, we just xor.  Thus, we tend to get a bit sloppy about
+ *   the difference between adding and subtracting.
+ *
+ * A 32-bit CRC polynomial is actually 33 bits long.  But since it's
+ * 33 bits long, bit 32 is always going to be set, so usually the CRC
+ * is written in hex with the most significant bit omitted.  (If you're
+ * familiar with the IEEE 754 floating-point format, it's the same idea.)
+ *
+ * Note that a CRC is computed over a string of *bits*, so you have
+ * to decide on the endianness of the bits within each byte.  To get
+ * the best error-detecting properties, this should correspond to the
+ * order they're actually sent.  For example, standard RS-232 serial is
+ * little-endian; the most significant bit (sometimes used for parity)
+ * is sent last.  And when appending a CRC word to a message, you should
+ * do it in the right order, matching the endianness.
+ *
+ * Just like with ordinary division, the remainder is always smaller than
+ * the divisor (the CRC polynomial) you're dividing by.  Each step of the
+ * division, you take one more digit (bit) of the dividend and append it
+ * to the current remainder.  Then you figure out the appropriate multiple
+ * of the divisor to subtract to being the remainder back into range.
+ * In binary, it's easy - it has to be either 0 or 1, and to make the
+ * XOR cancel, it's just a copy of bit 32 of the remainder.
+ *
+ * When computing a CRC, we don't care about the quotient, so we can
+ * throw the quotient bit away, but subtract the appropriate multiple of
+ * the polynomial from the remainder and we're back to where we started,
+ * ready to process the next bit.
+ *
+ * A big-endian CRC written this way would be coded like:
+ * for (i = 0; i < input_bits; i++) {
+ * 	multiple = remainder & 0x80000000 ? CRCPOLY : 0;
+ * 	remainder = (remainder << 1 | next_input_bit()) ^ multiple;
+ * }
+ * Notice how, to get at bit 32 of the shifted remainder, we look
+ * at bit 31 of the remainder *before* shifting it.
+ *
+ * But also notice how the next_input_bit() bits we're shifting into
+ * the remainder don't actually affect any decision-making until
+ * 32 bits later.  Thus, the first 32 cycles of this are pretty boring.
+ * Also, to add the CRC to a message, we need a 32-bit-long hole for it at
+ * the end, so we have to add 32 extra cycles shifting in zeros at the
+ * end of every message,
+ *
+ * So the standard trick is to rearrage merging in the next_input_bit()
+ * until the moment it's needed.  Then the first 32 cycles can be precomputed,
+ * and merging in the final 32 zero bits to make room for the CRC can be
+ * skipped entirely.
+ * This changes the code to:
+ * for (i = 0; i < input_bits; i++) {
+ *      remainder ^= next_input_bit() << 31;
+ * 	multiple = (remainder & 0x80000000) ? CRCPOLY : 0;
+ * 	remainder = (remainder << 1) ^ multiple;
+ * }
+ * With this optimization, the little-endian code is simpler:
+ * for (i = 0; i < input_bits; i++) {
+ *      remainder ^= next_input_bit();
+ * 	multiple = (remainder & 1) ? CRCPOLY : 0;
+ * 	remainder = (remainder >> 1) ^ multiple;
+ * }
+ *
+ * Note that the other details of endianness have been hidden in CRCPOLY
+ * (which must be bit-reversed) and next_input_bit().
+ *
+ * However, as long as next_input_bit is returning the bits in a sensible
+ * order, we can actually do the merging 8 or more bits at a time rather
+ * than one bit at a time:
+ * for (i = 0; i < input_bytes; i++) {
+ * 	remainder ^= next_input_byte() << 24;
+ * 	for (j = 0; j < 8; j++) {
+ * 		multiple = (remainder & 0x80000000) ? CRCPOLY : 0;
+ * 		remainder = (remainder << 1) ^ multiple;
+ * 	}
+ * }
+ * Or in little-endian:
+ * for (i = 0; i < input_bytes; i++) {
+ * 	remainder ^= next_input_byte();
+ * 	for (j = 0; j < 8; j++) {
+ * 		multiple = (remainder & 1) ? CRCPOLY : 0;
+ * 		remainder = (remainder << 1) ^ multiple;
+ * 	}
+ * }
+ * If the input is a multiple of 32 bits, you can even XOR in a 32-bit
+ * word at a time and increase the inner loop count to 32.
+ *
+ * You can also mix and match the two loop styles, for example doing the
+ * bulk of a message byte-at-a-time and adding bit-at-a-time processing
+ * for any fractional bytes at the end.
+ *
+ * The only remaining optimization is to the byte-at-a-time table method.
+ * Here, rather than just shifting one bit of the remainder to decide
+ * in the correct multiple to subtract, we can shift a byte at a time.
+ * This produces a 40-bit (rather than a 33-bit) intermediate remainder,
+ * but again the multiple of the polynomial to subtract depends only on
+ * the high bits, the high 8 bits in this case.  
+ *
+ * The multile we need in that case is the low 32 bits of a 40-bit
+ * value whose high 8 bits are given, and which is a multiple of the
+ * generator polynomial.  This is simply the CRC-32 of the given
+ * one-byte message.
+ *
+ * Two more details: normally, appending zero bits to a message which
+ * is already a multiple of a polynomial produces a larger multiple of that
+ * polynomial.  To enable a CRC to detect this condition, it's common to
+ * invert the CRC before appending it.  This makes the remainder of the
+ * message+crc come out not as zero, but some fixed non-zero value.
+ *
+ * The same problem applies to zero bits prepended to the message, and
+ * a similar solution is used.  Instead of starting with a remainder of
+ * 0, an initial remainder of all ones is used.  As long as you start
+ * the same way on decoding, it doesn't make a difference.
+ */
+
+#if UNITTEST
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#if 0				/*Not used at present */
+static void
+buf_dump(char const *prefix, unsigned char const *buf, size_t len)
+{
+	fputs(prefix, stdout);
+	while (len--)
+		printf(" %02x", *buf++);
+	putchar('\n');
+
+}
+#endif
+
+static void bytereverse(unsigned char *buf, size_t len)
+{
+	while (len--) {
+		unsigned char x = *buf;
+		x = (x >> 4) | (x << 4);
+		x = (x >> 2 & 0x33) | (x << 2 & 0xcc);
+		x = (x >> 1 & 0x55) | (x << 1 & 0xaa);
+		*buf++ = x;
+	}
+}
+
+static void random_garbage(unsigned char *buf, size_t len)
+{
+	while (len--)
+		*buf++ = (unsigned char) random();
+}
+
+#if 0				/* Not used at present */
+static void store_le(u32 x, unsigned char *buf)
+{
+	buf[0] = (unsigned char) x;
+	buf[1] = (unsigned char) (x >> 8);
+	buf[2] = (unsigned char) (x >> 16);
+	buf[3] = (unsigned char) (x >> 24);
+}
+#endif
+
+static void store_be(u32 x, unsigned char *buf)
+{
+	buf[0] = (unsigned char) (x >> 24);
+	buf[1] = (unsigned char) (x >> 16);
+	buf[2] = (unsigned char) (x >> 8);
+	buf[3] = (unsigned char) x;
+}
+
+/*
+ * This checks that CRC(buf + CRC(buf)) = 0, and that
+ * CRC commutes with bit-reversal.  This has the side effect
+ * of bytewise bit-reversing the input buffer, and returns
+ * the CRC of the reversed buffer.
+ */
+static u32 test_step(u32 init, unsigned char *buf, size_t len)
+{
+	u32 crc1, crc2;
+	size_t i;
+
+	crc1 = crc32_be(init, buf, len);
+	store_be(crc1, buf + len);
+	crc2 = crc32_be(init, buf, len + 4);
+	if (crc2)
+		printf("\nCRC cancellation fail: 0x%08x should be 0\n",
+		       crc2);
+
+	for (i = 0; i <= len + 4; i++) {
+		crc2 = crc32_be(init, buf, i);
+		crc2 = crc32_be(crc2, buf + i, len + 4 - i);
+		if (crc2)
+			printf("\nCRC split fail: 0x%08x\n", crc2);
+	}
+
+	/* Now swap it around for the other test */
+
+	bytereverse(buf, len + 4);
+	init = bitreverse(init);
+	crc2 = bitreverse(crc1);
+	if (crc1 != bitreverse(crc2))
+		printf("\nBit reversal fail: 0x%08x -> %0x08x -> 0x%08x\n",
+		       crc1, crc2, bitreverse(crc2));
+	crc1 = crc32_le(init, buf, len);
+	if (crc1 != crc2)
+		printf("\nCRC endianness fail: 0x%08x != 0x%08x\n", crc1,
+		       crc2);
+	crc2 = crc32_le(init, buf, len + 4);
+	if (crc2)
+		printf("\nCRC cancellation fail: 0x%08x should be 0\n",
+		       crc2);
+
+	for (i = 0; i <= len + 4; i++) {
+		crc2 = crc32_le(init, buf, i);
+		crc2 = crc32_le(crc2, buf + i, len + 4 - i);
+		if (crc2)
+			printf("\nCRC split fail: 0x%08x\n", crc2);
+	}
+
+	return crc1;
+}
+
+#define SIZE 64
+#define INIT1 0
+#define INIT2 0
+
+int main(void)
+{
+	unsigned char buf1[SIZE + 4];
+	unsigned char buf2[SIZE + 4];
+	unsigned char buf3[SIZE + 4];
+	int i, j;
+	u32 crc1, crc2, crc3;
+
+	for (i = 0; i <= SIZE; i++) {
+		printf("\rTesting length %d...", i);
+		fflush(stdout);
+		random_garbage(buf1, i);
+		random_garbage(buf2, i);
+		for (j = 0; j < i; j++)
+			buf3[j] = buf1[j] ^ buf2[j];
+
+		crc1 = test_step(INIT1, buf1, i);
+		crc2 = test_step(INIT2, buf2, i);
+		/* Now check that CRC(buf1 ^ buf2) = CRC(buf1) ^ CRC(buf2) */
+		crc3 = test_step(INIT1 ^ INIT2, buf3, i);
+		if (crc3 != (crc1 ^ crc2))
+			printf("CRC XOR fail: 0x%08x != 0x%08x ^ 0x%08x\n",
+			       crc3, crc1, crc2);
+	}
+	printf("\nAll test complete.  No failures expected.\n");
+	return 0;
+}
+
+#endif				/* UNITTEST */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/lib/crc32defs.h linux-2.4.22-pre2/lib/crc32defs.h
--- linux-2.4.21/lib/crc32defs.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/lib/crc32defs.h	2003-06-26 21:43:22.000000000 +0000
@@ -0,0 +1,32 @@
+/*
+ * There are multiple 16-bit CRC polynomials in common use, but this is
+ * *the* standard CRC-32 polynomial, first popularized by Ethernet.
+ * x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x^1+x^0
+ */
+#define CRCPOLY_LE 0xedb88320
+#define CRCPOLY_BE 0x04c11db7
+
+/* How many bits at a time to use.  Requires a table of 4<<CRC_xx_BITS bytes. */
+/* For less performance-sensitive, use 4 */
+#ifndef CRC_LE_BITS 
+# define CRC_LE_BITS 8
+#endif
+#ifndef CRC_BE_BITS
+# define CRC_BE_BITS 8
+#endif
+
+/*
+ * Little-endian CRC computation.  Used with serial bit streams sent
+ * lsbit-first.  Be sure to use cpu_to_le32() to append the computed CRC.
+ */
+#if CRC_LE_BITS > 8 || CRC_LE_BITS < 1 || CRC_LE_BITS & CRC_LE_BITS-1
+# error CRC_LE_BITS must be a power of 2 between 1 and 8
+#endif
+
+/*
+ * Big-endian CRC computation.  Used with serial bit streams sent
+ * msbit-first.  Be sure to use cpu_to_be32() to append the computed CRC.
+ */
+#if CRC_BE_BITS > 8 || CRC_BE_BITS < 1 || CRC_BE_BITS & CRC_BE_BITS-1
+# error CRC_BE_BITS must be a power of 2 between 1 and 8
+#endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/lib/gen_crc32table.c linux-2.4.22-pre2/lib/gen_crc32table.c
--- linux-2.4.21/lib/gen_crc32table.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/lib/gen_crc32table.c	2003-06-26 21:43:21.000000000 +0000
@@ -0,0 +1,82 @@
+#include <stdio.h>
+#include "crc32defs.h"
+#include <sys/types.h>
+
+#define ENTRIES_PER_LINE 4
+
+#define LE_TABLE_SIZE (1 << CRC_LE_BITS)
+#define BE_TABLE_SIZE (1 << CRC_BE_BITS)
+
+static u_int32_t crc32table_le[LE_TABLE_SIZE];
+static u_int32_t crc32table_be[BE_TABLE_SIZE];
+
+/**
+ * crc32init_le() - allocate and initialize LE table data
+ *
+ * crc is the crc of the byte i; other entries are filled in based on the
+ * fact that crctable[i^j] = crctable[i] ^ crctable[j].
+ *
+ */
+static void crc32init_le(void)
+{
+	unsigned i, j;
+	u_int32_t crc = 1;
+
+	crc32table_le[0] = 0;
+
+	for (i = 1 << (CRC_LE_BITS - 1); i; i >>= 1) {
+		crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
+		for (j = 0; j < LE_TABLE_SIZE; j += 2 * i)
+			crc32table_le[i + j] = crc ^ crc32table_le[j];
+	}
+}
+
+/**
+ * crc32init_be() - allocate and initialize BE table data
+ */
+static void crc32init_be(void)
+{
+	unsigned i, j;
+	u_int32_t crc = 0x80000000;
+
+	crc32table_be[0] = 0;
+
+	for (i = 1; i < BE_TABLE_SIZE; i <<= 1) {
+		crc = (crc << 1) ^ ((crc & 0x80000000) ? CRCPOLY_BE : 0);
+		for (j = 0; j < i; j++)
+			crc32table_be[i + j] = crc ^ crc32table_be[j];
+	}
+}
+
+static void output_table(u_int32_t table[], int len, char *trans)
+{
+	int i;
+
+	for (i = 0; i < len - 1; i++) {
+		if (i % ENTRIES_PER_LINE == 0)
+			printf("\n");
+		printf("%s(0x%8.8xL), ", trans, table[i]);
+	}
+	printf("%s(0x%8.8xL)\n", trans, table[len - 1]);
+}
+
+int main(int argc, char** argv)
+{
+	printf("/* this file is generated - do not edit */\n\n");
+
+	if (CRC_LE_BITS > 1) {
+		crc32init_le();
+		printf("static const u32 crc32table_le[] = {");
+		output_table(crc32table_le, LE_TABLE_SIZE, "tole");
+		printf("};\n");
+	}
+
+	if (CRC_BE_BITS > 1) {
+		crc32init_be();
+		printf("static const u32 crc32table_be[] = {");
+		output_table(crc32table_be, BE_TABLE_SIZE, "tobe");
+		printf("};\n");
+	}
+
+	return 0;
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/mm/filemap.c linux-2.4.22-pre2/mm/filemap.c
--- linux-2.4.21/mm/filemap.c	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/mm/filemap.c	2003-06-26 21:43:17.000000000 +0000
@@ -123,8 +123,6 @@
  */
 void __remove_inode_page(struct page *page)
 {
-	if (PageDirty(page) && !PageSwapCache(page))
-		BUG();
 	remove_page_from_inode_queue(page);
 	remove_page_from_hash_queue(page);
 }
@@ -1545,6 +1543,12 @@
 	UPDATE_ATIME(inode);
 }
 
+/*
+ * i_sem and i_alloc_sem should be held already.  i_sem may be dropped
+ * later once we've mapped the new IO.  i_alloc_sem is kept until the IO
+ * completes.
+ */
+
 static ssize_t generic_file_direct_IO(int rw, struct file * filp, char * buf, size_t count, loff_t offset)
 {
 	ssize_t retval;
@@ -1699,12 +1703,16 @@
 		retval = 0;
 		if (!count)
 			goto out; /* skip atime */
+		down_read(&inode->i_alloc_sem);
+		down(&inode->i_sem);
 		size = inode->i_size;
 		if (pos < size) {
 			retval = generic_file_direct_IO(READ, filp, buf, count, pos);
 			if (retval > 0)
 				*ppos = pos + retval;
 		}
+		up(&inode->i_sem);
+		up_read(&inode->i_alloc_sem);
 		UPDATE_ATIME(filp->f_dentry->d_inode);
 		goto out;
 	}
@@ -2944,44 +2952,18 @@
 }
 
 /*
- * Write to a file through the page cache. 
- *
- * We currently put everything into the page cache prior to writing it.
- * This is not a problem when writing full pages. With partial pages,
- * however, we first have to read the data into the cache, then
- * dirty the page, and finally schedule it for writing. Alternatively, we
- * could write-through just the portion of data that would go into that
- * page, but that would kill performance for applications that write data
- * line by line, and it's prone to race conditions.
- *
- * Note that this routine doesn't try to keep track of dirty pages. Each
- * file system has to do this all by itself, unfortunately.
- *							okir@monad.swb.de
+ * precheck_file_write():
+ * Check the conditions on a file descriptor prior to beginning a write
+ * on it.  Contains the common precheck code for both buffered and direct
+ * IO.
  */
-ssize_t
-generic_file_write(struct file *file,const char *buf,size_t count, loff_t *ppos)
+static int precheck_file_write(struct file *file, struct inode *inode,
+			       size_t *count, loff_t *ppos)
 {
-	struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
-	struct inode	*inode = mapping->host;
-	unsigned long	limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
-	loff_t		pos;
-	struct page	*page, *cached_page;
-	ssize_t		written;
-	long		status = 0;
 	ssize_t		err;
-	unsigned	bytes;
-
-	if ((ssize_t) count < 0)
-		return -EINVAL;
-
-	if (!access_ok(VERIFY_READ, buf, count))
-		return -EFAULT;
-
-	cached_page = NULL;
-
-	down(&inode->i_sem);
-
-	pos = *ppos;
+	unsigned long	limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
+	loff_t		pos = *ppos;
+	
 	err = -EINVAL;
 	if (pos < 0)
 		goto out;
@@ -2992,11 +2974,9 @@
 		goto out;
 	}
 
-	written = 0;
-
 	/* FIXME: this is for backwards compatibility with 2.4 */
 	if (!S_ISBLK(inode->i_mode) && file->f_flags & O_APPEND)
-		pos = inode->i_size;
+		*ppos = pos = inode->i_size;
 
 	/*
 	 * Check whether we've reached the file size limit.
@@ -3008,23 +2988,23 @@
 			send_sig(SIGXFSZ, current, 0);
 			goto out;
 		}
-		if (pos > 0xFFFFFFFFULL || count > limit - (u32)pos) {
+		if (pos > 0xFFFFFFFFULL || *count > limit - (u32)pos) {
 			/* send_sig(SIGXFSZ, current, 0); */
-			count = limit - (u32)pos;
+			*count = limit - (u32)pos;
 		}
 	}
 
 	/*
 	 *	LFS rule 
 	 */
-	if ( pos + count > MAX_NON_LFS && !(file->f_flags&O_LARGEFILE)) {
+	if ( pos + *count > MAX_NON_LFS && !(file->f_flags&O_LARGEFILE)) {
 		if (pos >= MAX_NON_LFS) {
 			send_sig(SIGXFSZ, current, 0);
 			goto out;
 		}
-		if (count > MAX_NON_LFS - (u32)pos) {
+		if (*count > MAX_NON_LFS - (u32)pos) {
 			/* send_sig(SIGXFSZ, current, 0); */
-			count = MAX_NON_LFS - (u32)pos;
+			*count = MAX_NON_LFS - (u32)pos;
 		}
 	}
 
@@ -3041,7 +3021,7 @@
 	if (!S_ISBLK(inode->i_mode)) {
 		if (pos >= inode->i_sb->s_maxbytes)
 		{
-			if (count || pos > inode->i_sb->s_maxbytes) {
+			if (*count || pos > inode->i_sb->s_maxbytes) {
 				send_sig(SIGXFSZ, current, 0);
 				err = -EFBIG;
 				goto out;
@@ -3049,35 +3029,71 @@
 			/* zero-length writes at ->s_maxbytes are OK */
 		}
 
-		if (pos + count > inode->i_sb->s_maxbytes)
-			count = inode->i_sb->s_maxbytes - pos;
+		if (pos + *count > inode->i_sb->s_maxbytes)
+			*count = inode->i_sb->s_maxbytes - pos;
 	} else {
 		if (is_read_only(inode->i_rdev)) {
 			err = -EPERM;
 			goto out;
 		}
 		if (pos >= inode->i_size) {
-			if (count || pos > inode->i_size) {
+			if (*count || pos > inode->i_size) {
 				err = -ENOSPC;
 				goto out;
 			}
 		}
 
-		if (pos + count > inode->i_size)
-			count = inode->i_size - pos;
+		if (pos + *count > inode->i_size)
+			*count = inode->i_size - pos;
 	}
 
 	err = 0;
-	if (count == 0)
+	if (*count == 0)
 		goto out;
 
 	remove_suid(inode);
 	inode->i_ctime = inode->i_mtime = CURRENT_TIME;
 	mark_inode_dirty_sync(inode);
+	
+out:
+	return err;
+}
 
-	if (file->f_flags & O_DIRECT)
-		goto o_direct;
+/*
+ * Write to a file through the page cache. 
+ *
+ * We currently put everything into the page cache prior to writing it.
+ * This is not a problem when writing full pages. With partial pages,
+ * however, we first have to read the data into the cache, then
+ * dirty the page, and finally schedule it for writing. Alternatively, we
+ * could write-through just the portion of data that would go into that
+ * page, but that would kill performance for applications that write data
+ * line by line, and it's prone to race conditions.
+ *
+ * Note that this routine doesn't try to keep track of dirty pages. Each
+ * file system has to do this all by itself, unfortunately.
+ *							okir@monad.swb.de
+ */
+ssize_t
+do_generic_file_write(struct file *file,const char *buf,size_t count, loff_t *ppos)
+{
+	struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
+	struct inode	*inode = mapping->host;
+	loff_t		pos;
+	struct page	*page, *cached_page;
+	ssize_t		written;
+	long		status = 0;
+	int		err;
+	unsigned	bytes;
 
+	cached_page = NULL;
+	pos = *ppos;
+	written = 0;
+	
+	err = precheck_file_write(file, inode, &count, &pos);
+	if (err != 0 || count == 0)
+		goto out;
+	
 	do {
 		unsigned long index, offset;
 		long page_fault;
@@ -3155,11 +3171,9 @@
 			status = generic_osync_inode(inode, OSYNC_METADATA|OSYNC_DATA);
 	}
 	
-out_status:	
 	err = written ? written : status;
 out:
 
-	up(&inode->i_sem);
 	return err;
 fail_write:
 	status = -EFAULT;
@@ -3176,8 +3190,28 @@
 	if (pos + bytes > inode->i_size)
 		vmtruncate(inode, inode->i_size);
 	goto done;
+}
+
+ssize_t
+do_generic_direct_write(struct file *file,const char *buf,size_t count, loff_t *ppos)
+{
+	struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
+	struct inode	*inode = mapping->host;
+	loff_t		pos;
+	ssize_t		written;
+	long		status = 0;
+	int		err;
+
+	pos = *ppos;
+	written = 0;
+	
+	err = precheck_file_write(file, inode, &count, &pos);
+	if (err != 0 || count == 0)
+		goto out;
+	
+	if (!file->f_flags & O_DIRECT)
+		BUG();
 
-o_direct:
 	written = generic_file_direct_IO(WRITE, file, (char *) buf, count, pos);
 	if (written > 0) {
 		loff_t end = pos + written;
@@ -3194,7 +3228,57 @@
 	 */
 	if (written >= 0 && file->f_flags & O_SYNC)
 		status = generic_osync_inode(inode, OSYNC_METADATA);
-	goto out_status;
+
+	err = written ? written : status;
+out:
+	return err;
+}
+
+static int do_odirect_fallback(struct file *file, struct inode *inode,
+			       const char *buf, size_t count, loff_t *ppos)
+{
+	int ret, err;
+
+	down(&inode->i_sem);
+	ret = do_generic_file_write(file, buf, count, ppos);
+	if (ret > 0) {
+		err = do_fdatasync(file);
+		if (err)
+			ret = err;
+	}
+	up(&inode->i_sem);
+	return ret;
+}
+
+ssize_t
+generic_file_write(struct file *file,const char *buf,size_t count, loff_t *ppos)
+{
+	struct inode	*inode = file->f_dentry->d_inode->i_mapping->host;
+	int		err;
+
+	if ((ssize_t) count < 0)
+		return -EINVAL;
+
+	if (!access_ok(VERIFY_READ, buf, count))
+		return -EFAULT;
+
+	if (file->f_flags & O_DIRECT) {
+		/* do_generic_direct_write may drop i_sem during the
+		   actual IO */
+		down_read(&inode->i_alloc_sem);
+		down(&inode->i_sem);
+		err = do_generic_direct_write(file, buf, count, ppos);
+		up(&inode->i_sem);
+		up_read(&inode->i_alloc_sem);
+		if (unlikely(err == -ENOTBLK))
+			err = do_odirect_fallback(file, inode, buf, count, ppos);
+	} else {
+		down(&inode->i_sem);
+		err = do_generic_file_write(file, buf, count, ppos);
+		up(&inode->i_sem);
+	}
+
+	return err;
 }
 
 void __init page_cache_init(unsigned long mempages)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/README linux-2.4.22-pre2/net/README
--- linux-2.4.21/net/README	2001-12-21 17:42:05.000000000 +0000
+++ linux-2.4.22-pre2/net/README	1970-01-01 00:00:00.000000000 +0000
@@ -1,26 +0,0 @@
-
-Maintainers and developers for networking code sections
-
-Code Section		Bug Report Contact
--------------------+-------------------------------------------
-802 [other	]	alan@lxorguk.ukuu.org.uk	
-    [token ring	]	p.norton@computer.org
-appletalk		jschlst@samba.org
-ax25			g4klx@g4klx.demon.co.uk
-bridge			buytenh@gnu.org
-core			alan@lxorguk.ukuu.org.uk
-decnet			SteveW@ACM.org
-ethernet		alan@lxorguk.ukuu.org.uk
-ipv4			davem@caip.rutgers.edu,Eric.Schenk@dna.lth.se
-ipv6			davem@caip.rutgers.edu,Eric.Schenk@dna.lth.se
-ipx			acme@conectiva.com.br
-spx			jschlst@samba.org
-irda                    dagb@cs.uit.no
-lapb			g4klx@g4klx.demon.co.uk
-netrom			g4klx@g4klx.demon.co.uk
-rose			g4klx@g4klx.demon.co.uk
-wanrouter		gene@compuserve.com, jaspreet@sangoma and dm@sangoma.com
-unix			alan@lxorguk.ukuu.org.uk
-x25			g4klx@g4klx.demon.co.uk
-bluetooth		maxk@qualcomm.com
-8021q                   greearb@candelatech.com, vlan@scry.wanfear.com
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/atm/common.c linux-2.4.22-pre2/net/atm/common.c
--- linux-2.4.21/net/atm/common.c	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/net/atm/common.c	2003-06-26 21:43:34.000000000 +0000
@@ -292,7 +292,7 @@
 	if (vpi != ATM_VPI_UNSPEC && vci != ATM_VCI_UNSPEC)
 		clear_bit(ATM_VF_PARTIAL,&vcc->flags);
 	else if (test_bit(ATM_VF_PARTIAL,&vcc->flags)) return -EINVAL;
-	printk(KERN_DEBUG "atm_connect (TX: cl %d,bw %d-%d,sdu %d; "
+	DPRINTK("atm_connect (TX: cl %d,bw %d-%d,sdu %d; "
 	    "RX: cl %d,bw %d-%d,sdu %d,AAL %s%d)\n",
 	    vcc->qos.txtp.traffic_class,vcc->qos.txtp.min_pcr,
 	    vcc->qos.txtp.max_pcr,vcc->qos.txtp.max_sdu,
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/atm/lec.c linux-2.4.22-pre2/net/atm/lec.c
--- linux-2.4.21/net/atm/lec.c	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/net/atm/lec.c	2003-06-26 21:43:11.000000000 +0000
@@ -283,7 +283,7 @@
 #endif
         min_frame_size = LEC_MINIMUM_8023_SIZE;
         if (skb->len < min_frame_size) {
-                if (skb->truesize < min_frame_size) {
+                if ((skb->len + skb_tailroom(skb)) < min_frame_size) {
                         skb2 = skb_copy_expand(skb, 0,
                             min_frame_size - skb->truesize, GFP_ATOMIC);
                                 dev_kfree_skb(skb);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/atm/svc.c linux-2.4.22-pre2/net/atm/svc.c
--- linux-2.4.21/net/atm/svc.c	2001-04-12 19:11:39.000000000 +0000
+++ linux-2.4.22-pre2/net/atm/svc.c	2003-06-26 21:43:29.000000000 +0000
@@ -65,8 +65,8 @@
 
 	DPRINTK("svc_disconnect %p\n",vcc);
 	if (test_bit(ATM_VF_REGIS,&vcc->flags)) {
-		sigd_enq(vcc,as_close,NULL,NULL,NULL);
 		add_wait_queue(&vcc->sleep,&wait);
+		sigd_enq(vcc,as_close,NULL,NULL,NULL);
 		while (!test_bit(ATM_VF_RELEASED,&vcc->flags) && sigd) {
 			set_current_state(TASK_UNINTERRUPTIBLE);
 			schedule();
@@ -125,8 +125,8 @@
 	if (!test_bit(ATM_VF_HASQOS,&vcc->flags)) return -EBADFD;
 	vcc->local = *addr;
 	vcc->reply = WAITING;
-	sigd_enq(vcc,as_bind,NULL,NULL,&vcc->local);
 	add_wait_queue(&vcc->sleep,&wait);
+	sigd_enq(vcc,as_bind,NULL,NULL,&vcc->local);
 	while (vcc->reply == WAITING && sigd) {
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule();
@@ -170,12 +170,13 @@
 		    !vcc->qos.rxtp.traffic_class) return -EINVAL;
 		vcc->remote = *addr;
 		vcc->reply = WAITING;
+		add_wait_queue(&vcc->sleep,&wait);
 		sigd_enq(vcc,as_connect,NULL,NULL,&vcc->remote);
 		if (flags & O_NONBLOCK) {
+			remove_wait_queue(&vcc->sleep,&wait);
 			sock->state = SS_CONNECTING;
 			return -EINPROGRESS;
 		}
-		add_wait_queue(&vcc->sleep,&wait);
 		error = 0;
 		while (vcc->reply == WAITING && sigd) {
 			set_current_state(TASK_INTERRUPTIBLE);
@@ -244,8 +245,8 @@
 	/* let server handle listen on unbound sockets */
 	if (test_bit(ATM_VF_SESSION,&vcc->flags)) return -EINVAL;
 	vcc->reply = WAITING;
-	sigd_enq(vcc,as_listen,NULL,NULL,&vcc->local);
 	add_wait_queue(&vcc->sleep,&wait);
+	sigd_enq(vcc,as_listen,NULL,NULL,&vcc->local);
 	while (vcc->reply == WAITING && sigd) {
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule();
@@ -314,8 +315,8 @@
 		}
 		/* wait should be short, so we ignore the non-blocking flag */
 		new_vcc->reply = WAITING;
-		sigd_enq(new_vcc,as_accept,old_vcc,NULL,NULL);
 		add_wait_queue(&new_vcc->sleep,&wait);
+		sigd_enq(new_vcc,as_accept,old_vcc,NULL,NULL);
 		while (new_vcc->reply == WAITING && sigd) {
 			set_current_state(TASK_UNINTERRUPTIBLE);
 			schedule();
@@ -348,8 +349,8 @@
 	DECLARE_WAITQUEUE(wait,current);
 
 	vcc->reply = WAITING;
-	sigd_enq2(vcc,as_modify,NULL,NULL,&vcc->local,qos,0);
 	add_wait_queue(&vcc->sleep,&wait);
+	sigd_enq2(vcc,as_modify,NULL,NULL,&vcc->local,qos,0);
 	while (vcc->reply == WAITING && !test_bit(ATM_VF_RELEASED,&vcc->flags)
 	    && sigd) {
 		set_current_state(TASK_UNINTERRUPTIBLE);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ax25/ax25_ip.c linux-2.4.22-pre2/net/ax25/ax25_ip.c
--- linux-2.4.21/net/ax25/ax25_ip.c	2001-10-12 21:22:49.000000000 +0000
+++ linux-2.4.22-pre2/net/ax25/ax25_ip.c	2003-06-26 21:43:17.000000000 +0000
@@ -160,9 +160,15 @@
 				skb_set_owner_w(ourskb, skb->sk);
 
 			kfree_skb(skb);
-
-			src_c = *src;
-			dst_c = *dst;
+			/* dl9sau: bugfix
+			 * after kfree_skb(), dst and src which were pointer
+			 * to bp which is part of skb->data would not be valid
+			 * anymore hope that after skb_pull(ourskb, ..) our
+			 * dsc_c and src_c will not become invalid
+			 */
+			bp  = ourskb->data;
+			dst_c = *(ax25_address *)(bp + 1);
+			src_c = *(ax25_address *)(bp + 8);
 
 			skb_pull(ourskb, AX25_HEADER_LEN - 1);	/* Keep PID */
 			ourskb->nh.raw = ourskb->data;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ax25/ax25_out.c linux-2.4.22-pre2/net/ax25/ax25_out.c
--- linux-2.4.21/net/ax25/ax25_out.c	2000-12-29 22:35:47.000000000 +0000
+++ linux-2.4.22-pre2/net/ax25/ax25_out.c	2003-06-26 21:43:15.000000000 +0000
@@ -138,7 +138,7 @@
 	struct sk_buff *skbn;
 	unsigned char *p;
 	int frontlen, len, fragno, ka9qfrag, first = 1;
-	long flags;
+	unsigned long flags;
 
 	if ((skb->len - 1) > paclen) {
 		if (*skb->data == AX25_P_TEXT) {
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/Config.in linux-2.4.22-pre2/net/bluetooth/Config.in
--- linux-2.4.21/net/bluetooth/Config.in	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/Config.in	2003-06-26 21:43:29.000000000 +0000
@@ -13,6 +13,7 @@
       dep_tristate 'SCO links support' CONFIG_BLUEZ_SCO $CONFIG_BLUEZ
       source net/bluetooth/rfcomm/Config.in
       source net/bluetooth/bnep/Config.in
+      source net/bluetooth/cmtp/Config.in
       source drivers/bluetooth/Config.in
    fi
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/Makefile linux-2.4.22-pre2/net/bluetooth/Makefile
--- linux-2.4.21/net/bluetooth/Makefile	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/Makefile	2003-06-26 21:43:12.000000000 +0000
@@ -15,6 +15,7 @@
 
 subdir-$(CONFIG_BLUEZ_RFCOMM) += rfcomm
 subdir-$(CONFIG_BLUEZ_BNEP) += bnep
+subdir-$(CONFIG_BLUEZ_CMTP) += cmtp
 
 ifeq ($(CONFIG_BLUEZ_RFCOMM),y)
 obj-y += rfcomm/rfcomm.o
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/af_bluetooth.c linux-2.4.22-pre2/net/bluetooth/af_bluetooth.c
--- linux-2.4.21/net/bluetooth/af_bluetooth.c	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/af_bluetooth.c	2003-06-26 21:43:13.000000000 +0000
@@ -27,7 +27,7 @@
  *
  * $Id: af_bluetooth.c,v 1.8 2002/07/22 20:32:54 maxk Exp $
  */
-#define VERSION "2.2"
+#define VERSION "2.3"
 
 #include <linux/config.h>
 #include <linux/module.h>
@@ -57,7 +57,7 @@
 #endif
 
 /* Bluetooth sockets */
-#define BLUEZ_MAX_PROTO	5
+#define BLUEZ_MAX_PROTO	6
 static struct net_proto_family *bluez_proto[BLUEZ_MAX_PROTO];
 
 int bluez_sock_register(int proto, struct net_proto_family *ops)
@@ -253,39 +253,35 @@
 	return mask;
 }
 
-int bluez_sock_w4_connect(struct sock *sk, int flags)
+int bluez_sock_wait_state(struct sock *sk, int state, unsigned long timeo)
 {
 	DECLARE_WAITQUEUE(wait, current);
-	long timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);
 	int err = 0;
 
 	BT_DBG("sk %p", sk);
 
 	add_wait_queue(sk->sleep, &wait);
-	while (sk->state != BT_CONNECTED) {
+	while (sk->state != state) {
 		set_current_state(TASK_INTERRUPTIBLE);
+
 		if (!timeo) {
 			err = -EAGAIN;
 			break;
 		}
 
+		if (signal_pending(current)) {
+			err = sock_intr_errno(timeo);
+			break;
+		}
+
 		release_sock(sk);
 		timeo = schedule_timeout(timeo);
 		lock_sock(sk);
 
-		err = 0;
-		if (sk->state == BT_CONNECTED)
-			break;
-
 		if (sk->err) {
 			err = sock_error(sk);
 			break;
 		}
-
-		if (signal_pending(current)) {
-			err = sock_intr_errno(timeo);
-			break;
-		}
 	}
 	set_current_state(TASK_RUNNING);
 	remove_wait_queue(sk->sleep, &wait);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/bnep/Makefile linux-2.4.22-pre2/net/bluetooth/bnep/Makefile
--- linux-2.4.21/net/bluetooth/bnep/Makefile	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/bnep/Makefile	2003-06-26 21:43:28.000000000 +0000
@@ -4,7 +4,7 @@
 
 O_TARGET := bnep.o
 
-obj-y	 := core.o sock.o netdev.o crc32.o
+obj-y	 := core.o sock.o netdev.o
 obj-m    += $(O_TARGET)
 
 include $(TOPDIR)/Rules.make
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/bnep/Makefile.lib linux-2.4.22-pre2/net/bluetooth/bnep/Makefile.lib
--- linux-2.4.21/net/bluetooth/bnep/Makefile.lib	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/bnep/Makefile.lib	2003-06-26 21:43:12.000000000 +0000
@@ -0,0 +1 @@
+obj-$(CONFIG_BLUEZ_BNEP) += crc32.o
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/bnep/bnep.h linux-2.4.22-pre2/net/bluetooth/bnep/bnep.h
--- linux-2.4.21/net/bluetooth/bnep/bnep.h	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/bnep/bnep.h	2003-06-26 21:43:33.000000000 +0000
@@ -26,7 +26,7 @@
 #include <linux/types.h>
 #include <net/bluetooth/bluetooth.h>
 
-#include "crc32.h"
+#include <linux/crc32.h>
 
 // Limits
 #define BNEP_MAX_PROTO_FILTERS     5
@@ -179,7 +179,7 @@
 
 static inline int bnep_mc_hash(__u8 *addr)
 {
-        return (bnep_crc32(~0, addr, ETH_ALEN) >> 26);
+        return (crc32_be(~0, addr, ETH_ALEN) >> 26);
 }
 
 #endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/bnep/core.c linux-2.4.22-pre2/net/bluetooth/bnep/core.c
--- linux-2.4.21/net/bluetooth/bnep/core.c	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/bnep/core.c	2003-06-26 21:43:33.000000000 +0000
@@ -680,7 +680,6 @@
 
 static int __init bnep_init_module(void)
 {
-	bnep_crc32_init();
 	bnep_sock_init();
 
 	BT_INFO("BlueZ BNEP ver %s", VERSION);
@@ -695,7 +694,6 @@
 static void __exit bnep_cleanup_module(void)
 {
 	bnep_sock_cleanup();
-	bnep_crc32_cleanup();
 }
 
 module_init(bnep_init_module);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/bnep/crc32.c linux-2.4.22-pre2/net/bluetooth/bnep/crc32.c
--- linux-2.4.21/net/bluetooth/bnep/crc32.c	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/bnep/crc32.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,59 +0,0 @@
-/* 
- * Based on linux-2.5/lib/crc32 by Matt Domsch <Matt_Domsch@dell.com>
- *
- * FIXME: Remove in 2.5  
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/init.h>
-#include <asm/atomic.h>
-
-#include "crc32.h"
-
-#define CRCPOLY_BE 0x04c11db7
-#define CRC_BE_BITS 8
-
-static u32 *bnep_crc32_table;
-
-/*
- * This code is in the public domain; copyright abandoned.
- * Liability for non-performance of this code is limited to the amount
- * you paid for it.  Since it is distributed for free, your refund will
- * be very very small.  If it breaks, you get to keep both pieces.
- */
-u32 bnep_crc32(u32 crc, unsigned char const *p, size_t len)
-{
-	while (len--)
-		crc = (crc << 8) ^ bnep_crc32_table[(crc >> 24) ^ *p++];
-	
-	return crc;
-}
-
-int __init bnep_crc32_init(void)
-{
-	unsigned i, j;
-	u32 crc = 0x80000000;
-
-	bnep_crc32_table = kmalloc((1 << CRC_BE_BITS) * sizeof(u32), GFP_KERNEL);
-	if (!bnep_crc32_table)
-		return -ENOMEM;
-
-	bnep_crc32_table[0] = 0;
-
-	for (i = 1; i < 1 << CRC_BE_BITS; i <<= 1) {
-		crc = (crc << 1) ^ ((crc & 0x80000000) ? CRCPOLY_BE : 0);
-		for (j = 0; j < i; j++)
-			bnep_crc32_table[i + j] = crc ^ bnep_crc32_table[j];
-	}
-	return 0;
-}
-
-void __exit bnep_crc32_cleanup(void)
-{
-	if (bnep_crc32_table)
-		kfree(bnep_crc32_table);
-	bnep_crc32_table = NULL;
-}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/bnep/crc32.h linux-2.4.22-pre2/net/bluetooth/bnep/crc32.h
--- linux-2.4.21/net/bluetooth/bnep/crc32.h	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/bnep/crc32.h	1970-01-01 00:00:00.000000000 +0000
@@ -1,10 +0,0 @@
-/*
- * crc32.h
- * See crc32.c for license and changes
- *
- * FIXME: Remove in 2.5
- */
-
-int  bnep_crc32_init(void);
-void bnep_crc32_cleanup(void);
-u32  bnep_crc32(u32 crc, unsigned char const *p, size_t len);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/cmtp/Config.in linux-2.4.22-pre2/net/bluetooth/cmtp/Config.in
--- linux-2.4.21/net/bluetooth/cmtp/Config.in	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/cmtp/Config.in	2003-06-26 21:43:18.000000000 +0000
@@ -0,0 +1,6 @@
+#
+# Bluetooth CMTP layer configuration
+#
+
+dep_tristate 'CMTP protocol support' CONFIG_BLUEZ_CMTP $CONFIG_BLUEZ_L2CAP
+
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/cmtp/Makefile linux-2.4.22-pre2/net/bluetooth/cmtp/Makefile
--- linux-2.4.21/net/bluetooth/cmtp/Makefile	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/cmtp/Makefile	2003-06-26 21:43:27.000000000 +0000
@@ -0,0 +1,10 @@
+#
+# Makefile for the Linux Bluetooth CMTP layer
+#
+
+O_TARGET := cmtp.o
+
+obj-y	:= core.o sock.o capi.o
+obj-m	+= $(O_TARGET)
+
+include $(TOPDIR)/Rules.make
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/cmtp/capi.c linux-2.4.22-pre2/net/bluetooth/cmtp/capi.c
--- linux-2.4.21/net/bluetooth/cmtp/capi.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/cmtp/capi.c	2003-06-26 21:43:33.000000000 +0000
@@ -0,0 +1,707 @@
+/* 
+   CMTP implementation for Linux Bluetooth stack (BlueZ).
+   Copyright (C) 2002-2003 Marcel Holtmann <marcel@holtmann.org>
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License version 2 as
+   published by the Free Software Foundation;
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
+   IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   SOFTWARE IS DISCLAIMED.
+*/
+
+#include <linux/config.h>
+#include <linux/module.h>
+
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/major.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/poll.h>
+#include <linux/fcntl.h>
+#include <linux/skbuff.h>
+#include <linux/socket.h>
+#include <linux/ioctl.h>
+#include <linux/file.h>
+#include <net/sock.h>
+
+#include <linux/capi.h>
+
+#include "../drivers/isdn/avmb1/capilli.h"
+#include "../drivers/isdn/avmb1/capicmd.h"
+#include "../drivers/isdn/avmb1/capiutil.h"
+
+#include "cmtp.h"
+
+#ifndef CONFIG_BLUEZ_CMTP_DEBUG
+#undef  BT_DBG
+#define BT_DBG(D...)
+#endif
+
+#define REVISION "1.0"
+
+#define CAPI_INTEROPERABILITY		0x20
+
+#define CAPI_INTEROPERABILITY_REQ	CAPICMD(CAPI_INTEROPERABILITY, CAPI_REQ)
+#define CAPI_INTEROPERABILITY_CONF	CAPICMD(CAPI_INTEROPERABILITY, CAPI_CONF)
+#define CAPI_INTEROPERABILITY_IND	CAPICMD(CAPI_INTEROPERABILITY, CAPI_IND)
+#define CAPI_INTEROPERABILITY_RESP	CAPICMD(CAPI_INTEROPERABILITY, CAPI_RESP)
+
+#define CAPI_INTEROPERABILITY_REQ_LEN	(CAPI_MSG_BASELEN + 2)
+#define CAPI_INTEROPERABILITY_CONF_LEN	(CAPI_MSG_BASELEN + 4)
+#define CAPI_INTEROPERABILITY_IND_LEN	(CAPI_MSG_BASELEN + 2)
+#define CAPI_INTEROPERABILITY_RESP_LEN	(CAPI_MSG_BASELEN + 2)
+
+#define CAPI_FUNCTION_REGISTER		0
+#define CAPI_FUNCTION_RELEASE		1
+#define CAPI_FUNCTION_GET_PROFILE	2
+#define CAPI_FUNCTION_GET_MANUFACTURER	3
+#define CAPI_FUNCTION_GET_VERSION	4
+#define CAPI_FUNCTION_GET_SERIAL_NUMBER	5
+#define CAPI_FUNCTION_MANUFACTURER	6
+#define CAPI_FUNCTION_LOOPBACK		7
+
+static struct capi_driver_interface *di;
+
+
+#define CMTP_MSGNUM	1
+#define CMTP_APPLID	2
+#define CMTP_MAPPING	3
+
+static struct cmtp_application *cmtp_application_add(struct cmtp_session *session, __u16 appl)
+{
+	struct cmtp_application *app = kmalloc(sizeof(*app), GFP_KERNEL);
+
+	BT_DBG("session %p application %p appl %d", session, app, appl);
+
+	if (!app)
+		return NULL;
+
+	memset(app, 0, sizeof(*app));
+
+	app->state = BT_OPEN;
+	app->appl = appl;
+
+	list_add_tail(&app->list, &session->applications);
+
+	return app;
+}
+
+static void cmtp_application_del(struct cmtp_session *session, struct cmtp_application *app)
+{
+	BT_DBG("session %p application %p", session, app);
+
+	if (app) {
+		list_del(&app->list);
+		kfree(app);
+	}
+}
+
+static struct cmtp_application *cmtp_application_get(struct cmtp_session *session, int pattern, __u16 value)
+{
+	struct cmtp_application *app;
+	struct list_head *p, *n;
+
+	list_for_each_safe(p, n, &session->applications) {
+		app = list_entry(p, struct cmtp_application, list);
+		switch (pattern) {
+		case CMTP_MSGNUM:
+			if (app->msgnum == value)
+				return app;
+			break;
+		case CMTP_APPLID:
+			if (app->appl == value)
+				return app;
+			break;
+		case CMTP_MAPPING:
+			if (app->mapping == value)
+				return app;
+			break;
+		}
+	}
+
+	return NULL;
+}
+
+static int cmtp_msgnum_get(struct cmtp_session *session)
+{
+	session->msgnum++;
+
+	if ((session->msgnum & 0xff) > 200)
+		session->msgnum = CMTP_INITIAL_MSGNUM + 1;
+
+	return session->msgnum;
+}
+
+
+static void cmtp_send_interopmsg(struct cmtp_session *session,
+					__u8 subcmd, __u16 appl, __u16 msgnum,
+					__u16 function, unsigned char *buf, int len)
+{
+	struct sk_buff *skb;
+	unsigned char *s;
+
+	BT_DBG("session %p subcmd 0x%02x appl %d msgnum %d", session, subcmd, appl, msgnum);
+
+	if (!(skb = alloc_skb(CAPI_MSG_BASELEN + 6 + len, GFP_ATOMIC))) {
+		BT_ERR("Can't allocate memory for interoperability packet");
+		return;
+	}
+
+	s = skb_put(skb, CAPI_MSG_BASELEN + 6 + len);
+
+	capimsg_setu16(s, 0, CAPI_MSG_BASELEN + 6 + len);
+	capimsg_setu16(s, 2, appl);
+	capimsg_setu8 (s, 4, CAPI_INTEROPERABILITY);
+	capimsg_setu8 (s, 5, subcmd);
+	capimsg_setu16(s, 6, msgnum);
+
+	/* Interoperability selector (Bluetooth Device Management) */
+	capimsg_setu16(s, 8, 0x0001);
+
+	capimsg_setu8 (s, 10, 3 + len);
+	capimsg_setu16(s, 11, function);
+	capimsg_setu8 (s, 13, len);
+
+	if (len > 0)
+		memcpy(s + 14, buf, len);
+
+	cmtp_send_capimsg(session, skb);
+}
+
+static void cmtp_recv_interopmsg(struct cmtp_session *session, struct sk_buff *skb)
+{
+	struct capi_ctr *ctrl = session->ctrl;
+	struct cmtp_application *application;
+	__u16 appl, msgnum, func, info;
+	__u32 controller;
+
+	BT_DBG("session %p skb %p len %d", session, skb, skb->len);
+
+	switch (CAPIMSG_SUBCOMMAND(skb->data)) {
+	case CAPI_CONF:
+		func = CAPIMSG_U16(skb->data, CAPI_MSG_BASELEN + 5);
+		info = CAPIMSG_U16(skb->data, CAPI_MSG_BASELEN + 8);
+
+		switch (func) {
+		case CAPI_FUNCTION_REGISTER:
+			msgnum = CAPIMSG_MSGID(skb->data);
+
+			application = cmtp_application_get(session, CMTP_MSGNUM, msgnum);
+			if (application) {
+				application->state = BT_CONNECTED;
+				application->msgnum = 0;
+				application->mapping = CAPIMSG_APPID(skb->data);
+				wake_up_interruptible(&session->wait);
+			}
+
+			break;
+
+		case CAPI_FUNCTION_RELEASE:
+			appl = CAPIMSG_APPID(skb->data);
+
+			application = cmtp_application_get(session, CMTP_MAPPING, appl);
+			if (application) {
+				application->state = BT_CLOSED;
+				application->msgnum = 0;
+				wake_up_interruptible(&session->wait);
+			}
+
+			break;
+
+		case CAPI_FUNCTION_GET_PROFILE:
+			controller = CAPIMSG_U16(skb->data, CAPI_MSG_BASELEN + 11);
+			msgnum = CAPIMSG_MSGID(skb->data);
+
+			if (!info && (msgnum == CMTP_INITIAL_MSGNUM)) {
+				session->ncontroller = controller;
+				wake_up_interruptible(&session->wait);
+				break;
+			}
+
+			if (!info && ctrl) {
+				memcpy(&ctrl->profile,
+					skb->data + CAPI_MSG_BASELEN + 11,
+					sizeof(capi_profile));
+				session->state = BT_CONNECTED;
+				ctrl->ready(ctrl);
+			}
+
+			break;
+
+		case CAPI_FUNCTION_GET_MANUFACTURER:
+			controller = CAPIMSG_U32(skb->data, CAPI_MSG_BASELEN + 10);
+
+			if (!info && ctrl) {
+				strncpy(ctrl->manu,
+					skb->data + CAPI_MSG_BASELEN + 15,
+					skb->data[CAPI_MSG_BASELEN + 14]);
+			}
+
+			break;
+
+		case CAPI_FUNCTION_GET_VERSION:
+			controller = CAPIMSG_U32(skb->data, CAPI_MSG_BASELEN + 12);
+
+			if (!info && ctrl) {
+				ctrl->version.majorversion = CAPIMSG_U32(skb->data, CAPI_MSG_BASELEN + 16);
+				ctrl->version.minorversion = CAPIMSG_U32(skb->data, CAPI_MSG_BASELEN + 20);
+				ctrl->version.majormanuversion = CAPIMSG_U32(skb->data, CAPI_MSG_BASELEN + 24);
+				ctrl->version.minormanuversion = CAPIMSG_U32(skb->data, CAPI_MSG_BASELEN + 28);
+			}
+
+			break;
+
+		case CAPI_FUNCTION_GET_SERIAL_NUMBER:
+			controller = CAPIMSG_U32(skb->data, CAPI_MSG_BASELEN + 12);
+
+			if (!info && ctrl) {
+				memset(ctrl->serial, 0, CAPI_SERIAL_LEN);
+				strncpy(ctrl->serial,
+					skb->data + CAPI_MSG_BASELEN + 17,
+					skb->data[CAPI_MSG_BASELEN + 16]);
+			}
+
+			break;
+		}
+
+		break;
+
+	case CAPI_IND:
+		func = CAPIMSG_U16(skb->data, CAPI_MSG_BASELEN + 3);
+
+		if (func == CAPI_FUNCTION_LOOPBACK) {
+			appl = CAPIMSG_APPID(skb->data);
+			msgnum = CAPIMSG_MSGID(skb->data);
+			cmtp_send_interopmsg(session, CAPI_RESP, appl, msgnum, func,
+						skb->data + CAPI_MSG_BASELEN + 6,
+						skb->data[CAPI_MSG_BASELEN + 5]);
+		}
+
+		break;
+	}
+
+	kfree_skb(skb);
+}
+
+void cmtp_recv_capimsg(struct cmtp_session *session, struct sk_buff *skb)
+{
+	struct capi_ctr *ctrl = session->ctrl;
+	struct cmtp_application *application;
+	__u16 cmd, appl, info;
+	__u32 ncci, contr;
+
+	BT_DBG("session %p skb %p len %d", session, skb, skb->len);
+
+	if (CAPIMSG_COMMAND(skb->data) == CAPI_INTEROPERABILITY) {
+		cmtp_recv_interopmsg(session, skb);
+		return;
+	}
+
+	if (session->flags & (1 << CMTP_LOOPBACK)) {
+		kfree_skb(skb);
+		return;
+	}
+
+	cmd = CAPICMD(CAPIMSG_COMMAND(skb->data), CAPIMSG_SUBCOMMAND(skb->data));
+	appl = CAPIMSG_APPID(skb->data);
+	contr = CAPIMSG_CONTROL(skb->data);
+
+	application = cmtp_application_get(session, CMTP_MAPPING, appl);
+	if (application) {
+		appl = application->appl;
+		CAPIMSG_SETAPPID(skb->data, appl);
+	} else {
+		BT_ERR("Can't find application with id %d", appl);
+		kfree_skb(skb);
+		return;
+	}
+
+	if ((contr & 0x7f) == 0x01) {
+		contr = (contr & 0xffffff80) | session->num;
+		CAPIMSG_SETCONTROL(skb->data, contr);
+	}
+
+	if (!ctrl) {
+		BT_ERR("Can't find controller %d for message", session->num);
+		kfree_skb(skb);
+		return;
+	}
+
+	switch (cmd) {
+	case CAPI_CONNECT_B3_CONF:
+		ncci = CAPIMSG_NCCI(skb->data);
+		info = CAPIMSG_U16(skb->data, 12);
+
+		BT_DBG("CONNECT_B3_CONF ncci 0x%02x info 0x%02x", ncci, info);
+
+		if (info == 0)
+			ctrl->new_ncci(ctrl, appl, ncci, 8);
+
+		ctrl->handle_capimsg(ctrl, appl, skb);
+		break;
+
+	case CAPI_CONNECT_B3_IND:
+		ncci = CAPIMSG_NCCI(skb->data);
+
+		BT_DBG("CONNECT_B3_IND ncci 0x%02x", ncci);
+
+		ctrl->new_ncci(ctrl, appl, ncci, 8);
+		ctrl->handle_capimsg(ctrl, appl, skb);
+		break;
+
+	case CAPI_DISCONNECT_B3_IND:
+		ncci = CAPIMSG_NCCI(skb->data);
+
+		BT_DBG("DISCONNECT_B3_IND ncci 0x%02x", ncci);
+
+		if (ncci == 0xffffffff)
+			BT_ERR("DISCONNECT_B3_IND with ncci 0xffffffff");
+
+		ctrl->handle_capimsg(ctrl, appl, skb);
+		ctrl->free_ncci(ctrl, appl, ncci);
+		break;
+
+	default:
+		ctrl->handle_capimsg(ctrl, appl, skb);
+		break;
+	}
+}
+
+void cmtp_send_capimsg(struct cmtp_session *session, struct sk_buff *skb)
+{
+	struct cmtp_scb *scb = (void *) skb->cb;
+
+	BT_DBG("session %p skb %p len %d", session, skb, skb->len);
+
+	scb->id = -1;
+	scb->data = (CAPIMSG_COMMAND(skb->data) == CAPI_DATA_B3);
+
+	skb_queue_tail(&session->transmit, skb);
+
+	cmtp_schedule(session);
+}
+
+
+static int cmtp_load_firmware(struct capi_ctr *ctrl, capiloaddata *data)
+{
+	BT_DBG("ctrl %p data %p", ctrl, data);
+
+	return -EIO;
+}
+
+static void cmtp_reset_ctr(struct capi_ctr *ctrl)
+{
+	BT_DBG("ctrl %p", ctrl);
+
+	ctrl->reseted(ctrl);
+}
+
+static void cmtp_remove_ctr(struct capi_ctr *ctrl)
+{
+	struct cmtp_session *session = ctrl->driverdata;
+
+	BT_DBG("ctrl %p", ctrl);
+
+	ctrl->suspend_output(ctrl);
+
+	atomic_inc(&session->terminate);
+	cmtp_schedule(session);
+}
+
+static void cmtp_register_appl(struct capi_ctr *ctrl, __u16 appl, capi_register_params *rp)
+{
+	DECLARE_WAITQUEUE(wait, current);
+	struct cmtp_session *session = ctrl->driverdata;
+	struct cmtp_application *application;
+	unsigned long timeo = CMTP_INTEROP_TIMEOUT;
+	unsigned char buf[8];
+	int err = 0, nconn, want = rp->level3cnt;
+
+	BT_DBG("ctrl %p appl %d level3cnt %d datablkcnt %d datablklen %d",
+		ctrl, appl, rp->level3cnt, rp->datablkcnt, rp->datablklen);
+
+	application = cmtp_application_add(session, appl);
+	if (!application) {
+		BT_ERR("Can't allocate memory for new application");
+		ctrl->appl_released(ctrl, appl);
+		return;
+	}
+
+	if (want < 0)
+		nconn = ctrl->profile.nbchannel * -want;
+	else
+		nconn = want;
+
+	if (nconn == 0)
+		nconn = ctrl->profile.nbchannel;
+
+	capimsg_setu16(buf, 0, nconn);
+	capimsg_setu16(buf, 2, rp->datablkcnt);
+	capimsg_setu16(buf, 4, rp->datablklen);
+
+	application->state = BT_CONFIG;
+	application->msgnum = cmtp_msgnum_get(session);
+
+	cmtp_send_interopmsg(session, CAPI_REQ, 0x0000, application->msgnum,
+				CAPI_FUNCTION_REGISTER, buf, 6);
+
+	add_wait_queue(&session->wait, &wait);
+	while (1) {
+		set_current_state(TASK_INTERRUPTIBLE);
+
+		if (!timeo) {
+			err = -EAGAIN;
+			break;
+		}
+
+		if (application->state == BT_CLOSED) {
+			err = -application->err;
+			break;
+		}
+
+		if (application->state == BT_CONNECTED)
+			break;
+
+		if (signal_pending(current)) {
+			err = -EINTR;
+			break;
+		}
+
+		timeo = schedule_timeout(timeo);
+	}
+	set_current_state(TASK_RUNNING);
+	remove_wait_queue(&session->wait, &wait);
+
+	if (err) {
+		ctrl->appl_released(ctrl, appl);
+		cmtp_application_del(session, application);
+		return;
+	}
+
+	ctrl->appl_registered(ctrl, appl);
+}
+
+static void cmtp_release_appl(struct capi_ctr *ctrl, __u16 appl)
+{
+	DECLARE_WAITQUEUE(wait, current);
+	struct cmtp_session *session = ctrl->driverdata;
+	struct cmtp_application *application;
+	unsigned long timeo = CMTP_INTEROP_TIMEOUT;
+
+	BT_DBG("ctrl %p appl %d", ctrl, appl);
+
+	application = cmtp_application_get(session, CMTP_APPLID, appl);
+	if (!application) {
+		BT_ERR("Can't find application");
+		return;
+	}
+
+	application->msgnum = cmtp_msgnum_get(session);
+
+	cmtp_send_interopmsg(session, CAPI_REQ, application->mapping, application->msgnum,
+				CAPI_FUNCTION_RELEASE, NULL, 0);
+
+	add_wait_queue(&session->wait, &wait);
+	while (timeo) {
+		set_current_state(TASK_INTERRUPTIBLE);
+
+		if (application->state == BT_CLOSED)
+			break;
+
+		if (signal_pending(current))
+			break;
+
+		timeo = schedule_timeout(timeo);
+	}
+	set_current_state(TASK_RUNNING);
+	remove_wait_queue(&session->wait, &wait);
+
+	cmtp_application_del(session, application);
+	ctrl->appl_released(ctrl, appl);
+}
+
+static void cmtp_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
+{
+	struct cmtp_session *session = ctrl->driverdata;
+	struct cmtp_application *application;
+	__u16 appl;
+	__u32 contr;
+
+	BT_DBG("ctrl %p skb %p", ctrl, skb);
+
+	appl = CAPIMSG_APPID(skb->data);
+	contr = CAPIMSG_CONTROL(skb->data);
+
+	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;
+	}
+
+	CAPIMSG_SETAPPID(skb->data, application->mapping);
+
+	if ((contr & 0x7f) == session->num) {
+		contr = (contr & 0xffffff80) | 0x01;
+		CAPIMSG_SETCONTROL(skb->data, contr);
+	}
+
+	cmtp_send_capimsg(session, skb);
+}
+
+static char *cmtp_procinfo(struct capi_ctr *ctrl)
+{
+	return "CAPI Message Transport Protocol";
+}
+
+static int cmtp_ctr_read_proc(char *page, char **start, off_t off, int count, int *eof, struct capi_ctr *ctrl)
+{
+	struct cmtp_session *session = ctrl->driverdata;
+	struct cmtp_application *app;
+	struct list_head *p, *n;
+	int len = 0;
+
+	len += sprintf(page + len, "%s (Revision %s)\n\n", cmtp_procinfo(ctrl), REVISION);
+	len += sprintf(page + len, "addr %s\n", session->name);
+	len += sprintf(page + len, "ctrl %d\n", session->num);
+
+	list_for_each_safe(p, n, &session->applications) {
+		app = list_entry(p, struct cmtp_application, list);
+		len += sprintf(page + len, "appl %d -> %d\n", app->appl, app->mapping);
+	}
+
+	if (off + count >= len)
+		*eof = 1;
+
+	if (len < off)
+		return 0;
+
+	*start = page + off;
+
+	return ((count < len - off) ? count : len - off);
+}
+
+static struct capi_driver cmtp_driver = {
+	name:		"cmtp",
+	revision:	REVISION,
+	load_firmware:	cmtp_load_firmware,
+	reset_ctr:	cmtp_reset_ctr,
+	remove_ctr:	cmtp_remove_ctr,
+	register_appl:	cmtp_register_appl,
+	release_appl:	cmtp_release_appl,
+	send_message:	cmtp_send_message,
+	procinfo:	cmtp_procinfo,
+	ctr_read_proc:	cmtp_ctr_read_proc,
+
+	driver_read_proc:	0,
+	add_card:		0,
+};
+
+
+int cmtp_attach_device(struct cmtp_session *session)
+{
+	DECLARE_WAITQUEUE(wait, current);
+	unsigned long timeo = CMTP_INTEROP_TIMEOUT;
+	unsigned char buf[4];
+
+	BT_DBG("session %p", session);
+
+	capimsg_setu32(buf, 0, 0);
+
+	cmtp_send_interopmsg(session, CAPI_REQ, 0xffff, CMTP_INITIAL_MSGNUM,
+				CAPI_FUNCTION_GET_PROFILE, buf, 4);
+
+	add_wait_queue(&session->wait, &wait);
+	while (timeo) {
+		set_current_state(TASK_INTERRUPTIBLE);
+
+		if (session->ncontroller)
+			break;
+
+		if (signal_pending(current))
+			break;
+
+		timeo = schedule_timeout(timeo);
+	}
+	set_current_state(TASK_RUNNING);
+	remove_wait_queue(&session->wait, &wait);
+
+	BT_INFO("Found %d CAPI controller(s) on device %s", session->ncontroller, session->name);
+
+	if (!timeo)
+		return -ETIMEDOUT;
+
+	if (!session->ncontroller)
+		return -ENODEV;
+
+
+	if (session->ncontroller > 1)
+		BT_INFO("Setting up only CAPI controller 1");
+
+	if (!(session->ctrl = di->attach_ctr(&cmtp_driver, session->name, session))) {
+		BT_ERR("Can't attach new controller");
+		return -EBUSY;
+	}
+
+	session->num = session->ctrl->cnr;
+
+	BT_DBG("session %p ctrl %p num %d", session, session->ctrl, session->num);
+
+	capimsg_setu32(buf, 0, 1);
+
+	cmtp_send_interopmsg(session, CAPI_REQ, 0xffff, cmtp_msgnum_get(session),
+				CAPI_FUNCTION_GET_MANUFACTURER, buf, 4);
+
+	cmtp_send_interopmsg(session, CAPI_REQ, 0xffff, cmtp_msgnum_get(session),
+				CAPI_FUNCTION_GET_VERSION, buf, 4);
+
+	cmtp_send_interopmsg(session, CAPI_REQ, 0xffff, cmtp_msgnum_get(session),
+				CAPI_FUNCTION_GET_SERIAL_NUMBER, buf, 4);
+
+	cmtp_send_interopmsg(session, CAPI_REQ, 0xffff, cmtp_msgnum_get(session),
+				CAPI_FUNCTION_GET_PROFILE, buf, 4);
+
+	return 0;
+}
+
+void cmtp_detach_device(struct cmtp_session *session)
+{
+	struct capi_ctr *ctrl = session->ctrl;
+
+	BT_DBG("session %p ctrl %p", session, ctrl);
+
+	if (!ctrl)
+		return;
+
+	ctrl->reseted(ctrl);
+
+	di->detach_ctr(ctrl);
+}
+
+int cmtp_init_capi(void)
+{
+	if (!(di = attach_capi_driver(&cmtp_driver))) {
+		BT_ERR("Can't attach CAPI driver");
+		return -EIO;
+	}
+
+	return 0;
+}
+
+void cmtp_cleanup_capi(void)
+{
+	detach_capi_driver(&cmtp_driver);
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/cmtp/cmtp.h linux-2.4.22-pre2/net/bluetooth/cmtp/cmtp.h
--- linux-2.4.21/net/bluetooth/cmtp/cmtp.h	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/cmtp/cmtp.h	2003-06-26 21:43:10.000000000 +0000
@@ -0,0 +1,138 @@
+/* 
+   CMTP implementation for Linux Bluetooth stack (BlueZ).
+   Copyright (C) 2002-2003 Marcel Holtmann <marcel@holtmann.org>
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License version 2 as
+   published by the Free Software Foundation;
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
+   IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   SOFTWARE IS DISCLAIMED.
+*/
+
+#ifndef __CMTP_H
+#define __CMTP_H
+
+#include <linux/types.h>
+#include <net/bluetooth/bluetooth.h>
+
+#define BTNAMSIZ 18
+
+/* CMTP ioctl defines */
+#define CMTPCONNADD	_IOW('C', 200, int)
+#define CMTPCONNDEL	_IOW('C', 201, int)
+#define CMTPGETCONNLIST	_IOR('C', 210, int)
+#define CMTPGETCONNINFO	_IOR('C', 211, int)
+
+#define CMTP_LOOPBACK	0
+
+struct cmtp_connadd_req {
+	int   sock;	// Connected socket
+	__u32 flags;
+};
+
+struct cmtp_conndel_req {
+	bdaddr_t bdaddr;
+	__u32    flags;
+};
+
+struct cmtp_conninfo {
+	bdaddr_t bdaddr;
+	__u32    flags;
+	__u16    state;
+	int      num;
+};
+
+struct cmtp_connlist_req {
+	__u32  cnum;
+	struct cmtp_conninfo *ci;
+};
+
+int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock);
+int cmtp_del_connection(struct cmtp_conndel_req *req);
+int cmtp_get_connlist(struct cmtp_connlist_req *req);
+int cmtp_get_conninfo(struct cmtp_conninfo *ci);
+
+/* CMTP session defines */
+#define CMTP_INTEROP_TIMEOUT	(HZ * 5)
+#define CMTP_INITIAL_MSGNUM	0xff00
+
+struct cmtp_session {
+	struct list_head list;
+
+	struct socket *sock;
+
+	bdaddr_t bdaddr;
+
+	unsigned long state;
+	unsigned long flags;
+
+	uint mtu;
+
+	char name[BTNAMSIZ];
+
+	atomic_t terminate;
+
+	wait_queue_head_t wait;
+
+	int ncontroller;
+	int num;
+	struct capi_ctr *ctrl;
+
+	struct list_head applications;
+
+	unsigned long blockids;
+	int msgnum;
+
+	struct sk_buff_head transmit;
+
+	struct sk_buff *reassembly[16];
+};
+
+struct cmtp_application {
+	struct list_head list;
+
+	unsigned long state;
+	int err;
+
+	__u16 appl;
+	__u16 mapping;
+
+	__u16 msgnum;
+};
+
+struct cmtp_scb {
+	int id;
+	int data;
+};
+
+int  cmtp_attach_device(struct cmtp_session *session);
+void cmtp_detach_device(struct cmtp_session *session);
+
+void cmtp_recv_capimsg(struct cmtp_session *session, struct sk_buff *skb);
+void cmtp_send_capimsg(struct cmtp_session *session, struct sk_buff *skb);
+
+static inline void cmtp_schedule(struct cmtp_session *session)
+{
+	struct sock *sk = session->sock->sk;
+
+	wake_up_interruptible(sk->sleep);
+}
+
+/* CMTP init defines */
+int cmtp_init_capi(void);
+int cmtp_init_sockets(void);
+void cmtp_cleanup_capi(void);
+void cmtp_cleanup_sockets(void);
+
+#endif /* __CMTP_H */
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/cmtp/core.c linux-2.4.22-pre2/net/bluetooth/cmtp/core.c
--- linux-2.4.21/net/bluetooth/cmtp/core.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/cmtp/core.c	2003-06-26 21:43:13.000000000 +0000
@@ -0,0 +1,512 @@
+/* 
+   CMTP implementation for Linux Bluetooth stack (BlueZ).
+   Copyright (C) 2002-2003 Marcel Holtmann <marcel@holtmann.org>
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License version 2 as
+   published by the Free Software Foundation;
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
+   IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   SOFTWARE IS DISCLAIMED.
+*/
+
+#include <linux/config.h>
+#include <linux/module.h>
+
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/major.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/poll.h>
+#include <linux/fcntl.h>
+#include <linux/skbuff.h>
+#include <linux/socket.h>
+#include <linux/ioctl.h>
+#include <linux/file.h>
+#include <net/sock.h>
+
+#include <net/bluetooth/bluetooth.h>
+#include <net/bluetooth/l2cap.h>
+
+#include "cmtp.h"
+
+#ifndef CONFIG_BLUEZ_CMTP_DEBUG
+#undef  BT_DBG
+#define BT_DBG(D...)
+#endif
+
+#define VERSION "1.0"
+
+static DECLARE_RWSEM(cmtp_session_sem);
+static LIST_HEAD(cmtp_session_list);
+
+static struct cmtp_session *__cmtp_get_session(bdaddr_t *bdaddr)
+{
+	struct cmtp_session *session;
+	struct list_head *p;
+
+	BT_DBG("");
+
+	list_for_each(p, &cmtp_session_list) {
+		session = list_entry(p, struct cmtp_session, list);
+		if (!bacmp(bdaddr, &session->bdaddr))
+			return session;
+	}
+	return NULL;
+}
+
+static void __cmtp_link_session(struct cmtp_session *session)
+{
+	MOD_INC_USE_COUNT;
+	list_add(&session->list, &cmtp_session_list);
+}
+
+static void __cmtp_unlink_session(struct cmtp_session *session)
+{
+	list_del(&session->list);
+	MOD_DEC_USE_COUNT;
+}
+
+static void __cmtp_copy_session(struct cmtp_session *session, struct cmtp_conninfo *ci)
+{
+	bacpy(&ci->bdaddr, &session->bdaddr);
+
+	ci->flags = session->flags;
+	ci->state = session->state;
+
+	ci->num = session->num;
+}
+
+
+static inline int cmtp_alloc_block_id(struct cmtp_session *session)
+{
+	int i, id = -1;
+
+	for (i = 0; i < 16; i++)
+		if (!test_and_set_bit(i, &session->blockids)) {
+			id = i;
+			break;
+		}
+
+	return id;
+}
+
+static inline void cmtp_free_block_id(struct cmtp_session *session, int id)
+{
+	clear_bit(id, &session->blockids);
+}
+
+static inline void cmtp_add_msgpart(struct cmtp_session *session, int id, const unsigned char *buf, int count)
+{
+	struct sk_buff *skb = session->reassembly[id], *nskb;
+	int size;
+
+	BT_DBG("session %p buf %p count %d", session, buf, count);
+
+	size = (skb) ? skb->len + count : count;
+
+	if (!(nskb = alloc_skb(size, GFP_ATOMIC))) {
+		BT_ERR("Can't allocate memory for CAPI message");
+		return;
+	}
+
+	if (skb && (skb->len > 0))
+		memcpy(skb_put(nskb, skb->len), skb->data, skb->len);
+
+	memcpy(skb_put(nskb, count), buf, count);
+
+	session->reassembly[id] = nskb;
+
+	if (skb)
+		kfree_skb(skb);
+}
+
+static inline int cmtp_recv_frame(struct cmtp_session *session, struct sk_buff *skb)
+{
+	__u8 hdr, hdrlen, id;
+	__u16 len;
+
+	BT_DBG("session %p skb %p len %d", session, skb, skb->len);
+
+	while (skb->len > 0) {
+		hdr = skb->data[0];
+
+		switch (hdr & 0xc0) {
+		case 0x40:
+			hdrlen = 2;
+			len = skb->data[1];
+			break;
+		case 0x80:
+			hdrlen = 3;
+			len = skb->data[1] | (skb->data[2] << 8);
+			break;
+		default:
+			hdrlen = 1;
+			len = 0;
+			break;
+		}
+
+		id = (hdr & 0x3c) >> 2;
+
+		BT_DBG("hdr 0x%02x hdrlen %d len %d id %d", hdr, hdrlen, len, id);
+
+		if (hdrlen + len > skb->len) {
+			BT_ERR("Wrong size or header information in CMTP frame");
+			break;
+		}
+
+		if (len == 0) {
+			skb_pull(skb, hdrlen);
+			continue;
+		}
+
+		switch (hdr & 0x03) {
+		case 0x00:
+			cmtp_add_msgpart(session, id, skb->data + hdrlen, len);
+			cmtp_recv_capimsg(session, session->reassembly[id]);
+			session->reassembly[id] = NULL;
+			break;
+		case 0x01:
+			cmtp_add_msgpart(session, id, skb->data + hdrlen, len);
+			break;
+		default:
+			if (session->reassembly[id] != NULL)
+				kfree_skb(session->reassembly[id]);
+			session->reassembly[id] = NULL;
+			break;
+		}
+
+		skb_pull(skb, hdrlen + len);
+	}
+
+	kfree_skb(skb);
+	return 0;
+}
+
+static int cmtp_send_frame(struct cmtp_session *session, unsigned char *data, int len)
+{
+	struct socket *sock = session->sock;
+	struct iovec iv = { data, len };
+	struct msghdr msg;
+	int err;
+
+	BT_DBG("session %p data %p len %d", session, data, len);
+
+	if (!len)
+		return 0;
+
+	memset(&msg, 0, sizeof(msg));
+	msg.msg_iovlen = 1;
+	msg.msg_iov = &iv;
+
+	err = sock->ops->sendmsg(sock, &msg, len, 0);
+	return err;
+}
+
+static int cmtp_process_transmit(struct cmtp_session *session)
+{
+	struct sk_buff *skb, *nskb;
+	unsigned char *hdr;
+	unsigned int size, tail;
+
+	BT_DBG("session %p", session);
+
+	if (!(nskb = alloc_skb(session->mtu, GFP_ATOMIC))) {
+		BT_ERR("Can't allocate memory for new frame");
+		return -ENOMEM;
+	}
+
+	while ((skb = skb_dequeue(&session->transmit))) {
+		struct cmtp_scb *scb = (void *) skb->cb;
+
+		if ((tail = (session->mtu - nskb->len)) < 5) {
+			cmtp_send_frame(session, nskb->data, nskb->len);
+			skb_trim(nskb, 0);
+			tail = session->mtu;
+		}
+
+		size = min_t(uint, ((tail < 258) ? (tail - 2) : (tail - 3)), skb->len);
+
+		if ((scb->id < 0) && ((scb->id = cmtp_alloc_block_id(session)) < 0)) {
+			skb_queue_head(&session->transmit, skb);
+			break;
+		}
+
+		if (size < 256) {
+			hdr = skb_put(nskb, 2);
+			hdr[0] = 0x40
+				| ((scb->id << 2) & 0x3c)
+				| ((skb->len == size) ? 0x00 : 0x01);
+			hdr[1] = size;
+		} else {
+			hdr = skb_put(nskb, 3);
+			hdr[0] = 0x80
+				| ((scb->id << 2) & 0x3c)
+				| ((skb->len == size) ? 0x00 : 0x01);
+			hdr[1] = size & 0xff;
+			hdr[2] = size >> 8;
+		}
+
+		memcpy(skb_put(nskb, size), skb->data, size);
+		skb_pull(skb, size);
+
+		if (skb->len > 0) {
+			skb_queue_head(&session->transmit, skb);
+		} else {
+			cmtp_free_block_id(session, scb->id);
+			if (scb->data) {
+				cmtp_send_frame(session, nskb->data, nskb->len);
+				skb_trim(nskb, 0);
+			}
+			kfree_skb(skb);
+		}
+	}
+
+	cmtp_send_frame(session, nskb->data, nskb->len);
+
+	kfree_skb(nskb);
+
+	return skb_queue_len(&session->transmit);
+}
+
+static int cmtp_session(void *arg)
+{
+	struct cmtp_session *session = arg;
+	struct sock *sk = session->sock->sk;
+	struct sk_buff *skb;
+	wait_queue_t wait;
+
+	BT_DBG("session %p", session);
+
+	daemonize(); reparent_to_init();
+
+	sprintf(current->comm, "kcmtpd_ctr_%d", session->num);
+
+	sigfillset(&current->blocked);
+	flush_signals(current);
+
+	current->nice = -15;
+
+	set_fs(KERNEL_DS);
+
+	init_waitqueue_entry(&wait, current);
+	add_wait_queue(sk->sleep, &wait);
+	while (!atomic_read(&session->terminate)) {
+		set_current_state(TASK_INTERRUPTIBLE);
+
+		if (sk->state != BT_CONNECTED)
+			break;
+
+		while ((skb = skb_dequeue(&sk->receive_queue))) {
+			skb_orphan(skb);
+			cmtp_recv_frame(session, skb);
+		}
+
+		cmtp_process_transmit(session);
+
+		schedule();
+	}
+	set_current_state(TASK_RUNNING);
+	remove_wait_queue(sk->sleep, &wait);
+
+	down_write(&cmtp_session_sem);
+
+	if (!(session->flags & (1 << CMTP_LOOPBACK)))
+		cmtp_detach_device(session);
+
+	fput(session->sock->file);
+
+	__cmtp_unlink_session(session);
+
+	up_write(&cmtp_session_sem);
+
+	kfree(session);
+	return 0;
+}
+
+int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock)
+{
+	struct cmtp_session *session, *s;
+	bdaddr_t src, dst;
+	int i, err;
+
+	BT_DBG("");
+
+	baswap(&src, &bluez_pi(sock->sk)->src);
+	baswap(&dst, &bluez_pi(sock->sk)->dst);
+
+	session = kmalloc(sizeof(struct cmtp_session), GFP_KERNEL);
+	if (!session) 
+		return -ENOMEM;
+	memset(session, 0, sizeof(struct cmtp_session));
+
+	down_write(&cmtp_session_sem);
+
+	s = __cmtp_get_session(&bluez_pi(sock->sk)->dst);
+	if (s && s->state == BT_CONNECTED) {
+		err = -EEXIST;
+		goto failed;
+	}
+
+	bacpy(&session->bdaddr, &bluez_pi(sock->sk)->dst);
+
+	session->mtu = min_t(uint, l2cap_pi(sock->sk)->omtu, l2cap_pi(sock->sk)->imtu);
+
+	BT_DBG("mtu %d", session->mtu);
+
+	sprintf(session->name, "%s", batostr(&dst));
+
+	session->sock  = sock;
+	session->state = BT_CONFIG;
+
+	init_waitqueue_head(&session->wait);
+
+	session->ctrl   = NULL;
+	session->msgnum = CMTP_INITIAL_MSGNUM;
+
+	INIT_LIST_HEAD(&session->applications);
+
+	skb_queue_head_init(&session->transmit);
+
+	for (i = 0; i < 16; i++)
+		session->reassembly[i] = NULL;
+
+	session->flags = req->flags;
+
+	__cmtp_link_session(session);
+
+	err = kernel_thread(cmtp_session, session, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
+	if (err < 0)
+		goto unlink;
+
+	if (!(session->flags & (1 << CMTP_LOOPBACK))) {
+		err = cmtp_attach_device(session);
+		if (err < 0)
+			goto detach;
+	}
+
+	up_write(&cmtp_session_sem);
+	return 0;
+
+detach:
+	cmtp_detach_device(session);
+
+unlink:
+	__cmtp_unlink_session(session);
+
+failed:
+	up_write(&cmtp_session_sem);
+	kfree(session);
+	return err;
+}
+
+int cmtp_del_connection(struct cmtp_conndel_req *req)
+{
+	struct cmtp_session *session;
+	int err = 0;
+
+	BT_DBG("");
+
+	down_read(&cmtp_session_sem);
+
+	session = __cmtp_get_session(&req->bdaddr);
+	if (session) {
+		/* Flush the transmit queue */
+		skb_queue_purge(&session->transmit);
+
+		/* Kill session thread */
+		atomic_inc(&session->terminate);
+		cmtp_schedule(session);
+	} else
+		err = -ENOENT;
+
+	up_read(&cmtp_session_sem);
+	return err;
+}
+
+int cmtp_get_connlist(struct cmtp_connlist_req *req)
+{
+	struct list_head *p;
+	int err = 0, n = 0;
+
+	BT_DBG("");
+
+	down_read(&cmtp_session_sem);
+
+	list_for_each(p, &cmtp_session_list) {
+		struct cmtp_session *session;
+		struct cmtp_conninfo ci;
+
+		session = list_entry(p, struct cmtp_session, list);
+
+		__cmtp_copy_session(session, &ci);
+
+		if (copy_to_user(req->ci, &ci, sizeof(ci))) {
+			err = -EFAULT;
+			break;
+		}
+
+		if (++n >= req->cnum)
+			break;
+
+		req->ci++;
+	}
+	req->cnum = n;
+
+	up_read(&cmtp_session_sem);
+	return err;
+}
+
+int cmtp_get_conninfo(struct cmtp_conninfo *ci)
+{
+	struct cmtp_session *session;
+	int err = 0;
+
+	down_read(&cmtp_session_sem);
+
+	session = __cmtp_get_session(&ci->bdaddr);
+	if (session)
+		__cmtp_copy_session(session, ci);
+	else
+		err = -ENOENT;
+
+	up_read(&cmtp_session_sem);
+	return err;
+}
+
+
+int __init init_cmtp(void)
+{
+	cmtp_init_capi();
+	cmtp_init_sockets();
+
+	BT_INFO("BlueZ CMTP ver %s", VERSION);
+	BT_INFO("Copyright (C) 2002-2003 Marcel Holtmann <marcel@holtmann.org>");
+
+	return 0;
+}
+
+void __exit exit_cmtp(void)
+{
+	cmtp_cleanup_sockets();
+	cmtp_cleanup_capi();
+}
+
+module_init(init_cmtp);
+module_exit(exit_cmtp);
+
+MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
+MODULE_DESCRIPTION("BlueZ CMTP ver " VERSION);
+MODULE_LICENSE("GPL");
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/cmtp/sock.c linux-2.4.22-pre2/net/bluetooth/cmtp/sock.c
--- linux-2.4.21/net/bluetooth/cmtp/sock.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/cmtp/sock.c	2003-06-26 21:43:31.000000000 +0000
@@ -0,0 +1,236 @@
+/* 
+   CMTP implementation for Linux Bluetooth stack (BlueZ).
+   Copyright (C) 2002-2003 Marcel Holtmann <marcel@holtmann.org>
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License version 2 as
+   published by the Free Software Foundation;
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
+   IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   SOFTWARE IS DISCLAIMED.
+*/
+
+#include <linux/config.h>
+#include <linux/module.h>
+
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/major.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/poll.h>
+#include <linux/fcntl.h>
+#include <linux/skbuff.h>
+#include <linux/socket.h>
+#include <linux/ioctl.h>
+#include <linux/file.h>
+#include <net/sock.h>
+
+#include <asm/system.h>
+#include <asm/uaccess.h>
+
+#include "cmtp.h"
+
+#ifndef CONFIG_BLUEZ_CMTP_DEBUG
+#undef  BT_DBG
+#define BT_DBG(D...)
+#endif
+
+static inline struct socket *socki_lookup(struct inode *inode)
+{
+	return &inode->u.socket_i;
+}
+
+static struct socket *sockfd_lookup(int fd, int *err)
+{
+	struct file *file;
+	struct inode *inode;
+	struct socket *sock;
+
+	if (!(file = fget(fd))) {
+		*err = -EBADF;
+		return NULL;
+	}
+
+	inode = file->f_dentry->d_inode;
+	if (!inode->i_sock || !(sock = socki_lookup(inode))) {
+		*err = -ENOTSOCK;
+		fput(file);
+		return NULL;
+	}
+
+	if (sock->file != file) {
+		printk(KERN_ERR "socki_lookup: socket file changed!\n");
+		sock->file = file;
+	}
+	return sock;
+}
+
+static int cmtp_sock_release(struct socket *sock)
+{
+	struct sock *sk = sock->sk;
+
+	BT_DBG("sock %p sk %p", sock, sk);
+
+	if (!sk)
+		return 0;
+
+	sock_orphan(sk);
+	sock_put(sk);
+
+	MOD_DEC_USE_COUNT;
+	return 0;
+}
+
+static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
+{
+	struct cmtp_connadd_req ca;
+	struct cmtp_conndel_req cd;
+	struct cmtp_connlist_req cl;
+	struct cmtp_conninfo ci;
+	struct socket *nsock;
+	int err;
+
+	BT_DBG("cmd %x arg %lx", cmd, arg);
+
+	switch (cmd) {
+	case CMTPCONNADD:
+		if (!capable(CAP_NET_ADMIN))
+			return -EACCES;
+
+		if (copy_from_user(&ca, (void *) arg, sizeof(ca)))
+			return -EFAULT;
+
+		nsock = sockfd_lookup(ca.sock, &err);
+		if (!nsock)
+			return err;
+
+		if (nsock->sk->state != BT_CONNECTED)
+			return -EBADFD;
+
+		err = cmtp_add_connection(&ca, nsock);
+		if (!err) {
+			if (copy_to_user((void *) arg, &ca, sizeof(ca)))
+				err = -EFAULT;
+		} else
+			fput(nsock->file);
+
+		return err;
+
+	case CMTPCONNDEL:
+		if (!capable(CAP_NET_ADMIN))
+			return -EACCES;
+
+		if (copy_from_user(&cd, (void *) arg, sizeof(cd)))
+			return -EFAULT;
+
+		return cmtp_del_connection(&cd);
+
+	case CMTPGETCONNLIST:
+		if (copy_from_user(&cl, (void *) arg, sizeof(cl)))
+			return -EFAULT;
+
+		if (cl.cnum <= 0)
+			return -EINVAL;
+
+		err = cmtp_get_connlist(&cl);
+		if (!err && copy_to_user((void *) arg, &cl, sizeof(cl)))
+			return -EFAULT;
+
+		return err;
+
+	case CMTPGETCONNINFO:
+		if (copy_from_user(&ci, (void *) arg, sizeof(ci)))
+			return -EFAULT;
+
+		err = cmtp_get_conninfo(&ci);
+		if (!err && copy_to_user((void *) arg, &ci, sizeof(ci)))
+			return -EFAULT;
+
+		return err;
+	}
+
+	return -EINVAL;
+}
+
+static struct proto_ops cmtp_sock_ops = {
+	family:		PF_BLUETOOTH,
+	release:	cmtp_sock_release,
+	ioctl:		cmtp_sock_ioctl,
+	bind:		sock_no_bind,
+	getname:	sock_no_getname,
+	sendmsg:	sock_no_sendmsg,
+	recvmsg:	sock_no_recvmsg,
+	poll:		sock_no_poll,
+	listen:		sock_no_listen,
+	shutdown:	sock_no_shutdown,
+	setsockopt:	sock_no_setsockopt,
+	getsockopt:	sock_no_getsockopt,
+	connect:	sock_no_connect,
+	socketpair:	sock_no_socketpair,
+	accept:		sock_no_accept,
+	mmap:		sock_no_mmap
+};
+
+static int cmtp_sock_create(struct socket *sock, int protocol)
+{
+	struct sock *sk;
+
+	BT_DBG("sock %p", sock);
+
+	if (sock->type != SOCK_RAW)
+		return -ESOCKTNOSUPPORT;
+
+	sock->ops = &cmtp_sock_ops;
+
+	if (!(sk = sk_alloc(PF_BLUETOOTH, GFP_KERNEL, 1)))
+		return -ENOMEM;
+
+	MOD_INC_USE_COUNT;
+
+	sock->state = SS_UNCONNECTED;
+	sock_init_data(sock, sk);
+
+	sk->destruct = NULL;
+	sk->protocol = protocol;
+
+	return 0;
+}
+
+static struct net_proto_family cmtp_sock_family_ops = {
+	family:		PF_BLUETOOTH,
+	create:		cmtp_sock_create
+};
+
+int cmtp_init_sockets(void)
+{
+	int err;
+
+	if ((err = bluez_sock_register(BTPROTO_CMTP, &cmtp_sock_family_ops))) {
+		BT_ERR("Can't register CMTP socket layer (%d)", err);
+		return err;
+	}
+
+	return 0;
+}
+
+void cmtp_cleanup_sockets(void)
+{
+	int err;
+
+	if ((err = bluez_sock_unregister(BTPROTO_CMTP)))
+		BT_ERR("Can't unregister CMTP socket layer (%d)", err);
+
+	return;
+}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/l2cap.c linux-2.4.22-pre2/net/bluetooth/l2cap.c
--- linux-2.4.21/net/bluetooth/l2cap.c	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/l2cap.c	2003-06-26 21:43:19.000000000 +0000
@@ -27,7 +27,7 @@
  *
  * $Id: l2cap.c,v 1.15 2002/09/09 01:14:52 maxk Exp $
  */
-#define VERSION "2.1"
+#define VERSION "2.3"
 
 #include <linux/config.h>
 #include <linux/module.h>
@@ -284,7 +284,7 @@
 			l2cap_disconn_req req;
 
 			sk->state = BT_DISCONN;
-			l2cap_sock_set_timer(sk, HZ * 5);
+			l2cap_sock_set_timer(sk, sk->sndtimeo);
 
 			req.dcid = __cpu_to_le16(l2cap_pi(sk)->dcid);
 			req.scid = __cpu_to_le16(l2cap_pi(sk)->scid);
@@ -309,11 +309,9 @@
 static void l2cap_sock_close(struct sock *sk)
 {
 	l2cap_sock_clear_timer(sk);
-
 	lock_sock(sk);
 	__l2cap_sock_close(sk, ECONNRESET);
 	release_sock(sk);
-
 	l2cap_sock_kill(sk);
 }
 
@@ -527,7 +525,8 @@
 		goto done;
 
 wait:
-	err = bluez_sock_w4_connect(sk, flags);
+	err = bluez_sock_wait_state(sk, BT_CONNECTED,
+			sock_sndtimeo(sk, flags & O_NONBLOCK));
 
 done:
 	release_sock(sk);
@@ -760,32 +759,39 @@
 static int l2cap_sock_shutdown(struct socket *sock, int how)
 {
 	struct sock *sk = sock->sk;
+	int err = 0;
 
 	BT_DBG("sock %p, sk %p", sock, sk);
 
 	if (!sk) return 0;
 
-	l2cap_sock_clear_timer(sk);
-
 	lock_sock(sk);
-	sk->shutdown = SHUTDOWN_MASK;
-	__l2cap_sock_close(sk, ECONNRESET);
-	release_sock(sk);
+	if (!sk->shutdown) {
+		sk->shutdown = SHUTDOWN_MASK;
+		l2cap_sock_clear_timer(sk);
+		__l2cap_sock_close(sk, 0);
 
-	return 0;
+		if (sk->linger)
+			err = bluez_sock_wait_state(sk, BT_CLOSED, sk->lingertime);
+	}
+	release_sock(sk);
+	return err;
 }
 
 static int l2cap_sock_release(struct socket *sock)
 {
 	struct sock *sk = sock->sk;
+	int err;
 
 	BT_DBG("sock %p, sk %p", sock, sk);
 
 	if (!sk) return 0;
 
+	err = l2cap_sock_shutdown(sock, 2);
+
 	sock_orphan(sk);
-	l2cap_sock_close(sk);
-	return 0;
+	l2cap_sock_kill(sk);
+	return err;
 }
 
 /* --------- L2CAP channels --------- */
@@ -917,10 +923,12 @@
 		hci_conn_put(conn->hcon);
 	}
 
-	sk->state = BT_CLOSED;
-	sk->err   = err;
+	sk->state  = BT_CLOSED;
 	sk->zapped = 1;
 
+	if (err)
+		sk->err = err;
+
 	if (parent)
 		parent->data_ready(parent, 0);
 	else
@@ -956,6 +964,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->err = err;
+	}
+	read_unlock(&l->lock);
+}
+
 static void l2cap_chan_ready(struct sock *sk)
 {
 	struct sock *parent = bluez_pi(sk)->parent;
@@ -1320,15 +1344,18 @@
 {
 	l2cap_conf_rsp *rsp = (l2cap_conf_rsp *) data;
 	void *ptr = rsp->data;
+	u16 flags = 0;
 
 	BT_DBG("sk %p complete %d", sk, result ? 1 : 0);
 
 	if (result)
 		*result = l2cap_conf_output(sk, &ptr);
+	else	
+		flags |= 0x0001;
 
 	rsp->scid   = __cpu_to_le16(l2cap_pi(sk)->dcid);
 	rsp->result = __cpu_to_le16(result ? *result : 0);
-	rsp->flags  = __cpu_to_le16(0);
+	rsp->flags  = __cpu_to_le16(flags);
 
 	return ptr - data;
 }
@@ -1441,7 +1468,7 @@
 	case L2CAP_CR_SUCCESS:
 		sk->state = BT_CONFIG;
 		l2cap_pi(sk)->dcid = dcid;
-		l2cap_pi(sk)->conf_state |= CONF_REQ_SENT;
+		l2cap_pi(sk)->conf_state |= L2CAP_CONF_REQ_SENT;
 
 		l2cap_send_req(conn, L2CAP_CONF_REQ, l2cap_build_conf_req(sk, req), req);
 		break;
@@ -1476,7 +1503,7 @@
 
 	l2cap_parse_conf_req(sk, req->data, cmd->len - L2CAP_CONF_REQ_SIZE);
 
-	if (flags & 0x01) {
+	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);
 		goto unlock;
@@ -1489,12 +1516,12 @@
 		goto unlock;
 
 	/* Output config done */
-	l2cap_pi(sk)->conf_state |= CONF_OUTPUT_DONE;
+	l2cap_pi(sk)->conf_state |= L2CAP_CONF_OUTPUT_DONE;
 
-	if (l2cap_pi(sk)->conf_state & CONF_INPUT_DONE) {
+	if (l2cap_pi(sk)->conf_state & L2CAP_CONF_INPUT_DONE) {
 		sk->state = BT_CONNECTED;
 		l2cap_chan_ready(sk);
-	} else if (!(l2cap_pi(sk)->conf_state & CONF_REQ_SENT)) {
+	} else if (!(l2cap_pi(sk)->conf_state & L2CAP_CONF_REQ_SENT)) {
 		char req[64];
 		l2cap_send_req(conn, L2CAP_CONF_REQ, l2cap_build_conf_req(sk, req), req);
 	}
@@ -1520,18 +1547,34 @@
 	if (!(sk = l2cap_get_chan_by_scid(&conn->chan_list, scid)))
 		return -ENOENT;
 
-	if (result) {
-		l2cap_disconn_req req;
+	switch (result) {
+	case L2CAP_CONF_SUCCESS:
+		break;
 
-		/* They didn't like our options. Well... we do not negotiate.
-		 * Close channel.
-		 */
+	case L2CAP_CONF_UNACCEPT:
+		if (++l2cap_pi(sk)->conf_retry < L2CAP_CONF_MAX_RETRIES) {
+			char req[128];
+			/* 
+			   It does not make sense to adjust L2CAP parameters 
+			   that are currently defined in the spec. We simply 
+			   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);
+			goto done;
+		}
+	default: 
 		sk->state = BT_DISCONN;
+		sk->err   = ECONNRESET;
 		l2cap_sock_set_timer(sk, HZ * 5);
-
-		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, L2CAP_DISCONN_REQ_SIZE, &req);
+		{
+			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, L2CAP_DISCONN_REQ_SIZE, &req);
+		}
 		goto done;
 	}
 
@@ -1539,9 +1582,9 @@
 		goto done;
 
 	/* Input config done */
-	l2cap_pi(sk)->conf_state |= CONF_INPUT_DONE;
+	l2cap_pi(sk)->conf_state |= L2CAP_CONF_INPUT_DONE;
 
-	if (l2cap_pi(sk)->conf_state & CONF_OUTPUT_DONE) {
+	if (l2cap_pi(sk)->conf_state & L2CAP_CONF_OUTPUT_DONE) {
 		sk->state = BT_CONNECTED;
 		l2cap_chan_ready(sk);
 	}
@@ -1592,7 +1635,7 @@
 
 	if (!(sk = l2cap_get_chan_by_scid(&conn->chan_list, scid)))
 		return 0;
-	l2cap_chan_del(sk, ECONNABORTED);
+	l2cap_chan_del(sk, 0);
 	bh_unlock_sock(sk);
 
 	l2cap_sock_kill(sk);
@@ -1943,26 +1986,36 @@
 			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 small (len %d)", skb->len);
+			BT_ERR("Frame is too short (len %d)", skb->len);
+			l2cap_conn_unreliable(conn, ECOMM);
 			goto drop;
 		}
 
 		hdr = (l2cap_hdr *) skb->data;
 		len = __le16_to_cpu(hdr->len) + L2CAP_HDR_SIZE;
 
-		BT_DBG("Start: total len %d, frag len %d", len, skb->len);
-
 		if (len == skb->len) {
 			/* Complete frame received */
 			l2cap_recv_frame(conn, skb);
 			return 0;
 		}
 
-		/* Allocate skb for the complete frame (with header) */
-		if (!(conn->rx_skb = bluez_skb_alloc(len, GFP_ATOMIC)))
+		BT_DBG("Start: total len %d, frag len %d", len, skb->len);
+
+		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;
+		}
+
+		/* Allocate skb for the complete frame including header */
+		conn->rx_skb = bluez_skb_alloc(len, GFP_ATOMIC);
+		if (!conn->rx_skb)
 			goto drop;
 
 		memcpy(skb_put(conn->rx_skb, skb->len), skb->data, skb->len);
@@ -1972,15 +2025,17 @@
 
 		if (!conn->rx_len) {
 			BT_ERR("Unexpected continuation frame (len %d)", skb->len);
+			l2cap_conn_unreliable(conn, ECOMM);
 			goto drop;
 		}
 
 		if (skb->len > conn->rx_len) {
-			BT_ERR("Fragment is too large (len %d, expect %d)",
+			BT_ERR("Fragment is too long (len %d, expected %d)",
 					skb->len, conn->rx_len);
 			kfree_skb(conn->rx_skb);
 			conn->rx_skb = NULL;
 			conn->rx_len = 0;
+			l2cap_conn_unreliable(conn, ECOMM);
 			goto drop;
 		}
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/rfcomm/core.c linux-2.4.22-pre2/net/bluetooth/rfcomm/core.c
--- linux-2.4.21/net/bluetooth/rfcomm/core.c	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/rfcomm/core.c	2003-06-26 21:43:29.000000000 +0000
@@ -198,6 +198,7 @@
 
 	d->state      = BT_OPEN;
 	d->flags      = 0;
+	d->mscex      = 0;
 	d->mtu        = RFCOMM_DEFAULT_MTU;
 	d->v24_sig    = RFCOMM_V24_RTC | RFCOMM_V24_RTR | RFCOMM_V24_DV;
 
@@ -274,13 +275,13 @@
 static int __rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst, u8 channel)
 {
 	struct rfcomm_session *s;
-	u8 dlci = __dlci(0, channel);
 	int err = 0;
+	u8 dlci;
 
-	BT_DBG("dlc %p state %ld %s %s channel %d dlci %d", 
-			d, d->state, batostr(src), batostr(dst), channel, dlci);
+	BT_DBG("dlc %p state %ld %s %s channel %d", 
+			d, d->state, batostr(src), batostr(dst), channel);
 
-	if (dlci < 1 || dlci > 62)
+	if (channel < 1 || channel > 30)
 		return -EINVAL;
 
 	if (d->state != BT_OPEN && d->state != BT_CLOSED)
@@ -293,16 +294,19 @@
 			return err;
 	}
 
+	dlci = __dlci(!s->initiator, channel);
+
 	/* Check if DLCI already exists */
 	if (rfcomm_dlc_get(s, dlci))
 		return -EBUSY;
 
 	rfcomm_dlc_clear_state(d);
 
-	d->dlci    = dlci;
-	d->addr    = __addr(s->initiator, dlci);
+	d->dlci     = dlci;
+	d->addr     = __addr(s->initiator, dlci);
+	d->priority = 7;
 
-	d->state   = BT_CONFIG;
+	d->state    = BT_CONFIG;
 	rfcomm_dlc_link(s, d);
 
 	d->mtu     = s->mtu;
@@ -707,7 +711,7 @@
 	hdr->len  = __len8(sizeof(*mcc) + 1);
 
 	mcc = (void *) ptr; ptr += sizeof(*mcc);
-	mcc->type = __mcc_type(s->initiator, RFCOMM_NSC);
+	mcc->type = __mcc_type(cr, RFCOMM_NSC);
 	mcc->len  = __len8(1);
 
 	/* Type that we didn't like */
@@ -733,12 +737,12 @@
 	hdr->len  = __len8(sizeof(*mcc) + sizeof(*pn));
 
 	mcc = (void *) ptr; ptr += sizeof(*mcc);
-	mcc->type = __mcc_type(s->initiator, RFCOMM_PN);
+	mcc->type = __mcc_type(cr, RFCOMM_PN);
 	mcc->len  = __len8(sizeof(*pn));
 
 	pn = (void *) ptr; ptr += sizeof(*pn);
 	pn->dlci        = d->dlci;
-	pn->priority    = 0;
+	pn->priority    = d->priority;
 	pn->ack_timer   = 0;
 	pn->max_retrans = 0;
 
@@ -842,7 +846,7 @@
 
 	msc = (void *) ptr; ptr += sizeof(*msc);
 	msc->dlci    = __addr(1, dlci);
-	msc->v24_sig = v24_sig;
+	msc->v24_sig = v24_sig | 0x01;
 
 	*ptr = __fcs(buf); ptr++;
 
@@ -1076,6 +1080,8 @@
 		d->state = BT_CONNECTED;
 		d->state_change(d, 0);
 		rfcomm_dlc_unlock(d);
+
+		rfcomm_send_msc(s, 1, dlci, d->v24_sig);
 	} else {
 		rfcomm_send_dm(s, dlci);
 	}
@@ -1095,8 +1101,6 @@
 			set_bit(RFCOMM_TX_THROTTLED, &d->flags);
 			d->credits = 0;
 		}
-
-		d->mtu = btohs(pn->mtu);
 	} else {
 		if (pn->flow_ctrl == 0xe0) {
 			d->tx_credits = pn->credits;
@@ -1104,10 +1108,12 @@
 			set_bit(RFCOMM_TX_THROTTLED, &d->flags);
 			d->credits = 0;
 		}
-
-		d->mtu = btohs(pn->mtu);
 	}
 
+	d->priority = pn->priority;
+
+	d->mtu = btohs(pn->mtu);
+
 	return 0;
 }
 
@@ -1133,7 +1139,7 @@
 			switch (d->state) {
 			case BT_CONFIG:
 				rfcomm_apply_pn(d, cr, pn);
-				
+
 				d->state = BT_CONNECT;
 				rfcomm_send_sabm(s, d->dlci);
 				break;
@@ -1144,7 +1150,7 @@
 
 		if (!cr)
 			return 0;
-		
+
 		/* PN request for non existing DLC.
 		 * Assume incomming connection. */
 		if (rfcomm_connect_ind(s, channel, &d)) {
@@ -1153,7 +1159,7 @@
 			rfcomm_dlc_link(s, d);
 
 			rfcomm_apply_pn(d, cr, pn);
-			
+
 			d->state = BT_OPEN;
 			rfcomm_send_pn(s, 0, d);
 		} else {
@@ -1198,6 +1204,14 @@
 	}
 	/* check for sane values: ignore/accept bit_rate, 8 bits, 1 stop bit, no parity,
 	                          no flow control lines, normal XON/XOFF chars */
+	if (rpn->param_mask & RFCOMM_RPN_PM_BITRATE) {
+		bit_rate = rpn->bit_rate;
+		if (bit_rate != RFCOMM_RPN_BR_115200) {
+			BT_DBG("RPN bit rate mismatch 0x%x", bit_rate);
+			bit_rate = RFCOMM_RPN_BR_115200;
+			rpn_mask ^= RFCOMM_RPN_PM_BITRATE;
+		}
+	}
 	if (rpn->param_mask & RFCOMM_RPN_PM_DATA) {
 		data_bits = __get_rpn_data_bits(rpn->line_settings);
 		if (data_bits != RFCOMM_RPN_DATA_8) {
@@ -1223,23 +1237,26 @@
 		}
 	}
 	if (rpn->param_mask & RFCOMM_RPN_PM_FLOW) {
-		if (rpn->flow_ctrl != RFCOMM_RPN_FLOW_NONE) {
-			BT_DBG("RPN flow ctrl mismatch 0x%x", rpn->flow_ctrl);
-			rpn->flow_ctrl = RFCOMM_RPN_FLOW_NONE;
+		flow_ctrl = rpn->flow_ctrl;
+		if (flow_ctrl != RFCOMM_RPN_FLOW_NONE) {
+			BT_DBG("RPN flow ctrl mismatch 0x%x", flow_ctrl);
+			flow_ctrl = RFCOMM_RPN_FLOW_NONE;
 			rpn_mask ^= RFCOMM_RPN_PM_FLOW;
 		}
 	}
 	if (rpn->param_mask & RFCOMM_RPN_PM_XON) {
-		if (rpn->xon_char != RFCOMM_RPN_XON_CHAR) {
-			BT_DBG("RPN XON char mismatch 0x%x", rpn->xon_char);
-			rpn->xon_char = RFCOMM_RPN_XON_CHAR;
+		xon_char = rpn->xon_char;
+		if (xon_char != RFCOMM_RPN_XON_CHAR) {
+			BT_DBG("RPN XON char mismatch 0x%x", xon_char);
+			xon_char = RFCOMM_RPN_XON_CHAR;
 			rpn_mask ^= RFCOMM_RPN_PM_XON;
 		}
 	}
 	if (rpn->param_mask & RFCOMM_RPN_PM_XOFF) {
-		if (rpn->xoff_char != RFCOMM_RPN_XOFF_CHAR) {
-			BT_DBG("RPN XOFF char mismatch 0x%x", rpn->xoff_char);
-			rpn->xoff_char = RFCOMM_RPN_XOFF_CHAR;
+		xoff_char = rpn->xoff_char;
+		if (xoff_char != RFCOMM_RPN_XOFF_CHAR) {
+			BT_DBG("RPN XOFF char mismatch 0x%x", xoff_char);
+			xoff_char = RFCOMM_RPN_XOFF_CHAR;
 			rpn_mask ^= RFCOMM_RPN_PM_XOFF;
 		}
 	}
@@ -1280,11 +1297,11 @@
 
 	BT_DBG("dlci %d cr %d v24 0x%x", dlci, cr, msc->v24_sig);
 
-	if (!cr)
+	d = rfcomm_dlc_get(s, dlci);
+	if (!d)
 		return 0;
 
-	d = rfcomm_dlc_get(s, dlci);
-	if (d) {
+	if (cr) {
 		if (msc->v24_sig & RFCOMM_V24_FC && !d->credits)
 			set_bit(RFCOMM_TX_THROTTLED, &d->flags);
 		else
@@ -1296,7 +1313,11 @@
 		rfcomm_dlc_unlock(d);
 		
 		rfcomm_send_msc(s, 0, dlci, msc->v24_sig);
-	}
+
+		d->mscex |= RFCOMM_MSCEX_RX;
+	} else 
+		d->mscex |= RFCOMM_MSCEX_TX;
+
 	return 0;
 }
 
@@ -1520,7 +1541,8 @@
 			continue;
 		}
 
-		if (d->state == BT_CONNECTED || d->state == BT_DISCONN)
+		if ((d->state == BT_CONNECTED || d->state == BT_DISCONN) &&
+				d->mscex == RFCOMM_MSCEX_OK)
 			rfcomm_process_tx(d);
 	}
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/rfcomm/sock.c linux-2.4.22-pre2/net/bluetooth/rfcomm/sock.c
--- linux-2.4.21/net/bluetooth/rfcomm/sock.c	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/rfcomm/sock.c	2003-06-26 21:43:28.000000000 +0000
@@ -188,8 +188,10 @@
 	BT_DBG("parent %p", parent);
 
 	/* Close not yet accepted dlcs */
-	while ((sk = bluez_accept_dequeue(parent, NULL)))
+	while ((sk = bluez_accept_dequeue(parent, NULL))) {
 		rfcomm_sock_close(sk);
+		rfcomm_sock_kill(sk);
+	}
 
 	parent->state  = BT_CLOSED;
 	parent->zapped = 1;
@@ -211,15 +213,10 @@
 	sock_put(sk);
 }
 
-/* Close socket.
- * Must be called on unlocked socket.
- */
-static void rfcomm_sock_close(struct sock *sk)
+static void __rfcomm_sock_close(struct sock *sk)
 {
 	struct rfcomm_dlc *d = rfcomm_pi(sk)->dlc;
 
-	lock_sock(sk);
-
 	BT_DBG("sk %p state %d socket %p", sk, sk->state, sk->socket);
 
 	switch (sk->state) {
@@ -236,11 +233,17 @@
 	default:
 		sk->zapped = 1;
 		break;
-	};
+	}
+}
 
+/* Close socket.
+ * Must be called on unlocked socket.
+ */
+static void rfcomm_sock_close(struct sock *sk)
+{
+	lock_sock(sk);
+	__rfcomm_sock_close(sk);
 	release_sock(sk);
-
-	rfcomm_sock_kill(sk);
 }
 
 static void rfcomm_sock_init(struct sock *sk, struct sock *parent)
@@ -374,7 +377,8 @@
 	
 	err = rfcomm_dlc_open(d, &bluez_pi(sk)->src, &sa->rc_bdaddr, sa->rc_channel);
 	if (!err)
-		err = bluez_sock_w4_connect(sk, flags);
+		err = bluez_sock_wait_state(sk, BT_CONNECTED,
+				sock_sndtimeo(sk, flags & O_NONBLOCK));
 
 	release_sock(sk);
 	return err;
@@ -558,9 +562,6 @@
 	int target, err = 0, copied = 0;
 	long timeo;
 
-	if (sk->state != BT_CONNECTED)
-		return -EINVAL;
-
 	if (flags & MSG_OOB)
 		return -EOPNOTSUPP;
 
@@ -635,23 +636,6 @@
 	return copied ? : err;
 }
 
-static int rfcomm_sock_shutdown(struct socket *sock, int how)
-{
-	struct sock *sk = sock->sk;
-
-	BT_DBG("sock %p, sk %p", sock, sk);
-
-	if (!sk) return 0;
-
-	lock_sock(sk);
-	sk->shutdown = SHUTDOWN_MASK;
-	if (sk->state == BT_CONNECTED)
-		rfcomm_dlc_close(rfcomm_pi(sk)->dlc, 0);
-	release_sock(sk);
-
-	return 0;
-}
-
 static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, char *optval, int optlen)
 {
 	struct sock *sk = sock->sk;
@@ -711,19 +695,42 @@
 	return err;
 }
 
+static int rfcomm_sock_shutdown(struct socket *sock, int how)
+{
+	struct sock *sk = sock->sk;
+	int err = 0;
+
+	BT_DBG("sock %p, sk %p", sock, sk);
+
+	if (!sk) return 0;
+
+	lock_sock(sk);
+	if (!sk->shutdown) {
+		sk->shutdown = SHUTDOWN_MASK;
+		__rfcomm_sock_close(sk);
+
+		if (sk->linger)
+			err = bluez_sock_wait_state(sk, BT_CLOSED, sk->lingertime);
+	}
+	release_sock(sk);
+	return err;
+}
+
 static int rfcomm_sock_release(struct socket *sock)
 {
 	struct sock *sk = sock->sk;
+	int err = 0;
 
 	BT_DBG("sock %p, sk %p", sock, sk);
 
 	if (!sk)
 		return 0;
 
-	sock_orphan(sk);
-	rfcomm_sock_close(sk);
+	err = rfcomm_sock_shutdown(sock, 2);
 
-	return 0;
+	sock_orphan(sk);
+	rfcomm_sock_kill(sk);
+	return err;
 }
 
 /* ---- RFCOMM core layer callbacks ---- 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/rfcomm/tty.c linux-2.4.22-pre2/net/bluetooth/rfcomm/tty.c
--- linux-2.4.21/net/bluetooth/rfcomm/tty.c	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/rfcomm/tty.c	2003-06-26 21:43:14.000000000 +0000
@@ -260,9 +260,9 @@
 	skb->destructor = rfcomm_wfree;
 }
 
-static struct sk_buff *rfcomm_wmalloc(struct rfcomm_dev *dev, unsigned long size, int priority)
+static struct sk_buff *rfcomm_wmalloc(struct rfcomm_dev *dev, unsigned long size, int force, int priority)
 {
-	if (atomic_read(&dev->wmem_alloc) < rfcomm_room(dev->dlc)) {
+	if (force || atomic_read(&dev->wmem_alloc) < rfcomm_room(dev->dlc)) {
 		struct sk_buff *skb = alloc_skb(size, priority);
 		if (skb) {
 			rfcomm_set_owner_w(skb, dev);
@@ -627,9 +627,9 @@
 		size = min_t(uint, count, dlc->mtu);
 
 		if (from_user)
-			skb = rfcomm_wmalloc(dev, size + RFCOMM_SKB_RESERVE, GFP_KERNEL);
+			skb = rfcomm_wmalloc(dev, size + RFCOMM_SKB_RESERVE, 0, GFP_KERNEL);
 		else
-			skb = rfcomm_wmalloc(dev, size + RFCOMM_SKB_RESERVE, GFP_ATOMIC);
+			skb = rfcomm_wmalloc(dev, size + RFCOMM_SKB_RESERVE, 0, GFP_ATOMIC);
 		
 		if (!skb)
 			break;
@@ -653,6 +653,27 @@
 	return sent ? sent : err;
 }
 
+static void rfcomm_tty_put_char(struct tty_struct *tty, unsigned char ch)
+{
+	struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
+	struct rfcomm_dlc *dlc = dev->dlc;
+	struct sk_buff *skb;
+
+	BT_DBG("tty %p char %x", tty, ch);
+
+	skb = rfcomm_wmalloc(dev, 1 + RFCOMM_SKB_RESERVE, 1, GFP_ATOMIC);
+
+	if (!skb)
+		return;
+
+	skb_reserve(skb, RFCOMM_SKB_HEAD_RESERVE);
+
+	*(char *)skb_put(skb, 1) = ch;
+
+	if ((rfcomm_dlc_send(dlc, skb)) < 0)
+		kfree_skb(skb);	
+}
+
 static int rfcomm_tty_write_room(struct tty_struct *tty)
 {
 	struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
@@ -879,6 +900,7 @@
 
 	open:			rfcomm_tty_open,
 	close:			rfcomm_tty_close,
+	put_char:		rfcomm_tty_put_char,
 	write:			rfcomm_tty_write,
 	write_room:		rfcomm_tty_write_room,
 	chars_in_buffer:	rfcomm_tty_chars_in_buffer,
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/sco.c linux-2.4.22-pre2/net/bluetooth/sco.c
--- linux-2.4.21/net/bluetooth/sco.c	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/sco.c	2003-06-26 21:43:33.000000000 +0000
@@ -332,8 +332,10 @@
 	BT_DBG("parent %p", parent);
 
 	/* Close not yet accepted channels */
-	while ((sk = bluez_accept_dequeue(parent, NULL)))
+	while ((sk = bluez_accept_dequeue(parent, NULL))) {
 		sco_sock_close(sk);
+		sco_sock_kill(sk);
+	}
 
 	parent->state  = BT_CLOSED;
 	parent->zapped = 1;
@@ -388,8 +390,6 @@
 	};
 
 	release_sock(sk);
-
-	sco_sock_kill(sk);
 }
 
 static void sco_sock_init(struct sock *sk, struct sock *parent)
@@ -508,7 +508,8 @@
 	if ((err = sco_connect(sk)))
 		goto done;
 
-	err = bluez_sock_w4_connect(sk, flags);
+	err = bluez_sock_wait_state(sk, BT_CONNECTED,
+			sock_sndtimeo(sk, flags & O_NONBLOCK));
 
 done:
 	release_sock(sk);
@@ -712,16 +713,23 @@
 static int sco_sock_release(struct socket *sock)
 {
 	struct sock *sk = sock->sk;
+	int err = 0;
 
 	BT_DBG("sock %p, sk %p", sock, sk);
 
 	if (!sk)
 		return 0;
 
-	sock_orphan(sk);
 	sco_sock_close(sk);
+	if (sk->linger) {
+		lock_sock(sk);
+		err = bluez_sock_wait_state(sk, BT_CLOSED, sk->lingertime);
+		release_sock(sk);
+	}
 
-	return 0;
+	sock_orphan(sk);
+	sco_sock_kill(sk);
+	return err;
 }
 
 static void __sco_chan_add(struct sco_conn *conn, struct sock *sk, struct sock *parent)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/bluetooth/syms.c linux-2.4.22-pre2/net/bluetooth/syms.c
--- linux-2.4.21/net/bluetooth/syms.c	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/net/bluetooth/syms.c	2003-06-26 21:43:27.000000000 +0000
@@ -78,4 +78,4 @@
 EXPORT_SYMBOL(bluez_sock_poll);
 EXPORT_SYMBOL(bluez_accept_enqueue);
 EXPORT_SYMBOL(bluez_accept_dequeue);
-EXPORT_SYMBOL(bluez_sock_w4_connect);
+EXPORT_SYMBOL(bluez_sock_wait_state);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/core/dev.c linux-2.4.22-pre2/net/core/dev.c
--- linux-2.4.21/net/core/dev.c	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/net/core/dev.c	2003-06-26 21:43:22.000000000 +0000
@@ -1372,8 +1372,10 @@
 {
 	struct net_device *dev = skb->dev;
 
-	if (dev->master)
+	if (dev->master) {
+		skb->real_dev = skb->dev;
 		skb->dev = dev->master;
+	}
 }
 
 static void net_tx_action(struct softirq_action *h)
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/core/dst.c linux-2.4.22-pre2/net/core/dst.c
--- linux-2.4.21/net/core/dst.c	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/net/core/dst.c	2003-06-26 21:43:28.000000000 +0000
@@ -105,6 +105,7 @@
 	if (!dst)
 		return NULL;
 	memset(dst, 0, ops->entry_size);
+	atomic_set(&dst->__refcnt, 0);
 	dst->ops = ops;
 	dst->lastuse = jiffies;
 	dst->input = dst_discard;
@@ -131,11 +132,9 @@
 	dst->next = dst_garbage_list;
 	dst_garbage_list = dst;
 	if (dst_gc_timer_inc > DST_GC_INC) {
-		del_timer(&dst_gc_timer);
 		dst_gc_timer_inc = DST_GC_INC;
 		dst_gc_timer_expires = DST_GC_MIN;
-		dst_gc_timer.expires = jiffies + dst_gc_timer_expires;
-		add_timer(&dst_gc_timer);
+		mod_timer(&dst_gc_timer, jiffies + dst_gc_timer_expires);
 	}
 
 	spin_unlock_bh(&dst_lock);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/core/neighbour.c linux-2.4.22-pre2/net/core/neighbour.c
--- linux-2.4.21/net/core/neighbour.c	2002-08-03 00:39:46.000000000 +0000
+++ linux-2.4.22-pre2/net/core/neighbour.c	2003-06-26 21:43:11.000000000 +0000
@@ -435,8 +435,8 @@
 	struct hh_cache *hh;
 
 	if (!neigh->dead) {
-		printk("Destroying alive neighbour %p from %08lx\n", neigh,
-		       *(((unsigned long*)&neigh)-1));
+		printk("Destroying alive neighbour %p\n", neigh);
+		dump_stack();
 		return;
 	}
 
@@ -1069,6 +1069,7 @@
 				return NULL;
 			}
 		}
+		p->sysctl_table = NULL;
 		write_lock_bh(&tbl->lock);
 		p->next = tbl->parms.next;
 		tbl->parms.next = p;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/core/rtnetlink.c linux-2.4.22-pre2/net/core/rtnetlink.c
--- linux-2.4.21/net/core/rtnetlink.c	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/net/core/rtnetlink.c	2003-06-26 21:43:22.000000000 +0000
@@ -394,7 +394,7 @@
  * Malformed skbs with wrong lengths of messages are discarded silently.
  */
 
-static __inline__ int rtnetlink_rcv_skb(struct sk_buff *skb)
+static inline int rtnetlink_rcv_skb(struct sk_buff *skb)
 {
 	int err;
 	struct nlmsghdr * nlh;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/core/skbuff.c linux-2.4.22-pre2/net/core/skbuff.c
--- linux-2.4.21/net/core/skbuff.c	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/net/core/skbuff.c	2003-06-26 21:43:13.000000000 +0000
@@ -231,6 +231,7 @@
 	skb->sk = NULL;
 	skb->stamp.tv_sec=0;	/* No idea about time */
 	skb->dev = NULL;
+	skb->real_dev = NULL;
 	skb->dst = NULL;
 	memset(skb->cb, 0, sizeof(skb->cb));
 	skb->pkt_type = PACKET_HOST;	/* Default type */
@@ -362,6 +363,7 @@
 	n->sk = NULL;
 	C(stamp);
 	C(dev);
+	C(real_dev);
 	C(h);
 	C(nh);
 	C(mac);
@@ -417,6 +419,7 @@
 	new->list=NULL;
 	new->sk=NULL;
 	new->dev=old->dev;
+	new->real_dev=old->real_dev;
 	new->priority=old->priority;
 	new->protocol=old->protocol;
 	new->dst=dst_clone(old->dst);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ethernet/eth.c linux-2.4.22-pre2/net/ethernet/eth.c
--- linux-2.4.21/net/ethernet/eth.c	2001-03-02 19:02:15.000000000 +0000
+++ linux-2.4.22-pre2/net/ethernet/eth.c	2003-06-26 21:43:22.000000000 +0000
@@ -216,9 +216,12 @@
 int eth_header_cache(struct neighbour *neigh, struct hh_cache *hh)
 {
 	unsigned short type = hh->hh_type;
-	struct ethhdr *eth = (struct ethhdr*)(((u8*)hh->hh_data) + 2);
+	struct ethhdr *eth;
 	struct net_device *dev = neigh->dev;
 
+	eth = (struct ethhdr*)
+		(((u8*)hh->hh_data) + (HH_DATA_OFF(sizeof(*eth))));
+
 	if (type == __constant_htons(ETH_P_802_3))
 		return -1;
 
@@ -235,5 +238,6 @@
 
 void eth_header_cache_update(struct hh_cache *hh, struct net_device *dev, unsigned char * haddr)
 {
-	memcpy(((u8*)hh->hh_data) + 2, haddr, dev->addr_len);
+	memcpy(((u8*)hh->hh_data) + HH_DATA_OFF(sizeof(struct ethhdr)),
+	       haddr, dev->addr_len);
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/Config.in linux-2.4.22-pre2/net/ipv4/Config.in
--- linux-2.4.21/net/ipv4/Config.in	2001-12-21 17:42:05.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/Config.in	2003-06-26 21:43:11.000000000 +0000
@@ -14,7 +14,6 @@
    bool '    IP: equal cost multipath' CONFIG_IP_ROUTE_MULTIPATH
    bool '    IP: use TOS value as routing key' CONFIG_IP_ROUTE_TOS
    bool '    IP: verbose route monitoring' CONFIG_IP_ROUTE_VERBOSE
-   bool '    IP: large routing tables' CONFIG_IP_ROUTE_LARGE_TABLES
 fi
 bool '  IP: kernel level autoconfiguration' CONFIG_IP_PNP
 if [ "$CONFIG_IP_PNP" = "y" ]; then
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/fib_frontend.c linux-2.4.22-pre2/net/ipv4/fib_frontend.c
--- linux-2.4.21/net/ipv4/fib_frontend.c	2002-08-03 00:39:46.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/fib_frontend.c	2003-06-26 21:43:21.000000000 +0000
@@ -160,9 +160,9 @@
 	if (res.type != RTN_LOCAL)
 		goto out;
 	dev = FIB_RES_DEV(res);
-	if (dev)
-		atomic_inc(&dev->refcnt);
 
+	if (dev)
+		dev_hold(dev);
 out:
 	fib_res_put(&res);
 	return dev;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/fib_hash.c linux-2.4.22-pre2/net/ipv4/fib_hash.c
--- linux-2.4.21/net/ipv4/fib_hash.c	2001-12-21 17:42:05.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/fib_hash.c	2003-06-26 21:43:21.000000000 +0000
@@ -89,7 +89,7 @@
 	int		fz_nent;	/* Number of entries	*/
 
 	int		fz_divisor;	/* Hash divisor		*/
-	u32		fz_hashmask;	/* (1<<fz_divisor) - 1	*/
+	u32		fz_hashmask;	/* (fz_divisor - 1)	*/
 #define FZ_HASHMASK(fz)	((fz)->fz_hashmask)
 
 	int		fz_order;	/* Zone order		*/
@@ -149,9 +149,19 @@
 
 static rwlock_t fib_hash_lock = RW_LOCK_UNLOCKED;
 
-#define FZ_MAX_DIVISOR 1024
+#define FZ_MAX_DIVISOR ((PAGE_SIZE<<MAX_ORDER) / sizeof(struct fib_node *))
 
-#ifdef CONFIG_IP_ROUTE_LARGE_TABLES
+static struct fib_node **fz_hash_alloc(int divisor)
+{
+	unsigned long size = divisor * sizeof(struct fib_node *);
+
+	if (divisor <= 1024) {
+		return kmalloc(size, GFP_KERNEL);
+	} else {
+		return (struct fib_node **)
+			__get_free_pages(GFP_KERNEL, get_order(size));
+	}
+}
 
 /* The fib hash lock must be held when this is called. */
 static __inline__ void fn_rebuild_zone(struct fn_zone *fz,
@@ -174,6 +184,15 @@
 	}
 }
 
+static void fz_hash_free(struct fib_node **hash, int divisor)
+{
+	if (divisor <= 1024)
+		kfree(hash);
+	else
+		free_pages((unsigned long) hash,
+			   get_order(divisor * sizeof(struct fib_node *)));
+}
+
 static void fn_rehash_zone(struct fn_zone *fz)
 {
 	struct fib_node **ht, **old_ht;
@@ -185,24 +204,30 @@
 	switch (old_divisor) {
 	case 16:
 		new_divisor = 256;
-		new_hashmask = 0xFF;
 		break;
 	case 256:
 		new_divisor = 1024;
-		new_hashmask = 0x3FF;
 		break;
 	default:
-		printk(KERN_CRIT "route.c: bad divisor %d!\n", old_divisor);
-		return;
+		if ((old_divisor << 1) > FZ_MAX_DIVISOR) {
+			printk(KERN_CRIT "route.c: bad divisor %d!\n", old_divisor);
+			return;
+		}
+		new_divisor = (old_divisor << 1);
+		break;
 	}
+
+	new_hashmask = (new_divisor - 1);
+
 #if RT_CACHE_DEBUG >= 2
 	printk("fn_rehash_zone: hash for zone %d grows from %d\n", fz->fz_order, old_divisor);
 #endif
 
-	ht = kmalloc(new_divisor*sizeof(struct fib_node*), GFP_KERNEL);
+	ht = fz_hash_alloc(new_divisor);
 
 	if (ht)	{
 		memset(ht, 0, new_divisor*sizeof(struct fib_node*));
+
 		write_lock_bh(&fib_hash_lock);
 		old_ht = fz->fz_hash;
 		fz->fz_hash = ht;
@@ -210,10 +235,10 @@
 		fz->fz_divisor = new_divisor;
 		fn_rebuild_zone(fz, old_ht, old_divisor);
 		write_unlock_bh(&fib_hash_lock);
-		kfree(old_ht);
+
+		fz_hash_free(old_ht, old_divisor);
 	}
 }
-#endif /* CONFIG_IP_ROUTE_LARGE_TABLES */
 
 static void fn_free_node(struct fib_node * f)
 {
@@ -233,12 +258,11 @@
 	memset(fz, 0, sizeof(struct fn_zone));
 	if (z) {
 		fz->fz_divisor = 16;
-		fz->fz_hashmask = 0xF;
 	} else {
 		fz->fz_divisor = 1;
-		fz->fz_hashmask = 0;
 	}
-	fz->fz_hash = kmalloc(fz->fz_divisor*sizeof(struct fib_node*), GFP_KERNEL);
+	fz->fz_hashmask = (fz->fz_divisor - 1);
+	fz->fz_hash = fz_hash_alloc(fz->fz_divisor);
 	if (!fz->fz_hash) {
 		kfree(fz);
 		return NULL;
@@ -467,12 +491,10 @@
 	if  ((fi = fib_create_info(r, rta, n, &err)) == NULL)
 		return err;
 
-#ifdef CONFIG_IP_ROUTE_LARGE_TABLES
-	if (fz->fz_nent > (fz->fz_divisor<<2) &&
+	if (fz->fz_nent > (fz->fz_divisor<<1) &&
 	    fz->fz_divisor < FZ_MAX_DIVISOR &&
 	    (z==32 || (1<<z) > fz->fz_divisor))
 		fn_rehash_zone(fz);
-#endif
 
 	fp = fz_chain_p(key, fz);
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/fib_semantics.c linux-2.4.22-pre2/net/ipv4/fib_semantics.c
--- linux-2.4.21/net/ipv4/fib_semantics.c	2003-06-26 21:45:12.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/fib_semantics.c	2003-06-26 21:43:13.000000000 +0000
@@ -368,7 +368,7 @@
 			if (!(dev->flags&IFF_UP))
 				return -ENETDOWN;
 			nh->nh_dev = dev;
-			atomic_inc(&dev->refcnt);
+			dev_hold(dev);
 			nh->nh_scope = RT_SCOPE_LINK;
 			return 0;
 		}
@@ -389,7 +389,7 @@
 		nh->nh_oif = FIB_RES_OIF(res);
 		if ((nh->nh_dev = FIB_RES_DEV(res)) == NULL)
 			goto out;
-		atomic_inc(&nh->nh_dev->refcnt);
+		dev_hold(nh->nh_dev);
 		err = -ENETDOWN;
 		if (!(nh->nh_dev->flags & IFF_UP))
 			goto out;
@@ -411,7 +411,7 @@
 			return -ENETDOWN;
 		}
 		nh->nh_dev = in_dev->dev;
-		atomic_inc(&nh->nh_dev->refcnt);
+		dev_hold(nh->nh_dev);
 		nh->nh_scope = RT_SCOPE_HOST;
 		in_dev_put(in_dev);
 	}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/icmp.c linux-2.4.22-pre2/net/ipv4/icmp.c
--- linux-2.4.21/net/ipv4/icmp.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/icmp.c	2003-06-26 21:43:18.000000000 +0000
@@ -595,8 +595,11 @@
 		if (inet_addr_type(iph->daddr) == RTN_BROADCAST)
 		{
 			if (net_ratelimit())
-				printk(KERN_WARNING "%u.%u.%u.%u sent an invalid ICMP error to a broadcast.\n",
-			       	NIPQUAD(skb->nh.iph->saddr));
+				printk(KERN_WARNING "%u.%u.%u.%u sent an invalid ICMP type %u, code %u error to a broadcast: %u.%u.%u.%u on %s\n",
+					NIPQUAD(iph->saddr),
+					icmph->type, icmph->code,
+					NIPQUAD(iph->daddr),
+					skb->dev->name);
 			goto out;
 		}
 	}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/igmp.c linux-2.4.22-pre2/net/ipv4/igmp.c
--- linux-2.4.21/net/ipv4/igmp.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/igmp.c	2003-06-26 21:43:33.000000000 +0000
@@ -68,6 +68,8 @@
  *		Alan Cox:		Forget to enable FDDI support earlier.
  *		Alexey Kuznetsov:	Fixed leaving groups on device down.
  *		Alexey Kuznetsov:	Accordance to igmp-v2-06 draft.
+ *		David L Stevens:	IGMPv3 support, with help from
+ *					Vinay Kulkarni
  */
 
 
@@ -102,11 +104,10 @@
 #define IP_MAX_MEMBERSHIPS 20
 
 #ifdef CONFIG_IP_MULTICAST
-
-
 /* Parameter names and values are taken from igmp-v2-06 draft */
 
 #define IGMP_V1_Router_Present_Timeout		(400*HZ)
+#define IGMP_V2_Router_Present_Timeout		(400*HZ)
 #define IGMP_Unsolicited_Report_Interval	(10*HZ)
 #define IGMP_Query_Response_Interval		(10*HZ)
 #define IGMP_Unsolicited_Report_Count		2
@@ -121,9 +122,20 @@
  * contradict to specs provided this delay is small enough.
  */
 
-#define IGMP_V1_SEEN(in_dev) ((in_dev)->mr_v1_seen && (long)(jiffies - (in_dev)->mr_v1_seen) < 0)
-
+#define IGMP_V1_SEEN(in_dev) ((in_dev)->mr_v1_seen && \
+		time_before(jiffies, (in_dev)->mr_v1_seen))
+#define IGMP_V2_SEEN(in_dev) ((in_dev)->mr_v2_seen && \
+		time_before(jiffies, (in_dev)->mr_v2_seen))
+
+static void igmpv3_add_delrec(struct in_device *in_dev, struct ip_mc_list *im);
+static void igmpv3_del_delrec(struct in_device *in_dev, __u32 multiaddr);
+static void igmpv3_clear_delrec(struct in_device *in_dev);
+static int sf_setstate(struct ip_mc_list *pmc);
+static void sf_markstate(struct ip_mc_list *pmc);
 #endif
+static void ip_mc_clear_src(struct ip_mc_list *pmc);
+int ip_mc_add_src(struct in_device *in_dev, __u32 *pmca, int sfmode,
+	int sfcount, __u32 *psfsrc, int delta);
 
 static void ip_ma_put(struct ip_mc_list *im)
 {
@@ -160,6 +172,23 @@
 		atomic_inc(&im->refcnt);
 }
 
+static void igmp_gq_start_timer(struct in_device *in_dev)
+{
+	int tv = net_random() % in_dev->mr_maxdelay;
+
+	in_dev->mr_gq_running = 1;
+	if (!mod_timer(&in_dev->mr_gq_timer, jiffies+tv+2))
+		in_dev_hold(in_dev);
+}
+
+static void igmp_ifc_start_timer(struct in_device *in_dev, int delay)
+{
+	int tv = net_random() % delay;
+
+	if (!mod_timer(&in_dev->mr_ifc_timer, jiffies+tv+2))
+		in_dev_hold(in_dev);
+}
+
 static void igmp_mod_timer(struct ip_mc_list *im, int max_delay)
 {
 	spin_lock_bh(&im->lock);
@@ -192,20 +221,400 @@
 	return skb->dst->output(skb);
 }
 
-static int igmp_send_report(struct net_device *dev, u32 group, int type)
+
+static int is_in(struct ip_mc_list *pmc, struct ip_sf_list *psf, int type,
+	int gdeleted, int sdeleted)
+{
+	switch (type) {
+	case IGMPV3_MODE_IS_INCLUDE:
+	case IGMPV3_MODE_IS_EXCLUDE:
+		if (gdeleted || sdeleted)
+			return 0;
+		return !(pmc->gsquery && !psf->sf_gsresp);
+	case IGMPV3_CHANGE_TO_INCLUDE:
+		if (gdeleted || sdeleted)
+			return 0;
+		return psf->sf_count[MCAST_INCLUDE] != 0;
+	case IGMPV3_CHANGE_TO_EXCLUDE:
+		if (gdeleted || sdeleted)
+			return 0;
+		if (pmc->sfcount[MCAST_EXCLUDE] == 0 ||
+		    psf->sf_count[MCAST_INCLUDE])
+			return 0;
+		return pmc->sfcount[MCAST_EXCLUDE] ==
+			psf->sf_count[MCAST_EXCLUDE];
+	case IGMPV3_ALLOW_NEW_SOURCES:
+		if (gdeleted || !psf->sf_crcount)
+			return 0;
+		return (pmc->sfmode == MCAST_INCLUDE) ^ sdeleted;
+	case IGMPV3_BLOCK_OLD_SOURCES:
+		if (pmc->sfmode == MCAST_INCLUDE)
+			return gdeleted || (psf->sf_crcount && sdeleted);
+		return psf->sf_crcount && !gdeleted && !sdeleted;
+	}
+	return 0;
+}
+
+static int
+igmp_scount(struct ip_mc_list *pmc, int type, int gdeleted, int sdeleted)
+{
+	struct ip_sf_list *psf;
+	int scount = 0;
+
+	for (psf=pmc->sources; psf; psf=psf->sf_next) {
+		if (!is_in(pmc, psf, type, gdeleted, sdeleted))
+			continue;
+		scount++;
+	}
+	return scount;
+}
+
+static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
+{
+	struct sk_buff *skb;
+	struct rtable *rt;
+	struct iphdr *pip;
+	struct igmpv3_report *pig;
+	u32	dst;
+
+	dst = IGMPV3_ALL_MCR;
+	if (ip_route_output(&rt, dst, 0, 0, dev->ifindex))
+		return 0;
+	if (rt->rt_src == 0) {
+		ip_rt_put(rt);
+		return 0;
+	}
+	skb = alloc_skb(size + dev->hard_header_len + 15, GFP_ATOMIC);
+	if (skb == NULL)
+		return 0;
+
+	skb->dst = &rt->u.dst;
+	skb->dev = dev;
+
+	skb_reserve(skb, (dev->hard_header_len+15)&~15);
+
+	skb->nh.iph = pip =(struct iphdr *)skb_put(skb, sizeof(struct iphdr)+4);
+
+	pip->version  = 4;
+	pip->ihl      = (sizeof(struct iphdr)+4)>>2;
+	pip->tos      = 0xc0;
+	pip->frag_off = htons(IP_DF);
+	pip->ttl      = 1;
+	pip->daddr    = rt->rt_dst;
+	pip->saddr    = rt->rt_src;
+	pip->protocol = IPPROTO_IGMP;
+	pip->tot_len  = 0;	/* filled in later */
+	ip_select_ident(pip, &rt->u.dst, NULL);
+	((u8*)&pip[1])[0] = IPOPT_RA;
+	((u8*)&pip[1])[1] = 4;
+	((u8*)&pip[1])[2] = 0;
+	((u8*)&pip[1])[3] = 0;
+
+	pig =(struct igmpv3_report *)skb_put(skb, sizeof(*pig));
+	skb->h.igmph = (struct igmphdr *)pig;
+	pig->type = IGMPV3_HOST_MEMBERSHIP_REPORT;
+	pig->resv1 = 0;
+	pig->csum = 0;
+	pig->resv2 = 0;
+	pig->ngrec = 0;
+	return skb;
+}
+
+static int igmpv3_sendpack(struct sk_buff *skb)
+{
+	struct iphdr *pip = skb->nh.iph;
+	struct igmphdr *pig = skb->h.igmph;
+	int iplen, igmplen;
+
+	iplen = skb->tail - (unsigned char *)skb->nh.iph;
+	pip->tot_len = htons(iplen);
+	ip_send_check(pip);
+
+	igmplen = skb->tail - (unsigned char *)skb->h.igmph;
+	pig->csum = ip_compute_csum((void *)skb->h.igmph, igmplen);
+
+	return NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, skb->dev,
+		       output_maybe_reroute);
+}
+
+static int grec_size(struct ip_mc_list *pmc, int type, int gdel, int sdel)
+{
+	return sizeof(struct igmpv3_grec) + 4*igmp_scount(pmc,type,gdel,sdel);
+}
+
+static struct sk_buff *add_grhead(struct sk_buff *skb, struct ip_mc_list *pmc,
+	int type, struct igmpv3_grec **ppgr)
+{
+	struct net_device *dev = pmc->interface->dev;
+	struct igmpv3_report *pih;
+	struct igmpv3_grec *pgr;
+
+	if (!skb)
+		skb = igmpv3_newpack(dev, dev->mtu);
+	if (!skb)
+		return 0;
+	pgr = (struct igmpv3_grec *)skb_put(skb, sizeof(struct igmpv3_grec));
+	pgr->grec_type = type;
+	pgr->grec_auxwords = 0;
+	pgr->grec_nsrcs = 0;
+	pgr->grec_mca = pmc->multiaddr;
+	pih = (struct igmpv3_report *)skb->h.igmph;
+	pih->ngrec = htons(ntohs(pih->ngrec)+1);
+	*ppgr = pgr;
+	return skb;
+}
+
+#define AVAILABLE(skb) ((skb) ? ((skb)->dev ? (skb)->dev->mtu - (skb)->len : \
+	skb_tailroom(skb)) : 0)
+
+static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,
+	int type, int gdeleted, int sdeleted)
+{
+	struct net_device *dev = pmc->interface->dev;
+	struct igmpv3_report *pih;
+	struct igmpv3_grec *pgr = 0;
+	struct ip_sf_list *psf, *psf_next, *psf_prev, *psf_list;
+	int scount, first, isquery, truncate;
+
+	if (pmc->multiaddr == IGMP_ALL_HOSTS)
+		return skb;
+
+	isquery = type == IGMPV3_MODE_IS_INCLUDE ||
+		  type == IGMPV3_MODE_IS_EXCLUDE;
+	truncate = type == IGMPV3_MODE_IS_EXCLUDE ||
+		    type == IGMPV3_CHANGE_TO_EXCLUDE;
+
+	psf_list = sdeleted ? pmc->tomb : pmc->sources;
+
+	if (!psf_list) {
+		if (type == IGMPV3_ALLOW_NEW_SOURCES ||
+		    type == IGMPV3_BLOCK_OLD_SOURCES)
+			return skb;
+		if (pmc->crcount || isquery) {
+			/* make sure we have room for group header and at
+			 * least one source.
+			 */
+			if (skb && AVAILABLE(skb) < sizeof(struct igmpv3_grec)+
+			    sizeof(__u32)) {
+				igmpv3_sendpack(skb);
+				skb = 0; /* add_grhead will get a new one */
+			}
+			skb = add_grhead(skb, pmc, type, &pgr);
+		}
+		return skb;
+	}
+	pih = skb ? (struct igmpv3_report *)skb->h.igmph : 0;
+
+	/* EX and TO_EX get a fresh packet, if needed */
+	if (truncate) {
+		if (pih && pih->ngrec &&
+		    AVAILABLE(skb) < grec_size(pmc, type, gdeleted, sdeleted)) {
+			if (skb)
+				igmpv3_sendpack(skb);
+			skb = igmpv3_newpack(dev, dev->mtu);
+		}
+	}
+	first = 1;
+	scount = 0;
+	psf_prev = 0;
+	for (psf=psf_list; psf; psf=psf_next) {
+		u32 *psrc;
+
+		psf_next = psf->sf_next;
+
+		if (!is_in(pmc, psf, type, gdeleted, sdeleted)) {
+			psf_prev = psf;
+			continue;
+		}
+
+		/* clear marks on query responses */
+		if (isquery)
+			psf->sf_gsresp = 0;
+
+		if (AVAILABLE(skb) < sizeof(u32) +
+		    first*sizeof(struct igmpv3_grec)) {
+			if (truncate && !first)
+				break;	 /* truncate these */
+			if (pgr)
+				pgr->grec_nsrcs = htons(scount);
+			if (skb)
+				igmpv3_sendpack(skb);
+			skb = igmpv3_newpack(dev, dev->mtu);
+			first = 1;
+			scount = 0;
+		}
+		if (first) {
+			skb = add_grhead(skb, pmc, type, &pgr);
+			first = 0;
+		}
+		psrc = (u32 *)skb_put(skb, sizeof(u32));
+		*psrc = psf->sf_inaddr;
+		scount++;
+		if ((type == IGMPV3_ALLOW_NEW_SOURCES ||
+		     type == IGMPV3_BLOCK_OLD_SOURCES) && psf->sf_crcount) {
+			psf->sf_crcount--;
+			if ((sdeleted || gdeleted) && psf->sf_crcount == 0) {
+				if (psf_prev)
+					psf_prev->sf_next = psf->sf_next;
+				else
+					pmc->tomb = psf->sf_next;
+				kfree(psf);
+				continue;
+			}
+		}
+		psf_prev = psf;
+	}
+	if (pgr)
+		pgr->grec_nsrcs = htons(scount);
+
+	if (isquery)
+		pmc->gsquery = 0;	/* clear query state on report */
+	return skb;
+}
+
+static int igmpv3_send_report(struct in_device *in_dev, struct ip_mc_list *pmc)
+{
+	struct sk_buff *skb = 0;
+	int type;
+
+	if (!pmc) {
+		read_lock(&in_dev->lock);
+		for (pmc=in_dev->mc_list; pmc; pmc=pmc->next) {
+			if (pmc->multiaddr == IGMP_ALL_HOSTS)
+				continue;
+			spin_lock_bh(&pmc->lock);
+			if (pmc->sfcount[MCAST_EXCLUDE])
+				type = IGMPV3_MODE_IS_EXCLUDE;
+			else
+				type = IGMPV3_MODE_IS_INCLUDE;
+			skb = add_grec(skb, pmc, type, 0, 0);
+			spin_unlock_bh(&pmc->lock);
+		}
+		read_unlock(&in_dev->lock);
+	} else {
+		spin_lock_bh(&pmc->lock);
+		if (pmc->sfcount[MCAST_EXCLUDE])
+			type = IGMPV3_MODE_IS_EXCLUDE;
+		else
+			type = IGMPV3_MODE_IS_INCLUDE;
+		skb = add_grec(skb, pmc, type, 0, 0);
+		spin_unlock_bh(&pmc->lock);
+	}
+	if (!skb)
+		return 0;
+	return igmpv3_sendpack(skb);
+}
+
+/*
+ * remove zero-count source records from a source filter list
+ */
+static void igmpv3_clear_zeros(struct ip_sf_list **ppsf)
+{
+	struct ip_sf_list *psf_prev, *psf_next, *psf;
+
+	psf_prev = 0;
+	for (psf=*ppsf; psf; psf = psf_next) {
+		psf_next = psf->sf_next;
+		if (psf->sf_crcount == 0) {
+			if (psf_prev)
+				psf_prev->sf_next = psf->sf_next;
+			else
+				*ppsf = psf->sf_next;
+			kfree(psf);
+		} else
+			psf_prev = psf;
+	}
+}
+
+static void igmpv3_send_cr(struct in_device *in_dev)
+{
+	struct ip_mc_list *pmc, *pmc_prev, *pmc_next;
+	struct sk_buff *skb = 0;
+	int type, dtype;
+
+	read_lock(&in_dev->lock);
+	write_lock_bh(&in_dev->mc_lock);
+
+	/* deleted MCA's */
+	pmc_prev = 0;
+	for (pmc=in_dev->mc_tomb; pmc; pmc=pmc_next) {
+		pmc_next = pmc->next;
+		if (pmc->sfmode == MCAST_INCLUDE) {
+			type = IGMPV3_BLOCK_OLD_SOURCES;
+			dtype = IGMPV3_BLOCK_OLD_SOURCES;
+			skb = add_grec(skb, pmc, type, 1, 0);
+			skb = add_grec(skb, pmc, dtype, 1, 1);
+		}
+		if (pmc->crcount) {
+			pmc->crcount--;
+			if (pmc->sfmode == MCAST_EXCLUDE) {
+				type = IGMPV3_CHANGE_TO_INCLUDE;
+				skb = add_grec(skb, pmc, type, 1, 0);
+			}
+			if (pmc->crcount == 0) {
+				igmpv3_clear_zeros(&pmc->tomb);
+				igmpv3_clear_zeros(&pmc->sources);
+			}
+		}
+		if (pmc->crcount == 0 && !pmc->tomb && !pmc->sources) {
+			if (pmc_prev)
+				pmc_prev->next = pmc_next;
+			else
+				in_dev->mc_tomb = pmc_next;
+			in_dev_put(pmc->interface);
+			kfree(pmc);
+		} else
+			pmc_prev = pmc;
+	}
+	write_unlock_bh(&in_dev->mc_lock);
+
+	/* change recs */
+	for (pmc=in_dev->mc_list; pmc; pmc=pmc->next) {
+		spin_lock_bh(&pmc->lock);
+		if (pmc->sfcount[MCAST_EXCLUDE]) {
+			type = IGMPV3_BLOCK_OLD_SOURCES;
+			dtype = IGMPV3_ALLOW_NEW_SOURCES;
+		} else {
+			type = IGMPV3_ALLOW_NEW_SOURCES;
+			dtype = IGMPV3_BLOCK_OLD_SOURCES;
+		}
+		skb = add_grec(skb, pmc, type, 0, 0);
+		skb = add_grec(skb, pmc, dtype, 0, 1);	/* deleted sources */
+
+		/* filter mode changes */
+		if (pmc->crcount) {
+			pmc->crcount--;
+			if (pmc->sfmode == MCAST_EXCLUDE)
+				type = IGMPV3_CHANGE_TO_EXCLUDE;
+			else
+				type = IGMPV3_CHANGE_TO_INCLUDE;
+			skb = add_grec(skb, pmc, type, 0, 0);
+		}
+		spin_unlock_bh(&pmc->lock);
+	}
+	read_unlock(&in_dev->lock);
+	if (!skb)
+		return;
+	(void) igmpv3_sendpack(skb);
+}
+
+static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
+	int type)
 {
 	struct sk_buff *skb;
 	struct iphdr *iph;
 	struct igmphdr *ih;
 	struct rtable *rt;
+	struct net_device *dev = in_dev->dev;
+	u32	group = pmc ? pmc->multiaddr : 0;
 	u32	dst;
 
-	/* According to IGMPv2 specs, LEAVE messages are
-	 * sent to all-routers group.
-	 */
-	dst = group;
-	if (type == IGMP_HOST_LEAVE_MESSAGE)
+	if (type == IGMPV3_HOST_MEMBERSHIP_REPORT)
+		return igmpv3_send_report(in_dev, pmc);
+	else if (type == IGMP_HOST_LEAVE_MESSAGE)
 		dst = IGMP_ALL_ROUTER;
+	else
+		dst = group;
 
 	if (ip_route_output(&rt, dst, 0, 0, dev->ifindex))
 		return -1;
@@ -228,7 +637,7 @@
 
 	iph->version  = 4;
 	iph->ihl      = (sizeof(struct iphdr)+4)>>2;
-	iph->tos      = 0;
+	iph->tos      = 0xc0;
 	iph->frag_off = htons(IP_DF);
 	iph->ttl      = 1;
 	iph->daddr    = dst;
@@ -253,6 +662,36 @@
 		       output_maybe_reroute);
 }
 
+static void igmp_gq_timer_expire(unsigned long data)
+{
+	struct in_device *in_dev = (struct in_device *)data;
+
+	in_dev->mr_gq_running = 0;
+	igmpv3_send_report(in_dev, 0);
+	__in_dev_put(in_dev);
+}
+
+static void igmp_ifc_timer_expire(unsigned long data)
+{
+	struct in_device *in_dev = (struct in_device *)data;
+
+	igmpv3_send_cr(in_dev);
+	if (in_dev->mr_ifc_count) {
+		in_dev->mr_ifc_count--;
+		igmp_ifc_start_timer(in_dev, IGMP_Unsolicited_Report_Interval);
+	}
+	__in_dev_put(in_dev);
+}
+
+static void igmp_ifc_event(struct in_device *in_dev)
+{
+	if (IGMP_V1_SEEN(in_dev) || IGMP_V2_SEEN(in_dev))
+		return;
+	in_dev->mr_ifc_count = in_dev->mr_qrv ? in_dev->mr_qrv : 
+		IGMP_Unsolicited_Report_Count;
+	igmp_ifc_start_timer(in_dev, 1);
+}
+
 
 static void igmp_timer_expire(unsigned long data)
 {
@@ -270,13 +709,33 @@
 	spin_unlock(&im->lock);
 
 	if (IGMP_V1_SEEN(in_dev))
-		igmp_send_report(in_dev->dev, im->multiaddr, IGMP_HOST_MEMBERSHIP_REPORT);
+		igmp_send_report(in_dev, im, IGMP_HOST_MEMBERSHIP_REPORT);
+	else if (IGMP_V2_SEEN(in_dev))
+		igmp_send_report(in_dev, im, IGMPV2_HOST_MEMBERSHIP_REPORT);
 	else
-		igmp_send_report(in_dev->dev, im->multiaddr, IGMP_HOST_NEW_MEMBERSHIP_REPORT);
+		igmp_send_report(in_dev, im, IGMPV3_HOST_MEMBERSHIP_REPORT);
 
 	ip_ma_put(im);
 }
 
+static void igmp_marksources(struct ip_mc_list *pmc, int nsrcs, __u32 *srcs)
+{
+	struct ip_sf_list *psf;
+	int i, scount;
+
+	scount = 0;
+	for (psf=pmc->sources; psf; psf=psf->sf_next) {
+		if (scount == nsrcs)
+			break;
+		for (i=0; i<nsrcs; i++)
+			if (srcs[i] == psf->sf_inaddr) {
+				psf->sf_gsresp = 1;
+				scount++;
+				break;
+			}
+	}
+}
+
 static void igmp_heard_report(struct in_device *in_dev, u32 group)
 {
 	struct ip_mc_list *im;
@@ -296,20 +755,53 @@
 	read_unlock(&in_dev->lock);
 }
 
-static void igmp_heard_query(struct in_device *in_dev, unsigned char max_resp_time,
-			     u32 group)
+static void igmp_heard_query(struct in_device *in_dev, struct igmphdr *ih,
+	int len)
 {
+	struct igmpv3_query *ih3 = (struct igmpv3_query *)ih;
 	struct ip_mc_list	*im;
+	u32			group = ih->group;
 	int			max_delay;
+	int			mark = 0;
 
-	max_delay = max_resp_time*(HZ/IGMP_TIMER_SCALE);
 
-	if (max_resp_time == 0) {
-		/* Alas, old v1 router presents here. */
-
-		max_delay = IGMP_Query_Response_Interval;
-		in_dev->mr_v1_seen = jiffies + IGMP_V1_Router_Present_Timeout;
-		group = 0;
+	if (len == 8) {
+		if (ih->code == 0) {
+			/* Alas, old v1 router presents here. */
+	
+			max_delay = IGMP_Query_Response_Interval;
+			in_dev->mr_v1_seen = jiffies +
+				IGMP_V1_Router_Present_Timeout;
+			group = 0;
+		} else {
+			/* v2 router present */
+			max_delay = ih->code*(HZ/IGMP_TIMER_SCALE);
+			in_dev->mr_v2_seen = jiffies +
+				IGMP_V2_Router_Present_Timeout;
+		}
+		/* cancel the interface change timer */
+		in_dev->mr_ifc_count = 0;
+		if (del_timer(&in_dev->mr_ifc_timer))
+			__in_dev_put(in_dev);
+		/* clear deleted report items */
+		igmpv3_clear_delrec(in_dev);
+	} else if (len < 12) {
+		return;	/* ignore bogus packet; freed by caller */
+	} else { /* v3 */
+		max_delay = IGMPV3_MRC(ih3->code)*(HZ/IGMP_TIMER_SCALE);
+		if (!max_delay)
+			max_delay = 1;	/* can't mod w/ 0 */
+		in_dev->mr_maxdelay = max_delay;
+		if (ih3->qrv)
+			in_dev->mr_qrv = ih3->qrv;
+		if (!group) { /* general query */
+			if (ih3->nsrcs)
+				return;	/* no sources allowed */
+			igmp_gq_start_timer(in_dev);
+			return;
+		}
+		/* mark sources to include, if group & source-specific */
+		mark = ih3->nsrcs != 0;
 	}
 
 	/*
@@ -328,6 +820,14 @@
 			continue;
 		if (im->multiaddr == IGMP_ALL_HOSTS)
 			continue;
+		spin_lock_bh(&im->lock);
+		if (im->tm_running)
+			im->gsquery = im->gsquery && mark;
+		else
+			im->gsquery = mark;
+		if (im->gsquery)
+			igmp_marksources(im, ntohs(ih3->nsrcs), ih3->srcs);
+		spin_unlock_bh(&im->lock);
 		igmp_mod_timer(im, max_delay);
 	}
 	read_unlock(&in_dev->lock);
@@ -361,10 +861,11 @@
 
 	switch (ih->type) {
 	case IGMP_HOST_MEMBERSHIP_QUERY:
-		igmp_heard_query(in_dev, ih->code, ih->group);
+		igmp_heard_query(in_dev, ih, len);
 		break;
 	case IGMP_HOST_MEMBERSHIP_REPORT:
-	case IGMP_HOST_NEW_MEMBERSHIP_REPORT:
+	case IGMPV2_HOST_MEMBERSHIP_REPORT:
+	case IGMPV3_HOST_MEMBERSHIP_REPORT:
 		/* Is it our report looped back? */
 		if (((struct rtable*)skb->dst)->key.iif == 0)
 			break;
@@ -425,15 +926,120 @@
 		dev_mc_delete(dev,buf,dev->addr_len,0);
 }
 
+#ifdef CONFIG_IP_MULTICAST
+/*
+ * deleted ip_mc_list manipulation
+ */
+static void igmpv3_add_delrec(struct in_device *in_dev, struct ip_mc_list *im)
+{
+	struct ip_mc_list *pmc;
+
+	/* this is an "ip_mc_list" for convenience; only the fields below
+	 * are actually used. In particular, the refcnt and users are not
+	 * used for management of the delete list. Using the same structure
+	 * for deleted items allows change reports to use common code with
+	 * non-deleted or query-response MCA's.
+	 */
+	pmc = (struct ip_mc_list *)kmalloc(sizeof(*pmc), GFP_KERNEL);
+	if (!pmc)
+		return;
+	memset(pmc, 0, sizeof(*pmc));
+	spin_lock_bh(&im->lock);
+	pmc->interface = im->interface;
+	in_dev_hold(in_dev);
+	pmc->multiaddr = im->multiaddr;
+	pmc->crcount = in_dev->mr_qrv ? in_dev->mr_qrv :
+		IGMP_Unsolicited_Report_Count;
+	pmc->sfmode = im->sfmode;
+	if (pmc->sfmode == MCAST_INCLUDE) {
+		struct ip_sf_list *psf;
+
+		pmc->tomb = im->tomb;
+		pmc->sources = im->sources;
+		im->tomb = im->sources = 0;
+		for (psf=pmc->sources; psf; psf=psf->sf_next)
+			psf->sf_crcount = pmc->crcount;
+	}
+	spin_unlock_bh(&im->lock);
+
+	write_lock_bh(&in_dev->mc_lock);
+	pmc->next = in_dev->mc_tomb;
+	in_dev->mc_tomb = pmc;
+	write_unlock_bh(&in_dev->mc_lock);
+}
+
+static void igmpv3_del_delrec(struct in_device *in_dev, __u32 multiaddr)
+{
+	struct ip_mc_list *pmc, *pmc_prev;
+	struct ip_sf_list *psf, *psf_next;
+
+	write_lock_bh(&in_dev->mc_lock);
+	pmc_prev = 0;
+	for (pmc=in_dev->mc_tomb; pmc; pmc=pmc->next) {
+		if (pmc->multiaddr == multiaddr)
+			break;
+		pmc_prev = pmc;
+	}
+	if (pmc) {
+		if (pmc_prev)
+			pmc_prev->next = pmc->next;
+		else
+			in_dev->mc_tomb = pmc->next;
+	}
+	write_unlock_bh(&in_dev->mc_lock);
+	if (pmc) {
+		for (psf=pmc->tomb; psf; psf=psf_next) {
+			psf_next = psf->sf_next;
+			kfree(psf);
+		}
+		in_dev_put(pmc->interface);
+		kfree(pmc);
+	}
+}
+
+static void igmpv3_clear_delrec(struct in_device *in_dev)
+{
+	struct ip_mc_list *pmc, *nextpmc;
+
+	write_lock_bh(&in_dev->mc_lock);
+	pmc = in_dev->mc_tomb;
+	in_dev->mc_tomb = 0;
+	write_unlock_bh(&in_dev->mc_lock);
+
+	for (; pmc; pmc = nextpmc) {
+		nextpmc = pmc->next;
+		ip_mc_clear_src(pmc);
+		in_dev_put(pmc->interface);
+		kfree(pmc);
+	}
+	/* clear dead sources, too */
+	read_lock(&in_dev->lock);
+	for (pmc=in_dev->mc_list; pmc; pmc=pmc->next) {
+		struct ip_sf_list *psf, *psf_next;
+
+		spin_lock_bh(&pmc->lock);
+		psf = pmc->tomb;
+		pmc->tomb = 0;
+		spin_unlock_bh(&pmc->lock);
+		for (; psf; psf=psf_next) {
+			psf_next = psf->sf_next;
+			kfree(psf);
+		}
+	}
+	read_unlock(&in_dev->lock);
+}
+#endif
+
 static void igmp_group_dropped(struct ip_mc_list *im)
 {
+	struct in_device *in_dev = im->interface;
 #ifdef CONFIG_IP_MULTICAST
 	int reporter;
 #endif
 
 	if (im->loaded) {
 		im->loaded = 0;
-		ip_mc_filter_del(im->interface, im->multiaddr);
+		ip_mc_filter_del(in_dev, im->multiaddr);
 	}
 
 #ifdef CONFIG_IP_MULTICAST
@@ -443,25 +1049,46 @@
 	reporter = im->reporter;
 	igmp_stop_timer(im);
 
-	if (reporter && !IGMP_V1_SEEN(im->interface))
-		igmp_send_report(im->interface->dev, im->multiaddr, IGMP_HOST_LEAVE_MESSAGE);
+	if (IGMP_V1_SEEN(in_dev))
+		goto done;
+	if (IGMP_V2_SEEN(in_dev)) {
+		if (reporter)
+			igmp_send_report(in_dev, im, IGMP_HOST_LEAVE_MESSAGE);
+		goto done;
+	}
+	/* IGMPv3 */
+	igmpv3_add_delrec(in_dev, im);
+
+	igmp_ifc_event(in_dev);
+done:
 #endif
+	ip_mc_clear_src(im);
 }
 
 static void igmp_group_added(struct ip_mc_list *im)
 {
+	struct in_device *in_dev = im->interface;
+
 	if (im->loaded == 0) {
 		im->loaded = 1;
-		ip_mc_filter_add(im->interface, im->multiaddr);
+		ip_mc_filter_add(in_dev, im->multiaddr);
 	}
 
 #ifdef CONFIG_IP_MULTICAST
 	if (im->multiaddr == IGMP_ALL_HOSTS)
 		return;
 
-	spin_lock_bh(&im->lock);
-	igmp_start_timer(im, IGMP_Initial_Report_Delay);
-	spin_unlock_bh(&im->lock);
+	if (IGMP_V1_SEEN(in_dev) || IGMP_V2_SEEN(in_dev)) {
+		spin_lock_bh(&im->lock);
+		igmp_start_timer(im, IGMP_Initial_Report_Delay);
+		spin_unlock_bh(&im->lock);
+		return;
+	}
+	/* else, v3 */
+
+	im->crcount = in_dev->mr_qrv ? in_dev->mr_qrv :
+		IGMP_Unsolicited_Report_Count;
+	igmp_ifc_event(in_dev);
 #endif
 }
 
@@ -484,6 +1111,7 @@
 	for (im=in_dev->mc_list; im; im=im->next) {
 		if (im->multiaddr == addr) {
 			im->users++;
+			ip_mc_add_src(in_dev, &addr, MCAST_EXCLUDE, 0, 0, 0);
 			goto out;
 		}
 	}
@@ -496,21 +1124,32 @@
 	im->interface=in_dev;
 	in_dev_hold(in_dev);
 	im->multiaddr=addr;
+	/* initial mode is (EX, empty) */
+	im->sfmode = MCAST_EXCLUDE;
+	im->sfcount[MCAST_INCLUDE] = 0;
+	im->sfcount[MCAST_EXCLUDE] = 1;
+	im->sources = 0;
+	im->tomb = 0;
+	im->crcount = 0;
 	atomic_set(&im->refcnt, 1);
 	spin_lock_init(&im->lock);
-#ifdef  CONFIG_IP_MULTICAST
+#ifdef CONFIG_IP_MULTICAST
 	im->tm_running=0;
 	init_timer(&im->timer);
 	im->timer.data=(unsigned long)im;
 	im->timer.function=&igmp_timer_expire;
 	im->unsolicit_count = IGMP_Unsolicited_Report_Count;
 	im->reporter = 0;
+	im->gsquery = 0;
 #endif
 	im->loaded = 0;
 	write_lock_bh(&in_dev->lock);
 	im->next=in_dev->mc_list;
 	in_dev->mc_list=im;
 	write_unlock_bh(&in_dev->lock);
+#ifdef CONFIG_IP_MULTICAST
+	igmpv3_del_delrec(in_dev, im->multiaddr);
+#endif
 	igmp_group_added(im);
 	if (in_dev->dev->flags & IFF_UP)
 		ip_rt_multicast_event(in_dev);
@@ -555,9 +1194,22 @@
 
 	ASSERT_RTNL();
 
+#ifdef CONFIG_IP_MULTICAST
+	in_dev->mr_ifc_count = 0;
+	if (del_timer(&in_dev->mr_ifc_timer))
+		__in_dev_put(in_dev);
+	in_dev->mr_gq_running = 0;
+	if (del_timer(&in_dev->mr_gq_timer))
+		__in_dev_put(in_dev);
+#endif
+
 	for (i=in_dev->mc_list; i; i=i->next)
 		igmp_group_dropped(i);
 
+#ifdef CONFIG_IP_MULTICAST
+	igmpv3_clear_delrec(in_dev);
+#endif
+
 	ip_mc_dec_group(in_dev, IGMP_ALL_HOSTS);
 }
 
@@ -569,6 +1221,20 @@
 
 	ASSERT_RTNL();
 
+	in_dev->mc_tomb = 0;
+#ifdef CONFIG_IP_MULTICAST
+	in_dev->mr_gq_running = 0;
+	init_timer(&in_dev->mr_gq_timer);
+	in_dev->mr_gq_timer.data=(unsigned long) in_dev;
+	in_dev->mr_gq_timer.function=&igmp_gq_timer_expire;
+	in_dev->mr_ifc_count = 0;
+	init_timer(&in_dev->mr_ifc_timer);
+	in_dev->mr_ifc_timer.data=(unsigned long) in_dev;
+	in_dev->mr_ifc_timer.function=&igmp_ifc_timer_expire;
+	in_dev->mr_qrv = IGMP_Unsolicited_Report_Count;
+#endif
+
+	in_dev->mc_lock = RW_LOCK_UNLOCKED;
 	ip_mc_inc_group(in_dev, IGMP_ALL_HOSTS);
 
 	for (i=in_dev->mc_list; i; i=i->next)
@@ -604,6 +1270,12 @@
 	struct net_device *dev = NULL;
 	struct in_device *idev = NULL;
 
+	if (imr->imr_ifindex) {
+		idev = inetdev_by_index(imr->imr_ifindex);
+		if (idev)
+			__in_dev_put(idev);
+		return idev;
+	}
 	if (imr->imr_address.s_addr) {
 		dev = ip_dev_find(imr->imr_address.s_addr);
 		if (!dev)
@@ -627,12 +1299,284 @@
  */
 int sysctl_igmp_max_memberships = IP_MAX_MEMBERSHIPS;
 
+
+static int ip_mc_del1_src(struct ip_mc_list *pmc, int sfmode,
+	__u32 *psfsrc)
+{
+	struct ip_sf_list *psf, *psf_prev;
+	int rv = 0;
+
+	psf_prev = 0;
+	for (psf=pmc->sources; psf; psf=psf->sf_next) {
+		if (psf->sf_inaddr == *psfsrc)
+			break;
+		psf_prev = psf;
+	}
+	if (!psf || psf->sf_count[sfmode] == 0) {
+		/* source filter not found, or count wrong =>  bug */
+		return -ESRCH;
+	}
+	psf->sf_count[sfmode]--;
+	if (psf->sf_count[sfmode] == 0) {
+		ip_rt_multicast_event(pmc->interface);
+	}
+	if (!psf->sf_count[MCAST_INCLUDE] && !psf->sf_count[MCAST_EXCLUDE]) {
+#ifdef CONFIG_IP_MULTICAST
+		struct in_device *in_dev = pmc->interface;
+#endif
+
+		/* no more filters for this source */
+		if (psf_prev)
+			psf_prev->sf_next = psf->sf_next;
+		else
+			pmc->sources = psf->sf_next;
+#ifdef CONFIG_IP_MULTICAST
+		if (psf->sf_oldin &&
+		    !IGMP_V1_SEEN(in_dev) && !IGMP_V2_SEEN(in_dev)) {
+			psf->sf_crcount = in_dev->mr_qrv ? in_dev->mr_qrv : 
+				IGMP_Unsolicited_Report_Count;
+			psf->sf_next = pmc->tomb;
+			pmc->tomb = psf;
+			rv = 1;
+		} else
+#endif
+			kfree(psf);
+	}
+	return rv;
+}
+
+int ip_mc_del_src(struct in_device *in_dev, __u32 *pmca, int sfmode,
+	int sfcount, __u32 *psfsrc, int delta)
+{
+	struct ip_mc_list *pmc;
+	int	changerec = 0;
+	int	i, err;
+
+	if (!in_dev)
+		return -ENODEV;
+	read_lock(&in_dev->lock);
+	for (pmc=in_dev->mc_list; pmc; pmc=pmc->next) {
+		if (*pmca == pmc->multiaddr)
+			break;
+	}
+	if (!pmc) {
+		/* MCA not found?? bug */
+		read_unlock(&in_dev->lock);
+		return -ESRCH;
+	}
+	spin_lock_bh(&pmc->lock);
+	read_unlock(&in_dev->lock);
+#ifdef CONFIG_IP_MULTICAST
+	sf_markstate(pmc);
+#endif
+	if (!delta) {
+		if (!pmc->sfcount[sfmode])
+			return -EINVAL;
+		pmc->sfcount[sfmode]--;
+	}
+	err = 0;
+	for (i=0; i<sfcount; i++) {
+		int rv = ip_mc_del1_src(pmc, sfmode, &psfsrc[i]);
+
+		changerec |= rv > 0;
+		if (!err && rv < 0)
+			err = rv;
+	}
+	if (pmc->sfmode == MCAST_EXCLUDE &&
+	    pmc->sfcount[MCAST_EXCLUDE] == 0 &&
+	    pmc->sfcount[MCAST_INCLUDE]) {
+#ifdef CONFIG_IP_MULTICAST
+		struct ip_sf_list *psf;
+#endif
+
+		/* filter mode change */
+		pmc->sfmode = MCAST_INCLUDE;
+#ifdef CONFIG_IP_MULTICAST
+		pmc->crcount = in_dev->mr_qrv ? in_dev->mr_qrv : 
+			IGMP_Unsolicited_Report_Count;
+		in_dev->mr_ifc_count = pmc->crcount;
+		for (psf=pmc->sources; psf; psf = psf->sf_next)
+			psf->sf_crcount = 0;
+		igmp_ifc_event(pmc->interface);
+	} else if (sf_setstate(pmc) || changerec) {
+		igmp_ifc_event(pmc->interface);
+#endif
+	}
+	spin_unlock_bh(&pmc->lock);
+	return err;
+}
+
+/*
+ * Add multicast single-source filter to the interface list
+ */
+static int ip_mc_add1_src(struct ip_mc_list *pmc, int sfmode,
+	__u32 *psfsrc, int delta)
+{
+	struct ip_sf_list *psf, *psf_prev;
+
+	psf_prev = 0;
+	for (psf=pmc->sources; psf; psf=psf->sf_next) {
+		if (psf->sf_inaddr == *psfsrc)
+			break;
+		psf_prev = psf;
+	}
+	if (!psf) {
+		psf = (struct ip_sf_list *)kmalloc(sizeof(*psf), GFP_ATOMIC);
+		if (!psf)
+			return -ENOBUFS;
+		memset(psf, 0, sizeof(*psf));
+		psf->sf_inaddr = *psfsrc;
+		if (psf_prev) {
+			psf_prev->sf_next = psf;
+		} else
+			pmc->sources = psf;
+	}
+	psf->sf_count[sfmode]++;
+	if (psf->sf_count[sfmode] == 1) {
+		ip_rt_multicast_event(pmc->interface);
+	}
+	return 0;
+}
+
+#ifdef CONFIG_IP_MULTICAST
+static void sf_markstate(struct ip_mc_list *pmc)
+{
+	struct ip_sf_list *psf;
+	int mca_xcount = pmc->sfcount[MCAST_EXCLUDE];
+
+	for (psf=pmc->sources; psf; psf=psf->sf_next)
+		if (pmc->sfcount[MCAST_EXCLUDE]) {
+			psf->sf_oldin = mca_xcount ==
+				psf->sf_count[MCAST_EXCLUDE] &&
+				!psf->sf_count[MCAST_INCLUDE];
+		} else
+			psf->sf_oldin = psf->sf_count[MCAST_INCLUDE] != 0;
+}
+
+static int sf_setstate(struct ip_mc_list *pmc)
+{
+	struct ip_sf_list *psf;
+	int mca_xcount = pmc->sfcount[MCAST_EXCLUDE];
+	int qrv = pmc->interface->mr_qrv;
+	int new_in, rv;
+
+	rv = 0;
+	for (psf=pmc->sources; psf; psf=psf->sf_next) {
+		if (pmc->sfcount[MCAST_EXCLUDE]) {
+			new_in = mca_xcount == psf->sf_count[MCAST_EXCLUDE] &&
+				!psf->sf_count[MCAST_INCLUDE];
+		} else
+			new_in = psf->sf_count[MCAST_INCLUDE] != 0;
+		if (new_in != psf->sf_oldin) {
+			psf->sf_crcount = qrv;
+			rv++;
+		}
+	}
+	return rv;
+}
+#endif
+
+/*
+ * Add multicast source filter list to the interface list
+ */
+int ip_mc_add_src(struct in_device *in_dev, __u32 *pmca, int sfmode,
+	int sfcount, __u32 *psfsrc, int delta)
+{
+	struct ip_mc_list *pmc;
+	int	isexclude;
+	int	i, err;
+
+	if (!in_dev)
+		return -ENODEV;
+	read_lock(&in_dev->lock);
+	for (pmc=in_dev->mc_list; pmc; pmc=pmc->next) {
+		if (*pmca == pmc->multiaddr)
+			break;
+	}
+	if (!pmc) {
+		/* MCA not found?? bug */
+		read_unlock(&in_dev->lock);
+		return -ESRCH;
+	}
+	spin_lock_bh(&pmc->lock);
+	read_unlock(&in_dev->lock);
+
+#ifdef CONFIG_IP_MULTICAST
+	sf_markstate(pmc);
+#endif
+	isexclude = pmc->sfmode == MCAST_EXCLUDE;
+	if (!delta)
+		pmc->sfcount[sfmode]++;
+	err = 0;
+	for (i=0; i<sfcount; i++) {
+		err = ip_mc_add1_src(pmc, sfmode, &psfsrc[i], delta);
+		if (err)
+			break;
+	}
+	if (err) {
+		int j;
+
+		pmc->sfcount[sfmode]--;
+		for (j=0; j<i; j++)
+			(void) ip_mc_del1_src(pmc, sfmode, &psfsrc[i]);
+	} else if (isexclude != (pmc->sfcount[MCAST_EXCLUDE] != 0)) {
+#ifdef CONFIG_IP_MULTICAST
+		struct in_device *in_dev = pmc->interface;
+		struct ip_sf_list *psf;
+#endif
+
+		/* filter mode change */
+		if (pmc->sfcount[MCAST_EXCLUDE])
+			pmc->sfmode = MCAST_EXCLUDE;
+		else if (pmc->sfcount[MCAST_INCLUDE])
+			pmc->sfmode = MCAST_INCLUDE;
+#ifdef CONFIG_IP_MULTICAST
+		/* else no filters; keep old mode for reports */
+
+		pmc->crcount = in_dev->mr_qrv ? in_dev->mr_qrv : 
+			IGMP_Unsolicited_Report_Count;
+		in_dev->mr_ifc_count = pmc->crcount;
+		for (psf=pmc->sources; psf; psf = psf->sf_next)
+			psf->sf_crcount = 0;
+		igmp_ifc_event(in_dev);
+	} else if (sf_setstate(pmc)) {
+		igmp_ifc_event(in_dev);
+#endif
+	}
+	spin_unlock_bh(&pmc->lock);
+	return err;
+}
+
+static void ip_mc_clear_src(struct ip_mc_list *pmc)
+{
+	struct ip_sf_list *psf, *nextpsf;
+
+	for (psf=pmc->tomb; psf; psf=nextpsf) {
+		nextpsf = psf->sf_next;
+		kfree(psf);
+	}
+	pmc->tomb = 0;
+	for (psf=pmc->sources; psf; psf=nextpsf) {
+		nextpsf = psf->sf_next;
+		kfree(psf);
+	}
+	pmc->sources = 0;
+	pmc->sfmode = MCAST_EXCLUDE;
+	pmc->sfcount[MCAST_EXCLUDE] = 0;
+	pmc->sfcount[MCAST_EXCLUDE] = 1;
+}
+
+
+/*
+ * Join a multicast group
+ */
 int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr)
 {
 	int err;
 	u32 addr = imr->imr_multiaddr.s_addr;
 	struct ip_mc_socklist *iml, *i;
 	struct in_device *in_dev;
+	struct inet_opt *inet = &sk->protinfo.af_inet;
 	int count = 0;
 
 	if (!MULTICAST(addr))
@@ -640,13 +1584,7 @@
 
 	rtnl_shlock();
 
-	if (!imr->imr_ifindex)
-		in_dev = ip_mc_find_dev(imr);
-	else {
-		in_dev = inetdev_by_index(imr->imr_ifindex);
-		if (in_dev)
-			__in_dev_put(in_dev);
-	}
+	in_dev = ip_mc_find_dev(imr);
 
 	if (!in_dev) {
 		iml = NULL;
@@ -657,7 +1595,7 @@
 	iml = (struct ip_mc_socklist *)sock_kmalloc(sk, sizeof(*iml), GFP_KERNEL);
 
 	err = -EADDRINUSE;
-	for (i=sk->protinfo.af_inet.mc_list; i; i=i->next) {
+	for (i = inet->mc_list; i; i = i->next) {
 		if (memcmp(&i->multi, imr, sizeof(*imr)) == 0) {
 			/* New style additions are reference counted */
 			if (imr->imr_address.s_addr == 0) {
@@ -674,7 +1612,9 @@
 	memcpy(&iml->multi, imr, sizeof(*imr));
 	iml->next = sk->protinfo.af_inet.mc_list;
 	iml->count = 1;
-	sk->protinfo.af_inet.mc_list = iml;
+	iml->sflist = NULL;
+	iml->sfmode = MCAST_EXCLUDE;
+	inet->mc_list = iml;
 	ip_mc_inc_group(in_dev, addr);
 	iml = NULL;
 	err = 0;
@@ -686,28 +1626,52 @@
 	return err;
 }
 
+int ip_mc_leave_src(struct sock *sk, struct ip_mc_socklist *iml,
+	struct in_device *in_dev)
+{
+	int err;
+
+	if (iml->sflist == 0) {
+		/* any-source empty exclude case */
+		return ip_mc_del_src(in_dev, &iml->multi.imr_multiaddr.s_addr,
+			iml->sfmode, 0, 0, 0);
+	}
+	err = ip_mc_del_src(in_dev, &iml->multi.imr_multiaddr.s_addr,
+			iml->sfmode, iml->sflist->sl_count,
+			iml->sflist->sl_addr, 0);
+	sock_kfree_s(sk, iml->sflist, IP_SFLSIZE(iml->sflist->sl_max));
+	iml->sflist = 0;
+	return err;
+}
+
 /*
  *	Ask a socket to leave a group.
  */
 
 int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr)
 {
+	struct inet_opt *inet = &sk->protinfo.af_inet;
 	struct ip_mc_socklist *iml, **imlp;
 
 	rtnl_lock();
-	for (imlp=&sk->protinfo.af_inet.mc_list; (iml=*imlp)!=NULL; imlp=&iml->next) {
+	for (imlp = &inet->mc_list; (iml = *imlp) != NULL; imlp = &iml->next) {
 		if (iml->multi.imr_multiaddr.s_addr==imr->imr_multiaddr.s_addr &&
 		    iml->multi.imr_address.s_addr==imr->imr_address.s_addr &&
 		    (!imr->imr_ifindex || iml->multi.imr_ifindex==imr->imr_ifindex)) {
 			struct in_device *in_dev;
+
+			in_dev = inetdev_by_index(iml->multi.imr_ifindex);
+			if (in_dev)
+				(void) ip_mc_leave_src(sk, iml, in_dev);
 			if (--iml->count) {
 				rtnl_unlock();
+				if (in_dev)
+					in_dev_put(in_dev);
 				return 0;
 			}
 
 			*imlp = iml->next;
 
-			in_dev = inetdev_by_index(iml->multi.imr_ifindex);
 			if (in_dev) {
 				ip_mc_dec_group(in_dev, imr->imr_multiaddr.s_addr);
 				in_dev_put(in_dev);
@@ -721,23 +1685,359 @@
 	return -EADDRNOTAVAIL;
 }
 
+int ip_mc_source(int add, int omode, struct sock *sk, struct
+	ip_mreq_source *mreqs, int ifindex)
+{
+	int err;
+	struct ip_mreqn imr;
+	u32 addr = mreqs->imr_multiaddr;
+	struct ip_mc_socklist *pmc;
+	struct in_device *in_dev = 0;
+	struct inet_opt *inet = &sk->protinfo.af_inet;
+	struct ip_sf_socklist *psl;
+	int i, j, rv;
+
+	if (!MULTICAST(addr))
+		return -EINVAL;
+
+	rtnl_shlock();
+
+	imr.imr_multiaddr.s_addr = mreqs->imr_multiaddr;
+	imr.imr_address.s_addr = mreqs->imr_interface;
+	imr.imr_ifindex = ifindex;
+	in_dev = ip_mc_find_dev(&imr);
+
+	if (!in_dev) {
+		err = -ENODEV;
+		goto done;
+	}
+	err = -EADDRNOTAVAIL;
+
+	for (pmc=inet->mc_list; pmc; pmc=pmc->next) {
+		if (memcmp(&pmc->multi, mreqs, 2*sizeof(__u32)) == 0)
+			break;
+	}
+	if (!pmc)		/* must have a prior join */
+		goto done;
+	/* if a source filter was set, must be the same mode as before */
+	if (pmc->sflist) {
+		if (pmc->sfmode != omode)
+			goto done;
+	} else if (pmc->sfmode != omode) {
+		/* allow mode switches for empty-set filters */
+		ip_mc_del_src(in_dev, &mreqs->imr_multiaddr, pmc->sfmode, 0, 
+			0, 0);
+		pmc->sfmode = omode;
+		ip_mc_add_src(in_dev, &mreqs->imr_multiaddr, pmc->sfmode, 0, 
+			0, 0);
+	}
+
+	psl = pmc->sflist;
+	if (!add) {
+		if (!psl)
+			goto done;
+		rv = !0;
+		for (i=0; i<psl->sl_count; i++) {
+			rv = memcmp(&psl->sl_addr, &mreqs->imr_multiaddr,
+				sizeof(__u32));
+			if (rv >= 0)
+				break;
+		}
+		if (!rv)	/* source not found */
+			goto done;
+
+		/* update the interface filter */
+		ip_mc_del_src(in_dev, &mreqs->imr_multiaddr, omode, 1, 
+			&mreqs->imr_sourceaddr, 1);
+
+		for (j=i+1; j<psl->sl_count; j++)
+			psl->sl_addr[j-1] = psl->sl_addr[j];
+		psl->sl_count--;
+		err = 0;
+		goto done;
+	}
+	/* else, add a new source to the filter */
+
+	if (!psl || psl->sl_count == psl->sl_max) {
+		struct ip_sf_socklist *newpsl;
+		int count = IP_SFBLOCK;
+
+		if (psl)
+			count += psl->sl_max;
+		newpsl = (struct ip_sf_socklist *)sock_kmalloc(sk,
+			IP_SFLSIZE(count), GFP_KERNEL);
+		if (!newpsl) {
+			err = -ENOBUFS;
+			goto done;
+		}
+		newpsl->sl_max = count;
+		newpsl->sl_count = count - IP_SFBLOCK;
+		if (psl) {
+			for (i=0; i<psl->sl_count; i++)
+				newpsl->sl_addr[i] = psl->sl_addr[i];
+			sock_kfree_s(sk, psl, IP_SFLSIZE(psl->sl_max));
+		}
+		pmc->sflist = psl = newpsl;
+	}
+	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,
+			sizeof(__u32));
+		if (rv >= 0)
+			break;
+	}
+	if (rv == 0)		/* address already there is an error */
+		goto done;
+	for (j=psl->sl_count-1; j>=i; j--)
+		psl->sl_addr[j+1] = psl->sl_addr[j];
+	psl->sl_addr[i] = mreqs->imr_sourceaddr;
+	psl->sl_count++;
+	err = 0;
+	/* update the interface list */
+	ip_mc_add_src(in_dev, &mreqs->imr_multiaddr, omode, 1, 
+		&mreqs->imr_sourceaddr, 1);
+done:
+	rtnl_shunlock();
+	return err;
+}
+
+int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex)
+{
+	int err;
+	struct ip_mreqn	imr;
+	u32 addr = msf->imsf_multiaddr;
+	struct ip_mc_socklist *pmc;
+	struct in_device *in_dev;
+	struct inet_opt *inet = &sk->protinfo.af_inet;
+	struct ip_sf_socklist *newpsl, *psl;
+
+	if (!MULTICAST(addr))
+		return -EINVAL;
+	if (msf->imsf_fmode != MCAST_INCLUDE &&
+	    msf->imsf_fmode != MCAST_EXCLUDE)
+		return -EINVAL;
+
+	rtnl_shlock();
+
+	imr.imr_multiaddr.s_addr = msf->imsf_multiaddr;
+	imr.imr_address.s_addr = msf->imsf_interface;
+	imr.imr_ifindex = ifindex;
+	in_dev = ip_mc_find_dev(&imr);
+
+	if (!in_dev) {
+		err = -ENODEV;
+		goto done;
+	}
+	err = -EADDRNOTAVAIL;
+
+	for (pmc=inet->mc_list; pmc; pmc=pmc->next) {
+		if (pmc->multi.imr_multiaddr.s_addr == msf->imsf_multiaddr &&
+		    pmc->multi.imr_ifindex == imr.imr_ifindex)
+			break;
+	}
+	if (!pmc)		/* must have a prior join */
+		goto done;
+	if (msf->imsf_numsrc) {
+		newpsl = (struct ip_sf_socklist *)sock_kmalloc(sk,
+				IP_SFLSIZE(msf->imsf_numsrc), GFP_KERNEL);
+		if (!newpsl) {
+			err = -ENOBUFS;
+			goto done;
+		}
+		newpsl->sl_max = newpsl->sl_count = msf->imsf_numsrc;
+		memcpy(newpsl->sl_addr, msf->imsf_slist,
+			msf->imsf_numsrc * sizeof(msf->imsf_slist[0]));
+		err = ip_mc_add_src(in_dev, &msf->imsf_multiaddr,
+			msf->imsf_fmode, newpsl->sl_count, newpsl->sl_addr, 0);
+		if (err) {
+			sock_kfree_s(sk, newpsl, IP_SFLSIZE(newpsl->sl_max));
+			goto done;
+		}
+	} else
+		newpsl = 0;
+	psl = pmc->sflist;
+	if (psl) {
+		(void) ip_mc_del_src(in_dev, &msf->imsf_multiaddr, pmc->sfmode,
+			psl->sl_count, psl->sl_addr, 0);
+		sock_kfree_s(sk, psl, IP_SFLSIZE(psl->sl_max));
+	} else
+		(void) ip_mc_del_src(in_dev, &msf->imsf_multiaddr, pmc->sfmode,
+			0, 0, 0);
+	pmc->sflist = newpsl;
+	pmc->sfmode = msf->imsf_fmode;
+done:
+	rtnl_shunlock();
+	return err;
+}
+
+int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
+	struct ip_msfilter *optval, int *optlen)
+{
+	int err, len, count, copycount;
+	struct ip_mreqn	imr;
+	u32 addr = msf->imsf_multiaddr;
+	struct ip_mc_socklist *pmc;
+	struct in_device *in_dev;
+	struct inet_opt *inet = &sk->protinfo.af_inet;
+	struct ip_sf_socklist *psl;
+
+	if (!MULTICAST(addr))
+		return -EINVAL;
+
+	rtnl_shlock();
+
+	imr.imr_multiaddr.s_addr = msf->imsf_multiaddr;
+	imr.imr_address.s_addr = msf->imsf_interface;
+	imr.imr_ifindex = 0;
+	in_dev = ip_mc_find_dev(&imr);
+
+	if (!in_dev) {
+		err = -ENODEV;
+		goto done;
+	}
+	err = -EADDRNOTAVAIL;
+
+	for (pmc=inet->mc_list; pmc; pmc=pmc->next) {
+		if (pmc->multi.imr_multiaddr.s_addr == msf->imsf_multiaddr &&
+		    pmc->multi.imr_ifindex == imr.imr_ifindex)
+			break;
+	}
+	if (!pmc)		/* must have a prior join */
+		goto done;
+	msf->imsf_fmode = pmc->sfmode;
+	psl = pmc->sflist;
+	rtnl_shunlock();
+	if (!psl) {
+		len = 0;
+		count = 0;
+	} else {
+		count = psl->sl_count;
+	}
+	copycount = count < msf->imsf_numsrc ? count : msf->imsf_numsrc;
+	len = copycount * sizeof(psl->sl_addr[0]);
+	msf->imsf_numsrc = count;
+	if (put_user(IP_MSFILTER_SIZE(copycount), optlen) ||
+	    copy_to_user((void *)optval, msf, IP_MSFILTER_SIZE(0))) {
+		return -EFAULT;
+	}
+	if (len &&
+	    copy_to_user((void *)&optval->imsf_slist[0], psl->sl_addr, len))
+		return -EFAULT;
+	return 0;
+done:
+	rtnl_shunlock();
+	return err;
+}
+
+int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
+	struct group_filter *optval, int *optlen)
+{
+	int err, i, count, copycount;
+	struct sockaddr_in *psin;
+	u32 addr;
+	struct ip_mc_socklist *pmc;
+	struct inet_opt *inet = &sk->protinfo.af_inet;
+	struct ip_sf_socklist *psl;
+
+	psin = (struct sockaddr_in *)&gsf->gf_group;
+	if (psin->sin_family != AF_INET)
+		return -EINVAL;
+	addr = psin->sin_addr.s_addr;
+	if (!MULTICAST(addr))
+		return -EINVAL;
+
+	rtnl_shlock();
+
+	err = -EADDRNOTAVAIL;
+
+	for (pmc=inet->mc_list; pmc; pmc=pmc->next) {
+		if (pmc->multi.imr_multiaddr.s_addr == addr &&
+		    pmc->multi.imr_ifindex == gsf->gf_interface)
+			break;
+	}
+	if (!pmc)		/* must have a prior join */
+		goto done;
+	gsf->gf_fmode = pmc->sfmode;
+	psl = pmc->sflist;
+	rtnl_shunlock();
+	count = psl ? psl->sl_count : 0;
+	copycount = count < gsf->gf_numsrc ? count : gsf->gf_numsrc;
+	gsf->gf_numsrc = count;
+	if (put_user(GROUP_FILTER_SIZE(copycount), optlen) ||
+	    copy_to_user((void *)optval, gsf, GROUP_FILTER_SIZE(0))) {
+		return -EFAULT;
+	}
+	for (i=0; i<copycount; i++) {
+		struct sockaddr_in *psin;
+		struct sockaddr_storage ss;
+
+		psin = (struct sockaddr_in *)&ss;
+		memset(&ss, 0, sizeof(ss));
+		psin->sin_family = AF_INET;
+		psin->sin_addr.s_addr = psl->sl_addr[i];
+		if (copy_to_user((void *)&optval->gf_slist[i], &ss, sizeof(ss)))
+			return -EFAULT;
+	}
+	return 0;
+done:
+	rtnl_shunlock();
+	return err;
+}
+
+/*
+ * check if a multicast source filter allows delivery for a given <src,dst,intf>
+ */
+int ip_mc_sf_allow(struct sock *sk, u32 loc_addr, u32 rmt_addr, int dif)
+{
+	struct inet_opt *inet = &sk->protinfo.af_inet;
+	struct ip_mc_socklist *pmc;
+	struct ip_sf_socklist *psl;
+	int i;
+
+	if (!MULTICAST(loc_addr))
+		return 1;
+
+	for (pmc=inet->mc_list; pmc; pmc=pmc->next) {
+		if (pmc->multi.imr_multiaddr.s_addr == loc_addr &&
+		    pmc->multi.imr_ifindex == dif)
+			break;
+	}
+	if (!pmc)
+		return 1;
+	psl = pmc->sflist;
+	if (!psl)
+		return pmc->sfmode == MCAST_EXCLUDE;
+
+	for (i=0; i<psl->sl_count; i++) {
+		if (psl->sl_addr[i] == rmt_addr)
+			break;
+	}
+	if (pmc->sfmode == MCAST_INCLUDE && i >= psl->sl_count)
+		return 0;
+	if (pmc->sfmode == MCAST_EXCLUDE && i < psl->sl_count)
+		return 0;
+	return 1;
+}
+
 /*
  *	A socket is closing.
  */
 
 void ip_mc_drop_socket(struct sock *sk)
 {
+	struct inet_opt *inet = &sk->protinfo.af_inet;
 	struct ip_mc_socklist *iml;
 
-	if (sk->protinfo.af_inet.mc_list == NULL)
+	if (inet->mc_list == NULL)
 		return;
 
 	rtnl_lock();
-	while ((iml=sk->protinfo.af_inet.mc_list) != NULL) {
+	while ((iml = inet->mc_list) != NULL) {
 		struct in_device *in_dev;
-		sk->protinfo.af_inet.mc_list = iml->next;
+		inet->mc_list = iml->next;
 
 		if ((in_dev = inetdev_by_index(iml->multi.imr_ifindex)) != NULL) {
+			(void) ip_mc_leave_src(sk, iml, in_dev);
 			ip_mc_dec_group(in_dev, iml->multi.imr_multiaddr.s_addr);
 			in_dev_put(in_dev);
 		}
@@ -747,24 +2047,41 @@
 	rtnl_unlock();
 }
 
-int ip_check_mc(struct in_device *in_dev, u32 mc_addr)
+int ip_check_mc(struct in_device *in_dev, u32 mc_addr, u32 src_addr)
 {
 	struct ip_mc_list *im;
+	struct ip_sf_list *psf;
+	int rv = 0;
 
 	read_lock(&in_dev->lock);
 	for (im=in_dev->mc_list; im; im=im->next) {
-		if (im->multiaddr == mc_addr) {
-			read_unlock(&in_dev->lock);
-			return 1;
+		if (im->multiaddr == mc_addr)
+			break;
+	}
+	/*
+	 * This should check the protocol and allow all IGMP packets
+	 * here, but it isn't available in the call from ip_route_output()
+	 * in 2.4.x. It shouldn't actually matter, since groups joined
+	 * from within the kernel will have an {exclude, empty} filter.
+	 * Differs from 2.5.x here.	+-DLS 4/23/03
+	 */
+	if (im) {
+		for (psf=im->sources; psf; psf=psf->sf_next) {
+			if (psf->sf_inaddr == src_addr)
+				break;
 		}
+		if (psf)
+			rv = psf->sf_count[MCAST_INCLUDE] ||
+				psf->sf_count[MCAST_EXCLUDE] !=
+				im->sfcount[MCAST_EXCLUDE];
+		else
+			rv = im->sfcount[MCAST_EXCLUDE] != 0;
 	}
 	read_unlock(&in_dev->lock);
-	return 0;
+	return rv;
 }
 
 
-#ifdef CONFIG_IP_MULTICAST
- 
 int ip_mc_procinfo(char *buffer, char **start, off_t offset, int length)
 {
 	off_t pos=0, begin=0;
@@ -782,7 +2099,9 @@
 		if (in_dev == NULL)
 			continue;
 
+#ifdef CONFIG_IP_MULTICAST
 		querier = IGMP_V1_SEEN(in_dev) ? "V1" : "V2";
+#endif
 
 		len+=sprintf(buffer+len,"%d\t%-10s: %5d %7s\n",
 			     dev->ifindex, dev->name, dev->mc_count, querier);
@@ -820,5 +2139,69 @@
 		len=0;
 	return len;
 }
-#endif
+
+int ip_mcf_procinfo(char *buffer, char **start, off_t offset, int length)
+{
+	off_t pos=0, begin=0;
+	int len=0;
+	int first = 1;
+	struct net_device *dev;
+
+	read_lock(&dev_base_lock);
+	for(dev=dev_base; dev; dev=dev->next) {
+		struct in_device *in_dev = in_dev_get(dev);
+		struct ip_mc_list *imc;
+
+		if (in_dev == NULL)
+			continue;
+
+		read_lock(&in_dev->lock);
+
+		for (imc=in_dev->mc_list; imc; imc=imc->next) {
+			struct ip_sf_list *psf;
+
+			spin_lock_bh(&imc->lock);
+			for (psf=imc->sources; psf; psf=psf->sf_next) {
+				if (first) {
+					len += sprintf(buffer+len, "%3s %6s "
+						"%10s %10s %6s %6s\n", "Idx",
+						"Device", "MCA", "SRC", "INC",
+						"EXC");
+					first = 0;
+				}
+				len += sprintf(buffer+len, "%3d %6.6s 0x%08x "
+					"0x%08x %6lu %6lu\n", dev->ifindex,
+					dev->name, ntohl(imc->multiaddr),
+					ntohl(psf->sf_inaddr),
+					psf->sf_count[MCAST_INCLUDE],
+					psf->sf_count[MCAST_EXCLUDE]);
+				pos=begin+len;
+				if(pos<offset)
+				{
+					len=0;
+					begin=pos;
+				}
+				if(pos>offset+length) {
+					spin_unlock_bh(&imc->lock);
+					read_unlock(&in_dev->lock);
+					in_dev_put(in_dev);
+					goto done;
+				}
+			}
+			spin_unlock_bh(&imc->lock);
+		}
+		read_unlock(&in_dev->lock);
+		in_dev_put(in_dev);
+	}
+done:
+	read_unlock(&dev_base_lock);
+
+	*start=buffer+(offset-begin);
+	len-=(offset-begin);
+	if(len>length)
+		len=length;
+	if(len<0)
+		len=0;
+	return len;
+}
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/ip_output.c linux-2.4.22-pre2/net/ipv4/ip_output.c
--- linux-2.4.21/net/ipv4/ip_output.c	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/ip_output.c	2003-06-26 21:43:33.000000000 +0000
@@ -167,8 +167,11 @@
 #endif /*CONFIG_NETFILTER_DEBUG*/
 
 	if (hh) {
+		int hh_alen;
+
 		read_lock_bh(&hh->hh_lock);
-  		memcpy(skb->data - 16, hh->hh_data, 16);
+		hh_alen = HH_DATA_ALIGN(hh->hh_len);
+  		memcpy(skb->data - hh_alen, hh->hh_data, hh_alen);
 		read_unlock_bh(&hh->hh_lock);
 	        skb_push(skb, hh->hh_len);
 		return hh->hh_output(skb);
@@ -1021,4 +1024,5 @@
 #ifdef CONFIG_IP_MULTICAST
 	proc_net_create("igmp", 0, ip_mc_procinfo);
 #endif
+	proc_net_create("mcfilter", 0, ip_mcf_procinfo);
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/ip_sockglue.c linux-2.4.22-pre2/net/ipv4/ip_sockglue.c
--- linux-2.4.21/net/ipv4/ip_sockglue.c	2001-10-30 23:08:12.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/ip_sockglue.c	2003-06-26 21:43:15.000000000 +0000
@@ -601,9 +601,202 @@
 			}
 
 			if (optname == IP_ADD_MEMBERSHIP)
-				err = ip_mc_join_group(sk,&mreq);
+				err = ip_mc_join_group(sk, &mreq);
 			else
-				err = ip_mc_leave_group(sk,&mreq);
+				err = ip_mc_leave_group(sk, &mreq);
+			break;
+		}
+		case IP_MSFILTER:
+		{
+			struct ip_msfilter *msf;
+
+			if (optlen < IP_MSFILTER_SIZE(0))
+				goto e_inval;
+			msf = (struct ip_msfilter *)kmalloc(optlen, GFP_KERNEL);
+			if (msf == 0) {
+				err = -ENOBUFS;
+				break;
+			}
+			err = -EFAULT;
+			if (copy_from_user(msf, optval, optlen)) {
+				kfree(msf);
+				break;
+			}
+			err = ip_mc_msfilter(sk, msf, 0);
+			kfree(msf);
+			break;
+		}
+		case IP_BLOCK_SOURCE:
+		case IP_UNBLOCK_SOURCE:
+		case IP_ADD_SOURCE_MEMBERSHIP:
+		case IP_DROP_SOURCE_MEMBERSHIP:
+		{
+			struct ip_mreq_source mreqs;
+			int omode, add;
+
+			if (optlen != sizeof(struct ip_mreq_source))
+				goto e_inval;
+			if (copy_from_user(&mreqs, optval, sizeof(mreqs))) {
+				err = -EFAULT;
+				break;
+			}
+			if (optname == IP_BLOCK_SOURCE) {
+				omode = MCAST_EXCLUDE;
+				add = 1;
+			} else if (optname == IP_UNBLOCK_SOURCE) {
+				omode = MCAST_EXCLUDE;
+				add = 0;
+			} else if (optname == IP_ADD_SOURCE_MEMBERSHIP) {
+				struct ip_mreqn mreq;
+
+				mreq.imr_multiaddr.s_addr = mreqs.imr_multiaddr;
+				mreq.imr_address.s_addr = mreqs.imr_interface;
+				mreq.imr_ifindex = 0;
+				err = ip_mc_join_group(sk, &mreq);
+				if (err)
+					break;
+				omode = MCAST_INCLUDE;
+				add = 1;
+			} else /*IP_DROP_SOURCE_MEMBERSHIP */ {
+				omode = MCAST_INCLUDE;
+				add = 0;
+			}
+			err = ip_mc_source(add, omode, sk, &mreqs, 0);
+			break;
+		}
+		case MCAST_JOIN_GROUP:
+		case MCAST_LEAVE_GROUP: 
+		{
+			struct group_req greq;
+			struct sockaddr_in *psin;
+			struct ip_mreqn mreq;
+
+			if (optlen < sizeof(struct group_req))
+				goto e_inval;
+			err = -EFAULT;
+			if(copy_from_user(&greq, optval, sizeof(greq)))
+				break;
+			psin = (struct sockaddr_in *)&greq.gr_group;
+			if (psin->sin_family != AF_INET)
+				goto e_inval;
+			memset(&mreq, 0, sizeof(mreq));
+			mreq.imr_multiaddr = psin->sin_addr;
+			mreq.imr_ifindex = greq.gr_interface;
+
+			if (optname == MCAST_JOIN_GROUP)
+				err = ip_mc_join_group(sk, &mreq);
+			else
+				err = ip_mc_leave_group(sk, &mreq);
+			break;
+		}
+		case MCAST_JOIN_SOURCE_GROUP:
+		case MCAST_LEAVE_SOURCE_GROUP:
+		case MCAST_BLOCK_SOURCE:
+		case MCAST_UNBLOCK_SOURCE:
+		{
+			struct group_source_req greqs;
+			struct ip_mreq_source mreqs;
+			struct sockaddr_in *psin;
+			int omode, add;
+
+			if (optlen != sizeof(struct group_source_req))
+				goto e_inval;
+			if (copy_from_user(&greqs, optval, sizeof(greqs))) {
+				err = -EFAULT;
+				break;
+			}
+			if (greqs.gsr_group.ss_family != AF_INET ||
+			    greqs.gsr_source.ss_family != AF_INET) {
+				err = -EADDRNOTAVAIL;
+				break;
+			}
+			psin = (struct sockaddr_in *)&greqs.gsr_group;
+			mreqs.imr_multiaddr = psin->sin_addr.s_addr;
+			psin = (struct sockaddr_in *)&greqs.gsr_source;
+			mreqs.imr_sourceaddr = psin->sin_addr.s_addr;
+			mreqs.imr_interface = 0; /* use index for mc_source */
+
+			if (optname == MCAST_BLOCK_SOURCE) {
+				omode = MCAST_EXCLUDE;
+				add = 1;
+			} else if (optname == MCAST_UNBLOCK_SOURCE) {
+				omode = MCAST_EXCLUDE;
+				add = 0;
+			} else if (optname == MCAST_JOIN_SOURCE_GROUP) {
+				struct ip_mreqn mreq;
+
+				psin = (struct sockaddr_in *)&greqs.gsr_group;
+				mreq.imr_multiaddr = psin->sin_addr;
+				mreq.imr_address.s_addr = 0;
+				mreq.imr_ifindex = greqs.gsr_interface;
+				err = ip_mc_join_group(sk, &mreq);
+				if (err)
+					break;
+				omode = MCAST_INCLUDE;
+				add = 1;
+			} else /* MCAST_LEAVE_SOURCE_GROUP */ {
+				omode = MCAST_INCLUDE;
+				add = 0;
+			}
+			err = ip_mc_source(add, omode, sk, &mreqs,
+				greqs.gsr_interface);
+			break;
+		}
+		case MCAST_MSFILTER:
+		{
+			struct sockaddr_in *psin;
+			struct ip_msfilter *msf = 0;
+			struct group_filter *gsf = 0;
+			int msize, i, ifindex;
+
+			if (optlen < GROUP_FILTER_SIZE(0))
+				goto e_inval;
+			gsf = (struct group_filter *)kmalloc(optlen,GFP_KERNEL);
+			if (gsf == 0) {
+				err = -ENOBUFS;
+				break;
+			}
+			err = -EFAULT;
+			if (copy_from_user(gsf, optval, optlen)) {
+				goto mc_msf_out;
+			}
+			if (GROUP_FILTER_SIZE(gsf->gf_numsrc) < optlen) {
+				err = EINVAL;
+				goto mc_msf_out;
+			}
+			msize = IP_MSFILTER_SIZE(gsf->gf_numsrc);
+			msf = (struct ip_msfilter *)kmalloc(msize,GFP_KERNEL);
+			if (msf == 0) {
+				err = -ENOBUFS;
+				goto mc_msf_out;
+			}
+			ifindex = gsf->gf_interface;
+			psin = (struct sockaddr_in *)&gsf->gf_group;
+			if (psin->sin_family != AF_INET) {
+				err = -EADDRNOTAVAIL;
+				goto mc_msf_out;
+			}
+			msf->imsf_multiaddr = psin->sin_addr.s_addr;
+			msf->imsf_interface = 0;
+			msf->imsf_fmode = gsf->gf_fmode;
+			msf->imsf_numsrc = gsf->gf_numsrc;
+			err = -EADDRNOTAVAIL;
+			for (i=0; i<gsf->gf_numsrc; ++i) {
+				psin = (struct sockaddr_in *)&gsf->gf_slist[i];
+
+				if (psin->sin_family != AF_INET)
+					goto mc_msf_out;
+				msf->imsf_slist[i] = psin->sin_addr.s_addr;
+			}
+			kfree(gsf);
+			gsf = 0;
+
+			err = ip_mc_msfilter(sk, msf, ifindex);
+mc_msf_out:
+			if (msf)
+				kfree(msf);
+			if (gsf)
+				kfree(gsf);
 			break;
 		}
 		case IP_ROUTER_ALERT:	
@@ -748,6 +941,42 @@
 				return -EFAULT;
 			return 0;
 		}
+		case IP_MSFILTER:
+		{
+			struct ip_msfilter msf;
+			int err;
+
+			if (len < IP_MSFILTER_SIZE(0)) {
+				release_sock(sk);
+				return -EINVAL;
+			}
+			if (copy_from_user(&msf, optval, IP_MSFILTER_SIZE(0))) {
+				release_sock(sk);
+				return -EFAULT;
+			}
+			err = ip_mc_msfget(sk, &msf,
+				(struct ip_msfilter *)optval, optlen);
+			release_sock(sk);
+			return err;
+		}
+		case MCAST_MSFILTER:
+		{
+			struct group_filter gsf;
+			int err;
+
+			if (len < GROUP_FILTER_SIZE(0)) {
+				release_sock(sk);
+				return -EINVAL;
+			}
+			if (copy_from_user(&gsf, optval, GROUP_FILTER_SIZE(0))) {
+				release_sock(sk);
+				return -EFAULT;
+			}
+			err = ip_mc_gsfget(sk, &gsf,
+				(struct group_filter *)optval, optlen);
+			release_sock(sk);
+			return err;
+		}
 		case IP_PKTOPTIONS:		
 		{
 			struct msghdr msg;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/netfilter/Config.in linux-2.4.22-pre2/net/ipv4/netfilter/Config.in
--- linux-2.4.21/net/ipv4/netfilter/Config.in	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/netfilter/Config.in	2003-06-26 21:43:21.000000000 +0000
@@ -24,6 +24,7 @@
   dep_tristate '  netfilter MARK match support' CONFIG_IP_NF_MATCH_MARK $CONFIG_IP_NF_IPTABLES
   dep_tristate '  Multiple port match support' CONFIG_IP_NF_MATCH_MULTIPORT $CONFIG_IP_NF_IPTABLES
   dep_tristate '  TOS match support' CONFIG_IP_NF_MATCH_TOS $CONFIG_IP_NF_IPTABLES
+  dep_tristate '  recent match support' CONFIG_IP_NF_MATCH_RECENT $CONFIG_IP_NF_IPTABLES
   dep_tristate '  ECN match support' CONFIG_IP_NF_MATCH_ECN $CONFIG_IP_NF_IPTABLES
  
   dep_tristate '  DSCP match support' CONFIG_IP_NF_MATCH_DSCP $CONFIG_IP_NF_IPTABLES
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/netfilter/Makefile linux-2.4.22-pre2/net/ipv4/netfilter/Makefile
--- linux-2.4.21/net/ipv4/netfilter/Makefile	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/netfilter/Makefile	2003-06-26 21:43:13.000000000 +0000
@@ -72,6 +72,9 @@
 obj-$(CONFIG_IP_NF_MATCH_MULTIPORT) += ipt_multiport.o
 obj-$(CONFIG_IP_NF_MATCH_OWNER) += ipt_owner.o
 obj-$(CONFIG_IP_NF_MATCH_TOS) += ipt_tos.o
+
+obj-$(CONFIG_IP_NF_MATCH_RECENT) += ipt_recent.o
+
 obj-$(CONFIG_IP_NF_MATCH_ECN) += ipt_ecn.o
 obj-$(CONFIG_IP_NF_MATCH_DSCP) += ipt_dscp.o
 obj-$(CONFIG_IP_NF_MATCH_AH_ESP) += ipt_ah.o ipt_esp.o
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/netfilter/ip_conntrack_core.c linux-2.4.22-pre2/net/ipv4/netfilter/ip_conntrack_core.c
--- linux-2.4.21/net/ipv4/netfilter/ip_conntrack_core.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/netfilter/ip_conntrack_core.c	2003-06-26 21:43:10.000000000 +0000
@@ -174,8 +174,8 @@
 static void
 destroy_expect(struct ip_conntrack_expect *exp)
 {
-	DEBUGP("destroy_expect(%p) use=%d\n", exp, atomic_read(exp->use));
-	IP_NF_ASSERT(atomic_read(exp->use));
+	DEBUGP("destroy_expect(%p) use=%d\n", exp, atomic_read(&exp->use));
+	IP_NF_ASSERT(atomic_read(&exp->use));
 	IP_NF_ASSERT(!timer_pending(&exp->timeout));
 
 	kfree(exp);
@@ -264,9 +264,7 @@
 
 	DEBUGP("remove_expectations(%p)\n", ct);
 
-	for (exp_entry = ct->sibling_list.next;
-	     exp_entry != &ct->sibling_list; exp_entry = next) {
-		next = exp_entry->next;
+	list_for_each_safe(exp_entry, next, &ct->sibling_list) {
 		exp = list_entry(exp_entry, struct ip_conntrack_expect,
 				 expected_list);
 
@@ -313,9 +311,6 @@
 	IP_NF_ASSERT(atomic_read(&nfct->use) == 0);
 	IP_NF_ASSERT(!timer_pending(&ct->timeout));
 
-	if (ct->master && master_ct(ct))
-		ip_conntrack_put(master_ct(ct));
-
 	/* To make sure we don't get any weird locking issues here:
 	 * destroy_conntrack() MUST NOT be called with a write lock
 	 * to ip_conntrack_lock!!! -HW */
@@ -332,9 +327,12 @@
 
 	/* Delete our master expectation */
 	if (ct->master) {
-		/* can't call __unexpect_related here,
-		 * since it would screw up expect_list */
-		list_del(&ct->master->expected_list);
+		if (ct->master->expectant) {
+			/* can't call __unexpect_related here,
+			 * since it would screw up expect_list */
+			list_del(&ct->master->expected_list);
+			ip_conntrack_put(ct->master->expectant);
+		}
 		kfree(ct->master);
 	}
 	WRITE_UNLOCK(&ip_conntrack_lock);
@@ -596,7 +594,7 @@
 	int dropped = 0;
 
 	READ_LOCK(&ip_conntrack_lock);
-	h = LIST_FIND(chain, unreplied, struct ip_conntrack_tuple_hash *);
+	h = LIST_FIND_B(chain, unreplied, struct ip_conntrack_tuple_hash *);
 	if (h)
 		atomic_inc(&h->ctrack->ct_general.use);
 	READ_UNLOCK(&ip_conntrack_lock);
@@ -695,9 +693,6 @@
 
 	INIT_LIST_HEAD(&conntrack->sibling_list);
 
-	/* Mark clearly that it's not in the hash table. */
-	conntrack->tuplehash[IP_CT_DIR_ORIGINAL].list.next = NULL;
-
 	WRITE_LOCK(&ip_conntrack_lock);
 	/* Need finding and deleting of expected ONLY if we win race */
 	READ_LOCK(&ip_conntrack_expect_tuple_lock);
@@ -705,6 +700,14 @@
 			     struct ip_conntrack_expect *, tuple);
 	READ_UNLOCK(&ip_conntrack_expect_tuple_lock);
 
+	/* If master is not in hash table yet (ie. packet hasn't left
+	   this machine yet), how can other end know about expected?
+	   Hence these are not the droids you are looking for (if
+	   master ct never got confirmed, we'd hold a reference to it
+	   and weird things would happen to future packets). */
+	if (expected && !is_confirmed(expected->expectant))
+		expected = NULL;
+
 	/* Look up the conntrack helper for master connections only */
 	if (!expected)
 		conntrack->helper = ip_ct_find_helper(&repl_tuple);
@@ -715,12 +718,7 @@
 	    && ! del_timer(&expected->timeout))
 		expected = NULL;
 
-	/* If master is not in hash table yet (ie. packet hasn't left
-	   this machine yet), how can other end know about expected?
-	   Hence these are not the droids you are looking for (if
-	   master ct never got confirmed, we'd hold a reference to it
-	   and weird things would happen to future packets). */
-	if (expected && is_confirmed(expected->expectant)) {
+	if (expected) {
 		DEBUGP("conntrack: expectation arrives ct=%p exp=%p\n",
 			conntrack, expected);
 		/* Welcome, Mr. Bond.  We've been expecting you... */
@@ -1033,18 +1031,11 @@
 		return -ENOMEM;
 	}
 	
-	/* Zero out the new structure, then fill out it with the data */
 	DEBUGP("new expectation %p of conntrack %p\n", new, related_to);
-	memset(new, 0, sizeof(*expect));
-	INIT_LIST_HEAD(&new->list);
-	INIT_LIST_HEAD(&new->expected_list);
 	memcpy(new, expect, sizeof(*expect));
 	new->expectant = related_to;
 	new->sibling = NULL;
-	/* increase usage count. This sucks. The memset above overwrites
-	 * old usage count [if still present] and we increase to one.  Only
-	 * works because everything is done under ip_conntrack_lock() */
-	atomic_inc(&new->use);
+	atomic_set(&new->use, 1);
 	
 	/* add to expected list for this connection */	
 	list_add(&new->expected_list, &related_to->sibling_list);
@@ -1309,8 +1300,8 @@
 getorigdst(struct sock *sk, int optval, void *user, int *len)
 {
 	struct ip_conntrack_tuple_hash *h;
-	struct ip_conntrack_tuple tuple = { { sk->rcv_saddr, { sk->sport } },
-					    { sk->daddr, { sk->dport },
+	struct ip_conntrack_tuple tuple = { { sk->rcv_saddr, { .tcp = { sk->sport } } },
+					    { sk->daddr, { .tcp = { sk->dport } },
 					      IPPROTO_TCP } };
 
 	/* We only do TCP at the moment: is there a better way? */
@@ -1483,8 +1474,10 @@
 	ip_ct_attach = ip_conntrack_attach;
 	return ret;
 
+#ifdef CONFIG_SYSCTL
 err_free_ct_cachep:
 	kmem_cache_destroy(ip_conntrack_cachep);
+#endif /*CONFIG_SYSCTL*/
 err_free_hash:
 	vfree(ip_conntrack_hash);
 err_unreg_sockopt:
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/netfilter/ip_conntrack_ftp.c linux-2.4.22-pre2/net/ipv4/netfilter/ip_conntrack_ftp.c
--- linux-2.4.21/net/ipv4/netfilter/ip_conntrack_ftp.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/netfilter/ip_conntrack_ftp.c	2003-06-26 21:43:30.000000000 +0000
@@ -366,11 +366,11 @@
 		    { 0 } },
 		  { htonl((array[0] << 24) | (array[1] << 16)
 			  | (array[2] << 8) | array[3]),
-		    { htons(array[4] << 8 | array[5]) },
+		    { .tcp = { htons(array[4] << 8 | array[5]) } },
 		    IPPROTO_TCP }});
 	exp->mask = ((struct ip_conntrack_tuple)
 		{ { 0xFFFFFFFF, { 0 } },
-		  { 0xFFFFFFFF, { 0xFFFF }, 0xFFFF }});
+		  { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFFFF }});
 
 	exp->expectfn = NULL;
 
@@ -405,7 +405,6 @@
 		ports[0] = FTP_PORT;
 
 	for (i = 0; (i < MAX_PORTS) && ports[i]; i++) {
-		memset(&ftp[i], 0, sizeof(struct ip_conntrack_helper));
 		ftp[i].tuple.src.u.tcp.port = htons(ports[i]);
 		ftp[i].tuple.dst.protonum = IPPROTO_TCP;
 		ftp[i].mask.src.u.tcp.port = 0xFFFF;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/netfilter/ip_conntrack_irc.c linux-2.4.22-pre2/net/ipv4/netfilter/ip_conntrack_irc.c
--- linux-2.4.21/net/ipv4/netfilter/ip_conntrack_irc.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/netfilter/ip_conntrack_irc.c	2003-06-26 21:43:30.000000000 +0000
@@ -209,11 +209,11 @@
 
 			exp->tuple = ((struct ip_conntrack_tuple)
 				{ { 0, { 0 } },
-				  { htonl(dcc_ip), { htons(dcc_port) },
+				  { htonl(dcc_ip), { .tcp = { htons(dcc_port) } },
 				    IPPROTO_TCP }});
 			exp->mask = ((struct ip_conntrack_tuple)
 				{ { 0, { 0 } },
-				  { 0xFFFFFFFF, { 0xFFFF }, 0xFFFF }});
+				  { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFFFF }});
 
 			exp->expectfn = NULL;
 
@@ -259,8 +259,6 @@
 
 	for (i = 0; (i < MAX_PORTS) && ports[i]; i++) {
 		hlpr = &irc_helpers[i];
-		memset(hlpr, 0,
-		       sizeof(struct ip_conntrack_helper));
 		hlpr->tuple.src.u.tcp.port = htons(ports[i]);
 		hlpr->tuple.dst.protonum = IPPROTO_TCP;
 		hlpr->mask.src.u.tcp.port = 0xFFFF;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/netfilter/ip_nat_amanda.c linux-2.4.22-pre2/net/ipv4/netfilter/ip_nat_amanda.c
--- linux-2.4.21/net/ipv4/netfilter/ip_nat_amanda.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/netfilter/ip_nat_amanda.c	2003-06-26 21:43:13.000000000 +0000
@@ -84,7 +84,7 @@
 		mr.range[0].flags |= IP_NAT_RANGE_PROTO_SPECIFIED;
 		mr.range[0].min = mr.range[0].max
 			= ((union ip_conntrack_manip_proto)
-				{ htons(port) });
+				{ .udp = { htons(port) } });
 	}
 
 	return ip_nat_setup_info(ct, &mr, hooknum);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/netfilter/ip_nat_core.c linux-2.4.22-pre2/net/ipv4/netfilter/ip_nat_core.c
--- linux-2.4.21/net/ipv4/netfilter/ip_nat_core.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/netfilter/ip_nat_core.c	2003-06-26 21:43:12.000000000 +0000
@@ -756,6 +756,11 @@
 	enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
 	int is_tcp = (*pskb)->nh.iph->protocol == IPPROTO_TCP;
 
+	/* Skip everything and don't call helpers if there are no
+	 * manips for this connection */
+	if (info->num_manips == 0)
+		return NF_ACCEPT;
+
 	/* Need nat lock to protect against modification, but neither
 	   conntrack (referenced) and helper (deleted with
 	   synchronize_bh()) can vanish. */
@@ -796,6 +801,7 @@
 		struct ip_conntrack_expect *exp = NULL;
 		struct list_head *cur_item;
 		int ret = NF_ACCEPT;
+		int helper_called = 0;
 
 		DEBUGP("do_bindings: helper existing for (%p)\n", ct);
 
@@ -814,19 +820,21 @@
 				continue;
 
 			if (exp_for_packet(exp, pskb)) {
-				/* FIXME: May be true multiple times in the case of UDP!! */
-				DEBUGP("calling nat helper (exp=%p) for packet\n",
-					exp);
+				/* FIXME: May be true multiple times in the
+				 * case of UDP!! */
+				DEBUGP("calling nat helper (exp=%p) for	packet\n", exp);
 				ret = helper->help(ct, exp, info, ctinfo, 
 						   hooknum, pskb);
 				if (ret != NF_ACCEPT) {
 					READ_UNLOCK(&ip_conntrack_lock);
 					return ret;
 				}
+				helper_called = 1;
 			}
 		}
-		/* Helper might want to manip the packet even when there is no expectation */
-		if (!exp && helper->flags & IP_NAT_HELPER_F_ALWAYS) {
+		/* Helper might want to manip the packet even when there is no
+		 * matching expectation for this packet */
+		if (!helper_called && helper->flags & IP_NAT_HELPER_F_ALWAYS) {
 			DEBUGP("calling nat helper for packet without expectation\n");
 			ret = helper->help(ct, NULL, info, ctinfo, 
 					   hooknum, pskb);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/netfilter/ip_nat_ftp.c linux-2.4.22-pre2/net/ipv4/netfilter/ip_nat_ftp.c
--- linux-2.4.21/net/ipv4/netfilter/ip_nat_ftp.c	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/netfilter/ip_nat_ftp.c	2003-06-26 21:43:12.000000000 +0000
@@ -84,7 +84,7 @@
 		mr.range[0].flags |= IP_NAT_RANGE_PROTO_SPECIFIED;
 		mr.range[0].min = mr.range[0].max
 			= ((union ip_conntrack_manip_proto)
-				{ htons(exp_ftp_info->port) });
+				{ .tcp = { htons(exp_ftp_info->port) } });
 	}
 	return ip_nat_setup_info(ct, &mr, hooknum);
 }
@@ -306,9 +306,6 @@
 		ports[0] = FTP_PORT;
 
 	for (i = 0; (i < MAX_PORTS) && ports[i]; i++) {
-
-		memset(&ftp[i], 0, sizeof(struct ip_nat_helper));
-
 		ftp[i].tuple.dst.protonum = IPPROTO_TCP;
 		ftp[i].tuple.src.u.tcp.port = htons(ports[i]);
 		ftp[i].mask.dst.protonum = 0xFFFF;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/netfilter/ip_nat_helper.c linux-2.4.22-pre2/net/ipv4/netfilter/ip_nat_helper.c
--- linux-2.4.21/net/ipv4/netfilter/ip_nat_helper.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/netfilter/ip_nat_helper.c	2003-06-26 21:43:12.000000000 +0000
@@ -84,7 +84,6 @@
 	iph = (*skb)->nh.iph;
 	if (iph->protocol == IPPROTO_TCP) {
 		struct tcphdr *tcph = (void *)iph + iph->ihl*4;
-		void *data = (void *)tcph + tcph->doff*4;
 
 		DEBUGP("ip_nat_resize_packet: Seq_offset before: ");
 		DUMP_OFFSET(this_way);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/netfilter/ip_nat_irc.c linux-2.4.22-pre2/net/ipv4/netfilter/ip_nat_irc.c
--- linux-2.4.21/net/ipv4/netfilter/ip_nat_irc.c	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/netfilter/ip_nat_irc.c	2003-06-26 21:43:33.000000000 +0000
@@ -243,9 +243,6 @@
 
 	for (i = 0; (i < MAX_PORTS) && ports[i] != 0; i++) {
 		hlpr = &ip_nat_irc_helpers[i];
-		memset(hlpr, 0,
-		       sizeof(struct ip_nat_helper));
-
 		hlpr->tuple.dst.protonum = IPPROTO_TCP;
 		hlpr->tuple.src.u.tcp.port = htons(ports[i]);
 		hlpr->mask.src.u.tcp.port = 0xFFFF;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/netfilter/ip_nat_snmp_basic.c linux-2.4.22-pre2/net/ipv4/netfilter/ip_nat_snmp_basic.c
--- linux-2.4.21/net/ipv4/netfilter/ip_nat_snmp_basic.c	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/netfilter/ip_nat_snmp_basic.c	2003-06-26 21:43:14.000000000 +0000
@@ -1309,9 +1309,9 @@
 	"snmp",
 	IP_NAT_HELPER_F_STANDALONE,
 	THIS_MODULE,
-	{ { 0, { __constant_htons(SNMP_PORT) } },
+	{ { 0, { .udp = { __constant_htons(SNMP_PORT) } } },
 	  { 0, { 0 }, IPPROTO_UDP } },
-	{ { 0, { 0xFFFF } },
+	{ { 0, { .udp = { 0xFFFF } } },
 	  { 0, { 0 }, 0xFFFF } },
 	nat_help, NULL };
  
@@ -1320,9 +1320,9 @@
 	"snmp_trap",
 	IP_NAT_HELPER_F_STANDALONE,
 	THIS_MODULE,
-	{ { 0, { __constant_htons(SNMP_TRAP_PORT) } },
+	{ { 0, { .udp = { __constant_htons(SNMP_TRAP_PORT) } } },
 	  { 0, { 0 }, IPPROTO_UDP } },
-	{ { 0, { 0xFFFF } },
+	{ { 0, { .udp = { 0xFFFF } } },
 	  { 0, { 0 }, 0xFFFF } },
 	nat_help, NULL };
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/netfilter/ip_tables.c linux-2.4.22-pre2/net/ipv4/netfilter/ip_tables.c
--- linux-2.4.21/net/ipv4/netfilter/ip_tables.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/netfilter/ip_tables.c	2003-06-26 21:43:14.000000000 +0000
@@ -1698,14 +1698,15 @@
 = { { NULL, NULL }, "icmp", &icmp_match, &icmp_checkentry, NULL };
 
 #ifdef CONFIG_PROC_FS
-static inline int print_name(const struct ipt_table *t,
+static inline int print_name(const char *i,
 			     off_t start_offset, char *buffer, int length,
 			     off_t *pos, unsigned int *count)
 {
 	if ((*count)++ >= start_offset) {
 		unsigned int namelen;
 
-		namelen = sprintf(buffer + *pos, "%s\n", t->name);
+		namelen = sprintf(buffer + *pos, "%s\n",
+				  i + sizeof(struct list_head));
 		if (*pos + namelen > length) {
 			/* Stop iterating */
 			return 1;
@@ -1723,7 +1724,7 @@
 	if (down_interruptible(&ipt_mutex) != 0)
 		return 0;
 
-	LIST_FIND(&ipt_tables, print_name, struct ipt_table *,
+	LIST_FIND(&ipt_tables, print_name, void *,
 		  offset, buffer, length, &pos, &count);
 
 	up(&ipt_mutex);
@@ -1732,6 +1733,46 @@
 	*start=(char *)((unsigned long)count-offset);
 	return pos;
 }
+
+static int ipt_get_targets(char *buffer, char **start, off_t offset, int length)
+{
+	off_t pos = 0;
+	unsigned int count = 0;
+
+	if (down_interruptible(&ipt_mutex) != 0)
+		return 0;
+
+	LIST_FIND(&ipt_target, print_name, void *,
+		  offset, buffer, length, &pos, &count);
+	
+	up(&ipt_mutex);
+
+	*start = (char *)((unsigned long)count - offset);
+	return pos;
+}
+
+static int ipt_get_matches(char *buffer, char **start, off_t offset, int length)
+{
+	off_t pos = 0;
+	unsigned int count = 0;
+
+	if (down_interruptible(&ipt_mutex) != 0)
+		return 0;
+	
+	LIST_FIND(&ipt_match, print_name, void *,
+		  offset, buffer, length, &pos, &count);
+
+	up(&ipt_mutex);
+
+	*start = (char *)((unsigned long)count - offset);
+	return pos;
+}
+
+static struct { char *name; get_info_t *get_info; } ipt_proc_entry[] =
+{ { "ip_tables_names", ipt_get_tables },
+  { "ip_tables_targets", ipt_get_targets },
+  { "ip_tables_matches", ipt_get_matches },
+  { NULL, NULL} };
 #endif /*CONFIG_PROC_FS*/
 
 static int __init init(void)
@@ -1757,13 +1798,19 @@
 #ifdef CONFIG_PROC_FS
 	{
 	struct proc_dir_entry *proc;
+	int i;
 
-	proc = proc_net_create("ip_tables_names", 0, ipt_get_tables);
-	if (!proc) {
-		nf_unregister_sockopt(&ipt_sockopts);
-		return -ENOMEM;
+	for (i = 0; ipt_proc_entry[i].name; i++) {
+		proc = proc_net_create(ipt_proc_entry[i].name, 0,
+				       ipt_proc_entry[i].get_info);
+		if (!proc) {
+			while (--i >= 0)
+				proc_net_remove(ipt_proc_entry[i].name);
+			nf_unregister_sockopt(&ipt_sockopts);
+			return -ENOMEM;
+		}
+		proc->owner = THIS_MODULE;
 	}
-	proc->owner = THIS_MODULE;
 	}
 #endif
 
@@ -1775,7 +1822,11 @@
 {
 	nf_unregister_sockopt(&ipt_sockopts);
 #ifdef CONFIG_PROC_FS
-	proc_net_remove("ip_tables_names");
+	{
+	int i;
+	for (i = 0; ipt_proc_entry[i].name; i++)
+		proc_net_remove(ipt_proc_entry[i].name);
+	}
 #endif
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/netfilter/ipt_MIRROR.c linux-2.4.22-pre2/net/ipv4/netfilter/ipt_MIRROR.c
--- linux-2.4.21/net/ipv4/netfilter/ipt_MIRROR.c	2001-12-21 17:42:05.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/netfilter/ipt_MIRROR.c	2003-06-26 21:43:33.000000000 +0000
@@ -85,8 +85,11 @@
 	struct hh_cache *hh = dst->hh;
 
 	if (hh) {
+		int hh_alen;
+
 		read_lock_bh(&hh->hh_lock);
-  		memcpy(skb->data - 16, hh->hh_data, 16);
+		hh_alen = HH_DATA_ALIGN(hh->hh_len);
+  		memcpy(skb->data - hh_alen, hh->hh_data, hh_alen);
 		read_unlock_bh(&hh->hh_lock);
 	        skb_push(skb, hh->hh_len);
 		hh->hh_output(skb);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/netfilter/ipt_ULOG.c linux-2.4.22-pre2/net/ipv4/netfilter/ipt_ULOG.c
--- linux-2.4.21/net/ipv4/netfilter/ipt_ULOG.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/netfilter/ipt_ULOG.c	2003-06-26 21:43:28.000000000 +0000
@@ -322,7 +322,6 @@
 
 	/* initialize ulog_buffers */
 	for (i = 0; i < ULOG_MAXNLGROUPS; i++) {
-		memset(&ulog_buffers[i], 0, sizeof(ulog_buff_t));
 		init_timer(&ulog_buffers[i].timer);
 		ulog_buffers[i].timer.function = ulog_timer;
 		ulog_buffers[i].timer.data = i;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/netfilter/ipt_recent.c linux-2.4.22-pre2/net/ipv4/netfilter/ipt_recent.c
--- linux-2.4.21/net/ipv4/netfilter/ipt_recent.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/netfilter/ipt_recent.c	2003-06-26 21:43:14.000000000 +0000
@@ -0,0 +1,990 @@
+/* Kernel module to check if the source address has been seen recently. */
+/* Copyright 2002-2003, Stephen Frost */
+/* Author: Stephen Frost <sfrost@snowman.net> */
+/* Project Page: http://snowman.net/projects/ipt_recent/ */
+/* This software is distributed under the terms of the GPL, Version 2 */
+/* This copyright does not cover user programs that use kernel services
+ * by normal system calls. */
+
+#include <linux/module.h>
+#include <linux/skbuff.h>
+#include <linux/proc_fs.h>
+#include <linux/spinlock.h>
+#include <linux/interrupt.h>
+#include <asm/uaccess.h>
+#include <linux/ctype.h>
+#include <linux/ip.h>
+#include <linux/vmalloc.h>
+
+#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter_ipv4/ipt_recent.h>
+
+#undef DEBUG
+#define HASH_LOG 9
+
+/* Defaults, these can be overridden on the module command-line. */
+static int ip_list_tot = 100;
+static int ip_pkt_list_tot = 20;
+static int ip_list_hash_size = 0;
+static int ip_list_perms = 0644;
+#ifdef DEBUG
+static int debug = 1;
+#endif
+
+static char version[] =
+KERN_INFO RECENT_NAME " " RECENT_VER ": Stephen Frost <sfrost@snowman.net>.  http://snowman.net/projects/ipt_recent/\n";
+
+MODULE_AUTHOR("Stephen Frost <sfrost@snowman.net>");
+MODULE_DESCRIPTION("IP tables recently seen matching module " RECENT_VER);
+MODULE_LICENSE("GPL");
+MODULE_PARM(ip_list_tot,"i");
+MODULE_PARM(ip_pkt_list_tot,"i");
+MODULE_PARM(ip_list_hash_size,"i");
+MODULE_PARM(ip_list_perms,"i");
+#ifdef DEBUG
+MODULE_PARM(debug,"i");
+MODULE_PARM_DESC(debug,"debugging level, defaults to 1");
+#endif
+MODULE_PARM_DESC(ip_list_tot,"number of IPs to remember per list");
+MODULE_PARM_DESC(ip_pkt_list_tot,"number of packets per IP to remember");
+MODULE_PARM_DESC(ip_list_hash_size,"size of hash table used to look up IPs");
+MODULE_PARM_DESC(ip_list_perms,"permissions on /proc/net/ipt_recent/* files");
+
+/* Structure of our list of recently seen addresses. */
+struct recent_ip_list {
+	u_int32_t addr;
+	u_int8_t  ttl;
+	u_int32_t last_seen;
+	u_int32_t *last_pkts;
+	u_int32_t oldest_pkt;
+	u_int32_t hash_entry;
+	u_int32_t time_pos;
+};
+
+struct time_info_list {
+	u_int32_t position;
+	u_int32_t time;
+};
+
+/* Structure of our linked list of tables of recent lists. */
+struct recent_ip_tables {
+	char name[IPT_RECENT_NAME_LEN];
+	int count;
+	int time_pos;
+	struct recent_ip_list *table;
+	struct recent_ip_tables *next;
+	spinlock_t list_lock;
+	int *hash_table;
+	struct time_info_list *time_info;
+#ifdef CONFIG_PROC_FS
+	struct proc_dir_entry *status_proc;
+#endif /* CONFIG_PROC_FS */
+};
+
+/* Our current list of addresses we have recently seen.
+ * Only added to on a --set, and only updated on --set || --update 
+ */
+static struct recent_ip_tables *r_tables = NULL;
+
+/* We protect r_list with this spinlock so two processors are not modifying
+ * the list at the same time. 
+ */
+static spinlock_t recent_lock = SPIN_LOCK_UNLOCKED;
+
+/* Our /proc/net/ipt_recent entry */
+static struct proc_dir_entry *proc_net_ipt_recent = NULL;
+
+/* Function declaration for later. */
+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 *hotdrop);
+
+/* Function to hash a given address into the hash table of table_size size */
+int hash_func(unsigned int addr, int table_size)
+{
+	int result = 0;
+	unsigned int value = addr;
+	do { result ^= value; } while((value >>= HASH_LOG));
+
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": %d = hash_func(%u,%d)\n",
+			 result & (table_size - 1),
+			 addr,
+			 table_size);
+#endif
+
+	return(result & (table_size - 1));
+}
+
+#ifdef CONFIG_PROC_FS
+/* This is the function which produces the output for our /proc output
+ * interface which lists each IP address, the last seen time and the 
+ * other recent times the address was seen.
+ */
+
+static int ip_recent_get_info(char *buffer, char **start, off_t offset, int length, int *eof, void *data)
+{
+	int len = 0, count, last_len = 0, pkt_count;
+	off_t pos = 0;
+	off_t begin = 0;
+	struct recent_ip_tables *curr_table;
+
+	curr_table = (struct recent_ip_tables*) data;
+
+	spin_lock_bh(&curr_table->list_lock);
+	for(count = 0; count < ip_list_tot; count++) {
+		if(!curr_table->table[count].addr) continue;
+		last_len = len;
+		len += sprintf(buffer+len,"src=%u.%u.%u.%u ",NIPQUAD(curr_table->table[count].addr));
+		len += sprintf(buffer+len,"ttl: %u ",curr_table->table[count].ttl);
+		len += sprintf(buffer+len,"last_seen: %u ",curr_table->table[count].last_seen);
+		len += sprintf(buffer+len,"oldest_pkt: %u ",curr_table->table[count].oldest_pkt);
+		len += sprintf(buffer+len,"last_pkts: %u",curr_table->table[count].last_pkts[0]);
+		for(pkt_count = 1; pkt_count < ip_pkt_list_tot; pkt_count++) {
+			if(!curr_table->table[count].last_pkts[pkt_count]) break;
+			len += sprintf(buffer+len,", %u",curr_table->table[count].last_pkts[pkt_count]);
+		}
+		len += sprintf(buffer+len,"\n");
+		pos = begin + len;
+		if(pos < offset) { len = 0; begin = pos; }
+		if(pos > offset + length) { len = last_len; break; }
+	}
+
+	*start = buffer + (offset - begin);
+	len -= (offset - begin);
+	if(len > length) len = length;
+
+	spin_unlock_bh(&curr_table->list_lock);
+	return len;
+}
+
+/* ip_recent_ctrl provides an interface for users to modify the table
+ * directly.  This allows adding entries, removing entries, and
+ * flushing the entire table.
+ * This is done by opening up the appropriate table for writing and
+ * sending one of:
+ * xx.xx.xx.xx   -- Add entry to table with current time
+ * +xx.xx.xx.xx  -- Add entry to table with current time
+ * -xx.xx.xx.xx  -- Remove entry from table
+ * clear         -- Flush table, remove all entries
+ */
+
+static int ip_recent_ctrl(struct file *file, const char *input, unsigned long size, void *data)
+{
+	static const u_int32_t max[4] = { 0xffffffff, 0xffffff, 0xffff, 0xff };
+	u_int32_t val;
+	int base, used = 0;
+	char c, *cp;
+	union iaddr {
+		uint8_t bytes[4];
+		uint32_t word;
+	} res;
+	uint8_t *pp = res.bytes;
+	int digit;
+
+	char buffer[20];
+	int len, check_set = 0, count;
+	u_int32_t addr = 0;
+	struct sk_buff *skb;
+	struct ipt_recent_info *info;
+	struct recent_ip_tables *curr_table;
+
+	curr_table = (struct recent_ip_tables*) data;
+
+	if(size > 20) len = 20; else len = size;
+
+	if(copy_from_user(buffer,input,len)) return -EFAULT;
+
+	if(len < 20) buffer[len] = '\0';
+
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": ip_recent_ctrl len: %d, input: `%.20s'\n",len,buffer);
+#endif
+
+	cp = buffer;
+	while(isspace(*cp)) { cp++; used++; if(used >= len-5) return used; }
+
+	/* Check if we are asked to flush the entire table */
+	if(!memcmp(cp,"clear",5)) {
+		used += 5;
+		spin_lock_bh(&curr_table->list_lock);
+		curr_table->time_pos = 0;
+		for(count = 0; count < ip_list_hash_size; count++) {
+			curr_table->hash_table[count] = -1;
+		}
+		for(count = 0; count < ip_list_tot; count++) {
+			curr_table->table[count].last_seen = 0;
+			curr_table->table[count].addr = 0;
+			curr_table->table[count].ttl = 0;
+			memset(curr_table->table[count].last_pkts,0,ip_pkt_list_tot*sizeof(u_int32_t));
+			curr_table->table[count].oldest_pkt = 0;
+			curr_table->table[count].time_pos = 0;
+			curr_table->time_info[count].position = count;
+			curr_table->time_info[count].time = 0;
+		}
+		spin_unlock_bh(&curr_table->list_lock);
+		return used;
+	}
+
+        check_set = IPT_RECENT_SET;
+	switch(*cp) {
+		case '+': check_set = IPT_RECENT_SET; cp++; used++; break;
+		case '-': check_set = IPT_RECENT_REMOVE; cp++; used++; break;
+		default: if(!isdigit(*cp)) return (used+1); break;
+	}
+
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": ip_recent_ctrl cp: `%c', check_set: %d\n",*cp,check_set);
+#endif
+	/* Get addr (effectively inet_aton()) */
+	/* Shamelessly stolen from libc, a function in the kernel for doing
+	 * this would, of course, be greatly preferred, but our options appear
+	 * to be rather limited, so we will just do it ourselves here.
+	 */
+	res.word = 0;
+
+	c = *cp;
+	for(;;) {
+		if(!isdigit(c)) return used;
+		val = 0; base = 10; digit = 0;
+		if(c == '0') {
+			c = *++cp;
+			if(c == 'x' || c == 'X') base = 16, c = *++cp;
+			else { base = 8; digit = 1; }
+		}
+		for(;;) {
+			if(isascii(c) && isdigit(c)) {
+				if(base == 8 && (c == '8' || c == '0')) return used;
+				val = (val * base) + (c - '0');
+				c = *++cp;
+				digit = 1;
+			} else if(base == 16 && isascii(c) && isxdigit(c)) {
+				val = (val << 4) | (c + 10 - (islower(c) ? 'a' : 'A'));
+				c = *++cp;
+				digit = 1;
+			} else break;
+		}
+		if(c == '.') {
+			if(pp > res.bytes + 2 || val > 0xff) return used;
+			*pp++ = val;
+			c = *++cp;
+		} else break;
+	}
+	used = cp - buffer;
+	if(c != '\0' && (!isascii(c) || !isspace(c))) return used;
+	if(c == '\n') used++;
+	if(!digit) return used;
+
+	if(val > max[pp - res.bytes]) return used;
+	addr = res.word | htonl(val);
+
+	if(!addr && check_set == IPT_RECENT_SET) return used;
+
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": ip_recent_ctrl c: %c, addr: %u used: %d\n",c,addr,used);
+#endif
+
+	/* Set up and just call match */
+	info = kmalloc(sizeof(struct ipt_recent_info),GFP_KERNEL);
+	if(!info) { return -ENOMEM; }
+	info->seconds = 0;
+	info->hit_count = 0;
+	info->check_set = check_set;
+	info->invert = 0;
+	info->side = IPT_RECENT_SOURCE;
+	strncpy(info->name,curr_table->name,IPT_RECENT_NAME_LEN);
+	info->name[IPT_RECENT_NAME_LEN-1] = '\0';
+
+	skb = kmalloc(sizeof(struct sk_buff),GFP_KERNEL);
+	if(!skb) { return -ENOMEM; }
+	skb->nh.iph = kmalloc(sizeof(struct iphdr),GFP_KERNEL);
+	if(!skb->nh.iph) { return -ENOMEM; }
+
+	skb->nh.iph->saddr = addr;
+	skb->nh.iph->daddr = 0;
+	/* Clear ttl since we have no way of knowing it */
+	skb->nh.iph->ttl = 0;
+	match(skb,NULL,NULL,info,0,NULL,sizeof(struct ipt_recent_info),NULL);
+
+	kfree(skb->nh.iph);
+	kfree(skb);
+	kfree(info);
+
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": Leaving ip_recent_ctrl addr: %u used: %d\n",addr,used);
+#endif
+	return used;
+}
+
+#endif /* CONFIG_PROC_FS */
+
+/* 'match' is our primary function, called by the kernel whenever a rule is
+ * hit with our module as an option to it.
+ * What this function does depends on what was specifically asked of it by
+ * the user:
+ * --set -- Add or update last seen time of the source address of the packet
+ *   -- matchinfo->check_set == IPT_RECENT_SET
+ * --rcheck -- Just check if the source address is in the list
+ *   -- matchinfo->check_set == IPT_RECENT_CHECK
+ * --update -- If the source address is in the list, update last_seen
+ *   -- matchinfo->check_set == IPT_RECENT_UPDATE
+ * --remove -- If the source address is in the list, remove it
+ *   -- matchinfo->check_set == IPT_RECENT_REMOVE
+ * --seconds -- Option to --rcheck/--update, only match if last_seen within seconds
+ *   -- matchinfo->seconds
+ * --hitcount -- Option to --rcheck/--update, only match if seen hitcount times
+ *   -- matchinfo->hit_count
+ * --seconds and --hitcount can be combined
+ */
+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 *hotdrop)
+{
+	int pkt_count, hits_found, ans;
+	unsigned long now;
+	const struct ipt_recent_info *info = matchinfo;
+	u_int32_t addr = 0, time_temp;
+	u_int8_t ttl = skb->nh.iph->ttl;
+	int *hash_table;
+	int orig_hash_result, hash_result, temp, location = 0, time_loc, end_collision_chain = -1;
+	struct time_info_list *time_info;
+	struct recent_ip_tables *curr_table;
+	struct recent_ip_tables *last_table;
+	struct recent_ip_list *r_list;
+
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": match() called\n");
+#endif
+
+	/* Default is false ^ info->invert */
+	ans = info->invert;
+
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": match(): name = '%s'\n",info->name);
+#endif
+
+	/* if out != NULL then routing has been done and TTL changed.
+	 * We change it back here internally for match what came in before routing. */
+	if(out) ttl++;
+
+	/* Find the right table */
+	spin_lock_bh(&recent_lock);
+	curr_table = r_tables;
+	while( (last_table = curr_table) && strncmp(info->name,curr_table->name,IPT_RECENT_NAME_LEN) && (curr_table = curr_table->next) );
+
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": match(): table found('%s')\n",info->name);
+#endif
+
+	spin_unlock_bh(&recent_lock);
+
+	/* Table with this name not found, match impossible */
+	if(!curr_table) { return ans; }
+
+	/* Make sure no one is changing the list while we work with it */
+	spin_lock_bh(&curr_table->list_lock);
+
+	r_list = curr_table->table;
+	if(info->side == IPT_RECENT_DEST) addr = skb->nh.iph->daddr; else addr = skb->nh.iph->saddr;
+
+	if(!addr) { 
+#ifdef DEBUG
+		if(debug) printk(KERN_INFO RECENT_NAME ": match() address (%u) invalid, leaving.\n",addr);
+#endif
+		spin_unlock_bh(&curr_table->list_lock);
+		return ans;
+	}
+
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": match(): checking table, addr: %u, ttl: %u, orig_ttl: %u\n",addr,ttl,skb->nh.iph->ttl);
+#endif
+
+	/* Get jiffies now in case they changed while we were waiting for a lock */
+	now = jiffies;
+	hash_table = curr_table->hash_table;
+	time_info = curr_table->time_info;
+
+	orig_hash_result = hash_result = hash_func(addr,ip_list_hash_size);
+	/* Hash entry at this result used */
+	/* Check for TTL match if requested.  If TTL is zero then a match would never
+	 * happen, so match regardless of existing TTL in that case.  Zero means the
+	 * entry was added via the /proc interface anyway, so we will just use the
+	 * first TTL we get for that IP address. */
+	if(info->check_set & IPT_RECENT_TTL) {
+		while(hash_table[hash_result] != -1 && !(r_list[hash_table[hash_result]].addr == addr &&
+			(!r_list[hash_table[hash_result]].ttl || r_list[hash_table[hash_result]].ttl == ttl))) {
+			/* Collision in hash table */
+			hash_result = (hash_result + 1) % ip_list_hash_size;
+		}
+	} else {
+		while(hash_table[hash_result] != -1 && r_list[hash_table[hash_result]].addr != addr) {
+			/* Collision in hash table */
+			hash_result = (hash_result + 1) % ip_list_hash_size;
+		}
+	}
+
+	if(hash_table[hash_result] == -1 && !(info->check_set & IPT_RECENT_SET)) {
+		/* IP not in list and not asked to SET */
+		spin_unlock_bh(&curr_table->list_lock);
+		return ans;
+	}
+
+	/* Check if we need to handle the collision, do not need to on REMOVE */
+	if(orig_hash_result != hash_result && !(info->check_set & IPT_RECENT_REMOVE)) {
+#ifdef DEBUG
+		if(debug) printk(KERN_INFO RECENT_NAME ": match(): Collision in hash table. (or: %d,hr: %d,oa: %u,ha: %u)\n",
+				 orig_hash_result,
+				 hash_result,
+				 r_list[hash_table[orig_hash_result]].addr,
+				 addr);
+#endif
+
+		/* We had a collision.
+		 * orig_hash_result is where we started, hash_result is where we ended up.
+		 * So, swap them because we are likely to see the same guy again sooner */
+#ifdef DEBUG
+		if(debug) {
+		  printk(KERN_INFO RECENT_NAME ": match(): Collision; hash_table[orig_hash_result] = %d\n",hash_table[orig_hash_result]);
+		  printk(KERN_INFO RECENT_NAME ": match(): Collision; r_list[hash_table[orig_hash_result]].hash_entry = %d\n",
+				r_list[hash_table[orig_hash_result]].hash_entry);
+		}
+#endif
+
+		r_list[hash_table[orig_hash_result]].hash_entry = hash_result;
+
+
+		temp = hash_table[orig_hash_result];
+#ifdef DEBUG
+		if(debug) printk(KERN_INFO RECENT_NAME ": match(): Collision; hash_table[hash_result] = %d\n",hash_table[hash_result]);
+#endif
+		hash_table[orig_hash_result] = hash_table[hash_result];
+		hash_table[hash_result] = temp;
+		temp = hash_result;
+		hash_result = orig_hash_result;
+		orig_hash_result = temp;
+		time_info[r_list[hash_table[orig_hash_result]].time_pos].position = hash_table[orig_hash_result];
+		if(hash_table[hash_result] != -1) {
+			r_list[hash_table[hash_result]].hash_entry = hash_result;
+			time_info[r_list[hash_table[hash_result]].time_pos].position = hash_table[hash_result];
+		}
+
+#ifdef DEBUG
+		if(debug) printk(KERN_INFO RECENT_NAME ": match(): Collision handled.\n");
+#endif
+	}
+
+	if(hash_table[hash_result] == -1) {
+#ifdef DEBUG
+		if(debug) printk(KERN_INFO RECENT_NAME ": match(): New table entry. (hr: %d,ha: %u)\n",
+				 hash_result, addr);
+#endif
+
+		/* New item found and IPT_RECENT_SET, so we need to add it */
+		location = time_info[curr_table->time_pos].position;
+		hash_table[r_list[location].hash_entry] = -1;
+		hash_table[hash_result] = location;
+		memset(r_list[location].last_pkts,0,ip_pkt_list_tot*sizeof(u_int32_t));
+		r_list[location].time_pos = curr_table->time_pos;
+		r_list[location].addr = addr;
+		r_list[location].ttl = ttl;
+		r_list[location].last_seen = now;
+		r_list[location].oldest_pkt = 1;
+		r_list[location].last_pkts[0] = now;
+		r_list[location].hash_entry = hash_result;
+		time_info[curr_table->time_pos].time = r_list[location].last_seen;
+		curr_table->time_pos = (curr_table->time_pos + 1) % ip_list_tot;
+
+		ans = !info->invert;
+	} else {
+#ifdef DEBUG
+		if(debug) printk(KERN_INFO RECENT_NAME ": match(): Existing table entry. (hr: %d,ha: %u)\n",
+				 hash_result,
+				 addr);
+#endif
+
+		/* Existing item found */
+		location = hash_table[hash_result];
+		/* We have a match on address, now to make sure it meets all requirements for a
+		 * full match. */
+		if(info->check_set & IPT_RECENT_CHECK || info->check_set & IPT_RECENT_UPDATE) {
+			if(!info->seconds && !info->hit_count) ans = !info->invert; else ans = info->invert;
+			if(info->seconds && !info->hit_count) {
+				if(time_before_eq(now,r_list[location].last_seen+info->seconds*HZ)) ans = !info->invert; else ans = info->invert;
+			}
+			if(info->seconds && info->hit_count) {
+				for(pkt_count = 0, hits_found = 0; pkt_count < ip_pkt_list_tot; pkt_count++) {
+					if(time_before_eq(now,r_list[location].last_pkts[pkt_count]+info->seconds*HZ)) hits_found++;
+				}
+				if(hits_found >= info->hit_count) ans = !info->invert; else ans = info->invert;
+			}
+			if(info->hit_count && !info->seconds) {
+				for(pkt_count = 0, hits_found = 0; pkt_count < ip_pkt_list_tot; pkt_count++) {
+					if(r_list[location].last_pkts[pkt_count] == 0) break;
+					hits_found++;
+				}
+				if(hits_found >= info->hit_count) ans = !info->invert; else ans = info->invert;
+			}
+		}
+#ifdef DEBUG
+		if(debug) {
+			if(ans)
+				printk(KERN_INFO RECENT_NAME ": match(): match addr: %u\n",addr);
+			else
+				printk(KERN_INFO RECENT_NAME ": match(): no match addr: %u\n",addr);
+		}
+#endif
+
+		/* If and only if we have been asked to SET, or to UPDATE (on match) do we add the
+		 * current timestamp to the last_seen. */
+		if((info->check_set & IPT_RECENT_SET && (ans = !info->invert)) || (info->check_set & IPT_RECENT_UPDATE && ans)) {
+#ifdef DEBUG
+			if(debug) printk(KERN_INFO RECENT_NAME ": match(): SET or UPDATE; updating time info.\n");
+#endif
+			/* Have to update our time info */
+			time_loc = r_list[location].time_pos;
+			time_info[time_loc].time = now;
+			time_info[time_loc].position = location;
+			while((time_info[(time_loc+1) % ip_list_tot].time < time_info[time_loc].time) && ((time_loc+1) % ip_list_tot) != curr_table->time_pos) {
+				time_temp = time_info[time_loc].time;
+				time_info[time_loc].time = time_info[(time_loc+1)%ip_list_tot].time;
+				time_info[(time_loc+1)%ip_list_tot].time = time_temp;
+				time_temp = time_info[time_loc].position;
+				time_info[time_loc].position = time_info[(time_loc+1)%ip_list_tot].position;
+				time_info[(time_loc+1)%ip_list_tot].position = time_temp;
+				r_list[time_info[time_loc].position].time_pos = time_loc;
+				r_list[time_info[(time_loc+1)%ip_list_tot].position].time_pos = (time_loc+1)%ip_list_tot;
+				time_loc = (time_loc+1) % ip_list_tot;
+			}
+			r_list[location].time_pos = time_loc;
+			r_list[location].ttl = ttl;
+			r_list[location].last_pkts[r_list[location].oldest_pkt] = now;
+			r_list[location].oldest_pkt = ++r_list[location].oldest_pkt % ip_pkt_list_tot;
+			r_list[location].last_seen = now;
+		}
+		/* If we have been asked to remove the entry from the list, just set it to 0 */
+		if(info->check_set & IPT_RECENT_REMOVE) {
+#ifdef DEBUG
+			if(debug) printk(KERN_INFO RECENT_NAME ": match(): REMOVE; clearing entry (or: %d, hr: %d).\n",orig_hash_result,hash_result);
+#endif
+			/* Check if this is part of a collision chain */
+			while(hash_table[(orig_hash_result+1) % ip_list_hash_size] != -1) {
+				orig_hash_result++;
+				if(hash_func(r_list[hash_table[orig_hash_result]].addr,ip_list_hash_size) == hash_result) {
+					/* Found collision chain, how deep does this rabbit hole go? */
+#ifdef DEBUG
+					if(debug) printk(KERN_INFO RECENT_NAME ": match(): REMOVE; found collision chain.\n");
+#endif
+					end_collision_chain = orig_hash_result;
+				}
+			}
+			if(end_collision_chain != -1) {
+#ifdef DEBUG
+				if(debug) printk(KERN_INFO RECENT_NAME ": match(): REMOVE; part of collision chain, moving to end.\n");
+#endif
+				/* Part of a collision chain, swap it with the end of the chain
+				 * before removing. */
+				r_list[hash_table[end_collision_chain]].hash_entry = hash_result;
+				temp = hash_table[end_collision_chain];
+				hash_table[end_collision_chain] = hash_table[hash_result];
+				hash_table[hash_result] = temp;
+				time_info[r_list[hash_table[hash_result]].time_pos].position = hash_table[hash_result];
+				hash_result = end_collision_chain;
+				r_list[hash_table[hash_result]].hash_entry = hash_result;
+				time_info[r_list[hash_table[hash_result]].time_pos].position = hash_table[hash_result];
+			}
+			location = hash_table[hash_result];
+			hash_table[r_list[location].hash_entry] = -1;
+			time_loc = r_list[location].time_pos;
+			time_info[time_loc].time = 0;
+			time_info[time_loc].position = location;
+			while((time_info[(time_loc+1) % ip_list_tot].time < time_info[time_loc].time) && ((time_loc+1) % ip_list_tot) != curr_table->time_pos) {
+				time_temp = time_info[time_loc].time;
+				time_info[time_loc].time = time_info[(time_loc+1)%ip_list_tot].time;
+				time_info[(time_loc+1)%ip_list_tot].time = time_temp;
+				time_temp = time_info[time_loc].position;
+				time_info[time_loc].position = time_info[(time_loc+1)%ip_list_tot].position;
+				time_info[(time_loc+1)%ip_list_tot].position = time_temp;
+				r_list[time_info[time_loc].position].time_pos = time_loc;
+				r_list[time_info[(time_loc+1)%ip_list_tot].position].time_pos = (time_loc+1)%ip_list_tot;
+				time_loc = (time_loc+1) % ip_list_tot;
+			}
+			r_list[location].time_pos = time_loc;
+			r_list[location].last_seen = 0;
+			r_list[location].addr = 0;
+			r_list[location].ttl = 0;
+			memset(r_list[location].last_pkts,0,ip_pkt_list_tot*sizeof(u_int32_t));
+			r_list[location].oldest_pkt = 0;
+			ans = !info->invert;
+		}
+		spin_unlock_bh(&curr_table->list_lock);
+		return ans;
+	}
+
+	spin_unlock_bh(&curr_table->list_lock);
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": match() left.\n");
+#endif
+	return ans;
+}
+
+/* This function is to verify that the rule given during the userspace iptables
+ * command is correct.
+ * If the command is valid then we check if the table name referred to by the
+ * rule exists, if not it is created.
+ */
+static int
+checkentry(const char *tablename,
+           const struct ipt_ip *ip,
+           void *matchinfo,
+           unsigned int matchsize,
+           unsigned int hook_mask)
+{
+	int flag = 0, c;
+	u_int32_t *hold;
+	const struct ipt_recent_info *info = matchinfo;
+	struct recent_ip_tables *curr_table, *find_table, *last_table;
+
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": checkentry() entered.\n");
+#endif
+
+	if (matchsize != IPT_ALIGN(sizeof(struct ipt_recent_info))) return 0;
+
+	/* seconds and hit_count only valid for CHECK/UPDATE */
+	if(info->check_set & IPT_RECENT_SET) { flag++; if(info->seconds || info->hit_count) return 0; }
+	if(info->check_set & IPT_RECENT_REMOVE) { flag++; if(info->seconds || info->hit_count) return 0; }
+	if(info->check_set & IPT_RECENT_CHECK) flag++;
+	if(info->check_set & IPT_RECENT_UPDATE) flag++;
+
+	/* One and only one of these should ever be set */
+	if(flag != 1) return 0;
+
+	/* Name must be set to something */
+	if(!info->name || !info->name[0]) return 0;
+
+	/* Things look good, create a list for this if it does not exist */
+	/* Lock the linked list while we play with it */
+	spin_lock_bh(&recent_lock);
+
+	/* Look for an entry with this name already created */
+	/* Finds the end of the list and the entry before the end if current name does not exist */
+	find_table = r_tables;
+	while( (last_table = find_table) && strncmp(info->name,find_table->name,IPT_RECENT_NAME_LEN) && (find_table = find_table->next) );
+
+	/* If a table already exists just increment the count on that table and return */
+	if(find_table) { 
+#ifdef DEBUG
+		if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: table found (%s), incrementing count.\n",info->name);
+#endif
+		find_table->count++;
+		spin_unlock_bh(&recent_lock);
+		return 1;
+	}
+
+	spin_unlock_bh(&recent_lock);
+
+	/* Table with this name not found */
+	/* Allocate memory for new linked list item */
+
+#ifdef DEBUG
+	if(debug) {
+		printk(KERN_INFO RECENT_NAME ": checkentry: no table found (%s)\n",info->name);
+		printk(KERN_INFO RECENT_NAME ": checkentry: Allocationg %d for link-list entry.\n",sizeof(struct recent_ip_tables));
+	}
+#endif
+
+	curr_table = vmalloc(sizeof(struct recent_ip_tables));
+	if(curr_table == NULL) return -ENOMEM;
+
+	curr_table->list_lock = SPIN_LOCK_UNLOCKED;
+	curr_table->next = NULL;
+	curr_table->count = 1;
+	curr_table->time_pos = 0;
+	strncpy(curr_table->name,info->name,IPT_RECENT_NAME_LEN);
+	curr_table->name[IPT_RECENT_NAME_LEN-1] = '\0';
+
+	/* Allocate memory for this table and the list of packets in each entry. */
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: Allocating %d for table (%s).\n",
+			sizeof(struct recent_ip_list)*ip_list_tot,
+			info->name);
+#endif
+
+	curr_table->table = vmalloc(sizeof(struct recent_ip_list)*ip_list_tot);
+	if(curr_table->table == NULL) { vfree(curr_table); return -ENOMEM; }
+	memset(curr_table->table,0,sizeof(struct recent_ip_list)*ip_list_tot);
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: Allocating %d for pkt_list.\n",
+			sizeof(u_int32_t)*ip_pkt_list_tot*ip_list_tot);
+#endif
+
+	hold = vmalloc(sizeof(u_int32_t)*ip_pkt_list_tot*ip_list_tot);
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: After pkt_list allocation.\n");
+#endif
+	if(hold == NULL) { 
+		printk(KERN_INFO RECENT_NAME ": checkentry: unable to allocate for pkt_list.\n");
+		vfree(curr_table->table); 
+		vfree(curr_table);
+		return -ENOMEM;
+	}
+	for(c = 0; c < ip_list_tot; c++) {
+		curr_table->table[c].last_pkts = hold + c*ip_pkt_list_tot;
+	}
+
+	/* Allocate memory for the hash table */
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: Allocating %d for hash_table.\n",
+			sizeof(int)*ip_list_hash_size);
+#endif
+
+	curr_table->hash_table = vmalloc(sizeof(int)*ip_list_hash_size);
+	if(!curr_table->hash_table) {
+		printk(KERN_INFO RECENT_NAME ": checkentry: unable to allocate for hash_table.\n");
+		vfree(hold);
+		vfree(curr_table->table); 
+		vfree(curr_table);
+		return -ENOMEM;
+	}
+
+	for(c = 0; c < ip_list_hash_size; c++) {
+		curr_table->hash_table[c] = -1;
+	}
+
+	/* Allocate memory for the time info */
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: Allocating %d for time_info.\n",
+			sizeof(struct time_info_list)*ip_list_tot);
+#endif
+
+	curr_table->time_info = vmalloc(sizeof(struct time_info_list)*ip_list_tot);
+	if(!curr_table->time_info) {
+		printk(KERN_INFO RECENT_NAME ": checkentry: unable to allocate for time_info.\n");
+		vfree(curr_table->hash_table);
+		vfree(hold);
+		vfree(curr_table->table); 
+		vfree(curr_table);
+		return -ENOMEM;
+	}
+	for(c = 0; c < ip_list_tot; c++) {
+		curr_table->time_info[c].position = c;
+		curr_table->time_info[c].time = 0;
+	}
+
+	/* Put the new table in place */
+	spin_lock_bh(&recent_lock);
+	find_table = r_tables;
+	while( (last_table = find_table) && strncmp(info->name,find_table->name,IPT_RECENT_NAME_LEN) && (find_table = find_table->next) );
+
+	/* If a table already exists just increment the count on that table and return */
+	if(find_table) { 
+		find_table->count++;	
+		spin_unlock_bh(&recent_lock);
+#ifdef DEBUG
+		if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: table found (%s), created by other process.\n",info->name);
+#endif
+		vfree(curr_table->time_info);
+		vfree(curr_table->hash_table);
+		vfree(hold);
+		vfree(curr_table->table);
+		vfree(curr_table);
+		return 1;
+	}
+	if(!last_table) r_tables = curr_table; else last_table->next = curr_table;
+
+	spin_unlock_bh(&recent_lock);
+
+#ifdef CONFIG_PROC_FS
+	/* Create our proc 'status' entry. */
+	curr_table->status_proc = create_proc_entry(curr_table->name, ip_list_perms, proc_net_ipt_recent);
+	if (!curr_table->status_proc) {
+		printk(KERN_INFO RECENT_NAME ": checkentry: unable to allocate for /proc entry.\n");
+		/* Destroy the created table */
+		spin_lock_bh(&recent_lock);
+		last_table = NULL;
+		curr_table = r_tables;
+		if(!curr_table) {
+#ifdef DEBUG
+			if(debug) printk(KERN_INFO RECENT_NAME ": checkentry() create_proc failed, no tables.\n");
+#endif
+			spin_unlock_bh(&recent_lock);
+			return -ENOMEM;
+		}
+		while( strncmp(info->name,curr_table->name,IPT_RECENT_NAME_LEN) && (last_table = curr_table) && (curr_table = curr_table->next) );
+		if(!curr_table) {
+#ifdef DEBUG
+			if(debug) printk(KERN_INFO RECENT_NAME ": checkentry() create_proc failed, table already destroyed.\n");
+#endif
+			spin_unlock_bh(&recent_lock);
+			return -ENOMEM;
+		}
+		if(last_table) last_table->next = curr_table->next; else r_tables = curr_table->next;
+		spin_unlock_bh(&recent_lock);
+		vfree(curr_table->time_info);
+		vfree(curr_table->hash_table);
+		vfree(hold);
+		vfree(curr_table->table);
+		vfree(curr_table);
+		return -ENOMEM;
+	}
+	
+	curr_table->status_proc->owner = THIS_MODULE;
+	curr_table->status_proc->data = curr_table;
+	wmb();
+	curr_table->status_proc->read_proc = ip_recent_get_info;
+	curr_table->status_proc->write_proc = ip_recent_ctrl;
+#endif /* CONFIG_PROC_FS */
+
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": checkentry() left.\n");
+#endif
+
+	return 1;
+}
+
+/* This function is called in the event that a rule matching this module is
+ * removed.
+ * When this happens we need to check if there are no other rules matching
+ * the table given.  If that is the case then we remove the table and clean
+ * up its memory.
+ */
+static void
+destroy(void *matchinfo, unsigned int matchsize)
+{
+	const struct ipt_recent_info *info = matchinfo;
+	struct recent_ip_tables *curr_table, *last_table;
+
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": destroy() entered.\n");
+#endif
+
+	if(matchsize != IPT_ALIGN(sizeof(struct ipt_recent_info))) return;
+
+	/* Lock the linked list while we play with it */
+	spin_lock_bh(&recent_lock);
+
+	/* Look for an entry with this name already created */
+	/* Finds the end of the list and the entry before the end if current name does not exist */
+	last_table = NULL;
+	curr_table = r_tables;
+	if(!curr_table) { 
+#ifdef DEBUG
+		if(debug) printk(KERN_INFO RECENT_NAME ": destroy() No tables found, leaving.\n");
+#endif
+		spin_unlock_bh(&recent_lock);
+		return;
+	}
+	while( strncmp(info->name,curr_table->name,IPT_RECENT_NAME_LEN) && (last_table = curr_table) && (curr_table = curr_table->next) );
+
+	/* If a table does not exist then do nothing and return */
+	if(!curr_table) { 
+#ifdef DEBUG
+		if(debug) printk(KERN_INFO RECENT_NAME ": destroy() table not found, leaving.\n");
+#endif
+		spin_unlock_bh(&recent_lock);
+		return;
+	}
+
+	curr_table->count--;
+
+	/* If count is still non-zero then there are still rules referenceing it so we do nothing */
+	if(curr_table->count) { 
+#ifdef DEBUG
+		if(debug) printk(KERN_INFO RECENT_NAME ": destroy() table found, non-zero count, leaving.\n");
+#endif
+		spin_unlock_bh(&recent_lock);
+		return;
+	}
+
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": destroy() table found, zero count, removing.\n");
+#endif
+
+	/* Count must be zero so we remove this table from the list */
+	if(last_table) last_table->next = curr_table->next; else r_tables = curr_table->next;
+
+	spin_unlock_bh(&recent_lock);
+
+	/* lock to make sure any late-runners still using this after we removed it from
+	 * the list finish up then remove everything */
+	spin_lock_bh(&curr_table->list_lock);
+	spin_unlock_bh(&curr_table->list_lock);
+
+#ifdef CONFIG_PROC_FS
+	if(curr_table->status_proc) remove_proc_entry(curr_table->name,proc_net_ipt_recent);
+#endif /* CONFIG_PROC_FS */
+	vfree(curr_table->table[0].last_pkts);
+	vfree(curr_table->table);
+	vfree(curr_table->hash_table);
+	vfree(curr_table->time_info);
+	vfree(curr_table);
+
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": destroy() left.\n");
+#endif
+
+	return;
+}
+
+/* This is the structure we pass to ipt_register to register our
+ * module with iptables.
+ */
+static struct ipt_match recent_match = { 
+  .name = "recent", 
+  .match = &match, 
+  .checkentry = &checkentry, 
+  .destroy = &destroy, 
+  .me = THIS_MODULE
+};
+
+/* Kernel module initialization. */
+static int __init init(void)
+{
+	int count;
+
+	printk(version);
+	proc_net_ipt_recent = proc_mkdir("ipt_recent",proc_net);
+	if(!proc_net_ipt_recent) return -ENOMEM;
+
+	if(ip_list_hash_size && ip_list_hash_size <= ip_list_tot) {
+	  printk(KERN_WARNING RECENT_NAME ": ip_list_hash_size too small, resetting to default.\n");
+	  ip_list_hash_size = 0;
+	}
+
+	if(!ip_list_hash_size) {
+		ip_list_hash_size = ip_list_tot*3;
+		count = 2*2;
+		while(ip_list_hash_size > count) count = count*2;
+		ip_list_hash_size = count;
+	}
+
+#ifdef DEBUG
+	if(debug) printk(KERN_INFO RECENT_NAME ": ip_list_hash_size: %d\n",ip_list_hash_size);
+#endif
+
+	return ipt_register_match(&recent_match);
+}
+
+/* Kernel module destruction. */
+static void __exit fini(void)
+{
+	ipt_unregister_match(&recent_match);
+
+	remove_proc_entry("ipt_recent",proc_net);
+}
+
+/* Register our module with the kernel. */
+module_init(init);
+module_exit(fini);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/route.c linux-2.4.22-pre2/net/ipv4/route.c
--- linux-2.4.21/net/ipv4/route.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/route.c	2003-06-26 21:43:33.000000000 +0000
@@ -108,7 +108,7 @@
 int ip_rt_max_size;
 int ip_rt_gc_timeout		= RT_GC_TIMEOUT;
 int ip_rt_gc_interval		= 60 * HZ;
-int ip_rt_gc_min_interval	= 5 * HZ;
+int ip_rt_gc_min_interval	= HZ / 2;
 int ip_rt_redirect_number	= 9;
 int ip_rt_redirect_load		= HZ / 50;
 int ip_rt_redirect_silence	= ((HZ / 50) << (9 + 1));
@@ -287,7 +287,7 @@
         for (lcpu = 0; lcpu < smp_num_cpus; lcpu++) {
                 i = cpu_logical_map(lcpu);
 
-		len += sprintf(buffer+len, "%08x  %08x %08x %08x %08x %08x %08x %08x  %08x %08x %08x %08x %08x %08x %08x \n",
+		len += sprintf(buffer+len, "%08x  %08x %08x %08x %08x %08x %08x %08x  %08x %08x %08x %08x %08x %08x %08x %08x %08x \n",
 			       dst_entries,		       
 			       rt_cache_stat[i].in_hit,
 			       rt_cache_stat[i].in_slow_tot,
@@ -304,7 +304,9 @@
 			       rt_cache_stat[i].gc_total,
 			       rt_cache_stat[i].gc_ignored,
 			       rt_cache_stat[i].gc_goal_miss,
-			       rt_cache_stat[i].gc_dst_overflow
+			       rt_cache_stat[i].gc_dst_overflow,
+			       rt_cache_stat[i].in_hlist_search,
+			       rt_cache_stat[i].out_hlist_search
 
 			);
 	}
@@ -344,16 +346,17 @@
 		rth->u.dst.expires;
 }
 
-static __inline__ int rt_may_expire(struct rtable *rth, int tmo1, int tmo2)
+static __inline__ int rt_may_expire(struct rtable *rth, unsigned long tmo1, unsigned long tmo2)
 {
-	int age;
+	unsigned long age;
 	int ret = 0;
 
 	if (atomic_read(&rth->u.dst.__refcnt))
 		goto out;
 
 	ret = 1;
-	if (rth->u.dst.expires && (long)(rth->u.dst.expires - jiffies) <= 0)
+	if (rth->u.dst.expires &&
+	    time_after_eq(jiffies, rth->u.dst.expires))
 		goto out;
 
 	age = jiffies - rth->u.dst.lastuse;
@@ -365,6 +368,25 @@
 out:	return ret;
 }
 
+/* Bits of score are:
+ * 31: very valuable
+ * 30: not quite useless
+ * 29..0: usage counter
+ */
+static inline u32 rt_score(struct rtable *rt)
+{
+	u32 score = rt->u.dst.__use;
+
+	if (rt_valuable(rt))
+		score |= (1<<31);
+
+	if (!rt->key.iif ||
+	    !(rt->rt_flags & (RTCF_BROADCAST|RTCF_MULTICAST|RTCF_LOCAL)))
+		score |= (1<<30);
+
+	return score;
+}
+
 /* This runs via a timer and thus is always in BH context. */
 static void SMP_TIMER_NAME(rt_check_expire)(unsigned long dummy)
 {
@@ -375,7 +397,7 @@
 
 	for (t = ip_rt_gc_interval << rt_hash_log; t >= 0;
 	     t -= ip_rt_gc_timeout) {
-		unsigned tmo = ip_rt_gc_timeout;
+		unsigned long tmo = ip_rt_gc_timeout;
 
 		i = (i + 1) & rt_hash_mask;
 		rthp = &rt_hash_table[i].chain;
@@ -384,7 +406,7 @@
 		while ((rth = *rthp) != NULL) {
 			if (rth->u.dst.expires) {
 				/* Entry is expired even if it is in use */
-				if ((long)(now - rth->u.dst.expires) <= 0) {
+				if (time_before_eq(now, rth->u.dst.expires)) {
 					tmo >>= 1;
 					rthp = &rth->u.rt_next;
 					continue;
@@ -402,7 +424,7 @@
 		write_unlock(&rt_hash_table[i].lock);
 
 		/* Fallback loop breaker. */
-		if ((jiffies - now) > 0)
+		if (time_after(jiffies, now))
 			break;
 	}
 	rover = i;
@@ -504,7 +526,7 @@
 
 static int rt_garbage_collect(void)
 {
-	static unsigned expire = RT_GC_TIMEOUT;
+	static unsigned long expire = RT_GC_TIMEOUT;
 	static unsigned long last_gc;
 	static int rover;
 	static int equilibrium;
@@ -556,7 +578,7 @@
 		int i, k;
 
 		for (i = rt_hash_mask, k = rover; i >= 0; i--) {
-			unsigned tmo = expire;
+			unsigned long tmo = expire;
 
 			k = (k + 1) & rt_hash_mask;
 			rthp = &rt_hash_table[k].chain;
@@ -602,7 +624,7 @@
 
 		if (atomic_read(&ipv4_dst_ops.entries) < ip_rt_max_size)
 			goto out;
-	} while (!in_softirq() && jiffies - now < 1);
+	} while (!in_softirq() && time_before_eq(jiffies, now));
 
 	if (atomic_read(&ipv4_dst_ops.entries) < ip_rt_max_size)
 		goto out;
@@ -626,10 +648,19 @@
 static int rt_intern_hash(unsigned hash, struct rtable *rt, struct rtable **rp)
 {
 	struct rtable	*rth, **rthp;
-	unsigned long	now = jiffies;
+	unsigned long	now;
+	struct rtable *cand, **candp;
+	u32 		min_score;
+	int		chain_length;
 	int attempts = !in_softirq();
 
 restart:
+	chain_length = 0;
+	min_score = ~(u32)0;
+	cand = NULL;
+	candp = NULL;
+	now = jiffies;
+
 	rthp = &rt_hash_table[hash].chain;
 
 	write_lock_bh(&rt_hash_table[hash].lock);
@@ -650,9 +681,35 @@
 			return 0;
 		}
 
+		if (!atomic_read(&rth->u.dst.__refcnt)) {
+			u32 score = rt_score(rth);
+
+			if (score <= min_score) {
+				cand = rth;
+				candp = rthp;
+				min_score = score;
+			}
+		}
+
+		chain_length++;
+
 		rthp = &rth->u.rt_next;
 	}
 
+	if (cand) {
+		/* ip_rt_gc_elasticity used to be average length of chain
+		 * length, when exceeded gc becomes really aggressive.
+		 *
+		 * The second limit is less certain. At the moment it allows
+		 * only 2 entries per bucket. We will see.
+		 */
+		if (chain_length > ip_rt_gc_elasticity ||
+		    (chain_length > 1 && !(min_score & (1<<31)))) {
+			*candp = cand->u.rt_next;
+			rt_free(cand);
+		}
+	}
+
 	/* Try to bind route to arp only if it is output
 	   route or unicast forwarding path.
 	 */
@@ -960,7 +1017,7 @@
 	/* No redirected packets during ip_rt_redirect_silence;
 	 * reset the algorithm.
 	 */
-	if (jiffies - rt->u.dst.rate_last > ip_rt_redirect_silence)
+	if (time_after(jiffies, rt->u.dst.rate_last + ip_rt_redirect_silence))
 		rt->u.dst.rate_tokens = 0;
 
 	/* Too many ignored redirects; do not send anything
@@ -974,8 +1031,9 @@
 	/* Check for load limit; set rate_last to the latest sent
 	 * redirect.
 	 */
-	if (jiffies - rt->u.dst.rate_last >
-	    (ip_rt_redirect_load << rt->u.dst.rate_tokens)) {
+	if (time_after(jiffies,
+		       (rt->u.dst.rate_last +
+			(ip_rt_redirect_load << rt->u.dst.rate_tokens)))) {
 		icmp_send(skb, ICMP_REDIRECT, ICMP_REDIR_HOST, rt->rt_gateway);
 		rt->u.dst.rate_last = jiffies;
 		++rt->u.dst.rate_tokens;
@@ -1672,6 +1730,7 @@
 			skb->dst = (struct dst_entry*)rth;
 			return 0;
 		}
+		rt_cache_stat[smp_processor_id()].in_hlist_search++;
 	}
 	read_unlock(&rt_hash_table[hash].lock);
 
@@ -1691,7 +1750,7 @@
 
 		read_lock(&inetdev_lock);
 		if ((in_dev = __in_dev_get(dev)) != NULL) {
-			int our = ip_check_mc(in_dev, daddr);
+			int our = ip_check_mc(in_dev, daddr, saddr);
 			if (our
 #ifdef CONFIG_IP_MROUTE
 			    || (!LOCAL_MCAST(daddr) && IN_DEV_MFORWARD(in_dev))
@@ -1917,7 +1976,7 @@
 		flags |= RTCF_MULTICAST|RTCF_LOCAL;
 		read_lock(&inetdev_lock);
 		if (!__in_dev_get(dev_out) ||
-		    !ip_check_mc(__in_dev_get(dev_out), oldkey->dst))
+		    !ip_check_mc(__in_dev_get(dev_out),oldkey->dst,oldkey->src))
 			flags &= ~RTCF_LOCAL;
 		read_unlock(&inetdev_lock);
 		/* If multicast route do not exist use
@@ -2032,6 +2091,7 @@
 			*rp = rth;
 			return 0;
 		}
+		rt_cache_stat[smp_processor_id()].out_hlist_search++;
 	}
 	read_unlock_bh(&rt_hash_table[hash].lock);
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/tcp.c linux-2.4.22-pre2/net/ipv4/tcp.c
--- linux-2.4.21/net/ipv4/tcp.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/tcp.c	2003-06-26 21:43:15.000000000 +0000
@@ -2067,7 +2067,7 @@
 
 /* These states need RST on ABORT according to RFC793 */
 
-extern __inline__ int tcp_need_reset(int state)
+static inline int tcp_need_reset(int state)
 {
 	return ((1 << state) &
 	       	(TCPF_ESTABLISHED|TCPF_CLOSE_WAIT|TCPF_FIN_WAIT1|
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/tcp_diag.c linux-2.4.22-pre2/net/ipv4/tcp_diag.c
--- linux-2.4.21/net/ipv4/tcp_diag.c	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/tcp_diag.c	2003-06-26 21:43:21.000000000 +0000
@@ -578,7 +578,7 @@
 }
 
 
-extern __inline__ void tcpdiag_rcv_skb(struct sk_buff *skb)
+static inline void tcpdiag_rcv_skb(struct sk_buff *skb)
 {
 	int err;
 	struct nlmsghdr * nlh;
@@ -588,7 +588,7 @@
 		if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len)
 			return;
 		err = tcpdiag_rcv_msg(skb, nlh);
-		if (err) 
+		if (err || nlh->nlmsg_flags & NLM_F_ACK) 
 			netlink_ack(skb, nlh, err);
 	}
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/tcp_ipv4.c linux-2.4.22-pre2/net/ipv4/tcp_ipv4.c
--- linux-2.4.21/net/ipv4/tcp_ipv4.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/tcp_ipv4.c	2003-06-26 21:43:16.000000000 +0000
@@ -163,7 +163,7 @@
 	spin_unlock(&head->lock);
 }
 
-__inline__ void tcp_inherit_port(struct sock *sk, struct sock *child)
+inline void tcp_inherit_port(struct sock *sk, struct sock *child)
 {
 	local_bh_disable();
 	__tcp_inherit_port(sk, child);
@@ -292,7 +292,7 @@
 /* Get rid of any references to a local port held by the
  * given sock.
  */
-__inline__ void __tcp_put_port(struct sock *sk)
+inline void __tcp_put_port(struct sock *sk)
 {
 	struct tcp_bind_hashbucket *head = &tcp_bhash[tcp_bhashfn(sk->num)];
 	struct tcp_bind_bucket *tb;
@@ -457,7 +457,7 @@
 }
 
 /* Optimize the common listener case. */
-__inline__ struct sock *tcp_v4_lookup_listener(u32 daddr, unsigned short hnum, int dif)
+inline struct sock *tcp_v4_lookup_listener(u32 daddr, unsigned short hnum, int dif)
 {
 	struct sock *sk;
 
@@ -533,7 +533,7 @@
 	return tcp_v4_lookup_listener(daddr, hnum, dif);
 }
 
-__inline__ struct sock *tcp_v4_lookup(u32 saddr, u16 sport, u32 daddr, u16 dport, int dif)
+inline struct sock *tcp_v4_lookup(u32 saddr, u16 sport, u32 daddr, u16 dport, int dif)
 {
 	struct sock *sk;
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/tcp_minisocks.c linux-2.4.22-pre2/net/ipv4/tcp_minisocks.c
--- linux-2.4.21/net/ipv4/tcp_minisocks.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/tcp_minisocks.c	2003-06-26 21:43:13.000000000 +0000
@@ -447,6 +447,8 @@
 
 	while((tw = tcp_tw_death_row[tcp_tw_death_row_slot]) != NULL) {
 		tcp_tw_death_row[tcp_tw_death_row_slot] = tw->next_death;
+		if (tw->next_death)
+			tw->next_death->pprev_death = tw->pprev_death;
 		tw->pprev_death = NULL;
 		spin_unlock(&tw_death_lock);
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/udp.c linux-2.4.22-pre2/net/ipv4/udp.c
--- linux-2.4.21/net/ipv4/udp.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/udp.c	2003-06-26 21:43:12.000000000 +0000
@@ -271,6 +271,8 @@
 	return sk;
 }
 
+extern int ip_mc_sf_allow(struct sock *sk, u32 local, u32 rmt, int dif);
+
 static inline struct sock *udp_v4_mcast_next(struct sock *sk,
 					     u16 loc_port, u32 loc_addr,
 					     u16 rmt_port, u32 rmt_addr,
@@ -286,6 +288,8 @@
 		    ipv6_only_sock(s)					||
 		    (s->bound_dev_if && s->bound_dev_if != dif))
 			continue;
+		if (!ip_mc_sf_allow(sk, loc_addr, rmt_addr, dif))
+			continue;
 		break;
   	}
   	return s;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv4/utils.c linux-2.4.22-pre2/net/ipv4/utils.c
--- linux-2.4.21/net/ipv4/utils.c	2002-08-03 00:39:46.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv4/utils.c	2003-06-26 21:43:20.000000000 +0000
@@ -21,26 +21,8 @@
  *		2 of the License, or (at your option) any later version.
  */
 
-#include <asm/uaccess.h>
-#include <asm/system.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/in.h>
-#include <linux/errno.h>
-#include <linux/stat.h>
-#include <stdarg.h>
-#include <linux/inet.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <net/ip.h>
-#include <net/protocol.h>
-#include <net/tcp.h>
-#include <linux/skbuff.h>
-
+#include <asm/byteorder.h>
 
 /*
  *	Convert an ASCII string to binary IP. 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv6/addrconf.c linux-2.4.22-pre2/net/ipv6/addrconf.c
--- linux-2.4.21/net/ipv6/addrconf.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv6/addrconf.c	2003-06-26 21:43:18.000000000 +0000
@@ -19,7 +19,7 @@
  *
  *	Janos Farkas			:	delete timer on ifdown
  *	<chexum@bankinf.banki.hu>
- *	Andi Kleen			:	kill doube kfree on module
+ *	Andi Kleen			:	kill double kfree on module
  *						unload.
  *	Maciej W. Rozycki		:	FDDI support
  *	sekiya@USAGI			:	Don't send too many RS
@@ -30,6 +30,7 @@
  *						address validation timer.
  *	Yuji SEKIYA @USAGI		:	Don't assign a same IPv6
  *						address on a same interface.
+ *	YOSHIFUJI Hideaki @USAGI	:	ARCnet support
  */
 
 #include <linux/config.h>
@@ -42,6 +43,7 @@
 #include <linux/in6.h>
 #include <linux/netdevice.h>
 #include <linux/if_arp.h>
+#include <linux/if_arcnet.h>
 #include <linux/route.h>
 #include <linux/inetdevice.h>
 #include <linux/init.h>
@@ -827,6 +829,13 @@
 		eui[4] = 0xFE;
 		eui[0] ^= 2;
 		return 0;
+	case ARPHRD_ARCNET:
+		/* XXX: inherit EUI-64 fro mother interface -- yoshfuji */
+		if (dev->addr_len != ARCNET_ALEN)
+			return -1;
+		memset(eui, 0, 7);
+		eui[7] = *(u8*)dev->dev_addr;
+		return 0;
 	}
 	return -1;
 }
@@ -903,7 +912,7 @@
 	rtmsg.rtmsg_type	= RTMSG_NEWROUTE;
 	rtmsg.rtmsg_metric	= IP6_RT_PRIO_ADDRCONF;
 
-	/* prefix length - 96 bytes "::d.d.d.d" */
+	/* prefix length - 96 bits "::d.d.d.d" */
 	rtmsg.rtmsg_dst_len	= 96;
 	rtmsg.rtmsg_flags	= RTF_UP|RTF_NONEXTHOP;
 	rtmsg.rtmsg_ifindex	= dev->ifindex;
@@ -1355,7 +1364,8 @@
 
 	if ((dev->type != ARPHRD_ETHER) && 
 	    (dev->type != ARPHRD_FDDI) &&
-	    (dev->type != ARPHRD_IEEE802_TR)) {
+	    (dev->type != ARPHRD_IEEE802_TR) &&
+	    (dev->type != ARPHRD_ARCNET)) {
 		/* Alas, we support only Ethernet autoconfiguration. */
 		return;
 	}
@@ -2188,6 +2198,7 @@
 		case ARPHRD_ETHER:
 		case ARPHRD_FDDI:
 		case ARPHRD_IEEE802_TR:	
+		case ARPHRD_ARCNET:
 			addrconf_dev_config(dev);
 			break;
 		default:;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv6/af_inet6.c linux-2.4.22-pre2/net/ipv6/af_inet6.c
--- linux-2.4.21/net/ipv6/af_inet6.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv6/af_inet6.c	2003-06-26 21:43:10.000000000 +0000
@@ -259,7 +259,7 @@
 	} else {
 		if (addr_type != IPV6_ADDR_ANY) {
 			/* ipv4 addr of the socket is invalid.  Only the
-			 * unpecified and mapped address have a v4 equivalent.
+			 * unspecified and mapped address have a v4 equivalent.
 			 */
 			v4addr = LOOPBACK4_IPV6;
 			if (!(addr_type & IPV6_ADDR_MULTICAST))	{
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv6/anycast.c linux-2.4.22-pre2/net/ipv6/anycast.c
--- linux-2.4.21/net/ipv6/anycast.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv6/anycast.c	2003-06-26 21:43:32.000000000 +0000
@@ -127,8 +127,8 @@
 			dev_hold(dev);
 			dst_release(&rt->u.dst);
 		} else if (ishost) {
-			sock_kfree_s(sk, pac, sizeof(*pac));
-			return -EADDRNOTAVAIL;
+			err = -EADDRNOTAVAIL;
+			goto out_free_pac;
 		} else {
 			/* router, no matching interface: just pick one */
 
@@ -138,18 +138,17 @@
 		dev = dev_get_by_index(ifindex);
 
 	if (dev == NULL) {
-		sock_kfree_s(sk, pac, sizeof(*pac));
-		return -ENODEV;
+		err = -ENODEV;
+		goto out_free_pac;
 	}
 
 	idev = in6_dev_get(dev);
 	if (!idev) {
-		sock_kfree_s(sk, pac, sizeof(*pac));
-		dev_put(dev);
 		if (ifindex)
-			return -ENODEV;
+			err = -ENODEV;
 		else
-			return -EADDRNOTAVAIL;
+			err = -EADDRNOTAVAIL;
+		goto out_dev_put;
 	}
 	/* reset ishost, now that we have a specific device */
 	ishost = !idev->cnf.forwarding;
@@ -170,21 +169,17 @@
 			err = -EADDRNOTAVAIL;
 		else if (!capable(CAP_NET_ADMIN))
 			err = -EPERM;
-		if (err) {
-			sock_kfree_s(sk, pac, sizeof(*pac));
-			dev_put(dev);
-			return err;
-		}
+		if (err)
+			goto out_dev_put;
 	} else if (!(ipv6_addr_type(addr) & IPV6_ADDR_ANYCAST) &&
-		   !capable(CAP_NET_ADMIN))
-		return -EPERM;
+		   !capable(CAP_NET_ADMIN)) {
+		err = -EPERM;
+		goto out_dev_put;
+	}
 
 	err = ipv6_dev_ac_inc(dev, addr);
-	if (err) {
-		sock_kfree_s(sk, pac, sizeof(*pac));
-		dev_put(dev);
-		return err;
-	}
+	if (err)
+		goto out_dev_put;
 
 	write_lock_bh(&ipv6_sk_ac_lock);
 	pac->acl_next = np->ipv6_ac_list;
@@ -194,6 +189,12 @@
 	dev_put(dev);
 
 	return 0;
+
+out_dev_put:
+	dev_put(dev);
+out_free_pac:
+	sock_kfree_s(sk, pac, sizeof(*pac));
+	return err;
 }
 
 /*
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv6/exthdrs.c linux-2.4.22-pre2/net/ipv6/exthdrs.c
--- linux-2.4.21/net/ipv6/exthdrs.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv6/exthdrs.c	2003-06-26 21:43:11.000000000 +0000
@@ -235,8 +235,13 @@
 		return (&hdr->nexthdr) - skb->nh.raw;
 	}
 
-	if (hdr->type != IPV6_SRCRT_TYPE_0 || (hdr->hdrlen & 0x01)) {
-		icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, hdr->type != IPV6_SRCRT_TYPE_0 ? 2 : 1);
+	if (hdr->type != IPV6_SRCRT_TYPE_0) {
+		icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, (&hdr->type) - skb->nh.raw);
+		return -1;
+	}
+	
+	if (hdr->hdrlen & 0x01) {
+		icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, (&hdr->hdrlen) - skb->nh.raw);
 		return -1;
 	}
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv6/ip6_fib.c linux-2.4.22-pre2/net/ipv6/ip6_fib.c
--- linux-2.4.21/net/ipv6/ip6_fib.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv6/ip6_fib.c	2003-06-26 21:43:14.000000000 +0000
@@ -594,7 +594,7 @@
 
 #ifdef CONFIG_IPV6_SUBTREES
 	/* Subtree creation failed, probably main tree node
-	   is orphan. If it is, shot it.
+	   is orphan. If it is, shoot it.
 	 */
 st_failure:
 	if (fn && !(fn->fn_flags&RTN_RTINFO|RTN_ROOT))
@@ -954,7 +954,7 @@
 
 #if RT6_DEBUG >= 2
 	if (rt->u.dst.obsolete>0) {
-		BUG_TRAP(fn==NULL || rt->u.dst.obsolete<=0);
+		BUG_TRAP(fn==NULL);
 		return -ENOENT;
 	}
 #endif
@@ -980,7 +980,7 @@
 }
 
 /*
- *	Tree transversal function.
+ *	Tree traversal function.
  *
  *	Certainly, it is not interrupt safe.
  *	However, it is internally reenterable wrt itself and fib6_add/fib6_del.
@@ -1181,14 +1181,14 @@
 	 */
 
 	if (rt->rt6i_flags&RTF_EXPIRES && rt->rt6i_expires) {
-		if ((long)(now - rt->rt6i_expires) > 0) {
+		if (time_after(now, rt->rt6i_expires)) {
 			RT6_TRACE("expiring %p\n", rt);
 			return -1;
 		}
 		gc_args.more++;
 	} else if (rt->rt6i_flags & RTF_CACHE) {
 		if (atomic_read(&rt->u.dst.__refcnt) == 0 &&
-		    (long)(now - rt->u.dst.lastuse) >= gc_args.timeout) {
+		    time_after_eq(now, rt->u.dst.lastuse + gc_args.timeout)) {
 			RT6_TRACE("aging clone %p\n", rt);
 			return -1;
 		}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv6/ip6_input.c linux-2.4.22-pre2/net/ipv6/ip6_input.c
--- linux-2.4.21/net/ipv6/ip6_input.c	2001-04-12 19:11:39.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv6/ip6_input.c	2003-06-26 21:43:13.000000000 +0000
@@ -221,7 +221,7 @@
 	IP6_INC_STATS_BH(Ip6InMcastPkts);
 
 	hdr = skb->nh.ipv6h;
-	if (ipv6_chk_mcast_addr(skb->dev, &hdr->daddr))
+	if (ipv6_chk_mcast_addr(skb->dev, &hdr->daddr, &hdr->saddr))
 		deliver = 1;
 
 	/*
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv6/ip6_output.c linux-2.4.22-pre2/net/ipv6/ip6_output.c
--- linux-2.4.21/net/ipv6/ip6_output.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv6/ip6_output.c	2003-06-26 21:43:11.000000000 +0000
@@ -69,8 +69,11 @@
 	struct hh_cache *hh = dst->hh;
 
 	if (hh) {
+		int hh_alen;
+
 		read_lock_bh(&hh->hh_lock);
-		memcpy(skb->data - 16, hh->hh_data, 16);
+		hh_alen = HH_DATA_ALIGN(hh->hh_len);
+		memcpy(skb->data - hh_alen, hh->hh_data, hh_alen);
 		read_unlock_bh(&hh->hh_lock);
 	        skb_push(skb, hh->hh_len);
 		return hh->hh_output(skb);
@@ -107,7 +110,8 @@
 	if (ipv6_addr_is_multicast(&skb->nh.ipv6h->daddr)) {
 		if (!(dev->flags&IFF_LOOPBACK) &&
 		    (skb->sk == NULL || skb->sk->net_pinfo.af_inet6.mc_loop) &&
-		    ipv6_chk_mcast_addr(dev, &skb->nh.ipv6h->daddr)) {
+		    ipv6_chk_mcast_addr(dev, &skb->nh.ipv6h->daddr,
+				&skb->nh.ipv6h->saddr)) {
 			struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC);
 
 			/* Do not check for IFF_ALLMULTI; multicast routing
@@ -243,6 +247,7 @@
 
 	if (net_ratelimit())
 		printk(KERN_DEBUG "IPv6: sending pkt_too_big to self\n");
+	skb->dev = dst->dev;
 	icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, dst->pmtu, skb->dev);
 	kfree_skb(skb);
 	return -EMSGSIZE;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv6/ipv6_sockglue.c linux-2.4.22-pre2/net/ipv6/ipv6_sockglue.c
--- linux-2.4.21/net/ipv6/ipv6_sockglue.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv6/ipv6_sockglue.c	2003-06-26 21:43:11.000000000 +0000
@@ -19,6 +19,10 @@
  *	o	Return -EINVAL for setsockopt of short lengths
  *	o	Truncate getsockopt returns
  *	o	Return an optlen of the truncated length if need be
+ *
+ *	Changes:
+ *	David L Stevens <dlstevens@us.ibm.com>:
+ *		- added multicast source filtering API for MLDv2
  */
 
 #include <linux/module.h>
@@ -117,6 +121,12 @@
 	return 0;
 }
 
+extern int ip6_mc_source(int add, int omode, struct sock *sk,
+	struct group_source_req *pgsr);
+extern int ip6_mc_msfilter(struct sock *sk, struct group_filter *gsf);
+extern int ip6_mc_msfget(struct sock *sk, struct group_filter *gsf,
+	struct group_filter *optval, int *optlen);
+
 
 int ipv6_setsockopt(struct sock *sk, int level, int optname, char *optval, 
 		    int optlen)
@@ -376,6 +386,91 @@
 			retv = ipv6_sock_ac_drop(sk, mreq.ipv6mr_ifindex, &mreq.ipv6mr_acaddr);
 		break;
 	}
+	case MCAST_JOIN_GROUP:
+	case MCAST_LEAVE_GROUP:
+	{
+		struct group_req greq;
+		struct sockaddr_in6 *psin6;
+
+		retv = -EFAULT;
+		if (copy_from_user(&greq, optval, sizeof(struct group_req)))
+			break;
+		if (greq.gr_group.ss_family != AF_INET6) {
+			retv = -EADDRNOTAVAIL;
+			break;
+		}
+		psin6 = (struct sockaddr_in6 *)&greq.gr_group;
+		if (optname == MCAST_JOIN_GROUP)
+			retv = ipv6_sock_mc_join(sk, greq.gr_interface,
+				&psin6->sin6_addr);
+		else
+			retv = ipv6_sock_mc_drop(sk, greq.gr_interface,
+				&psin6->sin6_addr);
+		break;
+	}
+	case MCAST_JOIN_SOURCE_GROUP:
+	case MCAST_LEAVE_SOURCE_GROUP:
+	case MCAST_BLOCK_SOURCE:
+	case MCAST_UNBLOCK_SOURCE:
+	{
+		struct group_source_req greqs;
+		int omode, add;
+
+		if (optlen != sizeof(struct group_source_req))
+			goto e_inval;
+		if (copy_from_user(&greqs, optval, sizeof(greqs))) {
+			retv = -EFAULT;
+			break;
+		}
+		if (greqs.gsr_group.ss_family != AF_INET6 ||
+		    greqs.gsr_source.ss_family != AF_INET6) {
+			retv = -EADDRNOTAVAIL;
+			break;
+		}
+		if (optname == MCAST_BLOCK_SOURCE) {
+			omode = MCAST_EXCLUDE;
+			add = 1;
+		} else if (optname == MCAST_UNBLOCK_SOURCE) {
+			omode = MCAST_EXCLUDE;
+			add = 0;
+		} else if (optname == MCAST_JOIN_SOURCE_GROUP) {
+			struct sockaddr_in6 *psin6;
+
+			psin6 = (struct sockaddr_in6 *)&greqs.gsr_group;
+			retv = ipv6_sock_mc_join(sk, greqs.gsr_interface,
+				&psin6->sin6_addr);
+			if (retv)
+				break;
+			omode = MCAST_INCLUDE;
+			add = 1;
+		} else /*IP_DROP_SOURCE_MEMBERSHIP */ {
+			omode = MCAST_INCLUDE;
+			add = 0;
+		}
+		retv = ip6_mc_source(add, omode, sk, &greqs);
+		break;
+	}
+	case MCAST_MSFILTER:
+	{
+		struct group_filter *gsf;
+
+		if (optlen < GROUP_FILTER_SIZE(0))
+			goto e_inval;
+		gsf = (struct group_filter *)kmalloc(optlen,GFP_KERNEL);
+		if (gsf == 0) {
+			retv = -ENOBUFS;
+			break;
+		}
+		retv = -EFAULT;
+		if (copy_from_user(gsf, optval, optlen)) {
+			kfree(gsf);
+			break;
+		}
+		retv = ip6_mc_msfilter(sk, gsf);
+		kfree(gsf);
+
+		break;
+	}
 	case IPV6_ROUTER_ALERT:
 		retv = ip6_ra_control(sk, val, NULL);
 		break;
@@ -498,6 +593,21 @@
 	case IPV6_PKTINFO:
 		val = np->rxopt.bits.rxinfo;
 		break;
+	case MCAST_MSFILTER:
+	{
+		struct group_filter gsf;
+		int err;
+
+		if (len < GROUP_FILTER_SIZE(0))
+			return -EINVAL;
+		if (copy_from_user(&gsf, optval, GROUP_FILTER_SIZE(0)))
+			return -EFAULT;
+		lock_sock(sk);
+		err = ip6_mc_msfget(sk, &gsf,
+			(struct group_filter *)optval, optlen);
+		release_sock(sk);
+		return err;
+	}
 
 	case IPV6_HOPLIMIT:
 		val = np->rxopt.bits.rxhlim;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv6/mcast.c linux-2.4.22-pre2/net/ipv6/mcast.c
--- linux-2.4.21/net/ipv6/mcast.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv6/mcast.c	2003-06-26 21:43:31.000000000 +0000
@@ -24,6 +24,8 @@
  *	YOSHIFUJI Hideaki @USAGI:
  *		- Ignore Queries for invalid addresses.
  *		- MLD for link-local addresses.
+ *	David L Stevens <dlstevens@us.ibm.com>:
+		- MLDv2 support
  */
 
 #include <linux/config.h>
@@ -35,6 +37,7 @@
 #include <linux/sockios.h>
 #include <linux/sched.h>
 #include <linux/net.h>
+#include <linux/in.h>
 #include <linux/in6.h>
 #include <linux/netdevice.h>
 #include <linux/if_arp.h>
@@ -63,6 +66,59 @@
 #define MDBG(x)
 #endif
 
+/*
+ *  These header formats should be in a separate include file, but icmpv6.h
+ *  doesn't have in6_addr defined in all cases, there is no __u128, and no
+ *  other files reference these.
+ *
+ *  			+-DLS 4/14/03
+ */
+
+/* Multicast Listener Discovery version 2 headers */
+
+struct mld2_grec {
+	__u8		grec_type;
+	__u8		grec_auxwords;
+	__u16		grec_nsrcs;
+	struct in6_addr	grec_mca;
+	struct in6_addr	grec_src[0];
+};
+
+struct mld2_report {
+	__u8	type;
+	__u8	resv1;
+	__u16	csum;
+	__u16	resv2;
+	__u16	ngrec;
+	struct mld2_grec grec[0];
+};
+
+struct mld2_query {
+	__u8 type;
+	__u8 code;
+	__u16 csum;
+	__u16 mrc;
+	__u16 resv1;
+	struct in6_addr mca;
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+	__u8 qrv:3,
+	     suppress:1,
+	     resv2:4;
+#elif defined(__BIG_ENDIAN_BITFIELD)
+	__u8 resv2:4,
+	     suppress:1,
+	     qrv:3;
+#else
+#error "Please fix <asm/byteorder.h>"
+#endif
+	__u8 qqic;
+	__u16 nsrcs;
+	struct in6_addr srcs[0];
+};
+
+struct in6_addr mld2_all_mcr = MLD2_ALL_MCR_INIT;
+struct in6_addr all_nodes_addr = {{{0xff,0x02,0,0,0,0,0,0,0,0,0,0,0,0,0,0x1}}};
+
 /* Big mc list lock for all the sockets */
 static rwlock_t ipv6_sk_mc_lock = RW_LOCK_UNLOCKED;
 
@@ -70,9 +126,39 @@
 
 static void igmp6_join_group(struct ifmcaddr6 *ma);
 static void igmp6_leave_group(struct ifmcaddr6 *ma);
-void igmp6_timer_handler(unsigned long data);
+static void igmp6_timer_handler(unsigned long data);
+
+static void mld_gq_timer_expire(unsigned long data);
+static void mld_ifc_timer_expire(unsigned long data);
+static void mld_ifc_event(struct inet6_dev *idev);
+static void mld_add_delrec(struct inet6_dev *idev, struct ifmcaddr6 *pmc);
+static void mld_del_delrec(struct inet6_dev *idev, struct in6_addr *addr);
+static void mld_clear_delrec(struct inet6_dev *idev);
+static int sf_setstate(struct ifmcaddr6 *pmc);
+static void sf_markstate(struct ifmcaddr6 *pmc);
+static void ip6_mc_clear_src(struct ifmcaddr6 *pmc);
+int ip6_mc_del_src(struct inet6_dev *idev, struct in6_addr *pmca, int sfmode,
+	int sfcount, struct in6_addr *psfsrc, int delta);
+int ip6_mc_add_src(struct inet6_dev *idev, struct in6_addr *pmca, int sfmode,
+	int sfcount, struct in6_addr *psfsrc, int delta);
+int ip6_mc_leave_src(struct sock *sk, struct ipv6_mc_socklist *iml,
+	struct inet6_dev *idev);
+
 
 #define IGMP6_UNSOLICITED_IVAL	(10*HZ)
+#define MLD_QRV_DEFAULT		2
+
+#define MLD_V1_SEEN(idev) ((idev)->mc_v1_seen && \
+		time_before(jiffies, (idev)->mc_v1_seen))
+
+#define MLDV2_MASK(value, nb) ((nb)>=32 ? (value) : ((1<<(nb))-1) & (value))
+#define MLDV2_EXP(thresh, nbmant, nbexp, value) \
+	((value) < (thresh) ? (value) : \
+	((MLDV2_MASK(value, nbmant) | (1<<(nbmant+nbexp))) << \
+	(MLDV2_MASK((value) >> (nbmant), nbexp) + (nbexp))))
+
+#define MLDV2_QQIC(value) MLDV2_EXP(0x80, 4, 3, value)
+#define MLDV2_MRC(value) MLDV2_EXP(0x8000, 12, 3, value)
 
 /*
  *	socket join on multicast group
@@ -113,6 +199,8 @@
 	}
 
 	mc_lst->ifindex = dev->ifindex;
+	mc_lst->sfmode = MCAST_EXCLUDE;
+	mc_lst->sflist = 0;
 
 	/*
 	 *	now add/increase the group membership on the device
@@ -154,6 +242,12 @@
 			write_unlock_bh(&ipv6_sk_mc_lock);
 
 			if ((dev = dev_get_by_index(ifindex)) != NULL) {
+				struct inet6_dev *idev = in6_dev_get(dev);
+
+				if (idev) {
+					(void) ip6_mc_leave_src(sk,mc_lst,idev);
+					in6_dev_put(idev);
+				}
 				ipv6_dev_mc_dec(dev, &mc_lst->addr);
 				dev_put(dev);
 			}
@@ -166,6 +260,40 @@
 	return -ENOENT;
 }
 
+struct inet6_dev *ip6_mc_find_dev(struct in6_addr *group, int ifindex)
+{
+	struct net_device *dev = 0;
+	struct inet6_dev *idev = 0;
+
+	if (ifindex == 0) {
+		struct rt6_info *rt;
+
+		rt = rt6_lookup(group, NULL, 0, 0);
+		if (rt) {
+			dev = rt->rt6i_dev;
+			dev_hold(dev);
+			dst_release(&rt->u.dst);
+		}
+	} else
+		dev = dev_get_by_index(ifindex);
+
+	if (!dev)
+		return 0;
+	idev = in6_dev_get(dev);
+	if (!idev) {
+		dev_put(dev);
+		return 0;
+	}
+	read_lock_bh(&idev->lock);
+	if (idev->dead) {
+		read_unlock_bh(&idev->lock);
+		in6_dev_put(idev);
+		dev_put(dev);
+		return 0;
+	}
+	return idev;
+}
+
 void ipv6_sock_mc_close(struct sock *sk)
 {
 	struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6;
@@ -180,6 +308,12 @@
 
 		dev = dev_get_by_index(mc_lst->ifindex);
 		if (dev) {
+			struct inet6_dev *idev = in6_dev_get(dev);
+
+			if (idev) {
+				(void) ip6_mc_leave_src(sk, mc_lst, idev);
+				in6_dev_put(idev);
+			}
 			ipv6_dev_mc_dec(dev, &mc_lst->addr);
 			dev_put(dev);
 		}
@@ -191,20 +325,293 @@
 	write_unlock_bh(&ipv6_sk_mc_lock);
 }
 
-int inet6_mc_check(struct sock *sk, struct in6_addr *addr)
+int ip6_mc_source(int add, int omode, struct sock *sk,
+	struct group_source_req *pgsr)
+{
+	struct in6_addr *source, *group;
+	struct ipv6_mc_socklist *pmc;
+	struct net_device *dev;
+	struct inet6_dev *idev;
+	struct ipv6_pinfo *inet6 = &sk->net_pinfo.af_inet6;
+	struct ip6_sf_socklist *psl;
+	int i, j, rv;
+	int err;
+
+	if (pgsr->gsr_group.ss_family != AF_INET6 ||
+	    pgsr->gsr_source.ss_family != AF_INET6)
+		return -EINVAL;
+
+	source = &((struct sockaddr_in6 *)&pgsr->gsr_source)->sin6_addr;
+	group = &((struct sockaddr_in6 *)&pgsr->gsr_group)->sin6_addr;
+
+	if (!(ipv6_addr_type(group) & IPV6_ADDR_MULTICAST))
+		return -EINVAL;
+
+	idev = ip6_mc_find_dev(group, pgsr->gsr_interface);
+	if (!idev)
+		return -ENODEV;
+	dev = idev->dev;
+
+	err = -EADDRNOTAVAIL;
+
+	for (pmc=inet6->ipv6_mc_list; pmc; pmc=pmc->next) {
+		if (pmc->ifindex != pgsr->gsr_interface)
+			continue;
+		if (ipv6_addr_cmp(&pmc->addr, group) == 0)
+			break;
+	}
+	if (!pmc)		/* must have a prior join */
+		goto done;
+	/* if a source filter was set, must be the same mode as before */
+	if (pmc->sflist) {
+		if (pmc->sfmode != omode)
+			goto done;
+	} else if (pmc->sfmode != omode) {
+		/* allow mode switches for empty-set filters */
+		ip6_mc_del_src(idev, group, pmc->sfmode, 0, 0, 0);
+		pmc->sfmode = omode;
+		ip6_mc_del_src(idev, group, pmc->sfmode, 0, 0, 0);
+	}
+
+	psl = pmc->sflist;
+	if (!add) {
+		if (!psl)
+			goto done;
+		rv = !0;
+		for (i=0; i<psl->sl_count; i++) {
+			rv = memcmp(&psl->sl_addr, group,
+				sizeof(struct in6_addr));
+			if (rv >= 0)
+				break;
+		}
+		if (!rv)	/* source not found */
+			goto done;
+
+		/* update the interface filter */
+		ip6_mc_del_src(idev, group, omode, 1, source, 1);
+
+		for (j=i+1; j<psl->sl_count; j++)
+			psl->sl_addr[j-1] = psl->sl_addr[j];
+		psl->sl_count--;
+		err = 0;
+		goto done;
+	}
+	/* else, add a new source to the filter */
+
+	if (!psl || psl->sl_count == psl->sl_max) {
+		struct ip6_sf_socklist *newpsl;
+		int count = IP6_SFBLOCK;
+
+		if (psl)
+			count += psl->sl_max;
+		newpsl = (struct ip6_sf_socklist *)sock_kmalloc(sk,
+			IP6_SFLSIZE(count), GFP_ATOMIC);
+		if (!newpsl) {
+			err = -ENOBUFS;
+			goto done;
+		}
+		newpsl->sl_max = count;
+		newpsl->sl_count = count - IP6_SFBLOCK;
+		if (psl) {
+			for (i=0; i<psl->sl_count; i++)
+				newpsl->sl_addr[i] = psl->sl_addr[i];
+			sock_kfree_s(sk, psl, IP6_SFLSIZE(psl->sl_max));
+		}
+		pmc->sflist = psl = newpsl;
+	}
+	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)
+			break;
+	}
+	if (rv == 0)		/* address already there is an error */
+		goto done;
+	for (j=psl->sl_count-1; j>=i; j--)
+		psl->sl_addr[j+1] = psl->sl_addr[j];
+	psl->sl_addr[i] = *source;
+	psl->sl_count++;
+	err = 0;
+	/* update the interface list */
+	ip6_mc_add_src(idev, group, omode, 1, source, 1);
+done:
+	read_unlock_bh(&idev->lock);
+	in6_dev_put(idev);
+	dev_put(dev);
+	return err;
+}
+
+int ip6_mc_msfilter(struct sock *sk, struct group_filter *gsf)
+{
+	struct in6_addr *group;
+	struct ipv6_mc_socklist *pmc;
+	struct net_device *dev;
+	struct inet6_dev *idev;
+	struct ipv6_pinfo *inet6 = &sk->net_pinfo.af_inet6;
+	struct ip6_sf_socklist *newpsl, *psl;
+	int i, err;
+
+	group = &((struct sockaddr_in6 *)&gsf->gf_group)->sin6_addr;
+
+	if (!(ipv6_addr_type(group) & IPV6_ADDR_MULTICAST))
+		return -EINVAL;
+	if (gsf->gf_fmode != MCAST_INCLUDE &&
+	    gsf->gf_fmode != MCAST_EXCLUDE)
+		return -EINVAL;
+
+	idev = ip6_mc_find_dev(group, gsf->gf_interface);
+
+	if (!idev)
+		return -ENODEV;
+	dev = idev->dev;
+	err = -EADDRNOTAVAIL;
+
+	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)
+			break;
+	}
+	if (!pmc)		/* must have a prior join */
+		goto done;
+	if (gsf->gf_numsrc) {
+		newpsl = (struct ip6_sf_socklist *)sock_kmalloc(sk,
+				IP6_SFLSIZE(gsf->gf_numsrc), GFP_ATOMIC);
+		if (!newpsl) {
+			err = -ENOBUFS;
+			goto done;
+		}
+		newpsl->sl_max = newpsl->sl_count = gsf->gf_numsrc;
+		for (i=0; i<newpsl->sl_count; ++i) {
+			struct sockaddr_in6 *psin6;
+
+			psin6 = (struct sockaddr_in6 *)&gsf->gf_slist[i];
+			newpsl->sl_addr[i] = psin6->sin6_addr;
+		}
+		err = ip6_mc_add_src(idev, group, gsf->gf_fmode,
+			newpsl->sl_count, newpsl->sl_addr, 0);
+		if (err) {
+			sock_kfree_s(sk, newpsl, IP6_SFLSIZE(newpsl->sl_max));
+			goto done;
+		}
+	} else
+		newpsl = 0;
+	psl = pmc->sflist;
+	if (psl) {
+		(void) ip6_mc_del_src(idev, group, pmc->sfmode,
+			psl->sl_count, psl->sl_addr, 0);
+		sock_kfree_s(sk, psl, IP6_SFLSIZE(psl->sl_max));
+	} else
+		(void) ip6_mc_del_src(idev, group, pmc->sfmode, 0, 0, 0);
+	pmc->sflist = newpsl;
+	pmc->sfmode = gsf->gf_fmode;
+done:
+	read_unlock_bh(&idev->lock);
+	in6_dev_put(idev);
+	dev_put(dev);
+	return err;
+}
+
+int ip6_mc_msfget(struct sock *sk, struct group_filter *gsf,
+	struct group_filter *optval, int *optlen)
+{
+	int err, i, count, copycount;
+	struct in6_addr *group;
+	struct ipv6_mc_socklist *pmc;
+	struct inet6_dev *idev;
+	struct net_device *dev;
+	struct ipv6_pinfo *inet6 = &sk->net_pinfo.af_inet6;
+	struct ip6_sf_socklist *psl;
+
+	group = &((struct sockaddr_in6 *)&gsf->gf_group)->sin6_addr;
+
+	if (!(ipv6_addr_type(group) & IPV6_ADDR_MULTICAST))
+		return -EINVAL;
+
+	idev = ip6_mc_find_dev(group, gsf->gf_interface);
+
+	if (!idev)
+		return -ENODEV;
+
+	dev = idev->dev;
+
+	err = -EADDRNOTAVAIL;
+
+	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)
+			break;
+	}
+	if (!pmc)		/* must have a prior join */
+		goto done;
+	gsf->gf_fmode = pmc->sfmode;
+	psl = pmc->sflist;
+	count = psl ? psl->sl_count : 0;
+	read_unlock_bh(&idev->lock);
+	in6_dev_put(idev);
+	dev_put(dev);
+
+	copycount = count < gsf->gf_numsrc ? count : gsf->gf_numsrc;
+	gsf->gf_numsrc = count;
+	if (put_user(GROUP_FILTER_SIZE(copycount), optlen) ||
+	    copy_to_user((void *)optval, gsf, GROUP_FILTER_SIZE(0))) {
+		return -EFAULT;
+	}
+	for (i=0; i<copycount; i++) {
+		struct sockaddr_in6 *psin6;
+		struct sockaddr_storage ss;
+
+		psin6 = (struct sockaddr_in6 *)&ss;
+		memset(&ss, 0, sizeof(ss));
+		psin6->sin6_family = AF_INET6;
+		psin6->sin6_addr = psl->sl_addr[i];
+	    	if (copy_to_user((void *)&optval->gf_slist[i], &ss, sizeof(ss)))
+			return -EFAULT;
+	}
+	return 0;
+done:
+	read_unlock_bh(&idev->lock);
+	in6_dev_put(idev);
+	dev_put(dev);
+	return err;
+}
+
+int inet6_mc_check(struct sock *sk, struct in6_addr *mc_addr,
+	struct in6_addr *src_addr)
 {
+	struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6;
 	struct ipv6_mc_socklist *mc;
+	struct ip6_sf_socklist *psl;
+	int rv = 1;
 
 	read_lock(&ipv6_sk_mc_lock);
-	for (mc = sk->net_pinfo.af_inet6.ipv6_mc_list; mc; mc=mc->next) {
-		if (ipv6_addr_cmp(&mc->addr, addr) == 0) {
-			read_unlock(&ipv6_sk_mc_lock);
-			return 1;
+	for (mc = np->ipv6_mc_list; mc; mc = mc->next) {
+		if (ipv6_addr_cmp(&mc->addr, mc_addr) == 0)
+			break;
+	}
+	if (!mc) {
+		read_unlock(&ipv6_sk_mc_lock);
+		return 1;
+	}
+	psl = mc->sflist;
+	if (!psl) {
+		rv = mc->sfmode == MCAST_EXCLUDE;
+	} else {
+		int i;
+
+		for (i=0; i<psl->sl_count; i++) {
+			if (ipv6_addr_cmp(&psl->sl_addr[i], src_addr) == 0)
+				break;
 		}
+		if (mc->sfmode == MCAST_INCLUDE && i >= psl->sl_count);
+			rv = 0;
+		if (mc->sfmode == MCAST_EXCLUDE && i < psl->sl_count);
+			rv = 0;
 	}
 	read_unlock(&ipv6_sk_mc_lock);
 
-	return 0;
+	return rv;
 }
 
 static void ma_put(struct ifmcaddr6 *mc)
@@ -215,7 +622,7 @@
 	}
 }
 
-static int igmp6_group_added(struct ifmcaddr6 *mc)
+static void igmp6_group_added(struct ifmcaddr6 *mc)
 {
 	struct net_device *dev = mc->idev->dev;
 	char buf[MAX_ADDR_LEN];
@@ -228,12 +635,20 @@
 	}
 	spin_unlock_bh(&mc->mca_lock);
 
-	if (dev->flags&IFF_UP)
+	if (!(dev->flags & IFF_UP) || (mc->mca_flags & MAF_NOREPORT))
+		return;
+
+	if (MLD_V1_SEEN(mc->idev)) {
 		igmp6_join_group(mc);
-	return 0;
+		return;
+	}
+	/* else v2 */
+
+	mc->mca_crcount = mc->idev->mc_qrv;
+	mld_ifc_event(mc->idev);
 }
 
-static int igmp6_group_dropped(struct ifmcaddr6 *mc)
+static void igmp6_group_dropped(struct ifmcaddr6 *mc)
 {
 	struct net_device *dev = mc->idev->dev;
 	char buf[MAX_ADDR_LEN];
@@ -246,9 +661,122 @@
 	}
 	spin_unlock_bh(&mc->mca_lock);
 
+	if (mc->mca_flags & MAF_NOREPORT)
+		goto done;
+
 	if (dev->flags&IFF_UP)
 		igmp6_leave_group(mc);
-	return 0;
+
+	spin_lock_bh(&mc->mca_lock);
+	if (del_timer(&mc->mca_timer))
+		atomic_dec(&mc->mca_refcnt);
+	spin_unlock_bh(&mc->mca_lock);
+
+done:
+	ip6_mc_clear_src(mc);
+}
+
+/*
+ * deleted ifmcaddr6 manipulation
+ */
+static void mld_add_delrec(struct inet6_dev *idev, struct ifmcaddr6 *im)
+{
+	struct ifmcaddr6 *pmc;
+
+	/* this is an "ifmcaddr6" for convenience; only the fields below
+	 * are actually used. In particular, the refcnt and users are not
+	 * used for management of the delete list. Using the same structure
+	 * for deleted items allows change reports to use common code with
+	 * non-deleted or query-response MCA's.
+	 */
+	pmc = (struct ifmcaddr6 *)kmalloc(sizeof(*pmc), GFP_ATOMIC);
+	if (!pmc)
+		return;
+	memset(pmc, 0, sizeof(*pmc));
+	spin_lock_bh(&im->mca_lock);
+	pmc->mca_lock = SPIN_LOCK_UNLOCKED;
+	pmc->idev = im->idev;
+	in6_dev_hold(idev);
+	pmc->mca_addr = im->mca_addr;
+	pmc->mca_crcount = idev->mc_qrv;
+	pmc->mca_sfmode = im->mca_sfmode;
+	if (pmc->mca_sfmode == MCAST_INCLUDE) {
+		struct ip6_sf_list *psf;
+
+		pmc->mca_tomb = im->mca_tomb;
+		pmc->mca_sources = im->mca_sources;
+		im->mca_tomb = im->mca_sources = 0;
+		for (psf=pmc->mca_sources; psf; psf=psf->sf_next)
+			psf->sf_crcount = pmc->mca_crcount;
+	}
+	spin_unlock_bh(&im->mca_lock);
+
+	write_lock_bh(&idev->mc_lock);
+	pmc->next = idev->mc_tomb;
+	idev->mc_tomb = pmc;
+	write_unlock_bh(&idev->mc_lock);
+}
+
+static void mld_del_delrec(struct inet6_dev *idev, struct in6_addr *pmca)
+{
+	struct ifmcaddr6 *pmc, *pmc_prev;
+	struct ip6_sf_list *psf, *psf_next;
+
+	write_lock_bh(&idev->mc_lock);
+	pmc_prev = 0;
+	for (pmc=idev->mc_tomb; pmc; pmc=pmc->next) {
+		if (ipv6_addr_cmp(&pmc->mca_addr, pmca) == 0)
+			break;
+		pmc_prev = pmc;
+	}
+	if (pmc) {
+		if (pmc_prev)
+			pmc_prev->next = pmc->next;
+		else
+			idev->mc_tomb = pmc->next;
+	}
+	write_unlock_bh(&idev->mc_lock);
+	if (pmc) {
+		for (psf=pmc->mca_tomb; psf; psf=psf_next) {
+			psf_next = psf->sf_next;
+			kfree(psf);
+		}
+		in6_dev_put(pmc->idev);
+		kfree(pmc);
+	}
+}
+
+static void mld_clear_delrec(struct inet6_dev *idev)
+{
+	struct ifmcaddr6 *pmc, *nextpmc;
+
+	write_lock_bh(&idev->mc_lock);
+	pmc = idev->mc_tomb;
+	idev->mc_tomb = 0;
+	write_unlock_bh(&idev->mc_lock);
+
+	for (; pmc; pmc = nextpmc) {
+		nextpmc = pmc->next;
+		ip6_mc_clear_src(pmc);
+		in6_dev_put(pmc->idev);
+		kfree(pmc);
+	}
+
+	/* clear dead sources, too */
+	read_lock_bh(&idev->lock);
+	for (pmc=idev->mc_list; pmc; pmc=pmc->next) {
+		struct ip6_sf_list *psf, *psf_next;
+
+		spin_lock_bh(&pmc->mca_lock);
+		psf = pmc->mca_tomb;
+		pmc->mca_tomb = 0;
+		spin_unlock_bh(&pmc->mca_lock);
+		for (; psf; psf=psf_next) {
+			psf_next = psf->sf_next;
+			kfree(psf);
+		}
+	}
+	read_unlock_bh(&idev->lock);
 }
 
 
@@ -276,6 +804,8 @@
 		if (ipv6_addr_cmp(&mc->mca_addr, addr) == 0) {
 			mc->mca_users++;
 			write_unlock_bh(&idev->lock);
+			ip6_mc_add_src(idev, &mc->mca_addr, MCAST_EXCLUDE, 0,
+				0, 0);
 			in6_dev_put(idev);
 			return 0;
 		}
@@ -303,10 +833,19 @@
 	atomic_set(&mc->mca_refcnt, 2);
 	mc->mca_lock = SPIN_LOCK_UNLOCKED;
 
+	/* initial mode is (EX, empty) */
+	mc->mca_sfmode = MCAST_EXCLUDE;
+	mc->mca_sfcount[MCAST_EXCLUDE] = 1;
+
+	if (ipv6_addr_cmp(&mc->mca_addr, &all_nodes_addr) == 0 ||
+	    IPV6_ADDR_MC_SCOPE(&mc->mca_addr) < IPV6_ADDR_SCOPE_LINKLOCAL)
+		mc->mca_flags |= MAF_NOREPORT;
+
 	mc->next = idev->mc_list;
 	idev->mc_list = mc;
 	write_unlock_bh(&idev->lock);
 
+	mld_del_delrec(idev, &mc->mca_addr);
 	igmp6_group_added(mc);
 	ma_put(mc);
 	return 0;
@@ -351,25 +890,57 @@
 /*
  *	check if the interface/address pair is valid
  */
-int ipv6_chk_mcast_addr(struct net_device *dev, struct in6_addr *addr)
+int ipv6_chk_mcast_addr(struct net_device *dev, struct in6_addr *group,
+	struct in6_addr *src_addr)
 {
 	struct inet6_dev *idev;
 	struct ifmcaddr6 *mc;
+	int rv = 0;
 
 	idev = in6_dev_get(dev);
 	if (idev) {
 		read_lock_bh(&idev->lock);
 		for (mc = idev->mc_list; mc; mc=mc->next) {
-			if (ipv6_addr_cmp(&mc->mca_addr, addr) == 0) {
-				read_unlock_bh(&idev->lock);
-				in6_dev_put(idev);
-				return 1;
+			if (ipv6_addr_cmp(&mc->mca_addr, group) == 0)
+				break;
+		}
+		if (mc) {
+			struct ip6_sf_list *psf;
+
+			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)
+					break;
 			}
+			if (psf)
+				rv = psf->sf_count[MCAST_INCLUDE] ||
+					psf->sf_count[MCAST_EXCLUDE] !=
+					mc->mca_sfcount[MCAST_EXCLUDE];
+			else
+				rv = mc->mca_sfcount[MCAST_EXCLUDE] != 0;
+			spin_unlock_bh(&mc->mca_lock);
 		}
 		read_unlock_bh(&idev->lock);
 		in6_dev_put(idev);
 	}
-	return 0;
+	return rv;
+}
+
+static void mld_gq_start_timer(struct inet6_dev *idev)
+{
+	int tv = net_random() % idev->mc_maxdelay;
+
+	idev->mc_gq_running = 1;
+	if (!mod_timer(&idev->mc_gq_timer, jiffies+tv+2))
+		in6_dev_hold(idev);
+}
+
+static void mld_ifc_start_timer(struct inet6_dev *idev, int delay)
+{
+	int tv = net_random() % delay;
+
+	if (!mod_timer(&idev->mc_ifc_timer, jiffies+tv+2))
+		in6_dev_hold(idev);
 }
 
 /*
@@ -384,7 +955,6 @@
 	if (ipv6_addr_type(&ma->mca_addr)&(IPV6_ADDR_LINKLOCAL|IPV6_ADDR_LOOPBACK))
 		return;
 
-	spin_lock(&ma->mca_lock);
 	if (del_timer(&ma->mca_timer)) {
 		atomic_dec(&ma->mca_refcnt);
 		delay = ma->mca_timer.expires - jiffies;
@@ -403,53 +973,134 @@
 	spin_unlock(&ma->mca_lock);
 }
 
+static void mld_marksources(struct ifmcaddr6 *pmc, int nsrcs,
+	struct in6_addr *srcs)
+{
+	struct ip6_sf_list *psf;
+	int i, scount;
+
+	scount = 0;
+	for (psf=pmc->mca_sources; psf; psf=psf->sf_next) {
+		if (scount == nsrcs)
+			break;
+		for (i=0; i<nsrcs; i++)
+			if (ipv6_addr_cmp(&srcs[i], &psf->sf_addr) == 0) {
+				psf->sf_gsresp = 1;
+				scount++;
+				break;
+			}
+	}
+}
+
 int igmp6_event_query(struct sk_buff *skb)
 {
+	struct mld2_query *mlh2 = (struct mld2_query *) skb->h.raw;
 	struct ifmcaddr6 *ma;
-	struct in6_addr *addrp;
-	unsigned long resptime;
+	struct in6_addr *group;
+	unsigned long max_delay;
 	struct inet6_dev *idev;
 	struct icmp6hdr *hdr;
-	int addr_type;
+	int group_type;
+	int mark = 0;
+	int len;
 
 	if (!pskb_may_pull(skb, sizeof(struct in6_addr)))
 		return -EINVAL;
 
-	hdr = (struct icmp6hdr*) skb->h.raw;
+	len = ntohs(skb->nh.ipv6h->payload_len);
 
 	/* Drop queries with not link local source */
 	if (!(ipv6_addr_type(&skb->nh.ipv6h->saddr)&IPV6_ADDR_LINKLOCAL))
 		return -EINVAL;
 
-	resptime = ntohs(hdr->icmp6_maxdelay);
-	/* Translate milliseconds to jiffies */
-	resptime = (resptime<<10)/(1024000/HZ);
-
-	addrp = (struct in6_addr *) (hdr + 1);
-	addr_type = ipv6_addr_type(addrp);
-
-	if (addr_type != IPV6_ADDR_ANY &&
-	    !(addr_type&IPV6_ADDR_MULTICAST))
-		return -EINVAL;
-
 	idev = in6_dev_get(skb->dev);
 
 	if (idev == NULL)
 		return 0;
 
-	read_lock(&idev->lock);
-	if (addr_type == IPV6_ADDR_ANY) {
-		for (ma = idev->mc_list; ma; ma=ma->next)
-			igmp6_group_queried(ma, resptime);
+	hdr = (struct icmp6hdr *) skb->h.raw;
+	group = (struct in6_addr *) (hdr + 1);
+	group_type = ipv6_addr_type(group);
+
+	if (group_type != IPV6_ADDR_ANY &&
+	    !(group_type&IPV6_ADDR_MULTICAST)) {
+		in6_dev_put(idev);
+		return -EINVAL;
+	}
+
+	if (len == 24) {
+		int switchback;
+		/* MLDv1 router present */
+
+		/* Translate milliseconds to jiffies */
+		max_delay = ntohs(hdr->icmp6_maxdelay)*(HZ/10);
+
+		switchback = (idev->mc_qrv + 1) * max_delay;
+		idev->mc_v1_seen = jiffies + switchback;
+
+		/* cancel the interface change timer */
+		idev->mc_ifc_count = 0;
+		if (del_timer(&idev->mc_ifc_timer))
+			__in6_dev_put(idev);
+		/* clear deleted report items */
+		mld_clear_delrec(idev);
+	} else if (len >= 28) {
+		max_delay = MLDV2_MRC(ntohs(mlh2->mrc))*(HZ/10);
+		if (!max_delay)
+			max_delay = 1;
+		idev->mc_maxdelay = max_delay;
+		if (mlh2->qrv)
+			idev->mc_qrv = mlh2->qrv;
+		if (group_type == IPV6_ADDR_ANY) { /* general query */
+			if (mlh2->nsrcs) {
+				in6_dev_put(idev);
+				return -EINVAL; /* no sources allowed */
+			}
+			mld_gq_start_timer(idev);
+			in6_dev_put(idev);
+			return 0;
+		}
+		/* mark sources to include, if group & source-specific */
+		mark = mlh2->nsrcs != 0;
+	} else {
+		in6_dev_put(idev);
+		return -EINVAL;
+	}
+
+	read_lock_bh(&idev->lock);
+	if (group_type == IPV6_ADDR_ANY) {
+		for (ma = idev->mc_list; ma; ma=ma->next) {
+			spin_lock_bh(&ma->mca_lock);
+			igmp6_group_queried(ma, max_delay);
+			spin_unlock_bh(&ma->mca_lock);
+		}
 	} else {
 		for (ma = idev->mc_list; ma; ma=ma->next) {
-			if (ipv6_addr_cmp(addrp, &ma->mca_addr) == 0) {
-				igmp6_group_queried(ma, resptime);
-				break;
+			if (group_type != IPV6_ADDR_ANY &&
+			    ipv6_addr_cmp(group, &ma->mca_addr) != 0)
+				continue;
+			spin_lock_bh(&ma->mca_lock);
+			if (ma->mca_flags & MAF_TIMER_RUNNING) {
+				/* gsquery <- gsquery && mark */
+				if (!mark)
+					ma->mca_flags &= ~MAF_GSQUERY;
+			} else {
+				/* gsquery <- mark */
+				if (mark)
+					ma->mca_flags |= MAF_GSQUERY;
+				else
+					ma->mca_flags &= ~MAF_GSQUERY;
 			}
+			if (ma->mca_flags & MAF_GSQUERY)
+				mld_marksources(ma, ntohs(mlh2->nsrcs),
+					mlh2->srcs);
+			igmp6_group_queried(ma, max_delay);
+			spin_unlock_bh(&ma->mca_lock);
+			if (group_type != IPV6_ADDR_ANY)
+				break;
 		}
 	}
-	read_unlock(&idev->lock);
+	read_unlock_bh(&idev->lock);
 	in6_dev_put(idev);
 
 	return 0;
@@ -489,7 +1140,7 @@
 	 *	Cancel the timer for this group
 	 */
 
-	read_lock(&idev->lock);
+	read_lock_bh(&idev->lock);
 	for (ma = idev->mc_list; ma; ma=ma->next) {
 		if (ipv6_addr_cmp(&ma->mca_addr, addrp) == 0) {
 			spin_lock(&ma->mca_lock);
@@ -500,11 +1151,385 @@
 			break;
 		}
 	}
-	read_unlock(&idev->lock);
+	read_unlock_bh(&idev->lock);
 	in6_dev_put(idev);
 	return 0;
 }
 
+static int is_in(struct ifmcaddr6 *pmc, struct ip6_sf_list *psf, int type,
+	int gdeleted, int sdeleted)
+{
+	switch (type) {
+	case MLD2_MODE_IS_INCLUDE:
+	case MLD2_MODE_IS_EXCLUDE:
+		if (gdeleted || sdeleted)
+			return 0;
+		return !((pmc->mca_flags & MAF_GSQUERY) && !psf->sf_gsresp);
+	case MLD2_CHANGE_TO_INCLUDE:
+		if (gdeleted || sdeleted)
+			return 0;
+		return psf->sf_count[MCAST_INCLUDE] != 0;
+	case MLD2_CHANGE_TO_EXCLUDE:
+		if (gdeleted || sdeleted)
+			return 0;
+		if (pmc->mca_sfcount[MCAST_EXCLUDE] == 0 ||
+		    psf->sf_count[MCAST_INCLUDE])
+			return 0;
+		return pmc->mca_sfcount[MCAST_EXCLUDE] ==
+			psf->sf_count[MCAST_EXCLUDE];
+	case MLD2_ALLOW_NEW_SOURCES:
+		if (gdeleted || !psf->sf_crcount)
+			return 0;
+		return (pmc->mca_sfmode == MCAST_INCLUDE) ^ sdeleted;
+	case MLD2_BLOCK_OLD_SOURCES:
+		if (pmc->mca_sfmode == MCAST_INCLUDE)
+			return gdeleted || (psf->sf_crcount && sdeleted);
+		return psf->sf_crcount && !gdeleted && !sdeleted;
+	}
+	return 0;
+}
+
+static int
+mld_scount(struct ifmcaddr6 *pmc, int type, int gdeleted, int sdeleted)
+{
+	struct ip6_sf_list *psf;
+	int scount = 0;
+
+	for (psf=pmc->mca_sources; psf; psf=psf->sf_next) {
+		if (!is_in(pmc, psf, type, gdeleted, sdeleted))
+			continue;
+		scount++;
+	}
+	return scount;
+}
+
+static struct sk_buff *mld_newpack(struct net_device *dev, int size)
+{
+	struct sock *sk = igmp6_socket->sk;
+	struct sk_buff *skb;
+	struct mld2_report *pmr;
+	struct in6_addr addr_buf;
+	int err;
+	u8 ra[8] = { IPPROTO_ICMPV6, 0,
+		     IPV6_TLV_ROUTERALERT, 2, 0, 0,
+		     IPV6_TLV_PADN, 0 };
+
+	skb = sock_alloc_send_skb(sk, size + dev->hard_header_len+15, 1, &err);
+
+	if (skb == 0)
+		return 0;
+
+	skb_reserve(skb, (dev->hard_header_len + 15) & ~15);
+	if (dev->hard_header) {
+		unsigned char ha[MAX_ADDR_LEN];
+
+		ndisc_mc_map(&mld2_all_mcr, ha, dev, 1);
+		if (dev->hard_header(skb, dev, ETH_P_IPV6,ha,NULL,size) < 0) {
+			kfree_skb(skb);
+			return 0;
+		}
+	}
+
+	if (ipv6_get_lladdr(dev, &addr_buf)) {
+		/* <draft-ietf-magma-mld-source-02.txt>:
+		 * use unspecified address as the source address 
+		 * when a valid link-local address is not available.
+		 */
+		memset(&addr_buf, 0, sizeof(addr_buf));
+	}
+
+	ip6_nd_hdr(sk, skb, dev, &addr_buf, &mld2_all_mcr, NEXTHDR_HOP, 0);
+
+	memcpy(skb_put(skb, sizeof(ra)), ra, sizeof(ra));
+
+	pmr =(struct mld2_report *)skb_put(skb, sizeof(*pmr));
+	skb->h.raw = (unsigned char *)pmr;
+	pmr->type = ICMPV6_MLD2_REPORT;
+	pmr->resv1 = 0;
+	pmr->csum = 0;
+	pmr->resv2 = 0;
+	pmr->ngrec = 0;
+	return skb;
+}
+
+static void mld_sendpack(struct sk_buff *skb)
+{
+	struct ipv6hdr *pip6 = skb->nh.ipv6h;
+	struct mld2_report *pmr = (struct mld2_report *)skb->h.raw;
+	int payload_len, mldlen;
+
+	payload_len = skb->tail - (unsigned char *)skb->nh.ipv6h -
+		sizeof(struct ipv6hdr);
+	mldlen = skb->tail - skb->h.raw;
+	pip6->payload_len = htons(payload_len);
+
+	pmr->csum = csum_ipv6_magic(&pip6->saddr, &pip6->daddr, mldlen,
+		IPPROTO_ICMPV6, csum_partial(skb->h.raw, mldlen, 0));
+	dev_queue_xmit(skb);
+	ICMP6_INC_STATS(Icmp6OutMsgs);
+}
+
+static int grec_size(struct ifmcaddr6 *pmc, int type, int gdel, int sdel)
+{
+	return sizeof(struct mld2_grec) + 4*mld_scount(pmc,type,gdel,sdel);
+}
+
+static struct sk_buff *add_grhead(struct sk_buff *skb, struct ifmcaddr6 *pmc,
+	int type, struct mld2_grec **ppgr)
+{
+	struct net_device *dev = pmc->idev->dev;
+	struct mld2_report *pmr;
+	struct mld2_grec *pgr;
+
+	if (!skb)
+		skb = mld_newpack(dev, dev->mtu);
+	if (!skb)
+		return 0;
+	pgr = (struct mld2_grec *)skb_put(skb, sizeof(struct mld2_grec));
+	pgr->grec_type = type;
+	pgr->grec_auxwords = 0;
+	pgr->grec_nsrcs = 0;
+	pgr->grec_mca = pmc->mca_addr;	/* structure copy */
+	pmr = (struct mld2_report *)skb->h.raw;
+	pmr->ngrec = htons(ntohs(pmr->ngrec)+1);
+	*ppgr = pgr;
+	return skb;
+}
+
+#define AVAILABLE(skb) ((skb) ? ((skb)->dev ? (skb)->dev->mtu - (skb)->len : \
+	skb_tailroom(skb)) : 0)
+
+static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc,
+	int type, int gdeleted, int sdeleted)
+{
+	struct net_device *dev = pmc->idev->dev;
+	struct mld2_report *pmr;
+	struct mld2_grec *pgr = 0;
+	struct ip6_sf_list *psf, *psf_next, *psf_prev, *psf_list;
+	int scount, first, isquery, truncate;
+
+	if (pmc->mca_flags & MAF_NOREPORT)
+		return skb;
+
+	isquery = type == MLD2_MODE_IS_INCLUDE ||
+		  type == MLD2_MODE_IS_EXCLUDE;
+	truncate = type == MLD2_MODE_IS_EXCLUDE ||
+		    type == MLD2_CHANGE_TO_EXCLUDE;
+
+	psf_list = sdeleted ? pmc->mca_tomb : pmc->mca_sources;
+
+	if (!psf_list) {
+		if (type == MLD2_ALLOW_NEW_SOURCES ||
+		    type == MLD2_BLOCK_OLD_SOURCES)
+			return skb;
+		if (pmc->mca_crcount || isquery) {
+			/* make sure we have room for group header and at
+			 * least one source.
+			 */
+			if (skb && AVAILABLE(skb) < sizeof(struct mld2_grec)+
+			    sizeof(struct in6_addr)) {
+				mld_sendpack(skb);
+				skb = 0; /* add_grhead will get a new one */
+			}
+			skb = add_grhead(skb, pmc, type, &pgr);
+		}
+		return skb;
+	}
+	pmr = skb ? (struct mld2_report *)skb->h.raw : 0;
+
+	/* EX and TO_EX get a fresh packet, if needed */
+	if (truncate) {
+		if (pmr && pmr->ngrec &&
+		    AVAILABLE(skb) < grec_size(pmc, type, gdeleted, sdeleted)) {
+			if (skb)
+				mld_sendpack(skb);
+			skb = mld_newpack(dev, dev->mtu);
+		}
+	}
+	first = 1;
+	scount = 0;
+	psf_prev = 0;
+	for (psf=psf_list; psf; psf=psf_next) {
+		struct in6_addr *psrc;
+
+		psf_next = psf->sf_next;
+
+		if (!is_in(pmc, psf, type, gdeleted, sdeleted)) {
+			psf_prev = psf;
+			continue;
+		}
+
+		/* clear marks on query responses */
+		if (isquery)
+			psf->sf_gsresp = 0;
+
+		if (AVAILABLE(skb) < sizeof(*psrc) +
+		    first*sizeof(struct mld2_grec)) {
+			if (truncate && !first)
+				break;	 /* truncate these */
+			if (pgr)
+				pgr->grec_nsrcs = htons(scount);
+			if (skb)
+				mld_sendpack(skb);
+			skb = mld_newpack(dev, dev->mtu);
+			first = 1;
+			scount = 0;
+		}
+		if (first) {
+			skb = add_grhead(skb, pmc, type, &pgr);
+			first = 0;
+		}
+		psrc = (struct in6_addr *)skb_put(skb, sizeof(*psrc));
+		*psrc = psf->sf_addr;
+		scount++;
+		if ((type == MLD2_ALLOW_NEW_SOURCES ||
+		     type == MLD2_BLOCK_OLD_SOURCES) && psf->sf_crcount) {
+			psf->sf_crcount--;
+			if ((sdeleted || gdeleted) && psf->sf_crcount == 0) {
+				if (psf_prev)
+					psf_prev->sf_next = psf->sf_next;
+				else
+					pmc->mca_tomb = psf->sf_next;
+				kfree(psf);
+				continue;
+			}
+		}
+		psf_prev = psf;
+	}
+	if (pgr)
+		pgr->grec_nsrcs = htons(scount);
+
+	if (isquery)
+		pmc->mca_flags &= ~MAF_GSQUERY;	/* clear query state */
+	return skb;
+}
+
+static void mld_send_report(struct inet6_dev *idev, struct ifmcaddr6 *pmc)
+{
+	struct sk_buff *skb = 0;
+	int type;
+
+	if (!pmc) {
+		read_lock_bh(&idev->lock);
+		for (pmc=idev->mc_list; pmc; pmc=pmc->next) {
+			if (pmc->mca_flags & MAF_NOREPORT)
+				continue;
+			spin_lock_bh(&pmc->mca_lock);
+			if (pmc->mca_sfcount[MCAST_EXCLUDE])
+				type = MLD2_MODE_IS_EXCLUDE;
+			else
+				type = MLD2_MODE_IS_INCLUDE;
+			skb = add_grec(skb, pmc, type, 0, 0);
+			spin_unlock_bh(&pmc->mca_lock);
+		}
+		read_unlock_bh(&idev->lock);
+	} else {
+		spin_lock_bh(&pmc->mca_lock);
+		if (pmc->mca_sfcount[MCAST_EXCLUDE])
+			type = MLD2_MODE_IS_EXCLUDE;
+		else
+			type = MLD2_MODE_IS_INCLUDE;
+		skb = add_grec(skb, pmc, type, 0, 0);
+		spin_unlock_bh(&pmc->mca_lock);
+	}
+	if (skb)
+		mld_sendpack(skb);
+}
+
+/*
+ * remove zero-count source records from a source filter list
+ */
+static void mld_clear_zeros(struct ip6_sf_list **ppsf)
+{
+	struct ip6_sf_list *psf_prev, *psf_next, *psf;
+
+	psf_prev = 0;
+	for (psf=*ppsf; psf; psf = psf_next) {
+		psf_next = psf->sf_next;
+		if (psf->sf_crcount == 0) {
+			if (psf_prev)
+				psf_prev->sf_next = psf->sf_next;
+			else
+				*ppsf = psf->sf_next;
+			kfree(psf);
+		} else
+			psf_prev = psf;
+	}
+}
+
+static void mld_send_cr(struct inet6_dev *idev)
+{
+	struct ifmcaddr6 *pmc, *pmc_prev, *pmc_next;
+	struct sk_buff *skb = 0;
+	int type, dtype;
+
+	read_lock_bh(&idev->lock);
+	write_lock_bh(&idev->mc_lock);
+
+	/* deleted MCA's */
+	pmc_prev = 0;
+	for (pmc=idev->mc_tomb; pmc; pmc=pmc_next) {
+		pmc_next = pmc->next;
+		if (pmc->mca_sfmode == MCAST_INCLUDE) {
+			type = MLD2_BLOCK_OLD_SOURCES;
+			dtype = MLD2_BLOCK_OLD_SOURCES;
+			skb = add_grec(skb, pmc, type, 1, 0);
+			skb = add_grec(skb, pmc, dtype, 1, 1);
+		}
+		if (pmc->mca_crcount) {
+			pmc->mca_crcount--;
+			if (pmc->mca_sfmode == MCAST_EXCLUDE) {
+				type = MLD2_CHANGE_TO_INCLUDE;
+				skb = add_grec(skb, pmc, type, 1, 0);
+			}
+			if (pmc->mca_crcount == 0) {
+				mld_clear_zeros(&pmc->mca_tomb);
+				mld_clear_zeros(&pmc->mca_sources);
+			}
+		}
+		if (pmc->mca_crcount == 0 && !pmc->mca_tomb &&
+		    !pmc->mca_sources) {
+			if (pmc_prev)
+				pmc_prev->next = pmc_next;
+			else
+				idev->mc_tomb = pmc_next;
+			in6_dev_put(pmc->idev);
+			kfree(pmc);
+		} else
+			pmc_prev = pmc;
+	}
+	write_unlock_bh(&idev->mc_lock);
+
+	/* change recs */
+	for (pmc=idev->mc_list; pmc; pmc=pmc->next) {
+		spin_lock_bh(&pmc->mca_lock);
+		if (pmc->mca_sfcount[MCAST_EXCLUDE]) {
+			type = MLD2_BLOCK_OLD_SOURCES;
+			dtype = MLD2_ALLOW_NEW_SOURCES;
+		} else {
+			type = MLD2_ALLOW_NEW_SOURCES;
+			dtype = MLD2_BLOCK_OLD_SOURCES;
+		}
+		skb = add_grec(skb, pmc, type, 0, 0);
+		skb = add_grec(skb, pmc, dtype, 0, 1);	/* deleted sources */
+
+		/* filter mode changes */
+		if (pmc->mca_crcount) {
+			pmc->mca_crcount--;
+			if (pmc->mca_sfmode == MCAST_EXCLUDE)
+				type = MLD2_CHANGE_TO_EXCLUDE;
+			else
+				type = MLD2_CHANGE_TO_INCLUDE;
+			skb = add_grec(skb, pmc, type, 0, 0);
+		}
+		spin_unlock_bh(&pmc->mca_lock);
+	}
+	read_unlock_bh(&idev->lock);
+	if (!skb)
+		return;
+	(void) mld_sendpack(skb);
+}
+
 void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
 {
 	struct sock *sk = igmp6_socket->sk;
@@ -529,7 +1554,7 @@
 	payload_len = len + sizeof(ra);
 	full_len = sizeof(struct ipv6hdr) + payload_len;
 
-	skb = sock_alloc_send_skb(sk, dev->hard_header_len + full_len + 15, 0, &err);
+	skb = sock_alloc_send_skb(sk, dev->hard_header_len + full_len + 15, 1, &err);
 
 	if (skb == NULL)
 		return;
@@ -577,12 +1602,250 @@
 	kfree_skb(skb);
 }
 
+static int ip6_mc_del1_src(struct ifmcaddr6 *pmc, int sfmode,
+	struct in6_addr *psfsrc)
+{
+	struct ip6_sf_list *psf, *psf_prev;
+	int rv = 0;
+
+	psf_prev = 0;
+	for (psf=pmc->mca_sources; psf; psf=psf->sf_next) {
+		if (ipv6_addr_cmp(&psf->sf_addr, psfsrc) == 0)
+			break;
+		psf_prev = psf;
+	}
+	if (!psf || psf->sf_count[sfmode] == 0) {
+		/* source filter not found, or count wrong =>  bug */
+		return -ESRCH;
+	}
+	psf->sf_count[sfmode]--;
+	if (!psf->sf_count[MCAST_INCLUDE] && !psf->sf_count[MCAST_EXCLUDE]) {
+		struct inet6_dev *idev = pmc->idev;
+
+		/* no more filters for this source */
+		if (psf_prev)
+			psf_prev->sf_next = psf->sf_next;
+		else
+			pmc->mca_sources = psf->sf_next;
+		if (psf->sf_oldin && !(pmc->mca_flags & MAF_NOREPORT) &&
+		    !MLD_V1_SEEN(idev)) {
+			psf->sf_crcount = idev->mc_qrv;
+			psf->sf_next = pmc->mca_tomb;
+			pmc->mca_tomb = psf;
+			rv = 1;
+		} else
+			kfree(psf);
+	}
+	return rv;
+}
+
+int ip6_mc_del_src(struct inet6_dev *idev, struct in6_addr *pmca, int sfmode,
+	int sfcount, struct in6_addr *psfsrc, int delta)
+{
+	struct ifmcaddr6 *pmc;
+	int	changerec = 0;
+	int	i, err;
+
+	if (!idev)
+		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)
+			break;
+	}
+	if (!pmc) {
+		/* MCA not found?? bug */
+		read_unlock_bh(&idev->lock);
+		return -ESRCH;
+	}
+	spin_lock_bh(&pmc->mca_lock);
+	read_unlock_bh(&idev->lock);
+	sf_markstate(pmc);
+	if (!delta) {
+		if (!pmc->mca_sfcount[sfmode]) {
+			spin_unlock_bh(&pmc->mca_lock);
+			return -EINVAL;
+		}
+		pmc->mca_sfcount[sfmode]--;
+	}
+	err = 0;
+	for (i=0; i<sfcount; i++) {
+		int rv = ip6_mc_del1_src(pmc, sfmode, &psfsrc[i]);
+
+		changerec |= rv > 0;
+		if (!err && rv < 0)
+			err = rv;
+	}
+	if (pmc->mca_sfmode == MCAST_EXCLUDE &&
+	    pmc->mca_sfcount[MCAST_EXCLUDE] == 0 &&
+	    pmc->mca_sfcount[MCAST_INCLUDE]) {
+		struct ip6_sf_list *psf;
+
+		/* filter mode change */
+		pmc->mca_sfmode = MCAST_INCLUDE;
+		pmc->mca_crcount = idev->mc_qrv;
+		idev->mc_ifc_count = pmc->mca_crcount;
+		for (psf=pmc->mca_sources; psf; psf = psf->sf_next)
+			psf->sf_crcount = 0;
+		mld_ifc_event(pmc->idev);
+	} else if (sf_setstate(pmc) || changerec)
+		mld_ifc_event(pmc->idev);
+	spin_unlock_bh(&pmc->mca_lock);
+	return err;
+}
+
+/*
+ * Add multicast single-source filter to the interface list
+ */
+static int ip6_mc_add1_src(struct ifmcaddr6 *pmc, int sfmode,
+	struct in6_addr *psfsrc, int delta)
+{
+	struct ip6_sf_list *psf, *psf_prev;
+
+	psf_prev = 0;
+	for (psf=pmc->mca_sources; psf; psf=psf->sf_next) {
+		if (ipv6_addr_cmp(&psf->sf_addr, psfsrc) == 0)
+			break;
+		psf_prev = psf;
+	}
+	if (!psf) {
+		psf = (struct ip6_sf_list *)kmalloc(sizeof(*psf), GFP_ATOMIC);
+		if (!psf)
+			return -ENOBUFS;
+		memset(psf, 0, sizeof(*psf));
+		psf->sf_addr = *psfsrc;
+		if (psf_prev) {
+			psf_prev->sf_next = psf;
+		} else
+			pmc->mca_sources = psf;
+	}
+	psf->sf_count[sfmode]++;
+	return 0;
+}
+
+static void sf_markstate(struct ifmcaddr6 *pmc)
+{
+	struct ip6_sf_list *psf;
+	int mca_xcount = pmc->mca_sfcount[MCAST_EXCLUDE];
+
+	for (psf=pmc->mca_sources; psf; psf=psf->sf_next)
+		if (pmc->mca_sfcount[MCAST_EXCLUDE]) {
+			psf->sf_oldin = mca_xcount ==
+				psf->sf_count[MCAST_EXCLUDE] &&
+				!psf->sf_count[MCAST_INCLUDE];
+		} else
+			psf->sf_oldin = psf->sf_count[MCAST_INCLUDE] != 0;
+}
+
+static int sf_setstate(struct ifmcaddr6 *pmc)
+{
+	struct ip6_sf_list *psf;
+	int mca_xcount = pmc->mca_sfcount[MCAST_EXCLUDE];
+	int qrv = pmc->idev->mc_qrv;
+	int new_in, rv;
+
+	rv = 0;
+	for (psf=pmc->mca_sources; psf; psf=psf->sf_next) {
+		if (pmc->mca_sfcount[MCAST_EXCLUDE]) {
+			new_in = mca_xcount == psf->sf_count[MCAST_EXCLUDE] &&
+				!psf->sf_count[MCAST_INCLUDE];
+		} else
+			new_in = psf->sf_count[MCAST_INCLUDE] != 0;
+		if (new_in != psf->sf_oldin) {
+			psf->sf_crcount = qrv;
+			rv++;
+		}
+	}
+	return rv;
+}
+
+/*
+ * Add multicast source filter list to the interface list
+ */
+int ip6_mc_add_src(struct inet6_dev *idev, struct in6_addr *pmca, int sfmode,
+	int sfcount, struct in6_addr *psfsrc, int delta)
+{
+	struct ifmcaddr6 *pmc;
+	int	isexclude;
+	int	i, err;
+
+	if (!idev)
+		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)
+			break;
+	}
+	if (!pmc) {
+		/* MCA not found?? bug */
+		read_unlock_bh(&idev->lock);
+		return -ESRCH;
+	}
+	spin_lock_bh(&pmc->mca_lock);
+	read_unlock_bh(&idev->lock);
+
+	sf_markstate(pmc);
+	isexclude = pmc->mca_sfmode == MCAST_EXCLUDE;
+	if (!delta)
+		pmc->mca_sfcount[sfmode]++;
+	err = 0;
+	for (i=0; i<sfcount; i++) {
+		err = ip6_mc_add1_src(pmc, sfmode, &psfsrc[i], delta);
+		if (err)
+			break;
+	}
+	if (err) {
+		int j;
+
+		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)) {
+		struct inet6_dev *idev = pmc->idev;
+		struct ip6_sf_list *psf;
+
+		/* filter mode change */
+		if (pmc->mca_sfcount[MCAST_EXCLUDE])
+			pmc->mca_sfmode = MCAST_EXCLUDE;
+		else if (pmc->mca_sfcount[MCAST_INCLUDE])
+			pmc->mca_sfmode = MCAST_INCLUDE;
+		/* else no filters; keep old mode for reports */
+
+		pmc->mca_crcount = idev->mc_qrv;
+		idev->mc_ifc_count = pmc->mca_crcount;
+		for (psf=pmc->mca_sources; psf; psf = psf->sf_next)
+			psf->sf_crcount = 0;
+		mld_ifc_event(idev);
+	} else if (sf_setstate(pmc))
+		mld_ifc_event(idev);
+	spin_unlock_bh(&pmc->mca_lock);
+	return err;
+}
+
+static void ip6_mc_clear_src(struct ifmcaddr6 *pmc)
+{
+	struct ip6_sf_list *psf, *nextpsf;
+
+	for (psf=pmc->mca_tomb; psf; psf=nextpsf) {
+		nextpsf = psf->sf_next;
+		kfree(psf);
+	}
+	pmc->mca_tomb = 0;
+	for (psf=pmc->mca_sources; psf; psf=nextpsf) {
+		nextpsf = psf->sf_next;
+		kfree(psf);
+	}
+	pmc->mca_sources = 0;
+	pmc->mca_sfmode = MCAST_EXCLUDE;
+	pmc->mca_sfcount[MCAST_EXCLUDE] = 0;
+	pmc->mca_sfcount[MCAST_EXCLUDE] = 1;
+}
+
 static void igmp6_join_group(struct ifmcaddr6 *ma)
 {
 	unsigned long delay;
 
-	if (IPV6_ADDR_MC_SCOPE(&ma->mca_addr) < IPV6_ADDR_SCOPE_LINKLOCAL ||
-	    ipv6_addr_is_ll_all_nodes(&ma->mca_addr))
+	if (ma->mca_flags & MAF_NOREPORT)
 		return;
 
 	igmp6_send(&ma->mca_addr, ma->idev->dev, ICMPV6_MGM_REPORT);
@@ -601,26 +1864,73 @@
 	spin_unlock_bh(&ma->mca_lock);
 }
 
+int ip6_mc_leave_src(struct sock *sk, struct ipv6_mc_socklist *iml,
+	struct inet6_dev *idev)
+{
+	int err;
+
+	if (iml->sflist == 0) {
+		/* any-source empty exclude case */
+		return ip6_mc_del_src(idev, &iml->addr, iml->sfmode, 0, 0, 0);
+	}
+	err = ip6_mc_del_src(idev, &iml->addr, iml->sfmode,
+		iml->sflist->sl_count, iml->sflist->sl_addr, 0);
+	sock_kfree_s(sk, iml->sflist, IP6_SFLSIZE(iml->sflist->sl_max));
+	iml->sflist = 0;
+	return err;
+}
+
 static void igmp6_leave_group(struct ifmcaddr6 *ma)
 {
-	if (IPV6_ADDR_MC_SCOPE(&ma->mca_addr) < IPV6_ADDR_SCOPE_LINKLOCAL ||
-	    ipv6_addr_is_ll_all_nodes(&ma->mca_addr))
-		return;
+	if (MLD_V1_SEEN(ma->idev)) {
+		if (ma->mca_flags & MAF_LAST_REPORTER)
+			igmp6_send(&ma->mca_addr, ma->idev->dev,
+				ICMPV6_MGM_REDUCTION);
+	} else {
+		mld_add_delrec(ma->idev, ma);
+		mld_ifc_event(ma->idev);
+	}
+}
 
-	if (ma->mca_flags & MAF_LAST_REPORTER)
-		igmp6_send(&ma->mca_addr, ma->idev->dev, ICMPV6_MGM_REDUCTION);
+static void mld_gq_timer_expire(unsigned long data)
+{
+	struct inet6_dev *idev = (struct inet6_dev *)data;
 
-	spin_lock_bh(&ma->mca_lock);
-	if (del_timer(&ma->mca_timer))
-		atomic_dec(&ma->mca_refcnt);
-	spin_unlock_bh(&ma->mca_lock);
+	idev->mc_gq_running = 0;
+	mld_send_report(idev, 0);
+	__in6_dev_put(idev);
+}
+
+static void mld_ifc_timer_expire(unsigned long data)
+{
+	struct inet6_dev *idev = (struct inet6_dev *)data;
+
+	mld_send_cr(idev);
+	if (idev->mc_ifc_count) {
+		idev->mc_ifc_count--;
+		if (idev->mc_ifc_count)
+			mld_ifc_start_timer(idev, idev->mc_maxdelay);
+	}
+	__in6_dev_put(idev);
+}
+
+static void mld_ifc_event(struct inet6_dev *idev)
+{
+	if (MLD_V1_SEEN(idev))
+		return;
+	idev->mc_ifc_count = idev->mc_qrv;
+	mld_ifc_start_timer(idev, 1);
 }
 
-void igmp6_timer_handler(unsigned long data)
+
+static void igmp6_timer_handler(unsigned long data)
 {
 	struct ifmcaddr6 *ma = (struct ifmcaddr6 *) data;
 
-	igmp6_send(&ma->mca_addr, ma->idev->dev, ICMPV6_MGM_REPORT);
+	if (MLD_V1_SEEN(ma->idev))
+		igmp6_send(&ma->mca_addr, ma->idev->dev, ICMPV6_MGM_REPORT);
+	else
+		mld_send_report(ma->idev, ma);
 
 	spin_lock(&ma->mca_lock);
 	ma->mca_flags |=  MAF_LAST_REPORTER;
@@ -638,9 +1948,18 @@
 	/* Withdraw multicast list */
 
 	read_lock_bh(&idev->lock);
+	idev->mc_ifc_count = 0;
+	if (del_timer(&idev->mc_ifc_timer))
+		__in6_dev_put(idev);
+	idev->mc_gq_running = 0;
+	if (del_timer(&idev->mc_gq_timer))
+		__in6_dev_put(idev);
+
 	for (i = idev->mc_list; i; i=i->next)
 		igmp6_group_dropped(i);
 	read_unlock_bh(&idev->lock);
+
+	mld_clear_delrec(idev);
 }
 
 
@@ -664,6 +1983,22 @@
 {
 	struct in6_addr maddr;
 
+	write_lock_bh(&idev->lock);
+	idev->mc_lock = RW_LOCK_UNLOCKED;
+	idev->mc_gq_running = 0;
+	init_timer(&idev->mc_gq_timer);
+	idev->mc_gq_timer.data = (unsigned long) idev;
+	idev->mc_gq_timer.function = &mld_gq_timer_expire;
+	idev->mc_tomb = 0;
+	idev->mc_ifc_count = 0;
+	init_timer(&idev->mc_ifc_timer);
+	idev->mc_ifc_timer.data = (unsigned long) idev;
+	idev->mc_ifc_timer.function = &mld_ifc_timer_expire;
+	idev->mc_qrv = MLD_QRV_DEFAULT;
+	idev->mc_maxdelay = IGMP6_UNSOLICITED_IVAL;
+	idev->mc_v1_seen = 0;
+	write_unlock_bh(&idev->lock);
+
 	/* Add all-nodes address. */
 	ipv6_addr_all_nodes(&maddr);
 	ipv6_dev_mc_inc(idev->dev, &maddr);
@@ -753,6 +2088,81 @@
 		len=0;
 	return len;
 }
+
+static int ip6_mcf_read_proc(char *buffer, char **start, off_t offset,
+			   int length, int *eof, void *data)
+{
+	off_t pos=0, begin=0;
+	int len=0;
+	int first=1;
+	struct net_device *dev;
+	
+	read_lock(&dev_base_lock);
+	for (dev=dev_base; dev; dev=dev->next) {
+		struct inet6_dev *idev = in6_dev_get(dev);
+		struct ifmcaddr6 *imc;
+
+		if (idev == NULL)
+			continue;
+
+		read_lock_bh(&idev->lock);
+
+		for (imc=idev->mc_list; imc; imc=imc->next) {
+			struct ip6_sf_list *psf;
+			unsigned long i;
+
+			spin_lock_bh(&imc->mca_lock);
+			for (psf=imc->mca_sources; psf; psf=psf->sf_next) {
+				if (first) {
+					len += sprintf(buffer+len, "%3s %6s "
+						"%32s %32s %6s %6s\n", "Idx",
+						"Device", "Multicast Address",
+						"Source Address", "INC", "EXC");
+					first = 0;
+				}
+				len += sprintf(buffer+len,"%3d %6.6s ",
+					dev->ifindex, dev->name);
+
+				for (i=0; i<16; i++)
+					len += sprintf(buffer+len, "%02x",
+						imc->mca_addr.s6_addr[i]);
+				buffer[len++] = ' ';
+				for (i=0; i<16; i++)
+					len += sprintf(buffer+len, "%02x",
+						psf->sf_addr.s6_addr[i]);
+				len += sprintf(buffer+len, " %6lu %6lu\n",
+					psf->sf_count[MCAST_INCLUDE],
+					psf->sf_count[MCAST_EXCLUDE]);
+				pos = begin+len;
+				if (pos < offset) {
+					len=0;
+					begin=pos;
+				}
+				if (pos > offset+length) {
+					spin_unlock_bh(&imc->mca_lock);
+					read_unlock_bh(&idev->lock);
+					in6_dev_put(idev);
+					goto done;
+				}
+			}
+			spin_unlock_bh(&imc->mca_lock);
+		}
+		read_unlock_bh(&idev->lock);
+		in6_dev_put(idev);
+	}
+	*eof = 1;
+
+done:
+	read_unlock(&dev_base_lock);
+
+	*start=buffer+(offset-begin);
+	len-=(offset-begin);
+	if(len>length)
+		len=length;
+	if (len<0)
+		len=0;
+	return len;
+}
 #endif
 
 int __init igmp6_init(struct net_proto_family *ops)
@@ -786,6 +2196,7 @@
 	sk->net_pinfo.af_inet6.hop_limit = 1;
 #ifdef CONFIG_PROC_FS
 	create_proc_read_entry("net/igmp6", 0, 0, igmp6_read_proc, NULL);
+	create_proc_read_entry("net/mcfilter6", 0, 0, ip6_mcf_read_proc, NULL);
 #endif
 
 	return 0;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv6/ndisc.c linux-2.4.22-pre2/net/ipv6/ndisc.c
--- linux-2.4.21/net/ipv6/ndisc.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv6/ndisc.c	2003-06-26 21:43:11.000000000 +0000
@@ -226,6 +226,9 @@
 	case ARPHRD_IEEE802_TR:
 		ipv6_tr_mc_map(addr,buf);
 		return 0;
+	case ARPHRD_ARCNET:
+		ipv6_arcnet_mc_map(addr, buf);
+		return 0;
 	default:
 		if (dir) {
 			memcpy(buf, dev->broadcast, dev->addr_len);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv6/netfilter/ip6_tables.c linux-2.4.22-pre2/net/ipv6/netfilter/ip6_tables.c
--- linux-2.4.21/net/ipv6/netfilter/ip6_tables.c	2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv6/netfilter/ip6_tables.c	2003-06-26 21:43:31.000000000 +0000
@@ -101,10 +101,8 @@
 	unsigned int hook_entry[NF_IP6_NUMHOOKS];
 	unsigned int underflow[NF_IP6_NUMHOOKS];
 
-	char padding[SMP_ALIGN((NF_IP6_NUMHOOKS*2+2)*sizeof(unsigned int))];
-
 	/* ip6t_entry tables: one per CPU */
-	char entries[0];
+	char entries[0] ____cacheline_aligned;
 };
 
 static LIST_HEAD(ip6t_target);
@@ -1450,7 +1448,7 @@
 	int ret;
 	struct ip6t_table_info *newinfo;
 	static struct ip6t_table_info bootstrap
-		= { 0, 0, 0, { 0 }, { 0 }, { }, { } };
+		= { 0, 0, 0, { 0 }, { 0 }, { } };
 
 	MOD_INC_USE_COUNT;
 	newinfo = vmalloc(sizeof(struct ip6t_table_info)
@@ -1767,14 +1765,15 @@
 = { { NULL, NULL }, "icmp6", &icmp6_match, &icmp6_checkentry, NULL };
 
 #ifdef CONFIG_PROC_FS
-static inline int print_name(const struct ip6t_table *t,
+static inline int print_name(const char *i,
 			     off_t start_offset, char *buffer, int length,
 			     off_t *pos, unsigned int *count)
 {
 	if ((*count)++ >= start_offset) {
 		unsigned int namelen;
 
-		namelen = sprintf(buffer + *pos, "%s\n", t->name);
+		namelen = sprintf(buffer + *pos, "%s\n",
+				  i + sizeof(struct list_head));
 		if (*pos + namelen > length) {
 			/* Stop iterating */
 			return 1;
@@ -1792,7 +1791,7 @@
 	if (down_interruptible(&ip6t_mutex) != 0)
 		return 0;
 
-	LIST_FIND(&ip6t_tables, print_name, struct ip6t_table *,
+	LIST_FIND(&ip6t_tables, print_name, char *,
 		  offset, buffer, length, &pos, &count);
 
 	up(&ip6t_mutex);
@@ -1801,6 +1800,46 @@
 	*start=(char *)((unsigned long)count-offset);
 	return pos;
 }
+
+static int ip6t_get_targets(char *buffer, char **start, off_t offset, int length)
+{
+	off_t pos = 0;
+	unsigned int count = 0;
+
+	if (down_interruptible(&ip6t_mutex) != 0)
+		return 0;
+
+	LIST_FIND(&ip6t_target, print_name, char *,
+		  offset, buffer, length, &pos, &count);
+
+	up(&ip6t_mutex);
+
+	*start = (char *)((unsigned long)count - offset);
+	return pos;
+}
+
+static int ip6t_get_matches(char *buffer, char **start, off_t offset, int length)
+{
+	off_t pos = 0;
+	unsigned int count = 0;
+
+	if (down_interruptible(&ip6t_mutex) != 0)
+		return 0;
+
+	LIST_FIND(&ip6t_match, print_name, char *,
+		  offset, buffer, length, &pos, &count);
+
+	up(&ip6t_mutex);
+
+	*start = (char *)((unsigned long)count - offset);
+	return pos;
+}
+
+static struct { char *name; get_info_t *get_info; } ip6t_proc_entry[] =
+{ { "ip6_tables_names", ip6t_get_tables },
+  { "ip6_tables_targets", ip6t_get_targets },
+  { "ip6_tables_matches", ip6t_get_matches },
+  { NULL, NULL} };
 #endif /*CONFIG_PROC_FS*/
 
 static int __init init(void)
@@ -1826,13 +1865,19 @@
 #ifdef CONFIG_PROC_FS
 	{
 		struct proc_dir_entry *proc;
-		proc = proc_net_create("ip6_tables_names", 0,
-					ip6t_get_tables);
-		if (!proc) {
-			nf_unregister_sockopt(&ip6t_sockopts);
-			return -ENOMEM;
+		int i;
+
+		for (i = 0; ip6t_proc_entry[i].name; i++) {
+			proc = proc_net_create(ip6t_proc_entry[i].name, 0,
+					       ip6t_proc_entry[i].get_info);
+			if (!proc) {
+				while (--i >= 0)
+				       proc_net_remove(ip6t_proc_entry[i].name);
+				nf_unregister_sockopt(&ip6t_sockopts);
+				return -ENOMEM;
+			}
+			proc->owner = THIS_MODULE;
 		}
-		proc->owner = THIS_MODULE;
 	}
 #endif
 
@@ -1844,7 +1889,11 @@
 {
 	nf_unregister_sockopt(&ip6t_sockopts);
 #ifdef CONFIG_PROC_FS
-	proc_net_remove("ip6_tables_names");
+	{
+		int i;
+		for (i = 0; ip6t_proc_entry[i].name; i++)
+			proc_net_remove(ip6t_proc_entry[i].name);
+	}
 #endif
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv6/raw.c linux-2.4.22-pre2/net/ipv6/raw.c
--- linux-2.4.21/net/ipv6/raw.c	2002-08-03 00:39:46.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv6/raw.c	2003-06-26 21:43:18.000000000 +0000
@@ -97,7 +97,7 @@
 				if (ipv6_addr_cmp(&np->rcv_saddr, loc_addr) == 0)
 					break;
 				if ((addr_type & IPV6_ADDR_MULTICAST) &&
-				    inet6_mc_check(s, loc_addr))
+				    inet6_mc_check(s, loc_addr, rmt_addr))
 					break;
 				continue;
 			}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv6/reassembly.c linux-2.4.22-pre2/net/ipv6/reassembly.c
--- linux-2.4.21/net/ipv6/reassembly.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv6/reassembly.c	2003-06-26 21:43:16.000000000 +0000
@@ -191,19 +191,19 @@
 atomic_t ip6_frag_mem = ATOMIC_INIT(0);
 
 /* Memory Tracking Functions. */
-extern __inline__ void frag_kfree_skb(struct sk_buff *skb)
+static inline void frag_kfree_skb(struct sk_buff *skb)
 {
 	atomic_sub(skb->truesize, &ip6_frag_mem);
 	kfree_skb(skb);
 }
 
-extern __inline__ void frag_free_queue(struct frag_queue *fq)
+static inline void frag_free_queue(struct frag_queue *fq)
 {
 	atomic_sub(sizeof(struct frag_queue), &ip6_frag_mem);
 	kfree(fq);
 }
 
-extern __inline__ struct frag_queue *frag_alloc_queue(void)
+static inline struct frag_queue *frag_alloc_queue(void)
 {
 	struct frag_queue *fq = kmalloc(sizeof(struct frag_queue), GFP_ATOMIC);
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv6/route.c linux-2.4.22-pre2/net/ipv6/route.c
--- linux-2.4.21/net/ipv6/route.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv6/route.c	2003-06-26 21:43:13.000000000 +0000
@@ -13,6 +13,17 @@
  *      2 of the License, or (at your option) any later version.
  */
 
+/*	Changes:
+ *
+ *	YOSHIFUJI Hideaki @USAGI
+ *		reworked default router selection.
+ *		- respect outgoing interface
+ *		- select from (probably) reachable routers (i.e.
+ *		routers in REACHABLE, STALE, DELAY or PROBE states).
+ *		- always select the same router if it is (probably)
+ *		reachable.  otherwise, round-robin the list.
+ */
+
 #include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/types.h>
@@ -168,6 +179,7 @@
 static struct rt6_info *rt6_dflt_pointer = NULL;
 static spinlock_t rt6_dflt_lock = SPIN_LOCK_UNLOCKED;
 
+/* Default Router Selection (RFC 2461 6.3.6) */
 static struct rt6_info *rt6_best_dflt(struct rt6_info *rt, int oif)
 {
 	struct rt6_info *match = NULL;
@@ -176,63 +188,115 @@
 
 	for (sprt = rt; sprt; sprt = sprt->u.next) {
 		struct neighbour *neigh;
+		int m = 0;
 
-		if ((neigh = sprt->rt6i_nexthop) != NULL) {
-			int m = -1;
+		if (!oif ||
+		    (sprt->rt6i_dev &&
+		     sprt->rt6i_dev->ifindex == oif))
+			m += 8;
+
+		if (sprt == rt6_dflt_pointer)
+			m += 4;
 
+		if ((neigh = sprt->rt6i_nexthop) != NULL) {
+			read_lock_bh(&neigh->lock);
 			switch (neigh->nud_state) {
 			case NUD_REACHABLE:
-				if (sprt != rt6_dflt_pointer) {
-					rt = sprt;
-					goto out;
-				}
-				m = 2;
+				m += 3;
 				break;
 
+			case NUD_STALE:
 			case NUD_DELAY:
-				m = 1;
+			case NUD_PROBE:
+				m += 2;
 				break;
 
-			case NUD_STALE:
-				m = 1;
+			case NUD_NOARP:
+			case NUD_PERMANENT:
+				m += 1;
 				break;
-			};
 
-			if (oif && sprt->rt6i_dev->ifindex == oif) {
-				m += 2;
+			case NUD_INCOMPLETE:
+			default:
+				read_unlock_bh(&neigh->lock);
+				continue;
 			}
+			read_unlock_bh(&neigh->lock);
+		} else {
+			continue;
+		}
 
-			if (m >= mpri) {
-				mpri = m;
-				match = sprt;
+		if (m > mpri || m >= 12) {
+			match = sprt;
+			mpri = m;
+			if (m >= 12) {
+				/* we choose the lastest default router if it
+				 * is in (probably) reachable state.
+				 * If route changed, we should do pmtu
+				 * discovery. --yoshfuji
+				 */
+				break;
 			}
 		}
 	}
 
-	if (match) {
-		rt = match;
-	} else {
+	spin_lock(&rt6_dflt_lock);
+	if (!match) {
 		/*
 		 *	No default routers are known to be reachable.
 		 *	SHOULD round robin
 		 */
-		spin_lock(&rt6_dflt_lock);
 		if (rt6_dflt_pointer) {
-			struct rt6_info *next;
-
-			if ((next = rt6_dflt_pointer->u.next) != NULL &&
-			    next->u.dst.obsolete <= 0 &&
-			    next->u.dst.error == 0)
-				rt = next;
+			for (sprt = rt6_dflt_pointer->u.next;
+			     sprt; sprt = sprt->u.next) {
+				if (sprt->u.dst.obsolete <= 0 &&
+				    sprt->u.dst.error == 0) {
+					match = sprt;
+					break;
+				}
+			}
+			for (sprt = rt;
+			     !match && sprt;
+			     sprt = sprt->u.next) {
+				if (sprt->u.dst.obsolete <= 0 &&
+				    sprt->u.dst.error == 0) {
+					match = sprt;
+					break;
+				}
+				if (sprt == rt6_dflt_pointer)
+					break;
+			}
 		}
-		spin_unlock(&rt6_dflt_lock);
 	}
 
-out:
-	spin_lock(&rt6_dflt_lock);
-	rt6_dflt_pointer = rt;
+	if (match)
+		rt6_dflt_pointer = match;
+
 	spin_unlock(&rt6_dflt_lock);
-	return rt;
+
+	if (!match) {
+		/*
+		 * Last Resort: if no default routers found, 
+		 * use addrconf default route.
+		 * We don't record this route.
+		 */
+		for (sprt = ip6_routing_table.leaf;
+		     sprt; sprt = sprt->u.next) {
+			if ((sprt->rt6i_flags & RTF_DEFAULT) &&
+			    (!oif ||
+			     (sprt->rt6i_dev &&
+			      sprt->rt6i_dev->ifindex == oif))) {
+				match = sprt;
+				break;
+			}
+		}
+		if (!match) {
+			/* no default route.  give up. */
+			match = &ip6_null_entry;
+		}
+	}
+
+	return match;
 }
 
 struct rt6_info *rt6_lookup(struct in6_addr *daddr, struct in6_addr *saddr,
@@ -272,7 +336,7 @@
 	return err;
 }
 
-/* No rt6_lock! If COW faild, the function returns dead route entry
+/* No rt6_lock! If COW failed, the function returns dead route entry
    with dst->error set to errno value.
  */
 
@@ -584,7 +648,7 @@
 	static unsigned long last_gc;
 	unsigned long now = jiffies;
 
-	if ((long)(now - last_gc) < ip6_rt_gc_min_interval &&
+	if (time_after(last_gc + ip6_rt_gc_min_interval, now) &&
 	    atomic_read(&ip6_dst_ops.entries) <= ip6_rt_max_size)
 		goto out;
 
@@ -1195,7 +1259,7 @@
 int ip6_pkt_discard(struct sk_buff *skb)
 {
 	IP6_INC_STATS(Ip6OutNoRoutes);
-	icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_ADDR_UNREACH, 0, skb->dev);
+	icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_NOROUTE, 0, skb->dev);
 	kfree_skb(skb);
 	return 0;
 }
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv6/tcp_ipv6.c linux-2.4.22-pre2/net/ipv6/tcp_ipv6.c
--- linux-2.4.21/net/ipv6/tcp_ipv6.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv6/tcp_ipv6.c	2003-06-26 21:43:10.000000000 +0000
@@ -351,9 +351,9 @@
 	return tcp_v6_lookup_listener(daddr, hnum, dif);
 }
 
-__inline__ struct sock *tcp_v6_lookup(struct in6_addr *saddr, u16 sport,
-				      struct in6_addr *daddr, u16 dport,
-				      int dif)
+inline struct sock *tcp_v6_lookup(struct in6_addr *saddr, u16 sport,
+				  struct in6_addr *daddr, u16 dport,
+				  int dif)
 {
 	struct sock *sk;
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/ipv6/udp.c linux-2.4.22-pre2/net/ipv6/udp.c
--- linux-2.4.21/net/ipv6/udp.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/ipv6/udp.c	2003-06-26 21:43:15.000000000 +0000
@@ -564,7 +564,7 @@
 				if(ipv6_addr_cmp(&np->rcv_saddr, loc_addr) == 0)
 					return s;
 			}
-			if(!inet6_mc_check(s, loc_addr))
+			if(!inet6_mc_check(s, loc_addr, rmt_addr))
 				continue;
 			return s;
 		}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/irda/crc.c linux-2.4.22-pre2/net/irda/crc.c
--- linux-2.4.21/net/irda/crc.c	1999-05-30 17:27:04.000000000 +0000
+++ linux-2.4.22-pre2/net/irda/crc.c	2003-06-26 21:43:17.000000000 +0000
@@ -57,7 +57,7 @@
 	0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
 };
 
-unsigned short crc_calc( __u16 fcs, __u8 const *buf, size_t len) 
+unsigned short irda_calc_crc16( __u16 fcs, __u8 const *buf, size_t len) 
 {
 	while (len--)
                 fcs = irda_fcs(fcs, *buf++);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/irda/ircomm/ircomm_param.c linux-2.4.22-pre2/net/irda/ircomm/ircomm_param.c
--- linux-2.4.21/net/irda/ircomm/ircomm_param.c	2001-11-09 22:22:17.000000000 +0000
+++ linux-2.4.22-pre2/net/irda/ircomm/ircomm_param.c	2003-06-26 21:43:21.000000000 +0000
@@ -219,9 +219,16 @@
 
 	/* 
 	 * Now the line is ready for some communication. Check if we are a
-         * server, and send over some initial parameters 
+         * server, and send over some initial parameters.
+	 * Client do it in ircomm_tty_state_setup().
+	 * Note : we may get called from ircomm_tty_getvalue_confirm(),
+	 * therefore before we even have open any socket. And self->client
+	 * is initialised to TRUE only later. So, we check if the link is
+	 * really initialised. - Jean II
 	 */
-	if (!self->client && (self->settings.service_type != IRCOMM_3_WIRE_RAW))
+	if ((self->max_header_size != IRCOMM_TTY_HDR_UNINITIALISED) &&
+	    (!self->client) &&
+	    (self->settings.service_type != IRCOMM_3_WIRE_RAW))
 	{
 		/* Init connection */
 		ircomm_tty_send_initial_parameters(self);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/irda/ircomm/ircomm_tty.c linux-2.4.22-pre2/net/irda/ircomm/ircomm_tty.c
--- linux-2.4.21/net/irda/ircomm/ircomm_tty.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/irda/ircomm/ircomm_tty.c	2003-06-26 21:43:16.000000000 +0000
@@ -417,8 +417,8 @@
 		self->line = line;
 		self->tqueue.routine = ircomm_tty_do_softint;
 		self->tqueue.data = self;
-		self->max_header_size = IRCOMM_TTY_HDR_UNITIALISED;
-		self->max_data_size = 64-self->max_header_size;
+		self->max_header_size = IRCOMM_TTY_HDR_UNINITIALISED;
+		self->max_data_size = IRCOMM_TTY_DATA_UNINITIALISED;
 		self->close_delay = 5*HZ/10;
 		self->closing_wait = 30*HZ;
 
@@ -696,16 +696,26 @@
 
 	/* We may receive packets from the TTY even before we have finished
 	 * our setup. Not cool.
-	 * The problem is that we would allocate a skb with bogus header and
-	 * data size, and when adding data to it later we would get
-	 * confused.
-	 * Better to not accept data until we are properly setup. Use bogus
-	 * header size to check that (safest way to detect it).
+	 * The problem is that we don't know the final header and data size
+	 * to create the proper skb, so any skb we would create would have
+	 * bogus header and data size, so need care.
+	 * We use a bogus header size to safely detect this condition.
+	 * Another problem is that hw_stopped was set to 0 way before it
+	 * should be, so we would drop this skb. It should now be fixed.
+	 * One option is to not accept data until we are properly setup.
+	 * But, I suspect that when it happens, the ppp line discipline
+	 * just "drops" the data, which might screw up connect scripts.
+	 * The second option is to create a "safe skb", with large header
+	 * and small size (see ircomm_tty_open() for values).
+	 * We just need to make sure that when the real values get filled,
+	 * we don't mess up the original "safe skb" (see tx_data_size).
 	 * Jean II */
-	if (self->max_header_size == IRCOMM_TTY_HDR_UNITIALISED) {
-		/* TTY will retry */
-		IRDA_DEBUG(2, __FUNCTION__ "() : not initialised\n");
-		return len;
+	if (self->max_header_size == IRCOMM_TTY_HDR_UNINITIALISED) {
+		IRDA_DEBUG(1, "%s() : not initialised\n", __FUNCTION__);
+#ifdef IRCOMM_NO_TX_BEFORE_INIT
+		/* We didn't consume anything, TTY will retry */
+		return 0;
+#endif
 	}
 
 	save_flags(flags);
@@ -739,8 +749,11 @@
 			 * transmit buffer? Cannot use skb_tailroom, since
 			 * dev_alloc_skb gives us a larger skb than we 
 			 * requested
+			 * Note : use tx_data_size, because max_data_size
+			 * may have changed and we don't want to overwrite
+			 * the skb. - Jean II
 			 */
-			if ((tailroom = (self->max_data_size-skb->len)) > 0) {
+			if ((tailroom = (self->tx_data_size - skb->len)) > 0) {
 				/* Adjust data to tailroom */
 				if (size > tailroom)
 					size = tailroom;
@@ -761,6 +774,9 @@
 			}
 			skb_reserve(skb, self->max_header_size);
 			self->tx_skb = skb;
+			/* Remember skb size because max_data_size may
+			 * change later on - Jean II */
+			self->tx_data_size = self->max_data_size;
 		}
 		
 		/* Copy data */
@@ -804,18 +820,23 @@
 	ASSERT(self != NULL, return -1;);
 	ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
 
+#ifdef IRCOMM_NO_TX_BEFORE_INIT
+	/* max_header_size tells us if the channel is initialised or not. */
+	if (self->max_header_size == IRCOMM_TTY_HDR_UNINITIALISED)
+		/* Don't bother us yet */
+		return 0;
+#endif
+
 	/* Check if we are allowed to transmit any data.
 	 * hw_stopped is the regular flow control.
-	 * max_header_size tells us if the channel is initialised or not.
 	 * Jean II */
-	if ((tty->hw_stopped) ||
-	    (self->max_header_size == IRCOMM_TTY_HDR_UNITIALISED))
+	if (tty->hw_stopped)
 		ret = 0;
 	else {
 		save_flags(flags);
 		cli();
 		if (self->tx_skb)
-			ret = self->max_data_size - self->tx_skb->len;
+			ret = self->tx_data_size - self->tx_skb->len;
 		else
 			ret = self->max_data_size;
 		restore_flags(flags);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/irda/ircomm/ircomm_tty_attach.c linux-2.4.22-pre2/net/irda/ircomm/ircomm_tty_attach.c
--- linux-2.4.21/net/irda/ircomm/ircomm_tty_attach.c	2002-11-28 23:53:16.000000000 +0000
+++ linux-2.4.22-pre2/net/irda/ircomm/ircomm_tty_attach.c	2003-06-26 21:43:17.000000000 +0000
@@ -515,6 +515,23 @@
 	
 	del_timer(&self->watchdog_timer);
 
+	/* Remove LM-IAS object now so it is not reused.
+	 * IrCOMM deals very poorly with multiple incomming 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. Incomming 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
@@ -522,10 +539,10 @@
 	 * line.  
 	 */
 	if ((self->flags & ASYNC_CTS_FLOW) && ((self->settings.dce & IRCOMM_CTS) == 0)) {
-		IRDA_DEBUG(0, __FUNCTION__ "(), waiting for CTS ...\n");
+		IRDA_DEBUG(0, "%s(), waiting for CTS ...\n", __FUNCTION__);
 		return;
 	} else {
-		IRDA_DEBUG(2, __FUNCTION__ "(), starting hardware!\n");
+		IRDA_DEBUG(1, "%s(), starting hardware!\n", __FUNCTION__);
 
 		self->tty->hw_stopped = 0;
 	
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/irda/irda_device.c linux-2.4.22-pre2/net/irda/irda_device.c
--- linux-2.4.21/net/irda/irda_device.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/irda/irda_device.c	2003-06-26 21:43:20.000000000 +0000
@@ -68,6 +68,7 @@
 extern int girbil_init(void);
 extern int sa1100_irda_init(void);
 extern int ep7211_ir_init(void);
+extern int mcp2120_init(void);
 
 static void __irda_task_delete(struct irda_task *task);
 
@@ -122,6 +123,9 @@
 	/* 
 	 * Call the init function of the device drivers that has not been
 	 * compiled as a module 
+	 * Note : non-modular IrDA is not supported in 2.4.X, so don't
+	 * waste too much time fixing this code. If you require it, please
+	 * upgrade to the IrDA stack in 2.5.X. Jean II
 	 */
 #ifdef CONFIG_IRTTY_SIR
 	irtty_init();
@@ -135,7 +139,7 @@
 #ifdef CONFIG_NSC_FIR
 	nsc_ircc_init();
 #endif
-#ifdef CONFIG_TOSHIBA_FIR
+#ifdef CONFIG_TOSHIBA_OLD
 	toshoboe_init();
 #endif
 #ifdef CONFIG_SMC_IRCC_FIR
@@ -162,6 +166,9 @@
 #ifdef CONFIG_EP7211_IR
  	ep7211_ir_init();
 #endif
+#ifdef CONFIG_MCP2120_DONGLE
+	mcp2120_init();
+#endif
 	return 0;
 }
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/irda/iriap_event.c linux-2.4.22-pre2/net/irda/iriap_event.c
--- linux-2.4.21/net/irda/iriap_event.c	2002-11-28 23:53:16.000000000 +0000
+++ linux-2.4.22-pre2/net/irda/iriap_event.c	2003-06-26 21:43:31.000000000 +0000
@@ -251,22 +251,25 @@
 static void state_s_make_call(struct iriap_cb *self, IRIAP_EVENT event, 
 			      struct sk_buff *skb) 
 {
+	struct sk_buff *tx_skb;
+
 	ASSERT(self != NULL, return;);
 
 	switch (event) {
 	case IAP_CALL_REQUEST:
-		skb = self->skb;
+		tx_skb = self->skb;
 		self->skb = NULL;
 		
-		irlmp_data_request(self->lsap, skb);
+		irlmp_data_request(self->lsap, tx_skb);
 		iriap_next_call_state(self, S_OUTSTANDING);
 		break;
 	default:
 		IRDA_DEBUG(0, "%s(), Unknown event %d\n", __FUNCTION__, event);
-		if (skb)
-			dev_kfree_skb(skb);
 		break;
 	}
+	/* Cleanup time ! */
+	if (skb)
+		dev_kfree_skb(skb);
 }
 
 /*
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/irda/irlan/irlan_eth.c linux-2.4.22-pre2/net/irda/irlan/irlan_eth.c
--- linux-2.4.21/net/irda/irlan/irlan_eth.c	2002-02-25 19:38:14.000000000 +0000
+++ linux-2.4.22-pre2/net/irda/irlan/irlan_eth.c	2003-06-26 21:43:14.000000000 +0000
@@ -31,6 +31,7 @@
 #include <linux/inetdevice.h>
 #include <linux/if_arp.h>
 #include <linux/random.h>
+#include <linux/module.h>
 #include <net/arp.h>
 
 #include <net/irda/irda.h>
@@ -61,6 +62,7 @@
 	dev->hard_start_xmit    = irlan_eth_xmit; 
 	dev->get_stats	        = irlan_eth_get_stats;
 	dev->set_multicast_list = irlan_eth_set_multicast_list;
+	SET_MODULE_OWNER(dev);
 
 	/* NETIF_F_DYNALLOC feature was set by irlan_eth_init() and would
 	 * cause the unregister_netdev() to do asynch completion _and_
@@ -122,8 +124,6 @@
 	self->disconnect_reason = 0;
 	irlan_client_wakeup(self, self->saddr, self->daddr);
 
-	irlan_mod_inc_use_count();
-
 	/* Make sure we have a hardware address before we return, so DHCP clients gets happy */
 	interruptible_sleep_on(&self->open_wait);
 	
@@ -148,8 +148,6 @@
 	/* Stop device */
 	netif_stop_queue(dev);
 	
-	irlan_mod_dec_use_count();
-
 	irlan_close_data_channel(self);
 	irlan_close_tsaps(self);
 
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/irda/irlap_event.c linux-2.4.22-pre2/net/irda/irlap_event.c
--- linux-2.4.21/net/irda/irlap_event.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/irda/irlap_event.c	2003-06-26 21:43:28.000000000 +0000
@@ -1869,7 +1869,7 @@
 				irlap_update_nr_received(self, info->nr);
 			
 				irlap_wait_min_turn_around(self, &self->qos_tx);
-				irlap_send_rr_frame(self, CMD_FRAME);
+				irlap_send_rr_frame(self, RSP_FRAME);
 			
 				irlap_start_wd_timer(self, self->wd_timeout);
 			}
@@ -2033,18 +2033,18 @@
 		irlap_update_nr_received(self, info->nr);
 		if (self->remote_busy) {
 			irlap_wait_min_turn_around(self, &self->qos_tx);
-			irlap_send_rr_frame(self, CMD_FRAME);
+			irlap_send_rr_frame(self, RSP_FRAME);
 		} else
-			irlap_resend_rejected_frames(self, CMD_FRAME);
+			irlap_resend_rejected_frames(self, RSP_FRAME);
 		irlap_start_wd_timer(self, self->wd_timeout);
 		break;
 	case RECV_SREJ_CMD:
 		irlap_update_nr_received(self, info->nr);
 		if (self->remote_busy) {
 			irlap_wait_min_turn_around(self, &self->qos_tx);
-			irlap_send_rr_frame(self, CMD_FRAME);
+			irlap_send_rr_frame(self, RSP_FRAME);
 		} else
-			irlap_resend_rejected_frame(self, CMD_FRAME);
+			irlap_resend_rejected_frame(self, RSP_FRAME);
 		irlap_start_wd_timer(self, self->wd_timeout);
 		break;
 	case WD_TIMER_EXPIRED:
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/irda/irlap_frame.c linux-2.4.22-pre2/net/irda/irlap_frame.c
--- linux-2.4.21/net/irda/irlap_frame.c	2002-08-03 00:39:46.000000000 +0000
+++ linux-2.4.22-pre2/net/irda/irlap_frame.c	2003-06-26 21:43:14.000000000 +0000
@@ -162,8 +162,8 @@
 	frame = (struct snrm_frame *) skb->data;
 	
 	if (skb->len >= sizeof(struct snrm_frame)) {
-		/* Copy the new connection address */
-		info->caddr = frame->ncaddr;
+		/* Copy the new connection address ignoring the C/R bit */
+		info->caddr = frame->ncaddr & 0xFE;
 
 		/* Check if the new connection address is valid */
 		if ((info->caddr == 0x00) || (info->caddr == 0xfe)) {
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/irda/irlmp_event.c linux-2.4.22-pre2/net/irda/irlmp_event.c
--- linux-2.4.21/net/irda/irlmp_event.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/irda/irlmp_event.c	2003-06-26 21:43:13.000000000 +0000
@@ -515,10 +515,10 @@
 
 		irlmp_next_lsap_state(self, LSAP_SETUP_PEND);
 
-		irlmp_do_lap_event(self->lap, LM_LAP_CONNECT_REQUEST, NULL);
-
 		/* Start watchdog timer (5 secs for now) */
 		irlmp_start_watchdog_timer(self, 5*HZ);
+
+		irlmp_do_lap_event(self->lap, LM_LAP_CONNECT_REQUEST, NULL);
 		break;
 	case LM_CONNECT_INDICATION:
 		if (self->conn_skb) {
@@ -529,8 +529,6 @@
 
 		irlmp_next_lsap_state(self, LSAP_CONNECT_PEND);
 
-		irlmp_do_lap_event(self->lap, LM_LAP_CONNECT_REQUEST, NULL);
-
 		/* Start watchdog timer
 		 * This is not mentionned in the spec, but there is a rare
 		 * race condition that can get the socket stuck.
@@ -543,10 +541,12 @@
 		 * a backup plan. 1 second is plenty (should be immediate).
 		 * Jean II */
 		irlmp_start_watchdog_timer(self, 1*HZ);
+
+		irlmp_do_lap_event(self->lap, LM_LAP_CONNECT_REQUEST, NULL);
 		break;
 	default:
-		IRDA_DEBUG(2, "%s(), Unknown event %s\n", 
-			 __FUNCTION__, irlmp_event[event]);
+		IRDA_DEBUG(1, "%s(), Unknown event %s on LSAP %#02x\n", 
+			   __FUNCTION__, irlmp_event[event], self->slsap_sel);
 		if (skb)
   			dev_kfree_skb(skb);
 		break;
@@ -604,8 +604,8 @@
 		irlmp_next_lsap_state(self, LSAP_DISCONNECTED);
 		break;
 	default:
-		IRDA_DEBUG(0, "%s(), Unknown event %s\n",
-			 __FUNCTION__, irlmp_event[event]);
+		IRDA_DEBUG(0, "%s(), Unknown event %s on LSAP %#02x\n", 
+			   __FUNCTION__, irlmp_event[event], self->slsap_sel);
 		if (skb)
  			dev_kfree_skb(skb);
 		break;
@@ -666,8 +666,8 @@
 		irlmp_next_lsap_state(self, LSAP_DISCONNECTED);
 		break;
 	default:
-		IRDA_DEBUG(0, "%s() Unknown event %s\n", 
-			 __FUNCTION__, irlmp_event[event]);
+		IRDA_DEBUG(0, "%s(), Unknown event %s on LSAP %#02x\n", 
+			   __FUNCTION__, irlmp_event[event], self->slsap_sel);
 		if (skb)
  			dev_kfree_skb(skb);
 		break;	
@@ -756,8 +756,8 @@
 		irlmp_disconnect_indication(self, reason, skb);
 		break;
 	default:
-		IRDA_DEBUG(0, "%s(), Unknown event %s\n", 
-			 __FUNCTION__, irlmp_event[event]);
+		IRDA_DEBUG(0, "%s(), Unknown event %s on LSAP %#02x\n", 
+			   __FUNCTION__, irlmp_event[event], self->slsap_sel);
 		if (skb)
  			dev_kfree_skb(skb);
 		break;	
@@ -829,8 +829,8 @@
 		irlmp_disconnect_indication(self, LM_CONNECT_FAILURE, NULL);
 		break;
 	default:
-		IRDA_DEBUG(0, "%s(), Unknown event %s\n", 
-			 __FUNCTION__, irlmp_event[event]);
+		IRDA_DEBUG(0, "%s(), Unknown event %s on LSAP %#02x\n", 
+			   __FUNCTION__, irlmp_event[event], self->slsap_sel);
 		if (skb)
  			dev_kfree_skb(skb);
 		break;	
@@ -888,8 +888,8 @@
 		irlmp_disconnect_indication(self, reason, NULL);
 		break;
 	default:
-		IRDA_DEBUG(0, "%s(), Unknown event %s\n", 
-			 __FUNCTION__, irlmp_event[event]);
+		IRDA_DEBUG(0, "%s(), Unknown event %s on LSAP %#02x\n", 
+			   __FUNCTION__, irlmp_event[event], self->slsap_sel);
 		if (skb)
  			dev_kfree_skb(skb);
 		break;	
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/irda/irsyms.c linux-2.4.22-pre2/net/irda/irsyms.c
--- linux-2.4.21/net/irda/irsyms.c	2002-11-28 23:53:16.000000000 +0000
+++ linux-2.4.22-pre2/net/irda/irsyms.c	2003-06-26 21:43:32.000000000 +0000
@@ -44,6 +44,7 @@
 #include <net/irda/wrapper.h>
 #include <net/irda/timer.h>
 #include <net/irda/parameters.h>
+#include <net/irda/crc.h>
 
 extern struct proc_dir_entry *proc_irda;
 
@@ -158,6 +159,8 @@
 
 EXPORT_SYMBOL(async_wrap_skb);
 EXPORT_SYMBOL(async_unwrap_char);
+EXPORT_SYMBOL(irda_calc_crc16);
+EXPORT_SYMBOL(irda_crc16_table);
 EXPORT_SYMBOL(irda_start_timer);
 EXPORT_SYMBOL(setup_dma);
 EXPORT_SYMBOL(infrared_mode);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/irda/irsysctl.c linux-2.4.22-pre2/net/irda/irsysctl.c
--- linux-2.4.21/net/irda/irsysctl.c	2002-11-28 23:53:16.000000000 +0000
+++ linux-2.4.22-pre2/net/irda/irsysctl.c	2003-06-26 21:43:18.000000000 +0000
@@ -35,7 +35,7 @@
 #define NET_IRDA 412 /* Random number */
 enum { DISCOVERY=1, DEVNAME, DEBUG, FAST_POLL, DISCOVERY_SLOTS,
        DISCOVERY_TIMEOUT, SLOT_TIMEOUT, MAX_BAUD_RATE, MIN_TX_TURN_TIME,
-       MAX_TX_DATA_SIZE, MAX_NOREPLY_TIME, WARN_NOREPLY_TIME,
+       MAX_TX_DATA_SIZE, MAX_TX_WINDOW, MAX_NOREPLY_TIME, WARN_NOREPLY_TIME,
        LAP_KEEPALIVE_TIME };
 
 extern int  sysctl_discovery;
@@ -48,6 +48,7 @@
 extern int  sysctl_max_baud_rate;
 extern int  sysctl_min_tx_turn_time;
 extern int  sysctl_max_tx_data_size;
+extern int  sysctl_max_tx_window;
 extern int  sysctl_max_noreply_time;
 extern int  sysctl_warn_noreply_time;
 extern int  sysctl_lap_keepalive_time;
@@ -69,6 +70,8 @@
 static int min_min_tx_turn_time = 0;
 static int max_max_tx_data_size = 2048;		/* See qos.c - IrLAP spec */
 static int min_max_tx_data_size = 64;
+static int max_max_tx_window = 7;		/* See qos.c - IrLAP spec */
+static int min_max_tx_window = 1;
 static int max_max_noreply_time = 40;		/* See qos.c - IrLAP spec */
 static int min_max_noreply_time = 3;
 static int max_warn_noreply_time = 3;		/* 3s == standard */
@@ -125,6 +128,9 @@
 	{ MAX_TX_DATA_SIZE, "max_tx_data_size", &sysctl_max_tx_data_size,
 	  sizeof(int), 0644, NULL, &proc_dointvec_minmax, &sysctl_intvec,
 	  NULL, &min_max_tx_data_size, &max_max_tx_data_size },
+	{ MAX_TX_WINDOW, "max_tx_window", &sysctl_max_tx_window,
+	  sizeof(int), 0644, NULL, &proc_dointvec_minmax, &sysctl_intvec,
+	  NULL, &min_max_tx_window, &max_max_tx_window },
 	{ MAX_NOREPLY_TIME, "max_noreply_time", &sysctl_max_noreply_time,
 	  sizeof(int), 0644, NULL, &proc_dointvec_minmax, &sysctl_intvec,
 	  NULL, &min_max_noreply_time, &max_max_noreply_time },
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/irda/parameters.c linux-2.4.22-pre2/net/irda/parameters.c
--- linux-2.4.21/net/irda/parameters.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/irda/parameters.c	2003-06-26 21:43:11.000000000 +0000
@@ -205,11 +205,13 @@
 {
 	irda_param_t p;
 	int n = 0;
+	int extract_len;	/* Real lenght we extract */
 	int err;
 
 	p.pi = pi;     /* In case handler needs to know */
 	p.pl = buf[1]; /* Extract lenght of value */
 	p.pv.i = 0;    /* Clear value */
+	extract_len = p.pl;	/* Default : extract all */
 
 	/* Check if buffer is long enough for parsing */
 	if (len < (2+p.pl)) {
@@ -221,18 +223,30 @@
 	/* 
 	 * Check that the integer length is what we expect it to be. If the
 	 * handler want a 16 bits integer then a 32 bits is not good enough
+	 * PV_INTEGER means that the handler is flexible.
 	 */
 	if (((type & PV_MASK) != PV_INTEGER) && ((type & PV_MASK) != p.pl)) {
 		ERROR(__FUNCTION__ "(), invalid parameter length! "
 		      "Expected %d bytes, but value had %d bytes!\n",
 		      type & PV_MASK, p.pl);
 		
-		/* Skip parameter */
-		return p.pl+2;
+		/* Most parameters are bit/byte fields or little endian,
+		 * so it's ok to only extract a subset of it (the subset
+		 * that the handler expect). This is necessary, as some
+		 * broken implementations seems to add extra undefined bits.
+		 * If the parameter is shorter than we expect or is big
+		 * endian, we can't play those tricks. Jean II */
+		if((p.pl < (type & PV_MASK)) || (type & PV_BIG_ENDIAN)) {
+			/* Skip parameter */
+			return p.pl+2;
+		} else {
+			/* Extract subset of it, fallthrough */
+			extract_len = type & PV_MASK;
+		}
 	}
 
 
-	switch (p.pl) {
+	switch (extract_len) {
 	case 1:
 		n += irda_param_unpack(buf+2, "b", &p.pv.i);
 		break;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/irda/qos.c linux-2.4.22-pre2/net/irda/qos.c
--- linux-2.4.21/net/irda/qos.c	2002-11-28 23:53:16.000000000 +0000
+++ linux-2.4.22-pre2/net/irda/qos.c	2003-06-26 21:43:31.000000000 +0000
@@ -70,13 +70,18 @@
  * 1.2, chapt 5.3.2.1, p41). But, this number includes the LAP header
  * (2 bytes), and CRC (32 bits at 4 Mb/s). So, for the I field (LAP
  * payload), that's only 2042 bytes. Oups !
- * I've had trouble trouble transmitting 2048 bytes frames with USB
- * dongles and nsc-ircc at 4 Mb/s, so adjust to 2042... I don't know
- * if this bug applies only for 2048 bytes frames or all negociated
- * frame sizes, but all hardware seem to support "2048 bytes" frames.
- * You can use the sysctl to play with this value anyway.
+ * My nsc-ircc hardware has troubles receiving 2048 bytes frames at 4 Mb/s,
+ * so adjust to 2042... I don't know if this bug applies only for 2048
+ * bytes frames or all negociated frame sizes, but you can use the sysctl
+ * to play with this value anyway.
  * Jean II */
 unsigned sysctl_max_tx_data_size = 2042;
+/*
+ * Maximum transmit window, i.e. number of LAP frames between turn-around.
+ * This allow to override what the peer told us. Some peers are buggy and
+ * don't always support what they tell us.
+ * Jean II */
+unsigned sysctl_max_tx_window = 7;
 
 static int irlap_param_baud_rate(void *instance, irda_param_t *param, int get);
 static int irlap_param_link_disconnect(void *instance, irda_param_t *parm, 
@@ -184,7 +189,19 @@
 {
 	__u16 msb = 0x8000;
 	int index = 15;   /* Current MSB */
-	
+
+	/* Check for buggy peers.
+	 * Note : there is a small probability that it could be us, but I
+	 * would expect driver authors to catch that pretty early and be
+	 * able to check precisely what's going on. If a end user sees this,
+	 * it's very likely the peer. - Jean II */
+	if (word == 0) {
+		WARNING("%s(), Detected buggy peer, adjust null PV to 0x1!\n",
+			 __FUNCTION__);
+		/* The only safe choice (we don't know the array size) */
+		word = 0x1;
+	}
+
 	while (msb) {
 		if (word & msb)
 			break;   /* Found it! */
@@ -335,10 +352,14 @@
 
 	/*
 	 * Make sure the mintt is sensible.
+	 * Main culprit : Ericsson T39. - Jean II
 	 */
 	if (sysctl_min_tx_turn_time > qos->min_turn_time.value) {
 		int i;
 
+		WARNING("%s(), Detected buggy peer, adjust mtt to %dus!\n",
+			 __FUNCTION__, sysctl_min_tx_turn_time);
+
 		/* We don't really need bits, but easier this way */
 		i = value_highest_bit(sysctl_min_tx_turn_time, min_turn_times,
 				      8, &qos->min_turn_time.bits);
@@ -400,6 +421,11 @@
 	if (qos->data_size.value > sysctl_max_tx_data_size)
 		/* Allow non discrete adjustement to avoid loosing capacity */
 		qos->data_size.value = sysctl_max_tx_data_size;
+	/*
+	 * Override Tx window if user request it. - Jean II
+	 */
+	if (qos->window_size.value > sysctl_max_tx_window)
+		qos->window_size.value = sysctl_max_tx_window;
 }
 
 /*
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/rose/af_rose.c linux-2.4.22-pre2/net/rose/af_rose.c
--- linux-2.4.21/net/rose/af_rose.c	2002-08-03 00:39:46.000000000 +0000
+++ linux-2.4.22-pre2/net/rose/af_rose.c	2003-06-26 21:43:21.000000000 +0000
@@ -1523,7 +1523,6 @@
 			dev_rose[i].priv = NULL;
 			unregister_netdev(&dev_rose[i]);
 		}
-		kfree(dev_rose[i].name);
 	}
 
 	kfree(dev_rose);
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/sched/cls_rsvp.h linux-2.4.22-pre2/net/sched/cls_rsvp.h
--- linux-2.4.21/net/sched/cls_rsvp.h	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/sched/cls_rsvp.h	2003-06-26 21:43:11.000000000 +0000
@@ -518,7 +518,7 @@
 
 	for (sp = &data->ht[h1]; (s=*sp) != NULL; sp = &s->next) {
 		if (dst[RSVP_DST_LEN-1] == s->dst[RSVP_DST_LEN-1] &&
-		    pinfo->protocol == s->protocol &&
+		    pinfo && pinfo->protocol == s->protocol &&
 		    memcmp(&pinfo->dpi, &s->dpi, sizeof(s->dpi)) == 0
 #if RSVP_DST_LEN == 4
 		    && dst[0] == s->dst[0]
@@ -560,9 +560,12 @@
 		goto errout;
 	memset(s, 0, sizeof(*s));
 	memcpy(s->dst, dst, sizeof(s->dst));
-	s->dpi = pinfo->dpi;
-	s->protocol = pinfo->protocol;
-	s->tunnelid = pinfo->tunnelid;
+
+	if (pinfo) {
+		s->dpi = pinfo->dpi;
+		s->protocol = pinfo->protocol;
+		s->tunnelid = pinfo->tunnelid;
+	}
 	for (sp = &data->ht[h1]; *sp; sp = &(*sp)->next) {
 		if (((*sp)->dpi.mask&s->dpi.mask) != s->dpi.mask)
 			break;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/sched/sch_cbq.c linux-2.4.22-pre2/net/sched/sch_cbq.c
--- linux-2.4.21/net/sched/sch_cbq.c	2001-12-21 17:42:06.000000000 +0000
+++ linux-2.4.22-pre2/net/sched/sch_cbq.c	2003-06-26 21:43:11.000000000 +0000
@@ -1056,11 +1056,9 @@
 		sch->stats.overlimits++;
 		if (q->wd_expires && !netif_queue_stopped(sch->dev)) {
 			long delay = PSCHED_US2JIFFIE(q->wd_expires);
-			del_timer(&q->wd_timer);
 			if (delay <= 0)
 				delay = 1;
-			q->wd_timer.expires = jiffies + delay;
-			add_timer(&q->wd_timer);
+			mod_timer(&q->wd_timer, jiffies + delay);
 			sch->flags |= TCQ_F_THROTTLED;
 		}
 	}
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/sched/sch_csz.c linux-2.4.22-pre2/net/sched/sch_csz.c
--- linux-2.4.21/net/sched/sch_csz.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/sched/sch_csz.c	2003-06-26 21:43:27.000000000 +0000
@@ -708,11 +708,9 @@
 	 */
 	if (q->wd_expires) {
 		unsigned long delay = PSCHED_US2JIFFIE(q->wd_expires);
-		del_timer(&q->wd_timer);
 		if (delay == 0)
 			delay = 1;
-		q->wd_timer.expires = jiffies + delay;
-		add_timer(&q->wd_timer);
+		mod_timer(&q->wd_timer, jiffies + delay);
 		sch->stats.overlimits++;
 	}
 #endif
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/sched/sch_htb.c linux-2.4.22-pre2/net/sched/sch_htb.c
--- linux-2.4.21/net/sched/sch_htb.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/sched/sch_htb.c	2003-06-26 21:43:10.000000000 +0000
@@ -9,6 +9,8 @@
  * Authors:	Martin Devera, <devik@cdi.cz>
  *
  * Credits (in time order) for older HTB versions:
+ *              Stef Coene <stef.coene@docum.org>
+ *			HTB support at LARTC mailing list
  *		Ondrej Kraus, <krauso@barr.cz> 
  *			found missing INIT_QDISC(htb)
  *		Vladimir Smelhaus, Aamer Akhter, Bert Hubert
@@ -19,7 +21,7 @@
  *			created test case so that I was able to fix nasty bug
  *		and many others. thanks.
  *
- * $Id: sch_htb.c,v 1.17 2003/01/29 09:22:18 devik Exp devik $
+ * $Id: sch_htb.c,v 1.20 2003/06/18 19:55:49 devik Exp devik $
  */
 #include <linux/config.h>
 #include <linux/module.h>
@@ -71,7 +73,7 @@
 #define HTB_HYSTERESIS 1/* whether to use mode hysteresis for speedup */
 #define HTB_QLOCK(S) spin_lock_bh(&(S)->dev->queue_lock)
 #define HTB_QUNLOCK(S) spin_unlock_bh(&(S)->dev->queue_lock)
-#define HTB_VER 0x3000a	/* major must be matched with number suplied by TC as version */
+#define HTB_VER 0x3000c	/* major must be matched with number suplied by TC as version */
 
 #if HTB_VER >> 16 != TC_HTB_PROTOVER
 #error "Mismatched sch_htb.c and pkt_sch.h"
@@ -217,6 +219,9 @@
     /* time of nearest event per level (row) */
     unsigned long near_ev_cache[TC_HTB_MAXDEPTH];
 
+    /* cached value of jiffies in dequeue */
+    unsigned long jiffies;
+
     /* whether we hit non-work conserving class during this dequeue; we use */
     int nwc_hit;	/* this to disable mindelay complaint in dequeue */
 
@@ -336,7 +341,7 @@
 static void htb_debug_dump (struct htb_sched *q)
 {
 	int i,p;
-	printk(KERN_DEBUG "htb*g j=%lu\n",jiffies);
+	printk(KERN_DEBUG "htb*g j=%lu lj=%lu\n",jiffies,q->jiffies);
 	/* rows */
 	for (i=TC_HTB_MAXDEPTH-1;i>=0;i--) {
 		printk(KERN_DEBUG "htb*r%d m=%x",i,q->row_mask[i]);
@@ -419,8 +424,8 @@
 	if ((delay <= 0 || delay > cl->mbuffer) && net_ratelimit())
 		printk(KERN_ERR "HTB: suspicious delay in wait_tree d=%ld cl=%X h=%d\n",delay,cl->classid,debug_hint);
 #endif
-	cl->pq_key = jiffies + PSCHED_US2JIFFIE(delay);
-	if (cl->pq_key == jiffies)
+	cl->pq_key = q->jiffies + PSCHED_US2JIFFIE(delay);
+	if (cl->pq_key == q->jiffies)
 		cl->pq_key++;
 
 	/* update the nearest event cache */
@@ -598,7 +603,7 @@
     long toks;
 
     if ((toks = (cl->ctokens + *diff)) < (
-#ifdef HTB_HYSTERESIS
+#if HTB_HYSTERESIS
 	    cl->cmode != HTB_CANT_SEND ? -cl->cbuffer :
 #endif
        	    0)) {
@@ -606,7 +611,7 @@
 	    return HTB_CANT_SEND;
     }
     if ((toks = (cl->tokens + *diff)) >= (
-#ifdef HTB_HYSTERESIS
+#if HTB_HYSTERESIS
 	    cl->cmode == HTB_CAN_SEND ? -cl->buffer :
 #endif
 	    0))
@@ -809,7 +814,7 @@
 				       cl->classid, diff,
 				       (unsigned long long) q->now,
 				       (unsigned long long) cl->t_c,
-				       jiffies);
+				       q->jiffies);
 			diff = 1000;
 		}
 #endif
@@ -852,6 +857,7 @@
  *
  * Scans event queue for pending events and applies them. Returns jiffies to
  * next pending event (0 for no event in pq).
+ * Note: Aplied are events whose have cl->pq_key <= jiffies.
  */
 static long htb_do_events(struct htb_sched *q,int level)
 {
@@ -866,9 +872,9 @@
 		while (p->rb_left) p = p->rb_left;
 
 		cl = rb_entry(p, struct htb_class, pq_node);
-		if (cl->pq_key - (jiffies+1) < 0x80000000) {
-			HTB_DBG(8,3,"htb_do_ev_ret delay=%ld\n",cl->pq_key - jiffies);
-			return cl->pq_key - jiffies;
+		if (cl->pq_key - (q->jiffies+1) < 0x80000000) {
+			HTB_DBG(8,3,"htb_do_ev_ret delay=%ld\n",cl->pq_key - q->jiffies);
+			return cl->pq_key - q->jiffies;
 		}
 		htb_safe_rb_erase(p,q->wait_pq+level);
 		diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32)cl->mbuffer, 0);
@@ -879,7 +885,7 @@
 				       cl->classid, diff,
 				       (unsigned long long) q->now,
 				       (unsigned long long) cl->t_c,
-				       jiffies);
+				       q->jiffies);
 			diff = 1000;
 		}
 #endif
@@ -986,9 +992,8 @@
 			printk(KERN_INFO "HTB delay %ld > 5sec\n", delay);
 		delay = 5*HZ;
 	}
-	del_timer(&q->timer);
-	q->timer.expires = jiffies + delay;
-	add_timer(&q->timer);
+	/* 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++;
 	HTB_DBG(3,1,"htb_deq t_delay=%ld\n",delay);
@@ -1004,6 +1009,7 @@
 	int evs_used = 0;
 #endif
 
+	q->jiffies = jiffies;
 	HTB_DBG(3,1,"htb_deq dircnt=%d qlen=%d\n",skb_queue_len(&q->direct_queue),
 			sch->q.qlen);
 
@@ -1023,14 +1029,14 @@
 		/* common case optimization - skip event handler quickly */
 		int m;
 		long delay;
-		if (jiffies - q->near_ev_cache[level] < 0x80000000 || 0) {
+		if (q->jiffies - q->near_ev_cache[level] < 0x80000000 || 0) {
 			delay = htb_do_events(q,level);
-			q->near_ev_cache[level] += delay ? delay : HZ;
+			q->near_ev_cache[level] = q->jiffies + (delay ? delay : HZ);
 #ifdef HTB_DEBUG
 			evs_used++;
 #endif
 		} else
-			delay = q->near_ev_cache[level] - jiffies;	
+			delay = q->near_ev_cache[level] - q->jiffies;	
 		
 		if (delay && min_delay > delay) 
 			min_delay = delay;
@@ -1049,8 +1055,8 @@
 #ifdef HTB_DEBUG
 	if (!q->nwc_hit && min_delay >= 10*HZ && net_ratelimit()) {
 		if (min_delay == LONG_MAX) {
-			printk(KERN_ERR "HTB: dequeue bug (%d), report it please !\n",
-					evs_used);
+			printk(KERN_ERR "HTB: dequeue bug (%d,%lu,%lu), report it please !\n",
+					evs_used,q->jiffies,jiffies);
 			htb_debug_dump(q);
 		} else 
 			printk(KERN_WARNING "HTB: mindelay=%ld, some class has "
@@ -1059,7 +1065,7 @@
 #endif
 	htb_delay_by (sch,min_delay > 5*HZ ? 5*HZ : min_delay);
 fin:
-	HTB_DBG(3,1,"htb_deq_end %s j=%lu skb=%p\n",sch->dev->name,jiffies,skb);
+	HTB_DBG(3,1,"htb_deq_end %s j=%lu skb=%p\n",sch->dev->name,q->jiffies,skb);
 	return skb;
 }
 
@@ -1424,7 +1430,7 @@
 	parent = parentid == TC_H_ROOT ? NULL : htb_find (parentid,sch);
 
 	hopt = RTA_DATA(tb[TCA_HTB_PARMS-1]);
-	HTB_DBG(0,1,"htb_chg cl=%p, clid=%X, opt/prio=%d, rate=%u, buff=%d, quant=%d\n", cl,cl?cl->classid:0,(int)hopt->prio,hopt->rate.rate,hopt->buffer,hopt->quantum);
+	HTB_DBG(0,1,"htb_chg cl=%p(%X), clid=%X, parid=%X, opt/prio=%d, rate=%u, buff=%d, quant=%d\n", cl,cl?cl->classid:0,classid,parentid,(int)hopt->prio,hopt->rate.rate,hopt->buffer,hopt->quantum);
 	rtab = qdisc_get_rtab(&hopt->rate, tb[TCA_HTB_RTAB-1]);
 	ctab = qdisc_get_rtab(&hopt->ceil, tb[TCA_HTB_CTAB-1]);
 	if (!rtab || !ctab) goto failure;
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/sched/sch_ingress.c linux-2.4.22-pre2/net/sched/sch_ingress.c
--- linux-2.4.21/net/sched/sch_ingress.c	2002-11-28 23:53:16.000000000 +0000
+++ linux-2.4.22-pre2/net/sched/sch_ingress.c	2003-06-26 21:43:30.000000000 +0000
@@ -15,10 +15,10 @@
 #include <linux/rtnetlink.h>
 #include <linux/netfilter_ipv4.h>
 #include <linux/netfilter.h>
+#include <linux/smp.h>
 #include <net/pkt_sched.h>
 #include <asm/byteorder.h>
 #include <asm/uaccess.h>
-#include <asm/smp.h>
 #include <linux/kmod.h>
 #include <linux/stat.h>
 #include <linux/interrupt.h>
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.21/net/sunrpc/svcsock.c linux-2.4.22-pre2/net/sunrpc/svcsock.c
--- linux-2.4.21/net/sunrpc/svcsock.c	2003-06-26 21:45:20.000000000 +0000
+++ linux-2.4.22-pre2/net/sunrpc/svcsock.c	2003-06-26 21:43:11.000000000 +0000
@@ -595,8 +595,17 @@
 	dprintk("svc: socket %p TCP (listen) state change %d\n",
 			sk, sk->state);
 
-	if  (sk->state != TCP_ESTABLISHED) {
-		/* Aborted connection, SYN_RECV or whatever... */
+	if  (sk->state != TCP_LISTEN) {
+		/*
+		 * This callback may called twice when a new connection
+		 * is established as a child socket inherits everything
+		 * from a parent LISTEN socket.
+		 * 1) data_ready method of the parent socket will be called
+		 *    when one of child sockets become ESTABLISHED.
+		 * 2) data_ready method of the child socket may be called
+		 *    when it receives data before the socket is accepted.
+		 * In case of 2, we should ignore it silently.
+		 */
 		goto out;
 	}
 	if (!(svsk = (struct svc_sock *) sk->user_data)) {
@@ -816,8 +825,12 @@
 		if ((len = svc_recvfrom(rqstp, &iov, 1, want)) < 0)
 			goto error;
 		svsk->sk_tcplen += len;
-		if (len < want)
-			return 0;
+		if (len < want) {
+			dprintk("svc: short recvfrom while reading record length (%d of %d)\n",
+			        len, want);
+			svc_sock_received(svsk);
+			return -EAGAIN; /* record header not complete */
+		}
 
 		svsk->sk_reclen = ntohl(svsk->sk_reclen);
 		if (!(svsk->sk_reclen & 0x80000000)) {
@@ -932,6 +945,7 @@
 svc_tcp_init(struct svc_sock *svsk)
 {
 	struct sock	*sk = svsk->sk_sk;
+	struct tcp_opt  *tp = &(sk->tp_pinfo.af_tcp);
 
 	svsk->sk_recvfrom = svc_tcp_recvfrom;
 	svsk->sk_sendto = svc_tcp_sendto;
@@ -948,6 +962,8 @@
 		svsk->sk_reclen = 0;
 		svsk->sk_tcplen = 0;
 
+		tp->nonagle = 1;        /* disable Nagle's algorithm */
+
 		/* initialise setting must have enough space to
 		 * receive and respond to one request.  
 		 * svc_tcp_recvfrom will re-adjust if necessary
@@ -957,6 +973,8 @@
 				    3 * svsk->sk_server->sv_bufsz);
 
 		set_bit(SK_CHNGBUF, &svsk->sk_flags);
+		if (sk->state != TCP_ESTABLISHED) 
+			set_bit(SK_CLOSE, &svsk->sk_flags);
 	}
 
 	return 0;
